The carry-skip adder computes the sum of its inputs full
This proof shows: correctness, termination.
Let n≥1, ai,bi,cin∈{0,1}, and block sizes k0,…,kt−1≥1 with sum n. Block j covers positions ℓj..uj, consecutive and in order. Write gi=ai∧bi and pi=ai⊕bi.
Termination. The loops of lines L4 and L6 run over finite lists of blocks and positions, and the AND trees of line L2 halve the number of signals at each level.
The reference values. Define the ripple carries c0∗=cin and ci+1∗=gi∨(pi∧ci∗). For each position, ai+bi+ci∗=(pi⊕ci∗)+2ci+1∗: if pi=1, then gi=0 and both sides are 1+ci∗; if pi=0, then ai=bi=gi and both sides are 2gi+ci∗. Multiplying by 2i and summing over i, the carries telescope:
a+b+cin=i=0∑n−1(pi⊕ci∗)2i+cn∗2n. So it suffices to show that the algorithm sets si=pi⊕ci∗ and returns cn∗.
Lemma 1 (a propagating block). If pi=1 for every i in block j, then cuj+1∗=cℓj∗.
Proof. For each such i, gi=ai∧bi=0 because ai=bi, so ci+1∗=0∨(1∧ci∗)=ci∗. Apply this kj times. □
Lemma 2 (the invariant). At the start of iteration j of the loop of line L4, c=cℓj∗. During the iteration, line L6 sets si=pi⊕ci∗ for each position i of block j, and at its end c=cuj+1∗.
Proof. By induction on j. For j=0, line L3 sets c=cin=c0∗. Assume c=cℓj∗ at the start of iteration j. Line L5 sets x=cℓj∗. Line L6 processes positions ℓj,…,uj in order; by induction on the position, when it reaches i the value c is ci∗, so it sets si=pi⊕ci∗ and then c=gi∨(pi∧ci∗)=ci+1∗. After the block, c=cuj+1∗. If j=0, line L7 does nothing. If j≥1, line L2 gives Pj=⋀i=ℓjujpi, and line L7 sets c←(Pj∧x)∨(¬Pj∧c):
- if Pj=0, the new value is c=cuj+1∗;
- if Pj=1, the new value is x=cℓj∗, which equals cuj+1∗ by Lemma 1.
So c=cuj+1∗=cℓj+1∗ at the end of the iteration. □
Theorem. CARRY-SKIP-ADD returns the bits of a+b+cin.
Proof. By Lemma 2, every si=pi⊕ci∗, and after the last block c=cut−1+1∗=cn∗. By the identity above, these n+1 bits represent a+b+cin. ■