Ensuring the correct behavior of cyber physical systems (CPS) at runtime is critical
and it is more so in safety-critical area
such as aerospace
automotive
nuclear power and medical. A method of runtime safety verification based on hidden Markov model (HMM) is proposed for the CPS with stochastic behavior and unobservable states. First
a runtime safety verification framework of the CPS is constructed where the system model is represented by HMM
and the negation of safety property is specified by deterministic finite automaton (DFA)
and then the product automata of DFA and HMM is used as a runtime monitor. Thus
the problem of CPS runtime safety verification is reduced into a probabilistic inference problem on the monitor. Second
an incremental iterative safety verification algorithm and a counterexample generation algorithm are proposed. The experimental results show that the prediction error rate of the safety verification algorithm is nearly 20% lower than that of the particle filter algorithm. When the system violates the safety property
the proposed method can product a counterexample which the particle filtering method cannot do.