The Algorithm Mannot for Coq Extraction to Statically...
Transcript of The Algorithm Mannot for Coq Extraction to Statically...
The AlgorithmM′annot
for Coq Extractionto Statically Typed Languages
without Type Inference
Yoshihiro Imai @yoshihiro503
IT Planning, Inc
ML-Nagoya 2012
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
Yoshihiro Imai
I Twitter: @yoshihiro503I Home Page:
http://proofcafe.org/ yoshihiro503/I Hatena: id:yoshihiro503
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
Coqすごい!
Extractionすごい!
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
I 2007 LL魂@東京一ツ橋ホールI 2008 LL Future @東京なかのZEROI 2009 OSC名古屋@名古屋市立大学I 2010 Coq庵@名古屋市青少年文化センターI 2011 QCon Tokyo @東京ファッションタウンI 2011 TopSE講義@国立情報学研究所I 2011特殊研究 1後期講演@京都大学I 2012特別講義@名古屋大学I 2012 TopSE講義@国立情報学研究所
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
I Coqでアルゴリズムを定義し、証明できる
I Extraction機能でアルゴリズムからコードを自動生成
I 既存のコードと混ぜて使える!
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
問題点
Extractionの対象となる言語が限られている。
現状では次の 3種類:
I OCamlI HaskellI Scheme
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
問題点
実は大丈夫。I 内部データでは小さな仮想言語mini-MLに一旦変換している。
I つまり対象言語の構文のためのプリンタを書けば簡単に拡張できる。
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
対象言語を増やす拡張の例
I coq-ruby: https://github.com/mzp/coq-rubyI coq-clojure: http://patch-tag.com/r/leque/coq-
clojure-ext/homeI coq2javascript: (*開発中*)
https://bitbucket.org/yoshihiro503/coq2javascriptI coq2sml: (*開発中*)
https://bitbucket.org/yoshihiro503/coq2sml
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
問題点再び
mini-MLの特徴から、対象言語は次の機能を持た
なければならない:
I GCIラムダ式 (無名関数)I型推論
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
問題点再び
mini-MLの特徴から、対象言語は次の機能を持た
なければならない:
I GC
Iラムダ式 (無名関数)I型推論
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
問題点再び
mini-MLの特徴から、対象言語は次の機能を持た
なければならない:
I GCIラムダ式 (無名関数)
I型推論
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
問題点再び
mini-MLの特徴から、対象言語は次の機能を持た
なければならない:
I GCIラムダ式 (無名関数)I型推論
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
結論
I GCIラムダ式 (無名関数)I型推論
←ここを消せた!
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
結論
I GCIラムダ式 (無名関数)I型推論←ここを消せた!
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
ここから細かい話
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
coq-8.3pl3/plugins/extraction/extraction.ml
Coqの式 (Gallina)をmini-MLの式に変換する関数
extract_term :
env -> Mlenv.t -> ml_type ->
constr -> constr list -> ml_ast
constrがGallina, ml astはmini-MLの式,ml typeはmini-MLの型式。M′と呼ばれるアルゴリズムを使っている。
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
アルゴリズムM′
t := x| c| (fun x → t)| t t| let x = t in t| magic t
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
アルゴリズムM′annot
t := x[τ, . . . , τ]| c| (fun (x: τ) → t)| t t| let (x: τ) = t in t| magic[τ] t
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
アルゴリズムM′
[1] P. Letouzey, Certified functional programming Programextraction within Coq proof assistant, PhD thesis, 2004
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
アルゴリズムM′annot
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
結論
I GCIラムダ式 (無名関数)I型推論
←ここを消せた!
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
結論
I GCIラムダ式 (無名関数)I型推論←ここを消せた!
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
系
Coq2Scala: ScalaへのExtractionI http://proofcafe.org/wiki/Coq2Scala
I 応用例: 証明された定理証明器のScala実装https://bitbucket.org/yoshihiro503/coqincoq scala/
I 応用例: [2]姜帆,田辺良則,本位田真一, Coqを使用したMapReduceアプリケーションの検証とScalaコードの抽出, PPL 2012
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference
Coqを学ぼう
I ソフトウェアの基礎 (日本語):http://proofcafe.org/sf/
I ProofCafe毎月第4土曜日:http://proofcafe.org/wiki/
@yoshihiro503 IT Planning, Inc
The AlgorithmM′annot for Coq Extractionto Statically Typed Languageswithout Type Inference