Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## Expression Parsing

I was wondering how I should write this expression parsing function:
I'm trying to create a new operator (→) that outputs:
Code:
```P   Q    P->Q
T   T      T
T   F      F
F   T      T
F   F      T
As you may have guessed the logic is (P==Q)||Q```
Another operator I'm trying to create is (↔) that outputs

Code:
```P   Q    P->Q
T   T      T
T   F      F
F   T      F
F   F      T
As you may have guessed the logic is (P==Q)||Q```
The logic here is P==Q[/CODE]

Additionally, I need to parse logical quantifiers so that:
Code:
```∃x becomes names.some(function(x){...})
∀x becomes names.every(function(x){...})```
For example:
• ∃x Dodec(x) becomes names.some(function(x){return Dodec(x)})
• ∃x ∃y Smaller(x,y) becomes names.some(function(x){names.some(function(y){return Smaller(x,y)})})
• ∃x ∃y ∀z Between(x,y,z) becomes names.some(function(x){names.some(function(y)names.some(function(x){names.some(function(z){return Between(x,y,z)})})})
For a well formed logical statement, a person needs to properly parenthesize the statement.
Valid examples:
(Dodec(a)→Dodec(b))→Dodec(c)
∃x(Dodec(x) && ∃y Smaller(x,y))

Invalid Examples:
Dodec(a)→Dodec(b)→Dodec(c)
∃x Dodec(x) && ∃ySmaller(x,y) [Valid: ∃x Dodec(x) && ∃x∃ySmaller(x,y), the quantifier does not carry through]

• this looks a lot like homework, if not what's the use-case?
Have you done anything so far?

• ## It's a personal project

I'm trying to port a software we had to use for Symbolic Logic to Javascript since I couldn't use it on Linux. Now the semester is over so I have more time to get involved. Yeah it is kinda for school, but now I'm just trying to learn Javascript and I think I'll turn this into Flash soon. Since using Flash will make a lot of the 3D stuff easier I could use SVG, but that's not supported as much as Flash.

The software I'm trying to port is: http://www-csli.stanford.edu/LPL/

I'll put up what I have so far here: http://dasickis.com/jstarski

• Can someone help?

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•