Critical theories of phase transition between symmetry protected topological states and their relation to the gapless boundary theories