One semantic universe #
End-to-end “one semantic universe” tutorial (single graph, many semantics, one checker).
This tutorial lives under NN/Examples/DeepDives because it connects execution, interval semantics,
and checker soundness in one graph.
We build one medium IR graph:
$$ x\mapsto\tanh\!\left(\operatorname{sum} \left(\operatorname{Linear}_2(\operatorname{ReLU}(\operatorname{Linear}_1(x)))\right)\right) $$
and then:
- evaluate it under multiple scalar semantics (
ℝ,FP32,IEEE32Exec); - run IBP under multiple interval semantics (endpoints in
ℝ,FP32,IEEE32Execwith directed rounding); - empirically check that
evalIEEE(G,x)lies in the IBP output box for random $x\in B$; - point to the Lean theorem that the Boolean checker is sound (
Box.containsDecBool_sound).
Notes:
ℝandFP32instantiations are proof-oriented and noncomputable (they typecheck, but do not run as an executable).IEEE32Execis fully executable inside Lean, so we use it for the runnable consistency check.
Run:
lake exe torchlean one_semantic_universe --samples 50
Command-line help for the one-semantics tutorial.
Instances For
- outputWeight : Spec.Tensor α outputWeightShape
Weight matrix for layer 2.
- outputBias : Spec.Tensor α outputBiasShape
Bias for layer 2.
Instances For
def
NN.Examples.DeepDives.OneSemanticUniverse.Params.map
{α β : Type}
(f : α → β)
(p : Params α)
:
Params β
Instances For
Instances For
def
NN.Examples.DeepDives.OneSemanticUniverse.mkParamStore
{α : Type}
[Context α]
(p : Params α)
(xB : MLTheory.CROWN.FlatBox α)
:
Instances For
def
NN.Examples.DeepDives.OneSemanticUniverse.evalOut
{α : Type}
[Context α]
[DecidableEq Spec.Shape]
(p : Params α)
(x : Spec.Tensor α xShape)
:
Instances For
Proof-only instantiations (typechecks) #
These have lines ensure we can interpret the same graph under:
ℝ(reference semantics),FP32(proof-oriented rounding-on-ℝ model),- plus IBP over those endpoint types.
They live in a propositional example, so they do not affect the executable tutorial.
def
NN.Examples.DeepDives.OneSemanticUniverse.xBoxOf
(α : Type)
[Context α]
[TorchLean.Runtime.FromFloat α]
(eps : Float)
:
Instances For
def
NN.Examples.DeepDives.OneSemanticUniverse.toFlatXBox
{α : Type}
[Context α]
(B : MLTheory.CROWN.Box α xShape)
:
Instances For
def
NN.Examples.DeepDives.OneSemanticUniverse.sampleInBoxIEEE
(seed idx : ℕ)
(B : MLTheory.CROWN.Box TorchLean.Floats.IEEE32Exec xShape)
: