theorem.modes: Theorems and proofs for (x)html

The module theorem.modes in the directory http://gloss.bham.ac.uk/mv/html/ of the gloss distribution and web pages contains the code for presenting theorems, proofs, examples, exercises, etc. in (x)html standards-compliant pages.

1 Synopsis

Six standard CLASSes of theorem-objects are intructuced in theorem.modes, though you could add your own. These are theorem, definition, example, proof, subproof, and remark. Each theorem-object also has a TYPE, which usually the word used in the heading. So you could have TYPEs "Theorem" and "Lemma" (which would normally be of CLASS theorem) and TYPEs "Argument" and "Demonstration" (which might be of CLASS proof). The standard module theorem.modes provides tags "theorem", "definition", "example", "proof", "subproof", "remark" to define theorem objects with types "Theorem", "Definition", "Example", "Proof", "Subproof", "Remark" and classes "theorem", "definition", "example", "proof", "subproof", "semark" repectively. The module theorem-english.modes defines many more such tags (specifically "proofcomment", "lemma", "proposition", "corollary", "question", "examples", "exercises", "moral", "rule") and can be used as a model to show you how you can define your own.

Theorem-objects can also have ID for cross-referencing, NAME and NUMBER.

Generally speaking the code you write in GLOSS to create a theorem is as follows.

theoremtag
  @type[TYPE]
  @name[NAME]
  @number[NUMBER]
  @id[ID]
  @class[CLASS]
  ...content...

where theoremtag is a predefined tag such as "theorem", "definition", "example", "proof", "subproof", "remark" or one of the ones defined in an extension module, and any of the attributes following can be omitted (in which case they will be the default values for the tag you are using). The content is anything that can be inside an HTML div.

The theorem is output with a sequence of div, p, span and other tags, designed to make changes in style easy with CSS. If you are writing CSS or XSLT you will need to know these details, which are as follows.

  1. At the outermost level, we have a <div class="CLASS">
  2. If the theorem has an ID this ID is the id of the outermost div just described.
  3. The first child element is a p with class CLASS-title, and the contents of this are as follows.
    1. If the theorem has a TYPE (i.e. if this is not null) the following elements occur inside a single strong tag, as follows. (If not, this strong tag and its content will be omitted.)
      1. the TYPE in a span of class CLASS-type and this span has id ID-type if the theorem has an ID.
      2. unless NUMBER is "no", a single space in a span of class title-space
      3. the number itself in a span of class CLASS-number. This number will be automatically generated unless it is given explicitly by the user. This span has id ID-number if the theorem has an ID.
    2. If the theorem has a NAME (i.e. if this is not null) the following elements occur inside a single strong tag, as follows.
      1. a single space in a span of class title-space
      2. an open parenthesis "(" in a span of class title-bracket
      3. the NAME in a span of class CLASS-name and this span has id ID-name if the theorem has an ID.
      4. a close parenthesis ")" in a span of class title-bracket
  4. Any remaining HTML content follows this title.

The parameter thm:scheme governs the numbering system. The numbering will be 1.1, 1.2, 1.3..., 2.1, 2.2,.... etc, within sections, but: SCHEME=all means there is a single numbering system for all numbered theorem-type objects irrespective of their class or type; SCHEME=class means there is a single numbering system for each class of numbered theorem-type objects irrespective of their type; and SCHEME=type means there is a single numbering system for each type of numbered theorem-type objects irrespective of their class. (It is possible, though unusual to have two objects with the same type and different class!)

2 The code

