CS-554 Part-3: First-Order Logic

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Standard Logical Equivalences
L41 Lecture 2: Predicates and Quantifiers.. L42 Agenda Predicates and Quantifiers –Existential Quantifier  –Universal Quantifier 
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
First-Order Logic Chapter 8.
SE Last time: Logic and Reasoning Knowledge Base (KB): contains a set of sentences expressed using a knowledge representation language TELL: operator.
First-Order Logic (FOL) aka. predicate calculus. First-Order Logic (FOL) Syntax User defines these primitives: –Constant symbols (i.e., the "individuals"
Knowledge Representation Methods
Artificial Intelligence Lecture No. 10 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Propositional Calculus A propositional calculus formula is composed of atomic propositions, which area simply statements that are either true or false.
Prolog IV Logic, condensed. 2 Propositional logic Propositional logic consists of: The logical values true and false ( T and F ) Propositions: “Sentences,”
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
1 Problem Solving CS 331 Dr M M Awais Representational Methods Formal Methods Propositional Logic Predicate Logic.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
CS 561, Session Last time: Logic and Reasoning Knowledge Base (KB): contains a set of sentences expressed using a knowledge representation language.
FIRST-ORDER LOGIC FOL or FOPC
Predicate Calculus.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
Propositional Logic Agenda: Other forms of inference in propositional logic Basics of First Order Logic (FOL) Vision Final Homework now posted on web site.
Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?
FIRST ORDER LOGIC Levent Tolga EREN.
Adapted from Discrete Math
Predicates and Quantifiers
Section 1.3: Predicates and Quantifiers
Discrete Mathematics Goals of a Discrete Mathematics Learn how to think mathematically 1. Mathematical Reasoning Foundation for discussions of methods.
The Foundations: Logic and Proofs
Intro to Discrete Structures
Propositions and Truth Tables
Discrete Mathematics and Its Applications
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Logic Introduction to Logic.
First Order Logic Chapter 7. PL is a Weak Representational Language §Propositional Logic (PL) is not a very expressive language because: §Hard to identify.
Atomic Sentences Chapter 1 Language, Proof and Logic.
1st-order Predicate Logic (FOL)
Fall 2002CMSC Discrete Structures1 Let’s get started with... Logic !
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
1 Predicate (Relational) Logic 1. Introduction The propositional logic is not powerful enough to express certain types of relationship between propositions.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, November 2015Introduction & Propositional Logic 1.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.
1 Introduction to Abstract Mathematics Predicate Logic Instructor: Hayk Melikya Purpose of Section: To introduce predicate logic (or.
1 Propositional Logic Introduction. 2 What is propositional logic? Propositional Logic is concerned with propositions and their interrelationships. 
Artificial Intelligence First-Order Logic (FOL). Outline of this Chapter The need for FOL? What is a FOL? Syntax and semantics of FOL Using FOL.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
Propositional Logic Predicate Logic
Propositional & Predicate Calculus _I
For Friday Read chapter 8 Homework: –Chapter 7, exercises 2 and 10 Program 1, Milestone 2 due.
11 Artificial Intelligence CS 165A Tuesday, October 30, 2007  Knowledge and reasoning (Ch 7) Propositional logic  First-order logic (Ch 8) 1.
First-Order Logic Chapter 8 (not 8.1). Outline Why FOL? Why FOL? Syntax and semantics of FOL Syntax and semantics of FOL Using FOL Using FOL Wumpus world.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
1 CS 2710, ISSP 2610 Chapter 8, Part 1 First Order Predicate Calculus FOPC.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
Law of logic Lecture 4.
Knowledge Representation using First-Order Logic
Last time: Logic and Reasoning
CMSC Discrete Structures
CS201: Data Structures and Discrete Mathematics I
1st-order Predicate Logic (FOL)
Predicates and Quantifiers
CSNB234 ARTIFICIAL INTELLIGENCE
Chapter 1: Propositional and First-Order Logic
CS201: Data Structures and Discrete Mathematics I
Logical and Rule-Based Reasoning Part I
First-Order Logic Chapter 8.
1st-order Predicate Logic (FOL)
Presentation transcript:

CS-554 Part-3: First-Order Logic By Dr. Syed Noman Hasany

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:

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.

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:

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…

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’.

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 

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): ↔

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)

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.

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’.

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’.

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’.

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.

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)

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’.

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

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.

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…’

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)

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 | ...

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)

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)

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…

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)

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.

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’

Inference Rules Quantifiers are changed to propositional formulae and inference is done according to PL.

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)

Mary’s mother likes chocolate and dislikes milk. likes(motherOf(Mary), chocolate) ∧ ¬ likes (motherOf(Mary), milk)

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)

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.

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)

Software Prolog CLIPS JESS

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