COMP2111 Week 5 Term 1, 2020 Lambda Calculus 1 -calculus Alonzo - - PowerPoint PPT Presentation

comp2111 week 5 term 1 2020 lambda calculus
SMART_READER_LITE
LIVE PREVIEW

COMP2111 Week 5 Term 1, 2020 Lambda Calculus 1 -calculus Alonzo - - PowerPoint PPT Presentation

COMP2111 Week 5 Term 1, 2020 Lambda Calculus 1 -calculus Alonzo Church lived 19031995 supervised people like Alan Turing, Stephen Kleene famous for Church-Turing thesis, lambda calculus, first undecidability results invented


slide-1
SLIDE 1

COMP2111 Week 5 Term 1, 2020 Lambda Calculus

1

slide-2
SLIDE 2

λ-calculus

Alonzo Church lived 1903–1995 supervised people like Alan Turing, Stephen Kleene famous for Church-Turing thesis, lambda calculus, first undecidability results invented λ calculus in 1930’s

2

slide-3
SLIDE 3

λ-calculus

Alonzo Church lived 1903–1995 supervised people like Alan Turing, Stephen Kleene famous for Church-Turing thesis, lambda calculus, first undecidability results invented λ calculus in 1930’s λ-calculus

  • riginally meant as foundation of mathematics

important applications in theoretical computer science foundation of computability and functional programming

3

slide-4
SLIDE 4

untyped λ-calculus

Turing complete model of computation a simple way of writing down functions λx. x + 5 a term a nameless function that adds 5 to its parameter

4

slide-5
SLIDE 5

untyped λ-calculus

Turing complete model of computation a simple way of writing down functions Basic intuition: instead of f (x) = x + 5 write f = λx. x + 5 λx. x + 5 a term a nameless function that adds 5 to its parameter

5

slide-6
SLIDE 6

untyped λ-calculus

Turing complete model of computation a simple way of writing down functions Basic intuition: instead of f (x) = x + 5 write f = λx. x + 5 λx. x + 5 a term a nameless function that adds 5 to its parameter

6

slide-7
SLIDE 7

untyped λ-calculus

Turing complete model of computation a simple way of writing down functions Basic intuition: instead of f (x) = x + 5 write f = λx. x + 5 λx. x + 5 a term a nameless function that adds 5 to its parameter

7

slide-8
SLIDE 8

untyped λ-calculus

Turing complete model of computation a simple way of writing down functions Basic intuition: instead of f (x) = x + 5 write f = λx. x + 5 λx. x + 5 a term a nameless function that adds 5 to its parameter

8

slide-9
SLIDE 9

Function Application

For applying arguments to functions instead of f (a) write f a Evaluating: in (λx. t) a replace x by a in t (computation!) Example: (λx. x + 5) (a + b) evaluates to (a + b) + 5

9

slide-10
SLIDE 10

Function Application

For applying arguments to functions instead of f (a) write f a Example: (λx. x + 5) a Evaluating: in (λx. t) a replace x by a in t (computation!) Example: (λx. x + 5) (a + b) evaluates to (a + b) + 5

10

slide-11
SLIDE 11

Function Application

For applying arguments to functions instead of f (a) write f a Example: (λx. x + 5) a Evaluating: in (λx. t) a replace x by a in t (computation!) Example: (λx. x + 5) (a + b) evaluates to (a + b) + 5

11

slide-12
SLIDE 12

Function Application

For applying arguments to functions instead of f (a) write f a Example: (λx. x + 5) a Evaluating: in (λx. t) a replace x by a in t (computation!) Example: (λx. x + 5) (a + b) evaluates to (a + b) + 5

12

slide-13
SLIDE 13

That’s it! Now Formally

13

slide-14
SLIDE 14

That’s it! Now Formally

14

slide-15
SLIDE 15

Syntax

Terms:

t ::= v | c | (t t) | (λx. t)

v, x ∈ V , c ∈ C, V , C sets of names

15

slide-16
SLIDE 16

Syntax

Terms:

t ::= v | c | (t t) | (λx. t)

v, x ∈ V , c ∈ C, V , C sets of names v, x variables c constants (t t) application (λx. t) abstraction

16

slide-17
SLIDE 17

Conventions

leave out parentheses where possible list variables instead of multiple λ Example: instead of (λy. (λx. (x y))) write λy x. x y

17

slide-18
SLIDE 18

Conventions

leave out parentheses where possible list variables instead of multiple λ Example: instead of (λy. (λx. (x y))) write λy x. x y Rules: list variables: λx. (λy. t) = λx y. t application binds to the left: x y z = (x y) z = x (y z) abstraction binds to the right: λx. x y = λx. (x y) = (λx. x) y leave out outermost parentheses

18

slide-19
SLIDE 19

Getting used to the Syntax

Example: λx y z. x z (y z) = λx y z. (x z) (y z) = λx y z. ((x z) (y z)) = λx. λy. λz. ((x z) (y z)) = (λx. (λy. (λz. ((x z) (y z)))))

19

slide-20
SLIDE 20

Getting used to the Syntax

Example: λx y z. x z (y z) = λx y z. (x z) (y z) = λx y z. ((x z) (y z)) = λx. λy. λz. ((x z) (y z)) = (λx. (λy. (λz. ((x z) (y z)))))

20

slide-21
SLIDE 21

Getting used to the Syntax

Example: λx y z. x z (y z) = λx y z. (x z) (y z) = λx y z. ((x z) (y z)) = λx. λy. λz. ((x z) (y z)) = (λx. (λy. (λz. ((x z) (y z)))))

21

slide-22
SLIDE 22

Getting used to the Syntax

Example: λx y z. x z (y z) = λx y z. (x z) (y z) = λx y z. ((x z) (y z)) = λx. λy. λz. ((x z) (y z)) = (λx. (λy. (λz. ((x z) (y z)))))

22

slide-23
SLIDE 23

Getting used to the Syntax

Example: λx y z. x z (y z) = λx y z. (x z) (y z) = λx y z. ((x z) (y z)) = λx. λy. λz. ((x z) (y z)) = (λx. (λy. (λz. ((x z) (y z)))))

23

slide-24
SLIDE 24

Computation

Intuition: replace parameter by argument this is called β-reduction Example (λx y. f (y x)) 5 (λx. x) − →β (λy. f (y 5)) (λx. x) − →β f ((λx. x) 5) − →β f 5

24

slide-25
SLIDE 25

Computation

Intuition: replace parameter by argument this is called β-reduction Example (λx y. f (y x)) 5 (λx. x) − →β (λy. f (y 5)) (λx. x) − →β f ((λx. x) 5) − →β f 5

