op2130_projected_conditional_means
After a fixed prefix, the full fair-coin conditional means immediately before and after a selected coin agree with the corresponding conditional means for the ordered selected-coin tape, when the outcome depends only on those selected coins.
Statement
theorem op2130_projected_conditional_means (T m t0 : ℕ) (ht0 : t0 ≤ T) (idx : Fin m → Fin T) (hinc : StrictMono idx) (hafter : ∀ i, t0 ≤ (idx i).val) (f : (Fin T → Bool) → ℝ) (g : (Fin m → Bool) → ℝ) (r : Fin T → Bool) (hproj : ∀ s : Fin T → Bool, (∀ i : Fin T, i.val < t0 → s i = r i) → f s = g (fun i => s (idx i))) (j : Fin m) : let Q : ℕ → (Fin T → Bool) → ℝ := fun t a => (∑ b : Fin T → Bool, if ∀ i : Fin T, i.val < t → b i = a i then f b else 0) / (2 : ℝ) ^ (T-t); let R : ℕ → (Fin m → Bool) → ℝ := fun t a => (∑ b : Fin m → Bool, if ∀ i : Fin m, i.val < t → b i = a i then g b else 0) / (2 : ℝ) ^ (m-t); Q (idx j).val r = R j.val (fun i => r (idx i)) ∧ Q ((idx j).val+1) r = R (j.val+1) (fun i => r (idx i))
- Source
- OP-2130, dummy-coin projection
- Verified
- 29 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 4
- op2130_coin_projection_fiber_cardEach assignment to m distinct coin positions extends to exactly 2^(T-m) Boolean tapes of length T.
- op2130_coin_projection_meanThe uniform mean of any function of m distinct selected bits of a T-bit tape equals its uniform mean over m-bit tapes.
- LinearOrder.toTotalPreorderEvery
LinearOrderis aTotalPreorder. - TotalPreorderA total preorder: a preorder where
≤is total (complete). This is weaker thanLinearOrder— it does NOT require antisymmetry or…
- Used by 1
- op2130_conditional_projection_lower_boundAfter a fixed tape prefix, if a real-valued outcome depends only on a strictly ordered selection of later coins, then its full-tape…
The proof, explained
The theorem establishes that the conditional expectation of an outcome function f on a tape of T fair coins matches the conditional expectation of a projected function g on m selected coins immediately before and after each selected coin. The core lemma, `pcm_general`, decomposes the full tape into the m selected coins and the remaining T - m unselected coins C; because f depends only on the selected coins after a prefix t0, the conditional sum factors into the selected-coin conditional sum times the number 2^N of valid completions on unselected coins. Partitioning the coordinates ≥ t into selected and unselected subsets shows that N + (m - k) = T - t, so the unselected factor 2^N exactly cancels against the normalizing ratio 2^(T-t) / 2^(m-k). Finally, `op2130_projected_conditional_means` applies this general result at times t = idx(j) and t = idx(j) + 1, where strict monotonicity of idx aligns the prefix conditions on the full tape with prefixes of length j and j + 1 on the selected tape.
There is a bijection between functions h : ι → Bool agreeing with c on P and unrestricted functions from the complement subtype {i // ¬ P i} to Bool.
We define an equivalence e whose forward map restricts h to indices where P fails. The inverse map extends any assignment on {i // ¬ P i} by setting values on P to agree with c. Both compositions equal the identity by case analysis on whether P i holds, using Subtype.ext.
uses
Subtype.extclassical let e : {h : ι → Bool // ∀ i, P i → h i = c i} ≃ ({i // ¬ P i} → Bool) := { toFun := fun h i => h.1 i.1 invFun := fun h' => ⟨fun i => if hi : P i then c i else h' ⟨i, hi⟩, fun i hi => by simp [hi]⟩ left_inv := fun h => by apply Subtype.ext; funext i by_cases hi : P i · simp [hi, h.2 i hi] · simp [hi] right_inv := fun h' => by funext i; simp [i.2] }
The number of functions h : ι → Bool agreeing with c on P is 2^(|{i // ¬ P i}|) (lemma `pcm_card_agree`).
Using the equivalence e, the cardinality of the subtype of functions agreeing with c on P equals the cardinality of the function space ({i // ¬ P i} → Bool), which is 2^(|{i // ¬ P i}|) by standard cardinality identities.
uses
Fintype.card_congr,Fintype.card_bool,Fintype.card_fun,Fintype.card_subtyperw [← Fintype.card_subtype, Fintype.card_congr e, Fintype.card_fun, Fintype.card_bool, Fintype.card_subtype]The full coin tape Fin T → Bool is bijectively decomposed into the selected tape Fin m → Bool and the unselected tape C → Bool, where C is the complement of the range of idx.
Since idx is strictly monotone, it is injective. Using standard equivalence constructors for product partitions and function arrows, we define a bijection e sending any tape b to the pair (b ∘ idx, b|_C), with the projection properties verified by reflexivity.
uses
Equiv.arrowCongr,Equiv.ofInjective,Equiv.piEquivPiSubtypeProd,Equiv.prodCongr,Equiv.reflclassical have hinj : Function.Injective idx := hinc.injective -- split the tape into the selected coordinates and the rest let C := {i : Fin T // i ∉ Set.range idx} let e : (Fin T → Bool) ≃ (Fin m → Bool) × (C → Bool) := (Equiv.piEquivPiSubtypeProd (fun i => i ∈ Set.range idx) (fun _ => Bool)).trans (Equiv.prodCongr (Equiv.arrowCongr (Equiv.ofInjective idx hinj).symm (Equiv.refl Bool)) (Equiv.refl _)) have he1 : ∀ b j, (e b).1 j = b (idx j) := by intro b j; rfl have he2 : ∀ b (i : C), (e b).2 i = b i.1 := by intro b i; rfl
The conditional sum of f(b) over Fin T → Bool equals the sum over product tapes (a, h) of g(a) subject to independent prefix conditions on a and h.
The condition b i = r i for all i < t holds if and only if both the selected prefix condition ca a (a j = r (idx j) for j < k) and the unselected condition ch h (h i = r i for i ∈ C with i < t) hold, because idx j < t ↔ j < k. When satisfied, b agrees with r on all coordinates below t0 ≤ t, so f(b) = g(a) by the projection hypothesis hproj. Reindexing by e and expanding into an iterated sum via Fintype.sum_prod_type yields the result.
uses
Fintype.sum_equiv,Fintype.sum_prod_type,if_neg,if_poslet ca : (Fin m → Bool) → Prop := fun a => ∀ i : Fin m, i.val < k → a i = r (idx i) let ch : (C → Bool) → Prop := fun h => ∀ i : C, i.1.val < t → h i = r i.1 have hsum : (∑ b : Fin T → Bool, if ∀ i : Fin T, i.val < t → b i = r i then f b else 0) = ∑ p : (Fin m → Bool) × (C → Bool), if ca p.1 ∧ ch p.2 then g p.1 else 0 := by refine Fintype.sum_equiv e _ _ (fun b => ?_) have hc : (∀ i : Fin T, i.val < t → b i = r i) ↔ (ca (e b).1 ∧ ch (e b).2) := by constructor · intro h refine ⟨fun j hj => ?_, fun i hi => ?_⟩ · rw [he1]; exact h _ ((htk j).2 hj) · rw [he2]; exact h _ hi · rintro ⟨h1, h2⟩ i hi by_cases hr : i ∈ Set.range idx · obtain ⟨j, rfl⟩ := hr have := h1 j ((htk j).1 hi) rw [he1] at this; exact this · have := h2 ⟨i, hr⟩ hi rw [he2] at this; exact this by_cases h : ∀ i : Fin T, i.val < t → b i = r i · rw [if_pos h, if_pos (hc.1 h)] rw [hproj b (fun i hi => h i (by omega))] congr 1 · rw [if_neg h, if_neg (fun h' => h (hc.2 h'))] rw [hsum, Fintype.sum_prod_type]
The inner sum over unselected tapes h : C → Bool factors into g(a) multiplied by the number of unselected tapes satisfying the prefix condition ch.
When the selected prefix condition ca a holds, the summand is g(a) whenever ch h holds and 0 otherwise; when ca a fails, it is identically 0. Factoring out the constant g(a) from the inner sum over h leaves g(a) times the number of unselected configurations satisfying ch.
uses
Finset.sum_const,Finset.sum_filter,if_true,mul_comm,nsmul_eq_mul,true_andhave hinner : ∀ a : Fin m → Bool, (∑ h : C → Bool, if ca a ∧ ch h then g a else 0) = if ca a then g a * ((Finset.univ.filter fun h : C → Bool => ch h).card : ℝ) else 0 := by intro a by_cases ha : ca a · simp only [ha, true_and, if_true] rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_comm] · simp [ha] simp only [hinner]
The number of unconstrained unselected coordinates N = |{i ∈ C // t ≤ i.val}| satisfies N + (m - k) = T - t.
By pcm_card_agree, the number of completions on C is 2^N. We partition the coordinates of Fin T that are ≥ t into those in the range of idx and those in C. There are T - t coordinates ≥ t in total. The selected coordinates ≥ t correspond via the strictly monotone map idx to indices j ∈ Fin m with j ≥ k, of which there are m - k. Since C consists of the non-selected coordinates, the unselected coordinates ≥ t have cardinality N, and disjoint union yields N + (m - k) = T - t.
uses
Finset.card_attachFin,Finset.card_bij,Finset.card_map,Finset.card_union_of_disjoint,Finset.disjoint_filter,Nat.card_Ico,pcm_card_agree,Subtype.exthave hcard := pcm_card_agree (ι := C) (fun i => i.1.val < t) (fun i => r i.1) -- the number of free coordinates set N := (Finset.univ.filter fun i : C => ¬ i.1.val < t).card with hN have hNeq : N + (m - k) = T - t := by have h1 : (Finset.univ.filter fun i : Fin T => t ≤ i.val).card = T - t := by have : (Finset.univ.filter fun i : Fin T => t ≤ i.val) = (Finset.Ico t T).attachFin (fun x hx => (Finset.mem_Ico.mp hx).2) := by ext i; simp [Finset.mem_attachFin, Finset.mem_Ico, i.2] rw [this, Finset.card_attachFin, Nat.card_Ico] have h2 : (Finset.univ.filter fun i : Fin T => i ∈ Set.range idx ∧ t ≤ i.val).card = m - k := by have : (Finset.univ.filter fun i : Fin T => i ∈ Set.range idx ∧ t ≤ i.val) = (Finset.univ.filter fun j : Fin m => k ≤ j.val).map ⟨idx, hinj⟩ := by ext i simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_map, Function.Embedding.coeFn_mk, Set.mem_range] constructor · rintro ⟨⟨j, rfl⟩, hj⟩ exact ⟨j, by have := (htk j).not; push Not at this; exact this.1 hj, rfl⟩ · rintro ⟨j, hj, rfl⟩ exact ⟨⟨j, rfl⟩, by have := (htk j).not; push Not at this; exact this.2 hj⟩ rw [this, Finset.card_map] have : (Finset.univ.filter fun j : Fin m => k ≤ j.val) = (Finset.Ico k m).attachFin (fun x hx => (Finset.mem_Ico.mp hx).2) := by ext j; simp [Finset.mem_attachFin, Finset.mem_Ico, j.2] rw [this, Finset.card_attachFin, Nat.card_Ico] have h3 : N = (Finset.univ.filter fun i : Fin T => i ∉ Set.range idx ∧ t ≤ i.val).card := by rw [hN] apply Finset.card_bij (fun i _ => i.1) · intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and, not_lt] at hi ⊢ exact ⟨i.2, hi⟩ · intro i _ j _ h; exact Subtype.ext h · intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi exact ⟨⟨i, hi.1⟩, by simp [hi.2], rfl⟩ rw [h3, ← h1, ← h2] rw [← Finset.card_union_of_disjoint] · congr 1; ext i; simp only [Finset.mem_union, Finset.mem_filter, Finset.mem_univ, true_and] tauto · rw [Finset.disjoint_filter]; intro i _ h1 h2; exact h1.1 h2.1
The normalized conditional expectation on Fin T → Bool equals the normalized conditional expectation on Fin m → Bool (`pcm_general`).
The denominator 2^(T - t) factors as 2^N * 2^(m - k) via pow_add and the index partition identity. The factor 2^N from the count of unselected completions cancels with the denominator factor 2^N. Summand-by-summand equality follows by rewriting with div_eq_div_iff and split_ifs.
uses
div_eq_div_iff,Finset.sum_congr,Finset.sum_mul,pow_addrw [hcard] have hpow : (2:ℝ) ^ (T - t) = 2 ^ N * 2 ^ (m - k) := by rw [← pow_add, hNeq] rw [hpow] have h2N : (0:ℝ) < 2 ^ N := by positivity have h2k : (0:ℝ) < 2 ^ (m - k) := by positivity rw [div_eq_div_iff (by positivity) (by positivity)] rw [Finset.sum_mul, Finset.sum_mul] apply Finset.sum_congr rfl; intro a _ push_cast split_ifs <;> ring
The conditional means immediately before the j-th selected coin agree: Q (idx j).val r = R j.val (r ∘ idx).
We apply pcm_general with t = (idx j).val and k = j.val. The condition t0 ≤ t is hafter j, and strict monotonicity of idx ensures that idx j' < idx j ↔ j' < j.
uses
pcm_generalintro Q R constructor · exact pcm_general T m t0 idx hinc hafter f g r hproj (idx j).val j.val (hafter j) (idx j).2.le j.2.le (fun j' => ⟨fun h => hinc.lt_iff_lt.mp h, fun h => hinc.lt_iff_lt.mpr h⟩)
The conditional means immediately after the j-th selected coin agree: Q ((idx j).val + 1) r = R (j.val + 1) (r ∘ idx).
We apply pcm_general with t = (idx j).val + 1 and k = j.val + 1. The prefix condition idx j' < idx j + 1 is equivalent to idx j' ≤ idx j, which by strict monotonicity is equivalent to j' ≤ j, and thus to j' < j + 1 by Nat.lt_succ_of_le.
uses
Nat.lt_succ_of_le,pcm_general· exact pcm_general T m t0 idx hinc hafter f g r hproj ((idx j).val+1) (j.val+1) (by have := hafter j; omega) (idx j).2 j.2 (fun j' => by constructor · intro h have : idx j' ≤ idx j := Fin.le_def.mpr (by omega) have := hinc.le_iff_le.mp this exact Nat.lt_succ_of_le (Fin.le_def.mp this) · intro h have : j' ≤ j := Fin.le_def.mpr (by omega) have := hinc.le_iff_le.mpr this exact Nat.lt_succ_of_le (Fin.le_def.mp this))
Fintype.card_congr- Equivalent finite types have the same cardinality.
Fintype.card_bool- The finite type Bool has cardinality 2.
Fintype.card_fun- The cardinality of the function type α → β between finite types is |β|^|α|.
Fintype.card_subtype- The cardinality of a subtype {x // p x} equals the cardinality of the filtered set of elements satisfying p.
Subtype.ext- Two elements of a subtype are equal if their underlying values are equal.
Equiv.arrowCongr- Equivalences on domain and codomain induce an equivalence between function types.
Equiv.ofInjective- An injective function yields an equivalence between its domain and its range.
Equiv.piEquivPiSubtypeProd- Dependent functions on α are equivalent to pairs of functions on a subtype {x // p x} and its complement subtype {x // ¬p x}.
Equiv.prodCongr- The product of two equivalences is an equivalence between the Cartesian products.
Equiv.refl- The identity map on any type is an equivalence with itself.
if_neg- An if-then-else expression evaluates to the else branch when the condition is false.
if_pos- An if-then-else expression evaluates to the then branch when the condition is true.
Fintype.sum_prod_type- A sum over a Cartesian product α × β equals the iterated sum over α and β.
Fintype.sum_equiv- A sum over a finite type can be reindexed along an equivalence of types.
Finset.sum_const- Finset filtering distributes over constant summation, yielding the cardinality times the constant.
Finset.sum_filter- Summing over elements of a finset satisfying predicate p equals summing the conditional expression if p x then f x else 0 over the whole finset.
if_true- An if-then-else expression with condition True evaluates to its then branch.
mul_comm- Multiplication in a commutative magma is commutative: a * b = b * a.
nsmul_eq_mul- Scalar multiplication of a semiring element by a natural number n equals algebraic multiplication by n.
true_and- The conjunction True ∧ p simplifies to p.
Finset.card_attachFin- Attaching proofs of an upper bound to a finset of natural numbers yields a finset of Fin n with the same cardinality.
Finset.card_bij- Two finite sets have equal cardinality if there is a bijection between them.
Finset.card_map- Mapping a finite set along an embedding preserves its cardinality.
Finset.card_union_of_disjoint- The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
Finset.disjoint_filter- Two filtered subsets of a finset are disjoint if no element satisfies both filtering predicates.
Nat.card_Ico- The cardinality of the half-open interval [a, b) of natural numbers is b - a.
pcm_card_agree- The number of functions on a finite type agreeing with a reference function on a predicate P is 2^(|{i | ¬ P i}|).
div_eq_div_iff- For nonzero denominators, a / b = c / d if and only if a * d = c * b.
Finset.sum_congr- Two finite sums are equal if their index sets are equal and their summands agree on all elements.
Finset.sum_mul- Right-distributivity of multiplication over finite sums: (∑ i, f i) * a = ∑ i, (f i * a).
pow_add- In any monoid, a^(m + n) = a^m * a^n.
Nat.lt_succ_of_le- If n ≤ m, then n < m + 1 for natural numbers.
pcm_general- The full-tape conditional mean equals the selected-tape conditional mean at any time t ≥ t0 splitting selected indices at k, when the outcome depends only on selected coins.
- Arithmetic bounds and index comparisons in lines 128–138 are discharged using Lean's `omega` decision procedure.
- In line 121, `split_ifs <;> ring` automatically verifies the piecewise polynomial equality on ℝ for each term.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem pcm_card_agree {ι : Type*} [Fintype ι] [DecidableEq ι] (P : ι → Prop) [DecidablePred P] (c : ι → Bool) : (Finset.univ.filter fun h : ι → Bool => ∀ i, P i → h i = c i).card = 2 ^ (Finset.univ.filter fun i => ¬ P i).card := by classical let e : {h : ι → Bool // ∀ i, P i → h i = c i} ≃ ({i // ¬ P i} → Bool) := { toFun := fun h i => h.1 i.1 invFun := fun h' => ⟨fun i => if hi : P i then c i else h' ⟨i, hi⟩, fun i hi => by simp [hi]⟩ left_inv := fun h => by apply Subtype.ext; funext i by_cases hi : P i · simp [hi, h.2 i hi] · simp [hi] right_inv := fun h' => by funext i; simp [i.2] } rw [← Fintype.card_subtype, Fintype.card_congr e, Fintype.card_fun, Fintype.card_bool, Fintype.card_subtype]/-- general form: at a time `t ≥ t0` splitting the selected indices at `k` -/theorem pcm_general (T m t0 : ℕ) (idx : Fin m → Fin T) (hinc : StrictMono idx) (hafter : ∀ i, t0 ≤ (idx i).val) (f : (Fin T → Bool) → ℝ) (g : (Fin m → Bool) → ℝ) (r : Fin T → Bool) (hproj : ∀ s : Fin T → Bool, (∀ i : Fin T, i.val < t0 → s i = r i) → f s = g (fun i => s (idx i))) (t k : ℕ) (ht0 : t0 ≤ t) (htT : t ≤ T) (hkm : k ≤ m) (htk : ∀ j : Fin m, (idx j).val < t ↔ j.val < k) : (∑ b : Fin T → Bool, if ∀ i : Fin T, i.val < t → b i = r i then f b else 0) / (2 : ℝ) ^ (T-t) = (∑ b : Fin m → Bool, if ∀ i : Fin m, i.val < k → b i = r (idx i) then g b else 0) / (2 : ℝ) ^ (m-k) := by classical have hinj : Function.Injective idx := hinc.injective -- split the tape into the selected coordinates and the rest let C := {i : Fin T // i ∉ Set.range idx} let e : (Fin T → Bool) ≃ (Fin m → Bool) × (C → Bool) := (Equiv.piEquivPiSubtypeProd (fun i => i ∈ Set.range idx) (fun _ => Bool)).trans (Equiv.prodCongr (Equiv.arrowCongr (Equiv.ofInjective idx hinj).symm (Equiv.refl Bool)) (Equiv.refl _)) have he1 : ∀ b j, (e b).1 j = b (idx j) := by intro b j; rfl have he2 : ∀ b (i : C), (e b).2 i = b i.1 := by intro b i; rfl let ca : (Fin m → Bool) → Prop := fun a => ∀ i : Fin m, i.val < k → a i = r (idx i) let ch : (C → Bool) → Prop := fun h => ∀ i : C, i.1.val < t → h i = r i.1 have hsum : (∑ b : Fin T → Bool, if ∀ i : Fin T, i.val < t → b i = r i then f b else 0) = ∑ p : (Fin m → Bool) × (C → Bool), if ca p.1 ∧ ch p.2 then g p.1 else 0 := by refine Fintype.sum_equiv e _ _ (fun b => ?_) have hc : (∀ i : Fin T, i.val < t → b i = r i) ↔ (ca (e b).1 ∧ ch (e b).2) := by constructor · intro h refine ⟨fun j hj => ?_, fun i hi => ?_⟩ · rw [he1]; exact h _ ((htk j).2 hj) · rw [he2]; exact h _ hi · rintro ⟨h1, h2⟩ i hi by_cases hr : i ∈ Set.range idx · obtain ⟨j, rfl⟩ := hr have := h1 j ((htk j).1 hi) rw [he1] at this; exact this · have := h2 ⟨i, hr⟩ hi rw [he2] at this; exact this by_cases h : ∀ i : Fin T, i.val < t → b i = r i · rw [if_pos h, if_pos (hc.1 h)] rw [hproj b (fun i hi => h i (by omega))] congr 1 · rw [if_neg h, if_neg (fun h' => h (hc.2 h'))] rw [hsum, Fintype.sum_prod_type] have hinner : ∀ a : Fin m → Bool, (∑ h : C → Bool, if ca a ∧ ch h then g a else 0) = if ca a then g a * ((Finset.univ.filter fun h : C → Bool => ch h).card : ℝ) else 0 := by intro a by_cases ha : ca a · simp only [ha, true_and, if_true] rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_comm] · simp [ha] simp only [hinner] have hcard := pcm_card_agree (ι := C) (fun i => i.1.val < t) (fun i => r i.1) -- the number of free coordinates set N := (Finset.univ.filter fun i : C => ¬ i.1.val < t).card with hN have hNeq : N + (m - k) = T - t := by have h1 : (Finset.univ.filter fun i : Fin T => t ≤ i.val).card = T - t := by have : (Finset.univ.filter fun i : Fin T => t ≤ i.val) = (Finset.Ico t T).attachFin (fun x hx => (Finset.mem_Ico.mp hx).2) := by ext i; simp [Finset.mem_attachFin, Finset.mem_Ico, i.2] rw [this, Finset.card_attachFin, Nat.card_Ico] have h2 : (Finset.univ.filter fun i : Fin T => i ∈ Set.range idx ∧ t ≤ i.val).card = m - k := by have : (Finset.univ.filter fun i : Fin T => i ∈ Set.range idx ∧ t ≤ i.val) = (Finset.univ.filter fun j : Fin m => k ≤ j.val).map ⟨idx, hinj⟩ := by ext i simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_map, Function.Embedding.coeFn_mk, Set.mem_range] constructor · rintro ⟨⟨j, rfl⟩, hj⟩ exact ⟨j, by have := (htk j).not; push Not at this; exact this.1 hj, rfl⟩ · rintro ⟨j, hj, rfl⟩ exact ⟨⟨j, rfl⟩, by have := (htk j).not; push Not at this; exact this.2 hj⟩ rw [this, Finset.card_map] have : (Finset.univ.filter fun j : Fin m => k ≤ j.val) = (Finset.Ico k m).attachFin (fun x hx => (Finset.mem_Ico.mp hx).2) := by ext j; simp [Finset.mem_attachFin, Finset.mem_Ico, j.2] rw [this, Finset.card_attachFin, Nat.card_Ico] have h3 : N = (Finset.univ.filter fun i : Fin T => i ∉ Set.range idx ∧ t ≤ i.val).card := by rw [hN] apply Finset.card_bij (fun i _ => i.1) · intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and, not_lt] at hi ⊢ exact ⟨i.2, hi⟩ · intro i _ j _ h; exact Subtype.ext h · intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi exact ⟨⟨i, hi.1⟩, by simp [hi.2], rfl⟩ rw [h3, ← h1, ← h2] rw [← Finset.card_union_of_disjoint] · congr 1; ext i; simp only [Finset.mem_union, Finset.mem_filter, Finset.mem_univ, true_and] tauto · rw [Finset.disjoint_filter]; intro i _ h1 h2; exact h1.1 h2.1 rw [hcard] have hpow : (2:ℝ) ^ (T - t) = 2 ^ N * 2 ^ (m - k) := by rw [← pow_add, hNeq] rw [hpow] have h2N : (0:ℝ) < 2 ^ N := by positivity have h2k : (0:ℝ) < 2 ^ (m - k) := by positivity rw [div_eq_div_iff (by positivity) (by positivity)] rw [Finset.sum_mul, Finset.sum_mul] apply Finset.sum_congr rfl; intro a _ push_cast split_ifs <;> ringtheorem op2130_projected_conditional_means (T m t0 : ℕ) (ht0 : t0 ≤ T) (idx : Fin m → Fin T) (hinc : StrictMono idx) (hafter : ∀ i, t0 ≤ (idx i).val) (f : (Fin T → Bool) → ℝ) (g : (Fin m → Bool) → ℝ) (r : Fin T → Bool) (hproj : ∀ s : Fin T → Bool, (∀ i : Fin T, i.val < t0 → s i = r i) → f s = g (fun i => s (idx i))) (j : Fin m) : let Q : ℕ → (Fin T → Bool) → ℝ := fun t a => (∑ b : Fin T → Bool, if ∀ i : Fin T, i.val < t → b i = a i then f b else 0) / (2 : ℝ) ^ (T-t); let R : ℕ → (Fin m → Bool) → ℝ := fun t a => (∑ b : Fin m → Bool, if ∀ i : Fin m, i.val < t → b i = a i then g b else 0) / (2 : ℝ) ^ (m-t); Q (idx j).val r = R j.val (fun i => r (idx i)) ∧ Q ((idx j).val+1) r = R (j.val+1) (fun i => r (idx i)) := by intro Q R constructor · exact pcm_general T m t0 idx hinc hafter f g r hproj (idx j).val j.val (hafter j) (idx j).2.le j.2.le (fun j' => ⟨fun h => hinc.lt_iff_lt.mp h, fun h => hinc.lt_iff_lt.mpr h⟩) · exact pcm_general T m t0 idx hinc hafter f g r hproj ((idx j).val+1) (j.val+1) (by have := hafter j; omega) (idx j).2 j.2 (fun j' => by constructor · intro h have : idx j' ≤ idx j := Fin.le_def.mpr (by omega) have := hinc.le_iff_le.mp this exact Nat.lt_succ_of_le (Fin.le_def.mp this) · intro h have : j' ≤ j := Fin.le_def.mpr (by omega) have := hinc.le_iff_le.mpr this exact Nat.lt_succ_of_le (Fin.le_def.mp this))