項書換え系(3) 合流性 Term Rewriting Systems(3) Confluence 知能ソフトウェア特論

Slides:



Advertisements
Similar presentations
だい六か – クリスマスとお正月 ぶんぽう. て form review ► Group 1 Verbs ► Have two or more ひらがな in the verb stem AND ► The final sound of the verb stem is from the い row.
Advertisements

Humble and Honorific Language By: Word-Master Leo, Mixer of Ill Beats.
て -form - Making て -form from ます -form -. With て -form, You can say... ~てもいいですか? (= May I do…) ~てください。 (= Please do…) ~ています。 (= am/is/are doing…) Connecting.
第 5 章 2 次元モデル Chapter 5 2-dimensional model. Contents 1.2 次元モデル 2-dimensional model 2. 弱形式 Weak form 3.FEM 近似 FEM approximation 4. まとめ Summary.
Essay writing rules for Japanese!!. * First ・ There are two directions you can write. ・よこがき / 横書き (same as we write English) ・たてがき / 縦書き (from right to.
VE 01 え form What is え form? え? You can do that many things with え form?
Coq を使った証明 : まとめ 稲葉.
英語特別講座 疑問文 #1    英語特別講座 2011 疑問文.
The Bar バー.
五段動詞の歌 ごだんどうしのうた.
STEP 2 ノート・テイキングのサンプル.
第1回レポートの課題 6月15日出題 今回の課題は1問のみ 第2回レポートと併せて本科目の単位を認定 第2回は7月に出題予定
Chapter 11 Queues 行列.
2010年7月9日 統計数理研究所 オープンハウス 確率モデル推定パラメータ値を用いた市場木材価格の期間構造変化の探求 Searching for Structural Change in Market-Based Log Price with Regard to the Estimated Parameters.
Chris Burgess (1号館1308研究室、内線164)
What did you do, mate? Plain-Past
プログラムの正当性(2) 正当性証明の基本原理
英語特別講座 代名詞・前置詞・形容詞・助動詞 #1   
日本人の英語文章の中で「ENJOY」はどういうふうに使われているのか
Noun の 間(に) + Adjective Verb てform + いる間(に) during/while.
Ch13-1 TB250 てフォーム.
There are 5 wearing verbs in Japanese depending on the part of body or the item being worn.
Model Checking (2) Temporal Logic
How do you talk about Positions/ Locations?
項書換え系(1) 代数的仕様と項書換え Term Rewriting Systems(1)
前回の練習問題について 情報記号 (x1, …, xk) に対し,検査記号 p = x1+…+xk+1として与えられる奇パリティ符号を考える.この符号が線形符号とならないことを証明せよ. 解答例: 線形符号とならない反例を示せばよい. x1=1, x2=x3=...=xk=0 ⇒ p = 0,対応する符号語は
Tohoku University Kyo Tsukada
V 03 I do NOT eat sushi. I do NOT do sumo.
放送番組と連動した 学校間交流学習コミュニティの設計
表現系工学特論 項書換え系(4) 完備化 1.語問題と等式証明 2.合流性とチャーチ・ロッサ性 3.完備化手続き.
十年生の 日本語 Year 10 Writing Portfolio
Reasonので + Consequence clause
Licensing information
Chapter 4 Quiz #2 Verbs Particles を、に、で
The Sacred Deer of 奈良(なら)
Did he/she just say that? Get your head out of the gutter! Oh wait….
“You Should Go To Kyoto”
Nihongo Japanese 日本ご ‘Numbers ’ & ‘Hiragana Revision’
ストップウォッチの カード ストップウォッチの カード
2018/11/19 The Recent Results of (Pseudo-)Scalar Mesons/Glueballs at BES2 XU Guofa J/ Group IHEP,Beijing 2018/11/19 《全国第七届高能物理年会》 《全国第七届高能物理年会》
点素パス問題に対するアルゴリズム 小林 佑輔 東京大学 大学院情報理工学系研究科 組合せ最適化セミナー 2012 年 7月 13日
Causative Verbs Extensively borrowed from Rubin, J “Gone Fishin’”, Power Japanese (1992: Kodansha:Tokyo) Created by K McMahon.
suppose to be expected to be should be
全国粒子物理会 桂林 2019/1/14 Implications of the scalar meson structure from B SP decays within PQCD approach Yuelong Shen IHEP, CAS In collaboration with.
Model Checking (2) Temporal Logic
Term paper, Report (1st, first)
Where is Wumpus Propositional logic (cont…) Reasoning where is wumpus
豊田正史(Masashi Toyoda) 福地健太郎(Kentarou Fukuchi)
逐次プログラムの正当性(2) 帰納的アサーション法(フロイド法)
Question Words….
2019年4月8日星期一 I. EPL 84, (2008) 2019年4月8日星期一.
プログラムの正当性(2) 正当性証明の基本原理
2019/4/22 Warm-up ※Warm-up 1~3には、小学校外国語活動「アルファベットを探そう」(H26年度、神埼小学校におけるSTの授業実践)で、5年生が撮影した写真を使用しています(授業者より使用許諾済)。
Term paper, report (2nd, final)
第1回レポートの課題 6月24日出題 今回の課題は1問のみ 第2回レポートと併せて本科目の単位を認定 第2回は7月に出題予定
Genetic Statistics Lectures (4) Evaluation of a region with SNPs
北大MMCセミナー 第62回 附属社会創造数学センター主催 Date: 2016年11月4日(金) 16:30~18:00
知能ソフトウェア特論 Intelligent Software
知能ソフトウェア特論 Intelligent Software
ー生命倫理の授業を通して生徒の意識に何が生じたかー
Created by L. Whittingham
東北大 情報科学 田中和之,吉池紀子 山口大 工 庄野逸 理化学研究所 岡田真人
英語勉強会:川口英語 Supporting of Continuing Life Habit Improvement Using the Theory of Cognitive Dissonance : System Extension and Evaluation Experiment B4 渡邉.
Cluster EG Face To Face meeting
第八課文法二 Chapter 8 Grammar 2
Grammar Point 2: Describing the locations of objects
Cluster EG Face To Face meeting 3rd
点素パス問題に対するアルゴリズム 小林 佑輔 東京大学 大学院情報理工学系研究科 組合せ最適化セミナー 2012 年 7月 13日
アノテーションガイドラインの管理を行う アノテーションシステムの提案
Improving Strategic Play in Shogi by Using Move Sequence Trees
Presentation transcript:

項書換え系(3) 合流性 Term Rewriting Systems(3) Confluence 知能ソフトウェア特論 Intelligent Software 項書換え系(3) 合流性 Term Rewriting Systems(3) Confluence

1.抽象書換え系 と合流性(1/3) (Abstract reduction systems and confluence) ■定義 ■Definition Abstract reduction system (A,R) consists of a set A and a binary relation R⊆A×A. We will write → for R. When (a,b)∈ →, we write a →b and say that a is reducible to b. a は b に簡約可能 【Example】

1.抽象書換え系 と合流性(2/3) (Abstract reduction systems and confluence) ■定義 ■Definition Reflexive transitive closure →*: We write a→*b, if b can be obtained from a by zero or more steps of reduction by →. Transitive closure →+: We write a→+b, if b can be obtained from a by one or more steps of reduction by →. Joinability ↓: a and b are joinable (a ↓ b), if there exists c in A such that a→*c and b→*c. 【Example】

弱合流性をもつが合流性をもたない例 (c と d が join しない) 1.抽象書換え系 と合流性(3/3) (Abstract reduction systems and confluence) ■定義 ■Definition Weak confluence: (A, →) is weakly confluent, if for all a, b and c in A, a →b and a →c implies b ↓ c. Confluence: (A, →) is confluent, if for all a, b and c in A, a →*b and a →*c implies b ↓ c. 【Example】 Confluence implies weak confluence, but its converse does not hold as the example in the right figure shows. 弱合流性をもつが合流性をもたない例 (c と d が join しない)

2.合流性の基本性質 (1/3) ■Definition 2.合流性の基本性質 (1/3)  (Basic properties of confluence) ■定義 ■Definition a∈A is a normal form, if there exists no b ∈A such that a →b. a∈A has a normal form, if there exists a normal form b ∈A such that a →*b. (A, →) has a unique normal form, if every a∈A has at most one normal form.

2.合流性の基本性質 (2/3) (Basic properties of confluence) 2.合流性の基本性質 (2/3)  (Basic properties of confluence) ■Theorem (Confluence ⇒ Unique normal form) Every confluent system has a unique normal form. 合流性は関数型プログラムに望まれる性質 (関数の返す値は非決定的な 並列計算をしても一意) Confluence is a desirable property for functional programs, as the values returned by functions should be unique even under nondeterministic, parallel computation. (Proof) If a has two normal forms b and c, then from a→*b and a→*c, we have b↓c. Since b and c are normal forms, it must be the case that b=c.

2.合流性の基本性質 (3/3) (Basic properties of confluence) 2.合流性の基本性質 (3/3)  (Basic properties of confluence) ■Theorem (Termination + Weak confluence ⇒ Confluence) [Newmann’s lemma] Every terminating, weakly confluent system is confluent. (証明) Termination of → allows us to use well-founded induction, where a→+b is a strict partial order that can be interpreted as “b is smaller than a”, and we can use the induction hypotheses P(b) to prove the induction step P(a). (Proof) (weak confluence) 整礎帰納法 (well-founded induction) 整礎帰納法 (well-founded induction) 停止性の検証方法は前回学んだので,合流性を検証するにはあと弱合流性の検証法を学べばよい Having already studied verification of termination, we will study verification of weak confluence to verify confluence.

【準備】代入(1/4) x y a g(z) (Preliminaries: Substitution) ■定義 ■Definition A substitution σ={x1/s1,…, xn/sn} represents the operation that replaces all the occurrences of variables xi (i=1,2,…,n) by the terms si. We will write σ(xi)=si. 代入 変数        を項  に 同時に置き換える操作を表す 【Example】 As this example shows, a substitution can be well represented as a table that maps each variable to a term. x y a g(z)

【準備】代入(2/4) x y a g(z) (Preliminaries: Substitution) ■定義 ■Definition Application of substitution σ to term t is denoted by σ(t). This represents the term obtained from t by replacing all the variables xi (i=1,2,…,n) by si. 代入の(項 t への)適用 項 t 内のすべての変数に対して,σで指定された置き換えを同時に一回行った結果を表す 【Example】 x y a g(z)

【準備】代入(3/4) (Preliminaries: Substitution) 代入σは,項の集合T からTへの関数 とみなすことができる A substitution σ can be seen as a function from the set of terms T to T. ■定義 代入の合成 ■Definition The composition of two substitutions σ1 and σ2 is the substitution σ1 ○ σ2 defined by 【Example】

【準備】代入(4/4) (Preliminaries: Substitution) ■定義 代入の一般性 ■Definition A substitution σ is more general than a subsitution σ’, if there exists a substitution τ such that σ’= τ ○ σ. 代入 σ は代入 σ’ より一般的である ある代入 τ に対し, 【Example】 In this example, σ is more general than σ’. Note that, intuitively, the result g(y,y) of σ is more general than the result g(b,b) of σ’, as the universally quantified variable y is more general than the specific constant b.

3.単一化 (1/6) (Unification) ■定義 ■Definition Two terms s and t are unifiable, if there exists a substitution σ, called a unifier of s and t, such that σ(s)= σ(t). ■Definition The most general unifier (mgu) σ of two terms s and t is a unifier σ such that there exists no unifier more general than σ. ■定義

3.単一化 (2/6) UNIFY (Unification) This is not the mgu. 【Example】 This is the mgu.

3.単一化 (3/6) s t (Unification) 単一化アルゴリズム 【入力】 項 s,t 【出力】 項 s,t が単一化可能ならば mgu を出力.            単一化可能でなければ「失敗」を出力. 【手順】 関数記号を解釈しない方程式 s = t を変形し,xi = ui の形の複数の方程式に変換して,代入(mgu) σ={ xi / ui | 1≦i≦n} を構成する. A unification algorithm accepts two terms s and t as input, and outputs the their mgu if they are unifiable; or the failure otherwise. Its procedure is basically the transformation of the equation s=t (in which the function symbols are not interpreted) into a set of equations of the form xi=ui, from which the resultant substitution (mgu) σ={xi / ui | 1≦i≦n} will be constructed. s t 【Example】 Equation: Solution:

3.単一化 (4/6) (Unification) Apply arbitrarily the following five transformation operations to the initial set of equations {s=t}. (Constants are regarded as function symbols with no arguments.) x is a variable and t is a term. Occurrence check: x = f(x)

3.単一化 (5/6) (Unification) When no operations of Step 1 are applicable any more, the set of equations should be in the form { xi = ui | 1≦i≦n} and no variables in the left-hand sides occur in the right-hand sides. In this case, s and t are unifiable and their mgu is σ={ xi / ui | 1≦i≦n}

3.単一化 (6/6) (Unification) 【Example】

4.危険対による合流性の判定 (1/5) (Decision on confluence by critical pairs) 【Motivation】 Consider two rules f(f(x, y), z) → f(x, f(y, z)) f(i(w), w) → e. To find general overlaps which can be reduced by any of them, try to unify a subterm of the left-hand side (LHS) of the first rule and the whole LHS of the second rule. 重なり(overlap) σ(left-hand side of first rule)= 弱合流性を乱す可能性のパターン (This pattern might violate weak confluence.) 危険対 (critical pair)

4.危険対による合流性の判定 (2/5) overlap critical pair (Decision on confluence by critical pairs) Let l1→r1 and l2→r2 be two rules in which variables are renamed so that they share no variables in common. ■定義 危険対 ■Definition A critical pair is a pair of terms σ(l1)[σ(r2)] and σ(r1), where σ is the mgu of l2 and a non-variable subterm s of l1 (i.e., σ(s)= σ(l2)). The notation l1[s] emphasizes that l1 contains s as its subterm. σ(l1)[σ(r2)] represents the term obtained from the overlap σ(l1)[σ(s)] by replacing the subterm σ(s) (=σ(l2)) by σ(r2). 危険対 overlap critical pair

4.危険対による合流性の判定 (3/5) overlap critical pair * * (Decision on confluence by critical pairs) ■Theorem (Critical pair theorem) A term rewriting system R is weakly confluent if, and only if, every critical pair 〈p,q〉 is joinable, i.e. p↓q. overlap (有限個の)危険対 だけ考えればよい critical pair We need to think about only a finite number of critical pairs to verify the weak confluence. * * (weak confluence)

(証明) ニューマンの補題(停止性∧弱合流性⇒合流性)と危険対定理を組み合わせる. 4.危険対による合流性の判定 (4/5) (Decision on confluence by critical pairs) ■Corollary (Confluence check by critical pairs for terminating TRS) A terminating, term rewriting system R is confluent if, and only if, for all critical pairs 〈p,q〉, normal forms of p and q are identical. (証明) ニューマンの補題(停止性∧弱合流性⇒合流性)と危険対定理を組み合わせる. (Proof) Combine the Newmann’s lemma with the Critical pair theorem. Algorithm Step 1. Let S = the finite set of all critical pairs of R. Step 2. For each critical pair 〈p,q〉 in S Let p* = a normal form of p; and q* = a normal form of q. If p* ≠ q*, then return false (R is not confluent). Step 3. Return true (R is confluent).

4.危険対による合流性の判定 (5/5) (Decision on confluence by critical pairs) 【Example】 It is not hard to show that R is terminating. R has only one critical pair 〈f(e),h(e,e)〉. Since the normal forms of both f(e) and h(e,e) are h(e,e), i.e., the same, R is confluent.

演習問題7 EXERCISE 7 Verify that the following terminating TRS R is confluent. (Hint: R has two critical pairs.) Verify that the following TRS S is not confluent. (Hint: The first two rules have two critical pairs, one of which consists of two terms that have normal forms different from each other.)