First Order Logic
First Order Logic
[email protected] https://sites.google.com/view/nsaini
Contents
• More on Representation
• Syntax and Semantics of First-Order Logic
• Using First Order Logic
• Knowledge Engineering in First-Order
Logic
2
Propositional logic
• Logical constants: true, false
• Propositional symbols: P, Q, S, ... (atomic
sentences)
• Wrapping parentheses: ( … )
• Sentences are combined by connectives:
...and [conjunction]
...or [disjunction]
...implies [implication / conditional]
..is equivalent [biconditional]
...not [negation]
• Literal: atomic sentence or negated atomic sentence
Examples of PL sentences
• P means “It is hot.”
• Q means “It is humid.”
• R means “It is raining.”
• (P Q) R
“If it is hot and humid, then it is raining”
• QP
“If it is humid, then it is hot”
Limitations of propositional logic
• No notion of objects
• No notion of relations among objects
• RoommateCarryingUmbrella0 is instructive to us,
suggesting
– there is an object we call Roommate,
– there is an object we call Umbrella0,
– there is a relationship Carrying between these two objects
7
Elements of first-order logic
9
Logics in General
Language Ontological Epistemological
Commitment Commitment
Propositional Logic Facts True / False /
Unknown
First-Order Logic Fact, objects, relations True / False /
Unknown
Temporal Logic Facts, objects, True / False /
relations, times Unknown
Probability Theory Facts Degree of belief
[0,1]
Fuzzy Logic Degree of truth Known interval value
[0,1]
10
Two main parts of FOL
• As a natural language, first-order logic
also has two main parts:
– Syntax
– Semantics
11
Syntax of First-Order Logic
• Constants 2, A,1,John,cat,…
• Predicates Brother, Father, >, …
• Functions Sqrt, LeftArmOf, …
• Variables x, y, a, b, …
• Connectives ¬
• Equality ==
• Quantifiers $"
12
Components of First-Order Logic
• Term
– Constant, e.g. Red
– Function of constant, e.g. Color(Block1)
• Atomic Sentence
– represent atomic sentences as Predicate (term1,
term2, ......, term n).
– Predicate relating objects (no variable)
• John and Richard are brothers: => Brother (John, Richard)
• Married (Mother(John), Father(John))
• Complex Sentences
– Atomic sentences + logical connectives
• Brother (John, Richard) Brother (John, Father(John))
13
Components of First-Order Logic
• Quantifiers
– These are the symbols that permit to determine or
identify the range and scope of the variable in the
logical expression.
– Two quantifiers:
• Universal Quantifier, (for all, everyone, everything)
• Existential quantifier, (for some, at least one).
– Example:
• All man drink coffee
• ∀x man(x) -> drink(x, coffee)
15
Components of First-Order Logic
• Existential quantifier “there exists” $
– The expression is true for at least one value of the
variable
– Example:
• Some boys are intelligent.
16
Some Examples of FOL using Quantifiers
17
Semantics in PL – Some Informal Definitions
• Example:
– Suppose v is an assignment for which
v(p) = F, v(q) = T. [here, p and q are
formulas]
– If A = (¬p → q) ↔ (p V q), what is v(A)?
Solution:
v(A) = v((¬p → q) ↔ (p V q))
= v(¬p → q) ↔ v(p V q)
= (v(¬p) → v(q)) ↔ (v(p) V v(q))
= (¬v(p) → v(q)) ↔ (v(p) V v(q))
= (¬F → T) ↔ (F V T)
= (T → T) ↔ (F V T)
= T↔T
= T
Models and Satisfiability
• Relevant properties:
– If U is satisfiable, then so is U − {Ai} for any i = 1, 2,…, n
– If U is satisfiable and B is valid, then U U {B} is also satisfiable
– If U is unsatisfiable and B is any formula, U U {B} is also unsatisfiable
– If U is unsatisfiable and some Ai is valid, then U − {Ai} is also unsatisfiable
Truth in First-Order Logic
• Sentences are true with respect to a model and an
interpretation
• Model contains >= 1 object (domain elements) and
relations among them
• Interpretation specifies referents for
– constant symbols -> objects
– predicate symbols -> relations
– function symbols -> functional relations
22
First-Order Logic Example
23
Examples
• Everyone likes McDonalds
– "x, likes(x, McDonalds)
27
Fun with Sentences
• Brothers are siblings
"x,y Brother(x,y) Sibling(x, y)
• Sibling is “symmetric”
"x,y Sibling(x,y) Sibling(y, x)
28
Other Comments About
Quantification
• To say “everyone likes McDonalds”, the following is too
broad!
– "x, likes(x, McDonalds)
29
Equality
• We allow the usual infix = operator
– Father(John) = Henry
– "x,y sibling(x, y) (x=y)
30
Knowledge Engineering in First-order logic
31
Review --- Knowledge engineering in FOL
1. Identify the task
Possible queries:
-does the circuit function properly?
-what gates are connected to the first input terminal?
-what would happen if one of the gates is broken? and
so on
The electronic circuits domain
1. Identify the task
– Does the circuit actually add properly?
3. Decide on a vocabulary
– 1≠0
Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),In(1,X1))
Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),In(1,A1))
Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),In(2,X1))
Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),In(2,A1))
Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1),In(2,X2))
Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2))
The electronic circuits domain
6. Pose queries to the inference procedure
What are the possible sets of values of all the terminals for the adder
circuit?
• https://www.cpp.edu/~ftang/courses/CS420/not
es/FOL.pdf
• https://www.ics.uci.edu/~rickl/courses/cs-171/0-
ihler-2016-fq/Lectures/Lathrop/cs-171-14-FOL-
Knowledge-Engineering_smr16.pdf
39
Thank You!!!
Any Queries:
[email protected]
40