t27.aiEnglish

GF96: девяносто шесть битов

Вы узнаете

Почему спека 96-битного числа записывает смещение выражением, а не числом.

В GF96 96 битов: 1 знак, 36 порядка, 59 мантиссы. Его смещение, 2^35 - 1, уже не помещается в 64-битные целые, которыми спека пользуется для малых форматов, поэтому спека пишет его текстом 2^(36-1) - 1 и проверяет раскладку инвариантами. Отношение E / M равно 0.610.

Попробуйте

Найдите BIAS_EXPR и EXP_MAX_EXPR в gf96.t27 и сравните с BIAS в gf48.t27. Затем прочитайте инварианты и скажите, что проверяет каждый.

Открыть интерактивный урок →

GoldenFloat 19: GF96, ninety-six bits
GoldenFloat 19: GF96, ninety-six bits ↗

GF96: 96 bits as the spec lays them out, read from gf96.t27. Lesson 19 of the GoldenFloat course.

specs/numeric/gf96.t27

// SPDX-License-Identifier: Apache-2.0
; gf96.t27 -- GoldenFloat96 Encode/Decode
; GF96: 96-bit floating point with 1 sign + 36 exponent + 59 mantissa
; Bit layout: [S(1) E(36) M(59)] = [95:95][94:59][58:0]
; phi^2 + 1/phi^2 = 3 | TRINITY
; Generated by the closed-form rule e = round((N-1)/phi^2), m = N-1-e.
; STATUS: Conj (spec-only; no RTL on this repo's path).

module triformat-gf96;

// ============================================================================
// Constants -- derived from the closed-form rule
// ============================================================================

pub const TOTAL_BITS : u16 = 96;
pub const SIGN_BITS  : u8 = 1;
pub const EXP_BITS   : u8 = 36;
pub const MANT_BITS  : u16 = 59;

pub const SIGN_SHIFT : u16 = 95;
pub const EXP_SHIFT  : u16 = 59;
pub const MANT_SHIFT : u16 = 0;

; BIAS = 2^(35) - 1   -- multi-word constant (exceeds u64); see codegen
; EXP_MAX = 2^36 - 1   -- multi-word constant (exceeds u64)
pub const BIAS_EXPR    : str = "2^(36-1) - 1";
pub const EXP_MAX_EXPR : str = "2^36 - 1";

// E/M ratio (target: 1/phi ~ 0.6180339887)
pub const EM_RATIO   : f64 = 0.610169491525;
pub const PHI_DIST   : f64 = 0.007864497224;

pub const PHI_BIAS_STATUS : str = "OPEN -- not derivable from closed form; empirical per format";

// PHI_BIAS for this rung is NOT defined. The published formula
// PHI_BIAS = EXP_MAX - BIAS reproduces GF64 only and is RETRACTED as a general law.
// Do NOT invent a value via Fibonacci/Lucas/square coincidence; those are
// descriptive, not prescriptive.

// ============================================================================
// Invariants -- the Fpath below, made executable (W601)
//
// This file declared its own falsification path in a comment and nothing
// checked it. W600's per-test measurement found 38 specs that compile while
// asserting nothing; this is one, and the rule it is derived from is stated
// precisely enough to be a test.
// ============================================================================

invariant gf96_field_widths_partition_the_word {
    @compileAssert(SIGN_BITS + EXP_BITS + MANT_BITS == TOTAL_BITS);
}

invariant gf96_closed_form_mantissa {
    // m = N - 1 - e, the second half of the generating rule
    @compileAssert(MANT_BITS == TOTAL_BITS - 1 - EXP_BITS);
}

invariant gf96_closed_form_exponent {
    // e = round((N-1)/phi^2)  <=>  (e - 1/2)*phi^2 <= N-1 <= (e + 1/2)*phi^2
    // Stated as bounds because the rule rounds; phi^2 = 2.618033988749895.
    @compileAssert((EXP_BITS as f64 - 0.5) * 2.618033988749895 <= TOTAL_BITS as f64 - 1.0);
    @compileAssert(TOTAL_BITS as f64 - 1.0 <= (EXP_BITS as f64 + 0.5) * 2.618033988749895);
}

invariant gf96_shifts_follow_the_layout {
    @compileAssert(SIGN_SHIFT == TOTAL_BITS - 1);
    @compileAssert(EXP_SHIFT == MANT_BITS);
    @compileAssert(MANT_SHIFT == 0);
}

; ============================================================================
; Claim-status: Conj
; Fpath: closed-form rule mis-applied (verify e = round((96-1)/phi^2) = 36, m = 59)
;        or RTL emission diverges from this constant set.
;        As of W601 the Fpath above is CHECKED by the invariants in this file.
; ============================================================================

Открыть спеку урока в плеере ↗

Все уроки