Skip to content

Commit dd2c97f

Browse files
committed
Move CompactedDecl to ppconstr
1 parent 0524542 commit dd2c97f

14 files changed

Lines changed: 69 additions & 108 deletions

File tree

engine/eConstr.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ type unsafe_judgment = (constr, types) Environ.punsafe_judgment
171171
type unsafe_type_judgment = (types, ESorts.t) Environ.punsafe_type_judgment
172172
type named_declaration = (constr, types, ERelevance.t) Context.Named.Declaration.pt
173173
type rel_declaration = (constr, types, ERelevance.t) Context.Rel.Declaration.pt
174-
type compacted_declaration = (constr, types, ERelevance.t) Context.Compacted.Declaration.pt
175174
type named_context = (constr, types, ERelevance.t) Context.Named.pt
176-
type compacted_context = compacted_declaration list
177175
type rel_context = (constr, types, ERelevance.t) Context.Rel.pt
178176
type 'a binder_annot = ('a, ERelevance.t) Context.pbinder_annot
179177

engine/eConstr.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ type unsafe_judgment = (constr, types) Environ.punsafe_judgment
9393
type unsafe_type_judgment = (types, Evd.esorts) Environ.punsafe_type_judgment
9494
type named_declaration = (constr, types, ERelevance.t) Context.Named.Declaration.pt
9595
type rel_declaration = (constr, types, ERelevance.t) Context.Rel.Declaration.pt
96-
type compacted_declaration = (constr, types, ERelevance.t) Context.Compacted.Declaration.pt
9796
type named_context = (constr, types, ERelevance.t) Context.Named.pt
98-
type compacted_context = compacted_declaration list
9997
type rel_context = (constr, types, ERelevance.t) Context.Rel.pt
10098
type 'a binder_annot = ('a,ERelevance.t) Context.pbinder_annot
10199

engine/termops.ml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ open Environ
2222

2323
module RelDecl = Context.Rel.Declaration
2424
module NamedDecl = Context.Named.Declaration
25-
module CompactedDecl = Context.Compacted.Declaration
2625

2726
module Internal = struct
2827

@@ -1182,28 +1181,6 @@ let fold_named_context_both_sides f l ~init = List.fold_right_and_left f l init
11821181
let mem_named_context_val id ctxt =
11831182
try ignore(Environ.lookup_named_ctxt id ctxt); true with Not_found -> false
11841183

1185-
let compact_named_context sigma sign =
1186-
let compact l decl =
1187-
match decl, l with
1188-
| NamedDecl.LocalAssum (i,t), [] ->
1189-
[CompactedDecl.LocalAssum ([i],t)]
1190-
| NamedDecl.LocalDef (i,c,t), [] ->
1191-
[CompactedDecl.LocalDef ([i],c,t)]
1192-
| NamedDecl.LocalAssum (i1,t1), CompactedDecl.LocalAssum (li,t2) :: q ->
1193-
if EConstr.eq_constr sigma t1 t2
1194-
then CompactedDecl.LocalAssum (i1::li, t2) :: q
1195-
else CompactedDecl.LocalAssum ([i1],t1) :: CompactedDecl.LocalAssum (li,t2) :: q
1196-
| NamedDecl.LocalDef (i1,c1,t1), CompactedDecl.LocalDef (li,c2,t2) :: q ->
1197-
if EConstr.eq_constr sigma c1 c2 && EConstr.eq_constr sigma t1 t2
1198-
then CompactedDecl.LocalDef (i1::li, c2, t2) :: q
1199-
else CompactedDecl.LocalDef ([i1],c1,t1) :: CompactedDecl.LocalDef (li,c2,t2) :: q
1200-
| NamedDecl.LocalAssum (i,t), q ->
1201-
CompactedDecl.LocalAssum ([i],t) :: q
1202-
| NamedDecl.LocalDef (i,c,t), q ->
1203-
CompactedDecl.LocalDef ([i],c,t) :: q
1204-
in
1205-
sign |> Context.Named.fold_inside compact ~init:[] |> List.rev
1206-
12071184
let clear_named_body id env =
12081185
let open NamedDecl in
12091186
let aux _ status = function

engine/termops.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ val fold_named_context_both_sides :
194194
('a -> Constr.named_declaration -> Constr.named_declaration list -> 'a) ->
195195
Constr.named_context -> init:'a -> 'a
196196
val mem_named_context_val : Id.t -> named_context_val -> bool
197-
val compact_named_context : Evd.evar_map -> EConstr.named_context -> EConstr.compacted_context
198197

199198
val clear_named_body : Id.t -> env -> env
200199

ide/rocqide/idetop.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ let process_goal short sigma g =
207207
if short then [] else
208208
let hyps =
209209
List.rev_map process_hyp
210-
(Termops.compact_named_context sigma (EConstr.named_context env))
210+
(Ppconstr.compact_named_context sigma (EConstr.named_context env))
211211
in
212212
hyps
213213
in

kernel/constr.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,10 +1383,8 @@ let hcons = HCons.hcons
13831383

13841384
type rel_declaration = (constr, types, Sorts.relevance) Context.Rel.Declaration.pt
13851385
type named_declaration = (constr, types, Sorts.relevance) Context.Named.Declaration.pt
1386-
type compacted_declaration = (constr, types, Sorts.relevance) Context.Compacted.Declaration.pt
13871386
type rel_context = rel_declaration list
13881387
type named_context = named_declaration list
1389-
type compacted_context = compacted_declaration list
13901388

13911389
(** Minimalistic constr printer, typically for debugging *)
13921390

kernel/constr.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,8 @@ val eq_constr_nounivs : constr -> constr -> bool
430430

