AFTD Auto-Formalizing Theoretical Domains

rat_segment_list_code

def

The binary word encoding a list S of plane segments, each given by two endpoints ((x1, y1), (x2, y2)) with rational coordinates: the length of S in nat_self_delimiting_code, followed, for each segment of S in order, by the codes rat_self_delimiting_code of x1, y1, x2, y2 in this order.

Statement

def rat_segment_list_code (S : List ((ℚ × ℚ) × (ℚ × ℚ))) : List Bool
Source
Input/output encoding, helper for the polynomial-time statement of OP-2019 (arXiv:2611.24611 (Inapproximability of Euclidean Steiner Tree), Section 6.1, after Corollary 20 (open question: is planar Euclidean Cable Steiner Tree APX-hard or does it admit a PTAS?)).
Verified
23 Nov 2026
Axioms
none listed
Built on 2
  • 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…
  • 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…
Used by 1
  • cable_instance_codeThe binary word encoding an instance of planar cable Steiner tree given as a list I of cables, each cable a list of segments with rational…

Lean source view module on GitHub

/-- The binary code of a finite list of plane segments with rational endpoints ((x₁, y₁), (x₂, y₂)): the length of the list, then the four coordinates of each segment in order. -/
def rat_segment_list_code (S : List ((ℚ × ℚ) × (ℚ × ℚ))) : List Bool :=
  nat_self_delimiting_code S.length ++
    S.flatMap (fun s => rat_self_delimiting_code s.1.1 ++ rat_self_delimiting_code s.1.2 ++
      rat_self_delimiting_code s.2.1 ++ rat_self_delimiting_code s.2.2)
See it in the graphDiscuss this resultChallenge it