Skip to main content

Module miscops

Module miscops 

Source
Expand description

Miscellaneous deterministic builtins: succ/2, plus/3, unify_with_occurs_check/2, write/1, writeln/1, nl/0.

Ported byte-for-byte from patch-prolog v1 (solver.rs arms, unify.rs occurs-check unifier). Notes:

  • succ/2 both modes; succ(X, 0) fails; negatives raise domain_error(not_less_than_zero, _); both-unbound raises instantiation.
  • plus/3 supports the three integer modes (any one argument unbound); fewer than two bound raises instantiation.
  • unify_with_occurs_check/2 uses a LOCAL occurs-checking unifier (iterative; does not touch the shared unify.rs).
  • write/1 / writeln/1 use v1’s term_to_string (infix operators, [a, b] lists, floats via {}), printed immediately. write adds no newline; writeln and nl add one.

Functions§

plg_rt_b_nl_0
nl/0: print a newline. Always succeeds.
plg_rt_b_plus_3
plus/3: Z = X + Y over integers; any single unbound is solved for.
plg_rt_b_succ_2
succ/2: S = X + 1 over non-negative integers, both modes.
plg_rt_b_unify_with_occurs_check_2
unify_with_occurs_check/2: like =/2 but fails rather than build a cyclic term. Local iterative implementation — bindings are trailed so the caller’s choice-point rewind undoes a partial unification.
plg_rt_b_write_1
write/1: print the term (v1 term_to_string), no trailing newline.
plg_rt_b_writeln_1
writeln/1: write/1 followed by a newline.