module DrinkerParadox where
open import Logic
open import Equality
open import Naturals
open import Two
open import Cantor
open import GenericConvergentSequence
Theorem-3·6 :
∀(p : ₂ℕ → ₂) → extensional p →
∃ \(x : ₂ℕ) → x ∈ ℕ∞ ∧
(p x ≡ ₁ → ∀(y : ₂ℕ) → y ∈ ℕ∞ → p y ≡ ₁)
Theorem-3·6 p extensionality-of-p = ∃-intro x (∧-intro Lemma₀ Lemma₁)
where
x : ₂ℕ
x 0 = p(underline 0)
x(succ n) = min (x n) (p(underline(succ n)))
Lemma₀ : x ∈ ℕ∞
Lemma₀ i = Lemma[minab≤a]
Dagger₀ : ∀(n : ℕ) → x ≣ underline n → p(underline n) ≡ ₀
Dagger₀ 0 r = r 0
Dagger₀ (succ n) r = transitivity u t
where s : x n ≡ ₁
s = transitivity (r n) (Lemma[underline-1] n)
t : x(succ n) ≡ ₀
t = transitivity (r(succ n)) (Lemma[underline-0] n)
u : p(underline(succ n)) ≡ x(succ n)
u = symmetry(extensionality(λ a → min a (p(underline(succ n)))) s)
Dagger₁ : x ≣ ∞ → ∀(n : ℕ) → p(underline n) ≡ ₁
Dagger₁ r 0 = r 0
Dagger₁ r (succ n) = transitivity u t
where s : x n ≡ ₁
s = r n
t : x(succ n) ≡ ₁
t = r(succ n)
u : p(underline(succ n)) ≡ x(succ n)
u = symmetry(extensionality(λ a → min a (p(underline(succ n)))) s)
Claim₀ : p x ≡ ₁ → ∀(n : ℕ) → ¬(x ≣ underline n)
Claim₀ r n s = Lemma[b≡₁→b≠₀] r (Lemma s)
where Lemma : x ≣ underline n → p x ≡ ₀
Lemma r = transitivity (extensionality-of-p r) (Dagger₀ n r)
Claim₁ : p x ≡ ₁ → x ≣ ∞
Claim₁ r = Lemma[ℕ∞∖underline[ℕ]⊆[∞]] x Lemma₀ (Claim₀ r)
Claim₂ : p x ≡ ₁ → ∀(n : ℕ) → p(underline n) ≡ ₁
Claim₂ r = Dagger₁(Claim₁ r)
Claim₃ : p x ≡ ₁ → p ∞ ≡ ₁
Claim₃ r = fact r (extensionality-of-p(Claim₁ r))
where fact : ∀{a b : ₂} → a ≡ ₁ → a ≡ b → b ≡ ₁
fact refl refl = refl
Lemma₁ : p x ≡ ₁ → ∀(y : ₂ℕ) → y ∈ ℕ∞ → p y ≡ ₁
Lemma₁ r = Lemma[density] p extensionality-of-p (Claim₂ r) (Claim₃ r)