HOL

Symmetry in HOL

Symmetry in HOL:

$\cfrac{Γ ⊢ s=u}{Γ ⊢ u=s}\texttt{SYM}$

Recall that:

1. Reflexivity of equality $\cfrac{}{⊢ t=t} REFL$

2. Transitivity of equality (could be derived from other rules, but added just for efficiency)

3. Congruence of application $s(u) = t(v)$ whenever $u=t$ ($MK_COMB$: make combinators)

4. Congruence of abstraction $λx. u = λx. v$ whenever $u=v$

5. $β$-reduction: $(λx. t)x = t$

6. Axiom rule $\lbrace p \rbrace ⊢ p$

7. Modus ponens $q$ whenever $p ⟺q$ and $p$

8. Building equivalence: $\cfrac{Γ ⊢ p \quad Δ ⊢ q}{(Γ\backslash \lbrace q \rbrace) ∪ (Δ \backslash \lbrace p \rbrace) ⊢ p ⟺ q}$

9. Instantiation of terms: $\cfrac{Γ[x_1, ⋯, x_n] ⊢ p[x_1, ⋯, x_n]}{Γ[t_1, ⋯, t_n] ⊢ p[t_1, ⋯, t_n]}$

10. Instantiation of type variables: $\cfrac{Γ[α_1, ⋯, α_n] ⊢ p[α_1, ⋯, α_n]}{Γ[γ_1, ⋯, γ_n] ⊢ p[γ_1, ⋯, γ_n]}$

And the $η$-rule can be added:

$\cfrac{}{⊢ λx.(t x) = t} \texttt{ETA} \text{ if } x ∉ fv(t)$

Let’s assume $\cfrac{}{Γ ⊢ s=u}$

We can write

$(=): ∀α, α ⟶ α ⟶ Bool$

So that:

$\cfrac{}{⊢ (=) = (=)}REFL$

and by $MK_COMB$:

$\cfrac{}{Γ ⊢ (=)s = (=)u}$

Then, by applying these functions to $s=s$ by $MK_COMB$ again:

$\cfrac{}{Γ ⊢ \underbrace{(=) \, s \, s}_{bool} ⟺ (=) \, u \, s}$

And finally, by modus ponens:

$\cfrac{}{Γ ⊢ (=) \, u \, s}$

Transitivity

Same thing for the transitivity (almost the same proof):

$\cfrac{}{⊢ (=)s = (=)s}REFL$

then, with $MK_COMB$ on our assumption $t=u$

$\cfrac{}{⊢ (=) \, s\, t = (=)\, s\, u}REFL$

then one concludes with the modus ponens on our assumption $s=t$

New beta rule

From

$\cfrac{}{⊢ (λx. t)x = t} \texttt{BETA}$

we want to derive

$\cfrac{}{⊢ (λx. t)u = t[x ← u]} \texttt{BETA'}$

Let’s begin with

$\cfrac{}{⊢ (λx. t)x = t}$

By instantiating $x ← u$:

$\cfrac{}{⊢ ((λx. t)x = t)[x ← u]}$

i.e.

$\cfrac{}{⊢ (λx. t)u = t[x ← u]}$

Implication

$p ⟹ q ≝ p ∧ q ⟺ p$

Why does it work?

Introduction

$\cfrac{Γ, p ⊢ q}{Γ ⊢ p ⟹ q} \texttt{INTRO}$

We want to prove

$\cfrac{}{Γ ⊢ \begin{cases} p ⟹ q \\ p ∧ q ⟺ p \end{cases}}$ $\cfrac{\cfrac{p ⊢ p \quad Γ, p ⊢ q}{Γ, p ⊢ p∧q} \texttt{∧-INTRO}\qquad \cfrac{p ∧ q ⊢ p ∧ q}{p ∧ q ⊢ p} \texttt{∧-Elim-left} }{Γ ⊢ \begin{cases} p ⟹ q \\ p ∧ q ⟺ p \end{cases}}$

where

$\cfrac{Γ ⊢ p \quad Δ ⊢ q}{Γ ∪ Δ ⊢ p ∧ q} \texttt{∧-INTRO}$

Elimination

We use symmetry, then modus ponens with $Δ ⊢ p$ to get $Γ ∪ Δ ⊢ p ∧ q$, and then by elim:

$Γ ∪ Δ ⊢ q$

Universal quantification $∀$

$\underbrace{∀x\underbrace{P(x)}_{α ⟶ bool}}_{bool} ≝ P = λx. ⊤$

Impredicative encoding: we can quantify over all propositions.

Let’s show

$\cfrac{}{Γ ⊢ \begin{cases} ∀x. P(x) \\ P = λx. ⊤ \end{cases}}$

under the assumption

$\cfrac{}{Γ ⊢ P(x)} \text{ when } x ∉ fv(Γ)$

With $η$-expansion:

$\cfrac{ \cfrac{ \cfrac{ \cfrac{}{ Γ ⊢ P(x) } \text{ when } x ∉ fv(Γ) }{Γ ⊢ P(x) ⟺ ⊤} }{Γ ⊢ λx. P(x) = λx. ⊤} }{Γ ⊢ \begin{cases} ∀x. P(x) \\ P = λx. ⊤ \end{cases}}$

To avoid extensionality, we could have defined:

$∀x. P(x) ≝ λx. P(x) = λx. ⊤$

The other direction:

$\cfrac{ Γ ⊢ \begin{cases} ∀x. P(x) \\ P = λx. ⊤ \end{cases} \qquad t=t} {\cfrac{ Γ ⊢ P(t) = \underbrace{(λx. ⊤)t}_{\overset{β}{=} ⊤}} { Γ ⊢ P(t) } }$

False $⊥$

$⊥ ≝ ∀ \underbrace{p}_{bool}. p$

Then: $⊥$-Elim = $∀$-Elim:

$\cfrac{Γ ⊢ ∀p.p}{Γ ⊢ p}$

Existential quantification $∃$

$∃x. P(x) ≝ ∀q. (∀x. P(x) ⟹ q) ⟹ q$

Elimination:

$\cfrac{Γ ⊢ ∃x. P(x) \qquad Δ, P(x) ⊢ C}{Γ, Δ ⊢ C} \text{ for } x ∉ fv(Δ, C)$

Introduction:

$\cfrac{ ⊢ P(t) ⟹ q \qquad ⊢ P(t) } { \cfrac{ ∀x. P(x) ⟹ q ⊢ q} {\cfrac{ ⊢ (∀x. P(x) ⟹ q) ⟹ q } { ⊢ ∃x. P(x) } }}$

In HOL, there is a (private) type thm (coming from LCF) ⟶ implemented in OCamL.

Tags:

Updated: