Giter VIP home page Giter VIP logo

coq_codewars's Introduction

A Coq plugin for Codewars

Installation

Create a make file:

coq_makefile -f _CoqProject -o Makefile

Now run make.

Extra

Run make .merlin to create the .merlin file.

New Vernacular Commands

  • CWAssert string? qualid Assumes qualid*

    This command fails if the tested qualid depends on an axiom which is not listed after Assumes:

    CWAssert "Testing lemma" lemma Assumes proof_irrelevance functional_extensionality.

    The string argument after CWAssert is an optional message.

  • CWAssert string? qualid : term

    Checks if the type of qualid is convertible to the type given by term.

    CWAssert "Testing type" lemma : (forall x, x > 0).

    The string argument after CWAssert is an optional message.

    Note that the term should be in parentheses.

  • CWStopOnFailure 0/1

    This command controls whether Coq execution should be stopped after a failed test (1) or not (0). The default behavior is to stop after the first failed test.

  • CWGroup string

    Begins a group of tests (outputs <DESCRIBE::>).

    Groups can be nested. But all tests should be performed after CWTest in nested groups.

  • CWEndGroup

    Ends a group of tests.

  • CWTest string

    Begins a test case (outputs <IT::>).

    Test cases cannot be nested.

  • CWEndTest

    Ends a test case. This command is optional before CWTest and CWEndGroup.

  • CWFile string? Size < int

    Tests if the size of a file (the first string argument) is less than the second argument.

    The file name is optional. The default file is the solution file.

  • CWFile string? Matches string

    Tests if the content of a file matches a regular expression (the second argument). The regular expression syntax is OCaml Str (\ should not be escaped).

  • CWFile string? Does Not Match string

    Tests if the content of a file does not match a regular expression (the second argument).

  • CWCompileAndRun ocaml_files* Options options? Driver driver_string

    Compiles and runs given ocaml_files and the driver code driver_string. The compilation is performed with ocamlc and with the provided options.

    Require Extraction.
    Extraction "out.ml" plus.
    CWCompileAndRun "out.mli" "out.ml" Options "-I . -verbose" Driver "
      open Out
      let () = assert (add O (S O) = (S O))
    ".

Examples

See cw_example/SolutionTest.v and cw_example_extraction/SolutionTest.v

More examples are in theories/Demo.v and theories/Demo2.v.

Compiling demo files:

coqc -I src -R theories/ CW theories/Demo.v
coqc -I src -R theories/ CW theories/Demo2.v

coq_codewars's People

Contributors

kazk avatar monadius avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coq_codewars's Issues

CWGroup fails to form nested test groups

Suppose I have the following test suite:

Require Solution.
Require Import Preloaded Check FunctionalExtensionality.
From CW Require Import Loader.

CWGroup "Solution.bubblesort_correct".
  CWGroup "should have the correct type".
    Goal True.
      check_type Solution.bubblesort_correct (is_a_sorting_algorithm bubblesort).
    Abort.
  CWEndGroup.
  CWGroup "should not assume any axioms other than (dependent) functional extensionality".
    CWTest Solution.bubblesort_correct Assumes functional_extensionality_dep.
  CWEndGroup.
CWEndGroup.

I'd assume that it would give the following structured output:


Solution.bubblesort_correct

  • should have the correct type
    • Solution.bubblesort_correct : Type is correct
  • should not assume any axioms other than (dependent) functional extensionality
    • Axiom Test

But instead, the top-level test group ("Solution.bubblesort_correct") doesn't show at all and the two sub-groups end up at the top level instead:

螢幕截圖 2019-07-19 13 19 26

Extraction tests (for complexity of algorithms)

Hello,

This is a feature request to add commands inside the plugin (or elsewhere in the tool?) which could compile and execute extracted code. The idea is to use that to test the complexity of algorithms given by users.

I don't know how code is executed inside this plugin but what would be enough for my usage is to redirect the Coq output to some files, then add some text, and compile/execute this file.

coqc mytest.v > extracted_code.ml &&
echo "let () = my_function(my_input)" >> extracted_code.ml &&
ocamlc -I zarith extracted_code.ml -o extracted_code.exe &&
./extracted_code.exe > /dev/null

Note that a command for compiling extracted code directly inside Coq already exists: Extraction TestCompile. I don't know if this can be useful ?

This is, of course, a very low priority problem.

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.