[英]Splitting a premise with conjunction conclusion in Coq
我經常需要做“歸納加載”來證明Coq中的目標,在Coq中我可以通過歸納法同時證明多件事。
問題是,我經常遇到以下形式的歸納假設:
forall a1 ... an,
Premise1 -> Premise2 -> ... Premisek ->
Conclusion1 /\ Conclusion2 /\ ... Conclusion_m
很好,但是像eauto
這樣的策略確實不知道如何處理這樣的事情,因此它在大多數情況下會扼殺自動化。
我想知道的是,有沒有一種方法可以自動將這樣的前提分解為m
不同的前提,即
forall a1 ... an,
Premise1 -> Premise2 -> ... Premisek ->
Conclusion1
...
forall a1 ... an,
Premise1 -> Premise2 -> ... Premise_k ->
Conclusion_m
我遇到的主要問題是我不知道如何與LTac中任意長度的箭頭鏈匹配。 我可以將代碼硬編碼到一定長度,但是我希望有更好的方法。
另外,如果有可能做對偶(即在Premise1 .. Premise_k中的所有析取的所有組合上拆分),這也將很有用。
我不是Ltac的專家,但是我嘗試了一下,並提出了以下策略。
Ltac decomp H :=
try match type of H with
context c [?A /\ ?B] =>
let H' := fresh H in
let Pa := context c[A] in
assert (H' : Pa) by (apply H);
let H'' := fresh H in
let Pb := context c[B] in
assert (H'' : Pb) by (apply H);
clear H;
rename H' into H;
rename H'' into H';
decomp H'
end.
Tactic Notation "decomp_hyp" hyp(H) := decomp H.
decomp H
搜索在連接詞的出現H
,然后將其分解成H'
和H''
,清潔狀態和遞歸調用自身。
在一個簡單的例子中,這似乎可行。
也許像這樣(減去調試打印輸出)?
Ltac foo :=
match goal with
| |- forall q, ?X =>
let x := fresh in intros x; idtac x q ; (try foo); generalize x as q; clear x
| |- ?X -> _ =>
let x := fresh in intros x; idtac x ; (try foo); generalize x; clear x
| |- _ /\ _ => repeat split
end; idtac "done".
Goal forall {T} (a1 a2 a3:T) P1 P2 P3 Q1 Q2 Q3, P1 a1 -> P2 a2 -> P3 a3 -> Q1 /\ Q2 /\ Q3.
foo.
這使您有了目標
3 subgoals (ID 253)
============================
forall (T : Type) (a1 a2 a3 : T) (P1 P2 P3 : T -> Type) (Q1 : Prop),
Prop -> Prop -> P1 a1 -> P2 a2 -> P3 a3 -> Q1
subgoal 2 (ID 254) is:
forall (T : Type) (a1 a2 a3 : T) (P1 P2 P3 : T -> Type),
Prop -> forall Q2 : Prop, Prop -> P1 a1 -> P2 a2 -> P3 a3 -> Q2
subgoal 3 (ID 255) is:
forall (T : Type) (a1 a2 a3 : T) (P1 P2 P3 : T -> Type),
Prop -> Prop -> forall Q3 : Prop, P1 a1 -> P2 a2 -> P3 a3 -> Q3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.