1% Given 3 birds, which can fly?
2
3#pred penguin(X) :: '@(X) is a penguin'.
4penguin(sam). % sam is a penguin
5#pred wounded_bird(X) :: '@(X) is a wounded bird'.
6wounded_bird(john). % john is wounded
7
8#pred bird(X) :: '@(X) is a bird'.
9bird(tweety). 11bird(X) :- penguin(X).
12bird(X) :- wounded_bird(X).
13
14#pred ab(X) :: '@(X:bird) is abnormal'.
16ab(X) :- penguin(X).
17ab(X) :- wounded_bird(X).
18
19#pred flies(X) :: '@(X) can fly'.
20% birds can fly if they are not abnormal
21flies(X) :- bird(X), not ab(X).
22
23#pred -flies(X) :: '@(X) can not fly'.
25-flies(X) :- ab(X).
26-flies(X) :- -bird(X).
27
28-wounded_bird(X) :- not wounded_bird(X).
29
30-bird(X) :- not bird(X).
31
32-penguin(X) :- not penguin(X).
33
34-ab(X) :- not ab(X).
35
36
37?- flies(X).