項書換え系(1) 代数的仕様と項書換え Term Rewriting Systems(1)

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

て -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.
一階述語論理 (first-order predicate logic) 一階述語論理入門 構文論(論理式の文 法) 意味論(論理式の解 釈) 認知システム論 知識と推論(4) 知識と論理でを組み合わせて問題を解決する.
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?
プログラミング言語論 第10回(演習) 情報工学科 木村昌臣   篠埜 功.
京都大学情報学研究科 通信情報システム専攻 湯淺研究室 M2 平石 拓
The Bar バー.
Chapter 11 Queues 行列.
Chris Burgess (1号館1308研究室、内線164)
じょし Particles.
What did you do, mate? Plain-Past
プログラムの正当性(2) 正当性証明の基本原理
日本人の英語文章の中で「ENJOY」はどういうふうに使われているのか
Ch13-1 TB250 てフォーム.
項書換え系(3) 合流性 Term Rewriting Systems(3) Confluence 知能ソフトウェア特論
There are 5 wearing verbs in Japanese depending on the part of body or the item being worn.
Let’s discuss in English! What are your opinions? Let’s discuss it!
Model Checking (2) Temporal Logic
条件式 (Conditional Expressions)
Tohoku University Kyo Tsukada
表現系工学特論 項書換え系(4) 完備化 1.語問題と等式証明 2.合流性とチャーチ・ロッサ性 3.完備化手続き.
にほんご JPN101 Oct. 26, 2009 (Monday).
十年生の 日本語 Year 10 Writing Portfolio
Reasonので + Consequence clause
Licensing information
The Sacred Deer of 奈良(なら)
“You Should Go To Kyoto”
Chapter 1 Hamburger History
ストップウォッチの カード ストップウォッチの カード
4 ソフトウェア工学 Software Engineering 抽象データ型 ABSTRACT DATA TYPE.
Topics on Japan これらは、過去のインターンが作成したパワポの写真です。毎回、同じような題材が多いため、皆さんの出身地等、ここにない題材も取り上げるようにしてください。
The Syntax of Participants シンタックスの中の話者と聞き手
Input slides 1 – 11 – teacher says word - pupils repeat – word appears on click Ohayoo. おはよう。
National adviser Japanese Yuriko Kayamoto
PROGRAMMING IN HASKELL
 言語の意味論3 ー表示的意味論ー 2007.
Causative Verbs Extensively borrowed from Rubin, J “Gone Fishin’”, Power Japanese (1992: Kodansha:Tokyo) Created by K McMahon.
述語論理と∀(全称)∃(存在) 3回の講義の概観: 命題論理 (真理値) (公理と推論規則) 述語論理 (モデルと解釈)
-Get test signed and make corrections
Model Checking (2) Temporal Logic
Term paper, Report (1st, first)
PROGRAMMING IN HASKELL
6. リスト処理関数の設計(発展版) プログラミング論 I.
Where is Wumpus Propositional logic (cont…) Reasoning where is wumpus
豊田正史(Masashi Toyoda) 福地健太郎(Kentarou Fukuchi)
大規模なこと Large scale.
逐次プログラムの正当性(2) 帰納的アサーション法(フロイド法)
受け身の疑問文 Practice ~ed・・・?.
いくらですか?.
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
論理的に推論 L4. Reasoning Logically Knowledge Representation (知識表現)
東北大 情報科学 田中和之,吉池紀子 山口大 工 庄野逸 理化学研究所 岡田真人
Type Systems and Programming Languages ; chapter 13 “Reference”
Visualizing Japanese Grammar Appendix
Cluster EG Face To Face meeting
Grammar Point 2: Describing the locations of objects
Term paper, report (2nd, final)
PROGRAMMING IN HASKELL
Improving Strategic Play in Shogi by Using Move Sequence Trees
Presentation transcript:

項書換え系(1) 代数的仕様と項書換え Term Rewriting Systems(1) 知能ソフトウェア特論 Intelligent Software 項書換え系(1) 代数的仕様と項書換え Term Rewriting Systems(1) Algebraic Specification and Term Rewriting

項書換え系入門:基本的なアイデア 等式 等式 (equation) (specification) (program) 書換え規則 (Introduction to term rewriting systems: Basic idea) 等式 等式 (equation) 仕様 (specification) (program) 書換え規則 (rewrite rule) プログラム 書換え (rewriting) (computation) 計算 書換え規則の左辺のインスタンス 対応する右辺のインスタンス (an instance of the left-hand side of a rewrite rule) (the corresponding instance of the right-hand side)

