Буду признателен за некоторые рекомендации, завершающие это доказательство.Я застрял в последнем admit
(остальные я выполнил без проблем, но я опускаю реальные доказательства).
Я добавил комментарии после моих рассуждений, потому что я думаю, что это объясняет лучше меняпытаясь описать это в абзаце.
Это определение используемых функций:
In =
fix In (A : Type) (x : A) (l : list A) {struct l} : Prop := match l with
| [ ] => False
| x' :: l' => x' = x \/ In A x l'
end
: forall A : Type, A -> list A -> Prop
Argument A is implicit and maximally inserted
Argument scopes are [type_scope _ _]
map =
fix map (X Y : Type) (f : X -> Y) (l : list X) {struct l} : list Y := match l with
| [ ] => [ ]
| h :: t => f h :: map X Y f t
end
: forall X Y : Type, (X -> Y) -> list X -> list Y
Arguments X, Y are implicit and maximally inserted
Argument scopes are [type_scope type_scope function_scope _]
А вот и лемма:
Lemma foo :
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.
- admit.
- induction l as [|x0 l' HIl'].
* admit.
* (*
HIl': (exists x : A, f x = y /\ In x l') -> In y (map f l')
Goal: (exists x : A, f x = y /\ In x (x0 :: l')) -> In y (map f (x0 :: l'))
*)
intros H. simpl.
(*
Goal: f x0 = y \/ In y (map f l')
*)
right.
(*
Taking the right side, because if `f x0 = y`, then the induction
hypothesis would tell us nothing.
*)
apply HIl'.
(*
Goal: exists x : A, f x = y /\ In x l'
*)
destruct H as [x1 H']. exists x1.
(*
This `x1` should be the element that is in both `l'` and `x0 ::
l'`, because we discarded the case when `f x0 = y`.
Goal: f x1 = y /\ In x1 l'
*)
destruct H' as [H'l H'r]. split.
+ (* Goal: fx1 = y *) apply H'l .
+ (* Goal: In x1 l' *)
(*
`x1` must be in `l'`, because we know it is in x0 :: l` by H'r:
H'r: In x1 (x0 :: l')
and we discarded the case where `f x0 = y`.
*)
destruct H'r as [H'rl | H'rr].
{ (* Stuck!!! *) admit. }
{ apply H'rr. } Abort.