COQ中的电感类型的证明
我试图证明以下定理:
Theorem implistImpliesOdd :
forall (n:nat) (l:list nat), implist n l -> Nat.Odd(length l).
含义如下:
Inductive implist : nat -> list nat -> Prop :=
| GSSingle : forall (n:nat), implist n [n]
| GSPairLeft : forall (a b n:nat) (l:list nat), implist n l -> implist n ([a]++[b]++l)
| GSPairRight : forall (a b n:nat) (l:list nat), implist n l -> implist n (l++[a]++[b]).
在证明期间,我达到了以下最终目标:
n: nat
l: list nat
a, b: nat
H: implist n (a :: b :: l)
IHl: implist n l -> Nat.Odd (length l)
=======================================
Nat.Odd (length l)
但是似乎倒置无法完成工作...
我该如何证明定理?
感谢您的帮助 !!
I try to prove the following theorem:
Theorem implistImpliesOdd :
forall (n:nat) (l:list nat), implist n l -> Nat.Odd(length l).
where implist is as follows :
Inductive implist : nat -> list nat -> Prop :=
| GSSingle : forall (n:nat), implist n [n]
| GSPairLeft : forall (a b n:nat) (l:list nat), implist n l -> implist n ([a]++[b]++l)
| GSPairRight : forall (a b n:nat) (l:list nat), implist n l -> implist n (l++[a]++[b]).
During the proof, I reach the following final goal :
n: nat
l: list nat
a, b: nat
H: implist n (a :: b :: l)
IHl: implist n l -> Nat.Odd (length l)
=======================================
Nat.Odd (length l)
But it seems an inversion can't do the job...
How can I prove the theorem ?
Thank you for your help !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需在
inmandist
谓语上进行诱导即可。例如,You can just proceed by induction on the
implist
predicate itself. E.g.,假设
h:inmandist n(a :: b :: b :: l)
不一定是从gspairleft
开始的证明,它也可以由gspairright的实例
,l = l = l'++ [c] ++ [d]
,您的归纳假设将不适用。您可以在列表的长度上而不是在列表本身上解决问题来解决问题。It is not necessarily the case that the assumption
H : implist n (a :: b :: l)
comes from a proof starting withGSPairLeft
, it could as well consist of an instance ofGSPairRight
withl = l' ++ [c] ++ [d]
and your induction hypothesis wouldn't apply. You can solve your problem using strong induction on the length of the list rather than on the list itself.