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

[Z3Backend] Add support for enumerations containing argument-less constructors #202

Merged
merged 5 commits into from
Feb 18, 2022

Conversation

R1kM
Copy link
Collaborator

@R1kM R1kM commented Feb 17, 2022

This PR adds Z3 encoding support for elements of type TUnit, which are generated as arguments of enumeration constructors that do not have any argument in Catala.
Values of type unit are encoded to Z3 as a tuple with 0 elements.
The unit value and type are generated once and for all when initializing the global context for simplicity, since it should be the same everywhere.
Simple unit tests for absence of errors, presence of an empty error and presence of an exception overlap were also added to tests/test_proof

@denismerigoux denismerigoux added ✅ proof Proof backends: encoding, solving, etx. ✨ enhancement New feature or request 🔧 compiler Issue concerns the compiler labels Feb 17, 2022
@denismerigoux denismerigoux marked this pull request as draft February 17, 2022 18:15
@R1kM
Copy link
Collaborator Author

R1kM commented Feb 17, 2022

The addition of this functionality was leading to failures when trying to run the proof platform on examples/allocations_familiales/allocations_familiales.catala_fr. The root cause was that, when trying to retrieve a model for a function, print_model was using Model.get_const_interp, which apparently throws an (undocumented) exception when the corresponding Z3 declaration is not a constant expr but a function.
To avoid this error, I added the logic for correctly retrieving the Z3 model of a Catala function, and used Z3 built-ins facilities to print this model during counterexample generation. Pretty-printing these functions will be addressed in a future PR.

@R1kM R1kM marked this pull request as ready for review February 17, 2022 23:39
Copy link
Contributor

@denismerigoux denismerigoux left a comment

Choose a reason for hiding this comment

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

Looks perfect, I'm merging!

@denismerigoux denismerigoux merged commit 12b3155 into master Feb 18, 2022
@R1kM R1kM deleted the afromher_proof branch February 18, 2022 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request ✅ proof Proof backends: encoding, solving, etx.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants