A proof-theoretic approach to logic programming, I. Generalized horn clauses