M is a Turing machine that accepts string w and does not accept string ε - theory

I need to prove whether this language is recognizable or not:
{ ⟨M, w⟩: M is a Turing machine that accepts string w and does not accept string ε }
I figure I could do a reduction on ATM, but how do I handle the empty string?

Here's one way to do a reduction from the complement of ATM to your language.
Given a TM M and a string w, build this TM/string pair:
M' = "On input x:
If x = "iheartquokkas", accept.
Otherwise:
Run M on w.
If M accepts, accept;
If M rejects, reject;
(Implicitly: if M loops, loop.)"
w' = "iheartquokkas"
First, suppose that M does not accept w. Then machine M' does indeed accept the string w', because it's programmed to do so. Additionally, when you run M' on ε, it will run M on w and never accept because M doesn't accept w. Thus M' accepts w' but not ε, so ⟨M', w'⟩ is in your language.
Second, suppose that M accepts w. Then when you run M' on ε, it will accept, so it is not the case that M' accepts w' but not ε. Therefore, ⟨M', w'⟩ is not in your language.
You now have a mapping reduction from ATM's complement to your language, so your language isn't recognizable.
Now, can you prove that it's not co-recognizable?

Related

Union and intersection of two languages

Given the language
L1 = {(i|l)p(f|g)n(f|h)m(f|i)r(l|m)p : n + m > r > 0, p >= 0}
and
L2 = (f|g)*(h|i)+
make an automaton for L1 ∪ L2 and (another one for) L1 ∩ L2.
I know that the L1 is a CFL and you need a PDA to parse it and I know that L2 is a RL and a DFA is to be used.
My question is: how do you make the intersection (and the union)? That is, what is the actual language L3 = L1 ∩ L2 on which you make the automaton and how do you compute it?
Union is easy - if you have PDAs for two languages, a nondeterministic PDA that accepts the union can be had by introducing a new initial state with epsilon transitions to each of the initial states of the automata for your languages. The accepted language will be exactly whatever is accepted by either (or both) automata.
Intersection is a little more tricky. Now, you say you want an automaton - that could refer to any theoretical machine, including Turing machines or, equivalently, two-stack PDAs. If you are OK with creating a two-stack PDA then your task is straightforward. Use the Cartesian product machine construction used to construct a DFA for A and B given DFAs for A and B, and have each transition of the form ((a, b), w) -> (a', b') push a symbol (x, y) onto the stack iff (a, w)->a' pushes x onto A's stack and (b, w)->b' pushes y onto B's stack.
Of course, if you start with a DFA for the RL and perform the above construction you only need one stack and the resulting automaton is a PDA, not a two-stack PDA.

Regular Languages and Concatenation

Regular languages are closed under concatenation - this is demonstrable by having the accepting state(s) of one language with an epsilon transition to the start state of the next language.
If we consider the language L = {a^n | n >=0}, this language is regular (it is simply a*). If we concatenate it with another language L = {b^n | n >=0}, which is also regular, we end up with a^nb^n, but we obviously know this isn't regular.
Where am I going wrong with my logic here?
The definition of the concatenation of two languages L1 and L2 is the set of all strings wx where w ∈ L1 and x ∈ L2. This means that L1L2 consists of all possible strings formed by pairing one string from L1 and one string from L2, which isn't necessarily the same as pairing up matching strings from each language.
As a result, as #Oli Charlesworth pointed out, the language you get back here isn't actually { anbn | n in N }. Instead, it's the language { anbm | n in N and m in N }, which is the language a*b*. This language is regular, since it's given by the regular languages.
Hope this helps!

Concatenation of a infinite language and a finite language

Why is it that the concatenation of a infinite language and a finite language always finite iff the language is not the empty set? I thought concatenating an infinite language with the empty set would just be the infinite language.
This statement is false. Try concatenating Σ* and Σ. This gives back Σ+, which is infinite.
I think that you meant
The concatenation of an infinite language I and a finite language F is infinite iff F ≠ ∅
This statement is true. If F = ∅ then IF is the empty set because the concatenation of any language and the empty language is the empty language. Specifically, IF = { wx | w in I and x in F }, so if F is empty, there are no x's that satisfy the condition x in F.
On the other hand, if x ≠ ∅ we can prove that IF is infinite. Consider any string w ∈ I whose length is longer than any string in F. Then the set wF = { wx | x in F } is infinite because there's at least one string in wF in-between any two multiples of |w|. Since wF ⊆ IF, this means that IF is infinite.
Hope this helps!

