If you have to spend some time working on this, it is worth installing at least Quicklisp and Slime, following this tutorial:
https://lisp-lang.org/learn/getting-started/
You can however start with only the interpreter. You need to install sbcl
, and I recommend having rlwrap
too because SBCL prompt does not have fancy readline features.
$ rlwrap sbcl
Then, you'll be in a Lisp REPL. Execute this to ensure the code is compiled with the maximum level of debugging:
* (sb-ext:restrict-compiler-policy 'debug 3)
The environment should reply with:
((DEBUG . 3))
NIL
Then, you can compile your input file (use an absolute path, or a path relative to the directory where you stared sbcl):
* (compile-file "/tmp/concepts")
A lot of text will be emitted, but the interpreter replies with the name of the object file being produced (e.g. "/tmp/concepts.fasl"), you can load it by supplying *
as an argument, since the asterisk means the last result.
* (load *)
Following the comments in the file (between #|
and |#
), you can test it as follows:
* (test-concepts shepard)
This performs a lot of tests.
You can trace individual functions if you want with (trace X Y Z)
where X
, Y
and Z
are function names (you can also untrace
them).
To simplify, here is a list where all (I think) symbols described in the comments are traced:
(trace frequency-of-properties
frequency-of-pairs
count-of-n
simplify-eight
remove-non-minimals
replace-lis-in-concept
print-linear-models
simplify-quads
make-master-list
make-pairs-for-quads
find-pair-quads
memberprop-lis
max-length
count-of-n
frequency-of-pairs
find-pairs-that-simplify
find-pair-to-simplify
remove-non-minimals
triples
three-pairs
simplify-by-mates
doubles
co
remove-non-minimals
replace-lis-in-concept
simplify-by-mates
singles
remove-non-minimals
replace-lis-in-concept
simplify-by-mates
print-linear-models
simplify-by-mates)
Using the same test as above, the last test prints the following trace:
Problem 6 0: (PRINT-LINEAR-MODELS (((A) (B) (- C)) ((A) (- B) (C)) ((- A) (B) (C)) ((- A) (- B) (- C))))
AB-C A-BC -ABC -A-B-C
0: PRINT-LINEAR-MODELS returned NIL
0: (FREQUENCY-OF-PROPERTIES (((A) (B) (- C)) ((A) (- B) (C)) ((- A) (B) (C)) ((- A) (- B) (- C))))
0: FREQUENCY-OF-PROPERTIES returned
((((A)) 2) (((B)) 2) (((- C)) 2) (((- B)) 2) (((C)) 2) (((- A)) 2))
0: (COUNT-OF-N ((((A)) 2) (((B)) 2) (((- C)) 2) (((- B)) 2) (((C)) 2) (((- A)) 2)) 4)
1: (COUNT-OF-N ((((B)) 2) (((- C)) 2) (((- B)) 2) (((C)) 2) (((- A)) 2)) 4)
2: (COUNT-OF-N ((((- C)) 2) (((- B)) 2) (((C)) 2) (((- A)) 2)) 4)
3: (COUNT-OF-N ((((- B)) 2) (((C)) 2) (((- A)) 2)) 4)
4: (COUNT-OF-N ((((C)) 2) (((- A)) 2)) 4)
5: (COUNT-OF-N ((((- A)) 2)) 4)
6: (COUNT-OF-N NIL 4)
6: COUNT-OF-N returned NIL
5: COUNT-OF-N returned NIL
4: COUNT-OF-N returned NIL
3: COUNT-OF-N returned NIL
2: COUNT-OF-N returned NIL
1: COUNT-OF-N returned NIL
0: COUNT-OF-N returned NIL
0: (SIMPLIFY-BY-MATES (((A) (B) (- C)) ((A) (- B) (C)) ((- A) (B) (C)) ((- A) (- B) (- C))))
1: (MAX-LENGTH (((A) (B) (- C)) ((A) (- B) (C)) ((- A) (B) (C)) ((- A) (- B) (- C))))
2: (MAX-LENGTH (((A) (- B) (C)) ((- A) (B) (C)) ((- A) (- B) (- C))) 3)
3: (MAX-LENGTH (((- A) (B) (C)) ((- A) (- B) (- C))) 3)
4: (MAX-LENGTH (((- A) (- B) (- C))) 3)
5: (MAX-LENGTH NIL 3)
5: MAX-LENGTH returned 3
4: MAX-LENGTH returned 3
3: MAX-LENGTH returned 3
2: MAX-LENGTH returned 3
1: MAX-LENGTH returned 3
0: SIMPLIFY-BY-MATES returned NIL
No simplification possible. Number of models 4
This should give a better understanding of what is happening.
You can also use (step (test shepard))
, in which case the execution breaks in the debugger; use help
to have more information about the commands you can invoke. For example you can write STEP
(or just S
) to step into an expression, NEXT
to skip over an expression and go to the next one, OUT
to step out of the current frame, etc.