Debian Codegraph @

tactics/tacticals.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 Evd
14 open Locus
15 open Tactypes
16
17 (** A special exception for levels for the Fail tactic *)
18 exception FailError of int * Pp.t Lazy.t
19
20 (** Tacticals defined directly in term of Proofview *)
21
22 (** The tacticals below are the tactical of Ltac. Their
23 semantics is an extension of the tacticals in this file for the
24 multi-goal backtracking tactics. They do not have the same
25 semantics as the similarly named tacticals in [Proofview]. The
26 tactical of [Proofview] are used in the definition of the
27 tacticals of [Tacticals], but they are more atomic. In
28 particular [Tacticals.tclORELSE] sees lack of progress as a
29 failure, whereas [Proofview.tclORELSE] doesn't. Additionally every
30 tactic which can catch failure ([tclOR], [tclORELSE], [tclTRY],
31 [tclREPEAt], etc…) are run into each goal independently (failures
32 and backtracks are localised to a given goal). *)
33
34 open Proofview
35
36 (** [catch_failerror e] fails and decreases the level if [e] is an
37 Ltac error with level more than 0. Otherwise succeeds. *)
38 val catch_failerror : Exninfo.iexn -> unit tactic
39
40 val tclIDTAC : unit tactic
41 val tclTHEN : unit tactic -> unit tactic -> unit tactic
42 (* [tclFAILn n msg] fails with [msg] as an error message at level [n]
43 (meaning that it will jump over [n] error catching tacticals FROM
44 THIS MODULE. *)
45 val tclFAILn : ?info:Exninfo.info -> int -> Pp.t -> 'a tactic
46
47 val tclFAIL : ?info:Exninfo.info -> Pp.t -> 'a tactic
48 (** Same as above with level set to 0. *)
49
50 val tclZEROMSG : ?info:Exninfo.info -> ?loc:Loc.t -> Pp.t -> 'a tactic
51 (** Fail with a [User_Error] containing the given message. *)
52
53 val tclOR : unit tactic -> unit tactic -> unit tactic
54 val tclORD : unit tactic -> (unit -> unit tactic) -> unit tactic
55 (** Like {!tclOR} but accepts a delayed tactic as a second argument
56 in the form of a function which will be run only in case of
57 backtracking. *)
58
59 val tclONCE : unit tactic -> unit tactic
60 val tclEXACTLY_ONCE : unit tactic -> unit tactic
61
62 val tclIFCATCH :
63 unit tactic ->
64 (unit -> unit tactic) ->
65 (unit -> unit tactic) -> unit tactic
66
67 val tclORELSE0 : unit tactic -> unit tactic -> unit tactic
68 val tclORELSE : unit tactic -> unit tactic -> unit tactic
69
70 (** [tclTHENS3PARTS tac1 [|t1 ; ... ; tn|] tac2 [|t'1 ; ... ; t'm|]
71 gls] applies the tactic [tac1] to [gls] then, applies [t1], ...,
72 [tn] to the first [n] resulting subgoals, [t'1], ..., [t'm] to the
73 last [m] subgoals and [tac2] to the rest of the subgoals in the
74 middle. Raises an error if the number of resulting subgoals is
75 strictly less than [n+m] *)
76 val tclTHENS3PARTS : unit tactic -> unit tactic array -> unit tactic -> unit tactic array -> unit tactic
77 val tclTHENSLASTn : unit tactic -> unit tactic -> unit tactic array -> unit tactic
78 val tclTHENSFIRSTn : unit tactic -> unit tactic array -> unit tactic -> unit tactic
79 val tclTHENFIRSTn : unit tactic -> unit tactic array -> unit tactic
80
81 (** [tclTHENFIRST tac1 tac2 gls] applies the tactic [tac1] to [gls]
82 and [tac2] to the first resulting subgoal *)
83 val tclTHENFIRST : unit tactic -> unit tactic -> unit tactic
84 val tclBINDFIRST : 'a tactic -> ('a -> 'b tactic) -> 'b tactic
85 val tclTHENLASTn : unit tactic -> unit tactic array -> unit tactic
86 val tclTHENLAST : unit tactic -> unit tactic -> unit tactic
87 val tclBINDLAST : 'a tactic -> ('a -> 'b tactic) -> 'b tactic
88 (* [tclTHENS t l = t <*> tclDISPATCH l] *)
89 val tclTHENS : unit tactic -> unit tactic list -> unit tactic
90 (* [tclTHENLIST [t1;…;tn]] is [t1<*>…<*>tn] *)
91 val tclTHENLIST : unit tactic list -> unit tactic
92
93 (** [tclMAP f [x1..xn]] builds [(f x1);(f x2);...(f xn)] *)
94 val tclMAP : ('a -> unit tactic) -> 'a list -> unit tactic
95
96 val tclTRY : unit tactic -> unit tactic
97 val tclTRYb : unit tactic -> bool list tactic
98 val tclFIRST : unit tactic list -> unit tactic
99 val tclIFTHENELSE : unit tactic -> unit tactic -> unit tactic -> unit tactic
100 val tclIFTHENSVELSE : unit tactic -> unit tactic array -> unit tactic -> unit tactic
101 val tclIFTHENTRYELSEMUST : unit tactic -> unit tactic -> unit tactic
102 val tclIFTHENFIRSTTRYELSEMUST : unit tactic -> unit tactic -> unit tactic
103
104 val tclDO : int -> unit tactic -> unit tactic
105 val tclREPEAT : unit tactic -> unit tactic
106 (* Repeat on the first subgoal (no failure if no more subgoal) *)
107 val tclREPEAT_MAIN : unit tactic -> unit tactic
108 val tclCOMPLETE : 'a tactic -> 'a tactic
109 val tclSOLVE : unit tactic list -> unit tactic
110 val tclPROGRESS : unit tactic -> unit tactic
111 val tclRUNWITHHOLES : bool -> 'a tactic -> ('a -> 'b tactic) -> 'b tactic
112 (** [tclRUNWITHHOLES b tac0 tac] is [tac0 >>= tac] if [b = false],
113 otherwise it additionally checks that evars created by [tac0] are solved after [tac]. *)
114
115 val tclWITHHOLES : bool -> 'a tactic -> Evd.evar_map -> 'a tactic
116 val tclDELAYEDWITHHOLES : bool -> 'a delayed_open -> ('a -> unit tactic) -> unit tactic
117 val tclMAPDELAYEDWITHHOLES : bool -> 'a delayed_open list -> ('a -> unit tactic) -> unit tactic
118 (* in [tclMAPDELAYEDWITHHOLES with_evars l tac] the delayed
119 argument of [l] are evaluated in the possibly-updated
120 environment and updated sigma of each new successive goals *)
121
122 val tactic_of_delayed : 'a delayed_open -> 'a tactic
123 (** Must be focused to use *)
124
125 val check_evar_list : Environ.env -> evar_map -> Evar.Set.t -> evar_map -> Evar.t list
126 (* [check_evar_list env sigma evars origsigma] returns the subset of
127 [evars] not instantiated (up to restriction) in the extension
128 [sigma] of [origsigma] where evars of [origsigma] are considered
129 as "axioms", that is that an evar of [evars] instantiated by an
130 evar of [origsigma] is considered to be instantiated *)
131
132 val tclTIMEOUT : int -> unit tactic -> unit tactic
133 val tclTIME : string option -> 'a tactic -> 'a tactic
134
135 val nLastDecls : Proofview.Goal.t -> int -> named_context
136
137 val ifOnHyp : (Environ.env -> evar_map -> Id.t * types -> bool) ->
138 (Id.t -> unit Proofview.tactic) -> (Id.t -> unit Proofview.tactic) ->
139 Id.t -> unit Proofview.tactic
140
141 val onNthHypId : int -> (Id.t -> unit tactic) -> unit tactic
142 val onLastHypId : (Id.t -> unit tactic) -> unit tactic
143 val onLastHyp : (constr -> unit tactic) -> unit tactic
144 val onLastDecl : (named_declaration -> unit tactic) -> unit tactic
145
146 val onNLastHypsId : int -> (Id.t list -> unit tactic) -> unit tactic
147 val onNLastHyps : int -> (constr list -> unit tactic) -> unit tactic
148 val onNLastDecls : int -> (named_context -> unit tactic) -> unit tactic
149
150 val onHyps : (Proofview.Goal.t -> named_context) ->
151 (named_context -> unit tactic) -> unit tactic
152 val afterHyp : Id.t -> (named_context -> unit tactic) -> unit tactic
153
154 val tryAllHyps : (Id.t -> unit tactic) -> unit tactic
155 val tryAllHypsAndConcl : (Id.t option -> unit tactic) -> unit tactic
156 val onClause : (Id.t option -> unit tactic) -> clause -> unit tactic
157
158 val onAllHyps : (Id.t -> unit tactic) -> unit tactic
159 val onAllHypsAndConcl : (Id.t option -> unit tactic) -> unit tactic
160
161 val elimination_sort_of_goal : Proofview.Goal.t -> UnivGen.QualityOrSet.t
162 [@@ocaml.deprecated "(9.2) Use Retyping.get_sort_quality_of"]
163 val elimination_sort_of_hyp : Id.t -> Proofview.Goal.t -> UnivGen.QualityOrSet.t
164 [@@ocaml.deprecated "(9.2) Use Retyping.get_sort_quality_of"]
165 val elimination_sort_of_clause : Id.t option -> Proofview.Goal.t -> UnivGen.QualityOrSet.t
166 [@@ocaml.deprecated "(9.2) Use Retyping.get_sort_quality_of"]
167
168 val pf_constr_of_global : GlobRef.t -> constr Proofview.tactic
169
170 val tclTYPEOFTHEN : ?refresh:bool -> constr -> (evar_map -> types -> unit Proofview.tactic) -> unit Proofview.tactic
171
172 (** {6 Elimination tacticals. } *)
173
174 (** [get_and_check_or_and_pattern loc pats branchsign] returns an appropriate
175 error message if |pats| <> |branchsign|; extends them if no pattern is given
176 for let-ins in the case of a conjunctive pattern *)
177 val get_and_check_or_and_pattern :
178 ?loc:Loc.t -> delayed_open_constr or_and_intro_pattern_expr ->
179 bool list array -> intro_patterns array
180
181 (** Tolerate "[]" to mean a disjunctive pattern of any length *)
182 val fix_empty_or_and_pattern : int ->
183 delayed_open_constr or_and_intro_pattern_expr ->
184 delayed_open_constr or_and_intro_pattern_expr
185
186 val compute_constructor_signatures : Environ.env -> rec_flag:bool -> inductive * 'a -> bool list array
187
188 (** Useful for [as intro_pattern] modifier *)
189 val compute_induction_names :
190 bool -> bool list array -> or_and_intro_pattern option -> intro_patterns array