Proving a theorem using induction in COQ

I am learning Coq at school, and I have an assignment to do for home. I have a lemma to proove: If a list contains a zero among its elements, then the product of its elements is 0. I started my code, and I am stuck in a point where I do not know how to go on. I do not know all the commands from Coq, I did a lot of research, but I cannot manage to find my way to the end of the Proof. Here is my code:
Require Import List ZArith.
Open Scope Z_scope.
Fixpoint contains_zero (l : list Z) :=
match l with
nil => false
| a::tl => if Zeq_bool a 0 then true else contains_zero tl
end.
Fixpoint product (l : list Z) :=
match l with
nil => 1
| a::tl => a * product tl
end.
Lemma Zmult_integral_r :
forall n m, m <> 0 -> m * n = 0 -> n = 0.
Proof.
intros n m m0; rewrite Zmult_comm; apply Zmult_integral_l.
assumption.
Qed.
Lemma product_contains_zero :
forall l, contains_zero l = true -> product l = 0.
intros l H.
So, I thought that it would be a good idea to create a function that checks if the list contains a zero, and another one to calculate the product of its elements. I have also found (luckily) a lemma online that prooves that if I have 2 numbers , and I know that one of them is not 0, and their product is 0, then necessarily the other number is 0 (I thought that might help). I thought about doing a proof by induction, but that didn't work out. Any ideas? I know that this is not the place to ask someone to do my work , I AM NOT ASKING THAT, I just need an idea.
1/ You do not need the theorem that you mention, " if I have 2 numbers , and I know that one of them is not 0, and their product is 0, then necessarily the other number is 0". You don't need it because you want to prove that the product is 0, you are not in a situation where you want to use the fact that the product is zero.
So the theorem Zmult_integral_r is not useful for the lemma in this question. It would be useful if you had to prove forall l, product l = 0 -> contains_zero l = true.
Here, for your problem, the two functions that you consider are recursive, so the usual hint is to do a proof by induction, and then to use the tactic simpl to make the functions look simpler.
Represent product of two numbers as one number while you will stand with that lemma.

Context Free pumping lemma

Is the following language context free?
L = {a^i b^k c^r d^s | i+s = k+r, i,k,r,s >= 0}
I've tried to come up with a context free grammar to generate this but I can not, so I'm assuming its not context free. As for my proof through contradiction:
Assume that L is context free,
Let p be the constant given by the pumping lemma,
Choose string S = a^p b^p c^p d^p where S = uvwxy
As |vwx| <= p, then at most vwx can contain two distinct symbols:
case a) vwx contains only a single type of symbol, therefore uv^2wx^2y will result in i+s != k+r
case b) vwx contains two types of symbols:
i) vwx is composed of b's and c's, therefore uv^2wx^2y will result in i+s != k+r
Now my problem is that if vwx is composed of either a's and b's, or c's and d's, then pumping them won't necessary break the language as i and k or s and r could increase in unison resulting in i+s == k+r.
Am I doing something wrong or is this a context free language?
I can't come up with a CFG to generate that particular language at the top of my head either, but we know that a language is context free iff some pushdown automata recognizes it.
Designing such a PDA won't be too difficult. Some ideas to get you started:
we know i+s=k+r. Equivalently, i-k-r+s = 0 (I wrote it in that order since that is the order in they appear). The crux of the problem is deciding what to do with the stack if (k+r)>i.
If you aren't familiar with PDA's or cannot use them to answer the problem, at least you know now that it is Context Free.
Good luck!
Here is a grammar that accepts this language:
A -> aAd
A -> B
A -> C
B -> aBc
B -> D
C -> bCd
C -> D
D -> bDc
D -> ε

Resources