Rich TA Explorations in PSOA Perspectivity

From RuleML Wiki
Jump to: navigation, search

The TA (Teaching Assistant) example has served as a use scenario for multiple inheritance in object-oriented databases and programming. On top of this, the Rich TA example has become a use scenario for perspectivity in Positional-Slotted Object-Applicative (PSOA) RuleML. Modifying the visualized Rich TA clauses (by changing a specific workload fact into a general workload rule, based on two new coursehours slots), the following abridged/unabridged KB reproduces Fig. 2 of the PSOAPerspectivalKnowledge paper, augmented by sample queries, all for copy&paste into PSOATransRun. This permits explorations in PSOA RuleML and PSOATransRun, particularly regarding their perspectivity dimension. The subsequent hints facilitate further explorations by readers.

1 From Abridged to Unabridged

KB (abridged, but still RuleML/Prefix+Assert-wrapped):

RuleML (
  Prefix(pred: <http://www.w3.org/2007/rif-builtin-predicate#>)
  
  Assert (                      % (KB)
                                   % (KB2#)
    Teacher##Scholar                 % Taxonomy
    Student##Scholar
    TA##Teacher
    TA##Student
                                     % Data (ii)
    John#Teacher(+[Wed Thu]
                   coursehours+>12 dept+>Physics salary+>29400
                                                 income->29400)
    John#Student(+[Mon Tue Fri] -[1995 8 17] 
                   coursehours+>20 dept+>Math gender->male)
    
    Forall ?o (                    % (R1)
      ?o#TA(workload+>high) :-
        And(?o#Teacher(coursehours+>?ht)
            External(pred:numeric-greater-than(?ht 10))    % ?ht > 10
            ?o#Student(coursehours+>?hs)
            External(pred:numeric-greater-than(?hs 18)))   % ?hs > 18
    )
  )
)

[Successful] Queries (abridged):

% Fact ("look-up") querying: Boolean (everything fixed)
John#Teacher(+[Wed Thu] coursehours+>12 dept+>Physics salary+>29400 income->29400)

