/* * 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 = * {ww1wR : |w| = |w1|, * w & w1 ∈ {a, b}*}. * * @author Chris Morgan */ public class WW1WrEquals extends ContextFreePumpingLemma { public String getTitle() { return "w w1 w^R : |w| = |w1|, w & w1 element_of {ab}*"; } public String getHTMLTitle() { return "ww1wR : |w| = |w1| " +", w & w1 " + ELEMENT_OF + " " + AB_STAR; } public void setDescription() { partitionIsValid = false; explanation = "For any m value, a possible value for w is \"am" + "bmam\". To be in the language with " + "this example, v & y together cannot possess substrings that are from both 'w' " + "and 'wR'. Thus, pumping a substring from either 'w', 'w1', " + " or 'wR' will violate the |'w'| = |'wR'| equality or cause |'w'| " + NOT_EQUAL + "|'w1'|. Thus, this language is not context-free."; } protected void addCases() { // TODO Auto-generated method stub } public void chooseI() { i = LemmaMath.flipCoin(); } public void chooseDecomposition() { setDecomposition(new int[] {0, 1, 0, 0}); } protected void chooseW() { w = pumpString("a", m) + pumpString("b", m) + pumpString("a", m); } protected void setRange() { myRange = new int[]{3, 10}; } public boolean isInLang(String s) { char[] list = new char[]{'a','b'}; if (LemmaMath.otherCharactersFound(s, list) || s.length()==0) return false; int front, end; front = 0; end = s.length()-1; while (s.charAt(front)==s.charAt(end) && front