It is possible to build a number system native to Modal.
The language does not accommodate for any specific numerical system, but allows for the notion of numbers to be implemented with Peano Numerals:
<> (add (s ?x) (s ?y)) (s (add ?x (s ?y))) <> (add (s ?x) (0)) (s ?x) <> (add (0) (s ?y)) (s ?y) <> (add (0) (0)) (0) <> (sub (s ?x) (s ?y)) (sub ?x ?y) <> (sub (s ?x) (0)) (s ?x) <> (sub (0) (s ?y)) (s ?y) <> (sub (0) (0)) (0) <> (mul (s ?x) (s ?y)) (add (s ?x) (mul (s ?x) (sub (s ?y) (s (0))))) <> (mul (s ?x) (s (0))) (s ?x) <> (mul (s (0)) (s ?y)) (s ?y) <> (mul (s ?x) (0)) (0) <> (mul (0) (s ?x)) (0)
To convert from prefix notation to infix:
<> (?x + ?y) (add ?x ?y) <> (?x - ?y) (sub ?x ?y) <> (?x * ?y) (mul ?x ?y)
Altogether, we have enough parts to implement factorial:
<> (factorial (s (0))) ((s (0))) <> (factorial (s ?x)) (((s ?x) * factorial ((s ?x) - (s (0))))) factorial (s (s (s (s (s (0))))))
Binary
Prefix rules to increment a binary number:
<> (inc (0 ?x)) ((1 ?x)) <> (inc (1 ?x)) ((0 inc ?x)) <> (inc ()) ((1 ())) ?(?-) (Count to 0x7f) <> (> increc (1 (1 (1 (1 ()))))) (done.) <> (> increc ?i) (> (inc ?i wait) increc) <> (> (?i wait) increc) (> increc ?i) > increc ()