25

slide-26
SLIDE 26

Computation

Intuition: replace parameter by argument this is called β-reduction Example (λx y. f (y x)) 5 (λx. x) − →β (λy. f (y 5)) (λx. x) − →β f ((λx. x) 5) − →β f 5

26

slide-27
SLIDE 27

Computation

Intuition: replace parameter by argument this is called β-reduction Example (λx y. f (y x)) 5 (λx. x) − →β (λy. f (y 5)) (λx. x) − →β f ((λx. x) 5) − →β f 5

27

slide-28
SLIDE 28

Defining Computation β reduction:

(λx. s) t − →β s[x ← t] s − →β s′ = ⇒ (s t) − →β (s′ t) t − →β t′ = ⇒ (s t) − →β (s t′) s − →β s′ = ⇒ (λx. s) − →β (λx. s′)

28

slide-29
SLIDE 29

Defining Computation β reduction:

(λx. s) t − →β s[x ← t] s − →β s′ = ⇒ (s t) − →β (s′ t) t − →β t′ = ⇒ (s t) − →β (s t′) s − →β s′ = ⇒ (λx. s) − →β (λx. s′) Still to do: define s[x ← t]

29

slide-30
SLIDE 30

Defining Substitution

Easy concept. Small problem: variable capture. Example: (λx. x z)[z ← x] We do not want: (λx. x x) as result. What do we want? In (λy. y z) [z ← x] = (λy. y x) there would be no problem. So, solution is: rename bound variables.

30

slide-31
SLIDE 31

Defining Substitution

Easy concept. Small problem: variable capture. Example: (λx. x z)[z ← x] We do not want: (λx. x x) as result. What do we want? In (λy. y z) [z ← x] = (λy. y x) there would be no problem. So, solution is: rename bound variables.

31

slide-32
SLIDE 32

Defining Substitution

Easy concept. Small problem: variable capture. Example: (λx. x z)[z ← x] We do not want: (λx. x x) as result. What do we want? In (λy. y z) [z ← x] = (λy. y x) there would be no problem. So, solution is: rename bound variables.

32

slide-33
SLIDE 33

Free Variables

Bound variables: in (λx. t), x is a bound variable. Free variables FV of a term: FV (x) = {x} FV (c) = {} FV (s t) = FV (s) ∪ FV (t) FV (λx. t) = FV (t) \ {x} Example: FV ( λx. (λy. (λx. x) y) y x ) = {y} Term t is called closed if FV (t) = {} The substitution example, (λx. x z)[z ← x], is problematic because the bound variable x is a free variable of the replacement term “x”.

33

slide-34
SLIDE 34

Free Variables

Bound variables: in (λx. t), x is a bound variable. Free variables FV of a term: FV (x) = {x} FV (c) = {} FV (s t) = FV (s) ∪ FV (t) FV (λx. t) = FV (t) \ {x} Example: FV ( λx. (λy. (λx. x) y) y x ) = {y} Term t is called closed if FV (t) = {} The substitution example, (λx. x z)[z ← x], is problematic because the bound variable x is a free variable of the replacement term “x”.

34

slide-35
SLIDE 35

Free Variables

Bound variables: in (λx. t), x is a bound variable. Free variables FV of a term: FV (x) = {x} FV (c) = {} FV (s t) = FV (s) ∪ FV (t) FV (λx. t) = FV (t) \ {x} Example: FV ( λx. (λy. (λx. x) y) y x ) = {y} Term t is called closed if FV (t) = {} The substitution example, (λx. x z)[z ← x], is problematic because the bound variable x is a free variable of the replacement term “x”.

35

slide-36
SLIDE 36

Free Variables

Bound variables: in (λx. t), x is a bound variable. Free variables FV of a term: FV (x) = {x} FV (c) = {} FV (s t) = FV (s) ∪ FV (t) FV (λx. t) = FV (t) \ {x} Example: FV ( λx. (λy. (λx. x) y) y x ) = {y} Term t is called closed if FV (t) = {} The substitution example, (λx. x z)[z ← x], is problematic because the bound variable x is a free variable of the replacement term “x”.

36

slide-37
SLIDE 37

Free Variables

Bound variables: in (λx. t), x is a bound variable. Free variables FV of a term: FV (x) = {x} FV (c) = {} FV (s t) = FV (s) ∪ FV (t) FV (λx. t) = FV (t) \ {x} Example: FV ( λx. (λy. (λx. x) y) y x ) = {y} Term t is called closed if FV (t) = {} The substitution example, (λx. x z)[z ← x], is problematic because the bound variable x is a free variable of the replacement term “x”.

37

slide-38
SLIDE 38

Substitution

x [x ← t] = t y [x ← t] = y if x = y c [x ← t] = c (s1 s2) [x ← t] = (s1[x ← t] s2[x ← t]) (λx. s) [x ← t] = (λx. s) (λy. s) [x ← t] = (λy. s[x ← t]) if x = y and y / ∈ FV (t) (λy. s) [x ← t] = (λz. s[y ← z][x ← t]) if x = y and z / ∈ FV (t) ∪ FV (s)

38

slide-39
SLIDE 39

Substitution

x [x ← t] = t y [x ← t] = y if x = y c [x ← t] = c (s1 s2) [x ← t] = (s1[x ← t] s2[x ← t]) (λx. s) [x ← t] = (λx. s) (λy. s) [x ← t] = (λy. s[x ← t]) if x = y and y / ∈ FV (t) (λy. s) [x ← t] = (λz. s[y ← z][x ← t]) if x = y and z / ∈ FV (t) ∪ FV (s)

39

slide-40
SLIDE 40

Substitution

x [x ← t] = t y [x ← t] = y if x = y c [x ← t] = c (s1 s2) [x ← t] = (s1[x ← t] s2[x ← t]) (λx. s) [x ← t] = (λx. s) (λy. s) [x ← t] = (λy. s[x ← t]) if x = y and y / ∈ FV (t) (λy. s) [x ← t] = (λz. s[y ← z][x ← t]) if x = y and z / ∈ FV (t) ∪ FV (s)

40

slide-41
SLIDE 41

Substitution

x [x ← t] = t y [x ← t] = y if x = y c [x ← t] = c (s1 s2) [x ← t] = (s1[x ← t] s2[x ← t]) (λx. s) [x ← t] = (λx. s) (λy. s) [x ← t] = (λy. s[x ← t]) if x = y and y / ∈ FV (t) (λy. s) [x ← t] = (λz. s[y ← z][x ← t]) if x = y and z / ∈ FV (t) ∪ FV (s)

