\documentclass[12pt]{cdblatex}
\usepackage{fancyhdr}
\usepackage{footer}

\begin{document}

% =================================================================================================
% create checkpoint file

\bgroup
\CdbSetup{action=hide}
\begin{cadabra}
   import cdblib
   checkpoint_file = 'tests/semantic/output/genGamma.json'
   cdblib.create (checkpoint_file)
   checkpoint = []
\end{cadabra}
\egroup

% =================================================================================================
\section*{The generalised connections}

The generalised connections may be computed recursively using
\begin{align}
   \label{eq:GenGamma}
\Gamma^{a}{}_{b\uc d} = \Gamma^{a}{}_{(b\uc,d)}
                - (n+1) \Gamma^{a}{}_{p(\uc}
                        \Gamma^{p}{}_{bd)}
\end{align}
where $\uc$ contains $n>0$ indices. The sequence begins with the standard metric compatible connection
\begin{align}
   \Gamma^{d}_{ab} = \frac{1}{2} g^{dc}\left( g_{cb,a} + g_{ac,b} - g_{ab,c} \right)
\end{align}

Here we will use the results of {\tt metric.tex} and {\tt metric-inv.tex} to compute the metric connection
$\Gamma^{d}_{ab}$. But since the $g_{ab}$ and $g^{ab}$ provided by those codes are truncated at a
particular order in the curvatures (and thus are only approximations to the $g_{ab}$ and $g^{ab}$) similar
truncations will arise in the $\Gamma^{a}{}_{b\uc d}$.

Approximations will be denoted by the addition of an overbar to an object. In this notation the metric
$g$ can be written as
\begin{align}
   g = {\bar g} + \BigO{\eps^n}
\end{align}
in which ${\bar g}$ is the truncated polynomial approximation to $g$ and $\BigO{\eps^n}$ is the error term
(containing terms no smaller than $\eps^n$). The polynomial structure of ${\bar g}$ can be expressed as
\begin{align}
   \gabBar = \ngabBar{0}
           + \ngabBar{1}
           + \ngabBar{2}
           + \dots
           + \ngabBar{p}
\end{align}
in which each terms like $\overset{m}{\bar g}$ contains only terms of order $m$. This notation will be applied
to other quantities in particular the generalised connections.

The notation $\BigO{\eps^n}$ denotes terms in the curvatures that are of order $\eps^n$. What does this actually mean?
Each term in $R$ is of order $\eps^2$ while each derivative of $R$ carries an extra power of $\eps$.
Thus $R\cdot R = \BigO{\eps^4}$, $R\cdot R\cdot\nabla R = \BigO{\eps^7}$ and $R\cdot R\cdot\nabla^2R = \BigO{\eps^8}$.

We will also adopt the convention that an object is said to be an $\BigO{\eps^{m}}$ approximation when the corresponding error term is $\BigO{\eps^{m+1}}$.

Consider the $\BigO{\eps^{m}}$ approximation of the generalised connection, namely,
\begin{align}
   \GammaBar^{a}{}_{b\ucn d}
      = \nGammaBar{0}^{a}{}_{b\ucn d}
      + \nGammaBar{1}^{a}{}_{b\ucn d}
      + \nGammaBar{2}^{a}{}_{b\ucn d}
      + \dots
      + \nGammaBar{m}^{a}{}_{b\ucn d}
\end{align}
where $\ucn$ denotes a set of indices such as $c_1c_2c_3\dots c_n$.

The first thing to note is that
\begin{align}
   0 = \nGammaBar{1+n}^{a}{}_{(b\ucn,d)}
\end{align}

There are two proofs of this claim. For the first proof, note (by inspection) that the order $\BigO{\eps^p}$
approximation for $\GammaBar^{a}{}_{b\ucn d}$ is a polynomial in $x$ of degree $p-n-1$. Thus
$\nGammaBar{1+n}^{a}{}_{(b\ucn,d)}$ is a polynomial in $x$ of degree
zero, i.e., a constant. However, we know that all generalised connections vanish at the origin of the RNC frame.
Thus this constant must be zero. The second proof makes explicit use of the first (and second?) Bianchi identity,
that is $0=R_{a(bcd)}$. The term $\nGammaBar{1+n}^{a}{}_{(b\ucn,d)}$ will
itself consist of a sum of terms built from combinations of $x$, $R$, $\nabla R$ etc. The $x^{a}$ will always
appear in a contraction with one of the indices on $R_{abcd}$ or one of its derivatives. Consider any one of
these terms, denoted by $A$, and assume for the moment that $1+n$ is an even number, say $1+n=2p$. The indices
$(b\ucn,d)$ must somehow be assigned to the factors that comprise $A$. Our aim is to show that at least one $R$
factor in $A$ will receive 3 of these indices and thus by the Bianchi identities will be zero. If there are too
many $R$ factors then the Bianchi identities will not come into play. So how many $R$ factors can we expect?
Since $A$ is a term in an $\BigO{\eps^{(n+1)}}$ approximation there can be no more than $(n+1)/2=p$ Riemann
factors. There will be at least one $x$ term contracted with one of the $p$ Riemann factors. However, we have
$n+2=2p+1$ indices to distribute amongst the $x$ term and $p$ Riemann factors. One of the indices is a derivative
index and will have nett effect of transferring that index from $x$ to one of the Riemann factors. The remaining
$2p$ indices must be distributed amongst the $p$ Riemann factors. It is not possible to avoid assigning three
indices to at least one of the Riemann factors. Thus, by the Bianchi identity, this $A$ term must vanish. Similar
arguments can be applied to the other cases where the $A$ terms consists of products of $R$ and its derivatives
and in the case where $n+1$ is an odd number. The analysis always comes down to the distribution of the indices
$(b\ucn,d)$ amongst the factors of a typical $A$ term. In all cases the Bianchi identity will enter the play and
force $A$ to be zero.

A corollary of the second proof is that for all $m<n+2$
\begin{align}
   0 = \nGammaBar{m}^{a}{}_{b\ucn d}
\end{align}
The proof follows exactly that of the second proof given above.

We can use the above results to streamline the computation of the generalised connections.
We begin with the formal expression for the $\BigO{\eps^m}$ approximations
\begin{align}
   \Gamma^{a}{}_{bc}
      &= \nGammaBar{2}^{a}{}_{bc}
       + \nGammaBar{3}^{a}{}_{bc}
       + \nGammaBar{4}^{a}{}_{bc}
       + \dots
       + \nGammaBar{m}^{a}{}_{bc}\\
   \Gamma^{a}{}_{b\uc}
      &= \nGammaBar{n+1}^{a}{}_{b\uc}
       + \nGammaBar{n+2}^{a}{}_{b\uc}
       + \nGammaBar{n+3}^{a}{}_{b\uc}
       + \dots
       + \nGammaBar{m}^{a}{}_{b\uc}\\
   \Gamma^{a}{}_{b\uc d}
      &= \nGammaBar{n+2}^{a}{}_{b\uc d}
       + \nGammaBar{n+3}^{a}{}_{b\uc d}
       + \nGammaBar{n+4}^{a}{}_{b\uc d}
       + \dots
       + \nGammaBar{m}^{a}{}_{b\uc d}\label{eq:GenGammaA}
\end{align}
These can be substituted into equation (\ref{eq:GenGamma}) with the result
\def\m{\hskip 4pt}
\begin{align}
   \Gamma^{a}{}_{b\uc d}
      &= \nGammaBar{n+1}^{a}{}_{(b\uc,d)}
       + \nGammaBar{n+2}^{a}{}_{(b\uc,d)}
       + \nGammaBar{n+3}^{a}{}_{(b\uc,d)}
       + \dots
       + \nGammaBar{m}^{a}{}_{(b\uc,d)}
       -(n+1)\left(\m \nGammaBar{n+1}^{a}{}_{p\uc}
                    + \nGammaBar{n+2}^{a}{}_{p\uc}
                    + \nGammaBar{n+3}^{a}{}_{p\uc}
                    + \dots
                    + \nGammaBar{m}^{a}{}_{p\uc}\right)
             \left(   \nGammaBar{2}^{p}{}_{bd}
                    + \nGammaBar{3}^{p}{}_{bd}
                    + \nGammaBar{4}^{p}{}_{bd}
                    + \dots
                    + \nGammaBar{m}^{p}{}_{bd}\right)\label{eq:GenGammaB}
\end{align}
where it is understood that in expanding the pair of bracketed terms in the last result the terms should be
symmetrised over $b\uc d$ and also truncated to terms of order $\BigO{\eps^m}$. Note that the first term
on the right hand side of this equation vanishes by way of the results described above.

Comparing the order $m$ terms in equation (\ref{eq:GenGammaA}) and (\ref{eq:GenGammaB}) leads to the
following equation
\begin{align}
   \nGammaBar{m}^{a}{}_{b\uc d}
   = \nGammaBar{m}^{a}{}_{(b\uc,d)}
   - (n+1)\left(\m \nGammaBar{m-2}^{a}{}_{p(\uc}
                   \nGammaBar{  2}^{p}{}_{bd)}
                  +\nGammaBar{m-3}^{a}{}_{p(\uc}
                   \nGammaBar{  3}^{p}{}_{bd)}
                  +\nGammaBar{m-4}^{a}{}_{p(\uc}
                   \nGammaBar{  4}^{p}{}_{bd)}
                  + \dots
                  + \nGammaBar{  n+1}^{a}{}_{p(\uc}
                    \nGammaBar{m-n-1}^{p}{}_{bd)}
   \right)
   \label{eq:GenGammaC}
\end{align}
This one equation is all that is needed to compute all of the
$\nGammaBar{p}^{a}{}_{b\uc d}$ for $p=3,4,5,\dots m$ given just
the $\nGammaBar{p}^{a}{}_{bd}$ for $p=2,3,4,\dots m$. For example,
suppose $m=5$ and suppose that we are given
$\nGammaBar{p}^{a}{}_{bd}$ for $p=2,3,4,5$. Then with $n=1$ we can
use equation (\ref{eq:GenGammaC}) to compute in turn,
$\nGammaBar{p}^{a}{}_{bc_1d}$ for $p=3,4,5$. Then with $n=2$ we
compute
$\nGammaBar{p}^{a}{}_{bc_1c_2d}$ for $p=4,5$ and finally with $n=3$
we compute $\nGammaBar{p}^{a}{}_{bc_1c_2c_3d}$ for $p=5$. There
are no terms like
$\nGammaBar{p}^{a}{}_{bc_1c_2c_3c_4d}$ for $p\le5$ due to the
corollary given earlier.

\clearpage

The explicit computations for $m=5$ are as follows.

For $n=1$,
\begin{align}
   \nGammaBar{3}^{a}{}_{bc_1d}
   &=
   \nGammaBar{3}^{a}{}_{(bc_1,d)}\\
   %-----------------------------------------------------------------------
   \nGammaBar{4}^{a}{}_{bc_1d}
   &=
   \nGammaBar{4}^{a}{}_{(bc_1,d)}
   - 2 \nGammaBar{2}^{a}{}_{p(c_1}
       \nGammaBar{2}^{p}{}_{bd)}\\
   %-----------------------------------------------------------------------
   \nGammaBar{5}^{a}{}_{bc_1d}
   &=
   \nGammaBar{5}^{a}{}_{(bc_1,d)}
   - 2 \nGammaBar{3}^{a}{}_{p(c_1}
       \nGammaBar{2}^{p}{}_{bd)}
   - 2 \nGammaBar{2}^{a}{}_{p(c_1}
       \nGammaBar{3}^{p}{}_{bd)}
\end{align}

For $n=2$,
\begin{align}
   \nGammaBar{4}^{a}{}_{bc_1c_2d}
   &=
   \nGammaBar{4}^{a}{}_{(bc_1c_2,d)}\\
   %-----------------------------------------------------------------------
   \nGammaBar{5}^{a}{}_{bc_1c_2d}
   &=
   \nGammaBar{5}^{a}{}_{(bc_1c_2,d)}
   - 3 \nGammaBar{2}^{a}{}_{p(c_1c_2}
       \nGammaBar{2}^{p}{}_{bd)}
\end{align}

For $n=3$,
\begin{align}
   \nGammaBar{5}^{a}{}_{bc_1c_2c_3d}
   &=
   \nGammaBar{5}^{a}{}_{(bc_1c_2c_3,d)}
\end{align}

\clearpage

