← Documents Documentation/trace/rv/linear_temporal_logic.rst GitHub 원문 ↗

Linux 6.18.37 · Tracing

선형 시간 논리

Linux RV에서 사용하는 선형 시간 논리의 문법, 시간 연산자, 명세 예제, rvgen을 통한 Buchi automaton C monitor 합성을 설명합니다.

Source pathDocumentation/trace/rv/linear_temporal_logic.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

linear_temporal_logic.rst:1-134

Linux RV에서 사용하는 선형 시간 논리의 문법, 시간 연산자, 명세 예제, rvgen을 통한 Buchi automaton C monitor 합성을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 Linear temporal logic
2 =====================
3
4 Introduction
5 ------------
6
7 Runtime verification monitor is a verification technique which checks that the
8 kernel follows a specification. It does so by using tracepoints to monitor the
9 kernel's execution trace, and verifying that the execution trace sastifies the
10 specification.
11
12 Initially, the specification can only be written in the form of deterministic
13 automaton (DA). However, while attempting to implement DA monitors for some
14 complex specifications, deterministic automaton is found to be inappropriate as
15 the specification language. The automaton is complicated, hard to understand,
16 and error-prone.
17
18 Thus, RV monitors based on linear temporal logic (LTL) are introduced. This type
19 of monitor uses LTL as specification instead of DA. For some cases, writing the
20 specification as LTL is more concise and intuitive.
21
22 Many materials explain LTL in details. One book is::
23
24 Christel Baier and Joost-Pieter Katoen: Principles of Model Checking, The MIT
25 Press, 2008.
26
27 Grammar
28 -------
29
30 Unlike some existing syntax, kernel's implementation of LTL is more verbose.
31 This is motivated by considering that the people who read the LTL specifications
32 may not be well-versed in LTL.
33
34 Grammar:
35 ltl ::= opd | ( ltl ) | ltl binop ltl | unop ltl
36
37 Operands (opd):
38 true, false, user-defined names consisting of upper-case characters, digits,
39 and underscore.
40
41 Unary Operators (unop):
42 always
43 eventually
44 next
45 not
46
47 Binary Operators (binop):
48 until
49 and
50 or
51 imply
52 equivalent
53
54 This grammar is ambiguous: operator precedence is not defined. Parentheses must
55 be used.
56
57 Example linear temporal logic
58 -----------------------------
59 .. code-block::
60
61 RAIN imply (GO_OUTSIDE imply HAVE_UMBRELLA)
62
63 means: if it is raining, going outside means having an umbrella.
64
65 .. code-block::
66
67 RAIN imply (WET until not RAIN)
68
69 means: if it is raining, it is going to be wet until the rain stops.
70
71 .. code-block::
72
73 RAIN imply eventually not RAIN
74
75 means: if it is raining, rain will eventually stop.
76
77 The above examples are referring to the current time instance only. For kernel
78 verification, the `always` operator is usually desirable, to specify that
79 something is always true at the present and for all future. For example::
80
81 always (RAIN imply eventually not RAIN)
82
83 means: *all* rain eventually stops.
84
85 In the above examples, `RAIN`, `GO_OUTSIDE`, `HAVE_UMBRELLA` and `WET` are the
86 "atomic propositions".
87
88 Monitor synthesis
89 -----------------
90
91 To synthesize an LTL into a kernel monitor, the `rvgen` tool can be used:
92 `tools/verification/rvgen`. The specification needs to be provided as a file,
93 and it must have a "RULE = LTL" assignment. For example::
94
95 RULE = always (ACQUIRE imply ((not KILLED and not CRASHED) until RELEASE))
96
97 which says: if `ACQUIRE`, then `RELEASE` must happen before `KILLED` or
98 `CRASHED`.
99
100 The LTL can be broken down using sub-expressions. The above is equivalent to:
101
102 .. code-block::
103
104 RULE = always (ACQUIRE imply (ALIVE until RELEASE))
105 ALIVE = not KILLED and not CRASHED
106
107 From this specification, `rvgen` generates the C implementation of a Buchi
108 automaton - a non-deterministic state machine which checks the satisfiability of
109 the LTL. See Documentation/trace/rv/monitor_synthesis.rst for details on using
110 `rvgen`.
111
112 References
113 ----------
114
115 One book covering model checking and linear temporal logic is::
116
117 Christel Baier and Joost-Pieter Katoen: Principles of Model Checking, The MIT
118 Press, 2008.
119
120 For an example of using linear temporal logic in software testing, see::
121
122 Ruijie Meng, Zhen Dong, Jialin Li, Ivan Beschastnikh, and Abhik Roychoudhury.
123 2022. Linear-time temporal logic guided greybox fuzzing. In Proceedings of the
124 44th International Conference on Software Engineering (ICSE '22). Association
125 for Computing Machinery, New York, NY, USA, 1343–1355.
126 https://doi.org/10.1145/3510003.3510082
127
128 The kernel's LTL monitor implementation is based on::
129
130 Gerth, R., Peled, D., Vardi, M.Y., Wolper, P. (1996). Simple On-the-fly
131 Automatic Verification of Linear Temporal Logic. In: Dembiński, P., Średniawa,
132 M. (eds) Protocol Specification, Testing and Verification XV. PSTV 1995. IFIP
133 Advances in Information and Communication Technology. Springer, Boston, MA.
134 https://doi.org/10.1007/978-0-387-34892-6_1
135

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

소개

1-26

런타임 검증 모니터는 커널이 명세를 따르는지 확인하는 검증 기법이다. tracepoint로 커널의 실행 trace를 감시하고, 그 실행 trace가 명세를 만족하는지 검사한다.

처음에는 명세를 결정적 오토마톤(DA) 형식으로만 작성할 수 있었다. 그러나 복잡한 명세의 DA monitor를 구현하는 과정에서 결정적 오토마톤은 명세 언어로 부적합한 경우가 드러났다. 오토마톤이 복잡하고 이해하기 어려우며 오류가 생기기 쉽기 때문이다.

이에 선형 시간 논리(LTL)에 기반한 RV monitor가 도입되었다. 이 유형은 DA 대신 LTL을 명세로 사용하며, 일부 경우에는 LTL 명세가 더 간결하고 직관적이다.

LTL을 자세히 설명하는 자료는 많다. 여기서는 Christel Baier와 Joost-Pieter Katoen의 `Principles of Model Checking`, The MIT Press, 2008을 참고 문헌으로 제시한다.

RV 명세 표현의 확장
kernel execution tracetracepoint로 관찰
LTL specification실행 trace가 명세를 만족하는지 검사
RV monitor위반 여부 보고

복잡한 결정적 오토마톤을 직접 작성하는 부담을 줄이기 위해 LTL 명세와 자동 합성 경로를 사용한다.

Linear temporal logic
=====================

Introduction
------------

Runtime verification monitor is a verification technique which checks that the
kernel follows a specification. It does so by using tracepoints to monitor the
kernel's execution trace, and verifying that the execution trace sastifies the
specification.

Initially, the specification can only be written in the form of deterministic
automaton (DA).  However, while attempting to implement DA monitors for some
complex specifications, deterministic automaton is found to be inappropriate as
the specification language. The automaton is complicated, hard to understand,
and error-prone.

Thus, RV monitors based on linear temporal logic (LTL) are introduced. This type
of monitor uses LTL as specification instead of DA. For some cases, writing the
specification as LTL is more concise and intuitive.

Many materials explain LTL in details. One book is::

  Christel Baier and Joost-Pieter Katoen: Principles of Model Checking, The MIT
  Press, 2008.

문법

27-56

커널의 LTL 구현 문법은 일부 기존 표기보다 장황하다. LTL에 익숙하지 않은 사람도 명세를 읽을 수 있도록 의도적으로 명시적인 단어를 사용한다.

ltl ::= opd | ( ltl ) | ltl binop ltl | unop ltl
LTL 문법 요소
분류허용 값
피연산자 `opd``true`, `false`, 대문자·숫자·밑줄로 이루어진 사용자 정의 이름
단항 `unop``always`, `eventually`, `next`, `not`
이항 `binop``until`, `and`, `or`, `imply`, `equivalent`

피연산자와 단항 및 이항 연산자를 원문의 철자 그대로 정리한다.

이 문법에는 연산자 우선순위가 정의되어 있지 않아 모호하다. 따라서 의도한 결합 순서를 반드시 괄호로 표시해야 한다.

Grammar
-------

Unlike some existing syntax, kernel's implementation of LTL is more verbose.
This is motivated by considering that the people who read the LTL specifications
may not be well-versed in LTL.

Grammar:
    ltl ::= opd | ( ltl ) | ltl binop ltl | unop ltl

Operands (opd):
    true, false, user-defined names consisting of upper-case characters, digits,
    and underscore.

Unary Operators (unop):
    always
    eventually
    next
    not

Binary Operators (binop):
    until
    and
    or
    imply
    equivalent

This grammar is ambiguous: operator precedence is not defined. Parentheses must
be used.

선형 시간 논리 예

57-87
RAIN imply (GO_OUTSIDE imply HAVE_UMBRELLA)

비가 온다면, 밖에 나간다는 것은 우산을 가지고 있음을 뜻한다.

RAIN imply (WET until not RAIN)

비가 온다면, 비가 멎을 때까지 젖은 상태가 이어진다는 뜻이다.

RAIN imply eventually not RAIN

비가 온다면 언젠가는 비가 멎는다는 뜻이다.

위 세 예는 현재 시점만 가리킨다. 커널 검증에서는 어떤 성질이 현재와 모든 미래에 항상 참임을 지정하는 `always` 연산자가 대체로 필요하다.

always (RAIN imply eventually not RAIN)

이 식은 모든 비가 결국 멎는다는 뜻이다. 예에서 `RAIN`, `GO_OUTSIDE`, `HAVE_UMBRELLA`, `WET`은 원자 명제(atomic proposition)이다.

예제의 시간 의미
의미
`RAIN imply ...`현재 시점의 비에 대한 조건
`eventually not RAIN`미래의 어느 시점에는 비가 오지 않음
`always (RAIN imply ...)`현재와 모든 미래 시점의 비에 조건 적용

같은 원자 명제도 시간 연산자를 어떻게 감싸는지에 따라 적용 범위가 달라진다.

Example linear temporal logic
-----------------------------
.. code-block::

   RAIN imply (GO_OUTSIDE imply HAVE_UMBRELLA)

means: if it is raining, going outside means having an umbrella.

.. code-block::

   RAIN imply (WET until not RAIN)

means: if it is raining, it is going to be wet until the rain stops.

.. code-block::

   RAIN imply eventually not RAIN

means: if it is raining, rain will eventually stop.

The above examples are referring to the current time instance only. For kernel
verification, the `always` operator is usually desirable, to specify that
something is always true at the present and for all future. For example::

    always (RAIN imply eventually not RAIN)

means: *all* rain eventually stops.

In the above examples, `RAIN`, `GO_OUTSIDE`, `HAVE_UMBRELLA` and `WET` are the
"atomic propositions".

모니터 합성

88-111

LTL을 커널 monitor로 합성하려면 `tools/verification/rvgen`의 `rvgen` 도구를 사용한다. 명세를 파일로 제공하고 `RULE = LTL` 대입문을 포함해야 한다.

RULE = always (ACQUIRE imply ((not KILLED and not CRASHED) until RELEASE))

이 규칙은 `ACQUIRE`가 발생했다면 `KILLED` 또는 `CRASHED`보다 먼저 `RELEASE`가 발생해야 한다는 뜻이다.

LTL은 하위 표현식으로 나눌 수 있다. 다음 두 줄은 위 규칙과 동등하다.

RULE = always (ACQUIRE imply (ALIVE until RELEASE))
ALIVE = not KILLED and not CRASHED

이 명세에서 `rvgen`은 LTL의 만족 가능성을 검사하는 비결정적 상태 기계인 Buchi automaton의 C 구현을 생성한다. 사용법은 `Documentation/trace/rv/monitor_synthesis.rst`를 참고한다.

LTL monitor 합성 경로
RULE = LTLrvgen parser
원자 명제와 하위 표현식Buchi automaton 구성
C implementationkernel RV monitor

명세 파일에서 하위 표현식을 해석하고 Buchi automaton의 C 구현을 생성한다.

Monitor synthesis
-----------------

To synthesize an LTL into a kernel monitor, the `rvgen` tool can be used:
`tools/verification/rvgen`. The specification needs to be provided as a file,
and it must have a "RULE = LTL" assignment. For example::

    RULE = always (ACQUIRE imply ((not KILLED and not CRASHED) until RELEASE))

which says: if `ACQUIRE`, then `RELEASE` must happen before `KILLED` or
`CRASHED`.

The LTL can be broken down using sub-expressions. The above is equivalent to:

   .. code-block::

    RULE = always (ACQUIRE imply (ALIVE until RELEASE))
    ALIVE = not KILLED and not CRASHED

From this specification, `rvgen` generates the C implementation of a Buchi
automaton - a non-deterministic state machine which checks the satisfiability of
the LTL. See Documentation/trace/rv/monitor_synthesis.rst for details on using
`rvgen`.

참고 문헌

112-134

모델 검사와 선형 시간 논리의 개론서로 Baier와 Katoen의 `Principles of Model Checking`을 제시한다.

소프트웨어 시험에 LTL을 적용한 사례로 Meng 외 저자의 2022년 ICSE 논문 `Linear-time temporal logic guided greybox fuzzing`과 DOI `10.1145/3510003.3510082`를 제시한다.

커널 LTL monitor 구현은 Gerth, Peled, Vardi, Wolper의 1996년 논문 `Simple On-the-fly Automatic Verification of Linear Temporal Logic`에 기반하며 DOI는 `10.1007/978-0-387-34892-6_1`이다.

References
----------

One book covering model checking and linear temporal logic is::

  Christel Baier and Joost-Pieter Katoen: Principles of Model Checking, The MIT
  Press, 2008.

For an example of using linear temporal logic in software testing, see::

  Ruijie Meng, Zhen Dong, Jialin Li, Ivan Beschastnikh, and Abhik Roychoudhury.
  2022. Linear-time temporal logic guided greybox fuzzing. In Proceedings of the
  44th International Conference on Software Engineering (ICSE '22).  Association
  for Computing Machinery, New York, NY, USA, 1343–1355.
  https://doi.org/10.1145/3510003.3510082

The kernel's LTL monitor implementation is based on::

  Gerth, R., Peled, D., Vardi, M.Y., Wolper, P. (1996). Simple On-the-fly
  Automatic Verification of Linear Temporal Logic. In: Dembiński, P., Średniawa,
  M. (eds) Protocol Specification, Testing and Verification XV. PSTV 1995. IFIP
  Advances in Information and Communication Technology. Springer, Boston, MA.
  https://doi.org/10.1007/978-0-387-34892-6_1