Foundations of Rules and Consequences