[T.Note note]
else []
in
- assert (Ut.is_sober csty);
- assert (Ut.is_sober cety);
+ assert (Ut.is_sober st.context csty);
+ assert (Ut.is_sober st.context cety);
if Ut.alpha_equivalence csty cety then script else
let sty, ety = H.acic_bc st.context sty, H.acic_bc st.context ety in
match name with
in
if DTI.does_not_occur (succ i) (H.cic t) || compare premise name then
{st with context = Cn.clear st.context premise}, script name
- else
+ else begin
+ assert (Ut.is_sober st.context (H.cic ity));
+ let ity = H.acic_bc st.context ity in
let br1 = [T.Id ""] in
let br2 = List.rev (T.Apply (w, "assumption") :: script None) in
let text = "non linear rewrite" in
st, [T.Branch ([br2; br1], ""); T.Cut (name, ity, text)]
+ end
| _ -> assert false
let mk_rewrite st dtext where qs tl direction t =
| C.AAppl (_, hd :: tl) when is_fwd_rewrite_left hd tl ->
mk_fwd_rewrite st dtext intro tl false v t ity
| v ->
+ assert (Ut.is_sober st.context (H.cic ity));
+ let ity = H.acic_bc st.context ity in
let qs = [proc_proof (next st) v; [T.Id ""]] in
- let ity = H.acic_bc st.context ity in
st, [T.Branch (qs, ""); T.Cut (intro, ity, dtext)]
in
st, C.Decl (H.cic ity), rqv
in
aux
-let is_sober t =
- let rec sober_term g = function
+let is_sober c t =
+ let rec sober_term c 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.MutInd (_, _, xnss) -> sober_xnss c g xnss
+ | C.Meta (_, xss) -> sober_xss c 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.Cast (t, v) ->
+ sober_term c (sober_term c g t) v
+ | C.LetIn (_, v, ty, t) ->
+ sober_term c (sober_term c (sober_term c g t) ty) v
| C.Appl []
| C.Appl [_] -> fun b -> false
- | C.Appl ts -> sober_terms g ts
+ | C.Appl ts -> sober_terms c 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
+ sober_terms c (sober_term c (sober_term c g t) v) ts
+ | C.Fix (_, ifs) -> sober_ifs c g ifs
+ | C.CoFix (_, cifs) -> sober_cifs c g cifs
+ and sober_terms c g = List.fold_left (sober_term c) g
+ and sober_xnss c g =
+ let map g (_, t) = sober_term c g t in
List.fold_left map g
- and sober_xss g =
+ and sober_xss c g =
let map g = function
| None -> g
- | Some t -> sober_term g t
+ | Some t -> sober_term c 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
+ and sober_ifs c g =
+ let map g (_, _, t, v) = sober_term c (sober_term c 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
+ and sober_cifs c g =
+ let map g (_, t, v) = sober_term c (sober_term c g t) v in
List.fold_left map g
in
- sober_term (fun b -> b) t true
+ sober_term c (fun b -> b) t true
| C.Lambda (n,s,t) ->
(* Let's visit all the subterms that will not be visited later *)
let _ = type_of_aux context s None in
- let expected_target_type =
+ let n, expected_target_type =
match expectedty with
- None -> None
+ | None -> n, None
| Some expectedty' ->
- let ty =
+ let n, ty =
match R.whd context expectedty' with
- C.Prod (_,_,expected_target_type) ->
- beta_reduce expected_target_type
+ | C.Prod (n',_,expected_target_type) ->
+ let xtt = beta_reduce expected_target_type in
+ if n <> C.Anonymous then n, xtt else n', xtt
| _ -> assert false
in
- Some ty
+ n, Some ty
in
let type2 =
type_of_aux ((Some (n,(C.Decl s)))::context) t expected_target_type