Skip to content
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

Types specifying the simplify-implication RPC endpoint #3614

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

geo2a
Copy link
Collaborator

@geo2a geo2a commented Jun 29, 2023

This PR modifies kore-rpc-types to include types that specify the new simplify-implication RPC endpoint. Based on the specification in #3787.

Note that the CI fails due to Z3 starvation, which is unrelated to these changes.

@geo2a geo2a force-pushed the rpc-simplify-implication branch 3 times, most recently from 9d6acef to 3f22ee1 Compare August 9, 2023 09:00
@ehildenb
Copy link
Member

ehildenb commented Aug 9, 2023

We need a testing harness! Let's make it easy from the start to test these functionalities.

@goodlyrottenapple
Copy link
Member

@geo2a can you add a simple test to test/rpc-server which exercises the endpoint as @ehildenb suggests? doesn't have to simplify anything, literally just return the same pattern for now...

@geo2a
Copy link
Collaborator Author

geo2a commented Aug 10, 2023

@ehildenb @goodlyrottenapple I've added a stub implementation into kore-rpc and an integration tests.

I've also extended the RPC API docs. @ehildenb please have a look at the shape of the responses and advise on how we should format them so pyk is happy. Probably the Haskell-style CamelCase tags are not OK, but I'm reluctant to invent another format before I get feedback from you.

deriving stock (Generic, Show, Eq)
deriving
(FromJSON, ToJSON)
via CustomJSON '[] ImplicationValidityResult
Copy link
Member

Choose a reason for hiding this comment

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

could use the same via CustomJSON '[FieldLabelModifier '[CamelToKebab]] as above. I think this is the naming convention in pyk?

Copy link
Member

@goodlyrottenapple goodlyrottenapple left a comment

Choose a reason for hiding this comment

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

LGTM @ehildenb @tothtamas28 please let us know if there are any tweaks to the responses you would like

Comment on lines +439 to +454
#### Implication **invalid**: terms do not match

Matching between antecedent and consequent configurations failed (different constructors, shared variables, sort error, etc.), constraints has not been subsumption been attempted. No matching substitution is returned.

```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"validity": {"tag": "implication-valid",
"contents": {"tag": "matching-failed",
"contents": "Shared variables: X:SortWordStack{}"
}},
}
}
```
Copy link
Member

Choose a reason for hiding this comment

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

The result here should be "unification-failed", and that's what we should be checking. Eventually, if unification succeeds and matching fails, we want ot return an core problem which may or may not be unsat, that the user can then forward to the more powerful implies endpoint.

Just want to make sure that when we get this response back, what it actually means is there is absolutely no overlap between the terms, we know because we found differing constructors.

"jsonrpc": "2.0",
"id": 1,
"result": {
"validity": {"tag": "implication-valid",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"validity": {"tag": "implication-valid",
"validity": {"tag": "implication-invalid",

I think this should likely actually just be unknown result actually, but we return the unsat core (the constarints we arent' sure about).

Comment on lines +493 to +510
#### Implication **unknown**: constraint subsumption indeterminate

If matching is successful, but the constraint solver procedure (internal, or the SMT solver if enabled) returned "unknown". Response contains the matching substitution and the unknown core of constraints.

```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"validity": {"tag": "implication-unknown",
"contents": {"tag": "constraint-subsumption-unknown",
"contents": {"tag": "constraint-subsumption-failed",
"contents": {"format": "KORE", "version": 1, "term": {}}
}},
"substitution": {"format": "KORE", "version": 1, "term": {}},
}
}
```
Copy link
Member

Choose a reason for hiding this comment

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

How is this different than "Implication invalid: terms match, but constraints subsumption failed"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought, we'd want to have a tri-state constraint subsumption check, just like we have a tri-stat matching routine. But perhaps we can indeed expose the "failed" and "unknown" constraint subsumption as just "failed" and have less user-facing cases.

Copy link
Member

Choose a reason for hiding this comment

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

Part of the confusion for me is that for the failure cases, you're using "terms don't match" as the criteria, but that's not how the tri-state matching algorithm works. It either reports back:

  • Terms match with substitution alpha.
  • Terms definitely don't unify.
  • Unknown.

The key here is that unification and matching are different algorithms, different complexities, and different properties. Saying a term matches another means it's completely subsumed, and saying that they don't unify means they have no overlap.

So I guess the language here needs to be cleared up, because here for example
image
we're saying "terms don't match" because of differing constructor, where I think it should be saying "terms don't unify".

Unification and matching are not interchangeable. See https://github.com/runtimeverification/hs-backend-booster/issues/193 again for the desired interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants