Skip to content

Commit bb8b614

Browse files
hyperpolymathclaude
andcommitted
feat: implement Phase 1 — ternary probabilistic modelling core
Rewrite manifest to parse betlangiser.toml with probabilistic variable declarations (Normal, Uniform, Beta, Bernoulli, Custom distributions), simulation config (samples, confidence, seed, output format), and full parameter validation. Implement ABI types: Distribution with validated constructors, TernaryBool with complete Kleene strong three-valued logic (AND/OR/NOT/ implies), ConfidenceInterval, SimulationConfig, and SimulationResult. Add codegen submodules (parser, distribution, codegen) that generate Betlang source code with distribution declarations, uncertainty propagation rules, ternary logic helpers, and Monte Carlo entry points. 84 tests pass: unit tests for all ABI types, codegen modules, manifest validation, and integration tests covering init, generate, end-to-end pipeline, De Morgan's laws for ternary logic, and all distribution types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 546fedb commit bb8b614

11 files changed

Lines changed: 3270 additions & 47 deletions

File tree

Cargo.lock

Lines changed: 906 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# betlangiser manifest — Risk model example
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
#
4+
# This example demonstrates ternary probabilistic modelling with betlangiser.
5+
# Three variables model a simplified pricing scenario:
6+
# - price: normally distributed around 100 with std_dev 5
7+
# - demand: uniformly distributed between 50 and 150 units
8+
# - will-buy: a Bernoulli variable representing purchase likelihood (70%)
9+
#
10+
# The generated Betlang code wraps these in probability distributions,
11+
# applies Kleene ternary logic to the Bernoulli variable, and runs
12+
# a Monte Carlo simulation to estimate confidence intervals.
13+
14+
[project]
15+
name = "risk-model"
16+
description = "Probabilistic pricing model with ternary purchase logic"
17+
18+
[[variables]]
19+
name = "price"
20+
distribution = "normal"
21+
mean = 100.0
22+
std-dev = 5.0
23+
24+
[[variables]]
25+
name = "demand"
26+
distribution = "uniform"
27+
min = 50.0
28+
max = 150.0
29+
30+
[[variables]]
31+
name = "will-buy"
32+
distribution = "bernoulli"
33+
probability = 0.7
34+
35+
[simulation]
36+
samples = 10000
37+
confidence = 0.95
38+
seed = 42
39+
output-format = "text"

0 commit comments

Comments
 (0)