Skip to content

Commit 6bb8f3b

Browse files
committed
feat(lean): mirror the A2 reversibility<->CNO bridge (UNVERIFIED — env-blocked)
Add proofs/lean4/CNOBridge.lean, a Lean 4 mirror of the five Coq bridge results (reverses, reverses_seq_computes_identity, cnoEquiv_seq_empty_of_reverses, reversible_bridge_forward, reversible_bridge_backward + a functional-model biconditional corollary). HONESTY: this file could NOT be machine-checked in the authoring environment — the Lean toolchain and Mathlib cache download from GitHub release assets, which the egress policy blocked (HTTP 403; confirmed on both the elan release and the lean4 v4.16.0 toolchain). It is therefore: - registered in lakefile.lean as a NON-@[default_target] lean_lib, so the standard `lake build` (the repo's green proof suite) is unaffected; - loudly labelled UNVERIFIED in its header, with the exact verify command (`lake build CNOBridge` + `#print axioms`); - disclosed as such in PROOF-STATUS.adoc. Modelling note: Lean's `eval` is a total function and `ProgramState.eq` includes the PC, so the mirror states the bridge with syntactic state equality — a stronger, cleaner form than Coq's `=st=`-relative statement (no determinism lemma or up-to-=st= slack needed). A disclosed cross-model difference, consistent with "each prover checks its own formalisation". No Coq files touched; the merged A2 development is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qwVESTcbfanY2iJPQNoSz
1 parent c233752 commit 6bb8f3b

3 files changed

Lines changed: 117 additions & 1 deletion

File tree

PROOF-STATUS.adoc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,19 @@ also demands purity and totality, which a `reversible` program need not have —
115115
backward direction to be up-to-`=st=`; (3) the repo's `reversible` is one-sided
116116
whereas the contract is two-sided. The in-file section header documents all three.
117117
This is a genuine statement-shape finding: it tells the aletheia contract to be
118-
stated two-sided and `=st=`-relative, not a proof dodged. *Lean mirror deferred.*
118+
stated two-sided and `=st=`-relative, not a proof dodged.
119+
120+
*Lean mirror — `proofs/lean4/CNOBridge.lean` (UNVERIFIED in this environment).*
121+
A functional-model mirror of the five bridge results was written for Lean 4, but
122+
it could **not** be machine-checked here: the Lean toolchain and Mathlib cache
123+
download from GitHub release assets, which the egress policy blocked (HTTP 403).
124+
It is registered in `lakefile.lean` as a **non-`@[default_target]`** `lean_lib`,
125+
so it does not gate the standard `lake build`; verify with
126+
`lake build CNOBridge` (+ `#print axioms`) where the toolchain is available. Note
127+
the mirror states the bridge with *syntactic* state equality (Lean's `eval` is a
128+
total function and `ProgramState.eq` includes the PC), a stronger/cleaner form
129+
than the Coq `=st=`-relative statement — a disclosed cross-model difference, not
130+
a claim of literal equivalence.
119131

120132
== OND — VERIFIED (this environment), the disclosure pillar
121133

proofs/lean4/CNOBridge.lean

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/- Reversibility ↔ CNO Bridge — Lean 4 mirror of the Coq A2 development
2+
3+
Mirrors the theorems added to proofs/coq/common/CNO.v (the "reversibility
4+
↔ CNO bridge" the MAA framework / aletheia cites). See PROOF-STATUS.adoc.
5+
6+
┌─ VERIFICATION STATUS ──────────────────────────────────────────────────┐
7+
│ NOT machine-checked in the environment where this file was written: │
8+
│ the Lean toolchain and Mathlib cache download from GitHub release │
9+
│ assets, which the egress policy blocked (HTTP 403). This file is a │
10+
│ best-effort transcription against the CNO.lean API and is registered in │
11+
│ lakefile.lean as a NON-default `lean_lib`, so the standard `lake build` │
12+
│ is unaffected by it. To verify: │
13+
│ cd proofs/lean4 && lake exe cache get && lake build CNOBridge │
14+
│ and `#print axioms` on each theorem. Treat as unverified until then. │
15+
└─────────────────────────────────────────────────────────────────────────┘
16+
17+
Modelling note (honest cross-prover difference): Lean's `eval` is a TOTAL
18+
FUNCTION and `ProgramState.eq` INCLUDES the program counter, whereas Coq's
19+
`eval` is a relation and `=st=` EXCLUDES the PC. So this Lean mirror states
20+
the bridge with SYNTACTIC equality of evaluated states — a stronger, cleaner
21+
form that needs no determinism lemma (free for a function) and no
22+
"up-to-=st=" slack on the backward direction. It is therefore not a literal
23+
transcription of the Coq statement but its functional-model analogue,
24+
consistent with the repo's "each prover checks its own formalisation" stance.
25+
26+
Author: Jonathan D. A. Jewell
27+
Project: Absolute Zero
28+
License: MPL-2.0
29+
-/
30+
31+
import CNO
32+
33+
namespace CNOBridge
34+
35+
open CNO
36+
37+
/-- `reverses p p_inv`: `p_inv` undoes `p` on every state. In Lean's functional
38+
model this is `∀ s, eval p_inv (eval p s) = s` — the body of `CNO.reversible`. -/
39+
def reverses (p p_inv : Program) : Prop :=
40+
∀ s, eval p_inv (eval p s) = s
41+
42+
/-- The repo's `reversible` is exactly "there exists a (one-sided) left inverse". -/
43+
theorem reversible_iff_exists_reverses (p : Program) :
44+
reversible p ↔ ∃ p_inv, reverses p p_inv := Iff.rfl
45+
46+
/-- CNO-equivalence to the no-op, functional form: the two programs evaluate to
47+
the same state from every start state. -/
48+
def cnoEquiv (p1 p2 : Program) : Prop :=
49+
∀ s, eval p1 s = eval p2 s
50+
51+
/-- Core lemma: a left inverse sequenced after `p` computes the identity on
52+
every state. Uses only `eval_seqComp` (Coq needed `eval_app` +
53+
`eval_deterministic`; determinism is free here because `eval` is a function). -/
54+
theorem reverses_seq_computes_identity {p p_inv : Program}
55+
(h : reverses p p_inv) : ∀ s, eval (seqComp p p_inv) s = s := by
56+
intro s
57+
rw [eval_seqComp]
58+
exact h s
59+
60+
/-- Repackaged as CNO-equivalence to the empty program (the canonical no-op). -/
61+
theorem cnoEquiv_seq_empty_of_reverses {p p_inv : Program}
62+
(h : reverses p p_inv) : cnoEquiv (seqComp p p_inv) [] := by
63+
intro s
64+
show eval (seqComp p p_inv) s = eval [] s
65+
have hnil : eval [] s = s := rfl
66+
rw [hnil]
67+
exact reverses_seq_computes_identity h s
68+
69+
/-- Forward bridge (the faithful direction of the aletheia contract): a
70+
two-sided inverse makes BOTH composites CNO-equivalent to the no-op. -/
71+
theorem reversible_bridge_forward {p : Program}
72+
(h : ∃ p_inv, reverses p p_inv ∧ reverses p_inv p) :
73+
∃ p_inv, cnoEquiv (seqComp p p_inv) [] ∧ cnoEquiv (seqComp p_inv p) [] := by
74+
obtain ⟨p_inv, hpp, hpi⟩ := h
75+
exact ⟨p_inv, cnoEquiv_seq_empty_of_reverses hpp,
76+
cnoEquiv_seq_empty_of_reverses hpi⟩
77+
78+
/-- Backward bridge: from "the composite is a no-op" recover the inverse. In
79+
Lean's functional/PC-inclusive model this is exact (SYNTACTIC), with no
80+
up-to-`=st=` slack and no termination hypothesis — the two facts Coq needed
81+
(its `reversible_bridge_backward_upto`) because its `eval` is relational and
82+
`=st=` drops the PC. -/
83+
theorem reversible_bridge_backward {p p_inv : Program}
84+
(h : cnoEquiv (seqComp p p_inv) []) : reverses p p_inv := by
85+
intro s
86+
have hs := h s
87+
rw [eval_seqComp] at hs
88+
-- hs : eval p_inv (eval p s) = eval [] s, and eval [] s = s definitionally
89+
exact hs
90+
91+
/-- Corollary: in the functional model the forward and backward directions
92+
combine into a genuine biconditional for a single inverse `p_inv`. -/
93+
theorem reverses_iff_cnoEquiv_seq_empty (p p_inv : Program) :
94+
reverses p p_inv ↔ cnoEquiv (seqComp p p_inv) [] :=
95+
⟨cnoEquiv_seq_empty_of_reverses, reversible_bridge_backward⟩
96+
97+
end CNOBridge

proofs/lean4/lakefile.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ lean_lib StatMech
3131

3232
@[default_target]
3333
lean_lib OND
34+
35+
-- Reversibility ↔ CNO bridge (mirror of the Coq A2 development). Deliberately
36+
-- NOT a @[default_target]: it was authored where the Lean toolchain could not be
37+
-- fetched (egress policy blocked the GitHub release, HTTP 403), so it is
38+
-- unverified in that environment and must not gate the standard `lake build`.
39+
-- Build/verify explicitly with `lake build CNOBridge`.
40+
lean_lib CNOBridge

0 commit comments

Comments
 (0)