\begin{cadabra}
   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,c1,c2,c3,c4,c5,w#}::Indices(position=independent).

   D{#}::Derivative.
   \nabla{#}::Derivative.
   \partial{#}::PartialDerivative.

   g_{a b}::Metric.
   g^{a b}::InverseMetric.
   g_{a}^{b}::KroneckerDelta.
   g^{a}_{b}::KroneckerDelta.
   \delta^{a}_{b}::KroneckerDelta.
   \delta_{a}^{b}::KroneckerDelta.

   R_{a b c d}::RiemannTensor.
   R^{a}_{b c d}::RiemannTensor.
   R_{a b c}^{d}::RiemannTensor.

   \Gamma^{a}_{b c}::TableauSymmetry(shape={2}, indices={1,2}).

   x^{a}::Depends(D{#}).

   g_{a b}::Depends(\partial{#}).
   R_{a b c d}::Depends(\partial{#}).
   R^{a}_{b c d}::Depends(\partial{#}).
   \Gamma^{a}_{b c}::Depends(\partial{#}).

   R_{a b c d}::Depends(\nabla{#}).
   R^{a}_{b c d}::Depends(\nabla{#}).

   import cdblib

   term0 = cdblib.get ('GammaRterm0','connection.json')
   term1 = cdblib.get ('GammaRterm2','connection.json')
   term2 = cdblib.get ('GammaRterm3','connection.json')
   term3 = cdblib.get ('GammaRterm4','connection.json')
   term4 = cdblib.get ('GammaRterm5','connection.json')

   # LCB: these terms were not computed in connection.tex so set them to zero
   #      maybe in the future I will compute down to term6.

   term5 := 0.
   term6 := 0.

   # genGmn : m = eps order of Rabcd terms
   #          n = number of c indices

   # --------------------------------------------------------------------------
   # rules for building the genGmn

   # note: after applying each rule, must symmetrise over (b c1 c2 ... cn d)

   # n = 0

   genG20 := genG2^{a}_{b d}.
   genG30 := genG3^{a}_{b d}.
   genG40 := genG4^{a}_{b d}.
   genG50 := genG5^{a}_{b d}.

   defG20 := genG2^{d}_{a b} -> @(term1).
   defG30 := genG3^{d}_{a b} -> @(term2).
   defG40 := genG4^{d}_{a b} -> @(term3).
   defG50 := genG5^{d}_{a b} -> @(term4).

   # LCB: rncGamma in connection.json limited to "term4" (ie. to 4th order in x)
   #      so can only compute genG3*, genG4* and genG5* (at this stage)
   #      but it doesn't hurt to provide the definitions for genG6*, genG7* etc. we just won't use them (at this atage)

   defG60 := genG6^{d}_{a b} -> @(term5).
   defG70 := genG7^{d}_{a b} -> @(term6).

   # n = 1

   defG31 := genG3^{a}_{b c1 d} -> D_{d}{genG3^{a}_{b c1}}.

   defG41 := genG4^{a}_{b c1 d} -> D_{d}{genG4^{a}_{b c1}}
                                   - 2 genG2^{a}_{p c1} genG2^{p}_{b d}.

   defG51 := genG5^{a}_{b c1 d} -> D_{d}{genG5^{a}_{b c1}}
                                   - 2 genG3^{a}_{p c1} genG2^{p}_{b d}
                                   - 2 genG2^{a}_{p c1} genG3^{p}_{b d}.

   defG61 := genG6^{a}_{b c1 d} -> D_{d}{genG6^{a}_{b c1}}
                                   - 2 genG4^{a}_{p c1} genG2^{p}_{b d}
                                   - 2 genG3^{a}_{p c1} genG3^{p}_{b d}
                                   - 2 genG3^{a}_{p c1} genG4^{p}_{b d}.

   defG71 := genG7^{a}_{b c1 d} -> D_{d}{genG7^{a}_{b c1}}
                                   - 2 genG5^{a}_{p c1} genG2^{p}_{b d}
                                   - 2 genG4^{a}_{p c1} genG3^{p}_{b d}
                                   - 2 genG3^{a}_{p c1} genG4^{p}_{b d}
                                   - 2 genG2^{a}_{p c1} genG5^{p}_{b d}.

   # n = 2

   defG42 := genG4^{a}_{b c1 c2 d} -> D_{d}{genG4^{a}_{b c1 c2}}.

   defG52 := genG5^{a}_{b c1 c2 d} -> D_{d}{genG5^{a}_{b c1 c2}}
                                      - 3 genG3^{a}_{p c1 c2} genG2^{p}_{b d}.

   defG62 := genG6^{a}_{b c1 c2 d} -> D_{d}{genG6^{a}_{b c1 c2}}
                                      - 3 genG4^{a}_{p c1 c2} genG2^{p}_{b d}
                                      - 3 genG3^{a}_{p c1 c2} genG3^{p}_{b d}.

   defG72 := genG7^{a}_{b c1 c2 d} -> D_{d}{genG7^{a}_{b c1 c2}}
                                      - 3 genG5^{a}_{p c1 c2} genG2^{p}_{b d}
                                      - 3 genG4^{a}_{p c1 c2} genG3^{p}_{b d}
                                      - 3 genG3^{a}_{p c1 c2} genG4^{p}_{b d}.

   # n = 3

   defG53 := genG5^{a}_{b c1 c2 c3 d} -> D_{d}{genG5^{a}_{b c1 c2 c3}}.

   defG63 := genG6^{a}_{b c1 c2 c3 d} -> D_{d}{genG6^{a}_{b c1 c2 c3}}
                                         - 4 genG3^{a}_{p c1 c2 c3} genG3^{p}_{b d}.

   defG73 := genG7^{a}_{b c1 c2 c3 d} -> D_{d}{genG7^{a}_{b c1 c2 c3}}
                                         - 4 genG4^{a}_{p c1 c2 c3} genG3^{p}_{b d}
                                         - 4 genG3^{a}_{p c1 c2 c3} genG4^{p}_{b d}.

   # n = 4

   defG64 := genG6^{a}_{b c1 c2 c3 c4 d} -> D_{d}{genG6^{a}_{b c1 c2 c3 c4}}.

   defG74 := genG7^{a}_{b c1 c2 c3 c4 d} -> D_{d}{genG7^{a}_{b c1 c2 c3 c4}}
                                            - 5 genG5^{a}_{p c1 c2 c3 c4} genG2^{p}_{b d}.

   # n = 5

   defG75 := genG7^{a}_{b c1 c2 c3 c4 c5 d} -> D_{d}{genG7^{a}_{b c1 c2 c3 c4 c5}}.

   # --------------------------------------------------------------------------
   # build the genGmn

   # ==========================================================================
   # n = 1

   genG31 := genG3^{a}_{b c1 d}.                              # cdb (genG31.000,genG31)
   genG41 := genG4^{a}_{b c1 d}.                              # cdb (genG41.000,genG41)
   genG51 := genG5^{a}_{b c1 d}.
   # genG61 := genG6^{a}_{b c1 d}.
   # genG71 := genG7^{a}_{b c1 d}.

   # --------------------------------------------------------------------------
   substitute     (genG20,defG20)                             # cdb (genG20.001,genG20)
   substitute     (genG30,defG30)                             # cdb (genG30.001,genG30)
   substitute     (genG40,defG40)                             # cdb (genG40.001,genG40)
   substitute     (genG50,defG50)                             # cdb (genG50.001,genG50)

   # --------------------------------------------------------------------------
   substitute     (genG31,defG31)                             # cdb (genG31.001,genG31)
   substitute     (genG31,defG30)                             # cdb (genG31.002,genG31)

   distribute     (genG31)                                    # cdb (genG31.002,genG31)
   unwrap         (genG31)                                    # cdb (genG31.003,genG31)
   product_rule   (genG31)                                    # cdb (genG31.004,genG31)
   distribute     (genG31)                                    # cdb (genG31.005,genG31)
   substitute     (genG31,$D_{a}{x^b}->\delta_{a}^{b}$)       # cdb (genG31.006,genG31)
   eliminate_kronecker (genG31)                               # cdb (genG31.007,genG31)
   sym            (genG31,$_{b}, _{c1}, _{d}$)
   sort_product   (genG31)                                    # cdb (genG31.008,genG31)
   rename_dummies (genG31)                                    # cdb (genG31.009,genG31)
   canonicalise   (genG31)                                    # cdb (genG31.010,genG31)

   # --------------------------------------------------------------------------
   substitute     (genG41,defG41)                             # cdb (genG41.001,genG41)
   substitute     (genG41,defG40)                             # cdb (genG41.002,genG41)
   substitute     (genG41,defG20,repeat=True)                 # cdb (genG41.003,genG41)

   distribute     (genG41)                                    # cdb (genG41.004,genG41)
   unwrap         (genG41)                                    # cdb (genG41.005,genG41)
   product_rule   (genG41)                                    # cdb (genG41.006,genG41)
   distribute     (genG41)                                    # cdb (genG41.007,genG41)
   substitute     (genG41,$D_{a}{x^b}->\delta_{a}^{b}$)       # cdb (genG41.008,genG41)
   eliminate_kronecker (genG41)                               # cdb (genG41.009,genG41)
   sym            (genG41,$_{b}, _{c1}, _{d}$)
   sort_product   (genG41)                                    # cdb (genG41.010,genG41)
   rename_dummies (genG41)                                    # cdb (genG41.011,genG41)
   canonicalise   (genG41)                                    # cdb (genG41.012,genG41)

   # --------------------------------------------------------------------------
   substitute     (genG51,defG51)
   substitute     (genG51,defG50)
   substitute     (genG51,defG30,repeat=True)
   substitute     (genG51,defG20,repeat=True)

   distribute     (genG51)
   unwrap         (genG51)
   product_rule   (genG51)
   distribute     (genG51)
   substitute     (genG51,$D_{a}{x^b}->\delta_{a}^{b}$)
   eliminate_kronecker (genG51)
   sym            (genG51,$_{b}, _{c1}, _{d}$)
   sort_product   (genG51)
   rename_dummies (genG51)
   canonicalise   (genG51)

   # update the rules

   defG31 := genG3^{a}_{b c1 d} -> @(genG31).
   defG41 := genG4^{a}_{b c1 d} -> @(genG41).
   defG51 := genG5^{a}_{b c1 d} -> @(genG51).

   # ==========================================================================
   # n = 2

   genG42 := genG4^{a}_{b c1 c2 d}.                           # cdb (genG42.000,genG42)
   genG52 := genG5^{a}_{b c1 c2 d}.
   # genG62 := genG6^{a}_{b c1 c2 d}.
   # genG72 := genG7^{a}_{b c1 c2 d}.

   # --------------------------------------------------------------------------
   substitute     (genG42,defG42)                             # cdb (genG42.001,genG42)
   substitute     (genG42,defG41)                             # cdb (genG42.002,genG42)

   distribute     (genG42)                                    # cdb (genG42.003,genG42)
   unwrap         (genG42)                                    # cdb (genG42.004,genG42)
   product_rule   (genG42)                                    # cdb (genG42.005,genG42)
   distribute     (genG42)                                    # cdb (genG42.006,genG42)
   substitute     (genG42,$D_{a}{x^b}->\delta_{a}^{b}$)       # cdb (genG42.007,genG42)
   eliminate_kronecker (genG42)                               # cdb (genG42.008,genG42)
   sym            (genG42,$_{b}, _{c1}, _{c2}, _{d}$)
   sort_product   (genG42)                                    # cdb (genG42.009,genG42)
   rename_dummies (genG42)                                    # cdb (genG42.010,genG42)
   canonicalise   (genG42)                                    # cdb (genG42.011,genG42)

   # --------------------------------------------------------------------------
   substitute     (genG52,defG52)
   substitute     (genG52,defG51)
   substitute     (genG52,defG31,repeat=True)
   substitute     (genG52,defG20,repeat=True)

   distribute     (genG52)
   unwrap         (genG52)
   product_rule   (genG52)
   distribute     (genG52)
   substitute     (genG52,$D_{a}{x^b}->\delta_{a}^{b}$)
   eliminate_kronecker (genG52)
   sym            (genG52,$_{b}, _{c1}, _{c2}, _{d}$)
   sort_product   (genG52)
   rename_dummies (genG52)
   canonicalise   (genG52)                                    # cdb (genG52.001,genG52)

   # update the rules

   defG42 := genG4^{a}_{b c1 c2 d} -> @(genG42).
   defG52 := genG5^{a}_{b c1 c2 d} -> @(genG52).

   # ==========================================================================
   # n = 3

   genG53 := genG5^{a}_{b c1 c2 c3 d}.
   # genG63 := genG6^{a}_{b c1 c2 c3 d}.
   # genG73 := genG7^{a}_{b c1 c2 c3 d}.

   # --------------------------------------------------------------------------
   substitute     (genG53,defG53)
   substitute     (genG53,defG52)

   distribute     (genG53)
   unwrap         (genG53)
   product_rule   (genG53)
   distribute     (genG53)
   substitute     (genG53,$D_{a}{x^b}->\delta_{a}^{b}$)
   eliminate_kronecker (genG53)
   sym            (genG53,$_{b}, _{c1}, _{c2}, _{c3}, _{d}$)
   sort_product   (genG53)
   rename_dummies (genG53)
   canonicalise   (genG53)                                    # cdb (genG53.001,genG53)

   # update the rules

   defG53 := genG5^{a}_{b c1 c2 c3 d} -> @(genG53).

\end{cadabra}

\clearpage

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{genG31.000} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.001} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.002} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.003} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.004} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.005} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.006} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.007} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.008} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.009} \end{dmath*}
   \begin{dmath*} \cdb*{genG31.010} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{genG41.000} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.001} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.002} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.003} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.004} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.005} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.006} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.007} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.008} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.009} \end{dmath*}
   % \begin{dmath*} \cdb*{genG41.010} \end{dmath*}
   % \begin{dmath*} \cdb*{genG41.011} \end{dmath*}
   \begin{dmath*} \cdb*{genG41.012} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{genG42.000} \end{dmath*}
   \begin{dmath*} \cdb*{genG42.001} \end{dmath*}
   \begin{dmath*} \cdb*{genG42.002} \end{dmath*}
   \begin{dmath*} \cdb*{genG42.003} \end{dmath*}
   \begin{dmath*} \cdb*{genG42.004} \end{dmath*}
   \begin{dmath*} \cdb*{genG42.005} \end{dmath*}
   % \begin{dmath*} \cdb*{genG42.006} \end{dmath*}
   % \begin{dmath*} \cdb*{genG42.007} \end{dmath*}
   % \begin{dmath*} \cdb*{genG42.008} \end{dmath*}
   % \begin{dmath*} \cdb*{genG42.009} \end{dmath*}
   % \begin{dmath*} \cdb*{genG42.010} \end{dmath*}
   \begin{dmath*} \cdb*{genG42.011} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{cadabra}
   # note: keeping numbering as is (out of order) to ensure R appears before \nabla R etc.
   def product_sort (obj):
       substitute (obj,$ A^{a}                            -> A001^{a}               $)
       substitute (obj,$ x^{a}                            -> A002^{a}               $)
       substitute (obj,$ g^{a b}                          -> A003^{a b}             $)
       substitute (obj,$ \nabla_{e f g h}{R_{a b c d}}    -> A008_{a b c d e f g h} $)
       substitute (obj,$ \nabla_{e f g}{R_{a b c d}}      -> A007_{a b c d e f g}   $)
       substitute (obj,$ \nabla_{e f}{R_{a b c d}}        -> A006_{a b c d e f}     $)
       substitute (obj,$ \nabla_{e}{R_{a b c d}}          -> A005_{a b c d e}       $)
       substitute (obj,$ R_{a b c d}                      -> A004_{a b c d}         $)
       sort_product   (obj)
       rename_dummies (obj)
       substitute (obj,$ A001^{a}                  -> A^{a}                         $)
       substitute (obj,$ A002^{a}                  -> x^{a}                         $)
       substitute (obj,$ A003^{a b}                -> g^{a b}                       $)
       substitute (obj,$ A004_{a b c d}            -> R_{a b c d}                   $)
       substitute (obj,$ A005_{a b c d e}          -> \nabla_{e}{R_{a b c d}}       $)
       substitute (obj,$ A006_{a b c d e f}        -> \nabla_{e f}{R_{a b c d}}     $)
       substitute (obj,$ A007_{a b c d e f g}      -> \nabla_{e f g}{R_{a b c d}}   $)
       substitute (obj,$ A008_{a b c d e f g h}    -> \nabla_{e f g h}{R_{a b c d}} $)

       return obj

   # --------------------------------------------------------------------------
   symG20 := @(genG20) A^{b} A^{d}.                           # cdb (symG20.100,symG20)

   distribute            (symG20)                             # cdb (symG20.101,symG20)
   symG20 = product_sort (symG20)                             # cdb (symG20.102,symG20)
   rename_dummies        (symG20)                             # cdb (symG20.103,symG20)
   canonicalise          (symG20)                             # cdb (symG20.104,symG20)

   # --------------------------------------------------------------------------
   symG30 := @(genG30) A^{b} A^{d}.                           # cdb (symG30.100,symG30)

   distribute            (symG30)                             # cdb (symG30.101,symG30)
   symG30 = product_sort (symG30)                             # cdb (symG30.102,symG30)
   rename_dummies        (symG30)                             # cdb (symG30.103,symG30)
   canonicalise          (symG30)                             # cdb (symG30.104,symG30)

   # --------------------------------------------------------------------------
   symG40 := @(genG40) A^{b} A^{d}.                           # cdb (symG40.100,symG40)

   distribute            (symG40)                             # cdb (symG40.101,symG40)
   symG40 = product_sort (symG40)                             # cdb (symG40.102,symG40)
   rename_dummies        (symG40)                             # cdb (symG40.103,symG40)
   canonicalise          (symG40)                             # cdb (symG40.104,symG40)

   # --------------------------------------------------------------------------
   symG50 := @(genG50) A^{b} A^{d}.                           # cdb (symG50.100,symG50)

   distribute            (symG50)                             # cdb (symG50.101,symG50)
   symG50 = product_sort (symG50)                             # cdb (symG50.102,symG50)
   rename_dummies        (symG50)                             # cdb (symG50.103,symG50)
   canonicalise          (symG50)                             # cdb (symG50.104,symG50)

   # --------------------------------------------------------------------------
   symG31 := @(genG31) A^{b} A^{c1} A^{d}.                    # cdb (symG31.100,symG31)

   distribute            (symG31)                             # cdb (symG31.101,symG31)
   symG31 = product_sort (symG31)                             # cdb (symG31.102,symG31)
   rename_dummies        (symG31)                             # cdb (symG31.103,symG31)
   canonicalise          (symG31)                             # cdb (symG31.104,symG31)

   # --------------------------------------------------------------------------
   symG41 := @(genG41) A^{b} A^{c1} A^{d}.                    # cdb (symG41.100,symG41)

   distribute            (symG41)                             # cdb (symG41.101,symG41)
   symG41 = product_sort (symG41)                             # cdb (symG41.102,symG41)
   rename_dummies        (symG41)                             # cdb (symG41.103,symG41)
   canonicalise          (symG41)                             # cdb (symG41.104,symG41)

   # --------------------------------------------------------------------------
   symG51 := @(genG51) A^{b} A^{c1} A^{d}.                    # cdb (symG51.100,symG51)

   distribute            (symG51)                             # cdb (symG51.101,symG51)
   symG51 = product_sort (symG51)                             # cdb (symG51.102,symG51)
   rename_dummies        (symG51)                             # cdb (symG51.103,symG51)
   canonicalise          (symG51)                             # cdb (symG51.104,symG51)

   # --------------------------------------------------------------------------
   symG42 := @(genG42) A^{b} A^{c1} A^{c2} A^{d}.             # cdb (symG42.100,symG42)

   distribute            (symG42)                             # cdb (symG42.101,symG42)
   symG42 = product_sort (symG42)                             # cdb (symG42.102,symG42)
   rename_dummies        (symG42)                             # cdb (symG42.103,symG42)
   canonicalise          (symG42)                             # cdb (symG42.104,symG42)

   # --------------------------------------------------------------------------
   symG52 := @(genG52) A^{b} A^{c1} A^{c2} A^{d}.             # cdb (symG52.100,symG52)

   distribute            (symG52)                             # cdb (symG52.101,symG52)
   symG52 = product_sort (symG52)                             # cdb (symG52.102,symG52)
   rename_dummies        (symG52)                             # cdb (symG52.103,symG52)
   canonicalise          (symG52)                             # cdb (symG52.104,symG52)

   # --------------------------------------------------------------------------
   symG53 := @(genG53) A^{b} A^{c1} A^{c2} A^{c3} A^{d}.      # cdb (symG53.100,symG53)

   distribute            (symG53)                             # cdb (symG53.101,symG53)
   symG53 = product_sort (symG53)                             # cdb (symG53.102,symG53)
   rename_dummies        (symG53)                             # cdb (symG53.103,symG53)
   canonicalise          (symG53)                             # cdb (symG53.104,symG53)

