Lambda Calculus! Gunnar Gotshalks! LC-1

Size: px
Start display at page:

Download "Lambda Calculus! Gunnar Gotshalks! LC-1"

Transcription

1 Lambda Calculus! LC-1

2 λ 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 to a Turing machine!» Turing machines and λ-calculus are alternate descriptions of our understanding of what is computable! LC-2

3 λ Calculus History 2! In the mid to late 1950 s, John McCarthy developed Lisp!» A programming language based on λ-calculus!» Implementation includes syntactic sugar! > functions and forms that do not add to the power of what we can compute but make programs simpler and easier to understand! LC-3

4 λ Calculus Basis! Mathematical theory for anonymous functions!» functions that have not been bound to names! Present a subset of full definition to present the flavour! Notation and interpretation scheme identifies!» functions and their application to operands! > argument-parameter binding!» Clearly indicates which variables are free and which are bound! LC-4

5 Bound and Free Variables! Bound variables are similar to local variables in Java function (or any procedural language)!» Changing the name of a bound variable (consistently) does not change the semantics (meaning) of a function! Free variables are similar to global variables in Java function (or any procedural language)!» Changing the name of a free variable normally changes the semantics (meaning) of a function.! LC-5

6 Consider following expression!» ( u + 1 ) ( u 1 )!» is u bound or free?! Disambiguate the expression with the following λ-function!» ( λ u. ( u + 1 ) ( u 1 ) )! defining form!» Clearly indicates that u is a bound variable! bound variables! λ functions 1! Note the parallel with programming language functions!» functionname ( arguments ) { function definition }! It seems obvious now but that is because programming languages developed out of these mathematical notions LC-6

7 λ functions 2! Consider the following expression!» ( u + a ) ( u + b )! Can have any of the following functions, depending on what you mean!» ( λ u. ( u + a ) ( u + b ) )! > u is bound, a and b are free (defined in the enclosing context)!» ( λ u b. ( u + a ) ( u + b ) )! > u and b are bound, a is free!» ( λ u a b. ( u + a ) ( u + b ) )! > u, a and b are all bound, no free variables in the expression! LC-7

8 Function application! Functions are applied to arguments in a list immediately following the l-function!» { λ u. ( u + 1 ) ( u + 2 ) } [ 3 ]! > 3 ==> u then ==> (3 + 1) (3 + 2) ==> 20!» { λ u. ( u + a ) ( u + b ) } [ 7 1 ]! > 7 1 ==> u then ==> ( 6 + a ) ( 6 + b ) and no further in this context!» {λ u v. ( u v ) ( u + v ) } [ 2p + q, 2p - q ]! > ==> ( (2p+q) (2p - q) ) ( (2p + q) + (2p q) )! > Can pass expressions to a variable! Can use different bracketing symbols for visual clarity; they all mean the same thing.! LC-8

9 Using auxiliary definitions! Build up longer definitions with auxiliary definitions!» Define u / ( u + 5 )!where u = a ( a + 1 )! where a = 7 3! { λ u. u / ( u + 5 ) } [ { λ a. a ( a + 1 ) } [ 7 3 ] ]! > Note the nested function definition and argument application! ==> { λ u. u / ( u + 5 ) } [ 4 ( ) ]! ==> { 20 / ( ) }! ==> 0.8! LC-9

10 Functions are Variables! Define f ( 3 ) + f ( 5 ) where f ( x ) = a x ( a + x ) where a = 4! { λ f. f (3) + f (5) } [ { λ a. { λ x. a x ( a + x ) } } [ 4 ] ]! Arguments must be evaluated first! ==> { λ f. f (3) + f (5) } [ { λ x. 4 x ( 4 + x ) } ]! ==> { λ x. 4 x (4 + x ) } (3) + { λ x. 4 x (4 + x ) } (5)! ==> 4 * 3 ( ) + 4 * 5 ( ) ==> 264! LC-10

11 Lamba notation in Lisp! Lambda expressions are a direct analogue of λ-calculus expressions!» They are the basis of Lisp functions a modified syntax to simplify the interpreter! For example! ( defun double ( x ) ( + x x ) )! > is the named version of the following unnamed lambda expression! ( lambda ( x ) ( + x x ) ) { λ x. ( x + x ) }! > Note the similar syntax with λ-calculus and the change to prefix, from infix, to permit a uniform syntax for functions of any number of arguments! LC-11

12 Anonymous functions! Recall in the abstraction for sumint we defined support functions to handle each case! (defun double (int) (+ int int))! (defun square (int) (* int int))! (defun identity (int) int)! This adds additional symbols we may not want, especially if the function is to be used only once.! Using lambda we get the same effect without adding symbols! (sumint # (lambda (int) (+ int int)) 10)! (sumint # (lambda (int) (* int int)) 10)! (sumint # (lambda (int) int) 10)! LC-12

13 The function function! What is the meaning of # in the following! (sumint # (lambda (int) (+ int int)) 10)! It is a short hand!» # (...) ==> (function (...))! One of its attributes is it works like quote, in that its argument is not evaluated, thus, in this simple context the following will also work! (sumint (lambda (int) (+ int int)) 10)! Later we will see another attribute of function that makes it different from quote.! Whenever a function is to be quoted use # in place of! LC-13

14 Recursion! Recursion with lambda functions uses labels to temporarily name a function! The following is a general λ-calculus template.! > The name is in scope within the entire body but is out of scope outside of the lambda expression.! { label name ( lambda arguments. body_references_name ) }! In Lisp can use labels to define a mutually recursive set of functions! ( labels (list of named lambda expressions) sequence of forms using the temporarily named functions )! LC-14

15 Example 1 of recursion! A recursive multiply that uses only addition.! > The temporary function is called mult! > Use quote not function using eval! (eval '(labels! ((mult (k n)! (cond ((zerop n) 0)! (t (+ k (mult k (1- n))))! )))! (mult 2 3)! )! )! LC-15

16 Example 2 of recursion! rectimes computes k * n by supplying the paramters to a unary function that is a variation of example 1.! (defun rectimes (k n)! (labels (( temp (n)! (cond ((zerop n) 0)! ( t (+ k (temp (1- n))))! )))! (temp n)! ))! LC-16

17 Churchʼs Lambda Calculus! The preceding description is not exactly what Church developed! He worked with one parameter! Result of a function is a function!» In lambda calculus numbers are functions! LC-17

18 Function notation! Do not need parenthesis for one argument functions.!» f ( x ) = f x!» g ( f ( x ) ) = g (f x)! > Cannot have g f x as that could mean (g f) x! > Could have g f x! LC-18

19 Function notation 2! For multiple argument functions convert to single argument functions!» f ( x, y ) = ( f x ) y! > (f x) returns a one parameter function that is applied to y!» f ( x, y, z ) = ( ( f x ) y ) z!»! LC-19

20 Function definition examples! Use λ to denote the parameters of a function!» { λ u. u * v + 2*a }!» { λ u v. u * v + 2*a } = { λ u. [ λ v. u * v + 2*a ] }! > Can see how multiple parameters are equivalent to nested one parameter functions! > At this level of definition, we simplify!» { λ v a. u * v + 2*a }!» { λ u v a. u * v + 2*a }!» { λ x. f x }!!! LC-20

21 Function application! Consider the following!» g = { λ x. (1 / 6) x^3 }!» g 3 = (1 / 6) 3^3 = 9 / 6!» g (a + 1) = (1 / 6) (a + 1)^3 = (1 / 6) a^3 + (1 / 2) a ^ 2 + (1 / 2) a + (1 / 6)! LC-21

22 Function application 2! Functions can be parameters!» { λ f. f x } g f g = g x! Can abstract out the x!» { λ f. [ λ x. f x ] } g = { λ f x. f x } g!simplify = { λ x. g x }! Apply the function!» { λ x. g x } a = g a! As a consequence g = { λ x. g x }!! LC-22

23 Function application 3! A more complex example!» { λ f x. f (f x) } g = { λ x. g (g x) } = g (g x)! Church associated this function with the number 2! > Numbers are functions!» 2 = { λ f x. f (f x) }!» 2 g = g (g x)!g applied twice LC-23

24 Definition of Natural Numbers! The following shows how the natural numbers can be defined!» 0 = { λ f x. x }!» 1 = { λ f x. f x }!» 2 = { λ f x. f (f x) }!» 3 = { λ f x. f (f (f x)) }!» 4 = { λ f x. f (f (f (f x))) }!»! LC-24

25 Add 1 to a number! Define add_1 as follows!» add_1 = { λ a b c. b ( (a b) c ) }! Apply add_1 to the number (i.e. function)!!3 = { λ f x. f (f (f x) ) }!» add_1 3 = { λ b c. b ( (3 b) c ) } = { λ b c. b ( { λ x. b (b (b x) ) } c ) } = { λ b c. b ( b (b (b c) ) ) } = 4! LC-25

26 Multiply a number by two! Define mult_2 as follows!» mult_2 = { λ a b c. (a b) ( (a b) c ) }! Apply multi_2 to the number (i.e. function)!!3 = { λ f x. f (f (f x) ) }!» mult_2 3 = { λ b c. (3 b) ( (3 b) c ) } = { λ b c. (3 b) ({ λ x. b (b (b x) ) } c ) } = { λ b c. (3 b) ( b (b (b c) ) ) } = { λ b c. { λ x. b (b (b x) ) } ( b (b (b c) ) ) } = { λ b c. b (b (b (b (b (b c) ) ) ) ) } = 6! LC-26

27 Basic arithmetic operator definitions! Addition operator p + q!» add = { λ p q x y. ( (p x) (q x) ) y ) }! > Exercise show that (add 2) 3 = = 5 Multiplication operator p q!» mult = { λ p q x. p (q x) }! > Exercise show that (mult 2) 3 = 2 3 = 6! Power operator p q!» pow = { λ p q. p q }! LC-27

28 (pow 2) 3 = 9!» (pow 2) 3 = ({ λ p q. p q } 2) 3 = { λ q. 2 q } 3 = { λ q. { λ f x. f (f x) } g } 3 = { λ q x. q (q x) } 3 = { λ x. 3 (3 x) } = { λ x. { λ f y. f (f (f y) ) } (3 x) } = { λ x. { λ y. (3 x) ((3 x) ((3 x) y) ) } } = { λ x y. (3 x) ((3 x) (x (x (x y) ) ) ) } } = { λ x y. (3 x) (x ( x (x (x (x (x y) ) ) ) ) ) } = { λ x y. x (x (x (x ( x (x (x (x (x y) ) ) ) ) ) ) ) } = 9 = 3 2 LC-28

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

