a–c, Bacterial (a) and phage titres upon individual (b) or mixed (c) infection of wild-type PA14 with phage DMS3 and virulent phage LMA2. d, e, Resistance phenotypes evolved by bacteria against DMS3 upon individual (d) or mixed (e) infection. f, Frequency of loss of CRISPR–Cas immune systems upon infection with phage DMS3 or with both the phages DMS3 and LMA2, based on 24 random clones per replicate experiment. g, Relative fitness of wild-type PA14 during competition with PA14 Δcas7 in the presence or absence of phages DMS3 and LMA2. a–g, Data are the means of six biological replicates. Error bars indicate 95% confidence intervals. h–o, Simulations of population and evolutionary dynamics during infection of bacteria carrying CRISPR–Cas systems with a mixed population of unrelated virulent and temperate phages. Graphs show densities of susceptible hosts, CRISPR-resistant bacteria and lysogens (h, i) and free viruses over time (j, k), as well as the frequencies of temperate phages in a population composed of both temperate and virulent types (l, m). Temperate phage can transmit both horizontally and vertically, whereas virulent phage can transmit only horizontally and can superinfect the lysogens (because temperate and virulent phages are unrelated). n, o, Frequencies of evolutionary loss of CRISPR–Cas system in the lysogen population over time. The simulations shown in h, j, l, n reflect a scenario in which bacteria can evolve CRISPR-based resistance against both phages, whereas those shown in i, k, m, o reflect a situation in which CRISPR-based resistance does not evolve against the virulent phage, and bacteria instead evolve costly surface-based resistance (as it is the case in our experiments). A detailed description of the simulations is provided in the Supplementary Information. Source data