Skip to content

Commit f7fb191

Browse files
committed
Putting all the tactics exported by the Tactics module in the new monad API.
2 parents cead0ce + dadd400 commit f7fb191

31 files changed

+428
-451
lines changed

ltac/coretactics.ml4

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ TACTIC EXTEND cut
3939
END
4040

4141
TACTIC EXTEND exact_no_check
42-
[ "exact_no_check" constr(c) ] -> [ Proofview.V82.tactic (Tactics.exact_no_check c) ]
42+
[ "exact_no_check" constr(c) ] -> [ Tactics.exact_no_check c ]
4343
END
4444

4545
TACTIC EXTEND vm_cast_no_check
46-
[ "vm_cast_no_check" constr(c) ] -> [ Proofview.V82.tactic (Tactics.vm_cast_no_check c) ]
46+
[ "vm_cast_no_check" constr(c) ] -> [ Tactics.vm_cast_no_check c ]
4747
END
4848

4949
TACTIC EXTEND native_cast_no_check
50-
[ "native_cast_no_check" constr(c) ] -> [ Proofview.V82.tactic (Tactics.native_cast_no_check c) ]
50+
[ "native_cast_no_check" constr(c) ] -> [ Tactics.native_cast_no_check c ]
5151
END
5252

5353
TACTIC EXTEND casetype
@@ -200,10 +200,10 @@ END
200200
(** Move *)
201201

202202
TACTIC EXTEND move
203-
[ "move" hyp(id) "at" "top" ] -> [ Proofview.V82.tactic (Tactics.move_hyp id MoveFirst) ]
204-
| [ "move" hyp(id) "at" "bottom" ] -> [ Proofview.V82.tactic (Tactics.move_hyp id MoveLast) ]
205-
| [ "move" hyp(id) "after" hyp(h) ] -> [ Proofview.V82.tactic (Tactics.move_hyp id (MoveAfter h)) ]
206-
| [ "move" hyp(id) "before" hyp(h) ] -> [ Proofview.V82.tactic (Tactics.move_hyp id (MoveBefore h)) ]
203+
[ "move" hyp(id) "at" "top" ] -> [ Tactics.move_hyp id MoveFirst ]
204+
| [ "move" hyp(id) "at" "bottom" ] -> [ Tactics.move_hyp id MoveLast ]
205+
| [ "move" hyp(id) "after" hyp(h) ] -> [ Tactics.move_hyp id (MoveAfter h) ]
206+
| [ "move" hyp(id) "before" hyp(h) ] -> [ Tactics.move_hyp id (MoveBefore h) ]
207207
END
208208

209209
(** Revert *)
@@ -231,23 +231,23 @@ END
231231
(* Fix *)
232232

233233
TACTIC EXTEND fix
234-
[ "fix" natural(n) ] -> [ Proofview.V82.tactic (Tactics.fix None n) ]
235-
| [ "fix" ident(id) natural(n) ] -> [ Proofview.V82.tactic (Tactics.fix (Some id) n) ]
234+
[ "fix" natural(n) ] -> [ Tactics.fix None n ]
235+
| [ "fix" ident(id) natural(n) ] -> [ Tactics.fix (Some id) n ]
236236
END
237237

238238
(* Cofix *)
239239

240240
TACTIC EXTEND cofix
241-
[ "cofix" ] -> [ Proofview.V82.tactic (Tactics.cofix None) ]
242-
| [ "cofix" ident(id) ] -> [ Proofview.V82.tactic (Tactics.cofix (Some id)) ]
241+
[ "cofix" ] -> [ Tactics.cofix None ]
242+
| [ "cofix" ident(id) ] -> [ Tactics.cofix (Some id) ]
243243
END
244244

245245
(* Clear *)
246246

247247
TACTIC EXTEND clear
248248
[ "clear" hyp_list(ids) ] -> [
249249
if List.is_empty ids then Tactics.keep []
250-
else Proofview.V82.tactic (Tactics.clear ids)
250+
else Tactics.clear ids
251251
]
252252
| [ "clear" "-" ne_hyp_list(ids) ] -> [ Tactics.keep ids ]
253253
END
@@ -261,7 +261,7 @@ END
261261
(* Generalize dependent *)
262262