Meta-Circularity, and Vice-Versa

Meta-Circularity, and Vice-Versa 1/60, and Vice-Versa didier@lrde.epita.fr http://www.lrde.epita.fr/ didier ACCU 2011 Thursday, April 14th 2/60 Table of contents 1 2 Symbolic Expressions 3 The of LISP 4 5 6 7 8 Dynamic 9 4/60 circularity

More information

Introduction to Turing Machines

Introduction to Turing Machines Introduction to Turing Machines Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 12 November 2015 Outline 1 Turing Machines 2 Formal definitions 3 Computability

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

Recursion - 1. Recursion. Recursion - 2. A Simple Recursive Example

Recursion - 1. Recursion. Recursion - 2. A Simple Recursive Example Recursion - 1 Only looping method in pure Lisp is recursion Recursion Based on Chapter 6 of Wilensky Recursive function f includes calls to f in its definition For a recursive function to eventually terminate

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

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

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

Theory of Computation

Theory of Computation Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation / Lecture 3: Overview Decidability of Logical Theories Presburger arithmetic Decidability of Presburger Arithmetic Dr.

More information

Propositional logic (revision) & semantic entailment. p. 1/34

Propositional logic (revision) & semantic entailment. p. 1/34 Propositional logic (revision) & semantic entailment p. 1/34 Reading The background reading for propositional logic is Chapter 1 of Huth/Ryan. (This will cover approximately the first three lectures.)

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

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 28, 2003 These supplementary notes review the notion of an inductive definition and give

