interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / bootstrap / formal-oracles / lean / MutantKvModels.lean

32 lines · 1587 bytes Raw Blame History
1import AienKv.Corpus
2/-!
3# Deliberate mutants of the KV layout (each must break one required rule)
4
5WRONG on purpose. Each mutant model compiles; the matching claim file must not.
6-/
7namespace AienKv
8
9/-- MUTANT 1 (kv_planes_overlap): layer stride is one plane, so the V plane starts inside the next layer. -/
10def Cfg.layerM1 (c : Cfg) : Nat := c.plane
11
12/-- MUTANT 2 (total_one_block_short): the allocation is one block too small. -/
13def Cfg.totalM2 (c : Cfg) : Nat := c.numBlocks * c.block - c.block
14
15/-- MUTANT 3 (token_stride_forgets_element_size): token stride = heads * dim, not heads * dim * bytes. -/
16def Cfg.tokenM3 (c : Cfg) : Nat := c.numKvHeads * c.headDim
17
18/-- MUTANT 4 (validity_off_by_one): the K/V selector is allowed to be 0, 1 or 2. -/
19def Cfg.ValidM4 (c : Cfg) (b l v t h d : Nat) : Prop :=
20 b < c.numBlocks ∧ l < c.numLayers ∧ v < 3 ∧ t < c.blockSize ∧ h < c.numKvHeads ∧ d < c.headDim
21
22/-- MUTANT 5 (block_stride_short): consecutive blocks are placed one byte too close. -/
23def Cfg.blockStrideM5 (c : Cfg) : Nat := c.block - 1
24
25theorem m1_witness : (tiny 4).plane = (tiny 4).layerM1 ∧ (tiny 4).layerM1 < 2 * (tiny 4).plane := by decide
26theorem m2_witness : (tiny 4).totalM2 < (tiny 4).block * 4 := by decide
27theorem m3_witness : (tiny 4).tokenM3 < (tiny 4).head * 4 := by decide
28theorem m4_witness : (tiny 4).off 0 0 2 0 0 0 + 4 ≤ (tiny 4).total ∧ ¬ (tiny 4).Valid 0 0 2 0 0 0 := by
29 refine ⟨by decide, ?_⟩; unfold Cfg.Valid; decide
30theorem m5_witness : 1 * (tiny 4).blockStrideM5 + (tiny 4).block > 1 * (tiny 4).block := by decide
31
32end AienKv