Giter VIP home page Giter VIP logo

philomath's Introduction

Philomath

Version 1.1 | See also: LCF-style-Natural-Deduction โˆ˜ Maxixe โˆ˜ Cardboard Prolog


Philomath is an LCF-style theorem prover written in ANSI C. It implements classical propositional logic inside a Natural Deduction system with labelled assumptions. For more information on this approach, see the LCF-style-Natural-Deduction article.

How do I write a proof with this?

Create a file myproof.c:

#include "formula.h"
#include "proof.h"
int main(int argc, char **argv) {
    /* Proof of p -> p */
    return proves(
        impl_intro(1, suppose(var("p"), 1)),
        impl(var("p"), var("p"))
    );
}

Then compile and run it with:

./build-proof.sh myproof

And run the resulting executable:

./myproof.exe

If the exit code is 0, the proof is valid!

% echo $?
0

If you wish to build the proof with debugging output, you can pass the -D flag:

./build-proof.sh -D myproof

Limitations

LCF-style theorem proving relies on data abstraction, i.e. information hiding. In C, information hiding is accomplished by exposing, in a header file, only the fact that a struct exists, and not exposing its structure. Client code can then work with pointers to that struct without knowing what's contained in it.

It is however possible to subvert this mechanism. If your proof code does any of the following things, it is possible it is no longer a valid proof:

  • includes the file proof.c directly, rather than including proof.h
  • casts a struct theorem value to some other type
  • casts a value of some other type to a struct theorem

Fortunately, it is possible to statically analyze a C source file and confirm that it does none of these things, if such a level of assurance is desired.

TODO

Should really have even more demo non-proofs, to help ensure that it's not letting non-proofs pass themselves off as proofs somewhere.

History

1.1

  • When creating a struct theorem or struct assumptions, the supplied struct formula * is now cloned (deep-copied) before being stored in the structure. This prevents the theorem from being manipulated after its creation by updating the contents of the struct formula * that was used to create it. Thanks to Proloy Mishra for pointing out this hole.
  • More test cases, and a driver script (test.sh) to run the tests.
  • Added this "History" section to the README.

1.0-2022.0905

  • Renamed struct theorem to struct proof, and proof.{c,h} to theorem.{c,h} to better reflect what these objects are.

1.0

  • Initial release of Philomath.

philomath's People

Contributors

cpressey avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

philomath's Issues

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.