CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

Size: px
Start display at page:

Download "CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus"

Transcription

1 CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016

2 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb. λt. λf. b t f This way, IF behaves how it ought to: IF TRUE v t v f v t IF FALSE v t v f v f

3 Review: Church Numerals 3 Church numerals encode a number n as a function that takes f and x, and applies f to x n times. 0 λf. λx. x 1 λf. λx. f x 2 λf. λx. f (f x) We can define other functions on integers: SUCC λn. λf. λx. f (n f x)

4 Review: Church Numerals 3 Church numerals encode a number n as a function that takes f and x, and applies f to x n times. 0 λf. λx. x 1 λf. λx. f x 2 λf. λx. f (f x) We can define other functions on integers: SUCC λn. λf. λx. f (n f x) PLUS λn 1. λn 2. n 1 SUCC n 2

5 Review: Church Numerals 3 Church numerals encode a number n as a function that takes f and x, and applies f to x n times. 0 λf. λx. x 1 λf. λx. f x 2 λf. λx. f (f x) We can define other functions on integers: SUCC λn. λf. λx. f (n f x) PLUS λn 1. λn 2. n 1 SUCC n 2 TIMES λn 1. λn 2. n 1 (PLUS n 2 ) 0

6 Review: Church Numerals 3 Church numerals encode a number n as a function that takes f and x, and applies f to x n times. 0 λf. λx. x 1 λf. λx. f x 2 λf. λx. f (f x) We can define other functions on integers: SUCC λn. λf. λx. f (n f x) PLUS λn 1. λn 2. n 1 SUCC n 2 TIMES λn 1. λn 2. n 1 (PLUS n 2 ) 0 ISZERO λn. n (λz. FALSE) TRUE

7 Recursive Functions 4 How would we write recursive functions like factorial?

8 Recursive Functions 4 How would we write recursive functions like factorial? We d like to write it like this... FACT λn. IF (ISZERO n) 1 (TIMES n (FACT (PRED n)))

9 Recursive Functions 4 How would we write recursive functions like factorial? We d like to write it like this... FACT λn. IF (ISZERO n) 1 (TIMES n (FACT (PRED n))) In slightly more readable notation this is... FACT λn. if n = 0 then 1 else n FACT (n 1)...but this is an equation, not a definition!

10 Recursion removal trick 5 We can perform a trick to define a function FACT that satisfies the recursive equation on the previous slide.

11 Recursion removal trick 5 We can perform a trick to define a function FACT that satisfies the recursive equation on the previous slide. Define a new function FACT : FACT λf. λn. if n = 0 then 1 else n (f f (n 1))

12 Recursion removal trick 5 We can perform a trick to define a function FACT that satisfies the recursive equation on the previous slide. Define a new function FACT : FACT λf. λn. if n = 0 then 1 else n (f f (n 1)) Then define FACT as FACT applied to itself: FACT FACT FACT

13 Example 6 Let s try evaluating FACT on 3... FACT 3

14 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3

15 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3

16 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3

17 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1))

18 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1)) 3 (FACT FACT (3 1))

19 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1)) 3 (FACT FACT (3 1)) = 3 (FACT (3 1))

20 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1)) 3 (FACT FACT (3 1)) = 3 (FACT (3 1))

21 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1)) 3 (FACT FACT (3 1)) = 3 (FACT (3 1))

22 Example 6 Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1)) 3 (FACT FACT (3 1)) = 3 (FACT (3 1))

23 Example Let s try evaluating FACT on 3... FACT 3 = (FACT FACT ) 3 = ((λf. λn. if n = 0 then 1 else n (f f (n 1))) FACT ) 3 (λn. if n = 0 then 1 else n (FACT FACT (n 1))) 3 if 3 = 0 then 1 else 3 (FACT FACT (3 1)) 3 (FACT FACT (3 1)) = 3 (FACT (3 1)) So we have a technique for writing recursive functions: write a function f that takes itself as an argument and define f as f f. 6

24 Fixed point combinators 7 There is another way: fixed points!

25 Fixed point combinators 7 There is another way: fixed points! Consider factorial again. It is a fixed point of the following: G λf. λn. if n = 0 then 1 else n (f (n 1))

26 Fixed point combinators 7 There is another way: fixed points! Consider factorial again. It is a fixed point of the following: G λf. λn. if n = 0 then 1 else n (f (n 1)) Recall that if g if a fixed point of G, then G g = g. To see that any fixed point g is a real factorial function, try evaluating it: g 5

27 Fixed point combinators 7 There is another way: fixed points! Consider factorial again. It is a fixed point of the following: G λf. λn. if n = 0 then 1 else n (f (n 1)) Recall that if g if a fixed point of G, then G g = g. To see that any fixed point g is a real factorial function, try evaluating it: g 5 = (G g) 5

28 Fixed point combinators 7 There is another way: fixed points! Consider factorial again. It is a fixed point of the following: G λf. λn. if n = 0 then 1 else n (f (n 1)) Recall that if g if a fixed point of G, then G g = g. To see that any fixed point g is a real factorial function, try evaluating it: g 5 = (G g) 5 5 (g 4)

