京都大学 情報学研究科 知能情報学専攻 2024年8月実施 専門科目 S-5
Author
itsuitsuki
Description
大学公表の原題
Consider deterministic finite state automata (Q,Σ,δ,q0,F), where Q is a finite set of states, Σ is a finite set of characters, δ:Q×Σ→Q is a transition function, q0∈Q is a start state, and F⊆Q is a set of accept states. Also, ϵ∈Σ∗ denotes the empty string.
Let Σ={0,1,2,…,9}. For w∈Σ∗, n(w) returns an integer number represented by w. For example, n(52)=52 and n(068)=68. For ϵ, we define n(ϵ)=0.
(1) Depict the state transition diagram of a deterministic finite state automaton (∣Q∣≤2) that accepts L1={w∈Σ∗∣n(w)≡0(mod2)}.
(2) Depict the state transition diagram of a deterministic finite state automaton (∣Q∣≤3) that accepts L2={w∈Σ∗∣n(w)≡0(mod3)}.
(3) Show Q,δ, and F of a deterministic finite state automaton that accepts L3={w∈Σ∗∣n(w)≡0(modk)} for any k≥2. You may use mod to describe δ.
(4) Let L4={w∈Σ+∣h(w)=0 or w=0}, where h(w) returns the first character of string w. Show Q,δ, and F of a deterministic finite state automaton that accepts L3∩L4 for any k≥2. You may use mod to describe δ.
题目描述
考虑确定性有限自动机 (Q,Σ,δ,q0,F),其中 Q 是有限状态集,Σ 是有限字符集,δ:Q×Σ→Q 是转移函数,q0∈Q 是初始状态,F⊆Q 是接受状态集;ϵ∈Σ∗ 表示空串。
令 Σ={0,1,2,…,9}。对 w∈Σ∗,n(w) 表示字符串 w 所代表的十进制整数,允许前导零,例如 n(52)=52、n(068)=68,并规定 n(ϵ)=0。
-
画出一个状态数满足 ∣Q∣≤2、接受语言
L1={w∈Σ∗∣n(w)≡0(mod2)}
的确定性有限自动机状态转移图。
-
画出一个状态数满足 ∣Q∣≤3、接受语言
L2={w∈Σ∗∣n(w)≡0(mod3)}
的确定性有限自动机状态转移图。
-
对任意 k≥2,给出接受
L3={w∈Σ∗∣n(w)≡0(modk)}
的确定性有限自动机的 Q,δ,F;描述 δ 时可以使用取模运算。
-
定义
L4={w∈Σ+∣h(w)=0 或 w=0},
其中 h(w) 返回字符串 w 的首字符。对任意 k≥2,给出接受 L3∩L4 的确定性有限自动机的 Q,δ,F;描述 δ 时可以使用取模运算。
Kai
(1)
Use states r0,r1 for the remainder modulo 2. The start state r0 is accepting, including the empty string. Reading an even digit leads to r0 from either state; reading an odd digit leads to r1.

(2)
Use states r0,r1,r2 for the remainder modulo 3, starting and accepting at r0. Since 10≡1(mod3), a digit with remainder d changes state ri to r(i+d)mod3.

The edge labels are A={0,3,6,9}, B={1,4,7}, and C={2,5,8}.
(3)
Let
Q={r0,…,rk−1},q0=r0,F={r0},δ(ri,d)=r(10i+d)modk.
Induction on the number of read digits shows that the current index is n(w)modk, proving the recognized language is L3.
(4)
Add three states s,z,⊥ distinct from all remainder states:
Q={s,z,⊥}∪{r0,…,rk−1},q0=s,F={z,r0}.
Here s is the initial state, z means the complete prefix is the single character 0, and ⊥ is a rejecting sink. Define
δ(s,0)δ(s,d)δ(z,d)δ(⊥,d)δ(ri,d)=z,=rdmodk=⊥=⊥=r(10i+d)modk(d=1,…,9),(d=0,…,9),(d=0,…,9),(d=0,…,9).
The empty word ends at rejecting s, the single zero ends at accepting z, and any longer word starting with zero reaches ⊥. A word starting with a nonzero digit is accepted precisely when its value is divisible by k. Hence the language is L3∩L4.