foundations 1 - hwpav1/lectures/f29fay-foundations 1/lecture1.pdf · propositional logic • formal...

40
Foundations 1 Patricia A. Vargas Joe Wells

Upload: others

Post on 21-Feb-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Foundations 1

Patricia A. Vargas

Joe Wells

Page 2: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Objectives

• To give an introduction to and an appreciation

of the basic principles and techniques of logic

and proof fundamental to Computer Science

• To acquaint the students with the syntax and

semantics of the language of computable

functions (the lambda calculus) and with its

reduction strategies with an eye on termination,

efficiency and the meaning of programs

2F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 3: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Lecturers

Dr. Patricia A. Vargas

• PhD in Computer Engineering from the University of Campinas, Unicamp (Brazil) in 2005

• is currently a Lecturer at MACS, Heriot-Watt University (Edinburgh, Scotland, UK)

• was a post-doc @ the Centre for Computational Neuroscience and Robotics, University of Sussex (Brighton, England, UK) and @ MACS, HWU, for the past 4 years

• http://www.macs.hw.ac.uk/~pav1

[email protected]

3F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 4: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Lecturers

Dr. Joe Wells

• Ph.D. in Computer Science at Boston University (USA) in 1996

• is currently a permanent Senior Research Fellow at MACS, Heriot-Watt University (Edinburgh, Scotland, UK)

• was a postdoctoral researcher at B.U. and GlasgowUniversity (Glasgow, Scotland, UK)

• http://www.macs.hw.ac.uk/~jbw

[email protected]

4F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 5: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

The Course – Part I

• Patricia will cover:

– Logic & proof: propositional calculus – truth

tables, predicate calculus, inference rules,

soundness, completeness, validity, satisfiability,

reasoning and calculating with propositions

• Material:

– http://www.macs.hw.ac.uk/~pav1

5F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 6: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

The Course – Part II

• Joe will cover:

– Lambda calculus, syntax and semantics: notation;

bound & free variables; de Bruijn notation, normal

& applicative order evaluation; confluence,

termination

• Material:

– http://www.macs.hw.ac.uk/~jbw

6F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 7: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Part I - Books

1. Logical Reasoning: A first course.

– Rob Nederpelt and Fairouz Kamareddine (2004)

– King’s college publications , Texts in Computing, Volume 3.

2. Logic: A Very Short Introduction

– Graham Priest (2000)

– Oxford University Press

3. Logic

– Wilfrid Hodges (2001)

– Penguin books

7F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 8: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Assessment

• In-course assessment (30%):

– From Patricia (15%) : random assignments + 1

class test on the 12th of October

– From Joe (15%) : TBA

• One written exam (70%) in December

8F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 9: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Lectures

Patricia

• 10 lectures + 5 tutorials

• week 1 to week 5

Joe

• 10 lectures + 5 tutorials

• week 6 to week 10

Revision

• week 11 (Part I)

• week 12 (Part II)

9F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 10: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Tutorials

• Exercises

• Tutor: Vincent Rahli

– fourth year PhD student @ HWU

– Is French and have done all hisstudies, prior to his PhD, in France (Angers, Nantes, Paris)

– started his PhD in October 2006 under the supervision of Prof. Fairouz Kamareddine and Dr. Joe Wells

– http://www.macs.hw.ac.uk/~rahli

10F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 11: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Lecture 1

I. Why Logic?

II. What is Logic?

III. History of Logic

IV. Preliminary Concepts

V. Propositional Logic (Part 1)

11F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 12: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Logic

• Why?

– “He who can reason, can carry through convincing

arguments with which he is able to achieve what

he desires”

– “With a reasoning-instrument, one can get rid of

false reasoning, and can win arguments against

opponents”

page 3 (Nederpelt & Kamareddine, 2004)

12F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 13: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Logic

• Why?

– “Modern logic is important in computer science

especially in areas like programming, database

theory, computer architecture and verification”

page 6 (Nederpelt & Kamareddine, 2004)

13F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 14: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Logic

• What is?

– is an ancient science

– logic is the study of the principles of reasoning

– logic deals with general reasoning laws which you

can trust

– logical laws are given in the form of logical

formulas with parameters

14F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 15: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Logic

• What is?– logical laws are given in the form of logical formulas with

parameters

– Here is a rule of Aristotle work in logic (a syllogism):

All K’s are L’s ;

All L’s are M’s ;

Then All K’s are M’s

– The rule can for example be applied as follows:

All Scottish are British;

All British are European;

Then All Scottish are European.

15F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 16: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Logic

• Modern logic comprises the logical theories & techniques of logic after the revolution in the 20th century

• Nowadays the term formal logic is used instead of modern logic

• logical formulas, hence formal

• Formal logic

– Propositional logic/calculus

– First-order/predicate logic/calculus

16F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 17: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Logic

• History

– 1st assignment

• Write a summary that outlines the “History of Logic”

• Alone or in pairs

• Include references

• 500 words (max)

• For next Thursday Lecture (17/09)

17F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 18: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Preliminary Concepts

Structures: Trees• nodes (the buttons)

• branches (the connecting lines)

• labels (the letters)

• nodes: the root or leaves

• a tree has a root and all nodes are connected to each other and there are no loops

18F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 19: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Preliminary Concepts

Set• Is a collection of distinct objects/elements

• Membership:– x ∈ A means x is an element of set A

– x ∉ A means x is NOT an element of set A

• Subset:– A ⊂ B means every element of set A is also an element of set B

– ∅ denotes the empty set which is a subset of every set

• Main operations:– Union

– Intersection

– Cartesian product

19F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 20: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Preliminary Concepts

Sets

• Union

A ∪ B = B ∪ A.

A ∪ (B ∪ C) = (A ∪ B) ∪ C.

