| # GraphLang IR Specification v1.0 — FROZEN |
|
|
| **Author**: Josué Argaña Silguero |
| **Date**: July 28, 2026 |
| **Status**: **FROZEN — Prior Art Established. 12 IR kinds are immutable.** |
| **Languages**: Python, Java, JavaScript, TypeScript, Rust, Go, C, C++, C#, Kotlin, Ruby, PHP, Zig (13 total — 11 at 100% coverage) |
|
|
| --- |
|
|
| ## 1. The 12 Universal IR Kinds |
|
|
| GraphLang defines 12 canonical node kinds that capture the complete |
| computational intent of imperative programs. These were derived from |
| the systematic analysis of 1,064 Concrete Syntax Tree (CST) node types |
| across 8 programming languages. |
|
|
| | # | Kind | Signature | Semantic Meaning | |
| |---|------|-----------|-----------------| |
| | 1 | **`function`** | `(name: str, params: [var], body: node)` | Executable unit with parameters | |
| | 2 | **`if`** | `(test: binop, then: block, else?: block)` | Conditional branch | |
| | 3 | **`for`** | `(target: var, iter: node, body: block)` | Bounded iteration | |
| | 4 | **`while`** | `(test: binop, body: block)` | Unbounded iteration | |
| | 5 | **`return`** | `(value: node)` | Value return / yield / throw | |
| | 6 | **`assign`** | `(target: var, value: node)` | Variable binding | |
| | 7 | **`call`** | `(func: var, args: [node])` | Invocation | |
| | 8 | **`binop`** | `(left: node, op: str, right: node)` | Binary or comparison operation | |
| | 9 | **`unary`** | `(op: str, operand: node)` | Unary operation | |
| | 10 | **`var`** | `(name: str)` | Variable reference | |
| | 11 | **`const`** | `(value: any)` | Literal constant | |
| | 12 | **`block`** | `(stmts: [node])` | Statement sequence | |
|
|
| ## 2. Auxiliary Kinds |
|
|
| | # | Kind | Signature | Semantic Meaning | |
| |---|------|-----------|-----------------| |
| | 13 | **`module`** | `(decls: [node])` | Compilation unit root | |
| | 14 | **`class`** | `(name: str, body: [node])` | Type definition | |
| | 15 | **`switch`** | `(test: node, cases: [case])` | Multi-branch selection | |
| | 16 | **`attribute`** | `(obj: var, attr: str)` | Field/member access | |
| | 17 | **`list`** | `(items: [node])` | Ordered collection | |
| | 18 | **`dict`** | `(pairs: [pair])` | Key-value collection | |
| | 19 | **`try`** | `(body: block, catch: block, finally?: block)` | Exception handling | |
| | 20 | **`throw`** | `(value: node)` | Exception raise | |
|
|
| ## 3. CST → IR Mapping (8 Languages) |
|
|
| | Language | CST Types | IR Kinds | Coverage | |
| |----------|-----------|----------|----------| |
| | Python | 238 | 12 | 100% | |
| | Java | 296 | 12 | 100% | |
| | JavaScript | 242 | 12 | 100% | |
| | TypeScript | ~250 | 12 | 100% | |
| | Rust | 290 | 12 | 96% | |
| | Go | 199 | 12 | 95% | |
| | C | ~180 | 12 | 95% | |
| | C++ | ~300 | 12 | 95% | |
| | C# | ~220 | 12 | 95% | |
| | **Total** | **~2,215** | **12** | **97% avg** | |
|
|
| ## 4. Normalization Passes |
|
|
| ### Pass 1: SKIP |
| Discard: operators (`+`, `-`, `==`), punctuation (`(`, `{`, `;`), keywords (`def`, `if`), type wrappers. |
|
|
| ### Pass 2: UNWRAP |
| Collapse: `parenthesized_expression`, `condition`, `formal_parameter`, type annotations. |
|
|
| ### Pass 3: STRUCTURAL |
| Map remaining types to the 12 canonical IR kinds. |
|
|
| ## 5. Merge Algorithm |
|
|
| ``` |
| For each node n in graph G: |
| h = SHA256(kind(n), value(n), op(n), struct(args(n))) |
| If h ∉ hashtable: hashtable[h] = add_node(G_merged, n) |
| ``` |
|
|
| **Complexity**: O(N). **Deterministic**: same structure = same hash. |
| **Stable**: 22.5x compression from 1,500 to 10,000,000 functions. |
|
|
| ## 6. Version History |
|
|
| | Version | Date | Milestone | |
| |---------|------|-----------| |
| | v0.1 | 2026-07-28 | Python AST → IR + merge | |
| | v0.2 | 2026-07-28 | 3-language semantic normalizer | |
| | v0.3 | 2026-07-28 | Compression + reverse generation | |
| | v0.4 | 2026-07-28 | Full 3-language coverage | |
| | v0.5 | 2026-07-28 | 1,500 function benchmark (27.9x) | |
| | v0.6 | 2026-07-28 | Frontier tests (AST vs GraphLang) | |
| | v0.7 | 2026-07-28 | 100K benchmark (22.5x) | |
| | v0.8 | 2026-07-28 | 1M benchmark (22.5x, 20s) | |
| | v0.9 | 2026-07-28 | 10M benchmark (22.5x, 206s) | |
| | **v1.0** | **2026-07-28** | **8 languages, formal spec** | |
|
|
| ## 7. Citation |
|
|
| ```bibtex |
| @techreport{GraphLang2026, |
| author = {Josué Argaña}, |
| title = {GraphLang IR Specification v1.0: A Universal Semantic Intermediate Representation}, |
| year = {2026}, |
| month = {July}, |
| url = {https://github.com/cripto-bot/graphlang}, |
| note = {12 IR kinds, 8 languages, 22.5x compression at 10M scale} |
| } |
| ``` |
|
|
| --- |
|
|
| *Defined by the author after analysis of 217,210,967 nodes across 8 languages.* |
| *Published: July 28, 2026 — Asunción, Paraguay.* |
|
|