Questions tagged [set-theory]

Set theory is a branch of logic which studies collections of distinct elements, called sets. Topics include set operations (such as intersection and union), relations and mappings between sets, and the ordering of elements of sets (often through binary predicates).

References

179 questions
84
votes
5 answers

sql joins as venn diagram

I've had trouble understanding joins in sql and came upon this image which I think might help me. The problem is that I don't fully understand it. For example, the join in the top right corner of the image, which colors the full B circle red and…
BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134
31
votes
10 answers

Algorithm to determine all possible ways a group of values can be removed from a sequence

I'm trying to determine how many different ways I can remove a group of values from a sequence, leaving the original sequence in order (stable), and making sure to remove only 1 instance value each from the original sequence. For example, if I had…
bkaid
  • 51,465
  • 22
  • 112
  • 128
25
votes
2 answers

How to implement the empty set - ∅?

Assuming that you want to implement set theory concepts such as element, set, collection and relation in Java: How would you represent the empty set ∅? Do I mislead myself, if I think of the NULL concept as it is used by the three-valued logic of…
M4TT4CK
  • 341
  • 1
  • 3
  • 4
23
votes
3 answers

Finding symmetric difference with LINQ

I have two collections a and b. I would like to compute the set of items in either a or b, but not in both (a logical exclusive or). With LINQ, I can come up with this: IEnumerable Delta(IEnumerable a, IEnumerable b) { return…
Pierre Arnaud
  • 10,212
  • 11
  • 77
  • 108
17
votes
5 answers

Is there a name for this set/array operation?

Given the input array [a,b,c,d,e] and a 'join' function (a,b) => (a+b) my code returns the following array of arrays, containing each possible variation obtained by applying the join function to various pairs of elements whilst maintaining the…
Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197
16
votes
5 answers

Combining NSArrays Through Intersection and Union

I have two NSArrays A and B that share some common elements, e.g. A: 1,2,3,4,5 B: 4,5,6,7 I would like to create a new NSArray consisting of the contents common between the two NSArrays joined with the contents of the second NSArray while…
Mat Kelly
  • 2,327
  • 7
  • 29
  • 51
12
votes
5 answers

How can I implement an infinite set class?

I'm designing a class library for discrete mathematics, and I can't think of a way to implement an infinite set. What I have so far is: I have an abstract base class, Set, which implements the interface ISet. For finite sets, I derive a class…
Daniel
  • 2,944
  • 3
  • 22
  • 40
8
votes
5 answers

Database operation that can be applied repeatedly and produce the same results?

I'm drawing a blank, or as some would say, having a senior moment. I know there’s a formal definition and a name for the concept where a db operation (stored procedure) that runs in a database will yield the same results if run repeatedly. It's…
Gandalf
8
votes
4 answers

Prolog list difference routine

I am trying to implement a list difference routine in prolog. For some reason the following fails: difference(Xs,Ys,D) :- difference(Xs,Ys,[],D). difference([],_,A,D) :- D is A, !. difference([X|Xs],Ys,A,D) :- not(member(X,Ys)), A1 is [X|A], …
TheOne
  • 10,819
  • 20
  • 81
  • 119
7
votes
1 answer

Typescript: Intersection - Confused about the naming

I am a bit confused about the name Intersection Types in Typescript. In set theory, intersection would imply that only properties that are common to both types would be available in the intersection of the two. In fact, that is how Typescript…
sarincasm
  • 477
  • 3
  • 9
6
votes
1 answer

How to express subset relation in Coq?

How can I describe in Coq that one set Y is a subset of another set X? I tested the following: Definition subset (Y X:Set) : Prop := forall y:Y, y:X. , trying to express that if an element y is in Y, then y is in X. But this generates type errors…
thor
  • 21,418
  • 31
  • 87
  • 173
6
votes
2 answers

implementing set theory operations in php

How to implement set theory operations in pure php?
Thomas Vincent
  • 248
  • 2
  • 12
6
votes
2 answers

Set Theory and .NET

Recently I came across a situation where set theory and set math fit what I was doing to the letter (granted there was an easier way to accomplish what I needed - i.e. LINQ - but I didn't think of that at the time). However I didn't know of any…
CodeMonkey1313
  • 15,717
  • 17
  • 76
  • 109
5
votes
6 answers

Fastest way to perform subset test operation on a large collection of sets with same domain

Assume we have trillions of sets stored somewhere. The domain for each of these sets is the same. It is also finite and discrete. So each set may be stored as a bit field (eg: 0000100111...) of a relatively short length (eg: 1024). That is, bit X in…
niktech
  • 115
  • 1
  • 5
  • 12
5
votes
2 answers

Minimal number of cuts to partition sequence into pieces that can form a non-decreasing sequence

I have N integers, for example 3, 1, 4, 5, 2, 8, 7. There may be some duplicates. I want to divide this sequence into contiguous subsequences such that we can form from them non-decreasing sequence. How to calculate minimal number of cuts? For the…
user128409235
  • 239
  • 1
  • 11
1
2 3
11 12