1 Embedded Parenlog
The easiest way to get started using Parenlog for Racket is with the main module:
(require parenlog) | package: parenlog |
Here is a basic example of using Parenlog:
Examples:
> (define-model family-tree (parent rogue moria) (parent rogue larn) (parent rogue omega) (parent rogue hack) (parent moria angband) (parent hack nethack) (parent angband tome) (parent angband zangband) (parent omega adom) (parent nethack adom) (parent nethack zapm) (parent nethack slashem) (parent nethack crawl) (:- (sibling X Y) (parent Z X) (parent Z Y) (,(compose not equal?) X Y)))
> (query-model family-tree (sibling adom zapm)) '(#hasheq())
> (query-model family-tree #:limit 4 (sibling X Y))
'(#hasheq((X . moria) (Y . larn))
#hasheq((X . moria) (Y . omega))
#hasheq((X . moria) (Y . hack))
#hasheq((X . larn) (Y . moria)))
syntax
(define-model id stmt ...)
stmt = head-query | (:- head-query body-query ...) head-query = s-expr body-query = s-expr | (,fun s-expr ...)
id : identifier?
fun : (any/c ... -> boolean?)
Defines id as a Parenlog model.
syntax
Syntax that may only appear within define-model.
syntax
(query-model model-expr maybe-limit body-query)
maybe-limit =
| #:limit limit-expr
model-expr : model?
limit-expr : number?
Queries model-expr with body-query until limit-expr results are found
or no results remain.
Returns a value matching the contract: (listof (hash/c symbol? anc/c)). Each value in this list is a substitution of body-query that model-expr proves.