AFTD Auto-Formalizing Theoretical Domains

majority_three

def

The majority function majority_three : (Fin 3 → Bool) → ℝ maps each x : Fin 3 → Bool to ℝ by returning -1 if ((if x 0 then 1 else 0) + (if x 1 then 1 else 0) + (if x 2 then 1 else 0) : ℕ) ≥ 2, and 1 otherwise.

Statement

def majority_three : (Fin 3 → Bool) → ℝ
Defined in
folklore
Verified
01 Nov 2026
Axioms
none listed
Used by 1

Read back from the Lean

majority_three is defined as a function from Fin 3 → Bool to ℝ that maps an input vector x to -1 if the number of indices in {0, 1, 2} for which x i is true is at least 2 (that is, if (if x 0 then 1 else 0) + (if x 1 then 1 else 0) + (if x 2 then 1 else 0) ≥ 2), and to 1 otherwise.

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 3-bit majority function on Fin 3 -> Bool with values in {-1, 1}. -/
def majority_three : (Fin 3 → Bool) → ℝ := fun x ↦ if ((if x 0 then 1 else 0) + (if x 1 then 1 else 0) + (if x 2 then 1 else 0) : ℕ) ≥ 2 then -1 else 1
See it in the graphDiscuss this resultChallenge it