_Truth

it.grypho.scala.leonardo.core._Truth
See the_Truth companion object
case class _Truth extends _Value

A graded truth value: a degree strictly between false and true.

The degree is never exactly 0.0 or 1.0 — the _Truth.of factory guarantees this invariant by collapsing to _Bool in those cases, so _Truth and _Bool together carry the full [0, 1] interval without overlapping. Construction through of is the only public route; pattern matching _Truth(d) remains available.

In three-valued (Kleene) logic the only reachable degree is 0.5, the named constant _Truth.Unknown, which prints and parses as unknown. The [0, 1] carrier is already in place for the fuzzy tier; degrees other than 0.5 print as plain numbers and do not round-trip through the parser yet (there is no grammar literal for them).

Like _Number, a _Truth never rounds in eval; rounding is a display concern handled by toString / display(p).

Value parameters

d

the truth degree, guaranteed to lie strictly inside (0, 1) by _Truth.of

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait _Value
trait _Expression
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

Definition Classes
def display(precision: Int): String

Renders this truth value at precision decimal places for REPL display.

Renders this truth value at precision decimal places for REPL display.

Both spellings are grammar literals, so the rendering round-trips: unknown parses back to _Truth.Unknown and truth(d) to the same degree. Without the truth(...) form a fuzzy degree would print as a bare number and re-parse as a plain _Number, silently losing its truth-valued nature across a :save/:load.

Value parameters

precision

number of decimal places to show

Attributes

Returns

"unknown" when the rounded degree is 0.5, "truth(d)" otherwise

override def eval(env: Environment): Either[_Expression, _Value]

Returns Right(this) — a concrete truth value needs no further reduction.

Returns Right(this) — a concrete truth value needs no further reduction.

Attributes

Definition Classes
override def rebuild(c: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Definition Classes
def symmetric: Double

This degree written as a symmetric ternary digit: 2 * d - 1, so 0.5 is 0. The inverse of _Truth.fromSymmetric.

This degree written as a symmetric ternary digit: 2 * d - 1, so 0.5 is 0. The inverse of _Truth.fromSymmetric.

Attributes

override def toString: String

Renders this truth value at Environment.DefaultPrecision decimal places; the Kleene midpoint prints as "unknown", any other degree as "truth(d)".

Renders this truth value at Environment.DefaultPrecision decimal places; the Kleene midpoint prints as "unknown", any other degree as "truth(d)".

Attributes

Definition Classes
Any

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Inherited fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes

Inherited from:
_Expression