runtimeverification / haskell-backend

The symbolic execution engine powering the K Framework
BSD 3-Clause "New" or "Revised" License
209 stars 41 forks source link

[K-Improvement] Add `preserves-definedness` attribute for semantic rules #3373

Open ana-pantilie opened 2 years ago

ana-pantilie commented 2 years ago

@ehildenb suggested a while ago we try https://github.com/runtimeverification/haskell-backend/issues/3175, and after the discussion here it looks like it's the way to go, especially for semantics which contain large maps/sets.

I think we need to do the following:

I've been thinking what the best way to integrate kore-rule-definedness and the frontend would be, and I think that kore-rule-definedness should be part of the kore-rpc-server. The reason is that this way we can avoid having to re-load the definition in the backend every call. kompile could spawn a kore server and run the command for every rule in definition, and add the appropriate information to each rule. Thoughts?

ehildenb commented 2 years ago

I think the first pass should just be the frontend inserting th edefinedness check @ana-pantilie , so that we don't have to worry about intergrating a new tool. That first version can be very simple, just "is the RHS all constructors and total functions, and there are no set variablse, then #Ceil(RHS) is #Top". If that is provable, that's a very quick frontend pass and we can see how much that improves performance before doing something more complicated which involves invoking the backend.

That also allows us to enable this preserves-definedness attribute much quicker, while the backend can work on a more advanced checker (if it's needed after profiling with the simple one in the frontend).

ana-pantilie commented 2 years ago

@ehildenb alright, let's give that a try.

@radumereuta How hard would it be to write a check like that? Like Everett said, if a semantic/rewrite rule has a RHS term which only contains constructors, functional symbols and element variables the frontend should add the preserves-definedness attribute to the rule.

radumereuta commented 2 years ago

With this visitor should be straightforward, but I imagine it would take a while until we manage to iron out all the kinks.

radumereuta commented 1 year ago

Front-end draft PR for first stage. Changes to the backend.

radumereuta commented 1 year ago

Related: https://github.com/runtimeverification/k/issues/1938 We can apply this idea for simplification rules as well.

ehildenb commented 1 year ago

Blocked on https://github.com/runtimeverification/haskell-backend/issues/3799 for now.