Class WitnessEnumerator
This is the ∃-polarity payoff: the census (M1) says an obligation is undischarged; this turns "undischarged" into a specific witnessing input a developer can paste into a test. It rests on the small-model premise (proven by spike S3, cost interactive) — if a contract can be violated at all it can almost always be violated by one of a type's few representative edge values, so enumerating the value-class vocabulary rather than a full domain is both sound-enough and fast.
Two sources of representatives:
- Built-in leaf types — the real
InputVarietyModelliteral pool viaBuiltinTypeClassModels.classIdsFor(String)(Example 1:count != 0→ZERO="0"). - User constrained types over
[lo,hi]— the MIN/NEAR_MIN/NEAR_MAX/MAX edges of the constraint window (Example 3:base + 20 <= 100over[0,100]→NEAR_MAX=99, since99 + 20 > 100).
Proven by spike S3b (see EK9_SYMBOLIC_SCANNER_SPIKE_REFERENCE.md §5.3). Net-new for
production, tracked: seed InputVarietyModel.literalFor(String, String) for the other ~16 built-ins
(mechanical); read the [lo,hi] window from a user constrained type's constraint AST instead
of being handed it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA concrete counterexample: which value-class it came from, its EK9-source literal, and its value. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<WitnessEnumerator.Witness> constraintEdges(long lo, long hi) The MIN/NEAR_MIN/NEAR_MAX/MAX edge witnesses of a[lo,hi]window, de-duplicated by value.static Optional<WitnessEnumerator.Witness> firstViolatingBuiltin(String typeName, LongPredicate obligation) Built-in leaf: enumerate the realInputVarietyModelpool and return the first value for whichobligationdoes NOT hold (i.e.static Optional<WitnessEnumerator.Witness> firstViolatingConstrained(long lo, long hi, LongPredicate obligation) User constrained type over[lo,hi]: enumerate the constraint-window edges and return the first violator.
-
Method Details
-
firstViolatingBuiltin
public static Optional<WitnessEnumerator.Witness> firstViolatingBuiltin(String typeName, LongPredicate obligation) Built-in leaf: enumerate the realInputVarietyModelpool and return the first value for whichobligationdoes NOT hold (i.e. the first violator).- Parameters:
typeName- the built-in simple type name (e.g."Integer")obligation- the safe condition that should hold for every input; the witness is where it fails- Returns:
- the first violating witness, or empty if every representative satisfies the obligation
-
firstViolatingConstrained
public static Optional<WitnessEnumerator.Witness> firstViolatingConstrained(long lo, long hi, LongPredicate obligation) User constrained type over[lo,hi]: enumerate the constraint-window edges and return the first violator.- Parameters:
lo- the inclusive lower bound of the constraint windowhi- the inclusive upper bound of the constraint windowobligation- the safe condition that should hold; the witness is where it fails- Returns:
- the first violating edge witness, or empty if every edge satisfies the obligation
-
constraintEdges
The MIN/NEAR_MIN/NEAR_MAX/MAX edge witnesses of a[lo,hi]window, de-duplicated by value.
-