Skip to content

Commit 547e2cc

Browse files
authored
Merge pull request #1702 from AdaWorldAPI/lab/dr-math-2-population-evidence-20261022
probe(dr-math): finite-population evidence and counterexample refusal [2/5]
2 parents ca05b1d + 365b6c9 commit 547e2cc

4 files changed

Lines changed: 415 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# D-DRMC-2 — Population evidence is not proof of universal mathematics
2+
3+
This stage adds a deliberately small independent **audit/reference** implementation for one 64×64 focus, plus scalar-per-pair differential fixtures. It has zero data storage and does not run in a hot application path.
4+
5+
`Gamma` (constraints, two-valued) and `R` (proposed relationship) are bound through Stage 1: same row/column coordinate domains, the same issue of the same store-sealed frame (still current), and the same focus. A three-valued `R` carries its own validity bits; there is no separately bound validity plane. `UNKNOWN` is not FALSE, and a counterexample is reported before any unknown pair: one observed FALSE refutes the claim whatever the unknown pairs hold. The fixed 4096-pair focus is not the global population, and a DR bit does not encode multiplicity, confidence, observational provenance, or independent data quality.
6+
7+
`universal_on_focus` checks, in order, `eligible > 0`, `false == 0`, `unknown == 0` over *these supplied bits*. This is a **finite-focus result**, not a generalized theorem, a causal discovery, or source attestation. Caller-supplied bits and revision numbers can be fabricated. In particular, no production method may call this a `CertifiedLaw` until an independently sealed source snapshot, completeness proof, interpretation of the constraints, and independent oracle have been checked.
8+
9+
Next falsifiers for an actual discovery pipeline:
10+
1. Compare against authoritative source observation IDs and a scalar/SQL/datafrog oracle; measure distinct/bag derivations separately.
11+
2. Add a source seal and valid coverage receipt, distinguish a selected focus from exhaustive whole-population enumeration, and revalidate any learned threshold/rule against a held-out population.
12+
3. For candidate algebraic rewrites, check the statement under formal mathematical assumptions through an independent proof checker. egglog e-graph extraction alone cannot prove it holds in nature.
13+
4. Preserve negative controls: empty sample, unknown observations, one contradicting member, stale revision, changed authorization, out-of-focus true member, cyclic/self-supporting derivations.
14+
15+
Runtime masks/folds remain Quack/R2IL/mask-risc or the established direct resident SIMD fast path. The `observe_focus` loop is test/reference checking only and not an alternative production evaluator.

‎crates/dr-math-binding-probe/src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,6 @@ pub fn bind_dr64<'a>(
271271
validity: operand.validity,
272272
})
273273
}
274+
275+
/// Independent 64x64 finite-population reference audit; NEVER a production evaluator.
276+
pub mod population;
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//! D-DRMC-2: deliberately small, independent FINITE POPULATION audit oracle.
2+
//!
3+
//! NOT a physical runtime executor, graph engine, statistical test, proof of
4+
//! causality, or independent authentication of supplied source data. Reads
5+
//! one 64x64 QR focus to find concrete counterexamples before a law is admitted.
6+
//! Hot production folds remain existing Quack/R2IL/mask-risc/native SIMD.
7+
use crate::{BoundDr64, FrameStore, Truth};
8+
9+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10+
pub struct PopulationReport {
11+
/// Pairs selected by Gamma within this concrete 64x64 focus.
12+
pub eligible: u32,
13+
/// Eligible positions with an observed TRUE/valid relationship.
14+
pub true_pairs: u32,
15+
/// Eligible positions observed FALSE (counterexamples).
16+
pub false_pairs: u32,
17+
/// Eligible positions without a known TRUE/FALSE observation.
18+
pub unknown_pairs: u32,
19+
}
20+
21+
impl PopulationReport {
22+
pub const fn checked(self) -> u32 {
23+
self.true_pairs + self.false_pairs
24+
}
25+
/// Finite-focus only: no statement about unobserved people or any theorem
26+
/// over every possible population.
27+
pub fn universal_on_focus(self) -> Result<Self, ClaimRefusal> {
28+
// Refuted beats unknown (certain-answer semantics): one observed
29+
// counterexample refutes the claim whatever the unknown pairs hold,
30+
// so it is reported first and never hidden behind `Unknown`.
31+
if self.eligible == 0 {
32+
return Err(ClaimRefusal::Vacuous);
33+
}
34+
if self.false_pairs != 0 {
35+
return Err(ClaimRefusal::Counterexamples(self.false_pairs));
36+
}
37+
if self.unknown_pairs != 0 {
38+
return Err(ClaimRefusal::Unknown(self.unknown_pairs));
39+
}
40+
Ok(self)
41+
}
42+
}
43+
44+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45+
pub enum ClaimRefusal {
46+
DifferentAxes,
47+
/// The selection is three-valued; Gamma selects or it does not.
48+
SelectionNotTwoValued,
49+
/// Gamma and R were not bound to the same issue of the same frame.
50+
DifferentFrame,
51+
/// The frame they share is no longer the store's current seal.
52+
StaleFrame,
53+
/// Gamma and R read different windows of the frame.
54+
DifferentFocus,
55+
Vacuous,
56+
Unknown(u32),
57+
Counterexamples(u32),
58+
}
59+
60+
/// Reference checker over the selection Gamma and the relation R:
61+
/// 1. Gamma: which DR pairs satisfy the candidate constraints (two-valued);
62+
/// 2. R: which DR pairs satisfy the proposed relational law, with R's own
63+
/// validity bits when R's method is three-valued. UNKNOWN is never FALSE.
64+
///
65+
/// It compares the bound axes, that both operands share one current frame
66+
/// issue and one focus. It does not verify that the source exists or that its
67+
/// relation facts are true.
68+
pub fn observe_focus(
69+
store: &FrameStore,
70+
gamma: &BoundDr64<'_>,
71+
relation: &BoundDr64<'_>,
72+
) -> Result<PopulationReport, ClaimRefusal> {
73+
if (gamma.method.row, gamma.method.column) != (relation.method.row, relation.method.column) {
74+
return Err(ClaimRefusal::DifferentAxes);
75+
}
76+
if gamma.method.truth != Truth::TwoValued {
77+
return Err(ClaimRefusal::SelectionNotTwoValued);
78+
}
79+
if !gamma.frame.same_issue(&relation.frame) {
80+
return Err(ClaimRefusal::DifferentFrame);
81+
}
82+
if store.check(&gamma.frame).is_err() {
83+
return Err(ClaimRefusal::StaleFrame);
84+
}
85+
if gamma.focus != relation.focus {
86+
return Err(ClaimRefusal::DifferentFocus);
87+
}
88+
let mut report = PopulationReport {
89+
eligible: 0,
90+
true_pairs: 0,
91+
false_pairs: 0,
92+
unknown_pairs: 0,
93+
};
94+
for i in 0..64 {
95+
let focus = gamma.rows[i];
96+
let known = relation.validity.map_or(u64::MAX, |v| v[i]);
97+
let positive = focus & relation.rows[i] & known;
98+
let negative = focus & !relation.rows[i] & known;
99+
let unknown = focus & !known;
100+
report.eligible += focus.count_ones();
101+
report.true_pairs += positive.count_ones();
102+
report.false_pairs += negative.count_ones();
103+
report.unknown_pairs += unknown.count_ones();
104+
}
105+
debug_assert_eq!(
106+
report.eligible,
107+
report.true_pairs + report.false_pairs + report.unknown_pairs
108+
);
109+
Ok(report)
110+
}

0 commit comments

Comments
 (0)