AFTD Auto-Formalizing Theoretical Domains

thr_to_lin

def

The translation ⟨f ≥ s⟩ of a threshold condition to a linear inequality over plain Boolean variables, obtained by substituting ~x_i = 1 - x_i.

Statement

def thr_to_lin {n : ℕ} (T : ThrCond n) : LinIneq n
Defined in
arXiv:2611.24548 Section 4.1
Verified
19 Nov 2026
Axioms
none listed
Built on 3
  • ThrCondA threshold condition over n Boolean variables is an inequality f ≥ s, where f is a nonnegative integer linear combination of literals…
  • LinIneqA linear inequality c^T x ≥ d over n Boolean variables, with integer coefficient vector c : Fin n → ℤ and integer constant term d : ℤ.
  • CnfLitA CNF literal over a variable type V is either a positive variable or a negated variable.

Read back from the Lean

Given a natural number n and a threshold condition T on n variables (ThrCond n), thr_to_lin defines a linear inequality (LinIneq n) where: 1. The coefficient assigned to each variable i : Fin n is the integer difference (T.coeffs (CnfLit.pos i) : ℤ) - (T.coeffs (CnfLit.neg i) : ℤ); 2. The constant term is T.threshold - ∑ i : Fin n, (T.coeffs (CnfLit.neg i) : ℤ).

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 translation ⟨f ≥ s⟩ of a threshold condition to a linear inequality by replacing ~x_i with 1 - x_i. -/
def thr_to_lin {n : ℕ} (T : ThrCond n) : LinIneq n :=
  ⟨fun i => (T.coeffs (CnfLit.pos i) : ℤ) - (T.coeffs (CnfLit.neg i) : ℤ),
   T.threshold - ∑ i : Fin n, (T.coeffs (CnfLit.neg i) : ℤ)⟩
See it in the graphDiscuss this resultChallenge it