All Projects → acharal → hopes

acharal / hopes

Licence: GPL-2.0 License
Higher Order Prolog with Extensional Semantics

Programming Languages

haskell
3896 projects
prolog
421 projects
Yacc
648 projects
Makefile
30231 projects

Projects that are alternatives of or similar to hopes

aria
Expressive, noiseless, interpreted, toy programming language
Stars: ✭ 40 (-6.98%)
Mutual labels:  interpreter
lust
A parser, compiler, and virtual machine evaluator for a minimal subset of Lua; written from scratch in Rust.
Stars: ✭ 120 (+179.07%)
Mutual labels:  interpreter
js-ziju
Compile javascript to LLVM IR, x86 assembly and self interpreting
Stars: ✭ 112 (+160.47%)
Mutual labels:  interpreter
computation-py
Python implementation for Understanding Computation book.
Stars: ✭ 22 (-48.84%)
Mutual labels:  interpreter
dragon
🐲 Object orientated, dynamically typed, interpreted programming language inspired by Python and Javascript.
Stars: ✭ 14 (-67.44%)
Mutual labels:  interpreter
esoo
Like the Programming Languages Zoo but with esoteric languages.
Stars: ✭ 18 (-58.14%)
Mutual labels:  interpreter
hematita
A memory safe Lua interpreter
Stars: ✭ 118 (+174.42%)
Mutual labels:  interpreter
cosy
A simple and pleasant programming language.
Stars: ✭ 21 (-51.16%)
Mutual labels:  interpreter
wazm
Web Assembly Zig Machine
Stars: ✭ 54 (+25.58%)
Mutual labels:  interpreter
boba-js
Toy programming language. Now being reimplemented in Rust: https://github.com/poteto/monkers
Stars: ✭ 22 (-48.84%)
Mutual labels:  interpreter
fakejava
嵌入式脚本语言 Lightweight embedded scripting language
Stars: ✭ 41 (-4.65%)
Mutual labels:  interpreter
oxide-lang
Oxide Programming Language, an interpreted scripting language with a Rust influenced syntax.
Stars: ✭ 106 (+146.51%)
Mutual labels:  interpreter
samlang
Sam's Programming Language
Stars: ✭ 22 (-48.84%)
Mutual labels:  interpreter
snap
An embeddable scripting language inspired by Lua and JavaScript.
Stars: ✭ 32 (-25.58%)
Mutual labels:  interpreter
chickadee
Chickadee is a minimal programming language implemented in TypeScript for teaching purposes.
Stars: ✭ 13 (-69.77%)
Mutual labels:  interpreter
clyde
Dialogue language and tools for games.
Stars: ✭ 21 (-51.16%)
Mutual labels:  interpreter
js-slang
Implementations of the Source languages, which are small sublanguages of JavaScript designed for SICP JS
Stars: ✭ 41 (-4.65%)
Mutual labels:  interpreter
monkers
Bytecode compiler and VM for the Monkeylang language, written in Rust
Stars: ✭ 34 (-20.93%)
Mutual labels:  interpreter
go-jdk
Run JVM-based code in Go efficiently
Stars: ✭ 61 (+41.86%)
Mutual labels:  interpreter
free-monads-functional-web-apps
Delving into Free Monads and using them to write pure functional web applications
Stars: ✭ 18 (-58.14%)
Mutual labels:  interpreter

HOPES: Higher-Order PROLOG with Extensional Semantics

GitHub license Build Status

HOPES is a prototype interpreter for a higher-order PROLOG-like language.

The syntax of the language extends that of PROLOG by supporting higher-order constructs (such as higher-order predicate variables, partial application and lambda terms). In particular, the syntax allows clauses (and queries) that contain uninstantiated predicate variables. The interpreter implements a higher-order top-down SLD-resolution proof procedure described in CKRW13 together with the semantics of the language.

HOPES has all the advantages of a higher-order system but continues to keep the flavor of classical PROLOG programming.

Introduction

In HOPES one can express popular functional operators such as map:

map(R,[],[]).
map(R,[X|Xs],[Y|Ys]) :- R(X,Y), map(R,Xs,Ys).

Apart from using functional operators in a logic programming context, we can also express naturally relational operators and graph operators:

join(R,Q)(X) :- R(X), Q(X).
union(R,Q)(X) :- R(X).
union(R,Q)(X) :- Q(X).
singleton(Y)(X) :- X = Y.
diff(R,Q)(X) :- R(X), not(Q(X)). 
tc(G)(X,Y) :- G(X,Y).
tc(G)(X,Y) :- G(X,Z), tc(G)(Z,Y).

The definition of higher-order predicates together with the use of partial applications can lead to a different programming style that blends the functional and the logic programming. The following HOPES snipset shows how we can define except (i.e. the predicate that succeeds for all elements of R except Y) by reusing (possibly) partially applied operators.

except(R,Y)(X) :- diff(R, singleton(Y)).

As in classical PROLOG it is not required to use in a query some variables as input and some variables as output. Along that lines, HOPES also support queries that may have unbound predicate variables. For example, one can query

?- tc(G)(a,b).

to ask for potential graphs G whose transitive closure contains (a,b). In that case the interpreter will systematically (and in a sophisticated way) investigate all finite instantiations of these variables. The answers will be sets that represent the extension of G even if no such predicate is currently defined in the program. For example, potential answers of the aforementioned query will be:

G = { (a,b) } ;
G = { (a,X1), (X1,b) } ;
G = { (a,X1), (X1,X2), (X2,b) };

Getting Started

Building HOPES

In order to build HOPES you must should install haskell stack.

$ curl -sSL https://get.haskellstack.org/ | sh
$ stack build

Note for Windows

Microsoft Windows compilations are not yet tested but there should be no problem as far as GHC and cabal are installed in the system.

Running some examples

In pl/examples directory there are some hopes examples to getting started. To load an example you must type

-? :l pl/examples/file.pl
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].