SlideShare a Scribd company logo
ML Coq
@tmiya_
July 09, 2016
Coq
Coq OCaml
OCaml ML
) Coq
omega
:
ISO/IEC 15408 EAL7
CompCert sel4 JavaCard
Coq TLS OpenSSL
[ 14]
Curry-Howard
() –
A () A
A () A a : A
A ^ B () A; B
A _ B () A; B
A ! B () A B
()
8a : A; B () A a , Bfx=ag
9a : A; B () a : A Bfa=xg
A ! B ()
() tactic
()
)
Peano
Inductive nat : Set :=
O : nat
| S : nat -> nat.
Inductive list {A : Type} : Type :=
nil : list A
| cons : A -> list A -> list A.
[], :: Notaion
Fixpoint length {A : Set } (xs : list A) :=
match xs with
| [] => O
| x :: xs’ => S (length xs’)
end.
map length
Goal forall (A B:Set)(f: A->B)(xs: list A),
length(map f xs) = length xs.
Proof.
intros; induction xs; simpl; auto.
Qed.
map OCaml
let rec map f = function
| Nil -> Nil
| Cons (a, t) -> Cons ((f a), (map f t))
OCaml coqio (IO )
@yoshihiro503
Coq
Goal forall (A B:Set)(f: A->B)(xs: list A),
length(map f xs) = length xs.
Proof.
intros A B f xs.
---------> length (map f xs) = length xs
induction xs as [|x xs’].
(* xs = nil *)
---------> length (map f nil) = length nil
- simpl.
---------> 0 = 0
auto.
(* xs = x :: xs’ *)
IHxs’ : length (map f xs’) = length xs’
list
---------> length (map f (x :: xs’)) = length (x :: xs’)
- simpl.
---------> S (length (map f xs’)) = S (length xs’)
auto.
Qed.
Why3
ML Java, C, Atlier B
/ Coq
Coq
(for )
OCaml
let max_sum (a: array int) (n: int) =
{ 0 <= n = length a / forall i:int. 0 <= i < n -> a[i] >= 0 }
let sum = ref 0 in
let max = ref 0 in
for i = 0 to n - 1 do
invariant { !sum <= i * !max }
if !max < a[i] then max := a[i];
sum := !sum + a[i]
done;
(!sum, !max)
{ let (sum, max) = result in sum <= n * max }
=) Coq
: “Coq: The world s best macro assembler?”
Coq X86
X86 state monad
! DFA ! X86
RET
| RETOP offset =>
let! oldSP = getRegFromProcState ESP;
let! IP = getDWORDFromProcState oldSP;
do! setRegInProcState ESP
(addB (oldSP+#4) (zeroExtend 16 offset));
setRegInProcState EIP IP
max
Definition max (r1 r2: Reg) : program :=
LOCAL Bigger;
CMP r1, r2;; JG Bigger;; MOV r1, r2;;
Bigger:; .
Coq
“Coq’Art”
tactic goal
twitter/
Garrigue
TAPL ) Pierce
)
Why3 CFML
) Garrigue Affeldt
SSReflect “Coq Winter School 2016”
) “Certified Programming with
Dependent Types” “Proof by Reflection”
/
Coq
SF :
Pierce +¸
connpass #readcoqart
7/24(Sun)
Coq
ProofCafe :
ProofSummit 2016
ProofSummit
9/25(Sun)
ICFP 2016 (9/17-24 )

More Related Content

PPT
Maximum flow
PDF
OCamlOScope: a New OCaml API Search
PPT
Jan 2012 HUG: RHadoop
TXT
Rumus vb
PDF
bpftrace - Tracing Summit 2018
PPTX
Minimum cost maximum flow
PDF
PPTX
Otter 2014-12-08-02
Maximum flow
OCamlOScope: a New OCaml API Search
Jan 2012 HUG: RHadoop
Rumus vb
bpftrace - Tracing Summit 2018
Minimum cost maximum flow
Otter 2014-12-08-02

What's hot (20)

PDF
L2 binomial operations
PDF
Rcpp11 genentech
PPT
A Speculative Technique for Auto-Memoization Processor with Multithreading
ODP
Java 8 Concurrency Updates
PDF
SciSmalltalk: Doing Science with Agility
PPT
Tutorials--Graphs of Logarithmic Functions
KEY
Generating and Analyzing Events
PDF
Ece512 h1 20139_621386735458ece512_test2_solutions
PPTX
Python at 10.1
PDF
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
PDF
R/C++ talk at earl 2014
PDF
Rcpp11 useR2014
DOCX
program on Function overloading in java
DOC
Computer hw1
PPT
Contrastive Divergence Learning
PPTX
PPTX
Cryptography : From Demaratus to RSA
PPT
Max flow min cut
PPTX
Network flows
L2 binomial operations
Rcpp11 genentech
A Speculative Technique for Auto-Memoization Processor with Multithreading
Java 8 Concurrency Updates
SciSmalltalk: Doing Science with Agility
Tutorials--Graphs of Logarithmic Functions
Generating and Analyzing Events
Ece512 h1 20139_621386735458ece512_test2_solutions
Python at 10.1
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
R/C++ talk at earl 2014
Rcpp11 useR2014
program on Function overloading in java
Computer hw1
Contrastive Divergence Learning
Cryptography : From Demaratus to RSA
Max flow min cut
Network flows
Ad

Similar to Coq for ML users (20)

PDF
Coq Tutorial
PDF
Coq Tutorial at Proof Summit 2011
PPTX
Prolog: Arithmetic Operations In Prolog
PPTX
PROLOG: Arithmetic Operations In Prolog
PDF
Coq for beginners
PDF
OCaml Walkthrough
PDF
Introduction to functional programming using Ocaml
PDF
Proofsummit2011a
PPT
Dynamic Programing_LCS.ppt
PDF
[Expert Fridays] Александр Чичигин - Как перестать бояться и полюбить COQ
PPTX
Week 4
PDF
Property Based Testing with ScalaCheck
PDF
Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Ed...
PDF
Decidability
PDF
CAML考古学
PDF
Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Ed...
PDF
ラベルなしオプション引数の型システムと型推論
PDF
3rd Semester Computer Science and Engineering (ACU-2022) Question papers
PDF
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
PDF
Why Haskell Matters
Coq Tutorial
Coq Tutorial at Proof Summit 2011
Prolog: Arithmetic Operations In Prolog
PROLOG: Arithmetic Operations In Prolog
Coq for beginners
OCaml Walkthrough
Introduction to functional programming using Ocaml
Proofsummit2011a
Dynamic Programing_LCS.ppt
[Expert Fridays] Александр Чичигин - Как перестать бояться и полюбить COQ
Week 4
Property Based Testing with ScalaCheck
Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Ed...
Decidability
CAML考古学
Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Ed...
ラベルなしオプション引数の型システムと型推論
3rd Semester Computer Science and Engineering (ACU-2022) Question papers
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Why Haskell Matters
Ad

More from tmiya (7)

PDF
Typeclass
PDF
RegExp20110305
PDF
Coq setoid 20110129
PDF
Coq Party 20101127
PPTX
Maude20100719
PDF
Formal methods20100529
PPTX
Coq 20100208a
Typeclass
RegExp20110305
Coq setoid 20110129
Coq Party 20101127
Maude20100719
Formal methods20100529
Coq 20100208a

Recently uploaded (20)

PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PPTX
assetexplorer- product-overview - presentation
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Nekopoi APK 2025 free lastest update
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Website Design Services for Small Businesses.pdf
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
iTop VPN Crack Latest Version Full Key 2025
Oracle Fusion HCM Cloud Demo for Beginners
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Weekly report ppt - harsh dattuprasad patel.pptx
17 Powerful Integrations Your Next-Gen MLM Software Needs
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
assetexplorer- product-overview - presentation
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
AutoCAD Professional Crack 2025 With License Key
Nekopoi APK 2025 free lastest update
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Download FL Studio Crack Latest version 2025 ?
Website Design Services for Small Businesses.pdf
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Complete Guide to Website Development in Malaysia for SMEs
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Wondershare Filmora 15 Crack With Activation Key [2025
Advanced SystemCare Ultimate Crack + Portable (2025)
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps

Coq for ML users

  • 3. : ISO/IEC 15408 EAL7 CompCert sel4 JavaCard Coq TLS OpenSSL [ 14]
  • 4. Curry-Howard () – A () A A () A a : A A ^ B () A; B A _ B () A; B A ! B () A B () 8a : A; B () A a , Bfx=ag 9a : A; B () a : A Bfa=xg A ! B () () tactic () )
  • 5. Peano Inductive nat : Set := O : nat | S : nat -> nat. Inductive list {A : Type} : Type := nil : list A | cons : A -> list A -> list A. [], :: Notaion Fixpoint length {A : Set } (xs : list A) := match xs with | [] => O | x :: xs’ => S (length xs’) end.
  • 6. map length Goal forall (A B:Set)(f: A->B)(xs: list A), length(map f xs) = length xs. Proof. intros; induction xs; simpl; auto. Qed. map OCaml let rec map f = function | Nil -> Nil | Cons (a, t) -> Cons ((f a), (map f t)) OCaml coqio (IO ) @yoshihiro503
  • 7. Coq Goal forall (A B:Set)(f: A->B)(xs: list A), length(map f xs) = length xs. Proof. intros A B f xs. ---------> length (map f xs) = length xs induction xs as [|x xs’]. (* xs = nil *) ---------> length (map f nil) = length nil - simpl. ---------> 0 = 0 auto. (* xs = x :: xs’ *) IHxs’ : length (map f xs’) = length xs’ list ---------> length (map f (x :: xs’)) = length (x :: xs’) - simpl. ---------> S (length (map f xs’)) = S (length xs’) auto. Qed.
  • 8. Why3 ML Java, C, Atlier B / Coq Coq (for ) OCaml let max_sum (a: array int) (n: int) = { 0 <= n = length a / forall i:int. 0 <= i < n -> a[i] >= 0 } let sum = ref 0 in let max = ref 0 in for i = 0 to n - 1 do invariant { !sum <= i * !max } if !max < a[i] then max := a[i]; sum := !sum + a[i] done; (!sum, !max) { let (sum, max) = result in sum <= n * max } =) Coq
  • 9. : “Coq: The world s best macro assembler?” Coq X86 X86 state monad ! DFA ! X86 RET | RETOP offset => let! oldSP = getRegFromProcState ESP; let! IP = getDWORDFromProcState oldSP; do! setRegInProcState ESP (addB (oldSP+#4) (zeroExtend 16 offset)); setRegInProcState EIP IP max Definition max (r1 r2: Reg) : program := LOCAL Bigger; CMP r1, r2;; JG Bigger;; MOV r1, r2;; Bigger:; .
  • 10. Coq “Coq’Art” tactic goal twitter/ Garrigue TAPL ) Pierce ) Why3 CFML ) Garrigue Affeldt SSReflect “Coq Winter School 2016” ) “Certified Programming with Dependent Types” “Proof by Reflection” /
  • 11. Coq SF : Pierce +¸ connpass #readcoqart 7/24(Sun) Coq ProofCafe : ProofSummit 2016 ProofSummit 9/25(Sun) ICFP 2016 (9/17-24 )