Documentation

LeanMlir.Proofs.Codegen.StableHLOParse

R4 — the syntactic half (4a), structural core #

StableHLO.lean closes the semantic half of R4: den (emit g) = fderiv. The syntactic half asks that the emitted text be a faithful, recoverable encoding of the graph — parse (pretty a) = a (the doc's "4a"). A verified lexer/parser of the literal SSA StableHLO text (with multi-instruction op expansion + name resolution) is a large separate build; this file lands its structural core, which is the load-bearing part:

What this buys: the structure of the emitted graph (which op, which operands, which shapes) is now proven recoverable — it leaves the trusted surface. What remains audited (the thin lexical boundary): the per-op Tok ↔ StableHLO text map — i.e. that stablehlo.dot_general … contracting_dims = [1] x [0] is the string for a dotIn token. That, plus per-op spec conformance, IREE lowering, and float32 ≈ ℝ, is the residue (validated by iree-compile + the GPU runs). Closes under [propext, Classical.choice, Quot.sound].

Stack reconstructor: fold the token stream, pushing operands and applying each opcode to the top of the stack (popping its arity).

Instances For

    Parse a full token stream back to a single graph.

    Equations
    Instances For
      theorem Proofs.StableHLO.parseStack_toToks (r : Raw) (ts : List Tok) (st : List Raw) :
      parseStack (toToks r ++ ts) st = parseStack ts (r :: st)

      Stack invariant. Serializing r and folding it onto a stack st pushes exactly r. The generalized statement that drives the round-trip.

      Serialization round-trip. parse recovers any skeleton from its postorder token stream.

      theorem Proofs.StableHLO.roundtrip {k : } (a : SHlo k) :

      R4 syntactic core. The emitted op-graph (skeleton) of any SHlo is a faithful, recoverable serialization: parse (toToks (skel a)) = some (skel a). The op structure / shapes / SSA names leave the trusted surface; only the per-op Tok ↔ StableHLO-text lexing stays audited.