Start pplus-library: 16 verified routines in six modules
Routines written once in pseudo and checked at every level, so programs can use them by name instead of rewriting and re-verifying them: - stats: Mean, Variance (two-pass) - numerics: KahanSum, LinearInterp, Trapezoid - align: LinearGapPenalty, AffineGapPenalty, MatchScore, NeedlemanWunschScore - md: LennardJones, LennardJonesForce, MinimumImage, PairDistance - seq: GCContent, HammingDistance - special: ErfApprox (Abramowitz and Stegun 7.1.26) Each has contracts, cases, reference implementations in Python, Mojo and (for the numerical ones) C at more than one level, and nine have a Dafny proof over exact numbers. status.json and STATUS.md are written by pplus-core's library-check: every check passes or is open/unverified as listed there. The Mojo references still need the pinned compiler's answers (library-verify-mojo, network). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
103 files changed
+3025
No files matched your search
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"tool": "dafny",
|
||||
"version": "4.11.0",
|
||||
"flags": [
|
||||
"verify",
|
||||
"--resource-limit",
|
||||
"20000000"
|
||||
],
|
||||
"source_sha256": "5a0a04933596877e8f881204d2508c4fd6f4fc5a37aa4d0a0dce95ac4da45730",
|
||||
"verdict": "verified",
|
||||
"summary": "3 verified, 0 errors"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
def affine_gap_penalty(length: Int, open_: Int, extend: Int) -> Int:
|
||||
return open_ + (length - 1) * extend
|
||||
@@ -0,0 +1,2 @@
|
||||
def affine_gap_penalty(length, open_, extend):
|
||||
return open_ + (length - 1) * extend
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "AffineGapPenalty",
|
||||
"summary": "The score of a gap of Length positions when opening a gap scores Open and each further position scores Extend.",
|
||||
"tags": [
|
||||
"alignment",
|
||||
"gap model"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
"title": "Gotoh, An improved algorithm for matching biological sequences, J. Mol. Biol. 162 (1982)",
|
||||
"url": "https://doi.org/10.1016/0022-2836(82)90398-9"
|
||||
}
|
||||
],
|
||||
"cases": [
|
||||
{
|
||||
"call": "AffineGapPenalty(1, -10, -1)"
|
||||
},
|
||||
{
|
||||
"call": "AffineGapPenalty(5, -10, -1)"
|
||||
},
|
||||
{
|
||||
"call": "AffineGapPenalty(3, -2, -2)"
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"lang": "python",
|
||||
"level": "plain",
|
||||
"file": "ref/python/plain.py",
|
||||
"note": "The same formula."
|
||||
},
|
||||
{
|
||||
"lang": "mojo",
|
||||
"level": "plain",
|
||||
"file": "ref/mojo/plain.mojo",
|
||||
"note": "The same formula in Mojo."
|
||||
}
|
||||
],
|
||||
"proof": {
|
||||
"lang": "dafny",
|
||||
"file": "proof/affine_gap.dfy",
|
||||
"note": "The formula equals the score built position by position, and with Open == Extend it equals the linear model."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// AffineGapPenalty: the score of a gap of Length positions under an affine
|
||||
// gap model (Gotoh, 1982): Open for the first position and Extend for each
|
||||
// one after it, so one long gap costs less than many short ones. With
|
||||
// Open == Extend it is the linear model.
|
||||
FUNCTION AffineGapPenalty(Length : INTEGER, Open : INTEGER, Extend : INTEGER) RETURNS INTEGER
|
||||
REQUIRE Length >= 1
|
||||
ENSURE RESULT == Open + (Length - 1) * Extend
|
||||
RETURN Open + (Length - 1) * Extend
|
||||
ENDFUNCTION
|
||||
Reference in new issue
Block a user