Interface:Axioms of first-order logic in terms of substitution built on equality

The axioms of first-order logic are usually stated in terms of substitution of one variable or constant for another, free variables and bound variables. Although JHilbert or metamath do not have this sort of knowledge of free variables or substitution built in, we can to some extent approximate the conventional axioms using the mechanisms we do have. Here we define substitution in terms of equality, and having done so, state axioms in terms of substitution.

The axioms are (somewhat loosely) based on those in Margaris.

It is possible to prove everything in Interface:First-order logic with quantifiability from these axioms. Therefore, this axiomization is an alternative to the metamath-inspired axiomization Interface:Axioms of first-order logic (plus the Interface:Axiom of quantifiability which is what allows substitution to proceed smoothly).

Formulas and objects
First we build on Interface:Classical propositional calculus.  param (CLASSICAL Interface:Classical_propositional_calculus ) 

We use φ, ψ, χ, and θ to represent formulas.  var (formula φ ψ χ θ) 

We use the word object to refer to something which is subject to equality (or, indirectly, via, quantification). We define a kind called, which corresponds to a term in more conventional terminology. Theories built on first-order logic, like ZFC set theory or Peano arithmetic, will define additional kinds of terms such as  (addition) or   (union). This corresponds to the operation symbols of Margaris. Such theories will also define new kinds of formulas such as  (less than) or   (is an element of), which correspond to the predicate symbols of Margaris.

 kind (object) var (object s t u s0 s1 t0 t1) 

A variable is something we can quantify over.

 kind (variable) var (variable x y z x0 x1 y0 y1) 

A variable can be used where an object is expected, although it needs to be converted via the following explicit conversion. When we are writing informally (rather than in JHilbert proofs themselves), we may omit the conversion (it should be understood whereever we use a variable in a context where an object is expected).  term (object (value variable)) 

The reverse is not possible. Examples of objects which are not variables might be  for Peano arithmetic, or   for set theory.

Quantification
We extend the available formulas with universal quantification.  term (formula (∀ variable formula)) 

Universal quantification can be distributed across implication. This is axiom A4 in Margaris.  stmt (ForAllImplication  ( (∀ x (φ → ψ)) → ((∀ x φ) → (∀ x ψ)) ) ) 

Free variables
Margaris defines free variables in terms of whether the variable has any occurences in a subformula which quantifies the occurence in question. At first glance, this might appear to be impossible to express in JHilbert, but we can actually express it fairly directly (at least, a good enough approximation for our purposes). There is one subtlety: Margaris states that the presence of a non-bound occurrence is a necessary and sufficient condition. We only provide one direction of this: we provide various ways to conclude that a variable is not free in a formula, but no way to show that a variable is free in one. This fits in better with the metamath-inspired treatment at Interface:Axioms of first-order logic and turns to be all we need to express Margaris's axioms.

 term (formula (is-not-free-in variable formula)) 

Most of the cases are straightforward:  is not free in , or a formula in which it does not occur, and whether it is free in another formula depends on whether it is free in each of the subformulas which make up that formula.  stmt (BoundForAllNotFree  (x is-not-free-in (∀ x φ))) stmt (DistinctNotFree ((x φ)) (x is-not-free-in φ))

stmt (addForAllNotFree ((x is-not-free-in φ)) (x is-not-free-in (∀ y φ)))

stmt (negateNotFree ((x is-not-free-in φ)) (x is-not-free-in (¬ φ))) stmt (implicationNotFree  ((x is-not-free-in φ) (x is-not-free-in ψ))  (x is-not-free-in (φ → ψ)) ) </jh>

We have handled the cases of "each of the subformulas which make up that formula" for logical connectives and quantifiers. But how can we deal with operations and predicates (which aren't even defined here, but instead in a module which imports first-order logic)? For example, suppose there is a predicate  is a theorem. We want to show that  follows from   and. The following axiom (together with the ones already presented) allows us to make that conclusion.  stmt (buildNotFree ((φ ↔ ψ)) ((x is-not-free-in φ) ↔ (x is-not-free-in ψ))) </jh>

Generalization
The ability to generalize when the variable is not free in the formula is axiom A6 in Margaris.  stmt (GeneralizationNotFree ((x is-not-free-in φ)) (φ → (∀ x φ))) </jh>

The ability to generalize a theorem, even if the variable is free in the formula, has two cases for Margaris. Margaris adopts an axiom schema called  which is the ability to generalize an axiom, and from that derives the ability to generalize a theorem. Because we do not have any way of distinguishing between an axiom and a theorem, we adopt the more general form as an axiom.  stmt (generalize (φ) (∀ x φ)) </jh>

Margaris defines a second quantifier (∃ for "there exists") in terms of ∀, so we have avoided it in the above axioms and do not need to define it here.

There is one more axiom, specialization (including the ability to substitute). Roughly speaking it says that one can take a formula of the form  and substitute a term   for the variable   inside. To state this in JHilbert, and correctly state what kinds of substitutions are permissible, will require us to define substitution, which we do mostly in terms of equality.

Reflexive, symmetry, and transitive
We introduce equality, which is reflexive, symmetry, and transitive. For simplicity, we simply adopt these three properties as axioms, rather than a smaller set of axioms which imply them.

 term (formula (= object object))

stmt (EqualityReflexivity  (s = s)) stmt (EqualitySymmetry  ((s = t) ↔ (t = s))) stmt (EqualityTransitivity  (((s = t) ∧ (t = u)) → (s = u))) </jh>

Substitution
We first define the  term:

 term (formula (subst object variable formula)) </jh>

so for example  can be thought of as a copy of   in which   is changed to. In more conventional notation this would be. A common but potentially ambiguous notation for this concept is changing  to   (one way to avoid the ambiguity is to follow the rules Margaris gives in defining similar formulas).

In many treatments of predicate logic, substitution is treated as a syntactic operation. For example  is equivalent to plugging in   for   to get. It is then necessary to provide a condition that the substitution (in this case ) is not "captured" by any quantifiers. For example it is not legitimate to expand  into. Margaris provides this in the definition of "admits". In our case, we treat substitution as following from equality. For example,  suffices to prove. The equivalent to the "admits" concept is the distinct variable constraint between  and   in the following theorem, together with normal predicate logic rules for adding quantifiers to the consequent in building up the formula. (TODO: expand on an example which shows that the  is needed, or otherwise explains what the admits stuff is all about in our context. My first attempt didn't quite hang together).

 stmt (makeSubstExplicitNotFree ((x s)) ((x is-not-free-in ψ) (((value x) = s) → (φ ↔ ψ)))  ((subst s x φ) ↔ ψ)) </jh>

Quite aside from the details of what substitutions are proper in the context of quantifiers, we also need to define substitution generally. The most obvious definition is a recursive one. It requires a bit of notation we don't otherwise need:  for   in the term. It can be found in metamath as.

substTerm s x x = s substTerm s x z = z (where z is distinct from x)  substTerm s x (t OP u) = (substTerm s x t) OP (substTerm s x u)    where OP is any operation defined by a module which includes first-order logic subst s x (t PRED u) ↔ (substTerm s x t) PRED (substTerm s x u)   where PRED is any predicate defined by a module which includes first-order logic

However, having described substitution informally in terms of this kind of recursive definition, we define it in a fairly different way, based on equality and some other axioms (which might not be a minimal axiomization, but which does suffice for our purposes). The reason for tying things into equality has to do with how the above steps are to be stated for each operation and predicate in the system.

The procedure which has been followed by modules building on first-order logic (that is, Interface:First-order logic or Interface:First-order logic with quantifiability) is to define an axiom for each operation or predicate which states that equals can be substituted for equals. We call such axioms builders and they take the form. Because these builders are in terms of equality,  covers most of the above cases in defining substitution. We adopt a few more axioms to make this work. First are some builders (or similar theorems) for  itself:

 stmt (SubstBuilderReplacement   ((s = t) → ((subst s x φ) ↔ (subst t x φ)))) stmt (SubstAddition  ((∀ x (φ → ψ)) → ((subst s x φ) → (subst s x ψ)))) </jh>

A substitution is like a quantifier, in that it binds the variable being substituted for.  stmt (SubstNotFree ((x s)) (x is-not-free-in (subst s x φ))) </jh>

We also state that substituting a variable for itself has no effect. Margaris states this but does not justify it, apparently treating it as an obvious consequence of a syntactic definition of substitution.

 stmt (SubstItself  ((subst (value x) x φ) ↔ φ)) </jh>

Specialization
Having defined substitution, we are prepared to adopt our final first-order logic axiom, which is A5 in Margaris.  stmt (SpecializationToObject  ((∀ x φ) → (subst s x φ))) </jh>