Skip to content

An absolute value cannot equal a negative (#812) - #815

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
fix/812-abs-inversion-guard
Aug 8, 2026
Merged

An absolute value cannot equal a negative (#812)#815
Rafael-SOWNet merged 1 commit into
masterfrom
fix/812-abs-inversion-guard

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Collaborator

Closes #812. Partly closes #318 — see below.

"abs(x) = -1".ToEntity().Solve("x")
// was   { -e ^ (i * r_1) provided r_1 in RR }
// is    { }

The old answer was wrong, not merely loose

At r_1 = 0 its member is -1, and abs(-1) is 1, not -1. Every member has modulus 1 and solves nothing.

Cause

abs(f(x)) = value is inverted by writing f(x) as value * e ^ (i * r) over real r — the circle of radius |value|. That solves the equation only where |value| and value agree, which is where value is real and not negative. The condition saying so was missing.

It is now carried alongside the one on r:

abs(x) = -1 { }fixed
abs(x) = 3 { 3 * e ^ (i * r_1) provided r_1 in RR } ← unchanged
abs(x) = 0 { 0 provided r_1 in RR } ← unchanged
abs(x) = a { a * e ^ (i * r_1) provided r_1 in RR and a >= 0 }new condition

A decidable negative collapses the set to empty; a decidable non-negative drops the condition and leaves the previous answer untouched; a symbolic one is kept rather than guessed at.

This is the missing half of #318

#318 asks for exactly this inversion and names both halves in one sentence:

|x| = a should return { a e ^ (i * r) : r in RR **and a >= 0** }

The r in RR half was already implemented. This is the a >= 0 half. What remains of #318 after this is only the internal return type — Invert is internal and InvertNode is private protected, so that part breaks nobody and is not urgent. Detail in this comment.

Tests

Solutions are checked by substituting them back with the circle's parameter given a value, not by comparing printed form.

Checked for teeth against origin/master: four of the seven fail without the fix. The three that pass on both sides are the ones asserting the previously-correct answers are unchanged, which is what they are for.

Verification

5558 unit tests, 130 F# tests. casbench 113/117 with 0 wrong, propcheck 0 failures, rootcheck 596/596, simpsweep 10463/10463.

🤖 Generated with Claude Code

    "abs(x) = -1".ToEntity().Solve("x")
    was  { -e ^ (i * r_1) provided r_1 in RR }
    is   { }

The old answer was wrong rather than merely loose. At r_1 = 0 its member is
-1, and abs(-1) is 1, not -1; every member has modulus 1 and solves nothing.

abs(f(x)) = value is inverted by writing f(x) as value * e ^ (i * r) over
real r, which is the circle of radius |value|. That solves the equation only
where |value| and value agree -- where value is real and not negative -- and
the condition saying so was missing. It is now carried alongside the one on
r, so a decidable negative collapses the set to empty, a decidable
non-negative drops it and leaves the previous answer untouched, and a
symbolic one is kept:

    abs(x) = 3    { 3 * e ^ (i * r_1) provided r_1 in RR }            unchanged
    abs(x) = 0    { 0 provided r_1 in RR }                            unchanged
    abs(x) = a    { a * e ^ (i * r_1) provided r_1 in RR and a >= 0 }  new condition

The last of those is what #318 asked this inversion to return, in the
sentence that named both halves of it; the r in RR half was already
implemented and the a >= 0 half is this.

The tests check solutions by substituting them back with the circle's
parameter given a value, not by comparing printed form. Checked for teeth
against origin/master: four of the seven fail without the fix, and the three
that do not are the ones asserting the previously-correct answers are
unchanged.

5558 unit tests and 130 F# tests pass; casbench 113/117 with 0 wrong,
propcheck 0 failures, rootcheck 596/596, simpsweep 10463/10463.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet force-pushed the fix/812-abs-inversion-guard branch from cbfca0a to c86c0bf Compare August 8, 2026 12:35
@Rafael-SOWNet
Rafael-SOWNet merged commit 197fc85 into master Aug 8, 2026
25 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the fix/812-abs-inversion-guard branch August 8, 2026 12:54
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.

abs(x) = -1 returns a non-empty set whose members do not satisfy the equation IEnumerable<Entity> -> Set in InvertNode

1 participant