using-predicate-logic
using-predicate-logic
First-OrderLogic
• First-orderlogicisanotherwayofknowledgerepresentationin
artificial intelligence. It is an extension to propositional logic.
• FOL is sufficiently expressive to represent the natural
language statements in a concise way.
• First-order logic is also known as Predicate logic or First-
orderpredicatelogic.First-orderlogicisapowerfullanguage
thatdevelopsinformationabouttheobjectsinamoreeasyway and
can also express the relationship between those objects.
• First-order logic (like natural language) does not only assume
that the world contains facts like propositional logic but also
assumes the following things in the world:
• Objects: A, B, people, numbers, colors, wars, theories,
squares, pits, ......
• Relations: It can be unaryrelationsuchas: red,round,is
adjacent, or n-any relation such as: the sister of, brother
of, has color, comes between
• Function:Fatherof,bestfriend,thirdinningof,endof,
......
• A quantifier is a language element which generates
quantification, and quantification specifies the quantity of
specimen in the universe of discourse.
• These are the symbols that permit to determine or identify the
range and scope of the variable in the logical expression.
1. UniversalQuantifier,(forall,everyone,everything)
2. Existentialquantifier,(forsome,atleastone).
1. Universal Quantifier
• Universal quantifier is a symbol of logical representation,
which specifies that the statement within its range is true for
resembles an inverted A.
• Note:Inuniversalquantifierweuseimplication"→".
• Ifxis avariable,then∀x isreadas:
• Forallx
• Foreachx
• Foreveryx.
Ex-
Allman drink coffee.
∀xman(x)→drink(x,coffee).
2. ExistentialQuantifier
• Existential quantifiers are the type of quantifiers, which
express that the statement within its scope is true for at least
2. MarcuswasaPompeian.
Pompeian(Marcus).
∀x:Pompeian(x) ->Roman(x).
3. AllPompeianswere Romans.
4. Caesarwasa ruler.
Ruler(Caesar).
∀x:Roman(y)->(LoyalTo(x,Caesar)∨Hate(x,Caesar))
5. AllRomanswereeitherloyaltoCaesar orhated him.
∀x :->y :LoyalTo(x,y)
6. Everyoneisloyaltosomeone.
∀x:∀y:Person(x)∧Ruler(y)∧TryAssassinate(x,y))->
7. Peopleonlytrytoassassinaterulerstheyaren'tloyalto.
¬LoyalTo(x,y)
8. MarcustriedtoassassinateCaesar.
TryAssassinate(Marcus,Caesar).
RepresentingInstanceandIsaRelationships
• Logic statements, containing subject, predicate, and object,
were explained. Also stated, twoimportantattributes "instance"
and "isa", ina hierarchical structure.
Ex-
Asimplesentencelike"Joe isa musician"
Ex-
1. Marcuswasaman.
man(Marcus).
2. Marcuswas Pompeian.
Pompeian(Marcus).
3. Marcuswasbornin40A.D.
born(Marcus,40).
∀x:man(x) →mortal(x).
4. Allmenaremortal.
∀x∀t1∀t2:mortal(x)/\born(x,t1)/\gt(t2-t1,150)→ dead(x,t2)
6. Nomortalliveslongerthan150 years.
7. Itisnow1991.
now=1991.
∀x ∀t: [alive(x,t)
8. Alivemeansnotdead.
→ ~dead(x,t)] /\ [~dead(x,t)
→alive(x,t)]
∀x∀t1∀t2:died(x,t1)/\gt(t2,t1)→dead(x,t2).
9. Ifsomeonedies,heis deadatalllatertimes.
Ex-“IsMarcusalivenow?”.
~alive(Marcus,now)
↓8
~[~dead(Marcus,now)]
↓negationoperation
dead(Marcus,now)
↓9
died(Marcus,t1)/\gt(now,t1)
↓5
erupted(volcano,79)/\Pompeian(Marcus)/\gt(now,79)
↓fact,2
gt(now,79)
↓
gt(1991,79)
↓computegt nil
Resolution
• Resolution proves facts and answers queries by refutation. This
involves assuming the fact/query is untrue and reaching a
contradiction which indicates that the oppositemust be true. The
wffs must firstly be firstly converted to clause form before using
resolution.
Algorithm:ConvertingwffstoClauseForm
1. Remove all implies, i.e. → by applying the following: a → b is
equivalent to ~a \/ b.
2. Usethefollowingrulestoreducethescopeofeachnegationoperator
to a single term:
• ~(~a)= a
• ~(a/\b)= ~a\/~b
• ~(a\/b)= ~a/\~b
~∀x: p(x)=∃x:~p(x)
~∃x:p(x)=∀x:~p(x)
4. Moveallquantifiers,inorder,totheleftofeach wff.
6. Drop thequantifierprefix.
7. Apply the associative property of disjunctions: a \/ (b \/ c) =(a
\/ b) \/ c and remove brackets giving a \/ b \/ c.
9. Createaseparateclausefor eachconjunction.
1. Convertthewffs toclauseform.
3. Repeat
i. Selecttwo clauses.
ii. Resolvetheclausesusingunification.
iii. If the resolvent clause is the empty clause, then a
contradiction has been reached. If not add the resolvent to
the set of clauses.
Consider thefollowing wffs:
1. man(Marcus).
man(Marcus).
2. Pompeian(Marcus).
Pompeian(Marcus).
3. ∀x:Pompeian(x) →Roman(x).
~Pompeian(x)\/Roman(x).
4. ruler(Caesar).
ruler(Caesar).
5. ∀x:Roman(x)→loyalto(x,Caesar)\/hate(x,Caesar).
~Roman(x1)\/loyalto(x1,Caesar)\/hate(x1,Caesar).
6. ∀x∃y:loyalto(x,y)
loyalto(x2,s1(x2))
8. tryassassinate(Marcus,Caesar).
tryassassinate(Marcus,Caesar).
9. ∀x:man(x) →person(x)
~man(x4)\/person(x4)
• wewant toprovethatMarcushatesCaesar.
• Wefirstlyconvertthistoawff:hate(Marcus,Caesar).