The behavior of industrial applications requires the guarantee of safety properties. Safety properties are guaranteed under assumptions about the operating environment of the system at design time. If the assumption is broken by a change of environment at runtime, the safety properties are not guaranteed. For the system to guarantee safety properties even in a changed environment, it is necessary to adapt to changes in the environment and change the specification of the system at runtime. Discrete controller synthesis is a technique for automatically generating a specification, but it is not efficient to use it for generating a new specification at runtime. In this work, we propose an efficient algorithm for regenerating a specification that guarantees safety properties under the environment changed at runtime of the system. We evaluated the computational time of our algorithm in two scenarios and found that it was faster than the existing algorithm for generating a specification.