/* * 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.reg; import pumping.LemmaMath; import pumping.RegularPumpingLemma; /** * The regular pumping lemma for L = * {bba(ba)nan-1}. * * @author Chris Morgan */ public class BBABAnAn extends RegularPumpingLemma { public String getHTMLTitle() { return "bba(ba)nan-1"; } public String getTitle() { return "bba(ba)^n a^(n-1)"; } public void setDescription() { partitionIsValid = false; explanation = "For any m value, a possible value for w is \"bba(ba)m" + "am-1\". No possible y value among the \"bba(ba)m\" " + "segment is possible to pump, meaning any possible generated string is not in the language. " + "Thus, the language is not regular."; } public void chooseI() { i = LemmaMath.flipCoin(); } public void chooseDecomposition() { setDecomposition(new int[]{1, 2}); } protected void chooseW() { w = "bba" + pumpString("ba", m) + pumpString("a", m-1); } protected void setRange() { myRange = new int[] {5, 10}; } public boolean isInLang(String s) { if (!s.startsWith("bba")) return false; String temp = s.substring(3); int n = 0; while (temp.startsWith("ba")) { temp = temp.substring(2); n++; } while (temp.startsWith("a")) { temp = temp.substring(1); n--; } if (n==1 && temp.length()==0) return true; return false; } }