[ltree] More supporting theorems for rose trees #1389
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This PR adds some useful definitions and theorems for the "rose tree" inside
ltreeTheory
.In
ltreeTheory
, there's a "rose tree" [*] inductively defined by a regular use of the datatype package:and the constant
from_rose
is defined to map any rose tree into a corresponding ltree (this is always possible):On the other hand, for any ltree which is finite (
ltree_finite
), there exists a corresponding rose tree:This is basically all we had before for the rose trees.
In this PR, first, I proved that the mapping
from_rose
is injective (by induction on one of the two rose trees):Then, using the injective result and the above
ltree_finite_from_rose
theorem, I defined the constantto_rose
for mapping ltree to rose tree (this is only possible when the ltree is finite) and proved the from/to relationships:Then, I added the following accessor contants for easy accessing rose tree components (ltree has them too):
And I prove what happens if these accessors were put on a rose tree converted from a (finite) ltree:
Finally, I added the following
rose_reduce
function as a general recursive function on rose trees:There's no other supporting theorems for this
rose_reduce
, but I'm using it to re-construct lambda-terms from their Boehm trees (when they are finite and are mapped to rose trees).--Chun
[*] But, according to Wikipedia [1], "rose tree" a term for the value of a tree data structure with a variable and unbounded number of branches per node. Our "rose tree" here is only finite branching.
[1] https://en.wikipedia.org/wiki/Rose_tree