File size: 6,608 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 103 104 105 106 107 108 109 110 | import OAI.Combinatorics.EditApproximation.Geometry.ComparisonBandCoverage
import OAI.Combinatorics.EditApproximation.Geometry.BandParameters
namespace OAI
/-! The comparison band uses the computed numerical parameters, with its error budget proved. -/
namespace EditApproximation
open Finset
theorem comparisonActionCurvature_nonneg {Ξ± : Type*} (source target : List Ξ±)
{M : β} (hM : 0 < M) (parent : TargetInterval source.length)
(r : TargetInterval target.length) (comparison : Fin M β TargetInterval target.length)
(child : Fin M β TargetInterval target.length β β)
(hgap : β i, |stateLengthGap
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i)| β€
child i (comparison i))
(hzero : endpointActionConnection r comparison = 0)
(hW : 0 < comparisonActionMass comparison child) :
0 β€ comparisonActionCurvature source target parent r comparison child := by
let mass := fun i => child i (comparison i)
let gap := fun i => stateLengthGap
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i)
have hmass (i : Fin M) : 0 β€ mass i := (abs_nonneg _).trans (hgap i)
have hzeroMass (i : Fin M) (hi : mass i = 0) : gap i = 0 := by
have h := hgap i
change |gap i| β€ mass i at h
rw [hi] at h
exact abs_eq_zero.mp (le_antisymm h (abs_nonneg _))
have hsum := zero_connection_gap_sum source target hM parent r comparison hzero
have h := curvature_nonneg univ mass gap (fun i _ => hmass i) (fun i _ => hzeroMass i) hW
dsimp only [mass, gap] at h
rw [hsum] at h
exact h
theorem computed_comparison_band_mem {Ξ± : Type*} (source target : List Ξ±)
(N : β) (hN : 0 < N) (hell : 2 ^ 1000 β€ inputSmallLog N)
{M b P : β} (hM : 0 < M) (hMeq : M = (integerParameters N).M)
(parent : TargetInterval source.length) (r : TargetInterval target.length)
(comparison : Fin M β TargetInterval target.length)
(hcomparison : comparison β wideActionList M parent r b P)
(hnonempty : wideActionList M parent r b P β [])
(child : Fin M β TargetInterval target.length β β) (a : β) (ha : 1 β€ a)
(hchild : β i s, max ((stateEditCost
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target s : β) / a)
|stateLengthGap (substring source (sourceChild parent i).lo (sourceChild parent i).hi) target s| β€
(child i s : β))
(hupper : β i, (child i (comparison i) : β) β€ 2 * inputSmallLog N * stateEditCost
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i))
(hcostSum : (β i, (stateEditCost
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i) : β)) β€ 4 * b)
(hpositive : 0 < stateEditCost (substring source parent.lo parent.hi) target r)
(hzero : endpointActionConnection r comparison = 0)
(hanchors : β i, Nat.dist (r.lo + ((sourceChild parent i).lo - parent.lo)) (comparison i).lo β€ 6 * b β§
Nat.dist (r.lo + ((sourceChild parent i).hi - parent.lo)) (comparison i).hi β€ 6 * b)
(hvelocity : |rationalStateGap (substring source parent.lo parent.hi) target r /
rationalWideActionMinimum parent r b P hnonempty child| β€
1 - (rationalParameters (inputSmallLog N)).tau)
(hKsmall : comparisonActionCurvature source target parent r comparison (fun i s => (child i s : β)) β€
b / heightQuarterRoot N)
(hGsmall : comparisonActionMass comparison (fun i s => (child i s : β)) -
wideActionMinimum parent r b P hnonempty (fun i s => (child i s : β)) β€ b / heightQuarterRoot N) :
comparison β representativeBandActions source target parent r b P
(rationalParameters (inputSmallLog N)).tau (rationalParameters (inputSmallLog N)).theta child := by
let childR := fun i s => (child i s : β)
let W := comparisonActionMass comparison childR
let Z := wideActionMinimum parent r b P hnonempty childR
let K := comparisonActionCurvature source target parent r comparison childR
have hgap (i : Fin M) : |stateLengthGap
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i)| β€
childR i (comparison i) := (le_max_right _ _).trans (hchild i (comparison i))
have hZlower : (stateEditCost (substring source parent.lo parent.hi) target r : β) / a β€ Z :=
(le_max_left _ _).trans (wideActionMinimum_lower source target hM parent r b P hnonempty a ha childR hchild)
have hcpos : (0 : β) < stateEditCost (substring source parent.lo parent.hi) target r := by exact_mod_cast hpositive
have hZpos : 0 < Z := (div_pos hcpos (by linarith only [ha] : 0 < a)).trans_le hZlower
have hZposQ : 0 < rationalWideActionMinimum parent r b P hnonempty child := by
have h := hZpos
change 0 < wideActionMinimum parent r b P hnonempty childR at h
rw [β rationalWideActionMinimum_cast] at h
exact_mod_cast h
have hZW : Z β€ W := by
have h := wideActionMinimum_le_member parent r hnonempty childR comparison hcomparison
simpa only [Z, W, comparisonActionMass, endpointActionValue, hzero, Nat.cast_zero, zero_add] using h
have hWpos : 0 < W := hZpos.trans_le hZW
have hK : 0 β€ K := comparisonActionCurvature_nonneg source target hM parent r comparison childR hgap hzero hWpos
have hG : 0 β€ W - Z := sub_nonneg.mpr hZW
have hWupper : W β€ 8 * inputSmallLog N * b := by
calc
W = β i, childR i (comparison i) := rfl
_ β€ β i, 2 * (inputSmallLog N : β) * stateEditCost
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i) :=
sum_le_sum fun i _ => hupper i
_ = 2 * (inputSmallLog N : β) * β i, (stateEditCost
(substring source (sourceChild parent i).lo (sourceChild parent i).hi) target (comparison i) : β) := by rw [mul_sum]
_ β€ 2 * (inputSmallLog N : β) * (4 * b) :=
mul_le_mul_of_nonneg_left hcostSum (by positivity)
_ = 8 * inputSmallLog N * b := by ring
have hnumerical := computed_nonbad_band_numerical_bound N hN hell (Nat.cast_nonneg b)
hK hG hWpos.le hKsmall hGsmall hWupper
rw [β hMeq] at hnumerical
apply comparison_representativeBandActions_mem source target hM parent r comparison hcomparison hnonempty
(rationalParameters (inputSmallLog N)).tau (rationalParameters (inputSmallLog N)).theta child
a ha hchild hzero hanchors hZposQ hvelocity
simpa only [mul_comm, W, Z, K, childR] using hnumerical
end EditApproximation
end OAI
|