Whether a context free language is deterministic context free language - computation-theory

Let L(G) be the language generated by a context free grammar G. Is the following decision problem decidable ?Whether L(G) is deterministic context free language ?
I understood why the above problem is undecidable from this link, but I had a doubt.
We know that CFL's and PDA's are equivalent (reference), i.e. for every CFL, G, there is a PDA M such that L(G) = L(M) and vice versa. A context free language is deterministic if it can be accepted by a DPDA. A deterministic PDA is one in which there is at most one possible transition from any state based on the current input.
Since we can create a PDA for every CFL and distinguish between PDA's being deterministic or not, could we say that the problem of whether L(G) is deterministic context free language is decidable ? Or am I missing something ?

You are missing something. You say:
A context free language is deterministic if it can be accepted by a DPDA.
and
we can create a PDA for every CFL
and
[we can] distinguish between PDA's being deterministic or not
The problem is that the PDA you get for the CFL might be nondeterministic even if the language is deterministic. While it's true that every deterministic CFL has a DPDA that accepts it, is is NOT true that every deterministic CFL is accepted ONLY by DPDAs. Indeed, every deterministic CFL is accepted by many nondeterministic PDAs... it's not hard to see that any DPDA can be transformed into an equivalent nondeterministic PDA by adding new states and branches that don't lead to accepting anything.

Related

Show that the language is undecidable

Consider the language
Consider the language
Aabb = {< M > | M is a TM, and M accepts abb}
a) What is the computational problem that is represented by Aabb?
b) Show that Aabb is undecidable.
I tried proving it but didn't know what to do.
You can use Rice's theorem directly and correctly prove the claim by noting that some TMs accept aab, some don't, and acceptance of abb is a semantic property of languages (it has to do only with the strings accepted, not the manner of accepting them). Rice guarantees this language is undecidable.
If you want another kind of proof, consider the following. There's nothing special about the string abb. If this problem is decidable, we'd expect the problem to be decidable for any arbitrary string. If it were decidable for any arbitrary string, we could use dovetailing to decide whether the language of the TM were empty. If we could decide whether the language of a TM were empty, we could take any TM, change all instances of halt-reject to halt-accept, and then decide whether the TM halts on at least one input. Etc. Etc. Basically, you can construct a chain of implications as long as you want but you quickly find known undecidable problems you can reduce to.

How to use Coq as calculator or as forward chaining rule engine/sequence application tool?