431431
type rel_declaration = (constr, types, Sorts.relevance) Context.Rel.Declaration.pt
432432
type named_declaration = (constr, types, Sorts.relevance) Context.Named.Declaration.pt
433-
type compacted_declaration = (constr, types, Sorts.relevance) Context.Compacted.Declaration.pt
434433
type rel_context = rel_declaration list
435434
type named_context = named_declaration list
436-
type compacted_context = compacted_declaration list
437435

438436
(** {6 Relocation and substitution } *)
439437

kernel/context.ml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -569,32 +569,3 @@ struct
569569
let instance mk l =
570570
Array.of_list (instance_list mk l)
571571
end
572-
573-
module Compacted =
574-
struct
575-
module Declaration =
576-
struct
577-
type ('constr, 'types, 'r) pt =
578-
| LocalAssum of (Id.t,'r) pbinder_annot list * 'types
579-
| LocalDef of (Id.t,'r) pbinder_annot list * 'constr * 'types
580-
581-
let map_constr f = function
582-
| LocalAssum (ids, ty) as decl ->
583-
let ty' = f ty in
584-
if ty == ty' then decl else LocalAssum (ids, ty')
585-
| LocalDef (ids, c, ty) as decl ->
586-
let ty' = f ty in
587-
let c' = f c in
588-
if c == c' && ty == ty' then decl else LocalDef (ids,c',ty')
589-
590-
let of_named_decl = function
591-
| Named.Declaration.LocalAssum (id,t) ->
592-
LocalAssum ([id],t)
593-
| Named.Declaration.LocalDef (id,v,t) ->
594-
LocalDef ([id],v,t)
595-
end
596-
597-
type ('constr, 'types, 'r) pt = ('constr, 'types, 'r) Declaration.pt list
598-
599-
let fold f l ~init = List.fold_right f l init
600-
end

kernel/context.mli

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,3 @@ sig
370370
(** [instance_list] is like [instance] but returning a list. *)
371371
val instance_list : (Id.t -> 'v) -> ('c, 't, 'r) pt -> 'v list
372372
end
373-
374-
module Compacted :
375-
sig
376-
module Declaration :
377-
sig
378-
type ('constr, 'types, 'r) pt =
379-
| LocalAssum of (Id.t,'r) pbinder_annot list * 'types
380-
| LocalDef of (Id.t,'r) pbinder_annot list * 'constr * 'types
381-
382-
val map_constr : ('c -> 'c) -> ('c, 'c, 'r) pt -> ('c, 'c, 'r) pt
383-
val of_named_decl : ('c, 't, 'r) Named.Declaration.pt -> ('c, 't, 'r) pt
384-
end
385-
386-
type ('constr, 'types, 'r) pt = ('constr, 'types, 'r) Declaration.pt list
387-
388-
val fold : (('c, 't, 'r) Declaration.pt -> 'a -> 'a) -> ('c, 't, 'r) pt -> init:'a -> 'a
389-
end

printing/ppconstr.ml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,3 +855,42 @@ let pr_lconstr_pattern_expr ~flags env sigma c : Pp.t = !term_pr.pr_lconstr_patt
855855
let pr_cases_pattern_expr ~flags c : Pp.t = pr_patt ~flags (pr ~flags no_after ltop) no_after ltop c
856856

857857
let pr_binders ~flags env sigma l : Pp.t = pr_undelimited_binders ~flags spc true (pr_expr ~flags env sigma no_after ltop) l
858+
859+
module CompactedDecl = struct
860+
type t =
861+
| LocalAssum of Id.t EConstr.binder_annot list * EConstr.types
862+
| LocalDef of Id.t EConstr.binder_annot list * EConstr.constr * EConstr.types
863+
864+
let of_named_decl = function
865+
| Context.Named.Declaration.LocalAssum (id,t) ->
866+
LocalAssum ([id],t)
867+
| Context.Named.Declaration.LocalDef (id,v,t) ->
868+
LocalDef ([id],v,t)
869+
870+
let to_tuple = function
871+
| LocalAssum (ids, t) -> ids, None, t
872+
| LocalDef (ids, b, t) -> ids, Some b, t
873+
end
874+
875+
let compact_named_context sigma sign =
876+
let module NamedDecl = Context.Named.Declaration in
877+
let compact l decl =
878+
match decl, l with
879+
| NamedDecl.LocalAssum (i,t), [] ->
880+
[CompactedDecl.LocalAssum ([i],t)]
881+
| NamedDecl.LocalDef (i,c,t), [] ->
882+
[CompactedDecl.LocalDef ([i],c,t)]
883+
| NamedDecl.LocalAssum (i1,t1), CompactedDecl.LocalAssum (li,t2) :: q ->
884+
if EConstr.eq_constr sigma t1 t2
885+
then CompactedDecl.LocalAssum (i1::li, t2) :: q
886+
else CompactedDecl.LocalAssum ([i1],t1) :: CompactedDecl.LocalAssum (li,t2) :: q
887+
| NamedDecl.LocalDef (i1,c1,t1), CompactedDecl.LocalDef (li,c2,t2) :: q ->
888+
if EConstr.eq_constr sigma c1 c2 && EConstr.eq_constr sigma t1 t2
889+
then CompactedDecl.LocalDef (i1::li, c2, t2) :: q
890+
else CompactedDecl.LocalDef ([i1],c1,t1) :: CompactedDecl.LocalDef (li,c2,t2) :: q
891+
| NamedDecl.LocalAssum (i,t), q ->
892+
CompactedDecl.LocalAssum ([i],t) :: q
893+
| NamedDecl.LocalDef (i,c,t), q ->
894+
CompactedDecl.LocalDef ([i],c,t) :: q
895+
in
896+
sign |> Context.Named.fold_inside compact ~init:[] |> List.rev

0 commit comments

Comments
 (0)