theorem
List.length_add_eq_lengthTRAux
{α : Type u}
(as : List α)
(n : Nat)
:
List.length as + n = List.lengthTRAux as n
Equations
- List.reverseAux [] x = x
- List.reverseAux (a :: l) x = List.reverseAux l (a :: x)
Equations
- List.reverse as = List.reverseAux as []
theorem
List.reverseAux_reverseAux_nil
{α : Type u}
(as : List α)
(bs : List α)
:
List.reverseAux (List.reverseAux as bs) [] = List.reverseAux bs as
theorem
List.reverseAux_reverseAux
{α : Type u}
(as : List α)
(bs : List α)
(cs : List α)
:
List.reverseAux (List.reverseAux as bs) cs = List.reverseAux bs (List.reverseAux (List.reverseAux as []) cs)
@[simp]
Equations
- List.append [] x = x
- List.append (a :: l) x = a :: List.append l x
Equations
- List.appendTR as bs = List.reverseAux (List.reverse as) bs
Equations
- List.instAppendList = { append := List.append }
Equations
- List.instEmptyCollectionList = { emptyCollection := [] }
Equations
- List.erase [] x = []
- List.erase (a :: as) x = match a == x with | true => as | false => a :: List.erase as x
Equations
- List.eraseIdx [] x = []
- List.eraseIdx (a :: as) 0 = as
- List.eraseIdx (a :: as) (Nat.succ n) = a :: List.eraseIdx as n
Equations
- List.isEmpty x = match x with | [] => true | x :: x_1 => false
@[specialize]
Equations
- List.mapTRAux f [] x = List.reverse x
- List.mapTRAux f (a :: as) x = List.mapTRAux f as (f a :: x)
@[inline]
Equations
- List.mapTR f as = List.mapTRAux f as []
theorem
List.reverseAux_eq_append
{α : Type u}
(as : List α)
(bs : List α)
:
List.reverseAux as bs = List.reverseAux as [] ++ bs
@[simp]
theorem
List.reverse_cons
{α : Type u}
(a : α)
(as : List α)
:
List.reverse (a :: as) = List.reverse as ++ [a]
@[simp]
theorem
List.reverse_append
{α : Type u}
(as : List α)
(bs : List α)
:
List.reverse (as ++ bs) = List.reverse bs ++ List.reverse as
theorem
List.mapTRAux_eq
{α : Type u}
{β : Type v}
(f : α → β)
(as : List α)
(bs : List β)
:
List.mapTRAux f as bs = List.reverse bs ++ List.map f as
@[specialize]
Equations
- List.filterMap f [] = []
- List.filterMap f (x_1 :: x_2) = match f x_1 with | none => List.filterMap f x_2 | some b => b :: List.filterMap f x_2
@[specialize]
Equations
- List.filterAux p [] x = List.reverse x
- List.filterAux p (a :: l) x = match p a with | true => List.filterAux p l (a :: x) | false => List.filterAux p l x
@[inline]
Equations
- List.filter p as = List.filterAux p as []
@[specialize]
Equations
- List.partitionAux p [] (bs, cs) = (List.reverse bs, List.reverse cs)
- List.partitionAux p (a :: as) (bs, cs) = match p a with | true => List.partitionAux p as (a :: bs, cs) | false => List.partitionAux p as (bs, a :: cs)
@[inline]
Equations
- List.partition p as = List.partitionAux p as ([], [])
Equations
- List.dropWhile p [] = []
- List.dropWhile p (x_1 :: x_2) = match p x_1 with | true => List.dropWhile p x_2 | false => x_1 :: x_2
Equations
- List.find? p [] = none
- List.find? p (x_1 :: x_2) = match p x_1 with | true => some x_1 | false => List.find? p x_2
Equations
- List.findSome? f [] = none
- List.findSome? f (x_1 :: x_2) = match f x_1 with | some b => some b | none => List.findSome? f x_2
Equations
- List.replace [] x x = []
- List.replace (a :: as) x x = match a == x with | true => x :: as | false => a :: List.replace as x x
Equations
- List.notElem a as = !List.elem a as
@[inline]
Equations
- List.contains as a = List.elem a as
Equations
- List.eraseDupsAux [] x = List.reverse x
- List.eraseDupsAux (a :: l) x = match List.elem a x with | true => List.eraseDupsAux l x | false => List.eraseDupsAux l (a :: x)
Equations
- List.eraseDups as = List.eraseDupsAux as []
Equations
- List.eraseRepsAux x [] x = List.reverse (x :: x)
- List.eraseRepsAux x (a' :: as) x = match x == a' with | true => List.eraseRepsAux x as x | false => List.eraseRepsAux a' as (x :: x)
Equations
- List.eraseReps x = match x with | [] => [] | a :: as => List.eraseRepsAux a as []
@[specialize]
Equations
- List.spanAux p [] x = (List.reverse x, [])
- List.spanAux p (a :: l) x = match p a with | true => List.spanAux p l (a :: x) | false => (List.reverse x, a :: l)
@[specialize]
Equations
- List.groupByAux eq (a :: as) ((ag :: g) :: gs) = match eq a ag with | true => List.groupByAux eq as ((a :: ag :: g) :: gs) | false => List.groupByAux eq as ([a] :: List.reverse (ag :: g) :: gs)
- List.groupByAux eq x x = List.reverse x
@[specialize]
Equations
- List.groupBy p x = match x with | [] => [] | a :: as => List.groupByAux p as [[a]]
Equations
- List.lookup x [] = none
- List.lookup x ((k, b) :: es) = match x == k with | true => some b | false => List.lookup x es
Equations
- List.removeAll xs ys = List.filter (fun x => List.notElem x ys) xs
Equations
- List.takeWhile p [] = []
- List.takeWhile p (x_1 :: x_2) = match p x_1 with | true => x_1 :: List.takeWhile p x_2 | false => []
@[specialize]
Equations
- List.foldr f init [] = init
- List.foldr f init (x_1 :: x_2) = f x_1 (List.foldr f init x_2)
Equations
- List.zipWith f (x_2 :: xs) (y :: ys) = f x_2 y :: List.zipWith f xs ys
- List.zipWith f x x = []
Equations
- List.unzip [] = ([], [])
- List.unzip ((a, b) :: t) = (a :: (List.unzip t).1, b :: (List.unzip t).2)
Equations
- List.rangeAux 0 x = x
- List.rangeAux (Nat.succ n) x = List.rangeAux n (n :: x)
Equations
- List.enumFrom x [] = []
- List.enumFrom x (x_2 :: xs) = (x, x_2) :: List.enumFrom (x + 1) xs
Equations
- List.intersperse sep [] = []
- List.intersperse sep [a] = [a]
- List.intersperse sep (a :: l) = a :: sep :: List.intersperse sep l
Equations
- List.intercalate sep xs = List.join (List.intersperse sep xs)
- nil: ∀ {α : Type u} [inst : LT α] (b : α) (bs : List α), List.lt [] (b :: bs)
- head: ∀ {α : Type u} [inst : LT α] {a : α} (as : List α) {b : α} (bs : List α), a < b → List.lt (a :: as) (b :: bs)
- tail: ∀ {α : Type u} [inst : LT α] {a : α} {as : List α} {b : α} {bs : List α}, ¬a < b → ¬b < a → List.lt as bs → List.lt (a :: as) (b :: bs)
instance
List.hasDecidableLt
{α : Type u}
[inst : LT α]
[h : DecidableRel fun a a_1 => a < a_1]
(l₁ : List α)
(l₂ : List α)
:
Equations
- List.hasDecidableLt [] [] = isFalse (_ : [] < [] → False)
- List.hasDecidableLt [] (b :: bs) = isTrue (_ : List.lt [] (b :: bs))
- List.hasDecidableLt (a :: as) [] = isFalse (_ : a :: as < [] → False)
- List.hasDecidableLt (a :: as) (b :: bs) = match h a b with | isTrue h₁ => isTrue (_ : List.lt (a :: as) (b :: bs)) | isFalse h₁ => match h b a with | isTrue h₂ => isFalse (_ : a :: as < b :: bs → False) | isFalse h₂ => match List.hasDecidableLt as bs with | isTrue h₃ => isTrue (_ : List.lt (a :: as) (b :: bs)) | isFalse h₃ => isFalse (_ : a :: as < b :: bs → False)
instance
List.instForAllListDecidableLeInstLEList
{α : Type u}
[inst : LT α]
[h : DecidableRel fun a a_1 => a < a_1]
(l₁ : List α)
(l₂ : List α)
:
Equations
Equations
- List.isPrefixOf [] x = true
- List.isPrefixOf x [] = false
- List.isPrefixOf (a :: as) (b :: bs) = (a == b && List.isPrefixOf as bs)
Equations
- List.isSuffixOf l₁ l₂ = List.isPrefixOf (List.reverse l₁) (List.reverse l₂)
@[specialize]
Equations
- List.isEqv [] [] x = true
- List.isEqv (a :: as) (b :: bs) x = (x a b && List.isEqv as bs x)
- List.isEqv x x x = false
Equations
- List.replicate 0 x = []
- List.replicate (Nat.succ n) x = x :: List.replicate n x
Equations
- List.replicateTR n a = (fun loop => loop n []) (List.replicateTR.loop a)
Equations
- List.replicateTR.loop a 0 x = x
- List.replicateTR.loop a (Nat.succ n) x = List.replicateTR.loop a n (a :: x)
theorem
List.replicateTR_loop_replicate_eq
{α : Type u}
(a : α)
(m : Nat)
(n : Nat)
:
List.replicateTR.loop a n (List.replicate m a) = List.replicate (n + m) a
Equations
- List.dropLast [] = []
- List.dropLast [a] = []
- List.dropLast (a :: l) = a :: List.dropLast l
@[simp]
@[simp]
theorem
List.length_concat
{α : Type u}
(as : List α)
(a : α)
:
List.length (List.concat as a) = List.length as + 1
@[simp]
theorem
List.length_set
{α : Type u}
(as : List α)
(i : Nat)
(a : α)
:
List.length (List.set as i a) = List.length as
@[simp]
theorem
List.length_dropLast
{α : Type u}
(as : List α)
:
List.length (List.dropLast as) = List.length as - 1
@[simp]
theorem
List.length_append
{α : Type u}
(as : List α)
(bs : List α)
:
List.length (as ++ bs) = List.length as + List.length bs
@[simp]
theorem
List.length_reverse
{α : Type u}
(as : List α)
:
List.length (List.reverse as) = List.length as
Equations
- List.maximum? x = match x with | [] => none | a :: as => some (List.foldl max a as)
Equations
- List.minimum? x = match x with | [] => none | a :: as => some (List.foldl min a as)