Knowledge Representation: The Basics
description
Transcript of Knowledge Representation: The Basics
![Page 1: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/1.jpg)
Knowledge Representation:The Basics
![Page 2: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/2.jpg)
UserInterface
Knowledge Base
InferenceEngine
Basic Knowledge-based system architecture
Knowledge-based System
![Page 3: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/3.jpg)
UserInterface
Knowledge Base
InferenceEngine
• Knowledge is explicitly represented in a knowledge base
• System has knowledge and uses this knowledge to achieve its goals
• Causal Link between knowledge and system’s behaviour
![Page 4: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/4.jpg)
Knowledge Representation Hypothesis
Any mechanically embodied intelligent process will be comprised of structural ingredients that
we as external observers naturally take to represent a propositional account of the knowledge that the overall process exhibits, and
independent of such external semantic attribution, play a formal but causal and essential role in engendering the behaviour that manifests that knowledge
Brian Smith, 1982
![Page 5: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/5.jpg)
Knowledge Representation Language
• Formalism to represent “propositional account of knowledge”
• Ingredients– Set of symbols
• The alphabet for constructing legal expressions
– Syntax• The rules that specify the set of legal expressions
– Semantics• An approach to assign meaning to symbols in the language
![Page 6: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/6.jpg)
An example
(works-with Enrico-Motta John-Domingue)
( <relation-name> <term1> <term2> )
![Page 7: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/7.jpg)
Another example
(setofall (?x) (or (works-with Enrico-Motta ?x) (works-with John-Domingue ?x)))
( setofall (var+) <log-expression>)
![Page 8: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/8.jpg)
Performing Inferences
(involved-in-project John-Domingue AKT)
(involved-in-project Enrico-Motta AKT)
(=> (and (involved-in-project ?x ?p) (involved-in-project ?y ?p) (not (= ?x ?y))) (works-with ?x ?y))
------------------
(works-with Enrico-Motta John-Domingue)
![Page 9: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/9.jpg)
Properties of an Inference System
• Soundness– Inferences have to be truth-preserving
• Computationally Tractable– Proofs should be carried out in polynomial time
• Completeness– Everything which logically follows from a knowledge base
should be actually derivable
![Page 10: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/10.jpg)
Fundamental Trade-offCompetence
Efficiency
Prolog
LOOM
1st order logic TP
C++
![Page 11: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/11.jpg)
The OCML Language
• OCML= Operational Conceptual Modelling Language
• Operational = Supported by an Interpreter
• Conceptual Modelling = Emphasis on modelling functionality, rather than symbol-level efficiency
• Originally defined as a environment to operationalise ontologies specified in Ontolingua
![Page 12: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/12.jpg)
OCML in the Trade-offCompetence
Efficiency
Prolog
LOOM, OCML
1st order logic TP
C++
![Page 13: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/13.jpg)
Modelling Primitives
• Relations
• Functions
• Classes
• Class Instances
• Relation Instances
• Rules
• Procedures
• Axioms
![Page 14: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/14.jpg)
Functional View of a Knowledge Base
Knowledge Base
Tell
Ask
![Page 15: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/15.jpg)
Asserting Relation Instances
(tell (involved-in-project enrico-motta akt))
(tell (involved-in-project john-domingue akt))
(def-relation-instances
(involved-in-project enrico-motta akt)
(involved-in-project john-domingue akt))
![Page 16: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/16.jpg)
Assertion-driven Inferences
(def-rule declare-cool-person
(involved-in-project ?x akt)
then
(exec (output "Cool Person ~s" ?x)))
![Page 17: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/17.jpg)
Constraint Checking as Assertion-driven Inference
(def-rule Legal-involved-in-project
(involved-in-project ?x ?y)
then
(or (not (person ?x))
(not (project ?y)))
(exec
(output
"~%Bad assertion (involved-in-project ~s ~s)"
?x ?y)))
![Page 18: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/18.jpg)
Expressing Constraints in OCML
(def-relation involved-in-project (?x ?project)
"This relation associates people to projects"
:constraint (and (person ?x)
(project ?project))))
Logically:
(=> (involved-in-project ?x ?p) (and (person ?x) (project ?p)))
![Page 19: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/19.jpg)
Querying a KB
? (ask (involved-in-project ?x ?y))
Solution: ((INVOLVED-IN-PROJECT JOHN-DOMINGUE AKT))
Solution: ((INVOLVED-IN-PROJECT ENRICO-MOTTA AKT))
![Page 20: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/20.jpg)
Goal-driven Inference
(def-relation involved-in-project (?x ?project)
"This relation associates people to projects"
:sufficient (has-project-leader ?project ?x))
Logically:
(=> (has-project-leader ?p ?x) (involved-in-project ?x ?p))
![Page 21: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/21.jpg)
Backward Chaining Rules
(def-rule infer-involved-in-project
((involved-in-project ?x ?y)
if
(has-project-leader ?project ?x)))
![Page 22: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/22.jpg)
If and only if statements
(def-relation involved-in-project (?x ?project)
"This relation associates people to projects"
:iff-def (or (has-project-member ?project ?x)
(has-project-leader ?project ?X)))
Logically:
(<=> (or (has-project-member ?p ?x) (has-project-leader ?p ?x)) (involved-in-project ?x ?p))
![Page 23: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/23.jpg)
Proofs by Procedural Attachments
• :Prove-by– Use to define an efficient mechanism to prove something
• :Lisp-fun– Use when you want to prove something by resorting to Lisp
code
![Page 24: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/24.jpg)
(def-relation enumerated-set (?x) "A set represented as (:set-of el1 el_2...el_n), where no el_i is repeated"
:iff-def (and (= ?x (:set . ?elements)) (not (exists ?el (and (member ?el ?elements) (member ?el (remove1 ?el ?elements))))))
:prove-by (and (variable-bound ?x) (= ?x (:set . ?elements)) (not (exists ?el (and (member ?el ?elements) (member ?el (remove1 ?el ?elements)))))) :no-proofs-by (:iff-def))
![Page 25: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/25.jpg)
Example of procedural attachment
(def-relation POSITIVE-REAL-NUMBER (?x)
:iff-def (and (real-number ?x)
(> ?x 0))
:lisp-fun #'(lambda (x env)
(let ((y (instantiate x env)))
(if (and (realp y)
(> y 0)) (list env)
:fail))))
![Page 26: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/26.jpg)
Classes
• Define collections of entities– Persons, Projects, Tigers, etc…
• Semantics is the same as unary relations
• Needed for– Modelling reasons
• Mechanisms to structure a domain KB and for highlighting main categories of target domain
– Operational reasons• Class taxonomies allow inheritance of properties
– HCI Reasons• Easier to design and implement effective browsers/editors for
hierarchical structures than for generic graphs
![Page 27: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/27.jpg)
THING
TECHNOLOGY
COMPUTING-TECHNOLOGY
GENERALISED-MEANS-OF-TRANSPORT
INFORMATION-TRANSFER-MEDIUM
TRANSPORTATION-DEVICE
INDIVIDUAL
STRING
QUANTITY
TEMPORAL-THING
ACTIVITY
EVENT
GENERIC-AGENT
TANGIBLE-THING
INTANGIBLE-THING ……………………
INTANGIBLE-THING
SOFTWARE-STATUS
METHOD
GENERIC-AREA-OF-INTEREST
BUSINESS-AREA
RESEARCH-AREA
AWARD
DEGREE
FINANCIAL-AWARD
EMPLOYMENT-CONTRACT-TYPE
WORK-STATUS
GENDER
APPELLATION
ORGANIZATION-SIZE
ABSTRACT-INFORMATION ……………………………….
![Page 28: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/28.jpg)
Classes in OCML
(def-class ORGANIZATION (legal-agent)
"An organization is a type of legal agent"
((affiliated-people :type affiliated-person)
(organization-part-of :type organization)
(has-sub-unit :type organization-unit)
(headed-by :type affiliated-person)
(has-size :cardinality 1 :type organization-size)
))
![Page 29: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/29.jpg)
Semantics of Subclass-of
(def-class organization (legal-agent))
(def-relation organization (?x))
(def-relation legal-agent (?x))
(=> (organization ?x) (legal-agent ?x))
![Page 30: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/30.jpg)
Semantics of type specifications
(def-class ORGANIZATION (legal-agent)
"An organization is a type of legal agent"
((affiliated-people :type affiliated-person)))
(def-relation affiliated-people (?x ?y))
(=> (and (organization ?x)
(affiliated-people ?x ?y))
(affiliated-person ?y))
![Page 31: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/31.jpg)
Semantics of cardinality specifications
(def-class ORGANIZATION (legal-agent)
((has-size :cardinality 1 :type organization-size)))
(def-relation has-size (?x ?y))
(=> (organization ?x)
(and (exists (?y)
(has-size ?x ?y))
(not (exists (?y1 ?y2)
(and (has-size ?x ?y1)
(has-size ?x ?y2)
(not (= ?y1 ?y2)))))))
![Page 32: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/32.jpg)
Semantics of slot values (inheritance)
(def-class SENDING-AN-EMAIL (information-transfer-event)
((sender-of-information :type generic-agent)
(information-object-being-transferred :type email-message)
(information-transfer-medium-used :value email-medium )))
(=> (sending-an-email ?x)
(information-transfer-medium-used ?x email-medium))
![Page 33: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/33.jpg)
Using relation options in classes
(def-class SMALL-OR-MEDIUM-SIZED-ORGANIZATION (organization) ?x
"SME are important, so we define a class to represent them explicitly.In some case we might not know or we do not want to bother specifying exactly whether something is a small-organization or a medium-organization. Hence, we can just say 'x is a SME' without going into further detail."
:iff-def (and (organization ?x)
(has-size ?x ?size)
(member ?size '(micro-size small-size medium-size)))
:avoid-infinite-loop t)
![Page 34: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/34.jpg)
Specifying Functions
(def-function rest (?l)
"Returns the elements of a list but the first one. If the list is empty, then NIL is returned"
:constraint (list ?l)
:body (if (= ?l (?a . ?b))
?b
nil))
![Page 35: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/35.jpg)
Function Specification Options
• :def. – Defines the function
• :constraint.
– Specifies a constraint on the domain of the function
• :body.
– Specifies how to compute the function
• :lisp-fun.
– Specifies a lisp function which is used to compute the function
![Page 36: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/36.jpg)
Example of :def spec
(def-function ALL-SUBCLASSES (?class) -> ?subs
"returns all subclasses of a class"
:constraint (class ?class)
:def (= ?subs (setofall ?sub (subclass-of ?sub ?class)))
:lisp-fun #'(lambda (class)
(let ((class-s (get-ocml-class class)))
(if class-s
(mapcar
#'name
(current-subclasses class-s))))))
![Page 37: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/37.jpg)
Semantics of Functions
(def-function find-somebody-coworkers (?x)
:body (setofall (?y) (works-with ?x ?y))
{ }
{ }
![Page 38: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/38.jpg)
Meta-level Mechanisms
Holds (?rel ?arg1…..?argn)
iff
(?rel ?arg1…..?argn)
Holds. Meta-relation which makes it possible to test whether a relation is true for certain arguments
![Page 39: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/39.jpg)
Function
Entities
Criterion
Filter
‘Right Entities’
Filtering items according to some criterion
![Page 40: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/40.jpg)
Definition of Filter
(def-function filter (?l ?rel) -> ?sub-l
"Returns all the elements in ?l which satisfy ?rel"
:body (if (null ?l)
?l
(if (holds ?rel (first ?l))
(cons (first ?l)
(filter (rest ?l) ?rel))
(filter (rest ?l) ?rel))))
![Page 41: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/41.jpg)
Summary
• The essence of knowledge-based systems– Explicit representation of knowledge– Casual link between knowledge and behaviour
• The importance of semantics– KB = Statements and inferences about a universe of
discourse
• Specification vs efficient implementation
• Variety of representational constructs
• Need for meta-level mechanisms– The world is not uni-dimensional!
![Page 42: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/42.jpg)
Modelling Task
John Domingue, a senior research fellow in KMi, has a cat called Bugsy. John and his cat live at 100, Infinite Loop in Disneyland. A cat is a specific species of animal. John has been involved in the PatMan project. He formalised in OCML a medical guideline targeted at nurses and non-professional care givers.
![Page 43: Knowledge Representation: The Basics](https://reader035.fdocuments.in/reader035/viewer/2022062806/56814fb9550346895dbd7387/html5/thumbnails/43.jpg)