From: Thomas Walker Lynch Date: Thu, 15 Jan 2026 11:50:49 +0000 (+0000) Subject: doc better term formatter X-Git-Url: https://git.reasoningtechnology.com/style/RT_TOC.js?a=commitdiff_plain;h=c706eeb231ba38f59b93181f6ab6eb60879564e4;p=Epimetheus%2F.git doc better term formatter --- diff --git a/developer/document/Epimetheus.html b/developer/document/Epimetheus.html index 7ea3635..cc461f1 100644 --- a/developer/document/Epimetheus.html +++ b/developer/document/Epimetheus.html @@ -44,7 +44,7 @@

- Distinctness. + Distinctness.

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

- Therefore, the Symbol (the unique, persistent identity) is the Only Primitive. It is the atomic unit of the universe. Everything else—semantics, types, relationships, values, are merely metadata layered on top of that primitive identity. + 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

diff --git a/developer/document/Epimetheus_2.html b/developer/document/Epimetheus_2.html new file mode 100644 index 0000000..714b660 --- /dev/null +++ b/developer/document/Epimetheus_2.html @@ -0,0 +1,216 @@ + + + + + Epimetheus: The Only Primitive + + + + + + + + + + + + +

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. +

+ + + +
+ + diff --git a/developer/document/style/RT_term.js b/developer/document/style/RT_term.js index c2c2b4a..1dec8fb 100644 --- a/developer/document/style/RT_term.js +++ b/developer/document/style/RT_term.js @@ -4,50 +4,104 @@ - The "-em" variants (e.g., ) are always styled. - Automatically generates IDs for first occurrences for future indexing. */ + window.StyleRT = window.StyleRT || {}; window.StyleRT.RT_term = function() { const RT = window.StyleRT; - const debug = RT.debug || { log: function(){} }; - - // Track seen terms to ensure only the first one gets decorated - const seen_terms = new Set(); - - // Helper to apply professional "Definiendum" styling - const apply_style = (el, is_neologism) => { - el.style.fontStyle = 'italic'; - el.style.fontWeight = is_neologism ? '600' : '500'; - el.style.color = is_neologism ? 'var(--rt-brand-secondary)' : 'var(--rt-brand-primary)'; - el.style.paddingRight = '0.1em'; // Compensation for italic slant - el.style.display = 'inline'; + + const debug = RT.debug || { + log: function() {} + ,warn: function() {} + ,error: function() {} }; - // Selector covers all four variations - const tags = document.querySelectorAll('rt-term, rt-term-em, rt-neologism, rt-neologism-em'); - - tags.forEach(el => { - const tag_name = el.tagName.toLowerCase(); - const is_neologism = tag_name.includes('neologism'); - const is_explicit_em = tag_name.endsWith('-em'); - - // Normalize text for comparison (e.g., "Symbol" vs "symbol") - const term_text = el.textContent.trim().toLowerCase(); - const slug = term_text.replace(/\s+/g, '-'); - - if (is_explicit_em || !seen_terms.has(term_text)) { - apply_style(el, is_neologism); - - // If it's the first occurrence, mark it and give it an ID - if (!is_explicit_em && !seen_terms.has(term_text)) { - seen_terms.add(term_text); - if (!el.id) el.id = `def-${is_neologism ? 'neo-' : ''}${slug}`; - debug.log('RT_term', `Defined first instance of: ${term_text}`); - } - } else { - // For subsequent mentions that aren't "-em", we treat as normal prose + const DEBUG_TOKEN_S = 'term'; + + try { + // Track seen terms so only the first occurrence is decorated + const seen_terms_dpa = new Set(); + + const apply_style = (el, is_neologism_b) => { + el.style.fontStyle = 'italic'; + el.style.fontWeight = is_neologism_b ? '600' : '500'; + el.style.color = is_neologism_b + ? 'var(--rt-brand-secondary)' + : 'var(--rt-brand-primary)'; + el.style.paddingRight = '0.1em'; // Compensation for italic slant + el.style.display = 'inline'; + }; + + const clear_style = (el) => { el.style.fontStyle = 'normal'; el.style.color = 'inherit'; el.style.fontWeight = 'inherit'; - } - }); + el.style.paddingRight = ''; + el.style.display = ''; + }; + + const selector_s = [ + 'rt-term' + ,'rt-term-em' + ,'rt-neologism' + ,'rt-neologism-em' + ].join(','); + + const tags_dpa = document.querySelectorAll(selector_s); + + debug.log(DEBUG_TOKEN_S, `Scanning ${tags_dpa.length} term tags`); + + tags_dpa.forEach(el => { + const tag_name_s = el.tagName.toLowerCase(); + const is_neologism_b = tag_name_s.includes('neologism'); + const is_explicit_em_b = tag_name_s.endsWith('-em'); + + const term_text_raw_s = (el.textContent || '').trim(); + if (!term_text_raw_s.length) { + debug.warn(DEBUG_TOKEN_S, `Empty term tag encountered: <${tag_name_s}>`); + return; + } + + // Normalize text for uniqueness tracking + const term_norm_s = term_text_raw_s.toLowerCase(); + + // Slug for ID generation (simple + stable) + const slug_s = term_norm_s.replace(/\s+/g, '-'); + + const is_first_occurrence_b = !seen_terms_dpa.has(term_norm_s); + + if (is_explicit_em_b || is_first_occurrence_b) { + apply_style(el, is_neologism_b); + + if (!is_explicit_em_b && is_first_occurrence_b) { + seen_terms_dpa.add(term_norm_s); + + if (!el.id) { + el.id = `def-${is_neologism_b ? 'neo-' : ''}${slug_s}`; + debug.log( + DEBUG_TOKEN_S + ,`First occurrence: "${term_norm_s}" -> id="${el.id}"` + ); + } else { + debug.log( + DEBUG_TOKEN_S + ,`First occurrence: "${term_norm_s}" (existing id="${el.id}")` + ); + } + } else if (is_explicit_em_b) { + debug.log( + DEBUG_TOKEN_S + ,`Emphasized occurrence: "${term_norm_s}" (<${tag_name_s}>)` + ); + } + } else { + // Subsequent mentions render as normal prose + clear_style(el); + } + }); + + debug.log(DEBUG_TOKEN_S, `Unique terms defined: ${seen_terms_dpa.size}`); + } catch (e) { + debug.error('error', `RT_term failed: ${e && e.message ? e.message : String(e)}`); + } }; diff --git a/developer/document/style/utility.js b/developer/document/style/utility.js index ae64e97..258eb28 100644 --- a/developer/document/style/utility.js +++ b/developer/document/style/utility.js @@ -6,12 +6,19 @@ window.StyleRT = window.StyleRT || {}; // --- DEBUG SYSTEM --- window.StyleRT.debug = { - // ENABLE 'selector', 'config', and 'error' so we aren't flying blind! + + // all debug messages enabled +/* active_tokens: new Set([ - 'style', 'layout', 'pagination', - 'selector', 'config', 'error' + 'style', 'layout', 'pagination' + ,'selector', 'config', 'error' + ,'term' ]), - +*/ + active_tokens: new Set([ + 'term' + ]), + log: function(token, message) { if (this.active_tokens.has(token)) { console.log(`[StyleRT:${token}]`, message); diff --git a/developer/document/style_manual.html b/developer/document/style_manual.html index 055bedd..afb7e69 100644 --- a/developer/document/style_manual.html +++ b/developer/document/style_manual.html @@ -50,33 +50,74 @@

Terminology

+

Conventional Terms

- Use <RT-term> for standard, industry-accepted technical terms. + Use <RT-term> for standard, industry accepted technical terms. The system decorates only the first occurrence of each unique term so that the first appearance functions as a definition point, and later appearances do not overload the page with styling.

+ The Singleton Pattern restricts instantiation... +

Renders as: The Singleton Pattern restricts instantiation...

-

Neologisms (Novel Concepts)

+

Neologisms

- Use <RT-neologism> for terms invented specifically for the current document or project. This visually distinguishes "jargon you should know" from "jargon we just made up." + Use <RT-neologism> for terms invented specifically for the current document or project. Neologisms are styled more strongly than conventional terms, visually distinguishing "jargon you should know" from "jargon we just made up."

+ -We define the Hyper-Tape as a construct... +We define the Hyper Tape as a construct... + +

+ Renders as: We define the Hyper Tape as a construct... +

+ +

First Occurrence Rule

+

+ The term system is intentionally conservative. For the tags <RT-term> and <RT-neologism>, only the first occurrence of a unique term is decorated. Subsequent mentions are rendered as normal prose. +

+ +

+ Uniqueness is tracked by normalizing the term text (trimmed, then lowercased). This means that Symbol and symbol count as the same term. +

+ +

Forced Emphasis Variants

+

+ Sometimes a later mention of a term should be emphasized again. For that purpose, the system provides explicit emphasis tags: +

+ + + +

+ These variants are always decorated, even if the term appeared earlier. +

+ +

Automatic Definition Anchors

+

+ For first occurrences, the term module automatically assigns an id attribute if one does not already exist. This creates stable anchors for future indexing and linking. +

+ + +We define a Symbol as... + +

- Renders as: We define the Hyper-Tape as a construct... + The first occurrence will be given an id similar to def-symbol. For neologisms, an additional marker is used, for example def-neo-hyper-tape.

Technical Content

Code

- Use <RT-code>. If placed inline, it acts like a span. If placed as a block (with newlines), it acts like a pre-formatted block with a theme-aware border. + Use <RT-code>. If placed inline, it acts like a span. If placed as a block (with newlines), it acts like a pre formatted block with a theme aware border.

@@ -87,7 +128,7 @@ def hello():

Mathematics

- Use <RT-math>. The system auto-detects if it is a block equation or inline variable and wraps it in MathJax delimiters. + Use <RT-math>. The system auto detects if it is a block equation or inline variable and wraps it in MathJax delimiters.

Inline: Let x be the input. @@ -106,7 +147,7 @@ def hello(): Use <RT-TOC> to insert a generated table of contents. The tag scans the document forward from its current position to collect headings.

-

Explicit Mode (Recommended)

+

Explicit Mode

Use the level="N" attribute to target a specific heading depth.

@@ -115,15 +156,14 @@ def hello():
  • <RT-TOC level="2">: Collects all <h2> elements until it encounters the next <h1>. Best for chapter summaries.
  • -

    Implicit Mode (Context Aware)

    +

    Implicit Mode

    - If no level is specified, the TOC scans backwards to find the nearest heading (e.g., H1) and assumes you want to collect children one level deeper (e.g., H2). + If no level is specified, the TOC scans backwards to find the nearest heading (for example H1) and assumes you want to collect children one level deeper (for example H2).

    - Note: Implicit mode can fail if placed before the first heading of a section (the "Halting Problem" scenario). Use explicit levels for robust results. + Note: Implicit mode can fail if placed before the first heading of a section. Use explicit levels for robust results.

    -

    The Title Block

    Use <RT-title> as the first element in your <body> (before the article container). This tag generates a standardized, styled header block with the document title and metadata. @@ -144,8 +184,9 @@ def hello(): date="2026-01-14"> +

    - Renders as: A centered, high-contrast H1 followed by a serif-styled metadata row containing the author and date, separated by an em-dash. + Renders as: A centered, high contrast H1 followed by a serif styled metadata row containing the author and date.

    The Article Container

    @@ -158,26 +199,62 @@ def hello(): The script paginate_by_element.js scans the article. It calculates the height of every element (including margins) and bundles them into <RT-page> elements.

    - Soft-Limit Pagination: The system attempts to keep headers with their following paragraphs. It will break a page early rather than stranding a header at the bottom. + Soft Limit Pagination: The system attempts to keep headers with their following paragraphs. It will break a page early rather than stranding a header at the bottom. +

    + +

    Debugging

    + +

    Debug Tokens

    +

    + RT provides a lightweight debug logging system in utility.js. Logging is controlled by a set of active debug tokens. Each log message is assigned a token, and the message prints only if that token is enabled. +

    + +

    + Examples of common tokens include style, layout, pagination, selector, config, and term. +

    + +

    How Logging is Gated

    +

    + Normal log and warning output are gated. The methods debug.log(token,message) and debug.warn(token,message) will print only when the token exists in debug.active_tokens. +

    + +

    + This prevents the console from being flooded during normal use, while still allowing deep visibility during development. +

    + +

    Errors are Always Printed

    +

    + Errors are treated differently. The method debug.error(token,message) always prints, regardless of token state. These messages represent failures that require attention. +

    + +

    Enabling and Disabling Tokens

    +

    + Tokens may be enabled or disabled in two ways: by editing the active_tokens set in utility.js, or at runtime by calling: +

    + + +window.StyleRT.debug.enable('term') +window.StyleRT.debug.disable('term') + + +

    + For example, the term system (RT_term.js) uses the term token. When that token is enabled, the module will print messages describing how terms were detected and which term definitions were assigned IDs.

    Themes

    - The system supports hot-swapping themes by changing the script import in the head. + The system supports hot swapping themes by changing the script import in the head.

    • Dark: style/theme_dark_gold.js (Default)
    • Light: style/theme_light_gold.js
    -

    Recovery Manifest

    -

    - If memory is lost, ensure these files exist in style/: -

    +

    Manifest

    -1. style_orchestrator.js (The brain) +1. style_orchestrator.js (Example/default footer script) 2. utility.js (Math/Color physics) -3. article_tech_ref.js (Typography & CSS injection) +3. article_tech_ref.js (Typography and CSS injection) 4. RT_code.js (Code block logic) 5. RT_math.js (MathJax wrapper) 6. RT_term.js (Term styling)