Predicate logic to prove equality of two formulas

Click For Summary
SUMMARY

This discussion focuses on developing a program to prove the equivalence of mathematical formulas using predicate logic. The recommended approach involves utilizing context-free grammars for representation and implementing simplification and transformation algorithms to handle algebraic expressions. C++ is suggested for creating a binary tree structure to represent the formulas, while Maxima is highlighted as a useful tool for parsing and simplifying expressions. The conversation emphasizes the importance of understanding parsing techniques for effective implementation.

PREREQUISITES
  • Understanding of predicate logic
  • Familiarity with context-free grammars
  • Knowledge of C++ programming
  • Basic concepts of binary tree data structures
NEXT STEPS
  • Learn about context-free grammars and their applications in parsing
  • Explore C++ binary tree implementations for expression evaluation
  • Study the Maxima software for symbolic computation and parsing
  • Read "Parsing Techniques" by Dick Grune to deepen understanding of parsing theory
USEFUL FOR

Mathematicians, computer scientists, software developers, and anyone interested in symbolic computation and formula equivalence verification.

budihart
Messages
1
Reaction score
0
Hi All,

I'm trying to write a program that will prove that a certain mathematical formula that is entered by a student is the same as the goal formula that I want.

For example, if the goal formula is: 2 * X + Y

then any of this student's answer can be considered correct:
-> X + X + Y
-> X - 5 + X + Y + 5
-> X/Y * Y + Y + X
-> Y + X * 2
and so on.

I have a thought that I can solve this problem by converting this mathematical formula to a predicate logic. But I still cannot figure out, how can I actually do it.

Any help is really appreciated.

Many thanks
 
Physics news on Phys.org
budihart said:
Hi All,

I'm trying to write a program that will prove that a certain mathematical formula that is entered by a student is the same as the goal formula that I want.

For example, if the goal formula is: 2 * X + Y

then any of this student's answer can be considered correct:
-> X + X + Y
-> X - 5 + X + Y + 5
-> X/Y * Y + Y + X
-> Y + X * 2
and so on.

I have a thought that I can solve this problem by converting this mathematical formula to a predicate logic. But I still cannot figure out, how can I actually do it.

Any help is really appreciated.

Many thanks

Hey budihart and welcome to the forums.

The best way I recommend to doing this systematically is to user context-free grammars for representing these kinds of things.

What you do in order to show equivalence is to have procedures that simplify expressions as well as allow isomorphisms or 'equivalent transformations' between representations.

The simplification function part of your system will do things like implement all the algebraic functionality like expanding everything out into its full expanded parts while getting rid of redundancies (example X + X = 2X not X + X). You can do this with fairly simple algorithms for the algebra, and you can use a recursive procedure to collect common terms together.

The transformation part of the algorithm allows you to do more advanced things like recognize things that are equivalent but algebraicly hard or impossible to show. Something like say e^x and its taylor series expansion (1 + x + x^2/2 + ...) is one way, but you can make this as complex as you want by allowing integral and derivative expansions and all kinds of series expansions.

I know you probably won't do the second part, but if you want to extend it and make it powerful with a simple design, this is what I would recommend.

The language itself would best be represented with a binary tree. Each node would have some kind of operator and the tree itself would expand both left and right down to the leaves where each node has the information for that particular thing. It could be a number, a variable of different types, a linguistic expression, an integral or other evaluation, a series expansion, and so on.

If you use C++, you can create a class system that allows you to extend the node types and deal with specialized simplification and transformation.

The binary tree example is a good way to design for example, simple calculator programs that take expressions (including with parentheses) and expand them out to give a final answer.

If you need more clarification don't hesitate to ask.
 
budihart said:
Hi All,

I'm trying to write a program that will prove that a certain mathematical formula that is entered by a student is the same as the goal formula that I want.

For example, if the goal formula is: 2 * X + Y

then any of this student's answer can be considered correct:
-> X + X + Y
-> X - 5 + X + Y + 5
-> X/Y * Y + Y + X
-> Y + X * 2
and so on.

I have a thought that I can solve this problem by converting this mathematical formula to a predicate logic. But I still cannot figure out, how can I actually do it.

Any help is really appreciated.

Many thanks

Hi budihart,

Adding to chiro's answer, you can write your program in just a few lines of code using Maxima as the core engine.

Now, if you are actually interested in how to do that yourself chiro has already given you a few hints; In CS this kind of analysis is called parsing. If you want to learn more about the theory behind parsing you can download a free book about parsing techniques from this site http://dickgrune.com/Books/PTAPG_1st_Edition/

Also, since Maxima is a FOSS project you can hack their code in whatever way you want and see how their parsers work too.

So Good Luck!

Edit: Maybe this question should be moved to the Computing & Technology forum, people checking that forum might have something else to say.
 
Last edited:

Similar threads

  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K