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

Artificial Intelligence

Course Code: ECE434


UNIT -IV
Sonit SukhRaj Singh
Assistant Professor
UID: 15840
Email ID: sonit.15840@lpu.co.in
Domain: Robotics & Automation(D6)
School of Electronics & Engineering(SEE)
Discipline of Electronics & Communication Engineering
Syllabus
UNIT
1. Introduction to Artificial Intelligence
2. Problem Solving : state-space Search And Control Strategies
3. Problem Reduction And Game Playing
4. Logic Concept And Logic Programming
5. Prolog Programming Language
 MID TERM
1. Knowledge Representations
2. Expert Systems And Applications
3. Uncertainty Measure: Probability Theory And Fuzzy Logic
4. Machine Learning, Ann And Evolutionary Computation
5. Introduction To Intelligent Agents And Natural Language
Processing
References
 Text

 1. “Artificial Intelligence” Saroj Kaushik 1st Edition


Cengage Learning 2011
 Reference Books

 2. “Introduction to Artificial Intelligence and Expert


Systems” Dan. W. Patterson 1st Edition 1990 PHI
(Pretice Hall India).
 3. “Artificial Intelligence- A Modern Approach”
Stuart Russel Peter Norvig 3rd Edition Pearson, 2009 .
 4. “Artificial Intelligence” Elaine Rich Kevin Knight
3rd Edition 2008 Tata McGraw Hill, India
Topics to be covered in Unit IV
Logic & its Concepts
 Meaning of Logic & its need
 What is Symbolic Logic & its Types
 Propositional Logic and Predicate Logic
Various methods for proving the validity of the formulae:
 Natural Deduction System
 Axiomatic System
 Semantic Tableau Method
 Resolution Refutation Method
Predicate Logic
Logic Programming
INTRODUCTION TO LOGIC CONCEPTS &
LOGIC PROGRAMMING

 Logic was to be a branch of philosophy;


however formal logic has been studied in the
context of foundation of mathematics where it
is referred to as symbolic logic.
 Logic is concerned with the principles of
drawing valid inferences from a given set of
true statements.
 Hence, it is referred to as symbolic logic.
LOGIC
Logic is concerned with the truth of statements about the world.
Generally each statement is either TRUE or FALSE. Logic includes : Syntax ,
Semantics and Inference Procedure.
 Syntax :
Specifies the symbols in the language about how they can be combined to
form sentences. The facts about the world are represented as sentences in
logic.
 Semantic :
Specifies how to assign a truth value to a sentence based on its meaning in
the world. It Specifies what facts a sentence refers to. A fact is a claim about
the world, and it may be TRUE or FALSE.
 Inference Procedure :
Specifies methods for computing new sentences from an existing sentences.
Branches of Symbolic logic
It is divided into 2 branches:
 Propositional logic
 Predicate logic
 A Proposition refers to a declarative statement
that is either true or false (but not both) in a
given context.
 One can infer a new proposition from a given
set of propositions in the same context using
logic.
Example of Propositional Logic
Propositional Calculus
 Propositional Calculus (PC) refers to a language
of propositions in which a set of rules are used
to combine simple propositions to form
compound propositions with the help of
certain logical operators.
 These logical operators are also called as
connectives;
 These operators are: not(~), or (v), and (^),
implies ( ), and equivalence ( ).
Well-formed formula (wff)
 A wff is defined is defined as a symbol or a string
of symbols generated by the formal grammar of a
formal language of a formal language.

Properties of wff:
 The smallest unit (or an atom) is considered to be
al wff.
 If α is a wff , then ~α is also a wff.
 If α and β are wff, then (α^β ), (α˅β ), (α → β ) and
(α↔β ) are also wff.
Truth Table to prove PC
 In Propositional Calculus (PC) is used to provide
operational definitions of important logical
operators.

 The logical constants in PC are true or False


and these are represented as T or F.
Truth Table for PC…

A B ~A A^B A˅B A→B A↔B


T T F T T T T

T F F F T F F

F T T F T T F

F F T F F T T
Do it yourself
Compute the truth value of using truth table
approach.
α: (A V B) ^ (~B →A)
Equivalence Laws
NAME OF THE RELATION EQUIVALENCE RELATIONS

Commutative Law AvB≡BvA


A^B ≡B^A

Associative Law A v (B v C) ≡ (A v B) v C
A ^ (B ^ C) ≡ (A ^ B) ^ C

Double Negation ~ (~A) ≡ A

Distributive Laws A v (B ^ C) ≡ (A v B) ^ (A v C)
A ^ (B v C) ≡ (A ^ B) v (A ^ C)

De Morgan’s Laws ~(A v B) ≡ ~A ^ ~B


~(A ^ B) ≡ ~A v ~B
Equivalence Laws…
NAME OF THE RELATION EQUIVALENCE RELATIONS

Absorption Laws A v (A ^ B) ≡ A
A ^ (A v B) ≡ A
A v (~A ^ B) ≡ A v B
A ^ (~A v B) ≡ A ^ B
Idempotence AvA ≡A
A^A ≡A
Excluded Middle Law A v ~A ≡ T (True)

Contradiction Law A ^ ~ A ≡ F (False)

Commonly Used Equivalence Relations A → B ≡ ~A v B


A ↔ B ≡ (A → B) ^ (B → A)
≡ (A ^ B) v (~A ^ ~B)
Propositional Logic

 Propositional logic deals with the validity,


satisfiability (also called consistency) and
unsatisfiability (inconsistency) of a formula and
the derivation of a new formula using
equivalence laws.
Propositional Logic…
The validity, satisfiability, and unsatisfiability of
a formula may be determined on the basis of
the following conditions:
 A formula α is said to be valid if and only if it is
a tautology.
 A formula α is said to be satisfiable if there
exists at least one interpretation for which α is
true.
 A formula α is said to be unsatisfiable if the
value of α is false under all interpretations.
Example…
Show that the following is a valid argument:
If it is humid then it will rain and since it is humid today it will rain
Solution to the Example…
Let us symbolize each part of the English
sentence by propositional atoms as follows:
A: It is humid
B: It will rain
Formula α can be represented as:
α: *(A → B) ^ A+ →B
Now Solve it to calculate the value of this formula
using Truth Table method
Advantages & Disadvantage of this
method for evaluating any formula
Advantage:
 The Truth Table approach is simple and straightforward method by
providing truth values in a given situation.
 It is an easy method for evaluating consistency, inconsistency, or validity of
a formula.
Disadvantage:
 As no. of values grows, the size of truth table grows exponentially.
 For example: in order to validate α: (A ^ B ^ C ^ D) → (B v E), we require 32
rows and compute the value of α for all the 32 interpretations.
 Hence, use of truth table approach proves to be wastage of time for various
cases. Therefore, we require some other methods which can help in proving
the validity of the formula directly.
Various methods for proofs &
Deduction
Some methods apart from the Truth Table
method that are concerned with proofs and
deductions are as follows:
 Natural Deduction System
 Axiomatic System
 Semantic Tableau Method
 Resolution Refutation Method
Natural Deduction system
 Natural deduction system (NDS) is called so
because of the fact that it mimics the pattern
of natural reasoning.

 NDS is based on a set of deductive inference


rules.
NDS Rules Table

RULE NAME SYMBOL RULE DESCRIPTION

Introducing ^ (I: ^) If A1, ………..An then If A1, A2,…An is true, then


A1^…….^An their conjunction is also true.

Eliminating ^ (E:^) If A1^ A2 ^……^An If A1^ A2^……An is true, then


then Ai(1<=i<=n) any Ai is also true

Introducing v (I: v) If any Ai (1<=i<=n) If any Ai (1<=i<=n) is true,


then A1 v Av…..vAn then A1v A2 v …..v An is also
true
Eliminating v (E:v) If A1 v A2 v……..vAn, If A1 v A2 v A3 v …… v An are
then A is true true, then A is true
NDS Rules Table…
RULE NAME SYMBOL RULE DESCRIPTION

Introducing → (I: →) If given that α1, ……αn are true and


If from α1,………. αn infer β from these we deduce β then α1^
is proved then α2^……αn→β is also true
α1,……αn→β is proved
Eliminating → (E:→) If A1→A, A1 , then A If A1→A is true and A1 is also true,
then A is also true. This is called as
Modus Ponen (MP) rule
Introducing ↔ (I: ↔) If A1→A2, A2→A1, then If A1→A2 and A2→A1 is true, then
A1 ↔ A2 A1 ↔ A2 is also true

Eliminating ↔ (E:↔) If A1 ↔ A2 then A1→A2, If A1 ↔ A2 is true then A1→A2 &


A2→A1 A2→A1 are also true

Introducing ~ (I: ~) If from A infer A1 ^ ~A1 is If from A (which is true), a


proved then ~A is proved contradiction is proved then truth
of ~A is also proved
Example
Prove that A ^ (B v C) is deduced from A ^ B
Description Formula Comments

Theorem From A^B infer A^(BvC) To be proved

Hypothesis(given) A^B 1

E: ^(1) A 2

E: ^(1) B 3

I: v(3) BvC 4

