# Difference between two values

**URL:** <https://swi-prolog.discourse.group/t/difference-between-two-values/2401>\
**Category:** Predicate\
**Created:** [May 23, 2020, 4:50pm UTC](https://swi-prolog.discourse.group/t/difference-between-two-values/2401 "2020-05-23T16:50:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![centurioneagrippa](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@centurioneagrippa](https://swi-prolog.discourse.group/u/centurioneagrippa)\
**Post date:** [May 23, 2020, 4:50pm UTC](https://swi-prolog.discourse.group/t/difference-between-two-values/2401/1 "2020-05-23T16:50:04Z")

</div>

Hi, why do i see this error? The rule is:

```prolog
minorenni(T,U) :-
   dataUdienza(U,DU),
   dataNascita(T,DT),
   18 is @=<(DU-DT),
   testimone(T).

```

while the error is:

```prolog
ERROR: c:/users/luigi/desktop/regole_ontologia_giuridica.pl:49:
ERROR: Arithmetic: `@=<(_832-_854)' is not a function

```

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [May 23, 2020, 5:14pm UTC](https://swi-prolog.discourse.group/t/difference-between-two-values/2401/2 "2020-05-23T17:14:22Z")

</div>

It is hard to tell exactly what you want because you did not explain it in words.

My best guess is that you want this form:

```prolog
?- 18 =< 10 - 5.
false.

```

More examples:

```prolog
?- DU = 10, DT = 5, 18 =< DU - DT.
false.

?- DU = 40, DT = 5, 18 =< DU - DT.
DU = 40,
DT = 5.

```

Since `=<` is also a [General purpose arithmetic](https://www.swi-prolog.org/pldoc/man?section=arithpreds) function it does not need is/2 but replaces it.

`@=<` is for [sorting](https://www.swi-prolog.org/pldoc/man?section=compare) which I also don’t think is what you want.

---

<div class="post-metadata">

**Author:** ![centurioneagrippa](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@centurioneagrippa](https://swi-prolog.discourse.group/u/centurioneagrippa)\
**Post date:** [May 23, 2020, 5:38pm UTC](https://swi-prolog.discourse.group/t/difference-between-two-values/2401/3 "2020-05-23T17:38:46Z")

</div>

sorry, you’re right. T is the result and D is the data to be entered, type:

```prolog
?- minorenni(T,'http://www.semanticweb.org/luigi/ontologies/2020/2/untitled-ontology-11#Udienza1_2').

```

T is the name of the underage witness.

This rule returns the date of the hearing:

```prolog
dataUdienza(X,Y) :-
   propertyAssertion('http://www.semanticweb.org/luigi/ontologies/2020/2/untitled-ontology-11#Data_Udienza',X,literal(type('http://www.w3.org/2001/XMLSchema#int',Y))).

```

while, this rule return the date of the witness:

```prolog
dataNascita(X,Y) :-
   propertyAssertion('http://www.semanticweb.org/luigi/ontologies/2020/2/untitled-ontology-11#Data_nascita',X,literal(type('http://www.w3.org/2001/XMLSchema#int',Y))).

```

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [May 23, 2020, 5:42pm UTC](https://swi-prolog.discourse.group/t/difference-between-two-values/2401/4 "2020-05-23T17:42:35Z")

</div>

Some useful formmatting advise.

For blocks of Prolog code, if you bookend the code with ````` it will format much nicer, e.g.

```
```
functor(A,B) :-
   query_1(A),
   query_2(B).
```
```

renders as

```prolog
functor(A,B) :-
   query_1(A),
   query_2(B).

```
