McCaskill partition function for RNA folding
DefinitionComplementary base pairing of two positions#✓fully proved
Positions i and j of s both lie in s and carry complementary bases.
Used by 8
DefinitionInside recursion#✓fully proved
Inside recursion over a commutative semiring R: inside pair m s w i len is the
weighted sum over the secondary structures supported in the interval [i, i + len) (proved in
inside_eq_sum). Base i is either unpaired, or paired with i + 1 + k for some k ≥ m
with CanPair pair s i (i + 1 + k), which contributes w i (i + 1 + k) times the inside
values of the enclosed interval [i + 1, i + 1 + k) and of the outer interval
[i + k + 2, i + len + 1).
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
def CanPair (i j : ℕ) : Prop :=
∃ a b, s[i]? = some a ∧ s[j]? = some b ∧ pair a b
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:113
Uses 1 · Used by 8
DefinitionOutside recursion#✓fully proved
Outside recursion (McCaskill 1990) over a commutative semiring R, for a sequence of
length n = s.length: outside pair m s w i j is the weighted sum of the parts outside the
pair (i, j) of all structures containing it (proved in outside_mul_eq_sum). Either no pair
encloses (i, j), leaving independent structures on [0, i) and [j + 1, n), or there is a
unique innermost enclosing pair (a, b) (a < i, j < b < n), contributing the outside value
of (a, b), its weight, and the inside values of [a + 1, i) and [j + 1, b).
def outside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) (i j : ℕ) : R :=
inside pair m s w 0 i * inside pair m s w (j + 1) (s.length - (j + 1)) +
∑ a : Fin i, ∑ c : Fin (s.length - (j + 1)),
if a.val + m < j + 1 + c.val ∧ CanPair pair s a.val (j + 1 + c.val) then
outside w a.val (j + 1 + c.val) * w a.val (j + 1 + c.val) *
inside pair m s w (a.val + 1) (i - (a.val + 1)) * inside pair m s w (j + 1) c.val
else 0
termination_by s.length - (j - i)
decreasing_by omega
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
def CanPair (i j : ℕ) : Prop :=
∃ a b, s[i]? = some a ∧ s[j]? = some b ∧ pair a b
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:113
Uses 2 · Used by 2
DefinitionSecondary structures within an interval#✓fully proved
The secondary structures on s (IsStructure pair m s) all of whose pairs lie in the
interval [i, i + len).
noncomputable def structuresIn (i len : ℕ) : Finset (Finset (ℕ × ℕ)) :=
((Finset.Ico i (i + len) ×ˢ Finset.Ico i (i + len)).powerset).filter
fun P => IsStructure pair m s P
structure IsStructure {B : Type*} (pair : B → B → Prop) (m : ℕ) (s : List B)
(P : Finset (ℕ × ℕ)) : Prop where
/-- Each pair encloses at least `m` positions: `i + m < j`. -/
loop : ∀ p ∈ P, p.1 + m < p.2
/-- Both positions of a pair lie in `s` and carry complementary bases. -/
compl : ∀ p ∈ P, ∃ a b, s[p.1]? = some a ∧ s[p.2]? = some b ∧ pair a b
/-- Distinct pairs share no position. -/
disjoint : ∀ p ∈ P, ∀ q ∈ P, p ≠ q →
p.1 ≠ q.1 ∧ p.1 ≠ q.2 ∧ p.2 ≠ q.1 ∧ p.2 ≠ q.2
/-- No two pairs cross. -/
noncrossing : ∀ p ∈ P, ∀ q ∈ P, ¬ (p.1 < q.1 ∧ q.1 < p.2 ∧ p.2 < q.2)
CSLibExt/Bioinformatics/RNA/Nussinov.lean:64
Uses 1 · Used by 4
DefinitionSet of all secondary structures of a sequence#✓fully proved
All secondary structures on s with minimum hairpin m (see mem_structures).
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
noncomputable def structuresIn (i len : ℕ) : Finset (Finset (ℕ × ℕ)) :=
((Finset.Ico i (i + len) ×ˢ Finset.Ico i (i + len)).powerset).filter
fun P => IsStructure pair m s P
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:157
Uses 1 · Used by 14
DefinitionWeight of a secondary structure#✓fully proved
The weight of a structure: the product of the weights of its base pairs.
def weight {R : Type*} [CommMonoid R] (w : ℕ → ℕ → R) (P : Finset (ℕ × ℕ)) : R :=
∏ p ∈ P, w p.1 p.2
Used by 11
TheoremMembership in the set of secondary structures#✓fully proved
structures is exactly the set of secondary structures on s.
theorem mem_structures (P : Finset (ℕ × ℕ)) :
P ∈ structures pair m s ↔ IsStructure pair m s P
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
structure IsStructure {B : Type*} (pair : B → B → Prop) (m : ℕ) (s : List B)
(P : Finset (ℕ × ℕ)) : Prop where
/-- Each pair encloses at least `m` positions: `i + m < j`. -/
loop : ∀ p ∈ P, p.1 + m < p.2
/-- Both positions of a pair lie in `s` and carry complementary bases. -/
compl : ∀ p ∈ P, ∃ a b, s[p.1]? = some a ∧ s[p.2]? = some b ∧ pair a b
/-- Distinct pairs share no position. -/
disjoint : ∀ p ∈ P, ∀ q ∈ P, p ≠ q →
p.1 ≠ q.1 ∧ p.1 ≠ q.2 ∧ p.2 ≠ q.1 ∧ p.2 ≠ q.2
/-- No two pairs cross. -/
noncrossing : ∀ p ∈ P, ∀ q ∈ P, ¬ (p.1 < q.1 ∧ q.1 < p.2 ∧ p.2 < q.2)
CSLibExt/Bioinformatics/RNA/Nussinov.lean:64
Uses 2 · Used by 5
TheoremInside algorithm#✓fully proved
The inside recursion sums the weights of all secondary structures
supported in the interval [i, i + len), over any commutative semiring.
theorem inside_eq_sum [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R)
(i len : ℕ) :
inside pair m s w i len = ∑ P ∈ structuresIn pair m s i len, weight w P
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
noncomputable def structuresIn (i len : ℕ) : Finset (Finset (ℕ × ℕ)) :=
((Finset.Ico i (i + len) ×ˢ Finset.Ico i (i + len)).powerset).filter
fun P => IsStructure pair m s P
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:157
def weight {R : Type*} [CommMonoid R] (w : ℕ → ℕ → R) (P : Finset (ℕ × ℕ)) : R :=
∏ p ∈ P, w p.1 p.2
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:166
Uses 5 · Used by 2
TheoremInside value sums the weights of all secondary structures#✓fully proved
The inside value of the whole sequence sums the weights of all its secondary structures.
theorem inside_eq_sum_structures [DecidableRel pair] {R : Type*} [CommSemiring R]
(w : ℕ → ℕ → R) :
inside pair m s w 0 s.length = ∑ P ∈ structures pair m s, weight w P
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
def weight {R : Type*} [CommMonoid R] (w : ℕ → ℕ → R) (P : Finset (ℕ × ℕ)) : R :=
∏ p ∈ P, w p.1 p.2
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:166
Uses 4 · Used by 4
TheoremOutside algorithm#✓fully proved
Outside algorithm (McCaskill 1990): for a candidate pair (i, j) (i + m < j and
CanPair pair s i j), the outside value times the pair's weight times the inside value of the
enclosed interval [i + 1, j) sums the weights of all secondary structures containing
(i, j).
theorem outside_mul_eq_sum [DecidableRel pair] {R : Type*} [CommSemiring R]
(w : ℕ → ℕ → R) (i j : ℕ) (hij : i + m < j) (hc : CanPair pair s i j) :
outside pair m s w i j * w i j * inside pair m s w (i + 1) (j - (i + 1)) =
∑ P ∈ structures pair m s with (i, j) ∈ P, weight w P
def CanPair (i j : ℕ) : Prop :=
∃ a b, s[i]? = some a ∧ s[j]? = some b ∧ pair a b
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:113
def outside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) (i j : ℕ) : R :=
inside pair m s w 0 i * inside pair m s w (j + 1) (s.length - (j + 1)) +
∑ a : Fin i, ∑ c : Fin (s.length - (j + 1)),
if a.val + m < j + 1 + c.val ∧ CanPair pair s a.val (j + 1 + c.val) then
outside w a.val (j + 1 + c.val) * w a.val (j + 1 + c.val) *
inside pair m s w (a.val + 1) (i - (a.val + 1)) * inside pair m s w (j + 1) c.val
else 0
termination_by s.length - (j - i)
decreasing_by omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:144
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
def weight {R : Type*} [CommMonoid R] (w : ℕ → ℕ → R) (P : Finset (ℕ × ℕ)) : R :=
∏ p ∈ P, w p.1 p.2
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:166
Uses 9 · Used by 1
Min-plus: the Nussinov maximum
TheoremTropical semiring#✓fully proved
With every base pair weighted -1 in the min-plus semiring
MinTropical (WithTop ℤ) (addition min, multiplication +), a structure with k pairs has
weight -k, so the inside value of the whole sequence is minus the Nussinov maximum number of
base pairs.
theorem inside_minTropical [DecidableRel pair] :
inside pair m s (fun _ _ => MinTropical.trop ((-1 : ℤ) : WithTop ℤ)) 0 s.length =
MinTropical.trop ((-(nussinov pair m s : ℤ) : ℤ) : WithTop ℤ)
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
def nussinov {B : Type*} (pair : B → B → Prop) [DecidableRel pair] (m : ℕ) : List B → ℕ
| [] => 0
| a :: rest =>
max (nussinov pair m rest)
(listMax ((List.finRange rest.length).map fun k =>
if m ≤ k.val ∧ pair a rest[k] then
1 + nussinov pair m (rest.take k.val) + nussinov pair m (rest.drop (k.val + 1))
else 0))
termination_by l => l.length
decreasing_by
all_goals simp only [List.length_cons, List.length_take, List.length_drop]
all_goals omega
CSLibExt/Bioinformatics/RNA/Nussinov.lean:83
Uses 9
Counting: Waterman, Motzkin, Stein–Waterman
DefinitionWaterman's recursion#✓fully proved
Waterman's recursion for the number S_m(n) of secondary structures on n points
with minimum hairpin m when every pair is allowed: S(0) = 1 and
S(n + 1) = S(n) + ∑_{m ≤ k < n} S(k) S(n - 1 - k) (Waterman 1978; Stein–Waterman 1979).
For m = 0 these are the Motzkin numbers (watermanNumber_zero_eq_motzkinNumber); for m = 1
the Stein–Waterman numbers 1, 1, 1, 2, 4, 8, 17, 37, … (OEIS A004148).
def watermanNumber (m : ℕ) : ℕ → ℕ
| 0 => 1
| n + 1 =>
watermanNumber m n +
∑ k : Fin n, if m ≤ k.val then
watermanNumber m k.val * watermanNumber m (n - 1 - k.val) else 0
termination_by n => n
decreasing_by all_goals omega
Used by 2
TheoremCounting semiring#✓fully proved
The number of secondary structures on n points with minimum
hairpin m, when every pair of positions may pair, is Waterman's number S_m(n).
theorem card_structures_eq_watermanNumber (m n : ℕ) :
(structures (fun _ _ : Unit => True) m (List.replicate n ())).card =
watermanNumber m n
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
def watermanNumber (m : ℕ) : ℕ → ℕ
| 0 => 1
| n + 1 =>
watermanNumber m n +
∑ k : Fin n, if m ≤ k.val then
watermanNumber m k.val * watermanNumber m (n - 1 - k.val) else 0
termination_by n => n
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1497
TheoremWaterman numbers with no hairpin constraint are Motzkin numbers#✓fully proved
For m = 0 (no hairpin constraint) Waterman's numbers are the Motzkin numbers
M(n) = ∑_k C(n, 2k) C(k): the number of non-crossing partial matchings on n points.
theorem watermanNumber_zero_eq_motzkinNumber (n : ℕ) :
watermanNumber 0 n = MetaMathlibExt.motzkinNumber n
def watermanNumber (m : ℕ) : ℕ → ℕ
| 0 => 1
| n + 1 =>
watermanNumber m n +
∑ k : Fin n, if m ≤ k.val then
watermanNumber m k.val * watermanNumber m (n - 1 - k.val) else 0
termination_by n => n
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1497
def motzkinNumber (n : ℕ) : ℕ :=
∑ k ∈ Finset.range (n + 1), n.choose (2 * k) * catalan k
MathlibExt/Combinatorics/Enumerative/MotzkinNumber.lean:44
Uses 3
Sum-product: the McCaskill partition function
DefinitionAdditive base-pair energy model#✓fully proved
An additive base-pair energy model: the free energy of a structure is the sum of the
energies e i j of its base pairs (in the same units as RT).
def energy (e : ℕ → ℕ → ℝ) (P : Finset (ℕ × ℕ)) : ℝ :=
∑ p ∈ P, e p.1 p.2
Used by 2
DefinitionMcCaskill partition function of RNA secondary structures#✓fully proved
The partition function Z = ∑_S exp (-E(S) / RT) over all secondary structures S
on s with minimum hairpin m, for the additive energy e at thermal energy RT
(physically 0 < RT; the identities below hold for every real RT).
noncomputable def partitionFunction (e : ℕ → ℕ → ℝ) (RT : ℝ) : ℝ :=
∑ P ∈ structures pair m s, Real.exp (-energy e P / RT)
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
def energy (e : ℕ → ℕ → ℝ) (P : Finset (ℕ × ℕ)) : ℝ :=
∑ p ∈ P, e p.1 p.2
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1562
Uses 2 · Used by 1
TheoremMcCaskill's algorithm#✓fully proved
McCaskill's algorithm (inside part): over the sum-product semiring ℝ with Boltzmann
weights exp (-e i j / RT), the inside value of the whole sequence is the partition function.
This is an algebraic identity valid for every real RT.
theorem inside_boltzmann_eq_partitionFunction [DecidableRel pair] (e : ℕ → ℕ → ℝ) (RT : ℝ) :
inside pair m s (fun i j => Real.exp (-e i j / RT)) 0 s.length =
partitionFunction pair m s e RT
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
noncomputable def partitionFunction (e : ℕ → ℕ → ℝ) (RT : ℝ) : ℝ :=
∑ P ∈ structures pair m s, Real.exp (-energy e P / RT)
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1568
DefinitionBase-pair probability#✓fully proved
The base-pair probability P(i, j): the total weight of the structures containing the
pair (i, j), divided by the total weight Z of all structures. For nonnegative weights Z ≥ 1
(the empty structure has weight 1), so the denominator is positive; for Boltzmann weights this
is the probability of (i, j) under the Boltzmann distribution on structures.
noncomputable def pairProb (w : ℕ → ℕ → ℝ) (i j : ℕ) : ℝ :=
(∑ P ∈ structures pair m s with (i, j) ∈ P, weight w P) /
∑ P ∈ structures pair m s, weight w P
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
def weight {R : Type*} [CommMonoid R] (w : ℕ → ℕ → R) (P : Finset (ℕ × ℕ)) : R :=
∏ p ∈ P, w p.1 p.2
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:166
Uses 2 · Used by 3
TheoremMcCaskill's base-pair probabilities#✓fully proved
For a candidate pair (i, j),
P(i, j) = outside(i, j) · w(i, j) · inside(i + 1, j) / inside(0, n).
theorem pairProb_eq_outside [DecidableRel pair] (w : ℕ → ℕ → ℝ) (i j : ℕ) (hij : i + m < j)
(hc : CanPair pair s i j) :
pairProb pair m s w i j =
outside pair m s w i j * w i j * inside pair m s w (i + 1) (j - (i + 1)) /
inside pair m s w 0 s.length
def CanPair (i j : ℕ) : Prop :=
∃ a b, s[i]? = some a ∧ s[j]? = some b ∧ pair a b
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:113
noncomputable def pairProb (w : ℕ → ℕ → ℝ) (i j : ℕ) : ℝ :=
(∑ P ∈ structures pair m s with (i, j) ∈ P, weight w P) /
∑ P ∈ structures pair m s, weight w P
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1585
def outside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) (i j : ℕ) : R :=
inside pair m s w 0 i * inside pair m s w (j + 1) (s.length - (j + 1)) +
∑ a : Fin i, ∑ c : Fin (s.length - (j + 1)),
if a.val + m < j + 1 + c.val ∧ CanPair pair s a.val (j + 1 + c.val) then
outside w a.val (j + 1 + c.val) * w a.val (j + 1 + c.val) *
inside pair m s w (a.val + 1) (i - (a.val + 1)) * inside pair m s w (j + 1) c.val
else 0
termination_by s.length - (j - i)
decreasing_by omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:144
def inside [DecidableRel pair] {R : Type*} [CommSemiring R] (w : ℕ → ℕ → R) :
ℕ → ℕ → R
| _, 0 => 1
| i, len + 1 =>
inside w (i + 1) len +
∑ k : Fin len, if m ≤ k.val ∧ CanPair pair s i (i + 1 + k.val) then
w i (i + 1 + k.val) * inside w (i + 1) k.val *
inside w (i + k.val + 2) (len - 1 - k.val)
else 0
termination_by _ len => len
decreasing_by all_goals omega
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:126
TheoremTotal structure weight is at least one#✓fully proved
For nonnegative weights the total weight of all structures is at least 1, the weight of
the empty structure; so the denominator of pairProb is positive.
theorem one_le_sum_weight (w : ℕ → ℕ → ℝ) (hw : ∀ i j, 0 ≤ w i j) :
1 ≤ ∑ P ∈ structures pair m s, weight w P
noncomputable def structures : Finset (Finset (ℕ × ℕ)) :=
structuresIn pair m s 0 s.length
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:162
def weight {R : Type*} [CommMonoid R] (w : ℕ → ℕ → R) (P : Finset (ℕ × ℕ)) : R :=
∏ p ∈ P, w p.1 p.2
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:166
Uses 4 · Used by 1
TheoremNonnegativity of base-pair probabilities#✓fully proved
Base-pair probabilities are nonnegative for nonnegative weights.
theorem pairProb_nonneg (w : ℕ → ℕ → ℝ) (hw : ∀ i j, 0 ≤ w i j) (i j : ℕ) :
0 ≤ pairProb pair m s w i j
noncomputable def pairProb (w : ℕ → ℕ → ℝ) (i j : ℕ) : ℝ :=
(∑ P ∈ structures pair m s with (i, j) ∈ P, weight w P) /
∑ P ∈ structures pair m s, weight w P
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1585
Uses 3
TheoremEach base pairs at most once#✓fully proved
For nonnegative weights, the probabilities that base i
pairs with some later base j or some earlier base j sum to at most 1
(∑_j (P(i, j) + P(j, i)) ≤ 1).
theorem sum_pairProb_le_one (w : ℕ → ℕ → ℝ) (hw : ∀ i j, 0 ≤ w i j) (i : ℕ) :
∑ j ∈ Finset.range s.length, (pairProb pair m s w i j + pairProb pair m s w j i) ≤ 1
noncomputable def pairProb (w : ℕ → ℕ → ℝ) (i j : ℕ) : ℝ :=
(∑ P ∈ structures pair m s with (i, j) ∈ P, weight w P) /
∑ P ∈ structures pair m s, weight w P
CSLibExt/Bioinformatics/RNA/PartitionFunction.lean:1585
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.