Skip to content
scrambled
Programming Language Theory Book

Chapter 3. Hypothetical and general judgments

  • A Hypothetical judgment expresses an Entailment between one or more Hypothesises and a Conclusion.

    -> Two forms of Entailment:

    • Derivability.

    • Admissibility.

      -> Both differ in that Derivability is Stable under extension with new rules, but Admissibility is not.

  • A General judgment expresses the Universality or Genericity of a Judgment.

    -> Two forms of General judgment:

Hypothetical judgments ​

  • The Hypothetical judgment arranges the rules for expressing the Validity of a Conclusion conditional on the Validity of one or more Hypothesises.

  • There are two forms of Hypothetical judgments:

    -> Differ according to the sense in which the Conclusion is conditional on the Hypothesises.

    -> One is stable under extension with more rules, and the other is not.

Derivability ​

  • Consider a given set ℛ of Rules.

  • The Derivability judgment is written J1,…,Jk⊢ℛK, where Ji and K are Basic judgments.

  • Such a Derivability judgment means that we may derive K from the Expansion ℛ∪{J1,…,Jk} of the rules ℛ with the Axioms:

    J1…Jk
    • The Hypothesises, or Antecedents, of the judgment, J1,…,Jk as "temporary axioms".

    • The Conclusion, or Consequents are derived by composing rules in ℛ.

  • A set of finite Basic judgments is usually denoted as a capital Greek letter, such as Γ or Δ.

  • ℛ∪Γ is taken to mean the Expansion of ℛ with additional axioms with judgments in Γ as the Consequents.

  • The Judgment Γ⊢ℛK means that K is Derivable from rules ℛ∪Γ.

    The Judgment ⊢ℛΓ means that ⊢ℛJ for each J in Γ.

  • An equivalent way of defining J1,…,Jn⊢ℛJ is to say that the rule

    J1 … JnJ

    is Derivable from ℛ - there is a derivation of J composed of the rules in R augmented by treating J1,…,Jn as axioms.

  • Derivability is Stable under extension with new rules.

Stability ​

Theorem. If Γ⊢ℛJ, then Γ⊢ℛ∪ℛ′J.

Proof

Any derivation of J from R∪Γ is also a derivation from (R∪R′)∪Γ, because any rule in R is also a rule in R∪R′.

Structural property ​

  • Reflexivity: Every judgment is a consequence of itself - Γ,J⊢ℛJ. Each hypothesis justifies itself as a Conclusion.

  • Weakening: If Γ⊢ℛJ, then Γ,K⊢ℛJ. Entailment is not influenced by un-exercised options.

  • Transitivity: If Γ,K⊢ℛJ and Γ⊢ℛK, then Γ⊢ℛJ. If we replace an axiom by a derivation of it, the result is a derivation of its consequent without that hypothesis.

Admissibility ​

  • Admissibility, usually written as Γ⊨ℛJ, is a weaker form of Hypothetical judgment stating that ⊢ℛΓ implies ⊢ℛJ.

    That is, the conclusion J is derivable from rules ℛ when the assumptions Γ are all derivable from rules ℛ.

    In particular, if any of the hypotheses are not derivable relative to ℛ, then the judgment is vacuously true.

    • An equivalent way to define the judgment J1,…,Jn⊨ℛJ is to state that the rule

    J1 … JnJ

    is admissible relative to the rules in ℛ.

    Given any derivations of J1,…,Jn using the rules in ℛ, we may build a derivation of J using the rules in ℛ.

  • Example

    The Admissibility judgment

    succ(a) even⊨a odd

    is valid.

    Reason: Any derivation of succ(a) even from rules must contain a sub-derivation of a odd from the same rules, which justifies the conclusion.

Unstability ​

  • The admissibility judgment is not stable under extension to the rules.

  • Counterexample

    If we enrich the original rules:

    zero evenn evensucc(n) oddn oddsucc(n) even

    with the following rule:

    succ(zero) even

    Then the rule succ(a) even⊨a odd is Inadmissible.

Derivability as a stronger judgment than Admissibility ​

Theorem. If Γ⊢ℛJ, then Γ⊨ℛJ.

Proof

Repeated application of the transitivity of derivability shows that if Γ⊢ℛJ and ⊢ℛΓ, then ⊢ℛJ .

  • Counterexample to: If Γ⊨ℛJ, then Γ⊢ℛJ.

This amounts to showing an instance of ℛ, Γ and J such that:

  • Γ⊨ℛJ, or If ⊢ℛΓ then ⊢ℛJ.

  • Γ⊬ℛJ.

We can take ℛ to contain:

zero evenn evensucc(n) oddn oddsucc(n) even

We can take Γ to contain:

succ(zero) even

We can take J to be: zero odd.

Interpretation of an admissibility evidence ​

  • Evidence for admissibility can be thought of as a mathematical function transforming derivations ▽1,…,▽n of the hypotheses into a derivation ▽ of the consequent.

Structural property (admissibility) ​

  • Reflexivity: If J is derivable from the original rules, then J is derivable from the original rules: J⊨ℛJ.

  • Weakening: If J is derivable from the original rules assuming that each of the judgments in Γ are derivable from these rules, then J must also be derivable assuming that Γ and K are derivable from the original rules: if Γ⊨ℛJ, then Γ,K⊨ℛJ.

  • Transitivity: If Γ,K⊨ℛJ and Γ⊨ℛK, then Γ⊨ℛJ. If the judgments in Γ are derivable, so is K, by assumption, and hence so are the judgments in Γ,K, and hence so is J.

Hypothetical inductive definitions ​

  • Hypothetical inductive definitions enrich standard Inductive definitions by allowing rules where the Premises and Conclusions are Derivability judgments.

  • This structure introduces two types of hypotheses:

    • Global hypothesises (Γ): In effect at the point where the Rule is applied.

    • Local hypothesises (Γi): Specific only to the Derivation of a particular Premise.

  • A Hypothetical rule takes the following explicit form:

    Γ Γ1⊢J1…Γ Γn⊢JnΓ⊢J

    The Hypothesises Γ are the Global hypothesises of the Rule.

    The Hypothesises Γi are the Local hypothesises of the ith Premise or the Rule.

    • Interpretation: J is a Derivable consequence of Γ if, for every Premise i, Ji is a Derivable consequence of Γ augmented by the local hypotheses Γi.

    • Context switch: Deriving a Premise involves a "context switch" where the Global hypothesises are extended by the Local hypothesises of that Premise.

Uniformity & Implicit form ​

  • Rules in a Hypothetical inductive definition must be Uniform, meaning they apply in all global Contexts.

  • Because of this Uniformity, the global Context Γ is often suppressed, leading to the Implicit form:

    Γ1⊢J1…Γn⊢JnJ

    -> Implicit understanding: The rule applies for any choice of Global hypothesises.

Structurality of judgments ​

  • A Hypothetical inductive definition -> An ordinary Inductive definition of a Formal derivability judgment Γ⊢J consisting of:

    • A finite set of Basic judgments Γ.

    • A Basic judgment J.

  • A set of Hypothetical rules ℛ defines the strongest Formal derivability judgment that is Structural and Closed (under) Uniform rules ℛ.

  • Structurality means that the Formal derivability judgment must be closed under the following rules:

    • Reflexivity:

      Γ,J⊢J
    • Weakening:

      Γ⊢JΓ,K⊢J
    • Transitivity:

      Γ⊢KΓ,K⊢JΓ⊢J

Hypothetical rule induction ​

  • The principle of Hypothetical rule induction is simply standard Rule induction applied to the Formal derivability judgment.

  • To show that a property 𝒫(Γ⊢J) holds whenever Γ⊢ℛJ, one must show that 𝒫 is closed under:

    1. The rules of ℛ: If 𝒫(Γ Γ1⊢J1) and \ldots and 𝒫(Γ Γn⊢Jn), then 𝒫(Γ⊢J).

    2. The structural rules: The property must be preserved under Reflexivity, Weakening, and Transitivity.

  • In practice, rather than proving the structural steps explicitly during induction, we typically prove that the structural rules are Admissible.

    • If rules are Uniform, Weakening and Transitivity are usually clearly admissible.

    • Reflexivity is usually postulated explicitly as a rule.

