Question about ideal opamp

The ideal opamp model assumes there is no voltage difference between the input terminals. How is that possible? To me, the voltage at the inputs are defined by external components that we connect to each input, with each input independent from the other. My question is, what would happen if I connected one input to a 5V voltage source and the other input to a 12V voltage source?

There is no voltage difference between the input terminals AFTER the input signals have been fed into the input network. The ideal opamp has infinite gain and the output is fed back to the inputs via the input network so as to reduce the input voltage difference to zero.

In the most simplistic of ideal op-amp models, applying different voltages directly to the amplifier inputs would result in infinite output, an unrealistic condition in practice. More representative models limit the range of possible output voltages. In this case, applying the sort of voltages you mention would force the amplifier output to an extreme value. That is also what would happen in practice, provided that these large voltages lay within the acceptable input range for the amplifier concerned.

The condition that the difference between the two input voltages is negligible assumes that the amplifier is in a negative feedback configuration, and that any applied inputs lie within a range which allows a nulled input voltage to be obtained within the available range of output voltages. Overdrive of the input(s) beyond this range will force the input voltages apart, at least as far as the real world or models having finite output capability are concerned.

Theoretically, there is a voltage difference between the differential input terminals when the op amp is operating within normal limits--however, it is so small that for practical purposes it cannot be measured--this is because the Av (open loop gain) is in the order of 100,000 or even higher.

Op amp datasheets give a specification for the input offset voltage. For the ideal op amp the input offset voltage equals zero. In all useful op amp circuits, the op amp works to reduce the voltage difference at the input terminals to zero. However, if you force a voltage difference at the input terminals, then the op amp output is forced to one power rail or the other. Then it is no longer an op amp circuit but a comparator circuit. It can work, but op amps make poor comparators.