import OAI.Combinatorics.Crossing.StepEvents import Mathlib.Tactic.FieldSimp namespace OAI noncomputable section namespace Zarankiewicz open scoped BigOperators def positiveIndicator (x : ℝ) : ℝ := if 0 < x then 1 else 0 def slopeSign (b : ℝ) : ℝ := if 0 < b then 1 else -1 def sideBefore (b : ℝ) : ℝ := if 0 < b then 0 else 1 def sideAfter (b : ℝ) : ℝ := if 0 < b then 1 else 0 theorem sideAfter_sub_before (b : ℝ) : sideAfter b-sideBefore b = slopeSign b := by unfold sideAfter sideBefore slopeSign split_ifs <;> norm_num theorem positiveIndicator_factor (b r t : ℝ) (hb : b ≠ 0) (ht : t ≠ r) : positiveIndicator (b*(t-r)) = stepAt r (sideBefore b) (sideAfter b) t := by rcases lt_or_gt_of_ne hb with hb | hb · by_cases htr : t sideBefore (b i)) (fun i => sideAfter (b i)) hr h0 h1 have he : ∀ i : Fin n, stepEvent r (fun i => sideBefore (b i)) (fun i => sideAfter (b i)) i = if 0