All maximal independent sets of a matroid have the same cardinality - algorithm

How to prove that all maximal independent sets of a matroid have the same cardinality.
Provided a matroid is a 2-tuple (M,J ) where M is a finite set and J is a
family of some of the subsets of M satisfying the following
properties:
If A is subset of B and B belongs to J , then A belongs to J ,
If A, B belongs to J , |A| <= |B|, and x belongs to A - B,
then there exists y belongs to B - A such that (B U {x})- {y} belongs to J.
The members of J are called independent sets.

Assume to the contrary that |A| < |B|, and A is not maximally independent.
Consider the following Venn diagram
Clearly B \ A (the only-blue part) is nonempty, as the cardinality of B is larger than that of A. Also, clearly A \ B (the only-orange part) is nonempty, as otherwise A ⊂ B, and, by definition, A is not maximally independent.
Hence, by the exchange property, there is some x &in; A \ B, y &in; B \ A, such that B ∪ {x} \ {y} &in; J as well. Let's call this set C. Note that if we would draw the Venn diagram for A and C (now the blue circle is C):
|B| = |C| (the blue circle has the same size)
|(A \ {x}) \ C| < |A \ B| (the only-orange part is smaller than before)
Now we can repeat the argument about A and C, and so on. Note, however, that we can't repeat it indefinitely, as A is assumed to be finite. Hence, at some point we will reach the contradiction that the orange set is completely contained in the blue set, which we already saw before is impossible (that would mean, by definition, that it is not maximally independent).

