let zero = []
let succ n = () :: n

let rec int_of_peano p =
  match p with
  | [] -> 0
  | _::p' -> 1 + int_of_peano p'

let rec peano_of_int n =
  if n < 0 then failwith "n doit etre positif ou nul.";
  if n = 0 then zero
  else succ (peano_of_int (n-1))

let int_of_peano p =
  let rec aux p n = 
    match p with
    | [] -> n
    | _::p' -> aux p' (n+1)
  in
  aux p 0

let peano_of_int n =
  if n < 0 then failwith "n doit etre positif ou nul.";
  let rec aux n p =
    if n = 0 then p
    else aux (n-1) (succ p)
  in
  aux n zero


(* 

   succ (peano_of_int max_int) est different de peano_of_int (max_int +1) car
   max_int + 1 = min_int

*)


let rec add p1 p2 =
  match p1 with
  | [] -> p2
  | ()::p1' -> add p1' (succ p2)

let rec mult p1 p2 =
  match p1 with 
  | [] -> []
  | ()::p1' -> add p2 (mult p1' p2)

let rec inf_eq p1 p2 =
  match p1, p2 with
  | [], _ -> true
  | _, [] -> false
  | ()::p1', ()::p2' -> inf_eq p1' p2'