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

Add base case option to isodata :undefined parameter #1433

Merged
merged 7 commits into from Oct 3, 2022

Conversation

gjurgensen
Copy link
Member

This adds :base-case and :base-case-then as options to isodata's :undefined parameter. When either of these options are provided, isodata will choose the undefined value by looking for a base case within the newly generated function. A base case of a term may either be the whole term when the term does not include a recursive call, or if the term is an if, then it may be a base case of the then or else branch. A term may have several base cases; the :base-case option is biased toward selecting base cases in else branches, while :base-case-then is biased toward then branches.

The motivation for this feature is that a base-case will likely have a desirable type, and the result may be amenable to combining nested ifs.

@gjurgensen gjurgensen changed the title Add base case option to isodate :undefined parameter Add base case option to isodata :undefined parameter Sep 29, 2022
(local (include-book "kestrel/typed-lists-light/pseudo-term-listp" :dir :system))
(local (include-book "kestrel/typed-lists-light/symbol-listp" :dir :system))

(defthm pseudo-termp-of-if-condition
Copy link
Member

Choose a reason for hiding this comment

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

Can these three theorems be made local, so they do not affect the books that they include this tool directly or indirectly?

@@ -397,6 +397,15 @@
(xdoc::li
"@(':auto'), to use @('nil') or @('(mv nil ... nil)') for single-value
and multi-value functions respectively.")
(xdoc::li
"@(':base-case'), to search for a base-case within the domain of the new
Copy link
Member

Choose a reason for hiding this comment

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

I would make the two options more symmetric, i.e. :base-case-then and :base-case-else, also switching them in the two xdoc::lis (i.e. first describing :base-case-then, then :base-case-else briefly).

(symbol-listp fns)
(booleanp prefer-then))))
(b* (((unless (consp term)) (mv nil t nil))
((unless (eq 'if (ffn-symb term)))
Copy link
Member

Choose a reason for hiding this comment

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

It may be cleaner to have an explicit case/check for a quoted constant, between the previous check (for variables) and this check (where the use of ffn-symb suggests that we are in the case of a call term.

@gjurgensen
Copy link
Member Author

Thanks Alessandro, I made some updates. I had meant for the pseudo-termp theorems to be local originally; it was an oversight that they were not.

I also tried to improve the documentation of the find-a-base-case functions. Hopefully it is clearer now.

Copy link
Member

@acoglio acoglio left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@acoglio acoglio merged commit 9f65ba8 into acl2:testing-kestrel Oct 3, 2022
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.

None yet

2 participants