Repository navigation
A congruence compiles - #2233
Merged
Merged
Conversation
a = b (mod n) was refused by both compilers, the last statement about whole numbers that was. It now compiles to the truth value evaluation gives: - between whole numbers, whether n divides a - b; - a modulus of 0 meaning equality; - no truth value for a fraction, a complex number, NaN or an infinity. NumberStatements.Congruent takes the difference in whole numbers. At 2^60 + 256, the double difference x - 1 rounds back to x, which 4 divides, so x = 1 (mod 4) would have been True. The exact difference is 3 modulo 4, and evaluation says False. FastExpression has a three-argument instruction, CALL_CONGRUENT. The LINQ compiler calls the kernel over Complex where any of the three numbers is one, and over double otherwise. A chain such as x = 1 = 11 (mod 5) is a conjunction of congruences, and compiles as one. CongruenceCompilationTest compares both compilers with evaluation on 10 numbers by 10 numbers by 7 moduli, among them -5, 0, 5/2, i, +oo and 10^20. It also checks the case past 2^53 and a chain. Part of #2195. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2233 +/- ##
==========================================
- Coverage 86.69% 86.68% -0.02%
==========================================
Files 310 310
Lines 67717 67738 +21
Branches 19644 19649 +5
==========================================
+ Hits 58707 58716 +9
- Misses 4895 4907 +12
Partials 4115 4115
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.
a = b (mod n)was refused by both compilers, the last statement about whole numbers that was. It now compiles to the truth value evaluation gives:ndividesa - b;0meaning equality;NaNor an infinity.NumberStatements.Congruenttakes the difference in whole numbers. At2^60 + 256, the double differencex - 1rounds back tox, which 4 divides, sox = 1 (mod 4)would have beenTrue. The exact difference is 3 modulo 4, and evaluation saysFalse.FastExpression has a three-argument instruction,
CALL_CONGRUENT. The LINQ compiler calls the kernel overComplexwhere any of the three numbers is one, and overdoubleotherwise. A chain such asx = 1 = 11 (mod 5)is a conjunction of congruences, and compiles as one."x = 1 (mod 5)".ToEntity().Compile("x").Call(6)UncompilableNodeException(1, 0)"x = 1 (mod 5)".ToEntity().Compile<double, bool>("x")(6)UncompilableNodeExceptionTrueTests:
CongruenceCompilationTestcompares both compilers with evaluation on 10 numbers by 10 numbers by 7 moduli, among them-5,0,5/2,i,+ooand10^20. It also checks the case past2^53and a chain. Full suite 18093/0, interactive trio, AOT smoke 73/0, all frameworks build.🤖 Generated with Claude Code