N-(Benzyloxycarbonyl)isonipecotic acid (I) was activated as the acid chloride (II) employing oxalyl chloride in the presence of a catalytic amount of DMF. Addition of diazomethane to acid chloride (II) produced the intermediate diazo ketone (III) which, upon treatment with an ethereal solution of HCl, led to the chloromethyl ketone (IV).
Acylation of the lithium derivative of 4-picoline (VI) with the Weinreb amide of 4-fluorobenzoic acid (V) yielded ketone (VII). The sodium enolate of (VII) was then alkylated with chloro ketone (IV) to afford diketone (VIII). The Paal-Knorr cyclization of diketone (VIII) in the presence of ammonium acetate in boiling HOAc led to pyrrole (IX). Finally, reduction of the benzyloxycarbonyl group of (IX) by means of LiAlH4 furnished the target N-methyl piperidine.