目的: chat-Claude Antikythera 4 構造 の 2 番目 = 単一マスタ位相からの全出力導出。 1 本のクランクから 全 channel が 派生する pure TS シミュレータ。 STEP 1575 antikythera-ratio-synth (歯車列 solver) と 直接 bridge。
対応: 機械 = ラインシャフト / 電子カム (バーチャルマスタ軸) / 回路 = 単一クロックドメイン + 派生イネーブル (CDC 問題が消える) / 現代応用 = 包装機、 輪転機 (現役の設計思想)。
interface DerivedChannel {
name: string;
ratio: { p: number; q: number }; // master が q tick 進む間に channel が p tick 進む
phaseOffset?: number; // [0, 1) 初期位相
}
createPhaseSystem(masterPeriod: number, channels: DerivedChannel[]): MasterPhaseSystem
validateSystem(sys) → { valid, reason? }
tick(sys, count) → PhaseSample[]
verifyCoherence(sys, samples, tolerance?) → CoherenceVerdict
// STEP 1575 bridge
channelFromRatioSynth(name, RatioSynthResult, phaseOffset?) → DerivedChannel | null
| verdict | 意味 | 条件 |
|---|---|---|
| TRUE | 全 channel coherent | drift ≤ tolerance ∧ 全 channel 一意 ratio |
| BOTH | duplicate ratio 検出 = LCM 崩壊 | drift ≤ tolerance ∧ 2 以上 channel が 同 ratio (aliasing、 冗長) |
| NEITHER | drift 検知 (数値誤差 蓄積 or sample 不足) | drift > tolerance、 or sample < 2 |
| FALSE | misconfigured | masterPeriod ≤ 0 or 非整数 or 非整数 tooth or ratio 分母 0 |
| section | test | verdict |
|---|---|---|
| 1. config validation | 5 case (正常 + 4 invalid) | 全 PASS |
| 2. tick 基本動作 | same 1/1 + half 1/2 で t=0..8 | 期待 phase 一致 |
| 3. coherence TRUE | 2 channel 100 tick | TRUE, max drift 1.11e-16 |
| 4. duplicate ratio | Meton × 2 (同 235/19) | BOTH (LCM 崩壊 検出) |
| 5. invalid config | masterPeriod = -1 | FALSE (validation 失敗) |
| 6. STEP 1575 bridge | Meton (235/19) + Saros (32112/144) + Callippic (auto→235/19) | BOTH (Meton + Callippic 同 ratio 検出) |
| 7. phaseOffset | 同 1/1 で offset 0 vs 0.5 | BOTH (offset 違い でも 同 ratio 検出) |
import { synthesizeRatio } from './antikythera-ratio-synth';
import { channelFromRatioSynth, createPhaseSystem, tick, verifyCoherence }
from './master-phase-primitive';
// STEP 1575 solver で 歯車列 を 導出
const metonResult = synthesizeRatio(
{ name: 'Meton', targetRatio: 235 / 19, tolerance: 1e-6 },
{ minTeeth: 12, maxTeeth: 300, maxStages: 4 },
);
// → stages: [{ driverTeeth: 235, drivenTeeth: 19 }]、 verdict: TRUE
// STEP 1577 で channel に 変換 して 位相 system 構築
const metonCh = channelFromRatioSynth('Meton', metonResult);
// → { name: 'Meton', ratio: { p: 235, q: 19 } }
const sys = createPhaseSystem(360, [metonCh!]);
const samples = tick(sys, 100);
const verdict = verifyCoherence(sys, samples);
// → verdict: TRUE, maxDrift: 1.11e-16 (数値限界)