Skip to content

add internal Array theory, elaborate Set theory into it#688

Merged
nikivazou merged 23 commits into
ucsd-progsys:developfrom
clayrat:elab-set
May 16, 2024
Merged

add internal Array theory, elaborate Set theory into it#688
nikivazou merged 23 commits into
ucsd-progsys:developfrom
clayrat:elab-set

Conversation

@clayrat

@clayrat clayrat commented May 9, 2024

Copy link
Copy Markdown
Contributor

Fixes ucsd-progsys/liquidhaskell#2272 by elaborating Set operations into Array operations which are "internally" polymorphic in Z3.

Currently, this only touches Sets but presumably Maps also need to undergo the same treatment.

@clayrat

clayrat commented May 9, 2024

Copy link
Copy Markdown
Contributor Author

Performance charts (on LH test suite):

bot
top
filtered

@nikivazou nikivazou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me! But does it come with a relevant LH pull request to ensure that it does not break any tests?

-- | Theory Symbols ------------------------------------------------------------
--------------------------------------------------------------------------------

-- TODO drop all of Set and Map symbols when Map is handled through arrays

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this still TODO?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, as currently the Map theory is still done via monomorphizing and it has operations for converting to Sets, we can't yet remove the SMT-interacting parts for Maps+Sets. Once Maps are also converted, we can drop this code and only leave the Array theory to be written to SMT. These TODOs serve as a reminder of this.

, interpSym setSub sub setCmpSort
, interpSym setCom com setCmpSort
[
-- TODO we'll probably need two versions of these - one for sets and one for maps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still a TODO?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Once we start converting Maps, there are likely to be some design choices whether to try making Array theory more polymorphic, or simply have a second set of Array operations specialized for Sets. This TODO is a heads-up for this.

| SBool
| SReal
| SString
-- TODO remove these now that we use SArray directly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you now remove these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not yet, see above

@facundominguez

Copy link
Copy Markdown
Collaborator

by elaborating Set operations into Array operations which are "internally" polymorphic in Z3

Might require documentation: Does this PR narrow in some way the list of SMT solvers that LH/LF can work with?

@clayrat

clayrat commented May 14, 2024

Copy link
Copy Markdown
Contributor Author

Might require documentation: Does this PR narrow in some way the list of SMT solvers that LH/LF can work with?

This uses the same SMTLIBv2-compliant ArraysEx theory encoding as before, we're just now inlining the definitions so that the LF elaborator can produce local signatures instead of hardcoding all Sets to be Array Int Bool. So in theory all the solvers that support SMTLIBv2 should still keep working.

However, the concern that by now we're pretty much vendor-locked into Z3 is valid; I've tried running the .smt files produced by LF even before this PR through CVC5 and failed; investigating this is our next step (after converting the Map theory to use Arrays as well).

@clayrat

clayrat commented May 14, 2024

Copy link
Copy Markdown
Contributor Author

Looks good to me! But does it come with a relevant LH pull request to ensure that it does not break any tests?

The tests pass successfully after adapting LH to the develop branch: ucsd-progsys/liquidhaskell#2282

@nikivazou

Copy link
Copy Markdown
Member

@ranjitjhala we can merge this tomorrow (just checking it does not break flux or anything else)

@ranjitjhala

Copy link
Copy Markdown
Member

Yes please merge, thanks @nikivazou and @clayrat -- this is a really huge step!!!

@ranjitjhala

Copy link
Copy Markdown
Member

[I think its a big enough change to warrant a version number bump?]

@nikivazou

Copy link
Copy Markdown
Member

Alex wants to apply the same inlining for Maps (for uniformity) so we can change the version number after this pending edit.

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.

Set measures generate erroneous constraints when applied to non-polymorphic datatypes

4 participants