fundamentals\RelationsFunctionsAndStateMachines

Relations Functions And State Machines

目录

Relations Functions And State Machines

Relations

Cartesian:笛卡儿积

Functions

Finite State Machines:有限状态机

Language:Strings:字符串的数学定义

Finit State Machine:有限状态机-干货有翻译哦


Relations

 

Cartesian:笛卡儿积

An Ordered pair (a, b) is a Set \{ \{ a \}, \{ a, b \} \}

笛卡尔积
图:笛卡尔积

For sets A, B the Cartesian product, or cross product, of A and B is denoted by AXB and equals {(a, b) | a∈A, b∈B}.

Not closed

Their tie-in with Cartesian products.

For sets A, B, any subset of AXB is called a (binary) relation R from A to B. Any subset of AXA is called a (binary) relation on A.

如果  (a, b) \in R,写作 aRb。读作 “a与b有关”,这也意味着可能存在 R(x, y) 的函数,或者在逻辑上写做 R_x_y

For finite sets A, B with |A|=m and |B|=n, there are 2mn relations from A to B, including the empty relation as well as the relation AXB itself…….

A X (B∩C) = (AXB) ∩ (AXC)

A X (B∪C) = (AXB) ∪ (AXC)

(A∩B) X C = (AXC) ∩ (BXC)

(A∪B) X C = (AXC) ∪ (BXC)

A relation R on a set A is called reflexive if for all x∈A, (x, x)∈R.

x \in A \: , \: \forall x R(x,x)                                            

reflexive(对称的,不变的——就像空间)​​​​​

栗如:R(x, y) 表示 x = y

x \in \mathbb{Z} \: , \: \forall x R(x,x) 

任意一个整数 = 它自身

Relation R on set A is called symmetric if (x, y)∈R => (y, x)∈R, for all x, y∈A.

\forall x \forall y, xRy \rightarrow yRx

symmetric相互的,方向性——就像力的作用师相互的)​​​​

栗如:R(x, y) 表示 x \neq y

xRy \rightarrow yRx

如果 x \neq y 那么 y \neq x

For a set A, a relation R on A is called transitive if, for all x, y, z∈A, (x, y), (y, z)∈R =>(x, z)∈R.(So if x is related to y, and y is related to z, we want x related to z, with y playing the role of intermediary).

\forall x \forall y \forall z, xRy \wedge yRz \rightarrow xRz 

transitive ( 累积的,演进的——就像时间)

栗如:R(x, y) 表示 x < y

xRy \wedge yRz \rightarrow xRz

如果 x < yy < z 那么 y < z

如果一个(关系)运算同时具备 reflexive、symmetric、transitive 我们称之为 等价(Equivalence Class)

a == b == c

 [x] = \{y | xRy\}

反对称(Antisymmetry)

 Antisymmetry: If two objects are both related to each other, they are the same object. (aRb \wedge bRa) \rightarrow a = b

栗如 x \leq y 并且 y \leq x 那么 x = y

偏序(Partial Orders) x \leq y

  • Antisymmetry
  • Reflexive
  • Transitive

串?(Alphabetical Order)a \leq b \leq c

栗如: 哈斯图(Hasse diagram): A=\{ 1, 2, 3, 4\} 当 x | y 时 xRy

图:哈斯图中元素的关系
图:哈斯图

全序关系:(total order): A=\{ 1, 2, 4, 8\} 当 x | y 时 xRy

图:全序关系

全序关系有最小值,最大值 

证明如果 R 是 symmetric、transitive 的,那么 R 一定是 reflexive

symmetric: xRy \rightarrow yRx

transitive: xRy \wedge yRz \rightarrow xRz

假设:xRy

\begin{matrix} \\ Assume \: \:\: \: \: \: xRy \\ Then \: \:\: \: \: \: \: \: \: \: yRx \\ inference \: xRx \end{matrix} 

证明: A \times (B -C) = (A \times B) - (A \times C)

let  (x, y) \in A \times (B -C)

then x \in A and y \in (B - C)

x \in A and y \in B and y \notin C

(x \in A and y \in B) and (x \in A and y \notin C)

(x, y) \in A \times B and (x, y) \notin A \times C

(x, y) \in (A \times B) - (A \times C)

……

Functions

a special kind of relation called a function.