% Fact ("distributed look-up") querying: Boolean (everything fixed)
And(John#Teacher(+[Wed Thu] coursehours+>12) John#Teacher(dept+>Physics salary+>29400 income->29400))

% Fact ("look-up") querying: OID-anchored (OID fixed, descriptors variable)
John#Teacher(+[?dy1 ?dy2] coursehours+>?ch dept+>?dt salary+>?sa income->?in)
John#Teacher(+[? ?] coursehours+>?ch dept+>?dt salary+>?si income->?si)

% Fact ("look-up") querying: Descriptor-associative (OID variable, descriptors fixed)
?who#Teacher(+[Wed Thu] coursehours+>12 dept+>Physics salary+>29400 income->29400)

% Fact ("look-up") querying: Descriptor-pattern (OID variable, descriptors variable)
?who#Teacher(+[?dy1 ?dy2] coursehours+>?ch dept+>?dt salary+>?sa income->?in)
?who#Teacher(+[? ?] coursehours+>?ch dept+>?dt salary+>?si income->?si)

% Fact ("look-in") querying: Relational- and Graph-style

Student(+[Mon Tue Fri])    % Relational query with explicit tuple, marked as predicate-dependent
Student(Mon Tue Fri)       % Relational query with implicit tuple, understood as predicate-dependent
?#Student(Mon Tue Fri)     % Relational-like query with don't-care Object-IDentifier (OID) variable
?w#Student(Mon Tue Fri)    % Relational-like query with named OID variable
John#Student(Mon Tue Fri)  % Relational-like query with OID constant 
John#Student(?d1 ?d2 ?d3)
?w#Teacher(Wed Thu)
?w#Teacher(?d1 ?d2)
?w#Student(-[1995 ?m 17])  % Relational-like query with explicit tuple, marked as predicate-independent
?w#Student(-[?y ?m ?d])
?w#Teacher(-[?y ?m ?d])
?w#Top(-[?y ?m ?d])

John#Student(gender->male)    % Graph query with OID constant typed by Student predicate and described by independent slot
John#Teacher(gender->male)    % Graph query with OID constant typed by Teacher predicate and described by independent slot
?w#Top(gender->male)          % Graph query with OID variable typed by any predicate and described by independent slot
John#Student(dept+>?d)    % Graph query with OID constant typed by Student predicate and described by dependent slot
John#Teacher(dept+>?d)    % Graph query with OID constant typed by Teacher predicate and described by dependent slot
John#?p(dept+>?d)         % Graph query with OID constant typed by predicate variable and described by dependent slot
?w#?p(coursehours+>?h)
And(?w#Teacher(coursehours+>?ht) ?w#Student(coursehours+>?hs))

% Explicit (R1) Rule ("deductive") querying: Deriving a descriptor via thresholds of other descriptors 

John#TA(workload+>?l)   % Graph query with OID constant typed by TA predicate and described by dependent slot
?w#?p(workload+>?l)     % Graph query with OID variable typed by predicate variable and described by dependent slot

% Implicit (##) Rule ("deductive") querying: Deriving an OID membership from OID's membership in a subclass

John#Scholar  % Derivable from describution-obtained John#Teacher (via Teacher##Scholar) or John#Student (via Student##Scholar)

% Querying of two Facts as well as the Explicit and one Implicit Rule: Combining retrieval with (general and taxonomic) inference

John#?p        % Finds all four predicates for John

KB (unabridged):

RuleML (
  Prefix(pred: <http://www.w3.org/2007/rif-builtin-predicate#>)
  
  Assert (                      % (KB)
                                   % (KB2#)
    _Teacher##_Scholar               % Taxonomy
    _Student##_Scholar
    _TA##_Teacher
    _TA##_Student
                                     % Data (ii)
    _John#_Teacher(+[_Wed _Thu]
                   _coursehours+>12 _dept+>_Physics _salary+>29400
                                                    _income->29400)
    _John#_Student(+[_Mon _Tue _Fri] -[1995 8 17] 
                   _coursehours+>20 _dept+>_Math _gender->_male)
    
    Forall ?o (                    % (R1)
      ?o#_TA(_workload+>_high) :-
        And(?o#_Teacher(_coursehours+>?ht)
            External(pred:numeric-greater-than(?ht 10))    % ?ht > 10
            ?o#_Student(_coursehours+>?hs)
            External(pred:numeric-greater-than(?hs 18)))   % ?hs > 18
    )
  )
)

[Successful] Queries (unabridged, although not Query-wrapped):

% Fact ("look-up") querying: Boolean (everything fixed)
_John#_Teacher(+[_Wed _Thu] _coursehours+>12 _dept+>_Physics _salary+>29400 _income->29400)

% Fact ("distributed look-up") querying: Boolean (everything fixed)
And(_John#_Teacher(+[_Wed _Thu] _coursehours+>12) _John#_Teacher(_dept+>_Physics _salary+>29400 _income->29400))

% Fact ("look-up") querying: OID-anchored (OID fixed, descriptors variable)
_John#_Teacher(+[?dy1 ?dy2] _coursehours+>?ch _dept+>?dt _salary+>?sa _income->?in)
_John#_Teacher(+[? ?] _coursehours+>?ch _dept+>?dt _salary+>?si _income->?si)

% Fact ("look-up") querying: Descriptor-associative (OID variable, descriptors fixed)
?who#_Teacher(+[_Wed _Thu] _coursehours+>12 _dept+>_Physics _salary+>29400 _income->29400)

% Fact ("look-up") querying: Descriptor-pattern (OID variable, descriptors variable)
?who#_Teacher(+[?dy1 ?dy2] _coursehours+>?ch _dept+>?dt _salary+>?sa _income->?in)
?who#_Teacher(+[? ?] _coursehours+>?ch _dept+>?dt _salary+>?si _income->?si)

% Fact ("look-in") querying: Relational- and Graph-style

_Student(+[_Mon _Tue _Fri])    % Relational query with explicit tuple, marked as predicate-dependent
_Student(_Mon _Tue _Fri)       % Relational query with implicit tuple, understood as predicate-dependent
?#_Student(_Mon _Tue _Fri)     % Relational-like query with don't-care Object-IDentifier (OID) variable
?w#_Student(_Mon _Tue _Fri)    % Relational-like query with named OID variable
_John#_Student(_Mon _Tue _Fri) % Relational-like query with OID constant 
_John#_Student(?d1 ?d2 ?d3)
?w#_Teacher(_Wed _Thu)
?w#_Teacher(?d1 ?d2)
?w#_Student(-[1995 ?m 17])     % Relational-like query with explicit tuple, marked as predicate-independent
?w#_Student(-[?y ?m ?d])
?w#_Teacher(-[?y ?m ?d])
?w#Top(-[?y ?m ?d])

_John#_Student(_gender->_male)    % Graph query with OID constant typed by _Student predicate and described by independent slot
_John#_Teacher(_gender->_male)    % Graph query with OID constant typed by _Teacher predicate and described by independent slot
?w#Top(_gender->_male)            % Graph query with OID variable typed by any predicate and described by independent slot
_John#_Student(_dept+>?d)    % Graph query with OID constant typed by _Student predicate and described by dependent slot
_John#_Teacher(_dept+>?d)    % Graph query with OID constant typed by _Teacher predicate and described by dependent slot
_John#?p(_dept+>?d)          % Graph query with OID constant typed by predicate variable and described by dependent slot
?w#?p(_coursehours+>?h)
And(?w#_Teacher(_coursehours+>?ht) ?w#_Student(_coursehours+>?hs))

% Explicit (R1) Rule ("deductive") querying: Deriving a descriptor via thresholds of other descriptors

_John#_TA(_workload+>?l)   % Graph query with OID constant typed by _TA predicate and described by dependent slot
?w#?p(_workload+>?l)       % Graph query with OID variable typed by predicate variable and described by dependent slot

% Implicit (##) Rule ("deductive") querying: Deriving an OID membership from OID's membership in a subclass

_John#_Scholar  % Derivable from describution-obtained _John#_Teacher (via _Teacher##_Scholar) or _John#_Student (via _Student##_Scholar)

% Querying of two Facts as well as the Explicit and one Implicit Rule: Combining retrieval with (general and taxonomic) inference

_John#?p        % Finds all four predicates for _John

2 Further Explorations

  • Modify and add Queries
  • Modify and add facts and rules to the abridged or unabridged KB variant, watching answers for Queries change and new Queries become possible
  • Start KB expansion with Mary/_Mary facts, e.g. with the abridged/unabridged relational-like fact below, and request more answers for Queries
Mary#Teacher(Wed Fri)
_Mary#_Teacher(_Wed _Fri)
  • Continue KB expansion with slot-enrichment rules, e.g. with a rule that adds a conclusion slot coursehours+>?h for a condition conjunct ?h = External(func:numeric-add(?ht ?hs)) [the original and the new rule can then be merged into one augmented rule]