Martin Escardo and Paulo Oliva 2011

\begin{code}

{-# OPTIONS --without-K #-}

module InfinitePigeon.J-InfinitePigeon where

\end{code}

20 May 2011

We use the J-translation instead, also called Peirce translation.

We prefix equations with K.  This eliminates efq R->A for all
formulas in the image of the translation.

We prefix ∃ and ∨ with J.  This eliminates Peirces law JA->A for
all formulas in the image of the translation.

In the end there is not much difference with InfinitePigeon.

\begin{code}

open import InfinitePigeon.Addition
open import InfinitePigeon.Cantor
open import InfinitePigeon.Equality
open import InfinitePigeon.J-AC-N
open import InfinitePigeon.JK-LogicalFacts
open import InfinitePigeon.JK-Monads
open import InfinitePigeon.Logic
open import InfinitePigeon.LogicalFacts
open import InfinitePigeon.Naturals
open import InfinitePigeon.Order
open import InfinitePigeon.Two

Pigeonhole : {R : Ω}  ₂ℕ  Ω
Pigeonhole {R} α =
    \(b : )   \(g :   ) 
   ∀(i : )  g i < g(i + 1)  K {R} (α(g i)  b)


pigeonhole : {R : Ω}
            ∀(α : ₂ℕ)  J(Pigeonhole α)
pigeonhole {R} α = J-∨-elim case₀ case₁ J-Excluded-Middle
 where
  A : Ω
  A =  \(n : )  ∀(i : )  K(α(n + i)  )

  case₀ : A  J(Pigeonhole α)
  case₀ = ηJ  lemma₁
   where
    lemma₁ : A  Pigeonhole α
    lemma₁ (∃-intro n h) =
            ∃-intro  (∃-intro  i  n + i)
                                λ i  (∧-intro (less-proof 0) (h i)))

  case₁ : (A  R)  J(Pigeonhole α)
  case₁ assumption =  J-functor lemma₇ lemma₆
   where
    lemma₂ : ∀(n : )  (∀(i : )  K(α(n + i)  ))  R
    lemma₂ = not-exists-implies-forall-not assumption

    lemma₃ : ∀(n : )  J∃ \(i : )  K(α(n + i)  )
    lemma₃ = lemma₄ lemma₂
     where
      lemma₄ : (∀(n : )  (∀(i : )  K(α(n + i)  ))  R) 
               (∀(n : )  J∃ \(i : )  K(α(n + i)  ))
      lemma₄ h n = K-J {R} efq (K-functor lemma₅ (not-forall-not-implies-K-exists(h n)))
       where
        efq : R   \(i : )  K{R}(α(n + i)  )
        efq r = ∃-intro 0  p  r)

        lemma₅ : ( \(i : )  α(n + i)    R)   \(i : )  K(α(n + i)  )
        lemma₅ (∃-intro i r) = (∃-intro i (two-equality-cases (α(n + i)) r))

    lemma₆ : J∃ \(f :   )  ∀(n : )  K(α(n + f n)  )
    lemma₆ = J-AC-ℕ lemma₃

    lemma₇ : ( \(f :   )  ∀(n : )  K(α(n + f n)  ))  Pigeonhole α
    lemma₇ (∃-intro f h) =
            ∃-intro  (∃-intro g λ i  (∧-intro (fact₀ i) (fact₁ i)))
     where
      g :   
      g 0 = 0 + f 0
      g(succ i) = let j = g i + 1 in  j + f j

      fact₀ : ∀(i : )  g i < g(i + 1)
      fact₀ i = let n = f(g i + 1)
                in ∃-intro n (trivial-addition-rearrangement (g i) n 1)


      fact₁ : ∀(i : )  K(α(g i)  )
      fact₁ 0 = h 0
      fact₁ (succ i) = h(g i + 1)

\end{code}