\end{cadabra}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{symG31.100} \end{dmath*}
   \begin{dmath*} \cdb*{symG31.101} \end{dmath*}
   \begin{dmath*} \cdb*{symG31.102} \end{dmath*}
   \begin{dmath*} \cdb*{symG31.103} \end{dmath*}
   \begin{dmath*} \cdb*{symG31.104} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{symG41.100} \end{dmath*}
   \begin{dmath*} \cdb*{symG41.101} \end{dmath*}
   \begin{dmath*} \cdb*{symG41.102} \end{dmath*}
   \begin{dmath*} \cdb*{symG41.103} \end{dmath*}
   \begin{dmath*} \cdb*{symG41.104} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{symG51.104} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{symG42.104} \end{dmath*}
   \begin{dmath*} \cdb*{symG52.104} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{symG53.104} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{cadabra}
   def reformat (obj,scale):
       foo  = Ex(str(scale))
       bah := @(foo) @(obj).
       distribute (bah)
       factor_out (bah,$A^{a?},x^{b?}$)
       ans := @(bah) / @(foo).
       return ans

   fooG20 = reformat (symG20,3)
   fooG30 = reformat (symG30,12)
   fooG40 = reformat (symG40,360)
   fooG50 = reformat (symG50,180)

   fooG31 = reformat (symG31,2)
   fooG41 = reformat (symG41,120)
   fooG51 = reformat (symG51,180)

   fooG42 = reformat (symG42,15)
   fooG52 = reformat (symG52,90)

   fooG53 = reformat (symG53,3)

   genGamma0 := @(fooG20) + @(fooG30) + @(fooG40) + @(fooG50).  # cdb (genGamma0.000,genGamma0)
   genGamma1 := @(fooG31) + @(fooG41) + @(fooG51).              # cdb (genGamma1.000,genGamma1)
   genGamma2 := @(fooG42) + @(fooG52).                          # cdb (genGamma2.000,genGamma2)
   genGamma3 := @(fooG53).                                      # cdb (genGamma3.000,genGamma3)

   cdblib.create ('genGamma.json')

   cdblib.put ('genGamma0',genGamma0,'genGamma.json')
   cdblib.put ('genGamma1',genGamma1,'genGamma.json')
   cdblib.put ('genGamma2',genGamma2,'genGamma.json')
   cdblib.put ('genGamma3',genGamma3,'genGamma.json')

   cdblib.put ('genGamma01',fooG20,'genGamma.json')
   cdblib.put ('genGamma02',fooG30,'genGamma.json')
   cdblib.put ('genGamma03',fooG40,'genGamma.json')
   cdblib.put ('genGamma04',fooG50,'genGamma.json')

   cdblib.put ('genGamma11',fooG31,'genGamma.json')
   cdblib.put ('genGamma12',fooG41,'genGamma.json')
   cdblib.put ('genGamma13',fooG51,'genGamma.json')

   cdblib.put ('genGamma21',fooG42,'genGamma.json')
   cdblib.put ('genGamma22',fooG52,'genGamma.json')

   cdblib.put ('genGamma31',fooG53,'genGamma.json')

\end{cadabra}

\clearpage

% =================================================================================================
\section*{The generalised connection in Riemann normal coordinates}

\begin{dgroup*}
   \begin{dmath*} A^b A^c \Gamma^{a}_{b c}(x) = \cdb{genGamma0.000} \end{dmath*}
   \begin{dmath*} A^b A^c A^d \Gamma^{a}_{b c d}(x) = \cdb{genGamma1.000} \end{dmath*}
   \begin{dmath*} A^b A^c A^d A^e \Gamma^{a}_{b c d e}(x) = \cdb{genGamma2.000} \end{dmath*}
   \begin{dmath*} A^b A^c A^d A^e A^f \Gamma^{a}_{b c d e f}(x) = \cdb{genGamma3.000} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{cadabra}
   scaledGamma0 := 360 @(genGamma0).  # cdb (scaledGamma0.001,scaledGamma0)
   scaledGamma1 := 360 @(genGamma1).  # cdb (scaledGamma1.001,scaledGamma1)
   scaledGamma2 :=  90 @(genGamma2).  # cdb (scaledGamma2.001,scaledGamma2)
   scaledGamma3 :=   3 @(genGamma3).  # cdb (scaledGamma3.001,scaledGamma3)

\end{cadabra}

\clearpage

% =================================================================================================
\section*{The generalised connection in Riemann normal coordinates}

This is the same as the previous page but with a small change in the format to avoid fractions.

\begin{dgroup*}
   \begin{dmath*} 360 A^b A^c \Gamma^{a}_{b c}(x) = \cdb{scaledGamma0.001} \end{dmath*}
   \begin{dmath*} 360 A^b A^c A^d \Gamma^{a}_{b c d}(x) = \cdb{scaledGamma1.001} \end{dmath*}
   \begin{dmath*}  90 A^b A^c A^d A^e \Gamma^{a}_{b c d e}(x) = \cdb{scaledGamma2.001} \end{dmath*}
   \begin{dmath*}   3 A^b A^c A^d A^e A^f \Gamma^{a}_{b c d e f}(x) = \cdb{scaledGamma3.001} \end{dmath*}
\end{dgroup*}

\clearpage

% =================================================================================================
% export selected objects, these will later be imported into a library
% these are the objects that will appear in the paper

\begin{cadabra}
   tmp0 := @(fooG20) + @(fooG30).
   tmp1 := @(fooG31).

   alt0 := @(genGamma0).
   alt1 := @(genGamma1).
   alt2 := @(genGamma2).
   alt3 := @(genGamma3).

   alt0scaled := @(scaledGamma0).
   alt1scaled := @(scaledGamma1).
   alt2scaled := @(scaledGamma2).
   alt3scaled := @(scaledGamma3).

   substitute (tmp0, $A^{a}->1$)
   substitute (tmp1, $A^{a}->1$)

   substitute (alt0, $A^{a}->1$)
   substitute (alt1, $A^{a}->1$)
   substitute (alt2, $A^{a}->1$)
   substitute (alt3, $A^{a}->1$)

   substitute (alt0scaled, $A^{a}->1$)
   substitute (alt1scaled, $A^{a}->1$)
   substitute (alt2scaled, $A^{a}->1$)
   substitute (alt3scaled, $A^{a}->1$)

   cdblib.create ('genGamma.export')

   # 4th order gen gamma
   cdblib.put ('gen_gamma_0_4th',tmp0,'genGamma.export')
   cdblib.put ('gen_gamma_1_4th',tmp1,'genGamma.export')

   # 6th order gen gamma
   cdblib.put ('gen_gamma_0',alt0,'genGamma.export')
   cdblib.put ('gen_gamma_1',alt1,'genGamma.export')
   cdblib.put ('gen_gamma_2',alt2,'genGamma.export')
   cdblib.put ('gen_gamma_3',alt3,'genGamma.export')

   # 6th order gen gamma scaled
   cdblib.put ('gen_gamma_0_scaled',alt0scaled,'genGamma.export')
   cdblib.put ('gen_gamma_1_scaled',alt1scaled,'genGamma.export')
   cdblib.put ('gen_gamma_2_scaled',alt2scaled,'genGamma.export')
   cdblib.put ('gen_gamma_3_scaled',alt3scaled,'genGamma.export')

   checkpoint.append (tmp0)
   checkpoint.append (tmp1)

   checkpoint.append (alt0)
   checkpoint.append (alt1)
   checkpoint.append (alt2)
   checkpoint.append (alt3)

   checkpoint.append (alt0scaled)
   checkpoint.append (alt1scaled)
   checkpoint.append (alt2scaled)
   checkpoint.append (alt3scaled)

\end{cadabra}

% =================================================================================================
% export checkpoints in json format

\bgroup
\CdbSetup{action=hide}
\begin{cadabra}
   for i in range( len(checkpoint) ):
      cdblib.put ('check{:03d}'.format(i),checkpoint[i],checkpoint_file)
\end{cadabra}
\egroup

\end{document}


