AFTD Auto-Formalizing Theoretical Domains

ks2_instance_code

def

With explicit arguments α : ℚ, d : ℕ and vs : List (ℚ × List (ℚ × ℚ)), in this order: the Bool word (List Bool) that is the concatenation of nat_self_delimiting_code d, then rat_self_delimiting_code α, then nat_self_delimiting_code of the length of vs, then, for each entry (t, w) of vs in order (List.flatMap): rat_self_delimiting_code t, nat_self_delimiting_code of the length of w, and for each pair (a, b) of w in order (List.flatMap) rat_self_delimiting_code a followed by rat_self_delimiting_code b.

Statement

def ks2_instance_code (α : ℚ) (d : ℕ) (vs : List (ℚ × List (ℚ × ℚ))) : List Bool
Defined in
arXiv:2611.27740, Problem 1.1: binary encoding of an instance (alpha, d, v_1..v_m). Encoding choice (the paper fixes none): an input vector is given by a pair (t, w), t a rational and w a list of pairs of rationals, and stands for sqrt(t) times the vector with Gaussian-rational coordinates a_j + b_j i; this covers the paper's reduction, whose vectors are sqrt(alpha_r / q_v) times sign vectors.
Verified
26 Nov 2026
Axioms
none listed
Built on 2
  • rat_self_delimiting_codeThe binary word encoding a rational number q: the bit true if q < 0 and false otherwise, followed by the self-delimiting code…
  • nat_self_delimiting_codeThe self-delimiting binary code of a natural number m: each bit b of the binary expansion of m (least significant bit first, as in…
Used by 2
  • ks2_distinct_outer_languageWith explicit argument c : ℝ, the language over Bool (Language Bool, a set of words List Bool) of all words w for which there exist α : ℚ,…
  • ks2_distinct_languageWith explicit argument c : ℝ, the language over Bool (Language Bool, a set of words List Bool) of all words w for which there exist α : ℚ,…

Read back from the Lean

ks2_instance_code is a definition that takes a rational number α : ℚ, a natural number d : ℕ, and a list vs : List (ℚ × List (ℚ × ℚ)) (where each element of vs is a pair consisting of a rational number and a list of pairs of rational numbers), and returns a List Bool formed by concatenating: 1. The self-delimiting code of d (nat_self_delimiting_code d), 2. The self-delimiting code of α (rat_self_delimiting_code α), 3. The self-delimiting code of the length of vs (nat_self_delimiting_code vs.length), 4. For each element p = (p.1, p.2) in vs (in list order): - The self-delimiting code of p.1 (rat_self_delimiting_code p.1), - The self-delimiting code of the length of p.2 (nat_self_delimiting_code p.2.length), - For each element z = (z.1, z.2) in p.2 (in list order): - The self-delimiting code of z.1 (rat_self_delimiting_code z.1), - Followed by the self-delimiting code of z.2 (rat_self_delimiting_code z.2). Note that d is encoded before α, despite α appearing first in the parameter list.

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 binary word encoding an instance `(α, d, vs)` of the algorithmic Kadison-Singer problem. -/
def ks2_instance_code (α : ℚ) (d : ℕ) (vs : List (ℚ × List (ℚ × ℚ))) : List Bool :=
  nat_self_delimiting_code d ++ rat_self_delimiting_code α ++
    nat_self_delimiting_code vs.length ++
    vs.flatMap (fun p => rat_self_delimiting_code p.1 ++ nat_self_delimiting_code p.2.length ++
      p.2.flatMap (fun z => rat_self_delimiting_code z.1 ++ rat_self_delimiting_code z.2))
See it in the graphDiscuss this resultChallenge it