29 Fixed point combinators 7 There is another way: fixed points! Consider factorial again. It is a fixed point of the following: G λf. λn. if n = 0 then 1 else n (f (n 1)) Recall that if g if a fixed point of G, then G g = g. To see that any fixed point g is a real factorial function, try evaluating it: g 5 = (G g) 5 5 (g 4) = 5 ((G g) 4)

30 Fixed point combinators 8 How can we generate the fixed point of G? In denotational semantics, finding fixed points took a lot of math. In the λ-calculus, we just need a suitable combinator...

31 Y Combinator 9 The (infamous) Y combinator is defined as Y λf. (λx. f (x x)) (λx. f (x x)) We say that Y is a fixed point combinator because Y f is a fixed point of f (for any lambda term f).

32 Y Combinator 9 The (infamous) Y combinator is defined as Y λf. (λx. f (x x)) (λx. f (x x)) We say that Y is a fixed point combinator because Y f is a fixed point of f (for any lambda term f). What happens when we evaluate Y G under CBV?

33 Z Combinator 10 To avoid this issue, we ll use a slight variant of the Y combinator, called Z, which is easier to use under CBV.

34 Z Combinator 10 To avoid this issue, we ll use a slight variant of the Y combinator, called Z, which is easier to use under CBV. Z λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))

35 Example 11 Let s see Z in action, on our function G. FACT

36 Example 11 Let s see Z in action, on our function G. FACT = Z G

37 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G

38 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y))

39 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y)) G (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y)

40 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y)) G (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) = (λf. λn. if n = 0 then 1 else n (f (n 1))) (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y)

41 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y)) G (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) = (λf. λn. if n = 0 then 1 else n (f (n 1))) (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) λn. if n = 0 then 1 else n ((λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) (n 1))

42 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y)) G (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) = (λf. λn. if n = 0 then 1 else n (f (n 1))) (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) λn. if n = 0 then 1 else n ((λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) (n 1)) = β λn. if n = 0 then 1 else n (λy. (Z G) y) (n 1)

43 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y)) G (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) = (λf. λn. if n = 0 then 1 else n (f (n 1))) (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) λn. if n = 0 then 1 else n ((λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) (n 1)) = β λn. if n = 0 then 1 else n (λy. (Z G) y) (n 1) = β λn. if n = 0 then 1 else n (Z G (n 1))

44 Example 11 Let s see Z in action, on our function G. FACT = Z G = (λf. (λx. f (λy. x x y)) (λx. f (λy. x x y))) G (λx. G (λy. x x y)) (λx. G (λy. x x y)) G (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) = (λf. λn. if n = 0 then 1 else n (f (n 1))) (λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) λn. if n = 0 then 1 else n ((λy. (λx. G (λy. x x y)) (λx. G (λy. x x y)) y) (n 1)) = β λn. if n = 0 then 1 else n (λy. (Z G) y) (n 1) = β λn. if n = 0 then 1 else n (Z G (n 1)) = λn. if n = 0 then 1 else n (FACT (n 1))

45 Other fixed point combinators 12 There are many (indeed infinitely many) fixed-point combinators. Here s a cute one: where Y k (L L L L L L L L L L L L L L L L L L L L L L L L L L) L λabcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d p o i n t c o m b i n a t o r))

46 Turing s Fixed Point Combinator 13 To gain some more intuition for fixed point combinators, let s derive a combinator Θ originally discovered by Turing.

47 Turing s Fixed Point Combinator 13 To gain some more intuition for fixed point combinators, let s derive a combinator Θ originally discovered by Turing. We know that Θ f is a fixed point of f, so we have Θ f = f (Θ f).

48 Turing s Fixed Point Combinator 13 To gain some more intuition for fixed point combinators, let s derive a combinator Θ originally discovered by Turing. We know that Θ f is a fixed point of f, so we have Θ f = f (Θ f). We can write the following recursive equation: Θ = λf. f (Θ f).

49 Turing s Fixed Point Combinator 13 To gain some more intuition for fixed point combinators, let s derive a combinator Θ originally discovered by Turing. We know that Θ f is a fixed point of f, so we have Θ f = f (Θ f). We can write the following recursive equation: Θ = λf. f (Θ f). Now use the recursion removal trick: Θ λt. λf. f (t t f) Θ Θ Θ

50 θ Example 14 FACT = Θ G

51 θ Example 14 FACT = Θ G = ((λt. λf. f (t t f)) (λt. λf. f (t t f))) G

52 θ Example 14 FACT = Θ G = ((λt. λf. f (t t f)) (λt. λf. f (t t f))) G (λf. f ((λt. λf. f (t t f)) (λt. λf. f (t t f)) f)) G

53 θ Example 14 FACT = Θ G = ((λt. λf. f (t t f)) (λt. λf. f (t t f))) G (λf. f ((λt. λf. f (t t f)) (λt. λf. f (t t f)) f)) G G ((λt. λf. f (t t f)) (λt. λf. f (t t f)) G)

54 θ Example 14 FACT = Θ G = ((λt. λf. f (t t f)) (λt. λf. f (t t f))) G (λf. f ((λt. λf. f (t t f)) (λt. λf. f (t t f)) f)) G G ((λt. λf. f (t t f)) (λt. λf. f (t t f)) G) = G (Θ G)

