در بازبینیِ یک مرحلهٔ عددیِ کدک، «همهٔ خروجی‌ها صحیح‌اند» پاسخِ کافی نیست. ممکن است گردکردن، دو ورودی را به یک نتیجه برساند؛ ممکن هم هست اطلاعاتِ کنارگذاشته‌شده در خروجیِ دیگری حفظ شود. این درس حالتِ دوم را با تبدیلِ صحیحِ Haar می‌سازد. یک قابِ ساختگی را به تقریب و جزئیات می‌بریم و با همان اعداد بازمی‌گردانیم. موضوع، قراردادِ محاسباتیِ این جزء است؛ فایلِ صوت، برد، مدلِ گفتار و نتیجهٔ فشرده‌سازی نداریم.

۱. تقریب و جزئیات را با قراردادِ صحیح جدا کنیم

جفت قطعه‌های کنار هم و سینی‌های جدا برای جزء مشترک و تفاوت
تصویر مفهومی: جفت قطعه‌های کنار هم و سینی‌های جدا برای جزء مشترک و تفاوت؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

ورودیِ جلو یک tuple واقعی با طولِ یک، دو، چهار یا هشت و عضوهای دقیقاً int در بازهٔ منفی شانزده تا شانزده است. مقدارها شمارشِ علامت‌دارِ ساختگی و بی‌بُعدند؛ نه ولتاژِ کالیبره، نه الزاماً کُدِ PCM یا Q15. تعدادِ سطح، صحیحِ صفر تا لگاریتمِ دودوییِ طول است. طولِ فرد، قابِ خالی و کامل‌کردنِ خودکارِ مرز را نمی‌پذیریم؛ این انتخابِ آموزشی، مشخصاتِ همهٔ کتابخانه‌های موجک نیست.

در یک زوجِ مرتب، مقدارِ اول را a و دوم را b بنامیم. ابتدا اختلافِ علامت‌دارِ d=b−a را نگه می‌داریم؛ سپس تقریبِ صحیح را s=a+floor(d/2) می‌سازیم. این تقریب با floor((a+b)/2) برابر است. خروجی فقط تقریب نیست: هر دو عددِ s و d لازم‌اند. پیش‌چاپِ نویسندگان دربارهٔ تبدیل‌های صحیحِ موجک این قرارداد را S-transform و نمونه‌ای از lifting معرفی می‌کند.

اصطلاحِ Haar اینجا نباید مقیاسِ تبدیل را پنهان کند. جذرِ دو و نرمال‌سازیِ متعامد نداریم؛ همچنین اختلاف، «دوم منهای اول» است. عوض‌کردنِ علامتِ اختلاف یا ترتیبِ سینیِ ضرایب، داده‌ای با معنای دیگر می‌سازد. با حفظِ همین قرارداد، تعدادِ اعداد ثابت می‌ماند، اما دامنهٔ عددِ اختلاف ممکن است بزرگ‌تر شود. کوچک‌ترشدنِ فایل یا حذفِ اطلاعات از این دو مشاهده نتیجه نمی‌شود.

۲. گردکردنِ منفی و وارونِ گام‌های lifting

دو گیرهٔ پیاپی که با بازکردنِ ترتیبِ آن‌ها قطعهٔ اصلی آزاد می‌شود
تصویر مفهومی: دو گیرهٔ پیاپی که با بازکردنِ ترتیبِ آن‌ها قطعهٔ اصلی آزاد می‌شود؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

زوجِ هشت و سه را دستی حساب کنیم: اختلاف منفی پنج است و تقسیمِ رو به پایینِ آن بر دو، منفی سه. تقریب پنج می‌شود؛ خروجیِ مرتب پنج و منفی پنج است. در وارون، ابتدا a=s−floor(d/2) را حساب می‌کنیم و سپس b=d+a را می‌سازیم. پنج منهای منفی سه، هشت است و جمعِ هشت با منفی پنج، سه. ترتیبِ بازکردن، معکوسِ ترتیبِ بستنِ دو گام است.

