| C.Cast (te,ty) -> is_closed k te && is_closed k ty
| C.Prod (name,so,dest) -> is_closed k so && is_closed (k+1) dest
| C.Lambda (_,so,dest) -> is_closed k so && is_closed (k+1) dest
- | C.LetIn (_,so,dest) -> is_closed k so && is_closed (k+1) dest
+ | C.LetIn (_,so,ty,dest) ->
+ is_closed k so && is_closed k ty && is_closed (k+1) dest
| C.Appl l ->
List.fold_right (fun x i -> i && is_closed k x) l true
| C.Var (_,exp_named_subst)
| C.Cast (te,ty) -> is_meta_closed te && is_meta_closed ty
| C.Prod (name,so,dest) -> is_meta_closed so && is_meta_closed dest
| C.Lambda (_,so,dest) -> is_meta_closed so && is_meta_closed dest
- | C.LetIn (_,so,dest) -> is_meta_closed so && is_meta_closed dest
+ | C.LetIn (_,so,ty,dest) ->
+ is_meta_closed so &&
+ is_meta_closed ty &&
+ is_meta_closed dest
| C.Appl l ->
not (List.exists (fun x -> not (is_meta_closed x)) l)
| C.Var (_,exp_named_subst)
| C.ACast (id,_,_)
| C.AProd (id,_,_,_)
| C.ALambda (id,_,_,_)
- | C.ALetIn (id,_,_,_)
+ | C.ALetIn (id,_,_,_,_)
| C.AAppl (id,_)
| C.AConst (id,_,_)
| C.AMutInd (id,_,_,_)
| C.Cast (te,ty) -> C.Cast (rehash_term te, rehash_term ty)
| C.Prod (n,s,t) -> C.Prod (n, rehash_term s, rehash_term t)
| C.Lambda (n,s,t) -> C.Lambda (n, rehash_term s, rehash_term t)
- | C.LetIn (n,s,t) -> C.LetIn (n, rehash_term s, rehash_term t)
+ | C.LetIn (n,s,ty,t) ->
+ C.LetIn (n, rehash_term s, rehash_term ty, rehash_term t)
| C.Appl l -> C.Appl (List.map rehash_term l)
| C.Const (uri,exp_named_subst) ->
let uri' = recons uri in
| Some (name,C.Decl t) ->
Some (name,C.Decl (rehash_term t))
| Some (name,C.Def (bo,ty)) ->
- let ty' =
- match ty with
- None -> None
- | Some ty'' -> Some (rehash_term ty'')
- in
- Some (name,C.Def (rehash_term bo, ty'))) hyps,
+ Some (name,C.Def (rehash_term bo, rehash_term ty))) hyps,
rehash_term ty))
conjs
in
List.flatten (List.map (fun (u, t) -> metas_of_term t) ens)
| C.Cast (s, t)
| C.Prod (_, s, t)
- | C.Lambda (_, s, t)
- | C.LetIn (_, s, t) -> (metas_of_term s) @ (metas_of_term t)
+ | C.Lambda (_, s, t) -> (metas_of_term s) @ (metas_of_term t)
+ | C.LetIn (_, s, ty, t) ->
+ (metas_of_term s) @ (metas_of_term ty) @ (metas_of_term t)
| C.Appl l -> List.flatten (List.map metas_of_term l)
| C.MutCase (uri, i, s, t, l) ->
(metas_of_term s) @ (metas_of_term t) @
S.empty ens
| C.Cast (s, t)
| C.Prod (_, s, t)
- | C.Lambda (_, s, t)
- | C.LetIn (_, s, t) -> S.union (metas_of_term_set s) (metas_of_term_set t)
+ | C.Lambda (_, s, t) -> S.union (metas_of_term_set s) (metas_of_term_set t)
+ | C.LetIn (_, s, ty, t) ->
+ S.union (metas_of_term_set s)
+ (S.union (metas_of_term_set ty) (metas_of_term_set t))
| C.Appl l ->
List.fold_left
(fun s t -> S.union s (metas_of_term_set t))
aux s s' && aux t t'
| C.Lambda (_,s,t), C.Lambda (_,s',t') ->
aux s s' && aux t t'
- | C.LetIn (_,s,t), C.LetIn(_,s',t') ->
- aux s s' && aux t t'
- | C.Appl l, C.Appl l' ->
+ | C.LetIn (_,s,ty,t), C.LetIn(_,s',ty',t') ->
+ aux s s' && aux ty ty' && aux t t'
+ | C.Appl l, C.Appl l' when List.length l = List.length l' ->
(try
List.fold_left2
(fun b t1 t2 -> b && aux t1 t2) true l l'
| _ -> b
) true subst subst'
with
- Invalid_argument _ -> false)
+ Invalid_argument _ -> false)
+ | C.Appl [t], t' | t, C.Appl [t'] -> assert false
(* FG: are we _really_ sure of these?
| C.Sort (C.Type u), C.Sort (C.Type u') -> u = u'
| C.Implicit a, C.Implicit a' -> a = a'
we insert an unused variable below to genarate a warning at compile time
*)
- | _,_ -> let fix_alpha_equivalence_please = 0 in false (* we already know that t != t' *)
+ | _,_ -> false (* we already know that t != t' *)
and aux_exp_named_subst exp_named_subst1 exp_named_subst2 =
try
List.fold_left2
Invalid_argument _ -> false
in
aux
+
+let is_sober t =
+ let rec sober_term g = function
+ | C.Rel _
+ | C.Sort _
+ | C.Implicit _ -> g
+ | C.Const (_, xnss)
+ | C.Var (_, xnss)
+ | C.MutConstruct (_, _, _, xnss)
+ | C.MutInd (_, _, xnss) -> sober_xnss g xnss
+ | C.Meta (_, xss) -> sober_xss g xss
+ | C.Lambda (_, v, t)
+ | C.Prod (_, v, t)
+ | C.Cast (t, v) -> sober_term (sober_term g t) v
+ | C.LetIn (_, v, ty, t) -> sober_term
+ (sober_term (sober_term g t) ty) v
+ | C.Appl []
+ | C.Appl [_] -> fun b -> false
+ | C.Appl ts -> sober_terms g ts
+ | C.MutCase (_, _, t, v, ts) ->
+ sober_terms (sober_term (sober_term g t) v) ts
+ | C.Fix (_, ifs) -> sober_ifs g ifs
+ | C.CoFix (_, cifs) -> sober_cifs g cifs
+ and sober_terms g = List.fold_left sober_term g
+ and sober_xnss g =
+ let map g (_, t) = sober_term g t in
+ List.fold_left map g
+ and sober_xss g =
+ let map g = function
+ | None -> g
+ | Some t -> sober_term g t
+ in
+ List.fold_left map g
+ and sober_ifs g =
+ let map g (_, _, t, v) = sober_term (sober_term g t) v in
+ List.fold_left map g
+ and sober_cifs g =
+ let map g (_, t, v) = sober_term (sober_term g t) v in
+ List.fold_left map g
+ in
+ sober_term (fun b -> b) t true