-
Notifications
You must be signed in to change notification settings - Fork 34
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
Enriched and unified syntax for reduction strategies #85
Open
herbelin
wants to merge
1
commit into
coq:master
Choose a base branch
from
herbelin:unified-reduction-strategies
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
- Title: A unified view at reduction strategies with extended unfolding control | ||
|
||
- Drivers: Hugo Herbelin | ||
|
||
---- | ||
|
||
# Summary and motivation | ||
|
||
Each user-level, compilation-free, reduction strategy of Coq, `simpl`, | ||
`cbn`, `cbv`, `lazy`, come, in addition to a reduction order | ||
(call-by-name, call-by-value, call-by-need), with its own | ||
specificities, such as: | ||
|
||
- refolding (co)fixpoints (in `simpl` and `cbn`) | ||
- local specification of the kind of reduction to consider (`cbn`, `cbv`, `lazy`) | ||
- specification of a subterm to reduce (`simpl pattern`) | ||
- some static parameterization of the unfolding (argument flags `simpl never`, `simpl nonmeta`, `!`, `/`) | ||
|
||
The proposal is to go in the direction of one unified entry point to | ||
reduction strategies eventually supporting all combinations of the | ||
features currently provided only by one or the other entry point, thus | ||
gaining both in expressiveness and easiness to document. At the | ||
current time, the focus is however only on a unified syntax. | ||
|
||
Additionally, the proposal is intended to complement CEP coq/ceps#35 | ||
(more fine-tuning of reduction) and CEP coq/ceps#84 (support for | ||
symbol sets, hereafter called unfol bases). | ||
|
||
# Detailed design | ||
|
||
We propose to elaborate a unified syntax for all four mentioned user-level reduction strategies on top of the following: | ||
|
||
```text | ||
red_expr ::= red_name pattern_opt flags_opt | ||
red_name ::= "cbv" | "cbn" | "lazy" | "simpl" | ||
pattern ::= CONSTR | ||
flags ::= "with" head_flag_opt flag_list unfold_bases | ||
head_flag ::= "head" | ||
flag ::= "beta" | "iota" | "zeta" | "match" | "fix" | "cofix" | "delta" | ||
unfold_bases ::= "+" unfold_base signed_unfold_base_list | signed_unfold_base_list | ||
signed_unfold_base ::= unfold_base | "-" unfold_base | ||
unfold_base ::= "[" QUALID_list "]" | IDENT constraint_opt | "module" "(" QUALID ")" | ||
constraint ::= "(" op INT ")" | ||
op ::= "<" | ">" | "<=" | ">=" | ||
``` | ||
where: | ||
- `pattern` would work as it does currently in `simpl pattern` | ||
- the use of `with` is reminiscent of the `with hintbase` of `auto`, `autorewrite`, `autounfold`, `firstorder`, ... | ||
- `red_name with ...` can be abbreviated into `red_name ...` for consistency with the current syntax of `cbn`, `cbv`, `lazy` | ||
- `- unfold_base` would mean subtracting the given unfold_base to what has been computed so far | ||
- `unfold_base` in `signed_unfold_base` would mean adding to what has been computed so far | ||
- `+ unfold_base signed_unfold_base_list` would mean starting from the current transparency state, adding `unfold_base`, and continuing with `signed_unfold_base_list` | ||
- `[ QUALID_list ]` would refers to a list of names controlling the reduction, be as it is now | ||
- `IDENT` would refer to an unfolding database (see CEP coq/ceps#84 about how to build such databases) | ||
- `module(QUALID)` would mean to include constants from module `QUALID` | ||
- one could add a variant of `module(QUALID)` for recursive inclusion | ||
- `constraint` would select a subset of the bases depending on the level of the hint | ||
- the list of names in `QUALID_list` could include constructors, e.g. `None` to reduce `match` only on constructor `None` | ||
- then, current flag `match` could be seen as an alias for declaring all constructors "unfoldable" | ||
- `iota` would remain an alias for `match` + `fix` + `cofix` | ||
- if both `delta` and bases are given, `delta` should be last in the list of flags | ||
|
||
Note: in a world where all fixpoint and cofixpoints are globally | ||
named, the trigerring of `iota` could thus be mostly controlled by | ||
giving or not the names of the relevant fixpoint, cofixpoints, | ||
projections, constructors. | ||
|
||
Note: we could also try to unify the syntax `[ QUALID_list ]` with the | ||
`using QUALID_list` clause of `auto` and `firstorder`. | ||
|
||
# Implementation issues | ||
|
||
The implementation work at this stage would be mostly at the parsing level or database management level: | ||
- a generic `pattern` combinator is already implemented (`contextually`), it is just a matter of encapsulating all reduction strategies with it | ||
- for database management, see CEP coq/ceps#84 | ||
|
||
# Unresolved questions | ||
|
||
We would probably expect all reduction strategies to eventually do **refolding**? This refolding could be `simpl`-style (maximal refolding) or to just the surrounding name of the global (co)fixpoints. | ||
|
||
We would probably expect all reduction strategies to eventually support different **unfolding policies** (exposing `match`, supporting reduction of nested `match`/`fix`, supporting reduction of match-free constant which "simplify" the term in some sense). | ||
|
||
Would a **level**, like in `with_strategy level [...]` be useful? |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why is head_flag separate? Is there something wrong with writing eg
with beta head
?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 don't remember if there was a technical reason or just because I was thinking at
head
as a modifier of a different nature than the flags.