Rational habit formation