]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/cic_acic/doubleTypeInference.ml
- Procedural: generation of "exact" is now complete
[helm.git] / helm / software / components / cic_acic / doubleTypeInference.ml
index 4910275ea48c291662f213bd72fdb3ddd5e462c1..7f93716b26c6685e1b3a2c74e3da64fc1b4d95cc 100644 (file)
@@ -37,7 +37,7 @@ exception RelToHiddenHypothesis;;
 
 let xxx_type_of_aux' m c t =
  try 
-   Some (fst (CicTypeChecker.type_of_aux' m c t CicUniv.empty_ugraph))
+   Some (fst (CicTypeChecker.type_of_aux' m c t CicUniv.oblivion_ugraph))
  with
  | CicTypeChecker.TypeCheckerFailure _ -> None (* because eta_expansion *)
 ;;
@@ -180,9 +180,9 @@ let type_of_constant uri =
  let module R = CicReduction in
  let module U = UriManager in
   let cobj =
-   match CicEnvironment.is_type_checked CicUniv.empty_ugraph uri with
+   match CicEnvironment.is_type_checked CicUniv.oblivion_ugraph uri with
       CicEnvironment.CheckedObj (cobj,_) -> cobj
-    | CicEnvironment.UncheckedObj uobj ->
+    | CicEnvironment.UncheckedObj (uobj,_) ->
        raise (NotWellTyped "Reference to an unchecked constant")
   in
    match cobj with
@@ -195,9 +195,9 @@ let type_of_variable uri =
  let module C = Cic in
  let module R = CicReduction in
  let module U = UriManager in
-  match CicEnvironment.is_type_checked CicUniv.empty_ugraph uri with
+  match CicEnvironment.is_type_checked CicUniv.oblivion_ugraph uri with
      CicEnvironment.CheckedObj ((C.Variable (_,_,ty,_,_)),_) -> ty
-   | CicEnvironment.UncheckedObj (C.Variable _) ->
+   | CicEnvironment.UncheckedObj (C.Variable _,_) ->
       raise (NotWellTyped "Reference to an unchecked variable")
    |  _ -> raise (WrongUriToVariable (UriManager.string_of_uri uri))
 ;;
@@ -207,9 +207,9 @@ let type_of_mutual_inductive_defs uri i =
  let module R = CicReduction in
  let module U = UriManager in
   let cobj =
-   match CicEnvironment.is_type_checked CicUniv.empty_ugraph uri with
+   match CicEnvironment.is_type_checked CicUniv.oblivion_ugraph uri with
       CicEnvironment.CheckedObj (cobj,_) -> cobj
-    | CicEnvironment.UncheckedObj uobj ->
+    | CicEnvironment.UncheckedObj (uobj,_) ->
        raise (NotWellTyped "Reference to an unchecked inductive type")
   in
    match cobj with
@@ -224,9 +224,9 @@ let type_of_mutual_inductive_constr uri i j =
  let module R = CicReduction in
  let module U = UriManager in
   let cobj =
-   match CicEnvironment.is_type_checked CicUniv.empty_ugraph uri with
+   match CicEnvironment.is_type_checked CicUniv.oblivion_ugraph uri with
       CicEnvironment.CheckedObj (cobj,_) -> cobj
-    | CicEnvironment.UncheckedObj uobj ->
+    | CicEnvironment.UncheckedObj (uobj,_) ->
        raise (NotWellTyped "Reference to an unchecked constructor")
   in
    match cobj with
@@ -339,17 +339,18 @@ let rec type_of_aux' subterms_to_types metasenv context t expectedty =
      | 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
@@ -464,7 +465,7 @@ let rec type_of_aux' subterms_to_types metasenv context t expectedty =
          let (cl,parsno) =
            let obj,_ =
              try
-               CicEnvironment.get_cooked_obj CicUniv.empty_ugraph uri
+               CicEnvironment.get_cooked_obj CicUniv.oblivion_ugraph uri
              with Not_found -> assert false
            in
           match obj with
@@ -573,7 +574,7 @@ let rec type_of_aux' subterms_to_types metasenv context t expectedty =
   let uris_and_types =
      let obj,_ =
        try
-         CicEnvironment.get_cooked_obj CicUniv.empty_ugraph uri
+         CicEnvironment.get_cooked_obj CicUniv.oblivion_ugraph uri
        with Not_found -> assert false
      in
     let params = CicUtil.params_of_obj obj in
@@ -581,7 +582,7 @@ let rec type_of_aux' subterms_to_types metasenv context t expectedty =
       (function uri ->
          let obj,_ =
            try
-             CicEnvironment.get_cooked_obj CicUniv.empty_ugraph uri
+             CicEnvironment.get_cooked_obj CicUniv.oblivion_ugraph uri
            with Not_found -> assert false
          in
          match obj with
@@ -608,15 +609,10 @@ let rec type_of_aux' subterms_to_types metasenv context t expectedty =
    let t1' = CicReduction.whd context t1 in
    let t2' = CicReduction.whd ((Some (name,C.Decl s))::context) t2 in
    match (t1', t2') with
-      (C.Sort _, C.Sort s2)
-        when (s2 = C.Prop or s2 = C.Set or s2 = C.CProp) -> 
-        (* different from Coq manual!!! *)
-         C.Sort s2
-    | (C.Sort (C.Type t1), C.Sort (C.Type t2)) -> 
-       C.Sort (C.Type (CicUniv.fresh()))
-    | (C.Sort _,C.Sort (C.Type t1)) -> 
-        (* TASSI: CONSRTAINTS: the same in cictypechecker,cicrefine *)
-       C.Sort (C.Type t1) (* c'e' bisogno di un fresh? *)
+    | (C.Sort _, C.Sort s2) when (s2 = C.Prop || s2 = C.Set) -> C.Sort s2
+    | (C.Sort (C.Type t1), C.Sort (C.Type t2)) ->C.Sort(C.Type(CicUniv.fresh()))
+    | (C.Sort _,C.Sort (C.Type t1)) -> C.Sort (C.Type t1)
+    | (C.Sort _,C.Sort (C.CProp t1)) -> C.Sort (C.CProp t1)
     | (C.Meta _, C.Sort _) -> t2'
     | (C.Meta _, (C.Meta (_,_) as t))
     | (C.Sort _, (C.Meta (_,_) as t)) when CicUtil.is_closed t ->