text:
\documentclass[10pt]{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{spverbatim}
\sloppy

\usepackage{xr}
\externaldocument{move-op}

\newcommand{\todo}[1]{\textcolor{red}{TODO: #1}}
\newcommand{\authorcomment}[1]{\begin{quote}\textbf{Author comment:} #1\end{quote}}

\begin{document}
\title{Summary of changes to ``A highly-available move operation for replicated trees''}
\author{Martin Kleppmann, Dominic P.\ Mulligan, Victor B.F.\ Gomes, Alastair R.\ Beresford}
\date{}
\maketitle

We thank the reviewers very much for their comments, which have improved the paper.
In this document we explain how we have addressed the issues highlighted in the reviews.
The most important changes are as follows:
\begin{itemize}
\item We have changed the title (previously \emph{``A highly-available move operation for replicated trees and distributed filesystems''}) to remove \emph{``and distributed filesystems''}, as suggested by Reviewer 2.
\item We have added an optimisation for operations that create new tree nodes, allowing them to be applied without any undo or redo, and proved using Isabelle/HOL that this optimisation is safe.
We have also added an explanation of why the same optimisation does not work for removing tree nodes, addressing point C3 by Reviewer 2.
\item We have created an optimised alternative implementation of our algorithm, and added it to the performance evaluation.
The optimised implementation is not formally verified, but it is approximately 10 times faster than the verified code generated by Isabelle/HOL.
This implementation significantly narrows the performance gap between our algorithm and state machine replication.
This addresses point C7 by Reviewer 2.
\item We have expanded the discussion of related work as suggested by the reviewers, re-run all of the experiments, and made various other improvements to clarity.
\end{itemize}

\section{Reviewer 1}

\begin{spverbatim}
Recommendation: Author Should Prepare A Major Revision For A Second Review

Comments:
Introduction section offers very brief and simplified coverage of common topics and don't really offer anything new.
It would be even more valuable if some critical comparisons were made among the systems and approaches. There is no discussion that could help the reader understand that, given a particular system/approach configuration or set of performance or availability goals, approach X would be preferable to approach Y.
\end{spverbatim}
\authorcomment{Section \ref{sec:smr} contains a discussion of the trade-offs between our algorithm, locking, and state machine replication, including an explanation of the situations in which a particular approach would be preferable.
These are all the approaches that we currently know of.}
\begin{spverbatim}
In Section 3.5, please explain all cases with examples.
\end{spverbatim}
\authorcomment{Done.}
\begin{spverbatim}
My main concern is whether the comparison is fair. It shows that some results are achievable. How could one trustfully decide to apply the operations on the basis of these results for another scenario?
\end{spverbatim}
\authorcomment{We requested clarification from the reviewer (via the editor) as to which specific aspects of our evaluation they believed to be unfair, but we did not receive any reply.
Without a concrete request it is impossible for us to address this point.}
\begin{spverbatim}

Additional Questions:
1.  Please explain how this manuscript advances this field of research and/or contributes something new to the literature.: It presents move operation for distributed filesystems.

2. Is the manuscript technically sound? Please explain your answer under Public Comments below.: Yes

1. Which category describes this manuscript?: Practice / Application / Case Study / Experience Report

2. How relevant is this manuscript to the readers of this periodical? Please explain your rating under Public Comments below.: Relevant

1. Are the title, abstract, and keywords appropriate? Please explain under Public Comments below.: Yes

2. Does the manuscript contain sufficient and appropriate references? Please explain under Public Comments below.: Important references are missing; more references are needed
\end{spverbatim}
\authorcomment{We asked the reviewer to name the references they wanted us to add (again via the editor), but we did not receive a response.
The editor advised us to prepare a revision based on the other reviews.}
\begin{spverbatim}
3. Does the introduction state the objectives of the manuscript in terms that encourage the reader to read on? Please explain your answer under Public Comments below.: Could be improved

4. How would you rate the organization of the manuscript? Is it focused? Is the length appropriate for the topic? Please explain under Public Comments below.: Could be improved

5. Please rate the readability of the manuscript. Explain your rating under Public Comments below.: Readable - but requires some effort to understand

6. Should the supplemental material be included? (Click on the Supplementary Files icon to view files): Yes, as part of the digital library for this submission if accepted

7. If yes to 6, should it be accepted: After revisions.  Please include explanation under Public Comments below.

8. Would you recommend adding the code/data associated with this paper to help address your concerns and/or strengthen the paper?: Yes

Please rate the manuscript. Please explain your choice.: Good
\end{spverbatim}

\section{Reviewer 2}

\begin{spverbatim}
Recommendation: Author Should Prepare A Major Revision For A Second Review

Comments:
## Is the manuscript technically sound?
Yes. As stated before the paper has a clear contribution, which includes a mechanised proof of the algorithm correctness. Moreover, the proof code is presented in the appendix and is available online with instructions on how to check proofs locally.

## How relevant is this manuscript to the readers of this periodical?
The topic is relevant for TPDS community as it proposes a distributed algorithm to support optimistic replication of tree data structures.

## Are the title, abstract, and keywords appropriate?
Yes. However, it is unclear why is necessary to include "distributed filesystems" in the title. The work is concerned with a tree replicated datatype and distributed filesystems is an application.
\end{spverbatim}
\authorcomment{We have removed this part of the title as suggested.}
\begin{spverbatim}
## Does the manuscript contain sufficient and appropriate references?
The following reference should be included and is missing:

De Porre K, Myter F, De Troyer C, Scholliers C, De Meuter W, Boix EG. Putting order in strong eventual consistency. In IFIP International Conference on Distributed Applications and Interoperable Systems 2019 Jun 17 (pp. 36-56). Springer, Cham.

De Porre et al. work proposes an optimistic replication algorithm that can transform a general-purpose data type into a replicated data type. Similarly to the submitted paper, strong eventual consistency is ensured by maintaining a global total order of the operations. Since the case study in De Porre's paper is an AVL tree, a comparison should be included in the related work.
\end{spverbatim}
\authorcomment{Thank you for pointing out this paper, which we had missed. We now discuss it in Section~\ref{sec:oplogs}.}
\begin{spverbatim}
## Does the introduction state the objectives of the manuscript in terms that encourage the reader to read on?
I found the introduction enticing and, although brief, it does a great job in defining the context, illustrating the problem, and clearly defining the contributions.

## How would you rate the organization of the manuscript? Is it focused? Is the length appropriate for the topic?
The paper is well structured. I particularly liked section 2 that clearly illustrates the main issues with concurrent non-coordinated move operations. Also, by showing that the replicated filesystems of Dropbox and Google drive both have bugs demonstrates how difficult is to devise a correct resolution policy for the move operation. Overall, section 2 nicely shows the work relevance and potential impact without getting too technical.
The replication algorithm is thoroughly described and the proof of correctness is presented at the right level of detail - although the proofs are an essential component a more detailed presentation would become tedious.

## Please rate the readability of the manuscript.
The paper is well written and easy to follow.

## Detailed comments

C1: The system model and network requirements should be explicitly defined.
\end{spverbatim}
\authorcomment{We have improved the description of the system model at the beginning of Section~\ref{sec:algorithm}.}
\begin{spverbatim}
C2: Is the metadata parameter necessary? It seems that this parameter could be abstracted away which would simplify the algorithm presentation.
\end{spverbatim}
\authorcomment{The metadata is not needed for the functioning of our algorithm per se, but it is needed for several applications of our algorithm, such as filesystems (metadata is a filename) or JSON/XML (metadata indicates the order of children of the same parent).
Since it does not significantly complicate the algorithm, we would prefer to keep it as-is.}
\begin{spverbatim}
C3: Further justification is needed for choosing to encode add and remove operations as move operations. My intuition, base on previously published results as CISE and Hamsaz, is that not all operations need to follow a total ordered across replicas. However, because all operations are defined as moves, conflicts are always possible. I was left wondering if by having explicit add and remove operations some undo-do-redo cycles could be avoided.
\end{spverbatim}
\authorcomment{We have done substantial further work on this question, and added Section~\ref{sec:create} to discuss it.
In particular, we have proved in Isabelle that creation operations can skip the undo/redo process, provided that some additional assumptions are met.
We now also explain why the same optimisation does not work for remove operations.}
\begin{spverbatim}
C4: Instead of having an undo-do-redo cycle would it be possible to have state checkpoints? As operations might arrive in any order, the number of operations to undo can be high, in that case, it might be useful to have state checkpoints and combine these with undo operations.
\end{spverbatim}
\authorcomment{Periodically checkpointing the state would indeed reduce the number of operations to undo, since a replica could jump to the checkpoint nearest to the log position where a new operation needs to be inserted.
However, we believe that this would not bring about a large performance improvement, because we would still have to perform the redo step for all operations with timestamps greater than the new operation, which still has a cost that is proportional to the number of operations we have to undo if there are no checkpoints.

This redo is necessary because the new operation may cause any subsequent operation to flip from safe to unsafe or vice versa, and so we have to recompute that safety status for all operations with timestamps greater than the new operation.}
\begin{spverbatim}
C5: Notation is not consistent. It is stated that types are primed letters (2nd paragraph of section 3.1), however, this naming convention is dropped later on.
\end{spverbatim}
\authorcomment{We have carefully checked the paper and confirmed that the notation is correct.

Primed letters are \emph{type variables}, not concrete types.
For example, the type of our tree is written in Isabelle as $('n \times '\!m \times '\!n)\;\mathit{set}$, which means a set of triples where the first and third element of each triple have the same type (since they both represent a tree node, namely the parent and the child).
The type variable $'n$ can then be instantiated with any concrete type; for example, in our evaluation it is a 64-bit integer.}
\begin{spverbatim}
C6: The evaluation proves the point that the tree CRDT is the best option for fast response time and disconnected mode (in this case it is the only option).

C7: The choice of using the extracted code for the evaluation is questionable. Stating that the code could be optimised, does not provide useful information. It is unclear what the impact would be if optimisations were applied. It's reasonable to conclude that the comparison between the proposed CRDT and state machine replication would be maintained, but the optimised code would give a clear evaluation of the tree CRDT.
\end{spverbatim}
\authorcomment{We have implemented an alternative version of the algorithm directly in Scala, and added it to the evaluation.
It is almost 10 times faster than the Isabelle-generated code in terms of the CRDT operation throughput it can sustain.
This work allows us to distinguish between the costs that are incidental inefficiencies of Isabelle's generated code, and the costs that are inherent to our algorithm.
We thank the reviewer for prompting this work, which we believe has made the paper stronger.}
\begin{spverbatim}

## Overall evaluation

I really enjoyed reading this paper, it's well written and easy to follow and addresses a relevant topic to the TPDS community.
It has a novel contribution as it defines an optimistic replication algorithm for trees that ensures convergence and the structural properties of trees. The idea behind the tree CRDT is simple, but it provides a solution to an existing problem. The fact that authors found problems in widely used applications that could be addressed with the tree CRDT proves its usefulness.
The fact the CRDT was formally verified for any number of replicas and a certified implementation was extracted from the formal definitions, strengths considerably the submission.
There are some choices that need to be further discussed and the evaluation should consider an optimised implementation of the algorithm.
\end{spverbatim}
\authorcomment{Done.}
\begin{spverbatim}
Additional Questions:
1.  Please explain how this manuscript advances this field of research and/or contributes something new to the literature.: The paper presents the first tree replicated data type that allows concurrent move operations without any coordination between replicas. The tree data type relies on an optimistic replication algorithm that ensures state convergence and that the tree structure properties are preserved at all times. Given the complex (inductive) structure of trees, a strong point of the work is the mechanised proof that provides certification for the correctness of the algorithm.

2. Is the manuscript technically sound? Please explain your answer under Public Comments below.: Yes

1. Which category describes this manuscript?: Research/Technology

2. How relevant is this manuscript to the readers of this periodical? Please explain your rating under Public Comments below.: Relevant

1. Are the title, abstract, and keywords appropriate? Please explain under Public Comments below.: Yes

2. Does the manuscript contain sufficient and appropriate references? Please explain under Public Comments below.: Important references are missing; more references are needed

3. Does the introduction state the objectives of the manuscript in terms that encourage the reader to read on? Please explain your answer under Public Comments below.: Yes

4. How would you rate the organization of the manuscript? Is it focused? Is the length appropriate for the topic? Please explain under Public Comments below.: Satisfactory

5. Please rate the readability of the manuscript. Explain your rating under Public Comments below.: Easy to read

6. Should the supplemental material be included? (Click on the Supplementary Files icon to view files): Yes, as part of the digital library for this submission if accepted

7. If yes to 6, should it be accepted: After revisions.  Please include explanation under Public Comments below.

8. Would you recommend adding the code/data associated with this paper to help address your concerns and/or strengthen the paper?: No

Please rate the manuscript. Please explain your choice.: Excellent
\end{spverbatim}

\section{Reviewer 3}

\begin{spverbatim}
Recommendation: Accept With No Changes

Comments:
The paper presents an implementation of a replicated tree data type with operations for adding, removing, and moving tree nodes. Replicated tree data types are essential basic blocks of a wide range of distributed software like distributed file systems, editors, applications manipulating XML/JSON structures, etc. While replication is needed to ensure resilience to network/machine failures, an important and difficult challenge in this context is ensuring some form of convergence, e.g., that all the nodes storing a replica of the data structure (tree) reach the same state when all the updates have been propagated in the network. This is an instance of strong eventual consistency. The paper presents a solution to this challenge that provides high availability as well (clients do not need to wait for the replicas to synchronize), and that is also formally verified in the Isabelle/HOL theorem prover.

The paper starts with a very clear description of the motivation, noting that current solutions for the above challenge, deployed in Google Drive or Dropbox, are not satisfactory. The Google Drive solution may lead to unexpected errors while the Dropbox solution may duplicate nodes of the tree which may impact the user experience. It identifies the main challenge in designing replicated trees which is related to the move operation: moving a tree node so that it becomes the child of a different parent. In fact, node insertion and removal can be reduced to move operations.

Then, it describes an implementation that in particular, solves the issues in Google Drive or Dropbox, which is based on a very neat and simple idea. Essentially, every operation is associated with a timestamp (one can use Lamport timestamps [11] and avoid synchronized clocks), and every replica maintains a tree and a log of operations (issued locally or remote operations received from other replicas), ordered by timestamps. Applying a remote operation O with timestamp T consists in undoing operations with a timestamp bigger than T, applying O, and finally, re-applying the undone operations. This solution, which is quite generic and could be applied for other data types as well, makes it possible to handle concurrent move operations that try to move the same node (taking into account only the one with a bigger timestamp like in Last Writer Wins conflict resolution [10]), and avoid introducing cycles due to concurrent move operations. It also ensures strong eventual consistency because when all the updates are received, any two replicas apply them in the same order (according to their timestamps). The fact that the implementation satisfies strong eventual consistency and that every replica stores a tree (without cycles) is proved in the Isabelle/HOL theorem prover. The implementation in Isabelle is compiled to executable Scala code which is evaluated in a rather realistic deployment (with three replicas on different continents) and compared to a standard master-slave implementation where the order between operations is managed by a single master node. This evaluation shows that indeed, the current solution has very low latency compared to the master-slave implementation, although a smaller throughput.

The related work is quite extensive, covering the literature on Conflict-Free Data Types (the implementation in this paper being an instance of such a datatype), distributed file systems (the main application of this work), and works that use similar implementation ideas, based on timestamps.

Overall, I think that the paper is very well written. The motivation and the description of the challenges are very convincing, the flow of the ideas being very easy to follow. Technically, the implementation relies on an idea which is simple in hindsight, but which has not been used in previous work (up to my knowledge), and which seems to have a very important practical impact. The formalization and proofs in Isabelle/HOL are a very important and non-trivial contribution which is meant to increase the confidence we have in this solution.

Additional Questions:
1.  Please explain how this manuscript advances this field of research and/or contributes something new to the literature.: The paper presents a new formally-verified implementation of a replicated tree data type, which is an essential ingredient of a wide range of distributed software like distributed file systems, editors, applications manipulating XML/JSON structures, etc. This implementation is highly-available (the latency of applying an operation is independent of the network's latency) and eventually consistent (all replicas reach the same state when all updates have been propagated). These properties are essential in modern distributed services. The implementation solves existing issues in industrial applications like Google Drive and Dropbox, and contradicts claims about the existence of such an implementation in previous research articles.

2. Is the manuscript technically sound? Please explain your answer under Public Comments below.: Yes

1. Which category describes this manuscript?: Research/Technology

2. How relevant is this manuscript to the readers of this periodical? Please explain your rating under Public Comments below.: Very Relevant

1. Are the title, abstract, and keywords appropriate? Please explain under Public Comments below.: Yes

2. Does the manuscript contain sufficient and appropriate references? Please explain under Public Comments below.: References are sufficient and appropriate

3. Does the introduction state the objectives of the manuscript in terms that encourage the reader to read on? Please explain your answer under Public Comments below.: Yes

4. How would you rate the organization of the manuscript? Is it focused? Is the length appropriate for the topic? Please explain under Public Comments below.: Satisfactory

5. Please rate the readability of the manuscript. Explain your rating under Public Comments below.: Easy to read

6. Should the supplemental material be included? (Click on the Supplementary Files icon to view files): Yes, as part of the digital library for this submission if accepted

7. If yes to 6, should it be accepted: As is

8. Would you recommend adding the code/data associated with this paper to help address your concerns and/or strengthen the paper?: Yes

Please rate the manuscript. Please explain your choice.: Excellent
\end{spverbatim}
\authorcomment{Thank you for the very positive review!}
\end{document}

max_stars_repo_name: trvedata/move-op

max_issues_repo_name: trvedata/move-op

max_forks_repo_name: trvedata/move-op


text:
\section*{Figure Legends}

\textbf{Figure \ref{fig:Fig1}. The git add/commit process.}
To store a snapshot of changes in your repository, first \verb|git add| any files to the staging area you wish to commit (for example, you've updated the \verb|process.sh| file).
Second, type \verb|git commit| with a message. Only files added to the staging area will be committed.
All past commits are located in the hidden \verb|.git| directory in your repository.

\textbf{Figure \ref{fig:Fig2}. Working with a local repository.}
A) To designate a directory on your computer as a Git repo, type the command \verb|git init|.
This initializes the repository and will allow you to track the files located within that directory.
B) Once you have added a file, follow the git add/commit cycle to place the new file first into the staging area by typing \verb|git add| to designate it to be committed, and then \verb|git commit| to take the shapshot of that file.
The commit is assigned a commit identifier (d75es) that can be used in the future to pull up this version or to compare different committed versions of this file.
C) As you continue to add and change files, you should regularly add and commit those changes.
Here, an additional commit was done and the commit log now shows two commit identifiers: d75es (from step B) and f658t (the new commit).
Each commit will generate a unique identifier, which can be examined in reverse chronological order using \verb|git log|.

\textbf{Figure \ref{fig:Fig3}. Working with both a local and remote repository as a single user.}
A) On your computer you commit to a Git repository (commit d75es).
B) On GitHub, you create a new repository called \verb|thesis|.
This repository is currently empty and not linked to the repo on your local machine.
C) The command \verb|git remote add| connects your local repository to your remote repository.
The remote repository is still empty, however, because you have not pushed any content to it.
D) You send all the local commits to the remote repository using the command \verb|git push|.
Only files that have been committed will appear in the remote repository.
E) You repeat several more rounds of updating scripts and committing on your local computer (commit f658t and then commit xv871).
You have not yet pushed these commits to the remote repository, so only the previously pushed commit is in the remote repo (commit d75es).
F) To bring the remote repository up-to-date with your local repository, you \verb|git push| the two new commits to the remote repository.
The local and remote repositories now contain the same files and commit histories.

\textbf{Figure \ref{fig:Fig4}. Contributing to Open Source Projects.}
We would like you to add an empty file that is named after your GitHub username to the repo used to write this manuscript.
A) Using your internet browser, navigate to \href{https://github.com/jdblischak/git-for-science}{github.com/jdblischak/git-for-science}.
B) Click on the ``Fork'' button to create a copy of this repo on GitHub under your username.
C) On your computer, type \verb|git clone https://github.com/username/git-for-science.git|, which will create a copy of git-for-science on your local machine.
D) Navigate to the \verb|readers| directory by typing \verb|cd git-for-science/readers/|.
Create an empty file that is titled with your GitHub username by typing \verb|touch username.txt|.
Commit that new file by adding it to the staging area (\verb|git add username.txt|) and committing with a message (\verb|git commit -m "Add username to directory of readers."|).
Note that your commit identifier will be different than what is shown here.
E) You have committed your new file locally and the next step is to push that new commit up to the git-for-science repo under your username on GitHub.
To do so, type \verb|git push origin master|.
F) To request to add your commits to the original git-for-science repo, issue a pull request from the git-for-science repo under your username on GitHub.
Once your Pull Request is reviewed and accepted, you will be able to see the file you committed with your username in the original git-for-science repository.

ext: tex

max_stars_repo_name: Hennebe/git-for-science

