scrambled
Book

Chapter 3 hypothetical and general judgments

Modified just now
  • 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 R\mathcal{R} of Rules.

  • The Derivability judgment is written J1,,JkRKJ_1,\dots,J_k \vdash_\mathcal{R} K, where JiJ_i and KK are Basic judgments.

  • Such a Derivability judgment means that we may derive KK from the Expansion R{J1,,Jk}\mathcal{R} \cup \{J_1, \dots, J_k\} of the rules R\mathcal{R} with the Axioms:

    J1Jk \displaystyle\frac{}{J_1} \quad \dots \quad \displaystyle\frac{}{J_k}

    • The Hypothesises, or Antecedents, of the judgment, J1,,JkJ_1, \dots , J_k as "temporary axioms".
    • The Conclusion, or Consequents are derived by composing rules in R\mathcal{R}.
  • A set of finite Basic judgments is usually denoted as a capital Greek letter, such as Γ\Gamma or Δ\Delta.

  • RΓ\mathcal{R}\cup \Gamma is taken to mean the Expansion of R\mathcal{R} with additional axioms with judgments in Γ\Gamma as the Consequents.

  • The Judgment ΓRK\Gamma \vdash_{\mathcal{R}} K means that KK is Derivable from rules RΓ\mathcal{R} \cup \Gamma.

    The Judgment RΓ\vdash_\mathcal{R} \Gamma means that RJ\vdash_\mathcal{R} J for each JJ in Γ\Gamma.

  • An equivalent way of defining J1,,JnRJJ_1, \dots, J_n \vdash_\mathcal{R} J is to say that the rule

    J1  JnJ \displaystyle\frac{J_1\ \dots\ J_n}{J}

    is Derivable from R\mathcal{R} - there is a derivation of JJ composed of the rules in RR augmented by treating J1,,JnJ_1, \dots , J_n as axioms.

  • Derivability is Stable under extension with new rules.

Stability

Theorem. If ΓRJ\Gamma \vdash_\mathcal{R} J, then ΓRRJ\Gamma \vdash_{\mathcal{R}\cup\mathcal{R}'} J.

Proof

Any derivation of JJ from RΓR \cup \Gamma is also a derivation from (RR)Γ(R \cup R') \cup \Gamma, because any rule in RR is also a rule in RRR \cup R'.

Structural property

  • Reflexivity: Every judgment is a consequence of itself - Γ,JRJ\Gamma, J \vdash_\mathcal{R} J. Each hypothesis justifies itself as a Conclusion.
  • Weakening: If ΓRJ\Gamma \vdash_\mathcal{R} J, then Γ,KRJ\Gamma, K \vdash_\mathcal{R} J. Entailment is not influenced by un-exercised options.
  • Transitivity: If Γ,KRJ\Gamma, K \vdash_\mathcal{R} J and ΓRK\Gamma \vdash_\mathcal{R} K, then ΓRJ\Gamma \vdash_\mathcal{R} 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 ΓRJ\Gamma \models_\mathcal{R} J, is a weaker form of Hypothetical judgment stating that RΓ\vdash_\mathcal{R} \Gamma implies RJ\vdash_\mathcal{R} J.

    That is, the conclusion JJ is derivable from rules R\mathcal{R} when the assumptions Γ\Gamma are all derivable from rules R\mathcal{R}.

    In particular, if any of the hypotheses are not derivable relative to R\mathcal{R}, then the judgment is vacuously true.

    • An equivalent way to define the judgment J1,,JnRJJ_1, \dots , J_n \models_\mathcal{R} J is to state that the rule

    J1  JnJ \displaystyle\frac{J_1\ \dots\ J_n}{J}

    is admissible relative to the rules in R\mathcal{R}.

    Given any derivations of J1,,JnJ_1, \dots, J_n using the rules in R\mathcal{R}, we may build a derivation of JJ using the rules in R\mathcal{R}.

  • Example

    The Admissibility judgment

    succ(a) evena odd \text{succ}(a)\ \text{even} \models a\ \text{odd}

    is valid.

    Reason: Any derivation of succ(a) even\text{succ}(a)\ \text{even} from rules must contain a sub-derivation of a odda\ \text{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 even \displaystyle\frac{}{\text{zero}\ \text{even}}

    n evensucc(n) odd \displaystyle\frac{n\ \text{even}}{ \text{succ}(n)\ \text{odd}}

    n oddsucc(n) even \displaystyle\frac{n\ \text{odd}}{\text{succ}(n)\ \text{even}}

    with the following rule:

    succ(zero) even \displaystyle\frac{}{\text{succ}(\text{zero})\ \text{even}}

    Then the rule succ(a) evena odd\text{succ}(a)\ \text{even} \models a\ \text{odd} is Inadmissible.

Derivability as a stronger judgment than Admissibility

Theorem. If ΓRJ\Gamma \vdash_\mathcal{R} J, then ΓRJ\Gamma \models_\mathcal{R} J.

Proof

Repeated application of the transitivity of derivability shows that if ΓRJ\Gamma \vdash_\mathcal{R} J and RΓ\vdash_\mathcal{R} \Gamma, then RJ\vdash_\mathcal{R} J .

  • Counterexample to: If ΓRJ\Gamma \models_\mathcal{R} J, then ΓRJ\Gamma \vdash_\mathcal{R} J.

This amounts to showing an instance of R\mathcal{R}, Γ\Gamma and JJ such that:

  • ΓRJ\Gamma \models_\mathcal{R} J, or If RΓ\vdash_\mathcal{R} \Gamma then RJ\vdash_\mathcal{R} J.
  • Γ̸RJ\Gamma \not\vdash_\mathcal{R} J.

We can take R\mathcal{R} to contain:

zero even\displaystyle\frac{}{\text{zero}\ \text{even}}

n evensucc(n) odd\displaystyle\frac{n\ \text{even}}{ \text{succ}(n)\ \text{odd}}

n oddsucc(n) even\displaystyle\frac{n\ \text{odd}}{\text{succ}(n)\ \text{even}}

We can take Γ\Gamma to contain:

succ(zero) even\text{succ}(\text{zero})\ \text{even}

We can take JJ to be: zero odd\text{zero}\ \text{odd}.

Interpretation of an admissibility evidence

  • Evidence for admissibility can be thought of as a mathematical function transforming derivations 1,,n\triangledown_1, \dots, \triangledown_n of the hypotheses into a derivation \triangledown of the consequent.

Structural property (admissibility)

  • Reflexivity: If JJ is derivable from the original rules, then JJ is derivable from the original rules: JRJJ \models_\mathcal{R} J.
  • Weakening: If JJ is derivable from the original rules assuming that each of the judgments in Γ\Gamma are derivable from these rules, then JJ must also be derivable assuming that Γ\Gamma and KK are derivable from the original rules: if ΓRJ\Gamma \models_\mathcal{R} J, then Γ,KRJ\Gamma, K \models_\mathcal{R} J.
  • Transitivity: If Γ,KRJ\Gamma, K \models_\mathcal{R} J and ΓRK\Gamma \models_\mathcal{R} K, then ΓRJ\Gamma \models_\mathcal{R} J. If the judgments in Γ\Gamma are derivable, so is KK, by assumption, and hence so are the judgments in Γ,K\Gamma, K, and hence so is JJ.

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 (Γ\Gamma): In effect at the point where the Rule is applied.
    • Local hypothesises (Γi\Gamma_i): Specific only to the Derivation of a particular Premise.
  • A Hypothetical rule takes the following explicit form:

    Γ Γ1J1Γ ΓnJnΓJ \frac{\Gamma\ \Gamma_1 \vdash J_1 \quad \dots \quad \Gamma\ \Gamma_n \vdash J_n}{\Gamma \vdash J}

    The Hypothesises Γ\Gamma are the Global hypothesises of the Rule.

    The Hypothesises Γi\Gamma_i are the Local hypothesises of the $i$th Premise or the Rule.

    • Interpretation: JJ is a Derivable consequence of Γ\Gamma if, for every Premise ii, JiJ_i is a Derivable consequence of Γ\Gamma augmented by the local hypotheses Γi\Gamma_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 Γ\Gamma is often suppressed, leading to the Implicit form:

    Γ1J1ΓnJnJ \frac{\Gamma_1 \vdash J_1 \quad \dots \quad \Gamma_n \vdash J_n}{J}

    -> 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\Gamma \vdash J consisting of:

    • A finite set of Basic judgments Γ\Gamma.
    • A Basic judgment JJ.
  • A set of Hypothetical rules R\mathcal{R} defines the strongest Formal derivability judgment that is Structural and Closed (under) Uniform rules R\mathcal{R}.

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

    • Reflexivity:

      Γ,JJ \displaystyle\frac{}{\Gamma, J \vdash J}

    • Weakening:

      ΓJΓ,KJ \displaystyle\frac{\Gamma \vdash J}{\Gamma, K \vdash J}

    • Transitivity:

      ΓKΓ,KJΓJ \displaystyle\frac{\Gamma \vdash K \quad \Gamma, K \vdash J}{\Gamma \vdash 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 P(ΓJ)\mathcal{P}(\Gamma \vdash J) holds whenever ΓRJ\Gamma \vdash_{\mathcal{R}} J, one must show that P\mathcal{P} is closed under:

    1. The rules of R\mathcal{R}: If P(Γ Γ1J1)\mathcal{P}(\Gamma\ \Gamma_1 \vdash J_1) and \ldots and P(Γ ΓnJn)\mathcal{P}(\Gamma\ \Gamma_n \vdash J_n), then P(ΓJ)\mathcal{P}(\Gamma \vdash 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.

  • ΓRU;XJ\Gamma^{\mathcal{U};\mathcal{X}}_\mathcal{R}J - JJ is Derivable from Γ\Gamma according to Rules R\mathcal{R}, with objects consisting of Abstract binding tree (ABT)s over Symbols U\mathcal{U} and Variables X\mathcal{X}.

  • 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 R\mathcal{R} is a set of rules containing a Free variable xx of Sort ss, then it must also contain all possible substitution instances of Abstract binding tree (ABT)s aa of Sort ss for xx, including those that contain other Free variables.

    • If R\mathcal{R} contains Rules with a Symbolic parameter uu, then it must contain all instances of that rule obtained by renaming uu of a sort to any uu' 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:

    Y  ΓRX JiffΓRXYJ \mathcal{Y}\ \vert \ \Gamma \vdash^\mathcal{X}_\mathcal{R}\ J\quad \text{iff} \quad \Gamma \vdash^{\mathcal{X}\mathcal{Y}}_\mathcal{R}J

    where YX=\mathcal{Y} \cap \mathcal{X} = \emptyset.

  • Evidence for Generic derivability consists of a Generic derivation \triangledown involving the Variables XY\mathcal{X}\mathcal{Y}.

    -> If the rules are Uniform, the choice of Y\mathcal{Y} does not matter.

    • Example

      Given R\mathcal{R} as:

      zero nat \displaystyle\frac{}{\text{zero}\ \text{nat}}

      x natsucc(x) nat \displaystyle\frac{x\ \text{nat}}{\text{succ}(x)\ \text{nat}}

      The Generic derivation \triangledown:

      x natsucc(x) natsucc(succ(x)) nat \displaystyle\frac{\displaystyle\frac{\displaystyle\frac{}{x\ \text{nat}}}{\text{succ}(x)\ \text{nat}}}{\text{succ}(\text{succ}(x))\ \text{nat}}

      is Evidence for the Judgment:

      x  x natRX succ(succ(x)) nat x \ \vert \ x\ \text{nat} \vdash^{\mathcal{X}}_\mathcal{R}\ \text{succ}(\text{succ}(x))\ \text{nat}

      provided xXx \notin \mathcal{X}.

  • The Generic derivability judgment enjoys the following Structural property governing the behavior of Variables, provided that R\mathcal{R} is Uniform.

    • Proliferation:

      If Y  ΓRX J\mathcal{Y}\ \vert \ \Gamma \vdash^\mathcal{X}_\mathcal{R}\ J, then Y,y  ΓRXJ\mathcal{Y}, y\ \vert \ \Gamma \vdash^\mathcal{X}_\mathcal{R} J.

    • Renaming:

      If Y,y  ΓRXJ\mathcal{Y}, y\ \vert \ \Gamma \vdash^\mathcal{X}_\mathcal{R} J, then Y,y  [yy]ΓRX[yy]J\mathcal{Y}, y'\ \vert \ [y \leftrightarrow y']\Gamma \vdash^\mathcal{X}_\mathcal{R}[y \leftrightarrow y']J for any yXYy' \notin \mathcal{XY}.

    • Substitution:

      If Y,y  ΓRXJ\mathcal{Y}, y\ \vert \ \Gamma \vdash^\mathcal{X}_\mathcal{R} J and aB[XY]a \in \mathcal{B}[\mathcal{XY}], then Y  [a/y]ΓRX[a/y]J\mathcal{Y}\ \vert \ [a/y]\Gamma \vdash^\mathcal{X}_\mathcal{R}[a/y]J.

  • Remarks: To my understanding, X\mathcal{X} acts somewhat like free variables, and Y\mathcal{Y} acts somewhat like bound variables.

Parametric derivability

  • Parametric (general) judgment is defined analogously like Generic (general) judgment, albeit by generalizing over Symbolic parameters, rather than Variables.

  • Parametric (general) judgment is defined by:

    V  Y  ΓRU;X JiffY  ΓRUV;X J \mathcal{V} \ \Vert \ \mathcal{Y}\ \vert \ \Gamma \vdash^{\mathcal{U};\mathcal{X}}_{\mathcal{R}}\ J \quad \text{iff} \quad \mathcal{Y}\ \vert \ \Gamma^{\mathcal{UV};\mathcal{X}}_\mathcal{R}\ J

    where VU=\mathcal{V} \cap \mathcal{U} = \emptyset.

  • Evidence for Parametric (general) judgment consists of a Derivation \triangledown involving the symbols V\mathcal{V}.

  • Uniformity of R\mathcal{R} ensures that any choice of parameter names is as good as any other. Derivability is Stable under Renaming.

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:

    Y Y1  Γ Γ1J1Y Yn  Γ ΓnJnY  ΓJ \displaystyle\frac{\mathcal{Y}\ \mathcal{Y}_1\ \vert \ \Gamma\ \Gamma_1 \vdash J_1 \quad \dots \quad \mathcal{Y}\ \mathcal{Y}_n\ \vert \ \Gamma\ \Gamma_n\vdash J_n}{\mathcal{Y}\ \vert \ \Gamma \vdash J}

    • Global variables: Y\mathcal{Y}.
    • For each 1in1 \le i \le n, Local variables of the $i$th Premise: Yi\mathcal{Y}_i.
  • Implicit form:

    Y1  Γ1J1Yn  ΓnJnJ \displaystyle\frac{\mathcal{Y}_1\ \vert \ \Gamma_1 \vdash J_1 \quad \dots \quad \mathcal{Y}_n\ \vert \ \Gamma_n \vdash J_n}{J}

  • A Generic inductive definition is an ordinary Inductive definition of a family of formal Generic (general) judgments of the form Y  ΓJ\mathcal{Y}\ \vert \ \Gamma \vdash J.

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

    -> The latter Judgment is treated as identical to the Judgment Y  ρ^(Γ)ρ^(J)\mathcal{Y}'\ \vert \ \hat{\rho}(\Gamma) \vdash \hat{\rho}(J) for any Renaming ρ:YY\rho : \mathcal{Y} \leftrightarrow \mathcal{Y}'.

  • If R\mathcal{R} is a collection of Generic rules, we write Y  ΓRJ\mathcal{Y}\ \vert \ \Gamma \vdash_{\mathcal{R}} J to mean that the formal Generic (general) judgment Y  ΓJ\mathcal{Y}\ \vert \ \Gamma \vdash J is derivable from rules R\mathcal{R}.

  • When specialized to a set of Generic rules, the principle of Rule induction states that to show P(Y  ΓJ)\mathcal{P}(\mathcal{Y}\ \vert \ \Gamma \vdash J) when Y ΓRJ\mathcal{Y}\ \vert \Gamma \vdash_{\mathcal{R}} J, it is sufficient to show that P\mathcal{P} is closed under the rules R\mathcal{R}.

    If P(Y Y1  Γ Γ1J1)  P(Y Yn  Γ ΓnJn)\mathcal{P}(\mathcal{Y}\ \mathcal{Y}_1\ \vert \ \Gamma\ \Gamma_1 \vdash J_1)\ \dots\ \mathcal{P}(\mathcal{Y}\ \mathcal{Y}_n\ \vert \ \Gamma\ \Gamma_n \vdash J_n) then P(Y  ΓJ)\mathcal{P}(\mathcal{Y}\ \vert \ \Gamma \vdash J).

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

    Y  Γ,JJ(3.14a) \displaystyle\frac{}{\mathcal{Y}\ \vert \ \Gamma, J \vdash J} \tag{3.14a}

    Y  ΓJY  Γ,JJ(3.14b) \displaystyle\frac{\mathcal{Y}\ \vert \ \Gamma \vdash J}{\mathcal{Y}\ \vert \ \Gamma, J' \vdash J} \tag{3.14b}

    Y  ΓJY,x  ΓJ(3.14c) \displaystyle\frac{\mathcal{Y}\ \vert \ \Gamma \vdash J}{\mathcal{Y}, x\ \vert \ \Gamma \vdash J} \tag{3.14c}

    Y,x  [xx]Γ[xx]JY,x  ΓJ(3.14d) \displaystyle\frac{\mathcal{Y}, x'\ \vert \ [x\leftrightarrow x']\Gamma \vdash [x \leftrightarrow x']J}{\mathcal{Y}, x\ \vert \ \Gamma \vdash J} \tag{3.14d}

    Y  ΓJY  Γ,JJY  ΓJ(3.14e) \displaystyle\frac{\mathcal{Y}\ \vert \ \Gamma\vdash J\quad \mathcal{Y}\ \vert \ \Gamma, J \vdash J'}{\mathcal{Y}\ \vert \ \Gamma \vdash J'} \tag{3.14e}

    Y,x  ΓJaB[Y]Y  [a/x]Γ[a/x]J(3.14f) \displaystyle\frac{\mathcal{Y}, x\ \vert \ \Gamma \vdash J \quad a \in \mathcal{B}[\mathcal{Y}]}{\mathcal{Y}\ \vert \ [a/x]\Gamma \vdash [a/x]J} \tag{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 xx to the global variables Y\mathcal{Y}.
      • Assimilate the added hypothesis JJ' to the global hypotheses Γ\Gamma'.
    • 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 C\mathcal{C} given as follows:

s comb(3.15a)\displaystyle \frac{}{\mathsf{s} \ \text{comb}} \quad \tag{3.15a}

k comb(3.15b)\displaystyle\frac{}{\mathsf{k}\ \text{comb}} \quad \tag{3.15b}

a1 comba2 combap(a1;a2) comb(3.15c)\displaystyle \frac{a_1 \text{ comb} \quad a_2 \text{ comb}}{\mathsf{ap}(a_1; a_2) \text{ comb}} \quad \tag{3.15c}

Give an inductive definition of the length of a combinator defined as the number of occurrences of s\mathsf{s} and k\mathsf{k} within it.

Solution
  • Definition

    len(s;succ(zero)) \displaystyle\frac{}{\text{len}(\mathsf{s};\text{succ(\text{zero})})}

    len(k;succ(zero)) \displaystyle\frac{}{\text{len}(\mathsf{k};\text{succ(\text{zero})})}

    a1 comba2 comblen(a1;l1)len(a2;l2)len(ap(a1;a2);plus(l1;l2)) \displaystyle\frac{a_1\ \text{comb} \quad a_2\ \text{comb} \quad \text{len}(a_1; l_1) \quad \text{len}(a_2;l_2)}{\text{len}(\mathsf{ap}(a_1;a_2);\text{plus}(l_1;l_2))}

  • Existence

    For every a comba\ \text{comb}, there must exist n natn\ \text{nat} such that len(a;n)\text{len}(a; n).

  • For a=sa=\mathsf{s} and a=ka=\mathsf{k}, it's obvious that n=succ(zero)n = \text{succ}(\text{zero}) is a witness. - Suppose that n1 natn_1\ \text{nat} is a witness for a1 comba_1\ \text{comb} and n2 natn_2\ \text{nat} is a witness for a2 comba_2\ \text{comb}, then it's obvious that plus(l1;l2)\text{plus}(l_1;l_2) is a witness for ap(a1;a2)\mathsf{ap}(a_1;a_2).

  • Uniqueness

    For every a comba\ \text{comb}, if there exist two n1 natn_1\ \text{nat} and n2 natn_2\ \text{nat} such that len(a;n1)\text{len}(a;n_1) and len(a;n2)\text{len}(a;n_2), then n1=n2n_1 = n_2.

  • For a=sa = \mathsf{s} and a=ka = \mathsf{k}, it's obvious that n=succ(zero)n = \text{succ}(\text{zero}) is the unique value. - Suppose that n1 natn_1\ \text{nat} is a witness for a1 comba_1\ \text{comb} and n2 natn_2\ \text{nat} is a witness for a2 comba_2\ \text{comb}, then it's obvious that plus(l1;l2)\text{plus}(l_1;l_2) is the unique value.

Exercise 3.2

Problem statement. The general judgment

x1,,xnx1 comb,,xn combCA combx_1, \ldots, x_n \mid x_1 \text{ comb}, \ldots, x_n \text{ comb} \vdash_{\mathcal{C}} A \text{ comb}

states that AA is a combinator that may involve the variables x1,,xnx_1, \ldots, x_n. Prove that if xx combCa2 combx \mid x \text{ comb} \vdash_{\mathcal{C}} a_2 \text{ comb} and a1 comba_1 \text{ comb}, then [a1/x]a2 comb[a_1/x]a_2 \text{ 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 C\mathcal{C} (combinators) do not mention variables or contexts, how is it possible to derive a judgment that contains them?

  • For example:

  • The rule for s\mathsf{s} is just s comb\overline{\mathsf{s} \text{ comb}}. It knows nothing about xx. - We often need to prove things like xap(s;x)x \vdash \mathsf{ap}(\mathsf{s}; x).

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

  • For some variables Y\mathcal{Y} and hypotheses Γ\Gamma:

  • Reflexivity:

Y  Γ,JCJ \displaystyle\frac{}{\mathcal{Y}\ \vert \ \Gamma, J \vdash_\mathcal{C} J}

  • Y  ΓCJ\mathcal{Y} \ \vert \ \Gamma \vdash_\mathcal{C} J is defined to be equivalent to ΓCYJ\Gamma \vdash_\mathcal{C}^\mathcal{Y} J, which in turn, means that with Y\mathcal{Y} instantiated, JJ is derivable using the rules ΓC\Gamma \cup \mathcal{C}.

Because the rules in C\mathcal{C} holds regardless of instantiations of Y\mathcal{Y} and Γ\Gamma, we can lift each rule in C\mathcal{C} like this:

Y  Γa1 combY  Γa2 combY  Γap(a1;a2) comb \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, C\mathcal{C} becomes (minus the structural rules):

Γs comb(3.15a)\displaystyle \frac{}{\Gamma \vdash \mathsf{s} \ \text{comb}} \quad \tag{3.15a}

Γk comb(3.15b)\displaystyle \frac{}{\Gamma \vdash \mathsf{k} \ \text{comb}} \quad \tag{3.15b}

Y  Γa1 combY  Γa2 combY  Γap(a1;a2) comb(3.15c)\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}} \quad \tag{3.15c}

By the problem statement, I assume that:

There is a derivation \triangledown using the rules C\mathcal{C} with a conclusion of x  x combCa2 combx\ \vert \ x\ \text{comb} \vdash_\mathcal{C} a_2\ \text{comb}.

Consider the last rule applied in \triangledown for each of the above rule, then maybe try to modify the derivation to conclude ap(a1;a2)\mathsf{ap}(a_1;a_2).

Exercise 3.3

Problem statement. Conversion, or equivalence, of combinators is expressed by the judgment ABA \equiv B defined by the rule set E\mathcal{E} extending C\mathcal{C} as follows:

a combaa(3.16a)\frac{a \text{ comb}}{a \equiv a} \tag{3.16a}

a2a1a1a2(3.16b)\frac{a_2 \equiv a_1}{a_1 \equiv a_2} \tag{3.16b}

a1a2a2a3a1a3(3.16c)\frac{a_1 \equiv a_2 \quad a_2 \equiv a_3}{a_1 \equiv a_3} \tag{3.16c}

a1a1a2a2a1 a2a1 a2(3.16d)\frac{a_1 \equiv a_1' \quad a_2 \equiv a_2'}{a_1\ a_2 \equiv a_1'\ a_2'} \tag{3.16d}

a1 comba2 combka1a2a1(3.16e)\frac{a_1 \text{ comb} \quad a_2 \text{ comb}}{\mathsf{k} \, a_1 \, a_2 \equiv a_1} \tag{3.16e}

a1 comba2 comba3 combsa1a2a3(a1a3) (a2a3)(3.16f)\frac{a_1 \text{ comb} \quad a_2 \text{ comb} \quad a_3 \text{ comb}}{\mathsf{s} \, a_1 \, a_2 \, a_3 \equiv (a_1 \, a_3)\ (a_2 \, a_3)} \tag{3.16f}

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

xx combCEskkxxx \mid x \text{ comb} \vdash_{\mathcal{C} \cup \mathcal{E}} \mathsf{s} \, \mathsf{k} \, \mathsf{k} \, x \equiv x

Note: The combinator ap(a1;a2)\text{ap}(a_1 ;a_2 ) is written a1 a2a_1\ a_2 for short, left-associatively when used in succession.

Solution

After lifting, the ruleset E\mathcal{E} becomes:

Y  Jx combxx(3.16a)\frac{\mathcal{Y}\ \vert \ J \vdash x\ \text{comb}}{x \equiv x} \tag{3.16a}

Y  Jx2x1x1x2(3.16b)\frac{\mathcal{Y}\ \vert \ J \vdash x_2 \equiv x_1}{x_1 \equiv x_2} \tag{3.16b}

Y  Jx1x2Y  Jx2x3Y  Jx2x3(3.16c)\frac{\mathcal{Y}\ \vert \ J \vdash x_1 \equiv x_2 \quad \mathcal{Y}\ \vert \ J \vdash x_2 \equiv x_3}{\mathcal{Y}\ \vert \ J \vdash x_2 \equiv x_3} \tag{3.16c}

Y  Jx1x1Y  Jx2x2Y  Jx1 x2x1 x2(3.16d)\frac{\mathcal{Y}\ \vert \ J \vdash x_1 \equiv x_1' \quad \mathcal{Y}\ \vert \ J \vdash x_2 \equiv x_2'}{\mathcal{Y}\ \vert \ J \vdash x_1\ x_2 \equiv x_1'\ x_2'} \tag{3.16d}

Y  Jx1 combY  Jx2 combY  Jkx1x2x1(3.16e)\frac{\mathcal{Y}\ \vert \ J \vdash x_1 \text{ comb} \quad \mathcal{Y}\ \vert \ J \vdash x_2 \text{ comb}}{\mathcal{Y}\ \vert \ J \vdash \mathsf{k} \, x_1 \, x_2 \equiv x_1} \tag{3.16e}

Y  Jx1 combY  Jx2 combY  Jx3 combY  Jsx1x2x3(x1x3) (x2x3)(3.16f)\frac{\mathcal{Y}\ \vert \ J \vdash x_1 \text{ comb} \quad \mathcal{Y}\ \vert \ J \vdash x_2 \text{ comb} \quad \mathcal{Y}\ \vert \ J \vdash x_3 \text{ comb}}{\mathcal{Y}\ \vert \ J \vdash \mathsf{s} \, x_1 \, x_2 \, x_3 \equiv (x_1 \, x_3)\ (x_2 \, x_3)} \tag{3.16f}

We'll prove that:

xx combCEskkxx.x \mid x \text{ comb} \vdash_{\mathcal{C} \cup \mathcal{E}} \mathsf{s} \, \mathsf{k} \, \mathsf{k} \, x \equiv x.

x  x combk combx  x combx combx  x combs k k x(k x) (k x)x  x combx combx  x comb(k x) combx  x combs k k xx\displaystyle\frac{\displaystyle\frac{x\ \vert \ x\ \text{comb} \vdash \mathsf{k}\ \text{comb} \quad x\ \vert \ x\ \text{comb} \vdash x\ \text{comb}}{x\ \vert \ x\ \text{comb} \vdash \mathsf{s}\ \mathsf{k}\ \mathsf{k}\ x \equiv (\mathsf{k}\ x)\ (\mathsf{k}\ x)} \quad \displaystyle\frac{ x\ \vert \ x\ \text{comb} \vdash \mathsf{x}\ \text{comb}}{ x\ \vert \ x\ \text{comb} \vdash (\mathsf{k}\ x)\ \text{comb}}}{x\ \vert \ x\ \text{comb} \vdash \mathsf{s}\ \mathsf{k}\ \mathsf{k}\ x \equiv x}

Exercise 3.4

Problem statement. Show that if xx combCa combx \mid x \text{ comb} \vdash_{\mathcal{C}} a \text{ comb}, then there is a combinator aa', written [x]a[x]a and called bracket abstraction, such that:

xx combCEa xax \mid x \text{ comb} \vdash_{\mathcal{C} \cup \mathcal{E}} a'\ x \equiv a

Consequently, by Exercise 3.2, if a comba'' \text{ comb}, then:

([x]a) a[a/x]a([x]a)\ a'' \equiv [a''/x]a

Hint:

Inductively define the judgment:

xx combabsx a is ax \mid x \text{ comb} \vdash \text{abs}_x\ a \text{ is } a'

where xx comba combx \mid x \text{ comb} \vdash a \text{ comb}. Then argue that it defines aa' as a binary function of xx and aa. The motivation for the conversion axioms governing k\mathsf{k} and s\mathsf{s} should become clear while developing the proof of the desired equivalence.

  • Confusion point

    I thought a=[x]ak aa' = [x]a \equiv \mathsf{k}\ a worked for all aa and xx & spent 1 hour wondering why this problem was nontrivial.

    It turns out, because aa' is a combinator, which means a comb\vdash a'\ \text{comb}.

    If aa contains the variable xx, then, ⊬(k a) comb\not\vdash (\mathsf{k}\ a)\ \text{comb}. It's only true that x  x comb(k a) combx\ \vert \ x\ \text{comb} \vdash (\mathsf{k}\ a)\ \text{comb} .

Solution

We define abs\text{abs} as:

x  x combabsx s is k s\displaystyle\frac{}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ \mathsf{s}\ \text{is}\ \mathsf{k}\ \mathsf{s}}

x  x combabsx k is k k\displaystyle\frac{}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ \mathsf{k}\ \text{is}\ \mathsf{k}\ \mathsf{k}}

x y  x comb y combabsx y is k y\displaystyle\frac{}{x\ y\ \vert \ x\ \text{comb} \ y\ \text{comb} \vdash \text{abs}_x\ y\ \text{is}\ \mathsf{k}\ y}

x  x combabsx x is s k k x\displaystyle\frac{}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ x\ \text{is}\ \mathsf{s}\ \mathsf{k}\ \mathsf{k}\ x}

x  x combabsx a1 is a1x  x combabsx a2 is a2x  x combabsx ap a1 a2 is s a1 a2\displaystyle\frac{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ a_1\ \text{is}\ a'_1 \quad x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ a_2\ \text{is}\ a'_2}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ \text{ap}\ a_1\ a_2 \ \text{is}\ \mathsf{s}\ a_1'\ a_2'}

Exercise 3.5

Problem statement. Prove that bracket abstraction, as defined in Exercise 3.4, is non-compositional by exhibiting aa and bb such that a comba \text{ comb} and

xyx comby combCb combx \, y \mid x \text{ comb} \, y \text{ comb} \vdash_{\mathcal{C}} b \text{ comb}

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

Hint: Consider the case that bb is yy.

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)[a/y]([x]b) = [x]([a/y]b)

  • Note

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

Solution
  • If b=yb = y, then:
  • [x]b=[x]y=k y[x]b = [x]y = \mathsf{k}\ y.

-> LHS = [a/y]([x] b)=[a/y](k y)=k a[a/y]([x]\ b) = [a/y](\mathsf{k}\ y) = \mathsf{k}\ a.

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

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

It's trivial that there exists an aa being some combination of s\mathsf{s} and k\mathsf{k} such that k a[x]a\mathsf{k}\ a \neq [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=yb = y.

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

Then LHS = [a/y]([x]y)[a/y]([x]y) = [x]a[x]a = RHS for all aa such that a comb\vdash a\ \text{comb}.

  • Start with a=ka = \mathsf{k}.
  • New definition:

x  x combabsx s is k s\displaystyle\frac{}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ \mathsf{s}\ \text{is}\ \mathsf{k}\ \mathsf{s}}

x  x combabsx k is k k\displaystyle\frac{}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ \mathsf{k}\ \text{is}\ \mathsf{k}\ \mathsf{k}}

