AFTD Auto-Formalizing Theoretical Domains

op2130_decision_list_conditional_variation

theoremverified

For an odd number N of fair bits, the signed alternating OR/AND decision list has pathwise conditional-mean quadratic variation at least (N-2)/4 on the tape that takes the non-deciding branch at every gate.

Statement

theorem op2130_decision_list_conditional_variation (N : ℕ) (hN : 3 ≤ N) (hodd : N % 2 = 1) : let X : (Fin N → Bool) → ℝ := fun r => if op2130_outer_decision false (List.ofFn r) then -1 else 1; let Q : ℕ → (Fin N → Bool) → ℝ := fun t a => (∑ b : Fin N → Bool, if ∀ i : Fin N, i.val < t → b i = a i then X b else 0) / (2 : ℝ) ^ (N-t); let r : Fin N → Bool := fun i => i.val % 2 == 1; ((N : ℝ)-2)/4 ≤ ∑ t ∈ Finset.range N, (Q (t+1) r - Q t r) ^ 2
Source
OP-2130, fair-bit alternating decision-list martingale
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • op2130_variation_sum_lowerIf n real martingale increments each have magnitude at least one half, their squared sum is at least n/4. The helper theorems give the…
  • cFor a group $G$ and an element $s \in G$, the local count $c_G(s)$ is the cardinality of the set of elements $g \in G$ such that…

The proof, explained

The proof establishes that for an alternating OR/AND decision list on an odd number N of bits, the conditional expectation process along the all-non-deciding tape r exhibits quadratic variation at least (N - 2)/4. It first identifies the conditional expectation Q(t, r) with the recursively defined mean op2130_nondecd_mean, which reduces after t non-deciding steps to an unconditional expectation of length N - t with alternating gate polarities. Coupled recurrence relations show that every single-step increment has absolute value at least 1/2, so each squared increment is at least 1/4, yielding a total quadratic variation of at least N/4 ≥ (N - 2)/4.

  1. A sum over all boolean tapes of length n + 1 decomposes into the sum over length-n tapes of the evaluations on false-prepended and true-prepended tapes.

    The equivalence Fin.consEquiv identifies maps on Fin (n + 1) with pairs of a head bit and a tail map on Fin n. Summing over the product type and evaluating the boolean head bit decomposes the total sum into the sum of values with head false plus the sum with head true.

    lines 11–17

    uses Fin.consEquiv_apply, Fintype.sum_prod_type, Fintype.sum_bool, Finset.sum_add_distrib

      classical
      calc
        (∑ r, f r) = ∑ p : Bool × (Fin n → Bool), f ((Fin.consEquiv fun _ => Bool) p) :=
          ((Fin.consEquiv fun _ => Bool).sum_comp f).symm
        _ = _ := by
          simp only [Fintype.sum_prod_type, Fintype.sum_bool, Fin.consEquiv_apply, Finset.sum_add_distrib]
          ac_rfl
  2. Shifting the index of the non-deciding bit sequence by 1 toggles the starting polarity: op2130_nondecd_bit v (i + 1) = op2130_nondecd_bit (!v) i.

    By cases on the parity of i. If i is even, i + 1 is odd, so the left side is !v and the right side at even index i is !v. If i is odd, i + 1 is even, so the left side is v and the right side is !(!v) = v.

    lines 33–37

    uses op2130_nondecd_bit

      by_cases h : i%2=0
      · have hs : (i+1)%2 ≠ 0 := by omega
        simp [op2130_nondecd_bit,h,hs]
      · have hs : (i+1)%2 = 0 := by omega
        cases v <;> simp [op2130_nondecd_bit,h,hs]
  3. A tape of length n + 1 has a non-deciding prefix of length t + 1 starting in mode v iff its first bit is v and its tail has a non-deciding prefix of length t starting in mode !v.

    In the forward direction, evaluating the prefix condition at index 0 forces the first bit to be v, and evaluating at index i + 1 combined with index shifting gives the condition on the tail. In the reverse direction, any index of Fin (n + 1) is either 0 or a successor, both of which satisfy the non-deciding bit condition by hypothesis and index shifting.

    lines 42–56

    uses op2130_nondecd_bit, op2130_nondecd_bit_succ, Fin.cases

      constructor
      · intro h
        constructor
        · have hh := h 0 (by simp)
          simpa [op2130_nondecd_bit] using hh
        · intro i hi
          have hh := h i.succ (by simp only [Fin.val_succ]; omega)
          simpa only [Fin.val_succ,op2130_nondecd_bit_succ] using hh
      · rintro ⟨h0,ht⟩
        intro i
        refine Fin.cases ?_ ?_ i
        · intro _; simpa [op2130_nondecd_bit] using h0
        · intro j hj
          have hh := ht j (by simp only [Fin.val_succ] at hj; omega)
          simpa only [Fin.val_succ,op2130_nondecd_bit_succ] using hh
  4. Summing a payoff on length-(n + 1) tapes with a non-deciding prefix of length t + 1 equals summing on length-n tapes with prefix length t and inverted gate polarity !v.

    Splitting the tape sum on the first bit via op2130_logical_sum_bool_tapes_succ, the prefix condition forces the first bit to equal v. The deciding branch vanishes from the prefix requirement, leaving the non-deciding branch evaluated on the tail under inverted polarity !v and prefix length t.

    lines 59–68

    uses op2130_logical_sum_bool_tapes_succ, Finset.sum_congr, op2130_nondecd_prefix_succ, List.ofFn_succ, op2130_logical_count_decision

        (by classical exact (∑ r : Fin (n+1) → Bool,
          if op2130_nondecd_prefix v (t+1) r then f (op2130_logical_count_decision v (List.ofFn r)) else 0) =
        (∑ r : Fin n → Bool,
          if op2130_nondecd_prefix (!v) t r then f (op2130_logical_count_decision (!v) (List.ofFn r)) else 0)) := by
      classical
      rw [op2130_logical_sum_bool_tapes_succ]
      apply Finset.sum_congr rfl
      intro r hr
      rw [op2130_nondecd_prefix_succ,op2130_nondecd_prefix_succ]
      cases v <;> simp [List.ofFn_succ,op2130_logical_count_decision]
  5. The mean signed payoffs satisfy the coupled recurrence relations: op2130_sign_mean true (n + 1) = (1 + op2130_sign_mean false n) / 2 and op2130_sign_mean false (n + 1) = (-1 + op2130_sign_mean true n) / 2.

    Expanding the definition of op2130_sign_mean and splitting tapes on the first bit, at an AND gate (mode true) a false bit immediately outputs false (payoff +1 on all 2^n continuations), while a true bit continues to an OR gate (mode false) on the remaining n bits. Symmetrically, at an OR gate (mode false) a true bit immediately outputs true (payoff -1), while a false bit continues to an AND gate. Dividing by 2^(n + 1) yields the recurrence.

    lines 76–101

    uses op2130_sign_mean, op2130_logical_sum_bool_tapes_succ, pow_succ, pow_ne_zero

      constructor
      · unfold op2130_sign_mean
        rw [op2130_logical_sum_bool_tapes_succ]
        simp only [List.ofFn_succ, Fin.cons_zero, Fin.cons_succ, op2130_logical_count_decision,
          Bool.false_and, Bool.true_and, Bool.false_eq_true, ↓reduceIte, Finset.sum_add_distrib]
        simp only [Finset.sum_const_zero, zero_add, Finset.sum_const, Finset.card_univ,
          Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul]
        rw [pow_succ]
        have hn : (2:ℝ)^n ≠ 0 := pow_ne_zero _ (by norm_num)
        field_simp
        push_cast
        ring
      · unfold op2130_sign_mean
        rw [op2130_logical_sum_bool_tapes_succ]
        simp only [List.ofFn_succ, Fin.cons_zero, Fin.cons_succ, op2130_logical_count_decision,
          Bool.false_or, Bool.true_or, ↓reduceIte, Finset.sum_add_distrib, if_true]
        try simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fun,
          Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul]
        rw [pow_succ]
        have hn : (2:ℝ)^n ≠ 0 := pow_ne_zero _ (by norm_num)
        field_simp
        push_cast
        simp only [if_true, Finset.sum_const, Finset.card_univ, Fintype.card_fun,
          Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul]
        push_cast
        ring
  6. Define op2130_nondecd_mean as the average signed payoff over tapes of length n sharing the non-deciding prefix of length t.

    The definition sums the signed payoff over tapes satisfying op2130_nondecd_prefix v t r and normalizes by 2^(n - t), the number of free completions of a length-t prefix.

    lines 104–107

    uses op2130_nondecd_prefix, op2130_logical_count_decision

      classical
      exact (∑ r : Fin n → Bool,
        if op2130_nondecd_prefix v t r then
          (if op2130_logical_count_decision v (List.ofFn r) then (-1:ℝ) else 1) else 0) / (2:ℝ)^(n-t)
  7. The non-deciding conditional mean satisfies op2130_nondecd_mean v (n + 1) (t + 1) = op2130_nondecd_mean (!v) n t.

    Applying op2130_decision_prefix_sum_succ rewrites the numerator sum over length-(n + 1) tapes to that over length-n tapes with inverted mode !v, while the denominator 2^((n + 1) - (t + 1)) = 2^(n - t) remains identical.

    lines 111–115

    uses op2130_nondecd_mean, op2130_decision_prefix_sum_succ

      classical
      unfold op2130_nondecd_mean
      have hh := op2130_decision_prefix_sum_succ n t v (fun b => if b then (-1:ℝ) else 1)
      rw [show n+1-(t+1)=n-t by omega]
      congr 1
  8. Conditioned on a non-deciding prefix of length t, the mean payoff on n + t bits reduces to the unconditional sign mean on the remaining n bits: op2130_nondecd_mean v (n + t) t = op2130_sign_mean (op2130_toggle v t) n.

    By induction on t. For t = 0, a prefix of length 0 imposes no restrictions, so the conditional mean is identically the unconditional mean. For the inductive step, op2130_nondecd_mean_succ strips one prefix bit and inverts the gate polarity, matching op2130_toggle.

    lines 123–130

    uses op2130_nondecd_mean, op2130_sign_mean, op2130_nondecd_prefix, op2130_toggle, op2130_nondecd_mean_succ

      induction t generalizing v with
      | zero =>
          classical
          simp [op2130_nondecd_mean,op2130_sign_mean,op2130_nondecd_prefix,op2130_toggle]
          congr 1
      | succ t ih =>
          rw [show n+(t+1) = (n+t)+1 by omega, op2130_nondecd_mean_succ]
          simpa only [op2130_toggle] using ih (!v)
  9. For all n, the sign means lie in [-1, 1], with op2130_sign_mean true n ≥ 0, and op2130_sign_mean false n ≤ 0 whenever n > 0.

    By induction on n. At n = 0, both values equal 1. For n + 1, the bounds follow directly from the coupled recurrence relations via linear arithmetic using the induction hypotheses.

    lines 136–146

    uses op2130_sign_mean, op2130_logical_count_decision, op2130_sign_mean_recurrence

      induction n with
      | zero =>
          have he : ∀ r : Fin 0 → Bool, List.ofFn r = [] := by intro r; simp
          simp [op2130_sign_mean,he,op2130_logical_count_decision]
      | succ n ih =>
          have hr := op2130_sign_mean_recurrence n
          rcases ih with ⟨a,b,c,d,e,f⟩
          rw [hr.1,hr.2]
          refine ⟨?_,?_,?_,?_,?_,?_⟩ <;> try linarith
          intro _
          linarith
  10. Toggling a boolean starting polarity t times leaves it unchanged if t is even, and inverts it if t is odd.

    By induction on t. The base case t = 0 is immediate. For t + 1, the induction hypothesis inverts v according to the parity of t, and parity arithmetic flips whether t + 1 is even or odd.

    lines 150–158

    uses op2130_toggle

      induction t generalizing v with
      | zero => simp [op2130_toggle]
      | succ t ih =>
          simp only [op2130_toggle, ih]
          by_cases ht : t%2=0
          · have hs : (t+1)%2 ≠ 0 := by omega
            cases v <;> simp [ht,hs]
          · have hs : (t+1)%2=0 := by omega
            cases v <;> simp [ht,hs]
  11. Along the non-deciding path on N bits with N odd, each conditional mean increment has absolute value at least 1/2.

    Let n = N - (t + 1). By op2130_nondecd_mean_strip, the difference rewrites in terms of op2130_sign_mean at lengths n and n + 1. If t is even, the difference reduces to (1 + op2130_sign_mean true n) / 2 ≥ 1/2 because op2130_sign_mean true n ≥ 0. If t is odd, since N is odd, n = N - (t + 1) is odd and hence positive; the difference reduces to (1 - op2130_sign_mean false n) / 2 ≥ 1/2 because op2130_sign_mean false n ≤ 0.

    lines 162–186

    uses op2130_nondecd_mean_strip, op2130_toggle_eq, op2130_sign_mean_recurrence, op2130_sign_mean_bounds, abs_of_nonneg, abs_of_nonpos

      let n := N-(t+1)
      have hN : N = n+(t+1) := by dsimp [n]; omega
      have hn1 : N = (n+1)+t := by omega
      have qbefore := op2130_nondecd_mean_strip false (n+1) t
      have qafter := op2130_nondecd_mean_strip false n (t+1)
      rw [← hn1] at qbefore
      rw [← hN] at qafter
      rw [qbefore,qafter]
      rw [op2130_toggle_eq,op2130_toggle_eq]
      by_cases he : t%2=0
      · have ho : (t+1)%2 ≠ 0 := by omega
        simp only [he,ho,if_true,if_false,Bool.not_false]
        have hr := (op2130_sign_mean_recurrence n).2
        rw [hr]
        have hb := (op2130_sign_mean_bounds n).2.2.2.2.1
        rw [abs_of_nonneg (by linarith : 0 ≤ op2130_sign_mean true n - (-1 + op2130_sign_mean true n)/2)]
        linarith
      · have ho : (t+1)%2=0 := by omega
        have hp : 0 < n := by dsimp [n]; omega
        simp only [he,ho,if_true,if_false,Bool.not_false]
        have hr := (op2130_sign_mean_recurrence n).1
        rw [hr]
        have hb := (op2130_sign_mean_bounds n).2.2.2.2.2 hp
        rw [abs_of_nonpos (by linarith : op2130_sign_mean false n - (1 + op2130_sign_mean false n)/2 ≤ 0)]
        linarith
  12. The total pathwise conditional-mean quadratic variation along the non-deciding path is at least N / 4.

    Since each of the N increments has absolute value at least 1/2, squaring each increment yields at least 1/4 via op2130_nondecd_increment_lower and sq_abs. Summing this lower bound over all t < N gives N / 4.

    lines 191–198

    uses op2130_nondecd_increment_lower, sq_abs, Finset.sum_le_sum, div_eq_mul_inv

      have each : ∀ t ∈ Finset.range N, (1:ℝ)/4 ≤
          (op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t)^2 := by
        intro t ht
        have h := op2130_nondecd_increment_lower N t hodd (Finset.mem_range.mp ht)
        have hsq := sq_abs (op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t)
        nlinarith [sq_nonneg (|op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t| - 1/2)]
      have hs := Finset.sum_le_sum (s := Finset.range N) each
      simpa [div_eq_mul_inv] using hs
  13. The outer decision list evaluation coincides with the count-based decision list evaluation: op2130_outer_decision v xs = op2130_logical_count_decision v xs.

    By list induction on xs. The base case on the empty list is false for both definitions, and the inductive step follows immediately from their identical recursive clauses.

    lines 202–204

    uses op2130_outer_decision, op2130_logical_count_decision

      induction xs generalizing v with
      | nil => cases v <;> rfl
      | cons x xs ih => cases v <;> simp [op2130_outer_decision,op2130_logical_count_decision,ih]
  14. The non-deciding bit starting from false simplifies to parity testing: op2130_nondecd_bit false t = (t % 2 == 1).

    By cases on whether t is even. If t % 2 = 0, both sides equal false. If t % 2 ≠ 0, then t % 2 = 1, so both sides equal true.

    lines 208–212

    uses op2130_nondecd_bit

      by_cases ht : t%2=0
      · have ho : t%2 ≠ 1 := by omega
        simp [op2130_nondecd_bit,ht,ho]
      · have ho : t%2=1 := by omega
        simp [op2130_nondecd_bit,ht,ho]
  15. For each step t, the martingale conditional expectation Q t r along the non-deciding tape r equals op2130_nondecd_mean false N t.

    The non-deciding tape r has bits r i = (i % 2 == 1). By op2130_nondecd_bit_false, agreeing with r up to index t is equivalent to satisfying op2130_nondecd_prefix false t. By op2130_outer_eq_count, the payoff defined using op2130_outer_decision matches the one in op2130_nondecd_mean.

    lines 215–230

    uses op2130_nondecd_mean, Finset.sum_congr, op2130_nondecd_prefix, op2130_nondecd_bit_false, op2130_outer_eq_count

      classical
      let X : (Fin N → Bool) → ℝ := fun r => if op2130_outer_decision false (List.ofFn r) then -1 else 1
      let Q : ℕ → (Fin N → Bool) → ℝ := fun t a =>
        (∑ b : Fin N → Bool, if ∀ i : Fin N, i.val < t → b i = a i then X b else 0) / (2 : ℝ) ^ (N-t)
      let r : Fin N → Bool := fun i => i.val % 2 == 1
      have hQ (t : ℕ) : Q t r = op2130_nondecd_mean false N t := by
        dsimp only [Q,r,op2130_nondecd_mean]
        congr 1
        apply Finset.sum_congr rfl
        intro b hb
        have hc : (∀ i : Fin N, i.val < t → b i = (i.val%2 == 1)) ↔
            op2130_nondecd_prefix false t b := by
          simp only [op2130_nondecd_prefix,op2130_nondecd_bit_false]
        rw [if_congr hc rfl rfl]
        simp only [X,op2130_outer_eq_count]
      change ((N:ℝ)-2)/4 ≤ ∑ t ∈ Finset.range N, (Q (t+1) r - Q t r)^2
  16. The total pathwise conditional-mean quadratic variation along r is bounded below by (N - 2) / 4.

    Substituting the identification Q t r = op2130_nondecd_mean false N t, op2130_nondecd_variation_lower bounds the sum of squared increments from below by N / 4. Since N / 4 ≥ (N - 2) / 4, linear arithmetic concludes the proof.

    lines 231–233

    uses op2130_nondecd_variation_lower

      simp only [hQ]
      have hh := op2130_nondecd_variation_lower N hodd
      linarith
sq_abs
The square of the absolute value of an element equals the square of the element.
div_eq_mul_inv
Division by a number equals multiplication by its multiplicative inverse.
Finset.sum_le_sum
If one summand is pointwise bounded by another over a finite set, the sum satisfies the same inequality.
pow_succ
In any monoid, a power a ^ (n + 1) equals (a ^ n) * a.
pow_ne_zero
A non-zero element raised to any power in a domain remains non-zero.
abs_of_nonneg
The absolute value of a non-negative element equals itself.
abs_of_nonpos
The absolute value of a non-positive element equals its negation.
List.ofFn_succ
Converting a function on Fin (n + 1) to a list yields the head element consed onto the list formed by the tail.
Fin.cases
Dependent elimination principle for Fin (n + 1), splitting into the zero element and successor elements.
Fin.consEquiv_apply
Applying the equivalence between a head bit with a tail map and a combined map matches Fin.cons.
Fintype.sum_prod_type
A sum over a product type can be evaluated as an iterated sum over each component type.
Fintype.sum_bool
A sum of a function over the booleans equals its value at true plus its value at false.
Finset.sum_add_distrib
The sum of a sum of two functions over a finite set equals the sum of each function individually.
Finset.sum_congr
If two finite index sets and their respective summands are equal, their sums are equal.
op2130_outer_decision
Evaluates an alternating OR/AND decision list on a list of boolean bits.
op2130_logical_sum_bool_tapes_succ
Summing over all boolean tapes of length n + 1 equals summing the evaluations on false-prepended and true-prepended tapes.
op2130_logical_count_decision
Evaluates an alternating OR/AND decision list on a list of boolean bits via counting logic.
op2130_nondecd_bit
The bit that defers a decision at gate index i starting with polarity v: v if i is even, and !v if i is odd.
op2130_nondecd_prefix
Predicate stating that a boolean tape matches the non-deciding bits for all indices up to t.
op2130_nondecd_bit_succ
Shifting the gate index by 1 in the non-deciding bit sequence toggles the starting polarity.
op2130_nondecd_prefix_succ
A tape of length n + 1 has a non-deciding prefix of length t + 1 iff its head is v and its tail has a non-deciding prefix of length t with inverted polarity.
op2130_decision_prefix_sum_succ
Summing payoffs on length-(n + 1) tapes with prefix length t + 1 equals summing on length-n tapes with prefix length t and toggled gate mode.
op2130_sign_mean
The expected payoff of the decision list under the uniform distribution on tapes of length n.
op2130_sign_mean_recurrence
The coupled recurrence relations for the expected payoff when incrementing the input tape length.
op2130_nondecd_mean
The conditional expectation of the decision list payoff given a non-deciding prefix of length t on tapes of length n.
op2130_nondecd_mean_succ
Stepping both the tape length and the prefix length by 1 in the non-deciding mean inverts the starting polarity.
op2130_toggle
Repeatedly inverts a boolean starting polarity t times.
op2130_nondecd_mean_strip
Conditioned on a non-deciding prefix of length t, the conditional mean on length n + t reduces to the unconditional sign mean on length n with toggled gate polarity.
op2130_sign_mean_bounds
Bounds showing that the expected payoff remains in [-1, 1], with sign_mean true ≥ 0 and sign_mean false ≤ 0 for positive length.
op2130_toggle_eq
Toggling a boolean t times leaves it unchanged if t is even, and inverts it if t is odd.
op2130_nondecd_increment_lower
Each single-step increment in the conditional expectation along the non-deciding path has absolute value at least 1/2.
op2130_nondecd_variation_lower
The total conditional quadratic variation along the non-deciding path on N bits is at least N/4.
op2130_outer_eq_count
The outer decision list evaluation coincides with the count-based decision list evaluation.
op2130_nondecd_bit_false
The non-deciding bit starting from false simplifies to testing whether the index is odd.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

