Stefan Brass
This page is currently being written. Please look again at it in a few weeks/months.
...
The following is a legal input program:
% Note that all atoms must start with a lower case letter (as in Prolog).
visit(australia) v visit(europe).
happy <- visit(australia) v visit(europe).
bankrupt <- visit(australia) & visit(europe).
prudent <- not(visit(australia) & visit(europe)).
disappointed <- not visit(australia) & not visit(europe).
%
"
and reach to the end of the line.
_
"
is acceptable within the atom
(but not as the first letter).
There are two exceptions:
"not
" and "v
" are reserved words
and cannot be used as an atoms.
Atoms can also be written as 'xxx'
where xxx
is a sequence of arbitrary characters
except newline (and "'
").
However,
xxx
may not be the empty string
(i.e. "''
" is illegal).
Note that
abc
and 'abc'
are treated
as identical atoms.
However,
when the reserved words are quoted,
they can be used as ordinary atoms.
-
".
The maximal allowed integer is 65535,
the minimal integer is -65536
(i.e. integers are 16 bit).
_
")
is treated like an uppercase letter,
so it is acceptable everywhere within the variable.
However,
the token consisting of a single underscore
is treated special:
Every occurrence denotes a new variable
("anonymous variable" like in Prolog).
&
"
or as ",
".
|
".
The notation ";
" is also understood.
For compatibility reasons,
also "v
" is still accepted.
<-
".
The Prolog notation ":-
" is also accepted.
->
".
<->
".
~
".
Note that this is real classical negation,
and not default negation.
not
".
(
" and ")
")
are also understood.
.
".
It is required (as in Prolog) that the fullstop
is followed by white space (usually a newline).
An atomic formula (positive literal)
consists of a predicate and an optional argument list.
If no argument list is used,
the predicate is called a proposition.
For instance,
visit(X,europe)
or the_sun_shines
would be atomic formulas.
The second one is a proposition.
A predicate or proposition is an atom, i.e. a word beginning with a lowercase letter.
An argument consists of a left parenthesis '(', a list of terms separated by commas, and a right parenthesis ')'.
A term can be a constant or a variable. There are currently two kinds of constants:
xyz
,
which is a symbolic constant
(like an element of an enumeration type).
One can also use quoted atoms,
e.g. 'quoted atom!'
.
For all practical purposes,
these are string constants.
64
or -4
.
_
.
Therefore it is called the anonymous variable.
The following logical operators can be used in formulas:
Name | Notation | Alternatives | Priority | Associativity |
---|---|---|---|---|
Classical Negation | ~ | 1 | right associative | |
Default Negation | not | 1 | nesting is forbidden | |
Conjunction (and) | & | , (comma) | 2 | right associative |
Disjunction (or) | | | ; (semicolon) v | 3 | right associative |
Implication from left to right (then) | -> | 4 | not associative | |
Implication from right to left (if) | <- | :- | 4 | not associative |
Equivalence (if and only if) | <-> | 4 | not associative |
The priorities mean that
e.g. p & q | r
is parsed as (p & q) | r
.
I.e. conjunction binds stronger than disjunction,
or conjunction has precedence over disjunction.
The two negations bind strongest,
and the three implications bind weakest.
If the priorities do not give the right structure
or if one wants to be very clear,
one can always use parentheses.
The associativity means that
e.g. p & q & r
is parsed as p & (q & r)
.
If if were left associative,
it would be parsed as
e.g. (p & q) & r
.
But this distinction is logically not important
(is conjunction is associative after all).
The implications are declared as not associative,
so e.g. p -> q -> r
would be a syntax error.
The reason is that here it would make a difference whether one writes
(p -> q) -> r
or p -> (q -> r)
.
One has to decide for one of the two alternatives
and use parentheses.
In super logic programs, there are three restrictions for the use of default negation:
&
)
and disjunction (|
) can be used,
but not negation (~
)
or implication (->
, <-
, <->
).
~
,
on the left side of ->
,
or on the right side of <-
.
Note however
that two negations cancel out.
It is important for the deduction algorithm that derived conditional facts are ground. Therefore all variables must be bound in a positive body literal. Again, this condition has to be satisfied only after the transformation into clauses.
For anonymous variables, the rules are very simple (since every occurrence must be binding): Anonymous variables cannot be used in head literals (i.e. atomic formulas in positive context) and they cannot be used in default negation literals.
There are four possible sources for input:
slp
was compiled in CGI-Mode,
slp
can be called with an argument in the form
http://www.informatik.uni-giessen.de/db-cgi/slp?visit,
in which case it reads the super logic program from the file
visit
in a specified directory (VER_CGI_EXDIR
)
on the server machine.
Since such things are potentially dangerous,
the argument must be a sequences of lowercase letters
(or "_
")
of length at most 8.
slp
was compiled in CGI-Mode,
but there is no command line argument,
slp
reads the super logic
program from the standard input
(according to the CGI-specification for the POST-method).
slp
was compiled normally,
and a file is specified on the command line,
the input is taken from this file.
In this case,
there are no restrictions on the possible file names.
slp
was compiled normally,
and no command line argument is given,
slp
reads the super logic program from standard input.