From: Thomas Walker Lynch Date: Thu, 15 Jan 2026 19:11:52 +0000 (+0000) Subject: doc up to function X-Git-Url: https://git.reasoningtechnology.com/?a=commitdiff_plain;h=30d0096aee51f7e085e8ccf1e7e1e627e06710f4;p=Epimetheus%2F.git doc up to function --- diff --git a/developer/document/Epimetheus.html b/developer/document/Epimetheus.html index cc461f1..296c665 100644 --- a/developer/document/Epimetheus.html +++ b/developer/document/Epimetheus.html @@ -44,7 +44,7 @@

- Distinctness. + Distinctness.

@@ -52,7 +52,7 @@

- Thus the Symbol (the unique, persistent identity) is the most primitive data entity. Given symbols, and a Turing Machine for building structure, everything else follows. But this is not an article about constructing mathematics or computer science, rather it is about a type system, so lets not get too carried away with the grand strokes of the pen. + Thus the Symbol (the unique, persistent identity) is the most primitive data entity. Given Symbols, and a Turing Machine for building structure, everything else follows. But this is not an article about constructing mathematics or computer science, rather it is about a type system, so lets not get too carried away with the grand strokes of the pen.

Assumptions and Terms

@@ -65,7 +65,7 @@

- The code related to this discussion is implemented in Python; however, issues with other languages are considered. One salient difference involves the fact that Python integers are bignums and are passed by reference. In some other languages, integers are considered primitives, are bounded in magnitude, and are bit-copied. + The code related to this discussion is implemented in Python; however, issues with other languages are considered. One salient difference involves the fact that Python integers are bignums and are passed by reference. In some other languages, integers are considered primitives, are bounded in magnitude, and are bit-copied.

Symbol

@@ -73,56 +73,56 @@

Instance

- We are given a symbol instance factory. Each time the make function on the factory interface is called, the factory returns an instance of a distinct symbol. + We are given a symbol instance factory. Each time the make function on the factory interface is called, the factory returns an instance of a distinct symbol.

- In some languages symbols are implemented over primitive integers, and a symbol instance will be an integer. Thus symbol instances can be copied. A common method for making a copy is to use assignment, e.g., x = y, where y is a variable holding a symbol instance. After execution of the assignment, x will hold another instance of the same symbol. + In some languages symbols are implemented over primitive integers, and a symbol instance will be an integer. Thus symbol instances can be copied. A common method for making a copy is to use assignment, e.g., x = y, where y is a variable holding a symbol instance. After execution of the assignment, x will hold another instance of the same symbol.

- In the Python version of Epimetheus symbols are indeed implemented over integers. However, Python integers are non-primitive and thus are passed by reference. The Python Epimetheus symbol instance factory will return a reference to an integer, not the base integer, as the symbol instance. Assignment will then copy the reference. Thus this reference is the symbol instance rather than the integer the symbol is based on. + In the Python version of Epimetheus symbols are indeed implemented over integers. However, Python integers are non-primitive and thus are passed by reference. The Python Epimetheus symbol instance factory will return a reference to an integer, not the base integer, as the symbol instance. Assignment will then copy the reference. Thus this reference is the symbol instance rather than the integer the symbol is based on.

- In Epimetheus, we use a dictionary to give a symbol a name. The names need not meet the requirements imposed on a symbol instance, but it can be confusing when they don't. This is avoided in other symbol systems by implementing symbols over character strings, and using the character string as both the name and the instance. + In Epimetheus, we use a dictionary to give a symbol a name. The names need not meet the requirements imposed on a symbol instance, but it can be confusing when they don't. This is avoided in other symbol systems by implementing symbols over character strings, and using the character string as both the name and the instance.

Required Properties

- Any two, or by transitivity, any number of, symbol instances can be compared for equality, say x == y. A comparison between symbol instances will always return True or False. + Any two, or by transitivity, any number of, symbol instances can be compared for equality, say x == y. A comparison between symbol instances will always return True or False.

- A symbol instance newly minted using the given symbol factory make function is said to come direct from the factory. A symbol instance direct from the factory is also called an original symbol. + A symbol instance newly minted using the given symbol factory make function is said to come direct from the factory. A symbol instance direct from the factory is also called an original symbol.

