Principles of Programming Languages

Size: px
Start display at page:

Download "Principles of Programming Languages"

Transcription

1 Principles of Programming Languages Lecture 03 Theoretical Foundations 1

2 Domains Semantic model of a data type: semantic domain! Examples: Integer, Natural, Truth-Value Domains D are more than a set of values! Have an ``information ordering! on elements a partial order-- where x! y means (informally): ``y is as least as well-defined as x! There is a ``least defined element such that ( x)! x which represents an undefined value of the data type Or the value of a computation that fails to terminate ``bottom! Domains are complete: every monotone (non-decreasing) sequence x1! x2!!! xn!! in D has in D a least upper bound, i.e., an element denoted l = x i such that ( i) i and l is least element with this property D sometimes called a ``complete partial order or CPO x x!" l 2

3 Primitive Domains Integer (Z, Z) Natural (N, N) Truth-Value (Boolean, B, B) false true 3

4 Cartesian Product Domains D D = x y x D y D! ! bottom Truth-Value Truth-Value {(, ), } ( x, y )!( x, y ) x! x y!" y (, ) false true false true (false, false) (false, true) (true, false) (true, true) = (false,) (, false) (, true) (true, ) Generalizes to! D D D! D n (,) 4

5 Disjoint Union (Tagged Union) Domains left D + right D = left x x D right y y D left x!" left x x! x right y! right y y! y! ! bottom left Truth-Value + right Truth-Value {(, ) } {(, ) } left false true false true + right = left false left true right false right true left right 5

6 Disjoint Union Domains (cont.) Convention: tags are also names for mappings (injections) tagging operators D= left D + right D 1 2! left : D 1 left( x ) = ( left, x ) [ = left x ] right : D D D right( y ) = ( right, y ) [ = right y ]

7 Disjoint Union Domains (cont.) Example: union domains needed when data domains consist of different type elements (union types): imagine a very simple programming language in which the only things that can be named (denoted) are non-negative integer constants, or variables having such as values. Denotable = nat Natural + var Location! Dereferencing operation: Constant values dereference directly to their values Variables (locations) dereference to their contents in memory dereference : Store Denotable Natural dereference( sto, nat val) = val dereference( sto, var loc) = fetch( sto, loc) (no dependence on memory) 7

8 Sequence Domains Consist of homogenious tuples of lengths 0, 1, over a common domain D! 0 1 n+ 1 n D #{()} # Unit D # D D # D D D D D D # + + +!! Examples: Array- Value = Value String = Character! Concatenation operator : D D D ( d, d,, d ) ( e, e,, e ) = ( d, d,, d, e, e,, e ) 1 2 m 1 2 n 1 2 m 1 2 n nil = () nil x = x nil = x x D! Empty tuple nil 8

9 Functions A function f from source domain X to target domain Y is! A subset of X Y : f X Y (a relation)! Single-valued:! Source domain X! Target domain Y! Signature f : X Y Domain of f :! If X =domf then f is total ; otherwise partial To define (specify) a function, need to give! Source X! Target Y! Mapping rule x f(x) ( x, yz, ) ( xy, ) f ( xz, ) f y= z dom f = { x X y Y ( x, y) f} 9

10 Functions (cont.) Example: sq : Z sq( n)! Let R = Real. Not the same function as: sq1: R R 2 sq1( x) # x! Let N = Natural. Not the same as: sq % : N N % 2 sq() i # i Z 2 # n - fun sq(n:int):int = n*n; val sq = fn : int -> int - sq(3); val it = 9 : int - sq(1.5); stdin: Error: operator and operand don't agree [tycon mismatch] operator domain: int operand: real in expression: sq fun sq1(x:real):real = x*x; val sq1 = fn : real -> real - sq1(1.5); val it = 2.25 : real - sq1(3); stdin: Error: operator and operand don't agree [literal] operator domain: real operand:int in expression: sq1 3-10

11 Defining Functions Two views of ``mapping! Extension: view as a collection of facts square : Z Z square = {(0,0),(1,1),( 1,1)(2, 4),( 2,4)(3,9), } N N! Comprehension: view as a rule of mapping Combinator form: λ-abstraction form:! Typed λ-calculus square : Z Z # λ y : Z. y * y! In ML λ = fn. = => (λx e) = (fn x => e) square : Z Z square( x) # x* x square # λ y. y * y - fun square(x) = x*x; val square = fn : int -> int - square(4); val it = 16 : int - val square = (fn y => y*y); val square = fn : int -> int - square(5); val it = 25 : int 11

12 Defining Functions (cont.) Examples of λ-notation defining functions dist : R R R # λ( u, v). ( u v) double : Z Z # λn : Z. n + n successor : Z Z # λn : Z. n + 1 twice :( Z Z) ( Z Z) # λf :( Z Z). λn : Z. f ( f ( n)) compose :( Z Z) (( Z Z) ( Z Z)) # λf.( λg.( λn. f ( g( n)))) dist(0, ) : R R # λv. v 2 2 twice( double): Z Z # λn : Z.4 n twice( successor): Z Z # λn : Z. n + 2 ( compose( successor))( double): Z Z # λn : Z.2 n

