https://github.com/dafny-lang/compiler-bootstrap

A work-in-progress reimplementation of Dafny's compiler, in Dafny

https://github.com/dafny-lang/compiler-bootstrap

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

A work-in-progress reimplementation of Dafny's compiler, in Dafny

Basic Info
  • Host: GitHub
  • Owner: dafny-lang
  • License: mit
  • Language: Dafny
  • Default Branch: main
  • Size: 1.63 MB
Statistics
  • Stars: 6
  • Watchers: 8
  • Forks: 1
  • Open Issues: 14
  • Releases: 1
Created about 4 years ago · Last pushed over 2 years ago
Metadata Files
Readme License

README.rst

================
 Dafny in Dafny
================

A work-in-progress reimplementation of Dafny's compilers, in Dafny.

Trying it out
=============

Clone this repository as part of the ``compiler-bootstrap`` branch of the main Dafny repository, then use ``make tests`` or ``make repl`` (and read through the `Makefile <./GNUmakefile>`__ to see all the steps).  Alternatively, if you cloned this repo on its own, ``make`` will complain and ask you how to select which Dafny to run for bootstrapping.

Overview
========

- First we generate definitions to model the existing |DafnyAst.cs|_ in Dafny.  The result is ``src/Interop/CSharpDafnyModel.dfy``.

- Then we write a compiler in Dafny against this interface in |Compiler.dfy|_.

- Then we compile that to C# using the existing compiler, and link it with a `wrapper <./src/Backends/CSharp/EntryPoint.cs>`__ to get a Dafny compiler plugin.

Supported language
------------------

Our initial target is the purely functional subset of Dafny (aka non-ghost functions).  This is also the subset that the compiler is written on (our first large application will be bootstrapping the compiler itself).
The Dafny-in-Dafny AST is defined in ``src/AST.dfy``.  We have operational semantics for most of it in ``src/Semantics/Interp.dfy``.  The C# backend is in ``src/Backends/CSharp/Compiler.dfy``, but it is not up-to-date (we are focusing on the language and the semantics).

Tools
-----

The Dafny in Dafny code base supports two key executable programs:

* A REPL, for interactively evaluating Dafny statements, in ``src/REPL``.

* An auditor plugin, for reporting assumptions in a Dafny program, in ``src/Tools/Auditor``.

Design notes
------------

For details on how we interop with the existing C# codebase, read through https://github.com/dafny-lang/dafny/pull/1769.

Project hierarchy
=================

``src/``
  ``AST/``
    ``Syntax.dfy``
      Dafny expressions and statements
    ``Entities.dfy`` (TODO)
      Dafny classes, modules, methods, and functions
    ``Translator.dfy``
      Translation from ``DafnyAST.cs`` to our own AST and entities
    ``Predicates.dfy``
      Predicates on expressions
  ``Semantics/``
    ``Values.dfy``
      Dafny runtime values
    ``Printer.dfy``
      Converter from values to strings
    ``Interp.dfy``
      Operational semantics for the pure subset of Dafny
    ``Equiv.dfy``
      Definition of program equivalence based on ``Interp.dfy``
  ``Transforms/``
    ``Generic.dfy``
      Basic definitions for AST transformers
    ``BottomUp.dfy``
      Bottom-up rewriter
  ``Passes/``
    ``Pass.dfy``
      Definition of a compiler pass
    ``EliminateNegatedBinops.dfy``
      Simple demo pass
  ``REPL/``
    ``Repl.dfy``
      Driver for a REPL build on top of ``Interp/``
    ``REPLInterop.cs``
      Helper functions for ``Repl.dfy``
  ``Backends/``
    ``CSharp/``
      ``Compiler.dfy``
        C# compiler
      ``EntryPoint.cs``
        C# wrapper around ``Compiler.dfy``
  ``Interop/``
    ``CSharpDafnyASTInterop.dfy``
      Extern declarations for functions that deal with Dafny AST nodes and cannot be implemented in pure Dafny
    ``CSharpDafnyASTInterop.cs``
      Implementations for ``CSharpDafnyASTInterop.dfy``
    ``CSharpDafnyInterop.dfy``
      Extern declarations for functions that deal with Dafny types and cannot be implemented in pure Dafny
    ``CSharpDafnyInterop.cs``
      Implementations for ``CSharpDafnyInterop.dfy``
    ``CSharpInterop.dfy``
      Extern declarations for functions that deal with C# types and cannot be implemented in pure Dafny
    ``CSharpInterop.cs``
      Implementations for ``CSharpInterop.dfy``
    ``CSharpDafnyModel.dfy.template``
      Template used by ``AutoExtern`` to generate a Dafny model from ``DafnyAST.cs``.  This includes extern declarations for existing C# functions from Dafny's codebase.
    ``CSharpModel.dfy``
      Extern declarations for C#'s standard library (automatically copied from ``AutoExtern``)
  ``Tools/``
    ``Auditor/``
      ``Auditor.dfy``
        An auditor to identify assumptions in a Dafny program.
      ``EntryPoint.cs``
        The C# entry point that enables the auditor to be used as a plugin from Dafny.
      ``Report.dfy``
        The ``Report`` data structure used by the auditor.
  ``Utils/``
    ``Library.dfy``
      Utility functions (should move to shared library)
    ``StrTree.dfy``
      Tree of strings (for efficient concatenation).
``GNUmakefile``
  Build configuration

.. |Compiler.dfy| replace:: ``src/Backends/CSharp/Compiler.dfy``
.. _Compiler.dfy: ./src/Backends/CSharp/Compiler.dfy

.. |DafnyAst.cs| replace:: ``DafnyAst.cs``
.. _DafnyAst.cs: https://github.com/dafny-lang/dafny/blob/dind/Source/Dafny/AST/DafnyAst.cs

Owner

  • Name: Dafny
  • Login: dafny-lang
  • Kind: organization

Dafny is a verification-aware programming language

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 21
  • Total pull requests: 13
  • Average time to close issues: 29 days
  • Average time to close pull requests: 20 days
  • Total issue authors: 5
  • Total pull request authors: 5
  • Average comments per issue: 0.38
  • Average comments per pull request: 0.85
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • atomb (12)
  • cpitclaudel (4)
  • sonmarcho (3)
  • fabiomadge (1)
  • jtristan (1)
Pull Request Authors
  • atomb (5)
  • cpitclaudel (3)
  • sonmarcho (3)
  • MikaelMayer (1)
  • jtristan (1)
Top Labels
Issue Labels
documentation (1)
Pull Request Labels
documentation (1)

Dependencies

.github/workflows/build.yml actions
  • actions/checkout v2 composite
  • actions/setup-dotnet v1.9.0 composite
src/Tools/Auditor/DafnyAuditor.csproj nuget
  • DafnyPipeline 3.10.0.41215
  • DafnyRuntime 3.10.0.41215
src/Backends/CSharp/CSharpCompiler.csproj nuget
src/REPL/REPL.csproj nuget
src/Tools/Validator/Validator.csproj nuget