First-order logic in terms of substitution built on equality

We import some interfaces and define some variables:  import (PROPOSITIONAL Interface:Classical_propositional_calculus ) import (AXIOMS Interface:Axioms_of_first-order_logic_in_terms_of_substitution_built_on_equality (PROPOSITIONAL) )

var (formula φ ψ χ θ φx φy φs ψy antecedent) var (object s t u s0 s1 t0 t1) var (variable x y z x0 x1 y0 y1) 

Here we derive first-order logic from axioms. The proofs are largely taken from Margaris, although in some cases concepts (such as the deduction theorem) do not translate directly to JHilbert and we need to do things somewhat differently.

A few rules based on axioms
Here is a rule form of.  thm (specializeToObject ((H (∀ x φ))) (subst s x φ) ( H       x φ s SpecializationToObject applyModusPonens )) 

Here's another slight variant of that one.  thm (specializeToObjectInConsequent ((H (antecedent → (∀ x φ)))) (antecedent → (subst s x φ)) ( H       x φ s SpecializationToObject applySyllogism )) 

Builder for ∀
For convenience, we define some rules concerning building up formulas. From  we want to be able to get.  thm (addForAll ((H (φ → ψ))) ((∀ x φ) → (∀ x ψ)) ( H       x generalize

x φ ψ ForAllImplication

applyModusPonens )) 

The builder for the biconditional follows trivially:  thm (buildForAll ((H (φ ↔ ψ))) ((∀ x φ) ↔ (∀ x ψ)) ( H eliminateBiconditionalReverse x addForAll H eliminateBiconditionalForward x addForAll introduceBiconditionalFromImplications )) 

Substitution
Margaris does not develop substitution based on axioms and proofs, but instead describes most of the substitution rules in terms of definitions expressed in English. We don't have that luxury, nor does  know about substitution until we teach it, so we have assumed a number of substitution results as axioms, and here we prove some theorems as consequences of them.

Distinct variable version of makeSubstExplicitNotFree
 thm (makeSubstExplicit ((x s) (x ψ)) ((H (((value x) = s) → (φ ↔ ψ))))  ((subst s x φ) ↔ ψ) ( x ψ DistinctNotFree H       makeSubstExplicitNotFree )) 

Substitutions which replace equal terms
Replacing a variable with either of two terms has the same effect, if the two terms are equal. Since we are assuming various builders for   as axioms, we just need a rule form here.  thm (buildSubstReplacement ((H (s = t)))  ((subst s x φ) ↔ (subst t x φ)) ( H       s t x φ SubstBuilderReplacement applyModusPonens )) 

Builders
We assumed  as an axiom. We biconditionalize it and add some rules.  thm (SubstBuilder  ((∀ x (φ ↔ ψ)) → ((subst s x φ) ↔ (subst s x ψ))) ( φ ψ BiconditionalReverseElimination x addForAll

x φ ψ s SubstAddition applySyllogism

φ ψ BiconditionalForwardElimination x addForAll

x ψ φ s SubstAddition applySyllogism

introduceBiconditionalFromImplicationsInConsequent ))

thm (addSubst ((H (φ → ψ))) ((subst s x φ) → (subst s x ψ)) ( H       x generalize x φ ψ s SubstAddition applyModusPonens ))

thm (buildSubst ((H (φ ↔ ψ))) ((subst s x φ) ↔ (subst s x ψ)) ( H       x generalize x φ ψ s SubstBuilder applyModusPonens )) 

Composition
The ability to compose two substitutions is an easy consequence of  and.

 thm (SubstitutionComposition ((φ y) (s y) (x y))  ((subst s y (subst (value y) x φ)) ↔ (subst s x φ)) ( </jh> We start with.  (value y) s x φ SubstBuilderReplacement </jh> That's all set up for.  makeSubstExplicit )) </jh>

Substituting a variable with something equal to itself
The following result follows directly from  and.  thm (EqualitySubst  (((value x) = s) → (φ ↔ (subst s x φ))) ( </jh> The first step is  (value x) s x φ SubstBuilderReplacement </jh> Now we turn  into.  x φ SubstItself transformImplicationBiconditionalLeft )) </jh>

Turning an equality-based builder into the ability to move substitution across a predicate or operation
Substitution can be moved in or out of a predicate or operation, provided the predicate or operation has a builder. Here we show how, for the case where the predicate is  and the builder is the forward direction of.

We start with the special case in which the variable being substituted is distinct from its replacement.  thm (SubstNegationDistinct ((x s)) ((subst s x (¬ φ)) ↔ (¬ (subst s x φ))) ( </jh> A bit later we'll need, so we stick that on the proof stack.  x s φ SubstNotFree negateNotFree </jh> We start with.  x s φ EqualitySubst </jh> Now we add our predicate (here negation) to the right side, to get.  φ (subst s x φ) NegationFunction eliminateBiconditionalReverse applySyllogism </jh> Making that substitution explicit gives us, which is what we need.  makeSubstExplicitNotFree )) </jh>

Removing the distinct variable constraint is a matter of first substituting for an intermediate variable (which is distinct from everything), and then substituting the original replacement.  thm (SubstNegation ( (y x) (y s) (y φ)) ((subst s x (¬ φ)) ↔ (¬ (subst s x φ))) ( s y x (¬ φ) SubstitutionComposition swapBiconditional </jh> Now we have, which we first transform to  ,  (value y) x φ SubstNegationDistinct s y buildSubst applyBiconditionalTransitivity </jh> and then.  s y (subst (value y) x φ) SubstNegationDistinct applyBiconditionalTransitivity </jh> Applying composition once more we are done.  s y x φ SubstitutionComposition addNegation applyBiconditionalTransitivity )) </jh>

Subst across implication
While we are here, we'll go ahead and prove the analogous result for the other connectives, starting with implication. The proof is very much like the one for negation, with the most obvious difference being that implication has two arguments instead of just one.

 thm (SubstImplicationDistinct ((s x)) ((subst s x (φ → ψ)) ↔ ((subst s x φ) → (subst s x ψ))) ( </jh> A bit later we'll need, so we stick that on the proof stack. <jh> x s φ SubstNotFree x s ψ SubstNotFree implicationNotFree </jh> We start with , <jh> (value x) s x φ SubstBuilderReplacement (value x) s x ψ SubstBuilderReplacement buildImplicationInConsequent </jh> and simplify to. <jh> x φ SubstItself x ψ SubstItself buildImplication transformImplicationBiconditionalLeft </jh> Making that substitution explicit gives us, which is what we need. <jh> makeSubstExplicitNotFree )) </jh>

Removing the distinct variable constraint is analogous to what we did for negation. <jh> thm (SubstImplication ( (y x) (y s) (y φ) (y ψ)) ((subst s x (φ → ψ)) ↔ ((subst s x φ) → (subst s x ψ))) ( s y x (φ → ψ) SubstitutionComposition swapBiconditional

(value y) x φ ψ SubstImplicationDistinct s y buildSubst applyBiconditionalTransitivity

s y (subst (value y) x φ) (subst (value y) x ψ) SubstImplicationDistinct applyBiconditionalTransitivity

s y x φ SubstitutionComposition s y x ψ SubstitutionComposition buildImplication applyBiconditionalTransitivity )) </jh>

Subst across disjunction
Although we could prove similar results for the other three connectives in the same way, it will be slightly more convenient to just prove them from the two we already proved. <jh> thm (SubstDisjunction  ((subst s x (φ ∨ ψ)) ↔ ((subst s x φ) ∨ (subst s x ψ))) ( φ ψ DisjunctionImplication s x buildSubst

s x (¬ φ) ψ SubstImplication applyBiconditionalTransitivity

s x φ SubstNegation (subst s x ψ) buildImplicationConsequent applyBiconditionalTransitivity

(subst s x φ) (subst s x ψ) DisjunctionImplication swapBiconditional applyBiconditionalTransitivity ))

thm (SubstConjunction  ((subst s x (φ ∧ ψ)) ↔ ((subst s x φ) ∧ (subst s x ψ))) ( φ ψ DeMorganNDN swapBiconditional s x buildSubst

s x ((¬ φ) ∨ (¬ ψ)) SubstNegation applyBiconditionalTransitivity

s x (¬ φ) (¬ ψ) SubstDisjunction addNegation applyBiconditionalTransitivity

s x φ SubstNegation s x ψ SubstNegation buildDisjunction addNegation applyBiconditionalTransitivity

(subst s x φ) (subst s x ψ) DeMorganNDN applyBiconditionalTransitivity ))

thm (SubstBiconditional  ((subst s x (φ ↔ ψ)) ↔ ((subst s x φ) ↔ (subst s x ψ))) ( φ ψ BiconditionalImplication s x buildSubst

s x (φ → ψ) (ψ → φ) SubstConjunction applyBiconditionalTransitivity

s x φ ψ SubstImplication s x ψ φ SubstImplication buildConjunction applyBiconditionalTransitivity

(subst s x φ) (subst s x ψ) BiconditionalImplication swapBiconditional applyBiconditionalTransitivity )) </jh>

Existential quantification
We define  in terms of. <jh> def ((∃ x φ) (¬ (∀ x (¬ φ)))) </jh>

Existential Introduction
Introducing  from a substitution is closely related to specializing   to a substitution.

<jh> thm (ThereExistsIntroductionFromObject  ((subst s x φ) → (∃ x φ)) ( </jh> We start with , <jh> x (¬ φ) s SpecializationToObject </jh> turn the consequent into , <jh> s x φ SubstNegation eliminateBiconditionalReverse applySyllogism </jh> and transpose to get, which Margaris calls "An important special case".

<jh> thm (Specialization  ((∀ x φ) → φ) ( x φ (value x) SpecializationToObject

x φ SubstItself eliminateBiconditionalReverse applySyllogism ))

thm (specialize ((H (∀ x φ))) φ ( H       x φ Specialization applyModusPonens )) </jh>

Likewise,  is a special case of.

<jh> thm (ThereExistsIntroduction  (φ → (∃ x φ)) ( x φ SubstItself eliminateBiconditionalForward

(value x) x φ ThereExistsIntroductionFromObject applySyllogism )) </jh>

The previous results let us conclude. <jh> thm (ForAllThereExists  ((∀ x φ) → (∃ x φ)) ( x φ Specialization φ x ThereExistsIntroduction applySyllogism )) </jh>

Quantifier commutation
We can exchange the order of universal quantifiers. Margaris's proof doesn't quite work as-is, as it relies on the deduction theorem, but a fairly small variation of it avoids this problem. <jh> thm (ForAllCommutationImplication  ((∀ x (∀ y φ)) → (∀ y (∀ x φ))) ( </jh> First we add  to the start of. <jh> x (∀ y φ) BoundForAllNotFree GeneralizationNotFree </jh> Then we add  to the start. <jh> y φ BoundForAllNotFree x addForAllNotFree x addForAllNotFree GeneralizationNotFree applySyllogism </jh> That gives us  and dropping the last two quantifiers we are done. <jh> y φ Specialization x addForAll x addForAll y addForAll applySyllogism

x φ Specialization x addForAll y addForAll applySyllogism )) </jh>

The biconditional version follows trivially. <jh> thm (ForAllCommutation  ((∀ x (∀ y φ)) ↔ (∀ y (∀ x φ))) ( x y φ ForAllCommutationImplication y x φ ForAllCommutationImplication introduceBiconditionalFromImplications )) </jh>

Adding and removing quantifiers
Although Margaris does not tackle the biconditionalized version of this theorem until later, it will be convenient to prove it now. It is that, if   is not free in.

<jh> thm (ForAllAddRemoveNotFree ((XFREE (x is-not-free-in φ))) ((∀ x φ) ↔ φ) ( x φ Specialization

XFREE GeneralizationNotFree

introduceBiconditionalFromImplications )) </jh>

Moving is-not-free-in across connectives
The idea that a variable which is not free in the left hand and right hand sides of a connective is not free in the connected formula is basic to the understanding of what it means for a variable to not be free in a formula. We adopted this as an axiom for negation and implication. Here we prove it from the other three connectives, which follow easily from the two axioms.

Disjunction
<jh> thm (disjunctionNotFree  ((HPHI (x is-not-free-in φ)) (HPSI (x is-not-free-in ψ)))  (x is-not-free-in (φ ∨ ψ)) ( HPHI negateNotFree

HPSI implicationNotFree </jh> So far that's. Turning the implication to a disjunction we are done. <jh> φ ψ DisjunctionImplication x buildNotFree eliminateBiconditionalForward applyModusPonens )) </jh>

Conjunction
<jh> thm (conjunctionNotFree  ((HPHI (x is-not-free-in φ)) (HPSI (x is-not-free-in ψ)))  (x is-not-free-in (φ ∧ ψ)) ( HPHI negateNotFree

HPSI negateNotFree

disjunctionNotFree negateNotFree

φ ψ DeMorganNDN x buildNotFree eliminateBiconditionalReverse applyModusPonens )) </jh>

Biconditional
<jh> thm (biconditionalNotFree  ((HPHI (x is-not-free-in φ)) (HPSI (x is-not-free-in ψ)))  (x is-not-free-in (φ ↔ ψ)) ( HPHI HPSI implicationNotFree

HPSI HPHI implicationNotFree

conjunctionNotFree

φ ψ BiconditionalImplication x buildNotFree eliminateBiconditionalForward applyModusPonens )) </jh>

Existential quantification
In a manner similar to the connectives, freeness for  follows from the corresponding axioms for. <jh> thm (BoundThereExistsNotFree  (x is-not-free-in (∃ x φ)) ( x (¬ φ) BoundForAllNotFree negateNotFree ))

thm (addThereExistsNotFree ((HFREE (x is-not-free-in φ))) (x is-not-free-in (∃ y φ)) ( HFREE negateNotFree y addForAllNotFree negateNotFree )) </jh>

Adding existential quantification to the antecedent
Margaris expresses many of his proofs in terms of a rule which he calls Rule C. We give a few variants of rule C, one is that given  we can conclude , provided that   is not free in. Margaris' version basically combines this with the deduction theorem.

The first variation is Theorem 17.11 in Margaris. <jh> thm (ThereExistsAntecedentIntroductionNotFree  ((HFREE (x is-not-free-in ψ)))  ((∀ x (φ → ψ)) → ((∃ x φ) → ψ)) ( </jh> We start with. <jh> φ ψ Transposition eliminateBiconditionalReverse x addForAll

x (¬ ψ) (¬ φ) ForAllImplication applySyllogism </jh> Now we change  to. <jh> HFREE negateNotFree

ForAllAddRemoveNotFree

transformImplicationImplicationAntecedent </jh> Then we turn  into , which is all we need. <jh> ψ (∀ x (¬ φ)) TranspositionWithNegatedAntecedent eliminateBiconditionalReverse applySyllogism )) </jh>

The other variations are direct consequences of this one. <jh> thm (addThereExistsToAntecedentNotFree  ((HFREE (x is-not-free-in ψ)) (HIMP (φ → ψ)))  ((∃ x φ) → ψ) ( HIMP x generalize

HFREE φ ThereExistsAntecedentIntroductionNotFree

applyModusPonens ))

thm (addThereExistsToAntecedent ((x ψ)) ((H (φ → ψ)))  ((∃ x φ) → ψ) ( x ψ DistinctNotFree H       addThereExistsToAntecedentNotFree )) </jh>

We now prove a number of theorems using the ability to add there exists to the antecedent.

There exists across a conjunction
There exists can be split across a conjunction. <jh> thm (ThereExistsConjunction  ((∃ x (φ ∧ ψ)) → ((∃ x φ) ∧ (∃ x ψ))) ( </jh> We start with. <jh> x φ BoundThereExistsNotFree x ψ BoundThereExistsNotFree conjunctionNotFree </jh> The other part of the proof is. <jh> φ ψ ConjunctionRightElimination

φ x ThereExistsIntroduction applySyllogism

φ ψ ConjunctionLeftElimination

ψ x ThereExistsIntroduction applySyllogism

composeConjunction

addThereExistsToAntecedentNotFree )) </jh>

Adding there exists to both sides of an implication
Here we prove. <jh> thm (ForAllImplicationThereExists  ((∀ x (φ → ψ)) → ((∃ x φ) → (∃ x ψ))) ( </jh> We start with. <jh> ψ x ThereExistsIntroduction φ addCommonAntecedent x addForAll </jh> Combining that with  we are done. <jh> x ψ BoundThereExistsNotFree φ ThereExistsAntecedentIntroductionNotFree

applySyllogism )) </jh>

The rule form will also be convenient. <jh> thm (addThereExists ((H (φ → ψ))) ((∃ x φ) → (∃ x ψ)) ( H       x generalize x φ ψ ForAllImplicationThereExists applyModusPonens )) </jh>

There exists commutation
The next theorem is. We could, of course, prove this as a consequence of the corresponding theorem for, but instead we follow Margaris's proof, which adds the quantifiers with   and removes them with. <jh> thm (ThereExistsCommutationImplication  ((∃ x (∃ y φ)) → (∃ y (∃ x φ))) ( </jh> When we invoke, it will expect the freeness hypotheses before the implications, so we start by sticking   and   onto the proof stack. <jh> x φ BoundThereExistsNotFree y addThereExistsNotFree

y (∃ x φ) BoundThereExistsNotFree </jh> Now we can prove  and then add the quantifiers to the antecedent. <jh> φ x ThereExistsIntroduction

(∃ x φ) y ThereExistsIntroduction applySyllogism

addThereExistsToAntecedentNotFree

addThereExistsToAntecedentNotFree )) </jh>

The biconditional version follows trivially. <jh> thm (ThereExistsCommutation  ((∃ x (∃ y φ)) ↔ (∃ y (∃ x φ))) ( x y φ ThereExistsCommutationImplication y x φ ThereExistsCommutationImplication introduceBiconditionalFromImplications )) </jh>

Equivalence and replacement
Although we don't develop a detailed theory of equivalence and replacement (involving substituting equals for equals) quite the way that Margaris presents it, many of the theorems in this chapter of Margaris apply here.

Adding for-all to the consequent
Here we prove, where   is not free in  , and some related theorems and rules. Although Margaris does not emphasize this theorem, it forms the counterpart to adding there exists to the antecedent. That is, Margaris proofs which invoke Rule C can be translated fairly directly into proofs which invoke, and Margaris proofs which invoke generalization combined with the deduction theorem can be translated similarly into proofs which invoke.

<jh> thm (ForAllConsequentNotFreeForward  ((HFREE (x is-not-free-in φ)))  ((∀ x (φ → ψ)) → (φ → (∀ x ψ))) ( x φ ψ ForAllImplication

HFREE ForAllAddRemoveNotFree eliminateBiconditionalForward

(∀ x ψ) addCommonConsequent

applySyllogism ))

thm (addForAllToConsequentNotFree ((HFREE (x is-not-free-in φ)) (HIMP (φ → ψ)))  (φ → (∀ x ψ)) ( HIMP x generalize

HFREE ψ ForAllConsequentNotFreeForward

applyModusPonens ))

thm (ForAllConsequentNotFreeReverse  ((HFREE (x is-not-free-in φ)))  ((φ → (∀ x ψ)) → (∀ x (φ → ψ))) ( </jh> This proof is adapted from metamath. We start with  and the like, there are some complications in translating that proof to our setup (which lacks the deduction theorem), so we opt for a simpler proof based more directly on. <jh> thm (ForAllBiconditionalImplication  ((∀ x (φ ↔ ψ)) → ((∀ x φ) → (∀ x ψ))) ( φ ψ BiconditionalReverseElimination x addForAll

x φ ψ ForAllImplication applySyllogism ))

thm (ForAllBiconditional  ((∀ x (φ ↔ ψ)) → ((∀ x φ) ↔ (∀ x ψ))) ( x φ ψ ForAllBiconditionalImplication

φ ψ BiconditionalSymmetry eliminateBiconditionalReverse x addForAll

x ψ φ ForAllBiconditionalImplication applySyllogism

introduceBiconditionalFromImplicationsInConsequent )) </jh>

Replacement
For Margaris, the ability to replace a formula with one which is equivalent to it is stated in terms of substituting a formula for a subformula of a larger formula. The equivalent for us can accomplish the same things, but is a bit more low-level, and consists of various theorems involving biconditionals. We have already seen  and similar theorems for propositional logic. Here is the counterpart for. <jh> thm (buildThereExists ((H (φ ↔ ψ))) ((∃ x φ) ↔ (∃ x ψ)) ( H       addNegation x buildForAll addNegation )) </jh>

Negation and quantifiers
Margaris next proves, using replacement. We don't need that particular theorem to export to Interface:First-order logic with quantifiability, so we can demonstrate the same replacement-like reasoning with. The proof starts with, but we then need to replace this formula within a quantifier and a negation, which in Margaris is done with the replacement theorem and in our case is done with   and. <jh> thm (NotForAll  ((¬ (∀ x φ)) ↔ (∃ x (¬ φ))) ( φ DoubleNegation x buildForAll addNegation )) </jh>

Change of variable in ∀
We now turn to changing the variable of quantification. Margaris explains this in terms of whether two formulas  and   are similar. Our equivalent is fairly close; the distinct variable constraint between  and   corresponds to Margaris' requirement of two distinct variables; the distinct variable constraints   correspond to Margaris' statement that   must not be free in   and   must not be free in. Margaris' requirement that  be the same as   and that   be the same as   correspond to the hypothesis. These definitions in Margaris can be found on page 86, which also contains Margaris' statement of  and then add   to the consequent. <jh> HFREEY x addForAllNotFree x φx (value y) SpecializationToObject addForAllToConsequentNotFree </jh> Our hypothesis easily leads to. <jh> HFREEX H       makeSubstExplicitNotFree </jh> Combining those two results we are done. <jh> eliminateBiconditionalReverse y addForAll applySyllogism ))

thm (ChangeVariableForAllNotFree ((x y)) ((HFREEX (x is-not-free-in φy)) (HFREEY (y is-not-free-in φx)) (H (((value x) = (value y)) → (φx ↔ φy))) ) ((∀ x φx) ↔ (∀ y φy)) ( </jh> The forward implication is what we just proved. <jh> HFREEX HFREEY H ChangeVariableForAllImplicationNotFree </jh> The reverse implication is much the same. We just need to start out by transforming the hypothesis into. <jh> HFREEY HFREEX H       (value x) (value y) EqualitySymmetry transformAntecedent

φx φy BiconditionalSymmetry eliminateBiconditionalReverse applySyllogism

ChangeVariableForAllImplicationNotFree

introduceBiconditionalFromImplications )) </jh>

A version with distinct variables instead of freeness hypotheses is, of course, a simple consequence. <jh> thm (ChangeVariableForAll ((y φx) (x φy) (x y)) ((H (((value x) = (value y)) → (φx ↔ φy))))  ((∀ x φx) ↔ (∀ y φy)) ( x φy DistinctNotFree y φx DistinctNotFree H       ChangeVariableForAllNotFree )) </jh>

Change of variable in ∃
Although it should be possible to provide the corresponding theorem for ∃ via  and the like (see Intuitionistic first-order logic for an example of that), to keep things simple we just follow Margaris' proof which derives it from the one for ∀. <jh> thm (ChangeVariableThereExists ((y φx) (x φy) (x y))  ((H (((value x) = (value y)) → (φx ↔ φy))))  ((∃ x φx) ↔ (∃ y φy)) ( H       φx φy NegationFunction eliminateBiconditionalReverse applySyllogism

ChangeVariableForAll addNegation ))

thm (ChangeVariableThereExistsNotFree ((x y))  ((HFREEX (x is-not-free-in φy)) (HFREEY (y is-not-free-in φx)) (H (((value x) = (value y)) → (φx ↔ φy)))) ((∃ x φx) ↔ (∃ y φy)) ( HFREEX negateNotFree

HFREEY negateNotFree

H       φx φy NegationFunction eliminateBiconditionalReverse applySyllogism

ChangeVariableForAllNotFree addNegation )) </jh>

Stating changes of variable in terms of explicit substitutions
Another way to express the change variable theorems is with explicit substitution (using ). The proofs from First-order logic with quantifiability work without modification. <jh> thm (ChangeVariableExplicitThereExists ((y φ) (x y)) ((∃ x φ) ↔ (∃ y (subst (value y) x φ))) ( x (value y) φ SubstNotFree y φ DistinctNotFree x (value y) φ EqualitySubst ChangeVariableThereExistsNotFree ))

thm (ChangeVariableExplicitForAll ((y φ) (x y)) ((∀ x φ) ↔ (∀ y (subst (value y) x φ))) ( x (value y) φ SubstNotFree y φ DistinctNotFree x (value y) φ EqualitySubst ChangeVariableForAllNotFree )) </jh>

Theorems stated in chapter 19 of Margaris
In chapter 19, Margaris restates a number of theorems already proved, proves a few additional ones, and states a number while leaving the proof as exercises. Here we prove those which we haven't proved yet and which we need to export to Interface:First-order logic with quantifiability.

Negating there-exists
The theorem  is an easy consequence of our definition of ∃. <jh> thm (NotThereExists  ((¬ (∃ x φ)) ↔ (∀ x (¬ φ))) ( (∀ x (¬ φ)) DoubleNegation swapBiconditional )) </jh>

Adding and removing there exists
We already proved that  if   is not free in. Here we prove the analogous result for. <jh> thm (ThereExistsAddRemoveNotFree ((HFREE (x is-not-free-in φ))) ((∃ x φ) ↔ φ) ( HFREE φ ImplicationReflexivity addThereExistsToAntecedentNotFree

φ x ThereExistsIntroduction

introduceBiconditionalFromImplications )) </jh>

Here are a few variations of basically the same theorem. <jh> thm (NullThereExists ((x φ)) ((∃ x φ) ↔ φ) ( x φ DistinctNotFree ThereExistsAddRemoveNotFree ))

thm (removeThereExists ((x φ)) ((H (∃ x φ))) φ ( H       x φ NullThereExists eliminateBiconditionalReverse applyModusPonens ))

thm (removeThereExistsInConsequent ((x φ)) ((H (antecedent → (∃ x φ)))) (antecedent → φ) ( H       x φ NullThereExists eliminateBiconditionalReverse applySyllogism )) </jh>

Commuting ∃ followed by ∀
∃ followed by ∀ can be switched. <jh> thm (ThereExistsForAllCommutation  ((∃ x (∀ y φ)) → (∀ y (∃ x φ))) ( y φ BoundForAllNotFree x addThereExistsNotFree

x φ BoundThereExistsNotFree

y φ Specialization φ x ThereExistsIntroduction applySyllogism

addThereExistsToAntecedentNotFree

addForAllToConsequentNotFree )) </jh>

Biconditionalized version of ForAllImplicationThereExists
This is a biconditionalized variation of a theorem we already proved. <jh> thm (ForAllBiconditionalThereExists  ((∀ x (φ ↔ ψ)) → ((∃ x φ) ↔ (∃ x ψ))) ( φ ψ BiconditionalReverseElimination x addForAll

x φ ψ ForAllImplicationThereExists applySyllogism

φ ψ BiconditionalForwardElimination x addForAll

x ψ φ ForAllImplicationThereExists applySyllogism

introduceBiconditionalFromImplicationsInConsequent )) </jh>

Distribution of for-all over conjunction
Here we prove. As Margaris does, we prove the forward and reverse directions separately. <jh> thm (ForAllConjunctionForward  ((∀ x (φ ∧ ψ)) → ((∀ x φ) ∧ (∀ x ψ))) ( φ ψ ConjunctionRightElimination x addForAll

φ ψ ConjunctionLeftElimination x addForAll

composeConjunction ))

thm (ForAllConjunctionReverse  (((∀ x φ) ∧ (∀ x ψ)) → (∀ x (φ ∧ ψ))) ( </jh> First is. <jh> x φ BoundForAllNotFree x ψ BoundForAllNotFree conjunctionNotFree </jh> Next is. <jh> (∀ x φ) (∀ x ψ) ConjunctionRightElimination x φ Specialization applySyllogism

(∀ x φ) (∀ x ψ) ConjunctionLeftElimination x ψ Specialization applySyllogism

composeConjunction </jh> Adding  to the consequent finishes the job. <jh> addForAllToConsequentNotFree ))

thm (ForAllConjunction  ((∀ x (φ ∧ ψ)) ↔ ((∀ x φ) ∧ (∀ x ψ))) ( x φ ψ ForAllConjunctionForward x φ ψ ForAllConjunctionReverse introduceBiconditionalFromImplications )) </jh>

Distribution of there-exists across a disjunction
Here is. Margaris leaves the proof as an exercise, so we need to decide whether to derive it from  using our definition of ∃ and DeMorgan's law, or derive it from other theorems which involve ∃. We elect the latter. <jh> thm (ThereExistsDisjunctionSplitting  ((∃ x (φ ∨ ψ)) → ((∃ x φ) ∨ (∃ x ψ))) ( </jh> A bit later we'll need <jh> x φ BoundThereExistsNotFree x ψ BoundThereExistsNotFree disjunctionNotFree </jh> The key part of this proof is  and likewise for. <jh> φ x ThereExistsIntroduction ψ x ThereExistsIntroduction disjoin </jh> Now we are ready to add  to the antecedent. <jh> addThereExistsToAntecedentNotFree ))

thm (ThereExistsDisjunctionCombining  (((∃ x φ) ∨ (∃ x ψ)) → (∃ x (φ ∨ ψ))) ( φ ψ DisjunctionRightIntroduction x addThereExists

ψ φ DisjunctionLeftIntroduction x addThereExists

composeDisjunction ))

thm (ThereExistsDisjunction  ((∃ x (φ ∨ ψ)) ↔ ((∃ x φ) ∨ (∃ x ψ))) ( x φ ψ ThereExistsDisjunctionSplitting x φ ψ ThereExistsDisjunctionCombining introduceBiconditionalFromImplications )) </jh>

Distribution of there-exists across an implication
When distributing ∃ across an implication, the quantifier on the antecedent changes to ∀. Margaris first proves the forward (easy) direction, and then gives two proofs of the reverse direction, which basically amount to rewriting the implication as either a conjunction or a disjunction with the suitable amount of negation. We pick disjunction, and use equivalences so that the proof also takes care of the forward direction too. <jh> thm (ThereExistsImplication  ((∃ x (φ → ψ)) ↔ ((∀ x φ) → (∃ x ψ))) ( φ ψ ImplicationDisjunction x buildThereExists

x (¬ φ) ψ ThereExistsDisjunction applyBiconditionalTransitivity

x φ NotForAll swapBiconditional (∃ x ψ) BiconditionalReflexivity buildDisjunction applyBiconditionalTransitivity

(∀ x φ) (∃ x ψ) ImplicationDisjunction swapBiconditional applyBiconditionalTransitivity )) </jh>

Movement
There are a variety of theorems which involve moving a formula in or out of the scope of a quantifier (where the variable being quantified is not free in the formula). Margaris does not discuss these at length, but he does list them in the theorem schemes in chapter 19.

There exists and conjunction
First is moving a conjunction into or out of existential quantification. <jh> thm (ThereExistsConjunctionMovementNotFree ((HFREE (x is-not-free-in φ)))  ((∃ x (φ ∧ ψ)) ↔ (φ ∧ (∃ x ψ))) ( </jh> For the forward direction, we start with. <jh> x φ ψ ThereExistsConjunction </jh> Then we can remove the quantifier from  to finish the forward direction. <jh> HFREE ThereExistsAddRemoveNotFree eliminateBiconditionalReverse (∃ x ψ) conjoinRR applySyllogism </jh> The proof of the reverse direction is taken from metamath. . It starts with, and adds quantifiers to the consequent to get. <jh> HFREE φ ψ ConjunctionRightIntroduction addForAllToConsequentNotFree

x ψ (φ ∧ ψ) ForAllImplicationThereExists applySyllogism </jh> A bit of propositional logic and we are done. <jh> import introduceBiconditionalFromImplications )) </jh>

Here are two easy consequences stated in terms of distinct variables rather than freeness hypotheses. <jh> thm (ThereExistsConjunctionMovement ((x φ)) ((∃ x (φ ∧ ψ)) ↔ (φ ∧ (∃ x ψ))) ( x φ DistinctNotFree ψ ThereExistsConjunctionMovementNotFree ))

thm (ThereExistsConjunctionRightMovement ((x ψ)) ((∃ x (φ ∧ ψ)) ↔ ((∃ x φ) ∧ ψ)) ( φ ψ ConjunctionCommutativity x buildThereExists

x ψ φ ThereExistsConjunctionMovement applyBiconditionalTransitivity

ψ (∃ x φ) ConjunctionCommutativity applyBiconditionalTransitivity )) </jh>

For all and implication
We can move an antecedent, which does not have the variable being quantified free, in or out of universal quantification. <jh> thm (ForAllImplicationAntecedentMovement ((HFREE (x is-not-free-in φ))) ((∀ x (φ → ψ)) ↔ (φ → (∀ x ψ))) ( </jh> The forward direction just distributes the quantifier over the implication and removes the unnecessary quantifier on the antecedent. <jh> x φ ψ ForAllImplication

HFREE GeneralizationNotFree (∀ x ψ) addCommonConsequent applySyllogism </jh> The reverse direction follows from  and. <jh> HFREE x ψ BoundForAllNotFree implicationNotFree

x ψ Specialization φ addCommonAntecedent

addForAllToConsequentNotFree

introduceBiconditionalFromImplications ))

thm (moveAntecedentOutOfForAll ((H (∀ x (φ → ψ))) (HFREE (x is-not-free-in φ))) (φ → (∀ x ψ)) ( H

HFREE ψ ForAllImplicationAntecedentMovement eliminateBiconditionalReverse

applyModusPonens ))

thm (moveAntecedentIntoForAll  ((H (φ → (∀ x ψ))) (HFREE (x is-not-free-in φ)))  (∀ x (φ → ψ)) ( H

HFREE ψ ForAllImplicationAntecedentMovement eliminateBiconditionalForward

applyModusPonens )) </jh>

Moving antecedent in or out of there exists
We can move the antecedent in or out of there exists. <jh> thm (ThereExistsAntecedentMovementNotFree ((HFREE (x is-not-free-in φ))) ((∃ x (φ → ψ)) ↔ (φ → (∃ x ψ))) ( x φ ψ ThereExistsImplication

HFREE ForAllAddRemoveNotFree (∃ x ψ) buildImplicationConsequent

applyBiconditionalTransitivity ))

thm (ThereExistsAntecedentMovement ((x φ)) ((∃ x (φ → ψ)) ↔ (φ → (∃ x ψ))) ( x φ DistinctNotFree ψ ThereExistsAntecedentMovementNotFree )) </jh>

Moving the consequent in or out of for all
When we move the consequent out of, it changes to. The proof is based on the one in metamath. <jh> thm (ForAllImplicationConsequentMovement ((HFREE (x is-not-free-in ψ))) ((∀ x (φ → ψ)) ↔ ((∃ x φ) → ψ)) ( </jh> The forward direction is just a matter of distributing ∀ into two existential quantifiers and getting rid of the one which doesn't do anything. <jh> x φ ψ ForAllImplicationThereExists

HFREE ThereExistsAddRemoveNotFree eliminateBiconditionalReverse (∃ x φ) addCommonAntecedent applySyllogism </jh> The reverse direction is based on  and that   is not free in. <jh> x φ BoundThereExistsNotFree HFREE implicationNotFree

φ x ThereExistsIntroduction ψ addCommonConsequent

addForAllToConsequentNotFree

introduceBiconditionalFromImplications )) </jh>

Moving the consequent in or out of there exists
Similar to the previous one, but with ∃ and ∀ exchanged. <jh> thm (ThereExistsImplicationConsequentMovement ((HFREE (x is-not-free-in ψ)))  ((∃ x (φ → ψ)) ↔ ((∀ x φ) → ψ)) ( x φ ψ ThereExistsImplication

HFREE ThereExistsAddRemoveNotFree (∀ x φ) buildImplicationAntecedent

applyBiconditionalTransitivity )) </jh>

Disjunction movement
We can move a conjunct out of or into there exists. <jh> thm (ThereExistsDisjunctionMovementNotFree ((HFREE (x is-not-free-in φ)))  ((∃ x (φ ∨ ψ)) ↔ (φ ∨ (∃ x ψ))) ( x φ ψ ThereExistsDisjunction

HFREE ThereExistsAddRemoveNotFree (∃ x ψ) buildDisjunctionRR

applyBiconditionalTransitivity ))

thm (ThereExistsDisjunctionMovement ((x φ)) ((∃ x (φ ∨ ψ)) ↔ (φ ∨ (∃ x ψ))) ( x φ DistinctNotFree ψ ThereExistsDisjunctionMovementNotFree ))

thm (ThereExistsDisjunctionRightMovementNotFree ((HFREE (x is-not-free-in ψ)))  ((∃ x (φ ∨ ψ)) ↔ ((∃ x φ) ∨ ψ)) ( x φ ψ ThereExistsDisjunction

HFREE ThereExistsAddRemoveNotFree (∃ x φ) buildDisjunctionLL

applyBiconditionalTransitivity ))

thm (ThereExistsDisjunctionRightMovement ((x ψ)) ((∃ x (φ ∨ ψ)) ↔ ((∃ x φ) ∨ ψ)) ( x ψ DistinctNotFree φ ThereExistsDisjunctionRightMovementNotFree ))

</jh>

Combining one universal and one existential quantifier
Suppose we have one formula which holds for all values of a variable, and another which holds for some value. Then there is a value for which both hold. In symbols,. <jh> thm (ThereExistsConjunctionCombining   (((∀ x φ) ∧ (∃ x ψ)) → (∃ x (φ ∧ ψ))) ( x φ BoundForAllNotFree ψ ThereExistsConjunctionMovementNotFree eliminateBiconditionalForward

x φ Specialization ψ conjoinRR x addThereExists applySyllogism )) </jh>

It will also be convenient to have a commuted version, and a rule. <jh> thm (ThereExistsConjunctionRightCombining   (((∃ x φ) ∧ (∀ x ψ)) → (∃ x (φ ∧ ψ))) ( (∃ x φ) (∀ x ψ) ConjunctionCommutativity eliminateBiconditionalReverse

x ψ φ ThereExistsConjunctionCombining applySyllogism

ψ φ ConjunctionCommutativity eliminateBiconditionalReverse x addThereExists applySyllogism ))

thm (combineThereExistsForAll ((HEXISTS (∃ x φ)) (HALL (∀ x ψ))) (∃ x (φ ∧ ψ)) ( HEXISTS HALL introduceConjunction

x φ ψ ThereExistsConjunctionRightCombining applyModusPonens )) </jh>

A few more movement rules
Here are a few rules, for convenience: <jh> thm (moveLeftConjunctIntoThereExistsInConsequent ((x φ)) ((H (antecedent → (φ ∧ (∃ x ψ)))))  (antecedent → (∃ x (φ ∧ ψ))) ( H

x φ ψ ThereExistsConjunctionMovement eliminateBiconditionalForward applySyllogism ))

thm (moveRightConjunctIntoThereExistsInConsequent ((x ψ)) ((H (antecedent → ((∃ x φ) ∧ ψ))))  (antecedent → (∃ x (φ ∧ ψ))) ( H

x φ ψ ThereExistsConjunctionRightMovement eliminateBiconditionalForward applySyllogism ))

thm (repeatAntecedentThereExists ((x antecedent)) ((H (antecedent → (∃ x ψ))))  (antecedent → (∃ x (antecedent ∧ ψ))) ( antecedent ImplicationReflexivity H       composeConjunction moveLeftConjunctIntoThereExistsInConsequent )) </jh>

Scattering and gathering
The rules and theorems we call scattering and gathering are just consequences of the movement theorems, and as such we can use the exact same proofs as in First-order logic. <jh> thm (ThereExistsScattering ((φx y) (ψy x))  ((∃ x (∃ y (φx ∧ ψy))) ↔ ((∃ x φx) ∧ (∃ y ψy))) ( (∃ x φx) (∃ y ψy) ConjunctionCommutativity

x ψy DistinctNotFree y addThereExistsNotFree φx ThereExistsConjunctionMovementNotFree swapBiconditional applyBiconditionalTransitivity

(∃ y ψy) φx ConjunctionCommutativity x buildThereExists applyBiconditionalTransitivity

y φx ψy ThereExistsConjunctionMovement swapBiconditional x buildThereExists applyBiconditionalTransitivity

swapBiconditional ))

thm (gatherThereExistsInConsequent ((φx y) (ψy x)) ((H (antecedent → ((∃ x φx) ∧ (∃ y ψy))))) (antecedent → (∃ x (∃ y (φx ∧ ψy)))) ( H       x y φx ψy ThereExistsScattering eliminateBiconditionalForward applySyllogism )) </jh>

Other theorems
Here we present a few theorems which are convenience theorems, or other fairly simple deductions from theorems we have. <jh> thm (buildThereExistsInConsequent ((x φ)) ((H (φ → (ψ ↔ χ))))  (φ → ((∃ x ψ) ↔ (∃ x χ))) ( H       x addForAllToConsequent

x ψ χ ForAllBiconditionalThereExists applySyllogism ))

thm (buildForAllInConsequent ((x φ)) ((H (φ → (ψ ↔ χ))))  (φ → ((∀ x ψ) ↔ (∀ x χ))) ( H       x addForAllToConsequent

x ψ χ ForAllBiconditional applySyllogism ))

thm (Generalization ((x φ)) (φ → (∀ x φ)) ( x φ DistinctNotFree GeneralizationNotFree )) </jh>

Equality
Margaris considers equality in chapter 21. Most of the theorems there we have already adopted as axioms, but there are a variety of convenience theorems and the like to prove before we can export to Interface:First-order logic with quantifiability. In most cases we can just take the same proofs from First-order logic. <jh> def ((≠ s t) (¬ (s = t)))

thm (swapEquality ((H (s = t))) (t = s) ( H       s t EqualitySymmetry eliminateBiconditionalReverse applyModusPonens ))

thm (swapEqualityInConsequent ((H (φ → (s = t)))) (φ → (t = s)) ( H       s t EqualitySymmetry eliminateBiconditionalReverse applySyllogism ))

thm (applyEqualityTransitivity ((H1 (s = t)) (H2 (t = u))) (s = u) ( H1       H2        introduceConjunction s t u EqualityTransitivity applyModusPonens ))

thm (applyEqualityTransitivityInConsequent ((H1 (φ → (s = t))) (H2 (φ → (t = u)))) (φ → (s = u)) ( H1       H2        composeConjunction s t u EqualityTransitivity applySyllogism ))

thm (EqualityBuilderRR  ((s0 = s1) → ((s0 = t) ↔ (s1 = t))) ( s0 s1 EqualitySymmetry eliminateBiconditionalReverse

s1 s0 t EqualityTransitivity export

applySyllogism

s0 s1 t EqualityTransitivity export

composeConjunction

(s0 = t) (s1 = t) BiconditionalImplication eliminateBiconditionalForward applySyllogism ))

thm (commute2  (((s0 = t0) ↔ (s1 = t1)) → ((t0 = s0) ↔ (t1 = s1))) ( s0 t0 EqualitySymmetry s1 t1 EqualitySymmetry buildBiconditional eliminateBiconditionalReverse ))

thm (EqualityBuilderLL  ((s0 = s1) → ((t = s0) ↔ (t = s1))) ( s0 s1 t EqualityBuilderRR s0 t s1 t commute2 applySyllogism ))

thm (EqualityBuilder  (((s0 = s1) ∧ (t0 = t1)) → ((s0 = t0) ↔ (s1 = t1))) ( (s0 = s1) (t0 = t1) ConjunctionRightElimination s0 s1 t0 EqualityBuilderRR applySyllogism

(s0 = s1) (t0 = t1) ConjunctionLeftElimination t0 t1 s1 EqualityBuilderLL applySyllogism

composeConjunction

(s0 = t0) (s1 = t0) (s1 = t1) BiconditionalTransitivity applySyllogism ))

thm (buildEquality ((HX (s0 = s1)) (HY (t0 = t1))) ((s0 = t0) ↔ (s1 = t1)) ( HX       HY        introduceConjunction s0 s1 t0 t1 EqualityBuilder applyModusPonens ))

thm (buildEqualityRR ((H (s0 = s1))) ((s0 = t) ↔ (s1 = t)) ( H       t EqualityReflexivity introduceConjunction

s0 s1 t t EqualityBuilder

applyModusPonens ))

thm (buildEqualityLL ((H (t0 = t1))) ((s = t0) ↔ (s = t1)) ( s EqualityReflexivity H       introduceConjunction

s s t0 t1 EqualityBuilder

applyModusPonens ))

thm (buildEqualityInConsequent  ((HN (φ → (s0 = s1))) (HM (φ → (t0 = t1)))) (φ → ((s0 = t0) ↔ (s1 = t1))) ( HN HM composeConjunction s0 s1 t0 t1 EqualityBuilder applySyllogism ))

thm (buildEqualityRRInConsequent  ((H (φ → (s0 = s1))))  (φ → ((s0 = t) ↔ (s1 = t))) ( H       t EqualityReflexivity φ introduceAntecedent buildEqualityInConsequent ))

thm (buildEqualityLLInConsequent  ((H (φ → (t0 = t1))))  (φ → ((s = t0) ↔ (s = t1))) ( s EqualityReflexivity φ introduceAntecedent H       buildEqualityInConsequent )) </jh>

Quantifiability
<jh> thm (Quantifiability ((x s)) (∃ x ((value x) = s)) ( </jh> We stick  on the proof stack for later use. <jh> s EqualityReflexivity </jh> We start with. <jh> (value x) s s EqualityBuilderRR </jh> That in turn implies, which of course implies. <jh> makeSubstExplicit eliminateBiconditionalForward applyModusPonens </jh> And that is enough to give us <jh> introduceThereExistsFromObject )) </jh>

Variable to term
Although converting a variable to a term is more of a substitution concept than an equality one, since it is stated in terms of equality we prove it here. Although this theorem doesn't exist in Margaris in quite this form, it has echoes in the Margaris theorems concerning substituting equals for equals, for example 21.8. <jh> thm (VariableToObject ((x s) (x φs)) ((HSUBST (((value x) = s) → (φx ↔ φs))) (H φx) ) φs ( H       x generalize

x φx s SpecializationToObject applyModusPonens

HSUBST makeSubstExplicit eliminateBiconditionalReverse applyModusPonens )) </jh>

Substitution
Although our axioms were based on substitution and we've proved many of the substitution theorems we need, here are a few more consequences and convenience theorems.

Substitution of a theorem remains a theorem
If we have a theorem, we can add a variable substitution onto it. This is just a generalization followed by specializeToObject. <jh> thm (introduceSubst ((H φ)) (subst s x φ) ( H       x generalize s specializeToObject )) </jh>

Moving substitution across quantifiers
We have already shown we can move substitution across connectives. We can also move it across quantifiers (when variables are distinct). <jh> thm (SubstThereExists ((x y s)) ((subst s x (∃ y φ)) ↔ (∃ y (subst s x φ))) ( </jh> First is <jh> x s φ SubstNotFree y addThereExistsNotFree </jh> Leaving that aside for now, we start with , <jh> x s φ EqualitySubst </jh> add the quantifier to the two sides of the biconditional, and invoke. <jh> y buildThereExistsInConsequent makeSubstExplicitNotFree )) </jh>

Substitution of a variable which does not appear
If a variable does not appear in a formula, substituting it for anything does not affect the truth of the formula. <jh> thm (NullSubstitution ((x φ)) ((subst s x φ) ↔ φ) ( s x φ ThereExistsIntroductionFromObject removeThereExistsInConsequent

φ x Generalization x φ s SpecializationToObject applySyllogism

introduceBiconditionalFromImplications )) </jh>

A lemma regarding substitution and equality
Here we show. <jh> thm (SubstEquality ((x s)) (subst s x ((value x) = s)) ( </jh> We start with. <jh> s EqualityReflexivity </jh> The elaboration begins with , <jh> (value x) s s EqualityBuilderRR makeSubstExplicit </jh> which we then combine with  to give. <jh> eliminateBiconditionalForward applyModusPonens )) </jh>

Change of variable in substitution
Changing the bound variable in a substitution is possible, much as we do for quantifiers.

We are trying to show that we can conclude  from   (where almost everything is distinct except that   can contain   and   can contain  ). Without trying to sketch out the proof in detail right now, we will be adding  to the start of both sides of the implication, and likewise for. The first lemma is a variation of  which substitutes both sides of the equality, not just one. <jh> thm (ChangeVariableSubstitution-1 ((x y) (s x) (s y))   (subst s y (subst s x ((value x) = (value y)))) ( s x SubstEquality </jh> Having substituted one side of the equality, we pull the same trick with. The equivalence is, which derives from. <jh> (value y) s (value x) EqualityBuilderLL x addForAllToConsequent

x ((value x) = (value y)) ((value x) = s) s SubstBuilder applySyllogism

makeSubstExplicit </jh> Combining that with  gives , as desired. <jh> eliminateBiconditionalForward applyModusPonens ))

thm (ChangeVariableSubstitution ((y φx) (x φy) (x y) (s x) (s y))  ((H (((value x) = (value y)) → (φx ↔ φy))))  ((subst s x φx) ↔ (subst s y φy)) ( </jh> We'll stick our lemma on the proof stack for later. <jh> s y x ChangeVariableSubstitution-1

H </jh> We now have. We add a substitution for  everywhere, to get <jh> s x addSubst

s x φx φy SubstBiconditional eliminateBiconditionalReverse applySyllogism </jh> Now we add a substitution for  everywhere, to get. <jh> s y addSubst

s y (subst s x φx) (subst s x φy) SubstBiconditional eliminateBiconditionalReverse applySyllogism </jh> Detaching the lemma we get. <jh> applyModusPonens </jh> Because  does not occur in , we can remove   from the left hand side. <jh> swapBiconditional s y (subst s x φx) NullSubstitution applyBiconditionalTransitivity swapBiconditional </jh> Similarly, we remove  from the right hand side. <jh> s x φy NullSubstitution s y buildSubst applyBiconditionalTransitivity )) </jh>

Implicit substitution and universal quantification
One way to express a substitution is. <jh> thm (ImplicitForAll-1 ((x s) (x ψ))  ((subst s x φ) → (∀ x (((value x) = s) → φ))) ( </jh> Later we'll need <jh> x s φ SubstNotFree </jh> We start with. <jh> x s φ EqualitySubst eliminateBiconditionalForwardInConsequent applyComm </jh> Adding for-all to the consequent we are finished. <jh> addForAllToConsequentNotFree ))

thm (ImplicitForAll-2 ((x s) (x ψ))  ((∀ x (((value x) = s) → φ)) → (subst s x φ)) ( </jh> We'll need  shortly, so we put it on the proof stack. <jh> s x SubstEquality

x (((value x) = s) → φ) s SpecializationToObject

s x ((value x) = s) φ SubstImplication eliminateBiconditionalReverse applySyllogism </jh> Now the consequent is. But  is always true. <jh> detachImplicationImplication ))

thm (ImplicitForAll ((x s) (x ψ)) ((H (((value x) = s) → (φ ↔ ψ)))) ((∀ x (((value x) = s) → φ)) ↔ ψ) ( x s φ ImplicitForAll-2 s x φ ImplicitForAll-1 introduceBiconditionalFromImplications

H       makeSubstExplicit

applyBiconditionalTransitivity )) </jh>

Implicit substitution and existential quantification
There is another similar expression, involving, namely. <jh> thm (ImplicitThereExists-1 ((x s))  ((subst s x φ) → (∃ x (((value x) = s) ∧ φ))) ( </jh> We start with. <jh> x s φ SubstNotFree </jh> We start with , <jh> x s φ EqualitySubst </jh> and apply propositional logic to turn it into. <jh> eliminateBiconditionalReverseInConsequent import </jh> Adding  to the antecedent we are done. <jh> addThereExistsToAntecedentNotFree ))

thm (ImplicitThereExists ((x s) (x ψ)) ((H (((value x) = s) → (φ ↔ ψ)))) ((∃ x (((value x) = s) ∧ φ)) ↔ ψ) ( x s φ ImplicitThereExists-2 s x φ ImplicitThereExists-1 introduceBiconditionalFromImplications

H       makeSubstExplicit

applyBiconditionalTransitivity )) </jh>

Export
We can export first-order logic now. <jh> export (FIRSTORDER Interface:First-order_logic_with_quantifiability (PROPOSITIONAL) ) </jh>

Quantifiability
We also export the axiom of quantifiability, just to emphasize that this "axiom" is not just a (possibly arbitrary seeming) statement about proper classes, but is a consequence of substitution rules such as those described in Margaris.

We've already proved, but for the export we also need a slight rearrangement of one of the equality builders. <jh> thm (TermEqualityAxiom  ((s = t) → ((s = u) → (t = u))) ( s t u EqualityBuilderRR eliminateBiconditionalReverseInConsequent ))

export (QUANTIFIABILITY Interface:Axiom_of_quantifiability (PROPOSITIONAL FIRSTORDER) ) </jh>

Freeness
Until now we have glossed over one fact, which is that  does not quite match the textbook definition of freeness given in sources like Margaris. Our axioms for  also imply that a variable is considered to not be free in a theorem. For example, we can prove, whereas Margaris and other conventional treatments would consider   to be free in. Therefore,  could perhaps be better read as "is effectively not free in" than "is not free in", although its function is close enough to the traditional definition for most purposes.

To demonstrate this property of, we prove the following theorem. <jh> thm (TheoremNotFree ((H φ)) (x is-not-free-in φ) ( </jh> First we observe. <jh> x φ BoundForAllNotFree </jh> Next is. <jh> H       x generalize

H

introduceConjunction

(∀ x φ) φ TruthBiconditional applyModusPonens </jh> Adding  to both sides is basically all we need from here. <jh> x buildNotFree eliminateBiconditionalReverse applyModusPonens )) </jh>

Metamath axiomization of first-order logic
We also export the metamath axiomization of first-order logic, to provide a the solution to a modified version of the problem stated at 17 on the metamath site.

First we need some alternate names or very slight rearrangements for some of our existing axioms or theorems. <jh> thm (QuantifiedImplication  ( (∀ x (φ → ψ)) → ((∀ x φ) → (∀ x ψ)) ) ( x φ ψ ForAllImplication ))

thm (QuantifierCommutation  ( (∀ x (∀ y φ)) → (∀ y (∀ x φ)) ) ( x y φ ForAllCommutation eliminateBiconditionalReverse )) </jh>

We also need to export, which is an easy consequence of our theory of free variables. <jh> thm (QuantifiedNegation  ( (¬ (∀ x φ)) → (∀ x (¬ (∀ x φ))) ) ( x φ BoundForAllNotFree negateNotFree

ForAllAddRemoveNotFree eliminateBiconditionalForward )) </jh>

Although metamath has  without , for our purposes we might just try to prove the former as a special case of the latter. <jh> thm (ExistenceDistinct ((x y)) (¬ (∀ x (¬ ((value x) = (value y))))) ( x (value y) Quantifiability ))

thm (ExistenceNotDistinct  (¬ (∀ x (¬ ((value x) = (value x))))) ( (value x) EqualityReflexivity ((value x) = (value x)) x ThereExistsIntroduction applyModusPonens )) </jh>

Once we are done, here we would export the metamath axioms.

<jh> </jh>
 * 1) export (METAMATH Interface:Axioms_of_first-order_logic (PROPOSITIONAL) )