For nonempty sets A, B, a function, or mapping, f from A to B, denoted : f: A->B, is a relation from A to B in which every element of A appears exactly once as the first component of an ordered pair in the relation.

b is called the image of a under f, whereas a is a preimage of b.

图:函数

 f(x) = x^2 与 y = x^2 前者叫做函数,后者叫做表达式。之前我一直搞不懂函数与表达式的区别?

  • y = x^2 表示 x 的表达式,元素之间的关联 \{x, x^2\}  栗如 \{ 2, 4 \};y 是一个值;
  • f(x) = x^2 表示 X \rightarrow Y 的运算,笛卡儿积 \{ \{ x \}, \{ x, y \} \} ;y 参与运算;

函数是一种关系,同时研究 x 和 y;举个栗子:

  • 你从 n 个不同小球中取出 m 个,排成一列,这是运算;
  • 你把 n 个不同小球 放到 m 个箱子 里头,这,就是函数了;
    • 也就是说,我们可以有 108 个箱子(codomain),但是不是所有的箱子里头都必须有小球(range)!

公理逻辑之过滤定理(axiomatic logic filtration theorem):这不就是,我们常用到的过滤器????

f(x) = \left\{\begin{matrix} 1, x \in A \\ 0, x \notin A \end{matrix}\right.

相当于一个真值表

Characteristic Function 过滤器  P(x)
P(x)x
11
02
13
04
…………

A function f: A->B is called one-to-one, or injective, if each element of B appears at most once as the image of an element of A.

……By the rule of product, the number of one-to-one functions from A to B is n(n-1)(n-2)…(n-m+1)=P(n,m)=P(|B|, |A|).

If f: A->B and A1⊆A, then f(A1) = {b∈B | b=f(a), for some a∈A1}, and f(A1) is called the image of A1 under f.(表?table?)

Composite Functions:

图:复合函数

injective(one - to - one): If x_1 \neq x_2 then f(x_1) \neq f(x_2)  这不就是,DI 中的 I ,表示注入的单词,注入有单射的意思???

图:单射

证明 f:R \rightarrow R 且 f(x) = e^x 是单射:

假设:f(x) = f(y) \Leftrightarrow e^x = e^y \Rightarrow lne^x = lne^y \Rightarrow x = y 

f(x_1 \cap x_2) \subseteq f(x_1) \cap f(x_2)

f 为单射时 f(x_1 \cap x_2) = f(x_1) \cap f(x_2)  概率论上的独立?

……

 

Finite State Machines:有限状态机

It must have the ability to remember past information as it works on the information it is currently processing.

As the name indicates, a finite state machine has a finite number of internal states where the machine remembers certain information when it is in a particular state.

Language:Strings:字符串的数学定义

We use ∑ to denote a nonempty finite set of symbols, collectively called an alphabet.

If ∑ is an alphabet and n∈Z+, we define the powers of recursively as follows;( ∑的幂)

  1. ∑1=∑; and
  2. ∑n+1={xy | x∈∑, y∈∑n}, where xy denotes the juxtaposition of x and y.

For an alphabetwe define ∑0={λ}, where λ denotes the empty string—that is, the string consisting of no symbols taken from ∑.

If w1,w2∈∑+, then we may write w1=x1x2……xm and w2=y1y2……yn, for m, n∈Z+, and x1x2……xm, y1y2……yn∈∑. We say that the strings w1 and w2 are equal, and we write w1=w2, if m=n, and xi=yi for all 1<= I <= m.

Let w= x1x2……xn∈∑+, where xi∈∑ for each 1<= I <= n. We define the length of w, which is denoted by ||w||, as the value n. For the case of λ, we have ||λ|| = 0.

Let x, y∈∑+ with x = x1x2……xm and y = y1y2……yn, so that each xi, for 1 <= I <= m, and each yj, for 1 <= j <= n, is in ∑. Then concatenation of x and y, which we write as xy, is the string x1x2……xmy1y2……yn.

For each x∈∑*, we define the powers of x by x0=λ, x1=x, x2=xx, x3=xx2,……, xn+1=xxn,……, where n∈N.

If x,y∈∑* and w=xy, then the string x is called a prefix of w, and yλ, then x is said to be a proper prefix. Similarly, the string y is called a suffix of w; it is a proper suffix when xλ.

If x,y,z∈∑* and w = xyz, then y is called a substring of w. When at least one of x and z is different from λ( so that y is different from w), we call y a proper substring.
For a given alphabet ∑, any subset of ∑* is called a language over ∑. This includes the subset {}, which we call the empty language.

For an alphabet ∑ and languages A, B ⊆∑*, the concatenation of A and B, denoted AB, is {ab | a∈A, b∈B}.(级联)

For a given language A⊆∑* we can construct other languages as follows: (略,反正没看懂).

Finit State Machine:有限状态机-干货有翻译哦

Mary Jo gose to the vending machine, inserts two nickels and a dime, in that order, and presses the white button, denoted W. Out comes her package of peppermint-flavored chewing gum.

What Mary Jo has done, in making her purchase, can be represented as shown in Table 6.1, where t0 is the initial time, when she inserts her first nickel, and t1,t2,t3,t4 are later moments in time, with t1 < t2 < t3 < t4.

 

t0

t1

t2

t3

t4

State

s0

(4) s1(5$)

(7) s2(10$)

(10) s3(20$)

(13) s0

Input

5$

(5) 5$

(8) 10$

(11) W

 

Output

Nothing

(6) Nothing

(9) Nothing

(12) P

 

For each input at time ti, 0 <= I <= 3, there is at that time a corresponding output and then a change in state. The new state at time ti+1 depends on both the input and the (present) state at time ti

 

翻译:Mary Jo找到自动售货机,按顺序放入两个5分硬币和一角硬币,然后按下白色按钮,表示为W.自动售货机吐出,她的一包薄荷味口香糖。Mary Jo在购买时所做的,如下表中所示,t0是初始时间,当她插入第一个硬币时,t1t2t3t4是后来的时刻,t1 < t2 < t3 < t4

 

t0

t1

t2

t3

t4

State

s0

(4) s1(5$)

(7) s2(10$)

(10) s3(20$)

(13) s0

Input

5$

(5) 5$

(8) 10$

(11) W

 

Output

Nothing

(6) Nothing

(9) Nothing

(12) P

 

对于时间ti的每一个输入(Input),0<=i<=3,在那个时候有一个相应的输出(Output),然后是状态的变化。时间ti+1的新状态依赖于输入(Input)和(现在)状态(s)

 

The major features of such a machine are as follows:

  1. The machine can be in only one of finitely many states at a given time. These states are called the internal states of the machine, and at a given time the total memory available to the machine is the knowledge of which internal state it is in at that moment.
  2. The machine will accept as input only a finite number of symbols, which collectively are referred to as the input alphabet φ . In the vending machine example, the input alphabet is {nickel, dime, quarter, W, B}, each item of which is recognized by each internal state.
  3. An output and a next state are determined by each combination of inputs and internal states. The finite set of all possible outputs constitutes the output alphabet Ο/omikro:n/ for the machine.
  4. We assume that the sequential processings of the machine are synchronized by separate and distinct clock pulses and that the machine operates in a deterministic manner, where the output is completely determined by the total input provided and the starting state of the machine.

 

翻译:这台状态机的主要特点如下:

  1. 在给定的时间内,这台机器只能处于有限的几个状态中的某一个状态。这些状态被称为机器的内部状态,机器的所有运行时参数与可用的描述信息都只能来自于,它当前所处的内部状态
  2. 这台机器只接受有限数量的符号,这些符号统称为输入{字符集} φ 读作:/phi:/。在自动售货机的例子中,输入字母表是{5分硬币、1角硬币、20分硬币、W味口香糖、B薄荷味口香糖},每个元素,都能被内部状态所识别。
  3. 机器的输出和机器的下一个状态是由 输入和 内部状态的组合决定的。所有可能输出的有限集合构成了机器的输出 {字符集}Ο 读作:/omikro:n/
  4. 我们假设机器的连续运转过程是由独立synchronized的、在多线程下由不同的时钟脉冲保持线程的同步性,并且机器以一种确定的方式运行,输出完全由所提供的总输入和机器的启动状态决定。也就是说引入了状态机后,需要自己解决并发 以及事物带来的问题,状态机本身不处理事务及并发咯)。

A finite state machine is a five-tuple M=(S, φ, Ο, v, w), where S = the set of internal states for M; φ = the input alphabet for M; Ο = the output alphabet for M; v: S X φ -> S is the next state function; and w : S X φ –> Ο is the output function.

 

翻译:有限状态机是一个五元组的机器 M=SφΟvw),其中S 表示M的内部状态集; φ 表示M的输入字符集 ; Ο 表示 M的输出字符集; v 表示S X φ -> S是下一个状态函数,状态变迁函数,接受上一个状态S和本次输入φ 作为参数;w 表示S X φ –> Ο,是输出函数,接受上一个状态S和本次输入φ 作为参数。

 

The state table or transition table for the given machine:

 

v

w

0

1

0

1

s0

s0

s1

0

0

s1

s2

s1

0

0

s2

s0

s1

0

1

To calculate v(s1, 1) for example, we find s1 in the column of present states and proceed horizontally over form s1 until we are below the entry 1 in the section of the table for v. This entry give v(s1, 1) = s1. In the same way we find w(s1, 1) = 0.

 

翻译:状态机的trainsition table

假如需要计算v(s1, 1)我们在当前状态的列中找到s1,并水平地在行s1中查找(第四行),直到我们在v的表格的1的部分(第三列)。我们得到v(s1, 1) = s1s1状态下输入1的下一个状态是s1。同理我们得到w(s1, 1) = 0 s1状态下输入1状态机输出结果0

 

除了前面的table,上文的trainsition table,我们还有状态机的另外一种表示叫state table。(也是我们最常见的)

图片来自百度,如有侵权,请联系博主删除
图片来自百度,如有侵权,请联系博主删除

那么这种stateTable 怎么看捏?

In such a diagram each internal state s is represented by a circle with s inside of it. For states si and sj, if v(si, x) = sj for x∈φ, and w(si, x) = y for y∈Ο, we represent this in the state diagram by drawing a directed edge (or arc) from the circle for si to the circle for sj and labeling the arc with the input x and output y as shown if Fig.

 

翻译:在这样的图中,每个内部状态都由一个带s的圆表示。比如sisj如果v(si, x) = sj xφ, 并且w(si, x) = y yΟ也就是说s状态下输入x的下一个状态是sj, 状态机输出y我们在状态图中画一个从sisj的有向边(或弧)来表示这个过程,弧的标签上写x,y(输入x和输出y) 如上图所示。

 

其他一下状态机栗子:k-unit delay machines, 3的倍数结尾的状态机栗子:略(状态机state table实在不好画)。

Let M=(S, φ, Ο, v, w) be a finite state machine.

  1. For si, sj∈S, sj is said to be reachable from sj if si= sj or if there is an input string x∈φ+ such that v(si, x) = sj.
  2. A state s∈S is said to be transient if v(s, x) = s for x∈φ* implies x =λ; that is, there is no x∈φ+ with v(s, x) = s.
  3. A state s∈S is called a sink, or sink state, if v(s, x) = s, for all x∈φ+.
  4. *****is called a submachine of M.
  5. A machine is said to be strongly connected if for any states si, sj ∈S, sj is reachable from si.

 

翻译:百度上找不到这样子的图片啊,没办法,只好亲自上阵画了一个,额,如下图所示:

博主亲自照着画的状态机state table(版权没有,我也是照着画的,盗图可耻!)
博主亲自照着画的状态机state table(版权没有,我也是照着画的,盗图可耻!)

 

  1. s3从s0, s1, s2 都是可达的。
  2. s2 是唯一一个transient state 瞬态
  3. s3 是唯一一个 sink state 下沉(进去了就出不来了 ^_^)。
  4. S1 = { s4 , s5 , s6 , s7}是一个 submachine of M 是一个子状态机。
  5. S1 = { s4 , s5 , s6 , s7} strongly connected 强关联, 但是状态机M不是强关联。

 

最后一个问题:最优状态机:

We seek a process for transforming a given machine into one that has no redundant internal states. This process is known as the minimization process, and its development relies on the comcepts of equivalence relation and partition.

 

翻译:我们寻求将给定的机器转换为没有冗余的内部状态的过程。这个过程被称为最小化过程,它的处理过程依赖于等价关系和组合划分部分的知识。

Ok 博主还没有学到等价关系和组合划分,所以捏,这个最小化状态机是怎么个过程您去隔壁找找您呢。

未完待续…………

^………………^

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值