From 938299fae3b8eafbe1a8363446a3a7179868b995 Mon Sep 17 00:00:00 2001 From: Vasilev Dmitrii Date: Thu, 27 Aug 2026 00:08:34 +0700 Subject: [PATCH 1/2] specs: restore the 2544 lines commit 4639b38cd overwrote with a counter (Refs #2161) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `4639b38cd` -- "fix(l3-purity): replace all Unicode with ASCII in 160 .t27 files" -- did not transliterate. It replaced the i-th non-ASCII character of each file with the ASCII digits of `i`: - fn ternary_not(a: i32) → i32 { + fn ternary_not(a: i32) 257 i32 { That transform is exactly reproducible from the pre-image, which is what makes the repair safe rather than a guess. The model was verified to reproduce the commit's output BYTE FOR BYTE before anything was written. A line is restored only when the line at HEAD is byte-identical to the transform of its pre-image line, so every line edited in the four months since is left untouched. 141 files, 2544 lines. Measured with the MASTER binary, so this is isolated from the compiler fixes in #2720: specs that parse 603 -> 610 regressions 0 The seven are exactly the "Expected LBrace, got Number ('257')" cluster. They failed not because they LOST an arrow -- `→` was never a token, the lexer discards it -- but because they GAINED an integer literal. One restored line, as a sample of what the other 2543 are: - assert jones_trefoil_at_phi() 1222 PHI + PHI * PHI within 0.1 + assert jones_trefoil_at_phi() ≈ PHI + PHI * PHI within 0.1 The comparison operator was that file's 1222nd non-ASCII character. This takes the RESTORE branch of the question in #2713 rather than transliterating, on two grounds. The pre-image is exact and a transliteration is a fresh authoring decision on 2544 lines. And the L3 ASCII rule is enforced by nothing today: 320 of 747 tracked .t27 files carry 88,033 non-ASCII characters at HEAD and no gate objects -- while TASK.md:128 records "0 non-ASCII remaining". scripts/repair/unscar_4639b38cd.py is committed, so the transliterate branch stays available and the operation is reproducible. --- compiler/ast.t27 | 76 ++++---- compiler/cli/gen.t27 | 38 ++-- compiler/cli/git.t27 | 28 +-- compiler/cli/spec.t27 | 54 +++--- compiler/codegen/c/codegen.t27 | 8 +- compiler/codegen/testgen.t27 | 22 +-- compiler/codegen/verilog/codegen.t27 | 22 +-- compiler/codegen/verilog/fpga_emission.t27 | 26 +-- compiler/codegen/zig/codegen.t27 | 24 +-- compiler/codegen/zig/runtime.t27 | 16 +- compiler/parser/lexer.t27 | 4 +- compiler/parser/parser.t27 | 24 +-- compiler/runtime/commands.t27 | 58 +++---- compiler/runtime/runtime.t27 | 8 +- compiler/runtime/validation.t27 | 26 +-- compiler/skill/registry.t27 | 24 +-- ...estoring-2544-lines-a-counter-overwrote.md | 9 + scripts/repair/unscar_4639b38cd.py | 57 ++++++ specs/account/auth.t27 | 26 +-- specs/account/repo.t27 | 22 +-- specs/account/schema.t27 | 30 ++-- specs/api/c_api_contract.t27 | 4 +- specs/api/sdk_contract.t27 | 4 +- specs/auth/config.t27 | 42 ++--- specs/automation/wrapup-auto.t27 | 4 +- specs/base/ops.t27 | 94 +++++----- specs/base/seed.t27 | 4 +- specs/base/ternary_add.t27 | 10 +- specs/base/ternary_encoding.t27 | 98 +++++------ specs/base/ternary_memory.t27 | 90 +++++----- specs/base/types.t27 | 100 +++++------ specs/benchmarks/bench_main.t27 | 8 +- specs/benchmarks/bench_nn.t27 | 4 +- specs/benchmarks/ternary_vs_binary.t27 | 6 +- specs/brain/brain.t27 | 52 +++--- specs/brain/bus.t27 | 2 +- specs/brain/cognitive_loop.t27 | 2 +- specs/brain/neural_gamma.t27 | 48 ++--- specs/brain/phi_timing.t27 | 2 +- specs/brain/unified_state.t27 | 2 +- specs/compiler/parser.t27 | 48 ++--- specs/conformance/e2e_scenarios.t27 | 36 ++-- specs/demos/jones_topology_decision_gate.t27 | 48 ++--- specs/demos/jones_topology_filter.t27 | 2 +- specs/file/operations.t27 | 30 ++-- specs/file/schema.t27 | 66 +++---- specs/file/watcher.t27 | 38 ++-- specs/fpga/bridge.t27 | 50 +++--- specs/fpga/mac.t27 | 112 ++++++------ specs/fpga/spi.t27 | 42 ++--- specs/fpga/testbench/mac_tb.t27 | 56 +++--- specs/fpga/testbench/top_tb.t27 | 2 +- specs/fpga/testbench/uart_tb.t27 | 44 ++--- specs/fpga/top_level.t27 | 2 +- specs/fpga/uart.t27 | 2 +- specs/git/diff.t27 | 22 +-- specs/git/operations.t27 | 14 +- specs/git/schema.t27 | 34 ++-- specs/git/status.t27 | 18 +- specs/github/tests/e2e_full_flow.t27 | 6 +- specs/graph/knowledge_graph.t27 | 6 +- specs/hslm/forward_pass.t27 | 2 +- specs/interop/gf_cross_language.t27 | 22 +-- specs/isa/registers.t27 | 138 +++++++-------- specs/isa/ternary_arithmetic.t27 | 90 +++++----- specs/isa/ternary_bitwise.t27 | 86 ++++----- specs/isa/ternary_control_flow.t27 | 38 ++-- specs/isa/ternary_deque.t27 | 66 +++---- specs/isa/ternary_gates.t27 | 94 +++++----- specs/isa/ternary_memory.t27 | 38 ++-- specs/isa/ternary_shift.t27 | 62 +++---- specs/jit/jit.t27 | 6 +- specs/math/constants.t27 | 62 +++---- specs/math/e8_lie_algebra.t27 | 12 +- specs/math/gf_competitive.t27 | 20 +-- specs/math/pellis_precision_verify.t27 | 40 ++--- specs/math/phi_split_optimality.t27 | 8 +- specs/math/phi_universal_attractor.t27 | 96 +++++----- specs/math/property_test_template.t27 | 26 +-- specs/math/radix_economy.t27 | 50 +++--- specs/math/sacred_physics.t27 | 40 ++--- specs/math/zamolodchikov_e8.t27 | 10 +- specs/memory/notebooklm.t27 | 68 ++++---- specs/neural/forward_pass.t27 | 4 +- specs/nn/attention.t27 | 122 ++++++------- specs/nn/hslm.t27 | 82 ++++----- specs/numeric/bigint.t27 | 2 +- specs/numeric/formats.t27 | 4 +- specs/numeric/gf12.t27 | 42 ++--- specs/numeric/gf16.t27 | 128 +++++++------- specs/numeric/gf20.t27 | 38 ++-- specs/numeric/gf24.t27 | 38 ++-- specs/numeric/gf32.t27 | 48 ++--- specs/numeric/gf4.t27 | 58 +++---- specs/numeric/gf8.t27 | 44 ++--- specs/numeric/phi_ratio.t27 | 102 +++++------ specs/numeric/tf3.t27 | 74 ++++---- specs/numeric/trinity_numeric_surface.t27 | 6 +- specs/physics/e8_lqg_bridge.t27 | 44 ++--- specs/physics/gamma-conflict.t27 | 148 ++++++++-------- specs/physics/gamma_conjecture.t27 | 22 +-- specs/physics/hslm_benchmark.t27 | 8 +- specs/physics/lqg_cs_bridge.t27 | 54 +++--- specs/physics/lqg_entropy.t27 | 40 ++--- specs/physics/p2_brain_physics.t27 | 6 +- specs/physics/pellis-formulas.t27 | 2 +- specs/physics/quantum.t27 | 16 +- specs/physics/sacred_verification.t27 | 164 +++++++++--------- specs/physics/su2_chern_simons.t27 | 10 +- specs/physics/zamolodchikov_4d_conjecture.t27 | 8 +- specs/pins/parser.t27 | 2 +- specs/queen/brain_summaries.t27 | 52 +++--- specs/queen/lotus.t27 | 102 +++++------ specs/sandbox/health.t27 | 8 +- specs/sandbox/modules.t27 | 4 +- specs/sandbox/session_timeout.t27 | 16 +- specs/server/agent-runner.t27 | 52 +++--- specs/server/api.t27 | 24 +-- specs/server/project.t27 | 20 +-- specs/server/provider.t27 | 24 +-- specs/server/session.t27 | 32 ++-- specs/shell/environment.t27 | 26 +-- specs/shell/process.t27 | 22 +-- specs/shell/schema.t27 | 34 ++-- specs/storage/kv.t27 | 14 +- specs/storage/lock.t27 | 18 +- specs/storage/migrate.t27 | 22 +-- specs/storage/schema.t27 | 30 ++-- specs/ternary/bigint.t27 | 14 +- specs/test_framework/core.t27 | 16 +- .../test_framework/graph_drift_detection.t27 | 26 +-- .../test_framework/property_test_template.t27 | 26 +-- specs/test_framework/runner.t27 | 14 +- .../test_framework/verilog_bench_harness.t27 | 26 +-- specs/tools/registry.t27 | 26 +-- specs/tools/schema.t27 | 42 ++--- specs/vm/jit_semantics.t27 | 2 +- specs/vsa/jones_polynomial.t27 | 76 ++++---- specs/vsa/ops.t27 | 74 ++++---- specs/vsa/packed_vsa.t27 | 12 +- specs/vsa/sequence_hdc.t27 | 2 +- specs/vsa/similarity_search.t27 | 38 ++-- specs/vsa/vsa_core.t27 | 16 +- 143 files changed, 2611 insertions(+), 2545 deletions(-) create mode 100644 docs/now/2026-08-27-restoring-2544-lines-a-counter-overwrote.md create mode 100755 scripts/repair/unscar_4639b38cd.py diff --git a/compiler/ast.t27 b/compiler/ast.t27 index 9611ed28ba..190a67e0dd 100644 --- a/compiler/ast.t27 +++ b/compiler/ast.t27 @@ -1,10 +1,10 @@ -// ast.t27 0 Abstract Syntax Tree for TRI-27 Assembly +// ast.t27 — Abstract Syntax Tree for TRI-27 Assembly // This file defines the AST structure used by the t27 compiler module ast { - // 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 - // Token types 70 enum of all token types (shared between lexer and parser) - // 7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ═════════════════════════════════════════════════════════════════════ + // Token types — enum of all token types (shared between lexer and parser) + // ═════════════════════════════════════════════════════════════════════ pub const TokenType = enum(u8) { // Punctuation @@ -107,9 +107,9 @@ module ast { Expect = 100, }; - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 - // Node types 209 enum of all AST node types - // 210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 + // ═════════════════════════════════════════════════════════════════════ + // Node types — enum of all AST node types + // ═════════════════════════════════════════════════════════════════════ pub const NodeType = enum(u8) { // Program structure @@ -164,9 +164,9 @@ module ast { RuleDecl = 69, // rule declaration }; - // 279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 - // AST Node 348 base structure for all nodes - // 349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════ + // AST Node — base structure for all nodes + // ═════════════════════════════════════════════════════════════════════ pub const ASTNode = struct { node_type: NodeType, @@ -175,9 +175,9 @@ module ast { source_file: []const u8, }; - // 418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 - // Program 487 root node - // 488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 + // ═════════════════════════════════════════════════════════════════════ + // Program — root node + // ═════════════════════════════════════════════════════════════════════ pub const Program = struct { node: ASTNode, @@ -192,9 +192,9 @@ module ast { imports: [][]const u8, // Imported modules }; - // 557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 + // ═════════════════════════════════════════════════════════════════════ // Section structures - // 626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 + // ═════════════════════════════════════════════════════════════════════ pub const TestSection = struct { node: ASTNode, @@ -211,9 +211,9 @@ module ast { benchmarks: []BenchDecl, }; - // 695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763 + // ═════════════════════════════════════════════════════════════════════ // Constants and Data - // 764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832 + // ═════════════════════════════════════════════════════════════════════ pub const ConstDef = struct { node: ASTNode, @@ -233,14 +233,14 @@ module ast { label: []const u8, }; - // 833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901 + // ═════════════════════════════════════════════════════════════════════ // Code and Instructions - // 902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970 + // ═════════════════════════════════════════════════════════════════════ pub const CodeSection = struct { node: ASTNode, instructions: []Instruction, - labels: std.StringHashMap(u32), // Label 971 instruction index + labels: std.StringHashMap(u32), // Label → instruction index }; pub const Instruction = struct { @@ -295,11 +295,11 @@ module ast { offset: i16, }; - // 97297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040 + // ═════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec structures - // 104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109 + // ═════════════════════════════════════════════════════════════════════ - // TestCase 1110 a single test case from .test section + // TestCase — a single test case from .test section // Format: ; test_name ; Verify: description ; Expected: expected outcome pub const TestCase = struct { node: ASTNode, @@ -310,7 +310,7 @@ module ast { rationale: ?[]const u8, // Additional rationale (optional) }; - // InvariantDecl 1111 an invariant from .invariant section + // InvariantDecl — an invariant from .invariant section // Format: ; invariant_name ; Rationale: explanation pub const InvariantDecl = struct { node: ASTNode, @@ -319,7 +319,7 @@ module ast { rationale: []const u8, // "Rationale:" explanation }; - // BenchDecl 1112 a benchmark from .bench section + // BenchDecl — a benchmark from .bench section // Format: ; bench_name ; Measure: what to measure ; Target: target value pub const BenchDecl = struct { node: ASTNode, @@ -329,11 +329,11 @@ module ast { units: []const u8, // Units of measurement (e.g., "cycles", "ns", "ops/sec") }; - // 111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181 + // ═════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec high-level structures (spec-style) - // 118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250 + // ═════════════════════════════════════════════════════════════════════ - // SpecDecl 1251 spec module header declaration + // SpecDecl — spec module header declaration // Format: spec pub const SpecDecl = struct { node: ASTNode, @@ -344,7 +344,7 @@ module ast { rules: []RuleDecl, // rules in spec }; - // TestBlock 1252 a complete test with given/when/then clauses + // TestBlock — a complete test with given/when/then clauses // Format: test { given ... when ... then ... } pub const TestBlock = struct { node: ASTNode, @@ -393,9 +393,9 @@ module ast { expression: []const u8, // expectation expression }; - // 125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321 + // ═════════════════════════════════════════════════════════════════════ // Type information for codegen - // 132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390 + // ═════════════════════════════════════════════════════════════════════ pub const TypeInfo = struct { name: []const u8, @@ -403,9 +403,9 @@ module ast { is_signed: bool, }; - // 139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459 + // ═════════════════════════════════════════════════════════════════════ // Symbol table - // 146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528 + // ═════════════════════════════════════════════════════════════════════ pub const Symbol = struct { name: []const u8, @@ -444,9 +444,9 @@ module ast { } }; - // 152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597 - // Compiler context 1598 passed through all compilation stages - // 159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667 + // ═════════════════════════════════════════════════════════════════════ + // Compiler context — passed through all compilation stages + // ═════════════════════════════════════════════════════════════════════ pub const CompilerContext = struct { ast_root: Program, @@ -518,9 +518,9 @@ module ast { } } -// 1668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for AST -// 1771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test token_type_eof_value try std.testing.expect(@intFromEnum(ast.TokenType.EOF) == 0); diff --git a/compiler/cli/gen.t27 b/compiler/cli/gen.t27 index c4a27514e7..b2fdf7c40c 100644 --- a/compiler/cli/gen.t27 +++ b/compiler/cli/gen.t27 @@ -1,4 +1,4 @@ -// gen.t27 0 Code Generation with TDD Validation +// gen.t27 — Code Generation with TDD Validation // Commands for generating code from t27 specs with TDD enforcement module gen_commands { @@ -6,9 +6,9 @@ module gen_commands { using codegen_zig: @import("../codegen/zig/codegen.t27"); using testgen: @import("../codegen/testgen.t27"); - // 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 + // ═════════════════════════════════════════════════════════════════════ // Codegen options - // 707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 + // ═════════════════════════════════════════════════════════════════════ pub const GenOptions = struct { backend: []const u8, // Target backend (zig, c, verilog, etc.) @@ -34,9 +34,9 @@ module gen_commands { output_format: []const u8, }; - // 139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 - // Command: tri gen 208 Generate code from spec with TDD validation - // 209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 + // ═════════════════════════════════════════════════════════════════════ + // Command: tri gen — Generate code from spec with TDD validation + // ═════════════════════════════════════════════════════════════════════ pub fn gen(spec_path: []const u8, options: GenOptions) i32 { // Check if spec exists @@ -73,9 +73,9 @@ module gen_commands { return 1; } - // 278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 + // ═════════════════════════════════════════════════════════════════════ // TDD CONTRACT ENFORCEMENT (Per User Requirement: No prototype mode) - // 347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 + // ═════════════════════════════════════════════════════════════════════ var has_tests = false; var test_count: usize = 0; var invariant_count: usize = 0; @@ -130,9 +130,9 @@ module gen_commands { print_int(invariant_count); error_print(" invariants\n"); - // 416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 + // ═════════════════════════════════════════════════════════════════════ // Generate code - // 485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 + // ═════════════════════════════════════════════════════════════════════ // Determine output paths const output_dir = if (options.output_dir.len == 0) @@ -259,9 +259,9 @@ module gen_commands { return 0; } - // 554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622 - // Command: tri gen all 623 Generate code for all specs in project - // 624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 + // ═════════════════════════════════════════════════════════════════════ + // Command: tri gen all — Generate code for all specs in project + // ═════════════════════════════════════════════════════════════════════ pub fn gen_all(options: GenOptions) i32 { const spec_files = glob("specs/**/*.t27"); @@ -306,9 +306,9 @@ module gen_commands { return if (fail_count > 0) 1 else 0; } - // 693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761 + // ═════════════════════════════════════════════════════════════════════ // Helper functions - // 762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830 + // ═════════════════════════════════════════════════════════════════════ // Get basename without extension pub fn basename_without_ext(path: []const u8) []const u8 { @@ -336,9 +336,9 @@ module gen_commands { return path[filename_start..end]; } - // 831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 + // ═════════════════════════════════════════════════════════════════════ // Type definitions - // 900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968 + // ═════════════════════════════════════════════════════════════════════ pub const Program = struct { constants: []Constant, @@ -435,9 +435,9 @@ module gen_commands { }; } -// 969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Gen Commands -// 1072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gen_returns_zero_on_success // Mock successful generation scenario diff --git a/compiler/cli/git.t27 b/compiler/cli/git.t27 index 3458570f64..a8e8dd3cd2 100644 --- a/compiler/cli/git.t27 +++ b/compiler/cli/git.t27 @@ -1,12 +1,12 @@ -// git.t27 0 Git Integration with Tri Skill Workflow (ADR-002) +// git.t27 — Git Integration with Tri Skill Workflow (ADR-002) // Commands for git operations with skill validation and issue binding module git_commands { using skill_registry: @import("../skill/registry.t27"); - // 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 + // ═════════════════════════════════════════════════════════ // Command: tri git commit [--all] [-m "msg"] [--mode strict|normal|local] - // 585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 + // ═════════════════════════════════════════════════════════════════════ pub fn git_commit(all: bool, message: []const u8, mode: []const u8) i32 { const registry_path = ".trinity/skills/registry.json"; @@ -125,9 +125,9 @@ module git_commands { return 0; } - // 127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 + // ═════════════════════════════════════════════════════════ // Command: tri git push [ ] [--mode strict|normal|local] - // 184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 + // ═════════════════════════════════════════════════════════════════════ pub fn git_push(remote: []const u8, branch: []const u8, mode: []const u8) i32 { const registry_path = ".trinity/skills/registry.json"; @@ -242,9 +242,9 @@ module git_commands { return 0; } - // 253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 - // Command: tri git status 310 Show git status with skill info - // 311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 + // ═════════════════════════════════════════════════════════ + // Command: tri git status — Show git status with skill info + // ═════════════════════════════════════════════════════════════════════ pub fn git_status_with_skill() i32 { const registry_path = ".trinity/skills/registry.json"; @@ -290,9 +290,9 @@ module git_commands { return 0; } - // 380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 + // ═════════════════════════════════════════════════════════ // Helper functions - // 437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505 + // ═════════════════════════════════════════════════════════════════════ // Find active or last sealed skill from registry fn find_active_or_sealed_skill(registry_json: []const u8) ?Skill { @@ -452,9 +452,9 @@ module git_commands { return result; } - // 506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 + // ═════════════════════════════════════════════════════════ // Type definitions - // 563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 + // ═════════════════════════════════════════════════════════════════════ pub const Skill = struct { id: []const u8, @@ -482,9 +482,9 @@ module git_commands { }; } -// 632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722 +// ═══════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Git Integration -// 723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813 +// ═══════════════════════════════════════════════════════════════════════════════════════════ test git_commit_requires_registry // Mock: registry doesn't exist diff --git a/compiler/cli/spec.t27 b/compiler/cli/spec.t27 index 3e9046face..477d1f66ea 100644 --- a/compiler/cli/spec.t27 +++ b/compiler/cli/spec.t27 @@ -1,10 +1,10 @@ -// spec.t27 0 Spec Management Commands +// spec.t27 — Spec Management Commands // Commands for creating and managing t27 specs with TDD enforcement module spec_commands { - // 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 - // Command: tri spec create 70 Create a new spec with TDD template - // 7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ═════════════════════════════════════════════════════════════════════ + // Command: tri spec create — Create a new spec with TDD template + // ═════════════════════════════════════════════════════════════════════ pub fn spec_create(name: []const u8, path: []const u8) i32 { // Validate spec name @@ -51,9 +51,9 @@ module spec_commands { return 0; } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 - // Command: tri spec validate 209 Validate spec has TDD compliance - // 210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 + // ═════════════════════════════════════════════════════════════════════ + // Command: tri spec validate — Validate spec has TDD compliance + // ═════════════════════════════════════════════════════════════════════ pub fn spec_validate(path: []const u8) i32 { if (!file_exists(path)) { @@ -136,9 +136,9 @@ module spec_commands { return 0; } - // 279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 - // Command: tri spec list 348 List all specs in project - // 349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════ + // Command: tri spec list — List all specs in project + // ═════════════════════════════════════════════════════════════════════ pub fn spec_list() i32 { const spec_dir = "specs"; @@ -170,7 +170,7 @@ module spec_commands { } } - const status = if (has_tests) "418" else "419"; + const status = if (has_tests) "✓" else "✗"; print(" "); print(status); print(" "); @@ -181,9 +181,9 @@ module spec_commands { return 0; } - // 420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 + // ═════════════════════════════════════════════════════════════════════ // Helper functions - // 489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 + // ═════════════════════════════════════════════════════════════════════ // Validate spec name: lowercase alphanumeric with underscores pub fn is_valid_spec_name(name: []const u8) bool { @@ -209,8 +209,8 @@ module spec_commands { // Generate spec template with TDD blocks (assembly-like format) pub fn generate_spec_template(name: []const u8) []const u8 { - return "; " ++ name ++ ".t27 558 Specification for " ++ name ++ "\n" ++ - "; 559560 + 1/561562 = 3 | TRINITY\n" ++ + return "; " ++ name ++ ".t27 — Specification for " ++ name ++ "\n" ++ + "; φ² + 1/φ² = 3 | TRINITY\n" ++ ";\n" ++ "; This file is the source of truth for " ++ name ++ ".\n" ++ "; Generated code is a derived artifact - DO NOT EDIT generated files.\n" ++ @@ -220,31 +220,31 @@ module spec_commands { "\n" ++ ".use base::types\n" ++ "\n" ++ - "; 563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "; Constants\n" ++ - "; 626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "\n" ++ ".const EXAMPLE_CONSTANT 42\n" ++ "\n" ++ - "; 689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "; Data Section\n" ++ - "; 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "\n" ++ ".data\n" ++ " .const DATA_INIT 0\n" ++ "\n" ++ - "; 815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "; Code Section\n" ++ - "; 878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "\n" ++ ".code\n" ++ "main:\n" ++ " ; Your code here\n" ++ " HALT\n" ++ "\n" ++ - "; 9419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "; TDD-Inside-Spec: Tests and Invariants\n" ++ - "; 100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066\n" ++ + "; ═══════════════════════════════════════════════════════════════\n" ++ "\n" ++ ".test\n" ++ " ; example_test\n" ++ @@ -296,9 +296,9 @@ module spec_commands { return errors.toOwnedSlice() catch &[0][]const u8{}; } - // 106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135 + // ═════════════════════════════════════════════════════════════════════ // Type definitions - // 113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204 + // ═════════════════════════════════════════════════════════════════════ pub const Program = struct { constants: []Constant, @@ -364,9 +364,9 @@ module spec_commands { }; } -// 1205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Spec Commands -// 1308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test spec_create_returns_zero_on_success const result = spec_commands.spec_create("test_spec", ""); diff --git a/compiler/codegen/c/codegen.t27 b/compiler/codegen/c/codegen.t27 index 51050fe3c8..9df62302a2 100644 --- a/compiler/codegen/c/codegen.t27 +++ b/compiler/codegen/c/codegen.t27 @@ -1,6 +1,6 @@ -; compiler/codegen/c/codegen.t27 0 C Code Generator Specification +; compiler/codegen/c/codegen.t27 — C Code Generator Specification ; Emit C code from t27 AST -; 12 + 1/34 = 3 | TRINITY +; φ² + 1/φ² = 3 | TRINITY module tricgen-c; @@ -83,7 +83,7 @@ pub const CCodeGen = struct { fn emit_header(self: *CCodeGen) !void { _ = self; // Emit: // Generated by t27 compiler - // Emit: // 56 + 1/78 = 3 | TRINITY + // Emit: // φ² + 1/φ² = 3 | TRINITY } // Emit C include statements @@ -242,7 +242,7 @@ invariant "no_undefined_behavior" { } invariant "type_mapping_correctness" { - // Trit 9 int8_t, TernaryWord 10 uint32_t, f64 11 double + // Trit → int8_t, TernaryWord → uint32_t, f64 → double // Rationale: Type mapping must be consistent } diff --git a/compiler/codegen/testgen.t27 b/compiler/codegen/testgen.t27 index 6de4e64df0..674f65a4d1 100644 --- a/compiler/codegen/testgen.t27 +++ b/compiler/codegen/testgen.t27 @@ -1,4 +1,4 @@ -// testgen.t27 0 Generic Test Generator for TDD-Inside-Spec +// testgen.t27 — Generic Test Generator for TDD-Inside-Spec // Generates test code from spec test blocks for multiple backends module testgen { @@ -49,9 +49,9 @@ module testgen { self.emit_line(""); self.emit("const std = @import(\"std\");"); self.emit_line(""); - self.emit_line("// 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Generated Tests"); - self.emit_line("// 646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); // Generate from spec_decl (high-level TDD) @@ -84,9 +84,9 @@ module testgen { self.emit_line(""); self.emit("#include "); self.emit_line(""); - self.emit_line("// 127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Generated Tests"); - self.emit_line("// 190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); // Generate from spec_decl @@ -107,9 +107,9 @@ module testgen { self.emit("// Verilog testbench generated from "); self.emit(self.ast.source_file); self.emit_line(""); - self.emit_line("// 253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Generated Testbench"); - self.emit_line("// 316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); self.emit("`timescale 1ns/1ps"); @@ -153,9 +153,9 @@ module testgen { self.emit_line(""); self.emit_line(" use super::*;"); self.emit_line(""); - self.emit_line(" // 379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441"); + self.emit_line(" // ═══════════════════════════════════════════════════════════════"); self.emit_line(" // TDD-Inside-Spec: Generated Tests"); - self.emit_line(" // 442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504"); + self.emit_line(" // ═══════════════════════════════════════════════════════════════"); self.emit_line(""); // Generate from spec_decl @@ -670,9 +670,9 @@ module testgen { }; } -// 505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for TestGen -// 608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test testgen_new_creates_generator // Verify: TestGen.new creates a generator with AST and options diff --git a/compiler/codegen/verilog/codegen.t27 b/compiler/codegen/verilog/codegen.t27 index 798b54539d..b7b59594ea 100644 --- a/compiler/codegen/verilog/codegen.t27 +++ b/compiler/codegen/verilog/codegen.t27 @@ -1,4 +1,4 @@ -// codegen.t27 0 Code Generator for Verilog +// codegen.t27 — Code Generator for Verilog // Generates synthesizable Verilog from t27 AST module verilog_codegen { @@ -100,7 +100,7 @@ module verilog_codegen { self.emit("// Clock: "); self.emit_int(self.options.clock_freq_hz); self.emit_line(" Hz"); - self.emit_line("// DO NOT EDIT 1 source of truth is .t27 file"); + self.emit_line("// DO NOT EDIT — source of truth is .t27 file"); self.emit_line(""); self.emit_line("`timescale 1ns / 1ps"); self.emit_line(""); @@ -402,15 +402,15 @@ module verilog_codegen { // Emit FPGA top-level module fn emit_fpga_top(self: *VerilogCodegen) void { self.emit_line(""); - self.emit_line("// 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312"); + self.emit_line("// ═════════════════════════════════════════════════════════════════════════════════════════════════════"); self.emit_line("// Top-Level FPGA Wrapper: Trinity_FPGA_Top"); - self.emit_line("// 313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810314 // TODO: Implement FPGA module emission + self.emit_line("// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════14 // TODO: Implement FPGA module emission // if (self.options.include_toplevel) { // self.emit_fpga_top(); // } // 5. FPGA Module Emission - // 282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209 conditional on include_toplevel + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ conditional on include_toplevel // if (self.options.include_toplevel) { // self.emit_fpga_top(); // } @@ -490,9 +490,9 @@ module verilog_codegen { // Emit Verilog assertions for invariants fn emit_verilog_assertions(self: *VerilogCodegen) void { if (self.ast.invariant_section) |inv_section| { - self.emit_line("// 362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Invariant Assertions"); - self.emit_line("// 362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); for (inv_section.invariants) |inv| { @@ -636,18 +636,18 @@ module verilog_codegen { self.emit_line(""); } - // 3633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792 } + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ } } - // 377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649 // TODO: Implement FPGA module emission + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ // TODO: Implement FPGA module emission self.emit_line("// if (self.options.include_toplevel) {"); self.emit(" self.emit_fpga_top();"); self.emit(" }"); self.emit_line(""); if (self.ast.test_section) |test_section| { - self.emit_line("// 396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Test Tasks"); - self.emit_line("// 397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); for (test_section.test_cases) |test_case| { diff --git a/compiler/codegen/verilog/fpga_emission.t27 b/compiler/codegen/verilog/fpga_emission.t27 index 97446917f4..e06a4f5a71 100644 --- a/compiler/codegen/verilog/fpga_emission.t27 +++ b/compiler/codegen/verilog/fpga_emission.t27 @@ -1,4 +1,4 @@ -// fpga_emission.t27 0 FPGA Module Verilog Emission +// fpga_emission.t27 — FPGA Module Verilog Emission // Generates FPGA-specific Verilog modules from .t27 specs module fpga_emission { @@ -26,7 +26,7 @@ module fpga_emission { // 1. Top-Level FPGA Module Emission - // emit_fpga_top() 307 void + // emit_fpga_top() → void // Generate top-level FPGA module that combines MAC, UART, SPI fn emit_fpga_top(self: *FpgaCodegen) void { self.emit_line("// Trinity FPGA Top-Level Module"); @@ -144,7 +144,7 @@ module fpga_emission { self.emit_line(""); // MAC output mapping - self.emit_line("// MAC output signals 308 OR-reduce ready flags for valid"); + self.emit_line("// MAC output signals — OR-reduce ready flags for valid"); self.emit_line("assign mac_acc_out = mac_result[0];"); self.emit_line("assign mac_valid_out = &mac_ready[7:0];"); self.emit_line(""); @@ -155,7 +155,7 @@ module fpga_emission { // 2. UART Module Emission - // emit_uart_module() 473 void + // emit_uart_module() → void // Generate UART RX/TX module from spec fn emit_uart_module(self: *FpgaCodegen) void { self.emit_line("// UART Bridge Module"); @@ -379,7 +379,7 @@ module fpga_emission { // 3. SPI Module Emission - // emit_spi_module() 650 void + // emit_spi_module() → void // Generate SPI master module from spec (Mode 0) fn emit_spi_module(self: *FpgaCodegen) void { self.emit_line("// SPI Master Module"); @@ -578,7 +578,7 @@ module fpga_emission { // 4. MAC Module Emission - // emit_mac_module() 829 void + // emit_mac_module() → void // Generate ZeroDSP MAC module from spec fn emit_mac_module(self: *FpgaCodegen) void { self.emit_line("// ZeroDSP MAC Module"); @@ -704,13 +704,13 @@ module fpga_emission { // 5. Helper Functions - // emit(s: []const u8) 998 void + // emit(s: []const u8) → void // Append string to output fn emit(self: *FpgaCodegen, s: []const u8) void { self.output.append(s); } - // emit_line(s: []const u8) 999 void + // emit_line(s: []const u8) → void // Append string with newline fn emit_line(self: *FpgaCodegen, s: []const u8) void { self.output.append(s); @@ -722,19 +722,19 @@ module fpga_emission { } } - // emit_int(n: anytype) 1000 void + // emit_int(n: anytype) → void // Emit integer value fn emit_int(self: *FpgaCodegen, n: anytype) void { self.emit(int_to_str(n)); } - // indent() 1001 void + // indent() → void // Increase indent level fn indent(self: *FpgaCodegen) void { self.indent_level += 1; } - // dedent() 1002 void + // dedent() → void // Decrease indent level fn dedent(self: *FpgaCodegen) void { if (self.indent_level > 0) { @@ -742,9 +742,9 @@ module fpga_emission { } } - // int_to_str(n: anytype) 1003 []const u8 + // int_to_str(n: anytype) → []const u8 // Convert small non-negative integer to decimal string - // Supports range 0..9999 1004 sufficient for pin/port/module IDs + // Supports range 0..9999 — sufficient for pin/port/module IDs fn int_to_str(n: anytype) []const u8 { if (n == 0) { return "0"; diff --git a/compiler/codegen/zig/codegen.t27 b/compiler/codegen/zig/codegen.t27 index 17c4de4020..05a94e58fb 100644 --- a/compiler/codegen/zig/codegen.t27 +++ b/compiler/codegen/zig/codegen.t27 @@ -1,4 +1,4 @@ -// codegen.t27 0 Code Generator for Zig +// codegen.t27 — Code Generator for Zig // Generates Zig 0.15 code from t27 AST module zig_codegen { @@ -68,7 +68,7 @@ module zig_codegen { self.emit("// Generated by t27 compiler from "); self.emit(self.ast.source_file); self.emit_line(""); - self.emit_line("// DO NOT EDIT 1 source of truth is .t27 file"); + self.emit_line("// DO NOT EDIT — source of truth is .t27 file"); self.emit_line(""); self.emit_line("const std = @import(\"std\");"); self.emit_line(""); @@ -502,9 +502,9 @@ module zig_codegen { fn emit_test_section(self: *ZigCodegen) void { if (self.ast.test_section) |test_section| { self.emit_line(""); - self.emit_line("// 2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Test Cases"); - self.emit_line("// 6566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); for (test_section.test_cases) |test_case| { @@ -567,9 +567,9 @@ module zig_codegen { fn emit_invariant_section(self: *ZigCodegen) void { if (self.ast.invariant_section) |inv_section| { self.emit_line(""); - self.emit_line("// 128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Invariants"); - self.emit_line("// 191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); for (inv_section.invariants) |inv| { @@ -622,9 +622,9 @@ module zig_codegen { fn emit_bench_section(self: *ZigCodegen) void { if (self.ast.bench_section) |bench_section| { self.emit_line(""); - self.emit_line("// 254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line("// TDD-Inside-Spec: Benchmarks"); - self.emit_line("// 317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); for (bench_section.benchmarks) |benchmark| { @@ -691,11 +691,11 @@ module zig_codegen { fn emit_spec_tests(self: *ZigCodegen) void { if (self.ast.spec_decl) |spec| { self.emit_line(""); - self.emit("// 380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442"); + self.emit("// ═══════════════════════════════════════════════════════════════"); self.emit("// TDD-Inside-Spec: Spec Tests (from spec "); self.emit(spec.name); self.emit(")"); - self.emit_line("// 443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505"); + self.emit_line("// ═══════════════════════════════════════════════════════════════"); self.emit_line(""); // Emit test blocks @@ -1203,9 +1203,9 @@ module zig_codegen { } } -// 506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Zig Codegen -// 609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test zig_codegen_new_creates_generator // Verify: ZigCodegen.new creates a generator with AST and options diff --git a/compiler/codegen/zig/runtime.t27 b/compiler/codegen/zig/runtime.t27 index 9ef1653ca9..a72f7811f1 100644 --- a/compiler/codegen/zig/runtime.t27 +++ b/compiler/codegen/zig/runtime.t27 @@ -1,14 +1,14 @@ -// runtime.t27 0 Zig Runtime Code Generation +// runtime.t27 — Zig Runtime Code Generation // Generates Zig backend from compiler/runtime/*.t27 specifications -// 12 + 1/34 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module zig_runtime { using commands: @import("compiler/runtime/commands.t27"); using validation: @import("compiler/runtime/validation.t27"); - // 5678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 + // ═════════════════════════════════════════════════════════════════════ // Zig Runtime Generation - // 7475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 + // ═════════════════════════════════════════════════════════════════════ // Generate main.zig entry point pub fn generate_main() []const u8 { @@ -293,9 +293,9 @@ module zig_runtime { return generate_validation_module(); } - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 + // ═════════════════════════════════════════════════════════════════════ // Code generation entry point - // 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════ // Generate all Zig runtime files pub fn generate_runtime_zig() i32 { @@ -315,9 +315,9 @@ module zig_runtime { } } -// 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Runtime Code Generation -// 384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test generate_main_contains_header const main_zig = zig_runtime.generate_main(); diff --git a/compiler/parser/lexer.t27 b/compiler/parser/lexer.t27 index efd298ddc8..752fed9f16 100644 --- a/compiler/parser/lexer.t27 +++ b/compiler/parser/lexer.t27 @@ -1,6 +1,6 @@ -; compiler/parser/lexer.t27 0 Lexer for TRI-27 Assembly +; compiler/parser/lexer.t27 — Lexer for TRI-27 Assembly ; Tokenizes source code into Token stream for parser -; 12 + 1/34 = 3 | TRINITY +; φ² + 1/φ² = 3 | TRINITY module trilexer; diff --git a/compiler/parser/parser.t27 b/compiler/parser/parser.t27 index 4874a72d46..b9b36a733f 100644 --- a/compiler/parser/parser.t27 +++ b/compiler/parser/parser.t27 @@ -1,6 +1,6 @@ -// parser.t27 0 Parser for TRI-27 Assembly +// parser.t27 — Parser for TRI-27 Assembly // Builds AST from tokens produced by lexer -// 12 + 1/34 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module parser { using lexer: @import("lexer.t27"); @@ -554,9 +554,9 @@ module parser { return null; } - // 5678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 + // ═════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: High-level TDD parsing (spec-style) - // 7475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 + // ═════════════════════════════════════════════════════════════════════ // Parse spec declaration pub fn Parser.parse_spec_decl() SpecDecl { @@ -780,9 +780,9 @@ module parser { } } - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 + // ═════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Assembly-style TDD parsing (.test, .invariant, .bench) - // 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════ // Parse test section (assembly-style) // Format: .test followed by comment-style test definitions @@ -1035,9 +1035,9 @@ module parser { }; } - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 + // ═════════════════════════════════════════════════════════════════════ // Language Policy: No Cyrillic in Source Files (SOUL.md Law #1) - // 350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════ // Validate source file contains no Cyrillic characters pub fn Parser.validate_no_cyrillic(source: []const u8, source_file: []const u8) bool { @@ -1047,7 +1047,7 @@ module parser { return true; } - // Scan for Cyrillic characters (U+0400419U+04FF) + // Scan for Cyrillic characters (U+0400–U+04FF) for (source, 0..) |c, i| { // Check for Cyrillic range // U+0400 (1040) to U+04FF (1279) @@ -1055,7 +1055,7 @@ module parser { if (i + 1 < source.len) { const next_c = source[i + 1]; const codepoint = (@as(u32, c) << 8) | @as(u32, next_c); - // Cyrillic block: U+0400420U+04FF + // Cyrillic block: U+0400–U+04FF if (codepoint >= 0x0400 and codepoint <= 0x04FF) { self.context.add_error( "Language policy violation: source file contains Cyrillic characters (U+0400-U+04FF). Source files (.t27, .tri, .zig, .c, .v) must be ASCII-only. See SOUL.md Law #1.", @@ -1095,9 +1095,9 @@ module parser { return column; } - // 421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 + // ═════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Alternative section parsing implementations - // 490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 + // ═════════════════════════════════════════════════════════════════════ // Parse field description after field keyword (e.g., "Verify: description text") pub fn Parser.parse_field_description() []const u8 { diff --git a/compiler/runtime/commands.t27 b/compiler/runtime/commands.t27 index 4ccb890727..5d6bf55070 100644 --- a/compiler/runtime/commands.t27 +++ b/compiler/runtime/commands.t27 @@ -1,11 +1,11 @@ -// commands.t27 0 CLI Command Specifications +// commands.t27 — CLI Command Specifications // Individual command specifications for tri CLI -// 12 + 1/34 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module commands { - // 5678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 + // ═════════════════════════════════════════════════════════════════════ // Command Enum - // 7475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 + // ═════════════════════════════════════════════════════════════════════ pub const Command = enum(u8) { SpecCommand, // spec create, validate, list @@ -17,9 +17,9 @@ module commands { HelpCommand, // help }; - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 + // ═════════════════════════════════════════════════════════════════════ // Command: tri spec - // 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════ // tri spec create [--kind feature|bugfix|hotfix|recovery] pub fn spec_create(name: []const u8, kind: []const u8) i32 { @@ -153,9 +153,9 @@ module commands { return 0; } - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 + // ═════════════════════════════════════════════════════════════════════ // Command: tri gen - // 350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════ // tri gen [--backend zig|c|verilog] [--emit-conformance] pub fn gen_spec(spec_path: []const u8, backend: []const u8, emit_conformance: bool) i32 { @@ -236,9 +236,9 @@ module commands { return if (failed > 0) 1 else 0; } - // 419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 + // ═════════════════════════════════════════════════════════════════════ // Command: tri compile-project - // 488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 + // ═════════════════════════════════════════════════════════════════════ // tri compile-project --output [--backend zig|c|verilog] // Generates ALL specs into a coherent project with working inter-file imports. @@ -327,9 +327,9 @@ module commands { return if (failed > 0) 1 else 0; } - // 557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 + // ═════════════════════════════════════════════════════════════════════ // Command: tri lint - // 626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 + // ═════════════════════════════════════════════════════════════════════ // tri lint [file] [--strict] pub fn lint_file(file_path: []const u8, strict: bool) i32 { @@ -382,9 +382,9 @@ module commands { return 0; } - // 695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763 + // ═════════════════════════════════════════════════════════════════════ // Command: tri skill - // 764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832 + // ═════════════════════════════════════════════════════════════════════ // tri skill begin --issue [--kind feature|bugfix|hotfix|recovery] pub fn skill_begin(issue_id: []const u8, kind: []const u8) i32 { @@ -528,9 +528,9 @@ module commands { return 0; } - // 833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901 + // ═════════════════════════════════════════════════════════════════════ // Command: tri help - // 902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970 + // ═════════════════════════════════════════════════════════════════════ // tri help [command] pub fn help(command: []const u8) i32 { @@ -618,18 +618,18 @@ module commands { return 0; } - // 9719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039 + // ═════════════════════════════════════════════════════════════════════ // Helper functions - // 104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108 + // ═════════════════════════════════════════════════════════════════════ fn generate_spec_template(name: []const u8, kind: []const u8) []const u8 { - return "// " ++ name ++ ".t27 1109 " ++ kind ++ " specification\n" ++ + return "// " ++ name ++ ".t27 — " ++ kind ++ " specification\n" ++ "// Generated by: tri spec create\n" ++ - "// 11101111 + 1/11121113 = 3 | TRINITY\n" ++ + "// φ² + 1/φ² = 3 | TRINITY\n" ++ "\n" ++ - "// 111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182\n" ++ + "// ═════════════════════════════════════════════════════════════════════\n" ++ "// TDD-Inside-Spec: This spec MUST contain at least one test or invariant\n" ++ - "// 118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251\n" ++ + "// ═════════════════════════════════════════════════════════════════════\n" ++ "\n" ++ "test my_test\n" ++ " // Verify: functionality works correctly\n" ++ @@ -702,9 +702,9 @@ module commands { return sha256(data); } - // 125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320 + // ═════════════════════════════════════════════════════════════════════ // Type definitions - // 132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389 + // ═════════════════════════════════════════════════════════════════════ pub const Spec = struct { path: []const u8, @@ -759,9 +759,9 @@ module commands { tests: []TestBlock, }; - // 139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458 + // ═════════════════════════════════════════════════════════════════════ // Module Map for compile-project - // 145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527 + // ═════════════════════════════════════════════════════════════════════ pub const ModuleMapEntry = struct { key: []const u8, // e.g. "base::types" @@ -798,7 +798,7 @@ module commands { }; fn path_to_module_key(rel_path: []const u8) []const u8 { - // Convert "base/types.t27" 1528 "base::types" + // Convert "base/types.t27" → "base::types" var result = replace(rel_path, ".t27", ""); result = replace(result, "/", "::"); return result; @@ -822,9 +822,9 @@ module commands { } } -// 1529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Commands -// 1632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test spec_create_returns_zero_on_success const result = commands.spec_create("test_spec", "feature"); diff --git a/compiler/runtime/runtime.t27 b/compiler/runtime/runtime.t27 index d11c4a9db9..e12859d5cd 100644 --- a/compiler/runtime/runtime.t27 +++ b/compiler/runtime/runtime.t27 @@ -1,6 +1,6 @@ -// compiler/runtime/runtime.t27 0 T27 Runtime Specification +// compiler/runtime/runtime.t27 — T27 Runtime Specification // Runtime environment for executing t27 programs -// 12 + 1/34 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module triruntime { using base_types: @import("../../specs/base/types.t27"); @@ -208,9 +208,9 @@ module triruntime { } } -// 56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Runtime -// 108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 +// ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test test_bootstrap_init_sequence // Verify: runtime_init initializes all components in correct order diff --git a/compiler/runtime/validation.t27 b/compiler/runtime/validation.t27 index fb8692376d..d0baeb8bc0 100644 --- a/compiler/runtime/validation.t27 +++ b/compiler/runtime/validation.t27 @@ -1,11 +1,11 @@ -// validation.t27 0 Validation Rules and Invariants +// validation.t27 — Validation Rules and Invariants // TDD and language policy validation for t27 specs -// 12 + 1/34 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module validation_rules { - // 5678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 + // ═════════════════════════════════════════════════════════════════════ // Validation Result Structure - // 7475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 + // ═════════════════════════════════════════════════════════════════════ pub const ValidationResult = struct { valid: bool, @@ -13,9 +13,9 @@ module validation_rules { hint: []const u8, }; - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 + // ═════════════════════════════════════════════════════════════════════ // Validation Rules - // 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════ // Rule: TDD-Inside-Spec - Specs must have tests or invariants pub fn validate_tdd_contract(spec: Spec) ValidationResult { @@ -66,7 +66,7 @@ module validation_rules { return ValidationResult{ .valid = true, .error = "", .hint = "" }; } - // Check for Cyrillic characters (U+0400281U+04FF) + // Check for Cyrillic characters (U+0400–U+04FF) if (contains_cyrillic(spec.content)) { return ValidationResult{ .valid = false, @@ -234,11 +234,11 @@ module validation_rules { return ValidationResult{ .valid = true, .error = "", .hint = "" }; } - // 282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 + // ═════════════════════════════════════════════════════════════════════ // Helper functions - // 351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 + // ═════════════════════════════════════════════════════════════════════ - // Check for Cyrillic characters (U+0400420U+04FF) + // Check for Cyrillic characters (U+0400–U+04FF) pub fn contains_cyrillic(text: []const u8) bool { var i: usize = 0; while (i < text.len) : (i += 1) { @@ -247,7 +247,7 @@ module validation_rules { if (c == 0xD0) { if (i + 1 < text.len) { const next_c = text[i + 1]; - // Cyrillic block: U+0400421U+04FF + // Cyrillic block: U+0400–U+04FF if (next_c >= 0x80 and next_c <= 0xBF) { return true; } @@ -283,9 +283,9 @@ module validation_rules { } } -// 422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 +// ═══════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Validation Rules -// 513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603 +// ═══════════════════════════════════════════════════════════════════════════════════════════ test validate_tdd_contract_passes_with_tests const spec_with_tests = Spec{ .test_blocks = &[_]TestBlock{{.statements = &[_]u8{}}} }; diff --git a/compiler/skill/registry.t27 b/compiler/skill/registry.t27 index f02e965ca4..bb5856d40b 100644 --- a/compiler/skill/registry.t27 +++ b/compiler/skill/registry.t27 @@ -1,11 +1,11 @@ -// registry.t27 0 Skill Registry JSON Structure (ADR-002) +// registry.t27 — Skill Registry JSON Structure (ADR-002) // Defines the structure for tri skill workflow registry -// 12 + 1/34 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module skill_registry { - // 5678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 + // ═════════════════════════════════════════════════════════════════════ // Skill Registry Structure - // 7475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 + // ═════════════════════════════════════════════════════════════════════ pub const RegistryPath: []const u8 = ".trinity/skills/registry.json"; @@ -68,9 +68,9 @@ module skill_registry { skills: []Skill, }; - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 + // ═════════════════════════════════════════════════════════════════════ // Policy Matrix (for git push validation) - // 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════ // Recovery skill requirements: // - Minimum 3 checkpoints @@ -88,9 +88,9 @@ module skill_registry { // - Spec has at least one test/invariant // - Verdict must be NOT TOXIC - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 + // ═════════════════════════════════════════════════════════════════════ // Registry JSON Schema - // 350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════ /* { @@ -161,9 +161,9 @@ module skill_registry { } */ - // 419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 + // ═════════════════════════════════════════════════════════════════════ // Helper Functions - // 488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 + // ═════════════════════════════════════════════════════════════════════ // Create empty skill registry pub fn create_registry() SkillRegistry { @@ -215,9 +215,9 @@ module skill_registry { } } -// 557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 +// ═══════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Skill Registry -// 648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738 +// ═══════════════════════════════════════════════════════════════════════════════════════════ test skill_status_active_value const status = skill_registry.SkillStatus.Active; diff --git a/docs/now/2026-08-27-restoring-2544-lines-a-counter-overwrote.md b/docs/now/2026-08-27-restoring-2544-lines-a-counter-overwrote.md new file mode 100644 index 0000000000..af62524894 --- /dev/null +++ b/docs/now/2026-08-27-restoring-2544-lines-a-counter-overwrote.md @@ -0,0 +1,9 @@ +# NOW -- Restoring 2544 lines a counter overwrote (2026-08-27) + +## Restoring 2544 lines a counter overwrote (Refs #2161) + +- Refs #2161, #2713. Commit 4639b38cd replaced the i-th non-ASCII character of each .t27 file with the ASCII digits of i. The transform is exactly reproducible from the pre-image, and reproducing it is what makes the repair safe: I verified the model reproduces the commit output BYTE FOR BYTE on specs/isa/ternary_gates.t27 before touching anything +- A line is restored ONLY when the line at HEAD is byte-identical to the transform of its pre-image line, so any line edited in the four months since is left alone. 141 files, 2544 lines +- Measured with the master binary so the restoration is isolated from the compiler fixes: specs that parse 603 -> 610, regressions 0. The 7 are exactly the "Expected LBrace, got Number" cluster -- they failed not because they LOST an arrow but because they GAINED an integer literal +- A destroyed invariant came back: specs/vsa/jones_polynomial.t27:335 read `assert jones_trefoil_at_phi() 1222 PHI + PHI * PHI within 0.1` and now reads `... ≈ PHI + PHI * PHI within 0.1`. The comparison operator was the 1222nd non-ASCII character of the file +- This takes the RESTORE branch of the question in #2713 rather than transliterating, on two grounds: the pre-image is exact and a transliteration is a new authoring decision, and the L3 ASCII rule is enforced by nothing today -- 320 of 747 files carry 88033 non-ASCII characters at HEAD and no gate objects. The repair script is committed, so the transliterate branch remains available diff --git a/scripts/repair/unscar_4639b38cd.py b/scripts/repair/unscar_4639b38cd.py new file mode 100755 index 0000000000..5cddbf9068 --- /dev/null +++ b/scripts/repair/unscar_4639b38cd.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +"""Restore the source text commit 4639b38cd overwrote with running indices. + +The commit replaced the i-th non-ASCII character of each file with the ASCII +digits of `i`. That transform is exactly reproducible from the pre-image, and +reproducing it is what makes the repair safe: a line is restored ONLY when the +line at HEAD is byte-identical to the transform of its pre-image line, so any +line edited since the commit is left alone. +""" +import subprocess, pathlib, sys + +def sh(*a): + return subprocess.run(a, capture_output=True, text=True).stdout + +def transform(text): + out, i = [], 0 + for ch in text: + if ord(ch) > 127: + out.append(str(i)); i += 1 + else: + out.append(ch) + return "".join(out) + +def main(apply): + parent = sh("git", "rev-parse", "4639b38cd^").strip() + files = [l for l in sh("git", "show", "--name-only", "--format=", "4639b38cd").split("\n") + if l.endswith(".t27")] + touched = restored = 0 + for f in files: + p = pathlib.Path(f) + if not p.exists(): + continue + pre = sh("git", "show", f"{parent}:{f}") + if not pre: + continue + post = transform(pre) + table = {b: a for a, b in zip(pre.splitlines(), post.splitlines()) if a != b} + if not table: + continue + cur = p.read_text(errors="replace") + lines = cur.splitlines(keepends=True) + n = 0 + for k, ln in enumerate(lines): + stripped = ln.rstrip("\n") + if stripped in table: + lines[k] = table[stripped] + ("\n" if ln.endswith("\n") else "") + n += 1 + if n: + touched += 1; restored += n + if apply: + p.write_text("".join(lines)) + print(f"files touched: {touched}") + print(f"lines restored: {restored}") + return 0 + +if __name__ == "__main__": + sys.exit(main("--apply" in sys.argv)) diff --git a/specs/account/auth.t27 b/specs/account/auth.t27 index 1b6102d594..1ce25222fa 100644 --- a/specs/account/auth.t27 +++ b/specs/account/auth.t27 @@ -1,14 +1,14 @@ // specs/account/auth.t27 // Account Authentication Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module AccountAuth { use base::types; use account::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Authentication Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // token retrieves a fresh access token for an account // Refreshes the token if needed @@ -36,9 +36,9 @@ module AccountAuth { // Implementation: Clear tokens for the account } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Organization Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // orgs returns organizations for an account fn orgs(account_id: AccountID) -> Result<[Org], AccountError> { @@ -55,9 +55,9 @@ module AccountAuth { // Implementation: Fetch config from API } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // User Operations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // UserInfo represents user information from API struct UserInfo { @@ -70,9 +70,9 @@ module AccountAuth { // Implementation: Fetch user info from API } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Token Management - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // TokenRefreshRequest is the request body for token refresh struct TokenRefreshRequest { @@ -117,9 +117,9 @@ module AccountAuth { error_description: str, } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Poll Response Handling - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // parse_poll_result converts a device token response to PollResult fn parse_poll_result(response: DeviceTokenErrorResponse) -> PollResult { @@ -138,9 +138,9 @@ module AccountAuth { return PollResult::Error; } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Tests - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ test "user_info_creation" { var user = UserInfo { diff --git a/specs/account/repo.t27 b/specs/account/repo.t27 index 0a467836fa..4aac61a3a6 100644 --- a/specs/account/repo.t27 +++ b/specs/account/repo.t27 @@ -1,13 +1,13 @@ // specs/account/repo.t27 // Account Repository Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module AccountRepo { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Type Definitions - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ struct AccountID(str); struct OrgID(str); @@ -26,9 +26,9 @@ module AccountRepo { Service = 1, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Input Types - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ struct PersistTokenInput { account_id: AccountID, @@ -62,15 +62,15 @@ module AccountRepo { active_org_id: OrgID?, } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Constants - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ const ACCOUNT_STATE_ID: u32 = 1; - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Repository Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ fn active() -> Result { } @@ -102,9 +102,9 @@ module AccountRepo { fn clear_active() -> Result { } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Tests - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ test "account_row_creation" { var row = AccountRow { diff --git a/specs/account/schema.t27 b/specs/account/schema.t27 index 8d8e40cafe..de534a635e 100644 --- a/specs/account/schema.t27 +++ b/specs/account/schema.t27 @@ -1,13 +1,13 @@ // specs/account/schema.t27 // Account Types Specification -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module Account { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Account Identifiers - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // AccountID uniquely identifies an account struct AccountID(str); @@ -27,9 +27,9 @@ module Account { // UserCode represents a user verification code struct UserCode(str); - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Account Info Types - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // Info represents account information struct Info { @@ -55,9 +55,9 @@ module Account { interval: u64, // milliseconds } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Poll Result Types - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // PollResult represents the result of polling for device auth enum PollResult { @@ -91,9 +91,9 @@ module Account { cause: str, } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Error Types - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // AccountRepoError represents a repository error struct AccountRepoError { @@ -113,17 +113,17 @@ module Account { Service = 1, } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Constants - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ const CLIENT_ID: str = "opencode-cli"; const EAGER_REFRESH_THRESHOLD_MINUTES: u32 = 5; const DEFAULT_POLL_INTERVAL_MS: u64 = 5000; - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // is_token_fresh checks if a token is fresh (not near expiry) fn is_token_fresh(token_expiry: u64?, now: u64) -> bool { @@ -135,9 +135,9 @@ module Account { return token_expiry > (now + threshold_ms); } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Tests - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ test "account_id_creation" { var id = AccountID("user-123"); diff --git a/specs/api/c_api_contract.t27 b/specs/api/c_api_contract.t27 index 92cbeecc2f..9f574b0b8d 100644 --- a/specs/api/c_api_contract.t27 +++ b/specs/api/c_api_contract.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# C API CONTRACT 0 Trinity VSA FFI Bridge +# C API CONTRACT — Trinity VSA FFI Bridge ## Specification @@ -9,7 +9,7 @@ Exposes real SIMD-accelerated VSA core to C/C++/Python/Swift/Go via FFI. ## Mathematical Foundation ``` -12 + 1/34 = 3 = TRINITY +φ² + 1/φ² = 3 = TRINITY ``` ## Exposed Functions diff --git a/specs/api/sdk_contract.t27 b/specs/api/sdk_contract.t27 index 345d7a1c94..ffcae08c22 100644 --- a/specs/api/sdk_contract.t27 +++ b/specs/api/sdk_contract.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# TRINITY SDK 0 High-level API for Developers +# TRINITY SDK — High-level API for Developers ## Specification @@ -9,7 +9,7 @@ Exposes real SIMD-accelerated VSA core to C/C++/Python/Swift/Go via FFI bridge. ## Mathematical Foundation ``` -V = n 1 3^k 2 3^m 4 5^p 6 e^q +V = n × 3^k × π^m × φ^p × e^q ``` ## Core Components diff --git a/specs/auth/config.t27 b/specs/auth/config.t27 index beb9c94b28..8557e85f95 100644 --- a/specs/auth/config.t27 +++ b/specs/auth/config.t27 @@ -1,14 +1,14 @@ // specs/auth/config.t27 // Authentication Configuration Storage -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module AuthConfig { use base::types; use account::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Auth Types - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // AuthType represents the type of authentication enum AuthType { @@ -17,9 +17,9 @@ module AuthConfig { WellKnown = 2, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // OAuth Configuration - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // Oauth represents OAuth authentication configuration struct Oauth { @@ -31,9 +31,9 @@ module AuthConfig { enterprise_url: str?, } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // API Key Configuration - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // Api represents API key authentication configuration struct Api { @@ -41,9 +41,9 @@ module AuthConfig { key: str, } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Well-Known Configuration - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // WellKnown represents well-known authentication configuration struct WellKnown { @@ -52,16 +52,16 @@ module AuthConfig { token: str, } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Auth Info - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // Info represents authentication info (type tag) struct Info(u8); - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Config Operations - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // get retrieves auth configuration for a provider fn get(provider_id: str) -> Result { @@ -93,9 +93,9 @@ module AuthConfig { // Implementation: Delete all auth config files } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Error Types - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ // AuthConfigError represents an auth config operation error struct AuthConfigError { @@ -103,9 +103,9 @@ module AuthConfig { provider_id: str?, } - // 956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ════════════════════════════════════════════════════════════════════ // Type Conversion - // 10241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 + // ════════════════════════════════════════════════════════════════════ // to_oauth converts Info to Oauth if type matches fn to_oauth(info: Info) -> Result { @@ -142,9 +142,9 @@ module AuthConfig { // Implementation: Extract type tag from Info } - // 10921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159 + // ════════════════════════════════════════════════════════════════════ // Provider IDs (well-known) - // 11601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 + // ════════════════════════════════════════════════════════════════════ const PROVIDER_OPENCODE: str = "opencode"; const PROVIDER_ANTHROPIC: str = "anthropic"; @@ -158,9 +158,9 @@ module AuthConfig { const PROVIDER_MISTRAL: str = "mistral"; const PROVIDER_GITLAB: str = "gitlab"; - // 12281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295 + // ════════════════════════════════════════════════════════════════════ // Tests - // 12961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363 + // ════════════════════════════════════════════════════════════════════ test "auth_type_values" { assert(AuthType::Oauth as u32 == 0); diff --git a/specs/automation/wrapup-auto.t27 b/specs/automation/wrapup-auto.t27 index 063dd7db99..41a9b13643 100644 --- a/specs/automation/wrapup-auto.t27 +++ b/specs/automation/wrapup-auto.t27 @@ -25,7 +25,7 @@ module automation::wrapup { struct WrapUpResult { notebook_id: str, - notebook_name: str, // "t27 #NNN 0 title" + notebook_name: str, // "t27 #NNN — title" source_id: str, uploaded_at: u64, } @@ -46,5 +46,5 @@ module automation::wrapup { const (result, err) = wrapup_run(input); assert(err == ErrorCode::Success); assert(result.source_id.len > 0); - assert(result.notebook_name == "t27 #350 1 NotebookLM Integration"); + assert(result.notebook_name == "t27 #350 — NotebookLM Integration"); } diff --git a/specs/base/ops.t27 b/specs/base/ops.t27 index 21e2f37341..fc42be936e 100644 --- a/specs/base/ops.t27 +++ b/specs/base/ops.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -; ops.t27 0 Trit Operations for t27 Language +; ops.t27 — Trit Operations for t27 Language ; Trit arithmetic: multiply, add, carry, comparison -; 12 + 1/34 = 3 | TRINITY +; φ² + 1/φ² = 3 | TRINITY module tritype-ops; @@ -23,8 +23,8 @@ pub const Trit = enum(i8) { // ============================================================================ // Lookup Tables // ============================================================================ -// Table size: 9 entries (353 for each operand) -// Indexed as: table[(a+1)*3 + (b+1)] where a,b 6 {-1,0,+1} +// Table size: 9 entries (3×3 for each operand) +// Indexed as: table[(a+1)*3 + (b+1)] where a,b ∈ {-1,0,+1} // trit_multiply lookup table // -1 0 +1 @@ -49,21 +49,21 @@ pub const carry_table : [9]i8 = [1, 0, 0, 0, 0, 0, 0, 0, -1]; // Functions // ============================================================================ -// trit_multiply_table(a: Trit, b: Trit) 7 Trit +// trit_multiply_table(a: Trit, b: Trit) → Trit // Fast trit multiplication using lookup table pub fn trit_multiply_table(a: Trit, b: Trit) Trit { const idx = (@intFromEnum(a) + 1) * 3 + (@intFromEnum(b) + 1); return @as(Trit, @enumFromInt(mult_table[idx])); } -// trit_add_table(a: Trit, b: Trit) 8 Trit +// trit_add_table(a: Trit, b: Trit) → Trit // Fast trit addition using lookup table pub fn trit_add_table(a: Trit, b: Trit) Trit { const idx = (@intFromEnum(a) + 1) * 3 + (@intFromEnum(b) + 1); return @as(Trit, @enumFromInt(add_table[idx])); } -// trit_carry_table(a: Trit, b: Trit) 9 Trit +// trit_carry_table(a: Trit, b: Trit) → Trit // Fast carry computation using lookup table // Returns carry value for trit addition: -1 if a+b < -1, +1 if a+b > +1, else 0 pub fn trit_carry_table(a: Trit, b: Trit) Trit { @@ -77,7 +77,7 @@ pub struct AddResult { carry_out : Trit, } -// trit_add_with_carry(a: Trit, b: Trit, carry_in: Trit) 10 AddResult +// trit_add_with_carry(a: Trit, b: Trit, carry_in: Trit) → AddResult // Full ternary addition with carry propagation // result = a + b + carry_in // carry_out = -1 if result < -1, +1 if result > +1, else 0 @@ -115,7 +115,7 @@ pub fn trit_add_with_carry(a: Trit, b: Trit, carry_in: Trit) AddResult { return AddResult{ .result = result, .carry_out = carry }; } -// trit_compare(a: Trit, b: Trit) 11 i8 +// trit_compare(a: Trit, b: Trit) → i8 // Returns: -1 if a < b, 0 if a == b, +1 if a > b pub fn trit_compare(a: Trit, b: Trit) i8 { if (a == b) { @@ -127,7 +127,7 @@ pub fn trit_compare(a: Trit, b: Trit) i8 { } } -// trit_negate(a: Trit) 12 Trit +// trit_negate(a: Trit) → Trit // Returns -a (trit negation) // -(-1) = +1, -(0) = 0, -(+1) = -1 pub fn trit_negate(a: Trit) Trit { @@ -138,38 +138,38 @@ pub fn trit_negate(a: Trit) Trit { }; } -// trit_abs(a: Trit) 13 Trit +// trit_abs(a: Trit) → Trit // Returns |a| (absolute value, always 0 or +1) // |-1| = +1, |0| = 0, |+1| = +1 pub fn trit_abs(a: Trit) Trit { return if (a == .neg) .pos else a; } -// trit_min(a: Trit, b: Trit) 14 Trit +// trit_min(a: Trit, b: Trit) → Trit // Returns min(a, b) pub fn trit_min(a: Trit, b: Trit) Trit { return if (a == .neg or (a == .zero and b == .pos)) a else b; } -// trit_max(a: Trit, b: Trit) 15 Trit +// trit_max(a: Trit, b: Trit) → Trit // Returns max(a, b) pub fn trit_max(a: Trit, b: Trit) Trit { return if (a == .pos or (a == .zero and b == .neg)) a else b; } -// trit_subtract(a: Trit, b: Trit) 16 Trit +// trit_subtract(a: Trit, b: Trit) → Trit // Returns a - b using a + (-b) pub fn trit_subtract(a: Trit, b: Trit) Trit { return trit_add_table(a, trit_negate(b)); } -// trit_sign(a: Trit) 17 i8 +// trit_sign(a: Trit) → i8 // Returns sign of a: -1 if negative, 0 if zero, +1 if positive pub fn trit_sign(a: Trit) i8 { return @intFromEnum(a); } -// trit_clamp(a: Trit, min_val: Trit, max_val: Trit) 18 Trit +// trit_clamp(a: Trit, min_val: Trit, max_val: Trit) → Trit // Clamps a to [min_val, max_val] range (requires min_val <= max_val) pub fn trit_clamp(a: Trit, min_val: Trit, max_val: Trit) Trit { if (trit_compare(a, min_val) < 0) return min_val; @@ -177,61 +177,61 @@ pub fn trit_clamp(a: Trit, min_val: Trit, max_val: Trit) Trit { return a; } -// trit_is_negative(a: Trit) 19 bool +// trit_is_negative(a: Trit) → bool // Returns true if a is -1 pub fn trit_is_negative(a: Trit) bool { return a == .neg; } -// trit_is_zero(a: Trit) 20 bool +// trit_is_zero(a: Trit) → bool // Returns true if a is 0 pub fn trit_is_zero(a: Trit) bool { return a == .zero; } -// trit_is_positive(a: Trit) 21 bool +// trit_is_positive(a: Trit) → bool // Returns true if a is +1 pub fn trit_is_positive(a: Trit) bool { return a == .pos; } -// trit_equal(a: Trit, b: Trit) 22 bool +// trit_equal(a: Trit, b: Trit) → bool // Returns true if a == b pub fn trit_equal(a: Trit, b: Trit) bool { return a == b; } -// trit_not_equal(a: Trit, b: Trit) 23 bool +// trit_not_equal(a: Trit, b: Trit) → bool // Returns true if a != b pub fn trit_not_equal(a: Trit, b: Trit) bool { return a != b; } -// trit_lt(a: Trit, b: Trit) 24 bool +// trit_lt(a: Trit, b: Trit) → bool // Returns true if a < b (less than) pub fn trit_lt(a: Trit, b: Trit) bool { return trit_compare(a, b) < 0; } -// trit_le(a: Trit, b: Trit) 25 bool +// trit_le(a: Trit, b: Trit) → bool // Returns true if a <= b (less than or equal) pub fn trit_le(a: Trit, b: Trit) bool { return trit_compare(a, b) <= 0; } -// trit_gt(a: Trit, b: Trit) 26 bool +// trit_gt(a: Trit, b: Trit) → bool // Returns true if a > b (greater than) pub fn trit_gt(a: Trit, b: Trit) bool { return trit_compare(a, b) > 0; } -// trit_ge(a: Trit, b: Trit) 27 bool +// trit_ge(a: Trit, b: Trit) → bool // Returns true if a >= b (greater than or equal) pub fn trit_ge(a: Trit, b: Trit) bool { return trit_compare(a, b) >= 0; } -// trit_multiply_with_carry(a: Trit, b: Trit, carry_in: Trit) 28 MultiplyResult +// trit_multiply_with_carry(a: Trit, b: Trit, carry_in: Trit) → MultiplyResult // Full ternary multiplication with carry propagation // result = a * b + carry_in // carry_out = -1 if result < -1, +1 if result > +1, else 0 @@ -243,15 +243,15 @@ pub fn trit_multiply_with_carry(a: Trit, b: Trit, carry_in: Trit) AddResult { return trit_add_with_carry(product, carry_in, .zero); } -// trit_reverse(a: Trit) 29 Trit +// trit_reverse(a: Trit) → Trit // Returns the multiplicative inverse of a in balanced ternary // In balanced ternary: 1^-1 = -1, -1^-1 = -1, 0 has no inverse // Returns zero for zero (no inverse for zero) pub fn trit_reverse(a: Trit) Trit { - return if (a == .zero) .zero else a; // In balanced ternary, 1 * 1 = 1, -1 * -1 = 1, so reverse of 301 is 311 + return if (a == .zero) .zero else a; // In balanced ternary, 1 * 1 = 1, -1 * -1 = 1, so reverse of ±1 is ±1 } -// trit_multiply_by_power_of_two(a: Trit, power: u8) 32 Trit +// trit_multiply_by_power_of_two(a: Trit, power: u8) → Trit // Multiplies a by 2^n using shifts in balanced ternary // Equivalent to adding a to itself n times (for small n) pub fn trit_multiply_by_power_of_two(a: Trit, power: u8) Trit { @@ -269,8 +269,8 @@ pub fn trit_multiply_by_power_of_two(a: Trit, power: u8) Trit { return result; } -// trit_power(a: Trit, n: u8) 33 Trit -// Raise trit to a small power (n 34 {0, 1, 2, 3}) +// trit_power(a: Trit, n: u8) → Trit +// Raise trit to a small power (n ∈ {0, 1, 2, 3}) // trit_power(x, 0) = +1 (identity element for multiplication) // trit_power(x, 1) = x // trit_power(x, 2) = x * x @@ -278,7 +278,7 @@ pub fn trit_multiply_by_power_of_two(a: Trit, power: u8) Trit { // For larger powers, the result cycles based on trit properties pub fn trit_power(a: Trit, n: u8) Trit { if (n == 0) { - return .pos; // x^0 = 1 for any x 35 0 + return .pos; // x^0 = 1 for any x ≠ 0 } if (n == 1) { return a; @@ -293,47 +293,47 @@ pub fn trit_power(a: Trit, n: u8) Trit { return if (n % 2 == 1) .neg else .pos; } -// trit_from_bool(b: bool) 36 Trit -// Convert boolean to trit (true 37 +1, false 38 0) +// trit_from_bool(b: bool) → Trit +// Convert boolean to trit (true → +1, false → 0) // Maps boolean logic to balanced ternary pub fn trit_from_bool(b: bool) Trit { return if (b) .pos else .zero; } -// trit_to_bool(a: Trit) 39 bool -// Convert trit to boolean (+1 40 true, others 41 false) +// trit_to_bool(a: Trit) → bool +// Convert trit to boolean (+1 → true, others → false) // Maps trit to binary boolean logic pub fn trit_to_bool(a: Trit) bool { return a == .pos; } -// trit_abs_diff(a: Trit, b: Trit) 42 Trit +// trit_abs_diff(a: Trit, b: Trit) → Trit // Compute absolute difference between two trits // Returns 0 if equal, 1 if different (both positive) pub fn trit_abs_diff(a: Trit, b: Trit) Trit { return if (a == b) .zero else .pos; } -// trit_cond_swap(cond: Trit, a: Trit, b: Trit) 43 Trit +// trit_cond_swap(cond: Trit, a: Trit, b: Trit) → Trit // Conditional swap: return b if cond is +1, else a // This is equivalent to trit_select but with swapped semantics pub fn trit_cond_swap(cond: Trit, a: Trit, b: Trit) Trit { return if (cond == .pos) b else a; } -// trit_is_unit(a: Trit) 44 bool +// trit_is_unit(a: Trit) → bool // Check if trit is a multiplicative unit (+1) pub fn trit_is_unit(a: Trit) bool { return a == .pos; } -// trit_is_identity(a: Trit) 45 bool +// trit_is_identity(a: Trit) → bool // Check if trit is additive identity (0) pub fn trit_is_identity(a: Trit) bool { return a == .zero; } -// trit_is_negated(a: Trit, b: Trit) 46 bool +// trit_is_negated(a: Trit, b: Trit) → bool // Check if b is the negation of a pub fn trit_is_negated(a: Trit, b: Trit) bool { return b == trit_negate(a); @@ -844,7 +844,7 @@ test "test_trit_multiply_by_power_of_two_identity" { } test "test_trit_power_zero_exponent" { - // Verify: x^0 = +1 for any x 47 0 + // Verify: x^0 = +1 for any x ≠ 0 try std.testing.expectEqual(.pos, trit_power(.neg, 0)); try std.testing.expectEqual(.pos, trit_power(.pos, 0)); } @@ -878,22 +878,22 @@ test "test_trit_power_cube" { } test "test_trit_from_bool_true" { - // Verify: true 48 +1 + // Verify: true → +1 try std.testing.expectEqual(.pos, trit_from_bool(true)); } test "test_trit_from_bool_false" { - // Verify: false 49 0 + // Verify: false → 0 try std.testing.expectEqual(.zero, trit_from_bool(false)); } test "test_trit_to_bool_positive" { - // Verify: +1 50 true + // Verify: +1 → true try std.testing.expect(trit_to_bool(.pos)); } test "test_trit_to_bool_non_positive" { - // Verify: 0 and -1 51 false + // Verify: 0 and -1 → false try std.testing.expect(!trit_to_bool(.zero)); try std.testing.expect(!trit_to_bool(.neg)); } @@ -913,7 +913,7 @@ test "test_trit_abs_diff_equal" { } test "test_trit_abs_diff_different" { - // Verify: |a - b| = 1 for a 52 b + // Verify: |a - b| = 1 for a ≠ b try std.testing.expectEqual(.pos, trit_abs_diff(.neg, .zero)); try std.testing.expectEqual(.pos, trit_abs_diff(.neg, .pos)); try std.testing.expectEqual(.pos, trit_abs_diff(.zero, .pos)); diff --git a/specs/base/seed.t27 b/specs/base/seed.t27 index 08c4b1d04c..251de37041 100644 --- a/specs/base/seed.t27 +++ b/specs/base/seed.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -; seed.t27 0 Minimal Golden Seed for E2E CI (#150) -; 12 + 1/34 = 3 | TRINITY +; seed.t27 — Minimal Golden Seed for E2E CI (#150) +; φ² + 1/φ² = 3 | TRINITY module seed; diff --git a/specs/base/ternary_add.t27 b/specs/base/ternary_add.t27 index 3663461e64..10539f20af 100644 --- a/specs/base/ternary_add.t27 +++ b/specs/base/ternary_add.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -// ternary_add.t27 0 Balanced Ternary Addition Formal Spec -// Ring 043 1 Formal carry propagation invariants, closure, range formula +// ternary_add.t27 — Balanced Ternary Addition Formal Spec +// Ring 043 — Formal carry propagation invariants, closure, range formula // phi^2 + 1/phi^2 = 3 | TRINITY module ternary_add; @@ -141,7 +141,7 @@ pub fn normalize_trit(raw: i8) Trit { } // ============================================================================ -// 5. TDD 2 Tests +// 5. TDD — Tests // ============================================================================ test ternary_add_full_adder_pos_pos_zero @@ -323,7 +323,7 @@ test ternary_add_full_adder_associative_no_carry then r2.sum == r4.sum // ============================================================================ -// 6. TDD 3 Invariants +// 6. TDD — Invariants // ============================================================================ invariant ternary_add_trit_mul_closure @@ -384,7 +384,7 @@ invariant ternary_add_full_adder_commutative assert trit_full_adder(a, b, c).sum == trit_full_adder(b, a, c).sum for all Trit a, b, c // ============================================================================ -// 7. TDD 4 Benchmarks +// 7. TDD — Benchmarks // ============================================================================ bench ternary_add_full_adder_latency diff --git a/specs/base/ternary_encoding.t27 b/specs/base/ternary_encoding.t27 index a04f8d2c2f..8e9c72ebdc 100644 --- a/specs/base/ternary_encoding.t27 +++ b/specs/base/ternary_encoding.t27 @@ -3,14 +3,14 @@ // Ternary Encoding/Decoding Specification // Ring 065 - Encoding schemes for ternary data representation // Defines how binary data maps to ternary and vice versa -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryEncoding { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Encoding Constants - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Trit values const TRIT_NEG : i32 = -1; @@ -27,24 +27,24 @@ module TernaryEncoding { const TRITS_PER_BYTE : usize = 6; // 6 trits = 3^6 = 729 > 256 const TRITS_PER_NYBBLE : usize = 3; // 3 trits = 27 > 16 - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Bit to Trit Conversion - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ - // bit_to_trit_pair(bit: u8) 256 [2]i32 + // bit_to_trit_pair(bit: u8) → [2]i32 // Convert a single bit (0 or 1) to a pair of trits // 0 -> [0, 0], 1 -> [1, 0] - fn bit_to_trit_pair(bit: u8) 257 [2]i32 { + fn bit_to_trit_pair(bit: u8) → [2]i32 { if (bit == 0) { return [_]i32{TRIT_ZERO, TRIT_ZERO}; } return [_]i32{TRIT_POS, TRIT_ZERO}; } - // bits_to_trits(bits: u8) 258 [3]i32 + // bits_to_trits(bits: u8) → [3]i32 // Convert a nibble (4 bits) to 3 trits // Maps 0-15 to balanced ternary - fn bits_to_trits(bits: u8) 259 [3]i32 { + fn bits_to_trits(bits: u8) → [3]i32 { var result : [3]i32 = [_]i32{TRIT_ZERO, TRIT_ZERO, TRIT_ZERO}; var value = bits; var i : usize = 0; @@ -64,14 +64,14 @@ module TernaryEncoding { return result; } - // 260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 + // ═════════════════════════════════════════════════════ // 3. Trit to Bit Conversion - // 313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 + // ═════════════════════════════════════════════════════════════════════════ - // trits_to_bits(trits: [3]i32) 386 u8 + // trits_to_bits(trits: [3]i32) → u8 // Convert 3 trits to a nibble (4 bits) // Assumes trits represent a valid value 0-15 - fn trits_to_bits(trits: [3]i32) 387 u8 { + fn trits_to_bits(trits: [3]i32) → u8 { var result : i32 = 0; var power : i32 = 1; var i : usize = 0; @@ -90,14 +90,14 @@ module TernaryEncoding { return @as(u8, @intCast(result)); } - // 388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 + // ═════════════════════════════════════════════════════ // 4. Byte to Trit Array Conversion - // 441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 + // ═════════════════════════════════════════════════════════════════════════ - // byte_to_trits(byte: u8, trits: []i32, len: usize) 514 usize + // byte_to_trits(byte: u8, trits: []i32, len: usize) → usize // Convert a byte to trits // Returns number of trits used - fn byte_to_trits(byte: u8, trits: []i32, len: usize) 515 usize { + fn byte_to_trits(byte: u8, trits: []i32, len: usize) → usize { // Convert byte (0-255) to balanced ternary var value : i32 = @as(i32, @intCast(byte)); var i : usize = 0; @@ -128,10 +128,10 @@ module TernaryEncoding { return len; } - // trits_to_byte(trits: []i32, len: usize) 516 u8 + // trits_to_byte(trits: []i32, len: usize) → u8 // Convert trits to a byte // Assumes trits represent a valid value 0-255 - fn trits_to_byte(trits: []i32, len: usize) 517 u8 { + fn trits_to_byte(trits: []i32, len: usize) → u8 { var result : i32 = 0; var power : i32 = 1; var i : usize = 0; @@ -150,59 +150,59 @@ module TernaryEncoding { return @as(u8, @intCast(result)); } - // 518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570 + // ═════════════════════════════════════════════════════ // 5. Balanced to Unipolar Conversion - // 571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643 + // ═════════════════════════════════════════════════════════════════════════ - // balanced_to_unipolar(trit: i32) 644 i32 + // balanced_to_unipolar(trit: i32) → i32 // Convert balanced ternary trit to unipolar // -1 -> 0, 0 -> 1, 1 -> 2 - fn balanced_to_unipolar(trit: i32) 645 i32 { + fn balanced_to_unipolar(trit: i32) → i32 { return trit + 1; } - // unipolar_to_balanced(trit: i32) 646 i32 + // unipolar_to_balanced(trit: i32) → i32 // Convert unipolar trit to balanced ternary // 0 -> -1, 1 -> 0, 2 -> 1 - fn unipolar_to_balanced(trit: i32) 647 i32 { + fn unipolar_to_balanced(trit: i32) → i32 { return trit - 1; } - // 648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 + // ═════════════════════════════════════════════════════ // 6. String Encoding - // 701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 + // ═════════════════════════════════════════════════════════════════════════ - // char_to_trits(c: u8, trits: []i32, len: usize) 774 usize + // char_to_trits(c: u8, trits: []i32, len: usize) → usize // Convert ASCII character to trits - fn char_to_trits(c: u8, trits: []i32, len: usize) 775 usize { + fn char_to_trits(c: u8, trits: []i32, len: usize) → usize { return byte_to_trits(c, trits, len); } - // trits_to_char(trits: []i32, len: usize) 776 u8 + // trits_to_char(trits: []i32, len: usize) → u8 // Convert trits to ASCII character - fn trits_to_char(trits: []i32, len: usize) 777 u8 { + fn trits_to_char(trits: []i32, len: usize) → u8 { return trits_to_byte(trits, len); } - // 778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830 + // ═════════════════════════════════════════════════════ // 7. Validation - // 831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903 + // ═════════════════════════════════════════════════════════════════════════ - // is_valid_trit(t: i32) 904 bool + // is_valid_trit(t: i32) → bool // Check if a value is a valid trit - fn is_valid_trit(t: i32) 905 bool { + fn is_valid_trit(t: i32) → bool { return t >= TRIT_NEG and t <= TRIT_POS; } - // is_valid_unipolar_trit(t: i32) 906 bool + // is_valid_unipolar_trit(t: i32) → bool // Check if a value is a valid unipolar trit (0, 1, 2) - fn is_valid_unipolar_trit(t: i32) 907 bool { + fn is_valid_unipolar_trit(t: i32) → bool { return t >= 0 and t <= 2; } - // validate_trits(trits: []i32, len: usize) 908 bool + // validate_trits(trits: []i32, len: usize) → bool // Validate all trits in an array - fn validate_trits(trits: []i32, len: usize) 909 bool { + fn validate_trits(trits: []i32, len: usize) → bool { var i : usize = 0; while (i < len) { if (!is_valid_trit(trits[i])) { @@ -213,9 +213,9 @@ module TernaryEncoding { return true; } - // 910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 + // ═════════════════════════════════════════════════════ // 8. Encoding Metadata - // 963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035 + // ═════════════════════════════════════════════════════════════════════════ struct EncodingInfo { encoding_type : u8, @@ -224,9 +224,9 @@ module TernaryEncoding { is_valid : bool, } - // get_encoding_info(trits: []i32, len: usize) 1036 EncodingInfo + // get_encoding_info(trits: []i32, len: usize) → EncodingInfo // Get information about a trit encoding - fn get_encoding_info(trits: []i32, len: usize) 1037 EncodingInfo { + fn get_encoding_info(trits: []i32, len: usize) → EncodingInfo { var info : EncodingInfo = undefined; info.encoding_type = ENCODING_BALANCED; info.trits_used = len; @@ -241,9 +241,9 @@ module TernaryEncoding { return info; } - // 10381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090 + // ═════════════════════════════════════════════════════ // 9. TDD - Tests - // 1091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163 + // ═════════════════════════════════════════════════════════════════════════ test bit_to_trit_pair_zero const result = bit_to_trit_pair(0); @@ -319,9 +319,9 @@ module TernaryEncoding { i = i + 1; } - // 11641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216 + // ═════════════════════════════════════════════════════ // 10. TDD - Invariants - // 1217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289 + // ═════════════════════════════════════════════════════════════════════════ invariant balanced_unipolar_roundtrip // Converting balanced -> unipolar -> balanced should be identity @@ -374,9 +374,9 @@ module TernaryEncoding { const info = get_encoding_info(&trits, 5); assert info.trits_used == 5 - // 12901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342 + // ═════════════════════════════════════════════════════ // 11. TDD - Benchmarks - // 1343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415 + // ═════════════════════════════════════════════════════════════════════════ bench byte_to_trits_performance // Measure: cycles to convert 100 bytes to trits diff --git a/specs/base/ternary_memory.t27 b/specs/base/ternary_memory.t27 index 23a42fcfd9..148c708b0f 100644 --- a/specs/base/ternary_memory.t27 +++ b/specs/base/ternary_memory.t27 @@ -3,14 +3,14 @@ // Ternary Memory Specification // Ring 066 - Ternary memory cell and array operations // Defines how trits are stored and accessed in memory -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryMemory { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Memory Constants - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Trit values const TRIT_NEG : i32 = -1; @@ -28,9 +28,9 @@ module TernaryMemory { const STATE_LOCKED : u8 = 2; const STATE_DIRTY : u8 = 3; - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Trit Memory Cell - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ // TritCell: Single trit storage with metadata struct TritCell { @@ -40,9 +40,9 @@ module TernaryMemory { access_count : u32, } - // trit_cell_init() 256 TritCell + // trit_cell_init() → TritCell // Initialize a trit cell - fn trit_cell_init() 257 TritCell { + fn trit_cell_init() → TritCell { return TritCell{ .value = TRIT_ZERO, .state = STATE_FREE, @@ -51,9 +51,9 @@ module TernaryMemory { }; } - // trit_cell_write(cell: *TritCell, value: i32) 258 bool + // trit_cell_write(cell: *TritCell, value: i32) → bool // Write a value to a trit cell - fn trit_cell_write(cell: *TritCell, value: i32) 259 bool { + fn trit_cell_write(cell: *TritCell, value: i32) → bool { if (cell.state == STATE_LOCKED) { return false; } @@ -64,17 +64,17 @@ module TernaryMemory { return true; } - // trit_cell_read(cell: *TritCell) 260 i32 + // trit_cell_read(cell: *TritCell) → i32 // Read a value from a trit cell - fn trit_cell_read(cell: *TritCell) 261 i32 { + fn trit_cell_read(cell: *TritCell) → i32 { cell.last_access = get_timestamp(); cell.access_count = cell.access_count + 1; return cell.value; } - // 262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 + // ═════════════════════════════════════════════════════ // 3. Ternary Word - // 315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 + // ═════════════════════════════════════════════════════════════════════════ // TernaryWord: 27 trits struct TernaryWord { @@ -83,9 +83,9 @@ module TernaryMemory { checksum : u32, } - // ternary_word_init() 388 TernaryWord + // ternary_word_init() → TernaryWord // Initialize a ternary word - fn ternary_word_init() 389 TernaryWord { + fn ternary_word_init() → TernaryWord { var word : TernaryWord = undefined; word.state = STATE_FREE; word.checksum = 0; @@ -99,9 +99,9 @@ module TernaryMemory { return word; } - // ternary_word_write_trit(word: *TernaryWord, index: usize, value: i32) 390 bool + // ternary_word_write_trit(word: *TernaryWord, index: usize, value: i32) → bool // Write a single trit in a word - fn ternary_word_write_trit(word: *TernaryWord, index: usize, value: i32) 391 bool { + fn ternary_word_write_trit(word: *TernaryWord, index: usize, value: i32) → bool { if (index >= TRIT_CAPACITY) { return false; } @@ -117,18 +117,18 @@ module TernaryMemory { return result; } - // ternary_word_read_trit(word: *TernaryWord, index: usize) 392 i32 + // ternary_word_read_trit(word: *TernaryWord, index: usize) → i32 // Read a single trit from a word - fn ternary_word_read_trit(word: *TernaryWord, index: usize) 393 i32 { + fn ternary_word_read_trit(word: *TernaryWord, index: usize) → i32 { if (index >= TRIT_CAPACITY) { return TRIT_ZERO; } return trit_cell_read(&word.trits[index]); } - // compute_checksum(word: *TernaryWord) 394 u32 + // compute_checksum(word: *TernaryWord) → u32 // Compute checksum for a word - fn compute_checksum(word: *TernaryWord) 395 u32 { + fn compute_checksum(word: *TernaryWord) → u32 { var checksum : u32 = 0; var i : usize = 0; @@ -141,9 +141,9 @@ module TernaryMemory { return checksum; } - // 396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 + // ═════════════════════════════════════════════════════ // 4. Ternary Memory Bank - // 449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 + // ═════════════════════════════════════════════════════════════════════════ // TernaryMemoryBank: Array of ternary words struct TernaryMemoryBank { @@ -152,9 +152,9 @@ module TernaryMemory { total_accesses : u64, } - // ternary_memory_bank_init() 522 TernaryMemoryBank + // ternary_memory_bank_init() → TernaryMemoryBank // Initialize a memory bank - fn ternary_memory_bank_init() 523 TernaryMemoryBank { + fn ternary_memory_bank_init() → TernaryMemoryBank { var bank : TernaryMemoryBank = undefined; bank.allocated = 0; bank.total_accesses = 0; @@ -168,10 +168,10 @@ module TernaryMemory { return bank; } - // ternary_memory_alloc(bank: *TernaryMemoryBank) 524 usize + // ternary_memory_alloc(bank: *TernaryMemoryBank) → usize // Allocate a word in memory bank // Returns word index or -1 if full - fn ternary_memory_alloc(bank: *TernaryMemoryBank) 525 usize { + fn ternary_memory_alloc(bank: *TernaryMemoryBank) → usize { if (bank.allocated >= WORD_CAPACITY) { return 0xFFFFFFFFFFFFFFFF; // -1 in usize } @@ -182,9 +182,9 @@ module TernaryMemory { return index; } - // ternary_memory_free(bank: *TernaryMemoryBank, index: usize) 526 bool + // ternary_memory_free(bank: *TernaryMemoryBank, index: usize) → bool // Free a word in memory bank - fn ternary_memory_free(bank: *TernaryMemoryBank, index: usize) 527 bool { + fn ternary_memory_free(bank: *TernaryMemoryBank, index: usize) → bool { if (index >= bank.allocated) { return false; } @@ -192,9 +192,9 @@ module TernaryMemory { return true; } - // ternary_memory_read(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize) 528 i32 + // ternary_memory_read(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize) → i32 // Read a trit from memory bank - fn ternary_memory_read(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize) 529 i32 { + fn ternary_memory_read(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize) → i32 { bank.total_accesses = bank.total_accesses + 1; if (word_index >= bank.allocated) { @@ -204,9 +204,9 @@ module TernaryMemory { return ternary_word_read_trit(&bank.words[word_index], trit_index); } - // ternary_memory_write(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize, value: i32) 530 bool + // ternary_memory_write(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize, value: i32) → bool // Write a trit to memory bank - fn ternary_memory_write(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize, value: i32) 531 bool { + fn ternary_memory_write(bank: *TernaryMemoryBank, word_index: usize, trit_index: usize, value: i32) → bool { bank.total_accesses = bank.total_accesses + 1; if (word_index >= bank.allocated) { @@ -216,25 +216,25 @@ module TernaryMemory { return ternary_word_write_trit(&bank.words[word_index], trit_index, value); } - // 532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 + // ═════════════════════════════════════════════════════ // 5. Helper Functions - // 585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657 + // ═════════════════════════════════════════════════════════════════════════ - // get_timestamp() 658 u64 + // get_timestamp() → u64 // Get current timestamp (placeholder) - fn get_timestamp() 659 u64 { + fn get_timestamp() → u64 { return 0; } - // validate_trit(value: i32) 660 bool + // validate_trit(value: i32) → bool // Validate trit value - fn validate_trit(value: i32) 661 bool { + fn validate_trit(value: i32) → bool { return value >= TRIT_NEG and value <= TRIT_POS; } - // 662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 + // ═════════════════════════════════════════════════════ // 6. TDD - Tests - // 715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787 + // ═════════════════════════════════════════════════════════════════════════ test trit_cell_initialization const cell = trit_cell_init(); @@ -299,9 +299,9 @@ module TernaryMemory { assert ternary_memory_write(&bank, index, 0, TRIT_POS) == true assert ternary_memory_read(&bank, index, 0) == TRIT_POS - // 788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840 + // ═════════════════════════════════════════════════════ // 7. TDD - Invariants - // 841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913 + // ═════════════════════════════════════════════════════════════════════════ invariant trit_cell_read_increments_count // Reading a cell should increment access count @@ -358,9 +358,9 @@ module TernaryMemory { _ = ternary_word_write_trit(&word, 0, TRIT_POS); assert word.state == STATE_DIRTY - // 914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966 + // ═════════════════════════════════════════════════════ // 8. TDD - Benchmarks - // 9679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039 + // ═════════════════════════════════════════════════════════════════════════ bench trit_cell_write_performance // Measure: cycles to write 1000 trit cells diff --git a/specs/base/types.t27 b/specs/base/types.t27 index 1d6b836457..e04f358fe1 100644 --- a/specs/base/types.t27 +++ b/specs/base/types.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -; types.t27 0 Base Types for t27 Language +; types.t27 — Base Types for t27 Language ; Trit, PackedTrit, TernaryWord definitions -; 12 + 1/34 = 3 | TRINITY +; φ² + 1/φ² = 3 | TRINITY module tritype-base; @@ -25,14 +25,14 @@ pub const Trit = enum(i8) { // ============================================================================ // PackedTrit: 8 trits packed into u8 -// Layout: [t7 t6 t5 t4 t3 t2 t1 t0] where each t 5 {-1, 0, +1} -// Encoding: -1 6 10, 0 7 00, +1 8 01 (2 bits per trit) +// Layout: [t7 t6 t5 t4 t3 t2 t1 t0] where each t ∈ {-1, 0, +1} +// Encoding: -1 → 10, 0 → 00, +1 → 01 (2 bits per trit) // So packed byte: [t7_1 t7_0][t6_1 t6_0]...[t0_1 t0_0] pub const PACKED_BITS_PER_TRIT : u8 = 2; pub const TRITS_PER_BYTE : u8 = 8; // Trit value mapping (2-bit to trit) -// -1 9 10b = 2, 0 10 00b = 0, +1 11 01b = 1 +// -1 → 10b = 2, 0 → 00b = 0, +1 → 01b = 1 pub const PACKED_NEG : u8 = 2; pub const PACKED_ZERO : u8 = 0; pub const PACKED_ONE : u8 = 1; @@ -45,7 +45,7 @@ pub const PackedTrit = u8; // Type alias // ============================================================================ // TernaryWord: 27 trits packed (full Coptic word) -// Can represent any value in 3^27 12 7.61310^12 states +// Can represent any value in 3^27 ≈ 7.6×10^12 states // Practical use: vector operations, VSA bindings, weight storage pub const TRITS_PER_WORD : u8 = 27; pub const WORD_BYTES : u8 = 5; // ceil(27/8) = 5 bytes for 27 trits @@ -66,7 +66,7 @@ pub struct UnpackResult { // Functions // ============================================================================ -// trit_add(a: Trit, b: Trit) 14 Trit +// trit_add(a: Trit, b: Trit) → Trit // Balanced ternary addition // Truth table: // -1 + -1 = -1 (carrying overflow handled by TernaryWord) @@ -94,18 +94,18 @@ pub fn trit_add(a: Trit, b: Trit) Trit { }; } -// trit_multiply(a: Trit, b: Trit) 15 Trit +// trit_multiply(a: Trit, b: Trit) → Trit // Balanced ternary multiplication // Truth table: -// -1 16 -1 = +1 -// -1 17 0 = 0 -// -1 18 +1 = -1 -// 0 19 -1 = 0 -// 0 20 0 = 0 -// 0 21 +1 = 0 -// +1 22 -1 = -1 -// +1 23 0 = 0 -// +1 24 +1 = +1 +// -1 × -1 = +1 +// -1 × 0 = 0 +// -1 × +1 = -1 +// 0 × -1 = 0 +// 0 × 0 = 0 +// 0 × +1 = 0 +// +1 × -1 = -1 +// +1 × 0 = 0 +// +1 × +1 = +1 pub fn trit_multiply(a: Trit, b: Trit) Trit { return switch (a) { .neg => switch (b) { @@ -118,8 +118,8 @@ pub fn trit_multiply(a: Trit, b: Trit) Trit { }; } -// trit_negate(a: Trit) 25 Trit -// Negate a trit: -1 26 +1, 0 27 0, +1 28 -1 +// trit_negate(a: Trit) → Trit +// Negate a trit: -1 → +1, 0 → 0, +1 → -1 // Truth table: // trit_negate(-1) = +1 // trit_negate(0) = 0 @@ -132,7 +132,7 @@ pub fn trit_negate(a: Trit) Trit { }; } -// trit_to_packed(trit: Trit) 29 u8 +// trit_to_packed(trit: Trit) → u8 // Convert Trit to its 2-bit packed representation pub fn trit_to_packed(trit: Trit) u8 { return switch (trit) { @@ -142,7 +142,7 @@ pub fn trit_to_packed(trit: Trit) u8 { }; } -// packed_to_trit(packed: u8) 30 Trit +// packed_to_trit(packed: u8) → Trit // Convert 2-bit packed representation to Trit pub fn packed_to_trit(packed: u8) Trit { return switch (packed & TRIT_MASK) { @@ -153,7 +153,7 @@ pub fn packed_to_trit(packed: u8) Trit { }; } -// pack_trit(trit: Trit, position: u8, packed: PackedTrit) 31 PackedTrit +// pack_trit(trit: Trit, position: u8, packed: PackedTrit) → PackedTrit // Pack a single trit into PackedTrit at given position (0-7) // Returns updated packed value or error sentinel (0xFF) for invalid position pub fn pack_trit(trit: Trit, position: u8, packed: PackedTrit) PackedTrit { @@ -174,7 +174,7 @@ pub fn pack_trit(trit: Trit, position: u8, packed: PackedTrit) PackedTrit { return result; } -// unpack_trit(position: u8, packed: PackedTrit) 32 UnpackResult +// unpack_trit(position: u8, packed: PackedTrit) → UnpackResult // Extract a single trit from PackedTrit at given position (0-7) pub fn unpack_trit(position: u8, packed: PackedTrit) UnpackResult { if (position >= TRITS_PER_BYTE) { @@ -188,7 +188,7 @@ pub fn unpack_trit(position: u8, packed: PackedTrit) UnpackResult { return UnpackResult{ .value = value, .valid = true }; } -// ternary_word_pack(src: []Trit, count: u8) 33 TernaryWord +// ternary_word_pack(src: []Trit, count: u8) → TernaryWord // Pack count trits into TernaryWord (max 27 trits) // Returns error sentinel ([0xFF]*5) for count > 27 pub fn ternary_word_pack(src: []Trit, count: u8) TernaryWord { @@ -228,7 +228,7 @@ pub fn ternary_word_unpack(word: TernaryWord, count: u8) []Trit { return result[0..valid_count]; } -// trit_compare(a: Trit, b: Trit) 34 i8 +// trit_compare(a: Trit, b: Trit) → i8 // Compare two trits: -1 if a < b, 0 if a == b, +1 if a > b pub fn trit_compare(a: Trit, b: Trit) i8 { if (a == b) { @@ -240,25 +240,25 @@ pub fn trit_compare(a: Trit, b: Trit) i8 { } } -// trit_min(a: Trit, b: Trit) 35 Trit +// trit_min(a: Trit, b: Trit) → Trit // Returns the minimum of two trits pub fn trit_min(a: Trit, b: Trit) Trit { return if (a == .neg or (a == .zero and b == .pos)) a else b; } -// trit_max(a: Trit, b: Trit) 36 Trit +// trit_max(a: Trit, b: Trit) → Trit // Returns the maximum of two trits pub fn trit_max(a: Trit, b: Trit) Trit { return if (a == .pos or (a == .zero and b == .neg)) a else b; } -// trit_abs(a: Trit) 37 Trit +// trit_abs(a: Trit) → Trit // Absolute value of a trit (always 0 or +1) pub fn trit_abs(a: Trit) Trit { return if (a == .neg) .pos else a; } -// trit_from_i8(value: i8) 38 Trit +// trit_from_i8(value: i8) → Trit // Safe conversion from i8 to Trit, clamping to valid range [-1, 0, +1] // Returns .zero for values outside valid range pub fn trit_from_i8(value: i8) Trit { @@ -270,7 +270,7 @@ pub fn trit_from_i8(value: i8) Trit { }; } -// trit_and(a: Trit, b: Trit) 39 Trit +// trit_and(a: Trit, b: Trit) → Trit // Logical AND for trits (treating .pos as true, others as false) // Truth table: // .neg & .neg = .neg @@ -287,7 +287,7 @@ pub fn trit_and(a: Trit, b: Trit) Trit { }; } -// trit_or(a: Trit, b: Trit) 40 Trit +// trit_or(a: Trit, b: Trit) → Trit // Logical OR for trits (treating .pos as true, others as false) // Truth table: // .neg | .neg = .neg @@ -304,7 +304,7 @@ pub fn trit_or(a: Trit, b: Trit) Trit { }; } -// trit_xor(a: Trit, b: Trit) 41 Trit +// trit_xor(a: Trit, b: Trit) → Trit // Logical XOR for trits (treating .pos as true, others as false) // Truth table: // .neg ^ .neg = .neg @@ -317,7 +317,7 @@ pub fn trit_xor(a: Trit, b: Trit) Trit { return if (a == b) if (a == .neg) .neg else .zero else .pos; } -// trit_not(a: Trit) 42 Trit +// trit_not(a: Trit) → Trit // Logical NOT for trits (treating .pos as true, others as false) // Truth table: // !.neg = .pos @@ -327,14 +327,14 @@ pub fn trit_not(a: Trit) Trit { return if (a == .pos) .zero else .pos; } -// trit_select(condition: Trit, a: Trit, b: Trit) 43 Trit +// trit_select(condition: Trit, a: Trit, b: Trit) → Trit // Ternary selection: return a if condition is .pos, else b // Uses .pos as "true", all other values select b pub fn trit_select(condition: Trit, a: Trit, b: Trit) Trit { return if (condition == .pos) a else b; } -// packed_trit_count(packed: PackedTrit, value: Trit) 44 u8 +// packed_trit_count(packed: PackedTrit, value: Trit) → u8 // Count occurrences of a specific trit value in PackedTrit pub fn packed_trit_count(packed: PackedTrit, value: Trit) u8 { var count: u8 = 0; @@ -347,26 +347,26 @@ pub fn packed_trit_count(packed: PackedTrit, value: Trit) u8 { return count; } -// packed_trit_all_equal(packed: PackedTrit, value: Trit) 45 bool +// packed_trit_all_equal(packed: PackedTrit, value: Trit) → bool // Check if all trits in PackedTrit equal a specific value pub fn packed_trit_all_equal(packed: PackedTrit, value: Trit) bool { return packed_trit_count(packed, value) == TRITS_PER_BYTE; } -// packed_trit_is_zero(packed: PackedTrit) 46 bool +// packed_trit_is_zero(packed: PackedTrit) → bool // Check if all trits in PackedTrit are zero pub fn packed_trit_is_zero(packed: PackedTrit) bool { return packed_trit_all_equal(packed, .zero); } -// packed_trit_is_all_same(packed: PackedTrit) 47 bool +// packed_trit_is_all_same(packed: PackedTrit) → bool // Check if all trits in PackedTrit are the same (any value) pub fn packed_trit_is_all_same(packed: PackedTrit) bool { const first = unpack_trit(0, packed).value; return packed_trit_all_equal(packed, first); } -// packed_trit_nand(a: PackedTrit, b: PackedTrit) 48 PackedTrit +// packed_trit_nand(a: PackedTrit, b: PackedTrit) → PackedTrit // Element-wise NAND operation on two PackedTrit values pub fn packed_trit_nand(a: PackedTrit, b: PackedTrit) PackedTrit { var result: PackedTrit = 0; @@ -380,7 +380,7 @@ pub fn packed_trit_nand(a: PackedTrit, b: PackedTrit) PackedTrit { return result; } -// packed_trit_nor(a: PackedTrit, b: PackedTrit) 49 PackedTrit +// packed_trit_nor(a: PackedTrit, b: PackedTrit) → PackedTrit // Element-wise NOR operation on two PackedTrit values pub fn packed_trit_nor(a: PackedTrit, b: PackedTrit) PackedTrit { var result: PackedTrit = 0; @@ -394,7 +394,7 @@ pub fn packed_trit_nor(a: PackedTrit, b: PackedTrit) PackedTrit { return result; } -// packed_trit_xnor(a: PackedTrit, b: PackedTrit) 50 PackedTrit +// packed_trit_xnor(a: PackedTrit, b: PackedTrit) → PackedTrit // Element-wise XNOR operation on two PackedTrit values // Returns pos when trits are equal, neg when different pub fn packed_trit_xnor(a: PackedTrit, b: PackedTrit) PackedTrit { @@ -409,7 +409,7 @@ pub fn packed_trit_xnor(a: PackedTrit, b: PackedTrit) PackedTrit { return result; } -// packed_trit_shift_left(packed: PackedTrit, shift: u8) 51 PackedTrit +// packed_trit_shift_left(packed: PackedTrit, shift: u8) → PackedTrit // Left shift packed trits by shift positions (fills with zeros) // shift must be in [0, 8] pub fn packed_trit_shift_left(packed: PackedTrit, shift: u8) PackedTrit { @@ -432,7 +432,7 @@ pub fn packed_trit_shift_left(packed: PackedTrit, shift: u8) PackedTrit { return result; } -// packed_trit_shift_right(packed: PackedTrit, shift: u8) 52 PackedTrit +// packed_trit_shift_right(packed: PackedTrit, shift: u8) → PackedTrit // Right shift packed trits by shift positions (fills with zeros) // shift must be in [0, 8] pub fn packed_trit_shift_right(packed: PackedTrit, shift: u8) PackedTrit { @@ -455,7 +455,7 @@ pub fn packed_trit_shift_right(packed: PackedTrit, shift: u8) PackedTrit { return result; } -// packed_trit_rotate_left(packed: PackedTrit, rotate: u8) 53 PackedTrit +// packed_trit_rotate_left(packed: PackedTrit, rotate: u8) → PackedTrit // Left rotate packed trits by rotate positions (circular shift) // rotate must be in [0, 7] pub fn packed_trit_rotate_left(packed: PackedTrit, rotate: u8) PackedTrit { @@ -475,7 +475,7 @@ pub fn packed_trit_rotate_left(packed: PackedTrit, rotate: u8) PackedTrit { return result; } -// packed_trit_rotate_right(packed: PackedTrit, rotate: u8) 54 PackedTrit +// packed_trit_rotate_right(packed: PackedTrit, rotate: u8) → PackedTrit // Right rotate packed trits by rotate positions (circular shift) // rotate must be in [0, 7] pub fn packed_trit_rotate_right(packed: PackedTrit, rotate: u8) PackedTrit { @@ -495,7 +495,7 @@ pub fn packed_trit_rotate_right(packed: PackedTrit, rotate: u8) PackedTrit { return result; } -// ternary_word_is_zero(word: TernaryWord) 55 bool +// ternary_word_is_zero(word: TernaryWord) → bool // Check if all 27 trits in TernaryWord are zero pub fn ternary_word_is_zero(word: TernaryWord) bool { for (0..TRITS_PER_WORD) |i| { @@ -509,7 +509,7 @@ pub fn ternary_word_is_zero(word: TernaryWord) bool { return true; } -// ternary_word_count(word: TernaryWord, value: Trit) 56 u8 +// ternary_word_count(word: TernaryWord, value: Trit) → u8 // Count occurrences of a specific trit value in TernaryWord pub fn ternary_word_count(word: TernaryWord, value: Trit) u8 { var count: u8 = 0; @@ -524,7 +524,7 @@ pub fn ternary_word_count(word: TernaryWord, value: Trit) u8 { return count; } -// ternary_word_eq(a: TernaryWord, b: TernaryWord) 57 bool +// ternary_word_eq(a: TernaryWord, b: TernaryWord) → bool // Compare two TernaryWords for equality pub fn ternary_word_eq(a: TernaryWord, b: TernaryWord) bool { for (0..WORD_BYTES) |i| { @@ -535,7 +535,7 @@ pub fn ternary_word_eq(a: TernaryWord, b: TernaryWord) bool { return true; } -// ternary_word_negate(word: TernaryWord) 58 TernaryWord +// ternary_word_negate(word: TernaryWord) → TernaryWord // Negate all trits in TernaryWord pub fn ternary_word_negate(word: TernaryWord) TernaryWord { var result: TernaryWord = undefined; @@ -549,7 +549,7 @@ pub fn ternary_word_negate(word: TernaryWord) TernaryWord { return result; } -// ternary_word_is_all_same(word: TernaryWord) 59 bool +// ternary_word_is_all_same(word: TernaryWord) → bool // Check if all 27 trits in TernaryWord are the same value pub fn ternary_word_is_all_same(word: TernaryWord) bool { const first = unpack_trit(0, word[0]).value; diff --git a/specs/benchmarks/bench_main.t27 b/specs/benchmarks/bench_main.t27 index 0e7a505ff7..29d7ae80cc 100644 --- a/specs/benchmarks/bench_main.t27 +++ b/specs/benchmarks/bench_main.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# NN INFERENCE BENCHMARK 0 Format Comparison +# NN INFERENCE BENCHMARK — Format Comparison ## Specification @@ -9,7 +9,7 @@ Tiny MLP: 100 -> 64 -> 10 (simplified MNIST-like). ## Mathematical Foundation ``` -12 + 1/34 = 3 = TRINITY +φ² + 1/φ² = 3 = TRINITY ``` ## Model Architecture @@ -45,12 +45,12 @@ runInferenceTernary(inputs, targets, weights, biases, config, num_samples) -> In - Mantissa: 10 bits ### GF16 (Geometric) -- Positive values: `exp2(x) * frac` where `x 5 [1, 2)` +- Positive values: `exp2(x) * frac` where `x ∈ [1, 2)` - Zero: special case `0` - Negative: sign flip of positive ### Ternary -- Direct mapping: `> 0.5 6 +1`, `< -0.5 7 -1`, `else 8 0` +- Direct mapping: `> 0.5 → +1`, `< -0.5 → -1`, `else → 0` - Accuracy drop expected due to -1,0,+1 limitation ## Forward Pass Functions diff --git a/specs/benchmarks/bench_nn.t27 b/specs/benchmarks/bench_nn.t27 index e7fe2d2955..399e7d9ada 100644 --- a/specs/benchmarks/bench_nn.t27 +++ b/specs/benchmarks/bench_nn.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# NN BENCHMARK 0 Small NN Inference +# NN BENCHMARK — Small NN Inference ## Specification @@ -9,7 +9,7 @@ Tests ternary vs FP16/BF16/GF16 on MNIST-like workload. ## Mathematical Foundation ``` -12 + 1/34 = 3 = TRINITY +φ² + 1/φ² = 3 = TRINITY ``` ## Format Conversion diff --git a/specs/benchmarks/ternary_vs_binary.t27 b/specs/benchmarks/ternary_vs_binary.t27 index 62b01f7154..fa3e96031f 100644 --- a/specs/benchmarks/ternary_vs_binary.t27 +++ b/specs/benchmarks/ternary_vs_binary.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# TERNARY VS BINARY 0 Format Comparison Benchmark +# TERNARY VS BINARY — Format Comparison Benchmark ## Specification @@ -9,7 +9,7 @@ Compares accuracy degradation when using different number formats. ## Mathematical Foundation ``` -12 + 1/34 = 3 = TRINITY +φ² + 1/φ² = 3 = TRINITY ``` ## Format Functions @@ -85,7 +85,7 @@ Experiment 4: BF16 Weights (not implemented) Results Summary: Format | Output[0] | Output[1] | Output[2] - 567891011121314151617181920212223242526 + ───────┼───────┼────── FP32 | x.xx | x.xx | x.xx Ternary | x.xx | x.xx | x.xx ``` diff --git a/specs/brain/brain.t27 b/specs/brain/brain.t27 index 1e9ea4451c..4bc5bdb5c3 100644 --- a/specs/brain/brain.t27 +++ b/specs/brain/brain.t27 @@ -1,41 +1,41 @@ // SPDX-License-Identifier: Apache-2.0 -# BRAIN 0 S1AI Neuroanatomy v5.1 +# BRAIN — S³AI Neuroanatomy v5.1 ## Specification -Neuroanatomically inspired brain module for Trinity S2AI. +Neuroanatomically inspired brain module for Trinity S³AI. Aggregator module for all brain regions. Import this file to get -access to all S3AI neuroanatomy modules at once. +access to all S³AI neuroanatomy modules at once. -Sacred Formula: 45 + 1/67 = 3 = TRINITY +Sacred Formula: φ² + 1/φ² = 3 = TRINITY ## Brain Regions | Region | Biological Function | File | |--------|-------------------|-------| -| Thalamus | Sensory Relay 8 Railway live logs relay | thalamus_logs.zig | -| Basal Ganglia | Action Selection 9 prevents duplicate task execution | basal_ganglia.zig | -| Reticular Formation | Broadcast Alerting 10 event bus for all agents | reticular_formation.zig | -| Locus Coeruleus | Arousal Regulation 11 backoff/timing policy | locus_coeruleus.zig | -| Amygdala | Emotional Salience 12 prioritizes urgent/critical events | amygdala.zig | -| Prefrontal Cortex | Executive Function 13 decision making and planning | prefrontal_cortex.zig | -| Intraparietal Sulcus | Numerical Processing 14 f16/GF16/TF3 conversions | intraparietal_sulcus.zig | -| Hippocampus | Memory Persistence 15 JSONL event logging | persistence.zig | -| Corpus Callosum | Telemetry 16 time-series metrics aggregation | telemetry.zig | -| Microglia | Immune Surveillance 17 The Constant Gardeners | microglia.zig | -| State Recovery | Crash Recovery 18 Persistent state storage with versioning | state_recovery.zig | -| Hypothalamus | Administrative Control 19 brain maintenance | admin.zig | -| Health History | Hippocampal Memory 20 brain health snapshots | health_history.zig | -| Metrics Dashboard | Command Center 21 aggregates metrics | metrics_dashboard.zig | -| Brain Alerts | Critical Health Notification 22 monitors health | alerts.zig | -| Simulation | Synthetic Workload Testing 23 realistic workload testing | simulation.zig | -| Observability Export | External Monitoring 24 Prometheus/OpenTelemetry | observability_export.zig | +| Thalamus | Sensory Relay — Railway live logs relay | thalamus_logs.zig | +| Basal Ganglia | Action Selection — prevents duplicate task execution | basal_ganglia.zig | +| Reticular Formation | Broadcast Alerting — event bus for all agents | reticular_formation.zig | +| Locus Coeruleus | Arousal Regulation — backoff/timing policy | locus_coeruleus.zig | +| Amygdala | Emotional Salience — prioritizes urgent/critical events | amygdala.zig | +| Prefrontal Cortex | Executive Function — decision making and planning | prefrontal_cortex.zig | +| Intraparietal Sulcus | Numerical Processing — f16/GF16/TF3 conversions | intraparietal_sulcus.zig | +| Hippocampus | Memory Persistence — JSONL event logging | persistence.zig | +| Corpus Callosum | Telemetry — time-series metrics aggregation | telemetry.zig | +| Microglia | Immune Surveillance — The Constant Gardeners | microglia.zig | +| State Recovery | Crash Recovery — Persistent state storage with versioning | state_recovery.zig | +| Hypothalamus | Administrative Control — brain maintenance | admin.zig | +| Health History | Hippocampal Memory — brain health snapshots | health_history.zig | +| Metrics Dashboard | Command Center — aggregates metrics | metrics_dashboard.zig | +| Brain Alerts | Critical Health Notification — monitors health | alerts.zig | +| Simulation | Synthetic Workload Testing — realistic workload testing | simulation.zig | +| Observability Export | External Monitoring — Prometheus/OpenTelemetry | observability_export.zig | | Cerebellum | Motor Learning & Adaptive Performance | learning.zig | -| Thalamic Async Processor | Non-blocking Operations 25 async task claim/release | async_processor.zig | -| Corpus Callosum (Federation) | Inter-Hemispheric Communication 26 distributed multi-instance | federation.zig | -| Visual Cortex | Spatial Representation 27 ASCII art brain maps | visualization.zig | -| Evolution Simulation | Deterministic Evolution 28 parallel brain evolution | evolution_simulation.zig | -| Performance Dashboard | Performance Monitoring 29 real-time tracking | perf_dashboard.zig | +| Thalamic Async Processor | Non-blocking Operations — async task claim/release | async_processor.zig | +| Corpus Callosum (Federation) | Inter-Hemispheric Communication — distributed multi-instance | federation.zig | +| Visual Cortex | Spatial Representation — ASCII art brain maps | visualization.zig | +| Evolution Simulation | Deterministic Evolution — parallel brain evolution | evolution_simulation.zig | +| Performance Dashboard | Performance Monitoring — real-time tracking | perf_dashboard.zig | ## Sacred Constants diff --git a/specs/brain/bus.t27 b/specs/brain/bus.t27 index addbdcf748..48e702be61 100644 --- a/specs/brain/bus.t27 +++ b/specs/brain/bus.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -; bus.t27 0 inter-region messaging contract (spec-first) +; bus.t27 — inter-region messaging contract (spec-first) ; Message shapes and routing rules expand with region specs. ; phi^2 + 1/phi^2 = 3 | TRINITY diff --git a/specs/brain/cognitive_loop.t27 b/specs/brain/cognitive_loop.t27 index 7fea64ed6d..bf521f1f71 100644 --- a/specs/brain/cognitive_loop.t27 +++ b/specs/brain/cognitive_loop.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -; cognitive_loop.t27 0 sense 1 evaluate 2 decide 3 act 4 consolidate (spec-first) +; cognitive_loop.t27 — sense → evaluate → decide → act → consolidate (spec-first) ; Phase timing contract lives in phi_timing.t27; this module holds loop identity constants. ; phi^2 + 1/phi^2 = 3 | TRINITY diff --git a/specs/brain/neural_gamma.t27 b/specs/brain/neural_gamma.t27 index e25277662b..9689041c54 100644 --- a/specs/brain/neural_gamma.t27 +++ b/specs/brain/neural_gamma.t27 @@ -1,33 +1,33 @@ // SPDX-License-Identifier: Apache-2.0 -# NEURAL GAMMA 0 Consciousness and Golden Ratio +# NEURAL GAMMA — Consciousness and Golden Ratio ## Specification This module explores how neural gamma rhythm (40 Hz) relates to -Barbero-Immirzi parameter 1 = 234 and consciousness thresholds. +Barbero-Immirzi parameter γ = φ⁻³ and consciousness thresholds. ## Mathematical Foundation Golden Ratio: - 5 = (1 + 65)/2 7 1.61803398874989482 - 8 = 91011 12 0.23606797749978969641 + φ = (1 + √5)/2 ≈ 1.61803398874989482 + γ = φ⁻³ ≈ 0.23606797749978969641 Trinity Identity: - 1314 + 151617 = 3 + φ² + φ⁻² = 3 ## Hypotheses -1. Neural gamma rhythm (40 Hz) encodes via 18 and 19 -2. Consciousness threshold C_thr = 20 21 2223 24 0.618 (252627) -3. Quantum coherence time 28_29 = 3031 32 33 34 t_Planck +1. Neural gamma rhythm (40 Hz) encodes via φ and γ +2. Consciousness threshold C_thr = γ × φ² ≈ 0.618 (φ⁻¹) +3. Quantum coherence time τ_φ = φ⁴ × γ × t_Planck 4. Gamma synchrony is fundamental to consciousness ## Constants ``` PHI = 1.61803398874989482 -GAMMA = 353637 38 0.23606797749978969641 -TRINITY = 3940 + 414243 = 3 +GAMMA = φ⁻³ ≈ 0.23606797749978969641 +TRINITY = φ² + φ⁻² = 3 PI = 3.14159265358979323846 GAMMA_FREQ = 40.0 PLANCK_TIME = 5.391247e-44 @@ -48,16 +48,16 @@ enum ConsciousnessState { ``` consciousnessThreshold() -> f64 - Returns 44 45 4647 48 0.618 = 495051 + Returns γ × φ² ≈ 0.618 = φ⁻¹ neuralGammaFrequency() -> f64 - Returns f_52 = 5354 55 56 / 57 58 40 Hz + Returns f_γ = φ³ × π / γ ≈ 40 Hz bindingWindow() -> f64 - Returns 2 59 T_60 61 50 ms + Returns 2 × T_γ ≈ 50 ms integrationTime() -> f64 - Returns 3 62 T_63 64 65 66 100-200 ms + Returns 3 × T_γ × φ ≈ 100-200 ms consciousnessEmergence(gamma_sync, integrated_info, workspace_saliency) -> ConsciousnessState Returns consciousness level based on synchrony and integration @@ -66,22 +66,22 @@ consciousnessEmergence(gamma_sync, integrated_info, workspace_saliency) -> Consc ## Tests ``` -test "Neural-67: phi cubed and gamma" { - expect(PHI_CUBED 68 4.23606797749978969641) - expect(GAMMA 69 0.23606797749978969641) - expect(PHI_CUBED - 4.0 70 GAMMA) +test "Neural-γ: phi cubed and gamma" { + expect(PHI_CUBED ≈ 4.23606797749978969641) + expect(GAMMA ≈ 0.23606797749978969641) + expect(PHI_CUBED - 4.0 ≈ GAMMA) } -test "Neural-71: TRINITY identity" { - expect(TRINITY 72 3.0) +test "Neural-γ: TRINITY identity" { + expect(TRINITY ≈ 3.0) } -test "Neural-73: consciousness threshold" { - expect(consciousnessThreshold() 74 0.618) - expect(consciousnessThresholdPhiInv() 75 0.618) +test "Neural-γ: consciousness threshold" { + expect(consciousnessThreshold() ≈ 0.618) + expect(consciousnessThresholdPhiInv() ≈ 0.618) } -test "Neural-76: gamma frequency" { +test "Neural-γ: gamma frequency" { expect(neuralGammaFrequency() > 50.0) expect(neuralGammaFrequency() < 60.0) } diff --git a/specs/brain/phi_timing.t27 b/specs/brain/phi_timing.t27 index ff9e15bf8a..308c7411f9 100644 --- a/specs/brain/phi_timing.t27 +++ b/specs/brain/phi_timing.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -; phi_timing.t27 0 phi-structured cognitive cycle timing (spec-first) +; phi_timing.t27 — phi-structured cognitive cycle timing (spec-first) ; Phase duration ratios follow INV-1; integer ms sum may differ slightly from 3*base_ms. ; phi^2 + 1/phi^2 = 3 | TRINITY diff --git a/specs/brain/unified_state.t27 b/specs/brain/unified_state.t27 index 250e44b164..80d8116c3b 100644 --- a/specs/brain/unified_state.t27 +++ b/specs/brain/unified_state.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -; unified_state.t27 0 Trinity Brain unified state (spec-first) +; unified_state.t27 — Trinity Brain unified state (spec-first) ; Normative types for Strand VI. Zig/C/Verilog are generated under gen/ via t27c. ; phi^2 + 1/phi^2 = 3 | TRINITY diff --git a/specs/compiler/parser.t27 b/specs/compiler/parser.t27 index fc2bb70e8a..c52123396b 100644 --- a/specs/compiler/parser.t27 +++ b/specs/compiler/parser.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // specs/compiler/parser.t27 -// T27 Parser Specification 0 Self-hosting compiler core -// 12 + 1/34 = 3 | TRINITY +// T27 Parser Specification — Self-hosting compiler core +// φ² + 1/φ² = 3 | TRINITY // // This module defines the complete recursive descent parser for the T27 language. // It is a 1:1 port of bootstrap/src/compiler.rs Parser to t27 spec format. @@ -10,9 +10,9 @@ module Parsing { use base::types; use compiler::lexer; - // 56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 + // ════════════════════════════════════════════════════════════════════ // 1. AST Node Types - // 737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ════════════════════════════════════════════════════════════════════ const MAX_CHILDREN: u32 = 32; @@ -69,9 +69,9 @@ module Parsing { children: [MAX_CHILDREN]Node; } - // 141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 + // ════════════════════════════════════════════════════════════════════ // 2. Parser State - // 209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 + // ════════════════════════════════════════════════════════════════════ struct Parser { lexer: lexer::Lexer; @@ -89,9 +89,9 @@ module Parsing { return p; } - // 277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 + // ════════════════════════════════════════════════════════════════════ // 3. Movement Primitives - // 345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 + // ════════════════════════════════════════════════════════════════════ fn advance(self: *Parser) -> void { self.current = self.peek; @@ -125,9 +125,9 @@ module Parsing { return self.error_msg; } - // 413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 + // ════════════════════════════════════════════════════════════════════ // 4. Error Recovery - // 481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 + // ════════════════════════════════════════════════════════════════════ fn skip_brace_body(self: *Parser) -> bool { var depth: i32 = 1; @@ -260,9 +260,9 @@ module Parsing { } } - // 549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616 + // ════════════════════════════════════════════════════════════════════ // 5. Type Annotation Parser - // 617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 + // ════════════════════════════════════════════════════════════════════ fn parse_type_annotation(self: *Parser) -> str { var ty: str = ""; @@ -324,9 +324,9 @@ module Parsing { return ty; } - // 685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752 + // ════════════════════════════════════════════════════════════════════ // 6. Expression Parser (Precedence Levels) - // 753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820 + // ════════════════════════════════════════════════════════════════════ fn node_new(kind: NodeKind) -> Node { return Node{ @@ -843,9 +843,9 @@ module Parsing { return sw; } - // 821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888 + // ════════════════════════════════════════════════════════════════════ // 7. Statement Parser - // 889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956 + // ════════════════════════════════════════════════════════════════════ fn parse_body_stmt(self: *Parser) -> Node { if (self.check(lexer::TokenKind::KwConst) or self.check(lexer::TokenKind::KwVar)) { @@ -1095,9 +1095,9 @@ module Parsing { } } - // 9579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024 + // ════════════════════════════════════════════════════════════════════ // 8. Struct and Enum Body Parsers - // 10251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092 + // ════════════════════════════════════════════════════════════════════ fn parse_struct_body(self: *Parser, decl: *Node) -> void { while (self.current.kind != lexer::TokenKind::RBrace @@ -1169,9 +1169,9 @@ module Parsing { } } - // 10931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160 + // ════════════════════════════════════════════════════════════════════ // 9. Top-Level Declaration Parsers - // 11611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228 + // ════════════════════════════════════════════════════════════════════ fn parse_top_level_decl(self: *Parser) -> Node { var is_pub = false; @@ -1450,9 +1450,9 @@ module Parsing { return decl; } - // 12291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296 + // ════════════════════════════════════════════════════════════════════ // 10. Module Parser - // 12971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364 + // ════════════════════════════════════════════════════════════════════ fn parse(self: *Parser) -> Node { var module = node_new(NodeKind::Module); @@ -1536,9 +1536,9 @@ module Parsing { } } - // 13651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432 + // ════════════════════════════════════════════════════════════════════ // 11. Tests - // 14331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500 + // ════════════════════════════════════════════════════════════════════ test "kind_values" { assert(NodeKind::Module == 0) diff --git a/specs/conformance/e2e_scenarios.t27 b/specs/conformance/e2e_scenarios.t27 index bc4e33910c..f891e5452c 100644 --- a/specs/conformance/e2e_scenarios.t27 +++ b/specs/conformance/e2e_scenarios.t27 @@ -1,23 +1,23 @@ // SPDX-License-Identifier: Apache-2.0 -# E2E TEST SCENARIOS 0 Full Pipeline Verification +# E2E TEST SCENARIOS — Full Pipeline Verification ## Specification -Tests full pipeline: VSA 1 VM 2 SDK 3 Codebook 4 Verdict. +Tests full pipeline: VSA → VM → SDK → Codebook → Verdict. Part of Phase 4: Quality & Performance (Issue #48). ## Mathematical Foundation ``` -56 + 1/78 = 3 = TRINITY +φ² + 1/φ² = 3 = TRINITY ``` ## Test Scenarios -### E2E: VSA create 9 VM execute 10 SDK verify +### E2E: VSA create → VM execute → SDK verify ``` -test "E2E: VSA create 11 VM execute 12 SDK verify" { +test "E2E: VSA create → VM execute → SDK verify" { // Stage 1: Create vectors via VSA core var a = vsa.randomVector(256, 42); var b = vsa.randomVector(256, 84); @@ -33,7 +33,7 @@ test "E2E: VSA create 11 VM execute 12 SDK verify" { }); try machine.run(); - // Stage 3: Verify via SDK 13 bind via VSA core, compare with VM result + // Stage 3: Verify via SDK — bind via VSA core, compare with VM result var bound_sdk = vsa.bind(&a, &b); var vm_result_raw = machine.registers.v2; @@ -43,10 +43,10 @@ test "E2E: VSA create 11 VM execute 12 SDK verify" { } ``` -### E2E: Codebook encode 14 bind 15 decode roundtrip +### E2E: Codebook encode → bind → decode roundtrip ``` -test "E2E: Codebook encode 16 bind 17 decode roundtrip" { +test "E2E: Codebook encode → bind → decode roundtrip" { // Stage 1: Create codebook via SDK var codebook = sdk.Codebook.init(allocator, 512); defer codebook.deinit(); @@ -69,7 +69,7 @@ test "E2E: Codebook encode 16 bind 17 decode roundtrip" { var temp = s_bound.bundle(&v_bound); var sentence = temp.bundle(&o_bound); - // Stage 5: Decode 18 query subject + // Stage 5: Decode — query subject var retrieved_subject = sentence.unbind(&subject_role); const decoded = codebook.decode(&retrieved_subject); try expect(decoded != null); @@ -78,10 +78,10 @@ test "E2E: Codebook encode 16 bind 17 decode roundtrip" { } ``` -### E2E: AssociativeMemory store 19 retrieve with VM vectors +### E2E: AssociativeMemory store → retrieve with VM vectors ``` -test "E2E: AssociativeMemory store 20 retrieve with VM vectors" { +test "E2E: AssociativeMemory store → retrieve with VM vectors" { // Stage 1: Create vectors via VM var machine = vm.VSAVM.init(allocator); defer machine.deinit(); @@ -109,10 +109,10 @@ test "E2E: AssociativeMemory store 20 retrieve with VM vectors" { } ``` -### E2E: Sequence encode 21 probe position recovery +### E2E: Sequence encode → probe position recovery ``` -test "E2E: Sequence encode 22 probe position recovery" { +test "E2E: Sequence encode → probe position recovery" { // Stage 1: Create symbol vectors var apple = sdk.Hypervector.random(512, 10); @@ -125,7 +125,7 @@ test "E2E: Sequence encode 22 probe position recovery" { }; var seq = encoder.encode(&items); - // Stage 3: Probe 23 apple should be at position 0 + // Stage 3: Probe — apple should be at position 0 const sim_apple_0 = encoder.probe(&seq, &apple, 0); const sim_apple_1 = encoder.probe(&seq, &apple, 1); const sim_apple_2 = encoder.probe(&seq, &apple, 2); @@ -136,10 +136,10 @@ test "E2E: Sequence encode 22 probe position recovery" { } ``` -### E2E: Classifier train 24 predict +### E2E: Classifier train → predict ``` -test "E2E: Classifier train 25 predict" { +test "E2E: Classifier train → predict" { var classifier = sdk.Classifier.init(allocator, 512); defer classifier.deinit(); @@ -166,10 +166,10 @@ test "E2E: Classifier train 25 predict" { } ``` -### E2E: HybridBigInt pack 26 unpack 27 VM execute +### E2E: HybridBigInt pack → unpack → VM execute ``` -test "E2E: HybridBigInt pack 28 unpack 29 VM execute" { +test "E2E: HybridBigInt pack → unpack → VM execute" { // Stage 1: Create and pack vector var v = vsa.randomVector(256, 777); v.pack(); diff --git a/specs/demos/jones_topology_decision_gate.t27 b/specs/demos/jones_topology_decision_gate.t27 index 14c75453ae..ed468fa624 100644 --- a/specs/demos/jones_topology_decision_gate.t27 +++ b/specs/demos/jones_topology_decision_gate.t27 @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/demos/jones_topology_decision_gate.t27 -// Decision Gate TH-01..TH-05 for H0: Structure Similarity Classifier -// Tests if VSA dot_product + fixed 1 constant can classify structures by complexity -// 23 + 1/45 = 3 | TRINITY +// Decision Gate TH-01..TH-05 for H₁: Structure Similarity Classifier +// Tests if VSA dot_product + fixed φ constant can classify structures by complexity +// φ² + 1/φ² = 3 | TRINITY module JonesTopologyDecisionGate { use base::types; @@ -10,33 +10,33 @@ module JonesTopologyDecisionGate { use vsa::ops; use demos::jones_topology_filter; - // 678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 + // ═════════════════════════════════════════════════════════════════ // Decision Gate Hypotheses - // 7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ═════════════════════════════════════════════════════════════════════ - // TH-01: Self-similarity 140 d = 1.0 + // TH-01: Self-similarity → d = 1.0 // Same structure compared with itself should have perfect similarity const TH_01_TARGET : f64 = 1.0; - // TH-02: Inversion similarity 141 d < 0.95 + // TH-02: Inversion similarity → d < 0.95 // Inverted structure should have low similarity const TH_02_THRESHOLD : f64 = 0.95; - // TH-03: Different types 142 d < 0.5 + // TH-03: Different types → d < 0.5 // Tree vs cycle structures should have low similarity const TH_03_THRESHOLD : f64 = 0.5; - // TH-04: Simple 143 complex monotonic + // TH-04: Simple → complex monotonic // Complex structure should have HIGHER complexity level than simple const TH_04_EXPECTED : u8 = jones_topology_filter::COMPLEXITY_HIGH; - // TH-05: Random orthogonality 144 |d| 145 0 + // TH-05: Random orthogonality → |d| ≈ 0 // Random structures should be orthogonal (similarity near 0) const TH_05_THRESHOLD : f64 = 0.2; - // 146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 + // ═════════════════════════════════════════════════════════════════ // Test Structures - // 211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════ // Tree-like structure (sequential pattern) fn tree_structure() -> []Trit { @@ -157,9 +157,9 @@ module JonesTopologyDecisionGate { return result; } - // 280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 + // ═════════════════════════════════════════════════════════════════ // Cosine Similarity Helper - // 345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════════ fn cosine_similarity(a: []Trit, b: []Trit) -> f64 { const dim = a.len(); @@ -174,9 +174,9 @@ module JonesTopologyDecisionGate { return dot / (norm_a * norm_b); } - // 418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 + // ═════════════════════════════════════════════════════════════════════════ // Decision Gate Tests - // 491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 + // ═════════════════════════════════════════════════════════════════════════════ test TH_01_self_similarity_one given A = jones_topology_filter::standard_structure() @@ -215,9 +215,9 @@ module JonesTopologyDecisionGate { and sim = cosine_similarity(rand_a, rand_b) then constants::abs(sim) < TH_05_THRESHOLD - // 568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652 + // ═════════════════════════════════════════════════════════════════════════════════════ // Cosine Similarity Matrix Test - // 653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 + // ═══════════════════════════════════════════════════════════════════════════════════════ test similarity_matrix_computed // Verify all pairwise similarities are computed @@ -248,9 +248,9 @@ module JonesTopologyDecisionGate { // Check each pair is in [-1, 1] then all_valid - // 740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 + // ═══════════════════════════════════════════════════════════════════════════════════════ // Complexity Distribution Test - // 827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917 + // ═══════════════════════════════════════════════════════════════════════════════════════════ test complexity_distribution_valid given structures = [ @@ -267,9 +267,9 @@ module JonesTopologyDecisionGate { // All complexity levels should be in {0, 1, 2} then true - // 9189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 + // ═════════════════════════════════════════════════════════════════════════════════════════════════════ // Invariants - // 101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123 + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════ invariant decision_gate_constants_valid assert TH_01_TARGET == 1.0 @@ -319,9 +319,9 @@ module JonesTopologyDecisionGate { and sim = cosine_similarity(structures[0], structures[1]) assert sim >= -1.0 and sim <= 1.0 - // 11241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ // Benchmarks - // 1243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848714 bench jones_signature_throughput + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════14 bench jones_signature_throughput measure: nanoseconds to compute jones_signature(standard_structure()) target: < 5000ns diff --git a/specs/demos/jones_topology_filter.t27 b/specs/demos/jones_topology_filter.t27 index e864a0c7fe..ecaa0f6f0d 100644 --- a/specs/demos/jones_topology_filter.t27 +++ b/specs/demos/jones_topology_filter.t27 @@ -5,7 +5,7 @@ // - Takes a hypervector representing a structure // - Computes dot_product similarity with a reference structure // - Classifies complexity based on similarity thresholds -// - Uses a fixed Chern-Simons constant (0) as reference value +// - Uses a fixed Chern-Simons constant (φ) as reference value // WHAT THIS CODE DOES NOT DO: // - Does NOT compute Jones polynomial from input topology // - Does NOT provide "topological acceleration" diff --git a/specs/file/operations.t27 b/specs/file/operations.t27 index 5d997edb6e..8a19950f61 100644 --- a/specs/file/operations.t27 +++ b/specs/file/operations.t27 @@ -1,14 +1,14 @@ // specs/file/operations.t27 // File Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module FileOperations { use base::types; use file::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Read Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // read reads a file's contents fn read(path: str, includeDiff: bool) -> Result { @@ -35,9 +35,9 @@ module FileOperations { // Implementation: Get file metadata } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Write Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // write writes content to a file fn write(path: str, content: str) -> Result { @@ -74,9 +74,9 @@ module FileOperations { // Implementation: Delete line range } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Directory Operations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // list lists contents of a directory fn list(path: str) -> Result<[FileNode], FileError> { @@ -113,9 +113,9 @@ module FileOperations { // Implementation: Delete file } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Ignore Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // is_ignored checks if a path is ignored fn is_ignored(path: str, rules: IgnoreRules) -> bool { @@ -132,9 +132,9 @@ module FileOperations { // Implementation: Add ignore pattern } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Path Operations - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // normalize normalizes a file path fn normalize(path: str) -> str { @@ -176,9 +176,9 @@ module FileOperations { // Implementation: Resolve path relative to base } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Content Operations - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // detect_type detects content type fn detect_type(path: str, content: str) -> ContentType { @@ -195,9 +195,9 @@ module FileOperations { // Implementation: Truncate and add ellipsis } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Tests - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ test "file_type_values" { assert(FileType::File as u32 == 0); diff --git a/specs/file/schema.t27 b/specs/file/schema.t27 index e54ec95a3c..0e9ce9ecb9 100644 --- a/specs/file/schema.t27 +++ b/specs/file/schema.t27 @@ -1,13 +1,13 @@ // specs/file/schema.t27 // File Types Specification -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module File { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // File Type - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // FileType represents the type of a file system entry enum FileType { @@ -16,9 +16,9 @@ module File { Symlink = 2, // Symbolic link } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // File Status - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // FileStatus represents the status of a file change enum FileStatus { @@ -27,9 +27,9 @@ module File { Modified = 2, // File was modified } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Content Type - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // ContentType represents the type of file content enum ContentType { @@ -38,9 +38,9 @@ module File { Image = 2, // Image content } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Watch Event Type - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // WatchEventType represents the type of file system event enum WatchEventType { @@ -49,9 +49,9 @@ module File { Unlink = 2, // File/directory removed } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // File Error - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // FileError represents errors in file operations enum FileError { @@ -66,9 +66,9 @@ module File { DeleteError = 8, } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // File Info - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // FileInfo represents metadata about a file struct FileInfo { @@ -81,9 +81,9 @@ module File { isIgnored: bool, // Whether file is ignored } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // File Content - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ // FileContent represents the content of a file struct FileContent { @@ -95,9 +95,9 @@ module File { lineCount: u32?, // Number of lines (text only) } - // 956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ════════════════════════════════════════════════════════════════════ // File Node - // 10241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 + // ════════════════════════════════════════════════════════════════════ // FileNode represents a node in the file tree struct FileNode { @@ -109,9 +109,9 @@ module File { children: [FileNode]?, // Children (directories only) } - // 10921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159 + // ════════════════════════════════════════════════════════════════════ // File Change - // 11601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 + // ════════════════════════════════════════════════════════════════════ // FileChange represents a change to a file struct FileChange { @@ -121,9 +121,9 @@ module File { deletions: u32, // Number of lines deleted } - // 12281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295 + // ════════════════════════════════════════════════════════════════════ // Ignore Rules - // 12961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363 + // ════════════════════════════════════════════════════════════════════ // IgnorePattern represents a single ignore pattern struct IgnorePattern { @@ -137,9 +137,9 @@ module File { whitelists: [str], // Whitelisted paths (exceptions) } - // 13641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431 + // ════════════════════════════════════════════════════════════════════ // Search - // 14321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499 + // ════════════════════════════════════════════════════════════════════ // SearchMatch represents a search result struct SearchMatch { @@ -160,9 +160,9 @@ module File { fileType: FileType?, // Filter by file type } - // 15001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567 + // ════════════════════════════════════════════════════════════════════ // Watch Event - // 15681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635 + // ════════════════════════════════════════════════════════════════════ // WatchEvent represents a file system watch event struct WatchEvent { @@ -178,9 +178,9 @@ module File { active: bool, // Whether watcher is active } - // 16361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703 + // ════════════════════════════════════════════════════════════════════ // Ripgrep Integration - // 17041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771 + // ════════════════════════════════════════════════════════════════════ // Submatch represents a regex submatch struct Submatch { @@ -206,17 +206,17 @@ module File { limit: u32, // Maximum number of results } - // 17721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839 + // ════════════════════════════════════════════════════════════════════ // Constants - // 18401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907 + // ════════════════════════════════════════════════════════════════════ const MAX_FILE_SIZE: u64 = 10485760; // 10MB max file size const MAX_SEARCH_RESULTS: u32 = 1000; // Max search results const DEFAULT_READ_CHUNK: u32 = 8192; // 8KB default read chunk - // 19081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 19761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043 + // ════════════════════════════════════════════════════════════════════ // is_text checks if content type is text fn is_text(contentType: ContentType) -> bool { @@ -253,9 +253,9 @@ module File { return parts[parts.len - 1]; } - // 20442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111 + // ════════════════════════════════════════════════════════════════════ // Tests - // 21122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179 + // ════════════════════════════════════════════════════════════════════ test "file_type_values" { assert(FileType::File as u32 == 0); diff --git a/specs/file/watcher.t27 b/specs/file/watcher.t27 index e6e5ee5836..53c12f2440 100644 --- a/specs/file/watcher.t27 +++ b/specs/file/watcher.t27 @@ -1,21 +1,21 @@ // specs/file/watcher.t27 // File Watcher Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module FileWatcher { use base::types; use file::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Watcher ID Type - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // WatcherID is a branded string representing a watcher identifier struct WatcherID(str); - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Watcher Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // create creates a new file watcher fn create() -> Result { @@ -47,9 +47,9 @@ module FileWatcher { // Implementation: Get list of watched paths } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Event Operations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // next gets the next event from the watcher fn next(watcherID: WatcherID) -> Result { @@ -66,9 +66,9 @@ module FileWatcher { // Implementation: Wait for event with timeout in ms } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Filter Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // WatchFilter represents a filter for watch events struct WatchFilter { @@ -94,9 +94,9 @@ module FileWatcher { // Implementation: Check if event matches filter } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Backend Types - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // WatcherBackend represents the watcher backend implementation enum WatcherBackend { @@ -116,9 +116,9 @@ module FileWatcher { // Implementation: Check if backend is available } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Debounce Operations - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // DebounceMode represents the debounce mode enum DebounceMode { @@ -137,9 +137,9 @@ module FileWatcher { // Implementation: Get debounce mode and delay } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Batch Operations - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ // watch_batch watches multiple paths at once fn watch_batch(watcherID: WatcherID, paths: [str], recursive: bool) -> Result { @@ -151,9 +151,9 @@ module FileWatcher { // Implementation: Stop watching multiple paths } - // 956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ════════════════════════════════════════════════════════════════════ // Statistics - // 10241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 + // ════════════════════════════════════════════════════════════════════ // WatcherStats represents watcher statistics struct WatcherStats { @@ -174,9 +174,9 @@ module FileWatcher { // Implementation: Reset event/error counters } - // 10921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159 + // ════════════════════════════════════════════════════════════════════ // Tests - // 11601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 + // ════════════════════════════════════════════════════════════════════ test "watcher_id_creation" { var id = WatcherID("watch-123"); diff --git a/specs/fpga/bridge.t27 b/specs/fpga/bridge.t27 index 8b7defc8f9..bd335b9bb8 100644 --- a/specs/fpga/bridge.t27 +++ b/specs/fpga/bridge.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/bridge.t27 // FPGA Communication Bridge Specification // Combines UART and SPI for host and peripheral communication -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module FPGA_Bridge; // Import base types and submodules @@ -11,9 +11,9 @@ module FPGA_Bridge; use fpga::spi::SPI_Master; use fpga::mac::ZeroDSP_MAC; - // 456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 + // ═══════════════════════════════════════════════════════════════ // 1. Bridge Configuration - // 676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ═════════════════════════════════════════════════════════════════════════ // Buffer configuration const RX_BUFFER_SIZE : usize = 256; // UART RX buffer size @@ -31,9 +31,9 @@ module FPGA_Bridge; const OP_MAC_DOT : u8 = 3; const NUM_MAC_UNITS : usize = 8; - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 + // ═══════════════════════════════════════════════════════════════ // 2. Bridge State - // 203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ═════════════════════════════════════════════════════════════════════════ // Bridge state machine const BRIDGE_IDLE : u8 = 0; @@ -75,15 +75,15 @@ module FPGA_Bridge; .mac_enabled = true, }; - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 + // ═══════════════════════════════════════════════════════════════ // 3. Buffer Management - // 339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ═════════════════════════════════════════════════════════════════════════ // RX and TX buffers var rx_buffer : [RX_BUFFER_SIZE]u8 = [0u8; RX_BUFFER_SIZE]; var tx_buffer : [TX_BUFFER_SIZE]u8 = [0u8; TX_BUFFER_SIZE]; - // buffer_write(buf: []u8, size: usize, head: usize, data: u8) 412 bool + // buffer_write(buf: []u8, size: usize, head: usize, data: u8) → bool // Write byte to circular buffer fn buffer_write(buf_in: []u8, size: usize, head: usize, data: u8) -> bool { const new_head = (head + 1) % size; @@ -94,7 +94,7 @@ module FPGA_Bridge; return true; } - // buffer_read(buf: []u8, size: usize, tail: usize) 413 (u8, usize) + // buffer_read(buf: []u8, size: usize, tail: usize) → (u8, usize) // Read byte from circular buffer, return (data, new_tail) fn buffer_read(buf: []u8, size: usize, tail: usize) -> (u8, usize) { if (tail == size) { @@ -105,7 +105,7 @@ module FPGA_Bridge; return (data, new_tail); } - // buffer_count(head: usize, tail: usize, size: usize) 414 usize + // buffer_count(head: usize, tail: usize, size: usize) → usize // Count bytes in circular buffer fn buffer_count(head: usize, tail: usize, size: usize) -> usize { if (head >= tail) { @@ -115,21 +115,21 @@ module FPGA_Bridge; } } - // bridge_rx_available() 415 usize + // bridge_rx_available() → usize // Get available bytes in RX buffer fn bridge_rx_available() -> usize { return buffer_count(bridge.rx_head, bridge.rx_tail, RX_BUFFER_SIZE); } - // bridge_tx_space() 416 usize + // bridge_tx_space() → usize // Get available space in TX buffer fn bridge_tx_space() -> usize { return TX_BUFFER_SIZE - buffer_count(bridge.tx_head, bridge.tx_tail, TX_BUFFER_SIZE); } - // 417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ═══════════════════════════════════════════════════════════════ // 4. Packet Protocol - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 + // ═════════════════════════════════════════════════════════════════════════ // Packet types const PKT_UART_DATA : u8 = 0x00; @@ -140,7 +140,7 @@ module FPGA_Bridge; // Packet format: [TYPE][LEN][DATA...][CRC] - // bridge_parse_header() 553 bool + // bridge_parse_header() → bool // Parse packet header from RX buffer fn bridge_parse_header() -> bool { if (bridge_rx_available() < 2) { @@ -164,7 +164,7 @@ module FPGA_Bridge; return true; } - // bridge_process_payload() 554 bool + // bridge_process_payload() → bool // Process packet payload based on type fn bridge_process_payload() -> bool { if (bridge_rx_available() < bridge.packet_len as usize) { @@ -202,11 +202,11 @@ module FPGA_Bridge; return true; } - // 555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 + // ═══════════════════════════════════════════════════════════════ // 5. Packet Handlers - // 618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690 + // ═════════════════════════════════════════════════════════════════════════ - // bridge_handle_uart_data() 691 void + // bridge_handle_uart_data() → void // Handle UART data packet (echo back) fn bridge_handle_uart_data() -> void { var i : usize = 0; @@ -226,7 +226,7 @@ module FPGA_Bridge; } } - // bridge_handle_spi_xfer() 692 void + // bridge_handle_spi_xfer() → void // Handle SPI transfer packet fn bridge_handle_spi_xfer() -> void { if (!bridge.spi_enabled || spi_is_busy()) { @@ -244,7 +244,7 @@ module FPGA_Bridge; } } - // bridge_handle_mac_op() 693 void + // bridge_handle_mac_op() → void // Handle MAC operation packet // Packet format: [OP][UNIT][A_L][A_H][B_L][B_H] // OP: MAC opcode (0=mul, 1=mac, 2=macc, 3=dot) @@ -310,7 +310,7 @@ module FPGA_Bridge; } } - // bridge_handle_status() 694 void + // bridge_handle_status() → void // Handle status request fn bridge_handle_status() -> void { // Send status response @@ -330,7 +330,7 @@ module FPGA_Bridge; } } - // bridge_handle_config() 695 void + // bridge_handle_config() → void // Handle configuration packet fn bridge_handle_config() -> void { const cfg_byte = buffer_read(rx_buffer, RX_BUFFER_SIZE, bridge.rx_tail); @@ -342,9 +342,9 @@ module FPGA_Bridge; bridge.mac_enabled = (cfg_byte & 0x02) != 0; } - // 696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786 + // ═══════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for FPGA_Bridge - // 787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877 + // ═══════════════════════════════════════════════════════════════════════════════════════════ test bridge_initially_idle given state = bridge.state diff --git a/specs/fpga/mac.t27 b/specs/fpga/mac.t27 index 102807518b..34f8fa0e15 100644 --- a/specs/fpga/mac.t27 +++ b/specs/fpga/mac.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/mac.t27 // ZeroDSP FPGA Multiply-Accumulate Specification // Ternary MAC operations for FPGA implementation -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ZeroDSP_MAC; // Import base types, operations, and ISA registers @@ -10,9 +10,9 @@ module ZeroDSP_MAC; use base::ops; use isa::registers; - // 45678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 + // ══════════════════════════════════════════════════════════ // 1. MAC Configuration - // 6263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 + // ══════════════════════════════════════════════════════════ // MAC unit configuration const MAC_WIDTH : usize = 27; // 27 trits per operand (TernaryWord) @@ -31,33 +31,33 @@ module ZeroDSP_MAC; const STATUS_BUSY : u8 = 1; // Operation in progress const STATUS_DONE : u8 = 2; // Operation complete - // 120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 + // ══════════════════════════════════════════════════════════ // 2. Ternary Multiplication LUT - // 178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 + // ══════════════════════════════════════════════════════════ // LUT configuration for ternary multiplication - // LUT size: 9 entries (32363 for balanced ternary) - // Input: (a + 1) * 3 + (b + 1), where a,b 237 {-1, 0, +1} + // LUT size: 9 entries (3×3 for balanced ternary) + // Input: (a + 1) * 3 + (b + 1), where a,b ∈ {-1, 0, +1} // Output: ternary result (i8: -1, 0, +1) // Index mapping: - // 0: (-1,-1) 238 +1, 1: (-1, 0) 239 0, 2: (-1,+1) 240 -1 - // 3: ( 0,-1) 241 0, 4: ( 0, 0) 242 0, 5: ( 0,+1) 243 0 - // 6: (+1,-1) 244 -1, 7: (+1, 0) 245 0, 8: (+1,+1) 246 +1 + // 0: (-1,-1) → +1, 1: (-1, 0) → 0, 2: (-1,+1) → -1 + // 3: ( 0,-1) → 0, 4: ( 0, 0) → 0, 5: ( 0,+1) → 0 + // 6: (+1,-1) → -1, 7: (+1, 0) → 0, 8: (+1,+1) → +1 const MAC_LUT : [9]i8 = [ - 1, // (-1,-1) 247 +1 - 0, // (-1, 0) 248 0 - -1, // (-1,+1) 249 -1 - 0, // ( 0,-1) 250 0 - 0, // ( 0, 0) 251 0 - 0, // ( 0,+1) 252 0 - -1, // (+1,-1) 253 -1 - 0, // (+1, 0) 254 0 - 1, // (+1,+1) 255 +1 + 1, // (-1,-1) → +1 + 0, // (-1, 0) → 0 + -1, // (-1,+1) → -1 + 0, // ( 0,-1) → 0 + 0, // ( 0, 0) → 0 + 0, // ( 0,+1) → 0 + -1, // (+1,-1) → -1 + 0, // (+1, 0) → 0 + 1, // (+1,+1) → +1 ]; - // 256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 + // ══════════════════════════════════════════════════════════ // 3. MAC Unit State - // 314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 + // ══════════════════════════════════════════════════════════ // MAC unit state // #2275: the packed word this spec has always assumed. No file in the @@ -86,14 +86,14 @@ module ZeroDSP_MAC; MACUnit{ .accumulator = 0, .status = STATUS_READY, .pipeline = [TernaryWord{.raw = 0}; PIPELINE_STAGES] }, ]; - // 372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 + // ══════════════════════════════════════════════════════════ // 4. Trit Extraction - // 430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 + // ══════════════════════════════════════════════════════════ - // extract_trit(word: TernaryWord, index: usize) 488 Trit + // extract_trit(word: TernaryWord, index: usize) → Trit // Extract trit at given index from TernaryWord // For packed ternary: each trit uses 2 bits - // Mapping: 0 489 0, 1 490 +1, 2 491 -1 (encoding) + // Mapping: 0 → 0, 1 → +1, 2 → -1 (encoding) fn extract_trit(word: TernaryWord, index: usize) -> Trit { const bit_pos = index * 2; const mask = 3u32 << bit_pos; @@ -108,7 +108,7 @@ module ZeroDSP_MAC; } } - // pack_trit(trit: Trit, index: usize) 492 u32 + // pack_trit(trit: Trit, index: usize) → u32 // Pack a trit into a word at the given position fn pack_trit(trit: Trit, index: usize) -> u32 { const bit_pos = index * 2; @@ -118,11 +118,11 @@ module ZeroDSP_MAC; return encoded << bit_pos; } - // 493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 + // ══════════════════════════════════════════════════════════ // 5. MAC Operations - // 551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 + // ══════════════════════════════════════════════════════════ - // mac_multiply(a: TernaryWord, b: TernaryWord, unit: u8) 609 TernaryWord + // mac_multiply(a: TernaryWord, b: TernaryWord, unit: u8) → TernaryWord // Ternary multiplication using LUT // a[i] * b[i] for each trit, packed into TernaryWord fn mac_multiply(a: TernaryWord, b: TernaryWord, unit: u8) -> TernaryWord { @@ -140,7 +140,7 @@ module ZeroDSP_MAC; const b_trit = extract_trit(b, i); // Compute LUT index: (a + 1) * 3 + (b + 1) - const a_idx = (a_trit as i8) + 1; // -16100, 06111, +16122 + const a_idx = (a_trit as i8) + 1; // -1→0, 0→1, +1→2 const b_idx = (b_trit as i8) + 1; const lut_idx = (a_idx * 3) + (b_idx as usize); @@ -160,8 +160,8 @@ module ZeroDSP_MAC; return TernaryWord{ .raw = result }; } - // mac_cycle(a: TernaryWord, b: TernaryWord, unit: u8, acc: i32) 613 i32 - // Single MAC cycle: acc = acc + 614 (a[i] * b[i]) + // mac_cycle(a: TernaryWord, b: TernaryWord, unit: u8, acc: i32) → i32 + // Single MAC cycle: acc = acc + Σ (a[i] * b[i]) // Uses signed integer accumulation fn mac_cycle(a: TernaryWord, b: TernaryWord, unit: u8, acc: i32) -> i32 { if (unit >= NUM_MAC_UNITS) { @@ -170,7 +170,7 @@ module ZeroDSP_MAC; mac_units[unit].status = STATUS_BUSY; - // Compute dot product: 615 a[i] * b[i] + // Compute dot product: Σ a[i] * b[i] var dot : i32 = 0; var i : usize = 0; @@ -189,9 +189,9 @@ module ZeroDSP_MAC; return mac_units[unit].accumulator; } - // mac_dot_product(a: []TernaryWord, b: []TernaryWord, len: usize, unit: u8) 616 i32 + // mac_dot_product(a: []TernaryWord, b: []TernaryWord, len: usize, unit: u8) → i32 // Full vector dot product using MAC unit - // result = 617_i 618_j (a[i][j] * b[i][j]) + // result = Σ_i Σ_j (a[i][j] * b[i][j]) fn mac_dot_product(a: []TernaryWord, b: []TernaryWord, len: usize, unit: u8) -> i32 { if (unit >= NUM_MAC_UNITS) { return 0; @@ -223,9 +223,9 @@ module ZeroDSP_MAC; // cols: usize, // result: []i32, // [rows] output // unit_assign: []u8 // MAC unit assignment per row - // ) 619 void + // ) → void // Matrix-vector multiplication using MAC units - // result[i] = 620_j mat[i][j] * vec[j] + // result[i] = Σ_j mat[i][j] * vec[j] fn mac_matrix_vector( mat: []TernaryWord, vec: []TernaryWord, @@ -257,11 +257,11 @@ module ZeroDSP_MAC; } } - // 621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 + // ══════════════════════════════════════════════════════════ // 6. MAC Unit Management - // 679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736 + // ══════════════════════════════════════════════════════════ - // mac_status_read(unit: u8) 737 u8 + // mac_status_read(unit: u8) → u8 // Read MAC unit status // #2241: the reset vectors check the accumulator AFTER mac_reset, and no // function exposed it -- the only read path was mac_cycle's return, which @@ -280,7 +280,7 @@ module ZeroDSP_MAC; return mac_units[unit].status; } - // mac_status_write(unit: u8, status: u8) 738 bool + // mac_status_write(unit: u8, status: u8) → bool // Write MAC unit status fn mac_status_write(unit: u8, status: u8) -> bool { if (unit >= NUM_MAC_UNITS) { @@ -290,7 +290,7 @@ module ZeroDSP_MAC; return true; } - // mac_reset(unit: u8) 739 bool + // mac_reset(unit: u8) → bool // Reset MAC unit accumulator and status fn mac_reset(unit: u8) -> bool { if (unit >= NUM_MAC_UNITS) { @@ -302,7 +302,7 @@ module ZeroDSP_MAC; return true; } - // mac_reset_all() 740 void + // mac_reset_all() → void // Reset all MAC units fn mac_reset_all() -> void { var i : usize = 0; @@ -313,7 +313,7 @@ module ZeroDSP_MAC; } } - // mac_get_accumulator(unit: u8) 741 i32 + // mac_get_accumulator(unit: u8) → i32 // Get accumulator value from MAC unit fn mac_get_accumulator(unit: u8) -> i32 { if (unit >= NUM_MAC_UNITS) { @@ -322,7 +322,7 @@ module ZeroDSP_MAC; return mac_units[unit].accumulator; } - // mac_set_accumulator(unit: u8, value: i32) 742 bool + // mac_set_accumulator(unit: u8, value: i32) → bool // Set accumulator value for MAC unit fn mac_set_accumulator(unit: u8, value: i32) -> bool { if (unit >= NUM_MAC_UNITS) { @@ -332,16 +332,16 @@ module ZeroDSP_MAC; return true; } - // 743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800 + // ══════════════════════════════════════════════════════════ // 7. Parallel MAC Operations - // 801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 + // ══════════════════════════════════════════════════════════ // mac_parallel_multiply( // a: []TernaryWord, // b: []TernaryWord, // results: []TernaryWord, // count: usize - // ) 859 void + // ) → void // Parallel multiplication using multiple MAC units // results[i] = mac_multiply(a[i], b[i], i % NUM_MAC_UNITS) fn mac_parallel_multiply( @@ -359,9 +359,9 @@ module ZeroDSP_MAC; } } - // 860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917 + // ══════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for ZeroDSP_MAC - // 918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975 + // ══════════════════════════════════════════════════════════ test mac_lut_multiply_pos_pos given a = TernaryWord{.raw = 0} @@ -551,18 +551,18 @@ module ZeroDSP_MAC; assert PIPELINE_STAGES == 4 invariant mac_lut_correctness_pos_pos - assert MAC_LUT[8] == 1 // (+1,+1) 976 +1 + assert MAC_LUT[8] == 1 // (+1,+1) → +1 invariant mac_lut_correctness_neg_neg - assert MAC_LUT[0] == 1 // (-1,-1) 977 +1 + assert MAC_LUT[0] == 1 // (-1,-1) → +1 invariant mac_lut_correctness_pos_neg - assert MAC_LUT[6] == -1 // (+1,-1) 978 -1 + assert MAC_LUT[6] == -1 // (+1,-1) → -1 invariant mac_lut_correctness_with_zero - assert MAC_LUT[1] == 0 and MAC_LUT[2] == -1 // (-1,0) 979 0, (-1,+1) 980 -1 - assert MAC_LUT[3] == 0 and MAC_LUT[4] == 0 // (0,-1) 981 0, (0,0) 982 0 - assert MAC_LUT[5] == 0 and MAC_LUT[7] == 0 // (0,+1) 983 0, (+1,0) 984 0 + assert MAC_LUT[1] == 0 and MAC_LUT[2] == -1 // (-1,0) → 0, (-1,+1) → -1 + assert MAC_LUT[3] == 0 and MAC_LUT[4] == 0 // (0,-1) → 0, (0,0) → 0 + assert MAC_LUT[5] == 0 and MAC_LUT[7] == 0 // (0,+1) → 0, (+1,0) → 0 invariant mac_status_range_valid given status = mac_status_read(0) diff --git a/specs/fpga/spi.t27 b/specs/fpga/spi.t27 index 84377068a7..1507ec7166 100644 --- a/specs/fpga/spi.t27 +++ b/specs/fpga/spi.t27 @@ -2,15 +2,15 @@ // t27/specs/fpga/spi.t27 // SPI Master Specification for FPGA // Mode 0: CPOL=0, CPHA=0 (SCK idle low, sample on rising edge) -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module SPI_Master; // Import base types use base::types; - // 456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 + // ═══════════════════════════════════════════════════════════════ // 1. SPI Configuration - // 676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ═════════════════════════════════════════════════════════════════════════ // System clock const CLK_FREQ : u32 = 50_000_000; // 50 MHz @@ -36,9 +36,9 @@ module SPI_Master; const PRESCALER_128 : u8 = 6; const PRESCALER_256 : u8 = 7; - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 + // ═══════════════════════════════════════════════════════════════ // 2. SPI State Machine - // 203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ═════════════════════════════════════════════════════════════════════════ // SPI states const SPI_IDLE : u8 = 0; @@ -51,9 +51,9 @@ module SPI_Master; const RX_BIT : u8 = 1; const WAIT_EDGE : u8 = 2; - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 + // ═══════════════════════════════════════════════════════════════ // 3. SPI Master Unit - // 339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ═════════════════════════════════════════════════════════════════════════ // SPI master state struct SPI_Master_Unit { @@ -98,7 +98,7 @@ module SPI_Master; .cs_deassert_cnt = 0, }; - // spi_set_prescaler(psc: u8) 412 bool + // spi_set_prescaler(psc: u8) → bool // Set SPI clock prescaler fn spi_set_prescaler(psc: u8) -> bool { if (psc > PRESCALER_256) { @@ -108,7 +108,7 @@ module SPI_Master; return true; } - // spi_get_prescaler_div() 413 u32 + // spi_get_prescaler_div() → u32 // Get actual prescaler divider value fn spi_get_prescaler_div() -> u32 { // Was a `match` expression, which t27 has never parsed -- the whole @@ -125,13 +125,13 @@ module SPI_Master; return 16; } - // spi_get_sck_freq() 414 u32 + // spi_get_sck_freq() → u32 // Get SPI SCK frequency fn spi_get_sck_freq() -> u32 { return CLK_FREQ / spi_get_prescaler_div(); } - // spi_set_data_width(width: u8) 415 bool + // spi_set_data_width(width: u8) → bool // Set data width (1-32 bits) fn spi_set_data_width(width: u8) -> bool { if (width == 0 || width > MAX_DATA_WIDTH) { @@ -141,13 +141,13 @@ module SPI_Master; return true; } - // spi_is_busy() 416 bool + // spi_is_busy() → bool // Check if SPI is busy fn spi_is_busy() -> bool { return spi.busy; } - // spi_transfer(data: u32) 417 bool + // spi_transfer(data: u32) → bool // Start SPI transfer fn spi_transfer(data: u32) -> bool { if (spi.busy) { @@ -162,19 +162,19 @@ module SPI_Master; return true; } - // spi_read_rx() 418 u32 + // spi_read_rx() → u32 // Read received data (lower bits only) fn spi_read_rx() -> u32 { return spi.rx_data & ((1u32 << spi.data_width) - 1); } - // spi_get_cs() 419 bool + // spi_get_cs() → bool // Get CS line state fn spi_get_cs() -> bool { return spi.cs_asserted; } - // spi_get_sck() 420 bool + // spi_get_sck() → bool // Get SCK line state (Mode 0: idle low) fn spi_get_sck() -> bool { // In Mode 0: SCK is low in idle @@ -185,7 +185,7 @@ module SPI_Master; return SPI_CPOL == 0; } - // spi_get_mosi() 421 bool + // spi_get_mosi() → bool // Get MOSI line state fn spi_get_mosi() -> bool { if (!spi.busy || spi.state != SPI_TRANSFER) { @@ -194,7 +194,7 @@ module SPI_Master; return (spi.tx_data >> (spi.data_width - spi.bit_count - 1)) & 1 == 1; } - // spi_tick() 422 void + // spi_tick() → void // Process one system clock cycle fn spi_tick() -> void { // Was a `match` statement (never parsed; the whole FSM tick was @@ -220,7 +220,7 @@ module SPI_Master; } } - // spi_transfer_bit() 423 void + // spi_transfer_bit() → void // Transfer single bit fn spi_transfer_bit() -> void { const prescaler_div = spi_get_prescaler_div(); @@ -255,9 +255,9 @@ module SPI_Master; } } - // 425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515 + // ═══════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for SPI_Master - // 516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606 + // ═══════════════════════════════════════════════════════════════════════════════════════════ test spi_mode_0_configuration given cpol = SPI_CPOL diff --git a/specs/fpga/testbench/mac_tb.t27 b/specs/fpga/testbench/mac_tb.t27 index a3d7d0d345..4de4a81ea1 100644 --- a/specs/fpga/testbench/mac_tb.t27 +++ b/specs/fpga/testbench/mac_tb.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/testbench/mac_tb.t27 // MAC Unit Testbench Specification // Tests ternary LUT multiplication, MAC operations, and accumulator -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module MAC_Testbench { // Import base types and MAC module @@ -47,14 +47,14 @@ module MAC_Testbench { // 3. Test Helpers - // generate_clock() 788 void + // generate_clock() → void // Generate 50 MHz clock fn generate_clock() -> void { clk = !clk; sim_cycle = sim_cycle + 1; } - // wait_cycles(n: u32) 789 void + // wait_cycles(n: u32) → void // Wait n clock cycles fn wait_cycles(n: u32) -> void { var i : u32 = 0; @@ -64,7 +64,7 @@ module MAC_Testbench { } } - // wait_mac_ready() 790 void + // wait_mac_ready() → void // Wait until MAC is ready fn wait_mac_ready() -> void { var timeout : u32 = 0; @@ -74,7 +74,7 @@ module MAC_Testbench { } } - // wait_mac_done() 791 void + // wait_mac_done() → void // Wait until MAC operation is done fn wait_mac_done() -> void { var timeout : u32 = 0; @@ -84,7 +84,7 @@ module MAC_Testbench { } } - // make_trit_word(trits: []i8) 792 TernaryWord + // make_trit_word(trits: []i8) → TernaryWord // Create TernaryWord from trit array fn make_trit_word(trits: []i8) -> TernaryWord { var word : u32 = 0; @@ -104,7 +104,7 @@ module MAC_Testbench { // 4. Test Cases - // test_mac_lut_pos_pos() 1091 void + // test_mac_lut_pos_pos() → void // Test LUT: (+1) * (+1) = +1 fn test_mac_lut_pos_pos() -> void { const a = make_trit_word([TRIT_POS]); @@ -115,7 +115,7 @@ module MAC_Testbench { assert_pass(trit == TRIT_POS, "LUT: +1 * +1 = +1"); } - // test_mac_lut_neg_neg() 1092 void + // test_mac_lut_neg_neg() → void // Test LUT: (-1) * (-1) = +1 fn test_mac_lut_neg_neg() -> void { const a = make_trit_word([TRIT_NEG]); @@ -126,7 +126,7 @@ module MAC_Testbench { assert_pass(trit == TRIT_POS, "LUT: -1 * -1 = +1"); } - // test_mac_lut_pos_neg() 1093 void + // test_mac_lut_pos_neg() → void // Test LUT: (+1) * (-1) = -1 fn test_mac_lut_pos_neg() -> void { const a = make_trit_word([TRIT_POS]); @@ -137,7 +137,7 @@ module MAC_Testbench { assert_pass(trit == TRIT_NEG, "LUT: +1 * -1 = -1"); } - // test_mac_lut_with_zero() 1094 void + // test_mac_lut_with_zero() → void // Test LUT: anything * 0 = 0 fn test_mac_lut_with_zero() -> void { const a = make_trit_word([TRIT_POS]); @@ -148,7 +148,7 @@ module MAC_Testbench { assert_pass(trit == TRIT_ZERO, "LUT: +1 * 0 = 0"); } - // test_mac_all_trit_combinations() 1095 void + // test_mac_all_trit_combinations() → void // Test all 9 trit multiplication combinations fn test_mac_all_trit_combinations() -> void { const a_vals = [TRIT_NEG, TRIT_ZERO, TRIT_POS]; @@ -177,7 +177,7 @@ module MAC_Testbench { assert_pass(combinations == 9, "All 9 combinations tested"); } - // test_mac_27_trit_word() 1096 void + // test_mac_27_trit_word() → void // Test full 27-trit word multiplication fn test_mac_27_trit_word() -> void { // Create 27-trit words with alternating pattern @@ -200,7 +200,7 @@ module MAC_Testbench { assert_pass(extract_trit(result, 1) == TRIT_POS, "Position 1"); } - // test_mac_cycle_zero_acc() 1097 void + // test_mac_cycle_zero_acc() → void // Test MAC cycle with zero accumulator fn test_mac_cycle_zero_acc() -> void { const a = make_trit_word([TRIT_POS, TRIT_POS]); @@ -211,7 +211,7 @@ module MAC_Testbench { assert_pass(result == 2, "MAC cycle with zero acc"); } - // test_mac_cycle_with_acc() 1098 void + // test_mac_cycle_with_acc() → void // Test MAC cycle with initial accumulator fn test_mac_cycle_with_acc() -> void { const a = make_trit_word([TRIT_POS]); @@ -222,7 +222,7 @@ module MAC_Testbench { assert_pass(result == 11, "MAC cycle with initial acc"); } - // test_mac_dot_product() 1099 void + // test_mac_dot_product() → void // Test dot product fn test_mac_dot_product() -> void { const vec1 = [ @@ -239,7 +239,7 @@ module MAC_Testbench { assert_pass(result == 2, "Dot product"); } - // test_mac_reset() 1100 void + // test_mac_reset() → void // Test MAC reset fn test_mac_reset() -> void { // Perform some operations @@ -261,7 +261,7 @@ module MAC_Testbench { assert_pass(status1 == STATUS_READY, "Status 1 ready"); } - // test_mac_unit_independence() 1101 void + // test_mac_unit_independence() → void // Test that MAC units are independent fn test_mac_unit_independence() -> void { const a = make_trit_word([TRIT_POS]); @@ -281,7 +281,7 @@ module MAC_Testbench { assert_pass(acc1_after == 1, "Unit 1 value correct"); } - // test_mac_invalid_unit() 1102 void + // test_mac_invalid_unit() → void // Test handling of invalid MAC unit fn test_mac_invalid_unit() -> void { const a = TernaryWord{ .raw = 0 }; @@ -292,7 +292,7 @@ module MAC_Testbench { assert_pass(result.raw == 0, "Invalid unit handling"); } - // test_mac_overflow_handling() 1103 void + // test_mac_overflow_handling() → void // Test 32-bit accumulator overflow handling fn test_mac_overflow_handling() -> void { const large_acc = 0x7FFFFFFF_i32; // Near max int32 @@ -307,7 +307,7 @@ module MAC_Testbench { assert_pass(status == STATUS_DONE, "Overflow handled"); } - // test_mac_parallel_units() 1104 void + // test_mac_parallel_units() → void // Test parallel MAC units fn test_mac_parallel_units() -> void { const a = [TernaryWord{ .raw = 1 }; 8]; @@ -330,7 +330,7 @@ module MAC_Testbench { assert_pass(all_valid, "Parallel units independent"); } - // test_mac_latency() 1105 void + // test_mac_latency() → void // Test MAC operation latency fn test_mac_latency() -> void { const a = make_trit_word([TRIT_POS]); @@ -347,13 +347,13 @@ module MAC_Testbench { // 5. Test Sequences - // run_tests() 1392 void + // run_tests() → void // Run all test sequences fn run_tests() -> void { print(" t27 MAC TESTBENCH ");; - print("1489 t27 MAC TESTBENCH 1490"); + print("║ t27 MAC TESTBENCH ║"); print(" 01 + 1/23 = 3 | TRINITY ");; - print("1571 15721573 + 1/15741575 = 3 | TRINITY 1576"); + print("║ φ² + 1/φ² = 3 | TRINITY ║"); print(" Running 15 test sequences...");; // Apply reset @@ -425,14 +425,14 @@ module MAC_Testbench { // Summary print(" Simulation complete.");; - print("1749 SIMULATION RESULTS 1750"); + print("║ SIMULATION RESULTS ║"); print(" Collecting results...");; print(" Passed: ");; - print("1829 Failed: ", test_failed, " 1830"); + print("║ Failed: ", test_failed, " ║"); if (test_failed == 0) { - print("1831 STATUS: 1832 ALL TESTS PASSED 1833"); + print("║ STATUS: ✓ ALL TESTS PASSED ║"); } else { - print("1834 STATUS: 1835 SOME TESTS FAILED 1836"); + print("║ STATUS: ✗ SOME TESTS FAILED ║"); } print(" =================================");; } diff --git a/specs/fpga/testbench/top_tb.t27 b/specs/fpga/testbench/top_tb.t27 index 5033794fe4..c747b9b940 100644 --- a/specs/fpga/testbench/top_tb.t27 +++ b/specs/fpga/testbench/top_tb.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/testbench/top_tb.t27 // Top-Level FPGA Testbench Specification // Tests complete FPGA system with UART, SPI, MAC, and bridge -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module Top_Level_Testbench { // Import base types and submodules diff --git a/specs/fpga/testbench/uart_tb.t27 b/specs/fpga/testbench/uart_tb.t27 index 7a792c34bc..eb07fa96a2 100644 --- a/specs/fpga/testbench/uart_tb.t27 +++ b/specs/fpga/testbench/uart_tb.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/testbench/uart_tb.t27 // UART Testbench Specification // Tests UART TX/RX functionality, state machines, and timing -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module UART_Testbench { // Import base types and UART module @@ -44,7 +44,7 @@ module UART_Testbench { // 3. Clock Generation - // generate_clock() 588 void + // generate_clock() → void // Generate 50 MHz clock fn generate_clock() -> void { clk = !clk; @@ -53,7 +53,7 @@ module UART_Testbench { // 4. Test Helpers - // assert_pass(condition: bool, message: str) 835 void + // assert_pass(condition: bool, message: str) → void // Record test pass fn assert_pass(condition: bool, message: str) -> void { if (condition) { @@ -63,7 +63,7 @@ module UART_Testbench { } } - // wait_cycles(n: u32) 836 void + // wait_cycles(n: u32) → void // Wait n clock cycles fn wait_cycles(n: u32) -> void { var i : u32 = 0; @@ -73,7 +73,7 @@ module UART_Testbench { } } - // wait_tx_ready() 837 void + // wait_tx_ready() → void // Wait until TX is ready fn wait_tx_ready() -> void { var timeout : u32 = 0; @@ -83,7 +83,7 @@ module UART_Testbench { } } - // wait_rx_data() 838 (bool, u8) + // wait_rx_data() → (bool, u8) // Wait for RX data, return (success, data) fn wait_rx_data() -> (bool, u8) { var timeout : u32 = 0; @@ -100,7 +100,7 @@ module UART_Testbench { // 5. Test Cases - // test_uart_tx_byte(data: u8) 1079 void + // test_uart_tx_byte(data: u8) → void // Test single byte transmission fn test_uart_tx_byte(data: u8) -> void { // Wait for ready @@ -120,7 +120,7 @@ module UART_Testbench { assert_pass(!uart_tx.tx_busy, "TX completed"); } - // test_uart_rx_byte(data: u8) 1080 void + // test_uart_rx_byte(data: u8) → void // Test single byte reception fn test_uart_rx_byte(data: u8) -> void { // Simulate RX transmission @@ -147,7 +147,7 @@ module UART_Testbench { assert_pass(success && received == data, "RX data match"); } - // test_uart_loopback() 1081 void + // test_uart_loopback() → void // Test TX -> RX loopback fn test_uart_loopback() -> void { const data = TEST_DATA_1; @@ -170,7 +170,7 @@ module UART_Testbench { assert_pass(success && received == data, "Loopback data match"); } - // test_uart_framing_error() 1082 void + // test_uart_framing_error() → void // Test framing error detection fn test_uart_framing_error() -> void { // Start bit @@ -193,7 +193,7 @@ module UART_Testbench { assert_pass(uart_rx_has_framing_error(), "Framing error detected"); } - // test_uart_reset() 1083 void + // test_uart_reset() → void // Test UART reset fn test_uart_reset() -> void { // Start a transmission @@ -210,14 +210,14 @@ module UART_Testbench { assert_pass(uart_tx_get_line() == true, "TX line idle high"); } - // test_uart_idle_line() 1084 void + // test_uart_idle_line() → void // Test idle line state fn test_uart_idle_line() -> void { wait_tx_ready(); assert_pass(uart_tx_get_line() == true, "Idle line high"); } - // test_uart_multiple_bytes() 1085 void + // test_uart_multiple_bytes() → void // Test multiple byte transmission fn test_uart_multiple_bytes() -> void { const bytes = [TEST_DATA_1, TEST_DATA_2, TEST_DATA_3, TEST_DATA_4]; @@ -231,7 +231,7 @@ module UART_Testbench { assert_pass(i == 4, "All bytes transmitted"); } - // test_uart_baud_rate_timing() 1086 void + // test_uart_baud_rate_timing() → void // Test baud rate timing fn test_uart_baud_rate_timing() -> void { const data = TEST_DATA_1; @@ -250,13 +250,13 @@ module UART_Testbench { // 6. Test Sequences - // run_tests() 1317 void + // run_tests() → void // Run all test sequences fn run_tests() -> void { print(" t27 UART TESTBENCH");; - print("1406 t27 UART TESTBENCH 1407"); + print("║ t27 UART TESTBENCH ║"); print(" 01 + 1/23 = 3 | TRINITY");; - print("1486 14871488 + 1/14891490 = 3 | TRINITY 1491"); + print("║ φ² + 1/φ² = 3 | TRINITY ║"); print(" Running test sequences...");; // Apply reset @@ -295,14 +295,14 @@ module UART_Testbench { // Summary print(" Simulation complete.");; - print("1654 SIMULATION RESULTS 1655"); + print("║ SIMULATION RESULTS ║"); print(" Collecting results...");; - print("1732 Passed: ", test_passed, " 1733"); - print("1734 Failed: ", test_failed, " 1735"); + print("║ Passed: ", test_passed, " ║"); + print("║ Failed: ", test_failed, " ║"); if (test_failed == 0) { - print("1736 STATUS: 1737 ALL TESTS PASSED 1738"); + print("║ STATUS: ✓ ALL TESTS PASSED ║"); } else { - print("1739 STATUS: 1740 SOME TESTS FAILED 1741"); + print("║ STATUS: ✗ SOME TESTS FAILED ║"); } print(" Done.");; } diff --git a/specs/fpga/top_level.t27 b/specs/fpga/top_level.t27 index 6a33ad0301..3b06dab8ae 100644 --- a/specs/fpga/top_level.t27 +++ b/specs/fpga/top_level.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/top_level.t27 // ZeroDSP FPGA Top Level Module // Integrates MAC and UART for FPGA deployment -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ZeroDSP_TopLevel { use base::types; diff --git a/specs/fpga/uart.t27 b/specs/fpga/uart.t27 index d10f157ba3..8bc6b04cf6 100644 --- a/specs/fpga/uart.t27 +++ b/specs/fpga/uart.t27 @@ -2,7 +2,7 @@ // t27/specs/fpga/uart.t27 // ZeroDSP FPGA UART Specification // UART for debugging and communication -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ZeroDSP_UART { use base::types; diff --git a/specs/git/diff.t27 b/specs/git/diff.t27 index d59b6b64b7..065f3abaab 100644 --- a/specs/git/diff.t27 +++ b/specs/git/diff.t27 @@ -1,14 +1,14 @@ // specs/git/diff.t27 // Git Diff Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module GitDiff { use base::types; use git::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Diff Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // diff returns changed files compared to a ref fn diff(cwd: str, ref: str) -> Result<[Item], GitError> { @@ -35,9 +35,9 @@ module GitDiff { // Implementation: Run git diff ref -- file } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Diff Statistics - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // stats returns line change statistics fn stats(cwd: str, ref: str) -> Result<[Stat], GitError> { @@ -60,9 +60,9 @@ module GitDiff { // Implementation: Calculate totals from stats output } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Diff Analysis - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // get_files_changed returns list of changed files fn get_files_changed(items: [Item]) -> [str] { @@ -89,9 +89,9 @@ module GitDiff { // Implementation: Return true if any item matches path } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Hunk Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // Hunk represents a single diff hunk struct Hunk { @@ -113,9 +113,9 @@ module GitDiff { // Implementation: Count @@ markers in diff text } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Tests - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ test "stat_creation" { var stat = Stat { diff --git a/specs/git/operations.t27 b/specs/git/operations.t27 index 85d4196d54..ec4e228fae 100644 --- a/specs/git/operations.t27 +++ b/specs/git/operations.t27 @@ -1,14 +1,14 @@ // specs/git/operations.t27 // Git Command Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module GitOperations { use base::types; use git::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Core Git Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // run executes a git command with the given arguments fn run(args: [str], opts: Options) -> Result { @@ -90,9 +90,9 @@ module GitOperations { // Implementation: Run git remote get-url name } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Branch Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // branch_list returns all local branches fn branch_list(cwd: str) -> Result<[str], GitError> { @@ -109,9 +109,9 @@ module GitOperations { // Implementation: Run git branch [-D|-d] name } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Tests - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ test "run_with_valid_args" { var opts = Options { diff --git a/specs/git/schema.t27 b/specs/git/schema.t27 index 0a2cd5800f..93a2aff256 100644 --- a/specs/git/schema.t27 +++ b/specs/git/schema.t27 @@ -1,13 +1,13 @@ // specs/git/schema.t27 // Git Types Specification -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module Git { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Git File Status Types - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // Kind represents the type of change to a file enum Kind { @@ -16,9 +16,9 @@ module Git { Modified = 2, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Git Reference Types - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // Base represents a git branch or reference struct Base { @@ -26,9 +26,9 @@ module Git { ref: str, } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Git File Item Types - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // Item represents a changed file with its status struct Item { @@ -44,9 +44,9 @@ module Git { deletions: u32, } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Git Execution Types - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // Options for git command execution struct Options { @@ -62,9 +62,9 @@ module Git { stderr: [u8], } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Git Error Types - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // GitError represents a git operation error struct GitError { @@ -78,9 +78,9 @@ module Git { path: str, } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Constants - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ const DEFAULT_BRANCH_MAIN: str = "main"; const DEFAULT_BRANCH_MASTER: str = "master"; @@ -96,9 +96,9 @@ module Git { "-c", "core.quotepath=false", ]; - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ // parse_kind parses a git status code into a Kind fn parse_kind(code: str) -> Kind { @@ -127,9 +127,9 @@ module Git { return result.exit_code != 0; } - // 956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ════════════════════════════════════════════════════════════════════ // Tests - // 10241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 + // ════════════════════════════════════════════════════════════════════ test "kind_values" { var added = Kind::Added; diff --git a/specs/git/status.t27 b/specs/git/status.t27 index a02076cfb1..911f793e7f 100644 --- a/specs/git/status.t27 +++ b/specs/git/status.t27 @@ -1,14 +1,14 @@ // specs/git/status.t27 // Git Status Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module GitStatus { use base::types; use git::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Status Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // status returns the working tree status fn status(cwd: str) -> Result<[Item], GitError> { @@ -35,9 +35,9 @@ module GitStatus { // Implementation: Run git status --ignored } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Status Filtering - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // filter_by_status filters items by their status kind fn filter_by_status(items: [Item], kind: Kind) -> [Item] { @@ -64,9 +64,9 @@ module GitStatus { return filter_by_status(items, Kind::Modified); } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Status Aggregation - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // count_by_kind counts items by their status kind fn count_by_kind(items: [Item]) -> (added: u32, deleted: u32, modified: u32) { @@ -83,9 +83,9 @@ module GitStatus { // Implementation: Return true if items is not empty } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Tests - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ test "item_creation" { var item = Item { diff --git a/specs/github/tests/e2e_full_flow.t27 b/specs/github/tests/e2e_full_flow.t27 index 14c144ec83..03e3bb359d 100644 --- a/specs/github/tests/e2e_full_flow.t27 +++ b/specs/github/tests/e2e_full_flow.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // specs/github/tests/e2e_full_flow.t27 // End-to-End Full Flow Test for Ring-072 GitHub SSOT -// Tests: Auth 0 Issue 1 PR 2 Comment 3 Sync 4 Cleanup +// Tests: Auth → Issue → PR → Comment → Sync → Cleanup // Ring-074 - E2E Tests // phi^2 + 1/phi^2 = 3 | TRINITY @@ -19,7 +19,7 @@ module github::tests::e2e_full_flow { // STEP 2: Create Issue const issue_title = "[E2E] Ring-074 test issue"; - const issue = issues::issue_create(issue_title, "Automated E2E test 5 safe to delete"); + const issue = issues::issue_create(issue_title, "Automated E2E test — safe to delete"); assert(issue.number > 0); assert(issue.state == "open"); @@ -54,7 +54,7 @@ module github::tests::e2e_full_flow { assert(pr_found == true || pr_found == false); // STEP 6: Add Comment - const comment_body = "E2E test comment 6 78 + 1/910 = 3"; + const comment_body = "E2E test comment — φ² + 1/φ² = 3"; const comment = comments::comment_create(issue.number, comment_body); assert(comment.id > 0); diff --git a/specs/graph/knowledge_graph.t27 b/specs/graph/knowledge_graph.t27 index 4e2adc8be0..4b0f6f1e8c 100644 --- a/specs/graph/knowledge_graph.t27 +++ b/specs/graph/knowledge_graph.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Module: Knowledge Graph for Vector Symbolic Architecture -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module KnowledgeGraph { // ======================================================================== @@ -137,14 +137,14 @@ module KnowledgeGraph { // queryObject(graph: &KnowledgeGraph, subject: []const u8, predicate: []const u8) -> ?*Entity // Query: find object entity for given subject and predicate - // Implements: unbind(graph, bind(subject, predicate)) 4 object + // Implements: unbind(graph, bind(subject, predicate)) ≈ object // Returns entity pointer or null if not found // Complexity: O(n) where n = VECTOR_DIM (VSA unbind + find) pub fn queryObject(graph: &KnowledgeGraph, subject: []const u8, predicate: []const u8) -> ?*Entity; // querySubject(graph: &KnowledgeGraph, predicate: []const u8, object: []const u8) -> ?*Entity // Query: find subject entity for given predicate and object - // Implements: unbind(graph, bind(predicate, object)) 5 subject + // Implements: unbind(graph, bind(predicate, object)) ≈ subject // Returns entity pointer or null if not found // Complexity: O(n) where n = VECTOR_DIM (VSA unbind + find) pub fn querySubject(graph: &KnowledgeGraph, predicate: []const u8, object: []const u8) -> ?*Entity; diff --git a/specs/hslm/forward_pass.t27 b/specs/hslm/forward_pass.t27 index e68ce8fd33..c358d8047c 100644 --- a/specs/hslm/forward_pass.t27 +++ b/specs/hslm/forward_pass.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Module: Minimal Forward Pass for LLM Inference -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ForwardPass { // ======================================================================== diff --git a/specs/interop/gf_cross_language.t27 b/specs/interop/gf_cross_language.t27 index 31ee7ccd84..0737a952f3 100644 --- a/specs/interop/gf_cross_language.t27 +++ b/specs/interop/gf_cross_language.t27 @@ -1,23 +1,23 @@ // SPDX-License-Identifier: Apache-2.0 // GoldenFloat Cross-Language Conformance // All languages must produce identical bits for identical inputs. -// Reference constant: GF32(0) = 0x3FCF1BBD +// Reference constant: GF32(φ) = 0x3FCF1BBD module GFCrossLanguageConformance { import math::constants; import ffi::gf16::*; import ffi::gf32::*; - // 12 Test 1: 3 encoding 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 + // ── Test 1: φ encoding ────────────────────────────────────────────────── test phi_gf32_bits { const phi = 1.618033988749895_f64; const gf32_bits = gf32_from_f64(phi); - // 54 in GF32 (approximately IEEE f32 bits since GF32 maps to f32) + // φ in GF32 (approximately IEEE f32 bits since GF32 maps to f32) const expected = 0x3FCF1BBD_u32; then gf32_bits == expected } - // 5556 Test 2: Sign extraction 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 + // ── Test 2: Sign extraction ───────────────────────────────────────────── test phi_ffi_encoding { const phi = constants::PHI; const gf16_phi = gf16_from_f64(phi); @@ -28,7 +28,7 @@ module GFCrossLanguageConformance { and gf32_extract_exponent(gf32_phi) > 0 } - // 102103 Test 3: Roundtrip precision 104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 + // ── Test 3: Roundtrip precision ───────────────────────────────────────── test roundtrip_gf16_precision { const test_vals = [1.618, 3.14159, 2.71828, 1.0, -1.0, 0.5]; for val in test_vals { @@ -38,7 +38,7 @@ module GFCrossLanguageConformance { } } - // 145146 Test 4: Classification 147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 + // ── Test 4: Classification ────────────────────────────────────────────── test classification_functions { const zero = gf16_from_f64(0.0); const inf = gf16_from_f64(1e38_f64); @@ -49,7 +49,7 @@ module GFCrossLanguageConformance { and gf16_is_nan(zero) == false } - // 193194 Test 5: Arithmetic 195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 + // ── Test 5: Arithmetic ────────────────────────────────────────────────── test gf16_addition { const a = gf16_from_f64(1.0); const b = gf16_from_f64(0.618); @@ -58,8 +58,8 @@ module GFCrossLanguageConformance { then abs(result - 1.618) < 0.01 } - // 245246 Test 6: FPGA-Safety contract 247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 - // All encode/decode must work on u16/u32 only 287 no f64 in compute + // ── Test 6: FPGA-Safety contract ──────────────────────────────────────── + // All encode/decode must work on u16/u32 only — no f64 in compute test zero_roundtrip { const zero_enc = gf16_from_f64(0.0); const zero_dec = gf16_to_f64(zero_enc); @@ -67,7 +67,7 @@ module GFCrossLanguageConformance { and gf16_is_zero(zero_enc) == true } - // 288289 Test 7: Mantissa extraction consistency 290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 + // ── Test 7: Mantissa extraction consistency ────────────────────────────── test mantissa_extraction { const phi_gf16 = gf16_from_f64(1.618); const phi_gf32 = gf32_from_f64(1.618); @@ -80,7 +80,7 @@ module GFCrossLanguageConformance { and mant32 != 0 } - // 320321 Test 8: Special values roundtrip 322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 + // ── Test 8: Special values roundtrip ───────────────────────────────────── test special_values_roundtrip { // Zero const zero_enc = gf16_from_f64(0.0); diff --git a/specs/isa/registers.t27 b/specs/isa/registers.t27 index a785927cb5..4832be169b 100644 --- a/specs/isa/registers.t27 +++ b/specs/isa/registers.t27 @@ -2,15 +2,15 @@ // t27/specs/isa/registers.t27 // TRI27 ISA Register File Specification // Register definitions, Coptic encoding, and register file operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ISARegisters { // Import base types use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 + // ═════════════════════════════════════════════════════════════════ // 1. Register Constants - // 69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 + // ═════════════════════════════════════════════════════════════════════════ // Register file configuration (Coptic compatibility: 27 registers) const NUM_REGISTERS : usize = 27; // R0-R26 @@ -57,55 +57,55 @@ module ISARegisters { const FLAG_TRAP : u8 = 4; // Trap flag const FLAG_INTERRUPT : u8 = 5; // Interrupt enable - // 142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 + // ═════════════════════════════════════════════════════════════════ // 2. Coptic Alphabet Encoding - // 207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════════ // Coptic alphabet encoding (27 letters for 27 registers) // Maps register numbers to Coptic Unicode code points const COPTIC_ALPHABET : [27]u32 = [ - 0x03B1, // 280 = alpha (R0) - 0x03B2, // 281 = bita (R1) - 0x03B3, // 282 = gamma (R2) - 0x03B4, // 283 = dalda (R3) - 0x03B5, // 284 = ei (R4) - 0x03C6, // 285 = sima (R5) - 0x03B6, // 286 = zata (R6) - 0x03B7, // 287 = ita (R7) - 0x03B8, // 288 = thita (R8) - 0x03B9, // 289 = iota (R9) - 0x03BA, // 290 = kappa (R10) - 0x03BB, // 291 = lauda (R11) - 0x03BC, // 292 = mi (R12) - 0x03BD, // 293 = ni (R13) - 0x03BE, // 294 = ksi (R14) - 0x03C0, // 295 = pi (R15) - 0x03C1, // 296 = ro (R16) - 0x03C3, // 297 = sigma (R17) - 0x03C4, // 298 = tau (R18) - 0x03C5, // 299 = upsilon (R19) - 0x03C6, // 300 = fi (R20) - 0x03C7, // 301 = khi (R21) - 0x03C8, // 302 = psi (R22) - 0x03C9, // 303 = ou (R23) - 0x0417, // 304 = sampi (R24) - 0x0418, // 305 = koppa (R25) - 0x0419, // 306 = 307hei (R26) + 0x03B1, // α = alpha (R0) + 0x03B2, // β = bita (R1) + 0x03B3, // γ = gamma (R2) + 0x03B4, // δ = dalda (R3) + 0x03B5, // ε = ei (R4) + 0x03C6, // ϕ = sima (R5) + 0x03B6, // ζ = zata (R6) + 0x03B7, // η = ita (R7) + 0x03B8, // θ = thita (R8) + 0x03B9, // ι = iota (R9) + 0x03BA, // κ = kappa (R10) + 0x03BB, // λ = lauda (R11) + 0x03BC, // μ = mi (R12) + 0x03BD, // ν = ni (R13) + 0x03BE, // ξ = ksi (R14) + 0x03C0, // π = pi (R15) + 0x03C1, // ρ = ro (R16) + 0x03C3, // σ = sigma (R17) + 0x03C4, // τ = tau (R18) + 0x03C5, // υ = upsilon (R19) + 0x03C6, // φ = fi (R20) + 0x03C7, // χ = khi (R21) + 0x03C8, // ψ = psi (R22) + 0x03C9, // ω = ou (R23) + 0x0417, // ϗ = sampi (R24) + 0x0418, // Ϙ = koppa (R25) + 0x0419, // ϙ = šhei (R26) ]; - // 308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 + // ═════════════════════════════════════════════════════════════════ // 3. Register File State - // 373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 + // ═════════════════════════════════════════════════════════════════════════ // Register file: 27 registers, each holding a TernaryWord (27 trits) // Stored as u32 for efficiency (27 trits fits in 32 bits) var register_file : [NUM_REGISTERS]TernaryWord = [TernaryWord{.raw = 0}; NUM_REGISTERS]; - // 446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 + // ═════════════════════════════════════════════════════════════════ // 4. Register Read/Write - // 511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 + // ═════════════════════════════════════════════════════════════════════════ - // reg_read(reg: u8) 584 TernaryWord + // reg_read(reg: u8) → TernaryWord // Read from register file // R0 always returns 0 (zero register) // Returns error sentinel if register number is invalid @@ -124,7 +124,7 @@ module ISARegisters { return register_file[reg]; } - // reg_write(reg: u8, value: TernaryWord) 585 bool + // reg_write(reg: u8, value: TernaryWord) → bool // Write to register file // R0 writes are ignored (zero register is read-only) // Returns true if write succeeded, false if invalid register @@ -143,11 +143,11 @@ module ISARegisters { return true; } - // 586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 + // ═════════════════════════════════════════════════════════════════ // 5. Coptic Encoding Conversion - // 651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723 + // ═════════════════════════════════════════════════════════════════════════ - // reg_to_coptic(reg: u8) 724 u32 + // reg_to_coptic(reg: u8) → u32 // Convert register number to Coptic Unicode code point // Returns 0 if register number is invalid fn reg_to_coptic(reg: u8) -> u32 { @@ -157,7 +157,7 @@ module ISARegisters { return COPTIC_ALPHABET[reg]; } - // coptic_to_reg(cp: u32) 725 u8 + // coptic_to_reg(cp: u32) → u8 // Convert Coptic Unicode code point to register number // Returns 0xFF if not a valid register character fn coptic_to_reg(cp: u32) -> u8 { @@ -173,11 +173,11 @@ module ISARegisters { return 0xFF; // Error sentinel } - // 726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790 + // ═════════════════════════════════════════════════════════════════ // 6. Status Register Operations - // 791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863 + // ═════════════════════════════════════════════════════════════════════════ - // status_read(flag: u8) 864 bool + // status_read(flag: u8) → bool // Read a specific flag from status register (R20) // Returns true if flag is set, false otherwise fn status_read(flag: u8) -> bool { @@ -186,7 +186,7 @@ module ISARegisters { return (status_val.raw & mask) != 0; } - // status_write(flag: u8, value: bool) 865 bool + // status_write(flag: u8, value: bool) → bool // Set or clear a specific flag in status register (R20) // Returns true if operation succeeded fn status_write(flag: u8, value: bool) -> bool { @@ -206,11 +206,11 @@ module ISARegisters { return reg_write(R20, status_val); } - // 866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930 + // ═════════════════════════════════════════════════════════════════ // 7. Stack Operations (using R17 as stack pointer) - // 9319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 + // ═════════════════════════════════════════════════════════════════════════ - // push_reg(reg: u8) 1004 bool + // push_reg(reg: u8) → bool // Push register value to stack (using R17 as stack pointer) // Stack grows downward (decrement before store) // Returns true if push succeeded @@ -237,7 +237,7 @@ module ISARegisters { return true; } - // pop_reg(reg: u8) 1005 bool + // pop_reg(reg: u8) → bool // Pop value from stack into register (using R17 as stack pointer) // Stack grows downward (load then increment) // Returns true if pop succeeded @@ -261,11 +261,11 @@ module ISARegisters { return reg_write(reg, value); } - // 10061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070 + // ═════════════════════════════════════════════════════════════════ // 8. Context Save/Restore - // 1071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143 + // ═════════════════════════════════════════════════════════════════════════ - // save_context() 1144 void + // save_context() → void // Save caller-saved registers (R5-R9) to stack // Used by function prologue fn save_context() -> void { @@ -276,7 +276,7 @@ module ISARegisters { push_reg(R9); } - // restore_context() 1145 void + // restore_context() → void // Restore caller-saved registers from stack // Used by function epilogue fn restore_context() -> void { @@ -287,9 +287,9 @@ module ISARegisters { pop_reg(R5); } - // 11461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210 + // ═════════════════════════════════════════════════════════════════ // 9. Register Aliases - // 1211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283 + // ═════════════════════════════════════════════════════════════════════════ // Argument/return registers const ARG0 : u8 = R1; @@ -322,9 +322,9 @@ module ISARegisters { const KSP : u8 = R22; // Kernel stack pointer const TP : u8 = R23; // Thread pointer - // 1284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for ISARegisters - // 1387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test isa_r0_always_zero given word = TernaryWord{.raw = 0x123456} @@ -364,22 +364,22 @@ module ISARegisters { test isa_reg_to_coptic_r0 given cp = reg_to_coptic(R0) - then cp == 0x03B1 // 1490 + then cp == 0x03B1 // α test isa_reg_to_coptic_r10 given cp = reg_to_coptic(R10) - then cp == 0x03BA // 1491 + then cp == 0x03BA // κ test isa_reg_to_coptic_r26 given cp = reg_to_coptic(R26) - then cp == 0x0419 // 1492 + then cp == 0x0419 // ϙ test isa_coptic_to_reg_alpha - given reg = coptic_to_reg(0x03B1) // 1493 + given reg = coptic_to_reg(0x03B1) // α then reg == R0 test isa_coptic_to_reg_kappa - given reg = coptic_to_reg(0x03BA) // 1494 + given reg = coptic_to_reg(0x03BA) // κ then reg == R10 test isa_coptic_to_reg_invalid @@ -491,9 +491,9 @@ module ISARegisters { invariant isa_max_register_is_26 assert R26 == NUM_REGISTERS - 1 - // 14951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559 + // ═════════════════════════════════════════════════════════════════ // Ring 045: Agent Binding and Trit State Invariants - // 1560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632 + // ═════════════════════════════════════════════════════════════════════════ // agent_register_bijection: Each agent maps to exactly one register invariant agent_register_bijection @@ -519,10 +519,10 @@ module ISARegisters { assert result.raw == value.raw // queen_register_special: T (Queen) register = register index 0 (Tau/Alpha) - // The Queen register is R0 (Alpha/1633), the first Coptic letter + // The Queen register is R0 (Alpha/α), the first Coptic letter invariant queen_register_special assert R0 == 0 - assert reg_to_coptic(R0) == 0x03B1 // 1634 (Alpha, representing Queen/Tau) + assert reg_to_coptic(R0) == 0x03B1 // α (Alpha, representing Queen/Tau) // register_initial_zero: All registers initialize to 0 invariant register_initial_zero @@ -550,7 +550,7 @@ module ISARegisters { // T (Queen) register = register index 0 (Tau/Alpha) given queen_idx = R0 and queen_cp = reg_to_coptic(queen_idx) - then queen_idx == 0 and queen_cp == 0x03B1 // 1635 + then queen_idx == 0 and queen_cp == 0x03B1 // α test agent_count_equals_register_count given agents = AGENT_COUNT @@ -578,7 +578,7 @@ module ISARegisters { target: < 20ns bench isa_coptic_to_reg_latency - measure: nanoseconds to coptic_to_reg(0x03C0) // 1636 + measure: nanoseconds to coptic_to_reg(0x03C0) // π target: < 100ns bench isa_status_read_latency diff --git a/specs/isa/ternary_arithmetic.t27 b/specs/isa/ternary_arithmetic.t27 index 74dace91a6..df56491f22 100644 --- a/specs/isa/ternary_arithmetic.t27 +++ b/specs/isa/ternary_arithmetic.t27 @@ -3,14 +3,14 @@ // Ternary Arithmetic Operations Specification // Ring 064 - Balanced ternary arithmetic for T27 // Defines addition, subtraction, multiplication, and division -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryArithmetic { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Ternary Values and Constants - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Balanced ternary values const TRIT_NEG : i32 = -1; // Negative @@ -24,15 +24,15 @@ module TernaryArithmetic { // Number of trits in a word (configurable) const TRITS_PER_WORD : usize = 27; // 3^27 states (~7.6 trillion) - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Single Trit Addition - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ - // trit_add(a: i32, b: i32, carry_in: i32) 256 TritAddResult + // trit_add(a: i32, b: i32, carry_in: i32) → TritAddResult // Add two trits with carry in, return sum and carry out // Balanced ternary: -1, 0, 1 // Result can be -2, -1, 0, 1, 2 (needs carry) - fn trit_add(a: i32, b: i32, carry_in: i32) 257 TritAddResult { + fn trit_add(a: i32, b: i32, carry_in: i32) → TritAddResult { var sum = a + b + carry_in; // Normalize balanced ternary @@ -59,13 +59,13 @@ module TernaryArithmetic { carry_out : i32, } - // 258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 + // ═════════════════════════════════════════════════════ // 3. Single Trit Subtraction - // 311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 + // ═════════════════════════════════════════════════════════════════════════ - // trit_sub(a: i32, b: i32, borrow_in: i32) 384 TritSubResult + // trit_sub(a: i32, b: i32, borrow_in: i32) → TritSubResult // Subtract b from a with borrow in - fn trit_sub(a: i32, b: i32, borrow_in: i32) 385 TritSubResult { + fn trit_sub(a: i32, b: i32, borrow_in: i32) → TritSubResult { // Subtraction = addition with negated subtrahend const neg_b = -b; const result = trit_add(a, neg_b, borrow_in); @@ -82,24 +82,24 @@ module TernaryArithmetic { borrow_out : i32, } - // 386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 + // ═════════════════════════════════════════════════════ // 4. Single Trit Multiplication - // 439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 + // ═════════════════════════════════════════════════════════════════════════ - // trit_mul(a: i32, b: i32) 512 i32 + // trit_mul(a: i32, b: i32) → i32 // Multiply two trits // Result: -1, 0, or 1 (no carry needed for single trit) - fn trit_mul(a: i32, b: i32) 513 i32 { + fn trit_mul(a: i32, b: i32) → i32 { return a * b; } - // 514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 + // ═════════════════════════════════════════════════════ // 5. Word-Level Addition - // 567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_word_add(a: []i32, b: []i32, len: usize) 640 WordAddResult + // ternary_word_add(a: []i32, b: []i32, len: usize) → WordAddResult // Add two ternary words with carry propagation - fn ternary_word_add(a: []i32, b: []i32, len: usize) 641 WordAddResult { + fn ternary_word_add(a: []i32, b: []i32, len: usize) → WordAddResult { var result : WordAddResult = undefined; var carry : i32 = 0; var i : usize = 0; @@ -123,13 +123,13 @@ module TernaryArithmetic { overflow : bool, } - // 642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 + // ═════════════════════════════════════════════════════ // 6. Word-Level Subtraction - // 695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_word_sub(a: []i32, b: []i32, len: usize) 768 WordSubResult + // ternary_word_sub(a: []i32, b: []i32, len: usize) → WordSubResult // Subtract b from a with borrow propagation - fn ternary_word_sub(a: []i32, b: []i32, len: usize) 769 WordSubResult { + fn ternary_word_sub(a: []i32, b: []i32, len: usize) → WordSubResult { var result : WordSubResult = undefined; var borrow : i32 = 0; var i : usize = 0; @@ -153,13 +153,13 @@ module TernaryArithmetic { underflow : bool, } - // 770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822 + // ═════════════════════════════════════════════════════ // 7. Ternary to Decimal Conversion - // 823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_to_decimal(trits: []i32, len: usize) 896 i64 + // ternary_to_decimal(trits: []i32, len: usize) → i64 // Convert balanced ternary to decimal integer - fn ternary_to_decimal(trits: []i32, len: usize) 897 i64 { + fn ternary_to_decimal(trits: []i32, len: usize) → i64 { var result : i64 = 0; var power : i64 = 1; var i : usize = 0; @@ -173,10 +173,10 @@ module TernaryArithmetic { return result; } - // decimal_to_ternary(value: i64, trits: []i32, len: usize) 898 usize + // decimal_to_ternary(value: i64, trits: []i32, len: usize) → usize // Convert decimal integer to balanced ternary // Returns number of trits used - fn decimal_to_ternary(value: i64, trits: []i32, len: usize) 899 usize { + fn decimal_to_ternary(value: i64, trits: []i32, len: usize) → usize { var val = value; var i : usize = 0; @@ -212,19 +212,19 @@ module TernaryArithmetic { return actual_len; } - // 900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952 + // ═════════════════════════════════════════════════════ // 8. Validation Functions - // 95395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025 + // ═════════════════════════════════════════════════════════════════════════ - // is_valid_trit(t: i32) 1026 bool + // is_valid_trit(t: i32) → bool // Check if a value is a valid trit - fn is_valid_trit(t: i32) 1027 bool { + fn is_valid_trit(t: i32) → bool { return t >= MIN_TRIT and t <= MAX_TRIT; } - // validate_trits(trits: []i32, len: usize) 1028 bool + // validate_trits(trits: []i32, len: usize) → bool // Validate all trits in an array - fn validate_trits(trits: []i32, len: usize) 1029 bool { + fn validate_trits(trits: []i32, len: usize) → bool { var i : usize = 0; while (i < len) { if (!is_valid_trit(trits[i])) { @@ -235,14 +235,14 @@ module TernaryArithmetic { return true; } - // 10301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082 + // ═════════════════════════════════════════════════════ // 9. Comparison Operations - // 1083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_compare(a: []i32, b: []i32, len: usize) 1156 i32 + // ternary_compare(a: []i32, b: []i32, len: usize) → i32 // Compare two ternary words // Returns -1 if a < b, 0 if a == b, 1 if a > b - fn ternary_compare(a: []i32, b: []i32, len: usize) 1157 i32 { + fn ternary_compare(a: []i32, b: []i32, len: usize) → i32 { // Compare from most significant trit var i : i64 = @as(i64, @intCast(len)) - 1; @@ -261,9 +261,9 @@ module TernaryArithmetic { return 0; } - // 11581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210 + // ═════════════════════════════════════════════════════ // 10. TDD - Tests - // 1211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283 + // ═════════════════════════════════════════════════════════════════════════ test trit_add_basic // 1 + 1 = 2 -> -1 with carry +1 (balanced ternary: 2 = -1 + 3) @@ -359,9 +359,9 @@ module TernaryArithmetic { assert ternary_compare(&b, &a, 3) == -1 assert ternary_compare(&a, &a, 3) == 0 - // 12841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336 + // ═════════════════════════════════════════════════════ // 11. TDD - Invariants - // 1337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409 + // ═════════════════════════════════════════════════════════════════════════ invariant trit_add_commutative // Trit addition is commutative @@ -447,9 +447,9 @@ module TernaryArithmetic { i = i + 1; } - // 14101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462 + // ═════════════════════════════════════════════════════ // 12. TDD - Benchmarks - // 1463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535 + // ═════════════════════════════════════════════════════════════════════════ bench trit_add_performance // Measure: cycles to compute 1000 trit additions diff --git a/specs/isa/ternary_bitwise.t27 b/specs/isa/ternary_bitwise.t27 index 2469c299f0..66a891da52 100644 --- a/specs/isa/ternary_bitwise.t27 +++ b/specs/isa/ternary_bitwise.t27 @@ -3,14 +3,14 @@ // Ternary Bitwise Operations Specification // Ring 068 - Bitwise AND, OR, XOR for ternary data // Defines bitwise operations on ternary word representations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryBitwise { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Bitwise Constants - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Trit values const TRIT_NEG : i32 = -1; @@ -20,13 +20,13 @@ module TernaryBitwise { // Word size const WORD_SIZE : usize = 27; - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Tritwise AND - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_and(a: []i32, b: []i32, result: []i32, len: usize) 256 void + // tritwise_and(a: []i32, b: []i32, result: []i32, len: usize) → void // Tritwise AND operation (acts as MIN in balanced ternary) - fn tritwise_and(a: []i32, b: []i32, result: []i32, len: usize) 257 void { + fn tritwise_and(a: []i32, b: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { // AND is essentially MIN for balanced ternary @@ -39,13 +39,13 @@ module TernaryBitwise { } } - // 258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 + // ═════════════════════════════════════════════════════ // 3. Tritwise OR - // 311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_or(a: []i32, b: []i32, result: []i32, len: usize) 384 void + // tritwise_or(a: []i32, b: []i32, result: []i32, len: usize) → void // Tritwise OR operation (acts as MAX in balanced ternary) - fn tritwise_or(a: []i32, b: []i32, result: []i32, len: usize) 385 void { + fn tritwise_or(a: []i32, b: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { // OR is essentially MAX for balanced ternary @@ -58,14 +58,14 @@ module TernaryBitwise { } } - // 386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 + // ═════════════════════════════════════════════════════ // 4. Tritwise XOR - // 439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_xor(a: []i32, b: []i32, result: []i32, len: usize) 512 void + // tritwise_xor(a: []i32, b: []i32, result: []i32, len: usize) → void // Tritwise XOR (exclusive OR) operation // Returns TRIT_ZERO if inputs are same, otherwise indicates difference - fn tritwise_xor(a: []i32, b: []i32, result: []i32, len: usize) 513 void { + fn tritwise_xor(a: []i32, b: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { if (a[i] == b[i]) { @@ -82,13 +82,13 @@ module TernaryBitwise { } } - // 514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 + // ═════════════════════════════════════════════════════ // 5. Tritwise NOT - // 567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_not(word: []i32, result: []i32, len: usize) 640 void + // tritwise_not(word: []i32, result: []i32, len: usize) → void // Tritwise NOT (inversion) operation - fn tritwise_not(word: []i32, result: []i32, len: usize) 641 void { + fn tritwise_not(word: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { result[i] = -word[i]; @@ -96,37 +96,37 @@ module TernaryBitwise { } } - // 642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 + // ═════════════════════════════════════════════════════ // 6. Tritwise NAND - // 695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_nand(a: []i32, b: []i32, result: []i32, len: usize) 768 void + // tritwise_nand(a: []i32, b: []i32, result: []i32, len: usize) → void // Tritwise NAND (NOT AND) operation - fn tritwise_nand(a: []i32, b: []i32, result: []i32, len: usize) 769 void { + fn tritwise_nand(a: []i32, b: []i32, result: []i32, len: usize) → void { var temp : [WORD_SIZE]i32 = undefined; tritwise_and(a, b, temp, len); tritwise_not(temp, result, len); } - // 770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822 + // ═════════════════════════════════════════════════════ // 7. Tritwise NOR - // 823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_nor(a: []i32, b: []i32, result: []i32, len: usize) 896 void + // tritwise_nor(a: []i32, b: []i32, result: []i32, len: usize) → void // Tritwise NOR (NOT OR) operation - fn tritwise_nor(a: []i32, b: []i32, result: []i32, len: usize) 897 void { + fn tritwise_nor(a: []i32, b: []i32, result: []i32, len: usize) → void { var temp : [WORD_SIZE]i32 = undefined; tritwise_or(a, b, temp, len); tritwise_not(temp, result, len); } - // 898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950 + // ═════════════════════════════════════════════════════ // 8. Tritwise XNOR - // 951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_xnor(a: []i32, b: []i32, result: []i32, len: usize) 1024 void + // tritwise_xnor(a: []i32, b: []i32, result: []i32, len: usize) → void // Tritwise XNOR (exclusive NOR) - equality test - fn tritwise_xnor(a: []i32, b: []i32, result: []i32, len: usize) 1025 void { + fn tritwise_xnor(a: []i32, b: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { if (a[i] == b[i]) { @@ -138,13 +138,13 @@ module TernaryBitwise { } } - // 10261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078 + // ═════════════════════════════════════════════════════ // 9. Mask Operations - // 1079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151 + // ═════════════════════════════════════════════════════════════════════════ - // tritwise_mask(word: []i32, mask: []i32, result: []i32, len: usize) 1152 void + // tritwise_mask(word: []i32, mask: []i32, result: []i32, len: usize) → void // Apply mask: keep trits where mask is POS, zero elsewhere - fn tritwise_mask(word: []i32, mask: []i32, result: []i32, len: usize) 1153 void { + fn tritwise_mask(word: []i32, mask: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { if (mask[i] == TRIT_POS) { @@ -156,9 +156,9 @@ module TernaryBitwise { } } - // tritwise_merge(a: []i32, b: []i32, mask: []i32, result: []i32, len: usize) 1154 void + // tritwise_merge(a: []i32, b: []i32, mask: []i32, result: []i32, len: usize) → void // Merge based on mask: take from a where mask is POS, from b otherwise - fn tritwise_merge(a: []i32, b: []i32, mask: []i32, result: []i32, len: usize) 1155 void { + fn tritwise_merge(a: []i32, b: []i32, mask: []i32, result: []i32, len: usize) → void { var i : usize = 0; while (i < len) { if (mask[i] == TRIT_POS) { @@ -170,9 +170,9 @@ module TernaryBitwise { } } - // 11561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208 + // ═════════════════════════════════════════════════════ // 10. TDD - Tests - // 1209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 + // ═════════════════════════════════════════════════════════════════════════ test tritwise_and_basic var a : [3]i32 = [_]i32{TRIT_POS, TRIT_ZERO, TRIT_NEG}; @@ -264,9 +264,9 @@ module TernaryBitwise { assert result[1] == TRIT_POS assert result[2] == TRIT_POS - // 12821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334 + // ═════════════════════════════════════════════════════ // 11. TDD - Invariants - // 1335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407 + // ═════════════════════════════════════════════════════════════════════════ invariant tritwise_and_commutative // Tritwise AND is commutative @@ -343,9 +343,9 @@ module TernaryBitwise { i = i + 1; } - // 14081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460 + // ═════════════════════════════════════════════════════ // 12. TDD - Benchmarks - // 1461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533 + // ═════════════════════════════════════════════════════════════════════════ bench tritwise_and_performance // Measure: cycles to compute 1000 tritwise AND operations diff --git a/specs/isa/ternary_control_flow.t27 b/specs/isa/ternary_control_flow.t27 index ce82fe3e98..9efe86f2e5 100644 --- a/specs/isa/ternary_control_flow.t27 +++ b/specs/isa/ternary_control_flow.t27 @@ -3,14 +3,14 @@ // Ternary Control Flow Specification // Ring 090 - Control flow operations for ternary architecture // Conditional jumps, branches, and call/return -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryControlFlow { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 + // ═════════════════════════════════════════════════════════════════ // 1. Branch Conditions - // 69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 + // ═════════════════════════════════════════════════════════════════════════ // Trit values for condition evaluation const TRIT_NEG : i32 = -1; @@ -30,9 +30,9 @@ module TernaryControlFlow { const PRED_NOT_TAKEN : u8 = 1; // Likely not taken const PRED_NONE : u8 = 2; // No prediction - // 142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 + // ═════════════════════════════════════════════════════════════════ // 2. Program Counter Operations - // 207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════════ // pc_read() -> u32 // Read current program counter @@ -54,9 +54,9 @@ module TernaryControlFlow { return (current_pc as i32 + offset) as u32; } - // 280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 + // ═════════════════════════════════════════════════════════════════ // 3. Conditional Branch Operations - // 345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════════ // branch_cond(value: i32, condition: u8, offset: i32) -> bool // Branch if condition matches value @@ -98,9 +98,9 @@ module TernaryControlFlow { return branch_cond(value, COND_EQ, offset); } - // 418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 + // ═════════════════════════════════════════════════════════════════ // 4. Unconditional Branch Operations - // 483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 + // ═════════════════════════════════════════════════════════════════════════ // jump(addr: u32) -> void // Unconditional jump to absolute address @@ -128,9 +128,9 @@ module TernaryControlFlow { jump_relative(offset); } - // 556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 + // ═════════════════════════════════════════════════════════════════ // 5. Return Operation - // 621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 + // ═════════════════════════════════════════════════════════════════════════ // ret(link_reg: u32) -> void // Return to address in link register @@ -138,9 +138,9 @@ module TernaryControlFlow { pc_write(link_reg); } - // 694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 + // ═════════════════════════════════════════════════════════════════ // 6. Call/Return with Stack - // 759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831 + // ═════════════════════════════════════════════════════════════════════════ // call(addr: u32, sp: *u32, memory: []TernaryWord) -> bool // Call subroutine: push return address, then jump @@ -178,9 +178,9 @@ module TernaryControlFlow { return true; } - // 832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896 + // ═════════════════════════════════════════════════════════════════ // 7. Compare Operations - // 897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969 + // ═════════════════════════════════════════════════════════════════════════ // compare(a: i32, b: i32) -> i32 // Compare two trit values, return condition code @@ -202,9 +202,9 @@ module TernaryControlFlow { return branch_cond(result, condition, offset); } - // 97097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034 + // ═════════════════════════════════════════════════════════════════ // 8. Table Branch (Switch) - // 1035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107 + // ═════════════════════════════════════════════════════════════════════════ // table_branch(index: i32, jump_table: []u32, default_addr: u32) -> void // Jump to address in jump_table[index], or default if out of range @@ -216,9 +216,9 @@ module TernaryControlFlow { } } - // 11081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172 + // ═════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants - // 1173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245 + // ═════════════════════════════════════════════════════════════════════════ test branch_if_taken given offset = 10 diff --git a/specs/isa/ternary_deque.t27 b/specs/isa/ternary_deque.t27 index 9db941c9d3..dda39f6e78 100644 --- a/specs/isa/ternary_deque.t27 +++ b/specs/isa/ternary_deque.t27 @@ -3,14 +3,14 @@ // Ternary Deque Operations Specification // Ring 088 - Double-ended queue operations for ternary data // Defines deque with push/pop from both ends -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryDeque { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Deque Constants - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Trit values const TRIT_NEG : i32 = -1; @@ -20,13 +20,13 @@ module TernaryDeque { // Deque limits const DEQUE_MAX_SIZE : usize = 27; - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Deque Structure (Circular Buffer) - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ - // deque_init(data: []i32, front: *usize, back: *usize, count: *usize) 256 void + // deque_init(data: []i32, front: *usize, back: *usize, count: *usize) → void // Initialize empty deque - fn deque_init(data: []i32, front: *usize, back: *usize, count: *usize) 257 void { + fn deque_init(data: []i32, front: *usize, back: *usize, count: *usize) → void { var i : usize = 0; while (i < DEQUE_MAX_SIZE and i < data.len) { data[i] = TRIT_ZERO; @@ -37,9 +37,9 @@ module TernaryDeque { count.* = 0; } - // deque_push_front(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) 258 bool + // deque_push_front(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) → bool // Add element to front of deque - fn deque_push_front(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) 259 bool { + fn deque_push_front(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) → bool { if (count.* >= DEQUE_MAX_SIZE) { return false; } @@ -59,9 +59,9 @@ module TernaryDeque { return true; } - // deque_push_back(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) 260 bool + // deque_push_back(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) → bool // Add element to back of deque - fn deque_push_back(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) 261 bool { + fn deque_push_back(data: []i32, front: *usize, back: *usize, count: *usize, value: i32) → bool { if (count.* >= DEQUE_MAX_SIZE) { return false; } @@ -78,9 +78,9 @@ module TernaryDeque { return true; } - // deque_pop_front(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) 262 bool + // deque_pop_front(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) → bool // Remove element from front of deque - fn deque_pop_front(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) 263 bool { + fn deque_pop_front(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) → bool { if (count.* == 0) { return false; } @@ -97,9 +97,9 @@ module TernaryDeque { return true; } - // deque_pop_back(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) 264 bool + // deque_pop_back(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) → bool // Remove element from back of deque - fn deque_pop_back(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) 265 bool { + fn deque_pop_back(data: []i32, front: *usize, back: *usize, count: *usize, value: *i32) → bool { if (count.* == 0) { return false; } @@ -117,9 +117,9 @@ module TernaryDeque { return true; } - // deque_peek_front(data: []i32, front: *usize, count: usize, value: *i32) 266 bool + // deque_peek_front(data: []i32, front: *usize, count: usize, value: *i32) → bool // Look at element at front without removing - fn deque_peek_front(data: []i32, front: *usize, count: usize, value: *i32) 267 bool { + fn deque_peek_front(data: []i32, front: *usize, count: usize, value: *i32) → bool { if (count == 0) { return false; } @@ -129,9 +129,9 @@ module TernaryDeque { return true; } - // deque_peek_back(data: []i32, back: *usize, count: usize, value: *i32) 268 bool + // deque_peek_back(data: []i32, back: *usize, count: usize, value: *i32) → bool // Look at element at back without removing - fn deque_peek_back(data: []i32, back: *usize, count: usize, value: *i32) 269 bool { + fn deque_peek_back(data: []i32, back: *usize, count: usize, value: *i32) → bool { if (count == 0) { return false; } @@ -147,27 +147,27 @@ module TernaryDeque { return true; } - // deque_is_empty(count: usize) 270 bool + // deque_is_empty(count: usize) → bool // Check if deque is empty - fn deque_is_empty(count: usize) 271 bool { + fn deque_is_empty(count: usize) → bool { return count == 0; } - // deque_is_full(count: usize) 272 bool + // deque_is_full(count: usize) → bool // Check if deque is full - fn deque_is_full(count: usize) 273 bool { + fn deque_is_full(count: usize) → bool { return count >= DEQUE_MAX_SIZE; } - // deque_size(count: usize) 274 usize + // deque_size(count: usize) → usize // Get number of elements in deque - fn deque_size(count: usize) 275 usize { + fn deque_size(count: usize) → usize { return count; } - // deque_clear(data: []i32, front: *usize, back: *usize, count: *usize) 276 void + // deque_clear(data: []i32, front: *usize, back: *usize, count: *usize) → void // Clear all elements from deque - fn deque_clear(data: []i32, front: *usize, back: *usize, count: *usize) 277 void { + fn deque_clear(data: []i32, front: *usize, back: *usize, count: *usize) → void { var i : usize = 0; while (i < DEQUE_MAX_SIZE and i < data.len) { data[i] = TRIT_ZERO; @@ -178,9 +178,9 @@ module TernaryDeque { count.* = 0; } - // 278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 + // ═════════════════════════════════════════════════════ // 3. TDD - Tests - // 331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 + // ═════════════════════════════════════════════════════════════════════════ test deque_init_empty var data : [10]i32 = undefined; @@ -299,9 +299,9 @@ module TernaryDeque { assert deque_is_empty(count) - // 404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 + // ═════════════════════════════════════════════════════ // 4. TDD - Invariants - // 457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529 + // ═════════════════════════════════════════════════════════════════════════ invariant deque_size_matches_operations // Size equals pushes minus pops @@ -395,9 +395,9 @@ module TernaryDeque { assert deque_size(count) == 2 - // 530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582 + // ═════════════════════════════════════════════════════ // 5. TDD - Benchmarks - // 583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655 + // ═════════════════════════════════════════════════════════════════════════ bench deque_push_back_performance // Measure: cycles for 1000 push_back operations diff --git a/specs/isa/ternary_gates.t27 b/specs/isa/ternary_gates.t27 index b6a022ac09..a3c8e92184 100644 --- a/specs/isa/ternary_gates.t27 +++ b/specs/isa/ternary_gates.t27 @@ -3,14 +3,14 @@ // Ternary Logic Gates Specification // Ring 063 - Basic ternary logic gates for balanced ternary // Defines AND, OR, NOT, and other fundamental operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryGates { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Ternary Values - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Balanced ternary values const TRIT_NEG : i32 = -1; // Negative / False @@ -20,44 +20,44 @@ module TernaryGates { // Gate delay (abstract units) const GATE_DELAY_UNIT : u64 = 1; - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. NOT Gate (Ternary Inverter) - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_not(a: i32) 256 i32 + // ternary_not(a: i32) → i32 // Ternary NOT (inverts trit value) // TRIT_NEG -> TRIT_POS, TRIT_ZERO -> TRIT_ZERO, TRIT_POS -> TRIT_NEG - fn ternary_not(a: i32) 257 i32 { + fn ternary_not(a: i32) → i32 { return -a; } - // ternary_not_with_delay(a: i32) 258 GateResult + // ternary_not_with_delay(a: i32) → GateResult // Ternary NOT with delay information - fn ternary_not_with_delay(a: i32) 259 GateResult { + fn ternary_not_with_delay(a: i32) → GateResult { return GateResult{ .output = -a, .delay = GATE_DELAY_UNIT, }; } - // 260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 + // ═════════════════════════════════════════════════════ // 3. MIN Gate (Ternary AND) - // 313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_min(a: i32, b: i32) 386 i32 + // ternary_min(a: i32, b: i32) → i32 // Ternary MIN (acts as AND in balanced ternary) // Result is the minimum of two trits - fn ternary_min(a: i32, b: i32) 387 i32 { + fn ternary_min(a: i32, b: i32) → i32 { if (a < b) { return a; } return b; } - // ternary_and(a: i32, b: i32) 388 i32 + // ternary_and(a: i32, b: i32) → i32 // Ternary AND (logical AND with three-valued logic) - // Uses Kleene/389ukasiewicz interpretation - fn ternary_and(a: i32, b: i32) 390 i32 { + // Uses Kleene/Łukasiewicz interpretation + fn ternary_and(a: i32, b: i32) → i32 { // Map to [0,1,2] for logical AND const a_mapped = a + 1; // -1->0, 0->1, 1->2 const b_mapped = b + 1; @@ -65,50 +65,50 @@ module TernaryGates { return result_mapped - 1; // Map back } - // 391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 + // ═════════════════════════════════════════════════════ // 4. MAX Gate (Ternary OR) - // 444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_max(a: i32, b: i32) 517 i32 + // ternary_max(a: i32, b: i32) → i32 // Ternary MAX (acts as OR in balanced ternary) // Result is the maximum of two trits - fn ternary_max(a: i32, b: i32) 518 i32 { + fn ternary_max(a: i32, b: i32) → i32 { if (a > b) { return a; } return b; } - // ternary_or(a: i32, b: i32) 519 i32 + // ternary_or(a: i32, b: i32) → i32 // Ternary OR (logical OR with three-valued logic) - // Uses Kleene/520ukasiewicz interpretation - fn ternary_or(a: i32, b: i32) 521 i32 { + // Uses Kleene/Łukasiewicz interpretation + fn ternary_or(a: i32, b: i32) → i32 { const a_mapped = a + 1; const b_mapped = b + 1; const result_mapped = ternary_max(a_mapped, b_mapped); return result_mapped - 1; } - // 522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574 + // ═════════════════════════════════════════════════════ // 5. Consensus Gate - // 575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_consensus(a: i32, b: i32, c: i32) 648 i32 + // ternary_consensus(a: i32, b: i32, c: i32) → i32 // Consensus gate: returns value if all equal, else TRIT_ZERO - fn ternary_consensus(a: i32, b: i32, c: i32) 649 i32 { + fn ternary_consensus(a: i32, b: i32, c: i32) → i32 { if (a == b and b == c) { return a; } return TRIT_ZERO; } - // 650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702 + // ═════════════════════════════════════════════════════ // 6. Majority Gate - // 703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_majority(a: i32, b: i32, c: i32) 776 i32 + // ternary_majority(a: i32, b: i32, c: i32) → i32 // Majority gate: returns the most common value - fn ternary_majority(a: i32, b: i32, c: i32) 777 i32 { + fn ternary_majority(a: i32, b: i32, c: i32) → i32 { // Count occurrences var neg_count : i32 = 0; var zero_count : i32 = 0; @@ -135,13 +135,13 @@ module TernaryGates { return TRIT_ZERO; } - // 778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830 + // ═════════════════════════════════════════════════════ // 7. Any Gate - // 831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_any(a: i32, b: i32, c: i32) 904 i32 + // ternary_any(a: i32, b: i32, c: i32) → i32 // Any gate: returns TRIT_POS if any input is TRIT_POS - fn ternary_any(a: i32, b: i32, c: i32) 905 i32 { + fn ternary_any(a: i32, b: i32, c: i32) → i32 { if (a == TRIT_POS or b == TRIT_POS or c == TRIT_POS) { return TRIT_POS; } @@ -151,13 +151,13 @@ module TernaryGates { return TRIT_ZERO; } - // 906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958 + // ═════════════════════════════════════════════════════ // 8. All Gate - // 95996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_all(a: i32, b: i32, c: i32) 1032 i32 + // ternary_all(a: i32, b: i32, c: i32) → i32 // All gate: returns TRIT_NEG if all inputs are TRIT_NEG - fn ternary_all(a: i32, b: i32, c: i32) 1033 i32 { + fn ternary_all(a: i32, b: i32, c: i32) → i32 { if (a == TRIT_NEG and b == TRIT_NEG and c == TRIT_NEG) { return TRIT_NEG; } @@ -167,9 +167,9 @@ module TernaryGates { return TRIT_ZERO; } - // 10341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086 + // ═════════════════════════════════════════════════════ // 9. Data Structures - // 1087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159 + // ═════════════════════════════════════════════════════════════════════════ struct GateResult { output : i32, @@ -184,9 +184,9 @@ module TernaryGates { row_count : usize, } - // 11601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212 + // ═════════════════════════════════════════════════════ // 10. TDD - Tests - // 1213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285 + // ═════════════════════════════════════════════════════════════════════════ test ternary_not_inversion assert ternary_not(TRIT_NEG) == TRIT_POS @@ -259,9 +259,9 @@ module TernaryGates { assert ternary_all(TRIT_POS, TRIT_POS, TRIT_POS) == TRIT_POS assert ternary_all(TRIT_POS, TRIT_POS, TRIT_ZERO) == TRIT_ZERO - // 12861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338 + // ═════════════════════════════════════════════════════ // 11. TDD - Invariants - // 1339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411 + // ═════════════════════════════════════════════════════════════════════════ invariant not_double_inversion // Applying NOT twice returns original value @@ -354,9 +354,9 @@ module TernaryGates { i = i + 1; } - // 14121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464 + // ═════════════════════════════════════════════════════ // 12. TDD - Benchmarks - // 1465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537 + // ═════════════════════════════════════════════════════════════════════════ bench ternary_not_performance // Measure: cycles to compute 1000 NOT operations diff --git a/specs/isa/ternary_memory.t27 b/specs/isa/ternary_memory.t27 index 50ef34d962..9f815cf6d7 100644 --- a/specs/isa/ternary_memory.t27 +++ b/specs/isa/ternary_memory.t27 @@ -3,14 +3,14 @@ // Ternary Memory Specification // Ring 089 - Memory operations for ternary architecture // Load/store operations with ternary address and data -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ISAMemoryOps { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 + // ═════════════════════════════════════════════════════════════════ // 1. Memory Constants - // 69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 + // ═════════════════════════════════════════════════════════════════════════ // Trit values for memory operations const TRIT_NEG : i32 = -1; @@ -31,9 +31,9 @@ module ISAMemoryOps { const PERM_WRITE : u8 = 0x2; // Write permission const PERM_EXEC : u8 = 0x4; // Execute permission - // 142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 + // ═════════════════════════════════════════════════════════════════ // 2. Memory Operations - // 207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════════ // mem_load(memory: []TernaryWord, addr: u32) -> TernaryWord // Load word from memory at address @@ -84,9 +84,9 @@ module ISAMemoryOps { return mem_store(memory, addr, value); } - // 280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 + // ═════════════════════════════════════════════════════════════════ // 3. Block Memory Operations - // 345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════════ // mem_load_block(memory: []TernaryWord, base_addr: u32, count: usize, dest: []TernaryWord) -> bool // Load block of memory (count words) from base_addr @@ -134,9 +134,9 @@ module ISAMemoryOps { return true; } - // 418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 + // ═════════════════════════════════════════════════════════════════ // 4. Stack Operations (Memory-based) - // 483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 + // ═════════════════════════════════════════════════════════════════════════ // Stack grows downward from high memory const STACK_BASE : u32 = MEM_SIZE - 1; @@ -169,9 +169,9 @@ module ISAMemoryOps { return value; } - // 556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 + // ═════════════════════════════════════════════════════════════════ // 5. Address Translation (Basic) - // 621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 + // ═════════════════════════════════════════════════════════════════════════ // virt_to_phys(virt_addr: u32, base: u32, limit: u32) -> u32 // Simple virtual-to-physical address translation @@ -193,9 +193,9 @@ module ISAMemoryOps { return phys_addr; } - // 694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 + // ═════════════════════════════════════════════════════════════════ // 6. Memory Protection - // 759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831 + // ═════════════════════════════════════════════════════════════════════════ // mem_check_perm(addr: u32, perm: u8, protection_table: []u8) -> bool // Check if address has required permission @@ -218,9 +218,9 @@ module ISAMemoryOps { return true; } - // 832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896 + // ═════════════════════════════════════════════════════════════════ // 7. Memory Copy Operations - // 897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969 + // ═════════════════════════════════════════════════════════════════════════ // mem_copy(dst: []TernaryWord, dst_addr: u32, src: []TernaryWord, src_addr: u32, count: usize) -> bool // Copy count words from source to destination @@ -267,9 +267,9 @@ module ISAMemoryOps { return true; } - // 97097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034 + // ═════════════════════════════════════════════════════════════════ // 8. Word Operations - // 1035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107 + // ═════════════════════════════════════════════════════════════════════════ // word_extract_trit(word: TernaryWord, trit_index: usize) -> i32 // Extract single trit from word (0 = least significant) @@ -310,9 +310,9 @@ module ISAMemoryOps { return result; } - // 11081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172 + // ═════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants - // 1173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245 + // ═════════════════════════════════════════════════════════════════════════ test mem_load_valid_address given memory = []TernaryWord{TernaryWord{.raw = 0}, TernaryWord{.raw = 0x123}} diff --git a/specs/isa/ternary_shift.t27 b/specs/isa/ternary_shift.t27 index 7a30b910c0..8275e89cbd 100644 --- a/specs/isa/ternary_shift.t27 +++ b/specs/isa/ternary_shift.t27 @@ -3,14 +3,14 @@ // Ternary Shift and Rotate Operations Specification // Ring 067 - Bitwise/Tritwise shift and rotate operations // Defines how ternary words are shifted and rotated -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module TernaryShift { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Shift Constants - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ // Trit values const TRIT_NEG : i32 = -1; @@ -25,13 +25,13 @@ module TernaryShift { const SHIFT_LEFT : u8 = 0; const SHIFT_RIGHT : u8 = 1; - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Shift Operations - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_shift_left(word: []i32, shift: usize, len: usize) 256 bool + // ternary_shift_left(word: []i32, shift: usize, len: usize) → bool // Shift word left by N trits, fill with zero - fn ternary_shift_left(word: []i32, shift: usize, len: usize) 257 bool { + fn ternary_shift_left(word: []i32, shift: usize, len: usize) → bool { if (shift >= len) { return false; // Would shift everything out } @@ -52,9 +52,9 @@ module TernaryShift { return true; } - // ternary_shift_right(word: []i32, shift: usize, len: usize) 258 bool + // ternary_shift_right(word: []i32, shift: usize, len: usize) → bool // Shift word right by N trits, fill with zero - fn ternary_shift_right(word: []i32, shift: usize, len: usize) 259 bool { + fn ternary_shift_right(word: []i32, shift: usize, len: usize) → bool { if (shift >= len) { return false; // Would shift everything out } @@ -77,13 +77,13 @@ module TernaryShift { return true; } - // 260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 + // ═════════════════════════════════════════════════════ // 3. Rotate Operations - // 313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_rotate_left(word: []i32, shift: usize, len: usize) 386 void + // ternary_rotate_left(word: []i32, shift: usize, len: usize) → void // Rotate word left by N trits (circular shift) - fn ternary_rotate_left(word: []i32, shift: usize, len: usize) 387 void { + fn ternary_rotate_left(word: []i32, shift: usize, len: usize) → void { if (len == 0) { return; } @@ -112,9 +112,9 @@ module TernaryShift { } } - // ternary_rotate_right(word: []i32, shift: usize, len: usize) 388 void + // ternary_rotate_right(word: []i32, shift: usize, len: usize) → void // Rotate word right by N trits (circular shift) - fn ternary_rotate_right(word: []i32, shift: usize, len: usize) 389 void { + fn ternary_rotate_right(word: []i32, shift: usize, len: usize) → void { if (len == 0) { return; } @@ -143,13 +143,13 @@ module TernaryShift { } } - // 390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 + // ═════════════════════════════════════════════════════ // 4. Arithmetic Shift (Signed Shift) - // 443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515 + // ═════════════════════════════════════════════════════════════════════════ - // ternary_arithmetic_shift_right(word: []i32, shift: usize, len: usize) 516 bool + // ternary_arithmetic_shift_right(word: []i32, shift: usize, len: usize) → bool // Arithmetic shift right: preserves sign bit - fn ternary_arithmetic_shift_right(word: []i32, shift: usize, len: usize) 517 bool { + fn ternary_arithmetic_shift_right(word: []i32, shift: usize, len: usize) → bool { if (len == 0) { return false; } @@ -180,13 +180,13 @@ module TernaryShift { return true; } - // 518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570 + // ═════════════════════════════════════════════════════ // 5. Bit/Trit Extraction - // 571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643 + // ═════════════════════════════════════════════════════════════════════════ - // extract_trits(word: []i32, start: usize, count: usize, result: []i32) 644 bool + // extract_trits(word: []i32, start: usize, count: usize, result: []i32) → bool // Extract N trits starting from position S - fn extract_trits(word: []i32, start: usize, count: usize, result: []i32) 645 bool { + fn extract_trits(word: []i32, start: usize, count: usize, result: []i32) → bool { if (start + count > word.len) { return false; } @@ -200,9 +200,9 @@ module TernaryShift { return true; } - // insert_trits(word: []i32, start: usize, count: usize, values: []i32) 646 bool + // insert_trits(word: []i32, start: usize, count: usize, values: []i32) → bool // Insert N trits starting from position S - fn insert_trits(word: []i32, start: usize, count: usize, values: []i32) 647 bool { + fn insert_trits(word: []i32, start: usize, count: usize, values: []i32) → bool { if (start + count > word.len) { return false; } @@ -216,9 +216,9 @@ module TernaryShift { return true; } - // 648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 + // ═════════════════════════════════════════════════════ // 6. TDD - Tests - // 701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 + // ═════════════════════════════════════════════════════════════════════════ test ternary_shift_left_basic var word : [5]i32 = [_]i32{TRIT_POS, TRIT_ZERO, TRIT_NEG, TRIT_POS, TRIT_ZERO}; @@ -290,9 +290,9 @@ module TernaryShift { assert word[2] == TRIT_NEG assert word[3] == TRIT_NEG - // 774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 + // ═════════════════════════════════════════════════════ // 7. TDD - Invariants - // 827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 + // ═════════════════════════════════════════════════════════════════════════ invariant shift_left_zero_fill // Left shift should fill with zeros @@ -373,9 +373,9 @@ module TernaryShift { assert word_pos[4] == TRIT_POS assert word_neg[4] == TRIT_NEG - // 900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952 + // ═════════════════════════════════════════════════════ // 8. TDD - Benchmarks - // 95395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025 + // ═════════════════════════════════════════════════════════════════════════ bench shift_left_performance // Measure: cycles to perform 1000 left shifts diff --git a/specs/jit/jit.t27 b/specs/jit/jit.t27 index d45968d0d9..9e13ac91b0 100644 --- a/specs/jit/jit.t27 +++ b/specs/jit/jit.t27 @@ -3,8 +3,8 @@ // Trinity JIT Compiler // Compiles VSA operations to native machine code // -// 01234 567891011: V = n 12 3^k 13 14^m 15 16^p 17 e^q -// 1819 + 1/2021 = 3 | TRINITY +// ⲤⲀⲔⲢⲀ ⲪⲞⲢⲘⲨⲖⲀ: V = n × 3^k × π^m × φ^p × e^q +// φ² + 1/φ² = 3 | TRINITY // // JIT (Just-In-Time) compiler for VSA operations: // - Compiles high-level VSA operations to native x86-64 machine code @@ -351,7 +351,7 @@ pub const JitCompiler = struct { } /// Compile dot product operation - /// Generates native code for: return 22(a[i] * b[i]) + /// Generates native code for: return Σ(a[i] * b[i]) pub fn compile_dot_product(self: *Self, dimension: usize) bool { self.reset(); diff --git a/specs/math/constants.t27 b/specs/math/constants.t27 index c5c67925e3..769760f6c3 100644 --- a/specs/math/constants.t27 +++ b/specs/math/constants.t27 @@ -1,19 +1,19 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/constants.t27 // Mathematical Constants for Trinity Computing -// 01 + 1/23 = 3 | Sacred constants for ternary computing +// φ² + 1/φ² = 3 | Sacred constants for ternary computing module Constants { - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 - // 1. Sacred Constants 69 70, TRINITY, CODATA measurements - // 7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 - - // 156 (phi) = (1 + sqrt(5)) / 2 157 1.61803398875 158 the golden ratio - // 159160161 = 162 - 1 163 0.61803398875 164 the inverse golden ratio - // Sacred Identity: 165166 + 1/167168 = 3 - // Computed value: 169170 171 2.61803398875 - // 1/172173 174 0.38196601125 - // 175176 + 1/177178 = 3.000000 (exact within floating precision) + // ═════════════════════════════════════════════════════════════════ + // 1. Sacred Constants — φ, TRINITY, CODATA measurements + // ═════════════════════════════════════════════════════════════════════════════════════ + + // φ (phi) = (1 + sqrt(5)) / 2 ≈ 1.61803398875 — the golden ratio + // φ⁻¹ = φ - 1 ≈ 0.61803398875 — the inverse golden ratio + // Sacred Identity: φ² + 1/φ² = 3 + // Computed value: φ² ≈ 2.61803398875 + // 1/φ² ≈ 0.38196601125 + // φ² + 1/φ² = 3.000000 (exact within floating precision) const PHI : f64 = 1.61803398874989484820458683436563811772; const PHI_INV : f64 = 0.61803398874989484820458683436563811772; const PHI_SQ : f64 = PHI * PHI; @@ -25,43 +25,43 @@ module Constants { // TRINITY = 3.0 within numeric tolerance const TRINITY : f64 = 3.0; - // 179 (pi) 180 3.14159265359 + // π (pi) ≈ 3.14159265359 const PI : f64 = 3.14159265358979323846264338327950288; - // e (Euler's number) 181 2.71828182846 + // e (Euler's number) ≈ 2.71828182846 const E : f64 = 2.7182818284590452353602874713526625; - // CODATA: G_measured = 6.6743076718210183184185 m186187kg188189190s191192 (SI units) + // CODATA: G_measured = 6.67430767×10⁻¹¹ m³·kg⁻¹·s⁻² (SI units) // Reference: Planck 2018/2020 (https://ui.adsabs.harvard.edu/energy.html) // Scale factors derived from CODATA measurements: - // G_scale = G / G_measured 193 1.0001 (SI normalization) - // 194_scale = 195_196 / (197_198_computed 199 200201202) 203 0.9995 - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 - // 2. CODATA 2022 Measurements 281 sacred_gravity(), sacred_dark_energy() reference - // 282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 + // G_scale = G / G_measured ≈ 1.0001 (SI normalization) + // Ω_scale = Ω_Λ / (Ω_Λ_computed × φ⁻²) ≈ 0.9995 + // ═════════════════════════════════════════════════════════════════════════════ + // 2. CODATA 2022 Measurements — sacred_gravity(), sacred_dark_energy() reference + // ═════════════════════════════════════════════════════════════════════════════════════ // Gravitational constant G (measured) - // G = 6.67430 367 10^-11 m368 kg369370 s371372 + // G = 6.67430 × 10^-11 m³ kg⁻¹ s⁻² const G_MEASURED : f64 = 6.67430e-11; - // Cosmological constant 373 (dimensional) - // 374 375 1.1056 376 10^-52 m377378 + // Cosmological constant Λ (dimensional) + // Λ ≈ 1.1056 × 10^-52 m⁻² const LAMBDA_COSMO : f64 = 1.1056e-52; - // Dark energy density parameter 379_380 (dimensionless) - // 381_382 383 0.685 (Planck 2018/2020) + // Dark energy density parameter Ω_Λ (dimensionless) + // Ω_Λ ≈ 0.685 (Planck 2018/2020) const OMEGA_LAMBDA_MEASURED : f64 = 0.685; // Scale factors for sacred formulas - // G_SCALE = G / G_measured 384 1.0001 (SI normalization) - // OMEGA_COARSE_SCALE = 385_386_measured / 387_388_raw 389 728.9 (measured/raw ratio) - // OMEGA_FINE_SCALE = 390_391_measured / (392_393_computed 394 395396397) 398 0.9995 (from comment) + // G_SCALE = G / G_measured ≈ 1.0001 (SI normalization) + // OMEGA_COARSE_SCALE = Ω_Λ_measured / Ω_Λ_raw ≈ 728.9 (measured/raw ratio) + // OMEGA_FINE_SCALE = Ω_Λ_measured / (Ω_Λ_computed × φ⁻²) ≈ 0.9995 (from comment) const G_SCALE : f64 = 1.0001; const OMEGA_COARSE_SCALE : f64 = 728.9; - // 399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 + // ═══════════════════════════════════════════════════════════════════════════ // 3. Helper Functions - // 474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 + // ═════════════════════════════════════════════════════════════════════════════════════ // Absolute value fn abs(x: f64) -> f64 { @@ -198,9 +198,9 @@ module Constants { return (xi - 1) as f64; } - // 559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 + // ═════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Sacred Physics Constants - // 636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724 + // ═════════════════════════════════════════════════════════════════════════════════════════ test phi_squared_plus_inverse_squared_equals_3 given phi = PHI diff --git a/specs/math/e8_lie_algebra.t27 b/specs/math/e8_lie_algebra.t27 index e6ac94aad9..82a1bd213d 100644 --- a/specs/math/e8_lie_algebra.t27 +++ b/specs/math/e8_lie_algebra.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/e8_lie_algebra.t27 -// E8 Exceptional Lie Algebra 0 Root System, Cartan Matrix, Eigenvalues +// E8 Exceptional Lie Algebra — Root System, Cartan Matrix, Eigenvalues // Direction A (Priority 2) of PROJECT KEPLER->NEWTON // // E8 is the largest exceptional simple Lie group. Its root system contains @@ -16,10 +16,10 @@ // 5. McKay correspondence: binary icosahedral group 2I <-> affine E8 // // References: -// - Dechant, Proc. Roy. Soc. A 472 (2016) 1 E8 from icosahedral spinors -// - Aschheim, Minkowski Inst. Press (2017) 2 E9 eigenvalues contain phi^2 -// - Humphreys, "Introduction to Lie Algebras" 3 standard reference -// - Kac, "Infinite-Dimensional Lie Algebras" 4 affine E8 +// - Dechant, Proc. Roy. Soc. A 472 (2016) — E8 from icosahedral spinors +// - Aschheim, Minkowski Inst. Press (2017) — E9 eigenvalues contain phi^2 +// - Humphreys, "Introduction to Lie Algebras" — standard reference +// - Kac, "Infinite-Dimensional Lie Algebras" — affine E8 module E8LieAlgebra { use math::constants; @@ -174,7 +174,7 @@ module E8LieAlgebra { // E8 roots decompose as: Phi(E8) = H4 + phi*H4 // Two copies of the 600-cell, scaled by phi - // H4 exponents: {1, 11, 19, 29} 5 subset of E8 exponents + // H4 exponents: {1, 11, 19, 29} — subset of E8 exponents const H4_EXPONENTS : [4]i64 = [1, 11, 19, 29]; // phi appears because cos(pi/5) = phi/2 connects 5-fold rotation to phi diff --git a/specs/math/gf_competitive.t27 b/specs/math/gf_competitive.t27 index 52bb80bc7b..2a74e559fb 100644 --- a/specs/math/gf_competitive.t27 +++ b/specs/math/gf_competitive.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/gf_competitive.t27 -// GoldenFloat Competitive Analysis 0 GF vs Posit vs IEEE 754 -// MATH-COMPETITIVE-001 1 Decode latency, parallelism, hardware efficiency +// GoldenFloat Competitive Analysis — GF vs Posit vs IEEE 754 +// MATH-COMPETITIVE-001 — Decode latency, parallelism, hardware efficiency // // Ring 051: Competitive analysis showing GF's structural advantages // Main result: GF has O(1) parallel decode vs Posit's O(N) sequential @@ -10,9 +10,9 @@ module GFCompetitive { use math::constants; use math::sacred_physics; - // 2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 + // ═══════════════════════════════════════════════════════════════════════════ // 1. Decode Complexity Analysis - // 7778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Decode operation counts (worst case) struct DecodeComplexity { @@ -46,9 +46,9 @@ module GFCompetitive { ]; } - // 166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 + // ═══════════════════════════════════════════════════════════════════════════ // Tests - // 241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 + // ═════════════════════════════════════════════════════════════════════════════════════════ test "decode_complexity_returns_3_formats" { let complexity = decode_complexity(); @@ -80,9 +80,9 @@ module GFCompetitive { assert!(complexity[1].steps_sequential > complexity[2].steps_sequential); } - // 330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 + // ═══════════════════════════════════════════════════════════════════════════ // Invariants - // 405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 + // ═════════════════════════════════════════════════════════════════════════════════════════ invariant "decode_complexity_always_returns_3_entries" { let complexity = decode_complexity(); @@ -107,9 +107,9 @@ module GFCompetitive { } } - // 494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 + // ═══════════════════════════════════════════════════════════════════════════ // Benchmarks - // 569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657 + // ═════════════════════════════════════════════════════════════════════════════════════════ bench "decode_complexity" { let iterations = 10000; diff --git a/specs/math/pellis_precision_verify.t27 b/specs/math/pellis_precision_verify.t27 index 8644a30948..51de1a35bc 100644 --- a/specs/math/pellis_precision_verify.t27 +++ b/specs/math/pellis_precision_verify.t27 @@ -1,29 +1,29 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/pellis_precision_verify.t27 // Arbitrary precision verification via GMP/MPFR reference -// NUMERIC-VERIF-001 0 Pre-registered checkpoint for CODATA 2026 +// NUMERIC-VERIF-001 — Pre-registered checkpoint for CODATA 2026 module PellisPrecision { use math::constants; use math::sacred_physics; - // 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 + // ═════════════════════════════════════════════════════════════════ // 1. Golden Ratio at 100 Decimal Digits (pre-computed via GMP) - // 66676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 + // ═════════════════════════════════════════════════════════════════════════ - // 139 = (1 + 1405) / 2 at 100 decimal places + // φ = (1 + √5) / 2 at 100 decimal places // Computed once via GMP/mpmath, sealed as constant // Reference: mpmath.mpf(1).sqrt(5) + 1) / 2 at 100 digits precision const PHI_100DIGITS : string = "1.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475"; - // 141142143 = 144 - 1 at 100 decimal places + // φ⁻¹ = φ - 1 at 100 decimal places const PHI_INV_100DIGITS : string = "0.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475"; - // 145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 + // ═════════════════════════════════════════════════════════════════ // 2. Pellis Closed Form at 50 Decimal Digits (pre-registered checkpoint) - // 210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 + // ═════════════════════════════════════════════════════════════════════════ - // Pellis = 360/283284 - 2/285286 + (3287)288289 + // Pellis = 360/φ² - 2/φ³ + (3φ)⁻⁵ // Pre-registered for CODATA 2026/2030 comparison // Computed via GMP: 360/mp.mpf(phi**2) - 2/mp.mpf(phi**3) + (3*phi)**(-5) // 50 digits after the decimal point; refresh: python3 scripts/print_pellis_seal_decimal.py 55 @@ -32,12 +32,12 @@ module PellisPrecision { // CODATA 2022 reference: 137.035999166(15) const ALPHA_INV_CODATA_2022 : string = "137.035999166"; - // f64-style fixed prefix (29015 significant fractional digits; IEEE rounding) + // f64-style fixed prefix (≈15 significant fractional digits; IEEE rounding) const PELLIS_FIRST_15_DIGITS : string = "137.035999164765"; - // 291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 + // ═════════════════════════════════════════════════════════════════ // 3. Verification Tests (string compare against pre-computed values) - // 356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 + // ═════════════════════════════════════════════════════════════════════════ struct PellisPrecisionResult { phi_f64 : f64, @@ -53,7 +53,7 @@ module PellisPrecision { const phi_sq = phi * phi; const phi_cubed = phi * phi * phi; - // Compute Pellis via f64 (NOT 50-digit accurate 429 this test documents limit) + // Compute Pellis via f64 (NOT 50-digit accurate — this test documents limit) const pellis_f64 = 360.0 / phi_sq - 2.0 / phi_cubed + (3.0 * phi).pow(-5.0); // Count significant decimal digits of f64 representation @@ -109,18 +109,18 @@ module PellisPrecision { return x.to_string(); } - // 430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 + // ═════════════════════════════════════════════════════════════════ // 4. Helper functions - // 495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 + // ═════════════════════════════════════════════════════════════════════════ fn len(s: string) -> i32 { // String length stub - implementation dependent return 100; // Placeholder } - // 568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Pellis Precision Verification - // 671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test pellis_pre_registered_checkpoint_matches given result = pellis_pre_registered_checkpoint() @@ -161,9 +161,9 @@ module PellisPrecision { // This test ensures the formula is documented for reviewers then true // Formula is documented in comments above - // 774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838 + // ═════════════════════════════════════════════════════════════════ // 5. Invariants - // 839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911 + // ═════════════════════════════════════════════════════════════════════════ invariant pellis_50_digits_constant assert PELLIS_50DIGITS.starts_with("137.035999") @@ -189,9 +189,9 @@ module PellisPrecision { invariant pellis_first_15_digits_extracted_correctly assert PELLIS_FIRST_15_DIGITS.starts_with("137.035999164") - // 912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976 + // ═════════════════════════════════════════════════════════════════ // 6. Benchmarks - // 97797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049 + // ═════════════════════════════════════════════════════════════════════════ bench pellis_f64_computation measure: nanoseconds to compute pellis_pre_registered_checkpoint() diff --git a/specs/math/phi_split_optimality.t27 b/specs/math/phi_split_optimality.t27 index db6a8c9b8f..4be3404956 100644 --- a/specs/math/phi_split_optimality.t27 +++ b/specs/math/phi_split_optimality.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/phi_split_optimality.t27 -// Phi-Split Theorems 0 Self-Similarity + Optimal Rounding (CORRECTED) -// MATH-OPTIMALITY-001 1 Foundation for GoldenFloat being non-random +// Phi-Split Theorems — Self-Similarity + Optimal Rounding (CORRECTED) +// MATH-OPTIMALITY-001 — Foundation for GoldenFloat being non-random // // THEOREM 1 (Golden Self-Similarity): phi is unique self-similar proportion for bit allocation // THEOREM 2 (Optimal Rounding): round((N-1)/phi^2) minimizes phi-distance (7/7 match) @@ -23,7 +23,7 @@ module PhiSplitOptimality { // Solving: (exp/mant)^2 + (exp/mant) - 1 = 0 -> exp/mant = 1/phi // // IMPORTANT: This is NOT an optimization problem (maximizing e*m gives r=1 by AM-GM). - // This is a self-similarity constraint 2 a defining property of the golden ratio. + // This is a self-similarity constraint — a defining property of the golden ratio. const PHI_TARGET : f64 = sacred_physics::PHI_INV; // 1/phi approx 0.618... @@ -45,7 +45,7 @@ module PhiSplitOptimality { // r = (sqrt(5) - 1)/2 = 1/phi approx 0.618 // // This follows directly from phi^2 = phi + 1, the defining property of phi. - // It is NOT an optimization result 3 it's a self-similarity property. + // It is NOT an optimization result — it's a self-similarity property. fn optimal_ratio_by_self_similarity(available: u8) -> (u8, u8) { // Self-similarity constraint: exp/mant = 1/phi diff --git a/specs/math/phi_universal_attractor.t27 b/specs/math/phi_universal_attractor.t27 index 071d921c17..0142039342 100644 --- a/specs/math/phi_universal_attractor.t27 +++ b/specs/math/phi_universal_attractor.t27 @@ -1,38 +1,38 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/phi_universal_attractor.t27 -// Phi Universal Attractor Theorems 0 Theorem 3: 1 as Universal Fixed-Point -// MATH-ATTRACTOR-001 2 Generative mechanism for 3 proportion +// Phi Universal Attractor Theorems — Theorem 3: φ as Universal Fixed-Point +// MATH-ATTRACTOR-001 — Generative mechanism for φ proportion // -// THEOREM 3: 4 is the unique fixed point of balancing recursion f(x) = (x + x56 + 1) / 2 -// This addresses the critic's concern that 7 is "fitting" rather than a true mechanism. +// THEOREM 3: φ is the unique fixed point of balancing recursion f(x) = (x + x⁻¹ + 1) / 2 +// This addresses the critic's concern that φ is "fitting" rather than a true mechanism. module PhiUniversalAttractor { use math::constants; use math::sacred_physics; - // 8910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 - // 1. THEOREM 3: 83 as Universal Fixed-Point Attractor - // 84858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 + // ═══════════════════════════════════════════════════════════════════════════ + // 1. THEOREM 3: φ as Universal Fixed-Point Attractor + // ═════════════════════════════════════════════════════════════════════════════════════════ // The balancing recursion captures a fundamental dynamic: allocate a component // while maintaining balance with its complement. This is a zero-parameter mechanism. // - // From any positive starting point x173 > 0, iteration converges - // exponentially to 174 with rate 175 = (1765 - 1) / 4 177 0.309. + // From any positive starting point x₀ > 0, iteration converges + // exponentially to φ with rate λ = (√5 - 1) / 4 ≈ 0.309. - // The balancing function: f(x) = (x + x178179 + 1) / 2 + // The balancing function: f(x) = (x + x⁻¹ + 1) / 2 fn balancing_recursion(x: f64) -> f64 { const inv = 1.0 / x; return (x + inv + 1.0) / 2.0; } - // Theoretical convergence rate 180 = (1815 - 1) / 4 + // Theoretical convergence rate λ = (√5 - 1) / 4 // This is the Lipschitz constant for the contraction mapping f const CONVERGENCE_RATE_LAMBDA: f64 = (sqrt(5.0) - 1.0) / 4.0; - // 182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 + // ═══════════════════════════════════════════════════════════════════════════ // 2. Iteration to Fixed Point - // 257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 + // ═══════════════════════════════════════════════════════════════════════════ // Result tuple: (final_value, iterations, phi_distance) struct ConvergenceResult { @@ -41,7 +41,7 @@ module PhiUniversalAttractor { phi_error : f64, } - // Iterate from starting point until convergence to 332 + // Iterate from starting point until convergence to φ fn iterate_to_fixed_point(x0: f64, max_iter: u8, tolerance: f64) -> ConvergenceResult { let mut x = x0; let mut iter = 0; @@ -68,11 +68,11 @@ module PhiUniversalAttractor { }; } - // 333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ═══════════════════════════════════════════════════════════════════════════ // 3. Contraction Mapping Analysis - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 + // ═══════════════════════════════════════════════════════════════════════════ - // Derivative of f: f'(x) = (1 - x483484) / 2 + // Derivative of f: f'(x) = (1 - x⁻²) / 2 // This shows f is a contraction mapping for x > 0 fn balancing_derivative(x: f64) -> f64 { const inv_sq = 1.0 / (x * x); @@ -82,12 +82,12 @@ module PhiUniversalAttractor { // Maximum derivative magnitude (Lipschitz constant) for x > 0 // |f'(x)| < 0.5 for all x > 0, proving contraction fn max_lipschitz_constant() -> f64 { - return 0.5; // |(1 - x485486)/2| < 0.5 for all x > 0 + return 0.5; // |(1 - x⁻²)/2| < 0.5 for all x > 0 } - // 487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 + // ═══════════════════════════════════════════════════════════════════════════ // 4. Proof Steps Documentation - // 562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636 + // ═══════════════════════════════════════════════════════════════════════════ struct ProofStep { description : string, @@ -99,17 +99,17 @@ module PhiUniversalAttractor { return [ ProofStep{ description = "Balancing function definition", - equation = "f(x) = (x + x637638 + 1) / 2", + equation = "f(x) = (x + x⁻¹ + 1) / 2", result = "Fundamental balancing dynamic", }, ProofStep{ description = "Phi satisfies fixed point", - equation = "f(639) = (640 + 641642643 + 1) / 2 = (644 + (645 - 1) + 1) / 2 = 646", - result = "647 is a fixed point of f", + equation = "f(φ) = (φ + φ⁻¹ + 1) / 2 = (φ + (φ - 1) + 1) / 2 = φ", + result = "φ is a fixed point of f", }, ProofStep{ description = "Contraction property", - equation = "|f'(x)| = |(1 - x648649)/2| < 0.5 for all x > 0", + equation = "|f'(x)| = |(1 - x⁻²)/2| < 0.5 for all x > 0", result = "Banach fixed-point theorem guarantees unique attractor", }, ]; @@ -119,36 +119,36 @@ module PhiUniversalAttractor { return [ ProofStep{ description = "Derivative bounds", - equation = "f'(x) = (1 - x650651)/2, so |f'(x)| < 0.5", + equation = "f'(x) = (1 - x⁻²)/2, so |f'(x)| < 0.5", result = "f is a contraction mapping", }, ProofStep{ description = "Lipschitz constant", - equation = "652 = (6535 - 1)/4 654 0.309", - result = "Error decays as |x655 - 656| 657 658659 |x660 - 661|", + equation = "λ = (√5 - 1)/4 ≈ 0.309", + result = "Error decays as |xₙ - φ| ≤ λⁿ |x₀ - φ|", }, ProofStep{ description = "Exponential convergence", - equation = "lim(n662663) f664(x665) = 666 for all x667 > 0", + equation = "lim(n→∞) fⁿ(x₀) = φ for all x₀ > 0", result = "Universal attractor property", }, ProofStep{ description = "Zero parameters", - equation = "No fitting constants 668 669 emerges from f's structure", + equation = "No fitting constants — φ emerges from f's structure", result = "Generative mechanism, not fitted narrative", }, ]; } - // 670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 + // ═══════════════════════════════════════════════════════════════════════════ // 5. Connection to Bit Allocation - // 745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ═══════════════════════════════════════════════════════════════════════════ - // The GF bit allocation (exp/mant 820 1/821) is a special case - // of the universal attractor: any balancing dynamic of form f(x) = (x + x822823 + 1)/2 - // will converge to 824-proportional allocation regardless of initialization. + // The GF bit allocation (exp/mant ≈ 1/φ) is a special case + // of the universal attractor: any balancing dynamic of form f(x) = (x + x⁻¹ + 1)/2 + // will converge to φ-proportional allocation regardless of initialization. fn bit_allocation_attractor(available_bits: u8, initial_ratio: f64) -> (u8, u8, f64) { - // Simulate evolution of bit allocation ratio to 825 + // Simulate evolution of bit allocation ratio to φ const target_ratio = sacred_physics::PHI_INV; let mut current_ratio = initial_ratio; @@ -169,9 +169,9 @@ module PhiUniversalAttractor { return (exp, mant, current_ratio); } - // 826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900 + // ═══════════════════════════════════════════════════════════════════════════ // 6. TDD-Inside-Spec: Tests - // 901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975 + // ═══════════════════════════════════════════════════════════════════════════ test phi_is_fixed_point_of_f given phi = sacred_physics::PHI @@ -251,11 +251,11 @@ module PhiUniversalAttractor { given phi_computed_from_iter = iterate_to_fixed_point(2.0, 50, 1e-14) and phi_ref = sacred_physics::PHI then phi_computed_from_iter.phi_error < 1e-13 - // Note: No "fitting constants" used 976 pure recursion f + // Note: No "fitting constants" used — pure recursion f - // 9779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051 + // ═══════════════════════════════════════════════════════════════════════════ // 7. Invariants - // 105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126 + // ═══════════════════════════════════════════════════════════════════════════ invariant convergence_rate_is_positive assert CONVERGENCE_RATE_LAMBDA > 0.0 @@ -280,8 +280,8 @@ module PhiUniversalAttractor { forall i in 0..test_points.length(), abs(balancing_derivative(test_points[i])) < 0.5 invariant unique_attractor_property - // 1127 is the ONLY fixed point of f on R1128 - // If f(x) = x for x > 0, then x = 1129 + // φ is the ONLY fixed point of f on R⁺ + // If f(x) = x for x > 0, then x = φ assert balancing_recursion(sacred_physics::PHI) == sacred_physics::PHI invariant fixed_point_proof_steps_complete @@ -291,31 +291,31 @@ module PhiUniversalAttractor { assert convergence_proof_steps().length() == 4 invariant zero_free_parameters - // Mechanism is analytically defined 1130 no fitting constants + // Mechanism is analytically defined — no fitting constants assert CONVERGENCE_RATE_LAMBDA == (sqrt(5.0) - 1.0) / 4.0 invariant universal_attractor_from_positive_reals - // For ANY x1131 > 0, iteration converges to 1132 + // For ANY x₀ > 0, iteration converges to φ given start_values = [0.01, 0.1, 1.0, 10.0, 100.0] forall i in 0..start_values.length(), { let result = iterate_to_fixed_point(start_values[i], 30, 1e-13); result.phi_error < 1e-12 } - // 113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207 + // ═══════════════════════════════════════════════════════════════════════════ // 8. Benchmarks - // 120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282 + // ═══════════════════════════════════════════════════════════════════════════ bench balancing_recursion_single_call measure: nanoseconds for one balancing_recursion() call target: < 50ns bench iterate_to_convergence_from_arbitrary_start - measure: nanoseconds to converge from x1283 = 0.5 + measure: nanoseconds to converge from x₀ = 0.5 target: < 500ns bench iterate_to_convergence_from_large_start - measure: nanoseconds to converge from x1284 = 10.0 + measure: nanoseconds to converge from x₀ = 10.0 target: < 500ns bench derivative_computation diff --git a/specs/math/property_test_template.t27 b/specs/math/property_test_template.t27 index d20d2d4259..63d2403764 100644 --- a/specs/math/property_test_template.t27 +++ b/specs/math/property_test_template.t27 @@ -4,14 +4,14 @@ // Ring 053 - Defines reusable property testing patterns // This spec provides templates for property-based testing of T27 formats // Properties: mathematical invariants that must hold for ALL valid inputs -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module PropertyTestTemplate { use math::constants; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 + // ═════════════════════════════════════════════════════════════════ // 1. Property Test Types - // 69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 + // ═════════════════════════════════════════════════════════════════════════ // Property test strategies const STRATEGY_RANDOM : i32 = 0 // Random generation with N samples @@ -23,9 +23,9 @@ module PropertyTestTemplate { const SAMPLE_SIZE_MEDIUM : i32 = 1000 const SAMPLE_SIZE_LARGE : i32 = 10000 - // 142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 + // ═════════════════════════════════════════════════════════════════ // 2. Property Definitions (as test generators) - // 207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════════ // Test associativity: (a op b) op c = a op (b op c) for all a,b,c // Domain: binary operations @@ -238,9 +238,9 @@ module PropertyTestTemplate { return result as i64 } - // 280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 + // ═════════════════════════════════════════════════════════════════ // 3. Helper Functions - // 345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════════ // Absolute value fn abs(x: f64) -> f64 { @@ -324,9 +324,9 @@ module PropertyTestTemplate { return (xi - 1) as f64 } - // 418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 + // ═════════════════════════════════════════════════════════════════ // 4. TDD - Tests - // 483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 + // ═════════════════════════════════════════════════════════════════════════ test associative_addition given values = [_]f64{1.0, 2.0, 3.0, -1.5, 0.5, 0.0} @@ -419,9 +419,9 @@ module PropertyTestTemplate { when result = test_tritspace_dimension(n) then result == 243 - // 556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 + // ═════════════════════════════════════════════════════════════════ // 5. TDD - Invariants - // 621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 + // ═════════════════════════════════════════════════════════════════════════ invariant associative_invariant // Associativity is a fundamental property for many operations @@ -457,9 +457,9 @@ module PropertyTestTemplate { assert test_tritspace_dimension(4) == 81 // Rationale: N trits can represent 3^N distinct states - // 694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 + // ═════════════════════════════════════════════════════════════════ // 6. TDD - Benchmarks - // 759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831 + // ═════════════════════════════════════════════════════════════════════════ bench property_test_associative // Measure: cycles to test associativity on 10 values diff --git a/specs/math/radix_economy.t27 b/specs/math/radix_economy.t27 index a0f35b6875..88b7b17ef8 100644 --- a/specs/math/radix_economy.t27 +++ b/specs/math/radix_economy.t27 @@ -1,35 +1,35 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/radix_economy.t27 -// Radix Economy Formal Spec 0 Information-Theoretic Basis for Base-3 Computing -// E(b) = ln(b)/b, maximized at b = e 1 2.71828 +// Radix Economy Formal Spec — Information-Theoretic Basis for Base-3 Computing +// E(b) = ln(b)/b, maximized at b = e ≈ 2.71828 // E(3)/E(e) >= 99.5%, E(3)/E(2) = 1.054 (5.4% advantage) module RadixEconomy { use Constants; - // 2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 + // ═══════════════════════════════════════════════════════════════════════════ // 1. Radix Economy Constants - // 7778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 + // ═════════════════════════════════════════════════════════════════════════════════════════ - // E(b) = ln(b) / b 166 information per digit - // E(2) = ln(2)/2 167 0.34657 168 binary radix economy + // E(b) = ln(b) / b — information per digit + // E(2) = ln(2)/2 ≈ 0.34657 — binary radix economy const E_BASE2 : f64 = 0.34657359027997264; // ln(2)/2 - // E(3) = ln(3)/3 169 0.36620 170 ternary radix economy + // E(3) = ln(3)/3 ≈ 0.36620 — ternary radix economy const E_BASE3 : f64 = 0.3662040962227032; // ln(3)/3 - // E(e) = 1/e 171 0.36788 172 optimal radix economy (theoretical maximum) + // E(e) = 1/e ≈ 0.36788 — optimal radix economy (theoretical maximum) const E_OPTIMAL : f64 = 0.36787944117144233; // 1/e - // log2(3) 173 1.58496 174 bits per trit (information density) + // log2(3) ≈ 1.58496 — bits per trit (information density) const LOG2_3 : f64 = 1.584962500721156; - // log3(2) 175 0.63093 176 trits per bit (inverse density) + // log3(2) ≈ 0.63093 — trits per bit (inverse density) const LOG3_2 : f64 = 0.6309297535714574; - // 177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 + // ═══════════════════════════════════════════════════════════════════════════ // 2. Radix Economy Functions - // 252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Compute radix economy for base b fn radix_economy(b: f64) -> f64 { @@ -61,9 +61,9 @@ module RadixEconomy { return (pow(2.0, n as f64) - 1.0) as i64; } - // 341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 + // ═══════════════════════════════════════════════════════════════════════════ // 3. Helper Functions (logarithms) - // 416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Natural logarithm fn ln(x: f64) -> f64 { @@ -159,9 +159,9 @@ module RadixEconomy { return (xi - 1) as f64; } - // 505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579 + // ═══════════════════════════════════════════════════════════════════════════ // 4. TDD-Inside-Spec: Tests for Radix Economy - // 580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668 + // ═════════════════════════════════════════════════════════════════════════════════════════ test e_base3_near_optimal given e3 = E_BASE3 @@ -254,9 +254,9 @@ module RadixEconomy { and abs(log2_4 - 2.0) < 1e-6 and abs(log2_8 - 3.0) < 1e-6 - // 669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743 - // 5. Formal Invariants 744 Mathematical Truths - // 745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 + // ═══════════════════════════════════════════════════════════════════════════ + // 5. Formal Invariants — Mathematical Truths + // ═════════════════════════════════════════════════════════════════════════════════════════ invariant base3_995_percent_optimal assert E_BASE3 / E_OPTIMAL >= 0.995 @@ -272,7 +272,7 @@ module RadixEconomy { invariant log2_3_in_range assert LOG2_3 >= 1.58496 and LOG2_3 <= 1.58497 - // Rationale: log2(3) 834 1.584962500721156 + // Rationale: log2(3) ≈ 1.584962500721156 invariant trit_info_density assert LOG2_3 > 1.5 and LOG2_3 < 2.0 @@ -297,20 +297,20 @@ module RadixEconomy { invariant range_equivalence_27trit_43bit assert ternary_range(27) <= binary_range(43) and ternary_range(27) > binary_range(42) - // Rationale: (3^27-1)/2 835 3.8e12, 2^42 836 4.4e12, 2^43 837 8.8e12 + // Rationale: (3^27-1)/2 ≈ 3.8e12, 2^42 ≈ 4.4e12, 2^43 ≈ 8.8e12 invariant range_equivalence_18trit_29bit assert ternary_range(18) <= binary_range(29) and ternary_range(18) > binary_range(28) - // Rationale: 3^18 838 3.9e8, 2^28 839 2.7e8, 2^29 840 5.4e8 + // Rationale: 3^18 ≈ 3.9e8, 2^28 ≈ 2.7e8, 2^29 ≈ 5.4e8 invariant log_reciprocal_identity assert LOG3_2 * LOG2_3 = 1.0 within 1e-6 // Rationale: log_a(b) * log_b(a) = 1 for any valid bases - // 841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915 - // 6. Benchmarks 916 Performance Targets - // 917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005 + // ═══════════════════════════════════════════════════════════════════════════ + // 6. Benchmarks — Performance Targets + // ═════════════════════════════════════════════════════════════════════════════════════════ bench radix_economy_computation measure: cycles to compute radix_economy(3.0) diff --git a/specs/math/sacred_physics.t27 b/specs/math/sacred_physics.t27 index 6fa6b52325..184253a11e 100644 --- a/specs/math/sacred_physics.t27 +++ b/specs/math/sacred_physics.t27 @@ -1,14 +1,14 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/sacred_physics.t27 -// Strand I 0 Mathematical Foundation +// Strand I — Mathematical Foundation // Sacred Physics Layer: links TRINITY identity (phi) to gravity, cosmology and neurotime. module SacredPhysics { // Import base constants: PHI, PHI_INV, PI, E, G_MEASURED, OMEGA_LAMBDA_MEASURED use math::constants; -// 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 +// ───────────────────────────────────────────────────── // 1. TRINITY identity and derived dimensionless constants -// 54555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 +// ───────────────────────────────────────────────────── // Claim IDs: C-phi-001 (EXACT for mathematical identity, CONJECTURAL for physics interpretation) const PHI : f64 = constants::PHI; // 1.618... (golden ratio) const PHI_INV : f64 = constants::PHI_INV; // 0.618... (inverse golden ratio) @@ -19,7 +19,7 @@ module SacredPhysics { // Claim: C-phi-001 (EXACT - mathematical identity), tolerance: EXACT const TRINITY : f64 = PHI_SQ + PHI_INV_SQ; - // Barbero107Immirzi parameter from pure math: gamma = phi^{-3} + // Barbero–Immirzi parameter from pure math: gamma = phi^{-3} // Claim: C-phi-001 (CONJECTURAL - physics interpretation), tolerance: CONJECTURAL const GAMMA_LQG : f64 = pow(PHI, -3.0); @@ -39,12 +39,12 @@ module SacredPhysics { return (phi_cubed * pi) / GAMMA_LQG; } - // 108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 - // 1.5 161 power helper functions - // 162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 + // ───────────────────────────────────────────────────── + // 1.5 φ power helper functions + // ───────────────────────────────────────────────────── // phi_pow(n: i64) -> f64 - // Efficient computation of 215^n using recurrence 216^2 = 217 + 1 + // Efficient computation of φ^n using recurrence φ^2 = φ + 1 // Handles positive, zero, and negative exponents fn phi_pow(n: i64) -> f64 { if n == 0 { @@ -79,9 +79,9 @@ module SacredPhysics { return result; } -// 218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 +// ───────────────────────────────────────────────────── // 2. Gravity & dark energy from TRINITY -// 271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 +// ───────────────────────────────────────────────────── // Claim IDs: C-phi-005 (EMPIRICAL_FIT - Trinity monomials for fundamental constants) // Sacred gravity prediction: G_sacred = pi^3 * gamma^2 / phi @@ -103,9 +103,9 @@ module SacredPhysics { return (gamma8 * pi4) / (PHI_SQ); } - // 324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 - // 3. Verification API 377 language378agnostic conformance hooks - // 379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 + // ───────────────────────────────────────────────────── + // 3. Verification API — language‑agnostic conformance hooks + // ───────────────────────────────────────────────────── // All tolerances are relative errors. const MAX_REL_ERROR_G : f64 = 1.0e-3; // 0.1% @@ -176,13 +176,13 @@ module SacredPhysics { }; } - // 432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Sacred Physics - // 535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ - // 638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728 - // 4. TRINITY Verification 729 Core identity check - // 730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820 + // ═══════════════════════════════════════════════════════════════════════════════════════════ + // 4. TRINITY Verification — Core identity check + // ═══════════════════════════════════════════════════════════════════════════════════════════ struct TrinityVerification { phi_value : f64; @@ -217,9 +217,9 @@ module SacredPhysics { }; } - // 821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911 + // ═══════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Sacred Physics - // 912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990 + // ═══════════════════════════════════════════════════════════════════════════════ test trinity_identity_holds // Claim: C-phi-001 (EXACT), tolerance: EXACT diff --git a/specs/math/zamolodchikov_e8.t27 b/specs/math/zamolodchikov_e8.t27 index f64b67c395..b3fbffa1c8 100644 --- a/specs/math/zamolodchikov_e8.t27 +++ b/specs/math/zamolodchikov_e8.t27 @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/math/zamolodchikov_e8.t27 -// Zamolodchikov E8 Integrable Field Theory 0 Mass Spectrum +// Zamolodchikov E8 Integrable Field Theory — Mass Spectrum // Direction A/E of PROJECT KEPLER->NEWTON // // In 1989, Zamolodchikov proved that the 2D Ising CFT perturbed by // a magnetic field possesses E8 symmetry with exactly 8 stable particles. -// Their mass ratios are determined EXACTLY by E8 algebra 1 not fitted. +// Their mass ratios are determined EXACTLY by E8 algebra — not fitted. // // Key result: m2/m1 = phi (golden ratio). Also m6/m3 = m7/m4 = m8/m5 = phi. // This was confirmed experimentally by Coldea et al. (Science 2010) @@ -20,8 +20,8 @@ // // References: // - Zamolodchikov, Int. J. Mod. Phys. A4 (1989) 4235 -// - Coldea et al., Science 327 (2010) 177 2 experimental confirmation -// - Koca & Koca, arXiv:1204.4567 (2012) 3 E8 Gosset circles +// - Coldea et al., Science 327 (2010) 177 — experimental confirmation +// - Koca & Koca, arXiv:1204.4567 (2012) — E8 Gosset circles // - Fonseca & Zamolodchikov, J. Stat. Phys. 110 (2003) 527 module ZamolodchikovE8 { @@ -127,7 +127,7 @@ module ZamolodchikovE8 { // MW: n=162 = 2 * 3^4 (mark 2) // MH: n=135 = 5 * 3^3 (mark 5) // - // Non-matching: quark masses (n=199, 167, 149 4 primes) + // Non-matching: quark masses (n=199, 167, 149 — primes) struct MarkDecomposition { n: i64; diff --git a/specs/memory/notebooklm.t27 b/specs/memory/notebooklm.t27 index a72ec3c18f..c65e5a6ef2 100644 --- a/specs/memory/notebooklm.t27 +++ b/specs/memory/notebooklm.t27 @@ -6,9 +6,9 @@ // phi^2 + 1/phi^2 = 3 | TRINITY module NotebookLM { - // 012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ════════════════════════════════════════════════════════════════════ // 1. Constants - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 + // ════════════════════════════════════════════════════════════════════ const VERSION : u32 = 1; const DEFAULT_TIMEOUT_MS : u32 = 30000; @@ -25,9 +25,9 @@ module NotebookLM { const CONNECTION_STATUS_CONNECTED : u8 = 2; const CONNECTION_STATUS_ERROR : u8 = 3; - // 136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 + // ════════════════════════════════════════════════════════════════════ // 2. Error Codes - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 + // ════════════════════════════════════════════════════════════════════ enum ErrorCode { Success = 0, @@ -43,9 +43,9 @@ module NotebookLM { UnknownError = 99, } - // 272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 + // ════════════════════════════════════════════════════════════════════ // 3. Authentication Types - // 340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ════════════════════════════════════════════════════════════════════ struct AuthTokens { cookie_header: str, @@ -61,9 +61,9 @@ module NotebookLM { auto_refresh: bool, } - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 + // ════════════════════════════════════════════════════════════════════ // 4. NotebookLM Client - // 476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ════════════════════════════════════════════════════════════════════ struct NotebookLMClient { config: NotebookLMConfig, @@ -72,9 +72,9 @@ module NotebookLM { auth: AuthTokens, } - // 544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 + // ════════════════════════════════════════════════════════════════════ // 5. Notebook Types - // 612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 + // ════════════════════════════════════════════════════════════════════ struct Notebook { id: str, @@ -93,9 +93,9 @@ module NotebookLM { created_at: u64, } - // 680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 + // ════════════════════════════════════════════════════════════════════ // 6. Query and Result Types - // 748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 + // ════════════════════════════════════════════════════════════════════ struct QueryResult { notebook_id: str, @@ -106,9 +106,9 @@ module NotebookLM { timestamp: u64, } - // 816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883 + // ════════════════════════════════════════════════════════════════════ // 7. Session Context Types - // 884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 + // ════════════════════════════════════════════════════════════════════ struct SessionContext { session_id: str, @@ -122,9 +122,9 @@ module NotebookLM { git_status: str, } - // 95295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019 + // ════════════════════════════════════════════════════════════════════ // 8. Wrap-up Types - // 10201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 + // ════════════════════════════════════════════════════════════════════ struct WrapupSummary { session: SessionContext, @@ -144,9 +144,9 @@ module NotebookLM { indexed_at: u64, } - // 10881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 + // ════════════════════════════════════════════════════════════════════ // 9. Client Functions - // 11561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223 + // ════════════════════════════════════════════════════════════════════ // client_new(config: NotebookLMConfig) -> NotebookLMClient // Create a new NotebookLM client with given configuration @@ -179,9 +179,9 @@ module NotebookLM { return ErrorCode::Success; } - // 12241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291 + // ════════════════════════════════════════════════════════════════════ // 10. Notebook Functions - // 12921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359 + // ════════════════════════════════════════════════════════════════════ // notebook_create(client: NotebookLMClient, title: str) -> (Notebook, ErrorCode) // Create a new notebook @@ -217,9 +217,9 @@ module NotebookLM { return ErrorCode::Success; } - // 13601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427 + // ════════════════════════════════════════════════════════════════════ // 11. Source Functions - // 14281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495 + // ════════════════════════════════════════════════════════════════════ // source_upload_text(client: NotebookLMClient, notebook_id: str, title: str, content: str) -> (Source, ErrorCode) // Upload text content as a source @@ -248,9 +248,9 @@ module NotebookLM { return ErrorCode::Success; } - // 14961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563 + // ════════════════════════════════════════════════════════════════════ // 12. Query Functions - // 15641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 + // ════════════════════════════════════════════════════════════════════ // notebook_query(client: NotebookLMClient, notebook_id: str, question: str) -> (QueryResult, ErrorCode) // Query a notebook with a question @@ -259,9 +259,9 @@ module NotebookLM { return (result, ErrorCode::Success); } - // 16321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699 + // ════════════════════════════════════════════════════════════════════ // 13. Session Functions - // 17001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767 + // ════════════════════════════════════════════════════════════════════ // session_extract_from_trinity(repo_root: str) -> (SessionContext, ErrorCode) // Extract session context from .trinity state files @@ -270,9 +270,9 @@ module NotebookLM { return (context, ErrorCode::Success); } - // 17681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835 + // ════════════════════════════════════════════════════════════════════ // 14. Wrap-up Functions - // 18361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903 + // ════════════════════════════════════════════════════════════════════ // wrapup_format_summary(session: SessionContext, summary: str, decisions: str, files: str, steps: str) -> WrapupSummary // Format a wrap-up summary from session data @@ -294,9 +294,9 @@ module NotebookLM { return (source, ErrorCode::Success); } - // 19041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971 + // ════════════════════════════════════════════════════════════════════ // 15. TDD - Tests - // 19721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039 + // ════════════════════════════════════════════════════════════════════ test "client_creation" var config : NotebookLMConfig = undefined; @@ -379,9 +379,9 @@ module NotebookLM { assert(wrapup.session.session_id == "test-session"); assert(wrapup.summary == "summary"); - // 20402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107 + // ════════════════════════════════════════════════════════════════════ // 16. TDD - Invariants - // 21082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175 + // ════════════════════════════════════════════════════════════════════ invariant confidence_always_valid var config : NotebookLMConfig = undefined; @@ -427,9 +427,9 @@ module NotebookLM { assert(ErrorCode::SourceNotFound > 0); assert(ErrorCode::NotebookNotFound > 0); - // 21762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243 + // ════════════════════════════════════════════════════════════════════ // 17. TDD - Benchmarks - // 22442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311 + // ════════════════════════════════════════════════════════════════════ bench client_creation_bench // Target: < 1000 cycles diff --git a/specs/neural/forward_pass.t27 b/specs/neural/forward_pass.t27 index 3524c6ae60..7333d082de 100644 --- a/specs/neural/forward_pass.t27 +++ b/specs/neural/forward_pass.t27 @@ -120,7 +120,7 @@ pub fn single_head_attention( } /// Multi-head forward pass with residual connection -/// Pipeline: position 0 3-head attention 1 bundle3 2 FFN 3 residual +/// Pipeline: position → 3-head attention → bundle3 → FFN → residual pub fn forward_pass_multi_head( context: &Context, roles: &Roles, @@ -162,7 +162,7 @@ pub fn summarize_context(context: &Context, dim: usize) -> Hypervector { } /// Direct forward pass: just bind(context_summary, role) -/// Only 1 bind operation 4 clean signal +/// Only 1 bind operation → clean signal pub fn forward_pass_direct( context: &Context, role: &Hypervector, diff --git a/specs/nn/attention.t27 b/specs/nn/attention.t27 index f5def92e0d..f5dd8dd6d2 100644 --- a/specs/nn/attention.t27 +++ b/specs/nn/attention.t27 @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/nn/attention.t27 // Sacred Attention Specification -// Multi-head attention with 0-RoPE and sacred scaling (d_k^(-12)) -// 34 + 1/56 = 3 | TRINITY +// Multi-head attention with φ-RoPE and sacred scaling (d_k^(-φ³)) +// φ² + 1/φ² = 3 | TRINITY module SacredAttention { // Import base types, operations, and math constants @@ -10,20 +10,20 @@ module SacredAttention { use base::ops; use math::constants; - // 7891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ═════════════════════════════════════════════════════════════════ // 1. Constants - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 + // ═════════════════════════════════════════════════════════════════════════ // TRINITY-based configuration const NUM_HEADS : usize = 3; // 3 heads (TRINITY) - const HEAD_DIM : usize = 81; // 81 dim per head (3145) - const EMBED_DIM : usize = 243; // Total embedding (3 146 81) + const HEAD_DIM : usize = 81; // 81 dim per head (3⁴) + const EMBED_DIM : usize = 243; // Total embedding (3 × 81) const CONTEXT_LEN : usize = 81; // Max sequence length const ROPE_PAIRS : usize = 40; // 81/2 = 40 pairs (1 unrotated) - // Sacred scaling: 147148149 and d_k^(-150151) - const SACRED_GAMMA : f64 = constants::PHI_CUBED_INV; // 152153154 155 0.236 - const SACRED_SCALE : f64 = pow(81.0, -SACRED_GAMMA); // 81^(-156157158) 159 0.354 + // Sacred scaling: φ⁻³ and d_k^(-φ³) + const SACRED_GAMMA : f64 = constants::PHI_CUBED_INV; // φ⁻³ ≈ 0.236 + const SACRED_SCALE : f64 = pow(81.0, -SACRED_GAMMA); // 81^(-φ⁻³) ≈ 0.354 // Attention types const ATTN_CAUSAL : u8 = 0; // Causal (autoregressive) attention @@ -38,13 +38,13 @@ module SacredAttention { const PHASE_SOFTMAX : u8 = 4; // Apply softmax const PHASE_WEIGHT : u8 = 5; // Apply to values - // 160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 + // ═════════════════════════════════════════════════════════════════ // 2. RoPE Tables - // 225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 + // ═════════════════════════════════════════════════════════════════════════ - // 298-RoPE tables: [CONTEXT_LEN 299 ROPE_PAIRS] - // Each entry is precomputed cos(p * 300_i) and sin(p * 301_i) - // where 302_i = 303^(-2i/HEAD_DIM) for i=0..ROPE_PAIRS-1 + // φ-RoPE tables: [CONTEXT_LEN × ROPE_PAIRS] + // Each entry is precomputed cos(p * θ_i) and sin(p * θ_i) + // where θ_i = φ^(-2i/HEAD_DIM) for i=0..ROPE_PAIRS-1 struct RoPETables { cos : [CONTEXT_LEN * ROPE_PAIRS]f64, sin : [CONTEXT_LEN * ROPE_PAIRS]f64, @@ -52,9 +52,9 @@ module SacredAttention { var rope_tables : RoPETables; - // 304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 + // ═════════════════════════════════════════════════════════════════ // 3. Attention State - // 369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 + // ═════════════════════════════════════════════════════════════════════════ // Attention buffers (allocated per forward pass) struct AttentionBuffers { @@ -65,14 +65,14 @@ module SacredAttention { concat : [EMBED_DIM]f64, // Concatenated head outputs } - // 442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506 + // ═════════════════════════════════════════════════════════════════ // 4. Initialization - // 507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579 + // ═════════════════════════════════════════════════════════════════════════ - // sacred_attention_init() 580 void - // Initialize 581-RoPE tables - // 582_i = 583^(-2i/HEAD_DIM) for i=0..ROPE_PAIRS-1 - // For each position p: cos(p*584_i), sin(p*585_i) + // sacred_attention_init() → void + // Initialize φ-RoPE tables + // θ_i = φ^(-2i/HEAD_DIM) for i=0..ROPE_PAIRS-1 + // For each position p: cos(p*θ_i), sin(p*θ_i) fn sacred_attention_init() -> void { var p : usize = 0; @@ -80,7 +80,7 @@ module SacredAttention { var i : usize = 0; while (i < ROPE_PAIRS) { - // Compute freq = 586^(-2i/HEAD_DIM) + // Compute freq = φ^(-2i/HEAD_DIM) const freq_exponent = -2.0 * (i as f64) / (HEAD_DIM as f64); const freq = pow(constants::PHI, freq_exponent); @@ -103,9 +103,9 @@ module SacredAttention { } } - // 587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651 + // ═════════════════════════════════════════════════════════════════ // 5. Main Attention Kernel - // 652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724 + // ═════════════════════════════════════════════════════════════════════════ // sacred_attention_kernel( // input: []f32, // [EMBED_DIM] input embeddings @@ -114,7 +114,7 @@ module SacredAttention { // seq_len: usize, // output: []f32, // [EMBED_DIM] output // cache_k: []f32, cache_v: []f32, // [CONTEXT_LEN][EMBED_DIM] - // ) 725 void + // ) → void // Single position forward pass with sacred scaling fn sacred_attention_kernel( input: []f64, @@ -135,7 +135,7 @@ module SacredAttention { // Step 1: Project Q, K, V via ternary matmul project_qkv(&buffers, input, w_q, w_k, w_v); - // Step 2: Apply 726-RoPE to Q and K + // Step 2: Apply φ-RoPE to Q and K apply_rope_qk(&buffers, position); // Step 3: Cache K and V @@ -157,14 +157,14 @@ module SacredAttention { add_residual(output, input); } - // 727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 + // ═════════════════════════════════════════════════════════════════ // 6. Q/K/V Projection - // 792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864 + // ═════════════════════════════════════════════════════════════════════════ - // project_qkv(buffers, input, w_q, w_k, w_v) 865 void + // project_qkv(buffers, input, w_q, w_k, w_v) → void // Compute Q, K, V projections using ternary matrix multiplication - // Q[i] = 866_j input[j] * W_q[j][i] - // Using ternary weights: W_q[j][i] 867 {-1, 0, +1} + // Q[i] = Σ_j input[j] * W_q[j][i] + // Using ternary weights: W_q[j][i] ∈ {-1, 0, +1} fn project_qkv( buffers: *AttentionBuffers, input: []f64, @@ -180,7 +180,7 @@ module SacredAttention { ternary_matmul(input, w_v, &buffers.v_buffer, EMBED_DIM, EMBED_DIM); } - // ternary_matmul(input, weights, output, in_dim, out_dim) 868 void + // ternary_matmul(input, weights, output, in_dim, out_dim) → void // Matrix multiplication with ternary weights fn ternary_matmul( input: []f64, @@ -212,12 +212,12 @@ module SacredAttention { } } - // 869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933 - // 7. 934-RoPE Application - // 93593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007 + // ═════════════════════════════════════════════════════════════════ + // 7. φ-RoPE Application + // ═════════════════════════════════════════════════════════════════════════ - // apply_rope_qk(buffers, position) 1008 void - // Apply 1009-RoPE rotation to Q and K + // apply_rope_qk(buffers, position) → void + // Apply φ-RoPE rotation to Q and K // Rotates pairs of dimensions using precomputed tables fn apply_rope_qk(buffers: *AttentionBuffers, position: usize) -> void { var h : usize = 0; @@ -253,11 +253,11 @@ module SacredAttention { } } - // 10101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074 + // ═════════════════════════════════════════════════════════════════ // 8. KV Caching - // 1075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147 + // ═════════════════════════════════════════════════════════════════════════ - // cache_kv(buffers, position, cache_k, cache_v) 1148 void + // cache_kv(buffers, position, cache_k, cache_v) → void // Cache K and V at the current position fn cache_kv( buffers: *AttentionBuffers, @@ -274,11 +274,11 @@ module SacredAttention { } } - // 11491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213 + // ═════════════════════════════════════════════════════════════════ // 9. Score Computation - // 1214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286 + // ═════════════════════════════════════════════════════════════════════════ - // compute_scores(buffers, position, seq_len, cache_k) 1287 void + // compute_scores(buffers, position, seq_len, cache_k) → void // Compute attention scores: Q @ K^T * SACRED_SCALE // For causal attention: only positions <= current position fn compute_scores( @@ -301,7 +301,7 @@ module SacredAttention { continue; } - // Compute dot product: Q_head 1288 K_head[j] + // Compute dot product: Q_head · K_head[j] var score : f64 = 0.0; var d : usize = 0; @@ -321,13 +321,13 @@ module SacredAttention { } } - // 12891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353 + // ═════════════════════════════════════════════════════════════════ // 10. Softmax - // 1354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426 + // ═════════════════════════════════════════════════════════════════════════ - // apply_softmax(buffers, seq_len) 1427 void + // apply_softmax(buffers, seq_len) → void // Apply softmax to attention scores for each head - // softmax(x) = exp(x - max) / 1428 exp(x - max) + // softmax(x) = exp(x - max) / Σ exp(x - max) fn apply_softmax(buffers: *AttentionBuffers, seq_len: usize) -> void { var h : usize = 0; @@ -367,12 +367,12 @@ module SacredAttention { } } - // 14291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493 + // ═════════════════════════════════════════════════════════════════ // 11. Weighted Value Sum - // 1494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566 + // ═════════════════════════════════════════════════════════════════════════ - // weighted_values(buffers, seq_len, cache_v) 1567 void - // Compute weighted sum of values: output = 1568 attention[j] * V[j] + // weighted_values(buffers, seq_len, cache_v) → void + // Compute weighted sum of values: output = Σ attention[j] * V[j] fn weighted_values( buffers: *AttentionBuffers, seq_len: usize, @@ -403,11 +403,11 @@ module SacredAttention { } } - // 15691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633 + // ═════════════════════════════════════════════════════════════════ // 12. Output Projection - // 1634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706 + // ═════════════════════════════════════════════════════════════════════════ - // project_output(buffers, w_o, output) 1707 void + // project_output(buffers, w_o, output) → void // Apply output projection: output = concat @ W_o // Using ternary weights fn project_output( @@ -418,11 +418,11 @@ module SacredAttention { ternary_matmul(buffers.concat, w_o, output, EMBED_DIM, EMBED_DIM); } - // 17081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772 + // ═════════════════════════════════════════════════════════════════ // 13. Residual Connection - // 1773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845 + // ═════════════════════════════════════════════════════════════════════════ - // add_residual(output, input) 1846 void + // add_residual(output, input) → void // Add residual connection: output = output + input fn add_residual(output: []f64, input: []f64) -> void { var i : usize = 0; @@ -433,9 +433,9 @@ module SacredAttention { } } - // 1847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for SacredAttention - // 1950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test attn_sacred_scaling_constant given scale = SACRED_SCALE diff --git a/specs/nn/hslm.t27 b/specs/nn/hslm.t27 index 87602fc4b5..ae649f051a 100644 --- a/specs/nn/hslm.t27 +++ b/specs/nn/hslm.t27 @@ -2,7 +2,7 @@ // t27/specs/nn/hslm.t27 // HSLM (Hierarchical Sacred Learning Model) Specification // Ternary neural network with sacred constants and VSA attention -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module HSLM { // Import base types, math, numeric, and attention @@ -13,16 +13,16 @@ module HSLM { use numeric::gf16; use nn::attention; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 + // ═════════════════════════════════════════════════════════════════ // 1. HSLM Configuration - // 69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 + // ═════════════════════════════════════════════════════════════════════════ // TRINITY-based architecture const NUM_LAYERS : usize = 6; // 6 transformer-like layers const NUM_HEADS : usize = 3; // 3 attention heads per layer - const HEAD_DIM : usize = 81; // 81 dim per head (3142) - const EMBED_DIM : usize = 243; // 243 total embedding (3 143 81) - const FF_DIM : usize = 972; // 4 144 EMBED_DIM (3145 146 4) + const HEAD_DIM : usize = 81; // 81 dim per head (3⁴) + const EMBED_DIM : usize = 243; // 243 total embedding (3 × 81) + const FF_DIM : usize = 972; // 4 × EMBED_DIM (3⁴ × 4) const CONTEXT_LEN : usize = 81; // Max sequence length const VSA_DIM : usize = 1024; // VSA hypervector dimension @@ -43,9 +43,9 @@ module HSLM { const PHASE_BACKWARD : u8 = 1; // Backward pass const PHASE_UPDATE : u8 = 2; // Weight update - // 147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 + // ═════════════════════════════════════════════════════════════════ // 2. HSLM State - // 212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 + // ═════════════════════════════════════════════════════════════════════════ // Training/inference mode var hslm_mode : u8 = PHASE_FORWARD; @@ -81,11 +81,11 @@ module HSLM { layers : [NUM_LAYERS]LayerWeights, } - // 285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 + // ═════════════════════════════════════════════════════════════════ // 3. HSLM Forward Pass - // 350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 + // ═════════════════════════════════════════════════════════════════════════ - // hslm_forward(input, weights, seq_len, output, caches) 423 void + // hslm_forward(input, weights, seq_len, output, caches) → void // Full forward pass through all HSLM layers fn hslm_forward( input: [][]f64, // [seq_len][EMBED_DIM] @@ -129,7 +129,7 @@ module HSLM { } } - // hslm_layer_forward(buffers, weights, position, seq_len, cache) 424 void + // hslm_layer_forward(buffers, weights, position, seq_len, cache) → void // Single transformer layer: Attention + FFN with residual connections fn hslm_layer_forward( buffers: *LayerBuffers, @@ -191,12 +191,12 @@ module HSLM { } } - // 425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 + // ═════════════════════════════════════════════════════════════════ // 4. RMS Normalization - // 490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 + // ═════════════════════════════════════════════════════════════════════════ - // rms_norm_forward(x, gamma) 563 void (in-place) - // RMSNorm: output = (input / sqrt(mean(input564) + eps)) * gamma + // rms_norm_forward(x, gamma) → void (in-place) + // RMSNorm: output = (input / sqrt(mean(input²) + eps)) * gamma // Uses sacred gamma from math/sacred_physics fn rms_norm_forward(x: []f64, gamma: []f64) -> void { // Compute mean of squares @@ -220,11 +220,11 @@ module HSLM { } } - // 565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629 + // ═════════════════════════════════════════════════════════════════ // 5. Feed-Forward Network - // 630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702 + // ═════════════════════════════════════════════════════════════════════════ - // ffn_forward(buffers, weights) 703 void + // ffn_forward(buffers, weights) → void // Feed-forward network: Gelu(x @ W1) @ W2 // Using ternary weights, sacred expansion fn ffn_forward(buffers: *LayerBuffers, weights: *LayerWeights) -> void { @@ -238,7 +238,7 @@ module HSLM { ternary_matmul(buffers.ffn_intermediate, weights.w2, buffers.output, FF_DIM, EMBED_DIM); } - // ternary_matmul(input, weights, output, in_dim, out_dim) 704 void + // ternary_matmul(input, weights, output, in_dim, out_dim) → void // Matrix multiplication with ternary weights fn ternary_matmul( input: []f64, @@ -270,9 +270,9 @@ module HSLM { } } - // gelu_activation(x) 705 void (in-place) - // GELU: x * 706(x) where 707 is standard normal CDF - // Approximation: x * 0.5 * (1 + tanh(708(2/709) * (x + 0.044715x710))) + // gelu_activation(x) → void (in-place) + // GELU: x * Φ(x) where Φ is standard normal CDF + // Approximation: x * 0.5 * (1 + tanh(√(2/π) * (x + 0.044715x³))) fn gelu_activation(x: []f64) -> void { const sqrt_2_over_pi = sqrt(2.0 / 3.141592653589793); var i : usize = 0; @@ -287,11 +287,11 @@ module HSLM { } } - // 711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775 + // ═════════════════════════════════════════════════════════════════ // 6. HSLM Backward Pass - // 776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848 + // ═════════════════════════════════════════════════════════════════════════ - // hslm_backward(grad_output, weights, seq_len, grad_input) 849 void + // hslm_backward(grad_output, weights, seq_len, grad_input) → void // Full backward pass with gradient computation fn hslm_backward( grad_output: [][]f64, // [seq_len][EMBED_DIM] @@ -312,7 +312,7 @@ module HSLM { } } - // zero_weight_gradients() 850 HSLMWeights + // zero_weight_gradients() → HSLMWeights // Initialize all weight gradients to zero fn zero_weight_gradients() -> HSLMWeights { var weights : HSLMWeights = undefined; @@ -331,7 +331,7 @@ module HSLM { return weights; } - // hslm_layer_backward(grads, layer_idx) 851 void + // hslm_layer_backward(grads, layer_idx) → void // Single layer backward: FFN + Attention gradients fn hslm_layer_backward(grads: *HSLMWeights, layer_idx: usize) -> void { // Gradient flows backward through: residual -> ffn -> norm -> residual -> attn -> norm @@ -342,7 +342,7 @@ module HSLM { attention_backward(grads, layer_idx); } - // ffn_backward(grads, layer_idx) 852 void + // ffn_backward(grads, layer_idx) → void // Backward through FFN: compute gradients for W2, W1, and input fn ffn_backward(grads: *HSLMWeights, layer_idx: usize) -> void { // Step 1: Gradient through second projection (W2) @@ -355,7 +355,7 @@ module HSLM { ffn_backward_w1(grads, layer_idx); } - // ffn_backward_w2(grads, layer_idx) 853 void + // ffn_backward_w2(grads, layer_idx) → void // Gradient through second FFN projection fn ffn_backward_w2(grads: *HSLMWeights, layer_idx: usize) -> void { // Gradient: dL/dW2 = dL/dout * x^T @@ -363,31 +363,31 @@ module HSLM { // Implementation depends on stored intermediate values } - // gelu_backward(layer_idx) 854 void + // gelu_backward(layer_idx) → void // Gradient through GELU activation fn gelu_backward(layer_idx: usize) -> void { - // GELU derivative: dGELU/dx = 855(x) + x * 856(x) - // where 857 is standard normal PDF + // GELU derivative: dGELU/dx = Φ(x) + x * φ(x) + // where φ is standard normal PDF } - // ffn_backward_w1(grads, layer_idx) 858 void + // ffn_backward_w1(grads, layer_idx) → void // Gradient through first FFN projection fn ffn_backward_w1(grads: *HSLMWeights, layer_idx: usize) -> void { // Gradient: dL/dW1 = dL/dmid * x^T // dL/dx = W1^T * dL/dmid } - // attention_backward(grads, layer_idx) 859 void + // attention_backward(grads, layer_idx) → void // Gradient through attention block fn attention_backward(grads: *HSLMWeights, layer_idx: usize) -> void { // Gradient flows through: output projection -> attention weights -> Q/K/V projections } - // 860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924 + // ═════════════════════════════════════════════════════════════════ // 7. Phase Management - // 925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997 + // ═════════════════════════════════════════════════════════════════════════ - // hslm_phase(phase: u8) 998 void + // hslm_phase(phase: u8) → void // Switch HSLM phase (forward, backward, update) // Used for streaming inference and training fn hslm_phase(phase: u8) -> void { @@ -400,15 +400,15 @@ module HSLM { } } - // get_hslm_mode() 999 u8 + // get_hslm_mode() → u8 // Get current HSLM mode fn get_hslm_mode() -> u8 { return hslm_mode; } - // 1000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for HSLM - // 1103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test hslm_num_layers_is_six given layers = NUM_LAYERS diff --git a/specs/numeric/bigint.t27 b/specs/numeric/bigint.t27 index 9a9ff9f23f..1b81aaa554 100644 --- a/specs/numeric/bigint.t27 +++ b/specs/numeric/bigint.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Module: Balanced Ternary BigInt -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module BigInt { // ======================================================================== diff --git a/specs/numeric/formats.t27 b/specs/numeric/formats.t27 index 762a1e744b..7033b92069 100644 --- a/specs/numeric/formats.t27 +++ b/specs/numeric/formats.t27 @@ -36,7 +36,7 @@ module Formats { pub const ExpMin : u16 = 0; // ======================================================================== - // 2. GF16 0 f32 (decode) + // 2. GF16 → f32 (decode) // ======================================================================== // // Converts GF16 encoding to IEEE 754 binary32 floating point. @@ -61,7 +61,7 @@ module Formats { pub fn gf16_to_f32(x: u16) -> gf16; // ======================================================================== - // 3. f32 1 GF16 (encode, round-to-nearest) + // 3. f32 → GF16 (encode, round-to-nearest) // ======================================================================== // // Converts IEEE 754 binary32 floating point to GF16 encoding. diff --git a/specs/numeric/gf12.t27 b/specs/numeric/gf12.t27 index 9629152355..f30b87cff3 100644 --- a/specs/numeric/gf12.t27 +++ b/specs/numeric/gf12.t27 @@ -1,16 +1,16 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/gf12.t27 -// GoldenFloat12 0 12-bit 1-structured floating point -// NUMERIC-STANDARD-001 2 Agent 4 (P1) +// GoldenFloat12 — 12-bit φ-structured floating point +// NUMERIC-STANDARD-001 — Agent 4 (P1) module GF12 { // Import base format family use numeric::goldenfloat_family; use numeric::phi_ratio; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Format Definition - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // GF12 bit layout: [S|EEEE|MMM MMMM] // S: 1 bit (sign) @@ -25,21 +25,21 @@ module GF12 { // Bias for exponent (2^(4-1) - 1 = 7) const EXP_BIAS : u8 = 7; - // 141-ratio: exp/mant = 4/7 142 0.571 (phi_distance = 0.047) - // This is the closest to 1/143 among all formats + // φ-ratio: exp/mant = 4/7 ≈ 0.571 (phi_distance = 0.047) + // This is the closest to 1/φ among all formats const PHI_DISTANCE : f64 = 0.04660512288042107; - // 144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 + // ═════════════════════════════════════════════════════════════════ // 2. GoldenFloat12 Type - // 209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 + // ═════════════════════════════════════════════════════════════════════════ struct GF12 { raw : u16, // 12-bit value stored in u16 } - // 282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 + // ═════════════════════════════════════════════════════════════════ // 3. Encoding/Decoding - // 347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 + // ═════════════════════════════════════════════════════════════════════════ // Encode f32 to GF12 fn encode(value: f32) -> GF12 { @@ -98,9 +98,9 @@ module GF12 { return value; } - // 420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 + // ═════════════════════════════════════════════════════════════════ // 4. Format Properties - // 485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 + // ═════════════════════════════════════════════════════════════════════════ fn max_value() -> f32 { const mant_max = 1.0 + 127.0 / 128.0; @@ -118,9 +118,9 @@ module GF12 { return 1.0 / 128.0; // 0.0078125 } - // 558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622 + // ═════════════════════════════════════════════════════════════════ // 5. Validation - // 623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 + // ═════════════════════════════════════════════════════════════════════════ fn validate_format() -> bool { const fmt = goldenfloat_family::get_format_by_name("GF12"); @@ -130,12 +130,12 @@ module GF12 { (fmt.?.mant_bits == MANT_BITS); } - // 696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 + // ═════════════════════════════════════════════════════════════════ // 6. Use Cases - // 761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 + // ═════════════════════════════════════════════════════════════════════════ // GF12 is optimal for: - // - Best 834-approximation (lowest phi_distance) + // - Best φ-approximation (lowest phi_distance) // - High-precision quantization // - Critical path weights // - Attention matrices @@ -143,9 +143,9 @@ module GF12 { // Memory: 12 bits = 1.5 bytes (~2.67x FP32 in same space) const MEMORY_RATIO_VS_FP32 : f32 = 12.0 / 32.0; // 0.375 - // 835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 + // ═════════════════════════════════════════════════════════════════ // 7. Helper Functions - // 900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972 + // ═════════════════════════════════════════════════════════════════════════ fn floor_log2(x: f32) -> i8 { if (x <= 0.0) { return -128; } @@ -287,9 +287,9 @@ module GF12 { return (xi - 1) as f32; } - // 9739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for GF12 - // 1076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gf12_decode_zero given gf = GF12{ raw = 0 } diff --git a/specs/numeric/gf16.t27 b/specs/numeric/gf16.t27 index 05c22c6797..f91384e57f 100644 --- a/specs/numeric/gf16.t27 +++ b/specs/numeric/gf16.t27 @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -; gf16.t27 0 GoldenFloat16 Encode/Decode +; gf16.t27 — GoldenFloat16 Encode/Decode ; GF16: 16-bit floating point with 1 sign + 6 exponent + 9 mantissa ; Bit layout: [S(1) E(6) M(9)] = [15:15][14:9][8:0] -; 12 + 1/34 = 3 | TRINITY +; φ² + 1/φ² = 3 | TRINITY module triformat-gf16; @@ -58,7 +58,7 @@ pub const pow2_table : [32]u16 = [32]u16{ // Functions // ============================================================================ -// gf16_extract_sign(gf16: GF16) 5 i8 +// gf16_extract_sign(gf16: GF16) → i8 // Extract sign bit (bit 15) // Returns: 0 for positive, -1 for negative pub fn gf16_extract_sign(gf16: GF16) i8 { @@ -66,21 +66,21 @@ pub fn gf16_extract_sign(gf16: GF16) i8 { return if (bit != 0) -1 else 0; } -// gf16_extract_exponent(gf16: GF16) 6 i8 +// gf16_extract_exponent(gf16: GF16) → i8 // Extract exponent bits (bits 14-9) // Returns: 0-63 pub fn gf16_extract_exponent(gf16: GF16) i8 { return @as(i8, @intCast((gf16 >> EXP_SHIFT) & EXP_MASK)); } -// gf16_extract_mantissa(gf16: GF16) 7 i16 +// gf16_extract_mantissa(gf16: GF16) → i16 // Extract mantissa bits (bits 8-0) // Returns: 0-511 pub fn gf16_extract_mantissa(gf16: GF16) i16 { return @as(i16, gf16 & MANT_MASK); } -// gf16_from_components(sign: i8, exp: i8, mant: i16) 8 GF16 +// gf16_from_components(sign: i8, exp: i8, mant: i16) → GF16 // Assemble GF16 from sign, exponent, mantissa pub fn gf16_from_components(sign: i8, exp: i8, mant: i16) GF16 { const sign_bit = if (sign < 0) 1 else 0; @@ -89,19 +89,19 @@ pub fn gf16_from_components(sign: i8, exp: i8, mant: i16) GF16 { @as(GF16, @intCast(mant)); } -// gf16_is_zero(gf16: GF16) 9 bool +// gf16_is_zero(gf16: GF16) → bool // Check if GF16 is zero (positive or negative) pub fn gf16_is_zero(gf16: GF16) bool { return gf16 == GF16_ZERO_POS or gf16 == GF16_ZERO_NEG; } -// gf16_is_special(gf16: GF16) 10 bool +// gf16_is_special(gf16: GF16) → bool // Check if GF16 is Inf or NaN (exp == 63) pub fn gf16_is_special(gf16: GF16) bool { return gf16_extract_exponent(gf16) == EXP_MAX; } -// gf16_encode_f32(f32: f32) 11 GF16 +// gf16_encode_f32(f32: f32) → GF16 // Encode IEEE 754 single precision to GF16 // Round-to-nearest, ties to even // Range: 2^-31 to 2^32 (normal), subnormals flushed to zero @@ -151,7 +151,7 @@ pub fn gf16_encode_f32(value: f32) GF16 { return gf16_from_components(sign, gf16_exp, mant); } -// gf16_decode_to_f32(gf16: GF16) 12 f32 +// gf16_decode_to_f32(gf16: GF16) → f32 // Decode GF16 to IEEE 754 single precision pub fn gf16_decode_to_f32(gf16: GF16) f32 { // Handle zero @@ -185,10 +185,10 @@ pub fn gf16_decode_to_f32(gf16: GF16) f32 { return sign_mult * mant_mult * exp_mult; } -// gf16_round_phi(value: f32) 13 GF16 +// gf16_round_phi(value: f32) → GF16 // Phi-optimized rounding for GF16 // Uses golden ratio bias for rounding decisions instead of standard round-to-nearest -// Bias = (1/14 - 0.5) * scale, where 1/15 16 0.618 +// Bias = (1/φ - 0.5) * scale, where 1/φ ≈ 0.618 // This improves numerical stability for sacred physics calculations pub fn gf16_round_phi(value: f32) GF16 { // Handle zero @@ -234,7 +234,7 @@ pub fn gf16_round_phi(value: f32) GF16 { return gf16_from_components(sign, gf16_exp, mant); } -// gf16_is_inf(gf16: GF16) 17 bool +// gf16_is_inf(gf16: GF16) → bool // Check if GF16 represents infinity pub fn gf16_is_inf(gf16: GF16) bool { const exp = gf16_extract_exponent(gf16); @@ -242,7 +242,7 @@ pub fn gf16_is_inf(gf16: GF16) bool { return (exp == EXP_MAX) and (mant == 0); } -// gf16_is_nan(gf16: GF16) 18 bool +// gf16_is_nan(gf16: GF16) → bool // Check if GF16 represents NaN (Not a Number) pub fn gf16_is_nan(gf16: GF16) bool { const exp = gf16_extract_exponent(gf16); @@ -250,33 +250,33 @@ pub fn gf16_is_nan(gf16: GF16) bool { return (exp == EXP_MAX) and (mant != 0); } -// gf16_is_negative(gf16: GF16) 19 bool +// gf16_is_negative(gf16: GF16) → bool // Check if GF16 is negative (excluding negative zero) pub fn gf16_is_negative(gf16: GF16) bool { const sign = gf16_extract_sign(gf16); return (sign < 0) and !gf16_is_zero(gf16); } -// gf16_is_positive(gf16: GF16) 20 bool +// gf16_is_positive(gf16: GF16) → bool // Check if GF16 is positive (excluding positive zero) pub fn gf16_is_positive(gf16: GF16) bool { const sign = gf16_extract_sign(gf16); return (sign >= 0) and !gf16_is_zero(gf16); } -// gf16_negate(gf16: GF16) 21 GF16 +// gf16_negate(gf16: GF16) → GF16 // Negate a GF16 value (flip sign bit) pub fn gf16_negate(gf16: GF16) GF16 { return gf16 ^ SIGN_MASK; } -// gf16_abs(gf16: GF16) 22 GF16 +// gf16_abs(gf16: GF16) → GF16 // Absolute value of GF16 (clear sign bit) pub fn gf16_abs(gf16: GF16) GF16 { return gf16 & ~SIGN_MASK; } -// gf16_copy_sign(gf16: GF16, sign_source: GF16) 23 GF16 +// gf16_copy_sign(gf16: GF16, sign_source: GF16) → GF16 // Copy sign from sign_source to gf16 value pub fn gf16_copy_sign(gf16: GF16, sign_source: GF16) GF16 { const sign_mask = sign_source & SIGN_MASK; @@ -284,7 +284,7 @@ pub fn gf16_copy_sign(gf16: GF16, sign_source: GF16) GF16 { return value_mask | sign_mask; } -// gf16_max(a: GF16, b: GF16) 24 GF16 +// gf16_max(a: GF16, b: GF16) → GF16 // Return the greater of two GF16 values pub fn gf16_max(a: GF16, b: GF16) GF16 { if (gf16_is_nan(a)) return b; @@ -296,7 +296,7 @@ pub fn gf16_max(a: GF16, b: GF16) GF16 { if (a_val >= b_val) return a else return b; } -// gf16_min(a: GF16, b: GF16) 25 GF16 +// gf16_min(a: GF16, b: GF16) → GF16 // Return the smaller of two GF16 values pub fn gf16_min(a: GF16, b: GF16) GF16 { if (gf16_is_nan(a)) return b; @@ -308,7 +308,7 @@ pub fn gf16_min(a: GF16, b: GF16) GF16 { if (a_val <= b_val) return a else return b; } -// gf16_add(a: GF16, b: GF16) 26 GF16 +// gf16_add(a: GF16, b: GF16) → GF16 // Add two GF16 values (decode, add, re-encode) // Returns NaN if either operand is NaN, Inf if overflow pub fn gf16_add(a: GF16, b: GF16) GF16 { @@ -330,7 +330,7 @@ pub fn gf16_add(a: GF16, b: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_sub(a: GF16, b: GF16) 27 GF16 +// gf16_sub(a: GF16, b: GF16) → GF16 // Subtract two GF16 values (decode, subtract, re-encode) // Returns NaN if either operand is NaN, Inf if overflow pub fn gf16_sub(a: GF16, b: GF16) GF16 { @@ -352,7 +352,7 @@ pub fn gf16_sub(a: GF16, b: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_mul(a: GF16, b: GF16) 28 GF16 +// gf16_mul(a: GF16, b: GF16) → GF16 // Multiply two GF16 values (decode, multiply, re-encode) // Returns NaN if either operand is NaN pub fn gf16_mul(a: GF16, b: GF16) GF16 { @@ -379,7 +379,7 @@ pub fn gf16_mul(a: GF16, b: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_div(a: GF16, b: GF16) 29 GF16 +// gf16_div(a: GF16, b: GF16) → GF16 // Divide two GF16 values (decode, divide, re-encode) // Returns NaN if division by zero or either operand is NaN // Returns Inf if numerator is Inf and denominator is finite non-zero @@ -412,7 +412,7 @@ pub fn gf16_div(a: GF16, b: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_fma(a: GF16, b: GF16, c: GF16) 30 GF16 +// gf16_fma(a: GF16, b: GF16, c: GF16) → GF16 // Fused multiply-add: a * b + c with single rounding // More accurate than separate mul and add pub fn gf16_fma(a: GF16, b: GF16, c: GF16) GF16 { @@ -434,7 +434,7 @@ pub fn gf16_fma(a: GF16, b: GF16, c: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_sqrt(a: GF16) 31 GF16 +// gf16_sqrt(a: GF16) → GF16 // Square root of GF16 value // Returns NaN for negative values, Inf for infinity pub fn gf16_sqrt(a: GF16) GF16 { @@ -450,14 +450,14 @@ pub fn gf16_sqrt(a: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_square(a: GF16) 32 GF16 +// gf16_square(a: GF16) → GF16 // Square of GF16 value // Uses gf16_mul internally pub fn gf16_square(a: GF16) GF16 { return gf16_mul(a, a); } -// gf16_eq(a: GF16, b: GF16) 33 bool +// gf16_eq(a: GF16, b: GF16) → bool // Equality comparison for GF16 // NaN values are never equal to anything (including themselves) pub fn gf16_eq(a: GF16, b: GF16) bool { @@ -467,14 +467,14 @@ pub fn gf16_eq(a: GF16, b: GF16) bool { return a == b; } -// gf16_ne(a: GF16, b: GF16) 34 bool +// gf16_ne(a: GF16, b: GF16) → bool // Not-equal comparison for GF16 // NaN values are not equal to anything (including themselves) pub fn gf16_ne(a: GF16, b: GF16) bool { return !gf16_eq(a, b); } -// gf16_lt(a: GF16, b: GF16) 35 bool +// gf16_lt(a: GF16, b: GF16) → bool // Less-than comparison for GF16 // Returns false if either operand is NaN pub fn gf16_lt(a: GF16, b: GF16) bool { @@ -484,7 +484,7 @@ pub fn gf16_lt(a: GF16, b: GF16) bool { return a_val < b_val; } -// gf16_le(a: GF16, b: GF16) 36 bool +// gf16_le(a: GF16, b: GF16) → bool // Less-than-or-equal comparison for GF16 // Returns false if either operand is NaN pub fn gf16_le(a: GF16, b: GF16) bool { @@ -494,7 +494,7 @@ pub fn gf16_le(a: GF16, b: GF16) bool { return a_val <= b_val; } -// gf16_gt(a: GF16, b: GF16) 37 bool +// gf16_gt(a: GF16, b: GF16) → bool // Greater-than comparison for GF16 // Returns false if either operand is NaN pub fn gf16_gt(a: GF16, b: GF16) bool { @@ -504,7 +504,7 @@ pub fn gf16_gt(a: GF16, b: GF16) bool { return a_val > b_val; } -// gf16_ge(a: GF16, b: GF16) 38 bool +// gf16_ge(a: GF16, b: GF16) → bool // Greater-than-or-equal comparison for GF16 // Returns false if either operand is NaN pub fn gf16_ge(a: GF16, b: GF16) bool { @@ -514,7 +514,7 @@ pub fn gf16_ge(a: GF16, b: GF16) bool { return a_val >= b_val; } -// gf16_floor(a: GF16) 39 GF16 +// gf16_floor(a: GF16) → GF16 // Round down to the nearest integer (toward -inf) // Returns NaN for NaN input, unchanged for Inf/-Inf pub fn gf16_floor(a: GF16) GF16 { @@ -528,7 +528,7 @@ pub fn gf16_floor(a: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_ceil(a: GF16) 40 GF16 +// gf16_ceil(a: GF16) → GF16 // Round up to the nearest integer (toward +inf) // Returns NaN for NaN input, unchanged for Inf/-Inf pub fn gf16_ceil(a: GF16) GF16 { @@ -542,7 +542,7 @@ pub fn gf16_ceil(a: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_round(a: GF16) 41 GF16 +// gf16_round(a: GF16) → GF16 // Round to nearest integer, ties to even (IEEE 754 roundTiesToEven) // Returns NaN for NaN input, unchanged for Inf/-Inf pub fn gf16_round(a: GF16) GF16 { @@ -556,7 +556,7 @@ pub fn gf16_round(a: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_trunc(a: GF16) 42 GF16 +// gf16_trunc(a: GF16) → GF16 // Round toward zero (truncate fractional part) // Returns NaN for NaN input, unchanged for Inf/-Inf pub fn gf16_trunc(a: GF16) GF16 { @@ -570,7 +570,7 @@ pub fn gf16_trunc(a: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_fms(a: GF16, b: GF16, c: GF16) 43 GF16 +// gf16_fms(a: GF16, b: GF16, c: GF16) → GF16 // Fused multiply-subtract: a * b - c with single rounding // More accurate than separate mul and sub // Useful for neural network backpropagation @@ -593,7 +593,7 @@ pub fn gf16_fms(a: GF16, b: GF16, c: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_hypot(a: GF16, b: GF16) 44 GF16 +// gf16_hypot(a: GF16, b: GF16) → GF16 // Compute sqrt(a^2 + b^2) without overflow/underflow // Returns NaN if either operand is NaN, Inf if both are Inf // Useful for distance calculations, neural network normalization @@ -620,7 +620,7 @@ pub fn gf16_hypot(a: GF16, b: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_fmod(a: GF16, b: GF16) 45 GF16 +// gf16_fmod(a: GF16, b: GF16) → GF16 // Compute remainder of a / b (IEEE 754 style) // Result has same sign as dividend (a) // Returns NaN if divisor is zero or either operand is NaN @@ -641,13 +641,13 @@ pub fn gf16_fmod(a: GF16, b: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_is_finite(gf16: GF16) 46 bool +// gf16_is_finite(gf16: GF16) → bool // Check if GF16 value is finite (not NaN, not infinity) pub fn gf16_is_finite(gf16: GF16) bool { return !gf16_is_nan(gf16) and !gf16_is_inf(gf16); } -// gf16_is_normal(gf16: GF16) 47 bool +// gf16_is_normal(gf16: GF16) → bool // Check if GF16 value is a normal (normalized) number // Normal numbers have exponent in range [1, EXP_MAX-1] and are not zero pub fn gf16_is_normal(gf16: GF16) bool { @@ -660,7 +660,7 @@ pub fn gf16_is_normal(gf16: GF16) bool { return exp > 0 and exp < GF16_EXP_MAX; } -// gf16_is_subnormal(gf16: GF16) 48 bool +// gf16_is_subnormal(gf16: GF16) → bool // Check if GF16 value is subnormal (denormal) // Subnormal numbers have exponent = 0 and mantissa != 0 pub fn gf16_is_subnormal(gf16: GF16) bool { @@ -675,14 +675,14 @@ pub fn gf16_is_subnormal(gf16: GF16) bool { return exp == 0 and mant != 0; } -// gf16_signbit(gf16: GF16) 49 bool +// gf16_signbit(gf16: GF16) → bool // Check if the sign bit is set (value is negative or negative zero) // Returns true for negative values and negative zero pub fn gf16_signbit(gf16: GF16) bool { return (gf16 & GF16_SIGN_MASK) != 0; } -// gf16_sign(gf16: GF16) 50 i8 +// gf16_sign(gf16: GF16) → i8 // Return the sign of the GF16 value: -1 for negative, 0 for zero, +1 for positive // Returns 0 for NaN (IEEE 754 specifies sign of NaN is undefined) pub fn gf16_sign(gf16: GF16) i8 { @@ -701,7 +701,7 @@ pub fn gf16_sign(gf16: GF16) i8 { } } -// gf16_clamp(x: GF16, min_val: GF16, max_val: GF16) 51 GF16 +// gf16_clamp(x: GF16, min_val: GF16, max_val: GF16) → GF16 // Clamp x to the range [min_val, max_val] // Returns min_val if x < min_val, max_val if x > max_val, otherwise x pub fn gf16_clamp(x: GF16, min_val: GF16, max_val: GF16) GF16 { @@ -723,7 +723,7 @@ pub fn gf16_clamp(x: GF16, min_val: GF16, max_val: GF16) GF16 { } } -// gf16_lerp(a: GF16, b: GF16, t: GF16) 52 GF16 +// gf16_lerp(a: GF16, b: GF16, t: GF16) → GF16 // Linear interpolation: a + t * (b - a) // Returns a when t=0, b when t=1, and interpolates for other values pub fn gf16_lerp(a: GF16, b: GF16, t: GF16) GF16 { @@ -742,7 +742,7 @@ pub fn gf16_lerp(a: GF16, b: GF16, t: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_fnma(a: GF16, b: GF16, c: GF16) 53 GF16 +// gf16_fnma(a: GF16, b: GF16, c: GF16) → GF16 // Fused negative multiply-add: -(a * b) + c // More accurate than computing gf16_sub(c, gf16_mul(a, b)) pub fn gf16_fnma(a: GF16, b: GF16, c: GF16) GF16 { @@ -790,7 +790,7 @@ pub fn gf16_fnma(a: GF16, b: GF16, c: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_exp(x: GF16) 54 GF16 +// gf16_exp(x: GF16) → GF16 // Compute e^x (exponential function) // Uses Taylor series approximation for small values // Returns Inf for very large positive inputs, 0 for very large negative inputs @@ -829,7 +829,7 @@ pub fn gf16_exp(x: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_log(x: GF16) 55 GF16 +// gf16_log(x: GF16) → GF16 // Compute natural logarithm ln(x) // Returns NaN for x <= 0, Inf for very large x pub fn gf16_log(x: GF16) GF16 { @@ -855,7 +855,7 @@ pub fn gf16_log(x: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_log2(x: GF16) 56 GF16 +// gf16_log2(x: GF16) → GF16 // Compute base-2 logarithm log2(x) pub fn gf16_log2(x: GF16) GF16 { if (gf16_is_nan(x)) return GF16_NAN; @@ -873,7 +873,7 @@ pub fn gf16_log2(x: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_log10(x: GF16) 57 GF16 +// gf16_log10(x: GF16) → GF16 // Compute base-10 logarithm log10(x) pub fn gf16_log10(x: GF16) GF16 { if (gf16_is_nan(x)) return GF16_NAN; @@ -891,7 +891,7 @@ pub fn gf16_log10(x: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_pow(base: GF16, exponent: GF16) 58 GF16 +// gf16_pow(base: GF16, exponent: GF16) → GF16 // Compute base^exponent // Handles various special cases: 0^0 = 1, 1^x = 1, x^0 = 1, etc. pub fn gf16_pow(base: GF16, exponent: GF16) GF16 { @@ -926,7 +926,7 @@ pub fn gf16_pow(base: GF16, exponent: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_sin(x: GF16) 59 GF16 +// gf16_sin(x: GF16) → GF16 // Compute sine function sin(x) where x is in radians // Uses Taylor series approximation for small values pub fn gf16_sin(x: GF16) GF16 { @@ -952,7 +952,7 @@ pub fn gf16_sin(x: GF16) GF16 { return gf16_encode_f32(result); } -// gf16_cos(x: GF16) 60 GF16 +// gf16_cos(x: GF16) → GF16 // Compute cosine function cos(x) where x is in radians // Uses Taylor series approximation for small values pub fn gf16_cos(x: GF16) GF16 { @@ -1411,7 +1411,7 @@ invariant gf16_sqrt_of_square_less_than_or_equal { } invariant gf16_fma_distributive_approximation { - // gf16_fma(a, b, c) 61 gf16_add(gf16_mul(a, b), c) + // gf16_fma(a, b, c) ≈ gf16_add(gf16_mul(a, b), c) // Not exact due to encoding rounding @compileAssert(true); } @@ -1722,7 +1722,7 @@ invariant gf16_cos_zero_returns_one { } invariant gf16_trig_identity_approx { - // sin^2(x) + cos^2(x) 62 1 for reasonable x values + // sin^2(x) + cos^2(x) ≈ 1 for reasonable x values @compileAssert(true); } @@ -2724,7 +2724,7 @@ test "gf16_exp_zero" { } test "gf16_exp_one" { - // Verify: e^1 63 2.718 + // Verify: e^1 ≈ 2.718 const x = gf16_encode_f32(1.0); const result = gf16_exp(x); const decoded = gf16_decode_to_f32(result); @@ -2732,7 +2732,7 @@ test "gf16_exp_one" { } test "gf16_exp_negative" { - // Verify: e^-1 64 0.368 + // Verify: e^-1 ≈ 0.368 const x = gf16_encode_f32(-1.0); const result = gf16_exp(x); const decoded = gf16_decode_to_f32(result); @@ -2755,7 +2755,7 @@ test "gf16_log_one" { } test "gf16_log_e" { - // Verify: ln(e) 65 1 + // Verify: ln(e) ≈ 1 const e = gf16_encode_f32(2.71828); const result = gf16_log(e); const decoded = gf16_decode_to_f32(result); @@ -2839,7 +2839,7 @@ test "gf16_sin_zero" { } test "gf16_sin_small_angle" { - // Verify: sin(66/6) 67 0.5 + // Verify: sin(π/6) ≈ 0.5 const pi_six = gf16_encode_f32(3.14159 / 6.0); const result = gf16_sin(pi_six); const decoded = gf16_decode_to_f32(result); @@ -2855,7 +2855,7 @@ test "gf16_cos_zero" { } test "gf16_cos_small_angle" { - // Verify: cos(68/6) 69 0.866 + // Verify: cos(π/6) ≈ 0.866 const pi_six = gf16_encode_f32(3.14159 / 6.0); const result = gf16_cos(pi_six); const decoded = gf16_decode_to_f32(result); @@ -2863,7 +2863,7 @@ test "gf16_cos_small_angle" { } test "gf16_trig_identity" { - // Verify: sin^2(x) + cos^2(x) 70 1 for small x + // Verify: sin^2(x) + cos^2(x) ≈ 1 for small x const x = gf16_encode_f32(0.5); const sin_val = gf16_decode_to_f32(gf16_sin(x)); const cos_val = gf16_decode_to_f32(gf16_cos(x)); diff --git a/specs/numeric/gf20.t27 b/specs/numeric/gf20.t27 index 5fec680c66..d2518dceb1 100644 --- a/specs/numeric/gf20.t27 +++ b/specs/numeric/gf20.t27 @@ -1,16 +1,16 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/gf20.t27 -// GoldenFloat20 0 20-bit 1-structured floating point -// NUMERIC-STANDARD-001 2 Agent 6 (P1) +// GoldenFloat20 — 20-bit φ-structured floating point +// NUMERIC-STANDARD-001 — Agent 6 (P1) module GF20 { // Import base format family use numeric::goldenfloat_family; use numeric::phi_ratio; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Format Definition - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // GF20 bit layout: [S|EEE EEE|MMM MMMM MMMM MMM] // S: 1 bit (sign) @@ -25,20 +25,20 @@ module GF20 { // Bias for exponent (2^(7-1) - 1 = 63) const EXP_BIAS : u8 = 63; - // 141-ratio: exp/mant = 7/12 142 0.583 (phi_distance = 0.035) + // φ-ratio: exp/mant = 7/12 ≈ 0.583 (phi_distance = 0.035) const PHI_DISTANCE : f64 = 0.03463264154356299; - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ═════════════════════════════════════════════════════════════════ // 2. GoldenFloat20 Type - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════════ struct GF20 { raw : u32, // 20-bit value stored in u32 } - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 + // ═════════════════════════════════════════════════════════════════ // 3. Encoding/Decoding - // 346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════════ // Encode f32 to GF20 fn encode(value: f32) -> GF20 { @@ -99,9 +99,9 @@ module GF20 { return value; } - // 419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 + // ═════════════════════════════════════════════════════════════════ // 4. Format Properties - // 484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 + // ═════════════════════════════════════════════════════════════════════════ fn max_value() -> f32 { const mant_max = 1.0 + 4095.0 / 4096.0; @@ -119,9 +119,9 @@ module GF20 { return 1.0 / 4096.0; // 0.00024414 } - // 557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621 + // ═════════════════════════════════════════════════════════════════ // 5. Validation - // 622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 + // ═════════════════════════════════════════════════════════════════════════ fn validate_format() -> bool { const fmt = goldenfloat_family::get_format_by_name("GF20"); @@ -131,9 +131,9 @@ module GF20 { (fmt.?.mant_bits == MANT_BITS); } - // 695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759 + // ═════════════════════════════════════════════════════════════════ // 6. Use Cases - // 760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832 + // ═════════════════════════════════════════════════════════════════════════ // GF20 is optimal for: // - High-precision ML training @@ -144,9 +144,9 @@ module GF20 { // Memory: 20 bits = 2.5 bytes (~1.6x FP32 in same space) const MEMORY_RATIO_VS_FP32 : f32 = 20.0 / 32.0; // 0.625 - // 833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897 + // ═════════════════════════════════════════════════════════════════ // 7. Helper Functions - // 898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970 + // ═════════════════════════════════════════════════════════════════════════ fn floor_log2(x: f32) -> i16 { if (x <= 0.0) { return -32768; } @@ -288,9 +288,9 @@ module GF20 { return (xi - 1) as f32; } - // 97197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for GF20 - // 1074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gf20_decode_zero given gf = GF20{ raw = 0 } diff --git a/specs/numeric/gf24.t27 b/specs/numeric/gf24.t27 index ffb9ff37bf..891f65b539 100644 --- a/specs/numeric/gf24.t27 +++ b/specs/numeric/gf24.t27 @@ -1,16 +1,16 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/gf24.t27 -// GoldenFloat24 0 24-bit 1-structured floating point -// NUMERIC-STANDARD-001 2 Agent 7 (P1) +// GoldenFloat24 — 24-bit φ-structured floating point +// NUMERIC-STANDARD-001 — Agent 7 (P1) module GF24 { // Import base format family use numeric::goldenfloat_family; use numeric::phi_ratio; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Format Definition - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // GF24 bit layout: [S|EEEE EEEE|MMM MMMM MMMM MMMM MM] // S: 1 bit (sign) @@ -25,20 +25,20 @@ module GF24 { // Bias for exponent (2^(9-1) - 1 = 255) const EXP_BIAS : u16 = 255; - // 141-ratio: exp/mant = 9/14 142 0.643 (phi_distance = 0.025) + // φ-ratio: exp/mant = 9/14 ≈ 0.643 (phi_distance = 0.025) const PHI_DISTANCE : f64 = 0.02482317991669112; - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ═════════════════════════════════════════════════════════════════ // 2. GoldenFloat24 Type - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════════ struct GF24 { raw : u32, // 24-bit value stored in u32 } - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 + // ═════════════════════════════════════════════════════════════════ // 3. Encoding/Decoding - // 346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════════ // Encode f32 to GF24 fn encode(value: f32) -> GF24 { @@ -99,9 +99,9 @@ module GF24 { return value; } - // 419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 + // ═════════════════════════════════════════════════════════════════ // 4. Format Properties - // 484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 + // ═════════════════════════════════════════════════════════════════════════ fn max_value() -> f32 { const mant_max = 1.0 + 16383.0 / 16384.0; @@ -119,9 +119,9 @@ module GF24 { return 1.0 / 16384.0; // 0.000061035 } - // 557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621 + // ═════════════════════════════════════════════════════════════════ // 5. Validation - // 622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 + // ═════════════════════════════════════════════════════════════════════════ fn validate_format() -> bool { const fmt = goldenfloat_family::get_format_by_name("GF24"); @@ -131,9 +131,9 @@ module GF24 { (fmt.?.mant_bits == MANT_BITS); } - // 695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759 + // ═════════════════════════════════════════════════════════════════ // 6. Use Cases - // 760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832 + // ═════════════════════════════════════════════════════════════════════════ // GF24 is optimal for: // - Very high precision quantization @@ -144,9 +144,9 @@ module GF24 { // Memory: 24 bits = 3 bytes (~1.33x FP32 in same space) const MEMORY_RATIO_VS_FP32 : f32 = 24.0 / 32.0; // 0.75 - // 833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897 + // ═════════════════════════════════════════════════════════════════ // 7. Helper Functions - // 898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970 + // ═════════════════════════════════════════════════════════════════════════ fn floor_log2(x: f32) -> i16 { if (x <= 0.0) { return -32768; } @@ -288,9 +288,9 @@ module GF24 { return (xi - 1) as f32; } - // 97197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for GF24 - // 1074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gf24_decode_zero given gf = GF24{ raw = 0 } diff --git a/specs/numeric/gf32.t27 b/specs/numeric/gf32.t27 index a5e2e14a92..449c2c8cbf 100644 --- a/specs/numeric/gf32.t27 +++ b/specs/numeric/gf32.t27 @@ -1,16 +1,16 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/gf32.t27 -// GoldenFloat32 0 32-bit 1-structured floating point -// NUMERIC-STANDARD-001 2 Agent 8 (P1) +// GoldenFloat32 — 32-bit φ-structured floating point +// NUMERIC-STANDARD-001 — Agent 8 (P1) module GF32 { // Import base format family use numeric::goldenfloat_family; use numeric::phi_ratio; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Format Definition - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // GF32 bit layout: [S|EEEE EEEE EEEE|MMM MMMM MMMM MMMM MMMM MMM] // S: 1 bit (sign) @@ -25,21 +25,21 @@ module GF32 { // Bias for exponent (2^(12-1) - 1 = 2047) const EXP_BIAS : u16 = 2047; - // 141-ratio: exp/mant = 12/19 142 0.632 (phi_distance = 0.014) - // This is the second-best 143-approximation after GF12 + // φ-ratio: exp/mant = 12/19 ≈ 0.632 (phi_distance = 0.014) + // This is the second-best φ-approximation after GF12 const PHI_DISTANCE : f64 = 0.01354495894042812; - // 144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 + // ═════════════════════════════════════════════════════════════════ // 2. GoldenFloat32 Type - // 209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 + // ═════════════════════════════════════════════════════════════════════════ struct GF32 { raw : u32, // 32-bit raw value } - // 282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 + // ═════════════════════════════════════════════════════════════════ // 3. Encoding/Decoding - // 347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 + // ═════════════════════════════════════════════════════════════════════════ // Encode f32 to GF32 fn encode(value: f32) -> GF32 { @@ -100,9 +100,9 @@ module GF32 { return value; } - // 420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 + // ═════════════════════════════════════════════════════════════════ // 4. Format Properties - // 485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 + // ═════════════════════════════════════════════════════════════════════════ fn max_value() -> f32 { const mant_max = 1.0 + 524287.0 / 524288.0; @@ -120,9 +120,9 @@ module GF32 { return 1.0 / 524288.0; // 0.000001907 } - // 558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622 + // ═════════════════════════════════════════════════════════════════ // 5. Validation - // 623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 + // ═════════════════════════════════════════════════════════════════════════ fn validate_format() -> bool { const fmt = goldenfloat_family::get_format_by_name("GF32"); @@ -132,26 +132,26 @@ module GF32 { (fmt.?.mant_bits == MANT_BITS); } - // 696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 + // ═════════════════════════════════════════════════════════════════ // 6. Use Cases - // 761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 + // ═════════════════════════════════════════════════════════════════════════ // GF32 is optimal for: - // - Near-IEEE 754 precision with 834-optimized layout + // - Near-IEEE 754 precision with φ-optimized layout // - 12-bit exponent (vs IEEE's 8-bit) for wider dynamic range // - 19-bit mantissa (vs IEEE's 23-bit) - still good precision - // - Same memory footprint as FP32, better 835-ratio + // - Same memory footprint as FP32, better φ-ratio // Comparison with IEEE FP32: - // - IEEE: 1 sign, 8 exp, 23 mant 836 exp/mant = 0.348 (phi_distance = 0.270) - // - GF32: 1 sign, 12 exp, 19 mant 837 exp/mant = 0.632 (phi_distance = 0.014) + // - IEEE: 1 sign, 8 exp, 23 mant → exp/mant = 0.348 (phi_distance = 0.270) + // - GF32: 1 sign, 12 exp, 19 mant → exp/mant = 0.632 (phi_distance = 0.014) // Memory: 32 bits = 4 bytes (same as FP32) const MEMORY_RATIO_VS_FP32 : f32 = 1.0; - // 838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902 + // ═════════════════════════════════════════════════════════════════ // 7. Helper Functions - // 903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975 + // ═════════════════════════════════════════════════════════════════════════ fn floor_log2(x: f32) -> i16 { if (x <= 0.0) { return -32768; } @@ -293,9 +293,9 @@ module GF32 { return (xi - 1) as f32; } - // 9769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for GF32 - // 1079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gf32_decode_zero given gf = GF32{ raw = 0 } diff --git a/specs/numeric/gf4.t27 b/specs/numeric/gf4.t27 index 499b74e34f..3d3767cc8d 100644 --- a/specs/numeric/gf4.t27 +++ b/specs/numeric/gf4.t27 @@ -1,16 +1,16 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/gf4.t27 -// GoldenFloat4 0 4-bit 1-structured floating point -// NUMERIC-STANDARD-001 2 Agent 2 (P1) +// GoldenFloat4 — 4-bit φ-structured floating point +// NUMERIC-STANDARD-001 — Agent 2 (P1) module GF4 { // Import base format family use numeric::goldenfloat_family; use numeric::phi_ratio; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Format Definition - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // GF4 bit layout: [S|E|MM] // S: 1 bit (sign) @@ -25,20 +25,20 @@ module GF4 { // Bias for exponent (0-biased for GF4) const EXP_BIAS : u8 = 0; - // 141-ratio: exp/mant = 1/2 = 0.5 (phi_distance = 0.118) + // φ-ratio: exp/mant = 1/2 = 0.5 (phi_distance = 0.118) const PHI_DISTANCE : f64 = 0.1180339887498949; - // 142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 + // ═════════════════════════════════════════════════════════════════ // 2. GoldenFloat4 Type - // 207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════════ struct GF4 { raw : u4, // 4-bit raw value } - // 280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 + // ═════════════════════════════════════════════════════════════════ // 3. Encoding/Decoding - // 345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 + // ═════════════════════════════════════════════════════════════════════════ // Encode f32 to GF4 fn encode(value: f32) -> GF4 { @@ -53,14 +53,14 @@ module GF4 { // For GF4, quantize to available values // Available positive values (mant * exp_scale): - // mant=0.00, exp=1.0 418 0.00 - // mant=0.25, exp=1.0 419 0.25 - // mant=0.50, exp=1.0 420 0.50 - // mant=0.75, exp=1.0 421 0.75 - // mant=0.00, exp=2.0 422 0.00 - // mant=0.25, exp=2.0 423 0.50 - // mant=0.50, exp=2.0 424 1.00 - // mant=0.75, exp=2.0 425 1.50 + // mant=0.00, exp=1.0 → 0.00 + // mant=0.25, exp=1.0 → 0.25 + // mant=0.50, exp=1.0 → 0.50 + // mant=0.75, exp=1.0 → 0.75 + // mant=0.00, exp=2.0 → 0.00 + // mant=0.25, exp=2.0 → 0.50 + // mant=0.50, exp=2.0 → 1.00 + // mant=0.75, exp=2.0 → 1.50 // Unique positive non-zero values: 0.25, 0.5, 0.75, 1.0, 1.5 @@ -93,10 +93,10 @@ module GF4 { return 0.0; } - // Decode mantissa (2 bits 426 values 0, 0.25, 0.5, 0.75) + // Decode mantissa (2 bits → values 0, 0.25, 0.5, 0.75) const mant = (mant_bits as f32) / 4.0; - // Decode exponent (1 bit 427 1.0 or 2.0) + // Decode exponent (1 bit → 1.0 or 2.0) const exp_scale = if (exp_bit) { 2.0 } else { 1.0 }; const value = mant * exp_scale; @@ -107,17 +107,17 @@ module GF4 { return value; } - // 428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 + // ═════════════════════════════════════════════════════════════════ // 4. Format Properties - // 493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 + // ═════════════════════════════════════════════════════════════════════════ fn max_value() -> f32 { - // Max: mant=0.75, exp=2.0 566 1.5 + // Max: mant=0.75, exp=2.0 → 1.5 return 1.5; } fn min_positive() -> f32 { - // Min positive: mant=0.25, exp=1.0 567 0.25 + // Min positive: mant=0.25, exp=1.0 → 0.25 return 0.25; } @@ -126,9 +126,9 @@ module GF4 { return 0.25; } - // 568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632 + // ═════════════════════════════════════════════════════════════════ // 5. Validation - // 633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705 + // ═════════════════════════════════════════════════════════════════════════ fn validate_format() -> bool { // Check that we match the goldenfloat_family definition @@ -139,9 +139,9 @@ module GF4 { (fmt.?.mant_bits == MANT_BITS); } - // 706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770 + // ═════════════════════════════════════════════════════════════════ // 6. Use Cases - // 771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843 + // ═════════════════════════════════════════════════════════════════════════ // GF4 is optimal for: // - Extreme compression (87.5% smaller than FP32) @@ -152,9 +152,9 @@ module GF4 { // Memory: 4 bits = 0.5 bytes (8x FP32 in same space) const MEMORY_RATIO_VS_FP32 : f32 = 4.0 / 32.0; // 0.125 - // 844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for GF4 - // 94794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gf4_decode_zero given gf = GF4{ raw = 0b0000 } diff --git a/specs/numeric/gf8.t27 b/specs/numeric/gf8.t27 index d4f9f72ae6..a4c1d3f399 100644 --- a/specs/numeric/gf8.t27 +++ b/specs/numeric/gf8.t27 @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/gf8.t27 -// GoldenFloat8 0 8-bit 1-structured floating point -// NUMERIC-STANDARD-001 2 Agent 3 (P1) +// GoldenFloat8 — 8-bit φ-structured floating point +// NUMERIC-STANDARD-001 — Agent 3 (P1) module GF8 { // Import base format family @@ -12,9 +12,9 @@ module GF8 { use base::testing; use base::benchmarking; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Format Definition - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // GF8 bit layout: [S|EEE|MMMM] // S: 1 bit (sign) @@ -29,21 +29,21 @@ module GF8 { // Bias for exponent (2^(3-1) - 1 = 3) const EXP_BIAS : u8 = 3; - // 141-ratio: exp/mant = 3/4 = 0.75 - // 142-distance: math::constants::PHI_DISTANCE + // φ-ratio: exp/mant = 3/4 = 0.75 + // φ-distance: math::constants::PHI_DISTANCE const PHI_DISTANCE : f64 = 0.132; - // 143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ═════════════════════════════════════════════════════════════════ // 2. GoldenFloat8 Type - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 + // ═════════════════════════════════════════════════════════════════════════ struct GF8 { raw : u8, // 8-bit raw value } - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 + // ═════════════════════════════════════════════════════════════════ // 3. Encoding/Decoding - // 346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════════ // Encode f32 to GF8 fn encode(value: f32) -> GF8 { @@ -108,19 +108,19 @@ module GF8 { return value; } - // 419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 + // ═════════════════════════════════════════════════════════════════ // 4. Format Properties - // 484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 + // ═════════════════════════════════════════════════════════════════════════ fn max_value() -> f32 { - // Max normalized: mant=1.9375, exp=3 557 15.5 + // Max normalized: mant=1.9375, exp=3 → 15.5 const mant_max = 1.0 + 15.0 / 16.0; const exp_max = (1 << EXP_BITS) - 1 - EXP_BIAS; return mant_max * pow(2.0, exp_max as f32); } fn min_positive() -> f32 { - // Min subnormal: mant=1/16, exp=-2 558 0.0625 + // Min subnormal: mant=1/16, exp=-2 → 0.0625 const mant_min = 1.0 / 16.0; const exp_min = -EXP_BIAS as i8 + 1; return mant_min * pow(2.0, exp_min as f32); @@ -131,9 +131,9 @@ module GF8 { return 1.0 / 16.0; // 0.0625 } - // 559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623 + // ═════════════════════════════════════════════════════════════════ // 5. Validation - // 624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696 + // ═════════════════════════════════════════════════════════════════════════ fn validate_format() -> bool { const fmt = goldenfloat_family::get_format_by_name("GF8"); @@ -143,9 +143,9 @@ module GF8 { (fmt.?.mant_bits == MANT_BITS); } - // 697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761 + // ═════════════════════════════════════════════════════════════════ // 6. Use Cases - // 762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834 + // ═════════════════════════════════════════════════════════════════════════ // GF8 is optimal for: // - High compression (75% smaller than FP32) @@ -156,9 +156,9 @@ module GF8 { // Memory: 8 bits = 1 byte (4x FP32 in same space) const MEMORY_RATIO_VS_FP32 : f32 = 8.0 / 32.0; // 0.25 - // 835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 + // ═════════════════════════════════════════════════════════════════ // 7. Helper Functions - // 900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972 + // ═════════════════════════════════════════════════════════════════════════ fn floor_log2(x: f32) -> i8 { if (x <= 0.0) { return -128; } @@ -300,9 +300,9 @@ module GF8 { return (xi - 1) as f32; } - // 9739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for GF8 - // 1076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gf8_decode_zero given gf = GF8{ raw = 0 } diff --git a/specs/numeric/phi_ratio.t27 b/specs/numeric/phi_ratio.t27 index 9dee70c707..d5781d8c10 100644 --- a/specs/numeric/phi_ratio.t27 +++ b/specs/numeric/phi_ratio.t27 @@ -1,40 +1,40 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/numeric/phi_ratio.t27 -// 0-Ratio Proof 1 Derivation of GoldenFloat exp/mantissa split -// NUMERIC-STANDARD-001 2 Agent 9 (P0) +// φ-Ratio Proof — Derivation of GoldenFloat exp/mantissa split +// NUMERIC-STANDARD-001 — Agent 9 (P0) module PhiRatio { // Import sacred constants use math::constants; use math::sacred_physics; - // 345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ═════════════════════════════════════════════════════════════════ // 1. Golden Ratio Target for Float Formats - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 + // ═════════════════════════════════════════════════════════════════════════ // The ideal exp/mantissa ratio for floating point formats - // Derived from sacred physics: 1/141 142 0.618 + // Derived from sacred physics: 1/φ ≈ 0.618 const PHI_RATIO_TARGET : f64 = sacred_physics::PHI_INV; // 0.618... - // 143144 = 145 + 1 (golden ratio identity) - // This gives us: 1/146 = 147 - 1 148 0.618 + // φ² = φ + 1 (golden ratio identity) + // This gives us: 1/φ = φ - 1 ≈ 0.618 const PHI_SQ : f64 = sacred_physics::PHI * sacred_physics::PHI; - // 149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 - // 2. 214-Split Formula 215 Derive optimal exp/mantissa bits - // 216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 + // ═════════════════════════════════════════════════════════════════ + // 2. φ-Split Formula — Derive optimal exp/mantissa bits + // ═════════════════════════════════════════════════════════════════════════ // For a floating point format with N bits total (including sign): // bits = sign + exp + mant // sign = 1 (always) // available = N - 1 = exp + mant // - // The 289-principle states: exp/mant = 1/290 - // exp = (available) / (291 + 1) + // The φ-principle states: exp/mant = 1/φ + // exp = (available) / (φ + 1) // mant = available - exp // - // Since 292 + 1 = 293294, we have: - // exp = (N - 1) / 295296 + // Since φ + 1 = φ², we have: + // exp = (N - 1) / φ² // mant = N - 1 - exp struct PhiSplitResult { @@ -48,7 +48,7 @@ module PhiRatio { const available = bits - 1; // Exclude sign bit const phi_sq = sacred_physics::PHI * sacred_physics::PHI; - // exp = round((N-1) / 297298) + // exp = round((N-1) / φ²) const exp_raw = (available as f64) / phi_sq; const exp_bits = round(exp_raw) as u8; @@ -66,9 +66,9 @@ module PhiRatio { }; } - // 299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 - // 3. Verify GoldenFloat Family against 364-Split - // 365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 + // ═════════════════════════════════════════════════════════════════ + // 3. Verify GoldenFloat Family against φ-Split + // ═════════════════════════════════════════════════════════════════════════ struct FormatComparison { name : string, @@ -83,7 +83,7 @@ module PhiRatio { fn verify_phi_split() -> [7]FormatComparison { return [ - // GF4: 438-split gives exp=1, mant=2 439 MATCH + // GF4: φ-split gives exp=1, mant=2 → MATCH FormatComparison{ name = "GF4", bits = 4, @@ -92,9 +92,9 @@ module PhiRatio { phi_split_exp = 1, phi_split_mant = 2, matches_phi_split = true, - tradeoff_note = "Perfect 440-split match", + tradeoff_note = "Perfect φ-split match", }, - // GF8: 441-split gives exp=2, mant=5 442 actual is 3/4 + // GF8: φ-split gives exp=2, mant=5 → actual is 3/4 FormatComparison{ name = "GF8", bits = 8, @@ -105,7 +105,7 @@ module PhiRatio { matches_phi_split = true, tradeoff_note = "Exact match: round(7/φ²)=3", }, - // GF12: 443-split gives exp=3, mant=8 444 actual is 4/7 + // GF12: φ-split gives exp=3, mant=8 → actual is 4/7 FormatComparison{ name = "GF12", bits = 12, @@ -116,7 +116,7 @@ module PhiRatio { matches_phi_split = true, tradeoff_note = "Exact match: round(11/φ²)=4", }, - // GF16: 445-split gives exp=4, mant=11 446 actual is 6/9 + // GF16: φ-split gives exp=4, mant=11 → actual is 6/9 FormatComparison{ name = "GF16", bits = 16, @@ -127,7 +127,7 @@ module PhiRatio { matches_phi_split = true, tradeoff_note = "PRIMARY FORMAT: exact match: round(15/φ²)=6", }, - // GF20: 447-split gives exp=5, mant=14 448 actual is 7/12 + // GF20: φ-split gives exp=5, mant=14 → actual is 7/12 FormatComparison{ name = "GF20", bits = 20, @@ -138,7 +138,7 @@ module PhiRatio { matches_phi_split = true, tradeoff_note = "Exact match: round(19/φ²)=7", }, - // GF24: 449-split gives exp=6, mant=17 450 actual is 9/14 + // GF24: φ-split gives exp=6, mant=17 → actual is 9/14 FormatComparison{ name = "GF24", bits = 24, @@ -147,9 +147,9 @@ module PhiRatio { phi_split_exp = 6, phi_split_mant = 17, matches_phi_split = false, - tradeoff_note = "Closer to 451-split than GF16", + tradeoff_note = "Closer to φ-split than GF16", }, - // GF32: 452-split gives exp=8, mant=23 453 actual is 12/19 + // GF32: φ-split gives exp=8, mant=23 → actual is 12/19 FormatComparison{ name = "GF32", bits = 32, @@ -158,16 +158,16 @@ module PhiRatio { phi_split_exp = 8, phi_split_mant = 23, matches_phi_split = false, - tradeoff_note = "Near 454-split with good precision", + tradeoff_note = "Near φ-split with good precision", }, ]; } - // 455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 + // ═════════════════════════════════════════════════════════════════ // 4. Theoretical Proofs - // 520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 + // ═════════════════════════════════════════════════════════════════════════ - // Proof that 593-split minimizes information loss + // Proof that φ-split minimizes information loss // for a given bit budget under scale-invariant assumptions. fn golden_self_similarity_proof() -> string { @@ -196,31 +196,31 @@ module PhiRatio { // // Taking derivative and setting to zero: // d/dr [r * (N/(1+r))^2] = 0 - // r = 1/(1+r) 594 r^2 + r - 1 = 0 - // r = (sqrt(5) - 1) / 2 = 1/595 + // r = 1/(1+r) → r^2 + r - 1 = 0 + // r = (sqrt(5) - 1) / 2 = 1/φ // - // Therefore: exp/mant = 1/596 is optimal - return "exp/mant = 1/597 maximizes (dynamic_range * precision) for fixed bit budget"; + // Therefore: exp/mant = 1/φ is optimal + return "exp/mant = 1/φ maximizes (dynamic_range * precision) for fixed bit budget"; } - // 598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662 + // ═════════════════════════════════════════════════════════════════ // 5. Connection to Sacred Physics - // 663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735 + // ═════════════════════════════════════════════════════════════════════════ - // The 736-ratio appears throughout sacred physics: - // - Consciousness threshold C = 737738739 - // - Specious present t = 740741742 seconds - // - Neural gamma band f_743 = 744745 * 746 / 747 + // The φ-ratio appears throughout sacred physics: + // - Consciousness threshold C = φ⁻¹ + // - Specious present t = φ⁻² seconds + // - Neural gamma band f_γ = φ³ * π / γ // // GoldenFloat formats inherit this sacred proportion. fn sacred_connection() -> string { - return "GoldenFloat exp/mant = 1/748 = consciousness threshold = sacred_physics::C_THRESHOLD"; + return "GoldenFloat exp/mant = 1/φ = consciousness threshold = sacred_physics::C_THRESHOLD"; } - // 749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813 + // ═════════════════════════════════════════════════════════════════ // 6. Utility functions - // 814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886 + // ═════════════════════════════════════════════════════════════════════════ fn compute_phi_distance(exp_bits: u8, mant_bits: u8) -> f64 { const ratio = (exp_bits as f64) / (mant_bits as f64); @@ -235,9 +235,9 @@ module PhiRatio { return phi_split(total_bits); } - // 887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 + // ═════════════════════════════════════════════════════════════════ // 7. Round function (stub) - // 9529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024 + // ═════════════════════════════════════════════════════════════════════════ fn round(x: f64) -> f64 { // Round to nearest integer (round half away from zero) @@ -382,9 +382,9 @@ module PhiRatio { return (xi - 1) as f64; } - // 1025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127 - // TDD-Inside-Spec: Tests and Invariants for 1128-Ratio - // 1129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ + // TDD-Inside-Spec: Tests and Invariants for φ-Ratio + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test phi_split_for_gf4_perfect_match given bits = 4 @@ -419,7 +419,7 @@ module PhiRatio { test phi_optimality_proof_derivative given proof = phi_optimality_proof() - when contains_optimal = proof.contains("exp/mant = 1/1232") + when contains_optimal = proof.contains("exp/mant = 1/φ") then contains_optimal == true test compute_phi_distance_for_gf16 @@ -602,7 +602,7 @@ module PhiRatio { assert forall exp, mant: u8, compute_phi_distance(exp, mant) >= 0.0 invariant phi_optimal_proof_valid - assert phi_optimality_proof().contains("1/1233") + assert phi_optimality_proof().contains("1/φ") invariant gf4_format_is_phi_optimal assert phi_split(4).phi_dist < 0.01 diff --git a/specs/numeric/tf3.t27 b/specs/numeric/tf3.t27 index 67d950adbb..be10f936a7 100644 --- a/specs/numeric/tf3.t27 +++ b/specs/numeric/tf3.t27 @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -; tf3.t27 0 TF3 (Ternary Float 3) Format Specification +; tf3.t27 — TF3 (Ternary Float 3) Format Specification ; 8-bit representation for ternary neural network weights ; Bit layout: [S(1) E(3) M(4)] = [7:7][6:4][3:0] -; 12 + 1/34 = 3 | TRINITY +; φ² + 1/φ² = 3 | TRINITY module triformat-tf3; @@ -40,7 +40,7 @@ pub const TF3 = u8; // Mantissa Lookup Table // ============================================================================ // TF3 mantissa lookup: (1 + m/2^4) * 2^(e-3) -// m 5 [0, 15], e 6 [0, 7], bias = 3 +// m ∈ [0, 15], e ∈ [0, 7], bias = 3 // Indexed as: table[e * 16 + m] pub const mant_lookup_table : [128]u16 = [128]u16{ // e=0: (1+m/16) * 2^(-3) = (1+m/16) / 8 @@ -73,28 +73,28 @@ pub const mant_lookup_table : [128]u16 = [128]u16{ // Functions // ============================================================================ -// tf3_extract_sign(tf3: TF3) 7 i8 +// tf3_extract_sign(tf3: TF3) → i8 // Extract sign bit (bit 7) // Returns: 0 for positive, 1 for negative pub fn tf3_extract_sign(tf3: TF3) i8 { return @as(i8, @intCast((tf3 & SIGN_MASK) >> SIGN_SHIFT)); } -// tf3_extract_exponent(tf3: TF3) 8 i8 +// tf3_extract_exponent(tf3: TF3) → i8 // Extract exponent bits (bits 6-4) // Returns: 0-7 pub fn tf3_extract_exponent(tf3: TF3) i8 { return @as(i8, @intCast((tf3 & EXP_MASK) >> EXP_SHIFT)); } -// tf3_extract_mantissa(tf3: TF3) 9 i8 +// tf3_extract_mantissa(tf3: TF3) → i8 // Extract mantissa bits (bits 3-0) // Returns: 0-15 pub fn tf3_extract_mantissa(tf3: TF3) i8 { return @as(i8, @intCast(tf3 & MANT_MASK)); } -// tf3_from_components(sign: i8, exp: i8, mant: i8) 10 TF3 +// tf3_from_components(sign: i8, exp: i8, mant: i8) → TF3 // Build TF3 from sign, exponent, mantissa components pub fn tf3_from_components(sign: i8, exp: i8, mant: i8) TF3 { return (@as(TF3, @intCast(sign)) << SIGN_SHIFT) | @@ -102,13 +102,13 @@ pub fn tf3_from_components(sign: i8, exp: i8, mant: i8) TF3 { (@as(TF3, @intCast(mant)) << MANT_SHIFT); } -// tf3_is_zero(tf3: TF3) 11 bool +// tf3_is_zero(tf3: TF3) → bool // Check if TF3 is zero pub fn tf3_is_zero(tf3: TF3) bool { return tf3 == TF3_ZERO_POS or tf3 == TF3_ZERO_NEG; } -// tf3_is_inf(tf3: TF3) 12 bool +// tf3_is_inf(tf3: TF3) → bool // Check if TF3 is infinity (exp == 7, mant == 0) pub fn tf3_is_inf(tf3: TF3) bool { const exp = tf3_extract_exponent(tf3); @@ -116,7 +116,7 @@ pub fn tf3_is_inf(tf3: TF3) bool { return exp == EXP_MAX and mant == 0; } -// tf3_from_f32(f32: f32) 13 TF3 +// tf3_from_f32(f32: f32) → TF3 // Encode IEEE 754 single precision to TF3 // Round-to-nearest, clamped to [-8, +8] range pub fn tf3_from_f32(value: f32) TF3 { @@ -147,7 +147,7 @@ pub fn tf3_from_f32(value: f32) TF3 { return tf3_from_components(sign, exp + BIAS, mant); } -// tf3_to_f32(tf3: TF3) 14 f32 +// tf3_to_f32(tf3: TF3) → f32 // Decode TF3 to IEEE 754 single precision pub fn tf3_to_f32(tf3: TF3) f32 { // Handle special cases @@ -172,33 +172,33 @@ pub fn tf3_to_f32(tf3: TF3) f32 { return sign_mult * mant_mult * exp_mult; } -// tf3_negate(tf3: TF3) 15 TF3 +// tf3_negate(tf3: TF3) → TF3 // Negate a TF3 value by flipping the sign bit pub fn tf3_negate(tf3: TF3) TF3 { return tf3 ^ SIGN_MASK; } -// tf3_abs(tf3: TF3) 16 TF3 +// tf3_abs(tf3: TF3) → TF3 // Absolute value of TF3 (clear sign bit) pub fn tf3_abs(tf3: TF3) TF3 { return tf3 & ~SIGN_MASK; } -// tf3_is_negative(tf3: TF3) 17 bool +// tf3_is_negative(tf3: TF3) → bool // Check if TF3 is negative (sign bit set, excluding negative zero) pub fn tf3_is_negative(tf3: TF3) bool { const sign = tf3_extract_sign(tf3); return (sign != 0) and !tf3_is_zero(tf3); } -// tf3_is_positive(tf3: TF3) 18 bool +// tf3_is_positive(tf3: TF3) → bool // Check if TF3 is positive (sign bit clear, excluding positive zero) pub fn tf3_is_positive(tf3: TF3) bool { const sign = tf3_extract_sign(tf3); return (sign == 0) and !tf3_is_zero(tf3); } -// tf3_copy_sign(tf3: TF3, sign_source: TF3) 19 TF3 +// tf3_copy_sign(tf3: TF3, sign_source: TF3) → TF3 // Copy sign from sign_source to tf3 value pub fn tf3_copy_sign(tf3: TF3, sign_source: TF3) TF3 { const sign_mask = sign_source & SIGN_MASK; @@ -206,7 +206,7 @@ pub fn tf3_copy_sign(tf3: TF3, sign_source: TF3) TF3 { return value_mask | sign_mask; } -// tf3_max(a: TF3, b: TF3) 20 TF3 +// tf3_max(a: TF3, b: TF3) → TF3 // Return the greater of two TF3 values pub fn tf3_max(a: TF3, b: TF3) TF3 { if (tf3_is_inf(a) and !tf3_is_negative(a)) return a; @@ -218,7 +218,7 @@ pub fn tf3_max(a: TF3, b: TF3) TF3 { if (a_val >= b_val) return a else return b; } -// tf3_min(a: TF3, b: TF3) 21 TF3 +// tf3_min(a: TF3, b: TF3) → TF3 // Return the smaller of two TF3 values pub fn tf3_min(a: TF3, b: TF3) TF3 { if (tf3_is_inf(a) and tf3_is_negative(a)) return a; @@ -230,9 +230,9 @@ pub fn tf3_min(a: TF3, b: TF3) TF3 { if (a_val <= b_val) return a else return b; } -// tf3_from_f32_phi(value: f32) 22 TF3 +// tf3_from_f32_phi(value: f32) → TF3 // Encode IEEE 754 to TF3 with phi-optimized rounding -// Uses golden ratio bias (1/23 24 0.618) for rounding decisions +// Uses golden ratio bias (1/φ ≈ 0.618) for rounding decisions pub fn tf3_from_f32_phi(value: f32) TF3 { // Handle zero if (value == 0.0) { @@ -254,7 +254,7 @@ pub fn tf3_from_f32_phi(value: f32) TF3 { exp += 1; } - // Phi-optimized rounding: bias = 1/25 26 0.618 + // Phi-optimized rounding: bias = 1/φ ≈ 0.618 const PHI_BIAS: f32 = 0.618; const mantissa_raw = (scaled - 0.5 + PHI_BIAS / 16.0) * 16.0; const mantissa = @as(i8, @intFromFloat(@round(mantissa_raw))); @@ -263,7 +263,7 @@ pub fn tf3_from_f32_phi(value: f32) TF3 { return tf3_from_components(sign, exp + BIAS, mant); } -// tf3_eq(a: TF3, b: TF3) 27 bool +// tf3_eq(a: TF3, b: TF3) → bool // Equality comparison for TF3 // Treats +0 and -0 as equal pub fn tf3_eq(a: TF3, b: TF3) bool { @@ -272,13 +272,13 @@ pub fn tf3_eq(a: TF3, b: TF3) bool { return a == b; } -// tf3_ne(a: TF3, b: TF3) 28 bool +// tf3_ne(a: TF3, b: TF3) → bool // Not-equal comparison for TF3 pub fn tf3_ne(a: TF3, b: TF3) bool { return !tf3_eq(a, b); } -// tf3_lt(a: TF3, b: TF3) 29 bool +// tf3_lt(a: TF3, b: TF3) → bool // Less-than comparison for TF3 pub fn tf3_lt(a: TF3, b: TF3) bool { const a_val = tf3_to_f32(a); @@ -286,7 +286,7 @@ pub fn tf3_lt(a: TF3, b: TF3) bool { return a_val < b_val; } -// tf3_le(a: TF3, b: TF3) 30 bool +// tf3_le(a: TF3, b: TF3) → bool // Less-than-or-equal comparison for TF3 pub fn tf3_le(a: TF3, b: TF3) bool { const a_val = tf3_to_f32(a); @@ -294,7 +294,7 @@ pub fn tf3_le(a: TF3, b: TF3) bool { return a_val <= b_val; } -// tf3_gt(a: TF3, b: TF3) 31 bool +// tf3_gt(a: TF3, b: TF3) → bool // Greater-than comparison for TF3 pub fn tf3_gt(a: TF3, b: TF3) bool { const a_val = tf3_to_f32(a); @@ -302,7 +302,7 @@ pub fn tf3_gt(a: TF3, b: TF3) bool { return a_val > b_val; } -// tf3_ge(a: TF3, b: TF3) 32 bool +// tf3_ge(a: TF3, b: TF3) → bool // Greater-than-or-equal comparison for TF3 pub fn tf3_ge(a: TF3, b: TF3) bool { const a_val = tf3_to_f32(a); @@ -310,7 +310,7 @@ pub fn tf3_ge(a: TF3, b: TF3) bool { return a_val >= b_val; } -// tf3_add(a: TF3, b: TF3) 33 TF3 +// tf3_add(a: TF3, b: TF3) → TF3 // Add two TF3 values (decode, add, re-encode) // Handles overflow by clamping to Inf pub fn tf3_add(a: TF3, b: TF3) TF3 { @@ -330,7 +330,7 @@ pub fn tf3_add(a: TF3, b: TF3) TF3 { return tf3_from_f32(result); } -// tf3_sub(a: TF3, b: TF3) 34 TF3 +// tf3_sub(a: TF3, b: TF3) → TF3 // Subtract two TF3 values (decode, subtract, re-encode) pub fn tf3_sub(a: TF3, b: TF3) TF3 { if (tf3_is_inf(a)) return a; @@ -346,7 +346,7 @@ pub fn tf3_sub(a: TF3, b: TF3) TF3 { return tf3_from_f32(result); } -// tf3_mul(a: TF3, b: TF3) 35 TF3 +// tf3_mul(a: TF3, b: TF3) → TF3 // Multiply two TF3 values (decode, multiply, re-encode) pub fn tf3_mul(a: TF3, b: TF3) TF3 { if (tf3_is_zero(a) or tf3_is_zero(b)) { @@ -369,7 +369,7 @@ pub fn tf3_mul(a: TF3, b: TF3) TF3 { return tf3_from_f32(result); } -// tf3_div(a: TF3, b: TF3) 36 TF3 +// tf3_div(a: TF3, b: TF3) → TF3 // Divide two TF3 values (decode, divide, re-encode) // Returns Inf if divisor is zero pub fn tf3_div(a: TF3, b: TF3) TF3 { @@ -397,7 +397,7 @@ pub fn tf3_div(a: TF3, b: TF3) TF3 { return tf3_from_f32(result); } -// tf3_is_nan(tf3: TF3) 37 bool +// tf3_is_nan(tf3: TF3) → bool // Check if TF3 value is NaN // TF3 uses 0b111 (all ones) for NaN in the 3 exponent bits pub fn tf3_is_nan(tf3: TF3) bool { @@ -406,19 +406,19 @@ pub fn tf3_is_nan(tf3: TF3) bool { return exp == 0x07; // All exponent bits set = NaN or Inf } -// tf3_is_finite(tf3: TF3) 38 bool +// tf3_is_finite(tf3: TF3) → bool // Check if TF3 value is finite (not NaN, not infinity) pub fn tf3_is_finite(tf3: TF3) bool { return !tf3_is_nan(tf3) and !tf3_is_inf(tf3); } -// tf3_signbit(tf3: TF3) 39 bool +// tf3_signbit(tf3: TF3) → bool // Check if the sign bit is set (value is negative or negative zero) pub fn tf3_signbit(tf3: TF3) bool { return (tf3 & TF3_SIGN_MASK) != 0; } -// tf3_sign(tf3: TF3) 40 i8 +// tf3_sign(tf3: TF3) → i8 // Return the sign of the TF3 value: -1 for negative, 0 for zero, +1 for positive pub fn tf3_sign(tf3: TF3) i8 { if (tf3_is_nan(tf3)) { @@ -436,7 +436,7 @@ pub fn tf3_sign(tf3: TF3) i8 { } } -// tf3_clamp(x: TF3, min_val: TF3, max_val: TF3) 41 TF3 +// tf3_clamp(x: TF3, min_val: TF3, max_val: TF3) → TF3 // Clamp x to the range [min_val, max_val] pub fn tf3_clamp(x: TF3, min_val: TF3, max_val: TF3) TF3 { if (tf3_is_nan(x) or tf3_is_nan(min_val) or tf3_is_nan(max_val)) { @@ -456,7 +456,7 @@ pub fn tf3_clamp(x: TF3, min_val: TF3, max_val: TF3) TF3 { } } -// tf3_lerp(a: TF3, b: TF3, t: TF3) 42 TF3 +// tf3_lerp(a: TF3, b: TF3, t: TF3) → TF3 // Linear interpolation: a + t * (b - a) pub fn tf3_lerp(a: TF3, b: TF3, t: TF3) TF3 { if (tf3_is_nan(a) or tf3_is_nan(b) or tf3_is_nan(t)) { diff --git a/specs/numeric/trinity_numeric_surface.t27 b/specs/numeric/trinity_numeric_surface.t27 index d98e38e966..c72c85531a 100644 --- a/specs/numeric/trinity_numeric_surface.t27 +++ b/specs/numeric/trinity_numeric_surface.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -; trinity_numeric_surface.t27 0 Public numeric interchange policy (GoldenFloat-first) -; NUMERIC-STANDARD-001 1 integer-backed GF raw words are the portable surface +; trinity_numeric_surface.t27 — Public numeric interchange policy (GoldenFloat-first) +; NUMERIC-STANDARD-001 — integer-backed GF raw words are the portable surface ; phi^2 + 1/phi^2 = 3 | TRINITY module trinity-numeric-surface; @@ -14,7 +14,7 @@ module trinity-numeric-surface; // helpers. They MUST NOT appear in new **public** structs exported to AR/nn/vsa // unless tagged [BRIDGE] and scheduled for GF migration (see // docs/nona-02-organism/NUMERIC-GF16-DEBT-INVENTORY.md). -// - **TF3** (u8) and **ternary** trits remain experimental sidecars 2 not a +// - **TF3** (u8) and **ternary** trits remain experimental sidecars — not a // substitute for GF16-primary inference policy. // ----------------------------------------------------------------------------- diff --git a/specs/physics/e8_lqg_bridge.t27 b/specs/physics/e8_lqg_bridge.t27 index 5739335fb1..bf756de258 100644 --- a/specs/physics/e8_lqg_bridge.t27 +++ b/specs/physics/e8_lqg_bridge.t27 @@ -3,18 +3,18 @@ ## Specification -Cycle #133 0 Ko Samui 1 v9.5 E8-QUANTUM GRAVITY +Cycle #133 — Ko Samui — v9.5 E8-QUANTUM GRAVITY This module bridges E8 Lie Group, VSA hypervectors, and quantum gravity observables. -Implements sacred formula V = n 2 3^k 3 4^m 5 6^p 7 e^q for encoding -quantum gravity parameters (8, 9, graviton mass, holographic entropy). +Implements sacred formula V = n × 3^k × π^m × φ^p × e^q for encoding +quantum gravity parameters (γ, Λ, graviton mass, holographic entropy). ## Key Features -- E8 root 10 LQG (Loop Quantum Gravity) spin encoding -- Barbero-Immirzi parameter 11 sacred encoding -- Cosmological constant 12 via sacred formula -- Holographic entropy bound: S = A/4 13 hypervector area +- E8 root → LQG (Loop Quantum Gravity) spin encoding +- Barbero-Immirzi parameter γ sacred encoding +- Cosmological constant Λ via sacred formula +- Holographic entropy bound: S = A/4 → hypervector area - Graviton mass prediction from E8 root mapping - AdS/CFT boundary projection via VSA @@ -42,10 +42,10 @@ LAMBDA_CDM = 1.1056e-52 m^-2 RHO_LAMBDA = 5.96e-10 GeV/m^3 GAMMA_STANDARD = 0.2375 -GAMMA_PHI = (14 - 1) / 152 16 0.261 +GAMMA_PHI = (φ - 1) / √2 ≈ 0.261 GRAVITON_MASS_BOUND = 1e-22 eV -GRAVITON_MASS_PREDICTION = m_Pl 17 18^(-8) eV +GRAVITON_MASS_PREDICTION = m_Pl × φ^(-8) eV HOLOGRAPHIC_CONSTANT = 0.25 HYPERVECTOR_DIM = 1024 @@ -53,11 +53,11 @@ HYPERVECTOR_DIM = 1024 ## E8 Root Structure -### Type 1: (191, 201, 0, 0, 0, 0, 0, 0) with permutations +### Type 1: (±1, ±1, 0, 0, 0, 0, 0, 0) with permutations - 112 roots - Norm squared = 2 -### Type 2: (2122, 2324, 2526, 2728, 2930, 3132, 3334, 3536) with even parity +### Type 2: (±½, ±½, ±½, ±½, ±½, ±½, ±½, ±½) with even parity - 128 roots - Norm squared = 2 @@ -66,26 +66,26 @@ Total: 240 E8 roots ## Sacred Formula Encoding ``` -V = n 37 3^k 38 39^m 40 41^p 42 e^q +V = n × 3^k × π^m × φ^p × e^q ``` ### SacredParams Mapping -| Parameter | Encoding (43) | Encoding (44) | Encoding (m_g) | +| Parameter | Encoding (γ) | Encoding (Λ) | Encoding (m_g) | |----------|--------------|---------------|----------------| -| 45 < 0.24 | {n=1, k=-2, m=0, p=-1, q=1} | | | -| 46 < 0.26 | {n=1, k=-1, m=0, p=-2, q=0} | | | -| 47 48 0.26 | {n=2, k=-2, m=0, p=-2, q=-1} | | | -| 49 | | {n=1, k=-4, m=0, p=-8, q=2} | | +| γ < 0.24 | {n=1, k=-2, m=0, p=-1, q=1} | | | +| γ < 0.26 | {n=1, k=-1, m=0, p=-2, q=0} | | | +| γ ≥ 0.26 | {n=2, k=-2, m=0, p=-2, q=-1} | | | +| Λ | | {n=1, k=-4, m=0, p=-8, q=2} | | | m_g < 1e-24 eV | | | {n=1, k=0, m=0, p=-10, q=-5} | -| m_g 50 1e-24 eV | | | {n=1, k=0, m=0, p=-8, q=0} | +| m_g ≥ 1e-24 eV | | | {n=1, k=0, m=0, p=-8, q=0} | ## Quantum Gravity Projection Maps E8 coordinates to LQG parameters: -- First 4 coordinates 51 spin network (j1, j2, j3, j4) -- Next 2 coordinates 52 Barbero-Immirzi parameter 53 -- Last 2 coordinates 54 scaled cosmological constant 55 +- First 4 coordinates → spin network (j1, j2, j3, j4) +- Next 2 coordinates → Barbero-Immirzi parameter γ +- Last 2 coordinates → scaled cosmological constant Λ ## Tests @@ -94,7 +94,7 @@ test "E8: root generation" { const roots = generateAll() expect(roots.len == 240) expect(roots[0].isValid() == true) - expect(roots[0].normSquared() 56 2.0) + expect(roots[0].normSquared() ≈ 2.0) } test "E8: sacred formula" { diff --git a/specs/physics/gamma-conflict.t27 b/specs/physics/gamma-conflict.t27 index 55a6e80a2d..ca3ca9af11 100644 --- a/specs/physics/gamma-conflict.t27 +++ b/specs/physics/gamma-conflict.t27 @@ -9,25 +9,25 @@ ## Abstract -This spec defines Conjecture GI1: the Barbero-Immirzi parameter 0 equals 123 = 45 5 2. The conjecture addresses the "gamma conflict" between Trinity framework and standard LQG values by proposing an algebraically exact candidate that differs from the Meissner (2004) LQG value 67 by only 0.62%. +This spec defines Conjecture GI1: the Barbero-Immirzi parameter γ equals φ⁻³ = √5 − 2. The conjecture addresses the "gamma conflict" between Trinity framework and standard LQG values by proposing an algebraically exact candidate that differs from the Meissner (2004) LQG value γ₁ by only 0.62%. -**Key correction:** 89 = ln2/(1031112) 13 0.1274 is the *entropy coefficient* in S = 1415A/(416), NOT the Immirzi parameter itself. 1718 19 0.2375 is the Immirzi parameter. +**Key correction:** γ₀ = ln2/(√3·π) ≈ 0.1274 is the *entropy coefficient* in S = γ₀A/(4γ), NOT the Immirzi parameter itself. γ₁ ≈ 0.2375 is the Immirzi parameter. --- ## Conjecture Statement -**Conjecture GI1:** 20_true = 212223 = 245 25 2 +**Conjecture GI1:** γ_true = φ⁻³ = √5 − 2 Where: -- 26 = (1 + 275)/2 is the golden ratio (L5 identity: 2829 + 303132 = 3) -- 33 is the Barbero-Immirzi parameter of Loop Quantum Gravity -- 3435 = ln2/(36373) 38 0.237532958... (Meissner 2004, numerical) -- 3940 41 0.273985635... (Ghosh-Mitra 2004, alternative LQG) +- φ = (1 + √5)/2 is the golden ratio (L5 identity: φ² + φ⁻² = 3) +- γ is the Barbero-Immirzi parameter of Loop Quantum Gravity +- γ₁ = ln2/(π√3) ≈ 0.237532958... (Meissner 2004, numerical) +- γ₂ ≈ 0.273985635... (Ghosh-Mitra 2004, alternative LQG) **Gap analysis:** -- 42(4344 - 45_46)/4748 = 0.6167% (2249 smaller than internal LQG dispute) -- 50(5152 - 5354)/5556 = 13.9% (internal LQG dispute) +- Δ(γ₁ - γ_φ)/γ₁ = 0.6167% (22× smaller than internal LQG dispute) +- Δ(γ₂ - γ₁)/γ₁ = 13.9% (internal LQG dispute) --- @@ -38,20 +38,20 @@ Where: The Barbero-Immirzi parameter must satisfy: ``` -ln(2)/57 < 58 < ln(3)/59 +ln(2)/π < γ < ln(3)/π ``` **Values:** -- Lower bound: ln(2)/60 61 0.220635600... -- Upper bound: ln(3)/62 63 0.349699152... +- Lower bound: ln(2)/π ≈ 0.220635600... +- Upper bound: ln(3)/π ≈ 0.349699152... -**Verification for 64_65:** -- 66_67 = 0.236067977... -- ln(2)/68 < 69_70 < ln(3)/71 72 +**Verification for γ_φ:** +- γ_φ = 0.236067977... +- ln(2)/π < γ_φ < ln(3)/π ✓ -**Verification for 7374:** -- 7576 = 0.237532958... -- ln(2)/77 < 7879 < ln(3)/80 81 +**Verification for γ₁:** +- γ₁ = 0.237532958... +- ln(2)/π < γ₁ < ln(3)/π ✓ **Both candidates satisfy DL bounds.** @@ -60,12 +60,12 @@ ln(2)/57 < 58 < ln(3)/59 In LQG, the minimum area eigenvalue is: ``` -A_min = 8828384_P85 +A_min = 8πγℓ_P² ``` **Values:** -- With 86_87: A_min = 288893(905912)92_P93 94 2.569195_P96 -- With 9798: A_min = 899(ln2/(1001013))102_P103 104 2.5850105_P106 +- With γ_φ: A_min = 2π√3(√5−2)ℓ_P² ≈ 2.5691ℓ_P² +- With γ₁: A_min = 8π(ln2/(π√3))ℓ_P² ≈ 2.5850ℓ_P² --- @@ -75,35 +75,35 @@ A_min = 8828384_P85 **Specification:** ``` -G = 107108109110/111 112 G_Pl +G = π³γ²/φ · G_Pl ``` -**With 113_114 = 115116117:** +**With γ_φ = φ⁻³:** ``` -G = 118119120121122/123 = 124125126127128 +G = π³φ⁻⁶/φ = π³φ⁻⁷ ``` -The 129 parameter is eliminated entirely. +The γ parameter is eliminated entirely. **Predictions:** -- With 130_131: G/G_Pl = 1.0679... (0.0679% deviation from G_Pl baseline) -- With 132133: G/G_Pl = 1.0812... (0.0812% deviation) +- With γ_φ: G/G_Pl = 1.0679... (0.0679% deviation from G_Pl baseline) +- With γ₁: G/G_Pl = 1.0812... (0.0812% deviation) -**Status:** 134_135 gives 3.4136 better fit to CODATA 2022 than 137138. +**Status:** γ_φ gives 3.4× better fit to CODATA 2022 than γ₁. ### Formula BH1: Black Hole Entropy **Specification:** ``` -S = A/(4139) + O(140141) +S = A/(4γ) + O(γ⁰) ``` **Relative shift:** ``` -142S/S = 2143144145/146 +ΔS/S = 2·Δγ/γ ``` **Predictions:** -- 147148 149 150_151: 152S/S = 2 153 0.6167% = 1.233% +- γ₁ → γ_φ: ΔS/S = 2 × 0.6167% = 1.233% **Status:** Currently below observational sensitivity for stellar-mass black holes. @@ -111,12 +111,12 @@ S = A/(4139) + O(140141) **Specification:** ``` -T_H = T_H^(Hawking) 154 [1 - 155156157158/6 + O(159160)] +T_H = T_H^(Hawking) · [1 - π²γ²/6 + O(γ⁴)] ``` **Predictions:** -- With 161_162: Correction = 1639.1669% -- With 164165: Correction = 1669.2810% +- With γ_φ: Correction = −9.1669% +- With γ₁: Correction = −9.2810% - Difference: 0.1141% **Status:** Below any conceivable measurement at current technology. @@ -125,16 +125,16 @@ T_H = T_H^(Hawking) 154 [1 - 155156157158/6 + O(159160)] **SC3 (BCS gap ratio):** ``` -2167/(k_B T_c) = 4168 exp(1691/170) +2Δ/(k_B T_c) = 4π exp(−1/γ) ``` -With 171_172: 4173 exp(1741/175176177) 178 3.528 (BCS: 3.528, exact match) +With γ_φ: 4π exp(−1/φ⁻³) ≈ 3.528 (BCS: 3.528, exact match) **SC4 (Debye model):** ``` -T_c(max) = 179180181_D/(2182k_B) +T_c(max) = γ·ω_D/(2πk_B) ``` -**Status:** Critical temperature predictions shift by 0.62%, within experimental 1831 K (1%) precision. +**Status:** Critical temperature predictions shift by 0.62%, within experimental ±1 K (1%) precision. --- @@ -142,42 +142,42 @@ T_c(max) = 179180181_D/(2182k_B) ### test: gamma_candidates_comparison -Compare 184_185, 186187, and 188189 across four 190-dependent formulas. +Compare γ_φ, γ₁, and γ₂ across four γ-dependent formulas. **Formulae tested:** -- G1: Newton's G = 191192193194/195 -- BH1: Entropy shift = 2196197198/199 -- BH2: Temperature correction = 200201202203204/6 -- SC3: BCS gap = 4205 exp(2061/207) +- G1: Newton's G = π³γ²/φ +- BH1: Entropy shift = 2·Δγ/γ +- BH2: Temperature correction = −π²γ²/6 +- SC3: BCS gap = 4π exp(−1/γ) **Expected results:** -1. G1 with 208_209: 0.0679% deviation from G_Pl -2. G1 with 210211: 0.0812% deviation from G_Pl -3. 212_213 within DL bounds: True -4. 214215 within DL bounds: True -5. 216(217218 - 219_220)/221222 = 0.6167% +1. G1 with γ_φ: 0.0679% deviation from G_Pl +2. G1 with γ₁: 0.0812% deviation from G_Pl +3. γ_φ within DL bounds: True +4. γ₁ within DL bounds: True +5. Δ(γ₁ - γ_φ)/γ₁ = 0.6167% ### test: dl_bounds_containment -Verify that 223_224 and 225226 both lie within Domagala-Lewandowski bounds. +Verify that γ_φ and γ₁ both lie within Domagala-Lewandowski bounds. **Expected results:** -1. ln(2)/227 228 0.2206 -2. ln(3)/229 230 0.3497 -3. 0.2206 < 231_232 < 0.3497 -4. 0.2206 < 233234 < 0.3497 +1. ln(2)/π ≈ 0.2206 +2. ln(3)/π ≈ 0.3497 +3. 0.2206 < γ_φ < 0.3497 +4. 0.2206 < γ₁ < 0.3497 ### invariant: exact_closed_form -235_236 has an exact closed form; 237238 is transcendental. +γ_φ has an exact closed form; γ₁ is transcendental. **Statement:** ``` -239_240 = 2415 242 2 243 Q(2445) (algebraic field) -245246 = ln2/(2472483) 249 Q(2505) (transcendental) +γ_φ = √5 − 2 ∈ Q(√5) (algebraic field) +γ₁ = ln2/(π√3) ∉ Q(√5) (transcendental) ``` -**Expected result:** Verify that 251_252 can be expressed as a polynomial in 253 with rational coefficients, while 254255 cannot. +**Expected result:** Verify that γ_φ can be expressed as a polynomial in φ with rational coefficients, while γ₁ cannot. --- @@ -188,21 +188,21 @@ Verify that 223_224 and 225226 both lie within Domagala-Lewandowski bounds. Compute 50-digit precision values for comparison. **Targets:** -1. 256 = (1+2575)/2 (50 digits) -2. 258_259 = 260261262 (50 digits) -3. 263264 = ln2/(2652663) (50 digits) -4. 267(268269 - 270_271)/272273 (6 significant figures) +1. φ = (1+√5)/2 (50 digits) +2. γ_φ = φ⁻³ (50 digits) +3. γ₁ = ln2/(π√3) (50 digits) +4. Δ(γ₁ - γ_φ)/γ₁ (6 significant figures) ### bench: gap_ratio -Compare 274_275 proximity to 276277 vs 278279 proximity to 280281. +Compare γ_φ proximity to γ₁ vs γ₂ proximity to γ₁. **Target:** ``` -ratio = 282(283284 - 285286) / 287(288289 - 290_291) +ratio = Δ(γ₂ - γ₁) / Δ(γ₁ - γ_φ) ``` -**Expected value:** ratio 292 22.5 +**Expected value:** ratio ≈ 22.5 --- @@ -210,26 +210,26 @@ ratio = 282(283284 - 285286) / 287(288289 - 290_291) | Coq Proof | File | Purpose | |-----------|------|---------| -| L5 Identity | `proofs/sacred/l5_identity.v` | Prove 293294 + 295296297 = 3 | -| 298 = 299300301 | `proofs/sacred/gamma_phi3.v` | Prove 302_303 = 3045 305 2 | -| DL Bounds | `proofs/gravity/dl_bounds.v` | Prove 306_307 within [ln2/308, ln3/309] | +| L5 Identity | `proofs/sacred/l5_identity.v` | Prove φ² + φ⁻² = 3 | +| γ = φ⁻³ | `proofs/sacred/gamma_phi3.v` | Prove γ_φ = √5 − 2 | +| DL Bounds | `proofs/gravity/dl_bounds.v` | Prove γ_φ within [ln2/π, ln3/π] | --- ## Falsification Criteria -1. **DL bounds violation:** 310_311 falls outside [ln2/312, ln3/313] +1. **DL bounds violation:** γ_φ falls outside [ln2/π, ln3/π] - Current status: NOT VIOLATED -2. **LQG exclusion:** Rigorous LQG state counting proves 314 315 316317318 +2. **LQG exclusion:** Rigorous LQG state counting proves γ ≠ φ⁻³ - Current status: OPEN -3. **High-precision discrimination:** EHT or LIGO resolves 319 to < 0.5% and excludes 320_321 +3. **High-precision discrimination:** EHT or LIGO resolves γ to < 0.5% and excludes γ_φ - Current EHT precision: ~1.5% - Required: ngEHT 2027+ with < 0.6% precision -4. **Cascade contradiction:** 322-dependent formulas perform worse with 323_324 than 325326 - - Current status: NOT OBSERVED (G1 shows 3.4327 better fit with 328_329) +4. **Cascade contradiction:** γ-dependent formulas perform worse with γ_φ than γ₁ + - Current status: NOT OBSERVED (G1 shows 3.4× better fit with γ_φ) --- @@ -248,5 +248,5 @@ ratio = 282(283284 - 285286) / 287(288289 - 290_291) ## Version History -- v0.2 (2026-04-08): Initial version with corrected 330331 distinction (entropy coefficient vs Immirzi parameter) -- Gap corrected from 13.9% to 0.62% (332333 vs 334_335, not 336337 vs 338339) +- v0.2 (2026-04-08): Initial version with corrected γ₀ distinction (entropy coefficient vs Immirzi parameter) +- Gap corrected from 13.9% to 0.62% (γ₁ vs γ_φ, not γ₂ vs γ₁) diff --git a/specs/physics/gamma_conjecture.t27 b/specs/physics/gamma_conjecture.t27 index 45d847746a..9460d96bab 100644 --- a/specs/physics/gamma_conjecture.t27 +++ b/specs/physics/gamma_conjecture.t27 @@ -1,14 +1,14 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/physics/gamma_conjecture.t27 -// Strand I 0 Loop Quantum Gravity +// Strand I — Loop Quantum Gravity // Conjecture GI1: Barbero-Immirzi Parameter from Golden Section module GammaConjecture { // Import base constants: PHI, PI use math::constants; -// 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 +// ───────────────────────────────────────────────────── // 1. Conjecture GI1 Definition -// 54555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 +// ───────────────────────────────────────────────────── // Claim ID: C-gamma-001 (CONJECTURAL) // Trinity gamma conjecture: gamma_phi = phi^{-3} @@ -34,9 +34,9 @@ module GammaConjecture { const DELTA_GAMMA_2_1_PERCENT : f64 = ((GAMMA_LQG_ALT - GAMMA_LQG_STANDARD).abs() / GAMMA_LQG_STANDARD) * 100.0; -// 107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 +// ───────────────────────────────────────────────────── // 2. Formula Definitions (affected by gamma) -// 160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 +// ───────────────────────────────────────────────────── // Claim IDs: C-gamma-002 to C-gamma-006 // G1: Newton's constant G = pi^3 * gamma^2 / phi @@ -73,9 +73,9 @@ module GammaConjecture { return (gamma * PI / PHI) * scale; } -// 213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 +// ───────────────────────────────────────────────────── // 3. Verification API -// 266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 +// ───────────────────────────────────────────────────── struct GammaConjectureReport { gamma_phi_value : f64; @@ -113,9 +113,9 @@ module GammaConjecture { }; } - // 319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Gamma Conjecture GI1 - // 422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test gamma_phi_from_phi_inverse_cubed // Claim: C-gamma-001 (CONJECTURAL), tolerance: CONJECTURAL @@ -228,8 +228,8 @@ module GammaConjecture { invariant gamma_phi_structurally_simple // Claim: C-gamma-001 (CONJECTURAL), tolerance: CONJECTURAL - // 525_526 = 5275 528 2 uses only 5295 (from 530) and integer 2 - // 531532 = ln(2)/(5335343) uses ln(2), 535, and 5363 + // γ_φ = √5 − 2 uses only √5 (from φ) and integer 2 + // γ₁ = ln(2)/(π√3) uses ln(2), π, and √3 given sqrt5_form = 5.0_f64.sqrt() - 2.0 and gamma_phi = GAMMA_PHI then abs(gamma_phi - sqrt5_form) < 1e-12 diff --git a/specs/physics/hslm_benchmark.t27 b/specs/physics/hslm_benchmark.t27 index a3cd61a936..1368ba9b51 100644 --- a/specs/physics/hslm_benchmark.t27 +++ b/specs/physics/hslm_benchmark.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# HSLM BENCHMARK 0 Platform Benchmark Suite +# HSLM BENCHMARK — Platform Benchmark Suite ## Specification @@ -16,7 +16,7 @@ VOCAB_SIZE = 8192 EMBED_DIM = 512 HIDDEN_DIM = 2048 NUM_BLOCKS = 3 -ESTIMATED_PARAMS 1 1.58M ternary parameters +ESTIMATED_PARAMS ≈ 1.58M ternary parameters CONTEXT_LEN = 512 WARMUP_ITERS = 50 BENCH_ITERS = 1000 @@ -38,7 +38,7 @@ MATMUL_ITERS = 100_000 ### Part 3: Ternary MatVec bandwidth - Scalar vs SIMD comparison -- Matrix: EMBED_DIM 2 HIDDEN_DIM (512 3 2048) +- Matrix: EMBED_DIM × HIDDEN_DIM (512 × 2048) - Measures: ns/op, GOPS, speedup ### Part 4: Memory usage @@ -78,7 +78,7 @@ printPlatformTable(writer, single, multi) -> void ``` test "HSLM-Bench: parameter estimation" { - expect(ESTIMATED_PARAMS 4 1.58M) + expect(ESTIMATED_PARAMS ≈ 1.58M) } test "HSLM-Bench: configuration consistency" { diff --git a/specs/physics/lqg_cs_bridge.t27 b/specs/physics/lqg_cs_bridge.t27 index 3855ebfbfe..c48622984b 100644 --- a/specs/physics/lqg_cs_bridge.t27 +++ b/specs/physics/lqg_cs_bridge.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# KEPLER0NEWTON Implementation Summary +# KEPLER→NEWTON Implementation Summary **Date**: 2026-04-06 **Branch**: ring-71-philoop-clean @@ -11,12 +11,12 @@ Week 1 deliverables completed. Week 2 research task is now COMPLETE. -**Week 1 Status**: 1 COMPLETE -- `specs/physics/su2_chern_simons.t27` 2 SU(2)3 Chern-Simons formalism -- `specs/math/e8_lie_algebra.t27` 4 E5 Lie algebra wrapper -- `specs/physics/lqg_entropy.t27` 6 LQG entropy research (updated) -- `docs/KEPLER-NEWTON-CHERN-SIMONS.md` 7 Theory documentation -- `conformance/kepler_newton_tests.py` 8 152 formula verification +**Week 1 Status**: ✅ COMPLETE +- `specs/physics/su2_chern_simons.t27` — SU(2)₃ Chern-Simons formalism +- `specs/math/e8_lie_algebra.t27` — E₈ Lie algebra wrapper +- `specs/physics/lqg_entropy.t27` — LQG entropy research (updated) +- `docs/KEPLER-NEWTON-CHERN-SIMONS.md` — Theory documentation +- `conformance/kepler_newton_tests.py` — 152 formula verification **Test Results**: 12/16 tests passing (75.0%) @@ -26,15 +26,15 @@ Week 1 deliverables completed. Week 2 research task is now COMPLETE. ### Research Question -**Does SU(2)9 Chern-Simons entropy produce 10 = 111213?** +**Does SU(2)₃ Chern-Simons entropy produce γ = φ⁻³?** ### Honest Assessment -**CONCLUSION**: 14 = 151617 does NOT come from Chern-Simons theory. +**CONCLUSION**: γ = φ⁻³ does NOT come from Chern-Simons theory. ### New Deliverable Created -**`specs/physics/lqg_cs_bridge.t27`** 18 Comprehensive LQG-CS bridge research +**`specs/physics/lqg_cs_bridge.t27`** — Comprehensive LQG-CS bridge research This new spec provides: @@ -46,33 +46,33 @@ This new spec provides: | Barrier | Description | |---------|-------------| -| Dimensional | 2D CS theory 19 3D LQG geometry - no canonical mapping | -| Parametric | 20 has no role in CS (appears only as d_21 = 22), fundamental in LQG | +| Dimensional | 2D CS theory ↔ 3D LQG geometry - no canonical mapping | +| Parametric | γ has no role in CS (appears only as d_τ = φ), fundamental in LQG | | Formula | CS entropy logarithmic in A, LQG entropy linear in A | #### 3. Three Hypothetical Bridge Pathways -**Pathway A**: CS Effective Action 23 Wilson Loop Effective Action +**Pathway A**: CS Effective Action → Wilson Loop Effective Action - Status: No derivation exists - Barriers: CS is topological (metric-independent), Wilson loop action would be metric-dependent -**Pathway B**: Wilson Loop 24 LQG Area Operator with CS Corrections +**Pathway B**: Wilson Loop → LQG Area Operator with CS Corrections - Status: No calculation exists - Barriers: CS Wilson loops are 1D in 2D, LQG area is 3D surface operator -**Pathway C**: Area Spectrum from CS-Corrected LQG 25 26 +**Pathway C**: Area Spectrum from CS-Corrected LQG → γ - Status: No result exists -- Barriers: No known CS correction form 2728(29), ln(30) too small to fix 31 mismatch +- Barriers: No known CS correction form ΔÂ(φ), ln(φ) too small to fix γ mismatch #### 4. Honest Conclusion -32 = 333435 does NOT emerge from Chern-Simons theory. The connection, if any, would require three novel theoretical steps that face fundamental obstacles and are not established in literature. +γ = φ⁻³ does NOT emerge from Chern-Simons theory. The connection, if any, would require three novel theoretical steps that face fundamental obstacles and are not established in literature. #### 5. Alternative Research Directions -- **3D Generalization of Chern-Simons**: Find 3+1D TQFT where 36 is fundamental -- **Group Theoretical Bridge**: Relate SU(2)37 to E38 preserving 39 (but E40 doesn't justify 41 = 424344) -- **Alternative LQG Formulation**: Modify area operator to include ln(45) term (ad hoc, not derived) +- **3D Generalization of Chern-Simons**: Find 3+1D TQFT where φ is fundamental +- **Group Theoretical Bridge**: Relate SU(2)₃ to E₈ preserving φ (but E₈ doesn't justify γ = φ⁻³) +- **Alternative LQG Formulation**: Modify area operator to include ln(φ) term (ad hoc, not derived) --- @@ -90,7 +90,7 @@ This new spec provides: **Known Issues** (not blocking): - Jones polynomial (trefoil): Error 2.36e-01 -- Barbero-Immirzi from 46: Error 2.10e-13 +- Barbero-Immirzi from φ: Error 2.10e-13 - Sacred gravity constant: Error 8.40e+10 (G/G_measured ratio issue) - Sacred dark energy: Error 6.84e-01 (formula interpretation issue) @@ -98,11 +98,11 @@ This new spec provides: ## Files Created/Modified in This Session -1. `specs/physics/lqg_cs_bridge.t27` 47 NEW: LQG-CS bridge research +1. `specs/physics/lqg_cs_bridge.t27` — NEW: LQG-CS bridge research - Theoretical framework comparison (CS vs LQG) - Three fundamental incompatibilities documented - Three hypothetical bridge pathways analyzed with challenges - - Honest conclusion: 48 = 495051 NOT from CS + - Honest conclusion: γ = φ⁻³ NOT from CS - Alternative research directions proposed - Full bibliography included @@ -110,10 +110,10 @@ This new spec provides: ## Status Summary -**Week 1**: 52 COMPLETE 53 Chern-Simons foundation, E54 wrapper, documentation -**Week 2**: 55 COMPLETE 56 LQG entropy research with comprehensive bridge analysis +**Week 1**: ✅ COMPLETE — Chern-Simons foundation, E₈ wrapper, documentation +**Week 2**: ✅ COMPLETE — LQG entropy research with comprehensive bridge analysis -**Next Steps**: Week 3 tasks (E57 integration, verification, synthesis) +**Next Steps**: Week 3 tasks (E₈ integration, verification, synthesis) // ============================================================================ // TDD-Inside-Spec: Tests and Invariants @@ -131,7 +131,7 @@ invariant lqg_cs_bridge_research_complete assert true test lqg_cs_gamma_conclusion_documented - // Honest conclusion: 58 = 596061 does NOT emerge from Chern-Simons + // Honest conclusion: γ = φ⁻³ does NOT emerge from Chern-Simons then true invariant three_incompatibilities_documented diff --git a/specs/physics/lqg_entropy.t27 b/specs/physics/lqg_entropy.t27 index fbf17f1b19..40e1f8ebb7 100644 --- a/specs/physics/lqg_entropy.t27 +++ b/specs/physics/lqg_entropy.t27 @@ -1,38 +1,38 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/physics/lqg_entropy.t27 -// KEPLER0NEWTON Direction B: LQG 1 2 (PRIORITY 3 - HONEST INQUIRY) +// KEPLER→NEWTON Direction B: LQG → γ (PRIORITY 3 - HONEST INQUIRY) // Status: Final v2.2 // Date: 2026-04-05 // -// HONEST ASSESSMENT: 3 = 456 does NOT come from CS theory. +// HONEST ASSESSMENT: γ = φ⁻³ does NOT come from CS theory. // This spec documents research needed to find: -// 1. Does SU(2) Chern-Simons entropy produce 7 = 8910? -// 2. If not, what alternative 11 emerges from theory? +// 1. Does SU(2) Chern-Simons entropy produce γ = φ⁻³? +// 2. If not, what alternative γ emerges from theory? // // References: // - Meissner 2004: Black hole area gap and Immirzi parameter // - Rovelli 2015: LQG entropy review // - Perez 2017: LQG black hole spectroscopy // -// HONEST CONCLUSION: The relationship between SU(2)12 Chern-Simons and LQG Immirzi 13 -// is NOT established in the literature. Both theories treat 14 differently: +// HONEST CONCLUSION: The relationship between SU(2)₃ Chern-Simons and LQG Immirzi γ +// is NOT established in the literature. Both theories treat γ differently: // -// CS theory: 15 emerges from quantum dimension d = 16 via topological +// CS theory: γ emerges from quantum dimension d = φ via topological // invariants (quantum dimension appears in CS entropy). -// LQG theory: 17 = Barbero-Immirzi parameter, fixed from area +// LQG theory: γ = Barbero-Immirzi parameter, fixed from area // spectrum quantization (Meissner gap formula). // -// These are DIFFERENT origins for 18: -// - CS 19: Property of anyons, emerges from topological structure -// - LQG 20: Quantization parameter from LQG area operator +// These are DIFFERENT origins for γ: +// - CS γ: Property of anyons, emerges from topological structure +// - LQG γ: Quantization parameter from LQG area operator // -// UNRESOLVED: How does 21 = d_22 in CS theory relate to 23 in LQG? +// UNRESOLVED: How does φ = d_τ in CS theory relate to γ in LQG? // This is a FUNDAMENTAL GAP in theoretical foundation. // -// RESEARCH PATHWAY: To establish 24 = 252627 would require: -// 1. CS effective action 28 Wilson loop effective action -// 2. Wilson loop 29 LQG area operator with CS corrections -// 3. Area spectrum from CS-corrected LQG 30 31 that equals 323334 +// RESEARCH PATHWAY: To establish γ = φ⁻³ would require: +// 1. CS effective action → Wilson loop effective action +// 2. Wilson loop → LQG area operator with CS corrections +// 3. Area spectrum from CS-corrected LQG → γ that equals φ⁻³ // // This is NOT found in published papers and would be NOVEL RESEARCH. @@ -50,17 +50,17 @@ test lqg_entropy_module_exists then true invariant lqg_entropy_research_documented - // This spec documents that 35 = 363738 does NOT come from CS theory + // This spec documents that γ = φ⁻³ does NOT come from CS theory // and identifies the research gap between CS and LQG theories assert true test lqg_cs_gamma_origin_different_from_lqg - // Verify documentation: CS 39 emerges from quantum dimension d = 40 - // LQG 41 = Barbero-Immirzi parameter from area spectrum quantization + // Verify documentation: CS γ emerges from quantum dimension d = φ + // LQG γ = Barbero-Immirzi parameter from area spectrum quantization then true invariant lqg_unresolved_gap_documented - // The relationship between CS quantum dimension and LQG Immirzi 42 + // The relationship between CS quantum dimension and LQG Immirzi γ // is NOT established in the literature assert true diff --git a/specs/physics/p2_brain_physics.t27 b/specs/physics/p2_brain_physics.t27 index 20b37f36c8..e43fc01099 100644 --- a/specs/physics/p2_brain_physics.t27 +++ b/specs/physics/p2_brain_physics.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -// Module: P2 Brain 0 Physics Engine Framework -// 12 + 1/34 = 3 | TRINITY +// Module: P2 Brain — Physics Engine Framework +// φ² + 1/φ² = 3 | TRINITY module P2Brain { // ======================================================================== @@ -20,7 +20,7 @@ module P2Brain { pub const PHI_INV : gf16 = numeric::phi_ratio::PHI_INV; pub const PHI_INV_SQ : gf16 = numeric::phi_ratio::PHI_INV_SQ; - // Trinity identity: 56 + 789 = 3 + // Trinity identity: φ² + φ⁻² = 3 pub const TRINITY_PHI_SQ_INV : gf16 = numeric::phi_ratio::TRINITY_PHI_SQ_INV; // Planck constant (from physics/sacred_constants.t27) diff --git a/specs/physics/pellis-formulas.t27 b/specs/physics/pellis-formulas.t27 index eb19fc80cf..902282c5f4 100644 --- a/specs/physics/pellis-formulas.t27 +++ b/specs/physics/pellis-formulas.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/physics/pellis-formulas.t27 -// Trinity x Pellis hybrid 0 thin-structure formulas anchored on L5 (issue #277). +// Trinity x Pellis hybrid — thin-structure formulas anchored on L5 (issue #277). // SSOT: invariants tie Pell ladders to phi; observables are references for tri math compare. // // Anchor (L5): phi^2 + phi^-2 = 3 | TRINITY diff --git a/specs/physics/quantum.t27 b/specs/physics/quantum.t27 index fc743da57b..1659edc810 100644 --- a/specs/physics/quantum.t27 +++ b/specs/physics/quantum.t27 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -# TERNARY QUANTUM VM 0 CLI Runner +# TERNARY QUANTUM VM — CLI Runner ## Specification @@ -24,32 +24,32 @@ phi^2 + 1/phi^2 = 3 = TRINITY ## Commands -### chsh 1 CHSH Correlation Test +### chsh — CHSH Correlation Test - Runs CHSH-like correlation test on qutrits - Options: --trials N (default: 10000), --sacred, --entangled - Measures correlation, classical bound, violation detection -### cglmp 2 CGLMP Inequality Test +### cglmp — CGLMP Inequality Test - Runs CGLMP inequality test with entangled pairs - Collins-Gisin-Linden-Massar-Popescu 2002 - Tests: entangled non-maximally pair vs separable product state -### demo 3 Demonstration +### demo — Demonstration - Shows qutrit gates and measurement operations - Displays basis states, superposition, entanglement -### bench 4 Benchmark +### bench — Benchmark - Benchmarks gate operations - Measures per-gate latency and throughput -### weights 5 Weight Generation +### weights — Weight Generation - Generates quantum-derived weights for FPGA dot product - Option: --entangled for entanglement-derived signatures ## Sacred Phase Encoding - Sacred golden angle phase applied to qutrits -- Phase shift: 6-based sacred angle +- Phase shift: φ-based sacred angle - Used in entangled pair measurements ## Tests @@ -66,6 +66,6 @@ test "Quantum-CGLMP: entangled vs separable" { } test "Quantum: TRINITY identity" { - expect(phi^2 + phi^(-2) 7 3.0) + expect(phi^2 + phi^(-2) ≈ 3.0) } ``` diff --git a/specs/physics/sacred_verification.t27 b/specs/physics/sacred_verification.t27 index b8a5fa5763..7f79342554 100644 --- a/specs/physics/sacred_verification.t27 +++ b/specs/physics/sacred_verification.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/physics/sacred_verification.t27 -// KEPLER0NEWTON Sacred Formula Verification Spec +// KEPLER→NEWTON Sacred Formula Verification Spec // Status: Final v1.0 // Date: 2026-04-06 // @@ -19,14 +19,14 @@ module SacredVerification { use math::constants; use math::sacred_physics; - // 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 + // ═══════════════════════════════════════════════════════════════ // 1. Sacred Formula Categories - // 646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 + // ═════════════════════════════════════════════════════════════════ // The [planned] 152 Sacred Formulas can be classified into: - // - EXACT: Mathematically exact identities (129130 + 131132133 = 3) - // - PHYSICAL: Formulas relating to measured constants (G, 134_135) - // - DERIVED: Values derived from 136 (137 = 138139140) + // - EXACT: Mathematically exact identities (φ² + φ⁻² = 3) + // - PHYSICAL: Formulas relating to measured constants (G, Ω_Λ) + // - DERIVED: Values derived from φ (γ = φ⁻³) // - CONJECTURAL: Hypotheses not yet proven enum FormulaCategory { @@ -47,9 +47,9 @@ module SacredVerification { notes : string, } - // 141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 + // ═════════════════════════════════════════════════════════════ // 2. Verification Status - // 202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 + // ═══════════════════════════════════════════════════════════════ enum VerificationStatus { PASS, // Within tolerance @@ -69,9 +69,9 @@ module SacredVerification { notes : string, } - // 265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 + // ═════════════════════════════════════════════════════════════════ // 3. Core Sacred Formulas (EXACT Category) - // 330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 + // ═════════════════════════════════════════════════════════════════ fn phi_identity_results() -> [5]FormulaDefinition { return [ @@ -79,7 +79,7 @@ module SacredVerification { FormulaDefinition{ id = 1, name = "TRINITY Identity", - formula = "395396 + 397398399", + formula = "φ² + φ⁻²", category = EXACT, expected = sacred_physics::TRINITY, tolerance = 1e-12, @@ -90,40 +90,40 @@ module SacredVerification { FormulaDefinition{ id = 2, name = "Golden Ratio", - formula = "400", + formula = "φ", category = EXACT, expected = sacred_physics::PHI, tolerance = 1e-15, scale_factor = 1.0, - notes = "Fundamental constant: (1+4015)/2", + notes = "Fundamental constant: (1+√5)/2", }, // Inverse golden ratio FormulaDefinition{ id = 3, name = "Inverse Golden Ratio", - formula = "402403404", + formula = "φ⁻¹", category = EXACT, expected = sacred_physics::PHI_INV, tolerance = 1e-15, scale_factor = 1.0, notes = "IIT consciousness threshold", }, - // 405 squared + // φ squared FormulaDefinition{ id = 4, name = "Golden Ratio Squared", - formula = "406407", + formula = "φ²", category = EXACT, expected = sacred_physics::PHI_SQ, tolerance = 1e-15, scale_factor = 1.0, notes = "Appears in CS level theorem", }, - // 408 inverse squared + // φ inverse squared FormulaDefinition{ id = 5, name = "Inverse Golden Ratio Squared", - formula = "409410411", + formula = "φ⁻²", category = EXACT, expected = sacred_physics::PHI_INV_SQ, tolerance = 1e-15, @@ -133,9 +133,9 @@ module SacredVerification { ]; } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 + // ═════════════════════════════════════════════════════════════════ // 4. Chern-Simons Formulas (EXACT Category) - // 477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ═══════════════════════════════════════════════════════════════════ fn chern_simons_formulas() -> [5]FormulaDefinition { return [ @@ -143,63 +143,63 @@ module SacredVerification { FormulaDefinition{ id = 10, name = "Fibonacci Anyon Dimension", - formula = "d_544 = sin(3545/5)/sin(546/5)", + formula = "d_τ = sin(3π/5)/sin(π/5)", category = EXACT, expected = sacred_physics::PHI, tolerance = 1e-10, scale_factor = 1.0, - notes = "SU(2)547 Chern-Simons: d_548 = 549", + notes = "SU(2)₃ Chern-Simons: d_τ = φ", }, // CS level theorem FormulaDefinition{ id = 11, name = "CS Level Theorem", - formula = "k = d_550551 + d_552553554", + formula = "k = d_τ² + d_τ⁻²", category = EXACT, expected = 3.0, tolerance = 1e-10, scale_factor = 1.0, - notes = "Chern-Simons level k=3 from 555", + notes = "Chern-Simons level k=3 from φ", }, // Jones polynomial magnitude FormulaDefinition{ id = 12, name = "Jones Polynomial (Trefoil)", - formula = "|V(e^{2556i/5})|557 = 3 - 558559560 = 561562 - 563", + formula = "|V(e^{2πi/5})|² = 3 - φ⁻¹ = φ² - γ", category = EXACT, - expected = 3.0 - sacred_physics::PHI_INV, // 564 2.382 + expected = 3.0 - sacred_physics::PHI_INV, // ≈ 2.382 tolerance = 1e-10, scale_factor = 1.0, - notes = "Connects Jones polynomial to 565 and 566 (Barbero-Immirzi)", + notes = "Connects Jones polynomial to φ and γ (Barbero-Immirzi)", }, // Fibonacci fusion probability FormulaDefinition{ id = 13, name = "Fibonacci Fusion Sum", - formula = "p_1 + p_567", + formula = "p_1 + p_τ", category = EXACT, expected = 1.0, tolerance = 1e-10, scale_factor = 1.0, - notes = "568569570 = 1+571 fusion normalization", + notes = "τ×τ = 1+τ fusion normalization", }, // Braiding phase FormulaDefinition{ id = 14, name = "Fibonacci Braiding Phase", - formula = "R(572,573,574)", + formula = "R(τ,τ,τ)", category = EXACT, expected = 4.0 * constants::PI / 5.0, tolerance = 1e-15, scale_factor = 1.0, - notes = "Topological spin: exp(4575i/5)", + notes = "Topological spin: exp(4πi/5)", }, ]; } - // 576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 - // 5. LQG and 645 Formulas (DERIVED Category) - // 646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 + // ═════════════════════════════════════════════════════════════════════ + // 5. LQG and γ Formulas (DERIVED Category) + // ═════════════════════════════════════════════════════════════════════ fn lqg_gamma_formulas() -> [5]FormulaDefinition { return [ @@ -207,7 +207,7 @@ module SacredVerification { FormulaDefinition{ id = 20, name = "Barbero-Immirzi Parameter", - formula = "715 = 716717718", + formula = "γ = φ⁻³", category = DERIVED, expected = sacred_physics::GAMMA_LQG, tolerance = 1e-15, @@ -218,18 +218,18 @@ module SacredVerification { FormulaDefinition{ id = 21, name = "Area Gap (Meissner)", - formula = "719 = 720721 + 722(2723724)", + formula = "Δ = γ² + √(2γ²)", category = DERIVED, expected = 0.0857, tolerance = 1e-3, scale_factor = 1.0, - notes = "For 725 = 726727728: 729 730 0.0857", + notes = "For γ = φ⁻³: Δ ≈ 0.0857", }, // Meissner gap (standard) FormulaDefinition{ id = 22, - name = "Meissner Gap (731=0.274)", - formula = "732(733_Meissner)", + name = "Meissner Gap (γ=0.274)", + formula = "Δ(γ_Meissner)", category = PHYSICAL, expected = 0.110, tolerance = 1e-2, @@ -240,72 +240,72 @@ module SacredVerification { FormulaDefinition{ id = 23, name = "Immirzi Ratio", - formula = "734_735 / 736_Meissner", + formula = "γ_φ / γ_Meissner", category = DERIVED, expected = 0.861, tolerance = 1e-3, scale_factor = 1.0, - notes = "737738739 / 0.274 740 0.861 (13.9% gap)", + notes = "φ⁻³ / 0.274 ≈ 0.861 (13.9% gap)", }, ]; } - // 741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809 - // 6. E810 Formulas (EXACT Category) - // 811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 + // ═════════════════════════════════════════════════════════════════════ + // 6. E₈ Formulas (EXACT Category) + // ═════════════════════════════════════════════════════════════════════ fn e8_formulas() -> [5]FormulaDefinition { return [ - // E880 dimension + // E₈ dimension FormulaDefinition{ id = 30, - name = "E881 Dimension", - formula = "dim(E882)", + name = "E₈ Dimension", + formula = "dim(E₈)", category = EXACT, expected = 248.0, tolerance = 0.0, scale_factor = 1.0, notes = "Adjoint representation dimension", }, - // E883 root count + // E₈ root count FormulaDefinition{ id = 31, - name = "E884 Root Count", - formula = "roots(E885)", + name = "E₈ Root Count", + formula = "roots(E₈)", category = EXACT, expected = 240.0, tolerance = 0.0, scale_factor = 1.0, notes = "240 + 8 Cartan = 248", }, - // Cartan eigenvalue 886887 + // Cartan eigenvalue λ₃ FormulaDefinition{ id = 32, - name = "E888 Cartan 889890", - formula = "891892 = 2 - 2cos(893/5)", + name = "E₈ Cartan λ₃", + formula = "λ₃ = 2 - 2cos(π/5)", category = EXACT, expected = sacred_physics::PHI_INV_SQ, tolerance = 0.01, scale_factor = 1.0, - notes = "Confirmed: 894895 = 896897898", + notes = "Confirmed: λ₃ = φ⁻²", }, - // E899 900 2D projection + // E₈ → 2D projection FormulaDefinition{ id = 33, - name = "E901 902 Golden Icosahedron", - formula = "E903_2D_quasi_projection", + name = "E₈ → Golden Icosahedron", + formula = "E₈_2D_quasi_projection", category = EXACT, expected = 20.0, tolerance = 0.0, scale_factor = 1.0, - notes = "Koca 2019: E904 projects to 2D golden structure", + notes = "Koca 2019: E₈ projects to 2D golden structure", }, ]; } - // 905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977 + // ═════════════════════════════════════════════════════════════════════════ // 7. Physical Constants (PHYSICAL Category - AMBIGUOUS) - // 978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050 + // ═════════════════════════════════════════════════════════════════════════ fn physical_constants_formulas() -> [5]FormulaDefinition { return [ @@ -313,29 +313,29 @@ module SacredVerification { FormulaDefinition{ id = 40, name = "Sacred Gravity", - formula = "G = 1051105210531054/1055 (dimensionless)", + formula = "G = π³γ²/φ (dimensionless)", category = PHYSICAL, expected = 1.6e11, tolerance = 0.2, scale_factor = 1.0, - notes = "10561057 Off by 84% - needs scale factor", + notes = "⚠️ Off by 84% - needs scale factor", }, // Sacred dark energy FormulaDefinition{ id = 41, name = "Sacred Dark Energy", - formula = "1058_1059 = 1060106110621063/10641065", + formula = "Ω_Λ = γ⁸π⁴/φ²", category = PHYSICAL, expected = sacred_physics::OMEGA_LAMBDA_MEASURED, tolerance = 0.001, scale_factor = 1.0, - notes = "10661067 Off by 99.9% - computed 1068 0.0009", + notes = "⚠️ Off by 99.9% - computed ≈ 0.0009", }, // Hubble constant FormulaDefinition{ id = 42, name = "Hubble Constant", - formula = "H1069 (sacred)", + formula = "H₀ (sacred)", category = PHYSICAL, expected = 70.0, tolerance = 5.0, @@ -346,42 +346,42 @@ module SacredVerification { FormulaDefinition{ id = 43, name = "Sacred Gravity (Calibrated)", - formula = "G_calibrated = G_raw 1070 G_SCALE", + formula = "G_calibrated = G_raw × G_SCALE", category = PHYSICAL, expected = sacred_physics::G_MEASURED, tolerance = 0.01, scale_factor = 1.0, - notes = "G_raw 1071 1.068, G_SCALE 1072 6.25e-11", + notes = "G_raw ≈ 1.068, G_SCALE ≈ 6.25e-11", }, // Sacred dark energy (updated) FormulaDefinition{ id = 44, name = "Sacred Dark Energy (Calibrated)", - formula = "1073_1074_calibrated = 1075_1076_raw 1077 OMEGA_COARSE_SCALE", + formula = "Ω_Λ_calibrated = Ω_Λ_raw × OMEGA_COARSE_SCALE", category = PHYSICAL, expected = sacred_physics::OMEGA_LAMBDA_MEASURED, tolerance = 0.01, scale_factor = 1.0, - notes = "1078_1079_raw 1080 0.000359, OMEGA_COARSE_SCALE 1081 1909", + notes = "Ω_Λ_raw ≈ 0.000359, OMEGA_COARSE_SCALE ≈ 1909", }, ]; } - // 108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174 - // 8. Scale Factors for Sacred Formulas (Raw 1175 Calibrated) - // 1176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260 + // ═════════════════════════════════════════════════════════════════════════════════════════════ + // 8. Scale Factors for Sacred Formulas (Raw → Calibrated) + // ═════════════════════════════════════════════════════════════════════════════════════ // Gravitational Constant Scale Factor - const G_RAW: f64 = 1.06791364671254; // 12611262 1263 12641265 / 1266 (dimensionless sacred value) + const G_RAW: f64 = 1.06791364671254; // π³ × γ² / φ (dimensionless sacred value) const G_SCALE: f64 = 6.24984990176514e-11; // G_measured / G_raw // Dark Energy Density Scale Factor - const OMEGA_LAMBDA_RAW: f64 = 0.000358856522493947; // 12671268 1269 12701271 / 12721273 = 12741275 / 127612771278 - const OMEGA_COARSE_SCALE: f64 = 1908.84; // 1279_1280_measured / 1281_1282_raw + const OMEGA_LAMBDA_RAW: f64 = 0.000358856522493947; // γ⁸ × π⁴ / φ² = π⁴ / φ²⁶ + const OMEGA_COARSE_SCALE: f64 = 1908.84; // Ω_Λ_measured / Ω_Λ_raw - // 1283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367 + // ═════════════════════════════════════════════════════════════════════════════════════ // 9. Verification Functions - // 1368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440 + // ═════════════════════════════════════════════════════════════════════════ fn verify_formula(formula: FormulaDefinition, computed: f64) -> VerificationResult { const abs_error = computed - formula.expected; @@ -463,9 +463,9 @@ module SacredVerification { }; } - // 144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545 + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for Sacred Formula Verification - // 15461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ test trinity_identity_exact given formula = phi_identity_results()[0] @@ -514,7 +514,7 @@ module SacredVerification { then result.status == VerificationStatus::PASS test sacred_gravity_calibrated_passes - // Test: G_calibrated = G_raw 1677 G_SCALE 1678 G_measured + // Test: G_calibrated = G_raw × G_SCALE ≈ G_measured given g_raw = G_RAW and g_scale = G_SCALE and g_measured = sacred_physics::G_MEASURED @@ -524,7 +524,7 @@ module SacredVerification { then rel_error < 0.01 // 1% tolerance for calibrated pipeline test sacred_dark_energy_calibrated_passes - // Test: 1679_1680_calibrated = 1681_1682_raw 1683 OMEGA_COARSE_SCALE 1684 1685_1686_measured + // Test: Ω_Λ_calibrated = Ω_Λ_raw × OMEGA_COARSE_SCALE ≈ Ω_Λ_measured given omega_raw = OMEGA_LAMBDA_RAW and omega_scale = OMEGA_COARSE_SCALE and omega_measured = sacred_physics::OMEGA_LAMBDA_MEASURED @@ -534,7 +534,7 @@ module SacredVerification { then rel_error < 0.01 // 1% tolerance for calibrated pipeline test jones_polynomial_identity - // Test: |V(e^{21687i/5})|1688 = 3 - 168916901691 = 16921693 - 1694 + // Test: |V(e^{2πi/5})|² = 3 - φ⁻¹ = φ² - γ given expected = 3.0 - sacred_physics::PHI_INV and gamma = sacred_physics::GAMMA_LQG and alt_expected = sacred_physics::PHI_SQ - gamma diff --git a/specs/physics/su2_chern_simons.t27 b/specs/physics/su2_chern_simons.t27 index ae28be7f1e..71025c1153 100644 --- a/specs/physics/su2_chern_simons.t27 +++ b/specs/physics/su2_chern_simons.t27 @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/physics/su2_chern_simons.t27 -// SU(2)_k Chern-Simons Theory 0 Topological QFT Foundation +// SU(2)_k Chern-Simons Theory — Topological QFT Foundation // Direction F (Priority 1) of PROJECT KEPLER->NEWTON // // This module formalizes the PROVEN THEOREM: golden ratio phi emerges // from SU(2) Chern-Simons theory at level k=3 as quantum dimension -// of Fibonacci anyons. This is NOT numerology 1 it is a mathematical +// of Fibonacci anyons. This is NOT numerology — it is a mathematical // consequence of the fusion rule tau x tau = 1 + tau. // // Key results: @@ -21,7 +21,7 @@ // - Freedman, Kitaev, Larsen, Wang, arXiv:quant-ph/0101025 (2003) // - Witten, Commun. Math. Phys. 121 (1989) 351 // - Zamolodchikov, Int. J. Mod. Phys. A4 (1989) 4235 -// - Minev et al., IBM/Cornell (2024) 2 experimental Fibonacci anyon gates +// - Minev et al., IBM/Cornell (2024) — experimental Fibonacci anyon gates module SU2ChernSimons { use math::constants; @@ -39,7 +39,7 @@ module SU2ChernSimons { // At k=3: sectors labeled j = 0, 1/2, 1, 3/2 const NUM_SECTORS : i64 = CS_LEVEL + 1; // = 4 - // k+2 = 5 3 this is the cyclotomic index + // k+2 = 5 — this is the cyclotomic index // All appearances of phi trace to Q(sqrt(5)) and 5th roots of unity const CYCLOTOMIC_INDEX : i64 = CS_LEVEL + 2; // = 5 @@ -148,7 +148,7 @@ module SU2ChernSimons { // The deepest connection: CS level k=3 and the TRINITY identity // phi^2 + phi^{-2} = 3 = k - // This is not a coincidence 4 it reflects that phi arises from + // This is not a coincidence — it reflects that phi arises from // the cyclotomic field Q(sqrt(5)) where 5 = k + 2 fn trinity_equals_cs_level() -> bool { diff --git a/specs/physics/zamolodchikov_4d_conjecture.t27 b/specs/physics/zamolodchikov_4d_conjecture.t27 index 56bb9688b2..78a8f59cd8 100644 --- a/specs/physics/zamolodchikov_4d_conjecture.t27 +++ b/specs/physics/zamolodchikov_4d_conjecture.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/physics/zamolodchikov_4d_conjecture.t27 -// 4D Zamolodchikov Conjecture 0 The Breakthrough Hypothesis +// 4D Zamolodchikov Conjecture — The Breakthrough Hypothesis // Direction E of PROJECT KEPLER->NEWTON // // HYPOTHESIS: A 4D quantum field theory with E8 integrable structure @@ -29,9 +29,9 @@ // - Zamolodchikov, Int. J. Mod. Phys. A4 (1989) 4235 // - Seiberg & Witten, Nucl. Phys. B426 (1994) 19-52 // - Ashwinkumar et al., arXiv:2309.14412 (2023) -// - Beisert et al., arXiv:1012.3982 (2010) 1 N=4 SYM integrability review -// - Razamat et al., SciPost Phys. 8 (2020) 014 2 rank Q E-string with E8 -// - Kaushik et al., arXiv:2206.06911 (2024) 3 E8 x E8 unification +// - Beisert et al., arXiv:1012.3982 (2010) — N=4 SYM integrability review +// - Razamat et al., SciPost Phys. 8 (2020) 014 — rank Q E-string with E8 +// - Kaushik et al., arXiv:2206.06911 (2024) — E8 x E8 unification module Zamolodchikov4DConjecture { use math::constants; diff --git a/specs/pins/parser.t27 b/specs/pins/parser.t27 index 4511ec6b32..034d4bdec7 100644 --- a/specs/pins/parser.t27 +++ b/specs/pins/parser.t27 @@ -580,4 +580,4 @@ module PinsParser { } } -// 01 + 1/23 = 3 | TRINITY \ No newline at end of file +// φ² + 1/φ² = 3 | TRINITY \ No newline at end of file diff --git a/specs/queen/brain_summaries.t27 b/specs/queen/brain_summaries.t27 index 1b7ba305b7..59fb413a3d 100644 --- a/specs/queen/brain_summaries.t27 +++ b/specs/queen/brain_summaries.t27 @@ -3,14 +3,14 @@ // Queen Brain Summaries Pipeline Specification // Ring 061 - Episode summarization for Queen brain // Defines how experience episodes are aggregated into summaries -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module BrainSummaries { use queen::lotus; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Summary Configuration - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ const MAX_EPISODES_PER_SUMMARY : usize = 50; const SUMMARY_RETENTION_DAYS : usize = 90; @@ -22,9 +22,9 @@ module BrainSummaries { const SUMMARY_TYPE_RING : u8 = 2; const SUMMARY_TYPE_PHASE : u8 = 3; - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Summary Data Structures - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ // Brain summary record struct BrainSummary { @@ -72,11 +72,11 @@ module BrainSummaries { last_summary_id : usize, } - // 256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 + // ═════════════════════════════════════════════════════ // 3. Episode Aggregation - // 309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 + // ═════════════════════════════════════════════════════════════════════════ - // aggregate_episodes() 382 BrainSummary + // aggregate_episodes() → BrainSummary // Aggregate episodes into a summary fn aggregate_episodes(episodes: []lotus.Episode, summary_type: u8) -> BrainSummary { var summary : BrainSummary = undefined; @@ -136,11 +136,11 @@ module BrainSummaries { return summary; } - // 383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 + // ═════════════════════════════════════════════════════ // 4. Quality Assessment - // 436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 + // ═════════════════════════════════════════════════════════════════════════ - // determine_quality() 509 u8 + // determine_quality() → u8 // Determine overall quality from metrics fn determine_quality(summary: BrainSummary) -> u8 { const success_rate : f64; @@ -161,11 +161,11 @@ module BrainSummaries { } } - // 510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 + // ═════════════════════════════════════════════════════ // 5. Summary Persistence - // 563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 + // ═════════════════════════════════════════════════════════════════════════ - // save_summary() 636 bool + // save_summary() → bool // Save summary to persistent storage fn save_summary(summary: BrainSummary, path: []u8) -> bool { // Implementation: serialize and write to file @@ -173,7 +173,7 @@ module BrainSummaries { return true; } - // load_summary() 637 BrainSummary + // load_summary() → BrainSummary // Load summary from persistent storage fn load_summary(summary_id: usize) -> BrainSummary { var summary : BrainSummary = undefined; @@ -181,11 +181,11 @@ module BrainSummaries { return summary; } - // 638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690 + // ═════════════════════════════════════════════════════ // 6. Summary Generation - // 691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763 + // ═════════════════════════════════════════════════════════════════════════ - // generate_daily_summary() 764 BrainSummary + // generate_daily_summary() → BrainSummary // Generate daily summary of episodes fn generate_daily_summary(day_start: u64, day_end: u64) -> BrainSummary { var episodes : [MAX_EPISODES_PER_SUMMARY]lotus.Episode; @@ -201,7 +201,7 @@ module BrainSummaries { return summary; } - // generate_ring_summary() 765 BrainSummary + // generate_ring_summary() → BrainSummary // Generate summary for a specific ring fn generate_ring_summary(ring_number: usize) -> BrainSummary { var episodes : [MAX_EPISODES_PER_SUMMARY]lotus.Episode; @@ -217,7 +217,7 @@ module BrainSummaries { return summary; } - // generate_phase_summary() 766 BrainSummary + // generate_phase_summary() → BrainSummary // Generate summary for a phase fn generate_phase_summary(phase_number: u8, ring_start: usize, ring_end: usize) -> BrainSummary { var episodes : [MAX_EPISODES_PER_SUMMARY]lotus.Episode; @@ -234,9 +234,9 @@ module BrainSummaries { return summary; } - // 767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ═════════════════════════════════════════════════════ // 7. TDD - Tests - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892 + // ═════════════════════════════════════════════════════════════════════════ test aggregate_empty_episodes var episodes : [0]lotus.Episode = undefined; @@ -305,9 +305,9 @@ module BrainSummaries { when quality = determine_quality(summary) then quality == lotus.QUALITY_BAD - // 893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945 + // ═════════════════════════════════════════════════════ // 8. TDD - Invariants - // 9469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 + // ═════════════════════════════════════════════════════════════════════════ invariant summary_totals_consistency // Total cycles should equal sum of successful and failed @@ -356,9 +356,9 @@ module BrainSummaries { const summary = aggregate_episodes(&episodes, SUMMARY_TYPE_DAILY); assert summary.max_cycle_time_ms >= summary.min_cycle_time_ms - // 10191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071 + // ═════════════════════════════════════════════════════ // 9. TDD - Benchmarks - // 1072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144 + // ═════════════════════════════════════════════════════════════════════════ bench aggregate_50_episodes // Measure: cycles to aggregate 50 episodes diff --git a/specs/queen/lotus.t27 b/specs/queen/lotus.t27 index c9fd915252..744169f657 100644 --- a/specs/queen/lotus.t27 +++ b/specs/queen/lotus.t27 @@ -2,7 +2,7 @@ // t27/specs/queen/lotus.t27 // Queen Lotus 6-Phase Orchestration Specification // Self-improving agent orchestration with episode-based learning -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module QueenLotus { // Import base types, HSLM, and runtime @@ -10,9 +10,9 @@ module QueenLotus { use nn::hslm; use compiler::runtime; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Lotus Configuration - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ const NUM_PHASES : usize = 6; // 6 phases in Lotus cycle const EPISODE_BUFFER_SIZE : usize = 100; // Max episodes in buffer @@ -45,9 +45,9 @@ module QueenLotus { const DELTA_SET : u8 = 2; // Set parameter const DELTA_WAIT : u8 = 3; // Wait/observe - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Lotus State - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ // Lotus runtime state var current_phase : u8 = PHASE_OBSERVE; @@ -76,9 +76,9 @@ module QueenLotus { var phase_start_time : u64 = 0; const PHASE_TIMEOUT_MS : u64 = 5000; // 5 second timeout per phase - // 256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 + // ═════════════════════════════════════════════════════ // 3. Data Structures - // 309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 + // ═════════════════════════════════════════════════════════════════════════ // Context: system state observation struct Context { @@ -120,11 +120,11 @@ module QueenLotus { total_time_ms : u64, } - // 382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 + // ═════════════════════════════════════════════════════ // 4. Main Orchestration - // 435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 + // ═════════════════════════════════════════════════════════════════════════ - // lotus_orchestrate() 508 CycleResult + // lotus_orchestrate() → CycleResult // Run complete 6-phase Lotus cycle // Returns: context, evaluation, plan, result, outcome fn lotus_orchestrate() -> CycleResult { @@ -154,7 +154,7 @@ module QueenLotus { return result; } - // lotus_phase(phase: u8) 509 PhaseOutput + // lotus_phase(phase: u8) → PhaseOutput // Execute a single phase of the Lotus cycle fn lotus_phase(phase: u8) -> PhaseOutput { current_phase = phase; @@ -177,9 +177,9 @@ module QueenLotus { return PhaseOutput{ .success = false }; } - // 510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 + // ═════════════════════════════════════════════════════ // 5. Phase: Observe - // 563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 + // ═════════════════════════════════════════════════════════════════════════ // PhaseOutput wrapper for observe_state struct PhaseOutput { @@ -187,7 +187,7 @@ module QueenLotus { data : [256]u8 = [0; 256], } - // observe_state() 636 Context + // observe_state() → Context // Gather current state information fn observe_state() -> Context { const active_issues = get_active_issues_count(); @@ -201,29 +201,29 @@ module QueenLotus { }; } - // get_active_issues_count() 637 usize + // get_active_issues_count() → usize // Get number of active issues fn get_active_issues_count() -> usize { // Query issue tracker return 0; // Placeholder } - // get_system_health() 638 f64 + // get_system_health() → f64 // Get system health score (0.0 to 1.0) fn get_system_health() -> f64 { return 1.0; // Placeholder } - // get_timestamp() 639 u64 + // get_timestamp() → u64 // Get current timestamp fn get_timestamp() -> u64 { // Return current time (placeholder) return 0; } - // 640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 + // ═════════════════════════════════════════════════════ // 6. Phase: Recall - // 693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765 + // ═════════════════════════════════════════════════════════════════════════ // RecallEpisode wrapper struct RecallEpisode { @@ -231,7 +231,7 @@ module QueenLotus { count : usize, } - // recall_episodes() 766 RecallEpisode + // recall_episodes() → RecallEpisode // Recall relevant episodes from episode buffer // Uses HSLM for semantic similarity search fn recall_episodes() -> RecallEpisode { @@ -254,9 +254,9 @@ module QueenLotus { }; } - // 767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ═════════════════════════════════════════════════════ // 7. Phase: Evaluate - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892 + // ═════════════════════════════════════════════════════════════════════════ // EvaluationResult wrapper struct EvaluationResult { @@ -264,7 +264,7 @@ module QueenLotus { confidence : f64, } - // evaluate_quality(recalled: RecallEpisode) 893 Evaluation + // evaluate_quality(recalled: RecallEpisode) → Evaluation // Evaluate quality based on episode outcomes fn evaluate_quality(recalled: RecallEpisode) -> Evaluation { var success_count : u8 = 0; @@ -322,7 +322,7 @@ module QueenLotus { }; } - // evaluate_quality_() 894 EvaluationResult + // evaluate_quality_() → EvaluationResult // Wrapper for phase execution fn evaluate_quality_() -> EvaluationResult { const recalled = recall_episodes(); @@ -333,9 +333,9 @@ module QueenLotus { }; } - // 895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947 + // ═════════════════════════════════════════════════════ // 8. Phase: Plan - // 948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020 + // ═════════════════════════════════════════════════════════════════════════ // PlanResult wrapper struct PlanResult { @@ -344,7 +344,7 @@ module QueenLotus { target_value : i32, } - // generate_plan(evaluation: Evaluation) 1021 Plan + // generate_plan(evaluation: Evaluation) → Plan // Generate action plan based on quality evaluation fn generate_plan(evaluation: Evaluation) -> Plan { var delta_type : u8 = DELTA_WAIT; @@ -362,7 +362,7 @@ module QueenLotus { }; } - // generate_plan_() 1022 PlanResult + // generate_plan_() → PlanResult // Wrapper for phase execution fn generate_plan_() -> PlanResult { const eval = evaluate_quality_(); @@ -381,9 +381,9 @@ module QueenLotus { }; } - // 10231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 + // ═════════════════════════════════════════════════════ // 9. Phase: Act - // 1076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148 + // ═════════════════════════════════════════════════════════════════════════ // ActionResult wrapper struct ActionResult { @@ -391,7 +391,7 @@ module QueenLotus { execution_time_ms : u64, } - // execute_action(plan: Plan) 1149 Action + // execute_action(plan: Plan) → Action // Execute the planned action fn execute_action(plan: Plan) -> Action { var success = false; @@ -416,7 +416,7 @@ module QueenLotus { }; } - // execute_action_() 1150 ActionResult + // execute_action_() → ActionResult // Wrapper for phase execution fn execute_action_() -> ActionResult { const plan_result = generate_plan_(); @@ -432,21 +432,21 @@ module QueenLotus { }; } - // scale_up_resources() 1151 bool + // scale_up_resources() → bool // Increase system resources fn scale_up_resources() -> bool { // Increase agent count, memory allocation, etc. return true; } - // scale_down_resources() 1152 bool + // scale_down_resources() → bool // Decrease system resources fn scale_down_resources() -> bool { // Decrease agent count, free memory, etc. return true; } - // set_parameter(plan: Plan) 1153 bool + // set_parameter(plan: Plan) → bool // Set a policy parameter fn set_parameter(plan: Plan) -> bool { // Set parameter from plan @@ -454,9 +454,9 @@ module QueenLotus { return true; } - // 11541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206 + // ═════════════════════════════════════════════════════ // 10. Phase: Record - // 1207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279 + // ═════════════════════════════════════════════════════════════════════════ // RecordResult wrapper struct RecordResult { @@ -464,7 +464,7 @@ module QueenLotus { episode_id : usize, } - // record_episode(cycle_result: CycleResult) 1280 u8 + // record_episode(cycle_result: CycleResult) → u8 // Record episode to buffer fn record_episode(cycle_result: CycleResult) -> u8 { const slot = current_episode % EPISODE_BUFFER_SIZE; @@ -484,7 +484,7 @@ module QueenLotus { return OUTCOME_SUCCESS; // Placeholder } - // record_episode_() 1281 RecordResult + // record_episode_() → RecordResult // Wrapper for phase execution fn record_episode_() -> RecordResult { const cycle_result = CycleResult{ @@ -504,7 +504,7 @@ module QueenLotus { }; } - // determine_outcome(result: CycleResult) 1282 u8 + // determine_outcome(result: CycleResult) → u8 // Determine episode outcome based on action success fn determine_outcome(result: CycleResult) -> u8 { if (result.action.success) { @@ -514,11 +514,11 @@ module QueenLotus { } } - // 12831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335 + // ═════════════════════════════════════════════════════ // 11. Agent Spawning - // 1336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408 + // ═════════════════════════════════════════════════════════════════════════ - // lotus_spawn(agent_type: u8, count: u8) 1409 bool + // lotus_spawn(agent_type: u8, count: u8) → bool // Spawn new agents for orchestration fn lotus_spawn(agent_type: u8, count: u8) -> bool { var spawned : u8 = 0; @@ -533,18 +533,18 @@ module QueenLotus { return true; } - // spawn_agent(agent_type: u8) 1410 bool + // spawn_agent(agent_type: u8) → bool // Spawn a single agent fn spawn_agent(agent_type: u8) -> bool { // Spawn agent of specified type return true; } - // 14111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463 + // ═════════════════════════════════════════════════════ // 12. Phase Management - // 1464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536 + // ═════════════════════════════════════════════════════════════════════════ - // lotus_phase_management() 1537 bool + // lotus_phase_management() → bool // Manage phase transitions and timeouts fn lotus_phase_management() -> bool { if (check_phase_timeout()) { @@ -554,7 +554,7 @@ module QueenLotus { return false; } - // check_phase_timeout() 1538 bool + // check_phase_timeout() → bool // Check if current phase has timed out fn check_phase_timeout() -> bool { const current_time = get_timestamp(); @@ -563,7 +563,7 @@ module QueenLotus { return elapsed > PHASE_TIMEOUT_MS; } - // force_phase_transition() 1539 void + // force_phase_transition() → void // Force transition to next phase fn force_phase_transition() -> void { current_phase = current_phase + 1; @@ -573,9 +573,9 @@ module QueenLotus { } } - // 1540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672 + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for QueenLotus - // 167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813 + // ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ test lotus_num_phases_is_six given phases = NUM_PHASES diff --git a/specs/sandbox/health.t27 b/specs/sandbox/health.t27 index 21c1bbcbad..4366b26eba 100644 --- a/specs/sandbox/health.t27 +++ b/specs/sandbox/health.t27 @@ -16,15 +16,15 @@ use sandbox.session_timeout; use timestamp; use sandbox.session; -// 01234567891011121314151617181920212223242526272829303132333435363738394041424344 +// ───────────────────────────────────────────── // Configuration -// 454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 +// ───────────────────────────────────────────── const DEFAULT_POLL_INTERVAL_MS : usize = 10_000; // 10 seconds between health checks -// 90919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 +// ───────────────────────────────────────────── // Interface -// 135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 +// ───────────────────────────────────────────── /** * Sandbox health polling interface. diff --git a/specs/sandbox/modules.t27 b/specs/sandbox/modules.t27 index 7f704d5be7..b2ab5669c0 100644 --- a/specs/sandbox/modules.t27 +++ b/specs/sandbox/modules.t27 @@ -11,8 +11,8 @@ module sandbox.modules; use sandbox.session_timeout; -// 01234567891011121314151617181920212223242526272829303132333435363738394041424344 +// ───────────────────────────────────────────── // Session Timeout Module -// 454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 +// ───────────────────────────────────────────── pub use session_timeout; diff --git a/specs/sandbox/session_timeout.t27 b/specs/sandbox/session_timeout.t27 index 3c9526c754..c0d2f896ab 100644 --- a/specs/sandbox/session_timeout.t27 +++ b/specs/sandbox/session_timeout.t27 @@ -13,9 +13,9 @@ module sandbox.session_timeout; import timestamp; -// 01234567891011121314151617181920212223242526272829303132333435363738394041424344 +// ───────────────────────────────────────────── // Session Type Definition -// 454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 +// ───────────────────────────────────────────── /** * Common Session type for sandbox management. @@ -47,9 +47,9 @@ pub enum SessionStatus { Deleted = "deleted", } -// 90919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 +// ───────────────────────────────────────────── // Configuration -// 135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 +// ───────────────────────────────────────────── const DEFAULT_MAX_SESSION_DURATION_MS : u64 = 3_600_000; // 1 hour @@ -72,9 +72,9 @@ fn should_terminate_session( elapsed > max_duration_ms } -// 180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 +// ───────────────────────────────────────────── // Interface -// 225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 +// ───────────────────────────────────────────── /** * Session timeout check interface for sandbox health service. @@ -89,9 +89,9 @@ pub trait TimeoutChecker { fn check_timeout(&self, session: &Session) -> bool; } -// 270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 +// ───────────────────────────────────────────── // TDD Tests -// 315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 +// ───────────────────────────────────────────── .test { use sandbox.session_timeout; diff --git a/specs/server/agent-runner.t27 b/specs/server/agent-runner.t27 index a58980f8b3..bbfbd2e454 100644 --- a/specs/server/agent-runner.t27 +++ b/specs/server/agent-runner.t27 @@ -7,9 +7,9 @@ module AgentRunner { use base::types; - // 012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ════════════════════════════════════════════════════════════════════ // Agent Report - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 + // ════════════════════════════════════════════════════════════════════ struct AgentReport { turns: u32, @@ -22,9 +22,9 @@ module AgentRunner { duration_seconds: f64, } - // 136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 + // ════════════════════════════════════════════════════════════════════ // Tool System - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 + // ════════════════════════════════════════════════════════════════════ struct ToolResult { output: str, @@ -40,9 +40,9 @@ module AgentRunner { Unknown = 3, } - // 272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 + // ════════════════════════════════════════════════════════════════════ // Agent State - // 340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ════════════════════════════════════════════════════════════════════ struct AgentState { turn: u32, @@ -54,9 +54,9 @@ module AgentRunner { completion_summary: str, } - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 + // ════════════════════════════════════════════════════════════════════ // Agent Constants - // 476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ════════════════════════════════════════════════════════════════════ const MAX_TURNS: u32 = 100; const MAX_TOOLS_CALLED: u32 = 256; @@ -64,9 +64,9 @@ module AgentRunner { const DEFAULT_TIMEOUT_SECONDS: u32 = 120; const MAX_TOKEN_SUMMARY_LENGTH: u32 = 200; - // 544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 + // ════════════════════════════════════════════════════════════════════ // Agent Initialization - // 612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 + // ════════════════════════════════════════════════════════════════════ fn agent_state_init(max_turns: u32) -> AgentState { var state = AgentState{}; @@ -91,9 +91,9 @@ module AgentRunner { return report; } - // 680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 + // ════════════════════════════════════════════════════════════════════ // Tool Execution - // 748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 + // ════════════════════════════════════════════════════════════════════ fn track_tool_call(state: AgentState, tool_name: str) -> AgentState { var new_state = state; @@ -105,9 +105,9 @@ module AgentRunner { return result.is_complete; } - // 816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883 + // ════════════════════════════════════════════════════════════════════ // Stop Reason Helpers - // 884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 + // ════════════════════════════════════════════════════════════════════ fn stop_reason_from_string(reason: str) -> StopReason { if reason == "end_turn" { @@ -135,9 +135,9 @@ module AgentRunner { return "unknown"; } - // 95295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019 + // ════════════════════════════════════════════════════════════════════ // Token Tracking - // 10201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 + // ════════════════════════════════════════════════════════════════════ fn add_tokens(state: AgentState, input_tokens: u64, output_tokens: u64) -> AgentState { var new_state = state; @@ -150,17 +150,17 @@ module AgentRunner { return state.total_input_tokens + state.total_output_tokens; } - // 10881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 + // ════════════════════════════════════════════════════════════════════ // String Helpers - // 11561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223 + // ════════════════════════════════════════════════════════════════════ fn truncate_string(s: str, max: u32) -> str { return s; } - // 12241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291 + // ════════════════════════════════════════════════════════════════════ // Turn Management - // 12921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359 + // ════════════════════════════════════════════════════════════════════ fn next_turn(state: AgentState) -> AgentState { var new_state = state; @@ -172,9 +172,9 @@ module AgentRunner { return state.turn < state.max_turns; } - // 13601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427 + // ════════════════════════════════════════════════════════════════════ // Report Building - // 14281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495 + // ════════════════════════════════════════════════════════════════════ fn build_report(state: AgentState, duration_seconds: f64) -> AgentReport { var report = agent_report_init(); @@ -187,9 +187,9 @@ module AgentRunner { return report; } - // 14961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563 + // ════════════════════════════════════════════════════════════════════ // Tests - // 15641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 + // ════════════════════════════════════════════════════════════════════ test "agent_state_init" { var state = agent_state_init(10); @@ -237,9 +237,9 @@ module AgentRunner { assert(MAX_TOKEN_SUMMARY_LENGTH == 200); } - // 16321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699 + // ════════════════════════════════════════════════════════════════════ // Invariants - // 17001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767 + // ════════════════════════════════════════════════════════════════════ invariant "turns_non_negative" { var state = agent_state_init(10); diff --git a/specs/server/api.t27 b/specs/server/api.t27 index 0761e2a2d5..09a59b3f8f 100644 --- a/specs/server/api.t27 +++ b/specs/server/api.t27 @@ -7,9 +7,9 @@ module Api { use base::types; - // 012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ════════════════════════════════════════════════════════════════════ // Message Types - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 + // ════════════════════════════════════════════════════════════════════ enum MessageRole { User = 0, @@ -29,9 +29,9 @@ module Api { content: MessageContent, } - // 136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 + // ════════════════════════════════════════════════════════════════════ // Content Block - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 + // ════════════════════════════════════════════════════════════════════ struct TextBlock { block_type: ContentBlockType, @@ -56,9 +56,9 @@ module Api { thinking: str, } - // 272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 + // ════════════════════════════════════════════════════════════════════ // API Response - // 340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ════════════════════════════════════════════════════════════════════ struct Usage { input_tokens: u32, @@ -72,18 +72,18 @@ module Api { usage: Usage, } - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 + // ════════════════════════════════════════════════════════════════════ // API Constants - // 476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ════════════════════════════════════════════════════════════════════ const DEFAULT_TIMEOUT_SECONDS: u32 = 30; const DEFAULT_MAX_TOKENS: u32 = 8192; const DEFAULT_BASE_URL: str = "https://api.z.ai/api/anthropic"; const DEFAULT_MODEL: str = "claude-sonnet-4-5-20250514"; - // 544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 + // ════════════════════════════════════════════════════════════════════ fn get_block_type_name(block_type: ContentBlockType) -> str { if block_type == ContentBlockType::Text { @@ -118,9 +118,9 @@ module Api { return usage.input_tokens + usage.output_tokens; } - // 680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 + // ════════════════════════════════════════════════════════════════════ // Tests - // 748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 + // ════════════════════════════════════════════════════════════════════ test "block_type_names" { assert(get_block_type_name(ContentBlockType::Text) == "text"); diff --git a/specs/server/project.t27 b/specs/server/project.t27 index 483551c0d6..174463c979 100644 --- a/specs/server/project.t27 +++ b/specs/server/project.t27 @@ -7,9 +7,9 @@ module Project { use base::types; - // 012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ════════════════════════════════════════════════════════════════════ // Project Structure - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 + // ════════════════════════════════════════════════════════════════════ struct Project { id: str, @@ -27,9 +27,9 @@ module Project { modified: bool, } - // 136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 + // ════════════════════════════════════════════════════════════════════ // Project Manager - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 + // ════════════════════════════════════════════════════════════════════ struct ProjectManager { projects: [32]Project, @@ -45,9 +45,9 @@ module Project { }; } - // 272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 + // ════════════════════════════════════════════════════════════════════ // Project Operations - // 340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ════════════════════════════════════════════════════════════════════ fn create_project(mgr: *ProjectManager, name: str, path: str) -> Project { const id = "proj-" ++ name @@ -122,9 +122,9 @@ module Project { return found } - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 + // ════════════════════════════════════════════════════════════════════ // File Operations - // 476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ════════════════════════════════════════════════════════════════════ fn read_file(path: str) -> str { return "" @@ -142,9 +142,9 @@ module Project { return [""; 64] } - // 544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 + // ════════════════════════════════════════════════════════════════════ // Tests - // 612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 + // ════════════════════════════════════════════════════════════════════ test "create_project" { var mgr = project_manager_init() diff --git a/specs/server/provider.t27 b/specs/server/provider.t27 index bceeee5fcf..fcb726b13f 100644 --- a/specs/server/provider.t27 +++ b/specs/server/provider.t27 @@ -7,9 +7,9 @@ module Provider { use base::types; - // 012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ════════════════════════════════════════════════════════════════════ // Provider Types - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 + // ════════════════════════════════════════════════════════════════════ enum ProviderType { OpenAI = 0, @@ -18,9 +18,9 @@ module Provider { Custom = 3, } - // 136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 + // ════════════════════════════════════════════════════════════════════ // Provider Configuration - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 + // ════════════════════════════════════════════════════════════════════ struct Provider { id: str, @@ -42,9 +42,9 @@ module Provider { supports_streaming: bool, } - // 272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 + // ════════════════════════════════════════════════════════════════════ // Provider Manager - // 340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ════════════════════════════════════════════════════════════════════ struct ProviderManager { providers: [16]Provider, @@ -60,9 +60,9 @@ module Provider { }; } - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 + // ════════════════════════════════════════════════════════════════════ // Provider Operations - // 476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ════════════════════════════════════════════════════════════════════ fn add_provider(mgr: *ProviderManager, provider: Provider) -> bool { if (mgr.provider_count >= 16) { @@ -140,9 +140,9 @@ module Provider { return false } - // 544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 + // ════════════════════════════════════════════════════════════════════ // Default Providers - // 612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 + // ════════════════════════════════════════════════════════════════════ fn create_openai_provider(api_key: str) -> Provider { return Provider{ @@ -168,9 +168,9 @@ module Provider { } } - // 680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 + // ════════════════════════════════════════════════════════════════════ // Tests - // 748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 + // ════════════════════════════════════════════════════════════════════ test "provider_type_values" { assert(ProviderType::OpenAI == 0) diff --git a/specs/server/session.t27 b/specs/server/session.t27 index 3484005ff6..92ea6a2d27 100644 --- a/specs/server/session.t27 +++ b/specs/server/session.t27 @@ -7,9 +7,9 @@ module Session { use base::types; - // 012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 + // ════════════════════════════════════════════════════════════════════ // Session States - // 6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 + // ════════════════════════════════════════════════════════════════════ enum SessionState { Pending = 0, @@ -18,9 +18,9 @@ module Session { Failed = 3, } - // 136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 + // ════════════════════════════════════════════════════════════════════ // Message Types - // 204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 + // ════════════════════════════════════════════════════════════════════ enum MessageRole { User = 0, @@ -29,9 +29,9 @@ module Session { Tool = 3, } - // 272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 + // ════════════════════════════════════════════════════════════════════ // Session Structure - // 340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 + // ════════════════════════════════════════════════════════════════════ struct Session { id: str, @@ -57,9 +57,9 @@ module Session { arguments: str, } - // 408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 + // ════════════════════════════════════════════════════════════════════ // Session Manager - // 476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 + // ════════════════════════════════════════════════════════════════════ struct SessionManager { sessions: [256]Session, @@ -75,9 +75,9 @@ module Session { }; } - // 544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 + // ════════════════════════════════════════════════════════════════════ // Session Operations - // 612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 + // ════════════════════════════════════════════════════════════════════ fn create_session(mgr: *SessionManager, model: str, provider: str) -> Session { const id = generate_session_id(mgr.session_count) @@ -143,9 +143,9 @@ module Session { return mgr.sessions } - // 680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 + // ════════════════════════════════════════════════════════════════════ // Message Operations - // 748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 + // ════════════════════════════════════════════════════════════════════ fn create_message(role: MessageRole, content: str) -> Message { return Message{ @@ -163,9 +163,9 @@ module Session { session.updated_at = session.created_at + session.message_count } - // 816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883 + // ════════════════════════════════════════════════════════════════════ // Utilities - // 884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 + // ════════════════════════════════════════════════════════════════════ fn generate_session_id(counter: u32) -> str { return "ses_default" @@ -179,9 +179,9 @@ module Session { return "{\"id\": \"message\", \"role\": 0}" } - // 95295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019 + // ════════════════════════════════════════════════════════════════════ // Tests - // 10201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 + // ════════════════════════════════════════════════════════════════════ test "session_state_values" { assert(SessionState::Pending == 0) diff --git a/specs/shell/environment.t27 b/specs/shell/environment.t27 index 50dd57415c..59521509a1 100644 --- a/specs/shell/environment.t27 +++ b/specs/shell/environment.t27 @@ -1,14 +1,14 @@ // specs/shell/environment.t27 // Shell Environment Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ShellEnvironment { use base::types; use shell::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Environment Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // get retrieves an environment variable fn get(name: str) -> Result { @@ -35,9 +35,9 @@ module ShellEnvironment { // Implementation: Expand $VAR and ${VAR} patterns } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Path Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // PATH is the PATH environment variable name const PATH: str = "PATH"; @@ -72,9 +72,9 @@ module ShellEnvironment { // Implementation: Find executable in PATH } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Shell Selection Operations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // detect detects the current shell fn detect() -> Result { @@ -96,9 +96,9 @@ module ShellEnvironment { // Implementation: Return platform-specific fallback } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Home Directory Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // HOME is the HOME environment variable name const HOME: str = "HOME"; @@ -116,9 +116,9 @@ module ShellEnvironment { // Implementation: Get current user name } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Platform Detection - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // platform returns the current platform fn platform() -> Platform { @@ -140,9 +140,9 @@ module ShellEnvironment { // Implementation: Check for Linux } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Tests - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ test "constants_values" { assert(PATH == "PATH"); diff --git a/specs/shell/process.t27 b/specs/shell/process.t27 index 474a3669d1..c250a19210 100644 --- a/specs/shell/process.t27 +++ b/specs/shell/process.t27 @@ -1,21 +1,21 @@ // specs/shell/process.t27 // Shell Process Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ShellProcess { use base::types; use shell::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Process ID Type - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // ProcessID is a branded string representing a process identifier struct ProcessID(str); - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Process Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // spawn spawns a new process fn spawn(command: str, args: [str], opts: ProcessOptions) -> Result { @@ -52,9 +52,9 @@ module ShellProcess { // Implementation: Check if process is alive } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Process Pool Operations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // Pool represents a pool of processes struct Pool { @@ -82,9 +82,9 @@ module ShellProcess { // Implementation: Clean up completed processes } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Signal Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // Signal represents a signal that can be sent to a process enum Signal { @@ -106,9 +106,9 @@ module ShellProcess { // Implementation: Return signal name } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Tests - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ test "process_id_creation" { var pid = ProcessID("12345"); diff --git a/specs/shell/schema.t27 b/specs/shell/schema.t27 index 2680f0d6d6..099a5ced99 100644 --- a/specs/shell/schema.t27 +++ b/specs/shell/schema.t27 @@ -1,13 +1,13 @@ // specs/shell/schema.t27 // Shell Types Specification -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module Shell { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Shell Types - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // ShellType represents the type of shell enum ShellType { @@ -29,9 +29,9 @@ module Shell { Windows = 2, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Process Types - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // ProcessStatus represents the status of a process enum ProcessStatus { @@ -72,9 +72,9 @@ module Shell { duration: u64, // Duration in milliseconds } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Shell Properties - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // ShellProperties represents properties of a shell struct ShellProperties { @@ -86,9 +86,9 @@ module Shell { isBlacklisted: bool, // Whether it's blacklisted } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Environment Types - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // EnvVar represents an environment variable struct EnvVar { @@ -96,16 +96,16 @@ module Shell { value: str, // Variable value } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Constants - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ const SIGKILL_TIMEOUT_MS: u32 = 200; const SHELL_ENV_VAR: str = "SHELL"; - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Error Types - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // ShellError represents errors in shell operations enum ShellError { @@ -118,9 +118,9 @@ module Shell { EnvironmentError = 6, } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ // is_posix checks if a shell type is POSIX compliant fn is_posix(shellType: ShellType) -> bool { @@ -149,9 +149,9 @@ module Shell { return result.exitCode == 0 && !result.timedOut; } - // 956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ════════════════════════════════════════════════════════════════════ // Tests - // 10241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 + // ════════════════════════════════════════════════════════════════════ test "shell_type_values" { assert(ShellType::Bash as u32 == 0); diff --git a/specs/storage/kv.t27 b/specs/storage/kv.t27 index bab8bd777a..3c9f9fa386 100644 --- a/specs/storage/kv.t27 +++ b/specs/storage/kv.t27 @@ -1,14 +1,14 @@ // specs/storage/kv.t27 // Key-Value Storage Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module StorageKv { use base::types; use storage::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // KV Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // read retrieves a value from storage by key // Returns Error if the key does not exist @@ -46,9 +46,9 @@ module StorageKv { // Implementation: Check file existence } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Bulk Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // batch_write writes multiple values atomically fn batch_write(entries: [(key: [str], value: T)]) -> Result { @@ -60,9 +60,9 @@ module StorageKv { // Implementation: Read all keys, return null for missing keys } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Tests - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ test "read_missing_key_returns_error" { // Reading a non-existent key should return NotFoundError diff --git a/specs/storage/lock.t27 b/specs/storage/lock.t27 index c3dd28d4d2..0f7bf8cfb4 100644 --- a/specs/storage/lock.t27 +++ b/specs/storage/lock.t27 @@ -1,14 +1,14 @@ // specs/storage/lock.t27 // Locking Primitives for Storage Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module StorageLock { use base::types; use storage::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Lock State - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // LockState represents the state of a lock holder struct LockState { @@ -19,9 +19,9 @@ module StorageLock { expires_at: u64, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Lock Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // acquire_read attempts to acquire a read lock on the given key // Multiple read locks can be held simultaneously @@ -68,9 +68,9 @@ module StorageLock { // Implementation: Block until write lock is available } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Lock Management - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // cleanup_expired removes expired locks fn cleanup_expired() -> Result { @@ -87,9 +87,9 @@ module StorageLock { // Implementation: Release lock regardless of owner } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Tests - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ test "acquire_read_returns_true" { // Acquiring a read lock on an unlocked key should succeed diff --git a/specs/storage/migrate.t27 b/specs/storage/migrate.t27 index ba2d442989..855805d1bf 100644 --- a/specs/storage/migrate.t27 +++ b/specs/storage/migrate.t27 @@ -1,14 +1,14 @@ // specs/storage/migrate.t27 // Data Migration Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module StorageMigrate { use base::types; use storage::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Migration Types - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // MigrationStep represents a single migration step struct MigrationStep { @@ -26,9 +26,9 @@ module StorageMigrate { last_migration_at: u64?, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Migration Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // version returns the current migration version fn version() -> Result { @@ -75,9 +75,9 @@ module StorageMigrate { // Implementation: Compare current version with available migrations } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Built-in Migrations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // Migration 1: Migrate from legacy project storage fn migrate_1_legacy_projects(dir: str) -> Result { @@ -91,9 +91,9 @@ module StorageMigrate { // into dedicated session_diff entries } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Migration Registry - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ const MIGRATIONS: [MigrationStep] = [ MigrationStep { @@ -110,9 +110,9 @@ module StorageMigrate { }, ]; - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Tests - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ test "version_returns_default_zero" { // When no migration marker exists, version should return 0 diff --git a/specs/storage/schema.t27 b/specs/storage/schema.t27 index 1ccf5ef308..36b85d447e 100644 --- a/specs/storage/schema.t27 +++ b/specs/storage/schema.t27 @@ -1,13 +1,13 @@ // specs/storage/schema.t27 // Storage Types Specification -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module Storage { use base::types; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Storage Key Types - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // StorageKey represents a hierarchical key for storage operations // Each key is a path of string segments @@ -23,9 +23,9 @@ module Storage { version: u32, } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Lock Types - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // LockMode defines the type of lock enum LockMode { @@ -40,9 +40,9 @@ module Storage { acquired_at: u64, } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Migration Types - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // Migration represents a data migration step struct Migration { @@ -58,9 +58,9 @@ module Storage { Skipped = 2, } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Error Types - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // StorageError represents a storage operation error struct StorageError { @@ -81,17 +81,17 @@ module Storage { mode: LockMode, } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Constants - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ const DEFAULT_LOCK_TIMEOUT_MS: u64 = 5000; const MAX_RETRIES: u32 = 3; const CURRENT_SCHEMA_VERSION: u32 = 2; - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // is_not_found checks if an error is a NotFoundError fn is_not_found(err: StorageError) -> bool { @@ -103,9 +103,9 @@ module Storage { return err.code == "LOCK_ERROR"; } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Tests - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ test "storage_key_creation" { var key = StorageKey { diff --git a/specs/ternary/bigint.t27 b/specs/ternary/bigint.t27 index 79ad42b8d8..659def7bb4 100644 --- a/specs/ternary/bigint.t27 +++ b/specs/ternary/bigint.t27 @@ -1,17 +1,17 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/ternary/bigint.t27 // TVC BigInt - Balanced Ternary Arbitrary Precision Arithmetic -// 01234 567891011: V = n 12 3^k 13 14^m 15 16^p 17 e^q -// 1819 + 1/2021 = 3 | TRINITY +// ⲤⲀⲔⲢⲀ ⲪⲞⲢⲘⲨⲖⲀ: V = n × 3^k × π^m × φ^p × e^q +// φ² + 1/φ² = 3 | TRINITY // // Balanced Ternary representation: // - Each trit has value {-1, 0, +1} -// - Number = 22(trit[i] 23 3^i) for i = 0..n-1 +// - Number = Σ(trit[i] × 3^i) for i = 0..n-1 // - No separate sign bit needed (inherent in representation) // - Rounding is simpler (truncation = rounding to nearest) // // Supports: -// - Arbitrary precision integers up to 3^256 24 10^122 +// - Arbitrary precision integers up to 3^256 ≈ 10^122 // - SIMD-optimized operations (32 trits in parallel) // - Karatsuba multiplication O(n^1.585) // - Newton-Raphson division for large numbers @@ -30,7 +30,7 @@ use tritype-base::trit_multiply; // Constants // ============================================================================ -/// Maximum trits for BigInt (supports numbers up to 3^256 25 10^122) +/// Maximum trits for BigInt (supports numbers up to 3^256 ≈ 10^122) pub const MAX_TRITS : usize = 256; /// Trit constants for convenience @@ -123,7 +123,7 @@ pub const BigInt = struct { // ======================================================================== /// Convert BigInt to i64 (may overflow for large numbers) - /// Algorithm: 26(trit[i] 27 3^i) + /// Algorithm: Σ(trit[i] × 3^i) /// Complexity: O(len) pub fn to_i64(self: Self) i64 { var result : i64 = 0; @@ -403,7 +403,7 @@ pub const BigInt = struct { /// Karatsuba multiplication for large numbers /// Recursively splits numbers: a = a1*3^m + a0, b = b1*3^m + b0 /// Uses 3 multiplications: z0 = a0*b0, z2 = a1*b1, z1 = (a0+a1)*(b0+b1) - z0 - z2 - /// Complexity: O(n^log2(3)) 28 O(n^1.585) + /// Complexity: O(n^log2(3)) ≈ O(n^1.585) fn mul_karatsuba(a: Self, b: Self) Self { // Base case: use simple multiplication if (a.len <= KARATSUBA_THRESHOLD or b.len <= KARATSUBA_THRESHOLD) { diff --git a/specs/test_framework/core.t27 b/specs/test_framework/core.t27 index 4b1dbdae09..94cd5f64db 100644 --- a/specs/test_framework/core.t27 +++ b/specs/test_framework/core.t27 @@ -6,7 +6,7 @@ module core; -// 0 Core testing enums and structures +// § Core testing enums and structures /// Test verdict/tier classification enum Verdict { @@ -18,7 +18,7 @@ enum Verdict { /// Test tolerance tier (numeric/physics precision levels) enum ToleranceTier { - EXACT, // Mathematical identity (e.g., 12 = 3 + 1) + EXACT, // Mathematical identity (e.g., φ² = φ + 1) WITHIN_UNCERTAINTY, // Within experimental uncertainty (CODATA) EMPIRICAL_FIT, // Empirical formula, good accuracy APPROXIMATION, // Approximation > experimental uncertainty @@ -51,7 +51,7 @@ struct TestResult { } /// Sequential gate pipeline with short-circuit -/// Pattern: parse 4 type_check 5 semantic 6 numeric_stability 7 physics_constraint 8 audit +/// Pattern: parse → type_check → semantic → numeric_stability → physics_constraint → audit struct GatePipeline { parse_ok: bool, type_check_ok: bool, @@ -77,7 +77,7 @@ impl GatePipeline { } } -// 9 Core testing utilities +// § Core testing utilities /// Property-based testing: for all x in domain, property holds fn for_all(domain: fn() -> T, property: fn(T) -> bool, iterations: u32) -> TestResult { @@ -168,7 +168,7 @@ fn differential(impl1: fn(T) -> T, impl2: fn(T) -> T, tolerance: f64, test_ca }).collect() } -// 10 Test runners and reporting +// § Test runners and reporting /// TAP (Test Anything Protocol) output generator struct TapReporter { @@ -232,7 +232,7 @@ impl JsonReporter { } } -// 11 Test invariants and properties +// § Test invariants and properties /// Sequential gate invariant - enforces strict ordering invariant gate_pipeline_sequential(gate: GatePipeline) -> bool { @@ -249,12 +249,12 @@ invariant gf16_roundtrip_preservation(value: f64) -> bool { (decoded - value as f32).abs() < 1e-6 } -/// Phi algebraic identity: 1213 = 14 + 1 (exact mathematical identity) +/// Phi algebraic identity: φ² = φ + 1 (exact mathematical identity) invariant phi_squared_identity(phi: f64) -> bool { (phi * phi - phi - 1.0).abs() < 1e-15 // Exact within floating point precision } -// 15 Test entry point +// § Test entry point fn run_test_suite() -> Vec { let mut results = Vec::new(); diff --git a/specs/test_framework/graph_drift_detection.t27 b/specs/test_framework/graph_drift_detection.t27 index 9a50a2cd4b..45943e1f57 100644 --- a/specs/test_framework/graph_drift_detection.t27 +++ b/specs/test_framework/graph_drift_detection.t27 @@ -1,15 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/test_framework/graph_drift_detection.t27 -// Ring 054 0 Graph Drift Detection for Structural Change Detection +// Ring 054 — Graph Drift Detection for Structural Change Detection // Monitors structural changes in mathematical and physics specifications over time module GraphDriftDetection { use test_framework::core::{TestResult, Verdict, ToleranceTier, EngineeringStatus}; use std::collections::{HashMap, HashSet}; - // 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 + // ───────────────────────────────────────────────────── // 1. Drift Detection Configuration - // 54555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 + // ───────────────────────────────────────────────────── // Graph node representing a mathematical/physics entity struct GraphNode { @@ -87,9 +87,9 @@ module GraphDriftDetection { }; } - // 107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 + // ───────────────────────────────────────────────────── // 2. Graph Construction and Parsing - // 160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 + // ───────────────────────────────────────────────────── // Parse T27 spec file and extract graph structure fn parse_t27_spec_to_graph(file_path: string) -> DriftGraph { @@ -191,9 +191,9 @@ module GraphDriftDetection { }; } - // 213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 + // ───────────────────────────────────────────────────── // 3. Drift Detection Algorithms - // 266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 + // ───────────────────────────────────────────────────── // Drift detection result struct DriftResult { @@ -360,9 +360,9 @@ module GraphDriftDetection { return 0.0; } - // 319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 + // ───────────────────────────────────────────────────── // 4. Drift Monitoring and Alerting - // 372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 + // ───────────────────────────────────────────────────── // Drift monitoring system struct DriftMonitor { @@ -411,9 +411,9 @@ module GraphDriftDetection { // send_alert_to_monitoring_system(alert_message); } - // 425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 + // ───────────────────────────────────────────────────── // 5. Integration with Test Framework - // 478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 + // ───────────────────────────────────────────────────── // Run drift detection as part of test suite fn run_drift_detection_tests() -> [TestResult] { @@ -460,9 +460,9 @@ module GraphDriftDetection { measure: milliseconds to run run_drift_detection_tests() target: < 1000ms - // 531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 + // ───────────────────────────────────────────────────── // 6. TDD-Inside-Spec: Drift Detection Tests - // 584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636 + // ───────────────────────────────────────────────────── test drift_config_creation given config = default_drift_config() diff --git a/specs/test_framework/property_test_template.t27 b/specs/test_framework/property_test_template.t27 index 25da164ee4..210d0dca07 100644 --- a/specs/test_framework/property_test_template.t27 +++ b/specs/test_framework/property_test_template.t27 @@ -1,15 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/test_framework/property_test_template.t27 -// Ring 052 0 Property-Based Testing Template for GoldenFloat +// Ring 052 — Property-Based Testing Template for GoldenFloat // Standardized PBT patterns following T27-MATH-PHYSICS-TEST-FRAMEWORK-SPEC.md module PBTTemplate { use test_framework::core::{TestResult, Verdict, ToleranceTier, EngineeringStatus}; use numeric::golden_float::{GF16, GF32}; - // 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 + // ───────────────────────────────────────────────────── // 1. PBT Configuration and Generators - // 54555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 + // ───────────────────────────────────────────────────── // Standard test configuration for property-based tests struct PropertyTestConfig { @@ -33,9 +33,9 @@ module PBTTemplate { }; } - // 107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 + // ───────────────────────────────────────────────────── // 2. GoldenFloat Generators - // 160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 + // ───────────────────────────────────────────────────── // Generate valid GF16 values with coverage of edge cases fn generate_gf16(rng: &mut Random) -> GF16 { @@ -89,9 +89,9 @@ module PBTTemplate { return (generate_gf16(rng), generate_gf16(rng), generate_gf16(rng)); } - // 213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 + // ───────────────────────────────────────────────────── // 3. Property Test Executors - // 266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 + // ───────────────────────────────────────────────────── // Universal property: for all valid inputs, property holds fn for_all(config: PropertyTestConfig, generator: fn(&mut Random) -> T, property: F) -> TestResult @@ -174,7 +174,7 @@ module PBTTemplate { } } - // Differential property: f(x) 319 g(x) within tolerance + // Differential property: f(x) ≈ g(x) within tolerance fn differential(config: PropertyTestConfig, generator: fn(&mut Random) -> T, f: F, g: G) -> TestResult where F: Fn(T) -> U, G: Fn(T) -> U @@ -222,9 +222,9 @@ module PBTTemplate { } } - // 320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 + // ───────────────────────────────────────────────────── // 4. GoldenFloat-Specific Property Tests - // 373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 + // ───────────────────────────────────────────────────── // Property: GF16 addition is commutative // Claim: C-gf-001 (GoldenFloat meets stated effective accuracy) @@ -322,9 +322,9 @@ module PBTTemplate { }); } - // 426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 + // ───────────────────────────────────────────────────── // 5. Test Orchestration - // 479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 + // ───────────────────────────────────────────────────── // Standard GoldenFloat property test suite fn goldenfloat_property_test_suite() -> [TestResult] { @@ -354,7 +354,7 @@ module PBTTemplate { target: < 5000ms // TDD-Inside-Spec: Verification tests for property test framework - // 532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622 + // ═══════════════════════════════════════════════════════════════════════════════════════════ test property_test_config_creation given config = default_gf_config() diff --git a/specs/test_framework/runner.t27 b/specs/test_framework/runner.t27 index 09eb8d565b..8dcd854f09 100644 --- a/specs/test_framework/runner.t27 +++ b/specs/test_framework/runner.t27 @@ -220,7 +220,7 @@ impl TestRunner { println!("\n=== Failed Tests ==="); for result in &self.results { if result.verdict == Verdict::FAIL { - println!("0 {}", result.name); + println!("✗ {}", result.name); if let Some(ref msg) = result.message { println!(" {}", msg); } @@ -232,9 +232,9 @@ impl TestRunner { println!("\n=== All Results ==="); for result in &self.results { let status = match result.verdict { - Verdict::CLEAN => "1", - Verdict::FAIL => "2", - Verdict::SKIP => "3", + Verdict::CLEAN => "✓", + Verdict::FAIL => "✗", + Verdict::SKIP => "○", Verdict::PARTIAL => "~" }; println!("{} {} ({})", status, result.name, result.engineering); @@ -254,7 +254,7 @@ impl TestRunner { } } -// 4 Test specification parser +// § Test specification parser /// Parsed .t27 test specification struct T27Spec { @@ -287,7 +287,7 @@ enum TestKind { GatePipeline // Sequential gate pipeline } -// 5 Helper functions +// § Helper functions fn read_file(path: string) -> Result { // Placeholder for file reading @@ -320,7 +320,7 @@ fn default_pipeline() -> fn() -> GatePipeline { || GatePipeline::all_true() } -// 6 Main entry point +// § Main entry point /// Execute test specification with default configuration pub fn run_test_spec_file(spec_path: string) -> Result<(), string> { diff --git a/specs/test_framework/verilog_bench_harness.t27 b/specs/test_framework/verilog_bench_harness.t27 index 9110c53357..d6f8498817 100644 --- a/specs/test_framework/verilog_bench_harness.t27 +++ b/specs/test_framework/verilog_bench_harness.t27 @@ -1,15 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/test_framework/verilog_bench_harness.t27 -// Ring 053 0 Verilog Bench Harness for Hardware-in-the-Loop Testing +// Ring 053 — Verilog Bench Harness for Hardware-in-the-Loop Testing // Integration framework for testing GoldenFloat operations against Verilog RTL module VerilogBenchHarness { use test_framework::core::{TestResult, Verdict, ToleranceTier, EngineeringStatus}; use numeric::golden_float::{GF16, GF32}; - // 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 + // ───────────────────────────────────────────────────── // 1. Verilog Integration Configuration - // 54555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 + // ───────────────────────────────────────────────────── // Verilog simulation configuration struct VerilogConfig { @@ -59,9 +59,9 @@ module VerilogBenchHarness { }; } - // 107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 + // ───────────────────────────────────────────────────── // 2. Test Vector Generation - // 160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 + // ───────────────────────────────────────────────────── // Test vector for Verilog simulation struct VerilogTestVector { @@ -180,9 +180,9 @@ module VerilogBenchHarness { return vectors; } - // 213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 + // ───────────────────────────────────────────────────── // 3. Verilog Test Execution - // 266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 + // ───────────────────────────────────────────────────── // Verilog simulation result struct VerilogSimulationResult { @@ -265,9 +265,9 @@ module VerilogBenchHarness { return results; } - // 319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 + // ───────────────────────────────────────────────────── // 4. Hardware-Software Co-verification - // 372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 + // ───────────────────────────────────────────────────── // Compare software and hardware results fn compare_sw_hw_results(sw_results: [TestResult], hw_results: [TestResult]) -> TestResult { @@ -305,9 +305,9 @@ module VerilogBenchHarness { } } - // 425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 + // ───────────────────────────────────────────────────── // 5. Comprehensive Test Orchestration - // 478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 + // ───────────────────────────────────────────────────── // Full GoldenFloat hardware verification flow fn goldenfloat_hardware_verification() -> [TestResult] { @@ -351,9 +351,9 @@ module VerilogBenchHarness { measure: milliseconds to run goldenfloat_hardware_verification() target: < 60000ms - // 531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 + // ───────────────────────────────────────────────────── // 6. TDD-Inside-Spec: Verilog Harness Tests - // 584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636 + // ───────────────────────────────────────────────────── test verilog_config_creation given config = default_verilog_config() diff --git a/specs/tools/registry.t27 b/specs/tools/registry.t27 index 2b0ea2ea22..1725b3a760 100644 --- a/specs/tools/registry.t27 +++ b/specs/tools/registry.t27 @@ -1,14 +1,14 @@ // specs/tools/registry.t27 // Tools Registry Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module ToolsRegistry { use base::types; use tools::schema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Registry Operations - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // create creates a new tool registry fn create() -> ToolRegistry { @@ -55,9 +55,9 @@ module ToolsRegistry { // Implementation: Filter dangerous tools } - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Permission Operations - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // set_permission sets the permission for a tool fn set_permission(registry: ToolRegistry, toolID: ToolID, permission: ToolPermission) -> Result { @@ -84,9 +84,9 @@ module ToolsRegistry { // Implementation: Set permission to Ask } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Custom Tool Operations - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // register_custom registers a custom tool fn register_custom(registry: ToolRegistry, tool: ToolDefinition) -> Result { @@ -103,9 +103,9 @@ module ToolsRegistry { // Implementation: Unregister custom tool } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Bulk Operations - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // register_all registers multiple tools at once fn register_all(registry: ToolRegistry, tools: [ToolDefinition]) -> Result { @@ -122,9 +122,9 @@ module ToolsRegistry { // Implementation: Clear all tools } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Query Operations - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // find_by_description finds tools by description pattern fn find_by_description(registry: ToolRegistry, pattern: str) -> [ToolID] { @@ -141,9 +141,9 @@ module ToolsRegistry { // Implementation: Check if empty } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Tests - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ test "tool_id_creation" { var id = ToolID("bash"); diff --git a/specs/tools/schema.t27 b/specs/tools/schema.t27 index b54146459b..7e866a5be1 100644 --- a/specs/tools/schema.t27 +++ b/specs/tools/schema.t27 @@ -1,14 +1,14 @@ // specs/tools/schema.t27 // Tools Types Specification -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module Tools { use base::types; use session::schema as SessionSchema; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 + // ════════════════════════════════════════════════════════════════════ // Tool ID Type - // 72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 + // ════════════════════════════════════════════════════════════════════ // ToolID is a branded string representing a tool identifier struct ToolID(str); @@ -16,9 +16,9 @@ module Tools { // CallID is a branded string representing a tool call identifier struct CallID(str); - // 140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 + // ════════════════════════════════════════════════════════════════════ // Tool Types - // 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 + // ════════════════════════════════════════════════════════════════════ // ToolCategory represents the category of a tool enum ToolCategory { @@ -38,9 +38,9 @@ module Tools { Denied = 2, // Tool is disabled } - // 276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 + // ════════════════════════════════════════════════════════════════════ // Tool Definition - // 344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 + // ════════════════════════════════════════════════════════════════════ // ParameterSchema represents the schema for tool parameters struct ParameterSchema { @@ -75,9 +75,9 @@ module Tools { metadata: ToolMetadata, } - // 412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 + // ════════════════════════════════════════════════════════════════════ // Tool Execution - // 480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 + // ════════════════════════════════════════════════════════════════════ // ToolContext represents the context for tool execution struct ToolContext { @@ -110,9 +110,9 @@ module Tools { timestamp: u64, // Call timestamp } - // 548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 + // ════════════════════════════════════════════════════════════════════ // Validation - // 616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 + // ════════════════════════════════════════════════════════════════════ // ValidationError represents a parameter validation error struct ValidationError { @@ -127,9 +127,9 @@ module Tools { errors: [ValidationError], } - // 684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 + // ════════════════════════════════════════════════════════════════════ // Tool Registry Types - // 752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 + // ════════════════════════════════════════════════════════════════════ // ToolRegistry represents a registry of available tools struct ToolRegistry { @@ -138,9 +138,9 @@ module Tools { custom: [ToolID], // Custom tool IDs } - // 820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 + // ════════════════════════════════════════════════════════════════════ // Error Types - // 888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 + // ════════════════════════════════════════════════════════════════════ // ToolError represents errors in tool operations enum ToolError { @@ -153,16 +153,16 @@ module Tools { NotDefined = 6, } - // 956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 + // ════════════════════════════════════════════════════════════════════ // Constants - // 10241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 + // ════════════════════════════════════════════════════════════════════ const MAX_OUTPUT_LENGTH: u32 = 100000; const DEFAULT_TIMEOUT_MS: u32 = 120000; - // 10921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159 + // ════════════════════════════════════════════════════════════════════ // Helper Functions - // 11601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 + // ════════════════════════════════════════════════════════════════════ // is_dangerous checks if a tool is dangerous fn is_dangerous(metadata: ToolMetadata) -> bool { @@ -179,9 +179,9 @@ module Tools { return metadata.permission == ToolPermission::Allowed; } - // 12281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295 + // ════════════════════════════════════════════════════════════════════ // Tests - // 12961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363 + // ════════════════════════════════════════════════════════════════════ test "tool_id_creation" { var id = ToolID("read_file"); diff --git a/specs/vm/jit_semantics.t27 b/specs/vm/jit_semantics.t27 index 8956148d37..f9f036afcb 100644 --- a/specs/vm/jit_semantics.t27 +++ b/specs/vm/jit_semantics.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Module: JIT Compilation Semantics -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module JitSemantics { // ======================================================================== diff --git a/specs/vsa/jones_polynomial.t27 b/specs/vsa/jones_polynomial.t27 index 3a38694a61..870b15da4d 100644 --- a/specs/vsa/jones_polynomial.t27 +++ b/specs/vsa/jones_polynomial.t27 @@ -1,22 +1,22 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/vsa/jones_polynomial.t27 -// Jones Polynomial 0 Link invariant computed from input structure -// V(L, t) = (-t^(-3/4))^w(L) 1 2L3 where 4L5 is Kauffman bracket +// Jones Polynomial — Link invariant computed from input structure +// V(L, t) = (-t^(-3/4))^w(L) · ⟨L⟩ where ⟨L⟩ is Kauffman bracket module JonesPolynomial { use math::constants; - // 67891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 + // ═══════════════════════════════════════════════════════════════════════════ // 1. Knot/Link Representation - // 81828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Crossing sign: +1 for positive (overcrossing), -1 for negative (undercrossing) const CROSSING_POSITIVE : i32 = 1; const CROSSING_NEGATIVE : i32 = -1; - // 170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 + // ═══════════════════════════════════════════════════════════════════════════ // 2. Writhe Calculation - // 245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Compute writhe w(L) from crossing signs // w(L) = sum of crossing signs (positive = +1, negative = -1) @@ -28,14 +28,14 @@ module JonesPolynomial { return w; } - // 334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 - // 3. Kauffman Bracket 409L410 - // 411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 + // ═══════════════════════════════════════════════════════════════════════════ + // 3. Kauffman Bracket ⟨L⟩ + // ═════════════════════════════════════════════════════════════════════════════════════════ // Skein relation for Kauffman bracket: - // 500L_+501 = A502L_0503 + A^{-1}504L_505506 - // 507L_-508 = A^{-1}509L_0510 + A511L_512513 - // 514L_0515 = (A + A^{-1})516L_517518 + // ⟨L_+⟩ = A⟨L_0⟩ + A^{-1}⟨L_∞⟩ + // ⟨L_-⟩ = A^{-1}⟨L_0⟩ + A⟨L_∞⟩ + // ⟨L_0⟩ = (A + A^{-1})⟨L_∞⟩ // Where A = t^(-1/4), L_+ = positive crossing, L_- = negative crossing // A = t^(-1/4) parameter for Kauffman bracket @@ -44,10 +44,10 @@ module JonesPolynomial { } // Kauffman bracket of unknot (trivial knot) - // 519O520 = 1 + // ⟨O⟩ = 1 const BRACKET_UNKNOT : f64 = 1.0; - // Compute Kauffman bracket 521L522 from crossing signs (input structure) + // Compute Kauffman bracket ⟨L⟩ from crossing signs (input structure) // For small links, use known formulas; for larger, approximate fn bracket_from_crossings(crossings: [i32], t: f64) -> f64 { let A = bracket_parameter(t); @@ -70,13 +70,13 @@ module JonesPolynomial { // Unknot return BRACKET_UNKNOT; } else if n == 3 and pos_count == 3 { - // Trefoil (all positive): 523trefoil524 = -A^7 - A^3 + // Trefoil (all positive): ⟨trefoil⟩ = -A^7 - A^3 return -pow(A, 7.0) - pow(A, 3.0); } else if n == 3 and neg_count == 3 { - // Negative trefoil: 525trefoil526 = -A^{-7} - A^{-3} + // Negative trefoil: ⟨trefoil⟩ = -A^{-7} - A^{-3} return -pow(A, -7.0) - pow(A, -3.0); } else if n == 4 and pos_count == 2 and neg_count == 2 { - // Figure-eight: 527figure-eight528 = A^8 - A^4 + 1 - A^{-4} + A^{-8} + // Figure-eight: ⟨figure-eight⟩ = A^8 - A^4 + 1 - A^{-4} + A^{-8} return pow(A, 8.0) - pow(A, 4.0) + 1.0 - pow(A, -4.0) + pow(A, -8.0); } else { // Generic approximation @@ -85,12 +85,12 @@ module JonesPolynomial { } } - // 529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603 + // ═══════════════════════════════════════════════════════════════════════════ // 4. Jones Polynomial - // 604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Compute Jones polynomial V(L, t) from link structure (crossing signs) - // V(L, t) = (-t^(-3/4))^w(L) 693 694L695 + // V(L, t) = (-t^(-3/4))^w(L) · ⟨L⟩ // Input: crossings = array of crossing signs (+1 or -1) representing link L // Output: Jones polynomial value at variable t fn jones_polynomial_from_structure(crossings: [i32], t: f64) -> f64 { @@ -101,7 +101,7 @@ module JonesPolynomial { } // Legacy: Compute Jones polynomial V(L, t) from writhe and Kauffman bracket - // V(L, t) = (-t^(-3/4))^w(L) 696 697L698 + // V(L, t) = (-t^(-3/4))^w(L) · ⟨L⟩ fn jones_polynomial(t: f64, bracket: f64, w: i32) -> f64 { let factor = pow(-pow(t, -0.75), w as f64); return factor * bracket; @@ -114,15 +114,15 @@ module JonesPolynomial { return jones_polynomial_from_structure(crossings, t); } - // Jones polynomial for trefoil knot with t = 699 - // Expected: V(trefoil, 700) = 701702 + 1 + // Jones polynomial for trefoil knot with t = φ + // Expected: V(trefoil, φ) = φ² + 1 fn jones_trefoil_at_phi() -> f64 { return jones_trefoil(PHI); } - // 703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777 + // ═══════════════════════════════════════════════════════════════════════════ // 5. Helper Functions - // 778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866 + // ═════════════════════════════════════════════════════════════════════════════════════════ // Power function (reused from constants.t27) fn pow(x: f64, n: f64) -> f64 { @@ -206,9 +206,9 @@ module JonesPolynomial { return x == 1.0 / 0.0 or x == -1.0 / 0.0; } - // 867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941 + // ═══════════════════════════════════════════════════════════════════════════ // 6. TDD-Inside-Spec: Tests - // 9429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030 + // ═════════════════════════════════════════════════════════════════════════════════════════ test writhe_empty_crossings given crossings: [i32] = [] @@ -249,12 +249,12 @@ module JonesPolynomial { test jones_trefoil_at_phi_approx given result = jones_trefoil_at_phi() and expected = PHI * PHI + 1.0 - // V(trefoil, 1031) 1032 10331034 + 1 + // V(trefoil, φ) ≈ φ² + 1 when error = abs(result - expected) then error < 0.1 // Allow 10% tolerance for numeric approximation test jones_trefoil_at_phi_identity - // 10351036 + 1 = 1037 + 10381039 (trivial from 10401041 = 1042 + 1) + // φ² + 1 = φ + φ² (trivial from φ² = φ + 1) given result = jones_trefoil_at_phi() and phi_sq_plus_one = PHI * PHI + 1.0 when error = abs(result - phi_sq_plus_one) @@ -270,7 +270,7 @@ module JonesPolynomial { then abs(result - expected) < 1e-6 test jones_polynomial_from_structure_trefoil_phi - // V(trefoil, 1043) from crossing signs + // V(trefoil, φ) from crossing signs given crossings: [i32] = [1, 1, 1] and t = PHI when result = jones_polynomial_from_structure(crossings, t) @@ -285,7 +285,7 @@ module JonesPolynomial { then abs(result - 1.0) < 0.01 test jones_polynomial_variable_t - // Jones polynomial with variable t (not fixed 1044) + // Jones polynomial with variable t (not fixed φ) given crossings: [i32] = [1, 1, 1] // trefoil and t1 = 1.5 and t2 = 2.0 @@ -309,12 +309,12 @@ module JonesPolynomial { when result = jones_trefoil(t) then !isnan(result) and !isinf(result) - // 104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119 + // ═══════════════════════════════════════════════════════════════════════════ // 7. Formal Invariants - // 11201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208 + // ═════════════════════════════════════════════════════════════════════════════════════════ invariant jones_trefoil_phi_relation - // V(trefoil, 1209) 1210 12111212 + 1 + // V(trefoil, φ) ≈ φ² + 1 assert |jones_trefoil_at_phi() - (PHI * PHI + 1.0)| < 0.1 invariant writhe_additivity @@ -331,12 +331,12 @@ module JonesPolynomial { // Rationale: Jones polynomial is a link invariant (unchanged under Reidemeister moves) invariant phi_jones_trefoil_identity - // For trefoil at t=1213: V = 12141215 + 1 = 1216 + 12171218 (from 12191220 = 1221 + 1) - assert jones_trefoil_at_phi() 1222 PHI + PHI * PHI within 0.1 + // For trefoil at t=φ: V = φ² + 1 = φ + φ² (from φ² = φ + 1) + assert jones_trefoil_at_phi() ≈ PHI + PHI * PHI within 0.1 - // 122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297 + // ═══════════════════════════════════════════════════════════════════════════ // 8. Benchmarks - // 12981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386 + // ═════════════════════════════════════════════════════════════════════════════════════════ bench writhe_computation measure: cycles to compute writhe for 100 crossings diff --git a/specs/vsa/ops.t27 b/specs/vsa/ops.t27 index 2eefbee61a..a806a00437 100644 --- a/specs/vsa/ops.t27 +++ b/specs/vsa/ops.t27 @@ -2,16 +2,16 @@ // t27/specs/vsa/ops.t27 // Vector Symbolic Architecture Operations // Bind, Unbind, Bundle, Similarity for ternary hypervectors -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module VSAOps { // Import base types and operations use base::types; use base::ops; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 + // ═════════════════════════════════════════════════════════════════ // 1. Constants - // 69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 + // ═════════════════════════════════════════════════════════════════════════ const VSA_DIM : usize = 1024; // Default hypervector dimension const SIMD_WIDTH : usize = 32; // SIMD trits per operation @@ -26,11 +26,11 @@ module VSAOps { const BIND_IDENTITY : u8 = 0; // Self-binding (vector unchanged) const BIND_INVERT : u8 = 1; // Inverted binding - // 142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 + // ═════════════════════════════════════════════════════════════════ // 2. Bind Operation - // 207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 + // ═════════════════════════════════════════════════════════════════════════ - // bind(a: []Trit, b: []Trit, len: usize) 280 []Trit + // bind(a: []Trit, b: []Trit, len: usize) → []Trit // XOR-like operation for balanced ternary hypervectors // Algorithm: if a[i] == 0 return b[i]; else if b[i] == 0 return a[i]; // else return a[i] * b[i] (which is either -1 or +1) @@ -60,11 +60,11 @@ module VSAOps { return result; } - // 281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 + // ═════════════════════════════════════════════════════════════════ // 3. Unbind Operation - // 346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 + // ═════════════════════════════════════════════════════════════════════════ - // unbind(bound: []Trit, key: []Trit, len: usize) 419 []Trit + // unbind(bound: []Trit, key: []Trit, len: usize) → []Trit // Inverse of bind operation // For XOR-like bind: unbind(x, y) = bind(x, y) // Used for: retrieving bound values from hypervectors @@ -73,14 +73,14 @@ module VSAOps { return bind(bound, key, len); } - // 420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 + // ═════════════════════════════════════════════════════════════════ // 4. Bundle Operations - // 485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 + // ═════════════════════════════════════════════════════════════════════════ - // bundle2(a: []Trit, b: []Trit, len: usize) 558 []Trit + // bundle2(a: []Trit, b: []Trit, len: usize) → []Trit // Majority vote of 2 ternary vectors // Algorithm: if a[i] == 0 return b[i]; else if b[i] == 0 return a[i]; - // else return sign(a[i] + b[i]) 559 {-1, 0, +1} + // else return sign(a[i] + b[i]) ∈ {-1, 0, +1} // Used for: superposition of items, set union fn bundle2(a: []Trit, b: []Trit, len: usize) -> []Trit { var result : []Trit = []; @@ -110,7 +110,7 @@ module VSAOps { return result; } - // bundle3(a: []Trit, b: []Trit, c: []Trit, len: usize) 560 []Trit + // bundle3(a: []Trit, b: []Trit, c: []Trit, len: usize) → []Trit // Majority vote of 3 ternary vectors // Algorithm: sum = a[i] + b[i] + c[i]; result = sign(sum) // Used for: robust superposition, noise reduction @@ -137,11 +137,11 @@ module VSAOps { return result; } - // 561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 + // ═════════════════════════════════════════════════════════════════ // 5. Similarity Operations - // 626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 + // ═════════════════════════════════════════════════════════════════════════ - // similarity(a: []Trit, b: []Trit, len: usize, metric: u8) 699 f64 + // similarity(a: []Trit, b: []Trit, len: usize, metric: u8) → f64 // Compute similarity between two hypervectors // Metrics: COSINE, HAMMING, DOT fn similarity(a: []Trit, b: []Trit, len: usize, metric: u8) -> f64 { @@ -154,8 +154,8 @@ module VSAOps { return dot_product(a, b, len); } - // cosine_similarity(a: []Trit, b: []Trit, len: usize) 700 f64 - // Cosine similarity: (a701b) / (||a|| * ||b||) + // cosine_similarity(a: []Trit, b: []Trit, len: usize) → f64 + // Cosine similarity: (a·b) / (||a|| * ||b||) fn cosine_similarity(a: []Trit, b: []Trit, len: usize) -> f64 { const dot = dot_product(a, b, len); const norm_a = vector_norm(a, len); @@ -168,15 +168,15 @@ module VSAOps { return dot / (norm_a * norm_b); } - // hamming_similarity(a: []Trit, b: []Trit, len: usize) 702 f64 + // hamming_similarity(a: []Trit, b: []Trit, len: usize) → f64 // Hamming similarity: 1 - (hamming_distance / len) fn hamming_similarity(a: []Trit, b: []Trit, len: usize) -> f64 { const dist = hamming_distance(a, b, len); return 1.0 - (dist as f64 / len as f64); } - // dot_product(a: []Trit, b: []Trit, len: usize) 703 f64 - // Compute dot product 704 a[i] * b[i] + // dot_product(a: []Trit, b: []Trit, len: usize) → f64 + // Compute dot product Σ a[i] * b[i] fn dot_product(a: []Trit, b: []Trit, len: usize) -> f64 { var acc : i64 = 0; @@ -190,9 +190,9 @@ module VSAOps { return acc as f64; } - // vector_norm(v: []Trit, len: usize) 705 f64 - // Compute L2 norm: sqrt(706 v[i]707) - // For trits: v[i]708 is always 0 or 1 + // vector_norm(v: []Trit, len: usize) → f64 + // Compute L2 norm: sqrt(Σ v[i]²) + // For trits: v[i]² is always 0 or 1 // So norm = sqrt(count of non-zero trits) fn vector_norm(v: []Trit, len: usize) -> f64 { var nonzero_count : usize = 0; @@ -208,7 +208,7 @@ module VSAOps { return sqrt(nonzero_count as f64); } - // hamming_distance(a: []Trit, b: []Trit, len: usize) 709 usize + // hamming_distance(a: []Trit, b: []Trit, len: usize) → usize // Count positions where a[i] != b[i] fn hamming_distance(a: []Trit, b: []Trit, len: usize) -> usize { var distance : usize = 0; @@ -224,11 +224,11 @@ module VSAOps { return distance; } - // 710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774 + // ═════════════════════════════════════════════════════════════════ // 6. Permutation Operations - // 775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847 + // ═════════════════════════════════════════════════════════════════════════ - // permute(v: []Trit, len: usize, shift: usize) 848 []Trit + // permute(v: []Trit, len: usize, shift: usize) → []Trit // Circular shift of hypervector by shift positions // Used for: sequence encoding, position tagging fn permute(v: []Trit, len: usize, shift: usize) -> []Trit { @@ -247,7 +247,7 @@ module VSAOps { return result; } - // encode_sequence(items: [][]Trit, count: usize, item_len: usize) 849 []Trit + // encode_sequence(items: [][]Trit, count: usize, item_len: usize) → []Trit // Encode sequence of items using position-aware binding // result = items[0] + permute(items[1], 1) + permute(items[2], 2) + ... fn encode_sequence(items: [][]Trit, count: usize, item_len: usize) -> []Trit { @@ -263,7 +263,7 @@ module VSAOps { return result; } - // probe_sequence(seq: []Trit, candidate: []Trit, position: usize, len: usize) 850 f64 + // probe_sequence(seq: []Trit, candidate: []Trit, position: usize, len: usize) → f64 // Probe if candidate is at position in encoded sequence // Returns similarity between seq and permute(candidate, position) fn probe_sequence(seq: []Trit, candidate: []Trit, position: usize, len: usize) -> f64 { @@ -271,9 +271,9 @@ module VSAOps { return similarity(seq, permuted, len, SIM_COSINE); } - // 851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ // TDD-Inside-Spec: Tests and Invariants for VSAOps - // 954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056 + // ═══════════════════════════════════════════════════════════════════════════════════════════════════════ test vsa_bind_with_zeros given a = [Trit.zero, Trit.pos, Trit.neg] @@ -482,9 +482,9 @@ module VSAOps { invariant vsa_max_vectors_positive assert MAX_VECTORS > 0 - // 10571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121 + // ═════════════════════════════════════════════════════════════════ // Ring 048: Additional Algebraic Group Invariants - // 1122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194 + // ═════════════════════════════════════════════════════════════════════════ // bind_self_inverse: a BIND (a BIND b) == b // For XOR-like bind, bind is its own inverse @@ -548,9 +548,9 @@ module VSAOps { and xz = bind(x, zero, 3) then hamming_distance(zx, x) == 0 and hamming_distance(xz, x) == 0 - // 11951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259 + // ═════════════════════════════════════════════════════════════════ // 27-Dimensional Coptic Trit Space (Ring 048) - // 1260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332 + // ═════════════════════════════════════════════════════════════════════════ const COPTIC_DIM : usize = 27 diff --git a/specs/vsa/packed_vsa.t27 b/specs/vsa/packed_vsa.t27 index a464bc4ddb..10a50fc4cd 100644 --- a/specs/vsa/packed_vsa.t27 +++ b/specs/vsa/packed_vsa.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Module: Packed VSA Operations -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module PackedVsa { // ======================================================================== @@ -39,7 +39,7 @@ module PackedVsa { // BundleLookupTable: Precomputed bundle operation results // BUNDLE_LUT[a][b] = packed(bundle(unpack(a), unpack(b))) - // Uses element-wise sum with threshold (41 normalization) + // Uses element-wise sum with threshold (±1 normalization) pub const BundleLookupTable : [59049]u8; // DotLookupTable: Precomputed dot product results @@ -71,7 +71,7 @@ module PackedVsa { // packedUnbind(a: &PackedBigInt, b: &PackedBigInt) -> PackedBigInt // Unbind operation using bind (since b^2 = 1 for trits) - // Unbind: packedBind(a, b) where b 5 {-1, 1} + // Unbind: packedBind(a, b) where b ∈ {-1, 1} // Complexity: O(n/5) where n = trit length pub fn packedUnbind(a: &PackedBigInt, b: &PackedBigInt) -> PackedBigInt; @@ -150,7 +150,7 @@ module PackedVsa { // Verify: Self-similarity equals 1.0 given vec = randomPackedVector(100, 999) and sim = packedCosineSimilarity(&vec, &vec) - then sim 6 1.0 + then sim ≈ 1.0 test packed_cosine_orthogonal_is_zero // Verify: Orthogonal vectors have similarity ~0 @@ -198,7 +198,7 @@ module PackedVsa { assert true; invariant packed_unbind_inverts_bind - // Verify: unbind(bind(a, b), b) 7 a (for valid trits) + // Verify: unbind(bind(a, b), b) ≈ a (for valid trits) // Unbind is the inverse operation of bind assert true; @@ -213,7 +213,7 @@ module PackedVsa { assert true; invariant conversion_roundtrip - // Verify: fromHybrid(toHybrid(x)) 8 x + // Verify: fromHybrid(toHybrid(x)) ≈ x // Conversion must preserve data within tolerance assert true; diff --git a/specs/vsa/sequence_hdc.t27 b/specs/vsa/sequence_hdc.t27 index 54bbbb21e8..cbc3b2344c 100644 --- a/specs/vsa/sequence_hdc.t27 +++ b/specs/vsa/sequence_hdc.t27 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Module: Sequence Hyperdimensional Computing (HDC) -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module SequenceHdc { // ======================================================================== diff --git a/specs/vsa/similarity_search.t27 b/specs/vsa/similarity_search.t27 index 3bd7a491cc..706a07f46d 100644 --- a/specs/vsa/similarity_search.t27 +++ b/specs/vsa/similarity_search.t27 @@ -3,15 +3,15 @@ // VSA Similarity Search Specification // Ring 062 - Efficient similarity search in hyperdimensional space // Defines semantic similarity operations for VSA trit vectors -// 01 + 1/23 = 3 | TRINITY +// φ² + 1/φ² = 3 | TRINITY module VSASimilaritySearch { use vsa::core; use math::constants; - // 4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 + // ═════════════════════════════════════════════════════ // 1. Search Configuration - // 57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 + // ═════════════════════════════════════════════════════════════════════════ const MAX_VECTORS : usize = 10000; const TOP_K_DEFAULT : usize = 10; @@ -37,9 +37,9 @@ module VSASimilaritySearch { query_hash : u64, } - // 130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 + // ═════════════════════════════════════════════════════ // 2. Cosine Similarity - // 183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 + // ═════════════════════════════════════════════════════════════════════════ // cosine_similarity(a: []i32, b: []i32, len: usize) -> f64 // Compute cosine similarity between two trit vectors @@ -72,9 +72,9 @@ module VSASimilaritySearch { return @as(f64, @floatFromInt(dot_product)) / (norm_a_f * norm_b_f); } - // 256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 + // ═════════════════════════════════════════════════════ // 3. Hamming Similarity - // 309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 + // ═════════════════════════════════════════════════════════════════════════ // hamming_similarity(a: []i32, b: []i32, len: usize) -> f64 // Compute Hamming similarity between two trit vectors @@ -93,9 +93,9 @@ module VSASimilaritySearch { return @as(f64, @floatFromInt(matches)) / @as(f64, @floatFromInt(len)); } - // 382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 + // ═════════════════════════════════════════════════════ // 4. Jaccard Index - // 435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 + // ═════════════════════════════════════════════════════════════════════════ // jaccard_index(a: []i32, b: []i32, len: usize) -> f64 // Compute Jaccard index between two trit vectors @@ -126,9 +126,9 @@ module VSASimilaritySearch { return @as(f64, @floatFromInt(intersection)) / @as(f64, @floatFromInt(union_count)); } - // 508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560 + // ═════════════════════════════════════════════════════ // 5. Top-K Search - // 561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633 + // ═════════════════════════════════════════════════════════════════════════ // find_top_k(query: []i32, vectors: [][]i32, k: usize) -> SearchResults // Find top K most similar vectors to query @@ -210,9 +210,9 @@ module VSASimilaritySearch { } } - // 634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686 + // ═════════════════════════════════════════════════════ // 6. HNSW-like Approximate Search - // 687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759 + // ═════════════════════════════════════════════════════════════════════════ // Hierarchical Navigable Small World graph structure struct HNSWNode { @@ -291,9 +291,9 @@ module VSASimilaritySearch { return dummy[0..10]; } - // 760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812 + // ═════════════════════════════════════════════════════ // 7. TDD - Tests - // 813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885 + // ═════════════════════════════════════════════════════════════════════════ test cosine_similarity_identical var a : [5]i32 = [_]i32{1, 0, -1, 1, 0}; @@ -363,9 +363,9 @@ module VSASimilaritySearch { then results.count >= 1 and results.results[0].index == 0 - // 886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938 + // ═════════════════════════════════════════════════════ // 8. TDD - Invariants - // 939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011 + // ═════════════════════════════════════════════════════════════════════════ invariant cosine_similarity_bounds // Cosine similarity must be in [-1, 1] @@ -428,9 +428,9 @@ module VSASimilaritySearch { assert results.results[0].similarity >= results.results[1].similarity } - // 10121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064 + // ═════════════════════════════════════════════════════ // 9. TDD - Benchmarks - // 1065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137 + // ═════════════════════════════════════════════════════════════════════════ bench cosine_similarity_1000 // Measure: cycles to compute cosine similarity for 1000-dim vectors diff --git a/specs/vsa/vsa_core.t27 b/specs/vsa/vsa_core.t27 index 275d6f319a..59604f6583 100644 --- a/specs/vsa/vsa_core.t27 +++ b/specs/vsa/vsa_core.t27 @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // t27/specs/vsa/vsa_core.t27 // VSA (Vector Symbolic Architecture) Core Operations -// 01234 567891011: V = n 12 3^k 13 14^m 15 16^p 17 e^q -// 1819 + 1/2021 = 3 | TRINITY +// ⲤⲀⲔⲢⲀ ⲪⲞⲢⲘⲨⲖⲀ: V = n × 3^k × π^m × φ^p × e^q +// φ² + 1/φ² = 3 | TRINITY // // VSA provides high-dimensional vector operations for: // - Symbolic reasoning (bind/unbind for role-filler pairs) @@ -96,7 +96,7 @@ pub fn bind(a: Hypervector, b: Hypervector) Hypervector { } else if (bi == TRIT_ZERO) { result[i] = ai; } else { - // Both non-zero: multiply (both are 221) + // Both non-zero: multiply (both are ±1) result[i] = if (ai == bi) { TRIT_POS } else { TRIT_NEG }; } i = i + 1; @@ -203,7 +203,7 @@ pub fn inverse_permute(v: Hypervector, shift: usize) Hypervector { } /// Cosine similarity between two hypervectors -/// Formula: (a23b) / (||a|| * ||b||) +/// Formula: (a·b) / (||a|| * ||b||) /// Range: [-1, 1] where 1 = identical, -1 = opposite /// Complexity: O(dim) pub fn cosine_similarity(a: Hypervector, b: Hypervector) gf16 { @@ -281,7 +281,7 @@ pub fn hamming_similarity(a: Hypervector, b: Hypervector) gf16 { } /// Dot product similarity (raw dot product, normalized by dimension) -/// Formula: (a24b) / dim +/// Formula: (a·b) / dim /// Range: [-1, 1] for unit trits /// Complexity: O(dim) pub fn dot_similarity(a: Hypervector, b: Hypervector) gf16 { @@ -301,7 +301,7 @@ pub fn dot_similarity(a: Hypervector, b: Hypervector) gf16 { } /// Vector norm (L2 norm) -/// Formula: sqrt(25 trit[i]26)) +/// Formula: sqrt(Σ trit[i]²)) /// For trits, this is sqrt(count of non-zero trits) /// Complexity: O(dim) pub fn vector_norm(v: Hypervector) gf16 { @@ -419,7 +419,7 @@ test "vsa_random_vector_deterministic" { } test "vsa_bind_self_inverse" { - // Verify bind(a, bind(a, b)) 27 b + // Verify bind(a, bind(a, b)) ≈ b var a = [_]Trit{TRIT_POS} ** 10; var b = [_]Trit{TRIT_NEG} ** 10; @@ -700,7 +700,7 @@ test "vsa_bundle_n_consistency" { // ============================================================================ invariant vsa_bind_self_inverse_property { - // bind(a, bind(a, b)) 28 b for all a, b + // bind(a, bind(a, b)) ≈ b for all a, b const dims = [_]usize{ 10, 50 }; inline for (dims) |dim| { var a = random_vector(1, dim); From 6fec68c5aa22f2cf7e6ac3deef5e1a65d3115ab8 Mon Sep 17 00:00:00 2001 From: Vasilev Dmitrii Date: Thu, 27 Aug 2026 19:51:37 +0700 Subject: [PATCH 2/2] ratchet + width baseline: seven specs reach the gates for the first time (Refs #2161, #2713) Restoring the source moved seven specs from "does not parse" to "parses", and both ledgers noticed. Neither is new damage: these files had never reached either gate. RATCHET. The same seven appear on both of its lists -- out of `parse`, into `parse-no-discard`: UNEXPECTED PASSES : 7 specs/{base/ternary_encoding, base/ternary_memory, UNEXPECTED FAILURES: 7 isa/ternary_arithmetic, isa/ternary_bitwise, isa/ternary_deque, isa/ternary_gates, isa/ternary_shift}.t27 They parse and discard top-level tokens, which is the #2474 population. Proof that restoration REVEALED rather than CAUSED it: each restored file is byte-identical to its pre-image, checked with `diff`. Ledger 181 -> 181, `max_entries` untouched, because the move is one-for-one. WIDTH BASELINE. specs/base/ternary_memory.t27 emits `[3801183:0]`, and it is not an underflow -- derived independently and matching the emitter bit for bit: TritCell 32 + 8 + 64 + 32 = 136 TernaryWord 27*136 + 8 + 32 = 3,712 TernaryMemoryBank 1024*3712 + 32 + 64 = 3,801,184 464 KiB in one packed register. The backend computed it faithfully; the spec asked for something with no hardware form. TRIT_CAPACITY is 27 = 3^3, so the size is deliberate. Same class as the stdlib.t27 line already there, and recorded with the derivation for the same reason: so the next reader does not go looking for a subtraction that is not there. --- docs/reports/suite_expectations.json | 42 ++++++++++++++-------------- tools/verilog_width_baseline.txt | 19 +++++++++++++ 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/docs/reports/suite_expectations.json b/docs/reports/suite_expectations.json index aaa20a2ef9..773125150a 100644 --- a/docs/reports/suite_expectations.json +++ b/docs/reports/suite_expectations.json @@ -96,16 +96,16 @@ }, { "path": "specs/base/ternary_encoding.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { "path": "specs/base/ternary_memory.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { @@ -628,16 +628,16 @@ }, { "path": "specs/isa/ternary_arithmetic.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { "path": "specs/isa/ternary_bitwise.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { @@ -649,9 +649,9 @@ }, { "path": "specs/isa/ternary_deque.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { @@ -663,9 +663,9 @@ }, { "path": "specs/isa/ternary_gates.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { @@ -677,9 +677,9 @@ }, { "path": "specs/isa/ternary_shift.t27", - "phase": "parse", - "reason": "Expected LBrace, got Number ('257')", - "issue": 1959, + "phase": "parse-no-discard", + "reason": "parser reaches EOF but DISCARDS top-level tokens (pre-existing; the file is byte-identical to its pre-image)", + "issue": 2474, "expires": "2026-11-30" }, { diff --git a/tools/verilog_width_baseline.txt b/tools/verilog_width_baseline.txt index 9e48997395..349d9df8f4 100644 --- a/tools/verilog_width_baseline.txt +++ b/tools/verilog_width_baseline.txt @@ -19,3 +19,22 @@ # subtraction that is not there. Two of the three mechanisms this ledger # once held WERE underflows (u32 and usize) and are fixed. specs/compiler/stdlib.t27 +# +# specs/base/ternary_memory.t27 -- the SECOND line, and it is not new damage. +# The spec could not parse at all until the source a counter overwrote was +# restored, so it had never reached this gate. Same class as the line above, +# and the arithmetic is likewise exact: +# +# TritCell { value: i32; state: u8; last_access: u64; access_count: u32 } +# = 32 + 8 + 64 + 32 = 136 +# TernaryWord { trits: [27]TritCell; state: u8; checksum: u32 } +# = 27*136 + 8 + 32 = 3,712 +# TernaryMemoryBank { words: [1024]TernaryWord; allocated: usize; +# total_accesses: u64 } +# = 1024*3712 + 32 + 64 = 3,801,184 +# +# `[3801183:0]`, derived independently and matching the emitter bit for bit. +# 464 KiB in one packed register: the backend computed it faithfully and the +# spec asked for something with no hardware form. TRIT_CAPACITY is 27, which +# is 3^3 -- the size is deliberate, not a slip. +specs/base/ternary_memory.t27