Skip to content

Commit 286cf5c

Browse files
author
Enrico
authored
Merge pull request math-comp#118 from maximedenes/coq-pr417-landing
Adapt the ssr plugin to Coq's PR#417.
2 parents caeeae8 + 2cb863a commit 286cf5c

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

mathcomp/ssreflect/plugin/trunk/ssreflect.ml4

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ let mkCExplVar loc id n =
249249
CAppExpl (loc, (None, Ident (loc, id), None), mkCHoles loc n)
250250
let mkCLambda loc name ty t =
251251
CLambdaN (loc, [[loc, name], Default Explicit, ty], t)
252-
let mkCLetIn loc name bo t =
253-
CLetIn (loc, (loc, name), bo, t)
252+
let mkCLetIn loc name bo oty t =
253+
CLetIn (loc, (loc, name), bo, oty, t)
254254
let mkCArrow loc ty t =
255255
CProdN (loc, [[dummy_loc,Anonymous], Default Explicit, ty], t)
256256
let mkCCast loc t ty = CCast (loc,t, dC ty)
@@ -1359,7 +1359,7 @@ END
13591359

13601360
let rec splay_search_pattern na = function
13611361
| Pattern.PApp (fp, args) -> splay_search_pattern (na + Array.length args) fp
1362-
| Pattern.PLetIn (_, _, bp) -> splay_search_pattern na bp
1362+
| Pattern.PLetIn (_, _, _, bp) -> splay_search_pattern na bp
13631363
| Pattern.PRef hr -> hr, na
13641364
| _ -> CErrors.error "no head constant in head search pattern"
13651365

