Module spec/numeric

spec/numeric
Stability: unstable — may still change; see below.

Numeric refinement families — real predicates over the refine(T, p) surface (V6 task 3, plans/backlog/FORMAL_VERIFICATION.md §7; breaking-change ledger entry 3). Each family is a comptime alias whose predicate ghost is spelled INSIDE the alias body: the alias's comptime T is in scope at ghost creation, so every Positive(i32) evaluation creates a fully concrete predicate.

{ Positive, check_positive } :: import("std/spec/numeric");

recipl :: (fn(x : Positive(i32)) -> i32)(i32(1) / x);   // p assumed at entry

match(check_positive(i32(3)),        // runtime gate: Option(Positive(i32))
  .Some(v) => recipl(v),
  .None    => i32(0)
);

Stability

unstable — outside the std stability promise entirely; the verification campaign is still shaping this surface.

Types

Positive type-function
fn(T : Type) -> Type

Positive(T) — strictly greater than zero.

Type Parameters

NameTypeNotes
TTypecomptime
Negative type-function
fn(T : Type) -> Type

Negative(T) — strictly less than zero.

Type Parameters

NameTypeNotes
TTypecomptime
NonNegative type-function
fn(T : Type) -> Type

NonNegative(T) — greater than or equal to zero.

Type Parameters

NameTypeNotes
TTypecomptime
NonPositive type-function
fn(T : Type) -> Type

NonPositive(T) — less than or equal to zero.

Type Parameters

NameTypeNotes
TTypecomptime
Even type-function
fn(T : Type) -> Type

Even(T) — divisible by two.

Type Parameters

NameTypeNotes
TTypecomptime
Odd type-function
fn(T : Type) -> Type

Odd(T) — not divisible by two.

Type Parameters

NameTypeNotes
TTypecomptime

Functions

check_positive function
fn(generic(T : Type), x : T) -> Option(Positive(T))

check_positive(x) — the Positive family's runtime gate.

Type Parameters

NameTypeNotes
TTypecomptime

Parameters

NameTypeNotes
xT

Returns: Option(Positive(T))

check_negative function
fn(generic(T : Type), x : T) -> Option(Negative(T))

check_negative(x) — the Negative family's runtime gate.

Type Parameters

NameTypeNotes
TTypecomptime

Parameters

NameTypeNotes
xT

Returns: Option(Negative(T))

fn(generic(T : Type), x : T) -> Option(NonNegative(T))

check_non_negative(x) — the NonNegative family's runtime gate.

Type Parameters

NameTypeNotes
TTypecomptime

Parameters

NameTypeNotes
xT

Returns: Option(NonNegative(T))

fn(generic(T : Type), x : T) -> Option(NonPositive(T))

check_non_positive(x) — the NonPositive family's runtime gate.

Type Parameters

NameTypeNotes
TTypecomptime

Parameters

NameTypeNotes
xT

Returns: Option(NonPositive(T))

check_even function
fn(generic(T : Type), x : T) -> Option(Even(T))

check_even(x) — the Even family's runtime gate.

Type Parameters

NameTypeNotes
TTypecomptime

Parameters

NameTypeNotes
xT

Returns: Option(Even(T))

check_odd function
fn(generic(T : Type), x : T) -> Option(Odd(T))

check_odd(x) — the Odd family's runtime gate.

Type Parameters

NameTypeNotes
TTypecomptime

Parameters

NameTypeNotes
xT

Returns: Option(Odd(T))