263263
TACTIC EXTEND generalize_dependent
264-
[ "generalize" "dependent" constr(c) ] -> [ Proofview.V82.tactic (Tactics.generalize_dep c) ]
264+
[ "generalize" "dependent" constr(c) ] -> [ Tactics.generalize_dep c ]
265265
END
266266

267267
(* Table of "pervasives" macros tactics (e.g. auto, simpl, etc.) *)

ltac/extratactics.ml4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ END
582582
during dependent induction. For internal use. *)
583583

584584
TACTIC EXTEND specialize_eqs
585-
[ "specialize_eqs" hyp(id) ] -> [ Proofview.V82.tactic (specialize_eqs id) ]
585+
[ "specialize_eqs" hyp(id) ] -> [ specialize_eqs id ]
586586
END
587587

588588
(**********************************************************************)
@@ -728,7 +728,7 @@ let mkCaseEq a : unit Proofview.tactic =
728728
Proofview.Goal.nf_enter { enter = begin fun gl ->
729729
let type_of_a = Tacmach.New.of_old (fun g -> Tacmach.pf_unsafe_type_of g a) gl in
730730
Tacticals.New.tclTHENLIST
731-
[Proofview.V82.tactic (Tactics.generalize [mkApp(delayed_force refl_equal, [| type_of_a; a|])]);
731+
[Tactics.generalize [mkApp(delayed_force refl_equal, [| type_of_a; a|])];
732732
Proofview.Goal.nf_enter { enter = begin fun gl ->
733733
let concl = Proofview.Goal.concl gl in
734734
let env = Proofview.Goal.env gl in

ltac/tacinterp.ml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ and interp_atomic ist tac : unit Proofview.tactic =
16591659
Proofview.Trace.name_tactic (fun () -> Pp.str"<exact>") begin
16601660
Proofview.Goal.nf_s_enter { s_enter = begin fun gl ->
16611661
let (sigma, c_interp) = pf_interp_casted_constr ist gl c in
1662-
Sigma.Unsafe.of_pair (Proofview.V82.tactic (Tactics.exact_no_check c_interp), sigma)
1662+
Sigma.Unsafe.of_pair (Tactics.exact_no_check c_interp, sigma)
16631663
end }
16641664
end
16651665
| TacApply (a,ev,cb,cl) ->
@@ -1714,7 +1714,7 @@ and interp_atomic ist tac : unit Proofview.tactic =
17141714
let (sigma,l_interp) =
17151715
Evd.MonadR.List.map_right (fun c sigma -> f sigma c) l (project gl)
17161716
in
1717-
let tac = Proofview.V82.tactic (Tactics.mutual_fix (interp_ident ist env sigma id) n l_interp 0) in
1717+
let tac = Tactics.mutual_fix (interp_ident ist env sigma id) n l_interp 0 in
17181718
Sigma.Unsafe.of_pair (tac, sigma)
17191719
end }
17201720
end
@@ -1729,7 +1729,7 @@ and interp_atomic ist tac : unit Proofview.tactic =
17291729
let (sigma,l_interp) =
17301730
Evd.MonadR.List.map_right (fun c sigma -> f sigma c) l (project gl)
17311731
in
1732-
let tac = Proofview.V82.tactic (Tactics.mutual_cofix (interp_ident ist env sigma id) l_interp 0) in
1732+
let tac = Tactics.mutual_cofix (interp_ident ist env sigma id) l_interp 0 in
17331733
Sigma.Unsafe.of_pair (tac, sigma)
17341734
end }
17351735
end
@@ -1755,7 +1755,7 @@ and interp_atomic ist tac : unit Proofview.tactic =
17551755
Tacticals.New.tclWITHHOLES false
17561756
(name_atomic ~env
17571757
(TacGeneralize cl)
1758-
(Proofview.V82.tactic (Tactics.generalize_gen cl))) sigma
1758+
(Tactics.generalize_gen cl)) sigma
17591759
end }
17601760
| TacLetTac (na,c,clp,b,eqpat) ->
17611761
Proofview.V82.nf_evar_goals <*>
@@ -1879,7 +1879,7 @@ and interp_atomic ist tac : unit Proofview.tactic =
18791879
in
18801880
Sigma.Unsafe.of_pair (c, sigma)
18811881
end } in
1882-
Proofview.V82.tactic (Tactics.change None c_interp (interp_clause ist (pf_env gl) (project gl) cl))
1882+
Tactics.change None c_interp (interp_clause ist (pf_env gl) (project gl) cl)
18831883
end }
18841884
end
18851885
| TacChange (Some op,c,cl) ->
@@ -1889,25 +1889,22 @@ and interp_atomic ist tac : unit Proofview.tactic =
18891889
Proofview.Goal.enter { enter = begin fun gl ->
18901890
let env = Proofview.Goal.env gl in
18911891
let sigma = project gl in
1892-
Proofview.V82.tactic begin fun gl ->
1893-
let op = interp_typed_pattern ist env sigma op in
1894-
let to_catch = function Not_found -> true | e -> Errors.is_anomaly e in
1895-
let c_interp patvars = { Sigma.run = begin fun sigma ->
1896-
let lfun' = Id.Map.fold (fun id c lfun ->
1897-
Id.Map.add id (Value.of_constr c) lfun)
1898-
patvars ist.lfun
1899-
in
1900-
let ist = { ist with lfun = lfun' } in
1901-
try
1902-
let sigma = Sigma.to_evar_map sigma in
1903-
let (sigma, c) = interp_constr ist env sigma c in
1904-
Sigma.Unsafe.of_pair (c, sigma)
1905-
with e when to_catch e (* Hack *) ->
1906-
errorlabstrm "" (strbrk "Failed to get enough information from the left-hand side to type the right-hand side.")
1907-
end } in
1908-
(Tactics.change (Some op) c_interp (interp_clause ist env sigma cl))
1909-
gl
1910-
end
1892+
let op = interp_typed_pattern ist env sigma op in
1893+
let to_catch = function Not_found -> true | e -> Errors.is_anomaly e in
1894+
let c_interp patvars = { Sigma.run = begin fun sigma ->
1895+
let lfun' = Id.Map.fold (fun id c lfun ->
1896+
Id.Map.add id (Value.of_constr c) lfun)
1897+
patvars ist.lfun
1898+
in
1899+
let ist = { ist with lfun = lfun' } in
1900+
try
1901+
let sigma = Sigma.to_evar_map sigma in
1902+
let (sigma, c) = interp_constr ist env sigma c in
1903+
Sigma.Unsafe.of_pair (c, sigma)
1904+
with e when to_catch e (* Hack *) ->
1905+
errorlabstrm "" (strbrk "Failed to get enough information from the left-hand side to type the right-hand side.")
1906+
end } in
1907+
Tactics.change (Some op) c_interp (interp_clause ist env sigma cl)
19111908
end }
19121909
end
19131910

