jagomart
digital resources
picture1_Calculus Pdf 168690 | Lecture5


 149x       Filetype PDF       File size 0.09 MB       Source: cs.pomona.edu


File: Calculus Pdf 168690 | Lecture5
lecture 5 lambda calculus see lambda calculus cheat csc 131 sheet on links page of fall 2011 course web page kim bruce pure lambda calculus computability terms of pure lambda ...

icon picture PDF Filetype PDF | Posted on 25 Jan 2023 | 2 years ago
Partial capture of text on file.
 
                    Lecture 5:  Lambda Calculus                                                                      See lambda calculus cheat 
                                                CSC 131                                                                sheet on “links” page of 
                                               Fall, 2011                                                                      course web page!
                                              Kim Bruce
                           Pure Lambda Calculus                                                                                   Computability
                    • Terms of pure lambda calculus
                       - M ::= v | (M M) | λv. M
                       - Provide theoretical foundations for functional                                          • Can encode all computable functions in pure 
                         languages.                                                                                 untyped lambda calculus.
                       - Turing-complete                                                                             - true = λ u. λ v. u 
                    • Reduction rules for lambda calculus:                                                           - false = λ u. λ v. v
                        (α) λx. M  → λy. ([y/x] M), if y ̸∉ FV(M).                                                   - cond = λ u. λ v. λ w. u v w
                        (β) (λx. M) N → [N/x] M. 
                        (η) λx. (M x)  → M.     Optional rule
                                Lambda Encoding                                                                              Encoding Integers
                                                                                                                 • Integers:
                    • Pairing:                                                                                       - 0 = λ s. λ z. z. 
                         Pair = λ m. λ n. λ b. cond b m n.                                                           - 1 = λ s. λ z. s z. 
                       -                                                                                             - 2 = λ s. λ z. s (s z). 
                       - fst = λp. p true 
                       - snd = λp. p false                                                                       • Integers encode repetition:
                                                                                                                     - 2 f x = f (f x)
                                                                                                                                (n)
                                                                                                                     - n f x = f   (x)
                                         Arithmetic                                                                                      Predecessor
                    • Succ = λ n. λ s. λ z. s (n s z)                                                                • PZero = <0,0> = Pair 0 0
                        - Succ n = λ s. λ z. s (n s z) = λ s. λ z. s (s(n) z) = n+1                                  • PSucc = λ n. Pair (snd n) (Succ (snd n))
                    • Plus = λ n. λ m. λ s. λ z. m s (n s z).                                                           - PSucc PZero = 
                    • Mult = λ n. λ m. (m ( Plus n) 0).                                                                 - n PSucc PZero =  for n > 0
                    • isZero = λ n. n (λ x. false) true                                                              • Pred = λ n. fst (n PSucc PZero)
                                                                                                                        - Pred n = n - 1, for n > 0, 
                    • Subtraction is hard!!                                                                             - Pred 0 = 0
                                           Recursion                                                                                    Fixed Points
                    • Recursive definitions are handy                                                                 • Several fixed point operators:
                        - fact = λn. cond (isZero n) 1 (Mult n (fact (Pred n)))                                         - Ex:  Y = λf . (λx. f (xx))(λx. f (xx)) 
                        - Not a definition because can’t name functions!                                              • Claim for all g,   Y g = g (Y g)
                    • Let F stand for the closed term:                                                                     Y g = λf . (λx. f (xx))(λx. f (xx)) g 
                        - λf. λn. cond (isZero n) 1 (Mult n (f (Pred n)))                                                         = (λx. g(xx))(λx. g(xx)) 
                        - Notice F(fact) = fact.                                                                                  = g((λx. g(xx))(λx. g(xx))) 
                        - fact is a fixed point of F                                                                               = g (Y g)
                        - To find fact, need only find fixed point of F!                                                  If let x  = Y g, then g (x ) = x .
                                                                                                                     •           0                      0       0
                                            Factorial                                                                        Computing Factorials
                    • Recursive definition:                                                                           fact 1 = (F (fact)) 1    because fact is a fixed point of F 
                  - let F = λf. λn. cond (isZero n) 1 (Mult n (f (Pred n)))                                                   = (λn. cond (isZero n) 1 (Mult n (fact (Pred n)))) 1        
                  - let fact  = Y F                                                                                                                                                                                 expanding F
                  - then F(fact) = fact                                                                                       = cond (isZero 1) 1 (Mult 1 (fact (Pred 1))) applying it
                    • Compute:                                                                                                = Mult 1 (fact (Pred 1)) by the definition of cond 
                     fact 0 = (F (fact)) 0    because fact is a fixed point of F                                               = fact 0              by the definition of Mult and Pred 
                                 = cond (isZero 0) 1 (Mult 0 (fact (Pred 0)))                                                 = 1                       by the above calculation 
                                 = 1 by the definition of cond
                                                                                                        Lambda Calculus
                                                                                             • λ-calculus invented in 1928 by Church in 
                                                                                               Princeton & first published in 1932.
                              Some History                                                   • Goal to provide a foundation for logic
                                                                                             • First to state explicit conversion rules.
                                                                                             • Original version inconsistent, but corrected
                                                                                             • 1933, definition of natural numbers
                              Collaborators                                                               Undecidability
                • 1931-1934: Grad students:  
                   - J. Barkley Rosser and Stephen Kleene                                    • Convertibility problem for λ-calculus 
                   - Church-Rosser confluence theorem ensured                                   undecidable.
                     consistency (earlier version inconsistent)                              • Validity in first-order predicate logic 
                   - Kleene showed λ-definable functions very rich                              undecidable.
                      • Equivalent to Herbrand-Gödel recursive functions
                      • Equivalent to Turing-computable functions.                           • Proved independently year later by Turing.
                      • Founder of recursion theory, invented regular expressions               - First showed halting problem undecidable
                • Church’s thesis: 
                   - λ-definability ≡ effectively computable
                                Alan Turing                                                          Combinatory Logic
                • Turing                                                                     • Schönfinkel - get rid of bound variables
                   - 1936, in Cambridge, England, definition of Turing                        • Combinators K, S sufficient to write all 
                     machine                                                                   computable functions:
                   - 1936-38, in Princeton to get Ph.D. under Church.                           - K x y = x
                   - 1937, first published fixed point combinator                                 - S x y z = (x y)(x z)
                   - Kleene did not use fixed-point operator in defining a%                      CL terms include K, S, variables and all terms 
                     recursive functions on natural numbers!                                 •
                   - Broke German enigma code in WW2, Turing test AI                           created by function application.
                   - Persecuted as homosexual, committed suicide in 1954                     • All computable fcns, equivalent to λ-calculus
                                                                                                                                        Types
                                                                                                              • Start with base type e and build up types and 
                                                                                                                 terms:
                        Typed Lambda Calculus                                                                     - Type ::= e | Type → Type
                                                                                                                  - M ::= v | (M M) | λv : Type. M
                                                                                                              • Examples:
                                                                                                                  - Types: e, e → e, e → e → e, (e → e) → e, ...
                                                                                                                  - Terms:  λx: e. x,    λf: e → e. λz: e. f(f(z))
                                       Definitions                                                                         Totally Awesome!!
                   • Earlier definitions generalize over types t:
                              t                                                                               • Theorem:  If M is a term of the typed lambda 
                       - true  = λx:t. λy:u. x                                                                   calculus, then M has a unique normal form.  
                          t                    (n)
                       - n  = λs: t→t. λz: t. s  (z)                                                             I.e., every term of the typed lambda calculus is total.
                   • Some untyped terms can’t be typed:                                                       • Corollary:  The typed lambda calculus does not 
                       - Ω = (λx. (x x))(λx. (x x))                                                              include all computable functions.
                       - Y = λf . (λx. f (x x))(λx. f (x x))
The words contained in this file might help you see if this file matches what you are looking for:

...Lecture lambda calculus see cheat csc sheet on links page of fall course web kim bruce pure computability terms m v provide theoretical foundations for functional can encode all computable functions in languages untyped turing complete true u reduction rules false x y if fv cond w n optional rule encoding integers pairing s z pair b fst p snd repetition f arithmetic predecessor succ pzero psucc plus mult iszero pred subtraction is hard recursion fixed points recursive denitions are handy several xed point operators fact ex xx not a denition because t name claim g let stand the closed term notice to nd need only then factorial computing factorials expanding applying it compute by and above calculation invented church princeton rst published some history goal foundation logic first state explicit conversion original version inconsistent but corrected natural numbers collaborators undecidability grad students j barkley rosser stephen kleene convertibility problem conuence theorem ensured ...

no reviews yet
Please Login to review.