Skip to content

Add RecAddDefinition and AddDefinition #106

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caioraposo
Copy link

This commit adds support for defining functions (recursive or not) through defineFun and defineFunRec from the base API.

This commit adds support for defining functions (recursive or not)
through defineFun and defineFunRec from the base API.
@caioraposo
Copy link
Author

Marked as draft as the curent implementation doesn't work due to #93.

"""Define a new SMT recursive function with the given function declaration.
Replaces constants in `args` with bound variables.

>>> fact = Function('fact', IntSort(), IntSort())
Copy link
Contributor

Choose a reason for hiding this comment

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

According to Z3, a recursive function must be declared using RecFunction instead of Function. If you try to add a definition using RecAddDefinition to a function declared with Function, Z3 will trigger an error.

Copy link
Author

Choose a reason for hiding this comment

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

I had an implementation of RecFunction but it turned out exactly the same as Function. The reason for this distinction in z3 is because they have Z3_mk_func_decl and Z3_mk_rec_func_decl, here I believe we just need mkConst to declare a function, recursive or not.

Copy link
Author

Choose a reason for hiding this comment

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

I could add RecFunction to maintain compatibility, but do you think we should restrict the usage of RecAddDefinition like z3 does?

Copy link
Member

Choose a reason for hiding this comment

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

We have discussed this in the cvc5 team and the conclusion is:

  • we should support the same functionality that z3 does, so to have a RecFunction method
  • we can also have extra functionality, so it's OK to support the case where we use Function

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.

3 participants