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 = ..., val limits: Limits = ..., val exactMode: Boolean = ...)

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

exactMode

the session's exact mode (F_0273, the owner's decision): when set, every constant a pass invents is built exact, whatever its input contains (_Rational.containsExactIn). Whether a value is exact is still carried by its own type; this reaches the passes that work on letters alone — derive(atan(x), x) has no exact value to read a tier from, so until then it built 1.0/(1.0 + x^2.0) under exact on. Defaults to false, under which every path is byte-identical.

limits

the work and size budgets every call evaluated here runs under (Limits, F_0124); each defaults to the value the library has always used. A library caller raises one with withLimit; the REPL and the browser keep the defaults.

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. Not the exact-mode switch: that is exactMode.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Constructors

def this(precision: Int, variables: Map[String, _Value], symmetricLogic: Boolean, semantics: LogicSemantics, workingPrecision: Int, limits: Limits)

The published six-argument constructor, kept so that adding exactMode is binary-compatible (MiMa, F_0273), as the five-argument one was for limits.

The published six-argument constructor, kept so that adding exactMode is binary-compatible (MiMa, F_0273), as the five-argument one was for limits.

Value parameters

limits

see the class

precision

see the class

semantics

see the class

symmetricLogic

see the class

variables

see the class

workingPrecision

see the class

Attributes

def this(precision: Int, variables: Map[String, _Value], symmetricLogic: Boolean, semantics: LogicSemantics, workingPrecision: Int)

The published five-argument constructor, kept so that adding limits is binary-compatible (MiMa): an existing caller compiled against it still links, with the default limits.

The published five-argument constructor, kept so that adding limits is binary-compatible (MiMa): an existing caller compiled against it still links, with the default limits.

Value parameters

precision

see the class

semantics

see the class

symmetricLogic

see the class

variables

see the class

workingPrecision

see the class

Attributes

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

def withExactMode(on: Boolean): Environment

This environment in or out of exact mode (F_0273).

This environment in or out of exact mode (F_0273).

Value parameters

on

whether the passes build exact constants

Attributes

Returns

the same bindings and settings with exactMode at on

def withLimit(limit: Limit, value: Long): Environment

This environment with one budget set (F_0124): env.withLimit(Limit.MaxQpVariables, 2000).

This environment with one budget set (F_0124): env.withLimit(Limit.MaxQpVariables, 2000).

Value parameters

limit

the budget

value

its new value, at least 1

Attributes

Returns

the same bindings and settings with limit at value

This environment with every budget taken from next.

This environment with every budget taken from next.

Value parameters

next

the limits

Attributes

Returns

the same bindings and settings under next

def withoutBindings(names: Iterable[String]): Environment

This environment with names unbound (F_0321): what an analysis that treats them as its own variables evaluates the rest of an expression in, so a session binding of one never folds it.

This environment with names unbound (F_0321): what an analysis that treats them as its own variables evaluates the rest of an expression in, so a session binding of one never folds it.

Value parameters

names

the names to free

Attributes

Returns

the same settings without those bindings

Concrete fields

val exactMode: Boolean
val limits: Limits
val precision: Int
val symmetricLogic: Boolean
val workingPrecision: Int