The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.List.Induction

26 declarations. Mathlib docs · Source

theorem List.reverseRec.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive [])
  (h_2 : (a : α) → (l : List α) → motive (a :: l)),
  x = [] →
    (match x with
      | [] => h_1 ()
      | a :: l => h_2 a l) ≍
      h_1 ()

theorem List.bidirectionalRec.match_1.congr_eq_3 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive []) (h_2 : (a : α) → motive [a])
  (h_3 : (a b : α) → (l : List α) → motive (a :: b :: l)) (a b : α) (l : List α),
  x = a :: b :: l →
    (match x with
      | [] => h_1 ()
      | [a] => h_2 a
      | a :: b :: l => h_3 a b l) ≍
      h_3 a b l

theorem List.bidirectionalRec.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive []) (h_2 : (a : α) → motive [a])
  (h_3 : (a b : α) → (l : List α) → motive (a :: b :: l)),
  x = [] →
    (match x with
      | [] => h_1 ()
      | [a] => h_2 a
      | a :: b :: l => h_3 a b l) ≍
      h_1 ()

theorem List.reverseRec.hcongr_5 E1 #

∀ (α α' : Type u_1),
  α = α' →
    ∀ (motive : List α → Sort u_2) (motive' : List α' → Sort u_2),
      motive ≍ motive' →
        ∀ (nil : motive []) (nil' : motive' []),
          nil ≍ nil' →
            ∀ (append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a]))
              (append_singleton' : (l : List α') → (a : α') → motive' l → motive' (l ++ [a])),
              append_singleton ≍ append_singleton' →
                ∀ (l : List α) (l' : List α'),
                  l ≍ l' → List.reverseRec nil append_singleton l ≍ List.reverseRec nil' append_singleton' l'

theorem List.reverseRec.match_1.congr_eq_2 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive [])
  (h_2 : (a : α) → (l : List α) → motive (a :: l)) (a : α) (l : List α),
  x = a :: l →
    (match x with
      | [] => h_1 ()
      | a :: l => h_2 a l) ≍
      h_2 a l

theorem List.bidirectionalRec.hcongr_6 E1 #

∀ (α α' : Type u_1),
  α = α' →
    ∀ (motive : List α → Sort u_2) (motive' : List α' → Sort u_2),
      motive ≍ motive' →
        ∀ (nil : motive []) (nil' : motive' []),
          nil ≍ nil' →
            ∀ (singleton : (a : α) → motive [a]) (singleton' : (a : α') → motive' [a]),
              singleton ≍ singleton' →
                ∀ (cons_append : (a : α) → (l : List α) → (b : α) → motive l → motive (a :: (l ++ [b])))
                  (cons_append' : (a : α') → (l : List α') → (b : α') → motive' l → motive' (a :: (l ++ [b]))),
                  cons_append ≍ cons_append' →
                    ∀ (l : List α) (l' : List α'),
                      l ≍ l' →
                        List.bidirectionalRec nil singleton cons_append l ≍
                          List.bidirectionalRec nil' singleton' cons_append' l'

theorem List.bidirectionalRec.match_1.congr_eq_2 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive []) (h_2 : (a : α) → motive [a])
  (h_3 : (a b : α) → (l : List α) → motive (a :: b :: l)) (a : α),
  x = [a] →
    (match x with
      | [] => h_1 ()
      | [a] => h_2 a
      | a :: b :: l => h_3 a b l) ≍
      h_2 a

def List.reverseRec E1 #

{α : Type u_1} →
  {motive : List α → Sort u_2} →
    motive [] → ((l : List α) → (a : α) → motive l → motive (l ++ [a])) → (l : List α) → motive l

Induction principle from the right for lists: if a property holds for the empty list, and for l ++ [a] if it holds for l, then it holds for all lists. The principle is given for a Sort-valued predicate, i.e., it can also be used to construct data.

theorem List.reverseRec_nil E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (nil : motive [])
  (append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])),
  List.reverseRec nil append_singleton [] = nil

theorem List.reverseRec_concat E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (x : α) (xs : List α) (nil : motive [])
  (append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])),
  List.reverseRec nil append_singleton (xs ++ [x]) = append_singleton xs x (List.reverseRec nil append_singleton xs)

abbrev List.reverseRecOn E1 #

{α : Type u_1} →
  {motive : List α → Sort u_2} →
    (l : List α) → motive [] → ((l : List α) → (a : α) → motive l → motive (l ++ [a])) → motive l

Like reverseRec, but with the list parameter placed first.

theorem List.reverseRecOn_nil E1 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (nil : motive [])
  (append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])),
  List.reverseRecOn [] nil append_singleton = nil

theorem List.reverseRecOn_concat E1 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (x : α) (xs : List α) (nil : motive [])
  (append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])),
  List.reverseRecOn (xs ++ [x]) nil append_singleton = append_singleton xs x (List.reverseRecOn xs nil append_singleton)

def List.bidirectionalRec E1 #

{α : Type u_1} →
  {motive : List α → Sort u_2} →
    motive [] →
      ((a : α) → motive [a]) →
        ((a : α) → (l : List α) → (b : α) → motive l → motive (a :: (l ++ [b]))) → (l : List α) → motive l

Bidirectional induction principle for lists: if a property holds for the empty list, the singleton list, and a :: (l ++ [b]) from l, then it holds for all lists. This can be used to prove statements about palindromes. The principle is given for a Sort-valued predicate, i.e., it can also be used to construct data.

theorem List.bidirectionalRec_nil E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (nil : motive []) (singleton : (a : α) → motive [a])
  (cons_append : (a : α) → (l : List α) → (b : α) → motive l → motive (a :: (l ++ [b]))),
  List.bidirectionalRec nil singleton cons_append [] = nil

theorem List.bidirectionalRec_singleton E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (nil : motive []) (singleton : (a : α) → motive [a])
  (cons_append : (a : α) → (l : List α) → (b : α) → motive l → motive (a :: (l ++ [b]))) (a : α),
  List.bidirectionalRec nil singleton cons_append [a] = singleton a

theorem List.bidirectionalRec_cons_append E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (nil : motive []) (singleton : (a : α) → motive [a])
  (cons_append : (a : α) → (l : List α) → (b : α) → motive l → motive (a :: (l ++ [b]))) (a : α) (l : List α) (b : α),
  List.bidirectionalRec nil singleton cons_append (a :: (l ++ [b])) =
    cons_append a l b (List.bidirectionalRec nil singleton cons_append l)

abbrev List.bidirectionalRecOn E1 #

{α : Type u_1} →
  {C : List α → Sort u_2} →
    (l : List α) → C [] → ((a : α) → C [a]) → ((a : α) → (l : List α) → (b : α) → C l → C (a :: (l ++ [b]))) → C l

Like bidirectionalRec, but with the list parameter placed first.

def List.recNeNil E1 #

{α : Type u_1} →
  {motive : (l : List α) → l ≠ [] → Sort u_2} →
    ((x : α) → motive [x] ⋯) →
      ((x : α) → (xs : List α) → (h : xs ≠ []) → motive xs h → motive (x :: xs) ⋯) →
        (l : List α) → (h : l ≠ []) → motive l h

A dependent recursion principle for nonempty lists. Useful for dealing with operations like List.head which are not defined on the empty list.

theorem List.recNeNil_singleton E0 #

∀ {α : Type u_1} {motive : (l : List α) → l ≠ [] → Sort u_2} (x : α) (singleton : (x : α) → motive [x] ⋯)
  (cons : (x : α) → (xs : List α) → (h : xs ≠ []) → motive xs h → motive (x :: xs) ⋯),
  List.recNeNil singleton cons [x] ⋯ = singleton x

theorem List.recNeNil_cons E0 #

∀ {α : Type u_1} {motive : (l : List α) → l ≠ [] → Sort u_2} (x : α) (xs : List α) (h : xs ≠ [])
  (singleton : (x : α) → motive [x] ⋯)
  (cons : (x : α) → (xs : List α) → (h : xs ≠ []) → motive xs h → motive (x :: xs) ⋯),
  List.recNeNil singleton cons (x :: xs) ⋯ = cons x xs h (List.recNeNil singleton cons xs h)

abbrev List.recOnNeNil E1 #

{α : Type u_1} →
  {motive : (l : List α) → l ≠ [] → Sort u_2} →
    (l : List α) →
      (h : l ≠ []) →
        ((x : α) → motive [x] ⋯) →
          ((x : α) → (xs : List α) → (h : xs ≠ []) → motive xs h → motive (x :: xs) ⋯) → motive l h

A dependent recursion principle for nonempty lists. Useful for dealing with operations like List.head which are not defined on the empty list. Same as List.recNeNil, with a more convenient argument order.

def List.twoStepInduction E1 #

{α : Type u_1} →
  {motive : List α → Sort u_2} →
    motive [] →
      ((x : α) → motive [x]) →
        ((x y : α) → (xs : List α) → motive xs → ((y : α) → motive (y :: xs)) → motive (x :: y :: xs)) →
          (l : List α) → motive l

A recursion principle for lists which separates the singleton case.

theorem List.twoStepInduction_nil E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (nil : motive []) (singleton : (x : α) → motive [x])
  (cons_cons : (x y : α) → (xs : List α) → motive xs → ((y : α) → motive (y :: xs)) → motive (x :: y :: xs)),
  List.twoStepInduction nil singleton cons_cons [] = nil

theorem List.twoStepInduction_singleton E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (x : α) (nil : motive []) (singleton : (x : α) → motive [x])
  (cons_cons : (x y : α) → (xs : List α) → motive xs → ((y : α) → motive (y :: xs)) → motive (x :: y :: xs)),
  List.twoStepInduction nil singleton cons_cons [x] = singleton x

theorem List.twoStepInduction_cons_cons E0 #

∀ {α : Type u_1} {motive : List α → Sort u_2} (x y : α) (xs : List α) (nil : motive [])
  (singleton : (x : α) → motive [x])
  (cons_cons : (x y : α) → (xs : List α) → motive xs → ((y : α) → motive (y :: xs)) → motive (x :: y :: xs)),
  List.twoStepInduction nil singleton cons_cons (x :: y :: xs) =
    cons_cons x y xs (List.twoStepInduction nil singleton cons_cons xs) fun y ↦
      List.twoStepInduction nil singleton cons_cons (y :: xs)