370 likes | 482 Views
4.0 Knowledge Representation. Outline 4.1 Introduction 4.2 Knowledge Representation schemes. 4.3 Propositional Calculus (PC) 4.3.1 PC Symbols and Sentences 4.3.2 Syntax of the propositional calculus 4.3.3 Semantics of PC 4.3.3.1 logic Laws and inference rules
E N D
4.0 Knowledge Representation Outline4.1 Introduction4.2 Knowledge Representation schemes. 4.3 Propositional Calculus (PC) 4.3.1 PC Symbols and Sentences 4.3.2 Syntax of the propositional calculus 4.3.3 Semantics of PC 4.3.3.1 logic Laws and inference rules 4.3.3.2 Classification of Compound Propositions 4.3.4 Exercises 4.4 Predicate Calculus 4.4.1 Syntax of predicate calculus 4.4.2 Some predicate calculus equivalences 4.4.3 Inference rules 4.5 Semantic Networks 4.5.1 Representation of Some Relations 4.5.2 Inheritance in Semantic Networks 4.6 Conceptual Graphs 4.6.1 Types and individuals 4.7 Frame Structure 4.7.1 Examples
4.1 Introduction AI System Knowledge Base (KB) Inference Mechanism Facts about objects: properties and relations Rules,Procedures, Theories Set of procedures to examine the KB in an orderly manner to answer questions, solve problems, or make decisions within the KB domain
4.2 Knowledge Representation schemes Logic Representation Network Representation Structural Representation Propositional Calculus Predicate Calculus Semantic Networks Conceptual Graphs Frame Structures
4.3 Propositional Calculus • Proposition: is a statement about the world that is either true or false. It is a declarative sentence. Examples : P= “It is hot”& Q =“The earth orbits the sun” are propositions. R=“can you play tennis” is not a proposition. • Premise: is a proposition which is assigned a logical value( true or false). Example : P is true • Rules are used to draw new propositions from known premises • Example Q=“We are in summer”, P=“It is hot” • Rule: QP Interpretation of P = assertion of its truth value conclusion or consequent Premise or antecedent
4.3.1 Propositional Calculus Symbols and Sentences 4.3.1.1 Symbols: • Propositional symbols: P,Q,R,S,….. • Truth symbols: true, false • Connective symbols: Not(┐,!,~), AND(^) OR(v), Imply() Equivalence (↔) The shown truth table gives their meaning A sentence in PCcan be a symbol or a collection of symbols connected legally by the connective symbols (^,v,!,, ↔). Symbols ( ) and [ ] are used to group symbols into subexepressions.
4.3.1.2 Examples for using connectives • 1-Although Ali and Samy are not young, Ali has a better chance of winning the next tennis match, despite Samy’s considerable experience. • The above is a complex sentence that can be broken into the following propositions: • S =“Ali is young” • G =“Samy is young” • B =“Ali has a better chance of winning the next tennis match” • E =“Samy has a considerable experience in tennis” • Formalization is done using connectives as follows: • (~S) ^(~G) ^B^E • 2- If Ali is not in a hospital then Ali is well C =“Ali is in a hospital” W =“Ali is well” Formalization: (~C)W
4.3.2 Syntax of the propositional calculus • The syntax provides us with a set of rules for generating complex formulae as follows: • 1- An identifier is a proposition (e.g. A,B, p, q). • 2-If p and q are propositions then so are ~P, (P), p^q, pvq, pq, pq. • Example: if A, B and C are propositions then • A C is a grammatically correct formula and, therefore • AC v B is also correct. • Terminology • Formula that contains only symbols of the agreed alphabet and obey grammatical rules given in the definition are called well-formed formulae (wffs). • Note that when mixing connectives, the rules of precedence should be taken into consideration. • Precedence from higher to lower :(),~,^,v, , • Hence A^BvC means (A^B)vC not A^(BvC).
4.3.3 Semantics of PC • Semantics deal with the meaning of compound propositions. • Meaning of a propositional sentence is The determination of its truth value ≡ Mapping it into T or F ≡Interpretation of it • This is done by using truth tables or by applying the laws and rules of propositional logic listed in the following section. 4.3.3.1 Logic laws and inference rules Cumulative laws: (P^Q) ≡(Q^P) and (PvQ) ≡(QvP) Associative Laws: ( (PvQ)vR) ≡(Pv(QvR)) and ( (P^Q)^R) ≡(P^(Q^R)) Distributive laws: Pv(Q^R) ≡(PvQ)^(PvR) and P^(QvR) ≡(PvQ)v(P^R)
~(~P) ≡ P (PvQ) ≡(~PQ) and (~PvQ) ≡ PQ Contrapositive law: (PQ) ≡(~Q~P) de Morgan’s law: ~(PvQ) ≡~P^~Q and ~(P^Q) ≡~Pv~Q An example of an inference rule: Modus Ponens rule: if P is true and PQ Then Q is true The validity (correctness or soundness) of this rule can be proven using truth tables as shown.
List of inference rules: each introduces or eliminates a connectiveNote that : _I means introduction of a connective. _E means Elimination of a connective. • Modus ponens: _E Pq p q • Modus tollens: _E Pq ~q ~p • Double negation: ~_E ~~p p • Transivity of equivalence: _E p qp q pq qp • Conjunction: ^_I p q p^q • Simplification: ^_E p^q p • Addition: v_I p p v q • Disjunctive syllogism: v_E p v q ~p q
4.3.3.2 Classification of Compound Propositions • Compound propositions can be classified based on the truth value each proposition can take under all possible interpretations of its constituent prime proposition as follows: • Tautology: is true under all possible assignments of truth values to its prime propositions always true • Example p v ~p is a tautology. • Contradiction: always false • Example: p ^ ~p is a contradiction. • Contingent: sometimes true and sometimes false. • Example: p~p
4.3.4 Exercises 1-Build the truth table for the following expression and deduce an expression equivalent to it: (PQ)^(QP) ≡ P….Q 2-Determine the type of the following expressions: a- p v qp ^ q b- pqqp c-~p v ~q ~(p^q) d-~p ^ ~q v p ^ q 3-Demonestrate the validity of modes tollens’ rule: If pq and ~q then ~p
4.4 Predicate Calculus • In Propositional Calculus, each symbol denotes a proposition. There is no way to access the components of an individual assertion. Predicate calculus provides this ability. • For Example in Propositional Calculus the symbol P may represent the proposition: P=“Ali is the father of Salem” • In Predicate calculus, the same proposition can be represented as father (ali , salem). By dividing the proposition into its internal components, predicate calculus allows inference of another information such as : Ali is a father, Salem is the son of Ali, And many other conclusions can be derived if combined with other predicates. • Predicate calculus also allows expressions to contain variables. Ex: X alive(X)drinks(X, water).
4.4.1 Syntax of predicate calculus • Constatns specific names of objects, properties, or relations. Must begin with small letters: Ex: ali, book, red, father, above. • Variables unknown or general classes of objects. Represented by symbols beginning with capital letters. X, Y, Z, Man… • Functions: maps its arguments from the domain into a unique object in the range (co-domain): Examples: fatherof(ali): maps ali to his father. plus(3,5): maps 3,58 price (banans): maps banans to price value. 1-arity function 2-arity function
Term: is a constant, variable, or function: Examples: cat, X, times(2,3), • Predicate: names a property of an object or a relationship between zero or more objects in the world: Examples: tall, likes, equal, on, near , part_of,….etc. • A predicate expression consists of a predicate symbol followed by n terms equal to its arity: predicate_symbol( term 1, term 2,… term n) Examples: likes (ali, football) friends (ali, father_of(ibrahim)) likes (X,Y) • Atomic sentence: includes truth symbols or predicate expression: true , false friends (ali, khaled)
Sentences: • Every atomic sentence is a sentence. • A legal combination of sentences using logical operators ( connectives of propositional calculus). • Quantifiers: • constrains the meaning of a sentence containing a variable to make it a proposition (can be T or F). • If X is a variable and S is a sentence then • X S is a sentence, and X S is a sentence. • The universal quantifier , for all: the sentence is true for all values of its variable. • The existential quantifier , there exist: the sentence is true for at least one value of its variable. • For complex expressions “()” are used to indicate the scope of quantification.
Free variables are not allowed in quantified expressions. • Examples: • Ali is a teacher and a good man • goodman (ali) ^ isa (ali, teacher) • Nobody likes taxes: • X likes (X , taxes) • Every dog is an animal: • X ( dog (X) animal (X)) • Every student has a pen: • X (Y(student(X) (pen (Y) ^ owns (X,Y))))
More examples • Everybody is an adult or a child • X ( adult(X) v child (X)) • Everybody is an adult or there are children • (X adult(X)) v (X child (X)) • Everybody is tall but there are children • (X tall(X)) ^ (X child (X)) • Although all adults are tall, they are not clever. • X (( adult(X)tall(X)) ^ (adult (X)~clever (X))) • All first-year students are clever. • X ( first_year(X)^student (X)clever(X) ) • No one can be clever without being hardworking • ~X (clever (X) ) ^ ~hardworking (X)) • Not being lazy is equivalent to being hardworking. • X (~lazy(X)hardworking (X))
Examples for expressing predicate formulae in English • X (child(X)^ clever(X)Y loves(Y,X) ): • Clever children are loved. • X (child(X)^ clever(X)Y (adult (Y) ^loves(Y,X))): • Clever children are loved by adults. • X (clever(X)Y cleverer(X,Y) ): • One can not be clever without being cleverer than someone. • Tall(samir) ^ ~Y loves(Y,samir) ^ X (respects( X, samir)) : • Samir is tall and nobody loves him although everybody respects him. • ~ X ( person (X) ^ (X/=samir) ^ speaks_slowly(X): • Nobody, except Samir, speaks slowly.
Important notes • Scope of the quantifier • the variable X may refer to different objects in the same argument as follows: • X distant(X)^ planet (X)X moon(X) • Bound and free variables: • X .p(X,Y) • Types of values • When a variable is quantified, we should associate it with a type or domain as follows: • Y:person. mortal (Y) XOne object Xanother object bound variable free variable
4.4.2 Semantics of predicate logic Interpretation of universal quantification • Assuming we deal with finite domain of individuals • X.p(X) p(x1)^p(x2)^….^p(Xn) • Example: assume the human society H consist of the individuals samir, samy, ali, salma, amira, and let the following propositions hold true : • male(samir) greedy (samir) kind(ali) • male (samy) greedy (samy) kind (amira) • male (ali) Let these predicate be false for individuals not mentioned above. Is the following formula (Z) true in the given context? X:H.male(X) greedy(X) v kind (X) To validate this argument we build a truth table as follows: Z is T From the same table we can deduce that X:H. greedy(X) v kind (X) is false.
Semantics of predicate logic Interpretation of Existential quantification • Assuming we deal with finite domain of individuals • X.p(X) p(x1) v p(x2) v….v p(Xn) • Example: assume the human society H mensioned in the previous example and consider the truth value of the formula Z • X:H.male(X)^(~ greedy(X) kind (X)) To validate this argument we build a truth table as follows: Z is T
4.4.2 Some predicate calculus equivalences Assume p and q are predicates and X,Y are variables: • X p(X) X p(X) • X p(X) X p(X) • X p(X) Y p(Y) • X p(X) Y p(Y) • X ( p(X) ^ q(X) ) X p(X) ^ Y q(Y) • X ( p(X) v q(X) ) X p(X) v Y q(Y)
4.4.3 Inference rules Predicate calculus equivalence: Given: X p(X) q(X) and p(a) Conclusion: q(a) Using substitution X=a • Modus Ponens: Given :PQ and P are true Conclusion: Q is true Example: PQ: “If I am in Jeddah then I’m in Saudi Arabia” P=“I am in Jeddah “ Q=“I’m in Saudi Arabia” added to PQ and P • Modus Tolens: Given :PQ and Q is false Conclusion: P is false Example: PQ: “If I am in Jeddah then I’m in Saudi Arabia” Q=“I’m not in Saudi Arabia” P=“I am not in Jeddah “ added to PQ and Q Predicate calculus equivalence: Given: X p(X) q(X) and q(a) Conclusion: p(a) Using substitution X=a
4.5 Semantic Networks • Network representation provides a means of structuring knowledge. • Semantic networks are : Directed graphs with labeled nodes and arcs ( arrows, or links). • Nodes corresponds to objects (physical as book or nonphysical such as concepts, events, or actions) • Links corresponds to relationships between objects. Examples: IS_A, MEMBER_OF, SUBSET_OF, AKO (a kind of), HAS_PARTS, INSTANCE_OF, SHAPED_LIKE, OWNS
4.5. 1 Representation of some Relations • In our course we will limit the use of these links to definite relations. • IS_A : to represent inheritance : subclass to superclass relationship: Example: a lion is an animal • Instance_of: To represent object to its class relationship: Example :Ali is a student lion IS_A animal Instance_of ali student
HAS_PARTS: to represent composition or aggregation • Example: A computer is an electronic device consisting of CPU unit, screen, keyboard Electronic Device IS_A screen HAS_PARTS computer HAS_PARTS keyboard HAS_PARTS CPU UNIT
HAS_ATTRIBUTE: to link an object to a property. Example : A person named Ahmad has a red car person instance_of owns ahmad car has_color Important Not : links in semantic networks can represent binary relations only. red
4.5.2 Inheritance in Semantic Networks Inheritance is represented with the IS_A And instance_of links. This allows unstated information to be inferred. Example: Has_parts hair mammal drinks milk IS_A From the shown net, using inheritance, we can infer that a mouse has hair and drinks milk. rodent IS_A mouse
4.6 Conceptual Graphs • It is a Network scheme in which both concepts and conceptual relations are represented by nodes in a directed graph. The links are not labelled. They indicate the direction of the relation only. • Concepts are represented with labelled rectangles. • Relations are represented by labelled ellipsis. • Example: the pen is red concepts concepts pen red color 2-ary conceptual relation
A concept may represent concrete or abstract objects. • Concrete concepts are like cat, telephone , or anything that we can imagine its shape. • Abstract concepts include concepts such as love, beauty….that do not correspond to images in our minds. • A conceptual relation has 1 to n- ary. flies is a 1-ary relation parents is a 3-ary relation flies bird father parents child mother
4.6.1 Types and individuals • A concept symbol may be individual (as instance objects) or generic) as classes). • Individual concepts have a type field followed by a referent field. • Example: the concept has type ‘person’ and referent ‘ali’ • Each conceptual graph represents a single proposition. The shown graph represents the proposition “ali gave ahmad the book” Person: ali Person: ali agent object give Person:ahmad recipient book
4.7 Frame Structure • Extends network by allowing each node to be a complex data structure. • The main advantage is that knowledge about an object or event is stored together in memory as a unit. • Each frame consists of named slots with attached values. • The slot values may be • Numeric data. • Symbolic data • Pointers to other frames • Procedures for performing a particular task.
Frames are general record-like structures, consisting of a collection of slots. • The slots may be of any size and type • Slots also may have subfields called facets. • Facets may also have names and any number of values. • A general frame structure is as follows: • (<frame name> (<slot 1> (<facet 1> <value 1> ……<value k1>) (<facet 2> <value 1> ……<value k2>) -- ) (<slot 2> (<facet 1> <value 1> ……<value km>) -- -- )
4.7.1 Examples • To define a frame which describes the shown screen: )screen (object 1 (shape (value pyramid)) (color (value yellow)) (supported_by (value object2))) (object 2 (shape (value cube)) (color (value red)) (supported_by (value object3))) (object 3 (shape (value cube)) (color (value blue)) (supported_by (value nil)))). Frame name slots slots slots facets slots slots
Another example: to describe a type (Cressida ( ako ( value car)) ( color ( value white, blue, black)) ( speed (value 220 km/hr)) ( model ( value 4-doors)). ( Mycar ( instance_of (value Cressida )) ( color ( value white))). Pointer to another frame to allow inheritance (subclass-superclass relationship) Pointer to another frame to allow object-class relationship
Problem Set 2 • Construct truth tables for the compound proposition: • p v (q ^ r) (p ^q) v r • Test Validity of the following rule • (p v q) ^ ~pq • Express the following in predicate logic • Although the tree is tall, it has no leaves. • If x is the father of y or mother of y then x is a parent of y • If y and x have same parent then they are sibling • If x and y are parents of z then they are married. • Every Muslim does prayer. • Nobody likes taxes • All students like AI • Evaluate the truth of the following, assuming the data is given in section 4.2 • X:H.male(X)^(~ greedy(X) v ~kind (X)) • ( X:H.~male(X) ^ kind (X))(X:H.male(X)~kind (X))