%	init.s

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Switches and counters for pretty printing
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Switch values are constants:

on isa constant.
off isa constant.

% Switches:

html isa switch.
double isa switch.

% Counters

display_columns isa counter.
display_position isa counter.

% To find switch values of all switches:
% (switches = switches`switch) where switches = switch`get_instances.
% Similarly, to find values of all counters:
% (counters = counters`count) where counters = counter`get_instances.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Switches for debugging
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

verbose isa switch.
trace isa switch.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	External predicates
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

make is external(result = nil).

about(_G2509) is external(module = objects, result = nil).
source(_G2509) is external(module = objects, result = nil).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Intrinsic functions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

shell(_G2509) is intrinsic.
confirm(_G2509) is intrinsic(result = boolean).
input(_G2509) is intrinsic.
print(_G2509) is intrinsic(result = nil).
format(_G2509) is intrinsic(result = nil).
format(_G2509, _G2510) is intrinsic(result = nil).
message(_G2509) is intrinsic(result = nil).
message(_G2509, _G2510) is intrinsic(result = nil).
banner(_G2509) is intrinsic(result = nil).
banner(_G2509, _G2510) is intrinsic(result = nil).
verbose(_G2509) is intrinsic(result = nil).
verbose(_G2509, _G2510) is intrinsic(result = nil).

seeing is intrinsic.
% gives file name of current input
telling is intrinsic.
% gives file name of current output

file_contents_to_string(_G2509) is intrinsic.

is_constant(_G2509) is intrinsic(module = gpas, result = boolean).
is_atom(_G2509) is intrinsic(module = gpas, result = boolean).
is_atomic(_G2509) is intrinsic(module = gpas, result = boolean).
is_number(_G2509) is intrinsic(module = gpas, result = boolean).
is_integer(_G2509) is intrinsic(module = gpas, result = boolean).
is_rational(_G2509) is intrinsic(module = gpas, result = boolean).
is_float(_G2509) is intrinsic(module = gpas, result = boolean).
is_string(_G2509) is intrinsic(module = gpas, result = boolean).
is_list(_G2509) is intrinsic(result = boolean).
is_op(_G2509) is intrinsic(module = gpas, result = boolean).

is_instance(_G2509) is intrinsic(result = boolean).

% The following infix operators have a high precedence (=998), so use brackets!

infix (instance_of) is intrinsic(result = boolean).
infix (parent_of) is intrinsic(result = boolean).
infix (isa) is intrinsic(result = boolean).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	GPAS Interface
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

postfix (transformations) is external(module = gpas, result = nil).
infix (=>) is external(module = gpas, result = nil).

normalize(_G2509, _G2510) is external(module = gpas, result = 2).
transform(_G2509, _G2510) is external(module = gpas, result = 2).
mode(_G2509, _G2510) is external(module = gpas, result = nil).
with(_G2509) is external(module = gpas, result = nil).
reload_rulebases is external(module = gpas, result = nil).
load_rulebase(_G2509) is external(module = gpas, result = nil).
about_rulebase(_G2509) is external(module = gpas, result = nil).
gpas_profile is external(module = gpas, result = nil).

remove_rules(_G2509) is external(module = gpas, result = nil).
about_rules(_G2509) is external(module = gpas, result = nil).
list_rules(_G2509) is external(module = gpas, result = nil).
trace_rules(_G2509) is external(module = gpas, result = nil).
notrace_rules(_G2509) is external(module = gpas, result = nil).

infix with is associative(grouping = left) has precedence(976).

Expr with Strategy := interpret(normalize(Expr, Strategy)).
Expr with [] := Expr.
Expr with [Rule | Rules] := interpret(normalize(Expr, [Rule | Rules])).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	LaTeX
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

latex_math isa switch.
latex_list isa switch.
latex_width isa counter.

latex_code isa switch.

latex_savebox_size isa counter.
latex_savebox_nest isa counter.
latex_max_subscripted_name_length isa counter.
latex_boxno_start isa counter.
latex_boxno isa counter.
latex_varno isa counter.

latex(_G2509) is intrinsic(module = (latex), result = nil).
latexm(_G2509) is intrinsic(module = (latex), result = nil).
view_latex(_G2509) is intrinsic(module = (latex), result = nil).
view_latex(_G2509, _G2510) is intrinsic(module = (latex), result = nil).
view_latexm(_G2509) is intrinsic(module = (latex), result = nil).
view_latexm(_G2509, _G2510) is intrinsic(module = (latex), result = nil).
view_latex_list(_G2509) is intrinsic(module = (latex), result = nil).
view_latex_list(_G2509, _G2510) is intrinsic(module = (latex), result = nil).
view_latexm_list(_G2509) is intrinsic(module = (latex), result = nil).
view_latexm_list(_G2509, _G2510) is intrinsic(module = (latex), result = nil).

latex_prolog_file(_G2509) is intrinsic(module = (latex), result = nil).
view_latex_prolog_file(_G2509) is intrinsic(module = (latex), result = nil).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Help
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

help := proc(message("~w", [file_contents_to_string("help.txt")])).
(help(X) :=
proc(( about(X)
; message("~nProlog information:")
; call(explain(X), nil)
; call(help(X), nil)
)))
.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% main := proc(banner("Welcome to Ctadel written in SWI-Prolog")).