{ Logiweb, a system for electronic distribution of mathematics Copyright (C) 2004 Klaus Grue This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 021111307 USA Contact: Klaus Grue, DIKU, Universitetsparken 1, DK2100 Copenhagen, Denmark, grue@diku.dk, http://yoa.dk/, http://www.diku.dk/~grue/ Logiweb is a system for distribution of mathematical definitions, lemmas, and proofs. For more on Logiweb, consult http://yoa.dk/. } {This file is an example of a pyk source file. Pyk is a language for expressing mathematics in a seminatural style. The name "pyk" is constructed from the name "Volapyk" in the same way that Rene Thom construct the word "versal" from "universal": "pyk" is constructed by removing "Vola" from "Volapyk". Volapyk was an artificial language constructed from several other languages by simplifying their words and their grammar. As an example, the name of the language itself is constructed from "Vola" which is a simplification of "World" and "pyk" which is a simplification of "speak". The pyk language used below may be used for "spoken mathematics" and may, among other, be entered through a microphone when editing mathematical text. The pyk languages comes to its full right in the BODY section at the end of this file. The other sections requires the speaker to be able to pronounce commas, asterisks, and several other signs, and to distinguish between words in capital (section headers) from other words. A pyk file has exactly one PAGE section, exactly one BIBLIOGRAPHY section, zero, one or more PREASSOCIATIVITY and POSTASSOCIATIVITY sections, and exactly one BODY section in exactly that order (except that associativity sections may be mixed freely among each other). Text in braces and text after semicolon are comments. Have fun.} {A pyk file defines precisely one 'Logiweb page' of mathematics. A Logiweb page is similar to a World Wide Web page. A Logiweb page can be anything from a small note to an encyclopedia of mathematics. The PAGE section gives a name to the page.} PAGE base {Now our page has the name "base". Names can be composed of small letters from the English alphabet (Unicode 97 to 122, inclusive) and space characters (Unicode 32). The next thing to do is to declare a bibliography. A bibliography is a list of pages that are already posted to Logiweb. The present base page refers to no other pages, so the bibliography is empty. We indicate that by writing BIBLIOGRAPHY followed by no bibliographic entries.} BIBLIOGRAPHY {Now we have to declare which constructs we are going to use and, for each construct, we must declare whether they are 'pre-' or 'postassociative'. A preassociative construct is leftassociative in text that runs left to right, rightassociative in text that runs right to left, topassociative in text that runs from top to bottom, counter-clock-wise-associative in text written in spirals, and so on. Pyk files run left to right, but the pages generated from them may run in any conceivable direction. All constructs mentioned in a single associativity section have the same priority, so associativity sections also affect priorities. All constructs defined on the page (except the name of the page) have to be mentioned exactly once in the associativity sections. Constructs that come from other pages (pages mentioned in the bibliography) are not allowed to occur in the associativity sections. (Technicality: Actually, it is the other way round. Constructs mentioned in associativity sections are considered local and shadow symbols with the same name on other pages).} PREASSOCIATIVE bracket * end bracket, big bracket * end bracket, math * end math, flush left * end left, var x, var y, var z, 1 proclaim * as * end proclaim, define * of * as * end define, pyk, tex, tex name, priority, 11 x, true, if * then * else * end if, introduce * of * as * end introduce, value, claim, bottom, function f of * end function, identity * end identity, false, untagged zero, untagged one, untagged two, untagged three, untagged four, untagged five, untagged six, untagged seven, untagged eight, untagged nine, zero, one, two, three, four, five, six, seven, eight, nine, var a, var b, var c, var d, var e, var f, var g, var h, var i, var j, var k, var l, var m, var n, var o, var p, var q, var r, var s, var t, var u, var v, var w, tagged parenthesis * end tagged, tagged if * then * else * end if, array * is * end array, left, center, right, empty, substitute * set * to * end substitute, map tag * end tag, raw map untag * end untag, map untag * end untag, normalizing untag * end untag, apply * to * end apply, apply one * to * end apply, identifier * end identifier, identifier one * plus id * end identifier, array plus * and * end plus, array remove * array * level * end remove, array put * value * array * level * end put, array add * value * index * value * level * end add, bit * of * end bit, bit one * of * end bit, example rack, vector hook, bibliography hook, dictionary hook, body hook, codex hook, expansion hook, code hook, cache hook, diagnose hook, pyk aspect, tex aspect, texname aspect, value aspect, message aspect, macro aspect, definition aspect, unpack aspect, claim aspect, priority aspect, lambda identifier, apply identifier, true identifier, if identifier, quote identifier, proclaim identifier, define identifier, introduce identifier, hide identifier, pre identifier, post identifier, eval * stack * cache * end eval, eval two * ref * id * stack * cache * end eval, eval three * function * stack * cache * end eval, eval four * arguments * stack * cache * end eval, lookup * stack * default * end lookup, abstract * term * stack * cache * end abstract, quote * end quote, expand * state * cache * end expand, expand two * definition * state * cache * end expand, expand list * state * cache * end expand, macro, macro state, zip * with * end zip, assoc one * address * index * end assoc, protect * end protect, self, macro define * as * end define, value define * as * end define, intro define * as * end define, pyk define * as * end define, tex define * as * end define, tex name define * as * end define, priority table * end table, macro define one, macro define two * end define, macro define three * end define, macro define four * state * cache * definition * end define, state expand * state * cache * end expand, quote expand * term * stack * end expand, quote expand two * term * stack * end expand, quote expand three * term * stack * value * end expand, quote expand star * term * stack * end expand, parenthesis * end parenthesis, big parenthesis * end parenthesis, display * end display, statement * end statement, spying test * end test, false spying test * end test, aspect * subcodex * end aspect, aspect * term * cache * end aspect, tuple * end tuple, tuple one * end tuple, tuple two * end tuple, let two * apply * end let, let one * apply * end let, claim define * as * end define, checker, check * cache * end check, check two * cache * def * end check, check three * cache * def * end check, check list * cache * end check, check list two * cache * value * end check, test * end test, false test * end test, raw test * end test, message, message define * as * end define, the statement aspect, statement, statement define * as * end define, example axiom, example scheme, example rule, absurdity, contraexample, example theory primed, example lemma, metavar * end metavar, meta a, meta b, meta c, meta d, meta e, meta f, meta g, meta h, meta i, meta j, meta k, meta l, meta m, meta n, meta o, meta p, meta q, meta r, meta s, meta t, meta u, meta v, meta w, meta x, meta y, meta z, sub * set * to * end sub, sub star * set * to * end sub, the empty set, example remainder, make visible * end visible, intro * index * pyk * tex * end intro, intro * pyk * tex * end intro, error * term * end error, error two * term * end error, proof * term * cache * end proof, proof two * term * end proof, sequent eval * term * end eval, seqeval init * term * end eval, seqeval modus * term * end eval, seqeval modus one * term * sequent * end eval, seqeval verify * term * end eval, seqeval verify one * term * sequent * end eval, sequent eval plus * term * end eval, seqeval plus one * term * sequent * end eval, seqeval minus * term * end eval, seqeval minus one * term * sequent * end eval, seqeval deref * term * end eval, seqeval deref one * term * sequent * end eval, seqeval deref two * term * sequent * def * end eval, seqeval at * term * end eval, seqeval at one * term * sequent * end eval, seqeval infer * term * end eval, seqeval infer one * term * premise * sequent * end eval, seqeval endorse * term * end eval, seqeval endorse one * term * side * sequent * end eval, seqeval est * term * end eval, seqeval est one * term * name * sequent * end eval, seqeval est two * term * name * sequent * def * end eval, seqeval all * term * end eval, seqeval all one * term * variable * sequent * end eval, seqeval cut * term * end eval, seqeval cut one * term * forerunner * end eval, seqeval cut two * term * forerunner * sequent * end eval, computably true * end true, claims * cache * ref * end claims, claims two * cache * ref * end claims, the proof aspect, proof, lemma * says * end lemma, proof of * reads * end proof, in theory * lemma * says * end lemma, in theory * antilemma * says * end antilemma, in theory * rule * says * end rule, in theory * antirule * says * end antirule, verifier, verify one * end verify, verify two * proofs * end verify, verify three * ref * sequents * diagnose * end verify, verify four * premises * end verify, verify five * ref * array * sequents * end verify, verify six * ref * list * sequents * end verify, verify seven * ref * id * sequents * end verify, cut * and * end cut, head * end head, tail * end tail, rule one * theory * end rule, rule * subcodex * end rule, rule tactic, plus * and * end plus, theory * end theory, theory two * cache * end theory, theory three * name * end theory, theory four * name * sum * end theory, example axiom lemma primed, example scheme lemma primed, example rule lemma primed, contraexample lemma primed, example axiom lemma, example scheme lemma, example rule lemma, contraexample lemma, example theory, ragged right, ragged right expansion, parameter term * stack * seed * end parameter, parameter term star * stack * seed * end parameter, instantiate * with * end instantiate, instantiate star * with * end instantiate, occur * in * substitution * end occur, occur star * in * substitution * end occur, unify * with * substitution * end unify, unify star * with * substitution * end unify, unify two * with * substitution * end unify, ell a, ell b, ell c, ell d, ell e, ell f, ell g, ell h, ell i, ell j, ell k, ell l, ell m, ell n, ell o, ell p, ell q, ell r, ell s, ell t, ell u, ell v, ell w, ell x, ell y, ell z, ell big a, ell big b, ell big c, ell big d, ell big e, ell big f, ell big g, ell big h, ell big i, ell big j, ell big k, ell big l, ell big m, ell big n, ell big o, ell big p, ell big q, ell big r, ell big s, ell big t, ell big u, ell big v, ell big w, ell big x, ell big y, ell big z, ell dummy, sequent reflexivity, tactic reflexivity, sequent commutativity, tactic commutativity, the tactic aspect, tactic, tactic define * as * end define, proof expand * state * cache * end expand, proof expand list * state * cache * end expand, proof state, conclude one * cache * end conclude, conclude two * proves * cache * end conclude, conclude three * proves * lemma * substitution * end conclude, conclude four * lemma * end conclude {Now we have declared quite some constructs such as "var x" and "define * of * as * end define". A sequence of spaces (i.e. space characters, newline characters, and comments) in a name counts as a single space. Hence "var x" and "var ;this a comment x" denote the same construct. Spaces at the start and end of a name are ignored so that "var x" and " var x " denote the same construct. Spaces around asterisks are also ignored so that "define * of * as * end define" and "define*of*as*end define" denote the same construct. An entry like "var x" in a pre- or postassociativity section actually declares two constructs. Firstly, the entry declares the "unqualified" construct "var x" itself. Secondly, the entry declares a "page qualified" construct which consists of the page name appended to a space character appended to the unqualified construct. Hence, the entry "var x" above declares two constructs, namely "var x" itself together with the page qualified construct "base var x". "var x" and "base var x" denote the same construct. If two pages, say "base" and "ground", both declare a construct named "var x", then the "var x" construct of the base page is different from the "var x" construct of the ground page. If the ground page refers to the base page, then one cannot refer to any of the two constructs as "var x" in the pyk source of the ground page. Rather, one can refer to the two constructs as "base var x" and "ground var x", respectively. In rare cases, page qualified constructs may cause ambiguity. If you define the constructs "var x" and "base var x" explicitly on a page named "base", then you may run into trouble: The "var x" construct gives rise to two constructs, "var x" and "base var x", and "base var x" gives rise to "base var x" and "base base var x". That is no problem as long as you only use "var x" and "base base var x" since they are unambiguous, but if you use "base var x" then the Pyk compiler will complain because it cannot tell which "base var x" you mean. The page name itself may be page qualified, so "base base" denotes the same construct as "base". But one cannot qualify a construct with a page qualified page name, so the sections above do not declare a "base base base" or "base base var x" construct. Every construct of every page has an "id" which is a cardinal (a nonnegative integer). Within each page, the id identifies the construct uniquely. The construct that names the page itself always has an id of zero. On the present page that means that the "base" construct has id zero. The page version "base base" also has id zero since it is actually the same construct in disguise. In most situations, the user can leave it to the pyk compile to assign ids to constructs. If the user needs to control the id of a construct, however, the user may simply write the id in front of the declaration of the construct. As an example, the construct "proclaim * as * end proclaim" above is prefixed by "1" which ensures that that particular construct gets an id of 1. One may number constructs freely except that the page construct is forced to have an id of zero. All the constructs above are 'closed' in the sence that they neither start nor end with an asterisk. Priority and associativity has no effect on closed constructs, but one still has to list all constructs of the page in associativity sections. Now let us move on.} PREASSOCIATIVE * sub * end sub, * intro * index * pyk * tex * end intro, * intro * pyk * tex * end intro, * intro * index * pyk * tex * name * end intro, * intro * pyk * tex * name * end intro, * prime, * assoc * end assoc, * set * to * end set, * set multi * to * end set, * bit nil, * bit one, binary, * color * end color, * color star * end color, * raw head, * raw tail, * cardinal untag, * head, * tail, * is singular, * is cardinal, * is data, * is atomic, * cardinal retract, * tagged retract, * boolean retract, * ref, * id, * debug, * root, * zeroth, * first, * second, * third, * fourth, * fifth, * sixth, * seventh, * eighth, * ninth, * is error, * is metavar, * is metaclosed, * is metaclosed star PREASSOCIATIVE 2 unicode start of text * end unicode text, 3 unicode end of text, 12 text * end text, 13 text * plus *, 14 text * plus indent *, 10 unicode newline *, 32 unicode space *, 33 unicode exclamation mark *, 34 unicode quotation mark *, 35 unicode number sign *, 36 unicode dollar sign *, 37 unicode percent *, 38 unicode ampersand *, 39 unicode apostrophe *, 40 unicode left parenthesis *, 41 unicode right parenthesis *, 42 unicode asterisk *, 43 unicode plus sign *, 44 unicode comma *, 45 unicode hyphen *, 46 unicode period *, 47 unicode slash *, 48 unicode zero *, 49 unicode one *, 50 unicode two *, 51 unicode three *, 52 unicode four *, 53 unicode five *, 54 unicode six *, 55 unicode seven *, 56 unicode eight *, 57 unicode nine *, 58 unicode colon *, 59 unicode semicolon *, 60 unicode less than *, 61 unicode equal sign *, 62 unicode greater than *, 63 unicode question mark *, 64 unicode commercial at *, 65 unicode capital a *, 66 unicode capital b *, 67 unicode capital c *, 68 unicode capital d *, 69 unicode capital e *, 70 unicode capital f *, 71 unicode capital g *, 72 unicode capital h *, 73 unicode capital i *, 74 unicode capital j *, 75 unicode capital k *, 76 unicode capital l *, 77 unicode capital m *, 78 unicode capital n *, 79 unicode capital o *, 80 unicode capital p *, 81 unicode capital q *, 82 unicode capital r *, 83 unicode capital s *, 84 unicode capital t *, 85 unicode capital u *, 86 unicode capital v *, 87 unicode capital w *, 88 unicode capital x *, 89 unicode capital y *, 90 unicode capital z *, 91 unicode left bracket *, 92 unicode backslash *, 93 unicode right bracket *, 94 unicode circumflex *, 95 unicode underscore *, 96 unicode grave accent *, 97 unicode small a *, 98 unicode small b *, 99 unicode small c *, 100 unicode small d *, 101 unicode small e *, 102 unicode small f *, 103 unicode small g *, 104 unicode small h *, 105 unicode small i *, 106 unicode small j *, 107 unicode small k *, 108 unicode small l *, 109 unicode small m *, 110 unicode small n *, 111 unicode small o *, 112 unicode small p *, 113 unicode small q *, 114 unicode small r *, 115 unicode small s *, 116 unicode small t *, 117 unicode small u *, 118 unicode small v *, 119 unicode small w *, 120 unicode small x *, 121 unicode small y *, 122 unicode small z *, 123 unicode left brace *, 124 unicode vertical line *, 125 unicode right brace *, 126 unicode tilde *, 6 preassociative * greater than *, 7 postassociative * greater than *, 8 priority * equal *, 9 priority * end priority, newline *, macro newline * {Now we have declared constructs like "* sub * end sub" which are 'suffix' in the sense that they start with an asterisk and end with a letter. We have also declared constructs like "newline *" which are 'prefix' in the sense that they start with a letter and end with an asterisk. The order of associativity sections indicates the priority of each construct. All constructs in the same associativity section have the same priority whereas constructs in one associativity section have higher priority than all constructs in the following associativity sections. As an example, "* sub * end sub" has higher priority than "newline *". Priority (and, sometimes, associativity) affects such constructs. As an example, "newline var x sub newline var y end sub" is understood as "newline (var x sub (newline var y) end sub)". A construct is said to be 'preopen' if it starts with an asterisk and to be 'preclosed' otherwise. Likewise, a construct is 'postopen' and 'postclosed' if it does and doesn't end with an asterisk, respectively. A construct is - closed if it is pre- and postclosed - prefix if it is preclosed and postopen - suffix if it is preopen and postclosed - open if it is pre- and postopen Here are some examples: parenthesis * end: preclosed, postclosed, closed. * apply *: preopen, postopen, open. if * then * else *: preclosed, postopen, prefix. * factorial: preopen, postclosed, suffix. The four constructs above are not necessarily declared on this page; they are just mentioned for the example. As with other constructs, the declaration of "* sub * end sub" also declares a page qualified construct, but since "* sub * end sub" is preopen, the page name is added after the first asterisk. Hence, the page qualified version of "* sub * end sub" is "* base sub * end sub". In general, a page qualified construct is preopen, preclosed, postopen, and postclosed iff the construct itself is preopen, preclosed, postopen, and postclosed, respectively. Two particular strings are considered to be invalid names, namely the empty string "" and the "recursive" string "*". Applying the rules above to these two strings is senseless. The associativity has no effect as long as one merely mixes prefix constructs, but does have effect when mixing prefix and suffix constructs or does mix with open constructs. As an example, if "not *", "* apply *", and "* factorial" have the same priority then "not var x apply var x factorial" reads "((not var x) apply var x) factorial" if the constructs are preassociative and reads "not (var x apply (var x factorial))" if the constructs are postassociative. Pyk requires constructs that have the same priority to have the same associativity as well. Most of the constructs above are intended for forming strings. As an example, consider the following expression: unicode small a unicode small b unicode small c unicode end of text The structure of the expression is: unicode small a (unicode small b (unicode small c (unicode end of text))) When read from left to right, the id's of the constructs are 97, 98, 99, and 3. By Logiweb convention, id's from 0 to 9 and from 11 to 31 should be ignored in strings, so the number 3 above should be ignored. What is left is the sequence 97, 98, 99 which happens to be the unicode codes for a small a, b, and c, respectively. For that reason, unicode small a unicode small b unicode small c unicode end of text represents the string "abc". A term like text unicode start of text unicode small a unicode small b unicode small c unicode end of text end unicode text end text also denotes the string "abc" because the "text * end text", "unicode start of text * end unicode text", and "unicode end of text" all have id's that are ignored in text. A term like text unicode start of text unicode small a unicode small b unicode end of text end unicode text plus text unicode start of text unicode small c unicode end of text end unicode text end text also denotes the string "abc". This is so because if one scans the text left to right (or scans the associated parse tree root to leaf, left to right) then one encounters the id's 7, 2, 97, 98, 3, 6, 99, 3 in that order. Ignoring numbers from 0 to 9 and from 11 to 31 leaves one with the sequence 97, 98, 99 which represents "abc". The pyk compiler allows to express mathematics using the small letters from a to z plus spaces. To support natural language, at least at the early stages of the development of Logiweb, the pyk compiler also has support for strings. The pyk compiler translates a string like "abc" into unicode start of text unicode small a unicode small b unicode small c unicode end of text end unicode text which, as we have seen, represents the string "abc". Constructs with ids from 97 to 122 (unicode a to unicode z) are used for certain idenfitifiers during bootstrap of the Logiweb system. 'Bootstrapping' simply means loading a base page, where a base page is a page whose bibliography is empty. As an example, if one declares a construct like lambda * dot * then one may connect that construct with the concept of lambda abstraction by a proclamation like proclaim lambda var x dot var y as text unicode start of text unicode small l unicode small a unicode small m unicode small b unicode small d unicode small a unicode end of text end unicode text end text end proclaim When loading a page, Logiweb will recognize a statement like the one above as a proclamation because "proclaim * end proclaim" is a construct whose id is one and which belongs to a base page. The string "lambda" happens to be the string that identifies the concept of lambda abstraction in Logiweb. Some further constructs:} PREASSOCIATIVE * apply *, * tagged apply * PREASSOCIATIVE * times *, * times zero * PREASSOCIATIVE * plus *, * plus zero *, * plus one *, * minus *, * minus zero *, * minus one * PREASSOCIATIVE * term plus * end plus, * term union *, * term minus * end minus POSTASSOCIATIVE * raw pair *, * eager pair *, * tagged pair *, * untagged double *, * pair *, * double * POSTASSOCIATIVE * comma * PREASSOCIATIVE * boolean equal *, * data equal *, * cardinal equal *, * peano equal *, * tagged equal *, * math equal *, * reduce to *, * term equal *, * term list equal *, * term root equal *, * term in *, * term subset *, * term set equal *, * sequent equal *, * free in *, * free in star *, * free for * in *, * free for star * in *, * claim in *, * less *, * less zero *, * less one * PREASSOCIATIVE not * PREASSOCIATIVE * and *, * macro and *, * simple and *, * claim and * PREASSOCIATIVE * or *, * parallel *, * macro or * POSTASSOCIATIVE * macro imply * POSTASSOCIATIVE * guard *, * spy *, * tagged guard * PREASSOCIATIVE * select * else * end select PREASSOCIATIVE lambda * dot *, tagged lambda * dot *, tagging *, open if * then * else *, let * be * in *, let * abbreviate * in * PREASSOCIATIVE * init, * modus, * verify, * curry plus, * curry minus, * dereference PREASSOCIATIVE * at *, * modus ponens *, * modus probans *, * conclude * POSTASSOCIATIVE * infer *, * endorse *, * id est * PREASSOCIATIVE all * indeed * POSTASSOCIATIVE * rule plus * POSTASSOCIATIVE * cut * PREASSOCIATIVE * proves * PREASSOCIATIVE * proof of * reads *, line * because * indeed * end line *, because * indeed * qed, line * premise * end line *, line * side condition * end line *, arbitrary * end line *, locally define * as * end line * POSTASSOCIATIVE 4 * then *, 5 * begin * end * {The pyk compiler translates a construct like "abc"[ var x sub var y end sub ]"def" into unicode start of text unicode small a unicode small b unicode asmll c unicode end of text end unicode text begin var x sub var y end sub end unicode start of text unicode small d unicode small e unicode asmll f unicode end of text end unicode text More precisely, the pyk compiler translates ..."[...]"... into a construct with and id of five. For completeness we mention, that the pyk compiler translates a comma into a construct with an id of four so that e.g. "abc "[ bracket var x, "\cdots", var y end bracket ]" def" translates into unicode start of text unicode small a unicode small b unicode asmll c unicode space unicode end of text end unicode text begin bracket var x then unicode start of text unicode backslash unicode small c unicode small d unicode asmll o unicode asmll t unicode asmll s unicode end of text end unicode text then var y end bracket end unicode start of text unicode space unicode small d unicode small e unicode asmll f unicode end of text end unicode text} PREASSOCIATIVE * tab * PREASSOCIATIVE * row * {Now all constructs are declared and have received an associativity and a priority so we are in position to write the contents of the page:} BODY "File page.tex \documentclass [fleqn]{article} \setlength {\overfullrule }{1mm} \input{lgwinclude} \usepackage{latexsym} %\setlength{\parindent}{0em} %\setlength{\parskip}{1ex} % The font of each Logiweb construct is under tight control except that % strings are typeset in whatever font is in effect at the time of % typesetting. This is done to enhance the readability of strings in the % TeX source generated by Logiweb. The default font for typesetting % strings is \rm: \everymath{\rm} \usepackage{makeidx} \usepackage{page} \makeindex \newcommand{\intro}[1]{\emph{#1}} \newcommand{\indexintro}[1]{\index{#1}\intro{#1}} \newcommand{\indexintros}[2]{\index{#1}\intro{#1#2}} \newlength{\bracketwidth} \settowidth{\bracketwidth}{$[{}$} \newcommand{\back}{\protect\makebox[-1.0\bracketwidth]{}} \usepackage[dvipdfm=true]{hyperref} \hypersetup{pdfpagemode=none} \hypersetup{pdfstartpage=1} \hypersetup{pdfstartview=FitBH} \hypersetup{pdfpagescrop={120 130 490 730}} \hypersetup{pdftitle=A Logiweb base page} \hypersetup{colorlinks=true} \bibliographystyle{plain} % \tex{something} writes something to page.otx for later inclusion \newwrite\outex \newtoks\toktex \immediate\openout\outex=page.otx \newcommand{\tex}[1]{\toktex={\item #1}\immediate\write\outex{\the\toktex}} % \test{something} writes something to page.tst for later inclusion \newwrite\outest \immediate\openout\outest=page.tst \newcommand{\test}[1]{\toktex={\item #1}\immediate\write\outest{\the\toktex}} % Concerning \catcode`\@=11 : See the TeXbook, Appendix B (page 344). % \afterheading suppresses indentation once, c.f. latex.ltx. % \display{something} displays something as a displayed equation except % that linebreaking is possible and displaymath is not turned on by default. % The first paragraph after \display{something} is unindented. % There may be too little space between a \display and a \section: The % definition of \display misses something like \addvspace{\belowdisplayskip}. \catcode`\@=11 \def\afterheading{\@afterheading} \catcode`\@=12 \newcommand{\display}[1]{\begin{list}{}{\setlength{\leftmargin}{\mathindent}} \item #1\end{list} \afterheading} \newcommand{\statement}[1]{\begin{list}{}{\setlength{\leftmargin}{0mm}} \item #1\end{list} \afterheading} % Save current \parindent. \newlength{\docparindent} \setlength{\docparindent}{\parindent} % To be included after each \section, \subsection, etc. when using % display * end display and statement * end statement \newcommand{\sect}[1]{\label{section:#1}\setlength{\parindent}{\docparindent}} \begin {document} \title{A Logiweb base page} \author{Klaus Grue} \maketitle \tableofcontents \section{Introduction} This is a Logiweb \indexintro{base page}\footnote{For the convenience of the reader, things that enter the index are in italics}. The Logiweb system \cite{Logiweb} is able to bootstrap using a page like the present one. Logiweb itself is a system for machine verification and distribution of formal mathematics. The base page contains quite a number of elementary definitions: \begin{itemize} \item On top of the Logiweb computing engine, the base page defines elementary operations on lists and cardinals (where \indexintro{cardinal} means \indexintro{natural number}). \item On top of the operations on lists and cardinals, the base page defines a macro expansion facility and a number of useful macros. \item On top of the operations on lists and cardinals, the base page defines a proof checker and a number of useful mathematical theories. \item Finally, the base page defines how to render the syntactic constructs defined on the page in the pyk and \TeX\ languages. \end{itemize} \subsection{The pyk language} From the point of view of Logiweb, the \indexintro{pyk} language is a source language. A user may express a Logiweb page in pyk and then run the pyk source through the pyk compiler to obtain a Logiweb page. A good way to learn the pyk language is to locate the pyk source of the present page and study it. The pyk source is likely to be in a file named ``base.pyk''. Plentiful comments in the pyk source explain what is going on. The name ``pyk'' is constructed from the name ``Volapyk'' in the same way that Rene Thom construct the word ``versal'' from ``universal'': ``pyk'' is constructed by removing ``Vola'' from ``Volapyk''. Volapyk was an artificial language constructed from several other languages by simplifying their words and their grammar. As an example, the name of the language itself is constructed from ``Vola'' which is a simplification of ``World'' and ``pyk'' which is a simplification of ``speak''. The pyk language may be used for ``spoken mathematics'' and may, among other, be entered through a microphone when editing mathematical text. The language is partly called ``pyk'' because of this speach aspect, partly because it looks like Volapyk in the other sense of that word. As an example, in a proper setup, the pyk phrase \begin{quote} parenthesis var x plus var y end parenthesis square equals var x square plus two times var x times var y plus var y square \end{quote} \noindent may correspond to the formula \[ ( x + y ) ^ 2 = x ^ 2 + 2 x y + y ^ 2 \] \subsection{The \TeX\ language} From the point of view of Logiweb, \TeX\ is an output format intended for the creation of beautiful Logiweb pages---and especially for Logiweb pages that contain a lot of mathematics (c.f.\ the preface of the \TeX book \cite{TeXbook}). The PDF version of the present page is produced by the \TeX\ system (including \LaTeX) and a program named dvipdfm. \TeX\ is chosen for this purpose because of the high quality and great maturity of that system. Early version of Logiweb also used MathML, but support for that was removed for several reasons, one of which was a desire to reduce the number of output formats to exactly one. One application of Logiweb could be straightforward translation of pyk to \TeX. A major purpose of Logiweb, however, is to allow the Logiweb system to understand the mathematics present on Logiweb pages. In particular, Logiweb is able to check proofs and execute programs defined on Logiweb pages. \subsection{The attributes of a Logiweb page} In general, a page has several attributes: \begin{description} \item[The reference]\index{reference} of a page is a cardinal that identifies the page. The reference of a page is world-wide unique. The Logiweb system includes Logiweb servers that can translate Logiweb references to Uniform Resource Locators (URLs) so that, having the reference of a page, one can locate the page without knowing which physical mirrors hold a copy of the page. \item[The vector]\index{vector} of a page is the sequence of bytes that encode the page when it is stored on disk or transmitted over a network. All attributes of a page, including the reference, can be computed from the vector. \item[The bibliography]\index{bibliography} of a page is a list of references to Logiweb pages. Entry number zero of the bibliography (i.e.\ the first element of the list of references) is the reference of the page itself. Appart from this self-reference, Logiweb pages and bibliographic references form a directed, acyclic graph. \item[The dictionary]\index{dictionary} of a page is a list of all concepts defined on the page. \item[The body]\index{body} of a page comprises all the text and definitions of the page. When a user wants to read a Logiweb page, the system renders the body of the page using the \TeX\ system and shows that to the user. What you read right now is such a rendering. % (Unless you are reading the pyk or tex sources, of course :-) \item[The expansion]\index{expansion} of a page is the macro expanded version of the body. Proof checking is done after macro expansion. \item[The codex]\index{codex} of a page is an associative structure for fast lookup of all definitions made on a page. \item[The cache]\index{cache} of a page is an associative structure for fast lookup of any attribute of any referenced page. \item[The diagnose]\index{diagnose} (if any) of a page indicates what is wrong with the page (if anything). \end{description} \subsection{Base pages} A Logiweb \indexintro{base page} is a page whose Logiweb bibliography references no other pages. As mentioned, Logiweb bibliographies form directed, acyclic graphs, so if one follows bibliographic references one can be sure to end up in a base page eventually. What you read right now is the body of a base page. % (Unless you are reading the pyk or tex sources, of course :-) The body does not include the Logiweb bibliography, so you cannot verify that the present page is a base page by reading the present text. The bibliography at the end of the present body is an ordinary \textsc{Bib}\TeX\ bibliography which is unrelated to the Logiweb bibliography. To see the Logiweb bibliography of a page, you must view the page in a Logiweb browser and open the bibliography. If the page is generated from a pyk source, you may also see the Logiweb bibliography in that source. \section{Elementary definitions} \subsection{Proclamations} \subsubsection{Loading}\label{section:loading} When Logiweb reads a Logiweb page in order to ``understand'' it, we shall say that Logiweb \indexintros{load}{s} the page. Logiweb loads a page as follows: \begin{description} \item[Resolving] Given the reference of the page, Logiweb uses the mesh of Logiweb servers to \indexintro{resolve} the reference, i.e.\ to locate a mirror that holds a copy of the page. That mirror typically is the server of the author of the page, but important pages may exist many places. \item[Retrieving] Once the reference is resolved into a Uniform Resource Locator (URL), Logiweb \indexintros{retrieve}{s} the vector of the page, i.e.\ the sequence of bytes that encode the page when it is stored on disk or transmitted over a network. \item[Unpacking] Once the vector is retrieved, Logiweb \indexintros{unpack}{s} it into a bibliography, a dictionary, and a body. During this process, Logiweb recursively loads all pages referenced in the bibliography of the page. \item[Codifying] Once the bibliography, dictionary, and body are available, Logiweb \index{codify}\intro{codifies} the body. Logiweb does so by reading the body over and over again (c.f.\ Section \ref{section:IteratedMacroExpansion}). During these iterations, Logiweb is supposed to obtain a deeper and deeper ``understanding'' of the page. The iterations end when the understanding reaches a fixed point. This is similar to \TeX\ that has to read a \TeX\ source over and over again to get the references right. The outcome of the codification is a \indexintro{codex} and an \indexintro{expansion}. The expansion is a macro expanded version of the body. The codex is an associative structure for fast lookup of all definitions made on a page. \item[Verifying] Once the page is codified, Logiweb \index{verify}\intro{verifies} the page. Verification involves execution of the \indexintro{claim} of the page as described later. The claim of a page typically runs a proof verifyer on all proofs on the page and typically also does several other chores to ensure that the formal mathematics presented on the page is correct. \end{description} \noindent Once a page is loaded, Logiweb can render it using \TeX\ to produce a human readable version of it. As a more exotic facility, Logiweb can also render a page in pyk to produce a pyk source file from which the page can be recompiled. This corresponds to ``view source'' when viewing html-pages but is more complex since Logiweb uses a compact, binary format from which the source has to be reverse engineered. Finally, Logiweb is supposed to be able to \indexintro{execute} the page, but that is not implemented at the time of writing. The execution facility will be a general programming facility including general I/O facilities. Logiweb itself is ultimately intended to be implemented using this facility. At the time of writing, Logiweb is implemented in Lisp. \subsubsection{Revelations}\label{section:revelations} Logiweb has three kinds of \indexintro{revelation} constructs that connect syntactic constructs with semantic concepts. The three kinds of revelations are called \indexintros{proclamation}{s}, \indexintros{definitition}{s}, and \indexintros{introduction}{s}. Logiweb has a small number of predefined concepts; a proclamation connects a syntactic construct with one of these predefined concepts. Definitions and introductions allow to connect syntactic constructs with user defined concepts. On the present page, proclamations are made using the \indexintro{proclamation construct} "[ math proclaim var x as var y end proclaim end math ]"\footnote{For the convenience of the reader, mathematics is enclosed in brackets to distinguish it clearly from other text. Such use of brackets is a stylistic choice which is independent of Logiweb.}. As we shall see in Section \ref{section:selfproclamation}, "[ math proclaim var x as var y end proclaim end math ]" proclaims "[ bracket var x end bracket ]" to denote the concept identified by "[ bracket var y end bracket ]". \subsubsection{Logiweb symbols} Every Logiweb construct is identified by a \indexintro{reference} and an \indexintro{identifier}, both of which are cardinals (i.e.\ natural numbers). The reference of a construct equals the reference of the page that introduces the construct. The identifier identifies the operation among all operations introduced by that page. The reference of the "[ math proclaim var x as var y end proclaim end math ]" construct equals the reference of the present page (which is a big number) and the identifier equals one. As we shall see, it is important to Logiweb that the identifier equals one. We shall refer to a pair consisting of the reference and identifier of a Logiweb construct as a Logiweb \indexintro{symbol}. Logiweb symbols resemble Common Lisp symbols \cite{steele} which is the same as Lisp atoms in the original sense of the word \cite{mccarthy60}. There is a one-to-one correpondence between Logiweb symbols and Logiweb constructs. But the concepts are not identical; Logiweb constructs are things one may encounter on Logiweb pages, Logiweb symbols are pairs of integers that represent the constructs. \subsubsection{Preconceived opinions} To begin with, and with two exceptions, Logiweb does not assign any particular meaning to any particular construct. The general rule that Logiweb has no preconceived opinion about the meaning of constructs makes Logiweb flexible and ensures the notational freedom of each, individual author. The exceptions allow Logiweb to bootstrap. The two exceptions relate to \indexintros{page construct}{s} and proclamation constructs. A page construct is a Logiweb construct whose identifier equals zero. There is a one-to-one correspondence between Logiweb pages and Logiweb page constructs: Given the reference of a page, one just adds a zero to get its page construct, and given a page construct one just removes the zero to get the reference of the page. Page constructs are used whenever there is a need to reference a page in a context that requires a symbol. As an example, Logiweb allows to assign names (i.e.\ pyk names) to symbols. Logiweb does not allow to assign names to pages. But every page has a page symbol, and the name of the page symbol effectively becomes the name of the page. Page constructs are unrelated to the bootstrapping of Logiweb. Rather, bootstrapping depends on proclamation constructs. \subsubsection{Bootstrapping and proclamation constructs}\label{section:Bootstrapping} As mentioned in Section \ref{section:loading}, Logiweb codifies a page by reading its body over and over again. At each reading, Logiweb ``understands'' the page in the light of what Logiweb already knows. This knowledge includes anything Logiweb managed to extract from pages referenced in the bibliography and anything Logiweb managed to extract from the present page at the previous reading. In one situation, Logiweb has no prior knowledge when reading a page. That happens when Logiweb reads a base page first time (recall that a base page is a Logiweb page that references no other pages). To get started, Logiweb has the preconceived opinion that, on first reading of a base page, the symbol whose identifier equals one is a proclamation symbol. The proclamation construct in turn has the preconceived opinion that Logiweb constructs with identifiers from $[97]$ to $[122]$ denote the small letters from a to z and that certain sequences of such letters denote particular concepts. How the constructs with identifiers from $[97]$ to $[122]$ are used to form strings is treated in Section \ref{section:strings}. \subsubsection{Self-proclamation}\label{section:selfproclamation} The first task of the proclamation symbol is to secure itself. Logiweb only has the preconceived opinion that the symbol whose identifier equals one is a proclamation symbol on first reading of a base page. On the second reading, Logiweb has no such preconceived opinion. For that reason, we make the following proclamation: \display{"[ math proclaim proclaim var x as var y end proclaim as text "proclaim" end text end proclaim end math ]"} The proclaimation construct happens to have the preconceived opinion that the string ``proclaim'' denotes the proclamation concept. Hence, during first reading of the present base page, Logiweb sees that "[ math proclaim var x as var y end proclaim end math ]" is proclaimed to denote proclamation and, hence, "[ math proclaim var x as var y end proclaim end math ]" denotes proclaimation during second reading of the base page. During second reading, "[ math proclaim var x as var y end proclaim end math ]" is again proclaimed to denote proclamation and, hence, "[ math proclaim var x as var y end proclaim end math ]" denotes proclaimation during third reading and so on. Readers with plenty of spare time may find fun in constructing a base page for which the constructs whose identifiers equal two and three end up being proclamation constructs whereas the construct whose identifier equals one ends up not being a proclamation construct. \subsection{Definitions} \subsubsection{Aspects} As mentioned in Section \ref{section:revelations}, Logiweb has three kinds of revelations: proclamations, definititions, and introductions. We now proclaim "[ math define var x of var y as var z end define end math ]" as a construct for definitions: \display{"[ math proclaim define var x of var y as var z end define as text "define" end text end proclaim end math ]"} The construct "[ math define var x of var y as var z end define end math ]" states that the "[ bracket var x end bracket ]" \indexintro{aspect} of "[ bracket var y end bracket ]" equals "[ bracket var z end bracket ]". A mathematical definition like $ [ r ( x , y ) \doteq \sqrt{ x ^ 2 + y ^ 2 } ] $ corresponds to a Logiweb definition in which the value aspect of $ [ r ( x , y ) ] $ is defined to be $ [ \sqrt{ x ^ 2 + y ^ 2 } ] $. In general, ordinary, mathematical definitions correspond to Logiweb value definitions. Logiweb, however, allows the user to define a variety aspects of each construct. \subsubsection{The pyk aspect} A particular important aspect is the \index{aspect, pyk}\indexintro{pyk aspect}. We use "[ bracket pyk end bracket ]" to denote the pyk aspect: \display{"[ math proclaim pyk as text "pyk" end text end proclaim end math ]"} The pyk aspect of a construct indicates how to render the construct in the pyk language. Until further, we have used the following constructs: % % proclaim % \index{proclaim x as y end proclaim "[ math proclaim var x as var y end proclaim end math ]"}% % \index{\alpha proclaim x as y end proclaim @\back "[ math proclaim var x as var y end proclaim end math ]" proclaim x as y end proclaim}% % \tex{"[ math tex define proclaim var x as var y end proclaim as " [#1/tex name/tex. \bowtie#2. ]" end define end math ]"}% % "[ math proclaim var x as var y end proclaim end math ]"% % \footnote{"[ math pyk define proclaim var x as var y end proclaim as "proclaim * as * end proclaim" end define end math ]"}, % % define % \index{define var x of var y as var z end define "[ math define var x of var y as var z end define end math ]"}% % \index{\alpha define var x of var y as var z end define @\back "[ math define var x of var y as var z end define end math ]" define var x of var y as var z end define}% % \tex{"[ math tex define define var x of var y as var z end define as " [#2/tex name/tex. \stackrel{#1. }{\rightarrow}#3. ]" end define end math ]"} % "[ math define var x of var y as var z end define end math ]"% % \footnote{"[ math pyk define define var x of var y as var z end define as "define * of * as * end define" end define end math ]"}, % % pyk % \index{pyk @\back "[ bracket pyk end bracket ]" pyk}% % \tex{"[ math tex define pyk as " \mathrm{pyk}" end define end math ]"}% % "[ bracket pyk end bracket ]"% % \footnote{"[ math pyk define pyk as "pyk" end define end math ]"}, % % var x % \tex{"[ math tex define var x as " \mathsf{x}" end define end math ]"}% % "[ bracket var x end bracket ]"% % \footnote{"[ math pyk define var x as "var x" end define end math ]"}, % % var y % \tex{"[ math tex define var y as " \mathsf{y}" end define end math ]"}% % "[ bracket var y end bracket ]"% % \footnote{"[ math pyk define var y as "var y" end define end math ]"}, and % % var z % \tex{"[ math tex define var z as " \mathsf{z}" end define end math ]"}% % "[ bracket var z end bracket ]"% % \footnote{"[ math pyk define var z as "var z" end define end math ]"}. The footnote of "[ math proclaim var x as var y end proclaim end math ]" reads \display{"[ math pyk define proclaim var x as var y end proclaim as "proclaim * as * end proclaim" end define end math ]"} As we shall see later, "[ math pyk define proclaim var x as var y end proclaim as "proclaim * as * end proclaim" end define end math ]" macro expands into \display{"[ math define pyk of proclaim var x as var y end proclaim as text "proclaim * as * end proclaim" end text end define end math ]"} which in turn defines the pyk aspect of "[ math proclaim var x as var y end proclaim end math ]" as the string ``proclaim * as * end proclaim''. "[ math pyk define proclaim var x as var y end proclaim as "proclaim * as * end proclaim" end define end math ]" differs from "[ math define pyk of proclaim var x as var y end proclaim as text "proclaim * as * end proclaim" end text end define end math ]" in a few places: The former protects the left hand side against macro expansion. That is important when defining the pyk aspect of macros. Furthermore, the former ensures that the right hand side is typeset as a string. Looking into the pyk source of the present page reveals that special measures are taken to get the string look right in "[ math define pyk of proclaim var x as var y end proclaim as text "proclaim * as * end proclaim" end text end define end math ]". Note that the pyk aspect of "[ math proclaim var x as var y end proclaim end math ]" has been defined seven times in total until now (once in a footnote and six times in the text). Logiweb just uses the definition that is leftmost after macro expansion. The pyk compiler is a little more touchy: it prints a warning if there are definitions that contradict one another. The pyk compiler accepts the seven pyk definitions of "[ math proclaim var x as var y end proclaim end math ]" without notice since all the definitions are identical after macro expansion. \subsubsection{Uses of pyk} The pyk definitions stated so far allow to write e.g. \begin{quote} proclaim define var x of var y as var z end define as $\cdots$ end proclaim \end{quote} \noindent in a pyk source file to obtain \display{"[ math proclaim define var x of var y as var z end define as text "define" end text end proclaim end math ]"} In principle, the pyk language is not part of Logiweb. The Logiweb standard merely defines how to interpret Logiweb vectors, i.e.\ Logiweb pages on binary format. The only formal link between Logiweb and pyk is the fact that Logiweb has a predefined concept that is proclaimable under the name of ``pyk''. The pyk language and compiler are just means for producing Logiweb pages. One could imagine other means for producing Logiweb pages that were completely independent of pyk. Nevertheless, authors who publish on Logiweb are encouraged to give a pyk definition of each and every construct that is introduced on the page. In the future, the pyk definitions may be used for entering mathematics through a microphone or for reading mathematics e.g.\ for blind people. At the time of writing, pyk definitions have a much more immediate use as explained in the following. At the time of writing, the pyk compiler is the only realistic means for producing Logiweb pages. The pyk compiler takes a pyk source text as input and produces a Logiweb page as output. The pyk compiler also has facilities for rendering pages, for making various soundness checks, and for printing warnings and error messages. A pyk source consists of a preamble and a body. The preamble defines the bibliography and dictionary of the page. The bibliography is a list of referenced pages and the dictionary is the list of all constructs introduced on the page. The preamble also defines other things like the priority and associativity of constructs and preliminary pyk definitions for all constructs. When the pyk compiler reads the preamble, it loads all pages referenced in the bibliography. Then it extracts all pyk definitions from all referenced pages, merge them with the preliminary pyk definitions of the preamble, and use the resulting grammar for parsing the body of the page. The pyk compiler does not care whether or not the resulting grammar is ambiguous as long as the body of the page has one and only one possible interpretation. When the pyk compiler generates the Logiweb page, all the preliminary pyk definitions from the preamble are lost. Only pyk definitions explicitly included in the body by the author make their way to the resulting Logiweb page. Hence, if you publish a Logiweb page and want to make the life easy for people who want to build on your work, you'd better include pyk definitions of each and every construct on your page. Do not omit constructs you think are unimportant or ``internal to the page'' in an information hiding sense. In the context of proof checking there is no such thing as an unimportant construct or an ``internal construct'' that one should not look at. \subsubsection{The tex aspect} The \index{tex aspect}\index{aspect, tex}\intro{tex aspect} is another important aspect. The tex aspect of a construct indicates how to render the construct in the \TeX\ language. We use "[ bracket tex end bracket ]" to denote the tex aspect: \index{tex @\back "[ bracket tex end bracket ]" tex}% % \tex{"[ math tex define tex as " \mathrm{tex}" end define end math ]"}% % \display{% "[ math proclaim tex as text "tex" end text end proclaim end math ]"% % \footnote{"[ math pyk define tex as "tex" end define end math ]"}} Tex definitions for the present page are collected in Appendix \ref{section:TeXdefinitions}. In that Appendix, one may find a definition like \display{"[ math tex define var x as " \mathsf{x}" end define end math ]"} As we shall see later, \mbox{"[ math tex define var x as " \mathsf{x}" end define end math ]"} macro expands into \display{"[ math define tex of var x as text " \mathsf{x}" end text end define end math ]"} which in turn defines the tex aspect of "[ bracket var x end bracket ]" to be a string that starts with a \indexintro{newline character} followed by $\backslash$mathsf\{x\}. Internally, Logiweb consistently uses Unicode 10 for the newline character. Whenever Logiweb runs on a host operating system that uses another character or character sequence between lines of text, newline characters have to be translated in the interface between Logiweb and the operating system. The tex definition above states that whenever Logiweb renders an "[ bracket var x end bracket ]" using the \TeX\ system, it dumps ${\downarrow}{\backslash}$mathsf\{x\} to a file and runs it through \TeX\ (where the down arrow represents the newline character). As another example, the pairing construct "[ bracket var x pair var y end bracket ]" introduced later has the following tex aspect: \display{"[ math tex define var x pair var y as "#1. \mathrel { : \, : }#2." end define end math ]"} Arguments are represented by asterisks in pyk aspects. In tex aspects, arguments are represented by sequences of characters that start with a hash mark and end with a period. As an example, \#117. denotes the 117'th argument of a construct. A hash mark immediately followed by a period as in ``\#.'' denotes a hash mark. When sending text through \TeX\ one has to be careful about newline characters. Firstly, one should avoid making lines that are too long for \TeX\ or the host operating system. Secondly, one should avoid producing two newline characters in sequence since \TeX\ assigns a special meaning to repeated newline characters. To fulfill both, the present page makes the following convention for tex aspects: A newline character is added in front of the string whenever the string starts with a character rather than an argument. Furthermore, a newline character is inserted whenever a character follows an argument. Newlines are omitted, however, if they disturb \TeX\ in achieving the intended rendering. \subsubsection{Interpretation of the tex aspect} Looking at the pyk source of the present page reveals that the tex aspect of the entire page looks like this: \begin{verbatim} File page.tex ... End of file File page.bib ... End of file latex page makeindex page bibtex page latex page makeindex page latex page \end{verbatim} The tex aspect above is not run directly through \TeX. Rather, it instructs an interpreter to place certain text in certain files and then run latex, bibtex, and makeindex in a certain pattern. For security reasons, the interpreter of the present system only allows execution of commands named tex, latex, bibtex, and makeindex. Furthermore, the interpreter only accepts file names made up from the characters a to z, A to Z, 0 to 9, and dots. At present, security holes in tex, latex, bibtex, or makeindex may compromise security. For this and other reasons, these programs will run in a chroot gail in some future release of Logiweb. \subsubsection{The tex name aspect} Some constructs look different when using them and when talking about them. As an example, consider ordinary typewriter text. When using a newline character, the character itself is invisible but has the effect that text following it starts on a new line. When talking about a newline character, one may call it ``the newline character''. This way, a newline character is invisible when using it and consists of 19 characters and two spaces when talking about it. As another example, the \TeX\ bold face command may be called \verb+\bf+ when talking about it and changes the text that follows it to bold face when using it. To cope with this, we introduce a \index{name, tex}\indexintro{tex name} or \intro{name} aspect to supplement the tex aspect: \display{% \tex{"[ math tex define tex name as " \mathrm{name}" end define end math ]"}% % "[ math proclaim tex name as text "texname" end text end proclaim end math ]"% % \footnote{"[ math pyk define tex name as "tex name" end define end math ]"}} The tex name aspect should be such that it can be typeset in \TeX\ math mode. The tex name aspect defaults to the tex aspect, so if the tex and tex name aspects of a construct are identical then one should only define the tex aspect. (The tex aspect in turn defaults to something that is constructed from the pyk aspect, and the pyk aspect in turn defaults to something semi-readable constructed from the reference and identifier of the construct). \subsubsection{Uses of the tex name aspect} As an example of a construct for which the tex and tex name aspects differ, consider the following: \display{% \index{math * end math}% % \tex{"[ math tex define math var x end math as "$#1.$" end define end math ]"}% % "[ math tex define math var x end math as "$#1.$" end define end math ]"% % \footnote{"[ math pyk define math var x end math as "math * end math" end define end math ]"}} \display{% \tex{"[ math tex name define math var x end math as " \ \$#1.\$\linebreak[0]\ " end define end math ]"}% % "[ math tex name define math var x end math as " \ \$#1.\$\linebreak[0]\ " end define end math ]"} The ``math * end math'' construct allows to insert mathematics in \TeX\ horizontal mode by changing to math mode temporarily. The tex name aspect allows to talk about the construct. The left hand sides of the three definitions above are typeset using the tex name aspect. Elaborating the example from the previous section, the pyk source of a definition like \display{"[ math proclaim define var x of var y as var z end define as text "define" end text end proclaim end math ]"} could read something like \begin{quote} math proclaim define var x of var y as var z end define as $\cdots$ end proclaim end math \end{quote} \noindent The ``math * end math'' construct is invisible in the definition above but certainly affects the typography; without it, \TeX\ would produce ugly error messages rather than beautiful typography. By the way: note that ``math * end math'' changes to $\backslash$rm immediately after changing to math mode. That is because Logiweb formulas contain loads of text and because the typography of e.g.\ variables is under tight control of Logiweb, so the defaults of \TeX\ math mode are not the right ones for Logiweb. \subsubsection{Brackets} For completeness, \display{\index{bracket * end bracket}% % \tex{"[ math tex define bracket var x end bracket as "$[#1.]$" end define end math ]"}% % \tex{"[ math tex name define bracket var x end bracket as " \mbox{bracket $#1.$ end bracket}" end define end math ]"}% % "[ math tex define bracket var x end bracket as "$[#1.]$" end define end math ]"% \footnote{"[ math define pyk of bracket var x end bracket as text "bracket * end bracket" end text end define end math ]"}} and \display{\index{big bracket * end bracket}% % \tex{"[ math tex define big bracket var x end bracket as "$\left[#1.\right]$" end define end math ]"}% % \tex{"[ math tex name define big bracket var x end bracket as " \mbox{big bracket $#1.$ end bracket}" end define end math ]"}% % "[ math tex define big bracket var x end bracket as "$\left[#1.\right]$" end define end math ]"% \footnote{"[ math define pyk of big bracket var x end bracket as text "big bracket * end bracket" end text end define end math ]"}} are versions of ``math * end math'' that add brackets around the formula. The latter adds large brackets using the large bracket facility of \TeX, which is useful occasionally but which mainly leads to undesirable results. The large brackets in \cite{MathComp} adjust their height independently of their depth and allow line breaking of their argument. The brackets of \cite{MathComp} are not used here, however, because they would have an inconveniently large tex aspect. By the way, two major Logiweb pages have been developed before Logiweb itself was developed. The first is \cite{MathComp} which is a three volume textbook on mathematics for first year computer science students used at the department of computer science at the University of Compenhagen as a replacement for discrete mathematics. The second is cite{grue02b} which contains a consistency proof for ZFC set theory expressed in Map theory. At the time of writing, these two are not yet published on Logiweb, but they have been drivers of the design of Logiweb. \subsubsection{The tex aspect of definitions} As stated in Appendix \ref{section:TeXdefinitions}, the \TeX\ definition of "[ math define var x of var y as var z end define end math ]" reads: \display{"[ math tex define define var x of var y as var z end define as " [#2/tex name/tex. \stackrel{#1. }{\rightarrow}#3. ]" end define end math ]"} In the definition, ``\#1.'' says ``insert the first argument (the aspect) here''. Likewise, ``\#3.'' says ``insert the third argument (the right hand side) here''. The second argument (the left hand side), is more complicated. A definition talks about the left hand side rather than just using it. For that reason, the left hand side should be rendered using the tex name aspect instead of the tex aspect. On the other hand, if the left hand side has parameters, then those parameters should be rendered normally, i.e.\ using the tex aspect. ``\#2/tex name/tex.'' says ``insert the second argument (the left hand side) here using the tex name aspect for the left hand side, but revert to the tex aspect for the parameters of the left hand side. \subsection{Associativity and priority} \subsubsection{Introduction} A ``preassociative'' construct is left associative in text that runs left to right, right associative in text that runs right to left, top associative in text that runs from top to bottom, counterclockwise associative in text written in left turning spirals, and so on. Text on Logiweb pages may run in any conceivable direction. Pyk source text runs from left to right. The pyk compiler uses associativities when parsing pyk source text. As an example, if the construct ``*~plus~*'' is preassociative then ``var~x plus var~y plus var~z'' is interpretted as ``(var~x plus var~y) plus var~z. Likewise, if ``*~pair~*'' is postassociative then ``var~x pair var~y pair var~z'' means ``var~x pair (var~y pair var~z)''. The pyk compiler also uses priorities. As an example, it ``*~plus~*'' has greater priority than ``*~pair~*'' then ``var~x plus var~y pair var~z'' means ``(var~x plus var~y) pair var~z'' and ``var~x pair var~y plus var~z'' means ``var~x pair (var~y plus var~z)''. If two constructs have equal priority, then they are forced to have the same associativity as well. As an example, if ``*~minus~*'' has the same priority as ``*~plus~*'' then ``*~minus~*'' automatically becomes preassociative. Hence, ``var~x plus var~y minus var~z'' means ``(var~x plus var~y) minus var~z'' and ``var~x minus var~y plus var~z'' means ``(var~x minus var~y) plus var~z''. \subsubsection{Open and closed constructs} A construct is said to be ``preopen'' if it starts with an asterisk and to be ``preclosed'' otherwise. Likewise, a construct is ``postopen'' and ``postclosed'' if it does and doesn't end with an asterisk, respectively. A construct is said to be ``open'' if it is pre- and postopen and ``closed'' if it is pre- and postclosed. A construct is said to be ``prefix'' if it is preclosed and post open and ``suffix'' if it is preopen and post closed. Here are some examples: \begin{tabular}{llll} parenthesis * end & preclosed & postclosed & closed \\ {*} apply * & preopen & postopen & open \\ lambda * dot * & preclosed & postopen & prefix \\ * factorial & preopen & postclosed & suffix \\ \end{tabular} None of the four constructs above are declared on this page; they are just included for the example. Associativity and priority is irrelevant for closed constructs. Associativity does affect prefix and suffix constructs. As an example, if ``*~apply~*'', ``lambda~*~dot~*'' and ``*~factorial'' have the same priority, then ``lambda var~x dot var~y apply var~z factorial'' means ``((lambda var~x dot var~y) apply var~z) factorial'' if the constructs are preassociative and ``lambda var~x dot (var~y apply (var~z factorial))'' if they are postassociative. \subsubsection{Priority interference} Prefixness and suffixness occasionally interfere with priorities. As an example, suppose ``*~apply~*'' has greater priority than ``lambda~*~dot~*'' and consider the following pyk source: var x apply lambda var y dot var y apply var y First step in disambiguating the text above is to put parentheses around the operator that has the lowest priority and to put parentheses around its parameters: var x apply (lambda (var y) dot (var y apply var y)) This divides the problem into two smaller problems: disambiguating ``var~x apply~$\cdots$'' and disambiguating ``var y apply var y'' both of which are trivial: ((var x) apply (lambda (var y) dot ((var y) apply (var y)))) Hence, the principal operator of ``var~x apply lambda var~y dot var~y apply var~y'' is the leftmost ``apply'' which may be surprising since the lambda is the operator with the lowest priority. \subsubsection{Openness coherence} When defining the pyk and tex aspects of a construct it is important to let them have the same ``openness'', i.e. to make them both open, both closed, both prefix, or both suffix. As an example, if one renders a pair as e.g.\ $x \mathrel{:\,:} y$ which is open then one should ensure that the pyk aspect is also open as in ``* plus *''. If one renders the pair as e.g.\ $(x,y)$ which is closed then one should ensure that the pyk aspect is closed as in ``pair * comma * end pair''. Failure to make openness coherent may seriously baffle the reader since it may make the pyk compiler and a human reader interpret terms differently. Some constructs are non-trivial to classify. As an example, exponentiation $x^y$ is best classified as a suffix construct because $a+x^y$ could mean $(a+x)^y$ or $a+(x^y)$ whereas $x^y+a$ can only mean $(x^y)+a$ and, thus, $x^y$ is ambiguous the way suffix constructs are. Hence, the pyk name of exponentiation should be something like ``* power * end power''. \subsubsection{Priority tables} A Logiweb page may contain constructs from the page itself as well as constructs from all pages it references in its Logiweb bibliography. The pyk compiler insists on knowing the associativity and priority af each non-closed construct that might possibly appear on a page. The pyk compiler is somewhat relaxed about whether or not priorities and associativities are specified for closed constructs because the associativities and priorities of such constructs have no effect. To avoid double work, a Logiweb page should contain a priority table which the pyk compiler can import when the page is included in the Logiweb bibliography of another Logiweb page. A page should contain one priority table, not one for each construct. Hence, the priority table is an aspect of the page rather than an aspect of each, individual construct. This is a problem because Logiweb allows to define aspects of constructs but does not allow to define aspects of pages. So what do we do? \subsubsection{The page symbol} As mentioned, every construct in Logiweb is identified by a reference $[r]$ and an id $[i]$, both of which are cardinals. The reference uniquely identifies the Logiweb page that introduces the construct and the id identifies the construct within the page. We shall refer to a construct with reference $[r]$ and id $[i]$ as the $[i]$'th construct of page $[r]$. The zero'th construct of a Logiweb page will be referred to as the ``page construct'' of the page. Aspects of the page construct should be thought of as aspects that concern the entire page. As an example, consider the following pyk definition of the page construct of the present page: "[ math define pyk of base as text "base" end text end define end math ]" Because of the definition above we shall say that the present page is named ``base''. To see that "[ bracket base end bracket ]" is the page construct of the present page one has to open the present page in a Logiweb browser, find the id of the construct, and see that the id is zero. In the Logiweb crossbrowser, one may do that by opening the ``dictionary'' window. More advanced browsers would probably allow the user to click on "[ bracket base end bracket ]" and view its properties somehow. We do not define a tex aspect of the page construct, and for that reason the tex aspect defaults to \verb+\mathrm{base}+. We do not define a tex name aspect either, and for that reason the tex name aspect defaults to be identical to the tex aspect. The page construct is forced to have arity zero, i.e. it has no parameters. \subsubsection{The priority aspect} The priority table is defined as a ``priority aspect'' of the page construct. We introduce the priority aspect thus: "[ math proclaim priority as text "priority" end text end proclaim end math ]" "[ math define pyk of priority as text "priority" end text end define end math ]" "[ math define tex of priority as text " \mathrm{prio}" end text end define end math ]" \subsubsection{Flush left environment} The priority table is a long, heterogeneous formula which is difficult to linebreak. For that reason we shall typeset it \index{right, ragged}\indexintro{ragged right} or \index{left, flush}\indexintro{flush left}. To do so, we introduce a % \index{flush left x end left @\back "[ bracket text flush left var x end left end text end bracket ]" flush left x end left}% % \tex{"[ math tex define flush left var x end left as " \begin {flushleft}#1. \end {flushleft}" end define end math ]"}% % \tex{"[ math tex name define flush left var x end left as " \mathbf{flush\ left\ }[ #1. ]" end define end math ]"}% % "[ bracket text flush left var x end left end text end bracket ]"% % \footnote{"[ math pyk define flush left var x end left as "flush left * end left" end define end math ]"}% % construct which typesets its argument with a ragged right margin. \subsubsection{The priority table} For convenience, we introduce a variable named "[ bracket x end bracket ]" which we use in pyk, \TeX, and priority definitions where parameter names are ignored. The priority table itself is given in Appendix \ref{section:PriorityTable}. The number of constructs in it is colossal, but that is normal for large base pages since the table contains lots of trivia like characters and variable names. \subsubsection{Priority table constructors} The priority table in Appendix \ref{section:PriorityTable} is constructed from the following four constructs: "[ math define pyk of preassociative var x greater than var y as text "preassociative * greater than *" end text end define end math ]" "[ math define pyk of postassociative var x greater than var y as text "postassociative * greater than *" end text end define end math ]" "[ math define pyk of priority var x equal var y as text "priority * equal *" end text end define end math ]" "[ math define pyk of priority var x end priority as text "priority * end priority" end text end define end math ]" The pyk source of the table looks something like \begin{verbatim} math define priority of base as preassociative priority bracket var x end bracket equal priority math var x end math equal ... priority priority end priority greater than preassociative priority unicode start of text var x end unicode text equal ... priority priority var x end priority end priority greater than postassociative priority var x then var y equal priority var x begin var y end var z end priority greater than base end define end math \end{verbatim} From the structure of the table, the pyk compiler can guess that ``priority * equal *'' denotes ``equal priority'' and that ``priority * end priority'' marks the end of a list of equal priorities. The pyk compiler can also guess that ``preassociative * greater than *'' and ``postassociative * greater than *'' denote pre- and postassociativity but cannot guess which is which. For that reason, we have to reveal that to Logiweb explicitly using proclamations: "[ math proclaim preassociative var x greater than var y as text "pre" end text end proclaim end math ]" "[ math proclaim postassociative var x greater than var y as text "post" end text end proclaim end math ]" \subsubsection{Tex aspects} Tex aspects of priority table constructors read: "[ math define tex of preassociative var x greater than var y as text " \newline \mathbf {Preassociative} \newline #1. ; #2." end text end define end math ]" "[ math define tex name of preassociative var x greater than var y as text " \mathbf{Preassociative}\,#1. ; #2." end text end define end math ]" "[ math define tex of postassociative var x greater than var y as text " \newline\mathbf{Postassociative} \newline #1. ; #2." end text end define end math ]" "[ math define tex name of postassociative var x greater than var y as text " \mathbf{Postassociative}\,#1. ; #2." end text end define end math ]" "[ math define tex of priority var x equal var y as text " [#1/tex name/tex. ] , \linebreak [0] #2." end text end define end math ]" "[ math define tex name of priority var x equal var y as text " [#1. ] , \linebreak [0] #2." end text end define end math ]" "[ math define tex of priority var x end priority as text " [#1/tex name/tex. ]" end text end define end math ]" "[ math define tex name of priority var x end priority as text " \mathrm{priority} \,#1. \, \mathrm{end}" end text end define end math ]" \subsection{Strings}\label{section:strings} \subsubsection{Introduction} The pyk language itself is a rather purist language that merely uses the small letters from a to z and space and newline characters for expressing Logiweb pages of arbitrary complexity. Capital letters and punktuation marks have been omitted to prepare the language for input via a microphone (it is easy, though, to adapt pyk to allow letters from other alphabets). Furthermore, the rather purist Logiweb computing engine described elsewhere has sufficient power to render pages all the way from layout to pixels without resorting to external systems like \TeX\ or \textsc{Bib}\TeX\ or whatever. Or, at least, programs like \TeX\ may be translated to the Logiweb language, placed on a Logiweb page, and executed from there by the Logiweb engine. During the early phases of the development of Logiweb, however, too much purism is unaffordable. \TeX\ is a very mature system that cannot be replaced overnight. To allow Logiweb pages to include \TeX\ source, the pyk language has support for strings. The treatment of strings in the following should make sense in itself, but the motivation for going through the pain of introducing strings requires quite some overview of how all the parts of Logiweb play together. \subsubsection{Construction of strings} As mentioned earlier, every construct in Logiweb is identified by a reference $[r]$ and an id $[i]$, both of which are cardinals. We shall say that a construct is ``blind'' if its id is between zero and nine, inclusive, or between 11 and 31, inclusive. We shall say that constructs whose ids equal 10 or are greater than 31 are non-blind. When used in strings, non-blind constructs represents the character whose unicode equals the id of the construct. Blind constructs represent no characters. As an example, The id's of the pyk construct ``unicode small a *'', ``unicode small b *'', ``unicode small c *'', and ``unicode end of text'' equal 97, 98, 99, and 3, respectively (to see that one needs access to the pyk source of the present page or needs to view the page in a Logiweb browser). The expression \begin{quote} unicode small a unicode small b unicode small c unicode end of text \end{quote} \noindent is interpretted as \begin{quote} unicode small a ( unicode small b ( unicode small c ( unicode end of text ) ) ) \end{quote} \noindent When read from left to right, the id's of the constructs are 97, 98, 99, and 3. Ignoring 3 which is blind, we are left with 97, 98, and 99 which are the unicodes for ``a'', ``b'', and ``c'', respectively. For that reason, \begin{quote} unicode small a unicode small b unicode small c unicode end of text \end{quote} \noindent represents the string ``abc''. \subsubsection{Pyk strings} Continuing the previous example, the id of the pyk construct ``unicode start of text * end unicode text'' equals two. Whenever the pyk compiler sees a string like \verb\"!abc"!\ inside a mathematical expression, it translates it to \begin{verbatim} unicode start of text unicode small a unicode small b unicode small c unicode end of text end unicode text \end{verbatim} Ignoring blind constructs, the expression above represents the string ``abc''. Logiweb itself assigns no particular semantics to constructs like ``unicode start of text * end unicode text'' and ``unicode end of text'' whose ids equal two or three. But the pyk compiler consistently add constructs with these particular ids whenever it translates a string. The representation of Logiweb pages is such that characters with codes below 128 take up one byte. A string like ``abc'' takes up five bytes because the start and end of text characters also take up one byte. \subsubsection{Rendering of strings} Rendering of ``a'', ``b'', and ``c'' is completely straighforward: "[ math define tex of unicode small a var x as text "a#1." end text end define end math ]" "[ math define tex of unicode small b var x as text "b#1." end text end define end math ]" "[ math define tex of unicode small c var x as text "c#1." end text end define end math ]" Pyk and tex definitions for ``a'', ``b'', ``c'', and many other non-blind characters are collected in the appendix. The tex aspects of the start of text character clearly show that it is blind: "[ math define tex of unicode start of text var x end unicode text as text "#1." end text end define end math ]" However, when talking about the start of text character it is inconvenient if it is blind. Instead, we represent it by double quotes: "[ math define tex name of unicode start of text var x end unicode text as text " \mbox{``}#1. \mbox{''}" end text end define end math ]" We shall take the liberty to make the end of text character completely blind: "[ math define tex of unicode end of text as text "" end text end define end math ]" As you can see (or, rather, cannot see), there are no glyphs in the left hand side of the definition above. That indicates that the left hand side comprises a unicode end of text. We shall define no other constructs that are completely blind, i.e.\ blind when talking about them. Lots of constructs are blind when using them, but the unicode end of text is the only one that is blind when talking about it. The unicode end of text should be used with caution is it may baffle the reader. For completeness, the pyk aspects of the start and end of text characters read: "[ math define pyk of unicode end of text as text "unicode end of text" end text end define end math ]" "[ math define pyk of unicode start of text var x end unicode text as text "unicode start of text * end unicode text" end text end define end math ]" \subsubsection{Rendering of special characters} The rendering of a backslash reads: "[ math define tex of unicode backslash var x as text "\#1." end text end define end math ]" "[ math define tex name of unicode backslash var x as text " \mbox{$\backslash$}#1." end text end define end math ]" The tex aspect of a backslash generates a backslash character in the input to \TeX. In contrast, the tex name aspect generates a backslash in the output from \TeX. \subsubsection{Talking about strings} The id of the pyk construct ``text * end text'' equals six so it is yet another blind construct. The construct is rendered thus: "[ math define pyk of text var x end text as text "text * end text" end text end define end math ]" "[ math define tex of text var x end text as text "#1/tex name." end text end define end math ]" "[ math define tex name of text var x end text as text " (#1. )^{\bf t}" end text end define end math ]" The tex aspect of ``text * end text'' is invisible in itself but has the effect that all of its argument is rendered using the tex name aspect. As an example, the expression \begin{verbatim} text unicode start of text unicode backslash unicode small b unicode small f unicode end of text end unicode text end text \end{verbatim} generates a start double quote, a backslash, a ``b'', an ``f'', and an end double quote in the output from \TeX. Without the ``text * end text'', the expression generates \verb+\bf+ in the input to \TeX\ which makes \TeX\ change to bold face. \subsubsection{Breaking strings} The id of the pyk construct ``text * plus *'' equals seven and the construct is rendered thus: "[ math define pyk of text var x plus var y as text "text * plus *" end text end define end math ]" "[ math define tex of text var x plus var y as text " \mathrm{#1/tex name. }+\newline#2." end text end define end math ]" "[ math define tex name of text var x plus var y as text " \mbox{string}(#1. )+#2." end text end define end math ]" A term like \begin{verbatim} text unicode start of text unicode small a unicode small b unicode end of text end unicode text plus text unicode start of text unicode small c unicode end of text end unicode text end text \end{verbatim} denotes the string ``abc''. This is so because if one scans the text left to right (or scans the associated parse tree root to leaf, left to right) then one encounters the id's 7, 2, 97, 98, 3, 6, 99, 3 in that order. Ignoring blind codes leaves one with the sequence 97, 98, 99 which represents ``abc''. The rendering of the string consists of ``ab'' on one line and ``c'' on the next. The ``text * plus *'' construct allows the author of a Logiweb page to split a long string over several lines. The id of the ``text * plus indent *'' construct equals eight; the construct does the same as ``text * plus *'' but also indents the second line: "[ math define pyk of text var x plus indent var y as text "text * plus indent *" end text end define end math ]" "[ math define tex of text var x plus indent var y as text " \mathrm{#1/tex name. }\;{++}\newline{}\qquad#2." end text end define end math ]" "[ math define tex name of text var x plus indent var y as text "\mbox{string}(#1. )\mathrel{++}#2." end text end define end math ]" \subsubsection{Formulas in text} The id of the pyk construct ``* begin * end *'' equals five and the construct is rendered thus: "[ math define pyk of var x begin var y end var z as text "*"n"nbegin *"n"nend *" end text end define end math ]" "[ math define tex of var x begin var y end var z as text "#1.#2.#3." end text end define end math ]" "[ math define tex name of var x begin var y end var z as text "#1. {[}#2. {]}#3." end text end define end math ]" As an example of use, the pyk source \begin{verbatim} "!abc"! begin math var x end math end "!def"! \end{verbatim} is equivalent to \begin{verbatim} unicode start of text unicode small a unicode small b unicode small c unicode end of text end unicode text begin math var x end math end unicode start of text unicode small d unicode small e unicode small f unicode end of text end unicode text \end{verbatim} The tex face of the expression above reads \begin{verbatim} abc$\mathsf{x}$def \end{verbatim} which, when run through \TeX, places the variable ``x'' in the middle of the string ``abcdef''. In general, the ``* begin * end *'' construct allows to place mathematical formulas in text. As a violation of purism, the pyk compiler allows the construct ``*[*]*'' to occur in pyk source files. Furthermore, the pyk compiler translates such constructs into constructs whose id equals five. For that reason one may write \begin{verbatim} "!abc"![ math var x end math ]"!def"! \end{verbatim} in place of the pyk source above. Due to a peculiarity in the current implementation of the pyk compiler, the space between the left bracket and the ``m'' in ``math'' above is obligatory. \subsubsection{Juxtaposition} The id of the pyk construct ``* then *'' equals four and the construct is rendered thus: "[ math define pyk of var x then var y as text "*"n"nthen *" end text end define end math ]" "[ math define tex of var x then var y as text "#1.#2." end text end define end math ]" "[ math define tex name of var x then var y as text "#1. \mathrel{\mathrm{then}}#2." end text end define end math ]" As a violation of purism, the pyk compiler allows the construct ``*,*'' to occur in pyk source files. Furthermore, the pyk compiler translates such constructs into constructs whose id equals four. For that reason one may write \begin{verbatim} var x, "!\cdots"!, var y \end{verbatim} to obtain "[ bracket var x , "\cdots" , var y end bracket ]". \subsubsection{Purism versus pragmatism} Purism is a good thing when defining, designing, implementing, debugging, testing, explaining, teaching, learning, understanding, and using a computational system, and one should only resort to pragmatism when neccessary. The pyk compiler is rather puristic, but resorts to pragmatism in the treatment of strings: Double quotes, brackets, and commas are treated specially and constructs whose id equal two, three, four, and five are used when translating those special characters. \section{The Engine} This section describes the Logiweb computing engine. The Logiweb engine is the computing machinery that performs proof checking, macro expansion, and general evaluation in the Logiweb system. At a later stage of the development of Logiweb, the engine is supposed to take over the layout and rendering of Logiweb pages. As mentioned previously, that task is currently done by \TeX\cite{TeXbook} and related programs. The engine is just a computing engine; it has no facilities to communicate with the outside world. The Logiweb ``machine'' described elsewhere contains the Logiweb engine and also contains facilities for input/output. Apart from introducing the engine, the present page also introduces a number of operations suited for manipulation of ``tagged trees''. Tagged trees are to Logiweb what Lisp S-expressions are to Lisp\cite{mccarthy60}. \subsection{Elementary concepts} \subsubsection{Fundamental, computable constructs} The Logiweb engine has four fundamental, computable constructs: lambda abstraction "[ bracket lambda var x dot var y end bracket ]"\footnote{For the convenience of the reader, mathematics is enclosed in brackets to distinguish it clearly from other text. Such use of brackets is a stylistic choice which is independent of Logiweb.}, functional application "[ bracket var x apply var y end bracket ]", truth "[ bracket true end bracket ]", and conditional "[ bracket if var x then var y else var z end if end bracket ]". "[ bracket lambda var x dot var y end bracket ]" denotes lambda abstraction\cite{church41}. Lambda abstraction is a \indexintro{predefined concept} of Logiweb in the sense that knowledge of lambda abstraction is hardwired into Logiweb. Logiweb does not connect lambda abstraction with any, particular syntax, so we must connect the syntactic construct "[ bracket lambda var x dot var y end bracket ]" with the concept of lamdba abstraction. We do so using a proclamation: "[ math proclaim lambda var x dot var y as text "lambda" end text end proclaim end math ]". The proclamation "[ math proclaim lambda var x dot var y as text "lambda" end text end proclaim end math ]" makes "[ bracket lambda var x dot var y end bracket ]" denote lambda abstraction on the present Logiweb page and on all Logiweb pages that include the present page in their Logiweb bibliography. This does not exclude other constructs from denoting lambda abstraction as well. One may proclaim any number of binary constructs to denote lambda abstraction. Neither does this exclude the possibility of using the notation "[ bracket lambda var x dot var y end bracket ]" for other concepts than lambda abstraction on other Logiweb pages. "[ bracket var x apply var y end bracket ]" denotes functional application. As an example, if "[ bracket var x end bracket ]" equals "[ bracket lambda var z dot var z , "+" , three end bracket ]" then "[ bracket var x apply two end bracket ]" equals "[ bracket two , "+" , three end bracket ]" which in turn equals "[ bracket five end bracket ]". We connect syntax and semantics of functional application thus: "[ math proclaim var x apply var y as text "apply" end text end proclaim end math ]". All computable functions can be expressed in \indexintro{pure lambda calculus}, i.e.\ using only "[ bracket lambda var x dot var y end bracket ]" and "[ bracket var x apply var y end bracket ]". Doing so is inconvenient, however. As an example, the range of any function of pure lambda calculus contains one or infinitely many values, and one often wants a computer program to have a finite range of possible responses. Just think of a computer program which is required to loop indefinitely or answer ``yes'' or ``no'' for arbitrary input, and which is required to answer ``yes'' in certain situations and ``no'' in certain, other, situations. Such a computer program cannot be implemented in pure lambda calculus since its range is finite and contains more than one possible response. One symptom of the inconvenience of pure lambda calculus is the difficulty of constructing models for it. Another symptom is the inability so far to construct a foundation of mathematics upon pure lambda calculus. If one adds two more constructs, truth "[ bracket true end bracket ]" and conditional "[ bracket if var x then var y else var z end if end bracket ]", then the problems disappear: One may express functions like "[ bracket lambda var x dot if var x then var y else var z end if end bracket ]" whose range is finite, one may construct rather simple models\cite{berline97}, and one may extend the system into a foundation of mathematics by the drop of a quantifier\cite{grue92}. "[ math proclaim true as text "true" end text end proclaim end math ]" denotes truth. The main property of "[ bracket true end bracket ]" is that it differs from "[ bracket lambda var x dot var y end bracket ]" for all variables "[ bracket var x end bracket ]" and all terms "[ bracket var y end bracket ]" (of course, we make the convention that "[ bracket lambda var x dot var y end bracket ]" represents falsehood for all variables "[ bracket var x end bracket ]" and all terms "[ bracket var y end bracket ]"). Since "[ bracket true end bracket ]" is no function, it does not make sense to apply it to an argument. For completeness, however, we make the convention that "[ bracket true end bracket ]" applied to anything equals "[ bracket true end bracket ]" itself: "[ bracket true apply var x math equal true end bracket ]". "[ math proclaim if var x then var y else var z end if as text "if" end text end proclaim end math ]" is a conditional which allows to test whether "[ bracket var x end bracket ]" equals "[ bracket true end bracket ]" or is a function: \display{"[ big bracket array left then left then left is if true then var u else var v end if tab empty math equal empty tab var u row if lambda var x dot var y then var u else var v end if tab empty math equal empty tab var v end array end bracket ]"} \subsubsection{Reduction system} The Logiweb \indexintro{reduction system} is thus: \display{"[ big bracket array left then left then left is identity lambda var x dot var y end identity apply var z tab empty reduce to empty tab substitute var y set var x to var z end substitute row true apply var z tab empty reduce to empty tab true row if true then var u else var v end if tab empty reduce to empty tab var u row if lambda var x dot var y then var u else var v end if tab empty reduce to empty tab var v end array end bracket ]"} "[ math substitute var y set var x to var z end substitute end math ]" denotes the result of replacing all free occurrences of the variable "[ bracket var x end bracket ]" in the term "[ bracket var y end bracket ]" by the term "[ bracket var z end bracket ]", possibly renaming bound variables as needed. We shall say that a term "[ bracket var z end bracket ]" is on \index{normal form}\indexintro{truth normal form} if the term "[ bracket var z end bracket ]" is identical to "[ bracket true end bracket ]". We shall say that a term "[ bracket var z end bracket ]" is on \indexintro{function normal form} if the term "[ bracket var z end bracket ]" has form "[ bracket lambda var x dot var y end bracket ]" where "[ bracket var x end bracket ]" is a variable and "[ bracket var y end bracket ]" is a term. We shall say that a term is on \indexintro{root normal form} if the term is on truth or function normal form. When given a term, the Logiweb engine starts reducing the term using leftmost reduction. The Logiweb engine stops again if the term reaches root normal form. \subsubsection{Root equivalence} We shall say that a term is a \indexintro{true term} if the engine can reduce it to truth normal form and that it is a \indexintro{function term} if it can reduce it to function normal form. We shall say that a term is \indexintro{perpetual} if the engine reduces it forever without reaching a root normal form. We shall say that two terms are \indexintro{root equivalent} if they are both true terms, both function terms, or both perpetual. Root equivalence is undecidable in general but is decidable on terms that have a root normal form. \subsubsection{Mathematical equality} The Logiweb computing engine does not support the parallel ``or'' operation "[ bracket var x parallel var y end bracket ]", but the operation is interesting for theoretical reasons. The parallel ``or'' operation has the following properties: \display{"[ big bracket array left then left then left is true parallel var y tab empty math equal empty tab true row var x parallel true tab empty math equal empty tab true row identity lambda var x dot var y end identity parallel identity lambda var u dot var v end identity tab empty math equal empty tab lambda var x dot true end array end bracket ]"} If the parallel ``or'' operation were added to the Logiweb computing engine, then the engine would be required to reduce both "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" in parallel whenever the engine had to reduce "[ bracket var x parallel var y end bracket ]". If the engine managed to reduce "[ bracket var x end bracket ]" to "[ bracket true end bracket ]" then it should stop reducing "[ bracket var y end bracket ]" and vice versa. We shall refer to the Logiweb engine extended with parallel ``or'' as the \index{engine, parallel}\indexintro{parallel engine}. The notions of ``root normal form'' and ``root equivalence'' are defined for the parallel engine as they are for the Logiweb engine. Two terms "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" are considered \indexintro{mathematically equal}, written "[ bracket var x math equal var y end bracket ]", if "[ bracket var z apply var x end bracket ]" is root equivalent to "[ bracket var z apply var y end bracket ]" for all terms "[ bracket var z end bracket ]" (where the term "[ bracket var z end bracket ]" is allowed to include parallel ``or''). This defines equality of term "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" that may include parallel ``or'' and, in particular, defines equality of terms that do not include paralle ``or''. Mathematical equality is undecidable in general. At this point, parallel ``or'' has played its role and we shall not refer to it anymore. But we shall use mathematical equality to state things like "[ bracket identity lambda var x dot var x end identity apply var y math equal var y end bracket ]". For an axiomatization of mathematical equality see \cite{grue92}. \subsection{Definitions} \subsubsection{The value aspect} One may define many ``aspects'' of each construct. As an example, the ``tex'' aspect of a construct defines how the construct should be rendered using \TeX. Likewise, the ``pyk'' aspect of a construct defines what the construct looks like in a pyk source file from which a Logiweb page may be compiled. An ordinary mathematical definition of a construct corresponds to a definition of the \indexintro{value aspect} of the construct in Logiweb. The value aspect is proclaimed thus: "[ math proclaim value as text "value" end text end proclaim end math ]". As an example of a value definition, consider the following: \display{"[ math define value of function f of var x end function as if var x then true else function f of var x apply true end function end if end define end math ]"} With the definition above we have "[ bracket function f of lambda var x dot lambda var x dot lambda var x dot true end function math equal function f of lambda var x dot lambda var x dot true end function math equal function f of lambda var x dot true end function math equal function f of true end function math equal true end bracket ]" \subsubsection{Parentheses} It is best to macro define parentheses, i.e.\ to define them by defining the macro aspect of the parenthesis construct. To keep the present page simple and to the point, however, we shall not deal with macro definitions here. Instead, we value define parentheses: \display{"[ math define value of identity var x end identity as var x end define end math ]"} \subsubsection{Bottom} As mentioned, a term is perpetual if reduction of the term proceeds indefinitely without yielding a root normal form. As an example, "[ bracket identity lambda var x dot var x apply var x end identity apply identity lambda var x dot var x apply var x end identity end bracket ]" is a perpetual term. Some authors prefer to use a capital omega for that term. There are different opinions on whether or not all perpetual terms are equal. Intuitionists will typically say that there are perpetual terms that are not provably equal. Other blends of mathematicians go further and claim there are perpetual terms that are provably different. With the definition of mathematical equality stated earlier, however, all perpetual terms are equal. Having decided that all perputual terms are equal or, equivalently, that they all have the same value, it is reasonable to introduce a name for that unique value. We shall follow tradition and call that value \indexintro{bottom} since it lurks at the bottom of kappa-Scott domains. Furthermore, we shall follow tradition and use "[ bracket bottom end bracket ]" to denote bottom. We do so by making the following definition: \display{"[ math introduce value of bottom as identity lambda var x dot var x apply var x end identity apply identity lambda var x dot var x apply var x end identity end introduce end math ]"} The equal sign in the definition deviates slightly from the equal sign used previously. Formally, that has no effect on the definition. See Section~\ref{optimization} for further details. With the definition above we have that "[ bracket bottom end bracket ]" is perpetual, since evaluating it causes a computer to look indefinitely. For that reason, the value of "[ bracket bottom end bracket ]" is bottom. Mathematics is referentially transparent, meaning that any term silently denotes the value of the term. For that reason, "[ bracket bottom end bracket ]" denotes bottom. By abuse of the language, we shall say that an operator \index{return "[ bracket bottom end bracket ]"}\intro{returns} "[ bracket bottom end bracket ]" when the operator does not return anything ever. \subsection{Peano trees} \hypertarget{RawPairs}{}\subsubsection{Raw pairs} Define \display{"[ math introduce value of var y raw pair var z as lambda var x dot if var x then var y else var z end if end introduce end math ]"} \display{"[ math introduce value of false as true raw pair true end introduce end math ]"} \display{"[ math define value of var x raw head as var x apply true end define end math ]"} \display{"[ math define value of var x raw tail as var x apply false end define end math ]"} We shall use "[ bracket true end bracket ]" and "[ bracket false end bracket ]" to denote truth and falsehood, respectively. Furthermore, we shall use "[ bracket var y raw pair var z end bracket ]" as the most fundamental (most \indexintro{raw}) among several pair constructs. The components of a pair may be found using the head operation "[ bracket var x raw head end bracket ]" and tail operation "[ bracket var x raw tail end bracket ]": "[ bracket identity var y raw pair var z end identity raw head math equal var y end bracket ]" "[ bracket identity var y raw pair var z end identity raw tail math equal var z end bracket ]" In principle, we may use any definition for "[ bracket var y raw pair var z end bracket ]" as long as it is possible to compute "[ bracket var y end bracket ]" and "[ bracket var z end bracket ]" from "[ bracket var y raw pair var z end bracket ]". The definition above differs from anything tenable in pure lambda calculus: The range of any function in pure lambda calculus has one or infinitely many elements whereas the range of "[ bracket identity var y raw pair var z end identity apply var x end bracket ]" comprises "[ bracket var y end bracket ]", "[ bracket var z end bracket ]", and "[ bracket bottom end bracket ]". \subsubsection{Peano trees} As is well known, Dedekind and Peano both managed to axiomatize the natural numbers. Dedekind was first, but Peano had best public relations, so we know the axioms as the Peano axioms today. In short, the Peano axioms are axioms for the smallest set "[ bracket "N" end bracket ]" which contains "[ bracket "0" end bracket ]" and which contains the successor of "[ bracket var x end bracket ]" whenever it contains "[ bracket var x end bracket ]". Now consider the smallest set "[ bracket "P" end bracket ]" which contains "[ bracket true end bracket ]" and which contains "[ bracket var x raw pair var y end bracket ]" whenever it contains "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]". We shall refer to the elements of "[ bracket "P" end bracket ]" as \index{Peano tree}\intro{Peano trees} due to the similarity to the structure of natural numbers. Peano trees are good substitutes for natural numbers in elementary recursion theory because it is much easier to work with ``G\"!{o}del trees'' than to work with ``G\"!{o}del numbers''. Peano trees are early precursors of the maps used in Map Theory and Logiweb, and they constitute convenient stepping stones for building up more advanced data structures. In early versions of Map Theory and Logiweb, Peano trees have been called ``Binary trees'', ``Finite trees'', and ``Bintrees'', but those names are inconvenient because it is convenient to reserve ``B'' for ``Boolean'' and ``F'' for ``False''. The ``P'' in ``Peano tree'' may be mistaken to denote ``Pair'', but that is acceptable since Peano trees are little more than a bunch of pairs. As far as possible, we shall represent data structures by Peano trees. As an example, we represented truth values by Peano trees in the previous section. \subsubsection{Canonical and liberal representations} In Logiweb (as in most computational systems) one has to distinguish between \indexintro{canonical} and \indexintro{liberal} representations. By a canonical representation we shall mean a representation scheme that assigns one and only one representation to each concept to be represented. By a liberal one we shall mean a representation scheme that assigns at least one. For each set of concepts to be represented, we shall assign a canonical as well as a liberal representation. And we shall make sure the representations are \indexintro{compatible} in the sense that the canonical representation of any concept is among the liberal representations of the concept. We make the convention that "[ bracket true end bracket ]" liberally represents truth and that any lambda abstraction liberally represents falsehood. This convention is compatible with the convention that "[ bracket true end bracket ]" represents truth and "[ bracket true raw pair true end bracket ]" represents falsehood. "[ bracket true end bracket ]"\footnote{It is generally considered to be bad style to start a sentence with a formula. But, in my opinion, the reasons for deprecating such opening formulas disappear when formulas are consistently surrounded by brackets.} of Map Theory and Logiweb corresponds to Nil in Lisp and Null in C. Hence, the convention to let "[ bracket true end bracket ]" represent truth and anything else falsehood is opposite to the choice made in Lisp and C. But the choice is in line with G\"!{o}dels choice to let 0 denote truth. G\"!{o}dels choice to make the simplest possible data structure represent truth and everything else denote falsehood is a smart one; it has the consequence that when programming primitive recursive functions, one tends to treat the simple case first and the recursive case afterwards which enhances the readability of the code. G\"!{o}dels 1931 paper \cite{godel} is the best example I have ever seen of ``literate programming'', and the syntax of that particular paper has been a driving force in the development of Logiweb since 1984 where the first version of the ``Pyk'' compiler was implemented. The present implementation of Logiweb depends heavily on the existence of \TeX\ and the World Wide Web. \subsubsection{Eager pairs} We now introduce an eager version of "[ bracket var x raw pair var y end bracket ]". In many situations, the eager version is more efficient to compute than the lazy one. Define \display{"[ math define value of var x guard var y as if var x then var y else var y end if end define end math ]"} \display{"[ math define value of var x eager pair var y as var x guard var y guard var x raw pair var y end define end math ]"} The \indexintro{guard} construct "[ bracket var x guard var y end bracket ]" equals "[ bracket bottom end bracket ]" whenever "[ bracket var x end bracket ]" equals "[ bracket bottom end bracket ]" and equals "[ bracket var y end bracket ]" otherwise. In Logiweb, one may use guards when one needs the value of one construct "[ bracket var y end bracket ]" but also wants to force another construct "[ bracket var x end bracket ]" to be computed. The guard construct is used in the definition of the \indexintro{eager} pair "[ bracket var x eager pair var y end bracket ]" above. Computation of "[ bracket var x eager pair var y end bracket ]" forces "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" to be computed. Whenever "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" differ from "[ bracket bottom end bracket ]", the eager pair equals the raw pair. We shall say that "[ bracket var x eager pair var y end bracket ]" is \indexintro{strict} in "[ bracket var x end bracket ]" because "[ bracket bottom eager pair var y math equal bottom end bracket ]" for all maps "[ bracket var y end bracket ]". Similarly, we shall say that "[ bracket var x eager pair var y end bracket ]" is \indexintro{strict} in "[ bracket var y end bracket ]" because "[ bracket var x eager pair bottom math equal bottom end bracket ]" for all maps "[ bracket var x end bracket ]". Furthermore, we shall say that "[ bracket var x eager pair var y end bracket ]" is ``strict'' (without mentioning a particular argument) because it is strict in all arguments. We shall say that "[ bracket var x raw pair var y end bracket ]" is \indexintro{lazy} in "[ bracket var x end bracket ]" because it is not strict in "[ bracket var x end bracket ]" and lazy in "[ bracket var y end bracket ]" for similar reasons. We shall say that "[ bracket var x raw pair var y end bracket ]" is ``lazy'' (without mentioning a particular argument) because it is lazy in at least one argument. \subsection{Cardinals} \subsubsection{Untagged cardinals} \index{cardinal number}\intro{Cardinal numbers} are the numbers ``one'', ``two'', ``three'', and so on as opposed to the \index{ordinal number}\intro{ordinal numbers} ``first'', ``second'', ``third'', and so on. In set theory, the words ``cardinal'' and ``ordinal'' are used in a somewhat technical sense in which cardinals and ordinals may be infinite. We shall not use the words in that sense here. In programming context, the word ``cardinal'' is sometimes simply used as a synonym for ``natural number''. We shall use the word in that sense here. We shall use "[ bracket "b_0" eager pair "b_1" eager pair "\cdots" eager pair "b_{n-1}" eager pair true end bracket ]" to represent \display{"[ big bracket "\sum_{i=0}^{n-1} 2^i" , if "b_i" then "0" else "1" end if end bracket ]"} As an example, "[ bracket true eager pair false eager pair false eager pair true end bracket ]" represents six. The rightmost "[ bracket true end bracket ]" marks the end of the structure. The other elements, "[ bracket true end bracket ]", "[ bracket false end bracket ]", and "[ bracket false end bracket ]", are the bits of $[ 6 = 110_2 ]$, stated with the least significant bit first. \subsubsection{Operations on untagged cardinals} Define \display{"[ math define value of var x untagged double var y as if var x then if var y then true else var x eager pair var y end if else var x eager pair var y end if end define end math ]"} If "[ bracket var y end bracket ]" is an untagged cardinal, then "[ bracket true untagged double var y end bracket ]" represents two times "[ bracket var y end bracket ]" and "[ bracket false untagged double var y end bracket ]" represents one plus two times "[ bracket var y end bracket ]". "[ bracket var x untagged double var y end bracket ]" is right associative so that e.g.\ "[ bracket true untagged double false untagged double true end bracket ]" equals "[ bracket true untagged double identity false untagged double true end identity end bracket ]" which in turn equals two. The set of untagged cardinals is the smallest set that contains "[ bracket true end bracket ]" (which represents zero) and which contains "[ bracket true untagged double var y end bracket ]" and "[ bracket false untagged double var y end bracket ]" whenever it contains "[ bracket var y end bracket ]". Now define \display{"[ math define value of var x cardinal retract as if var x then true else var x raw head boolean retract untagged double var x raw tail cardinal retract end if end define end math ]"} For all untagged cardinals "[ bracket var x end bracket ]" we have "[ bracket var x cardinal retract math equal var x end bracket ]". Furthermore we have "[ bracket bottom cardinal retract math equal bottom end bracket ]". We shall say that "[ bracket var x end bracket ]" is a \indexintro{lifted, untagged cardinal} if "[ bracket var x end bracket ]" is an untagged cardinal or equals "[ bracket bottom end bracket ]". "[ bracket var x cardinal retract math equal var x end bracket ]" if and only if "[ bracket var x end bracket ]" is a lifted, untagged cardinal. Moreover, "[ bracket var x cardinal retract end bracket ]" is a lifted, untagged cardinal for all maps "[ bracket var x end bracket ]". Hence, "[ bracket var x cardinal retract end bracket ]" is a construct that leaves lifted, untagged cardinals alone and converts everything else to lifted, untagged cardinals. From the remarks above it follows that "[ bracket var x cardinal retract end bracket ]" is \indexintro{idempotent} in the sense that "[ bracket var x cardinal retract cardinal retract math equal var x cardinal retract end bracket ]" for all maps "[ bracket var x end bracket ]". We shall say that an operation is a \indexintro{normalization construct} or \indexintro{retract} for a set "[ bracket "S" end bracket ]" if the operation is unary, strict, idempotent, and its range equals "[ bracket " S \cup \{ "[ bottom ]" \} " end bracket ]". Hence, "[ bracket var x cardinal retract end bracket ]" is a retract for untagged cardinals. \subsubsection{Retracts and representations} Given a map "[ bracket var x end bracket ]" one may use the liberal representation of Booleans to translate the map to a Boolean and then use the canonical representation to translate the Boolean back to a map. The operation thus defined is a retract of Booleans: \display{"[ math define value of var x boolean retract as if var x then true else false end if end define end math ]"} In general, any pair consisting of a liberal and a canonical representation defines a retract. \subsubsection{The untagged cardinals from zero to nine} Define "[ math define value of untagged zero as true end define end math ]", "[ math define value of untagged one as false untagged double untagged zero end define end math ]", "[ math define value of untagged two as true untagged double untagged one end define end math ]", "[ math define value of untagged three as false untagged double untagged one end define end math ]", "[ math define value of untagged four as true untagged double untagged two end define end math ]", "[ math define value of untagged five as false untagged double untagged two end define end math ]", "[ math define value of untagged six as true untagged double untagged three end define end math ]", "[ math define value of untagged seven as false untagged double untagged three end define end math ]", "[ math define value of untagged eight as true untagged double untagged four end define end math ]", and "[ math define value of untagged nine as false untagged double untagged four end define end math ]". \subsubsection{Tagged cardinals} For all untagged cardinals "[ bracket var y end bracket ]" we shall refer to "[ bracket true eager pair var y end bracket ]" as the corresponding \indexintro{tagged cardinal}. "[ bracket true end bracket ]" in "[ bracket true eager pair var y end bracket ]" is a \indexintro{tag} which, in a moment, allows to distringuish tagged cardinals from other data structures. \subsubsection{Operations on tagged cardinals} For all tagged cardinals "[ bracket var x end bracket ]", \display{"[ math define value of var x cardinal untag as if var x raw head then var x raw tail else true end if end define end math ]"} is the corresponding untagged cardinal. The untag operation maps data other than tagged cardinals to untagged zero or bottom. Now define \display{"[ math introduce value of var x double var y as true eager pair var x boolean retract eager pair var y cardinal untag cardinal retract end introduce end math ]"} If "[ bracket var y end bracket ]" is a tagged cardinal, then "[ bracket true double var y end bracket ]" represents two times "[ bracket var y end bracket ]" and "[ bracket false double var y end bracket ]" represents one plus two times "[ bracket var y end bracket ]". "[ math introduce value of zero as true raw pair true end introduce end math ]" is a tagged zero. The set of tagged cardinals is the smallest set that contains "[ bracket zero end bracket ]" and which contains "[ bracket true double var y end bracket ]" and "[ bracket false double var y end bracket ]" whenever it contains "[ bracket var y end bracket ]". \subsubsection{The tagged cardinals from one to nine} Define "[ math define value of one as false double zero end define end math ]", "[ math define value of two as true double one end define end math ]", "[ math define value of three as false double one end define end math ]", "[ math define value of four as true double two end define end math ]", "[ math define value of five as false double two end define end math ]", "[ math define value of six as true double three end define end math ]", "[ math define value of seven as false double three end define end math ]", "[ math define value of eight as true double four end define end math ]", and "[ math define value of nine as false double four end define end math ]" \subsection{Tagged trees} \subsubsection{Tagged pairs} For all "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]", we shall refer to \display{"[ math define value of var x tagged pair var y as identity untagged zero eager pair untagged zero eager pair true end identity eager pair var x eager pair var y end define end math ]"} as the \indexintro{tagged pair} of "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]". In "[ bracket identity untagged zero eager pair untagged zero eager pair true end identity eager pair var x eager pair var y end bracket ]" we shall refer to "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" as the head and tail, respectively, of the tagged pair. The set of \index{tagged Peano tree}\intro{tagged Peano trees} is the smallest set which contains "[ bracket true end bracket ]" and which contains "[ bracket var x tagged pair var y end bracket ]" whenever "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" are tagged Peano trees. \subsubsection{Cardinal trees} The set of \index{cardinal tree}\intro{cardinal trees} is the smallest set which contains "[ bracket true end bracket ]" and all tagged cardinals and which contains "[ bracket var x tagged pair var y end bracket ]" whenever "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" are cardinal trees. Cardinal trees are even more suited to replace G\"!{o}del numbers than Peano trees are. For that reason, Logiweb represents terms by Cardinal trees. In Logiweb, terms are represented by Cardinal trees as follows: Every operation in Logiweb is identified by a \indexintro{reference cardinal} "[ bracket var r end bracket ]" and an \indexintro{id} "[ bracket var i end bracket ]", which is also a cardinal. The reference cardinal uniquely identifies the home page of the operation, which is the page that introduces the operation. The id is a cardinal which identifies the operation among all operations introduced by that page. In Logiweb, an operation with reference cardinal "[ bracket var r end bracket ]" and id "[ bracket var i end bracket ]" applied to arguments is represented by the cardinal tree "[ bracket identity identity var r eager pair var i eager pair var x end identity eager pair var y eager pair "\cdots" eager pair var z eager pair true end identity end bracket ]" where "[ bracket var y, ",\ldots,", var z end bracket ]" are representations of the arguments and "[ bracket var x end bracket ]" is a structure which is ignored by Logiweb except when generating human readable error messages ("[ bracket var x end bracket ]" indicates the location the operation in the body before macro expansion so that a browser can locate and highlight it). \subsubsection{Tagged maps} We shall refer to \display{"[ math define value of map tag var x end tag as identity untagged zero eager pair untagged one eager pair true end identity raw pair var x end define end math ]"} as a \indexintro{tagged map} where "[ bracket untagged zero eager pair untagged one eager pair true end bracket ]" is the tag and "[ bracket var x end bracket ]" is the map itself. The set of \index{tagged tree}\intro{tagged trees} is the smallest set which contains "[ bracket true end bracket ]" and all tagged cardinals, which contains "[ bracket var x tagged pair var y end bracket ]" whenever "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" are tagged trees, and which contains "[ bracket identity untagged zero eager pair untagged one eager pair true end identity raw pair var x end bracket ]" for all maps "[ bracket var x end bracket ]". \subsubsection{The retract for tagged trees} We define the retract for tagged trees thus: \display{"[ math introduce value of var x tagged retract as if var x then true else if var x raw head then true eager pair var x raw tail cardinal retract else if var x raw head raw tail raw head then var x raw tail raw head tagged retract tagged pair var x raw tail raw tail tagged retract else map tag var x raw tail end tag end if end if end if end introduce end math ]"} We define the constructor operation for tagged pairs such that it normalises its arguments and, hence, is guaranteed to return "[ bracket bottom end bracket ]" or a tagged tree: \display{"[ math introduce value of var x pair var y as var x tagged retract tagged pair var y tagged retract end introduce end math ]"} Operations that retract their arguments allow certain optimizations to occur behind the scene (c.f. Section \ref{optimization}). \subsubsection{Predicates on tagged trees} The following predicate tests for being data (as opposed to being a tagged map): \display{"[ math introduce value of var x is data as var x tagged retract raw head raw tail raw head boolean retract end introduce end math ]"} The following predicate tests for being a cardinal: \display{"[ math introduce value of var x is cardinal as if var x then false else var x tagged retract raw head boolean retract end if end introduce end math ]"} We shall say that "[ bracket zero end bracket ]" is \indexintro{singular} among tagged cardinals, that "[ bracket true end bracket ]" is singular among tagged peano trees, and that "[ bracket map tag true end tag end bracket ]" is singular among tagged maps. Non-singular entities are called \indexintro{regular}. The following predicate tests for singularity: \display{"[ math introduce value of var x is singular as var x tagged retract raw tail boolean retract end introduce end math ]"} \subsubsection{Operations on tagged trees} We define the head of a tagged cardinal "[ bracket var x end bracket ]" to be "[ bracket true end bracket ]" if "[ bracket var x end bracket ]" is even and "[ bracket false end bracket ]" otherwise. All operations on tagged trees are defined such that they retract their arguments before operating on them. The head operation is defined thus: \display{"[ math introduce value of var x head as if var x is data then var x tagged retract raw tail raw head else true end if end introduce end math ]"} We define the tail of a tagged cardinal "[ bracket var x end bracket ]" to be "[ bracket var x end bracket ]" integer divided by two (i.e.\ divided by two and rounded to the nearest cardinal in the direction of minus infinity). The tail of a tagged pair is the second component of the pair. The tail of a tagged map or "[ bracket true end bracket ]" equals "[ bracket true end bracket ]": \display{"[ math introduce value of var x tail as if var x is data then if var x is cardinal then true eager pair var x tagged retract raw tail raw tail else var x tagged retract raw tail raw tail end if else true end if end introduce end math ]"} Accessors for the zeroth to ninth element of a list "[ bracket var x end bracket ]" read \tex{"[ math tex define var x zeroth as "#1. {}^{0}" end define end math ]"}"[ math define value of var x zeroth as var x head end define end math ]"\footnote{"[ math pyk define var x zeroth as "* zeroth" end define end math ]"}, % \index{x first "[ bracket var x first end bracket ]"}% \index{\alpha x first @\back "[ bracket var x first end bracket ]" x first}% \tex{"[ math tex define var x first as "#1. {}^{1}" end define end math ]"}"[ math define value of var x first as var x tail zeroth end define end math ]"\footnote{"[ math pyk define var x first as "* first" end define end math ]"}, % \tex{"[ math tex define var x second as "#1. {}^{2}" end define end math ]"}"[ math define value of var x second as var x tail first end define end math ]"\footnote{"[ math pyk define var x second as "* second" end define end math ]"}, % \tex{"[ math tex define var x third as "#1. {}^{3}" end define end math ]"}"[ math define value of var x third as var x tail second end define end math ]"\footnote{"[ math pyk define var x third as "* third" end define end math ]"}, % \tex{"[ math tex define var x fourth as "#1. {}^{4}" end define end math ]"}"[ math define value of var x fourth as var x tail third end define end math ]"\footnote{"[ math pyk define var x fourth as "* fourth" end define end math ]"}, % \tex{"[ math tex define var x fifth as "#1. {}^{5}" end define end math ]"}"[ math define value of var x fifth as var x tail fourth end define end math ]"\footnote{"[ math pyk define var x fifth as "* fifth" end define end math ]"}, % \tex{"[ math tex define var x sixth as "#1. {}^{6}" end define end math ]"}"[ math define value of var x sixth as var x tail fifth end define end math ]"\footnote{"[ math pyk define var x sixth as "* sixth" end define end math ]"}, % \tex{"[ math tex define var x seventh as "#1. {}^{7}" end define end math ]"}"[ math define value of var x seventh as var x tail sixth end define end math ]"\footnote{"[ math pyk define var x seventh as "* seventh" end define end math ]"}, % \tex{"[ math tex define var x eighth as "#1. {}^{8}" end define end math ]"}"[ math define value of var x eighth as var x tail seventh end define end math ]"\footnote{"[ math pyk define var x eighth as "* eighth" end define end math ]"}, and % \tex{"[ math tex define var x ninth as "#1. {}^{9}" end define end math ]"}"[ math define value of var x ninth as var x tail eighth end define end math ]"\footnote{"[ math pyk define var x ninth as "* ninth" end define end math ]"}. \subsubsection{Selection} The following operation is a retracting if-then-else construct which plays an important role in connection with optimizations and fitness and strictness analysis that occur behind the scene: \display{"[ math introduce value of tagged if var x then var y else var z end if as if var x tagged retract then var y tagged retract else var z tagged retract end if end introduce end math ]"} We shall use selection \display{"[ math introduce value of var x select var y else var z end select as tagged if var x then var y else var z end if end introduce end math ]"} as an alternative for "[ bracket tagged if var x then var y else var z end if end bracket ]". It would be very natural to macro define selection, but macro definitions depend on the Logiweb self-interpretter which in turn depends on the definitions presented on the present page. To keep the present page simple and to the point, we omit introducing the notion of macro definitions and, hence, avoid macro defining selection. \subsubsection{Semitagged maps} We introduce a \indexintro{semitagged} representation of maps as follows: \begin{enumerate} \item The canonical representation of a map "[ bracket var m end bracket ]" is "[ bracket map tag var m end tag end bracket ]". \item Any tagged tree "[ bracket var x end bracket ]" liberally represents the map "[ bracket tagged if var x is data then var x else var x raw tail end if end bracket ]". \end{enumerate} "[ bracket map untag var x end untag end bracket ]" returns the map represented by the semitagged "[ bracket var x end bracket ]". The untagger "[ bracket map untag var x end untag end bracket ]" leaves tagged data untouched and untags tagged maps: \display{"[ math define value of raw map untag var x end untag as if var x is data then var x else var x raw tail end if end define end math ]"} \display{"[ math define value of map untag var x end untag as raw map untag var x tagged retract end untag end define end math ]"} The construct "[ bracket apply var f to var x end apply end bracket ]" applies a tagged map "[ bracket var f end bracket ]" to a semitagged map "[ bracket var x end bracket ]" and returns the result as a tagged map. If "[ bracket var f end bracket ]" is tagged data then "[ bracket apply var f to var x end apply end bracket ]" equals "[ bracket var f end bracket ]": \display{"[ math introduce value of apply var f to var x end apply as apply one var f tagged retract to var x tagged retract end apply end introduce end math ]"} \display{"[ math define value of apply one var f to var x end apply as var f is data select tagged if var x is data then var f else var f end if else tagged if var x is data then map tag var f raw tail apply var x end tag else map tag var f raw tail apply identity var x raw tail end identity end tag end if end select end define end math ]"} A short version of "[ bracket apply var f to var x end apply end bracket ]" reads: \display{"[ math define value of var f tagged apply var x as apply var f to var x end apply end define end math ]"} We shall also introduce a tagged version of lambda abstraction. Logiweb, however, does not support value definitions of new binding constructs. This is convenient for designers of proof systems who can rely on lambda being the only binding construct in Logiweb. In Logiweb it is the intension that new binding constructs should be macro defined so that binding constructs are expanded into lambdas before proof checking. At the present stage of the bootstrap of Logiweb, however, we do not yet have macro definitions. For that reason we introduce a unary operator "[ bracket tagging var x end bracket ]" and use "[ bracket tagging lambda var x dot var y end bracket ]" to denote tagged lambda abstraction. At a later stage we introduce a construct that macro expands into "[ bracket tagging lambda var x dot var y end bracket ]". We define "[ bracket tagging var x end bracket ]" thus: \display{"[ math introduce value of tagging var x as map tag lambda var u dot map untag var x apply map tag var u end tag end untag end tag end introduce end math ]"} "[ bracket normalizing untag var x end untag end bracket ]" is a version of "[ bracket map untag var x end untag end bracket ]" which untags and then normalizes a semitagged map. \display{"[ math introduce value of normalizing untag var x end untag as map untag var x end untag tagged retract end introduce end math ]"} \subsection{Optimization}\label{optimization} \subsubsection{On-stage and off-stage semantics} The Logiweb computing engine maintains an \indexintro{on-stage semantics} and \indexintro{off-stage semantics}. The on-stage semantics concerns the input-output relation of operations. The off-stage semantics concerns the run time and memory usage of operations. One needs to know the on-stage semantics to make correct programs and one needs to know the off-stage semantics to make efficient programs. The on-stage semantics of operations must be the same on all implementations of Logiweb. The off-stage semantics may vary considerably. For that reason, it is only possible to say something definite about the on-stage semantics. The remarks on off-stage semantics below concern one, particular implementation of the Logiweb computing engine which we shall refer to as the \indexintro{first edition engine}. The on-stage semantics of "[ bracket var x head end bracket ]" is that the Logiweb computing engine reduces "[ bracket var x head end bracket ]" to "[ bracket var x tagged retract raw tail raw head end bracket ]" because of the definition "[ math introduce value of var x head as var x tagged retract raw tail raw head end introduce end math ]". Logiweb has three kinds of \indexintro{revelation} constructs that connect syntactic constructs with semantic concepts. The three kinds of revelations are called proclamations, definititions, and introductions. The revelation of "[ bracket var x head end bracket ]" above is an introduction rather than a definition. One can see that by looking at the equal sign which deviates from a normal equal sign. The first edition engine maintains a list of constructs that it can compute using hardcoded functions. Whenever the first edition engine sees an introduction, it runs through its list of known constructs to see, if it can recognize the construct being introduced. When doing so, the first edition engine is insensitive to names of bound variables, names of parameters, and names of auxiliary functions, but apart from that the engine merely recognises an introduction if its right hand side is identical to something the engine knows. If the first edition engine cannot recognize an introduction, it prints a warning and treats the introduction as if it were a definition. The notion of introduction is proclaimed: "[ math proclaim introduce var x of var y as var z end introduce as text "introduce" end text end proclaim end math ]". On the first-edition engine, the off-stage semantics of "[ bracket var x head end bracket ]" is that, behind the scenes, the engine converts the argument of "[ bracket var x head end bracket ]" to an internal, efficient representation, then manipulates that internal representation, and then converts the internal representation back to maps. The conversion back and forth takes time, but the manipulation of the internal representation is fast. When computing a single head operation, it does not pay off to round the internal representation. But when performing a long sequence of head and other, hardcoded operations, the engine merely has to convert back and forth once at the beginning and end of the computation. \subsubsection{Optimized bottom} The revelation "[ math introduce value of bottom as identity lambda var x dot var x apply var x end identity apply identity lambda var x dot var x apply var x end identity end introduce end math ]" of bottom is an introduction Bottom has the property that evaluation of it never returns a value. Genuine bottom "[ bracket identity lambda var x dot var x apply var x end identity apply identity lambda var x dot var x apply var x end identity end bracket ]" never returns a value because it makes the computer run forever. As any other optimized construct, optimized bottom must have exactly the same behavior as genuine bottom and, hence, optimized bottom must avoid returning a value. When evaluated on the first edition engine, optimized bottom signals an irrecoverable error and, hence, satisfies the requirements. Another valid implementation of optimized bottom would be to let it decrease the priority of the current operating system process so much that the process received no more cpu-time. The Logiweb machine described later is multitasking, so the latter implementation of optimized bottom would be reasonable there. Please never do ``bessermachen'' by introducing a construct that can test for optimized bottomness. That would ruin the applicative behaviour of the Logiweb reduction system. If a bottomness test seems desirable to have in some situation, consider using exceptions and exception handling instead; and don't try to solve Turings halting problem. \subsubsection{Strictness} Define \display{"[ math define value of var x and var y as var x select tagged if var y then true else false end if else tagged if var y then false else false end if end select end define end math ]"} We shall say that "[ bracket var x and var y end bracket ]" is \indexintro{strict} in its first argument because \display{"[ big bracket bottom and var y math equal bottom end bracket ]"} When an equation contains a free variable, it is understood that the equation holds for all values of the free variable. Hence, above, it is understood that the equation holds for all "[ bracket var y end bracket ]". We shall say that "[ bracket var x and var y end bracket ]" is strict in its second argument because \display{"[ big bracket var x and bottom math equal bottom end bracket ]"} We shall say that "[ bracket var x and var y end bracket ]" is strict because it is strict in all its arguments. \subsubsection{Types} We shall say that that the return value of "[ bracket var x and var y end bracket ]" is of \indexintro{type} tagged tree because "[ bracket identity var x and var y end identity tagged retract math equal var x and var y end bracket ]" We shall say that the first argument of "[ bracket var x and var y end bracket ]" is of type tagged tree because "[ bracket var x tagged retract and var y math equal var x and var y end bracket ]" Likewise, we shall say that the second argument of "[ bracket var x and var y end bracket ]" is of type tagged tree because "[ bracket var x and var y tagged retract math equal var x and var y end bracket ]" Summing up, we shall say that "[ bracket var x and var y end bracket ]" is an \indexintro{operation over} tagged trees because its return value and all its arguments are of type tagged tree. Being an operation over tagged trees does not exclude being an operation over other types as well. \subsubsection{User defined strict operations} We shall say that an operation is \indexintro{fit for optimization} if the first edition engine can prove that the operation is a strict operation over tagged trees. The first edition engine translates operations that are fit for optimization in a particularly efficient way. Users of the first edition engine need some understanding of fitness for optimization in order to make definitions that the first edition engine can compute efficiently. We shall refer to "[ bracket true end bracket ]", "[ bracket zero end bracket ]", "[ bracket var x tagged retract end bracket ]", "[ bracket var x double var y end bracket ]", "[ bracket var x pair var y end bracket ]", "[ bracket var x head end bracket ]", "[ bracket var x tail end bracket ]", "[ bracket var x is singular end bracket ]", "[ bracket var x is cardinal end bracket ]", and "[ bracket tagged if var x then var y else var z end if end bracket ]" as the \indexintro{basic tagged tree operations}. The first edition engine knows that the basic tagged tree operations are operations over tagged trees and that all but "[ bracket tagged if var x then var y else var z end if end bracket ]" are strict. From this the first edition engine can deduce that all operations defined from these constructs are operations over tagged trees. This includes operations that are defined by recursion or mutual recursion. There is one pathological exception, though. A projection operation like "[ bracket "f(" , var x , "," , var y , ")" math equal var x end bracket ]" may be defined using the functions above zero times but is not an operation over tagged trees. \subsubsection{Fitness analysis} Operations defined from the basic tagged tree operations need not be strict because "[ bracket tagged if var x then var y else var z end if end bracket ]" is non-strict. But the first edition engine performs fitness analysis as follows: The engine classifies all operations as ``fit'', ``unfit'', or ``possibly fit'' for optimization. As a fourth classification, the engine classifies "[ bracket tagged if var x then var y else var z end if end bracket ]" as a ``conditional''. Among the four elementary, computable constructs, the engine classifies "[ bracket true end bracket ]" as fit and "[ bracket lambda var x dot var y end bracket ]", "[ bracket var x apply var y end bracket ]", and "[ bracket if var x then var y else var z end if end bracket ]" as unfit. Among the basic tagged tree operations the engine classifies "[ bracket tagged if var x then var y else var z end if end bracket ]" as a conditional and the other ones as fit. The engine classifies all other operations as possibly fit, except that it classifies projection operations as unfit. Then the engine reclassifies possibly fit operations as unfit according to certain rules described in the following. And when no further operations can be reclassified as unfit, all remaining possibly fit operations are reclassified as fit. In other words, operations are considered fit unless they are provably unfit. This happens to be completely safe. Possibly fit operations are reclassified as unfit according to two rules: A possibly fit operation is reclassified as unfit if its definition contains an unfit operation. A possibly fit operation if reclassified as unfit if some variable one the left hand side of the definition does not occur strict in the right hand side where ``occurs strict'' is defined in the next section. \subsubsection{Strict variables} Possibly fit operations are reclassified as unfit according to two rules. The first is rather simple: A possibly fit operation is reclassified as unfit if its definition contains an unfit operation. The other rule is more complex and makes reference to the notion of a \indexintro{strict variable}. The notion of a strict variable is similar to the notion of a free variable. In fact, the strict variables of a term comprise a subset of the free variables of the term. The notion of strict variables of a term "[ bracket meta a end bracket ]" is defined by structural induction in "[ bracket meta a end bracket ]" by the following three cases: If the term "[ bracket meta a end bracket ]" is the variable "[ bracket var x end bracket ]", then the strict variables of "[ bracket meta a end bracket ]" comprises "[ bracket var x end bracket ]". If the term "[ bracket meta a end bracket ]" is an operation applied to subtrees and the operation is not classified as conditional, then the free variables of "[ bracket meta a end bracket ]" comprises the strict variables of the subtrees. If the term "[ bracket meta a end bracket ]" is a conditional operation applied to three subtrees like "[ bracket tagged if var x then var y else var z end if end bracket ]", then the strict variables of "[ bracket meta a end bracket ]" comprises the strict variables of "[ bracket var x end bracket ]" plus all variables that occur strict in both "[ bracket var y end bracket ]" and "[ bracket var z end bracket ]". As an example, "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" are the strict variables of "[ bracket tagged if var x then var y else tagged if var y then var z else var y end if end if end bracket ]". \subsubsection{Fitness of conjunction} The first edition engine classifies \display{"[ math define value of var x and var y as var x select tagged if var y then true else false end if else tagged if var y then false else false end if end select end define end math ]"} as fit for optimization because conjunction is not the conditional construct and because the engine does not classify conjunction as unfit. The engine does not classify conjunction as unfit because the right hand side of the definition above contains no unfit operations and because both variables, "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]", occur strict in the right hand side. \subsubsection{Logical connectives} Define \display{"[ math define value of not var x as tagged if var x then false else true end if end define end math ]"} \display{"[ math define value of var x or var y as var x select tagged if var y then true else true end if else tagged if var y then true else false end if end select end define end math ]"} The operations above are fit for optimization. Sometimes, when programming, it is useful to have lazy versions of the connectives that compute the first argument before they decide whether or not to compute the second, but we shall not need them here. If such lazy connectives are needed, one should consider to macro define them rather than value defining them. If lazy connectives are value defined, they will be classified as unfit for optimization. On the contrary, if they are macro defined they will be macro expanded away before fitness analysis and, hence, they can be used for defining operations that are fit for optimization. \subsubsection{Auxiliary operations} Parentheses cannot occur in definitions that are fit for optimization since "[ bracket identity var x end identity end bracket ]" does not normalize its argument. Later, we macro define parentheses. Once parentheses are macro defined, they disappear from terms before fitness analysis. Hence, once parentheses are macro defined, they can be used in optimizable definitions. Until we macro define parentheses, we shall use a normalizing version of parentheses: \display{"[ math define value of tagged parenthesis var x end tagged as var x tagged retract end define end math ]"} The following normalizing guard operation can be used in definitions for making the defined function strict: \display{"[ math introduce value of var x tagged guard var y as tagged if var x then var y else var y end if end introduce end math ]"} \subsubsection{Equality} Define \display{"[ math introduce value of var x tagged equal var y as var x is data select tagged if var y is data then var x data equal var y else false end if else tagged if var y is data then false else true end if end select end introduce end math ]"} \display{"[ math define value of var x data equal var y as var x is cardinal select tagged if var y is cardinal then var x cardinal equal var y else false end if else tagged if var y is cardinal then false else var x peano equal var y end if end select end define end math ]"} \display{"[ math define value of var x cardinal equal var y as var x is singular select tagged if var y is singular then true else false end if else tagged if var y is singular then false else var x head boolean equal var y head and var x tail cardinal equal var y tail end if end select end define end math ]"} \display{"[ math define value of var x boolean equal var y as var x select tagged if var y then true else false end if else tagged if var y then false else true end if end select end define end math ]"} \display{"[ math define value of var x peano equal var y as var x is singular select tagged if var y is singular then true else false end if else tagged if var y is singular then false else var x head tagged equal var y head and var x tail tagged equal var y tail end if end select end define end math ]"} "[ bracket var x tagged equal var y end bracket ]" is an example of an operation defined by mutual recursion which is fit for optimization. \subsection{Arithmetic} \subsubsection{Addition} Addition of cardinals is defined thus: % \index{\alpha x plus y @\back "[ bracket var x plus var y end bracket ]" x plus y}% % \index{x plus y "[ bracket var x plus var y end bracket ]"}% % \tex{"[ math tex define var x plus var y as "#1. + #2." end define end math ]"}% % \display{"[ math value define var x plus var y as tagged if var x is cardinal and var y is cardinal then var x plus zero var y else true end if end define end math ]"% % \footnote{"[ math pyk define var x plus var y as "* plus *" end define end math ]"}} % % \index{\alpha x plus zero y @\back "[ bracket var x plus zero var y end bracket ]" x plus zero y}% % \index{x plus zero y "[ bracket var x plus zero var y end bracket ]"}% % \tex{"[ math tex define var x plus zero var y as "#1. \mathop{+_0} #2." end define end math ]"}% % \display{"[ math value define var x plus zero var y as var x is singular select var y else var y is singular select var x else var x head select var y head select true double var x tail plus zero var y tail else false double var x tail plus zero var y tail end select else var y head select false double var x tail plus zero var y tail else true double var x tail plus one var y tail end select end select end select end select end define end math ]"% % \footnote{"[ math pyk define var x plus zero var y as "* plus zero *" end define end math ]"}} % % \index{\alpha x plus one y @\back "[ bracket var x plus one var y end bracket ]" x plus one y}% % \index{x plus one y "[ bracket var x plus one var y end bracket ]"}% % \tex{"[ math tex define var x plus one var y as "#1. \mathop{+_1} #2." end define end math ]"}% % \display{"[ math value define var x plus one var y as var x is singular select var y plus zero one else var y is singular select var x plus zero one else var x head select var y head select false double var x tail plus zero var y tail else true double var x tail plus one var y tail end select else var y head select true double var x tail plus one var y tail else false double var x tail plus one var y tail end select end select end select end select end define end math ]"% % \footnote{"[ math pyk define var x plus one var y as "* plus one *" end define end math ]"}} % \test{"[ math test true plus zero tagged equal true end test end math ]"} \test{"[ math test zero plus true tagged equal true end test end math ]"} \test{"[ math test true plus true tagged equal true end test end math ]"} \test{"[ math test zero plus zero tagged equal zero end test end math ]"} \test{"[ math test zero plus one tagged equal one end test end math ]"} \test{"[ math test zero plus two tagged equal two end test end math ]"} \test{"[ math test zero plus three tagged equal three end test end math ]"} \test{"[ math test one plus zero tagged equal one end test end math ]"} \test{"[ math test one plus one tagged equal two end test end math ]"} \test{"[ math test one plus two tagged equal three end test end math ]"} \test{"[ math test one plus three tagged equal four end test end math ]"} \test{"[ math test two plus zero tagged equal two end test end math ]"} \test{"[ math test two plus one tagged equal three end test end math ]"} \test{"[ math test two plus two tagged equal four end test end math ]"} \test{"[ math test two plus three tagged equal five end test end math ]"} \test{"[ math test three plus zero tagged equal three end test end math ]"} \test{"[ math test three plus one tagged equal four end test end math ]"} \test{"[ math test three plus two tagged equal five end test end math ]"} \test{"[ math test three plus three tagged equal six end test end math ]"} \subsubsection{Comparison} Comparison of cardinals is defined thus: % \index{\alpha x less y @\back "[ bracket var x less var y end bracket ]" x less y}% % \index{x less y "[ bracket var x less var y end bracket ]"}% % \tex{"[ math tex define var x less var y as "#1. < #2." end define end math ]"}% % \display{"[ math value define var x less var y as tagged if var x is cardinal and var y is cardinal then var x less zero var y else false end if end define end math ]"% % \footnote{"[ math pyk define var x less var y as "* less *" end define end math ]"}} % % \index{\alpha x less zero y @\back "[ bracket var x less zero var y end bracket ]" x less zero y}% % \index{x less zero y "[ bracket var x less zero var y end bracket ]"}% % \tex{"[ math tex define var x less zero var y as "#1. <' #2." end define end math ]"}% % \display{"[ math value define var x less zero var y as var y is singular select var x tagged guard false else var x is singular select true else var x head select var y head select var x tail less zero var y tail else var x tail less one var y tail end select else var y head select var x tail less zero var y tail else var x tail less zero var y tail end select end select end select end select end define end math ]"% % \footnote{"[ math pyk define var x less zero var y as "* less zero *" end define end math ]"}} % % \index{\alpha x less one y @\back "[ bracket var x less one var y end bracket ]" x less one y}% % \index{x less one y "[ bracket var x less one var y end bracket ]"}% % \tex{"[ math tex define var x less one var y as "#1. \le' #2." end define end math ]"}% % \display{"[ math value define var x less one var y as var x is singular select var y tagged guard true else var y is singular select false else var x head select var y head select var x tail less one var y tail else var x tail less one var y tail end select else var y head select var x tail less zero var y tail else var x tail less one var y tail end select end select end select end select end define end math ]"% % \footnote{"[ math pyk define var x less one var y as "* less one *" end define end math ]"}} % \test{"[ math test true less zero tagged equal false end test end math ]"} \test{"[ math test zero less true tagged equal false end test end math ]"} \test{"[ math test true less true tagged equal false end test end math ]"} \test{"[ math test zero less zero tagged equal false end test end math ]"} \test{"[ math test zero less one tagged equal true end test end math ]"} \test{"[ math test zero less two tagged equal true end test end math ]"} \test{"[ math test zero less three tagged equal true end test end math ]"} \test{"[ math test one less zero tagged equal false end test end math ]"} \test{"[ math test one less one tagged equal false end test end math ]"} \test{"[ math test one less two tagged equal true end test end math ]"} \test{"[ math test one less three tagged equal true end test end math ]"} \test{"[ math test two less zero tagged equal false end test end math ]"} \test{"[ math test two less one tagged equal false end test end math ]"} \test{"[ math test two less two tagged equal false end test end math ]"} \test{"[ math test two less three tagged equal true end test end math ]"} \test{"[ math test three less zero tagged equal false end test end math ]"} \test{"[ math test three less one tagged equal false end test end math ]"} \test{"[ math test three less two tagged equal false end test end math ]"} \test{"[ math test three less three tagged equal false end test end math ]"} \subsubsection{Subtraction} Subtraction of cardinals is defined below. Subtraction yields zero when a large number is subtracted from a small. % \index{\alpha x minus y @\back "[ bracket var x minus var y end bracket ]" x minus y}% % \index{x minus y "[ bracket var x minus var y end bracket ]"}% % \tex{"[ math tex define var x minus var y as "#1. - #2." end define end math ]"}% % \display{"[ math value define var x minus var y as tagged if var x is cardinal and var y is cardinal then tagged if var x less var y then zero else var x minus zero var y end if else true end if end define end math ]"% % \footnote{"[ math pyk define var x minus var y as "* minus *" end define end math ]"}} % % \index{\alpha x minus zero y @\back "[ bracket var x minus zero var y end bracket ]" x minus zero y}% % \index{x minus zero y "[ bracket var x minus zero var y end bracket ]"}% % \tex{"[ math tex define var x minus zero var y as "#1. \mathop{-_0} #2." end define end math ]"}% % \display{"[ math value define var x minus zero var y as var y is singular select var x else var x head select var y head select true double var x tail minus zero var y tail else false double var x tail minus one var y tail end select else var y head select false double var x tail minus zero var y tail else true double var x tail minus zero var y tail end select end select end select end define end math ]"% % \footnote{"[ math pyk define var x minus zero var y as "* minus zero *" end define end math ]"}} % % \index{\alpha x minus one y @\back "[ bracket var x minus one var y end bracket ]" x minus one y}% % \index{x minus one y "[ bracket var x minus one var y end bracket ]"}% % \tex{"[ math tex define var x minus one var y as "#1. \mathop{-_1} #2." end define end math ]"}% % \display{"[ math value define var x minus one var y as var y is singular select var x minus zero one else var x head select var y head select false double var x tail minus one var y tail else true double var x tail minus one var y tail end select else var y head select true double var x tail minus zero var y tail else false double var x tail minus one var y tail end select end select end select end define end math ]"% % \footnote{"[ math pyk define var x minus one var y as "* minus one *" end define end math ]"}} % \test{"[ math test true minus zero tagged equal true end test end math ]"} \test{"[ math test zero minus true tagged equal true end test end math ]"} \test{"[ math test true minus true tagged equal true end test end math ]"} \test{"[ math test zero minus zero tagged equal zero end test end math ]"} \test{"[ math test zero minus one tagged equal zero end test end math ]"} \test{"[ math test zero minus two tagged equal zero end test end math ]"} \test{"[ math test zero minus three tagged equal zero end test end math ]"} \test{"[ math test one minus zero tagged equal one end test end math ]"} \test{"[ math test one minus one tagged equal zero end test end math ]"} \test{"[ math test one minus two tagged equal zero end test end math ]"} \test{"[ math test one minus three tagged equal zero end test end math ]"} \test{"[ math test two minus zero tagged equal two end test end math ]"} \test{"[ math test two minus one tagged equal one end test end math ]"} \test{"[ math test two minus two tagged equal zero end test end math ]"} \test{"[ math test two minus three tagged equal zero end test end math ]"} \test{"[ math test three minus zero tagged equal three end test end math ]"} \test{"[ math test three minus one tagged equal two end test end math ]"} \test{"[ math test three minus two tagged equal one end test end math ]"} \test{"[ math test three minus three tagged equal zero end test end math ]"} \subsubsection{Multiplication} Multiplication of cardinals is defined thus: % \index{\alpha x times y @\back "[ bracket var x times var y end bracket ]" x times y}% % \index{x times y "[ bracket var x times var y end bracket ]"}% % \tex{"[ math tex define var x times var y as "#1. \cdot #2." end define end math ]"}% % \display{"[ math value define var x times var y as tagged if var x is cardinal and var y is cardinal then var x times zero var y else true end if end define end math ]"% % \footnote{"[ math pyk define var x times var y as "* times *" end define end math ]"}} % % \index{\alpha x times zero y @\back "[ bracket var x times zero var y end bracket ]" x times zero y}% % \index{x times zero y "[ bracket var x times zero var y end bracket ]"}% % \tex{"[ math tex define var x times zero var y as "#1. \cdot_0 #2." end define end math ]"}% % \display{"[ math value define var x times zero var y as var y is singular select var x tagged guard zero else var y head select true double var x times zero var y tail else tagged parenthesis true double var x times zero var y tail end tagged plus zero var x end select end select end define end math ]"% % \footnote{"[ math pyk define var x times zero var y as "* times zero *" end define end math ]"}} % \test{"[ math test true times zero tagged equal true end test end math ]"} \test{"[ math test zero times true tagged equal true end test end math ]"} \test{"[ math test true times true tagged equal true end test end math ]"} \test{"[ math test zero times zero tagged equal zero end test end math ]"} \test{"[ math test zero times one tagged equal zero end test end math ]"} \test{"[ math test zero times two tagged equal zero end test end math ]"} \test{"[ math test zero times three tagged equal zero end test end math ]"} \test{"[ math test one times zero tagged equal zero end test end math ]"} \test{"[ math test one times one tagged equal one end test end math ]"} \test{"[ math test one times two tagged equal two end test end math ]"} \test{"[ math test one times three tagged equal three end test end math ]"} \test{"[ math test two times zero tagged equal zero end test end math ]"} \test{"[ math test two times one tagged equal two end test end math ]"} \test{"[ math test two times two tagged equal four end test end math ]"} \test{"[ math test two times three tagged equal six end test end math ]"} \test{"[ math test three times zero tagged equal zero end test end math ]"} \test{"[ math test three times one tagged equal three end test end math ]"} \test{"[ math test three times two tagged equal six end test end math ]"} \test{"[ math test three times three tagged equal nine end test end math ]"} \subsubsection{Bit access} "[ bracket bit var x of var y end bit end bracket ]" is true if bit number "[ bracket var x end bracket ]" of the cardinal "[ bracket var y end bracket ]" is zero. The least significant bit is bit number zero. % \index{bit @\back "[ bracket bit var x of var y end bit end bracket ]" bit x of y end bit}% % \tex{"[ math tex define bit var x of var y end bit as " bit( #1. , #2. )" end define end math ]"}% % \display{"[ math value define bit var x of var y end bit as tagged if var x is cardinal and var y is cardinal then bit one var x of var y end bit else true end if end define end math ]"% % \footnote{"[ math pyk define bit var x of var y end bit as "bit * of * end bit" end define end math ]"}} % % \index{bit 1 @\back "[ bracket bit one var x of var y end bit end bracket ]" bit one x of y end bit}% % \tex{"[ math tex define bit one var x of var y end bit as " bit_1( #1. , #2. )" end define end math ]"}% % \display{"[ math value define bit one var x of var y end bit as tagged if var x is singular then var y head else bit var x minus one of var y tail end bit end if end define end math ]"% % \footnote{"[ math pyk define bit one var x of var y end bit as "bit one * of * end bit" end define end math ]"}} % \test{"[ math test bit true of zero end bit tagged equal true end test end math ]"} \test{"[ math test bit zero of true end bit tagged equal true end test end math ]"} \test{"[ math test bit true of true end bit tagged equal true end test end math ]"} \test{"[ math test bit zero of zero end bit tagged equal true end test end math ]"} \test{"[ math test bit zero of one end bit tagged equal false end test end math ]"} \test{"[ math test bit zero of two end bit tagged equal true end test end math ]"} \test{"[ math test bit zero of three end bit tagged equal false end test end math ]"} \test{"[ math test bit one of zero end bit tagged equal true end test end math ]"} \test{"[ math test bit one of one end bit tagged equal true end test end math ]"} \test{"[ math test bit one of two end bit tagged equal false end test end math ]"} \test{"[ math test bit one of three end bit tagged equal false end test end math ]"} \test{"[ math test bit two of zero end bit tagged equal true end test end math ]"} \test{"[ math test bit two of one end bit tagged equal true end test end math ]"} \test{"[ math test bit two of two end bit tagged equal true end test end math ]"} \test{"[ math test bit two of three end bit tagged equal true end test end math ]"} \test{"[ math test bit three of zero end bit tagged equal true end test end math ]"} \test{"[ math test bit three of one end bit tagged equal true end test end math ]"} \test{"[ math test bit three of two end bit tagged equal true end test end math ]"} \test{"[ math test bit three of three end bit tagged equal true end test end math ]"} \subsection{Quoting} \subsubsection{Terms} Terms have form "[ bracket identity var r pair var i pair var d end identity pair var a end bracket ]" where "[ bracket var r end bracket ]" and "[ bracket var i end bracket ]" are the reference and identifier, respectively, of the root symbol of the term and the argument list "[ bracket var a end bracket ]" is a list of terms. The debugging information "[ bracket var d end bracket ]" indicates the location of the root symbol on the page and allows a browser to highlight the root symbol even if the root symbol has been moved around by such processes as macro expansion. Accessors for the reference, identifier, and debug information of a term "[ bracket var x end bracket ]" read % \index{x ref "[ bracket var x ref end bracket ]"}% \index{r: "[ bracket var x ref end bracket ]" x ref}% \tex{"[ math tex define var x ref as "#1. {}^{r}" end define end math ]"}"[ math define value of var x ref as var x head head end define end math ]"\footnote{"[ math pyk define var x ref as "* ref" end define end math ]"}, % \index{x id "[ bracket var x id end bracket ]"}% \index{i: "[ bracket var x id end bracket ]" x id}% \tex{"[ math tex define var x id as "#1. {}^{i}" end define end math ]"}"[ math define value of var x id as var x head tail head end define end math ]"\footnote{"[ math pyk define var x id as "* id" end define end math ]"}, and % \index{x debug "[ bracket var x debug end bracket ]"}% \index{d: "[ bracket var x debug end bracket ]" x debug}% \tex{"[ math tex define var x debug as "#1. {}^{d}" end define end math ]"}"[ math define value of var x debug as var x head tail tail end define end math ]"\footnote{"[ math pyk define var x debug as "* debug" end define end math ]"}, % respectively. \index{x root "[ bracket var x root end bracket ]"}% \index{R: "[ bracket var x root end bracket ]" x root}% \tex{"[ math tex define var x root as "#1. {}^{R}" end define end math ]"}"[ math define value of var x root as var x ref pair var x id pair true end define end math ]"\footnote{"[ math pyk define var x root as "* root" end define end math ]"} % returns the root of the term "[ bracket var x end bracket ]" without debugging information. % \index{x term root equal y "[ bracket var x term root equal var y end bracket ]"}% % \index{r: "[ bracket var x term root equal var y end bracket ]" x term root equal y}% % \index{\alpha x term root equal y@\back "[ bracket var x term root equal var y end bracket ]" x term root equal y}% % \tex{"[ math tex define var x term root equal var y as "#1. \stackrel{r}{=} #2." end define end math ]"}% % "[ bracket var x term root equal var y end bracket ]"% % \footnote{"[ math pyk define var x term root equal var y as "* term root equal *" end define end math ]"} % is true if the roots of the terms "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" are equal except for debugging information: \display{"[ math define value of var x term root equal var y as tagged if var x ref tagged equal var y ref then var x id tagged equal var y id else false end if end define end math ]"} When testing two terms for identity, one should disregard debugging information. "[ bracket var x term equal var y end bracket ]" tests two terms "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" for identity disregarding debugging information: \display{"[ math define value of var x term equal var y as tagged if var x term root equal var y then var x tail term list equal var y tail else false end if end define end math ]"} "[ bracket var x term list equal var y end bracket ]" tests two lists "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" of terms for identity disregarding debugging information: \display{"[ math define value of var x term list equal var y as var x is atomic select tagged if var y is atomic then true else false end if else tagged if var y is atomic then false else tagged if var x head term equal var y head then var x tail term list equal var y tail else false end if end if end select end define end math ]"} \subsubsection{G{\"!o}del trees}\label{section:GodelTrees} In addition to the fundamental, computable constructs "[ bracket true end bracket ]", "[ bracket lambda var x dot var y end bracket ]", "[ bracket var f apply var x end bracket ]", and "[ bracket if var x then var y else var z end if end bracket ]" we introduce the \indexintro{quote} construct "[ bracket quote meta a end quote end bracket ]" for pragmatic reasons. The quote construct is computable but does not add to the computational power of the Logiweb engine. If it were omitted from Logiweb, one could replace it with a macro defined construct. The quote construct resembles ``quote'' in Lisp \cite{mccarthy60} and G{\"!o}del numbers as introduced in \cite{godel}. The reason for introducing quoting as a fundamental construct rather than macro defining it is that a macro defined quote would expand into rather large terms. In other words, quotes are introduced to enhance the efficiency of the macro facility. End users will probably prefer ``backquote'' like macros that are based on the quote construct rather than using quote raw. The quote construct is proclaimed thus: \display{"[ math proclaim quote var x end quote as text "quote" end text end proclaim end math ]"} For a term "[ bracket meta a end bracket ]", "[ bracket quote meta a end quote end bracket ]" denotes the tagged tree that represents "[ bracket meta a end bracket ]". As an example, \display{"[ big bracket quote var x tagged equal var y end quote end bracket ]"} is the tagged tree that represents the term "[ bracket var x tagged equal var y end bracket ]". We have \display{"[ big bracket quote var x tagged equal var y end quote math equal identity var r pair var i pair var d pair true end identity pair quote var x end quote pair quote var y end quote pair true end bracket ]"} except for debugging information present in each occurrence of "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]". The "[ bracket var r end bracket ]" and "[ bracket var i end bracket ]" above are the reference and identifier, respectively, of the "[ bracket x tagged equal x end bracket ]" symbol. The reference "[ bracket var r end bracket ]" is a large cardinal (around 200 bits long) which identifies the home page of the "[ bracket x tagged equal x end bracket ]" symbol, i.e.\ the page on which the "[ bracket x tagged equal x end bracket ]" symbol is introduced. The identifier "[ bracket var i end bracket ]" identifies the "[ bracket x tagged equal x end bracket ]" symbol among all symbols introduced on that page. The "[ bracket var d end bracket ]" above is debugging information that indicates the location of the particular instance of the "[ bracket x tagged equal x end bracket ]" symbol. The value of "[ bracket var d end bracket ]" has form "[ bracket var p sub one end sub pair var p sub two end sub pair "\cdots" pair var p sub var n end sub pair var q pair true end bracket ]" which indicates that the particular instance of the "[ bracket x tagged equal x end bracket ]" symbol occurs as the "[ math var p sub one end sub end math ]"'s subtree of the "[ math var p sub two end sub end math ]"'s subtree of the "[ math var p sub three end sub end math ]"'s subtree etc.\ of page "[ bracket var q end bracket ]". Since the particular instance of the "[ bracket x tagged equal x end bracket ]" symbol occurs on the present page we have that "[ bracket var q end bracket ]" equals the reference of the present page. In general, "[ bracket quote meta a end quote tail end bracket ]" is the list of subterms of the term "[ bracket meta a end bracket ]" and "[ bracket quote meta a end quote head end bracket ]" represents the identity and location of the root symbol of the term. As an example, \display{"[ big bracket quote var x tagged equal var y end quote ref end bracket ]"} and \display{"[ big bracket quote var x tagged equal var y end quote id end bracket ]"} are the reference and identifier, respectively, of the equality construct. As another example, we have \display{"[ big bracket quote base end quote id math equal zero end bracket ]"} because the identifier of the page symbol "[ bracket base end bracket ]" is zero. \section{The macro expansion facility} This section describes the macro expansion facility of Logiweb\cite{Logiweb}. The macro facility allows expressions that are easy to read for humans to expand into more machine readable formats before computer consumption. \subsection{Logiweb identifiers} \subsubsection{Representation scheme}\label{section:RepresentationScheme} Occasionally, we shall represent strings of characters by cardinals. To translate a string \[ [ c_1 c_2 \cdots c_m ] \] of characters to a cardinal, we proceed as follows. First, we mirror the string to get: \[ [ c_m \cdots c_2 c_1 ] \] Then we translate each character $[c_i]$ into its Unicode representation $[u_i]$, yielding a list of cardinals: \[ [ u_m \cdots u_2 u_1 ] \] Then we express each cardinal $ [ u _ i ] $ as a sequence of digits \[ [ d _ { i n _ i } \cdots d _ { i 1 } d _ { i 0 } ] \] in radix $ [ 128 ] $ such that $ [ 0 \le d _ { i j } < 128 ] $ and such that \[ u _ i = \left[ \sum _ { j = 0 } ^ { n _ i } d _ { i j } 128 ^ j \right] \] In addition, we require $ [ d _ { i n _ i } \neq 0 ] $ except when $ [ u _ i = 0 ] $ in which case we require $ [ n _ i = 1 ] $ instead. Next, we add 128 do all digits except leading ones, i.e. we define \[ \left[ d' _ { i j } = \left\{ \begin{array}{ll} d _ { i j } + 128 & \mbox{if $ 0 \le j < n _ i $} \\ d _ { i j } & \mbox{if $ j = n _ i $} \\ \end{array} \right. \right] \] This gives rise to a sequence \[ \begin{array}{llllr} [ & d' _ { m n _ m } & \cdots & d' _ { m 0 } \\ & \cdots \\ & d' _ { 2 n _ 2 } & \cdots & d' _ { 2 0 } \\ & d' _ { 1 n _ 1 } & \cdots & d' _ { 1 0 } & ] \\ \end{array} \] of cardinals in the range from $[0]$ to $[255]$. Renumbering the sequence above gives the sequence \[ [ d''_p \cdots d''_1 d''_0 ] \] which we then interpret as a sequence of digits in radix 256, so that we represent the string \[ [ c_1 c_2 \cdots c_m ] \] by the cardinal \[ c = \left[ \sum _ { k = 0 } ^ p d'' _ k 256 ^ k \right] \] \subsubsection{Representation of ASCII strings} Logiweb ASCII is a character encoding that is very close to the American Standard Code for Information Interchange (ASCII). The differences are: In Logiweb ASCII, character codes in the ranges $[0.\,.9]$ and $[11.\,.31]$ as well as character code $[127]$ are \index{dead character code}\intro{dead} character codes in the sense that if they occur in input, they should be discarded before they make their way into strings. In Logiweb ASCII, character code $[10]$, nothing but character code $[10]$, and always character code $[10]$, represents the newline character. Logiweb ASCII is similar to ASCII in that no characters have codes outside $[0.\,.127]$. Logiweb ASCII has two formatting character: newline (code $[10]$) and space (code $[32]$). All characters in the range $[33.\,.126]$ are printable glyphs. When running Logiweb under some host operating system, the convention that character $[10]$ is the newline character may equate or differ from the convention of the host operating system. In the very few cases where strings are exchanged between Logiweb and surrounding systems, one should translate between the newline conventions of Logiweb and the surroundings during the exchange. Translation from ASCII strings to cardinals and vice versa is particularly simple. To translate e.g. the string ``abc'', do as follows. First, write the string backwards: ``cba''. Then convert each character to an eight bit byte: \[ [ 0110 \ 0011 \quad 0110 \ 0010 \quad 0110 \ 0001 ] \] Finally, interpret the result as a binary number. Needless to say (so we say it for safety's sake), the above representation of ASCII strings by cardinals is quite memory efficient. \subsubsection{Constructors for binary numbers} To express binary numbers easily, we introduce the following three constructs: \display{"[ math define value of var x bit nil as true double var x end define end math ]"} \display{"[ math define value of var x bit one as false double var x end define end math ]"} \display{"[ math define value of binary as zero end define end math ]"} \subsubsection{Representation of Logiweb identifiers}\label{section:RepresentationOfLogiwebIdentifiers} We shall refer to a particular, short, finite list of strings as \index{identifier, Logiweb}\index{Logiweb identifier}\intro{Logiweb indentifiers}. The list of identifiers, and the semantics of each identifier, is at the heart of the Logiweb standard. At the time of writing I, the author of the present paper, control that list. Each Logiweb indentifier has the property that it only includes Unicode characters from 97 to 122 (small letter a to small letter z). Now define % \index{identifier @\back "[ bracket identifier var x end identifier end bracket ]" identifier x end identifier}% % \tex{"[ math tex define identifier var x end identifier as " identifier( #1. )" end define end math ]"}% % \display{"[ math define value of identifier var x end identifier as tagged if var x tail then zero else identifier one var x id plus id identifier var x first end identifier end identifier end if end define end math ]"}% % \footnote{"[ math pyk define identifier var x end identifier as "identifier * end identifier" end define end math ]"} % % \index{identifier 1 @\back "[ bracket identifier one var x plus id var y end identifier end bracket ]" identifier one x plus id y end identifier}% % \tex{"[ math tex define identifier one var x plus id var y end identifier as " identifier_{1}( #1. , #2. )" end define end math ]"}% % \display{"[ math define value of identifier one var x plus id var y end identifier as tagged if var x sixth then var y else var x zeroth double var x first double var x second double var x third double var x fourth double var x fifth double false double true double var y end if end define end math ]"}% % \footnote{"[ math pyk define identifier one var x plus id var y end identifier as "identifier one * plus id * end identifier" end define end math ]"} % We have that e.g. "[ bracket identifier quote text "code" end text end quote end identifier end bracket ]" is the string "[ bracket text "code" end text end bracket ]" translated to the cardinal specified in Section \ref{section:RepresentationScheme}: \display{"[ math test identifier quote text "code" end text end quote end identifier tagged equal binary bit one bit one bit nil bit nil bit one bit nil bit one bit nil bit one bit one bit nil bit nil bit one bit nil bit nil bit nil bit one bit one bit nil bit one bit one bit one bit one bit nil bit one bit one bit nil bit nil bit nil bit one bit one end test end math ]"}% % \test{"[ math test identifier quote text "code" end text end quote end identifier tagged equal binary bit one bit one bit nil bit nil bit one bit nil bit one bit nil bit one bit one bit nil bit nil bit one bit nil bit nil bit nil bit one bit one bit nil bit one bit one bit one bit one bit nil bit one bit one bit nil bit nil bit nil bit one bit one end test end math ]"} In general, "[ bracket identifier quote meta a end quote end identifier end bracket ]" converts the string "[ bracket meta a end bracket ]" correctly under the following conditions: \begin{itemize} \item All non-blind characters of the string are between 64 and 126 \item All blind characters of the string are between 0 and 9 or between 11 and 31. \item All characters are represented by unary operators except the end-of-text character, which must be nulary and blind. \end{itemize} \subsection{Associative structures} \subsubsection{Associations trees} We define the set of \index{association}\intro{associations} as the set of pairs "[ bracket var k pair var v end bracket ]" where "[ bracket var k end bracket ]" is a cardinal and "[ bracket var v end bracket ]" is a tagged tree. For an association "[ bracket var k pair var v end bracket ]" we shall refer to "[ bracket var k end bracket ]" and "[ bracket var v end bracket ]" as the \indexintro{key} and \indexintro{value} of the association, respectively. We define the set of \index{association tree}\intro{association trees} as the smallest set which contains "[ bracket true end bracket ]", which contains all associations, and which contains "[ bracket var a pair var b end bracket ]" for all association trees "[ bracket var a end bracket ]" and "[ bracket var b end bracket ]". Each association tree represents a finite set of associations. If all keys of an association tree "[ bracket var a end bracket ]" are distinct, then "[ bracket var a end bracket ]" represents the function that maps "[ bracket var k end bracket ]" to "[ bracket var v end bracket ]" whenever "[ bracket var k pair var v end bracket ]" belongs to "[ bracket var a end bracket ]" and maps "[ bracket var k end bracket ]" to "[ bracket true end bracket ]" whenever "[ bracket var k end bracket ]" is a cardinal which does not occur as a key in "[ bracket var a end bracket ]". In particular, the association tree "[ bracket true end bracket ]" represents the function that maps all cardinals to "[ bracket true end bracket ]". \subsubsection{Finite functions} We shall say that a function "[ bracket var f end bracket ]" is a \indexintro{finite function} if it maps cardinals to tagged trees and, furthermore, maps at most finitely many cardinals to tagged trees different from "[ bracket true end bracket ]". One may represent finite functions by association trees. \subsubsection{Addresses} Each association in an association tree "[ bracket var a end bracket ]" can be accessed using a sequence of head and tail operations. As an example, if "[ bracket var a end bracket ]" is an association tree and "[ bracket var a head tail head head end bracket ]" is an association, then the association can be addressed by a head-tail-head-head sequence. We now represent ``head'' by binary zero and ``tail'' by binary one. As an example, if "[ bracket var a end bracket ]" is an association tree and "[ bracket var a head tail head head end bracket ]" is an association then we say that the association occurs at address $ [ 0 , 1 , 0 , 0 ] $. \subsubsection{Arrays} A cardinal "[ bracket var k end bracket ]" may be written on form \[ \left[ \sum_{n=0}^{\infty} b_n 2^n \right] \] where $ [ b_0 , b_1 , b_2 , \ldots ] $ are bits (i.e.\ ``binary terms'', i.e.\ zero or one). We shall refer to $ [ b_0 , b_1 , b_2 , \ldots ] $ as the little endian, infinite binary representation of "[ bracket var k end bracket ]". We shall say that an association tree "[ bracket var a end bracket ]" is an \indexintro{array} if it satisfies the following two conditions: \begin{enumerate} \item For every association "[ bracket var k pair var v end bracket ]" in "[ bracket var a end bracket ]", the address of the association is a prefix of the little endian, infinite binary representation of "[ bracket var k end bracket ]". \item No substructure of "[ bracket var a end bracket ]" has form "[ bracket true pair var p end bracket ]" or "[ bracket var p pair true end bracket ]" where "[ bracket var p end bracket ]" is an association. \end{enumerate} The first condition makes it fast and easy to look up a key "[ bracket var k end bracket ]" in an array. The second condition together with the first ensures that each finite function is represented by exactly one array. \subsubsection{Array access} We shall say that a data structure is \indexintro{atomic} if it is not a pair. "[ bracket var x is atomic end bracket ]" is true if "[ bracket var x end bracket ]" is atomic: \display{"[ math define value of var x is atomic as not var x is data or var x is cardinal or var x is singular end define end math ]"} "[ bracket var a assoc var k end assoc end bracket ]" looks up the value associated to the key "[ bracket var k end bracket ]" in the array "[ bracket var a end bracket ]": \display{"[ math define value of var a assoc var k end assoc as assoc one var a address var k index var k end assoc end define end math ]"} \display{"[ math define value of assoc one var a address var d index var i end assoc as var a is atomic select var d tagged guard var i tagged guard true else var a head is cardinal select var i tagged equal var a head select var d tagged guard var a tail else var d tagged guard true end select else var d head select assoc one var a head address var d tail index var i end assoc else assoc one var a tail address var d tail index var i end assoc end select end select end select end define end math ]"} The above representation of arrays allows array access and update to occur reasonably efficiently. If even greater efficiency is needed, one may implement arrays as hash tables behind the scenes. The first edition engine (the only Logiweb engine in existence at the time of writing) does not treat arrays specially behind the scenes. But arrays are still defined the way they are in order to allow improvements in the future. As a matter of terminology, we shall refer to keys of arrays as \index{array index}\index{index (of array)}\intro{incices}. So an array maps indices to values. \subsubsection{Racks} Formally, we shall use ``\indexintro{rack}'' as a synonym for ``array''. Informally, we shall use ``array'' and ``rack'' for homogeneous and heterogeneous structures, respectively. So an array is an association list whose values are of homogeneous format and a rack is an association list with heterogeneous values. As a matter of terminology, we shall refer to keys of racks as \index{hook}\intro{hooks}. So a rack maps hooks to values. \subsubsection{Multidimensional arrays} We shall refer to arbitrary values as \index{zero dimensional array}\intro{zero dimensional arrays} and to arrays of $[n]$-dimensional arrays as $[n+1]$-dimensional arrays. As an example, if "[ bracket var a end bracket ]" is a three-dimensional array and "[ bracket var u end bracket ]", "[ bracket var v end bracket ]", and "[ bracket var w end bracket ]" are cardinals, then \display{"[ big bracket var a assoc var u end assoc assoc var v end assoc assoc var w end assoc end bracket ]"} is the value indexed by "[ bracket var u end bracket ]", "[ bracket var v end bracket ]", and "[ bracket var w end bracket ]". \subsubsection{Array assignment} "[ bracket var a set var i to var v end set end bracket ]" equals the array "[ bracket var a end bracket ]" except that "[ bracket var a set var i to var v end set end bracket ]" maps the index "[ bracket var i end bracket ]" to the value "[ bracket var v end bracket ]". % \index{\alpha x set y to z end set @\back "[ bracket var x set var y to var z end set end bracket ]" x set y to z end set}% % \index{x set y to z end set "[ bracket var x set var y to var z end set end bracket ]"t}% % \tex{"[ math tex define var a set var i to var v end set as "#1. [ #2. {\rightarrow} #3. ]" end define end math ]"}% % \display{"[ math value define var a set var i to var v end set as var i is cardinal select var v select array remove var i array var a level zero end remove else array put var i value var v array var a level zero end put end select else var v tagged guard var a end select end define end math ]"% % \footnote{"[ math pyk define var a set var i to var v end set as "* set * to * end set" end define end math ]"}} % % \index{array plus @\back "[ bracket array plus var x and var y end plus end bracket ]" array plus x and y end plus}% % \tex{"[ math tex define array plus var x and var y end plus as " array\mbox{-}\linebreak[0]plus( #1. , #2. )" end define end math ]"}% % \display{"[ math value define array plus var x and var y end plus as var x is atomic select var y is atomic select true else var y head is cardinal select var y else var x pair var y end select end select else var y is atomic select var x head is cardinal select var x else var x pair var y end select else var x pair var y end select end select end define end math ]"% % \footnote{"[ math pyk define array plus var x and var y end plus as "array plus * and * end plus" end define end math ]"}} % % \index{array remove @\back "[ bracket array remove var x array var y level var z end remove end bracket ]" array remove x array y level z end remove}% % \tex{"[ math tex define array remove var i array var a level var l end remove as " array\mbox{-}\linebreak[0]remove( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define array remove var i array var a level var l end remove as newline var i tagged guard var l tagged guard var a is atomic select true else var a head is cardinal select var a head tagged equal var i select true else var a end select else bit var l of var i end bit select array plus array remove var i array var a head level var l plus one end remove and var a tail end plus else array plus var a head and array remove var i array var a tail level var l plus one end remove end plus end select end select end select end define end math ]"% % \footnote{"[ math pyk define array remove var i array var a level var l end remove as "array remove * array * level * end remove" end define end math ]"}} % % \index{array put @\back "[ bracket array put var x value var y array var z level var a end put end bracket ]" array put x value y array z level a end put}% % \tex{"[ math tex define array put var i value var v array var a level var l end put as " array\mbox{-}\linebreak[0]put( #1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define array put var i value var v array var a level var l end put as newline var l tagged guard var a is atomic select var i pair var v else var a head is cardinal select var a head tagged equal var i select var i pair var v else array add var i value var v index var a head value var a tail level var l end add end select else bit var l of var i end bit select array put var i value var v array var a head level var l plus one end put pair var a tail else var a head pair array put var i value var v array var a tail level var l plus one end put end select end select end select end define end math ]"% % \footnote{"[ math pyk define array put var i value var v array var a level var l end put as "array put * value * array * level * end put" end define end math ]"}} % % \index{array add @\back "[ bracket array add var x value var y index var z value var a level var b end add end bracket ]" array add x value y index z value a level b end add}% % \tex{"[ math tex define array add var i value var v index var i prime value var v prime level var l end add as " array\mbox{-}\linebreak[0]add( #1. , #2. , #3. , #4. , #5. )" end define end math ]"}% % \display{"[ math value define array add var i value var v index var i prime value var v prime level var l end add as newline bit var l of var i end bit select bit var l of var i prime end bit select array add var i value var v index var i prime value var v prime level var l plus one end add pair true else tagged parenthesis var i pair var v end tagged pair tagged parenthesis var i prime pair var v prime end tagged end select else bit var l of var i prime end bit select tagged parenthesis var i prime pair var v prime end tagged pair tagged parenthesis var i pair var v end tagged else true pair array add var i value var v index var i prime value var v prime level var l plus one end add end select end select end define end math ]"% % \footnote{"[ math pyk define array add var i value var v index var i prime value var v prime level var l end add as "array add * value * index * value * level * end add" end define end math ]"}} % \test{"[ math test true set zero to one end set tagged equal zero pair one end test end math ]"} \test{"[ math test true set zero to one end set set one to two end set tagged equal parenthesis zero pair one end parenthesis pair parenthesis one pair two end parenthesis end test end math ]"} \test{"[ math test true set zero to one end set set two to four end set tagged equal parenthesis parenthesis zero pair one end parenthesis pair parenthesis two pair four end parenthesis end parenthesis pair true end test end math ]"} \test{"[ math test true set one to two end set set three to six end set tagged equal true pair parenthesis parenthesis one pair two end parenthesis pair parenthesis three pair six end parenthesis end parenthesis end test end math ]"} \test{"[ math test true set zero to one end set set two to four end set set zero to true end set tagged equal true set two to four end set end test end math ]"} \test{"[ math test true set zero to one end set set two to four end set set two to true end set tagged equal true set zero to one end set end test end math ]"} \test{"[ math test true set one to two end set set three to six end set set one to true end set tagged equal true set three to six end set end test end math ]"} \test{"[ math test true set one to two end set set three to six end set set three to true end set tagged equal true set one to two end set end test end math ]"} \test{"[ math test true set one to seven end set set two to eight end set set four to nine end set assoc one end assoc tagged equal seven end test end math ]"} \test{"[ math test true set one to seven end set set two to eight end set set four to nine end set assoc two end assoc tagged equal eight end test end math ]"} \test{"[ math test true set one to seven end set set two to eight end set set four to nine end set assoc four end assoc tagged equal nine end test end math ]"} \subsubsection{Multidimensional assignment} "[ bracket var a set multi var i to var v end set end bracket ]" equals the multidimensional array "[ bracket var a end bracket ]" except that "[ bracket var a set multi var i to var v end set end bracket ]" maps the list "[ bracket var i end bracket ]" of indices to the value "[ bracket var v end bracket ]". As an example, "[ bracket true set multi one pair two pair three pair true to four end set assoc one end assoc assoc two end assoc assoc three end assoc end bracket ]" equals "[ bracket four end bracket ]". % \index{\alpha x set multi y to z end set @\back "[ bracket var x set multi var y to var z end set end bracket ]" x set multi y to z end set}% % \index{x set multi y to z end set "[ bracket var x set multi var y to var z end set end bracket ]"t}% % \tex{"[ math tex define var a set multi var i to var v end set as "#1. [ #2. {\Rightarrow} #3. ]" end define end math ]"}% % \display{"[ math value define var a set multi var i to var v end set as var i is atomic select var a tagged guard var v else var a set var i head to var a assoc var i head end assoc set multi var i tail to var v end set end set end select end define end math ]"% % \footnote{"[ math pyk define var a set multi var i to var v end set as "* set multi * to * end set" end define end math ]"}} % \test{"[ math test true set multi tuple one comma two comma three end tuple to one end set set multi tuple two end tuple to two end set set multi tuple one comma one end tuple to three end set set multi tuple one comma two comma four end tuple to four end set assoc one end assoc assoc two end assoc assoc three end assoc tagged equal one end test end math ]"} \subsubsection{Variables} The term "[ bracket lambda var x dot var x end bracket ]" contains the variable "[ bracket var x end bracket ]". In Logiweb, any term may serve as a variable. Whether or not a given term is interpreted as a variable depends on context. A lambda construct forces its first argument to be a variable. This forces the first occurrence of "[ bracket var x end bracket ]" in "[ bracket lambda var x dot var x end bracket ]" to be a variable. The lambda does not force the second occurrence of "[ bracket var x end bracket ]" in "[ bracket lambda var x dot var x end bracket ]" to be a variable. But the second occurrence is a variable anyway because of another rule which says that any term whose root symbol has no value definition is a variable. As a more bizarre example, \display{"[ big bracket lambda two dot two end bracket ]"} is a valid term. The lambda forces the first occurrence of "[ bracket two end bracket ]" to be a variable. The second occurrence of "[ bracket two end bracket ]" is no variable, however, since nothing forces the second "[ bracket two end bracket ]" to be a variable and "[ bracket two end bracket ]" has a value definition. Renaming of the bound variable "[ bracket two end bracket ]" to "[ bracket var x end bracket ]" shows that "[ bracket lambda two dot two end bracket ]" equals "[ bracket lambda var x dot two end bracket ]": \display{"[ big bracket lambda two dot two math equal lambda var x dot two end bracket ]"} We now introduce the binary construct "[ bracket var x sub var y end sub end bracket ]", but we assign no value to it. For that reason, any term with the "[ bracket var x sub var y end sub end bracket ]" construct in the root will be a variable. As an example of use, \display{"[ big bracket lambda var x sub one end sub dot lambda var x sub two end sub dot var x sub one end sub pair var x sub two end sub end bracket ]"} equals \display{"[ big bracket lambda var u dot lambda var v dot var u pair var v end bracket ]"} To boost the number of available variables even further, we introduce a unary prime operator % \index{\alpha x prime @\back "[ bracket var x prime end bracket ]" x prime}% % \index{x prime "[ bracket var x prime end bracket ]"}% % \tex{"[ math tex define var x prime as "#1.'" end define end math ]"}% % "[ bracket var x prime end bracket ]"% % \footnote{"[ math pyk define var x prime as "* prime" end define end math ]"} % which allows to use "[ bracket var x prime end bracket ]", "[ bracket var y prime end bracket ]", "[ bracket var z prime prime prime end bracket ]", and so on as variables. Two variables are equal if they are identical terms (disregarding debugging information). For that reason, even if we defined "[ bracket var x , "+" , var y end bracket ]" such that $[2+2]$ equaled $[4]$, "[ bracket var x sub two , "+" , two end sub end bracket ]" and "[ bracket var x sub four end sub end bracket ]" would still be distinct variables. \subsubsection{Stacks} We shall refer to dynamic environments as \index{stack}\intro{stacks}. A stack is an association list from variables to values. We cannot use "[ bracket var s assoc var v end assoc end bracket ]" to look up the variable "[ bracket var v end bracket ]" in the stack "[ bracket var s end bracket ]" because we should disregard debugging information present in "[ bracket var v end bracket ]". For that reason, we use the following construct instead: \display{"[ math define value of lookup var v stack var s default var d end lookup as var v tagged guard var d tagged guard tagged if var s then var d else tagged if var v term equal var s head head then var s head tail else lookup var v stack var s tail default var d end lookup end if end if end define end math ]"} "[ bracket lookup var v stack var s default var d end lookup end bracket ]" looks up the variable "[ bracket var v end bracket ]" in the stack "[ bracket var s end bracket ]". If the variable is not found, "[ bracket lookup var v stack var s default var d end lookup end bracket ]" returns the default value "[ bracket var d end bracket ]" instead. The "[ bracket zip var p with var a end zip end bracket ]" construct zips two lists into a list of pairs and is suited for forming stacks: \display{"[ math define value of zip var p with var a end zip as var a tagged guard tagged if var p then true else tagged parenthesis var p head pair var a head end tagged pair zip var p tail with var a tail end zip end if end define end math ]"} \subsection{Static semantics} \subsubsection{The structure of Logiweb pages} As far as Logiweb is concerned, a Logiweb page consists of a \indexintro{bibliography}, a \indexintro{dictionary}, and a \indexintro{body}. What you read right now is a rendering of the body of a Logiweb page. The Logiweb bibliography of a page is a list of Logiweb references. The first reference (reference number zero) is the reference of the page itself, and the other references are references of other Logiweb pages. The bibliography at the end of the present page is a \textsc{Bib}\TeX\ bibliography which is part of the body of the page. The \textsc{Bib}\TeX\ bibliography is completely unrelated to the Logiweb bibliography. The Logiweb dictionary of a page is an array which maps identifiers to arities. If the dictionary of the page with reference "[ bracket var r end bracket ]" maps the cardinal "[ bracket var i end bracket ]" to "[ bracket var a end bracket ]" then, by definition, there exists a Logiweb symbol with reference "[ bracket var r end bracket ]" and identifier "[ bracket var i end bracket ]", and that symbol has arity "[ bracket var a end bracket ]". The Logiweb body of a page is one, big term. \subsubsection{Transitive bibliographies} As mentioned, the first entry of the Logiweb bibliography of any page is the reference of the page itself. Apart from this, the bibliographic references of Logiweb form a non-cyclic graph. Given a Logiweb page "[ bracket var p end bracket ]", we shall define the \indexintro{transitive bibliography} of "[ bracket var p end bracket ]" as the set of references of all pages reachable following bibliographic links starting at "[ bracket var p end bracket ]". The transitive bibliography of a page includes the reference of the page itself. We define the transitive, irreflexive bibliography of a Logiweb page as the transitive bibliography with the reference of the page itself removed. \subsubsection{Loading, referencing, and verbatim copying} Logiweb is able to \indexintro{load} Logiweb pages. Loading a Logiweb page involves a number of activities such as locating, retrieving, unpacking, and codifying the page. To display a page the system has to load and then render the page. Loading a page is cascading in that loading a page requires loading of all pages in the transitive bibliography of the page. A page cannot be loaded unless all pages in the transitive bibliography can be found. Hence, deleting a page from Logiweb is a serious thing since it ruins all pages that refer, directly or indirectly, to the deleted page. Fortunately, Logiweb allows duplication of pages so that a single Logiweb page may reside several places in the world. The author of a Logiweb page should secure a local copy of all pages in the transitive bibliography of the page unless the author trusts other people very much. Referencing, indexing, and verbatim copying are core activities of Logiweb; if one does not allow referencing, indexing, and verbatim copying of a page, one should not submit it to Logiweb. In other words, the author of a page silently permits referencing, indexing, and verbatim copying by submitting it. Authors may of course still claim copyright to a Logiweb page. That copyright may prevent other people from e.g.\ modifying the page, publishing the page outside Logiweb, or other activities other than the core activities of Logiweb. \subsubsection{The cache of a page}\label{section:TheCacheOfAPage} Loading a page results in the construction of a \indexintro{cache} and a \indexintro{rack} for the page. The cache and rack of a page represent the static semantics of the page. The cache "[ bracket var c end bracket ]" of a page "[ bracket var p end bracket ]" is an array which maps the references in the transitive bibliography of "[ bracket var p end bracket ]" to the rack of the associated page. Hence, "[ bracket var c assoc var r end assoc end bracket ]" is the rack of the page referenced by "[ bracket var r end bracket ]". In particular, the cache of a page contains the rack of the page itself. The cache "[ bracket var c end bracket ]" of a page is an almost homogeneous array. The only exception is that "[ bracket var c assoc zero end assoc end bracket ]" equals the reference of the page. As a consequence, if "[ bracket var c end bracket ]" is the cache of a page then "[ bracket var c assoc var c assoc zero end assoc end assoc end bracket ]" is the rack of the page. \subsubsection{The value of the page construct} A \index{construct, page}\indexintro{page construct} (the construct of a page whose id is zero) represents the page. As an example, the pyk and tex aspects of a page construct effectively become the name of the page expressed in pyk and \TeX, respectively. The page construct is always nulary. Evaluation of a page construct always yields the Logiweb cache of the associated page. In this way, the evaluator has a clean way to access its environment. Logiweb ignores value definitions of page constructs. From the point of view of mathematical reasoning, page constructs are constants whose values happen to be the cache of their associated pages. "[ bracket base end bracket ]" is the page construct of the present page. Hence, the value of "[ bracket base end bracket ]" is the cache of the present page. According to Section \ref{section:TheCacheOfAPage}, "[ bracket base assoc zero end assoc end bracket ]" is the reference of the present page. If we take any construct introduced on the present page, say "[ bracket seven end bracket ]", then the reference of the root of that construct must equal "[ bracket base assoc zero end assoc end bracket ]": \display{"[ math test base assoc zero end assoc tagged equal quote seven end quote ref end test end math ]"} In section \ref{section:SelfReferences} we macro define "[ bracket self end bracket ]" so that "[ bracket self end bracket ]" macro expands to the page construct of the page on which the construct occurs. Hence, on the present page, "[ bracket self end bracket ]" expands to "[ bracket base end bracket ]". On other pages, "[ bracket self end bracket ]" expands to the page construct of those other pages. We could use "[ bracket self end bracket ]" in place of "[ bracket base end bracket ]" above. Logiweb does not care about the order of definitions, and it is completely valid to use macros before they are defined. But beware of circularities, they can lead to intractable errors. \subsubsection{The rack of a page}\label{section:TheRackOfAPage} According to Section \ref{section:TheCacheOfAPage}, % \index{rack @\back "[ bracket example rack end bracket ]" example rack}% % \index{example rack "[ bracket example rack end bracket ]"}% % \tex{"[ math tex define example rack as " rack" end define end math ]"}% % "[ math value define example rack as base assoc base assoc zero end assoc end assoc end define end math ]"% % \footnote{"[ math pyk define example rack as "example rack" end define end math ]"} % is the rack of the present page. The rack of a page maps various, predefined hooks to various values. The hooks of the rack are Logiweb identifiers (c.f. Section \ref{section:RepresentationOfLogiwebIdentifiers}). At the time of writing, the rack "[ bracket var a end bracket ]" of a page has the following hooks: \begin{itemize} \item % \index{vector hook "[ bracket vector hook end bracket ]"}% % \tex{"[ math tex define vector hook as " \mbox {\tt \char34}\mathrm {vector}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of vector hook as identifier quote text "vector" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define vector hook as "vector hook" end define end math ]"} % The vector of the page, i.e.\ the sequence of bytes that constitute the page when it is stored on disc or transmitted over a network. As an example, "[ bracket example rack assoc vector hook end assoc head end bracket ]" is the first byte of the vector that represents the present page. That byte happens to be the major version number so, since the present page is encoded using Logiweb version "[ bracket one end bracket ]" we have "[ math test example rack assoc vector hook end assoc head tagged equal one end test end math ]". \item % \index{bibliography hook "[ bracket bibliography hook end bracket ]"}% % \tex{"[ math tex define bibliography hook as " \mbox {\tt \char34}\mathrm {bibliography}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of bibliography hook as identifier quote text "bibliography" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define bibliography hook as "bibliography hook" end define end math ]"} % The bibliography of the page, i.e.\ a list of references where the first reference is the reference of the page itself and the other references are references of other pages. The present page is a base page in the sense that it references no other pages: "[ math test example rack assoc bibliography hook end assoc tagged equal quote seven end quote ref pair true end test end math ]". \item % \index{dictionary hook "[ bracket dictionary hook end bracket ]"}% % \tex{"[ math tex define dictionary hook as " \mbox {\tt \char34}\mathrm {dictionary}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of dictionary hook as identifier quote text "dictionary" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define dictionary hook as "dictionary hook" end define end math ]"} % The dictionary of the page, i.e.\ an array that maps the identifiers of the symbols introduced on the page to their arities. As an example, the arity of "[ bracket var x pair var y end bracket ]" is two: \display{"[ math test example rack assoc dictionary hook end assoc assoc quote var x pair var y end quote id end assoc tagged equal two end test end math ]"} We say that a \index{exists, symbol}\indexintro{symbol exists} if the dictionary of the page pointed out by the reference of the symbol maps the identifier of the symbol to a value different from "[ bracket true end bracket ]". \item % \index{body hook "[ bracket body hook end bracket ]"}% % \tex{"[ math tex define body hook as " \mbox {\tt \char34}\mathrm {body}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of body hook as identifier quote text "body" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define body hook as "body hook" end define end math ]"} % The body of the page, i.e.\ the term that one should typeset when viewing the page. On a base page, the root of the body necessarily comes from the page itself: "[ math test example rack assoc body hook end assoc ref tagged equal quote seven end quote ref end test end math ]". \item % \index{codex hook "[ bracket codex hook end bracket ]"}% % \tex{"[ math tex define codex hook as " \mbox {\tt \char34}\mathrm {codex}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of codex hook as identifier quote text "codex" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define codex hook as "codex hook" end define end math ]"} % An array that contains all revelations (i.e.\ proclamations, definitons, and introductions) of the page as described in Section \ref{section:TheCodexOfAPage}. \item % \index{expansion hook "[ bracket expansion hook end bracket ]"}% % \tex{"[ math tex define expansion hook as " \mbox {\tt \char34}\mathrm {expansion}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of expansion hook as identifier quote text "expansion" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define expansion hook as "expansion hook" end define end math ]"} % The macro expanded version of the body of the page. The expanded version is always a syntactically valid term, i.e.\ a term in which all symbols exist and have correct arities as specified in the dictionaries. Logiweb ensures this syntactic validity in a roundabout way: The macro expansion facility is Turing complete and can produce any value as an output. Macro expansion may even loop indefinitely, in which case the author of the page should consider to correct the page before submitting it to Logiweb. If macro expansion does produce a value, then Logiweb checks the result for syntactical validity, and whenever it finds an invalid symbol or a symbol whose arity does not match the number of subtrees, Logiweb replaces the tree rooted at the invalid symbol with the page construct of the present page. \item % \index{code hook "[ bracket code hook end bracket ]"}% % \tex{"[ math tex define code hook as " \mbox {\tt \char34}\mathrm {code}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of code hook as identifier quote text "code" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define code hook as "code hook" end define end math ]"} % An array that contains compiled versions of all value revelations of a page. With two exceptions, the compiled versions are tagged, curried functions: "[ math test map untag example rack assoc code hook end assoc assoc quote var x pair var y end quote id end assoc tagged apply two tagged apply three end untag tagged equal two pair three end test end math ]". The first exceptions is lambda abstraction which, rather arbitrarily, is represented by a zero: "[ math test example rack assoc code hook end assoc assoc quote lambda var x dot var y end quote id end assoc tagged equal zero end test end math ]". The other exception is quoting which is represented by a one: "[ math test example rack assoc code hook end assoc assoc quote quote var x end quote end quote id end assoc tagged equal one end test end math ]". \item % \index{cache hook "[ bracket cache hook end bracket ]"}% % \tex{"[ math tex define cache hook as " \mbox {\tt \char34}\mathrm {cache}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of cache hook as identifier quote text "cache" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define cache hook as "cache hook" end define end math ]"} % An array which maps all references in the transitive, irreflexive bibliography of the page "[ bracket var p end bracket ]" to the caches of the associated pages. The present page is a base page in the sense that it references no other pages, so the cache that hangs on the cache hook is empty: "[ math test example rack assoc cache hook end assoc tagged equal true end test end math ]". If the present page did reference a page with reference "[ bracket var r end bracket ]" then "[ bracket example rack assoc cache hook end assoc assoc var r end assoc end bracket ]" would be the cache of page "[ bracket var r end bracket ]". In that case, "[ bracket base assoc var r end assoc end bracket ]" as well as "[ bracket example rack assoc cache hook end assoc assoc var r end assoc assoc var r end assoc end bracket ]" would be the rack of page "[ bracket var r end bracket ]". In general, the racks and caches of referenced pages can be addressed several ways. \item % \index{diagnose hook "[ bracket diagnose hook end bracket ]"}% % \tex{"[ math tex define diagnose hook as " \mbox {\tt \char34}\mathrm {diagnose}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of diagnose hook as identifier quote text "diagnose" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define diagnose hook as "diagnose hook" end define end math ]"} % If the value that hangs on the diagnose hook is "[ bracket true end bracket ]" then the page is correct. Otherwise, the value is a term which, when typeset, is supposed to explain what is wrong with the page. In other words, the diagnose hook is where the checking machinery hangs its complaints. The diagnose is pruned to a term the same way as the expansion is. The diagnose is added after checking. During checking the value that hangs on the diagnose hook is always "[ bracket true end bracket ]". \end{itemize} \noindent Constants (i.e.\ nulary constructs) like the ones above are computed lazily and the result is kept. For that reason, constants are computed at most once when a Logiweb page is loaded. Computation of e.g.\ "[ bracket identifier quote text "diagnose" end text end quote end identifier end bracket ]" is not particularly time and memory efficient but that is irrelevant when using "[ bracket diagnose hook end bracket ]" since it is only evaluated once. \subsubsection{The codex of a page}\label{section:TheCodexOfAPage} The codex "[ bracket var c end bracket ]" of a page is a four dimensional array that hangs on the "[ bracket codex hook end bracket ]" hook of the rack of the page. A page may contain revelations (i.e.\ proclamations, definitions, and introductions), and each revelation defines some aspect of some symbol. If "[ bracket var r sub var s end sub end bracket ]" and "[ bracket var i sub var s end sub end bracket ]" are the reference and identifier, respectively, of a symbol and if "[ bracket var r sub var a end sub end bracket ]" and "[ bracket var i sub var a end sub end bracket ]" are the reference and identifier, respectively, of an aspect, then \display{"[ big bracket var c assoc var r sub var s end sub end assoc assoc var i sub var s end sub end assoc assoc var r sub var a end sub end assoc assoc var i sub var a end sub end assoc end bracket ]"} is the revelation (if any) of the given aspect of the given symbol. If the revelation is a definition or introduction, the thing stored in the codex is the entire term that constitutes the revelation. In this case, the first argument of the definition is the aspect (with possible parameters), the second argument is the left hand side of the definition (with possible parameters), and the third argument is the right hand side. The root of the term is a symbol that is proclaimed to denote the ``definition'' or ``introduction'' concept. If the revelation is a proclamation, the thing stored in the codex has form "[ bracket parenthesis zero pair var i pair true end parenthesis pair true end bracket ]" where "[ bracket var i end bracket ]" where the cardinal "[ bracket var i end bracket ]" identifies the proclamation as explained in Section \ref{section:CodificationOfRevelations}. \subsubsection{Aspects} An aspect may be predefined or user defined. User defined aspects are introduced using a mechanism described later. The reference and identifier of a user defined aspect always identify an existing Logiweb symbol. The reference of a predefined aspect equals zero and the identifier is a Logiweb identifier. At the time of writing, the following Logiweb identifiers denote predefined aspects: \begin{itemize} \item % \index{value aspect "[ bracket value aspect end bracket ]"}% % % \tex below uses \char34 instead of "! to avoid problems with makeindex \tex{"[ math tex define value aspect as " \mbox {\tt \char34}\mathrm {value}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of value aspect as identifier quote text "value" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define value aspect as "value aspect" end define end math ]"} % \item % \index{pyk aspect "[ bracket pyk aspect end bracket ]"}% % \tex{"[ math tex define pyk aspect as " \mbox {\tt \char34}\mathrm {pyk}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of pyk aspect as identifier quote text "pyk" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define pyk aspect as "pyk aspect" end define end math ]"} % \item % \index{tex aspect "[ bracket tex aspect end bracket ]"}% % \tex{"[ math tex define tex aspect as " \mbox {\tt \char34}\mathrm {tex}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of tex aspect as identifier quote text "tex" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define tex aspect as "tex aspect" end define end math ]"} % \item % \index{texname aspect "[ bracket texname aspect end bracket ]"}% % \tex{"[ math tex define texname aspect as " \mbox {\tt \char34}\mathrm {texname}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of texname aspect as identifier quote text "texname" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define texname aspect as "texname aspect" end define end math ]"} % \item % \index{message aspect "[ bracket message aspect end bracket ]"}% % \tex{"[ math tex define message aspect as " \mbox {\tt \char34}\mathrm {message}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of message aspect as identifier quote text "message" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define message aspect as "message aspect" end define end math ]"} % \item % \index{macro aspect "[ bracket macro aspect end bracket ]"}% % \tex{"[ math tex define macro aspect as " \mbox {\tt \char34}\mathrm {macro}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of macro aspect as identifier quote text "macro" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define macro aspect as "macro aspect" end define end math ]"} % \item % \index{definition aspect "[ bracket definition aspect end bracket ]"}% % \tex{"[ math tex define definition aspect as " \mbox {\tt \char34}\mathrm {definition}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of definition aspect as identifier quote text "definition" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define definition aspect as "definition aspect" end define end math ]"} % \item % \index{unpack aspect "[ bracket unpack aspect end bracket ]"}% % \tex{"[ math tex define unpack aspect as " \mbox {\tt \char34}\mathrm {unpack}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of unpack aspect as identifier quote text "unpack" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define unpack aspect as "unpack aspect" end define end math ]"} % \item % \index{claim @\back "[ bracket claim aspect end bracket ]" claim aspect}% % \tex{"[ math tex define claim aspect as " \mbox {\tt \char34}\mathrm {claim}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of claim aspect as identifier quote text "claim" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define claim aspect as "claim aspect" end define end math ]"} % \item % \index{priority aspect "[ bracket priority aspect end bracket ]"}% % \tex{"[ math tex define priority aspect as " \mbox {\tt \char34}\mathrm {priority}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of priority aspect as identifier quote text "priority" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define priority aspect as "priority aspect" end define end math ]"} % \end{itemize} \noindent As an example, if "[ bracket var c end bracket ]" is the codex of a page and if the page makes a value definition of a symbol with reference "[ bracket var r end bracket ]" and identifier "[ bracket var i end bracket ]" then \display{"[ big bracket var c assoc var r end assoc assoc var i end assoc assoc zero end assoc assoc value aspect end assoc end bracket ]"} will equal that definition. \subsubsection{Domestic and foreign definitions} If a page with reference "[ bracket var r end bracket ]" has cache "[ bracket var c end bracket ]" then e.g. \display{"[ big bracket var c assoc var r end assoc assoc codex hook end assoc assoc var r sub var s end sub end assoc assoc var i sub var s end sub end assoc assoc zero end assoc assoc value aspect end assoc end bracket ]"} denotes the value aspect of the symbol with reference "[ bracket var r sub var s end sub end bracket ]" and identifier "[ bracket var i sub var s end sub end bracket ]" as defined on page "[ bracket var r end bracket ]". We shall say that a definition is \index{domestic definition}\intro{domestic} if "[ bracket var r math equal var r sub var s end sub end bracket ]" and \index{foreign definition}\intro{foreign} otherwise. In other words, a definition is domestic if it occurs on the home page of the symbol being defined. Logiweb ignores foreign value definitions but store them in the codex for the record. In general, Logiweb ignores foreign definitions of any predefined aspect. One could decide that foreign definitions could shadow domestic ones in certain situations. Actually, shadowing of pyk, tex, and tex name aspects has been considered for Logiweb, but has been rejected to keep core Logiweb simple. Authors who define their own user aspects may decide if and how foreign definitions may shadow domestic ones for their aspects. \subsubsection{A codex accessor} % \index{aspect @\back "[ bracket aspect var x subcodex var y end aspect end bracket ]" aspect x subcodex y end aspect}% % \tex{"[ math tex define aspect var a subcodex var c end aspect as " \mathbf{aspect}( #1. , #2. )" end define end math ]"}% % "[ bracket aspect var a subcodex var c end aspect end bracket ]"% % \footnote{"[ math pyk define aspect var a subcodex var c end aspect as "aspect * subcodex * end aspect" end define end math ]"} % looks up the the aspect "[ bracket var a end bracket ]" in the \indexintro{subcodex} "[ bracket var c end bracket ]". The subcodex is assumed to be the result of accessing a codex be the reference and identifier of a symbol. The subcodex is what is called a \index{Lisp property list}\index{property list, Lisp}\intro{property list} in Lisp \cite{mccarthy60,steele}. If "[ bracket var a end bracket ]" is a cardinal then it is interpreted as the Logiweb identifier of a predefined aspect. Otherwise, "[ bracket var a end bracket ]" is interpreted as a term whose root symbol denotes a user defined aspect. \display{"[ math define value of aspect var a subcodex var c end aspect as var a is cardinal select var c assoc zero end assoc assoc var a end assoc else var c assoc var a ref end assoc assoc var a id end assoc end select end define end math ]"} % \index{aspect @\back "[ bracket aspect var a term var t cache var c end aspect end bracket ]"}% % \tex{"[ math tex define aspect x term x cache x end aspect as " \mathbf{aspect}( #1. , #2. , #3. )" end define end math ]"}% % "[ bracket aspect var a term var t cache var c end aspect end bracket ]"% % \footnote{"[ math pyk define aspect var a term var t cache var c end aspect as "aspect * term * cache * end aspect" end define end math ]"} % looks up the domestic definition of the root of the term "[ bracket var t end bracket ]" for the aspect "[ bracket var a end bracket ]" in the cache "[ bracket var c end bracket ]". If "[ bracket var a end bracket ]" is a cardinal then it is interpreted as the Logiweb identifier of a predefined aspect. Otherwise, "[ bracket var a end bracket ]" is interpreted as a term whose root symbol denotes a user defined aspect. \display{"[ math define value of aspect var a term var t cache var c end aspect as aspect var a subcodex var c assoc var t ref end assoc assoc codex hook end assoc assoc var t ref end assoc assoc var t id end assoc end aspect end define end math ]"} \subsubsection{Value proclamations} Proclaiming a construct to denote ``apply'', ``lambda'', ``true'', ``if'', or ``quote'' affects the value aspect of the construct. For that reason we shall refer to proclamations with one of these strings in the right hand side as \index{value proclamation}\intro{value proclamations}. The strings that make sense in the right hand side of proclamations form a subset of the strings that define Logiweb identifiers. The Logiweb identifiers associated to the five value proclamations are defined thus: \begin{itemize} \item % \index{lambda identifier "[ bracket lambda identifier end bracket ]"}% % \tex{"[ math tex define lambda identifier as " \mbox {\tt \char34}\mathrm {lambda}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of lambda identifier as identifier quote text "lambda" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define lambda identifier as "lambda identifier" end define end math ]"} % \item % \index{apply identifier "[ bracket apply identifier end bracket ]"}% % \tex{"[ math tex define apply identifier as " \mbox {\tt \char34}\mathrm {apply}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of apply identifier as identifier quote text "apply" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define apply identifier as "apply identifier" end define end math ]"} % \item % \index{true identifier "[ bracket true identifier end bracket ]"}% % \tex{"[ math tex define true identifier as " \mbox {\tt \char34}\mathrm {true}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of true identifier as identifier quote text "true" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define true identifier as "true identifier" end define end math ]"} % \item % \index{if identifier "[ bracket if identifier end bracket ]"}% % \tex{"[ math tex define if identifier as " \mbox {\tt \char34}\mathrm {if}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of if identifier as identifier quote text "if" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define if identifier as "if identifier" end define end math ]"} % \item % \index{quote identifier "[ bracket quote identifier end bracket ]"}% % \tex{"[ math tex define quote identifier as " \mbox {\tt \char34}\mathrm {quote}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of quote identifier as identifier quote text "quote" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define quote identifier as "quote identifier" end define end math ]"} % \end{itemize} \subsubsection{Codification of revelations}\label{section:CodificationOfRevelations} Logiweb \index{codify}\intro{codifies} a definition like \display{"[ math define value of var x raw head as var x apply true end define end math ]"} simply by placing the entire definition in the codex: \display{"[ math test aspect value aspect term quote var x raw head end quote cache base end aspect term equal quote define value of var x raw head as var x apply true end define end quote end test end math ]"} Having that definition, one can gain access not only to the right hand side of the definition, but also e.g.\ the parameter list of the left hand side. If one decides to have parameterized aspects, then one will also have access to the parameter list of the aspect in the codex. Introductions are treated exactly the same way. An introduction like \display{"[ math introduce value of var y raw pair var z as lambda var x dot if var x then var y else var z end if end introduce end math ]"} results in the following entry in the codex: \display{"[ math test aspect value aspect term quote var y raw pair var z end quote cache base end aspect term equal quote introduce value of var y raw pair var z as lambda var x dot if var x then var y else var z end if end introduce end quote end test end math ]"} In contrast, a proclamation like \display{"[ math proclaim lambda var x dot var y as text "lambda" end text end proclaim end math ]"} results in an entry like \display{"[ math test aspect value aspect term quote lambda var x dot var y end quote cache base end aspect tagged equal identity zero pair lambda identifier pair true end identity pair true end test end math ]"} In general, a proclamation results in an entry of form "[ bracket identity zero pair var i pair true end identity pair true end bracket ]" where "[ bracket var i end bracket ]" is the Logiweb identifier that corresponds to the string in the right hand side of the proclamation. \subsubsection{Message proclamations} A construct denotes an aspect if the construct has a ``message'' aspect. Proclaiming a construct to denote ``pyk'', ``tex'', ``texname'', ``value'', ``message'', ``macro'', ``unpack'', ``claim'', or ``priority'' affects the message aspect of the construct. For that reason we shall refer to proclamations with one of these strings in the right hand side as \index{message proclamation}\intro{message proclamations}. The aspects mentioned above are said to be ``predefined''. User defined aspects are treated later. In addition to the predefined aspects mentioned above, Logiweb recognizes one more predefined aspect: the ``definition'' aspect, which is unproclaimable and which is treated in Section \ref{section:DefinitionProclamations}. As an example of use, \display{"[ math test aspect message aspect term quote pyk end quote cache base end aspect tagged equal identity zero pair pyk aspect pair true end identity pair true end test end math ]"} \subsubsection{Definition proclamation}\label{section:DefinitionProclamations} A construct denotes a revelation if the construct has a ``definition'' aspect. Proclaiming a construct to denote ``proclaim'', ``define'', ``introduce'', or ``hide'' affects the revelation aspect of the construct. For that reason we shall refer to proclamations with one of these strings in the right hand side as \index{definition proclamation}\intro{definition proclamations}. The Logiweb identifiers associated to the definition proclamations are defined thus: \begin{itemize} \item % \index{proclaim identifier "[ bracket proclaim identifier end bracket ]"}% % \tex{"[ math tex define proclaim identifier as " \mbox {\tt \char34}\mathrm {proclaim}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of proclaim identifier as identifier quote text "proclaim" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define proclaim identifier as "proclaim identifier" end define end math ]"} % \item % \index{define identifier "[ bracket define identifier end bracket ]"}% % \tex{"[ math tex define define identifier as " \mbox {\tt \char34}\mathrm {define}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of define identifier as identifier quote text "define" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define define identifier as "define identifier" end define end math ]"} % \item % \index{introduce identifier "[ bracket introduce identifier end bracket ]"}% % \tex{"[ math tex define introduce identifier as " \mbox {\tt \char34}\mathrm {introduce}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of introduce identifier as identifier quote text "introduce" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define introduce identifier as "introduce identifier" end define end math ]"} % \item % \index{hide identifier "[ bracket hide identifier end bracket ]"}% % \tex{"[ math tex define hide identifier as " \mbox {\tt \char34}\mathrm {hide}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of hide identifier as identifier quote text "hide" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define hide identifier as "hide identifier" end define end math ]"} % \end{itemize} \noindent Constructs proclaimed to ``hide'' disable all proclamations in their subtrees to have effect as described in Section \ref{section:AvoidMacroExpansionAndHarvestingOfStrings}. As an example of use of the definitions aspect we have \display{"[ math test aspect definition aspect term quote define value of var x raw head as var x apply true end define end quote cache base end aspect tagged equal identity zero pair define identifier pair true end identity pair true end test end math ]"} \subsubsection{Priority proclamations} Proclaiming a construct to denote ``pre'' or ``post'' affects the priority aspect of the construct. For that reason we shall refer to proclamations with one of these strings in the right hand side as \index{priority proclamation}\intro{priority proclamations}. The Logiweb identifiers associated to the priority proclamations are defined thus: \begin{itemize} \item % \index{pre identifier "[ bracket pre identifier end bracket ]"}% % \tex{"[ math tex define pre identifier as " \mbox {\tt \char34}\mathrm {pre}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of pre identifier as identifier quote text "pre" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define pre identifier as "pre identifier" end define end math ]"} % \item % \index{post identifier "[ bracket post identifier end bracket ]"}% % \tex{"[ math tex define post identifier as " \mbox {\tt \char34}\mathrm {post}\mbox {\tt \char34}" end define end math ]"}% % "[ math define value of post identifier as identifier quote text "post" end text end quote end identifier end define end math ]"% % \footnote{"[ math pyk define post identifier as "post identifier" end define end math ]"} % \end{itemize} \noindent As an example, \display{"[ math test aspect priority aspect term quote preassociative var x greater than var y end quote cache base end aspect tagged equal identity zero pair pre identifier pair true end identity pair true end test end math ]"} \subsubsection{The code of a page} The code of a page is a one-dimensional array that hangs on the "[ bracket code hook end bracket ]" hook of the rack of the page. If "[ bracket var c end bracket ]" is the cache of a page and "[ bracket var r end bracket ]" belongs to the transitive bibliography of the page, then \display{"[ big bracket var c assoc var r end assoc assoc code hook end assoc assoc var i end assoc end bracket ]"} is a tagged, Curried version of \display{"[ big bracket var c assoc var r end assoc assoc codex hook end assoc assoc var r end assoc assoc var i end assoc assoc zero end assoc assoc value aspect end assoc end bracket ]"} As an example, if "[ bracket var r end bracket ]" and "[ bracket var i end bracket ]" are the reference and identifier, respectively, of the "[ bracket var x pair var y end bracket ]" construct, then \display{"[ big bracket var c assoc var r end assoc assoc code hook end assoc assoc var i end assoc math equal map tag lambda var x dot lambda var y dot var x pair var y end tag end bracket ]"} The first edition engine performs compilation backstage so that the code of a page contains a compiled versions of the value aspects of the codex. If "[ bracket var r end bracket ]" and "[ bracket var i end bracket ]" are the reference and identifier, respectively, of a symbol that is proclaimed to denote lambda abstraction, then "[ bracket var c assoc var r end assoc assoc code hook end assoc assoc var i end assoc math equal zero end bracket ]". If "[ bracket var r end bracket ]" and "[ bracket var i end bracket ]" are the reference and identifier, respectively, of a symbol that is proclaimed to denote quoting, then "[ bracket var c assoc var r end assoc assoc code hook end assoc assoc var i end assoc math equal one end bracket ]". \subsection{Macro expansion} \subsubsection{A self interpreter} Before we can define a macro expander we need a self interpreter. We define a self interpreter in the following. The result of evaluating a term is a map, but the evaluator returns a semitagged map for efficiency reasons. To get the map itself one has to untag the return value. The self interpreter "[ bracket eval var t stack var s cache var c end eval end bracket ]" evaluates the term "[ bracket var t end bracket ]" for the stack "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]" and returns the result as a semitagged map. "[ bracket map untag eval var t stack var s cache var c end eval end untag end bracket ]" is the map itself. The self interpreter computes the reference "[ bracket var t ref end bracket ]" and identifier "[ bracket var t id end bracket ]" of the root of the term and passes control to an auxiliary function: \display{"[ math define value of eval var t stack var s cache var c end eval as eval two var t ref var t ref id var t id stack var s cache var c end eval end define end math ]"} "[ bracket eval two var t ref var r id var i stack var s cache var c end eval end bracket ]" evaluates the term "[ bracket var t end bracket ]" whose root symbol has reference "[ bracket var r end bracket ]" and identifier "[ bracket var i end bracket ]" for the stack "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]". If the root symbol is a page symbol, it returns the associated cache. Otherwise, it looks up the code of the root symbol: \display{"[ math define value of eval two var t ref var r id var i stack var s cache var c end eval as var i is singular select var t tagged guard var s tagged guard tagged if var r tagged equal var c assoc zero end assoc then var c else var c assoc var c assoc zero end assoc end assoc assoc cache hook end assoc assoc var r end assoc end if else eval three var t function var c assoc var r end assoc assoc code hook end assoc assoc var i end assoc stack var s cache var c end eval end select end define end math ]"} "[ bracket eval three var t function var f stack var s cache var c end eval end bracket ]" evaluates the term "[ bracket var t end bracket ]" whose root symbol has code "[ bracket var f end bracket ]" for the stack "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]". If the code equals "[ bracket true end bracket ]" then the root symbol has no value definition and, hence, the term "[ bracket var t end bracket ]" is treated a variable. If the code equals zero then the root symbol denotes lambda abstraction and is treated accordingly. If the code equals one then the root symbol denotes the quote construct and is treated accordingly. Otherwise, the code is a tagged, Curried function to be applied to the argument list "[ bracket var t tail end bracket ]" of the term "[ bracket var t end bracket ]": \display{"[ math define value of eval three var t function var f stack var s cache var c end eval as var f is cardinal select var f is singular select abstract var t first term var t second stack var s cache var c end abstract else var c tagged guard var s tagged guard var t first end select else var f select var c tagged guard lookup var t stack var s default true end lookup else eval four var f arguments var t tail stack var s cache var c end eval end select end select end define end math ]"} "[ bracket eval four var f arguments var a stack var s cache var c end eval end bracket ]" applies the function "[ bracket var f end bracket ]" to the arguments "[ bracket var a end bracket ]" evaluated for the stack "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]": \display{"[ math define value of eval four var f arguments var a stack var s cache var c end eval as tagged if var a then var s tagged guard var c tagged guard var f else eval four apply var f to eval var a head stack var s cache var c end eval end apply arguments var a tail stack var s cache var c end eval end if end define end math ]"} "[ bracket abstract var v term var t stack var s cache var c end abstract end bracket ]" abstracts the variable "[ bracket var v end bracket ]" in the term "[ bracket var t end bracket ]" for the stack "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]": \display{"[ math define value of abstract var v term var t stack var s cache var c end abstract as var v tagged guard var t tagged guard var s tagged guard var c tagged guard tagging lambda var x dot eval var t stack tagged parenthesis var v pair var x end tagged pair var s cache var c end eval end define end math ]"} \subsubsection{A macro expander} Macro definitions are based on definitions of the \indexintro{macro aspect} of symbols. Definitions of macro aspects will be referred to as \index{macro definition}\intro{macro definitions}. Other kinds of definitions treated so far include value, pyk, \TeX, and priority definitions. To make macro definitions we must proclaim "[ bracket macro end bracket ]" to denote the macro aspect: \display{"[ math proclaim macro as text "macro" end text end proclaim end math ]"} The macro expander "[ bracket expand var t state var s cache var c end expand end bracket ]" macro expands the term "[ bracket var t end bracket ]" for the \indexintro{macro state} "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]" and returns the result as a semitagged map. The untagged version "[ bracket map untag expand var t state var s cache var c end expand end untag end bracket ]" is the expansion itself. As we shall see, macros typically use the macro state to define what should happen after one macro expansion. The initial macro state defined in Section \ref{section:TheInitialMacroState} just specifies that the macro expander should be reinvoked which ensures that macro expansion proceeds until all macros are expanded. But macros may decide not to reinvoke the macro expander. Or they may decide to reinvoke it but with a modified macro state. Or they may decide to invoke an entirely different macro expander. If the term to be expanded is a page construct, the macro expander returns the term unchanged (page constructs should not be macro expanded for reasons explained later). Otherwise, the macro expander looks up the macro definition of the root of the term and passes control to an auxiliary function: \display{"[ math define value of expand var t state var s cache var c end expand as var s tagged guard var c tagged guard tagged if var t id is singular then var t else expand two var t definition aspect macro aspect term var t cache var c end aspect state var s cache var c end expand end if end define end math ]"} "[ bracket expand two var t definition var d state var s cache var c end expand end bracket ]" macro expands the term "[ bracket var t end bracket ]" whose root symbol has macro definition "[ bracket var d end bracket ]" for the macro state "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]". If the macro definition equals "[ bracket true end bracket ]" then the root symbol has no macro definition. In this case, the subterms of the term are macro expanded. Otherwise, "[ bracket expand two var t definition var d state var s cache var c end expand end bracket ]" evaluates the right hand side "[ bracket var d third end bracket ]" of the definition (for completeness: "[ bracket var d zeroth end bracket ]" is a symbol that denotes the ``definition'' concept, "[ bracket var d first end bracket ]" is a term that represents the macro aspect, "[ bracket var d second end bracket ]" is the left hand side and "[ bracket var d third end bracket ]" is the right hand side of the definition). Finally, the evaluated right hand side is applied to the term "[ bracket var t end bracket ]", the macro state "[ bracket var s end bracket ]", and the cache "[ bracket var c end bracket ]" so that the user defined macro "[ bracket var d end bracket ]" gets access to term, state, and cache (at expansion time, the cache will be the cache of the page on which the term being macro expanded resides). \display{"[ math define value of expand two var t definition var d state var s cache var c end expand as var d select var t head pair expand list var t tail state var s cache var c end expand else normalizing untag eval var d third stack true cache var c end eval tagged apply var t tagged apply var s tagged apply var c end untag end select end define end math ]"} The "[ bracket expand list var a state var s cache var c end expand end bracket ]" construct macro expands the elements of the list "[ bracket var a end bracket ]". \display{"[ math define value of expand list var a state var s cache var c end expand as var s tagged guard var c tagged guard tagged if var a then true else expand var a head state var s cache var c end expand pair expand list var a tail state var s cache var c end expand end if end define end math ]"} \subsubsection{The initial macro state}\label{section:TheInitialMacroState} The \index{macro state, initial}\indexintro{initial macro state} "[ bracket macro state end bracket ]" is useful for passing as the second parameter to "[ bracket expand var t state var s cache var c end expand end bracket ]". "[ bracket macro state end bracket ]" is a pair whose head is the macro expander itself and whose tail is left blank. The definition of "[ bracket macro state end bracket ]" reads: \display{"[ math define value of macro state as map tag lambda var t dot lambda var s dot lambda var c dot expand var t state var s cache var c end expand end tag pair true end define end math ]"} In the definition of "[ bracket macro state end bracket ]" note that the first ${\cal M}$ is a unary ``map tag'' operation that converts the lambda abstraction into a tagged map whereas the second ${\cal M}$ is the ternary macro expansion operation. Advanced users may write macros that pass down a macro state different from "[ bracket macro state end bracket ]". Such users should pass down a macro state of form "[ bracket var m pair var p end bracket ]" where "[ bracket var m end bracket ]" is a ternary macro expander and "[ bracket var p end bracket ]" is a parameter that can contain arbitrary data. The default macro expander "[ bracket expand var t state var s cache var c end expand end bracket ]" makes no use of the parameter and for that reason the parameter is set to "[ bracket true end bracket ]" in "[ bracket macro state end bracket ]". \subsubsection{Pruning}\label{section:pruning} In connection with macro expansion, Logiweb uses a hardwired retract on G{\"!odel} trees which we shall refer to as \indexintro{pruning}. Given the cache of a page and an arbitrary data structure, the pruning operation scans the data structure as if it were a G{\"!odel} tree. Whenever the pruning operation encounters a branch that cannot be a G{\"!odel} tree, it replaces the branch by the page construct of the given page. The pruning operation first applies the retract for tagged trees to the given data structure. Then, for each branch of the G{\"!odel} tree, it checks that the reference and identifier are cardinals. Then it looks up the arity of the associated symbol in the proper dictionary inside the cache of the given page. If no arity is found, the symbol is invalid and the branch is pruned. Otherwise, the pruning operation checks that the number of subtrees agree with the arity and descend recursively into the subtrees. If no arity is found for a given symbol it either means that the symbol does not exist on Logiweb or that it exists, but not on a page transitively referenced by the given page. \subsubsection{Potentially inherited page aspects}\label{section:InheritedAspects} Macro expansion of a page is governed by the ``potentially inherited macro aspect'' of the page. The potentially inherited macro aspect is an example of a \index{inherited page aspect, potentially}\index{page aspect, potentially inherited}\index{aspect, potentially inherited page}\indexintro{potentially inherited page aspect}. Let us take ``potentially inherited page aspect'' one word at a time. Aspects of the page construct of a page are ``page aspects'' for that page. An ``inherited page aspect'' of a page "[ bracket var p end bracket ]" is a page aspect of the \index{bed, page}\indexintro{page bed} "[ bracket var b end bracket ]" of page "[ bracket var p end bracket ]". The bed "[ bracket var b end bracket ]" of a page "[ bracket var p end bracket ]" is the first page referenced in the bibliography of page "[ bracket var p end bracket ]". If page "[ bracket var p end bracket ]" is a base page, i.e.\ if page "[ bracket var p end bracket ]" references no other pages, then the bed of page "[ bracket var p end bracket ]" is page "[ bracket var p end bracket ]" itself. The bed "[ bracket var b end bracket ]" of a page "[ bracket var p end bracket ]" is the page on which page "[ bracket var p end bracket ]" rests. Note for programmers: The first entry of the bibliography of a page is the one that comes after the zeroth entry. The zeroth entry references the page itself. A bibliography is a list of references, and the head of the list is the zeroth entry. But back to ``potentially inherited page aspects''. A potentially inherited page aspect of a page "[ bracket var p end bracket ]" is taken from the page construct of "[ bracket var p end bracket ]" if that aspect is available, and is taken from the page construct of the bed of "[ bracket var p end bracket ]" otherwise. As an example, the potentially inherited macro aspect of page "[ bracket var p end bracket ]" is the macro aspect of the page construct of page "[ bracket var p end bracket ]" if such an aspect is defined, and else the macro aspect of the page construct of the bed of "[ bracket var p end bracket ]" if such an aspect is defined. At the time of writing, Logiweb makes use of two potentially inherited page aspects: the macro aspect described in the following, and the claim aspect described in Section \ref{section:Claims}. At a later stage, Logiweb will also make use of a potentially inherited value aspect which defines things to be computed once and for all when pages are loaded and an unconditionally inherited unpack aspect which may decompress and/or decrypt Logiweb vectors when loaded. \subsubsection{Installing the macro expander} We shall refer to the G{\"!o}del tree that constitutes the macro expanded version of a page as the \indexintro{expansion} of the page. We define the \indexintro{expander} of a page to be the potentially inherited macro aspect of the page. Logiweb expands a page by applying the expander to the body and cache of the page. If no expander is defined then Logiweb does no macro expansion and uses the body unchanged as expansion. Now define \display{"[ math define macro of base as lambda var t dot lambda var c dot expand var t state macro state cache var c end expand end define end math ]"} Because of the definition above, the expansion of the present page is the pruned version of "[ bracket expand var t state macro state cache var c end expand end bracket ]" where "[ bracket var t end bracket ]" and "[ bracket var c end bracket ]" are the body and cache, respectively, of the page. Another page that uses the present page as bed and defines no expander of its own also has expansion "[ bracket expand var t state macro state cache var c end expand end bracket ]" but then "[ bracket var t end bracket ]" and "[ bracket var c end bracket ]" are the body and cache, respectively, of that other page. Recall that the macro expander "[ bracket expand var t state var s cache var c end expand end bracket ]" does not macro expand page constructs. One reason for that is that the macro aspect of the page construct defines an expander rather than a macro. \subsubsection{Iterated macro expansion}\label{section:IteratedMacroExpansion} The description of macro expansion above is part of the story rather than the whole story. As descripted in Section \ref{section:loading}, Logiweb ``loads'' a page by ``resolving'' its reference into a Uniform Resource Locator, then ``retrieves'' the page as a vector of bytes, then ``unpacks'' the vector into bibliography, dictionary, and body, then ``codifies'' the page into codex and expansion, and finally ``verifies'' the page. Codification comprises macro expansion and ``harvesting''. Harvesting is done by scanning the expansion of a page for revelations, i.e.\ proclamations, definitions, and introductions. The process of harvesting converts the expansion, which is a G{\"!o}del tree, into a codex. Codification proceeds thus: First, with the exception stated in Section \ref{section:Bootstrapping}, Logiweb sets the codex of the page to be empty. Then Logiweb macro expands the body of the page using the empty codex for the page in question plus all the codicies of referenced pages. Then Logiweb sets the codex of the page to the result of harvesting the expansion, and then Logiweb macro expands the body of the page once more. Logiweb proceeds this way until the codex does not change anymore (if ever). This is what was meant by ``reading the page over and over again'' in Section \ref{section:loading} and \ref{section:Bootstrapping}. \subsection{Macro definitions} \subsubsection{Protection} "[ bracket protect var x end protect end bracket ]" is a particularly important macro; it protects its argument against macro expansion. During macro expansion, the protection construct itself disappears. The definition of protection is not completely trivial: \display{"[ math protect define macro of protect var x end protect as lambda var t dot lambda var s dot lambda var c dot var t first end define end protect end math ]"} Note that the definition has two occurrences of the protection construct: an outermost and an innermost. At first reading of the page, no expander has been defined yet, the definition construct has not yet been proclaimed, and Logiweb has not yet understood what the protection construct is supposed to do. After a couple of readings, Logiweb has still not understood what the protection construct is supposed to do, but has reached a level where it can understand that the formula above defines the macro aspect of the protection construct. At the next reading of the page, the protection construct is operational, and for that reason, the outermost protection construct protects the innermost protection construct from macro expansion. Without the outermost protection construct, the innermost protection construct would disappear so that it was "[ bracket var x end bracket ]" that was macro defined to denote protection, which leads to disaster. It should be noted that base pages as large as the present one are not particularly easy to write. There are many things that can go wrong in intractable ways. Authors who insist on writing their own base page are encouraged to build them up in small steps, starting with a base page as simple as possible. \subsubsection{Self references}\label{section:SelfReferences} We macro define "[ bracket self end bracket ]" such that each instance of "[ bracket self end bracket ]" expands to the page construct of the page on which the instance occurs. \display{"[ math protect define macro of self as lambda var t dot lambda var s dot lambda var c dot identity var c assoc zero end assoc pair zero pair var t debug end identity pair true end define end protect end math ]"} Alternatively, one could define "[ bracket self end bracket ]" to expand into an invalid tree and let pruning insert a page construct. As an example, one could replace the entire right hand side above by "[ bracket true end bracket ]". But the definition above ensures that resulting page sysmbol enherits the debugging information present in the "[ bracket self end bracket ]" construct. \subsubsection{Avoid macro expansion and harvesting of strings}\label{section:AvoidMacroExpansionAndHarvestingOfStrings} Good Logiweb pages contain loads of text. Actually, the formal mathematics present on well written Logiweb pages only constitute a minor fraction of the page. Since macro expansion takes time, we arrange that strings are not macro expanded. The pyk compiler puts a unicode start and end of text construct at the root and leaf of strings, respectively, with the individual characters of the string in between as a row of perls (or, rather, a column of perls; in the string itself, the characters are like a row of perls). We can protect strings against macro expansion by a proper definition of the macro aspect of the unicode start of text construct: \display{"[ math define macro of unicode start of text var x end unicode text as lambda var t dot lambda var s dot lambda var c dot var t end define end math ]"} Once Logiweb has expanded the body of a page, it does \indexintro{harvesting} of definitions: it scans the expansion and collects all definitions found. To avoid spending time on harvesting inside strings, we proclaim the unicode start of text construct to protect against harvesting: \display{"[ math proclaim unicode start of text var x end unicode text as text "hide" end text end proclaim end math ]"} \subsubsection{Macro definitions} "[ math protect macro define var x as var y end define end protect end math ]" defines "[ bracket var x end bracket ]" as shorthand for "[ bracket var y end bracket ]". Hence, "[ math protect macro define var x as var y end define end protect end math ]" makes ordinary macro definitions. The definition of "[ math protect macro define var x as var y end define end protect end math ]" is slightly involved since "[ math protect macro define var x as var y end define end protect end math ]" is defined such that it macro expands into a general macro definition. \display{"[ math protect define macro of macro define var x as var y end define as lambda var t dot lambda var s dot lambda var c dot macro define three var t end define end define end protect end math ]"} "[ bracket state expand var t state var s cache var c end expand end bracket ]" macro expands the term "[ bracket var t end bracket ]" using the macro expander embedded in the macro state "[ bracket var s end bracket ]" using the cache "[ bracket var c end bracket ]". \display{"[ math define value of state expand var t state var s cache var c end expand as map untag var s head tagged apply var t tagged apply var s tagged apply var c end untag end define end math ]"} "[ bracket macro define one end bracket ]" is a template that defines what "[ math protect macro define var x as var y end define end protect end math ]" expands into: \display{"[ math define value of macro define one as quote define macro of var x as lambda var t dot lambda var s dot lambda var c dot macro define four var t state var s cache var c definition quote var d end quote end define end define end quote end define end math ]"} If "[ bracket var t end bracket ]" is a term of form "[ math protect macro define var x as var y end define end protect end math ]" then "[ bracket macro define two var t end define end bracket ]" is a stack that maps the variable "[ bracket var x end bracket ]" to the left hand side of the macro definition and maps the variable "[ bracket var d end bracket ]" to the entire macro definition. \display{"[ math define value of macro define two var t end define as tagged parenthesis quote var x end quote pair var t first end tagged pair tagged parenthesis quote var d end quote pair var t end tagged pair true end define end math ]"} "[ bracket macro define three var t end define end bracket ]" translates a term "[ bracket var t end bracket ]" of form "[ math protect macro define var x as var y end define end protect end math ]" into a general macro definition. This is done by replacing "[ bracket var x end bracket ]" and "[ bracket var d end bracket ]" in the template "[ bracket macro define one end bracket ]" by the left hand side of "[ bracket var t end bracket ]" and all of "[ bracket var t end bracket ]", respectively. \display{"[ math define value of macro define three var t end define as quote expand var t term macro define one stack macro define two var t end define end expand end define end math ]"} "[ bracket macro define four var t state var s cache var c definition var d end define end bracket ]" performs the macro expansion defined by "[ math protect macro define var x as var y end define end protect end math ]". The function above macro expands "[ math protect macro define var x as var y end define end protect end math ]". The function below expands the macro defined by "[ math protect macro define var x as var y end define end protect end math ]". \display{"[ math define value of macro define four var t state var s cache var c definition var d end define as state expand quote expand var t term var d second stack zip var d first tail with var t tail end zip end expand state var s cache var c end expand end define end math ]"} "[ bracket quote expand var r term var t stack var s end expand end bracket ]" performs the substitutions defined by the stack "[ bracket var s end bracket ]" in the term "[ bracket var t end bracket ]". Set the debugging information of all nodes taken from "[ bracket var t end bracket ]" to the debugging information of the root of the term "[ bracket var r end bracket ]". \display{"[ math define value of quote expand var r term var t stack var s end expand as quote expand two var r debug term var t stack var s end expand end define end math ]"} "[ bracket quote expand two var r term var t stack var s end expand end bracket ]" performs the substitutions defined by the stack "[ bracket var s end bracket ]" in the term "[ bracket var t end bracket ]". Set the debugging information of all nodes taken from "[ bracket var t end bracket ]" to the debugging information "[ bracket var r end bracket ]". \display{"[ math define value of quote expand two var r term var t stack var s end expand as quote expand three var r term var t stack var s value lookup var t stack var s default true end lookup end expand end define end math ]"} "[ bracket quote expand three var r term var t stack var s value var v end expand end bracket ]" performs the substitutions defined by the stack "[ bracket var s end bracket ]" in the term "[ bracket var t end bracket ]". Set the debugging information of all nodes taken from "[ bracket var t end bracket ]" to the debugging information "[ bracket var r end bracket ]". If "[ bracket var v end bracket ]" differs from "[ bracket true end bracket ]" then "[ bracket var t end bracket ]" is supposed to occur in "[ bracket var s end bracket ]" and "[ bracket var v end bracket ]" is supposed to be the associated value. Hence, if "[ bracket var v end bracket ]" differs from "[ bracket true end bracket ]" then "[ bracket var v end bracket ]" is returned. Otherwise, the root of "[ bracket var t end bracket ]" is merged properly with the debugging information "[ bracket var r end bracket ]" and substitutions are performed in all subterms of "[ bracket var t end bracket ]". \display{"[ math define value of quote expand three var r term var t stack var s value var v end expand as var v select tagged parenthesis var t ref pair var t id pair var r end tagged pair quote expand star var r term var t tail stack var s end expand else var r tagged guard var t tagged guard var s tagged guard var v end select end define end math ]"} "[ bracket quote expand star var r term var t stack var s end expand end bracket ]" performs the substitutions defined by the stack "[ bracket var s end bracket ]" in the list "[ bracket var t end bracket ]" of terms. Set the debugging information of all nodes taken from "[ bracket var t end bracket ]" to the debugging information "[ bracket var r end bracket ]". \display{"[ math define value of quote expand star var r term var t stack var s end expand as var t select var r tagged guard var t tagged guard var s tagged guard true else quote expand two var r term var t head stack var s end expand pair quote expand star var r term var t tail stack var s end expand end select end define end math ]"} \subsubsection{Parentheses}\sect{Parentheses} "[ bracket parenthesis var x end parenthesis end bracket ]" is probably the most important among all macros, at least from the point of view of the working mathematician. Parentheses simply disappear when macro expanded: \display{"[ math macro define parenthesis var x end parenthesis as var x end define end math ]"} The following construct uses \verb+\left(...\right)+ to render parentheses. Beware that the construct disables line breaking. "[ display math macro define big parenthesis var x end parenthesis as var x end define end math intro big parenthesis var x end parenthesis pyk "big parenthesis * end parenthesis" tex ""n\left( #1."n\right) " end intro end display ]" \subsection{Tagged lambda}\sect{TaggedLambda} The following macro definition allows to state tagged lambdas in a readable way: "[ display math macro define tagged lambda var x dot var y as tagging lambda var x dot var y end define end math intro tagged lambda var x dot var y pyk "tagged lambda * dot *" tex ""n\Lambda #1."n. #2." end intro end display ]" \subsubsection{Local abbreviations}\sect{LocalAbbreviations} The following construct allows to override macros locally: % \index{let @\back "[ bracket text let var x abbreviate var y in var z end text end bracket ]" let x abbreviate y in z}% % \tex{"[ math tex define let var x abbreviate var y in var z as " \mathbf{let\ } #1. \mathrel{\ddot{=}} #2. \mathrel{\ in\ } #3." end define end math ]"}% % \display{"[ math protect define macro of let var x abbreviate var y in var z as lambda var t dot lambda var s dot lambda var c dot newline state expand var t third state var s cache var c set multi var t first ref pair codex hook pair var t first ref pair var t first id pair zero pair macro aspect pair true to macro define three var t end define end set end expand end define end protect end math ]"% % \footnote{"[ math pyk define let var x abbreviate var y in var z as "let * abbreviate * in *" end define end math ]"}} % As a somewhat constructed example of use, \display{"[ bracket let parenthesis var x end parenthesis abbreviate var x pair var x in parenthesis three end parenthesis end bracket ]"} macro expands to \display{"[ bracket three pair three end bracket ]"} \subsubsection{Other kinds of definitions} The following constructs allow to define particular aspects of a left hand side to be the given right hand side. The following construct is useful for value definitions. \display{"[ math macro define value define var x as var y end define as define value of protect var x end protect as var y end define end define end math ]"} Use of the construct above for value definitions on which the definition of the macro expander depends may lead to intractable errors. For that reason, the present page is organised such that the construct above is only used from Section \ref{section:Claims} and on and such that the macro expander only depends on definitions stated before \ref{section:Claims}. Logiweb does not care about the order of definitions. The avoidance of vicious circles by dividing at the start of Section \ref{section:Claims} is just for the sake of the author. The following construct is suitable for value introductions, i.e.\ for value definitions of constructs for which the Logiweb system in use is expected to contain a hardcoded version. As with the value definition, it is not used before Section \ref{section:Claims}. \display{"[ math macro define intro define var x as var y end define as introduce value of protect var x end protect as var y end introduce end define end math ]"} The following constructs are convenient for defining "[ bracket pyk end bracket ]", "[ bracket tex end bracket ]", and "[ bracket tex name end bracket ]" definitions. The constructs protect the left hand side against macro expansion and ensures that the right hand side is typeset as a string. The three constructs below are used uncritically on the present page since rendering is done after codification and, hence, cannot interfere with codification. \display{"[ math macro define pyk define var x as var y end define as define pyk of protect var x end protect as text var y end text end define end define end math ]"} \display{"[ math macro define tex define var x as var y end define as define tex of protect var x end protect as text var y end text end define end define end math ]"} \display{"[ math macro define tex name define var x as var y end define as define tex name of protect var x end protect as text var y end text end define end define end math ]"} Finally, the following construct is convenient for defining priority tables. % \index{priority table @\back "[ bracket text priority table var x end table end text end bracket ]" priority table x end table}% % \tex{"[ math tex define priority table var x end table as " \mathbf{Priority\ table} #1. \mathbf{End\ table}" end define end math ]"}% % \tex{"[ math tex name define priority table var x end table as " \mathbf{Priority\ table} [ #1. ]" end define end math ]"}% % \display{"[ math macro define priority table var x end table as define priority of self as protect var x end protect end define end define end math ]"% % \footnote{"[ math pyk define priority table var x end table as "priority table * end table" end define end math ]"}} % \subsubsection{Tuples} We shall use \index{tuple x end tuple "[ bracket tuple var x end tuple end bracket ]"} \index{\alpha tuple x end tuple@\back "[ bracket tuple var x end tuple end bracket ]" tuple x end tuple} \tex{"[ math tex define tuple x end tuple as " \langle #1. \rangle " end define end math ]"}"[ bracket tuple var x end tuple end bracket ]"\footnote{"[ math pyk define tuple var x end tuple as "tuple * end tuple" end define end math ]"} and % \index{x comma y "[ bracket var x comma var y end bracket ]"} \index{\alpha x comma y@\back "[ bracket var x comma var y end bracket ]" x comma y} \tex{"[ math tex define var x comma var y as "#1. ,\linebreak [0] #2." end define end math ]"}"[ bracket var x comma var y end bracket ]"\footnote{"[ math pyk define var x comma var y as "* comma *" end define end math ]"} % to express tuples. "[ bracket tuple var x end tuple end bracket ]" will be macro defined such that e.g. "[ bracket tuple var x comma var y comma var z end tuple end bracket ]" macro expands into "[ bracket var x pair var y pair var z pair true end bracket ]". \display{"[ math protect define macro of tuple var x end tuple as lambda var t dot lambda var s dot lambda var c dot state expand tuple one var t end tuple state var s cache var c end expand end define end protect end math ]"} \index{tuple 1 @\back "[ bracket tuple one var t end tuple end bracket ]"} \tex{"[ math tex define tuple one x end tuple as " \mathbf {tuple}_1( #1. ) " end define end math ]"}"[ bracket tuple one var t end tuple end bracket ]"\footnote{"[ math pyk define tuple one var t end tuple as "tuple one * end tuple" end define end math ]"} expands the root of "[ bracket tuple var x end tuple end bracket ]": \display{"[ math define value of tuple one var t end tuple as var t first term root equal quote var x comma var y end quote select quote expand var t term quote var x pair protect tuple var y end tuple end protect end quote stack tuple two var t first end tuple end expand else quote expand var t term quote var x pair true end quote stack parenthesis quote var x end quote pair var t first end parenthesis pair true end expand end select end define end math ]"} \index{tuple 2 @\back "[ bracket tuple two var t end tuple end bracket ]"} \tex{"[ math tex define tuple two x end tuple as " \mathbf {tuple}_2( #1. ) " end define end math ]"}"[ bracket tuple two var t end tuple end bracket ]"\footnote{"[ math pyk define tuple two var t end tuple as "tuple two * end tuple" end define end math ]"} forms the stack used when expanding "[ bracket tuple var x comma var y end tuple end bracket ]": \display{"[ math define value of tuple two var t end tuple as parenthesis quote var x end quote pair var t first end parenthesis pair parenthesis quote var y end quote pair var t second end parenthesis pair true end define end math ]"} \subsubsection{Typography of the expansion} The author of a Logiweb page should ensure that the tex aspect of the body looks good when typeset by \TeX. Among other, the author should avoid overfull and underfull \TeX\ boxes in the body. When it comes to the expansion of the page, matters are a bit different. Firstly, the aesthetics of the expansion is less important since the expansion does not address the audience to the same degree as the body does. Secondly, precise control of the typography of the expansion is more intricate. For these reasons it is convenient to typeset the expansion in a \index{right, ragged}\indexintro{ragged right} style. To do so we first introduce a contruct % \index{ragged right @\back "[ bracket text ragged right end text end bracket ]" ragged right}% % \tex{"[ math tex define ragged right as " \raggedright" end define end math ]"}% % \tex{"[ math tex name define ragged right as " ragged\ right" end define end math]"}% % "[ bracket text ragged right end text end bracket ]"% % \footnote{"[ math pyk define ragged right as "ragged right" end define end math ]"} % which produces a \verb+\raggedright+ command when typeset using its tex aspect. Second, we introduce a construct which is invisible when typeset using its tex aspect but which macro expands into the construct above: % \index{ragged right expansion @\back "[ bracket text ragged right expansion end text end bracket ]" ragged right expansion}% % \tex{"[ math tex define ragged right expansion as "" end define end math ]"}% % \tex{"[ math tex name define ragged right expansion as " ragged\ right\ expansion\ " end define end math]"}% % \display{"[ math macro define ragged right expansion as make visible ragged right end visible end define end math ]"% % \footnote{"[ math pyk define ragged right expansion as "ragged right expansion" end define end math ]"}} % Including the latter construct above near the start of a Logiweb page, the expansion of the page will be typeset ragged right without affecting the supposedly splendid typography the body. \subsection{Programming aids} \subsubsection{Newlines in definitions} Traditional mathematical formulas typically fit on a single line. Formally, a computer program is nothing but a mathematical formula, but computer programs have a tendency to span more than one line. This is so even if one breaks up a computer program in individual definitions of computable functions and consider each definition at a time. For the sake of readablity, it is often convenient to control where line breaks occur in definitions of computable functions. To allow such control we introduce a newline construct whose tex name aspect is ``newline'' but whose tex aspect simply forces the formula following it to begin on a new line. The newline construct is prefix and should be put in front of the formula to begin a new line. \index{newline @\back "[ bracket text newline var x end text end bracket ]" newline x}% % \tex{"[ math tex define newline var x as " \newline #1." end define end math ]"}% % \tex{"[ math tex name define newline var x as " newline\ #1." end define end math ]"}% % \display{"[ math value define newline var x as var x tagged retract end define end math ]"% % \footnote{"[ math pyk define newline var x as "newline *" end define end math ]"}} The newline construct is value defined such that it retracts which allows it to occur in functions that are fit for optimization. The newline construct can be value or macro defined. Above, it has been value defined so that it also affects the typography of the expansion of the page. That is convenient for debugging. In formal reasoning about a computable function it is more convenient to have a newline construct that macro expands to nothingness: \index{newline @\back "[ bracket text macro newline var x end text end bracket ]" macro newline x}% % \tex{"[ math tex define macro newline var x as " \newline #1." end define end math ]"}% % \tex{"[ math tex name define macro newline var x as " macro\ newline\ #1." end define end math ]"}% % \display{"[ math macro define macro newline var x as var x end define end math ]"% % \footnote{"[ math pyk define macro newline var x as "macro newline *" end define end math ]"}} \subsubsection{The visibility operator} We now introduce a \indexintro{visibility} operator % \index{v: \back "[ bracket make visible make visible var x end visible end visible end bracket ]" make visible x end visible}% % \index{make visible x end visible "[ bracket make visible make visible var x end visible end visible end bracket ]"}% % \tex{"[ math tex define make visible var x end visible as "#1/tex name." end define end math ]"}% % \tex{"[ math tex name define make visible var x end visible as " ( #1. )^{\bf v}" end define end math ]"}% % "[ math macro define make visible var x end visible as var x end define end math ]"% % \footnote{"[ math pyk define make visible make visible var x end visible end visible as "make visible * end visible" end define end math ]"} % which forces its argument to be typeset using the tex name aspect and which macro expands to nothingness like parentheses do. The construct is useful in situations where e.g.\ the right hand side of a definition contains operators whose tex aspect make them invisible. When typeset in the tex aspect, the visibility operator does not exhibit itself, it just affects how its argument is typeset. When typeset in the tex name aspect, the visibility operator reads "[ bracket make visible make visible var x end visible end visible end bracket ]". The bracket "[ bracket make visible make visible var x end visible end visible end bracket ]" contains two visibility operators. The outermost operator makes the innermost visible. The visibility operator "[ bracket make visible make visible var x end visible end visible end bracket ]" is almost identical to the text operator "[ bracket make visible text var x end text end visible end bracket ]". The difference is that the visibility operator macro expands into nothingness whereas the text operator is value defined such that it is self-evaluating. The bracket "[ bracket make visible text var x end text end visible end bracket ]" contains a visibility and a text operator. The visibility operator makes the text operator visible. \subsubsection{Self-evaluation} The juxtaposition operator "[ bracket make visible var x then var y end visible end bracket ]" has a tex name aspect that reads "[ bracket make visible var x then var y end visible end bracket ]" and a tex aspect that reads "[ bracket var x then var y end bracket ]". The tex aspect of the juxtaposition operator allows to put two typographic entities back-to-back. In the following we silently use the "[ bracket make visible make visible var x end visible end visible end bracket ]" operator to make juxtaposition visible. We make juxtaposition \indexintro{self-evaluating}: \display{"[ math value define var x then var y as tuple quote make visible x then x end visible end quote root comma var x comma var y end tuple end define end math ]"} The definition above has the effect that e.g.\ "[ bracket quote make visible var x then var y end visible end quote end bracket ]" denotes the same term as "[ bracket make visible quote var x end quote then quote var y end quote end visible end bracket ]" except for debugging information present in the terms. The root of the latter is ``clean'' in the sense that its debugging information equals "[ bracket true end bracket ]". We also make the ``text'' construct self-evaluating: \display{"[ math value define text var x end text as tuple quote make visible text x end text end visible end quote root comma var x end tuple end define end math ]"} \subsubsection{Open if} The \index{if, open}\indexintro{open if} construct is defined thus: \index{if: "[ bracket open if var x then var y else var z end bracket ]" open if x then y else z}% % \index{open if x then y else z "[ bracket open if var x then var y else var z end bracket ]"}% % \tex{"[ math tex define open if var x then var y else var z as " {\bf if} \ #1. \ {\bf then} \ #2. \ {\bf else} \ #3." end define end math ]"}% % \display{"[ math macro define open if var x then var y else var z as tagged if var x then var y else var z end if end define end math ]"% % \footnote{"[ math pyk define open if var x then var y else var z as "open if * then * else *" end define end math ]"}} The open if construct is useful when writing programs with long chains of if-constructs. \subsubsection{The ``let'' construct} We define eager, retracting functional application "[ bracket let one var f apply var y end let end bracket ]" and the \indexintro{let} construct "[ bracket let var x be var y in var z end bracket ]" as follows: % \index{let @\back "[ bracket let var x be var y in var z end bracket ]" let x by y in z}% % \tex{"[ math tex define let var x be var y in var z as " \mathbf{let\ } #1. = #2. \mathbf{\ in\ } #3." end define end math ]"}% % \display{"[ math macro define let var x be var y in var z as let one lambda var x dot var z apply var y end let end define end math ]"% % \footnote{"[ math pyk define let var x be var y in var z as "let * be * in *" end define end math ]"}} % % \index{let 1 @\back "[ bracket let one var x apply var y end let end bracket ]" let one x apply y end let}% % \tex{"[ math tex define let one var f apply var y end let as " let_1( #1. , #2. )" end define end math ]"}% % \display{"[ math intro define let one var f apply var y end let as let two var f apply var y tagged retract end let tagged retract end define end math ]"% % \footnote{"[ math pyk define let one var f apply var y end let as "let one * apply * end let" end define end math ]"}} % % \index{let 2 @\back "[ bracket let two var x apply var y end let end bracket ]" let two x apply y end let}% % \tex{"[ math tex define let two var f apply var y end let as " let_2( #1. , #2. )" end define end math ]"}% % \display{"[ math value define let two var f apply var y end let as identity var y tagged guard var f apply var y end identity end define end math ]"% % \footnote{"[ math pyk define let two var f apply var y end let as "let two * apply * end let" end define end math ]"}} % The initial Logiweb engine translates all terms of form "[ bracket let one lambda var x dot var z apply var y end let end bracket ]" to an efficient let-construct internally. \test{"[ math test tuple two comma three comma two end tuple tagged equal let var x be two in tuple var x comma three comma var x end tuple end test end math ]"} \test{"[ math test zero tagged equal let var x be false in true raw pair false end test end math ]"} \test{"[ math test zero tagged equal let var x be false in true raw pair var x end test end math ]"} \test{"[ math test true pair zero tagged equal parenthesis untagged zero raw pair untagged zero raw pair true end parenthesis raw pair lambda var y dot var y end test end math ]"} \test{"[ math test true pair true tagged equal let var x be lambda var y dot var y in parenthesis untagged zero raw pair untagged zero raw pair true end parenthesis raw pair var x end test end math ]"} \subsubsection{Macro defined connectives} The connectives "[ bracket var x macro and var y end bracket ]", "[ bracket var x macro or var y end bracket ]", and "[ bracket var x macro imply var y end bracket ]" macro expand into constructs that only compute "[ bracket var y end bracket ]" when needed. Furthermore, the constructs return the value of "[ bracket var y end bracket ]" whenever "[ bracket var y end bracket ]" is computed. Such a left-to-right computing behaviour can also be achieved using lazy constructs, but the macro defined connectives above have the benefit that, when used with caution, they can occur in definitions that are fit for optimization. % \index{\alpha x macro and y @\back "[ bracket var x macro and var y end bracket ]" x macro and y}% % \index{x macro and y "[ bracket var x macro and var y end bracket ]"}% % \tex{"[ math tex define var x macro and var y as "#1. \mathrel{\ddot{\wedge}} #2." end define end math ]"}% % \display{"[ math macro define var x macro and var y as tagged if var x then var y else false end if end define end math ]"% % \footnote{"[ math pyk define var x macro and var y as "* macro and *" end define end math ]"}} % % \index{\alpha x macro or y @\back "[ bracket var x macro or var y end bracket ]" x macro or y}% % \index{x macro or y "[ bracket var x macro or var y end bracket ]"}% % \tex{"[ math tex define var x macro or var y as "#1. \mathrel{\ddot{\vee}} #2." end define end math ]"}% % \display{"[ math macro define var x macro or var y as tagged if var x then true else var y end if end define end math ]"% % \footnote{"[ math pyk define var x macro or var y as "* macro or *" end define end math ]"}} % % \index{\alpha x macro imply y @\back "[ bracket var x macro imply var y end bracket ]" x macro imply y}% % \index{x macro imply y "[ bracket var x macro imply var y end bracket ]"}% % \tex{"[ math tex define var x macro imply var y as "#1. \mathrel{\ddot{\Rightarrow}} #2." end define end math ]"}% % \display{"[ math macro define var x macro imply var y as tagged if var x then var y else true end if end define end math ]"% % \footnote{"[ math pyk define var x macro imply var y as "* macro imply *" end define end math ]"}} % \subsubsection{Display construct}\sect{DisplayConstruct} "[ bracket text display var x end display end text end bracket intro display var x end display index "Display" pyk "display * end display" tex " \addvspace{\abovedisplayskip} \setlength{\leftskip}{\mathindent}\noindent #1. \everypar{\setlength{\parindent}{\docparindent}} \setlength{\parindent}{0mm} \setlength{\leftskip}{0mm} \addvspace{\belowdisplayskip} " name " display(#1. )" end intro ]" typesets its argument as a paragraph whose left margin equals the indentation of a displayed equation. Space is added before and after the paragraph and the first paragraph after a display is unindented. "[ bracket text statement var x end statement end text end bracket intro statement var x end statement index "Statement" pyk "statement * end statement" tex " \addvspace{\abovedisplayskip} \setlength{\leftskip}{0mm}\noindent #1. \everypar{\setlength{\parindent}{\docparindent}} \setlength{\parindent}{0mm} \setlength{\leftskip}{0mm} \addvspace{\belowdisplayskip} " name " statement(#1. )" end intro ]" does the same except that the left margin flushes the left margin of the document. \subsubsection{Introduction of new constructs}\sect{Introduction of new constructs} The following constructs allow to introduce a new construct (``introduce'' in the normal sense of the word, not in the sense of a Logiweb revelation). The constructs allow to define the pyk aspect "[ bracket var p end bracket ]" and tex aspect "[ bracket var t end bracket ]" of a new construct "[ bracket var x end bracket ]" and also makes two entries in the index. The first of the constructs below adds the text "[ bracket var i end bracket ]" in front of one of the index entries. % \index{intro: intro * index * pyk * tex * end intro @intro: "[ bracket unicode start of text text intro var x index var i pyk var p tex var t end intro end text end unicode text end bracket ]" intro * index * pyk * tex * end intro} % \index{intro * index * pyk * tex * end intro "[ bracket unicode start of text text intro var x index var i pyk var p tex var t end intro end text end unicode text end bracket ]"}% % \tex{"[ math tex define intro var x index var i pyk var p tex var t end intro as "\index{#2.: #3. @#2.: $[#1/tex name/tex.]$ #3.}% \index{pyk: #3. $[#1/tex name/tex.]$}% \tex{ $[#1/tex name/tex. \stackrel {\mathrm {tex}}{=} #4/tex name. ]$}$[ #1/tex name/tex.% ]$\footnote{$[#1/tex name/tex. \stackrel {\mathrm {pyk}}{=} #3/tex name. ]$}" end define end math ]"}% % \tex{"[ math tex name define intro var x index var i pyk var p tex var t end intro as " intro(#1. ,#2. ,#3. ,#4. )" end define end math ]"}% % \display{"[ math macro define intro var x index var i pyk var p tex var t end intro as make visible math pyk define var x as var p end define end math end visible then make visible math tex define var x as var t end define end math end visible end define end math ]"% % \footnote{"[ math pyk define intro var x index var i pyk var p tex var t end intro as "intro * index * pyk * tex * end intro" end define end math ]"}} % \index{intro: intro * pyk * tex * end intro @intro: "[ bracket unicode start of text text intro var x pyk var p tex var t end intro end text end unicode text end bracket ]" intro * pyk * tex * end intro} % \index{intro * pyk * tex * end intro "[ bracket unicode start of text text intro var x pyk var p tex var t end intro end text end unicode text end bracket ]"}% % \tex{"[ math tex define intro var x pyk var p tex var t end intro as "\index{\alpha #2. @\back \makebox[20mm][l]{$[#1/tex name/tex.]$}#2.}% \index{pyk: #2. $[#1/tex name/tex.]$}% \tex{ $[#1/tex name/tex. \stackrel {\mathrm {tex}}{=} #3/tex name. ]$}$[ #1/tex name/tex.% ]$\footnote{$[#1/tex name/tex. \stackrel {\mathrm {pyk}}{=} #2/tex name. ]$}" end define end math ]"}% % \tex{"[ math tex name define intro var x pyk var p tex var t end intro as " intro(#1. ,#2. ,#3. )" end define end math ]"}% % \display{"[ math macro define intro var x pyk var p tex var t end intro as make visible math pyk define var x as var p end define end math end visible then make visible math tex define var x as var t end define end math end visible end define end math ]"% % \footnote{"[ math pyk define intro var x pyk var p tex var t end intro as "intro * pyk * tex * end intro" end define end math ]"}} \subsubsection{Further intro constructs}\sect{FurtherIntroConstruct} The following four constructs all help introducing new constructs. Each of them expand into pyk and tex and, optionally, tex name definitions. But they also render the pyk definition as a footnote, defer the tex and tex name definitions to an appendix, and make two entries in the index. One of the entries has form ``pyk: (pyk name) (tex rendering)''. The other entry has form ``(index): (tex rendering) (pyk name)''. If no index is given, then the latter entry has form ``(tex rendering) (pyk name)'' and is placed in front of other entries in the index. The four constructs are defined thus: "[ display math macro define var x intro var y pyk var p tex var t end intro as var x then make visible math pyk define var y as var p end define end math end visible then make visible math tex define var y as var t end define end math end visible end define end math intro var x intro var y pyk var p tex var t end intro index "intro" pyk "* intro * pyk * tex * end intro" tex "#1.% \footnote{$[#2/tex name/tex. \stackrel {\mathrm {pyk}}{=} #3/tex name. ]$}\index{\alpha #3. @\back \makebox[20mm][l]{$[#2/tex name/tex.]$}#3.}% \index{pyk: #3. $[#2/tex name/tex.]$}% \tex{ $[#2/tex name/tex. \stackrel {\mathrm {tex}}{=} #4/tex name. ]$}" name "#1. /intro(#2. ,#3. ,#4. )" end intro end display ]" "[ display math macro define var x intro var y index var i pyk var p tex var t end intro as var x then make visible math pyk define var y as var p end define end math end visible then make visible math tex define var y as var t end define end math end visible end define end math intro var x intro var y index var i pyk var p tex var t end intro index "indexintro" pyk "* intro * index * pyk * tex * end intro" tex "#1.% \footnote{$[#2/tex name/tex. \stackrel {\mathrm {pyk}}{=} #4/tex name. ]$}\index{#3.: #4. @#3.: $[#2/tex name/tex.]$ #4.}% \index{pyk: #4. $[#2/tex name/tex.]$}% \tex{ $[#2/tex name/tex. \stackrel {\mathrm {tex}}{=} #5/tex name. ]$}" name "#1. /indexintro(#2. ,#3. ,#4. ,#5. )" end intro end display ]" "[ display math macro define var x intro var y pyk var p tex var t name var n end intro as var x then make visible math pyk define var y as var p end define end math end visible then make visible math tex define var y as var t end define end math end visible then make visible math tex name define var y as var n end define end math end visible end define end math intro var x intro var y pyk var p tex var t name var n end intro index "nameintro" pyk "* intro * pyk * tex * name * end intro" tex "#1.% \footnote{$[#2/tex name/tex. \stackrel {\mathrm {pyk}}{=} #3/tex name. ]$}\index{\alpha #3. @\back \makebox[20mm][l]{$[#2/tex name/tex.]$}#3.}% \index{pyk: #3. $[#2/tex name/tex.]$}% \tex{ $[#2/tex name/tex. \stackrel {\mathrm {tex}}{=} #4/tex name. ]$} \tex{ $[#2/tex name/tex. \stackrel {\mathrm {name}}{=} #5/tex name. ]$}" name "#1. /nameintro(#2. ,#3. ,#4. ,#5. )" end intro end display ]" "[ display math macro define var x intro var y index var i pyk var p tex var t name var n end intro as var x then make visible math pyk define var y as var p end define end math end visible then make visible math tex define var y as var t end define end math end visible then make visible math tex name define var y as var n end define end math end visible end define end math intro var x intro var y index var i pyk var p tex var t name var n end intro index "bothintro" pyk "* intro * index * pyk * tex * name * end intro" tex "#1.% \footnote{$[#2/tex name/tex. \stackrel {\mathrm {pyk}}{=} #4/tex name. ]$}\index{#3.: #4. @#3.: $[#2/tex name/tex.]$ #4.}% \index{pyk: #4. $[#2/tex name/tex.]$}% \tex{ $[#2/tex name/tex. \stackrel {\mathrm {tex}}{=} #5/tex name. ]$} \tex{ $[#2/tex name/tex. \stackrel {\mathrm {name}}{=} #6/tex name. ]$}" name "#1. /bothintro(#2. ,#3. ,#4. ,#5. ,#6. )" end intro end display ]" \section{Claims}\sect{Claims} \subsection{The claim aspect} We define the \indexintro{claim} of a page to be the potentially inherited claim aspect of the page (c.f.\ \ref{section:InheritedAspects}). Logiweb checks the correctness of a Logiweb page by applying the claim of the page to the expansion and cache of the page. If the result is "[ bracket true end bracket ]" then the page is considered correct. If the page has no potentially inherited claim aspect then the page is said to make no claim and is considered trivially correct. We shall refer to the result of applying the claim of a page to the expansion and cache of the page as the \indexintro{correctness} of the page. The correctness equals "[ bracket true end bracket ]" for pages that are correct, including pages that are trivially correct. Pages are in error if their correctness differs from "[ bracket true end bracket ]". In that case Logiweb prunes the correctness (c.f. Section \ref{section:pruning}) and hangs the result on the \indexintro{diagnose} hook (c.f.\ Section \ref{section:TheRackOfAPage}) of the page. The proclaimation of the ``claim'' aspect reads: \display{"[ math proclaim claim as text "claim" end text end proclaim end math ]"} For convenience, we define a construct for making claim definitions: % \index{claim define x as y end define "[ bracket unicode start of text claim define var x as var y end define end unicode text end bracket ]"}% % \index{claim: "[ bracket unicode start of text claim define var x as var y end define end unicode text end bracket ]" claim define x as y end define}% % \tex{"[ math tex define claim define x as x end define as " [#1/tex name/tex. \stackrel {claim}{=}#2. ]" end define end math ]"}% % \display{"[ math macro define claim define var x as var y end define as define claim of var x as var y end define end define end math ]"% % \footnote{"[ math pyk define claim define var x as var y end define as "claim define * as * end define" end define end math ]"}} % \subsection{Conjunction of claims} Logiweb merely allows a page to make one claim. But that claim can be arbitrarily complex. As we shall see, the claim of the present page is the conjuctions of a ``checker'' and a ``verifier''. The ``checker'' scans the expansion of the page for tests like "[ math test false double three tagged equal seven end test end math ]" and checks the correctness of them all. In contrast, the ``verifier'' scans the codex for proofs and verifies all proofs found. Claims may be combined into a conjunction using "[ bracket var x claim and var y end bracket ]": % \index{\alpha x simple and y @\back "[ bracket var x simple and var y end bracket ]" x simple and y}% % \index{x simple and y "[ bracket var x simple and var y end bracket ]"}% % \tex{"[ math tex define var x simple and var y as "#1. \mathrel{\tilde{\wedge}} #2." end define end math ]"}% % \display{"[ math value define var x simple and var y as if var x then var y else var x end if end define end math ]"% % \footnote{"[ math pyk define var x simple and var y as "* simple and *" end define end math ]"}} % % \index{c: \back "[ bracket var x claim and var y end bracket ]" x claim and y}% % \index{\alpha x claim and y @\back "[ bracket var x claim and var y end bracket ]" x claim and y}% % \index{x claim and y "[ bracket var x claim and var y end bracket ]"}% % \tex{"[ math tex define var x claim and var y as "#1. \wedge_c #2." end define end math ]"}% % \display{"[ math value define var x claim and var y as lambda var t dot lambda var c dot var x apply var t apply var c simple and var y apply var t apply var c end define end math ]"% % \footnote{"[ math pyk define var x claim and var y as "* claim and *" end define end math ]"}} % \subsection{The checker} The \indexintro{checker} checks the correctness of all test statements on a page: % \index{checker @\back"[ bracket checker end bracket ]" checker}% % \display{"[ math value define checker as lambda var t dot lambda var c dot check var t cache var c end check end define end math ]"% % \footnote{"[ math pyk define checker as "checker" end define end math ]"}} % The construct % \index{check 1 @\back "[ bracket check var t cache var c end check end bracket ]"} \tex{"[ math tex define check x cache x end check as " \mathbf{check}( #1. , #2. )" end define end math ]"}"[ bracket check var t cache var c end check end bracket ]"\footnote{"[ math pyk define check var t cache var c end check as "check * cache * end check" end define end math ]"} % allows to check that all claims in the term "[ bracket var t end bracket ]" evaluate to "[ bracket true end bracket ]". If some claim is false then "[ bracket check var t cache var c end check end bracket ]" returns the value of the first false claim found. Such a non-nil value is a Logiweb \indexintro{diagnose}. To be useful, a diagnose should be a G{\"!o}del tree that can be typeset and which gives a clue what went wrong. "[ bracket check var t cache var c end check end bracket ]" skips all page constructs when checking "[ bracket var t end bracket ]". \display{"[ math value define check var t cache var c end check as tagged if var t id is singular then var c tagged guard true else check two var t cache var c def aspect claim aspect term var t cache var c end aspect end check end if end define end math ]"} The construct % \index{check 2 @\back "[ bracket check two var t cache var c def var d end check end bracket ]"} \tex{"[ math tex define check two x cache x def x end check as " \mathbf{check}_2( #1. , #2. , #3. )" end define end math ]"}"[ bracket check two var t cache var c def var d end check end bracket ]"\footnote{"[ math pyk define check two var t cache var c def var d end check as "check two * cache * def * end check" end define end math ]"} % allows to check that all claims in "[ bracket var t end bracket ]" evaluate to "[ bracket true end bracket ]" where "[ bracket var d end bracket ]" is the definition of the claim aspect of the root of "[ bracket var t end bracket ]". \display{"[ math value define check two var t cache var c def var d end check as var d select check three var t cache var c def aspect definition aspect term var t cache var c end aspect end check else normalizing untag eval var d third stack true cache var c end eval tagged apply var t tagged apply var c end untag end select end define end math ]"} The construct % \index{check 3 @\back "[ bracket check three var t cache var c def var d end check end bracket ]"} \tex{"[ math tex define check three x cache x def x end check as " \mathbf{check}_3( #1. , #2. , #3. )" end define end math ]"}"[ bracket check three var t cache var c def var d end check end bracket ]"\footnote{"[ math pyk define check three var t cache var c def var d end check as "check three * cache * def * end check" end define end math ]"} % allows to check that all claims in "[ bracket var t end bracket ]" evaluate to "[ bracket true end bracket ]". "[ bracket check three var t cache var c def var d end check end bracket ]" does not descend into trees whose root has a definition aspect "[ bracket var d end bracket ]". For that reason, checking does not occur inside definitions, introductions, proclamations, and trees with a ``hide'' construct in its root. In particular, no checking is done inside strings since strings have a ``hide'' construct in their root. This saves a lot of cpu-time. Furthermore, no checking is done inside definitions. This is convenient since otherwise one could not pyk, \TeX, macro, and priority define test constructs (c.f. Section \ref{section:TestForTruth} ff) without getting spurious errors from the occurrences of the test constructs inside the definitions of the test constructs themselves. \display{"[ math value define check three var t cache var c def var d end check as tagged if var d then check list var t tail cache var c end check else var t tagged guard var c tagged guard true end if end define end math ]"} The construct % \index{check 4 @\back "[ bracket check list var t cache var c end check end bracket ]"} \tex{"[ math tex define check list x cache x end check as " \mathbf{check}^*( #1. , #2. )" end define end math ]"}"[ bracket check list var t cache var c end check end bracket ]"\footnote{"[ math pyk define check list var t cache var c end check as "check list * cache * end check" end define end math ]"} % allows to check that all claims in the list "[ bracket var t end bracket ]" of terms evaluate to "[ bracket true end bracket ]". \display{"[ math value define check list var t cache var c end check as tagged if var t then var c tagged guard true else check list two var t tail cache var c value check var t head cache var c end check end check end if end define end math ]"} The construct % \index{check 5 @\back "[ bracket check list two var t cache var c value var v end check end bracket ]"} \tex{"[ math tex define check list two x cache x value x end check as " \mathbf{check}^*_2( #1. , #2. , #3. )" end define end math ]"}"[ bracket check list two var t cache var c value var v end check end bracket ]"\footnote{"[ math pyk define check list two var t cache var c value var v end check as "check list two * cache * value * end check" end define end math ]"} % also allows to check that all claims in the list "[ bracket var t end bracket ]" of terms evaluate to "[ bracket true end bracket ]" except that it returns "[ bracket var v end bracket ]" if "[ bracket var v end bracket ]" is false. \display{"[ math value define check list two var t cache var c value var v end check as tagged if not var v then var t tagged guard var c tagged guard var v else check list var t cache var c end check end if end define end math ]"} \subsection{Installing the checker}\label{section:InstallingTheChecker} We now define \display{"[ math claim define self as checker claim and verifier end define end math ]"} Because of the definition above, the present page claims that "[ bracket check var t cache var c end check end bracket ]" is true where "[ bracket var t end bracket ]" and "[ bracket var c end bracket ]" are the expansion and cache, respectively, of the present page (the claim above also invokes "[ bracket verifier end bracket ]" which is defined later). Another page that uses the present page as bed and makes no claim of its own also claims that "[ bracket check var t cache var c end check end bracket ]" is true but then "[ bracket var t end bracket ]" and "[ bracket var c end bracket ]" are the expansion and cache, respectively, of that other page. \subsection{Test for truth}\label{section:TestForTruth} The construct % \index{test x end test "[ bracket test var x end test end bracket ]"} \index{\alpha test x end test @\back "[ bracket test var t end test end bracket ]" test t end test} \tex{"[ math tex define test x end test as " \relax [ #1. \relax ]^{\cdot} " end define end math ]"}"[ math test var t end test end math ]"\footnote{"[ math pyk define test var t end test as "test * end test" end define end math ]"} % allows to claim that a term "[ bracket var t end bracket ]" evaluates to "[ bracket true end bracket ]". \display{"[ math claim define test var t end test as lambda var t dot lambda var c dot if map untag eval var t first stack true cache var c end eval end untag then true else var t end if end define end math ]"} As an example, one may claim that "[ bracket false double three end bracket ]" equals seven: \display{"[ math test false double three tagged equal seven end test end math ]"} "[ math test meta a end test end math ]" returns the G{\"!o}del tree of "[ math test meta a end test end math ]" as the diagnose if the claim fails. The overall claim defined in Section \ref{section:InstallingTheChecker} returns the value of the first failing claim (if any). Hence, if "[ math test false double three tagged equal seven end test end math ]" failed and was the first failing claim found, then the value of the claim of the page would be the G{\"!o}del tree of "[ math test false double three tagged equal seven end test end math ]". Reasonable Logiweb compilers typeset the diagnose so that the failing claim is easy to identify. Note that macro expansion occurs before checking, so the G{\"!o}del tree of a failing claim is the macro expanded version of the claim. The macro expansion facility defined on the present page, however, carefully carries debugging information around when macro expanding, so the debugging information in the root of the expanded G{\"!o}del tree indicates the exact location of the failing claim in the unexpanded page. Note that "[ math test var t end test end math ]" does not fail; all unbound variables evaluate to "[ bracket true end bracket ]". \subsection{Test for falsehood} The construct % \index{false test x end test "[ bracket unicode start of text false test var x end test end unicode text end bracket ]"}% % \index{\alpha false test x end test @\back "[ bracket unicode start of text false test var x end test end unicode text end bracket ]" false test t end test}% % \tex{"[ math tex define false test var x end test as " \relax [ #1. \relax ]^{-} " end define end math ]"}% % \display{"[ math claim define false test var x end test as lambda var t dot lambda var c dot if map untag eval var t first stack true cache var c end eval end untag then var t else true end if end define end math ]"% % \footnote{"[ math pyk define false test var x end test as "false test * end test" end define end math ]"}} % tests that its argument is false. As an example of use, one may claim that "[ bracket two tagged equal three end bracket ]" is false: \display{"[ math false test two tagged equal three end test end math ]"} \subsection{Raw test} Like "[ math test var t end test end math ]", the construct % \index{raw test x end test "[ bracket raw test var x end test end bracket ]"} \index{\alpha raw test x end test @\back "[ bracket raw test var t end test end bracket ]" raw test t end test} \tex{"[ math tex define raw test x end test as " \relax [ #1. \relax ]^{\circ} " end define end math ]"}"[ math raw test var t end test end math ]"\footnote{"[ math pyk define raw test var t end test as "raw test * end test" end define end math ]"} % allows to claim that a term "[ bracket var t end bracket ]" evaluates to "[ bracket true end bracket ]". Contrary to "[ math test var x end test end math ]", "[ math raw test var x end test end math ]" just returns the value of "[ bracket var x end bracket ]". This is useful for constructs that generate their own error messages. \display{"[ math claim define raw test var t end test as lambda var t dot lambda var c dot map untag eval var t first stack true cache var c end eval end untag end define end math ]"} \subsection{Spy construct}\sect{SpyConstruct} "[ math introduce value of var x spy var y as var x tagged guard var y end introduce end math intro var x spy var y index "spy" pyk "* spy *" tex "#1."n\mathrel{spy}#2." end intro ]" evaluates "[ bracket var x end bracket ]", discards the value, evaluates "[ bracket var y end bracket ]", and returns the value of "[ bracket var y end bracket ]". However, behind the scene, "[ bracket var x spy var y end bracket ]" also stores the value of "[ bracket var x end bracket ]" in the Lisp variable *spy*. "[ math macro define spying test var x end test as test quote var x end quote spy var x end test end define end math intro spying test var x end test pyk "spying test * end test" tex ""n[#1."n]^{\cdot}" end intro ]" is exactly like an ordinary test except that it calls the spy function (the spying nature is emphasized by the fact that spying and non-spying tests are rendered identically:-). "[ math macro define false spying test var x end test as false test quote var x end quote spy var x end test end define end math intro false spying test var x end test pyk "false spying test * end test" tex ""n[#1."n]^-" end intro ]" is a spying test for falsehood. Spying tests are good for debugging when some test loops indefinitely. If a test case loops indefinitely, then *spy* will typically contain the last spying test that was executed before the infinite loop. \section{Logiweb sequent calculus} The \index{sequent calculus}\index{calculus, sequent}\indexintro{Logiweb sequent calculus} is the low level theory (or ``metatheory'') that comes with Logiweb. Users may use Logiweb sequent calculus and its associated proof checker as they are or use them as a model for constructing their own proof checkers. The Logiweb sequent calculus corresponds to the assembly language of computing machines. It is possible in principle to use it as it is, but it is much more efficient to use higher level theories built on top of the calculus. When building theories on top of the calculus, the calculus ensures correctness whereas the high level theories provide user friendliness. Programming bugs in the high level theories cannot compromise correctness since correctness is ensured by the low level sequent calculus. Only bugs in the implementation of the sequent calculus and in the levels below can compromise correctness. In contrast, \indexintro{Map Theory} described later is the high level theory that comes with Logiweb. Again, users may use Map Theory as it is or use it as a model for constructing their own theories. Map Theory is a high level theory implemented on top of the Logiweb sequent calculus. Map Theory is a classical theory with power as classical ZFC set theory. Contrary to Set Theory, Map Theory builds on lambda calculus. More specificially, Map Theory is the result of adding quantifiers to the Logiweb computing engine. For that reason, Map Theory is suited both for classical mathematics and for reasoning about programs in general and programs for the Logiweb engine in particular. Logiweb sequent calculus is intuitionistic and has much less power than Map Theory. Now let "[ bracket meta m end bracket ]" be the intuitionistic conjunction of all axioms, axioms schemes, and inference rules of Map Theory and let "[ bracket meta l end bracket ]" be a lemma of Map Theory. In general, "[ bracket meta l end bracket ]" will not be intuitionistically valid and, hence, "[ bracket meta l end bracket ]" will not be a lemma of Logiweb sequent calculus. But the statement that "[ bracket meta m end bracket ]" infers "[ bracket meta l end bracket ]", written "[ bracket meta m infer meta l end bracket ]", will be intuitionistically valid, and that is the lemma to be proved from the point of view of the sequent calculus. Hence, if the user proves a lemma "[ bracket meta l end bracket ]" in Map Theory, then the lemma will be translated into "[ bracket meta m infer meta l end bracket ]" and the proof will be translated into a proof of that statement in the sequent calculus. Now let "[ bracket meta z end bracket ]" be the intuitionistic conjunction of all axioms, axiom schemes, and inference rules of classical ZFC set theory. At the time of writing, a rather large, formal proof of "[ bracket meta m infer meta z end bracket ]" exists, and that particular proof is going to be the main test case for checkout of the Logiweb system. The lemma "[ bracket meta m infer meta z end bracket ]" says that Map Theory can ``simulate'' ZFC set theory and that all developments possible in ZFC set theory are also possible in Map Theory. \subsection{Statements} \subsubsection{Messages} Logiweb comes with a number of predefined aspects like "[ bracket pyk end bracket ]", "[ bracket tex end bracket ]", "[ bracket value end bracket ]", and "[ bracket macro end bracket ]". Logiweb also has a facility for defining new aspects. New aspects are introduced using the \indexintro{message} aspect. The message aspect is a predefined one and, hence, has to be proclaimed: \display{\index{msg @\back "[ bracket message end bracket ]" message}\tex{"[ math tex define message as ""nmsg" end define end math ]"}"[ math proclaim message as text "message" end text end proclaim end math ]"\footnote{"[ math pyk define message as "message" end define end math ]"}} For convenience, we define a construct for making message definitions: \index{message define x as y end define "[ math unicode start of text message define var x as var y end define end unicode text end math ]"}% % \index{msg: "[ math unicode start of text message define var x as var y end define end unicode text end math ]" message define x as y end text end define}% % \tex{"[ math tex define message define var x as var y end define as " [#1/tex name/tex. \stackrel {msg}{=} #2. ]" end define end math ]"}% % \display{% "[ math macro define message define var x as var y end define as define message of protect var x end protect as var y end define end define end math ]"% % \footnote{"[ math pyk define message define var x as var y end define as "message define * as * end define" end define end math ]"}} Just like a construct may have e.g.\ a value aspect, a construct may have a message aspect. If a construct "[ bracket meta a end bracket ]" has a message aspect "[ bracket meta b end bracket ]", then "[ bracket meta a end bracket ]" denotes the aspect "[ bracket meta b end bracket ]". Hence, "[ bracket meta b end bracket ]" becomes an aspect by occurring in the right hand side of a message definition. If two constructs "[ bracket meta a sub one end sub end bracket ]" and "[ bracket meta a sub two end sub end bracket ]" both have message aspect "[ bracket meta b end bracket ]" then "[ bracket meta a sub one end sub end bracket ]" and "[ bracket meta a sub two end sub end bracket ]" denote the same aspect. The ability to have several constructs that denote the same aspect allows different users to use different notation for the same aspect. This is important because of the notational freedom of mathematics. If a construct "[ bracket meta a end bracket ]" has a message aspect "[ bracket meta b end bracket ]" then both "[ bracket meta a end bracket ]" and "[ bracket meta b end bracket ]" may have parameters. Parameters of "[ bracket meta a end bracket ]" allow to define parameterised aspects. Parameters of "[ bracket meta b end bracket ]" have no effect since an aspect is identified by the reference and identifier of the root of "[ bracket meta b end bracket ]". Aspects of Logiweb have a slight resemblance with messages in object-oriented programming, and for that reason, we use ``aspect'' and ``message'' as synonyms here. But why use ``message'' when ``message'' is just used as a synonym for ``aspect''? The answer is that ``message aspect'' sounds better than ``aspect aspect''. \subsubsection{The statement aspect} We shall refer to entities like axioms and inference rules as \index{statement}\intro{statements}. To define such entities it is convenient to have a \index{aspect, statement}\indexintro{statement aspect}. To introduce a statement aspect, we first introduce % \index{stmt @\back "[ bracket the statement aspect end bracket ]" the statement aspect}% % \index{the statement aspect "[ bracket the statement aspect end bracket ]"}% % \tex{"[ math tex define the statement aspect as " {<}stmt{>}" end define end math ]"}% % "[ bracket the statement aspect end bracket ]"% % \footnote{"[ math pyk define the statement aspect as "the statement aspect" end define end math ]"} % to represent it. "[ bracket the statement aspect end bracket ]" has a "[ bracket pyk end bracket ]" definition so that it can be referred to in pyk source files and a "[ bracket tex end bracket ]" definition so that it can be rendered in \TeX\ output from Logiweb, and it evaluates to itself: \display{"[ math value define the statement aspect as quote the statement aspect end quote end define end math ]"} Apart from that "[ bracket the statement aspect end bracket ]" is inert. Its purpose is to occur in the right hand side of a message definition where it identifies the statement aspect. We shall use "[ bracket statement end bracket ]" to denote the statement aspect: \display{\index{statement "[ bracket statement end bracket ]"} \index{stmt @\back "[ bracket statement end bracket ]" statement}\tex{"[ math tex define statement as ""nstmt" end define end math ]"}"[ math message define statement as the statement aspect end define end math ]"\footnote{"[ math pyk define statement as "statement" end define end math ]"}} For convenience, we define a construct for making statement definitions: \index{statement define x as y end define "[ math unicode start of text statement define var x as var y end define end unicode text end math ]"}% % \index{stmt: "[ math unicode start of text statement define var x as var y end define end unicode text end math ]"}% % \tex{"[ math tex define statement define var x as var y end define as " [#1/tex name/tex. \stackrel {stmt}{=}#2. ]" end define end math ]"}% % \display{% "[ math macro define statement define var x as var y end define as define statement of protect var x end protect as var y end define end define end math ]"% % \footnote{"[ math pyk define statement define var x as var y end define as "statement define * as * end define" end define end math ]"}} \subsubsection{Axioms} An \indexintro{axiom} is a statement that somebody accepts as true without proof. As an example, one could declare "[ bracket true head math equal true end bracket ]" as an axiom. The definition % \index{example axiom "[ bracket example axiom end bracket ]"}% % \index{HeadNil @\back "[ bracket example axiom end bracket ]" example axiom}% % \tex{"[ math tex define example axiom as " HeadNil'" end define end math ]"}% % "[ math macro define example axiom as true head math equal true end define end math ]"% % \footnote{"[ math pyk define example axiom as "example axiom" end define end math ]"} % allows to use "[ bracket example axiom end bracket ]" as shorthand for the given axiom. \subsubsection{Axiom schemes}\label{section:AxiomSchemes} An \index{scheme, axiom}\indexintro{axiom scheme} is a systematic collection of axioms. As an example, one could declare "[ bracket all meta a indeed all meta b indeed parenthesis meta a pair meta b end parenthesis head math equal meta a end bracket ]" as an axiom scheme. The axiom scheme says that "[ bracket parenthesis meta a pair meta b end parenthesis head math equal meta a end bracket ]" for all terms "[ bracket meta a end bracket ]" and "[ bracket meta b end bracket ]". The definition % \index{example scheme "[ bracket example scheme end bracket ]"}% % \index{HeadPair @\back "[ bracket example scheme end bracket ]" example scheme}% % \tex{"[ math tex define example scheme as " HeadPair'" end define end math ]"}% % "[ math macro define example scheme as all meta a indeed all meta b indeed parenthesis meta a pair meta b end parenthesis head math equal meta a end define end math ]"% % \footnote{"[ math pyk define example scheme as "example scheme" end define end math ]"} % allows to use "[ bracket example scheme end bracket ]" as shorthand for the given axiom scheme. The variables "[ bracket meta a end bracket ]" and "[ bracket meta b end bracket ]" are \index{variable, meta}\index{metavariable}\intro{metavariables}. Metavariables range over terms as opposed to \index{variable, ordinary}\index{ordinary variable}\intro{ordinary variables} which range over values. For more on metavariables see Section \ref{section:Metavariables}. \subsubsection{Inference rules} An \index{rule, inference}\indexintro{inference rule} is a rule which states that a certain \indexintro{conclusion} follows from one or more \index{premise}\intro{premisses}. An inference rule states that the conclusion is provable if all the premisses are provable. As an example, one could declare "[ bracket all meta a indeed all meta b indeed all meta c indeed meta a math equal meta b infer meta a math equal meta c infer meta b math equal meta c end bracket ]" as an inference rule. The inference rule says that if "[ bracket meta a end bracket ]", "[ bracket meta b end bracket ]", and "[ bracket meta c end bracket ]" are arbitrary terms, and if "[ bracket meta a math equal meta b end bracket ]" and "[ bracket meta a math equal meta c end bracket ]" are provable, then "[ bracket meta b math equal meta c end bracket ]" is provable. The definition % \index{example rule "[ bracket example rule end bracket ]"}% % \index{Transitivity @\back "[ bracket example rule end bracket ]" example rule}% % \tex{"[ math tex define example rule as " Transitivity'" end define end math ]"}% % "[ math macro define example rule as all meta a indeed all meta b indeed all meta c indeed meta a math equal meta b infer meta a math equal meta c infer meta b math equal meta c end define end math ]"% % \footnote{"[ math pyk define example rule as "example rule" end define end math ]"} % allows to use "[ bracket example rule end bracket ]" as shorthand for the given inference rule. \subsubsection{Contradictions} We make the convention that "[ bracket absurdity end bracket ]" represents absurdity. A Logiweb \indexintro{contradiction} is a statement that somebody accepts as false without proof. As an example, one could declare "[ bracket true pair true math equal true end bracket ]" as a contradiction. The contradiction "[ bracket true pair true math equal true end bracket ]" may be expressed as the statement "[ bracket true pair true math equal true infer absurdity end bracket ]". Contradictions were called ``Logiweb contradictions'' first time they were mentioned above. That was done to emphasize that the word ``contradiction'' is used here in a way that is not necessarily in line with the litterature. As we shall see, contradictions have two uses. Firstly, they may be used to refute a conjecture by proving that the conjecture implies a contradiction. Secondly, they may be used to refute a theory as inconsistent by proving that a contradiction is provable within the theory. The definition % \index{Contra' @\back "[ bracket contraexample end bracket ]" contraexample}% % \tex{"[ math tex define contraexample as " Contra'" end define end math ]"}% % "[ math macro define contraexample as true pair true math equal true infer absurdity end define end math ]"% % \footnote{"[ math pyk define contraexample as "contraexample" end define end math ]"} % allows to use "[ bracket contraexample end bracket ]" as shorthand for the given contradiction. \subsubsection{Theories} We shall refer to axioms, axiom schemes, and inference rules as \index{rule}\intro{rules}. A Logiweb \indexintro{theory} is a structure that encodes a finite set of rules and contradictions. As an example, one could declare the rules "[ bracket example axiom end bracket ]", "[ bracket example scheme end bracket ]", and "[ bracket example rule end bracket ]" and the contradiction "[ bracket contraexample end bracket ]" to form a theory. The definition % \index{example theory primed "[ bracket example theory primed end bracket ]"}% % \index{T' @\back "[ bracket example theory primed end bracket ]" example theory primed}% % \tex{"[ math tex define example theory primed as ""nT'_{E}" end define end math ]"}% % \display{"[ math statement define example theory primed as example axiom rule plus example scheme rule plus example rule rule plus contraexample end define end math ]"% % \footnote{"[ math pyk define example theory primed as "example theory primed" end define end math ]"}} % allows to refer to the example theory as "[ bracket example theory primed end bracket ]" (``T'' for ``Theory'', ``E'' for ``Example'', "[ bracket example theory primed end bracket ]" for ``example theory''). The notion of a ``Logiweb theory'' is close to the notion of an ``axiotic theory'' in the litterature. Some branches of the litterature use the word ``theory'' in a quite different sense, namely to denote the set of all statements provable from an axiomatic theory. The notion of a ``Logiweb theory'' differs from the notion of an ``axiomatic theory'' in three ways: Firstly, the notion of a ``Logiweb theory'' has a precise, technical meaning inside the Logiweb framework. The notion of an ``axiomatic theory'' is independent of any framework but is more vague. Secondly, a Logiweb theory may include Logiweb contradictions. Axiomatic theories merely contain rules. Finally, a Logiweb theory contains finitely many rules whereas an axiomatic theory may contain infinitely many. This is because Logiweb theories and axiomatic theories count rules differently. Axiomatic theories count rules in a very peculiar way: (1) inference rules do not count. (2) axioms that are axioms of first order predicate calculus do not count. (3) axiom schemes count as infinitely many rules. A theory like ZFC set theory \cite{mendelson} has the property that it is ``not finitely axiomatizable''. That result depends on the counting used in axiomatic theories. Using Logiweb counting, ZFC has finitely many rules. All axiomatic theories can be expressed as Logiweb theories using finitely many rules. \subsubsection{Conjectures, lemmas, and antilemmas} A Logiweb \indexintro{conjecture} is a statement of form "[ bracket meta t infer meta c end bracket ]" where "[ bracket meta t end bracket ]" is a theory and "[ bracket meta c end bracket ]" is a statement that is expected to follow from the theory. As an example, one could declare "[ bracket example theory primed infer all meta a indeed all meta b indeed meta a math equal meta b infer meta b math equal meta a end bracket ]" as a conjecture. The definition \index{example lemma "[ bracket example lemma end bracket ]"}\index{L @\back "[ bracket example lemma end bracket ]" example lemma}\tex{"[ math tex define example lemma as ""nL_{1}" end define end math ]"}"[ math statement define example lemma as example theory primed infer all meta a indeed all meta b indeed meta a math equal meta b infer meta b math equal meta a end define end math ]"\footnote{"[ math pyk define example lemma as "example lemma" end define end math ]"} allows to refer to the given conjecture as "[ bracket example lemma end bracket ]". Later, we introduce the ``Logiweb proof checker'' and the notion of a ``Logiweb proof''. Once a proof of a conjecture is written, accepted by the proof checker, and published on Logiweb, one may refer to the conjecture as a Logiweb \indexintro{lemma}. Furthermore, if "[ bracket meta t infer meta c infer absurdity end bracket ]", i.e. "[ bracket meta t infer parenthesis meta c infer absurdity end parenthesis end bracket ]" is a Logiweb lemma then one may refer to the conjecture "[ bracket meta t infer meta c end bracket ]" as a Logiweb \indexintro{antilemma}. \subsubsection{Statement constructors} We shall refer to a term as a \indexintro{statement} if we care about its mathematical truth. Hence, rules, contradictions, theories, conjectures, lemmas, and antilemmas are statements. The constructors % \index{x infer y "[ bracket var x infer var y end bracket ]"}% % \index{\alpha x infer y@\back "[ bracket var x infer var y end bracket ]" x infer y}% % \tex{"[ math tex define var x infer var y as "#1. \vdash #2." end define end math ]"}% % "[ bracket var x infer var y end bracket ]"% % \footnote{"[ math pyk define var x infer var y as "* infer *" end define end math ]"}, % \index{x endorse y "[ bracket var x endorse var y end bracket ]"}% % \index{\alpha x endorse y@\back "[ bracket var x endorse var y end bracket ]" x endorse y}% % \tex{"[ math tex define var x endorse var y as "#1. \mathrel {\makebox [0mm][l]{$\vdash $}\,{\vdash }} #2." end define end math ]"}% % "[ bracket var x endorse var y end bracket ]"% % \footnote{"[ math pyk define var x endorse var y as "* endorse *" end define end math ]"}, % % % \index{all x indeed y "[ bracket all var x indeed var y end bracket ]"}% % \index{\alpha all x indeed y@\back "[ bracket all var x indeed var y end bracket ]" all x indeed y}% % \tex{"[ math tex define all var x indeed var y as " \forall #1. \colon #2." end define end math ]"}% % "[ bracket all var x indeed var y end bracket ]"% % \footnote{"[ math pyk define all var x indeed var y as "all * indeed *" end define end math ]"}, % % % \index{\alpha absurdity @\back "[ bracket absurdity end bracket ]" absurdity}% % \index{absurdity "[ bracket absurdity end bracket ]"}% % \tex{"[ math tex define absurdity as " {\makebox [0mm][l]{$\bot $}\,{\bot }}" end define end math ]"}% % "[ bracket absurdity end bracket ]"% % \footnote{"[ math pyk define absurdity as "absurdity" end define end math ]"}, and % % % \index{x rule plus y "[ bracket var x rule plus var y end bracket ]"}% % \index{\alpha x rule plus y@\back "[ bracket var x rule plus var y end bracket ]" x rule plus y}% % \tex{"[ math tex define var x rule plus var y as "#1. \mathrel {\oplus} #2." end define end math ]"}% % "[ bracket var x rule plus var y end bracket ]"% % \footnote{"[ math pyk define var x rule plus var y as "* rule plus *" end define end math ]"} % % % allow to form statements from arbitrary terms and statements: \begin{itemize} \item "[ bracket meta a infer meta b end bracket ]" reads "[ bracket meta a end bracket ]" \index{infer}\intro{infers} "[ bracket meta b end bracket ]" and states that if "[ bracket meta a end bracket ]" is provable then "[ bracket meta b end bracket ]" is provable. \item "[ bracket meta a endorse meta b end bracket ]" reads "[ bracket meta a end bracket ]" \index{endorse}\intro{endorses} "[ bracket meta b end bracket ]" and states that if "[ bracket meta a end bracket ]" evaluates to "[ bracket true end bracket ]" then "[ bracket meta b end bracket ]" is provable. \item "[ bracket all meta a indeed meta b end bracket ]" reads \intro{all} "[ bracket meta a end bracket ]" \intro{indeed} "[ bracket meta b end bracket ]" and states that "[ bracket meta b end bracket ]" is provable for all terms "[ bracket meta a end bracket ]". \item "[ bracket absurdity end bracket ]" reads \indexintro{absurdity}. One may claim that a term "[ bracket meta a end bracket ]" is disprovable by the statement "[ bracket meta a infer absurdity end bracket ]". \item "[ bracket meta a rule plus meta b end bracket ]" reads "[ bracket meta a end bracket ]" \index{plus, rule}\indexintro{rule plus} "[ bracket meta b end bracket ]" and states that "[ bracket meta a end bracket ]" and "[ bracket meta b end bracket ]" are provable. \end{itemize} All the constructors above except endorsement have been used in examples. According to the Unicode standard, "[ bracket unicode end of text endorse unicode end of text end bracket ]" reads ``forses'', but we use "[ bracket meta a endorse meta b end bracket ]" for endorsement rather than enforcement. "[ bracket meta a endorse meta b end bracket ]" states that the side condition "[ bracket meta a end bracket ]" endorses the conclusion "[ bracket meta b end bracket ]". The construct can be used for statements like ``"[ bracket meta b end bracket ]" is free for "[ bracket meta x end bracket ]" in "[ bracket meta a end bracket ]" endorses "[ bracket parenthesis lambda meta x dot meta a end parenthesis apply meta b math equal substitute meta a set meta x to meta b end substitute end bracket ]". To give a meaningful example of the use of endorsement, however, one has to program some side condition like ``is free for'' first. Examples of use of endorsement will be given later. \subsubsection{Self-evaluation} We define the statement constructors such that they are ``self-evaluating''. As an example, the definition of "[ math var x infer var y end math ]" is such that e.g.\ "[ bracket quote meta a end quote infer quote meta b end quote end bracket ]" and "[ bracket quote meta a infer meta b end quote end bracket ]" are equal terms (equal except for debugging information present in the terms which indicates exactly where the terms occur on the Logiweb page). The following definitions make the constructors self-evaluating: "[ math value define var x infer var y as tuple quote var x infer var y end quote root comma var x comma var y end tuple end define end math ]" "[ math value define var x endorse var y as tuple quote var x endorse var y end quote root comma var x comma var y end tuple end define end math ]" "[ math value define all var x indeed var y as tuple quote all var x indeed var y end quote root comma var x comma var y end tuple end define end math ]" "[ math value define absurdity as tuple quote absurdity end quote root end tuple end define end math ]" "[ math value define var x rule plus var y as tuple quote var x rule plus var y end quote root comma var x comma var y end tuple end define end math ]" "[ math value define var x init as tuple quote var x init end quote root comma var x end tuple end define end math ]" "[ math value define var x modus as tuple quote var x modus end quote root comma var x end tuple end define end math ]" "[ math value define var x verify as tuple quote var x verify end quote root comma var x end tuple end define end math ]" "[ math value define var x curry plus as tuple quote var x curry plus end quote root comma var x end tuple end define end math ]" "[ math value define var x curry minus as tuple quote var x curry minus end quote root comma var x end tuple end define end math ]" "[ math value define var x dereference as tuple quote var x dereference end quote root comma var x end tuple end define end math ]" "[ math value define var x at var y as tuple quote var x at var y end quote root comma var x comma var y end tuple end define end math ]" "[ math value define var x id est var y as tuple quote var x id est var y end quote root comma var x comma var y end tuple end define end math ]" "[ math value define var x cut var y as tuple quote var x cut var y end quote root comma var x comma var y end tuple end define end math ]"% % \test{"[ math test parenthesis quote two end quote infer quote three end quote end parenthesis term equal quote two infer three end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote endorse quote three end quote end parenthesis term equal quote two endorse three end quote end test end math ]"}% % \test{"[ math test parenthesis all quote two end quote indeed quote three end quote end parenthesis term equal quote all two indeed three end quote end test end math ]"}% % \test{"[ math test absurdity term equal quote absurdity end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote rule plus quote three end quote end parenthesis term equal quote two rule plus three end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote init end parenthesis term equal quote two init end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote modus end parenthesis term equal quote two modus end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote verify end parenthesis term equal quote two verify end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote curry plus end parenthesis term equal quote two curry plus end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote curry minus end parenthesis term equal quote two curry minus end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote dereference end parenthesis term equal quote two dereference end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote at quote three end quote end parenthesis term equal quote two at three end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote id est quote three end quote end parenthesis term equal quote two id est three end quote end test end math ]"}% % \test{"[ math test parenthesis quote two end quote cut quote three end quote end parenthesis term equal quote two cut three end quote end test end math ]"}% % \subsection{Metavariables}\label{section:Metavariables} \subsubsection{Definition of metavariables} As mentioned in Section \ref{section:AxiomSchemes}, \indexintro{metavariables} range over terms as opposed to ordinary variables which range over values. In the sequent calculus presented in Section \ref{section:SequentCalculus} we need to distinguish metavariables from other variables. To do so, we simply introduce the unary operator % \index{\alpha metavar x end metavar @\back "[ bracket metavar var x end metavar end bracket ]" metavar x end metavar}% % \index{metavar x end metavar "[ bracket metavar var x end metavar end bracket ]"}% % \tex{"[ math tex define metavar var x end metavar as "\underline{#1.}" end define end math ]"}% % "[ bracket metavar var x end metavar end bracket ]"% % \footnote{"[ math pyk define metavar var x end metavar as "metavar * end metavar" end define end math ]"} % and make the convention that a term is a metavariable iff it has the "[ bracket metavar x end metavar end bracket ]" construct in its root. Having this convention in place, we introduce the metavariables \hskip0em plus2.0em % % a % \tex{"[ math tex define meta a as "{\cal A}" end define end math ]"}% % "[ math macro define meta a as metavar var a end metavar end define end math ]"% % \footnote{"[ math pyk define meta a as "meta a" end define end math ]"}, \hskip0em plus2.0em % % % b % \tex{"[ math tex define meta b as "{\cal B}" end define end math ]"}% % "[ math macro define meta b as metavar var b end metavar end define end math ]"% % \footnote{"[ math pyk define meta b as "meta b" end define end math ]"}, \hskip0em plus2.0em % % % c % \tex{"[ math tex define meta c as "{\cal C}" end define end math ]"}% % "[ math macro define meta c as metavar var c end metavar end define end math ]"% % \footnote{"[ math pyk define meta c as "meta c" end define end math ]"}, \hskip0em plus2.0em % % % d % \tex{"[ math tex define meta d as "{\cal D}" end define end math ]"}% % "[ math macro define meta d as metavar var d end metavar end define end math ]"% % \footnote{"[ math pyk define meta d as "meta d" end define end math ]"}, \hskip0em plus2.0em % % % e % \tex{"[ math tex define meta e as "{\cal E}" end define end math ]"}% % "[ math macro define meta e as metavar var e end metavar end define end math ]"% % \footnote{"[ math pyk define meta e as "meta e" end define end math ]"}, \hskip0em plus2.0em % % % f % \tex{"[ math tex define meta f as "{\cal F}" end define end math ]"}% % "[ math macro define meta f as metavar var f end metavar end define end math ]"% % \footnote{"[ math pyk define meta f as "meta f" end define end math ]"}, \hskip0em plus2.0em % % % g % \tex{"[ math tex define meta g as "{\cal G}" end define end math ]"}% % "[ math macro define meta g as metavar var g end metavar end define end math ]"% % \footnote{"[ math pyk define meta g as "meta g" end define end math ]"}, \hskip0em plus2.0em % % % h % \tex{"[ math tex define meta h as "{\cal H}" end define end math ]"}% % "[ math macro define meta h as metavar var h end metavar end define end math ]"% % \footnote{"[ math pyk define meta h as "meta h" end define end math ]"}, \hskip0em plus2.0em % % % i % \tex{"[ math tex define meta i as "{\cal I}" end define end math ]"}% % "[ math macro define meta i as metavar var i end metavar end define end math ]"% % \footnote{"[ math pyk define meta i as "meta i" end define end math ]"}, \hskip0em plus2.0em % % % j % \tex{"[ math tex define meta j as "{\cal J}" end define end math ]"}% % "[ math macro define meta j as metavar var j end metavar end define end math ]"% % \footnote{"[ math pyk define meta j as "meta j" end define end math ]"}, \hskip0em plus2.0em % % % k % \tex{"[ math tex define meta k as "{\cal K}" end define end math ]"}% % "[ math macro define meta k as metavar var k end metavar end define end math ]"% % \footnote{"[ math pyk define meta k as "meta k" end define end math ]"}, \hskip0em plus2.0em % % % l % \tex{"[ math tex define meta l as "{\cal L}" end define end math ]"}% % "[ math macro define meta l as metavar var l end metavar end define end math ]"% % \footnote{"[ math pyk define meta l as "meta l" end define end math ]"}, \hskip0em plus2.0em % % % m % \tex{"[ math tex define meta m as "{\cal M}" end define end math ]"}% % "[ math macro define meta m as metavar var m end metavar end define end math ]"% % \footnote{"[ math pyk define meta m as "meta m" end define end math ]"}, \hskip0em plus2.0em % % % n % \tex{"[ math tex define meta n as "{\cal N}" end define end math ]"}% % "[ math macro define meta n as metavar var n end metavar end define end math ]"% % \footnote{"[ math pyk define meta n as "meta n" end define end math ]"}, \hskip0em plus2.0em % % % o % \tex{"[ math tex define meta o as "{\cal O}" end define end math ]"}% % "[ math macro define meta o as metavar var o end metavar end define end math ]"% % \footnote{"[ math pyk define meta o as "meta o" end define end math ]"}, \hskip0em plus2.0em % % % p % \tex{"[ math tex define meta p as "{\cal P}" end define end math ]"}% % "[ math macro define meta p as metavar var p end metavar end define end math ]"% % \footnote{"[ math pyk define meta p as "meta p" end define end math ]"}, \hskip0em plus2.0em % % % q % \tex{"[ math tex define meta q as "{\cal Q}" end define end math ]"}% % "[ math macro define meta q as metavar var q end metavar end define end math ]"% % \footnote{"[ math pyk define meta q as "meta q" end define end math ]"}, \hskip0em plus2.0em % % % r % \tex{"[ math tex define meta r as "{\cal R}" end define end math ]"}% % "[ math macro define meta r as metavar var r end metavar end define end math ]"% % \footnote{"[ math pyk define meta r as "meta r" end define end math ]"}, \hskip0em plus2.0em % % % s % \tex{"[ math tex define meta s as "{\cal S}" end define end math ]"}% % "[ math macro define meta s as metavar var s end metavar end define end math ]"% % \footnote{"[ math pyk define meta s as "meta s" end define end math ]"}, \hskip0em plus2.0em % % % t % \tex{"[ math tex define meta t as "{\cal T}" end define end math ]"}% % "[ math macro define meta t as metavar var t end metavar end define end math ]"% % \footnote{"[ math pyk define meta t as "meta t" end define end math ]"}, \hskip0em plus2.0em % % % u % \tex{"[ math tex define meta u as "{\cal U}" end define end math ]"}% % "[ math macro define meta u as metavar var u end metavar end define end math ]"% % \footnote{"[ math pyk define meta u as "meta u" end define end math ]"}, \hskip0em plus2.0em % % % v % \tex{"[ math tex define meta v as "{\cal V}" end define end math ]"}% % "[ math macro define meta v as metavar var v end metavar end define end math ]"% % \footnote{"[ math pyk define meta v as "meta v" end define end math ]"}, \hskip0em plus2.0em % % % w % \tex{"[ math tex define meta w as "{\cal W}" end define end math ]"}% % "[ math macro define meta w as metavar var w end metavar end define end math ]"% % \footnote{"[ math pyk define meta w as "meta w" end define end math ]"}, \hskip0em plus2.0em % % % x % \tex{"[ math tex define meta x as "{\cal X}" end define end math ]"}% % "[ math macro define meta x as metavar var x end metavar end define end math ]"% % \footnote{"[ math pyk define meta x as "meta x" end define end math ]"}, \hskip0em plus2.0em % % % y % \tex{"[ math tex define meta y as "{\cal Y}" end define end math ]"}% % "[ math macro define meta y as metavar var y end metavar end define end math ]"% % \footnote{"[ math pyk define meta y as "meta y" end define end math ]"}, and \hskip0em plus2.0em % % % z % \tex{"[ math tex define meta z as "{\cal Z}" end define end math ]"}% % "[ math macro define meta z as metavar var z end metavar end define end math ]"% % \footnote{"[ math pyk define meta z as "meta z" end define end math ]"}. \subsubsection{Recognition of metavariables} \index{V: "[ bracket var x is metavar end bracket ]" x is metavar}% % \index{x is metavar "[ bracket var x is metavar end bracket ]"}% % \tex{"[ math tex define var t is metavar as "#1. {} ^ {\cal V}" end define end math ]"}% % "[ bracket var t is metavar end bracket ]"% % \footnote{"[ math pyk define var t is metavar as "* is metavar" end define end math ]"} % is true if "[ bracket var t end bracket ]" is a metavariable: \display{"[ math value define var t is metavar as var t term root equal quote meta a end quote end define end math ]"}% % \test{"[ math test quote meta p end quote is metavar end test end math ]"}% % \test{"[ math false test quote var p end quote is metavar end test end math ]"} \subsubsection{Closedness} \index{C: "[ bracket var x is metaclosed end bracket ]" x is metaclosed}% % \index{x is metaclosed "[ bracket var x is metaclosed end bracket ]"}% % \tex{"[ math tex define var t is metaclosed as "#1. {} ^ {\cal C}" end define end math ]"}% % "[ bracket var t is metaclosed end bracket ]"% % \footnote{"[ math pyk define var t is metaclosed as "* is metaclosed" end define end math ]"} % is true if the term "[ bracket var t end bracket ]" contains no metavariables and % \index{C*: "[ bracket var x is metaclosed star end bracket ]" x is metaclosed star}% % \index{x is metaclosed star "[ bracket var x is metaclosed star end bracket ]"}% % \tex{"[ math tex define var t is metaclosed star as "#1. {} ^ {{\cal C} ^ { \ast }}" end define end math ]"}% % "[ bracket var t is metaclosed star end bracket ]"% % \footnote{"[ math pyk define var t is metaclosed star as "* is metaclosed star" end define end math ]"} % is true if the list "[ bracket var t end bracket ]" of terms contains no metavariables: \display{"[ math value define var t is metaclosed as tagged if var t is metavar then false else var t tail is metaclosed star end if end define end math ]"} \display{"[ math value define var t is metaclosed star as tagged if var t then true else tagged if var t head is metaclosed then var t tail is metaclosed star else false end if end if end define end math ]"}% % \test{"[ math test quote var x pair var y pair var z end quote is metaclosed end test end math ]"}% % \test{"[ math false test quote var x pair meta y pair var z end quote is metaclosed end test end math ]"} \subsubsection{The ``free in'' predicate} \index{free in: "[ bracket var x free in var y end bracket ]" x free in y }% % \index{x free in y "[ bracket var x free in var y end bracket ]"}% % \tex{"[ math tex define var x free in var y as "#1. \mathrel {free\ in} #2." end define end math ]"}% % "[ bracket var v free in var t end bracket ]"% % \footnote{"[ math pyk define var v free in var t as "* free in *" end define end math ]"} % is true if the metavariable "[ bracket var v end bracket ]" is occurs free in the term "[ bracket var t end bracket ]". Furthermore, % \index{free in*: "[ bracket var x free in star var y end bracket ]" x free in star y }% % \index{x free in star y "[ bracket var x free in star var y end bracket ]"}% % \tex{"[ math tex define var x free in star var y as "#1. \mathrel {free\ in}^{\ast} #2." end define end math ]"}% % "[ bracket var v free in star var t end bracket ]"% % \footnote{"[ math pyk define var v free in star var t as "* free in star *" end define end math ]"} % is true if the metavariable "[ bracket var v end bracket ]" is occurs free in the list "[ bracket var t end bracket ]" of terms. \display{"[ math value define var v free in var t as newline open if var v term equal var t then true else newline open if not var t term root equal quote all x indeed x end quote then var v free in star var t tail else newline open if var v term equal var t first then false else var v free in var t second end define end math ]"} \display{"[ math value define var v free in star var t as tagged if var t then var v tagged guard false else tagged if var v free in var t head then true else var v free in star var t tail end if end if end define end math ]"}% % \test{"[ math test quote meta y end quote free in quote meta x pair meta y pair meta z end quote end test end math ]"}% % \test{"[ math false test quote meta y end quote free in quote meta x pair var y pair meta z end quote end test end math ]"}% \subsubsection{The ``free for'' predicate} % \index{free for: "[ bracket var x free for var y in var z end bracket ]" x free for y in z }% % \index{x free for y in z "[ bracket var x free for var y in var z end bracket ]"}% % \tex{"[ math tex define var a free for var x in var b as "#1. \mathrel {free\ for} #2. \mathrel {in} #3." end define end math ]"}% % "[ bracket var a free for var x in var b end bracket ]"% % \footnote{"[ math pyk define var a free for var x in var b as "* free for * in *" end define end math ]"} % is true if the term "[ bracket var a end bracket ]" is free for the metavariable "[ bracket var x end bracket ]" in the term "[ bracket var b end bracket ]". Furthermore, % \index{free for*: \back "[ bracket var x free for star var y in var z end bracket ]" x free for star y in z }% % \index{x free for star y in z "[ bracket var x free for star var y in var z end bracket ]"}% % \tex{"[ math tex define var a free for star var x in var b as "#1. \mathrel {free\ for}^{\ast} #2. \mathrel {in} #3." end define end math ]"}% % "[ bracket var a free for star x in var b end bracket ]"% % \footnote{"[ math pyk define var a free for star x in var b as "* free for star * in *" end define end math ]"} % is true if the term "[ bracket var a end bracket ]" is free for the metavariable "[ bracket var x end bracket ]" in the list "[ bracket var b end bracket ]" of terms. \display{"[ math value define var a free for var x in var b as var a tagged guard var x tagged guard newline open if var b is metavar then true else newline open if not var b term root equal quote all x indeed x end quote then var a free for star var x in var b tail else newline open if var x term equal var b first then true else newline open if not var x free in var b second then true else newline open if var b first free in var a then false else newline var a free for var x in var b second end define end math ]"} \display{"[ math value define var a free for star var x in var b as newline open if var b then var a tagged guard var x tagged guard true else newline open if var a free for var x in var b head then var a free for star var x in var b tail else false end define end math ]"}% % \test{"[ math test quote var x pair meta y pair var z end quote free for quote meta x end quote in quote all meta x indeed var b pair meta x pair var c end quote end test end math ]"} % \test{"[ math false test quote var x pair meta y pair var z end quote free for quote meta x end quote in quote all meta y indeed var b pair meta x pair var c end quote end test end math ]"} % \test{"[ math test quote var x pair meta y pair var z end quote free for quote meta y end quote in quote all meta x indeed var b pair meta x pair var c end quote end test end math ]"} % \test{"[ math test quote var x pair meta y pair var z end quote free for quote meta y end quote in quote all meta y indeed var b pair meta x pair var c end quote end test end math ]"} \subsubsection{Metavariable substitution} \index{\alpha sub x set y to z end sub @\back "[ bracket sub var x set var y to var z end sub end bracket ]" sub x set y to z end sub }% % \index{sub x set y to z end sub "[ bracket sub var x set var y to var z end sub end bracket ]"}% % \tex{"[ math tex define sub var a set var x to var b end sub as " \langle #1. \,{\protect\vert}#2. {:=}\,#3. \rangle " end define end math ]"}% % "[ bracket sub var a set var x to var b end sub end bracket ]"% % \footnote{"[ math pyk define sub var a set var x to var b end sub as "sub * set * to * end sub" end define end math ]"} % replaces all free occurrences of the metavariable "[ bracket var x end bracket ]" by the term "[ bracket var b end bracket ]" in the term "[ bracket var a end bracket ]". The operation does no renaming of bound variables, so variable clashes will occur if "[ bracket var b end bracket ]" is not free for "[ bracket var x end bracket ]" in "[ bracket var a end bracket ]". Furthermore, % \index{\alpha sub star x set y to z end sub @\back "[ bracket sub star var x set var y to var z end sub end bracket ]" sub star x set y to z end sub }% % \index{sub star x set y to z end sub "[ bracket sub star var x set var y to var z end sub end bracket ]"}% % \tex{"[ math tex define sub star var a set var x to var b end sub as " \langle ^ { \ast } #1. \,{\protect\vert}#2. {:=}\,#3. \rangle " end define end math ]"}% % "[ bracket sub star var a set var x to var b end sub end bracket ]"% % \footnote{"[ math pyk define sub star var a set var x to var b end sub as "sub star * set * to * end sub" end define end math ]"} % replaces all free occurrences of the metavariable "[ bracket var x end bracket ]" by the term "[ bracket var b end bracket ]" in the list "[ bracket var a end bracket ]" of terms. \display{"[ math value define sub var a set var x to var b end sub as var x tagged guard var b tagged guard newline open if var a is metavar then tagged if var a term equal var x then var b else var a end if else newline open if not var a term root equal quote all x indeed x end quote then var a head pair sub star var a tail set var x to var b end sub else newline open if var a first term equal var x then var a else newline tuple var a zeroth comma var a first comma sub var a second set var x to var b end sub end tuple end define end math ]"} \display{"[ math value define sub star var a set var x to var b end sub as var x tagged guard var b tagged guard tagged if var a then true else sub var a head set var x to var b end sub pair sub star var a tail set var x to var b end sub end if end define end math ]"}% % \test{"[ math test sub quote meta a pair parenthesis all meta a indeed meta a end parenthesis pair meta b pair meta a end quote set quote meta a end quote to quote two end quote end sub term equal quote two pair parenthesis all meta a indeed meta a end parenthesis pair meta b pair two end quote end test end math ]"} \subsection{Sequent calculus}\label{section:SequentCalculus} \subsubsection{Term sets} We shall represent sets of terms as lists without repetitions. We require the lists to be without repetitions in the sense that a term "[ bracket var x end bracket ]" is not allowed to occur more than once and, furthermore, if two distinct terms "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" satisfy "[ bracket var x term equal var y end bracket ]" then the lists are not allowed to contain them both. The membership operation % \index{\alpha x term in y @\back "[ bracket var x term in var y end bracket ]" x term in y}% % \index{x term in y "[ bracket var x term in var y end bracket ]"}% % \index{t: "[ bracket var x term in var y end bracket ]"}% % \tex{"[ math tex define var x term in var y as "#1. \in_t #2." end define end math ]"}% % "[ bracket var x term in var y end bracket ]"% % \footnote{"[ math pyk define var x term in var y as "* term in *" end define end math ]"} % is defined thus: \display{"[ math value define var x term in var y as tagged if var y is atomic then var x tagged guard false else tagged if var x term equal var y head then true else var x term in var y tail end if end if end define end math ]"}% % \test{"[ math test quote var y end quote term in tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"}% % \test{"[ math false test quote var u end quote term in tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"} The subset operation % \index{\alpha x term subset y @\back "[ bracket var x term subset var y end bracket ]" x term subset y}% % \index{x term subset y "[ bracket var x term subset var y end bracket ]"}% % \index{T: "[ bracket var x term subset var y end bracket ]"}% % \tex{"[ math tex define var x term subset var y as "#1. \subseteq_T #2." end define end math ]"}% % "[ bracket var x term subset var y end bracket ]"% % \footnote{"[ math pyk define var x term subset var y as "* term subset *" end define end math ]"} % is defined thus: \display{"[ math value define var x term subset var y as tagged if var x is atomic then var y tagged guard true else tagged if var x head term in var y then var x tail term subset var y else false end if end if end define end math ]"}% % \test{"[ math test tuple quote var z end quote comma quote var x end quote end tuple term subset tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"}% % \test{"[ math false test tuple quote var z end quote comma quote var u end quote end tuple term subset tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"} The set equality operation % \index{\alpha x term set equal y @\back "[ bracket var x term set equal var y end bracket ]" x term set equal y}% % \index{x term set equal y "[ bracket var x term set equal var y end bracket ]"}% % \index{T: "[ bracket var x term set equal var y end bracket ]"}% % \tex{"[ math tex define var x term set equal var y as "#1. \stackrel{T}{=} #2." end define end math ]"}% % "[ bracket var x term set equal var y end bracket ]"% % \footnote{"[ math pyk define var x term set equal var y as "* term set equal *" end define end math ]"} % is defined thus: \display{"[ math value define var x term set equal var y as tagged if var x term subset var y then var y term subset var x else false end if end define end math ]"}% % \test{"[ math test tuple quote var z end quote comma quote var y end quote comma quote var x end quote end tuple term set equal tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"}% % \test{"[ math false test tuple quote var z end quote comma quote var x end quote end tuple term set equal tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"}% % \test{"[ math false test tuple quote var z end quote comma quote var y end quote comma quote var x end quote end tuple term set equal tuple quote var x end quote comma quote var z end quote end tuple end test end math ]"} The empty set % \index{\alpha the empty set @\back "[ bracket the empty set end bracket ]" the empty set}% % \index{the empty set "[ bracket the empty set end bracket ]"}% % \tex{"[ math tex define the empty set as " \emptyset " end define end math ]"}% % "[ bracket the empty set end bracket ]"% % \footnote{"[ math pyk define the empty set as "the empty set" end define end math ]"} % is defined thus: \display{"[ math value define the empty set as true end define end math ]"} The operation % \index{\alpha x term plus y end plus @\back "[ bracket var x term plus var y end plus end bracket ]" x term plus y end plus}% % \index{x term plus var y end plus "[ bracket var x term plus var y end plus end bracket ]"}% % \tex{"[ math tex define var x term plus var y end plus as "#1. \cup \{ #2. \}" end define end math ]"}% % "[ bracket var x term plus var y end plus end bracket ]"% % \footnote{"[ math pyk define var x term plus var y end plus as "* term plus * end plus" end define end math ]"} % adds the term "[ bracket var y end bracket ]" to the term set "[ bracket var x end bracket ]": \display{"[ math value define var x term plus var y end plus as tagged if var y term in var x then var x else var y pair var x end if end define end math ]"}% % \test{"[ math test the empty set term plus quote var x end quote end plus term plus quote var y end quote end plus term plus quote var z end quote end plus term plus quote var y end quote end plus term list equal tuple quote var z end quote comma quote var y end quote comma quote var x end quote end tuple end test end math ]"} The operation % \index{\alpha x term minus y end minus @\back "[ bracket var x term minus var y end minus end bracket ]" x term minus y end minus}% % \index{x term minus var y end minus "[ bracket var x term minus var y end minus end bracket ]"}% % \tex{"[ math tex define var x term minus var y end minus as "#1. \backslash \{ #2. \}" end define end math ]"}% % "[ bracket var x term minus var y end minus end bracket ]"% % \footnote{"[ math pyk define var x term minus var y end minus as "* term minus * end minus" end define end math ]"} % removes the term "[ bracket var y end bracket ]" from the term set "[ bracket var x end bracket ]": \display{"[ math value define var x term minus var y end minus as tagged if var x is atomic then var y tagged guard the empty set else tagged if var y term equal var x head then var x tail else var x head pair var x tail term minus var y end minus end if end if end define end math ]"}% % \test{"[ math test tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple term minus quote var y end quote end minus term list equal tuple quote var x end quote comma quote var z end quote end tuple end test end math ]"}% % \test{"[ math test tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple term minus quote var u end quote end minus term list equal tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"} The operation % \index{\alpha x term union y @\back "[ bracket var x term union var y end bracket ]" x term union y}% % \index{x term union y "[ bracket var x term union var y end bracket ]"}% % \tex{"[ math tex define var x term union var y as "#1. \cup #2." end define end math ]"}% % "[ bracket var x term union var y end bracket ]"% % \footnote{"[ math pyk define var x term union var y as "* term union *" end define end math ]"} % computes the union of the term sets "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]": \display{"[ math value define var x term union var y as tagged if var x is atomic then var y else var x tail term union var y term plus var x head end plus end if end define end math ]"}% % \test{"[ math test tuple quote var a end quote comma quote var y end quote comma quote var b end quote end tuple term union tuple quote var x end quote comma quote var y end quote comma quote var z end quote end tuple term list equal tuple quote var a end quote comma quote var b end quote comma quote var x end quote comma quote var y end quote comma quote var z end quote end tuple end test end math ]"} \subsubsection{Sequents}\label{section:Sequents} A Logiweb \indexintro{sequent} is a triple "[ bracket tuple var p comma var s comma var c end tuple end bracket ]" where "[ bracket var p end bracket ]" and "[ bracket var s end bracket ]" are term sets and "[ bracket var c end bracket ]" is a term. In a sequent "[ bracket tuple var p comma var s comma var c end tuple end bracket ]" we shall refer to "[ bracket var p end bracket ]", "[ bracket var c end bracket ]", and "[ bracket var c end bracket ]" as \indexintro{premise}, \indexintro{side condition}, and \indexintro{conclusion}, respectively, of the sequent. A sequent "[ bracket tuple var p comma var s comma var c end tuple end bracket ]" represents the statement that if all members of "[ bracket var p end bracket ]" are provable and if all members of "[ bracket var s end bracket ]" evaluate to "[ bracket true end bracket ]" then "[ bracket var c end bracket ]" is provable. Sequents allow to express the same thing in many ways. As an example, the following five sequents all state that if "[ bracket meta a end bracket ]" and "[ bracket meta b end bracket ]" are provable then "[ bracket meta a rule plus meta b end bracket ]" is provable: \display{"[ math array left is tuple the empty set comma the empty set comma meta a infer meta b infer meta a rule plus meta b end tuple row tuple the empty set comma the empty set comma meta b infer meta a infer meta a rule plus meta b end tuple row tuple the empty set term plus meta a end plus comma the empty set comma meta b infer meta a rule plus meta b end tuple row tuple the empty set term plus meta b end plus comma the empty set comma meta a infer meta a rule plus meta b end tuple row tuple the empty set term plus meta a end plus term plus meta b end plus comma the empty set comma meta a rule plus meta b end tuple end array end math ]"} The sequent "[ bracket tuple the empty set term plus meta b end plus term plus meta a end plus comma the empty set comma meta a rule plus meta b end tuple end bracket ]" is considered equal to the last of the sequents above since the order of elements in term sets is considered unimportant. From an operational point of view one may think of a sequent "[ bracket tuple var p comma var s comma var c end tuple end bracket ]" as a tool makers workshop where "[ bracket var c end bracket ]" is the anvil where lemmas are forged. "[ bracket var p end bracket ]" may be seen as a storage room for premises, in which case part of the tool makers work is to bring premises back and forth between anvil and storage room. Alternatively, "[ bracket var p end bracket ]" may be seen as a backlog of proof obligations. "[ bracket var s end bracket ]" is like "[ bracket var p end bracket ]" except that it stores side conditions. As we shall see, the storage room "[ bracket var p end bracket ]" will be used for several different things. As an example, when proving "[ bracket meta a math equal meta b infer meta b math equal meta a end bracket ]" in "[ bracket example theory primed end bracket ]", "[ bracket var p end bracket ]" will be used to contain the axiomatic theory "[ bracket example theory primed end bracket ]" itself, it will be used to contain the premise "[ bracket meta a math equal meta b end bracket ]", and it will be used to contain conclusions of individual lines of the proof. \subsubsection{Sequent equality} The sequent equality operation % \index{\alpha x sequent equal y @\back "[ bracket var x sequent equal var y end bracket ]" x sequent equal y}% % \index{x sequent equal y "[ bracket var x sequent equal var y end bracket ]"}% % \index{s: "[ bracket var x sequent equal var y end bracket ]"}% % \tex{"[ math tex define var x sequent equal var y as "#1. \stackrel{s}{=} #2." end define end math ]"}% % "[ bracket var x sequent equal var y end bracket ]"% % \footnote{"[ math pyk define var x sequent equal var y as "* sequent equal *" end define end math ]"} % is defined thus: \display{"[ math value define var x sequent equal var y as tagged if not var x second term equal var y second then false else tagged if var x zeroth term set equal var y zeroth then var x first term set equal var y first else false end if end if end define end math ]"}% % \test{"[ math test tuple tuple quote one end quote comma quote two end quote end tuple comma tuple quote three end quote comma quote four end quote end tuple comma quote five end quote end tuple sequent equal tuple tuple quote two end quote comma quote one end quote end tuple comma tuple quote four end quote comma quote three end quote end tuple comma quote five end quote end tuple end test end math ]"}% % \test{"[ math false test tuple tuple quote six end quote comma quote two end quote end tuple comma tuple quote three end quote comma quote four end quote end tuple comma quote five end quote end tuple sequent equal tuple tuple quote two end quote comma quote one end quote end tuple comma tuple quote four end quote comma quote three end quote end tuple comma quote five end quote end tuple end test end math ]"}% % \test{"[ math false test tuple tuple quote one end quote comma quote six end quote end tuple comma tuple quote three end quote comma quote four end quote end tuple comma quote five end quote end tuple sequent equal tuple tuple quote two end quote comma quote one end quote end tuple comma tuple quote four end quote comma quote three end quote end tuple comma quote five end quote end tuple end test end math ]"}% % \test{"[ math false test tuple tuple quote one end quote comma quote two end quote end tuple comma tuple quote six end quote comma quote four end quote end tuple comma quote five end quote end tuple sequent equal tuple tuple quote two end quote comma quote one end quote end tuple comma tuple quote four end quote comma quote three end quote end tuple comma quote five end quote end tuple end test end math ]"}% % \test{"[ math false test tuple tuple quote one end quote comma quote two end quote end tuple comma tuple quote three end quote comma quote six end quote end tuple comma quote five end quote end tuple sequent equal tuple tuple quote two end quote comma quote one end quote end tuple comma tuple quote four end quote comma quote three end quote end tuple comma quote five end quote end tuple end test end math ]"}% % \test{"[ math false test tuple tuple quote one end quote comma quote two end quote end tuple comma tuple quote three end quote comma quote four end quote end tuple comma quote six end quote end tuple sequent equal tuple tuple quote two end quote comma quote one end quote end tuple comma tuple quote four end quote comma quote three end quote end tuple comma quote five end quote end tuple end test end math ]"}% \subsubsection{Sequent operations} Logiweb sequent calculus comprises twelve \index{sequent operation}\index{operation, sequent}\intro{sequent operations}. We shall refer to a term that is built up from these twelve operations as a \index{proof, sequent}\indexintro{sequent proof}. We shall say that a term "[ bracket var c end bracket ]" is a \index{lemma, sequent}\intro{sequent lemma} if there exists a sequent proof which evaluates to "[ bracket tuple the empty set comma the empty set comma var c end tuple end bracket ]". In the tool makers analogy, the sequent "[ bracket tuple the empty set comma the empty set comma var c end tuple end bracket ]" represents the situation where "[ bracket var c end bracket ]" has been forged and the backlogs of remaining work are empty. We shall refer to a sequent operation as sequent-nulary, sequent-unary, or sequent-binary if it depends on zero, one, or two sequents, respectively. As an example, a binary operation that depends on one sequent and one non-sequent is sequent-unary. Logiweb sequent calculus comprises one sequent-nulary, ten sequent-unary, and one sequent-binary operation. The sole sequent-binary operation of Logiweb sequent calculus is the ``cut'' operation. In the tool makers analogy, each sequent-unary operation corresponds to a work process such as moving a premise from anvil to storage room. The sequent-nulary operation is the starting point of any work process, and the sequent-binary operation allows to use the outcome of one work process as a tool in another process. \subsubsection{Proof initiation} The sequent-nulary operation % \index{I: "[ bracket var x init end bracket ]" x init}% % \index{x init "[ bracket var x init end bracket ]"}% % \tex{"[ math tex define var x init as "#1. {} ^ { I }" end define end math ]"}% % "[ bracket var x init end bracket ]"% % \footnote{"[ math pyk define var x init as "* init" end define end math ]"} % performs the following operation: \display{"[ bracket var a init end bracket ]" evaluates to "[ bracket tuple the empty set comma the empty set comma var a infer var a end tuple end bracket ]"} In section \ref{section:TheProofEvaluator} we introduce a ``proof evaluator'' which, given a sequent proof, computes the value of the proof. It is the proof evaluator that is going to evaluate "[ bracket var a init end bracket ]" as shown above. As an example of use, "[ bracket parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end bracket ]" is a sequent lemma because "[ bracket parenthesis meta a rule plus meta b end parenthesis init end bracket ]" evaluates to "[ bracket tuple the empty set comma the empty set comma parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end tuple end bracket ]". In other words, "[ math raw test parenthesis meta a rule plus meta b end parenthesis init proves parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end test end math ]", where the ``proves'' predicate will be defined in Section \ref{section:LemmaVerification}. The statement that \display{"[ bracket parenthesis meta a rule plus meta b end parenthesis init end bracket ]" proves "[ bracket parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end bracket ]"} is just an informal statement that the given sequent proof proves the given term. In contrast, the statement that \display{"[ math raw test parenthesis meta a rule plus meta b end parenthesis init proves parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end test end math ]"} is a formal one that uses the formally defined "[ bracket var x proves var y end bracket ]" relation defined in Section \ref{section:LemmaVerification}. The latter statement makes Logiweb verify the claim formally. The statement that \display{"[ math test parenthesis meta a rule plus meta b end parenthesis init proves parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end test end math ]"} also forces Logiweb to verify the claim formally, but if the claim turned out to fail, the user would merely get the information that that particular claim failed. If "[ bracket var x end bracket ]" does not prove "[ bracket var y end bracket ]" then "[ bracket var x proves var y end bracket ]" returns a term which, when typeset, explains why not. For that reason, \display{"[ math raw test parenthesis meta a rule plus meta b end parenthesis init proves parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end test end math ]"} has the benefit that if the claim fails then the generated error message will be more precise. \subsubsection{Inference introduction} We overload "[ bracket var x infer var y end bracket ]" to denote both an operation on statements and a sequent operation. Ambiguity cannot occur since the proof evaluator will decide what "[ bracket var x infer var y end bracket ]" means on a case by case basis. "[ bracket var a infer var q end bracket ]" is sequent-unary; it takes a premise "[ bracket var a end bracket ]" and a sequent "[ bracket var q end bracket ]" and moves the premise from storage room to anvil: \display{"[ bracket var a infer tuple var p comma var s comma var c end tuple end bracket ]" evaluates to "[ bracket tuple var p term minus var a end minus comma var s comma var a infer var c end tuple end bracket ]"} Note that a premise can be moved from storage room to anvil even if there the premise was not present in the storage room to begin with. A premise may be seen as work to be done, and moving a premise that did not exist before corresponds to creation of work to be done from nothing. As an example of use, "[ math raw test meta a infer meta b init proves meta a infer meta b infer meta b end test end math ]". \subsubsection{Endorsement and quantifier introduction} We also overload "[ bracket var x endorse var y end bracket ]" and "[ bracket all var x indeed var y end bracket ]": \display{"[ bracket var a endorse tuple var p comma var s comma var c end tuple end bracket ]" evaluates to "[ bracket tuple var p comma var s term minus var a end minus comma var a endorse var c end tuple end bracket ]"} \display{"[ bracket all var x indeed tuple var p comma var s comma var c end tuple end bracket ]" evaluates to "[ bracket tuple var p comma var s comma all var x indeed var c end tuple end bracket ]" if "[ bracket var x end bracket ]" is a metavariable and is not free in "[ bracket var p end bracket ]" and "[ bracket var s end bracket ]"} As an example of use, "[ math raw test all meta a indeed all meta b indeed meta a infer meta b init proves all meta a indeed all meta b indeed meta a infer meta b infer meta b end test end math ]". \subsubsection{Inference and endorsement elimination} The operation % \index{\alpha x modus @\back "[ bracket var x modus end bracket ]" x modus}% % \index{x modus "[ bracket var x modus end bracket ]"}% % \tex{"[ math tex define var x modus as "#1. {} ^ { \rhd }" end define end math ]"}% % "[ bracket var x modus end bracket ]"% % \footnote{"[ math pyk define var x modus as "* modus" end define end math ]"} % eliminates an inference or endorsement: \display{"[ bracket tuple var p comma var s comma var a infer var c end tuple modus end bracket ]" evaluates to "[ bracket tuple var p term plus var a end plus comma var s comma var c end tuple end bracket ]"} \display{"[ bracket tuple var p comma var s comma var a endorse var c end tuple modus end bracket ]" evaluates to "[ bracket tuple var p comma var s term plus var a end plus comma var c end tuple end bracket ]"} As an example of use, "[ math raw test meta a infer meta b infer meta a init modus proves meta a infer meta b infer meta a end test end math ]". We shall refer to "[ bracket var x modus end bracket ]" as the \indexintro{modus} operation. As we shall see, the inference rule of \index{ponens, modus}\indexintro{modus ponens} will be implemented by the modus operation together with the cut operation described later: the modus operation is used for preparation whereas a cut is used for the actual execution. Inferences can be eliminated by modus ponens whereas endorsements can be eliminated by either \index{probans, modus}\indexintro{modus probans} or \indexintro{verification}. Modus ponens says that if "[ bracket var x infer var y end bracket ]" and if we can prove "[ bracket var x end bracket ]" then we positivily have "[ bracket var y end bracket ]". Verification says that if "[ bracket var x endorse var y end bracket ]" and if "[ bracket var x end bracket ]" evaluates to "[ bracket true end bracket ]" then "[ bracket var y end bracket ]" is verified. Modus probans says that if "[ bracket var x endorse var y end bracket ]" and if we happen to know or assume that "[ bracket var x end bracket ]" evaluates to "[ bracket true end bracket ]" then this knowledge approves "[ bracket var y end bracket ]". The modus operation implements half of modus ponens or modus probans. Verification is treated in Section \ref{section:Verification}. \subsubsection{Quantifier elimination} The operation % \index{\alpha x at y @\back "[ bracket var x at var y end bracket ]" x at y}% % \index{x at y "[ bracket var x at var y end bracket ]"}% % % \tex below uses \char64 instead of @ to avoid problems with makeindex % \tex{"[ math tex define var x at var y as "#1. \mathop {\char64} #2." end define end math ]"}% % "[ bracket var x at var y end bracket ]"% % \footnote{"[ math pyk define var x at var y as "* at *" end define end math ]"} % eliminates a quantifer: \display{"[ bracket tuple var p comma var s comma all var x indeed var c end tuple at var a end bracket ]" evaluates to "[ bracket tuple var p comma var s comma substitute var c set var x to var a end substitute end tuple end bracket ]" if "[ bracket var x end bracket ]" is a metavariable and "[ bracket var a end bracket ]" is free for "[ bracket var x end bracket ]" in "[ bracket var c end bracket ]"} As an example of use, "[ math raw test parenthesis all meta a indeed meta a math equal meta a end parenthesis infer parenthesis all meta a indeed meta a math equal meta a end parenthesis init modus at zero proves parenthesis all meta a indeed meta a math equal meta a end parenthesis infer zero math equal zero end test end math ]". \subsubsection{Verification}\label{section:Verification} The operation % \index{V: "[ bracket var x verify end bracket ]" x verify}% % \index{x verify "[ bracket var x verify end bracket ]"}% % \tex{"[ math tex define var x verify as "#1. {} ^ { V } " end define end math ]"}% % "[ bracket var x verify end bracket ]"% % \footnote{"[ math pyk define var x verify as "* verify" end define end math ]"}% % eliminates a side condition by evaluating it and seeing that it is true: \display{"[ bracket tuple var p comma var s comma var a endorse var b end tuple verify end bracket ]" evaluates to "[ bracket tuple var p comma var s comma var b end tuple end bracket ]" if \begin{itemize} \item "[ bracket var a end bracket ]" contains no meta variables, and \item "[ bracket normalizing untag eval var a stack true cache var c end eval tagged apply var c end untag end bracket ]" evaluates to "[ bracket true end bracket ]" where "[ bracket var c end bracket ]" is the cache of the page on which the verification operation occurs \end{itemize}} As an example of use, "[ math raw test parenthesis all meta a indeed computably true meta a end true endorse meta a end parenthesis infer parenthesis parenthesis all meta a indeed computably true meta a end true endorse meta a end parenthesis init modus at parenthesis false double two tagged equal five end parenthesis end parenthesis verify proves parenthesis all meta a indeed computably true meta a end true endorse meta a end parenthesis infer false double two tagged equal five end test end math ]" where % \index{T @\back "[ bracket computably true var x end true end bracket ]" computably true x end true}% % \index{computably true x end true "[ bracket computably true var x end true end bracket ]"}% % \tex{"[ math tex define computably true var x end true as " {\cal T}( #1. )" end define end math ]"}% % \display{"[ math macro define computably true var x end true as lambda var c dot normalizing untag eval quote var x end quote stack true cache var c end eval end untag end define end math ]"% % \footnote{"[ math pyk define computably true var x end true as "computably true * end true" end define end math ]"}} % \test{"[ math test map untag eval quote false double two tagged equal five end quote stack true cache self end eval end untag end test end math ]"}% % \test{"[ math test normalizing untag eval quote false double two tagged equal five end quote stack true cache self end eval end untag end test end math ]"}% % \test{"[ math test normalizing untag eval quote computably true false double two tagged equal five end true end quote stack true cache self end eval tagged apply self end untag end test end math ]"} In the example above, "[ bracket all meta a indeed computably true meta a end true endorse meta a end bracket ]" is an axiom scheme that says that any term that evaluates to "[ bracket true end bracket ]" is provable. \subsubsection{Currying} The operations % \index{\alpha x curry plus @\back "[ bracket var x curry plus end bracket ]" x curry plus}% % \index{x curry plus "[ bracket var x curry plus end bracket ]"}% % \tex{"[ math tex define var x curry plus as "#1. {} ^ { + } " end define end math ]"}% % "[ bracket var x curry plus end bracket ]"% % \footnote{"[ math pyk define var x curry plus as "* curry plus" end define end math ]"} % and % \index{\alpha x curry minus @\back "[ bracket var x curry minus end bracket ]" x curry minus}% % \index{x curry minus "[ bracket var x curry minus end bracket ]"}% % \tex{"[ math tex define var x curry minus as "#1. {} ^ { - } " end define end math ]"}% % "[ bracket var x curry minus end bracket ]"% % \footnote{"[ math pyk define var x curry minus as "* curry minus" end define end math ]"} % add and remove a "[ bracket unicode end of text rule plus unicode end of text end bracket ]", respectively: \display{"[ bracket tuple var p comma var s comma var a infer var b infer var c end tuple curry plus end bracket ]" evaluates to "[ bracket tuple var p comma var s comma parenthesis var a rule plus var b end parenthesis infer var c end tuple end bracket ]"} \display{"[ bracket tuple var p comma var s comma parenthesis var a rule plus var b end parenthesis infer var c end tuple curry minus end bracket ]" evaluates to "[ bracket tuple var p comma var s comma var a infer var b infer var c end tuple end bracket ]"} "[ bracket var x curry minus end bracket ]" and "[ bracket var x curry plus end bracket ]" are known as \indexintro{currying} and \indexintro{decurrying}, respectively. As an example of use, "[ math raw test parenthesis meta a infer meta b init end parenthesis curry plus proves parenthesis meta a rule plus meta b end parenthesis infer meta b end test end math ]". As another example, "[ math raw test parenthesis meta a rule plus meta b end parenthesis init curry minus proves meta a infer meta b infer parenthesis meta a rule plus meta b end parenthesis end test end math ]". \subsubsection{Referencing and dereferencing} The operations % \index{i.e.: "[ bracket var x id est var y end bracket ]" x id est y}% % \index{x id est y "[ bracket var x id est var y end bracket ]"}% % \tex{"[ math tex define var x id est var y as "#1. \mathrel {i.e.} #2." end define end math ]"}% % "[ bracket var x id est var y end bracket ]"% % \footnote{"[ math pyk define var x id est var y as "* id est *" end define end math ]"} % and % \index{\alpha x dereference @\back "[ bracket var x dereference end bracket ]" x dereference}% % \index{x dereference "[ bracket var x dereference end bracket ]"}% % \tex{"[ math tex define var x dereference as "#1. {} ^ { \ast } " end define end math ]"}% % "[ bracket var x dereference end bracket ]"% % \footnote{"[ math pyk define var x dereference as "* dereference" end define end math ]"} % change from term to name and vice versa, respectively: \display{"[ bracket tuple var p comma var s comma var c end tuple id est var n end bracket ]" evaluates to "[ bracket tuple var p comma var s comma var n end tuple end bracket ]" if "[ bracket var c end bracket ]" is the statement aspect of "[ bracket var n end bracket ]"} \display{"[ bracket tuple var p comma var s comma var n end tuple dereference end bracket ]" evaluates to "[ bracket tuple var p comma var s comma var c end tuple end bracket ]" where "[ bracket var c end bracket ]" is the statement aspect of "[ bracket var n end bracket ]"} We shall refer to "[ bracket var x id est var y end bracket ]" and "[ bracket var x dereference end bracket ]" as \indexintro{referencing} and \indexintro{dereferencing}, respectively. The asterisk in "[ bracket var x dereference end bracket ]" is inspired by the C programming language. As an example of use, "[ math raw test example theory primed infer example theory primed init modus dereference proves example theory primed infer parenthesis example axiom rule plus example scheme rule plus example rule rule plus contraexample end parenthesis end test end math ]". As another example, "[ math raw test parenthesis example axiom rule plus example scheme rule plus example rule rule plus contraexample end parenthesis infer parenthesis example axiom rule plus example scheme rule plus example rule rule plus contraexample end parenthesis init modus id est example theory primed proves parenthesis example axiom rule plus example scheme rule plus example rule rule plus contraexample end parenthesis infer example theory primed end test end math ]". \subsubsection{The cut operation} The sequent-binary operation % \index{\alpha x cut y @\back "[ bracket var x cut var y end bracket ]" x cut y}% % \index{x cut y "[ bracket var x cut var y end bracket ]"}% % \tex{"[ math tex define var x cut var y as "#1. ; #2." end define end math ]"}% % "[ bracket var x cut var y end bracket ]"% % \footnote{"[ math pyk define var x cut var y as "* cut *" end define end math ]"} % is the well-known \indexintro{cut} operation. It satisfies: \display{"[ bracket tuple var p sub one end sub comma var s sub one end sub comma var c sub one end sub end tuple cut tuple var p sub two end sub comma var s sub two end sub comma var c sub two end sub end tuple end bracket ]" evaluates to "[ bracket tuple var p sub one end sub term union parenthesis var p sub two end sub term minus var c sub one end sub end minus end parenthesis comma var s sub one end sub term union var s sub two end sub comma var c sub two end sub end tuple end bracket ]"} As an example of use, let % \index{Remainder @\back "[ bracket example remainder end bracket ]"}% % \tex{"[ math tex define example remainder as " Remainder" end define end math ]"}% % "[ bracket example remainder end bracket ]"% % \footnote{"[ math pyk define example remainder as "example remainder" end define end math ]"} % denote all of "[ bracket example theory primed end bracket ]" except "[ bracket example axiom end bracket ]": \display{"[ math macro define example remainder as example scheme rule plus example rule rule plus contraexample end define end math ]"} We have that \display{"[ bracket example theory primed init modus dereference end bracket ]"} evaluates to \display{"[ bracket tuple example theory primed comma the empty set comma example axiom rule plus example remainder end tuple end bracket ]"} and that \display{"[ bracket parenthesis example axiom infer example remainder infer example axiom init end parenthesis curry plus modus end bracket ]"} evaluates to \display{"[ bracket tuple example axiom rule plus example remainder comma the empty set comma example axiom end tuple end bracket ]"} so \display{"[ math raw test example theory primed infer parenthesis example theory primed init modus dereference cut parenthesis example axiom infer example remainder infer example axiom init modus end parenthesis curry plus modus end parenthesis proves example theory primed infer example axiom end test end math ]".} The lemma says that "[ bracket example axiom end bracket ]" is provable in "[ bracket example theory primed end bracket ]". In general, as one should expect, all rules of a theory are provable in the theory. \subsubsection{Rule lemmas} For a rule "[ bracket meta r end bracket ]" of a theory "[ bracket meta t end bracket ]" we shall refer to "[ bracket meta t infer meta r end bracket ]" as the \index{lemma, rule}\indexintro{rule lemma} of "[ bracket meta r end bracket ]". In proofs, one constantly needs rule lemmas. Hence, as soon as one has defined a theory it is convenient to prove the rule lemma of each rule. Once that is done one can forget about the rules and use the rule lemmas instead. For that reason, one should not waste good names on rules; one should reserve good names for rule lemmas. \subsection{Implementation of the twelve sequent operations} Sequent evaluators for the twelve individual sequent operations of Logiweb sequent calculus are defined in the following sections. See Section \ref{section:SequentCalculus} for explanations of what each operation does. \subsubsection{Evaluation of the init operation} \index{S: "[ bracket seqeval init var x term var y end eval end bracket ]" seqeval init x term y end eval}% % \index{seqeval init x term y end eval "[ bracket seqeval init var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval init var x term var y end eval as " {\cal S}^{I}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval init var c term var t end eval as var c tagged guard tuple the empty set comma the empty set comma var t color var t first infer var t first end color end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval init var x term var y end eval as "seqeval init * term * end eval" end define end math ]"}} \subsubsection{Evaluation of the modus operation} \index{S: "[ bracket seqeval modus var x term var y end eval end bracket ]" seqeval modus x term y end eval}% % \index{seqeval modus x term y end eval "[ bracket seqeval modus var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval modus var x term var y end eval as " {\cal S}^{\rhd}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval modus var c term var t end eval as seqeval modus one var c term var t sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval modus var x term var y end eval as "seqeval modus * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval modus one var x term var y sequent var z end eval end bracket ]" seqeval modus one x term y sequent z end eval}% % \index{seqeval modus one x term y sequent z end eval "[ bracket seqeval modus one var x term var y sequent var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval modus one var x term var y sequent var z end eval as " {\cal S}_{1}^{\rhd}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval modus one var c term var t sequent var q end eval as var c tagged guard var t tagged guard newline open if var q is error then var q else newline open if var q second term root equal quote x infer x end quote then tuple var q zeroth term plus var q second first end plus comma var q first comma var q second second end tuple else newline open if var q second term root equal quote x endorse x end quote then tuple var q zeroth comma var q first term plus var q second first end plus comma var q second second end tuple else newline error "The modus operation requires the conclusion of its argument to be an inference or an endorsement" term var t end error end define end math ]"% % \footnote{"[ math pyk define seqeval modus one var x term var y sequent var z end eval as "seqeval modus one * term * sequent * end eval" end define end math ]"}}% % \test{"[ math test sequent eval self term quote meta a init modus end quote end eval sequent equal tuple tuple quote meta a end quote end tuple comma the empty set comma quote meta a end quote end tuple end test end math ]"} \subsubsection{Evaluation of the verify operation} \index{S: "[ bracket seqeval verify var x term var y end eval end bracket ]" seqeval verify x term y end eval}% % \index{seqeval verify x term y end eval "[ bracket seqeval verify var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval verify var x term var y end eval as " {\cal S}^{E}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval verify var c term var t end eval as seqeval verify one var c term var t sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval verify var x term var y end eval as "seqeval verify * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval verify one var x term var y sequent var z end eval end bracket ]" seqeval verify one x term y sequent z end eval}% % \index{seqeval verify one x term y sequent z end eval "[ bracket seqeval verify one var x term var y sequent var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval verify one var x term var y sequent var z end eval as " {\cal S}_{1}^{E}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval verify one var c term var t sequent var q end eval as var c tagged guard var t tagged guard newline open if var q is error then var q else newline open if not var q second term root equal quote x endorse x end quote then error "The verify operation requires the conclusion of its argument to be an endorsement:" term var t end error else newline open if not var q second first is metaclosed then error "The verify operation requires the side condition to contain no metavariables. Term;condition:" term var t cut var q second first end error else newline open if normalizing untag eval var q second first stack true cache var c end eval tagged apply var c end untag then tuple var q zeroth comma var q first comma var q second second end tuple else newline error "False side condition:" term var t end error end define end math ]"% % \footnote{"[ math pyk define seqeval verify one var x term var y sequent var z end eval as "seqeval verify one * term * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of the decurrying operation} \index{S: "[ bracket sequent eval plus var x term var y end eval end bracket ]" sequent eval plus x term y end eval}% % \index{sequent eval plus x term y end eval "[ bracket sequent eval plus var x term var y end eval end bracket ]"}% % \tex{"[ math tex define sequent eval plus var x term var y end eval as " {\cal S}^{+}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define sequent eval plus var c term var t end eval as seqeval plus one var c term var t sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define sequent eval plus var x term var y end eval as "sequent eval plus * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval plus one var x term var y sequent var z end eval end bracket ]" seqeval plus one x term y sequent z end eval}% % \index{seqeval plus one x term y sequent z end eval "[ bracket seqeval plus one var x term var y sequent var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval plus one var x term var y sequent var z end eval as " {\cal S}_{1}^{+}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval plus one var c term var t sequent var q end eval as var c tagged guard var t tagged guard newline open if var q is error then var q else newline open if var q second term root equal quote x infer x end quote and var q second second term root equal quote x infer x end quote then newline tuple var q zeroth comma var q first comma var t color parenthesis var q second first rule plus var q second second first end parenthesis infer var q second second second end color end tuple else newline error "Term;conclusion not fit for decurrying:" term var t cut var q second end error end define end math ]"% % \footnote{"[ math pyk define seqeval plus one var x term var y sequent var z end eval as "seqeval plus one * term * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of the currying operation} \index{S: "[ bracket seqeval minus var x term var y end eval end bracket ]" seqeval minus x term y end eval}% % \index{seqeval minus x term y end eval "[ bracket seqeval minus var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval minus var x term var y end eval as " {\cal S}^{-}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval minus var c term var t end eval as seqeval minus one var c term var t sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval minus var x term var y end eval as "seqeval minus * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval minus one var x term var y sequent var z end eval end bracket ]" seqeval minus one x term y sequent z end eval}% % \index{seqeval minus one x term y sequent z end eval "[ bracket seqeval minus one var x term var y sequent var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval minus one var x term var y sequent var z end eval as " {\cal S}_{1}^{-}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval minus one var c term var t sequent var q end eval as var c tagged guard var t tagged guard newline open if var q is error then var q else newline open if var q second term root equal quote x infer x end quote and var q second first term root equal quote x rule plus x end quote then newline tuple var q zeroth comma var q first comma var t color var q second first first infer var q second first second infer var q second second end color end tuple else newline error "Term;conclusion not fit for decurrying:" term var t cut var q second end error end define end math ]"% % \footnote{"[ math pyk define seqeval minus one var x term var y sequent var z end eval as "seqeval minus one * term * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of the dereferencing operation} \index{S: "[ bracket seqeval deref var x term var y end eval end bracket ]" seqeval deref x term y end eval}% % \index{seqeval deref x term y end eval "[ bracket seqeval deref var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval deref var x term var y end eval as " {\cal S}^{\ast}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval deref var c term var t end eval as seqeval deref one var c term var t sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval deref var x term var y end eval as "seqeval deref * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval deref one var x term var y sequent var z end eval end bracket ]" seqeval deref one x term y sequent z end eval}% % \index{seqeval deref one x term y sequent z end eval "[ bracket seqeval deref one var x term var y sequent var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval deref one var x term var y sequent var z end eval as " {\cal S}_{1}^{\ast}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval deref one var c term var t sequent var q end eval as var c tagged guard var t tagged guard newline open if var q is error then var q else newline seqeval deref two var c term var t sequent var q def aspect the statement aspect term var q second cache var c end aspect end eval end define end math ]"% % \footnote{"[ math pyk define seqeval deref one var x term var y sequent var z end eval as "seqeval deref one * term * sequent * end eval" end define end math ]"}} \index{S: "[ bracket seqeval deref two var x term var y sequent var z def var u end eval end bracket ]" seqeval deref two x term y sequent z def u end eval}% % \index{seqeval deref two x term y sequent z def u end eval "[ bracket seqeval deref two var x term var y sequent var z def var u end eval end bracket ]"}% % \tex{"[ math tex define seqeval deref two var c term var t sequent var q def var d end eval as " {\cal S}_{2}^{\ast}(#1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define seqeval deref two var c term var t sequent var q def var d end eval as var c tagged guard var t tagged guard var q tagged guard newline open if var d then error "Dereferencing construct that has no statement def:" term var t end error else newline tuple var q zeroth comma var q first comma var d third end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval deref two var c term var t sequent var q def var d end eval as "seqeval deref two * term * sequent * def * end eval" end define end math ]"}} \subsubsection{Evaluation of quantifier elimination} \index{S: "[ bracket seqeval at var x term var y end eval end bracket ]" seqeval at x term y end eval}% % \index{seqeval at x term y end eval "[ bracket seqeval at var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval at var x term var y end eval as " {\cal S}^{\char64}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval at var c term var t end eval as seqeval at one var c term var t sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval at var x term var y end eval as "seqeval at * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval at one var x term var y sequent var z end eval end bracket ]" seqeval at one x term y sequent x end eval}% % \index{seqeval at one x term y sequent z end eval "[ bracket seqeval at one var x term var y sequent var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval at one var c term var t sequent var q end eval as " {\cal S}_{1}^{\char64}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval at one var c term var t sequent var q end eval as var c tagged guard var t tagged guard newline open if var q is error then var q else newline open if not var q second term root equal quote all x indeed x end quote then error "Quantifier elimination requires the conclusion of its argument to be a quantifier:" term var t end error else newline open if not var t second free for var q second first in var q second second then error "Quantifier elimination leads to variable clash:" term var t end error else newline tuple var q zeroth comma var q first comma sub var q second second set var q second first to var t second end sub end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval at one var c term var t sequent var q end eval as "seqeval at one * term * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of inference introduction} \index{S: "[ bracket seqeval infer var x term var y end eval end bracket ]" seqeval infer x term y end eval}% % \index{seqeval infer x term y end eval "[ bracket seqeval infer var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval infer var x term var y end eval as " {\cal S}^{\vdash}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval infer var c term var t end eval as seqeval infer one var c term var t premise var t first sequent sequent eval var c term var t second end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval infer var x term var y end eval as "seqeval infer * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval infer one var x term var y premise var z sequent var u end eval end bracket ]" seqeval infer one x term y premise z sequent u end eval}% % \index{seqeval infer one x term y premise z sequent u end eval "[ bracket seqeval infer one var x term var y premise var z sequent var u end eval end bracket ]"}% % \tex{"[ math tex define seqeval infer one var x term var y premise var z sequent var u end eval as " {\cal S}_{1}^{\vdash}(#1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define seqeval infer one var c term var t premise var p sequent var q end eval as var c tagged guard var t tagged guard var p tagged guard newline open if var q is error then var q else newline tuple var q zeroth term minus var p end minus comma var q first comma var t color var p infer var q second end color end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval infer one var x term var y premise var z sequent var u end eval as "seqeval infer one * term * premise * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of endorsement introduction} \index{S: "[ bracket seqeval endorse var x term var y end eval end bracket ]" seqeval endorse x term y end eval}% % \index{seqeval endorse x term y end eval "[ bracket seqeval endorse var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval endorse var x term var y end eval as " {\cal S}^{\makebox [0mm][l]{\scriptsize $\vdash $}\,{\vdash }}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval endorse var c term var t end eval as seqeval endorse one var c term var t side var t first sequent sequent eval var c term var t second end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval endorse var x term var y end eval as "seqeval endorse * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval endorse one var x term var y side var z sequent var u end eval end bracket ]" seqeval endorse one x term y side z sequent u end eval}% % \index{seqeval endorse one x term y side z sequent u end eval "[ bracket seqeval endorse one var x term var y side var z sequent var u end eval end bracket ]"}% % \tex{"[ math tex define seqeval endorse one var x term var y side var z sequent var u end eval as " {\cal S}_{1}^{\makebox [0mm][l]{\scriptsize $\vdash $}\,{\vdash }}(#1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define seqeval endorse one var c term var t side var p sequent var q end eval as var c tagged guard var t tagged guard var p tagged guard newline open if var q is error then var q else newline tuple var q zeroth comma var q first term minus var p end minus comma var t color var p endorse var q second end color end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval endorse one var x term var y side var z sequent var u end eval as "seqeval endorse one * term * side * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of the referencing operation} \index{S: "[ bracket seqeval est var x term var y end eval end bracket ]" seqeval est x term y end eval}% % \index{seqeval est x term y end eval "[ bracket seqeval est var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval est var x term var y end eval as " {\cal S}^{i.e.}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval est var c term var t end eval as seqeval est one var c term var t name var t second sequent sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval est var x term var y end eval as "seqeval est * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval est one var x term var y name var z sequent var u end eval end bracket ]" seqeval est one x term y name z sequent u end eval}% % \index{seqeval est one x term y name z sequent u end eval "[ bracket seqeval est one var x term var y name var z sequent var u end eval end bracket ]"}% % \tex{"[ math tex define seqeval est one var x term var y name var z sequent var u end eval as " {\cal S}_{1}^{i.e.}(#1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define seqeval est one var c term var t name var a sequent var q end eval as var c tagged guard var t tagged guard var a tagged guard newline tagged if var q is error then var q else seqeval est two var c term var t name var a sequent var q def aspect the statement aspect term var a cache var c end aspect end eval end if end define end math ]"% % \footnote{"[ math pyk define seqeval est one var x term var y name var z sequent var u end eval as "seqeval est one * term * name * sequent * end eval" end define end math ]"}} \index{S: "[ bracket seqeval est two var x term var y name var z sequent var u def var v end eval end bracket ]" seqeval est two x term y name z sequent u def v end eval}% % \index{seqeval est two x term y name z sequent u def v end eval "[ bracket seqeval est two var x term var y name var z sequent var u def var v end eval end bracket ]"}% % \tex{"[ math tex define seqeval est two var c term var t name var a sequent var q def var d end eval as " {\cal S}_{2}^{i.e.}(#1. , #2. , #3. , #4. , #5. )" end define end math ]"}% % \display{"[ math value define seqeval est two var c term var t name var a sequent var q def var d end eval as var c tagged guard var t tagged guard var a tagged guard var q tagged guard newline open if var d then error "Referencing construct that has no statement def:" term var t end error else newline open if not var d third term equal var q second then error "Reference;conclusion do not match:" term var a cut var q second end error else newline tuple var q zeroth comma var q first comma var a end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval est two var c term var t name var a sequent var q def var d end eval as "seqeval est two * term * name * sequent * def * end eval" end define end math ]"}} \subsubsection{Evaluation of quantifier introduction} \index{S: "[ bracket seqeval all var x term var y end eval end bracket ]" seqeval all x term y end eval}% % \index{seqeval all x term y end eval "[ bracket seqeval all var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval all var x term var y end eval as " {\cal S}^{\forall}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval all var c term var t end eval as seqeval all one var c term var t variable var t first sequent sequent eval var c term var t second end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval all var x term var y end eval as "seqeval all * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval all one var x term var y variable var z sequent var u end eval end bracket ]" seqeval all one x term y variable z sequent u end eval}% % \index{seqeval all one x term y variable z sequent u end eval "[ bracket seqeval all one var x term var y variable var z sequent var u end eval end bracket ]"}% % \tex{"[ math tex define seqeval all one var c term var t variable var v sequent var q end eval as " {\cal S}_{1}^{\forall}(#1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define seqeval all one var c term var t variable var v sequent var q end eval as var c tagged guard var t tagged guard var v tagged guard newline open if var q is error then var q else newline open if not var v is metavar then error "Metageneralization over non-metavariable:" term var t end error else newline open if var v free in var q zeroth then error "Metageneralization over metavariable that occurs free in some premise:" term var t end error else newline open if var v free in var q first then error "Metageneralization over metavariable that occurs free in some side condition:" term var t end error else newline tuple var q zeroth comma var q first comma var t color all var v indeed var q second end color end tuple end define end math ]"% % \footnote{"[ math pyk define seqeval all one var c term var t variable var v sequent var q end eval as "seqeval all one * term * variable * sequent * end eval" end define end math ]"}} \subsubsection{Evaluation of the cut operation} \index{S: "[ bracket seqeval cut var x term var y end eval end bracket ]" seqeval cut x term y end eval}% % \index{seqeval cut x term y end eval "[ bracket seqeval cut var x term var y end eval end bracket ]"}% % \tex{"[ math tex define seqeval cut var x term var y end eval as " {\cal S}^{;}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define seqeval cut var c term var t end eval as seqeval cut one var c term var t forerunner sequent eval var c term var t first end eval end eval end define end math ]"% % \footnote{"[ math pyk define seqeval cut var x term var y end eval as "seqeval cut * term * end eval" end define end math ]"}} \index{S: "[ bracket seqeval cut one var x term var y forerunner var z end eval end bracket ]" seqeval cut one x term y forerunner z end eval}% % \index{seqeval cut one x term y forerunner z end eval "[ bracket seqeval cut one var x term var y forerunner var z end eval end bracket ]"}% % \tex{"[ math tex define seqeval cut one var x term var y forerunner var z end eval as " {\cal S}_{1}^{;}(#1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define seqeval cut one var c term var t forerunner var p end eval as var c tagged guard var t tagged guard newline tagged if var p is error then var p else seqeval cut two var c term var t forerunner var p sequent sequent eval var c term var t second end eval end eval end if end define end math ]"% % \footnote{"[ math pyk define seqeval cut one var c term var t forerunner var p end eval as "seqeval cut one * term * forerunner * end eval" end define end math ]"}} \index{S: "[ bracket seqeval cut two var x term var y forerunner var z sequent var u end eval end bracket ]" seqeval cut two x term y sequent u end eval}% % \index{seqeval cut two x term y forerunner z sequent u end eval "[ bracket seqeval cut two var x term var y forerunner var z sequent var u end eval end bracket ]"}% % \tex{"[ math tex define seqeval cut two var c term var t forerunner var p sequent var q end eval as " {\cal S}_{2}^{;}(#1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define seqeval cut two var c term var t forerunner var p sequent var q end eval as var c tagged guard var t tagged guard var p tagged guard newline tagged if var q is error then var q else tuple var p zeroth term union parenthesis var q zeroth term minus var p second end minus end parenthesis comma var p first term union var q first comma var q second end tuple end if end define end math ]"% % \footnote{"[ math pyk define seqeval cut two var x term var y forerunner var z sequent var u end eval as "seqeval cut two * term * forerunner * sequent * end eval" end define end math ]"}} \subsection{The proof evaluator}\label{section:TheProofEvaluator} \subsubsection{Coloring} "[ bracket var x infer var y end bracket ]" is self-evaluating. For that reason, "[ bracket quote var x end quote infer quote var y end quote end bracket ]" and "[ bracket quote var x infer var y end quote end bracket ]" are equal terms except for debugging information. The debugging information of the root of "[ bracket quote var x end quote infer quote var y end quote end bracket ]" equals "[ bracket true end bracket ]" which represents no debugging information. For that reason we shall call the root \indexintro{uncolored}. Proper debugging information comprises a list of cardinals where the last cardinal in the list is the reference of the page on which the given node occurs. Hence, proper debugging information always differs from "[ bracket true end bracket ]". We shall refer to nodes whose debugging information differs from "[ bracket true end bracket ]" as \indexintro{colored}. Whenever terms are generated using self-evaluating constructs, there will be uncolored nodes near the root of the generated term. The binary "[ bracket var a color var t end color end bracket ]" operation returns the term "[ bracket var t end bracket ]" but copies the debugging information from the root of "[ bracket var a end bracket ]" into uncolored nodes of "[ bracket var t end bracket ]". We shall refer to this artistic touch as \indexintro{coloring}. The coloring operation merely descends into the tree until it meets nodes with proper debugging information, so the operation will miss uncolored nodes hidden deeply inside the tree. The coloring operation is defined thus: \index{color: "[ bracket var x color var y end color end bracket ]" x color y end color}% % \index{x color y end color "[ bracket var x color var y end color end bracket ]"}% % \tex{"[ math tex define var x color var y end color as "#1. \mbox {-color}( #2. )" end define end math ]"}% % \display{"[ math value define var a color var t end color as var t debug select parenthesis var t ref pair var t id pair var a debug end parenthesis pair var a color star var t tail end color else var a tagged guard var t end select end define end math ]"% % \footnote{"[ math pyk define var x color var y end color as "* color * end color" end define end math ]"}} \index{color*: "[ bracket var x color star var y end color end bracket ]" x color star y end color}% % \index{x color star y end color "[ bracket var x color star var y end color end bracket ]"}% % \tex{"[ math tex define var x color star var y end color as "#1. \mbox {-color}^{\ast}( #2. )" end define end math ]"}% % \display{"[ math value define var a color star var t end color as var t select var a tagged guard true else var a color var t head end color pair var a color star var t tail end color end select end define end math ]"% % \footnote{"[ math pyk define var x color star var y end color as "* color star * end color" end define end math ]"}}% % \test{"[ math test quote two end quote color quote three end quote infer quote four end quote end color term equal quote three infer four end quote end test end math ]"} \subsubsection{Error message generation} The following macro expands into a construct that returns an error message. The first argument is supposed to be a string and the value of the second is supposed to be a term. When used, the construct generates an error message consisting of the string followed by a newline followed by the term, which is of course rather limited. Whenever it is convenient to include more than one term in a message we take the rather crude approach to combine the messages by the cut operation! The cut operation is self-evaluating and, when typeset, puts a semicolon between its arguments, which is close to tolerable. The error generation macro simply quotes the string argument and leaves the actual generation of the error message to an auxiliary function: \index{error @\back "[ bracket text error var m term var t end error end text end bracket ]" error x term y end error}% % \tex{"[ math tex define error var m term var t end error as " error(#1/tex name. ,#2. )" end define end math ]"}% % \display{"[ math macro define error var m term var t end error as error two quote var m end quote term var t end error end define end math ]"% % \footnote{"[ math pyk define error var m term var t end error as "error * term * end error" end define end math ]"}} The following function generates an error message from a message "[ bracket var m end bracket ]" and a term "[ bracket var t end bracket ]". "[ bracket var m end bracket ]" is supposed to be a unicode string with a unicode start of text in the root. That start of text character is removed by computing "[ bracket var m first end bracket ]" to drop the ``double quotes'' from the string, but a "[ bracket make visible text var x end text end visible end bracket ]" ensures that the unquoted string is still typeset as a string eventually. The text is glued together with a string that merely contains a newline character and which is treated similarly. Furthermore, the text plus newline character are glued together with the term "[ bracket var t end bracket ]". The text, newline character, and term are glued together with the "[ bracket make visible var x then var y end visible end bracket ]". The "[ bracket make visible text var x end text end visible end bracket ]" and "[ bracket make visible var x then var y end visible end bracket ]" are invisible when typeset using their tex aspects and, hence, do not exhibit themselves in the final error message. These two constructs are visible in the right hand side of the definition below and in several places above because they are made visible using "[ bracket make visible make visible var x end visible end visible end bracket ]". A "[ bracket var t color var x end color end bracket ]" copies the debugging information in the root of "[ bracket var t end bracket ]" to nodes in the error message that are generated by "[ bracket make visible text var x end text end visible end bracket ]" and "[ bracket make visible var x then var y end visible end bracket ]" and have no debugging information of their own. The definition reads: \index{error two @\back "[ bracket text error two var m term var t end error end text end bracket ]" error two x term y end error}% % \tex{"[ math tex define error two var m term var t end error as " error_{2}(#1/tex name. ,#2. )" end define end math ]"}% % \display{"[ math value define error two var m term var t end error as make visible var t color text var m first end text then text quote " " end quote first end text then var t end color end visible end define end math ]"% % \footnote{"[ math pyk define error two var m term var t end error as "error two * term * end error" end define end math ]"}} \subsubsection{Error recognition} The sequent evaluator returns a sequent or an error message. For obvious reasons, we shall need the ability to tell whether a return value is the one or the other. Error messages are terms that can be typeset by the Logiweb system. When recognizing error messages, we assume that they are generated by the error message generator of the previous section or similar means that put a "[ bracket make visible var x then var y end visible end bracket ]" operator in the root of the message. That particular operator is harmless to have in the root of error messages because typesetting of "[ bracket make visible var x then var y end visible end bracket ]" results in "[ bracket var x end bracket ]" and "[ bracket var y end bracket ]" being typeset and then concatenated. Note that "[ bracket make visible var x then var y end visible end bracket ]" above reads "[ bracket make visible make visible var x then var y end visible end visible end bracket ]" in the source of the present page, otherwise the ``then'' would have been invisible as in "[ bracket var x then var y end bracket ]". The predicate below is true if the argument is an error message and false if the argument is a sequent. It is also false in many other cases as we shall benefit from later. \index{E: "[ bracket var x is error end bracket ]" x is error}% % \index{x is error "[ bracket var x is error end bracket ]"}% % \tex{"[ math tex define var x is error as "#1. {} ^ { E }" end define end math ]"}% % \display{"[ math value define var x is error as var x term root equal quote make visible var x then var y end visible end quote end define end math ]"% % \footnote{"[ math pyk define var x is error as "* is error" end define end math ]"}} \subsubsection{Sequent evaluation} The sequent evaluation function "[ bracket sequent eval var c term var t end eval end bracket ]" evaluates the sequent proof "[ bracket var t end bracket ]" in the context defined by the cache "[ bracket var c end bracket ]". The result is a sequent or an error message. If it is a sequent, then the proof is valid and the sequent is the conclusion of the proof. The sequent evaluation function recognises the twelve sequent operations of Logiweb sequent calculus and turns against any other operations in "[ bracket var t end bracket ]". \index{S: "[ bracket sequent eval var x term var y end eval end bracket ]" sequent eval x term y end eval}% % \index{sequent eval x term y end eval "[ bracket sequent eval var x term var y end eval end bracket ]"}% % \tex{"[ math tex define sequent eval var x term var y end eval as " {\cal S}(#1. , #2. )" end define end math ]"}% % \display{"[ math value define sequent eval var c term var t end eval as var c tagged guard newline open if var t is error then var t else newline open if var t term root equal quote x init end quote then seqeval init var c term var t end eval else newline open if var t term root equal quote x modus end quote then seqeval modus var c term var t end eval else newline open if var t term root equal quote x verify end quote then seqeval verify var c term var t end eval else newline open if var t term root equal quote x curry plus end quote then sequent eval plus var c term var t end eval else newline open if var t term root equal quote x curry minus end quote then seqeval minus var c term var t end eval else newline open if var t term root equal quote x dereference end quote then seqeval deref var c term var t end eval else newline open if var t term root equal quote x at x end quote then seqeval at var c term var t end eval else newline open if var t term root equal quote x infer x end quote then seqeval infer var c term var t end eval else newline open if var t term root equal quote x endorse x end quote then seqeval endorse var c term var t end eval else newline open if var t term root equal quote x id est x end quote then seqeval est var c term var t end eval else newline open if var t term root equal quote all x indeed x end quote then seqeval all var c term var t end eval else newline open if var t term root equal quote x cut x end quote then seqeval cut var c term var t end eval else newline error "Unknown sequent operator:" term var t end error end define end math ]"% % \footnote{"[ math pyk define sequent eval var x term var y end eval as "sequent eval * term * end eval" end define end math ]"}}% % \test{"[ math test sequent eval self term quote parenthesis meta a rule plus meta b end parenthesis init end quote end eval sequent equal tuple the empty set comma the empty set comma quote parenthesis meta a rule plus meta b end parenthesis infer parenthesis meta a rule plus meta b end parenthesis end quote end tuple end test end math ]"}% % \test{"[ math test sequent eval self term quote meta a infer meta b init end quote end eval sequent equal tuple the empty set comma the empty set comma quote meta a infer meta b infer meta b end quote end tuple end test end math ]"} \subsubsection{Lemma verification}\label{section:LemmaVerification} The macro "[ bracket var p proves var t end bracket ]" claims that "[ bracket var p end bracket ]" proves "[ bracket var t end bracket ]": % \index{proves: "[ math var x proves var y end math ]" x proves y}% % \index{x proves y: "[ math var x proves var y end math ]"}% % \tex{"[ math tex define var p proves var t as "#1. \ proves\ #2." end define end math ]"}% % \display{"[ math macro define var p proves var t as proof quote var p end quote term quote var t end quote cache self end proof end define end math ]"% % \footnote{"[ math pyk define var x proves var y as "* proves *" end define end math ]"}} As an example, the following verifies "[ bracket two infer two end bracket ]": \display{"[ math raw test two init proves two infer two end test end math ]"} Perturbing the conclusion to e.g.\ "[ bracket two infer three end bracket ]" provokes the diagnose aspect of the page symbol to be set to a term which, if typeset using the tex aspect, generates an appropriate error message. "[ bracket proof var p term var t cache var c end proof end bracket ]" equals "[ bracket true end bracket ]" if the proof "[ bracket var p end bracket ]" proves the sequent lemma "[ bracket var t end bracket ]" in the context defined by the cache "[ bracket var c end bracket ]". Otherwise, "[ bracket proof var p term var t cache var c end proof end bracket ]" returns an error message: \index{proof @\back "[ bracket proof var x term var y cache var z end proof end bracket ]" proof x term y cache z end proof}% % \index{proof x term y cache z end proof "[ math proof var x term var y cache var z end proof end math ]"}% % \tex{"[ math tex define proof var p term var t cache var c end proof as " proof( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define proof var p term var t cache var c end proof as proof two sequent eval var c term var p end eval term var t end proof end define end math ]"% % \footnote{"[ math pyk define proof var p term var t cache var c end proof as "proof * term * cache * end proof" end define end math ]"}} "[ bracket proof two var q term var t end proof end bracket ]" equals "[ bracket true end bracket ]" if "[ bracket var q end bracket ]" is a sequent which proves the sequent lemma "[ bracket var t end bracket ]". Otherwise, "[ bracket proof two var q term var t end proof end bracket ]" returns an error message: \index{proof 2 @\back "[ bracket proof two var x term var y end proof end bracket ]" proof two x term y end proof}% % \tex{"[ math tex define proof two var q term var t end proof as " proof_{2}( #1. , #2. )" end define end math ]"}% % \display{"[ math value define proof two var q term var t end proof as var t tagged guard newline open if var q is error then var q else newline open if not var q zeroth then error "Proof has at least one unresolved premise. Lemma;premise reads:" term var t cut var q zeroth head end error else newline open if not var q first then error "Proof has at least one unresolved side condition. Lemma;condition reads:" term var t cut var q first head end error else newline open if var q second term equal var t then true else newline error "Lemma does not match conclusion. Lemma;conclusion reads:" term var t cut var q second end error end define end math ]"% % \footnote{"[ math pyk define proof two var q term var t end proof as "proof two * term * end proof" end define end math ]"}} \subsection{The verifier} \subsubsection{Conjunction membership} The verifier allows proofs to refer to previously proved lemmas. Such previously proved lemmas may occur on the same page as the proof or in transitively referenced pages. When a lemma on another page is referenced, the verifier needs to ensure that that other page has been properly checked. The verifier does so by looking up the diagnose aspect of the referenced page to see that the referenced page is correct. Furthermore, the verifier looks up the claim aspect of the referenced page to see that the claim is a conjunction that includes the verifier itself. The above verification check for referenced pages is fast because the verifier itself is not invoked on the page. Rather, the verifier just ensures that the verifier was invoked successfully when the page was loaded. Furthermore, the verification check is flexible in that the verifier only requires referenced pages to be checked by the verifier if those other pages actually contribute to proofs. This allows pages that contain proofs to reference pages that are unrelated to proofs such as pages that define computer programs, formatting constructs, fonts, or whatever. The verifier is also flexible in that it allows referenced pages to be checked by any number of other checkers alongside the verifier itself. That allows the verifier to coexist with other proof checkers and all sorts of other checkers. As an example, one may decide to impose strong typing on a page using some type checker without affecting the ability to check proofs. To implement the above verification check we need a relation "[ bracket var x claim in var y end bracket ]" which is true iff the term "[ bracket var x end bracket ]" belongs to the conjunction "[ bracket var y end bracket ]": % \index{c: \back "[ bracket var x claim in var y end bracket ]" x claim in y}% % \index{\alpha x claim in y @\back "[ bracket var x claim in var y end bracket ]" x claim in y}% % \index{x claim in y "[ bracket var x claim in var y end bracket ]"}% % \tex{"[ math tex define var x claim in var y as "#1. \in_c #2." end define end math ]"}% % \display{"[ math value define var x claim in var y as var y term root equal quote var x claim and var y end quote select tagged if var x claim in var y first then true else var x claim in var y second end if else var x term equal var y end select end define end math ]"% % \footnote{"[ math pyk define var x claim in var y as "* claim in *" end define end math ]"}} % Furthermore, we need a function "[ bracket claims var t cache var c ref var r end claims end bracket ]" which is true if the term "[ bracket var t end bracket ]" belongs to the potentially inherited claim of page "[ bracket var r end bracket ]" according to the cache "[ bracket var c end bracket ]": % \index{claims @\back "[ bracket claims var t cache var c ref var r end claims end bracket ]" claims t cache c ref r end claims}% % \tex{"[ math tex define claims var t cache var c ref var r end claims as " claims( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define claims var t cache var c ref var r end claims as newline tagged if claims two var t cache var c ref var r end claims then true else claims two var t cache var c ref var c assoc var r end assoc assoc bibliography hook end assoc first end claims end if end define end math ]"% % \footnote{"[ math pyk define claims var t cache var c ref var r end claims as "claims * cache * ref * end claims" end define end math ]"}} % % \index{claims 2 @\back "[ bracket claims two var t cache var c ref var r end claims end bracket ]" claims two t cache c ref r end claims}% % \tex{"[ math tex define claims two var t cache var c ref var r end claims as " claims_2( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define claims two var t cache var c ref var r end claims as tagged if not var r is cardinal then var t tagged guard var c tagged guard false else var t claim in var c assoc var r end assoc assoc codex hook end assoc assoc var r end assoc assoc zero end assoc assoc zero end assoc assoc claim aspect end assoc third end if end define end math ]"% % \footnote{"[ math pyk define claims two var t cache var c ref var r end claims as "claims two * cache * ref * end claims" end define end math ]"}} % \test{"[ math test quote checker end quote claim in quote checker claim and verifier end quote end test end math ]"} \test{"[ math test quote verifier end quote claim in quote checker claim and verifier end quote end test end math ]"} \test{"[ math false test quote seven end quote claim in quote checker claim and verifier end quote end test end math ]"} \test{"[ math test claims quote verifier end quote cache self ref self assoc zero end assoc end claims end test end math ]"} \test{"[ math false test claims quote seven end quote cache self ref self assoc zero end assoc end claims end test end math ]"} \subsubsection{The proof aspect}\label{section:TheProofAspect} The ``proves'' predicate in Section \ref{section:LemmaVerification} is useful for testing the validity of a single, stand-alone proof which proves some lemma from scratch without reference to any auxilliary lemmas. For more complex proofs, we introduce a \indexintro{proof aspect} and make the convention that whenever a construct has a proof aspect, then the construct should also have a statement aspect and, furthermore, the proof aspect should be a proof of the statement aspect. We make the proof aspect self-evaluating and use "[ bracket proof end bracket ]" to denote it: % \index{proof @\back "[ bracket the proof aspect end bracket ]" the proof aspect}% % \index{the proof aspect "[ bracket the proof aspect end bracket ]"}% % \tex{"[ math tex define the proof aspect as " {<}proof{>}" end define end math ]"}% % \display{"[ math value define the proof aspect as quote the proof aspect end quote end define end math ]"% % \footnote{"[ math pyk define the proof aspect as "the proof aspect" end define end math ]"}} % % \index{proof "[ bracket proof end bracket ]"}% % \tex{"[ math tex define proof as " proof" end define end math ]"}% % \display{"[ math message define proof as the proof aspect end define end math ]"% % \footnote{"[ math pyk define proof as "proof" end define end math ]"}} % From the point of view of Logiweb, lemmas and proofs are just definitions: % \index{Lemma @\back "[ math unicode start of text lemma var x says var y end lemma end unicode text end math ]" lemma x says y}% % \tex{"[ math tex define lemma var x says var y end lemma as " [ \mathbf{Lemma\ } #1. \colon #2. ]" end define end math ]"} % \display{"[ math macro define lemma var x says var y end lemma as define statement of var x as var y end define end define end math ]"% % \footnote{"[ math pyk define lemma var x says var y end lemma as "lemma * says * end lemma" end define end math ]"}} % \index{proof of @\back "[ math unicode start of text proof of var x reads var y end proof end unicode text end math ]" proof of x read y end proof}% % \tex{"[ math tex define proof of var x reads var y end proof as " [ \mathbf{Proof\ of\ }#1/tex name/tex. \colon #2. ]" end define end math ]"}% % \display{"[ math macro define proof of var x reads var y end proof as define proof of var x as var y end define end define end math ]"% % \footnote{"[ math pyk define proof of var x reads var y end proof as "proof of * reads * end proof" end define end math ]"}} % The following construct provides a reader friendly way of stating that a statement "[ bracket var z end bracket ]" is provable in a theory "[ bracket var x end bracket ]" and giving the conjecture the name "[ bracket var y end bracket ]". % \index{in theory x lemma y says z end lemma "[ math unicode start of text in theory var x lemma var y says var z end lemma end unicode text end math ]"}% % \index{lemma: "[ math unicode start of text in theory var x lemma var y says var z end lemma end unicode text end math ]" in theory x lemma y says z end lemma}% % \tex{"[ math tex define in theory var x lemma var y says var z end lemma as " [ #1. \mathbf{\ lemma\ } #2. \colon #3. ]" end define end math ]"} % \display{"[ math macro define in theory var x lemma var y says var z end lemma as statement define var y as var x infer var z end define end define end math ]"% % \footnote{"[ math pyk define in theory var x lemma var y says var z end lemma as "in theory * lemma * says * end lemma" end define end math ]"}} % As an example of use, % \index{example axiom lemma primed "[ bracket example axiom lemma primed end bracket ]"}% % \index{HeadNil @\back "[ bracket example axiom lemma primed end bracket ]" example axiom lemma primed}% % \tex{"[ math tex define example axiom lemma primed as " HeadNil''" end define end math ]"}% % \statement{"[ math in theory example theory primed lemma example axiom lemma primed says true head math equal true end lemma end math ]"% % \footnote{"[ math pyk define example axiom lemma primed as "example axiom lemma primed" end define end math ]"}} % conjectures that "[ bracket true head math equal true end bracket ]" is provable in "[ bracket example theory primed end bracket ]". The following construct provides a reader friendly way of stating that a statement "[ bracket var z end bracket ]" is disprovable in a theory "[ bracket var x end bracket ]" and giving the anticonjecture the name "[ bracket var y end bracket ]". % \index{in theory x antilemma y says z end antilemma "[ math unicode start of text in theory var x antilemma var y says var z end antilemma end unicode text end math ]"}% % \index{antilemma: "[ math unicode start of text in theory var x antilemma var y says var z end antilemma end unicode text end math ]" in theory x antilemma y says z end antilemma}% % \tex{"[ math tex define in theory var x antilemma var y says var z end antilemma as " [ #1. \mathbf{\ antilemma\ } #2. \colon #3. ]" end define end math ]"} % \display{"[ math macro define in theory var x antilemma var y says var z end antilemma as in theory var x lemma var y says var z infer absurdity end lemma end define end math ]"% % \footnote{"[ math pyk define in theory var x antilemma var y says var z end antilemma as "in theory * antilemma * says * end antilemma" end define end math ]"}} % As an example of use, % \index{Contra'' @\back "[ bracket contraexample lemma primed end bracket ]" contraexample lemma primed}% % \tex{"[ math tex define contraexample lemma primed as " Contra''" end define end math ]"}% % \statement{"[ math in theory example theory primed antilemma contraexample lemma primed says true pair true math equal true end antilemma end math ]"% % \footnote{"[ math pyk define contraexample lemma primed as "contraexample lemma primed" end define end math ]"}} % conjectures that "[ bracket true pair true math equal true end bracket ]" is disprovable in "[ bracket example theory primed end bracket ]". \subsubsection{Verifier} The "[ bracket verifier end bracket ]" checks the correctness of all proofs on a page. It is suited to appear in a conjunction that makes up the claim of a page. The verifier ignores the macro expanded tree "[ bracket var t end bracket ]" and merely uses the cache "[ bracket var c end bracket ]". % \index{verifier @\back "[ bracket verifier end bracket ]" verifier}% % \display{"[ math value define verifier as lambda var t dot lambda var c dot verify one var c end verify end define end math ]"% % \footnote{"[ math pyk define verifier as "verifier" end define end math ]"}} % "[ bracket verify one var c end verify end bracket ]" extracts the reference "[ bracket var r end bracket ]" of the page to be checked from the cache "[ bracket var c end bracket ]" of the page. Then it extracts the subcodex "[ bracket var x end bracket ]" of all domestic definition of the page and uses "[ bracket verify two var c proofs var x end verify end bracket ]" to evaluate the array of proofs into an array "[ bracket var p end bracket ]" of sequents. Then it uses "[ bracket verify three var c ref var r sequents var p diagnose var d end verify end bracket ]" to verify the correctness of all proofs. % \index{v 1 @\back "[ bracket verify one var c end verify end bracket ]" verify one c end verify}% % \index{verify one c end verify "[ bracket verify one var c end verify end bracket ]"}% % \tex{"[ math tex define verify one var c end verify as " {\cal V}_1( #1. )" end define end math ]"}% % \display{"[ math value define verify one var c end verify as newline let var r be var c assoc zero end assoc in newline let var x be var c assoc var r end assoc assoc codex hook end assoc assoc var r end assoc in newline let var p be verify two var c proofs var x end verify in newline let var d be verify three var c ref var r sequents var p diagnose true end verify in newline open if not var d then var d else newline let var i be verify five var c ref var r array var p sequents var p end verify in newline open if not var i is cardinal then true else newline error "Circular proof. Circle includes:" term var p assoc var i end assoc zeroth head end error end define end math ]"% % \footnote{"[ math pyk define verify one var c end verify as "verify one * end verify" end define end math ]"}} % "[ bracket verify two var c proofs var p end verify end bracket ]" evaluates all proofs in the subcodex "[ bracket var p end bracket ]" and returns the result as a one-dimensional array of sequents (indexed by the identifier of each proof). "[ bracket verify two var c proofs var p end verify end bracket ]" is not particularly efficient since it continues to evaluate all proofs even if one of the proofs returns an error message. For each symbol in the subcodex, "[ bracket verify two var c proofs var p end verify end bracket ]" extracts the proof definition "[ bracket var d end bracket ]" (i.e.\ the right hand side of the "[ bracket the proof aspect end bracket ]" aspect) of the symbol. If the proof aspect exists (i.e.\ differs from "[ bracket true end bracket ]") then "[ bracket verify two var c proofs var p end verify end bracket ]" uses the evaluator "[ bracket eval var d stack true cache var c end eval end bracket ]" to compute the value of "[ bracket var d end bracket ]", applies the result to the cache "[ bracket var c end bracket ]" in order to give access to the cache from proof tactics inside "[ bracket var d end bracket ]", and then uses the sequent evaluator "[ bracket sequent eval var c term var t end eval end bracket ]" to evaluate the proof into a sequent. % \index{v 2 @\back "[ bracket verify two var c proofs var p end verify end bracket ]" verify two c proofs p end verify}% % \index{verify two c proofs p end verify "[ bracket verify two var c proofs var p end verify end bracket ]"}% % \tex{"[ math tex define verify two var c proofs var p end verify as " {\cal V}_2( #1. , #2. )" end define end math ]"}% % \display{"[ math value define verify two var c proofs var p end verify as var c tagged guard newline open if var p then true else newline open if not var p head is cardinal then verify two var c proofs var p head end verify pair verify two var c proofs var p tail end verify else var p head pair newline let var d be aspect the proof aspect subcodex var p tail end aspect in newline open if var d then true else newline let var r be sequent eval var c term normalizing untag eval var d third stack true cache var c end eval tagged apply var c tagged apply var p end untag end eval in newline open if var r is error then error "Error in proof of" term var d second then text quote " " end quote first end text then var r end error else var r end define end math ]"% % \footnote{"[ math pyk define verify two var c proofs var p end verify as "verify two * proofs * end verify" end define end math ]"}} % "[ bracket verify three var c ref var r sequents var p diagnose var d end verify end bracket ]" returns the diagnose "[ bracket var d end bracket ]" if "[ bracket var d end bracket ]" differs from "[ bracket true end bracket ]". Otherwise, it traverses the array "[ bracket var p end bracket ]" of sequents and checks each sequent "[ bracket var q end bracket ]" for correctness. During the check, "[ bracket var i end bracket ]" is bound to the identifier of the proof being checked and "[ bracket var d end bracket ]" is bound to the lemma being checked. % \index{v 3 @\back "[ bracket verify three var c ref var r sequents var p diagnose var d end verify end bracket ]" verify three c ref r sequents p diagnose d end verify}% % \index{verify three c ref r sequents p diagnose d end verify "[ bracket verify three var c ref var r sequents var p diagnose var d end verify end bracket ]"}% % \tex{"[ math tex define verify three var c ref var r sequents var p diagnose var d end verify as " {\cal V}_3( #1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define verify three var c ref var r sequents var p diagnose var d end verify as var c tagged guard var r tagged guard var p tagged guard newline open if not var d then var d else newline open if var p then true else newline open if not var p head is cardinal then verify three var c ref var r sequents var p tail diagnose verify three var c ref var r sequents var p head diagnose true end verify end verify else newline let var i be var p head in newline let var q be var p tail in newline open if var q then true else newline open if var q is error then var q else newline open if not var q first then error "Unchecked sidecondition:" term var q first head end error else newline let var d be aspect the statement aspect subcodex var c assoc var r end assoc assoc codex hook end assoc assoc var r end assoc assoc var i end assoc end aspect in newline open if var d then error "Proof of non-existent lemma:" term var q second end error else newline open if not var q second term equal var d third then error "Lemma/proof mismatch:" term var d second cut var q second end error else newline {open if not var q zeroth then error "Unresolved premise:" term var q zeroth head end error else newline} verify four var c premises var q zeroth end verify end define end math ]"% % \footnote{"[ math pyk define verify three var c ref var r sequents var p diagnose var d end verify as "verify three * ref * sequents * diagnose * end verify" end define end math ]"}} % "[ bracket verify four var c premises var p end verify end bracket ]" checks that the list "[ bracket var p end bracket ]" of premises consists of proved lemmas. That is done by verifying that each member of "[ bracket var p end bracket ]" has a proof and belongs to a correct page that lists the verifier among its claims. The page being verified is considered correct during the check since the diagnose aspect is not yet set while checking the page. The only thing "[ bracket verify four var c premises var p end verify end bracket ]" does not check for is circular proofs (e.g.\ proofs that make use of the lemma they prove). Checking for circularity is done elsewhere. % \index{v 4 @\back "[ bracket verify four var c premises var p end verify end bracket ]" verify four c premises p end verify}% % \index{verify four c premises p end verify "[ bracket verify four var c premises var p end verify end bracket ]"}% % \tex{"[ math tex define verify four var c premises var p end verify as " {\cal V}_4( #1. , #2. )" end define end math ]"}% % \display{"[ math value define verify four var c premises var p end verify as var c tagged guard newline open if var p then true else newline let var d be verify four var c premises var p tail end verify in newline open if not var d then var d else newline let var p be var p head in newline let var r be var p ref in newline let var i be var p id in newline open if not var c assoc var r end assoc assoc diagnose hook end assoc then newline error "Reference to erroneous page" term var p end error else newline open if not claims quote verifier end quote cache var c ref var r end claims then newline error "Reference to unchecked lemma" term var p end error else newline open if aspect the proof aspect term var p cache var c end aspect then newline error "Reference to unproved lemma" term var p end error else true end define end math ]"% % \footnote{"[ math pyk define verify four var c premises var p end verify as "verify four * premises * end verify" end define end math ]"}} % "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" takes as input an array "[ bracket var q end bracket ]" that contains the conclusions of all proofs on the present page. These conclusions are all sequents and they are indexed by the identifiers of the symbols they belong to. The sequents are allowed to have unresolved premises provided the premises are proved elsewhere. Furthermore, the directed graph with sequents as nodes and premises as edges is required to be non-cyclic. "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" performs a search for cycles. Logiweb pages and Logiweb bibliographic references form a non-cyclic graph, so whenever a premise refers to a lemma proved on another page, that premise cannot be part of a cycle. For that reason, "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" ignores premises whose reference differs from the reference "[ bracket var r end bracket ]" of the page being checked. "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" checks all nodes and edges reachable from the node with identifier "[ bracket var i end bracket ]" for cycles. If a cycle is found, the identifier of one of the nodes in the cycle is returned. Hence, a return value which is a cardinal indicates that a cycle is found. Otherwise, "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" replaces all reachable nodes in "[ bracket var q end bracket ]" by the cardinal "[ bracket one end bracket ]" and returns the modified "[ bracket var q end bracket ]". When "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" reaches a node that is set to "[ bracket one end bracket ]" then it assumes that that node has already been checked for cycles. During the search for cycles, "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" temporarily sets all nodes being considered to "[ bracket zero end bracket ]". When "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" reaches a node that is set to "[ bracket zero end bracket ]" it assumes that a cycle has been found and returns the identifier of the node. % \index{v 7 @\back "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]" verify seven c ref r id i sequents q end verify}% % \index{verify seven c ref r id i sequents q end verify "[ bracket verify seven var c ref var r id var i sequents var q end verify end bracket ]"}% % \tex{"[ math tex define verify seven var c ref var r id var i sequents var q end verify as " {\cal V}_7( #1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define verify seven var c ref var r id var i sequents var q end verify as var c tagged guard var r tagged guard newline let var v be var q assoc var i end assoc in newline open if var v then var q else newline open if var v tagged equal zero then var i else newline open if var v tagged equal one then var q else newline let var q be verify six var c ref var r list var v zeroth sequents var q set var i to zero end set end verify in newline open if var q is cardinal then var q else var q set var i to one end set end define end math ]"% % \footnote{"[ math pyk define verify seven var c ref var r id var i sequents var q end verify as "verify seven * ref * id * sequents * end verify" end define end math ]"}} % "[ bracket verify six var c ref var r list var p sequents var q end verify end bracket ]" checks all indices in the list "[ bracket var p end bracket ]" if premises for circularity in the array "[ bracket var q end bracket ]" of sequents. % \index{v 6 @\back "[ bracket verify six var c ref var r list var p sequents var q end verify end bracket ]" verify six c ref r list p sequents q end verify}% % \index{verify six c ref r list p sequents q end verify "[ bracket verify six var c ref var r list var p sequents var q end verify end bracket ]"}% % \tex{"[ math tex define verify six var c ref var r list var p sequents var q end verify as " {\cal V}_6( #1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define verify six var c ref var r list var p sequents var q end verify as var c tagged guard var r tagged guard var p tagged guard newline open if var q is cardinal then var q else newline open if var p then var q else newline let var q be verify six var c ref var r list var p tail sequents var q end verify in newline open if var q is cardinal then var q else newline open if not var r tagged equal var p head ref then var q else newline verify seven var c ref var r id var p head id sequents var q end verify end define end math ]"% % \footnote{"[ math pyk define verify six var c ref var r list var p sequents var q end verify as "verify six * ref * list * sequents * end verify" end define end math ]"}} % "[ bracket verify five var c ref var r array var a sequents var q end verify end bracket ]" checks all indices in the array "[ bracket var a end bracket ]" for circularity in the array "[ bracket var q end bracket ]" of sequents. % \index{v 5 @\back "[ bracket verify five var c ref var r array var a sequents var q end verify end bracket ]" verify five c ref r array a sequents q end verify}% % \index{verify five c ref r array a sequents q end verify "[ bracket verify five var c ref var r array var a sequents var q end verify end bracket ]" verify five c ref r array a sequents q end verify}% % \tex{"[ math tex define verify five var c ref var r array var a sequents var q end verify as " {\cal V}_5( #1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define verify five var c ref var r array var a sequents var q end verify as var c tagged guard var r tagged guard var a tagged guard newline open if var q is cardinal then var q else newline open if var a then var q else newline open if not var a head is cardinal then verify five var c ref var r array var a tail sequents verify five var c ref var r array var a head sequents var q end verify end verify else newline verify seven var c ref var r id var a head sequents var q end verify end define end math ]"% % \footnote{"[ math pyk define verify five var c ref var r array var a sequents var q end verify as "verify five * ref * array * sequents * end verify" end define end math ]"}} % \subsubsection{The rule lemma tactic} In Section \ref{section:TheProofAspect} we stated two lemmas: \statement{"[ math in theory example theory primed lemma example axiom lemma primed says true head math equal true end lemma end math ]"} \statement{"[ math in theory example theory primed antilemma contraexample lemma primed says true pair true math equal true end antilemma end math ]"} Both lemmas are trivial; they are both instances of the general fact that all rules of a theory are provable in the theory. It is rather straightforward to prove both lemmas using suitable sequent operations but instead of writing a handmade proof for each lemma we shall write a proof tactic which, given a theory and a rule of the theory, generates a proof that the rule follows from the theory. We shall refer to the tactic as the "[ bracket rule tactic end bracket ]", and we shall arrange that the following become valid proofs of the above lemmas: \statement{"[ math proof of example axiom lemma primed reads rule tactic end proof end math ]"} \statement{"[ math proof of contraexample lemma primed reads rule tactic end proof end math ]"} We define the rule tactic thus: % \index{rule tactic @\back "[ bracket rule tactic end bracket ]" rule tactic}% % \tex{"[ math tex define rule tactic as " Rule\ tactic" end define end math ]"}% % \display{"[ math value define rule tactic as lambda var c dot lambda var p dot rule var c subcodex var p end rule end define end math ]"% % \footnote{"[ math pyk define rule tactic as "rule tactic" end define end math ]"}} % When invoked from the verifier, the tactic is applied to the cache "[ bracket var c end bracket ]" of the current page and a pair "[ bracket var p end bracket ]" whose first component is the identifier of the lemma to be proved and whose second component is the subcodex containing all aspects of that lemma. The rule tactic passes control to the function below. % \index{Rule @\back "[ bracket rule var x subcodex var y end rule end bracket ]" rule x subcodex y end rule}% % \tex{"[ math tex define rule var c subcodex var p end rule as " rule( #1. , #2. )" end define end math ]"}% % \display{"[ math value define rule var c subcodex var p end rule as var c tagged guard newline let var s be aspect the statement aspect subcodex var p tail end aspect third in newline open if var s then quote text "Rule has no statement aspect" end text end quote else newline open if not var s term root equal quote var x infer var y end quote then error "Rule has invalid statement aspect" term var s end error else newline let var t be aspect the statement aspect term var s first cache var c end aspect third in newline open if var t then quote text "Theory has no statement aspect" end text end quote else newline let var r be rule one var s second theory var t end rule in newline open if var r is cardinal then error "The theory does not assert the given rule" term var s cut var t end error else newline parenthesis var s first infer cut var s first init modus dereference and var r end cut end parenthesis end define end math ]"% % \footnote{"[ math pyk define rule var c subcodex var p end rule as "rule * subcodex * end rule" end define end math ]"}} % The function above finds out what the rule tactic is supposed to prove and then passes control to the function below for constructing the proofs. % \index{Rule 1 @\back "[ bracket rule one var x theory var y end rule end bracket ]" rule one x theory y end rule}% % \tex{"[ math tex define rule one var s theory var t end rule as " rule_1( #1. , #2. )" end define end math ]"}% % \display{"[ math value define rule one var s theory var t end rule as newline open if var s term equal var t then true else newline open if not var t term root equal quote var x rule plus var y end quote then zero else newline let var p be rule one var s theory var t first end rule in newline open if not var p is cardinal then cut head var t end head and var p end cut else newline let var p be rule one var s theory var t second end rule in newline open if not var p is cardinal then cut tail var t end tail and var p end cut else zero end define end math ]"% % \footnote{"[ math pyk define rule one var s theory var t end rule as "rule one * theory * end rule" end define end math ]"}} % The function above searches for the given rule in the given theory. When found, it constructs a proof using the three proof constructors below. % \index{Cut @\back "[ bracket cut var x and var y end cut end bracket ]" cut x and y end cut}% % \tex{"[ math tex define cut var a and var b end cut as " Cut( #1. , #2. )" end define end math ]"}% % \display{"[ math value define cut var a and var b end cut as tagged if var b then var a else var a cut var b end if end define end math ]"% % \footnote{"[ math pyk define cut var a and var b end cut as "cut * and * end cut" end define end math ]"}} % % \index{Head @\back "[ bracket head var x end head end bracket ]" head x end head}% % \tex{"[ math tex define head var s end head as " Head_{\oplus} ( #1. )" end define end math ]"}% % \display{"[ math value define head var s end head as parenthesis var s first infer var s second infer var s first init modus end parenthesis curry plus modus end define end math ]"% % \footnote{"[ math pyk define head var s end head as "head * end head" end define end math ]"}} % % \index{Tail @\back "[ bracket tail var x end tail end bracket ]" tail x end tail}% % \tex{"[ math tex define tail var s end tail as " Tail_{\oplus} ( #1. )" end define end math ]"}% % \display{"[ math value define tail var s end tail as parenthesis var s first infer var s second init end parenthesis curry plus modus end define end math ]"% % \footnote{"[ math pyk define tail var s end tail as "tail * end tail" end define end math ]"}} % \subsubsection{Stating rules} The rule tactic of the previous section allows to prove that all rules of a theory are provable in the theory. The following macros allow to express lemma and proof in one go: % \index{in theory x rule y says z end rule "[ math unicode start of text in theory var x rule var y says var z end rule end unicode text end math ]"}% % \index{rule: "[ math unicode start of text in theory var x rule var y says var z end rule end unicode text end math ]" in theory x rule y says z end rule}% % \tex{"[ math tex define in theory var x rule var y says var z end rule as " [ #1. \mathbf{\ rule\ } #2. \colon #3. ]" end define end math ]"} % \display{"[ math macro define in theory var x rule var y says var z end rule as in theory var x lemma var y says var z end lemma then proof of var y reads rule tactic end proof end define end math ]"% % \footnote{"[ math pyk define in theory var x rule var y says var z end rule as "in theory * rule * says * end rule" end define end math ]"}} % % \index{in theory x antirule y says z end antirule "[ math unicode start of text in theory var x antirule var y says var z end antirule end unicode text end math ]"}% % \index{antirule: "[ math unicode start of text in theory var x antirule var y says var z end antirule end unicode text end math ]" in theory x antirule y says z end antirule}% % \tex{"[ math tex define in theory var x antirule var y says var z end antirule as " [ #1. \mathbf{\ antirule\ } #2. \colon #3. ]" end define end math ]"} % \display{"[ math macro define in theory var x antirule var y says var z end antirule as in theory var x rule var y says var z infer absurdity end rule end define end math ]"% % \footnote{"[ math pyk define in theory var x antirule var y says var z end antirule as "in theory * antirule * says * end antirule" end define end math ]"}} % Having these constructs it is easy to state that all four rules of "[ bracket example theory primed end bracket ]" are provable in "[ bracket example theory primed end bracket ]": \statement{"[ math in theory example theory primed rule example axiom lemma primed says true head math equal true end rule end math ]"} % \index{example scheme lemma primed "[ bracket example scheme lemma primed end bracket ]"}% % \index{HeadPair @\back "[ bracket example scheme lemma primed end bracket ]" example scheme lemma primed}% % \tex{"[ math tex define example scheme lemma primed as " HeadPair''" end define end math ]"}% % \statement{"[ math in theory example theory primed rule example scheme lemma primed says all meta a indeed all meta b indeed parenthesis meta a pair meta b end parenthesis head math equal meta a end rule end math ]"% % \footnote{"[ math pyk define example scheme lemma primed as "example scheme lemma primed" end define end math ]"}} % % \index{example rule lemma primed "[ bracket example rule lemma primed end bracket ]"}% % \index{Transitivity @\back "[ bracket example rule lemma primed end bracket ]" example rule lemma primed}% % \tex{"[ math tex define example rule lemma primed as " Transitivity''" end define end math ]"}% % \statement{"[ math in theory example theory primed rule example rule lemma primed says all meta a indeed all meta b indeed all meta c indeed meta a math equal meta b infer meta a math equal meta c infer meta b math equal meta c end rule end math ]"% % \footnote{"[ math pyk define example rule lemma primed as "example rule lemma primed" end define end math ]"}} % \statement{"[ math in theory example theory primed antirule contraexample lemma primed says true pair true math equal true end antirule end math ]"} \subsubsection{Stating theories} We have now defined the theory "[ bracket example theory primed end bracket ]" and stated the four rule lemmas there are for that theory, namely one for each rule of the theory. Once the rules are stated, the definition if "[ bracket example theory primed end bracket ]" is a bit redundant since the four rules contain all information about the theory. We now define the theory and the four rule lemmas once more, but in a more elegant way: % \index{example axiom lemma "[ bracket example axiom lemma end bracket ]"}% % \index{HeadNil @\back "[ bracket example axiom lemma end bracket ]" example axiom lemma}% % \tex{"[ math tex define example axiom lemma as " HeadNil" end define end math ]"}% % \statement{"[ math in theory example theory rule example axiom lemma says true head math equal true end rule end math ]"% % \footnote{"[ math pyk define example axiom lemma as "example axiom lemma" end define end math ]"}} % % \index{example scheme lemma "[ bracket example scheme lemma end bracket ]"}% % \index{HeadPair @\back "[ bracket example scheme lemma end bracket ]" example scheme lemma}% % \tex{"[ math tex define example scheme lemma as " HeadPair" end define end math ]"}% % \statement{"[ math in theory example theory rule example scheme lemma says all meta a indeed all meta b indeed parenthesis meta a pair meta b end parenthesis head math equal meta a end rule end math ]"% % \footnote{"[ math pyk define example scheme lemma as "example scheme lemma" end define end math ]"}} % % \index{example rule lemma "[ bracket example rule lemma end bracket ]"}% % \index{Transitivity @\back "[ bracket example rule lemma end bracket ]" example rule lemma}% % \tex{"[ math tex define example rule lemma as " Transitivity" end define end math ]"}% % \statement{"[ math in theory example theory rule example rule lemma says all meta a indeed all meta b indeed all meta c indeed meta a math equal meta b infer meta a math equal meta c infer meta b math equal meta c end rule end math ]"% % \footnote{"[ math pyk define example rule lemma as "example rule lemma" end define end math ]"}} % % \index{Contra @\back "[ bracket contraexample lemma end bracket ]" contraexample lemma}% % \tex{"[ math tex define contraexample lemma as ""nContra" end define end math ]"}% % \statement{"[ math in theory example theory antirule contraexample lemma says true pair true math equal true end antirule end math ]"% % \footnote{"[ math pyk define contraexample lemma as "contraexample lemma" end define end math ]"}} % % \index{example theory "[ bracket example theory end bracket ]"}% % \index{T @\back "[ bracket example theory end bracket ]" example theory}% % \tex{"[ math tex define example theory as " T_E" end define end math ]"}% % \statement{"[ math theory example theory end theory end math ]"% % \footnote{"[ math pyk define example theory as "example theory" end define end math ]"}} % In the next section we define "[ math protect theory var x end theory end protect end math ]" such that "[ math protect theory example theory end theory end protect end math ]" macro expands into a definition which defines the statement aspect of "[ bracket example theory end bracket ]" to be a conjunction of "[ bracket true head math equal true end bracket ]", "[ bracket all meta a indeed all meta b indeed parenthesis meta a pair meta b end parenthesis head math equal meta a end bracket ]", "[ bracket all meta a indeed all meta b indeed all meta c indeed meta a math equal meta b infer meta a math equal meta c infer meta b math equal meta c end bracket ]", and "[ bracket true pair true math equal true infer absurdity end bracket ]", in some, arbitrary order. When "[ math protect theory var x end theory end protect end math ]" is macro expanded, it scans the codex of the page it occurs on for rules that belong to the theory "[ bracket var x end bracket ]", then forms a conjunction of the rules found, and then constructs a suitable definition for "[ bracket var x end bracket ]". \subsubsection{Rule collection} Here is the macro for collecting all rules of a theory from the codex: % \index{Theory @\back "[ math unicode start of text theory var x end theory end unicode text end math ]" theory x end theory}% % \tex{"[ math tex define theory var n end theory as " [ \mathbf{Theory\ } #1. ]" end define end math ]"}% % \display{"[ math protect define macro of theory var n end theory as lambda var t dot lambda var s dot lambda var c dot theory two var t cache var c end theory end define end protect end math ]"% % \footnote{"[ math pyk define theory var n end theory as "theory * end theory" end define end math ]"}} % % \index{Theory 2 @\back "[ bracket theory two var x cache var y end theory end bracket ]" theory two x cache y end theory}% % \tex{"[ math tex define theory two var t cache var c end theory as " theory_2( #1. , #2. )" end define end math ]"}% % \display{"[ math value define theory two var t cache var c end theory as newline let var n be var t first in newline let var s be tuple quote var n end quote pair var n comma quote var x end quote pair theory three var c name var n end theory end tuple in newline quote expand var t term quote statement define var n as var x end define end quote stack var s end expand end define end math ]"% % \footnote{"[ math pyk define theory two var t cache var c end theory as "theory two * cache * end theory" end define end math ]"}} % % \index{Theory 3 @\back "[ bracket theory three var x name var y end theory end bracket ]" theory three x name y end theory}% % \tex{"[ math tex define theory three var c name var n end theory as " theory_3( #1. , #2. )" end define end math ]"}% % \display{"[ math value define theory three var c name var n end theory as var n tagged guard newline let var r be var c assoc zero end assoc in newline theory four var c assoc var r end assoc assoc codex hook end assoc assoc var r end assoc name var n sum true end theory end define end math ]"% % \footnote{"[ math pyk define theory three var c name var n end theory as "theory three * name * end theory" end define end math ]"}} % % \index{Theory 4 @\back "[ bracket theory four var x name var y sum var z end theory end bracket ]" theory four x name var y sum z end theory}% % \tex{"[ math tex define theory four var c name var n sum var s end theory as " theory_4( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define theory four var c name var n sum var s end theory as var n tagged guard newline open if var c then var s else newline open if not var c head is cardinal then theory four var c tail name var n sum theory four var c head name var n sum var s end theory end theory else newline open if not aspect the proof aspect subcodex var c tail end aspect third term equal quote rule tactic end quote then var s else newline let var d be aspect the statement aspect subcodex var c tail end aspect third in newline open if not var d first term equal var n then var s else newline plus var d second and var s end plus end define end math ]"% % \footnote{"[ math pyk define theory four var c name var n sum var s end theory as "theory four * name * sum * end theory" end define end math ]"}} % % \index{Plus @\back "[ bracket plus var x and var y end plus end bracket ]" plus x and y end plus}% % \tex{"[ math tex define plus var a and var b end plus as " Plus( #1. , #2. )" end define end math ]"}% % \display{"[ math value define plus var a and var b end plus as tagged if var b then var a else var a rule plus var b end if end define end math ]"% % \footnote{"[ math pyk define plus var a and var b end plus as "plus * and * end plus" end define end math ]"}} % \subsubsection{Example lemmas}\label{section:ExampleLemmas} One may think of the Logiweb sequent calculus as an assembly language for expressing proofs. Proofs directly expressed in the calculus are somewhat obscure to read and write, but before we solve that problem in Section \ref{section:ProofGeneration}, we state and prove two lemmas the hard way. The first lemma proves reflexivity in the "[ bracket example theory end bracket ]" theory: % \index{sequent reflexivity "[ bracket sequent reflexivity end bracket ]"}% % \index{Reflexivity @\back "[ bracket sequent reflexivity end bracket ]" sequent reflexivity}% % \tex{"[ math tex define sequent reflexivity as " Reflexivity" end define end math ]"}% % \statement{"[ math in theory example theory lemma sequent reflexivity says all meta a indeed meta a math equal meta a end lemma end math ]"% % \footnote{"[ math pyk define sequent reflexivity as "sequent reflexivity" end define end math ]"}} % \statement{"[ math proof of sequent reflexivity reads quote example theory infer all meta a indeed parenthesis macro newline example scheme lemma init modus dereference modus at meta a at meta a cut macro newline parenthesis example rule lemma init modus dereference modus at parenthesis meta a pair meta a end parenthesis head at meta a at meta a end parenthesis modus modus end parenthesis end quote end proof end math ]"} Now that we have reflexivity available, we may use it to prove commutativity in "[ bracket example theory end bracket ]": % \index{sequent commutativity "[ bracket sequent commutativity end bracket ]"}% % \index{Commutativity @\back "[ bracket sequent commutativity end bracket ]" sequent commutativity}% % \tex{"[ math tex define sequent commutativity as " Commutativity" end define end math ]"}% % \statement{"[ math in theory example theory lemma sequent commutativity says all meta a indeed all meta b indeed meta a math equal meta b infer meta b math equal meta a end lemma end math ]"% % \footnote{"[ math pyk define sequent commutativity as "sequent commutativity" end define end math ]"}} % \statement{"[ math proof of sequent commutativity reads quote example theory infer all meta a indeed all meta b indeed meta a math equal meta b infer parenthesis macro newline sequent reflexivity init modus dereference modus at meta a cut macro newline parenthesis example rule lemma init modus dereference modus at meta a at meta b at meta a end parenthesis modus modus end parenthesis end quote end proof end math ]"} As can be seen on the diagnose hook of the present page, the proofs above are correct according the the machine check made by the verifier. \subsection{Unification}\label{section:Unification} The facilities defined in Section \ref{section:ProofGeneration} for expressing proofs in a human-tolerant style makes use of unification. Section \ref{section:Unification} implements unification. \subsubsection{Parameter terms} We shall refer to terms in which bound metavariables are replaced by cardinals as \index{term, parameter}\index{parameter term}\intro{parameter terms}. The function "[ bracket parameter term var t stack var s seed var n end parameter end bracket ]" converts an ordinary term "[ bracket var t end bracket ]" into a parameter term in which numbers are constructed from "[ bracket var n end bracket ]" using "[ bracket var b double var n end bracket ]" iteratively. When calling "[ bracket parameter term var t stack var s seed var n end parameter end bracket ]", "[ bracket var s end bracket ]" should be "[ bracket true end bracket ]". % \index{parameter term x stack y seed z end parameter "[ bracket parameter term var x stack var y seed var z end parameter end bracket ]"}% % \index{parm @\back "[ bracket parameter term var x stack var y seed var z end parameter end bracket ]" parameter term x stack y seed z end parameter}% % \tex{"[ math tex define parameter term var t stack var s seed var n end parameter as " parm(#1. ,#2. ,#3. )" end define end math ]"}% % \display{"[ math value define parameter term var t stack var s seed var n end parameter as var n tagged guard newline open if var t term root equal quote all var x indeed var y end quote then all var n indeed parameter term var t second stack parenthesis var t first pair var n end parenthesis pair var s seed true double var n end parameter else newline let var m be lookup var t stack var s default true end lookup in newline open if not var m then var m else var t root pair parameter term star var t tail stack var s seed var n end parameter end define end math ]"% % \footnote{"[ math pyk define parameter term var t stack var s seed var n end parameter as "parameter term * stack * seed * end parameter" end define end math ]"}} % % \index{parameter term star x stack y seed z end parameter "[ bracket parameter term star var x stack var y seed var z end parameter end bracket ]"}% % \index{parm @\back "[ bracket parameter term star var x stack var y seed var z end parameter end bracket ]" parameter term star x stack y seed z end parameter}% % \tex{"[ math tex define parameter term star var t stack var s seed var n end parameter as " parm^*(#1. ,#2. ,#3. )" end define end math ]"}% % \display{"[ math value define parameter term star var t stack var s seed var n end parameter as var s tagged guard var n tagged guard tagged if var t is atomic then true else parameter term var t head stack var s seed var n end parameter pair parameter term star var t tail stack var s seed var n end parameter end if end define end math ]"% % \footnote{"[ math pyk define parameter term star var t stack var s seed var n end parameter as "parameter term star * stack * seed * end parameter" end define end math ]"}} % \subsubsection{Substitutions} We shall refer to an array of parameter terms as a substitution. The following function instantiates a parameter term "[ bracket var t end bracket ]" using a substitution "[ bracket var s end bracket ]": % \index{instantiate x with y end instantiate "[ bracket instantiate var x with var y end instantiate end bracket ]"}% % \index{inst @\back "[ bracket instantiate var x with var y end instantiate end bracket ]" instantiate x with y end instantiate}% % \tex{"[ math tex define instantiate var t with var s end instantiate as " inst(#1. ,#2. )" end define end math ]"}% % \display{"[ math value define instantiate var t with var s end instantiate as tagged if var t is cardinal then instantiate var s assoc var t end assoc with var s end instantiate else var t root pair instantiate star var t tail with var s end instantiate end if end define end math ]"% % \footnote{"[ math pyk define instantiate var t with var s end instantiate as "instantiate * with * end instantiate" end define end math ]"}} % % \index{instantiate star x with y end instantiate "[ bracket instantiate star var x with var y end instantiate end bracket ]"}% % \index{inst @\back "[ bracket instantiate star var x with var y end instantiate end bracket ]" instantiate star x with y end instantiate}% % \tex{"[ math tex define instantiate star var t with var s end instantiate as " inst^*(#1. ,#2. )" end define end math ]"}% % \display{"[ math value define instantiate star var t with var s end instantiate as var s tagged guard tagged if var t is atomic then true else instantiate var t head with var s end instantiate pair instantiate star var t tail with var s end instantiate end if end define end math ]"% % \footnote{"[ math pyk define instantiate star var t with var s end instantiate as "instantiate star * with * end instantiate" end define end math ]"}} % \test{"[ math test instantiate parameter term quote all var x indeed all var y indeed var x plus var y end quote stack true seed four end parameter with true set four to quote var u end quote end set set eight to quote var v end quote end set end instantiate term equal quote all var u indeed all var v indeed var u plus var v end quote end test end math ]"} Instantiation may loop indefinitely. As an example, a substitution which maps "[ bracket meta a end bracket ]" to "[ bracket meta a pair meta a end bracket ]" will keep expanding "[ bracket meta a end bracket ]" forever. We shall say that a substitution "[ bracket var s end bracket ]" is \indexintro{circular} if there exists a term "[ bracket var t end bracket ]" for which "[ bracket instantiate var t with var s end instantiate end bracket ]" loops indefinitely. \subsubsection{Occurrence} "[ bracket occur var t in var u substitution var s end occur end bracket ]" is true if the parameter "[ bracket var t end bracket ]" occurs in "[ bracket instantiate var u with var s end instantiate end bracket ]". "[ bracket occur var t in var u substitution var s end occur end bracket ]" may loop indefinitely if the substitution "[ bracket var s end bracket ]" is circular. % \index{occur x in y substitution z end occur "[ bracket occur var x in var y substitution var z end occur end bracket ]"}% % \index{occur @\back "[ bracket occur var x in var y substitution var z end occur end bracket ]" occur x in y substitution z end occur}% % \tex{"[ math tex define occur var t in var u substitution var s end occur as " occur(#1. ,#2. ,#3. )" end define end math ]"}% % \display{"[ math value define occur var t in var u substitution var s end occur as var s tagged guard tagged if var u is cardinal then var t tagged equal var u macro or occur var t in var s assoc var u end assoc substitution var s end occur else occur star var t in var u tail substitution var s end occur end if end define end math ]"% % \footnote{"[ math pyk define occur var t in var u substitution var s end occur as "occur * in * substitution * end occur" end define end math ]"}} % % \index{occur star x in y substitution z end occur "[ bracket occur star var x in var y substitution var z end occur end bracket ]"}% % \index{occur @\back "[ bracket occur star var x in var y substitution var z end occur end bracket ]" occur star x in y substitution z end occur}% % \tex{"[ math tex define occur star var t in var u substitution var s end occur as " occur^*(#1. ,#2. ,#3. )" end define end math ]"}% % \display{"[ math value define occur star var t in var u substitution var s end occur as var t tagged guard var s tagged guard tagged if var u is atomic then false else occur var t in var u head substitution var s end occur macro or occur star var t in var u tail substitution var s end occur end if end define end math ]"% % \footnote{"[ math pyk define occur star var t in var u substitution var s end occur as "occur star * in * substitution * end occur" end define end math ]"}} % \test{math test occur eight in parameter term quote not all var x indeed var x end quote substitution true end occur end test end math} \test{math false test occur nine in parameter term quote not all var x indeed var x end quote substitution true end occur end test end math} \subsubsection{Unifications} We shall refer to the result of applying a substitution to a parameter term as an \indexintro{instance} of the term. We shall refer to a common instance of two parameter terms as a \indexintro{unification} of the terms. As an example, "[ bracket meta a pair false end bracket ]" and "[ bracket true pair meta b end bracket ]" (where "[ bracket meta a end bracket ]" and "[ bracket meta b end bracket ]" denote numbers) have exactly one unification, namely "[ bracket true pair false end bracket ]". We shall say that two terms are \indexintro{compatible} if they have at least one unification and \indexintro{incompatible} otherwise. A substitution which yields the same result when applied to two terms "[ bracket var u end bracket ]" and "[ bracket var v end bracket ]" is said to \indexintro{unify} the terms. As an example, the substitution which maps "[ bracket meta a end bracket ]" to "[ bracket true end bracket ]" and "[ bracket meta b end bracket ]" to "[ bracket false end bracket ]" unifies "[ bracket meta a pair false end bracket ]" and "[ bracket true pair meta b end bracket ]". The \index{algorithm, unification}\indexintro{unification algorithm} presented in the following takes two terms as input and returns a unifying substitution if the terms are compatible. As an example, when applied to "[ bracket meta a pair false end bracket ]" and "[ bracket true pair meta b end bracket ]", the unification algorithm returns the substitution which maps "[ bracket meta a end bracket ]" to "[ bracket true end bracket ]" and "[ bracket meta b end bracket ]" to "[ bracket false end bracket ]". There is more than one substitution which unifies "[ bracket meta a pair false end bracket ]" and "[ bracket true pair meta b end bracket ]". As an example the substitution that maps "[ bracket meta a end bracket ]" to "[ bracket true end bracket ]", "[ bracket meta b end bracket ]" to "[ bracket false end bracket ]", and "[ bracket meta c end bracket ]" to some term "[ bracket var x end bracket ]" also unifies "[ bracket meta a pair false end bracket ]" and "[ bracket true pair meta b end bracket ]". \subsubsection{Unification algorithm} The original unification algorithm by Robinson takes a set of equations (i.e.\ a set of pairs of parameter terms) as input and unifies all the pairs. In contrast, "[ bracket unify var t with var u substitution var s end unify end bracket ]" defined below adds the result of unifying "[ bracket var t end bracket ]" and "[ bracket var u end bracket ]" to the substitution "[ bracket var s end bracket ]". To unify a set of equations one should start with the empty substitution "[ bracket true end bracket ]" and call "[ bracket unify var t with var u substitution var s end unify end bracket ]" once for each equation. "[ bracket unify var t with var u substitution var s end unify end bracket ]" extends the substitution "[ bracket var s end bracket ]" to a substitution that unifies "[ bracket var t end bracket ]" with "[ bracket var u end bracket ]" if such a substitution exists and returns "[ bracket zero end bracket ]" otherwise. In particular, "[ bracket unify var t with var u substitution var s end unify end bracket ]" returns zero if "[ bracket var s end bracket ]" equals zero since in that case there is no substitution to extend. "[ bracket unify var t with var u substitution var s end unify end bracket ]" calls to auxiliary functions, "[ bracket unify two var t with var u substitution var s end unify end bracket ]" and "[ bracket unify star var t with var u substitution var s end unify end bracket ]". "[ bracket unify two var t with var u substitution var s end unify end bracket ]" does the same as "[ bracket unify var t with var u substitution var s end unify end bracket ]" but only covers the special case where "[ bracket var t end bracket ]" is a parameter. "[ bracket unify star var t with var u substitution var s end unify end bracket ]" unifies two lists "[ bracket var t end bracket ]" and "[ bracket var u end bracket ]" of parameter terms. "[ bracket unify var t with var u substitution var s end unify end bracket ]" errors out if "[ bracket var s tagged equal zero end bracket ]", calls "[ bracket unify two x with x substitution x end unify end bracket ]" if "[ bracket var t end bracket ]" or "[ bracket var u end bracket ]" happens to be a parameter, and calls "[ bracket unify star x with x substitution x end unify end bracket ]" otherwise: % \index{unify x with y substitution z end unify "[ bracket unify var x with var y substitution var z end unify end bracket ]"}% % \index{unify @\back "[ bracket unify var x with var y substitution var z end unify end bracket ]" unify x with y substitution z end unify}% % \tex{"[ math tex define unify var t with var u substitution var s end unify as " unify(#1. =#2. ,#3. )" end define end math ]"}% % \display{"[ math value define unify var t with var u substitution var s end unify as var t tagged guard var u tagged guard newline open if var s is cardinal then var s else newline open if var t is cardinal then unify two var t with var u substitution var s end unify else newline open if var u is cardinal then unify two var u with var t substitution var s end unify else newline open if var t term root equal var u then unify star var t tail with var u tail substitution var s end unify else zero end define end math ]"% % \footnote{"[ math pyk define unify var t with var u substitution var s end unify as "unify * with * substitution * end unify" end define end math ]"}} % "[ bracket unify star var t with var u substitution var s end unify end bracket ]" iterates "[ bracket unify var t with var u substitution var s end unify end bracket ]"; it depends on the fact that "[ bracket unify var t with var u substitution var s end unify end bracket ]" equals zero if "[ bracket var s end bracket ]" equals zero so that failure to find a unification propagates. % \index{unify star x with y substitution z end unify "[ bracket unify star var x with var y substitution var z end unify end bracket ]"}% % \index{unify @\back "[ bracket unify star var x with var y substitution var z end unify end bracket ]" unify star x with y substitution z end unify}% % \tex{"[ math tex define unify star var t with var u substitution var s end unify as " unify^*(#1. =#2. ,#3. )" end define end math ]"}% % \display{"[ math value define unify star var t with var u substitution var s end unify as var u tagged guard tagged if var t is atomic then var s else unify star var t tail with var u tail substitution unify var t head with var u head substitution var s end unify end unify end if end define end math ]"% % \footnote{"[ math pyk define unify star var t with var u substitution var s end unify as "unify star * with * substitution * end unify" end define end math ]"}} % "[ bracket unify two var t with var u substitution var s end unify end bracket ]" extends the substitution "[ bracket var s end bracket ]" with the result of unifying the parameter "[ bracket var t end bracket ]" with the parameter term "[ bracket var u end bracket ]". "[ bracket var s end bracket ]" is assumed to be a genuine substituion (i.e.\ not zero). Furthermore, "[ bracket var s end bracket ]" is assumed to be non-circular. "[ bracket unify two var t with var u substitution var s end unify end bracket ]" first tests "[ bracket var t end bracket ]" and "[ bracket var u end bracket ]" for equality. If they are equal, they are already unified and "[ bracket var s end bracket ]" is returned. Otherwise, if "[ bracket var s end bracket ]" already associates the parameter "[ bracket var t end bracket ]" with a term, then "[ bracket unify two var t with var u substitution var s end unify end bracket ]" unifies "[ bracket var u end bracket ]" with that term. Otherwise, "[ bracket unify two var t with var u substitution var s end unify end bracket ]" extends the substitution "[ bracket var s end bracket ]" with an association from "[ bracket var t end bracket ]" to "[ bracket var u end bracket ]". If "[ bracket occur var t in var u substitution var s end occur end bracket ]" is true, however, such an association would create a circular substitution. In that case no unification exists and "[ bracket unify two var t with var u substitution var s end unify end bracket ]" returns zero: % \index{unify two x with y substitution z end unify "[ bracket unify two var x with var y substitution var z end unify end bracket ]"}% % \index{unify @\back "[ bracket unify two var x with var y substitution var z end unify end bracket ]" unify two x with y substitution z end unify}% % \tex{"[ math tex define unify two var t with var u substitution var s end unify as " unify_2(#1. =#2. ,#3. )" end define end math ]"}% % \display{"[ math value define unify two var t with var u substitution var s end unify as newline open if var t tagged equal var u then var s else newline let var t prime be var s assoc var t end assoc in newline open if not var t prime then unify var t prime with var u substitution var s end unify else newline open if occur var t in var u substitution var s end occur then zero else var s set var t to var u end set end define end math ]"% % \footnote{"[ math pyk define unify two var t with var u substitution var s end unify as "unify two * with * substitution * end unify" end define end math ]"}} % \test{"[ math test unify quote two end quote with quote two end quote substitution true end unify end test end math ]"} \test{"[ math test unify quote two end quote with quote three end quote substitution true end unify tagged equal zero end test end math ]"} \test{"[ math test unify quote two plus three end quote with quote two plus three end quote substitution true end unify end test end math ]"} \test{"[ math test unify quote two plus three end quote with quote two plus four end quote substitution true end unify tagged equal zero end test end math ]"} \test{"[ math test unify quote two end quote with three substitution true end unify assoc three end assoc term equal quote two end quote end test end math ]"} \test{"[ math test unify three with quote two end quote substitution true end unify assoc three end assoc term equal quote two end quote end test end math ]"} \test{"[ math test unify tuple quote var x plus var y end quote root comma one comma quote three end quote end tuple with quote two plus three end quote substitution true end unify assoc one end assoc term equal quote two end quote end test end math ]"} \test{"[ math test unify tuple quote var x plus var y end quote root comma one comma quote three end quote end tuple with tuple quote var x plus var y end quote root comma quote two end quote comma two end tuple substitution true end unify assoc one end assoc term equal quote two end quote end test end math ]"} \test{"[ math test unify parameter term quote meta a plus three end quote stack tuple quote meta a end quote pair one end tuple seed one end parameter with parameter term quote two plus meta b end quote stack tuple quote meta b end quote pair two end tuple seed one end parameter substitution true end unify assoc one end assoc term equal quote two end quote end test end math ]"} \test{"[ math test unify parameter term quote meta a plus three end quote stack tuple quote meta a end quote pair one end tuple seed one end parameter with parameter term quote two plus meta b end quote stack tuple quote meta b end quote pair two end tuple seed one end parameter substitution true end unify assoc two end assoc term equal quote three end quote end test end math ]"} \test{"[ math test instantiate parameter term quote meta a plus meta b end quote stack tuple quote meta a end quote pair one comma quote meta b end quote pair two end tuple seed one end parameter with unify parameter term quote meta a plus three end quote stack tuple quote meta a end quote pair one end tuple seed one end parameter with parameter term quote two plus meta b end quote stack tuple quote meta b end quote pair two end tuple seed one end parameter substitution true end unify end instantiate term equal quote two plus three end quote end test end math ]"} \subsection{Proof generation}\label{section:ProofGeneration} \subsubsection{Proof tactics} Counted in sequent operators, proofs typically comprise a small amount of original thought and a lot of trivial derivations. Frequently, trivial derivations can be generated by computer programs. Such programs are typically called \index{tactic, proof}\intro{tactics} or \index{proof tactic}\intro{proof tactics} \cite{Gordon79}. To support proof tactics, we introduce a \indexintro{tactic aspect} for defining them and a \indexintro{proof expander} for evaluating them. The proof evaluator evaluates proof tactics and generates sequent proofs, which the proof evaluator may then evaluate to sequents. The proof expander is itself a tactic since it generates proofs. The proof expander is a value defined tactic like the rule lemma tactic defined previously. But the proof expander is a particularly general tactic which brings life to tactics that are defined using the ``tactic aspect'' which is introduced later. \subsubsection{Medium level proofs}\label{section:MediumLevelProofs} The proof tactics and the proof expander defined later can translate medium level proofs like those below to Logiweb sequent calculus proofs like those in Section \ref{section:ExampleLemmas}. Actually, the proofs below exactly translate to the proofs in Section \ref{section:ExampleLemmas}. We start out proving reflexivity: % \index{tactic reflexivity "[ bracket tactic reflexivity end bracket ]"}% % \index{Reflexivity @\back "[ bracket tactic reflexivity end bracket ]" tactic reflexivity}% % \tex{"[ math tex define tactic reflexivity as " Reflexivity_1" end define end math ]"}% % \statement{"[ math in theory example theory lemma tactic reflexivity says all meta a indeed meta a math equal meta a end lemma end math ]"% % \footnote{"[ math pyk define tactic reflexivity as "tactic reflexivity" end define end math ]"}} % \statement{"[ math example theory proof of tactic reflexivity reads arbitrary meta a end line line ell b because example scheme lemma indeed parenthesis meta a pair meta a end parenthesis head math equal meta a end line because example rule lemma modus ponens ell b modus ponens ell b indeed meta a math equal meta a qed end math ]"} In the proof above, the first line declares that "[ bracket meta a end bracket ]" denotes an arbitrary term. The second line uses "[ bracket example scheme lemma end bracket ]" to prove "[ bracket parenthesis meta a pair meta a end parenthesis head math equal meta a end bracket ]". In Section \ref{section:ExampleLemmas}, that statement is proved by "[ bracket example scheme lemma init modus dereference modus at meta a at meta a end bracket ]". As we shall see, the tactic introduced in Section \ref{section:TheConclusionTactic} adds the "[ bracket x init modus dereference modus end bracket ]" formula for referencing lemmas. That tactic also adds the "[ bracket "\cdots" at meta a at meta a end bracket ]" for instantiating the meta-quantifiers in "[ bracket example scheme lemma end bracket ]". The tactic uses unification and "[ bracket "\cdots" conclude parenthesis meta a pair meta a end parenthesis head math equal meta a end bracket ]" to decide that both meta-quantifiers should be instantiated to an "[ bracket meta a end bracket ]". The third line uses "[ bracket example rule lemma end bracket ]" and the meta-modus-ponens operator "[ bracket x modus ponens x end bracket ]" to prove "[ bracket meta a math equal meta a end bracket ]". The tactic defined in Section \ref{section:TheConclusionTactic} translates a meta-modus-ponens into a modus operation followed by a cut (c.f.\ the expanded proof in Section \ref{section:ExampleLemmas}). The tactic can expand modus ponens "[ bracket x modus ponens x end bracket ]" and modus probans "[ bracket x modus probans x end bracket ]". Modus ponens says that if "[ bracket meta a end bracket ]" is proved and "[ bracket meta a end bracket ]" infers "[ bracket meta b end bracket ]" then we may conclude "[ bracket meta b end bracket ]". Modus probans (``probans'' for ``approve'') says that if "[ bracket meta a end bracket ]" is known to evaluate to "[ bracket true end bracket ]" and the side condition "[ bracket meta a end bracket ]" endorses "[ bracket meta b end bracket ]" then we may conclude "[ bracket meta b end bracket ]". The tactic eliminates side conditions using modus probans when told to do so using "[ bracket x modus probans x end bracket ]" and otherwise eliminates them using the "[ bracket x verify end bracket ]" sequent operation which actually evaluates the side condition. Modus probans is useful in situations where a lemma assumes some side condition to hold. Assumed side-conditions are introduced in proofs using a Side-condition operation which is similar to the Premise used in Line 3 of the proof of "[ bracket tactic commutativity end bracket ]" stated in a moment. Line 3 above contains two references to Line 2. Each reference expands into the conclusion of Line 2 at macro expansion time. Hence, Line 3 reads "[ bracket example rule lemma modus ponens parenthesis meta a pair meta a end parenthesis head math equal meta a modus ponens parenthesis meta a pair meta a end parenthesis head math equal meta a conclude meta a math equal meta a end bracket ]" when the proof tactic is invoked. Now let us turn to the proof of "[ bracket tactic commutativity end bracket ]": % \index{tactic commutativity "[ bracket tactic commutativity end bracket ]"}% % \index{commutativity @\back "[ bracket tactic commutativity end bracket ]" tactic commutativity}% % \tex{"[ math tex define tactic commutativity as " Commutativity_1" end define end math ]"}% % \statement{"[ math in theory example theory lemma tactic commutativity says all meta a indeed all meta b indeed meta a math equal meta b infer meta b math equal meta a end lemma end math ]"% % \footnote{"[ math pyk define tactic commutativity as "tactic commutativity" end define end math ]"}} % \statement{"[ math example theory proof of tactic commutativity reads arbitrary meta a end line arbitrary meta b end line line ell a premise meta a math equal meta b end line line ell b because tactic reflexivity indeed meta a math equal meta a end line because example rule lemma modus ponens ell a modus ponens ell b indeed meta b math equal meta a qed end math ]"} The proof above only contains one new thing: Line 3 assumes "[ bracket meta a math equal meta b end bracket ]". \subsubsection{The ``tactic'' aspect} We now return to the actual implementation of proof tactics and the proof expander. We make the "[ bracket the tactic aspect end bracket ]" aspect self-evaluating and use "[ bracket tactic end bracket ]" to denote it: % \index{tactic @\back "[ bracket the tactic aspect end bracket ]" the tactic aspect}% % \index{the tactic aspect "[ bracket the tactic aspect end bracket ]"}% % \tex{"[ math tex define the tactic aspect as " {<}tactic{>}" end define end math ]"}% % \display{"[ math value define the tactic aspect as quote the tactic aspect end quote end define end math ]"% % \footnote{"[ math pyk define the tactic aspect as "the tactic aspect" end define end math ]"}} % % \index{tactic "[ bracket tactic end bracket ]"}% % \tex{"[ math tex define tactic as " tactic" end define end math ]"}% % \display{"[ math message define tactic as the tactic aspect end define end math ]"% % \footnote{"[ math pyk define tactic as "tactic" end define end math ]"}} % For convenience, we define a construct for making tactic definitions: \index{tactic define x as y end define "[ math unicode start of text tactic define var x as var y end define end unicode text end math ]"}% % \index{tactic: "[ math unicode start of text tactic define var x as var y end define end unicode text end math ]"}% % \tex{"[ math tex define tactic define var x as var y end define as " [#1/tex name/tex. \stackrel {tactic}{=}#2. ]" end define end math ]"}% % \display{% "[ math macro define tactic define var x as var y end define as define tactic of protect var x end protect as var y end define end define end math ]"% % \footnote{"[ math pyk define tactic define var x as var y end define as "tactic define * as * end define" end define end math ]"}} \subsubsection{The proof expander} The proof expander "[ bracket proof expand var t state var s cache var c end expand end bracket ]" proof expands the term "[ bracket var t end bracket ]" for the \indexintro{proof state} "[ bracket var s end bracket ]" and the cache "[ bracket var c end bracket ]" and returns the result as a semitagged map. The untagged version "[ bracket map untag proof expand var t state var s cache var c end expand end untag end bracket ]" is the expansion itself. The proof expander "[ bracket proof expand var t state var s cache var c end expand end bracket ]" differs from the macro expander "[ bracket expand var t state var s cache var c end expand end bracket ]" in that it has no special treatment for page symbols and in that it uses the "[ bracket tactic end bracket ]" aspect instead of the "[ bracket macro end bracket ]" aspect. When proofs are expanded, they are first macro expanded and then proof expanded. Macro expansion is done iteratively until the codex reaches a fixed point whereas proof expansion is done only once. Furthermore, the result of macro expansion is kept in the codex whereas the result of proof expansion is discarded as soon as a proof is checked. Hence, proof expansion is a momentary burden to the computers memory whereas macro expansion is chronic. The definition of "[ bracket proof expand var t state var s cache var c end expand end bracket ]" is almost identical to that of "[ bracket expand var t state var s cache var c end expand end bracket ]". But it is easier to express since we can use macros like the `let' macro when defining proof expansion. For obvious reasons, macros cannot be used when defining the notion of macro expansion. The definition of "[ bracket proof expand var t state var s cache var c end expand end bracket ]" reads: % \index{p: "[ bracket proof expand var x state var y cache var z end expand end bracket ]" proof expand x state y cache z end expand}% % \tex{"[ math tex define proof expand var t state var s cache var c end expand as " {\cal P}( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define proof expand var t state var s cache var c end expand as var s tagged guard newline let var d be aspect the tactic aspect term var t cache var c end aspect in newline open if var d then var t head pair proof expand list var t tail state var s cache var c end expand else newline normalizing untag eval var d third stack true cache var c end eval tagged apply var t tagged apply var s tagged apply var c end untag end define end math ]"% % \footnote{"[ math pyk define proof expand var t state var s cache var c end expand as "proof expand * state * cache * end expand" end define end math ]"}} % % \index{p: "[ bracket proof expand list var x state var y cache var z end expand end bracket ]" proof expand list x state y cache z end expand}% % \tex{"[ math tex define proof expand list var t state var s cache var c end expand as " {\cal P}^*( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define proof expand list var t state var s cache var c end expand as var s tagged guard var c tagged guard tagged if var t then true else proof expand var t head state var s cache var c end expand pair proof expand list var t tail state var s cache var c end expand end if end define end math ]"% % \footnote{"[ math pyk define proof expand list var t state var s cache var c end expand as "proof expand list * state * cache * end expand" end define end math ]"}} % \subsubsection{The initial proof state} Proof states have exactly the same format as macro states. The \index{proof state, initial}\indexintro{initial proof state} "[ bracket proof state end bracket ]" is useful for passing as the second parameter to "[ bracket proof expand var t state var s cache var c end expand end bracket ]". "[ bracket proof state end bracket ]" is a pair whose head is the proof expander itself and whose tail is left blank. The definition of "[ bracket proof state end bracket ]" reads: % \index{p: "[ bracket proof state end bracket ]" proof state}% % \tex{"[ math tex define proof state as " p_0" end define end math ]"}% % \display{"[ math define value of proof state as map tag lambda var t dot lambda var s dot lambda var c dot proof expand var t state var s cache var c end expand end tag pair true end define end math ]"% % \footnote{"[ math pyk define proof state as "proof state" end define end math ]"}} % The function "[ bracket state expand var t state var s cache var c end expand end bracket ]" defined previously macro expands the term "[ bracket var t end bracket ]" using the macro expander embedded in the macro state "[ bracket var s end bracket ]" using the cache "[ bracket var c end bracket ]". Since proof states have exactly the same syntax and semantics as macro states, we shall take the liberty to use "[ bracket state expand var t state var s cache var c end expand end bracket ]" for proof states also. \subsubsection{The conclusion tactic}\label{section:TheConclusionTactic} The \index{tactic, conclusion}\indexintro{conclusion tactic} "[ bracket var x conclude var y end bracket ]" constructs a proof of "[ bracket var y end bracket ]" from the partial proof "[ bracket var x end bracket ]" as described in Section \ref{section:MediumLevelProofs}. Among other, the tactic tactic expands modus ponens "[ bracket var x modus ponens var y end bracket ]" and modus probans "[ bracket var x modus probans var y end bracket ]" which we make self-evaluating: % \index{\alpha x modus ponens y @\back "[ bracket var x modus ponens var y end bracket ]" x modus ponens y}% % \tex{"[ math tex define var x modus ponens var y as "#1. \rhd #2." end define end math ]"}% % \display{"[ math value define var x modus ponens var y as tuple quote var x modus ponens var y end quote root comma var x comma var y end tuple end define end math ]"% % \footnote{"[ math pyk define var x modus ponens var y as "* modus ponens *" end define end math ]"}} % % \index{\alpha x modus probans y @\back "[ bracket var x modus probans var y end bracket ]" x modus probans y}% % \tex{"[ math tex define var x modus probans var y as "#1. \mathrel {\makebox [0mm][l]{$\rhd $}\,{\rhd }} #2." end define end math ]"}% % \display{"[ math value define var x modus probans var y as tuple quote var x modus probans var y end quote root comma var x comma var y end tuple end define end math ]"% % \footnote{"[ math pyk define var x modus probans var y as "* modus probans *" end define end math ]"}} % The conclusion tactic is defined thus: % \index{\alpha x conclude y @\back "[ bracket var x conclude var y end bracket ]" x conclude y}% % \tex{"[ math tex define var x conclude var y as "#1. \gg #2." end define end math ]"}% % \display{"[ math tactic define var x conclude var y as lambda var t dot lambda var s dot lambda var c dot conclude one var t cache var c end conclude end define end math ]"% % \footnote{"[ math pyk define var x conclude var y as "* conclude *" end define end math ]"}} % % \index{conclude @\back "[ bracket conclude one var x cache var y end conclude end bracket ]" conclude one x cache y end conclude}% % \tex{"[ math tex define conclude one var t cache var c end conclude as " conclude_1 ( #1. , #2. )" end define end math ]"}% % \display{"[ math value define conclude one var t cache var c end conclude as newline let var r be conclude two var t first proves var t second cache var c end conclude in newline open if var r is cardinal then error "Unification failed" term var t end error else var r end define end math ]"% % \footnote{"[ math pyk define conclude one var t cache var c end conclude as "conclude one * cache * end conclude" end define end math ]"}} % % \index{conclude @\back "[ bracket conclude two var x proves var y cache var z end conclude end bracket ]" conclude two x proves y cache z end conclude}% % \tex{"[ math tex define conclude two var a proves var t cache var c end conclude as " conclude_2 ( #1. , #2. , #3. )" end define end math ]"}% % \display{"[ math value define conclude two var a proves var t cache var c end conclude as var t tagged guard newline open if var a term root equal quote var x modus ponens var y end quote then conclude two var a first proves var a color var t modus ponens var a second end color cache var c end conclude else newline open if var a term root equal quote var x modus probans var y end quote then conclude two var a first proves var a color var t modus probans var a second end color cache var c end conclude else newline open if var a term root equal quote var x at var y end quote then conclude two var a first proves var a color var t at var a second end color cache var c end conclude else newline open if aspect the proof aspect term var a cache var c end aspect then error "Lemma expected" term var a end error else newline let var d be aspect the statement aspect term var a cache var c end aspect in newline conclude three var a color conclude four var a init modus dereference modus lemma var d third second end conclude end color proves var t lemma parameter term var d third second stack true seed one end parameter substitution true end conclude end define end math ]"% % \footnote{"[ math pyk define conclude two var a proves var t cache var c end conclude as "conclude two * proves * cache * end conclude" end define end math ]"}} % % \index{conclude @\back "[ bracket conclude three var x proves var y lemma var z substitution var a end conclude end bracket ]" conclude three x proves y lemma z substitution a end conclude}% % \tex{"[ math tex define conclude three var a proves var t lemma var l substitution var s end conclude as " conclude_3 ( #1. , #2. , #3. , #4. )" end define end math ]"}% % \display{"[ math value define conclude three var a proves var t lemma var l substitution var s end conclude as var a tagged guard var t tagged guard var l tagged guard var s tagged guard newline open if var l term root equal quote var x infer var y end quote then newline var t term root equal quote var x modus ponens var y end quote select conclude three {var t color} var a modus {end color} proves var t first lemma var l second substitution unify var l first with var t second substitution var s end unify end conclude else conclude three {var a color} var a modus {end color} proves var t lemma var l second substitution var s end conclude end select else newline open if var l term root equal quote var x endorse var y end quote then newline var t term root equal quote var x modus probans var y end quote select conclude three {var t color} var a modus {end color} proves var t first lemma var l second substitution unify var l first with var t second substitution var s end unify end conclude else conclude three {var a color} var a verify {end color} proves var t lemma var l second substitution var s end conclude end select else newline open if var l term root equal quote all var x indeed var y end quote then newline var t term root equal quote var x at var y end quote select conclude three {var t color} var a at var t second {end color} proves var t first lemma var l second substitution unify var l first with var t second substitution var s end unify end conclude else conclude three {var a color} var a at var l first {end color} proves var t lemma var l second substitution var s end conclude end select else newline let var s be unify var l with var t substitution var s end unify in newline open if var s is cardinal then var s else newline instantiate var a with var s end instantiate end define end math ]"% % \footnote{"[ math pyk define conclude three var a proves var t lemma var l substitution var s end conclude as "conclude three * proves * lemma * substitution * end conclude" end define end math ]"}} % % \index{conclude @\back "[ bracket conclude four var x lemma var y end conclude end bracket ]" conclude four x lemma y end conclude}% % \tex{"[ math tex define conclude four var a lemma var l end conclude as " conclude_4 ( #1. , #2. )" end define end math ]"}% % \display{"[ math value define conclude four var a lemma var l end conclude as var a tagged guard var l tagged guard newline open if not var l term root equal quote all var x indeed var y end quote then var a else newline let var v be tuple quote metavar x end metavar end quote root comma var l first end tuple in all var v indeed conclude four var a at var v lemma var l second end conclude end define end math ]"% % \footnote{"[ math pyk define conclude four var a lemma var l end conclude as "conclude four * lemma * end conclude" end define end math ]"}} % \subsubsection{Proof constructors} The following macros make it easy to construct medium level proofs: % \index{\alpha x proof of y reads z @\back "[ bracket unicode start of text var x proof of var y reads var z end unicode text end bracket ]" x proof of y reads z}% % \index{proof: "[ bracket unicode start of text var x proof of var y reads var z end unicode text end bracket ]" x proof of y reads z}% % \tex{"[ math tex define var t proof of var s reads var p as " \if\relax\csname lgwprooflinep\endcsname \def\lgwprooflinep{x} \newcount\lgwproofline \fi \begingroup \def\insideproof{x} \lgwproofline=0 #1. \mathbf {\ proof\ of\ } #2. \colon #3. \gdef\lgwella{\relax} \gdef\lgwellb{\relax} \gdef\lgwellc{\relax} \gdef\lgwelld{\relax} \gdef\lgwelle{\relax} \gdef\lgwellf{\relax} \gdef\lgwellg{\relax} \gdef\lgwellh{\relax} \gdef\lgwelli{\relax} \gdef\lgwellj{\relax} \gdef\lgwellk{\relax} \gdef\lgwelll{\relax} \gdef\lgwellm{\relax} \gdef\lgwelln{\relax} \gdef\lgwello{\relax} \gdef\lgwellp{\relax} \gdef\lgwellq{\relax} \gdef\lgwellr{\relax} \gdef\lgwells{\relax} \gdef\lgwellt{\relax} \gdef\lgwellu{\relax} \gdef\lgwellv{\relax} \gdef\lgwellw{\relax} \gdef\lgwellx{\relax} \gdef\lgwelly{\relax} \gdef\lgwellz{\relax} \gdef\lgwellbiga{\relax} \gdef\lgwellbigb{\relax} \gdef\lgwellbigc{\relax} \gdef\lgwellbigd{\relax} \gdef\lgwellbige{\relax} \gdef\lgwellbigf{\relax} \gdef\lgwellbigg{\relax} \gdef\lgwellbigh{\relax} \gdef\lgwellbigi{\relax} \gdef\lgwellbigj{\relax} \gdef\lgwellbigk{\relax} \gdef\lgwellbigl{\relax} \gdef\lgwellbigm{\relax} \gdef\lgwellbign{\relax} \gdef\lgwellbigo{\relax} \gdef\lgwellbigp{\relax} \gdef\lgwellbigq{\relax} \gdef\lgwellbigr{\relax} \gdef\lgwellbigs{\relax} \gdef\lgwellbigt{\relax} \gdef\lgwellbigu{\relax} \gdef\lgwellbigv{\relax} \gdef\lgwellbigw{\relax} \gdef\lgwellbigx{\relax} \gdef\lgwellbigy{\relax} \gdef\lgwellbigz{\relax} \endgroup " end define end math ]"}% % \tex{"[ math tex name define var t proof of var s reads var p as "#1. \mathbf{\ proof\ of\ } #2. : #3." end define end math ]"} % \display{"[ math macro define var t proof of var s reads var p as proof of var s reads lambda var c dot lambda var x dot proof expand quote var t infer var p end quote state proof state cache var c end expand end proof end define end math ]"% % \footnote{"[ math pyk define var t proof of var l reads var p as "* proof of * reads *" end define end math ]"}} % % \index{Line @\back "[ bracket text line var x because var y indeed var z end line var a end text end bracket ]" line x because y indeed z end line a}% % \index{line x because y indeed z end line a "[ bracket text line var x because var y indeed var z end line var a end text end bracket ]"}% % \tex{"[ math tex define line var l because var a indeed var i end line var p as " \newline \makebox [0.1\textwidth]{}% \parbox [b]{0.4\textwidth }{\raggedright \setlength {\parindent }{-0.1\textwidth }% \makebox [0.1\textwidth ][l]{$#1. $:}$#2. {}\gg {}$}\quad \parbox [t]{0.4\textwidth }{$#3. $\hfill \makebox [0mm][l]{\quad ;}}#4." end define end math ]"}% % \tex{"[ math tex name define line var l because var a indeed var i end line var p as " Line \, #1. : #2. \gg #3. ; #4." end define end math ]"}% % \display{"[ math macro define line var l because var a indeed var i end line var p as parenthesis var a conclude var i cut let var l abbreviate var i in var p end parenthesis end define end math ]"% % \footnote{"[ math pyk define line var l because var a indeed var i end line var p as "line * because * indeed * end line *" end define end math ]"}} % % \index{Last line @\back "[ bracket text because var x indeed var y qed end text end bracket ]" because x indeed y qed}% % \index{because x indeed y qed "[ bracket text because var x indeed var y qed end text end bracket ]"}% % \tex{"[ math tex define because var a indeed var i qed as " \newline \makebox [0.1\textwidth]{}% \parbox [b]{0.4\textwidth }{\raggedright \setlength {\parindent }{-0.1\textwidth }% \makebox [0.1\textwidth ][l]{$ \if \relax \csname lgwprooflinep\endcsname L_? \else \global \advance \lgwproofline by 1 L\ifnum \lgwproofline <10 0\fi \number \lgwproofline \fi $:}$#1. {}\gg {}$}\quad \parbox [t]{0.4\textwidth }{$#2. $\hfill \makebox [0mm][l]{\quad \makebox[0mm]{$\Box$}}}" end define end math ]"}% % \tex{"[ math tex name define because var a indeed var i qed as " Last\ line \, #1. \gg #2. \,\Box" end define end math ]"}% % \display{"[ math macro define because var a indeed var i qed as parenthesis var a conclude var i end parenthesis end define end math ]"% % \footnote{"[ math pyk define because var a indeed var i qed as "because * indeed * qed" end define end math ]"}} % % \index{premise @\back "[ bracket text line var x premise var y end line var z end text end bracket ]" line x premise y end line z}% % \index{line x premise y end line z "[ bracket text line var x premise var y end line var z end text end bracket ]"}% % \tex{"[ math tex define line var l premise var i end line var p as " \newline \makebox [0.1\textwidth ][l]{$#1. $:}\makebox [0.4\textwidth ][l]{$Premise{}\gg{}$}\quad \parbox [t]{0.4\textwidth }{$#2. $\hfill \makebox [0mm][l]{\quad ;}}#3." end define end math ]"}% % \tex{"[ math tex name define line var l premise var i end line var p as " Line \, #1. : Premise \gg #2. ;#3." end define end math ]"}% % \display{"[ math macro define line var l premise var i end line var p as parenthesis var i infer let var l abbreviate var i in var p end parenthesis end define end math ]"% % \footnote{"[ math pyk define line var l premise var i end line var p as "line * premise * end line *" end define end math ]"}} % % \index{side condition @\back "[ bracket text line var x side condition var y end line var z end text end bracket ]" line x side condition y end line z}% % \index{line x side condition y end line z "[ bracket text line var x side condition var y end line var z end text end bracket ]"}% % \tex{"[ math tex define line var l side condition var i end line var p as " \newline \makebox [0.1\textwidth ][l]{$#1. $:}\makebox [0.4\textwidth ][l]{% $\mbox{Side-condition}{}\gg{}$}\quad \parbox [t]{0.4\textwidth }{$#2. $\hfill \makebox [0mm][l]{\quad ;}}#3." end define end math ]"}% % \tex{"[ math tex name define line var l side condition var i end line var p as " Line \, #1. : \mbox{Side-condition} \gg #2. ; #3." end define end math ]"}% % \display{"[ math macro define line var l side condition var i end line var p as parenthesis var i endorse let var l abbreviate var i in var p end parenthesis end define end math ]"% % \footnote{"[ math pyk define line var l side condition var i end line var p as "line * side condition * end line *" end define end math ]"}} % % \index{arbitrary @\back "[ bracket text arbitrary var y end line var z end text end bracket ]" arbitrary x end line y}% % \index{arbitrary x end line y "[ bracket text arbitrary var x end line var y end text end bracket ]"}% % \tex{"[ math tex define arbitrary var i end line var p as " \newline \makebox [0.1\textwidth ][l]{$ \if \relax \csname lgwprooflinep\endcsname L_? \else \global \advance \lgwproofline by 1 L\ifnum \lgwproofline <10 0\fi \number \lgwproofline \fi $:}\makebox [0.4\textwidth ][l]{$Arbitrary{}\gg{}$}\quad \parbox [t]{0.4\textwidth }{$#1. $\hfill \makebox [0mm][l]{\quad ;}}#2." end define end math ]"}% % \tex{"[ math tex name define arbitrary var i end line var p as " Arbitrary \gg #1. ;#2." end define end math ]"}% % \display{"[ math macro define arbitrary var i end line var p as parenthesis all var i indeed var p end parenthesis end define end math ]"% % \footnote{"[ math pyk define arbitrary var i end line var p as "arbitrary * end line *" end define end math ]"}} % % \index{local @\back "[ bracket text locally define var x as var y end line var z end text end bracket ]" locally define x as y end line z}% % \index{locally define x as y end line z "[ bracket text locally define var x as var y end line var z end text end bracket ]"}% % \tex{"[ math tex define locally define var a as var i end line var p as " \newline\makebox[0.1\textwidth][l]{$ \if \relax \csname lgwprooflinep\endcsname L_? \else \global \advance \lgwproofline by 1 L\ifnum \lgwproofline <10 0\fi \number \lgwproofline \fi $:}% \makebox[0.4\textwidth][l]{$Local{}\gg{}$}% \quad% \parbox[t]{0.4\textwidth}{$#1. = #2. $\hfill\makebox[0mm][l]{\quad ;}}#3." end define end math ]"}% % \tex{"[ math tex name define locally define var a as var i end line var p as " Local \gg #1. = #2. ; #3." end define end math ]"}% % \display{"[ math macro define locally define var a as var i end line var p as parenthesis let var a abbreviate var i in var p end parenthesis end define end math ]"% % \footnote{"[ math pyk define locally define var u as var v end line var p as "locally define * as * end line *" end define end math ]"}} % Some of the constructs look different when used in proofs. As an example, the ``Arbitrary'' construct above gets a line number when used in a proof (or, more precisely, when typeset using the tex aspect instead of the tex name aspect). Line numbers in proofs are generated automatically. As an example, one may write \display{line ell a because tactic reflexivity indeed meta a math equal meta a end line ...} in a pyk source text to get a numbered proof line saying "[ bracket tactic reflexivity conclude meta a math equal meta a end bracket ]". The line number is assigned automatically, and afterwards references to ``ell a'' will refer to that line number. \appendix \section{Constructs} \subsection{Pyk definitions} This appendix contains pyk definitions which the author has not yet turned into footnotes. For convenience, we introduce a variable named "[ bracket x end bracket ]" which we use in pyk, \TeX, and priority definitions where parameter names are ignored. "[ math pyk define x as "x" end define end math ]" "[ math pyk define x apply x as "* apply *" end define end math ]" "[ math pyk define x tagged apply x as "* tagged apply *" end define end math ]" "[ math pyk define lambda x dot x as "lambda * dot *" end define end math ]" "[ math pyk define tagging x as "tagging *" end define end math ]" "[ math pyk define true as "true" end define end math ]" "[ math pyk define if x then x else x end if as "if * then * else * end if" end define end math ]" "[ math pyk define value as "value" end define end math ]" "[ math pyk define claim as "claim" end define end math ]" "[ math pyk define introduce x of x as x end introduce as "introduce * of * as * end introduce" end define end math ]" "[ math pyk define bottom as "bottom" end define end math ]" "[ math pyk define function f of x end function as "function f of * end function" end define end math ]" "[ math pyk define identity x end identity as "identity * end identity" end define end math ]" "[ math pyk define false as "false" end define end math ]" "[ math pyk define untagged zero as "untagged zero" end define end math ]" "[ math pyk define untagged one as "untagged one" end define end math ]" "[ math pyk define untagged two as "untagged two" end define end math ]" "[ math pyk define untagged three as "untagged three" end define end math ]" "[ math pyk define untagged four as "untagged four" end define end math ]" "[ math pyk define untagged five as "untagged five" end define end math ]" "[ math pyk define untagged six as "untagged six" end define end math ]" "[ math pyk define untagged seven as "untagged seven" end define end math ]" "[ math pyk define untagged eight as "untagged eight" end define end math ]" "[ math pyk define untagged nine as "untagged nine" end define end math ]" "[ math pyk define zero as "zero" end define end math ]" "[ math pyk define one as "one" end define end math ]" "[ math pyk define two as "two" end define end math ]" "[ math pyk define three as "three" end define end math ]" "[ math pyk define four as "four" end define end math ]" "[ math pyk define five as "five" end define end math ]" "[ math pyk define six as "six" end define end math ]" "[ math pyk define seven as "seven" end define end math ]" "[ math pyk define eight as "eight" end define end math ]" "[ math pyk define nine as "nine" end define end math ]" "[ math pyk define var a as "var a" end define end math ]" "[ math pyk define var b as "var b" end define end math ]" "[ math pyk define var c as "var c" end define end math ]" "[ math pyk define var d as "var d" end define end math ]" "[ math pyk define var e as "var e" end define end math ]" "[ math pyk define var f as "var f" end define end math ]" "[ math pyk define var g as "var g" end define end math ]" "[ math pyk define var h as "var h" end define end math ]" "[ math pyk define var i as "var i" end define end math ]" "[ math pyk define var j as "var j" end define end math ]" "[ math pyk define var k as "var k" end define end math ]" "[ math pyk define var l as "var l" end define end math ]" "[ math pyk define var m as "var m" end define end math ]" "[ math pyk define var n as "var n" end define end math ]" "[ math pyk define var o as "var o" end define end math ]" "[ math pyk define var p as "var p" end define end math ]" "[ math pyk define var q as "var q" end define end math ]" "[ math pyk define var r as "var r" end define end math ]" "[ math pyk define var s as "var s" end define end math ]" "[ math pyk define var t as "var t" end define end math ]" "[ math pyk define var u as "var u" end define end math ]" "[ math pyk define var v as "var v" end define end math ]" "[ math pyk define var w as "var w" end define end math ]" "[ math pyk define tagged parenthesis x end tagged as "tagged parenthesis * end tagged" end define end math ]" "[ math pyk define tagged if x then x else x end if as "tagged if * then * else * end if" end define end math ]" "[ math pyk define array x is x end array as "array * is * end array" end define end math ]" "[ math pyk define left as "left" end define end math ]" "[ math pyk define center as "center" end define end math ]" "[ math pyk define right as "right" end define end math ]" "[ math pyk define empty as "empty" end define end math ]" "[ math pyk define substitute x set x to x end substitute as "substitute * set * to * end substitute" end define end math ]" "[ math pyk define map tag x end tag as "map tag * end tag" end define end math ]" "[ math pyk define apply x to x end apply as "apply * to * end apply" end define end math ]" "[ math pyk define apply one x to x end apply as "apply one * to * end apply" end define end math ]" "[ math pyk define x raw head as "* raw head" end define end math ]" "[ math pyk define x raw tail as "* raw tail" end define end math ]" "[ math pyk define x is cardinal as "* is cardinal" end define end math ]" "[ math pyk define x is data as "* is data" end define end math ]" "[ math pyk define x cardinal untag as "* cardinal untag" end define end math ]" "[ math pyk define x head as "* head" end define end math ]" "[ math pyk define x tail as "* tail" end define end math ]" "[ math pyk define x is singular as "* is singular" end define end math ]" "[ math pyk define x boolean retract as "* boolean retract" end define end math ]" "[ math pyk define x cardinal retract as "* cardinal retract" end define end math ]" "[ math pyk define x tagged retract as "* tagged retract" end define end math ]" "[ math pyk define raw map untag x end untag as "raw map untag * end untag" end define end math ]" "[ math pyk define map untag x end untag as "map untag * end untag" end define end math ]" "[ math pyk define normalizing untag x end untag as "normalizing untag * end untag" end define end math ]" "[ math pyk define x raw pair x as "* raw pair *" end define end math ]" "[ math pyk define x eager pair x as "* eager pair *" end define end math ]" "[ math pyk define x tagged pair x as "* tagged pair *" end define end math ]" "[ math pyk define x untagged double x as "* untagged double *" end define end math ]" "[ math pyk define x pair x as "* pair *" end define end math ]" "[ math pyk define x double x as "* double *" end define end math ]" "[ math pyk define x math equal x as "* math equal *" end define end math ]" "[ math pyk define x data equal x as "* data equal *" end define end math ]" "[ math pyk define x cardinal equal x as "* cardinal equal *" end define end math ]" "[ math pyk define x peano equal x as "* peano equal *" end define end math ]" "[ math pyk define x tagged equal x as "* tagged equal *" end define end math ]" "[ math pyk define x reduce to x as "* reduce to *" end define end math ]" "[ math pyk define not x as "not *" end define end math ]" "[ math pyk define x and x as "* and *" end define end math ]" "[ math pyk define x or x as "* or *" end define end math ]" "[ math pyk define x parallel x as "* parallel *" end define end math ]" "[ math pyk define x boolean equal x as "* boolean equal *" end define end math ]" "[ math pyk define x guard x as "* guard *" end define end math ]" "[ math pyk define x tagged guard x as "* tagged guard *" end define end math ]" "[ math pyk define x select x else x end select as "* select * else * end select" end define end math ]" "[ math pyk define x tab x as "* tab *" end define end math ]" "[ math pyk define x row x as "* row"n"n*" end define end math ]" "[ math pyk define macro as "macro" end define end math ]" "[ math pyk define value aspect as "value aspect" end define end math ]" "[ math pyk define macro aspect as "macro aspect" end define end math ]" "[ math pyk define eval x stack x cache x end eval as "eval * stack * cache * end eval" end define end math ]" "[ math pyk define eval two x ref x id x stack x cache x end eval as "eval two * ref * id * stack * cache * end eval" end define end math ]" "[ math pyk define eval three x function x stack x cache x end eval as "eval three * function * stack * cache * end eval" end define end math ]" "[ math pyk define eval four x arguments x stack x cache x end eval as "eval four * arguments * stack * cache * end eval" end define end math ]" "[ math pyk define lookup x stack x default x end lookup as "lookup * stack * default * end lookup" end define end math ]" "[ math pyk define abstract x term x stack x cache x end abstract as "abstract * term * stack * cache * end abstract" end define end math ]" "[ math pyk define x is atomic as "* is atomic" end define end math ]" "[ math pyk define quote x end quote as "quote * end quote" end define end math ]" "[ math pyk define x bit nil as "* bit nil" end define end math ]" "[ math pyk define x bit one as "* bit one" end define end math ]" "[ math pyk define binary as "binary" end define end math ]" "[ math pyk define x term equal x as "* term equal *" end define end math ]" "[ math pyk define x term list equal x as "* term list equal *" end define end math ]" "[ math pyk define x assoc x end assoc as "* assoc * end assoc" end define end math ]" "[ math pyk define expand x state x cache x end expand as "expand * state * cache * end expand" end define end math ]" "[ math pyk define expand two x definition x state x cache x end expand as "expand two * definition * state * cache * end expand" end define end math ]" "[ math pyk define expand list x state x cache x end expand as "expand list * state * cache * end expand" end define end math ]" "[ math pyk define macro state as "macro state" end define end math ]" "[ math pyk define zip x with x end zip as "zip * with * end zip" end define end math ]" "[ math pyk define assoc one x address x index x end assoc as "assoc one * address * index * end assoc" end define end math ]" "[ math pyk define x sub x end sub as "* sub * end sub" end define end math ]" "[ math pyk define protect x end protect as "protect * end protect" end define end math ]" "[ math pyk define self as "self" end define end math ]" "[ math protect define pyk of macro define x as x end define as "macro define * as * end define" end define end protect end math ]" "[ math pyk define value define x as x end define as "value define * as * end define" end define end math ]" "[ math pyk define intro define x as x end define as "intro define * as * end define" end define end math ]" "[ math pyk define pyk define x as x end define as "pyk define * as * end define" end define end math ]" "[ math pyk define tex define x as x end define as "tex define * as * end define" end define end math ]" "[ math pyk define tex name define x as x end define as "tex name define * as * end define" end define end math ]" "[ math pyk define parenthesis x end parenthesis as "parenthesis * end parenthesis" end define end math ]" "[ math pyk define macro define one as "macro define one" end define end math ]" "[ math pyk define macro define two x end define as "macro define two * end define" end define end math ]" "[ math pyk define macro define three x end define as "macro define three * end define" end define end math ]" "[ math pyk define macro define four x state x cache x definition x end define as "macro define four * state * cache * definition * end define" end define end math ]" "[ math pyk define state expand x state x cache x end expand as "state expand * state * cache * end expand" end define end math ]" "[ math pyk define quote expand x term x stack x end expand as "quote expand * term * stack * end expand" end define end math ]" "[ math pyk define quote expand two x term x stack x end expand as "quote expand two * term * stack * end expand" end define end math ]" "[ math pyk define quote expand three x term x stack x value x end expand as "quote expand three * term * stack * value * end expand" end define end math ]" "[ math pyk define quote expand star x term x stack x end expand as "quote expand star * term * stack * end expand" end define end math ]" \subsection{\TeX\ definitions}\label{section:TeXdefinitions} \begin{list}{}{ \setlength{\leftmargin}{5em} \setlength{\itemindent}{-5em}} \immediate\closeout\outex \input{./page.otx} \end{list} \subsection{Further \TeX\ definitions} This section contains tex definitions in an old style which the author has not yet turned into the style used in Appendix \ref{section:TeXdefinitions} "[ math tex define x as " \ast " end define end math ]" "[ math tex define x apply x as "#1. \mathbin {\mbox {'}}#2." end define end math ]" "[ math tex define x tagged apply x as "#1. \mathbin {\mbox {`}}#2." end define end math ]" "[ math tex define lambda x dot x as " \lambda #1. .#2." end define end math ]" "[ math tex define tagging x as " \Lambda #1." end define end math ]" "[ math tex define true as " \mathsf {T}" end define end math ]" "[ math tex define if x then x else x end if as " \mathrm {if}(#1. ,\linebreak [0]#2. ,\linebreak [0]#3. )" end define end math ]" "[ math tex define value as " \mathrm {val}" end define end math ]" "[ math tex define claim as " \mathrm {claim}" end define end math ]" "[ math tex define introduce x of x as x end introduce as " [#2/tex name/tex. \stackrel {#1. }{\Rightarrow }#3. ]" end define end math ]" "[ math tex define bottom as " \bot " end define end math ]" "[ math tex define function f of x end function as " f(#1. )" end define end math ]" "[ math tex define identity x end identity as " (#1. ){}^{I} " end define end math ]" "[ math tex define false as " \mathsf {F}" end define end math ]" "[ math tex define untagged zero as " \underline {0}" end define end math ]" "[ math tex define untagged one as " \underline {1}" end define end math ]" "[ math tex define untagged two as " \underline {2}" end define end math ]" "[ math tex define untagged three as " \underline {3}" end define end math ]" "[ math tex define untagged four as " \underline {4}" end define end math ]" "[ math tex define untagged five as " \underline {5}" end define end math ]" "[ math tex define untagged six as " \underline {6}" end define end math ]" "[ math tex define untagged seven as " \underline {7}" end define end math ]" "[ math tex define untagged eight as " \underline {8}" end define end math ]" "[ math tex define untagged nine as " \underline {9}" end define end math ]" "[ math tex define zero as " 0" end define end math ]" "[ math tex define one as " 1" end define end math ]" "[ math tex define two as " 2" end define end math ]" "[ math tex define three as " 3" end define end math ]" "[ math tex define four as " 4" end define end math ]" "[ math tex define five as " 5" end define end math ]" "[ math tex define six as " 6" end define end math ]" "[ math tex define seven as " 7" end define end math ]" "[ math tex define eight as " 8" end define end math ]" "[ math tex define nine as " 9" end define end math ]" "[ math tex define var a as " \mathsf {a}" end define end math ]" "[ math tex define var b as " \mathsf {b}" end define end math ]" "[ math tex define var c as " \mathsf {c}" end define end math ]" "[ math tex define var d as " \mathsf {d}" end define end math ]" "[ math tex define var e as " \mathsf {e}" end define end math ]" "[ math tex define var f as " \mathsf {f}" end define end math ]" "[ math tex define var g as " \mathsf {g}" end define end math ]" "[ math tex define var h as " \mathsf {h}" end define end math ]" "[ math tex define var i as " \mathsf {i}" end define end math ]" "[ math tex define var j as " \mathsf {j}" end define end math ]" "[ math tex define var k as " \mathsf {k}" end define end math ]" "[ math tex define var l as " \mathsf {l}" end define end math ]" "[ math tex define var m as " \mathsf {m}" end define end math ]" "[ math tex define var n as " \mathsf {n}" end define end math ]" "[ math tex define var o as " \mathsf {o}" end define end math ]" "[ math tex define var p as " \mathsf {p}" end define end math ]" "[ math tex define var q as " \mathsf {q}" end define end math ]" "[ math tex define var r as " \mathsf {r}" end define end math ]" "[ math tex define var s as " \mathsf {s}" end define end math ]" "[ math tex define var t as " \mathsf {t}" end define end math ]" "[ math tex define var u as " \mathsf {u}" end define end math ]" "[ math tex define var v as " \mathsf {v}" end define end math ]" "[ math tex define var w as " \mathsf {w}" end define end math ]" "[ math tex define tagged parenthesis x end tagged as " (#1. )^M" end define end math ]" "[ math tex define tagged if x then x else x end if as " \mathrm {If}(#1. ,\linebreak [0]#2. ,\linebreak [0]#3. )" end define end math ]" "[ math tex define array x is x end array as " \begin {array}{#1. }#2. \end {array}" end define end math ]" "[ math tex name define array x is x end array as "\mathrm {array}\{#1. \}#2. \mathrm {end\ array}" end define end math ]" "[ math tex define left as " l" end define end math ]" "[ math tex define center as " c" end define end math ]" "[ math tex define right as " r" end define end math ]" "[ math tex define empty as " " end define end math ]" "[ math tex name define empty as " \mathrm {empty}" end define end math ]" "[ math tex define substitute x set x to x end substitute as " \langle #1. \,{|}#2. {:=}\,#3. \rangle " end define end math ]" "[ math tex define map tag x end tag as " {\cal M}(#1. )" end define end math ]" "[ math tex define apply x to x end apply as " \mathbf {apply}(#1. ,#2. )" end define end math ]" "[ math tex define apply one x to x end apply as " \mathbf {apply}_1(#1. ,#2. )" end define end math ]" "[ math tex define x raw head as "#1. {}^H" end define end math ]" "[ math tex define x raw tail as "#1. {}^T" end define end math ]" "[ math tex define x is cardinal as "#1. {}^c" end define end math ]" "[ math tex define x is data as "#1. {}^d" end define end math ]" "[ math tex define x cardinal untag as "#1. {}^U" end define end math ]" "[ math tex define x head as "#1. {}^h" end define end math ]" "[ math tex define x tail as "#1. {}^t" end define end math ]" "[ math tex define x is singular as "#1. {}^s" end define end math ]" "[ math tex define x boolean retract as "#1. {}^B" end define end math ]" "[ math tex define x cardinal retract as "#1. {}^C" end define end math ]" "[ math tex define x tagged retract as "#1. {}^M" end define end math ]" "[ math tex define raw map untag x end untag as " \tilde {{\cal U}}(#1. )" end define end math ]" "[ math tex define map untag x end untag as " {\cal U}(#1. )" end define end math ]" "[ math tex define normalizing untag x end untag as " {\cal U}^M(#1. )" end define end math ]" "[ math tex define x raw pair x as "#1. \mathrel { \dot { . \, . } }#2." end define end math ]" "[ math tex define x eager pair x as "#1. \mathrel { \underline { \dot { . \, . } } }#2." end define end math ]" "[ math tex define x tagged pair x as "#1. \mathrel { \underline { : \, : } }#2." end define end math ]" "[ math tex define x untagged double x as "#1. \mathrel { \underline { {+} 2 \ast } }#2." end define end math ]" "[ math tex define var x pair var y as "#1. \mathrel { : \, : }#2." end define end math ]" "[ math tex define x double x as "#1. \mathrel { {+} 2 \ast }#2." end define end math ]" "[ math tex define x boolean equal x as "#1. \stackrel {B}{\approx }#2." end define end math ]" "[ math tex define x data equal x as "#1. \stackrel {D}{\approx }#2." end define end math ]" "[ math tex define x cardinal equal x as "#1. \stackrel {C}{\approx }#2." end define end math ]" "[ math tex define x peano equal x as "#1. \stackrel {P}{\approx }#2." end define end math ]" "[ math tex define x tagged equal x as "#1. \approx #2." end define end math ]" "[ math tex define x math equal x as "#1. =#2." end define end math ]" "[ math tex define x reduce to x as "#1. \stackrel {+}{\rightarrow }#2." end define end math ]" "[ math tex define not x as " {\neg }#1." end define end math ]" "[ math tex define x and x as "#1. \wedge #2." end define end math ]" "[ math tex define x or x as "#1. \vee #2." end define end math ]" "[ math tex define x parallel x as "#1. \parallel #2." end define end math ]" "[ math tex define x guard x as "#1. :#2." end define end math ]" "[ math tex define x tagged guard x as "#1. !#2." end define end math ]" "[ math tex define x select x else x end select as "#1. \left\{\protect \begin {array}{l}#2. \\#3. \protect \end {array}\right." end define end math ]" "[ math tex define x tab x as "#1. ." end define end math ]" "[ math tex name define x tab x as "#1. \& #2." end define end math ]" "[ math tex define x row x as "#1. \\ #2." end define end math ]" "[ math tex name define x row x as "#1. \backslash \backslash #2." end define end math ]" "[ math tex define macro as " \mathrm {macro}" end define end math ]" "[ math tex define value aspect as " \mbox {\tt \char34}\mathrm {value}\mbox {\tt \char34}" end define end math ]" "[ math tex define macro aspect as " \mbox {\tt \char34}\mathrm {macro}\mbox {\tt \char34}" end define end math ]" "[ math tex define eval x stack x cache x end eval as " {\cal E}(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define eval two x ref x id x stack x cache x end eval as " {\cal E}_2(#1. ,#2. ,#3. ,#4. ,#5. )" end define end math ]" "[ math tex define eval three x function x stack x cache x end eval as " {\cal E}_3(#1. ,#2. ,#3. ,#4. )" end define end math ]" "[ math tex define eval four x arguments x stack x cache x end eval as " {\cal E}_4(#1. ,#2. ,#3. ,#4. )" end define end math ]" "[ math tex define lookup x stack x default x end lookup as " \mathbf {lookup}(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define abstract x term x stack x cache x end abstract as " \mathbf {abstract}(#1. ,#2. ,#3. ,#4. )" end define end math ]" "[ math tex define x is atomic as "#1. {}^a" end define end math ]" "[ math tex define quote x end quote as " \lceil #1. \rceil " end define end math ]" "[ math tex define x bit nil as "#1. 0" end define end math ]" "[ math tex define x bit one as "#1. 1" end define end math ]" "[ math tex define binary as " 0 \mathrm {b}" end define end math ]" "[ math tex define x term equal x as "#1. \stackrel {t}{=}#2." end define end math ]" "[ math tex define x term list equal x as "#1. \stackrel {t^*}{=}#2." end define end math ]" "[ math tex define x assoc x end assoc as "#1. {[}#2. {]}" end define end math ]" "[ math tex define expand x state x cache x end expand as " {\cal M}(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define expand two x definition x state x cache x end expand as " {\cal M}_2(#1. ,#2. ,#3. ,#4. )" end define end math ]" "[ math tex define macro state as " s_0" end define end math ]" "[ math tex define expand list x state x cache x end expand as " {\cal M}^*(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define zip x with x end zip as " \mathbf {zip}(#1. ,#2. )" end define end math ]" "[ math tex define assoc one x address x index x end assoc as " \mathbf {assoc}_1(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define x sub x end sub as "#1. _{#2. }" end define end math ]" "[ math tex name define x sub x end sub as "#1. \_\{#2. \}" end define end math ]" "[ math tex define protect x end protect as "(#1. )^{\mathbf {p}}" end define end math ]" "[ math protect define tex of macro define x as x end define as text " [#1/tex name/tex. \mathrel {\ddot {=}}#2. ]" end text end define end protect end math ]" "[ math tex define value define x as x end define as " [#1/tex name/tex. \mathrel {\dot {=}}#2. ]" end define end math ]" "[ math tex define intro define x as x end define as " [#1/tex name/tex. \mathrel {\acute {=}}#2. ]" end define end math ]" "[ math tex define pyk define x as x end define as " [#1/tex name/tex. \stackrel {\mathrm {pyk}}{=} #2/tex name. ]" end define end math ]" "[ math tex define tex define x as x end define as " [#1/tex name/tex. \stackrel {\mathrm {tex}}{=} #2/tex name. ]" end define end math ]" "[ math tex define tex name define x as x end define as " [#1/tex name/tex. \stackrel {\mathrm {name}}{=} #2/tex name. ]" end define end math ]" "[ math tex define macro define one as " \tilde {{\cal M}}_1" end define end math ]" "[ math tex define macro define two x end define as " \tilde {{\cal M}}_2(#1. )" end define end math ]" "[ math tex define macro define three x end define as " \tilde {{\cal M}}_3(#1. )" end define end math ]" "[ math tex define macro define four x state x cache x definition x end define as " \tilde {{\cal M}}_4(#1. ,#2. ,#3. ,#4. )" end define end math ]" "[ math tex define state expand x state x cache x end expand as " \tilde {{\cal M}}(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define quote expand x term x stack x end expand as " \tilde {{\cal Q}}(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define quote expand two x term x stack x end expand as " \tilde {{\cal Q}}_2(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define quote expand three x term x stack x value x end expand as " \tilde {{\cal Q}}_3(#1. ,#2. ,#3. ,#4. )" end define end math ]" "[ math tex define quote expand star x term x stack x end expand as " \tilde {{\cal Q}}^*(#1. ,#2. ,#3. )" end define end math ]" "[ math tex define parenthesis x end parenthesis as " (#1. )" end define end math ]" \subsection{Line numbers} The following definitions are experimental definitions of line numbers named ``ell a'', ``ell b'', etc.\ which expand into $[L_{01}]$, $[L_{02}]$, etc.\ in such a way that proof lines are numbered in succession. The ``ell dummy'' operator expands into different line numbers each time it is used and can be used for lines that are never referenced. \begin{flushleft} "[ math pyk define ell a as "ell a" end define end math ]" "[ math pyk define ell b as "ell b" end define end math ]" "[ math pyk define ell c as "ell c" end define end math ]" "[ math pyk define ell d as "ell d" end define end math ]" "[ math pyk define ell e as "ell e" end define end math ]" "[ math pyk define ell f as "ell f" end define end math ]" "[ math pyk define ell g as "ell g" end define end math ]" "[ math pyk define ell h as "ell h" end define end math ]" "[ math pyk define ell i as "ell i" end define end math ]" "[ math pyk define ell j as "ell j" end define end math ]" "[ math pyk define ell k as "ell k" end define end math ]" "[ math pyk define ell l as "ell l" end define end math ]" "[ math pyk define ell m as "ell m" end define end math ]" "[ math pyk define ell n as "ell n" end define end math ]" "[ math pyk define ell o as "ell o" end define end math ]" "[ math pyk define ell p as "ell p" end define end math ]" "[ math pyk define ell q as "ell q" end define end math ]" "[ math pyk define ell r as "ell r" end define end math ]" "[ math pyk define ell s as "ell s" end define end math ]" "[ math pyk define ell t as "ell t" end define end math ]" "[ math pyk define ell u as "ell u" end define end math ]" "[ math pyk define ell v as "ell v" end define end math ]" "[ math pyk define ell w as "ell w" end define end math ]" "[ math pyk define ell x as "ell x" end define end math ]" "[ math pyk define ell y as "ell y" end define end math ]" "[ math pyk define ell z as "ell z" end define end math ]" "[ math pyk define ell big a as "ell big a" end define end math ]" "[ math pyk define ell big b as "ell big b" end define end math ]" "[ math pyk define ell big c as "ell big c" end define end math ]" "[ math pyk define ell big d as "ell big d" end define end math ]" "[ math pyk define ell big e as "ell big e" end define end math ]" "[ math pyk define ell big f as "ell big f" end define end math ]" "[ math pyk define ell big g as "ell big g" end define end math ]" "[ math pyk define ell big h as "ell big h" end define end math ]" "[ math pyk define ell big i as "ell big i" end define end math ]" "[ math pyk define ell big j as "ell big j" end define end math ]" "[ math pyk define ell big k as "ell big k" end define end math ]" "[ math pyk define ell big l as "ell big l" end define end math ]" "[ math pyk define ell big m as "ell big m" end define end math ]" "[ math pyk define ell big n as "ell big n" end define end math ]" "[ math pyk define ell big o as "ell big o" end define end math ]" "[ math pyk define ell big p as "ell big p" end define end math ]" "[ math pyk define ell big q as "ell big q" end define end math ]" "[ math pyk define ell big r as "ell big r" end define end math ]" "[ math pyk define ell big s as "ell big s" end define end math ]" "[ math pyk define ell big t as "ell big t" end define end math ]" "[ math pyk define ell big u as "ell big u" end define end math ]" "[ math pyk define ell big v as "ell big v" end define end math ]" "[ math pyk define ell big w as "ell big w" end define end math ]" "[ math pyk define ell big x as "ell big x" end define end math ]" "[ math pyk define ell big y as "ell big y" end define end math ]" "[ math pyk define ell big z as "ell big z" end define end math ]" "[ math pyk define ell dummy as "ell dummy" end define end math ]" "[ math tex name define ell a as "L_a" end define end math ]" "[ math tex name define ell b as "L_b" end define end math ]" "[ math tex name define ell c as "L_c" end define end math ]" "[ math tex name define ell d as "L_d" end define end math ]" "[ math tex name define ell e as "L_e" end define end math ]" "[ math tex name define ell f as "L_f" end define end math ]" "[ math tex name define ell g as "L_g" end define end math ]" "[ math tex name define ell h as "L_h" end define end math ]" "[ math tex name define ell i as "L_i" end define end math ]" "[ math tex name define ell j as "L_j" end define end math ]" "[ math tex name define ell k as "L_k" end define end math ]" "[ math tex name define ell l as "L_l" end define end math ]" "[ math tex name define ell m as "L_m" end define end math ]" "[ math tex name define ell n as "L_n" end define end math ]" "[ math tex name define ell o as "L_o" end define end math ]" "[ math tex name define ell p as "L_p" end define end math ]" "[ math tex name define ell q as "L_q" end define end math ]" "[ math tex name define ell r as "L_r" end define end math ]" "[ math tex name define ell s as "L_s" end define end math ]" "[ math tex name define ell t as "L_t" end define end math ]" "[ math tex name define ell u as "L_u" end define end math ]" "[ math tex name define ell v as "L_v" end define end math ]" "[ math tex name define ell w as "L_w" end define end math ]" "[ math tex name define ell x as "L_x" end define end math ]" "[ math tex name define ell y as "L_y" end define end math ]" "[ math tex name define ell z as "L_z" end define end math ]" "[ math tex name define ell big a as "L_A" end define end math ]" "[ math tex name define ell big b as "L_B" end define end math ]" "[ math tex name define ell big c as "L_C" end define end math ]" "[ math tex name define ell big d as "L_D" end define end math ]" "[ math tex name define ell big e as "L_E" end define end math ]" "[ math tex name define ell big f as "L_F" end define end math ]" "[ math tex name define ell big g as "L_G" end define end math ]" "[ math tex name define ell big h as "L_H" end define end math ]" "[ math tex name define ell big i as "L_I" end define end math ]" "[ math tex name define ell big j as "L_J" end define end math ]" "[ math tex name define ell big k as "L_K" end define end math ]" "[ math tex name define ell big l as "L_L" end define end math ]" "[ math tex name define ell big m as "L_M" end define end math ]" "[ math tex name define ell big n as "L_N" end define end math ]" "[ math tex name define ell big o as "L_O" end define end math ]" "[ math tex name define ell big p as "L_P" end define end math ]" "[ math tex name define ell big q as "L_Q" end define end math ]" "[ math tex name define ell big r as "L_R" end define end math ]" "[ math tex name define ell big s as "L_S" end define end math ]" "[ math tex name define ell big t as "L_T" end define end math ]" "[ math tex name define ell big u as "L_U" end define end math ]" "[ math tex name define ell big v as "L_V" end define end math ]" "[ math tex name define ell big w as "L_W" end define end math ]" "[ math tex name define ell big x as "L_X" end define end math ]" "[ math tex name define ell big y as "L_Y" end define end math ]" "[ math tex name define ell big z as "L_Z" end define end math ]" "[ math tex name define ell dummy as "L_?" end define end math ]" \end{flushleft} "[ math tex define ell a as " \if \relax \csname lgwprooflinep\endcsname L_a \else \if \relax \csname lgwella\endcsname \global \advance \lgwproofline by 1 \xdef \lgwella {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwella \fi " end define end math ]" "[ math tex define ell b as " \if \relax \csname lgwprooflinep\endcsname L_b \else \if \relax \csname lgwellb\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellb {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellb \fi " end define end math ]" "[ math tex define ell c as " \if \relax \csname lgwprooflinep\endcsname L_c \else \if \relax \csname lgwellc\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellc {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellc \fi " end define end math ]" "[ math tex define ell d as " \if \relax \csname lgwprooflinep\endcsname L_d \else \if \relax \csname lgwelld\endcsname \global \advance \lgwproofline by 1 \xdef \lgwelld {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwelld \fi " end define end math ]" "[ math tex define ell e as " \if \relax \csname lgwprooflinep\endcsname L_e \else \if \relax \csname lgwelle\endcsname \global \advance \lgwproofline by 1 \xdef \lgwelle {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwelle \fi " end define end math ]" "[ math tex define ell f as " \if \relax \csname lgwprooflinep\endcsname L_f \else \if \relax \csname lgwellf\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellf {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellf \fi " end define end math ]" "[ math tex define ell g as " \if \relax \csname lgwprooflinep\endcsname L_g \else \if \relax \csname lgwellg\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellg {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellg \fi " end define end math ]" "[ math tex define ell h as " \if \relax \csname lgwprooflinep\endcsname L_h \else \if \relax \csname lgwellh\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellh {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellh \fi " end define end math ]" "[ math tex define ell i as " \if \relax \csname lgwprooflinep\endcsname L_i \else \if \relax \csname lgwelli\endcsname \global \advance \lgwproofline by 1 \xdef \lgwelli {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwelli \fi " end define end math ]" "[ math tex define ell j as " \if \relax \csname lgwprooflinep\endcsname L_j \else \if \relax \csname lgwellj\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellj {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellj \fi " end define end math ]" "[ math tex define ell k as " \if \relax \csname lgwprooflinep\endcsname L_k \else \if \relax \csname lgwellk\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellk {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellk \fi " end define end math ]" "[ math tex define ell l as " \if \relax \csname lgwprooflinep\endcsname L_l \else \if \relax \csname lgwelll\endcsname \global \advance \lgwproofline by 1 \xdef \lgwelll {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwelll \fi " end define end math ]" "[ math tex define ell m as " \if \relax \csname lgwprooflinep\endcsname L_m \else \if \relax \csname lgwellm\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellm {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellm \fi " end define end math ]" "[ math tex define ell n as " \if \relax \csname lgwprooflinep\endcsname L_n \else \if \relax \csname lgwelln\endcsname \global \advance \lgwproofline by 1 \xdef \lgwelln {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwelln \fi " end define end math ]" "[ math tex define ell o as " \if \relax \csname lgwprooflinep\endcsname L_o \else \if \relax \csname lgwello\endcsname \global \advance \lgwproofline by 1 \xdef \lgwello {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwello \fi " end define end math ]" "[ math tex define ell p as " \if \relax \csname lgwprooflinep\endcsname L_p \else \if \relax \csname lgwellp\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellp {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellp \fi " end define end math ]" "[ math tex define ell q as " \if \relax \csname lgwprooflinep\endcsname L_q \else \if \relax \csname lgwellq\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellq {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellq \fi " end define end math ]" "[ math tex define ell r as " \if \relax \csname lgwprooflinep\endcsname L_r \else \if \relax \csname lgwellr\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellr {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellr \fi " end define end math ]" "[ math tex define ell s as " \if \relax \csname lgwprooflinep\endcsname L_s \else \if \relax \csname lgwells\endcsname \global \advance \lgwproofline by 1 \xdef \lgwells {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwells \fi " end define end math ]" "[ math tex define ell t as " \if \relax \csname lgwprooflinep\endcsname L_t \else \if \relax \csname lgwellt\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellt {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellt \fi " end define end math ]" "[ math tex define ell u as " \if \relax \csname lgwprooflinep\endcsname L_u \else \if \relax \csname lgwellu\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellu {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellu \fi " end define end math ]" "[ math tex define ell v as " \if \relax \csname lgwprooflinep\endcsname L_v \else \if \relax \csname lgwellv\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellv {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellv \fi " end define end math ]" "[ math tex define ell w as " \if \relax \csname lgwprooflinep\endcsname L_w \else \if \relax \csname lgwellw\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellw {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellw \fi " end define end math ]" "[ math tex define ell x as " \if \relax \csname lgwprooflinep\endcsname L_x \else \if \relax \csname lgwellx\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellx {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellx \fi " end define end math ]" "[ math tex define ell y as " \if \relax \csname lgwprooflinep\endcsname L_y \else \if \relax \csname lgwelly\endcsname \global \advance \lgwproofline by 1 \xdef \lgwelly {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwelly \fi " end define end math ]" "[ math tex define ell z as " \if \relax \csname lgwprooflinep\endcsname L_z \else \if \relax \csname lgwellz\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellz {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellz \fi " end define end math ]" "[ math tex define ell big a as " \if \relax \csname lgwprooflinep\endcsname L_A \else \if \relax \csname lgwellbiga\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbiga {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbiga \fi " end define end math ]" "[ math tex define ell big b as " \if \relax \csname lgwprooflinep\endcsname L_B \else \if \relax \csname lgwellbigb\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigb {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigb \fi " end define end math ]" "[ math tex define ell big c as " \if \relax \csname lgwprooflinep\endcsname L_C \else \if \relax \csname lgwellbigc\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigc {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigc \fi " end define end math ]" "[ math tex define ell big d as " \if \relax \csname lgwprooflinep\endcsname L_D \else \if \relax \csname lgwellbigd\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigd {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigd \fi " end define end math ]" "[ math tex define ell big e as " \if \relax \csname lgwprooflinep\endcsname L_E \else \if \relax \csname lgwellbige\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbige {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbige \fi " end define end math ]" "[ math tex define ell big f as " \if \relax \csname lgwprooflinep\endcsname L_F \else \if \relax \csname lgwellbigf\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigf {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigf \fi " end define end math ]" "[ math tex define ell big g as " \if \relax \csname lgwprooflinep\endcsname L_G \else \if \relax \csname lgwellbigg\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigg {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigg \fi " end define end math ]" "[ math tex define ell big h as " \if \relax \csname lgwprooflinep\endcsname L_H \else \if \relax \csname lgwellbigh\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigh {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigh \fi " end define end math ]" "[ math tex define ell big i as " \if \relax \csname lgwprooflinep\endcsname L_I \else \if \relax \csname lgwellbigi\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigi {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigi \fi " end define end math ]" "[ math tex define ell big j as " \if \relax \csname lgwprooflinep\endcsname L_J \else \if \relax \csname lgwellbigj\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigj {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigj \fi " end define end math ]" "[ math tex define ell big k as " \if \relax \csname lgwprooflinep\endcsname L_K \else \if \relax \csname lgwellbigk\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigk {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigk \fi " end define end math ]" "[ math tex define ell big l as " \if \relax \csname lgwprooflinep\endcsname L_L \else \if \relax \csname lgwellbigl\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigl {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigl \fi " end define end math ]" "[ math tex define ell big m as " \if \relax \csname lgwprooflinep\endcsname L_M \else \if \relax \csname lgwellbigm\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigm {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigm \fi " end define end math ]" "[ math tex define ell big n as " \if \relax \csname lgwprooflinep\endcsname L_N \else \if \relax \csname lgwellbign\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbign {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbign \fi " end define end math ]" "[ math tex define ell big o as " \if \relax \csname lgwprooflinep\endcsname L_O \else \if \relax \csname lgwellbigo\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigo {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigo \fi " end define end math ]" "[ math tex define ell big p as " \if \relax \csname lgwprooflinep\endcsname L_P \else \if \relax \csname lgwellbigp\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigp {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigp \fi " end define end math ]" "[ math tex define ell big q as " \if \relax \csname lgwprooflinep\endcsname L_Q \else \if \relax \csname lgwellbigq\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigq {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigq \fi " end define end math ]" "[ math tex define ell big r as " \if \relax \csname lgwprooflinep\endcsname L_R \else \if \relax \csname lgwellbigr\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigr {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigr \fi " end define end math ]" "[ math tex define ell big s as " \if \relax \csname lgwprooflinep\endcsname L_S \else \if \relax \csname lgwellbigs\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigs {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigs \fi " end define end math ]" "[ math tex define ell big t as " \if \relax \csname lgwprooflinep\endcsname L_T \else \if \relax \csname lgwellbigt\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigt {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigt \fi " end define end math ]" "[ math tex define ell big u as " \if \relax \csname lgwprooflinep\endcsname L_U \else \if \relax \csname lgwellbigu\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigu {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigu \fi " end define end math ]" "[ math tex define ell big v as " \if \relax \csname lgwprooflinep\endcsname L_V \else \if \relax \csname lgwellbigv\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigv {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigv \fi " end define end math ]" "[ math tex define ell big w as " \if \relax \csname lgwprooflinep\endcsname L_W \else \if \relax \csname lgwellbigw\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigw {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigw \fi " end define end math ]" "[ math tex define ell big x as " \if \relax \csname lgwprooflinep\endcsname L_X \else \if \relax \csname lgwellbigx\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigx {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigx \fi " end define end math ]" "[ math tex define ell big y as " \if \relax \csname lgwprooflinep\endcsname L_Y \else \if \relax \csname lgwellbigy\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigy {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigy \fi " end define end math ]" "[ math tex define ell big z as " \if \relax \csname lgwprooflinep\endcsname L_Z \else \if \relax \csname lgwellbigz\endcsname \global \advance \lgwproofline by 1 \xdef \lgwellbigz {L\ifnum \lgwproofline <10 0\fi \number \lgwproofline } \fi \lgwellbigz \fi " end define end math ]" "[ math tex define ell dummy as " \if \relax \csname lgwprooflinep\endcsname L_? \else \global \advance \lgwproofline by 1 L\ifnum \lgwproofline <10 0\fi \number \lgwproofline \fi " end define end math ]" \subsection{Characters} \subsubsection{Pyk aspects of characters} "[ math pyk define unicode newline var x as " unicode newline *" end define end math ]" "[ math pyk define unicode space var x as "unicode space *" end define end math ]" "[ math pyk define unicode exclamation mark var x as "unicode exclamation mark *" end define end math ]" "[ math pyk define unicode quotation mark var x as "unicode quotation mark *" end define end math ]" "[ math pyk define unicode number sign var x as "unicode number sign *" end define end math ]" "[ math pyk define unicode dollar sign var x as "unicode dollar sign *" end define end math ]" "[ math pyk define unicode percent var x as "unicode percent *" end define end math ]" "[ math pyk define unicode ampersand var x as "unicode ampersand *" end define end math ]" "[ math pyk define unicode apostrophe var x as "unicode apostrophe *" end define end math ]" "[ math pyk define unicode left parenthesis var x as "unicode left parenthesis *" end define end math ]" "[ math pyk define unicode right parenthesis var x as "unicode right parenthesis *" end define end math ]" "[ math pyk define unicode asterisk var x as "unicode asterisk *" end define end math ]" "[ math pyk define unicode plus sign var x as "unicode plus sign *" end define end math ]" "[ math pyk define unicode comma var x as "unicode comma *" end define end math ]" "[ math pyk define unicode hyphen var x as "unicode hyphen *" end define end math ]" "[ math pyk define unicode period var x as "unicode period *" end define end math ]" "[ math pyk define unicode slash var x as "unicode slash *" end define end math ]" "[ math pyk define unicode zero var x as "unicode zero *" end define end math ]" "[ math pyk define unicode one var x as "unicode one *" end define end math ]" "[ math pyk define unicode two var x as "unicode two *" end define end math ]" "[ math pyk define unicode three var x as "unicode three *" end define end math ]" "[ math pyk define unicode four var x as "unicode four *" end define end math ]" "[ math pyk define unicode five var x as "unicode five *" end define end math ]" "[ math pyk define unicode six var x as "unicode six *" end define end math ]" "[ math pyk define unicode seven var x as "unicode seven *" end define end math ]" "[ math pyk define unicode eight var x as "unicode eight *" end define end math ]" "[ math pyk define unicode nine var x as "unicode nine *" end define end math ]" "[ math pyk define unicode colon var x as "unicode colon *" end define end math ]" "[ math pyk define unicode semicolon var x as "unicode semicolon *" end define end math ]" "[ math pyk define unicode less than var x as "unicode less than *" end define end math ]" "[ math pyk define unicode equal sign var x as "unicode equal sign *" end define end math ]" "[ math pyk define unicode greater than var x as "unicode greater than *" end define end math ]" "[ math pyk define unicode question mark var x as "unicode question mark *" end define end math ]" "[ math pyk define unicode commercial at var x as "unicode commercial at *" end define end math ]" "[ math pyk define unicode capital a var x as "unicode capital a *" end define end math ]" "[ math pyk define unicode capital b var x as "unicode capital b *" end define end math ]" "[ math pyk define unicode capital c var x as "unicode capital c *" end define end math ]" "[ math pyk define unicode capital d var x as "unicode capital d *" end define end math ]" "[ math pyk define unicode capital e var x as "unicode capital e *" end define end math ]" "[ math pyk define unicode capital f var x as "unicode capital f *" end define end math ]" "[ math pyk define unicode capital g var x as "unicode capital g *" end define end math ]" "[ math pyk define unicode capital h var x as "unicode capital h *" end define end math ]" "[ math pyk define unicode capital i var x as "unicode capital i *" end define end math ]" "[ math pyk define unicode capital j var x as "unicode capital j *" end define end math ]" "[ math pyk define unicode capital k var x as "unicode capital k *" end define end math ]" "[ math pyk define unicode capital l var x as "unicode capital l *" end define end math ]" "[ math pyk define unicode capital m var x as "unicode capital m *" end define end math ]" "[ math pyk define unicode capital n var x as "unicode capital n *" end define end math ]" "[ math pyk define unicode capital o var x as "unicode capital o *" end define end math ]" "[ math pyk define unicode capital p var x as "unicode capital p *" end define end math ]" "[ math pyk define unicode capital q var x as "unicode capital q *" end define end math ]" "[ math pyk define unicode capital r var x as "unicode capital r *" end define end math ]" "[ math pyk define unicode capital s var x as "unicode capital s *" end define end math ]" "[ math pyk define unicode capital t var x as "unicode capital t *" end define end math ]" "[ math pyk define unicode capital u var x as "unicode capital u *" end define end math ]" "[ math pyk define unicode capital v var x as "unicode capital v *" end define end math ]" "[ math pyk define unicode capital w var x as "unicode capital w *" end define end math ]" "[ math pyk define unicode capital x var x as "unicode capital x *" end define end math ]" "[ math pyk define unicode capital y var x as "unicode capital y *" end define end math ]" "[ math pyk define unicode capital z var x as "unicode capital z *" end define end math ]" "[ math pyk define unicode left bracket var x as "unicode left bracket *" end define end math ]" "[ math pyk define unicode backslash var x as "unicode backslash *" end define end math ]" "[ math pyk define unicode right bracket var x as "unicode right bracket *" end define end math ]" "[ math pyk define unicode circumflex var x as "unicode circumflex *" end define end math ]" "[ math pyk define unicode underscore var x as "unicode underscore *" end define end math ]" "[ math pyk define unicode small a var x as "unicode small a *" end define end math ]" "[ math pyk define unicode small b var x as "unicode small b *" end define end math ]" "[ math pyk define unicode small c var x as "unicode small c *" end define end math ]" "[ math pyk define unicode small d var x as "unicode small d *" end define end math ]" "[ math pyk define unicode small e var x as "unicode small e *" end define end math ]" "[ math pyk define unicode small f var x as "unicode small f *" end define end math ]" "[ math pyk define unicode small g var x as "unicode small g *" end define end math ]" "[ math pyk define unicode small h var x as "unicode small h *" end define end math ]" "[ math pyk define unicode small i var x as "unicode small i *" end define end math ]" "[ math pyk define unicode small j var x as "unicode small j *" end define end math ]" "[ math pyk define unicode small k var x as "unicode small k *" end define end math ]" "[ math pyk define unicode small l var x as "unicode small l *" end define end math ]" "[ math pyk define unicode small m var x as "unicode small m *" end define end math ]" "[ math pyk define unicode small n var x as "unicode small n *" end define end math ]" "[ math pyk define unicode small o var x as "unicode small o *" end define end math ]" "[ math pyk define unicode small p var x as "unicode small p *" end define end math ]" "[ math pyk define unicode small q var x as "unicode small q *" end define end math ]" "[ math pyk define unicode small r var x as "unicode small r *" end define end math ]" "[ math pyk define unicode small s var x as "unicode small s *" end define end math ]" "[ math pyk define unicode small t var x as "unicode small t *" end define end math ]" "[ math pyk define unicode small u var x as "unicode small u *" end define end math ]" "[ math pyk define unicode small v var x as "unicode small v *" end define end math ]" "[ math pyk define unicode small w var x as "unicode small w *" end define end math ]" "[ math pyk define unicode small x var x as "unicode small x *" end define end math ]" "[ math pyk define unicode small y var x as "unicode small y *" end define end math ]" "[ math pyk define unicode small z var x as "unicode small z *" end define end math ]" "[ math pyk define unicode grave accent var x as "unicode grave accent *" end define end math ]" "[ math pyk define unicode left brace var x as "unicode left brace *" end define end math ]" "[ math pyk define unicode vertical line var x as "unicode vertical line *" end define end math ]" "[ math pyk define unicode right brace var x as "unicode right brace *" end define end math ]" "[ math pyk define unicode tilde var x as "unicode tilde *" end define end math ]" \subsubsection{Tex aspects of characters} "[ math tex define unicode newline var x as ""n#1." end define end math ]" "[ math tex define unicode space var x as " #1." end define end math ]" "[ math tex define unicode exclamation mark var x as ""-!#1." end define end math ]" "[ math tex define unicode quotation mark var x as ""!#1." end define end math ]" "[ math tex define unicode number sign var x as "#.#1." end define end math ]" "[ math tex define unicode dollar sign var x as "$#1." end define end math ]" "[ math tex define unicode percent var x as "%#1." end define end math ]" "[ math tex define unicode ampersand var x as "." end define end math ]" "[ math tex define unicode apostrophe var x as "'#1." end define end math ]" "[ math tex define unicode left parenthesis var x as "(#1." end define end math ]" "[ math tex define unicode right parenthesis var x as ")#1." end define end math ]" "[ math tex define unicode asterisk var x as "*#1." end define end math ]" "[ math tex define unicode plus sign var x as ""-+#1." end define end math ]" "[ math tex define unicode comma var x as ",#1." end define end math ]" "[ math tex define unicode hyphen var x as ""--#1." end define end math ]" "[ math tex define unicode period var x as ".#1." end define end math ]" "[ math tex define unicode slash var x as "/#1." end define end math ]" "[ math tex define unicode zero var x as "0#1." end define end math ]" "[ math tex define unicode one var x as "1#1." end define end math ]" "[ math tex define unicode two var x as "2#1." end define end math ]" "[ math tex define unicode three var x as "3#1." end define end math ]" "[ math tex define unicode four var x as "4#1." end define end math ]" "[ math tex define unicode five var x as "5#1." end define end math ]" "[ math tex define unicode six var x as "6#1." end define end math ]" "[ math tex define unicode seven var x as "7#1." end define end math ]" "[ math tex define unicode eight var x as "8#1." end define end math ]" "[ math tex define unicode nine var x as "9#1." end define end math ]" "[ math tex define unicode colon var x as ":#1." end define end math ]" "[ math tex define unicode semicolon var x as ";#1." end define end math ]" "[ math tex define unicode less than var x as "<#1." end define end math ]" "[ math tex define unicode equal sign var x as "=#1." end define end math ]" "[ math tex define unicode greater than var x as ">#1." end define end math ]" "[ math tex define unicode question mark var x as ""-?#1." end define end math ]" "[ math tex define unicode commercial at var x as "@#1." end define end math ]" "[ math tex define unicode capital a var x as "A#1." end define end math ]" "[ math tex define unicode capital b var x as "B#1." end define end math ]" "[ math tex define unicode capital c var x as "C#1." end define end math ]" "[ math tex define unicode capital d var x as "D#1." end define end math ]" "[ math tex define unicode capital e var x as "E#1." end define end math ]" "[ math tex define unicode capital f var x as "F#1." end define end math ]" "[ math tex define unicode capital g var x as "G#1." end define end math ]" "[ math tex define unicode capital h var x as "H#1." end define end math ]" "[ math tex define unicode capital i var x as "I#1." end define end math ]" "[ math tex define unicode capital j var x as "J#1." end define end math ]" "[ math tex define unicode capital k var x as "K#1." end define end math ]" "[ math tex define unicode capital l var x as "L#1." end define end math ]" "[ math tex define unicode capital m var x as "M#1." end define end math ]" "[ math tex define unicode capital n var x as "N#1." end define end math ]" "[ math tex define unicode capital o var x as "O#1." end define end math ]" "[ math tex define unicode capital p var x as "P#1." end define end math ]" "[ math tex define unicode capital q var x as "Q#1." end define end math ]" "[ math tex define unicode capital r var x as "R#1." end define end math ]" "[ math tex define unicode capital s var x as "S#1." end define end math ]" "[ math tex define unicode capital t var x as "T#1." end define end math ]" "[ math tex define unicode capital u var x as "U#1." end define end math ]" "[ math tex define unicode capital v var x as "V#1." end define end math ]" "[ math tex define unicode capital w var x as "W#1." end define end math ]" "[ math tex define unicode capital x var x as "X#1." end define end math ]" "[ math tex define unicode capital y var x as "Y#1." end define end math ]" "[ math tex define unicode capital z var x as "Z#1." end define end math ]" "[ math tex define unicode left bracket var x as "[#1." end define end math ]" "[ math tex define unicode backslash var x as "\#1." end define end math ]" "[ math tex define unicode right bracket var x as "]#1." end define end math ]" "[ math tex define unicode circumflex var x as "^#1." end define end math ]" "[ math tex define unicode underscore var x as "_#1." end define end math ]" "[ math tex define unicode small a var x as "a#1." end define end math ]" "[ math tex define unicode small b var x as "b#1." end define end math ]" "[ math tex define unicode small c var x as "c#1." end define end math ]" "[ math tex define unicode small d var x as "d#1." end define end math ]" "[ math tex define unicode small e var x as "e#1." end define end math ]" "[ math tex define unicode small f var x as "f#1." end define end math ]" "[ math tex define unicode small g var x as "g#1." end define end math ]" "[ math tex define unicode small h var x as "h#1." end define end math ]" "[ math tex define unicode small i var x as "i#1." end define end math ]" "[ math tex define unicode small j var x as "j#1." end define end math ]" "[ math tex define unicode small k var x as "k#1." end define end math ]" "[ math tex define unicode small l var x as "l#1." end define end math ]" "[ math tex define unicode small m var x as "m#1." end define end math ]" "[ math tex define unicode small n var x as "n#1." end define end math ]" "[ math tex define unicode small o var x as "o#1." end define end math ]" "[ math tex define unicode small p var x as "p#1." end define end math ]" "[ math tex define unicode small q var x as "q#1." end define end math ]" "[ math tex define unicode small r var x as "r#1." end define end math ]" "[ math tex define unicode small s var x as "s#1." end define end math ]" "[ math tex define unicode small t var x as "t#1." end define end math ]" "[ math tex define unicode small u var x as "u#1." end define end math ]" "[ math tex define unicode small v var x as "v#1." end define end math ]" "[ math tex define unicode small w var x as "w#1." end define end math ]" "[ math tex define unicode small x var x as "x#1." end define end math ]" "[ math tex define unicode small y var x as "y#1." end define end math ]" "[ math tex define unicode small z var x as "z#1." end define end math ]" "[ math tex define unicode grave accent var x as "`#1." end define end math ]" "[ math tex define unicode left brace var x as "{#1." end define end math ]" "[ math tex define unicode vertical line var x as "|#1." end define end math ]" "[ math tex define unicode right brace var x as "}#1." end define end math ]" "[ math tex define unicode tilde var x as "~#1." end define end math ]" \subsubsection{Tex name aspects of characters} "[ ; Alternative definiton of newline that produces visible newlines. ; Was used during the initial development of Logiweb and might be useful ; for debugging, but generates annoying typography. ; math tex name define unicode newline var x as " ; {\downarrow }\newline #1." end define end math math tex name define unicode newline var x as " \newline #1." end define end math ]" "[ ; Alternative definiton of space that produces visible spaces. ; Was used during the initial development of Logiweb and might be useful ; for debugging, but generates annoying typography. ; math tex name define unicode space var x as " ; \hskip0em plus0.5em \mbox {\tt \char32 } ; \hskip0em plus0.5em \mbox {} \linebreak [0]#1." end define end math} math tex name define unicode space var x as " \linebreak [0]\ \hskip0em plus2.0em{}#1." end define end math ]" "[ math tex name define unicode number sign var x as " \#.#1." end define end math ]" "[ math tex name define unicode dollar sign var x as " \$#1." end define end math ]" "[ math tex name define unicode percent var x as " \%#1." end define end math ]" "[ math tex name define unicode ampersand var x as " \." end define end math ]" "[ math tex name define unicode apostrophe var x as " \mbox {'}#1." end define end math ]" "[ math tex name define unicode asterisk var x as " {*}#1." end define end math ]" "[ math tex name define unicode plus sign var x as " {+}#1." end define end math ]" "[ math tex name define unicode hyphen var x as " \mbox{-}#1." end define end math ]" "[ math tex name define unicode colon var x as " {:}#1." end define end math ]" "[ math tex name define unicode less than var x as " {<}#1." end define end math ]" "[ math tex name define unicode equal sign var x as " {=}#1." end define end math ]" "[ math tex name define unicode greater than var x as " {>}#1." end define end math ]" "[ math tex name define unicode backslash var x as " \mbox {$\backslash $}#1." end define end math ]" "[ math tex name define unicode circumflex var x as " {\char94}#1." end define end math ]" "[ math tex name define unicode underscore var x as " \_#1." end define end math ]" "[ math tex name define unicode grave accent var x as " \mbox {`}#1." end define end math ]" "[ math tex name define unicode left brace var x as " \{#1." end define end math ]" "[ math tex name define unicode right brace var x as " \}#1." end define end math ]" "[ math tex name define unicode tilde var x as " \char126 #1." end define end math ]" \section{Test} \begin{list}{}{ \setlength{\leftmargin}{5em} \setlength{\itemindent}{-5em}} \immediate\closeout\outest \input{./page.tst} \end{list} \section{Priority table}\label{section:PriorityTable} "[ flush left math protect define priority of base as Priority end define end protect end math end left ]" \section{Index} \newcommand\myidxitem{\par\noindent} \renewenvironment{theindex}{\let\item\myidxitem}{} \printindex \bibliography{./page} \end{document} End of file File page.bib @article {berline97, author = {C. Berline and K. Grue}, title = {A $\kappa$-denotational semantics for {M}ap {T}heory in {ZFC+SI}}, journal = TCS, year = {1997}, volume = {179}, number = {1--2}, pages = {137--202}, month = {jun}} @book {church41, author = {A. Church}, title = {The Calculi of Lambda-Conversion}, publisher = {Princeton University Press}, year = {1941}} @Article {godel, author = {K. G{\"!o}del}, title = {{\"!U}ber for\-mal un\-ent\-scheid\-ba\-re \mbox{S\"!at}\-ze der \mbox{Prin}\-ci\-pia \mbox{Mathe}\-ma\-ti\-ca und ver\-wand\-ter \mbox{Sys}\-teme \mbox{I}}, journal = {Mo\-nats\-hef\-te f{\"!u}r Mathe\-ma\-tik und Phy\-sik}, year = {19\-31}, volume = {12}, number = {\mbox{XXXVIII}}, pages = {173-198}} @book {Gordon79, author = {M. J. Gordon, A. J. Milner, C. P. Wadsworth}, title = {Edinburgh {LCF}, A mechanised logic of computation}, publisher = {Springer-Verlag}, year = {1979}, volume = {78}, series = {Lecture Notes in Computer Science}} @article {grue92, author = {K. Grue}, title = {Map Theory}, journal = TCS, year = {1992}, volume = {102}, number = {1}, pages = {1--133}, month = {jul}} @TechReport {grue02b, author = {K. Grue}, year = {2002}, title = {Map Theory with Classical Maps}, institution={DIKU}, address = {Universitetsparken 1, DK-2100 Copenhagen, Denmark}, note = {\\http:/$\!$/www.diku.dk/\verb+~+grue/papers/classical/classical.html}, number = {02/21}} @inproceedings{Logiweb, author = {K. Grue}, title = {Logiweb}, editor = {Fairouz Kamareddine}, booktitle = {Mathematical Knowledge Management Symposium 2003}, publisher = {Elsevier}, series = {Electronic Notes in Theoretical Computer Science}, volume = {93}, year = {2004}, pages = {70--101}} @Book {MathComp, author = {K. Grue}, title = {Mathematics and Computation (lecture notes)}, publisher = {DIKU}, year = {2001}, volume = {1--3}, edition = {7.}, note = {\\http:/$\!$/www.diku.dk/\verb+~+grue/papers/mac0102/}} @article {mccarthy60, author = {J. McCarthy}, title = {Recursive functions of symbolic expressions and their computation by machine}, journal = {Communications of the ACM}, year = {1960}, pages = {184--195}} @phdthesis {skalberg:isabelle-mt, author = {Sebastian C. Skalberg}, title = {An Interactive Proof System for Map Theory}, school = {University of Copenhagen}, year = {2002}, month = {oct}, note = {\url{http://www.mangust.dk/skalberg/phd/}}, postscript = {\url{http://www.mangust.dk/skalberg/phd/skalberg-phd.ps}}} @Book {steele, author = {Guy L. Steele}, title = {Common Lisp---The Language}, publisher = {Digital Press}, year = {1990}, edition = {Second}} @book {mendelson, author = {E. Mendelson}, title = {Introduction to Mathematical Logic}, publisher = {Wadsworth and Brooks}, year = {1987}, edition = {3.}} @book {TeXbook, author = {D. Knuth}, title = {The TeXbook}, publisher = {Addison Wesley}, year = {1983}} @book {vallee03theory, author = {Thierry Vall\'{e}e}, title = {``{Map Theory}'' et Antifondation}, series = {Electronic Notes in Theoretical Computer Science}, volume = {79}, publisher = {Elsevier}, year = {2003}, pages = {1-258}} End of file File page.sty % thebibliography environment from % /usr/share/texmf/tex/latex/base/book.cls % with \chapter removed \renewenvironment{thebibliography}[1] {\list{\@biblabel{\@arabic\c@enumiv}}% {\settowidth\labelwidth{\@biblabel{#1}}% \leftmargin\labelwidth \advance\leftmargin\labelsep \@openbib@code \usecounter{enumiv}% \let\p@enumiv\@empty \renewcommand\theenumiv{\@arabic\c@enumiv}}% \sloppy \clubpenalty4000 \@clubpenalty \clubpenalty \widowpenalty4000% \sfcode`\.\@m} {\def\@noitemerr {\@latex@warning{Empty `thebibliography' environment}}% \endlist} End of file latex page makeindex page bibtex page latex page makeindex page latex page dvipdfm page"