形式语言与自动机_笔记整理(一)

来源:互联网 发布:nginx configure 编辑:程序博客网 时间:2024/06/10 07:56

  • Outline
  • Preliminary
    • Math Preliminary
      • SET
      • FUNCTIONS
      • RELATIONS
      • GRAPHS
    • PROOF TECHNIQUES
  • Languages
    • String Operations
    • Operations on Languages
  • Finite Automata
    • Deterministic Finite Automata
      • Formal Definition
      • Graph Representation of DFA s
      • Transition Table of DFA s
      • Inductive Definition of Extended
      • Language of DFA
      • Proofs of Set Equivalence
    • Regular Language
  • Nondeterministic Finite Automata
    • Nondeterministic
    • Formal NFA
      • Transition Function of an NFA
      • Language of an NFA
      • Equivalence of DFA s NFA s
      • NFA s With -Transitions
        • Closure of States
        • Language of an -NFA

昨天晚上入睡的时候已经将近三点了,最近两天无所事事却又异常失眠。偶然发现CSDNblog的访问量已经超过了QQ空间,可见两年多自己在CS之路走得要比十多年的社交大道平坦得多呀,决定暂时中断社交平台的互动,以彰显期末复习之志。

回看博客记录的东西,除了冗余可读性差的代码,就是抱大腿的刻骨铭心记忆。回忆这半个学期确实没做什么事情。开学时不知天高地厚选了很多课,上起来才真正觉得力不从心。我以为我可以再强大一点,但是我并没有意识到,很多理论课自学难度稍微大于可以偶尔翘掉课堂然后自学并完成实验的应用课程。

一直清楚地知道自己并不能从完成大作业中获得很大的满足感,短暂的既视成就感不是我想要的,从不玩任何游戏的我以后也绝对不会去做也做不了游戏开发,但是我的心中一直不变的做一个优秀的并且快乐的程序员的梦想没有走远。

昨天晚上看到有人重提“写字台像乌鸦”的梗,又开始了一波感时伤世,你说啊,多愁伤感怎么会是我在这个时候应该想到的事情呢?细数自己应该不剩多少时间去挥霍游浪了,接下来的旅程怎么说都应该是道阻且艰的,怎就有胆量如此放肆任性而不计较呢?

Outline

Part 1
Preliminaries
Mathematical Knowledge
String and Language

Part 2
Finite Automata and Regular Expression
Context Free Grammar and Pushdown Automata
Turing Automata

Part 3 Modeling
Transition System
Petri Net
Timed and Hybrid Automata
Message Sequence Chart

Part 4 Tutorials
Computability
Model Checking
Trustworthy Software

Preliminary

Math Preliminary

SET

Powerset of S = the set of all the subsets of S, P(S), 2^S

FUNCTIONS

Given two sets A and B, a function from A into B
associates with each a in A at most one element b of B.
If A = domain, then f is a total function, otherwise f is a partial function.

f: A -> B is a bijection

  • f is total
  • for all a and a’ in A, a!=a’ implies f(a)!=f(a’)
  • for all b in B, there is a in A with f(a)=b

RELATIONS

A binary relation R over A is a partial order if it is reflexive, transitive, and antisymmetric.

A binary relation R over A is a total order(linear order) if it is a partial order and for all a, b in A, either aRb or bRa.

GRAPHS

  • Walk is a sequence of adjacent edges
  • A path is a walk where no edge is repeated
  • A simple path is a path where no node is repeated
  • A cycle is a walk from a node (base) to itself
  • A simple cycle: only the base node is repeated
  • Given a digraph G = (V, E) and nodes u and v, we say v is reachable from u, or u-reachable, if there is a path from u to v.
  • A tree is a directed graph that has no cycle.

PROOF TECHNIQUES

  • Proof by induction
  • Proof by contradiction

Languages

A language is a set of strings.
String: A sequence of letters/symbols.
Symbols are defined over an alphabet.

String Operations

Concatenation
Reverse
Σ: the set of all possible strings from alphabet Σ.
Σ+: the set of all possible strings from alphabet Σ except λ.

Operations on Languages

  • The usual set operations
  • Complement
  • Reverse
  • Concatenation
  • Star-Closure (Kleene *): L=L0L1L2
  • Positive Closure: L+=L{λ}

Finite Automata

Language of an Automaton: The set of strings accepted by an automaton A is the language of A. Denoted L(A).

Deterministic Finite Automata

Alphabet: An alphabet is any finite set of symbols.
String: A string over an alphabet Σ is a list, each element of which is a member of Σ.
Subtlety: 0 as a string, 0 as a symbol look the same.
A language is a subset of Σ* for some alphabet Σ.

Formal Definition

A formalism for defining languages, consisting of:

  • A finite set of states (Q, typically).
  • An input alphabet (Σ, typically).
  • A transition function (δ, typically).
    • Takes two arguments: a state and an input symbol.
    • δ(q, a) = the state that the DFA goes to when it is in state q and input a is received.
    • *Note:
      • δ is a total function
      • always a next state
      • add a dead state if no transition
  • A start state (q0, in Q, typically).
  • A set of final states (F ⊆ Q, typically).
    • “Final” and “accepting” are synonyms.

Graph Representation of DFA’ s

  • Nodes = states.
  • Arcs represent transition function.
    • Arc from state p to state q labeled by all those input symbols that have transitions from p to q.
  • Arrow labeled “Start” to the start state.
  • Final states indicated by double circles.

Transition Table of DFA’ s

这里写图片描述

Inductive Definition of Extended δ

Induction on length of string.
Basis: δ(q, ε) = q
Induction: δ(q, wa) = δ(δ(q, w), a)
Remember: w is a string; a is an input symbol, by convention.

We don’ t distinguish between the given delta and the extended delta or delta-hat.

Language of DFA

For a DFA A, L(A) is the set of strings labeling paths from the start state to a final state.
L(A) = the set of strings w such that δ(q0, w) is in F.
这里写图片描述

Proofs of Set Equivalence

TODO:
Important trick: Expand the inductive hypothesis to be more detailed than the statement you are trying to prove.

Regular Language

A language L is regular if it is the language accepted by some DFA.
There is a theorem that says the reverse of a regular language is also regular.

Nondeterministic Finite Automata

Nondeterministic

A nondeterministic finite automaton has the ability to be in several states at once.
Transitions from a state on an input symbol can be to any set of states.
Start in one start state.
Accept if any sequence of choices leads to a final state.

Formal NFA

  • A finite set of states, typically Q.
  • An input alphabet, typically Σ.
  • A transition function, typically δ.
  • A start state in Q, typically q0.
  • A set of final states F ⊆ Q.

Transition Function of an NFA

  • δ(q, a) is a set of states.
  • Extend to strings as follows:
    • Basis: δ(q, ε) = {q}
    • Induction: δ(q, wa) = the union over all states p in δ(q, w) of δ(p, a)

Language of an NFA

A string w is accepted by an NFA if δ(q0, w) contains at least one final state.
The language of the NFA is the set of strings it accepts.

Equivalence of DFA’ s, NFA’ s

Subset Construction
TODO:

NFA’ s With ε-Transitions

Closure of States

CL(q) = set of states you can reach from state q following only arcs labeled ε.
Closure of a set of states = union of the closure of each state.

Language of an ε-NFA

TODO:
Language of an ε-NFA is the set of strings w such that δ̂ (q0,w) contains a final state.

原创粉丝点击