Giter VIP home page Giter VIP logo

understanding-k-framework's Introduction

Understanding K Framework Exercises

Prepared for: HelloDecentralization 2021

Presentation: Presentation

Setup

Building a Language

Exercise 1: Calculator

Use functional fragment of K to correctly compute integer arithmetic expressions. Examples in tests/calc.

Exercise 2: Calculator with Boolean Expressions

Remaining in the functional fragment of K, extend the calculator to deal with boolean expressions too. Examples in tests/calc-bool.

Exercise 3: Variables in Expressions, Explicit Substitution

Now we must move to the stateful fragment of K, which requires adding a configuration. We can hardcode some variable values in the configuration for now, to allow using them in programs. Examples in tests/subst.

Exercise 4.1: Assignment Operator

Updating the entire definition each time to change variable values is impractical. Instead, we should provide a way for the user to update them instead. For this, we'll add statements, statement sequencing, and an assignment operator. Examples in tests/assignment.

Exercise 4.2: Assignment Operator

Now re-do the assignment operator, but using strict instead of substitution for expression evaluation.

Exercise 4.3: Assignment Operator

Now re-do the assignment operator, but using contextual functions instead of substitution for expression evaluation.

Exercise 5: Control Flow

We want to be able to have branches and loops in our programs, to do anything interesting. For that, we'll add an if statement, and a while loop. Examples in tests/control-flow.

Exercise 6: Procedures

We can add procedures to our language to be able to bundle up chunks of code and call them in other expressions. Examples in tests/procedures.

Getting Started With Proofs

In the directory tests/control-flow, there are some specifications which can be proven against the final definition. You must first kompile with Haskell backend kompile --backend haskell .... Then you can run proofs using kprove tests/control-flow/*-spec.k. Additionally you can step through the proofs in the debugger using kprove --debugger tests/control-flow/*-spec.k. To make pretty printing of definitions possible, run the command alias konfig = config | kast --input kore --output pretty /dev/stdin inside the repl.

understanding-k-framework's People

Contributors

ehildenb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.