/* * 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.*; /** * The regular pumping lemma for L = * {anblak : n * > 5, l > 3, kl}. * * @author Jinghui Lim & Chris Morgan * */ public class AnBlAk extends RegularPumpingLemma { public String getTitle() { return "a^n b^l a^k : n > 5, l > 3, k <= l"; } public String getHTMLTitle() { return "anblak : n " + GREATER_THAN + " 5, l " + GREATER_THAN + " 3, k " + LESS_OR_EQ + " l"; } public void setDescription() { partitionIsValid = false; explanation = "For any m value " + GREATER_OR_EQ + " 4, a possible value for w is \"a6" + "bmam\". The y value thus would be a combination of \"a\"s " + "and \"b\"s, in that order. If i = 0, either n " + LESS_OR_EQ + " 5, k > l, or both, giving a " + "string that is not in the language. Thus, the language is not regular."; } protected void chooseW() { if(getM() <= 3) w = pumpString("a", 6) + pumpString("b", 4) + pumpString("a", 4); else w = pumpString("a", 6) + pumpString("b", getM()) + pumpString("a", getM()); } public void chooseDecomposition() { int b = w.indexOf('b'); if (b > 6) setDecomposition(new int[] {0, 1}); else setDecomposition(new int[] {Math.min(b, m-1), 1}); } public void chooseI() { i = 0; } protected void setRange() { myRange = new int[]{2, 15}; } public boolean isInLang(String s) { int a, b, a2; char[] list = new char[]{'a','b','a'}; if (LemmaMath.isMixture(s, list)) return false; b = LemmaMath.countInstances(s, 'b'); if (b==0) return false; String ba2 = s.substring(s.indexOf('b')); //deletes the a^n portion of the string a = s.length() - ba2.length(); a2 = LemmaMath.countInstances(ba2, 'a'); if (a <= 5 || b <= 3 || a2 > b) return false; return true; } }