Proof of reverse binary strings? - string

If w : {1...L} → {0,1} is a binary string, the complement of w, denoted wC, is a string of length L defined by: wc(i) = 1 - w(i). The reverse of w, denoted wR, is the string of the length L defined by wR(i) = w(L + 1 - i). Use these definitions to give careful proof that, for every binary string x, (xC)R = (xR)C.
I have no idea how to start this question. I don't really want a direct answer I'd like to learn how to do this question by induction for future questions

If the solution I see is the simplest one, then it's a quite comprehensive exercise.
I suggest you start by proving a the following lemmas:
Lemma 1: (w0)C=(wC)1
Lemma 2: (w0)R=0(wR)
Both Lemma 1 and 2 can be proven by induction on the length of w. Doing it strictly by the given rules is tedious, but not very hard.
Argue that the following lemmas hold as well by the same argument
Lemma 1b: (w1)C=wC0
Lemma 2b: (w1)R=1(wR)
With those lemmas in place, you should be able to tackle the original problem of showing (xC)R=(xR)C.
Do an induction over L (i.e. the length of the word). The base case should be trivial. In the inductive step you'll end up with something like
Induction hypothesis
(uC)R=(uR)C.
Left to show:
((u0)C)R=((u0)R)C
and (by analogy)
((u1)C)R=((u1)R)C
Solving this step will involve the lemmas above.

Related

If the string of L consists of 0's only prove that L* is regular

A question 4.2.10 from Introduction to Automata Theory by Hopcroft and Ullman. The original language L can also be non-regular.
Let's say we got a function of 0^(2^n+5), n>=0, how would you prove that (0^(2^n+5))* is regular? And also for the more general case, when f(0) can be any function?
Suppose that L contains two strings 0^n and 0^m and that n and m share no common factors: they are relatively prime. Then, by concatenating some number of instances of 0^n with some number of instances of 0^m, any string of length (n - 1)(m - 1) can be formed. Since L* must therefore exclude only a finite number of words, the complement (L*)' must be finite, hence regular; because regular languages are closed under complement, L* must be regular too.
Where did (n - 1)(m - 1) come from? Well, it's a special case (n = 2) of the coin problem for which we have a closed-form solution. You should be able to research this and find some proofs.
What about the case where all strings in L have lengths divisible by some GCD, say g? Well, the proof of regularity is quite similar; consider a modified alphabet where 0 is replaced by the symbol (0^g) and then prove the analogous language over this alphabet is regular as above. In other words, you can show that L* contains only strings divisible by g and all strings divisible by g of length at least (n/g - 1)(m/g - 1) where n and m have GCD g. The language is regular because it excludes only finitely many words whose lengths are divisible by g.

Proof a language is not regular using Pumping Lemma

I am trying to prove that the following language is not regular using the pumping lemma.
L = {ak b3l al | k ≥ 1 , l ≥ 0}
I have decided to choose w = a b3p ap, then |w| = 4p+1 ≥ p
Any tips?
Thank you!
I am not sure about the exact formulation of the pumping lemma that you are using. At any rate, this is a rather tricky case, because standard formulations like in wikipedia only let you pump somewhere in a prefix of fixed length. But your initial block of a allows pumping anywhere and can be arbitrarily long. Thus you have to use some additional property. I suggest two:
Regular languages are closed under reversal. Thus you may as well look at $L^R = {a^l b^{3l} a^k}$. Now any pumping in the initial block of a will lead out of the language.
Regular languages are closed under intersection. If you take the intersection with a b+ a+ you end up with ${a b^{3l} a^k}$, and now pumping in the b block will take you out of the language.

Stuck with Apostolico-Crochemore algorithm

