Replies: 5 comments 2 replies
-
Here is a proposed schema for rules: id: https://w3id.org/rules
name: rules
description: >-
Rule Language
imports:
- biolinkml:meta
- biolinkml:types
prefixes:
biolinkml: https://w3id.org/biolink/biolinkml/
rules: https://w3id.org/rules
default_prefix: rules
slots:
rules:
range: rule
classes:
variable:
is_a: slot_definition
description: >-
A logical variable
attributes:
id:
description: >-
Variable name
range:
description: >-
Allowed values
todos:
- link this to linkmltypes
rule:
attributes:
id:
identifier: true
variables:
range: variable
multivalued: true
inlined: true
if:
range: logical term
then:
range: logical term
bidrectrional:
range: boolean
constraint:
range: boolean
description: >-
if true, then the then clause is only true when the if clause is true
logical term:
attributes:
and:
range: logical term
multivalued: true
description: >-
a conjunction of logical terms all of which are true
or:
range: logical term
multivalued: true
description: >-
a disjunction of logical terms one of which is true
not:
range: logical term
multivalued: false
description: >-
a logical term which is not true
instance:
range: atomic term
multivalued: false
atomic term:
attributes:
var:
range: variable
with:
range: slot constraint
inlined: true
multivalued: true
slot constraint:
is_a: atomic term
attributes:
slot:
identifier: true an example of a constraint, len = end-start: rules:
start_before_end:
description: >-
?interval start ?start, ?interval end ?end => ?start <= ?end
bidirectional: false
constraint: true
vars:
interval:
start:
end:
if:
and:
- instance:
var: interval
with:
start:
var: start
end:
var: end
then:
expression:
op: less_than_or_equal ## builtin
args:
- start
- end
an example of inference: rules:
isa_transitvity:
description: >-
?x is_a ?y, ?y is_a ?z => ?x is_a ?z
bidirectional: false
constraint: false
vars:
x:
y:
z:
if:
and:
- instance:
var: x
with:
is_a:
var: y
- instance:
var: y
with:
is_a:
var: z
then:
instance:
var: x
with:
- is_a:
var: z
isa_transitvity_nested:
bidirectional: false
constraint: false
description: >-
alternate version, no need to name intermediate node.
?x is_a [is_a ?z] => ?x is_a ?z
vars:
x:
z:
if:
and:
- instance:
var: x
with:
is_a:
with:
is_a:
var: z
then:
instance:
var: x
with:
- is_a:
var: z |
Beta Was this translation helpful? Give feedback.
-
One rule language I didn't know about (and that hasn't been mentioned in this discussion yet) is if-then-else support in JSON Schema draft 7. @ShahimEssaid is currently prototyping CRDCH model validation based on these rules. If that works, we might look into trying to implement this rule language (or something like it) in the LinkML JSON Schema generator. |
Beta Was this translation helpful? Give feedback.
-
looks simple and nice! |
Beta Was this translation helpful? Give feedback.
-
See also #195
the proposal is to extend linkml to support
Interval
class, the value oflen
must equalend-start
has_parent
should be irreflexive and acycliclen
slot in the above; but also deriveend
givenstart
andlen
)It is valid to argue that this is overloading linkml, and this should be done using an external rule language. There are many to choose from, including those based in open world semantics or rdf/owl standards, e.g. SWRL, RIF, Jena rules, ...; as well as those based on closed-world or non-monotonic frameworks, e.g. drools, datalog, DLV. For many purposes, even SQL provides a powerful framework
The counter-argument is that it is useful to keep rules close to the schema, with no impedance mismatches, and compile down to various frameworks.
As linkml has similarity to frame-based representation, we should look at frame-oriented solutions (e.g. Flora2), as well as lessons learned
Beta Was this translation helpful? Give feedback.
All reactions