Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swiftプログラミングと論理 〜そして帰ってきた圏論〜 / Swift and Logic,...

Yasuhiro Inami
September 06, 2019

Swiftプログラミングと論理 〜そして帰ってきた圏論〜 / Swift and Logic, and Category Theory

Swiftプログラミングと論理 〜そして帰ってきた圏論〜 iOSDC Japan 2019 (Sep 6, 2019)
https://fortee.jp/iosdc-japan-2019/proposal/9529444c-a849-47cd-94a7-bf2b694320aa

Yasuhiro Inami

September 06, 2019
Tweet

More Decks by Yasuhiro Inami

Other Decks in Programming

Transcript

  1. ࿦ཧࣜͷྫ A ∧ (B → C) (A ∨ B) ∧

    (C → D) (¬A → ⊥ ) ∨ (¬B ∧ ⊤ )
  2. ࿦ཧࣜʢه߸ʣˠਅཧ஋ͷׂΓ౰ͯ A B ¬A A∧B A∨B A→B 1 1 0

    1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 ෇஋ ਅ ِ A → B A ∧ B A ∨ B ¬A ֤ม߲ͷਅِΛܾΊΔ ʹߦΛબͿ
  3. ਅཧ஋දͷྫ A B ¬A ¬A∨B A→B (¬A∨B) → (A→B) (A→B)

    → (¬A∨B) 1 1 0 1 1 1 1 1 0 0 0 0 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 ৗʹʹͳΔ ࿦ཧ͕ࣜଘࡏ
  4. ߃ਅʢτʔτϩδʔʣͷྫ (A → B) → ((B → C) → (A

    → C)) ((((A → B) → (¬C → ¬D)) → C) → E) → ((E → A) → (D → A)) ¬(A ∧ ¬A) (A ∧ ¬A) → B ((A → B) → A) → A ¬¬A → A (A → B) ↔ (¬B → ¬A) ¬(A ∧ B) ↔ (¬A ∨ ¬B) ¬(A ∨ B) ↔ (¬A ∧ ¬B)
  5. (A → B) → ((B → C) → (A →

    C)) ((((A → B) → (¬C → ¬D)) → C) → E) → ((E → A) → (D → A)) ¬(A ∧ ¬A) (A ∧ ¬A) → B ((A → B) → A) → A ¬¬A → A (A → B) ↔ (¬B → ¬A) ¬(A ∧ B) ↔ (¬A ∨ ¬B) ¬(A ∨ B) ↔ (¬A ∧ ¬B) ߃ਅʢτʔτϩδʔʣͷྫ ໃ६཯ രൃ཯ ೋॏ൱ఆআڈ ύʔεͷ๏ଇ ରۮ཯ υɾϞϧΨϯͷ๏ଇ ਪҠ཯ ϝϨσΟεͷެཧ
  6. ήϯπΣϯྲྀɾࣗવԋ៷ A B A ∧ B A ∧ B A

    A ∧ B B A A ∨ B B A ∨ B A ∨ B C C C A → B A B B A → B ⊥ ¬A A ¬A ⊥ ⊥ A ⋮ [A] ¬¬A A ⋮ [A] ⋮ [B] ⋮ [A] <">ʜ"ͷԾఆΛด͡Δ
  7. ήϯπΣϯྲྀɾࣗવԋ៷ʢγʔΫΤϯτܭࢉ෩ʣ Γ ⊢ A Γ ⊢ B Γ ⊢ A

    ∧ B Γ ⊢ A ∧ B Γ ⊢ A Γ ⊢ A ∧ B Γ ⊢ B Γ ⊢ A Γ ⊢ A ∨ B Γ ⊢ B Γ ⊢ A ∨ B Γ ⊢ A ∨ B Γ, A ⊢ C Γ, B ⊢ C Γ ⊢ C Γ ⊢ A → B Γ ⊢ A Γ ⊢ B Γ, A ⊢ B Γ ⊢ A → B Γ, A ⊢ ⊥ Γ ⊢ ¬A Γ ⊢ A Γ ⊢ ¬A Γ ⊢ ⊥ Γ ⊢ ⊥ Γ ⊢ A Γ ⊢ ¬¬A Γ ⊢ A A ∈ Γ Γ ⊢ A ϵ⊢"ʜ࿦ཧࣜͷ༗ݶྻϵ͔Βɺ࿦ཧࣜ"͕ূ໌Ͱ͖Δ
  8. ώϧϕϧτྲྀ A → B A B B → (A →

    B) (A → (B → C)) → ((A → B) → (A → C)) ¬¬A → A A → A ∨ B ⊥ → A B → A ∨ B (A → C) → ((B → C) → ((A ∨ B) → C)) A ∧ B → A A ∧ B → B A → (B → (A ∧ B)) ਪ࿦نଇ͸ ϞʔμεϙωϯεͷΈ (A → ¬A) → ¬A ¬A → (A → B)
  9. ࿦ཧ˱4XJGUϓϩάϥϛϯά A → B A ∧ B A ∨ B

    ¬A := A → ⊥ ରԠ 㱻 ؔ਺ܕ ௚ੵܕ ௚࿨ܕ ⊥ Either<A, B> Never typealias Not<A> = (A) -> Never (A, B) (A) -> B ϘτϜܕ 㲄Λ࢖ͬͯ ൱ఆΛఆٛͰ͖Δ
  10. ʲ࠶ܝʳήϯπΣϯྲྀɾࣗવԋ៷ A B A ∧ B A ∧ B A

    A ∧ B B A A ∨ B B A ∨ B A ∨ B C C C A → B A B B A → B ⊥ ¬A A ¬A ⊥ ⊥ A ⋮ [A] ¬¬A A ⋮ [A] ⋮ [B] ⋮ [A]
  11. /// `B ===> A → B` /// - Note: More

    formally, A ⊢ B ===> ⊢ A → B. func implyIntro<A, B>(_ b: B) -> ((A) -> B) { { _ in b } } /// `A → B, A ===> B` (Modus ponens) func implyElim<A, B>(_ f: (A) -> B, _ a: A) -> B { f(a) } A → B A B B A → B ⋮ [A]
  12. /// `A, B ===> A ∧ B` func andIntro<A, B>(_

    a: A, _ b: B) -> (A, B) { (a, b) } /// `A ∧ B ===> A` func andElim1<A, B>(_ ab: (A, B)) -> A { ab.0 } /// `A ∧ B ===> B` func andElim2<A, B>(_ ab: (A, B)) -> B { ab.1 } A B A ∧ B A ∧ B A A ∧ B B
  13. /// `A ===> A ∨ B` func orIntro1<A, B>(_ a:

    A) -> Either<A, B> { .left(a) } /// `B ===> A ∨ B` func orIntro2<A, B>(_ b: B) -> Either<A, B> { .right(b) } /// `A ∨ B, A → C, B → C ===> C` func orElim<A, B, C>( _ e: Either<A, B>, _ ac: (A) -> C, _ bc: (B) -> C ) -> C { switch e { case let .left(a): return ac(a) case let .right(b): return bc(b) } } A A ∨ B B A ∨ B A ∨ B C C C ⋮ [A] ⋮ [B]
  14. struct Not<A> { let f: (A) -> Never } ///

    `A ⊢ ⊥ ===> ⊢ ¬A` func notIntro<A>(_ x: Never) -> Not<A> { Not { _ in x } } /// `A, ¬A ===> ⊥` (NOTE: not using `fatalError`) func notElim<A>(_ a: A, _ notA: Not<A>) -> Never { notA.f(a) } ⊥ ¬A A ¬A ⊥ ⋮ [A]
  15. /// `⊥ ===> A` func absurd<A>(_ x: Never) -> A

    { // Do nothing, but it compiles. } ⊥ A
  16. ʲ࠶ܝʳώϧϕϧτྲྀ B → (A → B) (A → (B →

    C)) → ((A → B) → (A → C)) A → A ∨ B B → A ∨ B (A → C) → ((B → C) → ((A ∨ B) → C)) A ∧ B → A A ∧ B → B A → (B → (A ∧ B)) A → B A B ਪ࿦نଇ͸ ϞʔμεϙωϯεͷΈ ¬¬A → A ⊥ → A (A → ¬A) → ¬A ¬A → (A → B)
  17. ʲ࠶ܝʳώϧϕϧτྲྀ (A → C) → ((B → C) → ((A

    ∨ B) → C)) A → B A B A → A ∨ B B → A ∨ B A ∧ B → A A ∧ B → B A → (B → (A ∧ B)) ਪ࿦نଇ͸ ϞʔμεϙωϯεͷΈ ¬¬A → A ⊥ → A (A → ¬A) → ¬A ¬A → (A → B) (A → (B → C)) → ((A → B) → (A → C)) A ∨ B := ¬A → B := ¬B → A A ∧ B := ¬(A → ¬B) := ¬(B → ¬A) ¬A := A → ⊥ /05&ˮ ˭ ™͸ɺˠͱ˵ͷΈΛ࢖ͬͯهड़Ͱ͖Δ B → (A → B)
  18. ίϯϏωʔλ࿦ཧ Kxy = x Sxyz = xz(yz) I = SKK

    K : X → Y → X S : (Z → Y → X) → (Z → Y) → Z → X I : X → X ஋ͷؔ਺Խ ҰൠԽ 
 3FBEFSϞφυͷQVSF Ϟʔμεϙωϯε ͷҰൠԽ
 3FBEFSϞφυͷBQ
  19. /// `K = A → (B → A)` func k<A,

    B>(_ a: A) -> (B) -> A { { _ in a } } /// `S = (A → (B → C)) → ((A → B) → (A → C))` func s<A, B, C>(_ a: @escaping (C) -> (A) -> B) -> (_ b: @escaping (C) -> A) -> (C) -> B { { b in { c in a(c)(b(c)) } } }
  20. /// `I = SKK: A → A` func i<A>(_ a:

    A) -> A { let k_: (A) -> (A) -> A = k let skk: (A) -> A = s(k)(k_) return skk(a) } i("hello") // "hello" i(123) // 123
  21. ((A → B) → A) → A A ∨ ¬A

    ¬¬A → A ¬(A ∧ B) → (¬A ∨ ¬B) (A → B) → (¬A ∨ B) (¬B → ¬A) → (A → B) ഉத཯ ೋॏ൱ఆআڈ ରۮ཯ ൱ఆআڈWFS υɾϞϧΨϯͷ๏ଇ ™㱸 ؚ࣮࣭ҙ ύʔεͷ๏ଇ /05& ʮٯʯ͸߃ਅ 4XJGUͰ࣮૷Ͱ͖ͳ͍߃ਅͳ࿦ཧࣜ
  22. /// `A ∨ ¬A` (Law of excluded middle) func excludedMiddle<A>()

    -> Either<A, Not<A>> { fatalError("Can't impl in Swift”) }
  23. /// `A ∨ ¬A` (Law of excluded middle) func excludedMiddle<A>()

    -> Either<A, Not<A>> { fatalError("Can't impl in Swift”) } ANY LANGUAGES!
  24. /// `((A → B) → A) → A` func peirceLaw<A,

    B>() -> (((A) -> B) -> A) -> A { { (aba: ((A) -> B) -> A) in let ab: (A) -> B = { fatalError("Can't impl ") }() let a = aba(ab) return a } }
  25. /// `((A → B) → A) → A` func peirceLaw<A,

    B>() -> (((A) -> B) -> A) -> A { { (aba: ((A) -> B) -> A) in // WARNING: This compiles, but using invalid `excludedMiddle()`. let either: Either<A, Not<A>> = excludedMiddle() switch either { case let .left(a): return a case let .right(notA): return aba { a in absurd(notA.f(a)) } } } } ݟ্͔͚͸࣮૷Ͱ͖͍ͯΔ͕ɺ ഉத཯Λ࢖͍ͬͯΔͷͰɺ
  26. ܕͳ͠ϥϜμܭࢉʢུ֓ʣ t ::= x | λx . t | t

    t ʢม਺ʣ ʢλந৅ɺؔ਺ఆٛʣ ʢؔ਺ద༻ʣ λx . x λx . (λy . x) (λx . xx)(λx . xx) λ߲ͷྫ ϥϜμ߲
  27. ܕ෇͖ϥϜμܭࢉʢུ֓ʣ T ::= X | T → T ʢܕม਺ʣ ʢؔ਺ܕʣ

    t ::= x | λ(x : T) . t | t t ʢม਺ʣ ʢλந৅ʣ ʢؔ਺ద༻ʣ : T ϥϜμ߲ ܕɹ
  28. ܕ෇͖ϥϜμܭࢉʢུ֓ʣ A ∈ Γ Γ ⊢ A Γ, A ⊢

    B Γ ⊢ A → B Γ ⊢ A → B Γ ⊢ A Γ ⊢ B (x : A) ∈ Γ Γ ⊢ x : A Γ, x : A ⊢ t : B Γ ⊢ λ(x : A) . t : A → B Γ ⊢ t12 : A → B Γ ⊢ t1 : A Γ ⊢ t12 t1 : B ܕ෇͚نଇͷʮܕͷΈʯʹ஫໨͢Δͱʜ ࣗવԋ៷ͱ ಉ౳ λ߲ͷܕ෇͚نଇ ม਺ Еந৅ ؔ਺ద༻
  29. ΧϦʔɾϋϫʔυಉܕରԠ ௚؍ओ໋ٛ୊࿦ཧʹ͓͚Δ
 ࣗવԋ៷ ୯७ ܕ෇͖ϥϜμܭࢉ
 ؔ਺ܕϓϩάϥϛϯά ໋୊ɾఆཧ ܕ ূ໌ਤ ϥϜμ߲ʢϓϩάϥϜʣ

    ؚҙಋೖ ϥϜμந৅ʢؔ਺ఆٛʣ Ϟʔμεϙωϯε ؔ਺ద༻ ެཧ άϩʔόϧม਺ Ծఆ ࣗ༝ม਺ ԾఆΛด͡Δ ଋറม਺ ଞͷ࿦ཧԋࢉ 㱸 㱹ͳͲ ͷ ֦ுͱಉܕରԠ΋Մೳ
  30. ֤ੈքͱਅཧ஋ͷҨ఻ؔ܎ A 0 B 0 A 1 B 0 A

    1 B 0 ͸ະདྷ΁Ҩ఻͢Δ ʹ໭Βͳ͍ ৽͍͠஌ݟ
  31. ֤ੈքͱਅཧ஋ͷҨ఻ؔ܎ A 0 ¬A 0 A 0 ¬A 1 A

    0 ¬A 1 ™"ͷ৔߹ɺ ݱࡏ͔Βະདྷʹ͔͚ͯ" ʢ"ʹͳΔ͜ͱ͸ͳ͍ʣ Ҩ఻
  32. A 0 ¬A 0 A 0 ¬A 1 A 0

    ¬A 1 ™"ͷ৔߹ɺ ݱࡏ͔Βະདྷʹ͔͚ͯ" ʢ"ʹͳΔ͜ͱ͸ͳ͍ʣ Ҩ఻ ֤ੈքͱਅཧ஋දͷҨ఻ؔ܎ A ∨ ¬A ഉத཯͸߃ਅͰ͸ͳ͍
  33. ֤ੈքͱਅཧ஋ͷҨ఻ؔ܎ A → B 1 A 0 B 0 A

    → B 1 A 1 B 1 A → B 1 A 1 B 1 Ҩ఻ "͕ಘΒΕΔͱɺ
 #΋ࣗಈతʹಘΒΕΔ " #ʹ ͳΔ͜ͱ͸ͳ͍
  34. ݹయ࿦ཧ˩௚؍ओٛ࿦ཧ ࠷খ࿦ཧ ௚؍ओٛ࿦ཧ ݹయ࿦ཧ A ∨ ¬A ⊥ → A

    → , ∧ , ∨ , ¬, ⊥ Λ࢖ͬͨ࿦ཧࣜ A → A ∨ B A ∧ B → A ໃ६཯ ഉத཯ ⋮ ʲ஫ҙʳ௚؍ओٛ࿦ཧ͕ഉத཯Λ௚઀ؚΉΘ͚Ͱ͸ͳ͍ʢ࣍ϖʔδࢀরʣ
  35. ((A → B) → A) → A A ∨ ¬A

    ¬¬A → A ¬(A ∧ B) → (¬A ∨ ¬B) (A → B) → (¬A ∨ B) (¬B → ¬A) → (A → B) ഉத཯ ೋॏ൱ఆআڈ ରۮ཯ ൱ఆআڈWFS υɾϞϧΨϯͷ๏ଇ ™㱸 ؚ࣮࣭ҙ ύʔεͷ๏ଇ ʲ࠶ܝʳ௚؍ओٛ࿦ཧͰ੒Γཱͨͳ͍࿦ཧࣜ /05& ʮٯʯ͸߃ਅ
  36. ¬¬(((A → B) → A) → A) ¬¬(A ∨ ¬A)

    ¬¬(¬¬A → A) ¬¬(¬(A ∧ B) → (¬A ∨ ¬B)) ¬¬((A → B) → (¬A ∨ B)) ¬¬((¬B → ¬A) → (A → B)) ௚؍ओٛ࿦ཧͰ߃ਅͳ࿦ཧࣜ ͢΂ͯ ௚؍ओٛ࿦ཧ Ͱ੒Γཱͭ
  37. ¬¬((A → B) → A) → ¬¬A ¬¬(A ∨ ¬A)

    ¬¬¬¬A → ¬¬A ¬¬¬(A ∧ B) → ¬¬(¬A ∨ ¬B) ¬¬(A → B) → ¬¬(¬A ∨ B) ¬¬(¬B → ¬A) → ¬¬(A → B) Tautologies in Intuitionistic Logic Using helper rule ¬¬(A → B) ¬¬A → ¬¬B
  38. /// `¬¬(A ∨ ¬A)` (Law of excluded middle in Intuitionistic

    Logic) func excludedMiddle_IL<A>() -> Not<Not<Either<A, Not<A>>>> { Not<Not<Either<A, Not<A>>>> { notEither in let notA: Not<A> = Not { a in notEither.f(.left(a)) } let either: Either<A, Not<A>> = .right(notA) return notEither.f(either) } }
  39. /// `¬¬¬¬A ===> ¬¬A` (Double negation elimination in IL) func

    doubleNegationElim_IL<A>( _ notNotNotNotA: Not<Not<Not<Not<A>>>> ) -> Not<Not<A>> { Not<Not<A>> { notA in notNotNotNotA.f( Not<Not<Not<A>>> { notNotA in notNotA.f(notA) } ) } }
  40. /// `¬¬¬(A ∧ B) ===> ¬¬(¬A ∨ ¬B)` (De-Morgan's Law

    in IL) func deMorgan4_IL<A, B>(_ notNotNotAB: Not<Not<Not<(A, B)>>>) -> Not<Not<Either<Not<A>, Not<B>>>> { Not<Not<Either<Not<A>, Not<B>>>> { (notEither: Not<Either<Not<A>, Not<B>>>) in let notNotAB = Not<Not<(A, B)>> { notAB in let notB = Not<B> { b in let notA = Not<A> { a in notAB.f((a, b)) } let either: Either<Not<A>, Not<B>> = .left(notA) return notEither.f(either) } let either: Either<Not<A>, Not<B>> = .right(notB) return notEither.f(either) } return notNotNotAB.f(notNotAB) } }
  41. /// `¬¬((A → B) → A) → ¬¬A` (Peirce's Law

    in IL) func peirceLaw_IL<A, B>() -> (Not<Not<((A) -> B) -> A>>) -> Not<Not<A>> { { notNotF in Not<Not<A>> { notA in let notABA = Not<((A) -> B) -> A> { aba in let ab: (A) -> B = { a in absurd(notElim(a, notA)) } let a = aba(ab) return notA.f(a) } return notNotF.f(notABA) } } }
  42. ύʔεͷ๏ଇˠDBMMDD ¬¬(A → B) ¬¬A → ¬¬B ((A → ¬¬B)

    → ¬¬A) → ¬¬A ͜͜Ͱ Λ࢖͏ͱ ¬¬(A → B) A → ¬¬B ¬¬(((A → B) → A) → A) ύʔεͷ๏ଇ
  43. /// Continuation. typealias Cont<R, A> = (@escaping (A) -> R)

    -> R /// /// Call with Current Continuation. /// - Peirce: `((A → B) → A) → A` /// - CallCC: `((A → M<B>) → M<A>) → M<A>` /// /// - Note: `callCC` is like control operators e.g. `goto`, `return`, `throw`. /// func callCC<A, B, R>( _ f: @escaping (_ exit: @escaping (A) -> Cont<R, B>) -> Cont<R, A> ) -> Cont<R, A> { { outer in f { a in { _ in outer(a) } }(outer) } }
  44. func doubleNegationElim_callCC<R, A>( _ doubleNegation: @escaping ( _ neg: @escaping

    (A) -> Cont<R, Never> ) -> Cont<R, Never> ) -> Cont<R, A> { callCC { exit -> Cont<R, A> in flatMap(doubleNegation(exit), absurd) } }
  45. ֊໋୊࿦ཧ A1 ∧ A2 ∧ ⋯ ≅ ∀X . X

    A1 ∨ A2 ∨ ⋯ ≅ ∃X . X (A1 → C) ∧ (A2 → C) ∧ ⋯ ≅ ∀X . (X → C) ʮ໋୊ʯͷશশྔԽ㱼ɺଘࡏྔԽ㱽
 ֊ड़ޠ࿦ཧͷʮ߲ʯͷྔԽͱҟͳΔͷͰ஫ҙ 㱸ͱ㱼 㱹ͱ㱽
  46. ֊໋୊࿦ཧͷਪ࿦نଇ ∀X . A(X) A(T) A(Y) ∀X . A(X) ∃X

    . A(X) ∀X . (A(X) → C) C A(T) ∃X . A(X) ͸ɹɹɹʹࢸΔԋ៷ͷԾఆ͢΂ͯͱɹɹɹͷதͰ ࣗ༝ม਺ͱͯ͠࢖ΘΕ͍ͯͳ͍ܕม਺ Y A(Y) A(X) ͸ɹɹʹ ୅ೖՄೳͳܕ T A
  47. (A1 → C) ∧ (A2 → C) ∧ ⋯ ≅

    ∀X . (X → C) let intToBool: (Int) -> Bool = { ... } let floatToBool: (Float) -> Bool = { ... } let strToBool: (String) -> Bool = { ... } // ... ͢΂ͯͷܕʹ͍ͭͯಉ͡Α͏ͳ࣮૷Λߦ͍͍ͨ // Swift ͷδΣωϦΫεʢଟ૬ؔ਺ʣΛ࢖͏ͱɺ // ্هͷॏෳίʔυΛ1ͭʹ·ͱΊͯந৅ԽͰ͖Δɻ func xToBool<X>(_ x: X) -> Bool { ... }
  48. ˲ͱ˳ͷؔ܎ (A1 ∨ A2 ) → C ≅ (A1 →

    C) ∧ (A2 → C) (∃X . X) → C ≅ ∀X . (X → C) (A1 ∨ A2 ∨ ⋯) → C ≅ (A1 → C) ∧ (A2 → C) ∧ ⋯ (A → C) → ((B → C) → ((A ∨ B) → C)) ࢀߟɿ
  49. ∀X . (X → C) ≅ (∃X . X) →

    C func forallXToBool<X>(_ x: X) -> Bool { anyToBool(x) } /// - Note: `∃X.X` is isomorphic to `Any`. func anyToBool(_ any: Any) -> Bool { forallXToBool(any) }
  50. ∀(X <: P) . (X → C) ≅ (∃(X <:

    P) . X) → C protocol P { var value: String { get } } struct AnyP: P { let value: String } func forallXProtocolToBool<X: P>(_ x: X) -> Bool { // Generic func protocolToBool(x) } func protocolToBool(_ p: P) -> Bool { // Protocol func (dynamic) forallXProtocolToBool(AnyP(value: p.value)) }
  51. ∀(X <: P) . (X → C) ≅ (∃(X <:

    P) . X) → C // Reverse Opaque Result Type (static) func someProtocolToBool(_ p: some P) -> Bool { forallXProtocolToBool(p) } // ERROR: Isn’t supported yet in Swift 5.1
  52. ϥϜμΩϡʔϒ ֊ ଟ૬ ϥϜμ ֊௚؍ओ໋ٛ୊࿦ཧ  ܕʹґଘͨ͠஋ ଟ૬ؔ਺ ͕࡞ΕΔ ୯७ܕ෇͖ϥϜμ

    ֊௚؍ओ໋ٛ୊࿦ཧ  ஋ʹґଘͨ͠஋ ߴ֊ؔ਺ ͕࡞ΕΔ ґଘܕ ֊௚؍ओٛड़ޠ࿦ཧ  ஋ʹґଘͨ͠ܕ͕࡞ΕΔ ߴ֊ଟ૬ϥϜμ ߴ֊ΧΠϯυʴଟ૬ؔ਺ ߴ֊ΧΠϯυܕ ܕʹґଘͨ͠ܕ ߴ֊ͷܕؔ਺ ͕࡞ΕΔ
  53. ϥϜμΩϡʔϒ ֊ ଟ૬ ϥϜμ ֊௚؍ओ໋ٛ୊࿦ཧ  ܕʹґଘͨ͠஋ ଟ૬ؔ਺ ͕࡞ΕΔ ୯७ܕ෇͖ϥϜμ

    ௚؍ओ໋ٛ୊࿦ཧ  ஋ʹґଘͨ͠஋ ௨ৗͷߴ֊ؔ਺ ͕࡞ΕΔ ґଘܕ ֊௚؍ओٛड़ޠ࿦ཧ  ஋ʹґଘͨ͠ܕ͕࡞ΕΔ ߴ֊ଟ૬ϥϜμ ଟ૬ͳߴ֊ܕߏஙࢠ͕࡞ΕΔ ߴ֊ΧΠϯυܕ ܕʹґଘͨ͠ܕ ߴ֊ͷܕߏஙࢠ ͕࡞ΕΔ Calculus of Constructions
  54. (C → A) ∧ (C → B) C → (A

    ∧ B) A B C A ∧ B A B A ∧ B HomC (C, A) × HomC (C, B) ≅ HomC (C, A × B)
  55. ࿦ཧԋࢉˮ ·ͨ͸ A A ∨ B B A ∨ B

    A ∨ B A → C B → C C
  56. A B C A ∨ B (A → C) ∧

    (B → C) (A ∨ B) → C A ∨ B A → C B → C C HomC (A, C) × HomC (B, C) ≅ HomC (A + B, C)
  57. ถాͷิ୊ Hom[C,Set] (HomC (A, − ), F) ≅ F(A) ∀B

    . (A → B) → F(B) ≅ F(A) A ⟺ ∀B . (A → B) → B A ⟹ (A → ⊥ ) → ⊥ '߃౳ؔखͷͱ͖ #˵ʹಛघԽ
 ˲আڈ ೋॏ൱ఆ ¬¬A
  58. άϦϕϯίͷఆཧɿݹయ࿦ཧˠ௚؍ओٛ࿦ཧ΁ͷຒΊࠐΈ ௚؍ओٛ࿦ཧ ݹయ࿦ཧ A ∨ ¬A ¬¬(A ∨ ¬A) ¬¬

    ೋॏ൱ఆಋೖ ഉத཯ ೋॏ൱ఆഉத཯ $14ม׵ A ⟹ (A → ⊥ ) → ⊥
  59. F(C) D ݍ F C ݍ U(D) ࣹͷू߹ U ≅

    rightAdjunct leftAdjunct
  60. F(C) D ݍ F U C U(D) ݍ F(U(D)) U(F(C))

    f f F(f) U(f) unitC counitD
  61. A × X B ݍ − × X ( −

    )X A BX ݍ BX × X f f f × id eval ႈ ࢦ਺ର৅ ධՁࣹ
  62. B BX × X eval A × X − ×

    X ( − )X A BX f f f × id ႈ ࢦ਺ର৅ ݍ ݍ ධՁࣹ X → B B B
  63. σΧϧτ ΧϧςγΞϯ ดݍ  ऴର৅ ⊤   ௚ੵ"ʷ# "˭#

      ႈ ࢦ਺ର৅ #" "ˠ#  Λ࣋ͭݍͷ͜ͱ ௚؍ओٛ ࿦ཧͷܗࣜతମܥ͸σΧϧτดݍʹΑͬͯ
 ݍ࿦తʹҙຯ෇͚͢Δ͜ͱ͕Ͱ͖Δ σΧϧτดݍ ࿦ཧࣜͷূ໌ ܕ෇͖ϥϜμܭࢉ ର৅ ࿦ཧࣜ ܕ ࣹ ূ໌ ϥϜμ߲ ࣗ༝ม਺Λ࣋ͨͳ͍ ႈର৅ ˠΛ࢖ͬͨ࿦ཧࣜ ؔ਺ܕ ධՁࣹ Ϟʔμεϙωϯε ؔ਺ద༻ ΧϦʔɾϋϫʔυɾϥϯϕοΫରԠ
  64. τϙεʹσΧϧτดݍʴ෦෼ର৅෼ྨࢠ {a ∈ A|p(a)} A τϙε Ω true 1 unit

    m ෦෼ର৅ 4VCPCKFDU  Ϟϊࣹ ෦෼ର৅෼ྨࢠ 4VCPCKFDU$MBTTJpFS  ྫɿτϙε͕ू߹ͷݍͷͱ͖
 Њ\USVF GBMTF^ p p.b. Ҿ͖໭͠
 1VMMCBDL QC ಛੑࣹ "্ͷड़ޠ
  65. ࢀߟจݙʢ࿦ཧֶɺϥϜμܭࢉɺܕγεςϜʣ w ʰܭࢉ࿦ཧֶʱߨٛࢿྉُࢁ޾ٛ w ΧϦʔʹϋϫʔυಉܕରԠ8JLJQFEJB w ΧϦʔɾϋϫʔυରԠͱ௚؍ओٛ࿦ཧͷ ҙຯ࿦ೖ໳໼ా෦ढ़հ w ௚؍ओٛ࿦ཧ΁ͷট଴রҪҰ੒

    w ਺ֶಉ޷ձފా w $MBTTJDBM-PHJDJO)BTLFMM w "5ZQF4ZTUFN'SPN4DSBUDIr 3PCFSU8JENBOO w "4IPSU*OUSPEVDUJPOUP4ZTUFNT' BOE'Т1BCMP/PHVFJSB w ࿦ཧͱܭࢉͷ͘͠ΈԮ୩ণݾɺ੢࡚ਅ໵ w ৘ใՊֶʹ͓͚Δ࿦ཧখ໺׮᏷ w ϓϩάϥϜҙຯ࿦ԣ಺׮จ w ܕγεςϜೖ໳ 5B1- 1JFSDF
  66. ࢀߟจݙʢݍ࿦ɺτϙεʣ w ೥ݍ࿦ษڧձࢿྉதଜߊҰ w ᐻࢁਖ਼޾ͷΩϚΠϥࣂҭه w ఩ֶऀͷͨΊͷݍ࿦ೖ໳৿ాਅੜ w ݍ࿦ʹΑΔϓϩάϥϛϯάͱ࿦ཧ !TIJBUTVNBU

    !@@JOU w τϙεBMHE w 5IF%BSL4JEFPG'PSDJOH w 0MJWJB$BSBNFMMPTXFCTJUF w "O*OUSPEVDUJPOUP5PQPT5IFPSZ w ,SJQLFr+PZBMҙຯ࿦;JQIJM"MFTIMBT w (SPUIFOEJFDL5PQPT΁ͷೖ໳ !LSJQLFKPZBM w ϓϩάϥϛϯάݴޠͷҙຯ࿦ͱݍ࿦௕୩઒ ਅਓ w τϙεͱߴ֊࿦ཧ5BJDIJ6FNVSB w ݍ࿦"XPEFZ w ݍ࿦ʹΑΔ࿦ཧֶʕߴ֊࿦ཧͱτϙεਗ਼ ਫٛ෉ w ݍ࿦ͷา͖ํ೔ຊධ࿦ࣾ