# Exact Mathematical Discovery Engine

## Result first

Version 0.5 turns Reality Bit Engine into a constrained theorem-discovery
system for finite bit universes. It can:

1. simulate a declared deterministic rule;
2. generate every polynomial invariant in a bounded algebraic language;
3. find the complete attractor and transient structure;
4. search all 256 elementary cellular-automaton rules;
5. infer a modular linear recurrence from training data;
6. test the recurrence on untouched holdout data;
7. return a concrete counterexample when a proposed law fails;
8. emit deterministic proof/checksum certificates.

The central boundary is:

\[
\boxed{
\text{simulation is evidence, but exhaustive verification on a finite domain
is a proof for that finite domain.}
}
\]

The engine never promotes a finite experiment into an unrestricted theorem.

## 1. Evidence levels

| Level | Engine label | Meaning |
|---|---|---|
| 1 | `observed-pattern` | Fits the observations used to generate it |
| 2 | `held-out-verified` | Also predicts supplied data excluded from fitting |
| 3 | `finite-exhaustive-proof` | Every state in the declared finite domain was checked |

Level 3 proves exactly the declared finite proposition. It does not prove the
same statement for arbitrary state width, real numbers, infinite time or the
physical universe.

## 2. Finite universe

For a universe of \(n\) bits, the state space is

\[
X_n=\{0,1\}^n.
\]

A deterministic law is a function

\[
F:X_n\rightarrow X_n.
\]

The first implemented law family is the elementary cellular automaton on a
periodic ring. For cell \(i\), the three-bit neighborhood is

\[
q_i=(x_{i+1},x_i,x_{i-1})_2,
\]

and the output cell is bit \(q_i\) of the selected Wolfram rule number
\(r\in\{0,\ldots,255\}\).

The engine stores the entire transition function as an exact integer map and
hashes its table for reproducibility.

## 3. Automatic Boolean-invariant discovery

An invariant is a function \(I:X_n\to GF(2)\) satisfying

\[
\boxed{I(F(x))=I(x)\quad\text{for every }x\in X_n.}
\]

The discovery language is algebraic normal form:

\[
I(x)=\bigoplus_{S\subseteq\{0,\ldots,n-1\},\ |S|\le d}
c_S\prod_{i\in S}x_i.
\]

For every state \(x\), invariance creates one homogeneous linear equation in
the unknown coefficient bits \(c_S\):

\[
\bigoplus_S c_S
\left[
\prod_{i\in S}F(x)_i
\oplus
\prod_{i\in S}x_i
\right]=0.
\]

The engine enumerates every one of the \(2^n\) states and solves the combined
system by exact Gaussian elimination over \(GF(2)\).

### Completeness theorem

Let \(M_d\) be the vector space of all ANF monomials with degree at most \(d\),
and let \(A\) be the matrix containing the exhaustive invariance equations.
Then

\[
\boxed{\ker A=\{I\in M_d:I\circ F=I\}.}
\]

Therefore the nullspace basis returned by the engine spans **every** invariant
expressible in the declared degree-bounded language. This is not sampling: the
matrix has a row for every possible state.

### Demonstrated discovery

For rule 150 on a periodic five-cell ring, the engine built the six-term
degree-one basis \(\{1,x_0,x_1,x_2,x_3,x_4\}\), checked all 32 states, found
matrix rank 4 and proved that the invariant space has dimension 2:

\[
I_0=1,
\qquad
I_1=x_0+x_1+x_2+x_3+x_4.
\]

The second invariant is global bit parity. The engine discovered it from the
transition table; it was not hard-coded.

## 4. Counterexample engine

For a candidate \(J\), the engine scans states in canonical integer order. If
the candidate is false it returns the first witness

\[
(x,F(x),J(x),J(F(x)))
\]

for which

\[
J(x)\ne J(F(x)).
\]

A counterexample decisively falsifies the finite universal claim. This makes
falsification cheaper than storing vague confidence scores.

## 5. Complete finite dynamics

Every finite deterministic map eventually reaches a cycle. For every state,
the engine calculates:

- transient distance to its attractor;
- attractor period;
- cycle identity;
- fixed-point membership.

Because every state is traversed, the resulting counts are finite exhaustive
proofs.

For rule 30 on a periodic 12-cell ring, the engine proved:

| Quantity | Exact result |
|---|---:|
| States checked | 4,096 |
| Attractor cycles | 12 |
| Fixed points | 3 |
| Maximum period | 102 |
| Maximum transient | 126 |
| Cycle histogram | period 1: 3; period 3: 4; period 8: 1; period 102: 4 |

This theorem is about exactly twelve periodic cells. It is not a theorem about
an infinite rule-30 lattice.

## 6. Autonomous rule-space search

`ca-scan` evaluates all 256 elementary rules for a chosen finite ring. Each
rule receives an exact maximum period, maximum transient, cycle count and
invariant-space dimension. Candidates are ranked by maximum period, then
invariant dimension, then rule number.

For eight cells and degree-one invariants, the highest periods found were:

| Rule | Maximum period |
|---:|---:|
| 30 | 40 |
| 86 | 40 |
| 135 | 40 |
| 149 | 40 |
| 45 | 32 |

This is genuine autonomous mathematical search: the program generated and
evaluated every candidate. “Discovery” means recovered by this run, not a claim
of priority over existing mathematical literature.

## 7. Modular recurrence discovery

For a sequence over a declared prime field \(GF(p)\), the engine uses the
Berlekamp-Massey algorithm to infer the shortest linear recurrence supported by
the training prefix:

\[
s_n=\sum_{i=1}^{L}c_i s_{n-i}\pmod p.
\]

The fitted recurrence is frozen before the untouched suffix is evaluated. A
successful suffix receives `held-out-verified`, not proof of infinite
continuation.

In the built-in blind demonstration, the engine receives 40 residues generated
by an undisclosed order-two rule. It uses 14 terms for discovery and all 26
remaining terms as holdout. It reconstructs

\[
\boxed{s_n=3s_{n-1}+2s_{n-2}\pmod{1,000,003}}
\]

and the entire holdout passes. If any later value is altered, the engine returns
the first failing sequence index.

## 8. Certificates

Each finite proof prints a stable text certificate containing:

- rule and state width;
- algebraic degree or dynamics statistics;
- states checked;
- transition-table checksum;
- result checksum;
- evidence level.

Example:

```text
RBE-INVARIANT-v1;rule=150;cells=5;degree=1;states=32;rank=4;nullity=2;transition-fnv1a64=bb7c4e2f9cc1dac4;certificate-fnv1a64=4cfdc5554e6416ca;level=finite-exhaustive-proof
```

FNV-1a is used as a deterministic accidental-change checksum, not as a
cryptographic signature. Re-running the same release with the same inputs must
reproduce the certificate.

## 9. Commands

```text
reality-bit-engine math-discovery-demo
reality-bit-engine ca-simulate 30 12 1 40
reality-bit-engine ca-discover 150 5 1
reality-bit-engine ca-dynamics 30 12
reality-bit-engine ca-scan 8 1 10
reality-bit-engine recurrence 1000003 6 0 1 1 2 3 5 8 13 21 34 55 89
```

## 10. Hard limits

- CA simulation and dynamics are capped at 20 cells.
- Polynomial invariant discovery is capped at 16 cells, degree 4 and 4,096
  monomials, with at most 2,000,000 state/monomial equation entries.
- Full rule scans are capped at 10 cells and invariant degree 2.
- Modular recurrence arithmetic uses a declared prime no larger than
  2,147,483,647 so multiplication remains portable in unsigned 64-bit C++.
- A held-out recurrence can still be coincidental.
- A finite-width theorem does not automatically generalize to all widths.
- A simulator cannot prove a proposition over infinitely many real inputs by
  enumeration.

The next honest expansion is to add symbolic induction certificates that can
lift selected finite discoveries into parameterized theorems, followed by an
independent proof checker.
