GithubHelp home page GithubHelp logo

dolovnyak / expert-system Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 4.38 MB

Expert system for logical expressions on backward-chaining inference engine.

License: The Unlicense

CMake 6.03% C++ 89.22% Yacc 4.02% Lex 0.73%
google-test yacc-lex backward-chaining logical-expression expert-system

expert-system's Introduction

Expert-System

MacOS - Build

Expert system that solves logical expressions (finds the values of all facts depending on the given true facts) using backward-chaining inference engine.

There are logical expressions, for example:

A => B      (A implies B)
C | D => A  (C or D implies A) 

All facts (fact is uppercase letter) are false by default, you can set true facts.

This program calculates, depending on the entered true facts - all facts values.

A=>B
# A - false, B - false
# A=>B - false=>false
# B - false
A=>B
=A
# A - true, B - false
# A=>B - true=>true (if implying fact is true, then fact which it implies must become true)
# B - true

Available logical operations:

  • () which means high priority. Example: A + (B | C) => D
  • ! which means NOT. Example: !B
  • + which means AND. Example: A + B
  • | which means OR. Example: A | B
  • ˆ which means XOR. Example: A ˆ B
  • => which means "implies". Example: A + B => C (expression always true)
  • <=> which means "if and only if". Example: A + B <=> C (expression always true)

Input file example:

# this is a comment
C => E          # C implies E
A + B + C => D  # A and B and C implies D
A | B => C      # A or B implies C
A + !B => F     # A and not B implies F
C | !G => H     # C or not G implies H
V ^ W => X      # V xor W implies X
A + B => Y + Z  # A and B implies Y and Z
C | D => X | V  # C or D implies X or V
E + F => !V     # E and F implies not V
A + B <=> C     # A and B if and only if C
A + B <=> !C    # A and B if and only if not C
=ABG            # Initial facts : A, B and G are true. All others are false.
?GVX            # Queries : What are G, V and X ? (it doesn't matter in visual mode)

Build and run on MacOS:

git submodule update --init --recursive
cmake -S . -B build -DINSTALL_DEPS=true
make -C build

./expert_system -v example.txt (visual mode with the ability to change expressions in real time)
or 
./expert_system example.txt (console answer)
or
./expert_system_tests

Graphical examples:

Simple logic example:

K=true, C=false -> K|C=true -> A=true -> B=true

K=false, C=false -> K|C=false -> A=false -> B=false

K=false, C=false -> K|C=false -> !(K|C)=true -> A=true -> B=true

K=true, C=false -> K|C=true -> !(K|C)=false -> A=false -> B=false

expert-system's People

Contributors

dolovnyak avatar insearcher avatar

Watchers

 avatar  avatar  avatar

expert-system's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.