Blake Regalia
Blake Regalia

Reputation: 2766

Define an OWL class to reflect the parameter list datatypes of a method's signature

How might you define a subclass of an RDF List (yes, it needs to be an RDF List) such that it reflects the restrictions on the datatypes of a method signature's parameter list?

For example

Given a method signature:

void set(uint, string);

Where an ABox statement would look like this:

# syntax: Turtle

("42"^^xsd:unsignedInt "Doug") a :SetCallArgumentList .

My attempt

# syntax: Turtle

:SetCallArgumentList
    rdfs:subClassOf a owl:Class ;
    owl:intersectionOf (
        rdf:List
        [
            a owl:Restriction ;
            owl:onProperty rdf:first ;
            owl:cardinality "1"^^xsd:nonNegativeInteger ;
            owl:allValuesFrom xsd:unsignedInt ;  # 1st parameter: uint
        ]
        [
            a owl:Restriction ;
            owl:onProperty rdf:rest ;
            owl:cardinality "1"^^xsd:nonNegativeInteger ;
            owl:allValuesFrom [
                a owl:Class ;
                owl:intersectionOf rdf:List, [
                    a owl:Restriction ;
                    owl:onProperty rdf:first ;
                    owl:cardinality "1"^^xsd:nonNegativeInteger ;
                    owl:allValuesFrom xsd:string ;  # 2nd parameter: string
                ], [
                    a owl:Restriction ;
                    owl:onProperty rdf:rest ;
                    owl:cardinality "1"^^xsd:nonNegativeInteger ;
                    owl:hasValue rdf:nil ;  # end-of-list
                ] ;
            ] ;
        ] ;
    ) .

Are there any dangers, redundancies or oversights to what I've done here? Any comments are welcome.

Upvotes: 1

Views: 238

Answers (1)

Henriette Harmse
Henriette Harmse

Reputation: 4787

Assume we have a class C with a method f(p1:P1, p2:P2):R meaning f is a method taking parameters p1 of type P1 and p2 of type P2 returning something of type R. The types P1, P2 and R can be data types or classes.

The basic idea is to introduce a class that will represent your method with its signature using reification. So we introduce a class, say Method_f, with properties r_f, r_f_inv, r_p1, r_p2 and r_R. r_f. r_f is an object property with r_f_inv its inverse. r_p1, r_p2 and r_R will be object properties or data properties depending on whether P1, P2 and R are classes or data types. I.e. if P1 is a class r_p1 will be an object property, if it is a data type, r_p1 will be a data property. Throughout I will use object properties.

Reification representing method

(1) The class Method_f must represent a tuple (consisting of 4 components in this case), for which we add the following axioms:

Class: Method_f
  SubClassOf:
    r_f_inv exactly 1 Thing and
    r_p1 exactly 1 Thing and
    r_p2 exactly 1 Thing and
    r_R exactly 1 Thing

(2) To ensure that a method for a given instance of a class C with given values for parameters p1 and p2 will not return different results, we add for class Method_f the following key:

  Haskey:
    r_f_inv, r_p1, r_p2

For methods not returning anything, the key is simply omitted.

(3) To ensure the parameters and return value has the correct types, the following axioms are added:

ObjectProperty: r_p1
  Domain: Method_f
  Range: P1
ObjectProperty: r_p2
  Domain: Method_f
  Range: P2
ObjectProperty: r_R
  Domain: Method_f
  Range: R

(4) To ensure that instances of the class C can invoke the method f, we add the axiom:

Class: C
  SubClassOf:
    r_f some Method_f

To represent the method f being invoked we have to:

(1) have instances of C, P1, P2 and R, say c, p1, p2, r. (2) have an instance of Method_f:

Individual: method_f_call_1
  Types: Method_f
  Facts: 
    r_f_inv c,
    r_p1 p1,
    r_p2 p2,
    r_R r

(3) invoke it.

Individual: c
  Types: C
  Facts: r_f method_f_call_1

For a detailed explanation regarding this, see Chapter 5 of my dissertation.

Upvotes: 1

Related Questions