You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: allow several tactics on types that are slightly less obviously Types (#3682)
Many tactics attempt to get the universe of the sort of the terms involved by matching on the level being a succ of something.
Unfortunately this fails on some nontrivial examples like mvpolynomial which can have type `Sort (max (u+1) (v+1))`
Instead we decrement the level manually after matching it.
See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60ring.60.20tactic.20cannot.20prove.20equality.20about.20.60MvPolynomial.60/near/352549549
This PR modifies ring, ring_nf, nontriviality, polyrith, linarith, and some norm_num handlers to appropriately handle this.
Test cases showing examples that failed before (inspired by the case of mvpolynomial, but in principle there could be other interesting types that have multiple universe parameters in this way, some of which may even have a linear order who knows).
In doing so we factor out `inferTypeQ'` into its own file `Mathlib.Tactic.Qq` for mathlib-relevant extensions of Qq
/-- Analogue of `inferTypeQ`, but that gets universe levels right for our application. -/
40
-
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Using.20.60QQ.60.20when.20you.20only.20have.20an.20.60Expr.60/near/303349037
41
-
definferTypeQ' (e : Expr) : MetaM ((u : Level) × (α : Q(Type $u)) × Q($α)) := do
Copyright (c) 2023 Scott Morrison. All rights reserved.
3
+
Released under Apache 2.0 license as described in the file LICENSE.
4
+
Authors: Scott Morrison, Alex J. Best
5
+
-/
6
+
import Qq
7
+
8
+
/-!
9
+
# Extra `Qq` helpers
10
+
11
+
This file contains some additional functions for using the quote4 library more conveniently.
12
+
-/
13
+
open Lean Elab Tactic Meta
14
+
15
+
namespace Qq
16
+
17
+
/-- Analogue of `inferTypeQ`, but that gets universe levels right for our application. -/
18
+
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Using.20.60QQ.60.20when.20you.20only.20have.20an.20.60Expr.60/near/303349037
19
+
definferTypeQ' (e : Expr) : MetaM ((u : Level) × (α : Q(Type $u)) × Q($α)) := do
20
+
let α ← inferType e
21
+
let .sort u ← instantiateMVars (← whnf (← inferType α)) | unreachable!
22
+
let some v := u.dec | throwError "not a type{indentExpr α}"
0 commit comments