Skip to content

Claude/add academic proofs mg s2z#29

Merged
hyperpolymath merged 8 commits into
mainfrom
claude/add-academic-proofs-MgS2z
Dec 31, 2025
Merged

Claude/add academic proofs mg s2z#29
hyperpolymath merged 8 commits into
mainfrom
claude/add-academic-proofs-MgS2z

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

No description provided.

claude and others added 8 commits December 31, 2025 12:22
This commit adds extensive formal proofs, theorems, and academic
documentation for WokeLang covering:

Formal Semantics:
- Big-step and small-step operational semantics
- Denotational semantics with domain theory
- Grammar proofs (unambiguity, LL(k) property, parser correctness)

Type Theory:
- Type safety proofs (Progress and Preservation theorems)
- Hindley-Milner type inference algorithm and properties
- Category theory foundations (CCCs, functors, monads)

Security:
- Capability-based security model proofs
- Consent model formal specification
- Information flow and access control properties

Compiler:
- Semantic preservation across compilation stages
- Memory model and safety proofs (no UAF, no data races)
- Interpreter ↔ VM ↔ WASM equivalence

Analysis:
- Complexity analysis for all major operations
- Concurrency and worker system proofs
- Deadlock freedom and isolation properties

Verification:
- Coq specification with theorem stubs (WokeLang.v)
- Lean 4 specification with proofs (WokeLang.lean)
- TODO markers for incomplete mechanized proofs

Papers:
- Language design white paper with rationale

These documents provide the theoretical foundation for
academic scrutiny and future formal verification efforts.
Core Language Features:
- Add Okay(value) and Oops(message) variants to runtime Value enum
- Add Expr::Index for array/string subscript access
- Add Expr::Okay, Expr::Oops, and Expr::Unwrap expression nodes
- Add Pattern::Constructor for matching Result types

Parser Updates:
- Parse Okay(expr) and Oops(expr) as Result constructors
- Parse expr[index] for array and string indexing
- Parse Okay(x) and Oops(e) as constructor patterns in decide blocks

Interpreter Updates:
- Implement evaluation of Index, Okay, Oops, Unwrap expressions
- Add apply_index() for array and string element access
- Update pattern matching to bind variables in constructor patterns
- Add builtin functions: isOkay, isOops, unwrapOr, getError
- Add is_okay(), is_oops(), unwrap() methods to Value

Tests:
- Add 7 new integration tests for Result types and indexing
- test_result_okay, test_result_oops, test_unwrap_or
- test_array_indexing, test_string_indexing
- test_decide_with_result, test_chained_indexing

All 21 tests pass.
AST Changes:
- Add Expr::Lambda for lambda expressions |x, y| -> expr
- Add Expr::CallExpr for calling expression values
- Add LambdaExpr and LambdaBody types
- Add Type::Function for function type annotations

Runtime Changes:
- Add Value::Function(Closure) for first-class functions
- Add Closure struct with params, body, and captured environment
- Add CapturedEnv to store captured variable bindings

Interpreter:
- Implement Lambda evaluation with environment capture
- Implement CallExpr for calling closures
- Add capture_environment() to snapshot bindings
- Add call_closure() to execute closures
- Update call_function() to check for closure variables first

Parser:
- Parse |x, y| -> expr (expression lambdas)
- Parse |x, y| { ... } (block lambdas)
- Parse || -> expr (no-param lambdas)
- Parse expr(args) for calling expression values

Tests:
- test_lambda_expression: basic lambda with arrow syntax
- test_lambda_block: block body with give back
- test_closure_captures: variable capture verification
- test_higher_order_function: passing functions as arguments
- test_lambda_no_params: zero-parameter lambdas

All 26 tests pass.
- Rewrote type checker to match current AST (Lambda, CallExpr, Result types)
- Added Hindley-Milner style type inference with unification
- Registered builtin functions (print, len, toString, toInt, isOkay, isOops, unwrapOr, getError)
- Updated main.rs to run type checker before interpreter
- Added --typecheck flag for type-checking without execution
- Type errors now block program execution with clear error messages
- Added TypeParam struct for generic type parameters with optional bounds
- Added type_params field to FunctionDef for generic functions: `to identity<T>(x: T) -> T`
- Added Type::Generic for parameterized types: `Result<Int, String>`
- Added Type::TypeVar for type parameter references inside generic functions
- Updated parser to parse <T, U: Bound> type parameters and type arguments
- Updated type checker to handle generic type conversion and unification
- Type variables unify with any type (polymorphic behavior)
- Added Literal::Unit variant to AST for the () value
- Parser now recognizes () as a Unit literal expression
- Interpreter and type checker handle Literal::Unit correctly
- Functions can return Unit type explicitly: `to foo() → Unit { give back (); }`
Features:
- Multiline input: automatic detection of incomplete expressions (unbalanced braces/parens)
- Persistent history: saved to ~/.woke_history between sessions
- Tab completion: keywords and user-defined identifiers
- Linting: type checking before execution (toggleable with :lint)
- New commands: :type, :lint, :history
- Start with `woke repl`

Commands: :help, :quit, :clear, :reset, :load, :ast, :type, :env, :lint, :history
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
@hyperpolymath
hyperpolymath merged commit 57a59d6 into main Dec 31, 2025
2 of 5 checks passed
@hyperpolymath
hyperpolymath deleted the claude/add-academic-proofs-MgS2z branch December 31, 2025 14:34
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