Zulip Chat Archive
Stream: new members
Topic: Review of simple proof
Dylan (Jan 08 2025 at 04:08):
Hi everyone! I'm just getting started with lean and trying to learn by implementing some simple proofs from my elementary number theory book. I'd appreciate any feedback on this proof or any advice for improving my code quality and conciseness.
Here's the theorem I proved:
SCR-20250107-tyla.png
SCR-20250107-tyoj.png
Mitchell Lee (Jan 08 2025 at 04:41):
Nice!
There shouldn't be any need to have any assumption like 0 < a ∧ ¬p ∣ a
. The fact that ¬p ∣ a
already implies that 0 < a
. Also, it's usually considered better to write any assumption of the form P ∧ Q
as two separate assumptions.
Your lemma order_one_mod_p
shouldn't require either the assumption that p
is prime or the assumption that 0 < a ∧ ¬p ∣ a
. This is one of the benefits of providing the sensible junk value 0
as you did.
You can make your code a little simpler by making a
and p
implicit arguments to some of your lemmas. For example:
lemma order_gt_zero {a p : ℕ} (ha : 0 < a ∧ ¬p ∣ a) (hp : Prime p) : a.order p > 0 := by
This means you won't have to supply a
and p
when citing this lemma, because they can be inferred from the type of ha
and hp
.
Mitchell Lee (Jan 08 2025 at 04:47):
Great job with this proof. I recommend taking a look at Mathematics in Lean (https://leanprover-community.github.io/mathematics_in_lean/) if you haven't already.
Dylan (Jan 10 2025 at 23:29):
Thank you for the advice! I didn't realize how powerful implicit arguments are. I also managed to substantially simplify the proof using the calc
tactic.
Last updated: May 02 2025 at 03:31 UTC