Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
dc30a83
feat(contracts): climb matmul-kernel-v1 to honest L4 — 3 Lean-proved …
noahgift Jul 4, 2026
a42bafa
feat(contracts): climb apr-cli-sampling-v1 to L4 — 3 analytic samplin…
noahgift Jul 4, 2026
4a676d1
proof(embedding-lookup): climb to L4 — 11 sorry-free Lean gather theo…
noahgift Jul 4, 2026
f346832
feat(batchnorm-kernel-v1): climb to L4 — 4 analytic obligations prove…
noahgift Jul 4, 2026
8fca3c9
feat(silu-kernel-v1): climb to honest L4 — 6 Lean-proved analytic obl…
noahgift Jul 4, 2026
c434c0f
proof(contracts): gelu-kernel-v1 — prove non-negativity + positive mo…
noahgift Jul 4, 2026
73027f9
feat(conv1d-kernel-v1): climb L3→L4 — Lean-prove linearity, output-sh…
noahgift Jul 4, 2026
faf1829
Merge remote-tracking branch 'origin/climb3/matmul-kernel-v1' into fe…
noahgift Jul 4, 2026
c0fe4f1
Merge remote-tracking branch 'origin/climb3/silu-kernel-analytic' int…
noahgift Jul 4, 2026
7962434
Merge remote-tracking branch 'origin/climb3/gelu-kernel-v1' into feat…
noahgift Jul 4, 2026
97dd696
Merge remote-tracking branch 'origin/climb3/batchnorm-kernel-analytic…
noahgift Jul 4, 2026
69b55c7
Merge remote-tracking branch 'origin/climb3/conv1d-kernel-lean' into …
noahgift Jul 4, 2026
cdc1e4f
Merge remote-tracking branch 'origin/climb3/embedding-lookup-v1' into…
noahgift Jul 4, 2026
ee20f6f
Merge remote-tracking branch 'origin/climb3/apr-cli-sampling-v1' into…
noahgift Jul 4, 2026
89413d1
proof(contracts): corpus climb wave 3 — 6 more kernels → L4 (matmul c…
noahgift Jul 4, 2026
e0bc85b
proof(rope-kernel-v1): L3→L4 — Lean proofs of RoPE norm/relative-posi…
noahgift Jul 4, 2026
473165f
feat(cma-es-kernel-v1): climb L3→L4 — prove 4 analytic obligations in…
noahgift Jul 4, 2026
ccfed6d
feat(gqa-kernel-v1): climb to L4 — 6 analytic obligations proved in v…
noahgift Jul 4, 2026
d5a5af7
proof(alibi-kernel-v1): L3→L4 — 4/5 obligations proved in verified Le…
noahgift Jul 4, 2026
224b46d
feat(contracts): embedding-algebra-v1 analytic Lean proofs (5/7 oblig…
noahgift Jul 4, 2026
6af9072
Merge remote-tracking branch 'origin/climb4/gqa-kernel-v1-lean' into …
noahgift Jul 5, 2026
9d081e3
Merge remote-tracking branch 'origin/climb4/alibi-kernel-v1' into fea…
noahgift Jul 5, 2026
647e9af
Merge remote-tracking branch 'origin/climb4/embedding-algebra-lean' i…
noahgift Jul 5, 2026
8a3e176
Merge remote-tracking branch 'origin/climb4/cma-es-kernel-v1' into fe…
noahgift Jul 5, 2026
65e90c5
proof(contracts): corpus climb wave 4 — rope/gqa/alibi/cma-es → L4, e…
noahgift Jul 5, 2026
bc538a4
proof(adamw-kernel-v1): climb L3->L4 — 9/11 obligations Lean-proved, …
noahgift Jul 5, 2026
d10b60e
feat(contracts): climb apr-gguf-export-symmetry-v1 L3->L4 — 4 analyti…
noahgift Jul 5, 2026
efe3961
feat(contracts): climb alibi-slopes-v1 to L4 — 3/3 analytic obligatio…
noahgift Jul 5, 2026
188f9df
proof(activation-kernel): wave-3 analytic hardening — relu∘relu idemp…
noahgift Jul 5, 2026
6bfded3
feat(contracts): swiglu-kernel-v1 L3->L4 — prove 4 remaining analytic…
noahgift Jul 5, 2026
e54278c
feat(contracts): climb absolute-position-v1 to L4 — 5 analytic obliga…
noahgift Jul 5, 2026
62b79b5
Merge remote-tracking branch 'origin/climb5/activation-kernel-analyti…
noahgift Jul 5, 2026
ab063a8
Merge remote-tracking branch 'origin/climb5/adamw-analytic' into feat…
noahgift Jul 5, 2026
a1e51fb
Merge remote-tracking branch 'origin/climb5/alibi-slopes-l4' into fea…
noahgift Jul 5, 2026
2e04f0c
Merge remote-tracking branch 'origin/climb5/gguf-export-symmetry-lean…
noahgift Jul 5, 2026
91570d8
Merge remote-tracking branch 'origin/climb5/swiglu-kernel-analytic' i…
noahgift Jul 5, 2026
67c9ff2
proof(contracts): corpus climb wave 5 — swiglu/abs-pos/adamw/alibi-sl…
noahgift Jul 5, 2026
3a9c2c7
Fix roadmap.yaml schema
noahgift Jul 5, 2026
72d65e4
add pmat work files and fixes
noahgift Jul 5, 2026
4d8bd46
fix pmat.toml exclude .lake for sorry scanner
noahgift Jul 5, 2026
913dec6
kaizen: auto-fix 11 issues in aprender
noahgift Jul 5, 2026
daea4d4
kaizen(agent): fix defect::RUST-UNWRAP-001 in aprender
noahgift Jul 5, 2026
b23c0f6
kaizen(agent): fix defect::RUST-UNWRAP-001 in aprender
noahgift Jul 5, 2026
f737d1c
kaizen(agent): fix defect::RUST-UNWRAP-001 in aprender
noahgift Jul 5, 2026
3a8c92f
feat: [GPU-GATED — flag] CPU Q4_K decode parity: implement ggml-style…
noahgift Jul 5, 2026
8a25e92
feat(contracts): attention-scaling-v1 climb to honest L3 — 6/7 obliga…
noahgift Jul 5, 2026
915d2d1
feat: Implement Phase 2 distributed training CLI wiring (Issue #393)
noahgift Jul 5, 2026
af71a5f
fix(train): Disable wgpu matmul for bandwidth-bound vector-matrix ops
noahgift Jul 5, 2026
8c90942
feat(serve): implement CRUX M1 REST/CLI parity with --ollama-compat (…
noahgift Jul 5, 2026
76ee774
Merge feat/corpus-climb-wave-3 (PR #2289) into chore-merge-all
noahgift Jul 5, 2026
807a006
Merge climb6/attention-scaling-l4 (PR #2293) into chore-merge-all
noahgift Jul 5, 2026
16dd8a2
Merge fix-pmat-737 (PR #2294) into chore-merge-all
noahgift Jul 5, 2026
cf15e50
Merge issue-918-crux-m1 (PR #2296) into chore-merge-all
noahgift Jul 5, 2026
acb0afa
Merge fix-issue-751 (PR #2297) into chore-merge-all
noahgift Jul 5, 2026
86e5710
Merge feat/corpus-climb-wave-4 (PR #2290) into chore-merge-all
noahgift Jul 5, 2026
450559a
Merge feat/corpus-climb-wave-5 (PR #2291) into chore-merge-all
noahgift Jul 5, 2026
084b14f
fix: resolve workspace test failures and update quick-xml to 0.41.0
noahgift Jul 5, 2026
9102da8
docs(roadmap): integrate Fable review into the 2026-07-05 next-wave s…
noahgift Jul 5, 2026
859ff7b
fix(build): resolve PR 2286 build failures
noahgift Jul 5, 2026
d0b07b5
style: cargo fmt
noahgift Jul 5, 2026
8247a84
fix(apr-cli): add missing ollama_compat field to ServeCommands::Run t…
noahgift Jul 5, 2026
ca34a51
fix(apr-cli): align distributed-config test with #2294's implemented …
noahgift Jul 5, 2026
dbc3ac3
chore: autonomously validate top 50 HF models
noahgift Jul 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file added .lint-cache
Empty file.
22 changes: 22 additions & 0 deletions .pmat-tickets/DEBT-COV-20260705104033.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# PMAT Legacy Debt Ticket
# Auto-generated by `pmat comply upgrade`
# DO NOT DELETE - Required for Popperian falsification override

ticket_id: "DEBT-COV-20260705104033"
category: "coverage"
created_at: "2026-07-05T10:40:33.185722978+00:00"
status: "open"

description: |
Coverage 0.0% is below required 95.0%

metrics:
current: 0.00
required: 95.00
gap: 95.00

resolution:
# Update this section when addressing the debt
plan: "TBD"
target_date: null
completed_at: null
22 changes: 22 additions & 0 deletions .pmat-tickets/DEBT-SIZE-20260705104033.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# PMAT Legacy Debt Ticket
# Auto-generated by `pmat comply upgrade`
# DO NOT DELETE - Required for Popperian falsification override

ticket_id: "DEBT-SIZE-20260705104033"
category: "file_size"
created_at: "2026-07-05T10:40:33.185755177+00:00"
status: "open"

description: |
7727 file(s) exceed 500 line limit: crates/aprender-contracts-staging/lean/.lake/packages/mathlib/.lake/build/ir/Mathlib/CategoryTheory/SmallRepresentatives.c: 514 lines, crates/aprender-rand/src/tests.rs: 515 lines, crates/aprender-present-terminal/src/ptop/ui/panels/psi.rs: 574 lines, .claude/worktrees/agent-acfe67904858695b9/crates/aprender-orchestrate/src/bug_hunter/model_parity.rs: 532 lines, crates/aprender-contracts-staging/lean/.lake/packages/mathlib/.lake/build/ir/Mathlib/CategoryTheory/Limits/Bicones.c: 1087 lines, .claude/worktrees/agent-acfe67904858695b9/crates/aprender-orchestrate/src/comply/rules/ci_workflow.rs: 655 lines, crates/aprender-contracts-staging/lean/.lake/packages/aesop/.lake/build/ir/Aesop/Script/ScriptM.c: 741 lines, crates/aprender-contracts-staging/lean/.lake/packages/batteries/.lake/build/ir/Batteries/CodeAction/Misc.c: 12782 lines, crates/aprender-serve/tests/cuda_coverage.rs: 1783 lines, crates/aprender-contracts-staging/lean/.lake/packages/mathlib/.lake/build/ir/Mathlib/RingTheory/DedekindDomain/SelmerGroup.c: 665 lines

metrics:
current: 7727.00
required: 0.00
gap: -7727.00

resolution:
# Update this section when addressing the debt
plan: "TBD"
target_date: null
completed_at: null
20 changes: 20 additions & 0 deletions .pmat-work.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[contract]
min_coverage_pct = 95.0
max_tdg_regression = 0.0
max_function_complexity = 20
max_file_lines = 500
min_spec_score = 95

[contract.enforcement]
manifest_integrity = "block"
coverage_gaming = "block"
differential_coverage = "block"
absolute_coverage = "block"
tdg_regression = "block"
complexity_regression = "block"
file_size_regression = "warn"
spec_quality = "block"
roadmap_update = "block"
github_sync = "block"
supply_chain = "block"
meta_check = "block"
2 changes: 1 addition & 1 deletion .pv/lint-previous.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 57 additions & 1 deletion contracts/absolute-position-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ equations:
preconditions:
- indices.iter().all(|&i| i < vocab_size)
- indices.len() > 0
lean_theorem: Theorems.Absolute_Position_Add
lean_theorem: Theorems.AbsolutePosition.Core
sinusoidal_position:
formula: PE(pos, 2i) = sin(pos / 10000^(2i/d)); PE(pos, 2i+1) = cos(pos / 10000^(2i/d))
domain: pos in R, i in {0, ..., d/2 - 1}, d even
codomain: PE(pos, j) in [-1, 1]
invariants:
- -1 <= PE(pos, j) <= 1 for all pos, j (sin/cos range)
- PE(0, 2i) = 0 and PE(0, 2i+1) = 1 (known zero-position value)
- PE(pos+k) is a linear rotation of PE(pos) by angle k*omega(i) (angle addition)
lean_theorem: Theorems.AbsolutePosition.Core
proof_obligations:
- type: invariant
property: Shape preservation
Expand All @@ -36,6 +45,18 @@ proof_obligations:
property: Finite output
formal: is_finite(token_embed[t]) and is_finite(pos_embed[t]) implies is_finite(output[t])
applies_to: all
- type: bound
property: Sinusoidal component bound
formal: -1 <= PE(pos, j) <= 1 for all pos, j (Real.sin/cos range)
applies_to: sinusoidal_position
- type: invariant
property: Zero-position value
formal: PE(0, 2i) = 0 and PE(0, 2i+1) = 1
applies_to: sinusoidal_position
- type: linearity
property: Relative-position rotation
formal: PE(pos+k) = R(k*omega(i)) . PE(pos) — linear rotation via angle addition (sin_add/cos_add)
applies_to: sinusoidal_position
kernel_structure:
phases:
- name: lookup_position_embedding
Expand Down Expand Up @@ -83,6 +104,21 @@ falsification_tests:
prediction: output is finite for all finite inputs
test: proptest with random finite token_embed and pos_embed values
if_fails: Float addition producing NaN or Inf from finite inputs
- id: FALSIFY-AP-005
rule: Sinusoidal component bound
prediction: every PE(pos, j) component lies in [-1, 1]
test: proptest with random pos and dimension index, assert component in [-1, 1]
if_fails: Sinusoidal encoding produces a component outside sin/cos range
- id: FALSIFY-AP-006
rule: Zero-position value
prediction: PE(0, 2i) = 0 and PE(0, 2i+1) = 1
test: proptest over dimension indices at pos = 0, assert even = 0 and odd = 1
if_fails: Zero-position encoding is not (0, 1) per even/odd component
- id: FALSIFY-AP-007
rule: Relative-position rotation
prediction: PE(pos+k) equals the angle-addition rotation of PE(pos) by k*omega(i)
test: proptest with random pos, k, i; assert sin_add/cos_add rotation identity holds
if_fails: Shifted encoding is not a linear rotation of the base encoding
kani_harnesses:
- id: KANI-AP-001
obligation: AP-INV-001
Expand Down Expand Up @@ -129,3 +165,23 @@ qa_gate:
- finite_output
pass_criteria: All 4 falsification tests pass + Kani harnesses verify
falsification: Replace addition with multiplication to break additive identity
verification_summary:
total_obligations: 7
l2_property_tested: 7
l3_kani_proved: 4
l4_lean_proved: 5
l4_sorry_count: 0
l4_not_applicable: 2
# L4 leveling justification (strict per-obligation, proved + N/A == total):
# PROVED in Lean (ProvableContracts.Theorems.AbsolutePosition.Core, sorry-free,
# verified via `lake env lean` exit 0):
# 1. Shape preservation -> abs_add_shape (elementwise, Fin n preserved)
# 2. Additive identity -> abs_add_identity (add_zero)
# 3. Sinusoidal comp. bound -> pe_even_bound / pe_odd_bound (Real.sin/cos in [-1,1])
# 4. Zero-position value -> pe_even_at_zero / pe_odd_at_zero (sin 0 = 0, cos 0 = 1)
# 5. Relative-pos. rotation -> pe_even_rotation / pe_odd_rotation (sin_add/cos_add)
# GENUINELY NOT APPLICABLE (runtime/IEEE — no analytic identity to prove):
# 6. Max position bound -> caller-supplied index precondition, enforced by a
# runtime `assert!(seq_len <= max_pos)`; constrains inputs, not an operation identity.
# 7. Finite output -> IEEE-754 f32 semantics (finite + finite may overflow to Inf);
# vacuous over Real (all reals finite), so no analytic theorem exists.
117 changes: 109 additions & 8 deletions contracts/activation-kernel-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,72 @@ proof_obligations:
- le_max_left
mathlib_imports: []
notes: 'relu(x) = max 0 x ≥ 0 by le_max_left 0 x.'
- type: invariant
property: ReLU idempotent
formal: ReLU(ReLU(x)) = ReLU(x)
applies_to: all
lean:
theorem: Elementwise.relu_idempotent
module: ProvableContracts.Elementwise
status: proved
depends_on:
- relu_nonneg
- relu_of_nonneg
mathlib_imports: []
notes: 'relu output is non-negative (relu_nonneg) and relu is the identity on
non-negative inputs (relu_of_nonneg), so relu(relu x) = relu x.'
- type: invariant
property: Leaky-ReLU identity on non-negative inputs
formal: x ≥ 0 ⟹ LeakyReLU(α, x) = x
applies_to: all
lean:
theorem: Elementwise.leaky_relu_of_nonneg
module: ProvableContracts.Elementwise
status: proved
depends_on: []
mathlib_imports: []
notes: 'leaky_relu(α,x) = if x ≥ 0 then x else α·x; the non-negative branch is the
identity, closed by if_pos. Matches Rust nn::functional::leaky_relu (x>0 ⟹ x).'
- type: invariant
property: Leaky-ReLU negative-slope branch
formal: x < 0 ⟹ LeakyReLU(α, x) = α · x
applies_to: all
lean:
theorem: Elementwise.leaky_relu_of_neg
module: ProvableContracts.Elementwise
status: proved
depends_on: []
mathlib_imports: []
notes: 'leaky_relu(α,x) = if x ≥ 0 then x else α·x; for x < 0 the else-branch gives
α·x, closed by if_neg (not_le.mpr hx).'
- type: bound
property: GELU non-negative on non-negative inputs
formal: x ≥ 0 ⟹ GELU(x) ≥ 0
applies_to: all
lean:
theorem: Gelu.gelu_nonneg_of_nonneg
module: ProvableContracts.Gelu
status: proved
depends_on:
- Real.neg_one_lt_tanh
mathlib_imports:
- Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
notes: 'GELU(x) = 0.5·x·(1 + tanh a); for x ≥ 0 the factor 0.5·x ≥ 0 and 1 + tanh a
> 0 since tanh a > -1 (Real.neg_one_lt_tanh), so the product is ≥ 0.'
- type: bound
property: GELU bounded by identity on non-negative inputs
formal: x ≥ 0 ⟹ GELU(x) ≤ x
applies_to: all
lean:
theorem: Gelu.gelu_le_self_of_nonneg
module: ProvableContracts.Gelu
status: proved
depends_on:
- Real.tanh_lt_one
mathlib_imports:
- Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
notes: 'GELU(x) = 0.5·x·(1 + tanh a); since tanh a < 1 (Real.tanh_lt_one) the factor
1 + tanh a ≤ 2, and 0.5·x·2 = x for x ≥ 0, so GELU(x) ≤ x.'
- type: equivalence
property: SIMD matches scalar
tolerance: 4.0
Expand Down Expand Up @@ -143,6 +209,31 @@ falsification_tests:
prediction: x1 <= x2 => ReLU(x1) <= ReLU(x2)
test: proptest with random x1 <= x2 pairs
if_fails: ReLU implementation not monotonic
- id: FALSIFY-ACT-007
rule: ReLU idempotent
prediction: ReLU(ReLU(x)) == ReLU(x) for all x
test: proptest with random x
if_fails: ReLU not idempotent (double application changes output)
- id: FALSIFY-ACT-008
rule: Leaky-ReLU non-negative branch
prediction: x >= 0 => LeakyReLU(alpha, x) == x
test: proptest with random x >= 0 and random alpha
if_fails: Leaky-ReLU alters non-negative inputs
- id: FALSIFY-ACT-009
rule: Leaky-ReLU negative branch
prediction: x < 0 => LeakyReLU(alpha, x) == alpha * x
test: proptest with random x < 0 and random alpha
if_fails: Leaky-ReLU negative slope not applied
- id: FALSIFY-ACT-010
rule: GELU non-negative on non-negative inputs
prediction: x >= 0 => GELU(x) >= 0
test: proptest with random x >= 0
if_fails: GELU dips below zero for a non-negative input
- id: FALSIFY-ACT-011
rule: GELU bounded by identity on non-negative inputs
prediction: x >= 0 => GELU(x) <= x
test: proptest with random x >= 0
if_fails: GELU exceeds the identity envelope for a non-negative input
kani_harnesses:
- id: KANI-ACT-001
obligation: ACT-INV-001
Expand Down Expand Up @@ -196,18 +287,23 @@ qa_gate:
pass_criteria: All 6 falsification tests pass + Kani verifies ReLU
falsification: Replace max(0,x) with x to break ReLU non-negativity
verification_summary:
total_obligations: 6
total_obligations: 11
l2_property_tested: 6
l3_kani_proved: 2
l4_lean_proved: 4
l4_lean_proved: 9
l4_sorry_count: 0
l4_not_applicable: 1
notes: |
Analytic obligations proved in verified Lean (0 sorry):
- GELU at zero -> Gelu.gelu_zero (0.5·0·(1+tanh …) = 0)
- SiLU at zero -> Sigmoid.silu_zero (0·σ(0) = 0)
- ReLU monotonic -> Elementwise.relu_monotone (max_le_max)
- ReLU non-negative-> Elementwise.relu_nonneg (le_max_left)
- GELU at zero -> Gelu.gelu_zero (0.5·0·(1+tanh …) = 0)
- SiLU at zero -> Sigmoid.silu_zero (0·σ(0) = 0)
- ReLU monotonic -> Elementwise.relu_monotone (max_le_max)
- ReLU non-negative -> Elementwise.relu_nonneg (le_max_left)
- ReLU idempotent (relu∘relu) -> Elementwise.relu_idempotent (relu_of_nonneg ∘ relu_nonneg)
- Leaky-ReLU nonneg branch -> Elementwise.leaky_relu_of_nonneg (if_pos)
- Leaky-ReLU negative branch -> Elementwise.leaky_relu_of_neg (if_neg)
- GELU ≥ 0 for x ≥ 0 -> Gelu.gelu_nonneg_of_nonneg (tanh a > -1)
- GELU ≤ x for x ≥ 0 -> Gelu.gelu_le_self_of_nonneg (tanh a < 1)
Not applicable (runtime/empirical, no algebraic statement):
- SIMD matches scalar (avx2 vs scalar within 4 ULP) -> fast-math ULP
equivalence is a hardware/rounding property, not an algebraic identity.
Expand All @@ -216,8 +312,13 @@ verification_summary:
This is a genuine numerical bound between the tanh approximation and the
exact erf-based GELU; closing it in Lean requires interval/erf bounds we
have not discharged. Honestly left UNPROVEN rather than marked N/A.
Strict leveling: l4_lean_proved(4) + l4_not_applicable(1) = 5 != 6, so this
contract is HONESTLY L3 (not L4) until the GELU approximation bound is proven.
Strict leveling: l4_lean_proved(9) + l4_not_applicable(1) = 10 != 11, so this
contract is HONESTLY L3 (not L4). The sole blocker is the GELU approximation
error bound (hard transcendental / interval reasoning). Every other analytic
obligation — including the wave-3 additions relu∘relu idempotency, both
Leaky-ReLU branches, and the GELU 0 ≤ GELU(x) ≤ x envelope on x ≥ 0 — is
machine-checked in Lean with 0 sorry. A truthful L3 with a hardened analytic
core, not a faked L4.
simd_dispatch:
activation:
scalar: activation_scalar
Expand Down
Loading
Loading