npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

logic-engine

v1.0.1

Published

A logic engine in js / ts

Downloads

5

Readme

Logic Engine

This library provides a logic engine for typescript projects which require clear types and processing for complicated logics. This library can also be used to learn logic and explore its applications and limits.

How to use

This library is written to provide support for logical languages for uses such as performing proofs or formalising natural language processing.

Each formal language makes assumptions and has limitations, over time the goal is to support most of the main formal logical languages.

In order to use the logic engine first install the package

npm install logic-engine

After this, the types and methods of the library will be available for use.

Below are a list of supported languages with details of how to use them.

Languages

First Order

First Order is the language of "classical propositional" logic. The main features of first-order are the following:

WFF

  • Every sentence of First Order is a Well Formed Formula (WFF).
  • WFF's can be either Atom or Complex types.

Atom

  • An Atom is the smallest unit of truth-evaluable proposition in First Order :

      interface Atom {
        unaryOperator: UnaryOperator | undefined;
        proposition?: boolean | (() => boolean);
        value: () => boolean;
      } 
  • The only valid unaryOperator in First Order is '~' for negation.

  • Every proposition is a truth-evaluable statement. As such, this can either be a boolean primitive or an expression which returns a boolean.

  • The value of an atom is a combination of the proposition with the application of the unary operator of negation (if it exists).

Complex

  • A Complex is similar to an Atom, however, it differs insofar as a Complex is a combination of WFF's, joined by a binaryOperator

      interface Complex { 
        unaryOperator: UnaryOperator | undefined;
        left?: WFF;
        binaryOperator?: BinaryOperator;
        right?: WFF;
        value: () => boolean;
      }
  • With a Complex, the left and right WFF's will evaluate to either true or false, these will be combined with a logical operator that will make the statement of the Complex evaluate to true or false (depending on the binary operator). The unaryOperator of negation can still be applied to the whole complex too

Binary Operators

  • Binary Operators combine multiple truth evaluable statement of WFF's into Complexes. For example the "then" in"If it is raining then the floor is when" or the "and" in "2+2=4 and today is Monday"
  • Binary operators combine a left and a right WFF. In the truth table models that follow I shall refer to the left WFF as 'P' and the right WFF as 'Q'.

AND

  • The Syntax for logical AND is '&'

  • Logical '&' has the following truth table

    | P | Q | P & Q | |-------|-------|---------| | True | True | True | | True | False | False | | False | True | False | | False | False | False |

OR

  • The Syntax for logical inclusive OR is '|'

  • Logical '|' has the following truth table

    | P | Q | P | Q | |-------|-------|--------| | True | True | True | | True | False | True | | False | True | True | | False | False | False |

MATERIAL IMPLICATION

  • The Syntax for logical Material Implication is '->'

  • Logical '->' has the following truth table

    | P | Q | P -> Q | |-------|-------|--------| | True | True | True | | True | False | False | | False | True | True | | False | False | True |

BICONDITIONAL

  • The Syntax for logical Biconditional is '<->'

  • Logical '<->' has the following truth table

    | P | Q | P <-> Q | |-------|-------|---------| | True | True | True | | True | False | False | | False | True | False | | False | False | True |

Syntax Engine

  • The SyntaxEngine is for processing strings, json and other types of information into the language of First Order and checking for correct syntax.

In Progress

Evalutation Engine

  • The EvaluationEngine is for evaluating claims made within First Order.

In Progress

Quantifiational

In Progress

Modal Logics

In Progress

Paraconsistent Logics

In Progress