;; lib/minikanren/intarith.sx — fast integer arithmetic via project. ;; ;; These are ground-only escapes into host arithmetic. They run at native ;; speed (host ints) but require their arguments to walk to actual numbers ;; — they are not relational the way `pluso` (Peano) is. Use them when ;; the puzzle size makes Peano impractical. ;; ;; Naming: `-i` suffix marks "integer-only" goals. (define pluso-i (fn (a b c) (project (a b) (if (and (number? a) (number? b)) (== c (+ a b)) fail)))) (define minuso-i (fn (a b c) (project (a b) (if (and (number? a) (number? b)) (== c (- a b)) fail)))) (define *o-i (fn (a b c) (project (a b) (if (and (number? a) (number? b)) (== c (* a b)) fail)))) (define lto-i (fn (a b) (project (a b) (if (and (number? a) (and (number? b) (< a b))) succeed fail)))) (define lteo-i (fn (a b) (project (a b) (if (and (number? a) (and (number? b) (<= a b))) succeed fail)))) (define neqo-i (fn (a b) (project (a b) (if (and (number? a) (and (number? b) (not (= a b)))) succeed fail)))) (define numbero (fn (x) (project (x) (if (number? x) succeed fail)))) (define stringo (fn (x) (project (x) (if (string? x) succeed fail)))) (define symbolo (fn (x) (project (x) (if (symbol? x) succeed fail))))