forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: have
simpa ... using ...
do exact
-like checks
Closes leanprover#5634. Before assigning the `using` clause expression to the goal, this adds a check that the expression has no new metavariables. It also admits the goal when we report new metavariables since asserting the term as a new hypothesis causes it to be linked to pre-existing goals, leading to "don't know how to synthesize placeholder" errors for them. We also throw in an occurs check immediately after elaboration to avoid some counterintuitive behavior with simp.
- Loading branch information
Showing
3 changed files
with
79 additions
and
12 deletions.
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
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
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,54 @@ | ||
/-! | ||
# Make sure `simpa` checks for metavariables in `using` clause | ||
https://github.com/leanprover/lean4/issues/5634 | ||
-/ | ||
|
||
/-! | ||
This used to have a "don't know how to synthesize placeholder" error on the `have` line too. | ||
This is because `have` is `refine_lift have ...; ?_`, so it indeed had a placeholder. | ||
-/ | ||
/-- | ||
error: don't know how to synthesize placeholder for argument 'a' | ||
context: | ||
htrue : True | ||
⊢ False | ||
-/ | ||
#guard_msgs in | ||
example : False := by | ||
have htrue : True := trivial | ||
simpa using id _ | ||
|
||
/-! | ||
Simplified version of the test. | ||
-/ | ||
/-- | ||
error: don't know how to synthesize placeholder for argument 'a' | ||
context: | ||
⊢ False | ||
-/ | ||
#guard_msgs in | ||
example : False := by | ||
refine ?_ | ||
simpa using id ?_ | ||
|
||
/-! | ||
Verifying that unassigned metavariables are OK, so long as they come from before elaboring the `using` clause. | ||
-/ | ||
example (p : Prop) (h : p) : p := by | ||
have : ?a := ?b | ||
simpa using ?b | ||
exact h | ||
|
||
/-! | ||
Occurs check | ||
-/ | ||
/-- | ||
error: occurs check failed, expression | ||
?foo | ||
contains the goal ?foo | ||
-/ | ||
#guard_msgs in | ||
example : False := by | ||
refine ?foo | ||
simpa using ?foo |