summaryrefslogtreecommitdiff
path: root/printing/printer.ml
diff options
context:
space:
mode:
authorGravatar Enrico Tassi <gareuselesinge@debian.org>2015-11-13 11:31:34 +0100
committerGravatar Enrico Tassi <gareuselesinge@debian.org>2015-11-13 11:31:34 +0100
commit2280477a96e19ba5060de2d48dcc8fd7c8079d22 (patch)
tree074182834cb406d1304aec4233718564a9c06ba1 /printing/printer.ml
parent0aa2544d04dbd4b6ee665b551ed165e4fb02d2fa (diff)
Imported Upstream version 8.5~beta3+dfsg
Diffstat (limited to 'printing/printer.ml')
-rw-r--r--printing/printer.ml99
1 files changed, 83 insertions, 16 deletions
diff --git a/printing/printer.ml b/printing/printer.ml
index 0d3a1c17..2e112f9a 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -208,10 +208,10 @@ let safe_pr_constr t =
let (sigma, env) = get_current_context () in
safe_pr_constr_env env sigma t
-let pr_universe_ctx c =
+let pr_universe_ctx sigma c =
if !Detyping.print_universes && not (Univ.UContext.is_empty c) then
fnl()++pr_in_comment (fun c -> v 0
- (Univ.pr_universe_context Universes.pr_with_global_universes c)) c
+ (Univ.pr_universe_context (Evd.pr_evd_level sigma) c)) c
else
mt()
@@ -455,14 +455,17 @@ let pr_ne_evar_set hd tl sigma l =
else
mt ()
+let pr_selected_subgoal name sigma g =
+ let pg = default_pr_goal { sigma=sigma ; it=g; } in
+ v 0 (str "subgoal " ++ name ++ pr_goal_tag g ++ pr_goal_name sigma g
+ ++ str " is:" ++ cut () ++ pg)
+
let default_pr_subgoal n sigma =
let rec prrec p = function
| [] -> error "No such goal."
| g::rest ->
if Int.equal p 1 then
- let pg = default_pr_goal { sigma=sigma ; it=g; } in
- v 0 (str "subgoal " ++ int n ++ pr_goal_tag g ++ pr_goal_name sigma g
- ++ str " is:" ++ cut () ++ pg)
+ pr_selected_subgoal (int n) sigma g
else
prrec (p-1) rest
in
@@ -559,8 +562,8 @@ let default_pr_subgoals ?(pr_first=true) close_cmd sigma seeds shelf stack goals
++ emacs_print_dependent_evars sigma seeds)
else
let pei = pr_evars_int sigma 1 exl in
- (str "No more subgoals but non-instantiated existential " ++
- str "variables:" ++ fnl () ++ (hov 0 pei)
+ (str "No more subgoals, but there are non-instantiated existential variables:"
+ ++ fnl () ++ (hov 0 pei)
++ emacs_print_dependent_evars sigma seeds ++ fnl () ++
str "You can use Grab Existential Variables.")
end
@@ -625,17 +628,17 @@ let pr_open_subgoals ?(proof=Proof_global.give_me_the_proof ()) () =
begin match bgoals,shelf,given_up with
| [] , [] , [] -> pr_subgoals None sigma seeds shelf stack goals
| [] , [] , _ ->
- msg_info (str "No more goals, however there are goals you gave up. You need to go back and solve them.");
+ msg_info (str "No more subgoals, but there are some goals you gave up:");
fnl ()
++ pr_subgoals ~pr_first:false None bsigma seeds [] [] given_up
+ ++ fnl () ++ str "You need to go back and solve them."
| [] , _ , _ ->
msg_info (str "All the remaining goals are on the shelf.");
fnl ()
++ pr_subgoals ~pr_first:false None bsigma seeds [] [] shelf
| _ , _, _ ->
let end_cmd =
- strbrk "This subproof is complete, but there are still \
- unfocused goals." ++
+ str "This subproof is complete, but there are some unfocused goals." ++
(match Proof_global.Bullet.suggest p
with None -> str"" | Some s -> fnl () ++ str s) ++
fnl ()
@@ -652,9 +655,17 @@ let pr_nth_open_subgoal n =
let pr_goal_by_id id =
let p = Proof_global.give_me_the_proof () in
- let g = Goal.get_by_uid id in
+ try
+ Proof.in_proof p (fun sigma ->
+ let g = Evd.evar_key id sigma in
+ pr_selected_subgoal (pr_id id) sigma g)
+ with Not_found -> error "No such goal."
+
+let pr_goal_by_uid uid =
+ let p = Proof_global.give_me_the_proof () in
+ let g = Goal.get_by_uid uid in
let pr gs =
- v 0 (str ("goal / evar " ^ id ^ " is:") ++ cut ()
+ v 0 (str "goal / evar " ++ str uid ++ str " is:" ++ cut ()
++ pr_goal gs)
in
try
@@ -713,31 +724,72 @@ let prterm = pr_lconstr
(* Printer function for sets of Assumptions.assumptions.
It is used primarily by the Print Assumptions command. *)
-open Assumptions
+type context_object =
+ | Variable of Id.t (* A section variable or a Let definition *)
+ | Axiom of constant * (Label.t * Context.rel_context * types) list
+ | Opaque of constant (* An opaque constant. *)
+ | Transparent of constant
+
+(* Defines a set of [assumption] *)
+module OrderedContextObject =
+struct
+ type t = context_object
+ let compare x y =
+ match x , y with
+ | Variable i1 , Variable i2 -> Id.compare i1 i2
+ | Axiom (k1,_) , Axiom (k2, _) -> con_ord k1 k2
+ | Opaque k1 , Opaque k2 -> con_ord k1 k2
+ | Transparent k1 , Transparent k2 -> con_ord k1 k2
+ | Axiom _ , Variable _ -> 1
+ | Opaque _ , Variable _
+ | Opaque _ , Axiom _ -> 1
+ | Transparent _ , Variable _
+ | Transparent _ , Axiom _
+ | Transparent _ , Opaque _ -> 1
+ | _ , _ -> -1
+end
+
+module ContextObjectSet = Set.Make (OrderedContextObject)
+module ContextObjectMap = Map.Make (OrderedContextObject)
let pr_assumptionset env s =
- if ContextObjectMap.is_empty s then
+ if ContextObjectMap.is_empty s &&
+ engagement env = (PredicativeSet, StratifiedType) then
str "Closed under the global context"
else
let safe_pr_constant env kn =
try pr_constant env kn
with Not_found ->
let mp,_,lab = repr_con kn in
- str (string_of_mp mp ^ "." ^ Label.to_string lab)
+ str (string_of_mp mp) ++ str "." ++ pr_label lab
in
let safe_pr_ltype typ =
try str " : " ++ pr_ltype typ
with e when Errors.noncritical e -> mt ()
in
+ let safe_pr_ltype_relctx (rctx, typ) =
+ let sigma, env = get_current_context () in
+ let env = Environ.push_rel_context rctx env in
+ try str " " ++ pr_ltype_env env sigma typ
+ with e when Errors.noncritical e -> mt ()
+ in
let fold t typ accu =
let (v, a, o, tr) = accu in
match t with
| Variable id ->
let var = str (Id.to_string id) ++ str " : " ++ pr_ltype typ in
(var :: v, a, o, tr)
- | Axiom kn ->
+ | Axiom (kn,[]) ->
let ax = safe_pr_constant env kn ++ safe_pr_ltype typ in
(v, ax :: a, o, tr)
+ | Axiom (kn,l) ->
+ let ax = safe_pr_constant env kn ++ safe_pr_ltype typ ++
+ cut() ++
+ prlist_with_sep cut (fun (lbl, ctx, ty) ->
+ str " used in " ++ str (Names.Label.to_string lbl) ++
+ str " to prove:" ++ safe_pr_ltype_relctx (ctx,ty))
+ l in
+ (v, ax :: a, o, tr)
| Opaque kn ->
let opq = safe_pr_constant env kn ++ safe_pr_ltype typ in
(v, a, opq :: o, tr)
@@ -748,6 +800,16 @@ let pr_assumptionset env s =
let (vars, axioms, opaque, trans) =
ContextObjectMap.fold fold s ([], [], [], [])
in
+ let theory =
+ if is_impredicative_set env then
+ [str "Set is impredicative"]
+ else []
+ in
+ let theory =
+ if type_in_type env then
+ str "Type hierarchy is collapsed (logic is inconsistent)" :: theory
+ else theory
+ in
let opt_list title = function
| [] -> None
| l ->
@@ -761,6 +823,7 @@ let pr_assumptionset env s =
opt_list (str "Section Variables:") vars;
opt_list (str "Axioms:") axioms;
opt_list (str "Opaque constants:") opaque;
+ opt_list (str "Theory:") theory;
] in
prlist_with_sep fnl (fun x -> x) (Option.List.flatten assums)
@@ -773,3 +836,7 @@ let pr_polymorphic b =
if b then str"Polymorphic " else str"Monomorphic "
else mt ()
+let pr_universe_instance evd ctx =
+ let inst = Univ.UContext.instance ctx in
+ str"@{" ++ Univ.Instance.pr (Evd.pr_evd_level evd) inst ++ str"}"
+