Skip to content

mark lines for removal ?? #2962

Answered by nikswamy
alex4482 asked this question in Q&A
Jun 12, 2023 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

By default, F* preserves the let-binding structure of a source program when extracting it.

I guess you have something that looks like this:

module Extract

let incr (x:int) : y:int { y = x + 1} = x + 1

let lem (x:int) (y:int)
  : Lemma
      (requires y = x + 1 /\ y > 1)
      (ensures x >= 0)
  = ()


let test (x:int { x > 0 }) : nat =
  let y = incr x in
  let _ = lem x y in
  x

And the extracted code produced by fstar.exe --codegen OCaml looks like

$ cat Extract.ml
open Prims
let (incr : Prims.int -> Prims.int) = fun x -> x + Prims.int_one
let (test : Prims.int -> Prims.nat) = fun x -> let y = incr x in x

Notice the call to lem is erased (total let bindings of unit are erased). But …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@alex4482
Comment options

@nikswamy
Comment options

@alex4482
Comment options

@nikswamy
Comment options

@alex4482
Comment options

Answer selected by alex4482
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants