]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_proof_checking/cicTypeChecker.ml
new cicEnvironment implementation
[helm.git] / helm / ocaml / cic_proof_checking / cicTypeChecker.ml
index 4035b32172a67f288a18db73b3b55e4a85a9d29a..cab4640c89ecb8d7e73cdd3c61d3fbe3af597375 100644 (file)
@@ -123,7 +123,7 @@ let rec type_of_constant ~logger uri ugraph =
  let module R = CicReduction in
  let module U = UriManager in
  let cobj,ugraph =
-   match CicEnvironment.is_type_checked ~trust:true uri ugraph with
+   match CicEnvironment.is_type_checked ~trust:true ugraph uri with
       CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph'
     | CicEnvironment.UncheckedObj uobj ->
        logger#log (`Start_type_checking uri) ;
@@ -180,7 +180,7 @@ let rec type_of_constant ~logger uri ugraph =
         try
           CicEnvironment.set_type_checking_info uri;
           logger#log (`Type_checking_completed uri) ;
-          match CicEnvironment.is_type_checked ~trust:false uri ugraph with
+          match CicEnvironment.is_type_checked ~trust:false ugraph uri with
                CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph'
              | CicEnvironment.UncheckedObj _ -> raise CicEnvironmentError
         with Invalid_argument s ->
@@ -198,7 +198,7 @@ and type_of_variable ~logger uri ugraph =
  let module R = CicReduction in
  let module U = UriManager in
   (* 0 because a variable is never cooked => no partial cooking at one level *)
