Skip to content

Add instanceFormat/certificateFormat declarations to PARTITION - #490

Open
Trosper3 wants to merge 4 commits into
CSharpAPIfrom
backfill/partition-format
Open

Add instanceFormat/certificateFormat declarations to PARTITION#490
Trosper3 wants to merge 4 commits into
CSharpAPIfrom
backfill/partition-format

Conversation

@Trosper3

Copy link
Copy Markdown
Contributor

Summary

  • PARTITION never adopted the self-describing instance/certificate format pattern (Interfaces/ProblemInterface.cs) and had no dedicated test file.
  • Declares instanceFormat and certificateFormat describing the two-list-partition (S1),(S2) certificate, on PARTITION_Class.cs.
  • Found while writing this: S is parsed with the SPADE pattern "{N | N is set}", so a duplicate value in the raw instance string collapses to one element. defaultInstance's "...,12,15,33,12,11,..." actually parses to an 11-element set (one 12), not the 12-element multiset the class's problemDefinition prose describes. instanceFormat documents the actual (set) parsing behavior rather than the aspirational multiset wording.
  • Adds a new PARTITION_Tests.cs covering the format declarations, including a check that the certificate example quoted in the format string ((33,21,15),(1,7,12,11,5,6,9,18)) actually verifies true against defaultInstance via the real verifier.

Closes #445

Test plan

  • dotnet test redux-tests/redux-tests.csproj --filter "FullyQualifiedName~PARTITION" — 4/4 passing

PARTITION never adopted the self-describing instance/certificate
format pattern (Interfaces/ProblemInterface.cs) and had no dedicated
test file. Declares instanceFormat and certificateFormat describing
the two-list-partition certificate. Documents that S is parsed as a
set ("N is set"), so a duplicate value in the raw instance string
collapses to one element -- defaultInstance's "12,12" is actually a
single 11-element set, not a 12-element multiset, despite
problemDefinition's "multiset" wording.

Adds a new PARTITION_Tests.cs covering the format declarations,
including a check that the certificate example quoted in the format
string actually verifies true against defaultInstance.
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown

Redux Build System — CI Report

dotnet · commit 12bc4b2

Operation Status Summary Time
audit no known vulnerabilities 6.7s
format-check all files formatted 20.4s
lint 0 issues 32.1s
typecheck ⏭️ covered by lint (dotnet build)
unit-test 910 passed · coverage 70% (min 80%) 42.0s
build built local/redux:ci · 234MB 36.4s
integration-test ⏭️ no [integration] command
push ⏭️ not implemented

Overall: ❌ 4 passed · 1 failed · 3 skipped

…tern

Extracts the constructor's inline StringParser grammar into a named
InstanceGrammar const, and adds CertificateGrammar/CertificateExample
consts to PartitionVerifier. instanceFormat/certificateFormat are now
interpolated from these plus _defaultInstance, instead of
hand-duplicated prose.

Also merges in CSharpAPI (including #501) to pick up the dotnet-format
gate this branch predates.
@Trosper3
Trosper3 requested a review from wrigjl August 31, 2026 18:03
Certificates come in two shapes: the documented bare pair
"(S1),(S2)" (no enclosing collection) and PartitionBruteForce's actual
output, which wraps that pair in an outer "{...}". Handled the same way
as CliqueCoverVerifier's identical ambiguity: try parsing the raw
string first, fall back to wrapping it in parens if that isn't a valid
top-level collection.

As a side effect this fixes the pre-existing bug (noted in open PR
#517's body) where a malformed certificate lacking "),(" -- e.g. "{}",
which is exactly what the solver returns for an infeasible instance --
threw IndexOutOfRangeException instead of returning false; assertCount
now fails gracefully into the try/catch.

Checked open PR #531 (adds test coverage here) first: its hardcoded
certificate literals ("{}", "{(1,2),(3)}") match the solver's existing
wrapped-output convention, so this parsing swap doesn't conflict.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015bSCoT5AU2UvNdHY4woxi1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backfill instanceFormat/certificateFormat: NPC_PARTITION

1 participant