Skip to content

Commit

Permalink
Enable preserving-definedness atrribute for rules discovered during c…
Browse files Browse the repository at this point in the history
…eil analysis (#426)

Closes #424.

This is a fix for the ceil analysis introduced in #402. We successfully
infer definedness, but don't currently mark the rules as preserving
definedness correctly.

The added integration tests makes sure that a rule that contains a
partial function on the RHS (discovered to be preserving definedness
during the ceil analysis) will apply during execution.

---------

Co-authored-by: Jost Berthold <jost.berthold@runtimeverification.com>
Co-authored-by: rv-jenkins <admin@runtimeverification.com>
  • Loading branch information
3 people authored Dec 18, 2023
1 parent 9b87f1e commit ad46990
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 2 deletions.
7 changes: 6 additions & 1 deletion library/Booster/Definition/Ceil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ computeCeilRule mllvm def r@RewriteRule.RewriteRule{lhs, requires, rhs, attribut
, ceils = requiresCeils <> rhsCeils
, newRule =
if null requiresCeils && null rhsCeils
then Just r{RewriteRule.attributes = attributes{preserving = Flag True}}
then
Just
r
{ RewriteRule.attributes = attributes{preserving = Flag True}
, RewriteRule.computedAttributes = computedAttributes{notPreservesDefinednessReasons = []}
}
else -- we could add a case when ceils are fully resolved into predicates, which we would then
-- add to the requires clause of a rule
Nothing
Expand Down
2 changes: 1 addition & 1 deletion scripts/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for dir in $(ls -d test-*); do
SERVER=$BOOSTER_DEV ./runDirectoryTest.sh test-$name $@
SERVER=$KORE_RPC_BOOSTER ./runDirectoryTest.sh test-$name $@
;;
"no-evaluator")
"compute-ceil" | "no-evaluator")
SERVER=$BOOSTER_DEV ./runDirectoryTest.sh test-$name $@
;;
"foundry-bug-report")
Expand Down
9 changes: 9 additions & 0 deletions test/rpc-integration/resources/compute-ceil.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module COMPUTE-CEIL
imports INT
imports ID-SYNTAX

syntax Foo ::= g ( Int )

rule g ( N:Int ) => N %Int 5

endmodule
7 changes: 7 additions & 0 deletions test/rpc-integration/resources/compute-ceil.kompile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
echo "kompiling compute-ceil.k"
kompile --backend haskell compute-ceil.k
cp compute-ceil-kompiled/definition.kore compute-ceil.kore
rm -r compute-ceil-kompiled
kompile --llvm-kompile-type c -o compute-ceil-library compute-ceil.k
cp compute-ceil-library/interpreter.* ./compute-ceil.dylib
rm -r compute-ceil-library
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"reason": "aborted",
"depth": 1,
"state": {
"term": {
"format": "KORE",
"version": 1,
"term": {
"tag": "App",
"name": "Lbl'-LT-'generatedTop'-GT-'",
"sorts": [],
"args": [
{
"tag": "App",
"name": "Lbl'-LT-'k'-GT-'",
"sorts": [],
"args": [
{
"tag": "App",
"name": "kseq",
"sorts": [],
"args": [
{
"tag": "App",
"name": "inj",
"sorts": [
{
"tag": "SortApp",
"name": "SortInt",
"args": []
},
{
"tag": "SortApp",
"name": "SortKItem",
"args": []
}
],
"args": [
{
"tag": "DV",
"sort": {
"tag": "SortApp",
"name": "SortInt",
"args": []
},
"value": "2"
}
]
},
{
"tag": "App",
"name": "dotk",
"sorts": [],
"args": []
}
]
}
]
},
{
"tag": "App",
"name": "Lbl'-LT-'generatedCounter'-GT-'",
"sorts": [],
"args": [
{
"tag": "DV",
"sort": {
"tag": "SortApp",
"name": "SortInt",
"args": []
},
"value": "0"
}
]
}
]
}
}
}
}
}
81 changes: 81 additions & 0 deletions test/rpc-integration/test-compute-ceil/state-evaluate-g.execute
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"format": "KORE",
"version": 1,
"term": {
"tag": "App",
"name": "Lbl'-LT-'generatedTop'-GT-'",
"sorts": [],
"args": [
{
"tag": "App",
"name": "Lbl'-LT-'k'-GT-'",
"sorts": [],
"args": [
{
"tag": "App",
"name": "kseq",
"sorts": [],
"args": [
{
"tag": "App",
"name": "inj",
"sorts": [
{
"tag": "SortApp",
"name": "SortFoo",
"args": []
},
{
"tag": "SortApp",
"name": "SortKItem",
"args": []
}
],
"args": [
{
"tag": "App",
"name": "Lblg'LParUndsRParUnds'COMPUTE-CEIL'Unds'Foo'Unds'Int",
"sorts": [],
"args": [
{
"tag": "DV",
"sort": {
"tag": "SortApp",
"name": "SortInt",
"args": []
},
"value": "12"
}
]
}
]
},
{
"tag": "App",
"name": "dotk",
"sorts": [],
"args": []
}
]
}
]
},
{
"tag": "App",
"name": "Lbl'-LT-'generatedCounter'-GT-'",
"sorts": [],
"args": [
{
"tag": "DV",
"sort": {
"tag": "SortApp",
"name": "SortInt",
"args": []
},
"value": "0"
}
]
}
]
}
}

0 comments on commit ad46990

Please sign in to comment.