Skip to content

Commit 66da7fa

Browse files
author
Abraxas1010
committed
feat(Append): prove completeness composition under init-uniformity; add run_pure_verifier
Two new theorems alongside the open general append_completeness: * Reduction.run_pure_verifier — for any reduction whose verifier is a pure function f of statement and transcript, (R.run stmt wit).run equals the lifted prover run followed by pure massage. The run characterization the support_run_pure_verifier premise pattern suggests. * Reduction.append_perfectCompleteness_of_proverFactorization — perfect completeness composes across append given: pure verifiers, the prover-level simulated factorization (the distributional shadow of the open Prover.append_run, taken as a hypothesis so this theorem is usable now and the factorization can land separately), and — answering the TODO at the top of this section — R2's completeness quantified over ALL initial states: the appended run hands R2 whatever state R1's prover left, so a fixed-init premise cannot apply. A run-level factorization through R2.run is false pointwise (the appended verifier chains V1's output while the appended prover chains P1's; they agree only on honest supports), hence the prover-level hypothesis. No sorry; axioms [propext, Classical.choice, Quot.sound]. All importers build. From The Institute for Ontological Mathematics (IAOM) / Equation Capital dba Apoth3osis.
1 parent fad5cbf commit 66da7fa

1 file changed

Lines changed: 150 additions & 0 deletions

File tree

  • ArkLib/OracleReduction/Composition/Sequential

