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

Declaring/Defining functions #110

Open
bruderj15 opened this issue Sep 13, 2024 · 0 comments
Open

Declaring/Defining functions #110

bruderj15 opened this issue Sep 13, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@bruderj15
Copy link
Owner

Following #109 one may often use the Sum-Types to only use a small subset of Sort Int for example.

Consider a scheduling problem where one knows that some entities always have exactly one of n heights.
Surely one could do:

data Entity t = Entity { height :: Expr t, ... } deriving anyclass (Equatable, Variable)

isOneOf :: forall t f. (KnownSMTSort t, (Equatable (Expr t)) Foldable f) 
  => Expr t -> f (Expr t) -> Expr BoolSort
isOneOf x = exactly @t 1 . fmap (=== x) . toList

problem = do
  e <- variable @(Entity IntSort)
  assert $ height e `isOneOf` [1..10]

However this is significantly more expensive in problem-size and solver-performance than:

data Height = One | Two | ... | Ten
-- with #109 derive: Symbolic Height
data Entity t = Entity { height :: Symbolic Height, ... } 

One may then want to use arithmetics with that and other expressions, so we need to convert:

sconvert :: Symbolic Height -> Expr IntSort

This conversion is obviously symbolic, so we need to (define-fun ...) in SMTLib.

This is easy as in hgoes/smtlib2.
However, the types there are ugly and not lightweight at all.

We can do better!

@bruderj15 bruderj15 added the enhancement New feature or request label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant