Skip to content

Commit 1c67e29

Browse files
committed
Merge PR rocq-prover#7004: Make simple apply obey Opaque directive.
2 parents 03a18dc + d28c22a commit 1c67e29

File tree

5 files changed

+43
-25
lines changed

5 files changed

+43
-25
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Tactics
2525

2626
- Deprecated the Implicit Tactic family of commands.
2727

28+
- The `simple apply` tactic now respects the `Opaque` flag when called from
29+
Ltac (`auto` still does not respect it).
30+
2831
Tools
2932

3033
- Coq_makefile lets one override or extend the following variables from

plugins/ssrmatching/ssrmatching.ml4

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,20 +312,22 @@ let unif_HO_args env ise0 pa i ca =
312312
(* for HO evars, though hopefully Miller patterns can pick up some of *)
313313
(* those cases, and HO matching will mop up the rest. *)
314314
let flags_FO env =
315+
let oracle = Environ.oracle env in
316+
let ts = Conv_oracle.get_transp_state oracle in
315317
let flags =
316-
{ (Unification.default_no_delta_unify_flags ()).Unification.core_unify_flags
318+
{ (Unification.default_no_delta_unify_flags ts).Unification.core_unify_flags
317319
with
318320
Unification.modulo_conv_on_closed_terms = None;
319321
Unification.modulo_eta = true;
320322
Unification.modulo_betaiota = true;
321-
Unification.modulo_delta_types = Conv_oracle.get_transp_state (Environ.oracle env)}
323+
Unification.modulo_delta_types = ts }
322324
in
323325
{ Unification.core_unify_flags = flags;
324326
Unification.merge_unify_flags = flags;
325327
Unification.subterm_unify_flags = flags;
326328
Unification.allow_K_in_toplevel_higher_order_unification = false;
327329
Unification.resolve_evars =
328-
(Unification.default_no_delta_unify_flags ()).Unification.resolve_evars
330+
(Unification.default_no_delta_unify_flags ts).Unification.resolve_evars
329331
}
330332
let unif_FO env ise p c =
331333
Unification.w_unify env ise Reduction.CONV ~flags:(flags_FO env)

pretyping/unification.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,13 @@ let default_no_delta_core_unify_flags () = { (default_core_unify_flags ()) with
398398
modulo_betaiota = false;
399399
}
400400