@@ -1556,7 +1556,7 @@ GEXTEND Gram
15561556
GLOBAL: closed_binder;
15571557
closed_binder: [
15581558
[ ["of" | "&"]; c = operconstr LEVEL "99" ->
1559-
[LocalRawAssum ([!@loc, Anonymous], Default Explicit, c)]
1559+
[CLocalAssum ([!@loc, Anonymous], Default Explicit, c)]
15601560
] ];
15611561
END
15621562
(* }}} *)
@@ -3343,15 +3343,15 @@ let pf_interp_ty ?(resolve_typeclasses=false) ist gl ty =
33433343
| a, (t, None) ->
33443344
let rec force_type = function
33453345
| GProd (l, x, k, s, t) -> incr n_binders; GProd (l, x, k, s, force_type t)
3346-
| GLetIn (l, x, v, t) -> incr n_binders; GLetIn (l, x, v, force_type t)
3346+
| GLetIn (l, x, v, oty, t) -> incr n_binders; GLetIn (l, x, v, oty, force_type t)
33473347
| ty -> mkRCast ty mkRType in
33483348
a, (force_type t, None)
33493349
| _, (_, Some ty) ->
33503350
let rec force_type = function
33513351
| CProdN (l, abs, t) ->
33523352
n_binders := !n_binders + List.length (List.flatten (List.map pi1 abs));
33533353
CProdN (l, abs, force_type t)
3354-
| CLetIn (l, n, v, t) -> incr n_binders; CLetIn (l, n, v, force_type t)
3354+
| CLetIn (l, n, v, oty, t) -> incr n_binders; CLetIn (l, n, v, oty, force_type t)
33553355
| ty -> mkCCast dummy_loc ty (mkCType dummy_loc) in
33563356
mk_term ' ' (force_type ty) in
33573357
let strip_cast (sigma, t) =
@@ -5308,7 +5308,7 @@ type ssrbindfmt =
53085308
| BFvar
53095309
| BFdecl of int (* #xs *)
53105310
| BFcast (* final cast *)
5311-
| BFdef of bool (* has cast? *)
5311+
| BFdef
53125312
| BFrec of bool * bool (* has struct? * has cast? *)
53135313

53145314
let rec mkBstruct i = function
@@ -5321,15 +5321,12 @@ let rec mkBstruct i = function
53215321
| [] -> []
53225322

53235323
let rec format_local_binders h0 bl0 = match h0, bl0 with
5324-
| BFvar :: h, LocalRawAssum ([_, x], _, _) :: bl ->
5324+
| BFvar :: h, CLocalAssum ([_, x], _, _) :: bl ->
53255325
Bvar x :: format_local_binders h bl
5326-
| BFdecl _ :: h, LocalRawAssum (lxs, _, t) :: bl ->
5326+
| BFdecl _ :: h, CLocalAssum (lxs, _, t) :: bl ->
53275327
Bdecl (List.map snd lxs, t) :: format_local_binders h bl
5328-
| BFdef false :: h, LocalRawDef ((_, x), v) :: bl ->
5329-
Bdef (x, None, v) :: format_local_binders h bl
5330-
| BFdef true :: h,
5331-
LocalRawDef ((_, x), CCast (_, v, CastConv t)) :: bl ->
5332-
Bdef (x, Some t, v) :: format_local_binders h bl
5328+
| BFdef :: h, CLocalDef ((_, x), v, oty) :: bl ->
5329+
Bdef (x, oty, v) :: format_local_binders h bl
53335330
| _ -> []
53345331

53355332
let rec format_constr_expr h0 c0 = match h0, c0 with
@@ -5339,12 +5336,9 @@ let rec format_constr_expr h0 c0 = match h0, c0 with
53395336
| BFdecl _:: h, CLambdaN (_, [lxs, _, t], c) ->
53405337
let bs, c' = format_constr_expr h c in
53415338
Bdecl (List.map snd lxs, t) :: bs, c'
5342-
| BFdef false :: h, CLetIn(_, (_, x), v, c) ->
5339+
| BFdef :: h, CLetIn(_, (_, x), v, oty, c) ->
53435340
let bs, c' = format_constr_expr h c in
5344-
Bdef (x, None, v) :: bs, c'
5345-
| BFdef true :: h, CLetIn(_, (_, x), CCast (_, v, CastConv t), c) ->
5346-
let bs, c' = format_constr_expr h c in
5347-
Bdef (x, Some t, v) :: bs, c'
5341+
Bdef (x, oty, v) :: bs, c'
53485342
| [BFcast], CCast (_, c, CastConv t) ->
53495343
[Bcast t], c
53505344
| BFrec (has_str, has_cast) :: h,
@@ -5367,10 +5361,8 @@ let rec format_glob_decl h0 d0 = match h0, d0 with
53675361
| Bdecl (xs, _) :: bs -> Bdecl (x :: xs, t) :: bs
53685362
| bs -> Bdecl ([x], t) :: bs
53695363
end
5370-
| BFdef false :: h, (x, _, Some v, _) :: d ->
5364+
| BFdef :: h, (x, _, Some v, _) :: d ->
53715365
Bdef (x, None, v) :: format_glob_decl h d
5372-
| BFdef true:: h, (x, _, Some (GCast (_, v, CastConv t)), _) :: d ->
5373-
Bdef (x, Some t, v) :: format_glob_decl h d
53745366
| _, (x, _, None, t) :: d ->
53755367
Bdecl ([x], t) :: format_glob_decl [] d
53765368
| _, (x, _, Some v, _) :: d ->
@@ -5389,12 +5381,9 @@ let rec format_glob_constr h0 c0 = match h0, c0 with
53895381
| Bdecl (xs, _) :: bs, c' -> Bdecl (x :: xs, t) :: bs, c'
53905382
| _ -> [Bdecl ([x], t)], c
53915383
end
5392-
| BFdef false :: h, GLetIn(_, x, v, c) ->
5393-
let bs, c' = format_glob_constr h c in
5394-
Bdef (x, None, v) :: bs, c'
5395-
| BFdef true :: h, GLetIn(_, x, GCast (_, v, CastConv t), c) ->
5384+
| BFdef :: h, GLetIn(_, x, v, oty, c) ->
53965385
let bs, c' = format_glob_constr h c in
5397-
Bdef (x, Some t, v) :: bs, c'
5386+
Bdef (x, oty, v) :: bs, c'
53985387
| [BFcast], GCast (_, c, CastConv t) ->
53995388
[Bcast t], c
54005389
| BFrec (has_str, has_cast) :: h, GRec (_, f, _, bl, t, c)
@@ -5501,11 +5490,9 @@ ARGUMENT EXTEND ssrbinder TYPED AS ssrfwdfmt * constr PRINTED BY pr_ssrbinder
55015490
(FwdPose, [BFdecl n]),
55025491
CLambdaN (loc, [xs, Default Explicit, t], mkCHole loc) ]
55035492
| [ "(" ssrbvar(id) ":" lconstr(t) ":=" lconstr(v) ")" ] ->
5504-
[ let loc' = Loc.join_loc (constr_loc t) (constr_loc v) in
5505-
let v' = CCast (loc', v, dC t) in
5506-
(FwdPose,[BFdef true]), CLetIn (loc,bvar_lname id, v',mkCHole loc) ]
5493+
[ (FwdPose,[BFdef]), CLetIn (loc,bvar_lname id, v, Some t, mkCHole loc) ]
55075494
| [ "(" ssrbvar(id) ":=" lconstr(v) ")" ] ->
5508-
[ (FwdPose,[BFdef false]), CLetIn (loc,bvar_lname id, v,mkCHole loc) ]
5495+
[ (FwdPose,[BFdef]), CLetIn (loc,bvar_lname id, v, None, mkCHole loc) ]
55095496
END
55105497

55115498
GEXTEND Gram
@@ -5529,8 +5516,8 @@ let push_binders c2 bs =
55295516
CProdN (mkloc loc1, b, loop ty c bs)
55305517
| (_, CLambdaN (loc1, b, _)) :: bs ->
55315518
CLambdaN (mkloc loc1, b, loop ty c bs)
5532-
| (_, CLetIn (loc1, x, v, _)) :: bs ->
5533-
CLetIn (mkloc loc1, x, v, loop ty c bs)
5519+
| (_, CLetIn (loc1, x, v, oty, _)) :: bs ->
5520+
CLetIn (mkloc loc1, x, v, oty, loop ty c bs)
55345521
| [] -> c
55355522
| _ -> anomaly "binder not a lambda nor a let in" in
55365523
match c2 with
@@ -5540,9 +5527,9 @@ let push_binders c2 bs =
55405527

55415528
let rec fix_binders = function
55425529
| (_, CLambdaN (_, [xs, _, t], _)) :: bs ->
5543-
LocalRawAssum (xs, Default Explicit, t) :: fix_binders bs
5544-
| (_, CLetIn (_, x, v, _)) :: bs ->
5545-
LocalRawDef (x, v) :: fix_binders bs
5530+
CLocalAssum (xs, Default Explicit, t) :: fix_binders bs
5531+
| (_, CLetIn (_, x, v, oty, _)) :: bs ->
5532+
CLocalDef (x, v, oty) :: fix_binders bs
55465533
| _ -> []
55475534

55485535
let pr_ssrstruct _ _ _ = function
@@ -5708,8 +5695,8 @@ let binder_to_intro_id = List.map (function
57085695
| (FwdPose, [BFvar]), CLambdaN (_,[ids,_,_],_)
57095696
| (FwdPose, [BFdecl _]), CLambdaN (_,[ids,_,_],_) ->
57105697
List.map (function (_, Name id) -> IpatId id | _ -> IpatAnon) ids
5711-
| (FwdPose, [BFdef _]), CLetIn (_,(_,Name id),_,_) -> [IpatId id]
5712-
| (FwdPose, [BFdef _]), CLetIn (_,(_,Anonymous),_,_) -> [IpatAnon]
5698+
| (FwdPose, [BFdef]), CLetIn (_,(_,Name id),_,_,_) -> [IpatId id]
5699+
| (FwdPose, [BFdef]), CLetIn (_,(_,Anonymous),_,_,_) -> [IpatAnon]
57135700
| _ -> anomaly "ssrbinder is not a binder")
57145701

57155702
let pr_ssrhavefwdwbinders _ _ prt (tr,((hpats, (fwd, hint)))) =

0 commit comments

Comments
 (0)