- Equality over symbol instances is an equivalence relation: x == x is True; x == y implies y == x; and if x == y and y == z then x == z. + Equality over symbol instances is an equivalence relation: x == x is True; x == y implies y == x; and if x == y and y == z then x == z.

- Any two symbol instances returned directly from the factory using two different make calls will always equality compare to be False. In other words, two distinct originals will always be not equal. + Any two symbol instances returned directly from the factory using two different make calls will always equality compare to be False. In other words, two distinct originals will always be not equal.

- Given an original, all copies stemming from it will be equal to each other and to the original. By stemming from we mean to include all direct copies and copies of copies. + Given an original, all copies stemming from it will be equal to each other and to the original. By stemming from we mean to include all direct copies and copies of copies.

- Given any two originals, say A and B, we know that A is not equal to B, as discussed above. Note also that A is not equal to any copy stemming from B, and B is not equal to any copy stemming from A. + Given any two originals, say A and B, we know that A is not equal to B, as discussed above. Note also that A is not equal to any copy stemming from B, and B is not equal to any copy stemming from A.

- Though symbol instances are integer-like in that copy and equality compare can be used with them, symbol instances are disallowed from being used with other integer operators. Symbols cannot be compared for greater-than or less-than; they cannot be incremented, added, nor subtracted, etc. + Though symbol instances are integer-like in that copy and equality compare can be used with them, symbol instances are disallowed from being used with other integer operators. Symbols cannot be compared for greater-than or less-than; they cannot be incremented, added, nor subtracted, etc.

What is a Symbol?

- Only symbol instances exist at runtime, so a symbol is never manipulated directly. + Only symbol instances exist at runtime, so a symbol is never manipulated directly.

@@ -130,83 +130,93 @@

- The factory’s make returns an original instance that is not equal to any other original. All copies stemming from an original remain in the same equivalence class. Therefore any instance in the class can represent the symbol, and we may choose any one instance as the symbol’s name (a canonical representative), or we could use a dictionary, and use, say, the original instance, to lookup a string as a name, among other possibilities. + The factory’s make returns an original instance that is not equal to any other original. All copies stemming from an original remain in the same equivalence class. Therefore any instance in the class can represent the symbol, and we may choose any one instance as the symbol’s name (a canonical representative), or we could use a dictionary, and use, say, the original instance, to lookup a string as a name, among other possibilities.

Distinctness Across Contexts

- If a symbol persists across contexts (such as across scopes or processes), it must remain distinct from all other symbols as it enters those new environments. + If a symbol persists across contexts (such as across scopes or processes), it must remain distinct from all other symbols as it enters those new environments.

- In this implementation, we meet this constraint by utilizing a global symbol instance factory and by explicitly disallowing a symbol from being employed outside the process of its creation. As a means of enforcement, there are no permitted methods to serialize a symbol to a string, nor to output one to a console or stream. + In this implementation, we meet this constraint by utilizing a global symbol instance factory and by explicitly disallowing a symbol from being employed outside the process of its creation. As a means of enforcement, there are no permitted methods to serialize a symbol to a string, nor to output one to a console or stream.

- These constraints do not apply to symbol names, which are text strings. However, a symbol cannot be recovered from its name; the name is a label, not a reconstruction key. + These constraints do not apply to symbol names, which are text strings. However, a symbol cannot be recovered from its name; the name is a label, not a reconstruction key.

Object

- The term "Python object" refers to anything that can or could appear in legal Python code and could be associated with a symbol. This includes symbols themselves. + The term "Python object" refers to anything that can or could appear in legal Python code and could be associated with a symbol. This includes symbols themselves.

- A symbol is associated with an object using a Python dictionary. The symbol is the key, and the object is that thing which is "looked up" via said key. - One such example is the symbol name dictionary mentioned in the prior section. + A symbol is associated with an object using a Python dictionary. The symbol is the key, and the object is that thing which is "looked up" via said key. + One such example is the symbol name dictionary mentioned in the prior section.

Tape

- In the TTCA, we gave a formal definition for a tape. A tape is an ordered sequence of cells with a leftmost cell, zero or more interior cells, and a rightmost cell. If the tape is infinite, then there is no rightmost cell. The original Turing Machine tape is a symbol tape due to each cell of the tape holding exactly one symbol. The TTCA tape generalizes this by permitting a cell to hold any object. + In the TTCA, we gave a formal definition for a tape. A tape is an ordered sequence of cells with a leftmost cell, zero or more interior cells, and a rightmost cell. If the tape is infinite, then there is no rightmost cell. The original Turing Machine tape is a symbol tape due to each cell of the tape holding exactly one symbol. The TTCA tape generalizes this by permitting a cell to hold any object.

- If a tape is treated as nothing more than its cells, then deleting the last cell causes the tape to no longer exist. In a system that has a higher level structure that preserves the tape as a distinct entity, deleting the last cell produces an empty tape that is said to have zero cells. + Two tapes, say A and B, are equal if and only if they are the same length and all their cells have equal contents. +

+ + A = B \iff \forall i \in \text{indices}, A[i] = B[i] + + +

+ If a tape is treated as nothing more than its cells, then deleting the last cell causes the tape to no longer exist. In a system that has a higher level structure that preserves the tape as a distinct entity, deleting the last cell produces an empty tape entity that is said to have zero cells.

Consider a web browser. When the last tab is closed, the window disappears, forcing the user to create a new window to continue. Some users don't like this behavior, and would prefer that the window to remain as an empty canvas. Then a mistaken close could be undone by selecting 'reopen closed tab', without having to relaunch the browser and resettle the new window into the workspace.
+

- The tape abstraction is particularly expressive in Python, as the language utilizes object references and permits lists to hold objects of any type. Once data within a container is modeled as a tape, structures such as lists, arrays, token streams, argument lists, and sequences all share the same abstract model. + The tape abstraction is particularly expressive in the Python context, as the language utilizes object references and permits lists to hold objects of any type. Once data within a container is modeled as a tape, structures such as lists, arrays, token streams, argument lists, and sequences all share the same abstract model.

Path

-

The term path is an ontological alias for tape. What we mean by 'ontological' is that when using the term path to describe a tape, we pick up a particular way of looking at tapes, and a new nomenclature.

+

The term path is an ontological alias for tape. Adopting the term path brings with it a specialized vocabulary and a semantic framework for discussing traversal. The structure is unchanged, but the interpretation changes, as a tape becomes something to follow.

- The leftmost cell in a path is called the destination. All cells of the path to the right of the destination cell are called the way. - If we were to drop the leftmost cell from the tape, then we would find "the way," if it exists, to be another tape. Hence a path can be thought of as a pair, (destination ,way). + The leftmost cell in a path is called the destination. + All cells of the path to the right of the destination + cell are called the way. If the path has two or more + cells, dropping the leftmost cell leaves a tape holding exactly the + way. Hence a path can be viewed as a pair, + (destination ,way), where the destination is a single + cell and the way is a tape (possibly empty).

- The reader might have expected the path to go from left to right, with the destination on the far right. This would be natural because we read characters from a written page going from right to left. However, such a definition would run into a problem, as left-to-right traversal might not ever end. + The reader might have expected the path to go from left to right, with the destination being in the rightmost cell. This would be natural because we read characters from a written page going from left to right. However, such a definition would run into a problem for us, as we will need for paths to always have a destination, and tapes can be open on the right, so they do not always have a rightmost cell.

- Think about it this way: you are sitting in a pub of an inn, and a stranger walks in. Though you know the stranger's current destination, you might not know where he came from. + Think about it this way: you are sitting in a pub of an inn, and a stranger walks in. Though you know the stranger's current destination, you might not know where he came from.

Discrete Function

- Now consider another tape called F, where each cell holds a path. As a path is a special kind of tape, this new structure, F, is a tape of tapes. + Now consider a tape, say called F, where each cell in F holds a path. As a path is a tape, the structure of F is that of a tape of tapes.

- Now suppose we traverse this new tape while examining the paths as (destination ,way) pairs. If we find that all eual ways lead to - the same destination, then tape F is a discrete Function. We say it is discrete because we F is defined on a tape of discrete cells, and it is based on discrete symbols. We say it is a function due to having this property that all paths with identical ways lead to identical destination. - - - - compare all the paths on this - Suppose that when we + Now suppose we traverse F while examining the paths as (destination ,way) pairs. If we find that all equal ways lead to + the same destination, then tape F is a discrete function. We say it is discrete because F is a tape with distinct cells. We say it is a function due to having the property that all paths with equal ways lead to the same destination. +

- If we compare all paths on said tape and find that no two paths have the same "ways" that lead to different destinations, we call said tape a discrete function. +

+ Thus a function is more restricted than a tape of paths, and due to this restriction it is possible to adopt the following notation, where a destination is said to be determined by, a function of, the way:

@@ -214,11 +224,9 @@

- This notation is possible because the same way always leads to the given destination. + That the same way always leads to the same destination fits our common experience. If we ever followed the same way twice and landed in a different destination we would think ourselves to be in a Sci-Fi movie. It is also intuitive to us that the function restrictions do not exclude the possibility that multiple ways can lead to the same destination. Because we often compute things that are related to our daily experience it is not surprising that this is a very common pattern. And this is not a coincidence, this is the reason functions are defined as they are.

- - - - - - - - - - - -

Introduction

- -

- Epimetheus is a Python library for Higher Order Analysis and Semantic Annotation. A data scientist might say it is a mechanism for Late Binding of ontology, while a programmer will call it a type system. -

- -

- Unlike Prometheus (Forethought), who defines what an object is before it is born (classic class instantiation), Epimetheus allows you to attach meaning, identity, and semantic types to objects after they exist. -

- -

- In standard programming, the primitives are things like - int, float, char, or boolean. These carry inherent meaning and behavior before you ever use them. An integer is a number; it must add and subtract. -

- -

- Epimetheus (Afterthought) rejects this. It allows you to attach meaning (semantics) to objects after they are born. You can decide later that an object behaves like a number, or a string, or a user. -

- -

- If you strip away all pre-defined types and behaviors (no ints, no strings, no classes), what is left? What is the one thing you absolutely cannot add later? -

- -

- Distinctness. -

- -

- You cannot attach meaning to an object if you cannot point to it. You cannot say "This object is a Number" if you cannot distinguish "This object" from "That object." -

- -

- Thus the Symbol (the unique, persistent identity) is the most primitive data entity. Given symbols, and a Turing Machine for building structure, everything else follows. But this is not an article about constructing mathematics or computer science, rather it is about a type system, so lets not get too carried away with the grand strokes of the pen. -

- -

Assumptions and Terms

- -

Given

- -

- As is apparent while you read this, English prose is a given. Our goal in using it is to show that the code is self-consistent without the English description. Once the formal relations are established, the prose becomes moot, as the logic permits no dependence on the medium used for its introduction. In other words, code does not read the comments to decide what to do. -

- -

- The code related to this discussion is implemented in Python; however, issues with other languages are considered. One salient difference involves the fact that Python integers are bignums and are passed by reference. In some other languages, integers are considered primitives, are bounded in magnitude, and are bit-copied. -

- -

Symbol

- -

Instance

- -

- We are given a symbol instance factory. Each time the make function on the factory interface is called, the factory returns an instance of a distinct symbol. -

- -

- In some languages symbols are implemented over primitive integers, and a symbol instance will be an integer. Thus symbol instances can be copied. A common method for making a copy is to use assignment, e.g., x = y, where y is a variable holding a symbol instance. After execution of the assignment, x will hold another instance of the same symbol. -

- -

- In the Python version of Epimetheus symbols are indeed implemented over integers. However, Python integers are non-primitive and thus are passed by reference. The Python Epimetheus symbol instance factory will return a reference to an integer, not the base integer, as the instance. Assignment will then copy the reference. Thus this reference is the symbol instance rather than the integer the symbol is based on. -

- -

- In Epimetheus, we use a dictionary to give a symbol a name. The names need not meet the requirements imposed on a symbol instance, but it can be confusing when they don't. This is avoided in other symbol systems by implementing symbols over character strings, and using the character string as both the name and the instance. -

- -

Required Properties

- -

- Any two, or by transitivity, any number of, symbol instances can be compared for equality, say x == y. A comparison between symbol instances will always return True or False. -

- -

- A symbol instance newly minted using the given symbol factory make function is said to come direct from the factory. A symbol instance direct from the factory is also called an original symbol. -

- -

- Equality over symbol instances is an equivalence relation: x == x is True; x == y implies y == x; and if x == y and y == z then x == z. -

- -

- Any two symbol instances returned directly from the factory using two different make calls will always equality compare to be False. In other words, two distinct originals will always be not equal. -

- -

- Given an original, all copies stemming from it will be equal to each other and to the original. By stemming from we mean to include all direct copies and copies of copies. -

- -

- Given any two originals, say A and B, we know that A is not equal to B, as discussed above. Note also that A is not equal to any copy stemming from B, and B is not equal to any copy stemming from A. -

- -

- Though symbol instances are integer-like in that copy and equality compare can be used with them, symbol instances are disallowed from being used with other integer operators. Symbols cannot be compared for greater-than or less-than; they cannot be incremented, added, nor subtracted, etc. -

- - -

What is a Symbol?

- -

- Only symbol instances exist at runtime, so a symbol is never manipulated directly. -

- -

- Define a relation ~ over instances by x ~ y iff x == y. Since == is an equivalence relation, this partitions instances into equivalence classes. Each such equivalence class is a Symbol. -

- -

- The factory’s make returns an original instance that is not equal to any other original. All copies stemming from an original remain in the same equivalence class. Therefore any instance in the class can represent the symbol, and we may choose any one instance as the symbol’s name (a canonical representative), or we could use a dictionary, and use, say, the original instance, to lookup a string as a name, among other possibilities. -

- -

Distinctness Across Contexts

-

- If a symbol persists across contexts (such as across scopes or processes), it must remain distinct from all other symbols as it enters those new environments. -

- -

- In this implementation, we meet this constraint by utilizing a global symbol instance factory and by explicitly disallowing a symbol from being employed outside the process of its creation. As a means of enforcement, there are no permitted methods to serialize a symbol to a string, nor to output one to a console or stream. -

- -

- These constraints do not apply to symbol names, which are text strings. However, a symbol cannot be recovered from its name; the name is a label, not a reconstruction key. -

- -

Identity and Entity

-

- We distinguish between the handle and the state to ensure the logic remains self-consistent. The Instance is the unique symbol returned by the factory; it serves as the persistent handle for an entity. -

- -

- The Identity is the memory selectively bound to an interface to provide state. When an instance is associated with an identity through a shared interface, they constitute a separate entity. -

- -

Tape

- -

- In the TTCA, we gave a formal definition for a tape. A tape is an ordered sequence of cells with a leftmost cell, zero or more interior cells, and a rightmost cell. If the tape is infinite, then there is no rightmost cell. The original Turing Machine tape is a symbol tape due to each cell of the tape holding exactly one symbol. The TTCA tape generalizes this by permitting a cell to hold any object. -

- -

- If a tape is treated as nothing more than its cells, then deleting the last cell causes the tape to no longer exist. In a system that has a higher level structure that preserves the tape as a distinct entity, deleting the last cell produces an empty tape that is said to have zero cells. -

- -
- Consider a web browser. When the last tab is closed, the window disappears, forcing the user to create a new window to continue. Some users don't like this behavior, and would prefer that the window to remain as an empty canvas. Then a mistaken close could be undone by selecting 'reopen closed tab', without having to relaunch the browser and resettle the new window into the workspace. -
- -

- The tape abstraction is particularly expressive in Python, as the language utilizes object references and permits lists to hold objects of any type. Once data within a container is modeled as a tape, structures such as lists, arrays, token streams, argument lists, and sequences all share the same abstract model. -

- - -

Path

- -

The term path is an ontological alias for tape. What we mean by 'ontological' is that when using the term path to describe a tape, we pick up a particular way of looking at tapes, and a new nomenclature.

- -

- The leftmost cell in a path is called the destination. All cells of the path to the right of the destination cell are called the way. - If we were to drop the leftmost cell from the tape, then we would find "the way," if it exists, to be another tape. Hence a path can be thought of as a pair, (destination , the way). -

- -

- The reader might have expected the path to go from left to right, with the destination on the far right. This would be natural because we read characters from a written page going from right to left. However, such a definition would run into a problem, as left-to-right traversal might not ever end. -

- -
- Think about it this way: you are sitting in a pub of an inn, and a stranger walks in. Though you know the stranger's current destination, you might not know where he came from. -
- -

Discrete Function

-

- Now consider another tape called F, where each cell holds a path. As a path is a special kind of tape, this new structure, F, is a tape of tapes. -

- -

- Now suppose we traverse this new tape while examining the paths as (destination , the way) pairs. If we find that all equal ways lead to the same destination, then tape F is a discrete function. -

- - - destination = f(way) - - -

- This notation is valid because the same way always leads to the same destination. -

- - - -
- -