Lean 4 formalization of the decision tree + MLP ensemble architecture. Axiomatizes Float properties (sigmoid bounds, ReLU nonnegativity) since Lean's Float ops are extern-backed. Proves MLP output is bounded in (0,1) and ensemble output is always a valid decision. No mathlib dependency. Signed-off-by: Sienna Meridian Satterwhite <sienna@sunbeam.pt>
26 lines
718 B
Lean4
26 lines
718 B
Lean4
namespace Sunbeam
|
||
|
||
/-- Decisions that a model component can output. -/
|
||
inductive Decision where
|
||
| block : Decision
|
||
| allow : Decision
|
||
| defer : Decision
|
||
deriving Repr, DecidableEq
|
||
|
||
/-- A fixed-size vector of floats. -/
|
||
def FloatVec (n : Nat) := Fin n → Float
|
||
|
||
/-- Dot product of two float vectors. -/
|
||
def dot {n : Nat} (a b : FloatVec n) : Float :=
|
||
(List.finRange n).foldl (fun acc i => acc + a i * b i) 0.0
|
||
|
||
/-- Matrix-vector product. Matrix is row-major: m rows × n cols. -/
|
||
def matVecMul {m n : Nat} (mat : Fin m → FloatVec n) (v : FloatVec n) : FloatVec m :=
|
||
fun i => dot (mat i) v
|
||
|
||
/-- Vector addition. -/
|
||
def vecAdd {n : Nat} (a b : FloatVec n) : FloatVec n :=
|
||
fun i => a i + b i
|
||
|
||
end Sunbeam
|