Zulip Chat Archive

Stream: new members

Topic: Clunky and condition


VayusElytra (Sep 03 2024 at 14:50):

Hello, I am working on the following relationship between sets of integers:

structure ExampleStruct where
  {S : Finset }

def ExampleRelation : ExampleStruct  ExampleStruct  Prop :=
  fun I J =>  d : (  Finset ),  N  I.S, N = ( x  (d N), x)   N  I.S, d N  J.S

The idea is that I and J are in a relationship if every element in the associated set to I can be expressed as a sum of elements of J's associated set. My function d only needs to map elements in I.S to the corresponding subset in J.S, so here it has too large a domain and codomain.

I think the condition ∀ N ∈ I.S, d N ⊆ J.S is clunky. It feels like this statement could just be integrated into the type of the codomain of d, but I haven't found anything too convincing so far. I have tried having d's codomain be Set J.S and Subtype J.S, but they create complications.

How would you write this properly?

Bjørn Kjos-Hanssen (Sep 03 2024 at 19:45):

This works and is maybe not too clunky(?):

import Mathlib.Data.Finset.Basic
import Mathlib.Algebra.BigOperators.Group.Finset

structure ExampleStruct where
  {S : Finset }

def ExampleRelation : ExampleStruct  ExampleStruct  Prop :=
  fun I J =>  d : I.S  Finset.powerset J.S,
     N : , (h : N  I.S)   N =  x  (d N,h), x

VayusElytra (Sep 04 2024 at 17:10):

Thank you, this is indeed a lot better!

Bjørn Kjos-Hanssen (Sep 04 2024 at 18:12):

Basically, powerset takes care of the problem of turning a subset of a Finset into another Finset.


Last updated: May 02 2025 at 03:31 UTC