aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Herbelin2014-11-03 20:20:35 +0100
committerHugo Herbelin2014-11-04 16:34:12 +0100
commitbcba6d1bc9f769da593a3b01a12846f3e7a26a25 (patch)
treef09be5662a73315b38a21f49afc0dd8b8407cf4b
parentd1321c8d686cc0e392c8ae26beb8abe762258900 (diff)
Experimentally applying eager evar substitution at the same time as
eager meta substition in w_unify, so as to preserve compatibility after PMP's move of (setoid) rewrite clauses from metas to evars (fbbe491cfa). Hoping it is compatible for non-rewrite uses of the eager meta flag, and that it is not too costly.
-rw-r--r--pretyping/evd.ml5
-rw-r--r--pretyping/evd.mli2
-rw-r--r--pretyping/unification.ml10
3 files changed, 10 insertions, 7 deletions
diff --git a/pretyping/evd.ml b/pretyping/evd.ml
index a3c9e39636..f495a81e6d 100644
--- a/pretyping/evd.ml
+++ b/pretyping/evd.ml
@@ -1454,11 +1454,14 @@ let retract_coercible_metas evd =
let metas = Metamap.smartmapi map evd.metas in
!mc, set_metas evd metas
-let subst_defined_metas bl c =
+let subst_defined_metas_evars (bl,el) c =
let rec substrec c = match kind_of_term c with
| Meta i ->
let select (j,_,_) = Int.equal i j in
substrec (pi2 (List.find select bl))
+ | Evar (evk,args) ->
+ let select (_,(evk',args'),_) = Evar.equal evk evk' && Array.equal Constr.equal args args' in
+ substrec (pi3 (List.find select el))
| _ -> map_constr substrec c
in try Some (substrec c) with Not_found -> None
diff --git a/pretyping/evd.mli b/pretyping/evd.mli
index 54c5d9bf23..513ade646b 100644
--- a/pretyping/evd.mli
+++ b/pretyping/evd.mli
@@ -443,7 +443,7 @@ val map_metas_fvalue : (constr -> constr) -> evar_map -> evar_map
type metabinding = metavariable * constr * instance_status
val retract_coercible_metas : evar_map -> metabinding list * evar_map
-val subst_defined_metas : metabinding list -> constr -> constr option
+val subst_defined_metas_evars : metabinding list * ('a * existential * constr) list -> constr -> constr option
(** {5 FIXME: Nothing to do here} *)
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index 39952242bc..a6b02bcf9d 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -509,10 +509,10 @@ let isAllowedEvar flags c = match kind_of_term c with
| _ -> false
let check_compatibility env pbty flags (sigma,metasubst,evarsubst) tyM tyN =
- match subst_defined_metas metasubst tyM with
+ match subst_defined_metas_evars (metasubst,evarsubst) tyM with
| None -> sigma
| Some m ->
- match subst_defined_metas metasubst tyN with
+ match subst_defined_metas_evars (metasubst,evarsubst) tyN with
| None -> sigma
| Some n ->
if is_ground_term sigma m && is_ground_term sigma n then
@@ -844,11 +844,11 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst) conv_at_top env cv_pb
match flags.modulo_conv_on_closed_terms with
| None -> None
| Some convflags ->
- let subst = if flags.use_metas_eagerly_in_conv_on_closed_terms then metasubst else ms in
- match subst_defined_metas subst cM with
+ let subst = if flags.use_metas_eagerly_in_conv_on_closed_terms then (metasubst,evarsubst) else (ms,es) in
+ match subst_defined_metas_evars subst cM with
| None -> (* some undefined Metas in cM *) None
| Some m1 ->
- match subst_defined_metas subst cN with
+ match subst_defined_metas_evars subst cN with
| None -> (* some undefined Metas in cN *) None
| Some n1 ->
(* No subterm restriction there, too much incompatibilities *)