Skip to content

Unfolding definitions after the fact #2556

Discussion options

You must be logged in to vote

Transcript from @aseemr's answer.

F* has a postprocess_with attribute that lets one run a meta-program (tactic) on a definition after it has type-checked. It has to solve a goal of the form e == ?u (where e is the body of the function), hence the trefl tactic at the end.

module Test

open FStar.Tactics

[@@ "opaque_to_smt"]
let n = 0

[@@ "opaque_to_smt"]
let m = 1

let t () : Tac unit = norm [delta_only [`%n; `%m]]; trefl ()

[@@ (postprocess_with t)]
let foo = n + m

let test () = assert (foo == 1)

The backtick followed by %n here quotes n.

The same method can be used to make a definition unfold after the fact:

module Test

open FStar.Tactics

[@@ "opaque_to_smt"]
let k = 0

let t () : Tac

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TheoWinterhalter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant