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.Palindrome

13 declarations. Mathlib docs · Source

Palindromes

This module defines palindromes, lists which are equal to their reverse.

The main result is the Palindrome inductive type, and its associated Palindrome.rec induction principle. Also provided are conversions to and from other equivalent definitions.

References

Tags

palindrome, reverse, induction

ctor List.Palindrome.below.cons_concat E0 #

∀ {α : Type u_1} {motive : (a : List α) → a.Palindrome → Prop} (x : α) {l : List α} (a : l.Palindrome),
  List.Palindrome.below a → motive l a → List.Palindrome.below ⋯

ctor List.Palindrome.below.singleton E0 #

∀ {α : Type u_1} {motive : (a : List α) → a.Palindrome → Prop} (x : α), List.Palindrome.below ⋯

ctor List.Palindrome.below.nil E0 #

∀ {α : Type u_1} {motive : (a : List α) → a.Palindrome → Prop}, List.Palindrome.below ⋯

inductive List.Palindrome E1 #

{α : Type u_1} → List α → Prop

Palindrome l asserts that l is a palindrome. This is defined inductively:

  • The empty list is a palindrome;
  • A list with one element is a palindrome;
  • Adding the same element to both ends of a palindrome results in a bigger palindrome.

ctor List.Palindrome.nil E0 #

∀ {α : Type u_1}, [].Palindrome

ctor List.Palindrome.singleton E0 #

∀ {α : Type u_1} (x : α), [x].Palindrome

ctor List.Palindrome.cons_concat E0 #

∀ {α : Type u_1} (x : α) {l : List α}, l.Palindrome → (x :: (l ++ [x])).Palindrome

theorem List.Palindrome.reverse_eq E0 #

∀ {α : Type u_1} {l : List α}, l.Palindrome → l.reverse = l

theorem List.Palindrome.of_reverse_eq E0 #

∀ {α : Type u_1} {l : List α}, l.reverse = l → l.Palindrome

theorem List.Palindrome.iff_reverse_eq E0 #

∀ {α : Type u_1} {l : List α}, l.Palindrome ↔ l.reverse = l

theorem List.Palindrome.append_reverse E1 #

∀ {α : Type u_1} (l : List α), (l ++ l.reverse).Palindrome

theorem List.Palindrome.map E1 #

∀ {α : Type u_1} {β : Type u_2} {l : List α} (f : α → β), l.Palindrome → (List.map f l).Palindrome

instance List.Palindrome.instDecidableOfDecidableEq E0 #

{α : Type u_1} → [DecidableEq α] → (l : List α) → Decidable l.Palindrome