Section | Example | Statement | File | Name | Simplified |
---|---|---|---|---|---|
Section 3.1 | Example 3.1 | Examples.Decalf.Basic | double |
||
Section 3.1 | Example 3.1 | Examples.Decalf.Basic | double/bound |
||
Section 3.1 | Example 3.1 | Examples.Decalf.Basic | double/has-cost |
||
Section 3.1 | Example 3.1 | Examples.Decalf.Basic | double/correct |
||
Section 3.1 | Example 3.2 | Examples.Sorting.Sequential.InsertionSort | insert |
||
Section 3.1 | Example 3.2 | Examples.Sorting.Sequential.InsertionSort | insert/cost |
✓ | |
Section 3.1 | Example 3.2 | Examples.Sorting.Sequential.InsertionSort | insert/is-bounded |
✓ | |
Section 3.1 | Example 3.4 | Examples.Sorting.Sequential.InsertionSort | sort |
||
Section 3.1 | Example 3.4 | Examples.Sorting.Sequential.InsertionSort | sort/cost |
✓ | |
Section 3.1 | Example 3.4 | Examples.Sorting.Sequential.InsertionSort | sort/is-bounded |
✓ | |
Section 3.1 | Example 3.4 | Examples.Sorting.Sequential.MergeSort | sort |
||
Section 3.1 | Example 3.4 | Examples.Sorting.Sequential.MergeSort | sort/cost |
✓ | |
Section 3.1 | Example 3.4 | Examples.Sorting.Sequential.MergeSort | sort/is-bounded |
✓ | |
Section 3.1 | Theorem 3.5 | Examples.Sorting.Sequential | isort≡msort |
✓ | |
Section 3.2.1 | Example 3.6 | Examples.Decalf.Nondeterminism | sort |
||
Section 3.2.1 | Example 3.6 |
|
Examples.Decalf.Nondeterminism | sort/is-bounded |
✓ |
Section 3.2.1 | Example 3.7 | Examples.Decalf.Nondeterminism | lookup |
||
Section 3.2.1 | Example 3.7 | Examples.Decalf.Nondeterminism | lookup/bound |
||
Section 3.2.1 | Example 3.8 | Examples.Decalf.Nondeterminism | e |
||
Section 3.2.1 | Example 3.8 |
|
Examples.Decalf.Nondeterminism | e/is-bounded |
|
Section 3.2.1 | Example 3.8 |
|
Examples.Decalf.Nondeterminism | e/is-bounded' |
|
Section 3.2.2 | Example 3.9 | Examples.Decalf.ProbabilisticChoice | sublist |
||
Section 3.2.2 | Example 3.9 | Examples.Decalf.ProbabilisticChoice | bernoulli |
||
Section 3.2.2 | Example 3.9 | Examples.Decalf.ProbabilisticChoice | binomial |
||
Section 3.2.2 | Example 3.9 |
|
Examples.Decalf.ProbabilisticChoice | sublist/is-bounded |
|
Section 3.2.2 | Example 3.9 |
|
Examples.Decalf.ProbabilisticChoice | binomial/upper |
|
Section 3.2.2 | Example 3.9 |
|
Examples.Decalf.ProbabilisticChoice | sublist/is-bounded' |
|
Section 3.2.3 | Example 3.10 | Examples.Decalf.GlobalState | e |
||
Section 3.2.3 | Example 3.10 | Examples.Decalf.GlobalState | e/bound |
||
Section 3.2.3 | Example 3.10 | Examples.Decalf.GlobalState | e/has-cost |
||
Section 3.3 | Example 3.11 | Examples.Decalf.HigherOrderFunction | twice |
||
Section 3.3 | Example 3.11 |
|
Examples.Decalf.HigherOrderFunction | twice/is-bounded |
|
Section 3.3 | Example 3.12 | Examples.Decalf.HigherOrderFunction | map |
||
Section 3.3 | Example 3.12 |
|
Examples.Decalf.HigherOrderFunction | map/is-bounded |
|
Section 3.3 | Example 3.12 |
|
Examples.Decalf.HigherOrderFunction | map/is-bounded' |
For simplicity, weaker cost bound proofs (eliding correctness proofs) for the sorting algorithms are given as indicated in the last column, following the original calf development of Niu et al. (2022).
ghc
: we have testedghc
versions 8.10.2cabal
: we have testedcabal
version 3.4.0.0
If you are running a version of Linux or Windows, the easiest way to install ghc
and cabal
is haskell-platform.
For MacOS, GHCup is recommended.
After this, you should have cabal
installed. Check by running cabal --version
on the command line. For us this returns the following:
cabal-install version 3.4.0.0
In theory, any cabal
version that supports installing Agda version 2.6.3 will work.
To use agda-calf
, you will need Agda version 2.6.3. First update the package listing with the following command:
cabal update
Then install Agda:
cabal install Agda-2.6.3
This may take a while. To test your installation, type agda --version
on the command line, which should return Agda version 2.6.3
.
agda-calf
depends on the Agda standard library, so you will need to download the standard library and tell Agda where to look for it.
First download the library:
wget -O agda-stdlib.tar https://github.com/agda/agda-stdlib/archive/refs/heads/master.tar.gz
Extract the tarball, noting the directory that contains the extracted folder agda-stdlib-master
:
tar -zxvf agda-stdlib.tar
Now we need to register the library with Agda.
- If it doesn't exist, create a directory called
.agda
in your home directory (on MacOS and Linux you can domkdir ~/.agda
). - Now in
.agda
, create a file calledlibraries
. - Inside
~/.agda/libraries
, write down the following line, where DIR is replaced with the directory in which you extracted the tarball:
DIR/agda-stdlib-master/standard-library.agda-lib
Clone the repository to a convenient directory:
git clone https://github.com/jonsterling/
agda-calf.git
The directory structure of agda-calf
should be as follows (omitting some files and directories):
agda-calf
└───src
│ └───Calf
│ │ index.agda
│ AEC.md
│ README.md
Note that the files relevant to the claims are all located in the src
directory.
To evaluate a single claim, navigate to the directory containing the file associated with that claim and run agda filename
on the command line.
Because the validity of each claim is equivalent to Agda being able to typecheck the function with no errors, the expected output is that Agda will finish running with no output.
For convenience, we have define a root file src/index.agda that includes all the files contained in agda-calf
, so running agda index.agda
in the directory src
will effectively evaluate all claims at once.
Again, the expected output is that Agda finishes typechecking with no errors or textual outputs.
Note that running agda index.agda
should not take more than a few minutes.
For an overview of the core implementation of agda-calf
, please see the Language Implementation section in the top-level README.md.
We also provide a listing of the case studies on cost verification in agda-calf
in the Examples section; some additional examples are updated from calf to decalf.
We recommend the interested reader to begin with the example Examples.Id
.
One can also view agda-calf
online here: https://jonsterling.github.io/agda-calf/
For writing and verifying new programs in agda-calf
, we recommend using VS Code with the agda-mode extension.