defbaseGraph (G : PortGraphVD) (accepts : EdgeVD→A→A→Bool)
(reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b) :
ConstraintGraphV (EdgeVD) Awhere
defpathAccepts (G : PortGraphVD) (accepts : EdgeVD→A→A→Bool)
(n : Nat) (selectors : ∀ v, AddressSelectorG (n + 1) v)
(w : WalkVD (n + 1)) (a b : PaddedLabelD (n + 1) A) : Bool:=
body · 4
lines
decide (∀k : Fin (n + 1),
accepts (edgeAt G n w k)
(decode (selectors w.1) a (tailFromStart G n w k))
(decode (selectors (endpoint G w)) b (headFromEnd G n w k)) = true)
theorempathAccepts_eq_true_iff (G : PortGraphVD)
(accepts : EdgeVD→A→A→Bool)
(n : Nat) (selectors : ∀ v, AddressSelectorG (n + 1) v)
(w : WalkVD (n + 1)) (a b : PaddedLabelD (n + 1) A) :
pathAccepts G accepts n selectors w a b = true↔∀k : Fin (n + 1),
accepts (edgeAt G n w k)
(decode (selectors w.1) a (tailFromStart G n w k))
(decode (selectors (endpoint G w)) b (headFromEnd G n w k)) = true:=by
reverse := reverseDart VD n
reverse_involutive := reverseDart_involutive VD n
tail d :=if d.1then endpoint G d.2else d.2.1
accepts d a b :=if d.1then pathAccepts G accepts n selectors d.2 b a
else pathAccepts G accepts n selectors d.2 a b
reverse_accepts :=by
rintro ⟨direction, w⟩ a b
cases direction <;> rfl
theorempathAccepts_honest (G : PortGraphVD)
(accepts : EdgeVD→A→A→Bool) (n : Nat)
(selectors : ∀ v, AddressSelectorG (n + 1) v)
(assignment : V→A)
(satisfies : ∀ e, accepts e (assignment e.1) (assignment (G.rot e).1) = true)
(w : WalkVD (n + 1)) :
pathAccepts G accepts n selectors w
(honestLabels G (n + 1) assignment w.1)
(honestLabels G (n + 1) assignment (endpoint G w)) = true:=by
proof · 4
lines
apply (pathAccepts_eq_true_iff G accepts n selectors w _ _).2
intro k
simpa only [honestLabels, decode_encode, tailFromStart_val, headFromEnd_val] using
satisfies (edgeAt G n w k)
theorempreserves_satisfiability (G : PortGraphVD)
(accepts : EdgeVD→A→A→Bool)
(reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b)
(n : Nat) (selectors : ∀ v, AddressSelectorG (n + 1) v)
(h : (baseGraph G accepts reverse_accepts).Satisfiable) :
(poweredGraph G accepts n selectors).Satisfiable:=by
proof · 5
lines
obtain ⟨assignment, satisfies⟩ := h
refine ⟨honestLabels G (n + 1) assignment, ?_⟩
apply perfect_completeness G accepts n selectors assignment
intro e
exact satisfies e
theoremdecodedBad_rot (G : PortGraphVD)
(accepts : EdgeVD→A→A→Bool)
(reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b)
(assignment : V→A) (e : EdgeVD) :
decodedBad G accepts assignment (G.rot e) = decodedBad G accepts assignment e :=by
proof · 3
lines
have h := congrArg Bool.not
(reverse_accepts e (assignment e.1) (assignment (G.rot e).1))
simpa only [decodedBad, G.rot_involutive e] using h
decodedBad G accepts assignment (edgeAt G n w k) = true∧
opinionAt G (n + 1) selectors labels fallback (edgeAt G n w k).1 w.1 =
assignment (edgeAt G n w k).1∧
opinionAt G (n + 1) selectors labels fallback
(G.rot (edgeAt G n w k)).1 (endpoint G w) =
assignment (G.rot (edgeAt G n w k)).1
theoremwitness_implies_path_rejection (G : PortGraphVD)
(accepts : EdgeVD→A→A→Bool) (n : Nat)
(selectors : ∀ v, AddressSelectorG (n + 1) v)
(labels : V→PaddedLabelD (n + 1) A) (fallback : A)
(assignment : V→A) (w : WalkVD (n + 1)) (k : Fin (n + 1))
(h : witness G accepts n selectors labels fallback assignment w k) :
pathAccepts G accepts n selectors w (labels w.1) (labels (endpoint G w)) = false:=by
proof · 19
lines
obtain ⟨hBad, hTail, hHead⟩ := h
havehTailDecode :
decode (selectors w.1) (labels w.1) (tailFromStart G n w k) =
assignment (edgeAt G n w k).1:=
(opinionAt_eq_decode G (n + 1) selectors labels fallback w.1
(tailFromStart G n w k)).symm.trans hTail
havehHeadDecode :
decode (selectors (endpoint G w)) (labels (endpoint G w))
(headFromEnd G n w k) = assignment (G.rot (edgeAt G n w k)).1:=
(opinionAt_eq_decode G (n + 1) selectors labels fallback (endpoint G w)
(headFromEnd G n w k)).symm.trans hHead
have hFalse := (decodedBad_eq_true_iff G accepts assignment (edgeAt G n w k)).1 hBad
cases hPath : pathAccepts G accepts n selectors w
(labels w.1) (labels (endpoint G w)) with
| false=> rfl
| true=>have hChecked := (pathAccepts_eq_true_iff G accepts n selectors w _ _).1 hPath k
rw [hTailDecode, hHeadDecode, hFalse] at hChecked
exact False.elim (Bool.noConfusion hChecked)