0% found this document useful (0 votes)
2K views56 pages

CI Unit 2 Resolution in FOL

The document discusses unification in first-order logic. It defines unification as a process that takes two logical atomic expressions and makes them identical through substitution. The unification algorithm finds a most general unifier (MGU) that applies substitutions to make the expressions match. Examples demonstrate applying the unification process and algorithm to expressions like King(x) and King(John) or P(x,y) and P(a,f(z)). Conditions for successful unification include having the same predicate symbol and number of arguments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views56 pages

CI Unit 2 Resolution in FOL

The document discusses unification in first-order logic. It defines unification as a process that takes two logical atomic expressions and makes them identical through substitution. The unification algorithm finds a most general unifier (MGU) that applies substitutions to make the expressions match. Examples demonstrate applying the unification process and algorithm to expressions like King(x) and King(John) or P(x,y) and P(a,f(z)). Conditions for successful unification include having the same predicate symbol and number of arguments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 56

Proposition Logic – First Order Predicate Logic – Unification – Forward Chaining -Backward Chaining –

Resolution – Knowledge Representation – Ontological Engineering – Categories and Objects – Events –


Mental Events and Mental Objects – Reasoning Systems for Categories – Reasoning with Default
Information – Prolog Programming.

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 
o UNIFY(Ψ1, Ψ2).
o Example: Find the MGU for Unify{King(x), King(John)}

Let Ψ1 = King(x), Ψ2 = King(John),

Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and both expressions will
be identical.

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.

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.

            P(x, y)......... (i)


            P(a, f(z))......... (ii)

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

Conditions for Unification:


Following are some basic conditions for unification:

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.

Unification Algorithm:
Algorithm: Unify(Ψ1, Ψ2)
Step. 1: If Ψ1 or Ψ2 is a variable or constant, then:
a) If Ψ1 or Ψ2 are identical, then return NIL.
b) Else if Ψ1is a variable,
a. then if Ψ1 occurs in Ψ2, then return FAILURE
b. Else return { (Ψ2/ Ψ1)}.
c) Else if Ψ2 is a variable,
a. If Ψ2 occurs in Ψ1 then return FAILURE,
b. Else return {( Ψ1/ Ψ2)}.
d) Else return FAILURE.
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then
return FAILURE.
Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then return
FAILURE.
Step. 4: Set Substitution set(SUBST) to NIL.
Step. 5: For i=1 to the number of elements in Ψ1.
a) Call Unify function with the ith element of Ψ1 and ith element of
Ψ2, and put the result into S.
b) If S = failure then returns Failure
c) If S ≠ NIL then do,
a. Apply S to the remainder of both L1 and L2.
b. SUBST= APPEND(S, SUBST).
Step.6: Return SUBST.

Implementation of the Algorithm


Step.1: Initialize the substitution set to be empty.

Step.2: Recursively unify atomic sentences:

a. Check for Identical expression match.


b. If one expression is a variable vi, and the other is a term ti which does not contain variable vi, then:

a. Substitute ti / vi in the existing substitutions


b. Add ti /vi to the substitution setlist.
c. If both the expressions are functions, then function name must be similar, and the number of
arguments must be the same in both the expression.

For each pair of the following atomic sentences find the most general unifier (If exist).

1. Find the MGU of {p(f(a), g(Y)) and p(X, X)}

            Sol: S0 => Here, Ψ1 = p(f(a), g(Y)), and Ψ2 = p(X, X)


                  SUBST θ= {f(a) / X}
                  S1 => Ψ1 = p(f(a), g(Y)), and Ψ2 = p(f(a), f(a))
                  SUBST θ= {f(a) / g(y)}, Unification failed.

Unification is not possible for these expressions.

2. Find the MGU of {p(b, X, f(g(Z))) and p(Z, f(Y), f(Y))}


Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y))
S0 => { p(b, X, f(g(Z))); p(Z, f(Y), f(Y))}
SUBST θ={b/Z}

S1 => { p(b, X, f(g(b))); p(b, f(Y), f(Y))}


SUBST θ={f(Y) /X}

S2 => { p(b, f(Y), f(g(b))); p(b, f(Y), f(Y))}


SUBST θ= {g(b) /Y}

