Vous êtes sur la page 1sur 17

CPE222 Discrete Structures

Lecture Notes

Lecture 4
First Order Logic
Propositional Logic
proposition - a statement which is true or false
Ex: 2+3=7 False (preposition)
Man is Mortal", it returns truth value TRUE (preposition)
"12 + 9 = 3 2", it returns truth value FALSE (preposition)
"A is less than 2". (not preposition) It is because unless we give a specific value of A,
we cannot say whether the statement is true or false

In Propositional Logic, there are two types of sentences - simple


sentences and compound sentences.
Simple sentences (P, Q, R) express ''atomic'' propositions about world

Compound sentences are formed from two or more simple sentences


Precedence levels of logical operators , , , ,
Ex: What is the value expression when p=T, q=F and r=F
pqr =TFF=FF=F
pqr =TFF=TF=F
Convert sentence into prepositional logic statement
Generally AND ( ^ )will come when and, but, since comes in sentence
OR ( v )will come when or / either comes in sentence
NOT ( )will come when not does not comes in sentence
IMPLY ( )will come when following comes in sentence

Equivalence ( )will come when if and only if comes in sentence


Inverse, Converse, and Contra-positive
Implication / if-then () is also called a conditional statement. p q
It has two parts- Hypothesis , p and Conclusion , q
Ex: If you read then you get A grade
Here, " you read " is hypothesis, p, and "you get A grade" is conclusion, q

Inverse: An inverse of conditional statement is negation of both hypothesis


and conclusion.
If statement is If p, then q, inverse is If not p, then not q. p q is !p !q
Ex: for above statement; If you do not read then you do not get A grade

Converse: The converse of conditional statement is computed by interchanging


hypothesis and conclusion.
If statement is If p, then q, converse is If q, then p. p q is q p
Ex: for above statement; If you get A grade then you read

Contra-positive: The contra-positive of conditional is computed by interchanging


hypothesis and conclusion of inverse statement.
If statement is If p, then q, contra-positive is If not q, then not p. p q is !q !p
Ex: for above statement; If you do not get A grade then you do not read

- only contrapositive always has the same truth value as p q


Convert sentence into prepositional logic statement (contd..)
1) It is hot and sunny
A - It is hot B - It is sunny A^B
2) If it is humid then it will rain (or) It will rain if it is humid (or) It will rain only if it is
humid (or) It will rain when it is humid (or) it will rain whenever it is humid
A - It is humid B - It will rain A B
3) Ali is boy -- boy(ali)
4) Cat chases mice or bird but not at same time
A - Cat chases mice B - Cat chases bird (A v B ) ^ (A ^ B )
5) Ali is math teacher but not computer teacher
A - Ali is math teacher B - Ali is computer teacher A ^ B
6) Ali is healthy and wealthy but not wise
A - Ali is healthy B - Ali is wealthy C Ali is wise (A ^ B ) ^ C
7) If Ali brings new house then he either sell old house or took loan
A - Ali bring new house B - Ali sell old house C- Ali took loan A (B v C)
Convert prepositional logic statement into sentence

Ex: Let p and q be the propositions


p : I bought a lottery ticket
q : I won million dollar jackpot
Express each of these propositions as an English sentence
(a) p q (b) p^q (c) p^ q (d) p ^ q (e) p q (f)!p
Either I bought a lottery ticket or I won million dollar jackpot
I bought a lottery ticket and I won million dollar jackpot
I bought a lottery ticket and I do not won million dollar jackpot
I do not bought a lottery ticket and I do not won million dollar jackpot
If I bought a lottery ticket, then I won million dollar jackpot
I did not bought a lottery ticket
Predicate Logic (First order logic)
- Propositional logic deals with facts (T or F) ,
- Propositional logic cannot adequately express the meaning of all
statements in mathematics and in natural language
- Predicate Logic deals with facts / objects / relations
- Predicate Logic deals with predicates, which are propositions
containing variables
Ex: Statement x is greater than 3 has two parts.
The first part, variable x, is subject (object) of statement
The second partpredicate, is greater than 3refers to a property that the
subject of the statement can have
Ex - x is student -- student(x) student predicate x subject (object)

A predicate is an expression of one or more variables defined on some specific


domain.
A predicate with variables can be made a proposition by either assigning a value
to variable or by quantifying variable
Ex: x>5 (if x=1 false, if x=10 true)
Capital(X,saudi) (if Riyadh true; if abha false)
Quantifiers
- Quantification expresses the extent to which a predicate is true over a range of
elements.
- In English, the words all, some, many, none, and few are used in quantifications.

two types of quantification:


(i) universal quantification, which tells us that a predicate is true for every (all)
element under consideration
x P(x) is read as for all value of x, P(x) is true
Ex: Fruit is sweet" can be transformed into the propositional form x P(x) where
P(x) is predicate which denotes x is sweet and universe of discourse is all fruit
Generally for universal ( ) statements IMPLY will come ( )

(ii) existential quantification, which tells us that there is one or more element under
consideration for which the predicate is true
x P(x) is read as for some values of x, P(x) is true
Ex: "Some students are good" can be transformed into the propositional form x
P(x) where P(x) is predicate which denotes x is good and is some students universe
of discourse
Generally for existential ( ) statements AND will come ( ^ )
Examples of First order logic
1) john likes cricket or football
likes(john, cricket) v likes(john, football)
2) john lives in a house and the colour of the house is green
lives(john,house) ^ colour(house,green)
3)if car belongs to john then it is green
belongs(car,john) colour(car,green)
4)john did not write JAVA
write(john,JAVA)
5)all elephants are grey
x [elephants(x) colour(x, grey)]
6)all computer students are brilliant
x [computer students(x) brilliant(x)]
7)john likes all kinds of foods
x [food(x) likes(john,x)]
8)everyone who is both strong and intelligent will succeed in his carrier
x [person(x) ^ strong(x) ^ intelligent(x) succeeds(x,carrier)]
9)there is person who wrote computer chess
X[person(x) ^ wrote(x, computer chess)]
Examples of First order logic (cont)
10) all courses in CEdepartment are easy
x [courses(x) CE department(x, easy)]
11)chicken is food -- food(chicken)
12)bill eats peanuts and is still alive
eats(bill,peanuts)^alive(bill)
13)sue eats everything that bill eat
x : eats(bill,x) eats(sue,x)
14)The last meeting of the club was at toms house
last meeting(club, toms house)
15)ali is not married married(ali)
16)Every country has exactly one ruler
x : y: country(x) ^ruler(y)
17)A grand parent is parent of ones parent
x : y : z parent(z,y)^parent(y,x) grand parent(z,x)
18)Every one is loyal to some one
x : y: loyal to(x,y)
19)All pompieans were romans
x : pompieans(x) romans(x)
Examples of Predicate logic (cont)
20) Bill takes either analysis or geometry
takes(bill, analysis) v takes(bill, geometry)
21) Bill takes analysis if and only if he does not take geometry
takes(bill, analysis) takes(bill, geometry)
22) Some students loves bill
x[student(x) ^ loves(x, bill)]
23) All students loves bill
x [student(x) loves(x, bill)]
24) All students are smart
x [student(x) smart(x)]
25) All graduating students are happy
x [GRstudent(x) happy(x)]
26) All happy people smile
x [happyPeople(x) smile(x)]
27) Someone is graduating
x[graduating (x)]
28) Someone is smiling
x[smiling (x)]

Vous aimerez peut-être aussi