diff --git a/src/Init/Grind/Ring/Envelope.lean b/src/Init/Grind/Ring/Envelope.lean index b93b17551c..2ad8b2e3fa 100644 --- a/src/Init/Grind/Ring/Envelope.lean +++ b/src/Init/Grind/Ring/Envelope.lean @@ -330,7 +330,7 @@ theorem toQ_inj [AddRightCancel α] {a b : α} : toQ a = toQ b → a = b := by obtain ⟨k, h₁⟩ := h₁ exact AddRightCancel.add_right_cancel a b k h₁ -instance [Semiring α] [AddRightCancel α] [NoNatZeroDivisors α] : NoNatZeroDivisors (OfSemiring.Q α) where +instance (priority := high) [Semiring α] [AddRightCancel α] [NoNatZeroDivisors α] : NoNatZeroDivisors (OfSemiring.Q α) where no_nat_zero_divisors := by intro k a b h₁ h₂ replace h₂ : mul (natCast k) a = mul (natCast k) b := h₂ @@ -346,7 +346,7 @@ instance [Semiring α] [AddRightCancel α] [NoNatZeroDivisors α] : NoNatZeroDiv replace h₂ := NoNatZeroDivisors.no_nat_zero_divisors k (a₁ + b₂) (a₂ + b₁) h₁ h₂ apply Quot.sound; simp [r]; exists 0; simp [h₂] -instance {p} [Semiring α] [AddRightCancel α] [IsCharP α p] : IsCharP (OfSemiring.Q α) p where +instance (priority := high) {p} [Semiring α] [AddRightCancel α] [IsCharP α p] : IsCharP (OfSemiring.Q α) p where ofNat_ext_iff := by intro x y constructor @@ -366,7 +366,7 @@ instance {p} [Semiring α] [AddRightCancel α] [IsCharP α p] : IsCharP (OfSemir apply Quot.sound exists 0; simp [← Semiring.ofNat_eq_natCast, this] -instance [LE α] [IsPreorder α] [OrderedAdd α] : LE (OfSemiring.Q α) where +instance (priority := high) [LE α] [IsPreorder α] [OrderedAdd α] : LE (OfSemiring.Q α) where le a b := Q.liftOn₂ a b (fun (a, b) (c, d) => a + d ≤ b + c) (by intro (a₁, b₁) (a₂, b₂) (a₃, b₃) (a₄, b₄) simp; intro k₁ h₁ k₂ h₂ @@ -382,14 +382,14 @@ instance [LE α] [IsPreorder α] [OrderedAdd α] : LE (OfSemiring.Q α) where rw [this]; clear this rw [← OrderedAdd.add_le_left_iff]) -instance [LE α] [IsPreorder α] [OrderedAdd α] : LT (OfSemiring.Q α) where +instance (priority := high) [LE α] [IsPreorder α] [OrderedAdd α] : LT (OfSemiring.Q α) where lt a b := a ≤ b ∧ ¬b ≤ a @[local simp] theorem mk_le_mk [LE α] [IsPreorder α] [OrderedAdd α] {a₁ a₂ b₁ b₂ : α} : Q.mk (a₁, a₂) ≤ Q.mk (b₁, b₂) ↔ a₁ + b₂ ≤ a₂ + b₁ := by rfl -instance [LE α] [IsPreorder α] [OrderedAdd α] : IsPreorder (OfSemiring.Q α) where +instance (priority := high) [LE α] [IsPreorder α] [OrderedAdd α] : IsPreorder (OfSemiring.Q α) where le_refl a := by obtain ⟨⟨a₁, a₂⟩⟩ := a change Q.mk _ ≤ Q.mk _ @@ -424,7 +424,7 @@ theorem toQ_le [LE α] [IsPreorder α] [OrderedAdd α] {a b : α} : toQ a ≤ to theorem toQ_lt [LE α] [LT α] [LawfulOrderLT α] [IsPreorder α] [OrderedAdd α] {a b : α} : toQ a < toQ b ↔ a < b := by simp [lt_iff_le_and_not_ge] -instance [LE α] [IsPreorder α] [OrderedAdd α] : OrderedAdd (OfSemiring.Q α) where +instance (priority := high) [LE α] [IsPreorder α] [OrderedAdd α] : OrderedAdd (OfSemiring.Q α) where add_le_left_iff := by intro a b c obtain ⟨⟨a₁, a₂⟩⟩ := a @@ -438,7 +438,7 @@ instance [LE α] [IsPreorder α] [OrderedAdd α] : OrderedAdd (OfSemiring.Q α) rw [← OrderedAdd.add_le_left_iff] -- This perhaps works in more generality than `ExistsAddOfLT`? -instance [LE α] [LT α] [LawfulOrderLT α] [IsPreorder α] [OrderedRing α] [ExistsAddOfLT α] : OrderedRing (OfSemiring.Q α) where +instance (priority := high) [LE α] [LT α] [LawfulOrderLT α] [IsPreorder α] [OrderedRing α] [ExistsAddOfLT α] : OrderedRing (OfSemiring.Q α) where zero_lt_one := by rw [← toQ_ofNat, ← toQ_ofNat, toQ_lt] exact OrderedRing.zero_lt_one @@ -511,7 +511,16 @@ def ofCommSemiring : CommRing (OfSemiring.Q α) := { OfSemiring.ofSemiring with mul_comm := mul_comm } -attribute [instance] ofCommSemiring +attribute [instance high] ofCommSemiring +instance (priority := high) [CommRing (OfSemiring.Q α)] : Add (OfSemiring.Q α) := by infer_instance +instance (priority := high) [CommRing (OfSemiring.Q α)] : Sub (OfSemiring.Q α) := by infer_instance +instance (priority := high) [CommRing (OfSemiring.Q α)] : Mul (OfSemiring.Q α) := by infer_instance +instance (priority := high) [CommRing (OfSemiring.Q α)] : Neg (OfSemiring.Q α) := by infer_instance +instance (priority := high) [CommRing (OfSemiring.Q α)] : OfNat (OfSemiring.Q α) n := by infer_instance +attribute [local instance] Semiring.natCast Ring.intCast +instance (priority := high) [CommRing (OfSemiring.Q α)] : NatCast (OfSemiring.Q α) := by infer_instance +instance (priority := high) [CommRing (OfSemiring.Q α)] : IntCast (OfSemiring.Q α) := by infer_instance +instance (priority := high) [CommRing (OfSemiring.Q α)] : HPow (OfSemiring.Q α) Nat (OfSemiring.Q α) := by infer_instance /- Remark: `↑a` is notation for `OfSemiring.toQ a`. diff --git a/tests/elab/info_trees.lean b/tests/elab/info_trees.lean index a99967b144..a1bedbd9f5 100644 --- a/tests/elab/info_trees.lean +++ b/tests/elab/info_trees.lean @@ -62,7 +62,7 @@ info: • [Command] @ ⟨79, 0⟩-⟨79, 40⟩ @ Lean.Elab.Command.elabDeclarati ⊢ 0 ≤ n after no goals • [Term] Nat.zero_le n : 0 ≤ n @ ⟨1, 1⟩†-⟨1, 1⟩† @ Lean.Elab.Term.elabApp - • [Completion-Id] Nat.zero_le : some LE.le.{0} Nat instLENat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) _uniq.35.3 @ ⟨1, 0⟩†-⟨1, 0⟩† + • [Completion-Id] Nat.zero_le : some LE.le.{0} Nat instLENat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) _uniq.47.3 @ ⟨1, 0⟩†-⟨1, 0⟩† • [Term] Nat.zero_le : ∀ (n : Nat), 0 ≤ n @ ⟨1, 0⟩†-⟨1, 0⟩† • [Term] n : Nat @ ⟨1, 5⟩†-⟨1, 5⟩† @ Lean.Elab.Term.elabIdent • [Completion-Id] n : some Nat @ ⟨1, 5⟩†-⟨1, 5⟩† diff --git a/tests/elab/setOptionTermTactic.lean.out.expected b/tests/elab/setOptionTermTactic.lean.out.expected index 1878862a00..232078aef5 100644 --- a/tests/elab/setOptionTermTactic.lean.out.expected +++ b/tests/elab/setOptionTermTactic.lean.out.expected @@ -1,8 +1,8 @@ [Meta.synthInstance] 💥️ OfNat ?m 1 [Meta.synthInstance] new goal OfNat ?m 1 - [Meta.synthInstance.instances] #[@Lean.Grind.Semiring.ofNat, @One.toOfNat1, @Int16.instOfNat, @UInt64.instOfNat, @Rat.instOfNat, @Int8.instOfNat, @instOfNatFloat, @BitVec.instOfNat, Dyadic.instOfNat, @Int64.instOfNat, @instOfNat, @Id.instOfNat, @UInt16.instOfNat, instOfNatNat, @UInt32.instOfNat, @UInt8.instOfNat, @Fin.instOfNat, @ISize.instOfNat, @instOfNatFloat32, @Int32.instOfNat, @USize.instOfNat] - [Meta.synthInstance.apply] 💥️ apply @USize.instOfNat to OfNat ?m 1 - [Meta.synthInstance.tryResolve] 💥️ OfNat ?m 1 ≟ OfNat USize ?m + [Meta.synthInstance.instances] #[@Lean.Grind.Semiring.ofNat, @One.toOfNat1, @Int16.instOfNat, @UInt64.instOfNat, @Rat.instOfNat, @Int8.instOfNat, @instOfNatFloat, @BitVec.instOfNat, Dyadic.instOfNat, @Int64.instOfNat, @instOfNat, @Id.instOfNat, @UInt16.instOfNat, instOfNatNat, @UInt32.instOfNat, @UInt8.instOfNat, @Fin.instOfNat, @ISize.instOfNat, @instOfNatFloat32, @Int32.instOfNat, @USize.instOfNat, @Lean.Grind.CommRing.OfCommSemiring.instOfNatQ] + [Meta.synthInstance.apply] 💥️ apply @Lean.Grind.CommRing.OfCommSemiring.instOfNatQ to OfNat ?m 1 + [Meta.synthInstance.tryResolve] 💥️ OfNat ?m 1 ≟ OfNat (Lean.Grind.Ring.OfSemiring.Q ?m) ?m [Meta.Tactic.simp.rewrite] Nat.add_succ:1000: x + 1 ==> diff --git a/tests/lean/interactive/completionPrefixIssue.lean.expected.out b/tests/lean/interactive/completionPrefixIssue.lean.expected.out index 42557a5dc8..3b795c3afb 100644 --- a/tests/lean/interactive/completionPrefixIssue.lean.expected.out +++ b/tests/lean/interactive/completionPrefixIssue.lean.expected.out @@ -3,7 +3,7 @@ {"items": [{"label": "veryLongDefinitionName", "kind": 6, - "data": ["file:///completionPrefixIssue.lean", 1, 64, 0, "f_uniq.39"]}, + "data": ["file:///completionPrefixIssue.lean", 1, 64, 0, "f_uniq.51"]}, {"label": "veryLongDefinitionNameVeryLongDefinitionName", "kind": 21, "data": @@ -17,7 +17,7 @@ Resolution of veryLongDefinitionName: {"label": "veryLongDefinitionName", "kind": 6, "detail": "Nat", - "data": ["file:///completionPrefixIssue.lean", 1, 64, 0, "f_uniq.39"]} + "data": ["file:///completionPrefixIssue.lean", 1, 64, 0, "f_uniq.51"]} Resolution of veryLongDefinitionNameVeryLongDefinitionName: {"label": "veryLongDefinitionNameVeryLongDefinitionName", "kind": 21, diff --git a/tests/pkg/module/Module/Imported.lean b/tests/pkg/module/Module/Imported.lean index 30636ba7a9..5baa85dcdb 100644 --- a/tests/pkg/module/Module/Imported.lean +++ b/tests/pkg/module/Module/Imported.lean @@ -28,6 +28,7 @@ Note: The following definitions were not unfolded because their definition is no #guard_msgs in example : f = 1 := rfl +set_option pp.mvars.anonymous false in /-- error: Tactic `apply` failed: could not unify the conclusion of `@rfl` ?a = ?a @@ -35,7 +36,7 @@ with the goal f = 1 Note: The full type of `@rfl` is - ∀ {α : Sort ?u.121} {a : α}, a = a + ∀ {α : Sort _} {a : α}, a = a Note: The following definitions were not unfolded because their definition is not exposed: f ↦ 1