Is it possible and how to use Coq as calculator or as rule engine in foward chaining mode? Coq script usually requires to declare the goal for which the proof can be found. But is it possible to go in other direction, e.g. to compute the set of some consequences bounded by some rule, e.g., by some number of steps. I am especially interested in the sequent calculus of full first order logic. I guess (but I don't know) that there are some implementation or package for some type of sequent calculus for first order logic, but it is for theorem proving. I woul like to use such sequent calculus to derive consequences in some directed order. Is that possible in Coq and how?
Coq can be used for forward reasoning as well, in particular with the assert tactic. When you write assert (H : P)., Coq generates a subgoal that asks you to prove P. When this goal is complete, it resumes the original proof, extending its context with a hypothesis H : P.
The ltac language used to write Coq scripts has a match goal operator that allows you to inspect the shape of your goal. This allows you to progressively saturate your proof context with new facts derived from your current assumptions using the assert tactic, and to stop once certain conditions are met. Adam Chlipala's CPDT book has a nice chapter covering these features of tactic programming.

Logic programming - Is subset with only one function symbol Turing - complete?

If I have a subset of logic programming which contains only one function symbol, am I able to do everything?
I think that I cannot but I am not sure at all.
A programming language can do anything user wants if it is a Turing-complete language. I was taught that this means it has to be able to execute if..then..else commands, recursion and that natural numbers should be defined.
Any help and opinions would be appreciated!
In classical predicate logic, there is a distinction between the formula level and the term level. Since an n-ary function can be represented as an (n+1)-ary predicate, restricting only the number of function symbols does not lessen the expressivity.
In prolog, there is no difference between the formula and the term level. You might pick an n-ary symbol p and try to encode turing machines or an equivalent notion(e.g. recursive functions) via nestings of p.
From my intution I would assume this is not possible: you can basically describe n-ary trees with variables as leaves, but then you can always unify these trees. This means that every rule head will match during recursive derivations and therefore you are unable to express any case distinction. Still, this is just an informal argument, not a proof.
P.S. you might also be interested in monadic logic, where only unary predicates are allowed. This fragment of first-order logic is decidable.

Algorithm for regular expression intersection with cfg

Im looking for an algorithm which outputs if the intersection of a regular expression and a contex free grammar is empty or not. I know that this problem is decidable, however, I cannot find any example implementation (in pseudocode).
Can someone provide me with such an algorithm, in .NET if possible but this is not a must. This problem is also called "regular intersection". Googling for it only gives me the geometrical algorithm or the theory about it.
edit:
Anybody. Im really stuck on it, and cannot find anything yet.
Here is a sketch of an approach that occurs to me. I think this should work but it is probably not the best way to do it since it uses the terribly messy conversion from PDA to CFG.
Convert the regular expression into a nondeterministic finite automaton (NFA) and reduce it down to the minimal determinsitic finite automaton (DFA). Convert the context free grammar (CFG) into a pushdown automoton (PDA). These first steps are all well known and fairly simple algorithms.
Take the intersection of the DFA and PDA, which is also a PDA. We will say the DFA has states S1, start state s1, final states F1, and transitions delta1 of the form ((source,trigger),destination), and the PDA has states S2, start state s2, final states F2, and transitons delta2 of the form ((source,trigger,pop),(destination,push)). The new PDA has states S1 X S2, each state labeled by a pair. It has final states F1 X F2, and start state (s1,s2). Now for the transitions.
For each transition d an element of delta2, for each state s an element s1, find the transition t an element of delta1 of the form ((s,d.trigger),?). Make a new transition (((d.source, s), d.trigger, d.pop),((d.destination, t.destination),d.push)).
This new PDA should accept the intersection of the languages produced by the RE and the CFG. To test if the language is empty you will need to convert it back to a CFG. The algorithm for that is messy and large, but it works. Once you have done that, mark each terminal symbol. Then mark each symbol which has a rule where there are only marked symbols on the right hand side, and repeat until you can mark no more symbols. If you can mark the start symbol, the language is not empty. Otherwise, the language is empty.
In fact, there is a simpler algorithm for computing the intersection between a context-free grammar and a regular expression. It does not use push-down automata, which can be costly to obtain from CFG with several conversions.
This solution was presented in:
Y. Ba-Hillel, M. Prles, and E. Shamir. 1965. On formal properties of
simple phrase structure grammars. Z. Phonetik, Sprachwissen. Komm. 15
(I961), 143-172. Y. Bar-Hillel, Language and Information,
Addison-Wesley, Reading, Mass (1965), 116–150.
but you can find a simpler version in:
Richard Beigel and William Gasarch. .. A Proof that the intersection
of a context-free language and a regular language is Context-Free
Which Does Not use pushdown automata.
http://www.cs.umd.edu/~gasarch/BLOGPAPERS/ cfg.pdf (.).
If it help, this solution was implemented in Pyformlang (https://pyformlang.readthedocs.io/), and you can find it on Github for Python (https://github.com/Aunsiels/pyformlang/blob/master/pyformlang/cfg/cfg.py)

Recursive languages vs context-sensitive languages

In Chomsky's hierarchy, the set of recursive languages is not defined. I know that recursive languages are a subset of recursively enumerable languages and that all recursive languages are decidable.
What I'm curious about is how recursive languages compare to context-sensitive languages. Can I assume that context-sensitive languages are a strict subset of recursive languages, and therefore all context-sensitive languages are decidable?
To recognize a recursive language you need a kind of automaton named Decider . It is exactly a Turing Machine tricked by a limited control flow, that is, to ensure it will always halt.
Concerning context-sensitive languages, they are indeed a proper subset of recursive ones. It's trivial giving that the minimal automaton to recognize a context-sensitive language, a Linear bounded automaton is strictly less powerful than a decider. I guess that it would also be possible to demonstrate based on grammar restriction rules.
If your question is only if every context sensitive language is in the set of all recursive languages, you should try to prove it the classical way through formal automata. Ask yourself what formal automaton can simulate generation of context sensitive language and what is used to generate recursive language. Then just try to simulate one using the other. Once you look up the right automata in your textbook, you will sure be able to prove what you want.
set of context sensitive languages are a proper subset of recursive languages.
You dont have to assume this, refer to Peter Linz's book for proof.
According to Papadimitriou's book (3.4.2 (e)), context-sensitive grammars are equivalent to NSPACE(n), which is a proper subset of recursive languages. So, yes, your assumption is correct.
As per my references , I would also say that Context Sensitive Languages are a proper subset of a set of all Recursive Languages.You can find this proof in any Standard Textbook like
> An Introduction to Formal Languages and Automata (Edition 5) by Peter Linz

Resources