Skip to content

A set-builder whose predicate is NaN is empty, and a set is never a constant in the derivative - #1455

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
subset-solve-crash
Sep 21, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
subset-solve-crash

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Two findings of the workspace harnesses run against 04a5dd45 (today's master), both from work merged today.

crashcheck — "x subset 2".ToEntity().Solve("x") threw InvalidCastException: Unable to cast object of type 'Real' to type 'Set' at Entity.Solve. The statement solver answers { x : x subset 2 }; the predicate is NaN since 2 is not a set, and a NaN predicate made the whole set-builder NaN, which Solve then cast to a Set. A predicate that is NaN holds nowhere, so the set-builder is now the empty set — which is what the solver already answered for 1/0 = x — and { x : 1/0 = x } evaluates to { } too, where 2.5.0 said NaN (recorded in BREAKING-CHANGES.md; subset itself is unreleased).

docsamples — "{ 1, 2 } + sin(x)".Differentiate("x") printed cos(x) where the wiki's Differentiation page says { cos(x) }. #1451 made the base derivative of a node with no rule of its own that does not mention the variable 0; a set is not a constant in the variable whatever it mentions — { 1, 2 } + sin(x) is { 1 + sin(x), 2 + sin(x) } — so a set keeps the derivative node, which reaches the elements. [1, 2] * x differentiates to [1, 2] unchanged (matrices have their own rule).

Tests: SubsetTest.APredicateThatIsNaNHoldsNowhere (both spellings, Solve and Evaled), ModulusPhaseTest.ASetDifferentiatesElementwiseNotToZero. Full suite 12515 passed, 0 failed; the kernel gate PASSED on all 19 gated benchmarks against the 84f83fd7 baseline.

Part of #1409.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

…onstant in the derivative

Two findings of the workspace harnesses against 04a5dd4, both from work merged
today:

- crashcheck: `"x subset 2".ToEntity().Solve("x")` threw InvalidCastException.
  The solver answers `{ x : x subset 2 }`; the predicate is NaN, since 2 is not a
  set, and a NaN predicate made the whole set-builder NaN, which Solve then cast
  to a set. A predicate that is NaN holds nowhere, so the set-builder is the empty
  set -- which is what the solver already answered for `1/0 = x`, and what
  `{ x : 1/0 = x }` now evaluates to as well (was NaN in 2.5.0; recorded).

- docsamples: `"{ 1, 2 } + sin(x)".Differentiate("x")` printed `cos(x)` where the
  wiki's Differentiation page says `{ cos(x) }`. #1451 made the base derivative
  of a node that does not mention the variable zero; a set is not a constant in
  the variable whatever it mentions, so a set keeps the derivative node, which
  reaches the elements.

Part of #1409.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet
Rafael-SOWNet merged commit 41d34f6 into master Sep 21, 2026
31 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the subset-solve-crash branch September 21, 2026 18:29
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