본문으로 건너뛰기
cccskills
무료GitHub에 공개

abductive-monte-carlo

Retroductive hypothesis sampling via MCMC: given observations, importance-sample explanations weighted by P(observation|hypothesis) using Gay.jl colored particles as hypothesis candidates.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md6.1 KB
  • CONCOMITANT_SKILLS.md1.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Abductive Monte Carlo

"Abduction is not exhaustive search; it is well-directed wandering in hypothesis space."

Trit: -1 (MINUS — retroductive: from effects back to causes)

GF(3) Triad

abductive-monte-carlo (-1) ⊗ abductive-repl (0) ⊗ gay-monte-carlo (+1) = 0 ✓
TritSkillRole
+1gay-monte-carloGenerative: colored particle distributions as priors
0abductive-replCoordinator: REPL test/refine loop
-1abductive-monte-carloRetroductive: MCMC sampling back to causes

Core Idea

Classical abduction: given rule A → E and evidence E, hypothesize A.

Abductive Monte Carlo extends this to noisy, high-dimensional settings:

P(H | E) ∝ P(E | H) · P(H)
             ─────────────────
               likelihood × prior

Instead of enumerating hypotheses, we sample them. Gay.jl provides:

  • Deterministic colored particles as hypothesis identities
  • SplitMix64 seed evolution for reproducible chains
  • Gamut-aware weighting (hypotheses far from sRGB boundary penalized)

Algorithm

Metropolis-Hastings on Hypothesis Space

def abductive_mcmc(observation, n_samples=10_000, seed=0xcd0a0fde6e0a8820):
    """
    Sample hypotheses H from P(H|E) ∝ P(E|H) · P(H)
    using Gay.jl particle coloring for deterministic identity.
    """
    current = initial_hypothesis(seed)
    samples = []

    for i in range(n_samples):
        # Propose: step in Gay.jl color space
        proposal = gay_next_color(current.seed)

        # Likelihood: P(observation | hypothesis)
        log_like_curr = log_likelihood(observation, current)
        log_like_prop = log_likelihood(observation, proposal)

        # Prior: gamut penalty
        log_prior_curr = log_prior(current)
        log_prior_prop = log_prior(proposal)

        # Accept/reject (log-space)
        log_ratio = (log_like_prop + log_prior_prop) - (log_like_curr + log_prior_curr)
        if log(uniform()) < log_ratio:
            current = proposal

        samples.append(current)

    return samples

Importance Sampling Variant (for color abduction)

using Gay, MonteCarloMeasurements

function abduce_mcmc(obs_rgb::RGB, seed::UInt64; n=2000)
    # Prior: uniform over Gay.jl color space
    candidates = [gay_color_at(seed, i) for i in 1:n]

    # Likelihood: Gaussian in CIELAB distance
    weights = [exp(-ciede2000(obs_rgb, c)^2 / 2σ²) for c in candidates]
    weights ./= sum(weights)

    # Weighted sample → ranked hypotheses
    ranked = sortperm(weights, rev=true)
    [(candidates[i], weights[i]) for i in ranked[1:10]]
end

State Representation

Each hypothesis is a Gay particle — a colored point in hypothesis space:

H = (seed: UInt64, color: RGB, index: Int, log_weight: Float64)

Seed evolution:
  seed_{n+1} = splitmix64(seed_n XOR observation_hash)

Proof-State Abduction (causal integration)

In the causal/proofgeneral context, abductive-monte-carlo can retroductively infer which lemmas/tactics led to a given proof state:

(defun abductive-mcmc-infer-proof-history (goal-state n-samples)
  "Given a GOAL-STATE (Γ ⊢ G), sample likely proof histories via MCMC."
  (let* ((obs-hash (sxhash goal-state))
         (tactic-vocab (self-walker--discover-tactics))
         (chains (abductive-mcmc-sample obs-hash tactic-vocab n-samples)))
    ;; Return ranked proof history hypotheses
    (abductive-mcmc-rank chains)))

