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
Conversation
isodate
:undefined
parameterisodata
:undefined
parameter
(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 |
There was a problem hiding this comment.
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?
books/kestrel/apt/isodata-doc.lisp
Outdated
@@ -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 |
There was a problem hiding this comment.
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::li
s (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))) |
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
This adds
:base-case
and:base-case-then
as options toisodata
'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 anif
, then it may be a base case of thethen
orelse
branch. A term may have several base cases; the:base-case
option is biased toward selecting base cases inelse
branches, while:base-case-then
is biased towardthen
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
if
s.