theoremclock_injective (V : NPVerifier) : Function.Injective (clock V) :=by
proof · 4
lines
intro a b h
have hs := (VerifierFront.clockSlots V).injective (Sum.inl.inj h)
have ho :=ClockPreparation.outputSlot_injective _ hs
cases a <;> cases b <;> simp_all [ClockPreparation.clockOutput] <;> cases ho
deftransitionPorts (V : NPVerifier) : TransitionArena.Tape ↪ TapeVwhere
body · 21
lines
toFun := transitionTape V
inj' :=by
intro a b h
cases a with
| inl a =>
cases b with
| inl b => simpa [transitionTape] using h
| inr b =>
cases b <;>
simp_all [transitionTape, raw, q, capacity, countdown, clock]
| inr a =>
cases b with
| inl b =>
cases a <;>
simp_all [transitionTape, raw, q, capacity, countdown, clock]
| inr b =>
cases a <;> cases b <;>
simp_all [transitionTape, q, capacity, countdown, raw, clock,
VerifierFront.raw, VerifierFront.clockTape, VerifierFront.clockSlots,
ClockPreparation.clockOutput] <;>
cases h
definitializationPorts (V : NPVerifier) : InitializationAssembly.Tape9 ↪ TapeVwhere
body · 11
lines
toFun := initializationTape V
inj' :=by
intro a b h
cases a <;> cases b <;>
simp_all [initializationTape, q, capacity, tokens, count, shared,
raw, framed, clock, VerifierFront.raw, VerifierFront.stream,
VerifierFront.clockTape, VerifierFront.clockSlots,
ClockPreparation.clockOutput]
all_goals
have ho :=ClockPreparation.outputSlot_injective (ClockPreparation.clockPolynomials V) h
cases ho
theoreminitialTapes_eq (V : NPVerifier) (input : ListBool) :
initialTapes V input = fun t =>if t = raw Vthen input else [] :=by
proof · 8
lines
funext t
cases t with
| inl t =>
cases t with
| inl i => fin_cases i <;> simp [initialTapes, frontTapes, VerifierFront.frameTapes,
raw, VerifierFront.raw]
| inr t => simp [initialTapes, frontTapes, VerifierFront.frameTapes, raw, VerifierFront.raw]
| inr t => simp [initialTapes, frontTapes, raw]
@[simp]theoremfrontendPrepared_clock (V : NPVerifier) (input : ListBool)
(c : ClockPreparation.Clock) : frontendPrepared V input (clock V c) =
encodeWord (ClockPreparation.clockValue V input.length c) :=
@[simp]theorembootstrapPrepared_front (V : NPVerifier) (input : ListBool)
(t : VerifierFront.TapeV) :
bootstrapPrepared V input (frontPorts V t) = VerifierFront.preparedTapes V input t :=by
theorembootstrapPrepared_other (V : NPVerifier) (input : ListBool) (t : TapeV)
(hc : t ≠ current V) (ht : t ≠ count V) (hz : t ≠ cursor V) :
bootstrapPrepared V input t = frontendPrepared V input t :=
proof · 1
line
ProducerBootstrap.prepared_other (bootstrapPorts V) (frontendPrepared V input) t hc ht hz
theorembootstrap_initialization_view (V : NPVerifier) (input : ListBool) :
(fun t => bootstrapPrepared V input (initializationPorts V t)) =
initializationBase V input :=by
proof · 8
lines
funext t
cases t <;>
simp [initializationTape, initializationBase, bootstrapPrepared,
ProducerBootstrap.prepared, ProducerBootstrap.copied,
frontendPrepared, frontTapes, current, count, cursor, tokens, shared,
raw, framed, q, capacity, freeInputs, clock,
VerifierFront.prepared_raw, VerifierFront.prepared_stream, VerifierFront.prepared_clock,
ClockPreparation.clockValue, encodeWord]
defboundary (V : NPVerifier) (input : ListBool) (remaining : Nat) (s : Snapshot) : TapeV→ListBool:=
body · 2
lines
ForestPlacement.fill (transitionPorts V) (bootstrapPrepared V input)
(TransitionArena.tapes (localBase V input) (VerifierCircuit.capacity V input.length) remaining s)
deffinished (V : NPVerifier) (input : ListBool) (s : Snapshot) : TapeV→ListBool:=
body · 2
lines
ForestPlacement.fill (transitionPorts V) (bootstrapPrepared V input)
(TransitionArena.finishTapes (localBase V input) (VerifierCircuit.capacity V input.length) s)
theoremfill_fill {IK : Type} (ports : I ↪ K) (base : K→ListBool)
(first second : I→ListBool) :
ForestPlacement.fill ports (ForestPlacement.fill ports base first) second =
ForestPlacement.fill ports base second :=by
proof · 8
lines
classical
funext k
by_cases hin : ∃ i, ports i = k
· obtain ⟨i, rfl⟩ := hin
simp only [ForestPlacement.fill_at]
· rw [ForestPlacement.fill_other ports _ _ k (not_exists.mp hin),
ForestPlacement.fill_other ports _ _ k (not_exists.mp hin),
ForestPlacement.fill_other ports _ _ k (not_exists.mp hin)]
theoremboundary_view (V : NPVerifier) (input : ListBool) (remaining : Nat) (s : Snapshot) :
(fun t => boundary V input remaining s (transitionPorts V t)) =
TransitionArena.tapes (localBase V input) (VerifierCircuit.capacity V input.length) remaining s :=by
theoremfinished_view (V : NPVerifier) (input : ListBool) (s : Snapshot) :
(fun t => finished V input s (transitionPorts V t)) =
TransitionArena.finishTapes (localBase V input) (VerifierCircuit.capacity V input.length) s :=by
theoremboundary_other (V : NPVerifier) (input : ListBool) (remaining : Nat) (s : Snapshot)
(k : TapeV) (outside : ∀ t, transitionPorts V t ≠ k) :
boundary V input remaining s k = bootstrapPrepared V input k :=
theoremfinished_other (V : NPVerifier) (input : ListBool) (s : Snapshot)
(k : TapeV) (outside : ∀ t, transitionPorts V t ≠ k) :
finished V input s k = bootstrapPrepared V input k :=
theoremiteration_handoff (V : NPVerifier) (input : ListBool) (remaining : Nat) (s next : Snapshot) :
ForestPlacement.fill (transitionPorts V) (boundary V input remaining s)
(TransitionArena.finishTapes (localBase V input) (VerifierCircuit.capacity V input.length) next) =
finished V input next := fill_boundary V input remaining s _
theoremacceptance_handoff (V : NPVerifier) (input : ListBool) (s next : Snapshot) :
ForestPlacement.fill (transitionPorts V) (finished V input s)
(TransitionArena.finishTapes (localBase V input) (VerifierCircuit.capacity V input.length) next) =
finished V input next := fill_finished V input s _
theoremfinished_private (V : NPVerifier) (input : ListBool) (s : Snapshot)
(w : Work) (outside : ∀ t, transitionPorts V t ≠ .inr w) :
finished V input s (.inr w) = [] :=by
proof · 6
lines
rw [finished_other V input s _ outside,
bootstrapPrepared_other V input _
(Ne.symm (outside (.inl (.lower .current))))
(Ne.symm (outside (.inl (.lower .remaining))))
(Ne.symm (outside (.inr .cursor)))]
rfl
theorembootstrap_clock (V : NPVerifier) (input : ListBool) (c : ClockPreparation.Clock) :
bootstrapPrepared V input (clock V c) = encodeWord (ClockPreparation.clockValue V input.length c) :=by
proof · 3
lines
change bootstrapPrepared V input (frontPorts V (VerifierFront.clockTape V c)) = _
rw [bootstrapPrepared_front]
exact VerifierFront.prepared_clock V input c
theorembootstrap_extra (V : NPVerifier) (input : ListBool) (s : Snapshot)
(e : TransitionArena.Extra) :
localBase V input (.inr e) =
TransitionArena.tapes (localBase V input) (VerifierCircuit.capacity V input.length)
(V.horizon input.length) s (.inr e) :=by
proof · 6
lines
cases e <;> simp only [TransitionArena.tapes]
all_goals first
| rfl
| exact bootstrapPrepared_cursor V input
| exact bootstrap_clock V input .capacity
| exact bootstrap_clock V input .horizon
theoreminitial_result_view (V : NPVerifier) (input : ListBool) :
(fun t =>InitializationStage.result (forestPorts V) (bootstrapPrepared V input) V input
(transitionPorts V t)) =
TransitionArena.tapes (localBase V input) (VerifierCircuit.capacity V input.length)
(V.horizon input.length) (snapshot (VerifierCircuit.initialFrame V input)) :=by
proof · 18
lines
funext t
cases t with
| inl t =>
change InitializationStage.result (forestPorts V) _ V input (forestPorts V t) = _
rw [InitializationStage.result_at]
cases t with
| lower t => cases t <;> rfl
| tokens => rfl
| records => rfl
| rootTable => rfl
| inr e =>haveoutside : ∀ t, forestPorts V t ≠ transitionPorts V (.inr e) :=by
intro t h
change transitionPorts V (.inl t) = transitionPorts V (.inr e) at h
have impossible := (transitionPorts V).injective h
cases impossible
rw [InitializationStage.result_other _ _ _ _ _ outside]
exact bootstrap_extra V input _ e
theoremclock_outside (V : NPVerifier) (c : ClockPreparation.Clock)
(hq : c ≠ .witness) (hS : c ≠ .capacity) (hT : c ≠ .horizon) :
∀ t, transitionPorts V t ≠ clock V c :=by
proof · 11
lines
intro t
cases t with
| inl t => simp [transitionTape, clock]
| inr e =>
cases e with
| q => change clock V .witness ≠ clock V c; simpa only [ne_eq, clock_eq_iff] usingNe.symm hq
| capacity => change clock V .capacity ≠ clock V c; simpa only [ne_eq, clock_eq_iff] usingNe.symm hS
| countdown => change clock V .horizon ≠ clock V c; simpa only [ne_eq, clock_eq_iff] usingNe.symm hT
| raw => exact raw_ne_clock V c
| cursor | position | address | value | scratch | copy | saveLeft | saveRight =>
simp [transitionTape, clock]
theoremframed_outside (V : NPVerifier) : ∀ t, transitionPorts V t ≠ framed V:=by
proof · 11
lines
intro t
cases t with
| inl t => simp [transitionTape, framed]
| inr e =>
cases e with
| q => exact clock_ne_framed V .witness
| capacity => exact clock_ne_framed V .capacity
| countdown => exact clock_ne_framed V .horizon
| raw => exact raw_ne_framed V
| cursor | position | address | value | scratch | copy | saveLeft | saveRight =>
simp [transitionTape, framed]
theoremboundary_clock (V : NPVerifier) (input : ListBool) (remaining : Nat) (s : Snapshot)
(c : ClockPreparation.Clock) (hq : c ≠ .witness) (hS : c ≠ .capacity) (hT : c ≠ .horizon) :
boundary V input remaining s (clock V c) = encodeWord (ClockPreparation.clockValue V input.length c) :=by
proof · 2
lines
rw [boundary_other V input remaining s _ (clock_outside V c hq hS hT)]
exact bootstrap_clock V input c
theoremfinished_clock (V : NPVerifier) (input : ListBool) (s : Snapshot)
(c : ClockPreparation.Clock) (hq : c ≠ .witness) (hS : c ≠ .capacity) (hT : c ≠ .horizon) :
finished V input s (clock V c) = encodeWord (ClockPreparation.clockValue V input.length c) :=by
proof · 2
lines
rw [finished_other V input s _ (clock_outside V c hq hS hT)]
exact bootstrap_clock V input c
theoremboundary_framed (V : NPVerifier) (input : ListBool) (remaining : Nat) (s : Snapshot) :
boundary V input remaining s (framed V) = encodeWord input.length ++ input :=by
proof · 4
lines
rw [boundary_other V input remaining s _ (framed_outside V)]
change bootstrapPrepared V input (frontPorts V (VerifierFront.stream V)) = _
rw [bootstrapPrepared_front]
exact VerifierFront.prepared_stream V input
theoremfinished_framed (V : NPVerifier) (input : ListBool) (s : Snapshot) :
finished V input s (framed V) = encodeWord input.length ++ input :=by
proof · 4
lines
rw [finished_other V input s _ (framed_outside V)]
change bootstrapPrepared V input (frontPorts V (VerifierFront.stream V)) = _
rw [bootstrapPrepared_front]
exact VerifierFront.prepared_stream V input
theoremfinish_view (V : NPVerifier) (input : ListBool) (s : Snapshot) :
(fun t => finished V input s (finishPorts V t)) =
CircuitFinish.memory s.currentBits
(encodeWord (2 * V.witnessBound.eval input.length + 1)) s.rootBits s.reversedRecords [] [] [] :=by
proof · 9
lines
funext t
cases t with
| current => exact finished_current V input s
| freeInputs => exact finished_freeInputs V input s
| root => exact finished_roots V input s
| reversedRecords => exact finished_records V input s
| output => exact finished_private V input s _ (private_finish_outside V .output)
| gateCount => exact finished_private V input s _ (private_finish_outside V .gateCount)
| scratch => exact finished_private V input s _ (private_finish_outside V .scratch)
theoremcircuitFinish_view (V : NPVerifier) (input : ListBool) :
(fun t => finished V input (snapshot (finalFrame V input)) (finishPorts V t)) =
CircuitFinish.initialTapes (VerifierCircuit.circuitOfVerifier V input).wires
(VerifierCircuit.circuitOfVerifier V input).inputs
(VerifierCircuit.circuitOfVerifier V input).output.val
(recordsBits (VerifierCircuit.circuitOfVerifier V input).records) :=by