summaryrefslogtreecommitdiff
path: root/intellect-framework-from-internet/starts/meaning-vm/level-2/habits.hpp
blob: d5fb0fd9cd4f7287e7816c926f8eb9cbbfc72b4f (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#pragma once

#include "common.hpp"
#include "ref.hpp"
#include "concepts.hpp"

namespace intellect {
namespace level2 {

void createhabits();

ref makeconcept();
void conceptunmake(ref c);

namespace concepts {

	// make a link
	// link(source, type, target)
	static ref link("link");

	// get if a link is permanent
	// result = (link-crucial)(source, type, target)
	static ref crucial("crucial");
	
	// set a link to be permanent
	// (link-set-crucial)(source, type, target)
	static ref set("set");

	// get if a link exists
	// result = linked(source, type, target? = anything)
	static ref linked("linked");

	// remove a link
	// unlink(source, type, target)
	static ref unlink("unlink");

	// get a link target by type
	// result = get(source, type)
	static ref get("get");

	// set a link target, replacing an existing type if needed
	// set(source, type, target)

	// produce a totally new, empty concept, with no links to or from
	// result = (make-concept)()
	static ref make("make"), concept("concept");

	// produce a new concept by copying links and data from an old concept.
	// nothing will link to new concept.
	// result = (make-copy)(concept)
	static ref copy("copy");

	// destroy a concept forever, for handling temporary data.
	// this will fail if the concept is set to be crucial, or is in use.
	// (concept-unmake)(concept)
	static ref unmake("unmake");

	// get if a concept is set to be crucial
	// result = (concept-crucial)(concept)
	
	// set a concept to be crucial
	// r(concept-set-crucial)(concept)
	
	// place a concept in a new group.
	// forms a new link of type 'is', fails if one aleady exists
	// concept = (know-is)(concept, group)
	static ref know("know"), is("is")  ;

	// fill any concept with information about the first link entry in a concept
	// if there is a link in the entry, then [type] and [target] will be present
	// link-entry = (know-is-first-link-entry)(link-entry, concept)
	static ref first("first"), entry("entry");

	// fill any concept with information about the last link entry in a concept
	// link-entry = (know-is-last-link-entry)(link-entry, concept)
	static ref last("last");

	// change a link entry concept to be about the next link in the concept
	// link-entry = (next-link-entry)(link-entry)

	// change a link entry concept to be about the previous link in the concept
	// link-entry = (previous-link-entry)(link-entry)
	static ref previous("previous");

	// get if two link entry concepts refer to the same link entry
	// result = (same-link-entry)(link-entry-A, link-entry-B)
	static ref same("same");

	// remove a link entry from a concept
	// the entry will be about the next one, after the action
	// link-entry = (link-entry-unlink)(link-entry)
	
	// get if a link entry is set to be crucial
	// result = (link-entry-crucial)(link-entry)
	
	// set a link entry to be crucial & permanent
	// (link-entry-set-crucial)(link-entry)
	
	// add links to a concept facilitating use as a list
	// list = (know-is-list)(list)
	static ref list("list");

	// get the first list-entry of a list
	// result = (list-first-entry)(list)
	
	// get the last list-entry of a list
	// result = (list-last-entry)(list)
	
	// get a subsequent list-entry
	// result = (list-entry-next)(list-entry)
	
	// get a preceding list-entry
	// result = (list-entry-previous)(list-entry)
	
	// get the item associated with a list-entry
	// result = (list-entry-item)(list-entry)
	static ref item("item");

	// make a new entry in a list, holding an item concept
	// list = (make-next-list-entry)(list, item)
	
	// destroy forever an entry in a list.  for lists of temporaries.
	// the result is the next entry.
	// result = (list-entry-unmake)(list-entry, le)
	
	// action(list-entry, context) for every entry in a list until result made
	// result = (list-each-entry)(list, context, action)
	static ref each("each");

	// get if a list has an item in it
	// result = (list-has-item)(list, item)
	static ref has("has");

	// destroy forever an entry in its list, by the item it contains
	// for lists of temporaries
	// true = (list-item-entry-unmake)(list, item)
	
	// the .act level-2 member function can ease list creation.
	// it passes itself as the first argument to a habit
	// (make-concept)().act(know-is-list)
	// 	.act(make-next-list-entry, i1)
	// 	.act(make-next-list-entry, i2)
	// 	...;
	
	// make a concept holding an item in a translation map
	// result = (make-map-item)(source, target)
	static ref map("map");

	// make a contextual subcontext for an action
	// the maps are lists of translation map items
	// known-information is a map where the source items are taken literally instead of mapped
	// result = (make-context-action)(known-information, needed-information-map, made-information-map, action)
	static ref action("action");

	// condition do one of multiple possible actions
	// looks up actions[condition] and does that.
	// does actions[anything] if nothing matches.
	// result = (condition-action)(condition, actions)
	static ref condition("condition");

	// action handlers
	// calls anything with a 'habit' handler: act(action, context)
	// 	for action is habit: provides context as full context
	// 	for action has habit: calls habit with unordered (context, action)
	// 		recursively handles if habit itself has habit to handle it.
	// the habit of habits, calls a habit: habit(context, action)
	// the habit of context-actions, calls a subcontextual action: (context-action)(context, action)
	// the habit of action lists, calls a list of actions: (action-list)(context, action)
	// the habit of 'nothing', does nothing: (nothing)()
}

}
}