Search code examples
agdaplfa

How to prove ¬ 2 < 1 in agda?


I think I must missing something to prove ¬ 2 < 1.

I have

¬1<0 : ¬ (1 < 0)
¬1<0 = λ()

¬0<0 : ¬ (0 < 0)
¬0<0 = λ()

¬2<0 : ¬ (2 < 0)
¬2<0 = λ()


contraposition : ∀ {A B : Set}
→ (A → B)
    -----------
→ (¬ B → ¬ A)
contraposition f ¬y x = ¬y (f x) 

If I want to prove ¬ 2 < 1 I can use contraposition like this:

¬2<1 : ¬ (2 < 1)
¬2<1 =  contraposition 2<1->1<0 ¬1<0

But 2<1->1<0 : 2 < 1 → 1 < 0 seem not simple to prove

We can simple s<s on 1 < 0.

1<0->2<1 : 1 < 0 → 2 < 1
1<0->2<1  x =  s<s x

But we can't easy do same thing on 2 < 1 Because we have <

data _<_ : ℕ → ℕ → Set where

    z<s : ∀ {n : ℕ}
        ------------
        → zero < suc n

    s<s : ∀ {m n : ℕ}
        → m < n
        -------------
        → suc m < suc n

I know the

_∸_ : ℕ → ℕ → ℕ  -
m     ∸ zero   =  m
zero  ∸ suc n  =  zero
suc m ∸ suc n  =  m ∸ n

may have help to prove 2<1->1<0. My intuition tell me, introduce _∸_ to prove this problem will be more complicate. There must something I don't know in Agda and it is obvious.

PS:

I must say "The solutions" will don't effect the people who take responsibility for themself. One student is good because he is good. I ask help here not because I want to get some answer to do exam. I am not a student anymore. I just got difficult and need some tips to go on. It need 1500 reputation to create tag likse plfa. Can anyone help it?


Solution

  • Many alternative approaches can be contrived. For your approach to work, you can prove 2<1->1<0, which is simple enough.

    sm<sn->m<n : {m n : ℕ} -> suc m < suc n -> m < n
    sm<sn->m<n (s<s m<n) = m<n
    
    ¬2<1 : ¬ (2 < 1)
    ¬2<1 = contraposition sm<sn->m<n ¬1<0