A ⊂ (A ∪ B).

A ∪ A = A.

A ∪ ∅ = A.

A ⊂ B if and only if A ∪ B = B.

20F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 21: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Preliminary Concepts

Sets

• Intersection

A ∩ B = B ∩ A.

A ∩ (B ∩ C) = (A ∩ B) ∩ C.

A ∩ B ⊂ A.

A ∩ A = A.

A ∩ ∅ = ∅.

A ⊂ B if and only if A ∩ B = A.

21F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 22: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Preliminary Concepts

Sets

• Cartesian product

A × ∅ = ∅.

A × (B ∪ C) = (A × B) ∪ (A × C).

(A ∪ B) × C = (A × C) ∪ (B × C).

• Example:

• A = {1, 2} and B = {red, white}

• A × B = {1, 2} × {red, white}

• A × B = {(1, red), (1, white), (2, red), (2, white)}

22F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 23: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• Formal logic has as a basic concept the so-calledproposition

• This is a pure technical term, and you must not think of the ordinary English word ’proposition’(lemma).

• Instead, think of something like a special kind of alanguage sentence.

• A proposition is a grammatically correct sentence which (at this moment, at this place, etc.) is eithertrue or false.

23F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 24: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• Examples of propositions:

A = “Aristotle is dead.”

B = “Barcelona is in Spain.”

C = “There are birds which cannot fly.”

D = “It is raining.”

24F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 25: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• Propositions are building blocks used to

construct formulas/sentences

• A formula/sentence is either true or false

• A Boolean value/truth value of 1 or 0 is

assigned accordingly

• We will use the truth value 1 for “true” and

the truth value 0 for “false”

25F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 26: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• The language of propositional logic contains symbols for some words (connectives):

∧ The symbol for the word ’and’.

∨ The symbol for the word ’or’.

¬ Represents the word ’not’.

⇒ For ’if ... then’ or ’implies’.

⇔ For ’if and only if ’.

26F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 27: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

∧ The symbol for the word ’and’

Example:

A = “It is raining.”

B = “It is windy.”

“It is raining and it is windy” = A ∧ B

27F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 28: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

∨ The symbol for the word ’or’

Example: Suppose you are hungry, you can say…

A = “I will fetch a roll.”

B = “I will fetch a sandwich.”

Or you can say…

“I will fetch a roll or a sandwich” = A ∨ B

28F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 29: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

¬ Represents the word ’not’

Example:

A = “It is freezing.”

¬ A = “It is not freezing.”

29F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 30: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

⇒ For ’if ... then’ or ’implies’

Example:

A = “It is raining.”

B = “ I will stay at home.”

A ⇒ B = “If it is raining, (then) I will stay at

home.”

30F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 31: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

⇔ For ’if and only if ’ also know as double arrow

(A ⇔ B) Can be rewritten like (A ⇒ B) ∧ (B ⇒ A)

Example:

A = “I am late.”

B = “ I miss the bus.”

A ⇒ B = “If I am late, (then) I miss the bus.”

B ⇒ A= “If I miss the bus, (then) I am late.”

31F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 32: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• In logic, the following priority scheme for the connectives is used (the numbers separate here the different priority levels):

1. ¬

2. ∧∨3. ⇒4. ⇔• This means that: ¬ has a higher priority than ∧ or ∨, which in turn have a higher priority than ⇒, which again in turn has a higher priority than ⇔.

32F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 33: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• Examples:(i) One must read ¬A∧ B as (¬A) ∧ B and not as ¬(A ∧ B).

(ii)One must read A∨ B ⇔ B∨ A as (A∨ B) ⇔ (B ∨ A) and not, for example, as (A∨ (B⇔ B)) ∨ A.

(iii)As to A ∧ B∨ C, there is a PROBLEM: ∧ and ∨ have the same priority in the above mentioned priority scheme, hence it is not clear whether one means with this formula (A ∧ B) ∨ C or A ∧ (B ∨ C)???

33F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 34: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• In this course, we will use the priority scheme

• If necessary, we keep the extra parentheses

needed to avoid ambiguity

34F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 35: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

• Examples:

– In the formula A∧ B∨ C, we add parentheses to describe

what we mean exactly. This could be either (A∧ B)∨C or

A∧(B ∨ C).

– We can write the proposition ((A∧ B) ⇒ (¬C)) completely

without parentheses: A∧ B⇒ ¬C.

– But, note that for readability, it is sometimes useful to keep

some parentheses; hence for this example, we may write

(A∧ B) ⇒ ¬C.

– Parentheses remain necessary for distinguishing for instance

between the formulas ¬(A∧ B) and ¬A∧ B.

35F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 36: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

36F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

• More on syntax:

(Basic) Proposition variables (like A, B and C) are

formulas.

(R1): If A is a formula, then so is ( ¬A).

(R2): If A and B are formulas, then so are (A∧B),

(A∨B), (A⇒ B) and (A⇔ B).

Page 37: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

37F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

More on syntax:

• Any formula is a sub-formula of itself

Page 38: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Propositional Logic

Sub-formulas

• We can give formulas/sentences graphically in

the form of trees

• The tree of ((a ∧ b) ⇒ (¬c )):

38F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 39: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Lecture 1

I. Why Logic?

II. What is Logic?

III. Preliminary Concepts

IV. Propositional Logic (Part 1)

39F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof

Page 40: Foundations 1 - HWpav1/Lectures/F29FAy-Foundations 1/Lecture1.pdf · Propositional Logic • Formal logic has as a basic concept the so-called proposition • This is a pure technical

Lecture 2

What’s next?

Propositional Logic (Part 2)

TRUTH TABLES

40F29FAy-Foundations 1-2009/2010 -

Semester 1-Part I-Logic&Proof