Git Product home page Git Product logo

predicate's Introduction

Predicate

Build Status Coverage Status Go Report Card

Predicate is a simple library for parsing, evaluating and textually representing predicates (boolean functions).

Install

git clone [email protected]:lamg/predicate.git
cd predicate/cmd/reduce && go install

Example

The following table shows some examples of how reduce works. Using standard input and output makes easier typing the boolean operators, since you can use Vim's multibyte input method (ex: C-k OR writes ∨), and then pipe the selected text using the visual mode to the reduce command, or just store the predicates in a file and then use it as standard input to reduce (reduce < file_with_predicates).

Standard input Standard output
true true
¬false true
¬true false
true ∧ false false
false ∧ false false
false ∨ false false
false ∨ true true
¬(true ∧ true) false
¬(true ∧ ¬A) ¬(¬A)
A ∧ A A
true ⇒ false false
A ≡ true A
A ≡ false ¬A
A ≡ A true
A ≡ ¬A false
A ≢ A false
A ⇐ true A
A ≢ false A

Syntax

The syntax is based on EWD1300 which I have formalized in the following grammar:

predicate = term {(''|'') term}.
term = junction ({'' junction} | {'' junction}).
junction = factor ({'' factor} | {'' factor}).
factor =	[unaryOp] (identifier | '(' predicate ')').
unaryOp = '¬'.

Reduction rules

The procedure Reduce applies the following rules while reducing the predicate.

¬true ≡ false
¬false ≡ true
A ∨ false ≡ A
A ∧ true ≡ A
A ∨ true ≡ true
A ∧ false ≡ false
A ∨ B ≡ B ∨ A
A ∧ B ≡ B ∧ A
A ≡ true ≡ A
A ≡ false ≡ ¬A
true ⇒ A ≡ A
false ⇒ A ≡ true
A ⇒ true ≡ true
A ⇒ false ≡ ¬A
A ⇐ B ≡ B ⇒ A
A ≢ B ≡ A ≡ ¬B

predicate's People

Contributors

lamg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

predicate'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.