Debian Codegraph @

interp/impargs.mli

raw symbols SCIP
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 open Names
12 open EConstr
13 open Environ
14
15 (** {6 Implicit Arguments } *)
16 (** Here we store the implicit arguments. Notice that we
17 are outside the kernel, which knows nothing about implicit arguments. *)
18
19 val make_implicit_args : bool -> unit
20 val make_strict_implicit_args : bool -> unit
21 val make_strongly_strict_implicit_args : bool -> unit
22 val make_reversible_pattern_implicit_args : bool -> unit
23 val make_contextual_implicit_args : bool -> unit
24 val make_maximal_implicit_args : bool -> unit
25
26 val is_implicit_args : unit -> bool
27 val is_strict_implicit_args : unit -> bool
28 val is_strongly_strict_implicit_args : unit -> bool
29 val is_reversible_pattern_implicit_args : unit -> bool
30 val is_contextual_implicit_args : unit -> bool
31 val is_maximal_implicit_args : unit -> bool
32
33 val with_implicit_protection : ('a -> 'b) -> 'a -> 'b
34
35 (** {6 ... } *)
36 (** An [implicits_list] is a list of positions telling which arguments
37 of a reference can be automatically inferred *)
38
39
40 type argument_position =
41 | Conclusion
42 | Hyp of int
43
44 (** We remember various information about why an argument is
45 inferable as implicit *)
46 type implicit_explanation =
47 | DepRigid of argument_position
48 (** means that the implicit argument can be found by
49 unification along a rigid path (we do not print the arguments of
50 this kind if there is enough arguments to infer them) *)
51 | DepFlex of argument_position
52 (** means that the implicit argument can be found by unification
53 along a collapsible path only (e.g. as x in (P x) where P is another
54 argument) (we do (defensively) print the arguments of this kind) *)
55 | DepFlexAndRigid of (*flex*) argument_position * (*rig*) argument_position
56 (** means that the least argument from which the
57 implicit argument can be inferred is following a collapsible path
58 but there is a greater argument from where the implicit argument is
59 inferable following a rigid path (useful to know how to print a
60 partial application) *)
61 | Manual
62 (** means the argument has been explicitly set as implicit. *)
63
64 (** We also consider arguments inferable from the conclusion but it is
65 operational only if [conclusion_matters] is true. *)
66
67 type maximal_insertion = bool (** true = maximal contextual insertion *)
68
69 type force_inference = bool (** true = always infer, never turn into evar/subgoal *)
70
71 type implicit_position = Name.t * int * int option
72
73 type implicit_status_info = {
74 impl_pos : implicit_position;
75 impl_expl : implicit_explanation;
76 impl_max : maximal_insertion;
77 impl_force : force_inference;
78 }
79
80 type implicit_status = implicit_status_info option
81 (** [None] = Not implicit *)
82
83 type implicit_side_condition
84
85 type implicits_list = implicit_side_condition * implicit_status list
86
87 val is_status_implicit : implicit_status -> bool
88 val binding_kind_of_status : implicit_status -> Glob_term.binding_kind
89 val is_inferable_implicit : bool -> int -> implicit_status -> bool
90 val name_of_implicit : implicit_status -> Id.t
91 val match_implicit : implicit_status -> Constrexpr.explicitation -> bool
92 val maximal_insertion_of : implicit_status -> bool
93 val force_inference_of : implicit_status -> bool
94 val is_nondep_implicit : int -> implicit_status list -> bool
95 val explicitation : implicit_status -> Constrexpr.explicitation
96
97 val positions_of_implicits : implicits_list -> int list
98
99 type manual_implicits = (Name.t * bool) option CAst.t list
100
101 val compute_implicits_with_manual : env -> Evd.evar_map -> ?silent:bool -> types -> bool ->
102 manual_implicits -> implicit_status list
103
104 val compute_implicits_names : env -> Evd.evar_map -> types -> implicit_position list
105
106 (** {6 Computation of implicits (done using the global environment). } *)
107
108 val declare_var_implicits : variable -> impl:Glob_term.binding_kind -> unit
109 val declare_constant_implicits : Constant.t -> unit
110 val declare_mib_implicits : MutInd.t -> unit
111
112 val declare_implicits : bool -> GlobRef.t -> unit
113
114 (** [declare_manual_implicits local ref enriching l]
115 Manual declaration of which arguments are expected implicit.
116 If not set, we decide if it should enrich by automatically inferd
117 implicits depending on the current state.
118 Unsets implicits if [l] is empty. *)
119
120 val declare_manual_implicits : bool -> GlobRef.t -> ?enriching:bool ->
121 manual_implicits -> unit
122
123 (** If the list is empty, do nothing, otherwise declare the implicits. *)
124
125 val maybe_declare_manual_implicits : bool -> GlobRef.t -> ?enriching:bool ->
126 manual_implicits -> unit
127
128 (** [set_implicits local ref l]
129 Manual declaration of implicit arguments.
130 [l] is a list of possible sequences of implicit statuses. *)
131 val set_implicits : bool -> GlobRef.t -> (Name.t * Glob_term.binding_kind) list list -> unit
132
133 val implicits_of_global : GlobRef.t -> implicits_list list
134
135 val extract_impargs_data :
136 implicits_list list -> ((int * int) option * implicit_status list) list
137
138 val make_implicits_list : implicit_status list -> implicits_list list
139
140 val drop_first_implicits : int -> implicits_list -> implicits_list
141
142 val projection_implicits : env -> Projection.t -> implicit_status list ->
143 implicit_status list
144
145 val select_impargs_size : int -> implicits_list list -> implicit_status list
146
147 val select_stronger_impargs : implicits_list list -> implicit_status list
148
149 val select_impargs_size_for_proj :
150 nexpectedparams:int -> ngivenparams:int -> nextraargs:int ->
151 implicits_list list -> (implicit_status list * implicit_status list, int list Lazy.t) Util.union
152
153 val impargs_for_proj :
154 nexpectedparams:int -> nextraargs:int ->
155 implicit_status list -> implicit_status list * implicit_status list