```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 ``` ```Zeroes = lambda: [0, Zeroes] Ones = lambda: [1, Ones] Push = lambda b, x: \ x if b == 0 and x == Zeroes or b == 1 and x == Ones \ else lambda: [b, x] Head = lambda x: x()[0] Tail = lambda x: x()[1] Inc = lambda x: \ Zeroes if x == Ones \ else Push(1, Zeroes) if x == Zeroes \ else Push(1, Tail(x)) if Head(x) == 0 \ else Push(0, Inc(Tail(x))) Dec = lambda x: \ Ones if x == Zeroes \ else Push(0, Ones) if x == Ones \ else Push(0, Tail(x)) if Head(x) == 1 \ else Push(1, Dec(Tail(x))) Plus = lambda x, y: \ x if y == Zeroes \ else Dec(x) if y == Ones \ else Push(Head(y), Plus(Tail(x), Tail(y))) if Head(x) == 0 \ else Push(1, Plus(Tail(x), Tail(y))) if Head(y) == 0 \ else Push(0, Inc(Plus(Tail(x), Tail(y)))) Minus = lambda x, y: \ x if y == Zeroes \ else Inc(x) if y == Ones \ else Push(Head(x), Minus(Tail(x), Tail(y))) if Head(y) == 0 \ else Push(0, Minus(Tail(x), Tail(y))) if Head(x) == 1 \ else Push(1, Dec(Minus(Tail(x), Tail(y)))) Negative = lambda x: Minus(Zeroes, x) Mult = lambda x, y: \ Zeroes if y == Zeroes \ else Negative(x) if y == Ones \ else Push(0, Mult(x, Tail(y))) if Head(y) == 0 \ else Plus(x, Push(0, Mult(x, Tail(y)))) LessEqual = lambda x, y: \ True if x == y or x == Ones and y == Zeroes \ else False if x == Zeroes and y == Ones \ else Less(Tail(x), Tail(y)) if Head(x) == 1 and Head(y) == 0 \ else LessEqual(Tail(x),Tail(y)) Less = lambda x, y: \ False if x == y or x == Zeroes and y == Ones \ else True if x == Ones and y == Zeroes \ else LessEqual(Tail(x), Tail(y)) if Head(x) == 0 and Head(y) == 1 \ else Less(Tail(x),Tail(y)) Equal = lambda x, y: \ x == Zeroes if y == Zeroes \ else x == Ones if y == Ones \ else Equal(Tail(x), Tail(y)) if Head(x) == Head(y) \ else False Zero = Zeroes One = Inc(Zero) Two = Inc(One) Three = Inc(Two) Four = Inc(Three) Five = Inc(Four) Six = Inc(Five) Seven = Inc(Six) Eight = Inc(Seven) Nine = Inc(Eight) Ten = Inc(Nine) #check that 3 * (-5) == (-7) * 7 + 6 * 6 - 2 print(Equal(Mult(Three, Negative(Five)), Minus(Plus(Mult(Negative(Seven), Seven), Mult(Six, Six)), Two))) #check that -10 < -(3 * 3) print(Less(Negative(Ten), Negative(Mult(Three, Three)))) ```
 ```1 2 ``` ```True True ```