Knowledge-based Reasoning and Learning under Partial Observability in Ad Hoc Teamwork