Splits, compatibility, ultrametrics and UPGMA
Hierarchies
DefinitionHierarchy on a finite set#✓fully proved
A hierarchy on a finite set S: a family of nonempty subsets of S containing S and
every singleton, any two members nested or disjoint. These are the cluster systems of the rooted
phylogenetic trees on S (Semple & Steel 2003, Section 3.5).
TheoremA binary hierarchy is a hierarchy#✓fully proved
A binary hierarchy is a hierarchy.
theorem IsBinaryHierarchy.isHierarchy {S : Finset α} {H : Finset (Finset α)}
(h : IsBinaryHierarchy S H) : IsHierarchy S H
def IsBinaryHierarchy {α : Type*} [DecidableEq α] (S : Finset α) (H : Finset (Finset α)) :
Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
(∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) ∧
∀ C ∈ H, 1 < C.card → ∃ D₁ ∈ H, ∃ D₂ ∈ H, Disjoint D₁ D₂ ∧ D₁ ∪ D₂ = C
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:95
def IsHierarchy (S : Finset α) (H : Finset (Finset α)) : Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:112
Uses 2
TheoremPairwise nested-or-disjoint clusters form a hierarchy#✓fully proved
Adding S and the singletons to
a family of pairwise nested-or-disjoint nonempty subsets of a nonempty S gives a hierarchy.
theorem isHierarchy_completion {S : Finset α} (hS : S.Nonempty) {F : Finset (Finset α)}
(hF : ∀ C ∈ F, C.Nonempty ∧ C ⊆ S)
(hlam : ∀ C ∈ F, ∀ D ∈ F, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) :
IsHierarchy S (insert S (F ∪ S.image ({·})))
def IsHierarchy (S : Finset α) (H : Finset (Finset α)) : Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:112
Uses 1
TheoremHierarchies are refined by binary trees#✓fully proved
Every family of pairwise nested-or-disjoint
nonempty subsets of a nonempty S is contained in a binary hierarchy on S, the cluster set of
a rooted binary phylogenetic tree on S (Semple & Steel 2003, Proposition 3.5.2 and the
refinement of a rooted tree to a binary one).
theorem exists_isBinaryHierarchy_superset {S : Finset α} (hS : S.Nonempty)
{F : Finset (Finset α)} (hF : ∀ C ∈ F, C.Nonempty ∧ C ⊆ S)
(hlam : ∀ C ∈ F, ∀ D ∈ F, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) :
∃ H, IsBinaryHierarchy S H ∧ F ⊆ H
def IsBinaryHierarchy {α : Type*} [DecidableEq α] (S : Finset α) (H : Finset (Finset α)) :
Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
(∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) ∧
∀ C ∈ H, 1 < C.card → ∃ D₁ ∈ H, ∃ D₂ ∈ H, Disjoint D₁ D₂ ∧ D₁ ∪ D₂ = C
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:95
Uses 1 · Used by 2
TheoremNumber of members of a binary hierarchy#✓fully proved
A binary hierarchy on S has 2 |S| - 1 members: the |S| singletons and |S| - 1
internal clusters (stated without subtraction).
theorem IsBinaryHierarchy.card_add_one {S : Finset α} {H : Finset (Finset α)}
(h : IsBinaryHierarchy S H) : H.card + 1 = 2 * S.card
def IsBinaryHierarchy {α : Type*} [DecidableEq α] (S : Finset α) (H : Finset (Finset α)) :
Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
(∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) ∧
∀ C ∈ H, 1 < C.card → ∃ D₁ ∈ H, ∃ D₂ ∈ H, Disjoint D₁ D₂ ∧ D₁ ∪ D₂ = C
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:95
Uses 2 · Used by 1
Splits and compatibility
DefinitionCompatible splits#✓fully proved
The splits A | Aᶜ and B | Bᶜ are compatible: one of A ∩ B, A ∩ Bᶜ, Aᶜ ∩ B,
Aᶜ ∩ Bᶜ is empty (Semple & Steel 2003, Section 3.1).
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
Used by 9
TheoremSymmetry of split compatibility#✓fully proved
Compatibility is symmetric.
theorem Compatible.symm {A B : Finset X} (h : Compatible A B) : Compatible B A
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 1 · Used by 1
TheoremCompatibility is unchanged by complementing the first split#✓fully proved
Compatibility depends only on the split, not on the side used to store it.
theorem compatible_compl_left {A B : Finset X} : Compatible Aᶜ B ↔ Compatible A B
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 1 · Used by 2
TheoremCompatibility is unchanged by complementing the second split#✓fully proved
Compatibility depends only on the split, not on the side used to store it.
theorem compatible_compl_right {A B : Finset X} : Compatible A Bᶜ ↔ Compatible A B
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 1 · Used by 2
TheoremCompatible clusters are nested or disjoint#✓fully proved
For the sides not containing a fixed taxon a, compatibility is being nested or disjoint:
splits seen from a root are clusters.
theorem compatible_iff_nested_or_disjoint {a : X} {A B : Finset X} (hA : a ∉ A) (hB : a ∉ B) :
Compatible A B ↔ A ⊆ B ∨ B ⊆ A ∨ Disjoint A B
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 1 · Used by 2
DefinitionFour-gamete condition for binary characters#✓fully proved
The binary characters χ and ψ show all four gametes (0,0), (0,1), (1,0), (1,1)
on the taxa.
Used by 8
DefinitionSplit of a binary character#✓fully proved
The split of a binary character: the taxa in state true.
def charSplit (χ : X → Bool) : Finset X :=
Finset.univ.filter fun x => χ x = true
TheoremThe four-gamete test#✓fully proved
Two binary characters give compatible splits iff they do not show all four gametes (Buneman 1971; Estabrook, Johnson & McMorris 1976).
theorem compatible_iff_not_fourGametes (χ ψ : X → Bool) :
Compatible (charSplit χ) (charSplit ψ) ↔ ¬ FourGametes χ ψ
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
def charSplit (χ : X → Bool) : Finset X :=
Finset.univ.filter fun x => χ x = true
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:442
def FourGametes (χ ψ : X → Bool) : Prop :=
∀ b c : Bool, ∃ x, χ x = b ∧ ψ x = c
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:438
Uses 3 · Used by 1
Splits of unrooted binary trees
DefinitionSplit set of a tree computed from a leaf#✓fully proved
The split set of T computed from the leaf a: both sides of every cluster of T seen
from a. It equals edgeSplits T for every a (splitSet_eq_edgeSplits).
noncomputable def splitSet (T : UnrootedBinaryTree X) (a : X) : Finset (Finset X) :=
clusterSet T a ∪ (clusterSet T a).image (·ᶜ)
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def clusterSet {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) : Finset (Finset X) :=
Finset.univ.image (cluster T a)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:613
Uses 2 · Used by 9
TheoremClusters seen from a leaf omit that leaf#✓fully proved
The clusters seen from a do not contain a.
theorem notMem_of_mem_clusterSet (T : UnrootedBinaryTree X) (a : X) {C : Finset X}
(hC : C ∈ clusterSet T a) : a ∉ C
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def clusterSet {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) : Finset (Finset X) :=
Finset.univ.image (cluster T a)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:613
Uses 3 · Used by 4
DefinitionSide of a tree edge containing a vertex#✓fully proved
The side of the edge p – v containing v: the taxa whose leaf is closer to v than to
p.
noncomputable def edgeSide (T : UnrootedBinaryTree X) (p v : T.V) : Finset X :=
Finset.univ.filter fun x => T.G.dist (T.label x) v < T.G.dist (T.label x) p
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
Uses 1 · Used by 13
0 · Subadditivity · The side of a pendant edge is the singleton of its leaf · Clusters seen from a leaf are edge sides · The two sides of a tree edge are complementary · Edge splits of a tree · Split set from any leaf equals the edge splitsDefinitionEdge splits of a tree#✓fully proved
The edge splits of T: the sides of all its edges (both sides of every edge).
noncomputable def edgeSplits (T : UnrootedBinaryTree X) : Finset (Finset X) :=
((Finset.univ ×ˢ Finset.univ).filter fun e : T.V × T.V => T.G.Adj e.1 e.2).image
fun e => edgeSide T e.1 e.2
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def edgeSide (T : UnrootedBinaryTree X) (p v : T.V) : Finset X :=
Finset.univ.filter fun x => T.G.dist (T.label x) v < T.G.dist (T.label x) p
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:536
Uses 2 · Used by 9
TheoremThe two sides of a tree edge are complementary#✓fully proved
The two sides of an edge are complementary.
theorem compl_edgeSide (T : UnrootedBinaryTree X) {p v : T.V} (hpv : T.G.Adj p v) :
(edgeSide T p v)ᶜ = edgeSide T v p
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def edgeSide (T : UnrootedBinaryTree X) (p v : T.V) : Finset X :=
Finset.univ.filter fun x => T.G.dist (T.label x) v < T.G.dist (T.label x) p
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:536
Uses 2 · Used by 2
TheoremClusters seen from a leaf are edge sides#✓fully proved
The cluster of a vertex v seen from a is the side of v of the edge from v to its
neighbor p toward a.
theorem cluster_eq_edgeSide (T : UnrootedBinaryTree X) (a : X) {p v : T.V} (hpv : T.G.Adj p v)
(hd : T.G.dist (T.label a) v = T.G.dist (T.label a) p + 1) :
cluster T a v = edgeSide T p v
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def cluster {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) (v : T.V) : Finset X :=
Finset.univ.filter fun x => x ≠ a ∧
T.G.dist (T.label a) v + T.G.dist v (T.label x) = T.G.dist (T.label a) (T.label x)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:606
noncomputable def edgeSide (T : UnrootedBinaryTree X) (p v : T.V) : Finset X :=
Finset.univ.filter fun x => T.G.dist (T.label x) v < T.G.dist (T.label x) p
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:536
Uses 4 · Used by 1
TheoremSplit set from any leaf equals the edge splits#✓fully proved
The split set computed from any leaf is the set of edge splits.
theorem splitSet_eq_edgeSplits (T : UnrootedBinaryTree X) (a : X) :
splitSet T a = edgeSplits T
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def splitSet (T : UnrootedBinaryTree X) (a : X) : Finset (Finset X) :=
clusterSet T a ∪ (clusterSet T a).image (·ᶜ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:480
noncomputable def edgeSplits (T : UnrootedBinaryTree X) : Finset (Finset X) :=
((Finset.univ ×ˢ Finset.univ).filter fun e : T.V × T.V => T.G.Adj e.1 e.2).image
fun e => edgeSide T e.1 e.2
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:540
Uses 8 · Used by 5
TheoremThe split set does not depend on the leaf used to compute it#✓fully proved
The split set does not depend on the leaf used to compute it.
theorem splitSet_eq_splitSet (T : UnrootedBinaryTree X) (a b : X) :
splitSet T a = splitSet T b
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def splitSet (T : UnrootedBinaryTree X) (a : X) : Finset (Finset X) :=
clusterSet T a ∪ (clusterSet T a).image (·ᶜ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:480
Uses 4 · Used by 1
TheoremSplits computed from a leaf are pairwise compatible#✓fully proved
Any two splits of one tree are compatible.
theorem compatible_of_mem_splitSet {T : UnrootedBinaryTree X} {a : X} {A B : Finset X}
(hA : A ∈ splitSet T a) (hB : B ∈ splitSet T a) : Compatible A B
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def splitSet (T : UnrootedBinaryTree X) (a : X) : Finset (Finset X) :=
clusterSet T a ∪ (clusterSet T a).image (·ᶜ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:480
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 9 · Used by 2
TheoremEdge splits of a tree are pairwise compatible#✓fully proved
Any two splits of one tree are compatible.
theorem compatible_of_mem_edgeSplits {T : UnrootedBinaryTree X} {A B : Finset X}
(hA : A ∈ edgeSplits T) (hB : B ∈ edgeSplits T) : Compatible A B
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def edgeSplits (T : UnrootedBinaryTree X) : Finset (Finset X) :=
((Finset.univ ×ˢ Finset.univ).filter fun e : T.V × T.V => T.G.Adj e.1 e.2).image
fun e => edgeSide T e.1 e.2
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:540
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 6 · Used by 1
TheoremSplits-equivalence theorem#✓fully proved
Splits-equivalence theorem, binary form (Buneman 1971; Semple & Steel 2003, Theorem
3.1.4): on at least two taxa, a family F of proper splits (both sides nonempty) is contained in
the split set of some unrooted binary phylogenetic tree iff its members are pairwise compatible.
The tree is a binary refinement of the tree whose splits are exactly F and the trivial ones.
theorem splits_equivalence (hX : 1 < Fintype.card X) (F : Finset (Finset X))
(hne : ∀ A ∈ F, A.Nonempty ∧ Aᶜ.Nonempty) :
(∃ T : UnrootedBinaryTree X, F ⊆ edgeSplits T) ↔
∀ A ∈ F, ∀ B ∈ F, Compatible A B
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def edgeSplits (T : UnrootedBinaryTree X) : Finset (Finset X) :=
((Finset.univ ×ˢ Finset.univ).filter fun e : T.V × T.V => T.G.Adj e.1 e.2).image
fun e => edgeSide T e.1 e.2
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:540
def Compatible (A B : Finset X) : Prop :=
Disjoint A B ∨ Disjoint A Bᶜ ∨ Disjoint Aᶜ B ∨ Disjoint Aᶜ Bᶜ
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:402
Uses 13 · Used by 1
DefinitionPerfect phylogeny for a binary character matrix#✓fully proved
T is a perfect phylogeny for the binary character matrix M (taxa by characters):
the split of every non-constant column is a split of T, i.e. every character changes state
on exactly one edge.
def IsPerfectPhylogeny {ι : Type} (T : UnrootedBinaryTree X) (M : X → ι → Bool) : Prop :=
∀ j, charSplit (M · j) = ∅ ∨ charSplit (M · j) = Finset.univ ∨
charSplit (M · j) ∈ edgeSplits T
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
def charSplit (χ : X → Bool) : Finset X :=
Finset.univ.filter fun x => χ x = true
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:442
noncomputable def edgeSplits (T : UnrootedBinaryTree X) : Finset (Finset X) :=
((Finset.univ ×ˢ Finset.univ).filter fun e : T.V × T.V => T.G.Adj e.1 e.2).image
fun e => edgeSide T e.1 e.2
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:540
Uses 3 · Used by 1
TheoremPerfect phylogeny and the four-gamete condition#✓fully proved
Perfect phylogeny and the four-gamete condition (Estabrook, Johnson & McMorris 1976; Gusfield 1991): a binary character matrix on at least two taxa has a perfect phylogeny iff no two of its columns show all four gametes.
theorem exists_perfectPhylogeny_iff {ι : Type} (hX : 1 < Fintype.card X) (M : X → ι → Bool) :
(∃ T : UnrootedBinaryTree X, IsPerfectPhylogeny T M) ↔
∀ j k, ¬ FourGametes (M · j) (M · k)
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
def IsPerfectPhylogeny {ι : Type} (T : UnrootedBinaryTree X) (M : X → ι → Bool) : Prop :=
∀ j, charSplit (M · j) = ∅ ∨ charSplit (M · j) = Finset.univ ∨
charSplit (M · j) ∈ edgeSplits T
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:724
def FourGametes (χ ψ : X → Bool) : Prop :=
∀ b c : Bool, ∃ x, χ x = b ∧ ψ x = c
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:438
The Robinson–Foulds distance
DefinitionRobinson–Foulds distance#✓fully proved
The Robinson–Foulds distance: the number of splits in exactly one of the two trees.
Each split is counted once, by its side away from the leaf a (its cluster seen from a);
trivial splits are common to all trees and cancel. The value does not depend on a
(rfDist_eq_rfDist).
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def clusterSet {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) : Finset (Finset X) :=
Finset.univ.image (cluster T a)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:613
Uses 2 · Used by 8
TheoremRobinson–Foulds distance as half the split symmetric difference#✓fully proved
Each split is counted twice in the symmetric difference of the split sets (once per side), so the Robinson–Foulds distance is half of it.
theorem two_mul_rfDist (a : X) (T T' : UnrootedBinaryTree X) :
2 * rfDist a T T' = (splitSet T a ∆ splitSet T' a).card
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
noncomputable def splitSet (T : UnrootedBinaryTree X) (a : X) : Finset (Finset X) :=
clusterSet T a ∪ (clusterSet T a).image (·ᶜ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:480
Uses 5 · Used by 1
TheoremRobinson–Foulds distance is independent of the base leaf#✓fully proved
The Robinson–Foulds distance does not depend on the leaf used to compute it.
theorem rfDist_eq_rfDist (a b : X) (T T' : UnrootedBinaryTree X) :
rfDist a T T' = rfDist b T T'
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
TheoremRobinson–Foulds distance from a tree to itself is zero#✓fully proved
The Robinson–Foulds distance from a tree to itself is zero.
theorem rfDist_self (a : X) (T : UnrootedBinaryTree X) : rfDist a T T = 0
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
Uses 3
TheoremSymmetry of the Robinson–Foulds distance#✓fully proved
The Robinson–Foulds distance is symmetric.
theorem rfDist_comm (a : X) (T T' : UnrootedBinaryTree X) : rfDist a T T' = rfDist a T' T
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
Uses 3
TheoremTriangle inequality for the Robinson–Foulds distance#✓fully proved
The Robinson–Foulds distance satisfies the triangle inequality.
theorem rfDist_triangle (a : X) (T₁ T₂ T₃ : UnrootedBinaryTree X) :
rfDist a T₁ T₃ ≤ rfDist a T₁ T₂ + rfDist a T₂ T₃
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
Uses 3
TheoremRobinson–Foulds distance vanishes exactly on isomorphic trees#✓fully proved
The Robinson–Foulds distance vanishes exactly on isomorphic trees (Robinson & Foulds 1981).
theorem rfDist_eq_zero_iff (a : X) (T T' : UnrootedBinaryTree X) :
rfDist a T T' = 0 ↔ T.Iso T'
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
TheoremIsomorphism invariance of the Robinson–Foulds distance#✓fully proved
The Robinson–Foulds distance is invariant under isomorphism, so it is a metric on the trees up to isomorphism.
theorem rfDist_congr {a : X} {T₁ T₂ T' : UnrootedBinaryTree X} (h : T₁.Iso T₂) :
rfDist a T₁ T' = rfDist a T₂ T'
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
TheoremMaximum of the Robinson–Foulds distance#✓fully proved
On n ≥ 3 taxa it is at most 2 (n - 3), the
number of nontrivial splits of two binary trees (Robinson & Foulds 1981).
theorem rfDist_le (a : X) (hn : 3 ≤ Fintype.card X) (T T' : UnrootedBinaryTree X) :
rfDist a T T' ≤ 2 * (Fintype.card X - 3)
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def rfDist (a : X) (T T' : UnrootedBinaryTree X) : ℕ :=
(clusterSet T a ∆ clusterSet T' a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:780
Majority-rule consensus and bootstrap support
DefinitionMajority splits of a family of trees#✓fully proved
The majority splits of a finite family of trees T i: the clusters, seen from a, of
more than half of the trees (repetitions in the family count).
noncomputable def majoritySplits {ι : Type} [Fintype ι] (T : ι → UnrootedBinaryTree X) (a : X) :
Finset (Finset X) :=
Finset.univ.filter fun A =>
Fintype.card ι < 2 * (Finset.univ.filter fun i => A ∈ clusterSet (T i) a).card
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def clusterSet {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) : Finset (Finset X) :=
Finset.univ.image (cluster T a)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:613
Uses 2 · Used by 3
TheoremMajority splits are compatible#✓fully proved
Majority splits are compatible (Margush & McMorris 1981): two clusters each in more than half of the trees are both clusters of a common tree (pigeonhole), hence nested or disjoint.
theorem nested_or_disjoint_of_mem_majoritySplits {ι : Type} [Fintype ι]
{T : ι → UnrootedBinaryTree X} {a : X} {A B : Finset X} (hA : A ∈ majoritySplits T a)
(hB : B ∈ majoritySplits T a) : A ⊆ B ∨ B ⊆ A ∨ Disjoint A B
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def majoritySplits {ι : Type} [Fintype ι] (T : ι → UnrootedBinaryTree X) (a : X) :
Finset (Finset X) :=
Finset.univ.filter fun A =>
Fintype.card ι < 2 * (Finset.univ.filter fun i => A ∈ clusterSet (T i) a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:928
Uses 4 · Used by 1
TheoremThe majority-rule consensus tree#✓fully proved
The majority splits are clusters of one unrooted binary phylogenetic tree (a binary refinement of the majority-rule consensus tree).
theorem exists_tree_majoritySplits_subset {ι : Type} [Fintype ι]
(T : ι → UnrootedBinaryTree X) (a : X) (hX : (Finset.univ.erase a).Nonempty) :
∃ T₀ : UnrootedBinaryTree X, majoritySplits T a ⊆ clusterSet T₀ a
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def majoritySplits {ι : Type} [Fintype ι] (T : ι → UnrootedBinaryTree X) (a : X) :
Finset (Finset X) :=
Finset.univ.filter fun A =>
Fintype.card ι < 2 * (Finset.univ.filter fun i => A ∈ clusterSet (T i) a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:928
noncomputable def clusterSet {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) : Finset (Finset X) :=
Finset.univ.image (cluster T a)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:613
Uses 8
DefinitionBootstrap support#✓fully proved
Bootstrap support (Felsenstein 1985) of the split with side A away from a, for a
tree estimator est and an alignment M of m sites: the fraction of the m ^ m site
resamplings with replacement w : Fin m → Fin m (uniform draws, whose site counts are
multinomial) for which the tree estimated from the resampled alignment M ∘ w has the
cluster A. This is the exact bootstrap proportion; Felsenstein's procedure estimates it from a
sample of resamplings.
noncomputable def bootstrapSupport {σ : Type} {m : ℕ}
(est : (Fin m → X → σ) → UnrootedBinaryTree X) (a : X) (M : Fin m → X → σ)
(A : Finset X) : ℝ :=
((Finset.univ.filter fun w : Fin m → Fin m => A ∈ clusterSet (est (M ∘ w)) a).card : ℝ) /
((m ^ m : ℕ) : ℝ)
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def clusterSet {X : Type} [Fintype X] [DecidableEq X] (T : UnrootedBinaryTree X)
(a : X) : Finset (Finset X) :=
Finset.univ.image (cluster T a)
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:613
Uses 2 · Used by 2
TheoremBootstrap support lies in the unit interval#✓fully proved
Bootstrap support is a frequency: it lies in [0, 1].
theorem bootstrapSupport_mem_Icc {σ : Type} {m : ℕ}
(est : (Fin m → X → σ) → UnrootedBinaryTree X) (a : X) (M : Fin m → X → σ)
(A : Finset X) : bootstrapSupport est a M A ∈ Set.Icc 0 1
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def bootstrapSupport {σ : Type} {m : ℕ}
(est : (Fin m → X → σ) → UnrootedBinaryTree X) (a : X) (M : Fin m → X → σ)
(A : Finset X) : ℝ :=
((Finset.univ.filter fun w : Fin m → Fin m => A ∈ clusterSet (est (M ∘ w)) a).card : ℝ) /
((m ^ m : ℕ) : ℝ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:973
Uses 3
TheoremBootstrap support above one half means a majority split#✓fully proved
A split has bootstrap support above one half iff it is a majority split of the bootstrap
replicate trees; so the splits with support above one half are pairwise compatible and form
one tree (exists_tree_majoritySplits_subset).
theorem one_half_lt_bootstrapSupport_iff {σ : Type} {m : ℕ}
(est : (Fin m → X → σ) → UnrootedBinaryTree X) (a : X) (M : Fin m → X → σ)
(A : Finset X) :
1 / 2 < bootstrapSupport est a M A ↔ A ∈ majoritySplits (fun w => est (M ∘ w)) a
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def bootstrapSupport {σ : Type} {m : ℕ}
(est : (Fin m → X → σ) → UnrootedBinaryTree X) (a : X) (M : Fin m → X → σ)
(A : Finset X) : ℝ :=
((Finset.univ.filter fun w : Fin m → Fin m => A ∈ clusterSet (est (M ∘ w)) a).card : ℝ) /
((m ^ m : ℕ) : ℝ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:973
noncomputable def majoritySplits {ι : Type} [Fintype ι] (T : ι → UnrootedBinaryTree X) (a : X) :
Finset (Finset X) :=
Finset.univ.filter fun A =>
Fintype.card ι < 2 * (Finset.univ.filter fun i => A ∈ clusterSet (T i) a).card
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:928
Uses 4
Ultrametrics and UPGMA
StructureUltrametric on taxa#✓fully proved
d is an ultrametric on the taxa: symmetric, zero exactly on the diagonal, and
satisfying the three-point condition d x z ≤ max (d x y) (d y z) (equivalently, of the
three distances among any three taxa the two largest are equal).
structure IsUltrametric (d : X → X → ℝ) : Prop where
/-- Symmetry. -/
symm : ∀ x y, d x y = d y x
/-- Zero on the diagonal. -/
self : ∀ x, d x x = 0
/-- Positive off the diagonal. -/
pos : ∀ x y, x ≠ y → 0 < d x y
/-- The three-point condition. -/
three_point : ∀ x y z, d x z ≤ max (d x y) (d y z)
DefinitionMetric of a dated rooted tree#✓fully proved
d is the metric of a dated rooted tree, encoded by its clusters: a hierarchy H on
the taxa with dates h (0 at the leaves, strictly increasing from a cluster to any cluster
strictly containing it) such that d x y is the date of the smallest cluster containing x
and y (their most recent common ancestor). With edge lengths (h D - h C) / 2 from each
cluster C to its parent D, d x y is the path length from x to y and all leaves are
equidistant from the root (Semple & Steel 2003, Section 7.2).
def IsDatedTreeMetric (d : X → X → ℝ) : Prop :=
∃ (H : Finset (Finset X)) (h : Finset X → ℝ), IsHierarchy Finset.univ H ∧
(∀ x, h {x} = 0) ∧ (∀ C ∈ H, ∀ D ∈ H, C ⊂ D → h C < h D) ∧
∀ x y, ∃ C ∈ H, x ∈ C ∧ y ∈ C ∧ d x y = h C ∧ ∀ D ∈ H, x ∈ D → y ∈ D → C ⊆ D
def IsHierarchy (S : Finset α) (H : Finset (Finset α)) : Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:112
Uses 1 · Used by 1
TheoremUltrametrics satisfy the four-point condition#✓fully proved
Ultrametrics satisfy the four-point condition (Semple & Steel 2003, Section 7.2), so
every ultrametric on a finite set is a tree metric (IsUltrametric.isTreeMetric).
theorem IsUltrametric.fourPointCondition {d : X → X → ℝ} (hd : IsUltrametric d) :
MathlibExt.Biology.Phylogenetics.Buneman.FourPointCondition d
structure IsUltrametric (d : X → X → ℝ) : Prop where
/-- Symmetry. -/
symm : ∀ x y, d x y = d y x
/-- Zero on the diagonal. -/
self : ∀ x, d x x = 0
/-- Positive off the diagonal. -/
pos : ∀ x y, x ≠ y → 0 < d x y
/-- The three-point condition. -/
three_point : ∀ x y z, d x z ≤ max (d x y) (d y z)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1029
def FourPointCondition {X : Type*} (d : X → X → ℝ) : Prop :=
∀ x y z t, d x y + d z t ≤ max (d x z + d y t) (d x t + d y z)
MathlibExt/Biology/Phylogenetics/Buneman.lean:72
Uses 2 · Used by 1
TheoremEvery ultrametric is a tree metric#✓fully proved
Every ultrametric on a finite set is a tree metric (via Buneman's four-point theorem).
theorem IsUltrametric.isTreeMetric [Finite X] {d : X → X → ℝ} (hd : IsUltrametric d) :
MathlibExt.Biology.Phylogenetics.Buneman.IsTreeMetric d
structure IsUltrametric (d : X → X → ℝ) : Prop where
/-- Symmetry. -/
symm : ∀ x y, d x y = d y x
/-- Zero on the diagonal. -/
self : ∀ x, d x x = 0
/-- Positive off the diagonal. -/
pos : ∀ x y, x ≠ y → 0 < d x y
/-- The three-point condition. -/
three_point : ∀ x y z, d x z ≤ max (d x y) (d y z)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1029
def IsTreeMetric {X : Type*} (d : X → X → ℝ) : Prop :=
∃ (V : Type) (_ : Fintype V) (G : SimpleGraph V) (_ : G.IsTree) (w : Sym2 V → ℝ)
(ι : X → V), (∀ e ∈ G.edgeSet, 0 < w e) ∧
∀ x y (p : G.Walk (ι x) (ι y)), p.IsPath → d x y = (p.edges.map w).sum
MathlibExt/Biology/Phylogenetics/Buneman.lean:66
Uses 4
TheoremUltrametrics are dated tree metrics#✓fully proved
Ultrametrics are dated tree metrics (Semple & Steel 2003, Theorem 7.2.5): on a nonempty finite set of taxa, a dissimilarity satisfies the three-point condition (and is a metric) iff it is the metric of a dated rooted tree.
theorem isUltrametric_iff_isDatedTreeMetric [Nonempty X] (d : X → X → ℝ) :
IsUltrametric d ↔ IsDatedTreeMetric d
structure IsUltrametric (d : X → X → ℝ) : Prop where
/-- Symmetry. -/
symm : ∀ x y, d x y = d y x
/-- Zero on the diagonal. -/
self : ∀ x, d x x = 0
/-- Positive off the diagonal. -/
pos : ∀ x y, x ≠ y → 0 < d x y
/-- The three-point condition. -/
three_point : ∀ x y z, d x z ≤ max (d x y) (d y z)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1029
def IsDatedTreeMetric (d : X → X → ℝ) : Prop :=
∃ (H : Finset (Finset X)) (h : Finset X → ℝ), IsHierarchy Finset.univ H ∧
(∀ x, h {x} = 0) ∧ (∀ C ∈ H, ∀ D ∈ H, C ⊂ D → h C < h D) ∧
∀ x y, ∃ C ∈ H, x ∈ C ∧ y ∈ C ∧ d x y = h C ∧ ∀ D ∈ H, x ∈ D → y ∈ D → C ⊆ D
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1045
Uses 3
DefinitionAverage linkage between clusters#✓fully proved
The average linkage between two clusters: the mean of d x y over x ∈ C, y ∈ D.
noncomputable def avgDist (d : X → X → ℝ) (C D : Finset X) : ℝ :=
(∑ x ∈ C, ∑ y ∈ D, d x y) / (C.card * D.card : ℝ)
Used by 3
InductiveStates reachable by UPGMA#✓fully proved
The states reachable by UPGMA (Sokal & Michener 1958) on d: a partition P of the
taxa into blocks and the heights c x y recorded so far. It starts from the singletons; each
step merges two distinct blocks C, D of least average linkage (ties broken arbitrarily) and
records avgDist d C D as the height at which every x ∈ C and y ∈ D are joined (the
distance between them in the output tree; their common ancestor sits at half of it).
inductive UpgmaReaches (d : X → X → ℝ) : Finset (Finset X) → (X → X → ℝ) → Prop
| init : UpgmaReaches d (Finset.univ.image ({·})) fun _ _ => 0
| step {P : Finset (Finset X)} {c : X → X → ℝ} {C D : Finset X} :
UpgmaReaches d P c → C ∈ P → D ∈ P → C ≠ D →
(∀ E ∈ P, ∀ F ∈ P, E ≠ F → avgDist d C D ≤ avgDist d E F) →
UpgmaReaches d (insert (C ∪ D) ((P.erase C).erase D))
fun x y => if (x ∈ C ∧ y ∈ D) ∨ (x ∈ D ∧ y ∈ C) then avgDist d C D else c x y
noncomputable def avgDist (d : X → X → ℝ) (C D : Finset X) : ℝ :=
(∑ x ∈ C, ∑ y ∈ D, d x y) / (C.card * D.card : ℝ)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1259
Uses 1 · Used by 2
TheoremUPGMA is exact on ultrametrics#✓fully proved
In every UPGMA run on an ultrametric, the recorded
height of two taxa in the same block is their distance. In particular a completed run (one
block) reconstructs d, i.e. the dated tree, exactly (Semple & Steel 2003, Section 7.2).
theorem upgma_exact {d : X → X → ℝ} (hd : IsUltrametric d) {P : Finset (Finset X)}
{c : X → X → ℝ} (h : UpgmaReaches d P c) {B : Finset X} (hB : B ∈ P) {x y : X}
(hx : x ∈ B) (hy : y ∈ B) : c x y = d x y
structure IsUltrametric (d : X → X → ℝ) : Prop where
/-- Symmetry. -/
symm : ∀ x y, d x y = d y x
/-- Zero on the diagonal. -/
self : ∀ x, d x x = 0
/-- Positive off the diagonal. -/
pos : ∀ x y, x ≠ y → 0 < d x y
/-- The three-point condition. -/
three_point : ∀ x y z, d x z ≤ max (d x y) (d y z)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1029
inductive UpgmaReaches (d : X → X → ℝ) : Finset (Finset X) → (X → X → ℝ) → Prop
| init : UpgmaReaches d (Finset.univ.image ({·})) fun _ _ => 0
| step {P : Finset (Finset X)} {c : X → X → ℝ} {C D : Finset X} :
UpgmaReaches d P c → C ∈ P → D ∈ P → C ≠ D →
(∀ E ∈ P, ∀ F ∈ P, E ≠ F → avgDist d C D ≤ avgDist d E F) →
UpgmaReaches d (insert (C ∪ D) ((P.erase C).erase D))
fun x y => if (x ∈ C ∧ y ∈ D) ∨ (x ∈ D ∧ y ∈ C) then avgDist d C D else c x y
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1267
Uses 3
TheoremUPGMA always completes#✓fully proved
UPGMA always completes: from the singletons it reaches the single block univ.
theorem exists_upgmaReaches_univ [Nonempty X] (d : X → X → ℝ) :
∃ c, UpgmaReaches d {Finset.univ} c
inductive UpgmaReaches (d : X → X → ℝ) : Finset (Finset X) → (X → X → ℝ) → Prop
| init : UpgmaReaches d (Finset.univ.image ({·})) fun _ _ => 0
| step {P : Finset (Finset X)} {c : X → X → ℝ} {C D : Finset X} :
UpgmaReaches d P c → C ∈ P → D ∈ P → C ≠ D →
(∀ E ∈ P, ∀ F ∈ P, E ≠ F → avgDist d C D ≤ avgDist d E F) →
UpgmaReaches d (insert (C ∪ D) ((P.erase C).erase D))
fun x y => if (x ∈ C ∧ y ∈ D) ∨ (x ∈ D ∧ y ∈ C) then avgDist d C D else c x y
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1267
Uses 2
Rooted triplets, quartets and BUILD
StructureRooted triplet#✓fully proved
A rooted triplet xy|z: x and y are closer to each other than to z.
structure Triplet (α : Type*) where
/-- The first taxon of the cherry. -/
x : α
/-- The second taxon of the cherry. -/
y : α
/-- The outgroup. -/
z : α
DefinitionCluster system displaying a triplet#✓fully proved
The cluster system H displays the triplet xy|z: some cluster contains x and y
but not z.
def DisplaysTriplet (H : Finset (Finset α)) (t : Triplet α) : Prop :=
∃ C ∈ H, t.x ∈ C ∧ t.y ∈ C ∧ t.z ∉ C
structure Triplet (α : Type*) where
/-- The first taxon of the cherry. -/
x : α
/-- The second taxon of the cherry. -/
y : α
/-- The outgroup. -/
z : α
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1494
Uses 1 · Used by 3
DefinitionCut in the Aho graph#✓fully proved
The Aho graph of the triplets R on S' (vertices S', an edge x y for each
xy|z ∈ R with x, y, z ∈ S') has a cut: a partition of S' into two nonempty parts with no
edge across, i.e. the graph is disconnected.
def HasAhoCut (R : Finset (Triplet α)) (S' : Finset α) : Prop :=
∃ K ⊆ S', K.Nonempty ∧ (S' \ K).Nonempty ∧
∀ t ∈ R, t.x ∈ S' → t.y ∈ S' → t.z ∈ S' → (t.x ∈ K ↔ t.y ∈ K)
structure Triplet (α : Type*) where
/-- The first taxon of the cherry. -/
x : α
/-- The second taxon of the cherry. -/
y : α
/-- The outgroup. -/
z : α
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1494
Uses 1 · Used by 1
TheoremA rooted binary tree is determined by its triplets#✓fully proved
A rooted binary tree is determined by its triplets (Semple & Steel 2003, Theorem
6.4.1): two binary hierarchies on S displaying the same triplets are equal.
theorem eq_of_displaysTriplet_iff {S : Finset α} {H H' : Finset (Finset α)}
(hH : IsBinaryHierarchy S H) (hH' : IsBinaryHierarchy S H')
(h : ∀ t : Triplet α, DisplaysTriplet H t ↔ DisplaysTriplet H' t) : H = H'
def IsBinaryHierarchy {α : Type*} [DecidableEq α] (S : Finset α) (H : Finset (Finset α)) :
Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
(∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) ∧
∀ C ∈ H, 1 < C.card → ∃ D₁ ∈ H, ∃ D₂ ∈ H, Disjoint D₁ D₂ ∧ D₁ ∪ D₂ = C
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:95
structure Triplet (α : Type*) where
/-- The first taxon of the cherry. -/
x : α
/-- The second taxon of the cherry. -/
y : α
/-- The outgroup. -/
z : α
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1494
def DisplaysTriplet (H : Finset (Finset α)) (t : Triplet α) : Prop :=
∃ C ∈ H, t.x ∈ C ∧ t.y ∈ C ∧ t.z ∉ C
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1504
Uses 3 · Used by 1
TheoremCorrectness of BUILD#✓fully proved
Correctness of BUILD (Aho, Sagiv, Szymanski & Ullman 1981; Semple & Steel 2003,
Section 6.4): a set R of triplets on a nonempty S, none of the degenerate form xx|x (which
no tree displays and no cut detects), is displayed by a rooted binary phylogenetic tree on S
iff for every subset S' of at least two taxa the Aho graph of R on S' is disconnected.
BUILD splits along the components and recurses; the converse direction builds the tree this
way, splitting along any cut.
theorem build_spec {S : Finset α} (hS : S.Nonempty) (R : Finset (Triplet α))
(hR : ∀ t ∈ R, t.x ∈ S ∧ t.y ∈ S ∧ t.z ∈ S ∧ (t.z ≠ t.x ∨ t.z ≠ t.y)) :
(∃ H, IsBinaryHierarchy S H ∧ ∀ t ∈ R, DisplaysTriplet H t) ↔
∀ S' ⊆ S, 2 ≤ S'.card → HasAhoCut R S'
structure Triplet (α : Type*) where
/-- The first taxon of the cherry. -/
x : α
/-- The second taxon of the cherry. -/
y : α
/-- The outgroup. -/
z : α
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1494
def IsBinaryHierarchy {α : Type*} [DecidableEq α] (S : Finset α) (H : Finset (Finset α)) :
Prop :=
S ∈ H ∧ (∀ C ∈ H, C.Nonempty ∧ C ⊆ S) ∧ (∀ x ∈ S, {x} ∈ H) ∧
(∀ C ∈ H, ∀ D ∈ H, C ⊆ D ∨ D ⊆ C ∨ Disjoint C D) ∧
∀ C ∈ H, 1 < C.card → ∃ D₁ ∈ H, ∃ D₂ ∈ H, Disjoint D₁ D₂ ∧ D₁ ∪ D₂ = C
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:95
def DisplaysTriplet (H : Finset (Finset α)) (t : Triplet α) : Prop :=
∃ C ∈ H, t.x ∈ C ∧ t.y ∈ C ∧ t.z ∉ C
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1504
def HasAhoCut (R : Finset (Triplet α)) (S' : Finset α) : Prop :=
∃ K ⊆ S', K.Nonempty ∧ (S' \ K).Nonempty ∧
∀ t ∈ R, t.x ∈ S' → t.y ∈ S' → t.z ∈ S' → (t.x ∈ K ↔ t.y ∈ K)
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1510
Uses 4
DefinitionTree displaying a quartet#✓fully proved
T displays the quartet xy|zw: some edge split of T has x, y on one side and
z, w on the other.
def DisplaysQuartet (T : UnrootedBinaryTree X) (x y z w : X) : Prop :=
∃ A ∈ edgeSplits T, x ∈ A ∧ y ∈ A ∧ z ∉ A ∧ w ∉ A
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
noncomputable def edgeSplits (T : UnrootedBinaryTree X) : Finset (Finset X) :=
((Finset.univ ×ˢ Finset.univ).filter fun e : T.V × T.V => T.G.Adj e.1 e.2).image
fun e => edgeSide T e.1 e.2
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:540
Uses 2 · Used by 1
TheoremAn unrooted binary tree is determined by its quartets#✓fully proved
An unrooted binary tree is determined by its quartets (Semple & Steel 2003, Corollary
6.3.8): two trees displaying the same quartets are isomorphic. Already the quartets containing
the taxon a suffice; they are the rooted triplets seen from a.
theorem iso_of_displaysQuartet_iff {T T' : UnrootedBinaryTree X} (a : X)
(h : ∀ x y z, DisplaysQuartet T x y z a ↔ DisplaysQuartet T' x y z a) : T.Iso T'
structure UnrootedBinaryTree (X : Type) : Type 1 where
/-- The vertex type. -/
V : Type
/-- The vertex type is finite. -/
[fintype : Fintype V]
/-- The tree. -/
G : SimpleGraph V
/-- Adjacency is decidable (so that degrees are defined). -/
[decRel : DecidableRel G.Adj]
/-- `G` is a tree. -/
isTree : G.IsTree
/-- The bijective labeling of the leaves by the taxa. -/
⋯
MathlibExt/Biology/Phylogenetics/UnrootedTreeCount.lean:66
def DisplaysQuartet (T : UnrootedBinaryTree X) (x y z w : X) : Prop :=
∃ A ∈ edgeSplits T, x ∈ A ∧ y ∈ A ∧ z ∉ A ∧ w ∉ A
CSLibExt/Bioinformatics/Phylogenetics/Splits.lean:1709
Uses 13
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.