Zulip Chat Archive

Stream: Is there code for X?

Topic: Ring for vector spaces


Patrick Johnstone (Jan 02 2022 at 20:21):

I use ring a lot as in

example (x y z: )
        : x + y + z = x + (y + z)
        :=
begin
  ring,
end

But if I try

example (x y z: euclidean_space  (fin 10))
        : x + y + z = x + (y + z)
        :=
begin
  ring,
end

ring fails. Is there a way to get ring to work for Euclidean space vectors?

Eric Rodriguez (Jan 02 2022 at 20:31):

Does abelwork?

Alex J. Best (Jan 02 2022 at 20:32):

What ring structure would you want on the euclidean space? I doubt that instance is defined in mathlib.

Yaël Dillies (Jan 02 2022 at 20:37):

Maybe you just want pointwise addition/multiplication? In that case, you should use fin 10 → ℝ.

Patrick Johnstone (Jan 02 2022 at 20:52):

abel works thanks

Patrick Johnstone (Jan 02 2022 at 21:56):

OK next question (related). How about linarith?

example (x y z w : ) (h : x+y=z+w)
  : z-x=y-w
  := by linarith

Works.

example (x y z w : euclidean_space  (fin 10)) (h : x+y=z+w)
  : z-x=y-w
  := by linarith

Fails.

Heather Macbeth (Jan 02 2022 at 21:59):

See a message I just wrote in another stream, replacing ring with abel

Heather Macbeth (Jan 02 2022 at 22:04):

Essentially, figure out for yourself the coefficients linarith would have used:

import analysis.inner_product_space.pi_L2

example (x y z w : euclidean_space  (fin 10)) (h : x + y = z + w) :
  z - x = y - w :=
begin
  rw  sub_eq_zero at h ,
  have h' := congr_arg (λ x, -x) h,
  convert h';
  abel,
end

Heather Macbeth (Jan 02 2022 at 22:06):

By the way, do you really need to be working with euclidean_space? You might find you have fewer distracting details if you assume {x y z w : V} where

variables {V : Type*} [inner_product_space  V]

Patrick Johnstone (Jan 02 2022 at 22:23):

That's OK but seems more low-level than I was hoping for. Does Linarith just not work unless it's basically the reals or some similar "ordered field"?

Patrick Johnstone (Jan 02 2022 at 22:23):

Also why do you need to use ";" after convert?

Heather Macbeth (Jan 02 2022 at 22:24):

Patrick Johnstone said:

Also why do you need to use ";" after convert?

In this case you probably don't, but it makes the technique more general (it allows it to work for a system of 10 equations rather than just one).

Heather Macbeth (Jan 02 2022 at 22:25):

Patrick Johnstone said:

Does Linarith just not work unless it's basically the reals or some similar "ordered field"?

Right, I think it's ordered commutative semirings.

Patrick Johnstone (Jan 02 2022 at 22:28):

Is the problem with eucliean_space \R (fin 10) for linarith that it is not "totally ordered"?

Heather Macbeth (Jan 02 2022 at 22:28):

It sure isn't!

Patrick Johnstone (Jan 02 2022 at 22:32):

Ok and there isn't a linarith for equalities only? That doesn't need the commutative semiring to be ordered? That would seem to simplify things only trying to prove equalities.

Heather Macbeth (Jan 02 2022 at 22:33):

Please read the thread I linked above. Basically you're asking a for a "Grobner basis tactic", which doesn't exist currently in Lean, but which you can approximate by providing the coefficients yourself -- I indicated an efficient syntax for doing this.


Last updated: Dec 20 2023 at 11:08 UTC