List Coq-列表上的归纳法,每个元素都应用一个函数
我试图证明,对两个列表中的每个元素应用函数f,如果它们最初是相关的,那么结果是相似的List Coq-列表上的归纳法,每个元素都应用一个函数,list,coq,induction,List,Coq,Induction,我试图证明,对两个列表中的每个元素应用函数f,如果它们最初是相关的,那么结果是相似的rel_listlist。我在列表的元素上有一个rel,并且已经证明了一个引理引理1,如果两个元素在rel中,那么在函数f应用于两个元素之后,它们都在rel中。我尝试在列表和rel_list上进行归纳,但在基本情况得到解决后,我最终得到了类似xL::xL0::xlL0=xL0::xlL0的情况,或者输入循环。请有人建议我如何关闭校样。 谢谢 Variable A:Type. Variable rel: A
rel_list
list。我在列表的元素上有一个rel
,并且已经证明了一个引理引理1
,如果两个元素在rel
中,那么在函数f应用于两个元素之后,它们都在rel
中。我尝试在列表和rel_list
上进行归纳,但在基本情况得到解决后,我最终得到了类似xL::xL0::xlL0=xL0::xlL0
的情况,或者输入循环。请有人建议我如何关闭校样。
谢谢
Variable A:Type.
Variable rel: A -> A -> Prop.
Variable f: A -> A.
Lemma lemma1: forall n m n' m',
rel n m ->
n' = f n ->
m' = f m ->
rel n' m'.
Proof.
...
Qed
Inductive rel_list : list A -> list A -> Prop :=
| rel_list_nil : rel_list nil nil
| rel_list_cons: forall x y xl yl,
rel x y ->
rel_list xl yl ->
rel_list (x::xl) (y::yl).
Fixpoint f_list (xl: list A) : list A :=
match xl with
| nil => xl
| x :: xl' => f x :: (f_list xl')
end.
Lemma Lemma2: forall lL lR lL' lR',
rel_list lL lR ->
lL' = f_list lL ->
lR' = f_list lR ->
rel_list lL' lR'.
Proof.
intros ? ? ? ? Hsim HmL HmR.
通过对
rel_列表
假设进行归纳,可以很容易地看出这一点。这是一个通用版本,它使用标准库中的函数:
Require Import Coq.Lists.List.
Section Lists.
Variables A1 A2 B1 B2 : Type.
Variables (RA : A1 -> A2 -> Prop) (RB : B1 -> B2 -> Prop).
Variables (f1 : A1 -> B1) (f2 : A2 -> B2).
Hypothesis parametric : forall a1 a2, RA a1 a2 -> RB (f1 a1) (f2 a2).
Lemma l : forall l1 l2, Forall2 RA l1 l2 ->
Forall2 RB (map f1 l1) (map f2 l2).
Proof.
intros.
induction H as [|a1 a2 l1 l2 HR H IH]; simpl; constructor; eauto.
Qed.
End Lists.
这对我的关系和我的类型起了作用。。。谢谢你的帮助。