x  x combabsx x is s k k\displaystyle\frac{}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ x\ \text{is}\ \mathsf{s}\ \mathsf{k}\ \mathsf{k}}

x  x comb y combabsx y is \displaystyle\frac{}{x\ \vert \ x\ \text{comb}\ y\ \text{comb}\vdash \text{abs}_x\ y\ \text{is}\ }

x  x combabsx a1 is a1x  x combabsx a2 is a2x  x combabsx ap a1 a2 is s a1 a2\displaystyle\frac{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ a_1\ \text{is}\ a'_1 \quad x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ a_2\ \text{is}\ a'_2}{x\ \vert \ x\ \text{comb}\vdash \text{abs}_x\ \text{ap}\ a_1\ a_2 \ \text{is}\ \mathsf{s}\ a_1'\ a_2'}

Exercise 3.6

Problem statement. Consider the set B[X]\mathcal{B}[\mathcal{X}] of ABT's generated by the operators ap\text{ap}, with arity (Exp,Exp)Exp(\text{Exp}, \text{Exp})\text{Exp}, and λ\lambda, with arity (Exp.Exp)Exp(\text{Exp}.\text{Exp})\text{Exp}, and possibly involving variables in X\mathcal{X}, all of which are of sort Exp\text{Exp}.

Give an inductive definition of the judgment b closedb \text{ closed}, which specifies that bb has no free occurrences of the variables in X\mathcal{X}.

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

x1,,xnx1 closed,,xn closedb closedx_1, \dots, x_n \mid x_1 \text{ closed}, \dots, x_n \text{ closed} \vdash b \text{ closed}

in order to account for the binding of a variable by the λ\lambda 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