Download presentation
1
CS-554 Part-3: First-Order Logic
By Dr. Syed Noman Hasany
2
Propositional Logic and limitation
Propositional logic allows us to represent statements about the world using logical symbols. However, propositional logic is limited in its expressiveness. Consider the following examples:
3
Examples In propositional logic the statement ‘Ali loves Makkah’ would simply be represented by a propositional variable, e.g. p. Similarly the statement ‘EveryMuslim loves Makkah’ would also be represented by a propositional variable, e.g. p. And the same is true for the following statement: ‘Some people are scared of heights’. However, all the above statements have obvious differences in the objects to which they are referring.
4
Problem with Propositional Logic
So, the problem with propositional logic is that it treats simple propositions as unanalysed wholes and thus it does not allow us to refer to the objects that are treated by propositions. Consider this further example:
5
Further Example In propositional logic we can only distinguish between propositions such as ‘Saad is a man’ and ‘Waqas is a man’ by using crude propositions such as p1 and p2 When we make a statement about some object, e.g. ‘the sky is blue’, we want to be able to symbolise both the claim and the object about which the claim is made. We have no way of expressing this in propositional logic. So, we turn to first-order predicate logic which does give us some further expressivity…
6
First-Order Logic In first-order logic we call the claim a predicate and we say that we are predicating some property of the object. So, in the previous example of ‘the sky is blue’, the predicate is the ‘is blue’ part and the object is ‘the sky’. As well as stating properties of objects we also wish to talk about relations between objects. For example, in the statement ‘2 is half of 4’, the relation part is ‘is half of’.
7
Quantifiers There are two such quantifiers:
In addition to objects, predicates and relations we also have the quantifiers of first-order logic. To enable us to express statements like ‘All humans are mortal’ and ‘Some people are scared of heights’ predicate logic provides us with quantifiers. There are two such quantifiers: The universal quantifier, which denotes ‘every’ and its symbol is The existential quantifier, which denotes ‘some’ and its symbol is
8
Combining Statements To combine atomic statements to form compound ones we use the same connectives that we have in propositional logic, i.e.: Conjunction (and): Λ Disjunction (or): v Negation (not): ¬ Implication (if..then): → Equivalence (if and only if): ↔
9
Constant and Variable Symbols
The symbols we use to represent objects in first-order logic can be either constants or variables. Constants are objects that never change, for example, natural numbers, e.g. greaterThan(5,2) Variables are objects that are not fixed, for example, loves(x,y)
10
Usage Given the previous definitions, we will now consider how they are used in first-order predicate logic. Consider the statement ‘Waqas is a man’. This may be represented as man(waqas). Similarly, ‘Saad is a man’ can be represented as man(saad). In these examples both ‘w’ (Waqas) and ‘s’ (Saad) are the objects and ‘man’ is the predicate that stands for ‘is a man’. This is known as prefix notation because the object is prefixed by the predicate.
11
Usage For example, the statement ‘Humans are mortal’ can be represented as: human(x) → mortal(x) This reads as: ‘if someone (x) is a human then he/she (x) is mortal’.
12
Usage In predicate logic the statement ‘Humans are mortal’ is understood to mean ‘Every human is mortal’ So, we make use of the universal quantifier and we can symbolise this more precisely as: x (human(x) → mortal(x)) This now reads: ‘for all x, if x is a human, then x is mortal’.
13
Usage Symbolise the statement ‘Some cars are red’ as:
x (car(x) Λ isRed(x)) This now reads as: ‘there exists some x, such that x is a car, and x is red’.
14
Usage (Binary predicate)
The two previous examples involve only one object (i.e. they are unary predicates). We can extend the statements to allow for further objects to be referred to, for example: x (evenNumber(x) → divisible(x,2)) This reads: ‘for all x, such that x is an even number, then x is divisible by 2’. Note: divisible is a binary predicate.
15
FOL (First-order predicate calculus)
Predicate logic includes a richer ontology: -objects (terms) -properties (unary predicates on terms) -relations (n-ary predicates on terms) -functions (mappings from terms to other terms)
16
Usage Statement: ‘Everyone loves someone’ we have: x y loves(x,y)
This reads as: ‘for all x, there exists a y such that x loves y’. Statement: ‘Every natural number is either even or odd’ we have: x (naturalNumber(x) → (even(x) V odd(x))) This reads as: ‘for all x, such that x is a natural number, then x is even or x is odd’.
17
Caution The quantifiers are required to be put in the correct place.
Consider the previous example: ‘Everyone loves someone’ we have: x y loves(x,y) Now consider the statement: ‘There is someone who is loved by everyone’. In this case we have: y x loves(x,y) x y loves(x,y): someone loves all
18
Nested Quantifiers Combinations of universal and existential quantification are possible: Order is important: Everyone is the father of someone. There is a person who has everyone as a father. There is a person who is the father of everyone. Everyone has a father.
19
Quantifiers Have you noticed a specific feature with the use of the quantifiers? Statements involving the universal quantifier () are used with the implication connective (→). Statements involving the existential quantifier () are used with the conjunction connective (Λ). Because statements involving the universal quantifier are read as ‘For all…then…’ And statements involving the existential quantifier are read as ‘Some …are both …and…’
20
Quantifiers and Connectives
Convert to English:: ∀x At(x, Qassim) ⇒ isSmart(x) Everyone at Qassim is smart. ∀x At(x, Qassim) ∧ isSmart(x) Everyone is at Qassim. Everyone is smart. This is probably not what you wanted to write. It’s also a very common mistake. Remember – use ⇒ with ∀, not ∧. ∃x At(x, Qassim) ⇒ isSmart(x) Contrary to what many people think, this statement does not say that there is a person at Qassim who is smart. It says that if there is at least one person who, if he is at Qassim, is also smart. And if he isn’t, who knows. While it’s possible the author meant this, in most cases this is an error. Remember – use ∧ with ∃, not ⇒. Applying implication elimination, you could also write: ∃x ¬At(x, Qassim) ∨ isSmart(x) which means there exists at least one person who either doesn’t go to Qassim or who is smart (whether he’s at Qassim or not). If you build a truth table for this statement you’ll find that it is false when someone attends Qassim and none of them are smart and is true all other times - if there is someone at Qassim who is smart and if nobody attends Qassim. Implicative rules are always true if the antecedent – the if part – is false, with the reasoning that you can’t test the rule and as a result can’t violate it. ∃x At(x, Qassim) ∧ isSmart(x)
21
FOL Grammar Sentence AtomicSentence | Sentence Connective Sentence | Quantifier Variable Sentence | Sentence | (Sentence) AtomicSentence Predicate(Term, Term, ...) | Term=Term Term Function(Term,Term,...) | Constant | Variable Connective | | | Quanitfier | Constant A | John | Car1 Variable x | y | z |... Predicate Brother | Owns | ... Function father-of | plus | ...
22
Connections Between and
The universal and existential quantifiers are connected with each other through negation. e.g., asserting ‘everyone dislikes sprouts’ is the same as asserting ‘there does not exist someone who likes sprouts’, and vice versa. We can express these two equivalent statements as follows. Firstly, for ‘everyone dislikes sprouts’ we have: x ¬likes(x, sprouts) and for ‘there does not exist someone who likes sprouts’, we have: ¬x likes(x, sprouts)
23
Connections Between and
Furthermore, making the assertion ‘everyone likes chocolate’ is the same as asserting ‘there is no-one who does not like chocolate’: Firstly, for ‘everyone likes chocolate’ we have: x likes(x, chocolate) which is equivalent to stating ‘there is no-one who does not like chocolate’, as follows: ¬x ¬likes(x, chocolate)
24
Connections Between and
Laws that define the relationship between the universal and existential quantifiers are as follows: x ¬p ≡ ¬x p ¬x p ≡ x ¬p x p ≡ ¬x ¬p x p ≡ ¬x ¬p This rules are known as DeMorgan’s laws for quantified statements The reasons these connections exist is because the universal quantifier is really a conjunction over the universe of objects, and the existential quantifier is really a disjunction over the universe of objects…
25
Connections Between and
Recall , DeMorgan’s laws for propositional logic are as follows: ¬(p V q) ≡ ¬p Λ ¬q ¬(p Λ q) ≡ ¬p V ¬q there are two more of DeMorgan’s laws, for propositional logic : p V q ≡ ¬(¬p Λ ¬q) p Λ q ≡ ¬(¬p V ¬q) Given that the universal quantifier is a conjunction over the universe of objects, and the existential quantifier a disjunction over the universe of objects, we can see the relation between DeMorgan’s laws for quantified and unquantified statements as follows: x ¬p ≡ ¬x p ¬p Λ ¬q ≡ ¬(p V q) ¬x p ≡ x ¬p ¬(p Λ q) ≡ ¬p V ¬q x p ≡ ¬x ¬p p Λ q ≡ ¬(¬p V ¬q) x p ≡ ¬x ¬p p V q ≡ ¬(¬p Λ ¬q)
26
Functions The use of functions in first-order logic enables us to refer more specifically to unique objects. For example, consider the statement ‘Mary’s mother likes chocolate’. We could represent this in the following way: x (motherOf(x,y) Λ likes(x,z)) However, this could be read as ‘Mary has at least one mother and she likes chocolate’ and it would be better if we could specify that Mary has one unique mother. For this we can make use of functions. Example: likes(motherOf(y),z) or likes(motherOf(Mary), chocolate) Here, the ‘motherOf’ part is the function.
27
Further Examples Here are a few more examples of the use of functions:
loves(motherOf(y),fatherOf(y)) If y represents ‘Mary’ then this statement can be read as ‘Mary’s mother loves Mary’s father’ x (odd(x) → odd(square(x))) If x represents ‘a natural number’ then this statement can be read as ‘The square of an odd number is odd’
28
Inference Rules Quantifiers are changed to propositional formulae and inference is done according to PL.
29
Examples (from sentences to FOL)
All cats are cute. ∀x Cat(x) ⇒ Cute(x) 1a. Cat of Noman is cute. Cute (CatOf(Noman)) All students taking AI are genius. ∀x Student(x) ∧ TakingAI(x) ⇒ Genius(x) Some students taking AI are genius and hardworking. ∃x Student(x) ∧ TakingAI(x) ⇒ Genius(x) ∧ Hardworking(x)
30
Mary’s mother likes chocolate and dislikes milk.
likes(motherOf(Mary), chocolate) ∧ ¬ likes (motherOf(Mary), milk)
31
Examples (from FOL to sentences)
∃s ∀h Student(s) ∧ Taking(s,AI) ∧ HomeworkFor(h,AI) ∧ ¬Hates(s,h) There are some student of AI course who doesn’t hate all of the AI homework. ∀x Mushroom(x) ⇒ ¬( Poisonous(x) ∧ Purple(x) ) There are no mushrooms that are poisonous and purple. (All mushrooms are not purple and poisonous at the same time.) ∃x IsABunny(x) ∧ IsCute(x) There is a bunny who is a cute. (some bunnies are cute)
32
Assign_1:Q.4 Convert the following to FOL predicate calculus:
Every Muslim loves Makkah. All purple mushrooms are poisonous. Sun is not cold. Not every cat likes fish. Every cat that lives in street is not a pet.
33
Assign_1:Q.5 Convert the following into English language sentences.
(∀ x) gardener(x) => likes(x,Sun) "x"y(Parent(x,y) Ù Male(y) Þ Son(y,x)) x (mushroom(x) ^ purple(x)) => ~poisonous ~ x purple(x) ^ mushroom(x) ^ poisonous(x)
34
Software Prolog CLIPS JESS
35
Midterm-1 (20) (without help paper)
Q.1: Fill in the blanks (5) Q.2 Propositional logic (8) Formulae yes/no Proof; having knowledge base using inference rules Entailment using truth table Tautaulogy, contradiction and contingency Q.3 FOL (7) Formula conversion with negation FOL to sentences and vice versa
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.