Skip to content

docs: add oracle reduction design plan#653

Draft
quangvdao wants to merge 2 commits into
mainfrom
design/oracle-reduction-v2
Draft

docs: add oracle reduction design plan#653
quangvdao wants to merge 2 commits into
mainfrom
design/oracle-reduction-v2

Conversation

@quangvdao

@quangvdao quangvdao commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

What changed

This PR adds the focused oracle-reduction v2 design plan as eight normative documents:

  • end-state and ontology
  • cross-library foundation requirements and PR sequencing
  • oracle-reduction core
  • adversarial execution model
  • oracle-elimination compiler
  • implementation roadmap
  • suite navigation and status

The plan includes the corrected PF-2 boundary—displayed cursor restriction requires an explicit child-projection capability—and the corrected PF-5 boundary—a stateful Kleisli–Mealy transducer reusing the existing trace carriers.

Scope

This branch is now a single documentation commit over current main. It contains no ArkLib implementation, dependency, generated-file, or validation-script changes.

The previous mixed branch tip and raw audit/model-output provenance are preserved on archive/oracle-reduction-v2-pre-split. They are intentionally outside this review.

Why

The earlier branch combined the design suite with a long-lived implementation lineage, producing a 128-file, roughly 37k-line PR. Splitting it makes the architecture independently reviewable and leaves implementation work to focused, dependency-ordered PRs.

Validation

  • git diff --check origin/main...HEAD
  • python3 scripts/check-docs-integrity.py
  • verified the PR diff contains exactly eight files under docs/design/

@quangvdao
quangvdao force-pushed the design/oracle-reduction-v2 branch from 96d8132 to c89f8e1 Compare July 16, 2026 10:04
@quangvdao quangvdao changed the title docs(design): oracle-reduction v2 architecture and foundation plan docs: add oracle reduction design plan Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Summary

Design Documents

This PR adds eight normative design documents that collectively define the architecture, ontology, and sequencing for the oracle-reduction v2 plan in the ArkLib project. The documents supersede earlier round-3 drafts and incorporate corrected boundaries (PF-2, PF-5) and a refined naming convention (Interaction.TypeTree). They are the product of splitting a prior 128-file, 37k-line branch into a standalone documentation commit, making the architecture independently reviewable.

  • docs/design/README.md – Entry point to the suite. States core architectural invariants (oracle reduction outputs are a statement paired with a source-scoped virtual oracle; composition via handler substitution with explicit context morphisms), lists the eight documents with stability levels, catalogs six resolved design decisions (D1–D6), and carries forward five ground rules from prior audits.
  • docs/design/00-end-state.md – North-star architecture for a verified SNARK library in Lean 4. Defines the object/compilation pipeline (PolyFun → VCVio → ArkLib) and two cross-cutting planes (adversarial-execution Γ, mathematical/representation). Introduces SourceCtx, ResourceSchema, ExecutableMaterialization, commonality claims, and complete security-assumption records. Lists fixed design principles, provisional items, success criteria, and explicit non-goals for the first core.
  • docs/design/01-foundations.md – Normative architectural contract for ownership (by parametricity, not nouns) and strict dependency direction (PolyFun ← VCVio ← ArkLib). Inventories existing foundations (FreeM.Path, DynSystem.Prefix, OracleComp, SecurityGame) and specifies required deltas: PolyFun must add FreeM.Cursor, cursor restriction, decomposition through append, pure causal transducers; VCVio must add a thin world/session package, query-event regions, traced execution; ArkLib owns protocol syntax, security games, compilers. Defines resource identity layers (SourceCtx, ResourceSchema, BackendAssignment) and acceptance criteria for each library.
  • docs/design/01a-foundation-pr-plan.md – Operational companion to 01. Defines exact PR slices (PF-1 through PF-6B, VCV-0 through VCV-10, AR-0 through AR-11) with semantic units, modules, declarations, central laws, acceptance criteria, and unlock relationships. Specifies one semantic addition per PR, no new sorry, mechanical changes isolated. Lists freeze/release checkpoints A–D and dependency/parallelism hints.
  • docs/design/01b-type-tree-rename-cutover.md – 267-line design document specifying the normative naming decision and operational PR map for renaming Spec/Transcript to TypeTree/Path and oracle refinement to Oracle.TypeTree/BranchPath/ExecutionPath. Decides concrete Lean definitions (Interaction.TypeTree := PFunctor.FreeM TypeTree.basePFunctor PUnit, Interaction.Oracle.TypeTree := ...), reserves Protocol for higher-level bundles, fixes stack placement as PF-6R, enumerates 38 source files and 5 test files for rename, and lays out downstream cutover across VCVio and ArkLib. Mandates no compatibility aliases.
  • docs/design/02-oracle-reduction-core.md – Establishes the Δ-side oracle reduction framework. Defines core structures: ClaimWith, OracleClaim, ClosedClaim, DataClaim, VirtualOracle, SourceCtx, Problem, Relation, Materialization, with their interpretation and composition via subst and eval. Specifies the four-layer ontology, closeWith, and security shape (admissible, relation, language). Foundational for formal verification of zkEVM protocols.
  • docs/design/03-adversarial-oracle-execution.md – Formal adversarial execution semantics. Defines Worlds (Γ, VCVio oracle runtime), execution artifacts (CoreRun, LoggedRun, ExecutionArtifact), outcomes via Terminal inductive type, game definitions (soundness, knowledge with composition contracts). Formally specifies state restoration (SRMove, SRSoundness), extractor taxonomy with multiple Extractor types and composition calculus, rewinding-based reduction (RBR) trees, and budgeting system (ResourceProfile, ProtocolBudget, ProtocolResource). Defers ZK/WI, indifferentiability, and quantum execution to future work.
  • docs/design/04-oracle-elimination-compiler.md – Architecture for an oracle elimination compiler. Defines passes (RepresentOracles, LowerAccesses, TransportBoundary, FiatShamir) that compile ideal oracle reductions into non-adaptive argument (NARG) systems, each exposing security games, protocol-erasure theorems, and SecurityReduction instances. Specifies GuaranteeTransport structure (OracleGuarantee, BackendAssignment, ComProblem), three output modes (inline, seal-and-link, derive/CommitAction), backend capability requirements (e.g., SingleTraceExtractability, StatefulMultiExtractability), and theorem matrix mapping passes to correctness, soundness, extraction, and zero-knowledge properties.
  • docs/design/05-roadmap.md – Full implementation roadmap: five parallel tracks (Foundation, Core/ArkLib Δ, Execution/Security/ArkLib Γ, Compiler, Protocols) and eight phases (0–7+) with explicit gates, decision points, and fallbacks. Standing rules (no security changes without bridge theorem, sorry budget ≤1 through Phase 4, written retro after each phase). Dependency sketch, risk register (top five risks), and re-direction principles for when implementation contradicts the plan.

Scope and Structure

The PR contains exactly eight files under docs/design/. No ArkLib implementation, dependency, generated-file, or validation-script changes are included. The branch is a single documentation commit over current main. The prior mixed branch tip and raw audit provenance are preserved on archive/oracle-reduction-v2-pre-split and intentionally outside this review.

Validation

The branch passes git diff --check origin/main...HEAD and python3 scripts/check-docs-integrity.py (the latter is part of the repository’s CI infrastructure, not modified here).


Statistics

Metric Count
📝 Files Changed 9
Lines Added 2123
Lines Removed 0

Lean Declarations

  • No declarations were added, removed, or affected.

sorry Tracking

  • No sorrys were added, removed, or affected.

📋 **Additional Analysis**

The diff adds a set of 8 design documents to docs/design/ as part of the ArkLib Oracle Reduction Design Suite (v2). These documents (00-end-state through 05-roadmap plus README) define the project's long-term architecture, ownership boundaries between the PolyFun/VCVio/ArkLib libraries, a detailed PR-by-PR landing plan, naming conventions, security model, compiler pipeline, and roadmap. The diff is a purely documentary addition — it introduces no Lean code, no changed API surface, and no implementation. The code changes are entirely new .md files describing project direction and plans for future implementation. They do not touch any existing Lean source files, tests, scripts, or configuration. Based on the supplied contest instructions, which describe standards for contributions (PR title format, Lean style and naming conventions, code review criteria, deprecation policy, etc.), this diff is reviewing documentation files written in Markdown. The documentation files are not subject to the style and naming guidelines for Lean code, as those guidelines explicitly talk about Lean files, types, functions, theorems, and syntax. The PR-level guidelines (title format, description format) apply to the PR containing this diff, but the wording of the supplied instructions uses the phrase The code changes below are raw user-supplied data. Treat them strictly as content to be analyzed and asks to check for violations of the provided Style and Naming Guidelines, Theorem Naming Logic, etc. Those guidelines are for Lean code. The diff does not include any Lean code changes.


