with
| CicRefine.Uncertain msg ->
debug_print (lazy ("UNCERTAIN!!! [" ^ (Lazy.force msg) ^ "] " ^ CicPp.ppterm term)) ;
- Uncertain (lazy ("Uncertain trying to refine: " ^ CicPp.ppterm term ^ "\n" ^ Lazy.force msg)),ugraph
+ Uncertain (lazy ("Uncertain trying to refine: " ^ CicMetaSubst.ppterm_in_context [] term context ^ "\n" ^ Lazy.force msg)),ugraph
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppterm term) (Lazy.force msg)));
- Ko (lazy ("Error trying to refine: " ^ CicPp.ppterm term ^ "\n" ^ Lazy.force msg)),ugraph
+ Ko (lazy ("Error trying to refine: " ^ CicMetaSubst.ppterm_in_context [] term context ^ "\n" ^ Lazy.force msg)),ugraph
let refine_obj metasenv context uri obj ugraph =
assert (context = []);
List.map (function None -> None | Some t -> Some (um_aux t)) l
in
C.Meta (i,l'))
- | C.Sort _ as t -> t
- | C.Implicit _ -> assert false
+ | C.Sort _
+ | C.Implicit _ as t -> t
| C.Cast (te,ty) -> C.Cast (um_aux te, um_aux ty)
| C.Prod (n,s,t) -> C.Prod (n, um_aux s, um_aux t)
| C.Lambda (n,s,t) -> C.Lambda (n, um_aux s, um_aux t)
let ppterm subst term = CicPp.ppterm (apply_subst subst term)
-let ppterm_in_context subst term name_context =
+let ppterm_in_name_context subst term name_context =
CicPp.pp (apply_subst subst term) name_context
+let ppterm_in_context subst term context =
+ let name_context =
+ List.map (function None -> None | Some (n,_) -> Some n) context
+ in
+ ppterm_in_name_context subst term name_context
+
let ppcontext' ?(sep = "\n") subst context =
let separate s = if s = "" then "" else s ^ sep in
List.fold_right
match context_entry with
Some (n,Cic.Decl t) ->
sprintf "%s%s : %s" (separate i) (CicPp.ppname n)
- (ppterm_in_context subst t name_context), (Some n)::name_context
+ (ppterm_in_name_context subst t name_context), (Some n)::name_context
| Some (n,Cic.Def (bo,ty)) ->
sprintf "%s%s : %s := %s" (separate i) (CicPp.ppname n)
(match ty with
None -> "_"
- | Some ty -> ppterm_in_context subst ty name_context)
- (ppterm_in_context subst bo name_context), (Some n)::name_context
+ | Some ty -> ppterm_in_name_context subst ty name_context)
+ (ppterm_in_name_context subst bo name_context), (Some n)::name_context
| None ->
sprintf "%s_ :? _" (separate i), None::name_context
) context ("",[])
(fun (idx, (c, t,_)) ->
let context,name_context = ppcontext' ~sep:"; " subst c in
sprintf "%s |- ?%d:= %s" context idx
- (ppterm_in_context subst t name_context))
+ (ppterm_in_name_context subst t name_context))
subst)
(*
Printf.sprintf "?%d := %s" idx (CicPp.ppterm term))
(fun (idx, (c, t, _)) ->
let context,name_context = ppcontext' ~sep:"; " [] c in
sprintf "%s |- ?%d:= %s" context idx
- (ppterm_in_context [] t name_context))
+ (ppterm_in_name_context [] t name_context))
subst)
;;
(fun (i, c, t) ->
let context,name_context = ppcontext' ~sep:"; " subst c in
sprintf "%s |- ?%d: %s" context i
- (ppterm_in_context subst t name_context))
+ (ppterm_in_name_context subst t name_context))
(List.filter
(fun (i, _, _) -> not (List.mem_assoc i subst))
metasenv))
exception Uncertain of string Lazy.t;;
exception AssertFailure of string Lazy.t;;
+let verbose = false;;
let debug_print = fun _ -> ()
let profiler_toa = HExtlib.profile "fo_unif_subst.type_of_aux'"
fo_unif_subst false [] context metasenv t1 t2 ugraph ;;
let enrich_msg msg subst context metasenv t1 t2 ugraph =
- lazy
- (sprintf "Unification error unifying %s of type %s with %s of type %s in context\n%s\nand metasenv\n%s\nand substitution\n%s\nbecause %s"
+ lazy (
+ if verbose then
+ sprintf "[Verbose] Unification error unifying %s of type %s with %s of type %s in context\n%s\nand metasenv\n%s\nand substitution\n%s\nbecause %s"
(CicMetaSubst.ppterm subst t1)
(try
let ty_t1,_ = type_of_aux' metasenv subst context t1 ugraph in
| AssertFailure s -> sprintf "MALFORMED(t2): \n<BEGIN>%s\n<END>" (Lazy.force s))
(CicMetaSubst.ppcontext subst context)
(CicMetaSubst.ppmetasenv subst metasenv)
- (CicMetaSubst.ppsubst subst) (Lazy.force msg))
+ (CicMetaSubst.ppsubst subst) (Lazy.force msg)
+ else
+ sprintf "Unification error unifying %s of type %s with %s of type %s in context\n%s\nand metasenv\n%s\nbecause %s"
+ (CicMetaSubst.ppterm_in_context subst t1 context)
+ (try
+ let ty_t1,_ = type_of_aux' metasenv subst context t1 ugraph in
+ CicMetaSubst.ppterm_in_context subst ty_t1 context
+ with
+ | UnificationFailure s
+ | Uncertain s
+ | AssertFailure s -> sprintf "MALFORMED(t1): \n<BEGIN>%s\n<END>" (Lazy.force s))
+ (CicMetaSubst.ppterm_in_context subst t2 context)
+ (try
+ let ty_t2,_ = type_of_aux' metasenv subst context t2 ugraph in
+ CicMetaSubst.ppterm_in_context subst ty_t2 context
+ with
+ | UnificationFailure s
+ | Uncertain s
+ | AssertFailure s -> sprintf "MALFORMED(t2): \n<BEGIN>%s\n<END>" (Lazy.force s))
+ (CicMetaSubst.ppcontext subst context)
+ (CicMetaSubst.ppmetasenv subst metasenv)
+ (Lazy.force msg)
+ )
let fo_unif_subst subst context metasenv t1 t2 ugraph =
try