Recursive languages vs context-sensitive languages - formal-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

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.

How to setup Coq as theorem prover for First Order Logic

As far as I understand, then Coq have built-in First Order Logic https://coq.inria.fr/tutorial/1-basic-predicate-calculus. But Coq is not theorem prover, Coq is proof assistant and that means that user is required to provide some hints what rules/strategies Coq should select in each step. There exists more ore lest combined heuristic strategies, but, still, Coq is not prover. I have heard about efforts to use machine learning or other heuristics to automate the proof procedure in the proof assistants (they have been named *hammer?), some of these trends are published in http://ai4reason.org/activities.html.
My question is - can Coq be configured to be used as FOL theorem prover in a similar capacity as E-prover or Z3 prover for the first order logic? And - if yes - how can I configure Coq for such use?
If you want to find a proof automatically of a first order statement within a Coq proof you can use the standard tactic firstorder, of the reconstruction tactics of Coq hammer (see below).
If you want to use Coq to solve problems presented in the tptp format, there is this tool https://github.com/lukaszcz/tptp2coq which can translate a tptp file into a Coq file, then you can use some automated tactics to solve the goals, but it will not compete with E-prover or Z3.
There is a also the tool, Coq hammer which will translate the Coq goal to FOL and then run FOF provers such as E, Vampire, Z3. If those FOF provers can find a proof, Coq hammer will use the list of lemmas used in the proof to try to find again the proof in Coq using automatic tactics (this is called proof reconstruction).

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.

Prolog - what sort of sentences can't be expressed

I was wondering what sort of sentences can't you express in Prolog? I've been researching into logic programming in general and have learned that first-order logic is more expressive compared to definite clause logic (Horn clause) that Prolog is based on. It's a tough subject for me to get my head around.
So, for instance, can the following sentence be expressed:
For all cars, there does not exist at least 1 car without an engine
If so, are there any other sentences that CAN'T be expressed? If not, why?
You can express your sentence straightforward with Prolog using negation (\+).
E.g.:
car(bmw).
car(honda).
...
car(toyota).
engine(bmw, dohv).
engine(toyota, wenkel).
no_car_without_engine:-
\+(
car(Car),
\+(engine(Car, _))
).
Procedure no_car_without_engine/0 will succeed if every car has an engine, and fail otherwise.
The most problematic definitions in Prolog, are those which are left-recursive.
Definitions like
g(X) :- g(A), r(A,X).
are most likely to fail, due to Prolog's search algorithm, which is plain depth-first-search
and will run to infinity and beyond.
The general problem with Horn Clauses however is, that they're defined to have at most one positive element. That said, one can find a clause which is limited to those conditions,
for example:
A ∨ B
As a consequence, facts like ∀ X: cat(X) ∨ dog(X) can't be expressed directly.
There are ways to work around those and there are ways to allow such statements (see below).
Reading material:
These slides (p. 3) give an
example of which sentence you can't build using Prolog.
This work (p. 10) also explains Horn Clauses and their implications and introduces a method to allow 'invalid' Horn Clauses.
Prolog is a programming language, not a natural language interface.
The sentence you show is expressed in such a convoluted way that I had hard time attempting to understand it. Effectively, I must thanks gusbro that took the pain to express it in understandable way. But he entirely glossed over the knowledge representation problems that any programming language pose when applied to natural language, or even simply negation in first order logic. These problems are so urgent that the language selected is often perceived as 'unimportant'.
Relating to programming, Prolog lacks the ability to access in O(1) (constant time) any linear data structure (i.e. arrays). Then a QuickSort, for instance, that requires access to array elements in O(1), can't be implemented in efficient way.
But it's nevertheless a Turing complete language, for what is worth. Then there are no statements that can't be expressed in Prolog.
So you are looking for sentences that can't be expressed in clausal logic that can be expressed in first order logic.
Strictly speaking, there are many, simply because clausal logic is a restriction of FOL. So that's true by definition.
What you can do though is you can rewrite any set of FOL sentences into a logic program that is not equivalent but with good properties. So for example if you want to know if p is a consequence of your theory, you can use equivalently the transformed logic program.
A few notes on the other answers:
Negation in Prolog (\+) is negation as failure and not first order logic negation
Prolog is a programming language, as correctly pointed out, we should be talking about clausal logic instead.
Left recursion is not a problem. You can easily use a different selection rule, or some other inference mechanism.

Resources