Rachunek lambda, zima

Podobne dokumenty
Logika i teoria typów

O czym będzie ten wykład: Logika i teoria typów. Zbiory i funkcje. Powtórzenie z rachunku lambda. Ekstensjonalność (?) Beztypowy rachunek lambda

Helena Boguta, klasa 8W, rok szkolny 2018/2019

Weronika Mysliwiec, klasa 8W, rok szkolny 2018/2019

Revenue Maximization. Sept. 25, 2018

Jak należy się spodziewać, mamy. Zauważmy jednak, że nie zachodzi równość

Convolution semigroups with linear Jacobi parameters

A sufficient condition of regularity for axially symmetric solutions to the Navier-Stokes equations

Mixed-integer Convex Representability

y = The Chain Rule Show all work. No calculator unless otherwise stated. If asked to Explain your answer, write in complete sentences.

Materia ly do wyk ladu. Rachunek lambda. Pawe l Urzyczyn 25 września 2015

Machine Learning for Data Science (CS4786) Lecture11. Random Projections & Canonical Correlation Analysis

Programowanie funkcyjne Wykład 14. Rachunek λ z typami prostymi

Linear Classification and Logistic Regression. Pascal Fua IC-CVLab

Aerodynamics I Compressible flow past an airfoil

Steeple #3: Gödel s Silver Blaze Theorem. Selmer Bringsjord Are Humans Rational? Dec RPI Troy NY USA

Elementy rachunku lambda. dr hab. inż. Joanna Józefowska, prof. PP 1

OBWIESZCZENIE MINISTRA INFRASTRUKTURY. z dnia 18 kwietnia 2005 r.

SSW1.1, HFW Fry #20, Zeno #25 Benchmark: Qtr.1. Fry #65, Zeno #67. like

EGZAMIN MATURALNY Z JĘZYKA ANGIELSKIEGO


Previously on CSCI 4622

rachunku kombinatorów logiką kom- binatoryczną Zmienne przedmiotowe Podstawienie słabej redukcji kombinatorami

VI. Równania różniczkowe liniowe wyższych rzędów

Hard-Margin Support Vector Machines

Domy inaczej pomyślane A different type of housing CEZARY SANKOWSKI

Roland HINNION. Introduction

TTIC 31210: Advanced Natural Language Processing. Kevin Gimpel Spring Lecture 8: Structured PredicCon 2

harmonic functions and the chromatic polynomial

DUAL SIMILARITY OF VOLTAGE TO CURRENT AND CURRENT TO VOLTAGE TRANSFER FUNCTION OF HYBRID ACTIVE TWO- PORTS WITH CONVERSION

Zakopane, plan miasta: Skala ok. 1: = City map (Polish Edition)

Wpływ dyrektywy PSD II na korzystanie z instrumentów płatniczych. Warszawa, 15 stycznia 2015 r. Zbigniew Długosz

System BCD z κ. Adam Slaski na podstawie wykładów, notatek i uwag Pawła Urzyczyna. Semestr letni 2009/10

Logiczne podstawy informatyki 1. Wojciech Buszkowski. Zakład Teorii Obliczeń Wydział Matematyki i Informatyki UAM

Rozpoznawanie twarzy metodą PCA Michał Bereta 1. Testowanie statystycznej istotności różnic między jakością klasyfikatorów

ITIL 4 Certification

Stability of Tikhonov Regularization Class 07, March 2003 Alex Rakhlin

Few-fermion thermometry

Wojewodztwo Koszalinskie: Obiekty i walory krajoznawcze (Inwentaryzacja krajoznawcza Polski) (Polish Edition)

Wojewodztwo Koszalinskie: Obiekty i walory krajoznawcze (Inwentaryzacja krajoznawcza Polski) (Polish Edition)

Tychy, plan miasta: Skala 1: (Polish Edition)


Jak zasada Pareto może pomóc Ci w nauce języków obcych?

Machine Learning for Data Science (CS4786) Lecture 11. Spectral Embedding + Clustering

