Semantic Web
Una sintesi da Semantic Web PrimerGrigoris Antoniou e Frank van Harmelen
Chapter 1 A Semantic Web Primer2
The Semantic Web Approach
● Represent Web content in a form that is more easily machine-processable.
● Use intelligent techniques to take advantage of these representations.
● The Semantic Web will gradually evolve out of the existing Web, it is not a competition to the current WWW
Chapter 1 A Semantic Web Primer3
Semantic Web Technologies
● Explicit Metadata● Ontologies● Logic and Inference● Agents
Chapter 1 A Semantic Web Primer4
On HTML
● Web content is currently formatted for human readers rather than programs
● HTML is the predominant language in which Web pages are written (directly or using tools)
● Vocabulary describes presentation
Chapter 1 A Semantic Web Primer5
An HTML Example
<h1>Agilitas Physiotherapy Centre</h1>Welcome to the home page of the Agilitas Physiotherapy Centre. Do you feel pain? Have you had an injury? Let our staff Lisa Davenport,Kelly Townsend (our lovely secretary) and Steve Matthews take careof your body and soul.<h2>Consultation hours</h2>Mon 11am - 7pm<br>Tue 11am - 7pm<br>Wed 3pm - 7pm<br>Thu 11am - 7pm<br>Fri 11am - 3pm<p>But note that we do not offer consultation during the weeks of the <a href=". . .">State Of Origin</a> games.
Chapter 1 A Semantic Web Primer6
Problems with HTML
● Humans have no problem with this● Machines (software agents) do:
– How distinguish therapists from the secretary, – How determine exact consultation hours – They would have to follow the link to the State
Of Origin games to find when they take place.
Chapter 1 A Semantic Web Primer7
A Better Representation
<company><treatmentOffered>Physiotherapy</treatmentOffered><companyName>Agilitas Physiotherapy Centre</companyName><staff>
<therapist>Lisa Davenport</therapist><therapist>Steve Matthews</therapist><secretary>Kelly Townsend</secretary>
</staff></company>
Chapter 1 A Semantic Web Primer8
Explicit Metadata
● This representation is far more easily processable by machines
● Metadata: data about data – Metadata capture part of the meaning of data
● Semantic Web does not rely on text-based manipulation, but rather on machine-processable metadata
Chapter 1 A Semantic Web Primer9
Ontologies
The term ontology originates from philosophy ● The study of the nature of existence
Different meaning from computer science● An ontology is an explicit and formal
specification of a conceptualization
Chapter 1 A Semantic Web Primer10
The Role of Ontologies on the Web
● Ontologies provide a shared understanding of a domain: semantic interoperability– overcome differences in terminology – mappings between ontologies
● Ontologies are useful for the organization and navigation of Web sites
Chapter 1 A Semantic Web Primer11
The Role of Ontologies in Web Search
● Ontologies are useful for improving the accuracy of Web searches – search engines can look for pages that refer to a precise concept
in an ontology ● Web searches can exploit generalization/ specialization
information – If a query fails to find any relevant documents, the search engine
may suggest to the user a more general query.– If too many answers are retrieved, the search engine may
suggest to the user some specializations.
Chapter 1 A Semantic Web Primer12
The Semantic Web Layer Tower
Alternative Semantic Web Stack
Chapter 1 A Semantic Web Primer13
Chapter 3 A Semantic Web Primer14
Drawbacks of XML
● XML is a universal metalanguage for defining markup● It provides a uniform framework for interchange of data
and metadata between applications● However, XML does not provide any means of talking
about the semantics (meaning) of data● E.g., there is no intended meaning associated with the
nesting of tags– It is up to each application to interpret the nesting.
Chapter 3 A Semantic Web Primer15
Nesting of Tags in XML
David Billington is a lecturer of Discrete Maths
<course name="Discrete Maths">
<lecturer>David Billington</lecturer>
</course>
<lecturer name="David Billington">
<teaches>Discrete Maths</teaches>
</lecturer>
Opposite nesting, same information!
Chapter 3 A Semantic Web Primer16
Basic Ideas of RDF
● Basic building block: object-attribute-value triple– It is called a statement– Sentence about Billington is such a statement
● RDF has been given a syntax in XML– This syntax inherits the benefits of XML– Other syntactic representations of RDF possible
Chapter 3 A Semantic Web Primer17
Statements
● Statements assert the properties of resources
● A statement is an object-attribute-value triple– It consists of a resource, a property, and a value
● Values can be resources or literals – Literals are atomic values (strings)
Chapter 3 A Semantic Web Primer18
Three Views of a Statement
● A triple● A piece of a graph● A piece of XML code
Thus an RDF document can be viewed as:● A set of triples● A graph (semantic net)● An XML document
Chapter 3 A Semantic Web Primer19
Statements as Triples
(http://www.cit.gu.edu.au/~db,
http://www.mydomain.org/site-owner,
#David Billington)
● The triple (x,P,y) can be considered as a logical formula P(x,y)– Binary predicate P relates object x to object y – RDF offers only binary predicates (properties)
Chapter 3 A Semantic Web Primer20
XML Vocabularies
● A directed graph with labeled nodes and arcs– from the resource (the subject of the statement) – to the value (the object of the statement)
● Known in AI as a semantic net● The value of a statement may be a resource
– Ιt may be linked to other resources
Chapter 3 A Semantic Web Primer21
A Set of Triples as a Semantic Net
Chapter 3 A Semantic Web Primer22
Statements in XML (2)
<rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:mydomain="http://www.mydomain.org/my-rdf-ns">
<rdf:Description rdf:about="http://www.cit.gu.edu.au/~db"> <mydomain:site-owner
rdf:resource=“#David Billington“/> </rdf:Description>
</rdf:RDF>
Chapter 3 A Semantic Web Primer23
Basic Ideas of RDF Schema
RDF is a universal language that lets users describe resources in their own vocabularies
– RDF does not assume, nor does it define semantics of any particular application domain
The user can do so in RDF Schema using:– Classes and Properties– Class Hierarchies and Inheritance– Property Hierarchies
Chapter 3 A Semantic Web Primer24
RDF Layer vs RDF Schema Layer (2)
Chapter 3 A Semantic Web Primer25
Summary
● RDF provides a foundation for representing and processing metadata
● RDF has a graph-based data model ● RDF has an XML-based syntax to support syntactic
interoperability – XML and RDF complement each other because RDF supports
semantic interoperability ● RDF has a decentralized philosophy and allows
incremental building of knowledge, and its sharing and reuse
Chapter 3 A Semantic Web Primer26
Summary (2)
● RDF is domain-independent - RDF Schema provides a mechanism for describing specific domains
● RDF Schema is a primitive ontology language– It offers certain modelling primitives with fixed meaning
● Key concepts of RDF Schema are class, subclass relations, property, subproperty relations, and domain and range restrictions
● There exist query languages for RDF and RDFS, including SPARQL
Chapter 3 A Semantic Web Primer27
Points for Discussion in Subsequent Chapters
● RDF Schema is quite primitive as a modelling language for the Web
● Many desirable modelling primitives are missing
● Therefore we need an ontology layer on top of RDF and RDF Schema
Chapter 4 A Semantic Web Primer28
Requirements for Ontology Languages
● Ontology languages allow users to write explicit, formal conceptualizations of domain models
● The main requirements are:– a well-defined syntax – efficient reasoning support – a formal semantics – sufficient expressive power – convenience of expression
Chapter 4 A Semantic Web Primer29
Tradeoff between Expressive Power and Efficient Reasoning Support
● The richer the language is, the more inefficient the reasoning support becomes
● Sometimes it crosses the border of noncomputability
● We need a compromise:– A language supported by reasonably efficient
reasoners – A language that can express large classes of
ontologies and knowledge.
Chapter 4 A Semantic Web Primer30
Three Species of OWL
● W3C’sWeb Ontology Working Group defined OWL as three different sublanguages:– OWL Full– OWL DL– OWL Lite
● Each sublanguage geared toward fulfilling different aspects of requirements
Chapter 4 A Semantic Web Primer31
OWL Full
● It uses all the OWL languages primitives● It allows the combination of these primitives in
arbitrary ways with RDF and RDF Schema● OWL Full is fully upward-compatible with RDF,
both syntactically and semantically● OWL Full is so powerful that it is undecidable
– No complete (or efficient) reasoning support
Chapter 4 A Semantic Web Primer32
OWL DL
● OWL DL (Description Logic) is a sublanguage of OWL Full that restricts application of the constructors from OWL and RDF– Application of OWL’s constructors’ to each other is disallowed– Therefore it corresponds to a well studied description logic
● OWL DL permits efficient reasoning support● But we lose full compatibility with RDF:
– Not every RDF document is a legal OWL DL document. – Every legal OWL DL document is a legal RDF document.
Chapter 4 A Semantic Web Primer33
OWL Lite
● An even further restriction limits OWL DL to a subset of the language constructors– E.g., OWL Lite excludes enumerated classes,
disjointness statements, and arbitrary cardinality.● The advantage of this is a language that is
easier to– grasp, for users– implement, for tool builders
● The disadvantage is restricted expressivity
Chapter 4 A Semantic Web Primer34
Upward Compatibility between OWL Species
● Every legal OWL Lite ontology is a legal OWL DL ontology
● Every legal OWL DL ontology is a legal OWL Full ontology
● Every valid OWL Lite conclusion is a valid OWL DL conclusion
● Every valid OWL DL conclusion is a valid OWL Full conclusion
Chapter 4 A Semantic Web Primer35
OWL Compatibility with RDF Schema
● All varieties of OWL use RDF for their syntax
● Instances are declared as in RDF, using RDF descriptions
● and typing informationOWL constructors are specialisations of theirRDF counterparts
Chapter 4 A Semantic Web Primer36
OWL Compatibility with RDF Schema (2)
● Semantic Web design aims at downward compatibility with corresponding reuse of software across the various layers
● The advantage of full downward compatibility for OWL is only achieved for OWL Full, at the cost of computational intractability
Hybrid KR systems
OCMLE. Motta
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
OCML components
● Ask-Tell Interface● Concept Language (DL)● Rules:
– Backward Chaining
– Forward Chaining
● Procedural Attachments● Constraints● Functions
Knowledge Base & Relations
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))
Querying a KB
? (ask (involved-in-project ?x ?y))
Solution: ((INVOLVED-IN-PROJECT JOHN-DOMINGUE AKT))
Solution: ((INVOLVED-IN-PROJECT ENRICO-MOTTA AKT))
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
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))
Case study: AEDSS Automatic EDSS Expert System
● AEDSS application ontology: an ontology which models the basic neurological concepts of the EDSS disability status scale.
● USE OF OCML:– Classes
– Instances
– Backward Rules
– Forward Rules
Functional Systemclass
Backward Rules in AEDSS● (def-rule ask_aedss
((ask_aedss ?rule)
if
(askorsupp ?rule ?q yes)
(questioninfer ?q)
(exec (tell (asked ?q yes)))
(exec (tell (answer ?q yes))))
((ask_aedss ?rule)
if
(askorsupp ?rule ?q no)
(exec (tell (asked ?q yes)))
(exec (tell (supposed ?q yes)))))
● (def-rule questioninfer
((questioninfer ?q)
if
(direct-instance-of ?q ?c)
(= ?lq (setofall ?y (and (questions ?y)
(direct-instance-of ?y ?c)
(not (= ?y ?q))
(asked ?y no))))
(= ?lq nil)))
The first rule manages AEDSS questions. Given a rule it finds the next question to check and if this question should be asked or assumed true. When the goal (askorsupp ?rule ?q yes) succeeds a question ?q is selected as the next question to ask the user. However, before asking it, AEDSS checks if the question ?q can be inferred from the ontology. This behavior is realized by rule questioninfer.
?
OCML Forward Rules in AEDSS
● (def-rule rmk01(FS_of_value pi ?vpi)
(FS_of_value cll ?vcll)
then
(>= ?vpi 5)
(>= ?vcll 3)
(set_medknow walk_20_aid))
This rule fires if the first two conditions are true, then thebody of the rule is evaluated. The body is composed of further
conditions and actions, they are evaluated in order, and whenevera condition or an action fails, the evaluation terminates.
Other OCML features
● Logical attachments● Procedural attachments● Constraints
Proofs by Logic and 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))))
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)))
ALSO: 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 (?rel ?arg1…..?argn)
iff
(?rel ?arg1…..?argn)
Holds. Meta-relation which makes it possible to test whether a relation is true for certain arguments
Function
Entities
Criterion
Filter
‘Right Entities’
Filtering items according to some criterion
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))))
Implementation
● Backward Chaining: Prolog like interpreter
● Forward Chaining: rete match algorithm– Working memory (facts in the KB)
– Forward rules
repeat until (condition or no rule fires):– Match (rules are translated into a network)
– Conflict Resolution (select one rule)
– Rule Execution
Rete Match data
● We assume the WM elements are triples:(involved-in-project enrico-motta akt)
● OCML: Forward rules have the structure:● (def-rule rmk01
CONDITIONS (WM elements)
then
TESTS
ACTIONS)
Rete Match basic idea
● Given a WM and a set of forward rules the conflict set is the set of rules that are satisfied.
● The conflict set changes whenever a rule fires and WM element are added or removed from the WM.
● However, changes are limited to a few rules.● The match algorithm deal only with the conditions.● It builds a network that determines in an efficient
way the rules that are satisfied.
Rete Match
Rete match description
● A rule is said to match the WM if all its conditions match facts in the WM.
● Rete uses a dataflow network to represent the conditions of productions.
● The network has two parts:– Alpha part: performs the constants tests on WM elements. The output is
stored in alpha memories (AM). An AM for a condition stores all the WM element that pass that condition.
– Beta part: contains join nodes and beta memories.● Join nodes perform the tests for consistency of variable bindings between
conditions.● Beta memories store partial instantiation of productions (a combination of WM
elements that some but not all the conditions of a production.