The Wittig reaction is an extremely important organic reaction that allows to prepare alkenes through a particular class of compounds called "ylides". The substrate on which the reaction is performed are aldehydes and ketones.
Ylides formation
This is the overall reaction. Ylides are used because they stabilize particularly well the carbanion and the reaction is, at the end of the day, controlled, contrarily to how are usually carbanions-based reactions. In addition we'll see that depending on the ylide used we can obtain stereospecific products (E or Z).
But first of all, we have to understand how to get phosphonium ylides.
1) The first part of the reaction is a symple nucleophilic substitution, SN2; phosphorus in triphenyl phosphine shows a lone pair that makes the molecule a soft nucleophile. Triphenyl phosphine can therefore attack the electrophilic carbon of the bromoalkane with subsequent leaving of bromide. The preferential substrate to carry out this reaction are actually halogen derivatives (since halogens are good leaving groups), but nothing prohibits to operate the substitution on different substrates. Once generated the phosphonium salt (i.e phosphonium bromide) there's the fundamental step.
2) Since phosphorus shows now four bonds and is then surrounded by four electrons, it is now positively charged. This intermediate is particularly stable because the charge can be delocalized on three aromatic systems (aromatic carbocations are quite stable → carbocations stability). At the same time, however, the positive charge induces the phosphorus to attract with more strengh bonding electrons, making acid hydrogen of the adjacent carbon (α position). Treating indeed this intermediate with a strong base, such as sodium ethoxide, they are the more easily removed. We have therefore generated a carbanion adjacent to an heteroatom positively charged (phosphorus). This particular kind of products are what is called "ylide"
Let's see in more details the reaction mechanism of this useful reaction.
Reaction mechanism step by step
First of all, it must be pointed out that phosphonium ylides can be better represented with two resonance structures, one of which doesn't show charge separation:
and more important, it is also the most representative. Anyway, the molecule is a resonance hybride, and the structure we called ylide is extremely useful to understand how actually the reaction proceeds. Now, let's see how do ylides react with carbonyl compounds, aldehydes and ketones:

2) Phosphorous has a strong oxygenophilic character and we arrive to an intermediate to a four-membered cyclic intermediate with an oxygen-phosphorus bond.
3) Let's consider now two things. Phosphorus is less electronegative than carbon, therefore a C-P bond will be polarized towards carbon. P-O bond instead is an extremely stable bond (very low in energy). What happens is that according to a concerted mechanism, C-P bond breaks down with bonding electrons that go to carbon while O pull in electrons from the bond on which was engaged and binds phosphorus.
The result is that triphenylphosphine oxide leaves (in reaction environment gives a solid that's easily filtered) and we finally get a double bond, the corresponding alkene.
...Resuming
Wittig reaction allows to obtain alkenes in which the localization of the double bond leaves no room for ambiguity. It's also free from typical problems related to alkene synthesis, for examples rearrangements in synthesis by elimination reactions.
For simplicity observe that, pointing only two substrates with whom we want actually carry out the reaction, the reaction product "corresponds simply to the superimposition of the molecules" . Obviously this is just a little trick to imagine more quickly the reaction product, being careful not to overlook the chemistry that physically underlies the reaction.
Stereoselectivity in Wittig reaction
In the previous example we've shown that there's no ambiguity from stereoselectivity viewpoint in this specific reaction, given that cyclohexanone is a perfectly symmetric molecule. But when the aldehyde or ketone are asymmetric, comes out the sometimes annoying trouble of cis-trans (E/Z) isomery.
If we replaced, for example cyclohexanone with 2-butanone, using the same ylidee of the previous example, the product we get could be a mixture of E,Z stereoisomers.
In the end, do i get both the stereoisomers or is the reaction stereoselective?
Well, Wittig reaction can be either E selective (but is quite slow) or more commonly Z selective.
The reaction is E selective when i use particularly well stabilized ylids, while is Z selective when ylides are not stabilized.
There are different groups who can stabilize an ylide, and are all those groups which allows a good delocalization of the negative charge of the carbanion. Which group meets better this definition than aromatyc systems?
Here's an example. Notice how many resonance structures can be written. Remember that more the resonance structures are, the lower is the energy of the molecule → great stability.
This ylide is very well stabilized by mesomeric effect. If we put this ylide with an aldehyde or ketone what we get would be for sure the E (trans) alkene.



