Skip to content

jamesshieh/ruby_logic_2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Logic

A symbolic logic parser written in ruby.


To run

bundle install
bin/ruby_logic

The language

Ruby logic is capable of parsing the following symbols in a symbolic logic string:

Propositions: A-Z
AND: &
OR: |
XOR : x
IMPIES: >
IFF: +
PARENS: ()
NOT: !
COMMAS: , (to separate statemets)

An example of a full statement:

A, !B, (A&B)>C, DxE+(A|B), ((A&E)|(C&D))>F

A single propositional statement is declared as a fact:

A     # A = true
!A    # A = false

Simple symbolic logic solving

The logic solver will attempt to resolve as many propositions as possible with the given statements and facts:

Example:

Input:

A, B, (A&B)>C

Output:

Statement: A, B, (A&B)>C
Validity: true
Truth Table: {:A=>true, :B=>true, :C=>true}
Parsed Statements:
Type: declaration
A
Type: declaration
B
Type: statement
[implies [parens [and A B ] C ]

About

Reworked ruby logic with grammar based parsing structure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages