Documentation

Cedar.Thm.Data.List.Basic

List properties #

This file contains useful custom definitions and lemmas about Lists.

Equiv #

def List.Equiv {α : Type u_1} (a b : List α) :
Equations
Instances For
    theorem List.Equiv.refl {α : Type u_1} {a : List α} :
    a a
    theorem List.Equiv.symm {α : Type u_1} {a b : List α} :
    a bb a
    theorem List.Equiv.trans {α : Type u_1} {a b c : List α} :
    a bb ca c
    theorem List.equiv_nil {α : Type u_1} (xs : List α) :
    xs [] xs = []
    theorem List.cons_equiv_cons {α : Type u_1} (x : α) (xs ys : List α) :
    xs ysx :: xs x :: ys
    theorem List.cons_equiv_implies_equiv {α : Type u_1} (x : α) (xs ys : List α) :
    x :: xs x :: ys¬x xs¬x ysxs ys
    theorem List.dup_head_equiv {α : Type u_1} (x : α) (xs : List α) :
    x :: x :: xs x :: xs
    theorem List.dup_head_equiv' {α : Type u_1} {x : α} {xs : List α} :
    x xsx :: xs xs
    theorem List.swap_cons_cons_equiv {α : Type u_1} (x₁ x₂ : α) (xs : List α) :
    x₁ :: x₂ :: xs x₂ :: x₁ :: xs
    theorem List.filter_equiv {α : Type u_1} (f : αBool) (xs ys : List α) :
    xs ysfilter f xs filter f ys
    theorem List.map_equiv {α : Type u_1} {β : Type u_2} (f : αβ) (xs ys : List α) :
    xs ysmap f xs map f ys
    theorem List.filterMap_equiv {α : Type u_1} {β : Type u_2} (f : αOption β) (xs ys : List α) :
    xs ysfilterMap f xs filterMap f ys
    theorem List.append_swap_equiv {α : Type u_1} (xs ys : List α) :
    xs ++ ys ys ++ xs
    theorem List.append_left_equiv {α : Type u_1} (xs ys zs : List α) :
    xs ysxs ++ zs ys ++ zs
    theorem List.append_right_equiv {α : Type u_1} (xs ys zs : List α) :
    ys zsxs ++ ys xs ++ zs

    Sorted #

    inductive List.SortedBy {β : Type u_1} {α : Type u_2} [LT β] (f : αβ) :
    List αProp
    Instances For
      @[reducible, inline]
      abbrev List.Sorted {α : Type u_1} [LT α] (xs : List α) :
      Equations
      Instances For
        theorem List.tail_sortedBy {β : Type u_1} {α : Type u_2} [LT β] {f : αβ} {x : α} {xs : List α} :
        SortedBy f (x :: xs)SortedBy f xs
        theorem List.sortedBy_implies_head_lt_tail {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] {f : αβ} {x : α} {xs : List α} :
        SortedBy f (x :: xs)∀ (y : α), y xsf x < f y
        theorem List.sortedBy_equiv_implies_head_eq {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] (f : αβ) {x y : α} {xs ys : List α} :
        SortedBy f (x :: xs)SortedBy f (y :: ys)x :: xs y :: ysx = y
        theorem List.sortedBy_equiv_implies_tail_subset {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] (f : αβ) {x : α} {xs ys : List α} :
        SortedBy f (x :: xs)SortedBy f (x :: ys)x :: xs x :: ysxs ys
        theorem List.sortedBy_equiv_implies_tail_equiv {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] (f : αβ) {x : α} {xs ys : List α} :
        SortedBy f (x :: xs)SortedBy f (x :: ys)x :: xs x :: ysxs ys
        theorem List.sortedBy_equiv_implies_eq {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] (f : αβ) {xs ys : List α} :
        SortedBy f xsSortedBy f ysxs ysxs = ys
        theorem List.sortedBy_cons {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] {f : αβ} {x : α} {ys : List α} :
        SortedBy f ys(∀ (y : α), y ysf x < f y)SortedBy f (x :: ys)
        theorem List.mem_of_sortedBy_unique {α : Type u_1} {β : Type u_2} [LT β] [Cedar.Data.StrictLT β] [DecidableLT β] [DecidableEq β] {f : αβ} {x y : α} {xs : List α} :
        SortedBy f xsx xsy xsf x = f yx = y
        theorem List.mem_of_sortedBy_implies_find? {α : Type u_1} {β : Type u_2} [LT β] [Cedar.Data.StrictLT β] [DecidableLT β] [DecidableEq β] {f : αβ} {x : α} {xs : List α} :
        x xsSortedBy f xsfind? (fun (y : α) => f y == f x) xs = some x
        theorem List.map_eq_implies_sortedBy {β : Type u_1} {α : Type u_2} {γ : Type u_3} [LT β] [Cedar.Data.StrictLT β] {f : αβ} {g : γβ} {xs : List α} {ys : List γ} :
        map f xs = map g ys → (SortedBy f xs SortedBy g ys)
        theorem List.filter_sortedBy {β : Type u_1} {α : Type u_2} [LT β] [Cedar.Data.StrictLT β] [DecidableLT β] {f : αβ} (p : αBool) {xs : List α} :
        SortedBy f xsSortedBy f (filter p xs)
        theorem List.filterMap_sortedBy {β : Type u_1} {α : Type u_2} {γ : Type u_3} [LT β] [Cedar.Data.StrictLT β] [DecidableLT β] {f : αβ} {g : αOption γ} {f' : γβ} {xs : List α} :
        (∀ (x : α) (y : γ), g x = some yf x = f' y)SortedBy f xsSortedBy f' (filterMap g xs)
        theorem List.filterMap_key_id_sortedBy_key {α β : Type} [LT α] [Cedar.Data.StrictLT α] [DecidableLT α] {ks : List α} {fn : αOption β} (hs : ks.Sorted) :
        SortedBy Prod.fst (filterMap (fun (k : α) => do let __do_liftfn k some (k, __do_lift)) ks)
        theorem List.find?_filterMap_key_id {α β : Type} [BEq α] [LawfulBEq α] {ks : List α} {fn : αOption β} {k : α} (h₂ : k ks) :
        Option.map Prod.snd (find? (fun (x : α × β) => match x with | (k', snd) => k' == k) (filterMap (fun (k : α) => do let __do_liftfn k some (k, __do_lift)) ks)) = fn k
        theorem List.mapM_key_id_sortedBy_key {α β : Type} [LT α] {ks : List α} {kvs : List (α × β)} {fn : αOption β} (hm : mapM (fun (k : α) => do let __do_liftfn k some (k, __do_lift)) ks = some kvs) (hs : ks.Sorted) :
        theorem List.isSortedBy_correct {α : Type u_1} {β : Type u_2} [LT β] [DecidableLT β] {l : List α} {f : αβ} :
        theorem List.isSorted_correct {α : Type u_1} [LT α] [DecidableLT α] {l : List α} :

        Forallᵥ #

        def List.Forallᵥ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : βγProp) (kvs₁ : List (α × β)) (kvs₂ : List (α × γ)) :
        Equations
        Instances For
          theorem List.forallᵥ_def {α : Type u_1} {β : Type u_2} {γ : Type u_3} {p : βγProp} {kvs₁ : List (α × β)} {kvs₂ : List (α × γ)} :
          Forallᵥ p kvs₁ kvs₂ = Forall₂ (fun (kv₁ : α × β) (kv₂ : α × γ) => kv₁.fst = kv₂.fst p kv₁.snd kv₂.snd) kvs₁ kvs₂