-
Notifications
You must be signed in to change notification settings - Fork 3
/
implication.n3
77 lines (67 loc) · 1.32 KB
/
implication.n3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@prefix : <urn:example:> .
:Alice :likes :Cats ;
:plays :Piano .
# A material implication works like an if->then
# P -> Q
# If P then Q
{
?Person :plays :Piano .
}
=>
{
?Person :likes :Music .
} .
# A converse implication works like a kind of a definition
# P <- Q
# Not Q without P
{
( ?X ?Y ) :likesXplaysY ?Person .
}
<=
{
?Person :likes ?X .
?Person :plays ?Y .
} .
# This converse implication you can use now in other rules
# Find out what Alice likes and plays
{
( ?X ?Y ) :likesXplaysY :Alice .
}
=>
{
:Alice :does ( ?X ?Y ).
# :Alice :does ( :Cats :Piano )
# :Alice :does ( :Music :Piano ) #(because of the first rule)
} .
# Or in other query
# What does Alice do besides playing piano?
{
( ?X :Piano ) :likesXplaysY :Alice .
}
=>
{
:Alice :doesPianoAnd ?X .
# :Alice :doesPianoAnd :Cats
# :Alice :doesPianoAnd :Music #(because of the first rule)
} .
# Or
# Who does play the piano and likes What
{
( ?What :Piano ) :likesXplaysY ?Who .
}
=>
{
?Who :doesPianoAnd2 ?What .
# :Alice :doesPianoAnd2 :Cats
# :Alice :doesPianoAnd2 :Music #(because of the first rule)
} .
# Test
{
:Alice :does ( :Cats :Piano ) , ( :Music :Piano ) ;
:doesPianoAnd :Cats , :Music ;
:doesPianoAnd2 :Cats , :Music .
}
=>
{
:test :is true .
} .