From acc3d057b5837c406d9667649bc732f18263f5a2 Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Thu, 22 Oct 2026 22:40:48 +0200 Subject: [PATCH 1/3] test(lab): test(math-foundry): typed tanh/atanh rewrites for NARS, Bayes and Fisher --- .../tests/palette256_typed_evidence_laws.rs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs diff --git a/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs b/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs new file mode 100644 index 000000000..fdf15c036 --- /dev/null +++ b/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs @@ -0,0 +1,59 @@ +//! Cold admission probes for mathematical candidate laws, *not* a new runtime +//! e-graph. Keep existing egglog -> R2IL -> mask-risc ownership boundaries. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Domain { + OpenUnitReal, + IndependentCounts, + BayesLogLikelihood, + FisherCorrelation, + QuantizedPalette, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Law { + TanhAtanhCancel, + MergeIndependentCounts, + AddLogLikelihoodRatios, + UnconditionalThreeSigmaPrune, +} +fn admit(law: Law, domain: Domain) -> bool { + matches!( + (law, domain), + (Law::TanhAtanhCancel, Domain::OpenUnitReal) + | (Law::MergeIndependentCounts, Domain::IndependentCounts) + | (Law::AddLogLikelihoodRatios, Domain::BayesLogLikelihood) + ) +} +#[test] +fn exact_identity_is_admitted_only_in_its_declared_numeric_domain() { + for x in [-0.99_f64, -0.5, 0.0, 0.25, 0.99] { + assert!((x.atanh().tanh() - x).abs() < 1e-12); + } + assert!(admit(Law::TanhAtanhCancel, Domain::OpenUnitReal)); + assert!(!admit(Law::TanhAtanhCancel, Domain::QuantizedPalette)); + assert!(!admit(Law::TanhAtanhCancel, Domain::FisherCorrelation)); + assert!(!admit(Law::UnconditionalThreeSigmaPrune, Domain::OpenUnitReal)); + assert!(1.0_f64.atanh().is_infinite()); +} +#[test] +fn bayesian_log_likelihood_addition_is_not_nars_frequency_revision() { + let f1 = 0.7_f64; + let f2 = 0.7_f64; + let nars_revision = (7.0 + 7.0) / (10.0 + 10.0); + let signed1 = 2.0 * f1 - 1.0; + let signed2 = 2.0 * f2 - 1.0; + let hyperbolic = ((signed1.atanh() + signed2.atanh()).tanh() + 1.0) * 0.5; + assert!((nars_revision - 0.7).abs() < 1e-12); + assert!(hyperbolic > 0.8, "different evidence algebra, not a compiler optimization"); + assert!(admit(Law::MergeIndependentCounts, Domain::IndependentCounts)); + assert!(!admit(Law::MergeIndependentCounts, Domain::BayesLogLikelihood)); + assert!(admit(Law::AddLogLikelihoodRatios, Domain::BayesLogLikelihood)); + assert!(!admit(Law::AddLogLikelihoodRatios, Domain::IndependentCounts)); +} +#[test] +fn tanh_addition_identity_is_a_distinct_true_mathematical_law() { + let a: f64 = 0.4; + let b: f64 = -0.2; + let left = (a + b).tanh(); + let right = (a.tanh() + b.tanh()) / (1.0 + a.tanh() * b.tanh()); + assert!((left - right).abs() < 1e-12); +} From 3ee3c78ec1cf843afb5b14d683d018a35f724b99 Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Thu, 22 Oct 2026 22:40:50 +0200 Subject: [PATCH 2/3] test(lab): test(math-foundry): typed tanh/atanh rewrites for NARS, Bayes and Fisher --- ...22-pal256-egraph-evidence-law-admission.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .claude/board/entries/2026-10-22-pal256-egraph-evidence-law-admission.md diff --git a/.claude/board/entries/2026-10-22-pal256-egraph-evidence-law-admission.md b/.claude/board/entries/2026-10-22-pal256-egraph-evidence-law-admission.md new file mode 100644 index 000000000..55de575ed --- /dev/null +++ b/.claude/board/entries/2026-10-22-pal256-egraph-evidence-law-admission.md @@ -0,0 +1,20 @@ +# Cold mathematical candidate laws for typed evidence families + +Scope **test-only / not egglog rule admission yet**. The Math Foundry E1 probe (#1690/#1693/#1696/#1698), R2IL and mask-risc remain sole owners. MeTTa/MORK/OpenNARS are source languages or independent differential oracles, never replacement hot execution engines. + +Candidate laws: +1. `tanh(atanh(x)) = x` on the open real unit interval; finite-precision LUT cancellation needs a separate quantization/error proof. +2. `tanh(a+b)=(tanh(a)+tanh(b))/(1+tanh(a)tanh(b))` on finite real operands. +3. NARS positive/negative independent evidence counts merge by additive counts. +4. Bayesian log-likelihood contributions add only with correctly identified prior, likelihood and conditional independence. + +Refuse: +- mapping arbitrary embedding cosine to Pearson sample r or sample-size evidence; +- treating `sum(atanh(cos))` as NARS revision; +- `c=tanh(|z|)` as sample-aware confidence; +- global e-graph `3σ -> 0` equivalence; +- float re-association, saturation, LUT roundtrips, or non-idempotent memory effects without typed guards. + +Next cold stage: attach admitted typed predicates to existing `egglog-r2il-probe` *without* adding a second e-graph, emit R2IL via `FoldDialect`, independent oracle/replay capsule, compare to baseline under altered binding and ABI witness. Keep proof/law, compiled recipe, dataset/source evidence and execution receipts separate. + +Run: `cargo test --manifest-path crates/egglog-r2il-probe/Cargo.toml --test palette256_typed_evidence_laws`. From c1015ea3030671fbed12d55c1c2fc05c35a25487 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 21:41:24 +0000 Subject: [PATCH 3/3] fix(ci): rustfmt the probe test, regenerate the board entries index, type the float literal so the test compiles Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg --- .claude/board/entries/README.md | 3 +- .../tests/palette256_typed_evidence_laws.rs | 36 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.claude/board/entries/README.md b/.claude/board/entries/README.md index dd6231c6a..28d4b7b43 100644 --- a/.claude/board/entries/README.md +++ b/.claude/board/entries/README.md @@ -25,10 +25,11 @@ index row, (3) no duplicate entry id. Checks 1 and 2 are deliberately opposite directions; the stranding this convention prevents shows up in exactly one of them, never both. -429 entries, 2026-08-06 .. 2026-10-22. +430 entries, 2026-08-06 .. 2026-10-22. | date | entry id | finding | file | |---|---|---|---| +| 2026-10-22 | `pal256-egraph-evidence-law-admission` | | [2026-10-22-pal256-egraph-evidence-law-admission.md](2026-10-22-pal256-egraph-evidence-law-admission.md) | | 2026-10-22 | `math-compiler-stage-b-e1` | | [2026-10-22-math-compiler-stage-b-e1.md](2026-10-22-math-compiler-stage-b-e1.md) | | 2026-10-22 | `math-compiler-gap-matrix` | | [2026-10-22-math-compiler-gap-matrix.md](2026-10-22-math-compiler-gap-matrix.md) | | 2026-10-22 | `D-MPS-9` | | [2026-10-22-d-mps-9-mork-oracle.md](2026-10-22-d-mps-9-mork-oracle.md) | diff --git a/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs b/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs index fdf15c036..39234a28a 100644 --- a/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs +++ b/crates/egglog-r2il-probe/tests/palette256_typed_evidence_laws.rs @@ -19,8 +19,8 @@ fn admit(law: Law, domain: Domain) -> bool { matches!( (law, domain), (Law::TanhAtanhCancel, Domain::OpenUnitReal) - | (Law::MergeIndependentCounts, Domain::IndependentCounts) - | (Law::AddLogLikelihoodRatios, Domain::BayesLogLikelihood) + | (Law::MergeIndependentCounts, Domain::IndependentCounts) + | (Law::AddLogLikelihoodRatios, Domain::BayesLogLikelihood) ) } #[test] @@ -31,23 +31,41 @@ fn exact_identity_is_admitted_only_in_its_declared_numeric_domain() { assert!(admit(Law::TanhAtanhCancel, Domain::OpenUnitReal)); assert!(!admit(Law::TanhAtanhCancel, Domain::QuantizedPalette)); assert!(!admit(Law::TanhAtanhCancel, Domain::FisherCorrelation)); - assert!(!admit(Law::UnconditionalThreeSigmaPrune, Domain::OpenUnitReal)); + assert!(!admit( + Law::UnconditionalThreeSigmaPrune, + Domain::OpenUnitReal + )); assert!(1.0_f64.atanh().is_infinite()); } #[test] fn bayesian_log_likelihood_addition_is_not_nars_frequency_revision() { let f1 = 0.7_f64; let f2 = 0.7_f64; - let nars_revision = (7.0 + 7.0) / (10.0 + 10.0); + let nars_revision: f64 = (7.0 + 7.0) / (10.0 + 10.0); let signed1 = 2.0 * f1 - 1.0; let signed2 = 2.0 * f2 - 1.0; let hyperbolic = ((signed1.atanh() + signed2.atanh()).tanh() + 1.0) * 0.5; assert!((nars_revision - 0.7).abs() < 1e-12); - assert!(hyperbolic > 0.8, "different evidence algebra, not a compiler optimization"); - assert!(admit(Law::MergeIndependentCounts, Domain::IndependentCounts)); - assert!(!admit(Law::MergeIndependentCounts, Domain::BayesLogLikelihood)); - assert!(admit(Law::AddLogLikelihoodRatios, Domain::BayesLogLikelihood)); - assert!(!admit(Law::AddLogLikelihoodRatios, Domain::IndependentCounts)); + assert!( + hyperbolic > 0.8, + "different evidence algebra, not a compiler optimization" + ); + assert!(admit( + Law::MergeIndependentCounts, + Domain::IndependentCounts + )); + assert!(!admit( + Law::MergeIndependentCounts, + Domain::BayesLogLikelihood + )); + assert!(admit( + Law::AddLogLikelihoodRatios, + Domain::BayesLogLikelihood + )); + assert!(!admit( + Law::AddLogLikelihoodRatios, + Domain::IndependentCounts + )); } #[test] fn tanh_addition_identity_is_a_distinct_true_mathematical_law() {