Compositional safety analysis using barrier certificates