Grammar for the syntax of mathematical expressions.
A mathematical expression is an instance of Math:
dataMath=
Symbol
| Integer
| Application
| Abstraction
| PiType
| Fst
| Snd
| Pair
| SigmaType
data PiType =
PiType(
local: Optional Symbol,
domain: Math,
range: Math)
data Fst = Fst
( pair: Math)
data Snd = Snd(
pair: Math)
data Pair =
Pair(
local: Optional Symbol,
fst: Math,
snd: Math,
sndtype: Optional Math)
data SigmaType =
SigmaType(
local: Optional Symbol},
fsttype: Math,
sndtype: Math)
Description
An impression of the terms of the formal
system and their use.
Basic expressions are Symbols and
Integers.
Functions:
Application
is used to apply a function to an argument.
Application( function =f, argument=a)
denotes the application of the function f to argument
a.
Abstraction is used to create a function from a
variable x with type T and a body Bx.
Abstraction( local= x, domain=T, body=Bx) represents the map x
-> Bx. For constant functions the localx can be left out, since it does not occur in the bodyBx.
PiType is a general function
type. The expression
PiType( local=x, domain=T, range=Ux)
denotes the type of functions which map arguments x
of type T to results of type Ux. Occurrences
of x in Ux indicate dependencies of the type
of the result on the argument. Thus for representing ordinary function
types like int -> int the localx can
be left out, because there are no such dependencies.
Pairs:
Fst is used to access the first element of
a pair.
Fst( pair=p)
denotes the first element of pair p.
Snd is used
to access the second element of a pair.
Snd(
pair=p)
denotes the second element of pair
p.
Pair is used to create a pair.
Pair( local=x, fst=f, snd=g, sndtype=Tx)
denotes the
pair (f,g) where g has type
Tx. Occurrences of x in Tx
indicate dependencies of Tx on f. For
representing ordinary pairs like (1,4) the localx and sndtypeTx can be left out.
SigmaType is a general type for pairs. The expression
SigmaType( local=x, fsttype=T,
sndtype=Ux)
denotes the type of a pair with a
first element of type T and a second element of type
Ux. Occurrences of x in Ux
refer to the first element of the pair. For representing ordinary
products like int x int, the localx
can be left out.