S2 => { p(b, f(g(b)), f(g(b)); p(b, f(g(b)), f(g(b))} Unified Successfully.


And Unifier = { b/Z, f(Y) /X , g(b) /Y}.

3. Find the MGU of {p (X, X), and p (Z, f(Z))}

Here, Ψ1 = {p (X, X), and Ψ2 = p (Z, f(Z))


S0 => {p (X, X), p (Z, f(Z))}
SUBST θ= {X/Z}
              S1 => {p (Z, Z), p (Z, f(Z))}
SUBST θ= {f(Z) / Z}, Unification Failed.

Hence, unification is not possible for these expressions.

4. Find the MGU of UNIFY(prime (11), prime(y))

Here, Ψ1 = {prime(11) , and Ψ2 = prime(y)}


S0 => {prime(11) , prime(y)}
SUBST θ= {11/y}

S1 => {prime(11) , prime(11)} , Successfully unified.


              Unifier: {11/y}.

5. Find the MGU of Q(a, g(x, a), f(y)), Q(a, g(f(b), a), x)}

Here, Ψ1 = Q(a, g(x, a), f(y)), and Ψ2 = Q(a, g(f(b), a), x)
S0 => {Q(a, g(x, a), f(y)); Q(a, g(f(b), a), x)}
SUBST θ= {f(b)/x}
S1 => {Q(a, g(f(b), a), f(y)); Q(a, g(f(b), a), f(b))}

SUBST θ= {b/y}
S1 => {Q(a, g(f(b), a), f(b)); Q(a, g(f(b), a), f(b))}, Successfully Unified.

Unifier: [a/a, f(b)/x, b/y].

6. UNIFY(knows(Richard, x), knows(Richard, John))

Here, Ψ1 = knows(Richard, x), and Ψ2 = knows(Richard, John)


S0 => { knows(Richard, x); knows(Richard, John)}
SUBST θ= {John/x}
S1 => { knows(Richard, John); knows(Richard, John)}, Successfully Unified.
Unifier: {John/x}.

Resolution in FOL
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.

Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to be conjunctive


normal form or CNF.

Note: To better understand this topic, firstly learns the FOL in AI.

The resolution inference rule:


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.

Where li and mj are complementary literals.

This rule is also called the binary resolution rule because it only resolves exactly two literals.

Example:
We can resolve two clauses which are given below:

[Animal (g(x) V Loves (f(x), x)]       and       [¬ Loves(a, b) V ¬Kills(a, b)]

Where two complimentary literals are: Loves (f(x), x) and ¬ Loves (a, b)

These literals can be unified with unifier θ= [a/f(x), and b/x] , and it will generate a resolvent clause:

[Animal (g(x) V ¬ Kills(f(x), x)].

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:
a. John likes all kind of food.
b. Apple and vegetable are food
c. Anything anyone eats and not killed is food.
d. Anil eats peanuts and still alive
e. Harry eats everything that Anil eats.
Prove by resolution that:
f. 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)
b. food(Apple) Λ food(vegetables)
c. ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀x ¬ eats(Anil, x) V eats(Harry, x)
f. ∀x¬ [¬ killed(x) ] V alive(x)
g. ∀x ¬ alive(x) V ¬ killed(x)
h. likes(John, Peanuts).
o Move negation (¬)inwards and rewrite

a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀x ¬ eats(Anil, x) V eats(Harry, x)
f. ∀x ¬killed(x) ] V alive(x)
g. ∀x ¬ alive(x) V ¬ killed(x)
h. likes(John, Peanuts).
o Rename variables or standardize variables

a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀y ∀z ¬ eats(y, z) V killed(y) V food(z)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀w¬ eats(Anil, w) V eats(Harry, w)
f. ∀g ¬killed(g) ] V alive(g)
g. ∀k ¬ alive(k) V ¬ killed(k)
h. likes(John, Peanuts).
o Eliminate existential instantiation quantifier by elimination.
In this step, we will eliminate existential quantifier ∃, and this 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.

Problem 1

1. All people who are graduating are happy.

2. All happy people smile.

3. Someone is graduating.

4. Conclusion: Is someone smiling?


Solution:

Convert the sentences into predicate Logic

1. ∀x graduating(x)happy(x)

2. ∀x happy(x)smile(x)

3. ∃x graduating(x)

4. ∃x smile(x)

Convert to clausal form

(i) Eliminate the  sign

1. ∀xgraduating(x) happy(x)

2. ∀xhappy(x) smile(x)

3. ∃x graduating(x)

4. ∃x smile(x)

(ii) Reduce the scope of negation

1. ∀xgraduating(x) happy(x)

2. ∀xhappy(x) smile(x)

3. ∃x graduating(x)

4. ∀x  smile(x)

(iii) Standardize variables apart

1. ∀xgraduating(x) happy(x)

2. ∀yhappy(y) smile(y)

3. ∃x graduating(z)

4. ∀w  smile(w)

(iv) Move all quantifiers to the left

1. ∀xgraduating(x) happy(x)

2. ∀yhappy(y) smile(y)

3. ∃x graduating(z)
4. ∀w  smile(w)

(v) Eliminate ∃

1. ∀xgraduating(x) happy(x)

2. ∀xhappy(y) smile(y)

3. graduating(name1)

4. ∀w  smile(w)

(vi) Eliminate ∀

1. graduating(x) happy(x)

2. happy(y) smile(y)

3. graduating(name1)

4.  smile(w)

(vii) Convert to conjunct of disjuncts form.

(viii) Make each conjunct a separate clause.

(ix) Standardize variables apart again.

happy(y) smile(y)  smile(w)

graduating(x) happy(x) happy(y)

. graduating(name1) graduating(x)
None

Thus, we proved someone is smiling.

Problem 2

Explain the unification algorithm used for reasoning under predicate logic with an example.
Consider the following facts

a. Team India

b. Team Australia

c. Final match between India and Australia

d. India scored 350 runs, Australia scored 350 runs, India lost 5 wickets, Australia lost 7
wickets.

e. The team which scored the maximum runs wins.

f. If the scores are same the team which lost minimum wickets wins the match.
Represent the facts in predicate, convert to clause form and prove by resolution “India wins the
match”.
Solution:

Convert in to predicate Logic

(a) team(India)

(b) team(Australia)

(c) team(India)  team(Australia)final_match(India, Australia)

(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)

(e) ∃x team(x)  wins(x)score(x, max_runs))

