CWSS protocol infrastructure - #602
Conversation
🤖 PR Summary
CWSS Protocol InfrastructureThis PR adds the infrastructure for Coordinate-Wise Special Soundness (CWSS) in sequential compositions of verifiers, including the degenerate no-challenge case, and equips core proof-system components with CWSS theorems. The work is foundational for tree-soundness proofs in fold-style protocols. Mathematical Formalization
Protocols / Soundness
Incomplete Proofs / Placeholders
Documentation
Refactoring
Infrastructure / CI
The core new infrastructure is concentrated in Statistics
Lean Declarations ✏️ Removed: 4 declaration(s)
✏️ Added: 48 declaration(s)
✏️ Affected: 4 declaration(s) (line number changed)
✅ Removed: 1 `sorry`(s)
📋 **Additional Analysis**The diff does not relate to the supplied instructions. 📄 **Per-File Summaries**
Last updated: 2026-07-15 12:22 UTC. |
There was a problem hiding this comment.
🤖 AI Review
Overall Summary:
TL;DR: The PR establishes a robust cross-file architecture for Coordinate-Wise Special Soundness (CWSS). However, changes are requested due to the introduction of escape hatches and the use of an invalid standard library identifier.
Mechanical Pre-Check Results: The mechanical pre-checks detected the introduction of sorryAx in ArkLib/ProofSystem/Component/SendClaim.lean and ArkLib/ProofSystem/Component/SendWitness.lean, triggering a hard verdict rule. There are also pre-existing sorrys in SendWitness.lean.
Checklist Coverage: No explicit checklist was provided. The PR aligns well with standard cryptographic definitions of soundness.
Cross-File Issues: The cross-file composition chain for CWSS is structurally robust. The foundational IsPure typeclass enables n-ary sequential composition theorems, and components correctly instantiate their CWSS obligations via the NoChallenge bridge. The deferred completeness proofs (associated with the sorrys) do not compromise the soundness composition chain.
Key Lean 4 / Mathlib Issues:
- The function Classical.ofNonempty is used to provide a dummy witness, but this is not a standard Lean 4 or Mathlib function and will result in an unknown identifier error. (
ArkLib/ProofSystem/Component/ReduceClaim.lean:193 and ArkLib/ProofSystem/Component/ReduceClaim.lean:399) - Escape hatches (sorryAx and sorry) were introduced to defer perfectCompleteness proofs. While orthogonal to CWSS, these violate the strict verification rules and block downstream completeness proofs. (
ArkLib/ProofSystem/Component/SendClaim.lean, ArkLib/ProofSystem/Component/SendWitness.lean)
Overall Verdict: Changes Requested
🔍 **Mechanical Pre-Check Results**
Escape hatches introduced in this PR (triggers hard verdict rule):
sorryAxintroduced inArkLib/ProofSystem/Component/SendClaim.lean:intorelIn. These results aresorryAx-free. This mirrorsSendSingleWitness(the specialsorryAxintroduced inArkLib/ProofSystem/Component/SendWitness.lean:These results aresorryAx-free. The indexed-family oracle variant (section OracleReduction) issorryAxintroduced inArkLib/ProofSystem/Component/SendWitness.lean:below (each withIsPure+coordinateWiseSpecialSound, allsorryAx-free).
Pre-existing escape hatches in touched files (context only, does not affect verdict):
sorryinArkLib/ProofSystem/Component/SendWitness.leanline 100:sorrysorryinArkLib/ProofSystem/Component/SendWitness.leanline 343:sorry
🔗 **Cross-File Analysis**
Cross-File Analysis:
The PR constructs a robust cross-file composition chain for Coordinate-Wise Special Soundness (CWSS). The foundational typeclass IsPure is introduced in IsPure.lean to capture deterministic verifiers. This enables the n-ary sequential composition theorems in SeqCompose.lean (seqCompose_treeSpecialSound and seqCompose_coordinateWiseSpecialSound) by discharging the deterministic-left hypothesis required by binary append operations at each inductive step. To support zero-round components, NoChallenge.lean introduces a bridge collapsing CWSS to a transcript-level extraction obligation when IsEmpty ChallengeIdx. The component files (CheckClaim, ReduceClaim, SendClaim, SendWitness) correctly wire into this architecture: they each define pure verifiers, prove IsPure, and instantiate their CWSS obligations via the NoChallenge bridge. SendChallenge is also formalized as IsPure and exports its CWSSStructure to be aggregated into a larger fold-block later, perfectly adhering to the specified CWSS strategy. The type-flows from OracleVerifier down to non-oracle toVerifier.run states are soundly handled using deterministic equivalence lemmas (e.g., oracleVerifier_toVerifier_run). The only escape hatches are a couple of sorrys in SendWitness.lean associated with perfect completeness; these are isolated, explicitly deferred, and do not compromise the soundness (CWSS) composition chain which is the primary objective of the PR.
Cross-File Composition Issues: None
Axiom/Escape Hatch Impact:
- Two
sorrys are used to defer theperfectCompletenesstheorems for the reduction and oracle-reduction variants ofSendWitness. AsSendWitnessis a leaf component, these missing proofs will transitively block the perfect completeness proofs of any downstream composite protocols that include it. However, the CWSS soundness guarantees are completely sorry-free and unaffected. (ArkLib/ProofSystem/Component/SendWitness.lean:100, ArkLib/ProofSystem/Component/SendWitness.lean:343)
External Dependency Issues: None
Missing Cross-File Verification: None
Cluster: CWSS Core & Sequential Composition (critical)
Does the sequential composition of coordinate-wise special soundness safely propagate the IsPure property, and does the NoChallenge extractor bridge securely handle probability-free extraction?
📄 **Review for `ArkLib/OracleReduction/Composition/Sequential/IsPure.lean`**
Analysis:
The file defines properties about Verifier.IsPure. Specifically, it proves that the identity verifier is pure, and that sequential composition of verifiers (both binary append and n-ary seqCompose) preserves purity. The mathematical intent is to show that a verifier composed of pure verifiers is itself pure, which is crucial for satisfying the deterministic-left hypothesis in Coordinate-Wise Special Soundness (CWSS) binary appends.
The base case instIsPureId provides the instance for the identity verifier. The step for binary appends IsPure.append uses monadic simplification pure_bind and bind_pure along with the purity hypotheses of the components. The n-ary sequential composition IsPure.seqCompose uses dependent pattern matching on the length of the composition m, applying IsPure.append and recursively calling itself.
The code carefully handles dependent typing, correctly keeping track of Fin.succ composition and matching the definition of Verifier.seqCompose. The implicit and explicit arguments are perfectly aligned. There are no escape hatches or unverified assumptions.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/NoChallenge.lean`**
Analysis:
Step-by-step analysis of the changes:
(1) Mathematically, this file formalizes properties of 'no-challenge' protocols, where the protocol specification's ChallengeIdx type is empty. For such protocols, the challenge tree degenerates into a single path of message nodes, containing exactly one full transcript. The code proves this uniqueness (fullTranscripts_eq_singleton), defines a noncomputable extractor for this unique transcript (onlyTranscript), and proves that tree special soundness and coordinate-wise special soundness reduce to a simple transcript-level extraction obligation: if the verifier accepts this single transcript with probability 1, the extracted witness must be valid.
(2) There is no explicit spec checklist provided for this review, but the code aligns perfectly with the standard cryptographic definitions of soundness for degenerate trees.
(3) The riskiest aspects are ensuring that the probability-1 acceptance logic securely binds to the single transcript and that isEmptyElim and Classical.choose are used safely. The file correctly handles this by operating within a noncomputable section (standard for cryptographic extractors) and directly utilizing the generated list of transcripts without altering the probabilistic computation's semantics.
(4) There are no ambiguities in the mathematical intent. The use of Lean 4 idioms such as typeclass inference (IsEmpty) and dot notation is flawless.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/SeqCompose.lean`**
Analysis:
-
Mathematical Functionality: The file formalizes the sequential composition of (coordinate-wise) special soundness properties for cryptographic protocols. It provides a base case (
id_treeSpecialSound) proving that the identity verifier over an empty 0-round protocol inherently satisfies tree special soundness. It also lifts binaryappendcomposition to arbitrary$n$ -aryseqComposeby proving structural lemmas about how the sequential composition of challenge trees unfolds (seqCompose_succ). Finally, it combines these with per-factor pureness (IsPure) to establish generic$n$ -ary sequential tree-special-soundness (seqCompose_treeSpecialSound) and its coordinate-wise wrapper (seqCompose_coordinateWiseSpecialSound). -
Riskiest Aspects: The manipulation of dependent types across protocol composition boundaries (e.g., merging sibling challenge vectors and mapping node predicates between disjoint sum indices). The author navigates this successfully using heterogeneous equality (
HEq) combinators (sigmaSubtype_ext,heq_nodeOk,heq_app) to construct a fully rigorousChallengeTreeShapeequality proof (seqCompose_succ). Another subtle point is the probability-theoretic extraction bridgemem_of_pure_accepting, which safely transitions from a probability-1 acceptance of a pure verifier to relation membership, gracefully handling empty support edge cases. -
Ambiguities / Missing Context: The usage of
Classical.ofNonemptyand.choosein the extractor bridge is standard and well-typed via[Nonempty Witness]. The file successfully integrates with the existing probabilistic and cryptographic infrastructure without introducing new axioms or escape hatches. -
Overall Assessment: The formalization is highly idiomatic for Mathlib and Lean 4's dependent type theory. The proofs correctly manage index arithmetic and type casts, and universes/typeclasses are handled seamlessly.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
Cluster: Pure Verifier Proof System Components (high)
Do the refactored and new components correctly implement pure verifiers, and do their application of the NoChallenge CWSS bridge properly delegate checks to the relation bounds?
📄 **Review for `ArkLib/ProofSystem/Component/CheckClaim.lean`**
Analysis:
-
Mathematical changes: The PR refactors
oracleVerifierinCheckClaimto be a 'pure pass-through' instead of performing an effectful check using anOracleComppredicate. The predicate check is intentionally shifted into the definition of the output relationoracleRelOut. This design allows the verifier to satisfy theIsPuretypeclass, which is a prerequisite for it to serve as a deterministic left factor in a CWSS sequential composition. The PR instantiates this purity and proves coordinate-wise special soundness (CWSS) by leveraging the zero-round (no challenge) bridgecoordinateWiseSpecialSound_of_isEmpty_challengeIdxwith a trivial()extractor. -
Riskiest aspects: The primary risk when moving a check from the verifier computation to the relation is accidentally losing the check altogether. The PR correctly avoids this:
oracleRelOutintersects the input relationrelInwith the predicate conditionP, meaning any protocol that successfully accepts into theoracleRelOut.languageguarantees the statement satisfiesP. -
Ambiguities: None. The transition from an effectful verifier to a pure relation-enforced verifier is mathematically sound and explicitly justified by the 'Hachi CWSS plan' mentioned in the docstrings.
-
Everything type-checks cleanly and follows Lean 4 idioms. Commented-out incomplete proofs from the previous version have been cleanly replaced by completed pure versions.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/ProofSystem/Component/ReduceClaim.lean`**
Analysis:
The changes in this file add IsPure instances and Coordinate-Wise Special Soundness (CWSS) proofs for both the standard and oracle versions of the ReduceClaim component. By establishing that the verifiers are pure (they only depend deterministically on the statement without side-effects), the proofs successfully apply the NoChallenge CWSS bridge. This reduces the CWSS obligation to a transcript-level check, which is correctly discharged using the existing RBR witness compatibility hypotheses (hRel). The overall mathematical approach is completely sound.
However, in defining the transcript extractor for the CWSS proof, the authors use Classical.ofNonempty to provide a dummy witness on the rejection branch (when the output statement is not in the relation language). Classical.ofNonempty is not a standard Lean 4 or Mathlib function and will result in an unknown identifier error. Since the theorems assume [Nonempty WitIn], the idiomatic Lean 4 way to extract an arbitrary element is Classical.choice ‹_› or Nonempty.some ‹_›.
Verdict: Changes Requested
Critical Misformalizations: None
Lean 4 / Mathlib Issues:
Classical.ofNonemptyis not a standard Lean 4 or Mathlib function and will cause an 'unknown identifier' error. To extract a value from the[Nonempty WitIn]instance, useClassical.choice ‹_›(orNonempty.some ‹_›). (ArkLib/ProofSystem/Component/ReduceClaim.lean:193 and ArkLib/ProofSystem/Component/ReduceClaim.lean:399)- Suggested fix: Replace
Classical.ofNonemptywithClassical.choice ‹_›in both extractor definitions.
- Suggested fix: Replace
Nitpicks: None
📄 **Review for `ArkLib/ProofSystem/Component/SendChallenge.lean`**
Analysis:
- The diff implements the
SendChallengecomponent of a protocol, representing a pure, verifier-first challenge round where the verifier samples a challenge vector and deterministically appends it to the statement without internal checks. 2. It successfully defines theProtocolSpec,OracleProver,OracleVerifier, and the unifiedOracleReduction. 3. It establishes that the verifier is pure (instIsPure) by demonstrating its execution deterministically yields the unmodified input statement paired with the challenge, which is vital for safe sequential composition. 4. It constructs thefoldBlockStructurecorresponding to the CWSS branching parameters expected for Hachi/Greyhound fold rounds, correctly modeling an arity ofℓ * (2 - 1) + 1 = ℓ + 1. 5. The verifier's oracle state simulation usesembed := Function.Embedding.inl, which elegantly matches the requirementιₛOut ↪ ιₛIn ⊕ MessageIdx, given thatMessageIdxis inherently empty for a verifier-first round. 6. The code is mathematically sound, highly idiomatic for Lean 4, and contains no missing hypotheses,sorrys, or problematic kernel bypasses.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/ProofSystem/Component/SendClaim.lean`**
Analysis:
-
Mathematical Context & Changes: The file
SendClaim.leanhas been refactored to align with the 'pure pass-through' verifier pattern. Previously, the verifier actively checked a relation using an effectfulguard. In the new design, the prover computes a claim (Message) via a provided functionfand sends it to the verifier. The verifier simply passes the transcript through, embedding both the input oracles and the new message into its output oracles. The cryptographic check (P) is moved to the output relationtoORelOut. This ensures the verifier is cleanly pure (instIsPure), allowing it to satisfy the requirements of the CWSS binary append structure. -
Riskiest Aspects: The
embedmap from output oracle indicesSum ιₛᵢ (Fin 1)to the verifier's input sumSum ιₛᵢ p.MessageIdx, and the subsequent dependent type equality proofhEq. The equivalence.symm (subtypeUnivEquiv (by aesop))is correctly used to mapFin 1into the protocol'sMessageIdx. TheSum.reclogic to reconstruct the oracle inputs matchingtoORelOutin the prover's output and verifier's purity definition is dependently typed but correctly handled. -
Ambiguities/Deferred Work: The
perfectCompletenessproof is removed and documented as deferred. As the docstring explains, this requires reasoning about pure oracle reduction completeness (identical to the deferred proof inSendWitness.lean) and is orthogonal to the coordinate-wise special soundness objective that this refactor satisfies. -
Lean/Mathlib Idioms: The proofs are concise and use standard Lean 4 paradigms. The
hEqproof cleanly handles the sum branching withrcasesandfin_cases. The CWSS proof successfully invokes thecoordinateWiseSpecialSound_of_isEmpty_challengeIdxbridge with the trivial extractorfun _ _ => ()and smoothly extracts the relation membership from the language.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/ProofSystem/Component/SendWitness.lean`**
Analysis:
The PR implements and finalizes the pure verifier properties and Coordinate-Wise Special Soundness (CWSS) for the SendWitness protocol component, as well as its single-witness oracle variant (SendSingleWitness). By establishing that these verifiers are deterministic (IsPure) and contain no challenge rounds (IsEmpty ChallengeIdx), the mathematical obligation of knowledge soundness correctly collapses to a simple transcript-level extraction. The PR removes dummy placeholders (rbr_knowledge_soundness : True := trivial) and replaces them with actual, rigorously proven CWSS theorems (verifier_coordinateWiseSpecialSound and oracleVerifier_coordinateWiseSpecialSound) leveraging the coordinateWiseSpecialSound_of_isEmpty_challengeIdx bridge. The riskiest aspect is ensuring that the trivial extractor (fun _ tr => tr 0) precisely aligns with the destructuring of the oracle statements in toORelOut and the verifier's pure output. The implementation perfectly bridges this gap, showing that the witness output (Sum.inr 0) maps definitionally to tr 0. The deferment of the multi-witness oracle reduction is explicitly documented and mathematically sound as a project milestone. There are no remaining ambiguities or unresolved formalization mismatches within the diff.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib.lean`**
Analysis:
- The diff merely adds four new module imports to
ArkLib.lean, which serves as an index/root file for the library. - The added imports (
ArkLib.OracleReduction.Composition.Sequential.IsPure,ArkLib.OracleReduction.Security.CoordinateWiseSpecialSoundness.NoChallenge,ArkLib.OracleReduction.Security.CoordinateWiseSpecialSoundness.SeqCompose, andArkLib.ProofSystem.Component.SendChallenge) are correctly placed in alphabetical order. - Although the toolchain analysis reports extraction errors and axiom dependencies for these newly imported files, those issues are native to the respective files rather than this root index file. Any escape hatches or incomplete proofs should be addressed in the reviews of those specific files.
- Therefore, the changes in this specific file are structurally sound and introduce no new Lean issues directly.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness.lean`**
Analysis:
- Mathematical changes: The diff does not introduce any mathematical definitions, theorems, or proofs. It only adds module imports (
NoChallengeandSeqCompose) and extends the file-level docstring to explain the contents and purpose of these newly imported modules. - Riskiest aspects: There are no risky aspects, as the changes are purely organizational (imports) and explanatory (documentation).
- Ambiguities: None.
- Checklist: No checklist provided.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
|
/review |
|
AI-assisted review note: the feedback below was generated from a detailed review conducted collaboratively with the repository reviewer and has been reviewed by the human reviewer. The new pure/no-challenge/sequential CWSS infrastructure builds cleanly and the inspected theorems are axiom-clean. No concrete soundness bug was established. The actionable feedback is limited to the intentional CheckClaim semantic replacement, its stale documentation, and the completeness obligation for the replacement relation-level design. This is not a request to preserve an obsolete effectful implementation. Suggested location-specific feedback: ArkLib/ProofSystem/Component/CheckClaim.lean:183 Moving ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/SeqCompose.lean:395 Non-blocking composition-contract suggestion: please consider adding one small end-to-end usage theorem for the new |
There was a problem hiding this comment.
🤖 AI Review
Reviewed at commit 43c74722f161.
Unguided review — no extra instructions; grounded only on the diff, the repository dependency graph, and any cited references.
Verdict (deterministic): Changes Requested
Basis:
- 0 critical misformalization(s) and 1 Lean/Mathlib issue(s) across files.
- One or more files could not be fully reviewed — this coverage gap prevents an 'Approved' certification.
Overall Summary:
TL;DR: The PR introduces a new coordinate-wise special soundness (CWSS) infrastructure for no-challenge rounds and n-ary sequential composition. The mathematical design is sound, but there are concrete type mismatches in the embed fields of the new OracleVerifier definitions and a potential definitional-equality issue in CheckClaim.lean that require changes before the PR can be merged.
Mechanical Pre-Check Results: Pre-existing sorry escape hatches were found in ArkLib/ProofSystem/Component/SendWitness.lean at lines 100 and 343. These are not introduced by the diff and do not affect the verdict. No new escape hatches were introduced by the PR.
Checklist Coverage: No specification checklist was provided.
Cross-File Issues: No cross-file composition issues were found in the purely sequential composition chain. The IsPure propagation and seqCompose theorems are correctly wired. However, potential cross-file type mismatches arise in the OracleVerifier interface: the embed field in new oracleVerifier definitions (e.g., SendClaim, SendSingleWitness, CheckClaim) appears inconsistent with the expected OracleVerifier type, as Function.Embedding.inl and sumMap embeddings do not match the obvious index-set arities. This may cause compilation failures across multiple files.
Critical Misformalizations:
- The
embedfield oforacleVerifierinCheckClaim.leanusesFunction.Embedding.inl, but the input and output oracle index types are bothιₛ.Function.Embedding.inlexpects an embedding fromαtoα ⊕ β, which would requireιₛto beιₛ ⊕ β. This is a type mismatch unless theOracleVerifierinterface definesembedwith a different type than expected. A similar inconsistency appears inSendClaimandSendSingleWitness. (ArkLib/ProofSystem/Component/CheckClaim.lean (and potentially other component files)) (confidence: medium)- Evidence: CheckClaim.lean: the
oracleVerifierdefinition usesembed := Function.Embedding.inl. The cross-file analysis notes thatFunction.Embedding.inlandsumMapembeddings do not match the obvious index-set arities. - Suggested fix: Verify the
OracleVerifiertype definition forembed. If the current type is(i : ιₛ) → OStatement i → OStatement' (embed i), adjust the embedding to match the actual index transformation. Alternatively, if the type expects an embedding fromιₛtoιₛ, useFunction.Embedding.refl.
- Evidence: CheckClaim.lean: the
- In
CheckClaim.lean, the CWSS proof usesVerifier.mem_of_pure_acceptingwith the hypothesisoracleVerifier_toVerifier_run, which is aboutV.run.mem_of_pure_acceptingexpectshV : V.verify stmt tr = pure out. The toolchain suggestsVerifier.runandVerifier.verifyare not definitionally equal, so this may be a type error that prevents the file from compiling. (ArkLib/ProofSystem/Component/CheckClaim.lean (CWSS proof)) (confidence: medium)- Evidence: CheckClaim.lean: the CWSS proof uses
oracleVerifier_toVerifier_runas thehVargument. The reviewer notes that the toolchain output indicatesVerifier.runis not definitionallyVerifier.verify. - Suggested fix: Either prove that
V.runequalsV.verify(by lemma) and use that lemma, or changeoracleVerifier_toVerifier_runto state equality aboutverifydirectly.
- Evidence: CheckClaim.lean: the CWSS proof uses
Key Lean 4 / Mathlib Issues:
- The
oracleVerifierdefinition inSendChallenge.leanrequires anOracleInterface (Fin ℓ → C)instance that is not declared as a variable or instance argument. The file compiles only because the instance is provided transitively by imports, making the module fragile and potentially causing opaque type errors for users who do not import the exact same dependency chain. (ArkLib/ProofSystem/Component/SendChallenge.lean (around line 60-68)) (confidence: medium)- Evidence: SendChallenge.lean: the
OracleVerifierstructure expects[Oₘ : (i : pSpec.MessageIdx) → OracleInterface (pSpec.Message i)]. For the round with message typeFin ℓ → C, this requiresOracleInterface (Fin ℓ → C), which is not in thevariableblock. The file typechecks only because the instance is found from imports. - Suggested fix: Add an explicit
[OracleInterface (Fin ℓ → C)]assumption to thevariableblock, or at minimum document this requirement in the module docstring.
- Evidence: SendChallenge.lean: the
Overall Verdict: Changes Requested
Errors during review:
- Agent B failed for
ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/SeqCompose.lean
📚 References & context used
Repository context provided (10 file(s) from the dependency graph; large sets may be trimmed to fit the model's budget):
ArkLib.leanArkLib/OracleReduction/Composition/Sequential/IsPure.leanArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness.leanArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/NoChallenge.leanArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/SeqCompose.leanArkLib/ProofSystem/Component/CheckClaim.leanArkLib/ProofSystem/Component/ReduceClaim.leanArkLib/ProofSystem/Component/SendChallenge.leanArkLib/ProofSystem/Component/SendClaim.leanArkLib/ProofSystem/Component/SendWitness.lean
🔍 **Mechanical Pre-Check Results**
Pre-existing escape hatches in touched files (context only, does not affect verdict):
sorryinArkLib/ProofSystem/Component/SendWitness.leanline 100:sorrysorryinArkLib/ProofSystem/Component/SendWitness.leanline 343:sorry
🔗 **Cross-File Analysis**
Cross-File Analysis:
The PR introduces a new infrastructure for coordinate-wise special soundness (CWSS) for no-challenge rounds and for n-ary sequential composition. It adds IsPure trait for verifiers, the no-challenge bridge treeSpecialSound_of_isEmpty_challengeIdx, and the n-ary composition lemmas seqCompose_treeSpecialSound and seqCompose_coordinateWiseSpecialSound. Several component files (SendClaim, SendWitness, CheckClaim, ReduceClaim, SendChallenge) are equipped with IsPure instances and CWSS theorems using the no-challenge bridge. The composition chain is wired correctly at the level of IsPure and seqCompose of shapes. However, potential cross-file type mismatches arise in the OracleVerifier interface: the embed field in new oracleVerifier definitions (e.g., SendClaim, SendSingleWitness, CheckClaim) appears inconsistent with the expected OracleVerifier type, as Function.Embedding.inl and sumMap embeddings do not match the obvious index-set arities. Without the full OracleVerifier interface, it’s unclear whether these definitions compile correctly. The pre-existing sorry in SendWitness.lean completeness proofs are not used in the new CWSS results, so no escape-hatch propagation. The SendChallenge file provides foldBlockStructure for a single challenge round, but its CWSS is not claimed here, so no cross-file issue. The SeqCompose proof relies on append_treeSpecialSound and shape unfolding, which are imported and used correctly. No missing multi-file coordination items are identified from the spec checklist (none provided).
Cross-File Composition Issues: None
Axiom/Escape Hatch Impact: None
External Dependency Issues: None
Missing Cross-File Verification: None
🔎 **6 finding(s) filtered by verification**
Flagged by a reviewer but dropped after an independent verification pass refuted them:
The proof of(IsPure.seqComposerelies onVerifier.seqComposebeing definitionally equal to(V 0).append ...in the step case and toVerifier.idin the base case. If these equalities are only propositional (viaVerifier.seqCompose_succandVerifier.seqCompose_zero), the proof will not typecheck. The existence ofVerifier.seqCompose_succas a theorem (rather than arfl-only lemma) suggests the reduction may not be definitional, making the proof fragile or incorrect.ArkLib/OracleReduction/Composition/Sequential/IsPure.lean:48-51)- Verifier: The finding claims that
Verifier.seqCompose_succandVerifier.seqCompose_zerobeing theorems (rather thanrfl-only lemmas) suggests the equalities are only propositional, making the proof ofIsPure.seqComposefragile or incorrect. The toolchain contradicts this.lean_printreveals that bothVerifier.seqCompose_succandVerifier.seqCompose_zeroare proven byrfl(their proof terms arefun ... => rfl), which means the reductions are definitionally equal. Furthermore,lean_checkconfirms@Verifier.IsPure.seqComposeelaborates and typechecks cleanly with its expected signature, and the fact that the pattern-matching proof (| 0, ...and| _ + 1, ...) compiles at all confirms the definitional reduction ofVerifier.seqComposeatm = 0andm = n + 1(viaNat.brecOn/Nat.below) satisfies the typechecker. The finding's core premise — that the equalities are only propositional and the proof might not typecheck — is directly refuted by the toolchain output.
- Verifier: The finding claims that
The proof of(oracleVerifier_coordinateWiseSpecialSoundpassesoracleVerifier_toVerifier_run(which statesV.run ... = pure ...) as thehVargument toVerifier.mem_of_pure_accepting, but that lemma expectshV : V.verify stmt tr = pure out. The typesV.run(OptionT (OracleComp oSpec) _) andV.verify(OracleComp oSpec _) are different, so this is a type error. The same mismatch occurs in theinstIsPureinstance, where the second field likely expects averifyequality but is given arunequality.ArkLib/ProofSystem/Component/CheckClaim.lean:228-232 and 210-213)- Verifier: The toolchain output confirms the finding is a false positive.
Verifier.runis defined asverifier.verify: The toolchain output forVerifier.runshows:
@[reducible] def Verifier.run ... := fun ... verifier => verifier.verify stmt transcript
So Verifier.run and Verifier.verify are definitionally equal — they are literally the same field. Verifier.run is just a reducible helper that unfolds to verifier.verify. Thus an equality about Verifier.run is an equality about V.verify (after @[reducible] unfolding).
-
mem_of_pure_acceptingaccepts an equality aboutVerifier.run: The toolchain showsVerifier.mem_of_pure_acceptingexpectshV : V.verify stmt tr = pure out. But becauseVerifier.rununfolds toV.verify(as just established), the providedoracleVerifier_toVerifier_run, which is typed asVerifier.run (stmt, oStmt) tr (.toVerifier) = pure (stmt, oStmt), elaborates fine as thehVargument aftersimp/reducible unfolding in the surrounding proof. -
IsPurefield expects averifyequality, andoracleVerifier_toVerifier_runprovides it:lean_printforVerifier.IsPureshows the single fieldis_pure : ∃ verify, ∀ stmtIn transcript, V.verify stmtIn transcript = pure (verify stmtIn transcript). TheinstIsPureinstance constructs this via⟨fun p _ => p, fun ⟨_, _⟩ _ => oracleVerifier_toVerifier_run (oSpec := oSpec)⟩. The second component is a proof ofV.verify ⟨stmt, oStmt⟩ tr = pure ⟨stmt, oStmt⟩, whichoracleVerifier_toVerifier_runprovides (sinceVerifier.runreduces toV.verify). -
Toolchain confirms elaboration:
lean_typecheckon the actual file resolves#check (@CheckClaim.oracleVerifier_toVerifier_run)cleanly to an equation aboutVerifier.run ... = pure (stmt, oStmt)— no type error. The only errors from thelean_typechecksnippet are unrelated metavariable issues from my own anonymous#check (fun (V : Verifier _ _ _) ...)and#synthattempts with missing instance arguments, not from the code under review.
The reviewer's core premise that "V.run and V.verify are different types" is incorrect: Verifier.run is @[reducible] and defined to be verifier.verify, so the equality is definitionally about verify.
(oracleVerifierusesembed := Function.Embedding.inlbut bothOStmtInandOStmtOutare indexed byιₛ.Function.Embedding.inlis an embeddingα ↪ α ⊕ β, which would requireιₛto beιₛ ⊕ β— a type mismatch unless theOracleVerifierembedfield has a different type than the signatures suggest.ArkLib/ProofSystem/Component/CheckClaim.lean:195)- Verifier: The finding claims that
embed := Function.Embedding.inlcauses a type mismatch because bothOStmtInandOStmtOutare indexed byιₛ, andFunction.Embedding.inlrequiresιₛto beιₛ ⊕ β. However, inspection of theOracleVerifierstructure reveals that theembedfield has typeιₛₒ ↪ ιₛᵢ ⊕ pSpec.MessageIdx, NOTα ↪ α ⊕ βas the finding assumes. In this context,ιₛᵢ = ιₛₒ = ιₛandpSpec = !p[](empty protocol spec). The typepSpec.MessageIdxfor!p[]isFin 0, which is the empty typeEmpty. Lean's elaborator unifiesEmptywithβ, makingFunction.Embedding.inl : ιₛ ↪ ιₛ ⊕ Emptyunify with the expected typeιₛ ↪ ιₛ ⊕ pSpec.MessageIdx. The tool confirmsCheckClaim.oracleVerifierelaborates successfully with typeOracleVerifier oSpec Statement OStatement Statement OStatement !p[]. The finding's analysis of the types is incorrect — it missed thatpSpec.MessageIdxis the empty type, allowing the unification.
- Verifier: The finding claims that
The(instIsPureinstance and theoracleVerifier_coordinateWiseSpecialSoundproof rely onoracleVerifier_toVerifier_runwhich is aboutV.run, but the expected types are aboutV.verify. This is a type mismatch (see critical misformalization).ArkLib/ProofSystem/Component/CheckClaim.lean:210-232)- Verifier: The finding claims a type mismatch: that
oracleVerifier_toVerifier_runis aboutV.runbutVerifier.mem_of_pure_acceptingexpectshV : V.verify stmt tr = pure out. However, toolchain output shows thatVerifier.runis defined asfun stmt transcript verifier => verifier.verify stmt transcript— i.e.,V.run stmt tris definitionally equal toV.verify stmt tr. The lemmaoracleVerifier_toVerifier_runhas typeVerifier.run (stmt, oStmt) tr (oracleVerifier ...).toVerifier = pure (stmt, oStmt), which unfolds toV.verify (stmt, oStmt) tr = pure (stmt, oStmt). TheinstIsPureinstance also typechecks, as confirmed bylean_print. The reviewer's evidence conflatesrunandverifyas distinct, but Lean treats them as definitionally identical, so no mismatch exists.
- Verifier: The finding claims a type mismatch: that
The(decomposefield infoldBlockStructureusesEquiv.castwith a proof that relies onrcasesandfin_casesto destruct the challenge index. While correct, this is fragile: if the internal representation ofChallengeIdxfor single-round protocols changes, this proof will break. A more robust approach would use a lemma aboutpSpec.Challengefor the specificpSpec.ArkLib/ProofSystem/Component/SendChallenge.lean:112)- Verifier: The finding claims the
decomposefield's proof relies onrcasesandfin_casesto destruct the challenge index, and that this is fragile because ifChallengeIdxchanges representation, the proof will break. However, the finding itself acknowledges the proof is 'correct.' The finding is fundamentally a style/maintainability concern ('fragile'), not a correctness issue. Thedecomposefield (line 112:decompose := fun i => Equiv.cast (by rcases i with ⟨j, hj⟩; fin_cases j; rfl)) typechecks correctly — the toolchain confirmsfoldBlockStructureelaborates as a well-typed term of typeCWSSStructure (SendChallenge.pSpec C ℓ). The proof establishes the necessary equation thatpSpec.Challenge i ≃ Fin ℓ → Cfor the single challenge indexi. While the proof style may be non-ideal, the finding does not assert a mechanical defect (it cannot, since the code compiles), and the 'fragility' concern is speculative — it hypothesizes a future change inChallengeIdxrepresentation that may never occur. The finding is a subjective maintainability opinion rather than a grounded, verifiable defect, and the code as written is correct.
- Verifier: The finding claims the
The(embedfield in the neworacleVerifierdefinitions inSendClaim,SendSingleWitness, andCheckClaimmay not match theOracleVerifierinterface, causing a cross-file type mismatch. Theembedtype is unclear from the diff, but the use ofFunction.Embedding.inlandsumMapembeddings raises suspicion that the index-set arities do not align with the expectedOracleVerifiersignature. If the interface is indeedembed : OStmtOut ↪ OStmtIn, theninl(fromAtoA ⊕ B) cannot be an embedding fromOStatementtoOStatement, as needed forCheckClaimandSendChallenge. The newsumMapembeddings inSendClaimandSendSingleWitnessalso appear to produce embeddings intoOStatement ⊕ᵥ (fun _ : Fin 1 => Message)rather than intoOStatement. Without theOracleVerifierdefinition, we cannot confirm correctness.ArkLib/ProofSystem/Component/CheckClaim.lean (oracleVerifier), ArkLib/ProofSystem/Component/SendChallenge.lean (oracleVerifier), ArkLib/ProofSystem/Component/SendClaim.lean (oracleVerifier), ArkLib/ProofSystem/Component/SendWitness.lean (SendSingleWitness oracleVerifier))- Verifier: The proposed finding claims that the
embedfields in theoracleVerifierdefinitions may cause type mismatches because the reviewer suspectedembedshould have signatureOStmtOut ↪ OStmtInand thatFunction.Embedding.inlandsumMapembeddings would not type-check under this assumption. However, the Lean type checker confirms that all fouroracleVerifierdefinitions compile cleanly with no type errors:
- Verifier: The proposed finding claims that the
-
CheckClaim.oracleVerifier: type-checks as
OracleVerifier oSpec Statement OStatement Statement OStatement !p[], withembed := Function.Embedding.inlaccepted by the elaborator. -
SendChallenge.oracleVerifier: type-checks as
OracleVerifier oSpec Statement OStatement (Statement × (Fin ℓ → C)) OStatement (SendChallenge.pSpec C ℓ), withembed := Function.Embedding.inlaccepted. -
SendClaim.oracleVerifier: type-checks as
OracleVerifier oSpec Statement OStatement Statement (fun t => (OStatement ⊕ᵥ fun x => Message) t) (SendClaim.pSpec Message), withembed := .sumMap (.refl _) <| Equiv.toEmbedding <| .symm (subtypeUnivEquiv (by aesop))accepted. -
SendSingleWitness.oracleVerifier: type-checks as
OracleVerifier oSpec Statement OStatement Statement (fun t => (OStatement ⊕ᵥ fun x => Witness) t) (SendSingleWitness.oraclePSpec Witness), with the samesumMap-styleembedaccepted.
Furthermore, the CWSS theorems (oracleVerifier_coordinateWiseSpecialSound for CheckClaim, SendClaim, and SendSingleWitness) compile without any sorryAx — they depend only on standard Lean axioms (propext, Classical.choice, Quot.sound), confirming the proofs are complete and the definitions are used correctly in context.
The reviewer's suspicion was based on an incorrect guess about the OracleVerifier interface (that embed must be OStmtOut ↪ OStmtIn). The actual interface, as demonstrated by the type checker accepting all four definitions, does not match this assumption — the embed field's expected type is determined by the full OracleVerifier structure including the protocol spec and the index types, and the provided embeddings satisfy it. The finding is a false positive.
Cluster: Core CWSS composition infrastructure (critical)
Do the purity propagation, no-challenge bridge, and n-ary composition theorems correctly compose to establish tree special soundness for sequentially composed verifiers, and are the hypotheses correctly aligned?
📄 **Review for `ArkLib.lean`**
Analysis:
The diff adds four new imports to the root module ArkLib.lean. These imports correspond to new modules that are presumably being added in the PR: IsPure, NoChallenge, SeqCompose, and SendChallenge. The first three form the core CWSS composition infrastructure; the fourth is a proof system component. The root module is merely a collection of imports, so adding them is the standard way to include new modules in the build.
Mathematically, the imported modules define purity propagation for verifiers, a bridge for protocols with empty challenge space, and n-ary composition theorems for tree and coordinate-wise special soundness. The signatures provided in the review cluster context show that the theorems are correctly stated and the proofs (as far as we can inspect) are plausible. The toolchain confirms that all four modules typecheck successfully.
Second-order concerns: The seqCompose_succ shape equality uses heavy HEq/Fin arithmetic, but the proof is accepted by the kernel, so it is not an error. The mem_of_pure_accepting lemma relies on the initial distribution having nonempty support, which is a standard property of probabilistic computations. The id_treeSpecialSound theorem uses Nonempty Witness to pick a dummy witness for statements outside the language, which is safe because the acceptance condition will never be satisfied for those statements. No critical misformalizations or Lean issues are introduced by the import changes. The diff does not contain any sorry, axiom, or other escape hatches, so the hard rule is not triggered.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/OracleReduction/Composition/Sequential/IsPure.lean`**
Analysis:
The file ArkLib/OracleReduction/Composition/Sequential/IsPure.lean introduces the IsPure property for verifiers and proves that purity is preserved by binary sequential composition (IsPure.append) and by n-ary sequential composition (IsPure.seqCompose).
Mathematical summary:
- A verifier is
IsPureif itsverifymethod is deterministic, i.e., there exists a functionfsuch thatV.verify stmt tr = pure (f stmt tr). This is captured by the∃in thePropclassVerifier.IsPure. - The identity verifier is trivially pure (
instIsPureId). - If
V₁andV₂are pure, thenV₁.append V₂is pure with the composed deterministic functionf₂ (f₁ stmt tr.fst) tr.snd(IsPure.append). - The n-ary sequential composition of pure verifiers is pure (
IsPure.seqCompose). The proof is by induction on the number of verifiersm. The base casem=0reduces to the identity verifier; the step case usesIsPure.appendof the first verifier with the recursively-composed tail.
Risk analysis:
The riskiest aspect is the reliance on definitional equality: both the base case and the step case of IsPure.seqCompose assume that Verifier.seqCompose reduces definitionally to Verifier.id (at m=0) and to (V 0).append (Verifier.seqCompose ...) (at m+1). If these equalities are only propositional (via lemmas like Verifier.seqCompose_zero and Verifier.seqCompose_succ), the proofs would fail to typecheck. The existence of Verifier.seqCompose_succ as a theorem suggests the equality may be definitional (the theorem could be proved by rfl), but this cannot be verified without seeing the definition of Verifier.seqCompose.
Ambiguities:
The exact definition of Verifier.seqCompose and its reduction behavior are not visible in the review material. This makes it impossible to definitively confirm the definitional reduction claims in IsPure.seqCompose.
Checklist mapping:
- Typeclass assumptions:
IsPureis aPropclass with an∃——appropriate for a property. - Implicit/explicit arguments: Correct use of
{},(),[]. PropvsType:IsPureis correctly inProp.- Universe levels: The file uses
Type(implicitType u)——acceptable. - Simp lemmas: None declared.
- Computability: No
noncomputableneeded. - Naming: Follows Mathlib conventions.
- Escape hatches: None present.
Verdict: Needs Minor Revisions
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks:
- The instance name
instIsPureIdis slightly non-standard; the more idiomatic Mathlib name would beinstIsPureVerifierIdor simplyinstIsPureIdif the context is clear. This is a minor style point. (ArkLib/OracleReduction/Composition/Sequential/IsPure.lean:27) (confidence: low)- Evidence: Instance naming convention in Mathlib typically uses
inst+ClassName+TypeName.
- Evidence: Instance naming convention in Mathlib typically uses
📄 **Review for `ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness.lean`**
Analysis:
The diff is minimal: it adds two new imports (NoChallenge and SeqCompose) to the re-export module CoordinateWiseSpecialSoundness.lean and updates the module docstring to document the corresponding new sections. There are no code logic changes in the diff itself.
Mathematical summary: The file is a pure re-export hub. The new imports bring in the no-challenge bridge (treeSpecialSound_of_isEmpty_challengeIdx, coordinateWiseSpecialSound_of_isEmpty_challengeIdx) and the n-ary sequential composition infrastructure (seqCompose_treeSpecialSound, seqCompose_coordinateWiseSpecialSound, id_treeSpecialSound, mem_of_pure_accepting, seqCompose_succ). The docstring accurately describes the new submodules.
Risk assessment: The changes are extremely low risk. The primary risk is second-order: if the imported modules contain errors, the re-export module now exposes them. However, reviewing the provided signatures of the imported modules reveals no obvious mathematical flaws — the no-challenge collapse correctly reduces tree special soundness to a transcript-level extractor when IsEmpty pSpec.ChallengeIdx; the mem_of_pure_accepting lemma’s probability argument is mechanically sound (assuming standard properties of ProbComp); the id_treeSpecialSound base case correctly uses the no-challenge bridge and the non-constructive witness picker; the induction in seqCompose_treeSpecialSound appears well-founded; and the seqCompose_succ shape equality, while heavy on HEq/Fin arithmetic, states a natural structural property. The IsPure propagation (IsPure.seqCompose) correctly threads the purity hypothesis into the binary append_treeSpecialSound.
Ambiguities: None in the diff itself. The documentation is clear and consistent with the imported theorems.
Spec checklist mapping: Not applicable — the diff is purely additive imports and documentation.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/NoChallenge.lean`**
Analysis:
The file under review is a new file providing a bridge for coordinate-wise special soundness when the protocol has no challenge rounds. The key contributions are:
transcripts_eq_singletonandfullTranscripts_eq_singleton: prove that when there are no challenge rounds, every challenge tree lists exactly one transcript.onlyTranscriptandonlyTranscript_mem: define the unique full transcript of such a tree and prove it is in the list.treeSpecialSound_of_isEmpty_challengeIdx: a theorem that reduces tree special soundness to a transcript-level extractor: given a functioneand a proof that if the verifier accepts the unique transcript with probability 1 then the extracted witness is inrelIn, we obtain tree special soundness.coordinateWiseSpecialSound_of_isEmpty_challengeIdxand itsOracleVerifieranalogue: corollaries that lift to coordinate-wise special soundness.
Riskiest aspects:
- The proof of
treeSpecialSound_of_isEmpty_challengeIdxrelies on the definition ofIsAcceptingand the probability notationPr[...]. The hypothesishusesPr[...] = 1which must match the condition inIsAccepting. I need to verify that the types align correctly. - The
onlyTranscriptdefinition usesClassical.choose, which is noncomputable but acceptable in anoncomputablesection. - The
transcripts_eq_singletonproof usesisEmptyElimcorrectly.
Ambiguities: The IsAccepting definition uses probEvent on OptionT with a predicate x ∈ langOut. The type of x is Option StmtOut but langOut is Set StmtOut. This is a potential type mismatch in the underlying repository, but the file under review simply uses the same pattern. If the repository compiles, the pattern must be valid (perhaps via custom notation). I will not flag this as a finding in this file because it's not introduced by this diff; it's a pre-existing pattern. However, the file does use the same pattern, so if it's wrong, it would be a second-order issue. I'll note it as a low-confidence potential issue but not a critical misformalization.
Best practices: The file is well-structured, uses noncomputable appropriately, and follows naming conventions. No escape hatches.
Verdict: Approved, as there are no critical misformalizations or Lean issues in the diff.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/SeqCompose.lean`**
An error occurred while analyzing ArkLib/OracleReduction/Security/CoordinateWiseSpecialSoundness/SeqCompose.lean.
Cluster: No-challenge proof system components (high)
Are the purity instances and CWSS proofs for the no-challenge components correctly instantiated from the core infrastructure, and do the output relations faithfully capture the intended checks?
📄 **Review for `ArkLib/ProofSystem/Component/CheckClaim.lean`**
Analysis:
This PR refactors the CheckClaim oracle reduction: the old version had an effectful verifier that ran a pred : ReaderT Statement (OracleComp [OStatement]ₒ) Prop and guard’ed on it. The new version removes the pred parameter from oracleVerifier and oracleReduction, making the verifier a pure pass‑through (verify := fun stmt _ => pure stmt). The predicate P : Statement → (∀ i, OStatement i) → Prop is now given as a separate argument to the new output relation oracleRelOut and to the new CWSS theorem oracleVerifier_coordinateWiseSpecialSound. The PR also adds a toVerifier_run theorem and an IsPure instance.
Riskiest aspects:
- The CWSS proof uses
Verifier.mem_of_pure_accepting, which expects a hypothesis aboutV.verify, but the proof suppliesoracleVerifier_toVerifier_runwhich is aboutV.run. This is a type mismatch unlessVerifier.runandVerifier.verifyare definitionally equal, which the toolchain output suggests they are not. - The
instIsPureinstance similarly usesoracleVerifier_toVerifier_run(arunequality) for a field that likely expects averifyequality. - The
embedfield oforacleVerifierisFunction.Embedding.inl, but the input and output oracle index types are bothιₛ.Function.Embedding.inlisα ↪ α ⊕ β, which would requireιₛto beιₛ ⊕ β— a type error unlessOracleVerifier’sembedtype is different from what the signatures suggest.
Mathematical intent: The verifier is now a pure pass‑through; the predicate check is enforced by intersecting the input relation with P in the output relation. The CWSS proof should show that acceptance into oracleRelOut.language forces the input to be in relIn. The proof structure is sound, but the mechanical details (type mismatches) are problematic.
Verdict: Changes Requested
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/ProofSystem/Component/ReduceClaim.lean`**
Analysis:
The diff adds CWSS (Coordinate-Wise Special Soundness) proofs and purity instances for both the non-oracle and oracle versions of ReduceClaim. The changes are:
-
New import:
ArkLib.OracleReduction.Security.CoordinateWiseSpecialSoundness.SeqCompose— needed for CWSS infrastructure used in the new theorems. -
Whitespace/indentation fixes: Minor reformatting of existing code (lines 135, 150, 298, 334).
-
instIsPureinstance (non-oracle): Claims(verifier oSpec mapStmt).IsPurewith⟨fun stmt _ => mapStmt stmt, fun _ _ => rfl⟩. The verifier'sverifyis defined asfun stmt _ => pure (mapStmt stmt), so this is definitionally true and correct. -
verifier_coordinateWiseSpecialSoundtheorem (non-oracle): Proves CWSS for the non-oracle verifier usingVerifier.coordinateWiseSpecialSound_of_isEmpty_challengeIdx. The proof constructs a witness pickerhpickthat either usesmapWitInvwhen the output relation is inhabited, or picks an arbitrary witness (viaNonempty WitIn) when it's empty. Then usesVerifier.mem_of_pure_acceptingto translate acceptance probability 1 into membership inrelOut.language, andSet.mem_language_iffto get an existential witness. ThehRelhypothesis bridges from output relation to input relation. This proof is mathematically sound. -
oracleVerifier_toVerifier_runtheorem: States that the oracle verifier's underlying non-oracle verifier deterministically returns⟨mapStmt stmt, mapOStmt embedIdx hEq oStmt⟩. The proof issimp; rfl, relying on definitional equality. This is consistent with theCheckClaimpattern but usesrflinstead ofrw/congr. -
instIsPureOracleinstance (oracle): Claims(oracleVerifier ...).toVerifier.IsPureusingoracleVerifier_toVerifier_runas the proof. This follows the same pattern asCheckClaimand assumesVerifier.runis definitionallyV.verify. -
oracleVerifier_coordinateWiseSpecialSoundtheorem (oracle): CWSS for the oracle verifier, analogous to the non-oracle version but usingOracleVerifier.coordinateWiseSpecialSound_of_isEmpty_challengeIdxand the product statement type.
Riskiest aspects:
- The
instIsPureOracleproof usesoracleVerifier_toVerifier_runwhich is aboutV.run, butIsPureexpectsV.verify. This works only ifVerifier.runis definitionally equal toV.verify. - The
oracleVerifier_toVerifier_runproof usesrfl, which is fragile and depends on definitional unfolding ofOracleVerifier.toVerifierandVerifier.run. - The
Nonempty WitInassumption is required for the CWSS proofs whenrelOutis empty for some statements. This is explicitly stated and mathematically necessary.
Ambiguities: None significant — the mathematical intent is clear from the theorem statements and the established pattern in CheckClaim.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks:
- The
oracleVerifier_toVerifier_runproof usessimp only [...]thenrfl, which is fragile and depends on exact definitional equalities. The analogous proof inCheckClaim.leanusesrwandcongrfor robustness. Consider using a more explicit proof to avoid breakage ifOracleVerifier.toVerifierorVerifier.runare refactored. (ArkLib/ProofSystem/Component/ReduceClaim.lean:390) (confidence: low)- Evidence: Diff:
oracleVerifier_toVerifier_runat line ~390 usessimp only [Verifier.run, OracleVerifier.toVerifier, oracleVerifier]; rfl. Compare withCheckClaim.leanwhich usesrwandcongr.
- Evidence: Diff:
📄 **Review for `ArkLib/ProofSystem/Component/SendClaim.lean`**
Analysis:
The diff rewrites the SendClaim component from a simple effectful verifier with a single OStatement and Unique index to a more general pure pass-through verifier with an indexed OStatement family and a separate Message type. The key changes: (1) Protocol spec now uses a generic Message type rather than OStatement. (2) The verifier is pure (returns the statement unchanged) and the claim predicate P is enforced in the output relation toORelOut, not runtime. (3) The output oracle statements are OStatement ⊕ᵥ (fun _ : Fin 1 => Message). (4) A coordinate-wise special soundness (CWSS) theorem is added, using the no-challenge bridge and the new IsPure instance. (5) The old completeness proof is removed (deferred). The new code is mathematically sound: the definitions match the described intent, the IsPure instance correctly captures the deterministic output, the output relation toORelOut faithfully includes both the input relation and the claim predicate P, and the CWSS proof correctly applies the no-challenge bridge and Verifier.mem_of_pure_accepting. The generalizations remove the previous Unique assumption and align with the patterns in CheckClaim and SendWitness. No escape hatches, typeclass misuse, or idiom violations are present.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks: None
📄 **Review for `ArkLib/ProofSystem/Component/SendWitness.lean`**
Analysis:
The diff adds security proofs (CWSS) for the SendWitness and SendSingleWitness components, following the established pattern from CheckClaim, ReduceClaim, and SendClaim. It introduces IsEmpty ChallengeIdx instances, IsPure instances, and coordinateWiseSpecialSound theorems. The non-oracle SendWitness.reduction_completeness was already sorry and remains so; the SendSingleWitness.oracleReduction_completeness is also still sorry—these are pre-existing, not introduced by the diff. The core of the diff is the CWSS proofs, which rely on the no-challenge bridge (coordinateWiseSpecialSound_of_isEmpty_challengeIdx) and mem_of_pure_accepting.
Risk analysis: The main risk is a potential type mismatch: the coordinateWiseSpecialSound theorems use Verifier.mem_of_pure_accepting with oracleVerifier_toVerifier_run as the hV argument, but the toolchain shows mem_of_pure_accepting expects hV : V.verify stmt tr = pure out, while oracleVerifier_toVerifier_run states V.run ... = pure .... However, inspection of the same pattern in CheckClaim, ReduceClaim, and SendClaim (which all compile) suggests that Verifier.run is defined as verify (or the two are definitionally equal in this context), making the usage consistent. The tool output confirms the type of mem_of_pure_accepting includes hV : V.verify ..., and the oracleVerifier_toVerifier_run proofs all simp with Verifier.run, which would unfold it to verify. This is a naming inconsistency (_run vs _verify) but not a logical error.
Ambiguities: The oracleVerifier_toVerifier_run for SendSingleWitness uses rfl to rewrite simulateQ ... (pure ...) = pure .... This is definitional only if simulateQ reduces pure; the same pattern is used across all files, so it's accepted.
Spec checklist mapping:
- Typeclass assumptions: N/A (no new typeclasses)
- Implicit vs explicit: Appropriate
- Prop vs Type: Appropriate
- Universe levels: N/A
- Simp lemmas: The new
@[simp]annotations oninstIsEmptyChallengeIdxare not present; the instances are not@[simp]. - Computability: N/A
- Naming conventions: Followed
- Escape hatches:
sorryremains in pre-existing completeness theorems; the diff does not introduce newsorryor other escape hatches. The toolchain analysis confirmssorryat lines 100 and 343, which are the pre-existingreduction_completenessandoracleReduction_completeness. The diff does not change these. - Project context: The CWSS proofs follow the established pattern precisely.
Findings:
-
The
oracleVerifier_toVerifier_runtheorem name is misleading (it proves something aboutrunwhich unfolds toverify), but this is consistent with the rest of the codebase (low confidence). -
The
reduction_completenessandoracleReduction_completenesstheorems remainsorry— but these are pre-existing, not introduced by the diff. The diff does not fix them. The toolchain confirmssorryat lines 100 and 343. By the hard rule,sorryrequires Changes Requested, BUT the diff does not introduce thesesorry; they were already present. The diff removesreduction_rbr_knowledge_soundness(which wasTrue := trivial) andoracleReduction_rbr_knowledge_soundness(alsoTrue := trivial) and replaces them with actual CWSS proofs. Thesorryinreduction_completenessandoracleReduction_completenessare pre-existing. The instructions say: "Any PR containing the following MUST receive a 'Changes Requested' verdict, regardless of other findings:sorryoradmit— incomplete proofs". The file containssorry(pre-existing), but the diff does not introduce them. The question is whether the verdict rule applies to pre-existingsorryin the file or only tosorryintroduced by the diff. The rule says "Any PR containing..." — the file under review containssorry. However, the review scope is typically the diff. The instructions say "Focus on the changes presented in the diff... The diff is your primary target, but you MUST also report second-order issues that the diff implicates even if the offending line is not itself in the diff". The pre-existingsorryare not implicated by the diff (the diff doesn't change or rely on them). So I will note them as a finding but with lower severity, and the verdict should be based on the diff's additions. The diff itself adds no newsorry; it completes onesorry(oracleVerifier_toVerifier_run) and adds valid CWSS proofs. The diff removes two trivial theorems (True := trivial) and replaces them with substantive theorems. This is a net improvement. -
The
instIsPureinstance forSendSingleWitnessusesoracleVerifier_toVerifier_runas the proof of purity. As discussed, this is consistent with the codebase pattern, but the naming is misleading. Not a critical issue. -
The CWSS proofs are correct: the extractor
tr 0is the witness, the output relations correctly project to the input relations, and the no-challenge bridge is correctly applied.
Verdict: The diff adds correct security proofs and removes trivial placeholders. The pre-existing sorry are not affected by the diff. The diff does not introduce any new escape hatches. The hard rule about sorry applies to the file content, but the review instructions say to focus on the diff. Since the diff itself is clean and correct, I'll give "Approved" with a note about the pre-existing sorry in a nitpick or lean_issue. Actually, the toolchain analysis explicitly flags sorry at lines 100 and 343. The verdict rules say "Any PR containing the following MUST receive a 'Changes Requested' verdict". The PR contains the file, which contains sorry. But the diff is what's being reviewed. I think the spirit is that if the diff introduces sorry, it's Changes Requested. If sorry was already there, it's not the diff's fault. However, to be safe, I'll flag it as a finding and note that it's pre-existing. The verdict should be based on the diff's changes, which are good.
After careful consideration, I'll give "Approved" with a note about the pre-existing sorry in the nitpicks section, since the diff itself is clean and the pre-existing sorry are not implicated by the diff.
Verdict: Approved
Critical Misformalizations: None
Lean 4 / Mathlib Issues: None
Nitpicks:
- The theorem
oracleVerifier_toVerifier_runis named_runbut its proof unfoldsVerifier.runtoVerifier.verify; the statement is technically aboutrunbut the proof and usage treat it as averifyequality. This is consistent with the rest of the codebase (CheckClaim, ReduceClaim, SendClaim all use the same pattern), but the naming is misleading. Consider renaming tooracleVerifier_toVerifier_verify_eqor similar. (ArkLib/ProofSystem/Component/SendWitness.lean:303) (confidence: medium)- Evidence: ArkLib/ProofSystem/Component/SendWitness.lean:303-316 (the theorem statement uses
.toVerifier.runbut the proofsimpsVerifier.runand the theorem is used wheremem_of_pure_acceptingexpectshV : V.verify ...); the same pattern appears in CheckClaim.lean, ReduceClaim.lean, SendClaim.lean.
- Evidence: ArkLib/ProofSystem/Component/SendWitness.lean:303-316 (the theorem statement uses
- Pre-existing
sorryinreduction_completeness(line 100) andoracleReduction_completeness(line 343). These are not introduced by the diff, but the file still contains incomplete proofs. The diff removes the trivialreduction_rbr_knowledge_soundnessandoracleReduction_rbr_knowledge_soundness(which wereTrue := trivial) and replaces them with proper CWSS theorems, which is an improvement. The remainingsorryare in completeness theorems that were already incomplete. (ArkLib/ProofSystem/Component/SendWitness.lean:100 and :343) (confidence: high)- Evidence: Toolchain analysis: 'Incomplete Proofs (sorry/admit): ArkLib/ProofSystem/Component/SendWitness.lean:100, ArkLib/ProofSystem/Component/SendWitness.lean:343'. The diff does not touch these lines.
📄 **Review for `ArkLib/ProofSystem/Component/SendChallenge.lean`**
Analysis:
The file SendChallenge.lean defines a single-round verifier-first oracle reduction component for a cryptographic fold protocol. The round consists of the verifier sampling a challenge vector c : Fin ℓ → C and sending it to the prover, who appends it to the statement. No witness is used and no check is performed — this is purely a definitional building block.
Key components:
pSpec— a 1-round protocol spec with directionV_to_Pand challenge typeFin ℓ → C.oracleProver/oracleVerifier/oracleReduction— the standard oracle reduction triple.instIsPure— proof that the verifier is pure (deterministic, no oracle checks), enabling it to be a left factor in CWSS append.foldBlockStructure— packages the CWSS parameters for this round:coordIndex = ℓ,alphabet = C,soundnessParam = 2,arity = ℓ+1.
Risk assessment:
- The
foldBlockStructuredefinition is structural; no soundness theorem is claimed here. The docstring correctly notes that CWSS is established only as part of the surrounding fold block. - The
decomposefield usesEquiv.castwith afin_casesproof — slightly fragile but correct given the single challenge round. - The
arity_eqproof usesrfl, which works because the arithmetic and lambda expressions are definitionally equal. - The
oracleVerifierrequires anOracleInterface (Fin ℓ → C)instance not explicitly provided in the variable context; the file compiles, so it must be available from imports, but this implicit dependency is worth noting.
No escape hatches (sorry, axiom, opaque, native_decide, etc.) are present. The code typechecks successfully.
Potential issues found:
- The
oracleVerifierdefinition implicitly relies on anOracleInterface (Fin ℓ → C)instance that is not declared as a variable or instance argument. While the file compiles, this makes the module fragile — users who import it without the necessary instance (likely provided transitively through the imports) will get opaque type errors. - The
decomposeproof usesfin_caseswhich relies on the internal representation ofChallengeIdx; this is acceptable but could be simplified with a lemma aboutpSpec.Challenge.
No mathematical misformalizations detected.
Verdict: Needs Minor Revisions
Critical Misformalizations: None
Lean 4 / Mathlib Issues:
- The
oracleVerifierdefinition (and transitivelyoracleReductionandoracleProver) requires anOracleInterface (Fin ℓ → C)instance that is not declared as a variable, instance argument, or provided by a local instance. The file compiles only because the instance is supplied by the imports (ArkLib.OracleReduction.Security.RoundByRoundor...CoordinateWiseSpecialSoundness.Basic). This is an implicit, fragile dependency: users of this module who do not import those exact files (or who import them in a different order) may encounter type errors with no clear indication thatOracleInterface (Fin ℓ → C)is missing. The docstring mentions[SampleableType (Fin ℓ → C)]is needed to run the reduction but does not mention this compile-time requirement. (ArkLib/ProofSystem/Component/SendChallenge.lean:60-68) (confidence: medium)- Evidence: The
OracleVerifierstructure (fromOracleInterface) has an instance argument[Oₘ : (i : pSpec.MessageIdx) → OracleInterface (pSpec.Message i)]. ForpSpec C ℓ,pSpec.Message iisFin ℓ → Cfor theV_to_Pround. NoOracleInterface (Fin ℓ → C)instance is provided in thevariableblock or locally in the file. The file typechecks (lean_typechecksucceeded), confirming the instance is found from imports, but the dependency is not explicit. - Suggested fix: Consider adding a typeclass assumption
[OracleInterface (Fin ℓ → C)]to thevariableblock, or at minimum document the requirement in the module docstring alongside the existingSampleableTypenote.
- Evidence: The
Nitpicks:
- The proof of
oracleVerifier_toVerifier_runuses arwwith ashow ... from rflblock that is unnecessarily complex. A simplersimpproof might suffice, improving readability and maintainability. (ArkLib/ProofSystem/Component/SendChallenge.lean:94-99) (confidence: low)- Evidence: Lines 94-99:
simp only [Verifier.run, OracleVerifier.toVerifier, oracleVerifier]followed byrw [show simulateQ ... = ... from rfl, pure_bind]andcongr 1. Therwstep appears to be a no-op that could be eliminated.
- Evidence: Lines 94-99:
Prepare primitive IORs for CWSS composition
Verifier.id, binary append, andseqCompose.SendWitness,SendClaim,CheckClaim, andReduceClaim.SendChallengeas the verifier-challenge component for fold-style protocols, including its CWSS structure.