Cslib.Algorithms.Lean.TimeM.some_algebra
theoremverifiedformalizationimported Lean
Cslib.Algorithms.Lean.TimeM.some_algebra
Statement
set_option relaxedAutoImplicit true in set_option autoImplicit false in variable {α : Type} [LinearOrder α] in open Nat (clog) in lemma Cslib.Algorithms.Lean.TimeM.some_algebra (n : ℕ) : (n / 2 + 1) * clog 2 (n / 2 + 1) + ((n + 1) / 2 + 1) * clog 2 ((n + 1) / 2 + 1) + (n + 2) ≤ (n + 2) * clog 2 (n + 2)
- Formalizes
- CSLib, `Cslib.Algorithms.Lean.TimeM.some_algebra`
- Lean proof
- By Sorrachai Yingchareonthawornhcai, from github.com/leanprover/cslib at
3951377e5a3f(Copyright (c) 2025 Sorrachai Yingchareonthawornhcai. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.33.0.Cslib.Algorithms.Lean.TimeM.some_algebra← Cslib.Algorithms.Lean.TimeM.some_algebra (Cslib/Algorithms/Lean/MergeSort/MergeSort.lean:141): verbatim
- Verified
- 08 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- Cslib.Algorithms.Lean.TimeM.clog2_half_leKey Lemma: ⌈log2 ⌈n/2⌉⌉ ≤ ⌈log2 n⌉ - 1 for n > 1
- Cslib.Algorithms.Lean.TimeM.clog2_floor_half_leSame logic for the floor half: ⌈log2 ⌊n/2⌋⌉ ≤ ⌈log2 n⌉ - 1
- Used by 1
- Cslib.Algorithms.Lean.TimeM.timeMergeSortRec_leSolve the recurrence
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.
set_option relaxedAutoImplicit true inset_option autoImplicit false invariable {α : Type} [LinearOrder α] inopen Nat (clog) inlemma Cslib.Algorithms.Lean.TimeM.some_algebra (n : ℕ) : (n / 2 + 1) * clog 2 (n / 2 + 1) + ((n + 1) / 2 + 1) * clog 2 ((n + 1) / 2 + 1) + (n + 2) ≤ (n + 2) * clog 2 (n + 2) := by -- 1. Substitution: Let N = n_1 + 2 to clean up the expression let N := n + 2 have hN : N ≥ 2 := by omega -- 2. Rewrite the terms using N have t1 : n / 2 + 1 = N / 2 := by omega have t2 : (n + 1) / 2 + 1 = (N + 1) / 2 := by omega have t3 : n + 1 + 1 = N := by omega let k := clog 2 N have h_bound_l : clog 2 (N / 2) ≤ k - 1 := clog2_floor_half_le N hN have h_bound_r : clog 2 ((N + 1) / 2) ≤ k - 1 := clog2_half_le N hN have h_split : N / 2 + (N + 1) / 2 = N := by omega grw [t1, t2, t3, h_bound_l, h_bound_r, ←Nat.add_mul, h_split] exact Nat.le_refl (N * (k - 1) + N)