k -Provability in PA

. We study the decidability of k -provability in PA—the relation ‘being provable in PA with at most k steps’—and the decidability of the proof-skeleton problem—the problem of deciding if a given formula has a proof that has a given skeleton (the list of axioms and rules that were used). The decidability of k -provability for the usual Hilbert-style formalisation of PA is still an open problem, but it is known that the proof-skeleton problem is undecidable for that theory. Using new methods, we present a characterisation of some numbers k for which k -provability is decidable, and we present a characterisation of some proof-skeletons for which one can decide whether a formula has a proof whose skeleton is the considered one. These characterisations are natural and parameterised by uniﬁcation algorithms.


Introduction
k-provability is the notion of provability ' ksteps ', i.e. the notion of being provable, in a certain theory, with at most k steps.This notion has been studied for different theories and with different purposes.In [6,11], and [8] the decidability of this relation was studied for several formalisations of Peano arithmetic (PA).Kreisel's conjecture-an open problem in k-provability [4]-was studied in [3,[7][8][9]11,12], and [1].We recommend [10] for a detailed account of this and other notions of provability.
In [2], it was proved that k-provability is undecidable for the sequent calculus of arithmetic with an infinite number of relation-symbols.Furthermore, in [6], this relation was proved to be decidable for several formulations of PA where the universal instantiation schema is replaced by other schemata.The usual universal instantiation schema is: Uni.Inst (∀x.ϕ) → ϕ x t , where t is substitutable for x in ϕ.
It is an open problem whether k-provability for PA with the usual instantiation schema is decidable [6].From [6,8], and [10, p. 103] we know that the proof-skeleton problem is undecidable for PA with the usual instantiation schema; by proof-skeleton problem we mean the problem of deciding if a given formula has a proof whose skeleton (the list of axioms and rules that were used) is the considered one.
PA is obtained from Q by adding the induction schema: PA1) ϕ y 0 ∧ ∀x.(ϕ y x → ϕ y S(x) ) → ∀x.ϕ y x , where y is free in ϕ and x is substitutable for y in ϕ.
Observe that we are considering the signature of the logic as only having the universal quantifier, implication sign, and negation sign: whenever another connective appears, it should be written using only implication and negation signs; for instance ϕ ∧ ψ := ¬(ϕ → ¬ψ).Other options could have been made here.

The Theory PA
In this section we develop a version of PA, namely PA .For that, we will present some useful results.
Theorem 2.1.The schema Inst. 1 (∀x.ϕ)→ ϕ x t , where t is substitutable for x in ϕ has the same instances as the two following schemata considered together: Inst. 2 (∀x.ϕ) → ϕ x t , where t is substitutable for x in ϕ and x does not occur in t; Inst. 3 (∀x.ϕy x ) → ϕ y t , where t is substitutable for y in ϕ, x does not occur free in ϕ, the variable y does not occur free under the scope of a ∀x quantifier in ϕ, the variable y is not the variable x, and y does not occur in t.

Proof. Let us analyse the following cases:
Inst. 2 =⇒ Inst. 1 This is immediate, since all instances of Inst. 2 are directly instances of Inst. 1. Inst. 3 =⇒ Inst. 1 Suppose that one is given μ := (∀x.ϕ y x ) → ϕ y t , where t is substitutable for y in ϕ, x does not occur free in ϕ, the variable y does not occur free under the scope of a ∀x quantifier in ϕ, the variable y is not the variable x, and y does not occur in t.Take ξ := ϕ y x .Consider the two following situations: y does not occur free in ϕ For this case, ξ = ϕ y x = ϕ = ϕ y t .As x does not occur free in ϕ, we conclude that ξ x t = ξ and t is substitutable for x in ϕ, thus t is substitutable for x in ξ.Consequently, μ = ((∀x.ϕy x ) → ϕ y t ) = ((∀x.ξ)→ ξ) = ((∀x.ξ)→ ξ x t ), so μ is an instance of Inst. 1. y occurs free in ϕ Suppose, aiming a contradiction, that t is not substitutable for x in ξ = ϕ y x .Then, x occurs free in ξ and there is a variable z in t which is captured by a quantifier ∀z in ξ x t .As x do not occur free in ϕ by hypothesis, this means that there is a variable z in t which is captured by a quantifier ∀z in ϕ y t ; which contradicts the fact that t is substitutable for y in ϕ.So, t is substitutable for x in ξ.As the variable y does not occur free under the scope of a ∀x quantifier and x does not occur free in ϕ, we conclude that ξ x t = (ϕ y x ) x t = ϕ y t .Hence, μ = ((∀x.ϕy x ) → ϕ y t ) = ((∀x.ξ)→ ξ x t ), and so μ is an instance of Inst. 1. Inst. 1 =⇒ Inst.2,Inst.3 Consider μ := (∀x.ϕ) → ϕ x t , where t is substitutable for x in ϕ.Consider the following cases: x does not occur in t In this case, μ is an immediate instance of Inst. 2.
x occurs in t Take χ := ϕ x y , where y is a fresh variable not occurring in ϕ (not even in the quantifiers of ϕ) and in t.Clearly, the variable y does not occur free under the scope of a ∀x quantifier in χ.As t is substitutable for x in ϕ and y does not occur in ϕ, it follows that t is substitutable for y in χ.Furthermore, x does not occur free in χ.It is clear that χ y x = ϕ.As y does not appear in ϕ (not even in quantifiers of ϕ) and all free occurrences of x in ϕ are being replaced by y in χ, we have that χ y t = ϕ x y y t = ϕ x t .Thus, ((∀x.χy x ) → χ y t ) = ((∀x.ϕ)→ ϕ x t ) = μ , and so μ is an instance of Inst. 3. The result follows by the previous case analysis.

Theorem 2.2. The following schemata have the same instances:
Ind. 1 ϕ y 0 ∧∀x.(ϕy x → ϕ y S(x) ) → ∀x.ϕ y x , where y is free in ϕ and x is substitutable for y in ϕ; Ind. 2 ϕ y 0 ∧∀x.(ϕy x → ϕ x S(x) ) → ∀x.ϕ y x , where y is free in ϕ, the variable x is not the variable y, and x is substitutable for y in ϕ.
Take y a fresh variable not occurring in ϕ (not even in quantifiers) and ψ := ϕ x y .As x is free in ϕ and y does not appear at all in ϕ, it follows that y is free in ψ.As x is free in ϕ, we conclude that x is substitutable for y in ψ.Furthermore, as y does not occur at all in ϕ, ψ y x = ϕ x y y x = ϕ, ψ y 0 = ϕ x y y 0 = ϕ x 0 , and ψ y S(x) = ϕ x y y S(x) = ϕ x S(x) .Therefore, we have By the previous result, we know that the decidability of PA ksteps reduces to the decidability of PA ksteps .We will consider the axioms Inst. 2 and Inst.3, and Ind. 2-they have the nice syntactical feature that in the replacements one cannot have a variable being substituted by a term where that very variable occurs.We are considering the number of steps as being the number of rules that are being applied-here one could also consider the number of proof lines, the results that we are going to present can be adapted for that situation.

Main Results
We were inspired by Parikh systems (see, for instance, [6]) for the systems that we have developed, but we use very similar terminology to the one used in [6] with very different meanings (the reader should always have this in mind).The biggest difference between our approach and the approach followed in [6] is that we have developed a general way to obtain the provable formulas via schemata and in the latter the authors' focus in schemata occurs mainly in the axioms (they do not extend that notion to the provable formulas as we do).In that paper, it was developed a technique to study the decidability of k-provability for some theories using unification.We will develop a new technique that depends on a different way to unify-we create a technique to unify some of the schemata that generate the provable formulas.

