Static snapshot of LinearCircuitJordan.lean · source revision dated 2026-10-19T10:47:08.000Z · source SHA-256 a6684acf9ddce44023fefef188a25ef848359e0b95c7b1cc6779342093fd81f6. Saved results, shown as recorded. Each result is shown as its check last saved it, compared only with this saved source and not with the reader's Lean environment. Nothing was checked or run to show it. This static page does not check or update results.
import Gimle.Forseti.LinearCircuitHoare
L1–1
import Mathlib.Tactic.FinCases
L2–2
import Mathlib.Tactic.NormNum
L3–3
Two linear systems can move through different states and still produce the same output stream. Damped Jordan chains show this in its simplest form: the two systems below differ in how strongly each coordinate feeds the next, yet a suitably scaled readout of the last coordinate is the same at every step.
Let S be the nilpotent shift, which moves every coordinate one place down and inserts a zero; in dimension three it sends (x0,x1,x2) to (0,x0,x1). Compare the updates
A=21(I+S),B=21I+S.
Both start at the first basis vector e0. Read the last coordinate of the first system and one quarter of the last coordinate of the second:
oA(n)=(Ane0)2,oB(n)=41(Bne0)2.
After one step the middle coordinates already differ, 21 against 1, yet the two output streams agree. Expanding the binomials gives oA(n)=oB(n)=(2n)2−n, so the outputs start 0,0,41,83,83,165. That expansion is ours, not Lean's: the claims below check the equality for every n, and the first six values of oA exactly.
Six comparisons suffice because the sum of the dimensions is six. We also check the one- and two-dimensional versions, with output scalings 1 and 21. These are exact rational calculations embedded into real circuit semantics. The proved property is output equality; a decay-rate or stability estimate would require a separate theorem.
/-- Three coordinates with update $B = \tfrac12 I + S$, reading a quarter of the last coordinate. -/def jordanRight3 : Program 3 where
updates := ![.mul (.constant (1 / 2)) (.var 0),
.add (.var 0) (.mul (.constant (1 / 2)) (.var 1)),
.add (.var 1) (.mul (.constant (1 / 2)) (.var 2))]
readout := .mul (.constant (1 / 4)) (.var 2)
matrix := ![![1 / 2, 0, 0], ![1, 1 / 2, 0], ![0, 1, 1 / 2]]
weights := ![0, 0, 1 / 4]
updates_ok := by intro i; fin_cases i <;> decide +kernel
readout_ok := by decide +kernel
Initial states and the finite predicate
Every example starts at the first basis vector. embed casts rational coordinates exactly into the real state space. The helper below transports a finite rational matrix calculation to prefixFormula, an existing Forseti formula about the original compiled programs. The transport is justified by Program.observe_ratCast, rather than by an independently translated program.
Definitioninitial1: Fin 1 → ℚL107–108The initial state e0∈Q1 as an explicit rational vector.
/-- A rational vector in $\mathbb{Q}^d$ as a point of $\mathbb{R}^d$, coordinates cast exactly. -/def embed {d : Nat} (x : Fin d → ℚ) : Point d := fun i => (x i : ℝ)
/-- Finite rational evidence constructs the existing formula, without changing core APIs. -/
private theorem prefix_of_rational_prefix {d₁ d₂ : Nat}
(P : Program d₁) (Q : Program d₂) (x : Fin d₁ → ℚ) (y : Fin d₂ → ℚ)
(h : ∀ n : Fin (d₁ + d₂),
matrix_output P.matrix x P.weights n = matrix_output Q.matrix y Q.weights n) :
(prefixFormula P Q).holds (pointAppend (embed x) (embed y)) := by
rw [prefixFormula_holds_iff]
simp only [pointLeft_pointAppend, pointRight_pointAppend]
intro n hn
calc
P.observe (embed x) n = (matrix_output P.matrix x P.weights n : ℝ) :=
P.observe_ratCast x n
_ = (matrix_output Q.matrix y Q.weights n : ℝ) :=
congrArg (fun q : ℚ => (q : ℝ)) (h ⟨n, hn⟩)
_ = Q.observe (embed y) n := (Q.observe_ratCast y n).symm
Three concrete applications of the same interface
For each dimension, decide +kernel checks the finite rational calculation. The resulting initialization claim supplies observations_eq_of_prefixFormula. That library endpoint consumes prefix_safety: the existing Discrete.certificate_sound rule instantiated with the preservation Hoare triple prefix_hoare and the predicate entailment prefix_entails_output. Consequently each infinite conclusion is about the original compiled circuits and their initialized executions, not only about their matrix representations.
Dimension one is a boundary check where the two realizations coincide. The following two dimensions exercise genuinely different transition circuits.
/-- Distinct dimension-three realizations agree through the existing Hoare/safety endpoint. -/theorem jordan3_equivalent : ∀ n,
jordanLeft3.observe (embed initial3) n = jordanRight3.observe (embed initial3) n := by
exact observations_eq_of_prefixFormula jordanLeft3 jordanRight3 _ _ jordan3_prefix
Independent numerical controls
Agreement between two implementations alone would not rule out the same mistake in both. The next claims compare the selected left outputs with prescribed exact values, independently of the equality proof. Observation zero is included. Finally, explicit unequal next-state coordinates confirm that the two nontrivial examples really have different transitions.