Git Product home page Git Product logo

lets-prove-leftpad's People

Contributors

07151129 avatar 17451k avatar alperaltuntas avatar davecturner avatar ezrakilty avatar gabriel-fallen avatar gallais avatar graydon avatar hako avatar hwayne avatar icecream17 avatar kanigsson avatar kini avatar louy2 avatar mpu avatar muenchnerkindl avatar porglezomp avatar pron avatar ranjitjhala avatar reedoei avatar shapr avatar suhr avatar tirix avatar tjoppen avatar valpackett avatar vthriller avatar waldyrious avatar wilfred avatar will62794 avatar zac-hd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lets-prove-leftpad's Issues

Cryptol Version?

Hi! Thanks very much for this repo & your write-up, I really enjoy them.

Would a Cryptol version be welcome? Here's a first attempt at one:

module leftpad where

leftpad: {pad, in, out}
         (fin pad, fin in, fin out, pad >= in, out == max pad in) =>
         Char -> String in -> String out
leftpad c s = repeat`{pad - in} c # s

leftpadLength: {pad, in, out}
         (fin pad, fin in, fin out, pad >= in, out == max pad in) =>
         Char -> String in -> Bit
property leftpadLength c s = length (leftpad`{pad, in, out}c s) == `out

leftpadPrefix: {pad, in, out}
               (fin pad, fin in, fin out, pad >= in, out == max pad in) =>
               Char -> String in -> Bit
property leftpadPrefix c s = take`{pad - in}(leftpad`{pad, in, out}c s) == repeat`{pad - in}c

leftpadSuffix: {pad, in, out}
               (fin pad, fin in, fin out, pad >= in, out == max pad in) =>
               Char -> String in -> Bit
property leftpadSuffix c s = drop`{pad - in}(leftpad`{pad, in, out}c s) == s

Though the cryptol REPL can prove things via the :prove command, it "cannot directly prove polymorphic properties as they may hold for certain monomorphic instances while not for others." For instance,

┏━╸┏━┓╻ ╻┏━┓╺┳╸┏━┓╻
┃  ┣┳┛┗┳┛┣━┛ ┃ ┃ ┃┃
┗━╸╹┗╸ ╹ ╹   ╹ ┗━┛┗━╸
version 2.13.0
https://cryptol.net  :? for help

Loading module Cryptol
Cryptol> :l leftpad.cry
Loading module Cryptol
Loading module leftpad
leftpad> :prove leftpadLength
Not a monomorphic type:
{pad, in, out}
  (fin pad, fin in, fin out, pad >= in, out == max pad in) =>
  [8] -> [in][8] -> Bit
(Total Elapsed Time: 0.000s)
leftpad> :prove leftpadLength`{10,3,10}
Q.E.D.
(Total Elapsed Time: 0.019s, using "Z3")

This can be nice in some respects; for instance, :prove leftpadLength`{10,3,0} throws an error about the unsolvable constraint 0 == 10. That said, I'm not sure needing explicitly specify pad, in, and out yourself fulfills the spirit of this challenge.

Thanks again!

Rust example

I proved leftpad in rust, using creusot: https://github.com/suhr/leftpad

How to verify:

  • cargo creusot --span-mode=absolute -- --features=contracts
  • «creusot repo»/ide target/debug/leftpad-rlib.mlcfg

NB: you need to apply “Split VC” on the leftpad VC to avoid CVC5 timeout.

Creusot is a research software, so I'm not sure if I should make a PR yet.

Add summary statistics about different proofs

I found this repository incredibly interesting.

I think it would be very informative to extract some kind of naive summary statistics (e.g. LOC) to understand the compromises between different proof systems.

As an old user of Spec#, Dafny's precursor, I was pleasantly surprised to see how well Dafny and other systems (e.g. Lean, Agda, F*, Coq/SSReflect or Idris) compare to Isabelle or Liquid Haskell.

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.