forked from trueagi-io/hyperon-experimental
-
Notifications
You must be signed in to change notification settings - Fork 0
/
e1_kb_write.metta
34 lines (30 loc) · 895 Bytes
/
e1_kb_write.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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MeTTa allows to use a separate knowledge base (Space) &kb
; to accumulate inferred knowledge
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Bind &kb to a new empty Space
!(bind! &kb (new-space))
; Some knowledge
(= (frog $x)
(and (croaks $x)
(eat_flies $x)))
(= (croaks Fritz) True)
(= (eat_flies Fritz) True)
(= (croaks Sam) True)
(= (eat_flies Sam) True)
(= (green $x)
(frog $x))
; Define conditional
(: ift (-> Bool Atom Atom))
(= (ift True $then) $then)
; For anything that is green, assert it is Green in &kb
; There should be two green things
!(assertEqualToResult
(ift (green $x)
(add-atom &kb (Green $x)))
(() ()))
; Retrieve the inferred Green things: Fritz and Sam.
!(assertEqualToResult
(match &kb (Green $x) $x)
(Fritz Sam))