(f) ∃xy score(x,equal(y))  wicket(x, min) final_match(x,y)win(x)

Convert to clausal form

(i) Eliminate the  sign

(a) team(India)

(b) team(Australia)

(c)  (team(India)  team(Australia))  final_match(India, Australia)

(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)

(e) ∃x  (team(x)  wins(x)) score(x, max_runs))


(f) ∃xy  (score(x,equal(y))  wicket(x, min) final_match(x,y)) win(x)

(ii) Reduce the scope of negation

(a) team(India)

(b) team(Australia)

(c)  team(India)  team(Australia)  final_match(India, Australia)

(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)

(e) ∃x  team(x)  wins(x) score(x, max_runs))

(f) ∃xy  score(x,equal(y)) wicket(x, min_wicket) final_match(x,y)) win(x)

(iii) Standardize variables apart

(iv) Move all quantifiers to the left

(v) Eliminate ∃

(a) team(India)

(b) team(Australia)

(c)  team(India)  team(Australia)  final_match(India, Australia)

(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)

(e)  team(x)  wins(x) score(x, max_runs))

(f)  score(x,equal(y)) wicket(x, min_wicket) final_match(x,y)) win(x)

(vi) Eliminate ∀

(vii) Convert to conjunct of disjuncts form.

(viii) Make each conjunct a separate clause.

(a) team(India)

(b) team(Australia)

(c)  team(India)  team(Australia)  final_match(India, Australia)

(d) score(India,350)

score(Australia,350)
wicket(India,5)

wicket(Australia,7)

(e)  team(x)  wins(x) score(x, max_runs))

(f)  score(x, equal(y)) wicket(x, min_wicket) final_match(x, y)) win(x)

(ix) Standardize variables apart again.

To prove: win(India)

Disprove: win(India)

 score(x, equal(y)) wicket(x, min_wicket) final_match(x, y)) win(x) win(India)

 team(India)  team(Australia)  final_match(India, Australia)  score(x, equal(y))


wicket(x,min_wicket) final_match(x, y))

team(India)

 team(India)  team(Australia)
score(x,equal(y))wicket(x, min_wicket)

