Write a module1 peano which implements the following functions:

Name and type Description
zero :: -> peano Constructor for the zero of the system, i.e., returns None
succ :: peano -> peano Constructor for the rest
zerop :: peano -> bool Check whether the given peano object is zero (in the peano sense).2
peanop:: obj -> bool Check whether the argument is peano.
to_int :: peano -> int Conversion
from_int :: int -> peano ditto
peano_add :: peano, peano -> peano Addition
peano_mult :: peano, peano -> peano Multiplication
peano_eq :: peano, peano -> bool Equality

Here are the rules of the game:

  1. All your functions must be recursively defined (no while, proc, whatever).
  2. No use of +, -, ==, <=, and so on, in your definitions. As long as it is not numerical comparison, == is allowed.
  1. If we are not already in the module business, “write a module” means create a peano.py file and define your functions there. Later on you can import your function names with from peano import peano_add, peano_mult, and so on. 

  2. We follow the LISP convention of naming predicates by attaching a p at the end of the corresponding property. The programmatic way to inquire about someone’s mood is to apply happyp to him/her. 

Updated: