Skip to content

Commit 0a6d73a

Browse files
alexanderlhicksXC0Rclaude
committed
feat(OracleReduction): prove identity verifier soundness and reduction log-discard
Rebase of #491 (by @XC0R) onto current main, keeping only the contributions that survive. The two proofs below are XC0R's work from that PR; this commit rebases them past the v4.29 -> v4.31 toolchain bump, drops one hunk that main has since superseded, and fixes a line-length lint. - `Verifier.id_soundness`: replaces a `sorry`. Three other declarations depend on it -- `OracleVerifier.id_soundness`, `Verifier.seqCompose_soundness` and `OracleVerifier.seqCompose_soundness` -- all reaching it via implicit `simp` firing, so this removes their dependence on this `sorry`. They remain `sorryAx`-tainted via the independent `append_soundness` gap. - `Reduction.runWithLog_discard_logs_eq_run`: replaces a `sorry`, plus the supporting private lemma `OptionT_liftM_bind_fst`. A whole-library scan (341601 constants, `Lean.collectAxioms` against a probe axiom substituted for the proof) finds no consumers anywhere in ArkLib. It is nonetheless worth proving: the lemma is `@[simp]`, so the admitted version sat in the default simp set ready to inject `sorryAx` into any future proof whose goal matched its LHS. Proving it disarms that, so the warning docstring is dropped. Dropped from #491: its proof of `Verifier.id_knowledgeSoundness`. That theorem was proved independently on main in #569, which also strengthened the `knowledgeSoundness` definition to close a vacuity (the always-failing extractor discharged it at error 0 for any verifier and any relations). #491's proof targets the pre-#569 event shape -- a bare `WitIn` where the definition now carries `Option WitIn` -- and no longer typechecks. Verified: `lake build` green (4135 jobs); `#print axioms` reports [propext, Classical.choice, Quot.sound] for both theorems and for `OracleVerifier.id_soundness`; no `sorryAx`. Co-authored-by: XC0R <8145037+XC0R@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent a477eea commit 0a6d73a

2 files changed

Lines changed: 58 additions & 12 deletions

File tree

ArkLib/OracleReduction/Execution.lean

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,21 +410,47 @@ private lemma Monad.map_of_prod_fst_eq_prod_fst {m : Type u → Type v} [Monad m
410410
(fun a => (c, a.1)) <$> ma = Prod.mk c <$> Prod.fst <$> ma := by
411411
simp only [Functor.map_map]
412412

413-
/-- Logging the queries made by both parties do not change the output of the reduction.
414-
415-
**(admitted)** — the proof below is a `sorry`; a partial `calc` attempt is retained in comments.
416-
417-
⚠️ This lemma is `@[simp]`, so **any** downstream proof whose `simp` call fires it silently
418-
inherits `sorryAx`. Check `#print axioms` on security-critical results that simp through this
419-
file, and treat a hit as a real gap rather than noise. -/
413+
/-- In OptionT, lifting a pair-valued computation and projecting the first component
414+
in the continuation equals lifting the map and binding directly. -/
415+
private lemma OptionT_liftM_bind_fst {m : TypeType} [Monad m] [LawfulMonad m]
416+
{α β γ : Type} (x : m (α × β)) (f : α → OptionT m γ) :
417+
((liftM x : OptionT m _) >>= fun p => f p.1) =
418+
(liftM (Prod.fst <$> x) : OptionT m _) >>= f := by
419+
rw [← bind_map_left]
420+
show (Prod.fst <$> monadLift x) >>= f = monadLift (Prod.fst <$> x) >>= f
421+
congr 1
422+
simp [liftM, MonadLift.monadLift, OptionT.lift, OptionT.mk,
423+
Functor.map_map, Function.comp]
424+
425+
/-- Logging the queries made by both parties do not change the output of the reduction -/
420426
@[simp]
421427
theorem Reduction.runWithLog_discard_logs_eq_run
422428
{stmt : StmtIn} {wit : WitIn}
423429
{reduction : Reduction oSpec StmtIn WitIn StmtOut WitOut pSpec} :
424430
Prod.fst <$>
425431
reduction.runWithLog stmt wit = reduction.run stmt wit := by
426-
simp [runWithLog, run, Prover.runWithLog]
427-
sorry
432+
simp only [Reduction.runWithLog, Reduction.run, map_bind, map_pure, Functor.map_map,
433+
Function.comp]
434+
have h1 := OptionT_liftM_bind_fst (m := OracleComp (oSpec + [pSpec.Challenge]ₒ))
435+
(Prover.runWithLog stmt wit reduction.prover)
436+
(fun proverResult =>
437+
liftM (simulateQ loggingOracle (Verifier.run stmt proverResult.1 reduction.verifier)).run
438+
>>= fun a_1 => (fun a_2 => (proverResult, a_2)) <$> a_1.1.getM)
439+
-- Prover logging elimination: use OptionT_liftM_bind_fst + Prover.runWithLog_discard_log_eq_run
440+
exact h1 ▸ by
441+
rw [Prover.runWithLog_discard_log_eq_run]
442+
congr 1; ext proverResult
443+
-- Verifier logging elimination by induction on the verifier computation
444+
generalize Verifier.run stmt proverResult.1 reduction.verifier = vc
445+
induction vc using OracleComp.induction with
446+
| pure a => simp [simulateQ_pure, WriterT.run_pure]; rfl
447+
| query_bind t oa ih =>
448+
simp only [run_simulateQ_loggingOracle_query_bind]
449+
simp [bind_map_left, ih, OptionT.run_bind, Option.elimM, bind_assoc, OptionT.run_map]
450+
-- Remaining: OptionT.run distributing through liftM + bind on RHS
451+
-- The RHS has OptionT.run (liftM (query t) >>= oa) which should equal
452+
-- query t >>= fun u => OptionT.run (oa u). This is monadLift_bind for OptionT SubSpec.
453+
rfl
428454
-- calc
429455
-- _ = (do
430456
-- let a ← (simulateQ loggingOracle proverRun).run

ArkLib/OracleReduction/Security/Basic.lean

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,29 @@ private lemma Reduction.run_mk_verifier_id {WitIn WitOut : Type}
554554
@[simp]
555555
theorem Verifier.id_soundness {lang : Set StmtIn} :
556556
(Verifier.id : Verifier oSpec _ _ _).soundness init impl lang lang 0 := by
557-
sorry
558-
-- Approach: after Reduction.run_mk_verifier_id, stmtOut = stmtIn always.
559-
-- Needs StateT.run'_bind/pure or manual support reasoning through OptionT+simulateQ+StateT.
557+
unfold soundness
558+
intro WitIn WitOut witIn prover stmtIn hstmtIn
559+
simp only [ENNReal.coe_zero, nonpos_iff_eq_zero, Reduction.run_mk_verifier_id,
560+
probEvent_eq_zero_iff]
561+
intro x hx hev
562+
apply hstmtIn
563+
rw [OptionT.mem_support_iff] at hx
564+
simp only [OptionT.run_mk, support_bind, Set.mem_iUnion] at hx
565+
obtain ⟨s, _, hx⟩ := hx
566+
simp only [StateT.run'_eq, support_map, Set.mem_image] at hx
567+
obtain ⟨⟨a, s'⟩, ha, rfl⟩ := hx
568+
have hliftM : (liftM ((fun pr => (pr, stmtIn)) <$> Prover.run stmtIn witIn prover) :
569+
OptionT (OracleComp _) _).run =
570+
(fun pr => some (pr, stmtIn)) <$> Prover.run stmtIn witIn prover := by
571+
simp [Functor.map_map]
572+
rw [hliftM, simulateQ_map, StateT.run_map] at ha
573+
simp only [support_map, Set.mem_image, Prod.exists] at ha
574+
obtain ⟨pr, s'', ⟨b, _, _, heq⟩⟩ := ha
575+
have := (Prod.mk.inj heq).1
576+
have := Option.some.inj this
577+
have := (Prod.mk.inj this).2
578+
rw [← this] at hev
579+
exact hev
560580

561581
/-- The straightline extractor for the identity / trivial reduction, which just returns the input
562582
witness. -/

0 commit comments

Comments
 (0)