From 417548361eb0c7a4c449245d19436e24d1b7f80a Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Tue, 7 Dec 2021 09:34:54 +0000 Subject: Move prolog site --- sites/pprolog.org/_images/screenshot.png | Bin 40738 -> 0 bytes sites/pprolog.org/_werc/config | 3 - sites/pprolog.org/_werc/lib/footer.inc | 1 - sites/pprolog.org/_werc/lib/top_bar.inc | 8 -- sites/pprolog.org/_werc/pub/style.css | 122 -------------------- sites/pprolog.org/about.md | 0 sites/pprolog.org/documentation/index.md | 28 ----- .../documentation/tutorial/1.-install.md | 17 --- .../documentation/tutorial/2.-prolog-primer.md | 127 --------------------- .../pprolog.org/documentation/tutorial/3.-repl.md | 0 .../tutorial/4.-writing-and-consulting.md | 0 sites/pprolog.org/favicon.ico | Bin 2576 -> 0 bytes sites/pprolog.org/index.md | 72 ------------ sites/pprolog.org/source.md | 0 14 files changed, 378 deletions(-) delete mode 100644 sites/pprolog.org/_images/screenshot.png delete mode 100644 sites/pprolog.org/_werc/config delete mode 100644 sites/pprolog.org/_werc/lib/footer.inc delete mode 100644 sites/pprolog.org/_werc/lib/top_bar.inc delete mode 100644 sites/pprolog.org/_werc/pub/style.css delete mode 100644 sites/pprolog.org/about.md delete mode 100644 sites/pprolog.org/documentation/index.md delete mode 100644 sites/pprolog.org/documentation/tutorial/1.-install.md delete mode 100644 sites/pprolog.org/documentation/tutorial/2.-prolog-primer.md delete mode 100644 sites/pprolog.org/documentation/tutorial/3.-repl.md delete mode 100644 sites/pprolog.org/documentation/tutorial/4.-writing-and-consulting.md delete mode 100644 sites/pprolog.org/favicon.ico delete mode 100644 sites/pprolog.org/index.md delete mode 100644 sites/pprolog.org/source.md (limited to 'sites/pprolog.org') diff --git a/sites/pprolog.org/_images/screenshot.png b/sites/pprolog.org/_images/screenshot.png deleted file mode 100644 index a1e75ce..0000000 Binary files a/sites/pprolog.org/_images/screenshot.png and /dev/null differ diff --git a/sites/pprolog.org/_werc/config b/sites/pprolog.org/_werc/config deleted file mode 100644 index bc8c0e5..0000000 --- a/sites/pprolog.org/_werc/config +++ /dev/null @@ -1,3 +0,0 @@ -masterSite=prolog.pmikkelsen.com -siteTitle='PProlog' -siteSubTitle='A prolog for plan9' diff --git a/sites/pprolog.org/_werc/lib/footer.inc b/sites/pprolog.org/_werc/lib/footer.inc deleted file mode 100644 index ac3b4a1..0000000 --- a/sites/pprolog.org/_werc/lib/footer.inc +++ /dev/null @@ -1 +0,0 @@ -Powered by werc © Peter Mikkelsen 2020-2021 \ No newline at end of file diff --git a/sites/pprolog.org/_werc/lib/top_bar.inc b/sites/pprolog.org/_werc/lib/top_bar.inc deleted file mode 100644 index e6a79eb..0000000 --- a/sites/pprolog.org/_werc/lib/top_bar.inc +++ /dev/null @@ -1,8 +0,0 @@ -
- pprolog source code | - pmikkelsen's site | - 9front -
- -
-
diff --git a/sites/pprolog.org/_werc/pub/style.css b/sites/pprolog.org/_werc/pub/style.css deleted file mode 100644 index 1002606..0000000 --- a/sites/pprolog.org/_werc/pub/style.css +++ /dev/null @@ -1,122 +0,0 @@ -body { display: flex; flex-wrap: wrap; font-family: sans;} -header { flex-basis: 100%; flex-shrink: 0; } -article { flex-basis: 60%; padding-left: 1em; } -footer { flex-basis: 100%; flex-shrink: 0; } -header nav { display: flex; justify-content: space-between; } -nav a, header a { text-decoration: none ; color: inherit; } -header h1 span { margin-left: 1em; font-size: 50%; font-style: italic; } -.mainContent > nav { flex-basis: content; padding-right: 1vw; min-width: 16em; } -nav ul { display: flex; flex-direction: column; list-style-type: none; list-style-position: outside; padding-left: 0; } -nav li ul { padding-left: 0.6em } -footer { display: flex; justify-content: space-between; } - -/* cut here to leave vanity behind */ - -body { margin:0; padding: 0; font-size: 84%; font-family: Helvetica, Verdana, Arial, 'Liberation Sans', FreeSans, sans-serif; } -a { text-decoration: none; color: } -a:hover { text-decoration: underline; } -.thisPage { color: black; } - -/* header and top bar */ -header nav { background-color: rgb(100,135,220); color: white; padding: 0.3em; border-bottom: 2px solid black; font-size: 91%; } -header h1 { background-color: #ff6d06; color: black; margin: 0; border-bottom: 2px solid black; font-weight: normal; padding: 0.25ex; font-size: 233%; } -header a:hover { text-decoration: none; } - -/* sidebar */ -.mainContent > nav { border-right: 1px solid #ddd; padding: 0; } -.mainContent > nav > div { border-bottom: 1px solid #ddd; } -.mainContent > nav > div a { color: rgb(0, 102, 204); display: block; text-transform: capitalize; font-weight: bold; padding: 0.25em 1ex 0.25em 2mm; font-size: 102%} -.mainContent > nav > div a:hover { color: white; background-color: rgb(100,135,220); border-left: black solid 0.2em; text-decoration: none; } -.mainContent > nav > div p { font-weight: bold; margin: 0 0 0.5em 2mm; padding: 1em 0 0 0; } - -/* main copy */ -article { padding: 0.5ex 0 5vh 1vw; } -article h1, article h2 { color: rgb(0,102,204); font-weight: bold; margin: 2em 0 0 0; border-bottom: 2px solid rgb(0,102,204); } -article h3, article h4, article h5 { color: rgb(0,102,204); font-weight: bold; margin: 2em 0 0 0; } -article h6, article h7, article h8 { color: rgb(0,102,204); font-weight: bold; margin: 2em 0 0 0; } -article a { color: rgb(0,102,204); } -article a:hover { color: rgb(100,135,220); } -article pre { font-size: 1.2em; } - -/* footer */ -footer { color: white; background-color: rgb(100,135,220); } -footer a { color: inherit; } -footer div { padding: 1em; } - -/* tables */ -table { border: 1px solid rgba(128,128,128,0.5); padding: 0; } -th { color: white; background-color: rgb(100,135,220); } -tr:nth-child(odd) { background-color: rgba(128,128,128,0.1) } - -/* modifications */ -img { - max-width: 100%; - border: 1px solid black; -} - -body { - -} - -header h1 { - background-color: #c2d2c6; -} - -html { - font-size: 1.2em; -} - -header nav, footer { - background-color: #442a13; -} - -code > pre { - border: 2px solid #442a13; - background-color: #c2d2c6; - width: max-content; - padding: 0 0.5em; -} - -.mainContent > nav > div a, article a:hover { - color: #442a13; -} - -.mainContent > nav > div a:hover { - color: #442a13; - background-color: #c2d2c6; -} - -article h1, article h2 { - color: #c48f3b; - border-bottom: 2px solid #442a13; -} - -article a, .thisPage, footer, header nav { - color: #c48f3b; -} - -footer { - padding: 0.5em; - flex-shrink: 1; - flex-basis: unset; -} - -header { - flex-basis: unset; -} - -html { - display: flex; - min-height: 100%; -} - -body { - flex-direction: column; - flex: 1; - background-color: #e3dfd7; -} - -.mainContent { - display: flex; - flex-grow: 1; -} \ No newline at end of file diff --git a/sites/pprolog.org/about.md b/sites/pprolog.org/about.md deleted file mode 100644 index e69de29..0000000 diff --git a/sites/pprolog.org/documentation/index.md b/sites/pprolog.org/documentation/index.md deleted file mode 100644 index 77da430..0000000 --- a/sites/pprolog.org/documentation/index.md +++ /dev/null @@ -1,28 +0,0 @@ -# Learning prolog - -If you are new to prolog the following resources helped me a lot in the -beginning and they still do: - -* [The Power of Prolog](https://www.metalevel.at/prolog) by Markus Triska is a great book about prolog and logic programming and is very up to date. -It even contains videos for some of its topics which can help a bit. The text is easy to read and -the chapters are short so it doesn't become overwhelming. -* [The Art of Prolog](https://mitpress.mit.edu/books/art-prolog) an older book by Leon S. Sterling and Ehud Y. Shapiro which goes much more into -the details and foundations of logic programming, but since it is older -it should not be your only learning source. This book is my recommendation for people who are not afraid to read a bit since it is very -interesting. - -Please be aware that some of the things taught in the books aren't supported by pprolog yet, such as constraint logic programming which is used a lot in Triskas book for doing integer arithmetic. - -# PProlog tutorial - -There exists a mini series to get you up and running with -the pprolog system: - -* [Installing](/documentation/tutorial/1.-install) covers the steps needed to install pprolog on you very own 9front machine. -* [Prolog primer](/documentation/tutorial/2.-prolog-primer) gives a short introduction to prolog. -* [Using the repl](/documentation/tutorial/3.-repl) explains how to ask queries to the system at the repl. -* [Writing and consulting code](/documentation/tutorial/4.-writing-and-consulting). While asking queries using only the standard library and the builtins is fun, it becomes even more fun when you can write your own fact and rules and load them. - -# Information about the standard library and the builtins - -At the moment [the source](https://git.sr.ht/~pmikkelsen/pprolog) is the documentation. \ No newline at end of file diff --git a/sites/pprolog.org/documentation/tutorial/1.-install.md b/sites/pprolog.org/documentation/tutorial/1.-install.md deleted file mode 100644 index f6f4bb2..0000000 --- a/sites/pprolog.org/documentation/tutorial/1.-install.md +++ /dev/null @@ -1,17 +0,0 @@ -# Install - -Since pprolog has zero dependencies other than what is available by default on 9front -it is pretty easy to install. - -If you have [git9](https://orib.dev/git9.html) installed the steps are: - - git/clone https://git.sr.ht/~pmikkelsen/pprolog - cd pprolog - mk install - - -This will install the pprolog binary to `/$objtype/bin`, so you may want to modify -`BIN` in the `mkfile` to install to somewhere else like `$home/bin/$objtype/` - -It will also install the prolog libraries to `/sys/lib/prolog` and this is hardcoded -in the `mkfile` and in `dat.h` if you want to change that. diff --git a/sites/pprolog.org/documentation/tutorial/2.-prolog-primer.md b/sites/pprolog.org/documentation/tutorial/2.-prolog-primer.md deleted file mode 100644 index f26345e..0000000 --- a/sites/pprolog.org/documentation/tutorial/2.-prolog-primer.md +++ /dev/null @@ -1,127 +0,0 @@ -# Introduction - -This page provides a *very* brief overview of prolog. For more documentation look at -[the documentation page](https://pprolog.org/documentation/). Also be aware that this -introduction is only _my_ explanation, so don't take it as 100% truth. - -First of all, prolog is a programming language in the family of languages called -*logic programming languages*. This means that it is very different from imperative -or functional programming, so you should read this with an open mind and try to -forget some of the things you already know. - -# Logic - -What does it mean to be a logic programming language? Well, it means that the programs written in it -can be understood as logical rules and results can be inferred from those rules. This leads to a very -declarative way of writing code which is often much cleaner than what could be written in C for example. - -It also means that in prolog we don't write code to tell the computer what to do, we write code to -express the facts and relations about a problem, and the prolog system then uses those facts and rules -to infer the result. - -# Example - -To calculate the length of a list in an imperative language like C, the following code would work. - - typedef struct List List; - struct List - { - int element; - List *next; - }; - - int - length(List *list) - { - int len = 0; - for(; list != nil; list = list->next) - len++; - - return len; - } - -It is very clear that the `length` function takes a list as input -and then runs a loop which increments `len` until the end of the list is reached. - -Compare this to the prolog code below which is a prolog predicate with arity 2, also sometimes called -`length/2` to describe the name and the arity. - - length([], 0). - length([_|Tail], N) :- - length(Tail, TailLength), - N is TailLength + 1. - -This code is written in a declarative style and it doesn't express _how_ the length -of the list is found, it expresses _what_ the length of a list is. -The code consists of two *clauses*: a fact and a rule. - -The fact `length([], 0).` describes that the length of an empty list (`[]`) is zero. - -The rule - - length([_|Tail], N) :- - length(Tail, TailLength), - N is TailLength + 1. - -describes that the length of a non-empty list with head `_` (we don't care about the head), and tail `Tail` has -then length `N` *if*: - -1. The length of the tail is `TailLength` *and* -2. `N` is `TailLength` plus one. - -The rule consists of a *head* `length([_|Tail), N)` and two goals separated by a comma which means *and*. - -# Wait, is the output just the last parameter? - -No, in general much prolog code describes relations between the parameters. -The length predicate from before as an example of that, but it could just -as well be used to check if a list has a given length, by providing an input for -both arguments. - -# Queries - -When `pprolog` is run it presents a toplevel where queries can be entered. The queries are like questions that -the prolog system tries to answer. It does this by looking in the *prolog database* which initially consists of -the predicates which are part of the standard library. Since `length/2` is part of the standard library, we could ask - - ?- length([1,2,3,a,b,c], Len). - -And it would respond - - Len = 6. - -In general, if a word starts with an uppercase letter it is a variable like `Len`, `Hello`, `X` and `Y`, and otherwise it -is an *atom* which just represents itself. - -To show that `length/2` can be used in multiple ways, consider the query - - ?- length([1,2], 4). - -What do you think it will say? The result is - - false. - -because it is not possible for the system to infer the the length of the list `[1,2]` is `4` using any of the -rules in the prolog database. The steps the system takes in calculating this result are: - -1. The fact `length([],0)` is tried first but it fails to *unify* (more on that later) with the query since -the empty list does not unify with our non-empty list, and 0 does not unify with 4. -2. The rule with the head `length([_|Tail], N)` is chosen at it unifies with our query giving the variables -`Tail = [2]` and `N = 4`. -3. The first goal is `length(Tail, TailLength)` and with the value of `Tail` that becomes `length([2], TailLenght)`. -As in step 1, the first fact does not unify with this goal since `[]` does not unify with `[2]`. -4. The second rule unifies with our goal and the variables become `Tail = []` and `N = TailLength`. Note that it is perfectly valid -to assign two unassigned variables to each other in prolog, and this just means that they should now be considered the same, and when one -of them is unified with a concrete value, the other will get that value too. -5. The first subgoal is tried again and this time it matches the first rule since `[]` unifies with `[]`, and `0` unifies `TailLength` with -the side effect that both `TailLength` and `N` is now 0. -6. We go back to step 4 and continue with subgoal 2 which says that `N` is `TailLength + 1` and N is therefore 1. -7. We go back to step 3 and continue with subgoal 2 which says that `N` is `TailLength + 1` but this fails since `N` at this -point was 4 and `TailLength` is 1, but the fact `4 = 1 + 1` is false. Since there are no more rules or facts to try, the whole query fails. - -(_that explanation was a mess_) - -# Unification - -say wut, like pattern matching but works both ways. - diff --git a/sites/pprolog.org/documentation/tutorial/3.-repl.md b/sites/pprolog.org/documentation/tutorial/3.-repl.md deleted file mode 100644 index e69de29..0000000 diff --git a/sites/pprolog.org/documentation/tutorial/4.-writing-and-consulting.md b/sites/pprolog.org/documentation/tutorial/4.-writing-and-consulting.md deleted file mode 100644 index e69de29..0000000 diff --git a/sites/pprolog.org/favicon.ico b/sites/pprolog.org/favicon.ico deleted file mode 100644 index 745367e..0000000 Binary files a/sites/pprolog.org/favicon.ico and /dev/null differ diff --git a/sites/pprolog.org/index.md b/sites/pprolog.org/index.md deleted file mode 100644 index 4d0efc5..0000000 --- a/sites/pprolog.org/index.md +++ /dev/null @@ -1,72 +0,0 @@ -# Introduction - -This is the website for PProlog, a new prolog implementation written -in C on and for plan 9 (9front specifically). Work started in december 2020 -due to the author's need for a prolog system on 9front. It is pure experimentation -and the code might be bad in more than a few places. - -*NOTE:* There is no development currently, and it is in a kinda broken state after -a failed attempt of adding modules. - -# Features - -* A base system based on the WAM (Warren abstract machine) implemented by following the book [here](http://wambook.sourceforge.net/wambook.pdf). -* Support for extended precision arithmetic via [mp(2)](http://man.9front.org/2/mp). -* Basic support for definite clause grammars (DCGs). For now DCG's are translated by the parser into difference lists and they do not support everything one expects. -* Lists. -* Strings represented as list of char atoms. -* The basic control predicates such as `,/2`, `;/2`, `->/2` and cut. -* Full unicode support. - -# Status - -At this moment the system works OK but it has very few builtin predicates -and much of what people expect from a working prolog system is still missing. - -The list of builtins as of January 13, 2021 is: - -* `is/2` -* `halt/0` -* `consult/1` -* `write/1` -* `read/1` -* `call/n` -* `fail/0` -* `>/2` -* `==/2` -* `atom/1` -* `integer/1` -* `float/1` -* `var/1` -* `compound/1` -* `term_variables/2` - -And the following predicates are implemented in the standard library: - -* `=/2` -* `\=/2` -* `reverse/2` -* `samelength/2` -* `append/3` -* `member/2` -* `select/3` -* `length/2` -* `nl/0` -* `phrase/2` -* `\+/2` -* `false/0` -* `true/0` -* `repeat/0` -* `once/1` -* `,/2` -* `;/2` -* `->/2` -* `=\=/2` - -and many more all listed [here](https://git.sr.ht/~pmikkelsen/pprolog/tree/master/item/stdlib.pl). - -# Screenshot - -[![A picture of pprolog in action][1]][1] - -[1]: /_images/screenshot.png diff --git a/sites/pprolog.org/source.md b/sites/pprolog.org/source.md deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3