UNIT -IV 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 1 st 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
AB
AB
AB 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 A v B B v A 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 Morgans 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 A v A 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: 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 A1^.^An If A1, A2,An is true, then their conjunction is also true. Eliminating ^ (E:^) If A1^ A2 ^^An then Ai(1<=i<=n)
If A1^ A2^An is true, then any Ai is also true Introducing v (I: v)
If any Ai (1<=i<=n) then A1 v Av..vAn If any Ai (1<=i<=n) is true, then A1v A2 v ..v An is also true Eliminating v (E:v)
If A1 v A2 v..vAn, then A is true If A1 v A2 v A3 v v An are true, then A is true NDS Rules Table
RULE NAME
SYMBOL
RULE
DESCRIPTION Introducing (I: ) If from 1,. n infer is proved then 1,n is proved If given that 1, n are true and from these we deduce then 1^ 2^n is also true Eliminating (E:) If A1A, A1 , then A If A1A is true and A1 is also true, then A is also true. This is called as Modus Ponen (MP) rule Introducing (I: ) If A1A2, A2A1, then A1 A2 If A1A2 and A2A1 is true, then A1 A2 is also true
Eliminating (E:) If A1 A2 then A1A2, A2A1 If A1 A2 is true then A1A2 & A2A1 are also true
Introducing ~ (I: ~) If from A infer A1 ^ ~A1 is proved then ~A is proved If from A (which is true), a contradiction is proved then truth of ~A is also proved Eliminating ~ (E:~) If from ~A infer A1^~A1 is proved, then A is proved If from ~A, a 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) B v C 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) ]
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 (BC)+ *(AB) (AC)+ 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 list 1 Semantic Tableau Rules list 2
Semantic Tableau Rules list 3 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 Morgans 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 ~ A v B 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) v 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 |= o KB . o |= false (o v |) . ( v |) (o v ) sound and complete Conversion to Clause Form 1. Eliminate . P Q P v Q 2. Reduce the scope of each to a single term. (P v Q) P . Q (P . Q) P v 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)) v (-x: Q(x)) (x: P(x)) v (-y: Q(y))
Conversion to Clause Form 4. Move all quantifiers to the left without changing their relative order. (x: P(x)) v (-y: Q(y)) x: -y: (P(x) v (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) v R (P v R) . (Q v 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.
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?