cfahlgren1/math / lean /OAI /Computability /VertexCover /PCP /DegreeReplacement.lean
cfahlgren1's picture
download
raw
10.5 kB
import Mathlib
import OAI.Computability.VertexCover.PCP.PortTables
namespace OAI
open scoped BigOperators
namespace UniqueGames.Foundations.PCP.DegreeReplacement
open PoweringWalks
variable {V E A D : Type*}
abbrev Cloud (G : ConstraintGraph V E A) (v : V) := {e : E // G.tail e = v}
def cloudIndexEquiv (G : ConstraintGraph V E A) :
(E × D) ≃ (Σ v : V, Cloud G v × D) where
toFun p := ⟨G.tail p.1, (⟨p.1, rfl⟩, p.2)⟩
invFun p := (p.2.1.val, p.2.2)
left_inv _ := rfl
right_inv := by
rintro ⟨v, ⟨⟨e, he⟩, d⟩⟩
cases he
rfl
def cloudRotation (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
(Σ v : V, Cloud G v × D) ≃ (Σ v : V, Cloud G v × D) :=
Equiv.sigmaCongrRight (fun v => (H v).rot)
theorem cloudRotation_involutive (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
Function.Involutive (cloudRotation G H) := by
rintro ⟨v, p⟩
change (⟨v, (H v).rot ((H v).rot p)⟩ : Σ v : V, Cloud G v × D) = ⟨v, p⟩
rw [(H v).rot_involutive p]
def innerRotation (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) : (E × D) ≃ (E × D) :=
((cloudIndexEquiv G).trans (cloudRotation G H)).trans (cloudIndexEquiv G).symm
theorem innerRotation_involutive (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
Function.Involutive (innerRotation G H) := by
intro p
apply (cloudIndexEquiv G).injective
simp only [innerRotation, Equiv.trans_apply, Equiv.apply_symm_apply]
exact cloudRotation_involutive G H _
theorem innerRotation_tail (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) (e : E) (d : D) :
G.tail (innerRotation G H (e, d)).1 = G.tail e := by
change G.tail (((H (G.tail e)).rot (⟨e, rfl⟩, d)).1.val) = G.tail e
exact ((H (G.tail e)).rot (⟨e, rfl⟩, d)).1.property
def replacementStep (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) : E × (D ⊕ Unit) → E × (D ⊕ Unit)
| (e, Sum.inl d) =>
let p := innerRotation G H (e, d)
(p.1, Sum.inl p.2)
| (e, Sum.inr u) => (G.reverse e, Sum.inr u)
theorem replacementStep_involutive (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
Function.Involutive (replacementStep G H) := by
rintro ⟨e, p⟩
rcases p with d | u
· change ((innerRotation G H (innerRotation G H (e, d))).1,
(Sum.inl ((innerRotation G H (innerRotation G H (e, d))).2) : D ⊕ Unit)) =
(e, Sum.inl d)
rw [innerRotation_involutive G H (e, d)]
· change (G.reverse (G.reverse e), (Sum.inr u : D ⊕ Unit)) = (e, Sum.inr u)
rw [G.reverse_involutive e]
def replacementPortGraph (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) : PortGraph E (D ⊕ Unit) where
rot :=
{ toFun := replacementStep G H
invFun := replacementStep G H
left_inv := replacementStep_involutive G H
right_inv := replacementStep_involutive G H }
rot_involutive := replacementStep_involutive G H
def replacementGraph [DecidableEq A] (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
ConstraintGraph E (E × (D ⊕ Unit)) A where
reverse := (replacementPortGraph G H).rot
reverse_involutive := (replacementPortGraph G H).rot_involutive
tail := Prod.fst
accepts p a b := match p.2 with
| Sum.inl _ => decide (a = b)
| Sum.inr _ => G.accepts p.1 a b
reverse_accepts := by
rintro ⟨e, p⟩ a b
rcases p with d | u
· change decide (b = a) = decide (a = b)
simp [eq_comm]
· exact G.reverse_accepts e a b
def liftLabel (G : ConstraintGraph V E A) (labeling : V → A) : E → A :=
fun e => labeling (G.tail e)
@[simp] theorem replacement_satisfied_inl [DecidableEq A]
(G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D)
(labeling : V → A) (e : E) (d : D) :
(replacementGraph G H).edgeSatisfied (liftLabel G labeling) (e, Sum.inl d) =
true := by
change decide (labeling (G.tail e) =
labeling (G.tail (innerRotation G H (e, d)).1)) = true
rw [innerRotation_tail G H e d]
simp
@[simp] theorem replacement_satisfied_inr [DecidableEq A]
(G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D)
(labeling : V → A) (e : E) (u : Unit) :
(replacementGraph G H).edgeSatisfied (liftLabel G labeling) (e, Sum.inr u) =
G.edgeSatisfied labeling e := rfl
theorem replacement_complete [DecidableEq A]
(G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D)
(labeling : V → A) (h : ∀ e, G.edgeSatisfied labeling e = true) :
∀ p, (replacementGraph G H).edgeSatisfied (liftLabel G labeling) p = true := by
rintro ⟨e, p⟩
rcases p with d | u
· exact replacement_satisfied_inl G H labeling e d
· rw [replacement_satisfied_inr]
exact h e
theorem replacement_satisfiable [DecidableEq A]
(G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D)
(h : G.Satisfiable) : (replacementGraph G H).Satisfiable := by
obtain ⟨labeling, hlabeling⟩ := h
exact ⟨liftLabel G labeling, replacement_complete G H labeling hlabeling⟩
theorem rejectionCount_eq_sum [Fintype E] (G : ConstraintGraph V E A)
(labeling : V → A) :
G.rejectionCount labeling =
∑ e, if G.edgeSatisfied labeling e = false then 1 else 0 := by
classical
simp only [ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts,
Finset.card_eq_sum_ones, Finset.sum_filter]
theorem replacement_rejectionCount [Fintype E] [Fintype D] [DecidableEq A]
(G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D)
(labeling : V → A) :
(replacementGraph G H).rejectionCount (liftLabel G labeling) =
G.rejectionCount labeling := by
classical
simp only [rejectionCount_eq_sum, Fintype.sum_prod_type, Fintype.sum_sum_type]
simp
simp only [Finset.card_filter]
apply Finset.sum_congr rfl
intro e he
by_cases h : G.edgeSatisfied labeling e = false <;> simp only [h, ite_true]
abbrev PaddedDart (_G : ConstraintGraph V E A) (dummy : V → Type*) :=
E ⊕ (Σ v : V, dummy v)
def paddedOwner (G : ConstraintGraph V E A) (dummy : V → Type*) :
PaddedDart G dummy → V
| Sum.inl e => G.tail e
| Sum.inr z => z.1
def paddedReverse (G : ConstraintGraph V E A) (dummy : V → Type*) :
PaddedDart G dummy ≃ PaddedDart G dummy :=
Equiv.sumCongr G.reverse (Equiv.refl (Σ v : V, dummy v))
theorem paddedReverse_involutive (G : ConstraintGraph V E A) (dummy : V → Type*) :
Function.Involutive (paddedReverse G dummy) := by
intro z
cases z with
| inl e =>
change (Sum.inl (G.reverse (G.reverse e)) : PaddedDart G dummy) = Sum.inl e
rw [G.reverse_involutive e]
| inr z => rfl
def paddedGraph (G : ConstraintGraph V E A) (dummy : V → Type*) :
ConstraintGraph V (PaddedDart G dummy) A where
reverse := paddedReverse G dummy
reverse_involutive := paddedReverse_involutive G dummy
tail := paddedOwner G dummy
accepts e a b := match e with
| Sum.inl e => G.accepts e a b
| Sum.inr _ => true
reverse_accepts := by
intro e a b
cases e with
| inl e => exact G.reverse_accepts e a b
| inr z => rfl
@[simp] theorem padded_satisfied_inl (G : ConstraintGraph V E A)
(dummy : V → Type*) (labeling : V → A) (e : E) :
(paddedGraph G dummy).edgeSatisfied labeling (Sum.inl e) =
G.edgeSatisfied labeling e := rfl
@[simp] theorem padded_satisfied_inr (G : ConstraintGraph V E A)
(dummy : V → Type*) (labeling : V → A) (z : Σ v : V, dummy v) :
(paddedGraph G dummy).edgeSatisfied labeling (Sum.inr z) = true := rfl
theorem padded_complete (G : ConstraintGraph V E A) (dummy : V → Type*)
(labeling : V → A) (h : ∀ e, G.edgeSatisfied labeling e = true) :
∀ «c», (paddedGraph G dummy).edgeSatisfied labeling «c» = true := by
intro «c»
cases «c» with
| inl e => exact h e
| inr z => rfl
theorem padded_satisfiable (G : ConstraintGraph V E A) (dummy : V → Type*)
(h : G.Satisfiable) : (paddedGraph G dummy).Satisfiable := by
obtain ⟨labeling, hlabeling⟩ := h
exact ⟨labeling, padded_complete G dummy labeling hlabeling⟩
theorem card_paddedDart [Fintype V] [Fintype E] (G : ConstraintGraph V E A)
(dummy : V → Type*) [∀ v, Fintype (dummy v)] :
Fintype.card (PaddedDart G dummy) =
Fintype.card E + ∑ v, Fintype.card (dummy v) := by
rw [Fintype.card_sum, Fintype.card_sigma]
theorem padded_rejectionCount [Fintype V] [Fintype E]
(G : ConstraintGraph V E A) (dummy : V → Type*) [∀ v, Fintype (dummy v)]
(labeling : V → A) :
(paddedGraph G dummy).rejectionCount labeling = G.rejectionCount labeling := by
classical
simp only [rejectionCount_eq_sum, Fintype.sum_sum_type]
simp
simp only [Finset.card_filter]
apply Finset.sum_congr rfl
intro e he
by_cases h : G.edgeSatisfied labeling e = false <;> simp only [h, ite_true]
def paddedReplacementPortGraph (G : ConstraintGraph V E A) (dummy : V → Type*)
(H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) :
PortGraph (PaddedDart G dummy) (D ⊕ Unit) :=
replacementPortGraph (paddedGraph G dummy) H
def paddedReplacementGraph [DecidableEq A]
(G : ConstraintGraph V E A) (dummy : V → Type*)
(H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) :
ConstraintGraph (PaddedDart G dummy) (PaddedDart G dummy × (D ⊕ Unit)) A :=
replacementGraph (paddedGraph G dummy) H
theorem paddedReplacement_rejectionCount
[Fintype V] [Fintype E] [Fintype D] [DecidableEq A]
(G : ConstraintGraph V E A) (dummy : V → Type*) [∀ v, Fintype (dummy v)]
(H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) (labeling : V → A) :
(paddedReplacementGraph G dummy H).rejectionCount
(liftLabel (paddedGraph G dummy) labeling) = G.rejectionCount labeling :=
(replacement_rejectionCount (paddedGraph G dummy) H labeling).trans
(padded_rejectionCount G dummy labeling)
def noDummyEquiv (G : ConstraintGraph V E A) :
PaddedDart G (fun _ : V => Empty) ≃ E where
toFun z := match z with
| Sum.inl e => e
| Sum.inr z => Empty.elim z.2
invFun := Sum.inl
left_inv := by
intro z
cases z with
| inl e => rfl
| inr z => exact Empty.elim z.2
right_inv _ := rfl
end UniqueGames.Foundations.PCP.DegreeReplacement
end OAI

Xet Storage Details

Size:
10.5 kB
·
Xet hash:
7505cfbd4b1de4ebb1cffb63b91087d18cc8cf06e7d3726668c23b91ba1714db

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