\newpage\section{Problems}

		\prob{https://artofproblemsolving.com/community/c6h1291293p6832329}{IRAN 3rd Round 2016 P2}{E}{Let $ABC$ be an arbitrary triangle. Let $E,F$ be two points on $AB,AC$ respectively such that their distance to the midpoint of $BC$ is equal. Let $P$ be the second intersection of the triangles $ABC,AEF$ circumcircles . The tangents from $E,F$ to the circumcircle of $AEF$ intersect each other at $K$. Prove that : $\angle KPA = 90$}

		\prob{https://artofproblemsolving.com/community/c6h1434843p8120660}{IRAN 2nd Round 2016 P6}{E}{Let $ABC$ be a triangle and $X$ be a point on its circumcircle. $Q,P$ lie on a line $BC$ such that $XQ\perp AC , XP\perp AB$. Let $Y$ be the circumcenter of $\triangle XQP$. Prove that $ABC$ is equilateral triangle if and if only $Y$ moves on a circle when $X$ varies on the circumcircle of $ABC$}

		\prob{https://artofproblemsolving.com/community/c6h1460735p8471885}{AoPS}{E}{Consider $ABC$ with orthic triangle $A'B'C'$, let $AA'\cap B'C' = E$ and $E'$ be reflection of $E$ wrt $BC$. Let $M$ be midpoint of $BC$ and $O$ be circumcenter of $E'B'C'$. Let $M'$ be projection of $O$ on $BC$ and $N$ be the intersection of a perpendicular to $B'C'$ through $E$ with $BC$. Prove that $MM' = 1/4MN$.}

		\prob{https://artofproblemsolving.com/community/c6h360730p1973873}{IRAN 3rd Round 2010 D3, P5}{M}{In a triangle $ABC$, $I$ is the incenter. $D$ is the reflection of $A$ to $I$. the incircle is tangent to $BC$ at point $E$. $DE$ cuts $IG$ at $P$ ($G$ is centroid). $M$ is the midpoint of $BC$. Prove that $AP||DM$ and $AP=2DM$.}

		\prob{https://artofproblemsolving.com/community/c6h429226p2428694}{IRAN 3rd Round 2011 G5}{M}{Given triangle $ABC$, $D$ is the foot of the external angle bisector of $A$, $I$ its incenter and $I_a$ its $A$-excenter. Perpendicular from $I$ to $DI_a$ intersects the circumcircle of triangle in $A'$. Define $B'$ and $C'$ similarly. Prove that $AA',BB'$ and $CC'$ are concurrent.}

		\prob{https://artofproblemsolving.com/community/c6t48f6h1519616_geometry}{AoPS3}{E}{$I$ is the incenter of $ABC$,  $PI,QI{\perp}BC$, $PA,QA$ intersect $BC$ at $DE$. Prove: $IADE$ is on a circle.}

			\fig{1}{AoPS3}{AoPS3}

		\prob{https://artofproblemsolving.com/community/c6t48f6h1523774_nice_property}{AoPS4}{E}{Given a triangle $ABC$, the incircle $(I)$ touch $BC,CA,AB$ at $D,E,F$ respectively. Let $AA_1,BB_1,CC_1$ be $A,B,C-altitude$ respectively. Let $N$ be the orthocenter of the triangle $AEF$. Prove that $N$ is the incenter of $AB_1C_1$}

			\fig{1}{AoPS4}{AoPS4}

		\prob{https://artofproblemsolving.com/community/c6h1087613p4817114}{IRAN TST 2015 Day 2, P3}{M}{$ABCD$ is a circumscribed and inscribed quadrilateral. $O$ is the circumcenter of the quadrilateral. $E,\ F$ and $S$ are the intersections of $AB,\ CD$; $AD,\ BC$ and $AC,\ BD$ respectively. $E'$ and $F'$ are points on $AD$ and $AB$ such that $\angle AEE'=\angle E'ED$ and $\angle AFF'=\angle F'FB$. $X$ and $Y$ are points on $OE'$ and $OF'$ such that $\frac{XA}{XD}=\frac{EA}{ED}$ and $\frac{YA}{YB}=\frac{FA}{FB}$. $M$ is the midpoint of arc $BD$ of $(O)$ which contains $A$. Prove that the circumcircles of triangles $OXY$ and $OAM$ are coaxial with the circle with diameter $OS$.}

			\fig{1}{ITST2015D3P3i}{Actual Prob}
			\fig{1}{ITST2015D3P3ii}{Inverted}

		\prob{https://artofproblemsolving.com/community/c6h1352164p7389108}{USA TST 2017 P2}{M}{Let $ABC$ be an acute scalene triangle with circumcenter $O$, and let $T$ be on line $BC$ such that $\angle TAO = 90^{\circ}$. The circle with diameter $\overline{AT}$ intersects the circumcircle of $\triangle BOC$ at two points $A_1$ and $A_2$, where $OA_1 < OA_2$. Points $B_1$, $B_2$, $C_1$, $C_2$ are defined analogously.

			\begin{enumerate}
				\item Prove that $\overline{AA_1}$, $\overline{BB_1}$, $\overline{CC_1}$ are concurrent.
				\item Prove that $\overline{AA_2}$, $\overline{BB_2}$, $\overline{CC_2}$ are concurrent on the Euler line of triangle $ABC$.
			\end{enumerate}}

		\prob{https://artofproblemsolving.com/community/c6t48f6h1522766_tangent_circles}{AoPS2}{}{Let $ABC$ be a triangle with circumcenter $O$ and altitude $AH.$ $AO$ meets $BC$ at $M$ and meets the circle $(BOC)$ again at $N.$ $P$ is the midpoint of $MN.$ $K$ is the projection of $P$ on line $AH.$ Prove that the circle $(K,KH)$ is tangent to the circle $(BOC).$}

			\fig{1}{AoPS2}{AoPS2}

			\solu{Inversion all the way...}

		\prob{https://artofproblemsolving.com/community/c6h46718}{AoPS5}{}{Let $ABC$ be a triangle inscribed in $(O)$ and $P$ be a point. Call $P'$ be the isogonal conjugate point of $P$. Let $A'$ be the second intersection of $AP'$ and $(O)$. Denote by $M$ the intersection of $BC$ and $A'P$. Prove that $P'M \parallel AP$.}

			\fig{1}{AoPS5}{AoPS5}

		\prob{https://artofproblemsolving.com/community/c6h283185}{AoPS}{E}{$I$ is the incenter of a non-isosceles triangle $\triangle ABC$. If the incircle touches $BC, CA, AB$ at $A_1, B_1, C_1$ respectively, prove that the circumcentres of the triangles $\triangle AIA_1$, $\triangle BIB_1$, $\triangle CIC_1$ are collinear.}

		\prob{https://artofproblemsolving.com/community/c6h1501095p8898504}{AoPS}{M}{Given $\triangle ABC$ and a point $P$ inside. $AP$ cuts $BC$ at $M.$ Let $M', A'$ be the reflection of $M, A$ in the perpendicular bisector of $BC.$ $A'P$ cuts the perpendicular bisector of $BC$ at $N.$ Let $Q$ be the isogonal conjugate of $P$ in triangle $ABC.$ Prove that $QM'\parallel AN$.}

		\prob{https://artofproblemsolving.com/community/c6h1301365p6934249}{IRAN 3rd Round 2016 G6}{E}{Given triangle $\triangle ABC$ and let $D,E,F$ be the foot of angle bisectors of $A,B,C$ ,respectively. $M,N$ lie on $EF$ such that $AM=AN$. Let $H$ be the foot of $A$-altitude on $BC$.\\
		Points $K,L$ lie on $EF$ such that triangles $\triangle AKL, \triangle HMN$ are correspondingly similar (with the given order of vertices's) such that $AK \not\parallel HM$ and $AK \not\parallel HN$. Show that: $DK=DL$.}

			\fig{1}{IRAN3rd2016G6}{IRAN 3rd Round 2016 G6}

		\prob{https://artofproblemsolving.com/community/c6h1438017p8160421}{Iran TST 2017 T3 P6}{H}{In triangle $ABC$ let $O$ and $H$ be the circumcenter and the orthocenter. The point $P$ is the reflection of $A$ with respect to $OH$. Assume that $P$ is not on the same side of $BC$ as $A$. Points $E,F$ lie on $AB,AC$ respectively such that $BE=PC \ ,  CF=PB$. Let $K$ be the intersection point of $AP,OH$. Prove that $\angle EKF = 90 ^{\circ}$.}

		\tr{Spiral Similarity (points on $AB, AC$ with some properties)}

			\figdf{1}{ITST2017T3P6}{Iran TST 2017 T3 P6}

		\prob{https://artofproblemsolving.com/community/c6h360732p1973876}{IRAN 3rd Round 2010 D3, P6}{M}{In a triangle $ABC$, $\angle C=45^{\circ}$. $AD$ is the altitude of the triangle. $X$ is on $AD$ such that $\angle XBC=90-\angle B$ ($X$ is inside of the triangle). $AD$ and $CX$ cut the circumcircle of $ABC$ in $M$ and $N$ respectively. Ff the tangent to $\odot ABC$ at $M$ cuts $AN$ at $P$, prove that $P, B$ and $O$ are collinear.}

		\tr{Cross-Ratio}

		\prob{https://artofproblemsolving.com/community/c6h585433p3462669}{Iran TST 2014 T1P6}{M}{$I$ is the incenter of triangle $ABC$. perpendicular from $I$ to $AI$ meet $AB$ and $AC$ at ${B}'$ and ${C}'$ respectively. Suppose that ${B}''$ and ${C}''$ are points on half-line $BC$ and $CB$ such that $B{B}''=BA$ and $C{C}''=CA$. Suppose that the second intersection of circumcircles of $A{B}'{B}''$ and $A{C}'{C}''$ is $T$. Prove that the circumcenter of $AIT$ is on the $BC$.} \tg{projective, inversion}

			\solu{Too many collinearity, need to prove concurrency, what else can come into mind except projective approach.}

			\solu{Too many incenter related things, $\sqrt{bc}$-inversion :o}

		\prob{https://artofproblemsolving.com/community/c6h582820p3444910}{APMO 2014 P5}{M}{Circles $\omega$ and $\Omega$ meet at points $A$ and $B$. Let $M$ be the midpoint of the arc $AB$ of circle $\omega$ ($M$ lies inside $\Omega$). A chord $MP$ of circle $\omega$ intersects $\Omega$ at $Q$ ($Q$ lies inside $\omega$). Let $\ell_P$ be the tangent line to $\omega$ at $P$, and let $\ell_Q$ be the tangent line to $\Omega$ at $Q$. Prove that the circumcircle of the triangle formed by the lines $\ell_P$, $\ell_Q$ and $AB$ is tangent to $\Omega$.}

			\fig{1}{APMO2014P5}{APMO 2014 P5}

		\prob{}{}{E}{Let $ABC$ be a triangle, $D, E, F$ are the feet of the altitudes, $DF\cap BE\equiv P, DE\cap CF\equiv Q$. Prove that the perpendicular from $A$ to $PQ$ goes through the reflection of $O$ on $BC$.}  \tg{projective}

			\solu{Projective approach.}

		\prob{https://artofproblemsolving.com/community/c6h1598147p9931685}{RMM 2018 P6}{H}{Fix a circle $\Gamma$, a line $\ell$ to tangent $\Gamma$, and another circle $\Omega$ disjoint from $\ell$ such that $\Gamma$ and $\Omega$ lie on opposite sides of $\ell$. The tangents to $\Gamma$ from a variable point $X$ on $\Omega$ meet $\ell$ at $Y$ and $Z$. Prove that, as $X$ varies over $\Omega$, the circumcircle of $XYZ$ is tangent to two fixed circles.} \tg{inversion}

			\solu{Too many circles, plus tangency, what else other than inversion? After the inversion the problem turns into a pretty obvious work-around problem.}

		\prob{https://artofproblemsolving.com/community/c6h1573301p9738624}{AoPS6}{H but Beautiful}{Let $O$ and $I$ be the circumcenter and incenter of $\Delta ABC$. Draw circle $\omega$ so that $B,C \in \omega$ and $\omega$ touches $(I)$ internally at $P$. $AI$ intersects $BC$ at $X$. Tangent at $X$ to $(I)$ which is different from $BC$, intersects tangent at $P$ to $(I)$ at $S$. $SA \cap (O)=T \neq A$. Prove that $\angle ATI=90^{\circ}$}

			\figdf{1}{AoPS6_1}{Solution 1}
			\figdf{1}{AoPS6_2}{Solution 2}

		\prob{https://artofproblemsolving.com/community/c6h1618875_cute_radical_axis}{AoPS7}{E}{Let $ABC$ be a triangle with incenter $I$ and circumcircle $\Gamma$. Let the line through $I$ perpendicular to $AI$ meet $AB$ at $E$ and $AC$ at $F$. Let the circumcircles of triangles $AIB$ and $AIC$ intersect the circumcircle of triangle $AEF$ $\omega$ again at points $M$ and $N$, and let $\omega$ intersect $\Gamma$ again at $Q$. Prove that $AQ$, $MN$, and $BC$ are concurrent.}

		\prob{https://artofproblemsolving.com/community/q2h514889p2893347}{AoPS}{E}{Given a circle $ (O) $ with center $ O $ and $ A,B $ are $ 2 $ fixed points on $ (O) $. $ E $ lies on $ AB $. $ C,D $ are on $ (O) $ and $ CD $ pass through $ E $. $ P $ lies on the ray $ DA $, $ Q $ lies on the ray $ DB $ such that $ E $ is the midpoint of $ PQ $. Prove that the circle passing through $ C $ and touch $ PQ $ at $ E $ also pass through the midpoint of $ AB $}

		\prob{https://artofproblemsolving.com/community/c6h514252p2889096}{WenWuGuangHua Mathematics Workshop}{E}{$ O_B, O_C $ are the $ B $ and $ C $ mixtilinear centers respectively. $ (O_B) $ touches $ BC, AB $ at $ X_B, Y_B $ respectively, and $ X_BY_B\cap O_BO_C $ at $ Z_B $. Define $ X_C, Y_C, Z_C $ similarly. Prove that if $ BZ_C\cap CZ_B = T $, then $ AT $ is the $ A $-angle bisector.}

		\prob{https://artofproblemsolving.com/community/c6h514371p2889823}{All Russia 1999 P9.3}{E}{A triangle $ABC$ is inscribed in a circle $S$. Let $A_0$ and $C_0$ be the midpoints of the arcs $BC$ and $AB$ on $S$, not containing the opposite vertex, respectively. The circle $S_1$ centered at $A_0$ is tangent to $BC$, and the circle $S_2$ centered at $C_0$ is tangent to $AB$. Prove that the incenter $I$ of $\triangle ABC$ lies on a common tangent to $S_1$ and $S_2$.}

		\prob{https://artofproblemsolving.com/community/c6h514303p2889241}{All Russia 2000 P11.7}{E}{ A quadrilateral $ABCD$ is circumscribed about a circle $\omega$. The lines $AB$ and $CD$ meet at $O$. A circle $\omega_1$ is tangent to side $BC$ at $K$ and to the extensions of sides $AB$ and $CD$, and a circle $\omega_2$ is tangent to side $AD$ at $L$ and to the extensions of sides $AB$ and $CD$. Suppose that points $O$, $K$, $L$ lie on a line. Prove that the midpoints of $BC$ and $AD$ and the center of $\omega$ also lie on a line.}

		\prob{https://artofproblemsolving.com/community/c6h514286p2889224}{All Russia 2000 P9.3}{E}{Let $O$ be the center of the circumcircle $\omega$ of an acute-angle triangle $ABC$. A circle $\omega_1$ with center $K$ passes through $A$, $O$, $C$ and intersects $AB$ at $M$ and $BC$ at $N$. Point $L$ is symmetric to $K$ with respect to line $NM$. Prove that $BL \perp AC$.}

		\prob{https://artofproblemsolving.com/community/q1h512017p2874889}{WenWuGuangHua Mathematics Workshop}{M}{

			\begin{enumerate}

				\item $ AD, BE, CF $ are concurrent cevians. Angle bisectors of $ \angle ADB $ and $ \angle AEB $ meet at $ C_0 $. Again the angle bisectors of $ \angle ADC $ and $ \angle AFC $ meet at $ B_0 $. And bisectors of $ \angle BEC $ and $ \angle BFC $ meet at $ A_0 $. Prove that $ AA_0, BB_0, CC_0 $ are concurrent.

				\item Angle bisectors of $ \angle AEB $ and $ \angle AFC $ meet at $ D_0 $, of $ \angle BFC $ and $ BDA $ meet at $ E_0 $, and of $ \angle CEB $ and $ \angle CDA $ meet at $ F_0 $. Prove that $ DD_0, EE_0, FF_0 $ are concurrent.

			\end{enumerate}}

			\solu{As this problem is purely made up with lines, we can do a projective transformation to simplify the problem. And as there are perpendicularity at $ D, E, F $, we make $ D, E, F $ the feet of the altitudes of $ \triangle ABC $. Then the angle bisector properties get replaced by simpler properties wrt $ DEF $.}

		\prob{https://artofproblemsolving.com/community/c6h359172}{WenWuGuangHua Mathematics Workshop}{E}{Generalization: Let $ AD, BE, CF $ be any cevians concurrent at $ T $. $ AD\cap EF=A',\ BE\cap DF=B',\ CF\cap DE=C',\ B'A'\cap AC= X,\ B'A'\cap BC= Y,\ C'X\cap EF=Z $. Prove that $ T, Y, Z $ are collinear.}

		\prob{https://artofproblemsolving.com/community/q1h512618p2878013}{AoPS}{E}{On circumcircle of triangle $ABC$, $T$ and $K$ are midpoints of arcs $BC$ and $BAC$ respectively . And $E$ is foot of altitude from $C$ on $AB$ . Point $P$ is on extension of $AK$ such that $PE$ is perpendicular to $ET$ . Prove that $PC=CK$.}

		\prob{https://artofproblemsolving.com/community/c5t256599f5h1629606_geo_3_equals_freak_out}{USJMO 2018 P3}{E}{Let $ABCD$ be a quadrilateral inscribed in circle $\omega$ with $\overline{AC} \perp \overline{BD}$. Let $E$ and $F$ be the reflections of $D$ over lines $BA$ and $BC$, respectively, and let $P$ be the intersection of lines $BD$ and $EF$. Suppose that the circumcircle of $\triangle EPD$ meets $\omega$ at $D$ and $Q$, and the circumcircle of $\triangle FPD$ meets $\omega$ at $D$ and $R$. Show that $EQ = FR$.}

		\prob{https://artofproblemsolving.com/community/c6h181312p996629}{All Russia 2002 P11.6}{M}{The diagonals $AC$ and $BD$ of a cyclic quadrilateral $ABCD$ meet at $O$. The circumcircles of triangles $AOB$ and $COD$ intersect again at $K$. Point $L$ is such that the triangles $BLC$ and $AKD$ are similar and equally oriented. Prove that if the quadrilateral $BLCK$ is convex, then it has an incircle.}

		\prob{https://artofproblemsolving.com/community/q3h511494p2873290}{WenWuGuangHua Mathematics Workshop}{M}{Let $ O_B, O_C $ be the $ B, C $ mixtilinear excircles. $ O $ meet $ CA, CB $ at $ X_C, Y_C $ and $ O_B $ meet $ BA, BC $ at $ X_B, Y_B $. Let $ I_C $ be the $ C $-excircle. $ I_CY_B $ meet $ O_BO_C $ at $ T $. Prove that $ BT\perp O_BO_C $}

			\solu{From what we have to prove, we find two circles, from where we get another circle. This circle suggests that we try power of point. }

		\prob{https://artofproblemsolving.com/community/c6h1623012p10163453}{Iran TST 2018 T1P3}{M}{In triangle $ABC$ let $M$ be the midpoint of $BC$. Let $\omega$ be a circle inside of $ABC$ and is tangent to $AB,AC$ at $E,F$, respectively. The tangents from $M$ to $\omega$ meet $\omega$ at $P,Q$ such that $P$ and $B$ lie on the same side of $AM$. Let $X \equiv PM \cap BF $ and $Y \equiv QM \cap CE $. If $2PM=BC$ prove that $XY$ is tangent to $\omega$.}

		\prob{https://artofproblemsolving.com/community/c6h1623417p10167655}{Iran TST 2018 T1P4}{E}{Let $ABC$ be a triangle ($\angle A\neq 90^\circ$). $BE,CF$ are the altitudes of the triangle. The bisector of $\angle A$ intersects $EF,BC$ at $M,N$. Let $P$ be a point such that $MP\perp EF$ and $NP\perp BC$. Prove that $AP$ passes through the midpoint of $BC$.}

			\solu{:'3 kala para na  T\_T }

		\prob{https://artofproblemsolving.com/community/6h1629942p10229160}{Iran TST 2018 T3P6}{H}{Consider quadrilateral $ ABCD $ inscribed in circle $ \omega $. $ AC\cap BD = P $. $ E, F $ lie on sides $ AB, CD $, respectively such that $ \angle APE=\angle DPF $. Circles $ \omega_1, \omega_2 $ are tangent to $ \omega $ at $ X, Y $ respectively and also both tangent to the circumcircle of $ PEF $ at $ P $. Prove that: \[\frac{EX}{EY}=\frac{FX}{FY}\]}

			\solu{fucking beautiful.}

		\prob{}{ISL 2006 G6}{E}{Circles $ \omega_1 $ and $ \omega_2 $ with centres $ O_1 $ and $ O_2 $ are externally tangent at point $ D $ and internally tangent to a circle $ \omega $ at points $ E $ and $ F $ respectively. Line $ t $ is the common tangent of $ \omega_1 $ and $ \omega_2 $ at $ D $. Let $ AB $ be the diameter of $ \omega $ perpendicular to $ t $, so that $ A, E, O_1 $ are on the same side of $ t $. Prove that lines $ AO_1, BO_2, EF $ and $ t $ are concurrent.}

		\prob{}{ISL 2006 G7}{E}{In a triangle $ ABC $, let $ M_a, M_b, M_c $ be the midpoints of the sides $ BC, CA, AB $, respectively, and $ T_a, T_b, T_c $ be the midpoints of the arcs $BC, CA, AB$ of the circumcircle of $ABC$, not containing the vertices's $A, B, C$, respectively. For $i \in {a, b, c}$, let $w_i$ be the circle with $M_iT_i$ as diameter. Let $p_i$ be the common external common tangent to the circles $w_j$ and $w_k$ (for all ${i, j, k} = {a, b, c}$) such that $w_i$ lies on the opposite side of $p_i$ than $w_j$ and $w_k$ do.

		Prove that the lines $p_a, p_b, p_c$ form a triangle similar to $ABC$ and find the ratio of similitude}

		\prob{}{ISL 2006 G9}{H}{Points $A_1, B_1, C_1$ are chosen on the sides $BC, CA, AB$ of a triangle $ABC$, respectively. The circumcircles of triangles $AB_1C_1,\ BC_1A_1,\ CA_1B_1$ intersect the circumcircle of triangle $ABC$ again at points $A_2, B_2, C_2$, respectively ($A_2 \not= A, B_2 \not= B, C_2 \not= C$). Points $A_3, B_3, C_3$ are symmetric to $A_1, B_1, C_1$ with respect to the midpoints of the sides $BC, CA, AB$ respectively. Prove that the triangles $A_2B_2C_2$ and $A_3B_3C_3$ are similar.}

			\solu{In this type of ``Miquel's Point and the intersections of the circumcircles'' related problems, it is useful to think about the second intersections of the lines joining the first intersections and the Miquel's Point with the main circle.}

			\figdf{1}{ISL2006G9}{IMO Shortlist G9}

		\prob{https://artofproblemsolving.com/community/c6h1423742p8012536}{Iran TST 2017 P5}{}{In triangle $ABC$, arbitrary points $P,Q$ lie on side $BC$ such that $BP=CQ$ and $P$ lies between $B,Q$. The circumcircle of triangle $APQ$ intersects sides $AB,AC$ at $E,F$ respectively. The point $T$ is the intersection of $EP,FQ$. Two lines passing through the midpoint of $BC$ and parallel to $AB$ and $AC$, intersect $EP$ and $FQ$ at points $X,Y$ respectively. Prove that the circumcircle of triangle $TXY$ and triangle $APQ$ are tangent to each other.}

		\prob{}{}{E}{Let $ X $  be the touchpoint of the incircle with $ BC $ and let $ AX $ meet $ \cdot ABC $ at $ D $. The tangents from $ D $ to the incircle meet $ \cdot ABC $ at $ E, F $. Prove that the tangent to the circumcircle at $ A $, $ EF $ and $ BC $ are concurrent.}

		\prob{https://artofproblemsolving.com/community/c6h546185p3160596}{ISL 2012 G8}{M}{Let $ABC$ be a triangle with circumcircle $\omega$ and $\ell$ a line without common points with $\omega$. Denote by $P$ the foot of the perpendicular from the center of $\omega$ to $\ell$. The side-lines $BC,CA,AB$ intersect $\ell$ at the points $X,Y,Z$ different from $P$. Prove that the circumcircles of the triangles $AXP$, $BYP$ and $CZP$ have a common point different from $P$ or are mutually tangent at $P$.}

			\solu{Using Cross ratio and Desergaus's Involution Theorem.}

		\prob{}{}{E}{Suppose an involution on a line $ l $ sending $ X, Y, Z $ to $ X', Y', Z' $. Let $ l_x, l_y, l_z $ be three lines passing through $ X, Y, Z $ respectively. And let $ X_0=l_y\cap l_z,\ Y_0=l_x\cap l_z,\ Z_0=l_x\cap l_y $. Then $ X_0X', Y_0Y', Z_0Z' $ are concurrent.}

		\prob{}{USAMO 2018 P5}{E}{In convex cyclic quadrilateral $ABCD$, we know that lines $AC$ and $BD$ intersect at $E$, lines $AB$ and $CD$ intersect at $F$, and lines $BC$ and $DA$ intersect at $G$. Suppose that the circumcircle of $\triangle ABE$ intersects line $CB$ at $B$ and $P$, and the circumcircle of $\triangle ADE$ intersects line $CD$ at $D$ and $Q$, where $C,B,P,G$ and $C,Q,D,F$ are collinear in that order. Prove that if lines $FP$ and $GQ$ intersect at $M$, then $\angle MAC = 90^\circ$.}

		\prob{https://artofproblemsolving.com/community/c6h1381506p7662154}{Japan MO 2017 P3}{E}{Let $ABC$ be an acute-angled triangle with the circumcenter $O$. Let $D,E$ and $F$ be the feet of the altitudes from $A,B$ and $C$, respectively, and let $M$ be the midpoint of $BC$. $AD$ and $EF$ meet at $X$, $AO$ and $BC$ meet at $Y$, and let $Z$ be the midpoint of $XY$. Prove that $A,Z,M$ are collinear.}

		\prob{https://artofproblemsolving.com/community/c6h17316p118667}{ISL 2002 G1}{E}{Let $B$ be a point on a circle $S_1$, and let $A$ be a point distinct from $B$ on the tangent at $B$ to $S_1$. Let $C$ be a point not on $S_1$ such that the line segment $AC$ meets $S_1$ at two distinct points. Let $S_2$ be the circle touching $AC$ at $C$ and touching $S_1$ at a point $D$ on the opposite side of $AC$ from $B$. Prove that the circumcenter of triangle $BCD$ lies on the circumcircle of triangle $ABC$.}

		\prob{https://artofproblemsolving.com/community/c6h17317p118668}{ISL 2002 G2}{M}{Let $ABC$ be a triangle for which there exists an interior point $F$ such that $\angle AFB=\angle BFC=\angle CFA$. Let the lines $BF$ and $CF$ meet the sides $AC$ and $AB$ at $D$ and $E$ respectively. Prove that \[ AB+AC\geq4DE. \]}

			\solu{Pari nai.}

		\prob{https://artofproblemsolving.com/community/c6h17318p118672}{ISL 2002 G3}{E}{The circle $S$ has center $O$, and $BC$ is a diameter of $S$. Let $A$ be a point of $S$ such that $\angle AOB<120{{}^\circ}$. Let $D$ be the midpoint of the arc $AB$ which does not contain $C$. The line through $O$ parallel to $DA$ meets the line $AC$ at $I$. The perpendicular bisector of $OA$ meets $S$ at $E$ and at $F$. Prove that $I$ is the incenter of the triangle $CEF.$}

		\prob{https://artofproblemsolving.com/community/c6h17319p118673}{ISL 2002 G4}{E}{Circles $S_1$ and $S_2$ intersect at points $P$ and $Q$. Distinct points $A_1$ and $B_1$ (not at $P$ or $Q$) are selected on $S_1$. The lines $A_1P$ and $B_1P$ meet $S_2$ again at $A_2$ and $B_2$ respectively, and the lines $A_1B_1$ and $A_2B_2$ meet at $C$. Prove that, as $A_1$ and $B_1$ vary, the circumcentres of triangles $A_1A_2C$ all lie on one fixed circle.}

		\prob{https://artofproblemsolving.com/community/c6h17323p118682}{ISL 2002 G7}{E}{The incircle $ \Omega$ of the acute-angled triangle $ ABC$ is tangent to its side $ BC$ at a point $ K$. Let $ AD$ be an altitude of triangle $ ABC$, and let $ M$ be the midpoint of the segment $ AD$. If $ N$ is the common point of the circle $ \Omega$ and the line $ KM$ (distinct from $ K$), then prove that the incircle $ \Omega$ and the circumcircle of triangle $ BCN$ are tangent to each other at the point $ N$.}

		\prob{https://artofproblemsolving.com/community/c6h1381506p7662154}{Japan MO 2017 P3}{E}{Let $ABC$ be an acute-angled triangle with the circumcenter $O$. Let $D,E$ and $F$ be the feet of the altitudes from $A,B$ and $C$, respectively, and let $M$ be the midpoint of $BC$. $AD$ and $EF$ meet at $X$, $AO$ and $BC$ meet at $Y$, and let $Z$ be the midpoint of $XY$. Prove that $A,Z,M$ are collinear.}

		\prob{}{India TST}{E}{$ ABC $ triangle, $ D, E, F $ touchpoints, $ M $ midpoint of $ BC $, $ K $ orthocenter of $ \triangle AIC $, prove that $ MI \perp KD $}

		\prob{https://artofproblemsolving.com/community/c6h355790p1932935}{ISL 2009 G3}{E}{Let $ABC$ be a triangle. The incircle of $ABC$ touches the sides $AB$ and $AC$ at the points $Z$ and $Y$, respectively. Let $G$ be the point where the lines $BY$ and $CZ$ meet, and let $R$ and $S$ be points such that the two quadrilaterals $BCYR$ and $BCSZ$ are parallelogram. Prove that $GR=GS$.}

			\solu{Point Circle, distance same means Power same wrt point circles.}

		\prob{https://artofproblemsolving.com/community/c6h1634974p10278638}{ARO 2018 P11.6}{E}{Three diagonals of a regular $n$-gon prism intersect at an interior point $O$. Show that $O$ is the center of the prism.

		(The diagonal of the prism is a segment joining two vertices's not lying on the same face of the prism.)}

		\vspace{8mm}

		\prob{https://artofproblemsolving.com/community/c6h488829p2739327}{ISL 2011 G4}{EM}{Let $ABC$ be an acute triangle with circumcircle $\Omega$. Let $B_0$ be the midpoint of $AC$ and let $C_0$ be the midpoint of $AB$. Let $D$ be the foot of the altitude from $A$ and let $G$ be the centroid of the triangle $ABC$. Let $\omega$ be a circle through $B_0$ and $C_0$ that is tangent to the circle $\Omega$ at a point $X\not= A$. Prove that the points $D,G$ and $X$ are collinear.}

			\vspace{8mm}

		\prob{}{}{Constructing a forth circle tangent}{Given 3 circle, construct another circle that is tangent to these three circles.}

			\solu{A trick to remember: decreasing the radius's of some circles doesn't effect much.}

		\prob{}{}{H}{Let $ ABCD $ be a convex quadrilateral, let $ AD\cap BC = P $. Let $ O, O';\ H, H' $ be the circumcentres and orthocenter of $ \triangle PCD, \triangle PAB $. $ \odot DOC $ is tangent to $ \odot AD'B $, if and only if $ \odot DHC $ is tangent to $ \odot AH'B $}

		\prob{https://artofproblemsolving.com/community/c6h1493342p8776187}{Iran MO 3rd round 2017 mid-terms Geometry P3}{M}{Let $ABC$ be an acute-angle triangle. Suppose that $M$ be the midpoint of $BC$ and $H$ be the orthocenter of $ABC$. Let $F\equiv BH\cap AC$ and $E\equiv CH\cap AB$. Suppose that $X$ be a point on $EF$ such that $\angle XMH=\angle HAM$ and $A,X$ are in the distinct side of $MH$. Prove that $AH$ bisects $MX$.}

%todo: curvilinear incircle prob


\documentstyle[11pt,reduce]{article}
\title{A \REDUCE{} package for Symmetry}
\date{}
\author{Karin Gatermann\\
        Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin\\
        Takustrasse\ 7\\
        D--14195 Berlin--Dahlem\\
        Federal Republic of Germany\\
	E--mail: gatermann@zib.de}
\begin{document}
\maketitle
\index{SYMMETRY package}

This short note describes a package of \REDUCE{} procedures
that compute symmetry-adapted bases and block diagonal forms
of matrices which have the symmetry of a group.
The SYMMETRY package is the implementation
of the theory of linear representations
for small finite groups such as the dihedral groups.

\section{Introduction}

The exploitation of symmetry is a very important principle in mathematics,
physics and engineering sciences.
The aim of the SYMMETRY package is to give an easy access to the
underlying theory of linear representations for small groups. For
example the
dihedral groups $D_3,D_4,D_5,D_6$ are included.
For an introduction to the theory see {\sc Serre} \cite{Se77} or
{\sc Stiefel} and {\sc F\"assler} \cite{StFae79}.
For a given orthogonal (or unitarian) linear representation
\[
\vartheta : G\longrightarrow GL(K^n), \qquad K=R,C.
\]
the character $\psi\rightarrow K$, the
canonical decomposition or the bases of the isotypic
components are computed. A matrix $A$ having the symmetry of a linear
representation,e.g.
\[
\vartheta_t A = A \vartheta_t \quad \forall \, t\in G,
\]
is transformed to block diagonal form by a coordinate
transformation.
The dependence of the algorithm on the
field of real or complex numbers is controled by the switch {\tt complex}.
An example for this is given in the testfile {\em symmetry.tst}.

As the algorithm needs information concerning the irreducible representations
this information is stored for some groups (see the operators in Section 3).
It is assumed that only orthogonal (unitar) representations are given.

The package is loaded by

{\tt load symmetry;}

\section{Operators for linear representations}

First the data structure for a linear representation has to be explained.
{\em representation} is a list consisting of the group identifier and
equations which assign matrices to the generators of the group.

{\bf Example:}
\begin{verbatim}
   rr:=mat((0,1,0,0),
           (0,0,1,0),
           (0,0,0,1),
           (1,0,0,0));

   sp:=mat((0,1,0,0),
           (1,0,0,0),
           (0,0,0,1),
           (0,0,1,0));

   representation:={D4,rD4=rr,sD4=sp};
\end{verbatim}

For orthogonal (unitarian) representations the following operators
are available.

{\tt canonicaldecomposition(representation);}

returns an equation giving the canonical decomposition of the linear
representation.

{\tt character(representation);}

computes the character of the linear representation. The result is a list
of the group identifier and of lists consisting of a
list of group elements in one equivalence class and a real or complex number.

{\tt symmetrybasis(representation,nr);}

computes the basis of the isotypic component corresponding to the irreducible
representation of type nr. If the nr-th irreducible representation is
multidimensional, the basis is symmetry adapted. The output is a matrix.

{\tt symmetrybasispart(representation,nr);}

is similar as {\tt symmetrybasis}, but for multidimensional
irreducible representations only the first part of the
symmetry adapted basis is computed.

{\tt allsymmetrybases(representation);}

is similar as {\tt symmetrybasis} and {\tt symmetrybasispart},
but the bases of all
isotypic components are computed and thus a
complete coordinate transformation is returned.

{\tt diagonalize(matrix,representation);}

returns the block diagonal form of matrix which has the symmetry
of the given linear representation. Otherwise an error message occurs.

{\tt on complex;}

Of course the property of irreducibility depends on the field $K$ of
real or complex numbers. This is why the algorithm depends on $K$.
The type of computation is set by the switch {\em complex}.

\section{Display Operators}

In this section the operators are described which give access to the
stored information for a group.
First the operators for the abstract groups are given.
Then it is described how to get the irreducible representations
for a group.

{\tt availablegroups();}

returns the list of all groups for which the information such as
irreducible representations is stored. In the following {\tt group}
is always one of these group identifiers.

{\tt printgroup(group);}

returns the list of all group elements;

{\tt generators(group);}

returns a list of group elements which generates the group. For the
definition of a linear representation matrices for these generators
have to be defined.

{\tt charactertable(group);}

returns a list of the characters corresponding to the irreducible
representations of this group.

{\tt charactern(group,nr);}

returns the character corresponding to the nr-th irreducible representation
of this group as a list (see also {\tt character}).

{\tt irreduciblereptable(group);}

returns the list of irreducible representations of the group.

{\tt irreduciblerepnr(group,nr);}

returns an irreducible representation of the group. The output
is a list of the group identifier and equations
assigning the representation matrices to group elements.

\section{Storing a new group}

If the user wants to do computations for a group for which
information is not predefined,
the package SYMMETRY offers the possibility to supply information
for this group.

For this the following data structures are used.

{\bf elemlist} = list of identifiers.

{\bf relationlist}  = list of equations with identifiers and
operators $@$ and $**$.

{\bf grouptable} = matrix with the (1,1)-entry grouptable.

{\bf filename} = "myfilename.new".

\vspace{2cm}
The following operators have to be used in this order.

{\tt setgenerators(group,elemlist,relationlist);}

{\bf Example:}
\begin{verbatim}
   setgenerators(K4,{s1K4,s2K4},
     {s1K4^2=id,s2K4^2=id,s1K4@s2K4=s2K4@s1K4});
\end{verbatim}

{\bf setelements(group,relationlist);}

The group elements except the neutral element
are given as product of the defined
generators. The neutral element is always called {\tt id}.

{\bf Example:}
\begin{verbatim}
   setelements(K4,
        {s1K4=s1K4,s2K4=s2K4,rK4=s1K4@s2K4});
\end{verbatim}

{\bf setgrouptable(group,grouptable);}

installs the group table.

{\bf Example:}
\begin{verbatim}
   tab:=
    mat((grouptable,     id,    s1K4, s2K4, rK4),
        (id        ,     id,    s1K4, s2K4, rK4),
        (s1K4      ,    s1K4,     id,  rK4,s2K4),
        (s2K4      ,    s2K4,    rK4,   id,s1K4),
        (rK4       ,     rK4,   s2K4, s1K4,  id));

   setgrouptable(K4,tab);
\end{verbatim}

{\bf Rsetrepresentation(representation,type);}

is used to define the real irreducible representations of the group.
The variable {\tt type} is either {\em realtype} or {\em complextype}
which indicates the type of the real irreducible representation.

{\bf Example:}
\begin{verbatim}
   eins:=mat((1));
   mineins:=mat((-1));
   rep3:={K4,s1K4=eins,s2K4=mineins};
   Rsetrepresentation(rep3,realtype);
\end{verbatim}

{\bf Csetrepresentation(representation);}

This defines the complex irreducible representations.

{\bf setavailable(group);}

terminates the installation of the group203. It checks some properties of the
irreducible representations and makes the group available for the
operators in Sections 2 and 3.

{\bf storegroup(group,filename);}

writes the information concerning the group to the file with name
{\em filename}.

{\bf loadgroups(filename);}

loads a user defined group from the file {\em filename} into
the system.

\begin{thebibliography}{5}

\bibitem{JaKer81} G.\ James, A.\ Kerber: {\it Representation Theory
of the Symmetric Group.} Addison, Wesley (1981).

\bibitem{LuFal88} W.\ Ludwig, C.\ Falter: {\it Symmetries in Physics.}
Springer, Berlin, Heidelberg, New York (1988).

\bibitem{Se77} J.--P.\ Serre, {\it Linear Representations of Finite
Groups}. Springer, New~York (1977).

\bibitem{StFae79} E.\  Stiefel, A.\  F{\"a}ssler, {\it Gruppentheoretische
Methoden und ihre Anwendung}. Teubner, Stuttgart (1979).
(English translation to appear by Birkh\"auser (1992)).

\end{thebibliography}
\end{document}


%!TEX root = ./thesis.tex
\graphicspath{{./Figs/LiteratureReview/}}
% Acronym
\nomtypeA{LES}{Large Eddy Simulations}
% Neutral ABL
\nomtypeR{$S_\epsilon$}{Source term in turbulent dissipation rate equation}{}
\nomtypeR{$S_k$}{Source term in turbulent kinetic energy equation}{}

\chapter{Literature Review}
\section{Neutral Atmospheric Boundary Layer modelling}
\subsection{Horizontally homogeneous boundary layer}
The important task before modelling flows in ABL is obtaining equilibrium ABL, i.e. zero stream-wise gradients of all variables. For neutral atmospheric boundary layer, \textcite{Richards1993} proposed the appropriate boundary conditions of mean wind speed and turbulence quantities for the standard $k-\epsilon$ model. These profiles were derived assuming constant shear stress with height and applied for surface layer of ABL. These were used to model ABL surface layer as horizontally homogeneous turbulent surface layer (HHTSL). However, HHTSL was hard to achieved mostly due to the ground boundary conditions \cite{Yang2009}, which manifested in the decay of velocity profile due to a spike in the turbulent kinetic energy profile close to the ground. The consistency between wall boundary conditions, turbulence model with associated constants and also numerical schemes was shown to help to achieve HHTSL \cite{Jonathon2012, Parente2011, Yan2016}. Under HHTSL, the governing equations can be simplified as:
\begin{equation} \label{eq:Richards1993_eqns}
\begin{aligned}
\nu_t \pdv{u(z)}{z} = \frac{\tau_w}{\rho} = u_*^2 \\
\pdv{}{z} \left(\nu_t \pdv{u(k)}{z}\right) + S_k = 0\\
\pdv{}{z} \left(\frac{\nu_t}{\sigma_{\epsilon}} \pdv{\epsilon}{z}\right) (C_{1\epsilon} - C_{2\epsilon})\frac{\epsilon^2}{k} + S_\epsilon = 0
\end{aligned}
\end{equation}

The inlet boundary conditions proposed by \textcite{Richards1993}, widely used in CFD study of atmospheric flow are:
\begin{equation} \label{eq:Richards1993_inlet}
\begin{aligned}
u(z) &= \frac{u_{*}}{\kappa }\ln \frac{z+z_0}{z_0}\\
k &= \frac{u_{*}^2}{\sqrt{C_\mu}}\\
\epsilon &= \frac{u_{*}^3}{\kappa (z + z_0)}
\end{aligned}
\end{equation}

These profiles are assured a solution of Equation~(\ref{eq:Richards1993_eqns}), if the model constant, turbulent Prandtl number of the dissipation rate $\sigma_{\epsilon}$, is modified as:
\begin{equation} \label{eq:Richards1993_model_constrain}
\sigma_{\epsilon} = \frac{\kappa^2 }{(C_{\epsilon2}-C_{\epsilon1}) \sqrt C_\mu}
\end{equation}

Instead of altering model constants, \textcite{Pontiggia2009} derived the $\epsilon$ equation $z$-dependent source term from solution of Equation~(\ref{eq:Richards1993_inlet}):
\begin{equation} \label{eq:epsSourcePont}
S_\epsilon= \frac{\rho u_*^4}{(z+z_0)^2} \left[ \frac{(C_{\epsilon 2}-C_{\epsilon 1})\sqrt{C_\mu}}{\kappa^2} - \frac{1}{\sigma_{\epsilon}} \right] - \mu \frac{\rho u_*^3}{ 2 \kappa(z+z_0)^3}
\end{equation}
Under turbulence case, molecular viscosity is negligible, therefore the second term is usually ignored.

Constant inlet turbulence kinetic energy proposed by \textcite{Richards1993} is subjected to many arguments. Since velocity field is limited affected by turbulence kinetic energy but the concentration field because if enhancing dispersion effect of turbulence. As noted by \textcite{Parente2011}, decreasing $k$ with height was shown in many wind tunnel test. \textcite{Yang2009} proposed new profile of $k$ and $\epsilon$ for standard $k-\epsilon$ model. $k$, $\epsilon$ are the non-linear function of height as:
\begin{equation}
\begin{aligned}
k &=\frac{u_*^2}{C_\mu^{1/2}}\sqrt{C_1 \ln\left(\frac{z+z_0}{z_0}\right)+C_2}\\
\epsilon &=\frac{u_*^3}{\kappa (z+z_0)}\sqrt{C_1 \ln\left(\frac{z+z_0}{z_0}\right)+C_2}\\
\end{aligned}
\end{equation}
$C_1=-0.17$ and $C_2=1.62$ are constants fitted from their wind tunnel experiments. They also proposed modified standard model constants in Table~\ref{tab:kEpsModifiedYang2009}.
\def\rowWidth{0.06}
\begin{table}[htbp]
	\caption{The modified $k-\epsilon$ model constants by \textcite{Yang2009}} \label{tab:kEpsModifiedYang2009}
	\centering
	\begin{tabular}{p{\rowWidth\textwidth}p{\rowWidth\textwidth}p{\rowWidth\textwidth}p{\rowWidth\textwidth}p{\rowWidth\textwidth}}
		\toprule
		$C_{1\epsilon}$	& $C_{2\epsilon}$ & $C_{\mu}$ & $\sigma_k$ & $\sigma_\epsilon$ \\
		\midrule
		1.5 & 1.92 	& 0.028 & 1.67 & 2.51\\
		\bottomrule
	\end{tabular}
\end{table}

\textcite{Parente2011} presented an elaborate procedure to ensure the consistency for arbitrary inlet profile of turbulent kinetic energy $k$. Instead of altering model constants as \textcite{Yang2009}, the effect of non-constant $k$ on momentum and $\epsilon$ equation can be characterised by deriving equation for $C_\mu$:
\begin{equation}
C_\mu(z) = \frac{u_*^4}{k(z)^2}
\end{equation}
Source terms are added to $k$ and $\epsilon$ transport equations to ensure equilibrium condition:
\begin{equation}
\begin{aligned}
S_k &= \frac{\rho u_* \kappa}{\sigma_k} \pdv{}{z}\left((z+z_0) \pdv{k}{z}\right)\\
S_\epsilon &= \frac{\rho u_*^4}{(z+z_0)^2} \left[ \frac{(C_{\epsilon 2}-C_{\epsilon 1})\sqrt{C_\mu}}{\kappa^2} - \frac{1}{\sigma_{\epsilon}} \right]\\
\end{aligned}
\end{equation}

\textcite{Richards2011} revisited the problem of modelling the HHTSL by deriving the inlet profiles directly from the conservation and equilibrium equations. This allows various inlet profiles can be specified by varying the turbulence models constants. For standard $k-\epsilon$ models, the inlet profiles of velocity and turbulence properties are the same as Equation~(\ref{eq:Richards1993_inlet}). However they suggested to change the von Karman constant according to model constants as:
\begin{equation} \label{eq:vonKarman_constrain}
\kappa_{k-\epsilon} = \sqrt{(C_{\epsilon2}-C_{\epsilon1}) \sigma_{\epsilon} \sqrt C_\mu}
\end{equation}
Using the standard $k-\epsilon$ model constants (Table \ref{tab:kEpsCons}), we can yield $\kappa_{k-\epsilon} = 0.433$.

\textcite{Hargreaves2007} had shown that zero gradient velocity at the top boundary resulted in a decay of velocity downstream, due to the extraction energy at wall due to wall shear stress. A driving shear stress, zero flux of turbulent kinetic energy and a flux of dissipation rate $\epsilon$ are to be imposed at the upper boundary:
\begin{equation}\label{eq:RichardsTopBCs}
\begin{aligned}
\frac{\dd u}{\dd z}&= \frac{u_*}{\kappa z}\\
\frac{\mu_t}{\sigma_{\epsilon}} \frac{d \epsilon}{dz} &= -\frac{\rho u_{*}^4}{\sigma_{\epsilon} z}\\
\end{aligned}
\end{equation}

For $k-\omega$ models, the specific dissipation $\omega$ is solved instead of dissipation rate $\epsilon$. Profiles of $U$ and $k$ are the same, except the new effective von Karman constant is $\kappa_{k-\omega}=0.408$. Profiles for $\omega$ has expression of:
\begin{equation} \label{eq:hhtslOmeProfile}
\omega = \frac{u_{*}}{C_{\mu}^{1/2} \kappa_{k-\epsilon} z}
\end{equation}

Similarly to the $k-\epsilon$ turbulence models, a flux of $\omega$ should be imposed at top boundary:
\begin{equation}
{\mu_t} \frac{d \omega}{dz} = -\frac{\rho u_{*}^2}{C_{\mu}^{1/2} z}
\end{equation}

In present of obstacles, \textcite{Richards2011} had shown that eddy viscosity models like $k-\epsilon$ or $k-\omega$ resulted the over-prediction of stagnation pressures, while Reynolds stress model (RSM) \cite{Gibson1978} was significantly reduced this issue.

\subsection{Boundary conditions}
At the outlet boundary, the flow is assumed fully developed and unidirectional. All flow variables are supposed to be constant in this boundary. The placement of this boundary, therefore, is very important. As the placement is so close to the source, significant errors can be made due to the propagation of the source to other boundaries. Otherwise, if the placement is so far, the computational time will increase dramatically.

The top and side of the computational domain are external boundaries representing the far fields of flow. If a constant pressure is applied in these boundaries, this may alter the inlet wind profile in case prescribed pressure is not matched with the boundary velocity \cite{Luketa-Hanlin2007}. The zero gradient boundary condition, which set normal velocity to zero and all others variables are set equal to the inner values, or symmetry condition can be used at the top and side boundaries to reserve the wind profile and eliminate the effect of changing the inlet profiles.

At the wall boundary, two models usually applied for turbulence properties are Low Reynolds number (LRN) turbulence model \cite{Jones1972} and high Re number (HRN) with wall function \cite{Launder1974}. HRN models are usually less accurate, and also sensitive to the mesh resolution close to the wall. Adaptive wall functions were developed to overcome the restriction HRN, which is the first point above the wall to lie in the logarithmic layer \cite{Kalitzin2005}. \textcite{Backar2017} proposed a hybrid approach, so called numerical wall function, where wall adjacent cells are divided into sub-grid and governing equations are solved with appropriate boundary conditions in this sub-grid.

\section{Stratified Atmospheric Boundary Layer modelling}
Either the Reynolds Averaged Navier–Stokes (RANS) equations or Large Eddy Simulations (LES) \cite{Moeng1984,Saiki2000} are used for stratified atmospheric turbulence modelling. RANS turbulence models are still widely used in practical approach to overcome boundary conditions sensitivity and computational intensive of the LES.

Thermal stratification results from heat flux of the ground have significant effects to the buoyancy and ABL turbulence. For standard $k-\epsilon$ model, the source term that accounts for gravity effects in $\epsilon$ equation can be written as \cite{Alinot2005}:
\begin{equation}
S_{\epsilon b} =  C_{\epsilon 1}(1-C_{\epsilon 3}) \frac{\epsilon}{k} G_b
\end{equation}
$G_b$ is turbulent kinetic energy production source term due to buoyancy:
\begin{equation}
G_b = \beta g_i \frac{\mu_t}{\sigma_T}  \left( \pdv{T}{x_i} - \frac{g_i}{c_p} \right)
\end{equation}

For stable stratified ABL, turbulent kinetic energy $k$ and dissipation rate $\epsilon$ can be derived from Monin-Obukhov similarity theory profiles and solving the $k-\epsilon$ equation \cite{Luketa-Hanlin2007}. For the height $z \le 0.1h_{ABL}$:
\begin{equation} \label{eq:MO-turl-stab-surface}
\begin{aligned}
k &= 6 u_{*}^2\\
\epsilon &= \frac{u_{*}^3}{\kappa z}\left( 1.24 +4.3 \frac{z}{L_{MO}} \right)
\end{aligned}
\end{equation}

For the height $z>0.1h_{ABL}$:
\begin{equation} \label{eq:MO-turl-stab-above}
\begin{aligned}
k &= 6 u_{*}^2 \left( 1-\frac{z}{h_{ABL}} \right)^{1.75}\\
\epsilon &= \frac{u_{*}^3}{\kappa z}\left( 1.24 +4.3 \frac{z}{L_{MO}} \right) \left( 1-0.85\frac{z}{h_{ABL}} \right)^{1.5}
\end{aligned}
\end{equation}

Under unstable ABL, the heat flux from the ground and height of ABL play an important role in increasing the turbulence in the air flow. This vertical flow can be characterised using convective velocity scale Equation~(\ref{eq:convective-scaling}). Turbulent kinetic energy $k$ and dissipation rate $\epsilon$ under unstable ABL can be defined in Equation~(\ref{eq:MO-turb-unstab-surface}) for $z \le 0.1h_{ABL}$ and Equation~(\ref{eq:MO-turb-unstab-above}) for $z > 0.1h_{ABL}$.
\begin{equation} \label{eq:MO-turb-unstab-surface}
\begin{aligned}
k &= 0.36 w_{*}^2 + 0.85 u_{*}^2 \left( 1-3\frac{z}{h_{ABL}} \right)^{2/3}\\
\epsilon &= \frac{u_{*}^3}{\kappa z} \left( 1 + 0.5 \abs{\frac{z}{L_{MO}}} ^{2/3} \right)^{1.5}
\end{aligned}
\end{equation}

\begin{equation} \label{eq:MO-turb-unstab-above}
\begin{aligned}
k &=w_{*}^2 \left[ 0.36 + 0.9\left( \frac{z}{h_{ABL}} \right)^{2/3}\left( 1-0.8\frac{z}{h_{ABL}} \right)^{2} \right]\\
\epsilon &= \frac{w_{*}^3}{h_{ABL}} \left( 0.8-0.3\frac{z}{h_{ABL}} \right)
\end{aligned}
\end{equation}

In order to simulate atmospheric stratification effects, \textcite{Alinot2005} changed model constants (Table~\ref{tab:kEpsConsAlinot2005}) to achieve a better agreement with atmospheric profile from Monin-Obukhov theory.
\begin{table}[htbp]
	\caption{The standard $k-\epsilon$ model constants proposed by \textcite{Alinot2005}} \label{tab:kEpsConsAlinot2005}
	\centering
	\begin{tabular}{ccccc}
		\toprule
		$C_{1\epsilon}$	& $C_{2\epsilon}$ & $C_{\mu}$ & $\sigma_k$ & $\sigma_\epsilon$ \\
		\midrule
		1.176 & 1.92 & 0.0333 & 1 & 3.4 ($L_{MO} > 0$)\\
		&  &  & & -4.4 ($L_{MO} < 0$)\\
		\bottomrule
	\end{tabular}
\end{table}

Effects of atmospheric stratification on dense gas dispersion CFD simulations was addressed by \textcite{Pontiggia2009a}. The consistency between Monin-Obhukov profiles with $k-\epsilon$ model is obtained by addition of z-dependent source term $S_\epsilon$ to the $\epsilon$ transport equation. Under neutral atmospheric stability:
\begin{equation}
S_\epsilon(z) = \frac{\rho u_*^4}{z^2} \left[ \frac{(C_{\epsilon 2}-C_{\epsilon 1}) \sqrt{C_\mu}}{\kappa^2} - \frac{1}{\sigma_{\epsilon}}\right] -\mu \frac{u_*^3}{2\kappa z^3}
\end{equation}
Under stable condition:
\begin{equation} \label{eq:stablePontiggiaEpsSource}
S_\epsilon(z) = \frac{\rho u_*^4}{z^2} \left[ \frac{(C_{\epsilon 2}-C_{\epsilon 1}) \sqrt{C_\mu}}{\kappa^2} \Phi_\epsilon^2 \sqrt \frac{\Phi_\epsilon}{\Phi_m} - \frac{1}{\sigma_\epsilon}\left( \frac{2}{\Phi_m} - \frac{1}{\Phi_m^2} + \frac{T_*}{\kappa T} \right)\right] -\mu \frac{u_*^3}{2\kappa z^3}
\end{equation}

In case of cold dense gas dispersion, heat exchange of gas cloud and the ground surface is a significant heat transfer process. Forced heat convection model was used to find this heat flux \cite{Nielsen1999}:
\begin{equation}
q_s=h_{f} (T_s - T_f)
\end{equation}
$h_f$ is the local heat transfer coefficient, $T_f$ is the fluid temperature.
\textcite{Kovalets2006} used mixed coefficients between force heat convection and natural convection.

Several studies used CFD commercial software such as FLUENT; as well as open-source software such as OpenFOAM to simulate ABL layers. \textcite{Hargreaves2007} have shown that applying at fixed variable fluxes at top boundary is difficult in general CFD software and usually replaced by zero gradient (no shear stress), however this will result a decaying boundary layer. They also highlighted different approaches of modelling near wall region can lead to significantly unexpected results especially when using general CFD software. Wall function applied for atmospheric flow is necessarily modified as the standard wall function is based on experiments of sand grain roughed pipe \cite{Blocken2007} and wind engineering roughness length $z_0$ is far from similar to this kind of roughness. \textcite{Pieterse2013} used STAR-CCM+ commercial code to simulate thermally stratified ABL with the standard $k-\epsilon$ and SST $k-\omega$ turbulence model.

\textcite{Flores2013a} used Detached Eddy Simulation (DES) technique, which incorporates RANS models in near wall region and LES model in the rest, to simulate atmospheric wind circulation in open pit. The simulation takes in to account effects of buoyancy, stratification and complex geometry. A quasi-compressible approximation (treating density as explicit variable) was applied to incorporate stratification effect. \textcite{Riddle2004a} simulated neutrally stable atmospheric boundary layer with RSM turbulence model.

\section{CFD simulation of dense gas dispersion}
Value of turbulent Schmidt number $Sc_t$ are shown to have significant effect on dense gas dispersion concentration. Using wind tunnel data, \textcite{Mokhtarzadeh-Dehghan2012} reported that $Sc_t$ was related with flow thermal stability, which is increased from 0.5 to 2.3 for the flows with Richardson number from 0.1 to 16.

Several studies in literature of atmospheric dense gas dispersion using CFD approach adopted commercial software such as ANSYS fluent \cite{Gavelli2008,Zhang2015,Ikealumba2016,Meroney2012,Labovsky2011}, ANSYS CFX \cite{Sklavounos2004}, FLACS \cite{Hanna2004,Hansen2010a,Schleder2015} as well as open-source software such as OpenFOAM \cite{Mack2013, Fiates2016,Fiates2016a}, FDS \cite{Mouilleau2009,Ryder2004}. \textcite{Hansen2010a} validated FLACS in all tests in model evaluation database of LNG vapour dispersion. These include both wind tunnel test as well as field tests.

Several turbulence models were tested for dense gas dispersion problem. \textcite{Mack2013} used standard $k-\epsilon$ model with OpenFOAM solver \bera{reactingFoam}, to simulate wind tunnel test case \bera{DAT632}, which is the gravity driven flow of heavy gas in slope terrain. Different treatments of buoyancy term in $\epsilon$ equation are investigated. It was shown that standard $k-\epsilon$ is able to predict turbulence damping due to vertical negative density gradient. \textcite{Gavelli2008} applied RSM model to account for directional effect of Reynold stress field (using standard $k-\epsilon$ model as initial guess of turbulence) to simulate \bera{Falcon1} field test. \textcite{Gant2014} simulated \ce{C02} field test with realizable $k-\epsilon$ model. Different RANS models were also tested for dense gas flow over obstacle \cite{Sklavounos2004}. \textcite{Tauseef2011} used realizable $k-\epsilon$ for modelling two Thorney Island test cases.

\section{Concluding remarks}
From the investigation of literature, modifications of general CFD are required to successfully simulate the ABL turbulence. These was done intensively in commercial proprietary software. But little works were done in open-source code like OpenFOAM. The modification of general code should be done to successfully apply OpenFOAM in simulating ABL flows.

Ensuring accurate description of the ABL is an important task in any ABL flow study. This can be done by simulating the horizontally homogeneous ABL flow prior of dispersion study. Either the Reynolds Averaged Navier–Stokes (RANS) equations or Large Eddy Simulations (LES) are used for atmospheric turbulence modelling. RANS turbulence models are still widely used in practical approach to overcome boundary conditions sensitivity and computational intensive of the LES. Neutral and thermal stratified ABL should be taken into account to simulate ABL turbulence.

Turbulent Schmidt number $Sc_t$ had significant effect on ABL dense gas dispersion concentration \cite{Mokhtarzadeh-Dehghan2012}. Therefore, the solver should be able to take $Sc_t$ as input parameter. In case of LNG vapour dispersion, buoyancy effect and ground heat transfer are two important factors. LNG vapour density changes with its cloud temperature, therefore it behaves as dense gas in low temperature but as buoyant gas at higher temperature. The solver should take into account buoyancy effect in this situation.


\section{Theoretical Background}

\subsection{Concept Embedding Analysis}\label{sec:conceptanalysis}

To understand the process flow of an algorithm, it is of great value
to have access to interpretable intermediate outputs.
% This is not available for DNNs: Their intermediate output of layers,
% the latent spaces, are high-dimensional, entangled, and non-semantic,
% meaning semantic information is only indirectly embedded.
% The latent spaces of DNNs---the output spaces of sets of neurons or of
% complete layers---usually are far from interpretable.
% Instead, they are high-dimensional, entangled, and non-semantic, since
% features are automatically extracted from correlations in the data.
% However, information about semantic concepts may still be embedded in
% the latent space of a DNN.
The goal of concept embedding analysis is to answer \emph{whether},
\emph{how well}, \emph{how}, and with what
\emph{contribution to the reasoning}
information about semantic concepts is embedded into the latent spaces
(intermediate outputs) of DNNs, and to provide the result in an
explainable way.
Focus currently lies on finding embeddings in either the complete
output of a layer (image-level concepts), or single pixels of an
activation map of a convolutional DNN (concept segmentation).
%
%%% whether
To answer the \emph{whether}, one can try to find a decoder for the
information about the concept of interest, the \emph{concept embedding}.
This means, one is looking for a classifier on the latent space that
can predict the presence of the concept.
% An example are the mini-1-hidden-layer neural networks used in
% \cite{fuchs_neural_2018}.
% how well
The performance of the classifier provides a measure of \emph{how well}
the concept is embedded.
%
%%% how
For an explainable answer of \emph{how} a concept is embedded, the
decoder should be easily interpretable.
One constraint to this is introduced by the rich vector space
structure of the space of semantic concepts respectively word vector spaces
\cite{mikolov_linguistic_2013}:
The decoder map from latent to semantic space should preserve at least
a similarity measure.
For example, the encodings of \enquote{cat} and \enquote{dog} should
be quite similar, whereas that of a \enquote{car} should be relatively
distant from the two.
The methods in literature can essentially be grouped by their choice
of distance measure $\langle -,-\rangle$ used on the latent vector space.
A concept embedding classifier $E_c$ predicting the presence of concept $c$
in the latent space $L$ then is of the form
% \begin{gather*}
%   \SwapAboveDisplaySkip
$E_c(v)=\langle v_c,v\rangle > t_c$
% \quad\text{for~}
for $v\in L$,
% \end{gather*}
where $v_c\in L$ is the concept vector of the embedding,
and $t_c\in \R$.% is a threshold for binarizing.

Automated concept explanations \cite{ghorbani_towards_2019} uses
$L_2$ distance as similarity measure. They discover concepts in an
unsupervised fashion by k-means clustering of the latent space
representations of input samples. The concept vectors of the
discovered concepts are the cluster centers.
% In \cite{yeh_completeness-aware_2020}, an improvement of the clustering
% by further semantic constraints was suggested.
% The proposed approach in \cite{gu_semantics_2019} also uses
% clustering, but by cosine distance. Their method is supervised in that
% they try to find a normalized concept vector for a concept given by
% positive samples. An interesting finding was that the chosen
% semantic concepts usually have a clearly dominant cluster in the
% latent space.
% For regularization, they binarize the entries in the latent space vectors to cluster.
%
In TCAV~\cite{kim_interpretability_2018} it is claimed that the
mapping from semantic to latent space should be linear for best
interpretability. To achieve this, they suggest to use linear
classifiers as concept embeddings. This means they try to find a
separation hyperplane between the latent space representations of
positive and negative samples of the concept.
A normal vector of the hyperplane then is their concept vector,
and the distance to the hyperplane
% measured by the scalar product with the concept vector
is used as distance measure.
As method to obtain the embedding they use support vector machines (SVMs).
TCAV further investigated the contribution of concepts to given output
classes by sensitivity analysis.
A very similar approach to TCAV, only instead relying on logistic
regression, is followed by Net2Vec~\cite{fong_net2vec_2018}.
% They directly built upon Network Dissection~\cite{bau_network_2017},
% which tries to associate concepts to single filters in convolutional
% DNNs (the unit vectors in the latent space of an activation map pixel).
% Just as Network Dissection, Net2Vec
As a regularization, they add a filter-specific cut-off before the
concept embedding analysis to remove noisy small activations.
% They apply a ReLU to the activation map of each filter with fixed
% filter-specific threshold.
% Other than TCAV, they constrain the hyperplane to run
% through zero, \idest assume $t_c=0$, which may lead to worse embedding
% performance.
The advantage of Net2Vec over the SVMs in TCAV is that they can
more easily be used in a convolutional setting: They used a
1$\times$1-convolution to do a prediction of the concept for each
activation map pixel, providing a segmentation of the concept.
This was extended by \cite{schwalbe_concept_2020}, who suggested to
allow larger convolution windows
% , essentially doing a simplified concept detection.
to ensure that the receptive field of the window can cover
the complete concept. This avoids a focus on local patterns.
% instead of \forexample the concept shape.
% They also investigated some improvements on the optimization
% technique.
%
A measure that can be applied to concept vectors of the same layer
regardless of the analysis method, is that of
\emph{completeness} suggested in \cite{yeh_completeness-aware_2020}.
They try to measure, how much of the information relevant to the final
output of the DNN is covered by a chosen set of concepts vectors.
% Their idea for measurement is as follows: If the layer output is
% reduced to the linear sub-space spanned by the concept vectors, the
% overall performance of the DNN should not drop significantly if the
% set of concepts is complete.
% This reduction was approximated by adding a bottleneck layer right
% after the considered layer, where the unit vectors correspond to the
% concepts.
% The projection is defined by the concept vectors, the connection to
% the succeeding layer is learned.
They also suggested a metric to compare the attribution of each
concept to the completeness score of a set of concepts.

\subsection{Inductive Logic Programming}\label{sec:ilp}

Inductive Logic Programming (ILP)~\cite{muggleton1991inductive} is a
machine learning technique that builds a logic theory over positive
and negative examples ($E^+$, $E^-$). The examples consist of symbolic
background knowledge (BK) in the form of first-order logic predicates,
\forexample \ilprule{contains(Example, Part), isa(Part, nose)}. Here the
upper case symbols are variables and the lower case symbol is a
constant. The given BK describes that example \ilprule{Example}
contains a part \ilprule{Part} which is a nose. Based on the examples,
a logic theory can be learned. The hypothesis language of this theory
consists of logic Horn clauses that contain predicates from the BK. We
write the Horn clauses as implication rules,
\forexample
\ilprule{
  \begin{align*}
    \text{face(Example) :- }& \text{contains(Example, Part), isa(Part, nose)}\;.
  \end{align*}
}
For this work we obey the syntactic rules of the Prolog
programming language. The \ilprule{:-} denotes the logic implication
($\leftarrow$). We call the part before the implication the
\emph{head} of a rule and the part after it the \emph{body} or
\emph{preconditions} of a rule.

We use the framework Aleph~\cite{srinivasan2001aleph}
for this work since it is a flexible and adaptive general purpose ILP
toolbox. Aleph's built in algorithm attempts to induce a logic theory
from the given BK to cover as many positive examples $E^+$ as possible
while avoiding covering the negative examples $E^-$. The general
algorithm of Aleph can be summarized as
follows~\cite{srinivasan2001aleph}:

\begin{enumerate}
\item As long as positive examples exist, select one. Otherwise halt.
\item Construct the most-specific clause that entails the selected example and is within the language constraints.
\item Find a more general clause which is a subset of the current literals in the clause.
\item Remove examples covered by the current clause.
\item Repeat from step 1.
\end{enumerate}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "concept_embeddings_and_ilp"
%%% End: