Top Banner
Gallimaufry An Automated Framework for Proving Type- Safety Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA [email protected] www.cs.wisc.edu/~mulhern/gallimaufry CLASE 2005
40

Gallimaufry

Jan 22, 2016

Download

Documents

caden

Gallimaufry. An Automated Framework for Proving Type-Safety. Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA [email protected] www.cs.wisc.edu/~mulhern/gallimaufry. CLASE 2005. Overview. Introduction Gallimaufry Design: Core - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Gallimaufry

GallimaufryAn Automated Framework for Proving Type-Safety

Anne MulhernComputer Sciences DepartmentUniversity of Wisconsin-Madison

Madison, WI [email protected]

www.cs.wisc.edu/~mulhern/gallimaufry

CLASE 2005

Page 2: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

2

Overview

• Introduction

• Gallimaufry Design: Core

• Gallimaufry Design: Extensions

• Conclusion and Future Work

Page 3: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

3

Type-Safety

• Trapped error An error which causes computation to stop immediately

• Untrapped error An error which may allow computation to continue

• Type safe All type errors are trapped• Statically type safe Type errors detected

at compile time• Well typed Can be assigned a type

Page 4: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

4

Type-Safety: Examples

• Statically type-safe:– ML

• Type-safe:– Java (partly static)– Lisp (entirely non-static)

• Not type-safe:– C (void*)

Page 5: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

5

Static type-safety is good …

• For developers– Many errors are caught at compile time– Code is generally better designed– Less time is spent in debugging

• For users– Better security guarantees – Faster execution

Page 6: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

6

…but has often been overlooked.

• Historical: Legacy of assembly language

• Cultural: Not highly valued by typical user

• Difficult to understand

• Languages are large and complex

• Proving type-safety for a real language is a daunting task

Page 7: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

7

Language Enhancements

• Grow up rapidly around a popular language

• Address limitations in expressiveness

• Redress flaws in design

• Example: O’Caml objects, Java Generics

• Considerations of type-safety are still of secondary importance

Page 8: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

8

Gallimaufry

1. A hash of various kinds of meats, a ragout.2. Any absurd medley; a hodgepodge.3. An automated framework for proving type-safety.

“So now they have made our English tongue a gallimaufry, or hodgepodge of all other speeches.”

- Edmund Spenser (1579)

Page 9: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

9

Gallimaufry

• Core: A proof of type-safety for a base language (SOOL)

• Usage:– User specifies an enhancement to the base

language– Gallimaufry responds with a new proof of type-

safety or an error message

• Status: In development

Page 10: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

10

Java Example: Array Subtyping1)String[] sa = new String[]{"zero"};2)Object[] oa = sa;3)oa[0] = new Integer(0);4)sa[0].charAt(0);

A <: B

A[] <: B[]Array<:

Page 11: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

11

Overview

• Introduction

• Gallimaufry Design: Core

• Gallimaufry Design: Extensions

• Conclusion and Future Work

Page 12: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

12

Gallimaufry Design: Translator

Page 13: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

13

SOOL

Bruce’s Simple Object-oriented Language

class CellClass { x: Integer = 0; function get(): Integer is { return self.x } function set(newVal:Integer): Void is { self.x := nuVal } function bump() : Void is { self <= set(self <= get() + 1}}

Page 14: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

14

Gallimaufry Design: Prover

Page 15: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

15

Proving type-safety of SOOL

• We know: Target lambda calculus is type-safe

• We prove: Translation is correct• We infer: Any well-typed SOOL program

yields a well-typed lambda calculus program

• We conclude: SOOL is type-safe

Page 16: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

16

Correctness of Translation

• Preservation of types– The type of the translated expression is the

translation of the type

• Preservation of subtypes – If a pair of types are in the subtype relation in

SOOL, then their translations are in the subtype relation

Page 17: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

17

Preservation of Types

Page 18: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

18

Preservation of Types

Page 19: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

19

Preservation of Subtypes

Page 20: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

20

Contributions:Translator• Confidence in prover

– Coq structures derived from working translator

• Feedback for implementer (myself)– Working translator unlikely to result from poor

understanding of translational semantics

“Beware of bugs in the above code; I have only proved it correct, not tried it.”

-Donald Knuth

Page 21: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

21

Contributions: Prover

• Language Design and Type-Theory– Automated proof of correctness of Bruce’s

translational semantics

• Proof Techniques– Extraction from O’Caml to Coq– Feedback: How can O’Caml program be

written so that it is easily extracted into Coq structures?

Page 22: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

22

Overview

• Introduction

• Gallimaufry Design: Core

• Gallimaufry Design: Extensions

• Conclusion and Future Work

Page 23: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

23

Gallimaufry Design: Extensions

• User specifies language extension– Syntax– Translation and type rules– Additions to translator

• Gallimaufry– Regenerates Coq structures– Modifies tactics– Generates new proof of type-safety

Page 24: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

24

Gallimaufry Design: Extensions

Page 25: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

25

Gallimaufry Design: Extensions

Userupdatestranslator

Page 26: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

26

Gallimaufry Design: Extensions

Gallimaufry updates Coq structures, tactics, and proof

Page 27: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

27

Contributions: Extension Part

• Automatic verification of type-safety for language extensions – Allow experimentation with language

extensions– Hide proof techniques

Page 28: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

28

Contributions: Extension Part

• Techniques for automatic restructuring of proof tactics

• Techniques for user interaction:– Specifying new syntax and translation– Meaningful errors if extension is not type-safe

• Investigate range of language extensions supported by this technique

Page 29: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

29

Overview

• Introduction

• Gallimaufry Design: Core

• Gallimaufry Design: Extensions

• Conclusion and Future Work

Page 30: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

30

Contributions

• Automated proof of type-safety using a translational semantics

• Tool for interactive experimentation with language design

• Techniques for automated proof (re)generation

Page 31: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

31

Future Work

Complete implementation of translator

Find and use Coq-friendly subset of O’Caml

Develop user-friendly interface for specification.

Page 32: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

32

Future Work

Complete implementation of extractor

Make extraction to Coq structures direct.

Develop sound strategies for modifying tactics.

Page 33: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

33

Future Work

Complete implementation of extractor

Develop useful error message extraction

Page 34: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

34

Future Work

Study range of language extensions supported

Extend to other calculi

Page 35: Gallimaufry

GallimaufryAn Automated Framework for Proving Type-Safety

Anne MulhernComputer Sciences DepartmentUniversity of Wisconsin-Madison

Madison, WI [email protected]

www.cs.wisc.edu/~mulhern/gallimaufry

CLASE 2005

Page 36: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

36

Why Translational Semantics?

• Translation more intuitive concept– Compilation is translation

• User interaction more intuitive– Easier to add additional translation rules

Page 37: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

37

Gallimaufry vs. Krakatoa

Page 38: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

38

Array Example

• Model arrays as objects• [] just syntactic sugar for method• Given an array with elements of type T

– []:int Ref T– Translation of T[] has type

. X ( {[]: int Ref T})

Page 39: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

39

Correctness of Translation

• Preservation of types– The type of the translated expression is the

translation of the type

• Preservation of subtypes – If a pair of types are in the subtype relation in

SOOL, then their translations are in the subtype relation

Page 40: Gallimaufry

CLASE 2005 Gallimaufry: An Automated Framework for Proving Type-Safety

40

Array Example: Subtypes