Skip to content

Claude/add academic proofs bo51p#22

Merged
hyperpolymath merged 5 commits intomainfrom
claude/add-academic-proofs-Bo51p
Dec 31, 2025
Merged

Claude/add academic proofs bo51p#22
hyperpolymath merged 5 commits intomainfrom
claude/add-academic-proofs-Bo51p

Conversation

@hyperpolymath
Copy link
Owner

No description provided.

Add complete formal academic documentation covering:

Proofs and Metatheory:
- Type system soundness (progress/preservation theorems)
- Quantitative type theory (linearity proofs, semiring laws)
- Algebraic effects formal semantics (handlers, row polymorphism)
- Ownership/borrowing verification (memory safety proofs)
- Row polymorphism (unification, coherence)
- Dependent types and refinement types (normalization, SMT)
- Coherence and parametricity (free theorems)
- Type inference algorithm specification

Formal Verification:
- Operational semantics (small-step, evaluation contexts)
- Denotational semantics (domain theory, logical relations)
- Axiomatic semantics (Hoare logic, separation logic)

Mathematical Foundations:
- Categorical semantics (LCCCs, graded comonads, Freyd categories)
- Logic foundations (Curry-Howard, linear logic correspondence)
- Complexity and decidability analysis

White Papers:
- Language design rationale and related work comparison

Mechanized Proofs (stubs):
- Coq formalization structure
- Lean 4 formalization structure
- Agda formalization structure

All documents include:
- Complete formal definitions and inference rules
- Detailed proof sketches and theorem statements
- Implementation dependencies marked with [IMPL-DEP] tags
- References to academic literature
- Connections to the existing codebase (lib/ast.ml, etc.)
This commit establishes the foundation for implementing AffineScript:

Design Documents:
- DECISIONS.md: Key design decisions for runtime, effects, WASM, SMT, etc.
- ROADMAP.md: Phased implementation plan (9 phases, version milestones)

Compiler Infrastructure (OCaml stubs):
- lib/symbol.ml: Symbol table for name resolution
- lib/resolve.ml: Name resolution pass
- lib/types.ml: Internal type representation
- lib/unify.ml: Type/row/effect unification
- lib/typecheck.ml: Bidirectional type checker
- lib/quantity.ml: QTT quantity checking
- lib/borrow.ml: Borrow checker

Runtime (Rust):
- runtime/Cargo.toml: Crate configuration
- runtime/src/lib.rs: Entry point
- runtime/src/alloc.rs: Memory allocator
- runtime/src/effects.rs: Effect handling (evidence-passing)
- runtime/src/panic.rs: Panic handling
- runtime/src/ffi.rs: Foreign function interface
- runtime/src/gc.rs: Optional garbage collector

Tooling (Rust):
- tools/affinescript-lsp/: Language server protocol implementation
- tools/affine-pkg/: Package manager (Cargo-inspired)
- tools/affine-doc/: Documentation generator

All stubs contain comprehensive TODOs for future implementation.
- Fix typecheck.ml: Rewrote to use correct AST constructors (ExprVar,
  ExprLit, ExprLambda, etc. instead of EVar, ELit, ELam) and correct
  field names (id.name/id.span instead of id.id_name/id.id_span)

- Fix quantity.ml: Updated to match actual AST structure with proper
  expression constructors (ExprVar, ExprApp, ExprLet, etc.) and field
  names for quantitative type checking

- Fix borrow.ml: Rewrote borrow checker to use correct AST expression
  and pattern constructors, fixing ownership verification

- Fix resolve.ml: Already fixed in previous session, confirmed working
  with correct ident field access patterns

- Fix parse_driver.ml: Added Fun.protect for resource-safe file
  handling, ensuring file handles are closed on exceptions

- Fix error.ml: Added bounds checks (line > 0, max 0 col-1) to prevent
  invalid negative indices in error message formatting

- Fix affinescript.opam: Removed duplicate dune constraint that caused
  opam parser warnings

- Fix runtime/src/gc.rs: Added checked_add for allocation size to
  prevent integer overflow attacks on 32-bit systems

These fixes address 8 critical issues that would prevent compilation
and 2 security vulnerabilities (resource leak, integer overflow).
- Replace innerHTML with safe DOM APIs (createElement, textContent)
- Add URL validation to prevent open redirect attacks
- Add null checks for search index entries
- Remove template literal HTML construction

Fixes Semgrep finding: javascript.browser.security.insecure-document-method
@hyperpolymath hyperpolymath merged commit b2b3699 into main Dec 31, 2025
3 of 5 checks passed
@hyperpolymath hyperpolymath deleted the claude/add-academic-proofs-Bo51p branch December 31, 2025 15:18
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