马尔可夫算法

马尔可夫算法是使用类似形式文法的规则在符号上操作的字符串重写系统马尔可夫算法被证明是图灵完全的,这意味着它们适合作为一般的计算模型,并可以用它的简单概念表示任何数学表达式

Refal是基于马尔可夫算法的编程语言

算法

  1. 自顶向下依次检查规则,看是否能在符号串中找到任何在箭头左边的字符串。
  2. 如果没有找到,停止执行算法。
  3. 如果找到一个或多个,把符号串中的最左匹配的文字替换为在第一个相应规则的箭头右边的字符串。
  4. 返回步骤1并继续。(如果应用的规则是终止规则,则停止执行算法。)

例子

下列例子展示了马尔可夫算法的基本操作。

规则

  1. "A" -> "apple"
  2. "B" -> "bag"
  3. "S" -> "shop"
  4. "T" -> "the"
  5. "the shop" -> "my brother"
  6. "从不使用的" -> ."终止规则"

符号串

"I bought a B of As from T S."

执行

如果算法应用于上述例子,符号串将被以如下方式变更。

  1. "I bought a B of apples from T S."
  2. "I bought a bag of apples from T S."
  3. "I bought a bag of apples from T shop."
  4. "I bought a bag of apples from the shop."
  5. "I bought a bag of apples from my brother."

算法接着就终止了。

引用

  • Caracciolo di Forino, A. String processing languages and generalized Markov algorithms. In Symbol manipulation languages and techniques, D. G. Bobrow (Ed.), North-Holland Publ. Co., Amsterdam, The Netherlands, 1968, pp. 191-206.
  • Andrey Andreevich Markov (1903-1979) 1960. The Theory of Algorithms. American Mathematical Society Translations, series 2, 15, 1-14.

外部链接