-  match CicEnvironment.is_type_checked ~trust:true uri ugraph with
+  match CicEnvironment.is_type_checked ~trust:true ugraph uri with
      CicEnvironment.CheckedObj ((C.Variable (_,_,ty,_)),ugraph') -> ty,ugraph'
    | CicEnvironment.UncheckedObj (C.Variable (_,bo,ty,_)) ->
       logger#log (`Start_type_checking uri) ;
@@ -219,7 +219,7 @@ and type_of_variable ~logger uri ugraph =
        (try
           CicEnvironment.set_type_checking_info uri ;
           logger#log (`Type_checking_completed uri) ;
-          match CicEnvironment.is_type_checked ~trust:false uri ugraph with
+          match CicEnvironment.is_type_checked ~trust:false ugraph uri with
                CicEnvironment.CheckedObj ((C.Variable (_,_,ty,_)),ugraph') -> 
                 ty,ugraph'
             | CicEnvironment.CheckedObj _ 
@@ -404,7 +404,7 @@ and strictly_positive context n nn te =
       List.fold_right (fun x i -> i && does_not_occur context n nn x) tl true
    | C.Appl ((C.MutInd (uri,i,exp_named_subst))::tl) -> 
       let (ok,paramsno,ity,cl,name) =
-       let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+       let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
        match o with
            C.InductiveDefinition (tl,_,paramsno) ->
             let (name,_,ity,cl) = List.nth tl i in
@@ -557,7 +557,7 @@ and type_of_mutual_inductive_defs ~logger uri i ugraph =
  let module R = CicReduction in
  let module U = UriManager in
   let cobj,ugraph1 =
-   match CicEnvironment.is_type_checked ~trust:true uri ugraph with
+   match CicEnvironment.is_type_checked ~trust:true ugraph uri with
        CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph'
      | CicEnvironment.UncheckedObj uobj ->
         logger#log (`Start_type_checking uri) ;
@@ -568,7 +568,7 @@ and type_of_mutual_inductive_defs ~logger uri i ugraph =
           try 
             CicEnvironment.set_type_checking_info uri ;
             logger#log (`Type_checking_completed uri) ;
-            (match CicEnvironment.is_type_checked ~trust:false uri ugraph with
+            (match CicEnvironment.is_type_checked ~trust:false ugraph uri with
                  CicEnvironment.CheckedObj (cobj,ugraph') -> (cobj,ugraph')
                | CicEnvironment.UncheckedObj _ -> raise CicEnvironmentError
             )
@@ -590,7 +590,7 @@ and type_of_mutual_inductive_constr ~logger uri i j ugraph =
  let module R = CicReduction in
  let module U = UriManager in
   let cobj,ugraph1 =
-    match CicEnvironment.is_type_checked ~trust:true uri ugraph with
+    match CicEnvironment.is_type_checked ~trust:true ugraph uri with
        CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph'
       | CicEnvironment.UncheckedObj uobj ->
          logger#log (`Start_type_checking uri) ;
@@ -601,10 +601,11 @@ and type_of_mutual_inductive_constr ~logger uri i j ugraph =
            try
              CicEnvironment.set_type_checking_info uri ;
              logger#log (`Type_checking_completed uri) ;
-             (match CicEnvironment.is_type_checked 
-                ~trust:false uri ugraph with
-                    CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph' 
-                  | CicEnvironment.UncheckedObj _ -> 
+             (match 
+                 CicEnvironment.is_type_checked ~trust:false ugraph uri 
+               with
+                CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph' 
+              | CicEnvironment.UncheckedObj _ -> 
                       raise CicEnvironmentError)
            with
                Invalid_argument s ->
@@ -739,7 +740,7 @@ and check_is_really_smaller_arg ?(subst = []) context n nn kl x safes te =
       (match term with
           C.Rel m when List.mem m safes || m = x ->
            let (tys,len,isinductive,paramsno,cl) =
-           let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+           let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
             match o with
                C.InductiveDefinition (tl,_,paramsno) ->
                 let tys =
@@ -778,7 +779,7 @@ and check_is_really_smaller_arg ?(subst = []) context n nn kl x safes te =
                ) (List.combine pl cl) true
         | C.Appl ((C.Rel m)::tl) when List.mem m safes || m = x ->
            let (tys,len,isinductive,paramsno,cl) =
-            let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+            let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
             match o with
                C.InductiveDefinition (tl,_,paramsno) ->
                 let (_,isinductive,_,cl) = List.nth tl i in
@@ -905,7 +906,7 @@ and guarded_by_destructors ?(subst = []) context n nn kl x safes =
       (match term with
           C.Rel m when List.mem m safes || m = x ->
            let (tys,len,isinductive,paramsno,cl) =
-           let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+           let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
             match o with
                C.InductiveDefinition (tl,_,paramsno) ->
                 let len = List.length tl in
@@ -950,7 +951,7 @@ and guarded_by_destructors ?(subst = []) context n nn kl x safes =
                ) (List.combine pl cl) true
         | C.Appl ((C.Rel m)::tl) when List.mem m safes || m = x ->
            let (tys,len,isinductive,paramsno,cl) =
-           let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+           let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
             match o with
                C.InductiveDefinition (tl,_,paramsno) ->
                 let (_,isinductive,_,cl) = List.nth tl i in
@@ -1063,7 +1064,7 @@ and guarded_by_constructors context n nn h te args coInductiveTypeURI =
       let consty =
        let obj,_ = 
          try 
-           CicEnvironment.get_cooked_obj ~trust:false uri CicUniv.empty_ugraph
+           CicEnvironment.get_cooked_obj ~trust:false CicUniv.empty_ugraph uri
          with Not_found -> assert false
        in
        match obj with
@@ -1250,7 +1251,7 @@ and check_allowed_sort_elimination ~logger context uri i need_dummy ind
    | (C.Sort C.Prop, C.Sort (C.Type _) ) when need_dummy ->
    (* TASSI: da verificare *)
 (*CSC: WRONG. MISSING CONDITIONS ON THE ARGUMENTS OF THE CONSTRUTOR *)
-       (let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+       (let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
         match o with
          C.InductiveDefinition (itl,_,_) ->
            let (_,_,_,cl) = List.nth itl i in
@@ -1270,7 +1271,7 @@ and check_allowed_sort_elimination ~logger context uri i need_dummy ind
    | ((C.Sort C.Set, C.Sort (C.Type _)) | (C.Sort C.CProp, C.Sort (C.Type _)))
       (* TASSI: da verificare *)
       when need_dummy ->
-       (let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+       (let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
         match o with
            C.InductiveDefinition (itl,_,paramsno) ->
             let tys =
@@ -1298,7 +1299,7 @@ and check_allowed_sort_elimination ~logger context uri i need_dummy ind
          (match CicReduction.whd ((Some (name,(C.Decl so)))::context) ta with
            C.Sort C.Prop -> true,ugraph1
          | (C.Sort C.Set | C.Sort C.CProp) ->
-             (let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+             (let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
               match o with
                C.InductiveDefinition (itl,_,_) ->
                    let (_,_,_,cl) = List.nth itl i in
@@ -1324,7 +1325,7 @@ and check_allowed_sort_elimination ~logger context uri i need_dummy ind
          | C.Sort C.CProp -> true,ugraph1
          | C.Sort (C.Type _) ->
              (* TASSI: da verificare *)
-             (let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+             (let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
               match o with
                C.InductiveDefinition (itl,_,paramsno) ->
                  let (_,_,_,cl) = List.nth itl i in
@@ -1722,7 +1723,7 @@ and type_of_aux' ~logger ?(subst = []) metasenv context t ugraph =
       let parsno =
         let obj,_ =
           try
-            CicEnvironment.get_cooked_obj ~trust:false uri CicUniv.empty_ugraph
+            CicEnvironment.get_cooked_obj ~trust:false CicUniv.empty_ugraph uri
           with Not_found -> assert false
         in
         match obj with
@@ -1961,7 +1962,7 @@ and type_of_aux' ~logger ?(subst = []) metasenv context t ugraph =
        (*CSC: definire una funzioncina per questo codice sempre replicato *)
         let obj,_ =
           try
-            CicEnvironment.get_cooked_obj ~trust:false uri CicUniv.empty_ugraph
+            CicEnvironment.get_cooked_obj ~trust:false CicUniv.empty_ugraph uri
           with Not_found -> assert false
         in
         (match obj with
@@ -1974,7 +1975,7 @@ and type_of_aux' ~logger ?(subst = []) metasenv context t ugraph =
               UriManager.string_of_uri uri))
         )
     | C.Appl ((C.MutInd (uri,i,_))::_) ->
-       (let o,_ = CicEnvironment.get_obj uri CicUniv.empty_ugraph in
+       (let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
         match o with
            C.InductiveDefinition (itl,_,_) ->
             let (_,is_inductive,_,_) = List.nth itl i in
@@ -2034,7 +2035,7 @@ let typecheck uri ugraph =
  let module U = UriManager in
  let logger = new CicLogger.logger in
    (* ??? match CicEnvironment.is_type_checked ~trust:true uri with ???? *)
-   match CicEnvironment.is_type_checked ~trust:false uri ugraph with
+   match CicEnvironment.is_type_checked ~trust:false ugraph uri with
      CicEnvironment.CheckedObj (cobj,ugraph') -> 
        (* prerr_endline ("NON-INIZIO A TYPECHECKARE " ^ U.string_of_uri uri);*)
        cobj,ugraph'
@@ -2099,7 +2100,7 @@ let typecheck uri ugraph =
        try
          CicEnvironment.set_type_checking_info uri;
          logger#log (`Type_checking_completed uri);
-         match CicEnvironment.is_type_checked ~trust:false uri ugraph with
+         match CicEnvironment.is_type_checked ~trust:false ugraph uri with
              CicEnvironment.CheckedObj (cobj,ugraph') -> cobj,ugraph'
            | _ -> raise CicEnvironmentError
        with