How does Hilbert's axiomatization relate to set theory? I'm studying Hilbert's axiomatization of Euclidean geometry, and I'm trying to combine my current understanding into my knowledge on mathematical logic (not very much).
At the beginning of this axiomatic system, it states the undefined terms are 'point', 'line', 'plane', 'lie', 'between', and 'congruence'. Therefore it seems that all later definitions should be based on these primitive notions. However, in the definition of 'segment', it states that a segment $AB$ is a set of two points on the same line. (or another variation where the segment contains also all points between two endpoints.)
My question is: how does 'set' come into play here? There is no notion of 'set' defined in this system, how is it valid to use the notion of set (or notions about sets like equivalent class) here? More generally, how does set relate to a specific mathematical theory?
Being a beginner on foundation related topics, I would appreciate if you can explain different concepts in a slow pace. In my understanding, Hilbert's system is a purely syntactic system with some undefined terms. It might be helpful if you can show me how the definitions (like segment) can be produced by FOL language.
 A: The resolution is that Hilbert's axioms are not first-order axioms. They refer to sets (or "systems") as well as to individual objects.
This is most visible in the axiom of continuity, which directly refers to sets. The purpose of this axiom is to prevent issues which affect Euclid's axioms. One such issue is that the rational plane $\mathbb{Q} \times \mathbb{Q}$ satisfies many of the axioms of geometry (including the natural FOL versions of Euclid's axioms). Some axiom is needed to prove, for example, that the line $y = x$ intersects the circle of radius $1$ centered at the origin. 
Hilbert's axioms are most naturally viewed in second-order logic. In that framework, "set" is a logical concept (like "equality" and "or") rather than a term of the theory being studied.  
At the time that Hilbert was working on geometry, the distinction between first-order and second-order logic was not yet understood. So it is not at all surprising that Hilbert would not make any distinction, and would not view "set" as an undefined term of geometry. From the 19th century point of view there was simply "logic", which had not yet been formalized. It took until the 1940s or 1950s for our contemporary understanding of logic to be completely developed. 
There are first-order axiom systems for geometry, such as Tarski's axioms. These are different from Hilbert's axioms in various ways, but in particular they do not try to include a "completeness" or "continuity" axiom analogous to Hilbert's axiom. 
A: Without further context, it seems that saying "a segment $AB$ is a set of points" is not meant to be a formal statement, only to give you intuition. In the axiomatic system you indeed cannot talk about sets directly. However, there are some sets you can describe indirectly: the phrase "$C$ lies on the line segment $AB$" is another way of saying "$C$ is between $A$ and $B$". That is, the definition of a segment, which is just "two distinct points", is based on your primitive notion: namely the primitive notion of a point. 
Similarly, you will likely at some point define a circle, as "the set of points which are as far away from $A$ as $B$ is" -- but really, that will just be a way of talking about the actual definition. The phrase "$C$ lies on the circle defined by $A$, $B$" will be an abbreviation for "$AC$ is congruent to $AB$". Or something like that.
A: One approach I know and which I find really advantageous is to assume axiomatic set theory as preceding theory which means that all Hilbert's undefined terms are sets. Explicitly:


*

*3d space is a set $S$. Elements of this set are called points.

*Family of lines is a set $\mathcal{L}\subset 2^S$. Elements of this set are called lines.

*Family of planes is a set $\mathcal{P}\subset 2^S$. Elements of this set are called planes.

*Betweenness relation is a set $B\subset S\times S\times S$

*Congruence relation $\equiv$ is as well a set (it requires some definitions to state of what set this relation is a subset)


So we can think of an ordered five $(S,\mathcal{L},\mathcal{P},B,\equiv)$ satisfying Hilbert axioms. To make it even more formal we may think that basic connections between these set (for example $\mathcal{L}\subset 2^S$) are axioms as well.
This way we bring everything to first order set theory and every theorem which will be then derived from Hilbert axioms will have following structure from logical point of view:
$$\mbox{(Set theory axioms)}\implies \forall{S}\forall{\mathcal{L}}\forall{\mathcal{P}}\forall{B}\forall{\equiv}(\mbox{(Hilbert axioms)}\implies \mbox{Theorem})$$
It is very much similar like when for example we define a group. We say that the group is a pair $(G,\cdot)$ where $G$ is a set and $\cdot$ is a function $\cdot:G\times G\to G$ and some axioms are satisfied. Then we can prove some theorems which are true is every group.
A: One of the primitive notions in Hilbert's approach is the relation of *betweenness" which is a relation among three variables $A,B,C$ written as $A*B*C$. This reflects our intuitive notion of point $B$ belonging to interval $[A,C]$. Thus Hilbert is not relying on naive Euclidean notions when he talks of segments. A book that details Hilbert's approach and is more accessible than Hilbert's is Greenberg's Euclidean and non-Euclidean geometries.
