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