ltac/tauto.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ let assert_ ?by c =
102102

103103
let apply c = Tactics.apply c
104104

105-
let clear id = Proofview.V82.tactic (fun gl -> Tactics.clear [id] gl)
105+
let clear id = Tactics.clear [id]
106106

107107
let assumption = Tactics.assumption
108108

plugins/decl_mode/decl_proof_instr.ml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ open Context.Named.Declaration
3434

3535
(* Strictness option *)
3636

37+
let clear ids { it = goal; sigma } =
38+
let ids = List.fold_left (fun accu x -> Id.Set.add x accu) Id.Set.empty ids in
39+
let env = Goal.V82.env sigma goal in
40+
let sign = Goal.V82.hyps sigma goal in
41+
let cl = Goal.V82.concl sigma goal in
42+
let evdref = ref (Evd.clear_metas sigma) in
43+
let (hyps, concl) =
44+
try Evarutil.clear_hyps_in_evi env evdref sign cl ids
45+
with Evarutil.ClearDependencyError (id, _) ->
46+
errorlabstrm "" (str "Cannot clear " ++ pr_id id)
47+
in
48+
let sigma = !evdref in
49+
let (gl,ev,sigma) = Goal.V82.mk_goal sigma hyps concl (Goal.V82.extra sigma goal) in
50+
let sigma = Goal.V82.partial_solution_to sigma goal gl ev in
51+
{ it = [gl]; sigma }
52+
3753
let get_its_info gls = get_info gls.sigma gls.it
3854

