/-- Show that any decision tree with at least `4! = 24` leaves has height at least `5`.
Hint: apply `sorting_lower_bound`, then argue by contradiction: if the height were at most `4`,
then `2 ^ height ≤ 2 ^ 4 = 16 < 24` (`Nat.pow_le_pow_right`, then `omega`). -/
theorem four_items_need_five (t : DecisionTree) (h : (4 : ℕ).factorial ≤ t.leaves) :
5 ≤ t.height := by
sorryShow the compiled solution
/-- Sorting `4` items needs at least `5` comparisons in the worst case: `4! = 24 > 16 = 2⁴`.
(Five comparisons suffice: mergesort uses at most `5` on four items.) -/
theorem four_items_need_five (t : DecisionTree) (h : (4 : ℕ).factorial ≤ t.leaves) :
5 ≤ t.height := by
have h2 := sorting_lower_bound 4 t h
by_contra hlt
rw [not_le] at hlt
have : 2 ^ t.height ≤ 2 ^ 4 := Nat.pow_le_pow_right (by norm_num) (by omega)
have h4 : (4 : ℕ).factorial = 24 := rfl
omegaAxioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AlgorithmDesign.leanTry it in the Lean web editor