Bounded Calculus , -translation, GateModel , and HBL box
Definitionpalomar_zf207_chi_gategoedellogicset-theoryzf207
Shared definitions for the Gödel/Hilbert–Bernays–Löb representability box of Calculus in Mission #9: (1) the bounded deduction predicate ProvCB matching InternalCalcDeriv (with on ) and InternalProvC; (2) the label-disciplined translation from ZF formulas to Calculus codes; (3) the pointed-hull schema gateSent and GateTheory; (4) the positive arithmetic provability formula fArithProvC1Var using Gödel's -function; and (5) the GateModel inner-ZF interpretation via tagged pairs and well-founded bisimulation quotients, yielding the provability box .
Definition code
import Definitions.Def_palomar_zf207_zf
import Definitions.Def_palomar_zf207_calc
import Definitions.Def_palomar_zf207_history
import Definitions.Def_palomar_zf207_internal_prov
namespace PalomarZF207ChiGate
open PalomarZF207 PalomarZF207Calc PalomarZF207History PalomarZF207Internal
/-! ### 1. Bounded Calculus C (matching `InternalCalcDeriv` with `u ≤ a` on `rho8`) -/
inductive ProvCB : Nat → Prop where
| truth : ProvCB 0
| mp {a b : Nat} : ProvCB (Ic a b) → ProvCB a → ProvCB b
| gen (a : Nat) {B : Nat} : ProvCB B → ProvCB (Uc a B)
| ax_rho8 (a b c u : Nat) : u ≤ a → ProvCB (rho8 a b c u)
| ax_h1 (x y : Nat) : ProvCB (head1 x y)
| ax_h2 (x y z : Nat) : ProvCB (head2 x y z)
| ax_h3 (x y z : Nat) : ProvCB (head3 x y z)
| ax_h4 (x y z : Nat) : ProvCB (head4 x y z)
| ax_h5 (x y : Nat) : ProvCB (head5 x y)
| ax_h6 (x y z : Nat) : ProvCB (head6 x y z)
| ax_gate (a b c : Nat) : c ≠ a → c ≠ b → ProvCB (gateF a b c)
def AndC (a b : Nat) : Nat := Nc (Ic a (Nc b))
def OrC (a b : Nat) : Nat := Ic (Nc a) b
def IffC (a b : Nat) : Nat := AndC (Ic a b) (Ic b a)
def ExC (x b : Nat) : Nat := Nc (Uc x (Nc b))
def InternalProvC {V : Type} (E : V → V → Prop) (x : V) : Prop :=
∃ len f last, InternalCalcDeriv E len f ∧ Succ E last len ∧ At E f last x
/-! ### 2. The `chi` Translation from ZF Formulas to Calculus C Codes -/
def freeIn : Nat → Formula → Bool
| _, .bot => false
| k, .mem i j => k == i || k == j
| k, .eq i j => k == i || k == j
| k, .and a b => freeIn k a || freeIn k b
| k, .or a b => freeIn k a || freeIn k b
| k, .imp a b => freeIn k a || freeIn k b
| k, .all a => freeIn (k + 1) a
| k, .ex a => freeIn (k + 1) a
def liveLabels (env : List Nat) (f : Formula) : List Nat :=
(List.range env.length).filterMap fun i =>
if freeIn i f then some (env.getD i 0) else none
def firstFreshAux : Nat → Nat → List Nat → Nat
| 0, cur, _ => cur
| fuel + 1, cur, used =>
if used.contains cur then firstFreshAux fuel (cur + 1) used else cur
def firstFresh (used : List Nat) : Nat :=
firstFreshAux (used.length + 1) 10 used
def chiEq (a b : Nat) : Nat :=
AndC (Uc 1 (IffC (Mc 1 a) (Mc 1 b))) (Uc 1 (IffC (Mc a 1) (Mc b 1)))
def chiMem (a b : Nat) : Nat :=
ExC 2 (ExC 3 (AndC (chiEq a 2) (AndC (chiEq b 3) (Mc 2 3))))
def chi (env : List Nat) : Formula → Nat
| .bot => 1
| .mem i j => chiMem (env.getD i 0) (env.getD j 0)
| .eq i j => chiEq (env.getD i 0) (env.getD j 0)
| .and a b => AndC (chi env a) (chi env b)
| .or a b => OrC (chi env a) (chi env b)
| .imp a b => Ic (chi env a) (chi env b)
| .all a =>
let v := firstFresh (liveLabels env (.all a))
Uc v (chi (v :: env) a)
| .ex a =>
let v := firstFresh (liveLabels env (.ex a))
ExC v (chi (v :: env) a)
def chi0 (f : Formula) : Nat := chi [] f
/-! ### 3. Pointed-Hull Schema `gateSent` and `GateTheory` -/
def gateRen0 : Nat → Nat
| 0 => 1
| 1 => 2
| k + 2 => k + 3
def gateRen1 : Nat → Nat
| 0 => 1
| 1 => 0
| k + 2 => k + 5
def gateRen2 : Nat → Nat
| 0 => 0
| 1 => 1
| k + 2 => k + 6
/-- Pointed hull axiom for a relation `θ(v, u, p̄)` (`Bound θ (n + 2)`):
`∀ p̄ ∀ u ∀ v ∃ C, (θ(v, u, p̄) → v ∈ C) ∧
∀ z ∈ C, (∃ p, θ(z, p, p̄)) ∧
∀ w, (∀ t, t ∈ w → t ∈ z) → (∃ r, θ(r, w, p̄)) → (∃ q, θ(q, w, p̄) ∧ q ∈ C)`. -/
def gateSent (n : Nat) (θ : Formula) : Formula :=
allPrefix n (.all (.all (.ex
(.and
(.imp (rename gateRen0 θ) (.mem 1 0))
(.all (.imp (.mem 0 1)
(.and
(.ex (rename gateRen1 θ))
(.all (.imp (.all (.imp (.mem 0 1) (.mem 0 2)))
(.imp (.ex (rename gateRen2 θ))
(.ex (.and (rename gateRen2 θ) (.mem 0 3)))))))))))))
def GateTheory (q : Formula) : Prop :=
q = fixedRefl ∨ q = fixedSym ∨ q = fixedTrans ∨ q = fixedEqElem ∨
(∃ n θ, Bound θ (n + 2) ∧ q = gateSent n θ)
def GateProvable (φ : Formula) : Prop :=
∃ Γ : Context, (∀ q, q ∈ Γ → GateTheory q) ∧ ND (.seq Γ φ)
/-! ### 4. Standard ZF Formula Builders & Σ₁ Internal Provability Formula -/
def fNot (p : Formula) : Formula := .imp p .bot
def fIff (p q : Formula) : Formula := .and (.imp p q) (.imp q p)
def fEmpty (a : Nat) : Formula := .all (fNot (.mem 0 (a + 1)))
def fSucc (a b : Nat) : Formula :=
.all (fIff (.mem 0 (b + 1)) (.or (.mem 0 (a + 1)) (.eq 0 (a + 1))))
def fPair (a b p : Nat) : Formula :=
.all (fIff (.mem 0 (p + 1)) (.or (.eq 0 (a + 1)) (.eq 0 (b + 1))))
def fOrderedPair (a b p : Nat) : Formula :=
.ex (.ex (.and (fPair (a + 2) (a + 2) 1)
(.and (fPair (a + 2) (b + 2) 0) (fPair 1 0 (p + 2)))))
def fAt (f x y : Nat) : Formula :=
.ex (.and (.mem 0 (f + 1)) (fOrderedPair (x + 1) (y + 1) 0))
def fFunctionOn (f dom : Nat) : Formula :=
.and
(.all (.imp (.mem 0 (dom + 1))
(.ex (.and (fAt (f + 2) 1 0) (.all (.imp (fAt (f + 3) 2 0) (.eq 0 1)))))))
(.all (.imp (.mem 0 (f + 1))
(.ex (.ex (.and (.mem 1 (dom + 3)) (fOrderedPair 1 0 2))))))
def fInductive (a : Nat) : Formula :=
.and (.ex (.and (fEmpty 0) (.mem 0 (a + 1))))
(.all (.imp (.mem 0 (a + 1)) (.ex (.and (fSucc 1 0) (.mem 0 (a + 2))))))
def fOmega (w : Nat) : Formula :=
.and (fInductive w) (.all (.imp (fInductive 0) (.all (.imp (.mem 0 (w + 2)) (.mem 0 1)))))
def fNatObject (x : Nat) : Formula := .ex (.and (fOmega 0) (.mem (x + 1) 0))
def fAdd (a b c : Nat) : Formula :=
.and (fNatObject a) (.and (fNatObject b) (.and (fNatObject c)
(.ex (.ex (.ex
(.and (fEmpty 2)
(.and (fSucc (b + 3) 1)
(.and (fFunctionOn 0 1)
(.and (fAt 0 2 (a + 3))
(.and (fAt 0 (b + 3) (c + 3))
(.and (.all (.all (.imp (.mem 1 3) (.imp (fAt 2 1 0) (fNatObject 0)))))
(.all (.imp (.mem 0 (b + 4))
(.ex (.ex (.ex
(.and (fSucc 3 2)
(.and (fAt 4 3 1)
(.and (fAt 4 2 0) (fSucc 1 0))))))))))))))))))))
def fMul (a b c : Nat) : Formula :=
.and (fNatObject a) (.and (fNatObject b) (.and (fNatObject c)
(.ex (.ex (.ex
(.and (fEmpty 2)
(.and (fSucc (b + 3) 1)
(.and (fFunctionOn 0 1)
(.and (fAt 0 2 2)
(.and (fAt 0 (b + 3) (c + 3))
(.and (.all (.all (.imp (.mem 1 3) (.imp (fAt 2 1 0) (fNatObject 0)))))
(.all (.imp (.mem 0 (b + 4))
(.ex (.ex (.ex
(.and (fSucc 3 2)
(.and (fAt 4 3 1)
(.and (fAt 4 2 0) (fAdd 1 (a + 7) 0))))))))))))))))))))
def fNum : Nat → Nat → Formula
| 0, a => fEmpty a
| k + 1, a => .ex (.and (fNum k 0) (fSucc 0 (a + 1)))
def numForm (n : Nat) : Formula := fNum n 0
def fBeta (c d i x : Nat) : Formula :=
.and (fNatObject c) (.and (fNatObject d) (.and (fNatObject i) (.and (fNatObject x)
(.ex (.ex (.ex (.ex (.ex
(.and (fSucc (i + 5) 4)
(.and (fMul 4 (d + 5) 3)
(.and (fSucc 3 2)
(.and (fMul 1 2 0)
(.and (fAdd 0 (x + 5) (c + 5)) (.mem (x + 5) 2))))))))))))))
def fCantor (a b z : Nat) : Formula :=
.and (fNatObject a) (.and (fNatObject b) (.and (fNatObject z)
(.ex (.ex (.ex (.ex (.ex (.ex
(.and (fNum 2 5)
(.and (fAdd (a + 6) (b + 6) 4)
(.and (fSucc 4 3)
(.and (fMul 4 3 2)
(.and (fMul 5 (b + 6) 1)
(.and (fMul 5 (z + 6) 0)
(fAdd 2 1 0)))))))))))))))
def fCalcIc (a b res : Nat) : Formula :=
.ex (.ex (.and (fCantor (a + 2) (b + 2) 1) (.and (fNum 4 0) (fMul 0 1 (res + 2)))))
def fCalcMc (a b res : Nat) : Formula :=
.ex (.and (fCalcIc (a + 1) (b + 1) 0) (fSucc 0 (res + 1)))
def fCalcUc (a B res : Nat) : Formula :=
.ex (.ex (.ex (.ex
(.and (fCantor (B + 4) (a + 4) 3)
(.and (fNum 4 2)
(.and (fMul 2 3 1)
(.and (fNum 2 0) (fAdd 1 0 (res + 4)))))))))
def fCalcEc (a b res : Nat) : Formula :=
.ex (.ex (.ex (.ex
(.and (fCantor (a + 4) (b + 4) 3)
(.and (fNum 4 2)
(.and (fMul 2 3 1)
(.and (fNum 3 0) (fAdd 1 0 (res + 4)))))))))
def fCalcNc (B res : Nat) : Formula :=
.ex (.and (fNum 1 0) (fCalcIc (B + 1) 0 (res + 1)))
def fCalcRho8 (res : Nat) : Formula :=
.ex (.ex (.ex (.ex -- a=3, b=2, c=1, u=0
(.and (fNatObject 3) (.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.and (.or (.mem 0 3) (.eq 0 3))
(.ex (.ex (.ex (.ex (.ex -- i1=4, i2=3, i3=2, i4=1, i5=0; a=8, b=7, c=6, u=5
(.and (fCalcIc 6 5 4)
(.and (fCalcIc 4 8 3)
(.and (fCalcIc 8 6 2)
(.and (fCalcIc 7 6 1)
(.and (fCalcIc 2 1 0) (fCalcIc 3 0 (res + 9))))))))))))))))))))
def fCalcHead1 (res : Nat) : Formula :=
.ex (.ex -- x=1, y=0
(.and (fNatObject 1) (.and (fNatObject 0)
(.ex (.ex (.ex (.ex -- u1=3, n1=2, u2=1, n2=0; x=5, y=4
(.and (fCalcUc 4 5 3)
(.and (fCalcNc 3 2)
(.and (fCalcUc 4 2 1)
(.and (fCalcNc 1 0) (fCalcIc 0 5 (res + 6)))))))))))))
def fCalcHead2 (res : Nat) : Formula :=
.ex (.ex (.ex -- x=2, y=1, z=0
(.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.ex (.ex (.ex (.ex -- u1=3, u2=2, u3=1, u4=0; x=6, y=5, z=4
(.and (fCalcUc 4 6 3)
(.and (fCalcUc 5 3 2)
(.and (fCalcUc 5 6 1)
(.and (fCalcUc 4 1 0) (fCalcIc 2 0 (res + 7)))))))))))))))
def fCalcHead3 (res : Nat) : Formula :=
.ex (.ex (.ex -- x=2, y=1, z=0
(.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.ex (.ex (.ex (.ex -- m1=3, e1=2, m2=1, i1=0; x=6, y=5, z=4
(.and (fCalcMc 6 5 3)
(.and (fCalcEc 6 4 2)
(.and (fCalcMc 4 5 1)
(.and (fCalcIc 2 1 0) (fCalcIc 3 0 (res + 7)))))))))))))))
def fCalcHead4 (res : Nat) : Formula :=
.ex (.ex (.ex -- x=2, y=1, z=0
(.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.ex (.ex (.ex (.ex -- e1=3, m1=2, m2=1, i1=0; x=6, y=5, z=4
(.and (fCalcEc 6 5 3)
(.and (fCalcMc 4 6 2)
(.and (fCalcMc 4 5 1)
(.and (fCalcIc 2 1 0) (fCalcIc 3 0 (res + 7)))))))))))))))
def fCalcHead5 (res : Nat) : Formula :=
.ex (.ex -- x=1, y=0
(.and (fNatObject 1) (.and (fNatObject 0)
(.ex (.ex (.ex -- e1=2, n1=1, u1=0; x=4, y=3
(.and (fCalcEc 4 3 2)
(.and (fCalcNc 2 1)
(.and (fCalcUc 3 1 0) (fCalcNc 0 (res + 5)))))))))))
def fCalcHead6 (res : Nat) : Formula :=
.ex (.ex (.ex -- x=2, y=1, z=0
(.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.ex (.ex (.ex (.ex (.ex -- u1=4, i1=3, u2=2, u3=1, i2=0; x=7, y=6, z=5
(.and (fCalcUc 6 5 4)
(.and (fCalcIc 5 7 3)
(.and (fCalcUc 6 3 2)
(.and (fCalcUc 6 7 1)
(.and (fCalcIc 2 1 0) (fCalcIc 4 0 (res + 8)))))))))))))))))
def fCalcGateG (a b c res : Nat) : Formula :=
-- 21 existential witnesses in two small nested blocks for readability:
-- Block 1 (11 vars): m1=10, m2=9, i1=8, subBA=7, m3=6, n1=5, i2=4, u1=3, stepEx=2, i3=1, stepAll=0
.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex
(.and (fCalcMc (c + 11) (b + 11) 10)
(.and (fCalcMc (c + 11) (a + 11) 9)
(.and (fCalcIc 10 9 8)
(.and (fCalcUc (c + 11) 8 7)
(.and (fCalcMc (a + 11) (c + 11) 6)
(.and (fCalcNc 6 5)
(.and (fCalcIc (c + 11) 5 4)
(.and (fCalcUc (a + 11) 4 3)
(.and (fCalcNc 3 2)
(.and (fCalcIc (c + 11) 2 1)
(.and (fCalcUc (a + 11) 1 0)
-- Block 2 (10 vars): i4=9, u2=8, n2=7, i5=6, u3=5, hullBody=4, i6=3, lhs=2, i7=1, rhs=0
-- Shifted from Block 1: subBA=17, m3=16, stepAll=10, a=a+21, b=b+21, c=c+21, res=res+21
(.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex
(.and (fCalcIc 17 10 9)
(.and (fCalcUc (b + 21) 9 8)
(.and (fCalcNc 8 7)
(.and (fCalcIc (c + 21) 7 6)
(.and (fCalcUc (b + 21) 6 5)
(.and (fCalcNc 5 4)
(.and (fCalcIc 16 4 3)
(.and (fCalcUc (a + 21) 3 2)
(.and (fCalcIc (c + 21) 16 1)
(.and (fCalcNc 1 0) (fCalcIc 2 0 (res + 21)))))))))))))))))))))))))))))))))))))))))))
def fCalcGateF (res : Nat) : Formula :=
.ex (.ex (.ex -- a=2, b=1, c=0
(.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.and (fNot (.eq 0 2)) (.and (fNot (.eq 0 1))
(.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex (.ex -- e1=9, ue1=8, delta=7, m1=6, um1=5, vax=4, g=3, q=2, iq=1, idq=0; a=12, b=11, c=10
(.and (fCalcEc 12 11 9)
(.and (fCalcUc 10 9 8)
(.and (fCalcIc 9 8 7)
(.and (fCalcMc 12 11 6)
(.and (fCalcUc 10 6 5)
(.and (fCalcIc 6 5 4)
(.and (fCalcGateG 12 11 10 3)
(.and (fCalcUc 10 3 2)
(.and (fCalcIc 4 2 1)
(.and (fCalcIc 7 1 0) (fCalcNc 0 (res + 13)))))))))))))))))))))))))))))
def fCalcAxiom (x : Nat) : Formula :=
.or (fEmpty x)
(.or (fCalcRho8 x)
(.or (fCalcHead1 x)
(.or (fCalcHead2 x)
(.or (fCalcHead3 x)
(.or (fCalcHead4 x)
(.or (fCalcHead5 x)
(.or (fCalcHead6 x) (fCalcGateF x))))))))
/-- Σ₁ arithmetic formula with 1 free variable (`0` = target code `x`) characterizing `InternalProvC E (s 0)`. -/
def fArithProvC1Var : Formula :=
.and (fNatObject 0)
(.ex (.ex (.ex (.ex -- len=3, c=2, d=1, last=0, target=4
(.and (fNatObject 3) (.and (fNatObject 2) (.and (fNatObject 1) (.and (fNatObject 0)
(.and (fSucc 0 3)
(.and (fBeta 2 1 0 4)
(.all (.imp (.mem 0 4) -- i=0, last=1, d=2, c=3, len=4, target=5
(.ex (.and (fNatObject 0) (.and (fBeta 4 3 1 0) -- x=0, i=1, last=2, d=3, c=4, len=5
(.or (fCalcAxiom 0)
(.or
(.ex (.ex (.ex (.ex -- j=3, k=2, a=1, imp=0; x=4, i=5, d=7, c=8
(.and (.mem 3 5) (.and (.mem 2 5)
(.and (fBeta 8 7 3 1) (.and (fBeta 8 7 2 0) (fCalcIc 1 4 0)))))))))
(.ex (.ex (.ex -- j=2, a=1, b=0; x=3, i=4, d=6, c=7
(.and (.mem 2 4) (.and (fNatObject 1)
(.and (fBeta 7 6 2 0) (fCalcUc 1 0 3))))))))))))))))))))))))
/-! ### 5. GateModel Inner-ZF Translation `J_trans`, `kappa`, and `provCBox` -/
def fSing (x s : Nat) : Formula :=
.all (fIff (.mem 0 (s + 1)) (.eq 0 (x + 1)))
def fTag (e x t : Nat) : Formula :=
.ex (.and (fSing (x + 1) 0)
(.all (fIff (.mem 0 (t + 2)) (.or (.eq 0 (e + 2)) (.eq 0 1)))))
def fMemE (e x a : Nat) : Formula :=
.ex (.and (fTag (e + 1) (x + 1) 0) (.mem 0 (a + 1)))
def fPairE (e a b p : Nat) : Formula :=
.all (fIff (fMemE (e + 1) 0 (p + 1)) (.or (.eq 0 (a + 1)) (.eq 0 (b + 1))))
def fOPE (e a b p : Nat) : Formula :=
.ex (.ex (.and (fPairE (e + 2) (a + 2) (a + 2) 1)
(.and (fPairE (e + 2) (a + 2) (b + 2) 0) (fPairE (e + 2) 1 0 (p + 2)))))
def fInRelE (e r a b : Nat) : Formula :=
.ex (.and (fOPE (e + 1) (a + 1) (b + 1) 0) (fMemE (e + 1) 0 (r + 1)))
def fIsBisim (e r : Nat) : Formula :=
.all (.all (.imp (fInRelE (e + 2) (r + 2) 1 0)
(.and
(.all (.imp (fMemE (e + 3) 0 2)
(.ex (.and (fMemE (e + 4) 0 2) (fInRelE (e + 4) (r + 4) 1 0)))))
(.all (.imp (fMemE (e + 3) 0 1)
(.ex (.and (fMemE (e + 4) 0 3) (fInRelE (e + 4) (r + 4) 0 1))))))))
def fEqE (e a b : Nat) : Formula :=
.ex (.and (fIsBisim (e + 1) 0) (fInRelE (e + 1) 0 (a + 1) (b + 1)))
def fMemNe (e a b : Nat) : Formula :=
.ex (.and (fEqE (e + 1) (a + 1) 0) (fMemE (e + 1) 0 (b + 1)))
def fIsTransE (e t : Nat) : Formula :=
.all (.all (.imp (fMemE (e + 2) 1 (t + 2))
(.imp (fMemE (e + 2) 0 1) (fMemE (e + 2) 0 (t + 2)))))
def fDomE (e x : Nat) : Formula :=
.ex (.and (fIsTransE (e + 1) 0) (.and (fMemE (e + 1) (x + 1) 0)
(.all (.imp (.ex (.and (fMemE (e + 3) 0 1) (fMemE (e + 3) 0 2)))
(.ex (.and (fMemE (e + 3) 0 1) (.and (fMemE (e + 3) 0 2)
(.all (.imp (fMemE (e + 4) 0 1) (fNot (fMemE (e + 4) 0 2)))))))))))
def J_trans (e : Nat) : Formula → Formula
| .bot => .bot
| .mem i j => fMemNe e i j
| .eq i j => fEqE e i j
| .and a b => .and (J_trans e a) (J_trans e b)
| .or a b => .or (J_trans e a) (J_trans e b)
| .imp a b => .imp (J_trans e a) (J_trans e b)
| .all a => .all (.imp (fDomE (e + 1) 0) (J_trans (e + 1) a))
| .ex a => .ex (.and (fDomE (e + 1) 0) (J_trans (e + 1) a))
/-- `kappa φ` interprets `φ` inside the inner ZF model `N_e` for every empty marker `e`. -/
def kappa (φ : Formula) : Formula :=
.all (.imp (fEmpty 0) (J_trans 0 φ))
/-- The HBL provability box for Calculus C. -/
def provCBox (φ : Formula) : Formula :=
.ex (.and (numForm (chi0 (kappa φ))) fArithProvC1Var)
end PalomarZF207ChiGate
Source
J. Chang, Nonhalting and ZF-independence for a 207-state Turing machine (zf207.tex), Sections 5–8