Parity decomposition of tree-witness safety (two half-scale problems plus a root condition)
ProvedErdos195.safe_parity_decompA tree witness is a function on the nodes of the binary tree of residues. For distinct integers with , put iff ( is the -th two's-complement binary digit). A finite word of integers is -safe if the completion "the letters of in order, then all remaining integers in -order" contains no monotone -term arithmetic progression (positions of increasing, ). Positions in are first occurrences. For a word let be the subsequence of even letters mapped by , and the subsequence of odd letters mapped by . Let for . Then
where the root condition (R) says: for every pair with odd and before , (i) if occurs after then occurs before ; (ii) if neither nor lies in then is odd exactly when .
This is the exact self-similarity of tree safety: all non-root constraints split into two independent problems of the same kind one binary digit lower (for the two subtrees of ), and the halves interact only through the odd-difference root condition (R). It generalizes the parity decomposition for -orders (the case ).
Formalization note: treeLt, Safe, bitOne from Definitions.Def_Erdos195_tree/Def_Erdos195_defs; positions are List.idxOf; x / 2 is floor division, so it equals on odd .
import Mathlib import Definitions.Def_Erdos195_tree
namespace Erdos195
theorem safe_parity_decomp (θ : ℕ → ℤ → Bool) (Q : List ℤ) :
Safe (treeLt θ) Q ↔
Safe (treeLt (fun k r => θ (k + 1) (2 * r)))
((Q.filter (fun x => decide (x % 2 = 0))).map (· / 2)) ∧
Safe (treeLt (fun k r => θ (k + 1) (2 * r + 1)))
((Q.filter (fun x => decide (x % 2 = 1))).map (· / 2)) ∧
(∀ a b : ℤ, a ∈ Q → b ∈ Q → (b - a) % 2 = 1 → Q.idxOf a < Q.idxOf b →
(2 * b - a ∈ Q → Q.idxOf b < Q.idxOf (2 * b - a) →
3 * b - 2 * a ∈ Q ∧ Q.idxOf (3 * b - 2 * a) < Q.idxOf (2 * b - a)) ∧
(2 * b - a ∉ Q → 3 * b - 2 * a ∉ Q → (θ 0 0 = true ↔ b % 2 = 1))) := by sorry
end Erdos195