Lean 4 · 33
declarations statementsfull
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 body · 7 lines
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
rfldef 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) := body · 1 line
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 proof · 3 lines
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) := body · 1 line
((cloudIndexEquiv G).trans (cloudRotation G H)).trans (cloudIndexEquiv G).symmtheorem innerRotation_involutive (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
Function.Involutive (innerRotation G H) := by proof · 4 lines
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 proof · 2 lines
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.propertydef replacementStep (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) : E × (D ⊕ Unit) → E × (D ⊕ Unit) body · 4 lines
| (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 proof · 8 lines
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 body · 6 lines
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 Hdef replacementGraph [DecidableEq A] (G : ConstraintGraph V E A)
(H : ∀ v, PortGraph (Cloud G v) D) :
ConstraintGraph E (E × (D ⊕ Unit)) A where body · 12 lines
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 bdef liftLabel (G : ConstraintGraph V E A) (labeling : V → A) : E → A := body · 1 line
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 proof · 4 lines
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 proof · 5 lines
rintro ⟨e, p⟩
rcases p with d | u
· exact replacement_satisfied_inl G H labeling e d
· rw [replacement_satisfied_inr]
exact h etheorem replacement_satisfiable [DecidableEq A]
(G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D)
(h : G.Satisfiable) : (replacementGraph G H).Satisfiable := by proof · 2 lines
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 proof · 3 lines
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 proof · 5 lines
classical
simp only [rejectionCount_eq_sum, Fintype.sum_prod_type, Fintype.sum_sum_type]
simp only [replacement_satisfied_inl, replacement_satisfied_inr,
Bool.true_eq_false, ite_false, Fintype.sum_unique, Finset.sum_const_zero, zero_add]
rflabbrev PaddedDart (_G : ConstraintGraph V E A) (dummy : V → Type*) := body · 1 line
E ⊕ (Σ v : V, dummy v)def paddedOwner (G : ConstraintGraph V E A) (dummy : V → Type*) :
PaddedDart G dummy → V body · 2 lines
| Sum.inl e => G.tail e
| Sum.inr z => z.1def paddedReverse (G : ConstraintGraph V E A) (dummy : V → Type*) :
PaddedDart G dummy ≃ PaddedDart G dummy := body · 1 line
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 proof · 6 lines
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 => rfldef paddedGraph (G : ConstraintGraph V E A) (dummy : V → Type*) :
ConstraintGraph V (PaddedDart G dummy) A where body · 11 lines
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 proof · 4 lines
intro c
cases c with
| inl e => exact h e
| inr z => rfltheorem padded_satisfiable (G : ConstraintGraph V E A) (dummy : V → Type*)
(h : G.Satisfiable) : (paddedGraph G dummy).Satisfiable := by proof · 2 lines
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 proof · 1 line
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 proof · 5 lines
classical
simp only [rejectionCount_eq_sum, Fintype.sum_sum_type]
simp only [padded_satisfied_inl, padded_satisfied_inr,
Bool.true_eq_false, ite_false, Finset.sum_const_zero, add_zero]
rfldef paddedReplacementPortGraph (G : ConstraintGraph V E A) (dummy : V → Type*)
(H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) :
PortGraph (PaddedDart G dummy) (D ⊕ Unit) := body · 1 line
replacementPortGraph (paddedGraph G dummy) Hdef 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 := body · 1 line
replacementGraph (paddedGraph G dummy) Htheorem 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 := proof · 2 lines
(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 body · 10 lines
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 _ := rflOutline
- abbrev
Cloud15 - def
cloudIndexEquiv17 - def
cloudRotation27 - theorem
cloudRotation_involutive32 - def
innerRotation39 - theorem
innerRotation_involutive43 - theorem
innerRotation_tail51 - def
replacementStep57 - theorem
replacementStep_involutive64 - def
replacementPortGraph76 - def
replacementGraph85 - def
liftLabel101 - theorem
replacement_satisfied_inl104 - theorem
replacement_satisfied_inr114 - theorem
replacement_complete120 - theorem
replacement_satisfiable130 - theorem
rejectionCount_eq_sum136 - theorem
replacement_rejectionCount144 - abbrev
PaddedDart155 - def
paddedOwner158 - def
paddedReverse163 - theorem
paddedReverse_involutive167 - def
paddedGraph176 - theorem
padded_satisfied_inl190 - theorem
padded_satisfied_inr195 - theorem
padded_complete199 - theorem
padded_satisfiable207 - theorem
card_paddedDart212 - theorem
padded_rejectionCount218 - def
paddedReplacementPortGraph228 - def
paddedReplacementGraph233 - theorem
paddedReplacement_rejectionCount239 - def
noDummyEquiv248
Xet Storage Details
- Size:
- 10.4 kB
- Xet hash:
- 7f0a7d39d0dcb023b6233a61846adf4839721077a1aa37cea4ededa488b745a9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.