Initial commit
Test (in pplus-core) / in-core (push) Failing after 28m44s

This commit is contained in:
alexm committed 2026-11-12 22:23:48 -05:00
commit 568474d52f
1591 files changed
+528213

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,19 @@
{
"tool": "godbolt",
"compiler": "mojo_1_2_0",
"mojoVersion": "1.2.0",
"source_sha256": "9310c57a1b1128544f150ac943ea5d5efd387150ba0e55de119d84398627df70",
"stdin": "3 1 -10 -1 5 -10 -1 3 -2 -2 end\n",
"args": "--target-cpu x86-64-v3 --fp-mode contract=off",
"asked": "2026-11-12",
"result": {
"compiled": true,
"buildStderr": "",
"executed": true,
"exitCode": 0,
"stdout": "-10\n-14\n-6",
"stderr": "",
"timedOut": false,
"asm": null
}
}
@@ -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
+44
View File
@@ -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."
}
}
+10
View File
@@ -0,0 +1,10 @@
// 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. When Open is more negative than Extend, one long gap scores
// better than several short gaps of the same total length. 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
@@ -0,0 +1,12 @@
{
"tool": "dafny",
"version": "4.11.0",
"flags": [
"verify",
"--resource-limit",
"20000000"
],
"source_sha256": "1d61017b086bed77518f358dcbbc0fd011139347f77beb2d39479d9db7edb2de",
"verdict": "verified",
"summary": "2 verified, 0 errors"
}
@@ -0,0 +1,19 @@
{
"tool": "godbolt",
"compiler": "mojo_1_2_0",
"mojoVersion": "1.2.0",
"source_sha256": "8810a7c99a71768e1a9c7c26fb37cc87bdb3d6affd03dee8b2abaa35f44482e1",
"stdin": "3 3 -2 0 -2 10 -1 end\n",
"args": "--target-cpu x86-64-v3 --fp-mode contract=off",
"asked": "2026-11-12",
"result": {
"compiled": true,
"buildStderr": "",
"executed": true,
"exitCode": 0,
"stdout": "-6\n0\n-10",
"stderr": "",
"timedOut": false,
"asm": null
}
}
@@ -0,0 +1,23 @@
// A gap of `length` positions under a linear model: each position scores `gap`.
method LinearGapPenalty(length: int, gap: int) returns (result: int)
requires length >= 0
ensures result == length * gap
{
result := length * gap;
}
// The same score, built one position at a time: the product is the model, not a shortcut.
method LinearGapByPositions(length: int, gap: int) returns (score: int)
requires length >= 0
ensures score == length * gap
{
score := 0;
var i := 0;
while i < length
invariant 0 <= i <= length
invariant score == i * gap
{
score := score + gap;
i := i + 1;
}
}
@@ -0,0 +1,2 @@
def linear_gap_penalty(length: Int, gap: Int) -> Int:
return length * gap
@@ -0,0 +1,2 @@
def linear_gap_penalty(length, gap):
return length * gap
+44
View File
@@ -0,0 +1,44 @@
{
"name": "LinearGapPenalty",
"summary": "The score of a gap of Length positions when every position of a gap scores Gap.",
"tags": [
"alignment",
"gap model"
],
"sources": [
{
"title": "Durbin, Eddy, Krogh and Mitchison, Biological Sequence Analysis (Cambridge, 1998), chapter 2, Pairwise alignment",
"url": "https://doi.org/10.1017/CBO9780511790492.003"
}
],
"cases": [
{
"call": "LinearGapPenalty(3, -2)"
},
{
"call": "LinearGapPenalty(0, -2)"
},
{
"call": "LinearGapPenalty(10, -1)"
}
],
"references": [
{
"lang": "python",
"level": "plain",
"file": "ref/python/plain.py",
"note": "The same product."
},
{
"lang": "mojo",
"level": "plain",
"file": "ref/mojo/plain.mojo",
"note": "The same product in Mojo."
}
],
"proof": {
"lang": "dafny",
"file": "proof/linear_gap.dfy",
"note": "The product equals the score built position by position: each of the Length positions adds Gap."
}
}
+7
View File
@@ -0,0 +1,7 @@
// LinearGapPenalty: the score of a gap of Length positions under a linear gap
// model, where every position of a gap scores Gap (usually negative).
FUNCTION LinearGapPenalty(Length : INTEGER, Gap : INTEGER) RETURNS INTEGER
REQUIRE Length >= 0
ENSURE RESULT == Length * Gap
RETURN Length * Gap
ENDFUNCTION
@@ -0,0 +1,12 @@
{
"tool": "dafny",
"version": "4.11.0",
"flags": [
"verify",
"--resource-limit",
"20000000"
],
"source_sha256": "374ce6664efd8802bb90e120a1107375c0ab607c9829987b26d73d5f5fd4b009",
"verdict": "verified",
"summary": "1 verified, 0 errors"
}
@@ -0,0 +1,19 @@
{
"tool": "godbolt",
"compiler": "mojo_1_2_0",
"mojoVersion": "1.2.0",
"source_sha256": "b0a5473abe88ee1d6bee716670978df110ceabab60ef98b9789ec3b7ae16f512",
"stdin": "3 A A 1 -1 A G 1 -1 T T 5 -4 end\n",
"args": "--target-cpu x86-64-v3 --fp-mode contract=off",
"asked": "2026-11-12",
"result": {
"compiled": true,
"buildStderr": "",
"executed": true,
"exitCode": 0,
"stdout": "1\n-1\n5",
"stderr": "",
"timedOut": false,
"asm": null
}
}
@@ -0,0 +1,5 @@
method MatchScore(a: char, b: char, match_: int, mismatch: int) returns (r: int)
ensures (a == b && r == match_) || (a != b && r == mismatch)
{
if a == b { r := match_; } else { r := mismatch; }
}
@@ -0,0 +1,4 @@
def match_score(a: String, b: String, match_: Int, mismatch: Int) -> Int:
if a == b:
return match_
return mismatch
@@ -0,0 +1,2 @@
def match_score(a, b, match, mismatch):
return match if a == b else mismatch
+44
View File
@@ -0,0 +1,44 @@
{
"name": "MatchScore",
"summary": "The score of aligning letter A with letter B: Match when they are the same, Mismatch otherwise.",
"tags": [
"alignment",
"scoring"
],
"sources": [
{
"title": "Durbin, Eddy, Krogh and Mitchison, Biological Sequence Analysis (Cambridge, 1998), chapter 2, Pairwise alignment",
"url": "https://doi.org/10.1017/CBO9780511790492.003"
}
],
"cases": [
{
"call": "MatchScore('A', 'A', 1, -1)"
},
{
"call": "MatchScore('A', 'G', 1, -1)"
},
{
"call": "MatchScore('T', 'T', 5, -4)"
}
],
"references": [
{
"lang": "python",
"level": "plain",
"file": "ref/python/plain.py",
"note": "The same test."
},
{
"lang": "mojo",
"level": "plain",
"file": "ref/mojo/plain.mojo",
"note": "The same test in Mojo; a letter is a String of one character."
}
],
"proof": {
"lang": "dafny",
"file": "proof/match_score.dfy",
"note": "The score is Match exactly when the letters agree."
}
}
+10
View File
@@ -0,0 +1,10 @@
// MatchScore: the score of aligning letter A with letter B: Match when they
// are the same letter, Mismatch otherwise. The simplest substitution score;
// a substitution matrix such as BLOSUM62 replaces it for proteins.
FUNCTION MatchScore(A : CHAR, B : CHAR, Match : INTEGER, Mismatch : INTEGER) RETURNS INTEGER
ENSURE (A == B AND RESULT == Match) OR (A != B AND RESULT == Mismatch)
IF A == B THEN
RETURN Match
ENDIF
RETURN Mismatch
ENDFUNCTION
+5
View File
@@ -0,0 +1,5 @@
{
"name": "align",
"title": "Sequence alignment",
"summary": "Scores for aligning two sequences: gap models, letter scores, and global alignment by dynamic programming."
}
@@ -0,0 +1,19 @@
{
"tool": "godbolt",
"compiler": "mojo_1_2_0",
"mojoVersion": "1.2.0",
"source_sha256": "cd659ffc727fffe9b7493b2f77e9e37e758ad6ff36e9afb122a10d29cb5aae57",
"stdin": "4 GATTACA GCATGCU 1 -1 -1 ACGT ACGT 1 -1 -2 ACG 1 -1 -2 AAAA TTTT 2 -3 -1 end\n",
"args": "--target-cpu x86-64-v3 --fp-mode contract=off",
"asked": "2026-11-12",
"result": {
"compiled": true,
"buildStderr": "<source>:7:13: warning: ref 'j' was never used, remove it?\n for j in range(m + 1):\n ^\n<source>:5:9: warning: ref 'i' was never used, remove it?\n for i in range(n + 1):\n ^",
"executed": true,
"exitCode": 0,
"stdout": "0\n4\n-6\n-8",
"stderr": "",
"timedOut": false,
"asm": null
}
}
@@ -0,0 +1,25 @@
def needleman_wunsch_score(s: String, t: String, match_: Int, mismatch: Int, gap: Int) -> Int:
var n = s.count_codepoints()
var m = t.count_codepoints()
var d = List[List[Int]]()
for i in range(n + 1):
var row = List[Int]()
for j in range(m + 1):
row.append(0)
d.append(row^)
for i in range(n + 1):
d[i][0] = i * gap
for j in range(1, m + 1):
d[0][j] = j * gap
for i in range(1, n + 1):
for j in range(1, m + 1):
var score = mismatch
if String(s[codepoint=i - 1]) == String(t[codepoint=j - 1]):
score = match_
var best = d[i - 1][j - 1] + score
if d[i - 1][j] + gap > best:
best = d[i - 1][j] + gap
if d[i][j - 1] + gap > best:
best = d[i][j - 1] + gap
d[i][j] = best
return d[n][m]
@@ -0,0 +1,12 @@
def needleman_wunsch_score(s, t, match, mismatch, gap):
n, m = len(s), len(t)
d = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(n + 1):
d[i][0] = i * gap
for j in range(1, m + 1):
d[0][j] = j * gap
for i in range(1, n + 1):
for j in range(1, m + 1):
diagonal = d[i - 1][j - 1] + (match if s[i - 1] == t[j - 1] else mismatch)
d[i][j] = max(diagonal, d[i - 1][j] + gap, d[i][j - 1] + gap)
return d[n][m]
@@ -0,0 +1,10 @@
def needleman_wunsch_score(s, t, match, mismatch, gap):
m = len(t)
prev = [j * gap for j in range(m + 1)]
for i in range(1, len(s) + 1):
cur = [i * gap] + [0] * m
for j in range(1, m + 1):
diagonal = prev[j - 1] + (match if s[i - 1] == t[j - 1] else mismatch)
cur[j] = max(diagonal, prev[j] + gap, cur[j - 1] + gap)
prev = cur
return prev[m]
@@ -0,0 +1,48 @@
{
"name": "NeedlemanWunschScore",
"summary": "The best score of a global alignment of two sequences with a linear gap model, by dynamic programming.",
"tags": [
"alignment",
"dynamic programming"
],
"sources": [
{
"title": "Needleman and Wunsch, A general method applicable to the search for similarities in the amino acid sequence of two proteins, J. Mol. Biol. 48 (1970)",
"url": "https://doi.org/10.1016/0022-2836(70)90057-4"
}
],
"cases": [
{
"call": "NeedlemanWunschScore(\"GATTACA\", \"GCATGCU\", 1, -1, -1)"
},
{
"call": "NeedlemanWunschScore(\"ACGT\", \"ACGT\", 1, -1, -2)"
},
{
"call": "NeedlemanWunschScore(\"\", \"ACG\", 1, -1, -2)"
},
{
"call": "NeedlemanWunschScore(\"AAAA\", \"TTTT\", 2, -3, -1)"
}
],
"references": [
{
"lang": "python",
"level": "plain",
"file": "ref/python/plain.py",
"note": "The same table, filled row by row."
},
{
"lang": "python",
"level": "two-rows",
"file": "ref/python/two-rows.py",
"note": "Only the previous row is kept: memory grows with the length of T alone, the first step toward Hirschberg's linear-space alignment."
},
{
"lang": "mojo",
"level": "plain",
"file": "ref/mojo/plain.mojo",
"note": "The same table in Mojo, as a list of rows."
}
]
}
@@ -0,0 +1,27 @@
// NeedlemanWunschScore: the best score of a global alignment of S and T
// (Needleman and Wunsch, 1970) with a linear gap model, by dynamic
// programming. D[I, J] is the best score of aligning the first I letters of
// S with the first J letters of T; each cell takes the best of three moves:
// align S[I - 1] with T[J - 1], or put a gap in one sequence or the other.
USE align.MatchScore
USE align.LinearGapPenalty
FUNCTION NeedlemanWunschScore(S : STRING, T : STRING, Match : INTEGER, Mismatch : INTEGER, Gap : INTEGER) RETURNS INTEGER
DECLARE N : INTEGER <- LENGTH(S)
DECLARE M : INTEGER <- LENGTH(T)
DECLARE D : ARRAY[N + 1, M + 1] OF INTEGER
FOR I <- 0 TO N + 1
D[I, 0] <- LinearGapPenalty(I, Gap)
NEXT I
FOR J <- 1 TO M + 1
D[0, J] <- LinearGapPenalty(J, Gap)
NEXT J
FOR I <- 1 TO N + 1
FOR J <- 1 TO M + 1
DECLARE Diagonal : INTEGER <- D[I - 1, J - 1] + MatchScore(S[I - 1], T[J - 1], Match, Mismatch)
DECLARE Down : INTEGER <- D[I - 1, J] + Gap
DECLARE Across : INTEGER <- D[I, J - 1] + Gap
D[I, J] <- MAX(Diagonal, Down, Across)
NEXT J
NEXT I
RETURN D[N, M]
ENDFUNCTION