Professional Documents
Culture Documents
unit 3 AI
unit 3 AI
unit 3 AI
First Order Logic in Artificial Intelligence is a technique used for knowledge representation.
It is an extension of propositional logic and unlike propositional logic, it is sufficiently
expressive in representing any natural language construct. First Order Logic in AI is also known
as Predicate Logic or First Order Predicate Logic. It is a robust technique to represent objects
as well as their relationships. Unlike propositional logic, First Order Logic in Artificial
Intelligence doesn't only include facts but also different other entities as listed below.
o Objects:
Objects can denote any real-world entity or any variable.
E.g., A, B, colours, theories, circles etc.
o Relations:
Relations represent the links between different objects. Relations can be unary(relations
defined for a single term) and n-ary(relations defined for n terms). E.g., blue, round
(unary); friends, siblings (binary); etc.
o Functions:
Functions map their input object to the output object using their underlying relation.
Eg: father_of(), mother_of() etc.
First-order logic in Artificial Intelligence comprises two main components, which are as
follows.
Syntax:
Syntax represents the rules to write expressions in First Order Logic in Artificial
Intelligence.
Semantics:
Semantics refers to the techniques that we use to evaluate an expression of First Order
Logic in AI. These techniques use various known relations and facts of the respective
environment to deduce the boolean value of the given First Order Logic expression.
Syntax of First Order Logic in Artificial Intelligence represents the rules of representing any
natural language construct in terms of First Order Logic in AI. This involves the rules to describe
any object and the relationships between different objects. These rules comprise rules for writing
constants, variables, predicates, quantifiers, etc. In the following sections, we present various
examples of the syntax of first-order logic in AI.
Variables x, y, z, a, b,....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Atomic Sentences
Atomic sentences are the most basic expressions of First Order Logic in AI. These sentences
comprise a predicate followed by a set of terms inside a parenthesis. Formally stating, the
structure of an atomic sentence looks like the following.
Predicate ( term 1, term 2, term 3,...) Predicate ( term 1, term 2, term 3,...)
One example of an atomic sentence in First Order Logic in Artificial Intelligence can
be Sisters ( Geeta , Seeta ) Sisters ( Geeta , Seeta ). Another example involving a unary predicate
can be Polygon ( Rectangle ) Polygon ( Rectangle ).
Complex Sentences
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.
What is knowledge-engineering?
In this topic, we will understand the Knowledge engineering process in an electronic circuit
domain, which is already familiar. This approach is mainly suitable for creating special-purpose
knowledge base.
The first step of the process is to identify the task, and for the digital circuit, there are various
reasoning tasks.
At the first level or highest level, we will examine the functionality of the circuit:
At the second level, we will examine the circuit structure details such as:
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:
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.
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.
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.
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 premise P(c) is true
for any arbitrary element c in the universe of discourse, then we can have a conclusion as
∀ x P(x).
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain 8
bits.", it will also be true.
2. Universal Instantiation:
Example:1.
Example: 2.
"All kings who are greedy are Evil." So let our knowledge base contains this detail as in the form
of FOL:
3. Existential Instantiation:
Example:
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the
knowledge base.
4. Existential introduction
What is Unification?
o Unification is a process of making two different logical atomic expressions identical by
finding a substitution. Unification depends on the substitution process.
o It takes two literals as input and makes them identical using substitution.
o Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 = Ψ2𝜎, then it
can be expressed as UNIFY(Ψ1, Ψ2).
o Example: Find the MGU for Unify{King(x), King(John)}
Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and both
expressions will be identical.
E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
In this example, we need to make both above statements identical to each other. For this, we will
perform the substitution.
o Substitute x with a, and y with f(z) in the first expression, and it will be represented
as a/x and f(z)/y.
o With both the substitutions, the first expression will be identical to the second expression
and the substitution set will be: [a/x, f(z)/y].
o Predicate symbol must be same, atoms or expression with different predicate symbol can
never be unified.
o Number of Arguments in both expressions must be identical.
o Unification will fail if there are two similar variables present in the same expression.
o The UNIFY algorithm is used for unification, which takes two atomic sentences and
returns a unifier for those sentences (If any exist).
o Unification is a key component of all first-order inference algorithms.
o It returns fail if the expressions do not match with each other.
o The substitution variables are called Most General Unifier or MGU.
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:
Forward chaining
Backward chaining
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:
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."
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.
Backward Chaining:
Example:
In backward-chaining, we will use the same above example, and will rewrite all the rules.
1. Forward chaining starts from known Backward chaining starts from the goal and
facts and applies inference rule to extract works backward through inference rules to
more data unit it reaches to the goal. find the required facts that support the goal.
2. It is a bottom-up approach It is a top-down approach
3. Forward chaining is known as data- Backward chaining is known as goal-driven
driven inference technique as we reach technique as we start from the goal and
to the goal using the available data. divide into sub-goal to extract the facts.
4. Forward chaining reasoning applies a Backward chaining reasoning applies a
breadth-first search strategy. depth-first search strategy.
5. Forward chaining tests for all the Backward chaining only tests for few
available rules required rules.
6. Forward chaining is suitable for the Backward chaining is suitable for
planning, monitoring, control, and diagnostic, prescription, and debugging
interpretation application. application.
9. Forward chaining is aimed for any Backward chaining is only aimed for the
conclusion. required data.
Resolution
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e.,
proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the year
1965.
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.
The resolution rule for first-order logic is simply a lifted version of the propositional rule.
Resolution can resolve two clauses if they contain complementary literals, which are assumed to
be standardized apart so that they share no variables.
Knowledge Representation
When we talk about knowledge representation, it’s like we’re creating a map of information
for AI to use. First-order logic (FOL) acts like a special language that helps us build this map
in a detailed and organized way. It’s important because it allows us to understand not only
facts but also the relationships and connections between objects. In this article, we will discuss
the fundamentals of Knowledge Representation in First-Order Logic