Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ewdlop/prolog-notes

https://en.wikipedia.org/wiki/Prolog
https://github.com/ewdlop/prolog-notes

atom depth-first-search horn-clauses knowledge-base literal logical-entailment prolog sld-resolution

Last synced: 1 day ago
JSON representation

https://en.wikipedia.org/wiki/Prolog

Awesome Lists containing this project

README

        

# Prolog-notes

## Locke's Philosophy

[Locke's Philosophy](https://en.wikipedia.org/wiki/John_Locke)

## https://www.cs.trincoll.edu/~ram/cpsc352/notes/prolog/factsrules.html

```prolog

% Relational Database "Representation" in Prolog

% Define tables as facts
% Table: employees(employee_id, name, department_id)
employee(1, john, 101).
employee(2, mary, 102).
employee(3, tom, 101).
employee(4, susan, 103).

% Table: departments(department_id, department_name)
department(101, sales).
department(102, hr).
department(103, it).

% Foreign key relationship: employees.department_id -> departments.department_id

% Rule to join employees and departments (SQL equivalent: SELECT * FROM employees JOIN departments)
employee_department(EmployeeName, DepartmentName) :-
employee(_, EmployeeName, DepartmentID),
department(DepartmentID, DepartmentName).

% Queries:
% Who works in the Sales department?
% ?- employee_department(EmployeeName, sales).

% Which department does Tom work in?
% ?- employee_department(tom, DepartmentName).

```