Zulip Chat Archive
Stream: general
Topic: create alias
Zesen Qian (Aug 17 2018 at 15:24):
How can I create an alias to anther declaration? Say, in my namespace foo
I want to create a true
such that users can see foo.true
and the prover treats it equally to true
from core.
Mario Carneiro (Aug 17 2018 at 15:32):
equally is hard, but there are a few ways to get close
Zesen Qian (Aug 17 2018 at 15:32):
right now I'm thinking about def
with attribute [reducible]
Mario Carneiro (Aug 17 2018 at 15:32):
@[reducible] def
makes rw
and simp
see through the definition, as well as typeclass inference
Zesen Qian (Aug 17 2018 at 15:32):
I guess that should work, but really I'm looking for shorter path.
Mario Carneiro (Aug 17 2018 at 15:33):
abbreviation
does something similar with kernel reduction, I'm not sure exactly
Mario Carneiro (Aug 17 2018 at 15:33):
what do you mean "shorter path"?
Zesen Qian (Aug 17 2018 at 15:33):
I mean, less characters to type.
Zesen Qian (Aug 17 2018 at 15:33):
alias true = true would be the best.
Mario Carneiro (Aug 17 2018 at 15:34):
mathlib has an alias
tactic, but it doesn't set reducible
Mario Carneiro (Aug 17 2018 at 15:34):
what's wrong with just def true := true
?
Chris Hughes (Aug 17 2018 at 15:34):
notation
?
Mario Carneiro (Aug 17 2018 at 15:36):
also, what is your use case? I wrote alias
to support alias constructions but it doesn't get much use since I specifically try to avoid aliases
Zesen Qian (Aug 17 2018 at 15:36):
I need something in my namespace that's definitionally equal to true
Zesen Qian (Aug 17 2018 at 15:37):
@Chris Hughes I haven't used notation before, can you give an example?
Mario Carneiro (Aug 17 2018 at 15:37):
def true := true
is the easiest way to accomplish that
Mario Carneiro (Aug 17 2018 at 15:37):
notation `true'` := true
Mario Carneiro (Aug 17 2018 at 15:38):
but notation is not a def
Mario Carneiro (Aug 17 2018 at 15:38):
so there will be no foo.true'
that way
Zesen Qian (Aug 17 2018 at 15:38):
yeah, I realize that.
Zesen Qian (Aug 17 2018 at 15:38):
ok, so the best way is reducible
def
.
Mario Carneiro (Aug 17 2018 at 15:38):
but you still haven't said why you need this
Zesen Qian (Aug 17 2018 at 15:39):
I'm doing some metaprogramming. A proof given by SMT solvers is mapped to a proof in lean.
Zesen Qian (Aug 17 2018 at 15:39):
so a true
in source proof mapped to true
in lean.
Mario Carneiro (Aug 17 2018 at 15:39):
then just map to the real true
Zesen Qian (Aug 17 2018 at 15:39):
I have a file containing all stuff that source proofs will refer.
Zesen Qian (Aug 17 2018 at 15:40):
so I don't need to write the mapping myself. The meta program will look it up itself.
Mario Carneiro (Aug 17 2018 at 15:41):
but then your output statements will just be needlessly encoded with reducible defs
Mario Carneiro (Aug 17 2018 at 15:41):
you are writing the mapping just by giving these defs
Zesen Qian (Aug 17 2018 at 15:41):
yeah, but that's not big problem, no one is gonna read the proof as long as it's correct.
Zesen Qian (Aug 17 2018 at 15:41):
machine generated proofs are never intended for people.
Mario Carneiro (Aug 17 2018 at 15:42):
heh, you would be surprised
Zesen Qian (Aug 17 2018 at 15:42):
I hope I will never be suprised.
Zesen Qian (Aug 17 2018 at 15:42):
anyway, I'm going reducible
def
s.
Mario Carneiro (Aug 17 2018 at 15:43):
I don't think there is any point in using reducible here though. if it's in the proof term it's in the proof term
Zesen Qian (Aug 17 2018 at 15:44):
I don't know what you meant.
Mario Carneiro (Aug 17 2018 at 15:44):
you aren't using it with rw or anything so it won't be unfolded
Mario Carneiro (Aug 17 2018 at 15:49):
if you put together a proof using these variant definitions, it will make no difference to the type-correctness as long as it's defeq, and a regular def accomplishes that
Zesen Qian (Aug 17 2018 at 15:50):
I think you are right.
Zesen Qian (Aug 17 2018 at 15:50):
I can now get it work without reducible, but I will see it can keep working.
Zesen Qian (Aug 17 2018 at 15:50):
yeah, but I'm thinking about if the user provides me with the "real" true
.
Zesen Qian (Aug 17 2018 at 15:50):
and when a proof depends on the definitional equality between these two true
, will that still work?
Mario Carneiro (Aug 17 2018 at 15:52):
yes, that's what defeq does
Zesen Qian (Aug 17 2018 at 15:52):
ok then!
Mario Carneiro (Aug 17 2018 at 15:52):
you can replace true
with true'
anywhere in the proof with no changes
Zesen Qian (Aug 17 2018 at 15:53):
ok. I guess I overlooked lean's ability of identifying equalities.
Last updated: Dec 20 2023 at 11:08 UTC