13 Defining Functions (cont.) - val double = (fn n => n+n); val double = fn : int -> int - val successor = (fn n => n+1); val successor = fn : int -> int - val twice = (fn f => (fn n => f(f(n)))); val twice = fn : ('a -> 'a) -> 'a -> 'a - val twice = (fn f : int -> int => (fn n : int => f(f(n)))); val twice = fn : (int -> int) -> int -> int - val td = twice(double); val td = fn : int -> int - td(3); val it = 12 : int - val ts = twice(successor); val ts = fn : int -> int - ts(3); val it = 5 : int 13

14 Defining Functions (cont.) - fun double(n) = n+n; val double = fn : int -> int - fun successor(n) = n+1; val successor = fn : int -> int - fun twice(f)(n) = f(f(n)); val twice = fn : ('a -> 'a) -> 'a -> 'a - fun twice(f : int -> int )(n : int) = f(f(n)); val twice = fn : (int -> int) -> int -> int - fun td = twice(double); stdin: Error: can't find function arguments in clause - twice(double)(3); val it = 12 : int - twice(successor)(3); val it = 5 : int - fun compose(f)(g)(n) = f(g(n)); val compose = fn : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b - val csd = compose(successor)(double); val csd = fn : int -> int - csd(3); val it = 7 : int 14

