Bounded polynomial provenance for positive relational queries, witnesses and exact possible-world evaluation
moon check --deny-warn --target all -j 1
moon build --deny-warn --target js -j 1
moon test --deny-warn --target js -j 1
moon run cmd/demo --target js
node scripts/cli.mjs examples.json
python scripts/oracle.py
moon test --deny-warn --target js -j 1$env:MOON_HOME = 'D:/moonbit/_tools/moon-audit-20261118'
$env:PATH = "$env:MOON_HOME/bin;$env:PATH"let orders = @why.source(
["customer", "product"],
[["Ada", "P1"], ["Ada", "P2"]],
["o1", "o2"],
).unwrap()
let stock = @why.source(
["product"], [["P1"], ["P2"]], ["s1", "s2"],
).unwrap()
let result = @why.project(
@why.natural_join(orders, stock).unwrap(), ["customer"],
).unwrap()
let explanation = result.rows[0].annotation
let sufficient = @why.witnesses(explanation).unwrap()
// sufficient = [["o1", "s1"], ["o2", "s2"]]
let remaining = @why.delete_tokens(result, ["s2"]).unwrap()| API | 输入 → 输出 |
|---|---|
| source / relation | 源表或注释行 → 校验、合并同值元组后的关系 |
| select_equal / project / rename | 关系 → 筛选、列投影或重命名 |
| union_all / natural_join | 两个关系 → 注释加法或乘法传播 |
| delete_tokens | 关系、删除 token → 精确保留未使用这些 token 的推导 |
| polynomial / token / constant | 非负整数项 → 规范多项式 |
| add / multiply / derivative | 注释 → 合并、组合或形式灵敏度 |
| evaluate | 注释、非负实数权重 → 半环代入值 |
| survives / witnesses | 注释 → 删除后的存在性 / 包含意义下最小充分 token 集 |
| probability | 注释、独立 token 概率 → 枚举可能世界的精确事件概率(Double 数值计算) |
fn process_json(text : String) -> StringInstall
Download zipBounded polynomial provenance for positive relational queries, witnesses and exact possible-world evaluation