🦲
mind
  • cleber's mind
  • plans
    • fact checking
    • personal assistant
  • self-management
    • agenda and tasks
    • mails and emails
  • knowledge
    • career
    • programming
      • Big O Notation
      • browsing data
      • C/C++
      • databases
      • eclipse
      • gradle
      • java
        • apache camel
      • javascript
      • naming convention
      • mysql
      • prolog
      • regex
      • REST
      • ssl/tls
      • version control
        • git commands
      • web-semantics
      • wot
    • research
      • mas
      • planning
      • math
        • probability
      • machine learning
      • nlp
      • speech recognition
      • data sources
      • data visualisation
    • it
      • asterisk
      • containers
        • installing docker
        • deploying busybox
        • deploying a sample
        • deploying node-red
        • deploying from the hub
      • clusters
        • installing kubernetes
        • deploying bootcamp
        • deploying nginx
        • deploying jacamo-rest
        • grafana
      • deploy
        • heroku
      • linux
        • tmux
        • vim
        • startup
      • networks
      • pdf
        • ssh
    • productivity
    • language
      • expressions
        • nice signposts
        • linking expressions
      • latex
      • scientific
      • writing
    • sailing
    • financial
      • assets
    • emergency
    • out of boxes
  • teaching
    • eletrônica digital
      • Conversão decimal para binário
      • Conversão binário para decimal
      • Sinais analógicos vs digitais
    • programação I
    • cabeamento estruturado
  • moments
    • insightful ai facts
    • ai4industry-hackathon
    • previous activities
  • brasil
  • external links
    • personal webpage
    • my github
Powered by GitBook
On this page
  • First steps
  • Installing gnu prolog
  • Running a simple application on gnu prolog
  • Adding new facts
  • Appending elements to a list
  • To be continued...

Was this helpful?

  1. knowledge
  2. programming

prolog

PreviousmysqlNextregex

Last updated 4 years ago

Was this helpful?

Here I have some notes about prolog. I am using . More information can be found at and .

First steps

Prolog is a symbolic language in which we declare facts and rules to then ask questions that will be answered based on these data.

Installing gnu prolog

Download and uncompress . After going to gprolog folder:

$ ./configure $ make $ sudo make install

Running a simple application on gnu prolog

Starting in a very simple way, let us prepare a set of facts. In gnu prolog, it must be written in a file. Let us considerer the file zoo.pl with the following content:

animal(turtle). animal(tiger). animal(giraffe).

Running gnu prolog on the folder we have the file zoo.pl:

$ gprolog GNU Prolog 1.4.5 (64 bits) Compiled Apr 12 2020, 18:50:29 with gcc By Daniel Diaz Copyright (C) 1999-2020 Daniel Diaz |?-

Importing zoo.pl and making first assertion:

|?- consult(zoo). |?- animal(X).

The answer will be X = turtle ?, pressing ; it shows X = tiger ?, pressing ; again it shows the last true value for X: X = giraffe. The command consult(file) and be replaced by [file].

In fact, currently, it is all we have in the database as we can check using listing command:

|?- listing. % file: /media/data/zoo.pl animal(turtle). animal(tiger). animal(giraffe). yes |?-

To exit from gnu prolog:

|?- Ctrl+C, then e (to exit).

Adding new facts

|?- assertz(bigger(giraffe,lion)). |?- assertz(bigger(lion,turtle)).

Appending elements to a list

append_element([],E,[E]). 
append_element([H|T],E,[H|L]) :- append_element(T,E,L).

To be continued...

I am following the material from which is very practical.

GNU Prolog
GNU Prolog manual
GNU Prolog tutorial
gprolog-1.4.5
http://www.cs.trincoll.edu/~ram/cpsc352/notes/