Download data/lean/OAI/Computability/Scheduling/Model.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.56 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/Scheduling/Model.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/Scheduling/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/Scheduling/Model.lean
3.56 kB
| import Mathlib | |
| namespace OAI | |
| namespace ThreeMachine | |
| structure Instance (n : β) where | |
| edges : List (Fin n Γ Fin n) | |
| def Instance.edge {n : β} (G : Instance n) (u v : Fin n) : Prop := | |
| (u, v) β G.edges | |
| def Instance.acyclic {n : β} (G : Instance n) : Prop := | |
| β v, Β¬Relation.TransGen G.edge v v | |
| def Feasible {n : β} (G : Instance n) (T : β) (Ο : Fin n β β) : Prop := | |
| (β v, 1 β€ Ο v β§ Ο v β€ T) β§ | |
| (β t, ((Finset.univ : Finset (Fin n)).filter (fun v => Ο v = t)).card β€ 3) β§ | |
| β u v, G.edge u v β Ο u < Ο v | |
| def encodeNat (n : β) : List Bool := | |
| let b := Computability.encodeNat n | |
| List.replicate b.length true ++ false :: b | |
| def encodeList {Ξ± : Type} (f : Ξ± β List Bool) (xs : List Ξ±) : List Bool := | |
| encodeNat xs.length ++ xs.flatMap f | |
| def encodeInput {n : β} (G : Instance n) (deadline : Option β) : List Bool := | |
| (match deadline with | |
| | none => [false] | |
| | some T => true :: encodeNat T) ++ | |
| encodeList encodeNat ((List.range n).map (Β· + 1)) ++ | |
| encodeList (fun (e : Fin n Γ Fin n) => encodeNat (e.1.val + 1) ++ | |
| encodeNat (e.2.val + 1)) G.edges | |
| def encodeAnswer : Option (List β) β List Bool | |
| | none => [false] | |
| | some slots => true :: encodeList encodeNat slots | |
| def slots {n : β} (Ο : Fin n β β) : List β := List.ofFn Ο | |
| def CorrectOutput {n : β} (G : Instance n) (deadline : Option β) | |
| (out : List Bool) : Prop := | |
| match deadline with | |
| | none => β T Ο, Feasible G T Ο β§ | |
| (β T' Ο', Feasible G T' Ο' β T β€ T') β§ | |
| out = encodeAnswer (some (slots Ο)) | |
| | some T => | |
| (out = encodeAnswer none β§ Β¬β Ο, Feasible G T Ο) β¨ | |
| β Ο, Feasible G T Ο β§ out = encodeAnswer (some (slots Ο)) | |
| structure Machine (k q g : β) where | |
| transition : Fin (q + 1) β (Fin (k + 1) β Fin (g + 3)) β | |
| Option (Fin (q + 1) Γ (Fin (k + 1) β Fin (g + 3) Γ Option Turing.Dir)) | |
| structure Configuration (k q g : β) where | |
| state : Fin (q + 1) | |
| tapes : Fin (k + 1) β Turing.Tape (Fin (g + 3)) | |
| def bitSymbol {g : β} (b : Bool) : Fin (g + 3) := | |
| if b then β¨2, by omegaβ© else β¨1, by omegaβ© | |
| def Machine.step {k q g : β} (M : Machine k q g) | |
| (c : Configuration k q g) : Option (Configuration k q g) := do | |
| let (state, action) β M.transition c.state (fun i => (c.tapes i).head) | |
| return { state := state, tapes := fun i => | |
| let tape := (c.tapes i).write (action i).1 | |
| match (action i).2 with | |
| | none => tape | |
| | some d => tape.move d } | |
| def Machine.initial {k q g : β} (_M : Machine k q g) | |
| (input : List Bool) : Configuration k q g := | |
| { state := 0, tapes := fun i => | |
| Turing.Tape.mkβ (if i = 0 then input.map bitSymbol else []) } | |
| def Machine.run {k q g : β} (M : Machine k q g) (input : List Bool) | |
| (t : β) : Configuration k q g := | |
| (fun c => (M.step c).getD c)^[t] (M.initial input) | |
| def Machine.Produces {k q g : β} (M : Machine k q g) | |
| (input out : List Bool) (timeBound : β) : Prop := | |
| β t β€ timeBound, M.step (M.run input t) = none β§ | |
| ((M.run input t).tapes 0).rightβ = Turing.ListBlank.mk (out.map bitSymbol) | |
| def ReleaseTheorem : Prop := | |
| β (k q g : β) (M : Machine k q g) (C : β), 0 < C β§ | |
| β n (G : Instance n), 1 β€ n β G.acyclic β | |
| β deadline : Option β, | |
| (β T β deadline, 1 β€ T β§ T β€ n) β | |
| β out, CorrectOutput G deadline out β§ | |
| M.Produces (encodeInput G deadline) out | |
| (C * ((encodeInput G deadline).length + 2) ^ 150020) | |
| end ThreeMachine | |
| end OAI | |