Zulip Chat Archive

Stream: Is there code for X?

Topic: simple function sum coercion


Vasily Ilin (Nov 16 2023 at 07:04):

This lemma feels like it should be in mathlib but I could not find it. I would appreciate a pointer on how to prove it.

import Mathlib.MeasureTheory.Function.SimpleFunc
open MeasureTheory BigOperators
variable [MeasurableSpace Ω]

lemma coe_sum (f : I  (SimpleFunc Ω )) [Fintype I] : ( i, f i).toFun =  i, (f i).toFun := by
  sorry

Chris Birkbeck (Nov 16 2023 at 07:14):

Is it not something like'Finset.sum_map_val? Here:https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/BigOperators/Basic.html#Finset.sum_map_val

Vasily Ilin (Nov 16 2023 at 07:15):

I don't see any similarity. My lemma is about SimpleFunc

Chris Birkbeck (Nov 16 2023 at 07:17):

Hmm sorry maybe I misunderstood the question then. I thought you simply wanted to commute the function and sum

Vasily Ilin (Nov 16 2023 at 07:18):

I edited the question to include the imports. I need to compute the sum and the coercion from SimpleFunc to the underlying function

Vasily Ilin (Nov 16 2023 at 07:25):

I need docs#MeasureTheory.SimpleFunc.coe_add but instead of two functions, finitely many of them

Vasily Ilin (Nov 16 2023 at 07:39):

Mathematically, I would do induction on the cardinality of the fintype I. But I'm struggling to make it work in Lean.

Chris Birkbeck (Nov 16 2023 at 07:49):

Sorry I'm on mobile and not much help, but can you do induction on your finset instead of it's cardinality?

Vasily Ilin (Nov 16 2023 at 07:50):

I don't know what it would mean to do induction on a finset

Vasily Ilin (Nov 16 2023 at 07:53):

I tried induction' I with I hI but it gave an error.

Chris Birkbeck (Nov 16 2023 at 07:58):

Something like this: https://leanprover-community.github.io/mathlib4_docs/Mathlib/Data/Finset/Basic.html#Finset.induction

Vasily Ilin (Nov 16 2023 at 08:06):

This looks quite relevant. The difficulty becomes translating between a fintype and a finset

Yaël Dillies (Nov 16 2023 at 08:06):

It would be called SimpleFunc.coe_sum but it is indeed missing. Please state it with

Yaël Dillies (Nov 16 2023 at 08:06):

There's no difficulty at all. But you need to generalise your statement

Vasily Ilin (Nov 16 2023 at 08:07):

I'm sure there is no difficulty for someone skilled at Lean but so far I have not found a way

Vasily Ilin (Nov 16 2023 at 08:09):

I'm not sure what you mean by stating it with . You mean instead of toFun? I feel uneasy about the many up arrows that Lean employs so I wanted to be explicit about my coercion.

Vasily Ilin (Nov 16 2023 at 08:10):

To what should the statement be generalized? I tried

lemma coe_sum :  n : ,  I : Type, (f : I  (SimpleFunc Ω )),
(hI : Fintype I)  (hn : Fintype.card I = n)  ( i, f i).toFun =  i, (f i).toFun

and tried induction on n but got stuck.

Yaël Dillies (Nov 16 2023 at 08:10):

import Mathlib.MeasureTheory.Function.SimpleFunc

open MeasureTheory BigOperators

namespace SimpleFunc
variable {ι α β : Type*} [MeasurableSpace α] [CommMonoid β]

@[to_additive (attr := simp, norm_cast)]
lemma coe_prod (f : ι  SimpleFunc α β) (s : Finset ι) :  i in s, f i =  i in s, (f i) := by
  induction s using Finset.cons_induction <;> simp [*]

Yaël Dillies (Nov 16 2023 at 08:11):

(untested, but it should work)

Yaël Dillies (Nov 16 2023 at 08:12):

Vasily Ilin said:

I feel uneasy about the many up arrows that Lean employs so I wanted to be explicit about my coercion.

Sadly for you, if f : α →ₛ β, then ⇑f and f.toFun are not syntactically equal, so you really have to stick to the first.

Yaël Dillies (Nov 16 2023 at 08:13):

Else no lemma will apply, except the one turning f.toFun into ⇑f.

Vasily Ilin (Nov 16 2023 at 08:15):

I'm getting an error in the →ₛ symbol. I know I can just change it to SimpleFunction \a \b but I assume this code compiles for you. It's weird that it does not compile for me

Yaël Dillies (Nov 16 2023 at 08:18):

No, I literally wrote it on Zulip without an infoview to look at. I fixed it now.

Vasily Ilin (Nov 16 2023 at 08:26):

It's very impressive. Thank you for your help

Chris Birkbeck (Nov 16 2023 at 10:11):

Yaël Dillies said:

(untested, but it should work)

isnt this essentially how LLMs solve IMO problems in lean? guess without an infoview and then check the answer. This is more evidence towards the belief you're just a LLM Yaël :laughing:

Eric Wieser (Nov 16 2023 at 10:27):

Come on Yael, the canonical proof is obviously to conjure the →+ and use map_sum. As an AI language model, you should know this!


Last updated: Dec 20 2023 at 11:08 UTC