項書換え系入門:応用 記号計算 (symbolic computation) 定理証明 (theorem proving) (Introduction to term rewriting systems: Applications) 記号計算 (symbolic computation) 定理証明 (theorem proving) ソフトウェアの代数的仕様記述 (algebraic specification of software) ソフトウェアの自動検証 (automated verification of software)

1.項書換え系の構文論 (1/2) (Syntax of term rewriting systems) 基本的な記号は次の3種類 Atomic symbols used in term rewriting systems are classified into variables (x,y,z,…), constants (0,1,…,a,b,c,…), and function symbols (f,g,h,…) with fixed arity, the number of arguments they take. A term is constructed as follows. A variable and a constant are terms. If f is a function symbol of arity n and if t1 ,…, tn are terms, then f(t1,…,tn) is a term.

1.項書換え系の構文論 (2/2) (Syntax of term rewriting systems) A rewrite rule is an ordered pair l→r of terms (the left-hand side l and the right-hand side r). Any instance of l can be rewritten to the corresponding instance of r. A term rewriting system (TRS) R is a set of rewrite rules.

左辺のインスタンス (instance: 実例) 2.項書換え系の操作的意味論 (1/5) (Operational semantics of term rewriting) A term s is reducible to a term t, notation s→Rt (or s→t), if t can be obtained by applying a rewrite rule in R once to a subterm (a part) of s. 左辺のインスタンス (instance: 実例) = リデックス (reducible expression) 部分項 subterm an instance of the left-hand side a redex (reducible expression)

2.項書換え系の操作的意味論 (2/5) (Operational semantics of term rewriting) A rewrite sequence represents a computation. A term tn is a normal form of the initial term t0 if tn cannot be rewritten any more. The normal form represents the result of the computation.

2.項書換え系の操作的意味論 (3/5) (Operational semantics of term rewriting) Rewrite strategy: In general, the computation is non-deterministic, i.e., there are many t’s to which s is reducible. A rewrite strategy determines which one to choose. Leftmost-innermost strategy chooses the leftmost redex from the innermost ones. Here is an example.

2.項書換え系の操作的意味論 (4/5) (Operational semantics of term rewriting) Leftmost-outermost strategy chooses the leftmost redex from the outermost ones.

2.項書換え系の操作的意味論 (5/5) (Operational semantics of term rewriting) A TRS is terminating (or has a termination property) if there exists no infinite rewrite sequence., i.e., the computation will terminate definitely . 第2回で扱う discuss it in the second lecture. A TRS is confluent (or has a confluence property) if there exists no or unique normal form, i.e., there exists at most one result of the computation. 第3回で扱う discuss it in the third lecture.

3.ソフトウェアの代数的仕様記述 (1/13) (Algebraic specification of software) Algebraic specifications define abstract data types by describing relationships among functions in a set of equations. Direct execution of algebraic specifications as TRSs are possible by directing equations l=r to l→r.

3.ソフトウェアの代数的仕様記述 (2/13) 例題1 スタック (Algebraic specification of software) 例題1  スタック (Example 1: Stack)

3.ソフトウェアの代数的仕様記述 (3/13) (Algebraic specification of software) (Example of direct execution)

パターン 0 と s(x) で第1引数に来るすべての自然数について場合を尽くしている 3.ソフトウェアの代数的仕様記述 (4/13) (Algebraic specification of software) 例題2:自然数の加算 (Example 2: Addition of natural numbers) The successor function s(x)=x+1 allows us to represent the natural numbers as terms 0, s(0), s(s(0)),… パターン 0 と s(x) で第1引数に来るすべての自然数について場合を尽くしている The patterns 0 and s(x) cover all the cases for possible natural numbers for the first argument.

3.ソフトウェアの代数的仕様記述 (5/13) (Algebraic specification of software) (Example of direct execution) 2+2→ → → 4

補足 リスト構造 (1/3) cons(H,T) H:T [A,B,C,…] [B,C,…] A 補足 リスト構造 (1/3) (Supplementary note: List structure) List structure is a data structure used to represent a sequence [A, B, C, …] of data. リスト構造 :データの列 [A, B, C, …] を表現するデータ構造 頭部 head セル cell 尾部 tail It is implemented as a cell consisting of two parts: the head for representing the first idem of the list and the tail for the subsequence starting from the second item. [A,B,C,…] [B,C,…] A これを,項  cons(H,T) The cell consisting of the head H and the tail T is represented by the term cons(H,T) and abbreviated as H:T. で表現 簡易記法:  H:T

A: (B: (C: NULL)) = A: B: C: NULL 補足 リスト構造 (2/3) (Supplementary note: List structure) 空リスト empty list アトム atom A: (B: (C: NULL)) = A: B: C: NULL = [A,B,C] : は右結合演算子 簡易記法  The : is a right-associative operator. abbreviation

(A:NULL):B:NULL [[A],B] 補足 リスト構造 (3/3) 補足 リスト構造 (3/3) (Supplementary note: List structure) トップレベル要素 top-level elements トップレベル要素 (A:NULL):B:NULL [[A],B]

3.ソフトウェアの代数的仕様記述 (6/13) (Algebraic specification of software) 例題3 n 番目に小さな素数     (先頭は 0 番目) Example 3: The nth smallest prime number (where 0th is the first one) 素数の集合={2,3,5,7,11,…} The set of prime number is {2,3,5,7,11,…}. The leftmost-outermost strategy will reduce prime(2) to 5. 最外最左戦略で prime(2)→…→5 n番目に小さな素数 prime(n) returns the nth smallest prime number. 先頭から n 番目のデータを返す 素数が昇順に並ぶ無限リスト nth(L, n) returns the nth element of the list L. primes( ) returns the infinite list of the prime numbers arranged in the ascending order.

3.ソフトウェアの代数的仕様記述 (7/13) The first (0th) element of x:y is x. (Algebraic specification of software) nth(L, n) はリストL のn 番目の要素 nth(L, n) returns the nth element of the list L The first (0th) element of x:y is x. The (n+1)th element of x:y is the nth element of y.

3.ソフトウェアの代数的仕様記述 (8/13) sieve (Algebraic specification of software) primes( ) returns the infinite list of the prime numbers in the ascending order. 素数が昇順に並ぶ無限リスト 自然数 x 以降の自然数の無限リスト ints(x) returns the infinite list of the natural numbers starting from the natural number x in the ascending order. ints(s(s(0)) = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,…] sieve primes( ) = [2, 3, 5, 7, 11, 13, ………]

3.ソフトウェアの代数的仕様記述 (9/13) (Algebraic specification of software) エラトステネスのふるい sieve(x:y) returns the list of prime numbers starting from x by filtering out the non-prime numbers from y based on the Eratosthenes' sieve algorithm. sieve [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,…] 2 : filter [3,4,5,6,7,…] by 2, followed by sieve 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 : sieve [3,5,7,9,11,13,15,…] 2 : 3 : filter [5,7,9,11,13,15,…] by 3, followed by sieve 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

3.ソフトウェアの代数的仕様記述 (10/13) (Algebraic specification of software) filt(x, L)は x の倍数をすべて リスト L から削除するフィルター filt(x, L) returns the list obtained from the list L by filtering out all the multiples of x. eq(x, y) means x=y and mod(y, x) means the remainder of y÷x. (Define them in the Exercise.) If the first element y is divided by x (i.e., y mod x equals 0), then ignore y and continue the filtering of z, else save y for the head and continue the filtering of z for the tail. if(C, x, y) represents the conditional expression. It returns x if the condition C is reduced to true; or y if C is reduced to false.

(leftmost outermost reduction strategy) 3.ソフトウェアの代数的仕様記述 (11/13) (Algebraic specification of software) (leftmost outermost reduction strategy) 最外最左戦略 遅延評価 (delayed evaluation) 2 などは s(s(0)) などの略. f は filt の略 1引数関数prime, ints, sieveの引数を囲む括弧は省略 For the simplicity of the expressions: ●the integers such as 2 represents the terms such as s(s(0)), ●f is the abbreviation for filt, ●the parentheses surrounding the argument of unary functions prime, ints, and sieve are omitted.

3.ソフトウェアの代数的仕様記述 (12/13) (Algebraic specification of software)

3.ソフトウェアの代数的仕様記述 (13/13) (Algebraic specification of software)

演習問題5 When the natural numbers are encoded by 0 and the successor function s, write the algebraic specifications of the following functions for completing the description for Example 3, assuming the built-in operator = is not available. eq(x, y) returns true if x=y; or false, otherwise. ge(x, y) returns true if x≧y; or false, otherwise. minus(x, y) returns x-y if x≧y; or 0, otherwise. mod(x, y) returns the remainder for x÷y. (Subtract y from x as long as possible.) Exercise 5 You have to define the equality operator eq without built-in equality =. For example, the solution including an equation like eq(x, y) = if(x=y, true, false) is incorrect. A correct answer would include four equations with the left-hand sides eq(0, 0), eq(0, s(y)), eq(s(x), 0), and eq(s(x), s(y)). Make sure that eq(s(0), s(s(s(0)))) reduces to false.