Source lean/Determinize/Frontend/Compile.lean
import Determinize.Frontend.Parserimport Determinize.Frontend.Elaborateimport Determinize.Theoremsnamespace Determinize.Frontendopen Spec.Paper/-- A compiled program: the resolved input, the annotated program and type that `infer` returns,and the guarantee of `Theorems.inference_correctness` for them. -/structure Program where  input : Input  annotated : Annotated  ty : Ty  aligned : input.Matches annotated  typed : Typed [] (interpret annotated) ty/-- The annotated program as a core program, which the runtime and the finite models run. -/def Program.source (p : Program) : Core := p.annotated.toCoredef compile (text : String) : Except String Program := do  let input ← elaborate (← parse text)  match inferred : infer input with  | .ok (annotated, ty) =>    have correct := inferred ▸ Theorems.inference_correctness input    return { input, annotated, ty, aligned := correct.1, typed := correct.2.1 }  | .error message => throw messageend Determinize.Frontend