Canonical form
Lax185574.CanonicalForm · concepts/Lax185574/CanonicalForm.lean · lax-185574
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Observation
A type tree given by a representation whose sets need not be sorted or duplicate-free can be brought into canonical form in polynomial time.
Concept map
In the paper
- page 42 of this submission's paper
Lean source view on GitHub
| 1 | import Lax185574.Algorithms |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Canonical form |
| 6 | type: observation |
| 7 | --- |
| 8 | A type tree given by a representation whose sets need not be sorted or |
| 9 | duplicate-free can be brought into canonical form in polynomial time. |
| 10 | |
| 11 | # Formalization notes |
| 12 | |
| 13 | The statement is made for one set: a list of elements of an encoded |
| 14 | type, possibly unsorted and with repetitions, is turned into the finite |
| 15 | set of its entries, whose encoding is the sorted duplicate-free list of |
| 16 | the encodings of the elements. The algorithm receives the list of the |
| 17 | encodings of the elements, so every element is preceded by its length, |
| 18 | and it can find the boundaries of the elements without knowing their |
| 19 | type. One algorithm works for all types. A type tree is brought into |
| 20 | canonical form by applying this at every node, from the leaves up. That |
| 21 | step is part of the proofs that use it. |
| 22 | |
| 23 | The algorithm is an algorithm in the sense of `Lax185574.Algorithms`. |
| 24 | Polynomial time means time `O((N + 1)^a)` on an input of length `N`. |
| 25 | The finite set `l.toFinset` needs decidable equality of the elements, |
| 26 | which every type has classically. |
| 27 | -/ |
| 28 | |
| 29 | namespace Lax185574.CanonicalForm |
| 30 | |
| 31 | open Lax185574.Encoding Lax185574.Algorithms |
| 32 | |
| 33 | /-- **Canonical form.** One algorithm turns a list of elements, given by |
| 34 | their encodings, into the finite set of its entries, in polynomial time. |
| 35 | It sorts the encodings and removes duplicates. -/ |
| 36 | axiom exists_program_canonical : |
| 37 | ∃ (A : Algorithm) (c a : ℕ), ∀ (α : Type) [Encode α] [DecidableEq α] (l : List α), |
| 38 | A.Computes c (l.map encode) l.toFinset (((encode (l.map encode)).length + 1) ^ a) |
| 39 | |
| 40 | end Lax185574.CanonicalForm |
| 41 |
Formalization notes
The statement is made for one set: a list of elements of an encoded type, possibly unsorted and with repetitions, is turned into the finite set of its entries, whose encoding is the sorted duplicate-free list of the encodings of the elements. The algorithm receives the list of the encodings of the elements, so every element is preceded by its length, and it can find the boundaries of the elements without knowing their type. One algorithm works for all types. A type tree is brought into canonical form by applying this at every node, from the leaves up. That step is part of the proofs that use it.
The algorithm is an algorithm in the sense of . Polynomial time means time on an input of length . The finite set needs decidable equality of the elements, which every type has classically.
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments