| | @@ -0,0 +1,99 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap.Data |
| 2 | + |
| 3 | +/-! |
| 4 | +# The five queries in the graph refinement for Erdős #530 |
| 5 | + |
| 6 | +Fixing one eligible face as a function of the pre-query state lets a list of yes-step |
| 7 | +indices determine the whole terminal pair. Links are taken before any vertices leave. |
| 8 | +The rule order is that of the graph refinement lemma in |
| 9 | +`experiments/erdos530/upper-canonical-deletion/NOTES.md`, §1. |
| 10 | +-/ |
| 11 | + |
| 12 | +namespace ErdosSwarm.Erdos530Gap.Refinement |
| 13 | + |
| 14 | +open Finset |
| 15 | + |
| 16 | +abbrev Faces := Finset (Finset ℕ) |
| 17 | + |
| 18 | +structure State where |
| 19 | + fixed : Finset ℕ |
| 20 | + live : Finset ℕ |
| 21 | + edges : Faces |
| 22 | + triples : Faces |
| 23 | + |
| 24 | +def State.leaf (s : State) : Leaf where |
| 25 | + fixed := s.fixed |
| 26 | + live := s.live |
| 27 | + graph := |
| 28 | + { Adj := fun x y => x ≠ y ∧ {x, y} ∈ s.edges |
| 29 | + symm := ⟨fun x y ⟨hne, he⟩ => ⟨hne.symm, by simpa only [pair_comm y x] using he⟩⟩ |
| 30 | + loopless := ⟨fun _ h => h.1 rfl⟩ } |
| 31 | + |
| 32 | +def active (s : State) : Faces := |
| 33 | + ((additiveQuadruples s.live).image fun (a, b, c, f) => {a, b, c, f}).filter |
| 34 | + fun q => ∀ t ∈ s.edges ∪ s.triples, ¬ t ⊆ q |
| 35 | + |
| 36 | +inductive LinkAction where |
| 37 | + | removeVertices | insertEdges | insertTriples |
| 38 | + |
| 39 | +structure Query where |
| 40 | + face : Finset ℕ |
| 41 | + link : Faces |
| 42 | + action : LinkAction |
| 43 | + |
| 44 | +noncomputable def chooseQuery (s : State) (family : Faces) (width degree : ℕ) |
| 45 | + (action : LinkAction) : Option Query := by |
| 46 | + classical |
| 47 | + let containing (q : Finset ℕ) := family.filter fun t => q ⊆ t |
| 48 | + let candidates := (s.live.powersetCard width).filter fun q => degree ≤ (containing q).card |
| 49 | + exact if h : candidates.Nonempty then |
| 50 | + let q := Classical.choose h |
| 51 | + some ⟨q, (containing q).image (fun t => t \ q), action⟩ |
| 52 | + else none |
| 53 | + |
| 54 | +noncomputable def query (s : State) (l : ℕ) : Option Query := |
| 55 | + [chooseQuery s s.edges 1 l .removeVertices, |
| 56 | + chooseQuery s s.triples 2 l .removeVertices, |
| 57 | + chooseQuery s s.triples 1 (l ^ 2) .insertEdges, |
| 58 | + chooseQuery s (active s) 2 (l ^ 2) .insertEdges, |
| 59 | + chooseQuery s (active s) 1 (l ^ 3) .insertTriples].findSome? id |
| 60 | + |
| 61 | +def advance (s : State) (q : Query) (yes : Bool) : State := |
| 62 | + let (remove, newEdges, newTriples) : Finset ℕ × Faces × Faces := |
| 63 | + if yes then |
| 64 | + match q.action with |
| 65 | + | .removeVertices => (q.face ∪ q.link.biUnion id, ∅, ∅) |
| 66 | + | .insertEdges => (q.face, q.link, ∅) |
| 67 | + | .insertTriples => (q.face, ∅, q.link) |
| 68 | + else if q.face.card = 1 then (q.face, ∅, ∅) else (∅, {q.face}, ∅) |
| 69 | + let live := s.live \ remove |
| 70 | + let edges := (s.edges ∪ newEdges).filter fun t => t ⊆ live |
| 71 | + { fixed := if yes then s.fixed ∪ q.face else s.fixed |
| 72 | + live := live |
| 73 | + edges := edges |
| 74 | + triples := (s.triples ∪ newTriples).filter fun t => t ⊆ live ∧ ∀ e ∈ edges, ¬ e ⊆ t } |
| 75 | + |
| 76 | +/-- The state and the indices of all effective yes answers after `i` steps. |
| 77 | +After termination every additional step is the identity. -/ |
| 78 | +noncomputable def run (C : Finset ℕ) (l : ℕ) (answer : ℕ → Finset ℕ → Bool) : |
| 79 | + ℕ → State × Finset ℕ |
| 80 | + | 0 => (⟨∅, C, ∅, ∅⟩, ∅) |
| 81 | + | i + 1 => |
| 82 | + let (s, Y) := run C l answer i |
| 83 | + match query s l with |
| 84 | + | none => (s, Y) |
| 85 | + | some q => |
| 86 | + let yes := answer i q.face |
| 87 | + (advance s q yes, if yes then insert i Y else Y) |
| 88 | + |
| 89 | +def steps (C : Finset ℕ) : ℕ := C.card + C.card.choose 2 |
| 90 | + |
| 91 | +noncomputable def level (m : ℝ) : ℕ := ⌈m ^ (1 / 4 : ℝ)⌉₊ |
| 92 | + |
| 93 | +noncomputable def follow (C : Finset ℕ) (l : ℕ) (I : Finset ℕ) : State × Finset ℕ := |
| 94 | + run C l (fun _ q => decide (q ⊆ I)) (steps C) |
| 95 | + |
| 96 | +noncomputable def decode (C : Finset ℕ) (l : ℕ) (Y : Finset ℕ) : Leaf := |
| 97 | + (run C l (fun i _ => decide (i ∈ Y)) (steps C)).1.leaf |
| 98 | + |
| 99 | +end ErdosSwarm.Erdos530Gap.Refinement |