Skip to content

Commit

Permalink
Trigger CI for leanprover/lean4#2964
Browse files Browse the repository at this point in the history
  • Loading branch information
leanprover-community-mathlib4-bot committed Dec 15, 2023
2 parents 91fc481 + 3df64fa commit df351c9
Show file tree
Hide file tree
Showing 1,334 changed files with 38,509 additions and 21,887 deletions.
5 changes: 4 additions & 1 deletion .docker/gitpod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -
# install whichever toolchain mathlib is currently using
RUN . ~/.profile && elan toolchain install $(curl https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain)

ENV PATH="/home/gitpod/.local/bin:/home/gitpod/.elan/bin:${PATH}"
# install neovim (for any lean.nvim user), via tarball since the appimage doesn't work for some reason, and jammy's version is ancient
RUN curl -s -L https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz | tar xzf - && sudo mv nvim-linux64 /opt/nvim

ENV PATH="/home/gitpod/.local/bin:/home/gitpod/.elan/bin:/opt/nvim/bin:${PATH}"

# fix the infoview when the container is used on gitpod:
ENV VSCODE_API_VERSION="1.50.0"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0-rc2
git checkout toolchain/v4.3.0
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
lake build
./test.sh
cd ..
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0-rc2
git checkout toolchain/v4.3.0
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
lake build
./test.sh
cd ..
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0-rc2
git checkout toolchain/v4.3.0
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
lake build
./test.sh
cd ..
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build_fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ jobs:
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
git checkout toolchain/v4.3.0-rc2
git checkout toolchain/v4.3.0
# Now that the git hash is embedded in each olean,
# we need to compile lean4checker on the same toolchain
cp ../lean-toolchain .
lake build
./test.sh
cd ..
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/nightly_detect_failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,29 @@ jobs:
toolchain=$(<lean-toolchain)
if [[ $toolchain =~ leanprover/lean4:nightly-([a-zA-Z0-9_-]+) ]]; then
version=${BASH_REMATCH[1]}
echo "NIGHTLY=$version" >> $GITHUB_ENV
git push origin refs/heads/nightly-testing:refs/heads/nightly-testing-$version
else
echo "Error: The file lean-toolchain does not contain the expected pattern."
exit 1
fi
# Next, we'll update the `nightly-with-mathlib` branch at Lean.
- name: Cleanup workspace
run: |
sudo rm -rf *
# Checkout the Lean repository on 'nightly-with-mathlib'
- name: Checkout Lean repository
uses: actions/checkout@v3
with:
repository: leanprover/lean4
token: ${{ secrets.LEAN_PR_TESTING }}
ref: nightly-with-mathlib
# Merge the relevant nightly.
- name: Fetch tags from 'lean4-nightly', and merge relevant nightly into 'nightly-with-mathlib'
run: |
git remote add nightly https://github.com/leanprover/lean4-nightly.git
git fetch nightly --tags
# Note: old jobs may run out of order, but it is safe to merge an older `nightly-YYYY-MM-DD`.
git merge nightly-${NIGHTLY} --strategy-option ours --allow-unrelated-histories || true
git push origin
11 changes: 6 additions & 5 deletions .github/workflows/nightly_merge_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
name: Merge master to nightly

on:
push:
branches:
- master
schedule:
- cron: '30 */3 * * *' # 8AM CET/11PM PT

jobs:
merge-to-nightly:
Expand All @@ -25,9 +24,11 @@ jobs:
- name: Merge master to nightly favoring nightly changes
run: |
git checkout nightly-testing
# If the merge goes badly, we proceed anyway via '|| true'
# If the merge goes badly, we proceed anyway via '|| true'.
# CI will report failures on the 'nightly-testing' branch direct to Zulip.
git merge master --strategy-option ours --no-commit --allow-unrelated-histories || true
git add .
git commit -m "Merge master into nightly-testing"
# If there's nothing to do (because there are no new commits from master),
# that's okay, hence the '|| true'.
git commit -m "Merge master into nightly-testing" || true
git push origin nightly-testing
16 changes: 7 additions & 9 deletions Archive/Examples/IfNormalization/WithoutAesop.lean
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,21 @@ def normalize' (l : AList (fun _ : ℕ => Bool)) :
· simp_all
· have := ht₃ v
have := he₃ v
simp_all? says simp_all only [Option.elim, ne_eq, normalized, Bool.and_eq_true,
Bool.not_eq_true', AList.lookup_insert]
simp_all? says simp_all only [Option.elim, normalized, Bool.and_eq_true,
Bool.not_eq_true', AList.lookup_insert, imp_false]
obtain ⟨⟨⟨tn, tc⟩, tr⟩, td⟩ := ht₂
split <;> rename_i h'
· subst h'
simp_all
· simp_all? says simp_all only [ne_eq, hasNestedIf, Bool.or_self, hasConstantIf,
and_self, hasRedundantIf, Bool.or_false, beq_eq_false_iff_ne, not_false_eq_true,
disjoint, List.disjoint, decide_not, Bool.and_true, Bool.and_eq_true,
Bool.not_eq_true', decide_eq_false_iff_not, true_and]
constructor <;> assumption
· simp_all? says simp_all only [hasNestedIf, Bool.or_self, hasConstantIf, and_self,
hasRedundantIf, Bool.or_false, beq_eq_false_iff_ne, ne_eq, not_false_eq_true,
disjoint, List.disjoint, decide_True, Bool.and_self]
· have := ht₃ w
have := he₃ w
by_cases h : w = v
· subst h; simp_all
· simp_all? says simp_all only [Option.elim, ne_eq, normalized, Bool.and_eq_true,
Bool.not_eq_true', not_false_eq_true, AList.lookup_insert_ne]
· simp_all? says simp_all only [Option.elim, normalized, Bool.and_eq_true,
Bool.not_eq_true', ne_eq, not_false_eq_true, AList.lookup_insert_ne]
obtain ⟨⟨⟨en, ec⟩, er⟩, ed⟩ := he₂
split at b <;> rename_i h'
· subst h'; simp_all
Expand Down
6 changes: 3 additions & 3 deletions Archive/Imo/Imo1972Q5.lean
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from `hneg` directly), finally raising a contradiction with `k' < k'`.
theorem imo1972_q5 (f g : ℝ → ℝ) (hf1 : ∀ x, ∀ y, f (x + y) + f (x - y) = 2 * f x * g y)
(hf2 : ∀ y, ‖f y‖ ≤ 1) (hf3 : ∃ x, f x ≠ 0) (y : ℝ) : ‖g y‖ ≤ 1 := by
-- Suppose the conclusion does not hold.
by_contra' hneg
by_contra! hneg
set S := Set.range fun x => ‖f x‖
-- Introduce `k`, the supremum of `f`.
let k : ℝ := sSup S
Expand Down Expand Up @@ -82,8 +82,8 @@ This is a more concise version of the proof proposed by Ruben Van de Velde.
-/
theorem imo1972_q5' (f g : ℝ → ℝ) (hf1 : ∀ x, ∀ y, f (x + y) + f (x - y) = 2 * f x * g y)
(hf2 : BddAbove (Set.range fun x => ‖f x‖)) (hf3 : ∃ x, f x ≠ 0) (y : ℝ) : ‖g y‖ ≤ 1 := by
-- porting note: moved `by_contra'` up to avoid a bug
by_contra' H
-- porting note: moved `by_contra!` up to avoid a bug
by_contra! H
obtain ⟨x, hx⟩ := hf3
set k := ⨆ x, ‖f x‖
have h : ∀ x, ‖f x‖ ≤ k := le_ciSup hf2
Expand Down
2 changes: 1 addition & 1 deletion Archive/Imo/Imo1994Q1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ theorem imo1994_q1 (n : ℕ) (m : ℕ) (A : Finset ℕ) (hm : A.card = m + 1)
_ = (m + 1) * (n + 1) := by rw [sum_const, card_fin, Nat.nsmul_eq_mul]
-- It remains to prove the key inequality, by contradiction
rintro k -
by_contra' h : a k + a (rev k) < n + 1
by_contra! h : a k + a (rev k) < n + 1
-- We exhibit `k+1` elements of `A` greater than `a (rev k)`
set f : Fin (m + 1) ↪ ℕ :=
fun i => a i + a (rev k), by
Expand Down
2 changes: 1 addition & 1 deletion Archive/Imo/Imo2008Q4.lean
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ theorem imo2008_q4 (f : ℝ → ℝ) (H₁ : ∀ x > 0, f x > 0) :
field_simp at H₂ ⊢
linear_combination 1 / 2 * H₂
have h₃ : ∀ x > 0, f x = x ∨ f x = 1 / x := by simpa [sub_eq_zero] using h₂
by_contra' h
by_contra! h
rcases h with ⟨⟨b, hb, hfb₁⟩, ⟨a, ha, hfa₁⟩⟩
obtain hfa₂ := Or.resolve_right (h₃ a ha) hfa₁
-- f(a) ≠ 1/a, f(a) = a
Expand Down
6 changes: 3 additions & 3 deletions Archive/Imo/Imo2013Q5.lean
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Imo2013Q5

theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
(h : ∀ n : ℕ, 0 < n → x ^ n - 1 < y ^ n) : x ≤ y := by
by_contra' hxy
by_contra! hxy
have hxmy : 0 < x - y := sub_pos.mpr hxy
have hn : ∀ n : ℕ, 0 < n → (x - y) * (n : ℝ) ≤ x ^ n - y ^ n := by
intro n _
Expand Down Expand Up @@ -68,7 +68,7 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
(h : ∀ n : ℕ, 0 < n → x ^ n - 1 < y ^ n) : x ≤ y := by
refine' le_of_all_pow_lt_succ hx _ h
by_contra' hy'' : y ≤ 1
by_contra! hy'' : y ≤ 1
-- Then there exists y' such that 0 < y ≤ 1 < y' < x.
let y' := (x + 1) / 2
have h_y'_lt_x : y' < x :=
Expand Down Expand Up @@ -163,7 +163,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
(x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := by gcongr; exact H5 x hx
_ ≤ f x + f (a ^ N - x) := by gcongr; exact H5 _ h_big_enough
have hxp : 0 < x := by positivity
have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN; linarith
have hNp : 0 < N := by by_contra! H; rw [le_zero_iff.mp H] at hN; linarith
have h2 :=
calc
f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) := H2 x (a ^ N - x) hxp (by positivity)
Expand Down
2 changes: 1 addition & 1 deletion Archive/Imo/Imo2021Q1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ theorem imo2021_q1 :
have hBsub : B ⊆ Finset.Icc n (2 * n) := by
intro c hcB; simpa only [Finset.mem_Icc] using h₂ c hcB
have hB' : 2 * 1 < (B ∩ (Finset.Icc n (2 * n) \ A) ∪ B ∩ A).card := by
rw [←inter_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
rw [← inter_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
inter_eq_left.2 hBsub]
exact Nat.succ_le_iff.mp hB
-- Since B has cardinality greater or equal to 3, there must exist a subset C ⊆ B such that
Expand Down
3 changes: 1 addition & 2 deletions Archive/Wiedijk100Theorems/AscendingDescendingSequences.lean
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ theorem erdos_szekeres {r s n : ℕ} {f : Fin n → α} (hn : r * s < n) (hf : I
-- Finished both goals!
-- Now that we have uniqueness of each label, it remains to do some counting to finish off.
-- Suppose all the labels are small.
by_contra q
push_neg at q
by_contra! q
-- Then the labels `(a_i, b_i)` all fit in the following set: `{ (x,y) | 1 ≤ x ≤ r, 1 ≤ y ≤ s }`
let ran : Finset (ℕ × ℕ) := (range r).image Nat.succ ×ˢ (range s).image Nat.succ
-- which we prove here.
Expand Down
1 change: 1 addition & 0 deletions Archive/Wiedijk100Theorems/BallotProblem.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def countedSequence (p q : ℕ) : Set (List ℤ) :=
{l | l.count 1 = p ∧ l.count (-1) = q ∧ ∀ x ∈ l, x = (1 : ℤ) ∨ x = -1}
#align ballot.counted_sequence Ballot.countedSequence

open scoped List in
/-- An alternative definition of `countedSequence` that uses `List.Perm`. -/
theorem mem_countedSequence_iff_perm {p q l} :
l ∈ countedSequence p q ↔ l ~ List.replicate p (1 : ℤ) ++ List.replicate q (-1) := by
Expand Down
33 changes: 13 additions & 20 deletions Archive/Wiedijk100Theorems/Partition.lean
Original file line number Diff line number Diff line change
Expand Up @@ -384,19 +384,11 @@ theorem partialOddGF_prop [Field α] (n m : ℕ) :
α) =
coeff α n (partialOddGF m) := by
rw [partialOddGF]
-- Porting note: `convert` timeouts. Please revert to `convert` when the performance of `convert`
-- is improved.
refine Eq.trans ?_
(Eq.trans (partialGF_prop α n ((range m).map mkOdd) ?_ (fun _ => Set.univ) fun _ _ => trivial)
(Eq.symm ?_))
convert partialGF_prop α n
((range m).map mkOdd) _ (fun _ => Set.univ) (fun _ _ => trivial) using 2
· congr
simp only [true_and_iff, forall_const, Set.mem_univ]
· intro i
rw [mem_map]
rintro ⟨a, -, rfl⟩
exact Nat.succ_pos _
· congr 1
rw [Finset.prod_map]
· rw [Finset.prod_map]
simp_rw [num_series']
congr! 2 with x
ext k
Expand All @@ -406,6 +398,10 @@ theorem partialOddGF_prop [Field α] (n m : ℕ) :
apply mul_comm
rintro ⟨a_w, -, rfl⟩
apply Dvd.intro_left a_w rfl
· intro i
rw [mem_map]
rintro ⟨a, -, rfl⟩
exact Nat.succ_pos _
#align theorems_100.partial_odd_gf_prop Theorems100.partialOddGF_prop

/-- If m is big enough, the partial product's coefficient counts the number of odd partitions -/
Expand Down Expand Up @@ -438,23 +434,20 @@ theorem partialDistinctGF_prop [CommSemiring α] (n m : ℕ) :
α) =
coeff α n (partialDistinctGF m) := by
rw [partialDistinctGF]
-- Porting note: `convert` timeouts. Please revert to `convert` when the performance of `convert`
-- is improved.
refine Eq.trans ?_
(Eq.trans (partialGF_prop α n ((range m).map ⟨Nat.succ, Nat.succ_injective⟩) ?_
(fun _ => {0, 1}) fun _ _ => Or.inl rfl) (Eq.symm ?_))
convert partialGF_prop α n
((range m).map ⟨Nat.succ, Nat.succ_injective⟩) _ (fun _ => {0, 1}) (fun _ _ => Or.inl rfl)
using 2
· congr
congr! with p
rw [Multiset.nodup_iff_count_le_one]
congr! with i
rcases Multiset.count i p.parts with (_ | _ | ms) <;> simp
· simp_rw [Finset.prod_map, two_series]
congr with i
simp [Set.image_pair]
· simp only [mem_map, Function.Embedding.coeFn_mk]
rintro i ⟨_, _, rfl⟩
apply Nat.succ_pos
· congr 1
simp_rw [Finset.prod_map, two_series]
congr with i
simp [Set.image_pair]
#align theorems_100.partial_distinct_gf_prop Theorems100.partialDistinctGF_prop

/-- If m is big enough, the partial product's coefficient counts the number of distinct partitions
Expand Down
16 changes: 10 additions & 6 deletions Cache/Hashing.lean
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ This happens with the `lean-pr-testing-NNNN` toolchains when Lean 4 PRs are upda
def getRootHash : IO UInt64 := do
let rootFiles : List FilePath := ["lakefile.lean", "lean-toolchain", "lake-manifest.json"]
let isMathlibRoot ← isMathlibRoot
let qualifyPath ←
if isMathlibRoot then
pure id
else
pure ((← mathlibDepPath) / ·)
let hashs ← rootFiles.mapM fun path =>
hashFileContents <$> IO.FS.readFile (if isMathlibRoot then path else mathlibDepPath / path)
return hash ((hash Lean.versionString) :: hashs)
hashFileContents <$> IO.FS.readFile (qualifyPath path)
return hash (hash Lean.githash :: hashs)

/--
Computes the hash of a file, which mixes:
Expand All @@ -81,14 +86,13 @@ Computes the hash of a file, which mixes:
* The hashes of the imported files that are part of `Mathlib`
-/
partial def getFileHash (filePath : FilePath) : HashM $ Option UInt64 := do
let stt ← get
match stt.cache.find? filePath with
match (← get).cache.find? filePath with
| some hash? => return hash?
| none =>
let fixedPath := (← IO.getPackageDir filePath) / filePath
if !(← fixedPath.pathExists) then
IO.println s!"Warning: {fixedPath} not found. Skipping all files that depend on it"
set { stt with cache := stt.cache.insert filePath none }
modify fun stt => { stt with cache := stt.cache.insert filePath none }
return none
let content ← IO.FS.readFile fixedPath
let fileImports := getFileImports content pkgDirs
Expand All @@ -97,7 +101,7 @@ partial def getFileHash (filePath : FilePath) : HashM $ Option UInt64 := do
match importHash? with
| some importHash => importHashes := importHashes.push importHash
| none =>
set { stt with cache := stt.cache.insert filePath none }
modify fun stt => { stt with cache := stt.cache.insert filePath none }
return none
let rootHash := (← get).rootHash
let pathHash := hash filePath.components
Expand Down
Loading

0 comments on commit df351c9

Please sign in to comment.