Zulip Chat Archive

Stream: new members

Topic: How to fix this?


Lewis (Jun 20 2024 at 03:23):

(deleted)

Lewis (Jun 20 2024 at 03:24):

(deleted)

Lewis (Jun 20 2024 at 03:25):

How to fix this?

All Messages (3)
f.lean:14:12

Kim Morrison said:

f.lean:27:2
invalid 'end', insufficient scopes
f.lean:27:5
unexpected token ','; expected command

For the lean 4 code:

import Mathlib.Tactic
import Mathlib.Data.Nat.Prime
import Mathlib.Data.Nat.Factorial.Basic

open Nat

theorem infinite_primes (n : ) :  p : , p  n  Prime p :=
let m := factorial n
let p := minFac (m + 1)
p, 
-- Prove p ≥ n
begin
intro hp,
push_neg at hp,
-- Since p < n, p should divide factorial of n
have h1 : p  m := dvd_factorial (minFac_pos (m + 1)) (le_of_lt hp),
-- p also divides (m + 1)
have h2 : p  (m + 1) := minFac_dvd (m + 1),
-- Thus, p divides the difference, which is 1
have h3 : p  1 := nat_dvd_sub h2 h1,
-- p cannot be greater than 1
have h4 : p  1 := le_of_dvd (by decide) h3,
-- But prime p must be at least 2
have h5 : 2  p := Prime.two_le (minFac_prime (m + 1)),
-- Contradiction arises
linarith
end,
-- Prove p is prime
minFac_prime (m + 1)
⟩⟩

Thanks a lot!

Kim Morrison (Jun 20 2024 at 03:26):

#backticks

Notification Bot (Jun 20 2024 at 03:26):

2 messages were moved here from #maths > How to fix this? by Kim Morrison.

Kim Morrison (Jun 20 2024 at 03:27):

(Please don't double post.)

Notification Bot (Jun 20 2024 at 03:27):

A message was moved here from #mathlib4 > How to fix this? by Kim Morrison.

Kim Morrison (Jun 20 2024 at 03:28):

Err.. triple post. Really, please do not ever do this again, okay?

Lewis (Jun 20 2024 at 07:46):

Deleted; How to fix the errors? Thanks.

Eric Wieser (Jun 20 2024 at 08:03):

Please read #backticks and edit your post above

Richard Copley (Jun 20 2024 at 12:08):

begin, end and the commas at the ends of lines are all Lean 3 Syntax. You can read the first chapters of one or both of the Lean 4 books #tpil or #mil to get introduced to the Lean 4 syntax.

Here is a version of your proof in Lean 4 syntax with the errors corrected. If you still have questions, please ask.


Last updated: May 02 2025 at 03:31 UTC