A negation is no longer answered with the empty set (#1127) - #1131
Merged
Conversation
StatementSolver.Solve had arms for equality, the connectives, the four
comparisons, membership, `provided` and `piecewise` -- and none for `not`, so
every negation fell through to `Set.Empty`. The empty set is a positive claim,
*no x satisfies this*, and it was false of every one of them:
not (x = 1) { }
not (x > 1) { }
not (x in RR) { }
not not (x = 1) { }
not (x > 1 or x < -1) { }
This is the defect #1036 fixed for equations, left standing for negation.
The negation is now pushed inward as far as there is an arm for it, and named
as a set-builder where there is not:
not (x = 1) { x : not x = 1 }
not (x > 1) (-oo; 1]
not (x in RR) { x : not x in RR }
not not (x = 1) { 1 }
not (x > 1 or x < -1) [-1; 1]
Inward is unambiguous *here* in a way it is not in the simplifier, which is why
it is done in the solver and not as a rule: this switch has arms for the
connectives and for the comparisons and none for `not`, so inward is the
direction that reaches one. A negated comparison is a comparison, and
RewriteRules.InequalityEquality is where that is already written down -- asking
it rather than restating it keeps the two from drifting.
What no arm reaches is answered as written rather than as nothing, which is the
shape #1126 introduced for implications: `{ x : not x in RR }` names the
non-real complex numbers exactly.
26 tests, asserting which values the answers admit rather than the shape they
are written in; 21 of the 26 fail against the previous behaviour.
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.
Closes #1127.
The defect
StatementSolver.Solvehas arms for equality, the connectives, the four comparisons, membership,providedandpiecewise. It had none fornot, so every negation fell through to_ => Set.Empty.The empty set is a positive claim — no x satisfies this — and it was false of all of these:
This is the defect #1036 fixed for equations, left standing for negation.
The fix
The negation is pushed inward as far as there is an arm for it, and named as a set-builder where
there is not:
Three things, in order:
unambiguous here in a way it is not in the simplifier — where it can grow an expression, which
is why no rule set does it — and that is the reason it lives in the solver: this switch has arms
for the connectives and for the comparisons and none for
not, so inward is the direction thatreaches one.
RewriteRules.InequalityEqualityis where that isalready written down. Asking it rather than restating it keeps the two from drifting.
{ x : not x in RR }names the non-real complex numbers exactly and asserts of them only whatthe statement says.
Tests
26, in
NegationIsNotTheEmptySetTest. They assert which values the answers admit rather thanthe shape the answers are written in, so a later rewrite that says the same thing better does not
fail them —
not (x > 1)is checked to contain 0 and 1 and not 5, and to equal the answer tox <= 1, rather than to print as(-oo; 1].21 of the 26 fail against the previous behaviour.
Measured
OneSidedLimitTest.ADifferenceOfReciprocalLogarithms(side: Left),which fails identically on plain
masterwith none of this branch's changes, and passes whenrun alone. Controlled for by running the full suite on
masterat5351d0cf: same one failure,9185 passed. Pre-existing, and not something this branch touches.
BREAKING-CHANGES.mdentries, both measured on a build.