15 Function Domains Elements are functions from a domain to 1 2 another Domain of functions denoted Not all functions must be monotone: if! Idea: more info about argument more info about value Ordering on domain Bottom element of domain! totally undefined function f : D D D1 D2 (or [ D1 D2] ) f D1 D2 xy, D x! y f( x)! f( y) 1 D 1 2 D1 D2 f! D ( 1 D g x D 2 1 f ( x)! D g( x) 2 D1 D2 # λx. Technical requirement: functions must be continuous: monotone chains x! x!! f( x ) = f( x ) D D D D i i 15

16 Function Domains (cont.) (Truth-Value Unit) f false true ( ) t f t ( ) ( ) Models procedures (void functions) that take a boolean and return, or not f f t ( ) t ( ) f?? f t ( ) t ( ) 16

17 Function Domains (cont.) (Truth-Value Truth-Value) Exercise! Be careful about monotonicity! false true false true 17

18 λ-calculus Let e be an expression containing zero or more occurrences of variables x1, x2,, xn Let ea [ / x] denote the result of replacing each occurrence of x by a The lambda expression! Denotes (names) a function λ x x x e 1 2 n.! Value of the λ-expression is a function f such that aa 1 2 an f( a1, a2,, an) = value of expression ea [ / x, a / x,, a / x] ! Provides a direct description of a function object, not indirectly via its behavior when applied to arguments n n 18

19 λ-calculus Examples Example: sq sq = ``that function that if applied to a results in = λx.( x x) a a'' Example: zval zval = ``the functional that when applied to function f results in f(0)'' = λ f. f (0) Example: compose = ``the functional that when applied to functions f and g results in the funtion λx. f( g( x))'' compose = λf.( λg.( λx.( f ( g( x))))) 19

20 λ-calculus Examples (cont.) Functionals: functions that take other functions as arguments or that return functions; also highertype functions Example: the definite integral Example: the indefinite integral 3 0 x 2 x udu= :( R R ) ( R R ) x 2 x ( λzz. ) = λx. = λf. λx. f( u) du :( R R ) R = λ f. f( u) du f( u) du ( f : R R ) 0 x f ( u ) du ( f : R R ) ( ) 20

21 λ-calculus Examples (cont.) Example: integration routine trapezoidal : R R R ( R R ) R [( b a)/ n] trapezoidal = λhabf. h f ( a + i h) ( f ( a) + f ( b))/2 i= 0 Example: summation operator n :( N R ) R n n nn ( λm.1) = n+ 1 ( λmm. ) = :( N R ) ( N R ) ( λm.1) = λn.( n+ 1) n f() i ( f : N R ) i= 0 ( + 1) 2 21

22 λ-calculus Examples (cont.) Example: derivative operator n n 1 2 Dx = nx D3 = 0(!) D :( R R ) ( R R ) ( ) ( ) n n 1 D λxx. = λxnx. Example: indexing operator Postfix [i]: IntArray Integer [i]= λa.a[i] Example: funcall or apply operator! Signature apply :( A B) A B! Combinator definition apply( f )( a) = f ( a)! Lambda definition apply = λf. λa. f ( a) 22

23 Currying (Curry 1945;Schönfinkel 1924) Transformation reducing a multi-argument function to a cascade of 1-argument functions curry :( X Y Z) ( X ( Y Z) f :X Y Z curry( f ):( X Y) Z f = λ( xy, ). f( xy, ) curryf ( ) = λx. λyf. ( xy, ) curry = λf. λx. λy. f ( x, y) Examples curry(" ") = λx. λy.( x y) [" " = λ( x, y)( x y)] curry(" ")(3) = λ y.(3 y) curry("*")(2) = λz.(2 z) = double Applying curry(f) to first argument a yields a partially evaluated function f of its second argument: f(a,-) λ yf. ( ay, ) 23

24 Currying (cont.) Example: machine language curries += λa. λb.( a+ b)! Assume contents(a)=a and contents(b)=b LDA A r0 = λa. λb.( a+ b) ADD B } r0= λb.( a+ b) 24

25 λ-calculus Syntax Lambda=expression Id=identifier Ab=abstraction Ap=application Lambda Id Ab Ap Ab (λ Id. Lambda) Ap (Lambda Lambda) Id x y z Examples (( xy) z) ( fx) ( λx.( λy.( λz.(( xy) z) ))) ( λx.( λy. x)) ( λx.( λy.( λz.( x( yz)) ))) ( λx.( λy.( sqrt(( plus( square x))( square y))))) 25

26 λ-calculus: simplified notation Conventions for dropping () disambiguation needed Rules for dropping parentheses! Application groups L to R xyz #(( xy) z) x( yz) #( x( yz))! Application has higher precedence than abstraction λxyz. #( λx.( yz)) ( λxy. ) z# (( λxy. ) z)! Abstraction groupts R to L! Consecutive abstractions collapse to single λ! Example: λx. λy. λze. # ( λx.( λy.( λze. ))) λxyz. e # λx. λy. λz. e S # ( λx.( λy.( λz.(( xz)( yz))))) S = λxyz.( xz)( yz) = λxyz. xz( yz) λxyz.( xz) yz = ( λx.( λy.( λz.((( xz) y) z)))) 26

27 Variables: Free, Bound, Scope Metavariables: I: Id L: Lambda Type the semantic function occurs: Lambda (Id B) one rule per syntactic case (syntax-driven)!! " are traditional around syntax argument & ' occurs I x= ( I = x) & λ. ' x= & ' occurs I L occurs L & ' = & ' & ' occurs L L x occurs L x occurs L x x Note: In expession λx.y the variable x does not occur! 27

28 Variables: Free, Bound, Scope (cont.) occurs_bound : Lambda (Id B) & ' occurs _ bound I x = false occurs_free : Lambda (Id B) & λ ' = = & ' occurs _ bound I. L x ( x I) occurs _ free L x & ' x= _ & ' occurs _ bound L L occurs bound L & ' occurs _ free I x= ( I = x) & occurs _ bound L & λ ' = & ' occurs _ free I. L x ( x I) occurs _ free L x & ' x= _ & ' occurs _ free L L occurs free L occurs _ & free L 2 x ' 2 ' x x x 28

29 Variables: Free, Bound, Scope (cont.) The notions free x, bound x, occur x are relative to a given expression or subexpression Examples:!!! ( λu.( λxux. ) xu) ( λ xy. ) ( λx.( λy. y)) 29

30 Variables: Scope The scope of a variable x bound by an λx prefix in an abstraction (λx.e) consists of all of e excluding any abstraction subexpressions with prefix λx! these subexpressions are known as holes in the scope! Any occurrence of x in scope is said to be bound by the λx prefix Example Bindings: λy. λz. x ( z ( y ( λy. y z) ) y ) Scopes: i λy λzi x ( z ( y ( λyi y z) ) y ) hole in scope 30

31 λ-calculus: formal computation reduction rules α-conversion: formal parameter names do not affect meaning! Ex: β-reduction: models application of a function abstraction to its argument! Ex: λx. e λye. [ y/ x] α substitute y for free occurrences of x in e (rename of clash occurs) λx. λza. ( xz) λx. λz. a( xz ) α λ z. λzazz. ( ) λz. λxazx. ( ) α α ( λx. ea ) ea [ / x] redex ( λx. λy. x) a(( λxxx. )( λxxx. )) β contractum ( λya. )(( λxxx. )( λxxx. )) a β β 31

32 λ-calculus: formal computation (cont.) η-reduction: models extensionality λx. ex e η! Ex: x not free in e (no other x occurrences in scope) λv.( λxx. ( λxux. )) v η λv.( λ xxu. ) v ( λxx. ( λxux. )) η η ( λxxu. ) η ( λxxu. ) 32

33 Reduction is locally non-deterministic ( λu. λv.( λww. ( λxxu. )) v) y β ( λu. λvv. ( λ xxu. )) y λv.( λww. ( λxxy. )) v β β β λvv.( λ xxy. ) λvv.( λxxy. )? 33

34 Normal Forms Identify α-equivalent expressions Reduction: Reduction as far as possible : Defn: Normal Form: an expression that cannot be further reduced by λz.( λxx. ) z(( λxx. ) z) β λzz.(( λ xx.)) z λz.( λxx. ) z z β # # ( ) β η ( ) β λz. zz β 34

35 Normal Forms Don t Always Exist Parallel of non-terminating computation Example: self-application combinator : What happens with SELF # λx. xx ( SELF SELF) = (( λx. xx)( λx. xx))? (( λxxx. )( λzzz. )) β ( λzzz. )( λzzz. ) Ω # ( SELF SELF) = (( λx. xx)( λx. xx)) # β 35

36 Computation Rules Leftmost Innermost (LI): among the innermost nested redexes, choose the leftmost one to reduce Leftmost Outermost(LO): among the outermost redexes, choose the letmost one to reduce (( λ yz.(( λ x. x) z)( yz))( λ x. x))( λ w. a) LO LI (( λ yz.( z( yz))( λ x. x))( λ w. a) ( λ z.(( λ xx. ) z)(( λ xx. ) z))( λ wa. ) ( λ z. z(( λ x. x) z))( λ w. a) (( λ x. x)( λ w. a))(( λ x. x)( λ w. a)) ( λ z. zz)( λ w. a) ( λ wa. )(( λ xx. )( λ wa. )) ( λ wa. )( λ wa. ) a 36

37 β vs η --very different β-reduction: abstract e, then apply ( λxe. ) x parse η-reduction: apply e, then abstract λxex. parse no restriction on e (( λ xe. ) x) ( λx.( ex)) β η not η-redex not β-redex β η only if e free of x ex [ / x] Example: ((lambda (x) 1+) x) 1+ e Example: (lambda (x) (1+ x)) 1+ 37

38 Mixed β and η reductions λv. ( λx. x( λxux. ) ) v parse ( λv. (( λx.( x ( λxux. )) ) v) ) ( λv.(( λx.( x u) ) v) ) η β ( λv.( v ( λx.( ux)) ) ) β ( λv.( vu)) η 38

39 Church-Rosser: ultimate determinism Church-Rosser Theorem P M Q R M, PQ, M P & M Q R P R & Q R Corollary: If a normal form exists for an expression, it is unique (up to α-equivalence) 39

40 Church-Rosser: says reduction, not forced ( λx. a)( SELF SELF) = ( λxa. )(( λxxx. )( λxxx. )) LO LI a ( λxa. )( SELF SELF) LO LI a LO Correct computation rule: if a normal form, it will be computed ex: LO a ( λxa. )( SELF SELF) LI LO a ( λxa. )( SELF SELF) LI $ Incorrect (but efficient): ex: LI LO = normal rule = CBN = lazy Prog Lang: Haskell LI = applicative rule = CBV=eager Prog Lang: Scheme 40

41 Correct Computation Rule A rule is correct if it calculates a normal form, provided one exists Theorem: LO (normal rule) is a correct computation rule.! LI (applicative rule) is not correct gives the same result as normal rule whenever it converges to a normal form (guaranteed by the Church-Rosser property)! LI is simple, efficient and natural to implement: always evaluate all arguments before evaluating the function! LO is very inefficient: performs lots of copying of unevaluated expressions 41

42 Typed λ-calculus More restrictive reduction. No SELF = ( λx. xx) Type ::= (Type Type) PrimType Lambda ::= Id (Lambda Lambda) (λ Id : Type. Lambda) Id ::= x y z PrimType ::= int Type Deduction Rules ) M : σ τ ) N : σ (axiom) (appl) ) x : τ ) ( MN): τ ) M : τ ) x : σ (abst) ) ( λx: σ. M): σ τ E is type correct iff a type α such that ) E : α Thm: Every type correct expression has a normal form 42

