/logic

Java libary, which allows you to use propositional logic in an OO and simple way.

Primary LanguageJavaMIT LicenseMIT

Logic

Quality Gate Status Coverage Lines of Code Code Smells

Bugs Vulnerabilities Security Rating Maintainability Rating Reliability Rating


This is a library to work with logic. Right now only propositional logic is implemented, but more will come. You can use this library to make your logical code more OOP like and readable. For example instead of writing something's like this:

private boolean evaluate() {
    return (!this.a || this.b) || ((this.c && this.b) || (!this.c && !this.b)) || 
        ((this.a && !this.b) || (!this.a && this.b));
}

You can do this instead:

private boolean evaluate() {
    return or(implication(this.a, this.b), xnor(this.c, this.b), xor(this.a, this.b));
}

Features

  • Symbols right now are:
    • ∧: AND
    • ∨: OR
    • ⊼: NAND
    • ⊽: NOR
    • ⟷: XNOR
    • ⊻: XOR
    • ⟶: IMPLICATION
  • You can just use the static functionalities of the logical Symbols
  • You can have multiple input arguments for the symbol
  • You can get the value or compare logical values with Booleans
  • You can get the value or compare logical values as binary String input
  • You can see the truth table of the symbols

Future plans

Not only implement propositional logic but also predicate logic. Then you will create your own predicates and define your own rules to evaluate logical problems.

Then not only Boolean or binary String inputs can be compared but all you could imagine.