public static PDLPos posMinusN(PDLPos position, int n) { if (n == 0) { return(position); } else { return(posMinusN(new PDLPredecessor(position), n - 1)); } }
public static Testcase createTestcase4() { PDLPos lastMinusFour = posMinusN(new PDLLast(), 4); PDLPred xLeqLastMinusFour = new PDLPosLeq(new PDLPosVar("x"), lastMinusFour); PDLPred xLeqY = new PDLPosLeq(new PDLPosVar("x"), new PDLPosVar("y")); PDLPred xLeqZ = new PDLPosLeq(new PDLPosVar("x"), new PDLPosVar("z")); PDLPred yLeqXPlusFour = new PDLPosLeq(new PDLPosVar("y"), posPlusN(new PDLPosVar("x"), 4)); PDLPred zLeqXPlusFour = new PDLPosLeq(new PDLPosVar("z"), posPlusN(new PDLPosVar("x"), 4)); PDLPred yNeqZ = new PDLNot(new PDLPosEq(new PDLPosVar("y"), new PDLPosVar("z"))); PDLPred zeroAtY = new PDLAtPos('0', new PDLPosVar("y")); PDLPred zeroAtZ = new PDLAtPos('0', new PDLPosVar("z")); PDLPred consequence = new PDLAnd(xLeqY, new PDLAnd(xLeqZ, new PDLAnd(yLeqXPlusFour, new PDLAnd(zLeqXPlusFour, new PDLAnd(yNeqZ, new PDLAnd(zeroAtY, zeroAtZ)))))); PDLPred quantConsequence = new PDLExistsFO("y", new PDLExistsFO("z", consequence)); PDLPred language = new PDLForallFO("x", new PDLIf(xLeqLastMinusFour, quantConsequence)); return(new Testcase(4, oneZeroAlphabet, language)); }
public static PDLPos posMinusN(PDLPos position, int n) { if (n == 0) { return position; } else { return posMinusN(new PDLPredecessor(position), n - 1); } }
private static bool IsNumericalFromFirstLastOcc(PDLPos phi, out int size) { if (phi is PDLLastOcc || phi is PDLFirstOcc) { size = 1; return true; } var v1 = phi as PDLPredecessor; if (v1 != null) { int s = 0; if (IsNumericalFromFirstLastOcc(v1.pos, out s)) { size = s + 1; return true; } } var v2 = phi as PDLSuccessor; if (v2 != null) { int s = 0; if (IsNumericalFromFirstLastOcc(v2.pos, out s)) { size = s + 1; return true; } } size = 0; return false; }
private static bool IsNumericalFromFirst(PDLPos phi, out int size) { if (phi is PDLFirst) { size = 1; return true; } var v = phi as PDLSuccessor; if (v != null) { int s = 0; if (IsNumericalFromFirst(v.pos, out s)) { size = s + 1; return true; } } size = 0; return false; }
internal static bool SyntacticDisequivIsFalse(PDLPos p1, PDLPos p2) { if (p1 is PDLSuccessor) { var p11 = p1 as PDLSuccessor; return SyntacticDisequivIsFalse(p11.pos, p2); } if (p2 is PDLPredecessor) { var p21 = p2 as PDLPredecessor; return SyntacticDisequivIsFalse(p1, p21.pos); } return p1.CompareTo(p2) == 0; }
//return true if two positions are trivially different internal static bool SyntacticDisequivIsTrivial(PDLPos p1, PDLPos p2) { return SyntacticDisequivIsTrue(p1, p2) || SyntacticDisequivIsFalse(p1, p2); }
private PDLPos NthSuccessor(int n, PDLPos operand) { PDLPos returnValue = operand; for (int i = 0; i < n; ++i) { returnValue = new PDLSuccessor(returnValue); } return returnValue; }