Skip to content

Core classes, methods and functions for calculating logical formulas and constructing proofs within the Chop Logic project.

License

Notifications You must be signed in to change notification settings

ChopLogic/chop-logic-core

Chop Logic Core

License: MIT codecov Quality Gate Status Conventional Commits Checked with Biome npm

Chop Logic Core is a TypeScript library providing core functions for working with symbolic logic. It is part of the broader Chop Logic project and offers essential utilities for logic processing and deduction.

✨ Features

  • 🛠️ Factory methods for building logical symbols, operators, expressions, and well-formed formulas (WFF).
  • 🔍 Tools for analyzing formulas:
    • Variable extraction
    • Sub-formula extraction
    • Truth table generation
    • Formula evaluation
    • Well-formedness checks
  • ✍️ Inference rules from:
    • Hilbert-style Calculus
    • Natural Deduction Calculus (Introduction & Elimination rules)
  • 🧪 Utilities for formula validation and consistency checks.
  • 🔣 Tokenizer for parsing and handling logical strings.

📦 Installation

You can install chop-logic-core via npm:

npm install chop-logic-core

Or using yarn:

yarn add chop-logic-core

⚙️ Available Scripts

The following npm scripts are available for development and maintenance:

  • npm run build – Build both ESM and CJS versions of the library.
  • npm run prepare – Run build an husky commands.
  • npm run clean – Remove the generated lib folder.
  • npm run check – Run Biome to check for code quality and formatting issues.
  • npm run format – Format all files.
  • npm run fix – Format, lint, and organize imports of all files.
  • npm run test – Run Jest in watch mode.
  • npm run test:ci – Run Jest in CI mode, allowing zero tests to pass.
  • npm run coverage – Generate a test coverage report.
  • release:version – Bumps the version (patch, minor, or major), commits the change, creates a Git tag, and pushes to main. Usage: npm run release:version patch

🔧 Usage

import { ChopLogicCore } from 'chop-logic-core';

const { PropositionalFactory, PropositionalUtils, HilbertCalculus } = ChopLogicCore;
const { createExpression, createFormula } = PropositionalFactory;
const { generateTT, convertToString } = PropositionalUtils;

const expression = createExpression('((A => B) & ~C)');
const formula = createFormula(expression);
const truthTable = generateTT(formula);

const A = createFormula(createExpression('A'));
const implicationAB = createFormula(createExpression('(A => B)'));

const consequent = HilbertCalculus.IE([implicationAB, A]);

const stringView = convertToString(consequent);

🛠 Contributing

Contributions are welcome! If you find a bug or have an idea for improvement, feel free to open an issue or submit a pull request. Please check the Contribution guide for additional info.

  1. Fork the repository.
  2. Clone your fork.
  3. Create a new feature branch.
  4. Implement and test your changes.
  5. Submit a pull request!

📄 License

This project is licensed under MIT. See the LICENSE file for details.

🔗 Links


Let's build better logic tools together! 🚀

About

Core classes, methods and functions for calculating logical formulas and constructing proofs within the Chop Logic project.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 2

  •  
  •