team(Australia) team(Australia) score(x, equal(y)) 


wicket(x, min_wicket)

score(India,350) score(x, equal(y))  wicket(x, min_wicket)


wicket(India,5) wicket(x, min_wicket)

None

Thus, proved India wins match.

Problem 3

Consider the following facts and represent them in predicate form:


F1. There are 500 employees in ABC company.
F2. Employees earning more than Rs. 5000 pay tax.
F3. John is a manager in ABC company.
F4. Manager earns Rs. 10,000.
Convert the facts in predicate form to clauses and then prove by resolution: “John pays tax”.

Solution:

Convert in to predicate Logic

1. company(ABC) employee(500,ABC)

2. ∃x company(ABC) employee(x, ABC) earns(x,5000)pays(x, tax)

3. manager(John, ABC)

4. ∃x manager(x, ABC)earns(x,10000)

Convert to clausal form

(i) Eliminate the  sign

1. company(ABC) employee(500,ABC)

2. ∃x (company(ABC) employee(x, ABC) earns(x,5000))  pays(x, tax)

3. manager(John, ABC)

4. ∃x manager(x, ABC)  earns(x, 10000)

(ii) Reduce the scope of negation

1. company(ABC) employee(500,ABC)

2. ∃x company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)

3. manager(John, ABC)

4. ∃x manager(x, ABC)  earns(x, 10000)

(iii) Standardize variables apart


1. company(ABC) employee(500,ABC)

2. ∃x company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)

3. manager(John, ABC)

4. ∃y manager(x, ABC)  earns(y, 10000)

(iv) Move all quantifiers to the left

(v) Eliminate ∃

1. company(ABC) employee(500,ABC)

2.  company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)

3. manager(John, ABC)

4. manager(x, ABC)  earns(y, 10000)

(vi) Eliminate ∀

(vii) Convert to conjunct of disjuncts form.

(viii) Make each conjunct a separate clause.

1. (a)company(ABC)

(b)employee(500,ABC)

2.  company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)

3. manager(John, ABC)

4. manager(x, ABC)  earns(y, 10000)

(ix) Standardize variables apart again.

Prove :pays(John, tax)

Disprove: pays(John, tax)

 company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax) pays(John, tax)

manager(x, ABC)  earns(y, 10000)  company(ABC) employee(x,ABC)


earns(x,5000)
manager(John, ABC) manager(x, ABC) company(ABC) employee(x, ABC)

company(ABC) company(ABC) employee(x, ABC)

employee(500,ABC) employee(x, ABC)

None

Thus, proved john pays tax.

Problem 4

If a perfect square is divisible by a prime p then it is also divisible by square of p.

Every perfect square is divisible by some prime.

36 is a perfect square.

Convert in to predicate Logic

1. ∀xy perfect_sq(x) prime(y) divides(x,y)divides(x,square(y))

2. ∀x∃y perfect_sq(x) prime(y) divides(x,y)

3. perfect_sq(36)
UNIFICATION ALGORITHM

When attempting to match 2 literals, all substitutions must be made to the entire literal. There may be
many substitutions that unify 2 literals, the most general unifier is always desired

1. Initial predicate symbols must match.

2. For each pair of predicate arguments:

– different constants cannot match.

– a variable may be replaced by a constant.

– a variable may be replaced by another variable.

– a variable may be replaced by a function as long as the function does not contain an instance of the
variable

Algorithm :Unify(L1,L2)

1. If L1 or L2 are both variables or constants, then:

(a) If L1 and L2 are identical, then return NIL.

(b) Else if L1 is a variable, then if L1 occurs in L2 the return {FAIL}, else return (L2/L1).

(c) Else if L2 is a variable, then if L2 occurs in L1 the return {FAIL}, else return (L1/L2).

(d) Else return {FAIL}

2. If the initial predicate symbols in L1 and L2 are not identical, the return {FAIL}.

3. If L1 and L2 have a different number of arguments, then return {FAIL}.

4. Set SUBST to NIL.

5. For i1 to number of arguments in L1:

(a) Call Unify with the ith argument of L1 and the ith argument of L2, putting result in S.

(b)If s contains FAIL then return {FAIL}

(c) If S is not equal to NIL then:

(i) Apply S to the remainder of both L1 and L2

(ii) SUBST=APPEND(S,SUBST).