Twierdzenie Hilberta o nieujemnie określonych formach ternarnych stopnia 4

SubVersion. Piotr Mikulski. SubVersion. P. Mikulski. Co to jest subversion? Zalety SubVersion. Wady SubVersion. Inne różnice SubVersion i CVS

License Certificate. Autodesk License Certificate Terms and Conditions

Has the heat wave frequency or intensity changed in Poland since 1950?

Karpacz, plan miasta 1:10 000: Panorama Karkonoszy, mapa szlakow turystycznych (Polish Edition)

Logika i teoria typów

Zarządzanie sieciami telekomunikacyjnymi

Katowice, plan miasta: Skala 1: = City map = Stadtplan (Polish Edition)


DO MONTAŻU POTRZEBNE SĄ DWIE OSOBY! INSTALLATION REQUIRES TWO PEOPLE!

Karpacz, plan miasta 1:10 000: Panorama Karkonoszy, mapa szlakow turystycznych (Polish Edition)

Strategic planning. Jolanta Żyśko University of Physical Education in Warsaw

KORELACJA 1. Wykres rozrzutu ocena związku między zmiennymi X i Y. 2. Współczynnik korelacji Pearsona

Stargard Szczecinski i okolice (Polish Edition)

R. D. Tennent, The Denotational Semantics of Programming Languages [1976]

Proposal of thesis topic for mgr in. (MSE) programme in Telecommunications and Computer Science

HAPPY ANIMALS L01 HAPPY ANIMALS L03 HAPPY ANIMALS L05 HAPPY ANIMALS L07

HAPPY ANIMALS L02 HAPPY ANIMALS L04 HAPPY ANIMALS L06 HAPPY ANIMALS L08

Title: On the curl of singular completely continous vector fields in Banach spaces

Analysis of Movie Profitability STAT 469 IN CLASS ANALYSIS #2

MaPlan Sp. z O.O. Click here if your download doesn"t start automatically

WZÓR ŚWIADECTWA UZNANIA POJAZDU DROGOWEGO Komentarze

Programowanie funkcyjne Wykład 12. Funkcje rekurencyjne i rachunek lambda

Extraclass. Football Men. Season 2009/10 - Autumn round

ZASADY ZALICZANIA PRZEDMIOTU:

USER EXPERIENCE Z UMIAREM

tradycyjna normalny multicache bardzo du y mobilna

Raport bieżący: 44/2018 Data: g. 21:03 Skrócona nazwa emitenta: SERINUS ENERGY plc

Counting quadrant walks via Tutte s invariant method

ON THE COMPLEXITY OF SOME MALTSEV CONDITIONS

DODATKOWE ĆWICZENIA EGZAMINACYJNE

Fragment darmowy udostępniony przez Wydawnictwo w celach promocyjnych. EGZEMPLARZ NIE DO SPRZEDAŻY!

Surname. Other Names. For Examiner s Use Centre Number. Candidate Number. Candidate Signature

ARNOLD. EDUKACJA KULTURYSTY (POLSKA WERSJA JEZYKOWA) BY DOUGLAS KENT HALL

Teoretyczne Podstawy Języków Programowania Wykład 4. Siła wyrazu rachunku λ

INSTRUKCJA MONTAŻU MARBO E SPORT LISTA CZĘŚCI (PARTS LIST) (ASSEMBLY INSTRUCTION) MH-W102 NR CZĘŚCI (PART NO.) ILOŚĆ (QUANTITY) OPIS (DESCRIPTION)

Rodzaje umów i formy oddelegowania w międzynarodowych projektach badawczych

MAGNESY KATALOG d e s i g n p r o d u c e d e l i v e r

Relaxation of the Cosmological Constant

kdpw_stream Struktura komunikatu: Status komunikatu z danymi uzupełniającymi na potrzeby ARM (auth.ste ) Data utworzenia: r.

dr Krzysztof Korus partner, radca prawny, ekonomista

THE RATE OF GW CAPTURE OF STELLAR-MASS BHS IN NUCLEAR STAR CLUSTERS. Alexander Rasskazov & Bence Kocsis Eotvos University

