The Logic of Totally and Partially Ordered Plans: A Deductive Database Approach.