More information

Supplementary Notes on Inductive Definitions

Supplementary Notes on Inductive Definitions Supplementary Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 29, 2002 These supplementary notes review the notion of an inductive definition

More information

Lectures on The Lambda Calculus (I)

Lectures on The Lambda Calculus (I) Lectures on The Lambda Calculus (I) Masahiko Sato Graduate School of Informatics, Kyoto University Autumn school Proof and Computation Fischbachau, Germany October 4, 2016 Overview In these lectures, I

More information

Lecture 12. Statement Logic as a word algebra on the set of atomic statements. Lindenbaum algebra.

Lecture 12. Statement Logic as a word algebra on the set of atomic statements. Lindenbaum algebra. V. Borschev and B. Partee, October 26, 2006 p. 1 Lecture 12. Statement Logic as a word algebra on the set of atomic statements. Lindenbaum algebra. 0. Preliminary notes...1 1. Freedom for algebras. Word

More information

Logic for Computer Science - Week 2 The Syntax of Propositional Logic

Logic for Computer Science - Week 2 The Syntax of Propositional Logic Logic for Computer Science - Week 2 The Syntax of Propositional Logic Ștefan Ciobâcă November 30, 2017 1 An Introduction to Logical Formulae In the previous lecture, we have seen what makes an argument

More information

Functional Programming with F# Overview and Basic Concepts

Functional Programming with F# Overview and Basic Concepts Functional Programming with F# Overview and Basic Concepts Radu Nicolescu Department of Computer Science University of Auckland 27 Sep 2017 1 / 52 1 Background 2 Overview 3 Type System and Type Inference

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

Bootstrapping Mathematics

Bootstrapping Mathematics Bootstrapping Mathematics Masahiko Sato Graduate School of Informatics, Kyoto University Mathematical Logic: Development and Evolution into Various Sciences Kanazawa, Japan March 9, 2012 Contents What

More information

MA5219 LOGIC AND FOUNDATION OF MATHEMATICS I. Lecture 1: Programs. Tin Lok Wong 13 August, 2018

MA5219 LOGIC AND FOUNDATION OF MATHEMATICS I. Lecture 1: Programs. Tin Lok Wong 13 August, 2018 MA5219 LOGIC AND FOUNDATION OF MATHEMATICS I Lecture 1: Programs Tin Lok Wong 13 August, 2018 The aim of this lecture is to characterize S N : some algorithm can tell whether n N belongs to S}. By an algorithm

More information

Meta-programming & you

Meta-programming & you Meta-programming & you Robin Message Cambridge Programming Research Group 10 th May 2010 What s meta-programming about? 1 result=somedb. customers. select 2 { first_name+ +last_name } 3 where name LIKE

More information

Math Boot Camp Functions and Algebra

Math Boot Camp Functions and Algebra Fall 017 Math Boot Camp Functions and Algebra FUNCTIONS Much of mathematics relies on functions, the pairing (relation) of one object (typically a real number) with another object (typically a real number).

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

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

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 September 2, 2004 These supplementary notes review the notion of an inductive definition and

More information

A Stochastic l-calculus

A Stochastic l-calculus A Stochastic l-calculus Content Areas: probabilistic reasoning, knowledge representation, causality Tracking Number: 775 Abstract There is an increasing interest within the research community in the design

More information

An Arithmetic Sequence can be defined recursively as. a 1 is the first term and d is the common difference where a 1 and d are real numbers.

An Arithmetic Sequence can be defined recursively as. a 1 is the first term and d is the common difference where a 1 and d are real numbers. Section 12 2A: Arithmetic Sequences An arithmetic sequence is a sequence that has a constant ( labeled d ) added to the first term to get the second term and that same constant is then added to the second

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

Departamento de Matematicas. Real Instituto de Jovellanos. J. F. Antona Algebraic notation and Polynomials 1

Departamento de Matematicas. Real Instituto de Jovellanos. J. F. Antona Algebraic notation and Polynomials 1 Departamento de Matematicas. Real Instituto de Jovellanos. J. F. Antona Algebraic notation and Polynomials 1 Algebraic Notation The ability to convert worded sentences and problems into algebraic symbols

