Latest 0.2.0
Homepage https://github.com/JimRoepcke/Rules
License MIT
Platforms ios 9.0, tvos 10.0, watchos 2.0
Authors

Version
License
Platform

Rules provides a simple forward-chaining inference rule engine that is configurable at runtime.

When you provide a set of known facts, and a set of rules, inferred facts
can be determined.

For example:

  • known fact: the sky is blue
  • rule: if the sky is blue, then the weather is sunny
  • inferrable fact: the weather is sunny

You you make much more complicated rules than this, which are
based on more facts, even based on inferred facts.

For example:

  • known fact: the sky is blue
  • known fact: the season is summer
  • rule: if the sky is blue, then the weather is sunny
  • rule: if true, the beach is empty (this is a fallback rule)
  • rule: if the weather is sunny and the season is summer, then the beach is full
  • inferred fact: the beach is full

  • known fact: the season is autumn
  • inferred fact: the beach is empty

Rules can be specified using a simple textual format, and can be decoded from JSON
to load into a Brain.

This repo also contains a TextRulesToJSON command-line program for macOS that can convert a text file with human-readable rules to JSON. As the Rule type in Rules conforms to Swift’s Decodable protocol, this makes it easy to import rules into an application. TextRulesToJSON can also lint the rules to help ensure they are valid before they are converted to JSON.

Example

The Example project only exists for unit tests. To run them, clone the repo, and run pod install from the Example directory first.

Requirements

  • Xcode 10.0
  • Swift 4.2

Installation

Rules is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'Rules'

Rules is also available as a Swift Package. See the Rules/Package.swift file for more information.

Author

Jim Roepcke, [email protected]

License

Rules is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Rules",
    "version": "0.2.0",
    "summary": "A forward-chaining inference engine rule engine",
    "description": "Rules provides a simple forward-chaining inference rule engine that is configurable at runtime.nnWhen you provide a set of _known facts_, and a set of _rules_, _inferred facts_ ncan be determined.nnFor example:nn- _known fact_: the sky is bluen- _rule_: if the sky is blue, then the weather is sunnyn- _inferrable fact_: the weather is sunnynnYou you make much more complicated rules than this, which arenbased on more facts, even based on inferred facts.nnFor example:nn- _known fact_: the sky is bluen- _known fact_: the season is summern- _rule_: if the sky is blue, then the weather is sunnyn- _rule_: if true, the beach is empty (this is a fallback rule)n- _rule_: if the weather is sunny and the season is summer, then the beach is fulln- _inferred fact_: the beach is fullnn- _known fact_: the season is autumnn- _inferred fact_: the beach is emptynnRules can be specified using a simple textual format, and can be decoded from JSONnto load into a `Brain`.",
    "homepage": "https://github.com/JimRoepcke/Rules",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jim Roepcke": "[email protected]"
    },
    "source": {
        "git": "https://github.com/JimRoepcke/Rules.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "9.0",
        "tvos": "10.0",
        "watchos": "2.0"
    },
    "swift_version": "4.2",
    "source_files": "Rules/Sources/**/*"
}

Pin It on Pinterest

Share This