Paraconsistent Library

This repository consists of a Python Library designed to help users apply paraconsistent annotated evidential logic (PALet), also known as paraconsistent annotated logic by 2-values (PAL2v), making advanced logic tools accessible and encouraging practical adoption.

How to reference the project:

At EAILab, our mission is to promote science and the use of artificial intelligence. Therefore, if you use the library in academic work, we would be very grateful if you could cite us, helping to further spread and promote the project.

DA CRUZ, Diego Oliveira; ALVES, Bruno. Da Silva; CARVALHO JUNIOR, Arnaldo. Paraconsistent-Lib, Python Library, EAILAB, IFSP, Sao Paulo - Brazil, 2025.

Overview

Paraconsistent logic (PL) is a type of logical reasoning that is interesting to deal with contradictory signals because, contrary to classical logic, it does not consider a contradiction as a foundation for invalidating the entire inference system. PL enables the quantification of the degree of contradiction and certainty of information, allowing conflicting data to be processed in a controlled manner and without loss of consistency.

Read more about

Main Features:

How to install

Requirements: Python 3.9 or higher

The installation is done via pip. To install, simply type the following command in your terminal:

pip install paraconsistent

Theory of Logic

PAL2v works with two degrees of evidence:

From these values, the following are calculated:

Decision Output:

Complementary Metrics

Radial Distance:

Degree of Real Certainty:

Resulting Evidence:

Certainty Interval:

Logical State Regions

PAL2v defines 12 regions in the unit square of annotation (QUPC), and your answer will be in one of those regions.

QUPC - Unit Square of Annotation showing 12 logical state regions

Extreme States:

Transition States:

User Guide

First of all, to create a block, write this:

from paraconsistent.blocks import ParaconsistentBlock

# Create block with default values
block = ParaconsistentBlock()

Configure the block parameters:

from paraconsistent.blocks import ParaconsistentBlock
block = ParaconsistentBlock()

# Configure certainty control limit (FtC)
block.config.FtC = 0.70

Set Inputs (μ, λ):

# Define levels of evidence
block.input.mu = 0.80  # Favorable evidence
block.input.lam = 0.20  # Unfavorable evidence

How to display the results:

# Access individual results
dc = block.complete.dc      # Degree of Certainty
dct = block.complete.dct    # Degree of Contradiction
muER = block.complete.muER  # Real Evidence
label = block.complete.label  # Logical Region

# Or print all results
block.print_complete()

How to Connect Multiple Blocks

# Create a network of two blocks
b1 = ParaconsistentBlock()
b2 = ParaconsistentBlock()

# Configure block 1
b1.config.FtC = 0.70
b1.input.mu = 0.80
b1.input.lam = 0.30

# Use the output of b1 as the input of b2
b2.input.mu = b1.complete.muER
b2.input.lam = 1 - b1.complete.phi

# Result propagated automatically
print(f"Final state: {b2.complete.label}")

API Reference

Builder

ParaconsistentBlock(
    *,
    mu: float | None = None,
    lam: float | None = None,
    **param_overrides
)

Parameters:

Configuration (config)

Parameter Type Range Default Description
FtC float [0, 1] 0.50 Certainty Tolerance Factor (Certainty Control Limit)

The FtC input parameter modifies the shape of the QUPC by adjusting the geometry of the Lattice (green line). As an example, we have two images: when FtC is 0.75, it reduces the areas of t and F while expanding the regions of T and Paracomplete; however, when FtC is 0.25, it increases the areas of t and F and decreases those of T and Paracomplete.

QUPC diagram with FtC = 0.75 showing reduced t and F areas

Example FtC = 0.75

QUPC diagram with FtC = 0.25 showing expanded t and F areas

Example FtC = 0.25

Note: The values VSSC, VICC, VSSCT, and VICCT are automatically calculated based on FtC.

Inputs

# Method 1: Direct assignment
block.input.mu = 0.80
block.input.lam = 0.20

# Method 2: Functional approach
block.input(mu=0.80, lam=0.20)

Values are automatically clamped in the range [0, 1].

Outputs (Complete)

Field Type Range Description
mufloat[0, 1]Favorable level of evidence
lamfloat[0, 1]Unfavorable level of evidence
dcfloat[-1, 1]Degree of Certainty: μ - λ
dctfloat[-1, 1]Degree of Contradiction: μ + λ - 1
dfloat[0, ∞)Raw radial distance
Dfloat[0, 1]Normalized radial distance
dcrfloat[-1, 1]Degree of Real Certainty: (1 - D) × sign(dc)
phifloat[0, 1]Certainty interval: 1 - |dct|
phiEfloat[0, 1]Certainty interval (alias of phi)
muEfloat[0, 1]Resulting evidence: (dc + 1) / 2
muECTfloat[0, 1]Contradiction evidence: (dct + 1) / 2
muERfloat[0, 1]Real evidence: (dcr + 1) / 2
decision_outputfloat{0.0, 0.5, 1.0}Binary decision output
labelstr-Logical region label (t, f, ┬, ┴, etc.)
Regionsdict-Boolean flags per region
FtCfloat[0, 1]Echo of parameters used in the calculation

Methods

# Export as a typed dictionary
result: Complete = block.to_dict()

# Print formatted to the console
block.print_complete()

# Set FtC parameter
block.set_params(FtC=0.7)

Examples of a paraconsistent analysis network project using the library

Flowchart diagram showing paraconsistent analysis network with NAP1, NAP2, and NAP3 blocks

Flowchart of the following example

# Paraconsistent Library developed by Diego Oliveira da Cruz - EAILAB - IFSP
# Oriented by Dr. Arnaldo de Carvalho Junior - EAILAB-IFSP
# Date: 04/nov/2025

# Installing PAL2v Library
%pip install pythonping paraconsistent

# Paraconsistent Analysis Network (PANnet)
# Created by: Dr. Arnaldo de Carvalho Junior
# Date: 04/11/2025
# Example application of the Paraconsistent-Lib Library

# Calls the Paraconsistent Library
from paraconsistent import ParaconsistentBlock

# 1) Create the PAN blocks
PAN1 = ParaconsistentBlock()
PAN2 = ParaconsistentBlock()
PAN3 = ParaconsistentBlock()

# 2) Adjust the Certainty Factor parameter (affects the geometry of the 12 paraconsistent logical states)
# Reference value: 0.5
PAN1.config.FtC = 0.5
PAN2.config.FtC = 0.5
PAN3.config.FtC = 0.5

# 3) Define the mu and lambda
PAN1.input.mu = 0.45
PAN1.input.lam = 0.76
PAN2.input.mu = 1.00
PAN2.input.lam = 0.40
PAN3.input.mu = NAP1.complete.muER
PAN3.input.lam = 1 - NAP2.complete.muER

# Output of the Paraconsistent Analysis Network
print(f"Result of the PAL2v Analysis = {PAN3.complete.muER:.3f}")

More examples:

Architecture

├── blocks/
│   └── block.py — ParaconsistentBlock class
├── core/
│   ├── config.py — Configuration and validation
│   ├── engine.py — Calculation engine
│   ├── metrics.py — Geometric metrics
│   ├── labels.py — Region classification
│   └── types.py — Type definitions
└── __init__.py

Calculation Flow

  1. Input: Validation and clamping of μ and λ
  2. Main Degrees: Calculation of dc and dct
  3. Geometry: Calculation of d, D, and dcr
  4. Evidence: Calculation of μE, μECT, μER, and φ
  5. Decision: Comparison of μER with FtC
  6. Classification: Identification of the logical region

Cache and Performance

The system features an intelligent caching mechanism that automatically refreshes whenever inputs or parameters are modified, guaranteeing result consistency while maintaining optimal performance.

License

MIT License

Copyright (c) 2025

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.