Zulip Chat Archive

Stream: new members

Topic: Evaluating Permutations


Callum Cassidy-Nolan (Mar 16 2022 at 21:26):

Hi there, I'm working on the formalization of image.png

I'm running into a little bit of trouble with the permutation sigma,

test.lean

open_locale big_operators

theorem r_eq
    (n : )
    (x y :   )
    (σ : equiv.perm (finset.Ioo 1 n))
    (h :  i : , i  finset.Ioc 1 n  x i < x (i + 1))
    (h :  i : , i  finset.Ioc 1 n  y i < y (i + 1)) :
     i in finset.Ioo 1 n, x (n + 1 - i)  * y i   i in finset.Ioo 1 n, x (σ i) * y i 
     i in finset.Ioo 1 n, x (σ i) * y i   i in finset.Ioo 1 n, x i * y i := sorry

causing :

type mismatch at application
  σ i
term
  i
has type
  
but is expected to have type
  (finset.Ioo 1 n)
Additional information:
/home/ccn/lean/olympiad-formalization/src/int_alg/section_18_2.lean:36:30: context: switched to simple application elaboration procedure because failed to use expected type to elaborate it, error message
  type mismatch, term
    σ ?m_1
  has type
    (finset.Ioo 1 n)
  but is expected to have type
    

What would be the simplest way to get the coercions to work without making the statement too ugly?

Kevin Buzzard (Mar 16 2022 at 21:28):

Can you post a mwe? you can sum over the fintype rather than using in

Callum Cassidy-Nolan (Mar 16 2022 at 21:39):

Your correct - using a sum over i : finset.Ioo 1 n makes it so that all the evaluations work out

Callum Cassidy-Nolan (Mar 16 2022 at 21:39):

What's the difference between using in and : ?

Yaël Dillies (Mar 16 2022 at 21:43):

Why are you talking permutations on a subtype? You should rather be taking (σ : equiv.perm ℕ) (hσ : σ.support ⊆ finset.Ioo 1 n)

Yaël Dillies (Mar 16 2022 at 21:44):

(annoyingly, docs#equiv.perm.support currently only works over fintypes...)

Reid Barton (Mar 16 2022 at 21:49):

I think x y : fin n → ℝ would be a better start. There should be a nicer way to state that x and y are increasing, for example ∀ i j, i < j -> x i < x j or using some mathlib increasing definition.

Reid Barton (Mar 16 2022 at 21:50):

It looks like all your os and cs in Ixx are backwards--but better to avoid these intervals in the first place

Reid Barton (Mar 16 2022 at 21:51):

(For this theorem statement, I mean.)

Eric Wieser (Mar 16 2022 at 22:11):

docs#strict_mono, as strict_mono x would work. for indicating that the sequence is increasing

Eric Wieser (Mar 16 2022 at 22:11):

Note we already have file#algebra/order/rearrangement

Eric Wieser (Mar 16 2022 at 22:13):

Which isn't to say that this is a bad learning exercise; heck, there's even a "solution" to compare against!

Yaël Dillies (Mar 16 2022 at 22:28):

Oh of course, I didn't recognize the rearrangement inequality :face_palm:

Yaël Dillies (Mar 16 2022 at 22:29):

Note that I cooked up docs#monovary for the occasion. AFAIK our statement of the rearrangement inequality is absolutely nonstandard.


Last updated: Dec 20 2023 at 11:08 UTC