3955
let get_strictness,set_strictness =
@@ -469,7 +485,7 @@ let thus_tac c ctyp submetas gls =
469485
Proofview.V82.of_tactic (exact_check proof) gls
470486
else
471487
let refiner = concl_refiner list proof gls in
472-
Tactics.refine refiner gls
488+
Tacmach.refine refiner gls
473489

474490
(* general forward step *)
475491

@@ -1273,7 +1289,7 @@ let rec execute_cases fix_name per_info tacnext args objs nhrec tree gls =
12731289
(fun id ->
12741290
hrec_for (out_name fix_name) per_info gls1 id)
12751291
recs in
1276-
generalize hrecs gls1
1292+
Proofview.V82.of_tactic (generalize hrecs) gls1
12771293
end;
12781294
match bro with
12791295
None ->
@@ -1349,7 +1365,7 @@ let end_tac et2 gls =
13491365
(default_justification (List.map mkVar clauses))
13501366
| ET_Induction,EK_nodep ->
13511367
tclTHENLIST
1352-
[generalize (pi.per_args@[pi.per_casee]);
1368+
[Proofview.V82.of_tactic (generalize (pi.per_args@[pi.per_casee]));
13531369
Proofview.V82.of_tactic (simple_induct (AnonHyp (succ (List.length pi.per_args))));
13541370
default_justification (List.map mkVar clauses)]
13551371
| ET_Case_analysis,EK_dep tree ->
@@ -1361,15 +1377,15 @@ let end_tac et2 gls =
13611377
(initial_instance_stack clauses) [pi.per_casee] 0 tree
13621378
| ET_Induction,EK_dep tree ->
13631379
let nargs = (List.length pi.per_args) in
1364-
tclTHEN (generalize (pi.per_args@[pi.per_casee]))
1380+
tclTHEN (Proofview.V82.of_tactic (generalize (pi.per_args@[pi.per_casee])))
13651381
begin
13661382
fun gls0 ->
13671383
let fix_id =
13681384
pf_get_new_id (Id.of_string "_fix") gls0 in
13691385
let c_id =
13701386
pf_get_new_id (Id.of_string "_main_arg") gls0 in
13711387
tclTHENLIST
1372-
[fix (Some fix_id) (succ nargs);
1388+
[Proofview.V82.of_tactic (fix (Some fix_id) (succ nargs));
13731389
tclDO nargs (Proofview.V82.of_tactic introf);
13741390
Proofview.V82.of_tactic (intro_mustbe_force c_id);
13751391
execute_cases (Name fix_id) pi

plugins/firstorder/instances.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ let left_instance_tac (inst,id) continue seq=
135135
[tclTHENLIST
136136
[Proofview.V82.of_tactic introf;
137137
pf_constr_of_global id (fun idc ->
138-
(fun gls->generalize
138+
(fun gls-> Proofview.V82.of_tactic (generalize
139139
[mkApp(idc,
140-
[|mkVar (Tacmach.pf_nth_hyp_id gls 1)|])] gls));
140+
[|mkVar (Tacmach.pf_nth_hyp_id gls 1)|])]) gls));
141141
Proofview.V82.of_tactic introf;
142142
tclSOLVE [wrap 1 false continue
143143
(deepen (record (id,None) seq))]];
@@ -158,10 +158,10 @@ let left_instance_tac (inst,id) continue seq=
158158
try Typing.type_of (pf_env gl) evmap gt
159159
with e when Errors.noncritical e ->
160160
error "Untypable instance, maybe higher-order non-prenex quantification" in
161-
tclTHEN (Refiner.tclEVARS evmap) (generalize [gt]) gl)
161+
tclTHEN (Refiner.tclEVARS evmap) (Proofview.V82.of_tactic (generalize [gt])) gl)
162162
else
163163
pf_constr_of_global id (fun idc ->
164-
generalize [mkApp(idc,[|t|])])
164+
Proofview.V82.of_tactic (generalize [mkApp(idc,[|t|])]))
165165
in
166166
tclTHENLIST
167167
[special_generalize;

plugins/firstorder/rules.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ let basename_of_global=function
5252
| _->assert false
5353

5454
let clear_global=function
55-
VarRef id->clear [id]
55+
VarRef id-> Proofview.V82.of_tactic (clear [id])
5656
| _->tclIDTAC
5757

5858
(* connection rules *)
5959

6060
let axiom_tac t seq=
61-
try pf_constr_of_global (find_left t seq) exact_no_check
61+
try pf_constr_of_global (find_left t seq) (fun c -> Proofview.V82.of_tactic (exact_no_check c))
6262
with Not_found->tclFAIL 0 (Pp.str "No axiom link")
6363

6464
let ll_atom_tac a backtrack id continue seq=
@@ -67,7 +67,7 @@ let ll_atom_tac a backtrack id continue seq=
6767
tclTHENLIST
6868
[pf_constr_of_global (find_left a seq) (fun left ->
6969
pf_constr_of_global id (fun id ->
70-
generalize [mkApp(id, [|left|])]));
70+
Proofview.V82.of_tactic (generalize [mkApp(id, [|left|])])));
7171
clear_global id;
7272
Proofview.V82.of_tactic intro]
7373
with Not_found->tclFAIL 0 (Pp.str "No link"))
@@ -135,7 +135,7 @@ let ll_ind_tac (ind,u as indu) largs backtrack id continue seq gl=
135135
let newhyps idc =List.init lp (myterm idc) in
136136
tclIFTHENELSE
137137
(tclTHENLIST
138-
[pf_constr_of_global id (fun idc -> generalize (newhyps idc));
138+
[pf_constr_of_global id (fun idc -> Proofview.V82.of_tactic (generalize (newhyps idc)));
139139
clear_global id;
140140
tclDO lp (Proofview.V82.of_tactic intro)])
141141
(wrap lp false continue seq) backtrack gl
@@ -151,9 +151,9 @@ let ll_arrow_tac a b c backtrack id continue seq=
151151
clear_global id;
152152
wrap 1 false continue seq];
153153
tclTHENS (Proofview.V82.of_tactic (cut cc))
154-
[pf_constr_of_global id exact_no_check;
154+
[pf_constr_of_global id (fun c -> Proofview.V82.of_tactic (exact_no_check c));
155155
tclTHENLIST
156-
[pf_constr_of_global id (fun idc -> generalize [d idc]);
156+
[pf_constr_of_global id (fun idc -> Proofview.V82.of_tactic (generalize [d idc]));
157157
clear_global id;
158158
Proofview.V82.of_tactic introf;
159159
Proofview.V82.of_tactic introf;
@@ -192,7 +192,7 @@ let ll_forall_tac prod backtrack id continue seq=
192192
(fun gls->
193193
let id0=pf_nth_hyp_id gls 1 in
194194
let term=mkApp(idc,[|mkVar(id0)|]) in
195-
tclTHEN (generalize [term]) (clear [id0]) gls));
195+
tclTHEN (Proofview.V82.of_tactic (generalize [term])) (Proofview.V82.of_tactic (clear [id0])) gls));
196196
clear_global id;
197197
Proofview.V82.of_tactic intro;
198198
tclCOMPLETE (wrap 1 false continue (deepen seq))];

0 commit comments

Comments
 (0)