Sunteți pe pagina 1din 25

Logic and Formal Systems Syllabus

Propositional logic (natural deduction, semantics, soundness and


completeness).
Predicate logic (natural deduction, semantics, undecidability).
Logic programming and the language Prolog.

Temporal logics (LTL, CTL, CTL ).


Model checking and the verier SMV.
Program verication (Floyd-Hoare logic).
Modal logic and agents.
Binary decision diagrams

Slide 1

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Propositional Logic

Motivation for studying Logic: To acquire the ability to model real-life


situations in a way that would allow us to reason about them formally.
Example 1: If the train arrives late and there are no taxis at the station,
then John is late for his meeting. John is not late for his meeting. The
train did arrive late. Therefore, there were taxis at the station.
Example 2: If it is raining and Jane does not have her umbrella with her,
then she will get wet. Jane is not wet. It is raining. Therefore, Jane has
her umbrella with her.
Can we verify the validity of these arguments formally?
We need to turn the English sentences into formulas (modeling).

Slide 2

Then, we can apply mathematical reasoning to formulas

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Modelling

Encoding:
Example 1
p
the train is late
q there are taxis at the station
r John is late for his meeting

Example 2
it is raining
Jane has her umbrella with her
Jane gets wet

Pattern:
If p and not q, then r. Not r. p. Therefore q.
We shall study reasoning patterns.

Slide 3

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Declarative Sentences

Declarative sentences (we can consider whether theyre true or not):

Non-declarative sentences (cant tell


whether theyre true or not):

The sum of the numbers 3


and 5 equals 8.

Could you please pass the salt.

Ready, steady, go.

Every even natural number


is the sum of two prime
numbers.

Slide 4

All Martians like peperoni


on their pizza.

Jane reacted violently to


Jacks accusations.

May fortune come your way.

We want to turn declarative sentences into formulas and create a


formalism to manipulate such formulas.

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Turning English Phrases into Formulas

Atomic sentences:
p: I won the lottery last week.
q: I purchased a lottery ticket.
r: I won last weeks sweepstakes.
Connectives:

: negation p: I did not win the lottery.

: disjunction p r: I won the lottery last week or I won the last weeks
sweepstakes.

: conjunction p r: I won the lottery and the sweepstakes last week.

q: If I won the lottery last week, then I purchased a

Slide 5

Composite formulas: p q
r q ; connective priority,
By this convention, we can remove the brackets: p q
r q.

: implication p
lottery ticket.

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction

Collection of proof rules, which allow to infer new formulas from


existing formulas.
n , we intend to infer a conclusion .

Given the formulas 1


We denote this by

This construct is called a sequent.


Example:
r rp

Slide 6

There is no perfect set of proof rules. You can create your own
(you can even invent your own logic). Such exercise resembles
computer programming.

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Rules Conjunction

p q
r

premise

e2 1

q r

q r

premise

i 3,2

and-elimination

e2

1
2

e1

Example: Prove p q r

and-introduction

Alternate way to write the proof:


e2

q r

Slide 7

p q

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Rules Double Negation and Implication Elimination

Justication:
If it rained, the
street is wet
q: The street is wet

e2 4

q r

premise
premise

i 3,5

e 1,3

e 2,3

premise

e 4,5

e2

q r

i1

Slide 8

premise

q r

premise

p r

q p

q r

Example: p p
r

Example: p

implication
elimination

double negation
introduction

q:

p: It rained

CS4231 Logic and Formal Systems Lecture 01 12/08/04

double negation
elimination

Natural Deduction Rules Implication Introduction

In order to prove
, we make the
temporary assumption of , and then
prove . The scope of the assumption
is indicated by the box.

.
.
.

q r
premise

r
r

Example: p q
1
p q

e 1,4

i 3-5

i 2-6

Slide 9

r
r

into a proof of
1

i 2,3

p q

assumption

Remark: We may transform any proof


of
1
n

assumption

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Implication Introduction Examples

p r

assumption

e1 2

e2 2

q r

e 4,5

e 1,3
i 26

Slide 10

p r

e2 2

premise

q r

e 1,3
i 4,5

p q

e1 2

q r

p r

premise

assumption

p q

Example: p

p q

Example: p

i 26

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Rules Disjunction

assumption

p r

assumption

premise

p r

i2 6

p r

e 2,3-4,5-7

p q

i2 2

p r

i1 3

e 1,5

i 2-8

assumption

i1 4

e 1,2-3,4-5

Slide 11

q
q

premise

p q

assumption

assumption

Example: p q

p q

p r

.
.
.

p q

.
.
.

Example: q

i2

i1

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Rules Negation

, all such for

Contradictions: formulas of the form


mulas shall be denoted by (bottom).

4
5

assumption

e 3,2
e4

assumption

e 1,3

premise

e 2,3

assumption

e 4,5

copy 7

i 3-6

10

11

i 3-5

Slide 12

6
7

premise

e2

premise

premise

p q

q p

Example: p

p q

Example:

i 9-10
e 1,2-6,7-10

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Derived Rules

premise

assumption

i 2-3

e 1,2
i 2-3

assumption

given

i 3-5

Justication: If I am Chinese,
then I am Asian. I am not
Asian. Therefore, Im not Chinese.
Slide 13

e 1,2

RAA (Reductio ad Absurdum)

e 4,2

e 1,3

assumption

.
.
.

premise

premise

MT

e4

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Summary

Basic rules (contd):

.
.
.

i2

RAA
e

.
.
.

MT

LEM

.
.
.

Slide 14

Useful derived rules:

.
.
.

derived

.
.
.

i1

no rule

e2

e1

Elim.

Introd.

Elim.

Introd.

Basic rules:

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Natural Deduction Provable Equivalence

Denition: We say that two formulas and are provably equivalent iff both
and . We denote this by
.

holds.

to mean that

Remark: We could dene


Interesting proof

Statement: There exist irrational numbers a and b such that ab is rational.


Choose b

Proof:

2. We have two cases.


b and the statement is proven.

bb is rational. Then choose a

2.

We have

Slide 15

ab

bb

bb is irrational. Then choose a

2 rational.

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Propositional Logic as a Formal Language

Proofs are in fact proof schemas.

s
r

premise
premise

e 1,2

We can build complicated formulas using our rules.


What exactly are the formulas? We need to dene a
formal language.

r
s

p
q

e 1,2

premise

rr

premise

q p

Denition:
atoms: propositional symbols p, q, p1 , p2 ,
an atom is a well-formed formula (wff)
if and are formulas, then so are , , ,

Slide 16

BNF form: ::

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Syntax Trees

Well-formed formula:

subformula
corresponding to the
left subtree

All subformulas:

q
r
p q

q
p

Slide 17

p
p
r

p
q
r

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Semantics of Propositional Logic Truth Values

The semantics of propositional logic is a mapping


T F

Interpretation : WFF

where T stands for true and F stands for false. The semantics has to
be consitent w.r.t. the connectives , , , and . This consitency is
specied by the following truth table.


F
F
T
F
T
T
F
T
F
T
T
T

T
F

F
T
F
T

F
F
T
T

Truth tables are means of exploring all possible interpretations for a


given formula.

Slide 18

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Truth Table Example

F q T

F
F q

Slide 19

p
T
T
T
T
T
T
T
T

p q

r
T
F
T
F
T
F
T
F

q
T
T
F
F
T
T
F
F

p
T
T
T
T
F
F
F
F

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Semantics of Propositional Logic Sequents

1 2

(which we dont know whether it is

Given a sequent 1 2
valid), we denote by

a new kind of sequent, which is valid if for every semantics S such that
S i
T, i 1
n, we also have that S
T . The relation is
called semantic entailment.

Slide 20

Example: p q

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Intermezzo Mathematical Induction

1. Indeed, 1

12
2 .

(Base case) We prove the statement for n

? Answer: Mathematical

n n 1
2

How do we prove that 1


induction.

(Induction case) We assume that the statement is true for some general
value of n, and we show that it implies the statement for n 1. In other
words, we prove that

n 1

1 2

1 2

n n 1
2

Indeed

Slide 21

n n 1
2

CS4231 Logic and Formal Systems Lecture 01 12/08/04

General Mathematical Induction Principle

Given a statement n that depends on a natural number n, and whose


validity we want to prove for all possible values of n, we proceed in the
following two steps:

Base case: prove that 1 holds.

Induction case: prove that n


n 1 , for all natural numbers n. When proving such a statement, we call n the induction
hypothesis.

Slide 22

These two conditions prove n for all n.

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Course of Values Induction

Given a statement n that depends on a natural number n, and whose


validity we want to prove for all possible values of n, we proceed in the
following two steps:

Base case: prove that 1 holds.

Induction case: prove that 1 2


n
n 1,
for all natural numbers n. When proving such a statement, we call
1 2
n the induction hypothesis.

Slide 23

These two conditions prove n for all n.

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Course of Values Induction Example

Denition: Given a well-formed formula , we dene its height to be 1 plus the


length of its largest path of its parse tree.
Theorem: For every well-formed propositional logic formula, the number of left
brackets is equal to the number of right brackets.
Proof: Denote by n the statement all formulas of height n have the same
number of left and right brackets.

Base case: n 1. 1 applies to all propositional formulas p, q, . . . and


obvioulsy holds.

Induction case: n 1. Then the root of the parse tree of is one of


the connectives , , , . We assume that it is
(the other cases are
proved in a similar manner.) Then 1 2 for some wffs 1 and 2 ,
whose heights are strictly smaller than n. Using the induction hypothesis,
the number of left and right brackets is equal for both 1 and 2 . adds
only two brackets, one and one . Therefore, the statement is correct.

Slide 24

CS4231 Logic and Formal Systems Lecture 01 12/08/04

Soundness and Completeness of Propositional Logic

When we dene a logic (or any type of calculus), we want to show that
it is useful.
Soundness: Formulas that we derive using the calculus reect a
real truth.

Completeness: Every formula corresponding to a real truth can


be inferred using the rules of the calculus.

In the case of propositional logic, given the wffs 1 , 2 , . . . , n , and ,


we have
n

holds, then 1

holds.
n

holds, then 1

Slide 25

Completeness: if 1
holds.

Soundness: if 1

CS4231 Logic and Formal Systems Lecture 01 12/08/04

S-ar putea să vă placă și