SNAPKITTYWEST commited on
Commit
5736180
·
verified ·
1 Parent(s): fe635c8

Sync from GitHub AHMADALIPARR/cpsc-qft@2603e23: axiom-free Operator.lean, axiom audit

Browse files

Adds lean/CPSC/Operator.lean and lean/Audit.lean, switches CPSC.lean imports from Axioms to Operator, rewrites Lemmas.lean as the Boolean-to-operator bridge, and adds paper/OPERATOR_PROOFS.md. Verified before sync: lake build succeeds on Lean 4.22.0; Audit.lean lists only propext, Classical.choice, Quot.sound; pytest 14 passed.

README.md CHANGED
@@ -15,7 +15,7 @@ tags:
15
  - quantum-computing
16
  ---
17
 
18
- > Mirrored from [https://github.com/SNAPKITTYWEST/cpsc-qft](https://github.com/SNAPKITTYWEST/cpsc-qft) at commit `8ebd1d5`. Part of the **SnapKitty October 2026 main drop**.
19
 
20
  <!--
21
  Copyright (c) 2026 Ahmad Ali Parr and others.
@@ -28,7 +28,7 @@ or the GNU AGPL v3 only. Both are strict copyleft.
28
 
29
  Proof-carrying lattice scattering for 1+1D scalar field theory. Conservation laws are compilation constraints, not post-selection filters.
30
 
31
- **Status:** prototype. The analyzer, translation-orbit check, Trotter product, certificate digest, and Boolean Lean skeleton run. Operator commutation on the qubit space is still open. The paper is [paper/PAPER.md](paper/PAPER.md).
32
 
33
  Repository: [AHMADALIPARR/cpsc-qft](https://github.com/AHMADALIPARR/cpsc-qft)
34
 
@@ -78,12 +78,13 @@ GitHub Pages serves `docs/`. The console is [qsim.html](https://ahmadaliparr.git
78
  ```
79
  docs/SPECIFICATION.md mathematical construction and PCSS workflow
80
  docs/CHANNEL_PRUNING.md channel rules and what they do not mean
81
- docs/OPEN_PROBLEMS.md discharged skeleton vs open operator proof
82
  lean/CPSC/ Boolean certificate, plus an emitted digest
83
  qsharp/ Ising and spin-flip Trotter operations
84
  src/cpsc/ analyzer, compiler, certificate binder
85
  tests/ adversarial rejection, orbit check, digest binding
86
  paper/PAPER.md working paper
 
87
  ```
88
 
89
  ## Run the analyzer
@@ -99,13 +100,7 @@ Python 3.11+. No quantum hardware required. The demo is a statevector check on $
99
 
100
  ## Certificate story
101
 
102
- `lean/CPSC/Certificate.lean` defines the statements that a later proof must discharge:
103
-
104
- 1. Every gate in the compiled circuit commutes with $Q$ and with the translation generator.
105
- 2. In the absence of decoherence, amplitude outside the input sector is identically zero.
106
- 3. If $[H, \Pi_\chi] = 0$, the exact evolution lies in $\mathcal{M}_{\mathrm{sym}}$ (completeness). Projection is then a no-op on the ideal operator and a rejection rule on illegal gates.
107
-
108
- These are `sorry`s. A modified circuit does not yet break a machine-checked proof, because the proof does not exist. The Python adversarial test is the executable stand-in: inserting an $X$ fails compilation.
109
 
110
  ## Relation to existing methods
111
 
 
15
  - quantum-computing
16
  ---
17
 
18
+ > Mirrored from [https://github.com/AHMADALIPARR/cpsc-qft](https://github.com/AHMADALIPARR/cpsc-qft) at commit `2603e23`. Part of the **SnapKitty October 2026 main drop**. Paper: [Snapkitty/cpsc-qft-paper](https://huggingface.co/datasets/Snapkitty/cpsc-qft-paper).
19
 
20
  <!--
21
  Copyright (c) 2026 Ahmad Ali Parr and others.
 
28
 
29
  Proof-carrying lattice scattering for 1+1D scalar field theory. Conservation laws are compilation constraints, not post-selection filters.
30
 
31
+ **Status:** prototype. The analyzer, translation-orbit check, Trotter product, certificate digest, and Boolean Lean skeleton run. Operator commutation sketches for every admitted schedule are in [paper/OPERATOR_PROOFS.md](paper/OPERATOR_PROOFS.md). The paper is [paper/PAPER.md](paper/PAPER.md).
32
 
33
  Repository: [AHMADALIPARR/cpsc-qft](https://github.com/AHMADALIPARR/cpsc-qft)
34
 
 
78
  ```
79
  docs/SPECIFICATION.md mathematical construction and PCSS workflow
80
  docs/CHANNEL_PRUNING.md channel rules and what they do not mean
81
+ docs/OPEN_PROBLEMS.md discharged skeleton vs remaining obligations
82
  lean/CPSC/ Boolean certificate, plus an emitted digest
83
  qsharp/ Ising and spin-flip Trotter operations
84
  src/cpsc/ analyzer, compiler, certificate binder
85
  tests/ adversarial rejection, orbit check, digest binding
86
  paper/PAPER.md working paper
87
+ paper/OPERATOR_PROOFS.md Appendix A operator proof sketches
88
  ```
89
 
90
  ## Run the analyzer
 
100
 
101
  ## Certificate story
102
 
103
+ `lean/CPSC/Certificate.lean` defines the Boolean admission predicates. Operator commutation for admitted schedules is proved in the sketches of [paper/OPERATOR_PROOFS.md](paper/OPERATOR_PROOFS.md). The Python adversarial test rejects illegal gates at compile time.
 
 
 
 
 
 
104
 
105
  ## Relation to existing methods
106
 
docs/OPEN_PROBLEMS.md CHANGED
@@ -7,17 +7,18 @@ or the GNU AGPL v3 only. Both are strict copyleft.
7
 
8
  # Open problems
9
 
10
- Marked `POSSIBLY_NOVEL` in the draft. The honest status is: executable prototype with a Boolean certificate. Operator commutation is not formally verified, and prior art is not cleared.
11
 
12
  ## Discharged in the prototype
13
 
14
  1. Boolean admission. `lean/CPSC/Certificate.lean` reduces the 4-site ring and both adversarial extensions by `rfl`.
15
  2. Digest binding. `cpsc.certificate` hashes the schedule. Editing a gate makes `Certificate.matches` false.
16
  3. Mode switch. λ = 0 rejects a single X. λ ≠ 0 rejects a lone Z. Translation orbits must be closed.
 
17
 
18
  ## Obligations not discharged
19
 
20
- 1. Operator commutation. The Boolean predicate is not yet proved equal to `[U, Π] = 0` on `(ℂ²)⊗N`.
21
  2. Leakage under hardware noise. Ideal leakage on N = 4 is zero; device leakage is unmodeled.
22
  3. Momentum as an eigenspace, rather than orbit closure of the gate support.
23
  4. A non-trivial φ⁴ encoding. `X^4 = I` on qubits. The next model is a truncated oscillator per site.
@@ -32,4 +33,4 @@ Marked `POSSIBLY_NOVEL` in the draft. The honest status is: executable prototype
32
 
33
  ## What would make the novelty claim true
34
 
35
- A released artifact where (i) the channel projector is derived from a stated lattice QFT, (ii) every hardware rewrite is rejected or proved inside the commutant, and (iii) a Lean checker fails closed on an edited circuit. The prototype now rejects illegal gates and binds a digest. It still does not fail a Lean checker on an edited operator identity. That gap is obligation 1.
 
7
 
8
  # Open problems
9
 
10
+ Marked `POSSIBLY_NOVEL` in the draft. The honest status is: executable prototype with a Boolean certificate and documented operator proof sketches. Prior art is not cleared.
11
 
12
  ## Discharged in the prototype
13
 
14
  1. Boolean admission. `lean/CPSC/Certificate.lean` reduces the 4-site ring and both adversarial extensions by `rfl`.
15
  2. Digest binding. `cpsc.certificate` hashes the schedule. Editing a gate makes `Certificate.matches` false.
16
  3. Mode switch. λ = 0 rejects a single X. λ ≠ 0 rejects a lone Z. Translation orbits must be closed.
17
+ 4. Operator proof sketches. Appendix A (every admitted Trotter schedule conserves the mode invariant on every lattice size) is extracted in [paper/OPERATOR_PROOFS.md](../paper/OPERATOR_PROOFS.md).
18
 
19
  ## Obligations not discharged
20
 
21
+ 1. Full Lean operator model without project axioms. The current `Axioms.lean` still axiomatizes commutation; the sketches in OPERATOR_PROOFS.md are the target for `Operator.lean`.
22
  2. Leakage under hardware noise. Ideal leakage on N = 4 is zero; device leakage is unmodeled.
23
  3. Momentum as an eigenspace, rather than orbit closure of the gate support.
24
  4. A non-trivial φ⁴ encoding. `X^4 = I` on qubits. The next model is a truncated oscillator per site.
 
33
 
34
  ## What would make the novelty claim true
35
 
36
+ A released artifact where (i) the channel projector is derived from a stated lattice QFT, (ii) every hardware rewrite is rejected or proved inside the commutant, and (iii) a Lean checker fails closed on an edited circuit. The prototype now rejects illegal gates, binds a digest, and documents the operator proofs. Integrating the sketches into a axiom-free Lean development closes the remaining gap on obligation 1.
lean/Audit.lean ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import CPSC
2
+
3
+ /-! Axiom audit. `lake env lean Audit.lean` must list only `propext`,
4
+ `Classical.choice`, and `Quot.sound`. Any `CPSC.*` axiom here is a regression. -/
5
+
6
+ #print axioms CPSC.Operator.admitted_trotter_commutes
7
+ #print axioms CPSC.operator_commutation
8
+ #print axioms CPSC.transverse_flip_breaks_magnetization
9
+ #print axioms CPSC.loneZ_breaks_spin_flip_op
10
+ #print axioms CPSC.Operator.rx_inverse
11
+ #print axioms CPSC.Emitted.emitted_commutes
lean/CPSC.lean CHANGED
@@ -4,5 +4,6 @@ SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
4
  -/
5
 
6
  import CPSC.Certificate
7
- import CPSC.Axioms
8
  import CPSC.Lemmas
 
 
4
  -/
5
 
6
  import CPSC.Certificate
7
+ import CPSC.Operator
8
  import CPSC.Lemmas
9
+ import CPSC.Emitted
lean/CPSC/Certificate.lean CHANGED
@@ -13,8 +13,8 @@ SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
13
  /-!
14
  Boolean certificate layer.
15
 
16
- These lemmas are proved. They do not mention operators. The operator axioms
17
- live in `CPSC.Axioms`, and the bridge lemmas in `CPSC.Lemmas`.
18
  -/
19
 
20
  namespace CPSC
 
13
  /-!
14
  Boolean certificate layer.
15
 
16
+ These lemmas are proved. They do not mention operators. The operator model
17
+ lives in `CPSC.Operator`, and the bridge lemmas in `CPSC.Lemmas`.
18
  -/
19
 
20
  namespace CPSC
lean/CPSC/Emitted.lean CHANGED
@@ -3,14 +3,20 @@ Copyright (c) 2026 Ahmad Ali Parr and others.
3
  SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
4
  -/
5
 
6
- import CPSC.Certificate
7
 
8
  namespace CPSC.Emitted
9
 
10
  -- emitted by cpsc.certificate; do not edit by hand
11
  def emittedHash : String := "e92f82910385ae3c46acc5479d57f4c6357cbbf9bf77d668e469a64b281db8e5"
12
- def emittedGates : List CPSC.GateKind := [.zz 0 1, .zz 1 2, .zz 2 3, .zz 3 0]
13
- theorem emitted_admitted : CPSC.allPreserve CPSC.preservesMagnetization emittedGates = true := by
14
  rfl
 
 
 
 
 
 
15
 
16
  end CPSC.Emitted
 
3
  SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
4
  -/
5
 
6
+ import CPSC.Operator
7
 
8
  namespace CPSC.Emitted
9
 
10
  -- emitted by cpsc.certificate; do not edit by hand
11
  def emittedHash : String := "e92f82910385ae3c46acc5479d57f4c6357cbbf9bf77d668e469a64b281db8e5"
12
+ def emittedGates : List GateKind := [.zz 0 1, .zz 1 2, .zz 2 3, .zz 3 0]
13
+ theorem emitted_admitted : allPreserve preservesMagnetization emittedGates = true := by
14
  rfl
15
+ -- operator-level: the emitted schedule commutes with the mode's invariant
16
+ theorem emitted_commutes {R : Type} [Lean.Grind.CommRing R] {n : Nat}
17
+ (ι : R) (ang : Operator.Angles R) (steps : Nat) :
18
+ Operator.Commutes (Operator.trotterOp (n := n) ι ang emittedGates steps)
19
+ (Operator.invariant .ising) :=
20
+ Operator.admitted_trotter_commutes .ising ι ang emittedGates emitted_admitted steps
21
 
22
  end CPSC.Emitted
lean/CPSC/Lemmas.lean CHANGED
@@ -1,111 +1,69 @@
1
- import CPSC.Axioms
2
-
3
  /-
4
  Copyright (c) 2026 Ahmad Ali Parr and others.
5
 
6
  SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
7
  -/
8
 
 
 
9
  /-!
10
- Lemmas derived from the operator axioms.
11
 
12
- Nothing in this file introduces a new axiom. Each result is either a Boolean
13
- fact from `CPSC.Certificate` or a consequence of `CPSC.Axioms`.
 
 
14
  -/
15
 
16
-
17
  namespace CPSC
18
 
19
- noncomputable def circuitOp : List GateKind → Unitary
20
- | [] => idU
21
- | g :: rest => mul (gateOp g) (circuitOp rest)
22
-
23
- theorem circuitOp_nil : circuitOp [] = idU := rfl
24
-
25
- theorem circuitOp_cons (g : GateKind) (rest : List GateKind) :
26
- circuitOp (g :: rest) = mul (gateOp g) (circuitOp rest) := rfl
27
-
28
- theorem circuitOp_append (xs ys : List GateKind) :
29
- circuitOp (xs ++ ys) = mul (circuitOp xs) (circuitOp ys) := by
30
- induction xs with
31
- | nil =>
32
- rw [List.nil_append, circuitOp_nil, mul_id_left]
33
- | cons g rest ih =>
34
- rw [List.cons_append, circuitOp_cons, circuitOp_cons, ih, mul_assoc]
35
-
36
- theorem circuit_comm_mag
37
- (gs : List GateKind) (h : allPreserve preservesMagnetization gs = true) :
38
- commMag (circuitOp gs) := by
39
- induction gs with
40
- | nil =>
41
- exact id_comm_mag
42
- | cons g rest ih =>
43
- have parts := bool_and_parts h
44
- exact mul_comm_mag _ _ (mag_of_bool g parts.1) (ih parts.2)
45
-
46
- theorem circuit_comm_spin
47
- (gs : List GateKind) (h : allPreserve preservesSpinFlip gs = true) :
48
- commSpin (circuitOp gs) := by
49
- induction gs with
50
- | nil =>
51
- exact id_comm_spin
52
- | cons g rest ih =>
53
- have parts := bool_and_parts h
54
- exact mul_comm_spin _ _ (spin_of_bool g parts.1) (ih parts.2)
55
-
56
- theorem admitted_commutes
57
- (mode : Mode) (gs : List GateKind) (h : admitted mode gs = true) :
58
- (mode = .ising → commMag (circuitOp gs)) ∧
59
- (mode = .spinFlip → commSpin (circuitOp gs)) := by
60
- cases mode with
61
- | ising =>
62
- refine And.intro ?_ ?_
63
- · intro _
64
- exact circuit_comm_mag gs h
65
- · intro contra
66
- nomatch contra
67
- | spinFlip =>
68
- refine And.intro ?_ ?_
69
- · intro contra
70
- nomatch contra
71
- · intro _
72
- exact circuit_comm_spin gs h
73
 
74
- theorem ising_ring_commutes : commMag (circuitOp isingRing4) :=
75
- circuit_comm_mag isingRing4 isingRing4_admitted
76
-
77
- theorem spin_flip_ring_commutes : commSpin (circuitOp spinFlip4) :=
78
- circuit_comm_spin spinFlip4 spinFlip4_admitted
79
-
80
- theorem transverse_circuit_not_ising (i : Nat) (rest : List GateKind) :
81
- ¬ commMag (circuitOp (.transverseFlip i :: rest)) :=
82
- reject_not_absorbed_mag _ _ (flip_not_mag i)
83
-
84
- theorem loneZ_circuit_not_spin (i : Nat) (rest : List GateKind) :
85
- ¬ commSpin (circuitOp (.loneZ i :: rest)) :=
86
- reject_not_absorbed_spin _ _ (z_not_spin i)
87
-
88
- theorem concatenated_ising
89
- (xs ys : List GateKind)
 
 
 
 
 
 
 
90
  (hx : allPreserve preservesMagnetization xs = true)
91
  (hy : allPreserve preservesMagnetization ys = true) :
92
- commMag (circuitOp (xs ++ ys)) := by
93
  have hjoin : allPreserve preservesMagnetization (xs ++ ys) = true := by
94
  rw [allPreserve_append, hx, hy]
95
  rfl
96
- exact circuit_comm_mag (xs ++ ys) hjoin
97
-
98
- theorem completeness_of_admitted
99
- (mode : Mode) (gs : List GateKind) (h : admitted mode gs = true) :
100
- (mode = .ising → commMag (circuitOp gs)) ∧
101
- (mode = .spinFlip → commSpin (circuitOp gs)) :=
102
- admitted_commutes mode gs h
103
-
104
- /-- The open matrix obligation, named so a later development can replace the axioms. -/
105
- def OperatorCommutation : Prop :=
106
- ∀ g : GateKind, preservesMagnetization g = true → commMag (gateOp g)
107
-
108
- theorem operator_commutation_from_bridge : OperatorCommutation :=
109
- mag_of_bool
 
 
 
110
 
111
  end CPSC
 
 
 
1
  /-
2
  Copyright (c) 2026 Ahmad Ali Parr and others.
3
 
4
  SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
5
  -/
6
 
7
+ import CPSC.Operator
8
+
9
  /-!
10
+ Bridge from the Boolean certificate to operators.
11
 
12
+ Earlier versions of this file derived these results from `CPSC.Axioms`. That
13
+ file is gone. Every result here now follows from the concrete operator model
14
+ in `CPSC.Operator`, and `#print axioms` on each one lists only Lean's standard
15
+ logical axioms (`propext`, `Classical.choice`, `Quot.sound`).
16
  -/
17
 
 
18
  namespace CPSC
19
 
20
+ open CPSC.Operator Lean.Grind
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ /-- The operator obligation from `docs/OPEN_PROBLEMS.md`, item 1: every gate
23
+ the Boolean analyzer admits commutes, as an operator on `(R²)^⊗N`, with the
24
+ conserved operator of its mode. The statement covers every lattice size, every
25
+ commutative ring, and every choice of rotation angles. -/
26
+ def OperatorCommutation : Prop :=
27
+ ∀ (R : Type) [CommRing R] (n : Nat) (ι : R) (ang : Angles R) (g : GateKind),
28
+ (preservesMagnetization g = true → Commutes (gateOp (n := n) ι ang g) Mag) ∧
29
+ (preservesSpinFlip g = true → Commutes (gateOp (n := n) ι ang g) PiX)
30
+
31
+ theorem operator_commutation : OperatorCommutation :=
32
+ fun _ _ _ ι ang g => ⟨mag_of_bool ι ang g, spin_of_bool ι ang g⟩
33
+
34
+ /-- Every admitted schedule, Trotterized for any number of steps, stays in its
35
+ symmetry sector. -/
36
+ theorem completeness_of_admitted {R : Type} [CommRing R] {n : Nat}
37
+ (mode : Mode) (ι : R) (ang : Angles R) (gs : List GateKind)
38
+ (h : admitted mode gs = true) (steps : Nat) :
39
+ Commutes (trotterOp (n := n) ι ang gs steps) (invariant mode) :=
40
+ admitted_trotter_commutes mode ι ang gs h steps
41
+
42
+ /-- Concatenating two admitted Ising schedules keeps magnetization. -/
43
+ theorem concatenated_ising {R : Type} [CommRing R] {n : Nat}
44
+ (ι : R) (ang : Angles R) (xs ys : List GateKind)
45
  (hx : allPreserve preservesMagnetization xs = true)
46
  (hy : allPreserve preservesMagnetization ys = true) :
47
+ Commutes (circuitOp (n := n) ι ang (xs ++ ys)) Mag := by
48
  have hjoin : allPreserve preservesMagnetization (xs ++ ys) = true := by
49
  rw [allPreserve_append, hx, hy]
50
  rfl
51
+ exact circuit_comm_mag ι ang (xs ++ ys) hjoin
52
+
53
+ /-- Rejection is not vacuous. With a nonzero rotation (`2 ι s ≠ 0`; for `ℂ`,
54
+ `sin θ ≠ 0`), the gate the Ising analyzer forbids does move magnetization. -/
55
+ theorem transverse_flip_breaks_magnetization {R : Type} [CommRing R] {n : Nat}
56
+ (ι : R) (ang : Angles R) (i : Nat)
57
+ (hs : 2 * (ι * (ang (.transverseFlip i)).2) ≠ 0) :
58
+ ¬ Commutes (gateOp (n := n) ι ang (.transverseFlip i)) Mag :=
59
+ rx_not_comm_Mag _ _ _ _ hs
60
+
61
+ /-- With a nonzero rotation, the gate the spin-flip analyzer forbids does break
62
+ `∏ X`. -/
63
+ theorem loneZ_breaks_spin_flip_op {R : Type} [CommRing R] {n : Nat}
64
+ (ι : R) (ang : Angles R) (i : Nat)
65
+ (hs : 2 * (ι * (ang (.loneZ i)).2) ≠ 0) :
66
+ ¬ Commutes (gateOp (n := n) ι ang (.loneZ i)) PiX :=
67
+ rz_not_comm_PiX _ _ _ _ hs
68
 
69
  end CPSC
lean/CPSC/Operator.lean ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /-
2
+ Copyright (c) 2026 Ahmad Ali Parr and others.
3
+ SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
4
+ -/
5
+
6
+ import CPSC.Certificate
7
+
8
+ /-!
9
+ Operator model on `(R²)^⊗N`.
10
+
11
+ This file discharges the operator obligation without axioms. A state of `N`
12
+ qubits is a function from computational basis strings `Fin N → Bool` to a
13
+ commutative ring `R`, so for `R = ℂ` this is exactly `(ℂ²)^⊗N` in the
14
+ computational basis. An operator is a map on such states, and operator
15
+ product is composition.
16
+
17
+ Pauli operators act on basis strings in the usual way:
18
+
19
+ * `Z q` multiplies the amplitude of `b` by `(-1)^(b q)`;
20
+ * `X q` flips bit `q`;
21
+ * `PiX = ∏ X` flips every bit;
22
+ * `Mag = ∑ Z` multiplies by `∑_k (-1)^(b k)`.
23
+
24
+ Each gate is the rotation `c·I + ι·s·P` for its Pauli generator `P`. With
25
+ `ι = i`, `c = cos θ`, and `s = ± sin θ`, and since `P² = I`, this equals
26
+ `exp(± i θ P)`. These are the factors `cpsc.channel` applies: `RZZ` is
27
+ `c + ι s Z_a Z_b` and `RX` is `c - ι s X_q`. The commutation theorems hold for
28
+ every ring, every `ι`, and every pair `(c, s)`. In particular they hold for
29
+ every Trotter step size, every `J`, and every `λ`.
30
+
31
+ Gate indices in `GateKind` are natural numbers. They are read modulo the
32
+ lattice size, which matches the periodic ring used by `bondOrbit`. Lattice
33
+ sizes are written `n + 1`, so there is always at least one site.
34
+ -/
35
+
36
+ namespace CPSC.Operator
37
+
38
+ open Lean.Grind
39
+
40
+ set_option linter.unusedSectionVars false
41
+
42
+ variable {R : Type} [CommRing R] {n : Nat}
43
+
44
+ /-- Computational basis strings on `n + 1` sites. -/
45
+ abbrev Basis (n : Nat) := Fin (n + 1) → Bool
46
+
47
+ /-- State vectors: amplitudes on basis strings. -/
48
+ abbrev Vec (R : Type) (n : Nat) := Basis n → R
49
+
50
+ /-- Operators: maps on state vectors. Product is composition. -/
51
+ abbrev Op (R : Type) (n : Nat) := Vec R n → Vec R n
52
+
53
+ /-- `A` and `B` commute as operators. -/
54
+ def Commutes (A B : Op R n) : Prop := ∀ v, A (B v) = B (A v)
55
+
56
+ /-! ## Signs and bit flips -/
57
+
58
+ /-- `(-1)^x`: the `Z` eigenvalue of a bit. -/
59
+ def sgn (x : Bool) : R := if x then -1 else 1
60
+
61
+ theorem sgn_not (x : Bool) : sgn (R := R) (!x) = - sgn x := by
62
+ cases x <;> simp [sgn] <;> grind
63
+
64
+ theorem sgn_sq (x : Bool) : sgn (R := R) x * sgn x = 1 := by
65
+ cases x <;> simp [sgn] <;> grind
66
+
67
+ /-- Flip one bit. -/
68
+ def flipAt (q : Fin (n + 1)) (b : Basis n) : Basis n :=
69
+ fun k => if k = q then !b k else b k
70
+
71
+ /-- Flip every bit. -/
72
+ def flipAll (b : Basis n) : Basis n := fun k => !b k
73
+
74
+ theorem flipAt_flipAll (q : Fin (n + 1)) (b : Basis n) :
75
+ flipAt q (flipAll b) = flipAll (flipAt q b) := by
76
+ funext k
77
+ simp only [flipAt, flipAll]
78
+ split <;> rfl
79
+
80
+ theorem flipAt_flipAt (q : Fin (n + 1)) (b : Basis n) :
81
+ flipAt q (flipAt q b) = b := by
82
+ funext k
83
+ simp only [flipAt]
84
+ split <;> simp
85
+
86
+ theorem flipAt_comm (p q : Fin (n + 1)) (b : Basis n) :
87
+ flipAt p (flipAt q b) = flipAt q (flipAt p b) := by
88
+ funext k
89
+ simp only [flipAt]
90
+ split <;> split <;> rfl
91
+
92
+ /-! ## Pauli operators and the two conserved quantities -/
93
+
94
+ def Z (q : Fin (n + 1)) : Op R n := fun v b => sgn (b q) * v b
95
+
96
+ def X (q : Fin (n + 1)) : Op R n := fun v b => v (flipAt q b)
97
+
98
+ /-- The global spin flip `∏_i X_i`, the `λ ≠ 0` symmetry. -/
99
+ def PiX : Op R n := fun v b => v (flipAll b)
100
+
101
+ /-- Partial magnetization `∑_{k < m} (-1)^(b k)`. -/
102
+ def magUpTo (b : Basis n) : Nat → R
103
+ | 0 => 0
104
+ | m + 1 => magUpTo b m + (if h : m < n + 1 then sgn (b ⟨m, h⟩) else 0)
105
+
106
+ /-- Magnetization eigenvalue `∑_k (-1)^(b k)` of a basis string. -/
107
+ def magVal (b : Basis n) : R := magUpTo b (n + 1)
108
+
109
+ /-- Total magnetization `∑_i Z_i`, the `λ = 0` symmetry. -/
110
+ def Mag : Op R n := fun v b => magVal b * v b
111
+
112
+ theorem Z_sq (q : Fin (n + 1)) (v : Vec R n) : Z q (Z q v) = v := by
113
+ funext b
114
+ simp only [Z]
115
+ have h := sgn_sq (R := R) (b q)
116
+ grind
117
+
118
+ theorem X_sq (q : Fin (n + 1)) (v : Vec R n) : X q (X q v) = v := by
119
+ funext b
120
+ simp only [X, flipAt_flipAt]
121
+
122
+ /-! ## Gates: `c·I + ι·s·P` -/
123
+
124
+ /-- `exp(i θ Z_p Z_q)` with `c = cos θ`, `s = sin θ`, `ι = i`. -/
125
+ def rzz (ι c s : R) (p q : Fin (n + 1)) : Op R n :=
126
+ fun v b => (c + ι * s * (sgn (b p) * sgn (b q))) * v b
127
+
128
+ /-- `exp(-i θ X_q)` with `c = cos θ`, `s = sin θ`, `ι = i`. -/
129
+ def rx (ι c s : R) (q : Fin (n + 1)) : Op R n :=
130
+ fun v b => c * v b - ι * s * v (flipAt q b)
131
+
132
+ /-- `exp(i θ Z_q)` with `c = cos θ`, `s = sin θ`, `ι = i`. -/
133
+ def rz (ι c s : R) (q : Fin (n + 1)) : Op R n :=
134
+ fun v b => (c + ι * s * sgn (b q)) * v b
135
+
136
+ /-- `rzz` is `c·I + ι s·Z_p Z_q`. -/
137
+ theorem rzz_eq (ι c s : R) (p q : Fin (n + 1)) (v : Vec R n) :
138
+ rzz ι c s p q v = fun b => c * v b + ι * s * Z p (Z q v) b := by
139
+ funext b
140
+ simp only [rzz, Z]
141
+ grind
142
+
143
+ /-- `rx` is `c·I - ι s·X_q`. -/
144
+ theorem rx_eq (ι c s : R) (q : Fin (n + 1)) (v : Vec R n) :
145
+ rx ι c s q v = fun b => c * v b - ι * s * X q v b := rfl
146
+
147
+ /-- `rz` is `c·I + ι s·Z_q`. -/
148
+ theorem rz_eq (ι c s : R) (q : Fin (n + 1)) (v : Vec R n) :
149
+ rz ι c s q v = fun b => c * v b + ι * s * Z q v b := by
150
+ funext b
151
+ simp only [rz, Z]
152
+ grind
153
+
154
+ /-- With `ι² = -1` and `c² + s² = 1`, the rotation by `-θ` inverts `rx`. -/
155
+ theorem rx_inverse (ι c s : R) (q : Fin (n + 1)) (v : Vec R n)
156
+ (hι : ι * ι = -1) (hcs : c * c + s * s = 1) :
157
+ rx ι c (-s) q (rx ι c s q v) = v := by
158
+ funext b
159
+ simp only [rx, flipAt_flipAt]
160
+ grind
161
+
162
+ /-! ## Algebra of commutation -/
163
+
164
+ theorem commutes_id (P : Op R n) : Commutes id P := fun _ => rfl
165
+
166
+ theorem commutes_comp {A B P : Op R n}
167
+ (hA : Commutes A P) (hB : Commutes B P) : Commutes (A ∘ B) P := by
168
+ intro v
169
+ simp only [Function.comp]
170
+ rw [hB, hA]
171
+
172
+ /-! ## Gates that commute with the spin flip `∏ X` -/
173
+
174
+ theorem rzz_comm_PiX (ι c s : R) (p q : Fin (n + 1)) :
175
+ Commutes (rzz ι c s p q) PiX := by
176
+ intro v
177
+ funext b
178
+ simp only [rzz, PiX, flipAll, sgn_not]
179
+ grind
180
+
181
+ theorem rx_comm_PiX (ι c s : R) (q : Fin (n + 1)) :
182
+ Commutes (rx ι c s q) PiX := by
183
+ intro v
184
+ funext b
185
+ simp only [rx, PiX, flipAt_flipAll]
186
+
187
+ theorem pair_comm_PiX (ι c s : R) (p q : Fin (n + 1)) :
188
+ Commutes (rx ι c s p ∘ rx ι c s q) PiX :=
189
+ commutes_comp (rx_comm_PiX ι c s p) (rx_comm_PiX ι c s q)
190
+
191
+ /-! ## Gates that commute with the magnetization `∑ Z` -/
192
+
193
+ theorem diag_comm_Mag (f : Basis n → R) :
194
+ Commutes (R := R) (fun v b => f b * v b) Mag := by
195
+ intro v
196
+ funext b
197
+ simp only [Mag]
198
+ grind
199
+
200
+ theorem rzz_comm_Mag (ι c s : R) (p q : Fin (n + 1)) :
201
+ Commutes (rzz ι c s p q) Mag :=
202
+ diag_comm_Mag _
203
+
204
+ theorem rz_comm_Mag (ι c s : R) (q : Fin (n + 1)) :
205
+ Commutes (rz ι c s q) Mag :=
206
+ diag_comm_Mag _
207
+
208
+ /-! ## The forbidden gates fail as operators, not only as Booleans -/
209
+
210
+ /-- Flipping bit `q` shifts the partial magnetization only once `q` is counted. -/
211
+ theorem magUpTo_flipAt (q : Fin (n + 1)) (b : Basis n) (m : Nat) :
212
+ magUpTo (R := R) (flipAt q b) m =
213
+ magUpTo b m + (if q.val < m then sgn (!b q) - sgn (b q) else 0) := by
214
+ induction m with
215
+ | zero => simp only [magUpTo]; grind
216
+ | succ m ih =>
217
+ simp only [magUpTo, ih]
218
+ by_cases hm : m < n + 1
219
+ · have hk : (⟨m, hm⟩ : Fin (n + 1)) = q ↔ q.val = m := by
220
+ constructor
221
+ · intro h; rw [← h]
222
+ · intro h; exact Fin.ext h.symm
223
+ by_cases hq : q.val = m
224
+ · have hlt : ¬ q.val < m := by omega
225
+ have hlt' : q.val < m + 1 := by omega
226
+ have hfeq : (⟨m, hm⟩ : Fin (n + 1)) = q := hk.mpr hq
227
+ simp only [hm, hlt, hlt', dite_true, if_false, if_true, flipAt, hfeq]
228
+ grind
229
+ · have hiff : q.val < m + 1 ↔ q.val < m := by omega
230
+ have hne : (⟨m, hm⟩ : Fin (n + 1)) ≠ q := fun h => hq (hk.mp h)
231
+ simp only [hm, hiff, dite_true, flipAt, hne, if_false]
232
+ grind
233
+ · have hiff : q.val < m + 1 ↔ q.val < m := by omega
234
+ simp only [hm, hiff, dite_false]
235
+ grind
236
+
237
+ theorem magVal_flipAt (q : Fin (n + 1)) (b : Basis n) :
238
+ magVal (R := R) (flipAt q b) = magVal b + (sgn (!b q) - sgn (b q)) := by
239
+ simp only [magVal, magUpTo_flipAt, q.isLt, if_true]
240
+
241
+ /-- A transverse rotation with `2 ι s ≠ 0` (for `ℂ`: `sin θ ≠ 0`) changes magnetization. -/
242
+ theorem rx_not_comm_Mag (ι c s : R) (q : Fin (n + 1))
243
+ (hs : 2 * (ι * s) ≠ 0) : ¬ Commutes (rx ι c s q) Mag := by
244
+ intro h
245
+ have h1 := congrFun (h (fun _ => 1)) (fun _ => false)
246
+ simp only [rx, Mag, magVal_flipAt, sgn] at h1
247
+ apply hs
248
+ simp at h1
249
+ grind
250
+
251
+ /-- A lone `Z` rotation with `2 ι s ≠ 0` (for `ℂ`: `sin θ ≠ 0`) breaks the spin flip. -/
252
+ theorem rz_not_comm_PiX (ι c s : R) (q : Fin (n + 1))
253
+ (hs : 2 * (ι * s) ≠ 0) : ¬ Commutes (rz ι c s q) PiX := by
254
+ intro h
255
+ have h1 := congrFun (h (fun _ => 1)) (fun _ => false)
256
+ simp only [rz, PiX, flipAll, sgn] at h1
257
+ apply hs
258
+ simp at h1
259
+ grind
260
+
261
+ /-! ## Compiler gates -/
262
+
263
+ /-- Read a `GateKind` index as a site of the periodic lattice. -/
264
+ def site (n : Nat) (i : Nat) : Fin (n + 1) :=
265
+ ⟨i % (n + 1), Nat.mod_lt _ (Nat.succ_pos n)⟩
266
+
267
+ /-- Rotation parameters `(c, s)` per gate kind. For a Trotter step, `ZZ` uses
268
+ `θ = J dt` and transverse gates use `θ = λ dt`. -/
269
+ abbrev Angles (R : Type) := CPSC.GateKind → R × R
270
+
271
+ /-- The operator `cpsc.channel` applies for each admitted gate kind. -/
272
+ def gateOp (ι : R) (ang : Angles R) : CPSC.GateKind → Op R n
273
+ | g@(.zz i j) => rzz ι (ang g).1 (ang g).2 (site n i) (site n j)
274
+ | g@(.parityEvenPair i j) =>
275
+ rx ι (ang g).1 (ang g).2 (site n i) ∘ rx ι (ang g).1 (ang g).2 (site n j)
276
+ | g@(.transverseFlip i) => rx ι (ang g).1 (ang g).2 (site n i)
277
+ | g@(.loneZ i) => rz ι (ang g).1 (ang g).2 (site n i)
278
+
279
+ /-- The Boolean spin-flip predicate is sound for operators. -/
280
+ theorem spin_of_bool (ι : R) (ang : Angles R) (g : CPSC.GateKind)
281
+ (h : CPSC.preservesSpinFlip g = true) :
282
+ Commutes (gateOp (n := n) ι ang g) PiX := by
283
+ cases g with
284
+ | zz i j => exact rzz_comm_PiX _ _ _ _ _
285
+ | parityEvenPair i j => exact pair_comm_PiX _ _ _ _ _
286
+ | transverseFlip i => exact rx_comm_PiX _ _ _ _
287
+ | loneZ i => simp [CPSC.preservesSpinFlip] at h
288
+
289
+ /-- The Boolean magnetization predicate is sound for operators. -/
290
+ theorem mag_of_bool (ι : R) (ang : Angles R) (g : CPSC.GateKind)
291
+ (h : CPSC.preservesMagnetization g = true) :
292
+ Commutes (gateOp (n := n) ι ang g) Mag := by
293
+ cases g with
294
+ | zz i j => exact rzz_comm_Mag _ _ _ _ _
295
+ | parityEvenPair i j => simp [CPSC.preservesMagnetization] at h
296
+ | transverseFlip i => simp [CPSC.preservesMagnetization] at h
297
+ | loneZ i => exact rz_comm_Mag _ _ _ _
298
+
299
+ /-! ## Circuits and Trotter products -/
300
+
301
+ /-- A gate list as an operator. The head gate acts first, as in
302
+ `cpsc.channel.evolve_trotter`. -/
303
+ def circuitOp (ι : R) (ang : Angles R) : List CPSC.GateKind → Op R n
304
+ | [] => id
305
+ | g :: rest => circuitOp ι ang rest ∘ gateOp ι ang g
306
+
307
+ /-- `steps` repetitions of one Trotter layer. -/
308
+ def trotterOp (ι : R) (ang : Angles R) (gs : List CPSC.GateKind) : Nat → Op R n
309
+ | 0 => id
310
+ | k + 1 => trotterOp ι ang gs k ∘ circuitOp ι ang gs
311
+
312
+ theorem circuit_comm {ι : R} {ang : Angles R} {P : Op R n}
313
+ (p : CPSC.GateKind → Bool)
314
+ (hp : ∀ g, p g = true → Commutes (gateOp ι ang g) P) :
315
+ ∀ gs, CPSC.allPreserve p gs = true → Commutes (circuitOp ι ang gs) P
316
+ | [], _ => commutes_id P
317
+ | g :: rest, h => by
318
+ have parts := CPSC.bool_and_parts h
319
+ exact commutes_comp (circuit_comm p hp rest parts.2) (hp g parts.1)
320
+
321
+ theorem trotter_comm {ι : R} {ang : Angles R} {P : Op R n}
322
+ {gs : List CPSC.GateKind} (h : Commutes (circuitOp ι ang gs) P) :
323
+ ∀ k, Commutes (trotterOp ι ang gs k) P
324
+ | 0 => commutes_id P
325
+ | k + 1 => commutes_comp (trotter_comm h k) h
326
+
327
+ theorem circuit_comm_mag (ι : R) (ang : Angles R) (gs : List CPSC.GateKind)
328
+ (h : CPSC.allPreserve CPSC.preservesMagnetization gs = true) :
329
+ Commutes (circuitOp (n := n) ι ang gs) Mag :=
330
+ circuit_comm _ (mag_of_bool ι ang) gs h
331
+
332
+ theorem circuit_comm_spin (ι : R) (ang : Angles R) (gs : List CPSC.GateKind)
333
+ (h : CPSC.allPreserve CPSC.preservesSpinFlip gs = true) :
334
+ Commutes (circuitOp (n := n) ι ang gs) PiX :=
335
+ circuit_comm _ (spin_of_bool ι ang) gs h
336
+
337
+ /-- The conserved operator of each compilation mode. -/
338
+ def invariant : CPSC.Mode → Op R n
339
+ | .ising => Mag
340
+ | .spinFlip => PiX
341
+
342
+ /-- Main theorem. Every schedule the analyzer admits in a mode, repeated for
343
+ any number of Trotter steps, commutes as an operator on `(R²)^⊗(n+1)` with
344
+ that mode's conserved operator. This holds for every lattice size, every
345
+ commutative ring, and every choice of rotation angles. -/
346
+ theorem admitted_trotter_commutes (mode : CPSC.Mode) (ι : R) (ang : Angles R)
347
+ (gs : List CPSC.GateKind) (h : CPSC.admitted mode gs = true) (steps : Nat) :
348
+ Commutes (trotterOp (n := n) ι ang gs steps) (invariant mode) := by
349
+ cases mode with
350
+ | ising => exact trotter_comm (circuit_comm_mag ι ang gs h) steps
351
+ | spinFlip => exact trotter_comm (circuit_comm_spin ι ang gs h) steps
352
+
353
+ /-! ## The concrete schedules from `CPSC.Certificate` -/
354
+
355
+ theorem ising_ring_commutes (ι : R) (ang : Angles R) (steps : Nat) :
356
+ Commutes (trotterOp (n := n) ι ang CPSC.isingRing4 steps) Mag :=
357
+ admitted_trotter_commutes .ising ι ang _ CPSC.isingRing4_admitted steps
358
+
359
+ theorem spin_flip_ring_commutes (ι : R) (ang : Angles R) (steps : Nat) :
360
+ Commutes (trotterOp (n := n) ι ang CPSC.spinFlip4 steps) PiX :=
361
+ admitted_trotter_commutes .spinFlip ι ang _ CPSC.spinFlip4_admitted steps
362
+
363
+ end CPSC.Operator
paper/OPERATOR_PROOFS.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Copyright (c) 2026 Ahmad Ali Parr and others.
3
+ SPDX-License-Identifier: LicenseRef-CPSC-ESCL-1.0 OR AGPL-3.0-only
4
+ -->
5
+
6
+ # Appendix A: Operator proofs
7
+
8
+ Extracted from the paper PDF (Conservation-Preserving Compilation for a 1+1D Lattice Shadow of φ⁴). Every admitted Trotter schedule commutes with its mode's conserved operator. Each step is checked by the Lean theorem named in brackets. These sketches correspond to the development in `lean/CPSC/Operator.lean` (when present) and discharge the axioms previously stated in `Axioms.lean`.
9
+
10
+ ## A.1 Setting
11
+
12
+ Fix \(N = n+1\) sites and a commutative ring \(R\). A basis string is a map \(b\) from sites to \(\{0,1\}\); a state is a map \(v\) from basis strings to \(R\), so \(R = \mathbb{C}\) gives \((\mathbb{C}^2)^{\otimes N}\). An operator is a map on states; product is composition. \(A\) commutes with \(P\) when \(A(Pv) = P(Av)\) for every \(v\) [`Commutes`]. Write \(\operatorname{sgn}(x) = (-1)^x\), \(b^{(q)}\) for \(b\) with bit \(q\) flipped [`flipAt`], and \(\bar{b}\) for \(b\) with every bit flipped [`flipAll`].
13
+
14
+ \[
15
+ (Z_q v)(b) = \operatorname{sgn}(b_q)\, v(b),\quad
16
+ (X_q v)(b) = v(b^{(q)}),\quad
17
+ (\Pi_X v)(b) = v(\bar{b}),\quad
18
+ (M v)(b) = m(b)\, v(b),\quad
19
+ m(b) = \sum_k \operatorname{sgn}(b_k).
20
+ \]
21
+
22
+ For \(\iota, c, s \in R\) the gates are the factors `cpsc.channel` applies:
23
+
24
+ \[
25
+ \begin{align*}
26
+ \mathrm{RZZ}_{pq}\, v(b) &= (c + \iota s\, \operatorname{sgn}(b_p)\operatorname{sgn}(b_q))\, v(b), \\
27
+ \mathrm{RX}_q\, v(b) &= c\, v(b) - \iota s\, v(b^{(q)}), \\
28
+ \mathrm{RZ}_q\, v(b) &= (c + \iota s\, \operatorname{sgn}(b_q))\, v(b), \\
29
+ \mathrm{PAIR}_{pq} &= \mathrm{RX}_p\, \mathrm{RX}_q.
30
+ \end{align*}
31
+ \]
32
+
33
+ ## A.2 Gates are rotations
34
+
35
+ **Lemma A.1 (Pauli squares).** \(Z_q^2 = I\), \(X_q^2 = I\), \(\operatorname{sgn}(\neg x) = -\operatorname{sgn}(x)\), and \(\operatorname{sgn}(x)^2 = 1\). [`Z_sq`, `X_sq`, `sgn_not`, `sgn_sq`]
36
+ *Proof.* \(\operatorname{sgn}\) takes values \(\pm 1\) and flipping a bit swaps them; flipping bit \(q\) twice returns \(b\).
37
+
38
+ **Proposition A.2 (Gate form).** \(\mathrm{RZZ}_{pq} = cI + \iota s\, Z_p Z_q\), \(\mathrm{RX}_q = cI - \iota s\, X_q\), and \(\mathrm{RZ}_q = cI + \iota s\, Z_q\). If \(\iota^2 = -1\) and \(c^2 + s^2 = 1\), the gate with \(s\) replaced by \(-s\) inverts \(\mathrm{RX}_q\). [`rzz_eq`, `rx_eq`, `rz_eq`, `rx_inverse`]
39
+ *Proof.* Evaluate both sides at a basis string. For the inverse:
40
+ \[
41
+ (cI + \iota s\, X_q)(cI - \iota s\, X_q) = c^2 I - \iota^2 s^2 X_q^2 = (c^2 + s^2)I = I.
42
+ \]
43
+ Over \(\mathbb{C}\) with \(\iota = i\), \(c = \cos\theta\), \(s = \sin\theta\), \(P^2 = I\) gives \(\exp(\pm i\theta P) = \cos\theta\, I \pm i\sin\theta\, P\), so the gates are \(e^{i\theta Z_p Z_q}\), \(e^{-i\theta X_q}\), and \(e^{i\theta Z_q}\). (This identification is the one step not formalized; see Section 7 of the paper.)
44
+
45
+ ## A.3 Commutation is closed under products
46
+
47
+ **Lemma A.3.** The identity commutes with every \(P\), and if \(A\) and \(B\) commute with \(P\), so does \(AB\). [`commutes_id`, `commutes_comp`]
48
+ *Proof.* \(A(B(Pv)) = A(P(Bv)) = P(A(Bv))\).
49
+
50
+ ## A.4 Admitted gates commute with the invariant
51
+
52
+ **Lemma A.4.** Flipping one bit commutes with flipping all bits. [`flipAt_flipAll`]
53
+
54
+ **Proposition A.5 (Spin flip).** \(\mathrm{RZZ}_{pq}\), \(\mathrm{RX}_q\), and \(\mathrm{PAIR}_{pq}\) commute with \(\Pi_X\) for all \(c, s, \iota\). [`rzz_comm_PiX`, `rx_comm_PiX`, `pair_comm_PiX`]
55
+ *Proof.* For \(\mathrm{RZZ}\) both sides are a coefficient times \(v(\bar{b})\), and the coefficients agree because flipping all bits negates both signs, which cancel. For \(\mathrm{RX}\) both sides equal \(c\, v(\bar{b}) - \iota s\, v(\text{flipped }\bar{b})\), by Lemma A.4. \(\mathrm{PAIR}\) follows from Lemma A.3.
56
+
57
+ **Proposition A.6 (Magnetization).** \(\mathrm{RZZ}_{pq}\) and \(\mathrm{RZ}_q\) commute with \(M\) for all \(c, s, \iota\). [`diag_comm_Mag`, `rzz_comm_Mag`, `rz_comm_Mag`]
58
+ *Proof.* All three are diagonal, and diagonal operators commute because \(R\) is commutative.
59
+
60
+ ## A.5 Rejection is not vacuous
61
+
62
+ **Lemma A.7.** \(m(b^{(q)}) = m(b) - 2\operatorname{sgn}(b_q)\). [`magUpTo_flipAt`, `magVal_flipAt`]
63
+ *Proof.* Only the \(q\)-th term of the sum changes; Lean proves it for every partial sum by induction.
64
+
65
+ **Proposition A.8.** If \(2\iota s \neq 0\) (over \(\mathbb{C}\): \(\sin\theta \neq 0\)), \(\mathrm{RX}_q\) does not commute with \(M\) and \(\mathrm{RZ}_q\) does not commute with \(\Pi_X\). [`rx_not_comm_Mag`, `rz_not_comm_PiX`]
66
+ *Proof.* Take \(v \equiv 1\) and evaluate at the all-zero string. For \(\mathrm{RX}\), by Lemma A.7:
67
+ \[
68
+ (M\,\mathrm{RX}_q v)(0) - (\mathrm{RX}_q M v)(0) = m(0)(c - \iota s) - \bigl(c\, m(0) - \iota s\,(m(0) - 2)\bigr) = -2\iota s \neq 0.
69
+ \]
70
+ For \(\mathrm{RZ}\) the two sides are \(c + \iota s\) and \(c - \iota s\), which differ by \(2\iota s \neq 0\). The hypothesis is necessary: at \(\theta = 0\) or \(\pi\) the rotation is \(\pm I\).
71
+
72
+ ## A.6 Main theorem
73
+
74
+ **Theorem A.9 (Admitted schedules conserve the invariant).** For either mode, with invariant \(M\) (Ising) or \(\Pi_X\) (spin-flip), and for every lattice size, commutative ring \(R\), \(\iota \in R\), angle map, admitted gate list, and number of Trotter steps \(k\), the Trotter operator \(\bigl(\prod_g \operatorname{gateOp}(g)\bigr)^k\) commutes with the invariant. [`admitted_trotter_commutes`]
75
+ *Proof.* A gate passing `preservesMagnetization` is \(\mathrm{RZZ}\) or \(\mathrm{RZ}\) (Proposition A.6); a gate passing `preservesSpinFlip` is \(\mathrm{RZZ}\), \(\mathrm{RX}\), or \(\mathrm{PAIR}\) (Proposition A.5) [`mag_of_bool`, `spin_of_bool`]. Induction on the list with Lemma A.3 gives the layer [`circuit_comm`], and induction on \(k\) gives the power [`trotter_comm`].
76
+
77
+ **Corollary A.10 (Sector preservation).** If the invariant \(P\) satisfies \(P\psi_0 = \mu\psi_0\), then \(PU\psi_0 = UP\psi_0 = \mu U\psi_0\) for the emitted Trotter operator \(U\). The even cat state stays in the \(+1\) sector of \(\Pi_X\), and a basis state stays in its magnetization sector, at every step. This is the content of the zero-leakage rows in Section 6.
78
+
79
+ ---
80
+
81
+ These sketches are the complete proof content of Appendix A. The corresponding Lean development (when `Operator.lean` is present) uses only Lean's standard axioms (`propext`, `Classical.choice`, `Quot.sound`).
paper/PAPER.md CHANGED
@@ -10,7 +10,7 @@ Ahmad Ali Parr
10
 
11
  ## Abstract
12
 
13
- See [ABSTRACT.md](ABSTRACT.md). This note is the working paper for `cpsc-qft`. It describes what the code does. It does not claim a machine-checked proof of operator commutation, and it does not claim a continuum scattering amplitude.
14
 
15
  ## 1. Introduction
16
 
@@ -75,7 +75,7 @@ theorem emitted_admitted : allPreserve preservesMagnetization emittedGates = tru
75
 
76
  `lean/CPSC/Certificate.lean` defines the predicates and discharges them by reduction for the 4-site ring and for the two adversarial extensions. `rfl` fails if a forbidden constructor is inserted. `lean/CPSC/Emitted.lean` is a sample binding produced by the compiler; its digest is `e92f82910385ae3c46acc5479d57f4c6357cbbf9bf77d668e469a64b281db8e5`.
77
 
78
- This is a Boolean skeleton. It does not yet prove that the corresponding unitary commutes with Π_X as an operator. That obligation is stated and left open.
79
 
80
  ## 5. Q# emission
81
 
@@ -102,7 +102,7 @@ These checks do not include device noise. Ideal leakage zero does not survive de
102
 
103
  ## 7. What is not proved
104
 
105
- Operator commutation, a noise bound, a truncated-oscillator φ⁴ encoding, and a Lean checker wired into CI are open. Completeness holds inside each mode by construction of H: the Ising limit conserves magnetization, and the transverse-field model conserves Π_X. Projecting onto magnetization at λ ≠ 0 is refused, because that projection would drop part of the true evolution.
106
 
107
  The construction collides with symmetry-sector simulators and with verified circuit compilers. The piece that is specific here is the channel rule for this lattice shadow, the mode switch at λ = 0, and the digest bound to the admitted schedule.
108
 
@@ -110,6 +110,10 @@ The construction collides with symmetry-sector simulators and with verified circ
110
 
111
  Block-diagonalization by a conserved charge is standard. Symmetry verification and post-selection are the method this compiler refuses to substitute for synthesis. Subspace-preserving evolution in existing quantum toolkits already builds a sector unitary once the symmetry is declared. Machine-checked circuit semantics exist in other stacks and do not know this Hamiltonian. Formalization of free bosonic quantum field theory in Lean (Douglas, Hoback, Mei, Nissim, 2026) is a different target: continuum Euclidean axioms, not a lattice scattering schedule.
112
 
 
 
 
 
113
  ## License
114
 
115
  Dual strict copyleft: `LicenseRef-CPSC-ESCL-1.0` or `AGPL-3.0-only`.
 
10
 
11
  ## Abstract
12
 
13
+ See [ABSTRACT.md](ABSTRACT.md). This note is the working paper for `cpsc-qft`. It describes what the code does. Operator commutation for every admitted Trotter schedule is proved (see [OPERATOR_PROOFS.md](OPERATOR_PROOFS.md) and the Lean development). It does not claim a continuum scattering amplitude.
14
 
15
  ## 1. Introduction
16
 
 
75
 
76
  `lean/CPSC/Certificate.lean` defines the predicates and discharges them by reduction for the 4-site ring and for the two adversarial extensions. `rfl` fails if a forbidden constructor is inserted. `lean/CPSC/Emitted.lean` is a sample binding produced by the compiler; its digest is `e92f82910385ae3c46acc5479d57f4c6357cbbf9bf77d668e469a64b281db8e5`.
77
 
78
+ Operator commutation is proved for every admitted schedule (see [OPERATOR_PROOFS.md](OPERATOR_PROOFS.md)). Each emitted certificate carries the corresponding theorem.
79
 
80
  ## 5. Q# emission
81
 
 
102
 
103
  ## 7. What is not proved
104
 
105
+ A noise bound relating device error rates to sector leakage, a truncated-oscillator φ⁴ encoding (where the quartic is not an identity), instantiation of the ring-generic proof at Mathlib's complex numbers, and a Lean checker wired into CI remain open. Completeness holds inside each mode by construction of H: the Ising limit conserves magnetization, and the transverse-field model conserves Π_X. Projecting onto magnetization at λ ≠ 0 is refused, because that projection would drop part of the true evolution.
106
 
107
  The construction collides with symmetry-sector simulators and with verified circuit compilers. The piece that is specific here is the channel rule for this lattice shadow, the mode switch at λ = 0, and the digest bound to the admitted schedule.
108
 
 
110
 
111
  Block-diagonalization by a conserved charge is standard. Symmetry verification and post-selection are the method this compiler refuses to substitute for synthesis. Subspace-preserving evolution in existing quantum toolkits already builds a sector unitary once the symmetry is declared. Machine-checked circuit semantics exist in other stacks and do not know this Hamiltonian. Formalization of free bosonic quantum field theory in Lean (Douglas, Hoback, Mei, Nissim, 2026) is a different target: continuum Euclidean axioms, not a lattice scattering schedule.
112
 
113
+ ## Appendix
114
+
115
+ The operator proofs are in [OPERATOR_PROOFS.md](OPERATOR_PROOFS.md).
116
+
117
  ## License
118
 
119
  Dual strict copyleft: `LicenseRef-CPSC-ESCL-1.0` or `AGPL-3.0-only`.