I: ^(2,4) A ^ (B v C) Proved
Example: NDS HOMEWORK
Prove the theorem infer *(A → B) ^ (B →C)+ →(A →C)
Axiomatic System
 The axiomatic system is based on a set of 3 axioms and one
rule of deduction.
 In axiomatic system, the proofs of the theorem are often
difficult and require a guess in selection of appropriate axiom.
 In this system, only two operators are used to form a formula:
not (~) and implies (→).
 These can be converted as follows:
A ^ B) ≡ ~(~A v B) ≡ ~(A →~B)
A v B ≡ ~A →B
A ↔ B ≡ (A →B) ^ (B →A) ≡ ~[(A →B) → ~ (B →A) ]
3 Axioms & 1Rule
Axiom 1: α → (β → α)
Axiom 2: [α → (β → ϒ)] → [(α → β) → (α → ϒ)]
Axiom 3: (~α → ~β) → (β → α)

Modus Ponen Rule


Hypothesis: α → β, and α, Consequent: β
Example
Establish that A → C is a deductive consequence
of ,A →B, B →C-
Description Formula Comments
Theorem ,A →B, B →C- І- (A →C) Prove
Hypothesis 1 A →B 1
Hypothesis 2 B →C 2
Instance of Axiom 1 (B →C) → *A → (B →C)+ 3
MP(2,3) [A → (B →C)+ 4
Instance of Axiom 2 [A →(B→C)+ → *(A→B) →(A→C)+ 5
MP(4,5) (A →B) → (A → C) 6
MP(1,6) (A → C) Proved
Semantic Tableau System in
Propositional Logic
 Semantic tableau is a binary tree which is
constructed by using semantic tableau rules
with a formula as a root.
 Both NDS and Axiomatic System uses forward
Chaining Approach.
 Semantic tableau methods as well as
Resolution Refutation method uses backward
chaining method.
Semantic Tableau Rules
Semantic Tableau Rules…
Example: Semantic Tableau
Example: Semantic Tableau.
Example: Semantic Tableau.
Resolution Refutation in
Propositional Logic
 Clause is defined as a special formula
containing the boolean operators ~ and v.
 Resolution Refutation method is the most
favoured method for developing computer
based systems that can be used to prove
theorems automatically.
 In this method, the negation of the goal to be
proved is added to the given set of clauses, and
using the resolution principle, it is shown that
there is a refutation in the new set.
Conversion of Formula to set of
Clauses
There are 2 Normal Forms:
 Disjunctive Normal Form (DNF)
 Conjunctive Normal Form (CNF)
Conversion of a Formula to its CNF
 Eliminate double negation signs by using
~(~A) ≡ A
 Use De Morgan’s law to push ~(negation) immediately before the
atomic formula
~(A ^ B) ≡ ~A v ~B
~(A v B) ≡ ~A ^ ~B
 Use Distributive law to get CNF
A v (B ^ C) ≡ (A v B) ^ (A v C)
 Eliminate the ↔ & → by using following equivalence laws:
A→B≡~AvB
A ↔ B ≡ (A → B) ^ (B → A)
Resolution of Clauses
 Two clauses can be resolved by eliminating
complimentary pair of literals, from both.
 A new clause is formed by disjunction of the
remaining literals in both the clauses.
 The complimentary literals are resolved
together by deleting complimentary literals
and hence a new clause is formed.
Example of Resolution
Example of Resolution
Predicate Logic
 It is the extension of Propositional Logic.

 Due to the disadvantages of propositional


logic, there is the need of predicate logic.

 It will provide more better inferencing and also


to have common validation mechanism.
Predicate Logic
The propositional logic, is not powerful enough for all types of
assertions;
Example : The assertion "x > 1", where x is a variable, is not a
proposition because it is neither true nor false unless value of x
is defined.
For x > 1 to be a proposition ,
– either we substitute a specific number for x ;
– or change it to something like
"There is a number x for which x > 1 holds";
– or "For every number x, x > 1 holds".
Predicate logic
Consider example :
“All men are mortal.
Socrates is a man.
Then Socrates is mortal” ,
These cannot be expressed in propositional logic as a finite and logically
valid argument (formula).
We need languages : that allow us to describe properties (predicates)
of objects, or a relationship among objects represented by the
variables .
Predicate logic satisfies the requirements of a language.
− Predicate logic is powerful enough for expression and reasoning.
− Predicate logic is built upon the ideas of propositional logic.
Using Predicate Logic
1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeians were Romans.
4. Caesar was a ruler.
5. All Pompeians were either loyal to Caesar or hated him.
6. Every one is loyal to someone.
7. People only try to assassinate rulers they are not loyal to.
8. Marcus tried to assassinate Caesar.
Predicate Logic Example
1. Marcus was a man.
man(Marcus)
2. Marcus was a Pompeian.
Pompeian(Marcus)
3. All Pompeians were Romans.
x: Pompeian(x)  Roman(x)
4. Caesar was a ruler.
ruler(Caesar)
Predicate Logic Example
5. All Pompeians were either loyal to Caesar or hated him.
inclusive-or
x: Pompeians (x)  loyalto(x, Caesar)  hate(x, Caesar)

exclusive-or
x: Pompeians (x)  (loyalto(x, Caesar)  hate(x, Caesar)) 
(loyalto(x, Caesar)  hate(x, Caesar))
Predicate Logic Example...
6. Every one is loyal to someone.
x: y: loyalto(x, y)

y: x: loyalto(x, y)


Predicate Logic Example

7. People only try to assassinate rulers they


are not loyal to.
x: y: person(x)  ruler(y) 
tryassassinate(x, y)  loyalto(x, y)
8. Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
Using Predicate Logic
Was Marcus loyal to Caesar?

Using 7 & 8 fact, we can predict


Backward chaining
man(Marcus)
ruler(Caesar)
tryassassinate(Marcus, Caesar)
 x: man(x)  person(x)
loyalto(Marcus, Caesar)
Resolution
The basic ideas

KB |=  KB   |=false

(  )  (  )  (  )

sound and complete


Conversion to Clause Form
1. Eliminate .
P  Q  P  Q
2. Reduce the scope of each  to a single term.
(P  Q)  P  Q
(P  Q)  P  Q
x: P  x: P
x: p  x: P
 P  P

3. Standardize variables so that each quantifier binds a unique


variable.
(x: P(x))  (x: Q(x))  (x: P(x))  (y: Q(y))
Conversion to Clause Form
4. Move all quantifiers to the left without changing their relative order.
(x: P(x))  (y: Q(y))  x: y: (P(x)  (Q(y))
5. Eliminate  (Skolemization).
x: P(x)  P(c) Skolem constant
x: y P(x, y)  x: P(x, f(x)) Skolem function
6. Drop .
x: P(x)  P(x)
7. Convert the formula into a conjunction of disjuncts.
(P  Q)  R  (P  R)  (Q  R)
8. Create a separate clause corresponding to each conjunct.
9. Standardize apart the variables in the set of obtained clauses.
Conversion to Clause Form Summary
1. Eliminate .
2. Reduce the scope of each  to a single term.
3. Standardize variables so that each quantifier binds a unique variable.
4. Move all quantifiers to the left without changing their relative order.
5. Eliminate  (Skolemization).
6. Drop .
7. Convert the formula into a conjunction of disjuncts.
8. Create a separate clause corresponding to each conjunct.
9. Standardize apart the variables in the set of obtained clauses.
Example
1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeians were Romans.
4. Caesar was a ruler.
5. All Pompeians were either loyal to Caesar or hated him.
6. Every one is loyal to someone.
7. People only try to assassinate rulers they are not loyal to.
8. Marcus tried to assassinate Caesar.
Example
1. Man(Marcus).
2. Pompeian(Marcus).
3. x: Pompeian(x)  Roman(x).
4. ruler(Caesar).
5. x: Roman(x)  loyalto(x, Caesar)  hate(x, Caesar).
6. x: y: loyalto(x, y).
7. x: y: person(x)  ruler(y)  tryassassinate(x, y)
 loyalto(x, y).
8. tryassassinate(Marcus, Caesar).
Example
Prove:
hate(Marcus, Caesar)
To prove Marcus is dead
To prove Marcus is dead
More Questions that can be raised
1. When did Marcus die?
2. Whom did Marcus hate?
3. Who tried to assassinate a ruler?
4. What happen in 79 A.D.?.
5. Did Marcus hate everyone?
Logic programming
• Program is usually a collection of program
clauses.
• A clausal notation is written in the form
P1,…..Pk N1,…., Nt where Pi are positive
literals And Nj are negative literals.
• The goals or queries are solved , derived or
proved from a logic program using resolution
principle.
Consider the following logic
program
Example
• Check whether the ground goal
• grandmother(‘Mary’, ‘Mike’ ) is true
• Add negation of the goal to the set of PL to get a new set S where S
is defined as PL U ,˜G -
Solution
The resolution tree is generated as
shown in fig:
Resolution Method
• Resolution is a powerful inference technique
which takes two clauses as input and produces
a new clause as output. The output clause is
called resolvent

• There are important cases of resolution used in


reasoning
– Backward chaining
– Forward chaining
Resolution Method
Resolution Method
Resolution Method
Resolution methods
Resolution methods

You might also like