Lecture-2 PropPred Merged

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

Propositional + Predicate Logic

Lecture 2
Mr. Waqas Ali

Lecturer
Department of Computer Science
UET, Lahore | KSK
Propositional Logic
->When most people say ‘logic’, they mean either propositional logic
or first-order predicate logic.

->However, the precise definition is quite broad, and literally


hundreds of logics have been studied by philosophers, computer
scientists and mathematicians.

Any ‘formal system’ can be considered a logic if it has:

– a well-defined syntax;
– a well-defined semantics; and
– a well-defined proof-theory.
Propositional Logic

•The syntax of a logic defines the syntactically acceptable objects of


the language, which are properly called well-formed formulae (wff).

•The semantics of a logic associate each formula with a meaning.

•The proof theory is concerned with manipulating formulae


according to certain rules.
Propositional Logic

•The simplest, and most abstract logic we can study is called


propositional logic.

•Definition: A proposition is a statement that can be either true or


false; it must be one or the other, and it cannot be both.
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).
• Then, we can apply mathematical reasoning to formulas
Modelling

Pattern:
If p and not q, then r. Not r. p. Therefore q.

We shall study reasoning patterns.


Declarative Sentences
Declarative sentences (we
Non-declarative sentences
can consider whether they’re
(can’t tell whether they’re true
true or not):
or not):
->The sum of the numbers 3
-> Could you please pass the
and 5 equals 8.
salt.
-> Jane reacted violently to
-> Ready, steady, go.
Jack’s accusations.
-> May fortune come your way.
-> Every even natural number
is the sum of two prime
numbers.
-> All Martians like peperoni
on their pizza.

We want to turn declarative sentences into formulas and create a


formalism to manipulate such formulas.
Turning English Phrases into Formulas
Examples
Write propositional logic formulas for these

•It is hot and sunny

•It is not hot

•It is hot or sunny

•It is sunny therefore it is hot


Propositional logic as a formal language

•Formulas in our propositional logic should certainly be strings over


the alphabet {p, q, r, . . .} U {p1, p2, p3, . . .} U {¬,X,V,→, (, )}.

•But this not good enough as it allows strings like (¬)() V pq → to be


a word over that alphabet, which it is not.

•So all formulas needs to be well-formed.


Propositional logic as a formal language

•The well-formed formulas of propositional logic are those which we


obtain by using the construction rules below

•¬: If φ is a well-formed formula, then so is (¬φ).


•X: If φ and ψ are well-formed formulas, then so is (φ X ψ).
•V: If φ and ψ are well-formed formulas, then so is (φ V ψ).
•→: If φ and ψ are well-formed formulas, then so is (φ → ψ).
Propositional logic as a formal language

•Well-formed propositional logic formulas are often given by a


defining grammar in Backus Naur form (BNF). In that form, the
above definition reads more compactly as

φ ::= p | q | r | (¬φ) | (φ X φ) | (φ V φ) | (φ → φ)

•where p stands for any atomic proposition and each occurrence of φ


to the right of ::= stands for any already constructed formula.

•(((¬p) X q) → (p X (q V (¬r)))) ?
Propositional logic as a formal language

Inversion principle means that we can invert the process of


building formulas.

So for this formula (((¬p) X q) → (p X (q V (¬r)))) ?


we can write the step by step rules which were applied.
Propositional logic as a formal language
•Rule 1 φ ::= p | q | r
•Rule 2 φ ::= (¬φ)
•Rule 3 φ ::= (φ X φ)
•Rule 4 φ ::= (φ V φ)
•Rule 5 φ ::= (φ → φ)

•(Using Rule 5) φ ::= (φ → φ)


•(Using Rule 3) φ ::= ((φ X φ) → φ)
•(Using Rule 2) φ ::= (((¬φ) X φ) → φ)
•(Using Rule 1) φ ::= (((¬p) X φ) → φ)
•(Using Rule 1) φ ::= (((¬p) X q) → φ)
•(Using Rule 3) φ ::= (((¬p) X q) → (φ X φ))
•(Using Rule 4) φ ::= (((¬p) X q) → (φ X (φ V φ)))
•(Using Rule 2) φ ::= (((¬p) X q) → (φ X (φ V (¬φ))))
•(Using Rule 1) φ ::= (((¬p) X q) → (p X (φ V (¬φ))))
•(Using Rule 1) φ ::= (((¬p) X q) → (p X (q V (¬φ))))
•(Using Rule 1) φ ::= (((¬p) X q) → (p X (q V (¬r))))
Propositional logic as a formal language
Propositional logic as a formal language

Using the inversion principle write the stepwise derivation for the
formula

(((¬p) X q) → (p v ((¬q) → (¬r)))) ?


Propositional logic as a formal language

->For humans, dealing with brackets is a tedious task but we need


them because formulas really have a tree-like structure

->Brackets become unnecessary in parse tree since the paths and


the branching structure of this tree remove any possible ambiguity in
interpreting φ.

->Note that the parse trees of well-formed formulas have either an


atom as root or the root contains ¬, V, X or →.

->In the case of ¬ there is only one subtree coming out of the root.

->In the cases X, V or → we must have two subtrees, each of which


must behave as just described.
Propositional logic as a formal language

Does this tree represents a well-formed formula?


Propositional logic as a formal language

It represents a well-formed formula


((¬(p V (q → (¬p)))) X r)

->All its leaves are propositional atoms (p twice, q and r).

->All branching nodes are logical connectives (¬ twice, X, V and →)

->The numbers of subtrees are correct in all those cases (one


subtree for a ¬ node and two subtrees for all other non-leaf nodes).
Semantics of propositional logic
->In this section we give an account of relationship between the
premises φ1, φ2, . . . , φn and the conclusion ψ.

->This is based on looking at the ‘truth values’ of the atomic


formulas in the premises and the conclusion; and at how the logical
connectives manipulate these truth values.
Semantics of propositional logic
Semantics of propositional logic
Note that φ → ψ and ¬φ V ψ are semantically equivalent.

->Given a formula φ which contains the propositional atoms p1,


p2, . . . , pn,we can construct a truth table for φ.

The problem is that the truth table has 2n many lines, each line
listing a possible combination of truth values for p1, p2, . . . , pn; and
for large n this task is impossible to complete.

Let us consider the example It involves three propositional atoms (n


= 3 which are p,q,r) so we have 23 = 8 cases to consider.
Semantics of propositional logic
Let consider a case in which q evaluates to F; and p and r evaluate to
T.
Semantics of propositional logic
->Figure below shows a truth table for the formula
(p → ¬q) → (q V¬p).

->The first two columns list all possible combinations of values for p
and q.
Predicate Logic
Predicate Logic
->Propositional logic dealt quite satisfactorily with sentence
components like not(¬), and(X), or(V) and if . . . then(→).

->Predicate logic (also called first-order logic) was developed


because of the limitations of propositional logic for modifiers like
there exists . . . , all . . . , among . . . and only . . .?

->Let us consider the declarative sentence. Can you write it in


propositional logic

Every student is younger than some instructor.


Predicate Logic
•We could identify this assertion with a propositional atom p.
However, that fails to reflect the finer logical structure of this
sentence.

•The statement is about being a student, being an instructor and


being younger than somebody else.

•These are all properties of some sort, so we would like to have a


logic for expressing them together with their logical relationships and
dependences.
Predicate Logic

But we don’t want to write down all instances of S(·) where · is


replaced by every student’s name in turn. Hence we use variable.

Variables are written u, v, w, x, y, z, . . . or x1, y3, u5, . . . and can


be thought of as place holders for concrete values (like a student).
Predicate Logic
•Using variables, we can now specify the meanings of S, I and Y more
formally:

•We need to introduce quantifiers 6 (read: ‘for all’) and E (read:


‘there exists’ or ‘for some’) which always come attached to a
variable, as in 6x (‘for all x’) or in Ez (‘there exists z’, or ‘there is
some z’)
Predicate Logic
•Different predicates can have a different number of arguments. The
predicates S and I have just one (they are called unary predicates),
but predicate Y requires two arguments (it is called a binary
predicate).

•Predicates with any finite number of arguments are possible in


predicate logic.

•Write the formula for

“All birds can fly”


Predicate Logic

•All birds can fly

6x(B(x) → F(x))

What if we can find such a bird who cannot fly? Then this means that
the above statement “All Birds Can Fly” is false

Ex(B(x) X ¬F(x))
Predicate Logic
•Write the formula for

“Not all birds can fly”


Predicate Logic

"Everyone gets a break once in a while”

"All cats have tails”

"Some people like their food cold"

"Everybody has somebody who is his or her mother”

"Some dogs are brown"


Predicate Logic

"Everyone gets a break once in a while”


Let B(x) : x gets a break once in a while
6x B(x)

"All cats have tails”


Let C(x) : x is a cat.
T(x) : x has a tail
6x(C(x) → T(x))

"Some people like their food cold”


P(x) : x like their food cold
Ex P(x)

"Everybody has somebody who is his or her mother”


M (x, y) : x is the mother of y
6yExM(x,y)
Predicate Logic

"Some dogs are brown"


D(x) : x is a dog
B(x) : x is brown
Ex (D(x) X B(x))

You might also like