Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifications by boolean laws #1908

Open
Willames-Jr opened this issue Nov 12, 2023 · 1 comment
Open

Simplifications by boolean laws #1908

Willames-Jr opened this issue Nov 12, 2023 · 1 comment

Comments

@Willames-Jr
Copy link

boolean_law

Hi guys! I'm working on a new feature focused on students who want to understand the applications of the laws of Boolean algebra in the process of simplifying an expression. To achieve this, I'm utilizing the Visitor class. Ultimately, i generate a new String representing the simplified form of the original Expression, similar to the process in Expression.toString(), but in each step ,like in the visitBinary() and visitNot(), i check if it's possible to apply some law and if i can i remove or add elements in the final String.

Identifying the laws and creating the final String pose no challenges for me. I've already implemented the simplification for every law that can simplify an Expression. However, due to the Visitor's left-to-right approach, i can't easily find a way (or determine if there's one) to identify patterns requiring the associative law.

Let me illustrate with an example: "a.a.b" simplifies to "a.b" and in this case, my function works. However, if I input "a.b.a" instead of "a.a.b," my function doesn't "recognize" this as an expression that can be simplified. The main issue is that my String is created like the Expression.toString(). Even if i can identify the simplification in the previous example, it could be difficult to remake the String (what/where i need to remove/add), at least i don't see how to do that.

In summary, is there a better approach to this simplification process? Alternatively, is there a more effective way to create the new Expression rather than using a StringBuilder?

I know that maybe it's just a lack of acknowledgment in algorithms or Java. I would be very thankful if anyone could help me with that.

@davidhutchens
Copy link
Member

There are many Boolean Algebra simplification programs available online. The first listed when I searched was www.boolean-algebra.com which will take an expression and show steps to simplify it. I'm not sure what advantage adding this to LE would provide.

If I were to try to implement it, I would start by parsing the string into a parse tree and investigate how compilers simplify expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants