cfahlgren1/math / lean /OAI /InformationTheory /Entanglement /CombinatorialOrder.lean
cfahlgren1's picture
download
raw
4.97 kB
10
instance baseLinearOrder : LinearOrder Base := LinearOrder.lift'
body · 5 lines
  (fun A => A.val.sort (· ≤ ·)) (by
    intro A B h
    apply Subtype.ext
    have he := congrArg List.toFinset h
    simpa only [Finset.sort_toFinset] using he)
16
instance (priority := 2000) baseLE : LE Base := baseLinearOrder.toLE
17
instance (priority := 2000) baseLT : LT Base := baseLinearOrder.toLT
19
instance questionLinearOrder : LinearOrder Question := LinearOrder.lift'
body · 4 lines
  (fun q => [q.1,q.2.1,q.2.2]) (by
    intro q r h
    simp only [List.cons.injEq,and_true] at h
    exact Prod.ext h.1 (Prod.ext h.2.1 h.2.2))
25
instance (priority := 2000) questionLE : LE Question := questionLinearOrder.toLE
26
instance (priority := 2000) questionLT : LT Question := questionLinearOrder.toLT
27
abbrev Eight := {S : Finset Question // S.card=8}
28
instance eightLinearOrder : LinearOrder Eight := LinearOrder.lift'
body · 5 lines
  (fun S => S.val.sort (· ≤ ·)) (by
    intro S T h
    apply Subtype.ext
    have he := congrArg List.toFinset h
    simpa only [Finset.sort_toFinset] using he)
34
instance (priority := 2000) eightLE : LE Eight := eightLinearOrder.toLE
35
instance (priority := 2000) eightLT : LT Eight := eightLinearOrder.toLT
36
lemma eight_card : Fintype.card Eight=L := by
proof · 1 line
  rw [L_def,Fintype.card_finset_len,question_card]
39
def six (S : Eight) (t : Fin 6) : Question :=
body · 1 line
  S.val.orderEmbOfFin S.property (Fin.castLE (by decide) t)
41
lemma six_mem (S : Eight) (t : Fin 6) : six S t ∈ S.val :=
proof · 1 line
  S.val.orderEmbOfFin_mem S.property _
43
lemma six_injective (S : Eight) : Function.Injective (six S) :=
proof · 1 line
  (S.val.orderEmbOfFin S.property).injective.comp (Fin.castLE_injective (by decide))
46
def OrthogonalEight (S : Eight) : Prop :=
body · 1 line
  Clique (fun q r => ProjectionCriterion.correlation u q r=0) S.val
49
def contextAt (S : Eight) (q : Question) : Option (Fin 6) := by
body · 4 lines
  classical
  exact if OrthogonalEight S then
    if h : ∃ t, six S t=q then some (Classical.choose h) else none
  else none
54
lemma contextAt_six (S : Eight) (hS : OrthogonalEight S) (t : Fin 6) :
    contextAt S (six S t)=some t := by
proof · 4 lines
  unfold contextAt
  rw [ite_eq_left hS,dite_eq_left (show ∃ t', six S t'=six S t from ⟨t,rfl⟩)]
  congr 1
  exact six_injective S (Classical.choose_spec (show ∃ t', six S t'=six S t from ⟨t,rfl⟩))
60
lemma contextAt_some (S : Eight) (q : Question) (t : Fin 6)
    (ht : contextAt S q=some t) : OrthogonalEight S ∧ six S t=q := by
proof · 6 lines
  unfold contextAt at ht
  split_ifs at ht with ho he
  · have heq := Option.some.inj ht
    refine ⟨ho,?_⟩
    rw [← heq]
    exact Classical.choose_spec he
69
abbrev OutputCoordinate := Eight → Four
70
abbrev Label := Question × (Eight → Outcome)
71
lemma four_card : Fintype.card Four=4 := rfl
72
lemma outcome_card : Fintype.card Outcome=4 := rfl
74
lemma card_arrow_eq {α β : Type} [Fintype α] [Fintype β] [DecidableEq α]
    {a b : ℕ} (ha : Fintype.card α=a) (hb : Fintype.card β=b) :
    Fintype.card (α → β)=b^a := by rw [Fintype.card_fun,ha,hb]
77
lemma card_pair_eq {α β : Type} [Fintype α] [Fintype β]
    {a b : ℕ} (ha : Fintype.card α=a) (hb : Fintype.card β=b) :
    Fintype.card (α × β)=a*b := by rw [Fintype.card_prod,ha,hb]
80
lemma output_card : Fintype.card OutputCoordinate=D := by
proof · 2 lines
  have he := card_arrow_eq eight_card four_card
  exact he
83
lemma outcomeString_card : Fintype.card (Eight → Outcome)=D := by
proof · 2 lines
  have he := card_arrow_eq eight_card outcome_card
  exact he
86
lemma label_card : Fintype.card Label=m := by
proof · 2 lines
  have he := card_pair_eq question_card outcomeString_card
  exact he
90
instance fourLinearOrder : LinearOrder Four :=
body · 1 line
  LinearOrder.lift' (toLex : Four ≃ Lex Four) toLex.injective
92
instance (priority := 2000) fourLE : LE Four := fourLinearOrder.toLE
93
instance (priority := 2000) fourLT : LT Four := fourLinearOrder.toLT
94
instance eightWellFounded : @WellFoundedLT Eight eightLinearOrder.toLT :=
body · 1 line
  @Finite.to_wellFoundedLT Eight inferInstance eightLinearOrder.toPreorder
97
instance outputLinearOrder : LinearOrder OutputCoordinate :=
body · 1 line
  LinearOrder.lift' (toLex : OutputCoordinate ≃ Lex OutputCoordinate) toLex.injective
99
instance labelLinearOrder : LinearOrder Label :=
body · 1 line
  LinearOrder.lift' (toLex : Label ≃ Lex Label) toLex.injective
102
def orderedEnumeration {τ : Type} [Fintype τ] [LinearOrder τ] {n : ℕ}
    (hc : Fintype.card τ=n) : Fin n ≃ τ :=
body · 5 lines
  ((Finset.univ : Finset τ).orderIsoOfFin (by simpa using hc)).toEquiv.trans
    { toFun := Subtype.val
      invFun := fun x => ⟨x,Finset.mem_univ x⟩
      left_inv := fun x => by cases x; rfl
      right_inv := fun x => rfl }
109
def outputEnumeration : Fin D ≃ OutputCoordinate := orderedEnumeration output_card
110
def labelEnumeration : Fin m ≃ Label := orderedEnumeration label_card

Xet Storage Details

Size:
4.97 kB
·
Xet hash:
c0d726aed1ef4536dc3a97165dcd9f0e4cfed71d31e7bcd896ffc4a01c2c025c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.