Zulip Chat Archive

Stream: general

Topic: Problem with looping over finset


AHan (Jan 15 2019 at 15:28):

Given s : finset ℕ, how can I construct s' : finset (ℕ × ℕ) s.t. ∀ a b, a b ∈ s ↔ (a, b) ∈ s' ?

Patrick Massot (Jan 15 2019 at 15:32):

I think what you wrote doesn't type-check

Mario Carneiro (Jan 15 2019 at 15:33):

I assume the a b means a * b

Patrick Massot (Jan 15 2019 at 15:34):

aren't you busy merging https://github.com/leanprover/mathlib/pull/583?

Patrick Massot (Jan 15 2019 at 15:35):

Seriously I'd never thought of that interpretation

AHan (Jan 15 2019 at 15:37):

I mean looping over s, and do something with every two distinct element in s.
(Sorry for my bad English, don't know how to express this well...

Mario Carneiro (Jan 15 2019 at 15:39):

what are you trying to do in your loop? lean doesn't have "looping constructs" as such

AHan (Jan 15 2019 at 15:41):

if with list I can do something like

variables {α : Type*}

def test (s : list ) : list  :=
do
    x <- s,
    y <- s,
    [x + y]

AHan (Jan 15 2019 at 15:42):

I'm just wondering how to do this in if the given type is finset

Mario Carneiro (Jan 15 2019 at 15:42):

the left arrow is just notation for list.bind, you can call finset.bind and it's just the same

Mario Carneiro (Jan 15 2019 at 15:43):

I guess there is a missing monad instance for finset that would allow you to use the same notation

AHan (Jan 15 2019 at 15:46):

Oh! Thanks a lot !!


Last updated: Dec 20 2023 at 11:08 UTC