Is this rule a left recursive production?

  • Context: MHB 
  • Thread starter Thread starter mathmari
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the nature of a specific grammar rule, $$X \to XX|a$$, and whether it constitutes a left recursive production. Participants explore the implications of left recursion on grammar determinism and propose modifications to achieve determinism.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants suggest that the rule $$X \to XX|a$$ is left recursive because it generates a sentential form with $X$ as the leftmost symbol.
  • One participant proposes a modification to the grammar to achieve determinism, suggesting $$X \to aT, T \to XT|\varnothing$$.
  • Another participant questions whether there are alternative methods to make the grammar deterministic.
  • Participants discuss the conditions under which a grammar is not deterministic, citing factors like dilemmas and left recursion.
  • There is a consideration of a rule $$Q \to aQb$$, which is neither a dilemma nor left recursion, prompting questions about its determinism.
  • Concerns are raised about the proposed grammar $$X \to aT, T \to XT|\varnothing$$, with one participant noting that substituting the first rule into the second could lead to a non-deterministic form $$T \to aTT$$.
  • Participants express uncertainty about what additional conditions must be satisfied for a grammar to be deterministic.

Areas of Agreement / Disagreement

Participants do not reach a consensus on whether the original rule is definitively left recursive or on the correctness of the proposed modifications for determinism. Multiple competing views remain regarding the nature of determinism in grammars.

Contextual Notes

There are unresolved questions regarding the definitions and implications of left recursion and determinism, as well as the specific conditions that must be met for a grammar to be classified as deterministic.

mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
Hey! :o

I have a question..
Is the rule $$X \to XX|a$$ a left recursive production?
 
Physics news on Phys.org
Not a specialist in this, but since $X$ generates a sentential form $XX$ with $X$ as the leftmost symbol, yes, $X$ is left-recursive. I am looking at Wikipedia, which has definitions for a left-recursive nonterminal and a left-recursive grammar, but not a left-recursive production.
 
Evgeny.Makarov said:
Not a specialist in this, but since $X$ generates a sentential form $XX$ with $X$ as the leftmost symbol, yes, $X$ is left-recursive. I am looking at Wikipedia, which has definitions for a left-recursive nonterminal and a left-recursive grammar, but not a left-recursive production.

To make the grammar deterministic do I have to do the following changes?
$$ X \to aT ,T\to XT|\varnothing$$
 
Last edited by a moderator:
Or is there an other way to make the grammar deterministic?
 
mathmari said:
To make the grammar deterministic do I have to do the following changes?
$$ X \to aT ,T\to XT|\varnothing$$

mathmari said:
Or is there an other way to make the grammar deterministic?

I have a 3 step plan! ;)

1. What does a deterministic grammar look like?
2. Can you give a regular expression that describes the language?
3. Can you write that regular expression as a deterministic grammar?
 
I like Serena said:
1. What does a deterministic grammar look like?

A grammar is not determinitic if we have at least one of these two factors:
1. <<dilemma>>: $Q \to kA$ and $Q \to kB$
2. <<left recursion>>: $Q \to QY|X$

So to construct the determinitic version of the grammar we do the following:
For 1. $Q \to kX$ and $X \to A|B$
For 2. $Q \to X|XT, T \to YT| \varnothing$So, for my case, is $ X \to aT, T \to XT| \varnothing$ correct?
 
mathmari said:
A grammar is not determinitic if we have at least one of these two factors:
1. <<dilemma>>: $Q \to kA$ and $Q \to kB$
2. <<left recursion>>: $Q \to QY|X$

This states when the grammar is guaranteed to be not deterministic.
The negation does not necessarily make it deterministic.

Suppose for instance we have a rule like $Q \to aQb$.
That is not a dilemma, nor a left recursion.
Does that make it deterministic?

Perhaps you can find a form that is guaranteed to be deterministic?
So to construct the determinitic version of the grammar we do the following:
For 1. $Q \to kX$ and $X \to A|B$
For 2. $Q \to X|XT, T \to YT| \varnothing$

So, for my case, is $ X \to aT, T \to XT| \varnothing$ correct?
 
I like Serena said:
This states when the grammar is guaranteed to be not deterministic.
The negation does not necessarily make it deterministic.

Suppose for instance we have a rule like $Q \to aQb$.
That is not a dilemma, nor a left recursion.
Does that make it deterministic?

Perhaps you can find a form that is guaranteed to be deterministic?

Besides not having a dilemma nor a left recursion, what else should be satisfied so that the grammar is deterministic?

Does the part of the grammar $X \to aT, T \to XT| \varnothing$, have something that makes the grammar non deterministic?
 
mathmari said:
Besides not having a dilemma nor a left recursion, what else should be satisfied so that the grammar is deterministic?

Does the part of the grammar $X \to aT, T \to XT| \varnothing$, have something that makes the grammar non deterministic?

It is at least not obviously deterministic.

As it is we can substitute the first rule in the second and get:
$$T \to aTT$$
Now without knowing what else $T$ might map to, this does not look good.
It suggests that we need to keep track of the first $T$ to be able to verify if the second $T$ "fits", which is what a deterministic language will not allow.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 11 ·
Replies
11
Views
4K