Zulip Chat Archive

Stream: general

Topic: NotEqualSign


James Arthur (May 21 2020 at 18:01):

I'm relatively new to LEAN and I'm trying to prove that $succ(x)\neq0$, I get my goal of $succ(x)\neq0$ and am a bit stuck from there. I have tried cases and induction.

Yury G. Kudryashov (May 21 2020 at 18:02):

#mwe

James Arthur (May 21 2020 at 18:09):

It's from the natural numbers game, but I assume just add the link as it suggests:

https://wwwf.imperial.ac.uk/~buzzard/xena/natural_number_game/?world=8&level=9

Jeremy Avigad (May 21 2020 at 18:09):

This will work:

open nat

example (n : ) : succ n  0 :=
begin
  intro h,
  contradiction
end

What is going on is that the natural numbers are an inductively defined type, and Lean knows that the constructors (in this case, zero and succ) are disjoint. That is one of the things the contradiction tactic will look for.

James Arthur (May 21 2020 at 18:11):

Jeremy Avigad said:

This will work:

open nat

example (n : ) : succ n  0 :=
begin
  intro h,
  contradiction
end

What is going on is that the natural numbers are an inductively defined type, and Lean knows that the constructors (in this case, zero and succ) are disjoint. That is one of the things the contradiction tactic will look for.

Thankyou, although I assume this isn't the intended solution, it works!

Jalex Stark (May 21 2020 at 18:14):

I imagine the intended solution starts like this (and may give you some extra insight into why jeremy's solution works

open nat

example (n : ) : succ n  0 :=
begin
  cases n,
end

Jason KY. (May 21 2020 at 18:15):

If you don't want to use contradiction you can use the axiom zero_ne_succ

intro h,
apply zero_ne_succ a,
rwa h

Mario Carneiro (May 21 2020 at 18:15):

@Jalex Stark there is no need to cases on n as it is already a successor in the theorem

Mario Carneiro (May 21 2020 at 18:15):

intro h, cases h would be my recommendation

Mario Carneiro (May 21 2020 at 18:16):

It's also a place for my favorite trick:

example (n : ) : succ n  0.

Mario Carneiro (May 21 2020 at 18:16):

the no proof proof

Bhavik Mehta (May 21 2020 at 18:16):

Can you explalin what . means? In general as well as here

Mario Carneiro (May 21 2020 at 18:17):

it's a 0-ary use of the equation compiler

Mario Carneiro (May 21 2020 at 18:17):

in general it ends a definition, which is almost always optional but not here

James Arthur (May 21 2020 at 18:17):

Thankyou all!

Mario Carneiro (May 21 2020 at 18:18):

(usually the end of a definition is signaled by the next command keyword, e.g. the def/theorem on the next line)

Kevin Buzzard (May 21 2020 at 23:46):

I love it when he comes out with those dot proofs.

Kevin Buzzard (May 21 2020 at 23:46):

It is ultimate golf.


Last updated: Dec 20 2023 at 11:08 UTC