Provable Schemata
The general idea of our approach is to attach a meaning to the combinatorial nature of general proof structures, namely to the different ways to combine, in a given number of steps, the axioms of the considered theory.Let us see, as an example, the general structure that corresponds to the following arrangement of the axioms: MP . This means that one firstly applies MP to an L1) implication using an L2) axiom, and to the result of that, which must be an implication, one applies an axiom of the form L2). Starting from the first application, to apply to the left side of (ϕ Hence, the application of the first MP yields something of the form (ϕ → ψ) → (ϕ → ϕ).Now, to apply L2) to (ϕ → ψ) → (ϕ → ϕ), one needs ψ = ξ → ϕ.In this conditions, the general shape/structure of MP( Clearly, any other way to arrange the axioms in the considered shape is a particular case of ϕ → ϕ.Moreover, ϕ → ϕ codifies, in a unique schema, all the ways to combine the axioms in MP([L)], MP([L)], [L)])).A similar analysis could be carried out for (some of) the other combinations of axioms, resulting in a finite list of schemata that generate, via substitutions, all instances of the other schemata that are obtainable in a given number of steps, k (this only works for some values of k due to undecidability issues).Hence, for some values of k, there are finitely many provable schemata that give rise to the formulas that are provable in k steps.It is important to observe that the previous idea does not work for all proof-skeletons (see theorem 5.1 from [8], and theorem 14.1 from [10, p.103]).Now we move to formalise the previous ideas.Having in mind what was previously observed, the general shape of a schema is nothing but F [ϕ 0 , . . ., ϕ n0 , t 0 , . . ., t n1 , v 0 , . . ., v n2 ]&C, where ϕ 0 , . . ., ϕ n0 stand for formulavariables, where t 0 , . . ., t n1 stand for term-variables, and where v 0 , . . ., v n2 stand for variable-variables; F stands for the arrangement of the logical symbols; and C stands for a condition on the variables, on the formulas, and on the terms.All the variables in the previous schema are exactly that, variables, they do not stand for actual entities; for instance, the formula-variables do not stand for actual formulas.Let us see two examples: has formula-variables, and where there are no conditions; • 'ϕ x 0 ∧ ∀y.(ϕ x y → ϕ x S(y) ) → ∀y.ϕ x y , where y is free in ϕ, the variable x is not the variable y, and x is substitutable for y in ϕ' is a schema where F [ϕ, x] := ϕ x 0 ∧ ∀y.(ϕ x y → ϕ x S(y) ) → ∀y.ϕ x y , and C :='y is free in ϕ, the variable x is not the variable y, and x is substitutable for y in ϕ'.
Let us fix throughout the rest of the paper: C 0 (ϕ, x) :='x is free in ϕ', C 1 (ϕ, x) :='x is not free in ϕ', C 2 (ϕ, t, x) :='t is substitutable for x in ϕ', C 3 (t, x) :='x does not occur in t', and C 4 (x, y) :='the variable x is different from the variable y', C 5 (ϕ, x, y) := 'the variable y does not occur free under the scope of a ∀x quantifier in ϕ', C 6 (ϕ, x) := 'x occurs in ϕ', C 7 (ϕ, x) :='x does not occur free in ϕ', and C 8 (ϕ, x, y) :='there is a a free occurrence of the variable y in ϕ that does not occur under the scope of a ∀x quantifier'.Observe that all the previous conditions are decidable.We will assume that T is a (fixed) theory of arithmetic that extends the presented version of PA by adding schemata that depend on formulas, terms, and variables, without having any conditions on the schemata.We now move to define formally what a proof-skeleton is.

Definition 3.1. We define inductively the notion of proof-skeleton:
Basis case A i is a proof-skeleton if A i is the number of an axiom of T ; Induction step If S 0 and S 1 are proof-skeleton, then MP(S 0 , S 1 ) and Gen(S 0 ) are proof-skeleton.We say that a proof-skeleton S has k steps if it has k applications of rules (k might be 0).Now we define the notion of a schema.Definition 3.2.We define inductively the notion of term-structure: Basis case Every variable-variable, every term-variable, and 0 are a term-structure.Induction step If r and s are term-structures, then S(r), r + s, r × s, and s x t , where x are variable-variables and t are termstructures, are also term-structures.We define inductively the notion of formula-structure: Basis case Every formula-variable is a formula-structure.Furthermore, r = s is a formula-structure, with r and s termstructures.Induction step If F and G are formula-structure, then the following are formula-structures: , where v are variable-variables, and t are a term-structure.We say that F is a sub-formula-structure of G if F is a formula-structure that occurs in G.We say that A is an atom if A is a formula-variable, or if A = ϕ x0...x t0...t , where ϕ is either a formula-variable or a formula-structure of the form r = s, with r and s term-structures.We say that an expression of the form or of the form is a schema, where I and J i are sets of indices (possibly empty, in which case we omit the conditions), F [ϕ 0 , . . ., ϕ n0 , t 0 , . . ., t n1 , v 0 , . . ., v n2 ] is a formulastructure, and A i are atoms.Here C k 1 j stand for a (syntactical) representation of the condition in the theory T previously mentioned (we also allow formulastructures to occur inside the conditions, but this will be avoided using several conventions).We allow term-structures to occur inside the conditions.
Every axiom of PA is a schema.Furthermore, every axiom of T is a schema.Convention 3.3.In every occurrence of ϕ x s or t x s in schemata, we do not allow the variables that are being changed to occur in the replacing term.Furthermore, we do not allow a variable to occur in a replacement being mapped to different terms and we do not allow repeated occurrences of the same change in the replacement (for instance t x x s s ).
It is important to stress that schemata are syntactical objects, even the conditions in them are syntactical (that have a semantical interpretation).The symbols ∼, , and & are syntactical representations of the connectives in the meta-language (negation, disjunction, and conjunction, respectively).
x t = ¬ϕ x t , and (∀y.ϕ) x t = ∀y.ϕ,x = y ∀y.ϕ x t , x = y, hold for all formulas, we will assume these identities for schemata.This means that in a schema one can move all occurrences of (•) x t inside the formulastructure.
With the conventions that we are going to present, we will extend the syntactical equality (and we will continue to denote it simply by '=').Sometimes to emphasise that E 0 = E 1 syntactically we will say that 'E 0 is E 1 ' (we will also use it to express that E 0 and E 1 are syntactically the same after some suitable substitution).Convention 3.5.We assume the following identities: , where f : {0, . . ., n} → {0, . . ., n} is a bijection (this feature is not troublesome because we are interpreting the replacements as simultaneous replacements that satisfy convention 3.3).
• The usual properties of replacements, for example: ). • The usual identities for propositional (meta-)logic, for example: - where C and C are conditions), and so on.
It is important to observe that in all the conditions one can arrange the formula-structures in such a way that inside the conditions one has only atoms (this will follow from the conventions that we are going to make, when considered together).Convention 3.6.Whenever we are considering, at the same time, different schemata, we will implicitly assume that they do not have common variables (this is just a useful technical feature that does not have any conceptual reason).Definition 3.7.A substitution σ is a function that assigns: formula-variables to formula-structures, term-variables to term-structures, and variable-variables to variable-variables.
It is important to observe that if one applies a substitution σ to a schema one might be increasing the number of term-variables and variable-variables.Definition 3.8.We define inductively the provable schemata by: Basis case Every schema that is an axiom is a provable schema; are provable schemata and there is σ such that is also a provable schema.C is a possibly added condition that arises from conventions, for instance from convention 3.4 by adding C 4 conditions.A provable schema S is provable in k steps if in the construction of S as a provable schema were used, at most, k steps (we do not count the application of conventions as steps nor the axiom case as a step).A provable schema that is an axiom has skeleton equal to the number of the axiom; if a provable schema S has skeleton S, then the corresponding provable schema obtained using the universal rule, ∀v.S, has skeleton Gen(S); if S 0 and S 1 are provable schemata that have skeletons S 0 and S 1 , respectively, and S is a schemata obtained using the MP construction from S 0 and S 1 , then S has skeleton MP(S 0 , S 1 ).Convention 3.9.The equality in the previous definition should be read as follows: there is a substitution σ such that, after applying the conventions to both formula-structures considered in the definition, one gets syntactical equality.For each way of applying the conventions and for a fixed substitution one might get new provable schemata (for each way one gets a new provable schema).Thus, a schema is provable if there are a substitution and several applications of the conventions that make the conditions of the definition (in particular the equality) hold.In practice, convention 3.4 will be applied in the following way: in a schema, either one has the same variable occurring in a quantifier and in a replacement, and then one eliminates the replacement; or one proceeds as the convention suggests and one adds a condition C 4 to differentiate the variables.This is assumed, for instance, in the provable schemata by considering both situations after the application of σ (this information then goes to the condition C).We will make the same assumption for the other conventions that we are going to establish.Whenever we consider a schema in the previous conditions, we are, in fact, considering all the schemata that are obtained using the previous procedure.In practice, we also allow that in the previous definition more conditions are added.Furthermore, we will use the notion of the previous definition where σ represents the application of several substitutions and conventions.
We now pause to give some examples.Clearly, (ϕ → (ψ → μ)) → ((ϕ → ψ) → (ϕ → μ)) is a provable schema, since it is an axiom.We also have that (ϕ → ψ) → (ϕ → ϕ) is a provable schema, since it can be obtained from the schemata (ϕ → (ψ → μ)) → ((ϕ → ψ) → (ϕ → μ)) and ϕ → (ψ → ϕ) (by considering the substitution such that σ(ϕ) := ϕ, σ(ψ) := ψ, and σ(μ) := ϕ).Moreover, for the same reason, (ϕ → ϕ) → (ϕ → ϕ) (by considering the substitution such that σ(ϕ) := ϕ, σ(ψ) := ϕ, and σ(μ) := ϕ) is a provable schema.It is a good exercise to check that ϕ → ϕ is a provable schema.Definition 3.10.We say that Σ is a concrete-substitution for the schema if Σ assigns formula-variables to actual formulas, term-variables to actual terms, and variable-variables to actual variables, in such a way that is a true condition and such that, in any occurrence of with G a term-structure or a formula-structure), no Σ(y i ) occurs in any Σ(s j ), and there are no Σ(y i ) with different attributions.It also needs to be the case that in every occurrence of G y0•••yn s0•••sn in the schema, each Σ(s i ) is substitutable for Σ(y i ) in Σ(G) and that no Σ(y i ) is Σ(y j ) with i = j (there are no repetitions of the same change).For a schema S, we use the notation Σ(S) to denote the result of performing the substitution Σ in the schema S whenever the substitution satisfies the definition.
To respect the previous definition, when one applies convention 3.4, one should add the condition C 7 (∀y.ϕ,x) C 3 (t, y) in the context of provable schemata.
Convention 3.11.We assume that t x s y r = t x y s r , and the analogue identity for formula-structures, if there are no other occurrences of the basis of the replacement, t, in the schema that is being considered (here we are assuming that no x is a y, the suitable changes should be applied for the other case and the respective conditions should be added in the presence of provable schemata).This offers no problem with the concrete-substitution interpretation because if one has a concrete-substitution that satisfies the left-hand-side of the equation, one can construct a concrete-substitution that satisfies the right-hand-side and vice-versa.For example, if we had (t x s ) y r with Σ(x) := x 0 , Σ(s) := S(x 1 ), Σ(y) := x 1 , Σ(r) := x 2 , then by considering a concrete-substitution Σ such that Σ (t) := Σ(t), Σ (x) := x 0 , Σ (y) := x 1 , Σ (s) := S(x 2 ), and Σ (r This means that if there is a concrete-substitution of one member of the equality, then there is a concrete-substitution for the other member.This identity will hold only if none of the x occurs in r (one should add the suitable condition to express this fact).
Observe that one could also have in a schema, besides the considered term-structure, the term-structures (t x z ) z s and t y r .In that type of situations, we take x a totally fresh variable (i.e.not occurring at all) and the first termstructure is replaced by t x z ss and the second is replaced by t y x r x (the same for formula-structures), assuming that z is not x (one should add add the suitable conditions for that).
More generally, t x r y s is replaced by (t ) x y r y s s , with x all fresh and t , and in the other occurrences of t where x are not being changed (one should do a case analysis for this using conditions C 4 and one should add the fact that, for the new t, x does not occur in t), one places (t ) x x and one proceeds in a similar fashion for the other cases; in the previous situation we need to assume that none x occurs in y, one should also consider the case where some of the x are y and add the suitable conditions in the presence of provable schemata, which simplifies the analysis.
We assume this convention also for formula-structures.More precisely, ϕ x r y s is replaced by (ϕ ) x y r y s s , with x all fresh and ϕ fresh, and in the other occurrences of ϕ where x are not being changed, one places (ϕ ) x x ; for the previous replacement to work we need, in the context of provable schemata, to add to the conditions: x is free in ϕ, x is substitutable for x in ϕ, r is substitutable for x in ϕ, and x is not free in ϕ (the justification for all this procedure is that one needs these conditions for the previous reasoning for terms to be applied for formulas, namely to be able, in the presence of a concrete-substitutions, to go back from the image of the replaced formula-structure to the image of the initial one).This means that, without loss of generality, we will assume that in the schemata all these reductions were already applied-in practice, this means that several case analyses ought to be done.As our interpretation of the schemata is obtained via concrete-substitutions, we do not have a problem, since everything fits the definition.Convention 3.12.In every occurrence of x y t in a provable schemata, one should consider the cases where x is the same as y, that entails x y t = t, and the case opposite case, that entails x y t = x.These situations will give rise to several provable schemata that are originated from a single syntactical expression.For each situation, we should add accordingly the conditions C 4 or ∼ C 4 (c.f.convention 3.9).Lemma 3.13.Consider formulas ϕ and ψ, and schemata If there are concrete-substitutions Σ 0 and Σ 1 such that Σ 0 (S 0 ) = ϕ and Σ 1 (S 1 ) = ϕ → ψ, then there are a substitution σ such that )] and a concrete-substitution Σ such that Σ(S 2 ) = ψ, where Proof.By hypothesis, Σ 0 (S 0 ) = ϕ and Σ 1 (S 1 ) = ϕ → ψ.This means that there are concrete (and not variable) formulas ϕ 0 0 , . . ., ϕ 0 n0 , ϕ 1 0 , . . ., ϕ 1 n2 , concrete terms t 0 0 , . . ., t 0 n1 , t 1 0 , . . ., t 1 n3 , and concrete variables v 0 obeying the semantical translation of the syntactical conditions such that Hence, the outer layout of implication signs, negation signs, universal quantifier signs, and parenthesis in S 0 and in S 1 can be made the same.For instance, the formula-structures ϕ → (ψ → ϕ) and ϕ → ((ϕ → ϕ) → ϕ) can have the same outer layout of signs, but ϕ → ϕ and (ϕ → ϕ) → ϕ cannotwe use this expression to say that they have a common outer structure of parenthesis, implication signs, negation signs, and universal quantifier sings (we will mention it as simply the layout).A layout is nothing but a sequence of symbols: parenthesis, implication signs, negation sings, and universal quantifier signs.For example, (∀()) → (¬() → ()) is a layout.We will say that a layout L is a sub-layout of L if L is a subsequence of L .We call entry to the content of a layout inside implications such that they do not contain further implications.
It is not hard to see that there are substitution σ 0 and σ 1 , and concretesubstitutions Σ 0 and Σ 1 , such that the layout of σ 0 (F ) and σ 1 (G) is the same as the layout of ϕ and Σ 0 (σ 0 (S 0 )) = ϕ and Σ 1 (σ 0 (S 1 )) = ϕ → ψ.It is enough for the procedure that we are going to describe that the layout is the same with possible exception of the entries in it because the entries are going to be accounted in the procedure per se.For example, consider the layouts (¬∀(¬())) → (() → (¬())) and () → (() → (¬())); although they are not the same, for the purposes of the procedure that we are going to develop the differences do not matter because they occur only at the level of the entries (this will be accounted for in the procedure); furthermore, when we are considering entries we always consider the biggest one, for instance, in the first layout, although (), ¬(), ∀(¬()), and ¬∀(¬()) are all entries of the layout that correspond to the same position, we will consider the biggest one, i.e. ¬∀(¬()).In all, without loss of generality, we may assume that F and G have the same layout.We assume that the changes of convention 3.11 were already made in such a way that one does not have compositions of replacements (from the information of the concrete-substitutions one can find the correct way to apply the convention).Using the concrete-substitutions, one can find the correct way to apply the convention 3.4 and add that information to a condition C, composed of several C 4 conditions.After this, one can still find concrete-substitutions such that Σ 0 (σ 0 (S 0 )) = ϕ and Σ 1 (σ 0 (S 1 )) = ϕ → ψ.
We do the following to construct a substitution σ and a concrete-substitution Σ (we are implicitly considering convention 3.6 and all the other conventions): 1.If x is a variable-variable that is mapped to Σ i (x), then x is assigned to a new fresh-variable, σ(x), and Σ(σ(x)) := Σ i (x).At this stage, one should also identify the variables that are mapped to the same concrete variables and distinguish the variables that are mapped to different variables using conditions C 4 and ∼ C 4 .2. One proceeds in a similar way with the term-variables.3. Starting from the first entry of the (common) layout, if the content of any of the entries is a formula-variable, then one assigns that formulavariable to the content of the other entry and moves to the next entry (in the end we might need to make some adjustments to this step).4. Suppose now that the contents of both entries are not formula-variables.
4.1.Suppose that the contents are , in S 0 , and , where ϕ i and ϕ j are formula-variables (here X i 0 • • • X i i are arrays of quantifiers and negation symbols).4.1.1.It might be needed to make a substitution in order to 0 = 1 (for the case where one has all the layout equal with possible exception of the entries in it).If 0 < 1 , this is achieved by , with ϕ fresh (it is possible that it is necessary to make adjustments to the variables occurring in the quantifiers so that none of them is v 0 0 • • • v 0 n and to add the suitable conditions).Using σ, one unifies the variables occurring in the same place in the quantifiers (their value is already fixed by stage 1).4.1.2.One then assigns for each component in the entry the corresponding image through the concrete-substitution, with the difference that the occurrences of actual variables in the formulas are replaced by occurrences of variable-variables.One does the same for the variables and term-structures in the replacements.4.1.3.Define the concrete-substitution accordingly.4.1.4.Move to the next entry.4.2.Suppose that the contents are , in S 0 , and , where r 0 , r 1 , s 0 , s 1 are term-structures.4.2.1.One proceeds as in 4.1 for the quantifier variables.4.2.2.We can perform substitutions to both entries in such a way that they become exactly equal to the content of the actual formula, but with the difference that actual variables in the formula are represented by variable-variables (the same idea that was applied before).For example, if the contents are x + t = y and t = t , and they are both mapped using the concretesubstitutions to x + (z + S(0)) = 0, then one considers σ(t) := z + S(0), with z a variable-variable, σ(t ) := x + (z + S(0)), and σ(t ) := 0. 4.2.3.One does the suitable adaptions for the replacements.For instance, if the content of an entry is t x s = S(x) + 0 and the concrete-substitution is defined for the entry by Σ i (t) := Σ(x) × (0 + x 0 ) and Σ i (s) := x 3 × S(0); then one defines for this entry σ(t) := σ(x)×(0+y), and σ(s) := z ×S(0), entailing that Observe that one might need to add several C 4 conditions.4.2.4.Define accordingly the concrete-substitution for this situation by assigning the variable-variables to the corresponding concrete variables.4.2.5.One can perform substitutions in such a way that the termstructures that appear are equal to their image through the concrete substitution where the occurrence of variables in the actual formula is replaced by an occurrence of variable-variables in the term-structures, as described before (all this can be done because we have the guarantee of the existence of the concretesubstitutions).4.2.6.Define the concrete-substitution for this case by assigning the variable-variables to the actual variables that they represent accordingly.4.2.7.With the previous construction, in particular we have 4.2.8.If any variable-variable or term-variable is already assigned, make the suitable adaptations (this is always possible and reduces to a case analysis).4.2.9.Move to the next entry.

If the content of one entry is X
, one proceeds in a similar way by attributing, via σ, the formula-variable ϕ k in such a way that in the end of the substitution one is left with a version of the actual formula where variables are replaced by variablevariables.4.4.Move to the next entry.5. Make the suitable changes in all the variables in order to have It is not hard to see that the constructed concrete-substitution obeys the conditions of the considered schemata and the added ones (while applying the conventions in a suitable way).
We could have presented a shorter proof of the previous results, but we decided to exhibit this one because it contains important ideas that are going to be used in several contexts.We can now prove that, using concretesubstitutions, k-provability of formulas is, in a sense, the same as k-provability of schemata.
Theorem 3.14.The two following statements are equivalent: C1 T ksteps ϕ; C2 There are S a provable schema in k steps and a concrete-substitution Σ such that Σ(S) = ϕ.
Proof.By definition of provable schema in k steps, we have that C2 implies C1 (this can be more formally proven by induction on k).
Let us prove that C1 implies C2 by induction on k, the number of steps.Clearly, if ϕ is an axiom, then there are an axiom schema S and a concretesubstitution Σ such that Σ(S) = ϕ.Suppose, by induction hypothesis, that the result holds for k.Furthermore, assume that T k+1steps ϕ.In the last steps of a proof of ϕ we either apply the rule MP or the rule Gen: MP In this case, there is a formula ψ such that T k0 steps ψ → ϕ and T k1steps ψ, with k = k 0 +k 1 .By induction hypothesis, there are schemata satisfying the conditions of lemma 3.13.By the lemma, it follows that there is a provable schema H and a concrete-substitution Σ such that Σ(H) = ϕ.As each of the schemata used in the lemma is, by induction hypothesis, provable in k 0 and k 1 steps (respectively), it follows that H is a schema provable in k + 1 steps.Gen In this case, ϕ is of the form ∀x.ψ.By hypothesis, T ksteps ψ.So, by induction hypothesis, there are a provable schema in k steps, H, and a concrete-substitution Σ such that Σ(H) = ψ.Consider the provable schema in k + 1 steps obtained from H via the universal schema from definition 3.8, let us call it H . Clearly, one can make the suitable changes in such a way that Σ(H ) = ∀x.ψ= ϕ.The result follows by induction.Lemma 3.15.Consider a formula ϕ, and schemata S 0 and S 1 .Suppose that there are a concrete-substitution Σ and a substitution σ (that might include the application of several substitutions and conventions) such that Σ(S 0 ) = ϕ and σ(S 1 ) = S 0 .Then, there is a concrete-substitution Σ such that Σ (S 1 ) = ϕ.
Proof.It is not hard to see that this follows from the considered definitions and from the fact that all the conventions are compatible with the concretesubstitution interpretation.

Decidability of Schemata
The next result has a similar content to proposition 2.2 from [6].Lemma 3.16.Given a condition of the form &i∈I is true; furthermore, witnesses can be found in affirmative case.The result still holds if the image of certain meta-variables are a priori fixed under a concrete-substitution.
Proof.The following idea is a procedure for the case where all the atoms that are not fixed are formula-variables and where the term-variables that are not fixed occur without replacements: 1. Start by considering enough variables to satisfy the occurrences of the conditions C 4 and ∼ C 4 .2. Then, consider every formula as being equal to 0 = 0 and every term as being equal to 0. 3.After that, focus on C 0 conditions.For every occurrence of C 0 (ϕ, x), make the attribution ϕ := (ϕ is not yet free in ϕ).Proceed in a similar way to ∼ C 7 (for this condition we just need one free occurrence).
For the occurrences of C 1 (ϕ, x) make ϕ := (ϕ ∧ ∀x.x = x), in particular if ∼ C 7 (ϕ, x) and also C 1 (ϕ, x), then attribute instead ϕ := (ϕ ∧ x = x) ∧ (∀x.x = x).4. Similarly for ∼ C 3 , for every occurrence of ∼ C 3 (t, x), consider t := (t+x). 5.Each time ∼ C 2 (ϕ, t, x) occurs, (one should always compare what one is doing here with the C 5 and C 2 conditions for the same formula-variables and variable-variables) consider y a fresh variable, and attribute t := (t + y) and ϕ := (ϕ ∧ ∀y.x = 0).6.For each occurrence of ∼ C 5 (ϕ, x, y), take ϕ := (ϕ ∧ ∀x.y = 0).For C 8 (ϕ, x, y) we might need to consider ϕ := (ϕ ∧ y = 0), in particular if ∼ C 5 (ϕ, x, y) and C 8 (ϕ, x, y) occur, then attribute ϕ := ((ϕ ∧ ∀x.y = 0) ∧ y = 0).If ∼ C 8 (ϕ, x, y) occurs, one should consider two cases: 6.1.y does not occur free in ϕ, i.e.C 7 (ϕ, y); 6.2.Or ∼ C 7 (ϕ, y) and in all free occurrences of y in ϕ they occur under the scope of a ∀x quantifier.For this situation one acts in a similar way to the one described for ∼ C 5 (ϕ, x, y) in all free occurrences of y (one places ∀x in all free occurrences of y in ϕ).If any variable, term, or formula is already fixed, the previous analyses remain valid (some adaptations are needed, for instance in the beginning of the algorithm)-this simplifies the algorithm to a case analysis.Furthermore, it is not hard to adapt it for replacements and for more complex term-structures (see the identities below).Suppose now that we have atoms of the form (r = s) x t .Then, we do the following: 1.We start by listing all the possible ways to apply the x to r = s, i.e. all the ways to apply the replacements (including the way in which the variables x do not occur in r = s).Each possibility will give rise to a separate analysis.2. We proceed as in step 1 until no further replacements are applicable to term-structures.3.In the previous step, one is left with several occurrences of t y t .4. One proceeds in a way similar to the previous algorithm (if possible, i.e. if no contradiction was reached).Observe that such an analysis is simplified, since, for instance, being free in the considered formula reduces to occurring in the formula (because there are no quantifiers).One can also adapt accordingly the idea of the initial procedure.One should also have in mind the following identities concerning t x s : • For C 2 , with z a totally fresh variable, The case where we have atoms of the form ϕ x t is a particular case of the previous analysis when one has in mind the following identities (that can be extended for more complex replacements): The result follows by this observation and the previous analysis (and by a version of disjunctive normal form for meta-connectives).
Theorem 3.17.Given a schema S and a formula ϕ, it is decidable whether there is a concrete-substitution Σ such that Σ(S) = ϕ.
Proof.Consider ϕ a formula and S a schema to which all the conventions were already applied.If the condition in S is a priori false, i.e. if using the rules of convention 3.5 one can obtain ⊥, then there is no concrete-substitution.Suppose now that S is of the form where the condition is not a priori false.It is not hard to see that one can computationally decide whether there is a substitution σ such that σ(F ) and ϕ have the same layout (the structure of parenthesis, implication signs, negation signs, and universal quantifier signs described before).The idea is the following: 1.If F and ϕ have different types, then reject (by different types we mean that, for instance, one is a negation and the other is an implication).2. If they have the same type, then one goes to the layout to the left of both outermost implication signs.
3. If the layout is the same, then one goes to the right and does the same move throughout the process.4. If one reaches an incompatibility-for example one implication sign versus one negation sign or universal quantification sign-one rejects. 5.One does the same for negations and universal quantifications.6.Using attributions to the formula-variables, one locally matches the layout of ϕ. 7. One proceeds by going to the inside the respective layouts until one reaches either a rejection or an equal layout (this procedure must eventually stop because the layout of the formula, just like the layout of a formulastructure, is finite).
In this briefly described way, one is not creating unnecessary changes in F , it is minimal in that sense.If F cannot be changed to have the same layout as ϕ, then there is no concrete-substitution (all this is decidable).Suppose that there is such a substitution σ that makes the layout the same.Consider σ in the mentioned minimal conditions, F := σ(F ), and S := σ(S).Assume that convention 3.11 was already applied to the schema, as well as convention 3.4 (this will yield a finite number of schemata to which one should do the analysis that follows).Having in mind that F and ϕ have the same layout, it is decidable whether there is Σ such that Σ(F ) = ϕ.The idea is the following: 1. Just like what was done in 4 of the proof of lemma 3.13, let us consider all the entries in the layout of ϕ (that is the same layout of F ). 2. Now, consider the finite list of variables occurring in ϕ under the scope of universal quantifiers and the finite list of terms occurring in ϕ.

One checks if there is any incompatibility between the array of quantifiers
and negation signs of each entry of F and of ϕ. 4. If there is, one rejects.5. Otherwise, one defines Σ for the variable-variables occurring in the quantifiers accordingly.6. Starting from the first entry and vanishing all entries, one takes for each entry (where the corresponding entry in the formula-structure has a replacement) the respective formula where the occurrences of some terms are replaced by fresh variables-ones should analyse all possibilities.Then, one checks if it is possible to assign formulas, terms, and variables to the entries of F in such a way that one obtains ϕ and they satisfy the (decidable) condition of the schema F .One does this for all entries.For single occurrences of term-variables without replacements, one simply assigns the corresponding term that occurs in the actual term.7.More precisely, one tests all possible substitutions by considering the formulas and the terms where the occurrences of some terms are replaced by fresh variables (one should vanish over all possibilities), one sees what the substituting term should look like, and one tests all the (finite number of) possibilities by making the fresh variables equal to some of the variables of the considered replacement.For each test one sees if the conditions of the schema are satisfied.For example, if one has the formula k-Provability in PA (x + 0) + z = y in the actual formula and the corresponding formulastructure (t 0 ) x0 s0 = x 1 in the schema, then one should assign x 1 to the variable y and, as in t 0 we are considering one replacement, one should consider the following possibilities for t 0 : • t 0 as being x 0 , with s 0 being (x + 0) + z; • t 0 as being (x + 0) + x 0 , where s 0 is z; • t 0 as being x 0 + z, where s 0 is x + 0; • t 0 as being (x 0 + 0) + z, with s 0 being x; • t 0 as being (x + x 0 ) + z, with s 0 being 0; • t 0 as being (x + 0) + z with x 0 not occurring in t 0 , where x 0 and s 0 are "arbitrary" in what t 0 is concerned; in practise this means that either they are assigned in the next entries, or they are to be considered as not assigned, which means that one has just to further study them if they appear in the conditions-see the proof of lemma 3.16 for a more detailed account.More generally, consider the case where a term-structure in the schema needs to be equal, under a concrete-substitution, to a certain term.Then, one needs to satisfy an equality similar to = ((S(x + y) + S(S(0))) + S(S(0) + (x × z))) × ((x × y) + 0).

This entails that
Thus, the image of t 2 under the concrete-substitution that one wants to construct is fixed, as well as the image of t 1 (if they were already fixed one should test if a contradiction is obtained).This means that, for the desired equality, it only remains to be analysed the equality Σ(t 0 ) Σ( s0) = (S(x+y)+S(S(0))).For this equality, one makes a (finite) case analysis as before by means of fresh variables (this will yield a similar analysis for the term-structures s 0 ).If Σ(t 0 ) is already assigned to, for instance, Σ(t 0 ) = S(Σ(x 0 ) + y) + S(Σ(x i )), then one substitutes the already attributed t 0 in the desired equality, namely (S(Σ(x 0 ) + y) + S(Σ(x i ))) = S(0); something that can, once again, be easily solved through a case analysis.Throughout the process one should add the suitable conditions on the variables.After that, one substitutes the new information about the variables and one sees if any contradiction is reached.8.We do the previous procedure for each entry of the layout and also for atoms-in fact, for formula-variables with replacements the fresh variables analysis remains valid: if one has ϕ x s , then one considers fresh termvariables t 0 and t 1 , one considers ϕ as being (t 0 = t 1 ), and one proceeds the analysis as before.For each case in the analysis of a given entry, one should consider all the sub-cases in the other entries for the choices that were made-this gives rise to a tree of possible cases; moving from one entry to another, either a new case analysis is created, or one reaches a contradiction, which, by its turn, forces the considered case in the already established case analysis to change (in particular this yields that the algorithm as a whole halts).One can computationally check if there are any incompatibilities at any stage; if any incompatibility is detected, one should consider another case in the analysis, if one reaches an incompatibility with all cases, it means that there is no concrete-substitution in the desired conditions.Observe that, for each entry, there is a finite number of ways to do the considered procedure, which entails that in the whole schema there is also a finite number of ways to consider all the possible cases.9.In the end of a case analysis, one should test to see whether the conditions of the schema are satisfied.This is achieved using lemma 3.16.One should also test if Σ can be made in such a way that satisfies the definition 3.10.10.If the previous steps are not possible, one should reject.
From lemma 3.15, if there is a concrete-substitution Σ such that Σ (S ) = ϕ, then there is a concrete substitution such that Σ(S) = ϕ.All the mentioned construction yields that one can decide whether there is a concrete-substitution Σ such that Σ(S) = ϕ.
It is important to observe that in the former algorithm it is not fundamental that the convention 3.11 is applied: if one has, for instance, the term-structure (t x r ) y s and one wants it to be equal to a certain term, then one proceeds by forcing T y s to be equal to that term using the considered analysis, and then one imposes Σ(t x r ) = Σ(T ) and makes a similar analysis for that fact; this means that if convention 3.11 was not applied, then one has to do several times the creation of the case analysis of stage 7 from the previous algorithm.We opted to firstly apply the convention because it simplifies the analysis and avoids having chained replacements.

Decidable of Some Proof-skeletons and k-Provability
As mentioned in the introduction, the decidability of k-provability for PA with the usual instantiation schema is an open problem and the proof-skeleton problem is in general undecidable for that version of PA.Nevertheless, we will characterise some values of k for which k-provability is decidable and some proof-skeletons for which the corresponding proof-skeleton problem is decidable.Definition 3.18.We say that a proof-skeleton S is stable (for T) if there is a finite list of provable-schemata L S such that: Stability A formula ϕ has a proof whose skeleton is S if, and only if, there are a schema S in L S and a concrete-substitution Σ that satisfy Σ(S) = ϕ.We say that a number k is stable (for T) if all proof-skeletons with length at most k are stable.
For stable proof-skeleton, the corresponding proof-skeleton problem is decidable, as the next result confirms.Theorem 3.19.If a proof-skeleton S is stable, then, for any formula ϕ, it is decidable whether ϕ has a proof whose skeleton is S.
Proof.By definition, ϕ has a proof whose skeleton is S if, and only if, there are a schema S in L S and a concrete-substitution Σ that satisfy Σ(S) = ϕ.The decidability follows from the fact that L S is finite and from theorem 3.17 (one tests computationally for each element of the finite list L S ).
If k is stable, then the respective k-provability is decidable, as the next result confirms.Theorem 3.20.If k is a stable number, then it is decidable whether T ksteps ϕ or not.
Proof.The result follows from the fact that for each k there is a finite number of proof-skeletons with length k and from theorem 3.19.

Theorem 3.21.
There is a maximum k stable number for PA .
Proof.Suppose that there is no maximum k stable number for PA .As the fact that k is a stable number implies that, for all s ≤ k, s is a stable number; it follows that all numbers are stable for PA .Thus, all proof-skeletons are stable.In particular, the proof-skeletons from the proof of theorem 6.1 from [6]-which is similar to the proof of 5.1 from [8]-are stable; from the previous theorem, it follows that it is decidable whether a formula has a proof whose skeleton is the skeletons from the proof of theorem 6.1 from [6], which contradicts that very theorem (when one adapts the proof to the theory PA ).
Although theorem 3.20 presents a characterisation of some proof-skeletons that have the respective proof-skeleton problem decidable, we have no information on how the lists were created; furthermore, so far we have no general way to generate (some of the) stable proof-skeletons.We now proceed to develop a general way to generate stable proof-skeletons.
From [8], we know that second-order unification is in general undecidable.In the proof presented in that paper, the main idea was to represent, inside the context of second-order unification, numerals, addition, and multiplication; something that is delivered by, c.f. [8], equations that include: In the previous equations, we followed the notation of the considered paper, where s denotes a unary function-symbol, • denotes a binary one, and σ 2 , σ 3 , τ term-variables.It is important to observe that, in the previous equations, one has in the two members of the equality sign occurrences of the same termvariable and occurrences of variables being replaced by something where that very variables occur.While this last feature can be avoided, using convention 3.11, the first feature will be something that we will not allow in the algorithms that we are going to develop; for example, S(t x0 x1 ) = t x0 S(x1) has an infinity of solutions, namely t = S n (x 0 ), that cannot be written in a closed form like t = E, where in E we do not have occurrences of natural numbers variables like S n (x 0 ).We will create an algorithm that will be able to solve some systems of the form where r 0 , . . ., r n , s 0 , . . ., s n are term-structures (we will assume that the equations in the left do not have common variables with the equations on the right): by a solution we mean a common substitution to the left and the right side such that one achieves the equality between them maybe after the application of several of the conventions (in fact, we might achieve the equality after the application of several substitutions and several conventions)-for each substitution there might be several ways to apply the conventions that yield several solutions.The main move that we are going to make is to avoid the mentioned occurrences of equal term-variables while the algorithm is running, this offers no problem since we will not develop a general algorithm and since the reasoning of [8] cannot be applied-we force the algorithm not to have the needed conditions for the proof, and thus avoid the undecidability; we do this with the cost that the algorithm will reject or not halt systems that indeed have a solution.
Algorithm 3.22.We will describe an algorithm that, for certain cases, sees whether there is a substitution σ such that where r 0 , . . ., r n , s 0 , . . ., s n are term-structures.Furthermore, such a σ can be found (for some cases) without the introduction of unnecessary complexity.Following convention 3.6, we assume that the r i 's and s j 's do not have common meta-variables.Furthermore, we assume that convention 3.11 was already applied.The algorithm is as follows: 1. Starting from i = 0, do the following to construct a list of equations: 1.1.If r i and s i are term-structures without term-variables, then see if it is possible to identify the variable-variables in such a way that σ(r i ) = σ(s i ) and add this fact to the list; if it is not possible, then reject.1.2.If r i or s i is of the form t x s , then add to the list of equations t x s = s i , when r i = t x s , and r i = t x s , for the other case.1.3.If r i and s i are both term-structures with an outermost occurrence of a function-symbol, then test whether the function-symbol is the same.1.4.If it is not, then reject.1.5.If r i = S(t 0 ) and r 1 = S(t 1 ), with t 0 and t 1 term-structures, then apply the previous procedure to t 0 and t 1 and add t 0 = t 1 to the list.Do the same for + and ×.This means that for each pair of terms r i and s i , one should see if If it occurs, then reject; and for each pair of terms r i and s i with r i = t 0 • t 1 and s i = t 2 • t 3 , do the previous procedure for t 0 with t 2 , and t 1 with t 3 , where • is + or ×, and add t 0 = t 2 and t 1 = t 3 to the list.1.6.Do the previous procedure until no further reductions are possible (this must stop after a finite number of steps).Thus, one should apply the procedure until one reaches either a rejection or has analysed all possible cases.1.7.Increment i until all the values for i were considered.2. Let us now assume that a list was build without reaching a rejecting state.3.As mentioned in 1.1, one has to make the suitable variable identification (for example using fresh variable-variables).For instance, if one has in the list an equation of the form where x and y occur in the same place of the layout of the functionsymbols, then one has to assign x and y to a new fresh common variablevariable.With this we get, we get the true equality If any of them was already assigned, assign all the variables previously assigned to this new common fresh variable.4. Proceed in a similar way with the occurrence of term-variables that do not occur under the scope of a replacement.This means that if one has an equation of the form = t, with t fresh, σ(t 1 ) = σ(y), and σ(t 3 ) = S(0).5. Let us now briefly describe the most complex case.6. Suppose we have in the list equations of the following form (observe that the analysis of the list can be reduced to the analysis of the next system), where we are implicitly considering in the left-side the r-part, and in the right-side the s-part: Do the following (the next procedure is a kind of co-recursion because one should apply the whole procedure to smaller parts of the very same procedure): 6.1.Firstly, substitute the already changed variable-variables and termvariables in the equations (one should do this step at every stage of the algorithm).6.2.If at any stage one obtains an equality where in both members one has an occurrence of t x s , one should output problem.6.3.If at any stage one obtains a non-trivial equality (i.e.not yet syntactically satisfied) where in both members one has an occurrence of the same term-variable one should output problem.6.4.Starting from i = 1 (up to n), solve, if possible, the first equation in the following way: 6.4.1 Consider the term-structure that corresponds to the right-side (respectively left-side) of the equation where some occurrences of term-structures in the considered equation were replaced by fresh variables (analyse all the finitely many possibilities for this).6.4.2Analyse all the possibilities to identify the fresh variables with the variables-variables σ( x 0 ) and see what the term-structures σ( s 0 ) ought to be-keep in mind that all the conventions ought to be satisfied (this fact can be verified in a decidable way).This idea was also used at stage 7 in the second procedure of the proof of theorem 3.17.If one has one of the variables σ( x 0 ) occurring in the opposite side, one should reject, since that is an impossibility.In the context of (provable) schemata, one should add condition C 4 for the variables that are being considered as being different throughout the procedure (the analogous situation for the other conventions).One should always substitute the already found solutions in the new equations.
6.4.3In σ( s 0 ) there might occur complex term-structure that would require an analysis similar to the one that we are considering (for example, s 0 could be t x t0+t1 ) and would yield a new system to be solved (to create the system we replicate the previous steps for the creation of the list and the fresh variables analysis).Without loss of generality, we might proceed our analysis because the algorithm will account for all the cases due to its co-recursive nature.We allow the occurrence of equations of the form (t 0 ) x0 s0 = ((x + y) × 0) + (S(t 1 ) + S(0)).6.4.4.For instance, in the case analysis of the previous stage, one might have One should consider the cases as in 7 in the second procedure of the proof of lemma 3.17 and as mentioned before.One of the cases is Then, for the previous equality, one should also carry a similar analysis.For example, σ(r) = σ(x 1 )+σ(y), with σ(s) = σ(x).In all, for the considered case, we get Observe that, in the previous analysis, we considered the variables as being different when the replacements are applied because they are fresh, they do not occur at all.Furthermore, observe that, for the considered case, σ(z) cannot be identified with σ(x 0 ) just like σ(x 1 ) cannot be identified with σ(y) (otherwise we would get a contradiction, in particular if we apply concrete-substitutions)-one should add the suitable conditions to express this fact.This means that the replacements that we are considering here act only on the fresh variables, without the possibility of overlapping the left with the right side, as mentioned.6.4.5.If a term-variable occurs in the other side of the equation, one should also consider, together with the fresh variables construction, the case where for that entry one places a fresh term-variable in the term-structure that one is creating.For example, if one has (t 0 ) x s = (S(0) + y) + t 1 , one of the cases that one should analyse is the case where σ(t 0 ) = (σ(x) + σ(y)) + t, with t fresh, which entails that σ(t 1 ) = t σ(x) σ(s) .This serves to cover the possibility, under the interpretation of the equality via concrete-substitutions, that the concrete term that results from t 1 was placed using the considered replacement to some other term in that very position in the function-symbols layout.6.4.6.Take note of the possible ones-the admissible possibilities form a tree, in the sense that for one case one might have to analyse a great variety of sub-cases.Unlike the proof of theorem 3.17 where the second algorithm only asks for a successful path in the tree, in this algorithm we want to study all admissible possibilities, since we want to find all the solutions to the system.6.4.7.If one reaches an impossibility in the case analysis one should reject that case and consider the other remaining cases.6.5.If, at any stage, there are no solutions, one should reject.6.6.Suppose that the system was solved, if possible, for i < n.Then, do the following: 6.6.1.Consider the (i + 1)th equation, say (t 0)).6.6.2.Substitute the already found term-structures and, if necessary, create new systems for the equalities that emerge.6.6.3.In particular, if t 5 was already found, then substitute it for the found solution, make a case analysis for the applications of the replacements, and solve the considered equation.If t 5 was not yet assigned, then solve the equation using the fresh variables analysis and with 6.2.5.6.6.4.Substitute in the previously obtained solutions the new ones and if necessary solve the new equations that emerge.7. Output all the found solutions.
We say that a system is successful if it halts and is not rejected as a whole (nevertheless we allow that in the case analysis some cases are rejected), and if in the case analysis no problem situation appeared.What we described is not a complete description of the algorithm, but it has the main ideas that are necessary to develop the much more complex and involved complete description of the algorithm.We considered particular cases in the algorithm to emphasise the main ideas.For instance, in the hard case that we presented-the one with a new system-, a more general approach is needed to write the complete algorithm.
Let us give an example of the some steps of the previous procedure.Suppose that one is given the system As the algorithm suggests, one should start by considering the first equation (the other cases should also be studied).One should consider all the sub-termstructures of (x × y) + t 1 and replace some occurrences by fresh variables, and then unify them, using substitutions, with x 0 or x 1 ; furthermore, one should proceed with the term-variables as described in 6.4.5.For example, for (x × y) + t 1 , one could consider, after the suitable unifications, t 0 as being (x 0 × x 1 ) + t, t 1 as being t x0 x1 s0 s1 , where t is fresh, s 0 as being x, and s 1 as being y.This constitutes a solution to the first equation.
Following the algorithm, then one should substitute the obtained solution in the second equation, giving ((x 0 × x 1 ) + t) So, after another case analysis, one of the cases is Hence, for this case, x 0 = x and x 3 is not x 3 , or x 0 = x 3 and s 3 = x; similarly for x 1 .Let us now focus in the second equation from the previous system.We proceed as before with a case analysis, one of the cases yields that t as being S(0); after that, one substitutes t in t 0 , yielding (x 0 × x 1 ) + S(0), and in t 1 , yielding S(0).Observe that in the considered cases no problem was identified (it is not hard to see that the previous system is successful).
In the end we get, if not all the cases are rejections and no problem was obtained, substitutions σ in the desired conditions.Furthermore, such substitutions are most general ones, in the sense that they do not introduce unnecessary complexity and unnecessary identifications (just like a most general unifier).Convention 3.23.We assume that A is a generic algorithm that solves some unification (of term-structures) problems (for example by a case analysis) and without the introduction of unnecessary complexity-i.e. has as output a finite number of most general unifiers in the sense that we used previously-, with some situations where it might output problem.We assume that A works in a very similar way to algorithm 3.22 (for instance, it might use a case analysis, it might use substitution of found solutions, it might use the creation of the systems, by considering all possible situation for the system, for some of them might output problem, etc).We will say that A is successful for a given system if it halts and no problem situations were identified during the computations, just like what was considered for the previous algorithm.We assume that A gives informations about the conditions needed for each step in the context of provable schemata (just like algorithm 3.22) and that has the following feature: and there are concrete-substitutions Σ 0 and Σ 1 such that then there are a solution σ of the system that is constructed by the algorithm A and a concrete-substitution Σ such that We also assume that the previous property is compatible with the conventions that the algorithm gives as additional information and that if t is a term-structure, then Σ(σ(t)) = Σ i (t), for i = 0, 1, depending on the concrete-substitution for which the value of t defined (this last condition is useful when one is dealing with provable schemata).
It is important to observe that algorithm 3.22 has the Sub.property: if the algorithm 3.22 is successful for a considered system and one is given concretesubstitutions as before, then, guided by the concrete-substitutions Σ 0 and Σ 1 , one can use the algorithm 3.22 to obtain a desired solution σ-here the concrete-substitutions can be used to identify the choices that one has to make while running the algorithm; moreover, the algorithm will be successful (by hypothesis); the existence of a concrete-substitution Σ with the mentioned properties follows from the fact that all the choices that were made for the construction of σ were guided by the concrete-substitutions Σ 0 and Σ 1 .
Observe that one can conceive several algorithm that satisfy the Sub.Property; for instance, one can extend algorithm 3.22 to account for other possibilities without outputting problem so often.For example, one could extend algorithm 3.22 by allowing situations where one has occurrences of replacements in the two sides of the equality, like under the proviso that no variable-variable in the replacement in the opposite side can be identified with a variable-variable that occurs in the considered replacement.Observe that x 1 is a variable-variable in the replacement that occurs in the opposite side of the considered replacement, but, under the concrete-substitution interpretation, it cannot be x 0 , since it occurs again in the right side, namely in (S(S(0)) + x 1 ).Then, one makes the usual fresh variable analysis, but, similarly to stage 6.4.5, one also accounts for the possibility of internal application of the replacement; in the considered example, this means that one of the cases to be considered is the one where t 0 is (x 0 + x 1 ) × t x1 s1 , with t fresh, s 0 is S(S(0)), and t ) by replacing the occurrences of s 0 that were placed using the replacement by x 0 , and the same for s 1 and x 1 .Then, t has x 0 and x 1 as variables.Furthermore, it follows that as desired.This justifies the described procedure that one can add to algorithm 3.22.Observe that in the justification it was used the fact that x 0 is not x 1 , otherwise the construction of t could fail; for example, for t 0 = S(S(x 0 )), s 0 = x, t 1 = S(x 1 ), and s 1 = S(x) one has that (t 0 ) x1 s1 , but one cannot construct t as before, since s 0 is being placed in the same place as s 1 .It is worth mentioning that the described impossibility is in the heart of the undecidability of second-order unification: keep in mind that, for example, S(t x0 x1 ) = t x0 S(x1) has an infinity of solutions, namely t = S n (x 0 ), that cannot be written in a closed form without using natural numbers, in fact a variation of this is used to represent the natural numbers inside the context of second-order unification in [8] (the idea of the proof of the undecidability is to represent natural numbers, addition, and multiplication inside second-order unification and apply Matijasevič's theorem).
We believe that algorithm 3.22 halts for every input, but we do not have a proof of that fact or a counter-example to it; the reason for this is that we believe that if a loop situation is reached using substitutions and replacements, then one must have an occurrence of the same term-variable in both sides of a given equation, something that is accounted for by the algorithm by just outputting problem.All this concern about the halting nature of algorithm 3.22 is not necessary for what we are going to develop because we want to account for other algorithms that might not halt on every input (that is why we assumed that the previous convention), thus the halting nature of algorithm 3.22 is a side discussion to our goal.
We move to create the desired lists that give a more concrete inside of theorem 3.19.List 3.24.We now proceed to create lists, for each k and each each algorithm A, of provable schemata, L A,k , and proof-skeletons, L A,k .

Basis case
The list L A,0 , for the case k = 0, is simply the (finite) list of axioms.The list L A,0 is the list of the numbers of the schemata that are axioms.
Inductive step Suppose that the lists L A,s and L A,s , with s ≤ k, where already created.Add all elements of L A,k to L A,k+1 , and all elements of L A,k to L A,k+1 .Consider the following cases: Gen If S is a schema in L A,k , then pick x a variable-variable not occurring in S and add ∀x.S to L A,k+1 -the respective schema obtained by placing a universal quantifier, just like in definition 3.8.If S is a proof-skeleton in L A,k , then add Gen(S) to L A,k+1 .MP Take k = k 0 + k 1 .Do the following: 1. Consider S 0 a schema in L A,k0 and S 1 a schema in L A,k1 .2. If S 1 is a universal quantification or a negation, then reject and consider another pair.3. Suppose that ), and ). 4. We now proceed to see whether F and G can be unified by means of a substitution σ using the algorithm A and the previously developed methods.We assume that the conventions were already applied to these schemata.5. Using the ideas of the previous proofs (with the suitable adaptations), it is not hard to see that one can test whether F and G have a common layout.6.If they do not have, then reject and consider another pair of schemata.7. If they have, find the common layout in such a way that unnecessary complexity is avoided (follow the ideas of the previous proofs).8. Starting from the first entry of the common layout, do the following: 8.1.Proceed with the quantifiers and negation signs as before (for instance, like in the proof of lemma 3.13).8.2.One should create a system for the cases where in both entries one has something of the form X 0 • • • X n r = s, with r and s termstructures.Act accordingly with the quantifiers and the negation signs.If it is not possible, then reject and consider another pair of proof-skeletons.8.3.One should run algorithm A (for example algorithm 3.22) for the needed equalities of term-structures that emerge.8.4.If A is not successful, then reject and consider another pair of schemata.8.5.Assume for the rest of the procedure that the algorithm A is successful.Take note of all solutions.8.6.Consider the case where one has in one entry Firstly, act accordingly with the quantifiers and negation signs (see, for example, 4.1.1 of the proof of lemma 3.13).If it is not possible, then reject and consider another pair of schemata.8.7.If any of the x 0 appears in r = s, then then reject and consider another pair of schemata.If ϕ 0 was already assigned to something of the form X 2 0 • • • X 2 2 r = s , then apply the considered replacement (this yields a case analysis).Apply the conventions and force it to be X 1 0 • • • X 1 1 r = s; this will give rise to another system that one should solve using algorithm A. If the system is not successful, then reject and consider another pair of schemata.If it is, save the solutions.If ϕ 0 was not yet assigned to such a structure, then consider ϕ 0 as being t = t , with t and t fresh term-variables.Run the algorithm A to solve the systems that emerge and proceed only in the case where the algorithm is successful (all the case analyses should include the suitable information about the conditions that are needed at each stage).8.8.One now considers all entries were ones has something of the form x0 s0 in both entries.8.9.We assume, due to our conventions, that in the considered case we do not have the same formula-variable occurring.Act accordingly with the quantifiers and the negation signs.If it is not possible, then reject and consider another pair of schemata.8.10.If both formula-variables were already assigned to something of the form X 0 • • • X 0 r = s, then apply the replacements, apply the conventions, and, for each case of the conventions, solve the obtained system in the previously mentioned ways.If any of the systems is not successful, reject and consider another pair of schemata.8.11.If only one of them was mapped to the mentioned structure, adapt step 8.6.8.12.Suppose now that non of the formula-variables was assigned.Then, one should unify them like what was done for the case of algorithm 3.22 for term-variables.If one needs to satisfy an equality where in both members of the equality one has something of the form ϕ x s , then reject and consider another pair of schemata; otherwise proceed as before by substituting the already attributed values.For example, if one has the equations ϕ 0 = ϕ 1 , ϕ 1 = ϕ 2 , then one assigns all those formula-variables to a common fresh formula-variable, say ϕ; if one has ϕ 0 = ϕ x s and ϕ 2 = ϕ 0 , then one assigns ϕ 2 to ϕ x s .8.13.Apply the previous steps to all entries.9.If we do not get a rejection for the considered schemata in the previous procedure, then apply to each of the final results the conventions and then add the all resulting provable schemata to the list L A,k+1 : where C are, possibly, the conditions that appear from the conventions and the solutions of the considered systems.10.Consider S 0 a proof-skeleton in L A,k0 and S 1 a proof-skeleton in L A,k1 .11.If for all schemata S 0 in L A,k0 with skeleton S 0 and S 1 in L A,k1 with skeleton S 1 , the previous procedure does not yield a rejection, then one should add MP(S 0 , S 1 ) to L A,k+1 ; if for any of them one rejects, then one should consider another pair of proof-skeletons and do the same move.
It is important to observe that the previous constructions does not contradict the undecidability of second-order unification problem (see, for instance, [8]): we are considering different types of terms, namely term-structures; we are considering a different type of substitutions σ; and in algorithm 3.22 we do not allow the occurrence of a term-variable in both sides of an equation, something that is indispensable in the proof of the undecidability of secondorder unification in [8].One should keep in mind that the algorithms that we are considering are all necessarily partial-they cannot solve successfully all systems.
Observe that for each k and A, the lists L k,A and L k,A are finite-this follows by construction, in particular from the fact that for each convention there is a finite number of ways to apply it, and from the fact that the systems that are successful have a finite number of (most general) solutions for the considered algorithm.Although we presented an inductive construction of the lists, they are not necessarily computable uniformly in k; nevertheless, for each fixed k, L A,k and L A,k are computable due to the fact that they are finite (and all finite lists are computable).The computable uniformity of the lists would entail that, for small values of k, one could, for the considered algorithm A, computationally decide if a given system is successful for A (a feature that fails for most algorithms).Definition 3.25.We say that a proof-skeleton S is grounded for A if S is in L A,k , where k is the number of steps of S. We say that k is a grounded number for A if all proof-skeleton whose number of steps is at most k are grounded for A. We will consider L A := ∪ k L A,k and L A := ∪ k L A,k .
If one makes some assumptions about the way the lists were generated-if one assumes that there is a general way to create them, if one assumes that in the construction one does not include unnecessary complexity, etc-, for most cases, the stable proof-skeletons are also grounded for some algorithm A.
The intuition behind grounded proof-skeletons is that, to such skeletons, one can apply the intuitive reasoning made in the beginning of section 3.1 Proof.Consider S a grounded proof-skeleton for A. Generate, using the previous procedures for the algorithm A, the schemata that have S as proofskeleton, let us call this finite list R.These obtained schemata are minimal in the sense that there was added no unnecessary complexity to the substitutions.Let us prove that ϕ has a proof whose skeleton is S if, and only if, there are a concrete-substitution Σ and S in R such that Σ(S) = ϕ.It is clear that if there are a concrete-substitution Σ and S in R such that Σ(R) = ϕ, then ϕ has a proof whose skeleton is S (this can be proved by induction on the definition of proof-skeleton).Let us prove the other direction.Suppose that ϕ has a proof whose skeleton is S.Then, by the previous theorem, there are a schema S with skeleton S, generated by the algorithms, and a concrete-substitution Σ such that Σ(S) = ϕ.Clearly S is in R, so desired result holds.
The decidability follows from the fact the the list R is finite and from theorem 3.17.
From the proof of the previous result we can conclude that every grounded skeleton is stable.Thus, every grounded number is stable.Theorem 3.28.For k a grounded number for A, T ksteps ϕ if, and only if, there are a schema S in L A,k and a concrete-substitution Σ such that Σ(S) = ϕ.
Proof.Clearly, if there is a schema S in L A,k and a concrete-substitution Σ such that Σ(S) = ϕ, then T ksteps ϕ(this follows by a simple induction argument).Let us prove the other direction by induction on k.It is clear that the result holds for k = 0, the axiom case.Suppose, by induction hypothesis, that the result holds for all s ≤ k.Suppose that k + 1 is a grounded number for A and consider ϕ such that T k+1steps ϕ.We have two cases: Last step uses Gen In this case, we have that ϕ = ∀x.ψand T ksteps ψ.It follows from the definition that k is a grounded number for A. By induction hypothesis, there are a schema S in L A,k and a concrete-substitution Σ such that Σ(S) = ψ.Consider ∀v.S the schema that is obtained from S by the generalisation rule.Clearly, ∀v.S is in L A,k+1 .Furthermore, we can extend Σ in such a way that Σ(∀v.S) = ∀x.ψ= ϕ.Last step uses MP In this case, there is a formula ψ such that T k0steps ψ and T k1steps ψ → ϕ, with k = k 0 + k 1 .It follows that k 0 and k 1 are grounded numbers for A. By induction hypothesis, there are schemata F in L A,k0 and G → H in L A,k1 , and concrete-substitutions Σ 0 and Σ 1 such that Σ 0 (F ) = ψ and Σ 1 (G → H) = ψ → ϕ.By the reasoning of the proof of theorem 3.26, we can guarantee the existence of a suitable substitution σ delivered by the algorithm such that σ(F ) = σ(G).As k + 1 is a grounded number for A, the algorithm must be successful and thus σ(H) is in L A,k+1 .As σ is minimal in the sense of introduction of unnecessary complexity and by the reasoning of the proof of theorem 3.26 (the fact that σ was chosen using the concrete-substitutions), there must be a concrete-substitution Σ such that Σ(σ(H)) = ϕ.The result follows by induction.One could also prove the result using the proof of corollary 3.27.Corollary 3.29.Given k a grounded number for A, it is decidable whether T ksteps ϕ or not.
Proof.One considers the finite list L A,k .By the previous result, it is enough to see whether there is a concrete-substitution Σ and S in L A,k such that Σ(S) = ϕ, something that is decidable from the fact that L A,k is finite and from theorem 3.17.This also follows from theorem 3.20.Corollary 3.30.Given k a grounded number for A in PA , it is decidable whether PA ksteps ϕ or not.
Proof.Follows from the previous result when one has in mind that PA is one of the considered theories.Corollary 3.31.Given k a grounded number for A in PA , it is decidable whether PA ksteps ϕ or not.
Proof.Follows from the previous corollary and theorem 2.4.Theorem 3.32.Given A, there is an infinity of schemata in L A .
Proof.It is not hard to see that all schemata that are constructed using only the propositional logic axioms, L1)-L3) in the initial list, are in L A .Furthermore, besides these propositional schemata, there are much more schemata in L A : the only restriction that ones has is that they do not yield the problem cases in their construction and the algorithm halts without rejecting.Theorem 3.33.Given an algorithm A, there is an algorithm H A such that, for every grounded proof-skeleton S and every formula ϕ, the algorithm halts and accepts for S and ϕ if, and only if, ϕ has a proof whose skeleton is S.
Proof.Fix an algorithm A. For a proof-skeleton S, the algorithm H A -using the construction of the schemata in L A -tries to generate all the provable schemata in L A whose skeleton is S. Observe that in the construction of the lists L A,k one needed to make assumptions about the successfulness of the algorithm A for certain systems, but in this algorithm we do not make those (possibly non-computable) assumptions; the rest of the process remains the same, but one only focus on the construction of the schemata that potentially have skeleton S.This yields no problem because the construction of the lists is computable with possible exception of the successfulness conditions.For nongrounded proof-skeletons (not in L A ) the algorithm might not halt.Suppose that S is a grounded proof-skeleton.Then, the algorithm H A can successfully construct the lists R from the proof of corollary 3.27.Thus, using theorem 3.17, the algorithm can decide whether ϕ has a proof whose skeleton is S.
Let PA be PA from before where the universal instantiation axiom is replaced by the schemata Inst. 2 and Inst.3, and where the induction axiom is replaced by Ind. 2.
Theorem 2.4.The two following statements are equivalent: 1. PA ksteps ϕ; 2. PA ksteps ϕ.Proof.From theorems 2.1 and 2.2, we know that the axioms in PA that are a replacement of the axioms of PA have exactly the same instances.So, in a proof of PA an occurrence of Inst. 1 can be replaced by an occurrence of Inst. 2 or Inst. 3 to obtain a proof in PA exactly with the same formulas, in particular with the same length.The same idea applies to substitutions of Ind. 1 in proofs of PA by Ind. 2 to obtain proofs in PA .Furthermore, Inst. 2 and Inst. 3 can be replaced by Inst. 1 in the same fashion, and Ind. 2 by Ind. 1.
7. Now test, for the considered attributions, if the occurrences of C 0 , C 1 , C 2 , C 3 , C 5 , ∼ C 6 , C 7 , C 8 , and ∼ C 8 are satisfied.In negative case (one should consider all possible situations), reject.8.If C 6 (ϕ, x) is in the expression, test if the condition is already satisfied for the considered attributions.If not, then take ϕ := (ϕ ∧ ∀x.x = 0) and test the conditions again.
1 is t x0 s0 .Let us briefly justify what was described.Let us suppose now that t 0 , t 1 , s 0 , and s 1 are concrete terms, and x 0 , x 1 concrete variables.Assume that x 0 is not x 1 and that where both variables are being replaced, i.e. x 0 occurs in t 0 and x 1 in t 1 .It is not hard to conclude that x 0 cannot occur in s 1 , just like x 1 cannot occur in s 0 .Consider t as being the term obtained from (t 0 )