General judgments ​

  • General judgments codify the Rules for handling Variables in a Judgment.

  • Variable: An unknown, ranging over a specified set of objects.

  • A Generic (general) judgment states that a Judgment holds for any choice of objects replacing designated variables in the judgment.

  • A Parametric (general) judgments codify the handling of Symbolic parameters, expressing generality over any choice of Fresh renamings of designated Symbols of a Judgment.

  • Γℛ𝒰;𝒳J - J is Derivable from Γ according to Rules ℛ, with objects consisting of Abstract binding tree (ABT)s over Symbols 𝒰 and Variables 𝒳.

  • The concept of Uniformity of a Rule must be extended to require that rules be:

    • Closed under renaming and substitution for Variables.

    • Closed under renaming for Symbolic parameters.

      Formally:

    • If ℛ is a set of rules containing a Free variable x of Sort s, then it must also contain all possible substitution instances of Abstract binding tree (ABT)s a of Sort s for x, including those that contain other Free variables.

    • If ℛ contains Rules with a Symbolic parameter u, then it must contain all instances of that rule obtained by renaming u of a sort to any u′ of the same Sort.

      -> Ruling out:

    • Stating a rule for a variable, without also stating it for all instances of that variable.

    • Stating a rule for a parameter without stating it for all possible renamings of that parameter.

Generic derivability ​

  • Generic derivability judgment is defined by:

    𝒴 | Γ⊢ℛ𝒳 JiffΓ⊢ℛ𝒳𝒴J

    where 𝒴∩𝒳=∅.

  • Evidence for Generic derivability consists of a Generic derivation ▽ involving the Variables 𝒳𝒴.

    -> If the rules are Uniform, the choice of 𝒴 does not matter.

    • Example

      Given ℛ as:

      zero natx natsucc(x) nat

      The Generic derivation ▽:

      x natsucc(x) natsucc(succ(x)) nat

      is Evidence for the Judgment:

      x | x nat⊢ℛ𝒳 succ(succ(x)) nat

      provided x∉𝒳.

  • The Generic derivability judgment enjoys the following Structural property governing the behavior of Variables, provided that ℛ is Uniform.

    • Proliferation:

      If 𝒴 | Γ⊢ℛ𝒳 J, then 𝒴,y | Γ⊢ℛ𝒳J.

    • Renaming:

      If 𝒴,y | Γ⊢ℛ𝒳J, then 𝒴,y′ | [y↔y′]Γ⊢ℛ𝒳[y↔y′]J for any y′∉𝒳𝒴.

    • Substitution:

      If 𝒴,y | Γ⊢ℛ𝒳J and a∈ℬ[𝒳𝒴], then 𝒴 | [a/y]Γ⊢ℛ𝒳[a/y]J.

  • Remarks: To my understanding, 𝒳 acts somewhat like free variables, and 𝒴 acts somewhat like bound variables.

Parametric derivability ​

Generic inductive definitions ​

  • A Generic inductive definition admits Generic inductive definition in the Premises of rules.

    -> Augmenting the variables & the rules within those Premises.

  • A Generic rule has the form:

    𝒴 𝒴1 | Γ Γ1⊢J1…𝒴 𝒴n | Γ Γn⊢Jn𝒴 | Γ⊢J
    • Global variables: 𝒴.

    • For each 1≤i≤n, Local variables of the ith Premise: 𝒴i.

  • Implicit form:

    𝒴1 | Γ1⊢J1…𝒴n | Γn⊢JnJ
  • A Generic inductive definition is an ordinary Inductive definition of a family of formal Generic (general) judgments of the form 𝒴 | Γ⊢J.

    Formal Generic (general) judgments are identified up to Renaming of Variables.

    -> The latter Judgment is treated as identical to the Judgment 𝒴′ | ρˆ(Γ)⊢ρˆ(J) for any Renaming ρ:𝒴↔𝒴′.

  • If ℛ is a collection of Generic rules, we write 𝒴 | Γ⊢ℛJ to mean that the formal Generic (general) judgment 𝒴 | Γ⊢J is derivable from rules ℛ.

  • When specialized to a set of Generic rules, the principle of Rule induction states that to show 𝒫(𝒴 | Γ⊢J) when 𝒴 |Γ⊢ℛJ, it is sufficient to show that 𝒫 is closed under the rules ℛ.

    If 𝒫(𝒴 𝒴1 | Γ Γ1⊢J1) … 𝒫(𝒴 𝒴n | Γ Γn⊢Jn) then 𝒫(𝒴 | Γ⊢J).

  • To ensure that a Formal generic judgment behaves like a Generic (general) judgment, the Structural rules are Admissible.

    𝒴 | Γ,J⊢J(3.14a)𝒴 | Γ⊢J𝒴 | Γ,J′⊢J(3.14b)𝒴 | Γ⊢J𝒴,x | Γ⊢J(3.14c)𝒴,x′ | [x↔x′]Γ⊢[x↔x′]J𝒴,x | Γ⊢J(3.14d)𝒴 | Γ⊢J𝒴 | Γ,J⊢J′𝒴 | Γ⊢J′(3.14e)𝒴,x | Γ⊢Ja∈ℬ[𝒴]𝒴 | [a/x]Γ⊢[a/x]J(3.14f)
    • The Admissibility of rule (3.14a) is in practice ensured by explicitly including it.

    • The Admissibility of rules (3.14b) and (3.14c) is assured if each of the generic rules is Uniform because we may:

      • Assimilate the added variable x to the global variables 𝒴.

      • Assimilate the added hypothesis J′ to the global hypotheses Γ′.

    • The Admissibility of rule (3.14d) is ensured by the identification convention for the formal generic judgment.

    • Rule (3.14f) must be verified explicitly for each inductive definition.

  • Parametric inductive definition is similar to generic inductive definition.

Notes ​

  • Foundational roots

    • The concepts of entailment and generality are central to logic and programming languages.

    • Harper's formulation builds specifically on the work of Martin-Lof (1983, 1987) and Avron (1991).

  • Contrast with AUTOMATH & LF

    • Unified Concept: Systems like AUTOMATH and the LF Logical Framework consolidate hypothetical and general reasoning into a single concept.

    • Arbitrary Nesting: These systems allow for arbitrarily nested combinations of judgments (e.g., judgments about judgments).

  • Harper's distinction

    • Restricted structure: Unlike LF, PFPL considers only general hypothetical judgments over basic judgment forms. It separates the machinery of entailment from the basic judgments.

    • Explicitly introduces symbols and variables, which were not present in the previous accounts (Martin-Lof/Avron).

  • Why symbols matter (Parametric Judgments)

    • Parametric judgments are necessary to specify languages that allow the dynamic creation of "new" objects.

Exercise ​

Exercise 3.1 ​

Problem statement. Combinators are inductively defined by the rule set 𝒞 given as follows:

𝗌 comb(3.15a)𝗄 comb(3.15b)a1 comba2 comb𝖺𝗉(a1;a2) comb(3.15c)

Give an inductive definition of the length of a combinator defined as the number of occurrences of 𝗌 and 𝗄 within it.

Solution
  • Definition

    len(𝗌;succ(zero))len(𝗄;succ(zero))a1 comba2 comblen(a1;l1)len(a2;l2)len(𝖺𝗉(a1;a2);plus(l1;l2))
  • Existence

    For every a comb, there must exist n nat such that len(a;n).

- For a=𝗌 and a=𝗄, it's obvious that n=succ(zero) is a witness. - Suppose that n1 nat is a witness for a1 comb and n2 nat is a witness for a2 comb, then it's obvious that plus(l1;l2) is a witness for 𝖺𝗉(a1;a2).

  • Uniqueness

    For every a comb, if there exist two n1 nat and n2 nat such that len(a;n1) and len(a;n2), then n1=n2.

- For a=𝗌 and a=𝗄, it's obvious that n=succ(zero) is the unique value. - Suppose that n1 nat is a witness for a1 comb and n2 nat is a witness for a2 comb, then it's obvious that plus(l1;l2) is the unique value.

Exercise 3.2 ​

Problem statement. The general judgment

x1,…,xn|x1 comb,…,xn comb⊢𝒞A comb

states that A is a combinator that may involve the variables x1,…,xn. Prove that if x|x comb⊢𝒞a2 comb and a1 comb, then [a1/x]a2 comb by induction on the derivation of the first hypothesis of the implication.

Confusion and notes ​

Lifting & Hypothetical judgments.

  • The core question:

    If the base rules 𝒞 (combinators) do not mention variables or contexts, how is it possible to derive a judgment that contains them?

  • For example:

- The rule for 𝗌 is just 𝗌 comb. It knows nothing about x. - We often need to prove things like x⊢𝖺𝗉(𝗌;x).

  • Where does the permission to use x come from if not from the rules?

  • For some variables 𝒴 and hypotheses Γ:

- Reflexivity: $$ \displaystyle\frac{}{\mathcal{Y}\ \vert \ \Gamma, J \vdash_\mathcal{C} J} $$ - 𝒴 | Γ⊢𝒞J is defined to be equivalent to Γ⊢𝒞𝒴J, which in turn, means that with 𝒴 instantiated, J is derivable using the rules Γ∪𝒞. Because the rules in 𝒞 holds regardless of instantiations of 𝒴 and Γ, we can lift each rule in 𝒞 like this: $$ \displaystyle \frac{\mathcal{Y}\ \vert \ \Gamma \vdash a_1 \text{ comb} \quad \mathcal{Y}\ \vert \ \Gamma \vdash a_2 \text{ comb}}{\mathcal{Y}\ \vert \ \Gamma \vdash \mathsf{ap}(a_1; a_2) \text{ comb}} $$

Solution

After lifting, 𝒞 becomes (minus the structural rules):

Γ⊢𝗌 comb(3.15a)Γ⊢𝗄 comb(3.15b)𝒴 | Γ⊢a1 comb𝒴 | Γ⊢a2 comb𝒴 | Γ⊢𝖺𝗉(a1;a2) comb(3.15c)

By the problem statement, I assume that:

There is a derivation ▽ using the rules 𝒞 with a conclusion of x | x comb⊢𝒞a2 comb.

Consider the last rule applied in ▽ for each of the above rule, then maybe try to modify the derivation to conclude 𝖺𝗉(a1;a2).

Exercise 3.3 ​

Problem statement. Conversion, or equivalence, of combinators is expressed by the judgment A≡B defined by the rule set ℰ extending 𝒞 as follows:

a comba≡a(3.16a)a2≡a1a1≡a2(3.16b)a1≡a2a2≡a3a1≡a3(3.16c)a1≡a1′a2≡a2′a1 a2≡a1′ a2′(3.16d)a1 comba2 comb𝗄a1a2≡a1(3.16e)a1 comba2 comba3 comb𝗌a1a2a3≡(a1a3) (a2a3)(3.16f)

The no-doubt mysterious motivation for the last two equations will become clearer in a moment. For now, show that

x|x comb⊢𝒞∪ℰ𝗌𝗄𝗄x≡x

Note: The combinator ap(a1;a2) is written a1 a2 for short, left-associatively when used in succession.

Solution

After lifting, the ruleset ℰ becomes:

𝒴 | J⊢x combx≡x(3.16a)𝒴 | J⊢x2≡x1x1≡x2(3.16b)𝒴 | J⊢x1≡x2𝒴 | J⊢x2≡x3𝒴 | J⊢x2≡x3(3.16c)𝒴 | J⊢x1≡x1′𝒴 | J⊢x2≡x2′𝒴 | J⊢x1 x2≡x1′ x2′(3.16d)𝒴 | J⊢x1 comb𝒴 | J⊢x2 comb𝒴 | J⊢𝗄x1x2≡x1(3.16e)𝒴 | J⊢x1 comb𝒴 | J⊢x2 comb𝒴 | J⊢x3 comb𝒴 | J⊢𝗌x1x2x3≡(x1x3) (x2x3)(3.16f)

We'll prove that:

x|x comb⊢𝒞∪ℰ𝗌𝗄𝗄x≡x.x | x comb⊢𝗄 combx | x comb⊢x combx | x comb⊢𝗌 𝗄 𝗄 x≡(𝗄 x) (𝗄 x)x | x comb⊢𝗑 combx | x comb⊢(𝗄 x) combx | x comb⊢𝗌 𝗄 𝗄 x≡x

