Skip to content

An indexed union or intersection binds its index - #2464

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
fix/union-index-is-bound
Nov 15, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
fix/union-index-is-bound

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

FreeVariables now reads the index of an indexed union or intersection as bound, over both the family and the index set, as a quantifier's: x in union(A_k, k in I) is exists k in I : x in A_k. Checking the other binder-aware API, DomainCondition, found the same leak in three more places, fixed here too:

  • an indexed union or intersection: its condition now has to hold over the index set, as a summation's holds over its range;
  • a set builder: its condition named %1, the name its predicate is renamed to internally (now an internal Placeholder). The existing ASetBuildersOwnConditionIsMembership passed only because it looked for the user's name while the leaked one was %1;
  • a lambda: its condition named its own parameter; that conjunct is dropped, as a set builder's is.
expression API was (2.7.0) now
union({2*pi*k + y}, k in ZZ) FreeVariables k, pi, y pi, y
intersection({k, y}, k in ZZ) FreeVariables k, y y
union({k*y}, k in {k, n}) FreeVariables k, n, y y, n
union({1/k}, k in ZZ) DomainCondition not k = 0 False
union({1/k}, k in ZZ+) DomainCondition not k = 0 True
{ k : 1/k > y } DomainCondition 1 / %1 in RR and y in RR and not %1 = 0 y in RR
lambda(k, 1/(k - y)) DomainCondition not k - y = 0 True

Vars and VarsAndConsts still list the index, as they do for sum. An index used outside its family (union(...) + k) is still free.

Binders checked, every node built through Binding.Of: sum, product, sum over a set, max/min/argmax/argmin, the definite integral, limit and the quantifiers were already right; the indexed union and intersection were wrong in both APIs; the set builder and lambda in DomainCondition only. One left as it is: a limit's domain condition still names its bound variable (domain(limit(1/(k-y), k, 0)) is not k - y = 0), which the code keeps deliberately since #1632.

FreeVariables is read inside the library in three places (lambda eta-reduction, a constant check in the limit transformations, and the binder scoping above), and each gets the right answer from the change; no solver code reads it.

Tests: Issue2458_* in FreeVariablesTest.cs and BinderConditionTest.cs; 14 fail on master. Full check on this commit before the rebase onto e4f84aa (clean): 20,001 unit tests, 0 failed; MCP 441, Terminal 69, F# 134, Interactive 19; AOT OK; BoundCheck 0 disagreements, RootCheck 596/596, CasBench 120/121 with 0 wrong, SimpSweep 10463/10463, RuleCheck clean, CanonCheck and Confluence at their baselines.

Closes #2458.

🤖 Generated with Claude Code

FreeVariables of union(A_k, k in I) and intersection(A_k, k in I) listed k,
though the family binds it as a quantifier does and Substitute already left
it alone. It is now bound throughout the family and the index set.

DomainCondition is the other binder-aware question, and the same sweep found
three leaks of a bound name into it: the indexed family's condition on k is
now required over the index set, as a sum's is over its range; a set builder's
condition mentioned the placeholder %1 its published predicate is renamed to
(so ASetBuildersOwnConditionIsMembership held vacuously), and a lambda's its
parameter. Both are dropped, as the set builder's own name already was meant
to be. A limit's condition is left as it was, as documented.

Fixes #2458

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.00%. Comparing base (e4f84aa) to head (93000f3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2464   +/-   ##
=======================================
  Coverage   87.00%   87.00%           
=======================================
  Files         320      320           
  Lines       71216    71229   +13     
  Branches    20774    20774           
=======================================
+ Hits        61959    61973   +14     
  Misses       4967     4967           
+ Partials     4290     4289    -1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.53% <100.00%> (+<0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 39.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...urces/AngouriMath/Core/Entity/Entity.Definition.cs 95.08% <100.00%> (+1.11%) ⬆️
...ngouriMath/Core/Entity/Omni/Entity.Omni.Classes.cs 87.85% <100.00%> (+0.03%) ⬆️
...Math/Functions/Evaluation/Evaluation.Definition.cs 91.60% <100.00%> (+0.61%) ⬆️

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

FreeVariables reports the index of an indexed union as free

1 participant