مرجعِ کاملِ عملگرهای حسابیِ پایتون، عملگرِ // روی int را تقسیمِ رو به پایین تعریف می‌کند. برای منفیِ پنج، حذفِ اعشار به سوی صفر، منفی دو می‌دهد و تقریب را شش می‌کند. جالب آنکه اگر همان سیاستِ متفاوت در جلو و عقب استفاده شود، رفت‌وبرگشت می‌تواند باز هم درست باشد. پس آزمونِ رفت‌وبرگشت به‌تنهایی ثابت نمی‌کند ضرایب از قراردادِ انتخاب‌شده آمده‌اند؛ پاسخِ دستی و مرجعِ مستقل نیز لازم‌اند.

در نسخهٔ آگوستِ ۱۹۹۶ِ منبع، علامت‌های وارون در رابطهٔ ۳٫۲ِ صفحهٔ چاپیِ نوزده با تعریفِ اختلاف سازگار نیستند. رابطهٔ ۳٫۴ و وارونِ ترتیبیِ صفحاتِ بعد، علامتِ درست را دارند. این درس از همان روابطِ سازگار و استنتاجِ بالا استفاده می‌کند. این اختلاف در تصویرِ خودِ صفحه دیده می‌شود؛ خطای متن‌برداری فرض نشده و پروندهٔ منبع دست‌کاری نشده است.

دلیلِ باقی‌ماندنِ اطلاعات، هم‌زوج یا هم‌فردبودنِ جمع و اختلافِ دو صحیح است. تقریبِ پنج می‌تواند از هشت و سه یا پنج و شش آمده باشد؛ اختلاف‌ها منفی پنج و یک‌اند. اگر اختلاف را صفر کنیم، وارونِ تقریبِ پنج، زوجِ پنج و پنج می‌شود و هیچ‌کدام از آن دو ورودی نیست. حفظِ عددِ صحیح با حفظِ تمامِ اطلاعات مترادف نیست؛ ساختارِ دو خروجی تعیین‌کننده است.

۳. چند سطح، ترتیبِ ضرایب و میانگینِ تو‌در‌تو

سینی‌های تو‌در‌تو با خانهٔ مرکزی و قطعه‌هایِ جزئیاتِ محفوظ در پیرامون
تصویر مفهومی: سینی‌های تو‌در‌تو با خانهٔ مرکزی و قطعه‌هایِ جزئیاتِ محفوظ در پیرامون؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

قابِ هشت‌عضویِ هشت، سه، منفی دو، منفی پنج، چهار، پنج، منفی یک و دو را در نظر بگیریم. سطحِ اول تقریب‌های پنج، منفی چهار، چهار و صفر و جزئیاتِ منفی پنج، منفی سه، یک و سه دارد. فقط چهار تقریب دوباره جفت می‌شوند: تقریب‌های سطحِ دوم صفر و دو و جزئیاتِ آن منفی نه و منفی چهارند. سطحِ سوم، تقریبِ یک و جزئیاتِ دو می‌دهد.

چینشِ تختِ نهایی ابتدا تقریبِ آخر، سپس جزئیات از درشت‌ترین سطح به ریزترین سطح است: یک، دو، منفی نه، منفی چهار، منفی پنج، منفی سه، یک و سه. تعدادِ سطح و طول، اندازهٔ هر بخش را تعیین می‌کنند. وارون ابتدا کوچک‌ترین پیشوند را باز می‌کند و به‌ترتیب پیشوندهای بزرگ‌تر را می‌سازد. مرزِ زوج‌ها از ابتدا ثابت است؛ این برنامه جابه‌جاییِ قاب یا فازِ دلخواه را یکسان نمی‌داند.

تقریبِ آخر الزاماً یک تقسیمِ رو به پایینِ جمعِ کل نیست. در قابِ صفر، یک، صفر و سه، تقریب‌های زوج‌ها صفر و یک‌اند؛ تقریبِ بعدی صفر می‌شود، درحالی‌که floor(4/4) یک است. گردکردنِ میانی با میانگینِ یک‌باره جابه‌جا نمی‌شود. ثابت‌افزودنِ یک صحیحِ مجاز به همهٔ نمونه‌ها، تقریب‌ها را همان‌قدر جابه‌جا می‌کند و جزئیات را ثابت می‌گذارد؛ این ویژگی، مجوزِ فرضِ خطی‌بودنِ کل تبدیل نیست.

۴. کدِ کامل و مرجعِ مستقلِ قیدهای صحیح

