Skip to content

Commit be18f02

Browse files
committed
Use Numbering to define NumberingOn; not working yet
1 parent 0bc5775 commit be18f02

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

LeanCamCombi/ProbLYM.lean

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ in mathlib because we need the special property `set_prefix_subset` below. -/
4343
def Numbering (α : Type*) [Fintype α] := α ≃ Fin (card α)
4444

4545
@[reducible]
46-
def NumberingOn {α : Type*} (s : Finset α) := {x // x ∈ s} ≃ Fin s.card
46+
def NumberingOn {α : Type*} (s : Finset α) := Numbering s
47+
--def NumberingOn {α : Type*} (s : Finset α) := {x // x ∈ s} ≃ Fin s.card
4748

4849
variable {α : Type*} [Fintype α] [DecidableEq α]
4950

@@ -52,7 +53,7 @@ theorem card_Numbering : card (Numbering α) = (card α).factorial := by
5253

5354
omit [Fintype α] in
5455
theorem card_NumberingOn (s : Finset α) : card (NumberingOn s) = s.card.factorial := by
55-
simp only [NumberingOn]
56+
simp only [NumberingOn, Numbering]
5657
have h1 : card {x // x ∈ s} = card (Fin s.card) := by simp
5758
have h2 : {x // x ∈ s} ≃ Fin s.card := by exact Fintype.equivOfCardEq h1
5859
simp [Fintype.card_equiv h2]
@@ -68,21 +69,23 @@ theorem subset_IsPrefix_IsPrefix {s1 s2 : Finset α} {f : Numbering α}
6869
intro a h_as1
6970
exact (h_s2 a).mpr (lt_of_lt_of_le ((h_s1 a).mp h_as1) h_card)
7071

71-
def equiv_IsPrefix_NumberingOn2 (s : Finset α) : {f // IsPrefix s f} ≃ NumberingOn s × NumberingOn sᶜ where
72+
def equiv_IsPrefix_NumberingOn2 (s : Finset α) :
73+
{f // IsPrefix s f} ≃ NumberingOn s × NumberingOn sᶜ where
7274
toFun := fun ⟨f, hf⟩ ↦
7375
({
74-
toFun := fun ⟨x, hx⟩ ↦ ⟨f x, by rwa [← hf x]⟩
75-
invFun := fun ⟨n, hn⟩ ↦ ⟨f.symm ⟨n, by have := s.card_le_univ; omega⟩, by rw [hf]; simpa⟩
76+
toFun := fun ⟨x, hx⟩ ↦ ⟨f x, by rwa [card_coe, ← hf x]⟩
77+
invFun := fun ⟨n, hn⟩ ↦ ⟨f.symm ⟨n, by rw [card_coe] at hn ; have := s.card_le_univ; omega⟩,
78+
by rw [hf]; rw [card_coe] at hn; simpa⟩
7679
left_inv := by rintro ⟨x, hx⟩; simp
7780
right_inv := by rintro ⟨n, hn⟩; simp
7881
},
7982
{
8083
toFun := fun ⟨x, hx⟩ ↦ ⟨f x - s.card, by
8184
rw [s.mem_compl, hf] at hx
82-
rw [s.card_compl]
85+
rw [card_coe, s.card_compl]
8386
exact Nat.sub_lt_sub_right (by omega) (by omega)
8487
85-
invFun := fun ⟨n, hn⟩ ↦ ⟨f.symm ⟨n + s.card, by rw [s.card_compl] at hn; omega⟩,
88+
invFun := fun ⟨n, hn⟩ ↦ ⟨f.symm ⟨n + s.card, by rw [card_coe, s.card_compl] at hn; omega⟩,
8689
by rw [s.mem_compl, hf]; simp⟩
8790
left_inv := by
8891
rintro ⟨x, hx⟩
@@ -96,12 +99,14 @@ def equiv_IsPrefix_NumberingOn2 (s : Finset α) : {f // IsPrefix s f} ≃ Number
9699
if hx : x ∈ s then
97100
g ⟨x, hx⟩ |>.castLE s.card_le_univ
98101
else
99-
g' ⟨x, by simpa⟩ |>.addNat s.card |>.cast (by simp)
102+
g' ⟨x, by simpa⟩ |>.addNat s.card |>.cast (
103+
by simp [card_coe] ; have := s.card_le_univ ; omega
104+
)
100105
invFun := fun ⟨n, hn⟩ ↦
101106
if hn' : n < s.card then
102107
g.symm ⟨n, hn'⟩
103108
else
104-
g'.symm ⟨n - s.card, by rw [s.card_compl]; omega⟩
109+
g'.symm ⟨n - s.card, by rw [card_coe, s.card_compl]; omega⟩
105110
left_inv := by intro x; by_cases hx : x ∈ s <;> simp [hx]
106111
right_inv := by
107112
rintro ⟨n, hn⟩

0 commit comments

Comments
 (0)