Documentation

Sparkle.Core.OracleSpec

A register role in an oracle specification.

  • role : String

    Logical name (e.g., "rs1")

  • namePattern : String

    Glob pattern to match IR register names. "*" = prefix wildcard.

  • isOutput : Bool

    True if this register is written by the oracle (output).

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def Sparkle.Core.OracleSpec.iterateN {α : Sort u_1} (f : αα) :
      Natαα

      Iterate a function n times.

      Equations
      Instances For
        class Sparkle.Core.OracleSpec.OracleReduction (tag : String) (State Input Output : Type) :

        Type class for oracle-driven FSM reductions with mandatory proof.

        Type parameters:

        • tag: string literal identifying this reduction (e.g., "pcpi_mul")
        • State: internal FSM state type (e.g., rd × rdx × rs1 × rs2)
        • Input: input type extracted from registers (e.g., rs1 × rs2)
        • Output: result type to inject back (e.g., product)

        The equiv field requires a proof that iterating step for numCycles from initState input and extracting the result equals compute input. Without this proof, the instance cannot be constructed.

        • step : StateState

          One cycle of the FSM (pure Lean function modeling the hardware)

        • initState : InputState

          Map input register values to the FSM's initial state

        • extractResult : StateOutput

          Extract the final result from the FSM state

        • compute : InputOutput

          Direct computation (what the oracle actually executes)

        • numCycles : Nat

          Number of cycles the FSM takes

        • equiv (input : Input) : extractResult tag Input (iterateN (step tag Input Output) (numCycles tag State Input Output) (initState tag Output input)) = compute tag State input

          MANDATORY PROOF: iterating step = direct compute. This is the soundness guarantee. Without it, the instance cannot be constructed (unless sorry is used, which is explicit).

        • registers : List RegRole

          Register roles for pattern matching

        • encodeInputs : Array UInt64Input

          Encode JIT register values → typed Input

        • decodeResult : OutputList (String × UInt64)

          Decode typed Output → (role, value) pairs to write back

        • trigger : Array UInt64Bool

          Trigger condition on raw register values

        • deadWirePatterns : List String

          Wire patterns to eliminate from IR (optional)

        Instances

          Resolved oracle: type class instance with register indices bound.

          Instances For

            Mutable state for a running oracle.

            • totalSkipped : Nat
            • triggerCount : Nat
            Instances For

              Match a name against a glob pattern. Splits pattern on * and checks that all segments appear in order. Examples: *pcpi_mul*_seq* matches _gen_picorv32_pcpi_mul_next_rd_seq42.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Sparkle.Core.OracleSpec.resolve (tag : String) {State Input Output : Type} [inst : OracleReduction tag State Input Output] (handle : JIT.JITHandle) :

                Resolve an OracleReduction instance against a JITHandle.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Sparkle.Core.OracleSpec.mkOracle (tag : String) {State Input Output : Type} [inst : OracleReduction tag State Input Output] (resolved : ResolvedOracle) :

                  Create a runtime oracle from a resolved OracleReduction.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Sparkle.Core.OracleSpec.mkOracleAuto (tag : String) (State Input Output : Type) [OracleReduction tag State Input Output] (handle : JIT.JITHandle) :

                    One-shot: resolve + create oracle.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Compose multiple oracle callbacks: first match wins.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def Sparkle.Core.OracleSpec.reduceIR (tag : String) (State Input Output : Type) [inst : OracleReduction tag State Input Output] (body : List IR.AST.Stmt) :

                        IR reduction: remove dead wires and stub output registers.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For