lemma
proved
coeffSign_foldPlusOneStep
show as:
view math explainer →
open explainer
Generate a durable explainer page for this declaration.
open lean source
IndisputableMonolith.ClassicalBridge.Fluids.Simulation2D on GitHub at line 127.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
-
GalerkinState -
modes -
coeffMag -
coeffSign -
cast_lt_zero_iff -
clampI32_pos_of_ge_one -
foldPlusOneStep -
step -
is -
is -
is -
is -
and
used by
formal source
124 rw [hz]
125 simp [abs_of_nonneg hm0]
126
127lemma coeffSign_foldPlusOneStep {N : ℕ} (u : GalerkinState N) (i : (modes N) × Fin 2) :
128 coeffSign ((foldPlusOneStep u) i) = coeffSign (u i) := by
129 classical
130 set x : ℝ := u i
131 have hx1 : (1 : Int) ≤ coeffMag x + 1 := by
132 have hx0 : (0 : Int) ≤ coeffMag x := (Int.floor_nonneg (a := |x|)).2 (abs_nonneg x)
133 linarith
134 have hmpos : 0 < clampI32 (coeffMag x + 1) :=
135 clampI32_pos_of_ge_one (x := coeffMag x + 1) hx1
136 by_cases hx : x < 0
137 ·
138 -- `x < 0` ⇒ `coeffSign x = -1`, and the step coefficient is negative (since the magnitude is positive).
139 have hzInt : (coeffSign x) * clampI32 (coeffMag x + 1) < 0 := by
140 have hneg : -(clampI32 (coeffMag x + 1)) < 0 := neg_neg_of_pos hmpos
141 calc
142 (coeffSign x) * clampI32 (coeffMag x + 1)
143 = (-1) * clampI32 (coeffMag x + 1) := by simp [coeffSign, hx]
144 _ = -(clampI32 (coeffMag x + 1)) := by ring
145 _ < 0 := hneg
146 have hzReal :
147 (((coeffSign x) * clampI32 (coeffMag x + 1) : Int) : ℝ) < 0 :=
148 (cast_lt_zero_iff (z := (coeffSign x) * clampI32 (coeffMag x + 1))).2 hzInt
149 have hy : (foldPlusOneStep u) i < 0 := by
150 simpa [foldPlusOneStep, x] using hzReal
151 simp [coeffSign, hx, hy, x]
152 ·
153 -- `¬ x < 0` ⇒ `coeffSign x = 1`, and the step coefficient is nonnegative.
154 have hzInt : (0 : Int) ≤ (coeffSign x) * clampI32 (coeffMag x + 1) := by
155 have hm0 : (0 : Int) ≤ clampI32 (coeffMag x + 1) := le_of_lt hmpos
156 simpa [coeffSign, hx] using hm0
157 have hzReal :