One semantic universe #
End-to-end “one semantic universe” tutorial (single graph, many semantics, one checker).
This tutorial is intentionally not part of the beginner training tutorials; it lives under
NN/Examples/Advanced.
We build one medium IR graph:
x ↦ tanh(sum(Linear2(ReLU(Linear1(x)))))
and then:
- evaluate it under multiple scalar semantics (
ℝ,FP32,IEEE32Exec); - run IBP under multiple interval semantics (endpoints in
ℝ,FP32,IEEE32Execwith directed rounding); - empirically sanity-check that
evalIEEE(G,x)lies in the IBP output box for randomx ∈ 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 sanity check.
Run:
lake exe torchlean one_semantic_universe --samples 50
- W1 : Spec.Tensor α W1Shape
Weight matrix for layer 1.
- b1 : Spec.Tensor α b1Shape
Bias for layer 1.
- W2 : Spec.Tensor α W2Shape
Weight matrix for layer 2.
- b2 : Spec.Tensor α b2Shape
Bias for layer 2.
Instances For
def
NN.Examples.Advanced.OneSemanticUniverse.Params.map
{α β : Type}
(f : α → β)
(p : Params α)
:
Params β
Instances For
Instances For
def
NN.Examples.Advanced.OneSemanticUniverse.mkParamStore
{α : Type}
[Context α]
(p : Params α)
(xB : MLTheory.CROWN.FlatBox α)
:
Instances For
def
NN.Examples.Advanced.OneSemanticUniverse.evalOut
{α : Type}
[Context α]
[Inhabited α]
[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.Advanced.OneSemanticUniverse.xBoxOf
(α : Type)
[API.Semantics.Scalar α]
[API.Runtime.Scalar α]
(eps : Float)
:
Instances For
def
NN.Examples.Advanced.OneSemanticUniverse.toFlatXBox
{α : Type}
[Context α]
(B : MLTheory.CROWN.Box α xShape)
:
Instances For
def
NN.Examples.Advanced.OneSemanticUniverse.sampleInBoxIEEE
(seed idx : ℕ)
(B : MLTheory.CROWN.Box TorchLean.Floats.IEEE32Exec xShape)
: