Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
aa:adt-formal [2018/12/12 11:04] dmihai [A tentative definition] |
aa:adt-formal [2018/12/12 11:30] (current) dmihai |
||
|---|---|---|---|
| Line 94: | Line 94: | ||
| While each of the above axioms describes sensible concatenation behaviour, the interesting questions are: | While each of the above axioms describes sensible concatenation behaviour, the interesting questions are: | ||
| - | * **the axioms are sufficient** in order to describe correct concatenation behaviour? | + | * **are the axioms sufficient** in order to describe correct concatenation behaviour? |
| * **are all axioms necessary**? | * **are all axioms necessary**? | ||
| Line 197: | Line 197: | ||
| The FIFO implementation has two issues which require attention: | The FIFO implementation has two issues which require attention: | ||
| - | * a pair of lists **is not a unique FIFO representation**. For instance, $math[Enqueue(1,Enqueue(2,Empty))] can be interpreted by: $math[\langle 1:2:Void, Void \rangle] as well as by $math[\langle 1:2:Void, Void \rangle]. Thus, FIFO equality in the implementation requires the operation: $math[\langle l, r \rangle \equiv \langle l', r' \rangle =^{(def)} l ++ reverse(r) = l' ++ reverse(r') ] | + | * a pair of lists **is not a unique FIFO representation**. For instance, $math[Enqueue(1,Enqueue(2,Empty))] can be interpreted by: $math[\langle 1:2:Void, Void \rangle] as well as by $math[\langle 1:Void, 2:Void \rangle]. Thus, FIFO equality in the implementation requires the operation: $math[\langle l, r \rangle \equiv \langle l', r' \rangle =^{(def)} l ++ reverse(r) = l' ++ reverse(r') ] |
| * A FIFO such as $math[\langle 1:2:Void, Void \rangle] is nonempty, however we cannot extract elements from the rightmost list, since it is empty. Hence, we require the operation: | * A FIFO such as $math[\langle 1:2:Void, Void \rangle] is nonempty, however we cannot extract elements from the rightmost list, since it is empty. Hence, we require the operation: | ||
| * (N) $math[normalize(\langle l, Void \rangle) = \langle Void, reverse(l) \rangle] | * (N) $math[normalize(\langle l, Void \rangle) = \langle Void, reverse(l) \rangle] | ||
| Line 223: | Line 223: | ||
| ADTs offer an interface between object implementation and object behaviour. The FIFO example illustrates the power of ADTs: | ADTs offer an interface between object implementation and object behaviour. The FIFO example illustrates the power of ADTs: | ||
| * A FIFO can be implemented as two lists, **irrespective of the list implementation choice** | * A FIFO can be implemented as two lists, **irrespective of the list implementation choice** | ||
| - | * Once axioms are shown to hold in the implementation, **it is guaranteed to satisfy all properties of the ADT**. | + | * Once axioms are shown to hold in the implementation, **they are guaranteed to satisfy all properties of the ADT**. |