VU Logic and Computation – P

VU Logic and Computation – P

VU Logic and Computation Agata Ciabattoni Institute fur¨ Computersprachen, Theory and Logic group [email protected] VU Logic and Computation – p. 1 Lection 4 – Computability Theory • Combinatory Logic • Recursive functions • (Hints on the) Equivalence between λ-calculus, recursive functions and TM • Computable and non computable functions VU Logic and Computation – p. 2 Combinatory Logic VU Logic and Computation – p. 3 Combinatory Logic: Motivation Example: commutative law of addition in arithmetic (∀xy) x + y = y + x VU Logic and Computation – p. 4 Combinatory Logic: Motivation Example: commutative law of addition in arithmetic (∀xy) x + y = y + x it can be expressed without the bound variables x and y: • first define A(x,y) = x + y (for all x and y) • then introduce an operator C defined by (Cf)(x,y) = f(y,x) (for all f,x and y) • then the commutative law becomes simply A = CA VU Logic and Computation – p. 4 Combinatory Logic: Motivation Example: commutative law of addition in arithmetic (∀xy) x + y = y + x it can be expressed without the bound variables x and y: • first define A(x,y) = x + y (for all x and y) • then introduce an operator C defined by (Cf)(x,y) = f(y,x) (for all f,x and y) • then the commutative law becomes simply A = CA C is called combinator VU Logic and Computation – p. 4 Combinatory Logic • only two constants S and K • only application (MN) VU Logic and Computation – p. 5 Combinatory Logic • only two constants S and K • only application (MN) (KMN) → M (SMNP ) → (MP )(NP ) with M,N and P terms of CL (combinators). VU Logic and Computation – p. 5 Equivalence with λ calculus K and S are expressible in λ calculus VU Logic and Computation – p. 6 Equivalence with λ calculus K and S are expressible in λ calculus (Vice versa) For each combinator M, there exist λ∗x.M which behaves as the λ abstraction, that is ∗ (λ x.MN) → M[N/x] Proof: We define λ∗x.M by structural induction: If M = x, then λ∗x.x = I =(SKK) If M does not contain x, then λ∗x.M =(KM) If M =(P Q), then λ∗x.(P Q)=(Sλ∗x.P λ∗x.Q) VU Logic and Computation – p. 6 Recursive Functions • An abstract description of computable functions – Gödel and Kleene (1936) • useful to study recursive programs VU Logic and Computation – p. 7 Recursive Functions • An abstract description of computable functions – Gödel and Kleene (1936) • useful to study recursive programs They form the smallest collection of partial functions containing some basic functions and closed under some fundamental operations for forming new functions from old – composition, primitive recursion and minimization. VU Logic and Computation – p. 7 Basic Functions • n n Projection functions, proji : N →N : n proji (x1,...xn) = xi • Constant funtions with value 0, zeron : N n →N : n zero (x1,...xn) = 0 • Successor function, succ : N →N : succ(x) = x + 1 VU Logic and Computation – p. 8 Composition n m Given f : N →N and g1,...gn : N →N , their composition is m the function f ◦ [g1,...gn] ∈N →N such that f ◦ [g1,...gn](x1,...xm) ≃ f(g1(x1,...xm),...gn(x1,...xm)) where ≃ is the equivalence of possibly undefined expressions VU Logic and Computation – p. 9 Recursion A function f is recursive when the value of f on some arguments depends on the value of f on "simpler" arguments. VU Logic and Computation – p. 10 Recursion A function f is recursive when the value of f on some arguments depends on the value of f on "simpler" arguments. • f1(0) = 0 f1(x + 1) = f1(x)+(x + 1) • f2(0) = 1 f2(x + 1) = (x + 1)f2(x) VU Logic and Computation – p. 10 Primitive Recursive Functions k Is the class of functions containing zero, succ and proji , closed under compositions and primitive recursion: Let g be a k-ary PRF and h be a k + 2-ary PRF. Then the k + 1-ary function f: f(0, x) = g(x) f(y + 1, x) = h(y,f(y, x), x) is PR. VU Logic and Computation – p. 11 PRF – Example 1 Addition: 1 sum(0,x) = proj1 (x) sum(y + 1,x) = h(y, sum(y,x),x) where 3 h := λxyz.succ(proj2 (x,y,z)) VU Logic and Computation – p. 12 PRF – Example 2 Product P (0,x) = zero1(x) P (y + 1,x) = h′(y, P (y,x),x) where ′ 3 3 h := λxyz.sum(proj2 (x,y,z),proj3 (x,y,z)) VU Logic and Computation – p. 13 Elementary Functions Is the subclass of primitive recursive functions containing k zero, succ, subtr and proji , closed under compositions and • m bounded summation f(m, x1,...,xn) = Pi=0 g(i, x1,...,xn) • m bounded product f(m, x1,...,xn) = Qi=0 g(i, x1,...,xn) (where g is elementary recursive) VU Logic and Computation – p. 14 Primitive Recursive Functions k Is the class of functions containing zero, succ and proji , closed under compositions and primitive recursion: f(0, x) = g(x) f(y + 1, x) = h(y,f(y, x), x) • total functions • all total computable function? VU Logic and Computation – p. 15 Ackermann Function f(0, 0,y) = y f(0,x + 1,y) = f(0,x,y) + 1 f(1, 0,y) = 0 f(z + 2, 0,y) = 1 f(z + 1,x + 1,y) = f(z,f(z + 1,x,y),y)) • f is computable • f grows faster than any PRF! (i.e., for any PRF F, there is an n such that f(n,x,y) >F (x,y)) VU Logic and Computation – p. 16 Extending the PRF g(x) = min y such that f(x,y) = 0 is g computable, if so is f? VU Logic and Computation – p. 17 Recursive Functions Is the smallest collection of functions containing all primitive k recursive functions (zero, succ and proji , closed under compositions and primitive recursion) and closed under minimalization: g(x) = µy(f(x,y) = 0) = min y such that f(x,y) = 0 and (f(x, z) ↓ for all z ≤ y and f(x, z) =6 0) ↑ otherwise Theorem If f is computable, so is g. VU Logic and Computation – p. 18 Example x D(x,y) = y if ∃z such that yz = x, and it is ↑ otherwise. VU Logic and Computation – p. 19 Example x D(x,y) = y if ∃z such that yz = x, and it is ↑ otherwise. D(x,y) := µz[eq(yz,x) = 0] where • Pred(0) = 0, and Pred(succ(x)) = x • x −⋆ 0 = x and x −⋆ succ(y) = Pred(x −⋆ y) • eq(x,y) = x −⋆ y + y −⋆ x VU Logic and Computation – p. 19 Church-Turing Thesis Formal notions appeared, starting in 1936: λ-calculus of Alonzo Church Turing machines of Alan Turing Recursive functions of Gödel and Kleene . These definitions look very different, but are provably equivalent. VU Logic and Computation – p. 20 Model of computations: equivalences • Recursive functions • λ-calculus • Combinatory logic • Turing machines • ... VU Logic and Computation – p. 21 Encoding of recursive functions in λ calculus Definition λ-definable functions f : N n →N is λ-definable if there is a closed λ-term F that n represents it: that is for all (x1,...xn) ∈N and y ∈N β • if f(x1,...xn) = y then Fx1 ...xn = y • if f(x1,...xn) ↑, then Fx1 ...xn has no β-nf VU Logic and Computation – p. 22 Church’s numerals n := λxy.x(x(. (x y) . ) | n times{z } Example 0 = λxy.y 1 = λxy.xy 2 = λxy.x(xy) (nM)N =β M(M(. (M N) . ) | n times{z } examples of functions on the blackboard ... VU Logic and Computation – p. 23 λ calculus and recursion Example (factorial function fact) λn. if n = 0 then 0 else n · ??(n − 1) VU Logic and Computation – p. 24 λ calculus and recursion Example (factorial function fact) λn. if n = 0 then 0 else n · ??(n − 1) Fixed point of a function f is a value x for which fx = x VU Logic and Computation – p. 24 λ calculus and recursion Example (factorial function fact) λn. if n = 0 then 0 else n · ??(n − 1) Fixed point of a function f is a value x for which fx = x Proposition Every λ term has a fixpoint, i.e. a term θ s.t. for all M: θM =β M(θM) 1. N := λf.λn. if n = 0 then 1 else n · f(n − 1) 2. fact := θN VU Logic and Computation – p. 24 Fixed Point and µ-recursion Fixed Point Is a term θ s.t. for all M: θM = M(θM). µ-recursion g(x) = µy(f(x,y) = 0) = min y such that f(x,y) = 0 and (f(x, z) ↓ for all z ≤ y and f(x, z) =6 0) ↑ otherwise VU Logic and Computation – p. 25 λ-definable ⇒ Turing Computable Theorem A λ-definable function is Turing Computable (T-Computable). VU Logic and Computation – p. 26 λ-definable ⇒ Turing Computable Theorem A λ-definable function is Turing Computable (T-Computable). To show this one can • code λ-terms as numbers (ensuring that operations for constructing and deconstructing terms are given by T-computable functions on codes) • write a T-interpreter for β-reductions VU Logic and Computation – p. 26 T-Computable ⇒ Recursive function Theorem A Turing Computable function is definable as a recursive function. VU Logic and Computation – p. 27 T-Computable ⇒ Recursive function Theorem A Turing Computable function is definable as a recursive function. To show this one can • code tape configurations and states of a Turing machine during a computation by natural numbers • the operation of the machine is represented by recursive functions of these numbers VU Logic and Computation – p.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    43 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us