A generalized Lax-Milgram theorem