55 θ Example 14 FACT = Θ G = ((λt. λf. f (t t f)) (λt. λf. f (t t f))) G (λf. f ((λt. λf. f (t t f)) (λt. λf. f (t t f)) f)) G G ((λt. λf. f (t t f)) (λt. λf. f (t t f)) G) = G (Θ G) = (λf. λn. if n = 0 then 1 else n (f (n 1))) (Θ G) λn. if n = 0 then 1 else n ((Θ G) (n 1)) = λn. if n = 0 then 1 else n (FACT (n 1))

56 Definitional Translation 15 We know how to encode Booleans, conditionals, natural numbers, and recursion in λ-calculus. Can we define a real programming language by translating everything in it into the λ-calculus?

57 Definitional Translation 15 We know how to encode Booleans, conditionals, natural numbers, and recursion in λ-calculus. Can we define a real programming language by translating everything in it into the λ-calculus? In definitional translation, we define a denotational semantics where the target is a simpler programming language instead of mathematical objects.

58 Review: Call-by-Value Here are the syntax and CBV semantics of λ-calculus: e ::= x λx. e e 1 e 2 v ::= λx. e e 1 e 1 e e e 1 e 2 e 1 e 2 v e v e (λx. e) v e{v/x} β There are two kinds of rules: congruence rules that specify evaluation order and computation rules that specify the interesting reductions. 16

59 Evaluation Contexts 17 Evaluation contexts let us separate out these two kinds of rules.

60 Evaluation Contexts 17 Evaluation contexts let us separate out these two kinds of rules. An evaluation context E is an expression with a hole in it: a single occurrence of the special symbol [ ] in place of a subexpression. E ::= [ ] E e v E

61 Evaluation Contexts 17 Evaluation contexts let us separate out these two kinds of rules. An evaluation context E is an expression with a hole in it: a single occurrence of the special symbol [ ] in place of a subexpression. E ::= [ ] E e v E We write E[e] to mean the evaluation context E where the hole has been replaced with the expression e.

62 Examples 18 E 1 = [ ] (λx. x) E 1 [λy. y y] = (λy. y y) λx. x

63 Examples 18 E 1 = [ ] (λx. x) E 1 [λy. y y] = (λy. y y) λx. x E 2 = (λz. z z) [ ] E 2 [λx. λy. x] = (λz. z z) (λx. λy. x)

64 Examples 18 E 1 = [ ] (λx. x) E 1 [λy. y y] = (λy. y y) λx. x E 2 = (λz. z z) [ ] E 2 [λx. λy. x] = (λz. z z) (λx. λy. x) E 3 = ([ ] λx. x x) ((λy. y) (λy. y)) E 3 [λf. λg. f g] = ((λf. λg. f g) λx. x x) ((λy. y) (λy. y))

65 CBV With Evaluation Contexts 19 With evaluation contexts, we can define the evaluation semantics for the CBV λ-calculus with just two rules: one for evaluation contexts, and one for β-reduction.

66 CBV With Evaluation Contexts (λx. e) v e{v/x} β 19 With evaluation contexts, we can define the evaluation semantics for the CBV λ-calculus with just two rules: one for evaluation contexts, and one for β-reduction. With this syntax: The small-step rules are: E ::= [ ] E e v E e e E[e] E[e ]

67 CBN With Evaluation Contexts 20 We can also define the semantics of CBN λ-calculus with evaluation contexts.

68 CBN With Evaluation Contexts 20 We can also define the semantics of CBN λ-calculus with evaluation contexts. For call-by-name, the syntax for evaluation contexts is different: E ::= [ ] E e

69 CBN With Evaluation Contexts We can also define the semantics of CBN λ-calculus with evaluation contexts. For call-by-name, the syntax for evaluation contexts is different: E ::= [ ] E e But the small-step rules are the same: e e E[e] E[e ] (λx. e) e e{e /x} β 20

70 Multi-Argument λ-calculus 21 Let s define a version of the λ-calculus that allows functions to take multiple arguments. e ::= x λx 1,..., x n. e e 0 e 1... e n

71 Multi-Argument λ-calculus 22 We can define a CBV operational semantics: E ::= [ ] v 0... v i 1 E e i+1... e n e e E[e] E[e ] (λx 1,..., x n. e 0 ) v 1... v n e 0 {v 1 /x 1 }{v 2 /x 2 }... {v n /x n } β The evaluation contexts ensure that we evaluate multi-argument applications e 0 e 1... e n from left to right.

72 Definitional Translation 23 The multi-argument λ-calculus isn t any more expressive that the pure λ-calculus.

73 Definitional Translation 23 The multi-argument λ-calculus isn t any more expressive that the pure λ-calculus. We can define a translation T [[ ]] that takes an expression in the multi-argument λ-calculus and returns an equivalent expression in the pure λ-calculus.

74 Definitional Translation 23 The multi-argument λ-calculus isn t any more expressive that the pure λ-calculus. We can define a translation T [[ ]] that takes an expression in the multi-argument λ-calculus and returns an equivalent expression in the pure λ-calculus. T [[x]] = x T [[λx 1,..., x n. e]] = λx λx n. T [[e]] T [[e 0 e 1 e 2... e n ]] = (... ((T [[e 0 ]] T [[e 1 ]]) T [[e 2 ]])... T [[e n ]]) This translation curries the multi-argument λ-calculus.

Type Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth.

Type Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth. Type Systems Lecture 2 Oct. 27th, 2004 Sebastian Maneth http://lampwww.epfl.ch/teaching/typesystems/2004 Today 1. What is the Lambda Calculus? 2. Its Syntax and Semantics 3. Church Booleans and Church

More information

Programming Languages

Programming Languages CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2

More information

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007 CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation

More information

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University The Lambda Calculus Stephen A. Edwards Columbia University Fall 2014 Lambda Expressions Function application written in prefix form. Add four and five is (+ 4 5) Evaluation: select a redex and evaluate

More information

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages ) Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) This Saturday, 10 November 2018, room 335 (FSEGA), we will recover the following activities: 1 Formal Methods

More information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 5 November 15 November 15, 2006 - version 1.0 Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed last

More information

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages ) Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed

More information

Typed Arithmetic Expressions

Typed Arithmetic Expressions Typed Arithmetic Expressions CS 550 Programming Languages Jeremy Johnson TAPL Chapters 3 and 5 1 Types and Safety Evaluation rules provide operational semantics for programming languages. The rules provide

More information

Type Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth

Type Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth Today 1. What is the Lambda Calculus? Type Systems 2. Its Syntax and Semantics 3. Church Booleans and Church Numerals 4. Lazy vs. Eager Evaluation (call-by-name vs. call-by-value) Lecture 2 Oct. 27th,

More information

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Content COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ Slide 1 Intro & motivation, getting started [1] Foundations & Principles Lambda

More information

1. Object Calculus. Object calculus is to OO languages what lambda calculus is to functional languages

1. Object Calculus. Object calculus is to OO languages what lambda calculus is to functional languages 1. Object Calculus In this section we will introduce a calculus of objects that gives a simple but powerful mathematical model to study object based languages. Object calculus is to OO languages what lambda

More information

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 Contents 1 Polymorphism 1 2 Polymorphic λ-calculus: Syntax 1 3 Static Semantics 2 4 Dynamic Semantics

More information

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures CS 6110 S18 Lecture 21 Products, Sums, and Other Datatypes 1 Introduction In this lecture, we add constructs to the typed λ-calculus that allow working with more complicated data structures, such as pairs,

More information

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready.

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready. CSE 505, Fall 2009, Midterm Examination 5 November 2009 Please do not turn the page until everyone is ready Rules: The exam is closed-book, closed-note, except for one side of one 85x11in piece of paper

More information

Lambda-Calculus (cont): Fixpoints, Naming. Lecture 10 CS 565 2/10/08

Lambda-Calculus (cont): Fixpoints, Naming. Lecture 10 CS 565 2/10/08 Lambda-Calculus (cont): Fixpoints, Naming Lecture 10 CS 565 2/10/08 Recursion and Divergence Consider the application: Ω ((λ x. (x x)) (λ x. (x x))) Ω evaluates to itself in one step. It has no normal

More information

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready.

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready. CSE 505, Fall 2005, Midterm Examination 8 November 2005 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.

More information

COMP6463: λ-calculus

COMP6463: λ-calculus COMP6463: λ-calculus 1. Basics Michael Norrish Michael.Norrish@nicta.com.au Canberra Research Lab., NICTA Semester 2, 2015 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics

More information

Formal Techniques for Software Engineering: Denotational Semantics

Formal Techniques for Software Engineering: Denotational Semantics Formal Techniques for Software Engineering: Denotational Semantics Rocco De Nicola IMT Institute for Advanced Studies, Lucca rocco.denicola@imtlucca.it May 2013 Lesson 4 R. De Nicola (IMT-Lucca) FoTSE@LMU

More information

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus Course 2D1453, 200607 Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Typing λterms The uptyped λcalculus

More information

ITP Programming Languages Lambda Calculus Lesson 0 Functional Programming and Lambda Calculus Lesson 1 Introduction to the Lambda Calculus

ITP Programming Languages Lambda Calculus Lesson 0 Functional Programming and Lambda Calculus Lesson 1 Introduction to the Lambda Calculus ITP 20005 Programming Languages Lambda Calculus Lesson 0 Functional Programming and Lambda Calculus Lesson 1 Introduction to the Lambda Calculus Lesson 2 Boolean Logic in the Lambda Calculus Lesson 3 Function

More information

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables conversion

More information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 7 November 29 November 29, 2006 - version 1.0 Plan PREVIOUSLY: 1. type safety as progress and preservation 2. typed arithmetic expressions 3. simply typed lambda

More information

Normalization by Evaluation

Normalization by Evaluation Normalization by Evaluation Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University PhD Seminar in Mathematical Engineering EAFIT University, Medellin, Colombia 9

More information

Models of computation

Models of computation Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal ethods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables odels of computation

More information

Extending the Lambda Calculus: An Eager Functional Language

Extending the Lambda Calculus: An Eager Functional Language Syntax of the basic constructs: Extending the Lambda Calculus: An Eager Functional Language canonical forms z cfm ::= intcfm boolcfm funcfm tuplecfm altcfm intcfm ::= 0 1-1... boolcfm ::= boolconst funcfm

More information

PROBLEM SET 3: PROOF TECHNIQUES