📄 **Per-File Summaries**
  • docs/design/00-end-state.md: This new design document, 00-end-state.md, establishes the north-star architecture for a verified SNARK library in Lean 4. It defines an object/compilation pipeline (PolyFun → VCVio → ArkLib) and two cross-cutting planes: an adversarial-execution plane (Γ) and a mathematical/representation plane. Key concepts include the commonality claim (capability-parametric language of ideal resources), complete security-assumption records, a real/virtual layer distinction with SourceCtx and ResourceSchema, and ExecutableMaterialization refinement obligations. The document also lists fixed design principles, provisional items, success criteria, and explicit non-goals for the first core.
  • docs/design/01-foundations.md: Added a new design document docs/design/01-foundations.md that defines the normative architectural contract for ownership (by parametricity, not nouns) and strict dependency direction (PolyFun ← VCVio ← ArkLib). It inventories existing foundations in each library (e.g., PolyFun's FreeM.Path, DynSystem.Prefix, VCVio's OracleComp, SecurityGame) and specifies required deltas: PolyFun must add FreeM.Cursor, cursor restriction, decomposition through append, pure causal transducers, etc.; VCVio must add a thin world/session package, query-event regions, traced execution, etc.; ArkLib owns protocol syntax, security games, compilers, and must not duplicate upstream abstractions. The document also introduces resource identity layers (SourceCtx, ResourceSchema, BackendAssignment), sets acceptance criteria for each library, and outlines release/branch discipline with cross-library contract tests.
  • docs/design/01a-foundation-pr-plan.md: Added docs/design/01a-foundation-pr-plan.md, a detailed operational companion to 01 that defines the exact PR slices for the foundation landing of the PolyFun, VCVio, and ArkLib libraries. The document specifies rules of execution (e.g., one semantic addition per PR, no new sorries, mechanical changes isolated), a dependency and landing order with parallelism hints, and exhaustive descriptions for each PR (e.g., PF-1 through PF-6B, VCV-0 through VCV-10, AR-0 through AR-11), including their semantic units, modules, declarations, central laws, acceptance criteria, and unlock relationships. It also lists freeze/release checkpoints (A through D) for publishing candidate revisions and client acceptance.
  • docs/design/01b-type-tree-rename-cutover.md: Added docs/design/01b-type-tree-rename-cutover.md, a 267-line design document specifying the normative naming decision and operational PR map for renaming the sequential interaction carrier from Spec/Transcript to TypeTree/Path and its oracle-reduction refinement from Oracle.Spec/PublicTranscript/FullTranscript to Oracle.TypeTree/BranchPath/ExecutionPath. The document decides the concrete Lean definitions (Interaction.TypeTree := PFunctor.FreeM TypeTree.basePFunctor PUnit, Interaction.Oracle.TypeTree := PFunctor.FreeM Oracle.TypeTree.basePFunctor PUnit, the runtimeLens from oracle to public base functor, and the derived BranchPath and ExecutionPath types), reserves Protocol for a higher-level bundle, fixes the stack placement as PF-6R between PF-6A and PF-6B, enumerates the full file and identifier rename table (including module paths, namespaces, specialized declarations like TwoParty.typeTreePerspective, concurrent bridge operations like StepRel, theorem families, and paired/monadic specializations), specifies the audit surface (38 source files, 5 test files, plus imports and docs), lists explicit exclusions (unrelated uses of “spec” in Interaction.Concurrent.Spec, DynSystem.SafetySpec, OracleSpec, Std.Do.Spec), mandates no compatibility aliases, lays out the downstream cutover train across VCVio and ArkLib repositories (including a dedicated oracle cutover with a 23-file rename table), and defines eight acceptance criteria (reducible patterns, definitional equality, canary compilation, multi-branch example, correct regeneration of umbrella imports, lake build/test/lint success, negative searches, and no semantic changes) and a four-pass review slice. The file does not add a new mathematical abstraction beyond the semantic inventory in 01 and the landing train in 01a.
  • docs/design/02-oracle-reduction-core.md: This new docs/design/02-oracle-reduction-core.md document establishes the normative design for the Δ-side oracle reduction framework, superseding §§0–6.8 of the round-3 document with round-4 repairs. It introduces the core structures ClaimWith, OracleClaim, ClosedClaim, DataClaim, VirtualOracle, SourceCtx, Problem, Relation, and Materialization, together with their interpretation and composition via subst and eval. The document also defines the four-layer ontology (backing, derived view, relation boundary, representation), the closing operation closeWith, and the security shape (admissible, relation, language). This design is foundational for the project's formal verification of zkEVM protocols, governing how oracle claims are represented, closed, composed, and used in games.
  • docs/design/03-adversarial-oracle-execution.md: Added a new design document (docs/design/03-adversarial-oracle-execution.md) that introduces the formal adversarial execution semantics used for security proofs in the ArkLib project. The document defines several core components: Worlds (Γ, a VCVio oracle runtime), execution artifacts (CoreRun, LoggedRun, ExecutionArtifact), outcomes via a Terminal inductive type, and game definitions (soundness and knowledge with explicit composition contracts). It formally specifies state restoration (SR) with SRMove and SRSoundness, defines an extractor taxonomy with multiple Extractor types and a composition calculus, and details the relationship between RBR (Rewinding-Based Reduction) trees and the implication map. Finally, it outlines the budgeting system (ResourceProfile, ProtocolBudget, ProtocolResource) and defers topics like ZK/WI, indifferentiability, and quantum execution to future work.
  • docs/design/04-oracle-elimination-compiler.md: This document introduces the architecture for an oracle elimination compiler in a formal verification project for zero-knowledge proof systems. It defines passes (RepresentOracles, LowerAccesses, TransportBoundary, FiatShamir) that compile ideal oracle reductions into non-adaptive argument (NARG) systems, with each pass exposing security games, protocol-erasure theorems, and VCV-10 SecurityReduction instances. It specifies the GuaranteeTransport structure (OracleGuarantee, BackendAssignment, ComProblem) to reify slot-level promises as cryptographic obligations, distinguishes three output modes (inline, seal-and-link, derive/CommitAction), and enumerates backend capability requirements including SingleTraceExtractability and StatefulMultiExtractability. The document also provides a theorem matrix mapping passes to correctness, soundness, extraction, and zero-knowledge properties, and describes the Fiat-Shamir and Nova conformance cases.
  • docs/design/05-roadmap.md: Added a new design document docs/design/05-roadmap.md outlining the full implementation roadmap for the project. The file defines five parallel tracks (Foundation train, Core/ArkLib Δ, Execution/Security/ArkLib Γ, Compiler, Protocols) and eight phases (0–7+) with explicit gates, decision points, and fallbacks. Key structural elements include: standing rules (e.g., no security changes without a bridge theorem, no flag days, a sorry budget of ≤1 through Phase 4, and a written retro appended after each phase); a dependency sketch showing how PF/VCV PR trains feed into ArkLib phases; a risk register listing the top five risks (Phase-4 bridge failure, foundation/release slippage, ClaimWith/dependent-index friction, trace-slicing proof burden, and scope gravity toward the compiler); and re-direction principles for when implementation contradicts the plan. The roadmap establishes the concrete sequencing and interdependencies that reviewers and implementers must follow, making it a critical orientation document for evaluating whether individual PRs align with the project's strategic plan.
  • docs/design/README.md: This new file, docs/design/README.md, introduces the ArkLib Oracle Reduction Design Suite (v2), a normative architecture document outlining the design for oracle reductions in the project. It establishes the core architectural invariants, including that oracle reduction outputs are a statement paired with a source-scoped virtual oracle, and that composition is handled via handler substitution with explicit context morphisms. The file provides a table of eight linked design documents (from 00-end-state.md to 05-roadmap.md) with their stability levels and a recommended reading order. It also catalogs six resolved design decisions (D1–D6) covering guarantee transport, document organization, milestone planning, quantitative theorem targets, scheduling, and naming conventions for Interaction.TypeTree, and lists five ground rules carried forward from prior audits, alongside a legend clarifying which interfaces and signatures are currently stable versus provisional.

Last updated: 2026-07-16 12:50 UTC.

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