Skip to content

feat(OracleReduction): prove identity verifier soundness and reduction log-discard - #681

Open
alexanderlhicks wants to merge 3 commits into
mainfrom
pr491-rebased
Open

feat(OracleReduction): prove identity verifier soundness and reduction log-discard#681
alexanderlhicks wants to merge 3 commits into
mainfrom
pr491-rebased

Conversation

@alexanderlhicks

Copy link
Copy Markdown
Collaborator

Supersedes #491 by @XC0R, rebased onto current main. The two proofs are XC0R's
work; this PR carries them past the v4.29 → v4.31 toolchain bump, drops one hunk
that main has since superseded, and fixes a line-length lint.

#491 could not be merged as-is: it was based on a three-month-old commit
(37298e66), conflicted in both files, and one of its three contributions is now
invalid rather than merely stale.

Kept

Verifier.id_soundness — replaces a sorry. Three other declarations depend
on it: OracleVerifier.id_soundness, Verifier.seqCompose_soundness and
OracleVerifier.seqCompose_soundness. All three reach it through implicit
simp firing, so none of them is visible to a text search — in particular
OracleVerifier.id_soundness is proved by simp [OracleVerifier.soundness] and
therefore silently inherited sorryAx on main despite looking proved.

Reduction.runWithLog_discard_logs_eq_run — replaces a sorry, plus the
supporting private lemma OptionT_liftM_bind_fst.

A whole-library scan (341,601 constants, Lean.collectAxioms run against a probe
axiom substituted for the proof) finds no consumers anywhere in ArkLib. It is
still worth proving: the lemma carries @[simp], so the admitted version sat in
the default simp set with a sorry behind it, ready to inject sorryAx into any
future proof whose goal matched its LHS. That is the hazard the previous
docstring warned about; proving it disarms the lemma, so the warning is dropped.

The scan's positive control is OracleVerifier.id_soundness, which reaches its
probe only via implicit simp — confirming the method detects exactly the kind
of reach that a null result would otherwise be suspected of missing.

Dropped

Verifier.id_knowledgeSoundness. Proved independently on main in #569,
which also strengthened the knowledgeSoundness definition to close a vacuity:
previously the always-failing extractor fun _ _ _ _ _ => failure discharged it
at error 0 for any verifier and any relations, because OptionT failure mass
falls outside probEvent. #491's proof targets the pre-#569 event shape — a bare
WitIn where the definition now carries Option WitIn — and no longer
typechecks. main's version is left untouched.

Verification

  • lake build green — 4135 jobs, 0 errors, on this exact commit
  • #print axioms[propext, Classical.choice, Quot.sound] for both theorems
    and for OracleVerifier.id_soundness; no sorryAx
  • 0 lint violations in the touched files

Scope note

The two seqCompose theorems remain sorryAx-tainted via the independent
append_soundness gap in Composition/Sequential/Append.lean. This PR removes
their dependence on this sorry; it does not make them axiom-clean.

The only sorry left in either touched file is the pre-existing, unrelated
Execution.lean:123 (fst_map_simulateQ_loggingOracle_run), which carries the
same @[simp]-contamination shape one lemma upstream and is worth a follow-up.

🤖 Generated with Claude Code

…n 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>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Summary

ℹ️ This PR modifies 1 file(s) under ArkLib/ToMathlib/ — consider whether a corresponding upstream PR is needed.

sorry delta: -2 (2 removed) — net proof progress

This PR completes two previously sorry-blocked proofs in the OracleReduction component, eliminating a latent sorryAx hazard from the default simp set. It also adds a supporting module of monad-lift lemmas and updates the central import file to expose them project-wide.

Mathematical Formalization

  • Verifier.id_soundness (ArkLib/OracleReduction/Security/Basic.lean): Replaces a sorry with a full tactic proof. The theorem states that the identity reduction verifier is sound: if a statement stmtIn is not in the language, then the probability (over the verifier’s randomness) that the identity reduction produces an accepting transcript is zero. The proof unfolds soundness, reduces the probability condition using ENNReal.coe_zero and probEvent_eq_zero_iff, then uses Reduction.run_mk_verifier_id and OptionT.mem_support_iff to derive a contradiction.

  • Reduction.runWithLog_discard_logs_eq_run (ArkLib/OracleReduction/Execution.lean): Replaces a sorry with a proof that discarding the log from runWithLog yields the same result as the plain run. The proof uses the new lemma monadLift_bind_fst together with loggingOracle.fst_map_run_simulateQ and Prover.runWithLog_discard_log_eq_run. A -based spelling is necessary due to OptionT transparency constraints.

  • Supporting lemma monadLift_bind_fst (new file ArkLib/ToMathlib/Control/MonadLift.lean): A specialization of monadLift_bind_map for Prod.fst. Also included is monadLift_bind_map, which equates lifting a computation and post-composing a function in the continuation with lifting the mapped computation. Both are proved from monadLift_map and bind_map_left; they are deliberately not @[simp] because the core simp set rewrites the RHS to the LHS.

Proof Completion (sorries removed)

  • Two sorry placeholders removed: Verifier.id_soundness and Reduction.runWithLog_discard_logs_eq_run. No sorry or admit remain in either touched file (the previously @[simp]-marked lazily proved lemmas are now fully closed).

  • Silent sorryAx hazard eliminated. OracleVerifier.id_soundness and both Verifier.seqCompose_soundness / OracleVerifier.seqCompose_soundness were proved by simp statements that implicitly fired Verifier.id_soundness – meaning that before this PR they transparently carried sorryAx. The axiom scan confirms that all four theorems now resolve to [propext, Classical.choice, Quot.sound] only.

Infrastructure / CI

  • ArkLib.lean: Adds an import of ArkLib.ToMathlib.Control.MonadLift to the central import file, making the new monad-lift lemmas available project-wide.

  • New module ArkLib/ToMathlib/Control/MonadLift.lean containing monadLift_bind_map and monadLift_bind_fst, intended as upstreaming candidates to Init.Control.Lawful.MonadLift.Lemmas.

  • Cleanup: Removes the unused private lemma Monad.map_of_prod_fst_eq_prod_fst from Execution.lean and drops a stray #check comment from Security/Basic.lean. Fixes a line-length lint violation.

Remaining Issues

  • The two seqCompose_soundness theorems remain sorryAx-tainted via an independent gap in Composition/Sequential/Append.lean (append_soundness). This PR removes their dependence on this sorry but does not make them axiom-clean.

  • The only sorry left in either touched file is the pre-existing, unrelated fst_map_simulateQ_loggingOracle_run at Execution.lean:123, which carries the same @[simp]-contamination shape as the now-proved lemmas.

Scope Note

