Repository navigation
Add an inline Distinct test where only Distinct separates the symbols - #121
Open
HowardvanRooijen wants to merge 1 commit into
Open
HowardvanRooijen wants to merge 1 commit into
HowardvanRooijen wants to merge 1 commit into
Conversation
The existing satisfiable inline test sets the two symbols to different values, so it passes without Distinct. In the new test, the two symbols have the same range of two values. Only Distinct keeps them different. The test comes from a review of #111. The other tests in #111 duplicate tests that are already in the suite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the added model-independent regression coverage of inline Z3Methods.Distinct.
No open issues 🎉
What changed in this PR
Adds focused regression coverage for inline Z3Methods.Distinct, complementing existing tests with a case where neither symbol is fixed to a particular value.
Changes:
- Adds a test with two integer symbols sharing the range
[0, 1], where onlyDistinctrequires different values. - Checks non-null results, inequality, and range membership without depending on which satisfying model Z3 returns.
| File | Description |
|---|---|
solutions/Z3.Linq.Tests/DistinctInlineArrayTheoremTests.cs |
Adds a model-independent test of Distinct over two symbols sharing a range. |
Review effort: Balanced
Code Coverage Summary Report - Linux (No TFM)Summary
CoverageZ3.Linq - 93.6%
Z3.Linq.Examples - 70.7%
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds one test to
DistinctInlineArrayTheoremTests.cs. The test comes from a review of the external PR #111.The new test is
Distinct_InlineSymbolsFreeInASharedRange_ForcesThemApart. The two symbols have the same range of two values, and no constraint sets their values. OnlyZ3Methods.Distinctkeeps the two values different.The existing satisfiable test,
Distinct_InlineDistinctSymbols_Solves, sets the two symbols to different values. Thus, that test passes withoutDistinct. The new test fails withoutDistinct.The test obeys the determinism rule of the suite. Two models satisfy the theorem: (0, 1) and (1, 0). Thus, the test checks only that the values are different and in the range. It does not check which model Z3 gives.
Why this PR does not add the other tests from #111
PR #111 adds 10 tests in a new file,
BasicTheoremTests.cs. The suite onmainalready has tests for these behaviors. The links go to commit964f177.Tests that have almost the same test on
mainmainOptimize_Maximize_ReturnsUpperBoundOptimizationTests.cs:42Optimize_Maximize_ReturnsTheLargestSatisfyingValueOptimize_Minimize_ReturnsLowerBoundOptimizationTests.cs:214Optimize_MinimizingIsNotJustTheFirstSatisfyingModelSolve_ContradictoryConstraints_ReturnsNullUnsatisfiabilityTests.cs:122TrySolve_UnsatisfiableReferenceTypeTheorem_ReturnsFalse&&(X1 > 4 && X1 < 2).TheoremSolveTests.cs:51Solve_UnsatisfiableTheorem_ReturnsNullwhereclauses.Solve()givesnull.Solve_ChainedWhereClauses_ConjoinOptimizationTests.cs:237Optimize_CalledTwiceOnTheSameTheorem_LeavesItReusable.Where(>= 1).Where(<= 4).Solve(), thenShouldBeInRange(1, 4).TheoremCompositionTests.cs:65Where_OriginalTheorem_RemainsIndependentlySolvableWherethat contradicts the firstWheregivesnull. The test in #111 passes also if the code does not use the secondWhere.NewTheorem_DummyOverload_SolvesLikeParameterlessTheoremCompositionTests.cs:168NewTheorem_WithATemplateInstance_InfersTheEnvironmentTypeTests that a set of tests on
maincoversmainSolve_IntTheorem_ReturnsModelInRangeDistinctSelectorTheoremTests.cs:30Distinct_SelectorProducingDistinctTerms_SolvesX1 > 10 && X1 < 14) withShouldBeInRange(11, 13).TheoremCompositionTests.cs:168NewTheorem_WithATemplateInstance_InfersTheEnvironmentTypeSolve_TupleTheorem_ReadsBackEverySymbolEnvironmentTypeTests.cs:290Solve_ValueTupleWithDouble_PopulatesEveryFieldand:309Solve_ValueTupleWithString_PopulatesEveryFieldTheoremSolveTests.cs:196Solve_LinearSystemWithForcedDifference_ForcesTheSameValuesInEveryModelSolve_BoolTheorem_SatisfiesPropositionTheoremSolveTests.cs:67Solve_ContradictoryBooleanTheorem_ReturnsNull&&and!.EnvironmentTypeTests.cs:93Solve_AnonymousTypeEnvironment_PopulatesEveryPropertytruefor a Boolean property of an anonymous type.EnvironmentTypeTests.cs:326Solve_RecordEnvironment_PopulatesEveryPropertyXand!Ygivetrueandfalse. This test uses a record.Solve_Distinct_ForcesDifferentValuesDistinctInlineArrayTheoremTests.cs:25Distinct_InlineDistinctSymbols_SolvesDistinct.DistinctInlineArrayTheoremTests.cs:42Distinct_InlineSymbolsConstrainedEqual_IsUnsatisfiableDistincttogether withX1 == X2givesnull.Distinctis the only constraint that keeps the two values different.Optimize_Minimize_OverTupleObjective_SolvesOptimizationTests.cs:185Optimize_LinearProgramOverDoubles_FindsTheKnownOptimumorderbyminimizes an objective of two fields (20.0 * t.sa + 15.0 * t.vz) on a(double sa, double vz)tuple.OptimizationTests.cs:82OrderBy_ProducesTheSameResultAsMinimizeorderbygives the same result asOptimize(Optimization.Minimize, ...).OptimizationTests.cs:164Optimize_ObjectiveOverSeveralSymbols_MinimizesTheirCombinationOptimizeminimizesX1 + X2. The test checks only the sum.The tuple test in #111 uses
intfields. The test atOptimizationTests.cs:185usesdoublefields. The two types use the same code for the objective and the tuple. Thus, anintversion adds no coverage.Test results
dotnet build solutions/Z3.Linq.slnx: 0 warnings, 0 errors.Distinct, the new test fails. Z3 gives the same value toX1andX2.Distinct, all tests pass: 369 passed, 0 failed.🤖 Generated with Claude Code