Evolutionary conservation scores
- Upper tail of the binomial distribution
- Binomial upper tail at zero equals one
- Binomial upper tail vanishes beyond \(n\)
- The tail is nonincreasing in
k - Derivative of the binomial upper tail
- The binomial upper tail is nondecreasing in
pon(0, 1) - The binomial upper tail is strictly increasing in
pon(0, 1)
DefinitionBinomial z-score approximation to the motif conservation score#✓fully proved
The conserved count
k of a motif with N occurrences, standardized under Bin(N, p):
(k - N p) / √(N p (1 - p)). This is an approximation to Xie et al.'s MCS, not their
exact score.
noncomputable def mcsApprox (N : ℕ) (k p : ℝ) : ℝ := (k - N * p) / Real.sqrt (N * p * (1 - p))
TheoremMotif conservation score approximation is strictly increasing#✓fully proved
The MCS approximation is strictly increasing in the conserved count, for N ≥ 1 and p ∈ (0, 1).
theorem mcsApprox_strictMono {N : ℕ} (hN : 0 < N) {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) :
StrictMono fun k => mcsApprox N k p
noncomputable def mcsApprox (N : ℕ) (k p : ℝ) : ℝ := (k - N * p) / Real.sqrt (N * p * (1 - p))
MathlibExt/Biology/Phylogenetics/MotifConservation.lean:64
Uses 1
TheoremMotif conservation score approximation as a de Moivre–Laplace sum#✓fully proved
The MCS approximation of the number of conserved occurrences among the first n is the
de Moivre–Laplace standardized sum.
theorem mcsApprox_sum_eq {Ω : Type*} (X : ℕ → Ω → ℝ) (p : ℝ) (n : ℕ) (ω : Ω) :
mcsApprox n (∑ i ∈ range n, X i ω) p = deMoivreLaplaceStandardized X p n ω
noncomputable def mcsApprox (N : ℕ) (k p : ℝ) : ℝ := (k - N * p) / Real.sqrt (N * p * (1 - p))
MathlibExt/Biology/Phylogenetics/MotifConservation.lean:64
noncomputable def deMoivreLaplaceStandardized {Ω : Type*} (X : ℕ → Ω → ℝ)
(p : ℝ) (n : ℕ) (ω : Ω) : ℝ :=
((∑ k ∈ Finset.range n, X k ω) - ↑n * p) / Real.sqrt (↑n * p * (1 - p))
MathlibExt/Probability/DeMoivreLaplace.lean:73
Uses 2
TheoremDe Moivre–Laplace for the MCS approximation#✓fully proved
If the conservation indicators of
the occurrences are i.i.d. Bernoulli(p) with 0 < p < 1, then for every z,
P(z ≤ MCS approximation of the first n occurrences) tends to the standard normal mass of
[z, ∞).
theorem tendsto_prob_le_mcsApprox {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω}
[IsProbabilityMeasure P] (X : ℕ → Ω → ℝ) {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1)
(h01 : ∀ i, ∀ᵐ ω ∂P, X i ω = 0 ∨ X i ω = 1) (hmean : ∀ i, ∫ ω, X i ω ∂P = p)
(hindep : iIndepFun X P) (hident : ∀ i, IdentDistrib (X i) (X 0) P P) (z : ℝ) :
Tendsto (fun n : ℕ => P.real {ω | z ≤ mcsApprox n (∑ i ∈ range n, X i ω) p}) atTop
(𝓝 ((gaussianReal 0 1).real (Set.Ici z)))
noncomputable def mcsApprox (N : ℕ) (k p : ℝ) : ℝ := (k - N * p) / Real.sqrt (N * p * (1 - p))
MathlibExt/Biology/Phylogenetics/MotifConservation.lean:64
DefinitionThe SiPhy rate matrix#✓fully proved
The SiPhy rate matrix Q a b = ω R a b π b for a ≠ b (Garber et al. 2009, Eq. 10),
with rows summing to zero: ω times the GTR matrix with exchangeabilities R and base
frequencies π.
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
noncomputable def gtrRate (π : ι → ℝ) (s : Matrix ι ι ℝ) : Matrix ι ι ℝ :=
Matrix.of fun i j => if i = j then -∑ k ∈ univ.erase i, s i k * π k else s i j * π j
MathlibExt/Biology/Phylogenetics/SubstitutionModels.lean:89
Uses 1 · Used by 6
TheoremSiPhy matrix is a rate matrix#✓fully proved
With ω ≥ 0, nonnegative R and nonnegative π, the SiPhy matrix is a rate matrix.
theorem isRateMatrix_siphyRate {ω : ℝ} {R : Matrix ι ι ℝ} {π : ι → ℝ} (hω : 0 ≤ ω)
(hR : ∀ a b, 0 ≤ R a b) (hπ : ∀ b, 0 ≤ π b) : IsRateMatrix (siphyRate ω R π)
structure IsRateMatrix (Q : Matrix ι ι ℝ) : Prop where
/-- The jump rates `Q i j`, `i ≠ j`, are nonnegative. -/
nonneg_of_ne : ∀ ⦃i j : ι⦄, i ≠ j → 0 ≤ Q i j
/-- Each row sums to `0`. -/
sum_row : ∀ i, ∑ j, Q i j = 0
MathlibExt/Probability/Process/ContinuousTimeMarkovChain/RateMatrix.lean:57
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
MathlibExt/Biology/Phylogenetics/SiPhy.lean:68
Uses 4
Theoremπ is the equilibrium of the SiPhy matrix#✓fully proved
For symmetric R it is in detailed balance
with π, for every ω.
theorem isDetailedBalance_siphyRate (ω : ℝ) {R : Matrix ι ι ℝ} (hR : ∀ a b, R a b = R b a)
(π : ι → ℝ) : IsDetailedBalance π (siphyRate ω R π)
def IsDetailedBalance (π : ι → ℝ) (Q : Matrix ι ι ℝ) : Prop :=
∀ i j, π i * Q i j = π j * Q j i
MathlibExt/Probability/Process/ContinuousTimeMarkovChain/Stationary.lean:64
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
MathlibExt/Biology/Phylogenetics/SiPhy.lean:68
Uses 4
DefinitionThe expected complete-data log-likelihood#✓fully proved
The expected complete-data log-likelihood of a rate matrix Q and root distribution π
(Garber et al. 2009, Eq. 6): ∑_{a ≠ b} n a b log Q a b + ∑ a, τ a Q a a + ∑ b, r b log π b,
for expected substitution counts n, expected state durations τ and the root posterior r.
DefinitionExpected total number of substitutions#✓fully proved
The expected total number of substitutions N = ∑_{a ≠ b} n a b.
def totalCount (n : Matrix ι ι ℝ) : ℝ := ∑ a, ∑ b, if a = b then 0 else n a b
DefinitionWeight of a state: substitutions into it plus root posterior#✓fully proved
The weight c b = ∑_{a ≠ b} n a b + r b of state b: substitutions into b plus the root
posterior of b.
def inCount (n : Matrix ι ι ℝ) (r : ι → ℝ) (b : ι) : ℝ :=
∑ a, (if a = b then 0 else n a b) + r b
DefinitionTime-weighted exchange rate into a state#✓fully proved
The time-weighted exchange rate into b, e b = ∑_{a ≠ b} τ a R a b.
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
DefinitionPart of the SiPhy objective depending on the constraint vector#✓fully proved
The part of Eq. 6 that depends on π (for fixed ω):
∑ b, (c b * log (π b) - d b * π b).
noncomputable def piObjective (c d π : ι → ℝ) : ℝ := ∑ b, (c b * log (π b) - d b * π b)
DefinitionConstant \(n \log R\) term of the SiPhy objective#✓fully proved
The n log R constant of Eq. 6.
TheoremEq. 6 for the SiPhy matrix#✓fully proved
For ω > 0, positive off-diagonal R and positive π,
expectedLogLik = N log ω + ∑_{a ≠ b} n a b log R a b + piObjective c (ω e) π.
theorem expectedLogLik_siphyRate (n : Matrix ι ι ℝ) (τ r : ι → ℝ) {ω : ℝ}
{R : Matrix ι ι ℝ} {π : ι → ℝ} (hω : 0 < ω) (hR : ∀ a b, a ≠ b → 0 < R a b)
(hπ : ∀ b, 0 < π b) :
expectedLogLik n τ r (siphyRate ω R π) π =
totalCount n * log ω + exchangeTerm n R +
piObjective (inCount n r) (fun b => ω * exitWeight τ R b) π
noncomputable def expectedLogLik (n : Matrix ι ι ℝ) (τ r : ι → ℝ) (Q : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
∑ a, ∑ b, (if a = b then 0 else n a b * log (Q a b)) + ∑ a, τ a * Q a a +
∑ b, r b * log (π b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:91
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
MathlibExt/Biology/Phylogenetics/SiPhy.lean:68
def totalCount (n : Matrix ι ι ℝ) : ℝ := ∑ a, ∑ b, if a = b then 0 else n a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:97
noncomputable def exchangeTerm (n R : Matrix ι ι ℝ) : ℝ :=
∑ a, ∑ b, if a = b then 0 else n a b * log (R a b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:113
noncomputable def piObjective (c d π : ι → ℝ) : ℝ := ∑ b, (c b * log (π b) - d b * π b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:110
def inCount (n : Matrix ι ι ℝ) (r : ι → ℝ) (b : ι) : ℝ :=
∑ a, (if a = b then 0 else n a b) + r b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:101
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:105
Uses 8 · Used by 3
DefinitionThe SiPhy rate update#✓fully proved
The SiPhy rate update (Eq. 7, for fixed π): ω = N / ∑ b, e b π b.
noncomputable def omegaUpdate (n : Matrix ι ι ℝ) (τ : ι → ℝ) (R : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
totalCount n / ∑ b, exitWeight τ R b * π b
def totalCount (n : Matrix ι ι ℝ) : ℝ := ∑ a, ∑ b, if a = b then 0 else n a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:97
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:105
Uses 2 · Used by 2
TheoremThe rate update maximizes Eq. 6 over ω > 0#✓fully proved
The rate update maximizes Eq. 6 over ω > 0 for a fixed positive π, when the expected
number of substitutions N and the time-weighted rate ∑ b, e b π b are positive.
theorem expectedLogLik_le_omegaUpdate (n : Matrix ι ι ℝ) (τ r : ι → ℝ) {R : Matrix ι ι ℝ}
{π : ι → ℝ} (hR : ∀ a b, a ≠ b → 0 < R a b) (hπ : ∀ b, 0 < π b) (hN : 0 < totalCount n)
(hD : 0 < ∑ b, exitWeight τ R b * π b) {ω : ℝ} (hω : 0 < ω) :
expectedLogLik n τ r (siphyRate ω R π) π ≤
expectedLogLik n τ r (siphyRate (omegaUpdate n τ R π) R π) π
def totalCount (n : Matrix ι ι ℝ) : ℝ := ∑ a, ∑ b, if a = b then 0 else n a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:97
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:105
noncomputable def expectedLogLik (n : Matrix ι ι ℝ) (τ r : ι → ℝ) (Q : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
∑ a, ∑ b, (if a = b then 0 else n a b * log (Q a b)) + ∑ a, τ a * Q a a +
∑ b, r b * log (π b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:91
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
MathlibExt/Biology/Phylogenetics/SiPhy.lean:68
noncomputable def omegaUpdate (n : Matrix ι ι ℝ) (τ : ι → ℝ) (R : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
totalCount n / ∑ b, exitWeight τ R b * π b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:171
TheoremThe rate update is the unique maximizer#✓fully proved
Any other ω > 0 gives a strictly smaller
value of Eq. 6.
theorem expectedLogLik_lt_omegaUpdate (n : Matrix ι ι ℝ) (τ r : ι → ℝ) {R : Matrix ι ι ℝ}
{π : ι → ℝ} (hR : ∀ a b, a ≠ b → 0 < R a b) (hπ : ∀ b, 0 < π b) (hN : 0 < totalCount n)
(hD : 0 < ∑ b, exitWeight τ R b * π b) {ω : ℝ} (hω : 0 < ω)
(hne : ω ≠ omegaUpdate n τ R π) :
expectedLogLik n τ r (siphyRate ω R π) π <
expectedLogLik n τ r (siphyRate (omegaUpdate n τ R π) R π) π
def totalCount (n : Matrix ι ι ℝ) : ℝ := ∑ a, ∑ b, if a = b then 0 else n a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:97
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:105
noncomputable def omegaUpdate (n : Matrix ι ι ℝ) (τ : ι → ℝ) (R : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
totalCount n / ∑ b, exitWeight τ R b * π b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:171
noncomputable def expectedLogLik (n : Matrix ι ι ℝ) (τ r : ι → ℝ) (Q : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
∑ a, ∑ b, (if a = b then 0 else n a b * log (Q a b)) + ∑ a, τ a * Q a a +
∑ b, r b * log (π b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:91
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
MathlibExt/Biology/Phylogenetics/SiPhy.lean:68
TheoremThe Lagrange multiplier of the π update exists and is unique#✓fully proved
For positive c and
nonnegative d on a nonempty finite alphabet there is exactly one γ with d b + γ > 0 for
all b and ∑ b, c b / (d b + γ) = 1.
theorem existsUnique_lagrange [Nonempty ι] {c d : ι → ℝ} (hc : ∀ b, 0 < c b)
(hd : ∀ b, 0 ≤ d b) :
∃! γ : ℝ, (∀ b, 0 < d b + γ) ∧ ∑ b, c b / (d b + γ) = 1
TheoremThe π update is the unique maximizer#✓fully proved
The π update is the unique maximizer of piObjective c d over the positive
probability vectors: with γ as in existsUnique_lagrange, every other positive π summing to
one has a strictly smaller objective than b ↦ c b / (d b + γ).
theorem piObjective_lt {c d : ι → ℝ} {γ : ℝ} (hc : ∀ b, 0 < c b) (hγ : ∀ b, 0 < d b + γ)
(hsum : ∑ b, c b / (d b + γ) = 1) {π : ι → ℝ} (hπ : ∀ b, 0 < π b) (hπs : ∑ b, π b = 1)
(hne : π ≠ fun b => c b / (d b + γ)) :
piObjective c d π < piObjective c d (fun b => c b / (d b + γ))
noncomputable def piObjective (c d π : ι → ℝ) : ℝ := ∑ b, (c b * log (π b) - d b * π b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:110
Uses 1 · Used by 1
DefinitionThe SiPhy constraint-vector update#✓fully proved
The SiPhy constraint-vector update (Eq. 8, for fixed ω):
π b = c b / (ω e b + γ), with γ the Lagrange multiplier of existsUnique_lagrange.
noncomputable def piUpdate [Nonempty ι] (n : Matrix ι ι ℝ) (τ r : ι → ℝ) (ω : ℝ)
(R : Matrix ι ι ℝ) (hc : ∀ b, 0 < inCount n r b) (hd : ∀ b, 0 ≤ ω * exitWeight τ R b)
(b : ι) : ℝ :=
inCount n r b / (ω * exitWeight τ R b + (existsUnique_lagrange hc hd).exists.choose)
def inCount (n : Matrix ι ι ℝ) (r : ι → ℝ) (b : ι) : ℝ :=
∑ a, (if a = b then 0 else n a b) + r b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:101
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:105
theorem existsUnique_lagrange [Nonempty ι] {c d : ι → ℝ} (hc : ∀ b, 0 < c b)
(hd : ∀ b, 0 ≤ d b) :
∃! γ : ℝ, (∀ b, 0 < d b + γ) ∧ ∑ b, c b / (d b + γ) = 1
MathlibExt/Biology/Phylogenetics/SiPhy.lean:235
TheoremThe constraint-vector update is the unique maximizer of Eq. 6#✓fully proved
The constraint-vector update is the unique maximizer of Eq. 6 over the positive
probability vectors π (the rate matrix ω R π and the root distribution both use π), for
fixed ω > 0, positive off-diagonal R and positive weights c.
theorem expectedLogLik_lt_piUpdate [Nonempty ι] (n : Matrix ι ι ℝ) (τ r : ι → ℝ) {ω : ℝ}
{R : Matrix ι ι ℝ} (hω : 0 < ω) (hR : ∀ a b, a ≠ b → 0 < R a b)
(hc : ∀ b, 0 < inCount n r b) (hd : ∀ b, 0 ≤ ω * exitWeight τ R b) {π : ι → ℝ}
(hπ : ∀ b, 0 < π b) (hπs : ∑ b, π b = 1) (hne : π ≠ piUpdate n τ r ω R hc hd) :
expectedLogLik n τ r (siphyRate ω R π) π <
expectedLogLik n τ r (siphyRate ω R (piUpdate n τ r ω R hc hd))
(piUpdate n τ r ω R hc hd)
def inCount (n : Matrix ι ι ℝ) (r : ι → ℝ) (b : ι) : ℝ :=
∑ a, (if a = b then 0 else n a b) + r b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:101
def exitWeight (τ : ι → ℝ) (R : Matrix ι ι ℝ) (b : ι) : ℝ :=
∑ a, if a = b then 0 else τ a * R a b
MathlibExt/Biology/Phylogenetics/SiPhy.lean:105
noncomputable def piUpdate [Nonempty ι] (n : Matrix ι ι ℝ) (τ r : ι → ℝ) (ω : ℝ)
(R : Matrix ι ι ℝ) (hc : ∀ b, 0 < inCount n r b) (hd : ∀ b, 0 ≤ ω * exitWeight τ R b)
(b : ι) : ℝ :=
inCount n r b / (ω * exitWeight τ R b + (existsUnique_lagrange hc hd).exists.choose)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:340
noncomputable def expectedLogLik (n : Matrix ι ι ℝ) (τ r : ι → ℝ) (Q : Matrix ι ι ℝ)
(π : ι → ℝ) : ℝ :=
∑ a, ∑ b, (if a = b then 0 else n a b * log (Q a b)) + ∑ a, τ a * Q a a +
∑ b, r b * log (π b)
MathlibExt/Biology/Phylogenetics/SiPhy.lean:91
noncomputable def siphyRate (ω : ℝ) (R : Matrix ι ι ℝ) (π : ι → ℝ) : Matrix ι ι ℝ :=
ω • gtrRate π R
MathlibExt/Biology/Phylogenetics/SiPhy.lean:68
DefinitionLeaf set meeting both sides of a tree edge#✓fully proved
Whether the leaf set S meets both sides of an edge with leaf set B below it, inside a
tree with leaf set U: S ∩ B and S ∩ (U \ B) are nonempty.
def Separates (U S B : Finset L) : Prop := (S ∩ B).Nonempty ∧ (S ∩ (U \ B)).Nonempty
Used by 8
0 · SubadditivityDefinitionNonnegative edge lengths of a tree#✓fully proved
Edge lengths are nonnegative: every dart's undirected edge has nonnegative length.
def NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
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 6
DefinitionTotal branch length of a tree#✓fully proved
The total branch length: half the sum of the edge lengths over the darts, since each undirected edge is traversed once in each direction.
noncomputable def totalLength (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge
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 5
DefinitionThe Branch Length Score#✓fully proved
The Branch Length Score (unnormalized): the total branch length of the smallest
subtree of T connecting the leaves S, as half the sum over the darts of the edge length
times the indicator that S meets both sides (edgeSide) of the dart's edge.
noncomputable def bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 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
def Separates (U S B : Finset L) : Prop := (S ∩ B).Nonempty ∧ (S ∩ (U \ B)).Nonempty
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:71
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 3 · Used by 10
0 · SubadditivityDefinitionNormalized branch length score#✓fully proved
The normalized Branch Length Score, bls S T w / totalLength T w, as reported by
Kheradpour et al. (a fraction of the total branch length).
noncomputable def blsFrac (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
bls S T w / totalLength T w
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 bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
noncomputable def totalLength (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:136
TheoremBranch length score is nonnegative for nonnegative edge lengths#✓fully proved
The BLS is nonnegative for nonnegative edge lengths.
theorem bls_nonneg (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ)
(hw : NonnegWeights T w) : 0 ≤ bls S T w
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 NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:131
noncomputable def bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
Uses 5 · Used by 1
TheoremBranch length score is at most the tree length for nonnegative lengths#✓fully proved
The BLS is at most the total branch length.
theorem bls_le_totalLength (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ)
(hw : NonnegWeights T w) : bls S T w ≤ totalLength T w
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 NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:131
noncomputable def bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
noncomputable def totalLength (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:136
Uses 6 · Used by 1
TheoremMonotonicity#✓fully proved
With nonnegative edge lengths, more conserving species never lower the BLS.
theorem bls_mono {S S' : Finset X} (h : S ⊆ S') (T : UnrootedBinaryTree X)
(w : Sym2 T.V → ℝ) (hw : NonnegWeights T w) : bls S T w ≤ bls S' T w
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 NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:131
noncomputable def bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
TheoremBranch length score of the empty set is zero#✓fully proved
The BLS of the empty set is 0.
theorem bls_empty (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : bls ∅ T w = 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 bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
Uses 4
TheoremA single species has BLS 0#✓fully proved
A single species has BLS 0 (a motif present in one genome is not conserved).
theorem bls_singleton (x : X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) :
bls {x} T w = 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 bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
Uses 4
TheoremAll species give the whole tree#✓fully proved
The BLS of the set of all leaves is the total branch length.
theorem bls_leaves (a : X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) :
bls Finset.univ T w = totalLength T w
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 bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
noncomputable def totalLength (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:136
Uses 12
TheoremSubadditivity#✓fully proved
For sets of species S, S' that share a species, the subtree
connecting S ∪ S' is at most as long as the two subtrees together.
theorem bls_union_le {S S' : Finset X} (hSS : (S ∩ S').Nonempty) (T : UnrootedBinaryTree X)
(w : Sym2 T.V → ℝ) (hw : NonnegWeights T w) :
bls (S ∪ S') T w ≤ bls S T w + bls S' T w
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 NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:131
noncomputable def bls (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge *
if Separates Finset.univ S (edgeSide T t.fst t.snd) then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:142
TheoremNormalized branch length score is nonnegative for nonnegative lengths#✓fully proved
The normalized BLS is nonnegative.
theorem blsFrac_nonneg (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ)
(hw : NonnegWeights T w) : 0 ≤ blsFrac S T w
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 NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:131
noncomputable def blsFrac (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
bls S T w / totalLength T w
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:148
TheoremNormalized branch length score is at most one for nonnegative lengths#✓fully proved
The normalized BLS is at most 1 when the tree has positive total length.
theorem blsFrac_le_one (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ)
(hw : NonnegWeights T w) (hpos : 0 < totalLength T w) : blsFrac S T w ≤ 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
def NonnegWeights (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : Prop :=
∀ t : T.G.Dart, 0 ≤ w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:131
noncomputable def totalLength (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
(1 / 2) * ∑ t : T.G.Dart, w t.edge
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:136
noncomputable def blsFrac (S : Finset X) (T : UnrootedBinaryTree X) (w : Sym2 T.V → ℝ) : ℝ :=
bls S T w / totalLength T w
CSLibExt/Bioinformatics/Phylogenetics/BranchLengthScore.lean:148
TheoremThe side of a pendant edge is the singleton of its leaf#✓fully proved
The taxa whose leaf is closer to the leaf vertex than to its neighbor are exactly that leaf's taxon.
theorem edgeSide_of_leaf (T : UnrootedBinaryTree X) {x : X} {p : T.V}
(hp : T.G.Adj p (T.label x)) : edgeSide T p (T.label x) = {x}
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
TheoremSum over darts is twice the sum over edges#✓fully proved
A sum over darts of a function of the undirected edge is twice the sum over the edges: the two darts of each edge contribute equally.
theorem dart_sum_edge (T : UnrootedBinaryTree X) (f : Sym2 T.V → ℝ) :
∑ t : T.G.Dart, f t.edge = ∑ e ∈ T.G.edgeFinset, 2 * f e
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
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.