Introduction to Artificial Intelligence (AI101) Lecture Notes - Chitkara University PDF

Document Details

IndebtedTantalum

Uploaded by IndebtedTantalum

Chitkara University

Dr. Aditi Moudgil

Tags

artificial intelligence AI logic knowledge representation

Summary

This document provides lecture notes on Unit 4 of a course titled 'Introduction to Artificial Intelligence' (AI101). It covers the topic of logic, focusing on the Wumpus world as a knowledge representation example. The syllabus for the course and relevant textbook details are also included.

Full Transcript

Unit- 4 Introduction to Artificial Intelligent [AI101] Dr. Aditi Moudgil Department Assistantof Computer Science and Engineering Professor Chitkara University, Punjab Syllabus Unit - 1 Introduction to Artif...

Unit- 4 Introduction to Artificial Intelligent [AI101] Dr. Aditi Moudgil Department Assistantof Computer Science and Engineering Professor Chitkara University, Punjab Syllabus Unit - 1 Introduction to Artificial Intelligence [4 hrs] Introduction of Artificial Intelligence: Definition, Goals of AI, Applications areas of AI, History of AI, Types of AI, Importance of Artificial Intelligence, Intelligent agents and environment. Unit - 2 Searching [6 hrs] Searching: Search algorithm terminologies, properties for search algorithms, Search Algorithms, Uninformed Search Algorithms, Informed Search Algorithms, Hill Climbing Algorithm, Means-Ends Analysis. Unit - 3 Knowledge [9 hrs] Knowledge-Based Agent, Architecture of knowledge-based agent, Inference system, Propositional Logic, Rules of Inference, Operations performed by Knowledge-Based Agent, Knowledge Representation, Types of Knowledge, Approaches to knowledge representation,2 Syllabus Unit - 4 Logic [11 hrs] The Wumpus world, knowledge-base for Wumpus World, First-order logic, Knowledge Engineering in FOL, Inference in First-Order Logic, Unification in FOL, Resolution in FOL, Forward Chaining and backward chaining, Backward Chaining vs forwarding Chaining, Reasoning in AI, Inductive vs. Deductive reasoning. Textbooks 1. Introduction to Artificial Intelligence & Expert Systems' by Dan W. Patterson, Englewood Cliffs, NJ, 1990, Prentice-Hall International. Reference Books 1. 'Artificial Intelligence’ by Elaine Rich, Kevin Knight, Shivashankar B Nair, (McGraw-Hill) 2. ‘Artificial Intelligence A Modern Approach, ‘ by Stuart J. Russell and Peter Norvig, Third Edition, Prentice-Hall. 3 Contents Unit - 4 Logic [11 hrs] The Wumpus world Unification in FOL knowledge-base for Resolution in FOL Wumpus World First-order logic Forward Chaining and backward chaining Knowledge Engineering Backward Chaining in FOL vs forwarding Chaining Inference in First-Order Reasoning in AI Logic 4 The Wumpus World in AI The Wumpus world is a simple world example to illustrate the worth of a knowledge-based agent and to represent knowledge representation. It was inspired by the video game Hunt the Wumpus by Gregory Yob in 1973. Wumpus world: The Wumpus world is a cave that has 4*4 rooms connected with passageways. So there are total of 16 rooms which are connected with each other. We have a knowledge-based agent who will go forward in this world. The cave has a room with a beast which is called5 The Wumpus World in AI The Wumpus can be shot by the agent, but the agent has a single arrow. In the Wumpus world, there are some Pits rooms that are bottomless, and if the agent falls in Pits, then he will be stuck there forever. The exciting thing with this cave is that in one room there is a possibility of finding a heap of gold. So the agent’s goal is to find the gold and climb out of the cave without falling into Pits or being eaten by Wumpus. The agent will get a reward if he comes out with gold, 6 and he will get a penalty if eaten by Wumpus or falls The Wumpus World in AI 7 The Wumpus World in AI There are also some components that can help the agent to navigate the cave. These components are given as follows: 1. The rooms adjacent to the Wumpus room are smelly so that they would have some stench. 2. The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will perceive the breeze. 3. There will be glitter in the room if and only if the room has gold. 4. The Wumpus can be killed by the agent if the agent is 8 facing it, and Wumpus will emit a horrible scream The Wumpus World in AI PEAS description of Wumpus world: Performance measure - +1000 reward points if the agent comes out of the cave with the gold. -1000 points penalty for being eaten by the Wumpus or falling into the pit. -1 for each action, and -10 for using an arrow. The game ends if either agent dies or came out of the cave. 9 The Wumpus World in AI PEAS description of Wumpus world: Environment - A 4*4 grid of rooms. The agent is initially in room square [1, 1], facing toward the right. Location of Wumpus and gold are chosen randomly except the first square [1,1]. Each square of the cave can be a pit with a probability 0.2 except the first square. 10 The Wumpus World in AI PEAS description of Wumpus world: Actuators - Left turn Right turn Move forward Grab Release Shoot 11 The Wumpus World in AI PEAS description of Wumpus world: Sensors: The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not diagonally). The agent will perceive breeze if he is in the room directly adjacent to the Pit. The agent will perceive the glitter in the room where the gold is present. The agent will perceive the bump if he walks into a wall. When the Wumpus is shot, it emits a horrible scream 12 The Wumpus World in AI The Wumpus world Properties: Partially observable: The Wumpus world is partially observable because the agent can only perceive the close environment such as an adjacent room. Deterministic: It is deterministic, as the result and outcome of the world are already known. Sequential: The order is important, so it is sequential. Static: It is static as Wumpus and Pits are not moving. Discrete: The environment is discrete. One agent: The environment is a single agent as we have one agent only and Wumpus is not considered as an agent. 13 The Wumpus World in AI Now we will explore the Wumpus world and will determine how the agent will find its goal by applying logical reasoning. Agent's First step: Initially, the agent is in the first room or on the square [1,1], and we already know that this room is safe for the agent, so to represent on the below diagram (a) that room is safe we will add a symbol OK. Symbol A is used to represent agent, symbol B for the breeze, G for Glitter or gold, V for the visited room, P for pits, W for Wumpus. At Room [1,1] agent does not feel any breeze or any 14 Stench which means the adjacent squares are also OK. The Wumpus World in AI 15 The Wumpus World in AI Agent's second Step: Now agent needs to move forward, so it will either move to [1, 2], or [2,1]. Let's suppose agent moves to the room [2, 1], at this room agent perceives some breeze which means Pit is around this room. The pit can be in [3, 1], or [2,2], so we will add symbol P? to say that, is this Pit room? Now agent will stop and think and will not make any harmful move. The agent will go back to the [1, 1] room. The room [1,1], and [2,1] are visited by the agent, so we will use symbol V to represent the visited squares. 16 The Wumpus World in AI Agent's third step: At the third step, now the agent will move to the room [1,2] which is OK. In the room [1,2] agent perceives a stench which means there must be a Wumpus nearby. But Wumpus cannot be in the room [1,1] as by rules of the game, and also not in [2,2] (Agent had not detected any stench when he was at [2,1]). Therefore agent infers that Wumpus is in the room [1,3], and in current state, there is no breeze which means in [2,2] there is no Pit and no Wumpus. So it is safe, and we will mark it OK, and the agent moves further in [2,2]. Agent's fourth step: At room [2,2], here no stench and no breezes present 17so let's suppose agent decides to move to [2,3]. At room The Wumpus World in AI 18 Knowledge-base for Wumpus World The agent starts visiting from the first square [1, 1], and we already know that this room is safe for the agent. To build a knowledge base for the wumpus world, we will use some rules and atomic propositions. We need symbol [i, j] for each location in the wumpus world, where i 19 is for the location of Knowledge-base for Wumpus World Atomic proposition variable for Wumpus world: Let Pi,j be true if there is a Pit in the room [i, j]. Let Bi,j be true if the agent perceives breeze in [i, j], (dead or alive). Let Wi,j be true if there is wumpus in the square[i, j]. Let Si,j be true if the agent perceives stench in the square [i, j]. Let Vi,j be true if that square[i, j] is visited. Let Gi,j be true if there is gold (and glitter) in the square [i, j]. Let OKi,j be true if the room is safe. 20 Knowledge-base for Wumpus World Some Propositional Rules for the wumpus world: 21 Knowledge-base for Wumpus World Representation of Knowledgebase for Wumpus world: Following is the Simple KB for wumpus world when an agent moves from room [1, 1], to room [2,1]: Here in the first row, we have mentioned propositional variables for room[1,1], which is showing that room does not have wumpus(¬ W11), no stench (¬S11), no Pit(¬P11), no breeze(¬B11), no gold (¬G11), visited 22 (V11), and the room is Safe(OK11). Knowledge-base for Wumpus World Representation of Knowledgebase for Wumpus world: In the second row, we have mentioned propositional variables for room [1,2], which is showing that there is no wumpus, stench and breeze are unknown as an agent has not visited room [1,2], no Pit, not visited yet, and the room is safe. In the third row we have mentioned propositional variable for room[2,1], which is showing that there is no wumpus(¬ W21), no stench (¬S21), no Pit (¬P21), Perceives breeze(B21), no glitter(¬G21), visited (V21), and room is safe (OK21). 23 Prove that Wumpus is in the room (1, 3) Apply Modus Ponens with ¬S11 and R1 We will firstly apply MP rule with R1 which is ¬S11 → ¬ W11 ^ ¬ W12 ^ ¬ W21, and ¬S11 which will give the output ¬ W11 ^ W12 ^ W12. Faculty Name - GroupNo 24 Prove that Wumpus is in the room (1, 3) Simplification Rule: After applying Simplification rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21, we will get three statements: ¬ W11, ¬ W12, and ¬W21. Apply Modus Ponens to ¬S21, and R2: Now we will apply Modus Ponens to ¬S21 and R2 which is ¬S21 → ¬ W21 ∧¬ W22 ∧ ¬ W31, which will give the Output as ¬ W21 ∧ ¬ W22 ∧¬ W31 Faculty Name - GroupNo 25 Prove that Wumpus is in the room (1, 3) Simplification rule: Now again apply Simplification rule to ¬ W21 ∧ ¬ W22 ∧¬ W31, We will get three statements: ¬ W21, ¬ W22, and ¬ W31. Apply MP to S12 and R4: Apply Modus Ponens to S12 and R4 which is S12 → W13 ∨. W12 ∨. W22 ∨.W11, we will get the output as W13∨ W12 ∨ W22 ∨.W11. Faculty Name - GroupNo 26 Prove that Wumpus is in the room (1, 3) Apply Disjunctive Syllogism on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 : After applying Disjunctive Syllogism formula on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 we will get W13 ∨ W12 ∨ W22. Faculty Name - GroupNo 27 Prove that Wumpus is in the room (1, 3) Apply Disjunctive Syllogism on W13 ∨ W12 ∨ W22 and ¬ W22 : After applying Disjunctive Syllogism on W13 ∨ W12 ∨ W22, and ¬W22, we will get W13 ∨ W12 as output. Faculty Name - GroupNo 28 Prove that Wumpus is in the room (1, 3) After Applying Disjunctive Syllogism on W13 ∨ W12 and ¬ W12, we will get W13 as an output, hence it is proved that the Wumpus is in the room [1, 3]. Faculty Name - GroupNo 29 First-Order Logic First-order logic is another way of knowledge representation in artificial intelligence. It is an extension to propositional logic. FOL is sufficiently expressive to represent the natural language statements in a concise way. 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. 30 First-Order Logic 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: Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus,...... 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 Function: Father of, best friend, third inning of, end of,...... As a natural language, first-order logic also has two 31 main parts: First-Order Logic Basic Elements of First-order logic: Constant 1, 2, A, John, Mumbai, cat,.... Variables x, y, z, a, b,.... Predicates Brother, Father, >,.... Function sqrt, LeftLegOf,.... Connectives ∧, ∨, ¬, ⇒, ⇔ Equality == Quantifier ∀, ∃ 32 First-Order Logic Atomic sentences: 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. 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: Complex sentences are made by combining atomic 33 sentences using connectives. First-Order Logic First-order logic statements can be divided into two parts: Subject: Subject is the main part of the statement. 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 the second part “is an integer,” which is known as a predicate. 34 First-Order Logic Quantifiers in First-order logic: A quantifier is a language element that generates quantification, and quantification specifies the quantity of specimen in the universe of discourse. 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 quantifiers: Universal Quantifier, (for all, everyone, everything) Existential quantifier, (for some, at least one). 35 First-Order Logic 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. If x is a variable, then ∀x is read as: For all x For each x For every x. Example: All man drink coffee. 36 First-Order Logic Universal Quantifier: ∀x man(x) → drink (x, coffee). It will be read as: There are all x where x is a man who drink coffee. 37 First-Order Logic 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. If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as: There exists a 'x.’ For some 'x.’ For at least one 'x.’ 38 First-Order Logic Existential Quantifier: 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. 39 First-Order Logic Points to remember: The main connective for universal quantifier ∀ is implication →. Let F be the domain of fruits and A(x):is an apple D(x):is delicious Let's say: ∀x∈F,A(x) → D(x) Is correct and means all apples are delicous. Whereas, ∀x∈F,A(x)∧D(x) is incorrect because this would be saying that all fruits are apples and delicious which is wrong. 40 First-Order Logic Points to remember: The main connective for existential quantifier ∃ is and ∧. But when it comes to the existential quantifier: ∃x∈F,A(x)∧D(x) Is correct and means there is some apple that is delicious. Also, ∃x∈F,A(x) → D(x) Is incorrect, it says there is some fruit that if it is an apple, it is delicious. Faculty Name - GroupNo 41 Knowledge Engineering in FOL The process of constructing a knowledge base in first- order logic is called knowledge- engineering. In knowledge engineering, someone who investigates a particular domain, learns the important concept of that domain, and generates a formal representation of the objects, is known as a knowledge engineer. 42 Knowledge Engineering in FOL The Knowledge-Engineering process :- Following are some main steps of the knowledge- engineering process. Using these steps, we will develop a knowledge base that will allow us to reason about digital circuits (One-bit full adder) which is given below: 1. Identify the task: At the first level or highest level, we will examine the functionality of the circuit: Does the circuit add properly? What will be the output of gate A2, if all the inputs are high? At the second level, we will examine the circuit structure details such as: 43 Knowledge Engineering in FOL The Knowledge-Engineering process :- 2. Assemble the relevant knowledge: In the second step, we will assemble the relevant knowledge which is required for digital circuits. So for digital circuits, we have the following required knowledge: Logic circuits are made up of wires and gates. Signal flows through wires to the input terminal of the gate, and each gate produces the corresponding output which flows further. In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT. All these gates have one output terminal and two input terminals (except NOT gate, it has one input terminal).44 Knowledge Engineering in FOL The Knowledge-Engineering process :- 3. Decide on vocabulary: To select functions, predicates, and constants to represent the circuits, terminals, signals, and gates. Each gate is represented as an object which is named by a constant, Gate(X1), Gate(X2). Constants such as AND, OR, XOR, or NOT. Circuits will be identified by a predicate: Circuit (C1). For the terminal, we will use the predicate: Terminal(x). For gate input, In(1, X1) and for output Out (1, X2). Arity(c, i, j) is used to denote that circuit c has i input, j output. 45 The connectivity between gates can be represented by Knowledge Engineering in FOL The Knowledge-Engineering process:- 4. Encode general knowledge about the domain: To encode the general knowledge about the logic circuit, we need the following rules: If two terminals are connected then they have the same signal, it can be represented as: ∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Signal (t2). Signal at every terminal will have either value 0 or 1, it will be represented as: ∀ t Terminal (t) →Signal (t) = 1 ∨ Signal (t) = 0. 46 All gates are logic circuits: Knowledge Engineering in FOL The Knowledge-Engineering process:- 5. Encode a description of the problem instance: Now we encode the problem of circuit C1, firstly we categorize the circuit and its gate components. This step involves writing simple atomics sentences of instances of concepts, which is known as ontology. Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates will be: For XOR gate: Type(x1)= XOR, Type(X2) = XOR For AND gate: Type(A1) = AND, Type(A2)= AND For OR gate: Type (O1) = OR. And then represent the connections between all the gates. 47 Knowledge Engineering in FOL The Knowledge-Engineering process:- 6. Pose queries to the inference procedure and get answers: In this step, we will find all the possible sets of values of all the terminals for the adder circuit. The first query will be: What should be the combination of input that would generate the first output of circuit C1, like 0, and a second output to be 1? ∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))= i2 ∧ Signal (In(3, C1))= i3 ∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1 48 Knowledge Engineering in FOL The Knowledge-Engineering process:- 7. Debug the knowledge base: Now we will debug the knowledge base, and this is the last step of the complete process. In this step, we will try to debug the issues of the knowledge base. 49 Inference in First-Order Logic Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences. Some basic terminologies used in FOL: Substitution: Substitution is the process of replacing one or more variables in a logical formula with specific terms. For example, in the formula "∀x, P(x)", if we substitute "a" for "x", the formula becomes "P(a)". Substitution is used to make a logical formula more specific by replacing variables with specific terms. Equality: Equality is a relation between two terms that states that they have the same value. Equality is represented by the symbol "=". For example, "a = b" states that a and b are equal. Equality is used to check if two terms are equal, and it can be 50 used in logical formulas to check if two terms have the same Inference in First-Order Logic Equality: 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. 51 Inference in First-Order Logic FOL inference rules for quantifier: As propositional logic, we also have inference rules in first-order logic, so the following are some basic inference rules in FOL: Universal Generalization Universal Instantiation Existential Instantiation Existential Introduction 52 Inference in First-Order Logic FOL inference rules for quantifier: 1. Universal Generalization: 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). It can be represented as: 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 ∀ x P(x) "All bytes contain 8 bits.", it 53 Inference in First-Order Logic FOL inference rules for quantifier: 2. Universal Instantiation: Universal instantiation is also called universal elimination or UI is a valid inference rule. It can be applied multiple times to add new sentences. The new KB is logically equivalent to the previous KB. As per UI, we can infer any sentence obtained by substituting a ground term for the variable. The UI rule state that we can infer any sentence P(c) by substituting a ground term c (a constant within domain x) from ∀ x P(x) for any object in the universe of discourse. It can be represented as: 54 Faculty Name - GroupNo 55 Faculty Name - GroupNo 56 Inference in First-Order Logic FOL inference rules for quantifier: 3. Existential Instantiation: Existential instantiation is also called Existential Elimination, which is a valid inference rule in first-order logic. This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a some constant symbol c. It can be represented as: 57 Inference in First-Order Logic FOL inference rules for quantifier: 4. Existential Introduction: An existential introduction is also known as an existential generalization, which is a valid inference rule in first-order logic. This rule states that if there is some element c in the universe of discourse that has a property P, then we can infer that there exists something in the universe which has the property P. It can be represented as: Example: Let's say that, "Priyanka got good marks in English." 58 "Therefore, someone got good marks in English.“ Faculty Name - GroupNo 59 Faculty Name - GroupNo 60 Unification in FOL What is Unification? Unification is a process of making two different logical atomic expressions identical by finding a substitution. Unification depends on the substitution process. It takes two literals as input and makes them Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be identical using substitution. a unifier such that, Ψ1𝜎 = Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2). 61 Unification in FOL 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) 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. With both the substitutions, the first expression will be 62 identical to the second expression and the substitution Unification in FOL Conditions for Unification: Predicate symbol must be same, atoms or expression with different predicate symbol can never be unified. Number of Arguments in both expressions must be identical. Unification will fail if there are two similar variables present in the same expression. For example, given the expressions "P(x,y) ∧ Q(y,z)" and "P(a,b) ∧ Q(c,z)", we cannot use unification to find a substitution that makes the two expressions identical. The reason is that the variable y in the first expression is assigned the value b in the second expression and assigned value c, this is a 63 contradiction and the two expressions cannot be made Resolution in FOL Resolution is a technique used to infer new logical statements from a given set of statements. 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. 64 Resolution in FOL 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)]. 65 Forward Chaining and Backward Chaining Inference Engine: An inference engine is a software component that is responsible for automatically inferring new logical statements from a given set of statements, using a set of inference rules. Inference engines are commonly used in artificial intelligence and knowledge representation to perform automated reasoning and theorem proving. There are two main types of inference engines: 1.Forward chaining 2.Backward chaining Horn Clause and Definite clause: Horn clause and definite clause are the forms of sentences, which enables the knowledge base to use a more restricted and efficient inference algorithm. Logical inference algorithms use forward and backward chaining approaches, which require 66 KB in the form of the first-order definite clause. Forward Chaining and Backward Chaining Definite clause: A clause that 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. 67 Forward Chaining and 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 starts with atomic sentences in the knowledge base and applies inference rules 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 adds their conclusion to the known facts. This process repeats until the problem is solved. 68 Forward Chaining and Backward Chaining Properties of Forward-Chaining: It is a down-up approach, as it moves from bottom to top. 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. Forward-chaining approach is also called as data- driven as we reach to the goal using available data. Forward -chaining approach is commonly used in the expert system, such as CLIPS, business, and production rule systems. 69 Forward Chaining and Backward Chaining Example: Consider the following famous example which we will use in both approaches: "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. 70 Start with the given premise "As per the law, it is a crime for an American to sell weapons to hostile nations." Next, we use the fact "Country A, an enemy of America, has some missiles" to infer that "Country A is a hostile nation." Then we use the fact "All the missiles were sold to [Country A] by Robert, who is an American citizen" to infer that "Robert sold weapons to [Country A]." Finally, we use the premise "As per the law, it is a crime for an American to sell weapons to hostile nations" and the inference "Country A is a hostile nation" and "Robert sold weapons to [Country A]" to conclude "Robert is criminal." Faculty Name - GroupNo 71 Forward Chaining and Backward Chaining 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: It is known as a top-down approach. Backward-chaining is based on modus ponens inference rule. In backward chaining, the goal is broken into sub-goal 72 or sub-goals to prove the facts true. Forward Chaining and Backward Chaining It is called a goal-driven approach, as a list of goals decides which rules are selected and used. Backward -chaining algorithm is used in game theory, automated theorem proving tools, inference engines, proof assistants, and various AI applications. The backward-chaining method mostly used a depth- first search strategy for proof. 73 Start with the goal "Prove that Robert is criminal" To prove this goal, we need to show that "Robert sold weapons to a hostile nation." We know that "Country A, an enemy of America, has some missiles." So we can infer that "Country A is a hostile nation." We also know that "All the missiles were sold to [Country A] by Robert, who is an American citizen." So we can infer that "Robert sold weapons to [Country A]." Now we have the evidence that "Robert sold weapons to a hostile nation." We also know that "As per the law, it is a crime for an American to sell weapons to hostile nations." Combining the evidence that "Robert sold weapons to a hostile nation" and "As per the law, it is a crime for an American to sell weapons to hostile nations", we can conclude that "Robert is criminal." Faculty Name - GroupNo 74 Backward Chaining vs Forwarding Chaining S. Forward Chaining Backward Chaining No. 1. Forward chaining starts Backward chaining starts from known facts and from the goal and works applies inference rule to backward through inference extract more data unit it rules to find the required reaches to the goal. facts that support the goal. 2. It is a bottom-up approach It is a top-down approach 3. Forward chaining is known Backward chaining is known as data-driven inference as goal-driven technique as technique as we reach to we start from the goal and the goal using the available divide into sub-goal to data. extract the facts. 4. Forward chaining reasoning Backward chaining applies a breadth-first reasoning applies a depth- search strategy. first search strategy. 75 Backward Chaining vs Forwarding Chaining S. No. Forward Chaining Backward Chaining 6. Forward chaining is suitable Backward chaining is for the planning, monitoring, suitable for control, and interpretation diagnostic, application. prescription, and debugging application. 7. Forward chaining can Backward chaining generate an infinite number generates a finite of possible conclusions. number of possible conclusions. 8. It operates in the forward It operates in the direction. backward direction. 9. Forward chaining is aimed for Backward chaining is any conclusion. only aimed for the 76 required data. Reasoning in AI Reasoning: Reasoning is the mental process of deriving logical conclusions and making predictions from available knowledge, facts, and beliefs. Or we can say, "Reasoning is a way to infer facts from existing data.“ It is a general process of thinking rationally, to find valid conclusions. In artificial intelligence, reasoning is essential so that the machine can also think rationally as a human brain, and can perform like a human. 77 Reasoning in AI Types of Reasoning In artificial intelligence, reasoning can be divided into the following categories: Deductive reasoning Inductive reasoning Abductive reasoning Common Sense Reasoning Monotonic Reasoning Non-monotonic Reasoning 78 Reasoning in AI 1. Deductive reasoning: Deductive reasoning is deducing new information from logically related known information. It is the form of valid reasoning, which means the argument's conclusion must be true when the premises are true. Deductive reasoning is a type of propositional logic in AI, and it requires various rules and facts. It is sometimes referred to as top-down reasoning, and contradictory to inductive reasoning. In deductive reasoning, the truth of the premises guarantees the truth of the conclusion. Deductive reasoning mostly starts from the general premises to the specific conclusion, which can be 79 explained as below example. Deductive reasoning: Deductive reasoning starts with a general statement or premise, and then applies logical rules to reach a specific, logical conclusion. For example, "All men are mortal. Socrates is a man. Therefore, Socrates is mortal." Faculty Name - GroupNo 80 Reasoning in AI Example: Premise-1: All human eats veggies Premise-2: Suresh is human. Conclusion: Suresh eats veggies. The general process of deductive reasoning is given below: 81 Reasoning in AI 2. Inductive Reasoning: Inductive reasoning is a form of reasoning to arrive at a conclusion using limited sets of facts by the process of generalization. It starts with a series of specific facts or data and reaches a general statement or conclusion. Inductive reasoning is a type of propositional logic, which is also known as cause-effect reasoning or bottom-up reasoning. In inductive reasoning, we use historical data or various premises to generate a generic rule, for which premises support the conclusion. In inductive reasoning, premises provide probable 82 supports to the conclusion, so the truth of premises Inductive reasoning: Inductive reasoning starts with specific observations and then uses them to make a generalization or a probable conclusion. For example, "Every time I have seen a bird fly, it has had two wings. Therefore, all birds have two wings." Faculty Name - GroupNo 83 Reasoning in AI Example: Premise: All of the pigeons we have seen in the zoo are white. Conclusion: Therefore, we can expect all the pigeons to be white. 84 Reasoning in AI 3. Abductive reasoning: Abductive reasoning is a form of logical reasoning which starts with single or multiple observations then seeks to find the most likely explanation or conclusion for the observation. Abductive reasoning is an extension of deductive reasoning, but in abductive reasoning, the premises do not guarantee the conclusion. Example: Implication: Cricket ground is wet if it is raining Axiom: Cricket ground is wet. Conclusion It is raining. 85 Abductive reasoning: Abductive reasoning starts with an incomplete set of observations and then uses them to form the best possible explanation or hypothesis. For example, "A patient presents with symptoms of fever and coughing. The best explanation is that the patient has a cold." Faculty Name - GroupNo 86 Reasoning in AI 4. Common Sense Reasoning: Common sense reasoning is an informal form of reasoning, which can be gained through experiences. Common Sense reasoning simulates the human ability to make presumptions about events that occur every day. It relies on good judgment rather than exact logic and operates on heuristic knowledge and heuristic rules. Example: 1. One person can be at one place at a time. 2. If I put my hand in a fire, then it will burn. The above two statements are examples of common 87 Common sense reasoning: Common sense reasoning uses practical understanding and everyday experiences to make judgments and solve problems. For example, "If you see a pot of boiling water on the stove, it is common sense to assume that the water is hot and not to touch it." Faculty Name - GroupNo 88 Reasoning in AI 5. Monotonic Reasoning: In monotonic reasoning, once the conclusion is taken, then it will remain the same even if we add some other information to existing information in our knowledge base. In monotonic reasoning, adding knowledge does not decrease the set of prepositions that can be derived. To solve monotonic problems, we can derive a valid conclusion from the available facts only, and it will not be affected by new facts. Monotonic reasoning is not useful for real-time systems, as in real-time, facts get changed, so we cannot use monotonic reasoning. Example: Earth revolves around the Sun. It is a true fact, and it cannot be changed even if we add 89 Monotonic reasoning: Monotonic reasoning is a logical reasoning that preserves truth when new information is added, it means if a conclusion is true, it will remain true even when more information is added. For example, "All mammals are warm-blooded animals, and dogs are mammals, hence all dogs are warm-blooded animals." Faculty Name - GroupNo 90 Reasoning in AI 6. Non-monotonic Reasoning: In Non-monotonic reasoning, some conclusions may be invalidated if we add some more information to our knowledge base. Logic will be said as non-monotonic if some conclusions can be invalidated by adding more knowledge into our knowledge base. Non-monotonic reasoning deals with incomplete and uncertain models. "Human perceptions for various things in daily life, "is a general example of non- monotonic reasoning. Example: Let suppose the knowledge base contains the following knowledge: Birds can fly Penguins cannot fly 91 Non-monotonic reasoning: Non-monotonic reasoning is a logical reasoning that does not preserve truth when new information is added. It means if a conclusion is true, it may not remain true when more information is added. For example, "John is a bachelor, but if we learn that he is married, the conclusion that he is a bachelor will no longer be true." Faculty Name - GroupNo 92 Inductive vs. Deductive Reasoning Basis for Deductive Reasoning Inductive Reasoning comparison Definition Deductive reasoning is the Inductive reasoning form of valid reasoning, to arrives at a conclusion deduce new information or by the process of conclusion from known generalization using related facts and specific facts or data. information. Approach Deductive reasoning follows Inductive reasoning a top-down approach. follows a bottom-up approach. Starts from Deductive reasoning starts Inductive reasoning from Premises. starts from the Conclusion. Validity In deductive reasoning In inductive reasoning, conclusion must be true if the truth of premises the premises are true. does not guarantee 93the Inductive vs. Deductive Reasoning Basis for Deductive Reasoning Inductive Reasoning comparison Usage Use of deductive reasoning Use of inductive is difficult, as we need reasoning is fast and facts which must be true. easy, as we need evidence instead of true facts. We often use it in our daily life. Process Theory→hypothesis→patter Observations→patterns ns→confirmation. →hypothesis→Theory. Argument In deductive reasoning, In inductive reasoning, arguments may be valid or arguments may be invalid. weak or strong. Structure Deductive reasoning Inductive reasoning reaches from general facts reaches from specific to specific facts. facts to general facts. 94 Inductive vs. Deductive Reasoning 95 THANK YOU 96

Use Quizgecko on...
Browser
Browser