Give a CFG for L = { x#y : x,y in {0,1}* |x| ≠ |y| }

  • Context: Comp Sci 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on constructing a context-free grammar (CFG) for the language L = { x#y : x,y in {0,1}* | |x| ≠ |y| }. The proposed approach involves defining four languages: L1 and L2 for cases where the number of 0s is greater than or less than the number of 1s, and L3 and L4 for the reverse scenario. However, the breakdown fails to incorporate the '#' terminal and lacks clarity on how the constructs 0^m1^n and 1^m0^n are derived from the original specification. A correct CFG must account for the separator and ensure the inequality in lengths of x and y.

PREREQUISITES
  • Understanding of context-free grammars (CFG)
  • Familiarity with formal language theory
  • Knowledge of terminal and non-terminal symbols in CFGs
  • Ability to manipulate and unionize language specifications
NEXT STEPS
  • Research how to construct CFGs for languages with specific constraints
  • Learn about the role of terminal symbols in CFGs, particularly in separating components
  • Study examples of CFGs that handle inequalities in string lengths
  • Explore decomposition techniques for complex language specifications
USEFUL FOR

Students and professionals in computer science, particularly those studying formal languages, automata theory, and compiler design, will benefit from this discussion.

shivajikobardan
Messages
637
Reaction score
54
Homework Statement
Give a CFG for L = { x#y : x,y in {0,1}* |x| ≠ |y| }
Relevant Equations
None
1636786865541.png


Is my this solution approach correct? I am thinking of making cfg for L1 U L2 U L3 U L4

Where L1=0^m 1^n ----------->m>n

L2=L1 for m<n

L3=1^m 0^n ---->m>n
L4=L3 for m<n

Is my approach correct? If I can do it like that then this will be easy problem for me as well.
 
Physics news on Phys.org
You are free to decompose a language specification into simpler specifications that can be unionized provided that you get the same specification. Your breakdown does not address the '#' terminal. I also don't see where you are getting 0m1n or 1m0n constructs from the original specification.
 
Last edited:

Similar threads

  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K