Introduction to GAP
===================

---

What is my aim?
---------------

* overview of the computer algebra system GAP

* how to find your way (through the documentation)

* ``What can GAP do for me, and what probably not?''


What is GAP?
------------

* a system for computations in discrete algebra,
  mainly concerning groups

* a programming language

* a collection of functions

* data libraries

* C kernel + GAP library + GAP packages + ...


Starting and leaving GAP
------------------------

* is GAP installed?
  (if not then go to http://www.gap-system.org)

* open a terminal

* start GAP by calling the executable

* leave GAP by entering `quit;`


A GAP session
-------------

* banner (version information)

* enter your input interactively (REPL)

* GAP prompt `gap> ` and partial prompt `> `

* comments: `#`

* errors, break loop, prompt `brk> `

* command line editing (`readline`)

* command line history

* command line completion

* load input from a file with `Read`

* write the session (input and output) to a log file with `LogTo`


The GAP Language
----------------

* variable: points to a value

* assignment: `<identifier>:= <value>;`
  (case sensitive)

* read-only variables

* infix operators:
  `and`, `or`, `not`
  `=`, `<>`
  `<`, `<=`, `>`, `>=`
  `+`, `-`, `*`, `/`, `^`, `mod`, `in`

* functions (and procedures):
  (optional) arguments, local variables, return value, recursion

* `if` statements:
  `if <cond1> then
     <statements1>
   elif <cond2> then
     <statements2>
   else
     <statements3>
   fi;`

* loops:
  `for <var> in <list> do <statements> od`

  `while <cond> do <statements> od;`

  `repeat <statements> until <cond>;`

  `break`

  `continue`


Constants
---------

* booleans: `true`, `false`, `fail`

* integers (arbitrary large)

* rationals

* elements of cyclotomic fields: `E(4) + 1`

* finite field elements: `Z(5)^3`

* permutations (on positive integers): `(1,2,3)(4,5)`


Lists (arrays)
--------------

* plain lists (dense, sorted, homogeneous, ...)

* element and sublist access

* element and sublist assignment

* common subobjects

* mutability
 
* sortedness: linear vs. binary search, store knowledge

* ranges

* list arithmetics: `+`, `-`, `*`

* vectors and matrices: `<vec> * <mat>`. `<mat> * <vec>`, `<mat> * <mat>`

* other representations of vectors and matrices (less flexible, more efficient)

* strings and characters

* shortcuts for common loops: `List`, `Filtered`, `First`, `ForAll`, `ForAny`


Records
-------

* label/value pairs

* component access and assignment

* common subobjects, mutability


Customization
-------------

* `~/.gap` directory (`GAPInfo.UserGapRoot`)

* `~/.gap/gap.ini` file (user preferences): `BrowseUserPreferences();`

* `~/.gap/gaprc` file: load code on startup

* command line options: `-b`, `-g`, `-A`, `-l`, `-m`, `-o`, `-L`, ...

* inside GAP: `SizeScreen`, `SetGasmanMessageStatus`, ...


Documentation
-------------

* manuals: Tutorial, Reference Manual, package manuals in
           chapters, sections, subsections

* PDF, HTML, and text versions

* source format: typically GAPDoc (a GAP package; XML based data format),
  but in principle free; see also the AutoDoc package

* interactive help: `?<topic>`, `??<topics>`, `?>`, `?<`

* `SetHelpViewer` and `?&`

* [GAP bibliography](http://www.gap-system.org/Doc/Bib/bib.html)
  (also `BrowseBibliography()`)


Domains
-------

* domain = structured set

* multiplicative structures (`*`):  magma, semigroup, monoid, group, ...

* additive structures (`+`):  additive magma, additive group, ...

* additive with scalar multipl.:  vector spaces, ...

* mult. and add. structures:  ring, algebra (assoc., Lie, ...), field, ...

* orbits (`^`):  conjugacy classes, ...

* generators:
   * domain as closure under the defining arithmetic operations,
   * different notions for different structures:
     ring generators, algebra generators, field generators, ...
   * create a domain from generators
     (elements exist prior to the domain)

* many operations for domains depend on the structure:
   * set theoretic, for all domains
     (`AsList`, `IsFinite`, `Size`, `IsSubset`, ...)
   * for multiplicative structures
     (`IsCommutative`, `IsAssociative`, `Centre`, ...)
   * for groups
     (`SylowSubgroup`, `DerivedSubgroup`, ...)
   * for vector spaces
     (`Dimension`, `Basis`, ...)

* natural embeddings:
   * permutation groups
   * finite fields of a given characteristic
   * abelian number fields

* usually store known information

* iterators and enumerators


Groups
------

* permutation groups
  (base, stabilizer chains)

* matrix groups: over finite fields, abelian number fields
  (permutation action, recognition)

* finitely presented groups
  (coset enumeration, rewriting)

* polycyclicly presented groups
  (normal form of elements, collecting)

* automorphism groups

* via multiplication tables, ...


Group actions
-------------

* action of G on S is a map M x G -> M

* predefined: `^`, `OnPoints`, `OnSets`, `OnTuples`, `OnLines`, ...

* action homomorphism: G -> Sym( M )


Mappings
--------

* homomorphisms:  respect structure

* create:
   * by action
   * natural epimorphism
   * by images

* source, range, preimage, image

* kernel, injectivity, surjectivity

* generalized mappings


Other structures
----------------

* fields:
   * finite (`GF(q)`)
   * abelian number fields (`CF(n)`)
   * Kronecker construction (`AlgebraicExtension`)

* vector spaces:
   * subspaces of `F^n`
   * (finite dimensional) vector spaces generated by
     field elements, matrices, polynomials, ...

* algebras:
   * assoc. and Lie algebras as matrix algebras
   * algebras defined by structure constants (of small dimension)
   * group rings (for finite groups)
   * polynomial rings and fields of rational functions:
     not one of the strengths of GAP;
     arithmetics of elements, factorization,
     rudimentary Gröbner basis functionality

* character tables

* tables of marks

* see GAP packages, for example the `GRAPE` package for graphs


Data libraries (mainly of groups)
---------------------------------

* GL, SL, GU, SU, Sp, ... (over finite fields)

* groups of small order (a GAP package)

* transitive, primitive, perfect, crystallographic groups

* character tables (ATLAS of Finite Groups, a GAP package)

* loops of small order, Lie algebras, graphs, ... (GAP packages)


Profiling
---------

* profile function by function
   * switch on, run computations, switch off,
   * show in GAP

* profile line by line
   * load package `profiling`,
   * switch on, run computations, switch off,
   * prepare output files, show in browser

* profile an individual function call
   * call `LineByLineProfileFunction`,
   * show in browser


GAP's type system
-----------------

* operations and methods

* method selection:
   * `ApplicableMethod`
   * use known information
   * partial methods
   * `no method found` errors

* filters and types

* attributes and properties 

* implications

* families: partition of GAP objects,
            used for caching and in the method selection,
            cause complications when designing new kinds of objects


Concepts and conventions
------------------------

* case sensitive

* keywords: cannot be used as names of variables

* predefined variable names: `FirstLetterOfEachWordCapitalized`,
  `ReturnForInputs`

* write protection of variables

* mutability of objects

* domain: structured set

* objects and elements, identity and equality

* generators: corresponding to the algebraic structure

* try to avoid running over all elements of a domain

* actions: from the right

* arguments of functions: most structured ones usually come first


Create a GAP package
--------------------

* for your research or also for public use

* organize your code, data, documentation, test files, ...

* start by
   * copying an existing GAP package and then adjusting your copy,
   * or use
     [the PackageMaker package](https://github.com/gap-system/PackageMaker),
   * or follow the documentation in
     [Appendix A of the Example package](http://www.gap-system.org/Manuals/pkg/Example-3.5.1/doc/chap0.html)

* [overview of available GAP packages](https://www.gap-system.org/Packages/packages.html)

