GithubHelp home page GithubHelp logo

aayushch23 / msetsextra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fireeye/msetsextra

0.0 1.0 0.0 622 KB

A Coq Library for Efficiently Executable Sets

License: GNU Lesser General Public License v2.1

Coq 12.19% Makefile 0.15% HTML 86.71% CSS 0.50% TeX 0.46%

msetsextra's Introduction

Efficiently Executable Sets Library

Coq (as of version 8.4pl6) provides the module MSetInterface which contains interfaces for sets. There are implementations using sorted and unsorted lists (both without duplicates) as well as AVL and RBT trees for these interfaces. While these implementations - particularly the ones based on binary trees - extract to reasonably efficient code, at FireEye we nevertheless were struggling with performance issues.

This directory contains extensions to Coq's set library that helped us, i.e. the FireEye Formal Methods team ([email protected]), solve these performance issues.

There are the following files

  • MSetWithDups.v (interface definitions for MSetListWithDups.v)

  • MSetListWithDups.v (unsorted Lists with duplicates)

  • MSetIntervals.v (sets implemented as intervals of integers)

  • MSetFoldWithAbort.v (efficient fold operation)

  • readme.md (this readme)

  • LICENSE (license information, LGPL 2.1)

  • Makefile

  • doc/* (high level documentation)

  • coqdoc/* (generated coqdoc documentation)

The Makefile provided is set up to generate documentation as well as process Coq files. The default target proof just processes the Coq files. For convenience coqdoc and a pdf version of top-level documentation is part of the repository. If you want to rebuild them use target doc or target all.

Interval Sets

The file MSetIntervals.v contains an implementation of WSetOn, which is backed by a sorted list of integer intervals. It is very space efficient for large sets that can be represented by a small number of large intervals. There are instantiations of this set for the element types Z, N and nat. Further instantiation can be easily created by the user.

Unsorted Lists With Duplicates

The file MSetListWithDups.v contains an implementation of sets as unsorted lists with duplicates. It has has an O(1) add operation and an O(n) union operation. The price for this is that we allow duplicates and fold is allowed to visit elements multiple times. It is the users responsibility to use this set implementation carefully and avoid adding the same element over and over again. Otherwise, a lot of space is used and performance of operations like filter might become arbitrarily bad.

Since fold is allowed to visit elements multiple times, this set implementation cannot instantiate the standard weak set interfaces (e.g. WSetOn). Therefore, the file MSetWithDups.v provides specialized interfaces for it and establishes the connection of these interfaces with WSetOn.

Fold With Abort

Folding over all elements of a set is a core operation, which has close ties to the concept of iterators in languages like C++. However, while iterators allow early abort, this is not possible with the standard fold operation. As a result, many efficient iterator algorithms become inefficient when implemented via folding.

Fold with abort operations are an answer to this issue. MSetFoldWithAbort.v provides interfaces for a family of such fold with abort operations and use these operations to define operation like a very efficient filter or existence check. The interfaces are instantiated for all of Coq's current set implementations, i.e. for AVL trees, RBT trees, sorted lists and unsorted lists without duplicates. Fold with abort can exploit the binary tree structure. Therefore the binary search tree implementation can skip the most work. Sorted lists are good as well, since the ordering can be used for aborting. For unsorted lists, operations like filter are not optimized, but at least operations like existence checks can abort early.

msetsextra's People

Contributors

mikesiko avatar

Watchers

James Cloos 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.