# 13.2 Definitions¶

The syntax for defining a domain constructor is the same as for any function in FriCAS:

DomainForm : Exports == Implementation

As this definition usually extends over many lines, a where expression is generally used instead. where

A recommended format for the definition of a domain is:
DomainForm : Exports == Implementation where optional type declarations Exports == [ Category Assertions] with list of exported operations Implementation == [ Add Domain] add [Rep := Representation] list of function definitions for exported operations

Note: The brackets [ ] here denote optionality.

A complete domain constructor definition for QuadraticForm is shown below. Interestingly, this little domain illustrates all the new concepts you need to learn.

)abbrev domain QFORM QuadraticForm
++ Description:
++   This domain provides modest support for
QuadraticForm(n, K): Exports == Implementation where
n: PositiveInteger
K: Field
Exports == AbelianGroup with                --The exports
quadraticForm: SquareMatrix(n,K) -> $--export this ++ \\bs{}axiom\\{quadraticForm(m)\\} creates a quadratic ++ quadratic form from a symmetric, ++ square matrix \\bs{}axiom\\{m\\}. matrix:$ -> SquareMatrix(n,K)           -- export matrix
++ \\bs{}axiom\\{matrix(qf)\\} creates a square matrix
++ from the quadratic form \\bs{}axiom\\{qf\\}.
elt: ( $, DirectProduct(n,K)) -> K -- export elt ++ \\bs{}axiom\\{qf(v)\\} evaluates the quadratic form ++ \\bs{}axiom\\{qf\\} on the vector \\bs{}axiom\\{v\\}, ++ producing a scalar. Implementation == SquareMatrix(n,K) add --The exports Rep := SquareMatrix(n,K) --representation quadraticForm m == --definition not symmetric? m => error "quadraticForm requires a symmetric matrix" m ::$
matrix q == q :: Rep                      --definition
elt(q,v) == dot(v, (matrix q * v))        --definition