type Bit = int 1; type Byte = vector 0..7 of Bit; zeroB = <<0,0,0,0,0,0,0,0>>; oneB = <<0,0,0,0,0,0,0,1>>; clearB () = zeroB; add (0,0,0) = (0,0); add (0,0,1) = (0,1); add (0,1,0) = (0,1); add (0,1,1) = (1,0); add (1,0,0) = (0,1); add (1,0,1) = (1,0); add (1,1,0) = (1,0); add (1,1,1) = (1,1); addB <> <> = case add (v0,w0,0) of (c0,s0) -> case add (v1,w1,c0) of (c1,s1) -> case add (v2,w2,c1) of (c2,s2) -> case add (v3,w3,c2) of (c3,s3) -> case add (v4,w4,c3) of (c4,s4) -> case add (v5,w5,c4) of (c5,s5) -> case add (v6,w6,c5) of (c6,s6) -> case add (v7,w7,c6) of (c7,s7) -> (c7,<>); incB <> = case addB <> oneB of (_,i) -> i; subB b1 b2 = addB b1 (incB (compB b2)); decB <> = case subB <> oneB of (_,d) -> d; and (0,0) = 0; and (0,1) = 0; and (1,0) = 0; and (1,1) = 1; andB <> <> = <>; ior (0,0) = 0; ior (0,1) = 1; ior (1,0) = 1; ior (1,1) = 1; iorB <> <> = <>; xor (0,0) = 0; xor (0,1) = 1; xor (1,0) = 1; xor (1,1) = 0; xorB <> <> = <>; neg 0 = 1; neg 1 = 0; compB <> = <>; expression incB zeroB; expression decB zeroB; expression addB oneB (decB zeroB); expression compB zeroB; expression xorB oneB oneB; expression iorB oneB oneB; expression andB oneB oneB;