Output Format

Observation: ⊢ n + 0 = n

Top-5 Abduced Proof Paths (MCMC, n=10000, seed=0xcd0a0fde6e0a8820):

  [1] intro n; simp       weight=0.412  color=RGB(200, 120, 180)
  [2] intro n; ring       weight=0.301  color=RGB(198, 118, 177)
  [3] intro n; omega      weight=0.187  color=RGB(203, 123, 182)
  [4] intro n; exact rfl  weight=0.074  color=RGB(196, 116, 175)
  [5] norm_num            weight=0.026  color=RGB(205, 125, 184)

GF(3) walk hash: 0x9F3A (Möbius product of tactic trits)
Chain acceptance rate: 0.31  (healthy MH range)

Protocol

1. Encode observation

obs_hash = sxhash(observation_string) ^ 0x9E3779B97F4A7C15

2. Initialize chain

h0 = gay_color_at(seed, obs_hash % 1_000_000)  # start in color space

3. Run MCMC

Metropolis-Hastings with Gay.jl next-color proposals, 10k steps default.

4. Extract MAP hypothesis

map_hypothesis = max(samples, key=lambda h: h.log_weight)

5. Roundtrip verify

prediction = forward_simulate(map_hypothesis)
assert ciede2000(prediction, observation) < threshold

Integration Points

  • self-walker (causal): feed terminal proof state as observation → abduce proof history
  • gay-monte-carlo: particle distributions → hypothesis priors
  • abductive-repl: REPL-test the top MCMC hypothesis
  • causal-catcolab: export MAP hypothesis as CatColab olog

Configuration

abductive-monte-carlo:
  n_samples: 10_000
  burn_in: 1_000
  seed: 0xcd0a0fde6e0a8820
  likelihood:
    metric: ciede2000        # color distance
    sigma: 5.0
  prior:
    gamut_penalty: true
    boundary_sigma: 10.0
  output:
    top_k: 10
    show_chain: false

Justfile

abduce-mcmc obs="0 120 180":
    julia -e 'using AbductiveMC; abduce_mcmc(RGB($(obs)))'

abduce-proof goal:
    emacs --batch -l causal-catcolab \
          --eval "(abductive-mcmc-infer-proof-history \"$(goal)\" 5000)"

abduce-test n="1000":
    julia -e 'using AbductiveMC; roundtrip_accuracy(n=$(n))'

Related Skills

  • abductive-repl (0): interactive hypothesis-test loop
  • gay-monte-carlo (+1): colored particle distributions, gamut-aware sampling
  • self-walker (0): proof-state walker that generates observations to abduce
  • lean-proof-walk (+1): proof state chains — can be observed for retroduction
  • fokker-planck-analyzer (-1): equilibrium distribution of Markov chain

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Model ElevenLabs voice synthesis as an ACSet schema with Unison ability handlers for typed voice operations. Use when integrating ElevenLabs TTS into category-theoretic pipelines, building typed voice synthesis workflows, or managing multi-voice narration with GF(3) conservation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

plurigrid/asi702026년 7월 10일 업데이트

Systematic process for analyzing and modernizing legacy applications to comply with the 12-Factor App methodology. Covers code analysis, configuration externalization, dependency management, and container/Kubernetes best practices.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

plurigrid/asi702026년 7월 10일 업데이트

13c0e3

무료

Gay MCP skill at invocation 26

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

plurigrid/asi702026년 7월 10일 업데이트

19d57d

무료

Gay MCP skill at invocation 5

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

plurigrid/asi702026년 7월 10일 업데이트

1ea91a

무료

Gay MCP skill at invocation 27

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

plurigrid/asi702026년 7월 10일 업데이트

1eab21

무료

Gay MCP skill at invocation 3

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

plurigrid/asi702026년 7월 10일 업데이트

plurigrid의 스킬 모두 보기

이 스킬의 문제 신고