/-
Copyright 2025 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import Mathlib.Data.Finset.Powerset@[expose] public sectionnamespace Finsetvariable {α : Type*} [DecidableEq α] {s t : Finset α} {n : ℕ}attribute [gcongr] powersetCard_monolemma powersetCard_inter : powersetCard n (s ∩ t) = powersetCard n s ∩ powersetCard n t := α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αn:ℕ⊢ powersetCard n (s ∩ t) = powersetCard n s ∩ powersetCard n t
α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αn:ℕa✝:Finset α⊢ a✝ ∈ powersetCard n (s ∩ t) ↔ a✝ ∈ powersetCard n s ∩ powersetCard n t; All goals completed! 🐙@[simp] lemma disjoint_powersetCard_powersetCard :
Disjoint (powersetCard n s) (powersetCard n t) ↔ #(s ∩ t) < n := α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αn:ℕ⊢ Disjoint (powersetCard n s) (powersetCard n t) ↔ #(s ∩ t) < n
All goals completed! 🐙
The (#t + 1)-subsets of s that contain t ⊆ s are exactly the sets insert a t with
a ∈ s \ t.
All goals completed! 🐙
· mpr α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ su:Finset α⊢ (∃ a, (a ∈ s ∧ a ∉ t) ∧ insert a t = u) → (u ⊆ s ∧ #u = #t + 1) ∧ t ⊆ u rintro ⟨a, ⟨has, hat⟩, rfl⟩ mpr α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αhas:a ∈ shat:a ∉ t⊢ (insert a t ⊆ s ∧ #(insert a t) = #t + 1) ∧ t ⊆ insert a t
exact ⟨⟨insert_subset has h, card_insert_of_notMem hat⟩, subset_insert _ _⟩ All goals completed! 🐙
A k-subset t of s lies in exactly #s - k of the (k + 1)-subsets of s.
lemma card_filter_subset_powersetCard_card_add_one (h : t ⊆ s) :
#((powersetCard (#t + 1) s).filter (t ⊆ ·)) = #s - #t := by α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ #({x ∈ powersetCard (#t + 1) s | t ⊆ x}) = #s - #t
rw [filter_subset_powersetCard_card_add_one h, α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ #(image (fun x ↦ insert x t) (s \ t)) = #s - #t α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ Set.InjOn (fun x ↦ insert x t) ↑(s \ t) card_image_of_injOn, α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ #(s \ t) = #s - #tα:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ Set.InjOn (fun x ↦ insert x t) ↑(s \ t) α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ Set.InjOn (fun x ↦ insert x t) ↑(s \ t) card_sdiff_of_subset h α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ #s - #t = #s - #tα:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ Set.InjOn (fun x ↦ insert x t) ↑(s \ t) α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ Set.InjOn (fun x ↦ insert x t) ↑(s \ t)] α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ Set.InjOn (fun x ↦ insert x t) ↑(s \ t)
intro a ha b _ hab α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) b⊢ a = b
have : a ∈ insert b t := by α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ s⊢ #({x ∈ powersetCard (#t + 1) s | t ⊆ x}) = #s - #t α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a ∈ insert b t⊢ a = b
rw [← show insert a t = insert b t from hab α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) b⊢ a ∈ insert a t α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) b⊢ a ∈ insert a t α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a ∈ insert b t⊢ a = b] α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) b⊢ a ∈ insert a t α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a ∈ insert b t⊢ a = b
exact mem_insert_self a t α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a ∈ insert b t⊢ a = b α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a ∈ insert b t⊢ a = b
rw [mem_insert α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a = b ∨ a ∈ t⊢ a = b α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a = b ∨ a ∈ t⊢ a = b] at this α:Type u_1inst✝:DecidableEq αs:Finset αt:Finset αh:t ⊆ sa:αha:a ∈ ↑(s \ t)b:αa✝:b ∈ ↑(s \ t)hab:(fun x ↦ insert x t) a = (fun x ↦ insert x t) bthis:a = b ∨ a ∈ t⊢ a = b
exact this.resolve_right (mem_sdiff.1 ha).2 All goals completed! 🐙end Finset