在“解释语言的语言”中提到,设计一个新的语言,仅仅是使用meta-language给出其描述是不够的,我们还需要去验证一些性质。
    考虑一下我们在“解释语言的语言中”给出的求值关系\(r\) ,对于表达式\(( f . ( t . f ) )\), 表达式能够通过求值关系\(\rightarrow_{r}\)得到\((f . (t . f) )\rightarrow_{r}(f . t)\)以及\((f . (t . f) )\rightarrow_{r}(t . f)\),但是我们的关注点在于通过求值关系\(\rightarrow_{r}\)得到的不同表达式的最终结果是否相同。这上面的例子中\((t . f)\)与\((f . t)\)最终都会规约到\(t\),但是单个例子显然没有说服力。这需要证明求值的一致性(Consistency of Evaluation)。
    回忆一下在上一节提到的不同扩展范围的求值关系:

name definition intution
\(-\) the base relation on members of an expression grammar a single "reduction" step with no context
\(\rightarrow_{-}\) the compatible clojure of - with respect to expression grammar a single step within context
\(\twoheadrightarrow_{-}\) the reflexive-transitive clojure of \(\rightarrow_{-}\) multiple evaluation steps (zero or more)
\(=_{-}\) the symmetric-transitive clojure of \(\twoheadrightarrow_{-}\) equate expression that produce the same result
\(eval_{-}\) \(=_{-}\)restricted to a range of results complete evaluation

    接下来在这里先给出3个定理

Theorem 1: \(eval_r(B_0)=R_1\) and \(eval_r(B_1)=R_2\), then \(R_1=R_2\)
Theorem 2(Church-Rosser Theorem ): If \(M=_{r}N\) , there exists expression \(L\) such that \(M \twoheadrightarrow_{r} L\) and \(N \twoheadrightarrow_{r} L\)
Theorem 3(Diamond property of \(\twoheadrightarrow_{r}\)): If \(L \twoheadrightarrow_{r} M\) and \(L \twoheadrightarrow_{r} N\), then there exists expression \(L'\) such that \(M \twoheadrightarrow_{r} L'\) and \(N \twoheadrightarrow_{r} L'\)

    定理1解释图:

    定理1描述的是一个表达式通过求值函数\(eval_r(B_0)\)得到的值的一致性。

    定理2解释图:

    定理2描述的是两个通过求值关系\(\twoheadrightarrow_{r}\)得到的表达式最终规约结果的一致性。
    证明过程:

Base case: if \(M =_{r} N\), there exists an expression \(L\) such that \(M =_{r} L\) and \(L =_{r} N\)( transitive relation)
- Case \(M \twoheadrightarrow_{r} N\)
Let \(L=N\) , the claim holds
Inductive cases:
- Case \(M =_{r} N\) because \(N =_{r} M\)
By induction, \(L\) exists for \(N =_{r} M\), that is the \(L\) we want
- Case \(M \twoheadrightarrow_{r} N\) because \(M \twoheadrightarrow_{r} L_0\) and \(L_0 \twoheadrightarrow_{r} N\)
By induction, there exists an \(L_1\) such that \(M \twoheadrightarrow_{r} L_1\) and \(L_0 \twoheadrightarrow_{r} L_1\). Also by the induction, there exists an \(L_2\) such that \(N \twoheadrightarrow_{r} L_2\) and \(L_0 \twoheadrightarrow_{r} L_2\)
then by theorem 1 and induction, there exists an \(L_3\) such that \(L_1 \twoheadrightarrow_{r} L_3\) and \(L_2 \twoheadrightarrow_{r} L_3\), the claim holds.

    定理2证明图:

    定理3解释图:

    定理3描述的是一个表达式的不同规约路径,最终规约到一个结果的过程,由于形状是一个四边形(可能中间也会有多个中间表达式\(L_n\)),因此称其为关系\(\twoheadrightarrow_{r}\)的Diamond property。
    基于上述的定理,可以得到基于关系\(\twoheadrightarrow_{r}\)拓展而来的求值关系求值一致性保证。但是在具体的语言描述中,还是需要对我们的语言描述进行验证,但这总是一个好的开始。

参考文献

    [1] Matthias Fellesisen, Matthew Flatt.Programming Languages And Lambda Calculi[M]. Utah:, 2006. 21-24.

殊途同归 - Church-Rosser and Consistency of Evaluation的更多相关文章

  1. Understanding about numerical stability, convergence and consistency

    In a computer simulation of the real world, physical quantities, which usually have continuous distr ...

  2. Utility2:Appropriate Evaluation Policy

    UCP收集所有Managed Instance的数据的机制,是通过启用各个Managed Instances上的Collection Set:Utility information(位于Managem ...

  3. SQL SERVER 2012 从Enterprise Evaluation Edtion 升级到 Standard Edtion SP1

    案例背景:公司从意大利购买了一套中控系统,前期我也没有参与其中(包括安装.实施都是第三方),直到最近项目负责人告诉我:前期谈判以为是数据库的License费用包含在合同中,现在经过确认SQL Serv ...

  4. mysql Statement violates GTID consistency 的坑

    今天项目迁移,重新换了一个数据库版本,然后问题来了,原本运行正常的程序迁移过来之后就是不能正常运行,后台报错如下: update tbl_user_info set -- 强制下架 mv_count ...

  5. cassandra-replication_factor 和 consistency level

    参考 replication_factor 决定了数据会被写到多少个节点.为2表示要写到两个节点. consistency level决定客户端要等待多少个节点被写成功.为1表示只要第一个节点被写成功 ...

  6. Evaluation Clustering methods

    There are many evaluation measures available like entropy, recall, precision, F-measure, silhouette ...

  7. PLT:说说Evaluation strategy

    Brief 在学习方法/函数时,我们总会接触到 按值传值 和 引用传值 两个概念.像C#是按值传值,但参数列表添加了ref/out后则是引用传值,但奇怪的事出现了 namespace Foo{ cla ...

  8. PyMySQL Evaluation

    PyMySQL Evaluation This page will capture issues related to Openstack moving to the PyMySQL driver f ...

  9. 分配给 主机的 Evaluation Mode 许可证已过期。建议升级许可证。

    参考文献 http://247its.wordpress.com/2012/04/02/new-build-esxi-5-complaints-licence-has-expired/ http:// ...

随机推荐

  1. python 函数enumerate(x,y)的用法

    enumerate(x,y)函数是把元组tuple.字符串str.列表list里面的元素遍历和索引组合,其用法与range()函数很相似, 下面示例enumerate(x,y)用法以及range(x) ...

  2. centos7设置静态IP地址

    1.查看IP配置信息 ifconfig 如上图所示,我的em1网卡已配置好 2.编辑em1对应的配置文件,位于/etc/sysconfig/network-scripts/ifcfg-你的网卡名字 操 ...

  3. Ajax原理以及优缺点

    ajax原理和XmlHttpRequest对象 Ajax的原理简单来说通过XmlHttpRequest对象来向服务器发异步请求,从服务器获得数据,然后用javascript来操作DOM而更新页面.这其 ...

  4. Get Random number

    , int pMaxVal = int.MaxValue) { int m = pMaxVal - pMinVal; int rnd = int.MinValue; decimal _base = ( ...

  5. 剑指offer-扑克牌顺子

    题目描述 LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决 ...

  6. 虚拟机上不了网的 VMware Workstation 与 Device/Credential Guard 不兼容

    VMware Workstation 与 Device/Credential Guard 不兼容   和    虚拟机上不了网的问题  解决方法: VMware Workstation 与 Devic ...

  7. 【转】Java遍历Map对象的四种方式

    关于java中遍历map具体哪四种方式,请看下文详解吧. 方式一 这是最常见的并且在大多数情况下也是最可取的遍历方式.在键值都需要时使用. Map<Integer, Integer> ma ...

  8. Java 基础 多线程进阶(锁,线程安全)

    一,前言 前面我们已经对线程和线程池有一定的了解,但是只要说到多线程,肯定需要考虑线程安全等问题.接下来我们就来好好聊聊这些问题. 二,线程安全 如果有多个线程在同时运行,而这些线程可能会同时运行这段 ...

  9. 清除eclipse项目中没用的图片、js、css代码

    import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOExce ...

  10. cocos creator使用anysdk接入admob广告教程

    http://lolling787.lofter.com/post/1f5b6553_12925042 cocos creator使用anysdk接入admob广告