On this page:
5.1 Facts
5.2 Rules
5.2.1 Strict Rules (always)
5.2.2 Defeasible Rules (normally)
5.2.3 Defeaters (except)
5.3 Negation
5.4 Superiority
5.5 Multiple Premises
5.6 Comments
5.7 Modal Operators
5.8 Using #lang spindle
5.9 Programmatic Use
5.10 Complete Example
5.11 SPL vs DFL Comparison
9.0

5 SPL Syntax Reference🔗ℹ

 (require spindle/lang) package: spindle

SPL (Spindle LISP) is an S-expression syntax for Spindle theories, designed for Racket users who prefer parenthesized notation.

5.1 Facts🔗ℹ

Use given to declare facts:

(given bird)
(given penguin)

5.2 Rules🔗ℹ

5.2.1 Strict Rules (always)🔗ℹ

Rules that always apply, cannot be defeated:

(always r1 human mortal)
(always r2 (a b) c)           ; Multiple premises

5.2.2 Defeasible Rules (normally)🔗ℹ

Rules that typically apply but can be overridden:

(normally r1 bird flies)
(normally r2 student busy)

5.2.3 Defeaters (except)🔗ℹ

Rules that block conclusions without asserting the opposite:

(except d1 broken-wing (not flies))

5.3 Negation🔗ℹ

Use not for negated literals:

(not flies)
(normally r1 penguin (not flies))

5.4 Superiority🔗ℹ

Use prefer to declare which rules win conflicts:

(prefer r2 r1)                ; r2 defeats r1

5.5 Multiple Premises🔗ℹ

Wrap multiple premises in a list:

(normally r1 (fever cough) has-flu)
(always r2 (a b c) conclusion)

5.6 Comments🔗ℹ

Use semicolons for comments:

; This is a comment
(given bird)  ; Inline comment

5.7 Modal Operators🔗ℹ

SPL supports deontic modal operators:

(must pay-taxes)              ; Obligation
(may access-resource)         ; Permission
(forbidden enter-restricted)  ; Prohibition

In rules:

(normally r1 employee (must attend-meetings))
(normally r2 member (may access-library))

5.8 Using #lang spindle🔗ℹ

Create .spl files with the #lang spindle directive:

"theory.spl"

#lang spindle
 
(given bird)
(given penguin)
(normally r1 bird flies)
(normally r2 penguin (not flies))
(prefer r2 r1)

Then use in Racket:

(require "theory.spl")
(spindle-conclusions)

5.9 Programmatic Use🔗ℹ

(require spindle/lang)
 
(define conclusions
  (reason-spl-string
   "(given bird)\n    (normally r1 bird flies)"))
 
 
(reason-spl-file "theory.spl")

5.10 Complete Example🔗ℹ

#lang spindle
 
; Medical diagnosis example
 
; Patient symptoms
(given has-fever)
(given has-cough)
(given has-rash)
 
; Diagnostic rules
(normally r1 (has-fever has-cough) has-flu)
(normally r2 (has-fever has-rash) has-measles)
(normally r3 has-measles (not has-flu))
 
; Measles is more specific diagnosis
(prefer r3 r1)

5.11 SPL vs DFL Comparison🔗ℹ

Concept

  

DFL

  

SPL

Fact

  

>> bird

  

(given bird)

Strict rule

  

r1: a -> b

  

(always r1 a b)

Defeasible

  

r1: a => b

  

(normally r1 a b)

Defeater

  

d1: a ~> b

  

(except d1 a b)

Negation

  

¬a

  

(not a)

Superiority

  

r2 > r1

  

(prefer r2 r1)