-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow including lemmas dynamically into APRProver #4681
base: develop
Are you sure you want to change the base?
Conversation
…a functional rule
…s clause translation for functional rule
…ication rules to konvert
…unctional rules to translate
… tests to working version
…n concrete/symbolic attribute too
@@ -198,45 +218,105 @@ def _inject(definition: KDefinition, term: KInner, sort: KSort) -> KInner: | |||
|
|||
# 'krule' should have sorts on variables | |||
def krule_to_kore(definition: KDefinition, krule: KRule) -> Axiom: | |||
|
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.
@@ -102,15 +102,15 @@ def fun(term: KInner) -> KInner: | |||
return fun | |||
|
|||
|
|||
def bool_to_ml_pred(kast: KInner) -> KInner: | |||
def bool_to_ml_pred(kast: KInner, sort: str | KSort = GENERATED_TOP_CELL) -> KInner: | |||
def _bool_constraint_to_ml(_kast: KInner) -> KInner: | |||
if _kast == TRUE: | |||
return mlTop() |
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.
return mlTop() | |
return mlTop(sort=sort) |
@cached_property | ||
def function_labels(self) -> tuple[str, ...]: | ||
"""Returns the label names of all the `KProduction` which are function symbols for all modules in this definition.""" | ||
return tuple(func.klabel.name for func in self.functions if func.klabel is not None) |
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.
I don't think there's a function symbol without a klabel
, consider asserting instead.
|
||
axiom_vars: tuple[SortVar, ...] = () | ||
kore_axiom: Pattern | ||
if not is_functional: |
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.
Consider extracting two helpers: one for the functional case, one for a normal rewrite.
@@ -249,6 +329,25 @@ def kflatmodule_to_kore(definition: KDefinition, kflatmodule: KFlatModule) -> Mo | |||
return Module(name=kflatmodule.name, sentences=(imports + kore_axioms)) | |||
|
|||
|
|||
def _krule_att_to_kore(att_entry: AttEntry, kast_rule_vars: dict[str, list[KVariable]]) -> App: |
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.
There's similar logic in _module_to_kore
, maybe it's possible to extract that into it's own module and reuse it here.
@@ -255,19 +255,19 @@ def prove_claim( | |||
depth=depth, | |||
) | |||
|
|||
def get_claim_modules( | |||
def parse_modules( |
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.
Is the module parser exposed by kprove
general enough to parse an arbitrary module?
In order to include lemmas dynamically in the Kontrol prover, we need an option for passing the extra module into the
APRProver
so that it can be fed into the booster'sadd-module
endpoint. This also requires being able to translate functional rules to Kore in pyk usingkrule_to_kore
. This PR:extra_module
parameter to theAPRProver
initialization, which allows passing a new module with lemmas into the prover at initialization time. It will pass this module on to theadd-module
endpoint and make sure it's used on all future requests.symbolic
andsmt-lemma
attributes to the list of attributes recognized by pyk.KProve.get_claims_modules
toKProve.parse_modules
, and renames some of its parameters.bool_to_ml_pred
for converting boolean predicates to matching logic ones._krule_to_kore
to make it support translating some functional/simplification rules to Kore which were not supported before (and adds tests):_krule_att_to_kore
method for converting attributes ofKRule
to kore.krule_to_kore
(eg. handleowise => priority(200)
andsimplification
vspriority
).axiom
to differentiate between semantic and functional rules, and to convert functional rules as matching-logicimplies
axioms.