-
Notifications
You must be signed in to change notification settings - Fork 0
/
what_is_the_moon_of_saturn.clj
84 lines (66 loc) · 2.25 KB
/
what_is_the_moon_of_saturn.clj
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(ns what-is-the-moon-of-saturn
(:require
[tech.v3.datatype.functional :as f]
[tech.v3.datatype :as dtype]
[tech.v3.tensor :as dtt]
[tech.v3.datatype.bitmap :as bitmap]
[fastmath.random :as fm.rand]
[fastmath.core :as fm]
[bennischwerdtner.hd.binary-sparse-segmented :as
hd]
[tech.v3.datatype.unary-pred :as unary-pred]
[tech.v3.datatype.argops :as dtype-argops]
[bennischwerdtner.hd.data :as hdd]))
(def earth
(hdd/->directed-edge (hdd/clj->vsa* [:moon :luna])))
(def saturn
(hdd/directed-graph (hdd/clj->vsa*
[[:adjective :saturnian]
[:adjective :cronian]
[:adjective :kronian]
[:rings true]
[:moon :mimas]
[:moon :enceladus]
[:moon :tethys]
[:moon :dione]
[:moon :rhea]
[:moon :titan]
[:moon :iapetus]])))
;; let's say you know luna and you want to know what that is in saturn domain
(hdd/cleanup*
(hdd/edge->destination
saturn
(hdd/edge->source earth (hdd/clj->vsa :luna))))
'(:rhea :iapetus :tethys :dione :mimas :titan :enceladus)
;; 0. "What is the dollar in mexico?" kind of things work in general.
;; 1. the moon of saturn is a superposition 7 things
;; 2. Saturn is a composite datastructure, yet we pretend it's one element 'edge->destination'
;; works on an edge element, and the superposition of elements
;; partial expansion:
;; ----------------
(hdd/cleanup*
(hdd/edge->destination
saturn
(hdd/edge->source
(hdd/->directed-edge (hdd/clj->vsa* [:moon :luna]))
(hdd/clj->vsa :moon))))
(hdd/cleanup* (hd/unbind
;; earh
(hd/bind (hdd/clj->vsa* :moon)
(hd/permute (hdd/clj->vsa* :moon)))
(hd/permute (hdd/clj->vsa* :moon))))
'(:moon)
;; I am not expanding 'saturn' now for brevity.
;; But it is a set of directed edges.
(hdd/cleanup*
(hd/permute-inverse
(hd/unbind
saturn
;; moon
(hd/unbind
;; earth
(hd/bind
(hdd/clj->vsa* :moon)
(hd/permute (hdd/clj->vsa* :moon)))
(hd/permute (hdd/clj->vsa* :moon))))))
;; ------------------------------------------