Skip to content

Commit 73287c4

Browse files
Stevengreclaude
andcommitted
refactor(tests): distinguish -fail (program error) from -unsupported (missing semantics)
Rename 19 prove-rs test files from `-fail` to `-unsupported` to clarify that they fail because the semantics doesn't support the feature yet, not because the program itself is expected to fail. Revert unrelated K semantics changes (float support, priority annotations) to match origin/master. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0934224 commit 73287c4

43 files changed

Lines changed: 35 additions & 314 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

kmir/src/kmir/kdist/mir-semantics/intrinsics.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ error with `#AssertInhabitedFailure` if we see that following the intrinsic. Oth
6868
=> AssertInhabitedFailure
6969
...
7070
</k>
71-
[priority(100)]
7271
7372
rule <k> #execIntrinsic(IntrinsicFunction(symbol("assert_inhabited")), .Operands, _DEST, _SPAN)
7473
=> .K

kmir/src/kmir/kdist/mir-semantics/kmir.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ where the returned result should go.
434434
syntax KItem ::= #continueAt(MaybeBasicBlockIdx)
435435
rule <k> #continueAt(someBasicBlockIdx(TARGET)) => #execBlockIdx(TARGET) ... </k>
436436
rule <k> #continueAt(noBasicBlockIdx) => .K ... </k>
437-
[priority(50)]
438437
```
439438

440439
The local data has to be set up for the call, which requires information about the local variables of a call. This step is separate from the above call stack setup because it needs to retrieve the locals declaration from the body. Arguments to the call are `Operands` which refer to the old locals (`OLDLOCALS` below), and the data is either _copied_ into the new locals using `#setArgs`, or it needs to be _shared_ via references.

kmir/src/kmir/kdist/mir-semantics/lemmas/kmir-lemmas.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ power of two but the semantics will always operate with these particular ones.
163163
rule VAL &Int bitmask128 => VAL requires 0 <=Int VAL andBool VAL <=Int bitmask128 [simplification, preserves-definedness, smt-lemma]
164164
```
165165

166+
Shift operations like `wrapping_shl` mask the shift amount with `BITS - 1` (e.g., `rhs & 7` for `u8`).
167+
When the shift amount is already known to be less than `BITS`, the mask is a no-op.
168+
169+
```k
170+
rule VAL &Int 7 => VAL requires 0 <=Int VAL andBool VAL <Int 8 [simplification, preserves-definedness, smt-lemma]
171+
rule VAL &Int 15 => VAL requires 0 <=Int VAL andBool VAL <Int 16 [simplification, preserves-definedness, smt-lemma]
172+
rule VAL &Int 31 => VAL requires 0 <=Int VAL andBool VAL <Int 32 [simplification, preserves-definedness, smt-lemma]
173+
rule VAL &Int 63 => VAL requires 0 <=Int VAL andBool VAL <Int 64 [simplification, preserves-definedness, smt-lemma]
174+
rule VAL &Int 127 => VAL requires 0 <=Int VAL andBool VAL <Int 128 [simplification, preserves-definedness, smt-lemma]
175+
```
176+
166177
Repeated bit-masking can be simplified in an even more general way:
167178

168179
```k

kmir/src/kmir/kdist/mir-semantics/rt/data.md

Lines changed: 3 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,41 +1412,7 @@ Boolean values can also be cast to Integers (encoding `true` as `1`).
14121412
[preserves-definedness] // ensures #numTypeOf is defined
14131413
```
14141414

1415-
Casts involving `Float` values: `IntToFloat`, `FloatToInt`, and `FloatToFloat`.
1416-
1417-
```k
1418-
// IntToFloat: convert integer to float with the target float type's precision
1419-
rule <k> #cast(Integer(VAL, _WIDTH, _SIGNEDNESS), castKindIntToFloat, _, TY)
1420-
=> Float(
1421-
Int2Float(VAL,
1422-
#significandBits(#floatTypeOf(lookupTy(TY))),
1423-
#exponentBits(#floatTypeOf(lookupTy(TY)))),
1424-
#bitWidth(#floatTypeOf(lookupTy(TY)))
1425-
)
1426-
...
1427-
</k>
1428-
[preserves-definedness]
1429-
1430-
// FloatToInt: truncate float towards zero and convert to integer
1431-
rule <k> #cast(Float(VAL, _WIDTH), castKindFloatToInt, _, TY)
1432-
=> #intAsType(Float2Int(VAL), 128, #intTypeOf(lookupTy(TY)))
1433-
...
1434-
</k>
1435-
requires #isIntType(lookupTy(TY))
1436-
[preserves-definedness]
1437-
1438-
// FloatToFloat: round float to the target float type's precision
1439-
rule <k> #cast(Float(VAL, _WIDTH), castKindFloatToFloat, _, TY)
1440-
=> Float(
1441-
roundFloat(VAL,
1442-
#significandBits(#floatTypeOf(lookupTy(TY))),
1443-
#exponentBits(#floatTypeOf(lookupTy(TY)))),
1444-
#bitWidth(#floatTypeOf(lookupTy(TY)))
1445-
)
1446-
...
1447-
</k>
1448-
[preserves-definedness]
1449-
```
1415+
Casts involving `Float` values are currently not implemented.
14501416

14511417
### Casts between pointer types
14521418

@@ -2043,20 +2009,6 @@ are correct.
20432009
rule onInt(binOpRem, X, Y) => X %Int Y requires Y =/=Int 0 [preserves-definedness]
20442010
// operation undefined otherwise
20452011
2046-
// performs the given operation on IEEE 754 floats
2047-
// Note: Rust's float % is truncating remainder: x - trunc(x/y) * y
2048-
// This differs from K's %Float which is IEEE 754 remainder (round to nearest).
2049-
syntax Float ::= onFloat( BinOp, Float, Float ) [function]
2050-
// -------------------------------------------------------
2051-
rule onFloat(binOpAdd, X, Y) => X +Float Y [preserves-definedness]
2052-
rule onFloat(binOpAddUnchecked, X, Y) => X +Float Y [preserves-definedness]
2053-
rule onFloat(binOpSub, X, Y) => X -Float Y [preserves-definedness]
2054-
rule onFloat(binOpSubUnchecked, X, Y) => X -Float Y [preserves-definedness]
2055-
rule onFloat(binOpMul, X, Y) => X *Float Y [preserves-definedness]
2056-
rule onFloat(binOpMulUnchecked, X, Y) => X *Float Y [preserves-definedness]
2057-
rule onFloat(binOpDiv, X, Y) => X /Float Y [preserves-definedness]
2058-
rule onFloat(binOpRem, X, Y) => X -Float (Y *Float truncFloat(X /Float Y)) [preserves-definedness]
2059-
20602012
// error cases for isArithmetic(BOP):
20612013
// * arguments must be Numbers
20622014
@@ -2125,18 +2077,6 @@ are correct.
21252077
// infinite precision result must equal truncated result
21262078
andBool truncate(onInt(BOP, ARG1, ARG2), WIDTH, Unsigned) ==Int onInt(BOP, ARG1, ARG2)
21272079
[preserves-definedness]
2128-
2129-
// Float arithmetic: Rust never emits CheckedBinaryOp for floats (only BinaryOp),
2130-
// so the checked flag is always false here. See rustc_const_eval/src/interpret/operator.rs:
2131-
// binary_float_op returns a plain value, not a (value, overflow) pair.
2132-
rule #applyBinOp(
2133-
BOP,
2134-
Float(ARG1, WIDTH),
2135-
Float(ARG2, WIDTH),
2136-
false)
2137-
=> Float(onFloat(BOP, ARG1, ARG2), WIDTH)
2138-
requires isArithmetic(BOP)
2139-
[preserves-definedness]
21402080
```
21412081

21422082
#### Comparison operations
@@ -2173,14 +2113,6 @@ The argument types must be the same for all comparison operations, however this
21732113
rule cmpOpBool(binOpGe, X, Y) => cmpOpBool(binOpLe, Y, X)
21742114
rule cmpOpBool(binOpGt, X, Y) => cmpOpBool(binOpLt, Y, X)
21752115
2176-
syntax Bool ::= cmpOpFloat ( BinOp, Float, Float ) [function]
2177-
rule cmpOpFloat(binOpEq, X, Y) => X ==Float Y
2178-
rule cmpOpFloat(binOpLt, X, Y) => X <Float Y
2179-
rule cmpOpFloat(binOpLe, X, Y) => X <=Float Y
2180-
rule cmpOpFloat(binOpNe, X, Y) => X =/=Float Y
2181-
rule cmpOpFloat(binOpGe, X, Y) => X >=Float Y
2182-
rule cmpOpFloat(binOpGt, X, Y) => X >Float Y
2183-
21842116
// error cases for isComparison and binOpCmp:
21852117
// * arguments must be numbers or Bool
21862118
@@ -2208,19 +2140,9 @@ The argument types must be the same for all comparison operations, however this
22082140
BoolVal(cmpOpBool(OP, VAL1, VAL2))
22092141
requires isComparison(OP)
22102142
[priority(60), preserves-definedness] // OP known to be a comparison
2211-
2212-
rule #applyBinOp(OP, Float(VAL1, WIDTH), Float(VAL2, WIDTH), _)
2213-
=>
2214-
BoolVal(cmpOpFloat(OP, VAL1, VAL2))
2215-
requires isComparison(OP)
2216-
[preserves-definedness] // OP known to be a comparison
22172143
```
22182144

2219-
Types that are equivlance relations can implement [Eq](https://doc.rust-lang.org/std/cmp/trait.Eq.html),
2220-
and then they may implement [Ord](https://doc.rust-lang.org/std/cmp/trait.Ord.html) for a total ordering.
2221-
For types that implement `Ord` the `cmp` method must be implemented which can compare any two elements respective to their total ordering.
2222-
Here we provide the `binOpCmp` for `Bool` and `Int` operation which returns `-1`, `0`, or `+1` (the behaviour of Rust's `std::cmp::Ordering as i8`),
2223-
indicating `LE`, `EQ`, or `GT`.
2145+
The `binOpCmp` operation returns `-1`, `0`, or `+1` (the behaviour of Rust's `std::cmp::Ordering as i8`), indicating `LE`, `EQ`, or `GT`.
22242146

22252147
```k
22262148
syntax Int ::= cmpInt ( Int , Int ) [function , total]
@@ -2255,11 +2177,7 @@ The semantics of the operation in this case is to wrap around (with the given bi
22552177
...
22562178
</k>
22572179
2258-
rule <k> #applyUnOp(unOpNeg, Float(VAL, WIDTH))
2259-
=>
2260-
Float(--Float VAL, WIDTH)
2261-
...
2262-
</k>
2180+
// TODO add rule for Floats once they are supported.
22632181
```
22642182

22652183
The `unOpNot` operation works on boolean and integral values, with the usual semantics for booleans and a bitwise semantics for integral values (overflows cannot occur).

kmir/src/kmir/kdist/mir-semantics/rt/decoding.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,10 @@ and arrays (where layout is trivial).
5252
requires #isIntType(TYPEINFO) andBool lengthBytes(BYTES) ==Int #elemSize(TYPEINFO)
5353
[preserves-definedness]
5454
55-
// Float: handled in separate module for numeric operations
56-
rule #decodeValue(BYTES, TYPEINFO) => #decodeFloat(BYTES, #floatTypeOf(TYPEINFO))
57-
requires #isFloatType(TYPEINFO) andBool lengthBytes(BYTES) ==Int #elemSize(TYPEINFO)
58-
[preserves-definedness]
59-
6055
// TODO Char type
6156
// rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), typeInfoPrimitiveType(primTypeChar)) => typedValue(Str(...), TY, mutabilityNot)
57+
58+
// TODO Float decoding: not supported natively in K
6259
```
6360

6461

0 commit comments

Comments
 (0)