[英]Logical Coq Proof related to map function
I am trying to prove the following Lemma:我试图证明以下引理:
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.
I begin by splitting to handle the first direction, then do induction on l, then the base case is easy.我首先拆分处理第一个方向,然后对 l 进行归纳,那么基本情况很容易。 But past that I get stuck.但过去我卡住了。 I think it's something to do with exists x and how I cannot get x to line up with x0 no matter where I try introducing x.我认为这与存在 x 以及无论我在哪里尝试引入 x 都无法让 x 与 x0 对齐有关。 Help!帮助!
I don't understand your problem about x0
, if this is about Coq automatically renaming x
to x0
.我不明白你关于x0
的问题,如果这是关于 Coq 自动将x
重命名为x0
。
If I were to tackle your goal I would do it as follows:如果我要解决你的目标,我会这样做:
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.
Perhaps you wanted to line up the induction hypothesis and the goal to apply it directly?也许您想排列归纳假设和直接应用它的目标? Unfortunately I think you have to do as I do, by first destructing the induction hypothesis into an x
and its properties and then reconstruct the goal where you stipulate it's in the tail of l
.不幸的是,我认为您必须像我一样做,首先将归纳假设破坏为x
及其属性,然后在您规定它位于l
尾部的位置重构目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.