Prolog Predicates

Поделиться
HTML-код
  • Опубликовано: 6 ноя 2024

Комментарии • 11

  • @iamjimfan
    @iamjimfan 5 лет назад +2

    For years I've been using Prolog, this is the first time I come across dif/2 predicate !
    (Edited) Anyway I just tried dif/2 in swi-prolog and found it is readily available as a *constraint* in clpfd. But it is not recognised by eclipse-clp.

    • @ThePowerOfProlog
      @ThePowerOfProlog  5 лет назад +4

      In eclipse-clp, sound disequality is available as (~=)/2:
      www.eclipseclp.org/doc/bips/kernel/termcomp/TE-2.html
      You can easily make this an alias for dif/2. dif/2 is also available in SICStus Prolog. Enjoy!

  • @owonubijobsunday4764
    @owonubijobsunday4764 5 лет назад +5

    Saved a life

  • @bertrandduguesclin826
    @bertrandduguesclin826 2 года назад +1

    Why do you define the unification predicate as (=)/2 and not =/2 ?

    • @ThePowerOfProlog
      @ThePowerOfProlog  2 года назад +1

      = is a predefined infix operator, and an operator cannot be a direct operand of an operator (such as /). Therefore, I am writing (=)/2, so that the predicate indicator is itself also a valid Prolog term. For example, using Scryer Prolog, we get:
      ?- write_canonical((=)/2).
      /(=,2)
      On the other hand, =/2 is not a valid Prolog term:
      ?- write_canonical(=/2).
      error(syntax_error(incomplete_reduction),read_term/3:1).

    • @bertrandduguesclin826
      @bertrandduguesclin826 2 года назад +1

      ​@@ThePowerOfProlog Thanks for the clarification. With SWI-Prolog, if I write write_canonical(=/2) I obtain an error message, but if I enter write_canonical(;/2) then I obtain /(;,2). Isn't ; an operator also ?

    • @ThePowerOfProlog
      @ThePowerOfProlog  2 года назад +1

      ​@@bertrandduguesclin826 SWI-Prolog cannot be used to tell what is Prolog syntax and what is not, because SWI-Prolog is not conforming to the Prolog ISO standard. For learning Prolog syntax, I recommend to use a conforming Prolog system. For example, with Scryer Prolog, we get:
      ?- write_canonical(;/2).
      error(syntax_error(incomplete_reduction),read_term/3:1).
      ?- write_canonical((;)/2).
      /(;,2) true.
      This is because ';' is an infix operator, and therefore cannot be used as a direct operand of another operator (such as '/').

    • @bertrandduguesclin826
      @bertrandduguesclin826 2 года назад

      @@ThePowerOfProlog ok Thank you

  • @i6g7f
    @i6g7f 2 года назад +1

    Danke! Thank You

  • @robertdowneysr_
    @robertdowneysr_ 4 года назад

    if I have a problem like
    gossip(X) : X loves to gossip
    friend (X,Y) : X is a friend of Y
    knows(X,S) : X knows the secret S
    X knows the secret and blurt it out to his friend so what is
    we want to find the predicate for gets-to-know(X,S) :-

  • @noguy909
    @noguy909 3 года назад +2

    you can define false, by not defining false xD