module Data.Nat; open import Data.String; open import Data.Int; inductive Nat { zero : Nat; suc : Nat → Nat; }; foreign c { void* natInd(int n, void* zeroCtor, juvix_function_t* sucCtor) { if (n <= 0) return zeroCtor; return ((void* (*) (juvix_function_t*, void*))sucCtor->fun)(sucCtor, natInd(n - 1, zeroCtor, sucCtor)); \} }; axiom natInd : Int → Nat → (Nat → Nat) → Nat; compile natInd { c ↦ "natInd"; }; natToInt : Nat → Int; natToInt zero ≔ Int_0; natToInt (suc n) ≔ Int_1 + (natToInt n); natToStr : Nat → String; natToStr n ≔ intToStr (natToInt n); intToNat : Int → Nat; intToNat x ≔ natInd x zero suc; end;