it.grypho.scala.leonardo.logic
Members list
Type members
Classlikes
Conjunction: a and b, evaluated as min over the operand degrees.
Conjunction: a and b, evaluated as min over the operand degrees.
Short-circuits on a false left operand exactly as Product.eval does on a zero left operand: false and X is false without evaluating X. The rule is sound in the graded table too — 0 annihilates min — so no many-valued special case is needed. A true operand on either side leaves the other, a false right operand decides (F_0326).
Value parameters
- a
-
left operand
- b
-
right operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Connectivetrait _Expressionclass Objecttrait Matchableclass AnyShow all
A defuzzification method, with the slot word that names it at the prompt (F_0136).
A defuzzification method, with the slot word that names it at the prompt (F_0136).
The words are matched only in defuzz's last slot and are not reserved, the c2d precedent: mom and bisector are plausible variable names elsewhere.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalstrait Keywordedclass Objecttrait Matchableclass AnyShow all
Why _Equivalent declined (F_0322): it stays unevaluated and the REPL appends the reason.
Why _Equivalent declined (F_0322): it stays unevaluated and the REPL appends the reason.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
What _Equivalent found (F_0322, LT L_0079).
What _Equivalent found (F_0322, LT L_0079).
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Gaussian membership curve gaussmf(x, mean, sigma) = exp(-(x - mean)² / (2σ²)). A non-positive sigma leaves the node symbolic (no curve is defined).
Gaussian membership curve gaussmf(x, mean, sigma) = exp(-(x - mean)² / (2σ²)). A non-positive sigma leaves the node symbolic (no curve is defined).
Value parameters
- mean
-
the centre, where the degree is one
- sigma
-
the standard deviation; must be positive
- x
-
the crisp input
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
Biconditional: a iff b, evaluated as the conjunction of the two implications (F_0322, LT L_0079; see kleeneIff). Under min-max that is not (a xor b), and unknown iff unknown is unknown.
Biconditional: a iff b, evaluated as the conjunction of the two implications (F_0322, LT L_0079; see kleeneIff). Under min-max that is not (a xor b), and unknown iff unknown is unknown.
No short-circuit is possible -- both operands matter -- but a crisp one decides how, on either side, as for Xor and under every semantics: true iff X is X, false iff X is not X.
Value parameters
- a
-
left operand
- b
-
right operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Connectivetrait _Expressionclass Objecttrait Matchableclass AnyShow all
Material implication: a implies b, evaluated as max(1 - a, b).
Material implication: a implies b, evaluated as max(1 - a, b).
Short-circuits on a false left operand: false implies X is true without evaluating X (sound in the graded table, since 1 annihilates max). A true antecedent leaves the consequent, a true consequent decides, a false consequent leaves the negated antecedent (F_0326): the readings of tconorm(1 - a, b) at one crisp operand.
Value parameters
- a
-
antecedent
- b
-
consequent
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Connectivetrait _Expressionclass Objecttrait Matchableclass AnyShow all
A minimal two-level form, and how many there are.
A minimal two-level form, and how many there are.
Value parameters
- count
-
how many forms of the same, least cost exist (at least 1);
expris the first of them in the canonical order of minimalForm - expr
-
the form: a sum of products or a product of sums, or a constant
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Which minimal form a _MinimalForm asks for, with its grammar keyword.
Which minimal form a _MinimalForm asks for, with its grammar keyword.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalstrait Keywordedclass Objecttrait Matchableclass AnyShow all
Why minimalForm declined (F_0325 step 2). The node stays unevaluated and the REPL appends why.
Why minimalForm declined (F_0325 step 2). The node stays unevaluated and the REPL appends why.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Which normal form a _NormalForm asks for (F_0133), with its grammar keyword.
Which normal form a _NormalForm asks for (F_0133), with its grammar keyword.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalstrait Keywordedclass Objecttrait Matchableclass AnyShow all
Negation: not a, evaluated as 1 - a. unknown is the fixpoint.
Negation: not a, evaluated as 1 - a. unknown is the fixpoint.
Value parameters
- a
-
the operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Connectivetrait _Expressionclass Objecttrait Matchableclass AnyShow all
Disjunction: a or b, evaluated as max over the operand degrees.
Disjunction: a or b, evaluated as max over the operand degrees.
Short-circuits on a true left operand (the dual of And's rule): true or X is true without evaluating X. Sound in the graded table — 1 annihilates max. A false operand on either side leaves the other, a true right operand decides (F_0326).
Value parameters
- a
-
left operand
- b
-
right operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Connectivetrait _Expressionclass Objecttrait Matchableclass AnyShow all
Sigmoid membership curve sigmf(x, a, c) = 1 / (1 + exp(-a(x - c))). A positive a opens to the right, a negative one to the left.
Sigmoid membership curve sigmf(x, a, c) = 1 / (1 + exp(-a(x - c))). A positive a opens to the right, a negative one to the left.
Value parameters
- a
-
the slope
- c
-
the inflection point, where the degree is one half
- x
-
the crisp input
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
The dilation hedge somewhat(a) = √a: softens a degree towards the middle.
The dilation hedge somewhat(a) = √a: softens a degree towards the middle.
Value parameters
- a
-
the degree expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
Trapezoidal membership curve trapmf(x, a, b, c, d): rises from a to b, is one on the plateau [b, c], falls from c to d, and is zero outside [a, d]. Requires a <= b <= c <= d; otherwise the node stays symbolic.
Trapezoidal membership curve trapmf(x, a, b, c, d): rises from a to b, is one on the plateau [b, c], falls from c to d, and is zero outside [a, d]. Requires a <= b <= c <= d; otherwise the node stays symbolic.
Value parameters
- a
-
left foot
- b
-
left shoulder
- c
-
right shoulder
- d
-
right foot
- x
-
the crisp input
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
Triangular membership curve trimf(x, a, b, c): rises from a to the apex b, falls from b to c, and is zero outside [a, c].
Triangular membership curve trimf(x, a, b, c): rises from a to the apex b, falls from b to c, and is zero outside [a, c].
Degenerate shoulders (a == b or b == c) give a vertical edge rather than a division by zero. Requires a <= b <= c; otherwise the node stays symbolic.
Value parameters
- a
-
left foot
- b
-
apex
- c
-
right foot
- x
-
the crisp input
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
The concentration hedge very(a) = a²: sharpens a degree towards its extremes.
The concentration hedge very(a) = a²: sharpens a degree towards its extremes.
Value parameters
- a
-
the degree expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
Exclusive disjunction: a xor b, evaluated as the lattice reading of (a and not b) or (not a and b) (see kleeneXor). No short-circuit is possible: both operands always matter -- but a crisp one decides how (F_0326): false xor X is X and true xor X is not X, on either side.
Exclusive disjunction: a xor b, evaluated as the lattice reading of (a and not b) or (not a and b) (see kleeneXor). No short-circuit is possible: both operands always matter -- but a crisp one decides how (F_0326): false xor X is X and true xor X is not X, on either side.
Value parameters
- a
-
left operand
- b
-
right operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Connectivetrait _Expressionclass Objecttrait Matchableclass AnyShow all
Marker trait for the six logical connectives: And, Or, Not, Implies, Xor and Iff.
Operands are untyped core._Expressions so equations and other domains compose without cross-domain imports. eval runs the shared Kleene/Zadeh min–max rule table (kleeneAnd, kleeneOr, kleeneNot, kleeneImplies, kleeneXor) over operands widened by asTruth, so core._Bool and core._Truth operands mix freely and the boolean behaviour is a special case of the graded table rather than a separate branch. The result is rebuilt through _Truth.of, which collapses a crisp degree back to _Bool. Any other concrete operand (a _Number, a matrix) leaves the node symbolic.
A known operand decides what it can on either side (F_0326, LT L_0082). The annihilators were always folded on the left (false and X, true or X, false implies X, each without evaluating X) and nowhere else, so with p := true the prompt answered p and q as (true and q) while simplify gave q. Now the identity and the annihilator fold on both sides: true and q is q, q and false is false, true implies q is q, q implies true is true, q implies false is not q, true xor q is not q, false xor q is q. Sound under all three semantics: every t-norm has unit 1 and annihilator 0, every t-conorm unit 0 and annihilator 1, the S-implication is tconorm(1 - a, b), and xor is the lattice reading of (a and not b) or (not a and b), in which one crisp operand leaves the other or its negation under each kernel. Only a truth-valued or symbolic other side is folded: a number beside a truth value stays as written.
eval consults its Environment for two knobs, neither of which is a second node hierarchy: the truth-value encoding (symmetricLogic, which additionally admits the digits {-1, 0, 1} as truth values -- a change of digits, never a change of meaning) and the semantics (LogicSemantics, selecting the t-norm / t-conorm pair: min-max, product, or Lukasiewicz). All three semantics agree with classical logic on the crisp values, so the boolean and three-valued tiers are unaffected by the default.
Deliberately NOT marked core._ElementWise: that marker means derive/simplify/ expand/integrate distribute over children (linear containers only), and the connectives are not linear -- derive(a and b, x) must stay symbolic.
Attributes
- Supertypes
- Known subtypes
Defuzzification of a membership expression to a crisp value: defuzz(e, v, lo, hi).
Defuzzification of a membership expression to a crisp value: defuzz(e, v, lo, hi).
Evaluates by centroid once lo and hi fold to numbers; stays symbolic otherwise (the fixpoint convention shared with the transforms and _ODE). v is a binder, so it is excluded from children — the same convention as _DefIntegral.
Value parameters
- e
-
the membership expression
- hi
-
right endpoint
- lo
-
left endpoint of the universe
- v
-
the variable ranging over the universe of discourse
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Defuzzification by a named method: defuzz(e, v, lo, hi, centroid | mom | bisector) (F_0136).
Defuzzification by a named method: defuzz(e, v, lo, hi, centroid | mom | bisector) (F_0136).
A node of its own rather than a widened _Defuzzify, because that case class is published and a new field would be a binary break -- the _RidgeRegress precedent. The four-argument form keeps meaning the centroid, so every existing call is unchanged.
Value parameters
- e
-
the membership expression
- hi
-
right endpoint
- lo
-
left endpoint of the universe
- method
-
the defuzzification method
- v
-
the variable ranging over the universe of discourse (a binder)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
equivalent(f, g) -- whether two formulas agree on every assignment of their free names as booleans (F_0322, LT L_0079).
equivalent(f, g) -- whether two formulas agree on every assignment of their free names as booleans (F_0322, LT L_0079).
Logical equivalence is not ==. == compares values and stays what it was (f == g between two formulas echoes itself, and a connective is not even an operand of ==, L_0066); equivalence asks about every row of the table, which is what the BL lessons built by hand as truth f xor g reading false throughout.
Both sides are evaluated first, so a name bound in the session is read as its value and is not enumerated; the names left over -- the free names of the two reduced sides together -- are enumerated as truth does, the first name the most significant. true when every row agrees, false as soon as one differs (the first such row is in detailed, for the REPL's note), and unevaluated past the table's cap or when a row is no boolean: crisp only, the cnf / dnf convention (F_0133), since a graded value has no row to be equal on.
Value parameters
- a
-
the left formula
- b
-
the right formula
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Marker trait for the nodes that produce a truth degree from crisp input: the hedges (Very, Somewhat) and the membership curves (TriMF, TrapMF, GaussMF, SigMF), plus the explicit conversion _TruthOf.
Marker trait for the nodes that produce a truth degree from crisp input: the hedges (Very, Somewhat) and the membership curves (TriMF, TrapMF, GaussMF, SigMF), plus the explicit conversion _TruthOf.
These are the fuzzy tier's entry points: a membership function maps a crisp measurement into [0, 1], and everything downstream is an ordinary truth value that the connectives already understand. Their eval therefore returns _Truth.of(degree) rather than a plain number — a membership degree is a truth value, and returning one is what lets very(trimf(t, 0, 10, 20)) and somewhat(x) compose without an explicit cast at every step.
Arguments are read with asDegree, which accepts a bare number in [0, 1] as well as a _Bool/_Truth: a hedge has no other domain, so there is none of the ambiguity that makes the connectives insist on asTruth. An argument outside the domain, or one that does not reduce, leaves the node symbolic.
Attributes
- Supertypes
- Known subtypes
mindnf(e) / mincnf(e) -- a minimal two-level form at the prompt (F_0325 step 2).
mindnf(e) / mincnf(e) -- a minimal two-level form at the prompt (F_0325 step 2).
The cnf/dnf node's shape (F_0133): the operand is evaluated first, so a bound name takes its value and a concrete truth value is its own minimal form, and the node stays unevaluated on a refusal (a graded truth value, too many atoms, a search past its budget) rather than answering the input as though it were minimal. detailed carries the reason and the count, for the REPL's note.
Value parameters
- e
-
the logical expression
- kind
-
which form
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
cnf(e) / dnf(e) -- the conjunctive or disjunctive normal form of a logical expression at the prompt (F_0133).
cnf(e) / dnf(e) -- the conjunctive or disjunctive normal form of a logical expression at the prompt (F_0133).
The library has had toCNF and toDNF since 4.E; this node is their prompt form, chosen over a REPL command (Decision 1, 2026-10-17) so that it composes inside an expression and round-trips through :save. The operand is evaluated first, so a bound name takes its value; a concrete truth value is its own normal form. On a refusal -- a graded truth value anywhere in the operand, or more than the environment's Limit.MaxNormalFormClauses clauses -- the node stays unevaluated rather than answering the operand as though it were already in normal form.
Value parameters
- e
-
the logical expression
- kind
-
which normal form
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Explicit conversion of a scalar degree into a truth value: truth(x).
Explicit conversion of a scalar degree into a truth value: truth(x).
Also the printed form of a graded core._Truth (truth(0.25)), which is what makes a fuzzy degree round-trip through toString and through a :save/:load — without it a degree would print as a bare number and re-parse as a plain _Number. The Kleene midpoint keeps its own literal, unknown.
This is also how a custom membership function is written: the argument is an arbitrary scalar expression, so truth(1 / (1 + (x - 5)^2)) is a perfectly good curve and composes with the hedges, the connectives, and defuzz exactly like the built-in ones.
An argument outside [0, 1] is not a degree, so the node stays symbolic rather than clamping — the same "domain errors stay symbolic" rule the rest of the library follows, and a useful signal that a custom curve has left the unit interval.
Value parameters
- a
-
the degree expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Membershiptrait _Expressionclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Defuzzifies by the bisector: the sampled point at which the cumulative membership first reaches half of the total, splitting the area in two.
Defuzzifies by the bisector: the sampled point at which the cumulative membership first reaches half of the total, splitting the area in two.
Value parameters
- env
-
environment for resolving any other free variables
- hi
-
right endpoint
- lo
-
left endpoint of the universe
- membership
-
the membership expression in
v - n
-
number of grid points
- v
-
the variable ranging over the universe of discourse
Attributes
- Returns
-
the crisp representative, or
Nonewhen nothing was sampled or the total membership is zero
Defuzzifies by the centre of gravity: Σ x·μ(x) / Σ μ(x) over the sampled curve.
Defuzzifies by the centre of gravity: Σ x·μ(x) / Σ μ(x) over the sampled curve.
The most common defuzzifier, and the one defuzz(...) uses in the grammar.
Value parameters
- env
-
environment for resolving any other free variables
- hi
-
right endpoint
- lo
-
left endpoint of the universe
- membership
-
the membership expression in
v - n
-
number of grid points
- v
-
the variable ranging over the universe of discourse
Attributes
- Returns
-
the crisp representative, or
Nonewhen nothing was sampled or the total membership is zero (no centroid is defined)
Enumerates every three-valued (Kleene) assignment of vars and evaluates e under each.
Enumerates every three-valued (Kleene) assignment of vars and evaluates e under each.
The three-valued counterpart of truthTable: each variable ranges over KleeneValues (false, unknown, true) for 3^n rows, ordered with the first variable as the most significant digit. The result column is Some(v) when the row reduces to a truth-valued result (_Bool or _Truth) and None otherwise.
Value parameters
- e
-
the expression to tabulate
- env
-
base environment for each row's evaluation (row bindings shadow it)
- vars
-
the variables to enumerate; an empty list yields a single row with the empty assignment
Attributes
- Returns
-
one
(assignment, result)pair per row, or an empty vector whenvarsexceeds the environment'sLimit.MaxKleeneTableVars
Defuzzifies by the mean of maxima: the average of the sampled points that attain the greatest membership.
Defuzzifies by the mean of maxima: the average of the sampled points that attain the greatest membership.
Points within 1e-9 of the maximum count as maximal, so a plateau is averaged rather than resolved by floating-point noise.
Value parameters
- env
-
environment for resolving any other free variables
- hi
-
right endpoint
- lo
-
left endpoint of the universe
- membership
-
the membership expression in
v - n
-
number of grid points
- v
-
the variable ranging over the universe of discourse
Attributes
- Returns
-
the crisp representative, or
Nonewhen nothing was sampled or the curve is everywhere zero
A minimal two-level form of e (F_0325 step 2, LT L_0081): the Karnaugh-map exercise, by Quine–McCluskey and an exact minimum cover.
A minimal two-level form of e (F_0325 step 2, LT L_0081): the Karnaugh-map exercise, by Quine–McCluskey and an exact minimum cover.
What "minimal" means (Decision A): the fewest terms, then the fewest literals -- the reading of a Karnaugh map, fewest groups each as large as it can be, and Espresso's order. Several minimal forms (Decision B): a cyclic cover has two or more of equal cost; one is answered, the first in a fixed canonical order, identical on the JVM and Node, and MinimalForm.count says how many there are. Atoms (Decision C): as for cnf and dnf, any subexpression that is not a connective is an opaque atom, so x > 0 and y has two; the atoms are ordered by their printed form, a name by itself. The canonical order of the terms is lexicographic over their literals in that atom order, a positive literal before a negative one, a prefix before its extension.
The formula is simplified first (the cnf pre-pass), the truth vector read off over its atoms, and the prime implicants found; mincnf is the dual, the minimal sum of products of not e with every literal negated and the connectives swapped. Crisp only: a graded truth value is declined.
Value parameters
- conjunctive
-
falsefor a sum of products (mindnf),truefor a product of sums (mincnf) - e
-
the formula
- limits
-
the budgets: atoms (
MaxMinimiseVars, at most 15) and work (MaxMinimiseWork) - symmetric
-
whether the symmetric ternary digits are in scope
Attributes
- Returns
-
the form and the number of minimal forms, or why there is none
Samples a membership expression over a uniform grid of n points in [lo, hi].
Samples a membership expression over a uniform grid of n points in [lo, hi].
Fast path: when the expression is pure scalar arithmetic it scalar.compiles to a Double => Double closure — the same fast path _DefIntegral.eval uses for Simpson's rule. A membership or connective node is not something compile can lower, so it returns None and the fallback evaluates the tree per point, reading the result with asDegree so a truth-valued degree counts (scalar.sample would drop it, since it keeps only _Number results).
A point is kept only when its value is an actual membership degree — finite and inside [0, 1]. The range test matters for the fast path: the tree path already reads through asDegree, which rejects anything outside the interval, so without it the same curve would be treated differently depending on whether compile happened to lower it. Points outside the interval are dropped, following the sample convention for values that are not results.
Value parameters
- env
-
environment for resolving any other free variables
- hi
-
right endpoint
- lo
-
left endpoint
- membership
-
the membership expression in
v - n
-
number of grid points
- v
-
the variable ranging over the grid
Attributes
- Returns
-
(x, degree)pairs in ascendingxorder
Single-pass structural simplification of the logical connectives.
Single-pass structural simplification of the logical connectives.
Rules: constant folding through the shared kernels, double negation (not not a = a), idempotence (a and a = a), complement (a and not a = false), and absorption (a or (a and b) = a). Three laws that shrink a formula were added by F_0325 (LT L_0081): the combining law (a and b) or (a and not b) = a and its dual, the absorbed implication (a implies b) and a = a and b, and De Morgan where it removes a negation -- not (not a and not b) is a or b, not (not a and b) is a or not b. Every rule leaves the formula no larger, which is what keeps simplifyLogicFully terminating. De Morgan with nothing to remove (not (a and b)) and the implies/xor desugarings still belong to the normal forms (toCNF/toDNF): they reshape without shrinking.
Many-valued soundness, in two layers. Six rules — complement in and and in or, a implies a = true, a xor a = false, the combining law and the absorbed implication — hold only in classical logic: they fail at unknown (unknown and not unknown = unknown, not false) and are gated on isCrisp. Two more — idempotence and absorption — hold throughout a lattice but not under the product or Lukasiewicz t-norms (a and a is a squared there), so they are additionally gated on the semantics being LogicSemantics.MinMax. Everything else (constant folding, the identity and annihilator elements, double negation, De Morgan) is valid under every t-norm and fires unconditionally: the conorm is the dual of the norm under the strong negation in all three families.
Free variables count as crisp: the classical rules assume boolean-valued atoms, the documented domain restriction of this pass (the Asin convention). Bind a variable to unknown and use eval, not simplify, to get the many-valued answer.
Non-connective sub-expressions are handed to simplifyLeaf. The default is identity; the REPL passes scalar.simplifyFully so a scalar body nested inside a connective is simplified too -- logic itself imports core only, so the scalar pass is injected rather than imported. simplifyLeaf must be idempotent for simplifyLogicFully's fixpoint to terminate.
Value parameters
- e
-
the expression to simplify
- semantics
-
the t-norm family the constant folding and the lattice-only rules are judged against (default
LogicSemantics.MinMax) - simplifyLeaf
-
pass applied to non-connective sub-expressions (default:
identity) - symmetric
-
whether the symmetric ternary digits
{-1, 0, 1}are in scope (the REPL passes its session toggle); this pass takes noEnvironment, by the same design that makesscalar.simplifyignore bindings
Attributes
- Returns
-
the simplified expression; never larger than the input
Iterates simplifyLogic until the result stops changing (fixpoint).
Iterates simplifyLogic until the result stops changing (fixpoint).
Terminates because simplifyLogic never increases expression size (given an idempotent simplifyLeaf).
Value parameters
- e
-
the expression to simplify
- semantics
-
the t-norm family (default
LogicSemantics.MinMax) - simplifyLeaf
-
pass applied to non-connective sub-expressions (default:
identity) - symmetric
-
whether the symmetric ternary digits
{-1, 0, 1}are in scope
Attributes
- Returns
-
the fully simplified expression
Rewrites e into conjunctive normal form: a conjunction of disjunctions of literals.
Rewrites e into conjunctive normal form: a conjunction of disjunctions of literals.
Pipeline: simplifyLogic fixpoint (folds connective-level constants away), desugar implies/xor/iff, push not to the leaves via De Morgan, then distribute or over and. Trivially-true clauses (containing a complementary literal pair) and duplicate literals/clauses are dropped; when every clause is trivially true the result is _Bool(true).
Crisp-only (the Asin convention): valid for _Bool operands only. Non-connective sub-expressions (equations, scalar bodies) are treated as opaque atoms. Returns the input unchanged when distribution would exceed MaxNormalFormClauses, or when the expression carries a _Truth degree (normal forms are a two-valued notion).
Value parameters
- e
-
the expression to normalise
- symmetric
-
whether the symmetric ternary digits
{-1, 0, 1}are in scope
Attributes
- Returns
-
the CNF of
e, oreunchanged when it is not crisp or the distribution blows up
Rewrites e into disjunctive normal form: a disjunction of conjunctions of literals.
Rewrites e into disjunctive normal form: a disjunction of conjunctions of literals.
The exact dual of toCNF -- and distributes over or, trivially-false terms are dropped, and an empty term set collapses to _Bool(false). Same crisp-only domain restriction and clause cap.
Value parameters
- e
-
the expression to normalise
- symmetric
-
whether the symmetric ternary digits
{-1, 0, 1}are in scope
Attributes
- Returns
-
the DNF of
e, oreunchanged when it is not crisp or the distribution blows up
Enumerates every boolean assignment of vars and evaluates e under each.
Enumerates every boolean assignment of vars and evaluates e under each.
Rows are ordered with the first variable as the most significant bit, i.e. from all-false to all-true. The result column is Some(b) when the expression fully reduces to _Bool(b) under that assignment and None otherwise (free variables outside vars, non-boolean operands, or a row that reduces to a graded _Truth degree — use kleeneTable for those).
Crisp-only (the Asin convention): assignments range over _Bool values only.
Value parameters
- e
-
the expression to tabulate
- env
-
base environment for each row's evaluation (row bindings shadow it)
- vars
-
the variables to enumerate (each bound to
_Boolper row); an empty list yields a single row with the empty assignment
Attributes
- Returns
-
one
(assignment, result)pair per row, or an empty vector whenvarsexceeds the environment'sLimit.MaxTruthTableVars
Concrete fields
Default number of grid points used when defuzzifying; odd so the midpoint of the range is always sampled.
Default number of grid points used when defuzzifying; odd so the midpoint of the range is always sampled.
Attributes
The three Kleene truth values in ascending order: false, unknown, true. The enumeration alphabet of kleeneTable.
The three Kleene truth values in ascending order: false, unknown, true. The enumeration alphabet of kleeneTable.
Attributes
Maximum number of variables kleeneTable enumerates (3^10 = 59049 rows) — the three-valued counterpart of MaxTruthTableVars, set to the same row budget. The default of core.Limit.MaxKleeneTableVars (F_0124), honoured up to 19 (3¹⁹ rows).
Maximum number of variables kleeneTable enumerates (3^10 = 59049 rows) — the three-valued counterpart of MaxTruthTableVars, set to the same row budget. The default of core.Limit.MaxKleeneTableVars (F_0124), honoured up to 19 (3¹⁹ rows).
Attributes
Maximum number of variables truthTable enumerates (2^16 = 65536 rows). Beyond this the table is rejected (empty result) rather than attempted. The default of core.Limit.MaxTruthTableVars (F_0124): truthTable reads its environment's value, up to 30, past which the row count overflows an Int.
Maximum number of variables truthTable enumerates (2^16 = 65536 rows). Beyond this the table is rejected (empty result) rather than attempted. The default of core.Limit.MaxTruthTableVars (F_0124): truthTable reads its environment's value, up to 30, past which the row count overflows an Int.