-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic defunctionalization for building rules in K (#4610)
Currently, when we are converting a summarized K definition to a module, we have only used it for then feeding that module into the Haskell backend, which does not have the restriction that the generated rules cannot have functions on the LHS of them. Now Pi2 wants to also feed those rules into the LLVM backend, so it's needed that we can defunctionalize the LHS of those rules. This PR achieves that by threading through the needed options to `cterm_build_rule` to defunctionalize the LHS of generated rules. In particular: - Some bugs in the imports of #4607 are fixed. Imports are made relative, and a circular import path is broken. - A routine `defunctionalize(KDefinition, KInner) -> tuple[Kinner, list[KInner]]` is added to `kast.manip`, which replaces functions in the supplied term with variables and returns also a list of constraints binding those variables to their original terms. - A unit test-harness, and many tests, are added of the `defunctionalize` routine. - An integration test of `cterm_build_rule` defunctionalization is added over the `simple_proofs.k` test harness. - The "functions" `.Map`, `.Set`, `.List`, and `.RangeMap` are added to the list of "not actually functions, more like constructors" for considering when deciding if something is a function or a constructor. This is exercised by the added test because `.Map` shows up, but is not defunctionalized. - `KCFG.edge.to_rule`, `cterm_build_rule`, and `build_rule` now take an optional `KDefinition`, and if it's supplied, will defunctionalize the LHS of generated rules that it makes. - The routine in `kast.manip` named `minimize_rule` is renamed to `minimize_rule_like`, to reflect better its type. - `KCFG.edge.to_rule` now takes an optional `minimize: bool` parameter, which if supplied will run the `minimize_rule_like` routine over the generated rule. --------- Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com>
- Loading branch information
1 parent
98f057e
commit 2fb4bf7
Showing
11 changed files
with
215 additions
and
25 deletions.
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
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
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
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
Oops, something went wrong.