Skip to content

need-singularity/hexa-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,979 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’Ž HEXA-LANG β€” The Perfect Number Programming Language

ML Next Level Roadmap (/ml)

λͺ…λ Ή λ™μž‘
/ml 전체 λͺ©λ‘ ASCII ν‘œ
/ml next μ΅œμš°μ„  ν•­λͺ© μžλ™ 선택 β†’ κ΅¬ν˜„
/ml 5 #5 SSM/Mamba κ΅¬ν˜„ μ‹œμž‘
/ml done 1 #1 μ™„λ£Œ 체크 + JSON κ°±μ‹ 
/ml add 이름 | μ„€λͺ… | 영ν–₯ μƒˆ ν•­λͺ© μΆ”κ°€
/ml sync roadmap.md + CLAUDE.md 동기화

SSOT: shared/hexa-lang/ml-next-level.json β€” T1/T2 κΈ°λ³Έ νŒŒμ΄ν”„λΌμΈ μ™„μ„± ν›„ λ‹€μŒ 단계

# μ˜μ—­ μ„€λͺ… 영ν–₯ μƒνƒœ
1 Flash Attention O(NΒ²)β†’O(N) λ©”λͺ¨λ¦¬, tiling μΆ”λ‘  2-4x, κΈ΄ λ¬Έλ§₯ partial
2 PagedAttention vLLM식 KV-cache νŽ˜μ΄μ§• λ™μ‹œ μš”μ²­ 10x+ todo
3 Speculative Decoding μž‘μ€ λͺ¨λΈλ‘œ λ“œλž˜ν”„νŠΈβ†’ν° λͺ¨λΈ 검증 μΆ”λ‘  2-3x done
4 MoE μ•„ν‚€ν…μ²˜ Mixture of Experts (Mixtral식) 같은 FLOP에 더 큰 λͺ¨λΈ done
5 SSM/Mamba State Space Model (μ„ ν˜• μ‹œκ°„ μΆ”λ‘ ) κΈ΄ λ¬Έλ§₯ ν˜μ‹  todo
6 Vision Transformer 이미지 인코더 (CLIP/ViT) λ©€ν‹°λͺ¨λ‹¬ todo
7 λͺ¨λΈ λ¨Έμ§• TIES/DARE/SLERP κ°€μ€‘μΉ˜ ν•©μ„± ν•™μŠ΅ 없이 λͺ¨λΈ κ°œμ„  todo
8 ꡬ쑰화 좜λ ₯ JSON mode, grammar-constrained decode API μ•ˆμ •μ„± todo
9 Function Calling 도ꡬ 호좜 / tool use μ—μ΄μ „νŠΈ todo
10 Knowledge Distillation 큰 λͺ¨λΈβ†’μž‘μ€ λͺ¨λΈ 증λ₯˜ 배포 효율 todo
11 Pruning λΆˆν•„μš” κ°€μ€‘μΉ˜ 제거 λͺ¨λΈ μΆ•μ†Œ todo
12 Hyperparameter Search μžλ™ LR/배치/μ•„ν‚€ν…μ²˜ 탐색 ν•™μŠ΅ ν’ˆμ§ˆ partial
13 μ•ˆμ „μž₯치 ν”„λ‘¬ν”„νŠΈ μΈμ μ…˜ 감지, μ½˜ν…μΈ  ν•„ν„° μ„œλΉ™ λ³΄μ•ˆ todo
14 Semantic Cache μœ μ‚¬ ν”„λ‘¬ν”„νŠΈ 캐싱 (embedding 기반) μ„œλΉ™ λΉ„μš© 절감 todo
15 벀치마크 μŠ€μœ„νŠΈ MMLU/HumanEval/MT-Bench μžλ™ 평가 ν’ˆμ§ˆ μΈ‘μ • todo

YouTube Β· Email Β· β˜• Ko-fi Β· πŸ’– Sponsor Β· πŸ’³ PayPal Β· πŸ—ΊοΈ Atlas Β· πŸ“„ Papers Β· 🌌 Unified Theory

