* http://cs.unibo.it/helm/.
*)
-exception NotImplemented;;
exception Impossible of int;;
exception NotWellTyped of string;;
exception WrongUriToConstant of string;;
exception NotWellFormedTypeOfInductiveConstructor of string;;
exception WrongRequiredArgument of string;;
-let log =
- let module U = UriManager in
- let indent = ref 0 in
- function
- `Start_type_checking uri ->
- print_string (
- (String.make !indent ' ') ^
- "<div style=\"margin-left: " ^
- string_of_float (float_of_int !indent *. 0.5) ^ "cm\">" ^
- "Type-Checking of " ^ (U.string_of_uri uri) ^ " started</div>\n"
- ) ;
- flush stdout ;
- incr indent
- | `Type_checking_completed uri ->
- decr indent ;
- print_string (
- (String.make !indent ' ') ^
- "<div style=\"color: green ; margin-left: " ^
- string_of_float (float_of_int !indent *. 0.5) ^ "cm\">" ^
- "Type-Checking of " ^ (U.string_of_uri uri) ^ " completed.</div>\n"
- ) ;
- flush stdout
-;;
-
let fdebug = ref 0;;
let debug t env =
let rec debug_aux t i =
match CicEnvironment.is_type_checked uri cookingsno with
CicEnvironment.CheckedObj cobj -> cobj
| CicEnvironment.UncheckedObj uobj ->
- log (`Start_type_checking uri) ;
+ Logger.log (`Start_type_checking uri) ;
(* let's typecheck the uncooked obj *)
(match uobj with
C.Definition (_,te,ty,_) ->
| C.Axiom (_,ty,_) ->
(* only to check that ty is well-typed *)
let _ = type_of ty in ()
- | C.CurrentProof (_,_,te,ty) ->
- let _ = type_of ty in
- if not (R.are_convertible (type_of te) ty) then
+ | C.CurrentProof (_,conjs,te,ty) ->
+ let _ = type_of_aux' conjs [] ty in
+ if not (R.are_convertible (type_of_aux' conjs [] te) ty) then
raise (NotWellTyped ("CurrentProof" ^ (U.string_of_uri uri)))
| _ -> raise (WrongUriToConstant (U.string_of_uri uri))
) ;
CicEnvironment.set_type_checking_info uri ;
- log (`Type_checking_completed uri) ;
+ Logger.log (`Type_checking_completed uri) ;
match CicEnvironment.is_type_checked uri cookingsno with
CicEnvironment.CheckedObj cobj -> cobj
| CicEnvironment.UncheckedObj _ -> raise CicEnvironmentError
match CicEnvironment.is_type_checked uri 0 with
CicEnvironment.CheckedObj (C.Variable (_,_,ty)) -> ty
| CicEnvironment.UncheckedObj (C.Variable (_,bo,ty)) ->
- log (`Start_type_checking uri) ;
+ Logger.log (`Start_type_checking uri) ;
(* only to check that ty is well-typed *)
let _ = type_of ty in
(match bo with
raise (NotWellTyped ("Variable " ^ (U.string_of_uri uri)))
) ;
CicEnvironment.set_type_checking_info uri ;
- log (`Type_checking_completed uri) ;
+ Logger.log (`Type_checking_completed uri) ;
ty
| _ -> raise (WrongUriToVariable (UriManager.string_of_uri uri))
match CicEnvironment.is_type_checked uri cookingsno with
CicEnvironment.CheckedObj cobj -> cobj
| CicEnvironment.UncheckedObj uobj ->
- log (`Start_type_checking uri) ;
+ Logger.log (`Start_type_checking uri) ;
cooked_mutual_inductive_defs uri uobj ;
CicEnvironment.set_type_checking_info uri ;
- log (`Type_checking_completed uri) ;
+ Logger.log (`Type_checking_completed uri) ;
(match CicEnvironment.is_type_checked uri cookingsno with
CicEnvironment.CheckedObj cobj -> cobj
| CicEnvironment.UncheckedObj _ -> raise CicEnvironmentError
match CicEnvironment.is_type_checked uri cookingsno with
CicEnvironment.CheckedObj cobj -> cobj
| CicEnvironment.UncheckedObj uobj ->
- log (`Start_type_checking uri) ;
+ Logger.log (`Start_type_checking uri) ;
cooked_mutual_inductive_defs uri uobj ;
CicEnvironment.set_type_checking_info uri ;
- log (`Type_checking_completed uri) ;
+ Logger.log (`Type_checking_completed uri) ;
(match CicEnvironment.is_type_checked uri cookingsno with
CicEnvironment.CheckedObj cobj -> cobj
| CicEnvironment.UncheckedObj _ -> raise CicEnvironmentError
(* type_of_aux' is just another name (with a different scope) for type_of_aux *)
-and type_of_aux' env t =
+and type_of_aux' metasenv env t =
let rec type_of_aux env =
let module C = Cic in
let module R = CicReduction in
let ty = type_of_variable uri in
decr fdebug ;
ty
- | C.Meta n -> raise NotImplemented
+ | C.Meta n -> List.assoc n metasenv
| C.Sort s -> C.Sort C.Type (*CSC manca la gestione degli universi!!! *)
| C.Implicit -> raise (Impossible 21)
| C.Cast (te,ty) ->
let module C = Cic in
match CicReduction.whd c with
C.Prod (_,so,de) ->
- let s = type_of_aux' env so in
+ (*CSC: [] is an empty metasenv. Is it correct? *)
+ let s = type_of_aux' [] env so in
(s = C.Sort C.Prop || s = C.Sort C.Set) &&
is_small_aux (so::env) de
| _ -> true (*CSC: we trust the type-checker *)
is_small_aux (List.rev sx) dx
and type_of t =
- type_of_aux' [] t
+ type_of_aux' [] [] t
;;
let typecheck uri =
CicEnvironment.CheckedObj _ -> ()
| CicEnvironment.UncheckedObj uobj ->
(* let's typecheck the uncooked object *)
- log (`Start_type_checking uri) ;
+ Logger.log (`Start_type_checking uri) ;
(match uobj with
C.Definition (_,te,ty,_) ->
let _ = type_of ty in
| C.Axiom (_,ty,_) ->
(* only to check that ty is well-typed *)
let _ = type_of ty in ()
- | C.CurrentProof (_,_,te,ty) ->
- (*CSC [] wrong *)
- let _ = type_of ty in
- debug (type_of te) [] ;
- if not (R.are_convertible (type_of te) ty) then
- raise (NotWellTyped ("CurrentProof" ^ (U.string_of_uri uri)))
+ | C.CurrentProof (_,conjs,te,ty) ->
+ (*CSC [] wrong *)
+ let _ = type_of_aux' conjs [] ty in
+ debug (type_of_aux' conjs [] te) [] ;
+ if not (R.are_convertible (type_of_aux' conjs [] te) ty) then
+ raise (NotWellTyped ("CurrentProof" ^ (U.string_of_uri uri)))
| C.Variable (_,bo,ty) ->
(* only to check that ty is well-typed *)
let _ = type_of ty in
cooked_mutual_inductive_defs uri uobj
) ;
CicEnvironment.set_type_checking_info uri ;
- log (`Type_checking_completed uri)
+ Logger.log (`Type_checking_completed uri)
;;
+