x = λy1 . . . yn . t ▶ ... introduces a new constant and an axiom ▶ but: t must not depend on x itself ▶ primrec defines a func on using that recursor ▶ fun allows more flexible recursion, but need to prove termina on 4 / 12
and Scala abstract sealed class list[A] final case class Nila[A]() extends list[A] final case class Cons[A](a: A, b: list[A]) extends list[A] def append[A](x0: list[A], xs: list[A]): list[A] = (x0, xs) match { case (Nila(), xs) => xs case (Cons(y, ys), xs) => Cons[A](y, append[A](ys, xs)) } 7 / 12
2. Preprocess 3. Build dependency graph, compute SCCs 4. Translate to intermediate language 5. Serialize to target language 6. Output: Source text 8 / 12
intermediate formal object Intermediate AST is a value in the logic Magnus O. Myreen and Sco Owens. Proof-producing synthesis of ML from higher-order logic. In Interna onal Conference on Func onal Programming (ICFP), 2012. 9 / 12
▶ Define a datatype for ML syntax, formalize seman cs ▶ Define relators between HOL values and ML values, e. g. relint :: ML val → int → bool ▶ When code generator is invoked on constant f, ▶ define a logical constant fML containing the AST ▶ prove theorem rela ng f to fML using the type’s relator 10 / 12
syntax and seman cs by Myreen ▶ Define intermediate layer of an Higher-Order TRS (including relators) ▶ When code generator is invoked on constant f, ▶ define a logical constant fTRS containing the TRS ▶ prove theorem rela ng f to fTRS using the type’s relator ▶ Define a HOL func on compile :: trs → ML val ▶ Prove it correct once and for all 11 / 12
dic onary construc on ▶ Users can specify custom equa ons need to figure out termina on and induc on principles (like fun) ▶ Genera on of relators for complex data types complex proof tac cs to accomodate for non-standard recursion ▶ Set of code equa ons is unordered need to specify wellformedness condi ons ▶ Execu on of the compiler itself (compile compileTRS ) bootstrapping using term rewri ng (slow!) 12 / 12