forked from trueagi-io/metta-wam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackward_chain.metta
46 lines (33 loc) · 1005 Bytes
/
backward_chain.metta
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
(Evaluation (philosopher Plato))
(Evaluation (likes-to-wrestle Plato))
(Implication
(And (Evaluation (philosopher $x))
(Evaluation (likes-to-wrestle $x)))
(Evaluation (human $x)))
; Another implication rule
(Implication
(Evaluation (human $x))
(Evaluation (mortal $x)))
; Deduction case when the desired evaluation is present in
; the knowledge base
(= (deduce (Evaluation ($P $x)))
(match &self (Evaluation ($P $x)) ($P $x)))
; Deduction case when the desired evaluation is the result
; of an implication, which implies a recursion
(= (deduce (Evaluation ($P $x)))
(match &self
(Implication $a (Evaluation ($P $x)))
(($P $x) proven by (deduce $a))))
(= (deduce (And $a $b))
(And (deduce $a) (deduce $b)))
!(deduce (Evaluation (mortal $x)))
;;direct_metta
(= (And True True) True)
(= (frog $x)
(And (croaks $x)
(eat_flies $x)))
(= (croaks Fritz) False)
(= (eat_flies Fritz) True)
(= (green $x) (frog $x))
!(frog Fritz)
!(True)