From 6649aadd48c3d2c3ed3c733cebeb8429561f23f5 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Mon, 12 Jan 2026 13:53:00 +0000 Subject: [PATCH] doc started, uses js style formatting, pages were working but not now... --- developer/document/Epimetheus.html | 139 +++++++++++++++++ developer/document/style/RT_code.js | 66 ++++++++ developer/document/style/RT_math.js | 35 +++++ developer/document/style/RT_term.js | 22 +++ developer/document/style/article_generic.js | 21 +++ .../document/style/body_visibility_hidden.js | 12 ++ .../document/style/body_visibility_visible.js | 13 ++ developer/document/style/do_style.js | 89 +++++++++++ developer/document/style/page.js | 40 +++++ developer/document/style/page_each_H1.js | 43 ++++++ developer/document/style/theme_RT.js | 22 +++ developer/document/style/toc.js | 46 ++++++ developer/document/style/utility.js | 106 +++++++++++++ developer/document/test.html | 146 ++++++++++++++++++ developer/document/theory.html | 119 ++++++++++++++ 15 files changed, 919 insertions(+) create mode 100644 developer/document/Epimetheus.html create mode 100644 developer/document/style/RT_code.js create mode 100644 developer/document/style/RT_math.js create mode 100644 developer/document/style/RT_term.js create mode 100644 developer/document/style/article_generic.js create mode 100644 developer/document/style/body_visibility_hidden.js create mode 100644 developer/document/style/body_visibility_visible.js create mode 100644 developer/document/style/do_style.js create mode 100644 developer/document/style/page.js create mode 100644 developer/document/style/page_each_H1.js create mode 100644 developer/document/style/theme_RT.js create mode 100644 developer/document/style/toc.js create mode 100644 developer/document/style/utility.js create mode 100644 developer/document/test.html create mode 100644 developer/document/theory.html diff --git a/developer/document/Epimetheus.html b/developer/document/Epimetheus.html new file mode 100644 index 0000000..cd06c98 --- /dev/null +++ b/developer/document/Epimetheus.html @@ -0,0 +1,139 @@ + + + + + Epimetheus: The Only Primitive + + + + + + + +

Given

+

The English language is a given, apparently.

+

+ This discussion happens to appear in the context of a Python language + implementation, though it applies equally as well to other languages. +

+ +

Symbol

+

Definition

+

+ We have a symbol instance factory. Each time the make + method on the factory is called, the factory returns an instance of a + distinct symbol. +

+ +

+ A symbol instance may be copied as though it were an integer. Thus, a + common method for making a copy is 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 symbol. +

+ +

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

+ +

+ It follows that any two symbol instances directly returned from the + factory will always equality compare to be False. +

+ +

+ An equivalence set of symbol instances is a functional representation of + the symbol. The name of this set is yet another instance of said symbol. + Thus, every instance of the symbol represents the symbol. +

+ +

+ Though symbol instances are integer-like for copy and equality compare, + they 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. +

+ +

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 into those + new processes or contexts. +

+ +

+ In this implementation, we meet this constraint by using a global symbol + factory and by explicitly disallowing a symbol from being used outside + the process it was made in. +

+ +

Object

+

Definition

+

+ The term "Python object" refers to anything that can or could + appear in 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. +

+ +

Path

+

Individual Path

+

+ In the TTCA, we provided a formal definition for a "tape." A tape has a + leftmost cell, one or more "in-between" cells, and a rightmost cell. + A "path" is a special case of a tape with additional constraints. +

+ +

+ Each cell of a path holds a symbol. The leftmost cell is called the + destination. The reader might have expected the path + to go from left to right, but 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. +
+ +

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

+ +

Discrete Function

+

+ Consider another tape where each cell holds a path. If we compare all + paths on said tape and find that no two identical "ways" lead to + different destinations, we call said tape a discrete function. +

+ + + destination = f(way) + + +

+ This notation is possible because the same way always leads to the given + destination. +

