Skip to content

Commit

Permalink
do some multiGoal linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Dec 19, 2024
1 parent b0ba458 commit 03722eb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 37 deletions.
11 changes: 7 additions & 4 deletions Compfiles/Imo1965P1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ problem imo1965_p1 :
simp [←pow_two, h0]
simp only [Set.mem_Icc]
simp_rw [this, and_true]
symm; ext x; constructor; dsimp
. rw [the_answer]; rintro ⟨h1, h2⟩
symm; ext x; constructor
· dsimp
rw [the_answer]; rintro ⟨h1, h2⟩
constructor
. constructor <;> linarith
have : x ∈ Ico (π/4) (π / 2) ∪ Icc (π/2) (3*π/2) ∪ Ioc (3*π/2) (7*π/4) := by
Expand All @@ -57,7 +58,8 @@ problem imo1965_p1 :
have cosx2_nonneg : 02 * cos x := by linarith
rw [←abs_of_nonneg cosx2_nonneg, ←sq_le_sq, h0, abs_of_nonpos cos2x_nonpos, cos_two_mul]
linarith
. trans 0; swap; simp
. trans 0; swap;
· simp
suffices cos x ≤ 0 by linarith
apply cos_nonpos_of_pi_div_two_le_of_le h3
linarith
Expand Down Expand Up @@ -90,7 +92,8 @@ problem imo1965_p1 :
rw [cos_pi_div_four, div_pow] at this; norm_num at this
linarith
rw [sq_lt_sq, abs_of_nonneg cosx_nonneg, abs_of_nonneg]
swap; simp [cos_pi_div_four]; positivity
swap
· simp [cos_pi_div_four]; positivity
rcases h4 with h5 | h5
. apply cos_lt_cos_of_nonneg_of_le_pi_div_two h1 (by linarith) h5
rw [←cos_neg x, ←cos_add_two_pi (-x)]
Expand Down
44 changes: 21 additions & 23 deletions Compfiles/Imo1970P4.lean
Original file line number Diff line number Diff line change
Expand Up @@ -174,30 +174,28 @@ lemma odd_props (n : ℕ) (odd_s : Finset ℕ) (s_odd_eq : odd_s = (Finset.Icc n
ext x
simp_all only [Finset.mem_insert, Finset.mem_singleton, Finset.mem_filter, Finset.mem_Icc]
apply Iff.intro
intro H
constructor
· omega
· cases H
case inl h3 =>
simp_all only
case inr h4 =>
cases h4
case inl h5 =>
simp_all only
dsimp[Odd]
dsimp[Odd] at h
obtain ⟨k, h6⟩ := h
use k + 1
rw[h6]
ring_nf
case inr h6 =>
· intro H
constructor
· omega
· cases H
case inl h3 =>
simp_all only
dsimp[Odd]
dsimp[Odd] at h
obtain ⟨k, h6⟩ := h
use k + 2
rw[h6]
ring_nf
case inr h4 =>
cases h4
case inl h5 =>
simp_all only
dsimp[Odd] at h ⊢
obtain ⟨k, h6⟩ := h
use k + 1
rw[h6]
ring_nf
case inr h6 =>
simp_all only
dsimp[Odd] at h ⊢
obtain ⟨k, h6⟩ := h
use k + 2
rw[h6]
ring_nf
intro H
obtain ⟨a, Hh⟩ := H
have h3 := Odd.not_two_dvd_nat Hh
Expand Down
6 changes: 3 additions & 3 deletions Compfiles/Usa1996P1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ problem usa1996_p1 :
ring
· rw [mul_comm]
rw [Finset.sum_eq_zero]
simp only [zero_sub]
rw [←neg_mul, ←Real.cos_sub_pi]
congr; ring
· simp only [zero_sub]
rw [←neg_mul, ←Real.cos_sub_pi]
congr; ring
intro n _
rw [cos_add]
ring
Expand Down
8 changes: 4 additions & 4 deletions Compfiles/Usa2001P3.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ problem usa2001_p3 (a b c : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c)
rw [←geq]
wlog ha1 : a≤1 generalizing a b c with Ha
· by_cases hb1 : b ≤ 1
rw [(by ring_nf : g a b c = g b a c)]
exact Ha b a c hb ha hc (by rw [←h]; unfold f; ring_nf) hb1
· rw [(by ring_nf : g a b c = g b a c)]
exact Ha b a c hb ha hc (by rw [←h]; unfold f; ring_nf) hb1
by_cases hc1 : c ≤ 1
rw [(by ring_nf : g a b c = g c b a)]
exact Ha c b a hc hb ha (by rw [←h]; unfold f; ring_nf) hc1
· rw [(by ring_nf : g a b c = g c b a)]
exact Ha c b a hc hb ha (by rw [←h]; unfold f; ring_nf) hc1
apply False.elim (ne_of_not_le _ h)
unfold f
rw [not_le]
Expand Down
2 changes: 1 addition & 1 deletion Compfiles/Usa2015P1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ problem usa2015_p1 (x y : ℤ) :
all_goals obtain ⟨h, hx, hy⟩ := h; rw [hx, hy]; ring_nf; use (h + h ^ 2); ring_nf
· intro h; apply_fun (· * 3 ^ 3) at h; rw [←mul_pow, (add_mul _ 1)] at h; simp at h
norm_num at h; norm_cast at h
suffices : (x + y) % 3 = 0; rw [←dvd_def]; exact Int.dvd_of_emod_eq_zero this
suffices (x + y) % 3 = 0 by rw [←dvd_def]; exact Int.dvd_of_emod_eq_zero this
have h1 : (x ^ (2 : ℕ) + x * y + y ^ (2 : ℕ)) * (27 : ℤ) % 3 =
(x + y + (3 : ℤ)) ^ (3 : ℕ) % 3 := by rw [h]
clear h
Expand Down
8 changes: 6 additions & 2 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import Lake

open Lake DSL

package compfiles where
leanOptions := #[
abbrev leanOptions : Array LeanOption := #[
`pp.unicode.fun, true⟩, -- pretty-prints `fun a ↦ b`
`autoImplicit, false⟩,
`relaxedAutoImplicit, false
-- ⟨`weak.linter.style.multiGoal, true⟩
]

package compfiles where
leanOptions := leanOptions
moreServerOptions := leanOptions

@[default_target]
lean_lib ProblemExtraction

Expand Down

0 comments on commit 03722eb

Please sign in to comment.