More information

cis32-ai lecture # 18 mon-3-apr-2006

cis32-ai lecture # 18 mon-3-apr-2006 cis32-ai lecture # 18 mon-3-apr-2006 today s topics: propositional logic cis32-spring2006-sklar-lec18 1 Introduction Weak (search-based) problem-solving does not scale to real problems. To succeed, problem

More information

Part 2: First-Order Logic

Part 2: First-Order Logic Part 2: First-Order Logic First-order logic formalizes fundamental mathematical concepts is expressive (Turing-complete) is not too expressive (e. g. not axiomatizable: natural numbers, uncountable sets)

More information

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation (IX) Yijia Chen Fudan University Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and

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

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

About the relationship between formal logic and complexity classes

About the relationship between formal logic and complexity classes About the relationship between formal logic and complexity classes Working paper Comments welcome; my email: armandobcm@yahoo.com Armando B. Matos October 20, 2013 1 Introduction We analyze a particular

More information

COMP 3161/9161 Week 2

COMP 3161/9161 Week 2 Concepts of Programming Languages Judgements, Inference Rules & Proofs Lecturer: Gabriele Keller Tutor: Liam O Connor University of New South Wales School of Computer Sciences & Engineering Sydney, Australia

More information

Propositional Logic: Syntax

Propositional Logic: Syntax Logic Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and programs) epistemic

More information

Communication and Concurrency: CCS

Communication and Concurrency: CCS Communication and Concurrency: CCS R. Milner, A Calculus of Communicating Systems, 1980 cours SSDE Master 1 Why calculi? Prove properties on programs and languages Principle: tiny syntax, small semantics,

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

Communication and Concurrency: CCS. R. Milner, A Calculus of Communicating Systems, 1980

Communication and Concurrency: CCS. R. Milner, A Calculus of Communicating Systems, 1980 Communication and Concurrency: CCS R. Milner, A Calculus of Communicating Systems, 1980 Why calculi? Prove properties on programs and languages Principle: tiny syntax, small semantics, to be handled on

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

Classical First-Order Logic

Classical First-Order Logic Classical First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2009/2010 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10

More information

Compiling Techniques

Compiling Techniques Lecture 7: Abstract Syntax 13 October 2015 Table of contents Syntax Tree 1 Syntax Tree Semantic Actions Examples Abstract Grammar 2 Internal Representation AST Builder 3 Visitor Processing Semantic Actions

More information

Course Runtime Verification

Course Runtime Verification Course Martin Leucker (ISP) Volker Stolz (Høgskolen i Bergen, NO) INF5140 / V17 Chapters of the Course Chapter 1 Recall in More Depth Chapter 2 Specification Languages on Words Chapter 3 LTL on Finite

More information

20.1 Detecting the Need for Structural Induction

20.1 Detecting the Need for Structural Induction 183 Appendix 20: Structural Induction The relation r defined in the previous lecture is a function, but how could we prove it? Here s a semi-formal argument: The relation r is defined by a pair of constraints.

More information

11.1 Vectors in the plane

11.1 Vectors in the plane 11.1 Vectors in the plane What is a vector? It is an object having direction and length. Geometric way to represent vectors It is represented by an arrow. The direction of the arrow is the direction of

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

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic The Importance of Being Formal Martin Henz February 5, 2014 Propositional Logic 1 Motivation In traditional logic, terms represent sets, and therefore, propositions are limited to stating facts on sets

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

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

Church s undecidability result

Church s undecidability result Church s undecidability result Alan Turing Birth Centennial Talk at IIT Bombay, Mumbai Joachim Breitner April 21, 2011 Welcome, and thank you for the invitation to speak about Church s lambda calculus

More information

Logic. Propositional Logic: Syntax. Wffs

Logic. Propositional Logic: Syntax. Wffs Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about

More information

Introduction to Turing Machines. Reading: Chapters 8 & 9

Introduction to Turing Machines. Reading: Chapters 8 & 9 Introduction to Turing Machines Reading: Chapters 8 & 9 1 Turing Machines (TM) Generalize the class of CFLs: Recursively Enumerable Languages Recursive Languages Context-Free Languages Regular Languages

