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
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.
- nil: ∀ {α : Type u_1}, [].Palindrome
- singleton: ∀ {α : Type u_1} (x : α), [x].Palindrome
- cons_concat: ∀ {α : Type u_1} (x : α) {l : List α}, l.Palindrome → (x :: (l ++ [x])).Palindrome
Instances For
instance
List.Palindrome.instDecidableOfDecidableEq
{α : Type u_1}
[DecidableEq α]
(l : List α)
:
Decidable l.Palindrome
Equations
- List.Palindrome.instDecidableOfDecidableEq l = decidable_of_iff' (l.reverse = l) ⋯