Skip to content

Commit d286d05

Browse files
committed
wip
1 parent 33fb39b commit d286d05

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/ecHiInductive.ml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,24 @@ let trans_datatype (env : EcEnv.env) (name : ptydname) (dt : pdatatype) =
131131

132132
let tdecl = EcEnv.Ty.by_path_opt tname env0
133133
|> odfl (EcDecl.abs_tydecl ~params:(`Named tparams) lc) in
134-
let tyinst () =
135-
fun ty -> ty_instantiate tdecl.tyd_params targs ty in
134+
let tyinst = ty_instantiate tdecl.tyd_params targs in
136135

137136
match tdecl.tyd_type with
138137
| Abstract _ ->
139-
List.exists isempty (targs)
138+
List.exists isempty targs
140139

141140
| Concrete ty ->
142-
isempty_1 [tyinst () ty]
141+
isempty_1 [ tyinst ty ]
143142

144143
| Record (_, fields) ->
145-
isempty_1 (List.map (tyinst () |- snd) fields)
144+
isempty_1 (List.map (tyinst |- snd) fields)
146145

147146
| Datatype dt ->
148-
isempty_n (List.map (List.map (tyinst ()) |- snd) dt.tydt_ctors)
147+
(* FIXME: Inspecting all constructors recursively causes
148+
non-termination in some cases. One can have the same
149+
limitation as is done for positivity in order to limit this
150+
unfolding to well-behaved cases. *)
151+
isempty_n (List.map (List.map tyinst |- snd) dt.tydt_ctors)
149152

150153
in
151154

src/ecInductive.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@ exception NonPositive of nonpositive_description
9898
- inductive occurences a₁ a₂ .. aₙ p are such that ∀i. p ∉ fv(aᵢ)
9999
100100
Crucially, this has to be checked whenever p occurs in an instance of
101-
another type constructor. *)
101+
another type constructor.
102+
103+
FIXME: The current implementation prohibits the use of a type which changes
104+
its type arguments like e.g.
105+
{v
106+
type ('a, 'b) t = [
107+
| Elt of 'a
108+
| Swap of ('b, 'a) t
109+
].
110+
v}
111+
to be used as a type constructor *)
102112

103113
let rec occurs ?(normty = identity) p t =
104114
match (normty t).ty_node with
@@ -121,7 +131,7 @@ let rec check_positivity_in_decl fct p decl ident =
121131
| Concrete ty -> [ ty ]
122132
| Abstract _ ->
123133
raise (NonPositive (AbstractTypeRestriction p))
124-
| Datatype { tydt_ctors } -> List.flatten @@ List.map snd tydt_ctors
134+
| Datatype { tydt_ctors } -> List.concat_map snd tydt_ctors
125135
| Record (_, tys) -> List.map snd tys
126136
in
127137
List.iter (check_positivity_ident fct p decl.tyd_params ident) tys_to_inspect

0 commit comments

Comments
 (0)