theory Demo02
imports Main
begin

text "lambda terms"

term "\<lambda>x. x"


text "alpha"

thm refl

lemma "(\<lambda>x. x) = (\<lambda>y. y)"
  apply (rule refl)
  done


text "eta"

term "\<lambda>x. f x"


text "beta"

term "(\<lambda>x. x y) t"


text "beta with renaming"

term "(\<lambda>z. (\<lambda>x. f x z)) x"


text "definitions and unfold"

definition
  my_true :: "'a \<Rightarrow> 'b \<Rightarrow> 'a"
  where "my_true \<equiv> \<lambda>x y. x"

definition
  my_false :: "'a \<Rightarrow> 'b \<Rightarrow> 'b"
  where "my_false \<equiv> \<lambda>x y. y"

definition
  my_if :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'c"
  where "my_if \<equiv> \<lambda>z x y. z x y"

text "unfolding a definition"

lemma "my_true = (\<lambda>x y. x)"
  unfolding my_true_def
  apply (rule refl)
  done

lemma "my_if my_false x y = y"
  unfolding my_if_def my_false_def
  apply (rule refl)
  done

end
