Esempio n. 1
0
  private static PExp normalize(TypeGraph g, Exp original) {
    if (original == null) {
      original = g.getTrueVarExp();
    }

    original = Utilities.applyQuantification(original);

    return PExp.buildPExp(original);
  }
Esempio n. 2
0
  @Override
  public boolean equals(Object o) {
    boolean result = (o instanceof PTFamily);

    if (result) {
      PTFamily oAsPTFamily = (PTFamily) o;

      result =
          (myModel.equals(oAsPTFamily.myModel))
              && (myName.equals(oAsPTFamily.myName))
              && (myExemplarName.equals(oAsPTFamily.myExemplarName))
              && (myConstraint.equals(oAsPTFamily.myConstraint))
              && (myInitializationRequires.equals(oAsPTFamily.myInitializationRequires))
              && (myInitializationEnsures.equals(oAsPTFamily.myInitializationEnsures))
              && (myFinalizationRequires.equals(oAsPTFamily.myFinalizationRequires))
              && (myFinalizationEnsures.equals(oAsPTFamily.myFinalizationEnsures));
    }

    return result;
  }
Esempio n. 3
0
  @Override
  public PTType instantiateGenerics(
      Map<String, PTType> genericInstantiations, FacilityEntry instantiatingFacility) {

    Map<String, MTType> stringToMathType =
        SymbolTableEntry.buildMathTypeGenerics(genericInstantiations);

    @SuppressWarnings("unchecked")
    Map<MTType, MTType> mathTypeToMathType =
        (Map<MTType, MTType>)
            (Map<?, MTType>) MTNamed.toMTNamedMap(getTypeGraph(), stringToMathType);

    MTType newModel = myModel.getCopyWithVariablesSubstituted(stringToMathType);

    PExp newConstraint = myConstraint.withTypesSubstituted(mathTypeToMathType);

    PExp newInitializationRequires =
        myInitializationRequires.withTypesSubstituted(mathTypeToMathType);

    PExp newInitializationEnsures =
        myInitializationEnsures.withTypesSubstituted(mathTypeToMathType);

    PExp newFinalizationRequires = myFinalizationRequires.withTypesSubstituted(mathTypeToMathType);

    PExp newFinalizationEnsures = myFinalizationEnsures.withTypesSubstituted(mathTypeToMathType);

    return new PTFamily(
        newModel,
        myName,
        myExemplarName,
        newConstraint,
        newInitializationRequires,
        newInitializationEnsures,
        newFinalizationRequires,
        newFinalizationEnsures);
  }
Esempio n. 4
0
  private void addTheoremToLibrary(String name, Exp theorem) {
    try {

      Exp quantifiersAppliedTheorem = Utilities.applyQuantification(theorem);

      if (quantifiersAppliedTheorem instanceof EqualsExp) {
        myTheorems.add(quantifiersAppliedTheorem);
        myPExpTheorems.add(PExp.buildPExp(quantifiersAppliedTheorem, myTyper));
        myTheoremNames.add(name);
      } else if (quantifiersAppliedTheorem instanceof InfixExp) {
        InfixExp theoremAsInfixExp = (InfixExp) quantifiersAppliedTheorem;
        if (theoremAsInfixExp.getOpName().getName().equals("implies")) {
          myImplications.add(
              new Implication(theoremAsInfixExp.getLeft(), theoremAsInfixExp.getRight()));
        }
      }

    } catch (IllegalArgumentException e) {
      // This theorem contains a "where" clause and just shouldn't
      // be added.
    }
  }