Skip to content

Commit f0f813b

Browse files
committed
Fix a bug in pclearbot using pclearbotH
1 parent ae2b3c9 commit f0f813b

File tree

3 files changed

+92
-20
lines changed

3 files changed

+92
-20
lines changed

metasrc/pacotac.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,37 @@
8080
(** ** [pclearbot] simplifies all hypotheses of the form [upaco{n} gf bot{n}] to [paco{n} gf bot{n}].
8181
*)
8282
83+
Definition pclearbot_orL (P Q: Prop) := P.
84+
Definition pclearbot_orR (P Q: Prop) := Q.
85+
86+
Ltac pclearbotH H :=
87+
generalize _paco_mark_cons;
88+
let NH := fresh H in
89+
revert_until H;
90+
repeat red in H;
91+
match goal with [Hcrr: context f [or] |- _] =>
92+
match Hcrr with H =>
93+
first[(
94+
let P := context f [pclearbot_orL] in
95+
assert (NH: P) by (repeat intro; edestruct H ; [eassumption|repeat (match goal with [X: _ \/ _ |- _] => destruct X end); contradiction]);
96+
clear H; rename NH into H; unfold pclearbot_orL in H
97+
) | (
98+
let P := context f [pclearbot_orR] in
99+
assert (NH: P) by (repeat intro; edestruct H ; [repeat (match goal with [X: _ \/ _ |- _] => destruct X end); contradiction|eassumption]);
100+
clear H; rename NH into H; unfold pclearbot_orR in H
101+
)]
102+
end
103+
end;
104+
intros; paco_revert_hyp _paco_mark.
105+
83106
Ltac pclearbot :=
84-
repeat match goal with
107+
repeat (
108+
match goal with
85109
""",end="")
86110
for i in range(n+1):
87-
print (" | [H: context [bot"+str(i)+"] |- _] => destruct H as [H|H]; [|inversion H]")
88-
print (""" end.
111+
print (" | [H: context [bot"+str(i)+"] |- _] => pclearbotH H")
112+
print (""" end).
113+
89114
90115
(** ** [pdestruct H] and [pinversion H]
91116
*)

src/examples.v

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,25 @@ Lemma seq_trans : forall d1 d2 d3
310310
Proof.
311311
eauto using gseq_trans, seq_implies_gseq, gseq_implies_seq.
312312
Qed.
313+
314+
(**
315+
Tests for [pclearbot]
316+
**)
317+
318+
Lemma plcearbot_test1 x y
319+
(H: upaco2 seq_step bot2 x y)
320+
:
321+
True.
322+
Proof.
323+
pclearbot.
324+
eauto.
325+
Qed.
326+
327+
Lemma plcearbot_test2
328+
(H: forall x y, upaco2 seq_step bot2 x y)
329+
:
330+
True.
331+
Proof.
332+
pclearbot.
333+
eauto.
334+
Qed.

src/pacotac.v

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,49 @@ Tactic Notation "pcofix" ident(CIH) := pcofix CIH with r.
6969
(** ** [pclearbot] simplifies all hypotheses of the form [upaco{n} gf bot{n}] to [paco{n} gf bot{n}].
7070
*)
7171

72+
Definition pclearbot_orL (P Q: Prop) := P.
73+
Definition pclearbot_orR (P Q: Prop) := Q.
74+
75+
Ltac pclearbotH H :=
76+
generalize _paco_mark_cons;
77+
let NH := fresh H in
78+
revert_until H;
79+
repeat red in H;
80+
match goal with [Hcrr: context f [or] |- _] =>
81+
match Hcrr with H =>
82+
first[(
83+
let P := context f [pclearbot_orL] in
84+
assert (NH: P) by (repeat intro; edestruct H ; [eassumption|repeat (match goal with [X: _ \/ _ |- _] => destruct X end); contradiction]);
85+
clear H; rename NH into H; unfold pclearbot_orL in H
86+
) | (
87+
let P := context f [pclearbot_orR] in
88+
assert (NH: P) by (repeat intro; edestruct H ; [repeat (match goal with [X: _ \/ _ |- _] => destruct X end); contradiction|eassumption]);
89+
clear H; rename NH into H; unfold pclearbot_orR in H
90+
)]
91+
end
92+
end;
93+
intros; paco_revert_hyp _paco_mark.
94+
7295
Ltac pclearbot :=
73-
repeat match goal with
74-
| [H: context [bot0] |- _] => destruct H as [H|H]; [|inversion H]
75-
| [H: context [bot1] |- _] => destruct H as [H|H]; [|inversion H]
76-
| [H: context [bot2] |- _] => destruct H as [H|H]; [|inversion H]
77-
| [H: context [bot3] |- _] => destruct H as [H|H]; [|inversion H]
78-
| [H: context [bot4] |- _] => destruct H as [H|H]; [|inversion H]
79-
| [H: context [bot5] |- _] => destruct H as [H|H]; [|inversion H]
80-
| [H: context [bot6] |- _] => destruct H as [H|H]; [|inversion H]
81-
| [H: context [bot7] |- _] => destruct H as [H|H]; [|inversion H]
82-
| [H: context [bot8] |- _] => destruct H as [H|H]; [|inversion H]
83-
| [H: context [bot9] |- _] => destruct H as [H|H]; [|inversion H]
84-
| [H: context [bot10] |- _] => destruct H as [H|H]; [|inversion H]
85-
| [H: context [bot11] |- _] => destruct H as [H|H]; [|inversion H]
86-
| [H: context [bot12] |- _] => destruct H as [H|H]; [|inversion H]
87-
| [H: context [bot13] |- _] => destruct H as [H|H]; [|inversion H]
88-
| [H: context [bot14] |- _] => destruct H as [H|H]; [|inversion H]
89-
end.
96+
repeat (
97+
match goal with
98+
| [H: context [bot0] |- _] => pclearbotH H
99+
| [H: context [bot1] |- _] => pclearbotH H
100+
| [H: context [bot2] |- _] => pclearbotH H
101+
| [H: context [bot3] |- _] => pclearbotH H
102+
| [H: context [bot4] |- _] => pclearbotH H
103+
| [H: context [bot5] |- _] => pclearbotH H
104+
| [H: context [bot6] |- _] => pclearbotH H
105+
| [H: context [bot7] |- _] => pclearbotH H
106+
| [H: context [bot8] |- _] => pclearbotH H
107+
| [H: context [bot9] |- _] => pclearbotH H
108+
| [H: context [bot10] |- _] => pclearbotH H
109+
| [H: context [bot11] |- _] => pclearbotH H
110+
| [H: context [bot12] |- _] => pclearbotH H
111+
| [H: context [bot13] |- _] => pclearbotH H
112+
| [H: context [bot14] |- _] => pclearbotH H
113+
end).
114+
90115

91116
(** ** [pdestruct H] and [pinversion H]
92117
*)

0 commit comments

Comments
 (0)