File: Mathlib/Data/Real/Pi/Bounds.lean

full_name: Real.pi_gt_sqrtTwoAddSeries
code: theorem pi_gt_sqrtTwoAddSeries (n : ℕ) :
    (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) < π 
goal: 2 ^ (n + 1) * √(2 - Real.sqrtTwoAddSeries 0 n) < π

full_name: Real.pi_lt_sqrtTwoAddSeries
code: theorem pi_lt_sqrtTwoAddSeries (n : ℕ) :
    π < (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) + 1 / (4 : ℝ) ^ n 
goal: π < 2 ^ (n + 1) * √(2 - Real.sqrtTwoAddSeries 0 n) + 1 / 4 ^ n

full_name: Real.pi_lower_bound_start
code: /-- From an upper bound on `sqrtTwoAddSeries 0 n = 2 cos (π / 2 ^ (n+1))` of the form
`sqrtTwoAddSeries 0 n ≤ 2 - (a / 2 ^ (n + 1)) ^ 2)`, one can deduce the lower bound `a < π`
thanks to basic trigonometric inequalities as expressed in `pi_gt_sqrtTwoAddSeries`. -/
theorem pi_lower_bound_start (n : ℕ) {a}
    (h : sqrtTwoAddSeries ((0 : ℕ) / (1 : ℕ)) n ≤ (2 : ℝ) - (a / (2 : ℝ) ^ (n + 1)) ^ 2) :
    a < π 
goal: a < π

full_name: Real.sqrtTwoAddSeries_step_up
code: theorem sqrtTwoAddSeries_step_up (c d : ℕ) {a b n : ℕ} {z : ℝ} (hz : sqrtTwoAddSeries (c / d) n ≤ z)
    (hb : 0 < b) (hd : 0 < d) (h : (2 * b + a) * d ^ 2 ≤ c ^ 2 * b) :
    sqrtTwoAddSeries (a / b) (n + 1) ≤ z 
goal: (↑a / ↑b).sqrtTwoAddSeries (n + 1) ≤ z

full_name: _private.Mathlib.Data.Real.Pi.Bounds.0.Real.numDen
code: /-- `numDen stx` takes a syntax expression `stx` and
* if it is of the form `a / b`, then it returns `some (a, b)`;
* otherwise it returns `none`.
-/
private def numDen : Syntax → Option (Syntax.Term × Syntax.Term)
  
goal: Lean.Syntax → Option (Lean.Term × Lean.Term)

full_name: Real.«_aux_Mathlib_Data_Real_Pi_Bounds___elabRules_Real_tacticPi_lower_bound[_,,]_1»
code: /-- Create a proof of `a < π` for a fixed rational number `a`, given a witness, which is a
sequence of rational numbers `√2 < r 1 < r 2 < ... < r n < 2` satisfying the property that
`√(2 + r i) ≤ r(i+1)`, where `r 0 = 0` and `√(2 - r n) ≥ a/2^(n+1)`. -/
elab "pi_lower_bound " "[" l:term,* "]" : tactic => do
  let rat_sep := l.elemsAndSeps
  let sep := rat_sep.getD 1 .missing
  let ratStx := rat_sep.filter (· != sep)
  let n := ← (toExpr ratStx.size).toSyntax
  let els := (ratStx.map numDen).reduceOption
  evalTactic (← `(tactic| apply pi_lower_bound_start $n))
  let _ := ← els.mapM fun (x, y) => do
      evalTactic (← `(tactic| apply sqrtTwoAddSeries_step_up $x $y))
  evalTactic (← `(tactic| simp [sqrtTwoAddSeries]))
  allGoals (evalTactic (← `(tactic| norm_num1)))
goal: Lean.Elab.Tactic.Tactic

full_name: Real.«tacticPi_lower_bound[_,,]»
code: /-- Create a proof of `a < π` for a fixed rational number `a`, given a witness, which is a
sequence of rational numbers `√2 < r 1 < r 2 < ... < r n < 2` satisfying the property that
`√(2 + r i) ≤ r(i+1)`, where `r 0 = 0` and `√(2 - r n) ≥ a/2^(n+1)`. -/
elab "pi_lower_bound " "[" l:term,* "]" : tactic => do
  let rat_sep := l.elemsAndSeps
  let sep := rat_sep.getD 1 .missing
  let ratStx := rat_sep.filter (· != sep)
  let n := ← (toExpr ratStx.size).toSyntax
  let els := (ratStx.map numDen).reduceOption
  evalTactic (← `(tactic| apply pi_lower_bound_start $n))
  let _ := ← els.mapM fun (x, y) => do
      evalTactic (← `(tactic| apply sqrtTwoAddSeries_step_up $x $y))
  evalTactic (← `(tactic| simp [sqrtTwoAddSeries]))
  allGoals (evalTactic (← `(tactic| norm_num1)))
goal: Lean.ParserDescr

