We have observed four carbon stars (
W Ori,
RW LMi [
CIT6],
Y CVn, and
LP And [
IRC+40540]) in the
HCN(J=1->0) line and three of them (
RW LMi,
Y CVn, and
LP And) also in the CN(N=1->0) line using the IRAM interferometer on Plateau de Bure. The HCN brightness distributions are centred on the stellar positions suggesting a photospheric origin of this molecule. We see the expected structure of a hollow CN brightness distribution outside that of the HCN emitting region (in particular, for
RW LMi and
LP And). We have used a non-LTE radiative transfer code, based on the Monte Carlo method, to model the circumstellar HCN and CN line emissions. We have, in addition to the interferometer data, used also multi-transition single dish data as constraints. The results are qualitatively, and in most cases also quantitatively, consistent with a simple photodissociation model, in which HCN is produced in the stellar atmosphere, while the observed CN is formed in the circumstellar envelope due to the photodissociation of HCN. The most notable discrepancy is the low CN/HCN peak abundance ratios, ≃0.16, obtained for those objects with the best observational constraints. These are lower by at least a factor of two compared to the results of also more elaborate chemical models. Some of our modelling discrepancies, e.g., the weakness of the model HCN(J=1->0) intensities, are attributed to a too crude treatment of the radiative excitation in the inner region of a circumstellar envelope, and to a lack of knowledge of the density structure and kinematics in the same region. We find it particularly difficult to model the circumstellar line emissions towards
RW LMi, and suspect that this is due to, e.g., a mass loss rate that has varied with time and/or a non-spherical envelope. The HCN and CN brightness maps suggest the latter. Furthermore, we have obtained interferometric data towards
RW LMi in also the HNC(J=1-0), HC
3N(J=10-9), HC
5N(J=34-33) and SiS(J=5-4) lines. The HNC, HC
3N, and HC
5N molecules appear to be distributed in a shell, while the SiS emission is clearly confined to regions close to the star. The HCN(J=1-0), HNC(J=1-0), and HC
3N(J=10-9) lines show the effect that the peak brightness position varies systematically with the velocity. We attribute this to a large-scale asymmetry in the envelope. We also find that some of the spectra obtained towards the map centre are highly asymmetric, with the redshifted emission being significantly stronger than the blueshifted emission.