(* 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 \\<^sub>\ x" proof - have "\ \ x \\<^sub>\ 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 \\<^sub>\ Abs (Abs (lift (lift g 0) 0 \ (Var 1 \ Var 0)))" proof - have "\ \ g \\<^sub>\ 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 \\<^sub>\\<^sup>* Abs (lift g 0 \ (lift f 0 \ Var 0))" proof - have "\ \ g \ f \\<^sub>\\<^sup>* Abs (Abs (lift (lift g 0) 0 \ (Var 1 \ Var 0))) \ f" using B_eval1 by blast also have "... \\<^sub>\ 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 \\<^sub>\\<^sup>* g \ (f \ x)" proof - have "\ \ g \ f \ x \\<^sub>\\<^sup>* Abs (lift g 0 \ (lift f 0 \ Var 0)) \ x" using B_eval2 by blast also have "... \\<^sub>\ (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 \\<^sub>\ Abs (Var 0 \ lift x 0)" proof - have "\ \ x \\<^sub>\ Abs (Var 0 \ Var 1) [x/0]" unfolding T_def .. then show ?thesis by simp qed lemma T_eval: "\ \ x \ f \\<^sub>\\<^sup>* f \ x" proof - have "\ \ x \ f \\<^sub>\\<^sup>* Abs (Var 0 \ lift x 0) \ f" using T_eval1 by blast also have "... \\<^sub>\ (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