We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86
Unit IV Knowledge
• Logical Agents, Knowledge-Based Agents, The
Wumpus World, Logic, Propositional Logic: A Very Simple Logic, Propositional Theorem Proving, Effective Propositional Model Checking, Agents Based on Propositional Logic, First-Order Logic, Representation Revisited, Syntax and Semantics of First-Order Logic, Using First-Order Logic, Knowledge Engineering in First-Order Logic What is Logical AI • A logical agent is an entity in artificial intelligence that makes decisions and takes actions based on a set of logical rules and reasoning processes. • These agents typically operate in environments where they can perceive information and use it to infer new knowledge, allowing them to achieve specific goals. Key characteristics of logical agents include: • Knowledge Representation: They use formal languages (like propositional logic or first-order logic) to represent facts about the world. • Inference Mechanism: They apply logical reasoning to derive conclusions from known facts and rules, enabling them to solve problems and make decisions. • Decision Making: Based on their knowledge and reasoning, logical agents can choose actions that lead to desired outcomes. Knowledge-based agents • Intelligent agents need knowledge about the world to choose good actions/decisions. • Knowledge = {sentences} in a knowledge representation language (formal language). • A sentence is an assertion about the world. • A knowledge-based agent is composed of: 1. Knowledge base: domain-specific content. 2. Inference mechanism: domain-independent algorithms. Applications:
• Knowledge-based agents can be found in
various fields, including: • Expert Systems: Systems that provide decision-making support in specific domains (e.g., medical diagnosis). • Robotics: Autonomous robots that navigate and interact with their environment. • Natural Language Processing: Systems that understand and respond to human language. • The agent must be able to: – • Represent states, actions, etc. • – Incorporate new percepts • – Update internal representations of the world • – Deduce hidden properties of the world • – Deduce appropriate actions • The above diagram is representing a generalized architecture for a knowledge-based agent. • The knowledge-based agent (KBA) take input from the environment by perceiving the environment. • The input is taken by the inference engine of the agent and which also communicate with KB to decide as per the knowledge store in KB. • The learning element of KBA regularly updates the KB by learning new knowledge. • Knowledge base: Knowledge-base is a central component of a knowledge-based agent, it is also known as KB. • It is a collection of sentences (here 'sentence' is a technical term and it is not identical to sentence in English). • These sentences are expressed in a language which is called a knowledge representation language. • The Knowledge-base of KBA stores fact about the world. • Why use a knowledge base? • Knowledge-base is required for updating knowledge for an agent to learn with experiences and take action as per the knowledge. Inference system
• Inference means deriving new sentences from
old. Inference system allows us to add a new sentence to the knowledge base. • A sentence is a proposition about the world. Inference system applies logical rules to the KB to deduce new information. • Inference system generates new facts so that an agent can update the KB. An inference system works mainly in two rules which are given as: • Forward chaining • Backward chaining • A. Forward Chaining • Forward chaining is also known as a forward deduction or forward reasoning method when using an inference engine. Forward chaining is a form of reasoning which start with atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the forward direction to extract more data until a goal is reached. • The Forward-chaining algorithm starts from known facts, triggers all rules whose premises are satisfied, and add their conclusion to the known facts. This process repeats until the problem is solved. • Properties of Forward-Chaining: • 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. B. 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 or sub-goals to prove the facts true. • 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. Operations Performed by KBA
• Following are three operations which are
performed by KBA in order to show the intelligent behavior: • TELL: This operation tells the knowledge base what it perceives from the environment. • ASK: This operation asks the knowledge base what action it should perform. • Perform: It performs the selected action. The Wumpus World
• The Wumpus world is a simple world example to
illustrate the worth of a knowledge-based agent and to represent knowledge representation. • The Wumpus world is a cave which has 4/4 rooms connected with passageways. • So there are total 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 called Wumpus, who eats anyone who enters the room • . The Wumpus can be shot by the agent, but the agent has a single arrow. • In the Wumpus world, there are some Pits rooms which are bottomless, and if 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 goal is to find the gold and climb out the cave without fallen into Pits or eaten by Wumpus. • The agent will get a reward if he comes out with gold, and he will get a penalty if eaten by Wumpus or falls in the pit. PEAS description of Wumpus world:
• To explain the Wumpus world we have given
PEAS description as below: • 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. • Environment: • A 4*4 grid of rooms. • The agent 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 probability 0.2 except the first square. • Actuators: • Left turn, • Right turn • Move forward • Grab • Release • Shoot. • 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 which can be perceived anywhere in the cave. 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. Propositional logic in Artificial intelligence • Propositional logic (PL) is the simplest form of logic where all the statements are made by propositions. A proposition is a declarative statement which is either true or false. It is a technique of knowledge representation in logical and mathematical form. Knowledge representation using propositional logic • is a method for representing knowledge to a machine in a way that can be used to enhance its automatic learning capacity. It's one of the simplest ways to represent knowledge to a machine • Here are some details about knowledge representation using propositional logic: • Propositions • A proposition is a sentence that can be used to express an idea, plan, opinion, statement, or suggestion. It can represent a true or false value, but not both at the same time. For example, "Tomorrow it will be rainy" is a proposition because it can be true or false, but not both. • Logical connectives • Logical connectives are used to establish compound statements. • • Truth tables • Truth tables are constructed to investigate the properties of logical connectives. • • Logic • Logic combines the advantages of natural languages and formal languages. It allows users to make statements about the world that are true or false. • • Intelligent agents • Knowledge representation and logic are essential for building intelligent agents that can perform tasks that usually require human intelligence. Following are some basic facts about propositional logic: • Propositional logic is the study of how sentences are related to each other and what they mean. • Propositional logic is also called Boolean logic as it works on 0 and 1. • In propositional logic, we use symbolic variables to represent the logic, and we can use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc. • Propositions can be either true or false, but it cannot be both.
• Propositional logic consists of an object, relations or function, and logical
connectives. • These connectives are also called logical operators. • The propositions and connectives are the basic elements of the propositional logic. • Connectives can be said as a logical operator which connects two sentences. • A proposition formula which is always true is called tautology, and it is also called a valid sentence. • A proposition formula which is always false is called Contradiction. • A proposition formula which has both true and false values is called Statements which are questions, commands, or opinions are not propositions such as "Where is Rohini", "How are you", "What is your name", are not propositions. • Syntax of propositional logic: • The syntax of propositional logic defines the allowable sentences for the knowledge representation. There are two types of Propositions: • Atomic Propositions • Compound propositions • Atomic Proposition: Atomic propositions are the simple propositions. It consists of a single proposition symbol. These are the sentences which must be either true or false. • Example: • Compound proposition: Compound propositions are constructed by combining simpler or atomic propositions, using parenthesis and logical connectives. • Logical Connectives: • Logical connectives are used to connect two simpler propositions or representing a sentence logically. We can create compound propositions with the help of logical connectives. There are mainly five connectives, which are given as follows: First-Order Logic in Artificial intelligence • In the topic of Propositional logic, we have seen that how to represent statements using propositional logic. • But unfortunately, in propositional logic, we can only represent the facts, which are either true or false. • PL is not sufficient to represent the complex sentences or natural language statements. • The propositional logic has very limited expressive power. Consider the following sentence, which we cannot represent using PL logic. • "Some humans are intelligent", or • "Sachin likes cricket." • To represent the above statements, PL logic is not sufficient, so we required some more powerful logic, such as first-order logic. • Propositional theorem proving involves determining the validity of logical propositions using formal systems and rules of inference. Here’s a brief overview of the key concepts and methods involved: • Key Concepts • Propositions: Statements that can be either true or false. For example, ppp and qqq. • Logical Connectives: Symbols used to form compound propositions: – AND (∧\land∧) – OR (∨\lor∨) – NOT (¬\neg¬) – IMPLIES (→\rightarrow→) – BICONDITIONAL (↔\leftrightarrow↔) • Truth Tables: A method to evaluate the truth values of propositions based on the truth values of their components. • Inference Rules: Rules that allow you to derive new propositions from existing ones, such as: • Modus Ponens: From ppp and p→qp \rightarrow qp→q, infer qqq. • Modus Tollens: From ¬q\neg q¬q and p→qp \rightarrow qp→q, infer ¬p\neg p¬p. • Disjunctive Syllogism: From p∨qp \lor qp∨q and ¬p\neg p¬p, infer qqq. • Proof Techniques: • Direct Proof: Constructing a chain of logical implications leading from premises to conclusion. • Indirect Proof (Proof by Contradiction): Assuming the negation of what you want to prove, leading to a contradiction. • Proof by Cases: Analyzing separate cases based on different possibilities. • Effective propositional model checking refers to techniques used in computer science, particularly in the fields of formal verification and artificial intelligence, to systematically check the validity of propositional logic statements or the correctness of systems against specified properties. Here’s a breakdown of key concepts and approaches involved in this process: • Key Concepts • Propositional Logic: A branch of logic that deals with propositions that can either be true or false. It uses logical connectives like AND, OR, NOT, etc. • Model Checking: A method for verifying whether a model of a system satisfies a given specification. This is often done by exhaustively exploring the state space of the system. • States and Transitions: In model checking, systems are represented as states and transitions. Each state corresponds to a condition of the system, while transitions represent the changes from one state to another. • Temporal Logic: Often used in model checking, temporal logic allows reasoning about the temporal ordering of events. Common types include Linear Temporal Logic (LTL) and Computation Tree Logic (CTL). • Agents based on propositional logic are computational entities that use formal logical systems to represent knowledge and make decisions. They operate by reasoning through a set of propositions—statements that can be true or false—using logical rules. • Key Features of Propositional Logic Agents • Knowledge Representation: – Agents represent their knowledge as a collection of propositions, such as "It is raining" or "The ground is wet." – These propositions can be combined using logical connectives (AND, OR, NOT, IMPLIES, IFF) to form more complex statements. • Reasoning: • Agents use inference rules to draw conclusions from their knowledge. For example, if they know that "If it is raining, then the ground is wet," and they observe that it is raining, they can conclude that the ground is wet. • Common inference methods include Modus Ponens, Modus Tollens, and Disjunctive Syllogism. • Decision Making: • Based on their knowledge and reasoning, agents can make decisions. For example, if an agent concludes that the ground is wet, it might decide to take an umbrella. • Static Knowledge Base: • Propositional logic agents typically operate with a fixed set of propositions. They don’t handle uncertainty or varying truth values as more advanced logic systems (like first-order logic) do. • 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. • 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: • Syntax of First-Order logic: • The syntax of FOL determines which collection of symbols is a logical expression in first-order logic. The basic syntactic elements of first- order logic are symbols. We write statements in short-hand notation in FOL. Basic Elements of First-order logic: Following are the basic elements of FOL syntax: • Quantifiers in First-order logic: • A quantifier is a language element which 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 quantifier: – Universal Quantifier, (for all, everyone, everything) – Existential quantifier, (for some, at least one). • 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. • 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: • Knowledge Engineering in First-order logic • The process of constructing a knowledge-base in first-order logic is called as knowledge- engineering. • In knowledge-engineering, someone who investigates a particular domain, learns important concept of that domain, and generates a formal representation of the objects, is known as knowledge engineer • 1. Identify the task: • The first step of the process is to identify the task, and for the digital circuit, there are various reasoning tasks. • 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: • Which gate is connected to the first input terminal? • Does the circuit have feedback loops? • 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). • 3. Decide on vocabulary: • The next step of the process is to select functions, predicate, and constants to represent the circuits, terminals, signals, and gates. • Firstly we will distinguish the gates from each other and from other objects. • Each gate is represented as an object which is named by a constant, such as, Gate(X1). • The functionality of each gate is determined by its type, which is taken as constants such as AND, OR, XOR, or NOT. Circuits will be identified by a predicate: Circuit (C1).
• For the terminal, we will use predicate: Terminal(x).
• For gate input, we will use the function In(1, X1) for denoting the first input terminal of the gate, and for output terminal we will use Out (1, X1). • 4. Encode general knowledge about the domain: • To encode the general knowledge about the logic circuit, we need some following rules: • If two terminals are connected then they have the same input signal, it can be represented as: • 5. Encode a description of the problem instance: • Now we encode problem of circuit C1, firstly we categorize the circuit and its gate components. • This step is easy if ontology about the problem is already thought. • This step involves the writing simple atomics sentences of instances of concepts, which is known as ontology. • For the given circuit C1, we can encode the problem instance in atomic sentences as below: • Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates will be: • 6. Pose queries to the inference procedure and get answers: • In this step, we will find all the possible set of values of all the terminal for the adder circuit. The first query will be: • What should be the combination of input which would generate the first output of circuit C1, as 0 and a second output to be 1? • 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 knowledge base. • In the knowledge base, we may have omitted assertions like 1 ≠ 0. what are the approaches of knowledge representation in AI • The four main approaches to knowledge representation in artificial intelligence (AI) are: • Simple relational knowledge • Stores information in tables or relational databases, representing knowledge as facts in the form of relationships between entities. • Inheritable knowledge • Uses hierarchies and inheritance to represent information about objects, allowing entities to inherit properties from higher-level categories. • Procedural knowledge • Defines sequences of actions or steps needed to accomplish specific tasks. • Inferential knowledge • Represents knowledge in a way that allows the AI to infer new information from existing facts and rules.
• Knowledge representation is important in AI because it
allows computers to understand, store, and manipulate human knowledge. This enables them to solve complex problems, make decisions, and perform tasks that require intelligence. Detail an algorithm for deciding entailment in PL • A set of sentences (called premises) logically entails a sentence (called a conclusion) if and only if every truth assignment that satisfies the premises also satisfies the conclusion. • Prepare This question What is knowledge representation?
• Humans are best at understanding, reasoning, and
interpreting knowledge. Human knows things, which is knowledge and as per their knowledge they perform various actions in the real world. But how machines do all these things comes under knowledge representation and reasoning. Hence we can describe Knowledge representation as following: • Knowledge representation and reasoning (KR, KRR) is the part of Artificial intelligence which concerned with AI agents thinking and how thinking contributes to intelligent behavior of agents. • It is responsible for representing information about the real world so that a computer can understand and can utilize this knowledge to solve the complex real world problems such as diagnosis a medical condition or communicating with humans in natural language. • It is also a way which describes how we can represent knowledge in artificial intelligence. Knowledge representation is not just storing data into some database, but it also enables an intelligent machine to learn from that knowledge and experiences so that it can behave intelligently like a human. • What to Represent: • Following are the kind of knowledge which needs to be represented in AI systems: • Object: All the facts about objects in our world domain. E.g., Guitars contains strings, trumpets are brass instruments. • Events: Events are the actions which occur in our world. • Performance: It describe behavior which involves knowledge about how to do things. • Meta-knowledge: It is knowledge about what we know. • Knowledge-Base: The central component of the knowledge-based agents is the knowledge base. It is represented as KB. The Knowledgebase is a group of the Sentences (Here, sentences are used as a technical term and not identical with the English language). • Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and situations. Following are the types of knowledge in artificial intelligence: • Techniques of knowledge representation • There are mainly four ways of knowledge representation which are given as follows: • Logical Representation • Semantic Network Representation • Frame Representation • Production Rules • 1. Logical Representation • Logical representation is a language with some concrete rules which deals with propositions and has no ambiguity in representation. Logical representation means drawing a conclusion based on various conditions. • Syntax: • Syntaxes are the rules which decide how we can construct legal sentences in the logic. • It determines which symbol we can use in knowledge representation. • How to write those symbols. • Semantics: • Semantics are the rules by which we can interpret the sentence in the logic. • Semantic also involves assigning a meaning to each sentence. • Semantic Network Representation • Semantic networks are alternative of predicate logic for knowledge representation. In Semantic networks, we can represent our knowledge in the form of graphical networks. This network consists of nodes representing objects and arcs which describe the relationship between those objects. • 3. Frame Representation • A frame is a record like structure which consists of a collection of attributes and its values to describe an entity in the world. Frames are the AI data structure which divides knowledge into substructures by representing stereotypes situations. It consists of a collection of slots and slot values. These slots may be of any type and sizes. Slots have names and values which are called facets. • 4. Production Rules • Production rules system consist of (condition, action) pairs which mean, "If condition then action". It has mainly three parts: • The set of production rules • Working Memory • The recognize-act-cycle • In production rules agent checks for the condition and if the condition exists then production rule fires and corresponding action is carried out. Inference in First-Order Logic
• Inference in First-Order Logic is used to
deduce new facts or sentences from existing sentences. • Inference Rules • Here are some inference rules for first-order logic: • Existential introduction • Also known as existential generalization, this rule states that if an element in the universe has a property, then something in the universe has that property. For example, if Priyanka got good marks in English, then someone got good marks in English. • • Resolution • A fundamental inference method for logical reasoning and theorem proving. It generates new clauses from old ones to resolve logical issues • Universal generalization: If a premise P(c) is true for any arbitrary element c in the universe of discourse, then the conclusion is ∀ x P(x). • Universal instantiation: Also called universal elimination, this is a valid inference rule. • Equality: FOL uses equality to make atomic sentences in addition to terms and predicates. For example, Brother (John) = Smith. • Substitution: A fundamental operation performed on terms and formulas.