-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added current goal info to dependent evars line #2
base: dependent_evars
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- Update output generated by :flag:`Printing Dependent Evars Line` flag | ||
used by the Prooftree tool in Proof General. | ||
(`#10489 <https://github.com/coq/coq/pull/10489>`_, | ||
closes `#4504 <https://github.com/coq/coq/issues/4504>`_, | ||
`#10399 <https://github.com/coq/coq/issues/10399>`_ and | ||
`#10400 <https://github.com/coq/coq/issues/10400>`_, | ||
by Jim Fehrle). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -635,27 +635,33 @@ let () = | |
optwrite = (fun v -> should_print_dependent_evars := v) } | ||
|
||
let print_dependent_evars gl sigma seeds = | ||
let constraints = print_evar_constraints gl sigma in | ||
let evars () = | ||
if !should_print_dependent_evars then | ||
let evars = Evarutil.gather_dependent_evars sigma seeds in | ||
let evars = | ||
Evar.Map.fold begin fun e i s -> | ||
let e' = pr_internal_existential_key e in | ||
match i with | ||
| None -> s ++ str" " ++ e' ++ str " open," | ||
| Some i -> | ||
s ++ str " " ++ e' ++ str " using " ++ | ||
Evar.Set.fold begin fun d s -> | ||
pr_internal_existential_key d ++ str " " ++ s | ||
end i (str ",") | ||
end evars (str "") | ||
if !should_print_dependent_evars then | ||
let evars = Evarutil.gather_dependent_evars sigma seeds in | ||
let evars_pp = Evar.Map.fold (fun e i s -> | ||
let e' = pr_internal_existential_key e in | ||
s ++ e' ++ | ||
(match i with | ||
| None -> (str " : ") ++ (Termops.pr_existential_key sigma e) ++ (str " open") | ||
| Some i -> | ||
let using = Evar.Set.fold (fun d s -> | ||
s ++ str " " ++ (pr_internal_existential_key d)) | ||
i (str "") in | ||
str " using" ++ using) | ||
++ str ", ") | ||
evars (str "") | ||
in | ||
let evars_current_pp = match gl with | ||
| None -> str "no current goal" | ||
| Some gl -> | ||
let evars_current = Evarutil.gather_dependent_evars sigma [ gl ] in | ||
Evar.Map.fold (fun e _ s -> | ||
s ++ (pr_internal_existential_key e) ++ (str " ")) | ||
evars_current (str "current goal: ") | ||
in | ||
cut () ++ cut () ++ | ||
str "(dependent evars:" ++ evars ++ str ")" | ||
else mt () | ||
in | ||
constraints ++ evars () | ||
str "(dependent evars: " ++ evars_pp ++ str "; " ++ | ||
evars_current_pp ++ str ")" | ||
else mt () | ||
|
||
module GoalMap = Evar.Map | ||
|
||
|
@@ -732,6 +738,10 @@ let pr_subgoals ?(pr_first=true) ?(diffs=false) ?os_map | |
else | ||
pr_rec 1 (g::l) | ||
in | ||
let pr_evar_info gl sigma seeds = | ||
let first_goal = if pr_first then gl else None in | ||
print_evar_constraints gl sigma ++ print_dependent_evars first_goal sigma seeds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Actually because you're passing None here, so of course you need to update the declaration There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course not. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can see the typing error, if you annotate the |
||
in | ||
(* Side effect! This has to be made more robust *) | ||
let () = | ||
match close_cmd with | ||
|
@@ -742,31 +752,29 @@ let pr_subgoals ?(pr_first=true) ?(diffs=false) ?os_map | |
(* Main function *) | ||
match goals with | ||
| [] -> | ||
begin | ||
let exl = Evd.undefined_map sigma in | ||
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 ~given_up:[] 1 exl in | ||
v 0 ((str "No more subgoals," | ||
++ str " but there are non-instantiated existential variables:" | ||
++ cut () ++ (hov 0 pei) | ||
++ print_dependent_evars None sigma seeds | ||
++ cut () ++ str "You can use Grab Existential Variables.")) | ||
end | ||
let exl = Evd.undefined_map sigma in | ||
if Evar.Map.is_empty exl then | ||
v 0 (str "No more subgoals." ++ pr_evar_info None sigma seeds) | ||
else | ||
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) | ||
++ pr_evar_info None sigma seeds | ||
++ cut () ++ str "You can use Grab Existential Variables.")) | ||
| g1::rest -> | ||
let goals = print_multiple_goals g1 rest in | ||
let ngoals = List.length rest+1 in | ||
v 0 ( | ||
int ngoals ++ focused_if_needed ++ str(String.plural ngoals "subgoal") | ||
int ngoals ++ focused_if_needed ++ str(String.plural ngoals "subgoal") | ||
++ print_extra | ||
++ str (if (should_gname()) then ", subgoal 1" else "") | ||
++ (if should_tag() then pr_goal_tag g1 else str"") | ||
++ pr_goal_name sigma g1 ++ cut () ++ goals | ||
++ (if unfocused=[] then str "" | ||
else (cut() ++ cut() ++ str "*** Unfocused goals:" ++ cut() | ||
++ pr_rec (List.length rest + 2) unfocused)) | ||
++ print_dependent_evars (Some g1) sigma seeds | ||
++ pr_evar_info (Some g1) sigma seeds | ||
) | ||
|
||
let pr_open_subgoals_diff ?(quiet=false) ?(diffs=false) ?oproof proof = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
Coq < | ||
Coq < Coq < 1 subgoal | ||
|
||
============================ | ||
forall P Q R : Prop, (Q -> R) -> (P -> Q) -> (P -> Q) -> P -> R | ||
|
||
(dependent evars: ; | ||
mapping: ?X1 : ?Goal) | ||
|
||
strange_imp_trans < | ||
strange_imp_trans < No more subgoals.(dependent evars: ;mapping: ) | ||
|
||
strange_imp_trans < strange_imp_trans is defined | ||
|
||
Coq < Coq < 1 subgoal | ||
|
||
============================ | ||
forall P Q : Prop, (P -> Q) /\ P -> Q | ||
|
||
(dependent evars: ; | ||
mapping: ?X2 : ?Goal) | ||
|
||
modpon < | ||
modpon < No more subgoals.(dependent evars: ;mapping: ) | ||
|
||
modpon < modpon is defined | ||
|
||
Coq < Coq < | ||
Coq < P1 is declared | ||
P2 is declared | ||
P3 is declared | ||
P4 is declared | ||
|
||
Coq < p12 is declared | ||
|
||
Coq < p123 is declared | ||
|
||
Coq < p34 is declared | ||
|
||
Coq < Coq < 1 subgoal | ||
|
||
P1, P2, P3, P4 : Prop | ||
p12 : P1 -> P2 | ||
p123 : (P1 -> P2) -> P3 | ||
p34 : P3 -> P4 | ||
============================ | ||
P4 | ||
|
||
(dependent evars: ; | ||
mapping: ?X3 : ?Goal) | ||
|
||
p14 < | ||
p14 < 4 focused subgoals | ||
(shelved: 2) | ||
|
||
P1, P2, P3, P4 : Prop | ||
p12 : P1 -> P2 | ||
p123 : (P1 -> P2) -> P3 | ||
p34 : P3 -> P4 | ||
============================ | ||
?Q -> P4 | ||
|
||
subgoal 2 is: | ||
?P -> ?Q | ||
subgoal 3 is: | ||
?P -> ?Q | ||
subgoal 4 is: | ||
?P | ||
|
||
(dependent evars: ?X4 open, ?X5 open; | ||
mapping: ?X4 : ?P, ?X5 : ?Q, ?X6 : ?Goal, ?X7 : ?Goal0, ?X8 : ?Goal1, ?X9 : ?Goal2) | ||
|
||
p14 < 3 focused subgoals | ||
(shelved: 2) | ||
|
||
P1, P2, P3, P4 : Prop | ||
p12 : P1 -> P2 | ||
p123 : (P1 -> P2) -> P3 | ||
p34 : P3 -> P4 | ||
============================ | ||
?P -> (?Goal2 -> P4) /\ ?Goal2 | ||
|
||
subgoal 2 is: | ||
?P -> (?Goal2 -> P4) /\ ?Goal2 | ||
subgoal 3 is: | ||
?P | ||
|
||
(dependent evars: ?X4 open, ?X5 using ?X10 ?X11, ?X10 using ?X11, ?X11 open; | ||
mapping: ?X4 : ?P, ?X7 : ?Goal, ?X8 : ?Goal0, ?X9 : ?Goal1, ?X11 : ?Goal2) | ||
|
||
p14 < | ||
Coq < | ||
Coq < |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Set Printing Dependent Evars Line. | ||
Lemma strange_imp_trans : | ||
forall P Q R : Prop, (Q -> R) -> (P -> Q) -> (P -> Q) -> P -> R. | ||
Proof. | ||
auto. | ||
Qed. | ||
|
||
Lemma modpon : forall P Q : Prop, (P -> Q) /\ P -> Q. | ||
Proof. | ||
tauto. | ||
Qed. | ||
|
||
Section eex. | ||
Variables P1 P2 P3 P4 : Prop. | ||
Hypothesis p12 : P1 -> P2. | ||
Hypothesis p123 : (P1 -> P2) -> P3. | ||
Hypothesis p34 : P3 -> P4. | ||
|
||
Lemma p14 : P4. | ||
Proof. | ||
eapply strange_imp_trans. | ||
apply modpon. | ||
Abort. | ||
End eex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 The output after the
eapply strange_imp_trans
step is:However, the current goal is actually
?Goal
.?X5 = ?Q
is not. Is the labelcurrent goal
wrong or is the value wrong?2 It's odd to see
fold
here, which suggests there could be multiple elements in the mapping. There can only be one current goal. Would be clearer with something that makes this clear, such asEvar.Map.find_first
. You might add a temporary check thatEvar.Map.cardinal
is 1.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The evars after
current goal
are the evars used inside the current goal, see the feature description in coq#10420. This is not the current goal.Please read my comment in PR coq#10489 from Jul 24, 2019, 10:42 pm GMT+2, there you see an example with multiple evars after
current goal
. The code usesEvarutil.gather_dependent_evars
, which does not return the current goal, but rather all the evars used in the evar argument list, which is something completely different in most cases.