Proof: Reverse List Example 5
Let's prove the following theorem:
reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = [ 4, [ 3, [ 2, [ 1, [ ] ] ] ] ]
Proof:
# | Claim | Reason |
---|---|---|
1 | reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] | reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] |
2 | reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] | reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] |
3 | reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] | reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] |
4 | reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] | reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] |
5 | reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] = [ 4, [ 3, [ 2, [ 1, [ ] ] ] ] ] | reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] = [ 4, [ 3, [ 2, [ 1, [ ] ] ] ] ] |
6 | reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] | if reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] and reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ], then reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] |
7 | reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] | if reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] and reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ], then reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] |
8 | reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] | if reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] and reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ], then reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] |
9 | reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = [ 4, [ 3, [ 2, [ 1, [ ] ] ] ] ] | if reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] and reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ] = [ 4, [ 3, [ 2, [ 1, [ ] ] ] ] ], then reverse of [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] = [ 4, [ 3, [ 2, [ 1, [ ] ] ] ] ] |
Comments
Please log in to add comments