Skip to content

A quantifier, a subset and a cardinality over a finite set compile - #2234

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
statements-over-a-finite-set-compile
Oct 30, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
statements-over-a-finite-set-compile

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Part of #2195, item 3.

forall, exists, exists!, subset and card were refused by both compilers. Over a finite set, the set is known when the expression is compiled, so each one is a statement or a number about its members. CompiledMembership writes each out before either compiler sees it:

becomes
forall, exists the conjunction and the disjunction of the body at each member; True and False over the empty set
exists! exactly one of them: the disjunction over i of P_i and not P_j for every other j, by Kleene's connectives
{ ... } subset S each member a member of S, by #2223's membership rewrite
card({ ... }) the number of distinct values: each member counts, as an Iverson bracket, where it equals none before it

Each is capped at 64 members, since the cardinality and exists! grow with the square of the count. Past the cap, or over any set that is not finite, it is left as written, and neither compiler compiles it.

2.6.0 now
"forall t in { 1, 2, 3 } : t < x".ToEntity().Compile("x").Call(4) UncompilableNodeException (1, 0)
"{ x } subset [0; 3]".ToEntity().Compile<double, bool>("x")(0.5) UncompilableNodeException True
"card({ 1, x })".ToEntity().Compile("x").Call(1) UncompilableNodeException (1, 0)

At NaN the compiled value is undecided, or the vacuous truth of a quantifier over the empty set. Evaluation differs there for two reasons:

  • a finite set drops a member whose value is NaN, so { NaN } is { } and card({ 1, NaN }) is 1;
  • a NaN anywhere in a quantifier's body makes the quantifier NaN.

Undecided answers nothing wrong, and the vacuous truth is the mathematics, so the difference is pinned by its own test rather than mirrored.

Tests. FiniteSetStatementCompilationTest compares both compilers with evaluation at 12 points, among them i, 1 + i and the infinities:

  • nine statements, including nested quantifiers and quantifiers over the empty set;
  • three cardinalities;
  • the NaN cases;
  • four refusals over sets that are not finite.

Full suite 18113/0, interactive trio, AOT smoke 73/0, all frameworks build.

🤖 Generated with Claude Code

forall, exists, exists!, subset and card were refused by both compilers.
Over a finite set the set is known when the expression is compiled, so
each is a statement or a number about its members. CompiledMembership
writes each one out before either compiler sees it:
- forall and exists become the conjunction and the disjunction of the
  body at each member. Over the empty set they are True and False.
- exists! becomes exactly one of them, as the disjunction over i of P_i
  and not P_j for every j other than i, by Kleene's connectives.
- A finite set is a subset where each member is a member of the other
  set, by the membership rewrite of #2223.
- card is the number of distinct values among the members. Each member
  counts, as an Iverson bracket, where it equals none before it, so the
  count has no value where an equality has none.

Each is capped at 64 members, past which the cardinality and exists!
grow with the square of the count, and is left as written there. Over
any other set it is left as written too, and neither compiler compiles
it.

At a NaN argument the compiled value is undecided, or the vacuous truth
of a quantifier over the empty set. Evaluation differs there for two
reasons. A finite set drops a member whose value is NaN, so { NaN } is
{ } and card({ 1, NaN }) is 1. And a NaN anywhere in a quantifier's body
makes the quantifier NaN. Undecided answers nothing wrong, and the
vacuous truth is the mathematics, so the difference is pinned by its own
test rather than mirrored.

FiniteSetStatementCompilationTest compares both compilers with evaluation
at 12 points, among them i, 1 + i and the infinities:
- nine statements, among them nested quantifiers and quantifiers over
  the empty set;
- three cardinalities;
- the NaN cases;
- four refusals over sets that are not finite.

Part of #2195.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.71%. Comparing base (fba9096) to head (fcda989).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2234      +/-   ##
==========================================
+ Coverage   86.68%   86.71%   +0.02%     
==========================================
  Files         310      310              
  Lines       67738    67766      +28     
  Branches    19649    19660      +11     
==========================================
+ Hits        58720    58760      +40     
+ Misses       4902     4894       -8     
+ Partials     4116     4112       -4     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.26% <100.00%> (+0.02%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

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

Files with missing lines Coverage Δ
...riMath/Functions/Compilation/CompiledMembership.cs 97.87% <100.00%> (+3.13%) ⬆️

... and 10 files with indirect coverage changes

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

@Rafael-SOWNet
Rafael-SOWNet merged commit b8a6a6f into master Oct 30, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 30, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the statements-over-a-finite-set-compile branch October 30, 2026 10:16
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.

1 participant