Skip to content

Commit

Permalink
Moving some thoughts/docs around
Browse files Browse the repository at this point in the history
  • Loading branch information
FadiShawki committed Feb 21, 2024
1 parent e788ae3 commit b1a2b00
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 71 deletions.
89 changes: 22 additions & 67 deletions environments/python/_temp/Ray.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,23 @@
import JS, {NotImplementedError} from "@orbitmines/js";

namespace Ray {

/** A simplistic compiler for Ray */
export namespace Compiler { // TODO Ray is Compiler

/**
*
* TODO: Reference maybe as an orbit at the point is the thing ignorant
*
* TODO: Compiler could have things like other composed rays which tell it cares about the other (even if that's correct or not??)
*
* TODO: Do I want to keep the is_equiv/is_composed pattern? Or simplify to one of the two?
*
* // TODO: NEVER DIRECTLY EXECUTE, ONLY AFTER CHAIN OF FUNCS, possibly arbitrarily LAZY
*
* TODO
* - Compose empty as first element? Disregard none to first elemn? Or not??
*
* TODO; Impl
* - Generally, return something which knows where all continuations are.
* - Generator/step function/... ; with no assumption of halting, but allow to hook into any step.
* - Cache:
* - Control of (non-/)lazyness of functions
* - None as, first time called, memoize func.
* - Perhaps locally cache (for stuff like count?) - no way to ensure globally coherence
* - a.orbit() -> a.orbit(a)
* // TODO: Should be automatic? is_orbit() or any method without arguments is a.is_orbit(a.self()) ?? not a.is_orbit(a) ; ???
*
*
* TODO: Allow hooking
*
* TODO: Testing
* - Test if references hold after equivalence/composition...
*
* TODO: After initial demo:
* - Allow mapping/finding of other implementations regarding some equiv funcs (like different ways of implementing using NAND etc...)
*
* Arbitrary.
*
* TODO Pass a single ray to the runtime, and run that way? Access runtime as variable from ray? That would have programs accessing possible runtimes?
*/
}

/** Ray is an Enum(eration) */
export namespace Enum {

export type Type<T extends Array<string>> = {
[TKey in T[number]]: Ray.Any
}

export const Impl = <T extends Array<string>>(...enumeration: T): Type<T> => {
return Object.fromEntries(enumeration.map(value =>
[value, Ray.Function.None.Impl((): Ray.Any => {
throw new NotImplementedError(); // TODO
})]
)) as Type<T>;
// TODO: ONE OF 4 SELECTION RAY for the case of type.
}

}

}

// TODO

export default Ray;
/**
* TRAVERSAL
* - Generally, return something which knows where all continuations are.
*
* TODO
* - Compose empty as first element? Disregard none to first elemn? Or not??
*
* - a.orbit() -> a.orbit(a)
* // TODO: Should be automatic? is_orbit() or any method without arguments is a.is_orbit(a.self()) ?? not a.is_orbit(a) ; ???
*
*/


/**
* TODO: Compiler could have things like other composed rays which tell it cares about the other (even if that's correct or not??) - This is context/assumed global context.
*
*/

/**
* TODO: Testing
* - Test if references hold after equivalence/composition...
*/
1 change: 1 addition & 0 deletions environments/python/orbitmines/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test() -> Ray:

# test.compile(python).run(python)

# Hence the difference between add/sub and a normal boolean. Is context. What add/sub is applied to; i.e. what effects it has.
# These should be the same
# def add(self) -> Ray: return -self.sub
# def sub(self) -> Ray: return -self.add
Expand Down
30 changes: 26 additions & 4 deletions environments/python/orbitmines/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# TODO: Better python solution than just @ray everywhere (for typechecker)

# TODO: match, switch
# TODO: match, switch, enum (like key=value), dict, keyvalue, pair, ....
# TODO: zip, tensor (are these the same as match/switch?)

def ray(func: Callable[[Any, ...], Any]) -> Ray:
Expand All @@ -25,6 +25,10 @@ def __setattr__(self, key, value) -> Any:
print(f'__setattr__{key}={value}')
pass