def op2130_outer_decision : Bool → List Bool → Bool  | _, [] => false  | isAnd, b :: bs => if isAnd then b && op2130_outer_decision false bs else b || op2130_outer_decision true bsset_option maxHeartbeats 1000000theorem op2130_logical_sum_bool_tapes_succ {A : Type*} [AddCommMonoid A] (n : ℕ)    (f : (Fin (n+1) → Bool) → A) :    (∑ r, f r) = ∑ s : Fin n → Bool, (f (Fin.cons false s) + f (Fin.cons true s)) := by  classical  calc    (∑ r, f r) = ∑ p : Bool × (Fin n → Bool), f ((Fin.consEquiv fun _ => Bool) p) :=      ((Fin.consEquiv fun _ => Bool).sum_comp f).symm    _ = _ := by      simp only [Fintype.sum_prod_type, Fintype.sum_bool, Fin.consEquiv_apply, Finset.sum_add_distrib]      ac_rfldef op2130_logical_count_decision : Bool → List Bool → Bool  | _, [] => false  | isAnd, b::bs => if isAnd then b && op2130_logical_count_decision false bs else b || op2130_logical_count_decision true bsdef op2130_nondecd_bit (v : Bool) (i : ℕ) : Bool :=  if i%2=0 then v else !vdef op2130_nondecd_prefix {n : ℕ} (v : Bool) (t : ℕ) (r : Fin n → Bool) : Prop :=  ∀ i : Fin n, i.val < t → r i = op2130_nondecd_bit v i.valtheorem op2130_nondecd_bit_succ (v : Bool) (i : ℕ) :    op2130_nondecd_bit v (i+1) = op2130_nondecd_bit (!v) i := by  by_cases h : i%2=0  · have hs : (i+1)%2 ≠ 0 := by omega    simp [op2130_nondecd_bit,h,hs]  · have hs : (i+1)%2 = 0 := by omega    cases v <;> simp [op2130_nondecd_bit,h,hs]theorem op2130_nondecd_prefix_succ {n : ℕ} (v : Bool) (t : ℕ) (r : Fin (n+1) → Bool) :    op2130_nondecd_prefix v (t+1) r ↔ r 0 = v ∧      op2130_nondecd_prefix (!v) t (fun i => r i.succ) := by  constructor  · intro h    constructor    · have hh := h 0 (by simp)      simpa [op2130_nondecd_bit] using hh    · intro i hi      have hh := h i.succ (by simp only [Fin.val_succ]; omega)      simpa only [Fin.val_succ,op2130_nondecd_bit_succ] using hh  · rintro ⟨h0,ht⟩    intro i    refine Fin.cases ?_ ?_ i    · intro _; simpa [op2130_nondecd_bit] using h0    · intro j hj      have hh := ht j (by simp only [Fin.val_succ] at hj; omega)      simpa only [Fin.val_succ,op2130_nondecd_bit_succ] using hhtheorem op2130_decision_prefix_sum_succ (n t : ℕ) (v : Bool) (f : Bool → ℝ) :    (by classical exact (∑ r : Fin (n+1) → Bool,      if op2130_nondecd_prefix v (t+1) r then f (op2130_logical_count_decision v (List.ofFn r)) else 0) =    (∑ r : Fin n → Bool,      if op2130_nondecd_prefix (!v) t r then f (op2130_logical_count_decision (!v) (List.ofFn r)) else 0)) := by  classical  rw [op2130_logical_sum_bool_tapes_succ]  apply Finset.sum_congr rfl  intro r hr  rw [op2130_nondecd_prefix_succ,op2130_nondecd_prefix_succ]  cases v <;> simp [List.ofFn_succ,op2130_logical_count_decision]noncomputable def op2130_sign_mean (v : Bool) (n : ℕ) : ℝ :=  (∑ r : Fin n → Bool, if op2130_logical_count_decision v (List.ofFn r) then (-1:ℝ) else 1) / (2:ℝ)^ntheorem op2130_sign_mean_recurrence (n : ℕ) :    op2130_sign_mean true (n+1) = (1 + op2130_sign_mean false n)/2 ∧    op2130_sign_mean false (n+1) = (-1 + op2130_sign_mean true n)/2 := by  constructor  · unfold op2130_sign_mean    rw [op2130_logical_sum_bool_tapes_succ]    simp only [List.ofFn_succ, Fin.cons_zero, Fin.cons_succ, op2130_logical_count_decision,      Bool.false_and, Bool.true_and, Bool.false_eq_true, ↓reduceIte, Finset.sum_add_distrib]    simp only [Finset.sum_const_zero, zero_add, Finset.sum_const, Finset.card_univ,      Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul]    rw [pow_succ]    have hn : (2:ℝ)^n ≠ 0 := pow_ne_zero _ (by norm_num)    field_simp    push_cast    ring  · unfold op2130_sign_mean    rw [op2130_logical_sum_bool_tapes_succ]    simp only [List.ofFn_succ, Fin.cons_zero, Fin.cons_succ, op2130_logical_count_decision,      Bool.false_or, Bool.true_or, ↓reduceIte, Finset.sum_add_distrib, if_true]    try simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fun,      Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul]    rw [pow_succ]    have hn : (2:ℝ)^n ≠ 0 := pow_ne_zero _ (by norm_num)    field_simp    push_cast    simp only [if_true, Finset.sum_const, Finset.card_univ, Fintype.card_fun,      Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul]    push_cast    ringnoncomputable def op2130_nondecd_mean (v : Bool) (n t : ℕ) : ℝ := by  classical  exact (∑ r : Fin n → Bool,    if op2130_nondecd_prefix v t r then      (if op2130_logical_count_decision v (List.ofFn r) then (-1:ℝ) else 1) else 0) / (2:ℝ)^(n-t)theorem op2130_nondecd_mean_succ (v : Bool) (n t : ℕ) :    op2130_nondecd_mean v (n+1) (t+1) = op2130_nondecd_mean (!v) n t := by  classical  unfold op2130_nondecd_mean  have hh := op2130_decision_prefix_sum_succ n t v (fun b => if b then (-1:ℝ) else 1)  rw [show n+1-(t+1)=n-t by omega]  congr 1def op2130_toggle : Bool → ℕ → Bool  | v, 0 => v  | v, t+1 => op2130_toggle (!v) ttheorem op2130_nondecd_mean_strip (v : Bool) (n t : ℕ) :    op2130_nondecd_mean v (n+t) t = op2130_sign_mean (op2130_toggle v t) n := by  induction t generalizing v with  | zero =>      classical      simp [op2130_nondecd_mean,op2130_sign_mean,op2130_nondecd_prefix,op2130_toggle]      congr 1  | succ t ih =>      rw [show n+(t+1) = (n+t)+1 by omega, op2130_nondecd_mean_succ]      simpa only [op2130_toggle] using ih (!v)theorem op2130_sign_mean_bounds (n : ℕ) :    -1 ≤ op2130_sign_mean true n ∧ op2130_sign_mean true n ≤ 1 ∧    -1 ≤ op2130_sign_mean false n ∧ op2130_sign_mean false n ≤ 1 ∧    0 ≤ op2130_sign_mean true n ∧ (0 < n → op2130_sign_mean false n ≤ 0) := by  induction n with  | zero =>      have he : ∀ r : Fin 0 → Bool, List.ofFn r = [] := by intro r; simp      simp [op2130_sign_mean,he,op2130_logical_count_decision]  | succ n ih =>      have hr := op2130_sign_mean_recurrence n      rcases ih with ⟨a,b,c,d,e,f⟩      rw [hr.1,hr.2]      refine ⟨?_,?_,?_,?_,?_,?_⟩ <;> try linarith      intro _      linariththeorem op2130_toggle_eq (v : Bool) (t : ℕ) :    op2130_toggle v t = if t%2=0 then v else !v := by  induction t generalizing v with  | zero => simp [op2130_toggle]  | succ t ih =>      simp only [op2130_toggle, ih]      by_cases ht : t%2=0      · have hs : (t+1)%2 ≠ 0 := by omega        cases v <;> simp [ht,hs]      · have hs : (t+1)%2=0 := by omega        cases v <;> simp [ht,hs]theorem op2130_nondecd_increment_lower (N t : ℕ) (hodd : N%2=1) (ht : t < N) :    (1:ℝ)/2 ≤ |op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t| := by  let n := N-(t+1)  have hN : N = n+(t+1) := by dsimp [n]; omega  have hn1 : N = (n+1)+t := by omega  have qbefore := op2130_nondecd_mean_strip false (n+1) t  have qafter := op2130_nondecd_mean_strip false n (t+1)  rw [← hn1] at qbefore  rw [← hN] at qafter  rw [qbefore,qafter]  rw [op2130_toggle_eq,op2130_toggle_eq]  by_cases he : t%2=0  · have ho : (t+1)%2 ≠ 0 := by omega    simp only [he,ho,if_true,if_false,Bool.not_false]    have hr := (op2130_sign_mean_recurrence n).2    rw [hr]    have hb := (op2130_sign_mean_bounds n).2.2.2.2.1    rw [abs_of_nonneg (by linarith : 0 ≤ op2130_sign_mean true n - (-1 + op2130_sign_mean true n)/2)]    linarith  · have ho : (t+1)%2=0 := by omega    have hp : 0 < n := by dsimp [n]; omega    simp only [he,ho,if_true,if_false,Bool.not_false]    have hr := (op2130_sign_mean_recurrence n).1    rw [hr]    have hb := (op2130_sign_mean_bounds n).2.2.2.2.2 hp    rw [abs_of_nonpos (by linarith : op2130_sign_mean false n - (1 + op2130_sign_mean false n)/2 ≤ 0)]    linariththeorem op2130_nondecd_variation_lower (N : ℕ) (hodd : N%2=1) :    (N:ℝ)/4 ≤ ∑ t ∈ Finset.range N,      (op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t)^2 := by  have each : ∀ t ∈ Finset.range N, (1:ℝ)/4 ≤      (op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t)^2 := by    intro t ht    have h := op2130_nondecd_increment_lower N t hodd (Finset.mem_range.mp ht)    have hsq := sq_abs (op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t)    nlinarith [sq_nonneg (|op2130_nondecd_mean false N (t+1) - op2130_nondecd_mean false N t| - 1/2)]  have hs := Finset.sum_le_sum (s := Finset.range N) each  simpa [div_eq_mul_inv] using hstheorem op2130_outer_eq_count (v : Bool) (xs : List Bool) :    op2130_outer_decision v xs = op2130_logical_count_decision v xs := by  induction xs generalizing v with  | nil => cases v <;> rfl  | cons x xs ih => cases v <;> simp [op2130_outer_decision,op2130_logical_count_decision,ih]theorem op2130_nondecd_bit_false (t : ℕ) :    op2130_nondecd_bit false t = (t%2 == 1) := by  by_cases ht : t%2=0  · have ho : t%2 ≠ 1 := by omega    simp [op2130_nondecd_bit,ht,ho]  · have ho : t%2=1 := by omega    simp [op2130_nondecd_bit,ht,ho]theorem op2130_decision_list_conditional_variation (N : ℕ) (hN : 3 ≤ N) (hodd : N % 2 = 1) : let X : (Fin N → Bool) → ℝ := fun r => if op2130_outer_decision false (List.ofFn r) then -1 else 1; let Q : ℕ → (Fin N → Bool) → ℝ := fun t a => (∑ b : Fin N → Bool, if ∀ i : Fin N, i.val < t → b i = a i then X b else 0) / (2 : ℝ) ^ (N-t); let r : Fin N → Bool := fun i => i.val % 2 == 1; ((N : ℝ)-2)/4 ≤ ∑ t ∈ Finset.range N, (Q (t+1) r - Q t r) ^ 2 := by  classical  let X : (Fin N → Bool) → ℝ := fun r => if op2130_outer_decision false (List.ofFn r) then -1 else 1  let Q : ℕ → (Fin N → Bool) → ℝ := fun t a =>    (∑ b : Fin N → Bool, if ∀ i : Fin N, i.val < t → b i = a i then X b else 0) / (2 : ℝ) ^ (N-t)  let r : Fin N → Bool := fun i => i.val % 2 == 1  have hQ (t : ℕ) : Q t r = op2130_nondecd_mean false N t := by    dsimp only [Q,r,op2130_nondecd_mean]    congr 1    apply Finset.sum_congr rfl    intro b hb    have hc : (∀ i : Fin N, i.val < t → b i = (i.val%2 == 1)) ↔        op2130_nondecd_prefix false t b := by      simp only [op2130_nondecd_prefix,op2130_nondecd_bit_false]    rw [if_congr hc rfl rfl]    simp only [X,op2130_outer_eq_count]  change ((N:ℝ)-2)/4 ≤ ∑ t ∈ Finset.range N, (Q (t+1) r - Q t r)^2  simp only [hQ]  have hh := op2130_nondecd_variation_lower N hodd  linarith
See it in the graphDiscuss this resultChallenge it