-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow interpolation of fvars, with a warning
- Loading branch information
1 parent
b7ff016
commit f95d85e
Showing
2 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Lean | ||
import Qq.Macro | ||
|
||
open Qq | ||
open Lean Meta Elab Tactic Command | ||
|
||
elab "iff_constructor" : tactic => do | ||
let mvarId ← getMainGoal | ||
let goalType ← getMainTarget | ||
|
||
let_expr Iff a b := goalType | ||
| throwError "Goal type is not of the form `a ↔ b`" | ||
|
||
let a : Q(Prop) := a | ||
let b : Q(Prop) := b | ||
|
||
let mvarId1 ← mkFreshExprMVar q($a → $b) (userName := `mp) | ||
let mvarId2 ← mkFreshExprMVar q($b → $a) (userName := `mpr) | ||
|
||
let mvarId1 : Q($a → $b) := mvarId1 | ||
let mvarId2 : Q($b → $a) := mvarId2 | ||
|
||
mvarId.assign q(@Iff.intro $a $b $mvarId1 $mvarId2) | ||
|
||
modify fun _ => { goals := [mvarId1.mvarId!, mvarId2.mvarId!] } | ||
|
||
example (p q : Prop) (h1 : p → q) (h2 : q → p) : p ↔ q := by | ||
iff_constructor | ||
|
||
case mp => assumption | ||
case mpr => assumption |