From 5ef58df57a5e22f5e52f0212db0bc238b82141fd Mon Sep 17 00:00:00 2001 From: Christoph Zengler Date: Thu, 24 Nov 2022 16:33:50 +0100 Subject: [PATCH 1/6] Next development version 2.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc9068f5..24437cec 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 4.0.0 org.logicng logicng - 2.4.0 + 2.5.0-SNAPSHOT bundle LogicNG From 5b8485db86893cb4279b01f5aa69c8ebddd7cf46 Mon Sep 17 00:00:00 2001 From: Rouven Walter Date: Thu, 1 Dec 2022 00:18:51 +0100 Subject: [PATCH 2/6] extending parsers: allowing # in variable names --- CHANGELOG.md | 6 ++++++ pom.xml | 2 +- src/main/antlr/LogicNGPropositional.g4 | 2 +- src/main/antlr/LogicNGPseudoBoolean.g4 | 2 +- .../logicng/io/parsers/PropositionalParserTest.java | 11 +++++++++-- .../logicng/io/parsers/PseudoBooleanParserTest.java | 9 ++++++++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b014cb..664d63af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ LogicNG uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.4.1] - 2022-12-01 + +### Changed + +- Allowing symbol `#` in variable names for the `PropositionalParser` and the `PseudoBooleanParser`. + ## [2.4.0] - 2022-11-24 ### Added diff --git a/pom.xml b/pom.xml index 24437cec..660bd2bd 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 4.0.0 org.logicng logicng - 2.5.0-SNAPSHOT + 2.4.1-SNAPSHOT bundle LogicNG diff --git a/src/main/antlr/LogicNGPropositional.g4 b/src/main/antlr/LogicNGPropositional.g4 index 4b016890..967ddb2d 100644 --- a/src/main/antlr/LogicNGPropositional.g4 +++ b/src/main/antlr/LogicNGPropositional.g4 @@ -84,7 +84,7 @@ equiv returns [Formula f] @init{Formula[] operands = new Formula[2];} : a = impl {operands[0] =$a.f;} (EQUIV b = equiv {operands[1] = $b.f;})? {$f = operands[1] == null ? operands[0] : f.equivalence(operands[0], operands[1]);}; -VARIABLE : [A-Za-z0-9_@][A-Za-z0-9_]*; +VARIABLE : [A-Za-z0-9_@#][A-Za-z0-9_#]*; TRUE : '$true'; FALSE : '$false'; LBR : '('; diff --git a/src/main/antlr/LogicNGPseudoBoolean.g4 b/src/main/antlr/LogicNGPseudoBoolean.g4 index a9e7c5b6..f907fd8e 100644 --- a/src/main/antlr/LogicNGPseudoBoolean.g4 +++ b/src/main/antlr/LogicNGPseudoBoolean.g4 @@ -105,7 +105,7 @@ add returns [List literals, List coeffs] NUMBER : [\-]?[0-9]+; -LITERAL : [~]?[A-Za-z0-9_@][A-Za-z0-9_]*; +LITERAL : [~]?[A-Za-z0-9_@#][A-Za-z0-9_#]*; TRUE : '$true'; FALSE : '$false'; LBR : '('; diff --git a/src/test/java/org/logicng/io/parsers/PropositionalParserTest.java b/src/test/java/org/logicng/io/parsers/PropositionalParserTest.java index 5861444f..331f5f1b 100644 --- a/src/test/java/org/logicng/io/parsers/PropositionalParserTest.java +++ b/src/test/java/org/logicng/io/parsers/PropositionalParserTest.java @@ -40,7 +40,7 @@ /** * Unit Tests for the class {@link PropositionalParser}. - * @version 2.0.0 + * @version 2.4.1 * @since 1.0 */ public class PropositionalParserTest extends TestWithExampleFormulas { @@ -72,6 +72,13 @@ public void testParseLiterals() throws ParserException { assertThat(parser.parse("~a1")).isEqualTo(this.f.literal("a1", false)); assertThat(parser.parse("~aA_Bb_Cc_12_3")).isEqualTo(this.f.literal("aA_Bb_Cc_12_3", false)); assertThat(parser.parse("~@aA_Bb_Cc_12_3")).isEqualTo(this.f.literal("@aA_Bb_Cc_12_3", false)); + assertThat(parser.parse("#")).isEqualTo(this.f.literal("#", true)); + assertThat(parser.parse("~#")).isEqualTo(this.f.literal("#", false)); + assertThat(parser.parse("~A#B")).isEqualTo(this.f.literal("A#B", false)); + assertThat(parser.parse("A#B")).isEqualTo(this.f.literal("A#B", true)); + assertThat(parser.parse("~A#B")).isEqualTo(this.f.literal("A#B", false)); + assertThat(parser.parse("#A#B_")).isEqualTo(this.f.literal("#A#B_", true)); + assertThat(parser.parse("~#A#B_")).isEqualTo(this.f.literal("#A#B_", false)); } @Test @@ -250,7 +257,7 @@ public void testIllegalFormula8() { @Test public void testIllegalFormula9() { - final String string = "#"; + final String string = "@A@B"; final InputStream stream = new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8)); assertThatThrownBy(() -> new PropositionalParser(this.f).parse(stream)).isInstanceOf(ParserException.class); } diff --git a/src/test/java/org/logicng/io/parsers/PseudoBooleanParserTest.java b/src/test/java/org/logicng/io/parsers/PseudoBooleanParserTest.java index 57748952..c98547e8 100644 --- a/src/test/java/org/logicng/io/parsers/PseudoBooleanParserTest.java +++ b/src/test/java/org/logicng/io/parsers/PseudoBooleanParserTest.java @@ -40,7 +40,7 @@ /** * Unit Tests for the class {@link PseudoBooleanParser}. - * @version 2.0.0 + * @version 4.4.1 * @since 1.0 */ public class PseudoBooleanParserTest extends TestWithExampleFormulas { @@ -69,6 +69,13 @@ public void testParseLiterals() throws ParserException { assertThat(parser.parse("~A")).isEqualTo(this.f.literal("A", false)); assertThat(parser.parse("~a")).isEqualTo(this.f.literal("a", false)); assertThat(parser.parse("~aA_Bb_Cc_12_3")).isEqualTo(this.f.literal("aA_Bb_Cc_12_3", false)); + assertThat(parser.parse("#")).isEqualTo(this.f.literal("#", true)); + assertThat(parser.parse("~#")).isEqualTo(this.f.literal("#", false)); + assertThat(parser.parse("~A#B")).isEqualTo(this.f.literal("A#B", false)); + assertThat(parser.parse("A#B")).isEqualTo(this.f.literal("A#B", true)); + assertThat(parser.parse("~A#B")).isEqualTo(this.f.literal("A#B", false)); + assertThat(parser.parse("#A#B_")).isEqualTo(this.f.literal("#A#B_", true)); + assertThat(parser.parse("~#A#B_")).isEqualTo(this.f.literal("#A#B_", false)); } @Test From 1ad1b16c44d2d68fe1ac4f9b40b2f8f0636834c6 Mon Sep 17 00:00:00 2001 From: Christoph Zengler Date: Thu, 1 Dec 2022 08:25:59 +0100 Subject: [PATCH 3/6] Adjusted comments for parsers --- src/main/java/org/logicng/io/parsers/PropositionalParser.java | 2 +- src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/logicng/io/parsers/PropositionalParser.java b/src/main/java/org/logicng/io/parsers/PropositionalParser.java index d58bfb94..98840d3a 100644 --- a/src/main/java/org/logicng/io/parsers/PropositionalParser.java +++ b/src/main/java/org/logicng/io/parsers/PropositionalParser.java @@ -46,7 +46,7 @@ * * Brackets are {@code (} and {@code )}. For variable names, there are the following rules: *
    - *
  • must begin with a alphabetic character, {@code _} or {@code @}
  • + *
  • must begin with a alphabetic character, {@code _}, {@code @}, or {@code #}
  • *
  • can only contain alphanumerical character, or {@code _}
  • *
  • {@code @} is only allowed at the beginning of the variable name and is reserved for special internal variables
  • *
diff --git a/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java b/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java index a6e06e8d..d61a6486 100644 --- a/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java +++ b/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java @@ -53,7 +53,7 @@ * * Brackets are {@code (} and {@code )}. For variable names, there are the following rules: *
    - *
  • must begin with a alphabetic character, {@code _} or {@code @}
  • + *
  • must begin with a alphabetic character, {@code _}, {@code @}, or {@code #}
  • *
  • can only contain alphanumerical character, or {@code _}
  • *
  • {@code @} is only allowed at the beginning of the variable name and is reserved for special internal variables
  • *
From ca82a3a823a6e6d14af3c00ef357b6b9cb61235b Mon Sep 17 00:00:00 2001 From: Rouven Walter Date: Thu, 1 Dec 2022 08:49:27 +0100 Subject: [PATCH 4/6] adjusted comments and version tags for parsers --- src/main/java/org/logicng/io/parsers/PropositionalParser.java | 4 ++-- src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/logicng/io/parsers/PropositionalParser.java b/src/main/java/org/logicng/io/parsers/PropositionalParser.java index 98840d3a..146754d5 100644 --- a/src/main/java/org/logicng/io/parsers/PropositionalParser.java +++ b/src/main/java/org/logicng/io/parsers/PropositionalParser.java @@ -47,10 +47,10 @@ * Brackets are {@code (} and {@code )}. For variable names, there are the following rules: *
    *
  • must begin with a alphabetic character, {@code _}, {@code @}, or {@code #}
  • - *
  • can only contain alphanumerical character, or {@code _}
  • + *
  • can only contain alphanumerical character, {@code _}, or {@code #}
  • *
  • {@code @} is only allowed at the beginning of the variable name and is reserved for special internal variables
  • *
- * @version 1.2 + * @version 2.4.1 * @since 1.0 */ public final class PropositionalParser extends FormulaParser { diff --git a/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java b/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java index d61a6486..0725ca06 100644 --- a/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java +++ b/src/main/java/org/logicng/io/parsers/PseudoBooleanParser.java @@ -54,13 +54,13 @@ * Brackets are {@code (} and {@code )}. For variable names, there are the following rules: *
    *
  • must begin with a alphabetic character, {@code _}, {@code @}, or {@code #}
  • - *
  • can only contain alphanumerical character, or {@code _}
  • + *
  • can only contain alphanumerical character, {@code _}, or {@code #}
  • *
  • {@code @} is only allowed at the beginning of the variable name and is reserved for special internal variables
  • *
*

* A valid pseudo Boolean expression is of the form {@code c_1 * l_1 + ... + c_n * l_n R k} where the {@code c_i} are coefficients, * {@code l_i} are literals, and {@code R} is one of {@code =, >, >=, <, <=}. - * @version 1.2 + * @version 2.4.1 * @since 1.0 */ public final class PseudoBooleanParser extends FormulaParser { From ad3fc80c0a953e2feaf7ab87498daea6179ff4f8 Mon Sep 17 00:00:00 2001 From: Christoph Zengler Date: Thu, 1 Dec 2022 10:14:29 +0100 Subject: [PATCH 5/6] Set Jigsaw module name in manifest --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 660bd2bd..0be1b9a3 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ - + org.apache.maven.plugins maven-jar-plugin @@ -138,6 +138,7 @@ BooleWorks GmbH + logicng From 2b6d23c600ab16b756ce917590e3400713e7a8e3 Mon Sep 17 00:00:00 2001 From: Christoph Zengler Date: Thu, 1 Dec 2022 10:22:35 +0100 Subject: [PATCH 6/6] Final 2.4.1 release --- CHANGELOG.md | 1 + README.md | 4 ++-- pom.xml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 664d63af..1e9b85fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ LogicNG uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Changed - Allowing symbol `#` in variable names for the `PropositionalParser` and the `PseudoBooleanParser`. +- Set the Java Jigsaw automatic module name to `logicng` in the manifest. ## [2.4.0] - 2022-11-24 diff --git a/README.md b/README.md index 80344698..25518bed 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ An extensive white paper with a lot of interesting use cases of LogicNG for conf ## Philosophy -The most important philosophy of the library is to avoid unnecessary object creation. Therefore formulas can only be generated via formula factories. A formula +The most important philosophy of the library is to avoid unnecessary object creation. Therefore, formulas can only be generated via formula factories. A formula factory assures that a formula is only created once in memory. If another instance of the same formula is created by the user, the already existing one is returned by the factory. This leads to a small memory footprint and fast execution of algorithms. Formulas can cache the results of algorithms executed on them and since every formula is hold only once in memory it is assured that the same algorithm on the same formula is also executed only once. @@ -34,7 +34,7 @@ LogicNG is released in the Maven Central Repository. To include it just add org.logicng logicng - 2.4.0 + 2.4.1 ``` diff --git a/pom.xml b/pom.xml index 0be1b9a3..46a1fb80 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 4.0.0 org.logicng logicng - 2.4.1-SNAPSHOT + 2.4.1 bundle LogicNG