Exercise 3.4 ​

Problem statement. Show that if x|x comb⊢𝒞a comb, then there is a combinator a′, written [x]a and called bracket abstraction, such that:

x|x comb⊢𝒞∪ℰa′ x≡a

Consequently, by Exercise 3.2, if a′′ comb, then:

([x]a) a′′≡[a′′/x]a

Hint:

Inductively define the judgment:

x|x comb⊢absx a is a′

where x|x comb⊢a comb. Then argue that it defines a′ as a binary function of x and a. The motivation for the conversion axioms governing 𝗄 and 𝗌 should become clear while developing the proof of the desired equivalence.

  • Confusion point

    I thought a′=[x]a≡𝗄 a worked for all a and x & spent 1 hour wondering why this problem was nontrivial.

    It turns out, because a′ is a combinator, which means ⊢a′ comb.

    If a contains the variable x, then, ⊬(𝗄 a) comb. It's only true that x | x comb⊢(𝗄 a) comb .

Solution

We define abs as:

x | x comb⊢absx 𝗌 is 𝗄 𝗌x | x comb⊢absx 𝗄 is 𝗄 𝗄x y | x comb y comb⊢absx y is 𝗄 yx | x comb⊢absx x is 𝗌 𝗄 𝗄 xx | x comb⊢absx a1 is a1′x | x comb⊢absx a2 is a2′x | x comb⊢absx ap a1 a2 is 𝗌 a1′ a2′

Exercise 3.5 ​

Problem statement. Prove that bracket abstraction, as defined in Exercise 3.4, is non-compositional by exhibiting a and b such that a comb and

xy|x comby comb⊢𝒞b comb

such that: [a/y]([x]b)≠[x]([a/y]b)

Hint: Consider the case that b is y.

Suggest a modification to the definition of bracket abstraction that is compositional by showing under the same conditions given above that:

[a/y]([x]b)=[x]([a/y]b)
  • Note

Because a is a categorical judgment evaluated in an empty context, a must be a closed combinator with no free variables, whereas b is defined under a hypothetical judgment that explicitly permits variables.

Solution
  • If b=y, then:

  • [x]b=[x]y=𝗄 y.

-> LHS = [a/y]([x] b)=[a/y](𝗄 y)=𝗄 a.

  • [a/y]b=[a/y]y=a.

-> RHS = [x]([a/y]b)=[x]a.

It's trivial that there exists an a being some combination of 𝗌 and 𝗄 such that 𝗄 a≠[x]a (they are equivalent though).

  • Intuition: To redefine a new bracket abstraction that is compositional in this context, it must at least be compositional when b=y.

My guts feeling here is to modify the fourth rule in the original ruleset.

Then LHS = [a/y]([x]y) = [x]a = RHS for all a such that ⊢a comb.

  • Start with a=𝗄.

  • New definition:

x | x comb⊢absx 𝗌 is 𝗄 𝗌x | x comb⊢absx 𝗄 is 𝗄 𝗄x | x comb⊢absx x is 𝗌 𝗄 𝗄x | x comb y comb⊢absx y is x | x comb⊢absx a1 is a1′x | x comb⊢absx a2 is a2′x | x comb⊢absx ap a1 a2 is 𝗌 a1′ a2′

Exercise 3.6 ​

Problem statement. Consider the set ℬ[𝒳] of ABT's generated by the operators ap, with arity (Exp,Exp)Exp, and λ, with arity (Exp.Exp)Exp, and possibly involving variables in 𝒳, all of which are of sort Exp.

Give an inductive definition of the judgment b closed, which specifies that b has no free occurrences of the variables in 𝒳.

Hint: It is essential to give an inductive definition of the hypothetical, general judgment

x1,…,xn|x1 closed,…,xn closed⊢b closed

in order to account for the binding of a variable by the λ operator.

The hypothesis that a variable is closed seems self-contradictory in that a variable obviously occurs free in itself. Explain why this is not the case by examining carefully the meaning of the hypothetical and general judgments.

Solution