43 Typed λ-calculus (cont.) Example: SELF = ( λx. xx) is not type correct! Work backward using rules. Assume ) λx : α. xx : α β &) x : γ )( xx): β ) x: α ) λx: α.( xx): α β γ = α ) x: α &( xx): β ) x : δ β ) x : δ ) ( xx): β ) x : δ &) x : α δ = α ) x: δ β & ) δ = α ) x: α β ) x: α &) x: α β α = ( α β )! So a contradiction. Therefore there is no consistent type assignment to SELF = ( λx. xx) 43

44 Typed λ-calculus (cont.) Example: type the expression! Work forward ) f : α β ) x : α ) ( fx): β )( fx): β ) x: α ) λx: α.( fx): α β (appl) (abst) λf. λxfx. ) λx : α.( fx): α β ) f : α β ) ( λf : α β.( λx: α.( fx))) : ( α β ) ( α β ) (abst) 44

45 λ-calculus: History Frege 1893: unary functions suffice for a theory Schönfinkel 1924:! Introduced currying! Combinators KAB # A SABC # AC(BC)! Combinatory (Weak) Completeness: all closed λ-expressions can be defined in terms of K,S using application only: Let M be built up from λ, K,S with only x left free. Then an expression F built from K,S only such that Fx=M Curry 1930: K # λab. a S# λabc. ac( bc)! introduced axiom of extensionality:! Weak Consistency: K=S is not provable X FX = GX F = G 45

46 λ-calculus: History (cont.) Combinatory Completeness Example:! Composition functional: BXYZ # X(YZ) B #λ fgx. f ( gx)! Thm: B = S(KS)K! Prf: Note that K # λxy. x KS= ( λxyx. ) S= λy. S So S(KS) = ( λxyz. xz( yz))( KS) = ( λyz.(( KS) z)( yz)) and so = ( λyz.(( λy. S) z))( yz) = λyz. S( yz) S(KS)K = ( λyz. S( yz)) K = λz. S( Kz) = λz. S( λy. z) α = λv.( S λwv.) = λv.( λxyz. xz( yz))( λwv.) = λv.( λyz.( λwv. ) z( yz)) = λv.( λyzv. ( yz)) = λv. λy. λzv. ( yz) = λf. λg. λx. f( gx) * Exercise: define C # λxyx. xzy & show C = S(BBS)(KK) α 46

47 λ-calculus: History (cont.) Church 1932:! If Fx=M call F λx.m! Fixed Point Theorem: Given F can construct a Φ such that Φ=FΦ! Discovered fixed point (or paradoxical ) combinator: Y # λf.( λx. f ( xx))( λx. f ( xx))! Exercise: Define Φ=YF and show by reduction that Φ=FΦ Church & Rosser 1936: strong consistency Church- Rosser Property.! Implies that α-equivalence classes of normal forms are disjoint! provides a syntactic model of computation Martin-Löf 1972: simplified C-R Theorem s proof 47

