TAN
July 17th, 2001, 04:19 AM
I have to know how to determine whether an expression is a legal sentence.
Obtain an expression from the users; validate the expression by checking each constituent according to the sequence of Propositionai Rules. Display the constituents if the expression is a legal sentence. Otherwise, explain the reasons the expression is not a legal sentence.
A few examples are illustrated below: (in my program, : -| as'not', v 'or, 'and'; => as'=>'.)
Example 1
Expression : ((P ^ Q) => R) = -|(P ^ 0) v R
Answer: Yes. Legal Sentence.
Trace: P, Q, R are Propositional Symbols => Sentence
P /\ Q, is the AND (disjunction) of 2 sentences => Sentence
(P ^ Q) => R, is the Implication of 1 sentence for another sentence => Sentence
(P Q), is the Negation of 1 sentence => Sentence
(P Q) v R, is the OR (conjunction) of 2 sentences => Sentence ((P ^ Q) => R) = -| (P ^ Q) v R, is the Equivalence of 2 sentences => Sentence Legal Sentence.
Example 2
Expression : Upper ^ lower
Answer: Invalid expression
Reason : lower is invalid.Propositional symbol.
Example 3
Expression: -| \Q
Answer: Invalid expression
Reason Q is invalid Negation of a sentence => NOT Sentence
Example 4
Expression: /\ Q
Answer: Invalid expression
Reason Q is invalid AND (disjunction) of 1 sentence => NOT Sentence
Example 5
Expression: => R
Answer: Invalid expression
Reason R, is the invalid Implication for another sentence => NOT Sentence
Example 6
Expression : P ^ => Q
Answer: Invalid expression
Reason : P ^ => Q, is invalid AND (disjunction) of 1 sentence => NOT Sentence
Obtain an expression from the users; validate the expression by checking each constituent according to the sequence of Propositionai Rules. Display the constituents if the expression is a legal sentence. Otherwise, explain the reasons the expression is not a legal sentence.
A few examples are illustrated below: (in my program, : -| as'not', v 'or, 'and'; => as'=>'.)
Example 1
Expression : ((P ^ Q) => R) = -|(P ^ 0) v R
Answer: Yes. Legal Sentence.
Trace: P, Q, R are Propositional Symbols => Sentence
P /\ Q, is the AND (disjunction) of 2 sentences => Sentence
(P ^ Q) => R, is the Implication of 1 sentence for another sentence => Sentence
(P Q), is the Negation of 1 sentence => Sentence
(P Q) v R, is the OR (conjunction) of 2 sentences => Sentence ((P ^ Q) => R) = -| (P ^ Q) v R, is the Equivalence of 2 sentences => Sentence Legal Sentence.
Example 2
Expression : Upper ^ lower
Answer: Invalid expression
Reason : lower is invalid.Propositional symbol.
Example 3
Expression: -| \Q
Answer: Invalid expression
Reason Q is invalid Negation of a sentence => NOT Sentence
Example 4
Expression: /\ Q
Answer: Invalid expression
Reason Q is invalid AND (disjunction) of 1 sentence => NOT Sentence
Example 5
Expression: => R
Answer: Invalid expression
Reason R, is the invalid Implication for another sentence => NOT Sentence
Example 6
Expression : P ^ => Q
Answer: Invalid expression
Reason : P ^ => Q, is invalid AND (disjunction) of 1 sentence => NOT Sentence