!declare-prefix @prefix[thm] @uri[http://gloss.bham.ac.uk/mv/html/theorem] {
!declare-prefix @prefix[sec] @uri[http://gloss.bham.ac.uk/mv/html/section] {
!declare-prefix @prefix[html] @uri[http://gloss.bham.ac.uk/mv/html/plain] {
!declare-prefix @prefix[xml] @uri[http://gloss.bham.ac.uk/mv/xml/xml] {

The following parameters are used:

!init-parameter @name[thm:id] @value[]           ; the XML ID of the theorem
!init-parameter @name[thm:type] @value[Theorem]  ; the type (Theorem, Proposition, ... )
!init-parameter @name[thm:class] @value[theorem] ; the class (theorem, definition, ...)
!init-parameter @name[thm:name] @value[]         ; the name of the theorem
!init-parameter @name[thm:number] @value[]       ; the number of current theorem, "no" for none
!init-parameter @name[thm:manual] @value[auto]   ; whether the number was manually given
!init-parameter @name[thm:scheme] @value[type]   ; the numbering scheme: "all", "class" or "type"

The following are also used for various values of SUFFIX:

; !init-parameter @name @value                ; internal parameter used for numbering scheme
; !init-parameter @name @value             ; internal parameter: the number of the next theorem
; !init-parameter @name @value  ; internal parameter: the number of the last section
!mode @name[thm:body-content] @template[html:body-content] @type[process]
  !hook @mode[html:body-content] @action[process]
  theorem
    !process-tokens @mode[thm:do-theorem] ${thm:type}="Theorem"
  definition
    !process-tokens @mode[thm:do-theorem] ${thm:type}="Definition" ${thm:class}="definition"
  example
    !process-tokens @mode[thm:do-theorem] ${thm:type}="Example" ${thm:class}="example"
  proof
    !process-tokens @mode[thm:do-theorem] ${thm:type}="Proof" ${thm:class}="proof" ${thm:number}="no"
  subproof
    !process-tokens @mode[thm:do-theorem] ${thm:type}="Subproof" ${thm:class}="subproof" ${thm:number}="no"
  remark
    !process-tokens @mode[thm:do-theorem] ${thm:type}="Remark" ${thm:class}="remark" ${thm:number}="no"
  !include @mode[html:body-content] @hook[process]

!mode @name[thm:do-theorem] @accept[] @type[process]
  !default
    !set-parameter @name[thm:suffix] @value[]
    !if @test[$\{thm:scheme\}] @value[type]
      !set-parameter @name[thm:suffix] @value[-$\{thm:type\}]
    !if @test[$\{thm:scheme\}] @value[class]
      !set-parameter @name[thm:suffix] @value[-$\{thm:class\}]
    !process-tokens @mode[thm:get-parameters] @parameters[share]
    !element @name[div] !attribute @name[class] [$\{thm:class\}]
      !if @test[$\{thm:id\}] !attribute @name[id] [$\{thm:id\}]
      !element @name[p] !attribute @name[class] [$\{thm:class\}-title]
        !if @test[$\{thm:type\}]
          !element @name[strong] 
            !element @name[span]
	      !attribute @name[class] [$\{thm:class\}-type]
              !if @test[$\{thm:id\}] !attribute @name[id] [$\{thm:id\}-type]
              !text [$\{thm:type\}]
            !if-not @test[$\{thm:number\}] @value[no]
              !if-not @test[$\{thm:number\}]
                !if-not @test[$\{thm:num$\{thm:suffix\}\}]
                  !set-parameter @name[thm:num$\{thm:suffix\}] @value[1]
                  !export-parameter @name[thm:lastsec-number$\{thm:suffix\}] @value[$\{sec:section-number\}]
                !if @test[$\{sec:section-number\}] 
                  !if-not @test[$\{sec:section-number\}] @value[$\{thm:lastsec-number$\{thm:suffix\}\}]
                    !set-parameter @name[thm:num$\{thm:suffix\}] @value[1]
                    !export-parameter @name[thm:lastsec-number$\{thm:suffix\}] @value[$\{sec:section-number\}]
                  !set-parameter @name[thm:number] @value[$\{sec:section-number\}.]
		!set-parameter @name[thm:number] @value[$\{thm:number\}$\{thm:num$\{thm:suffix\}\}]
                !incr-parameter @name[thm:num$\{thm:suffix\}]
                !export-parameter @name[thm:num$\{thm:suffix\}]
              !element @name[span]
	        !attribute @name[class] [title-space]
                !literal [ ] 
              !element @name[span]
                !attribute @name[class] [$\{thm:class\}-number-$\{thm:manual\}] 
                !if @test[$\{thm:id\}] !attribute @name[id] [$\{thm:id\}-number]
                !text [$\{thm:number\}]
        !if @test[$\{thm:name\}]
          !element @name[strong] 
            !if @test[$\{thm:type\}]
              !element @name[span]
	        !attribute @name[class] [title-space]
                !literal [ ] 
              !element @name[span]
	        !attribute @name[class] [title-bracket]
                !text [(]
            !element @name[span]
              !attribute @name[class] [$\{thm:class\}-name]
              !if @test[$\{thm:id\}] !attribute @name[id] [$\{thm:id\}-name]
              !text [$\{thm:name\}]
            !if @test[$\{thm:type\}]
              !element @name[span]
	        !attribute @name[class] [title-bracket]
                !text [)]
      !text &#x0A;
      !process-tokens @mode[html:body-content]
    !text &#x0A;

!mode @name[thm:get-parameters] @accept[attr] @type[process]
  !attr @fullname[type] 
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[thm:type]
    !if @test[$\{thm:scheme\}] @value[type]
      !set-parameter @name[thm:suffix] @value[-$\{thm:type\}]
  !attr @fullname[name] 
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[thm:name]
  !attr @fullname[number] 
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[thm:number]
    !set-parameter @name[thm:manual] @value[manual]
  !attr @fullname[id] 
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[thm:id]
  !attr @fullname[class] 
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[thm:class]
    !if @test[$\{thm:scheme\}] @value[class]
      !set-parameter @name[thm:suffix] @value[-$\{thm:class\}]
  !default !abort

}; !declare-prefix
}; !declare-prefix
}; !declare-prefix
}; !declare-prefix

This file is part of the GLOSS system, Copyright Richard Kaye http://gloss.bham.ac.uk/. Usage permitted under the GPL. No Warranty.

This page is copyright. Web page design and creation by GLOSS.