import Tablet.Preamble set_option autoImplicit false namespace dec2flt_model -- [TABLET NODE: P616_T1_CutoffFoldComparison] theorem P616_T1_CutoffFoldComparison (H : Nat) (ds : List Nat) : let a := ds.foldl (fun n d => if n < H then 10 * n + d else n) 0 let b := ds.foldl (fun n d => 10 * n + d) 0 a <= b ∧ (a = b ∨ H <= a) := by -- BODY have comparison (ds : List Nat) (a b : Nat) (hab : a <= b) (hcase : a = b ∨ H <= a) : ds.foldl (fun n d => if n < H then 10 * n + d else n) a <= ds.foldl (fun n d => 10 * n + d) b ∧ (ds.foldl (fun n d => if n < H then 10 * n + d else n) a = ds.foldl (fun n d => 10 * n + d) b ∨ H <= ds.foldl (fun n d => if n < H then 10 * n + d else n) a) := by induction ds generalizing a b with | nil => exact ⟨hab, hcase⟩ | cons d ds ih => simp only [List.foldl_cons] apply ih · split <;> omega · split next hlt => rcases hcase with heq | hcap · left; omega · omega next hge => right; omega exact comparison ds 0 0 (by omega) (Or.inl rfl) end dec2flt_model