t27.aiEnglish

GF10: десять битов

Вы узнаете

Как 10 битов делятся на 1 + 3 + 6 и почему его отношение стоит в 0.118 от 1 / phi.

В GF10 10 битов: 1 знак, 3 порядка, 6 мантиссы, смещение 3. Правило даёт E = round(9 / phi^2) = 3, а E / M равно 0.5, на том же расстоянии 0.118 от 1 / phi, что и у GF4. Платой служит округление до целых битов: на малых ширинах выбирать почти не из чего.

Попробуйте

Найдите EM_RATIO и PHI_DIST в gf10.t27. Затем посчитайте round(9 / phi^2) сами и сверьте с EXP_BITS.

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

GoldenFloat 10: GF10, ten bits
GoldenFloat 10: GF10, ten bits ↗

GF10: 10 bits as the spec lays them out, read from gf10.t27. Lesson 10 of the GoldenFloat course.

specs/numeric/gf10.t27

// SPDX-License-Identifier: Apache-2.0
; gf10.t27 -- GoldenFloat10 Encode/Decode
; GF10: 10-bit floating point with 1 sign + 3 exponent + 6 mantissa
; Bit layout: [S(1) E(3) M(6)] = [9:9][8:6][5: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 (closed-form rule, no RTL yet on this repo).

module triformat-gf10;

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

pub const TOTAL_BITS : u16 = 10;
pub const SIGN_BITS  : u8 = 1;
pub const EXP_BITS   : u8 = 3;
pub const MANT_BITS  : u16 = 6;

pub const SIGN_SHIFT : u16 = 9;
pub const EXP_SHIFT  : u16 = 6;
pub const MANT_SHIFT : u16 = 0;

pub const BIAS    : u64 = 3;        // 2^(E-1) - 1
pub const EXP_MAX : u64 = 7;     // 2^E - 1

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

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 gf10_field_widths_partition_the_word {
    @compileAssert(SIGN_BITS + EXP_BITS + MANT_BITS == TOTAL_BITS);
}

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

invariant gf10_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 gf10_shifts_follow_the_layout {
    @compileAssert(SIGN_SHIFT == TOTAL_BITS - 1);
    @compileAssert(EXP_SHIFT == MANT_BITS);
    @compileAssert(MANT_SHIFT == 0);
}

invariant gf10_bias_identity {
    // BIAS = 2^(E-1) - 1, as the declaration's own comment states
    @compileAssert(BIAS == (1 << (EXP_BITS - 1)) - 1);
}

invariant gf10_exp_max_identity {
    // EXP_MAX = 2^E - 1
    @compileAssert(EXP_MAX == (1 << EXP_BITS) - 1);
}

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

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

Все уроки