]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/cic_proof_checking/freshNamesGenerator.ml
Very experimental commit: the type of the source is now required in LetIns
[helm.git] / helm / software / components / cic_proof_checking / freshNamesGenerator.ml
index 73b75ce18e7257e876a0d316d934fd95db15350d..1cb86b35abfad49738f4d79f8fb8c2c7490e3b8a 100755 (executable)
@@ -63,7 +63,7 @@ let rec guess_a_name context ty =
 (* warning: on appl we should beta reduce before the recursive call
   | Cic.Lambda _ -> assert false   
 *)
-  | Cic.LetIn (_,s,t) -> guess_a_name context (CicSubstitution.subst ~avoid_beta_redexes:true s t)
+  | Cic.LetIn (_,s,_,t) -> guess_a_name context (CicSubstitution.subst ~avoid_beta_redexes:true s t)
   | Cic.Appl [] -> assert false
   | Cic.Appl (he::_) -> guess_a_name context he 
   | Cic.Const (uri,_)
@@ -157,16 +157,17 @@ let rec mk_fresh_names ~subst metasenv context t =
          | _ -> n in 
        let t' = mk_fresh_names ~subst metasenv (Some(n',Cic.Decl s')::context) t in
        Cic.Lambda (n',s',t')
-    | Cic.LetIn (n,s,t) ->
+    | Cic.LetIn (n,s,ty,t) ->
        let s' = mk_fresh_names ~subst metasenv context s in
+        let ty' = mk_fresh_names ~subst metasenv context ty in
        let n' =
          match n with
            Cic.Anonymous -> Cic.Anonymous
          | Cic.Name "matita_dummy" -> 
              mk_fresh_name ~subst metasenv context Cic.Anonymous ~typ:s' 
          | _ -> n in 
-       let t' = mk_fresh_names ~subst metasenv (Some(n',Cic.Def (s',None))::context) t in
-       Cic.LetIn (n',s',t')    
+       let t' = mk_fresh_names ~subst metasenv (Some(n',Cic.Def (s',ty'))::context) t in
+       Cic.LetIn (n',s',ty',t')        
     | Cic.Appl l ->
        Cic.Appl (List.map (mk_fresh_names ~subst metasenv context) l)
     | Cic.Const (uri,exp_named_subst) ->
@@ -282,12 +283,13 @@ let clean_dummy_dependent_types t =
        let s',rels1 = aux k s in
        let t',rels2 = aux (k+1) t in
         C.Lambda (n, s', t'), rels1@rels2
-    | C.LetIn (n,s,t) ->
+    | C.LetIn (n,s,ty,t) ->
        let s',rels1 = aux k s in
-       let t',rels2 = aux (k+1) t in
-       let rels = rels1 @ rels2 in
-        if List.mem k rels2 then
-         C.LetIn (n, s', t'), rels
+       let ty',rels2 = aux k ty in
+       let t',rels3 = aux (k+1) t in
+       let rels = rels1 @ rels2 @ rels3 in
+        if List.mem k rels3 then
+         C.LetIn (n, s', ty', t'), rels
         else
          (* (C.Rel 1) is just a dummy term; any term would fit *)
          CicSubstitution.subst (C.Rel 1) t', rels