Reformulating the Situation Calculus and the Event Calculus in the General Theory of Stable Models and in Answer Set Programming