@@ -49,7 +49,8 @@ open import Relation.Binary.PropositionalEquality as ≡
49
49
using (≡-≟-identity; ≢-≟-identity)
50
50
open import Relation.Nullary.Decidable as Dec
51
51
using (Dec; _because_; yes; no; _×-dec_; _⊎-dec_; map′)
52
- open import Relation.Nullary.Negation.Core using (¬_; contradiction)
52
+ open import Relation.Nullary.Negation.Core
53
+ using (¬_; contradiction; contradiction′)
53
54
open import Relation.Nullary.Reflects using (invert)
54
55
open import Relation.Unary as U
55
56
using (U; Pred; Decidable; _⊆_; Satisfiable; Universal)
@@ -1076,24 +1077,26 @@ pigeonhole : m ℕ.< n → (f : Fin n → Fin m) → ∃₂ λ i j → i < j ×
1076
1077
pigeonhole z<s f = contradiction (f zero) λ ()
1077
1078
pigeonhole (s<s m<n@(s≤s _)) f with any? (λ k → f zero ≟ f (suc k))
1078
1079
... | yes (j , f₀≡fⱼ) = zero , suc j , z<s , f₀≡fⱼ
1079
- ... | no f₀≢fₖ
1080
- with i , j , i<j , fᵢ≡fⱼ ← pigeonhole m<n (λ j → punchOut (f₀≢fₖ ∘ (j ,_ )))
1081
- = suc i , suc j , s<s i<j , punchOut-injective (f₀≢fₖ ∘ (i ,_)) _ fᵢ≡fⱼ
1082
-
1083
- injective⇒≤ : ∀ {f : Fin m → Fin n} → Injective _≡_ _≡_ f → m ℕ.≤ n
1084
- injective⇒≤ {zero} {_} {f} _ = z≤n
1085
- injective⇒≤ {suc _} {zero} {f} _ = contradiction (f zero) ¬Fin0
1086
- injective⇒≤ {suc _} {suc _} {f} inj = s≤s (injective⇒≤ (λ eq →
1087
- suc-injective (inj (punchOut-injective
1088
- (contraInjective inj 0≢1+n)
1089
- (contraInjective inj 0≢1+n) eq))))
1080
+ ... | no f₀≢fₖ =
1081
+ let i , j , i<j , fᵢ≡fⱼ = pigeonhole m<n (λ j → punchOut (f₀≢fₖ ∘ (j ,_ )))
1082
+ in suc i , suc j , s<s i<j , punchOut-injective (f₀≢fₖ ∘ (i ,_)) _ fᵢ≡fⱼ
1090
1083
1091
1084
<⇒notInjective : ∀ {f : Fin m → Fin n} → n ℕ.< m → ¬ (Injective _≡_ _≡_ f)
1092
- <⇒notInjective n<m inj = ℕ.≤⇒≯ (injective⇒≤ inj) n<m
1085
+ <⇒notInjective {f = f} n<m inj =
1086
+ let i , j , i<j , fᵢ≡fⱼ = pigeonhole n<m f in <-irrefl (inj fᵢ≡fⱼ) i<j
1087
+
1088
+ -- specialised to m = suc n
1089
+
1090
+ private
1091
+ notInjective-Fin[1+n]→Fin[n] : ∀ {f : Fin (suc n) → Fin n} → ¬ (Injective _≡_ _≡_ f)
1092
+ notInjective-Fin[1+n]→Fin[n] {n = n} = <⇒notInjective (ℕ.n<1+n n)
1093
+
1094
+ injective⇒≤ : ∀ {f : Fin m → Fin n} → Injective _≡_ _≡_ f → m ℕ.≤ n
1095
+ injective⇒≤ = ℕ.≮⇒≥ ∘ flip <⇒notInjective
1093
1096
1094
1097
ℕ→Fin-notInjective : ∀ (f : ℕ → Fin n) → ¬ (Injective _≡_ _≡_ f)
1095
- ℕ→Fin-notInjective f inj = ℕ.<-irrefl refl
1096
- (injective⇒≤ ( Comp.injective _≡_ _≡_ _≡_ toℕ-injective inj))
1098
+ ℕ→Fin-notInjective f =
1099
+ notInjective-Fin[1+n]→Fin[n] ∘ Comp.injective _≡_ _≡_ _≡_ toℕ-injective
1097
1100
1098
1101
-- Cantor-Schröder-Bernstein for finite sets
1099
1102
@@ -1108,7 +1111,7 @@ injective⇒existsPivot : ∀ {f : Fin n → Fin m} → Injective _≡_ _≡_ f
1108
1111
injective⇒existsPivot {f = f} f-injective i
1109
1112
with any? (λ j → j ≤? i ×-dec i ≤? f j)
1110
1113
... | yes result = result
1111
- ... | no ¬result = contradiction (injective⇒≤ f∘inject!-injective) ℕ.1+n≰n
1114
+ ... | no ¬result = contradiction′ notInjective-Fin[1+n]→Fin[n] f∘inject!-injective
1112
1115
where
1113
1116
fj<i : (j : Fin′ (suc i)) → f (inject! j) < i
1114
1117
fj<i j with f (inject! j) <? i
0 commit comments