aboutsummaryrefslogtreecommitdiff
path: root/printing
diff options
context:
space:
mode:
Diffstat (limited to 'printing')
-rw-r--r--printing/ppconstr.ml15
-rw-r--r--printing/ppconstr.mli5
-rw-r--r--printing/pputils.ml99
-rw-r--r--printing/pputils.mli24
-rw-r--r--printing/prettyp.ml4
-rw-r--r--printing/printer.ml42
-rw-r--r--printing/printer.mli5
-rw-r--r--printing/printmod.ml10
-rw-r--r--printing/proof_diffs.ml75
-rw-r--r--printing/proof_diffs.mli1
10 files changed, 88 insertions, 192 deletions
diff --git a/printing/ppconstr.ml b/printing/ppconstr.ml
index 6d53349fa1..26202ef4ca 100644
--- a/printing/ppconstr.ml
+++ b/printing/ppconstr.ml
@@ -14,7 +14,6 @@ open Util
open Pp
open CAst
open Names
-open Nameops
open Libnames
open Pputils
open Ppextend
@@ -230,20 +229,6 @@ let tag_var = tag Tag.variable
| { CAst.v = CHole (_,IntroAnonymous,_) } -> mt ()
| t -> str " :" ++ pr_sep_com (fun()->brk(1,2)) (pr ltop) t
- let pr_lident {loc; v=id} =
- match loc with
- | None -> pr_id id
- | Some loc -> let (b,_) = Loc.unloc loc in
- pr_located pr_id (Some (Loc.make_loc (b,b + String.length (Id.to_string id))), id)
-
- let pr_lname = function
- | {CAst.loc; v=Name id} -> pr_lident CAst.(make ?loc id)
- | x -> pr_ast Name.print x
-
- let pr_or_var pr = function
- | Locus.ArgArg x -> pr x
- | Locus.ArgVar id -> pr_lident id
-
let pr_prim_token = function
| Numeral (n,s) -> str (if s then n else "-"^n)
| String s -> qs s
diff --git a/printing/ppconstr.mli b/printing/ppconstr.mli
index e7f71849a5..1cb3aa6d7a 100644
--- a/printing/ppconstr.mli
+++ b/printing/ppconstr.mli
@@ -21,11 +21,6 @@ val prec_less : precedence -> tolerability -> bool
val pr_tight_coma : unit -> Pp.t
-val pr_or_var : ('a -> Pp.t) -> 'a Locus.or_var -> Pp.t
-
-val pr_lident : lident -> Pp.t
-val pr_lname : lname -> Pp.t
-
val pr_with_comments : ?loc:Loc.t -> Pp.t -> Pp.t
val pr_com_at : int -> Pp.t
val pr_sep_com :
diff --git a/printing/pputils.ml b/printing/pputils.ml
index 59e5f68f22..e6daf9544c 100644
--- a/printing/pputils.ml
+++ b/printing/pputils.ml
@@ -12,7 +12,6 @@ open Util
open Pp
open Genarg
open Locus
-open Genredexpr
let beautify_comments = ref []
@@ -39,91 +38,25 @@ let pr_located pr (loc, x) =
let pr_ast pr { CAst.loc; v } = pr_located pr (loc, v)
-let pr_or_var pr = function
- | ArgArg x -> pr x
- | ArgVar {CAst.v=s} -> Names.Id.print s
-
-let pr_with_occurrences pr keyword (occs,c) =
- match occs with
- | AllOccurrences ->
- pr c
- | NoOccurrences ->
- failwith "pr_with_occurrences: no occurrences"
- | OnlyOccurrences nl ->
- hov 1 (pr c ++ spc () ++ keyword "at" ++ spc () ++
- hov 0 (prlist_with_sep spc (pr_or_var int) nl))
- | AllOccurrencesBut nl ->
- hov 1 (pr c ++ spc () ++ keyword "at" ++ str" - " ++
- hov 0 (prlist_with_sep spc (pr_or_var int) nl))
-
-exception ComplexRedFlag
-
-let pr_short_red_flag pr r =
- if not r.rBeta || not r.rMatch || not r.rFix || not r.rCofix || not r.rZeta then
- raise ComplexRedFlag
- else if List.is_empty r.rConst then
- if r.rDelta then mt () else raise ComplexRedFlag
- else (if r.rDelta then str "-" else mt ()) ++
- hov 0 (str "[" ++ prlist_with_sep spc pr r.rConst ++ str "]")
-
-let pr_red_flag pr r =
- try pr_short_red_flag pr r
- with ComplexRedFlag ->
- (if r.rBeta then pr_arg str "beta" else mt ()) ++
- (if r.rMatch && r.rFix && r.rCofix then pr_arg str "iota" else
- (if r.rMatch then pr_arg str "match" else mt ()) ++
- (if r.rFix then pr_arg str "fix" else mt ()) ++
- (if r.rCofix then pr_arg str "cofix" else mt ())) ++
- (if r.rZeta then pr_arg str "zeta" else mt ()) ++
- (if List.is_empty r.rConst then
- if r.rDelta then pr_arg str "delta"
- else mt ()
- else
- pr_arg str "delta " ++ (if r.rDelta then str "-" else mt ()) ++
- hov 0 (str "[" ++ prlist_with_sep spc pr r.rConst ++ str "]"))
-
-let pr_union pr1 pr2 = function
- | Inl a -> pr1 a
- | Inr b -> pr2 b
-
-let pr_red_expr (pr_constr,pr_lconstr,pr_ref,pr_pattern) keyword = function
- | Red false -> keyword "red"
- | Hnf -> keyword "hnf"
- | Simpl (f,o) -> keyword "simpl" ++ (pr_short_red_flag pr_ref f)
- ++ pr_opt (pr_with_occurrences (pr_union pr_ref pr_pattern) keyword) o
- | Cbv f ->
- if f.rBeta && f.rMatch && f.rFix && f.rCofix &&
- f.rZeta && f.rDelta && List.is_empty f.rConst then
- keyword "compute"
- else
- hov 1 (keyword "cbv" ++ pr_red_flag pr_ref f)
- | Lazy f ->
- hov 1 (keyword "lazy" ++ pr_red_flag pr_ref f)
- | Cbn f ->
- hov 1 (keyword "cbn" ++ pr_red_flag pr_ref f)
- | Unfold l ->
- hov 1 (keyword "unfold" ++ spc() ++
- prlist_with_sep pr_comma (pr_with_occurrences pr_ref keyword) l)
- | Fold l -> hov 1 (keyword "fold" ++ prlist (pr_arg pr_constr) l)
- | Pattern l ->
- hov 1 (keyword "pattern" ++
- pr_arg (prlist_with_sep pr_comma (pr_with_occurrences pr_constr keyword)) l)
+let pr_lident { CAst.loc; v=id } =
+ let open Names.Id in
+ match loc with
+ | None -> print id
+ | Some loc -> let (b,_) = Loc.unloc loc in
+ pr_located print
+ (Some (Loc.make_loc (b,b + String.length (to_string id))), id)
- | Red true ->
- CErrors.user_err Pp.(str "Shouldn't be accessible from user.")
- | ExtraRedExpr s ->
- str s
- | CbvVm o ->
- keyword "vm_compute" ++ pr_opt (pr_with_occurrences (pr_union pr_ref pr_pattern) keyword) o
- | CbvNative o ->
- keyword "native_compute" ++ pr_opt (pr_with_occurrences (pr_union pr_ref pr_pattern) keyword) o
+let pr_lname = let open Names in function
+ | {CAst.loc; v=Name id} -> pr_lident CAst.(make ?loc id)
+ | x -> pr_ast Name.print x
-let pr_red_expr_env env sigma (pr_constr,pr_lconstr,pr_ref,pr_pattern) =
- pr_red_expr (pr_constr env sigma, pr_lconstr env sigma, pr_ref, pr_pattern env sigma)
+let pr_or_var pr = function
+ | ArgArg x -> pr x
+ | ArgVar id -> pr_lident id
-let pr_or_by_notation f = let open Constrexpr in function
- | {CAst.loc; v=AN v} -> f v
- | {CAst.loc; v=ByNotation (s,sc)} -> qs s ++ pr_opt (fun sc -> str "%" ++ str sc) sc
+let pr_or_by_notation f = let open Constrexpr in CAst.with_val (function
+ | AN v -> f v
+ | ByNotation (s,sc) -> qs s ++ pr_opt (fun sc -> str "%" ++ str sc) sc)
let hov_if_not_empty n p = if Pp.ismt p then p else hov n p
diff --git a/printing/pputils.mli b/printing/pputils.mli
index 5b1969e232..ea554355bc 100644
--- a/printing/pputils.mli
+++ b/printing/pputils.mli
@@ -8,33 +8,17 @@
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
+open Names
open Genarg
-open Locus
-open Genredexpr
val pr_located : ('a -> Pp.t) -> 'a Loc.located -> Pp.t
val pr_ast : ('a -> Pp.t) -> 'a CAst.t -> Pp.t
(** Prints an object surrounded by its commented location *)
-val pr_or_var : ('a -> Pp.t) -> 'a or_var -> Pp.t
+val pr_lident : lident -> Pp.t
+val pr_lname : lname -> Pp.t
+val pr_or_var : ('a -> Pp.t) -> 'a Locus.or_var -> Pp.t
val pr_or_by_notation : ('a -> Pp.t) -> 'a Constrexpr.or_by_notation -> Pp.t
-val pr_with_occurrences :
- ('a -> Pp.t) -> (string -> Pp.t) -> 'a with_occurrences -> Pp.t
-
-val pr_short_red_flag : ('a -> Pp.t) -> 'a glob_red_flag -> Pp.t
-val pr_red_flag : ('a -> Pp.t) -> 'a glob_red_flag -> Pp.t
-
-val pr_red_expr :
- ('a -> Pp.t) * ('a -> Pp.t) * ('b -> Pp.t) * ('c -> Pp.t) ->
- (string -> Pp.t) -> ('a,'b,'c) red_expr_gen -> Pp.t
-
-val pr_red_expr_env : Environ.env -> Evd.evar_map ->
- (Environ.env -> Evd.evar_map -> 'a -> Pp.t) *
- (Environ.env -> Evd.evar_map -> 'a -> Pp.t) *
- ('b -> Pp.t) *
- (Environ.env -> Evd.evar_map -> 'c -> Pp.t) ->
- (string -> Pp.t) ->
- ('a,'b,'c) red_expr_gen -> Pp.t
val pr_raw_generic : Environ.env -> rlevel generic_argument -> Pp.t
val pr_glb_generic : Environ.env -> glevel generic_argument -> Pp.t
diff --git a/printing/prettyp.ml b/printing/prettyp.ml
index f9f4d7f7f8..c417ef8a66 100644
--- a/printing/prettyp.ml
+++ b/printing/prettyp.ml
@@ -427,7 +427,7 @@ let locate_modtype qid =
let all = Nametab.locate_extended_all_modtype qid in
let map mp = ModuleType mp, Nametab.shortest_qualid_of_modtype mp in
let modtypes = List.map map all in
- (** Don't forget the opened module types: they are not part of the same name tab. *)
+ (* Don't forget the opened module types: they are not part of the same name tab. *)
let all = Nametab.locate_extended_all_dir qid in
let map dir = let open Nametab.GlobDirRef in match dir with
| DirOpenModtype _ -> Some (Dir dir, qid)
@@ -575,7 +575,7 @@ let print_constant with_values sep sp udecl =
in
let env = Global.env () and sigma = Evd.from_ctx ctx in
let pr_ltype = pr_ltype_env env sigma in
- hov 0 (pr_polymorphic (Declareops.constant_is_polymorphic cb) ++
+ hov 0 (
match val_0 with
| None ->
str"*** [ " ++
diff --git a/printing/printer.ml b/printing/printer.ml
index 2bbda279bd..3f7837fd6e 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -546,10 +546,10 @@ let rec pr_evars_int_hd pr sigma i = function
(hov 0 (pr i evk evi)) ++
(match rest with [] -> mt () | _ -> fnl () ++ pr_evars_int_hd pr sigma (i+1) rest)
-let pr_evars_int sigma ~shelf ~givenup i evs =
+let pr_evars_int sigma ~shelf ~given_up i evs =
let pr_status i =
if List.mem i shelf then str " (shelved)"
- else if List.mem i givenup then str " (given up)"
+ else if List.mem i given_up then str " (given up)"
else mt () in
pr_evars_int_hd
(fun i evk evi ->
@@ -605,12 +605,12 @@ let print_evar_constraints gl sigma =
let t1 = Evarutil.nf_evar sigma t1
and t2 = Evarutil.nf_evar sigma t2 in
let env =
- (** We currently allow evar instances to refer to anonymous de Bruijn
- indices, so we protect the error printing code in this case by giving
- names to every de Bruijn variable in the rel_context of the conversion
- problem. MS: we should rather stop depending on anonymous variables, they
- can be used to indicate independency. Also, this depends on a strategy for
- naming/renaming *)
+ (* We currently allow evar instances to refer to anonymous de Bruijn
+ indices, so we protect the error printing code in this case by giving
+ names to every de Bruijn variable in the rel_context of the conversion
+ problem. MS: we should rather stop depending on anonymous variables, they
+ can be used to indicate independency. Also, this depends on a strategy for
+ naming/renaming *)
Namegen.make_all_name_different env sigma in
str" " ++
hov 2 (pr_env env ++ pr_leconstr_env env sigma t1 ++ spc () ++
@@ -686,7 +686,7 @@ let pr_subgoals ?(pr_first=true) ?(diffs=false) ?os_map
| None -> GoalMap.empty
in
- (** Printing functions for the extra informations. *)
+ (* Printing functions for the extra informations. *)
let rec print_stack a = function
| [] -> Pp.int a
| b::l -> Pp.int a ++ str"-" ++ print_stack b l
@@ -722,11 +722,11 @@ let pr_subgoals ?(pr_first=true) ?(diffs=false) ?os_map
let get_ogs g =
match os_map with
| Some (osigma, _) ->
- (* if Not_found, returning None treats the goal as new and it will be highlighted;
+ (* if Not_found, returning None treats the goal as new and it will be diff highlighted;
returning Some { it = g; sigma = sigma } will compare the new goal
to itself and it won't be highlighted *)
(try Some { it = GoalMap.find g diff_goal_map; sigma = osigma }
- with Not_found -> raise (Pp_diff.Diff_Failure "Unable to match goals between old and new proof states (7)"))
+ with Not_found -> None)
| None -> None
in
let rec pr_rec n = function
@@ -753,7 +753,7 @@ let pr_subgoals ?(pr_first=true) ?(diffs=false) ?os_map
| None -> ()
in
- (** Main function *)
+ (* Main function *)
match goals with
| [] ->
begin
@@ -761,7 +761,7 @@ let pr_subgoals ?(pr_first=true) ?(diffs=false) ?os_map
if Evar.Map.is_empty exl then
(str"No more subgoals." ++ print_dependent_evars None sigma seeds)
else
- let pei = pr_evars_int sigma ~shelf ~givenup:[] 1 exl in
+ let pei = pr_evars_int sigma ~shelf ~given_up:[] 1 exl in
v 0 ((str "No more subgoals,"
++ str " but there are non-instantiated existential variables:"
++ cut () ++ (hov 0 pei)
@@ -789,7 +789,7 @@ let pr_open_subgoals_diff ?(quiet=false) ?(diffs=false) ?oproof proof =
straightforward, but seriously, [Proof.proof] should return
[evar_info]-s instead. *)
let p = proof in
- let (goals , stack , shelf, given_up, sigma ) = Proof.proof p in
+ let Proof.{goals; stack; shelf; given_up; sigma} = Proof.data p in
let stack = List.map (fun (l,r) -> List.length l + List.length r) stack in
let seeds = Proof.V82.top_evars p in
begin match goals with
@@ -821,7 +821,7 @@ let pr_open_subgoals_diff ?(quiet=false) ?(diffs=false) ?oproof proof =
let unfocused_if_needed = if should_unfoc() then bgoals_unfocused else [] in
let os_map = match oproof with
| Some op when diffs ->
- let (_,_,_,_, osigma) = Proof.proof op in
+ let Proof.{sigma=osigma} = Proof.data op in
let diff_goal_map = Proof_diffs.make_goal_map oproof proof in
Some (osigma, diff_goal_map)
| _ -> None
@@ -834,8 +834,8 @@ let pr_open_subgoals ~proof =
pr_open_subgoals_diff proof
let pr_nth_open_subgoal ~proof n =
- let gls,_,_,_,sigma = Proof.proof proof in
- pr_subgoal n sigma gls
+ let Proof.{goals;sigma} = Proof.data proof in
+ pr_subgoal n sigma goals
let pr_goal_by_id ~proof id =
try
@@ -982,14 +982,6 @@ let pr_assumptionset env sigma s =
] in
prlist_with_sep fnl (fun x -> x) (Option.List.flatten assums)
-let pr_cumulative poly cum =
- if poly then
- if cum then str "Cumulative " else str "NonCumulative "
- else mt ()
-
-let pr_polymorphic b =
- if b then str"Polymorphic " else str"Monomorphic "
-
(* print the proof step, possibly with diffs highlighted, *)
let print_and_diff oldp newp =
match newp with
diff --git a/printing/printer.mli b/printing/printer.mli
index b0232ec4ac..9a06d555e4 100644
--- a/printing/printer.mli
+++ b/printing/printer.mli
@@ -81,8 +81,6 @@ val pr_sort : evar_map -> Sorts.t -> Pp.t
(** Universe constraints *)
-val pr_polymorphic : bool -> Pp.t
-val pr_cumulative : bool -> bool -> Pp.t
val pr_universe_instance : evar_map -> Univ.Instance.t -> Pp.t
val pr_universe_instance_constraints : evar_map -> Univ.Instance.t -> Univ.Constraint.t -> Pp.t
val pr_universe_ctx : evar_map -> ?variance:Univ.Variance.t array ->
@@ -112,6 +110,7 @@ val pr_pconstructor : env -> evar_map -> pconstructor -> Pp.t
(** Contexts *)
+
(** Display compact contexts of goals (simple hyps on the same line) *)
val set_compact_context : bool -> unit
val get_compact_context : unit -> bool
@@ -181,7 +180,7 @@ val pr_open_subgoals_diff : ?quiet:bool -> ?diffs:bool -> ?oproof:Proof.t -> Pr
val pr_open_subgoals : proof:Proof.t -> Pp.t
val pr_nth_open_subgoal : proof:Proof.t -> int -> Pp.t
val pr_evar : evar_map -> (Evar.t * evar_info) -> Pp.t
-val pr_evars_int : evar_map -> shelf:Goal.goal list -> givenup:Goal.goal list -> int -> evar_info Evar.Map.t -> Pp.t
+val pr_evars_int : evar_map -> shelf:Goal.goal list -> given_up:Goal.goal list -> int -> evar_info Evar.Map.t -> Pp.t
val pr_evars : evar_map -> evar_info Evar.Map.t -> Pp.t
val pr_ne_evar_set : Pp.t -> Pp.t -> evar_map ->
Evar.Set.t -> Pp.t
diff --git a/printing/printmod.ml b/printing/printmod.ml
index a8d7b0c1a8..898f231a8b 100644
--- a/printing/printmod.ml
+++ b/printing/printmod.ml
@@ -123,11 +123,7 @@ let print_mutual_inductive env mind mib udecl =
(Declareops.inductive_polymorphic_context mib) udecl
in
let sigma = Evd.from_ctx (UState.of_binders bl) in
- hov 0 (Printer.pr_polymorphic (Declareops.inductive_is_polymorphic mib) ++
- Printer.pr_cumulative
- (Declareops.inductive_is_polymorphic mib)
- (Declareops.inductive_is_cumulative mib) ++
- def keyword ++ spc () ++
+ hov 0 (def keyword ++ spc () ++
prlist_with_sep (fun () -> fnl () ++ str" with ")
(print_one_inductive env sigma mib) inds ++
match mib.mind_universes with
@@ -172,10 +168,6 @@ let print_record env mind mib udecl =
in
hov 0 (
hov 0 (
- Printer.pr_polymorphic (Declareops.inductive_is_polymorphic mib) ++
- Printer.pr_cumulative
- (Declareops.inductive_is_polymorphic mib)
- (Declareops.inductive_is_cumulative mib) ++
def keyword ++ spc () ++ Id.print mip.mind_typename ++ brk(1,4) ++
print_params env sigma params ++
str ": " ++ Printer.pr_lconstr_env envpar sigma arity ++ brk(1,2) ++
diff --git a/printing/proof_diffs.ml b/printing/proof_diffs.ml
index 3e2093db4a..c1ea067567 100644
--- a/printing/proof_diffs.ml
+++ b/printing/proof_diffs.ml
@@ -83,12 +83,13 @@ let tokenize_string s =
if Tok.(equal e EOI) then
List.rev acc
else
- stream_tok ((Tok.extract_string e) :: acc) str
+ stream_tok ((Tok.extract_string true e) :: acc) str
in
let st = CLexer.get_lexer_state () in
try
let istr = Stream.of_string s in
- let lex = CLexer.lexer.Gramlib.Plexing.tok_func istr in
+ let lexer = CLexer.make_lexer ~diff_mode:true in
+ let lex = lexer.Gramlib.Plexing.tok_func istr in
let toks = stream_tok [] (fst lex) in
CLexer.set_lexer_state st;
toks
@@ -138,13 +139,11 @@ let diff_hyps o_line_idents o_map n_line_idents n_map =
let hyp_diffs = diff_str ~tokenize_string o_line n_line in
let (has_added, has_removed) = has_changes hyp_diffs in
if show_removed () && has_removed then begin
- let o_entry = StringMap.find (List.hd old_ids) o_map in
- o_entry.done_ <- true;
+ List.iter (fun x -> (StringMap.find x o_map).done_ <- true) old_ids;
rv := (add_diff_tags `Removed o_pp hyp_diffs) :: !rv;
end;
if n_line <> "" then begin
- let n_entry = StringMap.find (List.hd new_ids) n_map in
- n_entry.done_ <- true;
+ List.iter (fun x -> (StringMap.find x n_map).done_ <- true) new_ids;
rv := (add_diff_tags `Added n_pp hyp_diffs) :: !rv
end
in
@@ -157,7 +156,7 @@ let diff_hyps o_line_idents o_map n_line_idents n_map =
if dtype = `Removed then begin
let o_idents = (StringMap.find ident o_map).idents in
(* only show lines that have all idents removed here; other removed idents appear later *)
- if show_removed () &&
+ if show_removed () && not (is_done ident o_map) &&
List.for_all (fun x -> not (exists x n_map)) o_idents then
output (List.rev o_idents) []
end
@@ -399,6 +398,10 @@ let match_goals ot nt =
It's set to the old goal's evar name once a rewitten goal is found,
at which point the code only searches for the replacing goals
(and ot is set to nt). *)
+ let iter2 f l1 l2 =
+ if List.length l1 = (List.length l2) then
+ List.iter2 f l1 l2
+ in
let rec match_goals_r ogname ot nt =
let constr_expr ogname exp exp2 =
match_goals_r ogname exp.v exp2.v
@@ -434,13 +437,13 @@ let match_goals ot nt =
let fix_expr ogname exp exp2 =
let (l,(lo,ro),lb,ce1,ce2), (l2,(lo2,ro2),lb2,ce12,ce22) = exp,exp2 in
recursion_order_expr ogname ro ro2;
- List.iter2 (local_binder_expr ogname) lb lb2;
+ iter2 (local_binder_expr ogname) lb lb2;
constr_expr ogname ce1 ce12;
constr_expr ogname ce2 ce22
in
let cofix_expr ogname exp exp2 =
let (l,lb,ce1,ce2), (l2,lb2,ce12,ce22) = exp,exp2 in
- List.iter2 (local_binder_expr ogname) lb lb2;
+ iter2 (local_binder_expr ogname) lb lb2;
constr_expr ogname ce1 ce12;
constr_expr ogname ce2 ce22
in
@@ -454,38 +457,38 @@ let match_goals ot nt =
in
let constr_notation_substitution ogname exp exp2 =
let (ce, cel, cp, lb), (ce2, cel2, cp2, lb2) = exp, exp2 in
- List.iter2 (constr_expr ogname) ce ce2;
- List.iter2 (fun a a2 -> List.iter2 (constr_expr ogname) a a2) cel cel2;
- List.iter2 (fun a a2 -> List.iter2 (local_binder_expr ogname) a a2) lb lb2
+ iter2 (constr_expr ogname) ce ce2;
+ iter2 (fun a a2 -> iter2 (constr_expr ogname) a a2) cel cel2;
+ iter2 (fun a a2 -> iter2 (local_binder_expr ogname) a a2) lb lb2
in
begin
match ot, nt with
| CRef (ref,us), CRef (ref2,us2) -> ()
| CFix (id,fl), CFix (id2,fl2) ->
- List.iter2 (fix_expr ogname) fl fl2
+ iter2 (fix_expr ogname) fl fl2
| CCoFix (id,cfl), CCoFix (id2,cfl2) ->
- List.iter2 (cofix_expr ogname) cfl cfl2
+ iter2 (cofix_expr ogname) cfl cfl2
| CProdN (bl,c2), CProdN (bl2,c22)
| CLambdaN (bl,c2), CLambdaN (bl2,c22) ->
- List.iter2 (local_binder_expr ogname) bl bl2;
+ iter2 (local_binder_expr ogname) bl bl2;
constr_expr ogname c2 c22
| CLetIn (na,c1,t,c2), CLetIn (na2,c12,t2,c22) ->
constr_expr ogname c1 c12;
constr_expr_opt ogname t t2;
constr_expr ogname c2 c22
| CAppExpl ((isproj,ref,us),args), CAppExpl ((isproj2,ref2,us2),args2) ->
- List.iter2 (constr_expr ogname) args args2
+ iter2 (constr_expr ogname) args args2
| CApp ((isproj,f),args), CApp ((isproj2,f2),args2) ->
constr_expr ogname f f2;
- List.iter2 (fun a a2 -> let (c, _) = a and (c2, _) = a2 in
+ iter2 (fun a a2 -> let (c, _) = a and (c2, _) = a2 in
constr_expr ogname c c2) args args2
| CRecord fs, CRecord fs2 ->
- List.iter2 (fun a a2 -> let (_, c) = a and (_, c2) = a2 in
+ iter2 (fun a a2 -> let (_, c) = a and (_, c2) = a2 in
constr_expr ogname c c2) fs fs2
| CCases (sty,rtnpo,tms,eqns), CCases (sty2,rtnpo2,tms2,eqns2) ->
constr_expr_opt ogname rtnpo rtnpo2;
- List.iter2 (case_expr ogname) tms tms2;
- List.iter2 (branch_expr ogname) eqns eqns2
+ iter2 (case_expr ogname) tms tms2;
+ iter2 (branch_expr ogname) eqns eqns2
| CLetTuple (nal,(na,po),b,c), CLetTuple (nal2,(na2,po2),b2,c2) ->
constr_expr_opt ogname po po2;
constr_expr ogname b b2;
@@ -500,7 +503,7 @@ let match_goals ot nt =
| CEvar (n,l), CEvar (n2,l2) ->
let oevar = if ogname = "" then Id.to_string n else ogname in
nevar_to_oevar := StringMap.add (Id.to_string n2) oevar !nevar_to_oevar;
- List.iter2 (fun x x2 -> let (_, g) = x and (_, g2) = x2 in constr_expr ogname g g2) l l2
+ iter2 (fun x x2 -> let (_, g) = x and (_, g2) = x2 in constr_expr ogname g g2) l l2
| CEvar (n,l), nt' ->
(* pass down the old goal evar name *)
match_goals_r (Id.to_string n) nt' nt'
@@ -545,19 +548,31 @@ module GoalMap = Evar.Map
let goal_to_evar g sigma = Id.to_string (Termops.pr_evar_suggested_name g sigma)
+open Goal.Set
+
[@@@ocaml.warning "-32"]
let db_goal_map op np ng_to_og =
- Printf.printf "New Goals: ";
- let (ngoals,_,_,_,nsigma) = Proof.proof np in
- List.iter (fun ng -> Printf.printf "%d -> %s " (Evar.repr ng) (goal_to_evar ng nsigma)) ngoals;
+ let pr_goals title prf =
+ Printf.printf "%s: " title;
+ let Proof.{goals;sigma} = Proof.data prf in
+ List.iter (fun g -> Printf.printf "%d -> %s " (Evar.repr g) (goal_to_evar g sigma)) goals;
+ let gs = diff (Proof.all_goals prf) (List.fold_left (fun s g -> add g s) empty goals) in
+ List.iter (fun g -> Printf.printf "%d " (Evar.repr g)) (elements gs);
+ in
+
+ pr_goals "New Goals" np;
(match op with
| Some op ->
- let (ogoals,_,_,_,osigma) = Proof.proof op in
- Printf.printf "\nOld Goals: ";
- List.iter (fun og -> Printf.printf "%d -> %s " (Evar.repr og) (goal_to_evar og osigma)) ogoals
+ pr_goals "\nOld Goals" op
| None -> ());
Printf.printf "\nGoal map: ";
- GoalMap.iter (fun og ng -> Printf.printf "%d -> %d " (Evar.repr og) (Evar.repr ng)) ng_to_og;
+ GoalMap.iter (fun ng og -> Printf.printf "%d -> %d " (Evar.repr ng) (Evar.repr og)) ng_to_og;
+ let unmapped = ref (Proof.all_goals np) in
+ GoalMap.iter (fun ng _ -> unmapped := Goal.Set.remove ng !unmapped) ng_to_og;
+ if Goal.Set.cardinal !unmapped > 0 then begin
+ Printf.printf "\nUnmapped goals: ";
+ Goal.Set.iter (fun ng -> Printf.printf "%d " (Evar.repr ng)) !unmapped
+ end;
Printf.printf "\n"
[@@@ocaml.warning "+32"]
@@ -612,11 +627,11 @@ let make_goal_map_i op np =
let nevar_to_oevar = match_goals (Some (to_constr op)) (to_constr np) in
let oevar_to_og = ref StringMap.empty in
- let (_,_,_,_,osigma) = Proof.proof op in
+ let Proof.{sigma=osigma} = Proof.data op in
List.iter (fun og -> oevar_to_og := StringMap.add (goal_to_evar og osigma) og !oevar_to_og)
(Goal.Set.elements rem_gs);
- let (_,_,_,_,nsigma) = Proof.proof np in
+ let Proof.{sigma=nsigma} = Proof.data np in
let get_og ng =
let nevar = goal_to_evar ng nsigma in
let oevar = StringMap.find nevar nevar_to_oevar in
diff --git a/printing/proof_diffs.mli b/printing/proof_diffs.mli
index ce9ee5ae6f..1ebde3d572 100644
--- a/printing/proof_diffs.mli
+++ b/printing/proof_diffs.mli
@@ -12,6 +12,7 @@
(** Controls whether to show diffs. Takes values "on", "off", "removed" *)
val write_diffs_option : string -> unit
+
(** Returns true if the diffs option is "on" or "removed" *)
val show_diffs : unit -> bool