Wyk lad 8: Leniwe metody klasyfikacji

arxiv: v5 [math.lo] 18 Jun 2019

& portable system. Keep the frame, change the graphics, change position. Create a new stand!

SNP SNP Business Partner Data Checker. Prezentacja produktu

Installation of EuroCert software for qualified electronic signature

POLITYKA PRYWATNOŚCI / PRIVACY POLICY

Chapter 1: Review Exercises

Wykaz linii kolejowych, które są wyposażone w urządzenia systemu ETCS

Miedzy legenda a historia: Szlakiem piastowskim z Poznania do Gniezna (Biblioteka Kroniki Wielkopolski) (Polish Edition)

INSTRUKCJE JAK AKTYWOWAĆ SWOJE KONTO PAYLUTION

Testy jednostkowe - zastosowanie oprogramowania JUNIT 4.0 Zofia Kruczkiewicz

Wykaz linii kolejowych, które są wyposażone w urzadzenia systemu ETCS

Maximum Ride Ostatnie Ostrzezenie Globalne Ocieplenie (Polska Wersja Jezykowa)

Transkrypt:

Rachunek lambda, zima 2015-16 Wykład 2 12 października 2015

Tydzień temu: Własność Churcha-Rossera (CR) Jeśli a b i a c, to istnieje takie d, że b d i c d.

Tydzień temu: Własność Churcha-Rossera (CR) Jeśli a b i a c, to istnieje takie d, że b d i c d. a b d c

Wnioski z twierdzenia Churcha-Rossera (1) Jeśli M = β N, to M β Q β N, dla pewnego Q.

Wnioski z twierdzenia Churcha-Rossera (1) Jeśli M = β N, to M β Q β N, dla pewnego Q. M Q 1 M 1 Q 2 Q n M 2... M n 1 N

Wnioski z twierdzenia Churcha-Rossera (2) Każdy term ma co najwyżej jedną postać normalną (i do niej się redukuje).

Wnioski z twierdzenia Churcha-Rossera (2) Każdy term ma co najwyżej jedną postać normalną (i do niej się redukuje). Dowód: Jeśli M = β N i N normalne, to M β Q β N. Skoro N normalne, to N = Q. Jeśli M też normalne, to M = Q = N.

Wnioski z twierdzenia Churcha-Rossera (3) Beta-konwersja jest niesprzeczną teorią równościową

Wnioski z twierdzenia Churcha-Rossera (3) Beta-konwersja jest niesprzeczną teorią równościową Dowód: Na przykład x = y, ponieważ x β y.

Eta-redukcja

Eta-reduction The least relation η, satisfying the conditions: λx.mx η M, when x FV(M); jeśli M η M, to MN η M N, NM η NM oraz λxm η λxm.

Eta-reduction The least relation η, satisfying the conditions: λx.mx η M, when x FV(M); jeśli M η M, to MN η M N, NM η NM oraz λxm η λxm. Symbol βη stands for the union of relations β and η. Other definitions and notation are applicable respectively.

Eta-conversion Axiom (η): λx.mx = M, when x FV(M).

Eta-conversion Axiom (η): λx.mx = M, when x FV(M). Rule (ext): Mx = Nx M = N (when x FV(M) FV(N))

Eta-conversion Axiom (η): λx.mx = M, when x FV(M). Rule (ext): Fakt Mx = Nx M = N Axiom (η) and rule (ext) are equivalent. (when x FV(M) FV(N))

Eta-conversion Axiom (η): λx.mx = M, when x FV(M). Rule (ext): Fakt Mx = Nx M = N Axiom (η) and rule (ext) are equivalent. Proof. (when x FV(M) FV(N)) (1) Assume (η) and let Mx = Nx. Then λx Mx = λx Nx by rule (ξ), whence M = N.

Eta-conversion Axiom (η): λx.mx = M, when x FV(M). Rule (ext): Fakt Mx = Nx M = N Axiom (η) and rule (ext) are equivalent. Proof. (when x FV(M) FV(N)) (1) Assume (η) and let Mx = Nx. Then λx Mx = λx Nx by rule (ξ), whence M = N. (2) Since (λx.mx)x = Mx, one has λx.mx = M by (ext).

Eta-reduction graphically λ @ = M M Eta-reduction amounts to removing a small loop in a graph.

Eta-reduction Fakt Eta-reduction is strongly normalizing.

Eta-reduction Fakt Eta-reduction is strongly normalizing. Proof. Because terms shrink under eta.

Eta-reduction Fakt Eta-reduction is strongly normalizing. Proof. Because terms shrink under eta. Fakt Eta-reduction is Church-Rosser.

Eta-reduction Fakt Eta-reduction is strongly normalizing. Proof. Because terms shrink under eta. Fakt Eta-reduction is Church-Rosser. Proof. Because it is WCR (easy), Newman s lemma applies.

Beta-eta-redukcja Relacja βη to suma β i η. Notacja βη, = βη itd. stosuje się odpowiednio.

Beta-eta critical pairs [λ] @ @ λ [@] λ

Beta-eta critical pairs [λ] @ @ (λx Mx)N λ [@] λ λx (λy M)x

Beta-eta critical pairs [λ] @ @ (λx Mx)N λ [@] λ λx (λy M)x Critical pair occurs when two redexes use the same resource.

Beta-eta critical pairs [λ] @ @ (λx Mx)N λ [@] λ λx (λy M)x Critical pair occurs when two redexes use the same resource. Proving WCR amounts to resolving critical pairs.

Beta-eta critical pairs (λx Mx)N MN

Beta-eta critical pairs (λx Mx)N MN λx (λy M)x λy M = λx. M[y := x]

Beta-eta critical pairs (λx Mx)N MN λx (λy M)x λy M = λx. M[y := x] Morał Beta-eta reduction is weakly Church-Rosser.

Towards Church-Rosser Lemma If P η M β Q then there is N such that P = β N η Q. η M β P β = N η Q

Towards Church-Rosser Lemma Relations β and η commute: if P η M β Q then there is N such that P β N η Q. P η β M N β η Q

Beta-eta is Church-Rosser M 1 β. η M 3 η η η. β. η. β β β. η M 2 β. η η β. η. η M 4

Beta-SN versus beta-eta-sn Theorem 0: A term is βη-sn if and only if it is β-sn. Proof: ( ) Obvious. ( ) Ćwiczenia?

Eta-postponement (odkładanie eta-redukcji) Theorem 1: If M βη N then M β P η N, for some P.

Eta-postponement (odkładanie eta-redukcji) Theorem 1: If M βη N then M β P η N, for some P. Theorem 2: A term has a β-normal form iff it has a βη-normal form. Proofs: Omitted.

Eta-postponement (odkładanie eta-redukcji) Theorem 1: If M βη N then M β P η N, for some P. Theorem 2: A term has a β-normal form iff it has a βη-normal form. Proofs: Omitted. Uwaga: Thm. 2 nie wynika natychmiast z Thm. 1.

Standaryzacja

Standard reduction: Never reduce to the left of something already reduced. Standard reduction: (λx.xx)((λzy.z(zy))(λu.u)(λw.w)) (λx.xx)((λy.(λu.u)((λu.u)y))(λw.w)) (λx.xx)((λu.u)((λu.u)(λw.w))) (λx.xx)((λu.u)(λw.w)) (λx.xx)(λw.w). Non-standard reduction: (λx.xx)((λzy.z(zy))(λu.u)(λw.w)) (λx.xx)((λy.(λu.u)((λu.u)y))(λw.w)) (λx.xx)((λy.(λu.u)y)(λw.w)) (λx.xx)((λy.y)(λw.w)) (λx.xx)(λw.w).

Standardization Theorem: If M β N then there is a standard reduction from M to N.

Standardization Theorem: If M β N then there is a standard reduction from M to N. Corollary: If M has a β-normal form then the leftmost reduction leads to the normal form.

Standardization Theorem: If M β N then there is a standard reduction from M to N. Corollary: If M has a β-normal form then the leftmost reduction leads to the normal form. Slogan: The leftmost reduction strategy is normalizing.

Redukcje czołowe i wewnętrzne A term λ x.z R is in head normal form. 1 A term λ x.(λy.p)q R has a head redex (λy.p)q. 1 Postać normalna jest wtedy, gdy R są normalne.

Redukcje czołowe i wewnętrzne A term λ x.z R is in head normal form. 1 A term λ x.(λy.p)q R has a head redex (λy.p)q. A reduction step of the form M = λ x.(λy.p)q R β λ x.p[y := Q] R = N is called head reduction. Write M h N. Other reductions are internal. Write M i N. 1 Postać normalna jest wtedy, gdy R są normalne.

Main Lemma Lemma: If M β N then M h P i N, for some P.

Main Lemma Lemma: If M β N then M h P i N, for some P. Warning: A naive proof attempt fails. The assumption: λ x.(λy.p)q R i λ x.(λy.p )Q R h λ x.p [y := Q ] R does not imply λ x.(λy.p)q R h λ x.p[y := Q] R i λ x.p [y := Q ] R.

Main Lemma Lemma: If M β N then M h P i N, for some P. Warning: A naive proof attempt fails. The assumption: λ x.(λy.p)q R i λ x.(λy.p )Q R h λ x.p [y := Q ] R does not imply λ x.(λy.p)q R h λ x.p[y := Q] R i λ x.p [y := Q ] R. This diagram is wrong. i h i h

Dygresja Lemat łatwy: Jeśli M i N h P, to M h Q β P, dla pewnego Q.

Dygresja Lemat łatwy: Jeśli M i N h P, to M h Q β P, dla pewnego Q. Wniosek: If M has a reduction with infinitely many head steps then it has an infinite head reduction.

Standaryzacja: jeśli M β N, to istnieje standardowa redukcja Lemma: If M β N then M h P i N, for some P.

Standaryzacja: jeśli M β N, to istnieje standardowa redukcja Lemma: If M β N then M h P i N, for some P. Dowód standaryzacji: Indukcja ze względu na długość N. Najpierw wykonujemy same redukcje czołowe. Dostajemy term P = λ x. M 1 M 2... M k, i dalej wszystkie redukcje są wewnątrz termów M 1, M 2,..., M k. Można je łatwo przepermutować tak, aby najpierw redukować wewnątrz M 1, potem wewnątrz M 2 i tak dalej. Do tych redukcji można zastosować indukcję.

Redukcje quasi-lewostronne Lemma: If M has a reduction with infinitely many head steps then it has an infinite head reduction.

Redukcje quasi-lewostronne Lemma: If M has a reduction with infinitely many head steps then it has an infinite head reduction. Uogólnienie: A quasi-leftmost reduction is an infinite reduction sequence with infinitely many leftmost steps.

Redukcje quasi-lewostronne Theorem: A normalizing term has no quasi-leftmost reduction sequence.

Redukcje quasi-lewostronne Theorem: A normalizing term has no quasi-leftmost reduction sequence. Proof: Induction wrt the length of the normal form of M. Suppose M has a quasi-leftmost reduction. If there is infinitely many head steps, then M has an infinite head (thus leftmost) reduction and cannot normalize.

Redukcje quasi-lewostronne Theorem: A normalizing term has no quasi-leftmost reduction sequence. Proof: Induction wrt the length of the normal form of M. Suppose M has a quasi-leftmost reduction. If there is infinitely many head steps, then M has an infinite head (thus leftmost) reduction and cannot normalize. Thus almost all reductions are internal. (W szczególności, od pewnego miejsca mamy czołowe postaci normalne.) λ z.yp 1... P k i λ z.yp 1... P k i λ z.yp 1... P k i

Redukcje quasi-lewostronne Theorem: A normalizing term has no quasi-leftmost reduction sequence. Proof: Induction wrt the length of the normal form of M. Suppose M has a quasi-leftmost reduction. If there is infinitely many head steps, then M has an infinite head (thus leftmost) reduction and cannot normalize. Thus almost all reductions are internal. (W szczególności, od pewnego miejsca mamy czołowe postaci normalne.) λ z.yp 1... P k i λ z.yp 1... P k i λ z.yp 1... P k i Infinitely many leftmost steps are within the same P i.

Redukcje quasi-lewostronne Theorem: A normalizing term has no quasi-leftmost reduction sequence. Proof: Induction wrt the length of the normal form of M. Suppose M has a quasi-leftmost reduction. If there is infinitely many head steps, then M has an infinite head (thus leftmost) reduction and cannot normalize. Thus almost all reductions are internal. (W szczególności, od pewnego miejsca mamy czołowe postaci normalne.) λ z.yp 1... P k i λ z.yp 1... P k i λ z.yp 1... P k Infinitely many leftmost steps are within the same P i. By induction, P i cannot normalize. i

Redukcje quasi-lewostronne Theorem: A normalizing term has no quasi-leftmost reduction sequence. Proof: Induction wrt the length of the normal form of M. Suppose M has a quasi-leftmost reduction. If there is infinitely many head steps, then M has an infinite head (thus leftmost) reduction and cannot normalize. Thus almost all reductions are internal. (W szczególności, od pewnego miejsca mamy czołowe postaci normalne.) λ z.yp 1... P k i λ z.yp 1... P k i λ z.yp 1... P k Infinitely many leftmost steps are within the same P i. By induction, P i cannot normalize. But then M cannot normalize. i

Rachunek λ-i

The λi-calculus The λi-terms: variables; applications (MN), where M and N are λi-terms; abstractions (λx M), where M is a λi-term, and x FV(M). Terms S = λxyz.xz(yz) and I = λx.x are λi-terms, but K = λxy.x is not.

Theorem: If a λi-term has a normal form then it is SN.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 1: M = λ x. yr 1 R 2... R k. Then N = λ x. yr 1... R k, with R i R i, for some i, and R i = R i, otherwise.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 1: M = λ x. yr 1 R 2... R k. Then N = λ x. yr 1... R k, with R i R i, for some i, and R i = R i, otherwise. Since N SN, also R i SN, with shorter normal form. Thus all R i are SN, and so is M.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 2: M = λ x. (λy P)QR 1... R k β λ x. P[y := Q]R 1... R k = N.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 2: M = λ x. (λy P)QR 1... R k β λ x. P[y := Q]R 1... R k = N. All terms P, Q, R 1,..., R k are SN.

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 2: M = λ x. (λy P)QR 1... R k β λ x. P[y := Q]R 1... R k = N. All terms P, Q, R 1,..., R k are SN. Therefore internal reductions of M must terminate,

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 2: M = λ x. (λy P)QR 1... R k β λ x. P[y := Q]R 1... R k = N. All terms P, Q, R 1,..., R k are SN. Therefore internal reductions of M must terminate, and otherwise we have: M i λ x. (λy P )Q R 1...R k h λ x. P [y := Q ]R 1... R k

Theorem: If a λi-term has a normal form then it is SN. Lemma: If M λi and M l N SN then M SN. Proof: Induction wrt the length of the normal form of N. Case 2: M = λ x. (λy P)QR 1... R k β λ x. P[y := Q]R 1... R k = N. All terms P, Q, R 1,..., R k are SN. Therefore internal reductions of M must terminate, and otherwise we have: M i λ x. (λy P )Q R 1...R k h λ x. P [y := Q ]R 1... R k But N β λ x. P [Q /y]r 1... R k, and N is SN.

Theorem: If a λi-term has a normal form then it is SN. Proof: Let M λi have normal form M.

Theorem: If a λi-term has a normal form then it is SN. Proof: Let M λi have normal form M. Then M l M SN.

Theorem: If a λi-term has a normal form then it is SN. Proof: Let M λi have normal form M. Then M l M SN. By induction wrt number of steps show that M is SN.