48 λ-calculus: History (cont.) Church 1932: Completeness of the λ-calculus! N can be embedded in the λ-calculus n# λf. λx. f( f(...( f x)...)) +,-,. n! Church 1932/Kleene 1935: recursive definition possible: F(1) = GA K-C-G ``general recursion'' Fn ( + 1) = GFn ( ) Thm : F is ``λ-definable'': F = λx. xga (!)! Check: F1 = ( λx. xga)1 1 GA ( λf. λx. fx) GA ( λxgx. ) A GA F2 2 GA ( λf. λx. f( fx)) GA ( λx. G( Gx)) A G( GA) 48

49 λ-calculus: History (cont.) Church-Rosser Thm (1936) λ-calculus functions are ``computable (aka ``recursive ) Church s Thesis: The ``effectively computable functions from N to N are exactly the λ-calculus definable functions a strong assertion about completeness ; all programming languages since are complete in this sense Evidence accumulated! Kleene 1936: general recursive λ-calculus definable! Turing 1937: λ-calculus definable Turing-computable! Post 1943, Markov 1951, etc.: many more confirmations! Any modern programming language 49

50 λ-calculus: History (cont.) Is the untyped λ-calculus consistent? Does it have a semantics? What is its semantic domain D?! want data objects same as function objects: since λ xmx. = M D= D! Trouble: impossible unless D =1 because! Troublesome self-application paradoxes: if we define then η τ = λ y. if y( y) = a then b else a τ ( τ) = if τ( τ) = a then b else a! Dana Scott 1970: will work if we have the D monotone (and continuous) functions of D! Above example: τ is not monotone τ ( λx. ) = if = a then b else a= a τλ ( xa. ) = if a= athen belse a = b λx.! λxa. but a! b D D < D D = D [ ] D= D D D 50

51 false false false true (false, false) (false, true) (true, false) (true, true) (false,) false (, false) false (, true) (true, ) (,) 51

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

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

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

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

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

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.

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

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

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

3.2 Equivalence, Evaluation and Reduction Strategies

3.2 Equivalence, Evaluation and Reduction Strategies 3.2 Equivalence, Evaluation and Reduction Strategies The λ-calculus can be seen as an equational theory. More precisely, we have rules i.e., α and reductions, for proving that two terms are intensionally

More information

Introduction to λ-calculus

Introduction to λ-calculus p.1/65 Introduction to λ-calculus Ken-etsu FUJITA fujita@cs.gunma-u.ac.jp http://www.comp.cs.gunma-u.ac.jp/ fujita/ Department of Computer Science Gunma University :Church 32, 36, 40; Curry 34 1. Universal

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

Origin in Mathematical Logic

Origin in Mathematical Logic Lambda Calculus Origin in Mathematical Logic Foundation of mathematics was very much an issue in the early decades of 20th century. Cantor, Frege, Russel s Paradox, Principia Mathematica, NBG/ZF Origin

More information

Introduction to lambda calculus Part 2

Introduction to lambda calculus Part 2 Introduction to lambda calculus Part 2 Antti-Juhani Kaijanaho 2017-01-24... 1 Untyped lambda calculus 1.1 Syntax... x, y, z Var t, u Term t, u ::= x t u λx t... In this document, I will be using the following

More information

Combinators & Lambda Calculus

