t27.aiEnglish

GF6: шесть битов

Вы узнаете

Как правило делит 6 битов на 1 + 2 + 3 и что значит смещение 1.

В GF6 6 битов: 1 знак, 2 порядка, 3 мантиссы. Два бита порядка дают коды от 0 до 3, и со смещением 1 масштаб идёт от 2^-1 до 2^2. Отношение E / M равно 0.667, на 0.049 от 1 / phi. В спеке есть и строка статуса: смещение не выводится из замкнутой формулы, оно выбирается для каждого формата, и спека так и пишет.

Попробуйте

Найдите BIAS и EXP_MAX в gf6.t27 и сверьте их с 2^(E-1) - 1 и 2^E - 1. Затем прочитайте PHI_BIAS_STATUS и скажите, что он признаёт.

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

GoldenFloat 8: GF6, six bits
GoldenFloat 8: GF6, six bits ↗

GF6: 6 bits as the spec lays them out, read from gf6.t27. Lesson 8 of the GoldenFloat course.

specs/numeric/gf6.t27

// SPDX-License-Identifier: Apache-2.0
; gf6.t27 -- GoldenFloat6 Encode/Decode
; GF6: 6-bit floating point with 1 sign + 2 exponent + 3 mantissa
; Bit layout: [S(1) E(2) M(3)] = [5:5][4:3][2: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-gf6;

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

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

pub const SIGN_SHIFT : u16 = 5;
pub const EXP_SHIFT  : u16 = 3;
pub const MANT_SHIFT : u16 = 0;

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

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

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

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

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

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

invariant gf6_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((6-1)/phi^2) = 2, m = 3)
;        or RTL emission diverges from this constant set.
;        As of W601 the Fpath above is CHECKED by the invariants in this file.
; ============================================================================

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

Все уроки