[英]How to group duplicated hypothesis in Coq?
I have我有
1 subgoals, subgoal 1
n : nat
b : bool
m : nat
H1: P1
H2: P2
H3: P1
H4: P2
=========
some_goal
after I run the tactic auto_group_duplicates
, it will become在我运行战术
auto_group_duplicates
,它会变成
1 subgoals, subgoal 1
n, m : nat
b : bool
H1, H3: P1
H2, H4: P2
=========
some_goal
Is there a tactic like this one?有这样的战术吗?
I don't think that there is a tactic like this.我不认为有这样的策略。 But you can always come up with something using Ltac.
但是你总是可以使用 Ltac 想出一些东西。
From Coq Require Import Utf8.
Definition mark {A : Type} (x : A) := x.
Ltac bar :=
match goal with
| x : ?A, y : ?A |- _ =>
lazymatch A with
| context [ mark ] => fail
| _ =>
move y after x ;
change A with (mark A) in x
end
end.
Ltac remove_marks :=
repeat match goal with
| x : mark ?A |- _ =>
change (mark A) with A in x
end.
Ltac auto_group_duplicates :=
repeat bar ; remove_marks.
Lemma foo :
∀ (n : nat) (b : bool) (m : nat) (c : bool),
n = m →
b = c →
n = m →
b = c →
n = m →
True.
Proof.
intros n b m c e1 e2 e3 e4 e5.
auto_group_duplicates.
auto_group_duplicates.
Here I have to apply the tactic twice because Ltac unifies A
with mark A
annoyingly.在这里,我必须两次应用该策略,因为 Ltac 烦人地将
A
与mark A
统一起来。
You can manually use the move
tactic (see https://coq.inria.fr/refman/proof-engine/tactics.html?highlight=top#coq:tacn.move-%E2%80%A6-after-%E2%80%A6 ) to rearrange hypothesis.您可以手动使用
move
策略(参见https://coq.inria.fr/refman/proof-engine/tactics.html?highlight=top#coq:tacn.move-%E2%80%A6-after-%E2 %80%A6 ) 重新排列假设。
I doubt that there is a general automatic tactic like the one you are looking for, but one could probably cook up a fancy match-goal
-based one to automate rearranging hypothesis using this tactic as a basic block, although this is out of my league.我怀疑是否有像您正在寻找的那样的通用自动策略,但人们可能会编造一种基于
match-goal
的奇特策略,以使用此策略作为基本块来自动重新排列假设,尽管这超出了我的能力.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.