pystc

A simple but extensible Python module for sentences


Keywords
logic, artificial, intelligence, formal-semantics, linguistics, natural-language-understanding, pragmatics, sentence
License
MIT
Install
pip install pystc==2.0.0

Documentation

pystc: A simple but extensible Python module for sentences

Introduction

A sentence is an atomic sentence or a (compound) sentence. An atomic sentence consists of a predicate and constants the predicate has as its arguments. There is no variable, no function. The number of arguments of a predicate is called the arity of the predicate. A compound sentence can be obtained by joining sentences with connectives.

pystc is a simple but extensible Python module for sentences. It provides functionality to define sentences as you like by adding constants, predicates, and connectives, whether logical or non-logical. Constants, predicates, and connectives can be introduced by specifying their names and how they are associated with other well-defined objects or functions.

Installation

$ pip install pystc

Usage

Let us first create atomic sentences that can be built from a predicate = and constants T, F,

Let us next construct compound sentences. A Sentence in pystc module is simply a recursive type defined to be:

Although it is loosely defined for simplicity, sentences are implicitly expected to fall into one of the following cases:

  1. An AtomicSentence object, say s2.
  2. The string representation of an AtomicSentence object, say "=(T,F)".
  3. A tuple such that the initial entry is a connective name and the other entries are Sentence objects, say ("&", s2, ("!", s2)).

As the connective names "&" and "!" appears just above, let us introduce these connectives in the following codeblock and inteprete sentences.

For another example of usage, let us convert sentences into strings in infix notation.

Let us not forget to clear class variables after everything is finished.

Bugs/Requests/Discussions

Please report bugs and requests from GitHub Issues , and ask questions from GitHub Discussions .

License

Please see LICENSE .