Neural Network: sineNet #
This file demonstrates end-to-end verified ML:
- A neural network was trained in PyTorch to approximate sin(x)
- Weights were exported as exact rational numbers
- We formally verify output bounds using interval arithmetic
Key Point: Formal Verification vs Testing #
Unlike testing (which checks finitely many points), formal verification proves properties for ALL inputs in a region. This is a mathematical proof covering infinitely many inputs - not sampling.
Architecture #
- Input: 1 dimensions
- Hidden: 16 neurons with ReLU activation
- Output: 1 dimensions
Training Results #
- Max approximation error: 0.031652
Verification #
This file provides formal verification that the network output is bounded for all inputs in the specified domain.
Layer 1: 1 → 16
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Layer 2: 16 → 1
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
The sineNet network
Equations
Instances For
Well-formedness Proofs #
Input Domain and Output Bounds #
Helper to create dyadic interval
Equations
- LeanCert.Examples.ML.SineApprox.mkInterval lo hi h prec = LeanCert.Core.IntervalDyadic.ofIntervalRat { lo := lo, hi := hi, le := h } prec
Instances For
Computed output bounds for the entire input domain
Equations
Instances For
Main Verification Theorem #
Main Theorem: For any x in [0, π], the network output is bounded.
This is a formal verification certificate proving that the trained neural network's output lies within computed bounds for ALL inputs in the domain.
Unlike testing (which checks finitely many points), this is a mathematical proof covering infinitely many inputs.
What This Proves #
The theorem output_bounded establishes:
For every real number x with 0 ≤ x ≤ π: The neural network output is contained in the computed interval bounds.
This is verified by Lean's proof checker - a mathematical certainty, not empirical testing.
Applications #
- Safety certification: Prove controller outputs stay in safe range
- Adversarial robustness: Bound how much outputs can change
- Regulatory compliance: Provide formal guarantees for ML systems