math / data /lean /OAI /NumberTheory /Ostmann /Arithmetic /BulkFrequencyFactor.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.58 kB
11
noncomputable def movingFrequencyCore {Οƒ : Type*} (value : Οƒ β†’ β„•)
    (F : Bool β†’ {n : β„•} β†’ MovingSlotData Οƒ n β†’ β„€ β†’ β„‚)
    (E : Bool β†’ {n : β„•} β†’ MovingSlotData Οƒ n β†’ β„€ β†’ β„€ β†’ β„€ β†’ ℝ)
    {n : β„•} (T : Bool β†’ MovingSlotData Οƒ n) (R x y : β„€) : β„‚ :=
body Β· 3 lines
  if βˆ€ b, movingFrequencyGate value R (T b) x y then
    movingDataWeight (F false) (E false) (T false) *
      conj (movingDataWeight (F true) (E true) (T true)) else 0

The only nonperiodic part of this factor consists of the explicit regular-prime coincidence tests. The remaining node bounds are independent of the numerical bulk values.

22
theorem movingFrequencyPairFactor_core {Οƒ : Type*} (value : Οƒ β†’ β„•)
    (outside : List β„•)
    (F : Bool β†’ {n : β„•} β†’ MovingSlotData Οƒ n β†’ β„€ β†’ β„‚)
    (E : Bool β†’ {n : β„•} β†’ MovingSlotData Οƒ n β†’ β„€ β†’ β„€ β†’ β„€ β†’ ℝ)
    {n : β„•} (T : Bool β†’ MovingSlotData Οƒ n) (nodes : Bool β†’ List MovingFormulaNode)
    (R x y : β„€) :
    movingFrequencyPairFactor value outside F E T nodes R x y =
      (if βˆ€ b, movingRegularOutsidePairwise value outside (T b) ∧
        (βˆ€ f ∈ nodes b, f.guard.frequencyBounds) then (1 : β„‚) else 0) *
      movingFrequencyCore value F E T R x y := by
proof Β· 14 lines
  have he : movingFrequencyPairSupport value outside T nodes R x y ↔
      (βˆ€ b, movingRegularOutsidePairwise value outside (T b) ∧
        (βˆ€ f ∈ nodes b, f.guard.frequencyBounds)) ∧
      (βˆ€ b, movingFrequencyGate value R (T b) x y) := by
    simp only [movingFrequencyPairSupport, Bool.forall_bool]
    tauto
  unfold movingFrequencyPairFactor movingFrequencyCore
  rw [he]
  by_cases hs : βˆ€ b, movingRegularOutsidePairwise value outside (T b) ∧
      (βˆ€ f ∈ nodes b, f.guard.frequencyBounds)
  Β· by_cases hc : βˆ€ b, movingFrequencyGate value R (T b) x y
    · rw [ite_eq_left ⟨hs, hc⟩, ite_eq_left hs, ite_eq_left hc, one_mul]
    Β· rw [ite_eq_right (fun h => hc h.2), ite_eq_left hs, ite_eq_right hc, mul_zero]
  Β· rw [ite_eq_right (fun h => hs h.1), ite_eq_right hs, zero_mul]

Unlike the removed coincidence tests, the actual frequency core is constant on the joint bulk residue cells.

49
theorem movingFrequencyCore_values_modEq {Οƒ : Type*} (v w : Οƒ β†’ β„•)
    (F : Bool β†’ {n : β„•} β†’ MovingSlotData Οƒ n β†’ β„€ β†’ β„‚)
    (E : Bool β†’ {n : β„•} β†’ MovingSlotData Οƒ n β†’ β„€ β†’ β„€ β†’ β„€ β†’ ℝ)
    {n : β„•} (T : Bool β†’ MovingSlotData Οƒ n) (R : β„€)
    (hf : βˆ€ b, (T b).Frequencies (Β· β‰  0))
    (hcomp : βˆ€ b, (T b).CompensationAgreement v w)
    (hR : βˆ€ b, (T b).frequencyProduct ∣ R)
    (hv : βˆ€ i, (v i : β„€) ≑ (w i : β„€) [ZMOD R ^ (n + 1)])
    (XL XR YL YR : β„€) (hL : XL ≑ YL [ZMOD R ^ (n + 1)])
    (hRight : XR ≑ YR [ZMOD R ^ (n + 1)]) :
    movingFrequencyCore v F E T R XL XR = movingFrequencyCore w F E T R YL YR := by
proof Β· 5 lines
  have he : (βˆ€ b, movingFrequencyGate v R (T b) XL XR) ↔
      (βˆ€ b, movingFrequencyGate w R (T b) YL YR) :=
    forall_congr' fun b => movingFrequencyGate_values_modEq v w R (T b)
      (hf b) (hcomp b) (hR b) hv XL XR YL YR hL hRight
  simp only [movingFrequencyCore, he]
66
def MovingSlotData.FrequencyBounds {Οƒ : Type*} (childBound : β„• β†’ β„•) :
    {n : β„•} β†’ MovingSlotData Οƒ n β†’ Prop
body Β· 5 lines
  | _, .leaf _ _ => True
  | n + 1, .node _ _ _ _ left right =>
      left.frequency.natAbs ≀ childBound (n + 1) ∧
      right.frequency.natAbs ≀ childBound (n + 1) ∧
      left.FrequencyBounds childBound ∧ right.FrequencyBounds childBound
74
theorem MovingSlotData.formulaNodes_frequencyBounds {Οƒ : Type*} (value : Οƒ β†’ β„•)
    (hv : βˆ€ i, value i β‰  0) (childBound pivotBound : β„• β†’ β„•)
    {n : β„•} (T : MovingSlotData Οƒ n) (hf : T.Frequencies (Β· β‰  0))
    (L R : HistoryFormula Bool) :
    (βˆ€ f ∈ T.formulaNodes value hv childBound pivotBound hf L R,
      f.guard.frequencyBounds) ↔ T.FrequencyBounds childBound := by
proof Β· 7 lines
  induction T generalizing L R with
  | leaf => simp [formulaNodes, FrequencyBounds]
  | node s CL CR u left right ihL ihR =>
    simp only [formulaNodes, List.mem_cons, List.mem_append,
      or_imp, forall_and, forall_eq, ihL, ihR, FrequencyBounds]
    change ((_ ∧ _) ∧ _ ∧ _) ↔ (_ ∧ _ ∧ _ ∧ _)
    tauto