Repository navigation
A quantifier, a subset and a cardinality over a finite set compile - #2234
Merged
Merged
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2195, item 3.
forall,exists,exists!,subsetandcardwere 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.CompiledMembershipwrites each out before either compiler sees it:forall,existsTrueandFalseover the empty setexists!iofP_iandnot P_jfor every otherj, by Kleene's connectives{ ... } subset SS, by #2223's membership rewritecard({ ... })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."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)UncompilableNodeExceptionTrue"card({ 1, x })".ToEntity().Compile("x").Call(1)UncompilableNodeException(1, 0)At
NaNthe compiled value is undecided, or the vacuous truth of a quantifier over the empty set. Evaluation differs there for two reasons:NaN, so{ NaN }is{ }andcard({ 1, NaN })is1;NaNanywhere in a quantifier's body makes the quantifierNaN.Undecided answers nothing wrong, and the vacuous truth is the mathematics, so the difference is pinned by its own test rather than mirrored.
Tests.
FiniteSetStatementCompilationTestcompares both compilers with evaluation at 12 points, among themi,1 + iand the infinities:NaNcases;Full suite 18113/0, interactive trio, AOT smoke 73/0, all frameworks build.
🤖 Generated with Claude Code