AFTD Auto-Formalizing Theoretical Domains

relu_network3_encode

def

Encoding of a width-3 ReLU network as a Bool word, of length linear in the total bit length of its rational entries: input weights, input biases, the hidden layers each preceded by true and the list closed by false, output weights, output bias.

Statement

def relu_network3_encode (net : ReLUNetwork 3) : List Bool
Source
Helper encoding serving OP-75 (arXiv:2610.06092, Remark 5.15). Section 2.1 of the paper writes rational entries as pairs of integers in binary; the bit-level layout is a choice made here.
Verified
09 Nov 2026
Axioms
none listed
Built on 5
  • relu_encode_vec3Encoding of a rational vector of length 3 as the concatenation of the encodings of its three entries.
  • relu_encode_ratEncoding of a rational in lowest terms as a Bool word: its numerator and denominator in binary.
  • relu_encode_hidden_layer3Encoding of a width-3 ReLU hidden layer as a Bool word: its 3 by 3 weight matrix row by row, then its bias vector.
  • ReLUNetworkA feedforward ReLU neural network from the real line to the real line with hidden layers of width k, specified by rational affine input…
  • ReLUHiddenLayerA hidden layer of width k consists of a k-by-k rational weight matrix and a rational bias vector of length k.
Used by 8

Lean source view module on GitHub

def relu_network3_encode (net : ReLUNetwork 3) : List Bool :=
  relu_encode_vec3 net.in_weight ++ relu_encode_vec3 net.in_bias ++
    (net.layers.flatMap (fun l => true :: relu_encode_hidden_layer3 l) ++ [false]) ++
    relu_encode_vec3 net.out_weight ++ relu_encode_rat net.out_bias
See it in the graphDiscuss this resultChallenge it