Combinators & Lambda Calculus Combinators & Lambda Calculus Abstracting 1/16 three apples plus two pears = five fruits concrete 3+2 = 5 abstract objects a+b = b+a a (b c) = (a b) c abstract quantities abstract operations a, b[r(a,

More information

Charles Wells 1. February 25, 1999

Charles Wells 1. February 25, 1999 NOTES ON THE λ-calculus Charles Wells 1 February 25, 1999 Department of Mathematics Case Western Reserve University 10900 Euclid Ave. Cleveland, OH 44106-7058 USA charles@freude.com http://www.cwru.edu/artsci/math/wells/home.html

More information

Traditional and Non Traditional lambda calculi

Traditional and Non Traditional lambda calculi Strategies July 2009 Strategies Syntax Semantics Manipulating Expressions Variables and substitutions Free and bound variables Subterms and substitution Grafting and substitution Ordered list of variables

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

λ 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

Origin in Mathematical Logic

Origin in Mathematical Logic Lambda Calculus Origin in Mathematical Logic Foundation of mathematics was very much an issue in the early decades of 20th century. Cantor, Frege, Russel s Paradox, Principia Mathematica, NBG/ZF The Combinatory

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

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

l-calculus and Decidability

l-calculus and Decidability U.U.D.M. Project Report 2017:34 l-calculus and Decidability Erik Larsson Examensarbete i matematik, 15 hp Handledare: Vera Koponen Examinator: Jörgen Östensson Augusti 2017 Department of Mathematics Uppsala

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

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

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

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

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

Simply Typed Lambda-Calculi (II)

Simply Typed Lambda-Calculi (II) THEORY AND PRACTICE OF FUNCTIONAL PROGRAMMING Simply Typed Lambda-Calculi (II) Dr. ZHANG Yu Institute of Software, Chinese Academy of Sciences Fall term, 2011 GUCAS, Beijing Introduction PCF Programming

More information

Lecture 3. Lambda calculus. Iztok Savnik, FAMNIT. October, 2015.

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

More information

Models of Computation,

Models of Computation, Models of Computation, 2010 1 The Lambda Calculus A brief history of mathematical notation. Our notation for numbers was introduced in the Western World in the Renaissance (around 1200) by people like

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

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

Axioms of Kleene Algebra

Axioms of Kleene Algebra Introduction to Kleene Algebra Lecture 2 CS786 Spring 2004 January 28, 2004 Axioms of Kleene Algebra In this lecture we give the formal definition of a Kleene algebra and derive some basic consequences.

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

The Lambda-Calculus Reduction System

The Lambda-Calculus Reduction System 2 The Lambda-Calculus Reduction System 2.1 Reduction Systems In this section we present basic notions on reduction systems. For a more detailed study see [Klop, 1992, Dershowitz and Jouannaud, 1990]. Definition

More information

Lecture 2: Self-interpretation in the Lambda-calculus

Lecture 2: Self-interpretation in the Lambda-calculus Lecture 2: Self-interpretation in the Lambda-calculus H. Geuvers Nijmegen, NL 21st Estonian Winter School in Computer Science Winter 2016 H. Geuvers - Radboud Univ. EWSCS 2016 Self-interpretation in λ-calculus

More information

Advanced Lambda Calculus Lecture 5

Advanced Lambda Calculus Lecture 5 Advanced Lambda Calculus Lecture 5 The fathers Alonzo Church (1903-1995) as mathematics student at Princeton University (1922 or 1924) Haskell B. Curry (1900-1982) as BA in mathematics at Harvard (1920)

More information

Typed Lambda Calculi. Nikos Tzeveλekos Queen Mary, University of London 1 / 23

Typed Lambda Calculi. Nikos Tzeveλekos Queen Mary, University of London 1 / 23 Typed Lambda Calculi Nikos Tzeveλekos Queen Mary, University of London 1 / 23 What is the Lambda Calculus A minimal formalism expressing computation with functionals s ::= x λx.s ss All you need is lambda.

More information

On the Standardization Theorem for λβη-calculus

On the Standardization Theorem for λβη-calculus On the Standardization Theorem for λβη-calculus Ryo Kashima Department of Mathematical and Computing Sciences Tokyo Institute of Technology Ookayama, Meguro, Tokyo 152-8552, Japan. e-mail: kashima@is.titech.ac.jp

More information

The λ-calculus and Curry s Paradox Drew McDermott , revised

The λ-calculus and Curry s Paradox Drew McDermott , revised The λ-calculus and Curry s Paradox Drew McDermott drew.mcdermott@yale.edu 2015-09-23, revised 2015-10-24 The λ-calculus was invented by Alonzo Church, building on earlier work by Gottlob Frege and Moses

More information

3. The λ-calculus and Implication

3. The λ-calculus and Implication 3. The λ-calculus and Implication (a) (b) (c) (d) (e) (f) The untyped λ-calculus. The typed λ-calculus. The λ-calculus in Agda. Logic with Implication Implicational Logic in Agda. More on the typed λ-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

Operational Semantics

Operational Semantics Operational Semantics Semantics and applications to verification Xavier Rival École Normale Supérieure Xavier Rival Operational Semantics 1 / 50 Program of this first lecture Operational semantics Mathematical

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

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

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

Computation Theory, L 9 116/171

Computation Theory, L 9 116/171 Definition. A partial function f is partial recursive ( f PR) ifitcanbebuiltupinfinitelymanysteps from the basic functions by use of the operations of composition, primitive recursion and minimization.

More information

Complete Partial Orders, PCF, and Control

Complete Partial Orders, PCF, and Control Complete Partial Orders, PCF, and Control Andrew R. Plummer TIE Report Draft January 2010 Abstract We develop the theory of directed complete partial orders and complete partial orders. We review the syntax

More information

Advanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands

Advanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands Advanced Lambda Calculus Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands Form of the course Ordinary lecture Seminar form Exam: working out an exercise

More information

Beyond First-Order Logic

Beyond First-Order Logic Beyond First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Beyond First-Order Logic MFES 2008/09 1 / 37 FOL

More information

FORMAL SYSTEMS: COMBINATORY LOGIC

FORMAL SYSTEMS: COMBINATORY LOGIC FORMAL SYSTEMS: COMBINATORY LOGIC AND λ-calculus Andrew R. Plummer Department of Linguistics The Ohio State University 30 Sept., 2009 OUTLINE 1 INTRODUCTION 2 APPLICATIVE SYSTEMS 3 USEFUL INFORMATION COMBINATORY

More information

Domain theory and denotational semantics of functional programming

Domain theory and denotational semantics of functional programming Domain theory and denotational semantics of functional programming Martín Escardó School of Computer Science, Birmingham University MGS 2007, Nottingham, version of April 20, 2007 17:26 What is denotational

More information

The Greek Alphabet. (a) The Untyped λ-calculus

The Greek Alphabet. (a) The Untyped λ-calculus 3. The λ-calculus and Implication Greek Letters (a) The untyped λ-calculus. (b) The typed λ-calculus. (c) The λ-calculus in Agda. (d) Logic with Implication (e) Implicational Logic in Agda. (f) More on

More information

Informal Statement Calculus

Informal Statement Calculus FOUNDATIONS OF MATHEMATICS Branches of Logic 1. Theory of Computations (i.e. Recursion Theory). 2. Proof Theory. 3. Model Theory. 4. Set Theory. Informal Statement Calculus STATEMENTS AND CONNECTIVES Example

More information

Theory of Computation

Theory of Computation Thomas Zeugmann Hokkaido University Laboratory for Algorithmics http://www-alg.ist.hokudai.ac.jp/ thomas/toc/ Lecture 12: Turing Machines Turing Machines I After having dealt with partial recursive functions,

More information

FIXED POINTS AND EXTENSIONALITY IN TYPED FUNCTIONAL PROGRAMMING LANGUAGES

FIXED POINTS AND EXTENSIONALITY IN TYPED FUNCTIONAL PROGRAMMING LANGUAGES FIXED POINTS AND EXTENSIONALITY IN TYPED FUNCTIONAL PROGRAMMING LANGUAGES a dissertation submitted to the department of computer science and the committee on graduate studies of stanford university in

More information

Axiomatic set theory. Chapter Why axiomatic set theory?

Axiomatic set theory. Chapter Why axiomatic set theory? Chapter 1 Axiomatic set theory 1.1 Why axiomatic set theory? Essentially all mathematical theories deal with sets in one way or another. In most cases, however, the use of set theory is limited to its

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

Ackermann s Function

Ackermann s Function Ackermann s Function George Tourlakis February 18, 2008 1 What The Ackermann function was proposed, naturally, by Ackermann. The version here is a simplification offered by Robert Ritchie. What the function

More information

Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012

Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012 1 λ Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 5, 2012 2 reading Femke van Raamsdonk Logical Verification Course Notes Herman Geuvers Introduction to

More information

This is logically equivalent to the conjunction of the positive assertion Minimal Arithmetic and Representability

This is logically equivalent to the conjunction of the positive assertion Minimal Arithmetic and Representability 16.2. MINIMAL ARITHMETIC AND REPRESENTABILITY 207 If T is a consistent theory in the language of arithmetic, we say a set S is defined in T by D(x) if for all n, if n is in S, then D(n) is a theorem of

More information

Programming Language Concepts, CS2104 Lecture 3

Programming Language Concepts, CS2104 Lecture 3 Programming Language Concepts, CS2104 Lecture 3 Statements, Kernel Language, Abstract Machine 31 Aug 2007 CS2104, Lecture 3 1 Reminder of last lecture Programming language definition: syntax, semantics

More information

CS522 - Programming Language Semantics

CS522 - Programming Language Semantics 1 CS522 - Programming Language Semantics Simply Typed Lambda Calculus Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 We now discuss a non-trivial extension of

More information

The integers. Chapter 3

The integers. Chapter 3 Chapter 3 The integers Recall that an abelian group is a set A with a special element 0, and operation + such that x +0=x x + y = y + x x +y + z) =x + y)+z every element x has an inverse x + y =0 We also

