The byproduct of sericulture in different industries.pptx
Knowledge base system appl. p 1,2-ver1
1. Course Code: IS 463
Course Title:
Knowledge Base Systems Application
PART : 1
Prof. Taymoor Mohamed Nazmy
Dept. of computer science, faculty of computer science, Ain Shams uni.
Ex-vice dean of post graduate studies and research Cairo, Egypt
2. Course Description
• Introduction.
• Review of first-order logic, relational algebra, and relational
calculus.
• Fundamentals of logic programming. Logic for knowledge
representation. Architecture of knowledge-base system.
Fundamentals of deductive databases. Top-down and bottom-
up query processing. Some important query processing
strategies and their comparison. Project or term paper on
current research topics.
• Textbook:
• Richard A. Frost, Introduction to Knowledge Based Systems.
3. About the lecturer
- Prof. of computer science since 2006,
- Director of Ain Shams information network,
- Vice dean of post graduate studies and research,
- Vice dean of environmental and social affairs,
- Member in editorial board of many Int. journals,
- Member in Scientific committee of many int.
conferences
- Executive chair of int. conf. on information and
intelligent systems,
- Published more than 60 scientific papers in int. journals
and conference,
-Supervised more than 20 master and Ph. D thesis.
4. About the course
• The materials of this course were collected from many resources, include the reference
book, other books, online courses, presentations, and web sites.
• There are many details will be given to simplify topics in this course, however at the end of
the course the most important topics will be highlighted.
• The delivered materials through this presentation is your main resource,
• This presentation will be delivered to you, through one ways, such as drop box, the course
consist of 4 parts, we will starts with Part 1,2, then continue with Part 3,4.
• There will be term exams 40%
• The attendance and term paper 20%
• The final exam 40%
• The exam will include subjective and objective questions,
• Through this course try to extends your knowledge by improving your self learning
capabilities.
5. The lecture link
• https://www.dropbox.com/s/9ee1j8jxj8jep8e/
Knowledge%20base%20system%20appl.-
%20P%201%2C2-ver1.pptx?dl=0
• Ntaymoor19600@gmail.com
6. Term paper
• Each 3-4 students have to prepare a report (20-30
page), to be delivered before the end of the term
in one of the following topics:
• Big data analytics,
• Types of query languages,
• Expert systems,
• Web SQL Database,
• Query processing,
• Open topic.
10. Cognitive sensors and networks
Cognitive information fusion
Cognitive robots
Cognitive agent technologies
Cognitive machine learning
Cognitive semantics
Cognitive mobile systems
Cognitive signal processing
Cognitive mobile systems
Cognitive vehicle communication
Cognitive knowledge representation
DNA and genome cognition
Cognitive image processing
Cognitive space communication
Cognitive agent technologies
Cognitive decision theories
Cognitive learning engines
Cognitive inference engines
Big data cognition
Cognitive informatics
Cognitive computer vision
11. KR and human brain
• Human brain can be considered as a huge knowledge base
system. Human can represent his knowledge by natural
language, sign language, Rhythms, painting, etc.
• Human brain can process the represented knowledge with
many complex fast methods called cognitive processes.
• Do you know that each human cell is it self a storage for
knowledgebase, how?
• Some of those method where simplified to be used by
computer, as we will see later.
12.
13. KR and artificial cognitive systems
• In the last few years, a big progress was achieved
towards having a machine that can understand
directly human language, self learning, and
compete with human to answer difficult
questions.
• This machine is called IBM WATSON, it
represents the new era of computing to have what
is called artificial cognitive systems. Most of
computer science disciplines will turned towards
this system.
14. A semantic network to represent the relation
among different topics related to knowledgebase
15. Definitions
• Knowledge: among other things, knowledge is a relation between a
knower and a proposition
– knower : John
– proposition: the idea expressed by a simple declarative sentence,
like “Mary will come to the party.”
– Knowledge representation, then, is the field of study concerned
with using formal symbols to represent a collection of
propositions.
– Reasoning: it is the formal manipulation of the symbols representing
a collection of believed propositions to produce representations of
new ones.
– Reasoning is a form of calculation, not unlike arithmetic, but over
symbols standing for propositions rather than numbers
16. Artificial Intelligence and Knowledge Representation
A description of Artificial Intelligence is:
The study and development of systems that
demonstrate intelligent behavior
Based on the above, a description of Knowledge
Representation & Reasoning is:
The study of ways to represent and reason with
information in order to achieve intelligent behavior
17. 17
Main questions
How we can represent knowledge
as symbol structures ?
How we can use that knowledge to
intelligently solve problems ?
18. Sources of Knowledge
• The main source of knowledge is the human
and his knowledge can be:
• documented
– books, journals, procedures
– films, databases
• undocumented
– people’s knowledge, explicit and tacit.
19. Types Knowledge
Type of Knowledge Examples
Facts dogs, teeth, house
Relations mother of Paul
Rules If it is cloudy then
It will rain
Concepts For all X & Y
Procedures Do this then that
21. Levels of Knowledge
• Shallow level:
– very specific to a situation Limited by IF-THEN type
rules. Rules have little meaning. No explanation.
• Deep Knowledge:
– problem solving. Internal causal structure. Built from a
range of inputs
– emotions, common sense,
– difficult to build into a system.
22. A knowledge-based system
• A knowledge-based system (KBS) is a computer program that can
represents the knowledge and reasons to solve complex problems.
• A knowledge based system has two types of sub-systems: a knowledge
base and an inference engine.
• The knowledge base represents facts about the world using knowledge
representation (KR) methods. The inference engine represents logical
assertions and conditions about the world, usually represented via IF-
THEN rules.
• Knowledge-based systems were first developed by artificial
intelligence researchers. These early knowledge-based systems were
primarily expert systems – in fact, the term is often used synonymously
with expert systems.
23.
24. Knowledge Representation
A subarea of Artificial Intelligence concerned with understanding,
designing, and implementing ways of representing information
(knowledge) in computers so that programs (agents) can use this
information…
• to derive new information that is implied by it, (inference, and
reasoning),
• to converse with people in natural languages,
• to decide what to do next
• to plan future activities,
• to solve problems in areas that normally require human
expertise.
25. How can knowledge be represented ?
Symbolic methods
Declarative Languages (Logic)
Declarative programing means style of building the structure and elements of computer programs—that expresses
the logic of a computation without describing its control flow. Where Algorithm = Logic + Control.
Imperative Languages (C, C++, Java, etc.),
Imperative programing means programming paradigm that uses statements that change a program's state.
Hybrid Languages (Prolog)
Rules
Frames
Semantic Networks
…
Non – symbolic methods
Neural Networks
Genetic Algorithms
28. What language should we use?
• Natural language, ie English, ASL, Cantonese. Too ambiguous.
• Programming Language, ie C++, Lisp, Java. Not very expressive.
We will use logic! Actually there are many different logics.
We will start by considering
•Propositional Logic. We will find that has some drawbacks so we
will consider the more general
•Predicate Logic. This too, has limitations, so we will consider the
more general
•First-Order Logic.
•Predicate logic
• (occasionally referred to as
• First-order logic (FOL))
Propositional Logic
Predicate Logic
First-Order Logic
29. Logic for KR
• Logic is a great knowledge representation language for many
AI problems
• Propositional logic is the simple foundation and fine for some
AI problems
• First order logic (FOL), is also known Predicate calculus is
much more expressive as a KR language and more commonly
used in AI
• There are many variations of logics such as: horn logic, higher
order logic, three-valued logic, probabilistic logics, etc.
30. Simple Propositions and
Compound Propositions
• Fast foods tend to be unhealthy.
• Parakeets are colorful birds.
• More complex proposition such as:
• If fast foods tend to be unhealthy, then you
shouldn’t eat them.
• Parakeets are colorful birds, and colorful birds
are good to have at home.
31. Basic connectives and truth tables
primitive and compound statements can be represented
by logical connectives, such as:
p p,
(a) conjunction (AND):
(b) disjunction(inclusive OR):
(c) exclusive or:
(d) implication: (if p then q)
(e) biconditional: (p if and only if q, or p iff q)
(f) negation ( )
p q
p q
p q
p q
p q
32. 32
Truth tables
Logic, like arithmetic, has operators, which apply to
one, two, or more values (operands)
A truth table lists the results for each possible
arrangement of operands
The rows in a truth table list all possible sequences of
truth values for n operands, and specify a result for
each sequence
Hence, there are 2n rows in a truth table for n
operands
33. Truth tables for logical connectives
TTFFTFF
FTTFTTF
FFTFFFT
TTTTFTT
~ QPQPQPQPPQP
Or p q p q p q p q p qp q
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1
34. The simplest example
Suppose our KB consists of
P
Q
R
A simple goal is … Q. Literally we are asking is it the
case that Q is true. In this case, the answer is yes!
35. Another simple example
Suppose our KB consists of
P
Q
R
Now suppose the goal is … P Q.
We are literally asking is it the case that P is true and Q
is true. In this case, the fact P Q is not in our KB. But
we can infer it by using the And rule.
36. 36
Example formula and truth-table
(p q) r
p q r q p q (p q) r
T T T F T T
T T F F T F
T F T T T T
T F F T T F
F T T F F T
F T F F F T
F F T T T T
F F F T T F
38. 38
Logical expressions
• All logical expressions can be computed with some combination
of and (), or (), and not () operators
• For example, logical implication can be computed this way:
• Notice that X Y is equivalent to X Y
X Y X X Y X Y
T T F T T
T F F F F
F T T T T
F F T T T
39. 39
Another example
• Exclusive or (xor) is true if exactly one of its operands is true
• Notice that (XY)(XY) is equivalent to X xor Y
X Y X Y X Y X Y (XY)(XY) X xor Y
T T F F F F F F
T F F T F T T T
F T T F T F T T
F F T T F F F F
40. How to built
Propositional logic sentences
• User defines set of propositional symbols, like P and Q
• User defines semantics of each propositional symbol:
– P means “It is hot”, Q means “It is humid”, etc.
• A sentence (well formed formula) is defined as follows:
– A symbol is a sentence
– If S is a sentence, then S is a sentence
– If S is a sentence, then (S) is a sentence
– If S and T are sentences, then (S T), (S T), (S T), and (S ↔ T)
are sentences
41. Examples of PL sentences
• P means “It is hot.”
• Q means “It is humid.”
• R means “It is raining.”
• Q P
“If it is humid, then it is hot”
• (P Q) R
“If it is hot and humid, then it is raining”
42. Example
B means Mihai has money
A means The car is white
F means The car is nice
C means Mihai goes to the mountain
If the car is white or the car is nice and Mihai has
money then Mihai goes to the mountain
(A F) B C
43. Example
s: Phyllis goes out for a walk.
t: The moon is out.
u: It is snowing.
( )t u s : If the moon is out and it is not snowing, then
Phyllis goes out for a walk.
If it is snowing and the moon is not out, then Phyllis
will not go out for a walk. ( )u t s
44. Tautologies
A sentence is a tautology if it is true for any setting of its
propositional symbols
(P OR Q) OR (NOT(P) AND NOT(Q)) is a tautology
45. Is this a tautology?
• (P => Q) OR (Q => P)
• Try it.
46. 46
Inference rules in propositional logic
• (a OR b) ≡ (b OR a) commutatitvity
• (a AND b) ≡ (b AND a) commutatitvity
• ((a AND b) AND c) ≡ (a AND (b AND c)) associativity
• ((a OR b) OR c) ≡ (a OR (b OR c)) associativity
• NOT(NOT(a)) ≡ a double-negation elimination
• (a => b) ≡ (NOT(b) => NOT(a)) contraposition
• (a => b) ≡ (NOT(a) OR b) implication elimination
• NOT(a AND b) ≡ (NOT(a) OR NOT(b)) De Morgan
• NOT(a OR b) ≡ (NOT(a) AND NOT(b)) De Morgan
• (a AND (b OR c)) ≡ ((a AND b) OR (a AND c)) distributitivity
• (a OR (b AND c)) ≡ ((a OR b) AND (a OR c)) distributitivity
47. Question
• Use propositional formulas to represents the
sentence, 'He will come on the 8:15 or the 9:15
train; if he will have time to visit us',
• where
p means 'He will come on the 8:15'
q means 'He will come on the 9:15'
r means 'He will have time to visit us'
49. 49
Limitations of Propositional Logic
p represents ‘My car is red’
q represents ‘This pen is red’
r represents ‘The planet Mars is red’
Cannot work with lower-level objects like ‘my car’,
‘this pen’, ‘the planet Mars’
For most practical applications, we need to be able to
talk about objects and properties within our logical
system
50. 50
Components of First-Order Logic
• Term
– Constant, e.g. Red
– Function of constant, e.g. Color(Block1)
• Atomic Sentence
– Predicate relating objects (no variable)
• Brother (John, Richard)
• Married (Mother(John), Father(John))
• Complex Sentences
– Atomic sentences + logical connectives
• Brother (John, Richard) Brother (John, Father(John))
51. Atomic Sentences
• Atomic sentences state facts using terms and
predicate symbols
– P(x,y) interpreted as “x is P of y”
• Examples:
LargerThan(2,3) is false.
Brother_of(Mary,Pete) is false.
Married(Father(Richard), Mother(John)) could
be true or false
52. Function
Function (evaluates to a constant / variable):
Maps Sentences to Objects
Ali is father of Babar father_of(ali) = baber
father(babar) = ali
Babar is son of Ali son_of(babar) = ali
• Interpretation has to be very clear.
• If you write father(baber), the answer should be ali
• For the above functions the arity is 1 (number of arguments to the
function)
53. Function-II
Functions:
1) shahid likes zahid likes(shahid) = zahid
2) atif likes abid likes(atif) = abid
3)Constants to Variables likes(X) = Y
{X,Y} have two possible BINDINGS
{X, Y} could be {shahid, zahid}
Or
{X,Y} could be {atif, abid}
likes(X) =Y
Substitutions:
For 1 to be true:
{shahid/X, zahid/Y}
For 2 to be true:
{atif/X, abid/Y}
54. Predicate
Predicate
Maps Sentences to Truth Values (True/False)
1) Shahid is student student(shahid)
2) Sana is a girl girl(sana)
3) Father of baber is elder than Hamza
elder(father(babar), hamza)
For 1 and 2 arity is 1 and for 3 the arity is 2
55. Predicate-II
Predicate
1) Shahid is a good student
student(shahid,good) or good_student(shahid) or
is_good(shahid,student)
2) Sana is a friend of Saima, Sana and Saima both are
girls
friend_of(sana,saima)^girl(sana)^girl(saima)
3) Bill helps Fred
helps(bill,fred)
56. FOL Provides
• Variable symbols
– E.g., x, y, foo
• Connectives
– Same as in PL: not (), and (), or (), implies (), if
and only if (biconditional )
• Quantifiers
– Universal x or (Ax)
– Existential x or (Ex)
57. 57
Components of First-Order Logic
• Quantifiers
– Each quantifier defines a variable for the duration of the
following expression, and indicates the truth of the
expression…
• Universal quantifier “for all”
– The expression is true for every possible value of the
variable
• Existential quantifier “there exists”
– The expression is true for at least one value of the variable
58. Quantification of Two Variables
(read left to right)
xyP(x,y) or yxP(x,y)
•True when P(x,y) is true for every pair x,y.
•False if there is a pair x,y for which P(x,y) is false.
xyP(x,y) or yxP(x,y)
True if there is a pair x,y for which P(x,y) is true.
False if P(x,y) is false for every pair x,y.
59. Quantification of Two Variables
xyP(x,y)
•True when for every x there is a y for which P(x,y) is true.
(in this case y can depend on x)
•False if there is an x such that P(x,y) is false for every y.
yxP(x,y)
•True if there is a y for which P(x,y) is true for every x.
(i.e., true for a particular y regardless (or independent) of x)
•False if for every y there is an x for which P(x,y) is false.
Note that order matters here
In particular, if yxP(x,y) is true, then xyP(x,y) is true.
However, if xyP(x,y) is true, it is not necessary that yxP(x,y)
is true.
60. 60
Properties of Quantifiers
• x y is the same as y x
• x y is the same as y x
• x y is not the same as y x
– x y Loves(x, y)
• “There is a person who loves everyone in the world”
– y x Loves(x, y)
• “Everyone in the world is loved by at least one person”
62. 62
Formal Relational Query Languages
Two mathematical Query Languages form the basis for
“real” languages (e.g. SQL), and for implementation:
• Relational Algebra: More operational, very useful for
representing execution plans.
• Relational Calculus: Lets users describe what they want,
rather than how to compute it. (Non-operational,
declarative.)
Understanding Algebra & Calculus is key to
understanding SQL, query processing!
63. Relational Algebra
• Relational Algebra is a procedural
language that can be used to tell
the DBMS ( Data Base Management
System) how to build a new relation from
one or more relations in the database.
64. 64
Relational Database: Definitions
Relational database: a set of relations
Relation: made up of 2 parts:
– Instance : a table, with rows and columns.
#Rows = cardinality, #fields = degree (arity).
– Schema : specifies name of relation, plus name and
type of each column.
• e.g. Students(sid: string, name: string, login: string,
age: integer, gpa: real).
We can think of a relation as a set of rows or
tuples (i.e., all rows are distinct).
65. 65
Example Instance of Students Relation
sid name login age gpa
53666 Jones jones@cs 18 3.4
53688 Smith smith@eecs 18 3.2
53650 Smith smith@math 19 3.8
Cardinality = 3, degree = 5, all rows distinct
Do all columns in a relation instance have to
be distinct?
66. Relation Instance
• The current values (relation instance) of a
relation are specified by a table
• An element t of r is a tuple, represented by
a row in a table
Jones
Smith
Curry
Lindsay
customer-name
Main
North
North
Park
customer-street
Harrison
Rye
Rye
Pittsfield
customer-city
customer
attributes
(or columns)
tuples
(or rows)
67. 67
Relational Algebra
• Basic operations:
– Selection ( ) Selects a subset of rows from relation.
– Projection ( ) Select a subset of columns from relation.
– Cross-product ( ) Allows us to combine two relations.
– Set-difference ( ) Tuples in reln. 1, but not in reln. 2.
– Union ( ) Tuples in reln. 1 and in reln. 2.
• Additional operations:
– Intersection, join, division, renaming: Not essential, but (very!)
useful.
69. 69
Example Instances
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
sid bid day
22 101 10/10/96
58 103 11/12/96
R1
S1
S2
• Consider the following
instances R1, S1, S2.
70. 70
Projection ( )
sname rating
yuppy 9
lubber 8
guppy 5
rusty 10
sname rating
S
,
( )2
age
35.0
55.5
age S( )2
• Deletes attributes that are not in projection list.
• Schema of result contains exactly the fields in the
projection list, with the same names that they had
in the (only) input relation.
• Projection operator has to eliminate duplicates!
(Why??)
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
S2
71. 71
Selection ( )
rating
S
8
2( )
sid sname rating age
28 yuppy 9 35.0
58 rusty 10 35.0
sname rating
yuppy 9
rusty 10
sname rating rating
S
,
( ( ))
8
2
• Selects rows that satisfy selection
condition.
• No duplicates in result! (Why?)
• Schema of result identical to
schema of (only) input relation.
• Result relation can be the input for
another relational algebra
operation! (Operator
composition.)
S2
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
73. 73
Cross-Product ()
• S1 R1 : Each row of S1 is paired with each row of R1.
• Result schema has one field per field of S1 and R1, with field
names `inherited’ if possible.
– Conflict: Both S1 and R1 have a field called sid.
(sid) sname rating age (sid) bid day
22 dustin 7 45.0 22 101 10/10/96
22 dustin 7 45.0 58 103 11/12/96
31 lubber 8 55.5 22 101 10/10/96
31 lubber 8 55.5 58 103 11/12/96
58 rusty 10 35.0 22 101 10/10/96
58 rusty 10 35.0 58 103 11/12/96
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
sid bid day
22 101 10/10/96
58 103 11/12/96
R1
S1
77. Course Code: IS 463
Course Title:
Knowledge Base Systems Application
PART : 2
Prof. Taymoor Mohamed Nazmy
Dept. of computer science, faculty of computer science, Ain Shams uni.
Ex-vice dean of post graduate studies and research Cairo, Egypt
79. Slide 6- 79
Relational Calculus
• Relational calculus is considered to be a
nonprocedural language.
• This differs from relational algebra, where we
must write a sequence of operations to specify
a retrieval request; hence relational algebra can
be considered as a procedural way of stating a
query.
80. Slide 6- 80
Relational Calculus
• A relational calculus expression creates a new
relation, which is specified in terms of variables
that range over rows of the stored database
relations (in tuple calculus) or over columns of
the stored relations (in domain calculus).
• In a calculus expression, there is no order of
operations to specify how to retrieve the query
result—a calculus expression specifies only what
information the result should contain.
– This is the main distinguishing feature between
relational algebra and relational calculus.
81. • In relational calculus user is not concerned with
the procedure to obtain the results, he/she just tell
his/her requirements and the output is available
without knowing the method about its retrieval.
• In relational calculus, a query is expressed as a
formula consisting of a number of variables and
an expression involving these variables. It is up to
the DBMS to transform these nonprocedural
queries into equivalent, efficient, procedural
queries.
84. Tuple Relational Calculus - Example
• To find details of all staff earning more than
£10,000:
{S | Staff(S) S.salary > 10000}
• To find a particular attribute, such as salary,
write:
{S.salary | Staff(S) S.salary > 10000}
84
85. Domain Oriented Relational Calculus
• The domain calculus differs from the tuple calculus in the type of
variables used in formulas. In domain calculus the variables range
over single values from domains of attributes rather than ranging
over tuples. To form a relation of degree 'n' for a query result, we
must have 'n' of these domain variables-one for each attribute.
• An expression of the domain calculus is of the following form:
• {Xl, X2, ... , Xn I COND(XI, X2, .. ·, Xn, Xn+b Xn+2, , Xn+m)}
• In the above expression Xl, X2, ... , Xn, Xn+b Xn+2, , Xn+m
• are domain variables that range over domains of attributes and
COND is a condition or formula of the domain relational calculus.
87. PROLOG
• PROLOG or programming in logic.
• is a programming language that allows the programmer to specify
declarative statements only
– declarative statements (things you are declaring)
– once specified, the programmer then introduces questions to be
answered
• PROLOG uses resolution (backward chaining) and
unification to perform the problem solving automatically
– the intent was to provide a language that could accommodate
logic statements and has largely been used in AI but also to a
lesser extent as a database language or to solve database related
problems
88. Anatomy of a Program
• Prolog programs are made up of facts and rules.
• A fact asserts some property of an object, or relation between
two or more objects.
e.g. parent(jane,alan).
Can be read as “Jane is the parent of Alan.”
• Rules allow us to infer that a property or relationship holds
based on preconditions.
e.g. parent(X,Y) :- mother(X,Y).
= “Person X is the parent of person Y if X is mother of Y.
89. • Both facts and rules are predicate definitions.
• ‘Predicate’is the name given to the word occurring
before the bracket in a fact or rule:
parent(jane,alan).
• By defining a predicate you are specifying which
information needs to be known for the property
denoted by the predicate to be true.
Predicate Definitions
Predicate name
90. Clauses
• Predicate definitions may be fact or rule).
e.g. mother(jane,alan). = Fact
parent(P1,P2):- mother(P1,P2). = Rule
• A clause consists of a head
• and sometimes a body.
– Facts don’t have a body because they are always true.
head body
91. 91
A clause Syntax
A prolog rule is called a clause.
A clause has a head, a neck and a body:
father(X,Y) :- parent(X,Y) , male(X) .
head neck body
the head is a rule's conclusion.
The body is a rule's premise or condition.
note:
read :- as IF
read , as AND
a . marks the end of input
92. Arguments
• A predicate head consists of a predicate name and sometimes
some arguments contained within brackets and separated by
commas.
mother(jane,alan).
• A body can be made up of any number of subgoals (calls to
other predicates) and terms.
• Arguments also consist of terms, which can be:
– Constants e.g. jane,
– Variables e.g. Person1, or
– Compound terms
Predicate name
Arguments
93. Complete Syntax of Terms
Term
Constant VariableCompound Term
Atom Number
alpha17
gross_pay
john_smith
dyspepsia
+
=/=
’12Q&A’
0
1
57
1.618
2.04e-27
-13.6
likes(john, mary)
book(dickens, Z, cricket)
f(x)
[1, 3, g(a), 7, 9]
-(+(15, 17), t)
15 + 17 - t
X
Gross_pay
Diagnosis
_257
_
Names an individual Stands for an individual
unable to be named when
program is written
Names an individual
that has parts
94. Structure of Programs
• Programs consist of procedures.
• Procedures consist of clauses.
• Each clause is a fact or a rule.
• Programs are executed by posing queries.
An example…
97. Clauses: Facts and Rules
Head :- Body. This is a rule.
Head. This is a fact.
‘if’
‘provided that’
‘turnstile’
Full stop at the end.
98. Body of a (rule) clause contains goals.
likes(mary, X) :- human(X), honest(X).
Head Body
Goals
Exercise: Identify all the parts of Prolog
text you have seen so far.
100. • Questions based on facts
• Answered by matching
Two facts match if their predicates are same and the
arguments each are same.
• If matched, prolog answers yes, else no.
• No does not mean falsity.
Questions
148. 148
Introduction
• Real knowledge representation and reasoning systems
come in several major varieties.
• These differ in their intended use, expressivity, features,…
• Some major families are
– Logic programming languages
– Theorem provers
– Rule-based or production systems
– Semantic networks
– Frame-based representation languages
– Databases (deductive, relational, object-oriented, etc.)
– Constraint reasoning systems
– Description logics
– Bayesian networks
– Evidential reasoning
149. Knowledge Representation Schemas
Real knowledge representation and reasoning systems come in several major
varieties. They all based on FOL but departing from it in different ways.
Logic based representation – first order predicate
logic, Prolog
Procedural representation – rules, production system
Network representation – semantic networks,
conceptual graphs
Structural representation – scripts, frames, objects
150. Production Systems
Widely used in expert systems (Production Systems)
System has:
Rule Base
Working Memory
Inference Mechanism (Interpreter)
Explanation Facility
151. Rule Base
Stores permanent (problem-independent) knowledge.
This knowledge is stored as production rules/condition-action
rules.
E.g.
IF condition-1
AND condition-2
AND …
AND condition-m
THEN action-1
AND action-2
AND …
AND action-n
152. The IF-part is also called the left-hand side or
antecedent.
The THEN-part is also called the right-hand side or
consequent.
The actions in the consequent usually involve
changes to working memory.
e.g. adding, deleting or modifying working memory
elements.
153. 153
What are Rules?
• Rules represent knowledge using IF-THEN format
• The IF portion of a rule is a condition, (also called a
premise or an antecedent), which tests the truth value
of set of facts.
• If these are found true, the THEN portion of a rule
(also called the action, the conclusion or the
consequent) is inferred as a new set of facts.
154. 154
Production Systems
and the Rules
• The rule based systems are also called production systems.
• Simon and Newel developed the production system to model
human problem solving.
• A production system consists of:
– An area of memory that is used to track the current state of the
universe under consideration (working memory - database).
– A set of production rules :condition - action pairs (knowledge base).
– An interpreter (inference engine) recognizes and executes a
production whose conditions has been satisfied. This control may be
either data driven or goal driven.
155. 155
Rule-based Inference
• Using search techniques and pattern matching, rule
based systems automate reasoning methods and
provide the logical progression from initial data to the
desired conclusion.
• Thus the process of problem solving in knowledge
based systems is to create a series of inferences that
create a “path” between the problem definition and
the solution
• This series of inferences is progressive in nature and
is called an inference chain.
156. 156
Example
• Suppose we are building a knowledge based
system for forecasting the weather over the
next 12 – 24 hours in Florida during the
summer.
RULE 1: IF the ambient temperature is above 900
F
THEN the weather is hot.
RULE 2: IF the relative humidity is greater than 65%
THEN the atmosphere is humid
RULE 3: IF the weather is hot and the atmosphere is humid
THEN thunderstorms are likely to develop.
157. 157
Knowledge Representation scheme:
Rules
• Rules
• These are formalization often used to specify recommendations, give
directives or strategy.
• Format: IF <premises> THEN <conclusion>.
• Related ideas: rules and fact base; conflict set - source of rules;
conflict resolution- deciding on rules to apply.
– Advantages: easy to use; explanations are possible; capture
heuristics; can handle uncertainties to some extent.
– Disadvantages: cannot cope with complex associated knowledge;
they can grow to unmanageable size.
158. 158
Knowledge Representation scheme:
Rules
Consists of:
• a rule set for representing the expert knowledge
• a “database management system” for the case-specific facts
• a rule interpreter for problem solving
Example
IF: (1) stain of organism is Gram neg. AND
(2) morphology of organism is rod AND
(3) aerobicity of organism is aerobic
THEN: strong evidence (0.8) that organism is Enterobact
Properties of rule-based systems:
modularity of rule, very expressive, easy hadling of certainty factors
(probabilistic, possibilitic reasoning)
Lack of precise semantics of rules. Not always efficient
159. 159
Rules - A simple example
• Assume: Knowledge base consisting of facts and rules, a rule
interpreter to match the rule conditions against facts and means for
executing the rules.
Rules:
R1: IF: Raining,Outside(x),Has_Umbrella(x)
THEN: Uses_Umbrella(x)
R2: IF: Raining,Outside(x)
NOT Has_Umbrella(x)
THEN: Wet(x)
R3: IF: Wet(x)
THEN: Gets_Cold(x)
R4: IF: Sunny,Outside(x)
THEN: Gets_Sun_Tan(x)
Initial facts: Raining, Outside(John)
160. 160
Rules - A simple example
Correct:
• Only one rule, R2 matches the facts with [xJohn], hence add
Wet(John)
• Facts after first cycle:
Raining, Outside(John), Wet(John)
• Now R3 matches facts, hence add
Gets_Cold(John)
• Facts after second cycle:
Raining, Outside(John), Wet(John), Gets_Cold(John)
Process of deriving new facts from given facts, is called INFERENCE
Incorrect:
Gets_Sun_Tan(John)
161. Inference Methods 1
deduction
◆ conclusions must follow from their premises; prototype of logical reasoning
induction
◆ inference from specific cases (examples) to the general
abduction
◆ reasoning from a true conclusion to premises that may have caused the conclusion
resolution
◆ find two clauses with complementary literals, and combine them
generate and test
◆ a tentative solution is generated and tested for validity
◆ often used for efficiency (trial and error)
1
6
1
162. Inference Methods 2
default reasoning
◆ general or common knowledge is assumed in the absence of specific
knowledge
analogy
◆ a conclusion is drawn based on similarities to another situation
heuristics
◆ rules of thumb based on experience
intuition
◆ typically human reasoning method
nonmonotonic reasoning
◆ new evidence may invalidate previous knowledge
auto epistemic
◆ reasoning about your own knowledge
1
6
2