A chain rule formula in BV(Omega) and applications to lower semicontinuity