juan_gandhi: (Default)
Just figured out how to calculate elements of yx for two sets (passed here as lists)

An element of an exponential is a Map[X, Y].

  /**
    * Set of all possible maps from set xs to set ys
    * @param xs domain of maps
    * @param ys codomain of maps
    * @tparam X type of domain elements
    * @tparam Y type of codomain elements
    * @return the set of all possible maps
    */
  def exponent[X, Y](xs: Set[X], ys: Set[Y]): Set[Map[X, Y]] = {
    setOf(allMaps(xs.toList, ys.toList),
      pow(ys size, xs size),
      (m: Map[X, Y]) => xs == m.keySet
    )
  }

  def allMaps[X, Y](xs: List[X], ys: List[Y]): List[Map[X, Y]] =
    (List(Map.empty[X, Y]) /: xs)((maps, x) =>
      maps flatMap (m => ys map (y => m + (x -> y)))
    )
juan_gandhi: (Default)

 Проблема бывает такая в теории множеств, что, мол, определили отношение эквивалентности между множествами, а классы эквивалентности не будут множествами, так где взять фактормножество?

Трюк такой - введем иерархию рангов множеств (ранг множества X - это ординал, определяемый так: берем все элементы X, их ординалы, к каждому прибавим 1, и берем супремум этих всех); так в классе эквивалентности берем множества минимального ранга.

Ну и получается множество, ну и.

juan_gandhi: (Default)
Take ZFC.

Take N (the set of natural numbers, exists by the axiom of infinity).
Take a predicate, p(x, y), which is true iff y = P^n(N), that is, a powerset of powerset).
By replacement axiom, there exists a set {N, P(N), P(P(N)),...}, defined by this predicate.
By union axiom, there is a union of this set.
WTF?

(src: https://arxiv.org/pdf/1212.6543.pdf, 10x [personal profile] xacid)
juan_gandhi: (Default)
https://en.wikipedia.org/wiki/Axiom_of_non-choice

Just slapped together a wikipedia article.
juan_gandhi: (VP)
So I build an exponential set, AB, which is a Set of Maps; but the thing is, either A or B can be infinite, so the map entryset can be infinite, so I cannot compare two such exponentials, even check that a specific map belongs to such a set, since AbstractSet implementation of equals() first checks if the sizes are the same... but the size is undefined. I do not mind if it just hangs listing the elements, trying to find one that does not belong; for this I may have a patience argument (halting it arbitrarily).
juan_gandhi: (VP)
I had a function checking if a collection of sets (of keys) has any common elements (if they do, have to add prefixes to the keys, to disambiguate). Imagine, I was just calculating their intersection. OMFG, in short.
juan_gandhi: (Default)
  val FINITE_SETS: BigSet = bigset((o: Set[_]) => o.size < Integer.MAX_VALUE)

  ...

  test("Setf should not not contain NNO") {
    assert(!(FINITE_SETS contains N))
  }

  test("Setf should not contain itself") {
    assert(!(FINITE_SETS contains FINITE_SETS))
  }

  test("Setf should contain various finite sets") {
    assert(FINITE_SETS contains Set[String]())
    assert(FINITE_SETS contains Set("infinity"))
    assert(FINITE_SETS contains Set(1,2,3,42))
  }

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
17181920212223
24252627282930
31      

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 14th, 2025 07:59 am
Powered by Dreamwidth Studios