bpodgursky / jbool_expressions Goto Github PK
View Code? Open in Web Editor NEWjbool_expressions is a simple open-source library for creating and manipulating propositional logic expressions in java
License: Other
jbool_expressions is a simple open-source library for creating and manipulating propositional logic expressions in java
License: Other
Hello! I had a question regarding the scenario where we parse an invalid boolean expression using ExprParser.parse
. The code seems to not throw any error and ignore the incorrect part of the expression.
My question - Is there a way to determine if a given expression is valid or not using jbool_expression library?
This test reproduces the issue:
public void testLongExpression() {
String exp = "(122036 | 122037 | 122039 | 122040 | 122042 | 122043 | 122045 | 122046 | 122048 | 122049 | " +
"122051 | 122052 | 122054 | 122055 | 122057 | 122058 | 122060 | 122061 | 122063 | 122064 | 122066 | " +
"122067 | 122069 | 122070 | 169225 | 169226 | 169228 | 169229 | 169231 | 169232 | 169234 | 169235 | " +
"169237 | 169238 | 169240 | 169241 | 169243 | 169244 | 169246 | 169247 | 169249 | 169250 | 169252 | " +
"169253 | 169255 | 169256 | 169258 | 169259 | 169261 | 169262 | 169264 | 169265 | 106925 | 106926 | " +
"165611)";
ExprParser.parse(exp);
}
I fixed this by caching the string representation in the Or, And and Not operations. If you're interested I can share the PR.
PD Great library, by the way! Thanks for sharing as open source!
Hi,
Thank you a lot for your work, I want to use it in my research job but after compiling with mvn I have a lot of exeption issues.
With this code:
Expression<String> expr = And.of( Variable.of("A"), Variable.of("B"), Or.of(Variable.of("C"), Not.of(Variable.of("C")))); System.out.println(expr);
I have this exeption:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Optional at com.bpodgursky.jbool_expressions.Not.<init>(Not.java:11) at com.bpodgursky.jbool_expressions.Not.of(Not.java:41) at src.Main.main(Main.java:148) Caused by: java.lang.ClassNotFoundException: com.google.common.base.Optional at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 3 more
With this little code:
Expression<String> nonStandard = ExprParser.parse("((A | B) & (C | D))"); System.out.println(nonStandard);
Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException at src.Main.main(Main.java:142) Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.RecognitionException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more
For moment I don't find any piece of code which works... Could you help me to fix this ?
Thanks a lot,
Joridan
Hi Ben,
I found an issue during parsing an expression with lower case characters.
ExprParser.parse("a & b")
I am getting the following error:
line 1:0 no viable alternative at character 'a'
line 1:2 no viable alternative at input '&'
line 1:6 no viable alternative at character 'b'
Is this a limitation?
Thanks for a very useful library.
Abhi
Hi,
First of all, awesome library, thank you very much for making it available!
I've found some issues while trying to parse the (probably too large) following expression with RuleSet.toDNF(Not.of(<large expression>))
, the library seems to run forever, although I haven't waited more than 1 or 2 minutes:
((b4 & b1 & !b3 & !c1 & c2 & c5) | (b4 & b1 & !b3 & !c1 & c2 & !c5) | (b4 & b1 & !b3 & !c1 & !c2 & c5) | (b4 & b1 & !b3 & !c1 & !c2 & !c5) | (b1 & b3 & !c1 & c2 & c5) | (b1 & b3 & !c1 & c2 & !c5) | (b1 & b3 & !c1 & !c2 & c5) | (b1 & b3 & !c1 & !c2 & !c5) | (!b4 & b1 & !b3 & !c1 & c2 & c5) | (!b4 & b1 & !b3 & !c1 & c2 & !c5) | (!b4 & b1 & !b3 & !c1 & !c2 & c5) | (!b4 & b1 & !b3 & !c1 & !c2 & !c5) | (b4 & !b1 & !c1 & b2 & c2 & c5) | (b4 & !b1 & !c1 & b2 & c2 & !c5) | (b4 & !b1 & !c1 & b2 & !c2 & c5) | (b4 & !b1 & !c1 & b2 & !c2 & !c5) | (!b1 & !c1 & !b2 & c2 & c5) | (!b1 & !c1 & !b2 & c2 & !c5) | (!b1 & !c1 & !b2 & !c2 & c5) | (!b1 & !c1 & !b2 & !c2 & !c5) | (!b4 & !b1 & !c1 & b2 & c2 & c5) | (!b4 & !b1 & !c1 & b2 & c2 & !c5) | (!b4 & !b1 & !c1 & b2 & !c2 & c5) | (!b4 & !b1 & !c1 & b2 & !c2 & !c5))
Suggestion from reddit comment;
"I think the expression building language could easily be extended to something more akin to a simple DSL for boolean expressions by introducing an interface such as:
BoolExpr {
BoolExpr and(BoolExpr rhs);
BoolExpr or(BoolExpr);
}
along with BoolExpr constructors from variables and other basic building blocks such as not().
This would facilitate slightly more intuitive expression builders such as :
(var("a").or(var("b"))).and(not(var("c")))
In fact if you provided a, b etc as builders for var("a") etc, then you could have:
(a.or(b)).and(not(c))
which equates to:
(a v b) ^ ~c
Implicit operator precedence won't work, so every expression has to be bracketed explicitly, but nonetheless it seems near optimal for Java.
(caveat: haven't actually tried it)"
I had been doing some experimentation with optimising SimplifyNExprChildren but realised that my tests were not behaving as expected. It turned out that the expression parser was not creating exactly the same tree as was being passed in.
I'd like to modify the expression parser to honour the general structure of expressions.
This means that in the expression parser tests the calls to simplify the parsed expression can be dropped.
Thanks for this cool library!
I found a little issue which does not behave like I would expect. When I build a product-of-sums from A & (!A | !C | !D | !E | !F)
I would expect the outcome to be (!C | !D | !E | !F) & A)
however the outcome is ((!C & A) | (!D & A) | (!E & A) | (!F & A))
which is equivalent to the first expression but to my knowledge not in the product-of-sums/CNF form.
Calculation of the therm in wolfram alpha.
The unit test would be:
assertToPos("((!C | !D | !E | !F) & A)","A & (!A | !C | !D | !E | !F)");
When trying to convert the following expression to CNF via RuleSet.toCnf(), the latter seems to run forever. Sure, it is a rather big expression, but I had hoped that your (very nice) lib could handle it.
(!S-950 | !S-P34 | (!S-001A & !S-002A & !S-003A & !S-004A & !S-005A & !S-006A & !S-007A & !S-008A & !S-009A & !S-011A & !S-012A & !S-015A & !S-017A & !S-018A & !S-019A & !S-021A & !S-022A & !S-026A & !S-027A & !S-028A & !S-031A & !S-032A & !S-036A & !S-037A & !S-038A & !S-039A & !S-041A & !S-042A & !S-045A & !S-048A & !S-051A & !S-052A & !S-055A & !S-057A & !S-058A & !S-061A & !S-062A & !S-065A & !S-068A & !S-069A & !S-071A & !S-072A & !S-073A & !S-077A & !S-078A & !S-081A & !S-082A & !S-085A & !S-088A & !S-091A & !S-092A & !S-095A & !S-098A & !S-101A & !S-102A & !S-104A & !S-105A & !S-108A & !S-111A & !S-112A & !S-114A & !S-115A & !S-118A & !S-121A & !S-124A & !S-125A & !S-128A & !S-131A & !S-132A & !S-135A & !S-138A & !S-141A & !S-142A & !S-144A & !S-145A & !S-148A & !S-151A & !S-152A & !S-154A & !S-155A & !S-157A & !S-158A & !S-161A & !S-164A & !S-165A & !S-168A & !S-171A & !S-175A & !S-178A & !S-189A & !S-191A & !S-192A & !S-196A & !S-197A & !S-198A & !S-199A & !S-201A & !S-202A & !S-204A & !S-205A & !S-206A & !S-207A & !S-208A & !S-211A & !S-212A & !S-214A & !S-215A & !S-217A & !S-218A & !S-219A & !S-221A & !S-222A & !S-224A & !S-225A & !S-227A & !S-228A & !S-231A & !S-232A & !S-234A & !S-235A & !S-237A & !S-238A & !S-239A & !S-241A & !S-242A & !S-244A & !S-245A & !S-246A & !S-247A & !S-248A & !S-251A & !S-252A & !S-254A & !S-255A & !S-257A & !S-258A & !S-261A & !S-262A & !S-263A & !S-264A & !S-265A & !S-267A & !S-268A & !S-269A & !S-271A & !S-272A & !S-274A & !S-275A & !S-277A & !S-278A & !S-281A & !S-282A & !S-284A & !S-285A & !S-287A & !S-288A & !S-291A & !S-292A & !S-294A & !S-295A & !S-296A & !S-297A & !S-298A & !S-299A & !S-301A & !S-305A & !S-308A & !S-311A & !S-314A & !S-315A & !S-318A & !S-321A & !S-325A & !S-328A & !S-331A & !S-332A & !S-335A & !S-338A & !S-341A & !S-348A & !S-351A & !S-358A & !S-361A & !S-363A & !S-368A & !S-371A & !S-378A & !S-381A & !S-382A & !S-386A & !S-387A & !S-388A & !S-391A & !S-392A & !S-395A & !S-398A & !S-401A & !S-402A & !S-404A & !S-405A & !S-406A & !S-407A & !S-408A & !S-409A & !S-411A & !S-412A & !S-414A & !S-415A & !S-418A & !S-421A & !S-425A & !S-428A & !S-431A & !S-432A & !S-435A & !S-438A & !S-441A & !S-442A & !S-445A & !S-447A & !S-448A & !S-451A & !S-452A & !S-455A & !S-457A & !S-458A & !S-461A & !S-471A & !S-472A & !S-475A & !S-476A & !S-477A & !S-478A & !S-481A & !S-482A & !S-485A & !S-487A & !S-488A & !S-491A & !S-492A & !S-495A & !S-498A & !S-501A & !S-502A & !S-504A & !S-515A & !S-517A & !S-519A & !S-521A & !S-524A & !S-527A & !S-528A & !S-531A & !S-532A & !S-534A & !S-535A & !S-536A & !S-537A & !S-538A & !S-541A & !S-542A & !S-548A & !S-551A & !S-552A & !S-554A & !S-555A & !S-557A & !S-558A & !S-561A & !S-564A & !S-565A & !S-567A & !S-568A & !S-571A & !S-572A & !S-574A & !S-575A & !S-577A & !S-578A & !S-581A & !S-582A & !S-584A & !S-585A & !S-586A & !S-587A & !S-588A & !S-591A & !S-594A & !S-595A & !S-598A & !S-601A & !S-604A & !S-605A & !S-608A & !S-611A & !S-614A & !S-615A & !S-618A & !S-621A & !S-625A & !S-628A & !S-631A & !S-637A & !S-638A & !S-641A & !S-648A & !S-651A & !S-654A & !S-661A & !S-665A & !S-671A & !S-678A & !S-681A & !S-691A & !S-698A & !S-701A & !S-702A & !S-704A & !S-705A & !S-707A & !S-708A & !S-711A & !S-718A & !S-721A & !S-725A & !S-726A & !S-727A & !S-728A & !S-731A & !S-732A & !S-735A & !S-738A & !S-741A & !S-742A & !S-746A & !S-747A & !S-748A & !S-751A & !S-752A & !S-755A & !S-756A & !S-761A & !S-767A & !S-771A & !S-778A & !S-781A & !S-782A & !S-786A & !S-787A & !S-798A & !S-801A & !S-802A & !S-804A & !S-805A & !S-807A & !S-808A & !S-811A & !S-812A & !S-814A & !S-815A & !S-817A & !S-818A & !S-821A & !S-822A & !S-824A & !S-825A & !S-827A & !S-828A & !S-831A & !S-832A & !S-834A & !S-835A & !S-838A & !S-841A & !S-842A & !S-843A & !S-844A & !S-845A & !S-848A & !S-851A & !S-852A & !S-854A & !S-855A & !S-857A & !S-858A & !S-861A & !S-864A & !S-865A & !S-867A & !S-868A & !S-871A & !S-872A & !S-873A & !S-874A & !S-875A & !S-877A & !S-878A & !S-881A & !S-884A & !S-885A & !S-887A & !S-888A & !S-895A & !S-897A & !S-901A & !S-904A & !S-905A & !S-908A & !S-911A & !S-914A & !S-915A & !S-918A & !S-921A & !S-951A & !S-954A & !S-955A & !S-958A & !S-961A & !S-962A & !S-965A & !S-968A & !S-971A & !S-974A & !S-975A & !S-977A & !S-978A & !S-984A & !S-985A & !S-987A & !S-991A & !S-992A & !S-994A & !S-995A & !S-996A & !S-997A & !S-998A & !S-999A & !S-X07A & !S-X09A) | (S-501A & S-X06) | (S-501A & S-X10) | (S-501A & S-X12) | (S-501A & S-X17) | (S-501A & S-X30) | (S-501A & S-X35) | (S-501A & S-X39) | (S-501A & S-X46) | (S-521A & S-956) | S-505A | S-507A | S-508A | S-511A | S-514A | S-518A | S-525A | S-545A | S-964A | S-967A)
I will run the conversion over night to see if it finishes at all but maybe you can already replicate it and see what the problem is.
Thanks a lot for the lib and looking into this issue.
Hi,
With version 1.23 of the library and Expressions like these where there isn't any Variable inside of the Logical Expression:
And doing this call:
RuleSet.toDNFViaQMC(expression, ExprOptions.noCaching())
This Exception is thrown:
Exception in thread "main" java.lang.ClassCastException: com.bpodgursky.jbool_expressions.And cannot be cast to com.bpodgursky.jbool_expressions.LiteralException in thread "main" java.lang.ClassCastException: com.bpodgursky.jbool_expressions.And cannot be cast to com.bpodgursky.jbool_expressions.Literal at com.bpodgursky.jbool_expressions.rules.QuineMcCluskey.findMinterms(QuineMcCluskey.java:412) at com.bpodgursky.jbool_expressions.rules.QuineMcCluskey.findMinterms(QuineMcCluskey.java:399) at com.bpodgursky.jbool_expressions.rules.QuineMcCluskey.toDNF(QuineMcCluskey.java:75) at com.bpodgursky.jbool_expressions.rules.RuleSet.toDNFViaQMC(RuleSet.java:52)
Thanks for having developed this library
First of all: thanks for this work.
It allows me to save a lot of time in the development of a proof of concept program.
I didn't find Java library that allows one to simple represent and manipulate a propositional logic expression like yours.
Two simple comments:
Assuming no unknown bugs, can I make three assumptions about the following code?
e=RuleSet.simplify(e);
Because of literal removal, either e is a literal or e does not contain any literals.
Because of negation simplification and De Morgans law, all instances of Not will only contain Variables, and no other extensions of Expression (like And/Or/Not).
Because of And / Or de-duplication and flattening. All children of an And will be either Or, Not or Variable, likewise all children of an Or will be either And, Not or Variable. Although there can be more nested downwards.
In the class ExprParser appear the error on every BooleanExprParser stating that cannot find symbol (either for class BooleanExprParser or variable BooleanExprParser)
closed
Here is sample code that shows rearrangement of the boolean children arguments (because there is internal children.sort() done on 'And' and 'Or'):
String expression = "((test1 | test0) & (test3 | test4) & test8)";
Expression<String> expr = ExprParser.parse(expression);
System.out.println(expression);
System.out.println();
System.out.println(expr.toString());
System.out.println();
System.out.println(expr.toLexicographicString());
The output is as follow:
((test1 | test0) & (test3 | test4) & test8)
((test0 | test1) & (test3 | test4) & test8)
((test0 | test1) & (test3 | test4) & test8)
e.g. test0 and test1 are swapped in the first OR boolean operator - the same is with AND operator:
Input:
String expression = "(test1 & test0)";
Output:
(test1 & test0)
(test0 & test1)
(test0 & test1)
The problem with this is as following:
in the case with (test1 & test0) :
if test1 is false then we could skip the evaluation of test0 as there is no point of trying to see the value of it - but because the parser will return (test0 & test1) we need to evaluate test0 first and then test1 - e.g. the side effect of the programming language effect is lost.
if you have this:
if (myBean != null && myBean.getName().equals("test")) {
}
is not the same as:
if (myBean.getName().equals("test") && myBean != null) {
}
Good day!
A colleauge of mine just merged something to master here. We would like to have a maven artifact built for this latest merge. Is it possible to get a release cut? Or do you have a specific release cadence? Thanks
I'm trying to make something similar to the Not expression class. However as sort is protected
I can't implement sort in the same way. As Not
is in the same package as Expression
it works for the inbuilt class.
I think Expression#sort should probably be public.
Hi,
Following expression :
String target ="((A34 | A35 | A36 | A37 | A38 | A39) & (A30 | A31) & (A32 | A33) & ((A27 & (A20 & A21 & A22)) | (A28 & (A23 & A24 & (A22 | A25))) | (A29 & (A23 & A26 & (A22 | A25)))) & (A40 | A41 | A42 | A43 | A44) & (((A20 & A21 & A22) | (A22 & A23 & A24) | (A23 & A24 & A25) | (A23 & A26 & (A22 | A25))) & A17 & (A18 | A19)) & (A1 & A2 & (((A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12) & A13 & A14) | (A15 & A16))))"
makes RuleSet.toDNF never returning a result.
Expression<String> nonStandard = null;
try {
nonStandard = RuleSet.simplify(ExprParser.parse(target));
} catch (Exception e) {
throw new BadDNFException("Error in following "+target);
}
System.out.println("Result Simplified = "+nonStandard.toString());
System.out.flush();
Expression<String> dnfForm = RuleSet.toDNF(nonStandard);
Thanks
Hello,
I am trying to minimize/simplify somes boolean expressions.
I tried to lunch your project on my computer. I work with Eclipse but I had so many problems. I don't know why. For example, Eclipse doesen't understand what is Expression.
Do you know why ?
And also, to simplify your expressions, did you use boolean algebra simplification or Quine McCluskey method ?
thanks you
The parser does work with latin letters only. Is there a way to support cyrlic letters ?
The documentation shows that you can include the library from maven central:
<dependency> <groupId>com.bpodgursky</groupId> <artifactId>jbool_expressions</artifactId> <version>1.10</version> </dependency>
However on maven central version 1.10 is not yet published.
Thanks a lot for your work!
Hey Ben,
I just faced some issues when parsing a Expression from a String.
All Expressions are of the form "Expression", but I usually put in numbers, formatted as Strings.
So there are two errors when parsing the Expressions from a String:
You can't parse sole variables, like: 0
When trying to parse this Expression: (0 & 1)
I get the errors:
W/System.err﹕ line 1:1 no viable alternative at character '0'
W/System.err﹕ line 1:3 no viable alternative at input '&'
W/System.err﹕ line 1:5 no viable alternative at character '1'
W/System.err﹕ line 1:6 no viable alternative at input ')'
I checked all the inputs and the Strings are formatted correctly.
So I think the parser just can't handle the numbers properly?
What would you suggest to use instead?
Thanks in advance and keep up the great work!
Johannes
mvn package fails in the first round, a 2nd run builds successfully.
[INFO] --- antlr3-maven-plugin:3.3:antlr (run antlr) @ jbool_expressions ---
[INFO] ANTLR: Processing source directory /Users/ukuhnhardt/Downloads/jbool_expressions/src/main/antlr3
ANTLR Parser Generator Version 3.3 Nov 30, 2010 12:46:29
com/bpodgursky/jbool_expressions/parsers/BooleanExpr.g
error(10): internal error: Can't get property indirectDelegates using method get/isIndirectDelegates from org.antlr.tool.Grammar instance : java.lang.NullPointerException
java.util.Objects.requireNonNull(Objects.java:203)
java.util.ArrayList.removeAll(ArrayList.java:689)
org.antlr.tool.CompositeGrammar.getIndirectDelegates(CompositeGrammar.java:222)
I have the following expression,
A&!(B|!C)
when simplified I am expecting the result to be
A&!B&C
But the output of this library is,
(!(!C|B)&A)
Any help is appreciated! Thank you!
Hi,
When calling RuleSet.toCNF with the following expression:
((105177 | 12030) & ((105098 | 105097 | 105096 | 105095 | 12003 | 12002 | 12001 | 12000) & ((12096 | 106083 | 106045) & 82095)))
the process hangs.
Here's my thread dump:
java.lang.Thread.State: RUNNABLE
at com.bpodgursky.jbool_expressions.NExpression.<init>(NExpression.java:19)
at com.bpodgursky.jbool_expressions.And.<init>(And.java:15)
at com.bpodgursky.jbool_expressions.And.createInternal(And.java:20)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:29)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:42)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.NExpression.apply(NExpression.java:27)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAllSingle(RuleSet.java:53)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applyAll(RuleSet.java:46)
at com.bpodgursky.jbool_expressions.rules.RuleSet.applySet(RuleSet.java:102)
at com.bpodgursky.jbool_expressions.rules.RuleSet.toSop(RuleSet.java:79)
at com.bpodgursky.jbool_expressions.rules.RuleSet.toPos(RuleSet.java:86)
at com.bpodgursky.jbool_expressions.rules.RuleSet.toCNF(RuleSet.java:75)
Thanks
Hi,
I have been a user of jbool_expressions for a while and have found it very good.
I was wondering if you would consider a pull request to implement hashCode and equals using standard java patterns rather than using string manipulation?
The reason for this is that I noticed during profiling that all this string manipulation shows up as a hot method.
The changes are pretty simple:
The downside of this is that this is a breaking change. Users with custom Expressions will have to implement hashCode and equals on all their subclasses of Expression.
The upside is that string manipulation is eliminated and implementing hashCode and equals can be optimised on a class by class basis.
I forked your project and cloned it to my computer. Then I added all the dependencies into builpath.
And in /src/main/java/com/bpodgursky/jbool_expressions/parsers/ExprParser.java eclipse is complaining about how BooleanExprLexer and BooleanExprParser can't be resolved to a type.
this happens on lines 32, 35, 36, 47, 52, 61, 66, 74, 76, 78, 80, 82 and 85.
Any idea how I can fix it?
The equivalent exists for And already
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.