| 1 |
(************************************************************************) |
| 2 |
(* * The Rocq Prover / The Rocq Development Team *) |
| 3 |
(* v * Copyright INRIA, CNRS and contributors *) |
| 4 |
(* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 |
(* \VV/ **************************************************************) |
| 6 |
(* // * This file is distributed under the terms of the *) |
| 7 |
(* * GNU Lesser General Public License Version 2.1 *) |
| 8 |
(* * (see LICENSE file for the text of the license) *) |
| 9 |
(************************************************************************) |
| 10 |
|
| 11 |
Require Import Ltac2.Init. |
| 12 |
Require Ltac2.Control. |
| 13 |
Require Ltac2.List. |
| 14 |
|
| 15 |
Module Free. |
| 16 |
|
| 17 |
Ltac2 Type t. |
| 18 |
(** Type of sets of free variables *) |
| 19 |
|
| 20 |
Ltac2 @external empty : t := "rocq-runtime.plugins.ltac2" "fresh_free_empty". |
| 21 |
|
| 22 |
Ltac2 @external add : ident -> t -> t := "rocq-runtime.plugins.ltac2" "fresh_free_add". |
| 23 |
|
| 24 |
Ltac2 @external union : t -> t -> t := "rocq-runtime.plugins.ltac2" "fresh_free_union". |
| 25 |
|
| 26 |
Ltac2 @external of_ids : ident list -> t := "rocq-runtime.plugins.ltac2" "fresh_free_of_ids". |
| 27 |
|
| 28 |
Ltac2 @external of_constr : constr -> t := "rocq-runtime.plugins.ltac2" "fresh_free_of_constr". |
| 29 |
|
| 30 |
Ltac2 of_goal () := of_ids (List.map (fun (id, _, _) => id) (Control.hyps ())). |
| 31 |
|
| 32 |
End Free. |
| 33 |
|
| 34 |
(** Generate a fresh identifier with the given base name which is not a |
| 35 |
member of the provided set of free variables, and update the set. |
| 36 |
More efficient than composing [fresh] and [Free.add]. *) |
| 37 |
Ltac2 @external next : Free.t -> ident -> ident * Free.t := "rocq-runtime.plugins.ltac2" "fresh_next". |
| 38 |
|
| 39 |
(** Generate a fresh identifier with the given base name which is not a |
| 40 |
member of the provided set of free variables. *) |
| 41 |
Ltac2 @external fresh : Free.t -> ident -> ident := "rocq-runtime.plugins.ltac2" "fresh_fresh". |
| 42 |
|
| 43 |
Ltac2 in_goal id := Fresh.fresh (Free.of_goal ()) id. |