Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "relational_clpq"

Title:A pure relational library for rational (fractions) arithmetic.
Rating:Not rated. Create the first rating!
Latest version:1.0.1
SHA1 sum:2e0f5b03356291b872400bb8e192c82a0eecbb48
Author:Luiz Fernando https://github.com/LuizFBR
Maintainer:Luiz Fernando https://github.com/LuizFBR
Packager:Luiz Fernando https://github.com/LuizFBR
Home page:https://github.com/LuizFBR/relational_clpq
Download URL:https://github.com/LuizFBR/relational_clpq.git

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
1.0.12e0f5b03356291b872400bb8e192c82a0eecbb482https://github.com/LuizFBR/relational_clpq

Relational-CLPQ

A Prolog pack built on top of CLPFD that allows reasoning about the rational numbers.

To-do:

  • More robust testing strategy (Limit Value Analysis);
  • Implementing logical (and, or, ...) operators;
  • Implementing domain/membership operators.
  • Implementing other arithmetic operators (^, mod, rem, min, max,...).

Installation

To install the relational-clpq library, type the following in the SWI-Prolog shell:

? - pack_install('relational_clpq').
  true.

or, alternatively, you can install directly from this github repo:

?- pack_install('https://github.com/LuizFBR/Relational-CLPQ.git').
  true.

Examples

Comparison of rational numbers:

1 ?- 10 :=: 10 .
true.

The following example shows clpfd's purity (two-way relation) in action:

2 ?- (10 + X) / Y :=: Z .
clpfd: #=(10+ #(X), #(_A)),
clpfd: #=(#(Z)* #(Y), #(_A)) .
3 ?- 1/2 :=<: 1/2 .
true ;
false.
3 ?- 1/2 :=<: 1/4 .
false.

List of all comparison constraints:

OperatorMeaning
Expr1 :=: Expr2Expr1 equals Expr2
Expr1 :\=: Expr2Expr1 is not equal to Expr2
Expr1 :>=: Expr2Expr1 is greater than or equal to Expr2
Expr1 :=<: Expr2Expr1 is less than or equal to Expr2
Expr1 :>: Expr2Expr1 is greater than Expr2
Expr1 :<: Expr2Expr1 is less than Expr2

Importing

Import this module with

:- use_module(library(relational_clpq)).

Dependencies

This library depends on Markus Triskas' clpfd library:

https://www.swi-prolog.org/man/clpfd.html

Contents of pack "relational_clpq"

Pack contains 4 files holding a total of 5.8K bytes.