Skip to content

Sixty-five arms become sixty-five rules: InequalityEquality is data (#746) - #1082

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
feat/inequality-is-data
Aug 26, 2026
Merged

Sixty-five arms become sixty-five rules: InequalityEquality is data (#746)#1082
Rafael-SOWNet merged 1 commit into
masterfrom
feat/inequality-is-data

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Collaborator

The set with the most arms after Common, and the one where nothing collapses: it writes
out shapes rather than orientations, so a commutative pattern has nothing to gather. Sixty-five
arms are sixty-five rules.

What it needs that a shape does not say

  • The two De Morgan arms are a fold over a chain of any length. not (a and b and c)
    negates each operand and joins them by the dual connective — not a shape. The rule matches
    the chain; PushNotInside and its guard MayPushNotInside stay in
    Patterns.EqualityInequality.cs and both forms ask them.
  • The excluded-middle pair reads two bound comparisons against each other — same operands,
    opposite or exhaustive signs — which is a when over the bindings rather than a shape.
  • The conditions those attach are about where the ordering exists at all, since i < 0 is
    NaN rather than false (p or not p depends on which side the not is written, and reduces to True where the proposition is undefined #876). Asked of the same helpers, never restated.

Measured

allocated
SolveMediumHard, master 165,054,016 B
SolveMediumHard, here 165,054,016 B — identical to the byte
SimplifyEasy 129,648 B on both

What the transcription found

Two wrong answers, both from writing the rules out as data — which makes the correspondence
between a pattern and its replacement something you have to state.

  1. Four or-with-equality arms carried their neighbour's comparison, so
    (y < x) or (x = y) simplified to x <= y — its own negation off the diagonal. Fixed
    first, in Four or-with-equality rules gave the opposite comparison (#1077) #1078, so this set agrees with a switch that is right.
  2. x! = 0 is answered False unconditioned, including at the negative integers where
    x! has a pole and the statement is NaN. The switch reads
    Factorialf({ DomainCondition: var condition }), a property pattern on the argument
    rather than on the factorial. Filed as x! = 0 simplifies to False, including where the factorial has a pole #1081 and not fixed here — this rule is faithful
    to the arm, which is what keeps the conversion mechanical. It was the single disagreement
    out of 3,485 expressions in the agreement run.

Part of #746 tier 1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bjumi5K7fg8yx6UK1mZTQd

The set with the most arms after `Common`, and the one where nothing collapses: it
writes out shapes rather than orientations, so a commutative pattern has nothing to
gather. Sixty-five arms are sixty-five rules, and the gain is elsewhere.

Three things it needs that a shape does not say, and each stays where it was written:

* The two De Morgan arms are a **fold over a chain of any length** -- `not (a and b and
  c)` negates each operand and joins them by the dual connective. That is not a shape,
  so the rule matches the chain and `PushNotInside` in `Patterns.EqualityInequality.cs`
  does the fold, asked by both forms. Its guard is `MayPushNotInside`, likewise.
* The excluded-middle pair reads **two bound comparisons against each other** -- same
  operands, opposite or exhaustive signs -- which is a `when` over the bindings.
* The conditions those attach are about where the ordering is defined at all, since
  `i < 0` is `NaN` rather than false, and they are asked of the same helpers.

Measured: `SolveMediumHard` allocates 165,054,016 B with this wired, which is master's
figure to the byte, and `SimplifyEasy` 129,648 B likewise.

**The transcription found a second wrong answer**, and the agreement run over 3,485
expressions reported it as its only disagreement. The `switch` reads
`Factorialf({ DomainCondition: var condition })`, which is a property pattern on the
factorial's *argument* rather than on the factorial -- so `x! = 0` is answered `False`
unconditioned, including at the negative integers where `x!` has a pole and the
statement is `NaN`. Filed as #1081 rather than fixed here: this rule is faithful to the
arm, which is what makes the conversion mechanical, and the arm is a separate question.

The first wrong answer that transcription found, four `or`-with-equality arms carrying
their neighbour's comparison, was fixed first (#1077, #1078) so that this set agrees
with a `switch` that is right.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bjumi5K7fg8yx6UK1mZTQd
@Rafael-SOWNet
Rafael-SOWNet merged commit 2d6bcfc into master Aug 26, 2026
31 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the feat/inequality-is-data branch August 26, 2026 18:45
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.

1 participant