Skip to content

AngelLogics, a simple CNF boolean expression generator, builder, and parser, supporting to serialize and deserialize boolean formulas from text expressions.

Notifications You must be signed in to change notification settings

NeonAngelThreads/AngelLogics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AngelLogics

AngelLogics is an advanced general logic expression builder and generator, supporting to serialize boolean expressions by using the logic notations.

Why AngelLogics

  • Easy to use, AngelLogics aggregated miscellaneous built-in functions logic metrics that aimed to software testing, such as widely used CNF expressions, and Linked expressions.

Features:

Implemented APIs:

Flatten Model:

Getting Started:

  1. Build a simple expression via several atomic variables. An example was shown below:
from src.angel_logics.core import AtomicVariable
from src.angel_logics.core.expressions import CNFExpressionBuilder, ExpressionSerializer

# -- To create several variables a, b, c and d
# -- where negation is meaning the inverter.
a = AtomicVariable("a", negation=False)
b = AtomicVariable("b", negation=False)
c = AtomicVariable("c", negation=False)
d = AtomicVariable("d", negation=False)  # negation = False means neg

expr = CNFExpressionBuilder.of("a AND -(b AND -c)") # build an expression
print(ExpressionSerializer.deserialize(expr)) # deserialization test.

Output:

>>> (a AND -(b AND -c))
  1. Evaluate above expression. The code shown above solely defines a boolean function. our goal is to evaluate the function with some inputs.
    Here is an example:
# we simply call expr.evaluate() function.
_input = [a, b, c] # to define an input of the function.
bo = expr.evaluate(_input) # [a, b, c] means that a=1, b=1 and c=1

print(bo)

Output:

>>> False
  1. CNF Expression Builder (Beta): Another expression metrics is CNF.
be = CNFExpressionBuilder() # AngelLogic API
be.append("1 4 -2 -5 2") # each digit is recognized as a variable. where "-" meaning the inverters.
be.append("0 1 -2 7")

print(be.build())

Output:

>>> ((1 OR 4 OR -2 OR -5 OR 2) AND (0 OR 1 OR -2 OR 7))

Community

Encountered a bug? issues and suggestions are welcome.
My Bilibili space: https://m.bilibili.com/space/386644641

Made with ❤️ by NeonAngelThreads

About

AngelLogics, a simple CNF boolean expression generator, builder, and parser, supporting to serialize and deserialize boolean formulas from text expressions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages