Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Ordered constraint accumulation #1065

Closed
wants to merge 12 commits into from
Closed

Conversation

PetarMax
Copy link
Contributor

@PetarMax PetarMax commented Apr 5, 2024

Currently, CSubst constraints are always sorted when a new CSubst is created. However, when a KCFG is minimized and splits are lifted into other splits, this sorting results in a misordering of constraints and therefore a slightly poorer user experience when trying to debug the control flow. For example, even though the branchings constraints were chronologically C1, C2, C3, when the KCFG is minimized they could appear as C2, C3, C1.

This PR enables constraint order preservation and uses it when lifting split nodes.

@PetarMax PetarMax self-assigned this Apr 5, 2024
@PetarMax PetarMax added the enhancement New feature or request label Apr 5, 2024
@PetarMax PetarMax requested review from ehildenb and tothtamas28 April 5, 2024 09:18
@@ -752,6 +752,102 @@ def test_minimize_02() -> None:
assert contains_edge(cfg, 8, 6, 40, ('r1', 'r3'))


def test_split_constraint_accumulation() -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +100 to +101
if not maintain_order:
constraints = sorted(constraints, key=CTerm._constraint_sort_key)
Copy link
Collaborator

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?

Copy link
Member

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 for CTerm directly.

So in short, I agree with @tothtamas28 to not provide the option to have the constraints out of order.

Copy link
Contributor Author

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.

@Baltoli
Copy link
Contributor

Baltoli commented Apr 15, 2024

@Baltoli Baltoli closed this Apr 15, 2024
@Baltoli Baltoli deleted the petar/constraint-order branch April 15, 2024 09:09
PetarMax added a commit to runtimeverification/k that referenced this pull request Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants