Module Mlsem_lang.Transform

Compilation of the full language down to the functional core.

Ast has pattern matching, structured statements (if/while), non-local exits (return/break) and mutable variables. Mlsem_system.Ast has none of these. transform bridges the gap in three stages:

The order matters: control flow must go before the dataflow analysis, which reasons about a single expression tree, and the reference encoding must come last, since it hides assignments inside opaque operations.

Both functions expect an alpha-converted term whose nodes carry distinct Mlsem_common.Eid.ts, and preserve that property: every sub-expression they duplicate gets refreshed ids.

val eliminate_cf : Ast.t -> MAst.t

Removes pattern matching and control flow.

  • raises Invalid_argument

    on an ill-formed pattern (cf. Ast.pattern) or on a Ret that refers to no enclosing block.

val transform : Ast.t -> Mlsem_system.Ast.t