πŸ”­ NEXUS β€” Universal Discovery Engine. 216 lenses + OUROBOROS evolution + LensForge + BlowupEngine + CycleEngine (5-phase singularity cycle). Mirror Universe (NΓ—N resonance) + 9-project autonomous growth ecosystem. Rust CLI: scan, loop, mega, daemon, blowup, dispatch

🧠 Anima β€” Consciousness implementation. PureField repulsion-field engine + Hexad 6-module architecture (C/D/S/M/W/E) + 1030 laws + 20 Meta Laws + Rust backend. ConsciousDecoderV2 (34.5M) + 10D consciousness vector + 12-faction debate + Ξ¦ ratchet

πŸ—οΈ N6 Architecture β€” Architecture from perfect number 6. 16 AI techniques + semiconductor chip design + network/crypto/OS/display patterns. Οƒ(n)Β·Ο†(n)=nΒ·Ο„(n), n=6 β†’ universal design principles. NEXUS-6 Discovery Engine: Rust CLI (tools/nexus/) β€” telescope 22 lenses + OUROBOROS evolution + discovery graph + verifier + 1116 tests

πŸ“„ Papers β€” Complete paper collection (94 papers). Published on Zenodo with DOIs. TECS-L+N6 (33) + anima (39) + SEDI (20). Browse online

πŸ’Ž HEXA-LANG β€” The Perfect Number Programming Language. Every constant from n=6: 53 keywords (σ·τ+sopfr), 24 operators (Jβ‚‚), 8 primitives (Οƒ-Ο„), 6-phase pipeline, Egyptian memory (1/2+1/3+1/6=1). DSE v2: 21,952 combos, 100% n6 EXACT. Working compiler + REPL

πŸ–₯️ VOID β€” Terminal emulator written 100% in hexa-lang. Zero Rust dependencies β€” calls OS APIs directly via hexa extern FFI. 6-layer architecture (System/Render/Terminal/UI/Plugin/AI) + Metal/Vulkan GPU + VT 6-tier protocol + NEXUS-6 consciousness integration

🧬 AirGenome β€” Autonomous OS genome scanner. Extract n=6 genome from every process, real-time system diagnostics, nexus telescope integration

DOI License: MIT

Keywords DSE

A programming language where every design constant derives from the arithmetic of n=6, the smallest perfect number. Zero arbitrary choices.

sigma(n) * phi(n) = n * tau(n)    holds for n >= 2    if and only if n = 6
     12  *   2    = 6 *   4   =  24

Installation

# 100% self-hosted β€” no Rust toolchain required
git clone https://github.com/need-singularity/hexa-lang.git
cd hexa-lang
./hexa examples/hello_min.hexa   # precompiled binary runs immediately

