The logic of historical explanation