More information

2 Results I: Lifting Computer Science

2 Results I: Lifting Computer Science Ben Greenman December 12, 2015 Call-By-Name, Call-By-Value, and the λ Calculus Abstract Plotkin s 1975 paper is strictly business. There are many theorems packed in the space of 35 pages, with little room

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

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

CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC

CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC 1 Motivation and History The origins of the classical propositional logic, classical propositional calculus, as it was, and still often is called,

More information

Notes on Inductive Sets and Induction

Notes on Inductive Sets and Induction Notes on Inductive Sets and Induction Finite Automata Theory and Formal Languages TMV027/DIT21 Ana Bove, March 15th 2018 Contents 1 Induction over the Natural Numbers 2 1.1 Mathematical (Simple) Induction........................

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

Notes. Corneliu Popeea. May 3, 2013

Notes. Corneliu Popeea. May 3, 2013 Notes Corneliu Popeea May 3, 2013 1 Propositional logic Syntax We rely on a set of atomic propositions, AP, containing atoms like p, q. A propositional logic formula φ Formula is then defined by the following

More information

(p == train arrives late) (q == there are taxis) (r == If p and not q, then r. Not r. p. Therefore, q. Propositional Logic

(p == train arrives late) (q == there are taxis) (r == If p and not q, then r. Not r. p. Therefore, q. Propositional Logic Propositional Logic The aim of logic in computer science is to develop languages to model the situations we encounter as computer science professionals Want to do that in such a way that we can reason

More information

Propositional and Predicate Logic. jean/gbooks/logic.html

Propositional and Predicate Logic.   jean/gbooks/logic.html CMSC 630 February 10, 2009 1 Propositional and Predicate Logic Sources J. Gallier. Logic for Computer Science, John Wiley and Sons, Hoboken NJ, 1986. 2003 revised edition available on line at http://www.cis.upenn.edu/

More information

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88 Lisp Introduction Dr. Neil T. Dantam CSCI-498/598 RPM, Colorado School of Mines Spring 28 Dantam (Mines CSCI, RPM) Lisp Spring 28 / 88 Outline Lisp Common Lisp by Example Implementation Details Typing

More information

Explicit Logics of Knowledge and Conservativity

Explicit Logics of Knowledge and Conservativity Explicit Logics of Knowledge and Conservativity Melvin Fitting Lehman College, CUNY, 250 Bedford Park Boulevard West, Bronx, NY 10468-1589 CUNY Graduate Center, 365 Fifth Avenue, New York, NY 10016 Dedicated

More information

6.001 Recitation 22: Streams

6.001 Recitation 22: Streams 6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris

More information

Lecture 13: Turing Machine

Lecture 13: Turing Machine Lecture 13: Turing Machine Instructor: Ketan Mulmuley Scriber: Yuan Li February 19, 2015 Turing machine is an abstract machine which in principle can simulate any computation in nature. Church-Turing Thesis:

More information

Topic 17. Analysis of Algorithms

Topic 17. Analysis of Algorithms Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm

More information

Propositional Logic and Semantics

Propositional Logic and Semantics Propositional Logic and Semantics English is naturally ambiguous. For example, consider the following employee (non)recommendations and their ambiguity in the English language: I can assure you that no

More information

On the Semantics of Parsing Actions

On the Semantics of Parsing Actions On the Semantics of Parsing Actions Hayo Thielecke School of Computer Science University of Birmingham Birmingham B15 2TT, United Kingdom Abstract Parsers, whether constructed by hand or automatically

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

Propositions as Types

Propositions as Types Propositions as Types Martin Pfeifhofer & Felix Schett May 25, 2016 Contents 1 Introduction 2 2 Content 3 2.1 Getting Started............................ 3 2.2 Effective Computability And The Various Definitions.......

More information

02 The Axiomatic Method

02 The Axiomatic Method CAS 734 Winter 2005 02 The Axiomatic Method Instructor: W. M. Farmer Revised: 11 January 2005 1 What is Mathematics? The essence of mathematics is a process consisting of three intertwined activities:

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

Classical First-Order Logic

Classical First-Order Logic Classical 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) First-Order Logic (Classical) MFES 2008/09

More information

SEMANTICS OF PROGRAMMING LANGUAGES Course Notes MC 308

SEMANTICS OF PROGRAMMING LANGUAGES Course Notes MC 308 University of Leicester SEMANTICS OF PROGRAMMING LANGUAGES Course Notes for MC 308 Dr. R. L. Crole Department of Mathematics and Computer Science Preface These notes are to accompany the module MC 308.

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

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

Predicate Calculus - Syntax

Predicate Calculus - Syntax Predicate Calculus - Syntax Lila Kari University of Waterloo Predicate Calculus - Syntax CS245, Logic and Computation 1 / 26 The language L pred of Predicate Calculus - Syntax L pred, the formal language

More information

Propositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54

Propositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54 Propositional Logic CS 3234: Logic and Formal Systems Martin Henz and Aquinas Hobor August 26, 2010 Generated on Tuesday 31 August, 2010, 16:54 1 Motivation In traditional logic, terms represent sets,

More information

Relational Algebra and Calculus

Relational Algebra and Calculus Topics Relational Algebra and Calculus Linda Wu Formal query languages Preliminaries Relational algebra Relational calculus Expressive power of algebra and calculus (CMPT 354 2004-2) Chapter 4 CMPT 354

More information

Due Date: Thursday, September 13th, 11:59PM (no late days), worth 60 points

Due Date: Thursday, September 13th, 11:59PM (no late days), worth 60 points Assignment 1: Introduction to Hybrid Programs 15-424/15-624/15-824 Logical Foundations of Cyber-Physical Systems TAs: Irene Li (mengzeli@andrew.cmu.edu) Yong Kiam Tan (yongkiat@cs.cmu.edu) Due Date: Thursday,

More information

Information Flow Inference for ML

Information Flow Inference for ML Information Flow Inference for ML Vincent Simonet INRIA Rocquencourt Projet Cristal MIMOSA September 27, 2001 Information flow account number bank applet order vendor account H order L bank H vendor L

More information

A Thread Algebra with Multi-level Strategic Interleaving

A Thread Algebra with Multi-level Strategic Interleaving Theory of Computing Systems manuscript No. (will be inserted by the editor) A Thread Algebra with Multi-level Strategic Interleaving J.A. Bergstra 1,2, C.A. Middelburg 3,1 1 Programming Research Group,

More information

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem Valentine Kabanets October 27, 2016 1 Gödel s Second Incompleteness Theorem 1.1 Consistency We say that a proof system P is consistent

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

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

Designing 1-tape Deterministic Turing Machines

Designing 1-tape Deterministic Turing Machines MCS-265: The Theory of Computation Handout #T1 San Skulrattanakulchai Gustavus Adolphus College April 5, 2011 Designing 1-tape Deterministic Turing Machines A TM corresponds to a computer program. We will

More information

CS156: The Calculus of Computation

CS156: The Calculus of Computation CS156: The Calculus of Computation Zohar Manna Winter 2010 It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

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

Theoretical Computer Science

Theoretical Computer Science Theoretical Computer Science Zdeněk Sawa Department of Computer Science, FEI, Technical University of Ostrava 17. listopadu 15, Ostrava-Poruba 708 33 Czech republic September 22, 2017 Z. Sawa (TU Ostrava)

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

Structure. Background. them to their higher order equivalents. functionals in Standard ML source code and converts

Structure. Background. them to their higher order equivalents. functionals in Standard ML source code and converts Introduction 3 Background functionals factor out common behaviour map applies a function to every element of a list fun map [ ] = [ ] map f ( x : : xs ) = f x : : map f xs filter keeps only those elements

More information

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula: Logic: The Big Picture Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and

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

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

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

Operationally-Based Theories of Program Equivalence

Operationally-Based Theories of Program Equivalence Operationally-Based Theories of Program Equivalence Andrew Pitts Contents 1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : 241 2 Contextual Equivalence : : : : : : : : : : : : : :

More information