raise (Try_again (lazy "The type of the term to be matched
is still unknown"))
| _ ->
- raise (Invalid_choice (Some loc, lazy "The type of the term to be matched is not (co)inductive!")))
+ raise (Invalid_choice (lazy (loc,"The type of the term to be matched is not (co)inductive!"))))
| None ->
let rec fst_constructor =
function
(Ast.Pattern (head, _, _), _) :: _ -> head
| (Ast.Wildcard, _) :: tl -> fst_constructor tl
- | [] -> raise (Invalid_choice (Some loc, lazy "The type of the term to be matched cannot be determined because it is an inductive type without constructors or because all patterns use wildcards"))
+ | [] -> raise (Invalid_choice (lazy (loc,"The type of the term to be matched cannot be determined because it is an inductive type without constructors or because all patterns use wildcards")))
in
(match resolve env (Id (fst_constructor branches)) () with
| Cic.MutConstruct (indtype_uri, indtype_no, _, _) ->
raise (Try_again (lazy "The type of the term to be matched
is still unknown"))
| _ ->
- raise (Invalid_choice (Some loc, lazy "The type of the term to be matched is not (co)inductive!")))
+ raise (Invalid_choice (lazy (loc,"The type of the term to be matched is not (co)inductive!"))))
in
let branches =
if create_dummy_ids then
(function
Ast.Wildcard,term -> ("wildcard",None,[]), term
| Ast.Pattern _,_ ->
- raise (Invalid_choice (Some loc, lazy "Syntax error: the left hand side of a branch patterns must be \"_\""))
+ raise (Invalid_choice (lazy (loc, "Syntax error: the left hand side of a branch patterns must be \"_\"")))
) branches
else
match fst(CicEnvironment.get_obj CicUniv.oblivion_ugraph indtype_uri) with
[] ->
if unrecognized != [] then
raise (Invalid_choice
- (Some loc,
- lazy
+ (lazy (loc,
("Unrecognized constructors: " ^
- String.concat " " unrecognized)))
+ String.concat " " unrecognized))))
else if useless > 0 then
raise (Invalid_choice
- (Some loc,
- lazy
+ (lazy (loc,
("The last " ^ string_of_int useless ^
"case" ^ if useless > 1 then "s are" else " is" ^
- " unused")))
+ " unused"))))
else
[]
| (Ast.Wildcard,_)::tl when not unused ->
[] ->
raise
(Invalid_choice
- (Some loc, lazy ("Missing case: " ^ name)))
+ (lazy (loc, ("Missing case: " ^ name))))
| ((Ast.Wildcard, _) as branch :: _) as branches ->
branch, branches
| (Ast.Pattern (name',_,_),_) as branch :: tl
else
raise
(Invalid_choice
- (Some loc,
- lazy ("Wrong number of arguments for " ^ name)))
+ (lazy (loc,"Wrong number of arguments for " ^
+ name)))
| Ast.Wildcard,term ->
let rec mk_lambdas =
function
(try
List.assoc s ids_to_uris, aux ~localize loc context term
with Not_found ->
- raise (Invalid_choice (Some loc, lazy "The provided explicit named substitution is trying to instantiate a named variable the object is not abstracted on"))))
+ raise (Invalid_choice (lazy (loc, "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
*)
t
| _ ->
- raise (Invalid_choice (Some loc, lazy "??? Can this happen?"))
+ raise (Invalid_choice (lazy (loc, "??? Can this happen?")))
with
CicEnvironment.CircularDependency _ ->
- raise (Invalid_choice (None, lazy "Circular dependency in the environment"))))
+ raise (Invalid_choice (lazy (loc,"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 ()
in refine_profiler.HExtlib.profile foo ()
with
| Try_again msg -> Uncertain (lazy (Stdpp.dummy_loc,Lazy.force msg))
- | Invalid_choice (None,msg) -> Ko(lazy (Stdpp.dummy_loc,Lazy.force msg))
- | Invalid_choice (Some loc,msg) -> Ko (lazy (loc,Lazy.force msg))
+ | Invalid_choice loc_msg -> Ko loc_msg
in
(* (4) build all possible interpretations *)
let (@@) (l1,l2,l3) (l1',l2',l3') = l1@l1', l2@l2', l3@l3' in
let debug_print _ = ();;
+let cic_name_of_name = function
+ | Ast.Ident (n, None) -> n
+ | _ -> assert false
+;;
+
let refine_term metasenv subst context uri term _ ~localization_tbl =
assert (uri=None);
debug_print (lazy (sprintf "TEST_INTERPRETATION: %s"
in
Disambiguate.Ok (term, metasenv, subst, ())
with
- | NCicRefiner.Uncertain (msg) ->
- debug_print (lazy ("UNCERTAIN: [" ^ snd (Lazy.force msg) ^ "] " ^
+ | NCicRefiner.Uncertain loc_msg ->
+ debug_print (lazy ("UNCERTAIN: [" ^ snd (Lazy.force loc_msg) ^ "] " ^
NCicPp.ppterm ~metasenv ~subst ~context term)) ;
- Disambiguate.Uncertain (loc,msg)
- | NCicRefiner.RefineFailure (msg) ->
+ Disambiguate.Uncertain loc_msg
+ | NCicRefiner.RefineFailure loc_msg ->
debug_print (lazy (sprintf "PRUNED:\nterm%s\nmessage:%s"
- (NCicPp.ppterm ~metasenv ~subst ~context term) (snd(Lazy.force msg))));
- Disambiguate.Ko (loc,msg,())
+ (NCicPp.ppterm ~metasenv ~subst ~context term) (snd(Lazy.force loc_msg))));
+ Disambiguate.Ko loc_msg
;;
let resolve (env: codomain_item Environment.t) (item: domain_item) ?(num = "") ?(args = []) () =
+ assert false;;
+(*
try
snd (Environment.find item env) env num args
with Not_found ->
failwith ("Domain item not found: " ^
(DisambiguateTypes.string_of_domain_item item))
+*)
(* TODO move it to Cic *)
let find_in_context name context =
let rec aux ~localize loc context = function
| CicNotationPt.AttributedTerm (`Loc loc, term) ->
let res = aux ~localize loc context term in
- if localize then NCic.NCicHash.add localization_tbl res loc;
+ if localize then NCicUntrusted.NCicHash.add localization_tbl res loc;
res
| CicNotationPt.AttributedTerm (_, term) -> aux ~localize loc context term
| CicNotationPt.Appl (CicNotationPt.Symbol (symb, i) :: args) ->
NCic.Appl (List.map (aux ~localize loc context) terms)
| CicNotationPt.Binder (binder_kind, (var, typ), body) ->
let cic_type = aux_option ~localize loc context (Some `Type) typ in
- let cic_name = CicNotationUtil.cic_name_of_name var in
+ let cic_name = cic_name_of_name var in
let cic_body = aux ~localize loc (cic_name :: context) body in
(match binder_kind with
| `Lambda -> NCic.Lambda (cic_name, cic_type, cic_body)
let rec do_branch' context = function
| [] -> aux ~localize loc context term
| (name, typ) :: tl ->
- let cic_name = CicNotationUtil.cic_name_of_name name in
+ let cic_name = cic_name_of_name name in
let cic_body = do_branch' (cic_name :: context) tl in
let typ =
match typ with
- | None -> NCic.Implicit (Some `Type)
+ | None -> NCic.Implicit `Type
| Some typ -> aux ~localize loc context typ
in
NCic.Lambda (cic_name, typ, cic_body)
match indty_ident with
| Some (indty_ident, _) ->
(match resolve env (Id indty_ident) () with
- | NCic.MutInd (uri, tyno, _) -> (uri, tyno)
+ | NCic.Const (NRef.Ref (uri, NRef.Ind (_, tyno))) -> (uri, tyno)
| NCic.Implicit _ ->
- raise (Disambiguate.Try_again (lazy "The type of the term to be matched
- is still unknown"))
+ raise (Disambiguate.Try_again
+ (lazy "The type of the term to be matched is still unknown"))
| _ ->
- raise (DisambiguateTypes.Invalid_choice (Some loc, lazy "The type of the term to be matched is not (co)inductive!")))
+ raise (DisambiguateTypes.Invalid_choice
+ (Some loc,
+ lazy "The type of the term to be matched is not (co)inductive!")))
| None ->
let rec fst_constructor =
function
NCic.Cast (cic_t1, cic_t2)
| CicNotationPt.LetIn ((name, typ), def, body) ->
let cic_def = aux ~localize loc context def in
- let cic_name = CicNotationUtil.cic_name_of_name name in
+ let cic_name = cic_name_of_name name in
let cic_typ =
match typ with
| None -> NCic.Implicit (Some `Type)
let context' =
List.fold_left
(fun acc (_, (name, _), _, _) ->
- CicNotationUtil.cic_name_of_name name :: acc)
+ cic_name_of_name name :: acc)
context defs
in
let cic_body =
aux_option ~localize loc context (Some `Type)
(HExtlib.map_option (add_binders `Pi) typ) in
let name =
- match CicNotationUtil.cic_name_of_name name with
+ match cic_name_of_name name with
| NCic.Anonymous ->
CicNotationPt.fail loc
"Recursive functions cannot be anonymous"