filecoin-project / devgrants

đź‘ź Apply for a Filecoin devgrant. Help build the Filecoin ecosystem!
Other
372 stars 308 forks source link

Open Grant Proposal: Agda formalization of Lurk #1416

Closed fare closed 1 year ago

fare commented 1 year ago

Open Grant Proposal: Agda formalization of Lurk

Name of Project: Agda formalization of Lurk

Proposal Category: Choose one of devtools-libraries Proposer: fare

(Optional) Technical Sponsor: porcuquine

Do you agree to open source all work you do on behalf of this RFP and dual-license under MIT or APACHE2 licenses?: Yes

Project Description

We propose to develop an Agda Library to formally reason about the execution of Lurk programs. It may be used to prove the properties of particular Lurk programs or to investigate their properties in general.

This proposed formalization is one of several prerequisites to verify the correctness of the compiler directly. The other prerequisites will be a formalization of the underlying zk-SNARK execution model, and a bridge between this high-level semantics of Lurk and that low-level semantics of zk-SNARKs.

This library will embed Lurk code into Agda and allow the writing of formally verified Lurk programs using interactive Agda mode. This result will be easily translatable to other proof assistants based on similar foundations (Coq, Lean)

Our library will enable reasoning about arbitrary Lurk code. However, it will also provide a set of theorems that apply to programs that satisfy various optional restrictions. For instance, we will automatically prove basic properties of well-typed recursive functions that operate only on “data-type” like values, such as termination, absence of runtime errors, necessary predicates about arguments, and predicates about return value.

Value

Formally verifying smart contracts can prevent dramatic security issues: most of the time, these issues entail the loss of assets entrusted to the smart contracts.

To assure that a smart contract is safe, the possible outcomes of the contract should be checked using mathematical methods to ascertain about two facts:

When successfully implemented, this formal verification library for Lurk will help avoid whole classes of bugs, including among others:

Deliverables

The final deliverable, will be a library providing a formalization of Lurk by embedding Lurk into Agda.

The scope of this formalization will cover :

The functionality of the formal verification library will also include:

Development Roadmap

Initial analysis (2 weeks)

We will produce the detailed design of the library, showcasing possible functionalities together with an assessment of the workload necessary to implement them.

We are confident that the proposed budget will be sufficient to implement a self contained formalization, but still, we can shift emphasis between features according to the priorities set by the Lurk team.

We will consult with the Lurk team and prepare one example of a Lurk program together with its properties that we want to later prove.

Reasoning about the Lurk code (4 weeks)

The following tools will be developed to reason about Lurk values so as to express the desired properties of Lurk programs:

During translation from S-expression-based representation, witnesses of proofs will be embedded into AST, which is more fine-grained and have separate nodes for different Lurk control structures (something like https://github.com/Glow-Lang/glow2-haskell/blob/9439e74ccf545ecd88b76dce110e30c73f128f14/glow/lib/Glow/Ast/Targets/Lurk.hs#L15, but with additional fields to allow decoration of AST with witnesses of desired properties)

Reasoning about the execution of Lurk (4 weeks)

Representation for the Lurk environment

Total Budget Requested

The above plan totals 11 weeks of work, at a cost of $97,500 ($88,000 development costs + $9,500). Payment for each milestone would be expected half at the beginning and half at the end.

Maintenance and Upgrade Plans

Maintenance will mainly focus on ensuring that the state of the library matches exactly the constantly evolving Lurk language and Filecoin ecosystem.

While the work proposed for this project will result in an Agda Library suitable for real world applications by experts, MuKn is interested in continuing work to ensure its wider adoption by: expanding the toolset for writing formally verified proofs about Lurk programs. creating more examples of verified Lurk programs. creating a library of verified Lurk snippets developing a framework to compose them into more complicated Lurk programs, and developing their proofs producing high quality learning materials and tutorials introducing developers to an effective workflow to develop formally verified Lurk applications.

Team

Team Members

Team Website

Relevant Experience

Relevant previous work by our contributors are listed in our Wiki:
https://github.com/Glow-lang/glow/wiki/Bibliography-Glow

Moreover, individual Glow contributors’ biographies can be found on
our company website.

Team code repositories

https://github.com/Glow-Lang/glow

https://github.com/MuKnIO/glow Glow language for Safe Decentralized Applications https://github.com/Glow-Lang/glow2-haskell WIP retargetable/portable backend for glow, written in Haskell. https://github.com/Glow-Lang/glow2-haskell/tree/glow-on-lurk-prototype/agda/Glow WIP formalization of Glow in agda

ErinOCon commented 1 year ago

Hi @fare, thank you for your proposal. Unfortunately, we will not be moving forward with a grant at this time. Wishing you the best of luck as you continue building!