Debian Codegraph @

theories/Ltac2/Unification.v

raw
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.TransparentState.
13
14
15 (** This file contains conversion and unification.
16 Both can add universe constraints.
17 Compared to conversion, unification can additionaly instantiate evars.
18 *)
19
20
21 (** Conversion **)
22
23 (** Controls if cumulativity Prop <= Set <= Type 1 <= ... <= Type i <= ... is used for conversion. *)
24 Ltac2 Type conv_flag := [
25 | CONV
26 | CUMUL
27 ].
28
29 (** Conv returns true if both terms are convertible, in which case it updates the
30 environment with the universes constraints required for the terms to be convertible.
31 It returns false if the terms are not convertible.
32 It fails if there is more than one goal under focus.
33
34 Conv is parametrised by:
35 - conv_flag which controls if conversion is done up to cumulativity or not
36 - TransparentState.t which controls which constants get unfolded during conversion
37 *)
38 Ltac2 @external conv : conv_flag -> TransparentState.t -> constr -> constr -> bool
39 := "rocq-runtime.plugins.ltac2" "infer_conv".
40
41 (** It only unfolds constants that are transparent in the current state *)
42 Ltac2 conv_current : constr -> constr -> bool := fun c1 c2 => conv CONV (TransparentState.current ()) c1 c2.
43
44 (** All constants are considered as transparents when doing conversion *)
45 Ltac2 conv_full : constr -> constr -> bool := fun c1 c2 => conv CONV TransparentState.full c1 c2.
46
47
48 (** Unification **)
49
50 (** [unify ts c1 c2] unifies [c1] and [c2] (using Evarconv unification), which
51 may have the effect of instantiating evars. If the [c1] and [c2] cannot be
52 unified, an [Internal] exception is raised. *)
53 Ltac2 @ external unify : TransparentState.t -> constr -> constr -> unit :=
54 "rocq-runtime.plugins.ltac2" "evarconv_unify".
55
56 (** [unify_with_full_ts] is like [unify TransparentState.full]. *)
57 Ltac2 unify_with_full_ts : constr -> constr -> unit := fun c1 c2 =>
58 unify TransparentState.full c1 c2.
59
60 (** [unify_with_current_ts] is like [unify (TransparentState.current ())]. *)
61 Ltac2 unify_with_current_ts : constr -> constr -> unit := fun c1 c2 =>
62 unify (TransparentState.current ()) c1 c2.
63
64 (** [solve_constraints ()] solves any delayed unification constraints. *)
65 Ltac2 @external solve_constraints : unit -> unit
66 := "rocq-runtime.plugins.ltac2" "solve_constraints".