data.nat.factorial.double_factorialMathlib.Data.Nat.Factorial.DoubleFactorial

This file has been ported!

Changes since the initial port

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.

Changes in mathlib3

(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)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -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"
Diff
@@ -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
Diff
@@ -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"
 
Diff
@@ -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
 
Diff
@@ -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
 
Diff
@@ -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
Diff
@@ -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)
Diff
@@ -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) * ...`.
 
Diff
@@ -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
 

Changes in mathlib4

mathlib3
mathlib4
chore: cleanup TODOs around leanprover/lean4#3060 (#10198)

Mathlib is now using v4.6.0-rc1, which includes the fix in leanprover/lean4#3060

Diff
@@ -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
 
doc: @[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.

Diff
@@ -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
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -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"
 
fix: patch for std4#198 (more mul lemmas for Nat) (#6204)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -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
feat: The double factorial is positive (#9102)

and other basic results. Also include a positivity extension to encode that new result.

From LeanAPAP

Diff
@@ -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
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -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
 
feat: port Data.Nat.Factorial.DoubleFactorial (#4117)

Dependencies 3 + 206

207 files ported (98.6%)
90243 lines ported (98.9%)
Show graph

The unported dependencies are