Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit c06f500

Browse files
gebnerjcommelin
andcommitted
feat(logic/basic): add eq_iff_true_of_subsingleton (#3308)
I'm surprised we didn't have this already. ```lean example (x y : unit) : x = y := by simp ``` Co-authored-by: Johan Commelin <johan@commelin.net>
1 parent 95cc1b1 commit c06f500

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

src/linear_algebra/basis.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,9 +1286,7 @@ begin
12861286
apply (is_basis_fun₀ R η).comp (λ i, ⟨i, punit.star⟩),
12871287
apply bijective_iff_has_inverse.2,
12881288
use sigma.fst,
1289-
suffices : ∀ (a : η) (b : unit), punit.star = b,
1290-
{ simpa [function.left_inverse, function.right_inverse] },
1291-
exact λ _, punit_eq _
1289+
simp [function.left_inverse, function.right_inverse]
12921290
end
12931291

12941292
end

src/logic/basic.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ instance psum.inhabited_right {α β} [inhabited β] : inhabited (psum α β) :=
5050
{α} [subsingleton α] : decidable_eq α
5151
| a b := is_true (subsingleton.elim a b)
5252

53+
@[simp] lemma eq_iff_true_of_subsingleton [subsingleton α] (x y : α) :
54+
x = y ↔ true :=
55+
by cc
56+
5357
/-- Add an instance to "undo" coercion transitivity into a chain of coercions, because
5458
most simp lemmas are stated with respect to simple coercions and will not match when
5559
part of a chain. -/

src/tactic/fin_cases.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ meta def fin_cases_at_aux : Π (with_list : list expr) (e : expr), tactic unit
4646
(to_rhs >> conv.interactive.change (to_pexpr h))
4747
-- Otherwise, call `norm_num`. We let `norm_num` unfold `max` and `min`
4848
-- because it's helpful for the `interval_cases` tactic.
49-
| _ := try $ tactic.interactive.norm_num
50-
[simp_arg_type.expr ``(max), simp_arg_type.expr ``(min)] (loc.ns [some sn])
49+
| _ := try $ tactic.interactive.conv (some sn) none $
50+
to_rhs >> conv.interactive.norm_num
51+
[simp_arg_type.expr ``(max), simp_arg_type.expr ``(min)]
5152
end,
5253
s ← get_local sn,
5354
try `[subst %%s],

src/tactic/norm_num.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,6 @@ where `A` and `B` are numerical expressions.
14421442
It also has a relatively simple primality prover. -/
14431443
meta def norm_num (hs : parse simp_arg_list) : conv unit :=
14441444
repeat1 $ orelse' norm_num1 $
1445-
simp_core {} norm_num1 ff hs [] (loc.ns [none])
1445+
conv.interactive.simp ff hs [] { discharger := tactic.interactive.norm_num1 (loc.ns [none]) }
14461446

14471447
end conv.interactive

test/fin_cases.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ begin
1515
simp, assumption,
1616
end
1717

18+
example (f : ℕ → Prop) (p : fin 0) : f p.val :=
19+
by fin_cases *
20+
21+
example (f : ℕ → Prop) (p : fin 1) (h : f 0) : f p.val :=
22+
begin
23+
fin_cases p,
24+
assumption
25+
end
26+
1827
example (x2 : fin 2) (x3 : fin 3) (n : nat) (y : fin n) : x2.val * x3.val = x3.val * x2.val :=
1928
begin
2029
fin_cases x2;

test/tidy.lean

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ namespace tidy.test
1111

1212
meta def interactive_simp := `[simp]
1313

14-
def tidy_test_0 : ∀ x : unit, x = unit.star :=
15-
begin
16-
success_if_fail { chain [ interactive_simp ] },
17-
intro1,
18-
induction x,
19-
refl
20-
end
2114
def tidy_test_1 (a : string) : ∀ x : unit, x = unit.star :=
2215
begin
2316
tidy -- intros x, exact dec_trivial

0 commit comments

Comments
 (0)