@@ -6,6 +6,8 @@ Authors: Arthur Paulino
66
77import Mathlib.Tactic.Use
88import Mathlib.Tactic.Basic
9+ import Mathlib.Logic.Equiv.Defs
10+ import Mathlib.Data.PNat.Defs
911
1012namespace UseTests
1113
@@ -37,9 +39,9 @@ example : ∃ x : Nat, ∃ y : Nat, x = y := by use 42, 42
3739
3840/--
3941error: failed to synthesize instance of type class
40- OfNat (Nat × Nat ) 42
42+ OfNat (ℕ × ℕ ) 42
4143numerals are polymorphic in Lean, but the numeral `42` cannot be used in a context where the expected type is
42- Nat × Nat
44+ ℕ × ℕ
4345due to the absence of the instance above
4446
4547Hint: Type class instance resolution failures can be inspected with the `set_option trace.Meta.synthInstance true` command.
@@ -64,6 +66,15 @@ example : ∃ x : String × String, x.1 = x.2 := by use ("a", "a")
6466
6567example : ∃ x : String × String, x.1 = x.2 := by use! "a" , "a"
6668
69+ example : Nonempty Nat := by use 5
70+
71+ example : Nonempty (PNat ≃ Nat) := by
72+ use PNat.natPred, Nat.succPNat
73+ · exact PNat.succPNat_natPred
74+ · intro; rfl
75+
76+ example : ∃ n : {n : Nat // n % 2 = 0 }, n.val > 10 := by use! 20 ; simp
77+
6778-- This example is why `use` always tries applying the constructor before refining.
6879example : ∃ x : Nat, x = x := by
6980 use ?_
@@ -94,9 +105,9 @@ example : Σ _x _y : Int, (Int × Int) × Int := by
94105-- There are two constructors, so applying a constructor fails and it tries to just refine
95106/--
96107error: failed to synthesize instance of type class
97- OfNat (Option Nat ) 1
108+ OfNat (Option ℕ ) 1
98109numerals are polymorphic in Lean, but the numeral `1` cannot be used in a context where the expected type is
99- Option Nat
110+ Option ℕ
100111due to the absence of the instance above
101112
102113Hint: Type class instance resolution failures can be inspected with the `set_option trace.Meta.synthInstance true` command.
@@ -106,9 +117,9 @@ example : Option Nat := by use 1
106117
107118/--
108119error: failed to synthesize instance of type class
109- OfNat (Nat → Nat ) 1
120+ OfNat (ℕ → ℕ ) 1
110121numerals are polymorphic in Lean, but the numeral `1` cannot be used in a context where the expected type is
111- Nat → Nat
122+ ℕ → ℕ
112123due to the absence of the instance above
113124
114125Hint: Type class instance resolution failures can be inspected with the `set_option trace.Meta.synthInstance true` command.
@@ -172,7 +183,7 @@ example : Baz 0 3 := by use 4
172183error: Type mismatch
173184 3
174185has type
175- Nat
186+ ℕ
176187of sort `Type` but is expected to have type
177188 Baz 1 3
178189of sort `Prop`
0 commit comments