Environment

it.grypho.scala.leonardo.core.Environment
See theEnvironment companion object
class Environment(val precision: Int, variables: Map[String, _Value], val symmetricLogic: Boolean, val semantics: LogicSemantics, val workingPrecision: Int)

Immutable variable-binding context shared across all domains.

Bindings map names to fully-reduced _Values (a number, a matrix, a boolean) — never to a symbolic expression. Kept in core because eval takes one, and core must not depend on any domain.

withBinding returns a new Environment; the original is unchanged (structural sharing).

Value parameters

precision

decimal places used when rendering numbers

semantics

the t-norm / t-conorm pair the logic connectives evaluate with; defaults to LogicSemantics.MinMax. Like symmetricLogic this is a knob on eval, not a separate node hierarchy.

symmetricLogic

when true, the digits {-1, 0, 1} are read as the symmetric ternary spelling of {false, unknown, true} in logical connective positions, and truth values render in that alphabet. This is an encoding toggle, not a semantics: the min–max rule table is untouched and the two alphabets are related by the affine map t = (s + 1) / 2 (see core._Truth.fromSymmetric). Defaults to false, the false/unknown/true spelling.

workingPrecision

decimal digits an irrational is approximated to before exact arithmetic continues. Read by eval wherever a _Rational meets an operation that is not closed over the rationals. Note this is not the exact-mode switch: whether a value is exact is carried by its own type, so the only component that has to be told is the parser, which decides what a literal becomes. That flag lives in cli.Session beside pretty; an Environment.exact field would be read by nothing.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def get(variable: String): Option[_Value]

Returns the value bound to variable, or None if it is free.

Returns the value bound to variable, or None if it is free.

Value parameters

variable

the name to look up

Attributes

def isBound(variable: String): Boolean

Returns true when variable has a binding in this environment.

Returns true when variable has a binding in this environment.

Value parameters

variable

the name to test

Attributes

The reduction policy sized for this environment's working precision.

The reduction policy sized for this environment's working precision.

Derived rather than stored: the gcd-policy benchmark showed that a bound below the operand size a precision implies degenerates GcdPolicy.Threshold into GcdPolicy.Eager, so the two have to move together.

Attributes

def withBinding(variable: String, value: _Value): Environment

Returns a new environment with variable bound to value.

Returns a new environment with variable bound to value.

Value parameters

value

the concrete value to associate

variable

the name to bind

Attributes

Concrete fields

val precision: Int
val symmetricLogic: Boolean
val workingPrecision: Int