TerminationTupledAckermann.agda 498 B

123456789101112131415161718192021222324
  1. -- test termination using structured orders
  2. module TerminationTupledAckermann where
  3. data Nat : Set where
  4. zero : Nat
  5. succ : Nat -> Nat
  6. data _×_ (A B : Set) : Set where
  7. _,_ : A -> B -> A × B
  8. -- addition in tupled form
  9. add : Nat × Nat -> Nat
  10. add (zero , m) = m
  11. add (succ n , m) = succ (add (n , m))
  12. -- ackermann in tupled form
  13. ack : Nat × Nat -> Nat
  14. ack (zero , y) = succ y
  15. ack (succ x , zero) = ack (x , succ zero)
  16. ack (succ x , succ y) = ack (x , ack (succ x , y))