; @author Jonas Schöpf
; Ctrl example from examples/student/sum10.ctrs
(format LCTRS :smtlib 2.6)

(theory Ints)

(sort Result)

(fun w (-> Int Int Int Result))
(fun return (-> Int Result))
(fun v (-> Int Int Int Result))
(fun u (-> Int Int Int Result))
(fun sum1 (-> Int Result))

(rule (w n i s) (return s) :guard (not (< s 0)))
(rule (w n i s) (return -1) :guard (< s 0))
(rule (v n i s) (w n i s) :guard (not (and (<= i n) (>= s 0))))
(rule (v n i s) (v n (+ i 1) (+ s i)) :guard (and (<= i n) (>= s 0)))
(rule (u n i s) (v n 0 s) :guard (not (< n 0)))
(rule (u n i s) (return 0) :guard (< n 0))
(rule (sum1 n) (u n rnd 0))
