Commit e7bb515b authored by Sarah Grebing's avatar Sarah Grebing

Matching of Sequent interimstate

parent d6247320
Pipeline #12958 failed with stage
in 1 minute and 35 seconds
......@@ -107,6 +107,10 @@ public class MatcherFacade {
* @return
*/
private static List<MatchInfo> reduceCompatibleMatches(List<List<MatchInfo>> allMatches) {
if (allMatches.size() == 1) {
return allMatches.get(0);
}
if (allMatches.size() == 2) {
return MatcherImpl.reduceConform(allMatches.get(0), allMatches.get(1));
} else {
......@@ -131,10 +135,20 @@ public class MatcherFacade {
MatcherImpl matcher = new MatcherImpl();
MatchPatternParser mpp = getParser(pattern);
SequentPatternContext ctx = mpp.sequentPattern();
Semisequent antec = sequent.antecedent();
Semisequent succ = sequent.succedent();
SemiSeqPatternContext antecPattern = ctx.antec;
SemiSeqPatternContext succPattern = ctx.succ;
System.out.println("SuccPattern " + succPattern);
Matchings mAntec = matches(antecPattern, antec);
Matchings mSucc = matches(succPattern, succ);
Matchings newMatching = MatcherImpl.reduceConform(mAntec, mSucc);
//return MatcherImpl.NO_MATCH;
return matches(pattern,antec);
return newMatching;
}
}
......@@ -42,10 +42,16 @@ public class MatcherFacadeTest {
shouldMatch("f(a)", "f(a)");
shouldMatchForm("pred(a)", "_");
shouldMatchForm("pred(a)", "pred(?X)", "[{?X=a}]");
shouldMatchSeq("pred(a), pred(b) ==> pred(b)", "pred(?X), pred(?Z) ==> pred(?Y)");
shouldMatchSeq("pred(a), pred(b) ==> pred(b)", "pred(?X), pred(?Z) ==> pred(?X)");
shouldMatchSemiSeq("pred(a), pred(b) ==>", "pred(?X), pred(?Y)", "[{?X=a, ?Y=b}, {?X=b, ?Y=a}]");
shouldMatchSemiSeq("pred(a), pred(b) ==>", "pred(?X), pred(?X)", "[]");
shouldMatchSemiSeq("pred(a), pred(f(a)) ==>", "pred(?X), pred(f(?X))", "[{?X=a}]");
shouldMatchSemiSeq("pred(b), pred(f(a)) ==>", "pred(?X), pred(f(?X))", "[]");
// shouldMatchSemiSeq("pred(a), pred(b) ==>", "pred(?X), pred(?X)", "[]");
// shouldMatchSemiSeq("pred(a), pred(f(a)) ==>", "pred(?X), pred(f(?X))", "[{?X=a}]");
// shouldMatchSemiSeq("pred(b), pred(f(a)) ==>", "pred(?X), pred(f(?X))", "[]");
// shouldMatchSemiSeq("pred(a), pred(b) ==> qpred(a,b)", "pred(a), pred(b)");
//shouldMatchSemiSeq("pred(a), pred(b) ==> qpred(a,b)", "pred(?X), pred(?Y)", "[{?X=a}, {?Y:=b}]");
......@@ -85,6 +91,12 @@ public class MatcherFacadeTest {
Assert.assertEquals(exp, m.toString());
}
private void shouldMatchSeq(String seq, String seqPattern) throws ParserException {
Sequent sequent = parseSeq(seq);
Matchings m = MatcherFacade.matches(seqPattern, sequent);
System.out.println(m);
}
private void shouldMatchSemiSeq(String s, String s1, String exp) throws ParserException {
Sequent term = parseSeq(s);
Matchings m = MatcherFacade.matches(s1, term);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment