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

Explain the transformation rewrite attempts step by step #232

Open
sgraf812 opened this issue Jan 8, 2025 · 0 comments
Open

Explain the transformation rewrite attempts step by step #232

sgraf812 opened this issue Jan 8, 2025 · 0 comments
Labels
doc-request Request for missing documenation

Comments

@sgraf812
Copy link

sgraf812 commented Jan 8, 2025

What question should the reference manual answer?

How does the rewrite tactic proceed? Which steps would I perform if I were to do it manually?

Additional context

The improved error message "error: tactic 'rewrite' failed, motive is not type correct" is really helpful and contains the explanation I was looking for (reformatted for better presentation):

First, it looks for all 'a' in 'e'.
Second, it tries to abstract these occurrences of 'a' to create a function 'm := fun _a => ...', called the *motive*, with the property that 'm a' is definitionally equal to 'e'.
Third, we observe that 'congrArg' implies that 'm a = m b', which can be used with lemmas such as 'Eq.mpr' to change the goal.
However, if 'e' depends on specific properties of 'a', then the motive 'm' might not typecheck.

Possible solutions: 
* Use rewrite's 'occs' configuration option to limit which occurrences are rewritten.
* Use 'simp' or 'conv' mode, which have strategies for certain kinds of dependencies (these tactics can handle proofs and 'Decidable' instances whose types depend on the rewritten term, and 'simp' can apply user-defined '@[congr]' theorems as well).

Perhaps some of this wisdom could be added to the reference manual entry for rewrite. This improved entry could include the example from test case motiveNotTypeCorrect and perhaps exemplify the workarounds.

@sgraf812 sgraf812 added the doc-request Request for missing documenation label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-request Request for missing documenation
Projects
None yet
Development

No branches or pull requests

1 participant