Skip to content

Commit

Permalink
Add bitvector version of L₈ test_sum_Gauss
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed May 3, 2024
1 parent 965f25d commit ab5bb29
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/SpriteLang-Tests/TBitVectorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,61 @@ TBitVectorTest >> test_09p [
};
'
]

{ #category : #tests }
TBitVectorTest >> test_sum_Gauss_BVn [
self proveUnsafe: '
[--check-termination]
⟦reflect sum : n:bv8 => bv8 / [n]⟧
let rec sum = (n) => {
let base = n == bv8(0);
if (base) {
bv8(0)
} else {
let n1 = bvsub8(n,bv8(2));
let t1 = sum(n1);
bvadd8(n,t1)
}
};
⟦val thm_sum : n:bv8 => bv8[w| 2///8*(sum value: n) === (n+1 * n)] / [n]⟧
let rec thm_sum = (n) => {
let base = n == bv8(0);
if (base) {
bv8(0)
} else {
let n1 = bvsub8(n,bv8(1));
thm_sum(n1)
}
};
'
]

{ #category : #tests }
TBitVectorTest >> test_sum_Gauss_BVp [
self proveSafe: '
[--check-termination]
⟦reflect sum : n:bv8 => bv8 / [n]⟧
let rec sum = (n) => {
let base = n == bv8(0);
if (base) {
bv8(0)
} else {
let n1 = bvsub8(n,bv8(1));
let t1 = sum(n1);
bvadd8(n,t1)
}
};
⟦val thm_sum : n:bv8 => bv8[w| 2///8*(sum value: n) === (n+1 * n)] / [n]⟧
let rec thm_sum = (n) => {
let base = n == bv8(0);
if (base) {
bv8(0)
} else {
let n1 = bvsub8(n,bv8(1));
thm_sum(n1)
}
};
'
]

0 comments on commit ab5bb29

Please sign in to comment.