Debian Codegraph @

proofs/proof.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 (* Module defining the last essential tiles of interactive proofs.
12 A proof deals with the focusing commands (including the braces and bullets),
13 the shelf (see the [shelve] tactic) and given up goal (see the [give_up]
14 tactic). A proof is made of the following:
15 - Proofview: a proof is primarily the data of the current view.
16 That which is shown to the user (as a remainder, a proofview
17 is mainly the logical state of the proof, together with the
18 currently focused goals).
19 - Focus: a proof has a focus stack: the top of the stack contains
20 the context in which to unfocus the current view to a view focused
21 with the rest of the stack.
22 In addition, this contains, for each of the focus context, a
23 "focus kind" and a "focus condition" (in practice, and for modularity,
24 the focus kind is actually stored inside the condition). To unfocus, one
25 needs to know the focus kind, and the condition (for instance "no condition" or
26 the proof under focused must be complete) must be met.
27 - Shelf: A list of goals which have been put aside during the proof. They can be
28 retrieved with the [Unshelve] command, or solved by side effects
29 - Given up goals: as long as there is a given up goal, the proof is not completed.
30 Given up goals cannot be retrieved, the user must go back where the tactic
31 [give_up] was run and solve the goal there.
32 *)
33
34 (* Type of a proof. *)
35 type t
36
37 type data = private
38 { sigma : Evd.evar_map
39 (** A representation of the evar_map [EJGA wouldn't it better to just return the proofview?] *)
40 ; goals : Evar.t list
41 (** Focused goals *)
42 ; entry : Proofview.entry
43 (** Entry for the proofview *)
44 ; stack : (Evar.t list * Evar.t list) list
45 (** A representation of the focus stack *)
46 ; name : Names.Id.t
47 (** The name of the theorem whose proof is being constructed *)
48 ; poly : PolyFlags.t
49 (** Universe polymorphism *)
50 }
51
52 val data : t -> data
53
54 (*** General proof functions ***)
55 val start
56 : name:Names.Id.t
57 -> poly:PolyFlags.t
58 -> ?typing_flags:Declarations.typing_flags
59 -> Evd.evar_map -> (Environ.env * EConstr.types) list -> t
60
61 val dependent_start
62 : name:Names.Id.t
63 -> poly:PolyFlags.t
64 -> ?typing_flags:Declarations.typing_flags
65 -> Proofview.telescope -> t
66
67 (* Returns [true] if the considered proof is completed, that is if no goal remain
68 to be considered (this does not require that all evars have been solved). *)
69 val is_done : t -> bool
70
71 (* Returns the list of partial proofs to initial goals. *)
72 val partial_proof : t -> EConstr.constr list
73
74 val compact : t -> t
75
76 (** [update_sigma_univs] lifts [UState.update_sigma_univs] to the proof *)
77 val update_sigma_univs : UGraph.t -> t -> t
78
79 (*** Focusing actions ***)
80
81 (* ['a focus_kind] is the type used by focusing and unfocusing
82 commands to synchronise. Focusing and unfocusing commands use
83 a particular ['a focus_kind], and if they don't match, the unfocusing command
84 will fail.
85 When focusing with an ['a focus_kind], an information of type ['a] is
86 stored at the focusing point. An example use is the "induction" tactic
87 of the declarative mode where sub-tactics must be aware of the current
88 induction argument. *)
89 type 'a focus_kind
90 val new_focus_kind : string -> 'a focus_kind
91
92 (* To be authorized to unfocus one must meet the condition prescribed by
93 the action which focused.
94 Conditions always carry a focus kind, and inherit their type parameter
95 from it.*)
96 type 'a focus_condition
97 (* [no_cond] only checks that the unfocusing command uses the right
98 [focus_kind].
99 If [loose_end] (default [false]) is [true], then if the [focus_kind]
100 doesn't match, then unfocusing can occur, provided it unfocuses
101 an earlier focus.
102 For instance bullets can be unfocused in the following situation
103 [{- solve_goal. }] because they use a loose-end condition. *)
104 val no_cond : ?loose_end:bool -> 'a focus_kind -> 'a focus_condition
105 (* [done_cond] checks that the unfocusing command uses the right [focus_kind]
106 and that the focused proofview is complete.
107 If [loose_end] (default [false]) is [true], then if the [focus_kind]
108 doesn't match, then unfocusing can occur, provided it unfocuses
109 an earlier focus.
110 For instance bullets can be unfocused in the following situation
111 [{ - solve_goal. }] because they use a loose-end condition. *)
112 val done_cond : ?loose_end:bool -> 'a focus_kind -> 'a focus_condition
113
114 (* focus command (focuses on the [i]th subgoal) *)
115 (* spiwack: there could also, easily be a focus-on-a-range tactic, is there
116 a need for it? *)
117 val focus : 'a focus_condition -> 'a -> int -> t -> t
118
119 (* focus on goal named id *)
120 val focus_id : 'a focus_condition -> 'a -> Libnames.qualid -> t -> t
121
122 exception FullyUnfocused
123 exception CannotUnfocusThisWay
124
125 (* This is raised when trying to focus on non-existing subgoals. It is
126 handled by an error message but one may need to catch it and
127 settle a better error message in some case (suggesting a better
128 bullet for example), see proof_global.ml function Bullet.pop and
129 Bullet.push. *)
130 exception NoSuchGoals of int * int
131
132 exception NoSuchGoal of Libnames.qualid option
133
134 (* Unfocusing command.
135 Raises [FullyUnfocused] if the proof is not focused.
136 Raises [CannotUnfocusThisWay] if the proof the unfocusing condition
137 is not met. *)
138 val unfocus : 'a focus_kind -> t -> unit -> t
139
140 (* [unfocused p] returns [true] when [p] is fully unfocused. *)
141 val unfocused : t -> bool
142
143 (** Unfocus everything (fail if no allowed). *)
144 val unfocus_all : t -> t
145
146 (* [get_at_focus k] gets the information stored at the closest focus point
147 of kind [k].
148 Raises [NoSuchFocus] if there is no focus point of kind [k]. *)
149 exception NoSuchFocus
150 val get_at_focus : 'a focus_kind -> t -> 'a
151
152 (* [is_last_focus k] check if the most recent focus is of kind [k] *)
153 val is_last_focus : 'a focus_kind -> t -> bool
154
155 (* returns [true] if there is no goal under focus. *)
156 val no_focused_goal : t -> bool
157
158 (*** Tactics ***)
159
160 (* the returned boolean signal whether an unsafe tactic has been
161 used. In which case it is [false]. *)
162 val run_tactic
163 : Environ.env
164 -> 'a Proofview.tactic -> t -> t * (Environ.env*bool*Proofview_monad.Info.tree) * 'a
165
166 val maximal_unfocus : 'a focus_kind -> t -> t
167
168 (*** Commands ***)
169
170 (* Remove all the goals from the shelf and adds them at the end of the
171 focused goals. *)
172 val unshelve : t -> t
173
174 (* Gives a unique identifier to each goal. The identifier is
175 guaranteed to contain no space. *)
176 val goal_uid : Evar.t -> string
177
178 val pr_proof : t -> Pp.t
179
180 (* All the subgoals of the proof, including those which are not focused. *)
181 val background_subgoals : t -> Evar.t list
182
183 (* returns the set of all goals in the proof *)
184 val all_goals : t -> Evar.Set.t
185
186 (** [solve (select_nth n) tac] applies tactic [tac] to the [n]th
187 subgoal of the current focused proof. [solve SelectAll
188 tac] applies [tac] to all subgoals. *)
189
190 val solve :
191 ?with_end_tac:unit Proofview.tactic
192 -> Environ.env
193 -> Goal_select.t
194 -> int option
195 -> unit Proofview.tactic
196 -> t
197 -> t * bool
198
199 (** Option telling if unification heuristics should be used. *)
200 val use_unification_heuristics : unit -> bool
201
202 exception SuggestNoSuchGoals of int * t
203
204 (** {6 Helpers to obtain proof state when in an interactive proof } *)
205 val get_goal_context_gen : t -> int -> Evd.evar_map * Environ.env
206
207 (** [get_proof_context ()] gets the goal context for the first subgoal
208 of the proof *)
209 val get_proof_context : t -> Evd.evar_map * Environ.env
210
211 val purge_side_effects : t -> t * Evd.side_effects