File size: 2,867 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 | import Mathlib
import OAI.Computability.VertexCover.Machines.Codec
import OAI.Computability.VertexCover.Machines.LCData
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.finFunction {α β : Type} [Fintype β]
(ea : α → List Bool) : (n : ℕ) → (f : α → Fin n → β) →
(∀ i, Poly ea (finiteCode β) (fun a => f a i)) →
Poly ea (finiteCode (Fin n → β)) f
| 0,f,_ => (Poly.const ea (finiteCode (Fin 0 → β)) (fun i => Fin.elim0 i)).congr
(fun a => by funext i; exact Fin.elim0 i)
| n+1,f,cf =>
(((cf 0).pair (Poly.finFunction ea n (fun a i => f a i.succ) (fun i => cf i.succ))).comp
(Poly.finite _ _ (prodBits_injective (finiteCode_injective β) (finiteCode_injective (Fin n → β)))
(fun p : β × (Fin n → β) => Fin.cons p.1 p.2))).congr
(fun a => by funext i; refine Fin.cases ?_ (fun j => ?_) i <;> rfl)
noncomputable def Poly.finiteFunction {α β ι : Type} [Fintype β] [Fintype ι] [DecidableEq ι]
(ea : α → List Bool) (f : α → ι → β)
(cf : ∀ i, Poly ea (finiteCode β) (fun a => f a i)) :
Poly ea (finiteCode (ι → β)) f := by
let E := Fintype.equivFin ι
exact ((Poly.finFunction ea (Fintype.card ι) (fun a i => f a (E.symm i))
(fun i => cf (E.symm i))).comp
(Poly.finite _ _ (finiteCode_injective _) (fun g : Fin (Fintype.card ι) → β => fun i => g (E i)))).congr
(fun a => by funext i; exact congrArg (f a) (E.symm_apply_apply i))
noncomputable def Poly.finiteRecode {α : Type} [Fintype α] (ea : α → List Bool)
(ha : Function.Injective ea) : Poly ea (finiteCode α) id :=
Poly.finite ea (finiteCode α) ha id
noncomputable def Poly.fixedSum {α ι : Type} (ea : α → List Bool)
(f : α → ι → ℕ) (cf : ∀ i, Poly ea natBits (fun a => f a i)) :
(xs : List ι) → Poly ea natBits (fun a => (xs.map (f a)).sum)
| [] => (Poly.const ea natBits 0).congr (fun _ => rfl)
| i::xs => (((cf i).pair (Poly.fixedSum ea f cf xs)).comp Poly.natAdd).congr
(fun a => by simp only [Function.comp_apply,List.map_cons,List.sum_cons])
noncomputable def Poly.finiteSum {α ι : Type} [Fintype ι] (ea : α → List Bool)
(f : α → ι → ℕ) (cf : ∀ i, Poly ea natBits (fun a => f a i)) :
Poly ea natBits (fun a => ∑ i, f a i) := by
classical
exact (Poly.fixedSum ea f cf Finset.univ.toList).congr (fun a => 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
|