data.nat.factorial.double_factorial
⟷
Mathlib.Data.Nat.Factorial.DoubleFactorial
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jake Levinson
-/
import Data.Nat.Factorial.Basic
-import Algebra.BigOperators.Order
+import Algebra.Order.BigOperators.Group.Finset
import Tactic.Ring
#align_import data.nat.factorial.double_factorial from "leanprover-community/mathlib"@"33c67ae661dd8988516ff7f247b0be3018cdd952"
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -66,7 +66,7 @@ theorem doubleFactorial_two_mul : ∀ n : ℕ, (2 * n)‼ = 2 ^ n * n !
| 0 => rfl
| n + 1 =>
by
- rw [mul_add, mul_one, double_factorial_add_two, factorial, pow_succ, double_factorial_two_mul,
+ rw [mul_add, mul_one, double_factorial_add_two, factorial, pow_succ', double_factorial_two_mul,
succ_eq_add_one]
ring
#align nat.double_factorial_two_mul Nat.doubleFactorial_two_mul
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2023 Jake Levinson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jake Levinson
-/
-import Mathbin.Data.Nat.Factorial.Basic
-import Mathbin.Algebra.BigOperators.Order
-import Mathbin.Tactic.Ring
+import Data.Nat.Factorial.Basic
+import Algebra.BigOperators.Order
+import Tactic.Ring
#align_import data.nat.factorial.double_factorial from "leanprover-community/mathlib"@"33c67ae661dd8988516ff7f247b0be3018cdd952"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2023 Jake Levinson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jake Levinson
-
-! This file was ported from Lean 3 source module data.nat.factorial.double_factorial
-! leanprover-community/mathlib commit 33c67ae661dd8988516ff7f247b0be3018cdd952
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Nat.Factorial.Basic
import Mathbin.Algebra.BigOperators.Order
import Mathbin.Tactic.Ring
+#align_import data.nat.factorial.double_factorial from "leanprover-community/mathlib"@"33c67ae661dd8988516ff7f247b0be3018cdd952"
+
/-!
# Double factorials
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -41,7 +41,6 @@ def doubleFactorial : ℕ → ℕ
#align nat.double_factorial Nat.doubleFactorial
-/
--- mathport name: nat.double_factorial
-- This notation is `\!!` not two !'s
scoped notation:10000 n "‼" => Nat.doubleFactorial n
mathlib commit https://github.com/leanprover-community/mathlib/commit/a3e83f0fa4391c8740f7d773a7a9b74e311ae2a3
@@ -90,7 +90,8 @@ theorem doubleFactorial_eq_prod_even : ∀ n : ℕ, (2 * n)‼ = ∏ i in Finset
-/
#print Nat.doubleFactorial_eq_prod_odd /-
-theorem doubleFactorial_eq_prod_odd : ∀ n : ℕ, (2 * n + 1)‼ = ∏ i in Finset.range n, 2 * (i + 1) + 1
+theorem doubleFactorial_eq_prod_odd :
+ ∀ n : ℕ, (2 * n + 1)‼ = ∏ i in Finset.range n, (2 * (i + 1) + 1)
| 0 => rfl
| n + 1 =>
by
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -27,7 +27,7 @@ This file defines the double factorial,
-/
-open Nat
+open scoped Nat
namespace Nat
@@ -76,7 +76,7 @@ theorem doubleFactorial_two_mul : ∀ n : ℕ, (2 * n)‼ = 2 ^ n * n !
#align nat.double_factorial_two_mul Nat.doubleFactorial_two_mul
-/
-open BigOperators
+open scoped BigOperators
#print Nat.doubleFactorial_eq_prod_even /-
theorem doubleFactorial_eq_prod_even : ∀ n : ℕ, (2 * n)‼ = ∏ i in Finset.range n, 2 * (i + 1)
mathlib commit https://github.com/leanprover-community/mathlib/commit/33c67ae661dd8988516ff7f247b0be3018cdd952
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jake Levinson
! This file was ported from Lean 3 source module data.nat.factorial.double_factorial
-! leanprover-community/mathlib commit 7daeaf3072304c498b653628add84a88d0e78767
+! leanprover-community/mathlib commit 33c67ae661dd8988516ff7f247b0be3018cdd952
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -15,6 +15,9 @@ import Mathbin.Tactic.Ring
/-!
# Double factorials
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
This file defines the double factorial,
`n‼ := n * (n - 2) * (n - 4) * ...`.
mathlib commit https://github.com/leanprover-community/mathlib/commit/95a87616d63b3cb49d3fe678d416fbe9c4217bf4
@@ -28,6 +28,7 @@ open Nat
namespace Nat
+#print Nat.doubleFactorial /-
/-- `nat.double_factorial n` is the double factorial of `n`. -/
@[simp]
def doubleFactorial : ℕ → ℕ
@@ -35,25 +36,33 @@ def doubleFactorial : ℕ → ℕ
| 1 => 1
| k + 2 => (k + 2) * double_factorial k
#align nat.double_factorial Nat.doubleFactorial
+-/
-- mathport name: nat.double_factorial
-- This notation is `\!!` not two !'s
scoped notation:10000 n "‼" => Nat.doubleFactorial n
+#print Nat.doubleFactorial_add_two /-
theorem doubleFactorial_add_two (n : ℕ) : (n + 2)‼ = (n + 2) * n‼ :=
rfl
#align nat.double_factorial_add_two Nat.doubleFactorial_add_two
+-/
+#print Nat.doubleFactorial_add_one /-
theorem doubleFactorial_add_one (n : ℕ) : (n + 1)‼ = (n + 1) * (n - 1)‼ := by cases n <;> rfl
#align nat.double_factorial_add_one Nat.doubleFactorial_add_one
+-/
+#print Nat.factorial_eq_mul_doubleFactorial /-
theorem factorial_eq_mul_doubleFactorial : ∀ n : ℕ, (n + 1)! = (n + 1)‼ * n‼
| 0 => rfl
| k + 1 => by
rw [double_factorial_add_two, factorial, factorial_eq_mul_double_factorial, mul_comm _ k‼,
mul_assoc]
#align nat.factorial_eq_mul_double_factorial Nat.factorial_eq_mul_doubleFactorial
+-/
+#print Nat.doubleFactorial_two_mul /-
theorem doubleFactorial_two_mul : ∀ n : ℕ, (2 * n)‼ = 2 ^ n * n !
| 0 => rfl
| n + 1 =>
@@ -62,9 +71,11 @@ theorem doubleFactorial_two_mul : ∀ n : ℕ, (2 * n)‼ = 2 ^ n * n !
succ_eq_add_one]
ring
#align nat.double_factorial_two_mul Nat.doubleFactorial_two_mul
+-/
open BigOperators
+#print Nat.doubleFactorial_eq_prod_even /-
theorem doubleFactorial_eq_prod_even : ∀ n : ℕ, (2 * n)‼ = ∏ i in Finset.range n, 2 * (i + 1)
| 0 => rfl
| n + 1 =>
@@ -73,7 +84,9 @@ theorem doubleFactorial_eq_prod_even : ∀ n : ℕ, (2 * n)‼ = ∏ i in Finset
(by ring : 2 * (n + 1) = 2 * n + 2)]
rfl
#align nat.double_factorial_eq_prod_even Nat.doubleFactorial_eq_prod_even
+-/
+#print Nat.doubleFactorial_eq_prod_odd /-
theorem doubleFactorial_eq_prod_odd : ∀ n : ℕ, (2 * n + 1)‼ = ∏ i in Finset.range n, 2 * (i + 1) + 1
| 0 => rfl
| n + 1 =>
@@ -82,6 +95,7 @@ theorem doubleFactorial_eq_prod_odd : ∀ n : ℕ, (2 * n + 1)‼ = ∏ i in Fin
(by ring : 2 * (n + 1) + 1 = 2 * n + 1 + 2)]
rfl
#align nat.double_factorial_eq_prod_odd Nat.doubleFactorial_eq_prod_odd
+-/
end Nat
mathlib commit https://github.com/leanprover-community/mathlib/commit/95a87616d63b3cb49d3fe678d416fbe9c4217bf4
Mathlib is now using v4.6.0-rc1, which includes the fix in leanprover/lean4#3060
@@ -95,13 +95,11 @@ open Lean Meta Qq
/-- Extension for `Nat.doubleFactorial`. -/
@[positivity Nat.doubleFactorial _]
def evalDoubleFactorial : PositivityExt where eval {u α} _ _ e := do
- if let 0 := u then -- lean4#3060 means we can't combine this with the match below
- match α, e with
- | ~q(ℕ), ~q(Nat.doubleFactorial $n) =>
- assumeInstancesCommute
- return .positive q(Nat.doubleFactorial_pos $n)
- | _, _ => throwError "not Nat.doubleFactorial"
- else throwError "not Nat.doubleFactorial"
+ match u, α, e with
+ | 0, ~q(ℕ), ~q(Nat.doubleFactorial $n) =>
+ assumeInstancesCommute
+ return .positive q(Nat.doubleFactorial_pos $n)
+ | _, _ => throwError "not Nat.doubleFactorial"
example (n : ℕ) : 0 < n‼ := by positivity
@[inherit_doc]
on notations (#9942)
Make all the notations that unambiguously should inherit the docstring of their definition actually inherit it.
Also write a few docstrings by hand. I only wrote the ones I was competent to write and which I was sure of. Some docstrings come from mathlib3 as they were lost during the early port.
This PR is only intended as a first pass There are many more docstrings to add.
@@ -35,7 +35,7 @@ def doubleFactorial : ℕ → ℕ
#align nat.double_factorial Nat.doubleFactorial
-- This notation is `\!!` not two !'s
-scoped notation:10000 n "‼" => Nat.doubleFactorial n
+@[inherit_doc] scoped notation:10000 n "‼" => Nat.doubleFactorial n
lemma doubleFactorial_pos : ∀ n, 0 < n‼
| 0 | 1 => zero_lt_one
@@ -4,8 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jake Levinson
-/
import Mathlib.Data.Nat.Factorial.Basic
-import Mathlib.Algebra.BigOperators.Order
+import Mathlib.Algebra.BigOperators.Basic
import Mathlib.Tactic.Ring
+import Mathlib.Tactic.Positivity.Core
#align_import data.nat.factorial.double_factorial from "leanprover-community/mathlib"@"7daeaf3072304c498b653628add84a88d0e78767"
@@ -57,7 +57,7 @@ theorem factorial_eq_mul_doubleFactorial : ∀ n : ℕ, (n + 1)! = (n + 1)‼ *
lemma doubleFactorial_le_factorial : ∀ n, n‼ ≤ n !
| 0 => le_rfl
| n + 1 => by
- rw [factorial_eq_mul_doubleFactorial]; exact le_mul_of_pos_right n.doubleFactorial_pos
+ rw [factorial_eq_mul_doubleFactorial]; exact Nat.le_mul_of_pos_right _ n.doubleFactorial_pos
theorem doubleFactorial_two_mul : ∀ n : ℕ, (2 * n)‼ = 2 ^ n * n !
| 0 => rfl
and other basic results. Also include a positivity extension to encode that new result.
From LeanAPAP
@@ -36,6 +36,10 @@ def doubleFactorial : ℕ → ℕ
-- This notation is `\!!` not two !'s
scoped notation:10000 n "‼" => Nat.doubleFactorial n
+lemma doubleFactorial_pos : ∀ n, 0 < n‼
+ | 0 | 1 => zero_lt_one
+ | _n + 2 => mul_pos (succ_pos _) (doubleFactorial_pos _)
+
theorem doubleFactorial_add_two (n : ℕ) : (n + 2)‼ = (n + 2) * n‼ :=
rfl
#align nat.double_factorial_add_two Nat.doubleFactorial_add_two
@@ -50,6 +54,11 @@ theorem factorial_eq_mul_doubleFactorial : ∀ n : ℕ, (n + 1)! = (n + 1)‼ *
mul_assoc]
#align nat.factorial_eq_mul_double_factorial Nat.factorial_eq_mul_doubleFactorial
+lemma doubleFactorial_le_factorial : ∀ n, n‼ ≤ n !
+ | 0 => le_rfl
+ | n + 1 => by
+ rw [factorial_eq_mul_doubleFactorial]; exact le_mul_of_pos_right n.doubleFactorial_pos
+
theorem doubleFactorial_two_mul : ∀ n : ℕ, (2 * n)‼ = 2 ^ n * n !
| 0 => rfl
| n + 1 => by
@@ -78,3 +87,21 @@ theorem doubleFactorial_eq_prod_odd :
#align nat.double_factorial_eq_prod_odd Nat.doubleFactorial_eq_prod_odd
end Nat
+
+namespace Mathlib.Meta.Positivity
+open Lean Meta Qq
+
+/-- Extension for `Nat.doubleFactorial`. -/
+@[positivity Nat.doubleFactorial _]
+def evalDoubleFactorial : PositivityExt where eval {u α} _ _ e := do
+ if let 0 := u then -- lean4#3060 means we can't combine this with the match below
+ match α, e with
+ | ~q(ℕ), ~q(Nat.doubleFactorial $n) =>
+ assumeInstancesCommute
+ return .positive q(Nat.doubleFactorial_pos $n)
+ | _, _ => throwError "not Nat.doubleFactorial"
+ else throwError "not Nat.doubleFactorial"
+
+example (n : ℕ) : 0 < n‼ := by positivity
+
+end Mathlib.Meta.Positivity
@@ -2,16 +2,13 @@
Copyright (c) 2023 Jake Levinson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jake Levinson
-
-! This file was ported from Lean 3 source module data.nat.factorial.double_factorial
-! leanprover-community/mathlib commit 7daeaf3072304c498b653628add84a88d0e78767
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Algebra.BigOperators.Order
import Mathlib.Tactic.Ring
+#align_import data.nat.factorial.double_factorial from "leanprover-community/mathlib"@"7daeaf3072304c498b653628add84a88d0e78767"
+
/-!
# Double factorials
The unported dependencies are