Multispecies coalescent
Species trees
InductiveRooted binary species tree with branch lengths#✓fully proved
A rooted binary species tree on the species Fin n with branch lengths: leaf i is
species i, and node l r t is the ancestral species of the species below l and r, where
t is the length, in coalescent units (2N generations), of the branch above the node, i.e.
the time during which the ancestral population of l and r exists before it merges with a
sister population. The length stored at the root node is not used: the root population lasts
until all lineages have coalesced. Leaf branch lengths are not recorded, because one gene
lineage is sampled per species and a single lineage cannot coalesce. A species tree on the
species Fin n labels each species by exactly one leaf; the type does not enforce this, and
the theorems below are about concrete trees with this property. The type accepts any real
branch length; the probabilistic statements assume nonnegative lengths (NonnegLengths).
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
Used by 31
DefinitionSpecies tree with nonnegative branch lengths#✓fully proved
Every branch length of the species tree, including the unused one stored at the root, is
nonnegative. On such trees geneTreeProb is a probability law; for a negative length it is
only a signed weight.
def NonnegLengths : SpeciesTree n → Prop
| leaf _ => True
| node l r t => l.NonnegLengths ∧ r.NonnegLengths ∧ 0 ≤ t
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
Uses 1 · Used by 3
DefinitionSpecies below a node of a species tree#✓fully proved
The species below a node.
def taxa : SpeciesTree n → Finset (Fin n)
| leaf i => {i}
| node l r _ => l.taxa ∪ r.taxa
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
Uses 1 · Used by 3
DefinitionClusters of a species tree#✓fully proved
The clusters (clades) of a species tree: the sets of species below its vertices, including the singletons and the full set of species.
def clusters : SpeciesTree n → Finset (Finset (Fin n))
| leaf i => {{i}}
| node l r _ => insert (l.taxa ∪ r.taxa) (l.clusters ∪ r.clusters)
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
Uses 2 · Used by 6
DefinitionTopology of a species tree#✓fully proved
The topology of a species tree, forgetting branch lengths, as a planar rooted binary tree.
def shape : SpeciesTree n → MathlibExt.Biology.Phylogenetics.TreeCount.PlaneTree (Fin n)
| leaf i => .leaf i
| node l r _ => .node l.shape r.shape
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
inductive PlaneTree (α : Type u) where
/-- A leaf labeled `a`. -/
| leaf : α → PlaneTree α
/-- An internal vertex with left subtree `l` and right subtree `r`. -/
| node : PlaneTree α → PlaneTree α → PlaneTree α
deriving DecidableEq
MathlibExt/Biology/Phylogenetics/TreeCount.lean:70
Uses 2
Tavaré's probabilities sum to one
TheoremTavaré's probabilities sum to one#✓fully proved
From m ≥ 1 lineages, the number of ancestors at
time t is one of 1, …, m. (The rows of exp (t • G) restricted to the states ≥ 1 sum to
one because G kills the indicator of {1, …, n}; an identity for every real t.)
theorem sum_tavareProb {m : ℕ} (hm : 1 ≤ m) (t : ℝ) :
∑ j ∈ Finset.Icc 1 m, tavareProb m j t = 1
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 3 · Used by 1
TheoremTavaré's probabilities are nonnegative#✓fully proved
Tavaré's probabilities are nonnegative for t ≥ 0: exp (t • G) is the entrywise limit
of powers of the Wright–Fisher transition matrix (tendsto_wfLineageMatrix_pow_floor), whose
entries are nonnegative. (For t < 0 they can be negative or exceed one.)
theorem tavareProb_nonneg {m j : ℕ} (hj : j ∈ Icc 1 m) {t : ℝ} (ht : 0 ≤ t) :
0 ≤ tavareProb m j t
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 5 · Used by 3
Coalescence inside one population
DefinitionLineages after the first coalescence events of a ranked history#✓fully proved
The lineages after the first t coalescence events of the ranked history h (of m
lineages), starting from the lineages bs, each given as the set of sampled genes it is
ancestral to. Events follow the encoding of RankedHistory: the pair {a, b} with a < b
merges into position a, and position b is removed (mergeBlocks). With the singletons as
starting lineages this is blocksAfter (mergeAlong_singletons).
def mergeAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
List (Finset (Fin n)) :=
((List.finRange (m - 1)).take t).foldl
(fun bs i =>
let s : Finset ℕ := (h i).1.map Fin.valEmbedding
mergeBlocks bs (s.min.getD 0) (s.max.getD 0))
bs
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
def mergeBlocks {n : ℕ} (bs : List (Finset (Fin n))) (a b : ℕ) : List (Finset (Fin n)) :=
(bs.set a (bs.getD a ∅ ∪ bs.getD b ∅)).eraseIdx b
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:80
Uses 2 · Used by 22
TheoremMerging lineages from singletons gives the ancestral blocks#✓fully proved
Starting from the singletons, mergeAlong is blocksAfter.
theorem mergeAlong_singletons (h : RankedHistory n) (t : ℕ) :
mergeAlong ((List.finRange n).map fun j => {j}) h t = blocksAfter h t
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
def mergeAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
List (Finset (Fin n)) :=
((List.finRange (m - 1)).take t).foldl
(fun bs i =>
let s : Finset ℕ := (h i).1.map Fin.valEmbedding
mergeBlocks bs (s.min.getD 0) (s.max.getD 0))
bs
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:272
def blocksAfter {n : ℕ} (h : RankedHistory n) (t : ℕ) : List (Finset (Fin n)) :=
((List.finRange (n - 1)).take t).foldl
(fun bs i =>
let s : Finset ℕ := (h i).1.map Fin.valEmbedding
mergeBlocks bs (s.min.getD 0) (s.max.getD 0))
((List.finRange n).map fun j => {j})
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:85
DefinitionClusters formed along a ranked history#✓fully proved
The clusters formed during the first t coalescence events of h from the lineages bs:
every lineage present at some step u ≤ t, as the set of sampled genes it is ancestral to.
def cladesAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
Finset (Finset (Fin n)) :=
(range (t + 1)).biUnion fun u => (mergeAlong bs h u).toFinset
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
def mergeAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
List (Finset (Fin n)) :=
((List.finRange (m - 1)).take t).foldl
(fun bs i =>
let s : Finset ℕ := (h i).1.map Fin.valEmbedding
mergeBlocks bs (s.min.getD 0) (s.max.getD 0))
bs
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:272
Uses 2 · Used by 24
The multispecies coalescent
DefinitionCoalescence along one branch of the species tree#✓fully proved
One population of the multispecies coalescent along a branch of length t. It receives
m lineages bs (and the clusters acc formed below it). Under Kingman's coalescent the
number j of lineages left at the top of the branch has law tavareProb m j t (Tavaré's
formula, exp_blockCountingGenerator_apply), and, independently of the coalescence times, the
order of the m - j coalescences is the beginning of a random-joining history of the m
lineages (randomJoining). The continuation k receives the number of exiting lineages, the
lineages, and the clusters formed so far.
def branchStep (t : ℝ) (m : ℕ) (bs : List (Finset (Fin n))) (acc : Finset (Finset (Fin n)))
(k : ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) : ℝ :=
∑ j ∈ Icc 1 m, tavareProb m j t *
∫ h, k j (mergeAlong bs h (m - j)) (acc ∪ cladesAlong bs h (m - j)) ∂randomJoining m
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
def mergeAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
List (Finset (Fin n)) :=
((List.finRange (m - 1)).take t).foldl
(fun bs i =>
let s : Finset ℕ := (h i).1.map Fin.valEmbedding
mergeBlocks bs (s.min.getD 0) (s.max.getD 0))
bs
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:272
def cladesAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
Finset (Finset (Fin n)) :=
(range (t + 1)).biUnion fun u => (mergeAlong bs h u).toFinset
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:287
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
Uses 6 · Used by 11
DefinitionLaw of the lineages leaving a species-tree branch#✓fully proved
The law of the lineages leaving the top of the branch above a vertex of the species tree,
in continuation-passing form: exitLaw T k is the expectation of k m bs acc, where m is
the number of exiting lineages, bs the lineages and acc the clusters formed below. The two
daughter populations evolve independently, and their lineages enter the ancestral population
together.
def exitLaw : SpeciesTree n → (ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) → ℝ
| leaf i, k => k 1 [{i}] {{i}}
| node l r t, k => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
branchStep t (ml + mr) (bl ++ br) (al ∪ ar) k
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def branchStep (t : ℝ) (m : ℕ) (bs : List (Finset (Fin n))) (acc : Finset (Finset (Fin n)))
(k : ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) : ℝ :=
∑ j ∈ Icc 1 m, tavareProb m j t *
∫ h, k j (mergeAlong bs h (m - j)) (acc ∪ cladesAlong bs h (m - j)) ∂randomJoining m
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:300
Uses 2 · Used by 19
DefinitionThe multispecies coalescent#✓fully proved
The multispecies coalescent (Pamilo & Nei 1988; Degnan & Salter 2005), one lineage
sampled per species: the probability that the gene tree, given by its set of clusters, lies in
the event E. Below the root, each branch population runs Kingman's coalescent for the
branch length (branchStep); in the root population all remaining lineages coalesce by
random joining. The definition accepts any real branch lengths; it is a probability law on
species trees with nonnegative branch lengths (geneTreeProb_nonneg, geneTreeProb_or,
geneTreeProb_true), and only a signed weight otherwise (with internal branch -1, the
matching three-species gene tree gets 1 - (2/3) e < 0).
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def exitLaw : SpeciesTree n → (ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) → ℝ
| leaf i, k => k 1 [{i}] {{i}}
| node l r t, k => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
branchStep t (ml + mr) (bl ++ br) (al ∪ ar) k
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:310
def cladesAlong {m : ℕ} (bs : List (Finset (Fin n))) (h : RankedHistory m) (t : ℕ) :
Finset (Finset (Fin n)) :=
(range (t + 1)).biUnion fun u => (mergeAlong bs h u).toFinset
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:287
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
Uses 6 · Used by 26
TheoremRoot branch length does not affect gene-tree probabilities#✓fully proved
The branch length stored at the root of a species tree does not affect the gene tree.
theorem geneTreeProb_node_length (l r : SpeciesTree n) (t t' : ℝ)
(E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
geneTreeProb (.node l r t) E = geneTreeProb (.node l r t') E
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
Uses 2
TheoremExit law of a constant continuation#✓fully proved
If a continuation takes the constant value c whenever at least one lineage exits, then
so does exitLaw (Tavaré's probabilities sum to one and random joining is a probability).
theorem exitLaw_eq_const (T : SpeciesTree n) (c : ℝ)
(k : ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ)
(hk : ∀ m bs acc, 1 ≤ m → k m bs acc = c) : exitLaw T k = c
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def exitLaw : SpeciesTree n → (ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) → ℝ
| leaf i, k => k 1 [{i}] {{i}}
| node l r t, k => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
branchStep t (ml + mr) (bl ++ br) (al ∪ ar) k
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:310
Uses 10 · Used by 2
TheoremNormalization#✓fully proved
For every species tree, the event "any gene tree" has weight one (an
identity for every real branch length). With geneTreeProb_nonneg and geneTreeProb_or this
makes geneTreeProb T a probability law when T.NonnegLengths.
theorem geneTreeProb_true (T : SpeciesTree n) : geneTreeProb T (fun _ => True) = 1
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
Uses 8
TheoremTotal gene-tree probability is one#✓fully proved
An event containing every gene tree has weight one, for every species tree.
theorem geneTreeProb_eq_one (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop)
[DecidablePred E] (hE : ∀ G, E G) : geneTreeProb T E = 1
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
TheoremNonnegativity of the exit law#✓fully proved
On a species tree with nonnegative branch lengths, exitLaw of a continuation that is
nonnegative whenever at least one lineage exits is nonnegative (Tavaré's probabilities are
nonnegative, tavareProb_nonneg).
theorem exitLaw_nonneg : ∀ (T : SpeciesTree n), T.NonnegLengths →
∀ k : ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ,
(∀ m bs acc, 1 ≤ m → 0 ≤ k m bs acc) → 0 ≤ exitLaw T k
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def exitLaw : SpeciesTree n → (ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) → ℝ
| leaf i, k => k 1 [{i}] {{i}}
| node l r t, k => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
branchStep t (ml + mr) (bl ++ br) (al ∪ ar) k
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:310
Uses 11 · Used by 1
TheoremGene-tree probabilities are nonnegative#✓fully proved
Gene-tree probabilities are nonnegative on species trees with nonnegative branch lengths. (For a negative branch length they need not be.)
theorem geneTreeProb_nonneg {T : SpeciesTree n} (hT : T.NonnegLengths)
(E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] : 0 ≤ geneTreeProb T E
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
Uses 9 · Used by 1
Evaluating random-joining expectations
TheoremExpectation under random joining as an average over histories#✓fully proved
An expectation under random joining is the average over the ∏_{k=2}^m C(k, 2) ranked
histories.
theorem integral_randomJoining (m : ℕ) (f : RankedHistory m → ℝ) :
∫ h, f h ∂randomJoining m = (∑ h, f h) / ∏ k ∈ Icc 2 m, ((k.choose 2 : ℕ) : ℝ)
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
Uses 4 · Used by 4
TheoremRational-valued expectation under random joining#✓fully proved
integral_randomJoining for a rational-valued function, with a rational result (used to
evaluate random-joining probabilities by computation).
theorem integral_randomJoining_ratCast (m : ℕ) (q : RankedHistory m → ℚ) :
∫ h, (q h : ℝ) ∂randomJoining m =
(((∑ h, q h) / ∏ k ∈ Icc 2 m, ((k.choose 2 : ℕ) : ℚ) : ℚ) : ℝ)
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
Uses 4 · Used by 13
TheoremRandom-joining probability as a fraction of ranked histories#✓fully proved
The probability of an event under random joining is the fraction of ranked histories in it.
theorem randomJoining_real (m : ℕ) (A : Set (RankedHistory m)) [DecidablePred (· ∈ A)] :
(randomJoining m).real A = (#{h | h ∈ A} : ℝ) / ∏ k ∈ Icc 2 m, ((k.choose 2 : ℕ) : ℝ)
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
Uses 4 · Used by 1
TheoremAdditivity of the exit law#✓fully proved
exitLaw is additive in the continuation.
theorem exitLaw_add (T : SpeciesTree n)
(k₁ k₂ : ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) :
exitLaw T (fun m bs acc => k₁ m bs acc + k₂ m bs acc) = exitLaw T k₁ + exitLaw T k₂
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def exitLaw : SpeciesTree n → (ℕ → List (Finset (Fin n)) → Finset (Finset (Fin n)) → ℝ) → ℝ
| leaf i, k => k 1 [{i}] {{i}}
| node l r t, k => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
branchStep t (ml + mr) (bl ++ br) (al ∪ ar) k
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:310
Uses 9 · Used by 1
TheoremAdditivity#✓fully proved
The probabilities of two disjoint events of gene trees add up. With
geneTreeProb_nonneg and geneTreeProb_true, geneTreeProb T is a probability law when
T.NonnegLengths.
theorem geneTreeProb_or (T : SpeciesTree n) (E F : Finset (Finset (Fin n)) → Prop)
[DecidablePred E] [DecidablePred F] (hEF : ∀ G, E G → ¬ F G) :
geneTreeProb T (fun G => E G ∨ F G) = geneTreeProb T E + geneTreeProb T F
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
Uses 8 · Used by 1
TheoremGene-tree probabilities are at most one#✓fully proved
On a species tree with nonnegative branch lengths, every gene-tree probability is at most one.
theorem geneTreeProb_le_one {T : SpeciesTree n} (hT : T.NonnegLengths)
(E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] : geneTreeProb T E ≤ 1
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
Tavaré's formula for two and three lineages
TheoremTwo lineages remain distinct with probability \(e^{-t}\)#✓fully proved
Two lineages are still distinct after time t with probability e^{-t}.
theorem tavareProb_two_two (t : ℝ) : tavareProb 2 2 t = Real.exp (-t)
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 1 · Used by 14
TheoremTwo lineages coalesce with probability \(1 - e^{-t}\)#✓fully proved
Two lineages have coalesced within time t with probability 1 - e^{-t}.
theorem tavareProb_two_one (t : ℝ) : tavareProb 2 1 t = 1 - Real.exp (-t)
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 1 · Used by 9
TheoremThree lineages remain distinct with probability \(e^{-3t}\)#✓fully proved
Three lineages are still distinct after time t with probability e^{-3t}.
theorem tavareProb_three_three (t : ℝ) : tavareProb 3 3 t = Real.exp (-(3 * t))
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 1 · Used by 7
TheoremThree lineages have two ancestors at time \(t\)#✓fully proved
Three lineages have two ancestors at time t with probability (3/2)(e^{-t} - e^{-3t}).
theorem tavareProb_three_two (t : ℝ) :
tavareProb 3 2 t = 3 / 2 * (Real.exp (-t) - Real.exp (-(3 * t)))
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 1 · Used by 7
TheoremThree lineages have one ancestor at time \(t\)#✓fully proved
Three lineages have one ancestor at time t with probability
1 - (3/2) e^{-t} + (1/2) e^{-3t}.
theorem tavareProb_three_one (t : ℝ) :
tavareProb 3 1 t = 1 - 3 / 2 * Real.exp (-t) + 1 / 2 * Real.exp (-(3 * t))
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Uses 1 · Used by 7
Three species
DefinitionThree-species tree ((0, 1), 2)#✓fully proved
The three-species tree ((0, 1), 2) with internal branch length t.
def triple (t : ℝ) : SpeciesTree 3 := .node (.node (.leaf 0) (.leaf 1) t) (.leaf 2) 0
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
Uses 1 · Used by 5
DefinitionThree-gene tree with a given cherry#✓fully proved
The gene tree on three genes with cherry c (a pair of genes), as a set of clusters.
TheoremClusters of the three-species tree#✓fully proved
The species tree ((0, 1), 2) has the clusters of the gene tree with cherry {0, 1}.
theorem clusters_triple (t : ℝ) : (triple t).clusters = tripleTree {0, 1}
def triple (t : ℝ) : SpeciesTree 3 := .node (.node (.leaf 0) (.leaf 1) t) (.leaf 2) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:551
def tripleTree (c : Finset (Fin 3)) : Finset (Finset (Fin 3)) := {{0}, {1}, {2}, c, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:554
Uses 5 · Used by 1
TheoremThree-species concordance#✓fully proved
Three-species concordance (Hudson 1983; Pamilo & Nei 1988): with one lineage per
species and internal branch length t, the gene tree matches the species tree with
probability 1 - (2/3) e^{-t}. (An identity for every real t; branch lengths are t ≥ 0.)
theorem geneTreeProb_triple_matching (t : ℝ) :
geneTreeProb (triple t) (· = tripleTree {0, 1}) = 1 - 2 / 3 * Real.exp (-t)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def triple (t : ℝ) : SpeciesTree 3 := .node (.node (.leaf 0) (.leaf 1) t) (.leaf 2) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:551
def tripleTree (c : Finset (Fin 3)) : Finset (Finset (Fin 3)) := {{0}, {1}, {2}, c, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:554
Uses 12 · Used by 1
TheoremProbability of the discordant three-species gene tree with cherry \(\{0, 2\}\)#✓fully proved
With one lineage per species and internal branch length \(t\), the gene tree of the species tree \(((0, 1), 2)\) whose cherry is \(\{0, 2\}\) has probability \(\frac{1}{3} e^{-t}\). (An identity for every real \(t\); branch lengths are \(t \ge 0\).)
theorem geneTreeProb_triple_cherry_02 (t : ℝ) :
geneTreeProb (triple t) (· = tripleTree {0, 2}) = 1 / 3 * Real.exp (-t)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def triple (t : ℝ) : SpeciesTree 3 := .node (.node (.leaf 0) (.leaf 1) t) (.leaf 2) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:551
def tripleTree (c : Finset (Fin 3)) : Finset (Finset (Fin 3)) := {{0}, {1}, {2}, c, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:554
Uses 11 · Used by 1
TheoremProbability of the discordant three-species gene tree with cherry \(\{1, 2\}\)#✓fully proved
With one lineage per species and internal branch length \(t\), the gene tree of the species tree \(((0, 1), 2)\) whose cherry is \(\{1, 2\}\) has probability \(\frac{1}{3} e^{-t}\). (An identity for every real \(t\); branch lengths are \(t \ge 0\).)
theorem geneTreeProb_triple_cherry_12 (t : ℝ) :
geneTreeProb (triple t) (· = tripleTree {1, 2}) = 1 / 3 * Real.exp (-t)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def triple (t : ℝ) : SpeciesTree 3 := .node (.node (.leaf 0) (.leaf 1) t) (.leaf 2) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:551
def tripleTree (c : Finset (Fin 3)) : Finset (Finset (Fin 3)) := {{0}, {1}, {2}, c, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:554
Uses 11 · Used by 1
TheoremNo anomalous gene trees for three species#✓fully proved
No anomalous gene trees for three species (Degnan & Rosenberg 2006): for a positive internal branch, each discordant gene tree is strictly less probable than the matching one.
theorem triple_no_anomaly {t : ℝ} (ht : 0 < t) :
geneTreeProb (triple t) (· = tripleTree {0, 2}) <
geneTreeProb (triple t) (· = (triple t).clusters) ∧
geneTreeProb (triple t) (· = tripleTree {1, 2}) <
geneTreeProb (triple t) (· = (triple t).clusters)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def triple (t : ℝ) : SpeciesTree 3 := .node (.node (.leaf 0) (.leaf 1) t) (.leaf 2) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:551
def tripleTree (c : Finset (Fin 3)) : Finset (Finset (Fin 3)) := {{0}, {1}, {2}, c, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:554
Uses 8
TheoremWright–Fisher limit of the no-coalescence probability#✓fully proved
The three-species probabilities come from the Wright–Fisher model: in a population of M
gene copies, the lineages of species 0 and 1 have distinct parents in each of the
⌊t M⌋ generations of the internal branch (t ≥ 0 coalescent units) with probability
noCoalProb M 2 ^ ⌊t M⌋, which tends to tavareProb 2 2 t = e^{-t}, the weight of the case
in which three lineages reach the root population.
theorem tendsto_noCoalProb_pow_floor_two {t : ℝ} (ht : 0 ≤ t) :
Tendsto (fun M : ℕ => noCoalProb M 2 ^ ⌊t * M⌋₊) atTop (𝓝 (tavareProb 2 2 t))
def noCoalProb (M k : ℕ) : ℝ := ∏ i ∈ range k, (1 - (i : ℝ) / M)
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:256
noncomputable def tavareProb (i j : ℕ) (t : ℝ) : ℝ :=
∑ k ∈ Finset.Icc j i,
Real.exp (-((k : ℝ) * (k - 1) * t / 2)) * (2 * k - 1) * (-1) ^ (k - j) *
(j.ascFactorial (k - 1) : ℝ) * (i.descFactorial k : ℝ) /
((j.factorial : ℝ) * ((k - j).factorial : ℝ) * (i.ascFactorial k : ℝ))
MathlibExt/Biology/PopulationGenetics/Coalescent/BlockCounting.lean:102
Four species: the anomaly zone
DefinitionCaterpillar four-species tree#✓fully proved
The asymmetric (caterpillar) species tree (((0, 1), 2), 3): x is the length of the
deeper internal branch (above the ancestor of 0, 1, 2) and y that of the shallower one
(above the ancestor of 0, 1), as in Degnan & Rosenberg (2006).
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
Uses 1 · Used by 13
DefinitionBalanced four-species tree#✓fully proved
The symmetric (balanced) species tree ((0, 1), (2, 3)) with internal branch lengths y₁
(above the ancestor of 0, 1) and y₂ (above the ancestor of 2, 3).
def balanced (y₁ y₂ : ℝ) : SpeciesTree 4 :=
.node (.node (.leaf 0) (.leaf 1) y₁) (.node (.leaf 2) (.leaf 3) y₂) 0
inductive SpeciesTree (n : ℕ) where
/-- The species `i`. -/
| leaf : Fin n → SpeciesTree n
/-- The ancestor of `l` and `r`, with branch length `t` above it. -/
| node : SpeciesTree n → SpeciesTree n → ℝ → SpeciesTree n
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:134
Uses 1 · Used by 5
DefinitionCaterpillar four-gene tree#✓fully proved
The asymmetric gene tree (((a, b), c), d) on four genes, as a set of clusters.
DefinitionBalanced four-gene tree#✓fully proved
The symmetric gene tree ((a, b), (c, d)) on four genes, as a set of clusters.
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
Used by 9
TheoremClusters of the caterpillar species tree#✓fully proved
The species tree (((0, 1), 2), 3) has the clusters of the gene tree (((0, 1), 2), 3).
theorem clusters_caterpillar (x y : ℝ) : (caterpillar x y).clusters = caterpillarTree 0 1 2 3
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def caterpillarTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {a, b, c}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:641
Uses 5 · Used by 3
DefinitionDegnan–Rosenberg probability of the matching caterpillar gene tree#✓fully proved
Degnan & Rosenberg (2006), eq. (1): f(x, y), the probability of the matching gene tree
(((A, B), C), D) on the caterpillar species tree.
DefinitionDegnan–Rosenberg formula g for the gene tree ((A, C), (B, D))#✓fully proved
Degnan & Rosenberg (2006), eq. (2): g(x, y), the probability of the gene tree
((A, C), (B, D)) (and of ((A, D), (B, C))) on the caterpillar species tree.
Used by 7
DefinitionDegnan–Rosenberg formula h for the gene tree ((A, B), (C, D))#✓fully proved
Degnan & Rosenberg (2006), eq. (3): h(x, y), the probability of the gene tree
((A, B), (C, D)) on the caterpillar species tree.
def drH (x y : ℝ) : ℝ :=
1 / 3 * Real.exp (-x) - 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
Used by 6
TheoremThe matching gene tree#✓fully proved
The matching gene tree on the caterpillar species tree has probability f(x, y)
(Degnan & Rosenberg 2006, eq. (1)). An identity for all real x, y.
theorem geneTreeProb_caterpillar_matching (x y : ℝ) :
geneTreeProb (caterpillar x y) (· = caterpillarTree 0 1 2 3) = drF x y
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def caterpillarTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {a, b, c}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:641
def drF (x y : ℝ) : ℝ :=
1 - 2 / 3 * Real.exp (-x) - 2 / 3 * Real.exp (-y) + 1 / 3 * Real.exp (-(x + y)) +
1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:655
Uses 19 · Used by 2
TheoremProbability of the gene tree ((A, C), (B, D)) on the caterpillar#✓fully proved
The symmetric gene tree ((A, C), (B, D)) on the caterpillar species tree has probability
g(x, y) (Degnan & Rosenberg 2006, eq. (2)).
theorem geneTreeProb_caterpillar_AC_BD (x y : ℝ) :
geneTreeProb (caterpillar x y) (· = balancedTree 0 2 1 3) = drG x y
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
def drG (x y : ℝ) : ℝ := 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:661
Uses 19 · Used by 2
TheoremProbability of the gene tree ((A, D), (B, C)) on the caterpillar#✓fully proved
The symmetric gene tree ((A, D), (B, C)) on the caterpillar species tree has probability
g(x, y), the same as ((A, C), (B, D)) (Degnan & Rosenberg 2006).
theorem geneTreeProb_caterpillar_AD_BC (x y : ℝ) :
geneTreeProb (caterpillar x y) (· = balancedTree 0 3 1 2) = drG x y
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
def drG (x y : ℝ) : ℝ := 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:661
Uses 19 · Used by 1
TheoremProbability of the gene tree ((A, B), (C, D)) on the caterpillar#✓fully proved
The symmetric gene tree ((A, B), (C, D)) on the caterpillar species tree has probability
h(x, y) (Degnan & Rosenberg 2006, eq. (3)).
theorem geneTreeProb_caterpillar_AB_CD (x y : ℝ) :
geneTreeProb (caterpillar x y) (· = balancedTree 0 1 2 3) = drH x y
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
def drH (x y : ℝ) : ℝ :=
1 / 3 * Real.exp (-x) - 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:665
Uses 19 · Used by 2
DefinitionBoundary of the four-species anomaly zone#✓fully proved
Degnan & Rosenberg (2006), eq. (4): the boundary a(x) of the four-species anomaly zone,
for a deeper internal branch of length x > 0 (at x = 0 the denominator vanishes and Lean's
a / 0 = 0 gives the junk value log (2/3 - 0); a(x) → ∞ as x → 0⁺).
DefinitionBoundary for three anomalous gene trees#✓fully proved
Degnan & Rosenberg (2006), eq. (5): the boundary b(x) below which the caterpillar species
tree has three anomalous gene trees (defined for x ≥ 0).
Theorem\(g(x, y) < h(x, y)\) for a positive shallower branch#✓fully proved
For a positive shallower branch, the symmetric gene tree ((A, B), (C, D)) is strictly more
probable than ((A, C), (B, D)): g(x, y) < h(x, y) (Degnan & Rosenberg 2006).
theorem drG_lt_drH (x : ℝ) {y : ℝ} (hy : 0 < y) : drG x y < drH x y
def drG (x y : ℝ) : ℝ := 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:661
def drH (x y : ℝ) : ℝ :=
1 / 3 * Real.exp (-x) - 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:665
TheoremThe boundary a(x) of the anomaly zone#✓fully proved
The boundary a(x) of the anomaly zone (Degnan & Rosenberg 2006): for a deeper
internal branch x > 0, the symmetric gene tree ((A, B), (C, D)) is more probable than the
matching gene tree, f(x, y) < h(x, y), if and only if y < a(x).
theorem drF_lt_drH_iff {x : ℝ} (hx : 0 < x) (y : ℝ) : drF x y < drH x y ↔ y < anomalyA x
def drF (x y : ℝ) : ℝ :=
1 - 2 / 3 * Real.exp (-x) - 2 / 3 * Real.exp (-y) + 1 / 3 * Real.exp (-(x + y)) +
1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:655
def drH (x y : ℝ) : ℝ :=
1 / 3 * Real.exp (-x) - 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:665
def anomalyA (x : ℝ) : ℝ :=
Real.log (2 / 3 + (3 * Real.exp (2 * x) - 2) / (18 * (Real.exp (3 * x) - Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:744
TheoremDegnan–Rosenberg criterion: \(f(x, y) < g(x, y)\) iff \(y < b(x)\)#✓fully proved
Degnan & Rosenberg (2006): for x ≥ 0, the gene tree ((A, C), (B, D)) (equivalently
((A, D), (B, C))) is more probable than the matching gene tree, f(x, y) < g(x, y), if and
only if y < b(x).
theorem drF_lt_drG_iff {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : drF x y < drG x y ↔ y < anomalyB x
def drF (x y : ℝ) : ℝ :=
1 - 2 / 3 * Real.exp (-x) - 2 / 3 * Real.exp (-y) + 1 / 3 * Real.exp (-(x + y)) +
1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:655
def drG (x y : ℝ) : ℝ := 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:661
def anomalyB (x : ℝ) : ℝ :=
Real.log (2 / 3 + (5 * Real.exp (2 * x) - 2) / (6 * (3 * Real.exp (3 * x) -
2 * Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:749
TheoremValue \(\log(7/6)\) of the three-anomaly boundary at zero#✓fully proved
b(0) = log (7/6) (Degnan & Rosenberg 2006): if y ≥ log (7/6), then y ≥ b(x) for every
x ≥ 0 (anomalyB_le_anomalyB_zero).
theorem anomalyB_zero : anomalyB 0 = Real.log (7 / 6)
def anomalyB (x : ℝ) : ℝ :=
Real.log (2 / 3 + (5 * Real.exp (2 * x) - 2) / (6 * (3 * Real.exp (3 * x) -
2 * Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:749
Uses 1 · Used by 1
TheoremThree-anomaly boundary is maximal at zero#✓fully proved
b is maximal at 0: b(x) ≤ log (7/6) for x ≥ 0, so for y ≥ log (7/6) at most one
gene tree is anomalous.
theorem anomalyB_le_anomalyB_zero {x : ℝ} (hx : 0 ≤ x) : anomalyB x ≤ anomalyB 0
def anomalyB (x : ℝ) : ℝ :=
Real.log (2 / 3 + (5 * Real.exp (2 * x) - 2) / (6 * (3 * Real.exp (3 * x) -
2 * Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:749
Uses 2
TheoremAnomaly-zone boundary blows up for short deep branches#✓fully proved
a(x) → ∞ as x → 0⁺ (Degnan & Rosenberg 2006): very short deep branches produce an
anomalous gene tree however long the shallower branch is.
theorem tendsto_anomalyA : Tendsto anomalyA (𝓝[>] 0) atTop
def anomalyA (x : ℝ) : ℝ :=
Real.log (2 / 3 + (3 * Real.exp (2 * x) - 2) / (18 * (Real.exp (3 * x) - Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:744
Uses 1
TheoremAnomalous gene tree on four species#✓fully proved
Anomalous gene tree on four species (Degnan & Rosenberg 2006): on the caterpillar
species tree with deeper branch x > 0 and shallower branch y, the symmetric gene tree
((A, B), (C, D)) is more probable than the gene tree matching the species tree if and only
if y < a(x). With caterpillar_le_matching this gives caterpillar_exists_anomalous_iff.
theorem caterpillar_anomalous_iff {x : ℝ} (hx : 0 < x) (y : ℝ) :
geneTreeProb (caterpillar x y) (· = (caterpillar x y).clusters) <
geneTreeProb (caterpillar x y) (· = balancedTree 0 1 2 3) ↔ y < anomalyA x
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
def anomalyA (x : ℝ) : ℝ :=
Real.log (2 / 3 + (3 * Real.exp (2 * x) - 2) / (18 * (Real.exp (3 * x) - Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:744
Uses 12 · Used by 1
a(x) of the anomaly zone · Degnan–Rosenberg formula h for the gene tree ((A, B), (C, D)) · Probability of the gene tree ((A, B), (C, D)) on the caterpillar · The matching gene treeTheoremAnomaly of ((A, C), (B, D)) and ((A, D), (B, C)) on the caterpillar#✓fully proved
On the caterpillar species tree with x ≥ 0, the gene trees ((A, C), (B, D)) and
((A, D), (B, C)) are more probable than the matching gene tree if and only if y < b(x).
theorem caterpillar_anomalous_AC_BD_iff {x : ℝ} (hx : 0 ≤ x) (y : ℝ) :
geneTreeProb (caterpillar x y) (· = (caterpillar x y).clusters) <
geneTreeProb (caterpillar x y) (· = balancedTree 0 2 1 3) ↔ y < anomalyB x
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
def anomalyB (x : ℝ) : ℝ :=
Real.log (2 / 3 + (5 * Real.exp (2 * x) - 2) / (6 * (3 * Real.exp (3 * x) -
2 * Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:749
Uses 12
DefinitionBalanced gene tree on four genes#✓fully proved
G is one of the three balanced (symmetric) gene trees on four genes.
def IsBalancedGeneTree (G : Finset (Finset (Fin 4))) : Prop :=
G = balancedTree 0 1 2 3 ∨ G = balancedTree 0 2 1 3 ∨ G = balancedTree 0 3 1 2
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
Uses 1 · Used by 2
TheoremOnly balanced gene trees can be anomalous on the caterpillar#✓fully proved
On the caterpillar species tree with nonnegative branch lengths, no asymmetric gene tree is more probable than the matching one (Degnan & Rosenberg 2006): only the three balanced gene trees can be anomalous.
theorem caterpillar_le_matching {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) (G : Finset (Finset (Fin 4)))
(hG : ¬ IsBalancedGeneTree G) :
geneTreeProb (caterpillar x y) (· = G) ≤
geneTreeProb (caterpillar x y) (· = caterpillarTree 0 1 2 3)
def IsBalancedGeneTree (G : Finset (Finset (Fin 4))) : Prop :=
G = balancedTree 0 1 2 3 ∨ G = balancedTree 0 2 1 3 ∨ G = balancedTree 0 3 1 2
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:902
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def caterpillarTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {a, b, c}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:641
Uses 13 · Used by 1
Theorem\(g(x, y) \le h(x, y)\) for a nonnegative shallower branch#✓fully proved
g(x, y) ≤ h(x, y) for a nonnegative shallower branch (equality at y = 0).
theorem drG_le_drH (x : ℝ) {y : ℝ} (hy : 0 ≤ y) : drG x y ≤ drH x y
def drG (x y : ℝ) : ℝ := 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:661
def drH (x y : ℝ) : ℝ :=
1 / 3 * Real.exp (-x) - 1 / 6 * Real.exp (-(x + y)) - 1 / 18 * Real.exp (-(3 * x + y))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:665
Uses 2 · Used by 1
TheoremThe four-species anomaly zone#✓fully proved
The four-species anomaly zone (Degnan & Rosenberg 2006, Definition 1 and Figure 2): the
caterpillar species tree with deeper branch x > 0 and shallower branch y ≥ 0 has an
anomalous gene tree, one strictly more probable than the gene tree matching the species
tree, if and only if y < a(x).
theorem caterpillar_exists_anomalous_iff {x y : ℝ} (hx : 0 < x) (hy : 0 ≤ y) :
(∃ G, geneTreeProb (caterpillar x y) (· = (caterpillar x y).clusters) <
geneTreeProb (caterpillar x y) (· = G)) ↔ y < anomalyA x
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def anomalyA (x : ℝ) : ℝ :=
Real.log (2 / 3 + (3 * Real.exp (2 * x) - 2) / (18 * (Real.exp (3 * x) - Real.exp (2 * x))))
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:744
Uses 16
TheoremNo anomalous gene trees on the balanced four-species tree#✓fully proved
No anomalous gene trees on the balanced four-species tree (Degnan & Rosenberg 2006):
for nonnegative branch lengths, no gene tree is more probable than the one matching the
species tree ((0, 1), (2, 3)). Given the numbers of lineages entering the root population,
the matching tree is already the most probable outcome of random joining.
theorem balanced_no_anomaly {y₁ y₂ : ℝ} (hy₁ : 0 ≤ y₁) (hy₂ : 0 ≤ y₂)
(G : Finset (Finset (Fin 4))) :
geneTreeProb (balanced y₁ y₂) (· = G) ≤
geneTreeProb (balanced y₁ y₂) (· = balancedTree 0 1 2 3)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def balanced (y₁ y₂ : ℝ) : SpeciesTree 4 :=
.node (.node (.leaf 0) (.leaf 1) y₁) (.node (.leaf 2) (.leaf 3) y₂) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:637
def balancedTree (a b c d : Fin 4) : Finset (Finset (Fin 4)) :=
{{a}, {b}, {c}, {d}, {a, b}, {c, d}, univ}
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:645
Uses 13
Unrooted quartets
DefinitionGene tree displaying a quartet split#✓fully proved
A rooted gene tree on four genes G (a set of clusters) displays the quartet split
ab | cd, where {c, d} is the complement of {a, b}: forgetting the root, the internal edge
separates {a, b} from {c, d}; equivalently {a, b} or {c, d} is a cluster.
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
Used by 7
TheoremNo anomalous unrooted quartets, caterpillar species tree#✓fully proved
No anomalous unrooted quartets, caterpillar species tree (Allman, Degnan & Rhodes 2011):
the unrooted gene quartet matches the species quartet 01 | 23 with probability
1 - (2/3) e^{-y}, where y is the length of the internal edge of the unrooted species
quartet (the shallower internal branch).
theorem geneTreeProb_caterpillar_split_01 (x y : ℝ) :
geneTreeProb (caterpillar x y) (DisplaysSplit 0 1) = 1 - 2 / 3 * Real.exp (-y)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
Uses 18 · Used by 1
TheoremProbability of quartet split 02|13 on the caterpillar tree#✓fully proved
On the caterpillar species tree the discordant unrooted gene quartet 02 | 13 has
probability (1/3) e^{-y}.
theorem geneTreeProb_caterpillar_split_02 (x y : ℝ) :
geneTreeProb (caterpillar x y) (DisplaysSplit 0 2) = 1 / 3 * Real.exp (-y)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
Uses 18 · Used by 1
TheoremProbability of quartet split 03|12 on the caterpillar tree#✓fully proved
On the caterpillar species tree the discordant unrooted gene quartet 03 | 12 has
probability (1/3) e^{-y}.
theorem geneTreeProb_caterpillar_split_03 (x y : ℝ) :
geneTreeProb (caterpillar x y) (DisplaysSplit 0 3) = 1 / 3 * Real.exp (-y)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
Uses 18 · Used by 1
TheoremNo anomalous unrooted quartets, balanced species tree#✓fully proved
No anomalous unrooted quartets, balanced species tree (Allman, Degnan & Rhodes 2011):
on ((0, 1), (2, 3)) the unrooted gene quartet matches 01 | 23 with probability
1 - (2/3) e^{-(y₁ + y₂)}, where y₁ + y₂ is the internal edge of the unrooted species
quartet.
theorem geneTreeProb_balanced_split_01 (y₁ y₂ : ℝ) :
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 1) = 1 - 2 / 3 * Real.exp (-(y₁ + y₂))
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def balanced (y₁ y₂ : ℝ) : SpeciesTree 4 :=
.node (.node (.leaf 0) (.leaf 1) y₁) (.node (.leaf 2) (.leaf 3) y₂) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:637
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
Uses 14 · Used by 1
TheoremProbability of quartet split 02|13 on the balanced tree#✓fully proved
On the balanced species tree the discordant unrooted gene quartet 02 | 13 has
probability (1/3) e^{-(y₁ + y₂)}.
theorem geneTreeProb_balanced_split_02 (y₁ y₂ : ℝ) :
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 2) = 1 / 3 * Real.exp (-(y₁ + y₂))
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def balanced (y₁ y₂ : ℝ) : SpeciesTree 4 :=
.node (.node (.leaf 0) (.leaf 1) y₁) (.node (.leaf 2) (.leaf 3) y₂) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:637
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
Uses 13 · Used by 1
TheoremProbability of quartet split 03|12 on the balanced tree#✓fully proved
On the balanced species tree the discordant unrooted gene quartet 03 | 12 has
probability (1/3) e^{-(y₁ + y₂)}.
theorem geneTreeProb_balanced_split_03 (y₁ y₂ : ℝ) :
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 3) = 1 / 3 * Real.exp (-(y₁ + y₂))
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def balanced (y₁ y₂ : ℝ) : SpeciesTree 4 :=
.node (.node (.leaf 0) (.leaf 1) y₁) (.node (.leaf 2) (.leaf 3) y₂) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:637
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
Uses 13 · Used by 1
TheoremThe species quartet maximizes quartet support#✓fully proved
The species quartet maximizes quartet support (Allman, Degnan & Rhodes 2011; Mirarab et al. 2014): for a positive internal edge, the unrooted gene quartet matching the species quartet is strictly the most probable of the three, on both four-species shapes. Since the expected quartet support of a candidate four-species tree (one quartet) is the probability of its quartet, the species tree maximizes it.
theorem split_01_most_probable {x y y₁ y₂ : ℝ} (hy : 0 < y) (hy₁₂ : 0 < y₁ + y₂) :
geneTreeProb (caterpillar x y) (DisplaysSplit 0 2) <
geneTreeProb (caterpillar x y) (DisplaysSplit 0 1) ∧
geneTreeProb (caterpillar x y) (DisplaysSplit 0 3) <
geneTreeProb (caterpillar x y) (DisplaysSplit 0 1) ∧
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 2) <
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 1) ∧
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 3) <
geneTreeProb (balanced y₁ y₂) (DisplaysSplit 0 1)
def geneTreeProb (T : SpeciesTree n) (E : Finset (Finset (Fin n)) → Prop) [DecidablePred E] :
ℝ :=
match T with
| leaf i => if E {{i}} then 1 else 0
| node l r _ => exitLaw l fun ml bl al => exitLaw r fun mr br ar =>
∫ h, (if E (al ∪ ar ∪ cladesAlong (bl ++ br) h (ml + mr - 1)) then 1 else 0)
∂randomJoining (ml + mr)
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:323
def caterpillar (x y : ℝ) : SpeciesTree 4 :=
.node (.node (.node (.leaf 0) (.leaf 1) y) (.leaf 2) x) (.leaf 3) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:632
def DisplaysSplit (a b : Fin 4) (G : Finset (Finset (Fin 4))) : Prop :=
{a, b} ∈ G ∨ univ \ {a, b} ∈ G
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:984
def balanced (y₁ y₂ : ℝ) : SpeciesTree 4 :=
.node (.node (.leaf 0) (.leaf 1) y₁) (.node (.leaf 2) (.leaf 3) y₂) 0
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:637
Uses 10
Clade probabilities under random joining
DefinitionClade of a ranked history#✓fully proved
The set S of sampled genes is a clade of the ranked history h: it is a block of one
of the ancestral partitions of h, i.e. the set of descendants of some lineage.
def IsClade {m : ℕ} (h : RankedHistory m) (S : Finset (Fin m)) : Prop :=
∃ P ∈ partitionsOf h, S ∈ P
abbrev RankedHistory (n : ℕ) : Type := (i : Fin (n - 1)) → LineagePair (n - i)
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:70
def partitionsOf {n : ℕ} (h : RankedHistory n) : List (Finset (Finset (Fin n))) :=
(blocksOf h).map List.toFinset
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:99
Uses 2 · Used by 2
TheoremClade probability#✓fully proved
Clade probability (Rosenberg 2003): under random joining, a fixed set of k among m
genes, 1 ≤ k < m, is a clade with probability 2m / (k (k + 1) C(m, k)).
theorem randomJoining_isClade {m : ℕ} (S : Finset (Fin m)) (hS : 1 ≤ S.card)
(hSm : S.card < m) :
(randomJoining m).real {h | IsClade h S} =
2 * m / (S.card * (S.card + 1) * (m.choose S.card : ℝ))
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
def IsClade {m : ℕ} (h : RankedHistory m) (S : Finset (Fin m)) : Prop :=
∃ P ∈ partitionsOf h, S ∈ P
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:1116
Uses 10 · Used by 1
TheoremClade probability under random joining for at most five genes#✓fully proved
The case m ≤ 5 of randomJoining_isClade.
@[deprecated "Use `randomJoining_isClade`." (since := "2026-11-02")]
theorem randomJoining_isClade_of_le_five {m : ℕ} (_hm : m ≤ 5) (S : Finset (Fin m))
(hS : 1 ≤ S.card) (hSm : S.card < m) :
(randomJoining m).real {h | IsClade h S} =
2 * m / (S.card * (S.card + 1) * (m.choose S.card : ℝ))
noncomputable def randomJoining (n : ℕ) : Measure (RankedHistory n) :=
Measure.pi fun i => ProbabilityTheory.uniformOn (Set.univ : Set (LineagePair (n - i)))
MathlibExt/Biology/PopulationGenetics/Coalescent/Topology.lean:159
def IsClade {m : ℕ} (h : RankedHistory m) (S : Finset (Fin m)) : Prop :=
∃ P ∈ partitionsOf h, S ∈ P
MathlibExt/Biology/PopulationGenetics/MultispeciesCoalescent.lean:1116
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.