aboutsummaryrefslogtreecommitdiff
path: root/kernel/reduction.ml
diff options
context:
space:
mode:
authorMatthieu Sozeau2014-09-27 16:08:02 +0200
committerMatthieu Sozeau2014-09-27 20:41:04 +0200
commit84544396cbbf34848be2240acf181b4d5f1f42d2 (patch)
tree72d398f334bdc7b1c6a0ee333a05940c34780f12 /kernel/reduction.ml
parent0efba04058ba28889c83553224309be216873298 (diff)
Add a boolean to indicate the unfolding state of a primitive projection,
so as to reproduce correctly the reduction behavior of existing projections, i.e. delta + iota. Make [projection] an abstract datatype in Names.ml, most of the patch is about using that abstraction. Fix unification.ml which tried canonical projections too early in presence of primitive projections.
Diffstat (limited to 'kernel/reduction.ml')
-rw-r--r--kernel/reduction.ml16
1 files changed, 9 insertions, 7 deletions
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index 802d2b67b4..9a7146890f 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -275,12 +275,14 @@ let in_whnf (t,stk) =
| FLOCKED -> assert false
let unfold_projection infos p c =
- if RedFlags.red_set infos.i_flags (RedFlags.fCONST p) then
- (match try Some (lookup_projection p (info_env infos)) with Not_found -> None with
- | Some pb ->
- let s = Zproj (pb.Declarations.proj_npars, pb.Declarations.proj_arg, p) in
- Some (c, s)
- | None -> None)
+ let unf = Projection.unfolded p in
+ if unf || RedFlags.red_set infos.i_flags (RedFlags.fCONST (Projection.constant p)) then
+ (match try Some (lookup_projection p (info_env infos)) with Not_found -> None with
+ | Some pb ->
+ let s = Zproj (pb.Declarations.proj_npars, pb.Declarations.proj_arg,
+ Projection.constant p) in
+ Some (c, s)
+ | None -> None)
else None
(* Conversion between [lft1]term1 and [lft2]term2 *)
@@ -368,7 +370,7 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| Some (def2,s2) ->
eqappr cv_pb l2r infos appr1 (lft2, whd def2 (s2 :: v2)) cuniv
| None ->
- if eq_constant p1 p2 && compare_stack_shape v1 v2 then
+ if Projection.equal p1 p2 && compare_stack_shape v1 v2 then
let u1 = ccnv CONV l2r infos el1 el2 c1 c2 cuniv in
convert_stacks l2r infos lft1 lft2 v1 v2 u1
else (* Two projections in WHNF: unfold *)