6. Return SUBST.

Example

P(x) and P(y) :substitution = (x/y)

• P(x,x) and P(y,z) : (z/y)(y/x)


• P(x,f(y)) and P(Joe,z) : (Joe/x, f(y)/z)

• P(f(x)) and P(x) : can’t do it!

• P(x) Ú Q(Jane) and P(Bill)  Q(y): (Bill/x, Jane/y)

PRODUCTION BASED SYSTEM


Production systems are also known as rule based system.
A system whose knowledge base is represented as a set of rules and facts is called rule based system. A
rule based system consists of a collection of IF-THEN rules, a collection of facts, and some interpreter
controlling the application of the rules given the facts.
Production rules
– IF-THEN expressions
– IF some condition(s) exists THEN perform some action(s)
Condition-action pair
– Condition: pattern that determines when a rule may be applied to problem instance
– Action: defines associated problem solving step
Antecedent – Consequent
– IF <antecedent> THEN <consequent>
When the antecedent part is NULL, the rule becomes fact.
Rule can have multiple antecedents
Conjunction AND
IF <antecedent0> AND <ante cedent1> … AND <antecedentn>
THEN <consequent>
Disjunction OR
IF <antecedent0> OR <antecedent1> … OR <antecedentn>
THEN <consequent>
Combination of both
IF <antecedent0> AND <antecedent1> … AND <antecedentn>
OR <antecedent0> OR <antecedent1> … OR <antecedentn>
THEN <consequent>
Consequents can also have multiple clauses
IF <antecedent> THEN <consequent0>, <consequent1>,
…<consequentn-1>, <consequentn>
Triggered and fired rules
A rule is triggered when all the antecedents evaluate to true.
A rule is fired when the action stated in the consequent part or the inference related to the
consequent part is inferred or taken.

Production based system

Inference machine is a machine that implements strategies to utilize the knowledge base and derive new
conclusions from it.
Match
Inference machine is comparing the fact base and the rule base and find some rules are matching. These
set of rules are passed to the next phase, conflict resolution.
Conflict resolution phase
 Rule 1:IF the ‘traffic light’ is green THEN the action is go
 Rule 2:IF the ‘traffic light’ is red THEN the action is stop
 Rule 3:IF the traffic light’ is red THEN the action is go
We have two rules, Rule 2 and Rule 3, with the same IF part. Thus both of them can be set to fire
when the condition part is satisfied. These rules represent a conflict set. The inference engine must
determine which rule to fire from such a set. A method for choosing a rule to fire when more than one
rule can be fired in a given cycle is called conflict resolution.
INFERENCE MECHANISM
An inference is an idea or conclusion that's drawn from evidence and reasoning.
An Inference Engine is a tool from artificial intelligence.
Given a set of rules, there are essentially two ways to generate new knowledge
 Forward chaining
 Backward chaining

FORWARD CHAINING
 Forward chaining is one of the two main methods of reasoning when using an inference engine
and can be described logically as repeated application of modus ponens.
 Forward chaining is a popular implementation strategy for expert systems, business and
production rule systems.
 Forward chaining is also known as data driven approach.
 Forward chaining starts with the facts and see what rules apply.
 To chain forward, match data in working memory against 'conditions' of rules in the rule-base.
Ontological Engineering
• An ontology is nothing exotic, at least in artificial intelligence.

• It is a formal explicit representation of a shared understanding of the important concepts in


some domain of interest.

• In philosophy the term ‘ontology’ refers to a more delicate, but related, concept:

• Ontologies contain consensual knowledge:

• accepted by a group of people

Ontologies are an abstract model of some “existing” domain of the world.

Commitment:

• make as few claims as possible about the domain being modeled,

• giving ontology reusers freedom to specialize and instantiate as needed.

Why ontologies are useful?


• Sharing:
– “communication” among people / agents with different needs and viewpoints due to
their different contexts
• unified framework within an “organization” to reduce conceptual and
terminological confusion
– inter-operability among systems by “translating” between different modeling
methods, languages and software tools
• ontologies as inter-lingua
• integration of ontologies
• Modeling
• System engineering:
– re-usability
• Use of standards
• Highly configurable ontologies and libraries of ontologies support re-usability
among different software systems.
– reliability
• Formal ontologies enable the use of consistency checking resulting in more
reliable systems.
Ontology engineering in computer science, information science and systems engineering is a field which studies the
methods and methodologies for building ontologies: formal representations of a set of concepts within a domain and
the relationships between those concepts. A large-scale representation of abstract concepts such as actions, time,
physical objects and beliefs would be an example of ontological engineering.
• The general framework of concepts is called an upper ontology,
– because of the convention of drawing graphs with:
• the general concepts at the top
• the more specific concepts below them
PROLOG

Prolog is by far the most widely used logic programming language. Its users number in the hundreds of
thousands. It is used primarily as a rapid-prototyping language and for symbol-manipulation tasks such as writing
compilers (Van Roy, 1990) and parsing natural language (Pereira and Warren, 1980). It has also been used to
develop expert system applications in legal, medical, financial, and other domains.
Prolog is a programming language centered around a small set of basic mechanisms, including pattern matching,
tree-base data structuring, and automatic backtracking. This small set constitutes a surprisingly powerful and
flexible programming framework. Prolog is especially well suited for problems that involve objects - in particular,
structured objects - and relations between them.
Prolog stands for programming in logic - an idea that emerged in the early 1970s to use logic as a programming
language. Since Prolog has its roots in mathematical logic it is often introduced through logic. However, such a
mathematically intensive introduction is not very useful if the aim is to teach Prolog as a practical programming
tool.

Data types
Prolog's single data type is the term. Terms are either atoms, numbers, variables or compound terms.

An atom is a general-purpose name with no inherent meaning. Examples of atoms include x, red, 'Taco', and
'some atom'.
Numbers can be floats or integers. ISO standard compatible Prolog systems can check the Prolog flag "bounded".
Most of the major Prolog systems support arbitrary length integer numbers.
Variables are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an
upper-case letter or underscore. Variables closely resemble variables in logic in that they are placeholders for
arbitrary terms.
A compound term is composed of an atom called a "functor" and a number of "arguments", which are again
terms. Compound terms are ordinarily written as a functor followed by a comma-separated list of argument terms,
which is contained in parentheses. The number of arguments is called the term's arity. An atom can be regarded as
a compound term with arity zero. An example of a compound term is person_friends(zelda,[tom,jim]).
Special cases of compound terms:

A List is an ordered collection of terms. It is denoted by square brackets with the terms separated by commas, or
in the case of the empty list, by []. For example, [1,2,3] or [red,green,blue].
Strings: A sequence of characters surrounded by quotes is equivalent to either a list of (numeric) character codes, a
list of characters (atoms of length 1), or an atom depending on the value of the Prolog flag double_quotes. For
example, "to be, or not to be".

Logic programming is a programming paradigm in which logical assertions viewed as


programs.
 These are several logic programming systems, PROLOG is one of them.
A PROLOG program consists of several logical assertions where each is a horn clause
i.e. a clause with at most one positive literal.
Ex : P, P V Q, P → Q
The facts are represented on Horn Clause for two reasons.
1. Because of a uniform representation, a simple and efficient interpreter can write.
2. The logic of Horn Clause decidable.

 Also, The first two differences are the fact that PROLOG programs are actually sets of
Horn clause that have been transformed as follows:-
1. If the Horn Clause contains no negative literal then leave it as it is.
2. Also, Otherwise rewrite the Horn clauses as an implication, combining all of the
negative literals into the antecedent of the implications and the single positive
literal into the consequent.
 Moreover, This procedure causes a clause which originally consisted of a disjunction of
literals (one of them was positive) to be transformed into a single implication whose
antecedent is a conjunction universally quantified.
 But when we apply this transformation, any variables that occurred in negative literals
and so now occur in the antecedent become existentially quantified, while the variables in
the consequent are still universally quantified.
For example the PROLOG clause P(x): – Q(x, y) is equal to logical expression ∀x: ∃y: Q (x,
y) → P(x).
 The difference between the logic and PROLOG representation is that the PROLOG
interpretation has a fixed control strategy. And so, the assertions in the PROLOG
program define a particular search path to answer any question.
 But, the logical assertions define only the set of answers but not about how to choose
