@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#>.
@prefix log:  <http://www.w3.org/2000/10/swap/log#>.
@prefix var:  <http://www.w3.org/2000/10/swap/var#>.
@prefix :     <http://example.org/#>.

# ───────────────────────────────────────────────
# Facts – Tweety & Polly
# ───────────────────────────────────────────────
:tweety  rdf:type :Bird ;
         :abnormal false .

:polly   rdf:type :Penguin .          # abnormality & flight decided by rules

# ───────────────────────────────────────────────
# Rules
# ───────────────────────────────────────────────

# 1.  Penguins are Birds
[ log:graph ( [ log:triple (var:X rdf:type :Penguin) ] ) ]
    log:implies
[ log:graph ( [ log:triple (var:X rdf:type :Bird) ] ) ].

# 2.  Penguins are Abnormal
[ log:graph ( [ log:triple (var:X rdf:type :Penguin) ] ) ]
    log:implies
[ log:graph ( [ log:triple (var:X :abnormal true) ] ) ].

# 3.  Normal birds fly (probability 0.9)
[ log:graph (
    [ log:triple (var:X rdf:type :Bird) ]
    [ log:triple (var:X :abnormal false) ]
) ] log:implies [ log:graph (
    [ log:triple (var:X :flies true) ]
    [ log:triple (var:X :fliesProb "0.9"^^xsd:double) ]
) ].

# 4.  Abnormal birds do NOT fly (probability 0.0)
[ log:graph (
    [ log:triple (var:X rdf:type :Bird) ]
    [ log:triple (var:X :abnormal true) ]
) ] log:implies [ log:graph (
    [ log:triple (var:X :flies false) ]
    [ log:triple (var:X :fliesProb "0.0"^^xsd:double) ]
) ].

# ───────────────────────────────────────────────
# Answer rules – deliver the three queries
# ───────────────────────────────────────────────
[ log:graph ( [ log:triple (var:A :flies var:B) ] ) ]
    log:impliesAnswer
[ log:graph ( [ log:triple (var:A :flies var:B) ] ) ].

[ log:graph ( [ log:triple (var:A :fliesProb var:P) ] ) ]
    log:impliesAnswer
[ log:graph ( [ log:triple (var:A :fliesProb var:P) ] ) ].

[ log:graph ( [ log:triple (var:A :abnormal var:B) ] ) ]
    log:impliesAnswer
[ log:graph ( [ log:triple (var:A :abnormal var:B) ] ) ].

