Zulip Chat Archive
Stream: new members
Topic: positive integers
Lawrence Lin (Jan 08 2023 at 04:40):
Hi, all! How do I define the positive integers in lean? I want to introduce the equivalent of
x, y \in \mathbb{Z}^+
in lean...
resolved! i just used (x, y : \N) and (hpos : x > 0) same with y
Hanting Zhang (Jan 08 2023 at 05:22):
There's docs#pnat
Hanting Zhang (Jan 08 2023 at 05:23):
But sometimes what you're doing with (x : \N) (hp : x > 0)
works just as well
Lawrence Lin (Jan 08 2023 at 05:28):
thanks-
Lawrence Lin (Jan 08 2023 at 05:54):
right so i ran into another funny situation.. is it possible to introduce a new variable k = x^3 + y^3? i don't think lean's letting me do that. can't find where to do it in the documentation either
Lawrence Lin (Jan 08 2023 at 05:58):
trying to introduce it in an example
environment, but it's not happening :(
Hanting Zhang (Jan 08 2023 at 06:34):
you can do
example (x y : \N) (hp : x > 0) : true :=
begin
let k := x^3 + y^3
sorry
end
Lawrence Lin (Jan 08 2023 at 06:56):
... i should've known... thanks again
Hanting Zhang (Jan 08 2023 at 06:58):
btw let
is different from have
in that it retains the definition, while have
is for Props (and so definition irrelevant). One neat trick is that is you're using an IDE, you can hover over the keywords let
, have
, or any other tactic to see documentation on what it does
Yaël Dillies (Jan 08 2023 at 08:09):
set k :) x^3 + y^3 with hk
is also useful to know.
Kevin Buzzard (Jan 08 2023 at 13:28):
:=
not :)
:)
Patrick Johnson (Jan 08 2023 at 14:50):
generalizing hk : x^3 + y^3 = k
may be useful if you have x^3 + y^3
in the goal statement or if you plan to use rw
, subst
or induction
later in the proof (with let
/set
you may get type errors).
Martin Dvořák (Jan 09 2023 at 09:32):
I use (x_pos : x > 0)
all the time. It isn't necessary to express positivity by a data type.
Last updated: Dec 20 2023 at 11:08 UTC