(Part 2) Fol

You might also like

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

Artificial Intelligence

Lecture 5
First Order Logic
10-11-2022
Outline

 Pros and cons of proportional logic


 Syntax of FOL
Pros and cons of propositional logic

☺ Propositional logic is declarative


(knowledge and inference are separate, and inference is entirely domain
independent.)
(its semantics is based on a truth relation between sentences and possible worlds.)
☺ Propositional logic allows partial/disjunctive/negated information
 (unlike most data structures and databases)
☺ Propositional logic is compositional:
(In a compositional language, the meaning of a sentence is a function of the meaning of
its parts.)
 For example, the meaning of B1,1  P1,2 is derived from meaning of B1,1 and
of P1,2
Pros and cons of propositional logic

☺ Meaning in propositional logic is context-independent

 (unlike natural language, where meaning depends on context)


Pros and cons of propositional logic

 Propositional logic has very limited expressive power to


concisely describe an environment with many objects.
 (unlike natural language)

 E.g., cannot say "pits cause breezes in adjacent squares“


◼ except by writing one sentence for each square
First-order logic (FOL)
 Whereas propositional logic assumes the world
contains facts.
 first-order logic (like natural language) assumes the
world contains:
 Objects:people, houses, numbers, colors, wars, …
 Relations:
◼ unary relations are called properties: person, red, round,
prime, …
◼ n-ary relations such as brother of, bigger than, owns, …
 Functions: father of, best friend, one more than, plus,

Examples
1. “One plus two equals three.”
Objects: one, two, three, one plus two;
Relation: equals;
Function: plus.
(“One plus two” is a name for the object that is obtained by
applying the function “plus” to the objects “one” and “two.”
“Three” is another name for this object.)
2. “Squares neighboring the wumpus are smelly.”
Objects: wumpus, squares;
Property: smelly;
Relation: neighboring.
Examples
3. “Evil King John ruled England in 1200.”
Objects: John, England, 1200;
Relation: ruled;
Properties: evil, king.
Syntax of FOL: Basic elements
 Constants: KingJohn, Adel, Mona, Red,
Cairo, 2,...
 Predicates Brother, >,...
 Functions Sqrt, Plus, Father,...
 Variables x, y, a, b,...
 Connectives , , , , 
 Equality =
 Quantifiers , 
BNF grammar of sentences in
predicate logic
Sentence → AtomicSentence | ComplexSentence
AtomicSentence → Predicate | Predicate(Term,…) | Term=Term
ComplexSentence → (Sentence) | [Sentence]
|  Sentence
| Sentence  Sentence
| Sentence  Sentence
| Sentence  Sentence
| Sentence  Sentence
| Quantifier Variable Sentence
BNF grammar of sentences in
predicate logic (Cont.)
Term → Function(Term, …)
| Constant
| Variable
Quantifier → ∀ | ∃
Constant → Adel | 3 | A |…
Variable → a | x | y | …
Predicate → True | False | Loves | Raining | …
Function → Mother |…
Operator Precedence : , , , , 
Conventions
 Constant symbols stands for objects;
 Predicate symbols stands for relations (property or n-ary); and
 Function symbols stands for functions.
 As a convention:
 constant symbols, predicate symbols, and function symbols begin with
uppercase letters,
 variables begin with lowercase letter.
 For example, the constant symbols Richard and John; the predicate
symbols Brother , OnHead, Person, King, and Crown; and the
function symbols Mother and Plus.
 The choice of names is entirely up to the user.
 Each predicate and function symbol has an arity that indicates the
number of arguments.
Types of sentences
 Term: constant, variable, function(𝑡𝑒𝑟𝑚1 ,…, 𝑡𝑒𝑟𝑚𝑛 )
 Atomic sentences: predicate(term, term)

𝑡𝑒𝑟𝑚1 = 𝑡𝑒𝑟𝑚2
e.g., Person(Mona)
 Complex sentences

 Combine atomic sentences using connectives


S, S1  S2, S1  S2, S1  S2, S1  S2,
E.g., Sibling(KingJohn,Richard)  Sibling(Richard,KingJohn)
>(1,2)  ≤ (1,2)
>(1,2)   >(1,2)
Truth in first-order logic
 Sentences are true with respect to a model and an interpretation.
 Model contains objects (domain elements) and relations among them.
 The domain of a model is the set of objects or domain elements it contains.

 Interpretation specifies referents for


constant symbols → objects
predicate symbols → relations on objects
function symbols → functional relation on objects

 An atomic sentence predicate(term1,...,termn) is true


iff the objects referred to by term1,...,termn
are in the relation referred to by predicate

You might also like