AFTD Auto-Formalizing Theoretical Domains

word_block_exchange_is_pure

def

An exchange E = (X, A, B, Y) swaps adjacent pure blocks of opposite sources from mask M if A and B are nonempty, either the slice of M for A is all true and for B is all false or vice versa, and the forward-transported mask has run count mask_u_runs (word_block_exchange_transport_forward E M) = mask_u_runs M - 1.

Statement

def word_block_exchange_is_pure {α : Type*} (E : WordBlockExchange α) (M : List Bool) : Prop
Defined in
arXiv:2610.39941, Section 3 and Section 4
Verified
31 Oct 2026
Axioms
none listed
Built on 4
  • mask_u_runsThe number of maximal nonempty U-runs in a binary mask M is defined by mask_u_runs M = mask_u_runs_aux false M, counting contiguous blocks…
  • word_block_exchange_transport_forwardGiven a block exchange E = (X, A, B, Y) and a binary mask M of type List Bool, word_block_exchange_transport_forward E M is the binary…
  • WordBlockExchangeA word block exchange consists of four words X, A, B, Y over an alphabet.
  • is_pure_maskA binary mask is pure of value b if every element in the mask equals b.

Read back from the Lean

The definition word_block_exchange_is_pure takes an implicit type α, a record E : WordBlockExchange α (having fields X, A, B, Y : List α), and a list of booleans M : List Bool. It defines the proposition asserting that all of the following hold: 1. E.A ≠ [] (the list E.A is non-empty), 2. E.B ≠ [] (the list E.B is non-empty), 3. Either: - every boolean in (M.drop E.X.length).take E.A.length is true, and every boolean in (M.drop (E.X.length + E.A.length)).take E.B.length is false; or - every boolean in (M.drop E.X.length).take E.A.length is false, and every boolean in (M.drop (E.X.length + E.A.length)).take E.B.length is true; 4. mask_u_runs (word_block_exchange_transport_forward E M) = mask_u_runs M - 1 (in ℕ), meaning that the number of maximal runs of true values in the rearranged list M.take E.X.length ++ (M.drop (E.X.length + E.A.length)).take E.B.length ++ (M.drop E.X.length).take E.A.length ++ M.drop (E.X.length + E.A.length + E.B.length) is equal to the number of maximal runs of true values in M minus 1.

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

/-- An exchange swaps adjacent pure blocks A and B from mask M, merging two U-runs. -/
def word_block_exchange_is_pure {α : Type*} (E : WordBlockExchange α) (M : List Bool) : Prop :=
  E.A ≠ [] ∧ E.B ≠ [] ∧
  ((is_pure_mask ((M.drop E.X.length).take E.A.length) true ∧
    is_pure_mask ((M.drop (E.X.length + E.A.length)).take E.B.length) false) ∨
   (is_pure_mask ((M.drop E.X.length).take E.A.length) false ∧
    is_pure_mask ((M.drop (E.X.length + E.A.length)).take E.B.length) true)) ∧
  mask_u_runs (word_block_exchange_transport_forward E M) = mask_u_runs M - 1
See it in the graphDiscuss this resultChallenge it