kc_kennylau

CFG

May 8th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. S
  2. ABCD
  3. EFGHJK
  4. LMNP
  5.  
  6. Given the alphabet {a,b,c,d}, define a context-free grammar for the language of words that contain exactly three unique symbols. For example, "abc" and "dcccaca" are both okay but neither of "abdc", "daaaad" are.
  7.  
  8. S>aA
  9. S>bB
  10. S>cC
  11. S>dD
  12. ----------------
  13. A>aA
  14. A>bE
  15. A>cF
  16. A>dG
  17.  
  18. B>aE
  19. B>bB
  20. B>cH
  21. B>dJ
  22.  
  23. C>aF
  24. C>bH
  25. C>cC
  26. C>dK
  27.  
  28. D>aG
  29. D>bJ
  30. D>cK
  31. D>dD
  32. ----------------
  33. E>aE
  34. E>bE
  35. E>cL
  36. E>dM
  37.  
  38. F>aF
  39. F>bL
  40. F>cF
  41. F>dN
  42.  
  43. G>aG
  44. G>bM
  45. G>cN
  46. G>dG
  47.  
  48. H>aL
  49. H>bH
  50. H>cH
  51. H>dP
  52.  
  53. J>aM
  54. J>bJ
  55. J>cP
  56. J>dJ
  57.  
  58. K>aN
  59. K>bP
  60. K>cK
  61. K>dK
  62. ----------------
  63. L>aL
  64. L>bL
  65. L>cL
  66. L>_
  67.  
  68. M>aM
  69. M>bM
  70. M>dM
  71. M>_
  72.  
  73. N>aN
  74. N>cN
  75. N>dN
  76. N>_
  77.  
  78. P>bP
  79. P>cP
  80. P>dP
  81. P>_
Advertisement
Add Comment
Please, Sign In to add comment