among those answers if there is more than one.
Consider the following example:
1. Logical representation
∀x : pet(x) ۸ small (x) → apartmentpet(x)
∀x : cat(x) ۸ dog(x) → pet(x)
∀x : poodle (x) → dog (x) ۸ small (x)
poodle (fluffy)
2. Prolog representation
apartmentpet (x) : pet(x), small (x)
pet (x): cat (x)
pet (x): dog(x)
dog(x): poodle (x)
small (x): poodle(x)
poodle (fluffy)

The Prolog language:


a Prolog program has the following characteristics:
• A program consists of a sequence of sentences, implicitly conjoined. All variables have implicit universal
quantification, and variables in different sentences are considered distinct.
• Only Horn clause sentences are acceptable. This means that each sentence is either an atomic sentence or an
implication with no negated antecedents and an atomic consequent.
• Terms can be constant symbols, variables, or functional terms.
• Queries can include conjunctions, disjunctions, variables, and functional terms.
• Instead of negated antecedents in implications, Prolog uses a negation as failure operator: a goal not P is
considered proved if the system fails to prove P.
• All syntactically distinct terms are assumed to refer to distinct objects. That is, you cannot assert A = B or A =
F(x), where A is a constant. You can assert x = B or x - F(y), where x is a variable.
• There is a large set of built-in predicates for arithmetic, input/output, and various system and knowledge base
functions. Literals using these predicates are "proved" by executing code rather than doing further inference.
In Prolog notation (where capitalized names are variables), the goal X is 4 + 3 succeeds with X bound to 7.
However, the goal 5 is X+Y cannot be proved, because the built-in functions do not do arbitrary equation solving.

As an example, here is a Prolog program for the Member relation, given both in normal first-order logic notation
and in the format actually used by Prolog:
An example program: defining family relations
Prolog is a programming language for symbolic, non-numeric computation. It is specially well suited for solving
problems that involve objects and relations between objects. Figure 1.1 shows an example: a family relation. The fact
that Tom is a parent of Bob can be written in Prolog as:

parent( tom, bob).

Here we choose parent as the name of a relation; tom and bob are its arguments.
FUZZY REASONING
Fuzzy Logic (FL) is a method of reasoning that resembles human reasoning. The approach of FL
imitates the way of decision making in humans that involves all intermediate possibilities between
digital values YES and NO. In fuzzy logic, the degree of truth is between 0 and 1.
Example: William is smart (0.8 truth)

The inventor of fuzzy logic, Lotfi Zadeh, observed that unlike computers, the human decision making
includes a range of possibilities between YES and NO, such as

The fuzzy logic works on the levels of possibilities of input to achieve the definite output.
Implementation
It can be implemented in systems with various sizes and capabilities ranging from small
 Micro-controllers to large, networked, workstation-based control systems.
 It can be implemented in hardware, software, or a combination of both.

Fuzzy logic is useful for commercial and practical purposes.


 It can control machines and consumer products.
 It may not give accurate reasoning, but acceptable reasoning.
 Fuzzy logic helps to deal with the uncertainty in engineering.

Fuzzy Inference Systems Architecture


It has four main parts as shown −
 Fuzzification Module − It transforms the system inputs, which are crisp numbers, into fuzzy
sets. It splits the input signal into five steps such as −
LP x is Large Positive

MP x is Medium Positive

S x is Small

MN x is Medium Negative

LN x is Large Negative
 Knowledge Base − It stores IF-THEN rules provided by experts.
 Inference Engine − It simulates the human reasoning process by making fuzzy inference on the
inputs and IF-THEN rules.
 Defuzzification Module − It transforms the fuzzy set obtained by the inference engine into a
crisp value.

A membership function for a fuzzy set A on the universe of discourse X is defined as


µA:X→[0,1].Here, each element of X is mapped to a value between 0 and 1. It is called membership
value or degree of membership.
All membership functions for LP, MP, S, MN, and LN are shown as below −
Here, the input to 5-level fuzzifier varies from -10 volts to +10 volts. Hence the corresponding output
also changes.

Example of a Fuzzy Logic System


Let us consider an air conditioning system with 5-lvel fuzzy logic system. This system adjusts the
temperature of air conditioner by comparing the room temperature and the target temperature value.

Algorithm
 Define linguistic variables and terms.
 Construct membership functions for them.
 Construct knowledge base of rules.
 Convert crisp data into fuzzy data sets using membership functions. (fuzzification)
 Evaluate rules in the rule base. (interface engine)
 Combine results from each rule. (interface engine)
 Convert output data into non-fuzzy values. (defuzzification)

