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

ラムダ計算入門 / Introduction of Lambda Calculus

katashin
August 09, 2017

ラムダ計算入門 / Introduction of Lambda Calculus

型勉強会 #2 2017/08/09

katashin

August 09, 2017
Tweet

More Decks by katashin

Other Decks in Programming

Transcript

  1. ਅِ஋ͷදݱ tru = λt. λf. t fls = λt. λf.

    f → true ͱΈͳͤΔ → false ͱΈͳͤΔ
  2. ྫ͑͹ if ࣜͬΆ͍ϥϜμந৅Λ͜ͷΑ͏ʹఆٛͰ͖Δ test = λl. λm. λn. l m

    n e.g. test t v w 
 t ͕ tru ͷ࣌ v Λɺfls ͷ࣌ w Λฦ͢
  3. ɹ test tru v w → (λl. λm. λn. l

    m n) tru v w → (λm. λn. tru m n) v w → (λn. tru v n) w → tru v w → (λt. λf. t) v w → (λf. v) w → v t = tru ͷ࣌ͷධՁͷྲྀΕ
  4. ੔਺஋ͷදݱ c0 = λs. λz. z c1 = λs. λz.

    s z c2 = λs. λz. s (s z) c3 = λs. λz. s (s (s z)) … → 0 → 1 → 2 → 3
  5. plus = λm. λn. λs. λz. m s (n s

    z) ଍͠ࢉΛ͢ΔϥϜμந৅
  6. ɹ plus c1 c3 → (λm. λn. λs. λz. m

    s (n s z)) c1 c3 → (λn. λs. λz. c1 s (n s z)) c3 → λs. λz. c1 s (c3 s z) → λs. λz. (λs’. λz’. s’ z’) s (c3 s z) → λs. λz. (λz’. s z’) (c3 s z) → λs. λz. s (c3 s z) → λs. λz. s ((λs’’. λz’’. s’’ (s’’ (s’’ z’’)) s z) → λs. λz. s ((λz’’. s (s (s z’’)) z) → λs. λz. s (s (s (s z))) → c4 ධՁͷྲྀΕ
  7. β-؆໿ • [x → t2] t12 ͸ t12 தͷ x

    ͷࣗ༝ͳग़ݱΛ͢΂ͯ t2 Ͱஔ͖׵ ͑Δ͜ͱʹΑͬͯಘΒΕΔ߲ • ͭ·Γؔ਺ద༻ͷධՁ (λx. t12) t2 → [x → t2] t12