combinatorics.set_family.compression.down ⟷ Mathlib.Combinatorics.SetFamily.Compression.Down

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -189,7 +189,7 @@ scoped[FinsetFamily] notation "𝓓 " => Down.compression
 original, or it's not in the original but it's the compression of something in the original. -/
 theorem mem_compression : s ∈ 𝓓 a π’œ ↔ s ∈ π’œ ∧ s.eraseβ‚“ a ∈ π’œ ∨ s βˆ‰ π’œ ∧ insert a s ∈ π’œ :=
   by
-  simp_rw [compression, mem_disj_union, mem_filter, mem_image, and_comm' (s βˆ‰ π’œ)]
+  simp_rw [compression, mem_disj_union, mem_filter, mem_image, and_comm (s βˆ‰ π’œ)]
   refine'
     or_congr_right
       (and_congr_left fun hs =>
Diff
@@ -222,7 +222,7 @@ theorem erase_mem_compression_of_mem_compression : s ∈ 𝓓 a π’œ β†’ s.erase
 theorem mem_compression_of_insert_mem_compression (h : insert a s ∈ 𝓓 a π’œ) : s ∈ 𝓓 a π’œ :=
   by
   by_cases ha : a ∈ s
-  Β· rwa [insert_eq_of_mem ha] at h 
+  Β· rwa [insert_eq_of_mem ha] at h
   Β· rw [← erase_insert ha]
     exact erase_mem_compression_of_mem_compression h
 #align down.mem_compression_of_insert_mem_compression Down.mem_compression_of_insert_mem_compression
@@ -250,7 +250,7 @@ theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).ca
     card_image_of_inj_on ((erase_inj_on' _).mono fun s hs => _), ← card_disjoint_union,
     filter_union_filter_neg_eq]
   Β· exact disjoint_filter_filter_neg _ _ _
-  rw [mem_coe, mem_filter] at hs 
+  rw [mem_coe, mem_filter] at hs
   exact not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
 #align down.card_compression Down.card_compression
 -/
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 YaΓ«l Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: YaΓ«l Dillies
 -/
-import Mathbin.Data.Finset.Card
+import Data.Finset.Card
 
 #align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"cc70d9141824ea8982d1562ce009952f2c3ece30"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2022 YaΓ«l Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: YaΓ«l Dillies
-
-! This file was ported from Lean 3 source module combinatorics.set_family.compression.down
-! leanprover-community/mathlib commit cc70d9141824ea8982d1562ce009952f2c3ece30
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.Finset.Card
 
+#align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"cc70d9141824ea8982d1562ce009952f2c3ece30"
+
 /-!
 # Down-compressions
 
Diff
@@ -185,7 +185,6 @@ def compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : Finset (Finset Ξ±) :=
 #align down.compression Down.compression
 -/
 
--- mathport name: down.compression
 scoped[FinsetFamily] notation "𝓓 " => Down.compression
 
 #print Down.mem_compression /-
Diff
@@ -226,7 +226,7 @@ theorem erase_mem_compression_of_mem_compression : s ∈ 𝓓 a π’œ β†’ s.erase
 theorem mem_compression_of_insert_mem_compression (h : insert a s ∈ 𝓓 a π’œ) : s ∈ 𝓓 a π’œ :=
   by
   by_cases ha : a ∈ s
-  Β· rwa [insert_eq_of_mem ha] at h
+  Β· rwa [insert_eq_of_mem ha] at h 
   Β· rw [← erase_insert ha]
     exact erase_mem_compression_of_mem_compression h
 #align down.mem_compression_of_insert_mem_compression Down.mem_compression_of_insert_mem_compression
@@ -254,7 +254,7 @@ theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).ca
     card_image_of_inj_on ((erase_inj_on' _).mono fun s hs => _), ← card_disjoint_union,
     filter_union_filter_neg_eq]
   Β· exact disjoint_filter_filter_neg _ _ _
-  rw [mem_coe, mem_filter] at hs
+  rw [mem_coe, mem_filter] at hs 
   exact not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
 #align down.card_compression Down.card_compression
 -/
Diff
@@ -142,39 +142,29 @@ theorem memberSubfamily_union_nonMemberSubfamily (a : Ξ±) (π’œ : Finset (Finset
 
 #print Finset.memberSubfamily_memberSubfamily /-
 @[simp]
-theorem memberSubfamily_memberSubfamily : (π’œ.memberSubfamily a).memberSubfamily a = βˆ… :=
-  by
-  ext
+theorem memberSubfamily_memberSubfamily : (π’œ.memberSubfamily a).memberSubfamily a = βˆ… := by ext;
   simp
 #align finset.member_subfamily_member_subfamily Finset.memberSubfamily_memberSubfamily
 -/
 
 #print Finset.memberSubfamily_nonMemberSubfamily /-
 @[simp]
-theorem memberSubfamily_nonMemberSubfamily : (π’œ.nonMemberSubfamily a).memberSubfamily a = βˆ… :=
-  by
-  ext
-  simp
+theorem memberSubfamily_nonMemberSubfamily : (π’œ.nonMemberSubfamily a).memberSubfamily a = βˆ… := by
+  ext; simp
 #align finset.member_subfamily_non_member_subfamily Finset.memberSubfamily_nonMemberSubfamily
 -/
 
 #print Finset.nonMemberSubfamily_memberSubfamily /-
 @[simp]
 theorem nonMemberSubfamily_memberSubfamily :
-    (π’œ.memberSubfamily a).nonMemberSubfamily a = π’œ.memberSubfamily a :=
-  by
-  ext
-  simp
+    (π’œ.memberSubfamily a).nonMemberSubfamily a = π’œ.memberSubfamily a := by ext; simp
 #align finset.non_member_subfamily_member_subfamily Finset.nonMemberSubfamily_memberSubfamily
 -/
 
 #print Finset.nonMemberSubfamily_nonMemberSubfamily /-
 @[simp]
 theorem nonMemberSubfamily_nonMemberSubfamily :
-    (π’œ.nonMemberSubfamily a).nonMemberSubfamily a = π’œ.nonMemberSubfamily a :=
-  by
-  ext
-  simp
+    (π’œ.nonMemberSubfamily a).nonMemberSubfamily a = π’œ.nonMemberSubfamily a := by ext; simp
 #align finset.non_member_subfamily_non_member_subfamily Finset.nonMemberSubfamily_nonMemberSubfamily
 -/
 

Changes in mathlib4

mathlib3
mathlib4
chore: remove mathport name: <expression> lines (#11928)

Quoting [@digama0](https://github.com/digama0):

These were actually never meant to go in the file, they are basically debugging information and only useful on significantly broken mathport files. You can safely remove all of them.

Diff
@@ -231,7 +231,6 @@ def compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : Finset (Finset Ξ±) :=
       exact this (mem_filter.1 h₁).1
 #align down.compression Down.compression
 
--- mathport name: down.compression
 @[inherit_doc]
 scoped[FinsetFamily] notation "𝓓 " => Down.compression
 -- Porting note: had to open this
feat: (s ∩ t).card = s.card + t.card - (s βˆͺ t).card (#10224)

once coerced to an AddGroupWithOne. Also unify Finset.card_disjoint_union and Finset.card_union_eq

From LeanAPAP

Diff
@@ -283,7 +283,7 @@ theorem compression_idem (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : 𝓓 a (𝓓 a 
 @[simp]
 theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).card = π’œ.card := by
   rw [compression, card_disjUnion, filter_image,
-    card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ← card_disjoint_union]
+    card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ← card_union_of_disjoint]
   Β· conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ π’œ)) π’œ]
   Β· exact disjoint_filter_filter_neg π’œ π’œ (fun s => (erase s a ∈ π’œ))
   intro s hs
chore: Improve Finset lemma names (#8894)

Change a few lemma names that have historically bothered me.

  • Finset.card_le_of_subset β†’ Finset.card_le_card
  • Multiset.card_le_of_le β†’ Multiset.card_le_card
  • Multiset.card_lt_of_lt β†’ Multiset.card_lt_card
  • Set.ncard_le_of_subset β†’ Set.ncard_le_ncard
  • Finset.image_filter β†’ Finset.filter_image
  • CompleteLattice.finset_sup_compact_of_compact β†’ CompleteLattice.isCompactElement_finset_sup
Diff
@@ -282,7 +282,7 @@ theorem compression_idem (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : 𝓓 a (𝓓 a 
 /-- Down-compressing a family doesn't change its size. -/
 @[simp]
 theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).card = π’œ.card := by
-  rw [compression, card_disjUnion, image_filter,
+  rw [compression, card_disjUnion, filter_image,
     card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ← card_disjoint_union]
   Β· conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ π’œ)) π’œ]
   Β· exact disjoint_filter_filter_neg π’œ π’œ (fun s => (erase s a ∈ π’œ))
chore: space after ← (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -142,7 +142,7 @@ lemma memberSubfamily_image_insert (hπ’œ : βˆ€ s ∈ π’œ, a βˆ‰ s) :
   simp only [mem_memberSubfamily, mem_image]
   refine ⟨?_, fun hs ↦ ⟨⟨s, hs, rfl⟩, hπ’œ _ hs⟩⟩
   rintro ⟨⟨t, ht, hts⟩, hs⟩
-  rwa [←insert_erase_invOn.2.injOn (hπ’œ _ ht) hs hts]
+  rwa [← insert_erase_invOn.2.injOn (hπ’œ _ ht) hs hts]
 
 @[simp] lemma nonMemberSubfamily_image_insert : (π’œ.image <| insert a).nonMemberSubfamily a = βˆ… := by
   simp [eq_empty_iff_forall_not_mem]
@@ -182,7 +182,7 @@ lemma memberFamily_induction_on {p : Finset (Finset Ξ±) β†’ Prop}
   clear_value u
   induction' u using Finset.induction with a u _ ih generalizing π’œ
   Β· simp_rw [subset_empty] at hu
-    rw [←subset_singleton_iff', subset_singleton_iff] at hu
+    rw [← subset_singleton_iff', subset_singleton_iff] at hu
     obtain rfl | rfl := hu <;> assumption
   refine subfamily a (ih _ ?_) (ih _ ?_)
   Β· simp only [mem_nonMemberSubfamily, and_imp]
@@ -211,7 +211,7 @@ protected lemma family_induction_on {p : Finset (Finset Ξ±) β†’ Prop}
     (subfamily : βˆ€ (a : Ξ±) β¦ƒπ’œ : Finset (Finset Ξ±)⦄,
       p (π’œ.filter (a βˆ‰ Β·)) β†’ p (π’œ.filter (a ∈ Β·)) β†’ p π’œ) : p π’œ := by
   refine memberFamily_induction_on π’œ empty singleton_empty fun a π’œ hπ’œβ‚€ hπ’œβ‚ ↦ subfamily a hπ’œβ‚€ ?_
-  rw [←image_insert_memberSubfamily]
+  rw [← image_insert_memberSubfamily]
   exact image_insert _ (by simp) hπ’œβ‚
 
 end Finset
feat: Finset family induction (#7522)

Provide an induction principle for finset families: One can increase the support of a finset family one by one.

Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 YaΓ«l Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: YaΓ«l Dillies
 -/
-import Mathlib.Data.Finset.Card
+import Mathlib.Data.Finset.Lattice
 
 #align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
 
@@ -136,6 +136,84 @@ theorem nonMemberSubfamily_nonMemberSubfamily :
   simp
 #align finset.non_member_subfamily_non_member_subfamily Finset.nonMemberSubfamily_nonMemberSubfamily
 
+lemma memberSubfamily_image_insert (hπ’œ : βˆ€ s ∈ π’œ, a βˆ‰ s) :
+    (π’œ.image <| insert a).memberSubfamily a = π’œ := by
+  ext s
+  simp only [mem_memberSubfamily, mem_image]
+  refine ⟨?_, fun hs ↦ ⟨⟨s, hs, rfl⟩, hπ’œ _ hs⟩⟩
+  rintro ⟨⟨t, ht, hts⟩, hs⟩
+  rwa [←insert_erase_invOn.2.injOn (hπ’œ _ ht) hs hts]
+
+@[simp] lemma nonMemberSubfamily_image_insert : (π’œ.image <| insert a).nonMemberSubfamily a = βˆ… := by
+  simp [eq_empty_iff_forall_not_mem]
+
+@[simp] lemma memberSubfamily_image_erase : (π’œ.image (erase Β· a)).memberSubfamily a = βˆ… := by
+  simp [eq_empty_iff_forall_not_mem,
+    (ne_of_mem_of_not_mem' (mem_insert_self _ _) (not_mem_erase _ _)).symm]
+
+lemma image_insert_memberSubfamily (π’œ : Finset (Finset Ξ±)) (a : Ξ±) :
+    (π’œ.memberSubfamily a).image (insert a) = π’œ.filter (a ∈ Β·) := by
+  ext s
+  simp only [mem_memberSubfamily, mem_image, mem_filter]
+  refine ⟨?_, fun ⟨hs, ha⟩ ↦ ⟨erase s a, ⟨?_, not_mem_erase _ _⟩, insert_erase ha⟩⟩
+  · rintro ⟨s, ⟨hs, -⟩, rfl⟩
+    exact ⟨hs, mem_insert_self _ _⟩
+  Β· rwa [insert_erase ha]
+
+/-- Induction principle for finset families. To prove a statement for every finset family,
+it suffices to prove it for
+* the empty finset family.
+* the finset family which only contains the empty finset.
+* `ℬ βˆͺ {s βˆͺ {a} | s ∈ π’ž}` assuming the property for `ℬ` and `π’ž`, where `a` is an element of the
+  ground type and `π’œ` and `ℬ` are families of finsets not containing `a`.
+  Note that instead of giving `ℬ` and `π’ž`, the `subfamily` case gives you
+  `π’œ = ℬ βˆͺ {s βˆͺ {a} | s ∈ π’ž}`, so that `ℬ = π’œ.nonMemberSubfamily` and `π’ž = π’œ.memberSubfamily`.
+
+This is a way of formalising induction on `n` where `π’œ` is a finset family on `n` elements.
+
+See also `Finset.family_induction_on.`-/
+@[elab_as_elim]
+lemma memberFamily_induction_on {p : Finset (Finset Ξ±) β†’ Prop}
+    (π’œ : Finset (Finset Ξ±)) (empty : p βˆ…) (singleton_empty : p {βˆ…})
+    (subfamily : βˆ€ (a : Ξ±) β¦ƒπ’œ : Finset (Finset Ξ±)⦄,
+      p (π’œ.nonMemberSubfamily a) β†’ p (π’œ.memberSubfamily a) β†’ p π’œ) : p π’œ := by
+  set u := π’œ.sup id
+  have hu : βˆ€ s ∈ π’œ, s βŠ† u := fun s ↦ le_sup (f := id)
+  clear_value u
+  induction' u using Finset.induction with a u _ ih generalizing π’œ
+  Β· simp_rw [subset_empty] at hu
+    rw [←subset_singleton_iff', subset_singleton_iff] at hu
+    obtain rfl | rfl := hu <;> assumption
+  refine subfamily a (ih _ ?_) (ih _ ?_)
+  Β· simp only [mem_nonMemberSubfamily, and_imp]
+    exact fun s hs has ↦ (subset_insert_iff_of_not_mem has).1 <| hu _ hs
+  Β· simp only [mem_memberSubfamily, and_imp]
+    exact fun s hs ha ↦ (insert_subset_insert_iff ha).1 <| hu _ hs
+
+/-- Induction principle for finset families. To prove a statement for every finset family,
+it suffices to prove it for
+* the empty finset family.
+* the finset family which only contains the empty finset.
+* `{s βˆͺ {a} | s ∈ π’œ}` assuming the property for `π’œ` a family of finsets not containing `a`.
+* `ℬ βˆͺ π’ž` assuming the property for `ℬ` and `π’ž`, where `a` is an element of the ground type and
+  `ℬ`is a family of finsets not containing `a` and `π’ž` a family of finsets containing `a`.
+  Note that instead of giving `ℬ` and `π’ž`, the `subfamily` case gives you `π’œ = ℬ βˆͺ π’ž`, so that
+  `ℬ = π’œ.filter (a βˆ‰ Β·)` and `π’ž = π’œ.filter (a ∈ Β·)`.
+
+This is a way of formalising induction on `n` where `π’œ` is a finset family on `n` elements.
+
+See also `Finset.memberFamily_induction_on.`-/
+@[elab_as_elim]
+protected lemma family_induction_on {p : Finset (Finset Ξ±) β†’ Prop}
+    (π’œ : Finset (Finset Ξ±)) (empty : p βˆ…) (singleton_empty : p {βˆ…})
+    (image_insert : βˆ€ (a : Ξ±) β¦ƒπ’œ : Finset (Finset Ξ±)⦄,
+      (βˆ€ s ∈ π’œ, a βˆ‰ s) β†’ p π’œ β†’ p (π’œ.image <| insert a))
+    (subfamily : βˆ€ (a : Ξ±) β¦ƒπ’œ : Finset (Finset Ξ±)⦄,
+      p (π’œ.filter (a βˆ‰ Β·)) β†’ p (π’œ.filter (a ∈ Β·)) β†’ p π’œ) : p π’œ := by
+  refine memberFamily_induction_on π’œ empty singleton_empty fun a π’œ hπ’œβ‚€ hπ’œβ‚ ↦ subfamily a hπ’œβ‚€ ?_
+  rw [←image_insert_memberSubfamily]
+  exact image_insert _ (by simp) hπ’œβ‚
+
 end Finset
 
 open Finset
feat: Miscellaneous Finset lemmas (#7379)
Diff
@@ -209,7 +209,7 @@ theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).ca
   Β· conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ π’œ)) π’œ]
   Β· exact disjoint_filter_filter_neg π’œ π’œ (fun s => (erase s a ∈ π’œ))
   intro s hs
-  rw [mem_coe, mem_filter, Function.comp_apply] at hs
+  rw [mem_coe, mem_filter] at hs
   exact not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
 #align down.card_compression Down.card_compression
 
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -37,7 +37,7 @@ compression, down-compression
 -/
 
 
-variable {Ξ± : Type _} [DecidableEq Ξ±] {π’œ ℬ : Finset (Finset Ξ±)} {s : Finset Ξ±} {a : Ξ±}
+variable {Ξ± : Type*} [DecidableEq Ξ±] {π’œ ℬ : Finset (Finset Ξ±)} {s : Finset Ξ±} {a : Ξ±}
 
 namespace Finset
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2022 YaΓ«l Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: YaΓ«l Dillies
-
-! This file was ported from Lean 3 source module combinatorics.set_family.compression.down
-! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.Finset.Card
 
+#align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
+
 /-!
 # Down-compressions
 
feat: add Mathlib.Tactic.Common, and import (#4056)

This makes a mathlib4 version of mathlib3's tactic.basic, now called Mathlib.Tactic.Common, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.

This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -9,7 +9,6 @@ Authors: YaΓ«l Dillies
 ! if you have ported upstream changes.
 -/
 import Mathlib.Data.Finset.Card
-import Mathlib.Tactic.ScopedNS
 
 /-!
 # Down-compressions
chore: bye-bye, solo bys! (#3825)

This PR puts, with one exception, every single remaining by that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh. The exception is when the by begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.

Essentially this is s/\n *by$/ by/g, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated bys".

Diff
@@ -62,8 +62,7 @@ theorem mem_nonMemberSubfamily : s ∈ π’œ.nonMemberSubfamily a ↔ s ∈ π’œ
 #align finset.mem_non_member_subfamily Finset.mem_nonMemberSubfamily
 
 @[simp]
-theorem mem_memberSubfamily : s ∈ π’œ.memberSubfamily a ↔ insert a s ∈ π’œ ∧ a βˆ‰ s :=
-  by
+theorem mem_memberSubfamily : s ∈ π’œ.memberSubfamily a ↔ insert a s ∈ π’œ ∧ a βˆ‰ s := by
   simp_rw [memberSubfamily, mem_image, mem_filter]
   refine' ⟨_, fun h => ⟨insert a s, ⟨h.1, by simp⟩, erase_insert h.2⟩⟩
   rintro ⟨s, ⟨hs1, hs2⟩, rfl⟩
@@ -77,8 +76,7 @@ theorem nonMemberSubfamily_inter (a : Ξ±) (π’œ ℬ : Finset (Finset Ξ±)) :
 #align finset.non_member_subfamily_inter Finset.nonMemberSubfamily_inter
 
 theorem memberSubfamily_inter (a : Ξ±) (π’œ ℬ : Finset (Finset Ξ±)) :
-    (π’œ ∩ ℬ).memberSubfamily a = π’œ.memberSubfamily a ∩ ℬ.memberSubfamily a :=
-  by
+    (π’œ ∩ ℬ).memberSubfamily a = π’œ.memberSubfamily a ∩ ℬ.memberSubfamily a := by
   unfold memberSubfamily
   rw [filter_inter_distrib, image_inter_of_injOn _ _ ((erase_injOn' _).mono _)]
   simp
@@ -95,8 +93,7 @@ theorem memberSubfamily_union (a : Ξ±) (π’œ ℬ : Finset (Finset Ξ±)) :
 #align finset.member_subfamily_union Finset.memberSubfamily_union
 
 theorem card_memberSubfamily_add_card_nonMemberSubfamily (a : Ξ±) (π’œ : Finset (Finset Ξ±)) :
-    (π’œ.memberSubfamily a).card + (π’œ.nonMemberSubfamily a).card = π’œ.card :=
-  by
+    (π’œ.memberSubfamily a).card + (π’œ.nonMemberSubfamily a).card = π’œ.card := by
   rw [memberSubfamily, nonMemberSubfamily, card_image_of_injOn]
   Β· conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
   Β· apply (erase_injOn' _).mono
@@ -104,8 +101,7 @@ theorem card_memberSubfamily_add_card_nonMemberSubfamily (a : Ξ±) (π’œ : Finset
 #align finset.card_member_subfamily_add_card_non_member_subfamily Finset.card_memberSubfamily_add_card_nonMemberSubfamily
 
 theorem memberSubfamily_union_nonMemberSubfamily (a : Ξ±) (π’œ : Finset (Finset Ξ±)) :
-    π’œ.memberSubfamily a βˆͺ π’œ.nonMemberSubfamily a = π’œ.image fun s => s.erase a :=
-  by
+    π’œ.memberSubfamily a βˆͺ π’œ.nonMemberSubfamily a = π’œ.image fun s => s.erase a := by
   ext s
   simp only [mem_union, mem_memberSubfamily, mem_nonMemberSubfamily, mem_image, exists_prop]
   constructor
@@ -119,31 +115,27 @@ theorem memberSubfamily_union_nonMemberSubfamily (a : Ξ±) (π’œ : Finset (Finset
 #align finset.member_subfamily_union_non_member_subfamily Finset.memberSubfamily_union_nonMemberSubfamily
 
 @[simp]
-theorem memberSubfamily_memberSubfamily : (π’œ.memberSubfamily a).memberSubfamily a = βˆ… :=
-  by
+theorem memberSubfamily_memberSubfamily : (π’œ.memberSubfamily a).memberSubfamily a = βˆ… := by
   ext
   simp
 #align finset.member_subfamily_member_subfamily Finset.memberSubfamily_memberSubfamily
 
 @[simp]
-theorem memberSubfamily_nonMemberSubfamily : (π’œ.nonMemberSubfamily a).memberSubfamily a = βˆ… :=
-  by
+theorem memberSubfamily_nonMemberSubfamily : (π’œ.nonMemberSubfamily a).memberSubfamily a = βˆ… := by
   ext
   simp
 #align finset.member_subfamily_non_member_subfamily Finset.memberSubfamily_nonMemberSubfamily
 
 @[simp]
 theorem nonMemberSubfamily_memberSubfamily :
-    (π’œ.memberSubfamily a).nonMemberSubfamily a = π’œ.memberSubfamily a :=
-  by
+    (π’œ.memberSubfamily a).nonMemberSubfamily a = π’œ.memberSubfamily a := by
   ext
   simp
 #align finset.non_member_subfamily_member_subfamily Finset.nonMemberSubfamily_memberSubfamily
 
 @[simp]
 theorem nonMemberSubfamily_nonMemberSubfamily :
-    (π’œ.nonMemberSubfamily a).nonMemberSubfamily a = π’œ.nonMemberSubfamily a :=
-  by
+    (π’œ.nonMemberSubfamily a).nonMemberSubfamily a = π’œ.nonMemberSubfamily a := by
   ext
   simp
 #align finset.non_member_subfamily_non_member_subfamily Finset.nonMemberSubfamily_nonMemberSubfamily
@@ -173,8 +165,7 @@ open FinsetFamily
 
 /-- `a` is in the down-compressed family iff it's in the original and its compression is in the
 original, or it's not in the original but it's the compression of something in the original. -/
-theorem mem_compression : s ∈ 𝓓 a π’œ ↔ s ∈ π’œ ∧ s.erase a ∈ π’œ ∨ s βˆ‰ π’œ ∧ insert a s ∈ π’œ :=
-  by
+theorem mem_compression : s ∈ 𝓓 a π’œ ↔ s ∈ π’œ ∧ s.erase a ∈ π’œ ∨ s βˆ‰ π’œ ∧ insert a s ∈ π’œ := by
   simp_rw [compression, mem_disjUnion, mem_filter, mem_image, and_comm (a := (Β¬ s ∈ π’œ))]
   refine'
     or_congr_right
@@ -184,23 +175,20 @@ theorem mem_compression : s ∈ 𝓓 a π’œ ↔ s ∈ π’œ ∧ s.erase a ∈ 
   rwa [insert_erase (erase_ne_self.1 (ne_of_mem_of_not_mem ht hs).symm)]
 #align down.mem_compression Down.mem_compression
 
-theorem erase_mem_compression (hs : s ∈ π’œ) : s.erase a ∈ 𝓓 a π’œ :=
-  by
+theorem erase_mem_compression (hs : s ∈ π’œ) : s.erase a ∈ 𝓓 a π’œ := by
   simp_rw [mem_compression, erase_idem, and_self_iff]
   refine' (em _).imp_right fun h => ⟨h, _⟩
   rwa [insert_erase (erase_ne_self.1 (ne_of_mem_of_not_mem hs h).symm)]
 #align down.erase_mem_compression Down.erase_mem_compression
 
 -- This is a special case of `erase_mem_compression` once we have `compression_idem`.
-theorem erase_mem_compression_of_mem_compression : s ∈ 𝓓 a π’œ β†’ s.erase a ∈ 𝓓 a π’œ :=
-  by
+theorem erase_mem_compression_of_mem_compression : s ∈ 𝓓 a π’œ β†’ s.erase a ∈ 𝓓 a π’œ := by
   simp_rw [mem_compression, erase_idem]
   refine' Or.imp (fun h => ⟨h.2, h.2⟩) fun h => _
   rwa [erase_eq_of_not_mem (insert_ne_self.1 <| ne_of_mem_of_not_mem h.2 h.1)]
 #align down.erase_mem_compression_of_mem_compression Down.erase_mem_compression_of_mem_compression
 
-theorem mem_compression_of_insert_mem_compression (h : insert a s ∈ 𝓓 a π’œ) : s ∈ 𝓓 a π’œ :=
-  by
+theorem mem_compression_of_insert_mem_compression (h : insert a s ∈ 𝓓 a π’œ) : s ∈ 𝓓 a π’œ := by
   by_cases ha : a ∈ s
   Β· rwa [insert_eq_of_mem ha] at h
   Β· rw [← erase_insert ha]
@@ -209,8 +197,7 @@ theorem mem_compression_of_insert_mem_compression (h : insert a s ∈ 𝓓 a 
 
 /-- Down-compressing a family is idempotent. -/
 @[simp]
-theorem compression_idem (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : 𝓓 a (𝓓 a π’œ) = 𝓓 a π’œ :=
-  by
+theorem compression_idem (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : 𝓓 a (𝓓 a π’œ) = 𝓓 a π’œ := by
   ext s
   refine' mem_compression.trans ⟨_, fun h => Or.inl ⟨h, erase_mem_compression_of_mem_compression h⟩⟩
   rintro (h | h)
@@ -220,8 +207,7 @@ theorem compression_idem (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : 𝓓 a (𝓓 a 
 
 /-- Down-compressing a family doesn't change its size. -/
 @[simp]
-theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).card = π’œ.card :=
-  by
+theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).card = π’œ.card := by
   rw [compression, card_disjUnion, image_filter,
     card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ← card_disjoint_union]
   Β· conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ π’œ)) π’œ]
Diff
@@ -175,8 +175,7 @@ open FinsetFamily
 original, or it's not in the original but it's the compression of something in the original. -/
 theorem mem_compression : s ∈ 𝓓 a π’œ ↔ s ∈ π’œ ∧ s.erase a ∈ π’œ ∨ s βˆ‰ π’œ ∧ insert a s ∈ π’œ :=
   by
-  simp_rw [compression, mem_disjUnion, mem_filter, mem_image,
-    decide_eq_true_eq, and_comm (a := (Β¬ s ∈ π’œ))]
+  simp_rw [compression, mem_disjUnion, mem_filter, mem_image, and_comm (a := (Β¬ s ∈ π’œ))]
   refine'
     or_congr_right
       (and_congr_left fun hs =>
feat: improvements to congr! and convert (#2606)
  • There is now configuration for congr!, convert, and convert_to to control parts of the congruence algorithm, in particular transparency settings when applying congruence lemmas.
  • congr! now applies congruence lemmas with reducible transparency by default. This prevents it from unfolding definitions when applying congruence lemmas. It also now tries both the LHS-biased and RHS-biased simp congruence lemmas, with a configuration option to set which it should try first.
  • There is now a new HEq congruence lemma generator that gives each hypothesis access to the proofs of previous hypotheses. This means that if you have an equality ⊒ ⟨a, x⟩ = ⟨b, y⟩ of sigma types, congr! turns this into goals ⊒ a = b and ⊒ a = b β†’ HEq x y (note that congr! will also auto-introduce a = b for you in the second goal). This congruence lemma generator applies to more cases than the simp congruence lemma generator does.
  • congr! (and hence convert) are more careful about applying lemmas that don't force definitions to unfold. There were a number of cases in mathlib where the implementation of congr was being abused to unfold definitions.
  • With set_option trace.congr! true you can see what congr! sees when it is deciding on congruence lemmas.
  • There is also a bug fix in convert_to to do using 1 when there is no using clause, to match its documentation.

Note that congr! is more capable than congr at finding a way to equate left-hand sides and right-hand sides, so you will frequently need to limit its depth with a using clause. However, there is also a new heuristic to prevent considering unlikely-to-be-provable type equalities (controlled by the typeEqs option), which can help limit the depth automatically.

There is also a predefined configuration that you can invoke with, for example, convert (config := .unfoldSameFun) h, that causes it to behave more like congr, including using default transparency when unfolding.

Diff
@@ -226,10 +226,10 @@ theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).ca
   rw [compression, card_disjUnion, image_filter,
     card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ← card_disjoint_union]
   Β· conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ π’œ)) π’œ]
-  Β· convert disjoint_filter_filter_neg π’œ π’œ (fun s => (erase s a ∈ π’œ))
+  Β· exact disjoint_filter_filter_neg π’œ π’œ (fun s => (erase s a ∈ π’œ))
   intro s hs
   rw [mem_coe, mem_filter, Function.comp_apply] at hs
-  convert not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
+  exact not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
 #align down.card_compression Down.card_compression
 
 end Down
chore: the style linter shouldn't complain about long #align lines (#1643)
Diff
@@ -101,9 +101,7 @@ theorem card_memberSubfamily_add_card_nonMemberSubfamily (a : Ξ±) (π’œ : Finset
   Β· conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
   Β· apply (erase_injOn' _).mono
     simp
-#align
-  finset.card_member_subfamily_add_card_non_member_subfamily
-  Finset.card_memberSubfamily_add_card_nonMemberSubfamily
+#align finset.card_member_subfamily_add_card_non_member_subfamily Finset.card_memberSubfamily_add_card_nonMemberSubfamily
 
 theorem memberSubfamily_union_nonMemberSubfamily (a : Ξ±) (π’œ : Finset (Finset Ξ±)) :
     π’œ.memberSubfamily a βˆͺ π’œ.nonMemberSubfamily a = π’œ.image fun s => s.erase a :=
@@ -118,9 +116,7 @@ theorem memberSubfamily_union_nonMemberSubfamily (a : Ξ±) (π’œ : Finset (Finset
     by_cases ha : a ∈ s
     · exact Or.inl ⟨by rwa [insert_erase ha], not_mem_erase _ _⟩
     · exact Or.inr ⟨by rwa [erase_eq_of_not_mem ha], not_mem_erase _ _⟩
-#align
-  finset.member_subfamily_union_non_member_subfamily
-  Finset.memberSubfamily_union_nonMemberSubfamily
+#align finset.member_subfamily_union_non_member_subfamily Finset.memberSubfamily_union_nonMemberSubfamily
 
 @[simp]
 theorem memberSubfamily_memberSubfamily : (π’œ.memberSubfamily a).memberSubfamily a = βˆ… :=
@@ -150,8 +146,7 @@ theorem nonMemberSubfamily_nonMemberSubfamily :
   by
   ext
   simp
-#align
-  finset.non_member_subfamily_non_member_subfamily Finset.nonMemberSubfamily_nonMemberSubfamily
+#align finset.non_member_subfamily_non_member_subfamily Finset.nonMemberSubfamily_nonMemberSubfamily
 
 end Finset
 
chore: revert Multiset and Finset API to use Prop instead of Bool (#1652)

Co-authored-by: Reid Barton <rwbarton@gmail.com>

Diff
@@ -67,7 +67,6 @@ theorem mem_memberSubfamily : s ∈ π’œ.memberSubfamily a ↔ insert a s ∈ 
   simp_rw [memberSubfamily, mem_image, mem_filter]
   refine' ⟨_, fun h => ⟨insert a s, ⟨h.1, by simp⟩, erase_insert h.2⟩⟩
   rintro ⟨s, ⟨hs1, hs2⟩, rfl⟩
-  rw [decide_eq_true_eq] at hs2
   rw [insert_erase hs2]
   exact ⟨hs1, not_mem_erase _ _⟩
 #align finset.mem_member_subfamily Finset.mem_memberSubfamily
@@ -100,7 +99,6 @@ theorem card_memberSubfamily_add_card_nonMemberSubfamily (a : Ξ±) (π’œ : Finset
   by
   rw [memberSubfamily, nonMemberSubfamily, card_image_of_injOn]
   Β· conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
-    simp
   Β· apply (erase_injOn' _).mono
     simp
 #align
@@ -169,7 +167,6 @@ def compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : Finset (Finset Ξ±) :=
       ((π’œ.image fun s => erase s a).filter fun s => s βˆ‰ π’œ) <|
     disjoint_left.2 fun s h₁ hβ‚‚ => by
       have := (mem_filter.1 hβ‚‚).2
-      rw [decide_eq_true_iff] at this
       exact this (mem_filter.1 h₁).1
 #align down.compression Down.compression
 
@@ -234,14 +231,9 @@ theorem card_compression (a : Ξ±) (π’œ : Finset (Finset Ξ±)) : (𝓓 a π’œ).ca
   rw [compression, card_disjUnion, image_filter,
     card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ← card_disjoint_union]
   Β· conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ π’œ)) π’œ]
-    congr
-    ext
-    simp
   Β· convert disjoint_filter_filter_neg π’œ π’œ (fun s => (erase s a ∈ π’œ))
-    ext
-    simp
   intro s hs
-  rw [mem_coe, mem_filter, Function.comp_apply, decide_eq_true_iff] at hs
+  rw [mem_coe, mem_filter, Function.comp_apply] at hs
   convert not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
 #align down.card_compression Down.card_compression
 
feat: port Combinatorics.SetFamily.Compression.Down (#1604)

Some proofs here needed rewriting mostly due to Finset.filter now taking bools and Function.comp not being seen through (see Zulip for what I think is a related discussion.)

Dependencies 2 + 154

155 files ported (98.7%)
71499 lines ported (99.8%)
Show graph

The unported dependencies are