SWI-Prolog Semantic Web Library 3.0
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Semantic Web Library 3.0
        • Introduction
        • Scalability
        • Two RDF APIs
        • Plugin modules for rdf_db
        • library(semweb/turtle): Turtle: Terse RDF Triple Language
        • library(semweb/rdf_ntriples): Process files in the RDF N-Triples format
        • library(semweb/rdfa): Extract RDF from an HTML or XML DOM
        • library(semweb/rdfs): RDFS related queries
          • Hierarchy and class-individual relations
          • Collections and Containers
        • Managing RDF input files
        • library(semweb/sparql_client): SPARQL client library
        • library(semweb/rdf_compare): Compare RDF graphs
        • library(semweb/rdf_portray): Portray RDF resources
        • Related packages
        • Version 3 release notes

8 library(semweb/rdfs): RDFS related queries

The library(semweb/rdfs) library adds interpretation of the triple store in terms of concepts from RDF-Schema (RDFS). There are two ways to provide support for more high level languages in RDF. One is to view such languages as a set of entailment rules. In this model the rdfs library would provide a predicate rdfs/3 providing the same functionality as rdf/3 on union of the raw graph and triples that can be derived by applying the RDFS entailment rules.

Alternatively, RDFS provides a view on the RDF store in terms of individuals, classes, properties, etc., and we can provide predicates that query the database with this view in mind. This is the approach taken in the library(semweb/rdfs.p)l library, providing calls like rdfs_individual_of(?Resource, ?Class).5The SeRQL language is based on querying the deductive closure of the triple set. The SWI-Prolog SeRQL library provides entailment modules that take the approach outlined above.

8.1 Hierarchy and class-individual relations

The predicates in this section explore the rdfs:subPropertyOf, rdfs:subClassOf and rdf:type relations. Note that the most fundamental of these, rdfs:subPropertyOf, is also used by rdf_has/[3,4].

rdfs_subproperty_of(?SubProperty, ?Property)
True if SubProperty is equal to Property or Property can be reached from SubProperty following the rdfs:subPropertyOf relation. It can be used to test as well as generate sub-properties or super-properties. Note that the commonly used semantics of this predicate is wired into rdf_has/[3,4].bugThe current implementation cannot deal with cycles.bugThe current implementation cannot deal with predicates that are an rdfs:subPropertyOf of rdfs:subPropertyOf, such as owl:samePropertyAs.
rdfs_subclass_of(?SubClass, ?Class)
True if SubClass is equal to Class or Class can be reached from SubClass following the rdfs:subClassOf relation. It can be used to test as well as generate sub-classes or super-classes.bugThe current implementation cannot deal with cycles.
rdfs_class_property(+Class, ?Property)
True if the domain of Property includes Class. Used to generate all properties that apply to a class.
rdfs_individual_of(?Resource, ?Class)
True if Resource is an indivisual of Class. This implies Resource has an rdf:type property that refers to Class or a sub-class thereof. Can be used to test, generate classes Resource belongs to or generate individuals described by Class.

8.2 Collections and Containers

The RDF construct rdf:parseType=Collection constructs a list using the rdf:first and rdf:next relations.

rdfs_member(?Resource, +Set)
Test or generate the members of Set. Set is either an individual of rdf:List or rdfs:Container.
rdfs_list_to_prolog_list(+Set, -List)
Convert Set, which must be an individual of rdf:List into a Prolog list of objects.
rdfs_assert_list(+List, -Resource)
Equivalent to rdfs_assert_list/3 using DB = user.
rdfs_assert_list(+List, -Resource, +DB)
If List is a list of resources, create an RDF list Resource that reflects these resources. Resource and the sublist resources are generated with rdf_bnode/1. The new triples are associated with the database DB.