* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Artificial Intelligence Chapter 4: Knowledge Representation
Survey
Document related concepts
Transcript
Artificial Intelligence Dr. Eng. Ahmed Moustafa Elmahalawy Computer Science and Engineering Department Artificial Intelligence Chapter 4: Knowledge Representation 4.5 Propositional Logic Propositional Logic is a formal system in which knowledge is represented as propositions. Further, these propositions can be joined in various ways using logical operators. These expressions can then be interpreted as truth-preserving inference rules that can be used to derive new knowledge from the old, or test the existing knowledge. Artificial Intelligence Chapter 4: Knowledge Representation First, let’s introduce the proposition. A proposition is a statement, or a simple declarative sentence. For example, “the book is expensive” is a proposition. Note that a definition of truth is not assigned to this proposition; it can be either true or false. Artificial Intelligence Chapter 4: Knowledge Representation In terms of binary logic, this proposition could be false in Cairo, but true in England. But a proposition always has a truth value. So, for any proposition, we can define the true-value based on a truth table (see the following figure). This simply says that for any given proposition, it can be either true or false. Artificial Intelligence Chapter 4: Knowledge Representation We can also negate our proposition to transform it into the opposite truth value. For example, if P (our proposition) is “the book is expensive,” then ~P is “the book is not expensive.” Artificial Intelligence Chapter 4: Knowledge Representation Propositions can also be combined to create compound propositions. The first, called a conjunction, is true only if both of the conjuncts are true (P and Q). The second called a disjunction, is true if at least one of the disjuncts are true (P or Q). Artificial Intelligence Chapter 4: Knowledge Representation The truth tables for these are shown in the following figure. These are obviously the AND and OR truth tables from Boolean logic. Artificial Intelligence Chapter 4: Knowledge Representation The power of propositional logic comes into play using the conditional forms. The two most basic forms are called 1- Modus Ponens. 2- Modus Tollens. Artificial Intelligence Chapter 4: Knowledge Representation 1- Modus Ponens is defined as: P, (P->Q), infer Q which simply means that given two propositions (P and Q), if P is true then Q is true. In English, let’s say that P is the proposition “the light is on” and Q is the proposition “the switch is on.” The conditional here can be defined as: if “the light is on” then “the switch is on” Artificial Intelligence Chapter 4: Knowledge Representation The truth table for Modus Ponens is shown in the following Figure. Artificial Intelligence Modus Chapter 4: Knowledge Representation Tollens takes the contradictory approach of Modus Ponens. With Modus Tollens, we assume that Q is false and then infer that the P must be false. Modus Tollens is defined as: P, (P->Q), not Q, therefore not P. Artificial Intelligence Chapter 4: Knowledge Representation Returning to our switch and light example, we can say “the switch is not on,” therefore “the light is not on.” The formal name for this method is proof by contra positive. The truth table for Modus Tollens is provided in the following figure. Artificial Intelligence Chapter 4: Knowledge Representation Artificial Intelligence Chapter 4: Knowledge Representation A famous inference rule from propositional logic is the hypothetical syllogism. This has the form: ((P->Q) ^ (Q->R), therefore (P->R) In this example, P is the major premise, Q is the minor premise. Both P and Q have one common term with the conclusion, P->R. Artificial Intelligence Chapter 4: Knowledge Representation Propositional logic includes a number of additional inference rules (beyond Modus Ponens and Modus Tollens). These inferences rules can be used to infer knowledge from existing knowledge (or deduce conclusions from an existing set of true premises). Artificial Intelligence 4.5.1 Chapter 4: Knowledge Representation Deductive Reasoning with Propositional Logic In deductive reasoning, the conclusion is reached from a previously known set of premises. If the premises are true, then the conclusion must also be true. Artificial Intelligence Chapter 4: Knowledge Representation Let’s now explore a couple of examples of deductive reasoning using propositional logic. As deductive reasoning is dependent on the set of premises, let’s investigate these first. 1) If it’s raining, the ground is wet. 2) If the ground is wet, the ground is slippery. Artificial Intelligence The Chapter 4: Knowledge Representation two facts (knowledge about the environment) are Premise 1 and Premise 2. These are also inference rules that will be used in deduction. Now we introduce another premise that it is raining. 3) It’s raining. Artificial Intelligence Chapter 4: Knowledge Representation Now, let’s prove that it’s slippery. First, using Modus Ponens with Premise 1 and Premise 3, we can deduce that the ground is wet: 4) The ground is wet. (Modus Ponens: Premise 1, Premise 3) Again, using Modus Ponens with Premise 3 and 4, we can prove that it’s slippery: 5) The ground is slippery. (Modus Ponens: Premise 3, Premise 4) Artificial Intelligence Chapter 4: Knowledge Representation 4.5.2 Limitations of Propositional Logic While propositional logic is useful, it cannot represent general-purpose logic in a compact and summary way. For example, a formula with N variables has 2^N different interpretations. It also doesn’t support changes in the knowledge base easily. Artificial Intelligence Chapter 4: Knowledge Representation Truth values of propositions can also be problematic, for example; consider the compound proposition below. This is considered true (using Modus Ponens where P -> Q is true when P is false and Q is false, see the truth table of Modus Ponens). If dogs can fly, then cats can fly. Artificial Intelligence Chapter 4: Knowledge Representation Both statements are obviously false, and further, there’s no connection between the two. But from the standpoint of propositional logic, they are syntactically correct. A major problem with propositional logic is that entire propositions are represented as a single symbol. Artificial Intelligence 4.6 First-Order Chapter 4: Knowledge Representation Logic (Predicate Logic) One issue with propositional logic is that it’s not very expressive. For example, when we declare a proposition such as: _ The ground is wet. Artificial Intelligence Chapter 4: Knowledge Representation It’s not clear which ground we’re referring to. Nor can we determine what liquid is making the ground wet. Propositional logic lacks the ability to talk about specifics. In the other hand, we’ll explore predicate calculus (otherwise known as First-Order Logic, or FOL). Using FOL, we can use both predicates and variables to add greater expressiveness as well as more generalization to our knowledge. Artificial Intelligence Chapter 4: Knowledge Representation In FOL, knowledge is built up from 1- Constants (the objects of the knowledge) 2- A set of predicates (relationships between the knowledge) 3- Some number of functions (indirect references to other knowledge). Artificial Intelligence Chapter 4: Knowledge Representation 4.6.1 Atomic Sentences A constant refers to a single object in our domain. A sample set of constants include: ali, mona, bicycle, scooter, the-stranger, colorado Artificial Intelligence A Chapter 4: Knowledge Representation predicate expresses a relationship between objects, or defines properties of those objects. A few examples of relationships and properties are defined below: owns, rides, knows, person, sunny, book, twowheeled Artificial Intelligence Chapter 4: Knowledge Representation With our constants and predicates defined, we can now use the predicates to define relationships and properties of the constants (also called Atomic sentences). First, we define that both Ali and Mona are ‘Persons.’ The ‘Person’ is a property for the objects (Ali and Mona). _Person( ali) _Person( mona) Artificial Intelligence Chapter 4: Knowledge Representation The above may appear as a function, with Person as the function and Ali or Mona as the argument. But in this context, Person(x) is a unary relation that simply means that Ali and Mona fall under the category of Person. Now we define that Ali and Mona both know each other. Artificial Intelligence Chapter 4: Knowledge Representation We use the knows predicate to define this relationship. Note that predicates have arity, which refers to the number of arguments. The ‘Person’ predicate has an arity if one where the predicate ‘knows’ has an arity of two. _Knows( ali, mona ) _Knows( mona, ali ) Artificial Intelligence Chapter 4: Knowledge Representation We can then extend our domain with a number of other atomic sentences, shown and defined below: _Rides( ali, bicycle ) - ali rides a bicycle. _Rides( mona, scooter ) - mona rides a scooter. _Two-Wheeled (bicycle)- A Bicycle is two-wheeled. _Book( the-stranger ) - The-Stranger is a book. _Owns( mona, Book(the-stranger) ) - mona owns a book called The Stranger. Artificial Intelligence Chapter 4: Knowledge Representation Finally, a function allows us to transform a constant into another constant. For example, the sister_of function is demonstrated below: _Knows( ali, sister_of( hassan ) ) -ali knows Hassan’s sister. Artificial Intelligence Chapter 4: Knowledge Representation 4.6.2 Compound Sentences Recall from propositional logic that we can apply Boolean operators to build more complex sentences. In this way, we can take two or more atomic sentences and with connectives, build a compound sentence. A sample set of connectives is shown below: Artificial Intelligence Chapter 4: Knowledge Representation AND OR NOT Logical Conditional (then) Logical Biconditional Artificial Intelligence Examples Chapter 4: Knowledge Representation of compound sentences shown below: - ali and mona know one another. Knows(ali, mona) Knows(mona, ali) - ali knows mona, and mona does not know ali. Knows( ali, mona ) Knows( mona, ali ) -ali rides a scooter or ali rides a bicycle. Rides( ali, scooter) Rides( ali, bicycle) are Artificial Intelligence Chapter 4: Knowledge Representation We can also build conditionals using the logical conditional connective, for example: - If ali knows mona, then mona knows ali. Knows( ali, mona ) Knows( mona, ali ) Artificial Intelligence Chapter 4: Knowledge Representation This can also be written as a biconditional, which changes biconditional, a the meaning slightly. b simply means “b if a and a if b,” or “b implies a and a implies b.” - ali knows mona if mona knows ali. Knows( ali, mona ) The Knows( mona, ali ) Artificial Intelligence Chapter 4: Knowledge Representation NOTE Another way to think about the biconditional is from the construction of two conditionals in the form of a conjunction, or: (a b) (b a) This implies that both are true or both are false. Artificial Intelligence Chapter 4: Knowledge Representation 4.6.3 Variables So far, we’ve explored sentences where all of the information was present, but to be useful, we need the ability to construct abstract sentences that don’t specify specific objects. This can be done using variables. Artificial Intelligence Chapter 4: Knowledge Representation For example: - If x Knows mona, then x is a Person. Knows( x, mona ) Person( x ) If we also knew that: ‘Knows( ali, mona)’ then we could deduce that ali is a person (Person(ali)). Artificial Intelligence Chapter 4: Knowledge Representation 4.6.4 Quantifiers A quantifier is used to determine the quantity of a variable. In first-order logic, there are two quantifiers, 1- The universal quantifier ( 2- The existential quantifier ( ) ) Artificial Intelligence Chapter 4: Knowledge Representation The universal quantifier is used to indicate that a sentence should hold when anything is substituted for the variable. The existential quantifier indicates that there is something that can be substituted for the variable such that the sentence holds. Let’s look at an example of each. Artificial Intelligence Chapter 4: Knowledge Representation - There exists x, that is a Person. x. Person( x ) - For all people, there exists someone that Knows ali or mona. x. x. Person( x ) (Knows( x, mona) Knows (x, ali)) - For any x, if there is someone x that Knows mona, then x is a Person. x. x. Knows( x, mona ) Person( x )