证明(prev n)&lt; = m从n <= m开始

时间:2012-10-20 23:38:30

标签: agda

我有下一个定义:

data Nat : Set where
  zero : Nat
  succ : Nat -> Nat

prev : Nat -> Nat
prev zero = zero
prev (succ n) = n

data _<=_ : Nat -> Nat -> Set where
  z<=n : forall {n} -> zero <= n
  s<=s : forall {n m} -> (n<=m : n <= m) -> (succ n) <= (succ m)

很容易证明下一个引理:

lem-prev : {x y : Nat} -> x <= y -> (prev x) <= (prev y)
lem-prev z<=n = z<=n
lem-prev (s<=s t) = t

但我无法找到证明下一个引理的方法:

lem-prev' : {x y : Nat} -> x <= y -> (prev x) <= y

我可以将<=的定义更改为下一个:

data _<='_ : Nat -> Nat -> Set where
  z<=n' : forall {n} -> zero <=' n
  s<=s' : forall {n m} -> (n<=m : n <=' m) -> (succ n) <=' m

在这种情况下,我可以证明lem-prev'

lem-prev' : {x y : Nat} -> x <=' y -> (prev x) <=' y
lem-prev' z<=n' = z<=n'
lem-prev' (s<=s' t) = t

但现在我无法证明lem-prev

有没有办法证明<=和/或<='的两个引理? 如果不是,那么我应该如何更改定义以使其成为可能?

ADD:使用hammar辅助引理的解决方案:

lem-prev : {x y : Nat} -> x <= y -> (prev x) <= y
lem-prev z<=n = z<=n
lem-prev (s<=s prev-n<=prev-m) = weaken (prev-n<=prev-m)

2 个答案:

答案 0 :(得分:5)

您可以在标准库中找到该引理的证明 http://www.cse.chalmers.se/~nad/listings/lib/Data.Nat.Properties.html#10457

答案 1 :(得分:4)

试试这个引理:

weaken : {x y : Nat} -> x <= y -> x <= succ y
weaken z<=n = z<=n
weaken (s<=s n<=m) = s<=s (weaken n<=m)