bugfix in detect_theories; better printing of FOTerms