Palindromes #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This module defines palindromes, lists which are equal to their reverse.
The main result is the palindrome
inductive type, and its associated palindrome.rec_on
induction
principle. Also provided are conversions to and from other equivalent definitions.
References #
Tags #
palindrome, reverse, induction
- nil : ∀ {α : Type u_1}, list.nil.palindrome
- singleton : ∀ {α : Type u_1} (x : α), [x].palindrome
- cons_concat : ∀ {α : Type u_1} (x : α) {l : list α}, l.palindrome → (x :: (l ++ [x])).palindrome
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.
Instances for list.palindrome
@[protected]
theorem
list.palindrome.map
{α : Type u_1}
{β : Type u_2}
{l : list α}
(f : α → β)
(p : l.palindrome) :
(list.map f l).palindrome
@[protected, instance]