I am trying to understand the Apostolico-Crochemore algorithm.
The only English description I have found is http://www-igm.univ-mlv.fr/~lecroq/string/node12.html#SECTION00120, but I am stuck with the second line of the description where it says
x is a power of a single character
What does that mean?
m in this case is the length of the pattern, c is a character from the alphabet in use. I can't understand how x == c^m.
This is then followed by (x=(a^l)bu for a, b in Sigma, u in Sigma and a neq b that also uses ^ operation which I cannot understand.
Algorithms on strings are sometimes described in the jargon of formal languages, where concatenation (joining) of strings is written as multiplication: x * y, usually written just xy, means "the string x followed by the string y". So x^n (i.e. "raising the string x to the nth power") naturally means "n copies of the string x, joined together".
This is mostly just a notational device, though multiplication (of ordinary real numbers) and string concatenation do share some abstract mathematical properties. E.g. they are both associative: (xy)z = x(yz), whether we're talking about multiplying numbers or joining strings. (OTOH, xy = yx for real numbers but not for strings, in general. But then matrix multiplication is not commutative either.)

Induction proof of correctness of fibonacci function

Haskell implementation of the familiar Fibonacci function
fibSlow n
| n == 0 = 1 --fib.1
| n == 1 = 1 --fib.2
| otherwise = fibSlow(n-1) + fibSlow(n-2) --fib.3
What is the induction proof of correctness for fibSlow?
To prove correctness of a function on the natural numbers by induction, you would show that it's correct for certain base cases, and then that it's correct for higher values of the parameter given the assumption that it's correct for lower ones. So you'd verify first that fibSlow 0 = 1, and then that fibSlow 1 = 1, and then that for n > 1, fibSlow n is equal to the (n-1)th fibonacci number plus the (n-2)th fibonacci number. Here you get to assume that those numbers are fibSlow (n-1) and fibSlow (n-2), since fibSlow is correct for all inputs less than n by the inductive hypothesis.
This might seem all rather trivial... because it is! The whole point of such an example in Haskell is that you can write code that's obviously correct. When you go to prove it correct, the proof just writes itself and amounts to looking at the code and noting that it clearly says exactly what you're trying to prove. This is one of the nice properties of a declarative language like Haskell.
Apologies I haven't formally seen this kind of material for a while, so you're probably best looking at other sources if this is homework.
I think you want to show the existence of a monotone function which describes the "progress" of the recursion. This case should be pretty simple: the argument itself is monotonically decreasing. For a nonnegative n, the recursive call will be made with a lesser n', and that n' will never be less than zero.
You can also use power induction to argue the function is defined on all n. You have declared it defined on 0 and 1, and it suffices to say that if it's defined on n and n+1, then it's defined on n+2. This is obvious by the definition of the recursive call.
I think you might be able to read up on some formalities in Jech's Set Theory book, in the Ordinals chapter.

Using Closure Properties to prove Regularity

Here's a homework problem:
Is L_4 Regular?
Let L_4 = L*, where L={0^i1^i | i>=1}.
I know L is non-regular and I know that Kleene Star is a closed operation, so my assumption is that L_4 is non-regular.
However my professor provided an example of the above in which L = {0^p | p is prime}, which he said was regular by proving that L* was equal to L(000* + e) by saying each was a subset of one another (e in this case means the empty word).
So his method involved forming a regex of 0^p, but how I can do that when I essentially have one already?
Regular languages are closed under Kleene star. That is, if language R is regular, so is R*.
But the reasoning doesn't work in the other direction: there are nonregular languages P for which P* is actually regular.
You mentioned one such P in your question: the set of strings 0^p where p is prime.
It is easy to use the pumping lemmas for regular and context-free languages to show that P is at least context-sensitive.
However, P* is equivalent to the language 0^q, where q is the sum of zero or more primes.
But this is true for q=0 (the empty string) and any q>=2, so P* can be recognized with a 3-state DFA, even though P itself is not regular.
So L being context-free has no bearing on whether your L_4 = L* is regular or not. If you can construct a DFA that recognizes L_4, as I did for P* above, then clearly it's regular.
In the process of trying to find a DFA that works, you'll probably see some pattern
emerge that can be used as the basis for a pumping argument. The Myhill-Nerode theorem is another approach to proving a language non-regular, and is useful if the language lends itself to analysis of prefixes and distinguishing extensions. If the language can be decomposed into a finite set of equivalence classes under a certain relation, then it can be recognized with a DFA containing that many states.
Edit: For anyone wondering whether OP's example L_4 is regular or not...it's not, which can be proved using the pumping lemma for regular languages.
Assume L_4 is regular, with "pumping length" P. Consider the string w=0P1P, which is an element of L_4. We need to decompose it into the form w=xyz,
with |y| >= 1 and |xy| <= P. Any choice of xy fulfilling these conditions will consist of all zeroes. But then any string w' = xynz with n != 1 will have mismatched counts of 0s and 1s, and therefore cannot be an element of L_4. So the pumping lemma does not hold, and L_4 cannot be regular.

Resources