@Test public void testReduce() { { And duplicate = makeAnd(a, b, c, a, b, c); assertEquals(makeAnd(a, b, c), duplicate.reduce()); } { And combined = makeAnd(a_and_b,a_and_c); assertEquals(makeAnd(a, b, c), combined.reduce()); } { And withTrue = makeAnd(a, b, True.get()); assertEquals(a_and_b, withTrue.reduce()); } { And withFalse = makeAnd(a, b, False.get()); assertEquals(False.get(), withFalse.reduce()); } { And solitaryWithTrue = makeAnd(a, True.get()); assertEquals(a, solitaryWithTrue.reduce()); } }
@Override protected LTLFormula reduce(){ for(int i = 0; i < children.size(); ++i){ children.set(i, children.get(i).reduce()); } flatten(); Collections.sort(children); for(int i = 0; ; ++i){ if(i >= children.size()) return this; if(children.get(i) == False.get()){ return False.get(); } if(children.get(i) == True.get()){ children.remove(i); --i; continue; } if(children.get(i).getLTLType() == LTLType.A){ for(int j = i; j < children.size(); ++j){ LTLFormula child = children.get(j); if(child.getLTLType().compareTo(LTLType.NEG) > 0){ break; } if(child.getLTLType() == LTLType.NEG && child.getChildren().get(0) == children.get(i)){ return False.get(); } } } if(i + 1 < children.size() && children.get(i).equals(children.get(i + 1))){ children.remove(i); --i; } if(children.size() == 1) return children.get(0); } }
And extends LTLFormula { @Override protected LTLFormula reduce(){ for(int i = 0; i < children.size(); ++i){ children.set(i, children.get(i).reduce()); } flatten(); Collections.sort(children); for(int i = 0; ; ++i){ if(i >= children.size()) return this; if(children.get(i) == False.get()){ return False.get(); } if(children.get(i) == True.get()){ children.remove(i); --i; continue; } if(children.get(i).getLTLType() == LTLType.A){ for(int j = i; j < children.size(); ++j){ LTLFormula child = children.get(j); if(child.getLTLType().compareTo(LTLType.NEG) > 0){ break; } if(child.getLTLType() == LTLType.NEG && child.getChildren().get(0) == children.get(i)){ return False.get(); } } } if(i + 1 < children.size() && children.get(i).equals(children.get(i + 1))){ children.remove(i); --i; } if(children.size() == 1) return children.get(0); } } }
And extends LTLFormula { @Override protected LTLFormula reduce(){ for(int i = 0; i < children.size(); ++i){ children.set(i, children.get(i).reduce()); } flatten(); Collections.sort(children); for(int i = 0; ; ++i){ if(i >= children.size()) return this; if(children.get(i) == False.get()){ return False.get(); } if(children.get(i) == True.get()){ children.remove(i); --i; continue; } if(children.get(i).getLTLType() == LTLType.A){ for(int j = i; j < children.size(); ++j){ LTLFormula child = children.get(j); if(child.getLTLType().compareTo(LTLType.NEG) > 0){ break; } if(child.getLTLType() == LTLType.NEG && child.getChildren().get(0) == children.get(i)){ return False.get(); } } } if(i + 1 < children.size() && children.get(i).equals(children.get(i + 1))){ children.remove(i); --i; } if(children.size() == 1) return children.get(0); } } And(ArrayList<LTLFormula> children); }
And extends LTLFormula { @Override protected LTLFormula reduce(){ for(int i = 0; i < children.size(); ++i){ children.set(i, children.get(i).reduce()); } flatten(); Collections.sort(children); for(int i = 0; ; ++i){ if(i >= children.size()) return this; if(children.get(i) == False.get()){ return False.get(); } if(children.get(i) == True.get()){ children.remove(i); --i; continue; } if(children.get(i).getLTLType() == LTLType.A){ for(int j = i; j < children.size(); ++j){ LTLFormula child = children.get(j); if(child.getLTLType().compareTo(LTLType.NEG) > 0){ break; } if(child.getLTLType() == LTLType.NEG && child.getChildren().get(0) == children.get(i)){ return False.get(); } } } if(i + 1 < children.size() && children.get(i).equals(children.get(i + 1))){ children.remove(i); --i; } if(children.size() == 1) return children.get(0); } } And(ArrayList<LTLFormula> children); @Override LTLType getLTLType(); @Override LTLFormula copy(); @Override LinkedHashSet<LinkedHashSet<LTLFormula>> toSetForm(); @Override ATransition d(HashMap<LTLFormula, ATransition> D); static void main(String args[]); }
And extends LTLFormula { @Override protected LTLFormula reduce(){ for(int i = 0; i < children.size(); ++i){ children.set(i, children.get(i).reduce()); } flatten(); Collections.sort(children); for(int i = 0; ; ++i){ if(i >= children.size()) return this; if(children.get(i) == False.get()){ return False.get(); } if(children.get(i) == True.get()){ children.remove(i); --i; continue; } if(children.get(i).getLTLType() == LTLType.A){ for(int j = i; j < children.size(); ++j){ LTLFormula child = children.get(j); if(child.getLTLType().compareTo(LTLType.NEG) > 0){ break; } if(child.getLTLType() == LTLType.NEG && child.getChildren().get(0) == children.get(i)){ return False.get(); } } } if(i + 1 < children.size() && children.get(i).equals(children.get(i + 1))){ children.remove(i); --i; } if(children.size() == 1) return children.get(0); } } And(ArrayList<LTLFormula> children); @Override LTLType getLTLType(); @Override LTLFormula copy(); @Override LinkedHashSet<LinkedHashSet<LTLFormula>> toSetForm(); @Override ATransition d(HashMap<LTLFormula, ATransition> D); static void main(String args[]);  }