full_name: Real.pi_upper_bound_start
code: /-- From a lower bound on `sqrtTwoAddSeries 0 n = 2 cos (π / 2 ^ (n+1))` of the form
`2 - ((a - 1 / 4 ^ n) / 2 ^ (n + 1)) ^ 2 ≤ sqrtTwoAddSeries 0 n`, one can deduce the upper bound
`π < a` thanks to basic trigonometric formulas as expressed in `pi_lt_sqrtTwoAddSeries`. -/
theorem pi_upper_bound_start (n : ℕ) {a}
    (h : (2 : ℝ) - ((a - 1 / (4 : ℝ) ^ n) / (2 : ℝ) ^ (n + 1)) ^ 2 ≤
        sqrtTwoAddSeries ((0 : ℕ) / (1 : ℕ)) n)
    (h₂ : (1 : ℝ) / (4 : ℝ) ^ n ≤ a) : π < a 
goal: π < a

full_name: Real.sqrtTwoAddSeries_step_down
code: theorem sqrtTwoAddSeries_step_down (a b : ℕ) {c d n : ℕ} {z : ℝ}
    (hz : z ≤ sqrtTwoAddSeries (a / b) n) (hb : 0 < b) (hd : 0 < d)
    (h : a ^ 2 * d ≤ (2 * d + c) * b ^ 2) : z ≤ sqrtTwoAddSeries (c / d) (n + 1) 
goal: z ≤ (↑c / ↑d).sqrtTwoAddSeries (n + 1)

full_name: Real.«tacticPi_upper_bound[_,,]»
code: /-- Create a proof of `π < a` for a fixed rational number `a`, given a witness, which is a
sequence of rational numbers `√2 < r 1 < r 2 < ... < r n < 2` satisfying the property that
`√(2 + r i) ≥ r(i+1)`, where `r 0 = 0` and `√(2 - r n) ≥ (a - 1/4^n) / 2^(n+1)`. -/
elab "pi_upper_bound " "[" l:term,* "]" : tactic => do
  let rat_sep := l.elemsAndSeps
  let sep := rat_sep.getD 1 .missing
  let ratStx := rat_sep.filter (· != sep)
  let n := ← (toExpr ratStx.size).toSyntax
  let els := (ratStx.map numDen).reduceOption
  evalTactic (← `(tactic| apply pi_upper_bound_start $n))
  let _ := ← els.mapM fun (x, y) => do
      evalTactic (← `(tactic| apply sqrtTwoAddSeries_step_down $x $y))
  evalTactic (← `(tactic| simp [sqrtTwoAddSeries]))
  allGoals (evalTactic (← `(tactic| norm_num1)))
goal: Lean.ParserDescr

full_name: Real.«_aux_Mathlib_Data_Real_Pi_Bounds___elabRules_Real_tacticPi_upper_bound[_,,]_1»
code: /-- Create a proof of `π < a` for a fixed rational number `a`, given a witness, which is a
sequence of rational numbers `√2 < r 1 < r 2 < ... < r n < 2` satisfying the property that
`√(2 + r i) ≥ r(i+1)`, where `r 0 = 0` and `√(2 - r n) ≥ (a - 1/4^n) / 2^(n+1)`. -/
elab "pi_upper_bound " "[" l:term,* "]" : tactic => do
  let rat_sep := l.elemsAndSeps
  let sep := rat_sep.getD 1 .missing
  let ratStx := rat_sep.filter (· != sep)
  let n := ← (toExpr ratStx.size).toSyntax
  let els := (ratStx.map numDen).reduceOption
  evalTactic (← `(tactic| apply pi_upper_bound_start $n))
  let _ := ← els.mapM fun (x, y) => do
      evalTactic (← `(tactic| apply sqrtTwoAddSeries_step_down $x $y))
  evalTactic (← `(tactic| simp [sqrtTwoAddSeries]))
  allGoals (evalTactic (← `(tactic| norm_num1)))
goal: Lean.Elab.Tactic.Tactic

full_name: Real.pi_gt_three
code: theorem pi_gt_three : 3 < π 
goal: 3 < π

full_name: Real.pi_gt_314
code: theorem pi_gt_314 : 3.14 < π 
goal: 3.14 < π

full_name: Real.pi_lt_315
code: theorem pi_lt_315 : π < 3.15 
goal: π < 3.15

full_name: Real.pi_gt_31415
code: theorem pi_gt_31415 : 3.1415 < π 
goal: 3.1415 < π

full_name: Real.pi_lt_31416
code: theorem pi_lt_31416 : π < 3.1416 
goal: π < 3.1416

full_name: Real.pi_gt_3141592
code: theorem pi_gt_3141592 : 3.141592 < π 
goal: 3.141592 < π

full_name: Real.pi_lt_3141593
code: theorem pi_lt_3141593 : π < 3.141593 
goal: π < 3.141593