Skip to content

Commit

Permalink
Solve conflict between do-mode and term-mode assumeInstancesCommute
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner committed Jul 15, 2023
1 parent b7c3ebf commit c0d9516
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Qq/AssertInstancesCommute.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Qq.MetaM

namespace Qq

scoped syntax "assumeInstancesCommute" term : term
scoped syntax "assumeInstancesCommute'" term : term

namespace Impl
open Lean Meta Elab Term
Expand Down Expand Up @@ -51,14 +51,14 @@ elab_rules : term <= expectedType | `(assertInstancesCommuteImpl $cont) => do
expectedType
| none => elabTerm cont expectedType

elab_rules : term <= expectedType | `(assumeInstancesCommute $cont) => do
elab_rules : term <= expectedType | `(assumeInstancesCommute' $cont) => do
match ← findRedundantLocalInstQuoted? with
| some ⟨fvar, _, _, lhs, rhs⟩ =>
let n ← mkFreshUserName ((← fvar.getUserName).eraseMacroScopes.appendAfter "_eq")
let ty := q(QE $lhs $rhs)
elabTerm (← `(
have $(mkIdent n) : $(← exprToSyntax ty) := ⟨⟩
assumeInstancesCommute $cont))
assumeInstancesCommute' $cont))
expectedType
| none => elabTerm cont expectedType

Expand All @@ -70,7 +70,7 @@ macro_rules
syntax "assumeInstancesCommuteDummy" : term
macro_rules
| `(assert! assumeInstancesCommuteDummy; $cont) =>
`(assumeInstancesCommute $cont)
`(assumeInstancesCommute' $cont)

end Impl
open Impl
Expand Down
2 changes: 1 addition & 1 deletion examples/strengthenInstance.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def maybeReassocAlt {M : Q(Type $u)} (mul : Q(Mul $M)) (a b : Q($M)) :

def maybeReassocPure {M : Q(Type $u)} (mul : Q(Mul $M)) (a b : Q($M)) (semigroup : Q(Semigroup $M)) :
Q($a*($b*$b) = ($a*$b)*$b) :=
assumeInstancesCommute
assumeInstancesCommute'
q(by rw [mul_assoc])

0 comments on commit c0d9516

Please sign in to comment.