401-
let default_no_delta_unify_flags () =
402-
let flags = default_no_delta_core_unify_flags () in {
401+
let default_no_delta_unify_flags ts =
402+
let flags = default_no_delta_core_unify_flags () in
403+
let flags = { flags with
404+
modulo_conv_on_closed_terms = Some ts;
405+
modulo_delta_types = ts
406+
} in
407+
{
403408
core_unify_flags = flags;
404409
merge_unify_flags = flags;
405410
subterm_unify_flags = flags;

pretyping/unification.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
(* * (see LICENSE file for the text of the license) *)
99
(************************************************************************)
1010

11+
open Names
1112
open Constr
1213
open EConstr
1314
open Environ
@@ -40,7 +41,7 @@ val default_core_unify_flags : unit -> core_unify_flags
4041
val default_no_delta_core_unify_flags : unit -> core_unify_flags
4142

4243
val default_unify_flags : unit -> unify_flags
43-
val default_no_delta_unify_flags : unit -> unify_flags
44+
val default_no_delta_unify_flags : transparent_state -> unify_flags
4445

4546
val elim_flags : unit -> unify_flags
4647
val elim_no_delta_flags : unit -> unify_flags

tactics/tactics.ml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,13 +1637,11 @@ let tclORELSEOPT t k =
16371637
Proofview.tclZERO ~info e
16381638
| Some tac -> tac)
16391639

1640-
let general_apply with_delta with_destruct with_evars clear_flag
1641-
{CAst.loc;v=(c,lbind : EConstr.constr with_bindings)} =
1640+
let general_apply ?(respect_opaque=false) with_delta with_destruct with_evars
1641+
clear_flag {CAst.loc;v=(c,lbind : EConstr.constr with_bindings)} =
16421642
Proofview.Goal.enter begin fun gl ->
16431643
let concl = Proofview.Goal.concl gl in
16441644
let sigma = Tacmach.New.project gl in
1645-
let flags =
1646-
if with_delta then default_unify_flags () else default_no_delta_unify_flags () in
16471645
(* The actual type of the theorem. It will be matched against the
16481646
goal. If this fails, then the head constant will be unfolded step by
16491647
step. *)
@@ -1652,7 +1650,12 @@ let general_apply with_delta with_destruct with_evars clear_flag
16521650
Proofview.Goal.enter begin fun gl ->
16531651
let env = Proofview.Goal.env gl in
16541652
let sigma = Tacmach.New.project gl in
1655-
1653+
let ts =
1654+
if respect_opaque then Conv_oracle.get_transp_state (oracle env)
1655+
else full_transparent_state
1656+
in
1657+
let flags =
1658+
if with_delta then default_unify_flags () else default_no_delta_unify_flags ts in
16561659
let thm_ty0 = nf_betaiota env sigma (Retyping.get_type_of env sigma c) in
16571660
let try_apply thm_ty nprod =
16581661
try
@@ -1718,14 +1721,14 @@ let rec apply_with_bindings_gen b e = function
17181721
(general_apply b b e k cb)
17191722
(apply_with_bindings_gen b e cbl)
17201723

1721-
let apply_with_delayed_bindings_gen b e l =
1724+
let apply_with_delayed_bindings_gen b e l =
17221725
let one k {CAst.loc;v=f} =
17231726
Proofview.Goal.enter begin fun gl ->
17241727
let sigma = Tacmach.New.project gl in
17251728
let env = Proofview.Goal.env gl in
17261729
let (sigma, cb) = f env sigma in
17271730
Tacticals.New.tclWITHHOLES e
1728-
(general_apply b b e k CAst.(make ?loc cb)) sigma
1731+
(general_apply ~respect_opaque:(not b) b b e k CAst.(make ?loc cb)) sigma
17291732
end
17301733
in
17311734
let rec aux = function
@@ -1800,21 +1803,25 @@ let apply_in_once_main flags innerclause env sigma (loc,d,lbind) =
18001803
in
18011804
aux (make_clenv_binding env sigma (d,thm) lbind)
18021805

1803-
let apply_in_once sidecond_first with_delta with_destruct with_evars naming
1804-
id (clear_flag,{ CAst.loc; v= d,lbind}) tac =
1806+
let apply_in_once ?(respect_opaque = false) sidecond_first with_delta
1807+
with_destruct with_evars naming id (clear_flag,{ CAst.loc; v= d,lbind}) tac =
18051808
let open Context.Rel.Declaration in
18061809
Proofview.Goal.enter begin fun gl ->
18071810
let env = Proofview.Goal.env gl in
18081811
let sigma = Tacmach.New.project gl in
1809-
let flags =
1810-
if with_delta then default_unify_flags () else default_no_delta_unify_flags () in
18111812
let t' = Tacmach.New.pf_get_hyp_typ id gl in
18121813
let innerclause = mk_clenv_from_env env sigma (Some 0) (mkVar id,t') in
18131814
let targetid = find_name true (LocalAssum (Anonymous,t')) naming gl in
18141815
let rec aux idstoclear with_destruct c =
18151816
Proofview.Goal.enter begin fun gl ->
18161817
let env = Proofview.Goal.env gl in
18171818
let sigma = Tacmach.New.project gl in
1819+
let ts =
1820+
if respect_opaque then Conv_oracle.get_transp_state (oracle env)
1821+
else full_transparent_state
1822+
in
1823+
let flags =
1824+
if with_delta then default_unify_flags () else default_no_delta_unify_flags ts in
18181825
try
18191826
let clause = apply_in_once_main flags innerclause env sigma (loc,c,lbind) in
18201827
clenv_refine_in ~sidecond_first with_evars targetid id sigma clause
@@ -1834,14 +1841,14 @@ let apply_in_once sidecond_first with_delta with_destruct with_evars naming
18341841
aux [] with_destruct d
18351842
end
18361843

1837-
let apply_in_delayed_once sidecond_first with_delta with_destruct with_evars naming
1838-
id (clear_flag,{CAst.loc;v=f}) tac =
1844+
let apply_in_delayed_once ?(respect_opaque = false) sidecond_first with_delta
1845+
with_destruct with_evars naming id (clear_flag,{CAst.loc;v=f}) tac =
18391846
Proofview.Goal.enter begin fun gl ->
18401847
let env = Proofview.Goal.env gl in
18411848
let sigma = Tacmach.New.project gl in
18421849
let (sigma, c) = f env sigma in
18431850
Tacticals.New.tclWITHHOLES with_evars
1844-
(apply_in_once sidecond_first with_delta with_destruct with_evars
1851+
(apply_in_once ~respect_opaque sidecond_first with_delta with_destruct with_evars
18451852
naming id (clear_flag,CAst.(make ?loc c)) tac)
18461853
sigma
18471854
end
@@ -2531,11 +2538,11 @@ let assert_as first hd ipat t =
25312538

25322539
(* apply in as *)
25332540

2534-
let general_apply_in sidecond_first with_delta with_destruct with_evars
2535-
id lemmas ipat =
2541+
let general_apply_in ?(respect_opaque=false) sidecond_first with_delta
2542+
with_destruct with_evars id lemmas ipat =
25362543
let tac (naming,lemma) tac id =
2537-
apply_in_delayed_once sidecond_first with_delta with_destruct with_evars
2538-
naming id lemma tac in
2544+
apply_in_delayed_once ~respect_opaque sidecond_first with_delta
2545+
with_destruct with_evars naming id lemma tac in
25392546
Proofview.Goal.enter begin fun gl ->
25402547
let destopt =
25412548
if with_evars then MoveLast (* evars would depend on the whole context *)
@@ -2566,7 +2573,7 @@ let apply_in simple with_evars id lemmas ipat =
25662573
general_apply_in false simple simple with_evars id lemmas ipat
25672574

25682575
let apply_delayed_in simple with_evars id lemmas ipat =
2569-
general_apply_in false simple simple with_evars id lemmas ipat
2576+
general_apply_in ~respect_opaque:true false simple simple with_evars id lemmas ipat
25702577

25712578
(*****************************)
25722579
(* Tactics abstracting terms *)

0 commit comments

Comments
 (0)