Maximum-likelihood ancestral reconstruction
DefinitionNonnegative transition weights on a tree#✓fully proved
All transition weights in the tree are nonnegative.
def NonnegWeights [Zero R] [LE R] : Tree L S R → Prop
| leaf _ => True
| node P l Q r => (∀ a b, 0 ≤ P a b) ∧ (∀ a b, 0 ≤ Q a b) ∧ NonnegWeights l ∧ NonnegWeights r
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
Uses 1 · Used by 5
DefinitionState maximizing a function#✓fully proved
A state maximizing f (ties broken by choice).
noncomputable def argmaxState (f : S → R) : S :=
(Finite.exists_max f).choose
TheoremThe argmax state maximizes the function#✓fully proved
argmaxState f maximizes f.
theorem le_argmaxState (f : S → R) (a : S) : f a ≤ f (argmaxState f)
noncomputable def argmaxState (f : S → R) : S :=
(Finite.exists_max f).choose
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:79
Uses 1 · Used by 1
TheoremValue at the argmax state is the maximum#✓fully proved
The value at argmaxState f is the maximum univ.sup' of f.
theorem sup'_eq_argmaxState [Fintype S] (f : S → R) :
univ.sup' univ_nonempty f = f (argmaxState f)
noncomputable def argmaxState (f : S → R) : S :=
(Finite.exists_max f).choose
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:79
Uses 2 · Used by 2
DefinitionMax-product pruning recursion#✓fully proved
The max-product (Viterbi) form of Felsenstein's pruning recursion: the largest weight of a
labeling of the subtree t given state s at its root.
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
Uses 1 · Used by 8
maxPrune bounds the weight of every labeling · The traced labeling attains maxPruneDefinitionPupko's traceback#✓fully proved
Pupko's traceback: given the state s of the root of t, label each child with a state
maximizing the transition weight times the child's maxPrune, and recurse.
noncomputable def traceback : (t : Tree L S R) → S → Labeling t
| leaf _, _ => PUnit.unit
| node P l Q r, s =>
let a := argmaxState fun a => P s a * maxPrune obs l a
let b := argmaxState fun b => Q s b * maxPrune obs r b
((a, traceback l a), (b, traceback r b))
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def Labeling : Tree L S R → Type v
| leaf _ => PUnit
| node _ l _ r => (S × Labeling l) × (S × Labeling r)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:101
noncomputable def argmaxState (f : S → R) : S :=
(Finite.exists_max f).choose
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:79
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
Uses 4 · Used by 3
TheoremNonnegativity of max-product pruning#✓fully proved
With nonnegative weights, maxPrune is nonnegative.
theorem maxPrune_nonneg (hobs : ∀ l s, 0 ≤ obs l s) :
∀ (t : Tree L S R), NonnegWeights t → ∀ s, 0 ≤ maxPrune obs t s
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def NonnegWeights [Zero R] [LE R] : Tree L S R → Prop
| leaf _ => True
| node P l Q r => (∀ a b, 0 ≤ P a b) ∧ (∀ a b, 0 ≤ Q a b) ∧ NonnegWeights l ∧ NonnegWeights r
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:70
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
Uses 3 · Used by 1
TheoremThe traced labeling attains maxPrune#✓fully proved
No sign condition is needed.
theorem weight_traceback :
∀ (t : Tree L S R) (s : S), weight obs t s (traceback obs t s) = maxPrune obs t s
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def weight : (t : Tree L S R) → S → Labeling t → R
| leaf l, s, _ => obs l s
| node P l Q r, s, z =>
(P s z.1.1 * weight l z.1.1 z.1.2) * (Q s z.2.1 * weight r z.2.1 z.2.2)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:134
noncomputable def traceback : (t : Tree L S R) → S → Labeling t
| leaf _, _ => PUnit.unit
| node P l Q r, s =>
let a := argmaxState fun a => P s a * maxPrune obs l a
let b := argmaxState fun b => Q s b * maxPrune obs r b
((a, traceback l a), (b, traceback r b))
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:107
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
Uses 7 · Used by 2
TheoremNonnegativity of labeling weights#✓fully proved
With nonnegative weights, every labeling has nonnegative weight.
theorem weight_nonneg (hobs : ∀ l s, 0 ≤ obs l s) :
∀ (t : Tree L S R), NonnegWeights t → ∀ (s : S) (z : Labeling t), 0 ≤ weight obs t s z
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def NonnegWeights [Zero R] [LE R] : Tree L S R → Prop
| leaf _ => True
| node P l Q r => (∀ a b, 0 ≤ P a b) ∧ (∀ a b, 0 ≤ Q a b) ∧ NonnegWeights l ∧ NonnegWeights r
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:70
def Labeling : Tree L S R → Type v
| leaf _ => PUnit
| node _ l _ r => (S × Labeling l) × (S × Labeling r)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:101
def weight : (t : Tree L S R) → S → Labeling t → R
| leaf l, s, _ => obs l s
| node P l Q r, s, z =>
(P s z.1.1 * weight l z.1.1 z.1.2) * (Q s z.2.1 * weight r z.2.1 z.2.2)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:134
Uses 4 · Used by 1
TheoremmaxPrune bounds the weight of every labeling#✓fully proved
maxPrune bounds the weight of every labeling (nonnegative weights).
theorem weight_le_maxPrune (hobs : ∀ l s, 0 ≤ obs l s) :
∀ (t : Tree L S R), NonnegWeights t → ∀ (s : S) (z : Labeling t),
weight obs t s z ≤ maxPrune obs t s
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def NonnegWeights [Zero R] [LE R] : Tree L S R → Prop
| leaf _ => True
| node P l Q r => (∀ a b, 0 ≤ P a b) ∧ (∀ a b, 0 ≤ Q a b) ∧ NonnegWeights l ∧ NonnegWeights r
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:70
def Labeling : Tree L S R → Type v
| leaf _ => PUnit
| node _ l _ r => (S × Labeling l) × (S × Labeling r)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:101
def weight : (t : Tree L S R) → S → Labeling t → R
| leaf l, s, _ => obs l s
| node P l Q r, s, z =>
(P s z.1.1 * weight l z.1.1 z.1.2) * (Q s z.2.1 * weight r z.2.1 z.2.2)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:134
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
Uses 7 · Used by 2
TheoremThe max-product recursion computes the maximal labeling weight#✓fully proved
maxPrune obs t s is the
maximum over all labelings z of the non-root nodes of weight obs t s z.
theorem maxPrune_eq_sup' (hobs : ∀ l s, 0 ≤ obs l s) (t : Tree L S R) (ht : NonnegWeights t)
(s : S) :
maxPrune obs t s = univ.sup' ⟨traceback obs t s, mem_univ _⟩ (weight obs t s)
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def NonnegWeights [Zero R] [LE R] : Tree L S R → Prop
| leaf _ => True
| node P l Q r => (∀ a b, 0 ≤ P a b) ∧ (∀ a b, 0 ≤ Q a b) ∧ NonnegWeights l ∧ NonnegWeights r
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:70
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
noncomputable def traceback : (t : Tree L S R) → S → Labeling t
| leaf _, _ => PUnit.unit
| node P l Q r, s =>
let a := argmaxState fun a => P s a * maxPrune obs l a
let b := argmaxState fun b => Q s b * maxPrune obs r b
((a, traceback l a), (b, traceback r b))
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:107
def weight : (t : Tree L S R) → S → Labeling t → R
| leaf l, s, _ => obs l s
| node P l Q r, s, z =>
(P s z.1.1 * weight l z.1.1 z.1.2) * (Q s z.2.1 * weight r z.2.1 z.2.2)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:134
DefinitionRoot state of Pupko's reconstruction#✓fully proved
The root state of Pupko's reconstruction: it maximizes π s * maxPrune obs t s.
noncomputable def jointRoot (t : Tree L S R) (π : S → R) : S :=
argmaxState fun s => π s * maxPrune obs t s
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def argmaxState (f : S → R) : S :=
(Finite.exists_max f).choose
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:79
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
Uses 3 · Used by 1
DefinitionPupko's joint reconstruction#✓fully proved
The root state jointRoot and the traced labeling.
noncomputable def pupko (t : Tree L S R) (π : S → R) : S × Labeling t :=
(jointRoot obs t π, traceback obs t (jointRoot obs t π))
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def Labeling : Tree L S R → Type v
| leaf _ => PUnit
| node _ l _ r => (S × Labeling l) × (S × Labeling r)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:101
noncomputable def jointRoot (t : Tree L S R) (π : S → R) : S :=
argmaxState fun s => π s * maxPrune obs t s
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:177
noncomputable def traceback : (t : Tree L S R) → S → Labeling t
| leaf _, _ => PUnit.unit
| node P l Q r, s =>
let a := argmaxState fun a => P s a * maxPrune obs l a
let b := argmaxState fun b => Q s b * maxPrune obs r b
((a, traceback l a), (b, traceback r b))
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:107
TheoremLikelihood of Pupko's joint reconstruction#✓fully proved
The likelihood of Pupko's reconstruction is max_s π s * maxPrune obs t s.
theorem jointLik_pupko (t : Tree L S R) (π : S → R) :
π (pupko obs t π).1 * weight obs t (pupko obs t π).1 (pupko obs t π).2 =
univ.sup' univ_nonempty fun s => π s * maxPrune obs t s
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def pupko (t : Tree L S R) (π : S → R) : S × Labeling t :=
(jointRoot obs t π, traceback obs t (jointRoot obs t π))
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:181
def weight : (t : Tree L S R) → S → Labeling t → R
| leaf l, s, _ => obs l s
| node P l Q r, s, z =>
(P s z.1.1 * weight l z.1.1 z.1.2) * (Q s z.2.1 * weight r z.2.1 z.2.2)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:134
def maxPrune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s =>
(univ.sup' univ_nonempty fun a => P s a * maxPrune l a) *
(univ.sup' univ_nonempty fun b => Q s b * maxPrune r b)
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:99
Uses 8 · Used by 1
TheoremPupko et al. (2000): joint maximum likelihood#✓fully proved
With nonnegative root, transition and leaf
weights, no root state s and labeling z of the non-root nodes has larger joint likelihood
π s * weight obs t s z than Pupko's reconstruction.
theorem pupko_isJointML (hobs : ∀ l s, 0 ≤ obs l s) (t : Tree L S R) (ht : NonnegWeights t)
(π : S → R) (hπ : ∀ s, 0 ≤ π s) (s : S) (z : Labeling t) :
π s * weight obs t s z ≤
π (pupko obs t π).1 * weight obs t (pupko obs t π).1 (pupko obs t π).2
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def NonnegWeights [Zero R] [LE R] : Tree L S R → Prop
| leaf _ => True
| node P l Q r => (∀ a b, 0 ≤ P a b) ∧ (∀ a b, 0 ≤ Q a b) ∧ NonnegWeights l ∧ NonnegWeights r
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:70
def Labeling : Tree L S R → Type v
| leaf _ => PUnit
| node _ l _ r => (S × Labeling l) × (S × Labeling r)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:101
def weight : (t : Tree L S R) → S → Labeling t → R
| leaf l, s, _ => obs l s
| node P l Q r, s, z =>
(P s z.1.1 * weight l z.1.1 z.1.2) * (Q s z.2.1 * weight r z.2.1 z.2.2)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:134
noncomputable def pupko (t : Tree L S R) (π : S → R) : S × Labeling t :=
(jointRoot obs t π, traceback obs t (jointRoot obs t π))
CSLibExt/Bioinformatics/Phylogenetics/AncestralReconstruction.lean:181
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.