More information

summer school Logic and Computation Goettingen, July 24-30, 2016

summer school Logic and Computation Goettingen, July 24-30, 2016 Università degli Studi di Torino summer school Logic and Computation Goettingen, July 24-30, 2016 A bit of history Alonzo Church (1936) The as formal account of computation. Proof of the undecidability

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

Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3.

Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3. Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3. Elena Machkasova Contents 1 Introduction and Related Work 1 1.1 Introduction..............................

More information

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule.

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule. 32 Reduction 29 32 Reduction In the preceding section, we have introduced the assignment of proof terms to natural deductions If proofs are programs then we need to explain how proofs are to be executed,

More information

TYPED LAMBDA CALCULI. Andrzej S. Murawski University of λeicester.

TYPED LAMBDA CALCULI. Andrzej S. Murawski University of λeicester. TYPED LAMBDA CALCULI Andrzej S. Murawski University of λeicester http://www.cs.le.ac.uk/people/amurawski/mgs2011-tlc.pdf THE COURSE The aim of the course is to provide an introduction to the lambda calculus

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

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

Theorem. For every positive integer n, the sum of the positive integers from 1 to n is n(n+1)

Theorem. For every positive integer n, the sum of the positive integers from 1 to n is n(n+1) Week 1: Logic Lecture 1, 8/1 (Sections 1.1 and 1.3) Examples of theorems and proofs Theorem (Pythagoras). Let ABC be a right triangle, with legs of lengths a and b, and hypotenuse of length c. Then a +

More information

Safety Analysis versus Type Inference

Safety Analysis versus Type Inference Information and Computation, 118(1):128 141, 1995. Safety Analysis versus Type Inference Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus

More information

Principles of Program Analysis: Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

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

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

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

The Curry-Howard Isomorphism

The Curry-Howard Isomorphism The Curry-Howard Isomorphism Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) The Curry-Howard Isomorphism MFES 2008/09

More information

Alonzo Church ( ) Lambda Calculus. λ-calculus : syntax. Grammar for terms : Inductive denition for λ-terms

Alonzo Church ( ) Lambda Calculus. λ-calculus : syntax. Grammar for terms : Inductive denition for λ-terms Alonzo Church (1903-1995) Lambda Calculus 2 λ-calculus : syntax Grammar for terms : t, u ::= x (variable) t u (application) λx.t (abstraction) Notation : Application is left-associative so that t 1 t 2...

More information

Theory of Computing Tamás Herendi

Theory of Computing Tamás Herendi Theory of Computing Tamás Herendi Theory of Computing Tamás Herendi Publication date 2014 Table of Contents 1 Preface 1 2 Formal languages 2 3 Order of growth rate 9 4 Turing machines 16 1 The definition

More information

Rewriting, Explicit Substitutions and Normalisation

Rewriting, Explicit Substitutions and Normalisation Rewriting, Explicit Substitutions and Normalisation XXXVI Escola de Verão do MAT Universidade de Brasilia Part 1/3 Eduardo Bonelli LIFIA (Fac. de Informática, UNLP, Arg.) and CONICET eduardo@lifia.info.unlp.edu.ar

More information

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas. 1 Chapter 1 Propositional Logic Mathematical logic studies correct thinking, correct deductions of statements from other statements. Let us make it more precise. A fundamental property of a statement is

More information

Axiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs

Axiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs Review Operational semantics relatively l simple many flavors (small vs. big) not compositional (rule for while) Good for describing language implementation reasoning about properties of the language eg.

More information

Context Free Grammars

Context Free Grammars Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.

More information

The semantics of propositional logic

The semantics of propositional logic The semantics of propositional logic Readings: Sections 1.3 and 1.4 of Huth and Ryan. In this module, we will nail down the formal definition of a logical formula, and describe the semantics of propositional

More information

Chapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011

Chapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Chapter 2 An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Assertions In this chapter, we give a more detailed exposition of the assertions of separation logic: their meaning,

More information

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types

More information

Lazy Strong Normalization

Lazy Strong Normalization Lazy Strong Normalization Luca Paolini 1,2 Dipartimento di Informatica Università di Torino (ITALIA) Elaine Pimentel 1,2 Departamento de Matemática Universidade Federal de Minas Gerais (BRASIL) Dipartimento

More information

CBV and CBN. Eduardo Bonelli. TP para LP 2012C1 1/55

CBV and CBN. Eduardo Bonelli. TP para LP 2012C1 1/55 CBV and CBN Eduardo Bonelli TP para LP 2012C1 1/55 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 2/55 Reduction Strategies Reduction

More information

5 Set Operations, Functions, and Counting

5 Set Operations, Functions, and Counting 5 Set Operations, Functions, and Counting Let N denote the positive integers, N 0 := N {0} be the non-negative integers and Z = N 0 ( N) the positive and negative integers including 0, Q the rational numbers,

More information

Peano Arithmetic. CSC 438F/2404F Notes (S. Cook) Fall, Goals Now

Peano Arithmetic. CSC 438F/2404F Notes (S. Cook) Fall, Goals Now CSC 438F/2404F Notes (S. Cook) Fall, 2008 Peano Arithmetic Goals Now 1) We will introduce a standard set of axioms for the language L A. The theory generated by these axioms is denoted PA and called Peano

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

Automata Theory and Formal Grammars: Lecture 1

Automata Theory and Formal Grammars: Lecture 1 Automata Theory and Formal Grammars: Lecture 1 Sets, Languages, Logic Automata Theory and Formal Grammars: Lecture 1 p.1/72 Sets, Languages, Logic Today Course Overview Administrivia Sets Theory (Review?)

More information

Simply Typed λ-calculus

Simply Typed λ-calculus Simply Typed λ-calculus Lecture 1 Jeremy Dawson The Australian National University Semester 2, 2017 Jeremy Dawson (ANU) COMP4630,Lecture 1 Semester 2, 2017 1 / 23 A Brief History of Type Theory First developed

More information

Mathematical Logic IV

Mathematical Logic IV 1 Introduction Mathematical Logic IV The Lambda Calculus; by H.P. Barendregt(1984) Part One: Chapters 1-5 The λ-calculus (a theory denoted λ) is a type free theory about functions as rules, rather that

More information

Introduction to dependent type theory. CIRM, May 30

Introduction to dependent type theory. CIRM, May 30 CIRM, May 30 Goals of this presentation Some history and motivations Notations used in type theory Main goal: the statement of main properties of equality type and the univalence axiom First talk P ropositions

More information

arxiv: v1 [cs.pl] 19 May 2016

arxiv: v1 [cs.pl] 19 May 2016 arxiv:1605.05858v1 [cs.pl] 19 May 2016 Domain Theory: An Introduction Robert Cartwright Rice University Rebecca Parsons ThoughtWorks, Inc. Moez AbdelGawad SRTA-City Hunan University This monograph is an

More information

Tutorial on Semantics Part I

Tutorial on Semantics Part I Tutorial on Semantics Part I Basic Concepts Prakash Panangaden 1 1 School of Computer Science McGill University on sabbatical leave at Department of Computer Science Oxford University Fields Institute,

More information

MATH 145 LECTURE NOTES. Zhongwei Zhao. My Lecture Notes for MATH Fall

MATH 145 LECTURE NOTES. Zhongwei Zhao. My Lecture Notes for MATH Fall MATH 145 LECTURE NOTES Zhongwei Zhao My Lecture Notes for MATH 145 2016 Fall December 2016 Lecture 1, Sept. 9 Course Orientation and Organization About the Professor Stephen New MC 5419 Ext 35554 Email:

More information

Sets, Structures, Numbers

Sets, Structures, Numbers Chapter 1 Sets, Structures, Numbers Abstract In this chapter we shall introduce most of the background needed to develop the foundations of mathematical analysis. We start with sets and algebraic structures.

More information