# AIFS

## General

AIFS is a text format for representation of the iterated function systems.

Any .aifs file consists from arbitrary number of blocks (even millions).

Usually one block corresponds to one IFS

One file can include another one using '@@import file_to_include.ext' directive (with relative path).

Every block starts with '@ID:ParendID', where ID and ParendID is unique identifiers of the block and its parent block.

ID can be empty if we not refer to the block from any other.

ParentID can be empty if the block has no parent.

Block can use all definitions from its parent, and can override some of them.

It is possible to call one block from another as a function by ID. In that case the first variables in the called block replaced by arguments, and the last variabale is used as return value.

## Constructions inside a block

To perform calculation with numbers and affine maps it is possible to use ordinary operations like '+', '-', '*', '/', '^' and brackets.

For numbers 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'exp', 'log', 'floor', 'ceil', 'arg' are defined.

Also 'if' function defined: if(cond, val1, val2) is equivalent to (cond>0)?val1:val2 in C-like languages.

Variable with name beginning with '$' symbol is considered as built-in variable and has special meaning. Variable with name beginning with '&' symbol is considered as substitution and recalculated in every place where used. [h1,h2, .., hn] defines vector of elements h1,h2, .., hn Vector can be indexed by '[]' operator (from zero) Vector with appropriate length can be automatically converted to the matrix or to the translation. [t1,t2, .., tn] (when$dim=n) - translation in $R^n$

$x_1,x_2,..x_n =\gt x_1+t_1, x_2+t_2, .... x_n+t_n$

[a11,a12, .., a1n, .., an1,an2, .., ann] (when $dim=n) - linear map in $R^n$ \begin{pmatrix} x'_1 \\ x'_2 \\ \cdots \\ x'_n \\ \end{pmatrix} = \begin{vmatrix} a_{11} & a_{12} & \cdots &a_{1n} \\ a_{21} & a_{22} & \cdots &a_{2n} \\ \cdots \\ a_{n1} & a_{n2} & \cdots &a_{nn} \\ \end{vmatrix} \begin{pmatrix} x_1 \\ x_2 \\ \cdots \\ x_n \\ \end{pmatrix} f1*f2*..*fn - composition $x =\gt f_1(f_2(..(f_n(x)..))$ S1 | S2 | ..| Sm - union of the sets $S_1, S_2, ...S_m$ f^n=f(f(f(...))) composition f with itself (n times) f^-1 inverse map$n=...

user-defined name of the IFS

$a=... attributes, can be c(hecked) and/or h(hidden)$dim=n

Algebraic dimension where all affine maps of the IFS have rational entries only.

if $subspace is not used, then equal to dimension of the Euclidean space $R^n$ where IFS will be generated.$subspace=M i1 i2 ...

Invariant subspace of the matrix M where IFS will be generated

i1, i2, ... - indices of the blocks from Real Jordan Form of M

Resulting subspace is a product of the subspaces that corresponds to the blocks

If omitted, then whole space ($dim) used.$diagonal([a0, a1, a2,..., a_n-1 ])

\begin{vmatrix} a_0 & 0 & \cdots &0 \\ 0 & a_1 & \cdots &0 \\ \cdots \\ 0 & 0 & \cdots &a_{n-1} \\ \end{vmatrix}

$companion([a0, a1, a2,..., a_n-1 ]) Companion matrix for $a_0+a_1*x+a_2*x^2+....a_{n-1}*x^{n-1}+x^n$ \begin{vmatrix} 0 & 0 & \cdots &-a_0 \\ 1 & 0 & \cdots &-a_1 \\ \cdots \\ 0 & 0 & \cdots &-a_{n-1} \\ \end{vmatrix}$exchange()

\begin{vmatrix} 0 & 0 & \cdots &0 &1 \\ 0 & 0 & \cdots &1 &0 \\ \cdots \\ 0 & 1 & \cdots &0 &0 \\ 1 & 0 & \cdots &0 &0 \\ \end{vmatrix}

$e - empty set$i - identity map

$semigroup([g1,g2,...gm], T) - element of Semigroup $g_1,g_2.. g_m$- generators T - [optional]$integer that represents length of the elements for infinite semigroups

$vector(L, T) - vector of numbers L - length of the vector (0 - default =$dim)

T - [optional] type of the numbers ($integer or$real)

$number(T) - number T - [optional] type of the number ($integer or $real)$real(a,b), $integer(a,b) - type representation for real or integer numbers from a to b$real(v), $integer(v) - type representation for real or integer numbers with (half-)normal distribution abs(v) - variance if v<0 then distribution is normal if v>0 then distribution is half-normal$semigroup, $number, and$vector can be used as templates for IFS variation (automatically, or manually in editor)

Below you can see several representations of the Pentadentrite

Exact forms can be used for automatically searching different variations.

@
$n=Pentadentrite$dim=2
h0=[0,0]*[0.341063,-0.0713672,0.0713672,0.341063]
h1=[0.341063,0.0713672]*[0.03752,-0.346424,0.346424,0.03752]
h2=[0.378583,0.417791]*[0.341063,-0.0713672,0.0713672,0.341063]
h3=[0.719646,0.489158]*[-0.233977,0.258209,-0.258209,-0.233977]
h4=[0.485669,0.230949]*[0.173268,0.302316,-0.302316,0.173268]
h5=[0.658937,-0.0713672]*[0.341063,-0.0713672,0.0713672,0.341063]
A=h0*A|h1*A|h2*A|h3*A|h4*A|h5*A


## Pentadentrite by translations and rotations (exact, searchable)

@G
$a=h$dim=4
$subspace=s 0 s=$companion([1,-1,1,-1])
g=3+s^2+s^6+s^8
h0=T
h1=T
h2=T
h3=T
h4=T
h5=T
&T=$semigroup([s])*$vector(0)
A=g^-1*(h0|h1|h2|h3|h4|h5)*A

@:G
$n=Pentadentrite h0=[0,0,0,0] h1=s^2*[0,0,0,-1] h2=[1,0,1,0] h3=s^6*[-2,1,-2,2] h4=s^8*[-1,1,1,0] h5=[2,-1,1,-1]  ## Pentadentrite as a curve (exact, searchable) @G$a=h
$dim=4$subspace=s 0
s=$companion([1,-1,1,-1]) k=$vector(6,$integer(0,9)) v=[1,0,0,0] u=v*0 s0=s^k[0] s1=s^k[1] s2=s^k[2] s3=s^k[3] s4=s^k[4] s5=s^k[5] t0=1 t1=(s0*u+1)*t0 t2=(s1*u+1)*t1 t3=(s2*u+1)*t2 t4=(s3*u+1)*t3 t5=(s4*u+1)*t4 h0=t0*s0 h1=t1*s1 h2=t2*s2 h3=t3*s3 h4=t4*s4 h5=t5*s5 g=s0+s1+s2+s3+s4+s5 A=g^-1*(h0|h1|h2|h3|h4|h5)*A @:G$n=Pentadentrite
k=[7,9,7,3,5,7]


## Example of user-defined functions

Blocks in the example below can be called as a function from another blocks:

v1 = scale3d(kx, ky, kz)

v2 = rotate3d([0,0,-1],90)

@scale3d
kx=1
ky=1
kz=1
ret=[kx,0,0,0,ky,0,0,0,kz]

@rotate3d
q=[0,0,1]
ang=0
k1=1
k2=1