+ + + + + + diff --git a/developer/document/style/RT_code.js b/developer/document/style/RT_code.js new file mode 100644 index 0000000..e5c8266 --- /dev/null +++ b/developer/document/style/RT_code.js @@ -0,0 +1,66 @@ +/* + Processes tags using StyleRT utilities. + Instrumented with token-based debugging. +*/ +function RT_code() { + const RT = window.StyleRT; + const U = RT.utility; + const debug = RT.debug; + + debug.log('RT_code', 'Starting render cycle.'); + + // 1. Fetch Theme + const theme = RT.active_theme ? RT.active_theme() : {}; + const accent = theme.accent || 'gold'; + + // 2. Physics + const metrics = U.measure_ink_ratio('monospace'); + + document.querySelectorAll('rt-code').forEach((el, index) => { + el.style.fontFamily = 'monospace'; + + // Analysis + const is_block = U.is_block_content(el); + const parentStyle = window.getComputedStyle(el.parentElement); + const parentColor = parentStyle.color; + + // Physics + const is_text_light = U.is_color_light(parentColor); + + if (index === 0) { + // Always log the first one if token is active, for sanity check + debug.log('RT_code', `Sample #0: Parent Color "${parentColor}" -> Detect Light? ${is_text_light}`); + } + + // Visuals + const alpha = is_block ? 0.08 : 0.15; + const overlay = is_text_light ? `rgba(255,255,255,${alpha})` : `rgba(0,0,0,${alpha})`; + const text_color = is_text_light ? '#ffffff' : '#000000'; + + el.style.backgroundColor = overlay; + + if (is_block) { + el.style.display = 'block'; + el.style.whiteSpace = 'pre'; + el.style.fontSize = (parseFloat(parentStyle.fontSize) * metrics.ratio * 0.95) + 'px'; + el.style.padding = '1.2rem'; + el.style.margin = '1.5rem 0'; + el.style.borderLeft = `4px solid ${accent}`; + el.style.color = 'inherit'; + } else { + el.style.display = 'inline'; + const exactPx = parseFloat(parentStyle.fontSize) * metrics.ratio * 1.0; + el.style.fontSize = exactPx + 'px'; + el.style.padding = '0.1rem 0.35rem'; + el.style.borderRadius = '3px'; + const offsetPx = metrics.baseline_diff * (exactPx / 100); + el.style.verticalAlign = offsetPx + 'px'; + el.style.color = text_color; + } + }); + + debug.log('RT_code', 'Render cycle complete.'); +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.RT_code = RT_code; diff --git a/developer/document/style/RT_math.js b/developer/document/style/RT_math.js new file mode 100644 index 0000000..2d07cfa --- /dev/null +++ b/developer/document/style/RT_math.js @@ -0,0 +1,35 @@ +/* + Processes tags. + JavaScript: RT_math() + HTML Tag: (parsed as rt-math) +*/ +function RT_math(){ + // querySelector treats 'rt-math' as case-insensitive for the tag + document.querySelectorAll('rt-math').forEach(el => { + if (el.textContent.startsWith('$')) return; + + const is_block = el.parentElement.tagName === 'DIV' || + el.textContent.includes('\n') || + el.parentElement.childNodes.length === 1; + + const delimiter = is_block ? '$$' : '$'; + el.style.display = is_block ? 'block' : 'inline'; + el.textContent = `${delimiter}${el.textContent.trim()}${delimiter}`; + }); + + // MathJax must find its config at window.MathJax + window.MathJax = { + tex: { + inlineMath: [['$', '$']], + displayMath: [['$$', '$$']] + } + }; + + const script = document.createElement('script'); + script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'; + script.async = true; + document.head.appendChild(script); +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.RT_math = RT_math; diff --git a/developer/document/style/RT_term.js b/developer/document/style/RT_term.js new file mode 100644 index 0000000..e66c7b2 --- /dev/null +++ b/developer/document/style/RT_term.js @@ -0,0 +1,22 @@ +/* + Processes tags. + Implements the "Definiendum Convention" (Italics + Theme Accent). +*/ +function RT_term() { + const RT = window.StyleRT; + + // Robust check for theme presence + const theme = RT.active_theme ? RT.active_theme() : {}; + const accent = theme.accent || 'inherit'; + + // Selects , , etc. + document.querySelectorAll('rt-term').forEach(el => { + el.style.fontStyle = 'italic'; + el.style.color = accent; + el.style.paddingRight = '0.15em'; // Spacing for the italic slant + el.style.display = 'inline'; + }); +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.RT_term = RT_term; diff --git a/developer/document/style/article_generic.js b/developer/document/style/article_generic.js new file mode 100644 index 0000000..f49feda --- /dev/null +++ b/developer/document/style/article_generic.js @@ -0,0 +1,21 @@ +/* + Sets basic document theme colors. + No layout enforcement (leaves flow to default HTML block behavior). +*/ +window.StyleRT = window.StyleRT || {}; + +window.StyleRT.article_generic = function() { + const RT = window.StyleRT; + const theme = RT.active_theme ? RT.active_theme() : {}; + + const body = document.body; + + // Basic Theme Colors (Required for RT_code physics) + body.style.backgroundColor = theme.background || '#000'; + body.style.color = theme.foreground || '#ddd'; + body.style.fontFamily = '"Noto Sans JP", sans-serif'; + + // Reset margins to prevent browser defaults from interfering with your page.js + body.style.margin = '0'; + body.style.padding = '0'; +}; diff --git a/developer/document/style/body_visibility_hidden.js b/developer/document/style/body_visibility_hidden.js new file mode 100644 index 0000000..d6a178a --- /dev/null +++ b/developer/document/style/body_visibility_hidden.js @@ -0,0 +1,12 @@ +/* + Targets the root element to ensure total blackout during load. +*/ +function body_visibility_hidden(){ + const gate = document.createElement('style'); + gate.id = 'rt-visibility-gate'; + gate.textContent = 'html{visibility:hidden !important; background:black !important;}'; + document.head.appendChild(gate); +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.body_visibility_hidden = body_visibility_hidden; diff --git a/developer/document/style/body_visibility_visible.js b/developer/document/style/body_visibility_visible.js new file mode 100644 index 0000000..ff1c4b6 --- /dev/null +++ b/developer/document/style/body_visibility_visible.js @@ -0,0 +1,13 @@ +/* + Restores visibility by removing the visibility gate. +*/ +function body_visibility_visible(){ + const gate = document.getElementById('rt-visibility-gate'); + if (gate){ + gate.remove(); + } + document.body.style.visibility = 'visible'; +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.body_visibility_visible = body_visibility_visible; diff --git a/developer/document/style/do_style.js b/developer/document/style/do_style.js new file mode 100644 index 0000000..ffd2da7 --- /dev/null +++ b/developer/document/style/do_style.js @@ -0,0 +1,89 @@ +/* + Master Loader & Orchestrator for StyleRT. + + PIPELINE DEPENDENCY CHAIN: + 1. PHYSICS (Utility, Theme) -> Required by everything. + 2. GLOBAL (Article) -> Sets background for contrast checks. + 3. SEMANTICS (Code, Math) -> Expands text size; must run before pagination. + 4. STRUCTURE (H1, TOC) -> Creates .page containers. + 5. STYLING (Page) -> Applies borders/margins to .page containers. + 6. REVEAL -> Shows the result. +*/ + +window.StyleRT = window.StyleRT || {}; + +window.StyleRT.do_style = function() { + + // 1. Manifest + const modules = [ + 'style/utility.js', + 'style/theme_RT.js', + 'style/RT_term.js', + 'style/RT_math.js', + 'style/RT_code.js', + 'style/article_generic.js', + 'style/page_each_H1.js', + 'style/toc.js', + 'style/page.js', + 'style/body_visibility_visible.js' + ]; + + // 2. Loader + const load_next = (index) => { + if (index >= modules.length) { + run_pipeline(); + return; + } + const src = modules[index]; + const script = document.createElement('script'); + script.src = src; + script.onload = () => load_next(index + 1); + script.onerror = () => { console.error(`StyleRT: Failed ${src}`); load_next(index + 1); }; + document.head.appendChild(script); + }; + + // 3. Execution Pipeline + const run_pipeline = () => { + const RT = window.StyleRT; + const debug = RT.debug; + + debug.log('pipeline', 'Starting execution...'); + + // PHASE 1: GLOBAL SETUP + if(RT.article_generic) { + debug.log('pipeline', 'Phase 1: Global Setup (article_generic)'); + RT.article_generic(); + } + + // PHASE 2: SEMANTICS (In-place modification) + debug.log('pipeline', 'Phase 2: Semantics (Term, Math, Code)'); + if(RT.RT_term) RT.RT_term(); + if(RT.RT_math) RT.RT_math(); + if(RT.RT_code) RT.RT_code(); + + // PHASE 3: STRUCTURE (DOM Surgery) + debug.log('pipeline', 'Phase 3: Structure (Pagination & TOC)'); + + // A. Content Pagination (Breaks body into pages) + if(RT.page_each_H1) RT.page_each_H1(); + + // B. TOC Generation (Creates the TOC Page) + // Must run AFTER H1s are processed (or scan them), but definitely creates a .page + if(RT.toc) RT.toc(); + + // PHASE 4: STYLING (The Frame) + // Must run LAST, after all .page elements (Content + TOC) exist. + if(RT.page) { + debug.log('pipeline', 'Phase 4: Styling (Applying Page Borders)'); + RT.page(); + } + + // PHASE 5: REVEAL + debug.log('pipeline', 'Phase 5: Reveal'); + if(RT.body_visibility_visible) RT.body_visibility_visible(); + + debug.log('pipeline', 'Execution complete.'); + }; + + load_next(0); +}; diff --git a/developer/document/style/page.js b/developer/document/style/page.js new file mode 100644 index 0000000..6eb5e61 --- /dev/null +++ b/developer/document/style/page.js @@ -0,0 +1,40 @@ +/* + Defines the appearance of a "Page" container. + Restores the Original "Gold Glow" Scheme. +*/ +window.StyleRT = window.StyleRT || {}; + +window.StyleRT.page = function() { + const RT = window.StyleRT; + + // Fetch Theme + const theme = RT.active_theme ? RT.active_theme() : {}; + // Use the bright accent for the glow + const glowColor = theme.accent || 'gold'; + + document.querySelectorAll('.page').forEach(el => { + // A. Dimensions (The "Web" Look) + el.style.width = '1200px'; + el.style.maxWidth = '95vw'; // Responsive safety + el.style.height = 'auto'; // Hug content + el.style.minHeight = '200px'; // Minimum sanity check + el.style.boxSizing = 'border-box'; + + // B. The "Original" Visuals + // 1. Background: Likely darker/transparent to let the theme breathe + el.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; + + // 2. Border: Thin accent line + el.style.border = `1px solid ${glowColor}`; + + // 3. Shadow: The "Gold Drop Shadow" you missed + // Format: offset-x | offset-y | blur-radius | color + el.style.boxShadow = `0 0 15px ${glowColor}`; + + el.style.margin = '0 auto'; + + // C. Typography Base + el.style.padding = '2rem 4rem'; // Standard comfortable web reading padding + el.style.lineHeight = '1.6'; + }); +}; diff --git a/developer/document/style/page_each_H1.js b/developer/document/style/page_each_H1.js new file mode 100644 index 0000000..ac19e83 --- /dev/null +++ b/developer/document/style/page_each_H1.js @@ -0,0 +1,43 @@ +/* + Wraps child elements into pages based on H1 headers. +*/ +function page_each_H1(){ + const body = document.body; + const elements = Array.from(body.children); + const pages = []; + let current_page_elements = []; + + elements.forEach(el => { + if ( el.tagName === 'SCRIPT' || el.tagName === 'STYLE' ){ + return; + } + + if (el.tagName === 'H1'){ + if (current_page_elements.length > 0){ + pages.push(current_page_elements); + } + current_page_elements = [el]; + } else { + current_page_elements.push(el); + } + }); + + if (current_page_elements.length > 0){ + pages.push(current_page_elements); + } + + const scripts = Array.from(document.querySelectorAll('script')); + body.innerHTML = ''; + + pages.forEach(element_list => { + const page_div = document.createElement('div'); + page_div.className = 'page'; + element_list.forEach(el => page_div.appendChild(el)); + body.appendChild(page_div); + }); + + scripts.forEach(s => body.appendChild(s)); +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.page_each_H1 = page_each_H1; diff --git a/developer/document/style/theme_RT.js b/developer/document/style/theme_RT.js new file mode 100644 index 0000000..937ceba --- /dev/null +++ b/developer/document/style/theme_RT.js @@ -0,0 +1,22 @@ +/* + Provides the color palette for the RT theme. + Registers itself as the active system theme upon load. +*/ +function theme_RT(){ + return { + name: 'theme_RT', // Identity + + // Palette + background: 'hsl(0, 0%, 0%)', + foreground: 'hsl(42, 100%, 80%)', + accent: 'hsl(42, 100%, 50%)', + faded: 'hsl(42, 100%, 20%)', + highlight: 'hsl(42, 100%, 90%)' + }; +} + +window.StyleRT = window.StyleRT || {}; +window.StyleRT.theme_RT = theme_RT; + +// Generic Interface: Set this as the current active theme +window.StyleRT.active_theme = theme_RT; diff --git a/developer/document/style/toc.js b/developer/document/style/toc.js new file mode 100644 index 0000000..220afa6 --- /dev/null +++ b/developer/document/style/toc.js @@ -0,0 +1,46 @@ +/* + Generates a Table of Contents. + Inserts it at the very top of the document body. +*/ +window.StyleRT = window.StyleRT || {}; + +window.StyleRT.toc = function() { + const RT = window.StyleRT; + // Use 'pipeline' token if available, otherwise silent + const debug = RT.debug ? RT.debug.log.bind(RT.debug) : () => {}; + + debug('pipeline', 'Generating TOC...'); + + // 1. Create Container (reusing 'page' class so it picks up your gold style) + const container = document.createElement('div'); + container.className = 'page'; + container.id = 'rt-toc'; + + // 2. Title + const title = document.createElement('h1'); + title.textContent = 'Table of Contents'; + title.style.textAlign = 'center'; + container.appendChild(title); + + // 3. Build List + const list = document.createElement('ul'); + document.querySelectorAll('h1').forEach((header, i) => { + if (header === title) return; + if (!header.id) header.id = `section-${i}`; + + const li = document.createElement('li'); + const a = document.createElement('a'); + a.href = `#${header.id}`; + a.textContent = header.textContent; + a.style.textDecoration = 'none'; + a.style.color = 'inherit'; + + li.appendChild(a); + list.appendChild(li); + }); + + container.appendChild(list); + + // 4. Insert at Top (Prepend) + document.body.insertBefore(container, document.body.firstChild); +}; diff --git a/developer/document/style/utility.js b/developer/document/style/utility.js new file mode 100644 index 0000000..4bf452f --- /dev/null +++ b/developer/document/style/utility.js @@ -0,0 +1,106 @@ +/* + General utilities for the StyleRT library. + Includes: + 1. Token-based Debugging System + 2. Physics (Ink metrics, Color analysis) + 3. Text Analysis +*/ + +window.StyleRT = window.StyleRT || {}; + +// --- DEBUG SYSTEM --- +window.StyleRT.debug = { + // Add tokens here to enable specific logs: 'RT_code', 'physics', 'pipeline', 'layout' + active_tokens: new Set(['pipeline', 'layout']), + + log: function(token, message) { + if (this.active_tokens.has(token)) { + console.log(`[StyleRT:${token}]`, message); + } + }, + + warn: function(token, message) { + if (this.active_tokens.has(token)) { + console.warn(`[StyleRT:${token}]`, message); + } + }, + + // Helper to enable/disable on the fly from console + enable: function(token) { this.active_tokens.add(token); console.log(`Enabled: ${token}`); }, + disable: function(token) { this.active_tokens.delete(token); console.log(`Disabled: ${token}`); } +}; + +// --- UTILITIES --- +window.StyleRT.utility = { + + // --- FONT PHYSICS --- + measure_ink_ratio: function(target_font, ref_font = null) { + const debug = window.StyleRT.debug; + debug.log('physics', `Measuring ink ratio for ${target_font}`); + + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + + if (!ref_font) { + const bodyStyle = window.getComputedStyle(document.body); + ref_font = bodyStyle.fontFamily; + } + + const get_metrics = (font) => { + ctx.font = '100px ' + font; + const metrics = ctx.measureText('M'); + return { + ascent: metrics.actualBoundingBoxAscent, + descent: metrics.actualBoundingBoxDescent + }; + }; + + const ref_m = get_metrics(ref_font); + const target_m = get_metrics(target_font); + + const ratio = ref_m.ascent / target_m.ascent; + debug.log('physics', `Ink Ratio calculated: ${ratio.toFixed(3)}`); + + return { + ratio: ratio, + baseline_diff: ref_m.descent - target_m.descent + }; + }, + + // --- COLOR PHYSICS --- + is_color_light: function(color_string) { + const debug = window.StyleRT.debug; + + // 1. HSL Check + if (color_string.startsWith('hsl')) { + const numbers = color_string.match(/\d+/g); + if (numbers && numbers.length >= 3) { + const lightness = parseInt(numbers[2]); + const is_light = lightness > 50; + debug.log('color_physics', `HSL ${color_string} -> Lightness ${lightness}% -> ${is_light ? 'LIGHT' : 'DARK'}`); + return is_light; + } + } + + // 2. RGB Check + const rgb = color_string.match(/\d+/g); + if (!rgb) { + debug.warn('color_physics', `Failed to parse color: "${color_string}". Defaulting to Light.`); + return true; + } + + const r = parseInt(rgb[0]); + const g = parseInt(rgb[1]); + const b = parseInt(rgb[2]); + const luma = (r * 299 + g * 587 + b * 114) / 1000; + const is_light = luma > 128; + + debug.log('color_physics', `RGB (${r},${g},${b}) -> Luma ${luma.toFixed(1)} -> ${is_light ? 'LIGHT' : 'DARK'}`); + return is_light; + }, + + // --- TEXT ANALYSIS --- + is_block_content: function(element) { + return element.textContent.trim().includes('\n'); + } +}; diff --git a/developer/document/test.html b/developer/document/test.html new file mode 100644 index 0000000..7bf9955 --- /dev/null +++ b/developer/document/test.html @@ -0,0 +1,146 @@ + + + + + Test File + + + + + + + +

text before the first heading

+ +

Given

+

The English language is a given, apparently.

+

+ This discussion happens to appear in the context of a Python implementation. +

+ +

Symbol

+

Definition

+

x + We have a symbol instance factory. Each time the make + method is called, we get a unique identity i. +

+ +

+ A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +x = y +# y is a variable holding a symbol instance + + +

+ 1. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 2. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 3. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 4. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 5. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 6. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 7. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 8. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

skipping 9 and 10, just for fun.

+ +

+ 11. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 12. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 13. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 14. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 15. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 16. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 17. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ +

+ 18. A symbol instance may be copied as though it were an integer. + Thus, a common method for making a copy is assignment: +

+ + +

Path

+

Discrete Function

+

Topologically it gives us a satisfying feeling that a given 'way' never leads to different destinations.

+ +

A common notation for a function is:

+ + destination = f(way) + + +

+ Because the same way always leads to the given destination, + we can represent the mapping as follows: +

+ + def resolve_path(way): + return hypergraph.lookup(way) + + + + + + + diff --git a/developer/document/theory.html b/developer/document/theory.html new file mode 100644 index 0000000..d2a2c54 --- /dev/null +++ b/developer/document/theory.html @@ -0,0 +1,119 @@ + + + + + Epimetheus: Tagged Math Paradigm + + + + + + + +

Given

+ + The English language is a given, apparently. + + This discussion happens to appear in the context of a Python language implementation, though it applies equally as well to other languages. + +

Symbol

+ +

Definition

+ + We have a symbol instance factory. Each time the `make` method on the factory is called, the factory returns an instance of a distinct symbol. + + A symbol instance may be copied as through it were an integer. Thus, a common method for making a copy is assignment, e.g. 'x = y', where y is a variable holding a symbol instance, and after execution of the assignment, x will hold another instance of the symbol. + + Any two, or by transitivity, any number of, symbol instances can be compared for equality using an integer equality comparison, e.g. 'x == y'. A comparison between symbol holding variables will always return `True` or `False`. + + It follows that any two symbol instances directly returned from the factory will always equality compare to be `False`. + + An equivalence set of symbol instances is a functional representation of the symbol. The name of this set is yet another instance of said symbol. Thus ever instance of the symbol represents the symbol. + + Though symbol instances are integer like for copy and equality compare, they are disallowed from being used with other integer operators. As examples, symbols can not be compared for greater-than or less-than, they can not be incremented, nor added, nor subtracted, etc. + + The only allowed operators for symbol instances are integer equality compare, integer not-equal compare, and integer copy. + +

Distinctness Across Contexts

+ + If a symbol persist across contexts, such as across scopes, or across processes, it must remain distinct from all other symbols as it enters into those new processes or contexts. + + There are many possible schemes or constraint sets for meeting this requirement. + + In this implementation we meet this constraint by using a global symbol factory, and by explicitly disallowing a symbol from being used outside the process it was made in. + +

Named Symbols

+ + It is common for a programmer to make a dictionary that has one-to-one association of a symbol and a Python string object, i.e. a `string`, as programmers like to be able to refer to each symbol by its 'name'. + +

Object

+ +

Definition

+ + The term 'Python object' is anything that can appear in Python code, or could appear in Python code, and could be associated with a symbol. + + 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 that key. + +

Path

+ +

Individual Path

+ + In the TTCA we provided formal definition for a 'tape'. A tape has a leftmost cell, one or more in between cells, and a rightmost cell. For a one cell tape, the one cell is both the leftmost cell and the rightmost cell. A zero cell tape either does not exist, or it is a higher order 'placeholder' concept. + + A 'path' is special case of a 'tape', as defined in the TTCA, with some additional constraints. + + Each cell of a path holds a symbol. + + The leftmost cell is called the 'destination'. The reader might have expected the path to go from left to right on the tape, in the same order that a person reads the words on a printed page, but such a definition would run into a problem, as left to right traversal of a tape 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 now know where he came from. + + All the 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. + +

Discrete Function

+ + Consider another tape where each cell holds a path. + + If when we compare all the paths on said tape, and find that no two identical ways lead to different destinations, we can call said tape a 'discrete function'. It is 'discrete' because of the type of math we are doing here, with symbols and tape cells. It is a 'function' because a given way never has two destinations. + + Topologically it gives us a satisfying feeling that a given 'way' never leads to different destinations. If it were otherwise we would feel to be in a sci-fi movie. + + Note, however, there can exist more than one way to reach the same destination, though there might not be. Again, this fits our intuition of real paths. + + Because functions embody our intuition about the space we live in, they occur often when doing real world modeling. There is also something about this quality that makes discrete functions useful in computer science. + + A common notation for a function is: + ``` + destination = f(way) + ``` + + This notation is possible because the same way always leads to the given destination. + + + + + + + + + + + + + + + + + + + -- 2.20.1