1 / 5

Inferring Better Contracts

2011/07/05 ICSE 勉強会 担当:新原敦介. Inferring Better Contracts. Yi Wei 他 , Chair of Software Engineering, ETH Zurich, Switzerland, ICSE2011. 背景 ソフトウェアの信頼性には、ミスを避けるための  contracts: 制約が効果的 静的アプローチでは保守的な制約しかえられず、小さいプログラムしか適用できない

Download Presentation

Inferring Better Contracts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2011/07/05 ICSE 勉強会担当:新原敦介 Inferring Better Contracts Yi Wei 他, Chair of Software Engineering, ETH Zurich, Switzerland, ICSE2011 • 背景 • ソフトウェアの信頼性には、ミスを避けるための contracts:制約が効果的 • 静的アプローチでは保守的な制約しかえられず、小さいプログラムしか適用できない • 動的アプローチではスケーラビリティはあるものの、既存の手法は sophisticated な性質を導出できない.← 目的: ここを導出したい • 提案手法 • Object指向言語 Eiffel を対象 • 既存のAutoTest(著者の成果)を用いた動的アプローチ • 制約の生成には、3つのアプローチ • Basic template 基本的なテンプレートを用意して、全部試す. • Quantified expressions マイニングパターンを用意して、全部試す. • Implication expressions ディシジョンツリーを作りながら、学習する. • すべてをEiffelでツール化済み • 評価実験 • 手法: Eiffel Base のデータ構造クラス6個すべてを、提案手法のツールにかける • 結果: 1283個の制約を生成. • 正当性  94% 生成された制約が意味があるものか. • 完全性  75 % 抜け漏れはないか. ⇒ 提案手法の有効性を確認した. sophisticated

  2. Method Over View Pre-defined template ※2 - Equalities - Liner relations [10]M.D.Ernst他、 Dynamically discovering likely program invariants to support program evolution Figure 1 より引用 AutoTest Change Analysis Eiffelclass Test suite Change profile Basic templates Inferredcontracts ※1 例 LINKED_LIST.extend(v) を考えたとき、 Query: is_empty に関して、 pre set { True, False} 空と、そうでない入力がある post set {False} extend後は空ではない Query: count に関して、 change set {1} 必ず、1増えるから Validation Random Testing Frameworkで さまざまなTestを生成 [24]Y.Wei他, Programs that test themselves. IEEE Software , 2009 Predicate mining Quantified expressions ※2 例Equalities : 何か同じものがないかを探す LINKED_LIST.extend(v) では、post_7: last = v Liner relations : INTEGER型の変数は、リニアな関係性を探す e1 = a・e2+b e1 = a・old e2 + b LINKED_LIST.extend(v) では、post_2: count = old count + 1 Testを実行しValue Setsを作成 ※1 - pre set - post set - change set Validation Decision tree learning Implication expressions Confidencefiltering Yi Wei 他, Inferring Better Contracts, ICSE2011

  3. Example: LINKED_LIST.extend Listing 1 より引用 1. extend ( v: G) -- Add ‘v’ to end . Do not move cursor. • ensure • -- Programmer-written • post_1: occurrences (v) = old (occurrences(v)) + 1 • -- Automatically inferred • post_2: count = old count + 1 • post_3: i_th (old count + 1 ) = v • post_4: forall i. • 1 < i <old count implies i_th(i) = old i_th(i) • post_5: old after implies index = old index + 1 • post_6: not old after implies index = old index • post_7: last = v • post_8: forall o:G ≠ v. • occurrences(o) = old occurrences(o) • post_9: forall o:G ≠v. has(o) = old has(o) basic Quantified Quantified Implication Implication basic Quantified Quantified Yi Wei 他, Inferring Better Contracts, ICSE2011

  4. Method Detail たぶん喋れない Quantified expressions Implication expressions forall: forall o もしくは forall o ≠v について、以下を探す. x(o) = y(o) x(o) ≠y(o) x(o) or y(o) implies z(o) x(o) and y(o) implies z(o) vは、入力, x,y,z は、テスト対象が持つクエリ. 例 LINKED_LIST.extend(v) では、 post_8: forall o:G ≠ v. occurrences(o) = old occurrences(o) post_9: forall o:G ≠v. has(o) = old has(o) Sequence-based contracts: コンテナクラスの中でも、シーケンスなクラスを対象に、 以下のconstractsが存在するか探す. forall m< j < n. en(j) = (old en) ( j - m + old m) en( v + 1) = z forall v + 1 + σz<j < v + 1 + σz + old ( M - y) en( j ) = (old en) ( j - v - 1 - σz + old y) 例 LINKED_LIST.extend(v) では、 post_3: i_th (old count + 1 ) = v post_4: forall i. 1 < i < old count implies i_th(i) = old i_th(i) Decision tree learning: 以下のような木を学習 Figure 3 より引用 oldafter False True index = oldindex + 1 index = oldindex old after extendする前のコンテナクラスの、カーソルが、 最終行に来ているか? True: index = old index + 1 extend 後のカーソルは、extend前から インクリメントする False : index = old index extend後のカーソルは、extend前と変わらない Yi Wei 他, Inferring Better Contracts, ICSE2011

  5. 冗長性 Experiments EiffelBaseのすべてのデータ構造クラスを対象 自動生成数 完全性 Repetition 入力したクラスの開発者が書いた数 正当性(人力) Variation Auto? Table 1 より引用 Variation: 冗長でも価値がある OKRepetation:同じ事を表現する  NG Auto?: 開発者が書いたPostConditionが      自動生成とかぶった率 正答でないケース LINKED_LIST の merge_left old is_equal (other) implies is_empty AutoInfer では、空リスト以外は、リストのインスタンスを複数生成しない 完全性が下がるケース Setに、意味が付加されると厳しい 例:Hashに、既に存在する   要素を追加するとき Yi Wei 他, Inferring Better Contracts, ICSE2011

More Related