Implementation of a compiler from Pluscal to TLA+ with Tom

Similar documents
TLA+ TLC. Rui Fan Stanislav Funiac Mandana Vaziri. Presented by Spring 2001

Specifying Concurrent Systems with TLA +

Specifying Concurrent Systems with TLA +

Proving the Correctness of Distributed Algorithms using TLA

TLA + Proofs. 1 Introduction. Denis Cousineau 1, Damien Doligez 2, Leslie Lamport 3, Stephan Merz 4, Daniel Ricketts 5, and Hernán Vanzetto 4

Specifying Concurrent Systems with TLA +

Leslie Lamport: The Specification Language TLA +

GUI for model checkers

Proofs and Proof Certification in the TLA + Proof System

Specifying Systems. Leslie Lamport. 27 Feb Preliminary Draft

Correctness of specifications. Correctness. Correctness of specifications (2) Example of a Correctness Proof. Testing versus Correctness Proofs


arxiv: v1 [cs.lo] 11 Nov 2010

The PlusCal Algorithm Language. Leslie Lamport Microsoft Research

IFM TLAPS tutorial. Peterson algorithm

Lectures 20, 21: Axiomatic Semantics

Formal Verification. Lecture 10

The SPIN Model Checker

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

Tool demonstration: Spin

LL(k) Parsing. Predictive Parsers. LL(k) Parser Structure. Sample Parse Table. LL(1) Parsing Algorithm. Push RHS in Reverse Order 10/17/2012

Current Versions of the TLA + Tools

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214

Copyright 2008 CS655 System Modeling and Analysis. Korea Advanced Institute of Science and Technology

Temporal Logic of Actions (TLA) (a brief introduction) Shmuel Katz Computer Science Department The Technion

tempo2hsal: Converting Tempo Models into HybridSal Tool Description

Program Syntax; Operational Semantics

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

Genie. Distributed Systems Synthesis and Verification. Marc Rosen. EN : Advanced Distributed Systems and Networks May 1, 2017

Transforming Programs into Recursive Functions

Outline. Introduction SDV Motivation Model vs Real Implementation SLIC SDVRP SLAM-2 Comparisons Conclusions

Introduction to Compilers and Language Design

Propositional Logic Formal Syntax and Semantics. Computability and Logic

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Object-Oriented and Classical Software Engineering

Object-Oriented and Classical Software Engineering

Towards certification of TLA + proof obligations with SMT solvers

Cover Page. The handle holds various files of this Leiden University dissertation

MPLc Documentation. Tomi Karlstedt & Jari-Matti Mäkelä

Model Checking Revision: Model Checking for Infinite Systems Revision: Traffic Light Controller (TLC) Revision: 1.12

AADL Graphical Editor Design

Cyber Physical System Verification with SAL

Formalizing Dijkstra

JavaFX on javac: A Case Study

Strategic Programming in Java

Clock-directed Modular Code-generation for Synchronous Data-flow Languages

Process Modelling. Fault Tolerant Systems Research Group. Budapest University of Technology and Economics

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

Safety and liveness for critical sections

Handout 9: Imperative Programs and State

In Our Last Exciting Episode

Parametricity. Types Are Documentation. Tony Morris

Interim Report: Build Your Efficient Programming Language Quickly

SPIN, PETERSON AND BAKERY LOCKS

Process Modelling. Fault Tolerant Systems Research Group. Budapest University of Technology and Economics

CMSC 330: Organization of Programming Languages. OCaml Expressions and Functions

TESTING. Overview Slide 6.2. Testing (contd) Slide 6.4. Testing Slide 6.3. Quality issues Non-execution-based testing

Formal Semantics of Programming Languages

Thread Synchronization: Too Much Milk

SPIN s Promela to Java Compiler, with help from Stratego

Grammars and Parsing, second week

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Local Verification of Global Invariants in

Generating a CTL model checker using an attribute grammar

Formal Semantics of Programming Languages

The Spin Model Checker : Part I/II

Parametricity. Types Are Documentation. Tony Morris

Temporal Refinement Using SMT and Model Checking with an Application to Physical-Layer Protocols

User-defined Functions. Conditional Expressions in Scheme

Using TLC to Check Inductive Invariance

A CRASH COURSE IN SEMANTICS

Matching Logic A New Program Verification Approach

Chapter 1. Introduction

Static analysis and testing of executable DSL specification

Formal specification of semantics of UML 2.0 activity diagrams by using Graph Transformation Systems

Programming Languages Third Edition

CS164: Midterm I. Fall 2003

Evaluation Strategies for Functional Logic Programming

Software Development & Education Center C Programming

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

A UNITY-based Formalism for Dynamic Distributed Systems

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

nfn2dlp: A Normal Form Nested Programs Compiler

Finding and Fixing Bugs in Liquid Haskell. Anish Tondwalkar

Programming Languages

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

C++ Programming: From Problem Analysis to Program Design, Third Edition

Software Construction

Applications of Formal Verification

CS2112 Fall Assignment 4 Parsing and Fault Injection. Due: March 18, 2014 Overview draft due: March 14, 2014

Making it Easy to Deploy the UVM by Dr. Christoph Sühnel, frobas GmbH

LOGIC AND DISCRETE MATHEMATICS

Applications of Formal Verification

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy!

Software Testing. Software Testing

Optimizing Compilers. Vineeth Kashyap Department of Computer Science, UCSB. SIAM Algorithms Seminar, 2014

Overview. Probabilistic Programming. Dijkstra s guarded command language: Syntax. Elementary pgcl ingredients. Lecture #4: Probabilistic GCL

Mutual Exclusion. 1 Formal problem definitions. Time notion CSE /17/2015. Outline of this lecture:

CS558 Programming Languages

Transcription:

Implementation of a compiler from Pluscal to TLA+ with Tom Marc PINHEDE ESIAL-Telecom Nancy 1 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Contents I Pluscal2.0 TLA+ Tools II Personal work Grammars Tree rewriting Code Generation III Situation after the internship Tests Todo 2 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Introduction Location: Loria Team: AlGorille Supervisor: Martin Quinson Task: Rework on a thesis compiler Subject: Compiler form Pluscal2.0 to TLA+ 3 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Introduction Situation: TLA+, a language used to specify a system : Very mathematical specification Permit to use a model-checker But not an easy language to learn, for program designers. Leslie Lamport introduced Pluscal. But it was still not really easy to use. 4 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Pluscal2.0 Syntax close to standard algorithms Procedures can be used Non typed variables Accept processes and hierarchical processes Atomicity for some part of code accepted Embedded TLA+ code 5 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Pluscal2.0 code algorithm Peterson extends Naturals constants numpeers (* Number of processes *) variables lockreq = [id \in Node -> FALSE], turn = 1, (* tie-break variable *) count = 0 (* number of processes holding the lock *) fair process Node[numPeers] definition other == CHOOSE id \in Node : id # self 6 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Pluscal2.0 code begin ncs: try: cs: loop skip; lockreq[self] := TRUE; turn := other; when ~lockreq[other] \/ turn = self; count := count + 1; leave: count := count - 1; lockreq[self] := FALSE; end loop; 7 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Pluscal2.0 code end process; (*No Main process*) (* Assert: at most one process have the lock *) invariant count <= 1 (* Liveness: each requested lock is eventually granted *) temporal \A p \in Node: [] (<> lockreq[p]) (* Instantiating the model for 2 processes *) constants numpeers = 2 8 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

TLA+ Set of Actions Action : Guard conditions Variable modifications List of unchanged variables Special actions that ensure liveness properties 9 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Vrai == hr # 13 Faux == hr # 7 10 / 21 ====================================================== Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom TLA+ code ---------------MODULE HourClock----------------------- EXTENDS Naturals VARIABLE hr HCini == hr \in (1..12) HCnxt == hr = IF hr # 12 THEN hr+1 ELSE 1 HC == HCini /\ [][HCnxt]_hr ------------------------------------------------------ THEOREM HC => []HCini

Outils Main tools: Tom: Language extension. Permit easy tree manipulations. Antlr: Automatic Parser/Lexer generator. Others: Text editor, TlaToolbox,Tlc... 11 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Grammars Grammars are divided in two set: one for Pluscal2.0, the other for TLA+ For each set, two grammars. The antlr version and the Tom version. Four files: Antlr grammar for Pluscal2.0 Antlr grammar for TLA+ Gom signature for Pluscal2.0 Gom signature for TLA+ 12 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Tree rewriting Tree rewriting are executed by tom. Two tools: match: Applied on a piece of the tree. strategy: Applied on the whole tree. Exemple: visit LabeledStatement{ /* Add label to any loop statement.*/ Labellisation(EmptyLabel(),Loop(labeledStatementList))-> { } return Labellisation(GivenLabel(OptionString("loop", ConcOption())),Loop(labeledStatementList)); } 13 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Rewriting steps 14 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Code generation Use of a pretty printer Recursive walk of the tree Two output files (.tla et.cfg) Completed step for the actual TLA+ signature 15 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Tests Approach close to the TDD (Test-Driven Development) used. Set of tests, divided in subset, available Tests identify working instructions. Scripted tests with recorded answers. 16 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Test of the whole compiler Implementation of a simple test requiring every steps of the compiler Test accepeted by the model-checker Verification of trivial properties validated 17 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Unfinished parts Semantic control Normalization for some instructions Potential add of a separate step to manage the PC value or Translator completion. Add of new features to the compiler 18 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Conclusion For the compiler: Use of traditional tools and separation of the work in steps to make sources more accessible Completed main process Some steps need to be completed or extended. As a personnal experience: Rewarding intership and good approach of the research world New tools and new way to program discovered Management and teamwork pleasant 19 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Sources Vérification Formelle d Algorithmes Distribués en PlusCal-2 - Sabina AKHTAR Specifying Systems - Leslie Lamport A Pluscal User s Manual - Leslie Lamport 20 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom

Thanks Thanks to: Martin QUINSON, my intership supervisor, for his presence and control, but also for the good atmosphere he was able to create in the team. Stephan MERTZ, for helping me to understand the potential of this project. Jean-Christophe BACH, for his help and patience with Tom. 21 / 21 Marc PINHEDE Implementation of a compiler from Pluscal to TLA+ with Tom