Consider the following extension to context-free grammars that permits rules to have in the left-hand side, one (or more) terminal on the right side of the non-terminal. That is, rules of the form:
A b -> ...
The right-hand side may be anything, like in context-free grammars. In particular, it is not required, that the right-hand side will have exactly the same terminal symbol at the end. In that case, this extension would be context-sensitive. But the terminal is not just a context. Sometimes, this terminal is called "pushback".
Clearly, this is no longer CFG (type-2). It includes type-1. But what is it? Really type-0 already?
This particular extension is permitted in Definite Clause Grammars dcg in Prolog. (To avoid misunderstandings, I do not consider here Prolog's full extensions. I.e. I assume terminals to come from a finite alphabet and not being arbitrary terms, also I do not consider Prolog's additional arguments that are permitted in DCGs, which also go into type-0 already.)
Edit: Here is a simpler way to describe the extension: Add to a CFG rules of the form
A b -> <epsilon>
Here's a partial answer:
The grammar is within type 0. A context-sensitive grammar
(type-1) has rules of the form wAx -> wBx
where w and x are strings of terminals and non-terminals, and B is not empty. Note that since B is not empty, |wAx| <= |wBx|
. Your grammar has rules of the form Ax -> z
where z is a string of terminals and non-terminals and can be empty, and x can be removed. This violates two principles of CSGs.
Unsatisfyingly, I did not answer two things:
Is the language generated by your grammar type-1? The grammar is type-0, but that does not mean the language cannot be type-1. For example, regular languages (type-3) can be described by CFGs (type-2).
Is the language recursive? This is important since, if so, the language is decidable (does not suffer from the halting problem).
I'm currently attempting a proof for the second point, but it's probably beyond my ability.
To answer my question with respect to Prolog's DCG formalism, this extension is now called a semicontext. See N253 DIN Draft for DCGs 2014-04-08 - ISO/IEC WDTR 13211-3:2014-04-08
Given
a1, [b] --> ... .
a2, [b,b] --> ... .
The terminal-sequence [b]
is now a semicontext, as well as the terminal-sequence [b,b]
.
Would the same terminal sequence now appear at the end of the rule, we would have a context:
a3, [b,b] --> ..., [b,b].
So "semi" means here "half" - similar to a semigroup where half of the algebraic properties of a group hold.
Yup it's type 0 I think. Principle for first 3 types (3, 2 and 1) is that those can't perform reduction. Those are generative only types.
Here you can transform a terminal into epsilon so it's type 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With