• No se han encontrado resultados

CONTENIDOS Y PROCEDIMIENTOS EN LA EDUCACIÓN EMOCIONAL

DESARROLLO EMOCIONAL?

4.4. CONTENIDOS Y PROCEDIMIENTOS EN LA EDUCACIÓN EMOCIONAL

The algorithm presented so far is a bit conservative: when instantiating a meta-variable, in order to cope with problems outside the higher-order pattern fragment, it only at-tempts the first-order approximation heuristic. For this reason, as we saw in the previous section, many equations with “false dependencies” are rejected right away, without any further attempt to find, if not the most general solution, at least some solution. In the context of the Ssreflect library, we demonstrated that this conservative approach is acceptable, since only a few lines required changes to work with our algorithm. And, moreover, in those cases, it is arguable who’s to blame, if our algorithm for not finding a solution, or the tactics and the refiner for posing equations with such false dependencies.

However, we should not jump to conclusions: the Ssreflect library was conceived for a specific problem (verification of mathematical components), and with specific program-ming patterns, coherently shared among the whole set of files. Other libraries may have different programming patterns, therefore expecting different results from the unifica-tion algorithm. For this reason, we decided to compile the files from the book Certified

Programming with Dependent Types (CPDT) (Chlipala,2011a) , which provides several examples of functional programming with dependent types, in a radically different style from that of Ssreflect.

The result is rather discouraging: from the total of 6.200 lines, more than 60 lines (about 0.01%) require modifications. The problem is exacerbated if we consider that this library uses standard Coq tactics instead of Ssreflect’s ones. As mentioned in the introduction of the previous section, most of Coq’s original tactics use a different unification algorithm than the one we are replacing, so our algorithm is being called to solve fewer cases than when compiling Ssreflect.

We are left with two options: either we change the refiner and tactics to make sure that fewer equations get false dependencies, or we introduce a new rule to the algorithm to brutally chop off those dependencies, therefore cherry-picking one specific solution from the set of possible solutions. Since the first option is out of the scope of this work, we pursue the second one. In particular, we extend the algorithm with the rule shown below, which simply removes all elements in the suspended substitution σ of a meta-variable ?x that are not meta-variables, or that occurs more than once in the substitution.

Given a list of indices l, we note σl as the substitution obtained after filtering out those elements in σ whose indices are not in l. Similarly, we denote Ψl as the filtering of local context Ψ with respect to l.

?x : T [Ψ] ∈ Σ l = [i|σi is variable and @j > i. σi = (σ, u)j] Ψ0 = Ψl Σ ` Ψ0 FV(T ) ⊆ Ψ0

Σ ∪ {?y : T [Ψ0], ?x := ?y[idΨ0]}; Γ ` t ≈ ?y[σl] u . Σ0

Σ; Γ ` t ≈ ?x[σ] u . Σ0 Meta-PruneR

What this rule does, then, is to take each position i in σ such that σi is a variable with no duplicated occurrence in σ, u. The list containing those positions l is used to filter out the local context of the meta-variable, obtaining the new context Ψ0. After making sure this context is valid, a fresh meta-variable ?y is created in this restricted local context, and ?x is instantiated with this meta-variable. The new meta-context obtained after this instantiation is used to recursively call the unification algorithm to solve the problem

?y[σl] u ≈ t.

We illustrate the effect of this rule with the examples from Section 4.4. The first issue was with non-dependent if−then−elses, which produced equations of the form

?T [true] ≈ nat

?T [false] ≈ nat

In this case, the rule Meta-PruneR will remove the dependency to the conditional, obtaining the following solvable equations, for a fresh meta-variable ?T0:

?T0[] ≈ nat

?T0[] ≈ nat

The second issue was with meta-variable dependency due to incorrect dependency in-jection by the in modifier in Ssreflect’s rewrite tactic. In the example, we ended up with the following equation:

?y[x, ?z[x]] ≈ 1 + x

The ruleMeta-PruneRwill remove the second dependency, obtaining the solvable equa-tion

?y0[x] ≈ 1 + x

The third issue was with non-dependen products. In the example, the equation that fall outside the higher-order pattern fragment was:

?U0[S x] ≈ Prop

Again,Meta-PruneR will remove the dependency and obtain the equation:

?U00[] ≈ Prop

The fourth issue was with explicit duplicated dependencies. The problematic equation there was:

?z[w] w ≈ t ∗ (w + u)

where the second w in the left-hand side corresponds to an explicit written dependency (as in w). Our algorithm, extended with the ruleMeta-PruneR, will chop off the first occurrence, obtaining the equation:

?z0[] w ≈ t ∗ (w + u)

As expected, with the addition of this rule the Ssreflect library compiles almost out of the box, with only 23 lines requiring modifications. We also obtain a significant reduction in the number of lines requiring modifications in the CPDT book: only 14 lines had to be revised. In most of the cases, the problem comes from our algorithm picking a different solution to the one expected. This is unsurprising, since we are deciding early on a solution, instead of postponing the equation until more information is obtained.

And even when the selected solution works most of the times, it simply cannot work always. We are certain that, with a smarter refiner and tactics, the number of unsolved problems can be drastically reduced. The question that we leave open for future work is if such modifications to the refiner and tactics are enough, or if this heuristic is, after all, essential.