The data type FourTree #
We define a tree-like structure, called FourTree
, for storing values of a
type α1 × α2 × α3 × α4
.
It is defined recursively, with the following structure:
instance
PhysLean.FourTree.instDecidableEqLeaf
{α4✝ : Type}
[DecidableEq α4✝]
:
DecidableEq (Leaf α4✝)
Repr instances for the FourTree #
These instances allow the FourTree
to be printed in a human-readable format,
and copied and pasted.
Conversion between FourTree and Multiset #
def
PhysLean.FourTree.fromMultiset
{α1 α2 α3 α4 : Type}
[DecidableEq α1]
[DecidableEq α2]
[DecidableEq α3]
[DecidableEq α4]
(l : Multiset (α1 × α2 × α3 × α4))
:
FourTree α1 α2 α3 α4
A FourTree
from a multiset of α1 × α2 × α3 × α4
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cardinality of the tree #
The cardinality of a Twig
is the number of leafs.
Equations
- (PhysLean.FourTree.Twig.twig xs a).card = a.card
Instances For
theorem
PhysLean.FourTree.card_eq_toMultiset_card
{α1 α2 α3 α4s : Type}
(T : FourTree α1 α2 α3 α4s)
:
Membership of a FourTree #
Based on the tree structure we can define a faster membership criterion, which is equivalent to membership based on multisets.
instance
PhysLean.FourTree.instDecidableMemOfDecidableEq
{α4 : Type}
[DecidableEq α4]
(T : Leaf α4)
(x : α4)
:
Equations
- One or more equations did not get rendered due to their size.
instance
PhysLean.FourTree.instDecidableMemOfDecidableEq_1
{α3 α4 : Type}
[DecidableEq α3]
[DecidableEq α4]
(T : Twig α3 α4)
(x : α3 × α4)
:
instance
PhysLean.FourTree.instDecidableMemOfDecidableEq_2
{α2 α3 α4 : Type}
[DecidableEq α2]
[DecidableEq α3]
[DecidableEq α4]
(T : Branch α2 α3 α4)
(x : α2 × α3 × α4)
:
instance
PhysLean.FourTree.instDecidableMemOfDecidableEq_3
{α1 α2 α3 α4 : Type}
[DecidableEq α1]
[DecidableEq α2]
[DecidableEq α3]
[DecidableEq α4]
(T : Trunk α1 α2 α3 α4)
(x : α1 × α2 × α3 × α4)
:
instance
PhysLean.FourTree.instDecidableMemOfDecidableEq_4
{α1 α2 α3 α4 : Type}
[DecidableEq α1]
[DecidableEq α2]
[DecidableEq α3]
[DecidableEq α4]
(T : FourTree α1 α2 α3 α4)
(x : α1 × α2 × α3 × α4)
:
instance
PhysLean.FourTree.instMembershipProd
{α1 α2 α3 α4 : Type}
:
Membership (α1 × α2 × α3 × α4) (FourTree α1 α2 α3 α4)
Equations
instance
PhysLean.FourTree.instDecidableMemProdOfDecidableEq
{α1 α2 α3 α4 : Type}
[DecidableEq α1]
[DecidableEq α2]
[DecidableEq α3]
[DecidableEq α4]
(T : FourTree α1 α2 α3 α4)
(x : α1 × α2 × α3 × α4)
:
theorem
PhysLean.FourTree.mem_of_parts
{α1 α2 α3 α4 : Type}
{T : FourTree α1 α2 α3 α4}
{C : α1 × α2 × α3 × α4}
(trunk : Trunk α1 α2 α3 α4)
(branch : Branch α2 α3 α4)
(twig : Twig α3 α4)
(leaf : Leaf α4)
(trunk_mem : trunk ∈ T.1)
(branch_mem : branch ∈ trunk.2)
(twig_mem : twig ∈ branch.2)
(leaf_mem : leaf ∈ twig.2)
(heq : C = (trunk.1, branch.1, twig.1, leaf.1))
: