Verifying a Lustre Compiler (Part 1)
Total Page:16
File Type:pdf, Size:1020Kb
Verifying a Lustre Compiler (Part 1) Timothy Bourke1;2 Lélio Brun1;2 Pierre-Évariste Dagand3 Xavier Leroy1 Marc Pouzet4;2;1 Lionel Rieg5 1. INRIA Paris 2. DI, École normale supérieure 3. CNRS 4. Univ. Pierre et Marie Curie 5. Yale University SYNCHRON Workshop, Bamberg—December 2016 1 / 20 The Coq Development Team (2016): The Coq proof Coq [assistant reference manual ] • A functional programming language; • ‘Extraction’ to OCaml programs; • A specification language (higher-order logic); • Tactic-based interactive proof. • Why not use Isabelle, PVS, ACL2, Agda, or hyour favourite tooli? CompCert: a formal model and compiler for a subset of C • A generic machine-level model of execution and memory • A verified path to assembly code Blazy, Dargaye, and Leroy (2006): “Formal Leroy (2009): “Formal verification of a Verification of a C Compiler Front-End” realistic compiler” • Computer assistance is all but essential for such detailed models. What are we doing? • Implementing a Lustre compiler in the Coq Interactive Theorem Prover • Proving that the generated code implements the dataflow semantics (Part of the ITEA 3 14014 ASSUME Project.) 2 / 20 CompCert: a formal model and compiler for a subset of C • A generic machine-level model of execution and memory • A verified path to assembly code Blazy, Dargaye, and Leroy (2006): “Formal Leroy (2009): “Formal verification of a Verification of a C Compiler Front-End” realistic compiler” • Computer assistance is all but essential for such detailed models. What are we doing? • Implementing a Lustre compiler in the Coq Interactive Theorem Prover • Proving that the generated code implements the dataflow semantics (Part of the ITEA 3 14014 ASSUME Project.) The Coq Development Team (2016): The Coq proof Coq [assistant reference manual ] • A functional programming language; • ‘Extraction’ to OCaml programs; • A specification language (higher-order logic); • Tactic-based interactive proof. • Why not use Isabelle, PVS, ACL2, Agda, or hyour favourite tooli? 2 / 20 • Computer assistance is all but essential for such detailed models. What are we doing? • Implementing a Lustre compiler in the Coq Interactive Theorem Prover • Proving that the generated code implements the dataflow semantics (Part of the ITEA 3 14014 ASSUME Project.) The Coq Development Team (2016): The Coq proof Coq [assistant reference manual ] • A functional programming language; • ‘Extraction’ to OCaml programs; • A specification language (higher-order logic); • Tactic-based interactive proof. • Why not use Isabelle, PVS, ACL2, Agda, or hyour favourite tooli? CompCert: a formal model and compiler for a subset of C • A generic machine-level model of execution and memory • A verified path to assembly code Blazy, Dargaye, and Leroy (2006): “Formal Leroy (2009): “Formal verification of a Verification of a C Compiler Front-End” realistic compiler” 2 / 20 What are we doing? • Implementing a Lustre compiler in the Coq Interactive Theorem Prover • Proving that the generated code implements the dataflow semantics (Part of the ITEA 3 14014 ASSUME Project.) The Coq Development Team (2016): The Coq proof Coq [assistant reference manual ] • A functional programming language; • ‘Extraction’ to OCaml programs; • A specification language (higher-order logic); • Tactic-based interactive proof. • Why not use Isabelle, PVS, ACL2, Agda, or hyour favourite tooli? CompCert: a formal model and compiler for a subset of C • A generic machine-level model of execution and memory • A verified path to assembly code Blazy, Dargaye, and Leroy (2006): “Formal Leroy (2009): “Formal verification of a Verification of a C Compiler Front-End” realistic compiler” • Computer assistance is all but essential for such detailed models. 2 / 20 • Implemented in Coq and (some) OCaml • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] • Not yet implemented: normalization and scheduling [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. • Translation to intermediate Obc code. • Optimization of intermediate Obc code. • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization Obc generation Clight compilation Assembly printing 3 / 20 • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] • Not yet implemented: normalization and scheduling [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. • Translation to intermediate Obc code. • Optimization of intermediate Obc code. • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc generation Clight compilation Assembly printing 3 / 20 • Not yet implemented: normalization and scheduling [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. • Translation to intermediate Obc code. • Optimization of intermediate Obc code. • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] generation Clight compilation Assembly printing 3 / 20 • Elaboration toScheduled andNormalized Lustre. • Translation to intermediate Obc code. • Optimization of intermediate Obc code. • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] generation • Not yet implemented: normalization and scheduling Clight [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] compilation Assembly printing 3 / 20 • Translation to intermediate Obc code. • Optimization of intermediate Obc code. • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] generation • Not yet implemented: normalization and scheduling Clight [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. compilation Assembly printing 3 / 20 • Optimization of intermediate Obc code. • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] generation • Not yet implemented: normalization and scheduling Clight [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. compilation • Translation to intermediate Obc code. Assembly printing 3 / 20 • Generation of CompCert Clight code. • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] generation • Not yet implemented: normalization and scheduling Clight [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. compilation • Translation to intermediate Obc code. Assembly • Optimization of intermediate Obc code. printing 3 / 20 • Rely on CompCert for compilation. The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling Unannotated Lustre N-Lustre SN-Lustre Lustre dataflow translation imperative fusion optimization • Implemented in Coq and (some) OCaml Obc • Validated parser (menhir –coq) [Jourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” ] generation • Not yet implemented: normalization and scheduling Clight [Auger (2013): “Compilation certifiée de SCADE/LUSTRE” ] • Elaboration toScheduled andNormalized Lustre. compilation • Translation to intermediate Obc code. Assembly • Optimization of intermediate Obc code. printing • Generation of CompCert Clight code. 3 / 20 The Vélus Lustre Compiler (normalized) elaboration / scheduling check parsing elaboration normalization scheduling