Lower and upper solutions to semilinear boundary value problems: an abstract approach