PROBLEM SET 3: PROOF TECHNIQUES PROBLEM SET 3: PROOF TECHNIQUES CS 198-087: INTRODUCTION TO MATHEMATICAL THINKING UC BERKELEY EECS FALL 2018 This homework is due on Monday, September 24th, at 6:30PM, on Gradescope. As usual, this homework

More information

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications NICTA Advanced Course Theorem Proving Principles, Techniques, Applications λ 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural

More information

Programming Language Concepts: Lecture 16

Programming Language Concepts: Lecture 16 Programming Language Concepts: Lecture 16 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 16, 23 March 2009 λ-calculus:

More information

Equivalent Computers. Lecture 39: Lambda Calculus. Lambda Calculus. What is Calculus? Real Definition. Why?

Equivalent Computers. Lecture 39: Lambda Calculus. Lambda Calculus. What is Calculus? Real Definition. Why? #,, - Lecture 39: Lambda Calculus Equivalent Computers z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in M. (λx. M)N β M [ x α N ] Turing Machine

More information

Lambda Calculus. Syntax. i ::= a b c d e... etc L ::= i i L L L ( L ) A Few Examples. x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a))

Lambda Calculus. Syntax. i ::= a b c d e... etc L ::= i i L L L ( L ) A Few Examples. x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a)) Syntax Lambda Calculus A Few Examples i ::= a b c d e... etc L ::= i i L L L ( L ) x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a)) Semantics With Examples α β Anywhere that something of the form

More information

Categories, Proofs and Programs

Categories, Proofs and Programs Categories, Proofs and Programs Samson Abramsky and Nikos Tzevelekos Lecture 4: Curry-Howard Correspondence and Cartesian Closed Categories In A Nutshell Logic Computation 555555555555555555 5 Categories

More information

On the Correctness and Efficiency of the Krivine Machine

On the Correctness and Efficiency of the Krivine Machine On the Correctness and Efficiency of the Krivine Machine Mitchell Wand Northeastern University Daniel P. Friedman Indiana University February 12, 2003 Abstract We provide a short derivation of the Krivine

More information

CS 6110 Lecture 28 Subtype Polymorphism 3 April 2013 Lecturer: Andrew Myers

CS 6110 Lecture 28 Subtype Polymorphism 3 April 2013 Lecturer: Andrew Myers CS 6110 Lecture 28 Subtype Polymorphism 3 April 2013 Lecturer: Andrew Myers 1 Introduction In this lecture, we make an attempt to extend the typed λ-calculus for it to support more advanced data structures

More information

CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers

CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers To develop a denotational semantics for a language with recursive types, or to give a denotational semantics for the untyped

More information

Simple Type Extensions

Simple Type Extensions Simple Type Extensions Type Systems, Lecture 4 Jevgeni Kabanov Tartu, 14.02.2006 PREVIOUSLY ON TYPE SYSTEMS Lambda Calculus Embedded Booleans and Arithmetical expressions Fixpoints and Recursion Simple

More information

Computability Theory. CS215, Lecture 6,

Computability Theory. CS215, Lecture 6, Computability Theory CS215, Lecture 6, 2000 1 The Birth of Turing Machines At the end of the 19th century, Gottlob Frege conjectured that mathematics could be built from fundamental logic In 1900 David

More information

The Knaster-Tarski Fixed Point Theorem for Complete Partial Orders

The Knaster-Tarski Fixed Point Theorem for Complete Partial Orders The Knaster-Tarski Fixed Point Theorem for Complete Partial Orders Stephen Forrest October 31, 2005 Complete Lattices Let (X, ) be a be partially ordered set, and let S X. Then S ( the meet of S ) denotes

More information

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers To develop a denotational semantics for a language with recursive types, or to give a denotational semantics for the untyped

More information

Type Systems. Lecture 9: Classical Logic. Neel Krishnaswami University of Cambridge

Type Systems. Lecture 9: Classical Logic. Neel Krishnaswami University of Cambridge Type Systems Lecture 9: Classical Logic Neel Krishnaswami University of Cambridge Where We Are We have seen the Curry Howard correspondence: Intuitionistic propositional logic Simply-typed lambda calculus

More information

Propositional Logic: Semantics and an Example

Propositional Logic: Semantics and an Example Propositional Logic: Semantics and an Example CPSC 322 Logic 2 Textbook 5.2 Propositional Logic: Semantics and an Example CPSC 322 Logic 2, Slide 1 Lecture Overview 1 Recap: Syntax 2 Propositional Definite

More information

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig First-Order Logic First-Order Theories Roopsha Samanta Partly based on slides by Aaron Bradley and Isil Dillig Roadmap Review: propositional logic Syntax and semantics of first-order logic (FOL) Semantic

More information

CIS 500 Software Foundations Midterm II Answer key November 17, 2004

CIS 500 Software Foundations Midterm II Answer key November 17, 2004 CIS 500 Software Foundations Midterm II Answer key November 17, 2004 Simply typed lambda-calculus The following questions refer to the simply typed lambda-calculus with booleans and error. The syntax,

More information

CIS 500 Software Foundations Final Exam Answer key December 20, 2004

CIS 500 Software Foundations Final Exam Answer key December 20, 2004 CIS 500 Software Foundations Final Exam Answer key December 20, 2004 True/False questions For each of the following statements, circle T if the sentence is true or F otherwise. 1. (10 points) (a) T F The

More information

Discrete Mathematics for CS Fall 2003 Wagner Lecture 3. Strong induction

Discrete Mathematics for CS Fall 2003 Wagner Lecture 3. Strong induction CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 3 This lecture covers further variants of induction, including strong induction and the closely related wellordering axiom. We then apply these

More information

Structural Induction

Structural Induction Structural Induction In this lecture we ll extend the applicability of induction to many universes, ones where we can define certain kinds of objects by induction, in addition to proving their properties

More information

Non deterministic classical logic: the λµ ++ -calculus

Non deterministic classical logic: the λµ ++ -calculus Paru dans : Mathematical Logic Quarterly, 48, pp. 357-366, 2002 Non deterministic classical logic: the λµ ++ -calculus Karim NOUR LAMA - Equipe de Logique, Université de Savoie 73376 Le Bourget du Lac

More information

Element x is R-minimal in X if y X. R(y, x).

Element x is R-minimal in X if y X. R(y, x). CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1

More information

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV Henrik Nilsson University of Nottingham, UK G54FOP: Lecture 17 & 18 p.1/33 These Two Lectures Revisit attempt to define denotational

More information

First-Order Logic (FOL)

First-Order Logic (FOL) First-Order Logic (FOL) Also called Predicate Logic or Predicate Calculus 2. First-Order Logic (FOL) FOL Syntax variables x, y, z, constants a, b, c, functions f, g, h, terms variables, constants or n-ary

More information

