-1

What does E -> T mean ? Variable E implies variable T ?

This the code which is linked :

e(TS,R) :- t(TS,R).

Thanks for your help

max66
  • 65,235
  • 10
  • 71
  • 111
wallace27
  • 35
  • 5
  • 1
    I'm not sure what you mean when you say, *This the code which is linked*. What does "linked" mean here? `(->)/2` in the term `E -> T` doesn't exactly mean "implies" but it does have a specific behavior in Prolog depending upon the result of `E` and `T`. `E -> T` fails if `E` fails. `E -> T` fails and doesn't backtrack to `E` if `E` succeeds and then `T` fails (as opposed to `E, T` in which case if `E` succeeds and then `T` fails, it will backtrack to `E`). `E -> T` succeeds if `E` and then `T` succeed. `E -> T` behaves like `E, !, T`. – lurker Mar 08 '17 at 16:29
  • 2
    Did you really mean `e --> t`? And be mindful of case. It matters in Prolog. And there's a huge difference between `-->` and `->`. – lurker Mar 08 '17 at 19:59

1 Answers1

4

Are you sure that you asking about E -> T (if E then T) and not about e --> t (lower case (thanks lurker!) and DCG syntax, where "DCG" is for "Definite Clause Grammar")?

Because the DCG syntax

e --> t.

is an alias (or a shortcut or syntactic sugar, if you prefer) for

e(L1, L2) :- t(L1, L2).

More generally speaking, the DCG syntax adds a couple of arguments, at the end of the clauses involved, making a chain on the right side of the :- operator where the the start and the end of the chain are the arguments added on the left side.

So (by example)

d --> c1, c2, ...., cn.

is an alias for

d(L1, Lnp1) :- c1(L1, L2), c2(L2, L3), ..., cn(Ln, Lnp1).
max66
  • 65,235
  • 10
  • 71
  • 111