math / data /lean /OAI /Combinatorics /EditApproximation /Binary /BinaryCellCenters.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.04 kB
import OAI.Combinatorics.EditApproximation.Binary.BinaryCellGrid
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
/-! Literal eligibility scans for the whole-cell representative list. -/
namespace EditApproximation
namespace BinaryFraction
@[simp] theorem centerEligibilityWithWork_value (b F : β„•) (a initial : BinaryFraction) :
(centerEligibilityWithWork b F a initial).1 = true ↔
(b : β„š) / (4 * a.value) ≀ initial.value ∧ initial.value ≀ 8 * F * b := by
simp only [centerEligibilityWithWork, Bool.and_eq_true, leWithWork_value,
divWithWork_value, canonicalMulWithWork_value, nat_value]
norm_num
def cellCentersWithWork {n : β„•} (P F b : β„•) (a theta : BinaryFraction)
(initial : TargetInterval n β†’ BinaryFraction) (cell : β„• Γ— β„•) :
List (TargetInterval n) Γ— β„• :=
let spacing := seedGridSpacingWithWork b P
let side := canonicalMulWithWork theta (nat b)
let states := cellStatesWithWork n (bitWordValue spacing.1) side.1 cell
let selected := filterWithWork (fun r => centerEligibilityWithWork b F a (initial r)) states.1
(selected.1, spacing.2 + side.2 + states.2 + selected.2 + 3)
@[simp] theorem cellCentersWithWork_value {n : β„•} (P F b : β„•) (a theta : BinaryFraction)
(initial : TargetInterval n β†’ BinaryFraction) (cell : β„• Γ— β„•) (hP : 0 < P) :
(cellCentersWithWork P F b a theta initial cell).1 =
cellRepresentativeStates n P F b a.value (fun r => (initial r).value) theta.value cell := by
have htest (r : TargetInterval n) : (centerEligibilityWithWork b F a (initial r)).1 =
decide ((b : β„š) / (4 * a.value) ≀ (initial r).value ∧ (initial r).value ≀ 8 * F * b) :=
Bool.eq_iff_iff.mpr (by simp only [centerEligibilityWithWork_value, decide_eq_true_eq])
simp only [cellCentersWithWork, filterWithWork_value, cellStatesWithWork_value,
seedGridSpacingWithWork_value b P hP, canonicalMulWithWork_value, nat_value,
htest, cellRepresentativeStates]
end BinaryFraction
end EditApproximation
end OAI