MHB Can You Convert a Context-Free Grammar to a Deterministic One?

  • Thread starter Thread starter evinda
  • Start date Start date
Click For Summary
The discussion centers on converting a context-free grammar into a deterministic one. The original grammar provided is I -> cdaX | cdbY, X -> XXX | d, Y -> I | X. The user attempts a conversion, proposing a new grammar structure with modifications. However, a participant points out that the proposed grammar allows strings like "cdadd," which are not permitted by the original grammar. The conversation highlights the importance of accurately preserving the language generated by the grammar during the conversion process. The need for careful consideration of the language's constraints is emphasized, as the proposed changes inadvertently broaden the language's acceptance.
evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Blush)

I have a context-free grammar,that I want to convert in a deterministic one.

This is the context-free grammar:

I -> cdaX|cdbY, X-> XXX |d , Y -> I | X

That's what I have tried:



I -> cdK , K ->aX | bY
X -> dM, M -> d M |N, N-> dN | ∅
Y ->cdK| dM

Is it right? Or have I done something wrong? (Thinking)
 
Last edited:
Technology news on Phys.org
evinda said:
Hello! (Blush)

I have a context-free grammar,that I want to convert in a deterministic one.

This is the context-free grammar:

I -> cdaX|cdbY, X-> XXX |d , Y -> I | X

That's what I have tried:



I -> cdK , K ->aX | bY
X -> dM, M -> d M |N, N-> dN | ∅
Y ->cdK| dM

Is it right? Or have I done something wrong? (Thinking)

Hi!

It is almost right. (Worried)

Is for instance [m]cdadd[/m] allowed? (Wondering)
 
I like Serena said:
Hi!

It is almost right. (Worried)

Is for instance [m]cdadd[/m] allowed? (Wondering)

Do you mean that it should be like that?

I -> cdK , K ->aX | bY
X -> dM, M -> d M | ∅
Y ->cdK| dM

?
(Thinking)
 
evinda said:
Do you mean that it should be like that?

I -> cdK , K ->aX | bY
X -> dM, M -> d M | ∅
Y ->cdK| dM

?
(Thinking)

No... my point was that the original language does not allow [m]cdadd[/m], while your languages both do. (Doh)
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
13
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 17 ·
Replies
17
Views
1K
Replies
4
Views
2K
  • · Replies 119 ·
4
Replies
119
Views
16K