The PR drops one hunk from its predecessor (#491), Verifier.id_knowledgeSoundness, because main independently proved a strengthened version in #569 that uses a different definitional shape (Option WitIn vs. bare WitIn). The (now) type-incorrect proof is not included.


Statistics

Metric Count
📝 Files Changed 4
Lines Added 90
Lines Removed 33

Lean Declarations

✏️ Removed: 1 declaration(s)

ArkLib/OracleReduction/Execution.lean (1)

  • private lemma Monad.map_of_prod_fst_eq_prod_fst {m : Type u → Type v} [Monad m] [LawfulMonad m]
✏️ Added: 2 declaration(s)

ArkLib/ToMathlib/Control/MonadLift.lean (2)

  • theorem monadLift_bind_fst {m : Type u → Type v} {n : Type u → Type w}
  • theorem monadLift_bind_map {m : Type u → Type v} {n : Type u → Type w}

sorry Tracking

Removed: 2 `sorry`(s)

ArkLib/OracleReduction/Execution.lean (1)

  • theorem Reduction.runWithLog_discard_logs_eq_run (L427)

ArkLib/OracleReduction/Security/Basic.lean (1)

  • theorem Verifier.id_soundness {lang : Set StmtIn} : (L557)

📋 **Additional Analysis**

The diff is generally well-structured and follows most of the ArkLib style guidelines. The new file MonadLift.lean is correctly named, uses proper headers, docstrings, and snake_case theorem names. The proofs in Execution.lean and Security/Basic.lean replace sorry with complete, working proofs that leverage the new lemmas. The only style violation is a comment line exceeding the 100-character limit.


📄 **Per-File Summaries**
  • ArkLib.lean: The diff adds a single import of ArkLib.ToMathlib.Control.MonadLift to ArkLib.lean, making the monad-lifting lemmas and instances from that module available project-wide via the central import file. This is a dependency/infrastructure change that does not introduce new theorems, modify definitions, or add any sorry or admit.
  • ArkLib/OracleReduction/Execution.lean: The file removes the unused private lemma Monad.map_of_prod_fst_eq_prod_fst, adds an import of ArkLib.ToMathlib.Control.MonadLift, and completes the proof of Reduction.runWithLog_discard_logs_eq_run, which was previously a sorry. The proof now uses monadLift_bind_fst alongside loggingOracle.fst_map_run_simulateQ and Prover.runWithLog_discard_log_eq_run; an updated comment explains why the /exact spelling is necessary over a direct rw due to transparency issues with OptionT. No sorry or admit remain in the file.
  • ArkLib/OracleReduction/Security/Basic.lean: This diff completes the proof of Verifier.id_soundness, replacing a previously unproven sorry with a full tactic proof. The proof now unfolds soundness, reduces the probability‑error condition using ENNReal.coe_zero and probEvent_eq_zero_iff, and then, via Reduction.run_mk_verifier_id and OptionT.mem_support_iff, shows that any supported execution of the identity reduction yields an output statement equal to the input stmtIn, contradicting the hypothesis stmtIn ∉ lang. Additionally, the diff removes a stray #check Reduction.runWithLog comment line. No new theorems or definitions are introduced; this only completes the existing statement.
  • ArkLib/ToMathlib/Control/MonadLift.lean: The new file ArkLib/ToMathlib/Control/MonadLift.lean adds two theorems: monadLift_bind_map, which equates lifting a computation and post-composing a function in the continuation with lifting the mapped computation, and monadLift_bind_fst, a specialization for Prod.fst. Both are proved using the existing lemmas monadLift_map and bind_map_left. They are intended as upstreaming candidates to Init.Control.Lawful.MonadLift.Lemmas and are deliberately not @[simp] because core's simp set rewrites the right-hand side into the left-hand side.

Last updated: 2026-08-05 14:42 UTC.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Build Timing Report

  • Commit: cbbc02a
  • Message: feat(OracleReduction): prove identity verifier soundness and reduction log-discard
  • Ref: pr491-rebased
  • Comparison baseline: d348ca9 from the previous successful PR update.
  • Measured on ubuntu-latest with /usr/bin/time -p.
  • Commands: clean build rm -rf .lake/build && lake build; warm rebuild lake build; validation wrapper ./scripts/validate.sh.
Measurement Baseline (s) Current (s) Delta (s) Status
Clean build 1296.91 1455.62 +158.71 ok
Warm rebuild 2.42 2.65 +0.23 ok
Validation wrapper 2.61 2.94 +0.33 ok

Incremental Rebuild Signal

  • Warm rebuild saved 1452.97s vs clean (549.29x faster).

This compares a clean project build against an incremental rebuild in the same CI job; it is a lightweight variability signal, not a full cross-run benchmark.

Slowest Current Clean-Build Files

Showing 20 slowest current targets, with comparison against the selected baseline when available.

Current (s) Baseline (s) Delta (s) Path
68.00 59.00 +9.00 ArkLib/ProofSystem/Stir/Combine.lean
66.00 56.00 +10.00 ArkLib/Data/CodingTheory/ProximityGap/DG25/MainResults.lean
65.00 59.00 +6.00 ArkLib/Data/CodingTheory/GuruswamiSudan/Basic.lean
61.00 50.00 +11.00 ArkLib/Data/CodingTheory/JohnsonBound/Lemmas.lean
56.00 51.00 +5.00 ArkLib/Data/CodingTheory/ProximityGap/BCIKS20/AffineSpaces.lean
54.00 48.00 +6.00 ArkLib/Data/CodingTheory/ProximityGap/AHIV22.lean
50.00 47.00 +3.00 ArkLib/Data/CodingTheory/ProximityGap/BCIKS20/AffineLines/BWMatrix.lean
43.00 35.00 +8.00 ArkLib/Data/CodingTheory/BerlekampWelch/Condition.lean
41.00 35.00 +6.00 ArkLib/OracleReduction/LiftContext/Reduction.lean
39.00 36.00 +3.00 ArkLib/Data/CodingTheory/ProximityGap/Folding.lean
32.00 28.00 +4.00 ArkLib/Data/CodingTheory/DivergenceOfSets.lean
29.00 18.00 +11.00 ArkLib/Data/Domain/CosetFftDomain/Subdomain.lean
29.00 27.00 +2.00 ArkLib/Data/CodingTheory/JohnsonBound/Basic.lean
29.00 24.00 +5.00 ArkLib/ProofSystem/Sumcheck/Spec/SingleRound.lean
28.00 19.00 +9.00 ArkLib/ToCompPoly/Univariate/Basic.lean
28.00 22.00 +6.00 ArkLib/OracleReduction/Security/RoundByRound.lean
28.00 24.00 +4.00 ArkLib/Data/Polynomial/Indicator.lean
28.00 25.00 +3.00 ArkLib/Data/Polynomial/FoldingPolynomial.lean
25.00 14.00 +11.00 ArkLib/Data/CodingTheory/GuruswamiSudan/GuruswamiSudan.lean
24.00 24.00 +0.00 ArkLib/Commitments/Functional/KZG/FunctionBinding/EvaluationBindingConflict.lean

alexanderlhicks and others added 2 commits August 5, 2026 03:38
… and linter warnings

Addresses review findings on the identity-soundness / log-discard proofs. No statement changes;
both theorems remain axiom-clean.

1. Generalise the private helper and use core lemmas properly.

   `OptionT_liftM_bind_fst` was hard-coded to `OptionT m` at `Type 0`, and proved by unfolding
   `liftM` / `MonadLift.monadLift` / `OptionT.lift` / `OptionT.mk` through a goal-changing `show`
   plus `congr 1` -- of whose six `simp` arguments five were unused. It is in fact the
   `monadLift`-generic form of `bind_map_left`, so restate it for any
   `[MonadLiftT m n] [LawfulMonadLiftT m n]` over arbitrary universes as `monadLift_bind_fst`,
   proved by `rw [monadLift_map, bind_map_left]` (both Lean core). Shorter, strictly more general,
   and it no longer depends on how `OptionT`'s lift happens to be implemented.

2. Dead code, in the region these changes own.

   - Removed the ~20-line commented-out `calc` attempt below the now-proved theorem; the docstring
     that referred to it ("a partial `calc` attempt is retained in comments") is already gone.
   - Removed `private lemma Monad.map_of_prod_fst_eq_prod_fst`, which nothing references.

3. Linter warnings. The above removes all 8 that `lake build` reported inside the new code
   (1 × `linter.style.show`, 7 × `linter.unusedSimpArgs`). The warnings remaining in
   `Execution.lean` are pre-existing.

4. Comments. Replaced the "Remaining: ..." / "should equal" note in front of the closing `rfl`,
   which read as unfinished work, with a statement of what the `rfl` discharges; and recorded why
   the verifier-logging step needs an explicit induction rather than reusing VCV-io's
   `loggingOracle.fst_map_run_simulateQ` or ArkLib's `loggingOracle.map_fst_run_simulateQ` (the
   verifier's run sits under `liftM` inside `OptionT`, so its log is consumed by an `OptionT` bind
   rather than a `Prod.fst` map -- six drop-in variants of those lemmas were tried and none
   applies). Named the three anonymous shadowing `have`s at the end of `Verifier.id_soundness`.

