30 lines
846 B
Plaintext
30 lines
846 B
Plaintext
method AffineGapPenalty(length: int, open: int, extend: int) returns (result: int)
|
|
requires length >= 1
|
|
ensures result == open + (length - 1) * extend
|
|
{
|
|
result := open + (length - 1) * extend;
|
|
}
|
|
|
|
// Position by position: the first position opens the gap, every later one extends it.
|
|
method AffineByPositions(length: int, open: int, extend: int) returns (score: int)
|
|
requires length >= 1
|
|
ensures score == open + (length - 1) * extend
|
|
{
|
|
score := open;
|
|
var i := 1;
|
|
while i < length
|
|
invariant 1 <= i <= length
|
|
invariant score == open + (i - 1) * extend
|
|
{
|
|
score := score + extend;
|
|
i := i + 1;
|
|
}
|
|
}
|
|
|
|
// With the same score for opening and extending, the affine model is the linear one.
|
|
lemma AffineIsLinearWhenEqual(length: int, gap: int)
|
|
requires length >= 1
|
|
ensures gap + (length - 1) * gap == length * gap
|
|
{
|
|
}
|