3 Core API Reference
| (require spindle) | package: spindle |
This section documents the core Spindle API for defeasible logic reasoning.
3.1 Literals
Literals represent atomic propositions that can be true or false.
procedure
(simple-literal name) → literal?
name : string?
(simple-literal "bird")
procedure
(negated-literal name) → literal?
name : string?
(negated-literal "flies")
procedure
(literal-name lit) → string?
lit : literal?
procedure
(literal->string lit) → string?
lit : literal?
3.2 Rules
Rules define how conclusions are derived from premises.
value
value
value
value
(make-fact "f1" (simple-literal "bird"))
procedure
(simple-rule label type body head) → rule?
label : string? type : symbol? body : (listof literal?) head : (listof literal?)
(simple-rule "r1" RULE-TYPE-DEFEASIBLE (list (simple-literal "bird")) (list (simple-literal "flies")))
procedure
(rule-label r) → string?
r : rule?
procedure
(rule->string r) → string?
r : rule?
3.3 Theories
A theory is a collection of rules and superiority relations.
procedure
(empty-theory) → theory?
procedure
(theory-add-rule th r) → theory?
th : theory? r : rule?
procedure
(theory-add-superiority th superior inferior) → theory? th : theory? superior : string? inferior : string?
procedure
(theory-all-rules th) → (listof rule?)
th : theory?
procedure
(theory-superiorities th) → (listof superiority?)
th : theory?
3.4 Reasoning
The reasoning engine derives conclusions from a theory.
procedure
(reason th) → (listof conclusion?)
th : theory?
(define conclusions (reason my-theory)) (for ([c conclusions]) (displayln (conclusion->string c)))
procedure
(reason-with-explanations th) → (listof conclusion?)
th : theory?
3.5 Conclusions
Conclusions represent the results of reasoning.
procedure
(conclusion? v) → boolean?
v : any/c
procedure
(conclusion-type c) → symbol?
c : conclusion?
procedure
(conclusion-literal c) → literal?
c : conclusion?
procedure
(conclusion->string c) → string?
c : conclusion?
3.6 Parsing
(define-values (ast errors) (parse-dfl-string ">> bird\nr1: bird => flies")) (when (null? errors) (displayln "Parse successful!"))
procedure
(parse-dfl-file path) →
any/c (listof any/c) path : path-string?