Ai Knowledge Representation Issues Predicate Logic Rules
Ai Knowledge Representation Issues Predicate Logic Rules
Topics
8 hours)
Slides 03-26
1. Knowledge Representation Introduction KR model, typology, relationship, framework, mapping, forward KR & backward schemes representation, relational, system requirements; inheritable,
inferential, declarative, procedural; relationship, granularity. 2. KR Using Predicate Logic Logic representation, tautologies, argument;
KR issues - attributes,
27-47
variables, symbols, connective, truth value, contingencies, contradictions, Predicate logic - expressions,
formula; Representing IsA and Instance relationships, computable functions and predicates; Resolution. 3. KR Using Rules Types of Rules declarative, procedural, meta rules; Procedural verses declarative knowledge & language; Logic programming characteristics, Statement, language, syntax & terminology, simple & structured data objects, Program predicate, sentence, subject; Components - clause,
48-77
Programming paradigms - models of computation, imperative model, functional model, logic model; 4. References
02
Knowledge Representation
Issues, Predicate Logic, Rules
How do we represent what we know ?
KR -Introduction
1. Introduction Knowledge is a general term. Knowledge is a progression that starts with data which is of limited utility. By organizing or analyzing the data, we understand what the data means, and this becomes information. The interpretation or evaluation of information yield knowledge. An understanding of the principles embodied within the knowledge is wisdom.
Knowledge Progression
Organizing Interpretation
Data
Analyzing
Information
Evaluation
Understanding
Knowledge
Principles
Wisdom
Information
established Provides
emerges and
when
Knowledge
relationships
emerges among
Wisdom
is
the
pinnacle
of the
uncovers
gradients,
KR -Introduction
The model tells, that as the degree of connectedness and understanding increase, we progress from data through information and knowledge to wisdom.
Degree of Connectedness
Wisdom
Understanding principles
Knowledge
Understanding patterns
Information
Understanding relations Fig. Knowledge Model
Data
Degree of Understanding
The model represents transitions and understanding. the transitions are from data, to information, to knowledge, and finally to wisdom; the understanding support the transitions from one stage to the next stage. The distinctions between data, information, knowledge, and wisdom are not very discrete. They are white (Shedroff, 2001). data and information deal with the past; they are based on the gathering of facts and adding context. knowledge deals with the present that enable us to perform. wisdom deals with the future, acquire vision for what will be, rather than for what is or was.
05
KR -Introduction
Knowledge Type
Knowledge is categorized into two major types: Tacit and term Explicit corresponds to formal type of knowledge.
Tacit knowledge Explicit knowledge
Explicit.
Drawn from experience, action, Drawn from artifact of some type as [The next slide explains more about tacit and explicit knowledge.]
06
KR -Introduction
Knowledge typology map The map shows that, Tacit knowledge comes from experience, action, subjective insight type.
Doing (action)
and
Experience
Principles
Procedure
Tacit Knowledge
Explicit Knowledge
Process
Subjective Insight
Knowledge
Concept
Context
Information
Data Facts
Facts : are data or instance that are specific and unique. Concepts : are class of items, words, or ideas that are known by a common name and share common features. Processes : are flow of events or activities that describe how things work rather than how to do things. Procedures : are series of step-by-step actions and decisions that result in the achievement of a task. Principles : are guidelines, rules, and parameters that govern; principles allow to make predictions and draw implications; principles are the basic building blocks of theoretical models (theories).
These artifacts are used in the knowledge creation process to create two types of knowledge: declarative and procedural explained below.
07
KR -Introduction
Knowledge Type
Cognitive psychologists sort knowledge into Declarative and Procedural category and some researchers added Strategic as a third category. Procedural knowledge examples
: procedures, strategies, agendas, models.
Declarative knowledge
propositions, assertions, semantic
rules, example : concepts, objects, facts, nets, logic and descriptive models.
focuses
on
tasks to
that a "how
must
be refers to representations of objects and events; knowledge about facts and relationships;
performed
reach
particular to
objective or goal.
Knowledge
something"; their ages.
about
e.g., to determine if
some-thing yet cannot be expressed in words; e.g., we read faces and moods.
Another view is, that it is close to declarative knowledge; the difference is that
All declarative knowledge are explicit knowledge; it is knowledge that can be and has been articulated. The strategic knowledge is thought as a subset of declarative knowledge.
08
KR -Introduction
Knowledge Start
No
Yes
Implicit
Yes Explicit
Facts and things
No Tacit
Motor Skill (Manual)
Describing
Tasks and methods
Declarative
Procedural
Doing
Mental Skill
The Figure shows, declarative knowledge is tied to "describing" and procedural knowledge is tied to "doing."
The arrows connecting explicit with declarative and tacit with procedural,
develop procedural knowledge as a result of starting with declarative knowledge. i.e., we often "know about" before we "know how". Therefore, we may view,
all procedural knowledge as tacit,
and
KR -framework
1.1 Framework of Knowledge Representation (Poole 1998) Computer requires a well-defined problem description to process and also provide well-defined acceptable solution. To collect fragments of knowledge we need : first to formulate description in our spoken language and then represent it in formal language so that computer can understand. The computer can then use an algorithm to compute an answer. This process is illustrated below.
Problem
Represent
Solve
Solution
Interpret
Informal Formal
Compute
Representation
Output
and
KR - framework
know things to
represent
- facts about objects in the domain. - actions that occur in the domain. - knowledge about how to do things
need means to
manipulate
Thus, knowledge representation can be considered at two levels : (a) knowledge level at which facts are described, and (b) symbol level at which the representations of the objects, defined in terms of symbols, can be manipulated in the programs. Note : A good representation enables fast and accurate access to knowledge and understanding of the content.
11
KR - framework
Facts
Internal Representation
English understanding English generation
English Representation
Facts Representations A fact represented in English sentence Using forward mapping function the above fact is represented in logic A logical representation of the fact that "all dogs have tails"
mechanism
we
can
generate
new
representation of object :
KR - framework
Initial Facts
Forward representation mapping
Final Facts
Backward representation mapping
Internal Representation
Operated by program
English Representation
The doted line on top indicates the abstract reasoning process that a
KR - framework
KR System Requirements
A good knowledge representation enables fast and accurate access to knowledge and understanding of the content. A knowledge representation system should have following properties.
Representational
Adequacy
The ability to represent all kinds of knowledge that are needed in that domain.
Acquisitional
Efficiency
The ability to acquire new knowledge using automatic methods wherever possible rather than reliance on human intervention.
Note : To date no single system can optimizes all of the above properties.
14
KR - schemes
1.2 knowledge Representation schemes There are four types of Knowledge representation - Relational, Inheritable, Inferential, and Declarative/Procedural.
Relational Knowledge :
provides a framework to compare two objects based on equivalent
attributes.
any instance in which two different objects are compared is a relational
type of knowledge.
Inheritable Knowledge
is obtained from associated objects. it prescribes a structure in which new objects are created which may inherit
Inferential Knowledge
is inferred from objects through relations among objects. e.g., a word alone is a simple syntax, but with the help of other words in
phrase the reader may infer more from a word; this inference within linguistic is called semantics.
Declarative Knowledge
a statement in which knowledge is specified, but the use to which that
use or implementation;
KR - schemes
different domains. The table below shows a simple way to store facts.
The facts about a set of objects are put systematically in columns. This representation provides little opportunity for inference.
Given the facts it is not possible to answer simple question such as : " Who is the heaviest player ? ". But if a procedure for finding heaviest player is provided, then these facts will enable that procedure to compute an answer.
16
KR - schemes
The knowledge is embodied in the design hierarchies found in the functional, physical and process domains. Within the hierarchy, elements inherit attributes from their parents, but in many cases, not all attributes of the parent elements be prescribed to the child elements.
The basic KR needs to be augmented with inference mechanism, Inheritance is a powerful form of inference, but not adequate.
and
The KR in hierarchical structure, shown below, is called semantic network or a collection of frames or slot-and-filler structure". It shows property inheritance and way for insertion of additional knowledge.
Property inheritance : Objects/elements of specific classes inherit attributes
Baseball knowledge
isa : show class inclusion
Person
handed height
Right
5.10 6.1
height
isa
Fielder
0.262
instance
Chicago Cubs
instance
Pee-WeeReese
team
team
BrooklynDodger
Fig. Inheritable knowledge representation (KR) the directed arrows represent attributes (isa, instance, and team) originating at the object being described and terminating at the object or its value. the box nodes represents objects and values of the attributes. [Continuing in the next slide]
17
KR - schemes
for an attribute A
of an instance object O.
(a) Get the value of the isa attribute and move to that node. (b) See if there is a value for the attribute A; If yes, report it.
This can be applied to the example of knowledge base illustrated to derive answers to the following queries :
team (Pee-Wee-Reese) = BrooklynDodger battingaverage(Three-Finger-Brown) = 0.106 height (Pee-Wee-Reese) = 6.1 bats(Three Finger Brown) = right
[For explanation - refer book on AI by Elaine Rich & Kevin Knight, page 112]
18
KR - schemes
individual data. The symbols used for the logic operations are :
3. All animals either live on land or in water : x : animal(x) live (x, land) V live (x, water)
We can infer from these three statements that : " Wonder lives either on land or on water." As more information is made available about these objects and their relations, more knowledge can be inferred.
19
KR - schemes
Declarative/Procedural knowledge
The difference between Declarative/Procedural knowledge is not very clear.
Declarative knowledge :
Here, the knowledge is based on declarative facts about axioms and domains.
axioms are assumed to be true unless a counter example is found to
invalidate them.
domains represent the physical world and the perceived functionality. axiom
Here the knowledge is a mapping process between domains that specifies what to do when and the representation is of how to make it rather than what it is. The procedural knowledge :
may
have inferential
and
acquisitional efficiency.
are represented as small programs that know how to do specific things,
how to proceed. Example : a parser in a natural language has the knowledge that a noun phrase may contain articles, adjectives and nouns. It thus accordingly call routines that know how to process articles, adjectives and nouns.
20
KR - issues
1.3 Issues in Knowledge Representation The fundamental goal of Knowledge Representation is to facilitate inferencing (conclusions) from knowledge. The issues that arise while using KR techniques are many. Some of these are explained below.
Set of objects : How sets of objects be represented ? Finding Right structure : Given a large amount of knowledge stored,
how can relevant parts be accessed ?
Note : These issues are briefly explained, referring previous example, Fig.
Inheritable KR. For detail readers may refer book on AI by Elaine Rich & Kevin Knight- page 115 126.
21
KR - issues
Important Attributes
There are two attributes "instance" and "isa", that are of general significance. These attributes are important because they support property inheritance.
The attributes we use to describe objects are themselves entities that we between the attributes of an object, independent of specific knowledge they encode, may hold properties like: Inverses , existence in an isa hierarchy , techniques for reasoning about values and single valued attributes.
Inverses :
This is about consistency check, while a value is added to one attribute. The entities are related to each other in many different ways. The figure shows attributes (isa, instance, and team), each with a directed arrow, originating at the object being described and terminating either at the object or its value. There are two ways of realizing this: first, represent both relationships in a single representation; e.g., a logical representation, team(Pee-Wee-Reese, BrooklynDodgers), that can be interpreted as a statement about Pee-Wee-Reese or BrooklynDodger. second, use attributes that focus on a single entity but use them in pairs, one the inverse of the other; for e.g., one, and the other, team = Pee-Wee-Reese, . . . . This second approach is followed in semantic net and frame-based systems, accompanied by a knowledge acquisition tool that guarantees the consistency of inverse slot by checking, each time a value is added to one attribute then the corresponding value is added to the inverse.
22
team = BrooklynDodgers ,
KR - issues
attribute physical-size which is, in turn, a specialization of physical-attribute. These generalization-specialization relationships are important for attributes because they support inheritance.
KR - issues
Choosing Granularity
Regardless of the KR formalism, it is necessary to know :
At what level should the knowledge be represented and what are the primitives ?." Should there be a small number or should there be a large number of low-level primitives or High-level facts. High-level facts may not be adequate for inference while Low-level primitives may require a lot of storage.
Example of Granularity :
Suppose we are interested in following facts: John spotted Sue. This could be represented as Spotted (agent(John), object (Sue)) Such a representation would make it easy to answer questions such are : Who spotted Sue ? Suppose we want to know : Did John see Sue ? Given only one fact, we cannot discover that answer. We can add other facts, such as Spotted (x , y) saw (x , y) We can now infer the answer to the question.
24
KR - issues
Set of objects
There are certain properties of objects that are true as member of a set but not as individual; Example : Consider the assertion made in the sentences : "there are more sheep than people in Australia", and "English speakers can be found all over the world." To describe these facts, the only way is to attach assertion to the sets representing people, sheep, and English. The reason to represent sets of objects is : If a property is true for all or most elements of a set, then it is more efficient to associate it once with the set rather than to associate it explicitly with every elements of the set . This is done,
and
in hierarchical structure where node represent sets and inheritance propagate set level assertion down to individual.
However in doing so, for example: assert large (elephant), remember to make clear distinction between,
whether we are asserting some property of the set itself, means, the set of elephants is large, or asserting some property that holds for individual elements of the set , means, any thing that is an elephant is large.
and
(c) Intensional definition is to provide a rule, that returns true or false depending
KR - issues
This is about access to right structure for describing a particular situation. This requires, selecting an initial structure and then revising the choice. While doing so, it is necessary to solve following problems :
how to perform an initial selection of the most appropriate structure. how to fill in appropriate details from the current situations. how to find a better structure if the one chosen initially turns out not to be appropriate. what to do if none of the available structures is appropriate. when to create and remember a new structure.
There is no good, general purpose method for solving all these problems. Some knowledge representation techniques solve some of them.
[Readers may refer book on AI by Elaine Rich & Kevin Knight- page 124 - 126]
26
KR using logic
2. KR Using Predicate Logic In the previous section much has been illustrated about knowledge and KR related issues. This section, illustrates how knowledge may be represented as symbol structures that characterize bits of knowledge about objects, concepts, facts, rules, strategies; examples :
red car1 "red(car1)" Assumptions about KR :
Intelligent Behavior can be achieved by manipulation of symbol structures. KR languages are designed to facilitate operations over symbol structures, have precise syntax and semantics; Syntax tells which expression is legal ?, and tells what an expression means ? e.g., red1(car1), red1 car1, car1(red1), red1(car1 & car2) ?; Semantic e.g., property dark red applies to my car.
To satisfy these assumptions about KR, we need formal notation that allow automated inference and problem solving. One popular choice is use of logic.
27
KR using Logic
Logic
Logic is concerned with the truth of statements about the world. Generally each statement is either TRUE or FALSE. Logic includes : Syntax , Semantics and Inference Procedure.
Syntax :
Specifies the symbols in the language about how they can be combined to form sentences. The facts about the world are represented as sentences in logic.
Semantic :
Specifies how to assign a truth value to a sentence based on its meaning in the world. It Specifies what facts a sentence refers to. A fact is a claim about the world, and it may be TRUE or FALSE.
Inference Procedure :
Specifies methods for computing new sentences from an existing sentences.
Note : Facts are claims about the world that are True or False. Representation is an expression (sentence), stands for the objects and relations. Sentences can be encoded in a computer program.
28
KR using Logic
Logic as a KR Language
Logic is a language for reasoning, a collection of rules used while doing logical reasoning. Logic is studied as KR languages in artificial intelligence.
a problem domain. (b) Efficient enough in reasoning and answering questions about
KR Logic
2.1 Logic Representation The Facts are claims about the world that are True or False. Logic can be used to represent simple facts.
To build a Logic-based representation :
User defines a set of primitive symbols and the associated semantics. Logic defines ways of putting symbols together so that user can define legal sentences in the language that represent TRUE facts. Logic defines ways of inferring new sentences from existing ones. Sentences - either TRUE or false but not both are called propositions. A declarative sentence expresses a statement with a proposition as content; example: the declarative "snow is white" expresses that snow is white; further, "snow is white" expresses that snow is white is TRUE. In this section, first Propositional Logic (PL) is briefly explained and then the Predicate logic is illustrated in detail.
30
KR - Propositional Logic
a sentence is smallest unit in propositional logic. then truth value is "true" . if proposition is false, then truth value is "false" .
Propositional logic is fundamental to all logic. Propositional logic Propositional logic propositions, is also called Propositional calculus, Sentential tells the ways of joining and/or modifying entire or sentences, as well as the logical calculus, or Boolean algebra.
propositions, statements or sentences to form more complicated statements relationships and properties that are derived from the methods of combining or altering statements.
31
KR - Propositional Logic
These and few more related terms, such as, connective, truth value, contingencies, tautologies, contradictions, antecedent, consequent and argument are explained below.
Statement
Simple statements (sentences), TRUE or FALSE, that does not contain any other statement as a part, are basic propositions; lower-case letters, p, q, r, are symbols for simple statements. Large, compound or complex statement are constructed from basic propositions by combining them with connectives.
Connective or Operator
The connectives join simple statements into compounds, and joins compounds into larger compounds. Table below indicates, five basic connectives and their symbols :
listed in decreasing order of operation priority; operations with higher priority is solved first.
Symbols
"p is true"
Read as
NOT AND OR if ..then
p
pq
"p is false"
"both p and q are true" "either p is true, or q is true, or both "
&& & |
P v q ||
pq
if and only if "p and q are either both true or both false"
Note : The propositions and connectives are the basic elements of propositional logic.
32
Truth value
The truth value of a statement is its Example : p ~p pvq is either TRUE or FALSE, is either TRUE or FALSE,
KR - Propositional Logic
TRUTH or FALSITY ,
use " T " or " 1 " to mean TRUE. use " F " or " 0 " to mean FALSE Truth table defining the basic connectives : p
T T F F
33
q
T F T F
p q p q p v q p q p q
F F T T F T F T T F F F T T T F T F T T T F F T
q p
T T F T
KR - Propositional Logic
Tautologies
A proposition that is always true is called a tautology. e.g., (P v P) is always true regardless of the truth value of the
proposition P.
Contradictions
A proposition that is always false is called a contradiction. e.g., (P P) is always false regardless of the truth value of
the proposition P.
Contingencies
A proposition is called a contingency, if that proposition is neither a tautology nor a contradiction e.g., (P v Q) is a contingency.
Antecedent, Consequent
In the conditional statements, p q , the 1st statement or "if - clause" (here p) is called antecedent , 2nd statement or "then - clause" (here q) is called consequent.
34
Argument
KR - Propositional Logic
Any argument can be expressed as a compound statement. Take all the premises, conjoin them, and make that conjunction the antecedent of a conditional and make the conclusion the consequent. This implication statement is called the corresponding conditional of the argument.
Note :
Every
argument
has
corresponding
conditional,
and
every
Because the corresponding conditional of an argument is a statement, it is therefore either a tautology, or a contradiction, or a contingency.
An argument is valid "if and only if" its corresponding conditional is a tautology. Two statements are consistent "if and only if" their conjunction is not a contradiction. Two statements are logically equivalent "if and only if" their truth table columns are identical; "if and only if" the statement of their equivalence using " " is a tautology.
Note :
KR - Predicate Logic
Predicate logic
The propositional logic, is not powerful enough for all types of assertions; Example : The assertion "x > 1", where x is a variable, is not a proposition because it is neither true nor false unless value of x is defined. For x > 1 to be a proposition ,
either we substitute a specific number for x ; or change it to something like "There is a number x for which x > 1 holds"; or "For every number x, x > 1 holds".
Consider example : All men are mortal. Socrates is a man. Then Socrates is mortal , These cannot be expressed in propositional logic as a finite and logically valid argument (formula).
We need languages : that allow us to describe properties (predicates) of
objects, or a relationship among objects represented by the variables . Predicate logic satisfies the requirements of a language.
36
Predicate logic is powerful enough for expression and reasoning. Predicate logic is built upon the ideas of propositional logic.
KR - Predicate Logic
Predicate : Every complete sentence contains two parts: a subject and a predicate. The subject The predicate Example : A sentence "Judy {runs}". is Judy and the predicate is runs . The subject is what (or whom) the sentence is about. tells something about the subject;
Predicate, always includes verb, tells something about the subject. Predicate is a verb phrase template that describes a property of objects, or a relation among objects represented by the variables. Example: The car Tom is driving is blue" ; "The sky is blue" ; "The cover of this book is blue" Predicate is is blue" , describes property. "x is blue"; Predicates are given names; Let B is name for predicate "is_blue". Sentence is represented as "B(x)" , read as x represents an arbitrary Object .
37
Predicate logic expressions : The propositional operators combine predicates, like If ( p(....) && ( !q(....) || r (....) ) )
KR - Predicate Logic
Examples of logic operators : disjunction (OR) and conjunction (AND). Consider the expression with the respective logic symbols || and && x < y || ( y < z && z < x) Which is true || ( true && True x, y, z and then true) ;
Assignment for < are 3, 2, 1 for the value can be FALSE or TRUE
False
KR - Predicate Logic
Predicate Logic Quantifiers As said before, x>1 is not proposition and why ? to be a proposition what is required ? Also said, that for x > 1
Generally, a predicate with variables (is called atomic formula) can be made a proposition by applying one of the following two operations to each of its variables :
1. Assign a value to the variable; e.g., x > 1, proposition. 2. Quantify the variable using a quantifier on formulas of predicate logic (called wff ), such as x > 1 or P(x), by using Quantifiers on variables. Apply Quantifiers on Variables if 3 is assigned to x becomes 3 > 1 , and it then becomes a true statement, hence a
Variable * x > 5
value of variable x * to reason such statements, x need to be declared Declaration x : a * x:a * x:a Statement declares variable x read as x is an element of set a
p is a statement about x is quantification of statement statement declaration of variable x as element of set a quantifier
* Q x:a p
* Quantifiers are two types : universal quantifiers , denoted by symbol and existential quantifiers , denoted by symbol Note : The next few slide tells more on these two Quantifiers.
39
KR - Predicate Logic
Universe of Discourse The universe of discourse, also called domain of discourse or universe. This indicates :
a set of entities that the quantifiers deal. entities can be set of real numbers, set of integers, set of all cars on a parking lot, the set of all students in a classroom etc. universe is thus the domain of the (individual) variables. propositions in the predicate logic are statements on objects of a universe.
The universe is often left implicit in practice, but it should be obvious from the context. Examples:
About natural numbers forAll x, y (x < y or x = y or x > y), there is no need to be more precise and say forAll because N is implicit, being the universe of discourse. x, y in N,
About a property that holds for natural numbers but not for real numbers, it is necessary to qualify what the allowable values of x and y are.
40
KR - Predicate Logic
Apply Universal quantifier collection of objects. Universal quantification: * read for all x in a , * a is universe of discourse
x:ap p holds
* x is a member of the domain of discourse. * p is a statement about x In propositional form it is written as : * read for all for each for every x x, x, x, P(x) holds P(x) holds P(x) holds x in the universe or x P(x)
* where P(x) is predicate, means all the objects P(x) is true for every object x in the universe Example : English language to Propositional form * "All cars have wheels" x : car x has wheel * x P(x) where P (x) is predicate tells : x has wheels x is variable for object cars that populate universe of discourse
41
KR - Predicate Logic
Existential Quantification allows us to state that an object does exist without naming it. Existential quantification: x:ap
* read there exists an x such that p holds * a is universe of discourse * x is a member of the domain of discourse. * p is a statement about x In propositional form it is written as : * read * Where x P(x)
there exists an x such that P(x) or there exists at least one x such that P(x) P(x) is predicate x P(x) means at least one object x in the universe is true for least one object x in the universe
Example : English language to Propositional form * Someone loves you x : Someone x loves you * x P(x) where P(x) is predicate tells : x loves you x
42
KR - Predicate Logic
Formula : In mathematical logic, a formula is a type of abstract object, a token of which is a symbol or string of symbols which may be interpreted as any meaningful unit in a formal language. Terms : Defined recursively as variables, or constants, or functions like f(t1, . . . , tn), where f is an n-ary function symbol, and t1, . . . , tn are terms. Applying predicates to terms produce atomic formulas. Atomic formulas : An atomic formula (or simply atom) is a formula with no deeper propositional structure, i.e., a formula that contains no logical connectives or a formula that has no strict sub-formulas.
Atoms are thus the simplest well-formed formulas of the logic. Compound formulas are formed by combining the atomic formulas
or
R(t1, . . . , tn),
are terms.
(a
b) c))
KR logic relation
Logic statements, containing subject, predicate, and object, were explained. Also stated, two important attributes "instance" and "isa", in a hierarchical structure (ref. fig. Inheritable KR). These two attributes support property inheritance and play important role in knowledge representation. The ways, attributes "instance" and "isa", are logically expressed are : Example : A simple sentence like "Joe is a musician" Here "is a" (called IsA) is a way of expressing what logically is called a class-instance relationship between the subjects represented by the terms "Joe" and "musician". "Joe" is an instance of the class of things called "musician". "Joe" plays the role of instance, "musician" plays the role of class in that sentence. Note : In such a sentence, while for a human there is no confusion, but for computers each relationship have to be defined explicitly. This is specified as: i.e.,
44
[Joe] [Instance]
IsA IsA
[Musician] [Class]
2.3 Computable Functions and Predicates The objective is to define class of functions C computable in terms of F. This is expressed as C { F } is explained below using two examples : (1) "evaluate factorial n" and (2) "expression for triangular functions". n!
Example (1) : A conditional expression to define factorial n ie Expression if p1 then e1 else ie. Here p1, p2, . . . . pn if p2 then e2 ... else
if pn then en .
pn en )
values T or F for true and false respectively. The value of ( p1 e1, p2 e2, the e corresponding to the first p that has value T. The expressions defining n! , n= 5, recursively are : n! = n x (n-1)! for n 1 5! = 1 x 2 x 3 x 4 x 5 = 120 0! = 1 The above definition incorporates an instance that the product of no numbers ie 0! = 1 , then only, the recursive relation (n + 1)! = n! x (n+1) works for n = 0 . Now use conditional expressions n! = ( n = 0 1, n 0 n . (n 1 ) ! ) to define functions recursively. Example: Evaluate 2! = 2 x 1! = 2 x ( 1 = 0 1, = 2 x 1 x 0! = 2 x 1 x ( 0 = 0 1, = 2x 1x 1 = 2
45
= ( 2 = 0 1,
-1,0
1,0
2.4 Resolution Resolution is a procedure used in proving that arguments which are expressible in predicate logic are correct. Resolution is a procedure that produces proofs by refutation or
contradiction. Resolution lead to refute a theorem-proving technique for sentences in propositional logic and first-order logic.
Resolution is a rule of inference. Resolution is a computerized theorem prover. Resolution is so far only defined for Propositional Logic. The strategy is
that
in
Predicate Logic.
47
KR Using Rules
3. KR Using Rules Knowledge representations using predicate logic have been illustrated.
The other most popular approach to Knowledge representation is to use production rules, sometimes called IF-THEN rules. The remaining two other types of KR are semantic net and frames. The production rules are simple but powerful forms of knowledge representation providing the flexibility of combining declarative and procedural representation for using them in a unified form. Examples of production rules :
IF condition THEN action IF premise
THEN conclusion
The production rules as knowledge representation mechanism are used in the design of many "Rule-based systems" also called "Production systems" .
48
KR Using Rules
Types of rules
Three major types of rules used in the Rule-based production systems. Knowledge Declarative Rules : These rules state all the facts and relationships about a problem. e.g., IF inflation rate declines THEN the price of gold goes down. These rules are a part of the knowledge base. Inference Procedural Rules These rules advise on how to solve a problem, while certain facts are known. e.g., IF the data needed is not in the system THEN request it from the user. These rules are part of the inference engine. Meta rules These are rules for making rules. Meta-rules reason about which rules should be considered for firing.
e.g., IF the rules which do not mention the current goal in their premise, AND there are rules which do mention the current goal in their premise, THEN the former rule should be used in preference to the latter.
Meta-rules
direct
reasoning
rather
than
actually
performing
reasoning.
Meta-rules specify which rules should be considered and in which
3.1 Procedural versus Declarative Knowledge These two types of knowledge were defined in earlier slides. Procedural Knowledge : knowing 'how to do' Includes : Rules, strategies, agendas, procedures, models. These explains what to do in order to reach a certain conclusion. e.g., Rule: To determine if Peter or Robert is older, first find their ages. It is knowledge about how to do something. It manifests itself in the doing of something, e.g., manual or mental skills cannot reduce to words. It is held by individuals in a way which does not allow it to be communicated directly to other individuals. Accepts a description of the steps of a task or procedure. being described instead of facts or things. Declarative Knowledge : knowing 'what', knowing 'that' It Looks
Includes : Concepts, objects, facts, propositions, assertions, models. It is knowledge about facts and relationships, that
can be expressed in simple and clear statements, can be added and modified without difficulty.
e.g.,
Declarative knowledge and explicit knowledge are articulated knowledge and may be treated as synonyms for most practical purposes. Declarative knowledge is represented in a format that can be
Hard to debug Black box Obscure Process oriented Extension may effect stability Fast , direct execution Simple data type can be used
sets of rules, organized into
Easy to validate White box Explicit Data - oriented Extension is easy Slow (requires interpretation) May require high level data type
production system, the entire set of rules for executing the task.
51
SQL
within the DBMS
Most work is done by interpreter of Most work done by Data Engine For one task many lines of code
translating the objective into lines of procedural code around the actual data
hold the data and execute the SQL statement . with the execution of the SQL statement
Data
exposed to programmer Programmer receives data at end during execution of the code as an entire set changes in the data structure changing data structure speed records
More susceptible to failure due to More resistant to changes in the Traditionally faster, but that is Originally slower, but now setting Code of procedure tightly linked to Same SQL statements will work
front end
Code
with Code loosely linked to structure of data; DBMS handles structural issues positioning
KR Logic Programming
3.2 Logic Programming Logic programming offers a formalism for specifying a computation in terms of logical relations between entities.
logic program is a collection of logic statements. programmer describes all relevant logical relationships between the
various entities.
computation determines whether or not, a particular conclusion follows
manner in which inference rules are applied. Thus Logic + Control = Algorithms
KR Logic Programming
There are many ways of organizing computations. The most familiar paradigm is procedural. The program specifies a computation by saying "how" it is to be performed. FORTRAN, C, and object-oriented languages fall under this general approach. Another paradigm is declarative. The program specifies a computation by giving the properties of a correct answer. Prolog and logic data language (LDL) are examples of declarative languages, emphasize the logical properties of a computation.
Prolog and LDL are called logic programming languages. PROLOG is the most popular Logic programming system.
54
KR Logic Programming
(A) Data components : Data components are collection of data objects that follow hierarchy.
Data object of any kind is also called
Data Objects (terms) Simple Structured
a term. A term is a constant, a variable or a compound term. Simple constants, data object The is not syntax decomposable; e.g. atoms, numbers, variables. distinguishes the data objects, hence no need for declaring them. Structured data object are made of several components; e.g. general, special structure.
Constants
Variables
Atoms
Numbers
All these data components were mentioned now explained in detail below.
55
in
KR Logic Programming
(a) Data objects : The data objects of any kind is called a term.
Term : examples Constants: denote elements such as integers, floating point, atoms. Variables: denote a single but unspecified element; variables begin with an uppercase letter or an underscore. Compound terms: comprise a functor and sequence of one or more compound terms called arguments. symbols for
Functors with the same name but different arities are distinct.
KR Logic Programming
X25
List
Noun_Phrase
KR Logic Programming
Note : a structure in Prolog is a mechanism for combining terms together, like integers 2, 3, 5 are combined with the functor plus. Special Structures In Prolog an ordered collection of terms is called a list . Lists are structured terms and Prolog offers a convenient notation to represent them: * * Empty list is denoted by the atom [ ]. Non-empty list carries element(s) between square brackets, separating elements by comma. e.g.
58
[bach, bee]
[]
KR Logic Programming
(B) Program Components A Prolog program is a collection of predicates or rules. A predicate establishes a relationships between objects.
(a) Clause, Predicate, Sentence, Subject Clause is a collection of grammatically-related words . Predicate is composed of one or more clauses. Clauses are the building blocks of sentences; every sentence contains one or more clauses. A Complete Sentence has two parts: subject and predicate. o subject is what (or whom) the sentence is about. o predicate tells something about the subject. Example 1 : the predicate Example 2 : "cows eat grass". "cows" and "eat grass." "cows eating grass are visible from highway" and It is a clause, because it contains the subject
the predicate "are visible from the highway" makes complete thought.
KR Logic Programming
(b) Predicates & Clause Syntactically a predicate is composed of one or more clauses. The general form of clauses is : <left-hand-side> :- <right-hand-side>. where LHS is a single goal called "goal" and RHS is composed of one or more goals, separated by commas, called "sub-goals" of the goal on left-hand side. The structure of a clause in logic program
head pred ( functor(var1, var2)) :body pred(var2) literal
pred(var1) , literal
clause
Example :
:-
Interpretation: * a clause specifies the conditional truth of the goal on the LHS; i.e., goal on LHS is assumed to be true if the sub-goals on RHS are all true. A predicate is true if at least one of its clauses is true. * An individual "Y" is the grand-parent of "X" "X" Y is "Z" and "Y" (Y is parent of Z) Z if a parent of that same
(Y is grand parent of X) * An individual "Y" is a parent of "X" if "Y" is the mother of "X" (Y is parent of X) Y (Y is mother of X) * An individual "Y" is a parent of "X" (Y is parent of X) Y (Y is father of X)
60
KR Logic Programming
(c) Unit Clause - a special Case Unlike the previous example of conditional truth, one often encounters unconditional relationships that hold. In Prolog the clauses that are unconditionally true are called clause or fact Example : say Unconditionally relationships is unconditionally true. 'Y' is the father of 'X' father(X, Y) :true. unit
This relationship as a Prolog clause is : Interpreted as relationship of father between Y and X is always true; or simply stated as Y is father of X Goal true is built-in in Prolog and always holds.
KR Logic Programming
(d) Queries In Prolog the queries are statements called directive. directives, are called queries. A special case of
The Imperative model of computation, consists of a state and an operation of assignment which is used to modify the state. Programs consist of sequences of commands. The computations are changes in the state. Example 1 : Linear function A linear function y = 2x + 3 can be written as Y := 2 X + 3 The implementation determines the value of X in the state and then create a new state, which differs from the old state. The value of Y in the new state is the value that 2 X + 3 had in the old state. Old State: X = 3, Y := 2 X + 3 New State: X = 3, Y = 9, on which most efficient model in terms The imperative model is closest to the hardware model programs are executed, that makes it of execution time.
64
Y = -2,
(b) Functional model : The Functional model of computation, consists of a set of values, functions, and the operation of functions. The functions may be named and may be composed with other functions. They can take other functions as arguments and return results. The programs consist of definitions of functions. The computations are application of functions to values. Example 1 : Linear function A linear function y = 2x + 3 can be defined as : f (x) = 2 x + 3 Example 2 : Determine a value for Circumference. Assigned a value to Radius, that determines a value for Circumference. Circumference = 2 pi radius where pi = 3.14 Generalize Circumference with the variable "radius" Circumference(radius) = 2 pi radius , ie where pi = 3.14
Functional models are developed over many years. The notations and methods form the base upon which problem solving methodologies rest.
65
(c) Logic model : The logic model of computation is based on relations and logical inference. Programs consist of definitions of relations. Computations are inferences (is a proof). Example 1 : Linear function A linear function y = 2x + 3 can be represented as : f (X , Y) Example 2: if Y is 2 X + 3. Determine a value for Circumference. Pi = 3.14 and C = 2 pi R.
The earlier circumference computation can be represented as: Circle (R , C) if circumference C. Example 3: Determine the mortality of Socrates. The program is to determine the mortality of Socrates. The fact given that Socrates is human. The rule is that all humans are mortal, for all X, that is if X is human then X is mortal. The function is represented as a relation between radious R and
To determine the mortality of Socrates, make the assumption that there are no mortals, that is mortal (Y)
[logic model
66
slide]
[logic model
The fact and rule are: human (Socrates) mortal (X) if human (X) mortal (Y)
Fact Rule assumption from 2 & 3 by unification and modus tollens from 1 and 4 by unification 5, 4b, and 1
To determine the mortality of Socrates, make the assumption that there are no mortals i.e.
1. 2. 3 4.(a) 4.(b) 5. 6. human(Socrates) mortal(X) if human(X) mortal(Y) X=Y human(Y) Y = Socrates Contradiction
Explanation :
* The 1st line is the statement "Socrates is a man." * The 2nd line is a phrase "all human are mortal"
into the equivalent "for all X, if X is a man then X is mortal".
* The 3rd line is added to the set to determine the mortality of Socrates. * The 4th line is the deduction from lines 2 and 3. It is justified by the
inference rule modus tollens which states that if the conclusion of a rule is known to be false, then so is the hypothesis.
* Variables X and Y are unified because they have same value. * By unification, Lines 5, 4b, and 1 produce contradictions and identify
Socrates as mortal.
contradiction and it is facilitated by unification which determines if there is a substitution which makes two terms the same.
Logic model formalizes the reasoning process. It is related to relational data bases and expert systems.
67
KR forward-backward reasoning
3.3 Forward versus Backward Reasoning Rule-Based system architecture consists a set of rules, a set of facts, and an inference engine. The need is to find what new facts can be derived. Given a set of rules, there are essentially two ways to generate new
knowledge: one, forward chaining and the other, backward chaining. Forward chaining : also called data driven. It starts with the facts, and sees what rules apply. Backward chaining : also called goal driven. It starts with something to find out, and looks for rules that will help in answering it.
68
KR forward-backward reasoning
Example 1 :
Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : IF IF IF hot hot AND smoky alarm_beeps fire [Given] [Given] THEN fire THEN smoky THEN switch_on_sprinklers
alarm_beeps
Example 2 :
Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 :
69
IF IF IF hot
alarm_beeps
KR forward-backward reasoning
alarm_beeps
[Given] [Given]
KR forward chaining
Forward chaining
The Forward chaining system, properties , algorithms, and conflict resolution strategy are illustrated. Forward chaining system
facts
Working Memory
facts facts
Inference Engine
rules
User
Rule Base
facts are held in a working memory condition-action rules represent actions to be taken when specified facts occur in working memory. typically, actions involve adding or deleting facts from the working memory. Properties of Forward Chaining all rules which can fire do fire. can be inefficient - lead to spurious rules firing, unfocused problem solving set of rules that can fire known as conflict set. decision about which rule to fire is conflict resolution.
71
KR forward chaining
alarm_beeps
two rules can fire (R2 and R4) humidifier is on (then, as before) humidifier is off A conflict !
R4 fires, R2 fires,
KR forward chaining
Conflict Resolution Strategy Conflict set is the set of rules that have their conditions satisfied by working memory elements. Conflict resolution normally selects a single rule to fire. The popular conflict resolution mechanisms are Refractory, Recency, Specificity. Refractory
a rule should not be allowed to fire more than once on the same data. discard executed rules from the conflict set. prevents undesired loops.
Recency
rank instantiations in terms of the recency of the elements in the premise of the rule. rules which use more recent data are preferred. working memory elements are time-tagged indicating at what cycle each fact was added to working memory.
Specificity
rules which have a greater number of conditions and are therefore more difficult to satisfy, are preferred to more general rules with fewer conditions. more specific rules are better because they take more of the data into account.
73
KR forward chaining
Alternative to Conflict Resolution Use Meta Knowledge Instead of conflict resolution strategies, sometimes we want to use knowledge in deciding which rules to fire. Meta-rules reason about which rules should be considered for firing. They direct reasoning rather than actually performing reasoning.
Meta-knowledge : knowledge about knowledge to guide search. Example of meta-knowledge
IF THEN
conflict set contains any rule (c , a) such that a = "animal is mammal'' fire (c , a)
level" knowledge.
74
KR backward chaining
Backward chaining
Backward chaining system and the algorithm are illustrated. Backward chaining system
Backward chaining means reasoning from goals back to facts.
If
Otherwise, find a rule which can be used to conclude try to prove each of that rule's conditions.
alarm_beeps
Smoky
hot
fire switch_on_sprinklers Encoding of rules Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : Goal :
75
[Given] [Given]
KR backward chaining
want to see what can be concluded from current situation; Synthesis systems - design / configuration.
76
e.g.,
KR control knowledge
3.4 Control Knowledge An algorithm consists of : logic component, that specifies the knowledge to be used in solving problems, and control component, that determines the problem-solving strategies by means of which that knowledge is used. Thus Algorithm = Logic + Control . The logic component determines the meaning of the algorithm whereas the control component only affects its efficiency. An algorithm may be formulated in different ways, producing same behavior. One formulation, may have a clear statement in logic component but employ a sophisticated problem solving strategy in the control component. The other formulation, may have a complicated logic component but employ a simple problem-solving strategy. The efficiency of an algorithm can often be improved by improving the control component without changing the logic of the algorithm and therefore without changing the meaning of the algorithm. The trend in databases is towards the separation of logic and control. The programming languages today do not distinguish between them. The programmer specifies both logic and control in a single language. The execution mechanism exercises only the most rudimentary problem-solving capabilities. Computer programs will be more often correct, more easily improved, and more readily adapted to new problems when programming languages separate logic and control, and when execution mechanisms provide more powerful problem-solving facilities of the kind provided by intelligent theorem-proving systems.
77
4. References
1. 2. 3. 4. 5. 6. 7. 8. 9. Elaine Rich and Kevin Knight, Carnegie Mellon University, Artificial Intelligence, 2006 Stuart Russell and Peter Norvig, University of California, Artificial Intelligence: A Modern Approach, http://aima.cs.berkeley.edu/, http://www.cs.berkeley.edu/~russell/intro.html Frans Coenen, University of Liverpool, Artificial Intelligence, 2CS24, http://www.csc.liv.ac.uk/~frans/OldLectures/2CS24/ai.html#definition" John McCarthy, Stanford University, what is artificial intelligence? http://www-formal.stanford.edu/jmc/whatisai/whatisai.html Randall Davis, Howard Shrobe, Peter Szolovits, What is a Knowledge Representation? http://groups.csail.mit.edu/medg/ftp/psz/k-rep.html#intro Conversion of data to knowledge, http://atlas.cc.itu.edu.tr/~sonmez/lisans/ai/KNOWLEDGE_REP.pdf Knowledge ManagementEmerging Perspectives, http://www.systems-thinking.org/kmgmt/kmgmt.htm Knowledge Management , http://www.nwlink.com/~donclark/knowledge/knowledge.html Nickols, F. W. (2000), The knowledge in knowledge management, http://home.att.net/~nickols/Knowledge_in_KM.htm
10. Paul Brna, Prolog Programming A First Course, http://computing.unn.ac.uk/staff/cgpb4/prologbook/book.html 11. Mike Sharples, David Hogg, Chris Hutchison, Steve Torrance, David Young, A practical Introduction to Artificial Intelligence, http://www.informatics.susx.ac.uk/books/computersand-thought/index.html 12. Alison Cawsey, Databases and Artificial Intelligence 3 Artificial Intelligence Segment, http://www.macs.hw.ac.uk/~alison/ai3notes/all.html 13. Milos Hauskrecht , CS2740 Knowledge Representation (ISSP 3712), http://www.cs.pitt.edu/~milos/courses/cs2740/ 14. Tru Hoang Cao , Knowledge Representation chapter 4, http://www.dit.hcmut.edu.vn/~tru/AI/chapter4.ppt, http://www.dit.hcmut.edu.vn/~tru/AI/ai.html 15. Agnar Aamodt, A Knowledge-Intensive, Integrated Approach to Problem Solving and Sustained Learning, http://www.idi.ntnu.no/grupper/su/publ/phd/aamodt-thesis.pdf
16. Ronald J. Brachman and Hector J. Levesque, Knowledge Representation and Reasoning, http://www.cs.toronto.edu/~hector/PublicKRSlides.pdf. 17. Stuart C. Shapiro, Knowledge Representation, CSE 4/563 http://www.cse.buffalo.edu/~shapiro/Courses/CSE563/ 18. Robert M. Keller, Predicate Logic http://www.cs.hmc.edu/~keller/cs60book/10%20Predicate%20Logic.pdf 19. Kevin C. Klement, Propositional Logic, http://www.iep.utm.edu/p/prop-log.htm#top 20. Aljoscha Burchardt, Stephan Walter, . . . , Computational Semantics http://www.coli.uni-saarland.de/projects/milca/courses/comsem/html/index.html 21. Open To Europe project, FUNDAMENTALS OF PROPOSITIONAL LOGIC http://www.informatik.htw-dresden.de/~nestleri/main.html 22. J Lawry, Propositional Logic Review, http://www.enm.bris.ac.uk/research/aigroup/enjl/logic/ 23. Al Lehnen, An Elementary Introduction to Logic and Set Theory, http://faculty.matcmadison.edu/alehnen/weblogic/logcont.htm 24. Jim Woodcock and Jim Davies, Using Z, http://www.uta.edu/cse/levine/fall99/cse5324/z/ 25. C. R. Dyer, Logic , CS 540 Lecture Notes, http://pages.cs.wisc.edu/~dyer/cs540/notes/logic.html 26. Peter Suber, Symbolic Logic, , http://www.earlham.edu/~peters/courses/log/loghome.htm 27. John Mccarthy, A Basis For A Mathematical Theory Of Computation, http://www-formal.stanford.edu/jmc/basis1/basis1.html 28. Shunichi Toida, CS381 Introduction to Discrete Structures, http://www.cs.odu.edu/~toida/index.html 29. Leopoldo Bertossi, Knowledge representation , http://www.scs.carleton.ca/~bertossi/KR/ 30. Anthony A. Aaby, Introduction to Programming Languages, http://moonbase.wwc.edu/~aabyan/PLBook/book/book.html 31. Carl Alphonce, CS312 Functional and Logic Programming, http://www.cse.buffalo.edu/faculty/alphonce/.OldPages/CPSC312/CPSC312/Lecture/Lectur eHTML/CS312.html 32. Anthony A. Aaby, Introduction to Programming Languages, http://cs.wwc.edu/~aabyan/PLBook/HTML/ Note : This list is not exhaustive. The quote, paraphrase or summaries, information, ideas, text, data, tables, figures or any other material which originally appeared in someone elses work, I sincerely acknowledge them.
79