Repository navigation
FastExpression compiles statements, provided and piecewise - #2209
Merged
Rafael-SOWNet merged 1 commit intoOct 29, 2026
Merged
Conversation
Compile refused every comparison, connective and Boolean, and so every provided, piecewise and Iverson bracket. A statement now compiles to its truth value on the stack: 1 where it holds, 0 where it does not, and NaN where it has none, which is what evaluation leaves for one. The comparisons and the connectives are the LINQ compiler's, with Kleene's tables. A provided is NaN where its predicate does not hold, and a piecewise is the first case whose predicate holds, or NaN: every case is computed and the one that holds is kept, so the instructions still run in one pass with no jump. Each is checked against evaluation over a grid of expressions and points. Part of #2195 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2209 +/- ##
==========================================
- Coverage 86.57% 86.57% -0.01%
==========================================
Files 302 302
Lines 66950 67045 +95
Branches 19464 19469 +5
==========================================
+ Hits 57965 58044 +79
- Misses 4883 4896 +13
- Partials 4102 4105 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
deleted the
fastexpression-compiles-statements-and-branches
branch
October 29, 2026 20:37
This was referenced Oct 29, 2026
Rafael-SOWNet
added a commit
that referenced
this pull request
Oct 30, 2026
…2229) A statement in a numeric position, such as the argument of sin or a summand, has no value: evaluation leaves sin(True) and True + 2 as written. The compilers each disagreed with that, differently: - FastExpression, which carries a statement as its truth value, took True as 1. So sin(x > 1) at 2 was 0.8414709848078965 and max(x > 1, 0) was 1. This came with #2209 and is unreleased. - The LINQ compiler threw KeyNotFoundException for sin(x > 1) and (x > 1)^2, from widening a bool to double. For max(x > 1, 0) it threw AngouriBugException, which asks for a bug report. Both are on 2.6.0. StatementPositions.Check now runs in both compilers, after the membership rewrite and before anything is compiled. A statement-valued node is a statement, or a provided or piecewise over one. It may stand at the root, as an operand of a connective, on both sides of an equality of statements, in an Iverson bracket, as a provided's or a piecewise's value or predicate, and in a set or a quantifier. Anywhere else it is refused with UncompilableNodeException, whose message points to iverson, the way to take a statement as a number. StatementInANumericPositionTest: 10 statements in numeric positions, refused by FastExpression and by LINQ over double and over Complex. All 10 fail without the check. Also 8 places where a statement is taken, which compile as before. Fixes #2227. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 1, statements and branches in FastExpression.
Entity.Compile(...)refused every comparison, connective and Boolean, and with them everyprovided,piecewiseand Iverson bracket.1where it holds,0where it does not, andNaNwhere it has none.NaNis what evaluation leaves for one, as fori > 1. The comparisons and the connectives are the LINQ compiler'sThreeValuedLogicfrom A compiled statement with no truth value has none #2208, so the two compilers agree, Kleene's tables included.providedandpiecewiseneed no jump. AprovidedisNaNwhere its predicate does not hold. Apiecewiseis the first case whose predicate holds, orNaN, and passes over a case with no truth value as evaluation does. Every case is computed and the one that holds is kept, so the instructions still run in one pass over aforeach. The cost is computing the cases not taken.Compile("x").Call(…)x > 1at2, atiUncompilableNodeException1,NaNx provided x > 0at-1UncompilableNodeExceptionNaNpiecewise(x provided x > 0, -x)at-3UncompilableNodeException3iverson(x > 0)at2UncompilableNodeException1Tests:
FastExpressionStatementTestcompiles 20 expressions, comparisons, connectives,provided,piecewiseand Iverson brackets inside arithmetic. Each is compared with evaluation at2,1,1/2,-3,i,1 + iandNaN, and the cases of a piecewise are checked to be taken in order. The AOT smoke test checks a piecewise and a statement in a native build. Full suite 17919/0, interactive trio, AOT smoke 67/0, all frameworks build.Still open on #2195:
modoverComplexin LINQ, the numerical nodes of item 3 and the calculus nodes of item 4.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura