In mathematical logic, Diaconescu's theorem, or the Goodman–Myhill theorem, states that the full axiom of choice is sufficient to derive the law of the excluded middle or restricted forms of it.
The theorem was discovered in 1975 by Radu Diaconescu and later by Goodman and Myhill. Already in 1967, Errett Bishop posed the theorem as an exercise (Problem 2 on page 58 in "Foundations of constructive analysis").
In set theory.
The theorem is a foregone conclusion over classical logic, where law of the excluded middle is assumed. The proof below is therefore given using the means of a constructive set theory. It is evident from the proof how the theorem relies on the axiom of pairing as well as an axiom of separation, of which there are notable variations. A crucial role in the set theoretic proof is also played by the axiom of extensionality. The subtleties the latter two axioms introduce are discussed further below.
Fixing terminology for the proof: Call a set finite if there exists a bijection with a natural number, i.e. a finite von Neumann ordinal. In particular, write formula_1, formula_2 and formula_3. For example, a set is finite with cardinality one (an inhabited singleton) if and only if there provenly exists a bijective function out of the set formula_4. The proof below is straight forward in that it does not require pathological distinctions concerning the empty set. For a set formula_5 to have choice shall mean that if all its members are inhabited, formula_5 is the domain of a choice function. Lastly, for inhabited formula_5, denote by formula_8 the proposition that formula_9 surjects onto formula_5.
The strategy of the proof is to couple a given proposition formula_11 to a potential choice domain formula_5. And in the end, only a rather restrained form of full choice must be made use of. For concreteness and simplicity, the section supposes a constructive set theory with "full" Separation, i.e. we allow for comprehension involving "any" proposition formula_11. In that context, the following lemma then more sharply isolates the core insight:
The law of excluded middle is equivalent to choice in all inhabited sets formula_14.
Once the backward-direction of this equivalence is a given, then the axiom of choice, in particular granting a choice function on all sets of this form, implies excluded middle for all propositions.
Proof of the lemma.
Choice is valid in all finite sets.
Given that in classical set theory the sets under consideration here are provably all finite (with exactly either the cardinalities one "or" two), the forward direction of the equivalence is thus established.
To prove the backward-direction one considers two subsets of any doubleton with two distinguishable members. As formula_15, a convenient choice is again formula_16. So, using Separation, let
formula_17 
and
formula_18
Both formula_19 and formula_20 are inhabited, as witnessed by formula_21 and formula_22. If the proposition formula_11 can be proven, then both of these sets equal formula_16. In particular, formula_25 by extensionality. 
In turn, for any mathematical function formula_26 that can take both of these sets as an argument, one finds formula_27, the contrapositive of which is formula_28. 
The rest of the proof concerns the pair formula_29, a set of inhabited sets. (Indeed, formula_5 is itself inhabited and even validates formula_14, meaning it is finitely indexed. However, note that when not assuming excluded middle, formula_5 need not be provably finite, in the bijection sense.)
A choice function formula_33 on formula_5 by definition has to map into the general union formula_35 and fulfill
formula_36
Using the definition of the two subsets and the function's established codomain, this reduces to
formula_37
Using the law of distributivity, this in turn implies formula_38. By the previous comment on functions, the existence of a choice function on this set thus implies the disjunction formula_39. This concludes the proof of the lemma.
Discussion.
As noted, formula_11 implies that both defined sets equal formula_16. In that case, the pair formula_42 equals the singleton set formula_43 and there are two possible choice functions on that domain, picking either formula_44 or formula_4. If, instead, formula_11 can be rejected, i.e. if formula_47 holds, then formula_48 and formula_49. So in that case formula_50, and on the proper pair formula_51 there is only one possible choice function, picking the unique inhabitant of each singleton set. This last assignment "formula_52 and formula_53" is not viable if formula_11 holds, as then the two inputs are actually the same. Similarly, the former two assignments are not viable if formula_47 holds, as then the two inputs share no common member. What can be said is that if a choice function exists at all, then there exists a choice function choosing formula_44 from formula_19, and one (possibly the same function) choosing formula_4 from formula_20.
For bivalent semantics, the above three explicit candidates are all the possible choice assignments.
One may define certain sets in terms of the proposition formula_11 and, using excluded middle, in classical set theory prove that these sets constitute choice functions formula_61. Such a set represents an assignment conditioned on whether or not formula_11 holds. If formula_11 can be decided true or false, then such a set explicitly simplifies to one of the above three candidates.
But, in any case, neither formula_11 nor formula_47 can necessarily be established. Indeed, they may even be independent of the theory at hand. Since the former two explicit candidates are each incompatible with the third, it is generally not possible to identify both of the choice function's return values, formula_66 and formula_67, among the terms formula_44 and formula_4. So it is not a function in the sense of the word that it could be explicitly evaluated into its codomain of distinguishable values.
Finitude.
In a theory not assuming the disjunction formula_39 or any principle implying it, it cannot even be proven that a disjunction of the set equality statements above must be the case. In fact, constructively also the two sets formula_19 and formula_20 are not even provably finite. (However, any finite ordinal injects into any Dedekind-infinite set and so a subset of a finite ordinal does validate the logically negative notion of Dedekind-finiteness. This is the case for both formula_19 and formula_20, into which formula_75 cannot be injected. As an aside, it is consistent also with classical formula_76 that there exist sets which are neither Dedekind-infinite nor finite.)
In turn, the pairing formula_42 is also elusive. It is in the surjective image of the domain formula_78, but regarding choice assignments it is not known how explicit value-assignments for both formula_19 and formula_20 can be made, or even how many different assignments would have to be specified. So there is generally no (set) definition such that a constructive theory would prove that joint assignment (set) to be a choice function with domain formula_42. Note that such a situation does not arise with the domain of choice functions granted by the weaker principles of countable and dependent choice, since in these cases the domain is always just formula_82, the trivially countable first infinite cardinal.
Adopting the full axiom of choice or classical logic formally implies that the cardinality of formula_42 is either formula_4 or formula_78, which in turn implies that it is finite. But a postulate such as this mere function existence axiom still does not resolve the question what exact cardinality this domain has, nor does it determine the cardinality of the set of that functions possible output values.
Role of separation.
In summary, functions are related to equality (by the definition of unique existence used in functionality), equality is related to membership (directly through the axiom of extensionality and also through the formalization of choice in sets) and membership is related to predicates (through an axiom of separation). Using the disjunctive syllogism, the statement formula_11 ends up equivalent to the extensional equality of the two sets. And the excluded middle statement for it is equivalent to the existence of some choice function on formula_42. Both goes through whenever formula_11 can be used in a set separation principle.
In theories with only restricted forms of separation, the types of propositions formula_11 for which excluded middle is implied by choice is also restricted. In particular, in the axiom schema of predicative separation only sentences with set bound quantifiers may be used. The restricted form of excluded middle provable in that context is however still not acceptable constructively. For example, when arithmetic has a model (when, relevantly, the infinite collection of natural numbers form a set one may quantify over), then set-bounded but undecidable propositions can be expressed.
Other frameworks.
In constructive type theory, or in Heyting arithmetic extended with finite types, there is typically no separation principle at all - subsets of a type are given different treatments. There, a form of the axiom of choice is a theorem, yet excluded middle is not.
In topoi.
In Diaconescu's original paper, the theorem is presented in terms of topos models of constructive set theory.