Bounded qualitative temporal interval constraint reasoning
moon add yujieMamba/moonallen@0.1.0import {
"yujieMamba/moonallen" @allen,
}fn validate() -> @allen.SolveReport raise @allen.AllenError {
let alg = @allen.Algebra::new()
let net = @allen.Network::new(["ingest", "publish"])
.restrict("ingest", "publish", @allen.parse_relset("b|m"))
@allen.solve(alg, net, @allen.SearchOptions::new())
}moon run examples/workflow # 相对阶段输入 -> 推理见证 -> 错误回边的可验证冲突核
moon run examples/annotation # 不确定事件标注 -> 精确可能关系 -> 蕴含反例
moon run examples/media # 具体区间观测 -> 策略检查/合并 -> JSON 和 DOT 报告| token | Relation | A 相对 B |
|---|---|---|
| b / bi | Before / After | 严格在前 / 在后 |
| m / mi | Meets / MetBy | 尾首相接 / 被相接 |
| o / oi | Overlaps / OverlappedBy | 从前方重叠 / 从后方重叠 |
| s / si | Starts / StartedBy | 同起点,A 更短 / 更长 |
| d / di | During / Contains | 严格包含于 / 严格包含 |
| f / fi | Finishes / FinishedBy | 同终点,A 更短 / 更长 |
| eq | Equal | 两端点都相等 |
| API | 行为 |
|---|---|
| Relation, RelSet, Algebra | 13 关系、位集运算、converse、精确 composition |
| Network::new/restrict/get | 不可变命名网络,源证据与当前域分离 |
| propagate, verify_trace | 有预算路径一致性传播、完整缩减轨迹重放 |
| solve, realize_atomic | MRV 原子场景搜索;端点等式合并和严格序 DAG 实现 |
| possible_relations, entails | 可行/不可行/未知三分区;非空前提的蕴含及反例 |
| explain_unsat, verify_core | 源证据上的删除式 UNSAT 核、独立再验证 |
| observe, check_observations, add_observations | 数值区间到定性观测、部分观测核对 |
| merge_networks, compare_domains | 按名称合并当前矩阵、域变化统计 |
| induced, rename, components | 诱导子矩阵、重命名、独立分量 |
| parse_dsl, parse_network_json | 有界数据交换;快照与原始证据分别导出 |
| render, to_dot, to_json | 稳定可读报告、图和机器可读诊断 |
interval a
interval b
rel a b b|m input-readymoon info && moon fmt
moon fmt --check
moon check --deny-warn
moon test --deny-warn
moon build --deny-warn
# 针对 wasm-gc、wasm、js、native 重复严格检查、构建、测试和三个示例
moon test --target js --deny-warnpub(all) suberror AllenError {
InvalidRelation(String)
InvalidMask(Int)
InvalidInterval(Int, Int)
InvalidName(String)
DuplicateName(String)
UnknownName(String)
InvalidIndex(Int)
InvalidLimit(String)
InvalidFormat(String)
TooLarge(Int)
}pub struct Algebra {
// private fields
}pub(all) struct ClosureReport {
status : ClosureStatus
network : Network
operations : Int
reductions : Array[Reduction]
reduction_count : Int
trace_complete : Bool
conflict : Conflict?
}pub(all) enum CoreOutcome {
ConflictCore(UnsatCore)
SourceSatisfiable(Witness)
CoreUnknown(SearchLimit)
}pub(all) enum Entailment {
Proven
Refuted(Witness)
InconsistentInput
EntailmentUnknown(SearchLimit)
}pub struct Network {
// private fields
}fn Network::from_constraints(names : Array[String], constraints : Array[Constraint]) -> Network raise AllenErrorfn Network::restrict(self : Network, left : String, right : String, allowed : RelSet, label? : String) -> Network raise AllenErrorpub(all) struct NetworkStats {
intervals : Int
pairs : Int
constrained_pairs : Int
atomic_pairs : Int
ambiguous_pairs : Int
empty_domains : Int
alternatives : Int
source_constraints : Int
}pub(all) struct PossibilityReport {
possible : RelSet
impossible : RelSet
unknown : RelSet
models : Array[RelationModel]
nodes : Int
operations : Int
}pub struct PropagationOptions {
// private fields
}fn PropagationOptions::new(max_operations? : Int, max_trace? : Int) -> PropagationOptions raise AllenErrorpub struct SearchOptions {
// private fields
}pub(all) struct SolveReport {
outcome : SolveOutcome
nodes : Int
operations : Int
maximum_depth : Int
}pub(all) struct UnsatCore {
constraints : Array[Constraint]
minimal : Bool
checks : Int
unresolved_checks : Int
}pub struct Witness {
// private fields
}fn check_observations(net : Network, names : Array[String], spans : Array[Interval]) -> Array[ObservationConflict] raise AllenErrorfn entails(alg : Algebra, net : Network, left : String, right : String, claim : RelSet, options : SearchOptions) -> Entailment raise AllenErrorfn explain_unsat(alg : Algebra, net : Network, options : SearchOptions, max_checks? : Int) -> CoreOutcome raise AllenErrorfn possible_relations(alg : Algebra, net : Network, left : String, right : String, options : SearchOptions) -> PossibilityReport raise AllenErrorfn verify_core(alg : Algebra, names : Array[String], core : UnsatCore, options : SearchOptions) -> SolveReport raise AllenErrorInstall
Download zipBounded qualitative temporal interval constraint reasoning