Kripke Model | 프로그래밍의 벗 PivotOJ
PivotOJ

Kripke Model

시간 제한: 1000ms메모리 제한: 128MB출처: NEERC Northern Subregional 2009BOJ 3560

문제

Testing and quality assurance are very time-consuming stages of software development process. Different techniques are used to reduce cost and time consumed by these stages. One of such techniques is software verification. Model checking is an approach to the software verification based on Kripke models.

A Kripke model is a 5-tuple (P,S,S0,R,L)(P, S, S_{0}, R, L), where PP is a finite set of atomic propositions, SS is a finite set of model's states, S0SS_{0} \subset S is a set of initial states, RS×SR \subset S \times S is a transition relation, and LS×PL \subset S \times P is a truth relation. In this problem we will not take initial states into account and relation RR will be a reflexive relation, so R(s,s)R(s, s) will be true for all states sSs \in S.

A path π\pi beginning in state ss in the Kripke model is an infinite sequence of states s0s1s_0 s_1 \ldots such that s0=ss_0=s, and for each i0i \ge 0 the (si,si+1)R(s_i, s_{i+1}) \in R

Temporal logic and its subset Computational tree logic (CTL) are used to describe propositions qualified in terms of time. Kripke models are often used to check properties, described in CTL. 

There are two types of formulae in CTL: state formulae and path formulae. The values of state and path formulae are evaluated for states and paths correspondingly.

If pPp \in P then pp is a state formula that holds in state ss iff (s,p)L(s, p) \in L

If ff is a path formula, then Af\mathrm{\mathbf{A}} f and Ef\mathrm{\mathbf{E}} f are state formulae, where A\mathrm{\mathbf{A}} and E\mathrm{\mathbf{E}} are path quantifiers:

  • Af\mathrm{\mathbf{A}} f holds in a state ss, iff ff holds for each path beginning in the state ss;
  • Ef\mathrm{\mathbf{E}} f holds in state ss, iff there exists a path π\pi, beginning in the state ss, such that ff holds for π\pi.

If ff and gg are state formulae, then Gf\mathrm{\mathbf{G}} f and fUgf \mathrm{\mathbf{U}} g are path formulae, where G\mathrm{\mathbf{G}} and U\mathrm{\mathbf{U}} are temporal operators:

  • Gf\mathrm{\mathbf{G}} f (Globally) holds for a path π=s0s1\pi = s_0 s_1 \ldots iff  for each i0i \ge 0 the formula ff holds in the state sis_i;
  • fUgf \mathrm{\mathbf{U}} g (Until) holds for a path π=s0s1\pi = s_0 s_1 \ldots if there exists i0i \ge 0 such that ff holds for each state in the range s0,s1,,si1s_0, s_1, \ldots, s_{i-1}, and gg holds in state sis_i;

To verify a property described by a state formula ff means to find all states, ff holds for. Verification of an arbitrary property is a pretty complex problem. Your problem is much easier --- you are to write a program that verifies a property described by a temporal logic formula E(xU(AGy))\mathrm{\mathbf{E}} (x \mathrm{\mathbf{U}} (\mathrm{\mathbf{A}} \mathrm{\mathbf{G}} y)), where xx and yy are some atomic propositions.

입력

The first line of the input file contains three positive integer numbers nn, mm and kk --- number of states, transitions and atomic propositions (1n100001 \le n \le 10\,000; 0m1000000 \le m \le 100\,000; 1k261 \le k \le 26).

The following nn lines describe one state each. The state ii (1in1 \le i \le n) is described by cic_i --- a number of atomic propositions which are true for this state and a space-separated list of these atomic propositions (0cik0 \le c_i \le k). Atomic propositions are denoted by first kk small English letters.

Next mm lines describe transitions. Each of them contains two integer numbers ss and tt (1s,tn1 \le s, t \le n; sts \ne t) --- the transition from state ss to state tt. The verified Kripke model contains implicit loop transitions (s,s)(s, s) for each state ss (they are not listed in the input file). No transition is listed in the input file twice.

The last line of the input file contains the formula of the property to be verified. This formula always has the form E(xU(AGy)), where x and y are some atomic propositions.

출력

The first line of the output file must contain the number of states for which the verified property holds. The following lines must contain the numbers of these states listed in increasing order.

예제

예제 1

입력
7 8 2
1 a
1 a
2 a b
1 b
1 b
1 a
1 a
1 2
2 3
3 4
4 5
5 3
2 6
6 7
7 6
E(aU(AGb))
출력
5
1
2
3
4
5
코드를 제출하려면 로그인하세요.