AFTD Auto-Formalizing Theoretical Domains

hamming_weight

def

The Hamming weight of a Boolean vector x is the number of true coordinates.

Statement

def hamming_weight {n : ℕ} (x : Fin n → Bool) : ℕ
Defined in
scout/2611-21910-new-gate-weight-and-wire-complexity-bounds-for-sigmoid-neur.md:713
Verified
18 Nov 2026
Axioms
none listed
Used by 2

Read back from the Lean

hamming_weight defines a function that, given an implicit natural number n and a function x : Fin n → Bool, returns the number of indices i : Fin n for which x i = true (computed as the cardinality of the filtered universal Finset).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

Lean source view module on GitHub

/-- The Hamming weight of a Boolean vector x in {0,1}^n. -/
def hamming_weight {n : ℕ} (x : Fin n → Bool) : ℕ := (Finset.univ.filter (fun i => x i = true)).card
See it in the graphDiscuss this resultChallenge it