AFTD Auto-Formalizing Theoretical Domains

is_bidirectional_ballot

def

A finite set of integers $E$ is a bidirectional ballot set in $[0, h-1]$ if $E \subseteq [0, h-1]$ and for every integer $q \in [1, h]$, $q < 2 |E \cap [0, q-1]|$ and $q < 2 |E \cap [h-q, h-1]|$ (that is, both the prefix and suffix intersections of length $q$ have cardinality strictly greater than $q/2$).

Statement

def is_bidirectional_ballot (h : ℤ) (E : Finset ℤ) : Prop
Defined in
arXiv:2611.23338, Definition 2.3
Verified
19 Nov 2026
Axioms
none listed
Built on 2
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…

Read back from the Lean

A predicate on an integer $h$ and a finite set of integers $E$ asserting that: 1. $E$ is a subset of the closed interval of integers $[0, h - 1]$ (i.e., every element $x \in E$ satisfies $0 \le x \le h - 1$), and 2. For every integer $q$ such that $1 \le q \le h$: - $q < 2 \cdot \#(E \cap [0, q - 1])$ (strictly more than half of the elements in $[0, q - 1]$ belong to $E$), and - $q < 2 \cdot \#(E \cap [h - q, h - 1])$ (strictly more than half of the elements in $[h - q, h - 1]$ belong to $E$).

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

/-- A finite set of integers in [0, h-1] is a bidirectional ballot set if every nonempty prefix and suffix contains strictly more than half the elements. -/
def is_bidirectional_ballot (h : ℤ) (E : Finset ℤ) : Prop :=
  E ⊆ Finset.Icc 0 (h - 1) ∧
  ∀ q : ℤ, 1 ≤ q → q ≤ h →
    q < 2 * ((E ∩ Finset.Icc 0 (q - 1)).card : ℤ) ∧
    q < 2 * ((E ∩ Finset.Icc (h - q) (h - 1)).card : ℤ)
See it in the graphDiscuss this resultChallenge it