Proof: Pop At Example
Let's prove the following theorem:
stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = [ 10, [ 14, [ ] ] ]
Proof:
# | Claim | Reason |
---|---|---|
1 | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = reverse of (stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ]) | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = reverse of (stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ]) |
2 | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ] = stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ] = stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] |
3 | 1 - 1 = 0 | 1 - 1 = 0 |
4 | stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] = stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] | if 1 - 1 = 0, then stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] = stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] |
5 | stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] = result of dumping [ 14, [ ] ] to [ 10, [ ] ] | stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] = result of dumping [ 14, [ ] ] to [ 10, [ ] ] |
6 | result of dumping [ 14, [ ] ] to [ 10, [ ] ] = [ 14, [ 10, [ ] ] ] | result of dumping [ 14, [ ] ] to [ 10, [ ] ] = [ 14, [ 10, [ ] ] ] |
7 | stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] = [ 14, [ 10, [ ] ] ] | if stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] = result of dumping [ 14, [ ] ] to [ 10, [ ] ] and result of dumping [ 14, [ ] ] to [ 10, [ ] ] = [ 14, [ 10, [ ] ] ], then stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] = [ 14, [ 10, [ ] ] ] |
8 | stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] = [ 14, [ 10, [ ] ] ] | if stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] = stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] and stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index 0 in traversed elements: [ 10, [ ] ] = [ 14, [ 10, [ ] ] ], then stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] = [ 14, [ 10, [ ] ] ] |
9 | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ] = [ 14, [ 10, [ ] ] ] | if stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ] = stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] and stack after popping a value from stack [ 12, [ 14, [ ] ] ] at index (1 - 1) in traversed elements: [ 10, [ ] ] = [ 14, [ 10, [ ] ] ], then stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ] = [ 14, [ 10, [ ] ] ] |
10 | reverse of (stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ]) = reverse of [ 14, [ 10, [ ] ] ] | if stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ] = [ 14, [ 10, [ ] ] ], then reverse of (stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ]) = reverse of [ 14, [ 10, [ ] ] ] |
11 | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = reverse of [ 14, [ 10, [ ] ] ] | if stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = reverse of (stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ]) and reverse of (stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 in traversed elements: [ ]) = reverse of [ 14, [ 10, [ ] ] ], then stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = reverse of [ 14, [ 10, [ ] ] ] |
12 | reverse of [ 14, [ 10, [ ] ] ] = [ 10, [ 14, [ ] ] ] | reverse of [ 14, [ 10, [ ] ] ] = [ 10, [ 14, [ ] ] ] |
13 | stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = [ 10, [ 14, [ ] ] ] | if stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = reverse of [ 14, [ 10, [ ] ] ] and reverse of [ 14, [ 10, [ ] ] ] = [ 10, [ 14, [ ] ] ], then stack after popping a value from stack [ 10, [ 12, [ 14, [ ] ] ] ] at index 1 = [ 10, [ 14, [ ] ] ] |
Comments
Please log in to add comments