Unit-3
Syllabus:
First-Order Logic:syantax and symantics of fol,Extensions
and notational variations using fol,Representing Change in the
world,deducing hidden properties of the world,interface in
fol,inference rules in involving quantifiers,An example
proof,Generalized Modus pones,Forward and backward
chaining,Completeness,Resolution,Completeness of Resolution
First-Order Logic in Artificial
intelligence
In the topic of Propositional logic, we have seen that how to
represent statements using propositional logic. But unfortunately, in
propositional logic, we can only represent the facts, which are either
true or false. PL is not sufficient to represent the complex sentences
or natural language statements. The propositional logic has very
limited expressive power. Consider the following sentence, which we
cannot represent using PL logic.
o "Some humans are intelligent", or
o "Sachin likes cricket."
To represent the above statements, PL logic is not sufficient, so we
required some more powerful logic, such as first-order logic.
First-Order logic:
o First-order logic is another way of knowledge representation in
artificial intelligence. It is an extension to propositional logic.
o FOL is sufficiently expressive to represent the natural language
statements in a concise way.
o First-order logic is also known as Predicate logic or First-order
predicate logic. First-order logic is a powerful language that
develops information about the objects in a more easy way and can
also express the relationship between those objects.
o 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:
o Objects: A, B, people, numbers, colors, wars, theories,
squares, pits, wumpus, ......
o Relations: It can be unary relation such as: red, round,
is adjacent, or n-any relation such as: the sister of, brother
of, has color, comes between
o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:
a. Syntax
b. Semantics
Syntax of First-Order logic:
The syntax of FOL determines which collection of symbols is a
logical expression in first-order logic. The basic syntactic elements
of first-order logic are symbols. We write statements in short-hand
notation in FOL.
Basic Elements of First-order logic:
Following are the basic elements of FOL syntax:
Constant 1, 2, A, John, Mumbai, cat,....
Variables x, y, z, a, b,....
Predicates Brother, Father, >,....
Function sqrt, LeftLegOf, ....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Atomic sentences:
o Atomic sentences are the most basic sentences of first-order logic.
These sentences are formed from a predicate symbol followed by a
parenthesis with a sequence of terms.
o We can represent atomic sentences as Predicate (term1,
term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi,
Ajay).
Chinky is a cat: => cat (Chinky).
Complex Sentences:
o Complex sentences are made by combining atomic sentences using
connectives.
First-order logic statements can be divided into two parts:
o Subject: Subject is the main part of the statement.
o Predicate: A predicate can be defined as a relation, which binds
two atoms together in a statement.
Consider the statement: "x is an integer.", it consists of two
parts, the first part x is the subject of the statement and second part
"is an integer," is known as a predicate.
Quantifiers in First-order logic:
o A quantifier is a language element which generates quantification,
and quantification specifies the quantity of specimen in the universe
of discourse.
o These are the symbols that permit to determine or identify the
range and scope of the variable in the logical expression. There are
two types of quantifier:
a. Universal Quantifier, (for all, everyone, everything)
b. Existential quantifier, (for some, at least one).
Universal Quantifier:
Universal quantifier is a symbol of logical representation, which
specifies that the statement within its range is true for everything or
every instance of a particular thing.
The Universal quantifier is represented by a symbol ∀, which
resembles an inverted A.
Note: In universal quantifier we use implication "→".
If x is a variable, then ∀x is read as:
o For all x
o For each x
o For every x.
Example:
All man drink coffee.
Let a variable x which refers to a cat so all x can be represented in
UOD as below:
∀x man(x) → drink (x, coffee).
It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that
the statement within its scope is true for at least one instance of
something.
It is denoted by the logical operator ∃, which resembles as inverted
E. When it is used with a predicate variable then it is called as an
existential quantifier.
Conjunction symbol (∧).
Note: In Existential quantifier we always use AND or
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it
will be read as:
o There exists a 'x.'
o For some 'x.'
o For at least one 'x.'
Example:
Some boys are intelligent.
∃x: boys(x) ∧ intelligent(x)
It will be read as: There are some x where x is a boy who is
intelligent.
Points to remember:
The main connective for universal quantifier ∀ is implication →.
The main connective for existential quantifier ∃ is and ∧.
o
o
Properties of Quantifiers:
In universal quantifier, ∀x∀y is similar to ∀y∀x.
In Existential quantifier, ∃x∃y is similar to ∃y∃x.
o
∃x∀y is not similar to ∀y∃x.
o
o
Some Examples of FOL using quantifier:
1. All birds fly.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as
∀x bird(x) →fly(x).
follows.
2. Every man respects his parent.
In this question, the predicate is "respect(x, y)," where x=man,
Since there is every man so will use ∀, and it will be represented as
and y= parent.
∀x man(x) → respects (x, parent).
follows:
3. Some boys play cricket.
y= game. Since there are some boys so we will use ∃, and it will
In this question, the predicate is "play(x, y)," where x= boys, and
∃x boys(x) → play(x, cricket).
be represented as:
4. Not all students like both Mathematics and Science.
In this question, the predicate is "like(x, y)," where x= student,
Since there are not all students, so we will use ∀ with negation,
and y= subject.
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x,
so following representation for this:
Science)].
5. Only one student failed in Mathematics.
In this question, the predicate is "failed(x, y)," where x=
student, and y= subject.
Since there is only one student who failed in Mathematics, so we will
∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y)
use following representation for this:
[¬(x==y) ∧ student(y) → ¬failed (x, Mathematics)].
Free and Bound Variables:
The quantifiers interact with variables which appear in a suitable
way. There are two types of variables in First-order logic which are
given below:
Free Variable: A variable is said to be a free variable in a formula if
it occurs outside the scope of the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
Bound Variable: A variable is said to be a bound variable in a
formula if it occurs within the scope of the quantifier.
Example: ∀x [A (x) B( y)], here x and y are the bound
variables.
Semantics of First-Order Logic
Semantics in first-order logic deals with the
interpretation of sentences and formulas within the
framework of a mathematical model. It provides a way to
assign meanings to the symbols and structures used in
first-order logic.
Key Elements of Semantics in First-Order Logic
Variables: These represent placeholders for
objects or elements within a domain.
Constants: These represent specific elements
within the domain.
Predicates: These are expressions that can be true
or false depending on the objects they're applied to.
Functions: These map elements from the domain
to other elements in the domain.
Quantifiers: Such as "for all" (∀) and "exists" (∃),
used to express universal and existential
quantification, respectively.
Interpretation in First-Order Logic
The semantics of first-order logic involve defining what
makes a formula true or false in a given interpretation (also
called a model). An interpretation consists of:
A domain of discourse: This is the set of objects
over which the variables range.
Interpretations of constants: Each constant is
mapped to an element in the domain.
Interpretations of predicates: These are
mappings that determine whether a predicate holds
true for a particular tuple of objects from the
domain.
Interpretations of functions: These mappings
assign values to functions based on the values of
their arguments.
The truth of a sentence or formula in first-order logic is
determined by evaluating it within a specific interpretation.
This is done recursively, where the truth of atomic formulas
(predicates applied to terms) is determined based on the
interpretation of predicates and the values of the terms.
Universal quantification (∀) asserts that a
statement holds true for all objects in the domain.
Existential quantification (∃) asserts that there
exists at least one object for which the statement is
true.
Overall, semantics in first-order logic provides a formal
framework for understanding how to assign meaning to
expressions and how to determine their truth values within
a given interpretation.
Satisfaction in First-Order Logic
Definition: A formula is said to be satisfied by an
interpretation if, under that interpretation, the
formula evaluates to true.
Symbolic Notation: M⊨ϕ, where M is an
interpretation and ϕ is a formula.
Atomic Formulas
An atomic formula P(t₁, t₂, ..., tₙ) is satisfied by an
interpretation if the objects assigned to the terms make the
predicate P true.
Complex Formulas
The satisfaction of complex formulas is determined
recursively based on the satisfaction of their constituent
parts, considering logical connectives and quantifiers. For
example, a conjunction ϕ∧ψ is satisfied if both ϕ and ψ are
satisfied.
A universally quantified formula ∀xϕ(x) is satisfied if
Quantifiers
An existentially quantified formula ∃xϕ(x) is
ϕ(x) is satisfied for all objects in the domain.
satisfied if ϕ(x) is satisfied for at least one object in
the domain.
Validity in First-Order Logic
Definition: A formula is considered valid if it is
satisfied by every interpretation, meaning it holds
Symbolic Notation: ⊨ϕ, meaning ϕ is valid.
true universally.
1. ∀x(P(x)→Q(x)) is valid if, under every interpretation,
Examples
2. ∃xP(x) is satisfied if there exists at least one object
whenever P(x) holds true, Q(x) also holds true.
in the domain for which P(x) holds true.
Relationship between Satisfaction and Validity
A formula is valid if and only if its negation is
unsatisfiable. In other words, a formula is valid if
there is no interpretation that makes it false.
If a formula is valid, it is satisfied by every
interpretation.
If a formula is satisfied by a specific interpretation,
it does not necessarily mean it is valid unless it
holds true under all possible interpretations.
First-order logic (FOL) can be extended and its notation varied,
including using different symbols for logical connectives and
quantifiers, and introducing new symbols for specific domains, while
maintaining the core principles of FOL.
Notational Variations:
Logical Connectives:
Conjunction: ∧ (and) can be represented
by &, Kpq (Polish notation), or a middle dot ⋅.
o
o Disjunction: ∨ (or) can be represented by ∨, Apq (Polish
notation), or a double bar ||.
o Negation: ¬ (not) can be represented by ~, Np, or Fp.
Implication: → (if...then) can be represented
by ⊃ or Cpq (Polish notation).
o
Biconditional: ↔ (if and only if) can be represented
o
by ≡ or Epq (Polish notation).
Quantifiers:
o Universal Quantification: ∀ (for all).
o Existential Quantification: ∃ (there exists).
Parentheses and Brackets: The choice of these symbols can
vary depending on context.
Variables: Lowercase letters at the end of the alphabet
(e.g., x, y, z) are used, with subscripts for distinction
(e.g., x0, x1).
Equality: = (or sometimes ≡) is used for equality.
Extensions:
Function Symbols:
Functions can be introduced, allowing for the creation of terms
like f(t1, ..., tn), where f is a function symbol and t1, ...,
tn are terms.
Predicates with Arity:
Predicates can take arguments, and the number of arguments is
called arity (e.g., P(x, y) where P is a predicate with arity 2).
Equality Axioms:
Axioms can be added to define the properties of equality, such as
reflexivity, symmetry, and transitivity.
Many-Sorted Logic:
This extension allows for different sorts (types) of objects, which
can be useful for representing complex domains.
Infinitary Logic:
This extension allows for quantifiers that range over infinite sets
of variables or formulas.
Higher-Order Logic:
This extension allows quantification over predicates and
functions, which can be useful for expressing more complex
properties
Representing change in the world
In First-Order Logic (FoL), representing change in the world involves modeling dynamic
situations where the state of the world changes over time. This is often referred to as
temporal logic or action-based logic, which goes beyond basic First-Order Logic to model
change.
However, we can still use First-Order Logic to represent change by incorporating time or
events into the representation. The key challenge is to represent how the properties of
objects and relationships evolve over time.
Here are some strategies for representing change in First-Order Logic (FoL):
1. Using Time Points or Time Indices
One common approach is to introduce time indices or time points to indicate when certain
facts hold true. The idea is that each formula or predicate is associated with a particular time
point.
Example:
Let’s say we have the following scenario:
A person JohnJohnJohn becomes a student at time t1t_1t1 and stops being a
student at time t2t_2t2.
We could represent this with the following predicates:
Student(John,t1)\text{Student}(John, t_1)Student(John,t1) — John is a student at
time t1t_1t1.
¬Student(John,t2)\neg \text{Student}(John, t_2)¬Student(John,t2) — John is not a
student at time t2t_2t2.
In this way, change is captured by associating predicates with specific time points.
2. Using Actions or Events
Another approach is to represent actions or events that cause change. This is particularly
common in planning and reasoning about the effects of actions (e.g., the Situation Calculus
or Event Calculus).
Example: Situation Calculus
In the Situation Calculus, we represent the world’s state as a function of actions performed
in different situations. We use the following components:
A function holdsAt(P,s)\text{holdsAt}(P, s)holdsAt(P,s) indicating that a predicate
PPP holds at a situation sss.
Actions aaa that change the world’s state.
A situation sss, which represents the state of the world at a given time.
For example, if John initially has a book, and then he gives the book to Mary, we might
represent it like this:
1. Holdsat(Hasbook(John),S0)\Text{Holdsat}(Hasbook(John),
S_0)Holdsat(Hasbook(John),S0) — John Has The Book In The Initial Situation s0s_0s0
.
2. Holdsat(Hasbook(John),S1)\Text{Holdsat}(Hasbook(John),
S_1)Holdsat(Hasbook(John),S1) — John Still Has The Book After The Action a1a_1a1.
3. Holdsat(Hasbook(Mary),S2)\Text{Holdsat}(Hasbook(Mary),
S_2)Holdsat(Hasbook(Mary),S2) — After The Action Of John Giving The Book To
Mary, Mary Has The Book In The New Situation s2s_2s2.
Here, the action of John giving the book to Mary changes the situation, and the predicate
associated with the book ownership changes accordingly.
3. Fluents and Effects
A fluent is a variable whose value can change over time. We can use fluents to model the
dynamic aspects of the world.
Example: Fluents for Change
Let’s model the change of a light being on or off over time.
LightOn(t1)\text{LightOn}(t_1)LightOn(t1): The light is on at time t1t_1t1.
¬LightOn(t2)\neg \text{LightOn}(t_2)¬LightOn(t2): The light is off at time t2t_2t2.
An action can change the state of a fluent. For example:
TurnOnLight(t2)\text{TurnOnLight}(t_2)TurnOnLight(t2) could represent the action
of turning the light on at time t2t_2t2, which results in LightOn(t2)\text{LightOn}
(t_2)LightOn(t2).
4. Using Modalities:
Temporal logic extends First-Order Logic to model time explicitly, using modal operators
such as:
□\Box□: "Always" (holds in all future states).
◊\Diamond◊: "Eventually" (holds in some future state).
For example:
□LightOn(t)\Box \text{LightOn}(t)□LightOn(t): The light will always be on at time ttt.
◊LightOn(t)\Diamond \text{LightOn}(t)◊LightOn(t): Eventually, the light will be on at
some point in the future.
Example of Change in the World (Action Representation)
Let’s consider a scenario where a robot picks up an object at time t1t_1t1 and places it at
another location at time t2t_2t2. We can represent this scenario as follows:
1. Before the action:
o At(obj,LocationA,t1)\text{At}(obj, \text{LocationA}, t_1)At(obj,LocationA,t1)
— The object is at Location A at time t1t_1t1.
o ¬At(obj,LocationB,t1)\neg \text{At}(obj, \text{LocationB},
t_1)¬At(obj,LocationB,t1) — The object is not at Location B at time t1t_1t1.
2. After the action:
o Action: Move(obj,LocationA,LocationB,t2)\text{Move}(obj, \
text{LocationA}, \text{LocationB}, t_2)Move(obj,LocationA,LocationB,t2) —
The action is moving the object from Location A to Location B.
o At(obj,LocationB,t2)\text{At}(obj, \text{LocationB}, t_2)At(obj,LocationB,t2)
— The object is at Location B at time t2t_2t2.
o ¬At(obj,LocationA,t2)\neg \text{At}(obj, \text{LocationA},
t_2)¬At(obj,LocationA,t2) — The object is no longer at Location A at time
t2t_2t2.
This example represents the change in the world by showing how the object’s location
changes over time due to the action.
Summary of Approaches to Representing Change:
1. Time Points or Indices: Using specific time points to associate predicates with time.
2. Actions and Events: Using actions or events to represent state transitions (e.g.,
Situation Calculus).
3. Fluents: Variables whose values change over time.
4. Modalities (Temporal Logic): Using temporal operators to represent properties that
hold across time.
In First-Order Logic, we often need to extend the system to fully capture change over time
(e.g., by incorporating temporal operators or actions), as standard FoL does not handle
dynamic change by itself.
Inference in First-Order Logic
Inference in First-Order Logic is used to deduce new facts or
sentences from existing sentences. Before understanding the FOL
inference rule, let's understand some basic terminologies used in
FOL.
Substitution is a fundamental operation performed on terms and
formulas. It occurs in all inference systems in first-order logic. The
substitution is complex in the presence of quantifiers in FOL. If we
write F[a/x], so it refers to substitute a constant "a" in place of
variable "x".
Equality:
First-Order logic does not only use predicate and terms for making
atomic sentences but also uses another way, which is equality in
FOL. For this, we can use equality symbols which specify that the
two terms refer to the same object.
Example: Brother (John) = Smith.
As in the above example, the object referred by the Brother
(John) is similar to the object referred by Smith. The equality
symbol can also be used with negation to represent that two terms
are not the same objects.
Example: ¬(x=y) which is equivalent to x ≠y.
In First-Order Logic (FoL), the concept of hidden properties of the world refers to
aspects of the world that are not directly observable or are not explicitly stated but
still influence the state of the world or the conclusions we can draw. These hidden
properties can be modeled in logic by introducing unobservable predicates, latent
variables, or by making use of assumptions and reasoning techniques to infer things
indirectly.
Here are some key ways we can model and reason about hidden properties of the world in
FoL:
1. Invisible or Implicit Predicates
One way to represent hidden properties in the world is by introducing implicit predicates
that describe aspects of the world which are not directly observable, but whose effects can
be inferred. These predicates can represent things like hidden states, unobserved
properties, or even beliefs that influence decisions or behaviors.
Example:
Let’s assume a scenario where we want to reason about whether someone is sick, but we
don’t have direct information about their health condition. We might introduce an implicit
predicate to represent their health:
Sick(x)Sick(x)Sick(x): Person xxx is sick (this is the hidden property).
We might know the following facts:
o ∀x(Sick(x)→Symptomatic(x))\forall x (Sick(x) \rightarrow
1. If a person is sick, they are likely to exhibit symptoms.
Symptomatic(x))∀x(Sick(x)→Symptomatic(x))
2. We observe that person JohnJohnJohn is symptomatic:
o Symptomatic(John)Symptomatic(John)Symptomatic(John)
Now, even though we cannot directly observe if John is sick, we can reason that John might
be sick based on the rule and the observation. This hidden property
Sick(John)Sick(John)Sick(John) is inferred through reasoning.
2. Latent Variables and Unobserved Causes
Sometimes, change or behavior in the world is influenced by latent variables or hidden
causes that are not directly observable, but their effects can be indirectly inferred. These
hidden variables represent underlying factors or unobserved events that cause observable
phenomena.
Example:
Let’s say we are reasoning about whether a machine will break down. We can’t directly
observe wear-and-tear (the latent variable), but it influences the machine’s state.
Broken(m)Broken(m)Broken(m): Machine mmm is broken.
WearAndTear(m)WearAndTear(m)WearAndTear(m): Machine mmm is worn out
(latent variable).
We might have the following rules:
1. If a machine has too much wear and tear, it will break down:
o∀m(WearAndTear(m)→Broken(m))\forall m (WearAndTear(m) \rightarrow
Broken(m))∀m(WearAndTear(m)→Broken(m))
2. We observe that the machine m1m_1m1 is broken:
o Broken(m1)Broken(m_1)Broken(m1)
We don't directly observe WearAndTear for the machine, but we can infer it indirectly, given
the relationship between wear and tear and the machine’s broken state.
3. Explanatory Variables and Assumptions
Hidden properties can also be modeled as assumptions or explanatory variables in the
world. These are aspects that we assume to be true but are not directly observable. We
make these assumptions to explain or reason about certain outcomes.
Example:
Imagine a situation where we are reasoning about whether an agent is trustworthy. The
trustworthiness might be a hidden property that we can only infer based on other
observable behaviors. We introduce assumptions to capture this.
Trustworthy(x)Trustworthy(x)Trustworthy(x): Agent xxx is trustworthy.
HelpsOthers(x)HelpsOthers(x)HelpsOthers(x): Agent xxx helps others.
We might assume that if an agent helps others, they are trustworthy:
∀x(HelpsOthers(x)→Trustworthy(x))\forall x (HelpsOthers(x) \rightarrow
Trustworthy(x))∀x(HelpsOthers(x)→Trustworthy(x))
If we observe that an agent AliceAliceAlice helps others:
HelpsOthers(Alice)HelpsOthers(Alice)HelpsOthers(Alice)
We can infer that:
Trustworthy(Alice)Trustworthy(Alice)Trustworthy(Alice)
Even though we don't have direct evidence of Alice’s trustworthiness, we can assume it
based on her behavior (the assumption that helping others implies trustworthiness).
4. Hidden States in Temporal Logic
Hidden properties of the world can also be modeled as hidden states that evolve over time.
In temporal logic, a property of the world may not be directly observable at one time, but its
past or future values may be inferred by reasoning about the world’s state over time.
Example: Hidden State of a Door (Closed or Open)
Suppose we want to reason about a door's state, but we can't directly observe whether the
door is open or closed at all times. We can model this in temporal logic by introducing the
state of the door at different times.
Let’s introduce:
DoorOpen(t)DoorOpen(t)DoorOpen(t): The door is open at time ttt.
DoorClosed(t)DoorClosed(t)DoorClosed(t): The door is closed at time ttt.
Assume that we know:
1. If the door was closed at time ttt and opened at time t+1t+1t+1, then the door was
o ∀t(DoorClosed(t)→DoorOpen(t+1))\forall t (DoorClosed(t) \rightarrow
closed at ttt and opened at t+1t+1t+1.
DoorOpen(t+1))∀t(DoorClosed(t)→DoorOpen(t+1))
2. The door is closed at time t0t_0t0.
o DoorClosed(t0)DoorClosed(t_0)DoorClosed(t0)
We can infer the door’s state over time without directly observing the door at every time
point. We use reasoning about past states to infer hidden properties of the world, like
whether the door is open at a given time.
5. Hidden States in the Context of Actions
In reasoning about actions (for example, in Action-Based Logic or Situation Calculus), some
aspects of the world are not directly observable, but the effects of actions can be inferred.
These hidden states might be things like an agent’s internal state or the world’s unobserved
configurations.
Example: Action Effects
Consider the scenario where an agent moves an object from one place to another. The
agent may be able to perform the action without directly observing the hidden properties
like hidden obstacles in the world.
1. Action: Move(Object, LocationA, LocationB)
2. Hidden Property: There may be an obstacle in the way at LocationB, but the agent
does not observe it.
After performing the action:
The agent may assume the object has been moved successfully, but due to a hidden
property (the obstacle), it might not have reached the intended location. The agent
may need to update its state based on further observations or reasoning.
Summary
In First-Order Logic, hidden properties of the world can be modeled in several ways:
1. Invisible or Implicit Predicates: Representing properties not directly observable but
inferred through reasoning.
2. Latent Variables: Hidden causes or factors that influence the world’s observable
state.
3. Explanatory Assumptions: Making assumptions about unobservable aspects of the
world based on indirect evidence.
4. Temporal or Hidden States: Representing properties that evolve over time but may
not always be directly observable.
5. Action Effects: Considering the effects of actions on the hidden states of the world.
Hidden properties often require reasoning about the consequences of actions, making
assumptions, and modeling the world’s unobservable components indirectly. Would you like
to explore one of these concepts in more detail or see a specific example?
Get smarter responses, upload files and images, and more.
Log in
FOL inference rules for quantifier:
As propositional logic we also have inference rules in first-order
logic, so following are some basic inference rules in FOL:
o Universal Generalization
o Universal Instantiation
o Existential Instantiation
o Existential introduction
1. Universal Generalization:
o Universal generalization is a valid inference rule which states that if
discourse, then we can have a conclusion as ∀ x P(x).
premise P(c) is true for any arbitrary element c in the universe of
o It can be represented as: .
o This rule can be used if we want to show that every element has a
similar property.
In this rule, x must not appear as a free variable.
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀
o
x P(x) "All bytes contain 8 bits.", it will also be true.
2. Universal Instantiation:
o Universal instantiation is also called as universal elimination or UI is
a valid inference rule. It can be applied multiple times to add new
sentences.
o The new KB is logically equivalent to the previous KB.
o As per UI, we can infer any sentence obtained by substituting
a ground term for the variable.
a ground term c (a constant within domain x) from ∀ x P(x) for
o The UI rule state that we can infer any sentence P(c) by substituting
any object in the universe of discourse.
o It can be represented as: .
Example:1.
IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)
Example: 2.
Let's take a famous example,
"All kings who are greedy are Evil." So let our knowledge base
contains this detail as in the form of FOL:
∀x king(x) ∧ greedy (x) → Evil (x),
So from this information, we can infer any of the following
statements using Universal Instantiation:
King(John) ∧ Greedy (John) → Evil (John),
King(Richard) ∧ Greedy (Richard) → Evil (Richard),
o
∧
o
o King(Father(John)) Greedy (Father(John)) → Evil
(Father(John)),
3. Existential Instantiation:
o Existential instantiation is also called as Existential Elimination,
which is a valid inference rule in first-order logic.
o It can be applied only once to replace the existential sentence.
o The new KB is not logically equivalent to old KB, but it will be
satisfiable if old KB was satisfiable.
form of ∃x P(x) for a new constant symbol c.
o This rule states that one can infer P(c) from the formula given in the
o The restriction with this rule is that c used in the rule must be a new
term for which P(c ) is true.
o It can be represented as:
Example:
From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does
not appear in the knowledge base.
o The above used K is a constant symbol, which is called Skolem
constant.
o The Existential instantiation is a special case of Skolemization
process.
4. Existential introduction
o An existential introduction is also known as an existential
generalization, which is a valid inference rule in first-order logic.
o This rule states that if there is some element c in the universe of
discourse which has a property P, then we can infer that there
exists something in the universe which has the property P.
o It can be represented as:
o Example: Let's say that,
"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
Generalized Modus Ponens Rule:
For the inference process in FOL, we have a single inference rule
which is called Generalized Modus Ponens. It is lifted version of
Modus ponens.
Generalized Modus Ponens can be summarized as, " P implies Q and
P is asserted to be true, therefore Q must be True."
According to Modus Ponens, for atomic sentences pi, pi', q. Where
there is a substitution θ such that SUBST (θ, pi',) = SUBST(θ, pi),
it can be represented as:
Example:
We will use this rule for Kings are evil, so we will find some x
such that x is king, and x is greedy so we can infer that x is
evil.
1. Here let say, p1' is king(John) p1 is king(x)
2. p2' is Greedy(y) p2 is Greedy(x)
3. θ is {x/John, y/John} q is evil(x)
4. SUBST(θ,q).
Forward Chaining and backward
chaining in AI
In artificial intelligence, forward and backward chaining is one of the
important topics, but before understanding forward and backward
chaining lets first understand that from where these two terms
came.
Inference engine:
The inference engine is the component of the intelligent system in
artificial intelligence, which applies logical rules to the knowledge
base to infer new information from known facts. The first inference
engine was part of the expert system. Inference engine commonly
proceeds in two modes, which are:
a. Forward chaining
b. Backward chaining
Horn Clause and Definite clause:
Horn clause and definite clause are the forms of sentences, which
enables knowledge base to use a more restricted and efficient
inference algorithm. Logical inference algorithms use forward and
backward chaining approaches, which require KB in the form of
the first-order definite clause.
Definite clause: A clause which is a disjunction of literals
with exactly one positive literal is known as a definite clause or
strict horn clause.
Horn clause: A clause which is a disjunction of literals with at
most one positive literal is known as horn clause. Hence all the
definite clauses are horn clauses.
Example: (¬ p V ¬ q V k). It has only one positive literal k.
It is equivalent to p ∧ q → k.
A. Forward Chaining
Forward chaining is also known as a forward deduction or forward
reasoning method when using an inference engine. Forward
chaining is a form of reasoning which start with atomic sentences in
the knowledge base and applies inference rules (Modus Ponens) in
the forward direction to extract more data until a goal is reached.
The Forward-chaining algorithm starts from known facts, triggers all
rules whose premises are satisfied, and add their conclusion to the
known facts. This process repeats until the problem is solved.
Properties of Forward-Chaining:
Properties of Forward-Chaining:
o It is a down-up approach, as it moves from bottom to top.
o It is a process of making a conclusion based on known facts or data,
by starting from the initial state and reaches the goal state.
o Forward-chaining approach is also called as data-driven as we reach
to the goal using available data.
o Forward -chaining approach is commonly used in the expert system,
such as CLIPS, business, and production rule systems.
Consider the following famous example which we will use in both
approaches:
Example:
"As per the law, it is a crime for an American to sell weapons
to hostile nations. Country A, an enemy of America, has
some missiles, and all the missiles were sold to it by Robert,
who is an American citizen."
Prove that "Robert is criminal."
To solve the above problem, first, we will convert all the above facts
into first-order definite clauses, and then we will use a forward-
chaining algorithm to reach the goal.
Facts Conversion into FOL:
o It is a crime for an American to sell weapons to hostile nations.
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) →
(Let's say p, q, and r are variables)
Country A has some missiles. ?p Owns(A, p) ∧ Missile(p). It can
Criminal(p) ...(1)
o
be written in two definite clauses by using Existential Instantiation,
introducing new Constant T1.
Owns(A, T1) ......(2)
Missile(T1) .......(3)
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
o All of the missiles were sold to country A by Robert.
......(4)
o Missiles are weapons.
Missile(p) → Weapons (p) .......(5)
o Enemy of America is known as hostile.
Enemy(p, America) →Hostile(p) ........(6)
o Country A is an enemy of America.
Enemy (A, America) .........(7)
o Robert is American
American(Robert). ..........(8)
Forward chaining proof:
Step-1:
In the first step we will start with the known facts and will choose
the sentences which do not have implications, such
as: American(Robert), Enemy(A, America), Owns(A, T1), and
Missile(T1). All these facts will be represented as below.
Step-2:
At the second step, we will see those facts which infer from
available facts and with satisfied premises.
Rule-(1) does not satisfy premises, so it will not be added in the first
iteration.
Rule-(2) and (3) are already added.
Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1,
A) is added, which infers from the conjunction of Rule (2) and (3).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added
and which infers from Rule-(7).
Step-3:
At step-3, as we can check Rule-(1) is satisfied with the
substitution {p/Robert, q/T1, r/A}, so we can add
Criminal(Robert) which infers all the available facts. And hence we
reached our goal statement.
Hence it is proved that Robert is Criminal using forward
chaining approach.
B. Backward Chaining:
Backward-chaining is also known as a backward deduction or
backward reasoning method when using an inference engine. A
backward chaining algorithm is a form of reasoning, which starts
with the goal and works backward, chaining through rules to find
known facts that support the goal.
Properties of backward chaining:
o It is known as a top-down approach.
o Backward-chaining is based on modus ponens inference rule.
o In backward chaining, the goal is broken into sub-goal or sub-goals
to prove the facts true.
o It is called a goal-driven approach, as a list of goals decides which
rules are selected and used.
o Backward -chaining algorithm is used in game theory, automated
theorem proving tools, inference engines, proof assistants, and
various AI applications.
o The backward-chaining method mostly used a depth-first
search strategy for proof.
Example:
In backward-chaining, we will use the same above example, and will
rewrite all the rules.
o American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) →
Criminal(p) ...(1)
Owns(A, T1) ........(2)
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
o Missile(T1)
o ......
(4)
o Missile(p) → Weapons (p) .......(5)
o Enemy(p, America) →Hostile(p) ........(6)
o Enemy (A, America) .........(7)
o American(Robert). ..........(8)
Backward-Chaining proof:
In Backward chaining, we will start with our goal predicate, which
is Criminal(Robert), and then infer further rules.
Step-1:
At the first step, we will take the goal fact. And from the goal fact,
we will infer other facts, and at last, we will prove those facts true.
So our goal fact is "Robert is Criminal," so following is the predicate
of it.
Step-2:
At the second step, we will infer other facts form goal fact which
satisfies the rules. So as we can see in Rule-1, the goal predicate
Criminal (Robert) is present with substitution {Robert/P}. So we will
add all the conjunctive facts below the first level and will replace p
with Robert.
Here we can see American (Robert) is a fact, so it is proved
here.
Step-3:t At step-3, we will extract further fact Missile(q) which infer
from Weapon(q), as it satisfies Rule-(5). Weapon (q) is also true with
the substitution of a constant T1 at q.
Step-4:
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form
Sells(Robert, T1, r) which satisfies the Rule- 4, with the substitution
of A in place of r. So these two statements are proved here.
Step-5:
At step-5, we can infer the fact Enemy(A,
America) from Hostile(A) which satisfies Rule- 6. And hence all the
statements are proved true using backward chaining.
In formal logic (FoL, or First-Order Logic), completeness refers to a property of a logical
system where every statement that is true (i.e., valid) in all models of the system can be
formally proven using the system's axioms and inference rules.
There are two main types of completeness in the context of formal logic:
1. Semantic Completeness
Semantic completeness means that if a statement is true in all interpretations (models) of
the system, then it is provable within the system. In other words, if a formula ϕ\phiϕ is valid
(true in every model), there exists a proof of ϕ\phiϕ within the system. This is a crucial
aspect of First-Order Logic as it ensures that the system is "strong enough" to prove every
true statement in all models.
2. Syntactic Completeness
Syntactic completeness refers to the idea that a logical system has a proof for every
statement that is either true or false, meaning every formula is either provable or its
negation is provable (i.e., the system is "decidable").
However, First-Order Logic (FoL), as shown in Gödel's completeness theorem, is both
semantically complete and sound. This means:
Every logically valid formula is provable (semantic completeness).
Every provable formula is logically valid (soundness).
Gödel's Completeness Theorem for First-Order Logic shows that if a formula is true in every
model (semantically valid), then it is provable within the system (syntactically provable).
Would you like more details on how completeness applies in specific contexts of FoL or
perhaps how this compares to other logical systems?
Resolution in FOL
Resolution
Resolution is a theorem proving technique that proceeds by building
refutation proofs, i.e., proofs by contradictions.
Resolution is used, if there are various statements are given, and we
need to prove a conclusion of those statements. Unification is a key
concept in proofs by resolutions. Resolution is a single inference rule
which can efficiently operate on the conjunctive normal form or
clausal form.
Clause: Disjunction of literals (an atomic sentence) is called
a clause. It is also known as a unit clause.
Conjunctive Normal Form: A sentence represented as a
conjunction of clauses is said to be conjunctive normal
form or CNF.
steps for Resolution:
1. Conversion of facts into first-order logic.
2. Convert FOL statements into CNF
3. Negate the statement which needs to prove (proof by contradiction)
4. Draw resolution graph (unification).
To better understand all the above steps, we will take an example in
which we will apply resolution.
Example:
1. John likes all kind of food.
2. Apple and vegetable are food.
3. Anything anyone eats and not killed is food.
4. Anil eats peanuts and still alive.
5. Harry eats everything that Anil eats.
6. John likes peanuts.
Step-1: Conversion of Facts into FOL
In the first step we will convert all the given statements into its first
order logic.
Step-2: Conversion of FOL into CNF
In First order logic resolution, it is required to convert the FOL into
CNF as CNF form makes easier for resolution proofs.
o Eliminate all implication (→) and rewrite
a. ∀x ¬ food(x) V likes(John, x)
∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
b. food(Apple) Λ food(vegetables)
c.
∀x ¬ eats(Anil, x) V eats(Harry, x)
d. eats (Anil, Peanuts) Λ alive(Anil)
∀x¬ [¬ killed(x) ] V alive(x)
e.
∀x ¬ alive(x) V ¬ killed(x)
f.
g.
h. likes(John, Peanuts).
o Move negation (¬)inwards and rewrite
a. ∀x ¬ food(x) V likes(John, x)
∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
b. food(Apple) Λ food(vegetables)
c.
∀x ¬ eats(Anil, x) V eats(Harry, x)
d. eats (Anil, Peanuts) Λ alive(Anil)
∀x ¬killed(x) ] V alive(x)
e.
∀x ¬ alive(x) V ¬ killed(x)
f.
g.
h. likes(John, Peanuts).
o Rename variables or standardize variables
a. ∀x ¬ food(x) V likes(John, x)
∀y ∀z ¬ eats(y, z) V killed(y) V food(z)
b. food(Apple) Λ food(vegetables)
c.
∀w¬ eats(Anil, w) V eats(Harry, w)
d. eats (Anil, Peanuts) Λ alive(Anil)
∀g ¬killed(g) ] V alive(g)
e.
∀k ¬ alive(k) V ¬ killed(k)
f.
g.
h. likes(John, Peanuts).
In this step, we will eliminate existential quantifier ∃, and this
o Eliminate existential instantiation quantifier by elimination.
process is known as Skolemization. But in this example problem
since there is no existential quantifier so all the statements will
remain same in this step.
o Drop Universal quantifiers.
In this step we will drop all universal quantifier since all the
statements are not implicitly quantified so we don't need it.
a. ¬ food(x) V likes(John, x)
b. food(Apple)
c. food(vegetables)
d. ¬ eats(y, z) V killed(y) V food(z)
e. eats (Anil, Peanuts)
f. alive(Anil)
g. ¬ eats(Anil, w) V eats(Harry, w)
h. killed(g) V alive(g)
i. ¬ alive(k) V ¬ killed(k)
j. likes(John, Peanuts).
Note: Statements "food(Apple) Λ food(vegetables)" and "eats
(Anil, Peanuts) Λ alive(Anil)" can be written in two separate
statements.
o Distribute conjunction ∧ over disjunction ¬.
This step will not make any change in this problem.
Step-3: Negate the statement to be proved
In this statement, we will apply negation to the conclusion
statements, which will be written as ¬likes(John, Peanuts)
Step-4: Draw Resolution graph:
Now in this step, we will solve the problem by resolution tree using
substitution. For the above problem, it will be given as follows:
Hence the negation of the conclusion has been proved as a
complete contradiction with the given set of statements.
Explanation of Resolution graph:
o In the first step of resolution graph, ¬likes(John, Peanuts) ,
and likes(John, x) get resolved(canceled) by substitution
of {Peanuts/x}, and we are left with ¬ food(Peanuts)
o In the second step of the resolution graph, ¬ food(Peanuts) ,
and food(z) get resolved (canceled) by substitution of {
Peanuts/z}, and we are left with ¬ eats(y, Peanuts) V killed(y) .
o In the third step of the resolution graph, ¬ eats(y,
Peanuts) and eats (Anil, Peanuts) get resolved by
substitution {Anil/y}, and we are left with Killed(Anil) .
o In the fourth step of the resolution graph, Killed(Anil) and ¬
killed(k) get resolve by substitution {Anil/k}, and we are left
with ¬ alive(Anil) .
o In the last step of the resolution graph ¬
alive(Anil) and alive(Anil) get resolved.