File size: 3,641 Bytes
92416a2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | import Mathlib
import OAI.Computability.VertexCover.Machines.Naturals
namespace OAI
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace VertexCover.Machine
noncomputable def Poly.fixedList {α ι β : Type} (ea : α → List Bool) (eb : β → List Bool)
(f : α → ι → β) (cf : ∀ i, Poly ea eb (fun a => f a i)) :
(xs : List ι) → Poly ea (listBits eb) (fun a => xs.map (f a))
| [] => Poly.const ea (listBits eb) []
| i::xs => ((cf i).pair (Poly.fixedList ea eb f cf xs)).comp (Poly.listCons eb)
noncomputable def Poly.fixedAll {α ι : Type} (ea : α → List Bool) (f : α → ι → Bool)
(cf : ∀ i, Poly ea boolBits (fun a => f a i)) :
(xs : List ι) → Poly ea boolBits (fun a => xs.all (f a))
| [] => Poly.const ea boolBits true
| i::xs => (((cf i).pair (Poly.fixedAll ea f cf xs)).comp (Poly.bool₂ (fun x => x.1 && x.2))).congr
(fun _ => by simp only [Function.comp_apply,List.all_cons])
noncomputable def Poly.finiteAll {α ι : Type} [Fintype ι] (ea : α → List Bool)
(f : α → ι → Bool) (cf : ∀ i, Poly ea boolBits (fun a => f a i)) :
Poly ea boolBits (fun a => decide (∀ i, f a i = true)) := by
classical
exact (Poly.fixedAll ea f cf Finset.univ.toList).congr (fun a => by
apply Bool.eq_iff_iff.mpr
simp only [List.all_eq_true,Finset.mem_toList,Finset.mem_univ,forall_const,decide_eq_true_iff])
noncomputable def fixedSelect {α ι β : Type} [DecidableEq ι]
(f : α → ι → β) (i₀ : ι) : List ι → α × ι → β
| [], x => f x.1 i₀
| i::xs, x => if x.2=i then f x.1 i else fixedSelect f i₀ xs x
theorem fixedSelect_mem {α ι β : Type} [DecidableEq ι]
(f : α → ι → β) (i₀ : ι) (a : α) :
∀ (xs : List ι) (i : ι), i ∈ xs → fixedSelect f i₀ xs (a,i) = f a i := by
intro xs
induction xs with
| nil => simp
| cons j xs ih =>
intro i hi
by_cases h : i=j
· subst i; simp [fixedSelect]
· rw [fixedSelect,ite_eq_right h]
exact ih i ((List.mem_cons.mp hi).resolve_left h)
noncomputable def Poly.fixedSelect {α ι β : Type} [Fintype ι] [DecidableEq ι]
(ea : α → List Bool) (ei : ι → List Bool) (eb : β → List Bool) (hi : Function.Injective ei)
(f : α → ι → β) (i₀ : ι) (cf : ∀ i, Poly ea eb (fun a => f a i)) :
(xs : List ι) → Poly (prodBits ea ei) eb (fixedSelect f i₀ xs)
| [] => (Poly.fst ea ei).comp (cf i₀)
| i::xs => (((Poly.snd ea ei).comp (Poly.finite ei boolBits hi (fun j => decide (j=i)))).ite
((Poly.fst ea ei).comp (cf i)) (Poly.fixedSelect ea ei eb hi f i₀ cf xs)).congr (fun _ => by
simp only [Function.comp_apply,VertexCover.Machine.fixedSelect,decide_eq_true_eq])
noncomputable def Poly.finiteBranch {α ι β : Type} [Fintype ι] [Nonempty ι]
(ea : α → List Bool) (ei : ι → List Bool) (eb : β → List Bool) (hi : Function.Injective ei)
(f : α → ι → β) (cf : ∀ i, Poly ea eb (fun a => f a i)) :
Poly (prodBits ea ei) eb (fun x => f x.1 x.2) := by
classical
let i₀ := Classical.choice (inferInstance : Nonempty ι)
exact (Poly.fixedSelect ea ei eb hi f i₀ cf Finset.univ.toList).congr
(fun x => fixedSelect_mem f i₀ x.1 _ x.2 (by simp))
end VertexCover.Machine
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI
|