Download data/lean/OAI/Combinatorics/EditApproximation/Numerics/RationalRefinement.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.55 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Numerics/RationalRefinement.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Numerics/RationalRefinement.lean
-
curl -L -o RationalRefinement.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Numerics/RationalRefinement.lean
3.55 kB
| import OAI.Combinatorics.EditApproximation.Geometry.Bellman | |
| import OAI.Combinatorics.EditApproximation.Geometry.Cones | |
| import OAI.Combinatorics.EditApproximation.Definitions | |
| namespace OAI | |
| /-! | |
| # Rational execution of the Bellman and refinement operations | |
| Every finite minimum, cone cost, warmup iteration, and refinement update | |
| is computed in rational arithmetic. The real analysis used elsewhere is | |
| the exact cast of these operations. An absent online candidate returns | |
| the cone minimum, avoiding an extended-real value in the implementation. | |
| -/ | |
| namespace EditApproximation | |
| theorem rationalMinimum_cast (fallback : β) (values : List β) : | |
| (rationalMinimum fallback values : β) = finiteMinimum (fallback : β) (values.map Rat.cast) := by | |
| induction values with | |
| | nil => rfl | |
| | cons value rest ih => | |
| simp only [rationalMinimum, finiteMinimum, List.map_cons, Rat.cast_min, ih] | |
| def RationalBellmanAction.toReal {Parent Child : Type*} {M : β} | |
| (action : RationalBellmanAction Parent Child M) : BellmanAction Parent Child M := | |
| β¨action.center, action.connection, action.childStateβ© | |
| theorem rationalActionValue_cast {Parent Child : Type*} {M : β} | |
| (distance : Parent β Parent β β) (L : β) (child : Child β β) | |
| (query : Parent) (action : RationalBellmanAction Parent Child M) : | |
| (rationalActionValue distance L child query action : β) = | |
| bellmanActionValue (fun q r => (distance q r : β)) (L : β) | |
| (fun s => (child s : β)) query action.toReal := by | |
| simp only [rationalActionValue, bellmanActionValue, RationalBellmanAction.toReal, | |
| Rat.cast_add, Rat.cast_mul, Rat.cast_sum] | |
| theorem rationalBellman_cast {Parent Child : Type*} {M : β} | |
| (fallback : Parent β β) (distance : Parent β Parent β β) (L : β) | |
| (actions : List (RationalBellmanAction Parent Child M)) (child : Child β β) (query : Parent) : | |
| (rationalBellman fallback distance L actions child query : β) = | |
| finiteBellman (fun q => (fallback q : β)) (fun q r => (distance q r : β)) (L : β) | |
| (actions.map RationalBellmanAction.toReal) (fun s => (child s : β)) query := by | |
| rw [rationalBellman, rationalMinimum_cast] | |
| unfold finiteBellman | |
| simp only [List.map_map, Function.comp_def, rationalActionValue_cast] | |
| def rationalWarmup {State : Type*} (operator : (State β β) β State β β) | |
| (initial : State β β) : β β State β β | |
| | 0 => initial | |
| | t + 1 => operator (rationalWarmup operator initial t) | |
| theorem rationalWarmup_cast {State : Type*} | |
| (operator : (State β β) β State β β) (realOperator : (State β β) β State β β) | |
| (initial : State β β) | |
| (hoperator : β value q, (operator value q : β) = realOperator (fun s => (value s : β)) q) | |
| (t : β) (q : State) : | |
| (rationalWarmup operator initial t q : β) = warmup realOperator (fun s => (initial s : β)) t q := by | |
| induction t generalizing q with | |
| | zero => rfl | |
| | succ t ih => | |
| rw [rationalWarmup, warmup, hoperator] | |
| congr 1 | |
| funext s | |
| exact ih s | |
| theorem rationalRefinementUpdate_cast (Ξ΄ cone online : β) : | |
| (rationalRefinementUpdate Ξ΄ cone (some online) : β) = | |
| refinementUpdate (Ξ΄ : β) (cone : β) (online : β) := by | |
| simp only [rationalRefinementUpdate, refinementUpdate, Rat.cast_min, Rat.cast_max, | |
| Rat.cast_div, Rat.cast_add, Rat.cast_one] | |
| theorem rationalRefinementUpdate_none (Ξ΄ cone : β) : | |
| rationalRefinementUpdate Ξ΄ cone none = cone := rfl | |
| end EditApproximation | |
| end OAI | |