index_combine
defimported Lean
Combine a block/index pair (i, j) back into a flat index.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open Filter in variable {I : Type*} [Fintype I] [DecidableEq I] [Inhabited I] [LinearOrder I] (card : I → ℕ+) in noncomputable def index_combine (p : Σ i, Fin (card i)) : Fin (total_card card)
- Defined in
- EconCSLib, `index_combine`
- Lean proof
- By xbei (from the file's git history), from github.com/gametheoryinlean/EconCSLib at
1a88f809b538(Copyright (c) 2026 EconCSLib contributors. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.30.0.index_combine← index_combine (EconCSLib/Math/FixedPoint/Brouwer_product.lean:165): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 2
- prefix_sumCumulative sum of
cardover indices strictly less thani. - total_cardTotal number of coordinates: the sum of
card iover alli.
- prefix_sumCumulative sum of
- Used by 10
- blockSum_continuousContinuity of
blockSum card i. - embed_from_productEmbedding of the product of simplices into the big simplex.
- blockSum_pushTowardsZ_formulaThe block sum after pushing towards
z_uniformfollows a linear formula. - project_to_productRetraction from the big simplex to the product of simplices.
- blockSumSum of coordinates of
xover the blocki. - index_split_combine_inverse
index_splitis a left inverse toindex_combine. - project_embed_id
project_to_product ∘ embed_from_product = id. - index_combine_split_inverse
index_combineis a left inverse toindex_split. - blockSum_nonneg
blockSum card i xis always nonnegative. - project_continuousContinuity of
project_to_product.
- blockSum_continuousContinuity of
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in open Filter in variable {I : Type*} [Fintype I] [DecidableEq I] [Inhabited I] [LinearOrder I] (card : I → ℕ+) in /-- Combine a block/index pair `(i, j)` back into a flat index. -/ noncomputable def index_combine (p : Σ i, Fin (card i)) : Fin (total_card card) := ⟨prefix_sum card p.1 + (p.2 : ℕ), by have h1 : prefix_sum card p.1 + (p.2 : ℕ) < prefix_sum card p.1 + (card p.1 : ℕ) := by simp only [add_lt_add_iff_left] exact p.2.is_lt have h2 : prefix_sum card p.1 + (card p.1 : ℕ) ≤ (total_card card : ℕ) := by simp only [prefix_sum, total_card] have h_subset : Finset.univ.filter (· ≤ p.1) ⊆ Finset.univ := Finset.filter_subset _ _ have h_eq : (Finset.univ.filter (· ≤ p.1)).sum (fun j => (card j : ℕ)) = (Finset.univ.filter (· < p.1)).sum (fun j => (card j : ℕ)) + (card p.1 : ℕ) := by have h_split : Finset.univ.filter (· ≤ p.1) = Finset.univ.filter (· < p.1) ∪ {p.1} := by ext j; simp [Finset.mem_filter, le_iff_lt_or_eq, or_comm] have h_disj : Disjoint (Finset.univ.filter (· < p.1)) {p.1} := by simp rw [h_split, Finset.sum_union h_disj, Finset.sum_singleton] rw [← h_eq] exact Finset.sum_le_sum_of_subset_of_nonneg h_subset (fun _ _ _ => by positivity) exact lt_of_lt_of_le h1 h2⟩