@[instance]
Equations
- list.inhabited α = {default := list.nil α}
Equations
- list.has_dec_eq (a :: as) (b :: bs) = list.has_dec_eq._match_1 a as b bs (λ (hab : a = b), list.has_dec_eq as bs) (s a b)
- list.has_dec_eq (a :: as) list.nil = decidable.is_false _
- list.has_dec_eq list.nil (b :: bs) = decidable.is_false _
- list.has_dec_eq list.nil list.nil = decidable.is_true list.has_dec_eq._main._proof_1
- list.has_dec_eq._match_1 a as b bs _f_1 (decidable.is_true hab) = list.has_dec_eq._match_2 a as b bs hab (_f_1 hab)
- list.has_dec_eq._match_1 a as b bs _f_1 (decidable.is_false nab) = decidable.is_false _
- list.has_dec_eq._match_2 a as b bs hab (decidable.is_true habs) = decidable.is_true _
- list.has_dec_eq._match_2 a as b bs hab (decidable.is_false nabs) = decidable.is_false _
@[instance]
Equations
@[instance]
Equations
- list.has_append = {append := list.append α}
@[instance]
Equations
- list.has_mem = {mem := list.mem α}
@[instance]
Equations
- list.decidable_mem a (b :: l) = dite (a = b) (λ (h₁ : a = b), decidable.is_true _) (λ (h₁ : ¬a = b), list.decidable_mem._match_1 a b l h₁ (list.decidable_mem a l))
- list.decidable_mem a list.nil = decidable.is_false not_false
- list.decidable_mem._match_1 a b l h₁ (decidable.is_true h₂) = decidable.is_true _
- list.decidable_mem._match_1 a b l h₁ (decidable.is_false h₂) = decidable.is_false _
@[instance]
Equations
- list.has_emptyc = {emptyc := list.nil α}
Equations
- (a :: l).reverse_core r = l.reverse_core (a :: r)
- list.nil.reverse_core r = r
Equations
- list.reverse = λ (l : list α), l.reverse_core list.nil
@[simp]
Equations
- list.map_with_index_core f k (a :: as) = f k a :: list.map_with_index_core f (k + 1) as
- list.map_with_index_core f k list.nil = list.nil
Given a function f : ℕ → α → β
and as : list α
, as = [a₀, a₁, ...]
, returns the list
[f 0 a₀, f 1 a₁, ...]
.
Equations
- list.map_with_index f as = list.map_with_index_core f 0 as
Equations
- list.filter_map f (a :: l) = list.filter_map._match_1 (list.filter_map f l) (list.filter_map f l) (f a)
- list.filter_map f list.nil = list.nil
- list.filter_map._match_1 _f_1 _f_2 (option.some b) = b :: _f_2
- list.filter_map._match_1 _f_1 _f_2 option.none = _f_1
Equations
- list.filter p (a :: l) = ite (p a) (a :: list.filter p l) (list.filter p l)
- list.filter p list.nil = list.nil
Equations
- list.partition p (a :: l) = list.partition._match_1 p a (list.partition p l)
- list.partition p list.nil = (list.nil α, list.nil α)
- list.partition._match_1 p a (l₁, l₂) = ite (p a) (a :: l₁, l₂) (l₁, a :: l₂)
Equations
- list.drop_while p (a :: l) = ite (p a) (list.drop_while p l) (a :: l)
- list.drop_while p list.nil = list.nil
after p xs
is the suffix of xs
after the first element that satisfies
p
, not including that element.
lean
after (eq 1) [0, 1, 2, 3] = [2, 3]
drop_while (not ∘ eq 1) [0, 1, 2, 3] = [1, 2, 3]
Equations
- list.after p (x :: xs) = ite (p x) xs (list.after p xs)
- list.after p list.nil = list.nil
Equations
- list.find_index p (a :: l) = ite (p a) 0 (list.find_index p l).succ
- list.find_index p list.nil = 0
Equations
- list.index_of a = list.find_index (eq a)
Equations
- xs.remove_all ys = list.filter (λ (_x : α), _x ∉ ys) xs
Equations
- (x :: xs).update_nth (i + 1) a = x :: xs.update_nth i a
- (x :: xs).update_nth 0 a = a :: xs
- list.nil.update_nth _x _x_1 = list.nil
Equations
- (x :: xs).remove_nth (i + 1) = x :: xs.remove_nth i
- (x :: xs).remove_nth 0 = xs
- list.nil.remove_nth _x = list.nil
@[simp]
Equations
- list.foldl f a (b :: l) = list.foldl f (f a b) l
- list.foldl f a list.nil = a
@[simp]
Equations
- list.foldr f b (a :: l) = f a (list.foldr f b l)
- list.foldr f b list.nil = b
Equations
- list.zip_with f (x :: xs) (y :: ys) = f x y :: list.zip_with f xs ys
- list.zip_with f (hd :: tl) list.nil = list.nil
- list.zip_with f list.nil _x = list.nil
Equations
- list.insert a l = ite (a ∈ l) l (a :: l)
@[instance]
Equations
- list.has_insert = {insert := list.insert (λ (a b : α), _inst_1 a b)}
@[instance]
Equations
- list.has_singleton = {singleton := λ (x : α), [x]}
@[instance]
Equations
Equations
- l₁.union l₂ = list.foldr has_insert.insert l₂ l₁
@[instance]
Equations
- list.has_union = {union := list.union (λ (a b : α), _inst_1 a b)}
Equations
- l₁.inter l₂ = list.filter (λ (_x : α), _x ∈ l₂) l₁
@[instance]
Equations
- list.has_inter = {inter := list.inter (λ (a b : α), _inst_1 a b)}
@[simp]
Equations
- list.repeat a n.succ = a :: list.repeat a n
- list.repeat a 0 = list.nil
Equations
- list.range_core n.succ l = list.range_core n (n :: l)
- list.range_core 0 l = l
Equations
- list.enum_from n (x :: xs) = (n, x) :: list.enum_from (n + 1) xs
- list.enum_from n list.nil = list.nil
Equations
- list.intersperse sep (x :: hd :: tl) = x :: sep :: list.intersperse sep (hd :: tl)
- list.intersperse sep [x] = [x]
- list.intersperse sep list.nil = list.nil
Equations
- sep.intercalate xs = (list.intersperse sep xs).join
@[instance]
Equations
- list.has_lt = {lt := list.lt _inst_1}
@[instance]
Equations
- (a :: as).has_decidable_lt (b :: bs) = list.has_decidable_lt._match_1 a as b bs (λ (h₁ : ¬a < b) (h₂ : ¬b < a), as.has_decidable_lt bs) (h a b)
- (a :: as).has_decidable_lt list.nil = decidable.is_false not_false
- list.nil.has_decidable_lt (b :: bs) = decidable.is_true trivial
- list.nil.has_decidable_lt list.nil = decidable.is_false not_false
- list.has_decidable_lt._match_1 a as b bs _f_1 (decidable.is_true h₁) = decidable.is_true _
- list.has_decidable_lt._match_1 a as b bs _f_1 (decidable.is_false h₁) = list.has_decidable_lt._match_2 a as b bs h₁ (λ (h₂ : ¬b < a), _f_1 h₁ h₂) (h b a)
- list.has_decidable_lt._match_2 a as b bs h₁ _f_1 (decidable.is_true h₂) = decidable.is_false _
- list.has_decidable_lt._match_2 a as b bs h₁ _f_1 (decidable.is_false h₂) = list.has_decidable_lt._match_4 a as b bs h₁ h₂ (_f_1 h₂)
- list.has_decidable_lt._match_4 a as b bs h₁ h₂ (decidable.is_true h₃) = decidable.is_true _
- list.has_decidable_lt._match_4 a as b bs h₁ h₂ (decidable.is_false h₃) = decidable.is_false _
@[instance]
Equations
- list.has_le = {le := list.le _inst_1}
@[instance]
Equations
- list.has_decidable_le = λ (a b : list α), not.decidable
is_prefix_of l₁ l₂
returns tt
iff l₁
is a prefix of l₂
.
Equations
- (a :: as).is_prefix_of (b :: bs) = decidable.to_bool (a = b) && as.is_prefix_of bs
- (hd :: tl).is_prefix_of list.nil = bool.ff
- list.nil.is_prefix_of (hd :: tl) = bool.tt
- list.nil.is_prefix_of list.nil = bool.tt
is_suffix_of l₁ l₂
returns tt
iff l₁
is a suffix of l₂
.
Equations
- l₁.is_suffix_of l₂ = l₁.reverse.is_prefix_of l₂.reverse