我必须通过归纳证明
no f xs ==> null (filter f xs)
在哪里 :
filter p [] = []
filter p (x:xs)
| p x = x : filter p xs
| otherwise = filter p xs
null [] = True; null _ = False
no p [] = True
no p (x:xs)
| p x = False
| otherwise = no p xs
Logic implication:
True ==> False = False
_ ==> _ = True
所以,我认为以下是我的假设和我的主张:
Assumption: no f xs ==> null (filter f xs)
Claim: no f (x:xs) ==> null (filter f (x:xs))
我开始尝试证明基本情况(空列表):
no f [] ==> null (filter f [])
== {- Filter.1, filter p [] = [] -}
no f [] ==> null ([])
== {- No.1, no p [] = True-}
True ==> null ([])
== {- Null.1, null [] = True -}
True ==> True
但是我不确定它是否正确,因为我已经证明它们都是 True 而不是如果左边部分是 True 而第二部分是 False,那么暗示是 False (即 ==> 的定义)。这个对吗?我怎样才能继续证明?我不清楚如何使用归纳来证明含义...
先感谢您!