Skip to content

A compiled statement with no truth value has none - #2208

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
a-compiled-comparison-is-undecided-where-it-has-no-truth-value
Oct 29, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
a-compiled-comparison-is-undecided-where-it-has-no-truth-value

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Part of #2195: item 2, comparisons over Complex, with the three-valued logic the thread arrived at.

A comparison over Complex was refused (The binary operator GreaterThan is not defined for the types 'System.Numerics.Complex'). So piecewise and provided compiled over double but not over Complex. Over double, a comparison with NaN was false, which made not (x > 1) true at NaN. Evaluation says it has no truth value there.

Now a compiled statement has the truth value evaluation gives it:

  • A comparison over Complex, double or float holds or fails where both sides are real, and has no truth value where one is NaN or not real.
  • The connectives follow Kleene's tables, as evaluation's do: (i > 1) or true is true, (i > 1) and false is false, and not (i > 1) has none.
  • A provided whose predicate has no truth value has no value, and nor has an Iverson bracket. A piecewise passes over such a case, as evaluation does: piecewise(1 provided x > 0, 3) is 3 at i.
  • Compiled to bool?, a statement with no truth value is null. Compiled to bool, it is false, as one that does not hold.

Integer types compare as before. The connectives are explicit methods in ThreeValuedLogic, not .NET's lifted operators, so the tables are written down. They are named the trimmer-safe way the operator tables already are.

2.6.0 now
not (x > 1), double -> bool, at NaN True False
x > 1, Complex -> bool, at i UncompilableNodeException False
x > 1 or true, Complex -> bool, at i UncompilableNodeException True
x provided x > 1, Complex -> Complex, at 2 and at i UncompilableNodeException 2, NaN

Tests: ThreeValuedCompilationTest compiles 14 statements over Complex and over double to bool?. Each is compared with evaluation at 2, 1, 1/2, i, 1 + i and NaN. The AOT smoke test checks the same in the interpreter a native build compiles to. Full suite 17898/0, interactive trio, AOT smoke 66/0, all frameworks build.

Still open on #2195: item 1, booleans and branches in FastExpression, and mod over Complex.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

A comparison over Complex was refused, as the operators are not defined
for it, so piecewise and provided compiled over double but not over
Complex. Over double a comparison with NaN was false, so that not (x > 1)
was true at NaN, where evaluation says it has no truth value.

The LINQ compiler now gives a comparison over Complex, double or float
the truth value evaluation does: it holds or fails where both sides are
real numbers, and is null where one is NaN or not real. The connectives
follow Kleene's tables, as evaluation's do, so (i > 1) or true is true
and not (i > 1) is null. A provided or a piecewise whose predicate is
null has no value, nor does an Iverson bracket. Compiled to bool? a
statement with no truth value is null, and compiled to bool it is
false, as one that does not hold. Each is checked against evaluation
over a grid of statements 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
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.25000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.58%. Comparing base (f950af8) to head (60883f0).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...Functions/Compilation/IntoLinq/ThreeValuedLogic.cs 90.56% 5 Missing ⚠️
...ctions/Compilation/IntoLinq/CompilationProtocol.cs 92.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2208      +/-   ##
==========================================
+ Coverage   86.55%   86.58%   +0.03%     
==========================================
  Files         301      302       +1     
  Lines       66878    66950      +72     
  Branches    19428    19464      +36     
==========================================
+ Hits        57888    57971      +83     
+ Misses       4888     4878      -10     
+ Partials     4102     4101       -1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.14% <91.25%> (+0.03%) ⬆️
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 Δ
...ctions/Compilation/IntoLinq/CompilationProtocol.cs 90.24% <92.59%> (+0.92%) ⬆️
...Functions/Compilation/IntoLinq/ThreeValuedLogic.cs 90.56% <90.56%> (ø)

... and 2 files with indirect coverage changes

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

As evaluation does: at i, piecewise(1 provided x > 0, 3) is 3. The
compiled forms already did; the entry said otherwise, and a test now
holds both to it.

Part of #2195

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet
Rafael-SOWNet merged commit 4f20451 into master Oct 29, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 29, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-compiled-comparison-is-undecided-where-it-has-no-truth-value branch October 29, 2026 19:54
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