theoremexists_subset_card_slot_injective
{PIJ : Type*} [DecidableEqP] [DecidableEqI] [DecidableEqJ]
(left : P→I) (right : P→J) (Dh : ℕ) (S : FinsetP)
(hleft : ∀ i, (S.filter fun x => left x = i).card ≤D)
(hright : ∀ j, (S.filter fun x => right x = j).card ≤D)
(hlarge : 2 * D * h < S.card) :
∃T : FinsetP, T⊆S∧T.card = h ∧Set.InjOn left (T : SetP) ∧Set.InjOn right (T : SetP) :=by
proof · 62
lines
classical
induction h generalizing Swith
| zero =>
refine ⟨∅, Finset.empty_subset S, by simp, ?_, ?_⟩
· simpa only [Finset.coe_empty] usingSet.injOn_empty left
· simpa only [Finset.coe_empty] usingSet.injOn_empty right
| succ h ih =>
obtain ⟨x, hx⟩ :=Finset.card_pos.mp
(lt_of_le_of_lt (Nat.zero_le _) hlarge)
letB:= (S.filter fun y => left y = left x) ∪
(S.filter fun y => right y = right x)
letU:=S \ BhavehUS : U⊆S:=Finset.sdiff_subset
havehB : B.card ≤2 * D:=bycalcB.card ≤ (S.filter fun y => left y = left x).card +
(S.filter fun y => right y = right x).card :=Finset.card_union_le _ _
_ ≤D + D:=Nat.add_le_add (hleft (left x)) (hright (right x))
_ = 2 * D:= (Nat.two_mul D).symm
havehUlarge : 2 * D * h < U.card :=byhavehcount : S.card ≤U.card + B.card :=Finset.card_le_card_sdiff_add_card
havehexpand : 2 * D * h + 2 * D < S.card :=by
simpa only [Nat.mul_succ] using hlarge
havehsum : 2 * D * h + 2 * D < U.card + 2 * D:=
hexpand.trans_le (hcount.trans (Nat.add_le_add_left hB U.card))
exact Nat.add_lt_add_iff_right.mp hsum
havehUleft : ∀ i, (U.filter fun y => left y = i).card ≤D:=by
intro i
exact (Finset.card_le_card
(Finset.filter_subset_filter (fun y => left y = i) hUS)).trans (hleft i)
havehUright : ∀ j, (U.filter fun y => right y = j).card ≤D:=by
intro j
exact (Finset.card_le_card
(Finset.filter_subset_filter (fun y => right y = j) hUS)).trans (hright j)
obtain ⟨T, hTU, hcard, hTL, hTR⟩ := ih U hUleft hUright hUlarge
have havoid (y : P) (hy : y ∈T) :
left y ≠ left x ∧ right y ≠ right x :=byhave hyU :=Finset.mem_sdiff.mp (hTU hy)
constructor
· intro heq
exact hyU.2 (Finset.mem_union.mpr
(Or.inl (Finset.mem_filter.mpr ⟨hyU.1, heq⟩)))
· intro heq
exact hyU.2 (Finset.mem_union.mpr
(Or.inr (Finset.mem_filter.mpr ⟨hyU.1, heq⟩)))
havehxT : x ∉T:=fun hxT => (havoid x hxT).1 rfl
refine ⟨insert x T, ?_, ?_, ?_, ?_⟩
· intro y hy
rcases Finset.mem_insert.mp hy with rfl | hy
· exact hx
· exact hUS (hTU hy)
· rw [Finset.card_insert_of_notMem hxT, hcard]
· rw [Finset.coe_insert]
refine (Set.injOn_insert hxT).2 ⟨hTL, ?_⟩
rintro ⟨y, hy, heq⟩
exact (havoid y hy).1 heq
· rw [Finset.coe_insert]
refine (Set.injOn_insert hxT).2 ⟨hTR, ?_⟩
rintro ⟨y, hy, heq⟩
exact (havoid y hy).2 heq
theoremexists_disjoint_coordinate_sample
{PIJ : Type*} [DecidableEqP] [DecidableEqI] [DecidableEqJ]
(S : FinsetP) (left : P→I) (right : P→J) (Dh : ℕ)
(hleft : ∀ i, (S.filter fun x => left x = i).card ≤D)
(hright : ∀ j, (S.filter fun x => right x = j).card ≤D)
(hlarge : 2 * D * h < S.card) :
∃e : Fin h ↪ ↥S,
Function.Injective (fun k => left (e k).val) ∧Function.Injective (fun k => right (e k).val) :=by
proof · 22
lines
classical
obtain ⟨T, hTS, hcard, hTL, hTR⟩ :=
exists_subset_card_slot_injective left right D h S hleft hright hlarge
letq : Fin h ≃ ↥T:= (Finset.equivFinOfCardEq (s :=T) hcard).symm
lete : Fin h ↪ ↥S:=
{ toFun :=fun k => ⟨(q k).val, hTS (q k).property⟩
inj' :=by
intro i j hij
apply q.injective
apply Subtype.ext
exact congrArg (funx : ↥S=> x.val) hij }
refine ⟨e, ?_, ?_⟩
· intro i j hij
apply q.injective
apply Subtype.ext
change left (q i).val = left (q j).val at hij
exact hTL (q i).property (q j).property hij
· intro i j hij
apply q.injective
apply Subtype.ext
change right (q i).val = right (q j).val at hij
exact hTR (q i).property (q j).property hij