Summary Extending IsabelleHOLs Code Generator with Go arxiv.org
8,324 words - PDF document - View PDF document
One Line
Isabelle/HOL's Code Generator extension allows code extraction in Go by mapping types, terms, and statements while translating type classes into dictionary types.
Slides
Slide Presentation (10 slides)
Key Points
- Isabelle/HOL's Code Generator has been extended to support the Go programming language.
- Go is an imperative language, so Isabelle's functional language had to be emulated using imperative constructs.
- The extension is provided as an add-on library that can be imported into existing theories.
- The intermediate language used by Isabelle's Code Generator is called Thingol, which is translated into the target language.
- The translation scheme for Go involves mapping types, terms, and statements from Thingol to their Go counterparts.
- Type classes in Isabelle are translated into data types representing dictionary types in Go.
- The translation scheme has been successfully evaluated by porting an existing Isabelle formalization from Scala to Go.
- Integrating the generated Go code with a larger codebase may require additional type annotations and careful handling of data structures not natively supported in Go.
Summaries
23 word summary
An extension to Isabelle/HOL's Code Generator enables code extraction in Go. It maps types, terms, and statements, translating type classes into dictionary types.
61 word summary
This paper introduces an extension to Isabelle/HOL's Code Generator that allows users to extract code in the Go programming language. The translation scheme maps types, terms, and statements from Isabelle's intermediate language to Go counterparts. Type classes are translated into dictionary types, and instances are translated into values or functions. Additional type annotations may be needed when integrating with existing codebases.
186 word summary
This paper introduces an extension to Isabelle/HOL's Code Generator that enables support for the Go programming language. Isabelle is an interactive theorem prover with a functional language for writing and reasoning about programs. The existing Code Generator allows users to extract code in different functional languages, and this extension adds Go as a new target language. The translation scheme maps types, terms, and statements from Isabelle's intermediate language, Thingol, to their corresponding Go counterparts. The scheme also handles abstractions, applications, data types, case expressions, and variable patterns. Type classes are translated into data types representing dictionary types, and type class instances are translated into values or functions producing values of the dictionary types. The translation scheme has been successfully evaluated by porting an existing Isabelle formalization from Scala to Go and running the Code Generator test session. However, integrating the generated Go code with a larger codebase may require additional type annotations and careful handling of unsupported data structures. Overall, this extension provides users with the ability to generate Go code from their Isabelle theories, and future work could focus on generating more idiomatic Go code.
432 word summary
This paper presents an extension to Isabelle/HOL's Code Generator that adds support for the Go programming language. Isabelle is an interactive theorem prover that includes a small functional language for writing and reasoning about programs. The existing Code Generator allows users to extract source code in various functional languages, and this work adds Go as a fifth target language. Unlike the previous targets, Go is an imperative language, so many features of Isabelle's language had to be emulated using imperative constructs. The extension is provided as an add-on library that can be imported into existing theories.
The intermediate language used by Isabelle's Code Generator is called Thingol, which is first translated from Isabelle definitions before being transformed into the target language. Thingol supports features common to previous target languages and is based on a simply-typed lambda calculus with ML-style polymorphism. It also supports type classes, which can be mapped to Haskell and Scala but less easily to other targets.
The translation scheme for Go involves mapping types, terms, and statements from Thingol to their Go counterparts. Expressions are translated into Go expressions, while statements are translated into Go statements. Abstractions and applications of top-level functions are handled differently in Go. Data types are translated into struct types for each constructor, along with corresponding destructors. Case expressions are translated into if-conditions and calls to destructors, and variable patterns and constructor patterns are handled separately.
The translation scheme for Go also includes a dictionary construction to handle type classes. Type classes are translated into data types representing the dictionary types, and type class constraints on functions are translated into explicit function arguments of dictionary types. Type class instances are translated into values or functions producing values of the dictionary types.
The translation scheme has been evaluated by porting an existing Isabelle formalization from Scala to Go, as well as running the Code Generator test session with Go as the target language. The results have been successful, with equivalent results obtained and no bugs found in the Code Generator or the generated code. However, integrating the generated Go code with a larger codebase may require additional type annotations and careful handling of data structures not natively supported in Go.
In conclusion, the extension to Isabelle's Code Generator adds support for Go as a target language, allowing users to generate Go code from their Isabelle theories. The translation scheme handles various language features and type classes, and the implementation is readily usable with a standard Isabelle installation. Future work could involve leveraging Go's imperative nature and generating more idiomatic Go code through custom code printing rules.