Sign in

    moonconcept

    Bounded formal concept analysis, concept lattices and attribute implication discovery in pure MoonBit

    fca
    formal-concept-analysis
    lattice
    implications
    data-mining
    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    18 hours ago
    Downloads
    18

    #MoonConcept

    纯 MoonBit 实现的有限二元**形式概念分析(Formal Concept Analysis,FCA)**内核:从对象—属性关系计算 Galois 闭包、闭合模式、概念格和精确属性依赖。

    原创实现,采用 MIT 许可证。当前版本:0.1.1。

    #项目解决什么问题

    同一套对象—属性模型可以复用于三个完整工作流:

    • 特征分析人员:导入 CSV 观测数据,计算闭合模式与支持度,寻找最小生成元及精确蕴含。结果描述输入数据中的关系,不代表统计显著性。
    • 权限模型维护者:输入具名用户与权限,生成共享权限概念和 Hasse 图,找出违反所提议权限依赖的具体用户。这里只做关系分析,不执行授权或强制实施安全策略。
    • 产品配置目录维护者:按名称对齐不同顺序的数据源,合并配置目录,审计规则并查看推理过程。

    没有外部第三方模块依赖。JSON 解析使用 moonbitlang/core(Apache-2.0);调用者提供字符串,并自行负责文件、网络等 I/O。

    #安装与快速使用

    moon new consumer cd consumer moon add Zh666-lab/moonconcept@0.1.1

    在消费者包的 moon.pkg 中添加导入:

    import {
    "Zh666-lab/moonconcept" @fca,
    }

    下面的示例将三个设备表示为对象,将触控、便携和键盘表示为属性:

    fn main {
    let labels = try {
    let data = @fca.context_from_sets(
    ["phone", "tablet", "desktop"],
    ["touch", "portable", "keyboard"],
    [[0, 1], [0, 1], [2]],
    )
    data.attribute_labels(data.closure([0]))
    } catch {
    _ => abort("invalid incidence data")
    }
    // 在这份数据中,touch 的闭包包含 touch 和 portable。
    println(labels)
    }

    对象名称在对象集合内唯一,属性名称在属性集合内唯一。索引从 0 开始;集合会防御性排序、去重,内部数据由内核持有并复制。

    非法输入抛出 FcaError::Invalid;超过明确的资源预算抛出 FcaError::Budget,而不是返回不完整答案。完整公开接口见 pkg.generated.mbti。

    #已实现的接口

    功能主要入口
    具备数据所有权的上下文context、context_from_sets、objects、attributes、rows、has
    Galois 导出与闭包intent、extent、closure、object_closure,名称与索引查找
    概念枚举concept_for、valid_concept、next_intent、concepts、frequent_concepts
    概念格lattice、covers、leq、meet、join、上下界、区间、to_dot
    Horn 蕴含推理implication、rule_system、closure、trace、entails、equivalent
    精确依赖发现canonical_basis、minimal_generators、generator_rules
    规则分析counterexamples、valid_implication、rule_metrics、filter_rules
    规则理论变换irredundant、reduce_premises、split_conclusions、with_rule
    上下文变换dual、project、不可变观测更新、clarify、横向合并 apposition / 纵向合并 subposition
    专家审阅exploration、next_question;通过一致性校验的不可变接受 / 反例拒绝操作
    数据交换严格二元 CXT、关联矩阵 CSV、带版本的类型化 JSON
    分析报告概念 / 格 JSON、带反例的规则审计、推理 JSON,以及仅使用数字标签的 DOT

    形式概念满足 extent' = intent 与 intent' = extent,其中 extent 为外延(对象集合),intent 为内涵(属性集合),撇号表示相应的 Galois 导出。

    格的顺序采用外延包含关系:cover 边及 DOT 箭头从较小外延(底)指向较大外延(顶);内涵的包含方向与之相反。

    #三个可运行的下游工作流

    moon run examples/features moon run examples/roles moon run examples/catalog

    • features:特征数据 → 闭合模式与支持度 → 最小生成元和规范蕴含基。
    • roles:用户—权限关系 → 角色概念格 → 所提议权限依赖的违反者;同时输出数字索引的 DOT Hasse 图。
    • catalog:不同来源的配置目录 → 按名称对齐合并 → JSON/CXT 往返、规则审计、推理报告与专家问题。

    示例输出真实的结构化分析结果,每个示例均有预期结果断言。替换示例中的内存或 CSV 输入,即可将库集成到自己的应用中。内核不需要服务器、凭据或文件系统访问。

    #数据格式

    #CXT

    布局依次为:B、空行、对象数量、属性数量、空行、对象名称、属性名称、由 X / . 组成的关联矩阵行。

    支持 LF / CRLF,不接受额外记录。CXT 不能表示多行名称;写出器会拒绝这类名称,而不是静默丢失数据。

    #CSV

    首个表头必须恰为 object,其余表头是属性名称;关联单元格必须恰为 0 或 1。

    支持引号字段,内部双引号以双写方式转义;包含逗号、引号和换行的 Unicode 名称可以往返。引号外支持 LF / CRLF。不自动去除空白、不将其他“真值”转换为 1,也不接受缺失单元格或不等长记录。

    CSV 导出保留名称,不会做电子表格公式注入清洗。将不可信名称交给 Excel 等电子表格软件前,调用方应采用适合目标软件的安全处理;详见 安全边界。

    #JSON

    • 上下文模式 moonconcept-context/v1:包含 objects、attributes 和布尔矩阵 rows。
    • 规则理论模式 moonconcept-rules/v1:包含整数 dimension,以及使用索引的 rules;每条规则有 premise / conclusion。

    缺少字段、未知字段及类型不符均报错。核心 JSON 解析器对重复对象键采用后出现的值覆盖先出现的值;该格式不适合直接用作签名或安全策略的规范化表示。

    报告采用类型化、带索引的 JSON,上下文名称表只存一次;它们不是任意报告模式的通用解码器。不保证 JSON 成员的字节排列顺序。

    #资源边界与不支持的范围

    操作明确限制
    上下文最多 4096 对象、128 属性;名称唯一、非空,最多 4096 个 UTF-16 单元
    文本解析最多 32 Mi 个 UTF-16 单元;CSV 字段最多 4096;JSON 嵌套深度最多 16
    概念枚举默认最多 4096 个概念;调用方上限最多 65536;失败时不返回部分结果
    实体化概念格最多 256 个概念;cover 关系约简采用立方级算法
    规则理论最多 4096 条蕴含、128 属性;规则约简最多 512 条规则
    规范蕴含基最多 16 属性、65536 个子集候选;默认 100 万工作单元,最多 1000 万
    最小生成元目标最多含 16 属性;最多 65536 个候选,默认最多 4096 个结果
    专家提问最多 16 属性;执行完整但有界的子集扫描

    闭包和 NextClosure 使用直接的数组算法,不是面向大规模数据的位集优化挖掘器。规范基的工作单元计算候选检查与伪意向比较次数,并不等于 CPU 指令数或内存消耗;即使输入满足限制,也可能需要较多计算。

    频繁模式先完整枚举,再按支持度过滤;支持度阈值不代表搜索剪枝保证。dual 交换对象与属性后仍须满足上下文限制。clarify 只合并重复行列,不删除所有可约简行列。

    前提 / 规则约简保持理论等价,但不保证得到全局最小理论。Exploration 是有限穷举的专家审阅辅助器,不承诺采用规范属性探索的提问顺序,也不证明未观测真实对象的性质。

    空对象集合导出全部属性,空属性集合导出全部对象。空总体的支持度为 0,蕴含仍可能因无反例而成立。未定义的置信度 / 提升度返回 None 或 JSON null,不返回 NaN。

    不包含:通用 Datalog / HOL / SMT / CSP / BDD、权限强制执行、统计显著性、机器学习、分布式挖掘、无限 / 时间 / 模糊上下文、交互 GUI 或自动赛事报名。

    #验证与复现

    moon info && moon fmt moon fmt --check moon check --deny-warn moon test --deny-warn moon build --deny-warn python scripts/measure.py # Bash/Linux:分别验证 wasm-gc / wasm / js / native。 bash scripts/verify.sh js

    49 项命名测试包括独立的标量矩阵 / 子集判定器,遍历全部 689 个维度为 0..3 × 0..3 的二元上下文及 5054 个属性种子(包含全部 512 个 3×3 上下文),核对精确伪意向、最小生成元、格 cover 关系与最大下界 / 最小上界,以及解析失败、所有权隔离和预算边界。

    此外,每个解析器还接受 1000 个确定性生成的短畸形字符串测试。这是有限范围的穷举证据,不是对任意规模输入的形式证明。

    发布验证的 Windows 工具链为 moon 0.1.20261012 / moonc v0.10.15 稳定版。本地已运行 wasm-gc、wasm、js 的严格检查、测试、构建与工作流;native 本地仅做严格检查,构建与测试需要本机尚未安装的 C 编译器。

    CI 在 Ubuntu / GCC 上执行全部四个目标,并记录实际工具版本。CI 下载官方 2026 年 10 月 12 日快照,使用对象 ETag 前置条件:若上游对象改变,则拒绝继续。ETag 是对象身份约束,不是独立的密码学签名校验。每次发布是否通过验证,应以对应提交的实际 Actions 记录为准。

    #来源、许可证与赛事资料

    请参阅 架构说明、安全边界、参考资料、AI 辅助披露、更新记录,以及注明日期和范围的 语义查重报告。

    没有内置第三方实现或数据集,测试样例为原创合成数据。查重结论受记录中的检索范围、结果上限和不可访问来源限制,不代表绝对唯一性或赛事官方裁决。

    中文赛事申报书仅保存在本地,不随 GitHub、MoonCakes 或 Release 分发;本项目不自动报名。

    FcaError

    pub(all) suberror FcaError {
    Invalid(String)
    Budget(String)
    } derive(Eq,
    Debug
    )

    Errors distinguish invalid data from an explicitly exhausted resource budget.

    FcaError::equal

    fn FcaError::equal(FcaError, FcaError) -> Bool

    FcaError::not_equal

    fn FcaError::not_equal(x : FcaError, y : FcaError) -> Bool

    FcaError::to_repr

    Clarification

    pub struct Clarification {
    context : Context
    // private fields
    } derive(
    Debug
    )

    Clarification removes only duplicate incidence rows/columns, not reducible nonduplicates. Groups map each representative back to every original index, so multiplicities are explicit.

    Clarification::attribute_classes

    fn Clarification::attribute_classes(self : Clarification) -> Array[Array[Int]]

    Clarification::expand_extent

    fn Clarification::expand_extent(self : Clarification, extent : Array[Int]) -> Array[Int] raise FcaError

    Clarification::expand_intent

    fn Clarification::expand_intent(self : Clarification, intent : Array[Int]) -> Array[Int] raise FcaError

    Clarification::object_classes

    fn Clarification::object_classes(self : Clarification) -> Array[Array[Int]]

    ClosureTrace

    pub struct ClosureTrace {
    result : Array[Int]
    steps : Array[InferenceStep]
    } derive(Eq,
    Debug
    )

    ClosureTrace::equal

    ClosureTrace::not_equal

    fn ClosureTrace::not_equal(x : ClosureTrace, y : ClosureTrace) -> Bool

    Concept

    pub struct Concept {
    extent : Array[Int]
    intent : Array[Int]
    } derive(Eq,
    Debug
    )

    One formal concept: extent' = intent and intent' = extent.

    Concept::equal

    fn Concept::equal(Concept, Concept) -> Bool

    Concept::not_equal

    fn Concept::not_equal(x : Concept, y : Concept) -> Bool

    Concept::to_repr

    Context

    pub struct Context {
    // private fields
    } derive(Eq,
    Debug
    )

    Owned binary incidence context. All input arrays and exposed arrays are copied.

    Context::apposition

    fn Context::apposition(self : Context, other : Context) -> Context raise FcaError

    Apposition aligns objects by identity and concatenates disjoint attribute vocabularies.

    Context::attribute_count

    fn Context::attribute_count(self : Context) -> Int

    Context::attribute_index

    fn Context::attribute_index(self : Context, name : String) -> Int?

    Context::attribute_labels

    fn Context::attribute_labels(self : Context, indices : Array[Int]) -> Array[String] raise FcaError

    Context::attributes

    fn Context::attributes(self : Context) -> Array[String]

    Context::canonical_basis

    fn Context::canonical_basis(self : Context, candidate_limit? : Int, work_limit? : Int) -> RuleSystem raise FcaError

    Duquenne–Guigues base by the definition of pseudo-intents. Numeric subset order is inclusion-compatible: every strict subset is visited first. This is exact, deliberately bounded, and not a large-scale mining algorithm.

    Context::clarify

    fn Context::clarify(self : Context) -> Clarification raise FcaError

    Context::closure

    fn Context::closure(self : Context, attributes : Array[Int]) -> Array[Int] raise FcaError

    Galois attribute closure B''. Extensivity, monotonicity and idempotence hold.

    Context::concept_for

    fn Context::concept_for(self : Context, attributes : Array[Int]) -> Concept raise FcaError

    Context::concept_report

    fn Context::concept_report(self : Context, limit? : Int) -> Json raise FcaError

    Indexed output keeps vocabularies once rather than repeating potentially large labels.

    Context::concepts

    fn Context::concepts(self : Context, limit? : Int) -> Array[Concept] raise FcaError

    Enumerate in lectic order; budget failure never returns a silently truncated result.

    Context::counterexample_labels

    fn Context::counterexample_labels(self : Context, rule : Implication) -> Array[String] raise FcaError

    Violating objects retain their original identities; this is descriptive, not policy enforcement.

    Context::counterexamples

    fn Context::counterexamples(self : Context, rule : Implication) -> Array[Int] raise FcaError

    Return exactly the observed objects satisfying the premise but missing a conclusion attribute.

    Context::density

    fn Context::density(self : Context) -> Double

    Context::dual

    fn Context::dual(self : Context) -> Context raise FcaError

    Interchange object and attribute universes, preserving their order.

    Context::equal

    fn Context::equal(Context, Context) -> Bool

    Context::extent

    fn Context::extent(self : Context, attributes : Array[Int]) -> Array[Int] raise FcaError

    Objects having all selected attributes. Empty selection yields every object.

    Context::filter_rules

    fn Context::filter_rules(self : Context, rules : Array[Implication], min_support? : Double, min_confidence? : Double) -> Array[ScoredRule] raise FcaError

    Score an explicit candidate inventory. Undefined confidence never passes a threshold.

    Context::frequent_concepts

    fn Context::frequent_concepts(self : Context, min_support : Double, limit? : Int) -> Array[Concept] raise FcaError

    Closed patterns meeting support; budget applies before filtering, not just to survivors.

    Context::generator_rules

    fn Context::generator_rules(self : Context, intent : Array[Int], candidate_limit? : Int) -> Array[Implication] raise FcaError

    Exact closure rules from minimal generators; this is not the canonical base.

    Context::has

    fn Context::has(self : Context, object : Int, attribute : Int) -> Bool raise FcaError

    Context::implication_for

    fn Context::implication_for(self : Context, premise : Array[Int]) -> Implication raise FcaError

    Context::intent

    fn Context::intent(self : Context, objects : Array[Int]) -> Array[Int] raise FcaError

    Attributes shared by all selected objects. Empty selection yields every attribute.

    Context::is_closed

    fn Context::is_closed(self : Context, attributes : Array[Int]) -> Bool raise FcaError

    Context::lattice

    fn Context::lattice(self : Context, limit? : Int) -> Lattice raise FcaError

    Materialize a bounded Hasse diagram; cubic cover reduction is limited to 256 concepts.

    Context::lattice_report

    fn Context::lattice_report(self : Context, limit? : Int) -> Json raise FcaError

    Context::minimal_generators

    fn Context::minimal_generators(self : Context, intent : Array[Int], candidate_limit? : Int, result_limit? : Int) -> Array[Array[Int]] raise FcaError

    All inclusion-minimal generators of a closed intent, not only minimum-size generators. Inclusion-compatible enumeration prunes supersets of previously found generators.

    Context::next_intent

    fn Context::next_intent(self : Context, current : Array[Int]) -> Array[Int]? raise FcaError

    NextClosure in the input attribute order. The supplied intent must already be closed.

    Context::not_equal

    fn Context::not_equal(x : Context, y : Context) -> Bool

    Context::object_closure

    fn Context::object_closure(self : Context, objects : Array[Int]) -> Array[Int] raise FcaError

    Context::object_count

    fn Context::object_count(self : Context) -> Int

    Context::object_index

    fn Context::object_index(self : Context, name : String) -> Int?

    Context::object_labels

    fn Context::object_labels(self : Context, indices : Array[Int]) -> Array[String] raise FcaError

    Context::objects

    fn Context::objects(self : Context) -> Array[String]

    Context::project

    fn Context::project(self : Context, objects : Array[Int], attributes : Array[Int]) -> Context raise FcaError

    Induced subcontext in original index order; duplicates in either selection are ignored.

    Context::rows

    fn Context::rows(self : Context) -> Array[Array[Bool]]

    Context::rule_metrics

    fn Context::rule_metrics(self : Context, rule : Implication) -> RuleMetrics raise FcaError

    Evaluate A -> B after removing A from B; no statistical significance is inferred.

    Context::subposition

    fn Context::subposition(self : Context, other : Context) -> Context raise FcaError

    Subposition aligns attributes by identity and concatenates disjoint object populations.

    Context::support

    fn Context::support(self : Context, attributes : Array[Int]) -> Double raise FcaError

    Relative support is defined as zero for an empty object universe.

    Context::to_csv

    fn Context::to_csv(self : Context) -> String

    Dataset export, not spreadsheet-safe sanitization: labels are preserved, including formulas.

    Context::to_cxt

    fn Context::to_cxt(self : Context) -> String raise FcaError

    Reject multiline labels because CXT has no quoting mechanism; use CSV/JSON instead.

    Context::to_json

    fn Context::to_json(self : Context) -> Json

    Context::to_json_string

    fn Context::to_json_string(self : Context) -> String

    Context::to_repr

    Context::valid_concept

    fn Context::valid_concept(self : Context, concept : Concept) -> Bool raise FcaError

    Context::valid_implication

    fn Context::valid_implication(self : Context, rule : Implication) -> Bool raise FcaError

    An implication with no observed premise examples is vacuously valid.

    Context::with_object

    fn Context::with_object(self : Context, name : String, attributes : Array[Int]) -> Context raise FcaError

    Add a named counterexample/observation without mutating the original context.

    Context::without_object

    fn Context::without_object(self : Context, object : Int) -> Context raise FcaError

    Cover

    pub struct Cover {
    lower : Int
    upper : Int
    } derive(Eq,
    Debug
    )

    Edge direction is lower extent -> upper extent (subset order).

    Cover::equal

    fn Cover::equal(Cover, Cover) -> Bool

    Cover::not_equal

    fn Cover::not_equal(x : Cover, y : Cover) -> Bool

    Cover::to_repr

    Exploration

    pub struct Exploration {
    // private fields
    } derive(
    Debug
    )

    Immutable, bounded expert-review assistant; not a claim of canonical exploration order. Observations and accepted theory are kept consistent at every transition.

    Exploration::accept

    fn Exploration::accept(self : Exploration, question : Implication) -> Exploration raise FcaError

    Expert acceptance is meaningful only for a non-entailed implication valid in observations.

    Exploration::context

    fn Exploration::context(self : Exploration) -> Context

    Exploration::next_question

    fn Exploration::next_question(self : Exploration, candidate_limit? : Int) -> Implication? raise FcaError

    None proves equality of theory closure and observed closure for this finite vocabulary. Budget exhaustion raises rather than incorrectly signaling completion.

    Exploration::reject

    fn Exploration::reject(self : Exploration, question : Implication, object_name : String, attributes : Array[Int]) -> Exploration raise FcaError

    Reject using a genuinely violating new complete object that respects all accepted rules. No transition is made on inconsistent/duplicate evidence.

    Exploration::theory

    fn Exploration::theory(self : Exploration) -> RuleSystem

    Implication

    pub struct Implication {
    premise : Array[Int]
    conclusion : Array[Int]
    } derive(Eq,
    Debug
    )

    Positive Horn implication. Conclusion is canonicalized to exclude the premise.

    Implication::equal

    fn Implication::equal(Implication, Implication) -> Bool

    Implication::not_equal

    fn Implication::not_equal(x : Implication, y : Implication) -> Bool

    InferenceStep

    pub struct InferenceStep {
    rule_index : Int
    added : Array[Int]
    } derive(Eq,
    Debug
    )

    InferenceStep::equal

    InferenceStep::not_equal

    fn InferenceStep::not_equal(x : InferenceStep, y : InferenceStep) -> Bool

    Lattice

    pub struct Lattice {
    // private fields
    } derive(
    Debug
    )

    Lattice::bottom

    fn Lattice::bottom(self : Lattice) -> Int

    Lattice::concept

    fn Lattice::concept(self : Lattice, node : Int) -> Concept raise FcaError

    Lattice::covers

    fn Lattice::covers(self : Lattice) -> Array[Cover]

    Lattice::find_extent

    fn Lattice::find_extent(self : Lattice, extent : Array[Int]) -> Int?

    Lattice::find_intent

    fn Lattice::find_intent(self : Lattice, intent : Array[Int]) -> Int?

    Lattice::interval

    fn Lattice::interval(self : Lattice, lower : Int, upper : Int) -> Array[Int] raise FcaError

    Lattice::join

    fn Lattice::join(self : Lattice, left : Int, right : Int) -> Int raise FcaError

    Least upper bound: intersection of closed intents (reverse inclusion).

    Lattice::join_all

    fn Lattice::join_all(self : Lattice, nodes : Array[Int]) -> Int raise FcaError

    Empty join is the bottom element.

    Lattice::leq

    fn Lattice::leq(self : Lattice, lower : Int, upper : Int) -> Bool raise FcaError

    Lattice::lower_covers

    fn Lattice::lower_covers(self : Lattice, node : Int) -> Array[Int] raise FcaError

    Lattice::meet

    fn Lattice::meet(self : Lattice, left : Int, right : Int) -> Int raise FcaError

    Greatest lower bound: intersection of closed extents.

    Lattice::meet_all

    fn Lattice::meet_all(self : Lattice, nodes : Array[Int]) -> Int raise FcaError

    Empty meet is the top element.

    Lattice::size

    fn Lattice::size(self : Lattice) -> Int

    Lattice::to_dot

    fn Lattice::to_dot(self : Lattice) -> String

    Safe numeric DOT labels, directed bottom -> top in extent inclusion order. Human label vocabulary remains in the companion lattice_report, never interpolated into DOT.

    Lattice::to_repr

    Lattice::top

    fn Lattice::top(self : Lattice) -> Int

    Lattice::upper_covers

    fn Lattice::upper_covers(self : Lattice, node : Int) -> Array[Int] raise FcaError

    RuleMetrics

    pub struct RuleMetrics {
    object_count : Int
    premise_count : Int
    conclusion_count : Int
    joint_count : Int
    counterexample_count : Int
    support : Double
    confidence : Double?
    lift : Double?
    leverage : Double
    } derive(Eq,
    Debug
    )

    Confidence/lift are undefined (None), not NaN, when their denominators vanish.

    RuleMetrics::equal

    fn RuleMetrics::equal(RuleMetrics, RuleMetrics) -> Bool

    RuleMetrics::not_equal

    fn RuleMetrics::not_equal(x : RuleMetrics, y : RuleMetrics) -> Bool

    RuleSystem

    pub struct RuleSystem {
    // private fields
    } derive(
    Debug
    )

    RuleSystem::attribute_count

    fn RuleSystem::attribute_count(self : RuleSystem) -> Int

    RuleSystem::audit

    fn RuleSystem::audit(self : RuleSystem, observed : Context) -> Json raise FcaError

    Every supplied rule is audited, including vacuously valid rules with undefined confidence.

    RuleSystem::closure

    fn RuleSystem::closure(self : RuleSystem, seed : Array[Int]) -> Array[Int] raise FcaError

    RuleSystem::entails

    fn RuleSystem::entails(self : RuleSystem, rule : Implication) -> Bool raise FcaError

    RuleSystem::equivalent

    fn RuleSystem::equivalent(self : RuleSystem, other : RuleSystem) -> Bool raise FcaError

    RuleSystem::implications

    fn RuleSystem::implications(self : RuleSystem) -> Array[Implication]

    RuleSystem::inference_report

    fn RuleSystem::inference_report(self : RuleSystem, seed : Array[Int]) -> Json raise FcaError

    Explanations identify source rule indices and only newly inferred attributes.

    RuleSystem::irredundant

    fn RuleSystem::irredundant(self : RuleSystem) -> RuleSystem raise FcaError

    Remove tautologies and rules entailed by the remaining current theory. Equivalent and irredundant, not a minimum-cardinality or canonical presentation.

    RuleSystem::is_model

    fn RuleSystem::is_model(self : RuleSystem, attributes : Array[Int]) -> Bool raise FcaError

    RuleSystem::reduce_premises

    fn RuleSystem::reduce_premises(self : RuleSystem) -> RuleSystem raise FcaError

    Delete premise attributes only when the current theory already entails the stronger rule.

    RuleSystem::split_conclusions

    fn RuleSystem::split_conclusions(self : RuleSystem) -> RuleSystem raise FcaError

    Equivalent singleton-conclusion Horn theory; large expansions fail atomically.

    RuleSystem::to_json

    fn RuleSystem::to_json(self : RuleSystem) -> Json

    RuleSystem::to_json_string

    fn RuleSystem::to_json_string(self : RuleSystem) -> String

    RuleSystem::trace

    fn RuleSystem::trace(self : RuleSystem, seed : Array[Int]) -> ClosureTrace raise FcaError

    Deterministic Armstrong forward chaining. Each recorded step adds at least one attribute.

    RuleSystem::with_rule

    fn RuleSystem::with_rule(self : RuleSystem, rule : Implication) -> RuleSystem raise FcaError

    Extend the theory with a new implication, retaining the original system unchanged.

    ScoredRule

    pub struct ScoredRule {
    rule : Implication
    metrics : RuleMetrics
    } derive(Eq,
    Debug
    )

    ScoredRule::equal

    fn ScoredRule::equal(ScoredRule, ScoredRule) -> Bool

    ScoredRule::not_equal

    fn ScoredRule::not_equal(x : ScoredRule, y : ScoredRule) -> Bool

    checked_indices

    fn checked_indices(values : Array[Int], dimension : Int) -> Array[Int] raise FcaError

    Validate a subset of a dimension; duplicate indices are canonicalized.

    context

    fn context(objects : Array[String], attributes : Array[String], rows : Array[Array[Bool]]) -> Context raise FcaError

    Up to 4096 objects and 128 attributes; empty dimensions have standard FCA semantics.

    context_from_sets

    fn context_from_sets(objects : Array[String], attributes : Array[String], positives : Array[Array[Int]]) -> Context raise FcaError

    Construct a context from per-object positive attribute indices; absent attributes are false.

    exploration

    fn exploration(observed : Context, accepted : RuleSystem) -> Exploration raise FcaError

    implication

    fn implication(premise : Array[Int], conclusion : Array[Int], dimension : Int) -> Implication raise FcaError

    index_set

    fn index_set(values : Array[Int]) -> Array[Int]

    Canonical sorted finite integer set. The input is never modified.

    model_respects

    fn model_respects(model : Array[Int], rule : Implication, dimension : Int) -> Bool raise FcaError

    parse_context_json

    fn parse_context_json(text : String) -> Context raise FcaError

    Strict typed schema after core JSON parsing. Duplicate object keys follow core's last-wins policy. This data interchange is not a signed/security-policy canonicalization format.

    parse_csv

    fn parse_csv(text : String) -> Context raise FcaError

    Incidence CSV profile: literal first header 'object', then unique attributes; cells 0/1. Quoted multiline labels are supported; no whitespace trimming or truthy coercion.

    parse_cxt

    fn parse_cxt(text : String) -> Context raise FcaError

    Strict Burmeister binary CXT: B, blank, counts, blank, labels, X/. incidence. LF and CRLF accepted; one optional terminal line ending, no trailing records.

    parse_rules_json

    fn parse_rules_json(text : String) -> RuleSystem raise FcaError

    rule_system

    fn rule_system(dimension : Int, rules : Array[Implication]) -> RuleSystem raise FcaError

    set_difference

    fn set_difference(left : Array[Int], right : Array[Int]) -> Array[Int]

    set_equal

    fn set_equal(left : Array[Int], right : Array[Int]) -> Bool

    set_intersection

    fn set_intersection(left : Array[Int], right : Array[Int]) -> Array[Int]

    set_subset

    fn set_subset(left : Array[Int], right : Array[Int]) -> Bool

    set_union

    fn set_union(left : Array[Int], right : Array[Int]) -> Array[Int]

    universe

    fn universe(size : Int) -> Array[Int] raise FcaError