Download lean/OAI/MathematicalPhysics/NavierStokes/BalancedTransport/NumericScopes.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
let a := o.left
let b := o.right
match o.tag with
| 0=>True
| 1=>True
| 2=> a < n ∧ b < n
| 3=> a < n ∧ b < n
| 4=> a < n
| 5=> a < n
| 6=> b < n
| 7=> a < n
| 8=>True
lemmareal_append (d : ℕ) [NeZero d] (o : NumericOp) (x : Fin d →ℝ)
(s q : Listℝ) (hs : o.Scoped s.length) : o.real d x (s ++ q) = o.real d x s :=by
proof · 5
lines
have he (i : ℕ) (hi : i < s.length) : (s ++ q).getD i 0 = s.getD i 0:=by
simp [List.getD, List.getElem?_append_left hi]
rcases o with ⟨j,r,a,b⟩
fin_cases j <;> simp only [Scoped, real, tag, rat, left, right] at hs ⊢
all_goals first | rfl | exact he _ hs | simp only [he _ hs] | simp only [he _ hs.1, he _ hs.2]
lemmarealFrom_length (p : NumericProgram) (x : Fin d →ℝ) (s : Listℝ) :
(realFrom p x s).length = p.length + s.length :=by
proof · 3
lines
induction p generalizing s with
| nil => simp [realFrom]
| cons o p ih => simpa [realFrom, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using ih (o.real d x s :: s)
lemmarealFrom_append (p : NumericProgram) (x : Fin d →ℝ) (s q : Listℝ)
(hs : p.ScopedFrom s.length) : realFrom p x (s ++ q) = realFrom p x s ++ q :=by
proof · 7
lines
induction p generalizing s with
| nil => rfl
| cons o p ih =>
change realFrom p x (o.real d x (s ++ q) :: (s ++ q)) =
realFrom p x (o.real d x s :: s) ++ q
rw [o.real_append d x s q hs.1]
exact ih (o.real d x s :: s) hs.2
lemmavalidFrom_append (p : NumericProgram) (x : Fin d →ℝ) (s q : Listℝ)
(hs : p.ScopedFrom s.length) : ValidFrom x p (s ++ q) ↔ValidFrom x p s :=by
proof · 7
lines
induction p generalizing s with
| nil => rfl
| cons o p ih =>
change o.Valid (s ++ q) ∧ValidFrom x p (o.real d x (s ++ q) :: (s ++ q)) ↔
o.Valid s ∧ValidFrom x p (o.real d x s :: s)
rw [o.valid_append s q hs.1, o.real_append d x s q hs.1]
exact and_congr_right (fun _ => ih (o.real d x s :: s) hs.2)
lemmavalidFrom_concat (p q : NumericProgram) (x : Fin d →ℝ) (s : Listℝ) :
(p ++ q).ValidFrom x s ↔ValidFrom x p s ∧ q.ValidFrom x (realFrom p x s) :=by
proof · 4
lines
induction p generalizing s with
| nil => simp [ValidFrom, realFrom]
| cons o p ih => simpa only [List.cons_append, ValidFrom, realFrom,
List.foldl_cons, and_assoc] using and_congr_right (fun _ => ih _)
lemmascopedFrom_mono (p : NumericProgram) {n m : ℕ} (hnm : n ≤ m) :
p.ScopedFrom n → p.ScopedFrom m :=by
proof · 10
lines
intro h
induction p generalizing n m with
| nil => trivial
| cons o p ih =>
refine ⟨?_, ih (Nat.add_le_add_right hnm 1) h.2⟩
rcases o with ⟨j,r,a,b⟩
have ho := h.1
fin_cases j <;> dsimp only [NumericOp.Scoped, NumericOp.tag, NumericOp.rat,
NumericOp.left, NumericOp.right] at ho ⊢
all_goals first | trivial | exact ho.trans_le hnm | exact ⟨ho.1.trans_le hnm,ho.2.trans_le hnm⟩
lemmascopedFrom_concat (p q : NumericProgram) (n : ℕ) :
(p ++ q).ScopedFrom n ↔ p.ScopedFrom n ∧ q.ScopedFrom (n+p.length) :=by
proof · 6
lines
induction p generalizing n with
| nil => simp [ScopedFrom]
| cons o p ih =>
simp only [List.cons_append, ScopedFrom, List.length_cons]
rw [ih]
simp only [Nat.add_assoc, Nat.add_comm 1, and_assoc]