Skip to main content

rnel: Refined Neutrosophic Evidential Logic

A toolkit for neutrosophic evidence

Documentation DOI

Documentation: https://mleyvaz.github.io/rnel/

rnel computes with typed evidence. A probability of truth cannot say why a system is unsure: two sources that contradict each other, a single source with balanced evidence, and no evidence at all can all give 0.5. RNEL (Smarandache and Leyva-Vázquez) keeps them apart:

Component Meaning Typical action
T evidence that the claim is true answer: supported
F evidence that the claim is false answer: refuted
C contradiction: strong evidence for both present both positions
U undetermined: "true or false, cannot say which" wait, ask for specific evidence
N neither: the claim is ill-posed question the premise
G ignorance: no evidence retrieve more or abstain

With only T and F it reduces exactly to Subjective Logic (Jøsang) and to evidential deep learning (Sensoy et al.).

Install

pip install rnel                                    # core, no dependencies
pip install "rnel[credal]"                          # with numpy, scikit-learn and scipy
pip install "rnel[nn]"                              # with PyTorch models
pip install git+https://github.com/mleyvaz/rnel     # development version

The core has no dependencies. The modules credal, neutro_credal, existential, mvc, active and cluster use numpy, scipy or scikit-learn (install rnel[credal]), and rnel.nn uses PyTorch (install rnel[nn]).

Betting triplet (experimental)

from rnel.betting import gaussian_evalues, log_ratio_from_ci, betting_triplet

# IPASS: progression-free survival hazard ratios with and without EGFR mutation
est = [log_ratio_from_ci(0.48, 0.36, 0.64), log_ratio_from_ci(2.85, 2.05, 3.98)]
lp, lm = gaussian_evalues([e for e, _ in est], [s for _, s in est], delta=0.2877, direction="less")
betting_triplet(lp, lm, lam=0.5)["verdict"]   # 'conflict'      (benefit in one stratum, harm in the other)
betting_triplet(lp, lm, lam=1.0)["verdict"]   # 'insufficient'  (pooling cancels them)

Refined truth (contributed by F. Smarandache): relative truth ("true in at least one source") and absolute truth ("true in every source"), each with its own error bound.

import math
from rnel.betting import refined_triplet
lp = [math.log(30), math.log(8), math.log(0.5)]          # e-values for A from three sources
r = refined_triplet(lp, [-x for x in lp], lam=0.5)
r["T_rel"], r["T_abs"], r["verdict"]                      # (0.981, 0.0, 'supported in some source')

Typed plithogenic statistics (experimental)

Contradiction degree between attribute values computed from data, with a guarantee (contributed by F. Smarandache).

from rnel.plithogeny import typed_plithogenic_report
r = typed_plithogenic_report({"lab1": (62, 30, 8), "lab2": (55, 38, 7), "lab3": (20, 72, 8)})
r["c_hat"]   # {('lab1','lab2'): 0.0, ('lab1','lab3'): 0.208, ('lab2','lab3'): 0.125}

Quick start

from rnel import Reports, rnel_tuple, fused_contradiction
from rnel.decide import Policy

# two confident sources that disagree, and a fair coin: SL fuses both to the same opinion
x = fused_contradiction([Reports(t=10), Reports(f=10)])
coin = fused_contradiction([Reports(t=10, f=10)])
print(x.C, coin.C)            # 0.579 vs 0.0 (Proposition 8.3 / Definition 8.4)
print(Policy().decide(x))     # ('C', 'present both positions and flag the dispute')

# the evidence tuple of Definition 8.1
print(rnel_tuple(Reports(t=3, f=1, c=2, v=1, n=1)).as_dict())

From text, with a public NLI model and no training (pip install transformers torch):

from rnel.text import NLIReader, rnel_from_text
t, readings = rnel_from_text(NLIReader(), "Coffee increases the risk of heart disease.",
                             ["A cohort found higher coffee intake linked to more heart disease.",
                              "A meta-analysis found moderate coffee lowers the risk of heart disease."])

NLI models often label unrelated text as "contradiction", so give only evidence that is about the claim.

Demo app: streamlit run examples/app.py.

Credal tools for neutrosophic triples

rnel.neutro_credal (experimental; pip install "rnel[credal]", needs numpy and scipy) reads a triple (T, I, F) of an event as the bounds T <= P(A) <= 1 - F of a credal set (Walley's betting reading). Through this reading the neutrosophic triple inherits Walley's quality checks and tools, applied directly to triples:

Function What it does Result used
avoids_sure_loss, sure_loss_degree is the credal set non-empty; degree (T + F - 1)/2 for one triple Theorem 3
is_coherent, classify every bound attained (LP, or closed form I_i <= Delta <= sum_{j!=i} I_j on singletons) Theorems 1, 2
natural_extension, coherent_correction triple of a composite event ("A or C"); correction with I^E <= I Theorems 1(c), 2(c)
singleton_intervals_check, singleton_natural_extension singletons as probability intervals, closed forms Theorem 2
idm_triple imprecise Dirichlet model as triples Corollary 2
interval_dominance, maximality, e_admissible decisions by sets over per-class triples or member distributions Walley, Levi
to_glut_frame, glut_conjunction credal set on a frame with a glut atom, including T + F > 1; N-norms as natural extensions Theorems 8, 9
sl_retraction saturating chart to Subjective Logic Theorem 5
credal_diagnosis all of the above plus the RNEL state (a, b, u, c) and C* from evidence per source, in one call
from rnel import neutro_credal as nc

members = [(0.7, 0.2, 0.1), (0.6, 0.3, 0.1), (0.1, 0.8, 0.1)]   # three classifiers, classes A, B, C
rep = nc.credal_diagnosis(members, labels=["A", "B", "C"], events={"A or C": ["A", "C"]})
rep["triples"]         # A (0.1, 0.6, 0.3), B (0.2, 0.6, 0.2), C (0.1, 0.0, 0.9): intervals [0.1,0.7], [0.2,0.8], [0.1,0.1]
rep["status"]          # 'coherent'
rep["events"]["A or C"]  # (0.2, 0.6, 0.2): P(A or C) in [0.2, 0.8]
rep["decision"]        # ['A', 'B'] (maximality; E-admissibility and interval dominance agree here)
rep["rnel"]            # why: per class a (support), b (rejection), u (absence), c (conflict between sources); C*

nc.sure_loss_degree((0.7, 0.1, 0.6))       # 0.15 = (T + F - 1) / 2
nc.to_glut_frame((0.8, 0.3, 0.7)).represents()   # True: the glut frame represents T + F > 1

The same call accepts a fitted rnel.credal.CredalEnsemble (credal_diagnosis(ensemble=ens, X=X)), using the leaf counts of each tree as evidence per source. A longer walk-through is in examples/neutro_credal_demo.py. Theorem numbers refer to Leyva-Vázquez and Smarandache, Neutrosophic probability and credal sets: exact reduction theorems and a glut lifting (manuscript, 2026); the tests check the closed forms of Theorem 2 against linear programming on 3000 random assessments (16 812 events, maximum error 3.3e-16) and reproduce Table 2 and counterexamples C1-C4.

Modules

Module Contents
rnel.sl Subjective Logic: opinions, evidence mapping, multiplication, comultiplication, cumulative and averaging fusion, discounting, ageing, degree of conflict
rnel.tuple RNEL reports, the tuple of Definition 8.1, cumulative fusion (Theorem 8.2), fused contradiction (Definition 8.4)
rnel.operators Priority-product ∧, ∨, ¬ for (T, I, N, F), (T, I, N, U₁…Uₙ, F) and RNEL, with coarsening to SL
rnel.ranking Total-order cascades: score, accuracy, extended certainty, certainty
rnel.decide From a tuple to an action (thresholds to be tuned with the costs of each application). Since v0.1.1 the evidence gate is monotone: a report for x never yields "refuted" (see CHANGELOG)
rnel.nn PyTorch: typed evidential head, loss, per-source evidential network, source conflict, fused dissonance
rnel.text Zero-shot RNEL from a claim and evidence texts via an NLI model
rnel.datasets Loaders for AVeriTeC, CLIMATE-FEVER and ChaosNLI with their mapping to RNEL types
rnel.off Experimental signed-evidence ledger, source-level retraction and over/under/off values
rnel.neutro_credal Experimental: Walley's tools (sure loss, coherence, natural extension, IDM, decisions by sets, glut lifting) on neutrosophic triples
rnel.neutro_stats Experimental: refined neutrosophic estimates with labelled indeterminacy symbols and an affine-arithmetic bridge
rnel.conflict Experimental: order-free between-source conflict, within-source conflict and provenance-aware fusion
rnel.copula Experimental: copulas, copula N-norms, Fréchet brackets and dependence diagnostics
rnel.plithogeny Experimental: switched/plithogenic N-norms, liftings, plithogenic IDM and typed plithogenic statistics (data-derived contradiction degree)
rnel.betting Experimental: betting reading of a triplet from several sources; refined truth (absolute/relative, graded sub-truths)
rnel.scores Base-rate score functions, Hurwicz readings and dominance under imprecise base rates
rnel.dsmt Experimental: DSmT rules on small free, Shafer and hybrid frames, plus the RNEL dictionary
rnel.mvc, rnel.active Experimental: multi-view clustering and reliability-weighted active learning

Verified

pytest runs the results of the papers and book as automated tests. Numbered results carry @pytest.mark.theorem(...); the generated theorem-to-test map records the current exact counts.

  • the worked example of Proposition 8.3 and Definition 8.4;
  • Theorem 8.2;
  • Theorem 5.2 on random tuples: involution, De Morgan, multiplicative mass, and projection onto SL multiplication and comultiplication;
  • Theorem 6.2 for n = 3;
  • De Morgan and SL projection for the RNEL operators;
  • the neural head and the per-source network.

Version 0.4.0 adds rnel.betting (with refined truth) and typed plithogenic statistics in rnel.plithogeny. Version 0.3.0 consolidates the credal, conflict, refined-statistics, multi-view learning, DSmT, copula, plithogenic and score modules used by Neutrosophic Evidence, and adds rnel.existential. It is archived at https://doi.org/10.5281/zenodo.23178344 (version 0.2.0: https://doi.org/10.5281/zenodo.23040628; all versions: https://doi.org/10.5281/zenodo.23040627).

Evidence on real data

The preregistered evaluation of the neural head on AVeriTeC, CLIMATE-FEVER and ChaosNLI is at https://github.com/mleyvaz/rnel-neural-factcheck.

Cite

F. Smarandache, M. Y. Leyva-Vázquez, The Neutrosophic (T, I, N, F), Multi-Uncertainty, n-Valued Refined, and Refined Evidential Logics with Neutrosophic Probability as Extensions of Subjective Logic, manuscript, 2026.

MIT licence.

Metadata

Release files for rnel 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rnel 0.4.0
File Size Uploaded Provenance Actions
rnel-0.4.0.tar.gz 133.8 kB Without provenance Details for rnel-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rnel 0.4.0
File Interpreter ABI Platform Actions
rnel-0.4.0-py3-none-any.whl Python 3 none any Details for rnel-0.4.0-py3-none-any.whl

Total release size: 233.2 kB

Release files / rnel-0.4.0.tar.gz

Download URL rnel-0.4.0.tar.gz
Size 133.8 kB
Tags Source
SHA-256 checksum
How to use checksums
eb20708ad5e6c7190a94200b9c62ec5d22c612d1cc9996c12037a88ff5d0c67f
BLAKE2b-256 checksum
How to use checksums
6c301b407a2c99a7dfedeb1d9002352f8d49674f805dd2d778917247f993443d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / rnel-0.4.0-py3-none-any.whl

Download URL rnel-0.4.0-py3-none-any.whl
Size 99.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9caaec00a79b56da1e5307ecd8bc05cd1712816d70f683fa1387fce45449f8e6
BLAKE2b-256 checksum
How to use checksums
5002cc9af3fa95a8f4f1fc925ef37f36e2f837eccb89ccc38c84283d1ddb3052
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for rnel 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page