Truth, deduction, computation lecture f
of 33
/33
-
Author
vlad-patryshev -
Category
Education
-
view
287 -
download
1
Embed Size (px)
description
My logic lectures at SCU Untyped Lambda; Peano arithmetics
Transcript of Truth, deduction, computation lecture f
- 1. Truth, Deduction, Computation Lecture F Untyped ... and other things Vlad Patryshev SCU 2013
- 2. Functions f: X Y; X - domain, X - codomain. x:X y:Y (y=f(x)) y y x A Function x Not a Function
- 3. Functions. Definitions Monomorphism, aka injective function, aka one-to-one function x y (f(x)=f(y) x=y) f: X Y
- 4. Functions. Definitions Epimorphism, aka surjective function, aka onto function y x (f(x)=y) f: X Y
- 5. Functions. Definitions Bijection, aka bijective function, aka one-to-one correspondence f is injection and surjection f: A
- 6. Functions. Composition f: X Y g: Y Z h=gf (gf)(x) = g(f(x)) h
- 7. Functions. Identity id: X X idf=f=fid IdX X id(x)=x
- 8. Functions. Make a monoid f,g: X X binary operation: fg neutral element: id associativity: (fg)h = f(gh)
- 9. Currying Having a function f: (x1,x2,...xn) y is equivalent to having a function f c: x 1 x 2 x n y
- 10. Functions in Programming languages Language Code Sample Java interface Function { public Y apply(x: X) } Function f = new Function() { public String apply(n: Int) { return "n=" + n; } Scala val f:(Int => String) = (n:Int) => "n=" + n Javascript f = function(n) { return "n=" + n }
- 11. Peano Arithmetic 1. 2. 3. 4. 5. 6. 7. 8. objects are called natural numbers equality is defined, with usual properties 0 is a natural number function s: s(x) is natural number x (s(x) 0) xy (s(x) = s(y) x = y) P(0), x (P(x)P(s(x))) x P(x) define 1 as s(0)
- 12. Peano Arithmetic Illustrated Giuseppe Peano Domino model of Peano Arithmetic
- 13. Peano Arithmetic: define + x+0 = x x+s(y) = s(x+y) have a monoid
- 14. Peano Arithmetic: define x0 = 0 xs(y) = x + (xy) have a monoid
- 15. Peano Arithmetic: define etc x0 = 1 xs(y) = x (xy) (strangely, no associativity) x0 = 1 xs(y) = x (xy) (Some people argue lately that this makes it inconsistent)
- 16. Peano Arithmetic: Universal Property
- 17. Alonzo Church Peano arithmetics is undecidable Every effectively calculable function is a computable function Invented -calculus which is equivalent to effectively calculable functions Is it so that all that machines can do is equivalent to lambdas? Church-Rosser thesis: YES! https://files.nyu.edu/cb125/public/Lambda/barendregt.94.pdf
- 18. So, can we build Peano arithmetic? They are called Church Numerals 0: 1: 2: n: f id f f f ff f ff } n times
- 19. Simplest Language for Calculations < < < < term>::= term>::=< term> < term> term>::=( < term>) term>::=(< term>) application abstraction http://www.itu.dk/people/sestoft/lamreduce/lamframes.html
- 20. Javascript Interpretation we have as many variables as we like x N function(x) {return N} (M N) M(N) http://myjavatools.com/js.html
- 21. Examples of terms x x x (x y) (( x x)(z t)) x ((x x) (x x)) Does not make much sense so far, right?
- 22. Same things in Javascript x function(x) {return x} x(y) (function(x) {return x})(z(t)) function(x) {return x(x)(x(x))}
- 23. Rules of Transformation -equivalence, renaming bound(*) variables -conversion (substitution/ intro) -conversion
- 24. Substitutions 1. 2. 3. 4. 5. x[x:=N] y[x:=N] (M1 M2)[x:=N] (x M)[x:=N] (y M)[x:=N] N y, if x y (M1[x:=N]) (M2[x:=N]) x M y (M[x:=N])//if xy and yFV(N)
- 25. -equivalence rule Bound variable in a lambda expression - the one which name is found right after . x (y (x (y z))) Two lambda expressions differing only in names of bound variables are equivalent. x (y (x (y z))) t (w (t (w z))) x (y (x (y z))) z (w (z (w z)))
- 26. Like in Javascript function(x) { return function(y) { return y(function(z) { return z(x) } } } // same as function(a) { return function(b) { return b(function(c) { return c(a) } } }
- 27. -conversion rule (x E) E E[x := E] (x (x (x (y x) (y z) (y z) x) (y y) y y x x x) (y y y) y y y y y) (x x) (x x) (x x) (x x)
- 28. -conversion is -reduction + -abstraction -reduction (x E) E E[x := E] -abstraction (x E) E E[x := E]
- 29. -reduction in Javascript (function(x) {return M})(N) Substitute all x in M with N
- 30. -reduction - tautological case t = t t (x (x x x // identity function, right? = ? x) M = M x) (a a) = a a
- 31. -reduction - tautology, Javascript id = function(x) { println(); return x } id(id)
- 32. -reduction - weird case t = t t (x (x x (x x) = ? (x x)) (x (x x)) =... (x x)) (x (x x)) - oops.
- 33. Thats it for today