We will do this using proof by Contradiction.
Let's assume that all maximal independent set of a matroid does not have the same cardinality.
Thus there must some set A and set B so that both are maximal independent set. Without the
loss of generality let us take j A j < j B j i.e cardinality of A is less than cardinality of B.
Let j A j = P and j B j = Q , P < Q . Now Let X 2 A-B and Y 2 B-A. X and Y will always exist
since A is maximal and dierent from B. Using the second property of Matroid we can make B1
= f B [ X g - f y g which is also independent set and j B1 j = Q . We can continue picking an
element from X' 2 A-Bi and an element from Y' 2 Bi-A and insert X' and remove Y' to make a
new independent set which has the cardinality Q untill there is no element in A-Bi.
Since A-Bi = thus A Bi. But Bi is also and independent set with cardinality Q. Now we can
say that A is not maximal which is a contradiction and thus our assumption was wrong.Thus j A j
= j B j which implies there can be no two maximal independent set with dierent cardinalities.
So all maximal independent set of a matroid have the same cardinality.

Related

Question about the Extended Euclidean Algorithm

So about the Extended Euclidean algorithm, the algorithm that finds, a, b, and d in the equation am+bn=d, where m and n are two positive integers, d is their GCD, and a and b are two integers (not necessarily positive)
So the book I am following has the following instructions for implementing this algorithm:
E1. [Initialize.] Set a′ ← b ← 1, a ← b′ ← 0, c ← m, d ← n.
E2. [Divide.] Let q and r be the quotient and remainder, respectively,
of c divided by d. (We have c = qd + r and 0 ≤ r < d.)
E3. [Remainder zero?] If r = 0, the algorithm terminates;
we have in this case am + bn = d as desired.
E4. [Recycle.] Set c ← d, d ← r, t ← a′, a′ ← a, a ← t − qa, t ← b′, b′ ← b, b ← t − qb,
and go back to E2.
My problem is that I don't particularly understand all the math around this algorithm, I understand the normal Euclidean algorithm well enough, so I understand half of the extended one as well. What I don't understand is the need for a' and b' as well t (I get that t is a temporary variable but I don't get the a = t - qa and b = t - qb part). That as well as the initialization of the variables a, a', b, and b' as well as the swapping of the values between them on each iteration. Can anybody help me bridge these gaps in my understanding of this algorithm?

For a subset of 5 vertices find P(all edges between these vertices are present in G)

For a random graph, G, on n vertices's, each possible edge is present independently with probability k, 0 <= k <= 1.
I seek P(all edges between these vertices's are present in G)
My thoughts so far
If we have the empty subset, p = 1
If we have a one element set, p = 1
If we have a two element set, p = k
If we have a three element set, p = k^3
If we have a four element st, p = k^6
If we have a five element set, p = k^10.
If the above is correct, then I can capture the probability as the following: P = k^(n C 2)
However, this only works for two - five element set. If I have a
one or two element set the following if incorrect. If I am understanding everything correctly up to this point, how can I capture the other two cases?
Is the only possibility a piecewise defined function?
If n=0 or n = 1, 1
Otherwise, k^(n C 2)
Actually, your formula works in all cases because:
n C 2 = 0, for n < 2
And thus:
k^(n C 2) = k^0 = 1, for n < 2

Recursion Puzzle

Recently, one of my friends challenged me to solve this puzzle which goes as follows:
Suppose that you have two variables x and y. These are the only variables which can be used for storage in the program. There are three operations which can be done:
Operation 1: x = x+y
Operation 2: x = x-y
Operation 3: y = x-y
Now, you are given two number n1 and n2 and a target number k. Starting with x = n1 and y = n2, is there a way to arrive at x = k using the operations mentioned above? If yes, what is the sequence of operations which can generate x = k.
Example: If n1 = 16, n2 = 6 and k = 28 then the answer is YES. The sequence is:
Operation 1
Operation 1
If n1 = 19, n2 = 7 and k = 22 then the answer is YES. The sequence is:
Operation 2
Operation 3
Operation 1
Operation 1
Now, I have wrapped my head around the problem for too long but I am not getting any initial thoughts. I have a feeling that this is recursion but I do not know what should be the boundary conditions. It would be very helpful if someone can direct me towards an approach which can be used to solve this problem. Thanks!
Maybe not a complete answer, but a proof that a sequence exists if and only if k is a multiple of the greatest common divisor (GCD) of n1 and n2. Let's write G = GCD(n1, n2) for brevity.
First I'll prove that x and y are always integer multiples of the G. This proof is really straightforward by induction. Hypothesis: x = p * G and y = q * G, for some integers p and q.
Initially, the hypothesis holds by definition of G.
Each of the rules respects the induction hypothesis. The rules yield:
x + y = p * G + q * G = (p + q) * G
x - y = p * G - q * G = (p - q) * G
y - x = q * G - p * G = (q - p) * G
Due to this result, there can only be a sequence to k if k is an integer multiple of the GCD of n1 and n2.
For the other direction we need to show that any integer multiple of G can be achieved by the rules. This is definitely the case if we can reach x = G and y = G. For this we use Euclid's algorithm. Consider the second implementation in the linked wiki article:
function gcd(a, b)
while a ≠ b
if a > b
a := a − b
else
b := b − a
return a
This is a repetitive application of rules 2 and 3 and results in x = G and y = G.
Knowing that a solution exists, you can apply a BFS, as shown in Amit's answer, to find the shortest sequence.
Assuming a solution exists, finding the shortest sequence to get to it can be done using a BFS.
The pseudo code should be something like:
queue <- new empty queue
parent <- new map of type map:pair->pair
parent[(x,y)] = 'root' //special indicator to stop the search there
queue.enqueue(pair(x,y))
while !queue.empty():
curr <- queue.dequeue()
x <- curr.first
y <- curr.second
if x == target or y == target:
printSolAccordingToMap(parent,(x,y))
return
x1 <- x+y
x2 <- x-y
y1 <- x-y
if (x1,y) is not a key in parent:
parent[(x1,y)] = (x,y)
queue.enqueue(pair(x1,y))
//similarly to (x2,y) and (x,y1)
The function printSolAccordingToMap() simply traces back on the map until it finds the root, and prints it.
Note that this solution only finds the optimal sequence if one exists, but will cause infinite loop if one does not exist, so this is only partial answer yet.
Consider that you have both (x,y) always <= target & >0 if not you can always bring them in the range by simple operations. If you consider this constraints you can make a graph where there are O(target*target) nodes and edge you can find by doing an operation among three on that node. You now need to evaluate the shortest path from start position node to target node which is (target,any). The assumption here is (x,y) values always stay within (0,target). The time complexity is O(target*target*log(target)) using djikstra.
In the Vincent's answer, I think the proof is not complete.
Let us suppose two relatively prime numbers suppose n1=19 and n2=13 whose GCD will be 1. According to him, sequence exits if k is multiple of GCD.Since every number is multiple of 1. I think it is not possible for every k.

How to generate matrices which satisfy the triangle inequality?

Let's consider square matrix
(n is a dimension of the matrix E and fixed (for example n = 4 or n=5)). Matrix entries
satisfy following conditions:
The task is to generate all matrices E. My question is how to do that? Is there any common approach or algorithm? Is that even possible? What to start with?
Naive solution
A naive solution to consider is to generate every possible n-by-n matrix E where each component is a nonnegative integer no greater than n, then take from those only the matrices that satisfy the additional constraints. What would be the complexity of that?
Each component can take on n + 1 values, and there are n^2 components, so there are O((n+1)^(n^2)) candidate matrices. That has an insanely high growth rate.
Link: WolframAlpha analysis of (n+1)^(n^2)
I think it's safe to safe that this not a feasible approach.
Better solution
A better solution follows. It involves a lot of math.
Let S be the set of all matrices E that satisfy your requirements. Let N = {1, 2, ..., n}.
Definitions:
Let a metric on N to have the usual definition, except with the requirement of symmetry omitted.
Let I and J partition the set N. Let D(I,J) be the n x n matrix that has D_ij = 1 when i is in I and j is in J, and D_ij = 0 otherwise.
Let A and B be in S. Then A is adjacent to B if and only if there exist I and J partitioning N such that A + D(I,J) = B.
We say A and B are adjacent if and only if A is adjacent to B or B is adjacent to A.
Two matrices A and B in S are path-connected if and only if there exists a sequence of adjacent elements of S between them.
Let the function M(E) denote the sum of the elements of matrix E.
Lemma 1:
E = D(I,J) is a metric on N.
Proof:
This is a trivial statement except for the case of an edge going from I to J. Let i be in I and j be in J. Then E_ij = 1 by definition of D(I,J). Let k be in N. If k is in I, then E_ik = 0 and E_kj = 1, so E_ik + E_kj >= E_ij. If k is in J, then E_ik = 1 and E_kj = 0, so E_ij + E_kj >= E_ij.
Lemma 2:
Let E be in S such that E != zeros(n,n). Then there exist I and J partitioning N such that E' = E - D(I,J) is in S with M(E') < M(E).
Proof:
Let (i,j) be such that E_ij > 0. Let I be the subset of N that can be reached from i by a directed path of cost 0. I cannot be empty, because i is in I. I cannot be N, because j is not in I. This is because E satisfies the triangle inequality and E_ij > 0.
Let J = N - I. Then I and J are both nonempty and partition N. By the definition of I, there does not exist any (x,y) such that E_xy = 0 and x is in I and y is in J. Therefore E_xy >= 1 for all x in I and y in J.
Thus E' = E - D(I,J) >= 0. That M(E') < M(E) is obvious, because all we have done is subtract from elements of E to get E'. Now, since E is a metric on N and D(I,J) is a metric on N (by Lemma 1) and E >= D(I,J), we have E' is a metric on N. Therefore E' is in S.
Theorem:
Let E be in S. Then E and zeros(n,n) are path-connected.
Proof (by induction):
If E = zeros(n,n), then the statement is trivial.
Suppose E != zeros(n,n). Let M(E) be the sum of the values in E. Then, by induction, we can assume that the statement is true for any matrix E' having M(E') < M(E).
Since E != zeros(n,n), by Lemma 2 we have some E' in S such that M(E') < M(E). Then by the inductive hypothesis E' is path-connected to zeros(n,n). Therefore E is path-connected to zeros(n,n).
Corollary:
The set S is path-connected.
Proof:
Let A and B be in S. By the Theorem, A and B are both path-connected to zeros(n,n). Therefore A is path-connected to B.
Algorithm
The Corollary tells us that everything in S is path-connected. So an effective way to discover all of the elements of S is to perform a breadth-first search over the graph defined by the following.
The elements of S are the nodes of the graph
Nodes of the graph are connected by an edge if and only if they are adjacent
Given a node E, you can find all of the (potentially) unvisited neighbors of E by simply enumerating all of the possible matrices D(I,J) (of which there are 2^n) and generating E' = E + D(I,J) for each. Enumerating the D(I,J) should be relatively straightforward (there is one for every possible subset I of D, except for the empty set and D).
Note that, in the preceding paragraph, E and D(I,J) are both metrics on N. So when you generate E' = E + D(I,J), you don't have to check that it satisfies the triangle inequality - E' is the sum of two metrics, so it is a metric. To check that E' is in S, all you have to do is verify that the maximum element in E' does not exceed n.
You can start the breadth-first search from any element of S and be guaranteed that you won't miss any of S. So you can start the search with zeros(n,n).
Be aware that the cardinality of the set S grows extremely fast as n increases, so computing the entire set S will only be tractable for small n.

Prove that the set of all languages over a finite alphabet is uncountable

Trying to do some revision but not sure on this one:
Prove that the set of all languages over a finite alphabet is uncountable.
I have a feeling it will require using the Cantor Diagonalization method - but I'm not sure how you would use it for this problem.
I've found in my computation theory class notes this proof, I hope it's useful for you
|N| < |languages(N)|
Supose that |N| >= |languages(N)|. Therefore, each of the elements of languages(N) can be related to one of the elements of N. So they can be put into order:
languages(N) = {S_1 , S_2, S_3, ...}
We define a set D like:
D = {n in N / n not in S_n}
D is valid and D is a subset of N, therefore D belongs languages(N).
So, there must exist a k for which D = S_k
1) If k belongs to D then by definition of D, k doesn't belong to S_k. And k doesn't belong to D Because D = S_k(We find a contradiction)
2) If k doesn't belong to D then: k belongs to S_k(by definition of D) and k belongs to D because D = S_k(Contradiction again)
A sequence like the one assumed can't exist. Therefore an injective function that assigns an elemnt of N for each element of languages(N) is not possible. Concluding that |languages(N)| !<= |N|, so |languages(N)| > |N|

Resources