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.Term term) 
    throws Exception
  {
    if (!term.getTopSymbol().isVariable()) {
      String function = term.getTopSymbol().getText();
      int arity = term.getNumberOfArguments();
      SymbolDescriptor functionDescriptor = _signature.get(function);
      if (functionDescriptor == null) {
        _signature.put(function,new SymbolDescriptor(false,arity));
      }
      else
        {
          if (functionDescriptor.isPredicate)  {
            throw new Exception("Semantic error in " + _semanticCheckFileName +
                                ", line " + _semanticCheckLineNumber + ":" +
                                "in term " + term + ": function " + 
                                function + " was used as a predicate elsewhere.");
          };
          if (functionDescriptor.arity != arity) {
            throw new Exception("Semantic error in " + _semanticCheckFileName +
                                ", line " + _semanticCheckLineNumber + ":" +
                                "in term " + term + ": function " + 
                                function + 
                                " was used with a different arity elsewhere.");
          };
        };
      if (term.getArguments() != null)
        for (SimpleTptpParserOutput.Term arg : term.getArguments())
          checkSemantically(arg);
    }; 
  }
private static void checkSemantically ( SimpleTptpParserOutput . Term term ) throws Exception { if ( ! term . getTopSymbol ( ) . isVariable ( ) ) { String function = term . getTopSymbol ( ) . getText ( ) ; int arity = term . getNumberOfArguments ( ) ; SymbolDescriptor functionDescriptor = _signature . get ( function ) ; if ( functionDescriptor == null ) { _signature . put ( function , new SymbolDescriptor ( false , arity ) ) ; } else { if ( functionDescriptor . isPredicate ) { throw new Exception ( "Semantic error in " + _semanticCheckFileName + ", line " + _semanticCheckLineNumber + ":" + "in term " + term + ": function " + function + " was used as a predicate elsewhere." ) ; } ; if ( functionDescriptor . arity != arity ) { throw new Exception ( "Semantic error in " + _semanticCheckFileName + ", line " + _semanticCheckLineNumber + ":" + "in term " + term + ": function " + function + " was used with a different arity elsewhere." ) ; } ; } ; if ( term . getArguments ( ) != null ) for ( SimpleTptpParserOutput . Term arg : term . 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 the function symbol in the signature // New symbol, has to be added to _signature // Check the arguments // if (!term.getTopSymbol().isVariable())