In a $ 40 \times 50$ array of control buttons, each button has two states: on and off. By touching a button, its state and the states of all buttons in the same row and in the same column are switched. Prove that the array of control buttons may be altered from the all-off state to the all-on state by touching buttons successively, and determine the least number of touches needed to do so.
To solve the problem, we need to prove that it is possible to switch all buttons from the all-off state to the all-on state by touching buttons successively, and determine the least number of touches needed to do so.

1. **Generalization for \( m \times n \) array:**
   - If both \( m \) and \( n \) are odd, the minimum number of steps is \( \min(m, n) \). This can be achieved by touching each of the buttons along the side containing the \( \min(m, n) \) buttons.
   - If only one of the sides is odd, say \( m \), then the minimum number of steps is \( m \), obtained by touching each of the buttons along the side containing \( m \) buttons.
   - If both \( m \) and \( n \) are even, then one way to alter all lights to the all-on state is to touch each of the \( m \times n \) buttons exactly once sequentially, going from one row/column to the next or in any other order.

2. **Proof for the case when both \( m \) and \( n \) are even:**
   - We need to prove that the minimum number of steps is \( m \times n \) when both \( m \) and \( n \) are even.
   - To prove this, it suffices to show that no button can be left untouched.

3. **Assume a button is left untouched:**
   - If a button is left untouched, it will be turned to the ON state only if there are an odd number of touches along the row and column containing this button.
   - Therefore, either the row or column (say row) containing this button must have an odd number of touches, and the other (say column) must have an even number of touches. Let us label this row as \( R \) and column as \( C \).

4. **Analyzing the matrix excluding \( R \) and \( C \):**
   - Each button in \( C \) needs to have an odd number of touches in total, so each row of the matrix obtained after excluding \( C \) and \( R \) must have an odd number of touches.
   - This matrix has dimensions \( (m-1) \times (n-1) \), so the total number of touches in this matrix must be odd. (Equation 1)
   - Each button in \( R \) needs to have an odd number of touches in total, so each column of the matrix obtained after excluding \( C \) and \( R \) must have an even number of touches, so the total number of touches in this matrix must be even. (Equation 2)

5. **Contradiction:**
   - From Equation 1 and Equation 2, we have a contradiction because the total number of touches in the matrix cannot be both odd and even simultaneously.
   - Therefore, our assumption that a button can be left untouched is false.

6. **Conclusion:**
   - Since no button can be left untouched, the minimum number of touches needed to switch all buttons from the all-off state to the all-on state when both \( m \) and \( n \) are even is \( m \times n \).

The final answer is \( \boxed{ m \times n } \) when both \( m \) and \( n \) are even.