Local definitions the statement names, followed through the definitions they name in turn. The match is by name in the source text, so a name reached only through notation can be missed; the full file is below.
inductive type OAI.ExactQuantumFactoring.Primitive line 12
inductive Primitive where | not | cnot | toffoli | hadamard | phase deriving DecidableEq
definition OAI.ExactQuantumFactoring.Primitive.arity line 16
def Primitive.arity : Primitive → ℕ | .not | .hadamard | .phase => 1 | .cnot => 2 | .toffoli => 3
definition OAI.ExactQuantumFactoring.Primitive.code line 21
def Primitive.code : Primitive → ℕ | .not => 0 | .cnot => 1 | .toffoli => 2 | .hadamard => 3 | .phase => 4
structure OAI.ExactQuantumFactoring.Gate line 26
structure Gate where primitive : Primitive inverse : Bool controlled : Bool deriving DecidableEq
definition OAI.ExactQuantumFactoring.Primitive.matrix line 36
noncomputable def Primitive.matrix : Primitive → List Bool → List Bool → ℂ | .not, [a], [b] => if a = !b then 1 else 0 | .cnot, [a,b], [c,d] => if a = c ∧ b = Bool.xor c d then 1 else 0 | .toffoli, [a,b,c], [d,e,f] => if a = d ∧ b = e ∧ c = Bool.xor f (d && e) then 1 else 0 | .hadamard, [a], [b] => (if a && b then -1 else 1) / (Real.sqrt 2 : ℂ) | .phase, [a], [b] => if a = b then (if b then Complex.I else 1) else 0 | _, _, _ => 0
structure OAI.ExactQuantumFactoring.Instruction line 59
structure Instruction (q : ℕ) where gate : Gate wire : Fin gate.arity → Fin q distinct : Function.Injective wire
abbreviation OAI.ExactQuantumFactoring.Basis line 64
abbrev Basis (q : ℕ) := Fin q → Bool
abbreviation OAI.ExactQuantumFactoring.State line 65
abbrev State (q : ℕ) := Basis q → ℂ
structure OAI.ExactQuantumFactoring.Circuit line 75
structure Circuit where qubits : ℕ instructions : List (Instruction qubits)
definition OAI.ExactQuantumFactoring.Circuit.apply line 79
noncomputable def Circuit.apply (c : Circuit) (ψ : State c.qubits) : State c.qubits := c.instructions.foldl (fun v o => o.matrix.mulVec v) ψ
definition OAI.ExactQuantumFactoring.inputBasis line 83
def inputBasis (q ℓ N : ℕ) : Basis q := fun i => if i.val < ℓ then N.testBit i.val else false
definition OAI.ExactQuantumFactoring.Circuit.outputState line 86
noncomputable def Circuit.outputState (c : Circuit) (ℓ N : ℕ) : State c.qubits := by classical exact c.apply (fun x => if x = inputBasis c.qubits ℓ N then 1 else 0)
definition OAI.ExactQuantumFactoring.paddedLength line 91
def paddedLength (ℓ : ℕ) : ℕ := max 128 ℓ
definition OAI.ExactQuantumFactoring.readBit line 93
def readBit {q : ℕ} (x : Basis q) (i : ℕ) : Bool := if h : i < q then x ⟨i,h⟩ else false
definition OAI.ExactQuantumFactoring.outputList line 97
def outputList {q : ℕ} (ℓ : ℕ) (x : Basis q) : List ℕ := let n := paddedLength ℓ List.ofFn (fun a : Fin n => ∑ j ∈ Finset.range n, if readBit x (ℓ + a.val * n + j) then 2^j else 0)
definition OAI.ExactQuantumFactoring.CorrectEncoding line 104
def CorrectEncoding (N n : ℕ) (xs : List ℕ) : Prop := ∃ ps : List ℕ, (∀ p ∈ ps, Nat.Prime p) ∧ ps.Pairwise (· ≤ ·) ∧ ps.prod = N ∧ ps.length ≤ n ∧ xs = ps ++ List.replicate (n - ps.length) 0
definition OAI.ExactQuantumFactoring.Circuit.correctProbability line 110
noncomputable def Circuit.correctProbability (c : Circuit) (ℓ N : ℕ) : ℝ := by classical exact ∑ x : Basis c.qubits, if CorrectEncoding N (paddedLength ℓ) (outputList ℓ x) then Complex.normSq (c.outputState ℓ N x) else 0
definition OAI.ExactQuantumFactoring.natWord line 118
def natWord (k : ℕ) : List Bool := List.replicate k true ++ [false]
definition OAI.ExactQuantumFactoring.Instruction.encode line 120
def Instruction.encode {q : ℕ} (o : Instruction q) : List Bool := natWord o.gate.primitive.code ++ [o.gate.inverse, o.gate.controlled] ++ (List.ofFn (fun i => o.wire i |>.val)).flatMap natWord
definition OAI.ExactQuantumFactoring.Uniform line 131
def Uniform (family : ℕ → Circuit) : Prop := ∃ generator : Turing.TM2ComputableInPolyTime (fun ℓ => List.replicate ℓ true) Circuit.encode family, ∀ k, Finite (generator.tm.Γ k)
definition OAI.ExactQuantumFactoring.PolynomialResources line 136
def PolynomialResources (family : ℕ → Circuit) : Prop := ∃ bound : Polynomial ℕ, ∀ ℓ, (family ℓ).qubits ≤ bound.eval ℓ ∧ (family ℓ).instructions.length ≤ bound.eval ℓ