and presented (in a not understandable way) to the user.
12 files changed:
matitaEngine.cmx: matitacleanLib.cmx matitaTypes.cmx matitaSync.cmx \
matitaMoo.cmx matitaMisc.cmx matitaLog.cmx matitaDisambiguator.cmx \
matitaDb.cmx matitaEngine.cmi
matitaEngine.cmx: matitacleanLib.cmx matitaTypes.cmx matitaSync.cmx \
matitaMoo.cmx matitaMisc.cmx matitaLog.cmx matitaDisambiguator.cmx \
matitaDb.cmx matitaEngine.cmi
-matitaExcPp.cmo: matitaTypes.cmi matitaMoo.cmi matitaExcPp.cmi
-matitaExcPp.cmx: matitaTypes.cmx matitaMoo.cmx matitaExcPp.cmi
+matitaExcPp.cmo: matitaTypes.cmi matitaMoo.cmi matitaDisambiguator.cmi \
+ matitaExcPp.cmi
+matitaExcPp.cmx: matitaTypes.cmx matitaMoo.cmx matitaDisambiguator.cmx \
+ matitaExcPp.cmi
matitaGeneratedGui.cmo: matitaGeneratedGui.cmi
matitaGeneratedGui.cmx: matitaGeneratedGui.cmi
matitaGtkMisc.cmo: matitaTypes.cmi matitaGeneratedGui.cmi matitaGtkMisc.cmi
matitaGeneratedGui.cmo: matitaGeneratedGui.cmi
matitaGeneratedGui.cmx: matitaGeneratedGui.cmi
matitaGtkMisc.cmo: matitaTypes.cmi matitaGeneratedGui.cmi matitaGtkMisc.cmi
matitaLog.cmo \
matitaTypes.cmo \
matitaMoo.cmo \
matitaLog.cmo \
matitaTypes.cmo \
matitaMoo.cmo \
matitaMisc.cmo \
matitaDb.cmo \
matitamakeLib.cmo \
matitaInit.cmo \
matitaSync.cmo \
matitaMisc.cmo \
matitaDb.cmo \
matitamakeLib.cmo \
matitaInit.cmo \
matitaSync.cmo \
matitaDisambiguator.cmo \
matitaDisambiguator.cmo \
+ matitaExcPp.cmo \
+ matitacleanLib.cmo \
matitaEngine.cmo \
matitacLib.cmo \
matitaScript.cmo \
matitaEngine.cmo \
matitacLib.cmo \
matitaScript.cmo \
matitaLog.cmo \
matitaTypes.cmo \
matitaMoo.cmo \
matitaLog.cmo \
matitaTypes.cmo \
matitaMoo.cmo \
matitaMisc.cmo \
matitaDb.cmo \
matitamakeLib.cmo \
matitaInit.cmo \
matitaSync.cmo \
matitaDisambiguator.cmo \
matitaMisc.cmo \
matitaDb.cmo \
matitamakeLib.cmo \
matitaInit.cmo \
matitaSync.cmo \
matitaDisambiguator.cmo \
matitacleanLib.cmo \
matitaEngine.cmo \
matitacLib.cmo \
matitacleanLib.cmo \
matitaEngine.cmo \
matitacLib.cmo \
open MatitaTypes
exception Ambiguous_input
open MatitaTypes
exception Ambiguous_input
+exception DisambiguationError of string Lazy.t list list
type choose_uris_callback =
id:string -> UriManager.uri list -> UriManager.uri list
type choose_uris_callback =
id:string -> UriManager.uri list -> UriManager.uri list
else
drop_aliases_and_clear_diff res
in
else
drop_aliases_and_clear_diff res
in
- | [ pass ] -> set_aliases pass (try_pass pass)
+ | [ pass ] ->
+ (try
+ set_aliases pass (try_pass pass)
+ with Disambiguate.NoWellTypedInterpretation newerrors ->
+ raise (DisambiguationError (errors @ [newerrors])))
| hd :: tl ->
(try
set_aliases hd (try_pass hd)
| hd :: tl ->
(try
set_aliases hd (try_pass hd)
- with Disambiguate.NoWellTypedInterpretation -> aux tl)
+ with Disambiguate.NoWellTypedInterpretation newerrors ->
+ aux (errors @ [newerrors]) tl)
| [] -> assert false
in
let saved_use_coercions = !CoercDb.use_coercions in
try
| [] -> assert false
in
let saved_use_coercions = !CoercDb.use_coercions in
try
- let res = aux passes in
+ let res = aux [] passes in
CoercDb.use_coercions := saved_use_coercions;
res
with exn ->
CoercDb.use_coercions := saved_use_coercions;
res
with exn ->
(** raised when ambiguous input is found but not expected (e.g. in the batch
* compiler) *)
exception Ambiguous_input
(** raised when ambiguous input is found but not expected (e.g. in the batch
* compiler) *)
exception Ambiguous_input
+exception DisambiguationError of string Lazy.t list list
type choose_uris_callback = id:string -> UriManager.uri list -> UriManager.uri list
type choose_interp_callback = (string * string) list list -> int list
type choose_uris_callback = id:string -> UriManager.uri list -> UriManager.uri list
type choose_interp_callback = (string * string) list list -> int list
with
| Cic.MutInd (uri, tyno, _) ->
(GrafiteAst.Type (uri, tyno) :: types)
with
| Cic.MutInd (uri, tyno, _) ->
(GrafiteAst.Type (uri, tyno) :: types)
- | _ -> raise Disambiguate.NoWellTypedInterpretation)
+ | _ -> raise (MatitaDisambiguator.DisambiguationError [[lazy "Decompose works only on inductive types"]]))
in
let types = List.fold_left disambiguate [] types in
GrafiteAst.Decompose (loc, types, what, names)
in
let types = List.fold_left disambiguate [] types in
GrafiteAst.Decompose (loc, types, what, names)
"Type checking error: " ^ Lazy.force msg
| CicTypeChecker.AssertFailure msg ->
"Type checking assertion failed: " ^ Lazy.force msg
"Type checking error: " ^ Lazy.force msg
| CicTypeChecker.AssertFailure msg ->
"Type checking assertion failed: " ^ Lazy.force msg
+ | MatitaDisambiguator.DisambiguationError errorll ->
+ let rec aux n =
+ function
+ [] -> ""
+ | phase::tl ->
+ aux (n+1) tl ^
+ "Errors obtained during phase " ^ string_of_int n ^":\n" ^
+ String.concat "\n" (List.map Lazy.force phase) ^ "\n" ^ "\n"
+ in
+ "DISAMBIGUATION ERROR:\n" ^
+ aux 1 errorll
| exn -> "Uncaught exception: " ^ Printexc.to_string exn
| exn -> "Uncaught exception: " ^ Printexc.to_string exn
open UriManager
exception No_choices of domain_item
open UriManager
exception No_choices of domain_item
-exception NoWellTypedInterpretation
+exception NoWellTypedInterpretation of string Lazy.t list
exception PathNotWellFormed
(** raised when an environment is not enough informative to decide *)
exception PathNotWellFormed
(** raised when an environment is not enough informative to decide *)
+exception Try_again of string Lazy.t
type aliases = bool * DisambiguateTypes.environment
type aliases = bool * DisambiguateTypes.environment
type 'a test_result =
| Ok of 'a * Cic.metasenv
type 'a test_result =
| Ok of 'a * Cic.metasenv
+ | Ko of string Lazy.t
+ | Uncertain of string Lazy.t
let refine_term metasenv context uri term ugraph =
(* if benchmark then incr actual_refinements; *)
let refine_term metasenv context uri term ugraph =
(* if benchmark then incr actual_refinements; *)
with
| CicRefine.Uncertain s ->
debug_print (lazy ("UNCERTAIN!!! [" ^ (Lazy.force s) ^ "] " ^ CicPp.ppterm term)) ;
with
| CicRefine.Uncertain s ->
debug_print (lazy ("UNCERTAIN!!! [" ^ (Lazy.force s) ^ "] " ^ CicPp.ppterm term)) ;
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppterm term) (Lazy.force msg)));
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppterm term) (Lazy.force msg)));
let refine_obj metasenv context uri obj ugraph =
assert (context = []);
let refine_obj metasenv context uri obj ugraph =
assert (context = []);
with
| CicRefine.Uncertain s ->
debug_print (lazy ("UNCERTAIN!!! [" ^ (Lazy.force s) ^ "] " ^ CicPp.ppobj obj)) ;
with
| CicRefine.Uncertain s ->
debug_print (lazy ("UNCERTAIN!!! [" ^ (Lazy.force s) ^ "] " ^ CicPp.ppobj obj)) ;
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppobj obj) (Lazy.force msg))) ;
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppobj obj) (Lazy.force msg))) ;
let resolve (env: codomain_item Environment.t) (item: domain_item) ?(num = "") ?(args = []) () =
try
let resolve (env: codomain_item Environment.t) (item: domain_item) ?(num = "") ?(args = []) () =
try
let (indtype_uri, indtype_no) =
match indty_ident with
| Some (indty_ident, _) ->
let (indtype_uri, indtype_no) =
match indty_ident with
| Some (indty_ident, _) ->
- (match resolve env (Id indty_ident) () with
+ (match resolve env (Id indty_ident) () with
| Cic.MutInd (uri, tyno, _) -> (uri, tyno)
| Cic.MutInd (uri, tyno, _) -> (uri, tyno)
- | Cic.Implicit _ -> raise Try_again
- | _ -> raise Invalid_choice)
+ | Cic.Implicit _ ->
+ raise (Try_again (lazy "The type of the term to be matched
+ is still unknown"))
+ | _ ->
+ raise (Invalid_choice (lazy "The type of the term to be matched is not (co)inductive!")))
| None ->
let fst_constructor =
match branches with
| ((head, _, _), _) :: _ -> head
| None ->
let fst_constructor =
match branches with
| ((head, _, _), _) :: _ -> head
- | [] -> raise Invalid_choice
+ | [] -> raise (Invalid_choice (lazy "The type of the term to be matched is an inductive type without constructors that cannot be determined"))
in
(match resolve env (Id fst_constructor) () with
| Cic.MutConstruct (indtype_uri, indtype_no, _, _) ->
(indtype_uri, indtype_no)
in
(match resolve env (Id fst_constructor) () with
| Cic.MutConstruct (indtype_uri, indtype_no, _, _) ->
(indtype_uri, indtype_no)
- | Cic.Implicit _ -> raise Try_again
- | _ -> raise Invalid_choice)
+ | Cic.Implicit _ ->
+ raise (Try_again (lazy "The type of the term to be matched
+ is still unknown"))
+ | _ ->
+ raise (Invalid_choice (lazy "The type of the term to be matched is not (co)inductive!")))
in
Cic.MutCase (indtype_uri, indtype_no, cic_outtype, cic_term,
(List.map do_branch branches))
in
Cic.MutCase (indtype_uri, indtype_no, cic_outtype, cic_term,
(List.map do_branch branches))
(try
List.assoc s ids_to_uris, aux loc context term
with Not_found ->
(try
List.assoc s ids_to_uris, aux loc context term
with Not_found ->
+ raise (Invalid_choice (lazy "The provided explicit named substitution is trying to instantiate a named variable the object is not abstracted on"))))
subst
| None -> List.map (fun uri -> uri, Cic.Implicit None) uris)
in
subst
| None -> List.map (fun uri -> uri, Cic.Implicit None) uris)
in
+ raise (Invalid_choice (lazy "??? Can this happen?"))
with
CicEnvironment.CircularDependency _ ->
with
CicEnvironment.CircularDependency _ ->
+ raise (Invalid_choice (lazy "Circular dependency in the environment"))))
| CicNotationPt.Implicit -> Cic.Implicit None
| CicNotationPt.UserInput -> Cic.Implicit (Some `Hole)
| CicNotationPt.Num (num, i) -> resolve env (Num i) ~num ()
| CicNotationPt.Implicit -> Cic.Implicit None
| CicNotationPt.UserInput -> Cic.Implicit (Some `Hole)
| CicNotationPt.Num (num, i) -> resolve env (Num i) ~num ()
(k , ugraph1 )
in refine_profiler.HExtlib.profile foo ()
with
(k , ugraph1 )
in refine_profiler.HExtlib.profile foo ()
with
- | Try_again -> Uncertain, ugraph
- | Invalid_choice -> Ko, ugraph
+ | Try_again msg -> Uncertain msg, ugraph
+ | Invalid_choice msg -> Ko msg, ugraph
in
(* (4) build all possible interpretations *)
in
(* (4) build all possible interpretations *)
+ let (@@) (l1,l2) (l1',l2') = l1@l1, l2@l2' in
let rec aux aliases diff lookup_in_todo_dom todo_dom base_univ =
match todo_dom with
| [] ->
assert (lookup_in_todo_dom = None);
(match test_env aliases [] base_univ with
| Ok (thing, metasenv),new_univ ->
let rec aux aliases diff lookup_in_todo_dom todo_dom base_univ =
match todo_dom with
| [] ->
assert (lookup_in_todo_dom = None);
(match test_env aliases [] base_univ with
| Ok (thing, metasenv),new_univ ->
- [ aliases, diff, metasenv, thing, new_univ ]
- | Ko,_ | Uncertain,_ -> [])
+ [ aliases, diff, metasenv, thing, new_univ ], []
+ | Ko msg,_ | Uncertain msg,_ -> [],[msg])
| item :: remaining_dom ->
debug_print (lazy (sprintf "CHOOSED ITEM: %s"
(string_of_domain_item item)));
| item :: remaining_dom ->
debug_print (lazy (sprintf "CHOOSED ITEM: %s"
(string_of_domain_item item)));
None -> lookup_choices item
| Some choices -> choices in
match choices with
None -> lookup_choices item
| Some choices -> choices in
match choices with
+ [] -> [], [lazy "No choices"]
| [codomain_item] ->
(* just one choice. We perform a one-step look-up and
if the next set of choices is also a singleton we
| [codomain_item] ->
(* just one choice. We perform a one-step look-up and
if the next set of choices is also a singleton we
(match test_env new_env remaining_dom base_univ with
| Ok (thing, metasenv),new_univ ->
(match remaining_dom with
(match test_env new_env remaining_dom base_univ with
| Ok (thing, metasenv),new_univ ->
(match remaining_dom with
- | [] -> [ new_env, new_diff, metasenv, thing, new_univ ]
+ | [] ->
+ [ new_env, new_diff, metasenv, thing, new_univ ], []
| _ ->
aux new_env new_diff lookup_in_todo_dom
remaining_dom new_univ)
| _ ->
aux new_env new_diff lookup_in_todo_dom
remaining_dom new_univ)
- | Uncertain,new_univ ->
+ | Uncertain msg,new_univ ->
(match remaining_dom with
(match remaining_dom with
| _ ->
aux new_env new_diff lookup_in_todo_dom
remaining_dom new_univ)
| _ ->
aux new_env new_diff lookup_in_todo_dom
remaining_dom new_univ)
+ | Ko msg,_ -> [], [msg])
| _::_ ->
let rec filter univ = function
| _::_ ->
let rec filter univ = function
| codomain_item :: tl ->
debug_print(lazy (sprintf "%s CHOSEN" (fst codomain_item)));
let new_env = Environment.add item codomain_item aliases in
| codomain_item :: tl ->
debug_print(lazy (sprintf "%s CHOSEN" (fst codomain_item)));
let new_env = Environment.add item codomain_item aliases in
(match test_env new_env remaining_dom univ with
| Ok (thing, metasenv),new_univ ->
(match remaining_dom with
(match test_env new_env remaining_dom univ with
| Ok (thing, metasenv),new_univ ->
(match remaining_dom with
- | [] -> [ new_env, new_diff, metasenv, thing, new_univ ]
+ | [] -> [ new_env, new_diff, metasenv, thing, new_univ ], []
| _ -> aux new_env new_diff None remaining_dom new_univ
| _ -> aux new_env new_diff None remaining_dom new_univ
- | Uncertain,new_univ ->
+ | Uncertain msg,new_univ ->
(match remaining_dom with
(match remaining_dom with
| _ -> aux new_env new_diff None remaining_dom new_univ
| _ -> aux new_env new_diff None remaining_dom new_univ
- | Ko,_ -> filter univ tl)
+ | Ko msg,_ -> ([],[msg]) @@ filter univ tl)
in
filter base_univ choices
in
in
filter base_univ choices
in
try
let res =
match aux aliases [] None todo_dom base_univ with
try
let res =
match aux aliases [] None todo_dom base_univ with
- | [] -> raise NoWellTypedInterpretation
- | [_,diff,metasenv,t,ugraph] ->
+ | [],errors -> raise (NoWellTypedInterpretation errors)
+ | [_,diff,metasenv,t,ugraph],_ ->
debug_print (lazy "SINGLE INTERPRETATION");
[diff,metasenv,t,ugraph], false
debug_print (lazy "SINGLE INTERPRETATION");
[diff,metasenv,t,ugraph], false
debug_print (lazy (sprintf "MANY INTERPRETATIONS (%d)" (List.length l)));
let choices =
List.map
debug_print (lazy (sprintf "MANY INTERPRETATIONS (%d)" (List.length l)));
let choices =
List.map
(** {2 Disambiguation interface} *)
(** {2 Disambiguation interface} *)
-exception NoWellTypedInterpretation
+exception NoWellTypedInterpretation of string Lazy.t list
exception PathNotWellFormed
val interpretate_path :
exception PathNotWellFormed
val interpretate_path :
in
try
List.combine names cic_args
in
try
List.combine names cic_args
- with Invalid_argument _ -> raise Invalid_choice
+ with Invalid_argument _ ->
+ raise (Invalid_choice (lazy "The notation expects a different number of arguments"))
in
CicNotationFwd.instantiate_appl_pattern env' appl_pattern)
in
CicNotationFwd.instantiate_appl_pattern env' appl_pattern)
| Symbol of string * int (* literal, instance num *)
| Num of int (* instance num *)
| Symbol of string * int (* literal, instance num *)
| Num of int (* instance num *)
-exception Invalid_choice
+exception Invalid_choice of string Lazy.t
module OrderedDomain =
struct
module OrderedDomain =
struct
(** to be raised when a choice is invalid due to some given parameter (e.g.
* wrong number of Cic.term arguments received) *)
(** to be raised when a choice is invalid due to some given parameter (e.g.
* wrong number of Cic.term arguments received) *)
-exception Invalid_choice
+exception Invalid_choice of string Lazy.t
type codomain_item =
string * (* description *)
type codomain_item =
string * (* description *)
(fun _ num _ ->
let num = int_of_string num in
if num = 0 then
(fun _ num _ ->
let num = int_of_string num in
if num = 0 then
- raise DisambiguateTypes.Invalid_choice
+ raise (DisambiguateTypes.Invalid_choice (lazy "0 is not a valid positive number"))
else
HelmLibraryObjects.build_bin_pos num));
DisambiguateChoices.add_num_choice
else
HelmLibraryObjects.build_bin_pos num));
DisambiguateChoices.add_num_choice