Download lean/OAI/Computability/VertexCover/PCP/AlphabetTableRelations.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 8.87 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/VertexCover/PCP/AlphabetTableRelations.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Computability/VertexCover/PCP/AlphabetTableRelations.lean
-
curl -L -o AlphabetTableRelations.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/VertexCover/PCP/AlphabetTableRelations.lean
8.87 kB
| import Mathlib | |
| import OAI.Computability.VertexCover.PCP.AlphabetTableEnumeration | |
| import OAI.Computability.VertexCover.PCP.AlphabetTableQueries | |
| namespace OAI | |
| namespace UniqueGames.Foundations.PCP.AlphabetTable.Relations | |
| open Hastad | |
| open Queries | |
| variable {q : Nat} | |
| def sameAddress (selfLoop : Bool) : RawQuery q → RawQuery q → Bool | |
| | .inl (side, f), .inl (side', g) => ((side == side') || selfLoop) && decide (f = g) | |
| | .inr f, .inr g => decide (f = g) | |
| | _, _ => false | |
| @[simp] theorem sameAddress_refl (selfLoop : Bool) (x : RawQuery q) : | |
| sameAddress selfLoop x x = true := by | |
| rcases x with ⟨side, f⟩ | f <;> simp [sameAddress] | |
| theorem globalize_eq_iff {V E : Type*} [DecidableEq V] | |
| (tail head : V) (edge : E) (selfLoop : Bool) | |
| (hloop : selfLoop = decide (tail = head)) (x y : RawQuery q) : | |
| globalize tail head edge x = globalize tail head edge y ↔ | |
| sameAddress selfLoop x y = true := by | |
| rcases x with ⟨side, f⟩ | f <;> rcases y with ⟨side', g⟩ | g | |
| · cases side <;> cases side' | |
| · simp [globalize, sameAddress] | |
| · simp [globalize, sameAddress, hloop] | |
| · simp [globalize, sameAddress, hloop, | |
| show head = tail ↔ tail = head from eq_comm] | |
| · simp [globalize, sameAddress] | |
| · simp [globalize, sameAddress] | |
| · simp [globalize, sameAddress] | |
| · simp [globalize, sameAddress] | |
| def eqProfile (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (i j : Fin 6) : Bool := sameAddress selfLoop (queries i) (queries j) | |
| @[simp] theorem eqProfile_refl (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (i : Fin 6) : eqProfile selfLoop queries i i = true := sameAddress_refl _ _ | |
| def canonicalSlot (selfLoop : Bool) (queries : Fin 6 → RawQuery q) (i : Fin 6) : Fin 6 := | |
| Fin.find (fun j => eqProfile selfLoop queries j i = true) ⟨i, eqProfile_refl _ _ _⟩ | |
| theorem canonicalSlot_profile (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (i : Fin 6) : eqProfile selfLoop queries (canonicalSlot selfLoop queries i) i = true := by | |
| unfold canonicalSlot | |
| exact Fin.find_spec (p := fun j => eqProfile selfLoop queries j i = true) | |
| ⟨i, eqProfile_refl _ _ _⟩ | |
| theorem canonicalSlot_le (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (i j : Fin 6) (h : eqProfile selfLoop queries j i = true) : | |
| canonicalSlot selfLoop queries i ≤ j := | |
| Fin.find_le_of_pos ⟨i, eqProfile_refl _ _ _⟩ h | |
| def RepeatedConsistent (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (label : QueryIncidence.Label 6) : Prop := | |
| ∀ i j, eqProfile selfLoop queries i j = true → label i = label j | |
| instance repeatedConsistentDecidable (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (label : QueryIncidence.Label 6) : Decidable (RepeatedConsistent selfLoop queries label) := by | |
| unfold RepeatedConsistent | |
| infer_instance | |
| def incidenceAccept (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (accept : QueryIncidence.Label 6 → Bool) (slot : Fin 6) | |
| (left right : QueryIncidence.Label 6) : Bool := | |
| decide (accept left = true ∧ RepeatedConsistent selfLoop queries left) && | |
| decide (left (canonicalSlot selfLoop queries slot) = right 0) | |
| def predicate (selfLoop : Bool) (queries : Fin 6 → RawQuery q) | |
| (accept : QueryIncidence.Label 6 → Bool) (slot : Fin 6) (orientation : Bool) | |
| (a b : QueryIncidence.Label 6) : Bool := | |
| if orientation then incidenceAccept selfLoop queries accept slot b a | |
| else incidenceAccept selfLoop queries accept slot a b | |
| def relation (P : Fin q → Fin q → Bool) (selfLoop : Bool) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) : | |
| GraphTables.RelationTable := | |
| GraphTables.relationOf fun a b => | |
| predicate selfLoop (query P event) (AssignmentTester.eventAccepts event.1) | |
| slot orientation (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) | |
| @[simp] theorem relationAt_relation (P : Fin q → Fin q → Bool) (selfLoop : Bool) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) | |
| (a b : GraphTables.Label) : | |
| GraphTables.relationAt (relation P selfLoop event slot orientation) a b = | |
| predicate selfLoop (query P event) (AssignmentTester.eventAccepts event.1) | |
| slot orientation (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) := by | |
| exact GraphTables.relationAt_relationOf _ _ _ | |
| theorem relation_reverse (P : Fin q → Fin q → Bool) (selfLoop : Bool) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) | |
| (a b : GraphTables.Label) : | |
| GraphTables.relationAt (relation P selfLoop event slot (!orientation)) b a = | |
| GraphTables.relationAt (relation P selfLoop event slot orientation) a b := by | |
| simp only [relationAt_relation] | |
| cases orientation <;> rfl | |
| def oldPredicate (old : Vector Bool (q * q)) (a b : Fin q) : Bool := | |
| old[(finProdFinEquiv (a, b) : Fin (q * q))] | |
| def relationFromTable (old : Vector Bool (q * q)) (selfLoop : Bool) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) : | |
| GraphTables.RelationTable := relation (oldPredicate old) selfLoop event slot orientation | |
| @[simp] theorem oldPredicate_relationAt (old : GraphTables.RelationTable) | |
| (a b : GraphTables.Label) : oldPredicate old a b = GraphTables.relationAt old a b := rfl | |
| theorem relationFromTable_eq (old : GraphTables.RelationTable) (selfLoop : Bool) | |
| (event : AlphabetGraph.LocalEvent (Fin 64)) (slot : Fin 6) (orientation : Bool) : | |
| relationFromTable old selfLoop event slot orientation = | |
| relation (GraphTables.relationAt old) selfLoop event slot orientation := rfl | |
| variable {V E : Type*} [DecidableEq V] [DecidableEq E] | |
| omit [DecidableEq E] in | |
| theorem eqProfile_query_iff (G : ConstraintGraph V E (Fin q)) (e : E) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (i j : Fin 6) : | |
| eqProfile (decide (G.tail e = G.head e)) (query (G.accepts e) event) i j = true ↔ | |
| (AlphabetGraph.verifier G).query (e, event) i = | |
| (AlphabetGraph.verifier G).query (e, event) j := by | |
| rw [← globalize_query G e event i, ← globalize_query G e event j] | |
| exact (globalize_eq_iff (G.tail e) (G.head e) e _ rfl _ _).symm | |
| theorem canonicalSlot_eq (G : ConstraintGraph V E (Fin q)) (e : E) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) : | |
| canonicalSlot (decide (G.tail e = G.head e)) (query (G.accepts e) event) slot = | |
| QueryIncidence.canonicalSlot (AlphabetGraph.verifier G) (e, event) slot := by | |
| unfold canonicalSlot QueryIncidence.canonicalSlot | |
| apply Fin.find_congr' | |
| exact eqProfile_query_iff G e event _ slot | |
| omit [DecidableEq E] in | |
| theorem repeatedConsistent_iff (G : ConstraintGraph V E (Fin q)) (e : E) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (label : QueryIncidence.Label 6) : | |
| RepeatedConsistent (decide (G.tail e = G.head e)) (query (G.accepts e) event) label ↔ | |
| QueryIncidence.RepeatedConsistent (AlphabetGraph.verifier G) (e, event) label := by | |
| constructor | |
| · intro h i j hij | |
| exact h i j ((eqProfile_query_iff G e event i j).mpr hij) | |
| · intro h i j hij | |
| exact h i j ((eqProfile_query_iff G e event i j).mp hij) | |
| omit [DecidableEq V] [DecidableEq E] in | |
| theorem verifier_accepts (G : ConstraintGraph V E (Fin q)) (e : E) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (label : QueryIncidence.Label 6) : | |
| (AlphabetGraph.verifier G).accepts (e, event) label = | |
| AssignmentTester.eventAccepts event.1 label := by | |
| rcases event with ⟨kind, k, f, g, r₀, r₁, r₂⟩ | |
| rfl | |
| theorem incidenceAccept_eq (G : ConstraintGraph V E (Fin q)) (e : E) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) | |
| (left right : QueryIncidence.Label 6) : | |
| incidenceAccept (decide (G.tail e = G.head e)) (query (G.accepts e) event) | |
| (AssignmentTester.eventAccepts event.1) slot left right = | |
| QueryIncidence.incidenceAccept (AlphabetGraph.verifier G) (by decide) (e, event) slot | |
| left right := by | |
| simp only [incidenceAccept, QueryIncidence.incidenceAccept, QueryIncidence.LeftValid, | |
| verifier_accepts, repeatedConsistent_iff, canonicalSlot_eq, | |
| QueryIncidence.decodeRight, QueryIncidence.zeroSlot] | |
| rfl | |
| theorem relationAt_relation_graph (G : ConstraintGraph V E (Fin q)) (e : E) | |
| (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) | |
| (a b : GraphTables.Label) : | |
| GraphTables.relationAt | |
| (relation (G.accepts e) (decide (G.tail e = G.head e)) event slot orientation) a b = | |
| (AlphabetGraph.graph G).accepts (((e, event), slot), orientation) | |
| (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) := by | |
| rw [relationAt_relation] | |
| cases orientation <;> | |
| exact incidenceAccept_eq G e event slot _ _ | |
| end UniqueGames.Foundations.PCP.AlphabetTable.Relations | |
| end OAI | |