Tautalogy evaluator help

What I'm trying to do is I have an expression that entered like

(P --> Q) <--> (P v ~Q) as a regular string. Then the string is parsed to see if the expression is a tautology. I have two case structures to process the operands and their priorities. And public void evaluate() does the parsing and uses a stack.

But right I'm completely lost as to figuring out the best way to do this. Can somebody give me any ideas, or point me in the right direction?

Here what I have so far for code:

import java.util.Stack;

publicclass TautologyExpress{

public String express;

public TautologyExpress(String string)

{

express="("+string+")";

}

publicvoid evaluate()

{

Stack stack =new Stack();

int a = express.length();

int i;

for(i = 0; i< a; i++)

{

if(express.charAt(i)=='P')

{

stack.push(express.charAt(i));

}

if(express.charAt(i)=='Q')

{

stack.push(express.charAt(i));

}

if(express.charAt(i)=='~')

{

if(!stack.isEmpty())

{

while(Priority((Character)stack.peek()) >= Priority(express.charAt(i)))

express += stack.pop();

}

}

}

}

publicboolean check(char ch)

{

switch(ch)

{

case'P':

returntrue;

case'Q':

returntrue;

}

returnfalse;

}

publicboolean Operator(char ch)

{

switch(ch)

{

case'|':// represents <>

case'>':

case'^':

case'v':

case'~':

case'(':

case')':

case'#':

returntrue;

default:

returnfalse;

}

}

publicint Priority(char ch)

{

switch(ch)

{

case')':

case'#':

return 0;

case'|':

return 1;

case'>':

return 2;

case'v':

return 3;

case'^':

return 4;

case'~':

return 5;

case'(':

return 6;

}

return -1;

}

publicstaticvoid main(String []args)

{

TautologyExpress obj=new TautologyExpress("(P > Q) | (~ P v Q)");

obj.evaluate();

}

}

[6007 byte] By [Hurcuta] at [2007-11-27 4:49:10]
# 1
You have two steps in there:1. Parse the string into... some data structure.2. Decide whether that data structure represents a tautology by... doing something.Your idea of parsing the string to see if it's a tautology is wrong. Parse first, analyze second.
DrClapa at 2007-7-12 10:02:13 > top of Java-index,Java Essentials,New To Java...
# 2

I know what a tautology is, but what does this mean(example or not):

(P --> Q) <--> (P v ~Q)

?

By what method do you decide - or do you hope to make the program decide - whether a statememt is a tautology?

Never mind the first part - I see it's really '(P > Q) | (~ P v Q)'

abillconsla at 2007-7-12 10:02:13 > top of Java-index,Java Essentials,New To Java...
# 3
Will this help you any? ... [url http://www.cs.sfu.ca/~cl/software/COBA/Javadoc/revisionlogic/SentenceParser.html][/url]
abillconsla at 2007-7-12 10:02:13 > top of Java-index,Java Essentials,New To Java...