Re: [eclipse-clp-users] Implying Initial Domains for Certain Arguments of Predicates

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Wed, 7 Oct 2015 14:42:25 +0100
On 06/10/2015 13:48, Gkhan Solak wrote:
> Thank you for your answer.
> Moving from your suggestion, I came up with a solution.
> What I wanted to do was to give an initial domain to the variables, according to their role as an
> argument in some predicates.

If you want to say something general about an argument of a predicate,
e.g. about the second argument of age(_,_), then you have to say it
*inside* the definition of age:

age(Thing, Age) :- ... Age :: ...

> To do this task I created a new predicate *init_domain/1*. And defined the init_domain with
> predicate-domain pairs as such:
> init_domain(X) :- age(_A, X), human(_A), X :: 1..130.
> init_domain(X) :- age(_, X), integers(X).
> init_domain(X) :- height(_A, X), human(_A), X :: 30..230.
> ...
> For every such predicate-domain pair, definition of init_domain should be extended. This way, when
> init_domain is called for every variable in the system, they will automatically be constrained with
> appropriate initial domains.

No, you fundamentally misunderstand something here.  init_domain has
only one argument, and will have the same effect on any variable you
call it with.

Your misconception seems to lie with the scope of variables and the way
resolution works (
It might help to run again through some introductory text and/or to look
in detail at some of the code examples in the tutorial and on the web site.

-- Joachim
Received on Wed Oct 07 2015 - 13:42:33 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST