Code Monkey home page Code Monkey logo

permutation-solver's Introduction

permutation-solver

A tactics for solving goals about permutation in Coq proof assistant.

Motivation

When I was attacking the problems in Verified Functional Algorithms by Andrew W. Appel, I constantly found that I need to prove some theorems about Permutation.

A typical example should be,

Example butterfly : forall b u t e r f l y : nat,
  Permutation ([b;u;t;t;e;r]++[f;l;y]) ([f;l;u;t;t;e;r]++[b;y]).

This theorem should be trivial in a very first glance, but proving it in Coq turns out to be rather tedious. Coq defines permutation in terms of swapping adjencent elements, so you need to find an element-swapping order to solve this goal. This kind of proof method is boring and lengthy to develop.

Idea

Coq actually provides another way to define permutation. Here, the basic idea is, two lists are considered as permutation of each other, if and only if all elements have the same multiplicity in both lists. This property is proven as a part of Coq's standard library.

With this theorem, we transform the problem of proving permutation to simple multiplicity calculation, which is easy to be automated via Omega tactics in Coq. This should work, since list appending is transformed into multiplicity addition in this way, solving equations over the group of natural numbers with addition should be trivial.

Implementation

Provide a tactics permutation_solver to attack permutations, which turns all Permutations in hypotheses and goals to multiplicity calculation. Using it is rather simple.

Goal
  forall (a b c d e : list nat) (x y : nat),
    Permutation (a ++ e) (x :: c) ->
    Permutation b (y :: d) ->
    Permutation (a ++ b ++ e) (x :: y :: c ++ d).
Proof.
  intros; permutation_solver.
Qed.

permutation-solver's People

Contributors

foreverbell 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.