|
| 1 | +;#------------------------------------------------------------------------------------------------------------------------------------------------ |
| 2 | +;# Inference rules |
| 3 | +;# |
| 4 | +;# :InferenceRule is a special class that contains the SPARQL rules in the form CONSTRUCT-WHERE to execute. Each individual of this |
| 5 | +;# class is associated through the property has-sparql-code with a xsd:string that executes it. The automated reasoner first collects |
| 6 | +;# all individuals of the class :InferenceRule; then, it iteratively re-execute the SPARQL rules in the range of :has-sparql-code |
| 7 | +;# until no new individual is inferred. |
| 8 | +;#------------------------------------------------------------------------------------------------------------------------------------------------ |
| 9 | +; |
| 10 | +;:InferenceRule rdf:type rdfs:Class. |
| 11 | +;:has-sparql-code rdf:type rdf:Property; |
| 12 | +; rdfs:domain :InferenceRule; |
| 13 | +; rdfs:range xsd:string. |
| 14 | + |
| 15 | +;#------------------------------------------------------------------------------------------------------------------------------------------------ |
| 16 | +;# 1st-level classes and properties (Hobbs's logic) - eventualities, modalities, and thematic roles |
| 17 | + |
| 18 | + |
| 19 | +;#Rexist modality: |
| 20 | +;:Rexist rdf:type rdfs:Class,:Modality. |
| 21 | + |
| 22 | +(= (not_exist pattern) |
| 23 | + !(unify &self (pattern) T F)) |
| 24 | + |
| 25 | +(rexist class modality) |
| 26 | + |
| 27 | +;#Top classes: |
| 28 | +;:Eventuality rdf:type rdfs:Class. |
| 29 | +;:Modality rdf:type rdfs:Class. |
| 30 | +;:ThematicRole rdf:type rdfs:Class. |
| 31 | + |
| 32 | +(eventuality class type) |
| 33 | +(modality class type) |
| 34 | +(thematic_role class type) |
| 35 | + |
| 36 | +;#negation, conjunction, and disjunction of eventualities: |
| 37 | +;:not rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality. |
| 38 | +;:and1 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality. |
| 39 | +;:and2 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality. |
| 40 | +;:or1 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality. |
| 41 | +;:or2 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality. |
| 42 | + |
| 43 | + |
| 44 | +(NOT property eventuality) |
| 45 | +(AND1 property eventuality) |
| 46 | +(AND2 property eventuality) |
| 47 | +(OR1 property eventuality) |
| 48 | +(OR2 property eventuality) |
| 49 | + |
| 50 | +;#Deontic modalities: |
| 51 | +;:DeonticModality rdf:type rdfs:Class; rdfs:subClassOf :Modality. |
| 52 | +;:Obligatory rdf:type rdfs:Class,:DeonticModality. |
| 53 | +;:Permitted rdf:type rdfs:Class,:DeonticModality. |
| 54 | +;:Optional rdf:type rdfs:Class,:DeonticModality. |
| 55 | + |
| 56 | +(deontic_modality class modality) |
| 57 | +(oligatory class deontic_modality) |
| 58 | +(permitted class deontic_modality) |
| 59 | +(optional class deontic_modality) |
| 60 | + |
| 61 | +;#------------------------------------------------------------------------------------------------------------------------------------------------ |
| 62 | + |
| 63 | +;# 2nd-level classes and properties - classical logic operators applied to rdf:Statement(s), i.e., reifications of 1st-level assertions. |
| 64 | +;# These are needed because RDF vocabulary does not implement several operators from classical logic (negation, disjunction, etc.), nor |
| 65 | +;# the alethic modal logic operators of necessity (□) and possibility (◊) |
| 66 | + |
| 67 | + |
| 68 | +;:statement rdf:type rdfs:Class; rdfs:subClassOf rdf:Statement. |
| 69 | +;:true rdf:type rdfs:Class; rdfs:subClassOf :statement. |
| 70 | +;:false rdf:type rdfs:Class; rdfs:subClassOf :statement. |
| 71 | +;:hold rdf:type rdfs:Class; rdfs:subClassOf :statement. |
| 72 | +;:necessary a rdfs:Class; rdfs:subClassOf :statement. |
| 73 | +;:possible a rdfs:Class; rdfs:subClassOf :statement. |
| 74 | +; |
| 75 | +;:disjunction rdf:type rdf:Property; |
| 76 | +; rdfs:domain :statement; |
| 77 | +; rdfs:range :statement. |
| 78 | + |
| 79 | +(true class statement) |
| 80 | +(false class statement) |
| 81 | +(hold class statement) |
| 82 | +(necessary class statement) |
| 83 | +(possible class statement) |
| 84 | + |
| 85 | +(disjunction property (statement statement)) ;!!!!!! |
| 86 | + |
| 87 | +;#------------------------------------------------------------------------------------------------------------------------------------------------ |
| 88 | + |
| 89 | +;3rd-level - explicit representation of contradictions, conflicts, violations, and other undesirable consequences (fallacies, mistakes, etc.) |
| 90 | + |
| 91 | +;:is-in-contradiction-with rdf:type rdf:Property; |
| 92 | +; rdfs:domain :statement; |
| 93 | +; rdfs:range :statement. |
| 94 | +;:is-in-conflict-with rdf:type rdf:Property; |
| 95 | +; rdfs:domain :statement; |
| 96 | +; rdfs:range :statement. |
| 97 | +;:is-complied-with-by rdf:type rdf:Property; |
| 98 | +; rdfs:domain :statement; |
| 99 | +; rdfs:range :statement. |
| 100 | +;:is-violated-by rdf:type rdf:Property; |
| 101 | +; rdfs:domain :statement; |
| 102 | +; rdfs:range :statement. |
| 103 | +;:is-necessary-violated-by rdf:type rdf:Property; |
| 104 | +; rdfs:domain :statement; |
| 105 | +; rdfs:range :statement. |
| 106 | + |
| 107 | +(is_in_contradiction_with property (statement statement)) |
| 108 | +(is_in_conflict_with property (statement statement)) |
| 109 | +(is_complied_with_by property (statement statement)) |
| 110 | +(is_violated_by property (statement statement)) |
| 111 | +(is_necessary_violated_by property (statement statement)) |
| 112 | + |
| 113 | +;#------------------------------------------------------------------------------------------------------------------------------------------------ |
| 114 | +;# Inference rules at the 1st level (the level of the eventualities) |
| 115 | + |
| 116 | +;#The following rule infers that if two eventualities are direct instantiations of the same abstract eventuality (i.e., they both describe the |
| 117 | +;#same action/state with the same thematic roles) but for at least one thematic role, for which it is asserted that one of the two eventualities |
| 118 | +;#has a certain value on that thematic role while the other one does not, then the two eventualities are connected by the ":not" property. |
| 119 | + |
| 120 | +;[rdf:type :InferenceRule; |
| 121 | +; :has-sparql-code """CONSTRUCT{?e1 :not ?e2} |
| 122 | +; WHERE{?e1 rdf:type ?c. ?e2 rdf:type ?c. ?c rdf:type :Eventuality. FILTER(?e1!=?e2) |
| 123 | +; ?trn rdf:type :ThematicRole. ?e1 ?trn ?vn. ?r rdf:type :false,:hold; rdf:subject ?e2; rdf:predicate ?trn; rdf:object ?vn. |
| 124 | +; NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e1 ?tr ?tv1. NOT EXISTS{?e2 ?tr ?tv2}} |
| 125 | +; NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e2 ?tr ?tv2. NOT EXISTS{?e1 ?tr ?tv1}} |
| 126 | +; NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e1 ?tr ?tv1. ?e2 ?tr ?tv2. FILTER(?tv1!=?tv2)}}"""^^xsd:string]. |
| 127 | + |
| 128 | +!(match &self (, ($e1 rdf:type $c) ($e2 rdf:type $c) ($c property eventuality)) |
| 129 | + (if (not (== $e1 $e2)) |
| 130 | + |
| 131 | + (match &self (, ($trn rdf:type :ThematicRole) ($e1 $trn $vn) (hold ($r rdf:type :false)) ) |
| 132 | + (if (and (not_exist (, ($tr rdf:type :ThematicRole) ($e1 $tr $tv1) (not_exist ($e2 $tr $tv2)))) |
| 133 | + (not_exist (, ($tr rdf:type :ThematicRole) ($e2 $tr $tv2) (not_exist ($e1 $tr $tv1)))) |
| 134 | + (not_exist (, ($tr rdf:type :ThematicRole) ($e1 $tr $tv1) (($e2 $tr $tv2))))) |
| 135 | + |
| 136 | + (add-atom &self (NOT $e1 $e2)))))) |
| 137 | + |
0 commit comments