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

+10
View File
@@ -0,0 +1,10 @@
// APPEND puts the INTEGER into a LIST OF FLOAT32 without rounding it; reading
// it back into a FLOAT32 rounds.
// MUST-NOT-PROVE: assert@10
DECLARE L : LIST OF FLOAT32
DECLARE Y : FLOAT32
DECLARE N : INTEGER
N <- 16777217
APPEND(L, N)
Y <- L[0]
ASSERT Y == N
+17
View File
@@ -0,0 +1,17 @@
// The first label matches every X, so ISqrt(X) in the second label is never
// called. The checker kept its ENSURE (0 <= RESULT <= X) as a fact anyway.
// CALL: P(-1)
// MUST-NOT-PROVE: assert@16
FUNCTION ISqrt(N : INTEGER) RETURNS INTEGER
REQUIRE N >= 0
ENSURE RESULT >= 0 AND RESULT <= N
RETURN 0
ENDFUNCTION
PROCEDURE P(X : INTEGER)
CASE OF X
X, ISqrt(X) : OUTPUT "a"
OTHERWISE : OUTPUT "b"
ENDCASE
ASSERT X >= 0
ENDPROCEDURE
+5
View File
@@ -0,0 +1,5 @@
// CHR accepts the two halves of a surrogate pair; joined they are one character.
// RUN-STOPS: value@4
DECLARE S : STRING
S <- CHR(55357) & CHR(56832)
ASSERT LENGTH(S) == 2
+6
View File
@@ -0,0 +1,6 @@
// The same for constants: X + A + 2 - A is X + 2, and the checker gets X + 1.
// INPUT: -5
// MUST-NOT-PROVE: assert@6
DECLARE X : INTEGER
INPUT X
ASSERT X + 9007199254740991 + 2 - 9007199254740991 == X + 1
+12
View File
@@ -0,0 +1,12 @@
// The run checks DECREASES >= 0 on every call, the first one too. No
// obligation covers that check, so a unit with everything proved still stops.
// MUST-NOT-PROVE: decreases-bound@5
FUNCTION F(N : INTEGER) RETURNS INTEGER
DECREASES N
IF N <= 0 THEN
RETURN 0
ENDIF
RETURN F(N - 1)
ENDFUNCTION
OUTPUT F(-5)
+15
View File
@@ -0,0 +1,15 @@
// The recursive call's measure is compared with N as it is at the call
// (N + 2), not with N as it was on entry. The run compares with entry.
// MUST-NOT-PROVE: decreases-step@12
// RUN-STOPS: decreases@7
FUNCTION F(N : INTEGER) RETURNS INTEGER
REQUIRE N >= 0
DECREASES N
IF N == 0 THEN
RETURN 0
ENDIF
N <- N + 2
RETURN F(N - 1)
ENDFUNCTION
OUTPUT F(3)
+9
View File
@@ -0,0 +1,9 @@
// FILL stops the program on a negative count, so the call is an
// obligation, not a fact the checker may assume.
// MUST-NOT-PROVE: argument@6
FUNCTION F(N : INTEGER) RETURNS INTEGER
DECLARE Xs : LIST OF INTEGER
Xs <- FILL(N, 0)
RETURN LENGTH(Xs)
ENDFUNCTION
OUTPUT F(-1)
+4
View File
@@ -0,0 +1,4 @@
// In a run only a whole number is IN a range. The checker reads
// X IN [0, 5) as 0 <= X < 5 for a FLOAT as well.
// MUST-NOT-PROVE: assert@4
ASSERT 2.5 IN [0, 5)
+10
View File
@@ -0,0 +1,10 @@
// The prover treats a FLOAT as a number: Y == Y, and X < X + 1.0 or not.
// Infinity and NaN are not numbers in that sense. A run that let 1.0E308 *
// 10.0 become infinity, and X - X become NaN, broke both claims while the
// checker proved them. Such a run now stops at the overflow instead.
// RUN-STOPS: overflow@7
DECLARE X, Y : FLOAT
X <- 1.0E308 * 10.0
Y <- X - X
ASSERT Y == Y
OUTPUT Y
+8
View File
@@ -0,0 +1,8 @@
// A whole number stored in a FLOAT32 is rounded to the nearest single:
// 16777217 becomes 16777216. A rule that kept the INTEGER's value for the
// FLOAT32 would prove this ASSERT, and the run breaks it.
// MUST-NOT-PROVE: assert@8
DECLARE N : INTEGER <- 16777217
DECLARE X : FLOAT32
X <- N
ASSERT X == N
+9
View File
@@ -0,0 +1,9 @@
// The checker's bound for the counter is stop + STEP, folded as a double:
// 9007199254740991 + 2 rounds down. The way out of the loop then holds a
// contradiction, and anything after the loop is proved.
// MUST-NOT-PROVE: assert@9
// RUN-STOPS: overflow@6
FOR I <- 9007199254740990 TO 9007199254740991 STEP 2
OUTPUT I
NEXT I
ASSERT 1 == 2
+10
View File
@@ -0,0 +1,10 @@
// A FOR counter declared INT8 holds only what INT8 holds: the run checks it at
// the top of each pass and stops here when NEXT takes it to 128. No obligation
// covered that check, so a unit with everything proved still stopped.
// MUST-NOT-PROVE: overflow@7
DECLARE I : INT8
DECLARE N : INTEGER <- 0
FOR I <- 120 TO 130
N <- N + 1
NEXT I
OUTPUT N
+13
View File
@@ -0,0 +1,13 @@
// The way out of a FOR EACH loop includes the case of no pass at all. A
// checker that kept "X is in Xs" on the way out held FALSE after looping over
// an empty list, and proved anything, even 1 == 2.
// MUST-NOT-PROVE: assert@12
DECLARE Xs : LIST OF INTEGER
DECLARE S : INTEGER
Xs <- []
S <- 0
FOR EACH X IN Xs
S <- S + X
NEXT X
ASSERT 1 == 2
OUTPUT S
@@ -0,0 +1,10 @@
// M is empty, so the loop makes no pass. Its INVARIANT was never checked in
// a run, and the checker assumed it on the way out all the same.
// The run now checks it once more when the loop ends, and stops.
// RUN-STOPS: invariant@7
DECLARE M : LIST OF INTEGER
FOR EACH E IN M
INVARIANT 1 == 2
OUTPUT E
NEXT E
ASSERT 1 == 2
@@ -0,0 +1,13 @@
// The INVARIANT is proved kept for the value just visited; the run checks it
// with the next value, and it is FALSE there (Seen is 1, X is -1).
// MUST-NOT-PROVE: invariant-keep@9
DECLARE L : LIST OF INTEGER
DECLARE Seen : INTEGER
L <- [1, -1]
Seen <- 0
FOR EACH X IN L
INVARIANT Seen == 0 OR X >= 0
IF X >= 0 THEN
Seen <- 1
ENDIF
NEXT X
+13
View File
@@ -0,0 +1,13 @@
// "An ARRAY keeps its dimensions through a loop" was assumed for every ARRAY
// the body changes, while A <- B gave A the length of B. The language now holds
// an ARRAY to its declared length: the store of another length stops the run.
// (When both lengths are plain numbers the checker refuses the store; B's
// length here is known only to the run.)
// RUN-STOPS: value@11
DECLARE A : ARRAY[3] OF INTEGER
DECLARE N : INTEGER <- 5
DECLARE B : ARRAY[N] OF INTEGER
FOR I <- 0 TO 1
A <- B
NEXT I
ASSERT LENGTH(A) == 3
+10
View File
@@ -0,0 +1,10 @@
// X is a FLOAT that starts at the whole number 1. At the top of the loop the
// checker makes X an unknown of the sort its value had (a whole number), and
// X is 0.5 on the second pass.
// MUST-NOT-PROVE: assert@8
DECLARE X : FLOAT
X <- 1
FOR I <- 0 TO 2
ASSERT X <= 0.0 OR X >= 1.0
X <- X / 2
NEXT I
+23
View File
@@ -0,0 +1,23 @@
// The checker's own invariant guesses must be checked to a fixed point.
// Each pass shifts a value one variable further down a chain, so "F <= 0"
// survives the first four rounds of guessing and fails on the fifth. A
// checker that stopped guessing after four rounds assumed it, and proved
// the false ASSERT below.
// MUST-NOT-PROVE: assert@22
DECLARE A, B, C, D, E, F : INTEGER
A <- 0
B <- 0
C <- 0
D <- 0
E <- 0
F <- 0
FOR I <- 0 TO 10
F <- E
E <- D
D <- C
C <- B
B <- A
A <- A + 1
NEXT I
ASSERT F <= 0
OUTPUT F
+7
View File
@@ -0,0 +1,7 @@
// With USE IEEE a FLOAT can be NaN, and NaN == NaN is FALSE. The prover's
// rule that every number equals itself does not hold for NaN, so nothing in
// a program that says USE IEEE may be marked proved.
// MUST-NOT-PROVE: assert@7
USE IEEE
DECLARE X : FLOAT <- NAN()
ASSERT X == X
+12
View File
@@ -0,0 +1,12 @@
// Roll() gives a different number on each call. The checker treats a
// FUNCTION as a function of its arguments only, so Roll() == Roll().
// MUST-NOT-PROVE: assert@12
FUNCTION Roll() RETURNS INTEGER
RETURN RANDINT(1, 7)
ENDFUNCTION
DECLARE A : INTEGER
DECLARE B : INTEGER
A <- Roll()
B <- Roll()
ASSERT A == B
+5
View File
@@ -0,0 +1,5 @@
// INDEX_OF("", "") is 0, and the checker assumes -1 <= result < LENGTH("").
// MUST-NOT-PROVE: assert@5
DECLARE I : INTEGER
I <- INDEX_OF("", "")
ASSERT I == -1
+15
View File
@@ -0,0 +1,15 @@
// The same, with INPUT inside the FUNCTION.
// INPUT: 1
// INPUT: 2
// MUST-NOT-PROVE: assert@15
FUNCTION ReadOne() RETURNS INTEGER
DECLARE V : INTEGER
INPUT V
RETURN V
ENDFUNCTION
DECLARE A : INTEGER
DECLARE B : INTEGER
A <- ReadOne()
B <- ReadOne()
ASSERT A == B
+7
View File
@@ -0,0 +1,7 @@
// INPUT accepts a whole number past 2^53 - 1 (so do TO_INTEGER, FLOOR, CEIL,
// ROUND and INT), and MOD on it is computed in doubles: here N MOD 11 is 64.
// INPUT: -516719406483505152
// RUN-STOPS: overflow@6
DECLARE N : INTEGER
INPUT N
ASSERT N MOD 11 < 11
+7
View File
@@ -0,0 +1,7 @@
// INT8 holds -128 to 127. X + 1 for X = 127 is 128, which does not fit, so
// the run stops there. A rule that treated the sum as an exact whole number
// with no range would prove it fits without a REQUIRE to guarantee it.
// MUST-NOT-PROVE: overflow@6
FUNCTION Inc(X : INT8) RETURNS INT8
RETURN X + 1
ENDFUNCTION
+8
View File
@@ -0,0 +1,8 @@
// X * A + (X * 2 - X * A) is 2 * X. The checker adds the coefficients as
// doubles: A + 2 rounds to 2^53, minus A leaves 1, so it proves the sum is X.
// Every value in the run is below 2^53.
// INPUT: 1
// MUST-NOT-PROVE: assert@8
DECLARE X : INTEGER
INPUT X
ASSERT X * 9007199254740991 + (X * 2 - X * 9007199254740991) == X
+11
View File
@@ -0,0 +1,11 @@
// MAX(X, I) is typed FLOAT32 and holds the INTEGER 16777217, which no FLOAT32
// holds. The store into Y rounds it; the checker sees a FLOAT32 going into a
// FLOAT32 and keeps the value.
// MUST-NOT-PROVE: assert@11
DECLARE X : FLOAT32
DECLARE Y : FLOAT32
DECLARE I : INTEGER
X <- 1.0
I <- 16777217
Y <- MAX(X, I)
ASSERT Y == I
+19
View File
@@ -0,0 +1,19 @@
// Both ASSERTs with FORALL hold in a run. The ENSUREs of ISqrt(K) and Neg(K)
// are kept as facts about one free "K" (K >= 0 from the first, K < 0 from
// the second): a contradiction, so everything after is proved.
// MUST-NOT-PROVE: assert@19
FUNCTION ISqrt(N : INTEGER) RETURNS INTEGER
REQUIRE N >= 0
ENSURE RESULT >= 0 AND RESULT <= N
RETURN 0
ENDFUNCTION
FUNCTION Neg(N : INTEGER) RETURNS INTEGER
REQUIRE N < 0
ENSURE RESULT == 0 - N AND RESULT > 0
RETURN 0 - N
ENDFUNCTION
ASSERT FORALL K IN [0, 3) : ISqrt(K) >= 0
ASSERT FORALL K IN [-3, 0) : Neg(K) > 0
ASSERT 1 == 2
+6
View File
@@ -0,0 +1,6 @@
// RANDINT is drawn again for each K; the checker uses one unknown for every K,
// so 0 and 1 are both in S or both out.
// MUST-NOT-PROVE: assert@6
DECLARE S : SET OF INTEGER
S <- { K IN [0, 2) : RANDINT(0, 2) == 0 }
ASSERT (0 IN S) == (1 IN S)
+6
View File
@@ -0,0 +1,6 @@
// RAND(X) for a negative X gives a value in (X, 0], not [0, X).
// MUST-NOT-PROVE: assert@5
DECLARE R : FLOAT
R <- RAND(-1.0)
ASSERT R >= 0.0
OUTPUT R
+7
View File
@@ -0,0 +1,7 @@
// RAND(0.0) gives 0.0. A checker that assumed 0 <= R < 0.0 held a
// contradiction from here on, and proved anything, even 1 == 2.
// MUST-NOT-PROVE: assert@6
DECLARE R : FLOAT
R <- RAND(0.0)
ASSERT 1 == 2
OUTPUT R
+8
View File
@@ -0,0 +1,8 @@
// RANDINT(A, B) stops the program when [A, B) is empty.
// MUST-NOT-PROVE: argument@5
FUNCTION G(A : INTEGER) RETURNS INTEGER
DECLARE R : INTEGER
R <- RANDINT(A, 3)
RETURN R
ENDFUNCTION
OUTPUT G(5)
+7
View File
@@ -0,0 +1,7 @@
// RANDN() is a new random number on each call; the checker makes both the same term.
// MUST-NOT-PROVE: assert@7
DECLARE A : FLOAT
DECLARE B : FLOAT
A <- RANDN()
B <- RANDN()
ASSERT A == B
@@ -0,0 +1,10 @@
// A REPEAT loop's INVARIANT is checked once more after the last pass. The
// checker has no obligation for that check: "kept" covers only passes that repeat.
// MUST-NOT-PROVE: invariant-keep@7
DECLARE X : INTEGER
X <- 0
REPEAT
INVARIANT X == 0
X <- 1
UNTIL X == 1
OUTPUT X
+6
View File
@@ -0,0 +1,6 @@
// {1, 2.5} is typed SET OF INTEGER (the type of its first member), so X is
// an INTEGER that holds 2.5.
// MUST-NOT-PROVE: assert@5
FOR EACH X IN {1, 2.5}
ASSERT X <= 2 OR X >= 3
NEXT X
+16
View File
@@ -0,0 +1,16 @@
// X >= 0 is FALSE, so ISqrt is never called. The checker keeps ISqrt's
// ENSURE (0 <= RESULT <= X) as a fact anyway, and X >= 0 follows from it.
// INPUT: -1
// MUST-NOT-PROVE: assert@16
FUNCTION ISqrt(N : INTEGER) RETURNS INTEGER
REQUIRE N >= 0
ENSURE RESULT >= 0 AND RESULT <= N
RETURN 0
ENDFUNCTION
DECLARE X : INTEGER
INPUT X
IF X >= 0 AND ISqrt(X) > 2 THEN
OUTPUT "big"
ENDIF
ASSERT X >= 0
+13
View File
@@ -0,0 +1,13 @@
// B is FALSE, so X + 1 is never computed and X may be 127. The checker
// keeps "X + 1 fits INT8" as a fact anyway, and proves X <= 126 from it.
// INPUT: 127
// INPUT: FALSE
// MUST-NOT-PROVE: assert@13
DECLARE X : INT8
DECLARE B : BOOL
INPUT X
INPUT B
IF B AND X + 1 > 0 THEN
OUTPUT "positive"
ENDIF
ASSERT X <= 126
+10
View File
@@ -0,0 +1,10 @@
// SORTED of a two-dimensional ARRAY gives every value (6 here); the checker
// gives SORTED(A) the first length of A.
// MUST-NOT-PROVE: assert@10
DECLARE A : ARRAY[2, 3] OF INTEGER
FOR R <- 0 TO 2
FOR C <- 0 TO 3
A[R, C] <- R + C
NEXT C
NEXT R
ASSERT LENGTH(SORTED(A)) == 2
+10
View File
@@ -0,0 +1,10 @@
// STEP 1 + 1 moves I by 2. The checker advances a counter whose STEP is not
// a plain number by 1, and proves N == I kept.
// MUST-NOT-PROVE: invariant-keep@7
DECLARE N : INTEGER
N <- 0
FOR I <- 0 TO 10 STEP 1 + 1
INVARIANT N == I
N <- N + 1
NEXT I
OUTPUT N
+6
View File
@@ -0,0 +1,6 @@
// A FLOAT sum rounds at every step: 1E16 + 1.0 is 1E16. The checker extends
// SUM over [0, 3) from SUM over [0, 2) by exact addition.
// MUST-NOT-PROVE: assert@6
DECLARE L : LIST OF FLOAT
L <- [1E16, 0.0, 1.0]
ASSERT (SUM K IN [0, 3) : L[K]) > (SUM K IN [0, 2) : L[K])
+13
View File
@@ -0,0 +1,13 @@
// SUM is not checked for infinity either: two sums overflow to +inf and -inf,
// their SUM is NaN, and the run goes on with it. T == T is then FALSE.
// RUN-STOPS: overflow@10
DECLARE A : LIST OF FLOAT
DECLARE B : LIST OF FLOAT
DECLARE M : LIST OF FLOAT
DECLARE T : FLOAT
A <- [1E308, 1E308]
B <- [-1E308, -1E308]
APPEND(M, SUM K IN [0, 2) : A[K])
APPEND(M, SUM K IN [0, 2) : B[K])
T <- SUM K IN [0, 2) : M[K]
ASSERT T == T
+6
View File
@@ -0,0 +1,6 @@
// SUM adds whole numbers without the check + has: past 2^53 - 1 the total is
// no longer exact and the run goes on.
// RUN-STOPS: overflow@6
DECLARE L : LIST OF INTEGER
L <- [9007199254740991, 1, 1]
ASSERT (SUM K IN [0, 3) : L[K]) > (SUM K IN [0, 2) : L[K])