| 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 |
(** This module defines the Ltac2 FFI to Ltac1 code. Due to intricate semantics |
| 12 |
of the latter, the functions described here are voluntarily under-specified. |
| 13 |
Not for the casual user, handle with care and expect undefined behaviours |
| 14 |
otherwise. **) |
| 15 |
|
| 16 |
Require Import Ltac2.Init Ltac2.Std Ltac2.Control. |
| 17 |
|
| 18 |
Ltac2 Type t. |
| 19 |
(** Dynamically-typed Ltac1 values. *) |
| 20 |
|
| 21 |
Ltac2 @ external ref : ident list -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_ref". |
| 22 |
(** Returns the Ltac1 definition with the given absolute name. *) |
| 23 |
|
| 24 |
Ltac2 @ external run : t -> unit := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_run". |
| 25 |
(** Runs an Ltac1 value, assuming it is a 'tactic', i.e. not returning |
| 26 |
anything. *) |
| 27 |
|
| 28 |
Ltac2 @ external lambda : (t -> t) -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_lambda". |
| 29 |
(** Embed an Ltac2 function into Ltac1 values. Contrarily to the ltac1:(...) |
| 30 |
quotation, this function allows both to capture an Ltac2 context inside the |
| 31 |
closure and to return an Ltac1 value. Returning values in Ltac1 is a |
| 32 |
intrepid endeavour prone to weird runtime semantics. *) |
| 33 |
|
| 34 |
Ltac2 @ external apply : t -> t list -> (t -> unit) -> unit := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_apply". |
| 35 |
(** Applies an Ltac1 value to a list of arguments, and provides the result in |
| 36 |
CPS style. It does **not** run the returned value. *) |
| 37 |
|
| 38 |
(** Conversion functions *) |
| 39 |
|
| 40 |
Ltac2 @ external of_int : int -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_of_int". |
| 41 |
(** Converts an Ltac2 int into an Ltac1 value. *) |
| 42 |
Ltac2 @ external to_int : t -> int option := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_to_int". |
| 43 |
(** Converts an Ltac1 int into an Ltac2 value. *) |
| 44 |
|
| 45 |
Ltac2 @ external of_constr : constr -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_of_constr". |
| 46 |
(** Converts an Ltac2 constr into an Ltac1 value. *) |
| 47 |
Ltac2 @ external to_constr : t -> constr option := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_to_constr". |
| 48 |
(** Converts an Ltac1 constr (which includes terms created via open_constr) into an Ltac2 value. *) |
| 49 |
|
| 50 |
(** [preterm] is called [uconstr] in Ltac1. *) |
| 51 |
Ltac2 @ external of_preterm : preterm -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_of_preterm". |
| 52 |
Ltac2 @ external to_preterm : t -> preterm option := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_to_preterm". |
| 53 |
|
| 54 |
Ltac2 @ external of_ident : ident -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_of_ident". |
| 55 |
Ltac2 @ external to_ident : t -> ident option := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_to_ident". |
| 56 |
|
| 57 |
Ltac2 @ external of_list : t list -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_of_list". |
| 58 |
Ltac2 @ external to_list : t -> t list option := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_to_list". |
| 59 |
|
| 60 |
Ltac2 @ external of_intro_pattern : intro_pattern -> t := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_of_intro_pattern". |
| 61 |
Ltac2 @ external to_intro_pattern : t -> intro_pattern option := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_to_intro_pattern". |
| 62 |
|
| 63 |
(** Debug information *) |
| 64 |
|
| 65 |
Ltac2 @ external tag_name : t -> string := "rocq-runtime.plugins.ltac2_ltac1" "ltac1_tag_name". |
| 66 |
(** Name of the ltac1 value class the argument belongs to. Should be |
| 67 |
used only for error printing, typically "expected a constr but got a tag_name". *) |