Formal Methods Lecture 8. (B. Pierce's slides for the book Types and Programming Languages )

Formal Methods Lecture 8. (B. Pierce's slides for the book Types and Programming Languages ) Formal Methods Lecture 8 (B. Pierce's slides for the book Types and Programming Languages ) Erasure and Typability Erasure We can transform terms in λ to terms of the untyped lambda-calculus simply by

More information

Lambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT

Lambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT Lambda Calculus Andrés Sicard-Ramírez Universidad EAFIT Semester 2010-2 Bibliography Textbook: Hindley, J. R. and Seldin, J. (2008). Lambda-Calculus and Combinators. An Introduction. Cambridge University

More information

CSCI3390-Lecture 6: An Undecidable Problem

CSCI3390-Lecture 6: An Undecidable Problem CSCI3390-Lecture 6: An Undecidable Problem September 21, 2018 1 Summary The language L T M recognized by the universal Turing machine is not decidable. Thus there is no algorithm that determines, yes or

More information

Turing Machines Part II

Turing Machines Part II Turing Machines Part II Problem Set Set Five Five due due in in the the box box up up front front using using a late late day. day. Hello Hello Condensed Slide Slide Readers! Readers! This This lecture

More information

(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F:

(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F: CS 6371 Advanced Programming Languages Sample Spring 2018 Final Exam This sample final exam is LONGER than a real final exam (to give you more practice problems) and has a medium difficulty level. You

More information

Kleene realizability and negative translations

Kleene realizability and negative translations Q E I U G I C Kleene realizability and negative translations Alexandre Miquel O P. D E. L Ō A U D E L A R April 21th, IMERL Plan 1 Kleene realizability 2 Gödel-Gentzen negative translation 3 Lafont-Reus-Streicher

More information

Recursion Theorem. Ziv Scully Ziv Scully Recursion Theorem / 28

Recursion Theorem. Ziv Scully Ziv Scully Recursion Theorem / 28 Recursion Theorem Ziv Scully 18.504 Ziv Scully Recursion Theorem 18.504 1 / 28 A very λ-calculus appetizer P-p-p-plot twist! λ Ziv Scully Recursion Theorem 18.504 2 / 28 A very λ-calculus appetizer The

More information

Functional Programming with Coq. Yuxin Deng East China Normal University

Functional Programming with Coq. Yuxin Deng East China Normal University Functional Programming with Coq Yuxin Deng East China Normal University http://basics.sjtu.edu.cn/ yuxin/ September 10, 2017 Functional Programming Y. Deng@ECNU 1 Reading materials 1. The Coq proof assistant.

More information

Lecture Notes on Data Abstraction

Lecture Notes on Data Abstraction Lecture Notes on Data Abstraction 15-814: Types and Programming Languages Frank Pfenning Lecture 14 October 23, 2018 1 Introduction Since we have moved from the pure λ-calculus to functional programming

More information

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018 Very short lecture notes: Mathematical Foundations of Programming University of Nottingham, Computer Science, module code G54FOP, Spring 2018 Nicolai Kraus Draft of February 15, 2018 What is this? This

More information

Semantics of Higher-Order Functional Programming

Semantics of Higher-Order Functional Programming Semantics of Higher-Order Functional Programming Petros Barbagiannis µ λ July 14, 2014 Petros Barbagiannis Semantics of Higher-Order Functional Programming July 14, 2014 1 / 18 Introduction Higher-order

More information

Lecture 2. Lambda calculus. Iztok Savnik, FAMNIT. March, 2018.

Lecture 2. Lambda calculus. Iztok Savnik, FAMNIT. March, 2018. Lecture 2 Lambda calculus Iztok Savnik, FAMNIT March, 2018. 1 Literature Henk Barendregt, Erik Barendsen, Introduction to Lambda Calculus, March 2000. Lambda calculus Leibniz had as ideal the following

More information

(a) Definition of TMs. First Problem of URMs

(a) Definition of TMs. First Problem of URMs Sec. 4: Turing Machines First Problem of URMs (a) Definition of the Turing Machine. (b) URM computable functions are Turing computable. (c) Undecidability of the Turing Halting Problem That incrementing

More information

Lambda Calculus! Gunnar Gotshalks! LC-1

Lambda Calculus! Gunnar Gotshalks! LC-1 Lambda Calculus! LC-1 λ Calculus History! Developed by Alonzo Church during mid 1930 s! One fundamental goal was to describe what can be computed.! Full definition of λ-calculus is equivalent in power

More information

Logic and Probability Lecture 3: Beyond Boolean Logic

Logic and Probability Lecture 3: Beyond Boolean Logic Logic and Probability Lecture 3: Beyond Boolean Logic Wesley Holliday & Thomas Icard UC Berkeley & Stanford August 13, 2014 ESSLLI, Tübingen Wesley Holliday & Thomas Icard: Logic and Probability, Lecture

More information

CS 361 Meeting 26 11/10/17

CS 361 Meeting 26 11/10/17 CS 361 Meeting 26 11/10/17 1. Homework 8 due Announcements A Recognizable, but Undecidable Language 1. Last class, I presented a brief, somewhat inscrutable proof that the language A BT M = { M w M is

More information

CS 2800: Logic and Computation Fall 2010 (Lecture 13)

CS 2800: Logic and Computation Fall 2010 (Lecture 13) CS 2800: Logic and Computation Fall 2010 (Lecture 13) 13 October 2010 1 An Introduction to First-order Logic In Propositional(Boolean) Logic, we used large portions of mathematical language, namely those

More information

Topic 1: Propositional logic

Topic 1: Propositional logic Topic 1: Propositional logic Guy McCusker 1 1 University of Bath Logic! This lecture is about the simplest kind of mathematical logic: propositional calculus. We discuss propositions, which are statements

More information

Programming Language Concepts: Lecture 18

Programming Language Concepts: Lecture 18 Programming Language Concepts: Lecture 18 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 18, 30 March 2009 One step reduction

More information

Lecture 2: Syntax. January 24, 2018

Lecture 2: Syntax. January 24, 2018 Lecture 2: Syntax January 24, 2018 We now review the basic definitions of first-order logic in more detail. Recall that a language consists of a collection of symbols {P i }, each of which has some specified

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 17 Tuesday, April 2, 2013 1 There is a strong connection between types in programming languages and propositions

More information

CS156: The Calculus of Computation Zohar Manna Winter 2010

CS156: The Calculus of Computation Zohar Manna Winter 2010 Page 3 of 35 Page 4 of 35 quantifiers CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 2: First-Order Logic (FOL) existential quantifier x. F [x] there exists an x such that F [x] Note:

More information

Turing Machine Recap

Turing Machine Recap Turing Machine Recap DFA with (infinite) tape. One move: read, write, move, change state. High-level Points Church-Turing thesis: TMs are the most general computing devices. So far no counter example Every

More information

Programming Languages and Types

Programming Languages and Types Programming Languages and Types Klaus Ostermann based on slides by Benjamin C. Pierce Where we re going Type Systems... Type systems are one of the most fascinating and powerful aspects of programming

More information

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018 CS 301 Lecture 17 Church Turing thesis Stephen Checkoway March 19, 2018 1 / 17 An abridged modern history of formalizing algorithms An algorithm is a finite, unambiguous sequence of steps for solving a

More information

September 14. Fall Software Foundations CIS 500

September 14. Fall Software Foundations CIS 500 CIS 500 Software Foundations Fall 2005 September 14 CIS 500, September 14 1 Announcements I will be away September 19-October 5. I will be reachable by email. Fastest response cis500@cis.upenn.edu No office

More information

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready.

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready. CSE 505, Fall 2008, Midterm Examination 29 October 2008 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.

More information

forty-two XLII Equivalent Computers? Lecture 40: Computing with Glue and Photons What is 42? cuarenta y dos Meaning of Numbers Meaning of Numbers

forty-two XLII Equivalent Computers? Lecture 40: Computing with Glue and Photons What is 42? cuarenta y dos Meaning of Numbers Meaning of Numbers ), #, R #,, - ), #, R #,, - Lecture 40: Computing with Glue and Photons Equivalent Computers? z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in

More information

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012 Decision Problems with TM s Look at following sets: Lecture 31: Halting Problem CSCI 81 Spring, 2012 Kim Bruce A TM = { M,w M is a TM and w L(M)} H TM = { M,w M is a TM which halts on input w} TOTAL TM

More information

Logic: The Big Picture

Logic: The Big Picture Logic: The Big Picture A typical logic is described in terms of syntax: what are the legitimate formulas semantics: under what circumstances is a formula true proof theory/ axiomatization: rules for proving

More information

A λ-calculus with Constants and Let-blocks

A λ-calculus with Constants and Let-blocks A λ-calculus with Constants and Let-blocks Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 19, 2006 September 19, 2006 http://www.csg.csail.mit.edu/6.827 L04-1 Outline Recursion

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Chapter 7 Propositional Satisfiability Techniques

Chapter 7 Propositional Satisfiability Techniques Lecture slides for Automated Planning: Theory and Practice Chapter 7 Propositional Satisfiability Techniques Dana S. Nau CMSC 722, AI Planning University of Maryland, Spring 2008 1 Motivation Propositional

More information

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw Applied Logic Lecture 1 - Propositional logic Marcin Szczuka Institute of Informatics, The University of Warsaw Monographic lecture, Spring semester 2017/2018 Marcin Szczuka (MIMUW) Applied Logic 2018

More information

Turing machines and linear bounded automata

Turing machines and linear bounded automata and linear bounded automata Informatics 2A: Lecture 29 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 27 November 2015 1 / 15 The Chomsky hierarchy: summary Level Language

More information

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims Introduction INTRODUCTION TO LOGIC 2 Syntax and Semantics of Propositional Logic Volker Halbach In what follows I look at some formal languages that are much simpler than English and define validity of

More information

Models of Computation,

Models of Computation, Models of Computation, 2010 1 Induction We use a lot of inductive techniques in this course, both to give definitions and to prove facts about our semantics So, it s worth taking a little while to set

More information

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement: Decidability 2017/10/31 Chapter 4.1 in Sipser Ø Announcement: q q q Slides for this lecture are here: http://www.public.asu.edu/~yzhan442/teaching/cse355/lectures/decidability.pdf Happy Hollaween! Delayed

More information

Propositions. c D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 5.1, Page 1

Propositions. c D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 5.1, Page 1 Propositions An interpretation is an assignment of values to all variables. A model is an interpretation that satisfies the constraints. Often we don t want to just find a model, but want to know what

More information

20.1 2SAT. CS125 Lecture 20 Fall 2016

20.1 2SAT. CS125 Lecture 20 Fall 2016 CS125 Lecture 20 Fall 2016 20.1 2SAT We show yet another possible way to solve the 2SAT problem. Recall that the input to 2SAT is a logical expression that is the conunction (AND) of a set of clauses,

More information

A Lambda Calculus for Quantum Computation

A Lambda Calculus for Quantum Computation arxiv:quant-ph/0307150v5 3 Apr 004 A Lambda Calculus for Quantum Computation André van Tonder Department of Physics, Brown University Box 1843, Providence, RI 0906 andre@het.brown.edu July 15, 003 Revised

More information

1 Problem 1. (20 pts)

1 Problem 1. (20 pts) CS 336 Programming Languages Homework Solution 4 Winter 2005 Due 2/24/05 1 Problem 1. (20 pts) Do Exercise 18.6.2. We define a meta-operation + on types as follows: If R is a record type with labels given

More information

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2018 5. Complexity of Query Evaluation Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 17 April, 2018 Pichler

More information

Turing machines and linear bounded automata

Turing machines and linear bounded automata and linear bounded automata Informatics 2A: Lecture 30 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 25 November 2016 1 / 17 The Chomsky hierarchy: summary Level Language

More information

Consistency of a Programming Logic for a Version of PCF Using Domain Theory

Consistency of a Programming Logic for a Version of PCF Using Domain Theory Consistency of a Programming Logic for a Version of PCF Using Domain Theory Andrés Sicard-Ramírez EAFIT University Logic and Computation Seminar EAFIT University 5 April, 3 May 2013 A Core Functional Programming

More information

T Reactive Systems: Temporal Logic LTL

T Reactive Systems: Temporal Logic LTL Tik-79.186 Reactive Systems 1 T-79.186 Reactive Systems: Temporal Logic LTL Spring 2005, Lecture 4 January 31, 2005 Tik-79.186 Reactive Systems 2 Temporal Logics Temporal logics are currently the most

More information

CS20a: Turing Machines (Oct 29, 2002)

CS20a: Turing Machines (Oct 29, 2002) CS20a: Turing Machines (Oct 29, 2002) So far: DFA = regular languages PDA = context-free languages Today: Computability 1 Church s thesis The computable functions are the same as the partial recursive

More information

Most General computer?

Most General computer? Turing Machines Most General computer? DFAs are simple model of computation. Accept only the regular languages. Is there a kind of computer that can accept any language, or compute any function? Recall

More information

Introduction to Probabilistic Programming Language (with Church as an example) Presenter: Enrique Rosales, Xing Zeng

Introduction to Probabilistic Programming Language (with Church as an example) Presenter: Enrique Rosales, Xing Zeng Introduction to Probabilistic Programming Language (with Church as an example) Presenter: Enrique Rosales, Xing Zeng 1 Knowledge How can we infer knowledge from observations? 2 Ron s box Bob has a box

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.2016.6.1 COMPUTER SCIENCE TRIPOS Part IB Thursday 2 June 2016 1.30 to 4.30 COMPUTER SCIENCE Paper 6 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.

More information

CITS2211 Discrete Structures (2017) Cardinality and Countability

CITS2211 Discrete Structures (2017) Cardinality and Countability CITS2211 Discrete Structures (2017) Cardinality and Countability Highlights What is cardinality? Is it the same as size? Types of cardinality and infinite sets Reading Sections 45 and 81 84 of Mathematics

More information