cfahlgren1's picture
download
raw
4.39 kB
import Mathlib
import OAI.Computability.VertexCover.PCP.PoweringLabels
namespace OAI
namespace UniqueGames.Foundations.PCP.PoweringReach
open PoweringWalks PoweringLabels
variable {V D : Type*}
def ReachLE (G : PortGraph V D) (t : Nat) (u v : V) : Prop :=
∃ l, l ≤ t ∧ ∃ p : Fin l → D, wordEnd G l u p = v
theorem reach_refl (G : PortGraph V D) (t : Nat) (u : V) : ReachLE G t u u :=
⟨0, Nat.zero_le t, Fin.elim0, rfl⟩
theorem reach_mono {G : PortGraph V D} {s t : Nat} {u v : V}
(hst : s ≤ t) (h : ReachLE G s u v) : ReachLE G t u v := by
obtain ⟨l, hl, p, hp⟩ := h
exact ⟨l, hl.trans hst, p, hp⟩
theorem reach_prepend (G : PortGraph V D) {t : Nat} (u : V) (d : D) {v : V}
(h : ReachLE G t (next G u d) v) : ReachLE G (t + 1) u v := by
obtain ⟨l, hl, p, hp⟩ := h
refine ⟨l + 1, Nat.succ_le_succ hl,
(fun i : Fin (l + 1) => Fin.cases d p i), ?_⟩
simpa only [wordEnd, Fin.cases_zero, Fin.cases_succ] using hp
def reversePorts (G : PortGraph V D) : V → List D → List D
| _, [] => []
| v, d :: ds => reversePorts G (next G v d) ds ++ [(G.rot (v, d)).2]
theorem reversePorts_length (G : PortGraph V D) (v : V) (ds : List D) :
(reversePorts G v ds).length = ds.length := by
induction ds generalizing v with
| nil => rfl
| cons d ds ih => simp [reversePorts, ih]
theorem walkEnd_reversePorts (G : PortGraph V D) (v : V) (ds : List D) :
walkEnd G (walkEnd G v ds) (reversePorts G v ds) = v := by
induction ds generalizing v with
| nil => rfl
| cons d ds ih =>
change walkEnd G (walkEnd G (next G v d) ds)
(reversePorts G (next G v d) ds ++ [(G.rot (v, d)).2]) = v
rw [walkEnd_append, ih]
change (G.rot (G.rot (v, d))).1 = v
exact congrArg Prod.fst (G.rot_involutive (v, d))
theorem wordEnd_eq_walkEnd_ofFn (G : PortGraph V D) :
∀ n v (p : Fin n → D), wordEnd G n v p = walkEnd G v (List.ofFn p) := by
intro n
induction n with
| zero => intro v p; rfl
| succ n ih =>
intro v p
rw [List.ofFn_succ, walkEnd_cons]
exact ih (next G v (p 0)) (fun j => p j.succ)
theorem reach_reverse {G : PortGraph V D} {t : Nat} {u v : V}
(h : ReachLE G t u v) : ReachLE G t v u := by
obtain ⟨l, hl, p, hp⟩ := h
refine ⟨(reversePorts G u (List.ofFn p)).length, ?_,
(reversePorts G u (List.ofFn p)).get, ?_⟩
· simpa only [reversePorts_length, List.length_ofFn] using hl
· rw [wordEnd_eq_walkEnd_ofFn, List.ofFn_get]
have hlist : walkEnd G u (List.ofFn p) = v := by
rw [← wordEnd_eq_walkEnd_ofFn]
exact hp
rw [← hlist, walkEnd_reversePorts]
theorem tail_reach (G : PortGraph V D) :
∀ (n : Nat) (w : Walk V D (n + 1)) (k : Fin (n + 1)),
ReachLE G (n + 1) w.1 (edgeAt G n w k).1 := by
intro n
induction n with
| zero =>
intro w k
exact reach_refl G 1 w.1
| succ n ih =>
intro w k
refine Fin.cases ?_ (fun j => ?_) k
· exact reach_refl G (n + 2) w.1
· exact reach_prepend G w.1 (w.2 0) (ih (advanceTail G w) j)
theorem head_reach_endpoint (G : PortGraph V D) :
∀ (n : Nat) (w : Walk V D (n + 1)) (k : Fin (n + 1)),
ReachLE G (n + 1) (G.rot (edgeAt G n w k)).1 (endpoint G w) := by
intro n
induction n with
| zero =>
intro w k
exact reach_refl G 1 (G.rot (w.1, w.2 0)).1
| succ n ih =>
intro w k
refine Fin.cases ?_ (fun j => ?_) k
· exact ⟨n + 1, Nat.le_succ (n + 1), (fun j => w.2 j.succ), rfl⟩
· exact reach_mono (Nat.le_succ (n + 1)) (ih (advanceTail G w) j)
def tailFromStart (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1))
(k : Fin (n + 1)) : Ball G (n + 1) w.1 :=
⟨(edgeAt G n w k).1, tail_reach G n w k⟩
def headFromEnd (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1))
(k : Fin (n + 1)) : Ball G (n + 1) (endpoint G w) :=
⟨(G.rot (edgeAt G n w k)).1, reach_reverse (head_reach_endpoint G n w k)⟩
@[simp] theorem tailFromStart_val (G : PortGraph V D) (n : Nat)
(w : Walk V D (n + 1)) (k : Fin (n + 1)) :
(tailFromStart G n w k).val = (edgeAt G n w k).1 := rfl
@[simp] theorem headFromEnd_val (G : PortGraph V D) (n : Nat)
(w : Walk V D (n + 1)) (k : Fin (n + 1)) :
(headFromEnd G n w k).val = (G.rot (edgeAt G n w k)).1 := rfl
end UniqueGames.Foundations.PCP.PoweringReach
end OAI

Xet Storage Details

Size:
4.39 kB
·
Xet hash:
127824fb24cfe2040b86bf58397bf809459076b023bb6d08d0cbe7609df9b2d8

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