@@ -3,7 +3,6 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved.
33Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Leonardo de Moura, Mario Carneiro
55-/
6- import Mathlib.Data.Sum.Basic
76import Mathlib.Logic.Equiv.Option
87import Mathlib.Logic.Equiv.Sum
98import Mathlib.Logic.Function.Conjugate
@@ -644,6 +643,7 @@ theorem swap_self (a : α) : swap a a = Equiv.refl _ :=
644643theorem swap_comm (a b : α) : swap a b = swap b a :=
645644 ext fun r => swapCore_comm r _ _
646645
646+ @[aesop simp, grind =]
647647theorem swap_apply_def (a b x : α) : swap a b x = if x = a then b else if x = b then a else x :=
648648 rfl
649649
@@ -653,10 +653,10 @@ theorem swap_apply_left (a b : α) : swap a b a = b :=
653653
654654@[simp]
655655theorem swap_apply_right (a b : α) : swap a b b = a := by
656- by_cases h : b = a <;> simp [swap_apply_def, h]
656+ grind
657657
658658theorem swap_apply_of_ne_of_ne {a b x : α} : x ≠ a → x ≠ b → swap a b x = x := by
659- simp +contextual [swap_apply_def]
659+ grind
660660
661661theorem eq_or_eq_of_swap_apply_ne_self {a b x : α} (h : swap a b x ≠ x) : x = a ∨ x = b := by
662662 contrapose! h
@@ -680,20 +680,17 @@ theorem swap_comp_apply {a b x : α} (π : Perm α) :
680680 cases π
681681 rfl
682682
683- theorem swap_eq_update (i j : α) : (Equiv.swap i j : α → α) = update (update id j i) i j :=
684- funext fun x => by rw [update_apply _ i j, update_apply _ j i, Equiv.swap_apply_def, id]
683+ theorem swap_eq_update (i j : α) : (Equiv.swap i j : α → α) = update (update id j i) i j := by
684+ aesop
685685
686686theorem comp_swap_eq_update (i j : α) (f : α → β) :
687687 f ∘ Equiv.swap i j = update (update f j (f i)) i (f j) := by
688- rw [swap_eq_update, comp_update, comp_update, comp_id]
688+ aesop
689689
690690@[simp]
691691theorem symm_trans_swap_trans [DecidableEq β] (a b : α) (e : α ≃ β) :
692- (e.symm.trans (swap a b)).trans e = swap (e a) (e b) :=
693- Equiv.ext fun x => by
694- have : ∀ a, e.symm x = a ↔ x = e a := fun a => by grind
695- simp only [trans_apply, swap_apply_def, this]
696- split_ifs <;> simp
692+ (e.symm.trans (swap a b)).trans e = swap (e a) (e b) := by
693+ grind
697694
698695@[simp]
699696theorem trans_swap_trans_symm [DecidableEq β] (a b : β) (e : α ≃ β) :
@@ -707,45 +704,25 @@ theorem swap_apply_self (i j a : α) : swap i j (swap i j a) = a := by
707704/-- A function is invariant to a swap if it is equal at both elements -/
708705theorem apply_swap_eq_self {v : α → β} {i j : α} (hv : v i = v j) (k : α) :
709706 v (swap i j k) = v k := by
710- by_cases hi : k = i
711- · rw [hi, swap_apply_left, hv]
712- by_cases hj : k = j
713- · rw [hj, swap_apply_right, hv]
714- rw [swap_apply_of_ne_of_ne hi hj]
707+ grind
715708
716709theorem swap_apply_eq_iff {x y z w : α} : swap x y z = w ↔ z = swap x y w := by
717710 rw [apply_eq_iff_eq_symm_apply, symm_swap]
718711
719712theorem swap_apply_ne_self_iff {a b x : α} : swap a b x ≠ x ↔ a ≠ b ∧ (x = a ∨ x = b) := by
720- by_cases hab : a = b
721- · simp [hab]
722- by_cases hax : x = a
723- · simp [hax, eq_comm]
724- by_cases hbx : x = b
725- · simp [hbx]
726- simp [hab, hax, hbx, swap_apply_of_ne_of_ne]
713+ grind
727714
728715namespace Perm
729716
730717@[simp]
731718theorem sumCongr_swap_refl {α β : Sort _} [DecidableEq α] [DecidableEq β] (i j : α) :
732719 Equiv.Perm.sumCongr (Equiv.swap i j) (Equiv.refl β) = Equiv.swap (Sum.inl i) (Sum.inl j) := by
733- ext x
734- cases x
735- · simp only [Equiv.sumCongr_apply, Sum.map, coe_refl, comp_id, Sum.elim_inl, comp_apply,
736- swap_apply_def, Sum.inl.injEq]
737- split_ifs <;> rfl
738- · simp [Sum.map, swap_apply_of_ne_of_ne]
720+ aesop
739721
740722@[simp]
741723theorem sumCongr_refl_swap {α β : Sort _} [DecidableEq α] [DecidableEq β] (i j : β) :
742724 Equiv.Perm.sumCongr (Equiv.refl α) (Equiv.swap i j) = Equiv.swap (Sum.inr i) (Sum.inr j) := by
743- ext x
744- cases x
745- · simp [Sum.map, swap_apply_of_ne_of_ne]
746- · simp only [Equiv.sumCongr_apply, Sum.map, coe_refl, comp_id, Sum.elim_inr, comp_apply,
747- swap_apply_def, Sum.inr.injEq]
748- split_ifs <;> rfl
725+ aesop
749726
750727end Perm
751728
@@ -805,11 +782,8 @@ section
805782def piCongrLeft' (P : α → Sort *) (e : α ≃ β) : (∀ a, P a) ≃ ∀ b, P (e.symm b) where
806783 toFun f x := f (e.symm x)
807784 invFun f x := (e.symm_apply_apply x).ndrec (f (e x))
808- left_inv f := funext fun x =>
809- (by rintro _ rfl; rfl : ∀ {y} (h : y = x), h.ndrec (f y) = f x) (e.symm_apply_apply x)
810- right_inv f := funext fun x =>
811- (by rintro _ rfl; rfl : ∀ {y} (h : y = x), (congr_arg e.symm h).ndrec (f y) = f x)
812- (e.apply_symm_apply x)
785+ left_inv f := by grind
786+ right_inv f := by grind
813787
814788/-- Note: the "obvious" statement `(piCongrLeft' P e).symm g a = g (e a)` doesn't typecheck: the
815789LHS would have type `P a` while the RHS would have type `P (e.symm (e a))`. For that reason,
@@ -881,14 +855,12 @@ lemma piCongrLeft_apply_eq_cast {P : β → Sort v} {e : α ≃ β}
881855theorem piCongrLeft_sumInl {ι ι' ι''} (π : ι'' → Type *) (e : ι ⊕ ι' ≃ ι'') (f : ∀ i, π (e (inl i)))
882856 (g : ∀ i, π (e (inr i))) (i : ι) :
883857 piCongrLeft π e (sumPiEquivProdPi (fun x => π (e x)) |>.symm (f, g)) (e (inl i)) = f i := by
884- simp_rw [piCongrLeft_apply_eq_cast, sumPiEquivProdPi_symm_apply,
885- sum_rec_congr _ _ _ (e.symm_apply_apply (inl i)), cast_cast, cast_eq]
858+ aesop
886859
887860theorem piCongrLeft_sumInr {ι ι' ι''} (π : ι'' → Type *) (e : ι ⊕ ι' ≃ ι'') (f : ∀ i, π (e (inl i)))
888861 (g : ∀ i, π (e (inr i))) (j : ι') :
889862 piCongrLeft π e (sumPiEquivProdPi (fun x => π (e x)) |>.symm (f, g)) (e (inr j)) = g j := by
890- simp_rw [piCongrLeft_apply_eq_cast, sumPiEquivProdPi_symm_apply,
891- sum_rec_congr _ _ _ (e.symm_apply_apply (inr j)), cast_cast, cast_eq]
863+ aesop
892864
893865end
894866
0 commit comments