File size: 5,646 Bytes
4a56cd6 | 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 | import OAI.MathematicalPhysics.RapidForcing.NamedForce
import OAI.MathematicalPhysics.RapidForcing.FormulaPrograms
namespace OAI
section
open Encodable Nat.Partrec
open scoped BigOperators
namespace RapidForcing.EffectiveProfile.Formula
open EffectiveArithmetic
attribute [local irreducible] runTyped bound Expr.bound Expr.diff diff
variable {d : β}
private lemma computable_lipMul : Computable (fun p : (Formula d Γ β) Γ
(Formula d Γ Formula d Γ β Γ β) =>
p.2.1.bound p.1.2 * p.2.2.2.2 + p.2.2.1.bound p.1.2 * p.2.2.2.1) := by
have ha := (@computable_bound d).comp (show Computable (fun p : (Formula d Γ β) Γ
(Formula d Γ Formula d Γ β Γ β) => (p.2.1, p.1.2)) by fun_prop)
have hb := (@computable_bound d).comp (show Computable (fun p : (Formula d Γ β) Γ
(Formula d Γ Formula d Γ β Γ β) => (p.2.2.1, p.1.2)) by fun_prop)
have hmβ := computable_rat_mul.comp (ha.pair (show Computable (fun p : (Formula d Γ β) Γ
(Formula d Γ Formula d Γ β Γ β) => p.2.2.2.2) by fun_prop))
have hmβ := computable_rat_mul.comp (hb.pair (show Computable (fun p : (Formula d Γ β) Γ
(Formula d Γ Formula d Γ β Γ β) => p.2.2.2.1) by fun_prop))
exact (computable_rat_add.comp (hmβ.pair hmβ)).of_eq (fun _ => rfl)
@[fun_prop] lemma computable_lipBound : Computable (fun p : Formula d Γ β => p.1.lipBound p.2) := by
have h := computable_recOn (e := fun p : Formula d Γ β => p.1) (by fun_prop)
(c := fun _ _ => (0 : β)) (by unfold Computableβ; fun_prop)
(v := fun _ _ => (1 : β)) (by unfold Computableβ; fun_prop)
(a := fun _ p => p.2.2.1 + p.2.2.2) (by unfold Computableβ; fun_prop)
(m := fun a p => p.1.bound a.2 * p.2.2.2 + p.2.1.bound a.2 * p.2.2.1) computable_lipMul.toβ
(p := fun _ p => p.1.diff.bound * p.2.2) (by unfold Computableβ; fun_prop)
exact h.of_eq (fun p => by induction p.1 <;> simp [lipBound, *])
lemma partrec_choosePrecision : Partrec (fun p : β Γ β => choosePrecision p.1 p.2) := by
apply Partrec.rfindOpt
unfold Computableβ
fun_prop
abbrev NameArgs (d : β) := Formula d Γ Code Γ β
private def nameLip (p : NameArgs d Γ (Fin d β β)) : β :=
p.1.1.lipBound (2 + β i, |p.2 i|)
private lemma computable_nameLip : Computable (@nameLip d) := by
have h := computable_fin_sum computable_rat_add (f := fun q : Fin d β β => fun i => |q i|)
(fun i => computable_rat_abs.comp (Computable.fin_app.comp Computable.id (Computable.const i)))
have ht := computable_rat_add.comp ((Computable.const 2).pair h)
have hR := ht.comp (show Computable (fun p : NameArgs d Γ (Fin d β β) => p.2) by fun_prop)
exact ((@computable_lipBound d).comp ((show Computable (fun p : NameArgs d Γ (Fin d β β) => p.1.1) by fun_prop).pair hR)).of_eq (fun _ => rfl)
lemma partrec_evalName : Partrec (fun p : NameArgs d =>
p.1.evalName (runTyped p.2.1) p.2.2) := by
have hβ := (partrec_runTyped (B := Fin d β β)).comp
(show Computable (fun p : NameArgs d => (p.2.1, (0 : β))) by fun_prop)
have hn := partrec_choosePrecision.comp
(computable_nameLip.pair (show Computable (fun p : NameArgs d Γ (Fin d β β) => p.1.2.2) by fun_prop))
have hq := (partrec_runTyped (B := Fin d β β)).comp
(show Computable (fun p : (NameArgs d Γ (Fin d β β)) Γ β => (p.1.1.2.1, p.2)) by fun_prop)
have hb := partrec_evalAt.comp (show Computable
(fun p : ((NameArgs d Γ (Fin d β β)) Γ β) Γ (Fin d β β) =>
(p.1.1.1.1, p.2, p.1.1.1.2.2 / 2)) by fun_prop)
have hf : Computable (fun p : (((NameArgs d Γ (Fin d β β)) Γ β) Γ (Fin d β β)) Γ Ball =>
(β¨p.2.center, p.2.radius + (1 / 2 : β) ^ p.1.1.2 * nameLip p.1.1.1β© : Ball)) := by
have hL := computable_nameLip.comp (show Computable (fun p :
(((NameArgs d Γ (Fin d β β)) Γ β) Γ (Fin d β β)) Γ Ball => p.1.1.1) by fun_prop)
fun_prop (disch := assumption)
exact (hβ.bind (hn.bind (hq.bind (hb.bind hf.partrec.toβ).toβ).toβ).toβ).of_eq (fun _ => rfl)
lemma partrec_readReal : Partrec (fun p : Program Γ β => readReal p.1 p.2) := by
exact (partrec_runTyped (B := β)).of_eq (fun _ => by simp [runTyped, readReal])
lemma partrec_readPoint : Partrec (fun p : Program Γ β => readPoint p.1 p.2) := by
exact (partrec_runTyped (B := RationalPoint)).of_eq (fun _ => by simp [runTyped, readPoint])
lemma partrec_coordinateName : Partrec (fun p : (Program Γ Program) Γ β =>
coordinateName p.1.1 p.1.2 p.2) := by
have hv := partrec_readReal.comp (show Computable (fun p : (Program Γ Program) Γ β =>
(p.1.1, p.2)) by fun_prop)
have hq := partrec_readPoint.comp (show Computable (fun p : ((Program Γ Program) Γ β) Γ β =>
(p.1.1.2, p.1.2)) by fun_prop)
have h : Computable (fun p : (((Program Γ Program) Γ β) Γ β) Γ RationalPoint =>
![p.2.1, p.2.2.1, p.2.2.2.1, p.2.2.2.2, p.1.2]) := by
apply computable_fin_lambda
intro i
fin_cases i <;> dsimp <;> fun_prop
exact (hv.bind (hq.bind h.partrec.toβ).toβ).of_eq (fun _ => rfl)
noncomputable def coordinateProgram (p : Program Γ Program) : Program :=
(typedCode _ partrec_coordinateName).curry (encode p)
@[fun_prop] lemma computable_coordinateProgram : Computable coordinateProgram :=
computable_specialize.comp ((Computable.const _).pair Computable.id)
lemma runTyped_coordinateProgram (p : Program Γ Program) (n : β) :
runTyped (coordinateProgram p) n = coordinateName p.1 p.2 n := by
rw [coordinateProgram, runTyped_curry, runTyped_typedCode]
end RapidForcing.EffectiveProfile.Formula
end
end OAI
|