Skip to content

Propositional calculus expert system in Ruby - 42 school project

Notifications You must be signed in to change notification settings

hivian/expert_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

expert_system

Backward-chaining inference engine in Ruby - 42 school project

ruby expert_system.rb [path/to/file]
or
ruby expert_system.rb => run [path/to/file]

File example:

B => A               # if B(true) then A(true)
D + E => B           # if D and E then A
!G + H => !F         # if G(false) and H(true) then F(false)
I + J => G
G <=> H              # biconditional rule: if G then H but also if H then G
L | M => K           # if A or M ...
L ^ M => K           # if A xor M ...
O + P => L | N       # ambiguous: L or N are undetermined
N => M
(F | G) + H => E     # parentheses handling

=DEIJOP              # By default, all facts are false, and can only be made true by this initial facts statement.

?AFKP                # list of queries

"help" for a list of available commands:

====================================== COMMANDS =======================================
#                                                                                     #
#    run   [file path]               : load a file and run it. Reset all facts        #
#                                                                                     #
#    fact  [letter] = [true/false]   : set the fact statement (not saved !)           #
#    save                            : save the new facts and reevaluate the rules    #
#    query [letters]                 : print the fact(s) corresponding                #
#                                                                                     #
#    rules                           : print all rules                                #
#    facts                           : print all saved facts                          #
#    facts:statement                 : print all facts statements                     #
#    reset                           : reset all facts and rules                      #
#    quit                            : exit the program                               #
#                                                                                     #
=======================================================================================

About

Propositional calculus expert system in Ruby - 42 school project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages