juan_gandhi: (Default)
2019-03-27 06:36 pm
Entry tags:

kind of improvement

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)
2019-01-19 12:02 pm
Entry tags:

Dana's trick

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

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

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

juan_gandhi: (Default)
2019-01-13 09:41 am
Entry tags:

anybody knows ZFC here?

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)
2016-12-23 11:10 pm
Entry tags:
juan_gandhi: (VP)
2015-06-25 02:11 pm
Entry tags:

halting problem, blin

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)
2014-10-15 04:12 pm
Entry tags:

just found a bug

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)
2010-09-18 11:45 pm

Playing with the set of finite sets (I know it does not exist)

  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))
  }