Built with
doc-gen4 , running Lean4.
Bubbles (
) indicate interactive fragments: hover for details, tap to reveal contents.
Use
Ctrl+β Ctrl+β to navigate,
Ctrl+π±οΈ to focus.
On Mac, use
Cmd instead of
Ctrl .
import Mathlib.Tactic.Linarith.Frontend
import Mathlib.Tactic.LibrarySearch
import Mathlib.Tactic.ClearExcept
import Mathlib.Data.List.Basic
import Mathlib.Data.String.Lemmas
/-!
## Basic lemmas about built-in types
-/
lemma List.fold_max_max_eq_max_fold_max :
β { a b : β }, List.foldl : {Ξ± : Type ?u.82} β {Ξ² : Type ?u.81} β (Ξ± β Ξ² β Ξ± ) β Ξ± β List Ξ² β Ξ± List.foldl max : {Ξ± : Type ?u.85} β [self : Max Ξ± ] β Ξ± β Ξ± β Ξ± max ( max : {Ξ± : Type ?u.117} β [self : Max Ξ± ] β Ξ± β Ξ± β Ξ± max a b ) xs = max : {Ξ± : Type ?u.133} β [self : Max Ξ± ] β Ξ± β Ξ± β Ξ± max a ( List.foldl : {Ξ± : Type ?u.137} β {Ξ² : Type ?u.136} β (Ξ± β Ξ² β Ξ± ) β Ξ± β List Ξ² β Ξ± List.foldl max : {Ξ± : Type ?u.140} β [self : Max Ξ± ] β Ξ± β Ξ± β Ξ± max b xs ) := by {
induction xs
case nil => simp
case cons ih => simp [ ih , max_assoc ]
}
lemma List.get_index_eq : β {Ξ± : Type u_1} {xs : List Ξ± } {i j : β } (hi : i < length xs ),
i = j β β hj , get xs { val := i , isLt := hi } = get xs { val := j , isLt := hj } List.get_index_eq { xs : List Ξ± } { i j : β } ( hi : i < xs . length ) ( h : i = j ) :
β ( hj : j < xs . length ), xs . get β¨ i , hi β© = xs . get β¨ j , hj β© := by
β hj , get xs { val := i , isLt := hi } = get xs { val := j , isLt := hj } simp [ h ] at hi β hj , get xs { val := i , isLt := hiβ } = get xs { val := j , isLt := hj }
β hj , get xs { val := i , isLt := hi } = get xs { val := j , isLt := hj } exists hi get xs { val := i , isLt := hiβ } = get xs { val := j , isLt := hi }
β hj , get xs { val := i , isLt := hi } = get xs { val := j , isLt := hj } simp [ h ]
lemma List.get_zero_eq_head : β {Ξ± : Type u_1} {xs : List Ξ± } (hn : xs β [] ), get xs { val := 0 , isLt := (_ : 0 < length xs ) } = head xs hn List.get_zero_eq_head { xs : List Ξ± } ( hn : xs β [] ) :
xs . get β¨ 0 , by { cases xs nil Ξ± : Type ?u.24015headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons ; nil Ξ± : Type ?u.24015headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons contradiction Ξ± : Type ?u.24015headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons ; Ξ± : Type ?u.24015headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons simp } β© = xs . head : {Ξ± : Type ?u.24048} β (as : List Ξ± ) β as β [] β Ξ± head hn := by
cases xs nil Ξ± : Type u_1headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons get (headβ :: tailβ ) { val := 0 , isLt := (_ : 0 < length (headβ :: tailβ ) ) } = head (headβ :: tailβ ) hn ; nil Ξ± : Type u_1headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons get (headβ :: tailβ ) { val := 0 , isLt := (_ : 0 < length (headβ :: tailβ ) ) } = head (headβ :: tailβ ) hn contradiction Ξ± : Type u_1headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons get (headβ :: tailβ ) { val := 0 , isLt := (_ : 0 < length (headβ :: tailβ ) ) } = head (headβ :: tailβ ) hn ; Ξ± : Type u_1headβ : Ξ± tailβ : List Ξ± hn : headβ :: tailβ β [] cons get (headβ :: tailβ ) { val := 0 , isLt := (_ : 0 < length (headβ :: tailβ ) ) } = head (headβ :: tailβ ) hn simp
lemma Nat.not_lt_of_lt : β {a b : β }, a < b β Β¬ b < a Nat.not_lt_of_lt { a b : β } ( h : a < b ): Β¬ b < a := by linarith
lemma Nat.mul_lt_mulβ : β {a b c d : β }, a < c β b < d β a * b < c * d Nat.mul_lt_mulβ { a b c d : Nat } ( h1 : a < c ) ( h2 : b < d ) : a * b < c * d :=
match b with
| 0 =>
match c with
| 0 => match h1 with .
| c +1 => by simp [ h2 ]
| b +1 => Nat.mul_lt_mul : β {a c b d : β }, a < c β b β€ d β 0 < b β a * b < c * d Nat.mul_lt_mul h1 ( Nat.le_of_lt : β {n m : β }, n < m β n β€ m Nat.le_of_lt h2 ) ( by simp )
lemma Nat.sub_lt_sub_right : β {a b c : β }, a < b β c β€ a β a - c < b - c Nat.sub_lt_sub_right { a b c : Nat } ( h0 : a < b ) ( h1 : c β€ a ) :
a - c < b - c := by {
induction c
case zero =>
simpa
case succ ih =>
simp [ Nat.sub_succ ]
apply Nat.pred_lt_pred
. simp
linarith
. apply ih
linarith
}
lemma Nat.sub_sub_eq : β {a b c : β }, a β€ b β c + a - b = c - (b - a ) Nat.sub_sub_eq { a b c : Nat } ( h : a β€ b ) : c + a - b = c - ( b - a ) := by {
let β¨ k , h' β© := Nat.le.dest : β {n m : β }, n β€ m β β k , n + k = m Nat.le.dest h
rw [ β h' ]
simp [ Nat.sub_add_eq : β (a b c : β ), a - (b + c ) = a - b - c Nat.sub_add_eq]
}