Logical Kernels¶
- jlnn.core.logic.and_drastic_pure(int_a: Array, int_b: Array) Array[source]¶
Pure drastic t-norm (AND). Represents the absolute mathematical lower bound of all valid t-norms.
Returns the opposing argument if one component equals exactly 1.0, otherwise collapses completely to 0.0.
- jlnn.core.logic.and_godel_pure(int_a: Array, int_b: Array) Array[source]¶
Computes a pure Godel conjunction (AND): min(A, B).
- jlnn.core.logic.and_lukasiewicz_pure(int_a: Array, int_b: Array) Array[source]¶
Computes a pure, parameterless Łukasiewicz conjunction (t-norm) for two intervals.
Mathematical formula: max(0.0, A + B - 1.0) evaluated over interval boundaries.
- jlnn.core.logic.and_product_pure(int_a: Array, int_b: Array) Array[source]¶
Computes a pure product conjunction (AND) for two input intervals: A * B.
- jlnn.core.logic.bulk_and_drastic_raw(x: Array) Array[source]¶
Computes a pure drastic AND reduction along the designated terminal axis using clean optimization masks.
- jlnn.core.logic.bulk_and_godel_raw(x: Array) Array[source]¶
Computes a pure Godel AND (min reduction) along the designated last axis.
- jlnn.core.logic.bulk_and_product_raw(x: Array) Array[source]¶
Executes a bulk product AND reduction across the last axis for n-inputs.
- jlnn.core.logic.bulk_or_drastic_raw(x: Array) Array[source]¶
Computes a pure drastic OR reduction along the designated terminal axis using clean optimization masks.
- jlnn.core.logic.bulk_or_godel_raw(x: Array) Array[source]¶
Computes a pure Godel OR (max reduction) along the designated last axis.
- jlnn.core.logic.bulk_or_product_raw(x: Array) Array[source]¶
Executes a bulk product OR reduction across the last axis for n-inputs.
- jlnn.core.logic.implies_godel(int_a: Array, int_b: Array) Array[source]¶
Computes a pure Gödel implication (R-implication residuum).
Defined algebraically as: 1.0 if A <= B, otherwise B.
- jlnn.core.logic.implies_goguen(int_a: Array, int_b: Array) Array[source]¶
Computes the pure Goguen implication (Residuation R-implication).
Defined algebraically as: 1.0 if A <= B, otherwise B / A.
- Parameters:
int_a (jnp.ndarray) – Antecedent truth interval.
int_b (jnp.ndarray) – Consequent truth interval.
- Returns:
Bounded truth interval evaluated via Goguen residuation.
- Return type:
jnp.ndarray
- jlnn.core.logic.implies_kleene_dienes(int_a: Array, int_b: Array) Array[source]¶
Implements the Kleene-Dienes implication (standard max-min logical model).
This implication strategy (A -> B) is explicitly defined as max(1.0 - A, B). In the context of JLNN interval logic, this represents a highly “pessimistic” approach, given that the resulting truth depends entirely on the dominant active extreme (either the complete falsity of the premise or the total truth of the conclusion).
Unlike Łukasiewicz models, it avoids linear addition of truths, making it highly suitable for structural systems designed to be robust against cumulative edge errors.
- Parameters:
int_a (jnp.ndarray) – Input interval for the antecedent structured as (…, 2).
int_b (jnp.ndarray) – Input interval for the consequent structured as (…, 2).
- Returns:
- The resulting truth interval [L, U] structured as (…, 2).
- Algebraic boundary configurations map as follows:
L_res = max(1.0 - U_a, L_b) U_res = max(1.0 - L_a, U_b)
- Return type:
jnp.ndarray
- jlnn.core.logic.implies_lukasiewicz(int_a: Array, int_b: Array, weights: Array, beta: float) Array[source]¶
Computes the logical implication A -> B (S-implication) based on Łukasiewicz logic.
- Within the JLNN framework, implication is modeled using classical logical equivalence:
(A -> B) identical to (NOT A OR B).
This routine utilizes interval arithmetic, where logical negation (NOT) inverts the boundaries: NOT [L, U] = [1 - U, 1 - L]. The resulting expressions are then processed by a parameterized weighted OR operator, enabling the neural architecture to learn the optimization weights and structural relevance of expert-defined rules.
- Parameters:
int_a (jnp.ndarray) – Antecedent tensor (premise A) structured as (…, 2), where the final dimension holds [Lower Bound, Upper Bound].
int_b (jnp.ndarray) – Consequent tensor (conclusion B) structured as (…, 2), where the final dimension holds [Lower Bound, Upper Bound].
weights (jnp.ndarray) – Optimization weight tensor for the underlying OR gate structured as (2,). The first component scales NOT A, the second scales B. Typically initialized to [1.0, 1.0].
beta (float) – Threshold parameter (bias) establishing the activation stringency of the implication.
- Returns:
The resulting truth interval of the implication [L, U] structured as (…, 2).
- Return type:
jnp.ndarray
- jlnn.core.logic.implies_physical_gravitational_lukasiewicz(int_a: Array, int_b: Array) Array[source]¶
Computes the Physical Gravitational Łukasiewicz implication.
Mathematical formula: min(1.0, 1.0 - (1.0 - H(A)) * A + (1.0 - H(B)) * B)
This operator strictly shadows classical truth mappings when input signals exhibit minimal entropy, while generating full structural convergence (truth = 1.0) as states enter the entropic singularity [0.5, 0.5].
- jlnn.core.logic.implies_physical_kleene_dienes(int_a: Array, int_b: Array) Array[source]¶
Computes the Physical Kleene-Dienes implication modulated by localized entropic chaos.
Mathematical formula: max(1.0 - (1.0 - H(A)) * A, (1.0 - H(B)) * B)
Evaluated independently on boundary limits conforming to strict pessimistic interval semantics.
- jlnn.core.logic.implies_physical_reichenbach(int_a: Array, int_b: Array) Array[source]¶
Computes the Physical Reichenbach implication via a smooth gravitational polynomial.
Mathematical formula: 1.0 - A + A * B * (1.0 - H(A) * H(B))
During peak systemic uncertainty (where both signals approach the logical midpoint 0.5), the coupling factor collapses entirely. This dynamic space bending establishes an uninhibited linear gradient channel to facilitate highly stable error backpropagation.
- jlnn.core.logic.implies_reichenbach(int_a: Array, int_b: Array) Array[source]¶
Implements the Reichenbach implication (product logic s-implication).
This method of computing implication (A -> B) is governed by the polynomial expression: 1.0 - A + (A * B)
In the context of interval logic, this represents a smooth “compromise” approach that, unlike Łukasiewicz or Kleene-Dienes, avoids sharp optimization boundaries caused by min/max operations.
The primary mathematical advantage is that it is fully differentiable across the entire unit domain [0, 1], guaranteeing stable, non-vanishing gradients for both antecedent and consequent parameters simultaneously.
- Parameters:
int_a (jnp.ndarray) – Input interval for the antecedent structured as (…, 2).
int_b (jnp.ndarray) – Input interval for the consequent structured as (…, 2).
- Returns:
The resulting truth interval [L, U] structured as (…, 2).
The boundary calculation satisfies rigorous interval arithmetic constraints:
L_res = 1.0 - U_a + (L_a * L_b) U_res = 1.0 - L_a + (U_a * U_b)
Outputs are bounded using jnp.clip to shield downstream layers from floating-point overflow.
- Return type:
jnp.ndarray
- jlnn.core.logic.or_drastic_pure(int_a: Array, int_b: Array) Array[source]¶
Pure drastic t-conorm (OR). Represents the absolute mathematical upper bound of all valid t-conorms.
Returns the opposing argument if one component equals exactly 0.0, otherwise saturates completely to 1.0.
- jlnn.core.logic.or_godel_pure(int_a: Array, int_b: Array) Array[source]¶
Computes a pure Godel disjunction (OR): max(A, B).
- jlnn.core.logic.or_lukasiewicz_pure(int_a: Array, int_b: Array) Array[source]¶
Computes a pure, parameterless Łukasiewicz disjunction (t-conorm) for two intervals.
Mathematical formula: min(1.0, A + B) evaluated over interval boundaries.
- jlnn.core.logic.or_product_pure(int_a: Array, int_b: Array) Array[source]¶
Computes a pure product disjunction (OR) for two input intervals: A + B - (A * B).
- jlnn.core.logic.weighted_and_lukasiewicz(x: Array, weights: Array, beta: Array) Array[source]¶
Calculates a weighted Łukasiewicz conjunction (AND) over truth intervals.
In LNN (Logical Neural Network) logic, conjunction is structurally formulated through “negative evidence”. The closer the inputs gravitate toward falsehood (1 - x) and the higher their respective importance weight, the more aggressively they suppress the overall truth value of the result. The parameter beta governs the structural sensitivity threshold below which the output completely saturates to absolute falsehood (0.0).
Interval Semantics: Because negation algebraically inverts boundary limits, computing the upper limit of the result (U) requires evaluating the negated lower limits of the inputs (L). Conversely, computing the lower limit of the result (L) requires evaluating the negated upper limits of the inputs (U).
- Parameters:
x (jnp.ndarray) – Input interval tensor structured as (…, num_inputs, 2).
weights (jnp.ndarray) – A tensor of input importance weights structured as (num_inputs,).
beta (jnp.ndarray) – Scalar activation sensitivity threshold parameter (bias).
- Returns:
The resulting bounded truth interval [L, U] structured as (…, 2).
- Return type:
jnp.ndarray
- jlnn.core.logic.weighted_or_lukasiewicz(x: Array, weights: Array, beta: Array) Array[source]¶
Calculates the weighted Łukasiewicz disjunction (OR) over truth intervals.
Disjunction within the LNN framework acts as an explicit accumulator of “positive evidence”. Each validating input signal increments the overall cumulative truth of the outcome proportional to its assigned weight. The beta threshold parameter regulates how much aggregate positive validation is required to establish absolute saturation at perfect truth (1.0).
Interval Semantics: The OR operation preserves standard boundary orientation: the lower limits of the inputs uniquely determine the lower limit of the result, while the upper limits of the inputs determine the corresponding upper limit of the result.
- Parameters:
x (jnp.ndarray) – Input interval tensor structured as (…, num_inputs, 2).
weights (jnp.ndarray) – A tensor of input importance weights structured as (num_inputs,).
beta (jnp.ndarray) – Scalar activation saturation threshold parameter (bias).
- Returns:
The resulting bounded truth interval [L, U] structured as (…, 2).
- Return type:
jnp.ndarray
This module implements low-level mathematical definitions of logical operators operating over truth intervals \([L, U]\). The calculations are designed to strictly preserve interval semantics and correctly propagate uncertainty throughout the network.
All functions are implemented as pure functions optimized for error-free compilation using jax.jit.
1. Łukasiewicz’s logic (Nilpotent / Accumulative)¶
Standard semantics for JLNN (Logical Neural Networks). Provides stable linear gradients and high interpretability. Conjunction is modeled here through the principle of “negative evidence”, where inputs approaching falsely dampen the result.
and_lukasiewicz_pure / or_lukasiewicz_pure: Pure, parametrically unweighted operators.
weighted_and_lukasiewicz / weighted_or_lukasiewicz: Weighted versions controlled by the
betaparameter, which determines the sensitivity or saturation threshold.implies_lukasiewicz: The implication \(A \rightarrow B\) modeled as the equivalence \(\neg A \lor B\). In interval reasoning, the inversion of limits occurs: \(\neg [L, U] = [1 - U, 1 - L]\).
2. Productive logic (Smooth / Probabilistic)¶
It models the interactions of independent probabilistic events. Its main feature is a smooth polynomial progression without sharp breaks caused by min/max operators.
and_product_pure / or_product_pure: Basic binary operators.
bulk_and_product_raw / bulk_or_product_raw: N-ary reduction along the last axis of the tensor.
implies_reichenbach: Reichenbach implication defined by the relation \(1.0 - A + (A \cdot B)\). It is fully differentiable in the entire unitary domain space, which guarantees stable and non-vanishing gradients for both the premise and conclusion simultaneously.
implies_goguen: Residual R-Implication (Goguen). The calculation uses numerically safe division in JAX to avoid NaN anomalies during backpropagation.
3. Gödel’s Logic (Strict / Extremal / Min-Max)¶
This logic is based on positional evaluation of extremes. The resulting truth depends purely on the dominant element, not on the cumulative sum.
and_godel_pure / or_godel_pure: Binary min-max operators.
bulk_and_godel_raw / bulk_or_godel_raw: Bulk reductions (vectorized functions
jnp.minandjnp.max).implies_kleene_dienes: A pessimistic implication model defined as \(\max(1.0 - A, B)\). It is highly robust against cumulative error propagation at interval boundaries.
implies_godel: Pure Gödel residue working on the basis of conditional masks
jnp.where.
4. Drastic Logic (Theoretical Mathematical Bottom)¶
Drastic logic represents the absolute limit barriers of fuzzy logic operators. The t-norm represents the smallest possible t-norm and the t-conorm represents the largest possible.
and_drastic_pure: If one of the components is exactly \(1.0\), return the other component, otherwise immediately collapse to pure \(0.0\).
or_drastic_pure: If one of the components is equal to \(0.0\), return the other, otherwise immediately saturate to the absolute truth \(1.0\).
The module also includes optimized bulk reductions bulk_and_drastic_raw and bulk_or_drastic_raw, which use precise tolerance masks (the
EPSILONconstant) to work with float32 precision.
5. Space-time curved physical fuzzy logic (PFL)¶
An advanced PFL (Space-Curved Physical Fuzzy Logic) apparatus that deforms the space of truth potentials based on local entropic chaos (Shannon entropy \(H\)).
implies_physical_kleene_dienes: Physical implication modulated by local stability of states. Uses stability weights \(1.0 - H\) to deform the boundaries.
implies_physical_reichenbach: Uses a smooth gravity polynomial \(1.0 - A + A \cdot B \cdot (1.0 - H(A) \cdot H(B))\). At maximum system uncertainty (when states approach the center \(0.5\)), the coupling term decays by eliminating entropy, opening a pure linear channel for stable gradient backpropagation.
implies_physical_gravitational_lukasiewicz: Generates full structural convergence (truth \(1.0\)) once the logical states enter the entropic singularity region around the point \([0.5, 0.5]\). If the entropy is minimal, it strictly shadows the classical Łukasiewicz behavior.