Git Product home page Git Product logo

pythogic's Introduction

Pythogic

DEPRECATED

The development and the support are temporarily suspended.

image

image

image

Documentation Status

image

MIT License

Codecov coverage

Status: Development

Python package for deal with logical formulas and formal systems.

Usage

First of all, create symbols and an alphabet

from pythogic.base.Alphabet import Alphabet
from pythogic.base.Symbol import Symbol

a_sym = Symbol("a")
b_sym = Symbol("b")
c_sym = Symbol("c")
alphabet = Alphabet({a_sym, b_sym, c_sym})
# you can also write:
alphabet = Alphabet.fromStrings({"a", "b", "c"})

Create some formulas:

from pythogic.base.Formula import AtomicFormula, TrueFormula, FalseFormula, Not, And, Or

# Propositions
a = AtomicFormula(a_sym)
b = AtomicFormula(b_sym)
c = AtomicFormula(c_sym)

# Elementary formulas
not_a = Not(a)
not_a_and_b = And(Not(a), b)
not_a_or_c = Or(not_a, c)
true = TrueFormula()
false = FalseFormula()

Using Propositional Calculus:

from pythogic.pl.PL import PL
from pythogic.pl.semantics.PLInterpretation import PLInterpretation

# A dictionary which assign each symbol to a truth value
symbol2truth = {
        a_sym: True,
        b_sym: False,
        c_sym: True
    }

# The propositional interpretation
I = PLInterpretation(alphabet, symbol2truth)

# main class which contains useful methods
PL = PL(alphabet)

PL.truth(a, I)              # returns true
PL.truth(b, I)              # returns false
PL.truth(c, I)              # returns true
PL.truth(not_a, I)          # returns false
PL.truth(not_a_and_b, I)    # returns false
PL.truth(not_a_or_c, I)     # returns true
PL.truth(true, I)           # returns true
PL.truth(false, I)          # returns false

Features

  • Compose logical formula by common syntax rules;
  • Implementation of several semantics (FOL Interpretation, finite trace, etc.);
  • Support for several logical formal systems: Propositional Logic, First-order Logic, REf, LTLf, LDLf;

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Many thanks to PySimpleAutomata for the automata support. .. _PySimpleAutomata: https://github.com/Oneiroe/PySimpleAutomata

pythogic's People

Contributors

codacy-badger avatar marcofavorito avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.