41

slide-42
SLIDE 42

Substitution

x [x ← t] = t y [x ← t] = y if x = y c [x ← t] = c (s1 s2) [x ← t] = (s1[x ← t] s2[x ← t]) (λx. s) [x ← t] = (λx. s) (λy. s) [x ← t] = (λy. s[x ← t]) if x = y and y / ∈ FV (t) (λy. s) [x ← t] = (λz. s[y ← z][x ← t]) if x = y and z / ∈ FV (t) ∪ FV (s)

42

slide-43
SLIDE 43

Substitution Example

(x (λx. x) (λy. z x))[x ← y] = (x[x ← y]) ((λx. x)[x ← y]) ((λy. z x)[x ← y]) = y (λx. x) (λy ′. z y)

43

slide-44
SLIDE 44

Substitution Example

(x (λx. x) (λy. z x))[x ← y] = (x[x ← y]) ((λx. x)[x ← y]) ((λy. z x)[x ← y]) = y (λx. x) (λy ′. z y)

44

slide-45
SLIDE 45

Substitution Example

(x (λx. x) (λy. z x))[x ← y] = (x[x ← y]) ((λx. x)[x ← y]) ((λy. z x)[x ← y]) = y (λx. x) (λy ′. z y)

45

slide-46
SLIDE 46

α Conversion

Bound names are irrelevant: λx. x and λy. y denote the same function.

α conversion:

s =α t means s = t up to renaming of bound variables.

46

slide-47
SLIDE 47

α Conversion

Bound names are irrelevant: λx. x and λy. y denote the same function.

α conversion:

s =α t means s = t up to renaming of bound variables. Formally: (λx. t) − →α (λy. t[x ← y]) if y / ∈ FV (t) s − →α s′ = ⇒ (s t) − →α (s′ t) t − →α t′ = ⇒ (s t) − →α (s t′) s − →α s′ = ⇒ (λx. s) − →α (λx. s′)

47

slide-48
SLIDE 48

α Conversion

Bound names are irrelevant: λx. x and λy. y denote the same function.

α conversion:

s =α t means s = t up to renaming of bound variables. Formally: (λx. t) − →α (λy. t[x ← y]) if y / ∈ FV (t) s − →α s′ = ⇒ (s t) − →α (s′ t) t − →α t′ = ⇒ (s t) − →α (s t′) s − →α s′ = ⇒ (λx. s) − →α (λx. s′) s =α t iff s − →∗

α t

(− →∗

α = transitive, reflexive closure of −

→α = multiple steps)

48

slide-49
SLIDE 49

α Conversion

Examples: x (λx y. x y) =α x (λy x. y x) =α x (λz y. z y) =α z (λz y. z y) =α x (λx x. x x)

49

slide-50
SLIDE 50

α Conversion

Examples: x (λx y. x y) =α x (λy x. y x) =α x (λz y. z y) =α z (λz y. z y) =α x (λx x. x x)

50

slide-51
SLIDE 51

α Conversion

Examples: x (λx y. x y) =α x (λy x. y x) =α x (λz y. z y) =α z (λz y. z y) =α x (λx x. x x)

51

slide-52
SLIDE 52

α Conversion

Examples: x (λx y. x y) =α x (λy x. y x) =α x (λz y. z y) =α z (λz y. z y) =α x (λx x. x x)

52

slide-53
SLIDE 53

α Conversion

Examples: x (λx y. x y) =α x (λy x. y x) =α x (λz y. z y) =α z (λz y. z y) =α x (λx x. x x)

53

slide-54
SLIDE 54

Back to β

We have defined β reduction: − →β Some notation and concepts:

β conversion: s =β t

iff ∃n. s − →∗

β n ∧ t −

→∗

β n

t is reducible if there is an s such that t − →β s (λx. s) t is called a redex (reducible expression) t is reducible iff it contains a redex if it is not reducible, t is in normal form

54

slide-55
SLIDE 55

Back to β

We have defined β reduction: − →β Some notation and concepts:

β conversion: s =β t

iff ∃n. s − →∗

β n ∧ t −

→∗

β n

t is reducible if there is an s such that t − →β s (λx. s) t is called a redex (reducible expression) t is reducible iff it contains a redex if it is not reducible, t is in normal form

55

slide-56
SLIDE 56

Back to β

We have defined β reduction: − →β Some notation and concepts:

β conversion: s =β t

iff ∃n. s − →∗

β n ∧ t −

→∗

β n

t is reducible if there is an s such that t − →β s (λx. s) t is called a redex (reducible expression) t is reducible iff it contains a redex if it is not reducible, t is in normal form

56

slide-57
SLIDE 57

Back to β

We have defined β reduction: − →β Some notation and concepts:

β conversion: s =β t

iff ∃n. s − →∗

β n ∧ t −

→∗

β n

t is reducible if there is an s such that t − →β s (λx. s) t is called a redex (reducible expression) t is reducible iff it contains a redex if it is not reducible, t is in normal form

57

slide-58
SLIDE 58

Back to β

We have defined β reduction: − →β Some notation and concepts:

β conversion: s =β t

iff ∃n. s − →∗

β n ∧ t −

→∗

β n

t is reducible if there is an s such that t − →β s (λx. s) t is called a redex (reducible expression) t is reducible iff it contains a redex if it is not reducible, t is in normal form

58

slide-59
SLIDE 59

Does every λ term have a normal form?

No!

Example: (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β . . . (but: (λx y. y) ((λx. x x) (λx. x x)) − →β λy. y)

λ calculus is not terminating

59

slide-60
SLIDE 60

Does every λ term have a normal form?

No!

Example: (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β . . . (but: (λx y. y) ((λx. x x) (λx. x x)) − →β λy. y)

λ calculus is not terminating

60

slide-61
SLIDE 61

Does every λ term have a normal form?

No!

Example: (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β . . . (but: (λx y. y) ((λx. x x) (λx. x x)) − →β λy. y)

λ calculus is not terminating

61

slide-62
SLIDE 62

Does every λ term have a normal form?

No!

Example: (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β . . . (but: (λx y. y) ((λx. x x) (λx. x x)) − →β λy. y)

λ calculus is not terminating

62

slide-63
SLIDE 63

Does every λ term have a normal form?

No!

Example: (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β (λx. x x) (λx. x x) − →β . . . (but: (λx y. y) ((λx. x x) (λx. x x)) − →β λy. y)

λ calculus is not terminating

63

slide-64
SLIDE 64

β reduction is confluent

Confluence: s − →∗

β x ∧ s −

→∗

β y =

⇒ ∃t. x − →∗

β t ∧ y −

→∗

β t

s x y t ∗ ∗ ∗ ∗

64

slide-65
SLIDE 65

β reduction is confluent

Confluence: s − →∗

β x ∧ s −

→∗

β y =

⇒ ∃t. x − →∗

β t ∧ y −

→∗

β t

s x y t ∗ ∗ ∗ ∗ Order of reduction does not matter for result Normal forms in λ calculus are unique

65

slide-66
SLIDE 66

β reduction is confluent

Example: (λx y. y) ((λx. x x) a) − →β (λx y. y) (a a) − →β λy. y (λx y. y) ((λx. x x) a) − →β λy. y

66

slide-67
SLIDE 67

β reduction is confluent

Example: (λx y. y) ((λx. x x) a) − →β (λx y. y) (a a) − →β λy. y (λx y. y) ((λx. x x) a) − →β λy. y

67

slide-68
SLIDE 68

β reduction is confluent

Example: (λx y. y) ((λx. x x) a) − →β (λx y. y) (a a) − →β λy. y (λx y. y) ((λx. x x) a) − →β λy. y

68

slide-69
SLIDE 69

So, what can you do with λ calculus?

λ calculus is very expressive, you can encode:

logic, set theory turing machines, functional programs, etc. Examples: Now, not, and, or, etc is easy:

69

slide-70
SLIDE 70

So, what can you do with λ calculus?

λ calculus is very expressive, you can encode:

logic, set theory turing machines, functional programs, etc. Examples: true ≡ λx y. x if true x y − →∗

β x

false ≡ λx y. y if false x y − →∗

β y

if ≡ λz x y. z x y Now, not, and, or, etc is easy:

70

slide-71
SLIDE 71

So, what can you do with λ calculus?

λ calculus is very expressive, you can encode:

logic, set theory turing machines, functional programs, etc. Examples: true ≡ λx y. x if true x y − →∗

β x

false ≡ λx y. y if false x y − →∗

β y

if ≡ λz x y. z x y Now, not, and, or, etc is easy:

71

slide-72
SLIDE 72

So, what can you do with λ calculus?

λ calculus is very expressive, you can encode:

logic, set theory turing machines, functional programs, etc. Examples: true ≡ λx y. x if true x y − →∗

β x

false ≡ λx y. y if false x y − →∗

β y

if ≡ λz x y. z x y Now, not, and, or, etc is easy:

72

slide-73
SLIDE 73

So, what can you do with λ calculus?

λ calculus is very expressive, you can encode:

logic, set theory turing machines, functional programs, etc. Examples: true ≡ λx y. x if true x y − →∗

β x

false ≡ λx y. y if false x y − →∗

β y

if ≡ λz x y. z x y Now, not, and, or, etc is easy: not ≡ λx. if x false true and ≡ λx y. if x y false

  • r

≡ λx y. if x true y

73

slide-74
SLIDE 74

Fix Points

(λx f . f (x x f )) (λx f . f (x x f )) t − →β (λf . f ((λx f . f (x x f )) (λx f . f (x x f )) f )) t − →β t ((λx f . f (x x f )) (λx f . f (x x f )) t) (λxf . f (x x f )) (λxf . f (x x f )) is Turing’s fix point operator

74

slide-75
SLIDE 75

Fix Points

(λx f . f (x x f )) (λx f . f (x x f )) t − →β (λf . f ((λx f . f (x x f )) (λx f . f (x x f )) f )) t − →β t ((λx f . f (x x f )) (λx f . f (x x f )) t) (λxf . f (x x f )) (λxf . f (x x f )) is Turing’s fix point operator

75

slide-76
SLIDE 76

Fix Points

(λx f . f (x x f )) (λx f . f (x x f )) t − →β (λf . f ((λx f . f (x x f )) (λx f . f (x x f )) f )) t − →β t ((λx f . f (x x f )) (λx f . f (x x f )) t) (λxf . f (x x f )) (λxf . f (x x f )) is Turing’s fix point operator

76

slide-77
SLIDE 77

Fix Points

(λx f . f (x x f )) (λx f . f (x x f )) t − →β (λf . f ((λx f . f (x x f )) (λx f . f (x x f )) f )) t − →β t ((λx f . f (x x f )) (λx f . f (x x f )) t) µ = (λxf . f (x x f )) (λxf . f (x x f )) µ t − →β t (µ t) − →β t (t (µ t)) − →β t (t (t (µ t))) − →β . . . (λxf . f (x x f )) (λxf . f (x x f )) is Turing’s fix point operator

77

slide-78
SLIDE 78

Fix Points

(λx f . f (x x f )) (λx f . f (x x f )) t − →β (λf . f ((λx f . f (x x f )) (λx f . f (x x f )) f )) t − →β t ((λx f . f (x x f )) (λx f . f (x x f )) t) µ = (λxf . f (x x f )) (λxf . f (x x f )) µ t − →β t (µ t) − →β t (t (µ t)) − →β t (t (t (µ t))) − →β . . . (λxf . f (x x f )) (λxf . f (x x f )) is Turing’s fix point operator

78

slide-79
SLIDE 79

Nice, but ...

As a mathematical foundation, λ does not work. It is inconsistent. Problem: with {x| P x} ≡ λx. P x x ∈ M ≡ M x you can write R ≡ λx. not (x x) and get (R R) =β not (R R) because (R R) = (λx. not (x x)) R − →β not (R R)

79

slide-80
SLIDE 80

Nice, but ...

As a mathematical foundation, λ does not work. It is inconsistent. Frege (Predicate Logic, ∼ 1879): allows arbitrary quantification over predicates Russell (1901): Paradox R ≡ {X|X / ∈ X} Whitehead & Russell (Principia Mathematica, 1910-1913): Fix the problem Church (1930): λ calculus as logic, true, false, ∧, . . . as λ terms Problem: with {x| P x} ≡ λx. P x x ∈ M ≡ M x you can write R ≡ λx. not (x x) and get (R R) =β not (R R) because (R R) = (λx. not (x x)) R − →β not (R R)

80

slide-81
SLIDE 81

Nice, but ...

As a mathematical foundation, λ does not work. It is inconsistent. Frege (Predicate Logic, ∼ 1879): allows arbitrary quantification over predicates Russell (1901): Paradox R ≡ {X|X / ∈ X} Whitehead & Russell (Principia Mathematica, 1910-1913): Fix the problem Church (1930): λ calculus as logic, true, false, ∧, . . . as λ terms Problem: with {x| P x} ≡ λx. P x x ∈ M ≡ M x you can write R ≡ λx. not (x x) and get (R R) =β not (R R) because (R R) = (λx. not (x x)) R − →β not (R R)

81

slide-82
SLIDE 82

Nice, but ...

As a mathematical foundation, λ does not work. It is inconsistent. Frege (Predicate Logic, ∼ 1879): allows arbitrary quantification over predicates Russell (1901): Paradox R ≡ {X|X / ∈ X} Whitehead & Russell (Principia Mathematica, 1910-1913): Fix the problem Church (1930): λ calculus as logic, true, false, ∧, . . . as λ terms Problem: with {x| P x} ≡ λx. P x x ∈ M ≡ M x you can write R ≡ λx. not (x x) and get (R R) =β not (R R) because (R R) = (λx. not (x x)) R − →β not (R R)

82

slide-83
SLIDE 83

Nice, but ...

As a mathematical foundation, λ does not work. It is inconsistent. Frege (Predicate Logic, ∼ 1879): allows arbitrary quantification over predicates Russell (1901): Paradox R ≡ {X|X / ∈ X} Whitehead & Russell (Principia Mathematica, 1910-1913): Fix the problem Church (1930): λ calculus as logic, true, false, ∧, . . . as λ terms Problem: with {x| P x} ≡ λx. P x x ∈ M ≡ M x you can write R ≡ λx. not (x x) and get (R R) =β not (R R) because (R R) = (λx. not (x x)) R − →β not (R R)

83

slide-84
SLIDE 84

Nice, but ...

As a mathematical foundation, λ does not work. It is inconsistent. Frege (Predicate Logic, ∼ 1879): allows arbitrary quantification over predicates Russell (1901): Paradox R ≡ {X|X / ∈ X} Whitehead & Russell (Principia Mathematica, 1910-1913): Fix the problem Church (1930): λ calculus as logic, true, false, ∧, . . . as λ terms Problem: with {x| P x} ≡ λx. P x x ∈ M ≡ M x you can write R ≡ λx. not (x x) and get (R R) =β not (R R) because (R R) = (λx. not (x x)) R − →β not (R R)

84

slide-85
SLIDE 85

Summary

λ calculus syntax free variables, substitution α conversion β reduction β reduction is confluent λ calculus is very expressive (Turing complete) λ calculus is inconsistent (as a logic)

85

slide-86
SLIDE 86

Exercise

Reduce (λx. y (λv. x v)) (λy. v y) to β normal form.

86

slide-87
SLIDE 87

λ calculus is inconsistent

Can find term R such that R R =β not(R R) There are more terms that do not make sense: true false, etc.

Solution: rule out ill-formed terms by using types. (Church 1940)

87

slide-88
SLIDE 88

λ calculus is inconsistent

Can find term R such that R R =β not(R R) There are more terms that do not make sense: true false, etc.

Solution: rule out ill-formed terms by using types. (Church 1940)

88

slide-89
SLIDE 89

Introducing types

Idea: assign a type to each “sensible” λ term. Examples: for term t has type α write t :: α if x has type α then λx. x is a function from α to α Write: (λx. x) :: α ⇒ α for s t to be sensible: s must be a function t must be right type for parameter If s :: α ⇒ β and t :: α then (s t) :: β

89

slide-90
SLIDE 90

Introducing types

Idea: assign a type to each “sensible” λ term. Examples: for term t has type α write t :: α if x has type α then λx. x is a function from α to α Write: (λx. x) :: α ⇒ α for s t to be sensible: s must be a function t must be right type for parameter If s :: α ⇒ β and t :: α then (s t) :: β

90

slide-91
SLIDE 91

Introducing types

Idea: assign a type to each “sensible” λ term. Examples: for term t has type α write t :: α if x has type α then λx. x is a function from α to α Write: (λx. x) :: α ⇒ α for s t to be sensible: s must be a function t must be right type for parameter If s :: α ⇒ β and t :: α then (s t) :: β

91

slide-92
SLIDE 92

Introducing types

Idea: assign a type to each “sensible” λ term. Examples: for term t has type α write t :: α if x has type α then λx. x is a function from α to α Write: (λx. x) :: α ⇒ α for s t to be sensible: s must be a function t must be right type for parameter If s :: α ⇒ β and t :: α then (s t) :: β

92

slide-93
SLIDE 93

That’s it! Now Formally

93

slide-94
SLIDE 94

That’s it! Now Formally

94

slide-95
SLIDE 95

Syntax for λ→

Terms:

t ::= v | c | (t t) | (λx. t)

v, x ∈ V , c ∈ C, V , C sets of names Types:

τ ::= b | ν | τ ⇒ τ

b ∈ {bool, int, . . .} base types ν ∈ {α, β, . . .} type variables α ⇒ β ⇒ γ = α ⇒ (β ⇒ γ) Context Γ: Γ: function from variable and constant names to types. Term t has type τ in context Γ: Γ ⊢ t :: τ

95

slide-96
SLIDE 96

Syntax for λ→

Terms:

t ::= v | c | (t t) | (λx. t)

v, x ∈ V , c ∈ C, V , C sets of names Types:

τ ::= b | ν | τ ⇒ τ

b ∈ {bool, int, . . .} base types ν ∈ {α, β, . . .} type variables α ⇒ β ⇒ γ = α ⇒ (β ⇒ γ) Context Γ: Γ: function from variable and constant names to types. Term t has type τ in context Γ: Γ ⊢ t :: τ

96

slide-97
SLIDE 97

Syntax for λ→

Terms:

t ::= v | c | (t t) | (λx. t)

v, x ∈ V , c ∈ C, V , C sets of names Types:

τ ::= b | ν | τ ⇒ τ

b ∈ {bool, int, . . .} base types ν ∈ {α, β, . . .} type variables α ⇒ β ⇒ γ = α ⇒ (β ⇒ γ) Context Γ: Γ: function from variable and constant names to types. Term t has type τ in context Γ: Γ ⊢ t :: τ

97

slide-98
SLIDE 98

Examples

Γ ⊢ (λx. x) :: α ⇒ α [y ← int] ⊢ y :: int [z ← bool] ⊢ (λy. y) z :: bool [] ⊢ λf x. f x :: (α ⇒ β) ⇒ α ⇒ β

98

slide-99
SLIDE 99

Examples

Γ ⊢ (λx. x) :: α ⇒ α [y ← int] ⊢ y :: int [z ← bool] ⊢ (λy. y) z :: bool [] ⊢ λf x. f x :: (α ⇒ β) ⇒ α ⇒ β

99

slide-100
SLIDE 100

Examples

Γ ⊢ (λx. x) :: α ⇒ α [y ← int] ⊢ y :: int [z ← bool] ⊢ (λy. y) z :: bool [] ⊢ λf x. f x :: (α ⇒ β) ⇒ α ⇒ β

100

slide-101
SLIDE 101

Examples

Γ ⊢ (λx. x) :: α ⇒ α [y ← int] ⊢ y :: int [z ← bool] ⊢ (λy. y) z :: bool [] ⊢ λf x. f x :: (α ⇒ β) ⇒ α ⇒ β

101

slide-102
SLIDE 102

Examples

Γ ⊢ (λx. x) :: α ⇒ α [y ← int] ⊢ y :: int [z ← bool] ⊢ (λy. y) z :: bool [] ⊢ λf x. f x :: (α ⇒ β) ⇒ α ⇒ β A term t is well typed or type correct if there are Γ and τ such that Γ ⊢ t :: τ

102

slide-103
SLIDE 103

Type Checking Rules

Variables: Γ ⊢ x :: Γ(x) Application: Γ ⊢ t1 :: τ2 ⇒ τ Γ ⊢ t2 :: τ2 Γ ⊢ (t1 t2) :: τ Abstraction: Γ[x ← τx] ⊢ t :: τ Γ ⊢ (λx. t) :: τx ⇒ τ

103

slide-104
SLIDE 104

Type Checking Rules

Variables: Γ ⊢ x :: Γ(x) Application: Γ ⊢ t1 :: τ2 ⇒ τ Γ ⊢ t2 :: τ2 Γ ⊢ (t1 t2) :: τ Abstraction: Γ[x ← τx] ⊢ t :: τ Γ ⊢ (λx. t) :: τx ⇒ τ

104

slide-105
SLIDE 105

Type Checking Rules

Variables: Γ ⊢ x :: Γ(x) Application: Γ ⊢ t1 :: τ2 ⇒ τ Γ ⊢ t2 :: τ2 Γ ⊢ (t1 t2) :: τ Abstraction: Γ[x ← τx] ⊢ t :: τ Γ ⊢ (λx. t) :: τx ⇒ τ

105

slide-106
SLIDE 106

Type Checking Rules

Variables: Γ ⊢ x :: Γ(x) Application: Γ ⊢ t1 :: τ2 ⇒ τ Γ ⊢ t2 :: τ2 Γ ⊢ (t1 t2) :: τ Abstraction: Γ[x ← τx] ⊢ t :: τ Γ ⊢ (λx. t) :: τx ⇒ τ

106

slide-107
SLIDE 107

Type Checking Rules

Variables: Γ ⊢ x :: Γ(x) Application: Γ ⊢ t1 :: τ2 ⇒ τ Γ ⊢ t2 :: τ2 Γ ⊢ (t1 t2) :: τ Abstraction: Γ[x ← τx] ⊢ t :: τ Γ ⊢ (λx. t) :: τx ⇒ τ

107

slide-108
SLIDE 108

Example Type Derivation:

[x ← α, y ← β] ⊢ x :: α [x ← α] ⊢ λy. x :: β ⇒ α [] ⊢ λx y. x :: α ⇒ β ⇒ α

108

slide-109
SLIDE 109

Example Type Derivation:

[x ← α, y ← β] ⊢ x :: α [x ← α] ⊢ λy. x :: β ⇒ α [] ⊢ λx y. x :: α ⇒ β ⇒ α

109

slide-110
SLIDE 110

Example Type Derivation:

[x ← α, y ← β] ⊢ x :: α [x ← α] ⊢ λy. x :: β ⇒ α [] ⊢ λx y. x :: α ⇒ β ⇒ α

110

slide-111
SLIDE 111

Example Type Derivation:

[x ← α, y ← β] ⊢ x :: α [x ← α] ⊢ λy. x :: β ⇒ α [] ⊢ λx y. x :: α ⇒ β ⇒ α

111

slide-112
SLIDE 112

More general Types

A term can have more than one type. Examples: int ⇒ bool

  • α ⇒ β
  • β ⇒ α
  • α ⇒ α

112

slide-113
SLIDE 113

More general Types

A term can have more than one type. Example: [] ⊢ λx. x :: bool ⇒ bool [] ⊢ λx. x :: α ⇒ α Examples: int ⇒ bool

  • α ⇒ β
  • β ⇒ α
  • α ⇒ α

113

slide-114
SLIDE 114

More general Types

A term can have more than one type. Example: [] ⊢ λx. x :: bool ⇒ bool [] ⊢ λx. x :: α ⇒ α Some types are more general than others: τ σ if there is a substitution S such that τ = S(σ) Examples: int ⇒ bool

  • α ⇒ β
  • β ⇒ α
  • α ⇒ α

114

slide-115
SLIDE 115

More general Types

A term can have more than one type. Example: [] ⊢ λx. x :: bool ⇒ bool [] ⊢ λx. x :: α ⇒ α Some types are more general than others: τ σ if there is a substitution S such that τ = S(σ) Examples: int ⇒ bool

  • α ⇒ β
  • β ⇒ α
  • α ⇒ α

115

slide-116
SLIDE 116

More general Types

A term can have more than one type. Example: [] ⊢ λx. x :: bool ⇒ bool [] ⊢ λx. x :: α ⇒ α Some types are more general than others: τ σ if there is a substitution S such that τ = S(σ) Examples: int ⇒ bool

  • α ⇒ β
  • β ⇒ α
  • α ⇒ α

116

slide-117
SLIDE 117

More general Types

A term can have more than one type. Example: [] ⊢ λx. x :: bool ⇒ bool [] ⊢ λx. x :: α ⇒ α Some types are more general than others: τ σ if there is a substitution S such that τ = S(σ) Examples: int ⇒ bool

  • α ⇒ β
  • β ⇒ α
  • α ⇒ α

117

slide-118
SLIDE 118

Most general Types

Fact: each type correct term has a most general type It can be found by executing the typing rules backwards. type checking: checking if Γ ⊢ t :: τ for given Γ and τ type inference: computing Γ and τ such that Γ ⊢ t :: τ Type checking and type inference on λ→ are decidable.

118

slide-119
SLIDE 119

Most general Types

Fact: each type correct term has a most general type Formally: Γ ⊢ t :: τ = ⇒ ∃σ. Γ ⊢ t :: σ ∧ (∀σ′. Γ ⊢ t :: σ′ = ⇒ σ′ σ) It can be found by executing the typing rules backwards. type checking: checking if Γ ⊢ t :: τ for given Γ and τ type inference: computing Γ and τ such that Γ ⊢ t :: τ Type checking and type inference on λ→ are decidable.

119

slide-120
SLIDE 120

Most general Types

Fact: each type correct term has a most general type Formally: Γ ⊢ t :: τ = ⇒ ∃σ. Γ ⊢ t :: σ ∧ (∀σ′. Γ ⊢ t :: σ′ = ⇒ σ′ σ) It can be found by executing the typing rules backwards. type checking: checking if Γ ⊢ t :: τ for given Γ and τ type inference: computing Γ and τ such that Γ ⊢ t :: τ Type checking and type inference on λ→ are decidable.

120

slide-121
SLIDE 121

Most general Types

Fact: each type correct term has a most general type Formally: Γ ⊢ t :: τ = ⇒ ∃σ. Γ ⊢ t :: σ ∧ (∀σ′. Γ ⊢ t :: σ′ = ⇒ σ′ σ) It can be found by executing the typing rules backwards. type checking: checking if Γ ⊢ t :: τ for given Γ and τ type inference: computing Γ and τ such that Γ ⊢ t :: τ Type checking and type inference on λ→ are decidable.

121

slide-122
SLIDE 122

Most general Types

Fact: each type correct term has a most general type Formally: Γ ⊢ t :: τ = ⇒ ∃σ. Γ ⊢ t :: σ ∧ (∀σ′. Γ ⊢ t :: σ′ = ⇒ σ′ σ) It can be found by executing the typing rules backwards. type checking: checking if Γ ⊢ t :: τ for given Γ and τ type inference: computing Γ and τ such that Γ ⊢ t :: τ Type checking and type inference on λ→ are decidable.

122

slide-123
SLIDE 123

Most general Types

Fact: each type correct term has a most general type Formally: Γ ⊢ t :: τ = ⇒ ∃σ. Γ ⊢ t :: σ ∧ (∀σ′. Γ ⊢ t :: σ′ = ⇒ σ′ σ) It can be found by executing the typing rules backwards. type checking: checking if Γ ⊢ t :: τ for given Γ and τ type inference: computing Γ and τ such that Γ ⊢ t :: τ Type checking and type inference on λ→ are decidable.

123

slide-124
SLIDE 124

What about β reduction?

Definition of β reduction stays the same. This property is called subject reduction

124

slide-125
SLIDE 125

What about β reduction?

Definition of β reduction stays the same. This property is called subject reduction

125

slide-126
SLIDE 126

What about β reduction?

Definition of β reduction stays the same. Fact: Well typed terms stay well typed during β reduction Formally: Γ ⊢ s :: τ ∧ s − →β t = ⇒ Γ ⊢ t :: τ This property is called subject reduction

126

slide-127
SLIDE 127

What about β reduction?

Definition of β reduction stays the same. Fact: Well typed terms stay well typed during β reduction Formally: Γ ⊢ s :: τ ∧ s − →β t = ⇒ Γ ⊢ t :: τ This property is called subject reduction

127

slide-128
SLIDE 128

What about termination?

=β is decidable To decide if s =β t, reduce s and t to normal form (always exists, because − →β terminates), and compare result. =αβ is decidable

128

slide-129
SLIDE 129

What about termination?

β reduction in λ→ always terminates.

(Alan Turing, 1942) =β is decidable To decide if s =β t, reduce s and t to normal form (always exists, because − →β terminates), and compare result. =αβ is decidable

129

slide-130
SLIDE 130

What about termination?

β reduction in λ→ always terminates.

(Alan Turing, 1942) =β is decidable To decide if s =β t, reduce s and t to normal form (always exists, because − →β terminates), and compare result. =αβ is decidable

130

slide-131
SLIDE 131

What about termination?

β reduction in λ→ always terminates.

(Alan Turing, 1942) =β is decidable To decide if s =β t, reduce s and t to normal form (always exists, because − →β terminates), and compare result. =αβ is decidable

131

slide-132
SLIDE 132

What does this mean for Expressiveness?

Not all computable functions can be expressed in λ→! How can typed functional languages then be Turing complete?

132

slide-133
SLIDE 133

What does this mean for Expressiveness?

Not all computable functions can be expressed in λ→! How can typed functional languages then be Turing complete?

133

slide-134
SLIDE 134

What does this mean for Expressiveness?

Not all computable functions can be expressed in λ→! How can typed functional languages then be Turing complete?

134

slide-135
SLIDE 135

What does this mean for Expressiveness?

Not all computable functions can be expressed in λ→! How can typed functional languages then be Turing complete? Fact: Each computable function can be encoded as closed, type correct λ→ term using Y :: (τ ⇒ τ) ⇒ τ with Y t − →β t (Y t) as only constant.

135

slide-136
SLIDE 136

What does this mean for Expressiveness?

Not all computable functions can be expressed in λ→! How can typed functional languages then be Turing complete? Fact: Each computable function can be encoded as closed, type correct λ→ term using Y :: (τ ⇒ τ) ⇒ τ with Y t − →β t (Y t) as only constant. Y is called fix point operator used for recursion lose decidability (what does Y (λx. x) reduce to?)

136

slide-137
SLIDE 137

We have learned so far...

Simply typed lambda calculus: λ→ Typing rules for λ→, type variables, type contexts β-reduction in λ→ satisfies subject reduction β-reduction in λ→ always terminates

137

slide-138
SLIDE 138

We have learned so far...

Simply typed lambda calculus: λ→ Typing rules for λ→, type variables, type contexts β-reduction in λ→ satisfies subject reduction β-reduction in λ→ always terminates

138

slide-139
SLIDE 139

We have learned so far...

Simply typed lambda calculus: λ→ Typing rules for λ→, type variables, type contexts β-reduction in λ→ satisfies subject reduction β-reduction in λ→ always terminates

139

slide-140
SLIDE 140

We have learned so far...

Simply typed lambda calculus: λ→ Typing rules for λ→, type variables, type contexts β-reduction in λ→ satisfies subject reduction β-reduction in λ→ always terminates

140

slide-141
SLIDE 141

Defining Higher Order Logic

141

slide-142
SLIDE 142

What is Higher Order Logic?

Propositional Logic:

no quantifiers all variables have type bool

142

slide-143
SLIDE 143

What is Higher Order Logic?

Propositional Logic:

no quantifiers all variables have type bool

First Order Logic:

quantification over values, but not over functions and predicates, terms and formulas syntactically distinct

143

slide-144
SLIDE 144

What is Higher Order Logic?

Propositional Logic:

no quantifiers all variables have type bool

First Order Logic:

quantification over values, but not over functions and predicates, terms and formulas syntactically distinct

Higher Order Logic:

quantification over everything, including predicates consistency by types formula = term of type bool definition built on λ→ with certain default types and constants

144

slide-145
SLIDE 145

Defining Higher Order Logic

Default types:

bool ⇒ ind

Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

145

slide-146
SLIDE 146

Defining Higher Order Logic

Default types:

bool ⇒ ind

Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

146

slide-147
SLIDE 147

Defining Higher Order Logic

Default types:

bool ⇒ ind

Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

147

slide-148
SLIDE 148

Defining Higher Order Logic

Default types:

bool ⇒ ind

Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

148

slide-149
SLIDE 149

Defining Higher Order Logic

Default types:

bool ⇒ ind

bool sometimes called o ⇒ sometimes called fun Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

149

slide-150
SLIDE 150

Defining Higher Order Logic

Default types:

bool ⇒ ind

bool sometimes called o ⇒ sometimes called fun Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

150

slide-151
SLIDE 151

Defining Higher Order Logic

Default types:

bool ⇒ ind

bool sometimes called o ⇒ sometimes called fun Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

151

slide-152
SLIDE 152

Defining Higher Order Logic

Default types:

bool ⇒ ind

bool sometimes called o ⇒ sometimes called fun Default Constants:

− → :: bool ⇒ bool ⇒ bool = :: α ⇒ α ⇒ bool

152

slide-153
SLIDE 153

Higher Order Abstract Syntax

Problem: Define syntax for binders like ∀ and ∃

153

slide-154
SLIDE 154

Higher Order Abstract Syntax

Problem: Define syntax for binders like ∀ and ∃ One approach: ∀ :: var ⇒ term ⇒ bool Drawback: need to think about substitution, α conversion again.

154

slide-155
SLIDE 155

Higher Order Abstract Syntax

Problem: Define syntax for binders like ∀ and ∃ One approach: ∀ :: var ⇒ term ⇒ bool Drawback: need to think about substitution, α conversion again. But: Already have binder, substitution, α conversion in meta logic

λ

155

slide-156
SLIDE 156

Higher Order Abstract Syntax

Problem: Define syntax for binders like ∀ and ∃ One approach: ∀ :: var ⇒ term ⇒ bool Drawback: need to think about substitution, α conversion again. But: Already have binder, substitution, α conversion in meta logic

λ

So: Use λ to encode all other binders.

156

slide-157
SLIDE 157

Higher Order Abstract Syntax

Example: ALL :: (α ⇒ bool) ⇒ bool HOAS usual syntax ALL (λx. x = 2) ∀x. x = 2 ALL P ∀x. P x

157

slide-158
SLIDE 158

Higher Order Abstract Syntax

Example: ALL :: (α ⇒ bool) ⇒ bool HOAS usual syntax ALL (λx. x = 2) ∀x. x = 2 ALL P ∀x. P x

158

slide-159
SLIDE 159

Higher Order Abstract Syntax

Example: ALL :: (α ⇒ bool) ⇒ bool HOAS usual syntax ALL (λx. x = 2) ∀x. x = 2 ALL P ∀x. P x

159

slide-160
SLIDE 160

Higher Order Abstract Syntax

Example: ALL :: (α ⇒ bool) ⇒ bool HOAS usual syntax ALL (λx. x = 2) ∀x. x = 2 ALL P ∀x. P x

160

slide-161
SLIDE 161

Higher Order Abstract Syntax

Example: ALL :: (α ⇒ bool) ⇒ bool HOAS usual syntax ALL (λx. x = 2) ∀x. x = 2 ALL P ∀x. P x

161

slide-162
SLIDE 162

Back to HOL

Base: bool, ⇒, ind =, − → And the rest is definitions: True ≡ (λx :: bool. x) = (λx. x) All P ≡ P = (λx. True) Ex P ≡ ∀Q. (∀x. P x − → Q) − → Q False ≡ ∀P. P ¬P ≡ P − → False P ∧ Q ≡ ∀R. (P − → Q − → R) − → R P ∨ Q ≡ ∀R. (P − → R) − → (Q − → R) − → R

162

slide-163
SLIDE 163

Back to HOL

Base: bool, ⇒, ind =, − → And the rest is definitions: True ≡ (λx :: bool. x) = (λx. x) All P ≡ P = (λx. True) Ex P ≡ ∀Q. (∀x. P x − → Q) − → Q False ≡ ∀P. P ¬P ≡ P − → False P ∧ Q ≡ ∀R. (P − → Q − → R) − → R P ∨ Q ≡ ∀R. (P − → R) − → (Q − → R) − → R

163

slide-164
SLIDE 164

Back to HOL

Base: bool, ⇒, ind =, − → And the rest is definitions: True ≡ (λx :: bool. x) = (λx. x) All P ≡ P = (λx. True) Ex P ≡ ∀Q. (∀x. P x − → Q) − → Q False ≡ ∀P. P ¬P ≡ P − → False P ∧ Q ≡ ∀R. (P − → Q − → R) − → R P ∨ Q ≡ ∀R. (P − → R) − → (Q − → R) − → R

164

slide-165
SLIDE 165

Back to HOL

Base: bool, ⇒, ind =, − → And the rest is definitions: True ≡ (λx :: bool. x) = (λx. x) All P ≡ P = (λx. True) Ex P ≡ ∀Q. (∀x. P x − → Q) − → Q False ≡ ∀P. P ¬P ≡ P − → False P ∧ Q ≡ ∀R. (P − → Q − → R) − → R P ∨ Q ≡ ∀R. (P − → R) − → (Q − → R) − → R

165

slide-166
SLIDE 166

Back to HOL

Base: bool, ⇒, ind =, − → And the rest is definitions: True ≡ (λx :: bool. x) = (λx. x) All P ≡ P = (λx. True) Ex P ≡ ∀Q. (∀x. P x − → Q) − → Q False ≡ ∀P. P ¬P ≡ P − → False P ∧ Q ≡ ∀R. (P − → Q − → R) − → R P ∨ Q ≡ ∀R. (P − → R) − → (Q − → R) − → R

166

slide-167
SLIDE 167

We have learned so far ...

HOL Higher Order Abstract Syntax

167

slide-168
SLIDE 168

We have learned so far ...

HOL Higher Order Abstract Syntax

168