SMS: The logical foundations of cognition