mirror of
https://github.com/zooai/proofs.git
synced 2026-10-30 14:49:47 +00:00
The lean/ proof library (88 files) had ~180 type-check errors across ~45 files plus 31 proof-by-assumption axiom cheats. It now type-checks cleanly under Lean 4.14.0 + Mathlib, with every theorem genuinely proven from definitions. Errors fixed: - Stale Mathlib imports: Data.Nat.Basic / Data.Int.Basic were removed this rev -> Data.Nat.Defs / Data.Int.Defs (57 files). - Shared AI/Agent/Governance/Contract/DeFi/Ecology draft files: same proof-rot as the zoo-labs sibling library (now reconciled): omega missing in-scope bounds, dead tactics after simp, simp over-reduction, doc-comment placement, reserved-word binders, deriving Repr on Finset-bearing structs, noncomputable defs over opaque primitives. - Consensus/Liveness: collapsed a 74-error cascade (undefined shared state model inlined from Safety.lean; the |>. pipe-projection vs comparison parse trap on 14 lines rewritten to explicit dot projection). - Crypto (BLS/FROST/Corona/Hybrid/threshold/FHE), Consensus, Protocol, Warp, Trust, GPU, Compute, Network, DeFi: brought structure invariants into scope for omega, Nat-division bounds via Nat.div_le_of_le_mul / Nat.div_mul_le_self, noncomputable over opaque crypto ops, deriving Inhabited for index access. Integrity: - Removed all 31 `theorem X := X_ax` cheats (axiom asserting the identical statement) and proved each from definitions; removed the UNSOUND content_addressed axiom (hash-injectivity over a struct with free fields). - Quorum-intersection theorems (BFT/Quasar/Flare/Warp/BLS/GPU/Bridge): the draft hypothesis 3f<n is insufficient (n unbounded above makes them false); tightened to the optimal-resilience invariant n=3f+1 / 2t>n. Statement intent preserved. - Net axiom change: -35 / +1 (the one addition, honesty_static, is a fixed-validator-set modeling assumption matching sibling files). - Remaining axioms are trusted-base only: opaque crypto primitives (groups, pairings, hardness, hashes, FHE encrypt/decrypt, BLS soundness, forward secrecy, Fisher-Yates uniformity) and protocol modeling assumptions. No sorry/admit/native_decide. Verified all theorems trace to [propext, Classical.choice, Quot.sound] plus those primitives. Co-authored-by: Hanzo Dev <[email protected]>
70 lines
2.1 KiB
Lean4
70 lines
2.1 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zach Kelling
|
|
|
|
Embedding Correctness (7680-dimensional)
|
|
|
|
Vector embeddings for semantic search and RAG.
|
|
Zoo uses 7680-dimensional embeddings for maximum resolution.
|
|
|
|
Maps to:
|
|
- zoo/papers/embedding-7680.tex: embedding specification
|
|
- hanzo/engine: embedding inference
|
|
- zoo/node: embedding storage
|
|
|
|
Properties:
|
|
- Dimensionality: 7680 dimensions (highest resolution)
|
|
- Normalization: unit-length vectors for cosine similarity
|
|
- Determinism: same input → same embedding
|
|
- Batching: batch embeddings preserve individual results
|
|
|
|
Author: Zach Kelling
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Data.List.Basic
|
|
import Mathlib.Tactic
|
|
|
|
namespace AI.Embedding
|
|
|
|
def standardDim : Nat := 7680
|
|
|
|
structure EmbeddingVector where
|
|
dim : Nat
|
|
hash : Nat -- content hash of the vector
|
|
normalized : Bool -- unit length for cosine sim
|
|
|
|
axiom embed : Nat → EmbeddingVector
|
|
axiom embed_deterministic : ∀ (input : Nat), embed input = embed input
|
|
|
|
/-- DIMENSIONALITY: Standard embedding is 7680-dim -/
|
|
axiom embed_dim : ∀ (input : Nat), (embed input).dim = standardDim
|
|
|
|
theorem dim_is_7680 : standardDim = 7680 := rfl
|
|
|
|
/-- NORMALIZATION: Embeddings are unit-length -/
|
|
axiom embed_normalized : ∀ (input : Nat), (embed input).normalized = true
|
|
|
|
/-- DETERMINISM: Same input always produces same vector -/
|
|
theorem deterministic (input : Nat) :
|
|
embed input = embed input := rfl
|
|
|
|
/-- BATCH: Batch embedding = individual embeddings -/
|
|
noncomputable def batchEmbed (inputs : List Nat) : List EmbeddingVector :=
|
|
inputs.map embed
|
|
|
|
theorem batch_length (inputs : List Nat) :
|
|
(batchEmbed inputs).length = inputs.length := by
|
|
simp [batchEmbed]
|
|
|
|
theorem batch_preserves (inputs : List Nat) (i : Fin inputs.length) :
|
|
(batchEmbed inputs)[i]'(by simp [batchEmbed, i.isLt]) = embed inputs[i] := by
|
|
simp [batchEmbed, List.getElem_map]
|
|
|
|
/-- 7680 > 1536 (OpenAI ada-002) -/
|
|
theorem higher_resolution : standardDim > 1536 := by simp [standardDim]
|
|
|
|
/-- 7680 > 3072 (OpenAI text-embedding-3-large) -/
|
|
theorem higher_than_openai : standardDim > 3072 := by simp [standardDim]
|
|
|
|
end AI.Embedding
|