forked from opencog/atomspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsatisfaction.scm
46 lines (39 loc) · 1.25 KB
/
satisfaction.scm
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
;
; satisfaction.scm -- Determining satisfiability of a query.
;
; SatisfactionLink usage example.
;
; Using the SatisfactionLink is fairly straightforward; what this
; example shows is how to obtain the variable grounding that caused
; the satisfaction to be fulfilled.
;
(use-modules (opencog) (opencog exec))
; Define a very simple satisfaction link.
(define satlink
(Satisfaction
(Evaluation
(Predicate "foobar")
(List
(Concept "funny")
(Variable "$x")))))
; Create something that will satisfy the above.
(Evaluation
(Predicate "foobar")
(List
(Concept "funny")
(Concept "thing")))
; Actually run it - this should return TrueTV i.e. `(stv 1 1)`
; because the SatisfactionLink is satisfiable.
(cog-evaluate! satlink)
; Print a list of all the keys attached to the SatisfactionLink.
(cog-keys satlink)
; The one and only key printed above should be the below.
(define pgk (Predicate "*-PatternGroundingsKey-*"))
; Get the value associated with this key.
; Ah Ha! It should print `(Concept "thing")` which is the
; value that grounded the `(Variable "$x")`.
;
; This value is cached indefinitely - until the next time that
; the SatisfactionLink is evaluated. If it evaluates to false,
; the old cached value is NOT cleared!
(cog-value satlink pgk)