ابزارِ جفت‌سازی در کنار شابلونِ قیدهای مستقل برای وارسیِ همان قطعه‌ها
تصویر مفهومی: ابزارِ جفت‌سازی در کنار شابلونِ قیدهای مستقل برای وارسیِ همان قطعه‌ها؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

فایلِ کامل، فقط کتابخانهٔ استانداردِ پایتون می‌خواهد. مسیرِ اصلی پیشوندِ تقریب را به‌صورتِ تکراری به‌روز می‌کند. مرجعِ تألیفی، درختِ بازه‌های دوتایی می‌سازد و تقریبِ هر گره را با یافتنِ تنها صحیحِ s که نامساویِ 2s≤a+b<2s+2 را ارضا کند به دست می‌آورد. برای وارون نیز زوجِ یکتایِ سازگار با جمع و اختلاف را جست‌وجو می‌کند؛ تابعِ اصلی، گامِ lifting و اعتبارسنجِ آن جوابِ انتظار را نمی‌سازند.

همهٔ قاب‌های سه‌مقداریِ منفی یک، صفر و یک با طول‌های مجاز و همهٔ سطح‌های همان طول، یک خانوادهٔ محدودِ مرجع‌اند. شمارِ قاب، پرس‌وجو و مؤلفه در خروجی جدا ثبت می‌شود؛ هر قاب یک گروهِ آزمونِ مستقل نیست. چهارده گروهِ نام‌دار، پاسخِ دستی، چینش، گردکردنِ منفی، قیدها، مرزِ دامنه و ویژگی‌های مرتبط را می‌سنجند. هر گروه تنها پس از برقرارشدنِ شرط‌هایش موفق گزارش می‌شود؛ توافقِ این خانواده، اثباتِ اجرای همهٔ قاب‌های ممکن نیست.

ورودِ وارون، ضرایبِ صحیحِ منفی سی‌ودو تا سی‌ودو را می‌پذیرد. این دامنه از دامنهٔ نمونهٔ جلو جداست: در شاهدِ مرزیِ خروجی، وارون مقدارِ هشتاد هم می‌سازد و تابعِ جلو به دلیلِ سقفِ شانزده، ورودِ دوبارهٔ آن را رد می‌کند. این ردشدن با صحتِ وارونِ ریاضی تعارض ندارد. همهٔ عضوها و سطح پیش از محاسبه بررسی می‌شوند؛ bool، زیرکلاس، رشته، مولد و تبدیلِ ضمنی پذیرفته نیستند.

"""Bounded integer S/Haar lifting; exact floor policy, not an audio codec."""
from itertools import product
import json
import platform
import sys


def _validated(values, levels, magnitude):
    if type(values) is not tuple or len(values) not in (1, 2, 4, 8):
        raise ValueError("tuple_length_contract")
    if any(type(value) is not int or not -magnitude <= value <= magnitude
           for value in values):
        raise ValueError("exact_integer_value_contract")
    if type(levels) is not int or not 0 <= levels < len(values).bit_length():
        raise ValueError("level_contract")
    return values


def forward_haar(samples, levels):
    """Exact tuple1/2/4/8, exact ints[-16,16], levels0..log2(N).

    Layout: final approximation, then details from coarsest to finest.
    Only each approximation prefix is transformed at the next level.
    """
    _validated(samples, levels, 16)
    work = list(samples)
    width = len(work)
    for _ in range(levels):
        low, detail = [], []
        for index in range(0, width, 2):
            even = work[index]
            difference = work[index + 1] - even
            low.append(even + difference // 2)
            detail.append(difference)
        work[:width] = low + detail
        width //= 2
    return tuple(work)


def inverse_haar(coefficients, levels):
    """Same lengths/levels, exact coefficient ints[-32,32].

    This inverse entry domain is deliberately wider: its result need not
    satisfy the forward sample cap16. No clipping or saturation is applied.
    """
    _validated(coefficients, levels, 32)
    work = list(coefficients)
    width = len(work) >> levels
    for _ in range(levels):
        expanded = []
        for index in range(width):
            average, difference = work[index], work[width + index]
            even = average - difference // 2
            expanded.extend((even, difference + even))
        work[:2 * width] = expanded
        width *= 2
    return tuple(work)


def tree_constraint_forward(samples, levels):
    """Valid fixtures only: recursive dyadic tree of integer constraints.

    No production helper, iterative prefix update or floor-division formula
    computes the expected pair mean. Search the unique feasible integer.
    """
    def fold(block):
        if len(block) == 1:
            return block[0], ()
        middle = len(block) // 2
        left, left_bands = fold(block[:middle])
        right, right_bands = fold(block[middle:])
        candidates = [s for s in range(-16, 17)
                      if 2 * s <= left + right < 2 * s + 2]
        assert len(candidates) == 1
        mean = candidates[0]
        bands = ((right - left,),) + tuple(
            a + b for a, b in zip(left_bands, right_bands))
        return mean, bands

    block_size = 1 << levels
    records = [fold(samples[offset:offset + block_size])
               for offset in range(0, len(samples), block_size)]
    return tuple(record[0] for record in records) + tuple(
        value for depth in range(levels) for _, bands in records
        for value in bands[depth])


def tree_constraint_inverse(coefficients, levels):
    """Valid fixtures only: find unique integer pair for sum/difference.

    Search candidates a with b=a+d and 2*s<=a+b<2*s+2; no inverse
    lifting formula or production call. Decode an explicit root/band tree.
    """
    roots = len(coefficients) >> levels
    bands = []
    cursor, count = roots, roots
    for _ in range(levels):
        bands.append(coefficients[cursor:cursor + count])
        cursor += count
        count *= 2
    assert cursor == len(coefficients)

    def unfold(value, depth, position):
        if depth == levels:
            return (value,)
        difference = bands[depth][position]
        candidates = [(a, a + difference) for a in range(-80, 81)
                      if -80 <= a + difference <= 80
                      and 2 * value <= 2 * a + difference < 2 * value + 2]
        assert len(candidates) == 1
        left, right = candidates[0]
        return (unfold(left, depth + 1, 2 * position)
                + unfold(right, depth + 1, 2 * position + 1))

    return tuple(value for root in range(roots)
                 for value in unfold(coefficients[root], 0, root))


def _rejected(call):
    try:
        call()
    except ValueError:
        return True
    return False


def run_example():
    checks = {}

    def check(name, condition):
        assert type(condition) is bool and condition, name
        checks[name] = condition

    pair = (8, 3)
    pair_coefficients = forward_haar(pair, 1)
    check("literal_pair_floor_mean_and_signed_detail_reconstruct_exactly",
          pair_coefficients == (5, -5)
          and inverse_haar(pair_coefficients, 1) == pair)

    literal = (8, 3, -2, -5, 4, 5, -1, 2)
    expected_levels = {
        0: literal,
        1: (5, -4, 4, 0, -5, -3, 1, 3),
        2: (0, 2, -9, -4, -5, -3, 1, 3),
        3: (1, 2, -9, -4, -5, -3, 1, 3),
    }
    actual_levels = {level: forward_haar(literal, level) for level in range(4)}
    check("literal_eight_sample_every_level_and_coarse_to_fine_layout",
          actual_levels == expected_levels
          and all(inverse_haar(value, level) == literal
                  for level, value in actual_levels.items()))
    check("level_zero_identity_singletons_and_zero_shape_are_explicit",
          forward_haar((-16,), 0) == inverse_haar((-16,), 0) == (-16,)
          and forward_haar((16,), 0) == (16,)
          and forward_haar(literal, 0) == literal
          and inverse_haar((32,), 0) == (32,)
          and all(forward_haar((0,) * n, n.bit_length() - 1) == (0,) * n
                  for n in (1, 2, 4, 8)))

    # A consistently different rounding convention can itself roundtrip.
    wrong_truncated_half = -(abs(-5) // 2)
    wrong_mean = 8 + wrong_truncated_half
    wrong_even = wrong_mean - wrong_truncated_half
    wrong_reconstruction = (wrong_even, -5 + wrong_even)
    check("negative_odd_floor_differs_even_when_wrong_truncation_roundtrips",
          -5 // 2 == -3 and wrong_truncated_half == -2
          and wrong_mean == 6 and wrong_reconstruction == pair
          and pair_coefficients != (wrong_mean, -5)
          and forward_haar((-2, -5), 1) == (-4, -3))

    nested = (0, 1, 0, 3)
    nested_coefficients = forward_haar(nested, 2)
    check("nested_rounded_pair_means_are_not_one_global_rounded_mean",
          nested_coefficients == (0, 1, 1, 3)
          and nested_coefficients[0] == 0 and sum(nested) // 4 == 1
          and inverse_haar(nested_coefficients, 2) == nested)

    other_pair = (5, 6)
    without_detail = inverse_haar((pair_coefficients[0], 0), 1)
    check("retained_detail_parity_distinguishes_equal_means_and_missing_detail",
          (sum(pair) % 2, (pair[1] - pair[0]) % 2) == (1, 1)
          and forward_haar(other_pair, 1) == (5, 1)
          and without_detail == (5, 5)
          and without_detail != pair and without_detail != other_pair)

    unit_step = forward_haar((0, 1), 1)
    double_step = forward_haar((0, 2), 1)
    check("exact_invertibility_does_not_make_integer_lifting_additive",
          unit_step == (0, 1) and double_step == (1, 2)
          and double_step != tuple(2 * value for value in unit_step))
    check("chosen_integer_coefficients_do_not_preserve_squared_sum",
          sum(value * value for value in (0, 2)) == 4
          and sum(value * value for value in double_step) == 5)

    shifted = tuple(value + 3 for value in literal)
    dc_ok = True
    for level in range(4):
        first = len(literal) >> level
        before, after = forward_haar(literal, level), forward_haar(shifted, level)
        dc_ok &= after[:first] == tuple(value + 3 for value in before[:first])
        dc_ok &= after[first:] == before[first:]
    check("admissible_integer_DC_shift_changes_only_approximation_band", bool(dc_ok))

    profiles = queries = compared_values = 0
    family_ok = True
    for size in (1, 2, 4, 8):
        for samples in product((-1, 0, 1), repeat=size):
            profiles += 1
            for level in range(size.bit_length()):
                actual = forward_haar(samples, level)
                reference = tree_constraint_forward(samples, level)
                recovered = inverse_haar(actual, level)
                independent_recovered = tree_constraint_inverse(actual, level)
                family_ok &= actual == reference and recovered == independent_recovered == samples
                queries += 1
                compared_values += size
    check("all_ternary_dyadic_vectors_levels_match_recursive_constraints_ONE_family",
          bool(family_ok) and (profiles, queries, compared_values) == (6654, 26508, 210963))

    inverse_corner = (32, -32, -32, -32, -32, -32, -32, -32)
    recovered_corner = inverse_haar(inverse_corner, 3)
    check("inverse_entry_domain_is_wider_than_forward_sample_domain",
          recovered_corner == (80, 48, 48, 16, 48, 16, 16, -16)
          and recovered_corner == tree_constraint_inverse(inverse_corner, 3)
          and _rejected(lambda: forward_haar(recovered_corner, 3)))

    class IntSubclass(int):
        pass

    class TupleSubclass(tuple):
        pass

    class CoercionTrap:
        calls = 0

        def __int__(self):
            self.calls += 1
            raise AssertionError("No numeric coercion is permitted")

        def __index__(self):
            self.calls += 1
            raise AssertionError("No indexing coercion is permitted")

    consumed = []

    def source():
        consumed.append(True)
        yield 0

    trap, generator = CoercionTrap(), source()
    invalid_values = (True, False, 1.0, "1", None, 1j, IntSubclass(1), trap, 10 ** 80)
    invalid_containers = ([], (), None, "01", b"01", (0, 0, 0),
                          (0,) * 16, TupleSubclass((0, 0)), generator)
    invalid_levels = (True, False, 1.0, "1", None, IntSubclass(1), trap, -1, 4)
    invalid_checks = []
    for function in (forward_haar, inverse_haar):
        invalid_checks.extend(_rejected(lambda v=v, f=function: f((0, v), 1))
                              for v in invalid_values)
        invalid_checks.extend(_rejected(lambda v=v, f=function: f(v, 0))
                              for v in invalid_containers)
        invalid_checks.extend(_rejected(lambda v=v, f=function: f((0, 0), v))
                              for v in invalid_levels)
        invalid_checks.append(_rejected(lambda f=function: f((0,) * 7 + (trap,), 3)))
    check("strict_whole_inputs_reject_late_types_and_leave_hooks_generators_untouched",
          all(invalid_checks) and trap.calls == 0 and consumed == [])

    endpoint_ok = (forward_haar((-16, 16), 1) == (0, 32)
                   and forward_haar((16, -16), 1) == (0, -32)
                   and forward_haar((16,) * 8, 3) == (16, 0, 0, 0, 0, 0, 0, 0)
                   and forward_haar((-16,) * 8, 3) == (-16, 0, 0, 0, 0, 0, 0, 0)
                   and _rejected(lambda: forward_haar((17,), 0))
                   and _rejected(lambda: inverse_haar((33,), 0))
                   and _rejected(lambda: forward_haar((0,), 1))
                   and _rejected(lambda: inverse_haar((0, 0), 2)))
    check("sample_detail_coefficient_length_and_level_endpoints_are_explicit", endpoint_ok)

    before = (literal, actual_levels[3])
    detached = list(forward_haar(literal, 3))
    detached[0] = -999
    forward_haar((-16, 16), 1)
    inverse_haar(inverse_corner, 3)
    check("immutable_inputs_results_and_intervening_calls_have_no_hidden_state",
          (literal, actual_levels[3]) == before
          and forward_haar(literal, 3) == actual_levels[3]
          and inverse_haar(actual_levels[3], 3) == literal
          and type(forward_haar(literal, 3)) is tuple
          and type(inverse_haar(actual_levels[3], 3)) is tuple)
    assert len(checks) == 14
    return {
        "runtime": {"python": platform.python_version(), "implementation": platform.python_implementation()},
        "dependencies": "Python standard library only",
        "units": "Original synthetic dimensionless signed sample counts; squared sums are not joules or acoustic power",
        "format": "Final approximation band, then detail bands from coarsest to finest; no padding or saturation",
        "input_profile": {"lengths": (1, 2, 4, 8), "sample_range": (-16, 16),
                          "inverse_coefficient_range": (-32, 32), "levels": "0..log2(N), exact int"},
        "manual_pair": {"samples": pair, "coefficients": pair_coefficients,
                        "wrong_truncated_mean": wrong_mean, "wrong_policy_roundtrip": wrong_reconstruction},
        "manual_multilevel": {"samples": literal, "coefficients_by_level": actual_levels,
                              "reconstructed": inverse_haar(actual_levels[3], 3)},
        "nested_rounding": {"samples": nested, "coefficients": nested_coefficients,
                            "one_global_rounded_mean": sum(nested) // 4},
        "dropped_detail_reconstruction": without_detail,
        "nonadditivity": {"F_0_1": unit_step, "F_0_2": double_step},
        "squared_sum_counterexample": {"input": 4, "coefficients": 5},
        "wider_inverse_profile": {"coefficients": inverse_corner, "reconstruction": recovered_corner,
                                  "forward_reentry_rejected": True},
        "finite_family": {"distinct_vectors": profiles, "forward_level_queries": queries,
                          "compared_coordinates": compared_values, "meaningful_groups": 1,
                          "reference": "Recursive tree plus unique integer sum/difference inequalities; no production helpers"},
        "invalid_API_profiles_inside_one_group": len(invalid_checks),
        "checks": checks, "unique_executed_checks": len(checks), "all_passed": True,
        "limits": ["Own bounded integer S/Haar convention, not normalized linear orthogonal Haar",
                   "Forward and inverse entry caps differ; inverse-first reentry is not always admitted",
                   "No byte format, entropy coding, JPEG2000 compatibility or compressed-size result",
                   "No MATLAB/PyWavelets/audio/model/hardware execution or quality/performance claim"],
    }


if __name__ == "__main__":
    payload = json.dumps(run_example(), ensure_ascii=True, indent=2, allow_nan=False) + "\n"
    sys.stdout.buffer.write(payload.encode("ascii"))

خروجیِ زیر، تمامِ اعدادِ نمونه و شرط‌های همان برنامه را ثبت می‌کند. صفرِ سطح یعنی همانی و طولِ یک فقط همین سطح را می‌پذیرد. ورودی‌ها تغییر نمی‌کنند و نتیجه tuple است؛ برای یک tuple تغییرناپذیر، تفاوتِ هویتِ شیء وعده داده نمی‌شود. ضربِ Q15 و اشباع مسئلهٔ جداگانه‌ای دربارهٔ کاهشِ مقیاس و اطلاعاتِ ازدست‌رفته دارد؛ اینجا هیچ اشباعی اعمال نمی‌شود.

{
  "runtime": {
    "python": "3.14.5",
    "implementation": "CPython"
  },
  "dependencies": "Python standard library only",
  "units": "Original synthetic dimensionless signed sample counts; squared sums are not joules or acoustic power",
  "format": "Final approximation band, then detail bands from coarsest to finest; no padding or saturation",
  "input_profile": {
    "lengths": [
      1,
      2,
      4,
      8
    ],
    "sample_range": [
      -16,
      16
    ],
    "inverse_coefficient_range": [
      -32,
      32
    ],
    "levels": "0..log2(N), exact int"
  },
  "manual_pair": {
    "samples": [
      8,
      3
    ],
    "coefficients": [
      5,
      -5
    ],
    "wrong_truncated_mean": 6,
    "wrong_policy_roundtrip": [
      8,
      3
    ]
  },
  "manual_multilevel": {
    "samples": [
      8,
      3,
      -2,
      -5,
      4,
      5,
      -1,
      2
    ],
    "coefficients_by_level": {
      "0": [
        8,
        3,
        -2,
        -5,
        4,
        5,
        -1,
        2
      ],
      "1": [
        5,
        -4,
        4,
        0,
        -5,
        -3,
        1,
        3
      ],
      "2": [
        0,
        2,
        -9,
        -4,
        -5,
        -3,
        1,
        3
      ],
      "3": [
        1,
        2,
        -9,
        -4,
        -5,
        -3,
        1,
        3
      ]
    },
    "reconstructed": [
      8,
      3,
      -2,
      -5,
      4,
      5,
      -1,
      2
    ]
  },
  "nested_rounding": {
    "samples": [
      0,
      1,
      0,
      3
    ],
    "coefficients": [
      0,
      1,
      1,
      3
    ],
    "one_global_rounded_mean": 1
  },
  "dropped_detail_reconstruction": [
    5,
    5
  ],
  "nonadditivity": {
    "F_0_1": [
      0,
      1
    ],
    "F_0_2": [
      1,
      2
    ]
  },
  "squared_sum_counterexample": {
    "input": 4,
    "coefficients": 5
  },
  "wider_inverse_profile": {
    "coefficients": [
      32,
      -32,
      -32,
      -32,
      -32,
      -32,
      -32,
      -32
    ],
    "reconstruction": [
      80,
      48,
      48,
      16,
      48,
      16,
      16,
      -16
    ],
    "forward_reentry_rejected": true
  },
  "finite_family": {
    "distinct_vectors": 6654,
    "forward_level_queries": 26508,
    "compared_coordinates": 210963,
    "meaningful_groups": 1,
    "reference": "Recursive tree plus unique integer sum/difference inequalities; no production helpers"
  },
  "invalid_API_profiles_inside_one_group": 56,
  "checks": {
    "literal_pair_floor_mean_and_signed_detail_reconstruct_exactly": true,
    "literal_eight_sample_every_level_and_coarse_to_fine_layout": true,
    "level_zero_identity_singletons_and_zero_shape_are_explicit": true,
    "negative_odd_floor_differs_even_when_wrong_truncation_roundtrips": true,
    "nested_rounded_pair_means_are_not_one_global_rounded_mean": true,
    "retained_detail_parity_distinguishes_equal_means_and_missing_detail": true,
    "exact_invertibility_does_not_make_integer_lifting_additive": true,
    "chosen_integer_coefficients_do_not_preserve_squared_sum": true,
    "admissible_integer_DC_shift_changes_only_approximation_band": true,
    "all_ternary_dyadic_vectors_levels_match_recursive_constraints_ONE_family": true,
    "inverse_entry_domain_is_wider_than_forward_sample_domain": true,
    "strict_whole_inputs_reject_late_types_and_leave_hooks_generators_untouched": true,
    "sample_detail_coefficient_length_and_level_endpoints_are_explicit": true,
    "immutable_inputs_results_and_intervening_calls_have_no_hidden_state": true
  },
  "unique_executed_checks": 14,
  "all_passed": true,
  "limits": [
    "Own bounded integer S/Haar convention, not normalized linear orthogonal Haar",
    "Forward and inverse entry caps differ; inverse-first reentry is not always admitted",
    "No byte format, entropy coding, JPEG2000 compatibility or compressed-size result",
    "No MATLAB/PyWavelets/audio/model/hardware execution or quality/performance claim"
  ]
}

۵. چهار پرسش دربارهٔ انرژی، حذفِ ضریب و کدک

جعبهٔ کاملِ قطعه‌ها در کنار جعبه‌ای که یک جزءِ ضروری از آن برداشته شده است
تصویر مفهومی: جعبهٔ کاملِ قطعه‌ها در کنار جعبه‌ای که یک جزءِ ضروری از آن برداشته شده است؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

پرسشِ اول: آیا گردکردنِ تقریب الزاماً بازسازی را ناممکن می‌کند؟ پاسخ: نه؛ اختلافِ حفظ‌شده، بیتِ زوجیتِ حذف‌شده از جمع را مشخص می‌کند. با همان تقسیمِ رو به پایین، ابتدا نمونهٔ اول و سپس دوم بازمی‌گردد. اگر جزئیات حذف یا سیاستِ دو مسیر متفاوت شود، این استدلال دیگر تضمینِ بازسازیِ ورودیِ اصلی نیست.

پرسشِ دوم: آیا تقریبِ نهایی همان میانگینِ صحیحِ کل قاب است؟ پاسخ: در چند سطح، لزوماً نه. شاهدِ صفر، یک، صفر و سه، تقریبِ نهاییِ صفر و میانگینِ یک‌بارهٔ یک دارد. ترتیبِ گردکردن‌های زوجی جزئی از الگوریتم است و نمی‌توان آن را با جمع و تقسیمِ نهایی جایگزین کرد.

پرسشِ سوم: بازسازیِ کامل، حفظِ انرژی را هم ثابت می‌کند؟ پاسخ: خیر. صفر و دو به یک و دو می‌روند؛ مجموعِ مربع‌ها چهار و پنج است. همچنین دو برابرِ تبدیلِ صفر و یک، با تبدیلِ صفر و دو برابر نیست. پس این نگاشتِ صحیح خطی و متعامد نیست. ترازِ انرژیِ DCT متعامدِ قاب را نمی‌توان به آن منتقل کرد؛ مربع‌ها نیز اینجا ژول یا توانِ صوت نیستند.

پرسشِ چهارم: آیا همین خروجی یک فایلِ فشردهٔ صوت یا کدکِ سازگار با JPEG2000 است؟ پاسخ: خیر؛ همان تعداد صحیح را داریم و جزئیات ممکن است بازهٔ بیشتری بخواهند. قالبِ بایتی، کدگذاریِ آنتروپی، حذفِ ضریب، سرریزِ ثبات و معیارِ شنیداری پیاده نشده‌اند. هیچ MATLAB، کتابخانهٔ موجک، پردازنده یا صدای واقعی برای کیفیت، سرعت یا حجم آزموده نشده است.

منابع در ۳۰ مهر ۱۴۰۵ خوانده شدند. پروندهٔ مقاله، پیش‌چاپِ آگوستِ ۱۹۹۶ است؛ سالِ چاپِ مجله ۱۹۹۸ جداست. مرجعِ زبان نسخهٔ 3.14.9 دارد و نسخهٔ اجرای برنامه در خروجی ثبت می‌شود؛ تاریخِ انتشارِ اولیهٔ صفحهٔ مستندات مشخص نیست. دو زمینهٔ مرتبط، متن‌های کاملِ ذخیره‌شده با هویتِ انتشار در تصویرِ موفقِ ۲۱ اکتبرِ ساعتِ حدودِ ۱۶:۳۸ تهران‌اند؛ برای پیوندهایِ همین لحظه، ادعای بررسیِ برخط نداریم.

منابع و مطالعهٔ بیشتر

بررسی منابع: ۳۰ مهر ۱۴۰۵. تحلیل‌ها و پیشنهادهای اجرایی، جمع‌بندی نویسنده‌اند.