UNIT 4 Knowledge, Reasoning, and Planning PDF
Document Details
Tags
Summary
These notes cover UNIT 4, Knowledge, Reasoning, and Planning. They discuss logical agents in AI, knowledge-based agents, propositional logic, and first-order logic.
Full Transcript
**UNIT 4** **KNOWLEDGE, REASONING, AND PLANNING** **Logical Agents: Knowledge-Based Agents, Propositional Logic, Propositional Theorem, First- Order Logic: Knowledge Engineering in First Order Logic, Inference, Knowledge Representation: Categories and Objects, Events, Reasoning Systems and Default...
**UNIT 4** **KNOWLEDGE, REASONING, AND PLANNING** **Logical Agents: Knowledge-Based Agents, Propositional Logic, Propositional Theorem, First- Order Logic: Knowledge Engineering in First Order Logic, Inference, Knowledge Representation: Categories and Objects, Events, Reasoning Systems and Default Information, Planning: Definition, Algorithm, Heuristic, Hierarchical, Time Schedules and Analysis.** **LOGICAL AGENTS** Logical agents in AI are computational systems that use symbolic logic and reasoning to make decisions, draw conclusions, and perform various tasks. These agents are designed to represent knowledge, make inferences, and use logical rules to manipulate information. They are a fundamental concept in artificial intelligence and have various applications, including expert systems, automated reasoning, knowledge representation, and natural language processing. Applications of logical agents in AI include: 1. Expert Systems: Logical agents are often used to build expert systems that can mimic the decision-making capabilities of human experts in specific domains, such as medicine, finance, or engineering. 2. Natural Language Processing: In natural language processing, logical agents can be used to understand and generate human language using formal logic and reasoning. 3. Automated Reasoning: Logical agents are employed in automated theorem proving and formal verification to prove the correctness of software and hardware systems. 4. Knowledge Representation and Reasoning: Logical agents play a crucial role in representing and reasoning about knowledge in AI systems, enabling them to answer complex questions and solve problems. 5. Semantic Web: In the context of the Semantic Web, logical agents help interpret and reason about the meaning of web resources and data, facilitating more intelligent web-based applications. **KNOWLEDGE-BASED AGENTS** Knowledge-based agents are a type of intelligent agent in artificial intelligence that use knowledge and reasoning to make decisions and solve problems. These agents are designed to operate in environments where information and knowledge play a crucial role in decision-making. Logical agents are a subset of knowledge-based agents that primarily use logical reasoning and inference techniques to process and manipulate their knowledge. Here are the key components and characteristics of logical agents, which are a type of knowledge-based agent: 1. **Knowledge Base (KB):** Logical agents have a knowledge base that stores information about the world and the agent\'s domain of operation. This knowledge is typically represented in a formal, structured way, often using logic-based representations such as propositional logic or first-order logic. 2. **Inference Engine:** The inference engine is responsible for reasoning with the information in the knowledge base. It uses logical rules, deduction, and inference techniques to draw conclusions and make decisions based on the available knowledge. 3. **Rule-Based Reasoning:** Logical agents often employ rule-based reasoning systems, where a set of logical rules dictates how the agent should respond to different situations or queries. These rules can be if-then statements that specify how to derive new information from existing knowledge. 4. **Knowledge Representation:** Knowledge in logical agents is typically represented using a formal language that allows for precise and unambiguous statements. Common representations include propositional logic, which deals with simple true/false statements, and first-order logic, which allows for more complex statements with variables and quantifiers. 5. **Inference Mechanisms:** Logical agents use inference mechanisms to make inferences and draw conclusions from the information in the knowledge base. Common inference techniques include resolution, modus ponens, and backward chaining, among others. 6. **Knowledge Acquisition:** Knowledge-based agents can acquire new knowledge over time. This can be done manually by human experts, through machine learning techniques, or by interacting with their environment to gather new data. 7. **Problem Solving:** Logical agents can use their knowledge and reasoning abilities to solve complex problems. They can break down problems into smaller sub problems, apply logical rules, and derive solutions through a series of logical steps. 8. **Domain Specific:** Knowledge-based agents are often designed for specific domains or tasks. They excel in situations where explicit knowledge and logical reasoning are essential for decision-making. 9. **Limitations:** Logical agents may struggle with uncertainty and incomplete information since they rely on precise, structured knowledge. Dealing with vague or probabilistic information can be challenging for these agents. Examples of logical agents include expert systems used in fields like medicine and finance, where they provide diagnostic or advisory capabilities based on a knowledge base of domain-specific rules and facts. Additionally, theorem proving systems and automated reasoning tools are also examples of logical agents used in areas like mathematics and computer science. These agents rely heavily on logical reasoning to derive conclusions and solve complex problems. **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. Example: 1. a) It is Sunday. 2. b) The Sun rises from West (False proposition) 3. c) 3+3= 7(False proposition) 4. d) 5 is a prime number. **Following are some basic facts about propositional logic:** - 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: 1. 2. - **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:** 1. a) 2+2 is 4, it is an atomic proposition as it is a **true** fact. 2. b) \"The Sun is cold\" is also a proposition as it is a **false** fact. - **Compound proposition:** Compound propositions are constructed by combining simpler or atomic propositions, using parenthesis and logical connectives. **Example:** 1. a) \"It is raining today, and street is wet.\" 2. b) \"Ankit is a doctor, and his clinic is in Mumbai.\" **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: 1. **Negation:** A sentence such as ¬ P is called negation of P. A literal can be either Positive literal or negative literal. 2. **Conjunction:** A sentence which has **∧ **connective such as, **P ∧ Q** is called a conjunction.\ **Example:** Rohan is intelligent and hardworking. It can be written as,\ **P= Rohan is intelligent**,\ **Q= Rohan is hardworking. → P∧ Q**. 3. **Disjunction:** A sentence, which has ∨ connective, such as P ∨ Q., is called disjunction, where P and Q are the propositions.\ **Example: \"Ritika is a doctor or Engineer\"**,\ Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as **P ∨ Q**. 4. **Implication:** A sentence such as P → Q, is called an implication. Implications are also known as if-then rules. It can be represented as **If** it is raining, then the street is wet.\ Let P= It is raining, and Q= Street is wet, so it is represented as P → Q 5. **Biconditional:** A sentence such as **P⇔ Q is a Biconditional sentence, example If I am breathing, then I am alive** P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q. **TRUTH TABLE** In propositional logic, we need to know the truth values of propositions in all possible scenarios. We can combine all the possible combination with logical connectives, and the representation of these combinations in a tabular format is called **Truth table**. Following are the truth table for all logical connectives: Propositional logic in Artificial intelligence ![Propositional logic in Artificial intelligence](media/image2.png) Following is the summarized table for Propositional Logic Connectives: Propositional logic in Artificial intelligence **Truth table with three** **propositions:** We can build a proposition composing three propositions P, Q, and R. This truth table is made-up of 8n Tuples as we have taken three proposition symbols. ![Propositional logic in Artificial intelligence](media/image4.png) **Precedence of connectives:** Just like arithmetic operators, there is a precedence order for propositional connectors or logical operators. This order should be followed while evaluating a propositional problem. Following is the list of the precedence order for operators: **Precedence** **Operators** ------------------- ------------------ First Precedence Parenthesis Second Precedence Negation Third Precedence Conjunction(AND) Fourth Precedence Disjunction(OR) Fifth Precedence Implication Six Precedence Biconditional **Logical equivalence:** Logical equivalence is one of the features of propositional logic. Two propositions are said to be logically equivalent if and only if the columns in the truth table are identical to each other. Let\'s take two propositions A and B, so for logical equivalence, we can write it as A⇔B. In below truth table we can see that column for ¬A∨ B and A→B, are identical hence A is Equivalent to B Propositional logic in Artificial intelligence Properties of Operators: - **Commutativity:** - P∧ Q= Q ∧ P, or - P ∨ Q = Q ∨ P. - **Associativity:** - (P ∧ Q) ∧ R= P ∧ (Q ∧ R), - (P ∨ Q) ∨ R= P ∨ (Q ∨ R) - **Identity element:** - P ∧ True = P, - P ∨ True= True. - **Distributive:** - P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R). - P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R). - - **De Morgan\'s Law:** - ¬ (P ∧ Q) = (¬P) ∨ (¬Q) - ¬ (P ∨ Q) = (¬ P) ∧ (¬Q). - **Double-negation elimination:** - ¬ (¬P) = P. Limitations of Propositional logic: - We cannot represent relations like ALL, some, or none with propositional logic. Example: 1. 2. - Propositional logic has limited expressive power. - In propositional logic, we cannot describe statements in terms of their properties or logical relationships. **PROPOSITIONAL THEOREM** - A propositional theorem is a statement or assertion in propositional logic that can be proven to be true based on the rules and axioms of propositional logic. Propositional logic, also known as sentential logic or statement logic, deals with propositions or statements that are either true or false and how they can be combined using logical connectives such as AND, OR, NOT, and IMPLIES. - In propositional logic, theorems are typically derived from a set of axioms and a set of inference rules. Axioms are basic, self-evident statements or assumptions that serve as the foundation of the logical system. Inference rules are used to make logical deductions from these axioms. - Here are some examples of common propositional theorems: - Modus Ponens: If you have statements A and A implies B, you can infer B. (A ∧ (A → B)) → B - Modus Tollens: If you have statements ¬B and A implies B, you can infer ¬A. ((¬B) ∧ (A → B)) → ¬A - Double Negation: A statement is equivalent to its double negation. A ↔ ¬¬A - De Morgan\'s Laws: ¬(A ∧ B) is equivalent to (¬A ∨ ¬B). ¬(A ∨ B) is equivalent to (¬A ∧ ¬B). - Proving propositional theorems involves applying these inference rules to manipulate propositions and show that a particular statement is a logical consequence of the axioms and previously proven theorems. The process of proving theorems in propositional logic is often carried out using truth tables, formal proofs, or proof by contradiction, depending on the complexity of the statement being proven. **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 easier 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: - **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 main parts: - - **Constant** 1, 2, A, John, Mumbai, cat,\.... ----------------- ---------------------------------- **Variables** x, y, z, a, b,\.... **Predicates** Brother, Father, \>,\.... **Function** sqrt, LeftLegOf, \.... **Connectives** ∧, ∨, ¬, ⇒, ⇔ **Equality** == **Quantifier** ∀, ∃ 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: ### 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 sentences using connectives. **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 second part \"is an integer,\" is known as a predicate. ![First-Order Logic in Artificial intelligence](media/image6.png) 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 symbols permit to determine or identify the range and scope of the variable in the logical expression. There are two types of quantifier: 1. 2. ### 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.** Let a variable x which refers to a cat so all x can be represented in UOD as below: First-Order Logic in Artificial intelligence **∀x man(x) → drink (x, coffee).** It will be read as: There are all x where x is a man who drink coffee. 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.\'** ### Example: **Some boys are intelligent.** ![First-Order Logic in Artificial intelligence](media/image8.png) **∃x: boys(x) ∧ intelligent(x)** It will be read as: There are some x where x is a boy who is intelligent. Properties of Quantifiers: -------------------------- - In universal quantifier, ∀x∀y is similar to ∀y∀x. - In Existential quantifier, ∃x∃y is similar to ∃y∃x. - ∃x∀y is not similar to ∀y∃x. Some Examples of FOL using quantifier: **1. All birds fly.**\ In this question the predicate is \"**fly(bird)**.\"\ And since there are all birds who fly so it will be represented as follows.\ **∀x bird(x) →fly(x)**. **2. Every man respects his parent.**\ In this question, the predicate is \"**respect(x, y),\" where x=man, and y= parent**.\ Since there is every man so will use ∀, and it will be represented as follows:\ **∀x man(x) → respects (x, parent)**. **3. Some boys play cricket.**\ In this question, the predicate is \"**play(x, y)**,\" where x= boys, and y= game. Since there are some boys so we will use **∃, and it will be represented as**:\ **∃x boys(x) → play(x, cricket)**. **4. Not all students like both Mathematics and Science.**\ In this question, the predicate is \"**like(x, y),\" where x= student, and y= subject**.\ Since there are not all students, so we will use **∀ with negation, so** following representation for this:\ **¬∀ (x) \[ student(x) → like(x, Mathematics) ∧ like(x, Science)\].** **5. Only one student failed in Mathematics.**\ In this question, the predicate is \"**failed(x, y),\" where x= student, and y= subject**.\ Since there is only one student who failed in Mathematics, so we will use following representation for this:\ **∃(x) \[ student(x) → failed (x, Mathematics) ∧∀ (y) \[¬(x==y) ∧ student(y) → ¬failed (x, Mathematics)\]**. Free and Bound Variables: ------------------------- The quantifiers interact with variables which appear in a suitable way. There are two types of variables in First-order logic which are given below: Free Variable: A variable is said to be a free variable in a formula if it occurs outside the scope of the quantifier. Example: ∀x ∃(y)\[P (x, y, z)\], where z is a free variable. Bound Variable: A variable is said to be a bound variable in a formula if it occurs within the scope of the quantifier. Example: ∀x \[A (x) B( y)\], here x and y are the bound variables. **KNOWLEDGE ENGINEERING IN FIRST ORDER LOGIC** Knowledge engineering in first-order logic is a process used in artificial intelligence and knowledge representation to formally capture and represent knowledge about a specific domain or problem using first-order logic (FOL) formalism. First-order logic, also known as predicate logic, is a formal system that extends propositional logic by introducing variables, quantifiers, and predicates, making it more expressive and suitable for representing complex relationships and facts. Here are the key steps involved in knowledge engineering in first-order logic: 1. Domain Analysis: The first step is to thoroughly understand and analyse the domain or problem you want to represent using FOL. This involves identifying the relevant entities, relationships, and properties within the domain. 2. Identify Predicates and Constants: Predicates represent relationships between entities, while constants represent specific individuals or objects within the domain. Identify and define predicates and constants that are relevant to the domain. For example, in a medical domain, you might have predicates like \"Patient,\" \"Doctor,\" \"Diagnosis,\" and constants like \"John,\" \"Dr. Smith,\" and \"COVID-19.\" 3. Define Functions and Variables: Functions can represent attributes or properties of entities in the domain, while variables are used to introduce generality into formulas. Define functions and variables as needed. For instance, you might have a function \"Age(x)\" to represent the age of a person and use the variable \"x\" to denote any person. 4. Formulate Axioms and Rules: Axioms and rules in FOL capture the knowledge about the domain. Axioms are typically statements that are universally true, while rules describe conditional relationships. For example, an axiom could be \"All humans are mortal,\" and a rule could be \"If a person has a high fever and cough, they may have COVID-19.\" 5. Quantifiers and Logical Connectives: Use quantifiers (e.g., ∀ for universal quantification and ∃ for existential quantification) to express statements that involve all or some entities. Employ logical connectives (e.g., ∧ for AND, ∨ for OR, ¬ for NOT) to build complex statements. 6. Formalize Knowledge: Write down the knowledge about the domain using FOL. This involves encoding the domain-specific information, facts, and relationships into FOL statements, taking into account the predicates, constants, functions, variables, axioms, and rules defined earlier. 7. Knowledge Base Construction: Organize the formalized knowledge into a knowledge base, which is a collection of FOL statements that represent the domain\'s knowledge. The knowledge base serves as the foundation for reasoning and inference in the AI system. 8. Reasoning and Inference: Once the knowledge base is constructed, it can be used for various AI tasks, including deductive reasoning, query answering, and decision-making. Inference engines and reasoning algorithms can be employed to draw conclusions and make decisions based on the knowledge represented in FOL. 9. Iterative Refinement: Knowledge engineering is often an iterative process. As the domain evolves or more knowledge becomes available, you may need to update and refine the knowledge base and FOL representation accordingly. **INFERENCE IN FIRST-ORDER LOGIC** Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences. Before understanding the FOL inference rule, let\'s understand some basic terminologies used in FOL. **Substitution:** Substitution is a fundamental operation performed on terms and formulas. It occurs in all inference systems in first-order logic. The substitution is complex in the presence of quantifiers in FOL. If we write **F\[a/x\]**, so it refers to substitute a constant \"**a**\" in place of variable \"**x**\". **Equality:** First-Order logic does not only use predicate and terms for making atomic sentences but also uses another way, which is equality in FOL. For this, we can use **equality symbols** which specify that the two terms refer to the same object. **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.** **FOL inference rules for quantifier:** As propositional logic we also have inference rules in first-order logic, so following are some basic inference rules in FOL: - **Universal Generalization** - **Universal Instantiation** - **Existential Instantiation** - **Existential introduction** **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: Inference in First-Order Logic. - 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 will also be true. **2. Universal Instantiation:** - Universal instantiation is also called as 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:![Inference in First-Order Logic](media/image10.png). **Example:1.** IF \"Every person like ice-cream\"=\> ∀x P(x) so we can infer that\ \"John likes ice-cream\" =\> P(c) **Example: 2.** Let\'s take a famous example, \"All kings who are greedy are Evil.\" So let our knowledge base contains this detail as in the form of FOL: **∀x king(x) ∧ greedy (x) → Evil (x),** So from this information, we can infer any of the following statements using Universal Instantiation: - **King(John) ∧ Greedy (John) → Evil (John),** - **King(Richard) ∧ Greedy (Richard) → Evil (Richard),** - **King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),** **3. Existential Instantiation:** - Existential instantiation is also called as Existential Elimination, which is a valid inference rule in first-order logic. - It can be applied only once to replace the existential sentence. - The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB was satisfiable. - This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a new constant symbol c. - The restriction with this rule is that c used in the rule must be a new term for which P(c ) is true. - It can be represented as:Inference in First-Order Logic **Example:** From the given sentence: **∃x Crown(x) ∧ OnHead(x, John),** So we can infer: **Crown(K) ∧ OnHead( K, John),** as long as K does not appear in the knowledge base. - The above used K is a constant symbol, which is called **Skolem constant**. - The Existential instantiation is a special case of **Skolemization process**. **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 which 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: ![Inference in First-Order Logic](media/image12.png) - **Example: Let\'s say that,**\ \"Priyanka got good marks in English.\"\ \"Therefore, someone got good marks in English.\" Generalized Modus Ponens Rule: For the inference process in FOL, we have a single inference rule which is called Generalized Modus Ponens. It is lifted version of Modus ponens. Generalized Modus Ponens can be summarized as, \" P implies Q and P is asserted to be true, therefore Q must be True.\" According to Modus Ponens, for atomic sentences **pi, pi\', q**. Where there is a substitution θ such that SUBST **(θ, pi\',) = SUBST(θ, pi)**, it can be represented as: Inference in First-Order Logic **Example:** **We will use this rule for Kings are evil, so we will find some x such that x is king, and x is greedy so we can infer that x is evil.** 1. Here let say, p1\' is king(John) p1 is king(x) 2. p2\' is Greedy(y) p2 is Greedy(x) 3. θ is {x/John, y/John} q is evil(x) 4. SUBST(θ,q). 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. - **Facts:** Facts are the truths about the real world and what we represent. - **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: **Types of knowledge** Following are the various types of knowledge: ![Knowledge Representation in Artificial intelligence](media/image14.png) **1. Declarative Knowledge:** - Declarative knowledge is to know about something. - It includes concepts, facts, and objects. - It is also called descriptive knowledge and expressed in declarativesentences. - It is simpler than procedural language. **2. Procedural Knowledge** - It is also known as imperative knowledge. - Procedural knowledge is a type of knowledge which is responsible for knowing how to do something. - It can be directly applied to any task. - It includes rules, strategies, procedures, agendas, etc. - Procedural knowledge depends on the task on which it can be applied. **3. Meta-knowledge:** - Knowledge about the other types of knowledge is called Meta-knowledge. **4. Heuristic knowledge:** - Heuristic knowledge is representing knowledge of some experts in a filed or subject. - Heuristic knowledge is rules of thumb based on previous experiences, awareness of approaches, and which are good to work but not guaranteed. **5. Structural knowledge:** - Structural knowledge is basic knowledge to problem-solving. - It describes relationships between various concepts such as kind of, part of, and grouping of something. - It describes the relationship that exists between concepts or objects. The relation between knowledge and intelligence: Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial intelligence. Knowledge plays an important role in demonstrating intelligent behavior in AI agents. An agent is only able to accurately act on some input when he has some knowledge or experience about that input. **AI knowledge cycle**: An Artificial intelligence system has the following components for displaying intelligent behavior: - Perception - Learning - Knowledge Representation and Reasoning - Planning - Execution Knowledge Representation in Artificial intelligence The above diagram is showing how an AI system can interact with the real world and what components help it to show intelligence. AI system has Perception component by which it retrieves information from its environment. It can be visual, audio or another form of sensory input. The learning component is responsible for learning from data captured by Perception comportment. In the complete cycle, the main components are knowledge representation and Reasoning. These two components are involved in showing the intelligence in machine-like humans. These two components are independent with each other but also coupled together. The planning and execution depend on analysis of Knowledge representation and reasoning. **Approaches to knowledge representation:** There are mainly four approaches to knowledge representation, which are given below: **1. Simple relational knowledge:** - It is the simplest way of storing facts which uses the relational method, and each fact about a set of the object is set out systematically in columns. - This approach of knowledge representation is famous in database systems where the relationship between different entities is represented. - This approach has little opportunity for inference. **2. Inheritable knowledge:** - In the inheritable knowledge approach, all data must be stored into a hierarchy of classes. - All classes should be arranged in a generalized form or a hierarchal manner. - In this approach, we apply inheritance property. - Elements inherit values from other members of a class. - This approach contains inheritable knowledge which shows a relation between instance and class, and it is called instance relation. - Every individual frame can represent the collection of attributes and its value. - In this approach, objects and values are represented in Boxed nodes. - We use Arrows which point from objects to their values. - **Example:** ![Knowledge Representation in Artificial intelligence](media/image16.png) **3. Inferential knowledge:** - Inferential knowledge approach represents knowledge in the form of formal logics. - This approach can be used to derive more facts. - It guaranteed correctness. - **Example:** Let\'s suppose there are two statements: 1. 2. **4. Procedural knowledge:** - Procedural knowledge approach uses small programs and codes which describes how to do specific things, and how to proceed. - In this approach, one important rule is used which is **If-Then rule**. - In this knowledge, we can use various coding languages such as **LISP language** and **Prolog language**. - We can easily represent heuristic or domain-specific knowledge using this approach. - But it is not necessary that we can represent all cases in this approach. Requirements for knowledge Representation system: A good knowledge representation system must possess the following properties. 1. **Representational Accuracy:**\ KR system should have the ability to represent all kind of required knowledge. 2. **Inferential Adequacy:**\ KR system should have ability to manipulate the representational structures to produce new knowledge corresponding to existing structure. 3. **Inferential Efficiency:**\ The ability to direct the inferential knowledge mechanism into the most productive directions by storing appropriate guides. 4. **Acquisitional efficiency-** ONTOLOGICAL ENGINEERING ======================= CATEGORIES AND OBJECTS ====================== ### EVENTS Situation calculus is perfect for the vacuum world, the wumpus world, or any world in which a single agent takes discrete actions. Unfortunately, situation calculus has two problems that limit its applicability. First, situations are instantaneous points in time, which are not very useful for describing the gradual growth of a kitten into a cat, the flow of electrons along a wire, or any other process where change occurs continuously over time. Second, situation calculus works best when only one action happens at a time. When there are multiple agents in the world, or when the world can change spontaneously, situation calculus begins to break down. It is possible to prop it back up for a while by defining composite actions, as in Exercise 7.12. If there are actions that have different durations, or whose effects depend on duration, then situation calculus in its intended form cannot be used at all. ### REASONING SYSTEMS FOR CATEGORIES Categories are the primary building blocks of any large-scale knowledge representation scheme. Categories are the primary building blocks of any large-scale knowledge representation scheme. This topic describes systems specially designed for organizing and reasoning with category. This topic describes systems specially designed for organizing and reasoning with category. There are two types of reasoning Systems There are two types of Reasoning Systems Semantic networks and description logic. Semantic networks and description logic. Semantic networks provide graphical aids for visualizing a knowledge base in patterns of interconnected nodes and arcs. It has an efficient algorithm for inferring of and object based on its category membership. In 1909 Charles Peirce proposed a graphical notation of nodes and arcs called existential graphs that is a visual notation for logical expressions. A typical graphical notation displays objects or categories names in oval or boxes and connects them with labeled arcs. For example, a MemberOf link between Mary and female persons corresponds to the logical assertion Mary E (element) of female person. We can connect categories using SubsetOf of links. A single box used to assert properties of every member of a category. A single box used to assert properties of every member of a category. ### REASONING WITH DEFAULT INFORMATION - What is the semantic status of default rules? If \"Cars have four wheels\" is false, what does it mean to have it in one\'s knowledge base? What is a good set of default rules to have? Without a good answer to these questions, default-reasoning systems will be no modular, and it will be hard to develop a good knowledge engineering methodology. - What happens when the evidence matches the premises of two default rules with conflicting conclusions? We saw examples of this in the discussion of multiple inheritance in Section - Sometimes a system may draw a number of conclusions based on a belief that is later retracted. How can a system keep track of which conclusions need to be retracted as a result? Conclusions that have multiple justifications, only some of which have been abandoned, should be retained; whereas those with no remaining justifications should be dropped. These problems have been addressed by truth maintenance systems, which are discussed in Section 10.8. - How can beliefs that have default status be used to make decisions? This is probably the hardest issue for default reasoning. Decisions often involve trade-offs, and one therefore needs to compare the strength of belief in the outcomes of different actions. In cases where the same kinds of decisions are being made repeatedly, it is possible to interpret default rules - To date, no default reasoning system has successfully addressed all of these issues. Furthermore, most systems are formally undecidable, and very slow in practice. There have been several attempts to subsume default reasoning in a probabilistic system, using the idea that a default rule is basically a conditional probability of 1 --- f. For reasons already mentioned, such an approach is likely to require a full integration of decision making before it fully captures the desirable features of default reasoning ### THE INTERNET SHOPPING WORLD #### How search is changing Traditional search engines such as Google have been using algorithms that pick on a string of keywords to throw up results that they think are closest to what searchers are looking for. While this approach worked for those looking for news items and some such, it was not ideal for online shoppers. With advancements in AI, online search has got that much more "cleverer", with even "visual search" gaining grounds with retailers. Retail companies are using a combination of analytics, machine learning, deep learning, computer vision and facial recognition to compete in online business. The latter, for example, is the same technology that drives self-driving cars. Amazon is already using these technologies in its new Amazon Go grocery stores. For now, it has deployed this in one store in Seattle, but expansion will follow suit. One of the biggest examples of visual search is 'Pinterest Lens'. Launched late 2016, this service allows consumers to point their mobile phone cameras at any commodity, and then conduct an online visual search. Lens, thus, goes beyond words to include images from the real world. How does it work? While image-detection programs identify an object, visual search digs up images similar to that object. The other advancement in online search uses Neuro-Linguistic Programming (NLP). This is a science that looks at the way in which human beings think (Neuro), the language patterns they use (Linguistic) and behaviours (Programming), and how these interact to effect human beings as individuals, both positive and negative. Some retailers have started applying the NLP approach, which is based on AI enabling computer programs to understand human speech, to search, allowing shoppers to search for items in a manner which is similar to asking a store help in person for the same. Some retail companies have claimed an amount of success in sales after deployment of advances in search. Well-known American luxury department store Neiman Marcus, for example, has increased app usage and customer engagement after implementing visual search. Other retail brands that are successfully using visual search include Shoes.com, Nordstrom, and Urban Outfitters. #### You are being serviced by a chatbot A recent report by Juniper Research found that chatbots would \"redefine\" the customer service industry, and forecast that the technology would save over US \$8 billion in operational costs by 2022. Another study by IBM showed that 65% of millennials preferred interacting with bots instead of talking to real human beings. Needless to say, the bots have truly arrived. Bots have become popular with retailers because of the increasing reliance on mobile messaging apps and the need for 24/7 customer service as business goes global. Brands are using chatbots to offer recommendations and services, and even to automate the purchase process. The most popular chatbot platforms are Facebook Messenger, WhatsApp, WeChat, and Slack. Top brands like Uber and Burberry have successfully deployed chatbots to acquire new customers, while retaining the old ones. **PLANNING**