@[protected, instance]
Equations
- list.inhabited α = {default := list.nil α}
@[protected]
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 = is_false _
- list.has_dec_eq list.nil (b :: bs) = is_false _
- list.has_dec_eq list.nil list.nil = is_true list.has_dec_eq._main._proof_1
- list.has_dec_eq._match_1 a as b bs _f_1 (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 (is_false nab) = is_false _
- list.has_dec_eq._match_2 a as b bs hab (is_true habs) = is_true _
- list.has_dec_eq._match_2 a as b bs hab (is_false nabs) = is_false _
@[protected, instance]
Equations
@[protected, instance]
Equations
- list.has_append = {append := list.append α}
@[protected, instance]
Equations
- list.has_mem = {mem := list.mem α}
@[protected, instance]
Equations
- list.decidable_mem a (b :: l) = dite (a = b) (λ (h₁ : a = b), 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 = is_false not_false
- list.decidable_mem._match_1 a b l h₁ (is_true h₂) = is_true _
- list.decidable_mem._match_1 a b l h₁ (is_false h₂) = is_false _
@[protected, instance]
Equations
- list.has_emptyc = {emptyc := list.nil α}
@[protected]
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 (some b) = b :: _f_2
- list.filter_map._match_1 _f_1 _f_2 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.
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
@[protected]
Equations
- list.insert a l = ite (a ∈ l) l (a :: l)
@[protected, instance]
Equations
- list.has_insert = {insert := list.insert (λ (a b : α), _inst_1 a b)}
@[protected, instance]
Equations
- list.has_singleton = {singleton := λ (x : α), [x]}
@[protected, instance]
@[protected]
Equations
- l₁.union l₂ = list.foldr insert l₂ l₁
@[protected, instance]
Equations
- list.has_union = {union := list.union (λ (a b : α), _inst_1 a b)}
@[protected]
Equations
- l₁.inter l₂ = list.filter (λ (_x : α), _x ∈ l₂) l₁
@[protected, 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
@[protected, instance]
Equations
- list.has_lt = {lt := list.lt _inst_1}
@[protected, 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 = is_false not_false
- list.nil.has_decidable_lt (b :: bs) = is_true trivial
- list.nil.has_decidable_lt list.nil = is_false not_false
- list.has_decidable_lt._match_1 a as b bs _f_1 (is_true h₁) = is_true _
- list.has_decidable_lt._match_1 a as b bs _f_1 (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 (is_true h₂) = is_false _
- list.has_decidable_lt._match_2 a as b bs h₁ _f_1 (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₂ (is_true h₃) = is_true _
- list.has_decidable_lt._match_4 a as b bs h₁ h₂ (is_false h₃) = is_false _
@[protected, instance]
Equations
- list.has_le = {le := list.le _inst_1}
@[protected, 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) = to_bool (a = b) && as.is_prefix_of bs
- (hd :: tl).is_prefix_of list.nil = ff
- list.nil.is_prefix_of (hd :: tl) = tt
- list.nil.is_prefix_of list.nil = 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