[英]Logical Coq Proof related to map function
我試圖證明以下引理:
forall (A B : Type) (f : A -> B) (l : list A) (y : B),
In y (map f l) <->
exists x, f x = y /\ In x l.
我首先拆分處理第一個方向,然后對 l 進行歸納,那么基本情況很容易。 但過去我卡住了。 我認為這與存在 x 以及無論我在哪里嘗試引入 x 都無法讓 x 與 x0 對齊有關。 幫助!
我不明白你關於x0
的問題,如果這是關於 Coq 自動將x
重命名為x0
。
如果我要解決你的目標,我會這樣做:
Goal forall (A B : Type) (f : A -> B) (l : list A) (y : B),
In y (map f l) <->
exists x, f x = y /\ In x l.
Proof.
intros A B f l y. split.
- intro h. induction l as [| a l ih].
+ contradict h.
+ simpl in h. destruct h as [h | h].
* exists a. split.
-- assumption.
-- left. reflexivity.
* specialize (ih h). destruct ih as [x [e i]].
exists x. split.
-- assumption.
-- right. assumption.
也許您想排列歸納假設和直接應用它的目標? 不幸的是,我認為您必須像我一樣做,首先將歸納假設破壞為x
及其屬性,然后在您規定它位於l
尾部的位置重構目標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.