src/main/java/logic/is/power/tptp_parser/tptp_tester.java
/** Auxilliary for 
     *  checkSemantically(SimpleTptpParserOutput.TopLevelItem item,String fileName):
     *  checks whether <strong> formula </strong> is semantically well-formed 
     *  wrt the signature <strong> _signature </strong>. Side effect: new symbols are 
     *  declared in <strong> _signature </strong>.
     */
Auxilliary for
checkSemantically(SimpleTptpParserOutput.TopLevelItem item,String fileName):
checks whether  formula  is semantically well-formed
wrt the signature  _signature . Side effect: new symbols are
declared in  _signature .
Auxilliary for checkSemantically ( SimpleTptpParserOutput . TopLevelItem item String fileName ) : checks whether formula is semantically well - formed wrt the signature _signature . Side effect : new symbols are declared in _signature .
private 
    static void checkSemantically(SimpleTptpParserOutput.Formula.Atomic atom)
    throws Exception
  {
    String predicate = atom.getPredicate();
    int arity = atom.getNumberOfArguments();
    SymbolDescriptor predicateDescriptor = _signature.get(predicate);
    if (predicateDescriptor == null) {
      _signature.put(predicate,new SymbolDescriptor(true,arity));
    }
    else
      {
        if (!predicateDescriptor.isPredicate) {
          throw new Exception("Semantic error in " + _semanticCheckFileName +
                              ", line " + _semanticCheckLineNumber + ":" +
                              "in atom " + atom + ": predicate " + 
                              predicate + " was used as a function elsewhere.");
        };
        if (predicateDescriptor.arity != arity) {
          throw new Exception("Semantic error in " + _semanticCheckFileName +
                              ", line " + _semanticCheckLineNumber + ":" +
                              "in atom " + atom + ": predicate " + 
                              predicate + " was used with a different arity elsewhere.");
        };
      };
    if (atom.getArguments() != null)
      for (SimpleTptpParserOutput.Term arg : atom.getArguments())
        checkSemantically(arg);
  }
private static void checkSemantically ( SimpleTptpParserOutput . Formula . Atomic atom ) throws Exception { String predicate = atom . getPredicate ( ) ; int arity = atom . getNumberOfArguments ( ) ; SymbolDescriptor predicateDescriptor = _signature . get ( predicate ) ; if ( predicateDescriptor == null ) { _signature . put ( predicate , new SymbolDescriptor ( true , arity ) ) ; } else { if ( ! predicateDescriptor . isPredicate ) { throw new Exception ( "Semantic error in " + _semanticCheckFileName + ", line " + _semanticCheckLineNumber + ":" + "in atom " + atom + ": predicate " + predicate + " was used as a function elsewhere." ) ; } ; if ( predicateDescriptor . arity != arity ) { throw new Exception ( "Semantic error in " + _semanticCheckFileName + ", line " + _semanticCheckLineNumber + ":" + "in atom " + atom + ": predicate " + predicate + " was used with a different arity elsewhere." ) ; } ; } ; if ( atom . getArguments ( ) != null ) for ( SimpleTptpParserOutput . Term arg : atom . getArguments ( ) ) checkSemantically ( arg ) ; }
Auxilliary for
  checkSemantically(SimpleTptpParserOutput.TopLevelItem item,String fileName):
  checks whether <strong> formula </strong> is semantically well-formed
  wrt the signature <strong> _signature </strong>.
Auxilliary for checkSemantically ( SimpleTptpParserOutput . TopLevelItem item String fileName ) : checks whether <strong > formula < / strong > is semantically well - formed wrt the signature <strong > _signature < / strong > .
// Look up this symbol in the signature: // New symbol, has to be added to _signature // Check the arguments