Skip to content

Commit

Permalink
Further fine-tune Int2Bytes(Int, Endianness, Signedness) equations …
Browse files Browse the repository at this point in the history
…for booster (#4533)

The previous change #4522 was insufficient to make the equations usable
in `booster`. Matches with literal `Int` constants will still be
indeterminate, so this PR removes the literals from the rule LHSs.

* Use `0 ==Int I` instead of a syntactic _match_ in the equation for
argument `0`. This enables evaluating terms with `I ==Int 0` in the path
condition.
* Remove equation with literal `-1` and widen requires in equation for
negative arguments (previously `I <Int -1`, now `I <Int 0`). The result
is the same as before with no extra equation required.
  • Loading branch information
jberthold authored Jul 23, 2024
1 parent d10dd05 commit 3435a3c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions k-distribution/include/kframework/builtin/domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -2210,14 +2210,14 @@ module BYTES
imports BYTES-KORE
imports private INT
rule Int2Bytes(I::Int, _::Endianness, _) => .Bytes
requires I ==Int 0
rule Int2Bytes(I::Int, E::Endianness, Unsigned) => Int2Bytes((log2Int(I) +Int 8) /Int 8, I, E)
requires I >Int 0 [preserves-definedness]
rule Int2Bytes(0, _::Endianness, _) => .Bytes
rule Int2Bytes(I::Int, E::Endianness, Signed) => Int2Bytes((log2Int(I) +Int 9) /Int 8, I, E)
rule Int2Bytes(I::Int, E::Endianness, Signed ) => Int2Bytes((log2Int(I) +Int 9) /Int 8, I, E)
requires I >Int 0 [preserves-definedness]
rule Int2Bytes(I::Int, E::Endianness, Signed) => Int2Bytes((log2Int(~Int I) +Int 9) /Int 8, I, E)
requires I <Int -1 [preserves-definedness]
rule Int2Bytes(-1, E::Endianness, Signed) => Int2Bytes(1, -1, E)
rule Int2Bytes(I::Int, E::Endianness, Signed ) => Int2Bytes((log2Int(~Int I) +Int 9) /Int 8, I, E)
requires I <Int 0 [preserves-definedness]
endmodule
```

Expand Down

0 comments on commit 3435a3c

Please sign in to comment.