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: Feb 28 2026 at 14:05 UTC