Zulip Chat Archive

Stream: new members

Topic: default operator == for structure ?


Jz Pan (Dec 24 2020 at 18:04):

Please forgive me for describing problem in C++ way. I have the following code

structure affine_plane_point (K : Type*) [field K] :=
mk :: (x y : K)

and now I try to prove

P: affine_plane_point K
 P = {x := P.x, y := P.y}

but have no ideas. simp refl library_search and hint are all failed. Do I need to define the operator == for affine_plane_point exilicitly ?

Johan Commelin (Dec 24 2020 at 18:06):

@Jz Pan cases P

Johan Commelin (Dec 24 2020 at 18:06):

and then dsimp

Johan Commelin (Dec 24 2020 at 18:06):

What you want is an "ext lemma"

Yakov Pechersky (Dec 24 2020 at 18:06):

Would tagging the structure as [ext] work?

Johan Commelin (Dec 24 2020 at 18:07):

You can search mathlib for [ext] to get examples.

Johan Commelin (Dec 24 2020 at 18:07):

Aside: note that mathlib has quite a bit on euclidean/affine geometry. What are your plans with affine_plane_point?

Jz Pan (Dec 24 2020 at 18:08):

My plan is also define projective plane and embed affine plane point into it.

Jz Pan (Dec 24 2020 at 18:09):

An ad-hoc work for Weierstrass equations.

Jz Pan (Dec 24 2020 at 18:16):

Thanks. The problem solved with

@[ext]
structure affine_plane_point (K : Type*) [field K] :=
mk :: (x y : K)

and the P = {x := P.x, y := P.y} can be proved by

  rw affine_plane_point.ext_iff,
  simp,

Johan Commelin (Dec 24 2020 at 18:19):

now that you tagged it with @[ext] you can also use the ext tactic (instead of that rw)

Johan Commelin (Dec 24 2020 at 18:20):

ext stands for "extensionality", and it means something like "if all the components of two things are equal, then the two things are equal"

Jz Pan (Dec 24 2020 at 18:22):

I tried ext but it splits the goal into two subgoals. So currently I still prefer rw

Johan Commelin (Dec 24 2020 at 18:34):

does ext; refl work?

Jz Pan (Dec 24 2020 at 18:37):

Yes. It works.


Last updated: Dec 20 2023 at 11:08 UTC