Skip to content

Commit

Permalink
Trigger CI for leanprover/lean4#3082
Browse files Browse the repository at this point in the history
  • Loading branch information
leanprover-community-mathlib4-bot committed Jan 10, 2024
2 parents cd59f1d + 8493d51 commit 3af4fac
Show file tree
Hide file tree
Showing 1,243 changed files with 27,673 additions and 14,916 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ jobs:
lean --version
lake --version
- name: build cache
run: |
lake build cache
- name: prune ProofWidgets .lake
run: |
# The ProofWidgets release contains not just the `.js` (which we need in order to build)
# but also `.oleans`, which may have been built with the wrong toolchain.
# This removes them.
rm -rf .lake/packages/proofwidgets/.lake/build/lib
rm -rf .lake/packages/proofwidgets/.lake/build/ir
- name: get cache
run: |
lake exe cache clean
Expand Down Expand Up @@ -194,6 +206,7 @@ jobs:
lake exe cache put || (sleep 1; lake exe cache put) || true
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check the cache
run: |
Expand Down Expand Up @@ -221,6 +234,7 @@ jobs:
lake exe cache put Archive.lean || (sleep 1; lake exe cache put Archive.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: build counterexamples
run: |
Expand All @@ -229,6 +243,7 @@ jobs:
lake exe cache put Counterexamples.lean || (sleep 1; lake exe cache put Counterexamples.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check declarations in db files
run: |
Expand Down Expand Up @@ -260,7 +275,7 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0
git checkout toolchain/v4.5.0-rc1
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ jobs:
lean --version
lake --version
- name: build cache
run: |
lake build cache
- name: prune ProofWidgets .lake
run: |
# The ProofWidgets release contains not just the `.js` (which we need in order to build)
# but also `.oleans`, which may have been built with the wrong toolchain.
# This removes them.
rm -rf .lake/packages/proofwidgets/.lake/build/lib
rm -rf .lake/packages/proofwidgets/.lake/build/ir
- name: get cache
run: |
lake exe cache clean
Expand Down Expand Up @@ -201,6 +213,7 @@ jobs:
lake exe cache put || (sleep 1; lake exe cache put) || true
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check the cache
run: |
Expand Down Expand Up @@ -228,6 +241,7 @@ jobs:
lake exe cache put Archive.lean || (sleep 1; lake exe cache put Archive.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: build counterexamples
run: |
Expand All @@ -236,6 +250,7 @@ jobs:
lake exe cache put Counterexamples.lean || (sleep 1; lake exe cache put Counterexamples.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check declarations in db files
run: |
Expand Down Expand Up @@ -267,7 +282,7 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0
git checkout toolchain/v4.5.0-rc1
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/build.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ jobs:
lean --version
lake --version

- name: build cache
run: |
lake build cache

- name: prune ProofWidgets .lake
run: |
# The ProofWidgets release contains not just the `.js` (which we need in order to build)
# but also `.oleans`, which may have been built with the wrong toolchain.
# This removes them.
rm -rf .lake/packages/proofwidgets/.lake/build/lib
rm -rf .lake/packages/proofwidgets/.lake/build/ir

- name: get cache
run: |
lake exe cache clean
Expand Down Expand Up @@ -180,6 +192,7 @@ jobs:
lake exe cache put || (sleep 1; lake exe cache put) || true
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check the cache
run: |
Expand Down Expand Up @@ -207,6 +220,7 @@ jobs:
lake exe cache put Archive.lean || (sleep 1; lake exe cache put Archive.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: build counterexamples
run: |
Expand All @@ -215,6 +229,7 @@ jobs:
lake exe cache put Counterexamples.lean || (sleep 1; lake exe cache put Counterexamples.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check declarations in db files
run: |
Expand Down Expand Up @@ -246,7 +261,7 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0
git checkout toolchain/v4.5.0-rc1
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/build_fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ jobs:
lean --version
lake --version
- name: build cache
run: |
lake build cache
- name: prune ProofWidgets .lake
run: |
# The ProofWidgets release contains not just the `.js` (which we need in order to build)
# but also `.oleans`, which may have been built with the wrong toolchain.
# This removes them.
rm -rf .lake/packages/proofwidgets/.lake/build/lib
rm -rf .lake/packages/proofwidgets/.lake/build/ir
- name: get cache
run: |
lake exe cache clean
Expand Down Expand Up @@ -198,6 +210,7 @@ jobs:
lake exe cache put || (sleep 1; lake exe cache put) || true
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check the cache
run: |
Expand Down Expand Up @@ -225,6 +238,7 @@ jobs:
lake exe cache put Archive.lean || (sleep 1; lake exe cache put Archive.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: build counterexamples
run: |
Expand All @@ -233,6 +247,7 @@ jobs:
lake exe cache put Counterexamples.lean || (sleep 1; lake exe cache put Counterexamples.lean)
env:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: check declarations in db files
run: |
Expand Down Expand Up @@ -264,7 +279,7 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0
git checkout toolchain/v4.5.0-rc1
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
Expand Down
1 change: 1 addition & 0 deletions Archive.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Archive.Examples.IfNormalization.Statement
import Archive.Examples.IfNormalization.WithoutAesop
import Archive.Examples.MersennePrimes
import Archive.Examples.PropEncodable
import Archive.Hairer
import Archive.Imo.Imo1959Q1
import Archive.Imo.Imo1960Q1
import Archive.Imo.Imo1962Q1
Expand Down
20 changes: 9 additions & 11 deletions Archive/Arithcc.lean
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ theorem stateEq_implies_write_eq {t : Register} {ζ₁ ζ₂ : State} (h : ζ₁
constructor; · exact h.1
intro r hr
have hr : r ≤ t := Register.le_of_lt_succ hr
cases' lt_or_eq_of_le hr with hr hr
rcases lt_or_eq_of_le hr with hr | hr
· cases' h with _ h
specialize h r hr
simp_all
Expand Down Expand Up @@ -303,23 +303,21 @@ theorem write_eq_implies_stateEq {t : Register} {v : Word} {ζ₁ ζ₂ : State}
Unlike Theorem 1 in the paper, both `map` and the assumption on `t` are explicit.
-/
theorem compiler_correctness :
∀ (map : Identifier → Register) (e : Expr) (ξ : Identifier → Word) (η : State) (t : Register),
(∀ x, read (loc x map) η = ξ x) →
(∀ x, loc x map < t) → outcome (compile map e t) η ≃[t] { η with ac := value e ξ } := by
intro map e ξ η t hmap ht
revert η t
induction e <;> intro η t hmap ht
theorem compiler_correctness
(map : Identifier → Register) (e : Expr) (ξ : Identifier → Word) (η : State) (t : Register)
(hmap : ∀ x, read (loc x map) η = ξ x) (ht : ∀ x, loc x map < t) :
outcome (compile map e t) η ≃[t] { η with ac := value e ξ } := by
induction e generalizing η t with
-- 5.I
case const => simp [StateEq, step]; rfl
| const => simp [StateEq, step]; rfl
-- 5.II
case var =>
| var =>
simp [hmap, StateEq, step] -- Porting note: was `finish [hmap, StateEq, step]`
constructor
· simp_all only [read, loc]
· rfl
-- 5.III
case sum =>
| sum =>
rename_i e_s₁ e_s₂ e_ih_s₁ e_ih_s₂
simp
generalize value e_s₁ ξ = ν₁ at e_ih_s₁ ⊢
Expand Down
135 changes: 135 additions & 0 deletions Archive/Hairer.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/-
Copyright (c) 2023 Floris Van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Sébastien Gouëzel, Patrick Massot, Ruben Van de Velde, Floris Van Doorn,
Junyan Xu
-/
import Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff
import Mathlib.RingTheory.MvPolynomial.Basic
import Mathlib.Analysis.Analytic.Polynomial
import Mathlib.Analysis.Analytic.Uniqueness
import Mathlib.Data.MvPolynomial.Funext

/-!
# Smooth functions whose integral calculates the values of polynomials
In any space `ℝᵈ` and given any `N`, we construct a smooth function supported in the unit ball
whose integral against a multivariate polynomial `P` of total degree at most `N` is `P 0`.
This is a test of the state of the library suggested by Martin Hairer.
-/

noncomputable section

open Metric Set MeasureTheory
open MvPolynomial hiding support
open Function hiding eval

section normed
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜]
variable [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F]

variable (𝕜 E F) in
/-- The set of smooth functions supported in a set `s`, as a submodule of the space of functions. -/
def SmoothSupportedOn (n : ℕ∞) (s : Set E) : Submodule 𝕜 (E → F) where
carrier := { f : E → F | tsupport f ⊆ s ∧ ContDiff 𝕜 n f }
add_mem' hf hg := ⟨tsupport_add.trans <| union_subset hf.1 hg.1, hf.2.add hg.2
zero_mem' :=
⟨(tsupport_eq_empty_iff.mpr rfl).subset.trans (empty_subset _), contDiff_const (c := 0)⟩
smul_mem' r f hf :=
⟨(closure_mono <| support_smul_subset_right r f).trans hf.1, contDiff_const.smul hf.2

namespace SmoothSupportedOn

variable {n : ℕ∞} {s : Set E}

instance : FunLike (SmoothSupportedOn 𝕜 E F n s) E (fun _ ↦ F) where
coe := Subtype.val
coe_injective' := Subtype.coe_injective

@[simp]
lemma coe_mk (f : E → F) (h) : (⟨f, h⟩ : SmoothSupportedOn 𝕜 E F n s) = f := rfl

lemma tsupport_subset (f : SmoothSupportedOn 𝕜 E F n s) : tsupport f ⊆ s := f.2.1

lemma support_subset (f : SmoothSupportedOn 𝕜 E F n s) :
support f ⊆ s := subset_tsupport _ |>.trans (tsupport_subset f)

lemma contDiff (f : SmoothSupportedOn 𝕜 E F n s) :
ContDiff 𝕜 n f := f.2.2

theorem continuous (f : SmoothSupportedOn 𝕜 E F n s) : Continuous f :=
(SmoothSupportedOn.contDiff _).continuous

lemma hasCompactSupport [ProperSpace E] (f : SmoothSupportedOn 𝕜 E F n (closedBall 0 1)) :
HasCompactSupport f :=
HasCompactSupport.of_support_subset_isCompact (isCompact_closedBall 0 1) (support_subset f)

end SmoothSupportedOn

end normed
open SmoothSupportedOn

instance {R σ : Type*} [CommSemiring R] [Finite σ] (N : ℕ) :
Module.Finite R (restrictTotalDegree σ R N) :=
have : Finite {n : σ →₀ ℕ | ∀ i, n i ≤ N} := by
erw [Finsupp.equivFunOnFinite.subtypeEquivOfSubtype'.finite_iff, Set.finite_coe_iff]
convert Set.Finite.pi fun _ : σ ↦ Set.finite_le_nat N using 1
ext; rw [mem_univ_pi]; rfl
have : Finite {s : σ →₀ ℕ | s.sum (fun _ e ↦ e) ≤ N} := by
rw [Set.finite_coe_iff] at this ⊢
exact this.subset fun n hn i ↦ (eq_or_ne (n i) 0).elim
(fun h ↦ h.trans_le N.zero_le) fun h ↦
(Finset.single_le_sum (fun _ _ ↦ Nat.zero_le _) <| Finsupp.mem_support_iff.mpr h).trans hn
Module.Finite.of_basis (basisRestrictSupport R _)

variable {ι : Type*}
lemma MvPolynomial.continuous_eval (p : MvPolynomial ι ℝ) :
Continuous fun x ↦ (eval x) p := by
continuity

variable [Fintype ι]
theorem SmoothSupportedOn.integrable_eval_mul (p : MvPolynomial ι ℝ)
(f : SmoothSupportedOn ℝ (EuclideanSpace ℝ ι) ℝ ⊤ (closedBall 0 1)) :
Integrable fun (x : EuclideanSpace ℝ ι) ↦ eval x p * f x :=
(p.continuous_eval.mul (SmoothSupportedOn.contDiff f).continuous).integrable_of_hasCompactSupport
(hasCompactSupport f).mul_left

variable (ι)
/-- Interpreting a multivariate polynomial as an element of the dual of smooth functions supported
in the unit ball, via integration against Lebesgue measure. -/
def L : MvPolynomial ι ℝ →ₗ[ℝ]
Module.Dual ℝ (SmoothSupportedOn ℝ (EuclideanSpace ℝ ι) ℝ ⊤ (closedBall 0 1)) :=
have int := SmoothSupportedOn.integrable_eval_mul (ι := ι)
.mk₂ ℝ (fun p f ↦ ∫ x : EuclideanSpace ℝ ι, eval x p • f x)
(fun p₁ p₂ f ↦ by simp [add_mul, integral_add (int p₁ f) (int p₂ f)])
(fun r p f ↦ by simp [mul_assoc, integral_mul_left])
(fun p f₁ f₂ ↦ by simp_rw [smul_eq_mul, ← integral_add (int p _) (int p _), ← mul_add]; rfl)
fun r p f ↦ by simp_rw [← integral_smul, smul_comm r]; rfl

lemma inj_L : Injective (L ι) :=
(injective_iff_map_eq_zero _).mpr fun p hp ↦ by
have H : ∀ᵐ x : EuclideanSpace ℝ ι, x ∈ ball 0 1 → eval x p = 0 :=
isOpen_ball.ae_eq_zero_of_integral_contDiff_smul_eq_zero
(by exact continuous_eval p |>.locallyIntegrable.locallyIntegrableOn _)
fun g hg _h2g g_supp ↦ by
simpa [mul_comm (g _), L] using congr($hp ⟨g, g_supp.trans ball_subset_closedBall, hg⟩)
simp_rw [MvPolynomial.funext_iff, map_zero]
refine fun x ↦ AnalyticOn.eval_linearMap (EuclideanSpace.equiv ι ℝ).toLinearMap p
|>.eqOn_zero_of_preconnected_of_eventuallyEq_zero
(preconnectedSpace_iff_univ.mp inferInstance) (z₀ := 0) trivial
(Filter.mem_of_superset (Metric.ball_mem_nhds 0 zero_lt_one) ?_) trivial
rw [← ae_restrict_iff'₀ measurableSet_ball.nullMeasurableSet] at H
apply Measure.eqOn_of_ae_eq H p.continuous_eval.continuousOn continuousOn_const
rw [isOpen_ball.interior_eq]
apply subset_closure

lemma hairer (N : ℕ) (ι : Type*) [Fintype ι] :
∃ (ρ : EuclideanSpace ℝ ι → ℝ), tsupport ρ ⊆ closedBall 0 1 ∧ ContDiff ℝ ⊤ ρ ∧
∀ (p : MvPolynomial ι ℝ), p.totalDegree ≤ N →
∫ x : EuclideanSpace ℝ ι, eval x p • ρ x = eval 0 p := by
have := (inj_L ι).comp (restrictTotalDegree ι ℝ N).injective_subtype
rw [← LinearMap.coe_comp] at this
obtain ⟨⟨φ, supφ, difφ⟩, hφ⟩ :=
LinearMap.flip_surjective_iff₁.2 this ((aeval 0).toLinearMap.comp <| Submodule.subtype _)
exact ⟨φ, supφ, difφ, fun P hP ↦ congr($hφ ⟨P, (mem_restrictTotalDegree ι N P).mpr hP⟩)⟩
Loading

0 comments on commit 3af4fac

Please sign in to comment.