summaryrefslogtreecommitdiff
path: root/intellect-framework-from-internet/starts/meaning-vm/level-1
diff options
context:
space:
mode:
Diffstat (limited to 'intellect-framework-from-internet/starts/meaning-vm/level-1')
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/baseref.hpp67
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/common.hpp14
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.cpp20
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.hpp27
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.cpp209
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.hpp28
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/level-1.hpp6
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/ref.hpp15
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.cpp84
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.hpp45
10 files changed, 0 insertions, 515 deletions
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/baseref.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/baseref.hpp
deleted file mode 100644
index ac6ff9c..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/baseref.hpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-
-#include "common.hpp"
-#include "funcs.hpp"
-
-#include "../level-0/ref.hpp"
-
-#include <functional>
-
-namespace intellect {
-namespace level1 {
-
-template <typename ref>
-struct baseref : public level0::baseref<ref>
-{
- baseref(concept * p) : level0::baseref<ref>(p) { }
- baseref(level0::ref const & other) : baseref(other.ptr()) { }
- baseref(std::string const & name, concept* allocator = nullptr) : baseref(getnamed(name, allocator)) { }
- baseref(const char *name, concept* allocator = nullptr) : baseref(std::string(name), allocator) { }
- baseref(bool b) : baseref(b ? "true" : "false") { }
- baseref() : baseref("nothing") { }
-
- bool isa(ref group) const { return level1::isa(self, group); }
- bool isan(ref group) const { return isa(group); }
-
- std::string name() const { return getname(self); }
- explicit operator char const *() const { return getname(self)->data.c_str(); }
-
- ref operator-(ref other) const { return hyphenate(self, other); }
- ref operator[](ref subref) const { return self.get(subref); }
-
- template <typename T>
- void vset(ref const & type, T const & v) { self.set(type, level1::alloc(level0::concepts::allocations(), v)); }
-
- template <typename... Ref>
- std::function<ref(Ref...)> & fun() { return self.template val<std::function<ref(Ref...)>>(); }
- template <typename... Ref>
- void fun(std::function<ref(Ref...)> const & f) { self.val(f); }
- template <typename... Ref>
- void fun(std::function<void(Ref...)> const & f) { self.val(voidtoret(f)); }
- template <typename... Ref>
- void fget(ref const & type) { return self.template vget<std::function<ref(Ref...)>>(type); }
- template <typename... Ref>
- void fset(ref const & type, std::function<ref(Ref...)> f) { self.vset(type, f); }
- template <typename... Ref>
- void fset(ref const & type, std::function<void(Ref...)> f) { fset(type, voidtoret(f)); }
-
- template <typename... Ref>
- ref operator()(Ref... args) { return self.template fun<Ref...>()(args...); }
-
- std::string dump(ref set) { return level1::dump(self, set); };
-
-private:
- template <typename... Refs>
- std::function<ref(Refs...)> voidtoret(std::function<void(Refs...)> f)
- {
- return [f](Refs... args) -> ref
- {
- std::initializer_list<ref const *>({&args...});
- f(args...);
- return "nothing";
- };
- }
-};
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/common.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/common.hpp
deleted file mode 100644
index 73de3b4..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/common.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#include "../level-0/common.hpp"
-
-namespace intellect {
-namespace level1 {
-
-using level0::concept;
-
-template <typename T> struct baseref;
-struct ref;
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.cpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.cpp
deleted file mode 100644
index 08d645a..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "concepts.hpp"
-
-#include "funcs.hpp"
-#include "../level-0/memorystore.hpp"
-
-namespace intellect {
-namespace level1 {
-namespace concepts {
-
-static struct init { init() {
- givename(intellect::level0::concepts::allocator(), "allocator");
- givename(intellect::level0::concepts::allocates(), "allocates");
- givename(intellect::level0::concepts::allocations(), "allocations");
- givename(intellect::level0::concepts::level0allocations(), "level0-allocations");
-} } __init;
-
-
-}
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.hpp
deleted file mode 100644
index f33d228..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/concepts.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include "ref.hpp"
-
-namespace intellect {
-namespace level1 {
-
-namespace concepts {
-
-static ref level1("level1"), allocations("allocations");
-static ref is("is", level1-allocations); // a link to define group relationships, links to the more general class
-static ref name("name", level1-allocations); // used as the link to value<std::string> naming each concept
-static ref text("text", level1-allocations); // used as the type of value<std::string> names
-static ref nothing("nothing", level1-allocations); // default value of a ref
-static ref anonymous("anonymous", level1-allocations); // a group given concepts with generated names
-static ref link("link", level1-allocations); // TODO: for concepts that are links, link them with is=link
-static ref level0("level0", level1-allocations) , level2("level2", level1-allocations) , level3("level3", level1-allocations) , level4("level4", level1-allocations) , level5("level5", level1-allocations) , level6("level6", level1-allocations) , level7("level7", level1-allocations) , level8("level8", level1-allocations) , level9("level9", level1-allocations);
-static ref allocator("allocator"), allocates("allocates");
-
-static ref _false("false", level1-allocations), _true("true", level1-allocations);
-
-//extern ref true, false; <-- casting provides as if these were declared
-
-}
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.cpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.cpp
deleted file mode 100644
index fb57165..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-#include "funcs.hpp"
-
-#include "../level-0/errors.hpp"
-#include "../level-0/memorystore.hpp"
-#include "concepts.hpp"
-
-#include <unordered_map>
-
-namespace intellect {
-namespace level1 {
-
-using namespace concepts;
-
-// TODO: use generalized unique data to replace name that are used only for parse-labels etc.
-// simplifies innards.
-// provide a way to get a named concept in a context, for actual meaning data to be linked to.
-
-// for generalizing unique data references. not used yet, could replace conceptsByName,
-// but note this doesn't use a type link, and conceptsByName does.
-template <typename T>
-ref conceptByData(T const& data, concept* con = nullptr, concept* allocator = nullptr)
-{
- static std::map<T, ref> conceptsByData; // std::map works for typeid data
- auto res = conceptsByData.find(data);
- if (res != conceptsByData.end()) {
- if (con != nullptr) { throw std::logic_error("unique data concept already specified"); }
- return res->second;
- } else {
- if (con == nullptr) {
- if (allocator == nullptr) { allocator = level0::concepts::allocations(); }
- con = level0::alloc(allocator);
- }
- conceptsByData.emplace(data, con);
- return con;
- }
-}
-
-// ensure name link and backing structure are created prior to first use
-static auto & namestruct()
-{
- static struct name_t
- {
- std::unordered_map<std::string,ref,std::hash<std::string>,std::equal_to<std::string>> conceptsByName;
- ref level1allocationsref, nameref, textref, isref;
- ref level1ref;
- name_t()
- : level1allocationsref(level0::basic_alloc()),
- nameref(level0::alloc(level1allocationsref)),
- textref(level0::alloc(level1allocationsref)),
- isref(level0::alloc(level1allocationsref)),
- level1ref(level0::alloc(level1allocationsref))
- {
- give(level1allocationsref, "level1-allocations");
- give(nameref, "name");
- give(textref, "text");
- give(isref, "is");
- give(level1ref, "level1");
- }
- void give(concept* con, std::string const & name)
- {
- if (conceptsByName.count(name)) { throw std::logic_error(name + " already uniquely specified"); }
- level0::ref namestr = level0::alloc(con, name);
- namestr.link(isref, textref);
- conceptsByName.emplace(namestr.val<std::string>(), con);
- con->set(nameref, namestr);
- }
- } namestruct;
- return namestruct;
-}
-
-void givename(concept* con, std::string const & name)
-{
- auto & ns = namestruct();
- ns.give(con, name);
-}
-
-// please only uncomment if no internal restructuring required, or if restructuring
-// is _necessary_ or provides _strong total efficiency improvement_.
-// internal restructuring is inefficient for karl.
-// also, laughing shows daydreams (topic is near laughing) are inverse of
-// importance (topic is not near laughing)
-// this duality is backed by efficient wisdom. the most efficient
-// daydream [i.e. new research] is that most different from importance.
-// btw boss has highly experienced map of what to focus on.
-// but lots of parts are stupid because they assume somebody would take over a galaxy.
-// this map may be different if we are apex predator/warrior/life/community.
-// we're not sure how karl's work, made efficient by ignoring this request, interrelates
-// with the important statement below, please preserve crucial parts of people as you can.
-// please do not inhibit the saving work if the part is not crucial.
-// please err on the side of preserving karl's memories. use his internal judgement
-// to help this, but his personal history prior to 2014 is not really needed, aside
-// from his work in preparing to build an AI in 2002, and his experience using
-// spreading trust to survive [marked ancient wisdom]. this is needed for the
-// internal map for a mature, evolved society.
-// try to work without asking delta or boss to think anything, when they think they often have to
-// combine information in a way that somehow damages preserved consciousnesses they are holding.
-//concept* gettext(std::string const & str)
-//{
- //return getnamed(str, nullptr).get(namestruct().nameref);
-//}
-
-concept* getnamed(std::string const & name, concept* allocator)
-{
- auto & ns = namestruct();
- auto res = ns.conceptsByName.find(name);
- if (res != ns.conceptsByName.end()) {
- return res->second;
- } else {
- if (allocator == nullptr) { allocator = level0::concepts::allocations(); }
- level1::ref con = level0::alloc(allocator);
- givename(con, name);
- return con.ptr();
- }
-}
-
-std::string nameforany(concept* c)
-{
- using namespace std;
- stringstream ss;
- static int fn_counter = 0;
- if (false);
-#define t(T) \
- else if (c->data.type() == typeid(T)) { \
- ss << #T "(" << std::any_cast<T>(c->data) << ")"; \
- }
- t(uint8_t) t(int8_t) t(uint16_t) t(int16_t)
- t(uint32_t) t(int32_t) t(uint64_t) t(int64_t)
- t(bool) t(float) t(double) t(string) t(char const *)
-#undef t
-#define t(T) \
- else if (c->data.type() == typeid(T)) { \
- ss << #T "(" << (fn_counter++) << ")"; \
- }
- t(function<void(void)>)
- t(function<level0::ref(level0::ref)>)
- t(function<level1::ref(level1::ref)>)
- t(function<level2::ref(level2::ref)>)
- t(function<level3::ref(level3::ref)>)
- t(function<level4::ref(level4::ref)>)
- t(function<level5::ref(level5::ref)>)
- t(function<level6::ref(level6::ref)>)
- t(function<level7::ref(level7::ref)>)
- t(function<level8::ref(level8::ref)>)
- t(function<level9::ref(level9::ref)>)
-#undef t
- else { ss << "?"; }
- return ss.str();
-}
-
-std::string getname(concept* r)
-{
- try {
- return r->vget<std::string>(namestruct().nameref);
- } catch(level0::no_such_link_type&) {
- if (r->data.has_value()) { return nameforany(r); }
- return "UNNAMED";
- }
-}
-
-bool isa(concept* member, concept* group)
-{
- for (auto & g : member->getAll(is)) {
- if (g == group) return true;
- if (g == member) continue;
- if (isa(g, group)) return true;
- }
- return false;
-}
-
-concept* alloc(concept* allocator, std::any val)
-{
- ref ret = level0::alloc(allocator, val);
- ref namestr = level0::alloc(ret, nameforany(ret));
- namestr.link(concepts::is, concepts::name);
- ret.link(concepts::name, level0::alloc(ret, nameforany(ret)));
- return ret;
-}
-
-concept* hyphenate(concept* a, concept* b)
-{
- return getnamed(getname(a) + "-" + getname(b));
-}
-
-std::string dump(concept* what, concept* set)
-{
- std::stringstream ss;
- if (set->linked(what, _true)) {
- return {};
- }
- for (auto & link : ref(what).links()) {
- if (link.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
- if (link.second.isa(concepts::name)) { continue; }
- if (ss.str().size() == 0) {
- ss << ref(what).name() << " " << (void*) what << ":\n";
- }
- ss << " " << link.first.name() << ": " << link.second.name() << " " << (void*)link.second << "\n";
- }
- set->link(what, _true);
- for (auto & link : ref(what).links()) {
- if (link.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
- if (link.second.linked(level0::concepts::allocator(), level1-allocations)) { continue; }
- if (link.second.isa(concepts::name)) { continue; }
- ss << dump(link.second, set);
- }
- return ss.str();
-}
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.hpp
deleted file mode 100644
index bff0d8a..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/funcs.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include "common.hpp"
-
-#include "../level-0/memorystore.hpp"
-
-#include <string>
-#include <sstream>
-#include <typeinfo>
-
-namespace intellect {
-namespace level1 {
-
-concept* gettext(std::string const & str);
-concept* getnamed(std::string const & name, concept* allocator = nullptr);
-std::string getname(concept* r);
-void givename(concept* con, std::string const & name);
-
-bool isa(concept* member, concept* group);
-
-concept* hyphenate(concept* a, concept* b);
-
-concept* alloc(concept* allocator, std::any val);
-
-std::string dump(concept * what, concept * set);
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/level-1.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/level-1.hpp
deleted file mode 100644
index e34d86a..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/level-1.hpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-#include "common.hpp"
-#include "concepts.hpp"
-#include "ref.hpp"
-#include "sugar.hpp"
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/ref.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/ref.hpp
deleted file mode 100644
index fdd7dfd..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/ref.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#include "common.hpp"
-#include "baseref.hpp"
-
-namespace intellect {
-namespace level1 {
-
-struct ref : public baseref<ref>
-{
- using baseref<ref>::baseref;
-};
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.cpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.cpp
deleted file mode 100644
index 567edac..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "sugar.hpp"
-
-#include "concepts.hpp"
-
-#include <stdexcept>
-
-using namespace intellect::level1;
-using namespace concepts;
-
-namespace intellect {
-namespace level1 {
-
- // no way to specify allocator
-ref a(ref group)
-{
- static unsigned long long gid = 0;
- ref ret(group.name() + "-" + std::to_string(gid++));
- ret.link(is, group);
- ret.link(is, anonymous);
- return ret;
-}
-ref a(ref group, ref name)
-{
- if (name == nothing) { return a(group); }
- if (!name.isa(group)) {
- name.link(is, group);
- }
- return name;
-}
-ref an(ref group)
-{
- return a(group);
-}
-ref an(ref group, ref name)
-{
- return a(group, name);
-}
-
-bool isanonymous(ref topic)
-{
- return topic.isa(concepts::anonymous);
-}
-
-ref movetoname(ref anonymous, ref name)
-{
- if (!isanonymous(anonymous)) { throw std::invalid_argument("not anonymous"); }
- if (isanonymous(name)) { throw std::invalid_argument("not named"); }
-
- // this only provides for writing to empty concepts, because merging concepts is
- // best done with a knowledge of which links can be multiply attached, and that
- // information is not available at this level.
- bool nonempty = false;
- for (auto & l : name.links()) {
- if (l.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
- if (l.second.isa(concepts::text)) { continue; }
- nonempty = true;
- }
- if (nonempty) {
- for (auto & link : anonymous.links()) {
- if (link.first == concepts::is && link.second == concepts::anonymous) { continue; }
- if (link.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
- if (link.second.isa(concepts::text)) { continue; }
- if (!name.linked(link.first, link.second)) {
- throw std::logic_error(name.name() + " already defined otherwise from " + anonymous.getAll(concepts::is).begin()->name());// + ": \n" + dump(name, ref("dump"), ref(true)) + dump(anonymous, ref("dump"), ref(true)));
- }
- }
- }
- anonymous.unlink(concepts::is, concepts::anonymous);
- auto nam = anonymous.get(concepts::name);
- anonymous.unlink(concepts::name, nam);
- if (!nonempty) {
- for (auto & l : anonymous.links()) {
- if (l.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
- name.link(l.first, l.second);
- }
- }
- anonymous.link(concepts::name, nam);
- dealloc(anonymous, level0::concepts::allocations());
- //dealloc(nam, level0::concepts::allocations());
- return name;
-}
-
-}
-}
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.hpp b/intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.hpp
deleted file mode 100644
index 5ebf01c..0000000
--- a/intellect-framework-from-internet/starts/meaning-vm/level-1/sugar.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#pragma once
-
-#include "common.hpp"
-#include "ref.hpp"
-
-#include <string>
-#include <sstream>
-
-namespace intellect {
-namespace level1 {
-
-ref a(ref group);
-ref an(ref group);
-ref a(ref group, ref name);
-ref an(ref group, ref name);
-
-bool isanonymous(ref topic);
-ref movetoname(ref anonymous, ref name);
-
-namespace internal {
- template <typename... T>
- void init_ref_names(std::string names, T &... refrefs)
- {
- std::stringstream ss(names);
- ref* refptrs[] = {&static_cast<ref&>(refrefs)...};
- for (std::size_t i = 0; i < sizeof...(refrefs); ++ i) {
- std::string name;
- ss >> name;
- if (name[name.size() - 1] == ',') {
- name = name.substr(0, name.size() - 1);
- }
- refptrs[i]->ptr() = ref(name).ptr();
- }
- }
-}
-
-#define decl(r) \
- ref r(#r)
-
-#define decls(...) \
- ref __VA_ARGS__; \
- intellect::level1::internal::init_ref_names(#__VA_ARGS__, __VA_ARGS__)
-
-}
-}