ArkLib/OracleReduction/Composition/Sequential/Append.lean

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,156 @@ theorem append_perfectCompleteness (R₁ : Reduction oSpec Stmt₁ Wit₁ Stmt
460460
convert Reduction.append_completeness R₁ R₂ h₁ h₂
461461
simp only [add_zero]
462462

463+
/-- **Run of a reduction with a pure verifier** (abstract prover): the `OptionT`
464+
plumbing collapses onto the prover's run. Reusable for any reduction whose verifier
465+
is a pure function of statement and transcript (their `support_run_pure_verifier`
466+
premise pattern). -/
467+
theorem run_pure_verifier
468+
(R : Reduction oSpec Stmt₁ Wit₁ Stmt₂ Wit₂ pSpec₁)
469+
(f : Stmt₁ → FullTranscript pSpec₁ → Stmt₂)
470+
(hf : ∀ stmt td, R.verifier.verify stmt td =
471+
(pure (f stmt td) : OptionT (OracleComp oSpec) Stmt₂))
472+
(stmt : Stmt₁) (wit : Wit₁) :
473+
(R.run stmt wit).run =
474+
((liftM (R.prover.run stmt wit) : OracleComp _ _) >>= fun r =>
475+
pure (some ((r.1, r.2), f stmt r.1))) := by
476+
unfold Reduction.run
477+
simp only [OptionT.run_bind, Option.elimM]
478+
rw [show ((liftM (R.prover.run stmt wit) : OptionT (OracleComp _) _)).run
479+
= (liftM (R.prover.run stmt wit) : OracleComp _ _) >>= fun r => pure (some r) from rfl]
480+
rw [bind_assoc]
481+
refine bind_congr fun r => ?_
482+
rw [pure_bind]
483+
simp only [Option.elim_some, Verifier.run, hf]
484+
rfl
485+
486+
/-- **Perfect completeness composes across `Reduction.append`** under:
487+
pure verifiers (`hf₁`, `hf₂`), the prover-level simulated factorization `hfact`
488+
(the distributional shadow of `Prover.append_run` — the sole remaining upstream
489+
obligation), and — the side condition answering the upstream TODO — R₂ complete
490+
**uniformly in the initial state** (`h₂` quantifies over `init'`; the appended run
491+
hands R₂ whatever state R₁'s prover left, so a fixed-`init` premise cannot apply). -/
492+
theorem append_perfectCompleteness_of_proverFactorization
493+
(R₁ : Reduction oSpec Stmt₁ Wit₁ Stmt₂ Wit₂ pSpec₁)
494+
(R₂ : Reduction oSpec Stmt₂ Wit₂ Stmt₃ Wit₃ pSpec₂)
495+
(f₁ : Stmt₁ → FullTranscript pSpec₁ → Stmt₂)
496+
(f₂ : Stmt₂ → FullTranscript pSpec₂ → Stmt₃)
497+
(hf₁ : ∀ stmt td, R₁.verifier.verify stmt td =
498+
(pure (f₁ stmt td) : OptionT (OracleComp oSpec) Stmt₂))
499+
(hf₂ : ∀ stmt td, R₂.verifier.verify stmt td =
500+
(pure (f₂ stmt td) : OptionT (OracleComp oSpec) Stmt₃))
501+
(hfact : ∀ (stmt : Stmt₁) (wit : Wit₁) (s : σ),
502+
StateT.run (simulateQ (QueryImpl.addLift impl challengeQueryImpl :
503+
QueryImpl _ (StateT σ ProbComp))
504+
(liftM ((R₁.append R₂).prover.run stmt wit) :
505+
OracleComp (oSpec + [(pSpec₁ ++ₚ pSpec₂).Challenge]ₒ) _)) s =
506+
(do
507+
let (r₁, s₁) ← StateT.run (simulateQ (QueryImpl.addLift impl challengeQueryImpl :
508+
QueryImpl _ (StateT σ ProbComp))
509+
(liftM (R₁.prover.run stmt wit) :
510+
OracleComp (oSpec + [pSpec₁.Challenge]ₒ) _)) s
511+
let (r₂, s₂) ← StateT.run (simulateQ (QueryImpl.addLift impl challengeQueryImpl :
512+
QueryImpl _ (StateT σ ProbComp))
513+
(liftM (R₂.prover.run r₁.2.1 r₁.2.2) :
514+
OracleComp (oSpec + [pSpec₂.Challenge]ₒ) _)) s₁
515+
pure ((r₁.1 ++ₜ r₂.1, r₂.2), s₂)))
516+
(h₁ : R₁.perfectCompleteness init impl rel₁ rel₂)
517+
(h₂ : ∀ init' : ProbComp σ, R₂.perfectCompleteness init' impl rel₂ rel₃) :
518+
(R₁.append R₂).perfectCompleteness init impl rel₁ rel₃ := by
519+
simp only [Reduction.perfectCompleteness, Reduction.completeness,
520+
ENNReal.coe_zero, tsub_zero] at h₁ h₂ ⊢
521+
intro stmtIn witIn hIn
522+
-- The appended verifier of pure verifiers is the pure composite.
523+
have hfA : ∀ stmt td, (R₁.append R₂).verifier.verify stmt td =
524+
(pure (f₂ (f₁ stmt td.fst) td.snd) : OptionT (OracleComp oSpec) Stmt₃) := by
525+
intro stmt td
526+
show (do
527+
let stmt₂ ← R₁.verifier.verify stmt td.fst
528+
let r ← R₂.verifier.verify stmt₂ td.snd
529+
pure r : OptionT (OracleComp oSpec) Stmt₃) = _
530+
rw [hf₁, pure_bind, hf₂]
531+
simp only [bind_pure]
532+
-- Composed-run characterization through the appended prover.
533+
have hcomp := run_pure_verifier (R₁.append R₂)
534+
(fun stmt td => f₂ (f₁ stmt td.fst) td.snd) hfA stmtIn witIn
535+
simp only [hcomp]
536+
rw [ge_iff_le, one_le_probEvent_iff, probEvent_eq_one_iff]
537+
-- Extract stage facts from h₁ at init.
538+
have h₁' := h₁ stmtIn witIn hIn
539+
rw [ge_iff_le, one_le_probEvent_iff, probEvent_eq_one_iff] at h₁'
540+
simp only [run_pure_verifier R₁ f₁ hf₁] at h₁'
541+
obtain ⟨-, h₁supp⟩ := h₁'
542+
-- Per-state stage-1 prover facts (constructive membership into h₁supp's support).
543+
have h₁supp' : ∀ s ∈ _root_.support init,
544+
∀ q ∈ _root_.support (StateT.run (simulateQ (QueryImpl.addLift impl challengeQueryImpl :
545+
QueryImpl _ (StateT σ ProbComp))
546+
(liftM (R₁.prover.run stmtIn witIn) :
547+
OracleComp (oSpec + [pSpec₁.Challenge]ₒ) _)) s),
548+
(f₁ stmtIn q.1.1, q.1.2.2) ∈ rel₂ ∧ q.1.2.1 = f₁ stmtIn q.1.1 := by
549+
intro s hs q hq
550+
exact h₁supp ((q.1.1, q.1.2), f₁ stmtIn q.1.1) (by
551+
rw [OptionT.mem_support_iff]
552+
simp only [OptionT.run_mk, support_bind, Set.mem_iUnion]
553+
refine ⟨s, hs, ?_⟩
554+
simp only [simulateQ_bind, StateT.run'_eq, StateT.run_bind, support_map, support_bind,
555+
Set.mem_image, Set.mem_iUnion, exists_prop]
556+
exact ⟨(some ((q.1.1, q.1.2), f₁ stmtIn q.1.1), q.2),
557+
⟨q, hq, by simp [simulateQ_pure, StateT.run_pure]⟩, rfl⟩)
558+
constructor
559+
· -- No failure: the composed value is unconditionally `some`.
560+
rw [OptionT.probFailure_eq, OptionT.run_mk]
561+
simp only [probFailure_eq_zero, zero_add]
562+
apply probOutput_eq_zero_of_not_mem_support
563+
simp only [support_bind, Set.mem_iUnion, not_exists]
564+
intro s _ h
565+
simp only [simulateQ_bind, StateT.run'_eq, StateT.run_bind, support_map,
566+
support_bind] at h
567+
simp only [Set.mem_image, Set.mem_iUnion, exists_prop] at h
568+
obtain ⟨p, ⟨r, _, hp⟩, hnone⟩ := h
569+
simp only [simulateQ_pure, StateT.run_pure, support_pure, Set.mem_singleton_iff] at hp
570+
rw [hp] at hnone
571+
exact Option.some_ne_none _ hnone
572+
· -- Support ⊆ event: decompose through hfact, compose event₁ and event₂.
573+
intro x hx
574+
rw [OptionT.mem_support_iff] at hx
575+
simp only [OptionT.run_mk, support_bind, Set.mem_iUnion] at hx
576+
obtain ⟨s, hs, hx⟩ := hx
577+
simp only [simulateQ_bind, StateT.run'_eq, StateT.run_bind, support_map,
578+
support_bind] at hx
579+
simp only [Set.mem_image, Set.mem_iUnion, exists_prop] at hx
580+
obtain ⟨p, ⟨r, hr, hp⟩, hsome⟩ := hx
581+
rw [hfact stmtIn witIn s] at hr
582+
simp only [support_bind, support_pure, Set.mem_iUnion, Set.mem_singleton_iff,
583+
exists_prop] at hr
584+
obtain ⟨q₁, hq₁, q₂, hq₂, hr_eq⟩ := hr
585+
obtain ⟨hrel₂, hstmt₂⟩ := h₁supp' s hs q₁ hq₁
586+
-- Stage-2 facts from h₂ at the deterministic mid state.
587+
have h₂' := h₂ (pure q₁.2) q₁.1.2.1 q₁.1.2.2 (by rw [hstmt₂]; exact hrel₂)
588+
rw [ge_iff_le, one_le_probEvent_iff, probEvent_eq_one_iff] at h₂'
589+
simp only [run_pure_verifier R₂ f₂ hf₂] at h₂'
590+
obtain ⟨-, h₂supp⟩ := h₂'
591+
have hev₂ := h₂supp ((q₂.1.1, q₂.1.2), f₂ q₁.1.2.1 q₂.1.1) (by
592+
rw [OptionT.mem_support_iff]
593+
simp only [OptionT.run_mk, support_bind, Set.mem_iUnion]
594+
refine ⟨q₁.2, by simp, ?_⟩
595+
simp only [simulateQ_bind, StateT.run'_eq, StateT.run_bind, support_map, support_bind,
596+
Set.mem_image, Set.mem_iUnion, exists_prop]
597+
exact ⟨(some ((q₂.1.1, q₂.1.2), f₂ q₁.1.2.1 q₂.1.1), q₂.2),
598+
⟨q₂, hq₂, by simp [simulateQ_pure, StateT.run_pure]⟩, rfl⟩)
599+
obtain ⟨hrel₃, hstmt₃⟩ := hev₂
600+
-- Assemble the composed event.
601+
simp only [simulateQ_pure, StateT.run_pure, support_pure, Set.mem_singleton_iff] at hp
602+
rw [hp] at hsome
603+
cases Option.some.inj hsome
604+
rw [hr_eq]
605+
refine ⟨?_, ?_⟩
606+
· show (f₂ (f₁ stmtIn (q₁.1.1 ++ₜ q₂.1.1).fst) (q₁.1.1 ++ₜ q₂.1.1).snd, q₂.1.2.2) ∈ rel₃
607+
rw [FullTranscript.append_fst, FullTranscript.append_snd, ← hstmt₂]
608+
exact hrel₃
609+
· show q₂.1.2.1 = f₂ (f₁ stmtIn (q₁.1.1 ++ₜ q₂.1.1).fst) (q₁.1.1 ++ₜ q₂.1.1).snd
610+
rw [FullTranscript.append_fst, FullTranscript.append_snd, ← hstmt₂]
611+
exact hstmt₃
612+
463613
variable {R₁ : Reduction oSpec Stmt₁ Wit₁ Stmt₂ Wit₂ pSpec₁}
464614
{R₂ : Reduction oSpec Stmt₂ Wit₂ Stmt₃ Wit₃ pSpec₂}
465615

0 commit comments

Comments
 (0)