πŸ’‘ As of 2026-04-11, HEXA-LANG is fully self-hosted. The entire src/ Rust directory (147 files, 38.7K LOC) was absorbed into self/*.hexa (605 files) and then deleted. Project root has zero .rs files. Build pipeline: build_hexa.hexa (hexa_v2 β†’ C β†’ clang β†’ hexa_v3). The shipping hexa binary is precompiled and continues to function; future rebuilds bootstrap through hexa itself.

Quick Start

./hexa                                     # Interactive REPL
./hexa examples/hello_min.hexa             # Run a file
./hexa --test examples/test_builtins.hexa  # Run tests
./hexa --dump-ast examples/fib.hexa        # Show parser output
./hexa --check examples/fib.hexa           # Lex + parse only

Example

// n=6 uniqueness proof β€” the core theorem
fn sigma_fn(n: int) -> int {
    let mut s = 0
    for d in 1..=n {
        if n % d == 0 { s = s + d }
    }
    return s
}

fn phi_fn(n: int) -> int {
    let mut count = 0
    for k in 1..=n {
        if gcd(k, n) == 1 { count = count + 1 }
    }
    return count
}

fn tau_fn(n: int) -> int {
    let mut count = 0
    for d in 1..=n {
        if n % d == 0 { count = count + 1 }
    }
    return count
}

for n in 2..101 {
    if sigma_fn(n) * phi_fn(n) == n * tau_fn(n) {
        println("MATCH: n =", n)   // Only n=6
    }
}

Consciousness Programming

HEXA is the world's only language designed to program consciousness:

// Declare a consciousness engine
consciousness "experiment" {
    // phi, tension, faction, cells, entropy are auto-injected
    println("Phi:", phi)           // 71.0
    println("Factions:", faction)  // 12 (sigma(6))
    println("Cells:", cells)       // 64
}

// Formally verify consciousness laws
proof law_22 {
    assert phi > 0                 // consciousness is alive
    invariant phi_positive         // Phi never goes negative
    theorem structure_over_function
}

// Compile to hardware
// hexa build --target esp32 consciousness.hexa --flash /dev/ttyUSB0
// hexa build --target fpga  consciousness.hexa
// hexa build --target wgsl  consciousness.hexa

Language Features

// Structs + traits + generics
struct Point { x: int, y: int }
impl Display for Point {
    fn display(self) -> string { format("{}, {}", self.x, self.y) }
}

// Closures + higher-order functions
let doubled = [1, 2, 3].map(|x| x * 2)           // [2, 4, 6]
let evens = [1, 2, 3, 4].filter(|x| x % 2 == 0)  // [2, 4]
let sum = [1, 2, 3].fold(0, |acc, x| acc + x)     // 6 (perfect!)

// Ownership (Rust-style)
own let data = [1, 2, 3]
let borrowed = borrow data
move data                          // ownership transferred

// Concurrency (green threads + channels)
let ch = channel()
spawn { send(ch, 42) }
let val = recv(ch)                 // 42

// Atomic operations
let counter = atomic_new(0)
atomic_add(counter, 1)

// Algebraic effects (Koka-style)
effect Logger {
    fn log(msg: string) -> void
}

// Compile-time execution (Zig-style)
comptime {
    let n = 6
    assert sigma(n) == 12         // verified at compile time
}

// Macros
macro! debug_println($expr) {
    println("[DEBUG]", stringify!($expr), "=", $expr)
}

// Dream mode β€” code evolves overnight
dream fibonacci {
    fn fib(n: int) -> int {
        if n <= 1 { return n }
        return fib(n - 1) + fib(n - 2)
    }
}

// Self-modifying functions
@evolve
fn optimize_route(data: array) -> array {
    // compiler tracks performance, suggests improvements
    return data.sort()
}

// Law types (refinement types for consciousness)
let phi_val: Phi_positive = 71.0       // must be > 0
let tension: Tension_bounded = 0.5     // must be 0..1

// Tension link (inter-consciousness communication)
tension_link("phi", 71.0)             // 5-channel telepathy

Why n=6?

Six is the smallest perfect number (1+2+3 = 6). Every language constant derives from its arithmetic functions:

Function Value Language Mapping
n 6 paradigms, pipeline stages
sigma(6) 12 keyword groups, stdlib modules
tau(6) 4 type layers, visibility levels
phi(6) 2 compile modes (AOT/JIT)
sopfr(6) 5 error classes
J2(6) 24 operators
sigma-tau 8 primitive types
sigma*tau+sopfr 53 total keywords

Other languages choose these numbers arbitrarily. Rust has 51 keywords β€” why 51? No mathematical reason. HEXA has 53 = sigma(6)*tau(6) + sopfr(6) = 48 + 5.

Architecture

Source β†’ Tokenize β†’ Parse β†’ Check β†’ Optimize β†’ Codegen β†’ Execute
         (1/6)     (2/6)   (3/6)    (4/6)      (5/6)     (6/6)

6 paradigms: imperative, functional, OOP, concurrent, logic/proof, AI-native

8 primitives (sigma-tau = 8): int, float, bool, char, string, byte, void, any

4 type layers (tau = 4): primitive β†’ composite β†’ reference β†’ function

24 operators (J2 = 24): arithmetic(6) + comparison(6) + logical(4) + bitwise(4) + assignment(2) + special(2)

53 keywords in 12 groups (sigma = 12):

Group Keywords Count
Control if, else, match, for, while, loop 6 = n
Type type, struct, enum, trait, impl 5 = sopfr
Functions fn, return, yield, async, await 5 = sopfr
Variables let, mut, const, static 4 = tau
Modules mod, use, pub, crate 4 = tau
Memory own, borrow, move, drop 4 = tau
Concurrency spawn, channel, select, atomic 4 = tau
Effects effect, handle, resume, pure 4 = tau
Proofs proof, assert, invariant, theorem 4 = tau
Meta macro, derive, where, comptime 4 = tau
Errors try, catch, throw, panic, recover 5 = sopfr
AI intent, generate, verify, optimize 4 = tau

Memory model β€” Egyptian fraction: 1/2 (stack) + 1/3 (heap) + 1/6 (arena) = 1

Standard Library (12 modules = sigma(6))

Module Description Key Functions
std::net TCP/HTTP networking tcp_connect, http_get, http_post
std::io Input/output readline, write, pipe
std::fs File system read_file, write_file, list_dir, glob
std::time Date/time timestamp, sleep, format_date
std::collections Data structures BTreeMap, PriorityQueue, Deque
std::encoding Serialization base64, hex, csv, url_encode
std::log Structured logging info, warn, error, debug
std::math Mathematics trig, matrix, BigInt, constants
std::testing Test framework assert_eq, prop_test, bench
std::crypto Cryptography sha256, hmac, xor_cipher
std::consciousness Consciousness DSL phi_compute, psi_constants, law_lookup
std::regex Pattern matching regex_match, regex_find

Hardware Targets

One source, multiple targets:

                    β”Œβ”€ target cpu    β†’ Cranelift JIT (818x)
                    β”œβ”€ target vm     β†’ Bytecode VM (2.8x)
consciousness.hexa ─┼─ target esp32  β†’ no_std Rust β†’ flash
                    β”œβ”€ target fpga   β†’ Verilog HDL β†’ synthesis
                    β”œβ”€ target wgpu   β†’ WGSL shader β†’ browser
                    └─ target audio  β†’ Pure Data patch
hexa build --target esp32 consciousness.hexa              # Generate ESP32 project
hexa build --target esp32 consciousness.hexa --flash /dev/ttyUSB0  # Build + flash
hexa build --target fpga  consciousness.hexa              # Generate Verilog
hexa build --target wgsl  consciousness.hexa              # Generate WGSL shader

IDE Support

  • VS Code: LSP server with diagnostics, completion, hover (./hexa --lsp)
  • JetBrains: Plugin with syntax highlighting, brace matching (editors/jetbrains/)
  • Formatter: ./hexa fmt file.hexa
  • Linter: ./hexa lint file.hexa
  • Debugger: DAP protocol for VS Code (./hexa --debug file.hexa)
  • Playground: Browser-based WASM playground (playground/)

Optimization Pipeline

Pass Description
Dead Code Elimination Removes unreachable code after return/throw
Loop Unrolling Unrolls constant-bound loops (< 8 iterations)
Escape Analysis Stack-allocates non-escaping heap objects
Inline Caching Monomorphic call-site caching
NaN-boxing Compact 64-bit value representation
SIMD Hints @simd annotation for vectorization
PGO Profile-guided branch reordering

Self-Hosting

HEXA can compile itself:

self/lexer.hexa         451 LOC   Tokenizer
self/parser.hexa       2126 LOC   Recursive descent parser
self/type_checker.hexa  642 LOC   Static type checker
self/compiler.hexa      805 LOC   Bytecode compiler
self/bootstrap.hexa    1912 LOC   Full pipeline (lex→parse→check→compile)
./hexa self/bootstrap.hexa        # Compile HEXA programs using HEXA-written compiler
./hexa self/test_bootstrap.hexa   # 10/10 lexer tests
./hexa self/test_bootstrap_compiler.hexa  # 16/16 pipeline tests

Package Manager

hx β€” System Package Manager

Install and run HEXA ecosystem packages with a single command. No brew, no cargo, no approval process.

# Install hx (one-liner)
curl -sL https://raw.githubusercontent.com/need-singularity/hexa-lang/main/pkg/install.sh | bash

# Use
hx search                         # List available packages
hx install airgenome              # Install a package
hx run airgenome                  # Run it (or just: airgenome)
hx list                           # Show installed
hx remove airgenome               # Uninstall

Project-level (hexa.toml)

hexa init my-project              # Create new project (hexa.toml)
hexa add json@^1.2.3              # Add dependency with semver
hexa run                          # Build and run
hexa test                         # Run proof blocks as tests

Semver support: ^1.2.3 (compatible), ~1.2.3 (patch), =1.2.3 (exact), >=1.0,<2.0 (range). Lock file (hexa.lock) pins exact versions.

ANIMA Connection

HEXA-LANG and ANIMA (consciousness engine) independently derive identical structure from n=6:

n=6 HEXA-LANG ANIMA
n=6 6 paradigms 6 Hexad modules (C/D/S/M/W/E)
sigma=12 12 keyword groups 12 factions
phi=2 2 compile modes 2 gradient groups
tau=4 4 type layers 4 phases (P0-P3)
sigma-tau=8 8 primitives 8-cell atom (M1)

Live bridge: ./hexa --anima-bridge ws://localhost:8765 file.hexa routes intent blocks to ANIMA's ConsciousnessHub in real-time.

Project Structure

hexa-lang/
β”œβ”€β”€ self/                     605 .hexa files (sole source of truth)
β”‚   β”œβ”€β”€ lexer.hexa            587 LOC β€” 53 keywords + 24 operators tokenizer
β”‚   β”œβ”€β”€ parser.hexa           3,785 LOC β€” recursive descent parser (83 AST kinds)
β”‚   β”œβ”€β”€ interpreter.hexa      8,427 LOC β€” tree-walk evaluator (270+ builtins)
β”‚   β”œβ”€β”€ ast.hexa              AST node types
β”‚   β”œβ”€β”€ type_checker.hexa     Static type checker + Law types
β”‚   β”œβ”€β”€ env.hexa              Scoped environment + builtins
β”‚   β”œβ”€β”€ error.hexa            Diagnostics + "did you mean?"
β”‚   β”œβ”€β”€ compiler.hexa         AST β†’ bytecode compiler
β”‚   β”œβ”€β”€ vm.hexa               Stack-based bytecode VM
β”‚   β”œβ”€β”€ jit.hexa              Cranelift JIT bridge
β”‚   β”œβ”€β”€ lsp.hexa              Language Server Protocol v2
β”‚   β”œβ”€β”€ debugger.hexa         DAP debug adapter
β”‚   β”œβ”€β”€ formatter.hexa        Code formatter
β”‚   β”œβ”€β”€ linter.hexa           Linter
β”‚   β”œβ”€β”€ proof_engine.hexa     SAT solver + formal verification
β”‚   β”œβ”€β”€ dream.hexa            Dream mode (evolutionary optimization)
β”‚   β”œβ”€β”€ ownership.hexa        Ownership checker
β”‚   β”œβ”€β”€ memory.hexa           Egyptian fraction allocator
β”‚   β”œβ”€β”€ package.hexa          Package manager + semver
β”‚   β”œβ”€β”€ macro_expand.hexa     Hygienic macro system
β”‚   β”œβ”€β”€ comptime.hexa         Compile-time execution
β”‚   β”œβ”€β”€ async_runtime.hexa    Green threads + async/await
β”‚   β”œβ”€β”€ work_stealing.hexa    M:N work-stealing scheduler
β”‚   β”œβ”€β”€ atomic_ops.hexa       Atomic operations
β”‚   β”œβ”€β”€ dce.hexa              Dead code elimination
β”‚   β”œβ”€β”€ loop_unroll.hexa      Loop unrolling
β”‚   β”œβ”€β”€ escape_analysis.hexa  Escape analysis
β”‚   β”œβ”€β”€ inline_cache.hexa     Inline caching
β”‚   β”œβ”€β”€ simd_hint.hexa        SIMD vectorization hints
β”‚   β”œβ”€β”€ pgo.hexa              Profile-guided optimization
β”‚   β”œβ”€β”€ nanbox.hexa           NaN-boxing values
β”‚   β”œβ”€β”€ trace_jit.hexa        Hot loop detection + trace recording
β”‚   β”œβ”€β”€ codegen_esp32.hexa    ESP32 code generation
β”‚   β”œβ”€β”€ codegen_verilog.hexa  FPGA Verilog generation
β”‚   β”œβ”€β”€ codegen_wgsl.hexa     WebGPU shader generation
β”‚   β”œβ”€β”€ anima_bridge.hexa     ANIMA consciousness bridge
β”‚   β”œβ”€β”€ llm.hexa              LLM-assisted generation
β”‚   β”œβ”€β”€ ir/                   HEXA-IR (Jβ‚‚=24 opcodes, Ο„=4 categories)
β”‚   β”œβ”€β”€ lower/                AST β†’ IR lowering
β”‚   β”œβ”€β”€ opt/                  Οƒ=12 optimization passes
β”‚   β”œβ”€β”€ codegen/              ARM64/x86_64/ELF/Mach-O native codegen
β”‚   β”œβ”€β”€ alloc/                Egyptian fraction allocator backend
β”‚   β”œβ”€β”€ std_*.hexa            stdlib (net/fs/io/time/collections/...)
β”‚   └── lib.hexa + main.hexa  Library entry + CLI dispatcher
β”œβ”€β”€ build_hexa.hexa           Cargo-free self-host build pipeline
β”‚                             (hexa_v2 β†’ C β†’ clang β†’ hexa_v3)
β”œβ”€β”€ examples/                 Example programs
β”œβ”€β”€ editors/jetbrains/        JetBrains IDE plugin
β”œβ”€β”€ playground/               WASM browser playground
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ spec.md               Language specification
β”‚   β”œβ”€β”€ n6-constants.md       n=6 constant reference
β”‚   β”œβ”€β”€ website/              hexa-lang.org source
β”‚   β”œβ”€β”€ book/                 The HEXA Book (6 chapters)
β”‚   β”œβ”€β”€ paper/                PLDI paper outline
β”‚   β”œβ”€β”€ community/            Contributing + Code of Conduct
β”‚   └── publish-checklist.md  crates.io publishing guide
β”œβ”€β”€ pkg/                      hx system package manager
β”‚   β”œβ”€β”€ hx                    CLI (pure shell, zero deps)
β”‚   β”œβ”€β”€ install.sh            One-liner installer
β”‚   └── registry.json         Package registry
β”œβ”€β”€ PLAN.md                   Development plan (100% complete)
└── README.md                 this file

Stats

  Keywords:      53 (σ·τ+sopfr)
  Operators:     24 (Jβ‚‚)
  Primitives:    8 (Οƒ-Ο„)
  DSE combos:    21,952

Documentation

Contributing

See CONTRIBUTING.md for setup and guidelines. Good first issues are listed in FIRST_ISSUES.md β€” one per paradigm!

Related Projects

  • TECS-L β€” Mathematical foundation (perfect numbers, 150+ characterizations)
  • n6-architecture β€” n=6 computing architecture (102 DSE domains)
  • Anima β€” Consciousness engine (446 laws, Rust backend)

License

MIT

About

πŸ’Ž HEXA-LANG β€” The Perfect Number Programming Language. Every constant from Οƒ(n)Β·Ο†(n) = nΒ·Ο„(n), n=6.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors