430 likes | 607 Views
Knowledge Representation: The Basics. Basic Knowledge-based system architecture. Inference Engine. User Interface. Knowledge Base. Knowledge-based System. User Interface. Inference Engine. Knowledge Base. Knowledge is explicitly represented in a knowledge base
E N D
Basic Knowledge-based system architecture Inference Engine User Interface Knowledge Base Knowledge-based System
User Interface Inference Engine Knowledge Base • 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
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
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
An example ( <relation-name> <term1> <term2> ) (works-with Enrico-Motta John-Domingue)
( setofall (var+) <log-expression>) Another example (setofall (?x) (or (works-with Enrico-Motta ?x) (works-with John-Domingue ?x)))
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)
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
1st order logic TP LOOM Prolog C++ Fundamental Trade-off Competence Efficiency
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
1st order logic TP LOOM, OCML Prolog C++ OCML in the Trade-off Competence Efficiency
Modelling Primitives • Relations • Functions • Classes • Class Instances • Relation Instances • Rules • Procedures • Axioms
Functional View of a Knowledge Base Knowledge Base Tell Ask
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))
Assertion-driven Inferences (def-rule declare-cool-person (involved-in-project ?x akt) then (exec (output "Cool Person ~s" ?x)))
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)))
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)))
Querying a KB ? (ask (involved-in-project ?x ?y)) Solution: ((INVOLVED-IN-PROJECT JOHN-DOMINGUE AKT)) Solution: ((INVOLVED-IN-PROJECT ENRICO-MOTTA AKT))
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))
Backward Chaining Rules (def-rule infer-involved-in-project ((involved-in-project ?x ?y) if (has-project-leader ?project ?x)))
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))
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
(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))
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))))
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
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 ………………………………. 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 ……………………
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) ))
Semantics of Subclass-of (def-class organization (legal-agent)) (def-relation organization (?x)) (def-relation legal-agent (?x)) (=> (organization ?x) (legal-agent ?x))
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))
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)))))))
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))
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)
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))
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
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))))))
} { { } Semantics of Functions (def-function find-somebody-coworkers (?x) :body (setofall (?y) (works-with ?x ?y))
Meta-level Mechanisms Holds. Meta-relation which makes it possible to test whether a relation is true for certain arguments Holds (?rel ?arg1…..?argn) iff (?rel ?arg1…..?argn)
Entities ‘Right Entities’ Filter Criterion Filtering items according to some criterion Function
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))))
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!
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.