The Foundation: Logic & Proof - 01

Nov 30, 2014

Problem Definition: we want to solve 3 or less variable logical Expression. For example: Let, Given Logical Expression: (a|b)&(c|b)
Output:
a
b
c
(a|b)&(c|b)
0
0
0
0
0
0
1
0
0
1
0
1
0
1
1
1
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
1

Description:
First, we have to find out the post-fix notation of the expression. For the above example, first we push “(“ and add ” )” to the end of logical expression.
Symbolic Scan
STACK
Expression
(
(
( (
a
( (
a
|
( ( |
a
b
( ( |
a b
)
(
a b |
&
(
a b |
(
(  (
a b |
c
( (
a b | c
|
( ( |
b
( ( |
a b | c b
)
(
a b | c b |
)
a b | c b | &
Evaluation of a Post-fix Notation:
Now we evaluate a post-fix notation:
Let, a = (00001111)2 = 15, b = (00110011)2= 51, c = (01010101)2= 85.
Symbolic Scan
STACK
Explain
a
a
b
a, b
|
63
a|b = (00111111)2=63
c
63, c
b
63, c, b
|
63,119
c|b =(01110111)2=119
&
55
63 & 119 = (00110111)2= 55
Sample Code in C++:
document Link : (pdf) & (doc)

No comments:

Post a Comment