# HG changeset patch # User Shinji KONO # Date 1686297291 -32400 # Node ID a93764db7c6789f4c91f53e543df67dd4ff047f2 # Parent f4bd059227f83a80fd3663d1c18d71aaf16cd1b9 ... diff -r f4bd059227f8 -r a93764db7c67 src/bijection.agda --- a/src/bijection.agda Fri Jun 09 11:26:36 2023 +0900 +++ b/src/bijection.agda Fri Jun 09 16:54:51 2023 +0900 @@ -456,7 +456,7 @@ lb04 [] = refl lb04 (false ∷ t) = refl lb04 (true ∷ []) = refl - lb04 (true ∷ t0 ) = begin + lb04 (true ∷ t0 @ (_ ∷ _)) = begin suc (suc (lton1 t0 + lton1 t0)) ≡⟨ sym (add11 (lton1 t0)) ⟩ suc (lton1 t0) + suc (lton1 t0) ≡⟨ cong (λ k → k + k ) (lb04 t0 ) ⟩ lton1 (lb+1 t0) + lton1 (lb+1 t0) ∎ where @@ -464,7 +464,7 @@ lb02 : (t : List Bool) → lton t ≡ n → lton (lb+1 t) ≡ suc n lb02 [] refl = refl - lb02 t eq1 = begin + lb02 (t @ (_ ∷ _)) eq1 = begin lton (lb+1 t) ≡⟨ refl ⟩ pred (lton1 (lb+1 t)) ≡⟨ cong pred (sym (lb04 t)) ⟩ pred (suc (lton1 t)) ≡⟨ sym (sucprd (lton1>0 t)) ⟩ @@ -511,13 +511,25 @@ -- the count of B is the numner of B in Bijection B ℕ -- if we have a , number a of A is larger than the numner of B C, so we have the inverse -- - record CB (n : ℕ) : Set where - field - ca cb : ℕ - cb≤n : cb ≤ suc n - ca≤cb : ca ≤ cb - na : {i : ℕ} → i < ca → A - nb : {i : ℕ} → i < cb → B + + count-B : ℕ → ℕ + count-B zero with is-B (fun← cn zero) + ... | yes isb = 1 + ... | no nisb = 0 + count-B (suc n) with is-B (fun← cn (suc n)) + ... | yes isb = suc (count-B n) + ... | no nisb = count-B n + + bton : B → ℕ + bton b = count-B (fun→ cn (g b)) + + count-A : ℕ → ℕ + count-A zero with is-A (fun← cn zero) + ... | yes isb = 1 + ... | no nisb = 0 + count-A (suc n) with is-A (fun← cn (suc n)) + ... | yes isb = suc (count-A n) + ... | no nisb = count-A n ¬isA∧isB : (y : C ) → Is A C (λ x → g ( f x)) y → ¬ Is B C g y → ⊥ ¬isA∧isB y isa nisb = ⊥-elim ( nisb record { a = f (Is.a isa) ; fa=c = lem } ) where @@ -527,76 +539,40 @@ y ∎ where open ≡-Reasoning - lb : (n : ℕ ) → CB n - lb zero with is-A (fun← cn zero) | is-B (fun← cn zero) - ... | yes isA | yes isB = record { ca = suc zero ; cb = suc zero ; cb≤n = ≤-refl ; ca≤cb = ≤-refl ; na = λ _ → Is.a isA ; nb = λ _ → Is.a isB } + ca≤cb0 : (n : ℕ) → count-A n ≤ count-B n + ca≤cb0 zero with is-A (fun← cn zero) | is-B (fun← cn zero) + ... | yes isA | yes isB = ≤-refl ... | yes isA | no nisB = ⊥-elim ( ¬isA∧isB _ isA nisB ) - ... | no nisA | yes isB = record { ca = zero ; cb = suc zero ; cb≤n = ≤-refl ; ca≤cb = px≤x ; na = λ () ; nb = λ _ → Is.a isB } - ... | no nisA | no nisB = record { ca = zero ; cb = zero ; cb≤n = px≤x ; ca≤cb = ≤-refl ; na = λ () ; nb = λ () } - lb (suc n) with is-A (fun← cn (suc n)) | is-B (fun← cn (suc n)) - ... | yes isA | yes isB = record { ca = suc (CB.ca (lb n)) ; cb = suc (CB.cb (lb n)) ; cb≤n = s≤s (CB.cb≤n (lb n)) ; ca≤cb = s≤s (CB.ca≤cb (lb n)) - ; na = na ; nb = nb } where - na : {i : ℕ} → i < suc (CB.ca (lb n)) → A - na {i} i