#
# "Arbitrarily partial/.../parallel/superposed" TODO? better name
# The concept is never really direct execution, and if it is, that's often more like ignorance. Basically, arbitrary lazyness. Like this we basically rephrase "output" or "halting" as "what if we assume it halts here". Inaccessible, ..., Ignorant ones turn into the inability to ask that question.
# @see "What if this wasn't the case?" https://orbitmines.com/papers/on-orbits-equivalence-and-inconsistencies#:~:text=%22What%20if%20this%20wasn%27t%20the%20case%3F%22
#
#
# In the case of Rays, whether something is a vertex/initial/terminal is only inferred from surrounding context. And these checks only need to happen locally in order to decide how to traverse arbitrary structure (as in - I only need to check the presence of something next to me, not traverse the whole direction recursively in order to decide what to do).
Expand All @@ -36,8 +40,13 @@ def __setattr__(self, key, value) -> Any:
# - Note that whenever you have a self-reference through operators, that requires an implementation to break this self-reference. For example ray functionality only requires initial + negative, or terminal + negative, or initial + terminal, to make all the other three.
#
#
# @staticmethod: Implement a function from no (or: an ignorant) perspective.
# method(self): Implement a function from the perspective of 'this'
# "Naming, ..., Grouping"
# TODO: This is basically: When to decide that perspective switches should have a different name associated with them, when they can probably be thrown in a bag with other stuff: I.e. Why is it so significantly different it should be separate?
# - ex: TODO: Do I want to keep the is_equiv/is_composed pattern? Or simplify to one of the two?
#
# These basically fall under naming/grouping
# @staticmethod: Implement a function from no (or: an ignorant) perspective.
# method(self): Implement a function from the perspective of 'this'
class Ray:
def __init__(self, *args, **kwargs):
# TODO: Named args in the sense, similar to class definition, in the sense that they equivalences on the existing functions. Again this thing of assign.
Expand Down Expand Up @@ -179,6 +188,9 @@ def is_vertex(self) -> Ray: return self.is_initial().nor(self.is_terminal())
@ray
def is_reference(self) -> Ray: return self.is_initial() & self.is_terminal() # [ | ]
# TODO: reference = pointer ...
# TODO: Reference maybe as an orbit at the point is the thing ignorant
# TODO: This is basically saying "reference as a constant"
# TODO Could say orbit = constant, meaning this entire direction repeats??? - maybe it's slightly different
@ray
def is_boundary(self) -> Ray: return self.is_initial() ^ self.is_terminal() # [?-| ] or [ |-?]

Expand Down Expand Up @@ -422,11 +434,14 @@ def __exit__(self, exc_type, exc_val) -> Ray: raise NotImplementedError
async def __aenter__(self) -> Ray: raise NotImplementedError
async def __aexit__(self, exc_type, exc_val) -> Ray: raise NotImplementedError


def __floordiv__(self, item): raise NotImplementedError

# TODO: THESE ARE ALL MAPS.
def __contains__(self, item): raise NotImplementedError
def __delitem__(self, item): raise NotImplementedError
def __getitem__(self, item): raise NotImplementedError
def __setitem__(self, key, value): raise NotImplementedError
def __floordiv__(self, item): raise NotImplementedError
def __pos__(self): raise NotImplementedError

@ray
Expand Down Expand Up @@ -516,6 +531,11 @@ def arbitrary(val: Arbitrary) -> Ray:

raise NotImplementedError

#
# Some functions which demonstrate control of (non-/)lazyness of functions
# TODO: this concept should be expanded (more like ignorant function calls from certain perspectives).
#

@staticmethod
# - TODO: readonly setup, where only traversal ops are allowed. Of course these are writing in some sense, but those writings aren't directly accessible from this perspective
def readonly() -> Ray: raise NotImplementedError
Expand All @@ -528,6 +548,8 @@ def memoized(self) -> Ray:
# res.initial = self
# return res
raise NotImplementedError
# TODO = cached
# TODO: Better ideas what local caching looks like, (i.e. put it in some local structure to cache, this can be delayed till some useful implementation is ready)

# print(f'{type(func)}')
# def method(*args, **kwargs) -> Ray:
Expand Down

0 comments on commit b1a2b00

Please sign in to comment.