IRC section 401(a)(2 requires that "under the trust instrument" certain things be true. Based on this, Treas. Reg. § 1.401-1(a)(2) states as follows:
QUOTE
A qualified pension, profit-sharing, or stock bonus plan is a definite written program ...
The IRS has in turn interpreted the requirement of a written program to mean that the plan must be operated in accordance with that written program; otherwise, the requirement would be meaningless.