/*
* JFLAP - Formal Languages and Automata Package
*
*
* Susan H. Rodger
* Computer Science Department
* Duke University
* August 27, 2009
* Copyright (c) 2002-2009
* All rights reserved.
* JFLAP is open source software. Please see the LICENSE for terms.
*
*/
package pumping.cf;
import pumping.*;
/**
* The context-free pumping lemma for L =
* {w1bnw2 : na(w1)
* < na(w2), n > na(w1),
* w1 & w2 ∈ {a, b}*}.
*
* @author Chris Morgan
*/
public class W1BnW2 extends ContextFreePumpingLemma {
public String getTitle()
{
return "w1 + b^n + w2 : na(w1) < na(w2) & na(w1) < n, w1 & w2 element_of {ab}*";
}
public String getHTMLTitle()
{
return "w1bnw2 : na" +
"(w1) " + LESS_THAN + " na(w2" +
"), na(w1) " + LESS_THAN +" n, " +
"w1 & w2 " + ELEMENT_OF + " " + AB_STAR;
}
public void setDescription()
{
partitionIsValid = false;
explanation = "For any m value, a possible value for w is \"am" +
"bm+1am+1\". To be in the language with " +
"this example, v & y together cannot possess substrings that are from " +
"'w'1, from bn, and from 'w2'. Thus, if i = 0, " +
"i = 2, or perhaps both, either v or y will violate one of the " +
"conditions, meaning there is no valid decomposition. Thus, this language is not " +
"context-free.";
}
protected void addCases()
{
// TODO Auto-generated method stub
}
protected void chooseW()
{
w = pumpString("a", m) + pumpString("b", m+1) + pumpString("a", m+1);
}
public void chooseDecomposition()
{
String s;
for (int k=w.length()-1; k>=0; k--) {
s = w.substring(0, k) + w.substring(k+1);
if (isInLang(s)) {
setDecomposition(new int[]{k, 1, 0, 0});
return;
}
}
super.chooseDecomposition();
}
public void chooseI()
{
if (getU().length() < m)
i = 2;
else
i = 0;
}
protected void setRange()
{
myRange = new int[]{2, 10};
}
public boolean isInLang(String s)
{
char[] list = new char[]{'a','b'};
if (LemmaMath.otherCharactersFound(s, list))
return false;
int i, a1, a2;
String w1, w2, temp;
temp = null;
i = 0;
while (i a1)
return true;
}
i++;
}
return false;
}
}