max_issues_repo_name: Hennebe/git-for-science

max_forks_repo_name: Hennebe/git-for-science


text:
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{courier} %% Sets font for listing as Courier.
\usepackage{listings, xcolor}
\usepackage{biblatex}
\usepackage{subcaption}

\addbibresource{test.bib}

\lstset{
tabsize = 4, %% set tab space width
showstringspaces = false, %% prevent space marking in strings, string is defined as the text that is generally printed directly to the console
numbers = left, %% display line numbers on the left
commentstyle = \color{green}, %% set comment color
keywordstyle = \color{blue}, %% set keyword color
stringstyle = \color{red}, %% set string color
rulecolor = \color{black}, %% set frame color to avoid being affected by text color
basicstyle = \ttfamily , %% set listing font and size
breaklines = true, %% enable line breaking
numberstyle = \tiny,
}

\title{Professional Practice in IT Project}
\author{
  Conor Shortt\\
  \href{https://github.com/conorshortt123}{Github}
  \and
  Blaine Burke\\
  \href{https://github.com/BurkeBlaine1999}{Github}
  \and
  Mark Reilly\\
  \href{https://github.com/MarkReillyGMIT}{Github}
}
\date{\today}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[scale=0.3]{./images/gmit.jpg}
\end{figure}

\maketitle

\tableofcontents
\newpage

\section{Introduction}
For our 3rd year project for professional practice in IT, we decided to design a full stack web application which uses Facial recognition software\cite{ageitgey} to log into a web page which
in turn allows the user to search a database to view other users information.\medskip

For the Front-end portion we chose to use Flask which is a micro framework written in Python,we chose Flask because it is extremely flexible, relatively easy to learn and use, and allows for more control over what components to use such as the type of database.\medskip

For the Back-end portion after a lot of research and testing for different ways to achieve communication between Front and Back end, the decision was made to use MongoDB.During the first few weeks we used Flask-SQLAlchemy but later changed to MongoDB which allowed the database to be accessed remotely by each project member.\medskip

Our main objectives for the project were:
\begin{enumerate}
\item Have a working login system using facial recognition
\item Improve communication skills in a project based environment
\item Learning new technologies
\item Learning more about database communication
\end{enumerate}

\newpage

\section{System Requirements}
In order to run the project, there are several requirements needed.
\begin{itemize}
  \item A webcam is required to use the App as when it comes to logging in you will be prompted to scan your face for two factor authentications.  You are also required to upload a self-portrait Image of yourself in order to register an account.
  \item You are required to install the latest version of \href{https://www.python.org/downloads/}{python 3.}\cite{python}
  \item The project decencies are required to run our application. To install them follow the steps below!
    \begin{enumerate}
    \item Clone the project to your desktop.
    \item Open the project and open command prompt
    \item Enter ‘pip install -r requirements.txt’ to download the dependencies
    \end{enumerate}
    \begin{center}
        \includegraphics[scale=0.8]{images/requirementsInstall.png}
    \end{center}
  \item You are required to have \cite{cmake}\href{https://cmake.org/}{Cmake} and \cite{dlib}\href{http://dlib.net/}{Dlib} installed
  \item A text/Script editor you have installed. For example Visual Studio Code
\end{itemize}

\begin{center}
\includegraphics[scale=0.10]{./images/Python-logo.png}
\\
\includegraphics[scale=0.7]{images/cmake75.png}
\end{center}

\newpage

\section{Technology Used}
\begin{enumerate}
\item \href{https://www.python.org/downloads/}{Python}\cite{python} \\
We used python as our programming language as it has wide variety of libraries we could use making it our best option over other languages. Python is also very simple to use , proof being that this is our first python project .
\item \href{https://flask.palletsprojects.com/en/1.1.x/}{Flask} \cite{flask} \\
We used Flask as our python framework for our web application.
Flask is a small and powerful web framework for Python.
It's easy to learn and simple to use, enabling you to build your web app in a short amount of time. Flask can be used for building complex, database-driven websites
We chose flask due to its extensive documentation online so if we had issues we could easily find a solution to any problem.
\item \href{https://www.mongodb.com/}{MongoDB} \cite{mongodb} \\
MongoDB is an open source database management system (DBMS) that uses a document-oriented database model which supports various forms of
Data. This is one reason we chose it as we have several different types of data we needed to add such as numpy and binary arrays. It  also has  a very flexible data model and is very easy to learn!

\item Webcam \\
We chose to use a webcam as we required one for facial recognition.
A webcam is essential for our application as without a webcam the user cannot login to our App due to our facial recognition two factor authentication.
Any webcam should work that is connected to your Computer.

\item \href{https://pillow.readthedocs.io/en/stable/}{PIL}  \cite{PIL} \\
PIL is the Python Imaging Library by Fredrik Lundh and Contributors.
We used PIL to convert images to bytes then to base 64 so we can easily store it on our database.

\item \href{https://github.com/ageitgey/face_recognition}{Face recognition Module} \cite{ageitgey} \\
We used \href{https://github.com/ageitgey}{Adam Geitgeys}  \cite{ageitgey} \href{https://github.com/ageitgey/face_recognition}{Face recognition Module} in our project for our two factor authentication when logging in

\item \href{https://flask-bcrypt.readthedocs.io/en/latest/}{Flask-Bcrypt} \\
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. We used bcrypt to hash the users password to implement a high level of security.

\item \href{https://flask-login.readthedocs.io/en/latest/}{Login Manager} \\
Flask-Login provides user session management for Flask. It handles the common tasks of logging in, logging out, and remembering your users’ sessions over extended periods of time.Login manager made the login system run more efficiently.
\end{enumerate}

\newpage

\section{Design Methodology}
When starting our project we specified our language we would use, our end goals  and what imports we could use.\medskip

\textbf{Setting our End Goals} \\
When we began our project, we, as a team decided on some end goals for our project.  We chose that our project would be a web application made using Python that uses facial recognition when logging in, in order to access a database containing all the user’s data.
At first, we were caught between the Flask and Django framework. Ultimately, we chose flask because it’s a small and powerful web framework, it’s easy to learn, flexible and simple to use.\medskip

\textbf{Choosing our storage method} \\
After deciding which framework we were going to use, we had to then chose which type of database was best to use with Flask. At the beginning we picked Flask-SQLAlchemy as it work very effectively and easily with Flask. After much consideration we decided that it would be best to change to using MongoDB because it would allow all the data in the database to be accessed remotely by each of us.\medskip

\textbf{Step One - Prepare the 3 main aspects individually} \\
After this we all began to work individually to get the three main aspects of the project functioning. These are the Facial recognition API , the backend server and the frontend built with flask. We spent approximatly 2 to 3 weeks building these individually. Once completed we began to implement them together.\medskip

\textbf{Step Two - Integration} \\
We began by taking the server and integrating it into the flask app. This was due to the fact that implementing the Facial recognition required the login and register to be working before it could be used.
Once the backend was implemented we added the facial recognition API as our two factor authentication.\medskip

\textbf{Step Three - Improving efficiency} \\
With the whole app finally together we set out on improving the apps overall efficiency by  removing any unnecessary code that was left in. During this process we greatly improved the time it takes to launch the localhost server.\medskip

\textbf{Step Four - Improve accesibility,Ergonomics and clean up code} \\
Now that the bulk of the work was done we had to clean up our code and UI. We began to add more detailed,updated comments to our code to make it more accessible to others. We made our Flask app more ergonomic so anyone using the app for the first time could easily understand how it works! During this process we also improved the overall aesthetics of the Application.

\begin{figure}[h!]
\centering
\includegraphics[scale=0.25]{images/Plan.jpg}
\caption{Our initial plan }
\end{figure}

\newpage

\section{Limitations and known bugs}
Throughout the course of making out project we encountered many bugs and limitations but we gradually over came them and worked around them.
\begin{enumerate}
\item \textbf{MongoDB} \\
When it came to connecting the MongoDB server, at first it would not connect and would throw errors whenever we tried to call from it. After several YouTube tutorials and after scrolling through several different stack overflow forums we figured it out and implemented the fixes.
\item \textbf{Dlib} \\
With Dlib we found it tough to get it installed correctly. In the beginning we could not figure out to get it installed properly as it would keep throwing errors every time, we called it. In the end with some research and determination we eventually got Dlib correctly working on our systems
\item \textbf{Facial Recognition} \\
In regards to the facial recognition side of the project, we originally had live facial recognition partially implemented. The idea was it would draw a box around the face of the user in the login screen, displaying their name at the bottom of the box if they were detected correctly, or "Unknown" if they weren't detected, but the limitation of this was that it was significantly more resource intensive to do live facial recognition. This is why we changed it to a single frame being captured and processed without drawing anything or altering the image taken.
\item \textbf{Storing Images in the Database} \\
Limitations of the database which we weren't aware of until later on was that we were not able to store images unless they were converted to bytes and then converted to a binary base64 array. We stored two arrays on the database, one for decoding to an image to be displayed on the search page, and one for decoding to numpy array to be used for facial recognition.
\item \textbf{Capturing images with webcam} \\
A bug that plagued us for quite a long time was that upon capturing and image with the webcam and saving it locally, trying to display that subsequent image straight away resulted in the webpage displaying the wrong image. To solve this we used ajax to update the webpage without reloading and this displayed the correct image.
\item \textbf{Flask} \\
With Flask we found throughout the project when importing different functions from within the project, it could not find the function.This lead to a great deal of time being consumed with fixing the imports and solving the bugs. In the end after lots of testing the importing of various functions was solved.

\end{enumerate}

\newpage

\section{Features of the Implementation}
There are several features available in our project.
\begin{enumerate}

    \item A Register system that requires several details such as the username and stores the details to a database.
    Due to our databases primary key being the username, they must all be different.
    See image (a) below.

    \begin{figure}[h!]
      \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/Register.png}
        \caption{The Register page}
        \label{fig:1}
      \end{subfigure}
      %
      \begin{subfigure}[b]{0.42\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/Login.png}
        \caption{The Login page}
        \label{fig:2}
      \end{subfigure}
    \end{figure}

    \item A Login system that validates the Users Username and password by checking if they match the records in the database. See image (b) above

    \begin{figure}[h!]
    \centering
      \begin{subfigure}[]{0.4\textwidth}
      \centering
        \includegraphics[width=\textwidth]{images/SamplePictures/logout.png}
        \caption{The Logout buttons}
        \label{fig:1}
      \end{subfigure}
    \end{figure}

    \item A Login / Logout system that allows the current user of a session to logout once logged in to allow another user to log in on the same device!\\ See Figure (a) above.

    \newpage

    \item A search bar that allows the user to search through the database  via username and retrieve the users profile.
    This contains their profile photo, username and email. See figure (a) below.
    \begin{figure}[h!]
      \begin{subfigure}[b]{0.5\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/Search.png}
        \caption{The Search page}
        \label{fig:1}
      \end{subfigure}
      %
      \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/Account.png}
        \caption{The Account page}
        \label{fig:2}
      \end{subfigure}
      %
      \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/Conor.png}
        \caption{Conors profile when searched}
        \label{fig:2}
      \end{subfigure}
     %
      \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/Mark.png}
        \caption{Marks profile when searched}
        \label{fig:2}
      \end{subfigure}
    \end{figure}
    \item An account button that allows the current user to view their own profile. See figure (b) above.
    \item Facial recognition Login which takes the users profile image from registration and compares it to the live image taken when the user enters their correct login details, this adds another layer of security to the application. See Figure (a) below
    \begin{figure}
    \centering
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{images/SamplePictures/FaceRec.png}
        \caption{The Facial recognition page}
        \label{fig:2}
    \end{subfigure}
    \end{figure}
\end{enumerate}

\newpage

\section{Testing Plans}

\begin{enumerate}
\item \textbf{Testing} \\
When it came to testing  our App we used mostly white box testing where the tester knows the internals of the code being tested and a small bit of black box testing where the tester knows nothing of the internals of the code.
\item \textbf{White box Testing} \\
White box testing allowed us to test our code faster and more efficiently but black box testing proved useful as it gave us the opinion of an outside source  , helping us get more ideas and opinions and allowed us to see if our app is ergonomic to a wide range of users and easy to navigate through.
\item \textbf{Black box Testing} \\
When we were black box testing we deliberately attempted to break our app. This is so we could try be prepared for any errors that may occur making our application less likely to crash
\item \textbf{Testing facial recognition} \\
When it came to testing the facial recognition module we tried different varients of lighting and also tried taking images without any face in it.At first having no face in the image would cause an error to occur but we solved this issue.
\item \textbf{Testing the Database} \\
With the database we tried putting many different types of data into it to see what we were limited to. We discovered the images were too large for the database when not encoded so when we pushed them to the database we had to encode them and decode them when we pulled them.
\item \textbf{Testing flask} \\
When testing the flask application , we tried several aspects such as refreshing the page after logging in , entering incorrect details etc. We found a few bugs that would cause the login button to stay appearing when logged in but this issue was solved by setting the sessions state to logged in.
\end{enumerate}
\newpage

\section{Recommendations for Future Development}
There are many aspects of this project that could be expanded upon after the duration of the allotted project time. We were limited by time but certainly we could improve many aspects of our software. There were three main areas that we developed as part of our project. I developed the facial recognition scripts and camera, Blaine developed the MongoDB backend aspect\cite{mongodb}, and Mark developed the frontend Flask web application.\cite{flask}
\\
\subsection{Current State of the Software}
Currently the software is extremely malleable and not concrete by any means. It could certainly be taken in almost any direction. As of right now it features a database connected to the frontend flask application. With two factor authentication (Enter details and also facial recognition) as part of logging in. This software could potentially be used in several ways as I will highlight below.

\subsection{Potential Future Uses}
\textbf{Student Database}\\\\
We discussed many ideas and plans of what we were going to aim for when making the software, we settled on a database where we could search for a student username and it would get their details from the database and return them. The idea is that this is tailored towards teachers where they log in with two factored authentication using their details and their face.
\\\\\\
\textbf{Criminal Records Database}\\\\
Another direction that this software could easily be brought in is a criminal records database. The user of this software would be a police officer or a prison warden perhaps. They log in with their details and face and then can subsequently scan a persons face who they have possibly stopped on the road, if the persons face is registered in the database it will pull down their details.
\\\\\\
\textbf{Database for Employees}\\\\
The database could also be geared for industrial use. If an employer needed to keep track of where every employee was in the company site for example they could set up a camera system, connected to a computer which took frames from the cameras and compared faces in each camera to the database of employees, if someone not registered as an employee entered the building, an alert of some sort could be triggered.
\\\textbf{Home Security}\\\\
The database could be set up for a household where every person in the house is registered in the database. A camera is mounted at the entrance to the home and whenever someone is detected in the camera a computer connected to the camera performs facial recognition and lets them in depending if their face is registered in the database or not.
\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{images/facerec.png}
\caption{Live facial recognition - Adam Geitgeys}\cite{ageitgey}
\end{figure}
\\\\
As explained above there are many options for expanding on this software and it could be taken in several directions.

\newpage

\section{Conclusions}
In conclusion we feel we achieved all the main objectives set out at the start of the project. Have a working login system using facial recognition was the main component of the project and this was achieved through a lot of research and testing, we also feel our communication skills within a project environment have improved immensely, which will benefit us greatly in the future.
Having been allowed to explore different technologies from the very start of the project we feel it has given each of us, a taste of different technologies we would have never come across, if there was a set technology to be used. \textbf{Some of the different learning's/findings are highlighted below:}
\\
\begin{itemize}
    \item Working as a team can be extremely difficult, but throughout the duration of this project we feel we all gained a lot of experience and skills necessary for collaboration.
    \item How to effectively use collaborative software such as Github, this was extremely useful for keeping everyone updated and working on the same code.
    \item  How to distribute the work load of our project evenly among our group to ensure fairness and that the work load is manageable.
    \item We each learned significant amount about our respective areas, in developing the frontend, backend, and the facial recognition scripts that were written.
    \item Python was relatively new to all of us when we undertook this project, and we all took the risk in choosing it as the language we would utilize to create our software, but we all learned a lot about the language and how simplistic but extremely effective it is.
    \item Flask was also completely new to all of us and we had never heard of it before the initial project planning phase. It came down to Flask or Django for our frontend development and then everything else would've been developed from it. We chose Flask as it was more lightweight and intuitive than Django. We were glad we chose Flask in the end because development went smoothly for everyone.
\end{itemize}

\newpage
\printbibliography
\end{document}

max_stars_repo_path: Project Document/Latex Files/main.tex

max_issues_repo_path: Project Document/Latex Files/main.tex

max_forks_repo_path: Project Document/Latex Files/main.tex


text:
\subsection{Standalone Test Case Generation}

TSTL test cases are saved as text files, where each line of the text
file contains a string representation of an action (with a unique
such string ``name'' for each action).  This format is somewhat human
readable, but is not machine-executable without the assistance of the
TSTL interface.  These test cases are also somewhat misleading for
readers, since guards, post-conditions, reference pool actions, and
allowed exceptions do not appear in this format.

Publishing test cases (or submitting them to Esri) is impractical,
however, if it requires use of the entire TSTL toolchain.  Moreover,
making tests only work within TSTL means it is not possible to
experiment with changing test cases in ways that are not in the TSTL
action set.  It is not  even possible to add print statements to help understand
behavior, without using TSTL's complex logging mechanisms.

In order to address these problems, we implemented a new TSTL utility
that takes a test case stored in TSTL's internal format and produces a
standalone Python file that does not require any TSTL support.  The
standalone test case generator has options to control whether the
generated test case includes actions on reference pools, property
checks, and handling for allowed exceptions (omitted only if the exception does not
actually take place when the test is replayed).  The reason for disabling
the last functionality is interesting:  most test cases that are
stored are minimized \cite{DD} test cases, from which all actions not
necessary to produce a failure or obtain desired code coverage have
been removed.  In most cases, this means that most ArcPy calls are
successful.  Adding code to handle potential exceptions makes
standalone test cases much longer and harder to read.

In the process of producing the standalone test case utility, we
introduced a more readable format for TSTL action names that is closer
to the code in standalone test cases.  This has, to our surprise, made
reading TSTL test cases in tool output, not just in standalone test
cases, much easier.  The new format has been integrated into new TSTL features.


text:
\chapter{Conclusions}

In this thesis,
we explored a very special class of supersymmetric gauge theories whose path integrals are directly reducible to finite-dimensional integrals,
i.e. 0-dimensional matrix models, by the means of the supersymmetric localization method.
In particular, we studied the vacuum partition function and the expectation values of BPS Wilson loop observables of $\mathcal{N}=2^*$ SYM on $S^4$.

Our main motivation was to rigorously test the gauge/string duality conjecture
in a slightly more generalized setting than the well-known case of $\mathcal{N}=4$  SYM and type IIB strings on $AdS_5 \times S^5$,
by introducing a mass scale.
The total access to the strong coupling phase of $\mathcal{N}=2^*$ SYM gives us a golden opportunity to explicitly test it
against its presumed dual theory of type IIB strings on the Pilch-Warner background.

Computations are highly non-trivial,
on the gauge theory side,
as well as on the string theory side.
From our work, we can conclude the following, supplemented with possible future work:
\begin{itemize}
 \item Paper I and \cite{Zarembo:2014ooa} showed that the decompactifaction limit of $\mathcal{N}=2^*$ SYM on $S^4$
 commutes with the strong coupling limit.
 This allows us to do holographic studies,
 since the dual of $\mathcal{N}=2^*$ SYM on $\mathbb{R}^4$ is known.
 For the sake of completeness, it would be interesting to extend the holographic study for the theory on $S^4$.

 \item
%  There are infinitely-many phase transitions previously seen for finite critical couplings at the decompactification limit \cite{Russo:2013qaa}.
 We used BPS Wilson loops in symmetric and antisymmetric representations of the gauge group to probe the strong-coupling phase of $\mathcal{N}=2^*$ SYM on $S^4$,
 especially in the decompactifaction limit, where infinite cusps appear.
 Paper II showed that these cusps induce phase transitions seen in the subleading order in strong coupling for these Wilson loops.
 In order to understand the nature of these phase transitions in the string theory side,
 Paper III computed the D3-brane configuration in the Pilch-Warner background dual to the symmetric Wilson loop.
 Only the leading result was derived, and it does not probe the full field theory result regime.
%  A different dual interpretation is needed to fully probe the field theory side solution though.
%  Therefore, we have not been able to answer the question of the nature of the holographic description of the phase transitions.
 From scaling arguments, we believe the D5-brane dual to the antisymmetric representation can be a promising case
 for a full matching, and hopefully even at 1-loop level, where phase transitions happen.
%  Unfortunately, due to technical difficulties, the solution has been elusive,
%
%  An attempt of a computer algebra program has been used to systematically solve the supersymmetric equations,
%  and a new unpublished D7 brane solution has been found.

 \item The gauge/string duality for $\mathcal{N}=2^*$ case works with the fundamental Wilson line at least up to 1-loop quantum corrections,
 shown numerically by Paper V. Given the simplicity of the field theory prediction,
 an analytical result in the string theory side might be possible and desirable.
 Moreover, the matching requires the existence of the controversial Fradkin-Tseytlin term in the string action.
 It would be clarifying to prove its existence independently, for example by requiring the beta function of the Green-Schwarz action to be zero.

  \item It is known that Wilson loops in the symmetric representation and the multiply-wrapped representation differ
 by exponentially suppressed terms for strong coupling \cite{Yamaguchi:2007ps}.
 Paper IV provided a non-planar correction to this statement for the $\mathcal{N}=4$ case,
 and helped to clarify a mismatch in an open problem concerning 1-loop corrections
 in the holographic dual computation \cite{Faraggi:2014tna, Buchbinder:2014nia}.
 Solving this problem is definitely a further non-trivial quantum rigorous test,
 and we would gain a better understanding of divergences in stringy corrections.
 There is a similar open problem concerning 1-loop matching for circular fundamental Wilson loop
 in $\mathcal{N}=4$ SYM \cite{Kruczenski:2008zk, Kristjansen:2012nz, Bergamin:2015vxa, Forini:2015bgo, Faraggi:2016ekd, Forini:2017whz}.
%  \item

\end{itemize}

Despite technical challenges,
further studies on this $\mathcal{N}=2^*$SYM case are necessary for better rigorous understanding of the generic gauge/string duality.

max_stars_repo_name: yixinyi/PhDThesis

max_issues_repo_name: yixinyi/PhDThesis

max_forks_repo_name: yixinyi/PhDThesis


text:
% Introduction to the three volume set by Ajahn Amaro
% title: Introduction -- Therav\=ada Buddhism And The Thai Forest Tradition

\chapter{Introduction}

\section{The Thai Forest Tradition}

\dropcaps{T}{he Venerable Ajahn Chah} often reminded his disciples that the Buddha was born in a forest, was enlightened in a forest and passed away in a forest. Ajahn Chah lived nearly all his adult life following a style of Buddhist practice known these days as the Thai Forest Tradition, a tradition which adheres to the spirit of the way espoused by the Buddha himself, and practises according to the same standards the Buddha encouraged during his lifetime.

This lineage is a branch of the Southern School of Buddhism, originally known as the \pali{Sthaviras} (in Sanskrit) or \pali{Theras} (in P\=a\d{l}i), later referred to as the Therav\=ada school. `Therav\=ada' means `The Way of the Elders', and that has been their abiding theme ever since. The ethos of the tradition can be characterized as something like: `That's the way the Buddha established it so that is the way we'll do it.' It has thus always had a particularly conservative quality to it.

From its origins, and particularly as the main religion of Sri Lanka, Therav\=ada Buddhism has been maintained and continually restored over the years, eventually spreading through South-East Asia and latterly from those countries to the West. As the religion became established in these geographical regions, respect and reverence for the original Teachings have remained, with a respect for the style of life as embodied by the Buddha and the original Sa\.ngha, the forest-dwelling monastics of the earliest times. This is the model that was employed then and is carried on today.

There have been ups and downs throughout its history; it would develop, get rich, become corrupt and collapse under its own weight. Then a splinter group would appear and go off into the forest in order to return to those original standards of keeping the monastic rules, practising meditation and studying the original Teachings. This is a pattern that has been maintained over the many centuries.

In more recent times, in mid 19\textsuperscript{th} century Thailand, the orthodox position held by scholars was that it was not possible to realize Nibb\=ana in this age, nor to attain \pali{jh\=ana} (meditative absorption). This was something that the revivers of the Forest Tradition refused to accept. It was also one of the reasons for which they were deemed, by the ecclesiastical hierarchy of the time, to be mavericks and trouble-makers, and it lies behind the obvious distance many of them (Ajahn Chah included) kept from the majority of `study' monks of their own Therav\=ada lineage -- as well as their refrain that you don't get wisdom from the books.

One might find such sentiments presumptuous or arrogant, unless it is appreciated that the interpretations of scholars were leading Buddhism into a black hole. Thai Forest monastics had the determination to focus on the lifestyle and on personal experience rather than on book study (especially the commentaries). In short, it was just the kind of situation that made the spiritual landscape ripe for renewal, and it was out of this fertile ground that the revival of the Forest Tradition emerged.

\section{AJAHN MUN}

The Thai Forest Tradition would not exist as it does today were it not for the influence of one particular great master, Ajahn Mun. Venerable Ajahn Mun Bhuridatta was born in Ubon Province in the 1870s. After his ordination as a bhikkhu he sought out Ven. Ajahn Sao, one of the rare local forest monks, and asked him to teach him meditation; he had also recognized that a rigorous adherence to the monastic discipline would be crucial to his spiritual progress.

Though both of these elements (i.e. meditation and strict discipline) might seem unremarkable from the vantage point of the present day, at that time monastic discipline had grown extremely lax throughout the region and meditation was looked upon with great suspicion. In time Ajahn Mun successfully explained and demonstrated the usefulness of meditation and became an exemplar of a much higher standard of conduct for the monastic community.

He became the most highly regarded of spiritual teachers in his country and almost all of the most accomplished and revered meditation masters of the 20\textsuperscript{th} century in Thailand were either his direct disciples or were deeply influenced by him. Ajahn Chah was among them.

\section{AJAHN CHAH}

Ajahn Chah was born in a village in Ubon Province, North-East Thailand. At the age of nine he went to live in the local monastery. He was ordained as a novice, and at the age of twenty took higher ordination. He studied basic Dhamma, the Discipline and other scriptures, and later became a wandering \pali{\glsdisp{tudong}{tudong}} bhikkhu. He travelled for a number of years in the style of an ascetic bhikkhu, sleeping in forests, caves and cremation grounds, and spent a short but enlightening period with Ajahn Mun himself.

In 1954 he was invited to settle in a forest near Bahn Gor, the village of his birth. The forest was uninhabited and known as a place of cobras, tigers and ghosts. More and more bhikkhus, nuns and lay-people came to hear his teachings and stay on to practise with him, and as time went by, a large monastery formed and was given the name Wat Pah Pong. There are now disciples of Ajahn Chah living, practising meditation and teaching in more than 300 mountain and forest branch monasteries throughout Thailand and the West.

Although Ajahn Chah passed away in 1992, the training that he established is still carried on at Wat Pah Pong and its branches. There is usually group meditation twice a day and sometimes a talk by the senior teacher, but the heart of the meditation is the way of life. The monastics do manual work, dye and sew their own robes, make most of their own requisites and keep the monastery buildings and grounds in immaculate shape. They live extremely simply, following the ascetic precepts of eating once a day from the alms bowl and limiting their possessions and robes. Scattered throughout the forest are individual huts where bhikkhus and nuns live and meditate in solitude, and where they practise walking meditation on cleared paths under the trees.

In some of the monasteries in the West, and a few in Thailand, the physical location of the centre dictates that there might be some small variations to this style -- for instance, the monastery in Switzerland is situated in a old wooden hotel building at the edge of a mountain village -- however, regardless of such differences, the same spirit of simplicity, quietude and scrupulosity sets the abiding tone. Discipline is maintained strictly, enabling one to lead a simple and pure life in a harmoniously regulated community where virtue, meditation and understanding may be skilfully and continuously cultivated.

Along with monastic life as it is lived within the bounds of fixed locations, the practice of \pali{tudong} -- wandering on foot through the countryside, on pilgrimage or in search of quiet places for solitary retreat -- is still considered a central part of spiritual training. Even though the forests have been disappearing rapidly throughout Thailand, and the tigers and other wild creatures so often encountered during such \pali{tudong} journeys in the past have been depleted almost to the point of extinction, it has still been possible for this way of life and practice to continue. Indeed, not only has this practice of wandering on foot been maintained by Ajahn Chah, his disciples and many other forest monastics in Thailand; it has also been sustained by his monks and nuns in many countries of the West. In these situations the strict standards of conduct are still maintained: living only on almsfood freely offered by local people, eating only between dawn and noon, not carrying or using money, sleeping wherever shelter can be found. Wisdom is a way of living and being, and Ajahn Chah endeavoured to preserve the simple monastic life-style in all its dimensions, in order that people may study and practise Dhamma in the present day.

\section{AJAHN CHAH'S TEACHING OF WESTERNERS}

\vspace*{0.4\baselineskip}
From the beginning Ajahn Chah chose not to give any special treatment to the \pali{farang} (Western) monks who came to study with him, but to let them adapt to the climate, food and culture as best they could, and use the experience of discomfort for the development of wisdom and patient endurance. In 1975 Wat Pah Nanachat (the International Forest Monastery) was established near Wat Pah Pong as a place for Westerners to practise. The people of Bung Wai village had been long-standing disciples of Ajahn Chah and asked him if the foreign monks could settle there and start a new monastery. Then in 1976 Ajahn Sumedho was invited by a group in London to come and establish a Therav\=adan monastery in England. Ajahn Chah came over the following year and left Ajahn Sumedho and a small group of monastics at the Hampstead Buddhist Vih\=ara, a town house on a busy street in North London. Within a few years they had moved to the country and several different branch monasteries had been established. Other monasteries were set up in France, Australia, New Zealand, Switzerland, Italy, Canada and the U.S.A. Ajahn Chah himself travelled twice to Europe and North America, in 1977 and 1979.

He once said that Buddhism in Thailand was like an old tree that had formerly been vigorous and abundant; now it was so aged that it could only produce a few fruits and they were small and bitter. Buddhism in the West he likened in contrast to a young sapling, full of youthful energy and the potential for growth, but needing proper care and support for its development.

% \section{THE ESSENTIALS: VIEW, TEACHING, AND PRACTICE}

\section{The Four Noble Truths}

\vspace*{0.4\baselineskip}
All the Teachings can be said to derive from an essential matrix of insight: \textit{The Setting in Motion of the Wheel of Truth} (\pali{Dhammacakkappavattana Sutta}, SN 56.11). In this brief discourse the Buddha speaks about the nature of the Middle Way and the Four Noble Truths. It takes only twenty minutes to recite, and the structures and forms he used to express this teaching were familiar to people in his time.

The Four Noble Truths are formulated like a medical diagnosis in the \textit{ayurvedic}\footnote{Ayurvedic medicine is a system of traditional medicine native to India.} tradition:

\begin{enumerate}
\item the symptom
\item the cause
\item the prognosis
\item the cure
\end{enumerate}

The First Truth is the `symptom'. There is \pali{dukkha} -- we experience incompleteness, dissatisfaction or suffering. There might be periods of a coarse or even a transcendent happiness, but there are also feelings of discontent which can vary from extreme anguish to the faintest sense that some blissful feeling we are experiencing will not last. All of this comes under the heading of `\pali{dukkha}'. This First Truth is often wrongly understood as: `Reality in every dimension is \pali{dukkha}'. That's not what is meant here. If it were, there would be no hope of liberation for anyone, and to realize the truth of the way things are would not result in abiding peace and happiness. These are \pali{noble} truths in the sense that they are relative truths; what makes them noble is that, when they are understood, they lead us to a realization of the Ultimate.

The Second Noble Truth is the `cause'. Self-centred craving, \pali{ta\d{n}h\=a} in P\=a\d{l}i  means `thirst'. This craving, this grasping, is the cause of \pali{dukkha}. There are many subtle dimensions to it: craving for sense-pleasure; craving to become something or craving to be identified as something; it can also be craving not to be, the desire to disappear, to be annihilated, the desire to get rid of.

The Third Truth is the `prognosis'. Cessation: \pali{dukkha-nirodha}. The experience of \pali{dukkha}, of incompleteness, can fade away, can be transcended. \mbox{It can end.} Dukkha is not an absolute reality, it's just a temporary experience from which the heart can be liberated.

The Fourth Noble Truth is the `cure'. It is the Path; it is how we get from the Second Truth to the Third, from the causation of \pali{dukkha} to the ending of it. The cure is the Eightfold Path: virtue, concentration and wisdom.

\section{The Law of Kamma}

The Buddha's insight into the nature of Reality led him to see that this is a moral universe: good actions reap pleasant results, harmful acts reap painful results. The results may come soon after the act or at some remote time in the future, but an effect which matches the cause will necessarily follow. The key element of \pali{kamma} is intention. As the Buddha expresses it in the opening verses of the Dhammapada:

\begin{verse}
`Mind is the forerunner of all things: think and act with a corrupt heart and sorrow will follow one as surely as the cart follows the ox that pulls it.'
\end{verse}

\begin{verse}
`Mind is the forerunner of all things: think and act with a pure heart and happiness will follow one as surely as one's never-departing shadow.'

\textit{(Dhp 1-2)}
\end{verse}

This understanding is something that one comes to recognize through experience, and reference to it will be found throughout the Dhamma talks in these pages. When Ajahn Chah encountered westerners who said that they didn't believe in \pali{kamma} as he described it, rather than dismissing it as wrong view, he was interested that they could look at things in such a different way -- he would ask them to describe how they saw things working, and then take the conversation from there. The story is widely circulated that when a young Western monk told Ajahn Chah he couldn't go along with the teachings on rebirth, Ajahn Chah answered him by saying that that didn't have to be a problem, but to come back in five years to talk about it again.

\section{Everything is Uncertain}

Insight can truly be said to have dawned when three qualities have been seen and known through direct experience. These are \pali{anicca, dukkha} and \pali{anatt\=a} -- impermanence, unsatisfactoriness and `not-self'. We recognize that everything is changing, nothing can be permanently satisfying or dependable, and nothing can truly be said to be ours, or absolutely who and what we are. Ajahn Chah stressed that the contemplation of \pali{anicca} is the gateway to wisdom. As he puts it in the talk `Still, Flowing Water'; `Whoever sees the uncertainty of things sees the unchanging reality of them \ldots{} If you know \pali{anicca}, uncertainty, you will let go of things and not grasp onto them.'

It is a characteristic of Ajahn Chah's teaching that he used the less familiar rendition of `uncertainty' (\pali{my naer} in Thai) for \pali{anicca}. While `impermanence' can have a more abstract or technical tone to it, `uncertainty' better describes the feeling in the heart when one is faced with that quality of change.

\section{Choice of Expression: `yes' or `no'}

A characteristic of the Therav\=ada teachings is that the Truth and the way leading to it are often indicated by talking about what they are \textit{not} rather than what they \textit{are}.

Readers have often mistaken this for a nihilistic view of life, and if one comes from a culture committed to expressions of life-affirmation, it's easy to see how the mistake could be made.

The Buddha realized that the mere declaration of the Truth did not necessarily arouse faith, and might not be effective in communicating it to others either, so he adopted a much more analy\-tical method (\pali{vibhajjav\=ada} in P\=a\d{l}i) and in doing so composed the formula of the Four Noble Truths. This analytical method through negation is most clearly seen in the Buddha's second discourse (\pali{Anattalakkhana Sutta}, SN 22.59), where it is shown how a `self' cannot be found in relation to any of the factors of body or mind, therefore: `The wise noble disciple becomes dispassionate towards the body, feelings, perceptions, mental formations and consciousness.' Thus the heart is liberated.

Once we let go of what we're not, the nature of what is Real becomes apparent. And as that Reality is beyond description, it is most appropriate, and least misleading, to leave it undescribed -- this is the essence of the `way of negation'.

Ajahn Chah avoided talking about levels of attainment and levels of meditative absorption in order to counter spiritual materialism (the gaining mind, competitiveness and jealousy) and to keep people focused on the Path. Having said that, he was also ready to speak about Ultimate Reality if required. The talks `Toward the Unconditioned,' `Transcendence' and `No Abiding' are examples of this. If, however, a person insisted on asking about transcendent qualities and it was clear that their understanding was not yet developed (as in the dialogue `What is Contemplation'), Ajahn Chah might well respond, as he does there, `It isn't anything and we don't call it anything -- that's all there is to it! Be finished with all of it', (literally: `If there is anything there, then just throw it to the dogs!')

\section{Right View and Virtue}

Ajahn Chah frequently said that his experience had shown him that all spiritual progress depended upon Right View and on purity of conduct. Of Right View the Buddha once said: `Just as the glowing of the dawn sky foretells the rising of the sun, so too is Right View the forerunner of all wholesome states' (AN 10.121). To establish Right View means firstly that one has a trustworthy map of the terrain of the mind and the world -- an appreciation of the law of \pali{kamma}, particularly -- and secondly it means that one sees experience in the light of the Four Noble Truths and is thus turning that flow of perceptions, thoughts and moods into fuel for insight. The four points become the quarters of the compass by which we orient our understanding and thus guide our actions and intentions.

Ajahn Chah saw \pali{s\={\i}la} (virtue) as the great protector of the heart and encouraged a sincere commitment to the Precepts by all those who were serious about their search for happiness and a skilfully lived life -- whether these were the Five Precepts of the householder or the Eight, Ten or 227 of the various levels of the monastic community. Virtuous action and speech, \pali{s\={\i}la}, brings the heart directly into accord with Dhamma and thus becomes the foundation for concentration, insight and, finally, liberation.

In many ways \pali{s\={\i}la} is the external corollary to the internal quality of Right View and there is a reciprocal relationship between them: if we understand causality and see the relationship between craving and \pali{dukkha}, then certainly our actions are more likely to be harmonious and restrained; similarly, if our actions and speech are respectful, honest and non-violent, we create the causes of peace within us and it will be much easier for us to see the laws governing the mind and its workings, and Right View will develop more easily.

One particular outcome of this relationship of which Ajahn Chah spoke regularly, as in the talk `Convention and Liberation', is the intrinsic emptiness of all conventions (e.g. money, monasticism, social customs), but the simultaneous need to respect them fully. This might sound paradoxical, but he saw the Middle Way as synonymous with the resolution of this kind of conundrum. As he once said, `The Dhamma is all about letting go; the monastic discipline is all about holding on; when you realize how those two function together, you will be fine.' If we cling to conventions we become burdened and limited by them, but if we try to defy them or negate them we find ourselves lost, conflicted and bewildered. He saw that with the right attitude, both aspects could be respected and in a way that was natural and freeing rather than forced or compromised.

It was probably due to his own profound insights in this area that he was able to be both extraordinarily orthodox and austere as a Buddhist monk, yet utterly relaxed and unfettered by any of the rules he observed. To many who met him he seemed the happiest man in the world -- a fact perhaps ironic about someone who had never had sex in his life, had no money, never listened to music, was regularly available to people eighteen to twenty hours a day, slept on a thin grass mat, had a diabetic condition and various forms of malaria, and who was delighted by the fact that Wat Pah Pong had the reputation of having `the worst food in the world.'

\section{Methods of Training}

The collection of Ajahn Chah's talks presented here was transcribed from tapes made more often than not in informal dialogues, where the flow of teaching and to whom it was directed were extremely unpredictable. Some of the talks were given in such spontaneous gatherings, others on more formal occasions, such as after the recitation of the bhikkhus' rules, or to the whole assembly of laity and monastics on the weekly lunar observance night. However, whether they were of the former or the latter kind, Ajahn Chah never planned anything. Not one single part of the Dhamma teachings printed here was plotted out before he started speaking. This was an important principle, he felt, as the job of the teacher was to get out of the way and let the Dhamma arise according to the needs of the moment -- if it's not alive to the present, it's not Dhamma, he would say. This style of teaching was not unique to Ajahn Chah, but is that espoused throughout the Thai Forest Tradition.

Ajahn Chah trained his students in many ways, the majority of the learning process occurring through situational teaching. He knew that, for the heart to learn any aspect of the Teaching truly and be transformed by it, the lesson had to be absorbed by experience, not intellectually alone. Thus he employed aspects of the monastic routine, communal living and the \pali{tudong} life as ways to teach: community work projects, learning to recite the rules, helping with the daily chores, random changes in the schedule -- these were all used as a forum in which to investigate the arising of \pali{dukkha} and the way leading to its cessation.

He encouraged the attitude of being ready to learn from everything, as he describes in the talk `Dhamma Nature'. He would emphasize that we are our own teachers: if we are wise, every personal problem, event and aspect of nature will instruct us; if we are foolish, not even having the Buddha before us explaining everything would make any real impression.

This insight became clear in the way he related to people's questions -- rather than answering the question in its own terms, he responded more to where the questioner was coming from. Often when asked something he would appear to receive the question, gently take it to pieces and then hand the bits back to those who asked; they would then see for themselves how it was put together. To their surprise he had guided them in such a way that they had answered their own question. When asked how it was that he could do this so often, he replied `If the person did not already know the answer they could not have posed the question in the first place.'

Other key attitudes that he encouraged and which can be found in the teachings here are, firstly, the need to cultivate a profound sense of urgency in meditation practice and, secondly, to use the training environment to develop patient endurance. This latter quality is seen in the forest life as almost synonymous with spiritual training, but has not otherwise received a great deal of attention in spiritual circles of the `quick fix' culture of the West.

When the Buddha was giving his very first instructions on monastic discipline, to a spontaneous gathering of 1,250 of his enlightened disciples at the Bamboo Grove, his first words were: `Patient endurance is the supreme practice for freeing the heart from unwholesome states.' (Dhp 183-85). So when someone would come to Ajahn Chah with a tale of woe, of how her husband was drinking and the rice crop looked bad this year, his first response would often be: `Can you endure it?' This was said not as some kind of macho challenge, but more as a means of pointing to the fact that the way beyond suffering is neither to run away from it, wallow in it or even grit one's teeth and get through on will alone -- no, the encouragement of patient endurance is to hold steady in the midst of difficulty, truly apprehend and digest the experience of \pali{dukkha}, understand its causes and let them go.

\section{Teaching the Laity and Teaching Monastics}

There were many occasions when Ajahn Chah's teachings were as applicable to laypeople as to monastics, but there were also many instances when they were not. The three volumes of this present collection -- Daily Life Practice, Formal Practice and Renunciant Practice -- have been arranged to reflect these differences of focus and applicability. Even though the teachings have already been divided up in this way, this is still an important factor to bear in mind when the reader is going through the talks contained here -- not to be aware of such differences could be confusing. For example, the talk `Making the Heart Good' is aimed at a lay audience -- a group of people who have come to visit Wat Pah Pong to \pali{tam boon}, to make offerings to the monastery both to support the community there and to make some good \pali{kamma} for themselves. On the other hand, a talk like `The Flood of Sensuality' would only be given to the monastics, in that instance just to the monks and male novices.

This distinction was not made because of certain teachings being `secret' or higher in some respect; rather it was through the need to speak in ways that would be appropriate and useful to particular audiences. Unlike the monastic, lay practitioners have a different range of concerns and influences in their daily life: trying to find time for formal meditation practice, maintaining an income, living with a spouse. And most particularly, the lay community has not undertaken the vows of the renunciant life -- a lay student may keep the Five Precepts, whereas the monastics would be keeping the Eight, Ten or 227 Precepts of the various levels of ordination.

When teaching monastics alone, Ajahn Chah's focus is much more specifically on using the renunciant way of life as the key method of training; the instruction therefore concerns itself with the hurdles, pitfalls and glories that that way of life might bring. Since the average age of the monks' community in a monastery in Thailand is usually around 25 to 30, and with the strict precepts around celibacy, there was also a natural need for Ajahn Chah to skilfully guide the restless and sexual energy that his monks would often experience. When it was well-directed, the individuals would be able to contain and employ that same energy, and transform it to help develop concentration and insight.

The tone of some of the talks to monastics will in certain instances also be seen to be considerably more directly confrontational than those given to the lay community, for example, `Dhamma Fighting'. This manner of expression represents something of the `take no prisoners' style which is characteristic of many of the teachers of the Thai Forest Tradition. It is a way of speaking that is intended to rouse the `warrior heart': an attitude toward spiritual practice which enables one to be ready to endure all hardships and to be wise, patient and faithful, regardless of how difficult things get.

At times this way of teaching may seem overly aggressive or combative in its tone; the reader should therefore bear in mind that the spirit behind such language is the endeavour to encourage the practitioner, gladden the heart and provide supportive strength when dealing with the multifarious challenges to freedom from greed, hatred and delusion. As Ajahn Chah once said: `All those who seriously engage in spiritual practice should expect to experience a great deal of friction and difficulty.' The heart is being trained to go against the current of self-centred habits, so it's quite natural for it to be buffeted around somewhat.

As a final note on this aspect of Ajahn Chah's teachings, particularly those one might term `higher' or `transcendent', it is significant that he didn't exclude the laity from any instruction of this nature. If he felt a group of people was ready for the highest levels of teaching, he would impart them freely and openly, whether it was to laypeople or to monastics, as in, for example, `Toward the Unconditioned' or `Still, Flowing Water' where he states: `People these days study away, looking for good and evil. But that which is beyond good and evil they know nothing of.' Like the Buddha, he never employed the `teacher's closed fist', and made his choices of what to teach solely on the basis of what would be useful to his listeners, not on their number of precepts and their religious affiliation or lack of one.

\section{Countering Superstition}

Ajahn Chah was well known for his keenness to dispel superstition from Buddhist practice in Thailand. He criticized the use of `magic' charms, amulets and fortune-telling. He rarely spoke about past or future lives, other realms, visions or psychic experiences. Anyone who came to him asking for the next winning lottery number (a very common reason why some people go to visit famous Ajahns) would generally get very short shrift. He saw that the Dhamma itself was the most priceless jewel, which could provide genuine protection and security in life, and yet it was continually overlooked for the sake of the promise of minor improvements to \pali{sa\d{m}s\=ara}.

He emphasized the usefulness and practicality of Buddhist practice, countering the common belief that Dhamma was too high or abstruse for the common person. His criticisms were not just aimed to break down childish dependencies on good luck and magical charms; rather he wanted people to invest in something that would truly serve them in their lives.

In the light of this life-long effort, there was also an ironic twist of circumstance that accompanied his funeral in 1993. He passed away on 16 January 1992 and they held the funeral exactly a year later; the memorial stupa had 16 pillars, was 32 metres high, and had foundations 16 metres deep -- consequently a huge number of people in Ubon Province bought lottery tickets with ones and sixes together. The next day the headlines in the local paper proclaimed: LUANG POR CHAH'S LAST GIFT TO HIS DISCIPLES -- the 16s had cleaned up and a couple of local bookmakers had even been bankrupted.

\section{Humour}

That last story brings us to a final quality of Ajahn Chah's teaching style. He was an amazingly quick-witted man and a natural performer. Although he could be very cool and forbidding, or sensitive and gentle in his way of expression, he also used a high degree of humour in his teaching. He had a way of employing wit to work his way into the hearts of his listeners, not just to amuse but to help convey truths that would otherwise not be received so easily.

His sense of humour and skilful eye for the tragi-comic absurdities of life enabled people to see situations in such a way that they could laugh at themselves and be guided to a wiser outlook. This might be in matters of conduct, such as a famous display he once gave of the many \textit{wrong} ways to carry a monk's bag: slung over the back, looped round the neck, grabbed in the fist, scraped along the ground \ldots{} Or it might be in terms of some painful personal struggle. One time a young bhikkhu came to him very downcast. He had seen the sorrows of the world and the horror of beings' entrapment in birth and death, and had realized that `I'll never be able to laugh again -- it's all so sad and painful.' Within forty-five minutes, via a graphic tale about a youthful squirrel repeatedly attempting and falling short in its efforts to learn tree-climbing, the monk was rolling on the floor clutching his sides, tears pouring down his face as he was convulsed with the laughter that he had thought would never return.
\vspace*{0.4\baselineskip}

\section{Last Years}

\vspace*{0.4\baselineskip}
During the rains retreat of 1981 Ajahn Chah became seriously ill, with what was apparently some form of stroke. His health had been shaky for the previous few years, with dizzy spells and diabetic problems, and now it went down with a crash. Over the next few months he received various kinds of treatment, including a couple of operations, but nothing helped. The slide continued until by the middle of the following year he was paralysed but for some slight movement in one hand, and he had lost the power of speech. He could still blink his eyes.

He remained in this state for the next ten years, his few areas of control diminishing slowly until by the end all voluntary movement was lost to him. During this time it was often said that he was still teaching his students: hadn't he reiterated endlessly that the body is of the nature to sicken and decay, and that it is not under personal control? As he put it somewhat prophetically in `Why Are We Here?', a talk given just before his health collapsed: `People come to visit, but I can't really receive them like I used to because my voice has just about had it; my breath is just about gone. You can count it a blessing that there's still this body sitting here for you all to see now. Soon you won't see it. The breath will be finished; the voice will be gone. They will fare in accordance with supporting factors, like all compounded things.'

So here was a prime object lesson for all his students -- neither a great master like Ajahn Chah nor even the Buddha himself could escape the inexorable laws of nature. The task, as always, was to find peace and freedom by not identifying with the changing forms.

During this time, despite his severe limitations, he occasionally managed to teach in ways other than just being an example of the uncertain processes of life and by giving opportunity for his monks and novices to offer their support through nursing care. The bhikkhus used to work in shifts, three or four at a time, to look after Ajahn Chah's physical needs, as he required attention twenty-four hours a day. On one particular shift two monks got into an argument, quite forgetting (as often happens around paralyzed or comatose people) that the other occupant of the room might be fully cognizant of what was going on. Had Ajahn Chah been fully active, it would have been unthinkable that they would have got into such a spat in front of him.

As the words got more heated an agitated movement began in the bed across the room. Suddenly Ajahn Chah coughed violently and, according to reports, sent a sizeable gob of phlegm shooting across the intervening space, passing between the two protagonists and smacking into the wall right beside them. The teaching was duly received and the argument came to an abrupt and embarrassed conclusion.

During the course of his illness the life of the monasteries continued much as before. The Master's being both there yet not there served in a strange way to help the community to adapt to communal decision-making and to the concept of life without their beloved teacher at the centre of everything. After such a great elder passes away it is not uncommon for things to disintegrate rapidly and for all his students to go their own way, the teacher's legacy vanishing within a generation or two. It is perhaps a testimony to how well Ajahn Chah trained people to be self-reliant that whereas at the time of his falling sick there were about 75 branch monasteries, this had increased to well over 100 by the time he passed away, and has now grown to more than 300, in Thailand and around the world.

After he passed away, his monastic community set about arranging his funeral. In keeping with the spirit of his life and teachings, the funeral was not to be just a ceremony but also a time for hearing and practising Dhamma. It was held over ten days with several periods of group meditation and instructional talks each day, these being given by many of the most accomplished Dhamma teachers in the country. There were about 6,000 monks, 1,000 nuns and just over 10,000 laypeople camped in the forest for the 10 days. Beside them, an estimated 1,000,000 people came passed through the monastery during the practice period; 400,000, including the king and queen and the prime minister of Thailand, who came on the day of the cremation itself.

Again, in the spirit of the standards Ajahn Chah espoused throughout his teaching career, throughout this entire session, not one penny was charged for anything: food was supplied for everyone through forty-two free food kitchens, run and stocked by many of the branch monasteries; over \pounds 120,000 worth of free Dhamma books were passed out; bottled water was provided by the gallon through a local firm, and the local bus company and other nearby lorry owners ferried out the thousands of monks each morning to go on almsround through villages and towns in the area. It was a grand festival of generosity and a fitting way to bid farewell to the great man.

It is in the same spirit of generosity that this present edition of Ajahn Chah's Dhamma talks has been compiled. This compilation, `The Collected Teachings of Ajahn Chah', comprises most of Ajahn Chah's talks which have been previously published for free distribution in English.

May these teachings provide nourishing contemplation for seekers of the Way and help to establish a heart which is awake, pure and peaceful.
\vspace*{2\baselineskip}

{\raggedleft\par Ajahn Amaro\\
February 2011 \par}