Termination Criteria for Datalog with Function Symbols