Skip to content

Conversation

@hyperpolymath
Copy link
Owner

No description provided.

claude and others added 7 commits December 31, 2025 12:31
This commit adds complete academic documentation for Eclexia including:

- WHITEPAPER.md: Introduction to Economics-as-Code paradigm
- PROOFS.md: Mathematical foundations and correctness proofs
  - Type safety (progress & preservation)
  - Dimensional correctness
  - Resource safety
  - Economic optimality
  - Termination bounds
- SPECIFICATION.md: Formal language specification with EBNF grammar
- FORMAL_VERIFICATION.md: Coq/Lean/Agda formalization roadmap
  - Logical relations proofs
  - Step-indexed semantics
  - Separation logic for memory safety
  - Quantitative type theory
- THEORY.md: Type theory and categorical semantics
  - Dependent resource types
  - Graded monads for effects
  - Domain-theoretic semantics
  - Game semantics
  - Session types for resources
- ALGORITHMS.md: Complexity analysis and optimization algorithms
  - Solution selection (O(n·m))
  - Shadow price computation (O(m³))
  - Multi-objective optimization
  - Carbon-aware scheduling
  - Online algorithms with competitive analysis
- BIBLIOGRAPHY.md: Comprehensive academic references

Updated STATE.scm to reflect 75% completion with new documentation.
- Add EXTENDED_PROOFS.md with complete academic proofs for
  substitution lemma, progress, preservation, strong normalization,
  logical relations, resource safety, and decidability
- Add IMPLEMENTATION_ROADMAP.md with comprehensive technology stack,
  phased development plan, and dependencies matrix for building
  Eclexia as a complete language
- Update ROADMAP.md to reference implementation roadmap and document
  completed academic documentation milestone
- Update STATE.scm to reflect 80% project completion
This commit implements the foundational compiler infrastructure for Eclexia:

Compiler Components:
- eclexia-ast: AST definitions with dimensional types, resource annotations,
  and adaptive block structures
- eclexia-lexer: Lexer with support for dimensional literals (100J, 5ms,
  10gCO2e), resource keywords, and all Eclexia syntax
- eclexia-parser: Recursive descent parser with error recovery for full
  Eclexia syntax including adaptive functions and constraints
- eclexia-typeck: Type checker scaffolding with type variable support
- eclexia-hir/mir/codegen: Placeholder crates for future phases

Runtime:
- eclexia-runtime: Runtime system scaffolding with scheduler, shadow price,
  profiler, and carbon monitoring modules

CLI & Tooling:
- eclexia: CLI with build, run, check, fmt, init, test, bench commands
- Interactive REPL with :help, :shadow, :resources commands

Examples:
- hello.ecl: Hello world with energy constraint
- fibonacci.ecl: Adaptive fibonacci with memoized/naive solutions
- matrix_multiply.ecl: GPU/parallel/naive matrix multiplication
- carbon_aware.ecl: Carbon-aware ML training with defer_until

All 14 tests passing (5 AST, 7 lexer, 2 parser tests).

Phase 1 of IMPLEMENTATION_ROADMAP.md: Minimal Viable Compiler
…election

- Add eclexia-interp crate with full interpreter implementation:
  - Value types for all Eclexia runtime values
  - Environment with lexical scoping
  - Expression and statement evaluation
  - Adaptive function solution selection based on shadow prices
  - Built-in functions (println, len, range, math functions, etc.)

- Integrate interpreter with CLI run command

- Add CARBON_APIS.md documenting carbon intensity API options:
  - UK Carbon Intensity API (free, no key)
  - WattTime (free tier + paid)
  - Electricity Maps
  - Implementation architecture recommendations

- Update fibonacci.ecl to demonstrate adaptive function selection:
  - Two solutions with different resource costs
  - Runtime selects lowest-cost solution based on shadow prices
  - fibonacci(10) = 55 works correctly

Project completion: 35% -> 45%
Security hardening:
- Add MAX_CALL_DEPTH (1000) to prevent stack overflow from unbounded recursion
- Add MAX_LOOP_ITERATIONS (10M) to prevent infinite loop DoS
- Add MAX_RANGE_SIZE (1M) to prevent memory exhaustion from range()
- Add integer overflow checking in power operations with checked_pow()
- Add exponent limit (63) for integer power operations

Bug fixes:
- Fix solution selection to properly error when no solution fits budget
  Previously returned index 0 even when all solutions exceeded constraints
- Now returns ResourceViolation error with current/budget values
Major improvements across the compiler and interpreter:

Type Checking:
- Implement basic Hindley-Milner type inference with unification
- Add proper type checking for functions, expressions, and operators
- Support variadic println/print functions

Error Reporting:
- Add LineCol struct for line:column position tracking
- Add format_with_source() to parse/type/runtime errors
- Display line:column in all error messages

Lambda Support:
- Fix lambda body execution by storing ExprId directly
- Update FunctionBody to enum with Block and Lambda variants

Adaptive Functions:
- Implement @when clause evaluation in solution selection
- Evaluate @when expressions in call context with bound parameters

CLI Improvements:
- Add path sanitization to init command (prevent path traversal)
- Implement basic fmt command with syntax checking
- Implement test command with file discovery and execution
- Implement bench command with timing output
- Fix REPL to actually evaluate expressions

Documentation:
- Add GETTING_STARTED.md with installation and usage guide

All 14 tests passing.
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
@hyperpolymath hyperpolymath merged commit d09799d into main Dec 31, 2025
1 of 2 checks passed
@hyperpolymath hyperpolymath deleted the claude/add-academic-proofs-ggVWJ branch December 31, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants