Theory Combinators

(* Author: Joshua Schneider, ETH Zurich *)

subsection ‹Combinators defined as closed lambda terms›

theory Combinators
imports Beta_Eta
begin

definition I_def: " = Abs (Var 0)"
definition B_def: " = Abs (Abs (Abs (Var 2 ° (Var 1 ° Var 0))))"
definition T_def: "𝒯 = Abs (Abs (Var 0 ° Var 1))" ― ‹reverse application›

lemma I_eval: " ° x β x"
proof -
  have " ° x β Var 0[x/0]" unfolding I_def ..
  then show ?thesis by simp
qed

lemma I_equiv[iff]: " ° x  x"
using I_eval ..

lemma I_closed[simp]: "liftn n  k = "
unfolding I_def by simp

lemma B_eval1: " ° g β Abs (Abs (lift (lift g 0) 0 ° (Var 1 ° Var 0)))"
proof -
  have " ° g β Abs (Abs (Var 2 ° (Var 1 ° Var 0))) [g/0]" unfolding B_def ..
  then show ?thesis by (simp add: numerals)
qed

lemma B_eval2: " ° g ° f β* Abs (lift g 0 ° (lift f 0 ° Var 0))"
proof -
  have " ° g ° f β* Abs (Abs (lift (lift g 0) 0 ° (Var 1 ° Var 0))) ° f"
    using B_eval1 by blast
  also have "... β Abs (lift (lift g 0) 0 ° (Var 1 ° Var 0)) [f/0]" ..
  also have "... = Abs (lift g 0 ° (lift f 0 ° Var 0))" by simp
  finally show ?thesis .
qed

lemma B_eval: " ° g ° f ° x β* g ° (f ° x)"
proof -
  have " ° g ° f ° x β* Abs (lift g 0 ° (lift f 0 ° Var 0)) ° x"
    using B_eval2 by blast
  also have "... β (lift g 0 ° (lift f 0 ° Var 0)) [x/0]" ..
  also have "... = g ° (f ° x)" by simp
  finally show ?thesis .
qed

lemma B_equiv[iff]: " ° g ° f ° x  g ° (f ° x)"
using B_eval ..

lemma B_closed[simp]: "liftn n  k = "
unfolding B_def by simp

lemma T_eval1: "𝒯 ° x β Abs (Var 0 ° lift x 0)"
proof -
  have "𝒯 ° x β Abs (Var 0 ° Var 1) [x/0]" unfolding T_def ..
  then show ?thesis by simp
qed

lemma T_eval: "𝒯 ° x ° f β* f ° x"
proof -
  have "𝒯 ° x ° f β* Abs (Var 0 ° lift x 0) ° f"
    using T_eval1 by blast
  also have "... β (Var 0 ° lift x 0) [f/0]" ..
  also have "... = f ° x" by simp
  finally show ?thesis .
qed

lemma T_equiv[iff]: "𝒯 ° x ° f  f ° x"
using T_eval ..

lemma T_closed[simp]: "liftn n 𝒯 k = 𝒯"
unfolding T_def by simp

end