Logic Development
Step 1: Define linguistic variables and terms
Linguistic variables are input and output variables in the form of simple words or sentences. For room
temperature, cold, warm, hot, etc., are linguistic terms.
Temperature (t) = {very-cold, cold, warm, very-warm, hot}
Step 2: Construct membership functions for them
The membership functions of temperature variable are as shown −

Step3: Construct knowledge base rules


Create a matrix of room temperature values versus target temperature values that an air conditioning
system is expected to provide.
RoomTemp. Very_Cold Cold Warm Very_Warm Hot
/Target

Very_Cold No_Change Heat Heat Heat Heat

Cold Cool No_Change Heat Heat Heat

Warm Cool Cool No_Change Heat Heat

Ver_Warm Cool Cool Cool No_Change Heat

Hot Cool Cool Cool Cool No_Change

Build a set of rules into the knowledge base in the form of IF-THEN-ELSE structures.
Sr. Condition Action
No.

1 IF temperature=(Cold OR Very_Cold) AND target=Warm THEN Heat

2 IF temperature=(Hot OR Very_Hot) AND target=Warm THEN Cool

3 IF (temperature=Warm) AND (target=Warm) THEN No_Change


Step 4: Obtain fuzzy value
Fuzzy set operations perform evaluation of rules. The operations used for OR and AND are Max and
Min respectively. Combine all results of evaluation to form a final result. This result is a fuzzy value.

Step 5: Perform defuzzification


Defuzzification is then performed according to membership function for output variable.

Application Areas of Fuzzy Logic


Automotive Systems
 Automatic Gearboxes
 Four-Wheel Steering
 Vehicle environment control
Consumer Electronic Goods
 Hi-Fi Systems
 Photocopiers
 Still and Video Cameras
 Television
Domestic Goods
 Microwave Ovens
 Refrigerators
 Toasters
 Vacuum Cleaners
 Washing Machines
Environment Control
 Air Conditioners/Dryers/Heaters
 Humidifiers
Advantages of Fuzzy Logic System
 Mathematical concepts within fuzzy reasoning are very simple.
 Able to modify Fuzzy Logic System by just adding or deleting rules due to flexibility of fuzzy
logic.
 Fuzzy logic Systems can take imprecise, distorted, noisy input information.
 FLSs are easy to construct and understand.
 Fuzzy logic is a solution to complex problems in all fields of life, including medicine, as it
resembles human reasoning and decision making.

Disadvantages of Fuzzy Logic System


 There is no systematic approach to fuzzy system designing.
 They are understandable only when simple.
 They are suitable for the problems which do not need high accuracy.
Temporal Logic
Temporal logic is a branch of symbolic logic which is concerned with problems on propositions that have
truth values dependent on time. Temporal logic is considered a variant of modal logic, which is a branch
of logic dealing with propositions that can be expressed as a set of possible worlds. Temporal logic is
used to touch all approaches to reasoning and representation based on time.

Applications of temporal logic include use in reasoning in philosophical issues based on time, as a
language in artificial language for encoding temporal knowledge, and as tool for formal analysis,
specification and verification of hardware and software requirements of computer applications and
systems.

One of the salient features of temporal propositions is that it mostly has either implicit or explicit
references to time conditions. This is in contrast to classical logic, which focuses on timeless
propositions. Temporal logic is one of the best and most appropriate means for reasoning with time-
related propositions, thanks to the temporal quantifiers. Although classical logic can deal with temporal
properties, the formulas often tend to be complicated as points of time need to be represented.

The concept of temporal logic was first introduced by Arthur Prior in 1960 under "tense logic" which was
further broadened by other computer scientists and logicians. Temporal logic is not focused on the truth
or falsity of formulas, rather is focused on the formulas which remain true through the flow of time, even
if valuation is altered.

Temporal logic has two types of operators: modal operators and logical operators. Model operators are
largely used in computation tree logic and linear temporal logic, whereas logical operators are mostly
truth-functional operators. Signal temporal logic, interval temporal logic, metric interval temporal logic,
linear temporal logic, computational tree logic and others form parts of temporal logic .

You might also like