Пример #1
0
  public static Formula buildLambdaFormula(String binary1, String binary2, boolean reverse) {

    Formula binary1Formula =
        reverse ? Formulas.newNameFormula("!" + binary1) : Formulas.newNameFormula(binary1);
    Formula binary2Formula =
        reverse ? Formulas.newNameFormula("!" + binary2) : Formulas.newNameFormula(binary2);
    Formula join1 = new JoinFormula(binary2Formula, new VariableFormula("x"));
    Formula join2 = new JoinFormula(binary1Formula, join1);
    return new LambdaFormula("x", join2);
  }
Пример #2
0
  public Formula equivalentFormula(LispTree tree) {

    if (tree.isLeaf()) {
      boolean rev = FreebaseInfo.isReverseProperty(tree.value);
      String fbProperty = rev ? tree.value.substring(1) : tree.value;
      String oppositeProperty = freebaseInfo.getOppositeFbProperty(fbProperty);
      return rev
          ? Formulas.newNameFormula(oppositeProperty)
          : Formulas.newNameFormula("!" + oppositeProperty);
    } else {
      String binary1 = tree.child(2).child(0).value;
      binary1 = FreebaseInfo.isReverseProperty(binary1) ? binary1.substring(1) : binary1;
      String binary2 = tree.child(2).child(1).child(0).value;
      binary2 = FreebaseInfo.isReverseProperty(binary2) ? binary2.substring(1) : binary2;
      String oppositeBinary1 = freebaseInfo.getOppositeFbProperty(binary1);
      String oppositeBinary2 = freebaseInfo.getOppositeFbProperty(binary2);
      boolean rev = FreebaseInfo.isReverseProperty(tree.child(2).child(0).value);
      return buildLambdaFormula(oppositeBinary1, oppositeBinary2, !rev);
    }
  }