Correction to the previous commit message: it says all three declarations that depend on
`Verifier.id_soundness` reach it by implicit `simp` firing and are invisible to a text search. Only
`OracleVerifier.id_soundness` does. `Verifier.seqCompose_soundness` names it outright
(`Composition/Sequential/General.lean`, `exact Verifier.id_soundness init impl`) and
`OracleVerifier.seqCompose_soundness` reaches it through that. The substantive claim is unaffected:
a library-wide `Lean.collectAxioms` sweep confirms exactly three declarations move from
`sorryAx`-tainted to clean -- `Verifier.id_soundness`, `OracleVerifier.id_soundness` (the one
silent dependent) and `Reduction.runWithLog_discard_logs_eq_run`.

Verified: `lake build` green (4135 jobs, 0 errors); `#print axioms` reports
[propext, Classical.choice, Quot.sound] for both theorems and for `OracleVerifier.id_soundness`;
no style-lint error and no build-linter warning inside the changed ranges.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… lift helper to ToMathlib

Acts on a fresh adversarial review that overturned a claim in the previous commit.

1. The previous commit asserted, in a code comment, that VCV-io's
   `loggingOracle.fst_map_run_simulateQ` and ArkLib's `loggingOracle.map_fst_run_simulateQ` could
   not be used for the verifier-logging step, and justified a hand-rolled `OracleComp.induction` on
   that basis. **That was wrong.** Applying this file's own `monadLift_bind_fst` a second time --
   to the verifier's lift, exactly as it is already applied to the prover's -- reduces the goal to
   `loggingOracle.fst_map_run_simulateQ`'s left-hand side. The induction, its two bare `rfl`s and
   the false comment are gone; the step is now

     have hVerif := monadLift_bind_fst ...
     exact hVerif ▸ by rw [loggingOracle.fst_map_run_simulateQ]; rfl

   Net -14 lines, and the proof now uses the library instead of re-deriving it, per the repo's
   reuse rule. My earlier search missed this because it only tried the logging lemmas *directly* at
   the goal, never after a second application of the helper.

