This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Ordered constraint accumulation #1065
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a7ca751
ordered constraint accumulation
PetarMax 9a9b3ad
Merge a7ca75103a775d2d06fcf3938e3956e2b120e0e2 into 3afe4ca78f993078e…
PetarMax 2022ffa
Set Version: 0.1.775
8809a10
Merge branch 'master' into petar/constraint-order
PetarMax 2e900de
Merge 8809a107245a66a2a5a067054cd4aac60d8945ce into 7ee5e70ee7745d5f6…
PetarMax c228e77
Set Version: 0.1.776
f34e06b
Merge branch 'master' into petar/constraint-order
PetarMax f9e81c3
Merge f34e06bcbf1f06e1afc857d1fb3f669831b85cd7 into be4edd60c39959e6d…
PetarMax 10bbc50
Set Version: 0.1.778
f41254e
Merge branch 'master' into petar/constraint-order
PetarMax 3d5385e
Merge f41254ee86ffa88aaf05d87a5fd972d8fde29d75 into 68bffc5ed0994d2c4…
PetarMax 534d9da
Set Version: 0.1.780
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.779 | ||
0.1.780 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "pyk" | ||
version = "0.1.779" | ||
version = "0.1.780" | ||
description = "" | ||
authors = [ | ||
"Runtime Verification, Inc. <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -752,6 +752,102 @@ def test_minimize_02() -> None: | |
assert contains_edge(cfg, 8, 6, 40, ('r1', 'r3')) | ||
|
||
|
||
def test_split_constraint_accumulation() -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
def x_ge(n: int) -> KApply: | ||
return mlEqualsTrue(geInt(KVariable('X'), intToken(n))) | ||
|
||
def x_lt(n: int) -> KApply: | ||
return mlEqualsTrue(ltInt(KVariable('X'), intToken(n))) | ||
|
||
d = { | ||
'next': 16, | ||
'nodes': node_dicts(15, config=x_config()), | ||
'edges': edge_dicts(), | ||
'splits': split_dicts( | ||
(1, [(2, x_ge(0)), (3, x_lt(0))]), | ||
(2, [(4, x_ge(32)), (5, x_lt(32))]), | ||
(3, [(6, x_ge(-32)), (7, x_lt(-32))]), | ||
(4, [(8, x_ge(64)), (9, x_lt(64))]), | ||
(5, [(10, x_ge(16)), (11, x_lt(16))]), | ||
(6, [(12, x_ge(-16)), (13, x_lt(-16))]), | ||
(7, [(14, x_ge(-64)), (15, x_lt(-64))]), | ||
csubst=x_subst(), | ||
), | ||
} | ||
cfg = KCFG.from_dict(d) | ||
propagate_split_constraints(cfg) | ||
|
||
cfg.minimize() | ||
|
||
kcfg_show = KCFGShow(MockKPrint(), node_printer=NodePrinter(MockKPrint())) | ||
actual = '\n'.join(kcfg_show.pretty(cfg)) + '\n' | ||
|
||
expected = ( | ||
'\n' | ||
'┌─ 1 (root, split)\n' | ||
'┃\n' | ||
'┃ (branch)\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _>=Int_ ( X , 0 )\n' | ||
'┃ ┃ _>=Int_ ( X , 32 )\n' | ||
'┃ ┃ _>=Int_ ( X , 64 )\n' | ||
'┃ │\n' | ||
'┃ └─ 8 (leaf)\n' | ||
'┃\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _>=Int_ ( X , 0 )\n' | ||
'┃ ┃ _>=Int_ ( X , 32 )\n' | ||
'┃ ┃ _<Int_ ( X , 64 )\n' | ||
'┃ │\n' | ||
'┃ └─ 9 (leaf)\n' | ||
'┃\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _>=Int_ ( X , 0 )\n' | ||
'┃ ┃ _<Int_ ( X , 32 )\n' | ||
'┃ ┃ _>=Int_ ( X , 16 )\n' | ||
'┃ │\n' | ||
'┃ └─ 10 (leaf)\n' | ||
'┃\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _>=Int_ ( X , 0 )\n' | ||
'┃ ┃ _<Int_ ( X , 32 )\n' | ||
'┃ ┃ _<Int_ ( X , 16 )\n' | ||
'┃ │\n' | ||
'┃ └─ 11 (leaf)\n' | ||
'┃\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _<Int_ ( X , 0 )\n' | ||
'┃ ┃ _>=Int_ ( X , -32 )\n' | ||
'┃ ┃ _>=Int_ ( X , -16 )\n' | ||
'┃ │\n' | ||
'┃ └─ 12 (leaf)\n' | ||
'┃\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _<Int_ ( X , 0 )\n' | ||
'┃ ┃ _>=Int_ ( X , -32 )\n' | ||
'┃ ┃ _<Int_ ( X , -16 )\n' | ||
'┃ │\n' | ||
'┃ └─ 13 (leaf)\n' | ||
'┃\n' | ||
'┣━━┓ constraints:\n' | ||
'┃ ┃ _<Int_ ( X , 0 )\n' | ||
'┃ ┃ _<Int_ ( X , -32 )\n' | ||
'┃ ┃ _>=Int_ ( X , -64 )\n' | ||
'┃ │\n' | ||
'┃ └─ 14 (leaf)\n' | ||
'┃\n' | ||
'┗━━┓ constraints:\n' | ||
' ┃ _<Int_ ( X , 0 )\n' | ||
' ┃ _<Int_ ( X , -32 )\n' | ||
' ┃ _<Int_ ( X , -64 )\n' | ||
' │\n' | ||
' └─ 15 (leaf)\n' | ||
'\n' | ||
) | ||
|
||
assert actual == expected | ||
|
||
|
||
def test_split_csubsts() -> None: | ||
cfg = KCFG() | ||
cfg.create_node(term(11)) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, sorting of constraints was important for the old KSummarizer where we compared nodes for equality a lot. I think it should be fine to just drop sorting without introducing an additional parameter, after testing it on
kontrol
.@ehildenb, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think there are still some places where we could be comparing equality of
CTerm
without considering different constraint ordering. So I wolud drop the parameter, not sort them by default, and then test with Kontrol. If there are no problems, good to merge. Otherwise, maybe we need to implement explicit equality operator forCTerm
directly.So in short, I agree with @tothtamas28 to not provide the option to have the constraints out of order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you, I will co-ordinate with @Baltoli and make the changes once the PR has been moved to the new setting of
pyk
.