Feel.Analysis.Failure (feel v0.1.0)

Copy Markdown View Source

The operands for which an operation, or a call of a number built-in, can be null (D-194).

An operation gives null for a result that cannot be written: past the largest number, or below the smallest there is, or a division by zero. Feel.Analysis.Inference says that an operation can be null for the numbers of an operand; this says which numbers, so that the branch where a comparison of the result is not true can leave them in (x * 2 > 10 is not true of an x of 4, and not of one that is too large to double). The set is an outer approximation: it holds every operand for which the run gives null, and some for which it does not, and :all is always an answer.

The results are rounded to 34 digits, to the nearest, and a result that is past the largest number only by less than half a unit of its last digit is rounded back to it, so a bound is the number the operation is null from if there were no rounding, and an operand at it may not give null: the bounds are closed, and are worked out to 34 digits outwards.

OperationThe operand is in the set when
x + yx + y is past the largest number or its negative, for some y: x within the greatest y of an end
x - y, y - xthe same, with the sign of y turned
x * yx * y is past the largest number: x from the largest number over the greatest y; or is not zero and too small to write (below 1E-6143, where a result need not be a multiple of the smallest number): x below that over the least y that is not zero. A y that is a whole number gives no result that is too small
x / yy can be 0 (every x); or x / y is past the largest number or not zero and too small to write, as for a product
y / xx can be 0, or is a number whose quotient with some y is past or too small
d + y, d - ya date, and a days and time duration y: the date within the whole days of the greatest y of an end of the calendar (one day for a day); or a years and months duration: the dates of the years that the greatest months over twelve, rounded up, can move past the end
u + v, u - v, u * n, n * u, u / n, u / vu and v durations of days and time, n a number: as for numbers, on the seconds
sqrt(x), log(x), exp(x)the numbers that give none (Feel.Analysis.Images.Number.Real)

Summary

Types

The operands, as a set of images, or every operand.

Functions

The arguments for which a call of sqrt, log or exp gives null; every number for another call.

The operands of a kind for which operator can give null, given the type of the other operand. side is the one that the operand is on.

Types

result()

@type result() :: {:ok, Feel.Type.NumberSet.t()} | :all

The operands, as a set of images, or every operand.

Functions

call(arg1)

@spec call(String.t()) :: result()

The arguments for which a call of sqrt, log or exp gives null; every number for another call.

iex> Feel.Analysis.Failure.call("sqrt") |> elem(1) |> Feel.Type.NumberSet.format()
"[-max..0)"

operand(operator, side, kind, other_type)

@spec operand(
  atom(),
  :left | :right,
  Feel.Type.Image.kind() | :number,
  Feel.Type.Union.t()
) :: result()

The operands of a kind for which operator can give null, given the type of the other operand. side is the one that the operand is on.

It is every operand if the other operand can be null or is not of the same kind, or an operation is not one of the four.

iex> alias Feel.Type.NumberSet
iex> {:ok, set} = Feel.Analysis.Failure.operand(:multiply, :left, :number, [{:number, NumberSet.point(Decimal.new(2))}])
iex> NumberSet.format(set)
"[-max..-4.999999999999999999999999999999999E+6144], [4.999999999999999999999999999999999E+6144..max]"
iex> Feel.Analysis.Failure.operand(:add, :left, :number, [:number, :null])
:all