2. The helper moves to `ArkLib/ToMathlib/Control/MonadLift.lean` and stops being `private`. It
   mentions nothing outside Lean core (it is a two-step composite of `monadLift_map` and
   `bind_map_left`), so per the repo layout it belongs in `ToMathlib` as an upstreaming candidate
   rather than buried in `OracleReduction/Execution.lean`. It is also generalised: the primitive is
   now `monadLift_bind_map` for an arbitrary `h : α → α'` (same one-line proof), with
   `monadLift_bind_fst` as the `Prod.fst` instance. Deliberately not `@[simp]` -- core's simp set
   rewrites its RHS *into* its LHS, so it is anti-normal-form and must be used explicitly.

3. The docstring now records why the `▸`/`exact` spelling is forced rather than stylistic: after
   `simp only` the goal is not type-correct at `instances` transparency (ArkLib's `Verifier.run` is
   an `OptionT`, which `kabstract` sees as `OracleComp _ (Option _)`), so `rw` cannot operate on it
   at all, for any spelling of the rewrite lemma.

Also removed a stray `#check Reduction.runWithLog` sitting in library code in `Security/Basic.lean`
(pre-existing, in a file this PR already edits).

Left alone deliberately: the zero-consumer, `stop`-admitted `fst_map_simulateQ_loggingOracle_run`
higher up in `Execution.lean`. Note `stop` expands to `repeat sorry`, so it is a `grep sorry`-
invisible admit. The companion PR #682 deletes it; removing it here too would collide.

Verified: `lake build` green (4135 jobs, 0 errors); `#print axioms` reports
[propext, Classical.choice, Quot.sound] for both theorems and for `OracleVerifier.id_soundness`;
`ArkLib.lean` regenerated via `scripts/update-lib.sh` (316 imports, `check-imports.sh` passes);
no new build-linter warning and no new style-lint error in the changed ranges.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant