如何使用NFA来显示具有多个字符串的常规语言?

时间:2018-01-27 22:50:41

标签: regular-language nfa

我很难理解如何在展示一种语言A如何与其他语言B等同的情况下使用NFA。以下是我尝试的一个例子了解。 为什么需要在这个NFA中持有5个州? 最后一步如何显示xyz是A的元素? 有人可以直观地解释这个例子吗? enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

您已获得字符串y。您随机选择两个状态pqp您认为y已开始,q是您认为y已结束的地方。

然后,您尝试通过跟踪非确定性转换,q0中每个字符的一次转换,找到从开始状态py的路径。

同时,您尝试查找从qqf的路径,再次确定y中每个字符的转换次数。

同时您关注ypq的过渡。

如果您最终处于州<p,p,q,q,qf>状态,则表示您已经

  1. 找到从起始状态q0p的路径。即,您已找到字符串x
  2. 找到从pq的路径。即,您已找到字符串y
  3. 找到从qqf的路径。即,您已找到字符串z
  4. 保证所有这些路径具有相同的长度(|x| = |y| = |z|
  5. 由于x从州q0转到py从州p转到qz转到q从州qfxyzq0从州qf转到xyz。即,A使用语言y,这意味着L使用语言var main = function() { var colors = ["#ED2007", "#EDAB07", "#ECF30A", "#69F30A", "#0AF3E8", "#0A69F3", "#DE0AF3", "#F30ADE"]; var quotes = [ "If you have nothing, are you a nillionaire?", "Turning up the volume is like zooming in, but with sound.", "If I eat myself, will I get twice as big, or disappear completely?", "Out of my mind. Back in five minutes", "I’m not a complete idiot — Some parts are missing." ]; //begin //when btn-1 is click, perform following $(".btn-1").click(function(){ var $this = $(this); debugger; $this[0].innerText ='loading'; setTimeout(function() { //begin loop for(var i = 0; i < quotes.length; i++){ var randQuote = Math.floor(Math.random() * (quotes.length - 1) + 1); $('#quote')[0].innerText = quotes[randQuote]; } for(var j = 0; j < colors.length; j++){ var randColor = Math.floor((Math.random() * colors[j].length-1)); switch(randColor){ case 0: document.body.style.backgroundColor = "#ED2007"; $this.css('background-color', '#ED2007'); break; case 1: document.body.style.backgroundColor = "#EDAB07"; $this.css('background-color', '#EDAB07'); break; case 2: document.body.style.backgroundColor ="#ECF30A"; $this.css('background-color', '#ECF30A'); break; case 3: document.body.style.backgroundColor = "#69F30A"; $this.css('background-color', '#69F30A'); break; case 4: document.body.style.backgroundColor ="#0AF3E8"; $this.css('background-color', '#0AF3E8'); break; case 5: document.body.style.backgroundColor = "#0A69F3"; $this.css('background-color', '#0A69F3'); break; case 6: document.body.style.backgroundColor = "#DE0AF3"; $this.css('background-color', '#DE0AF3'); break; case 7: document.body.style.backgroundColor="#F30ADE"; $this.css('background-color', '#F30ADE'); break; default: document.body.style.backgroundColor="#00ccff"; $this.css('background-color', '#00ccff'); } } $this[0].innerText = 'reset'; }, 2000); }); //end //when tumblr btn is click, perform following $(".fa-tumblr-square").click(function(){ location.href = "https://www.tumblr.com/"; }); //when twitter btn is click, perform following $(".fa-twitter-square").click(function(){ location.href = 'https://twitter.com/intent/tweet?text='; }); }; $(document).ready(main);