Nominal/Ex/Lambda.thy
changeset 3235 5ebd327ffb96
parent 3232 7bc38b93a1fc
child 3236 e2da10806a34
equal deleted inserted replaced
3234:08c3ef07cef7 3235:5ebd327ffb96
    70 qed
    70 qed
    71 
    71 
    72 
    72 
    73 section {* Simple examples from Norrish 2004 *}
    73 section {* Simple examples from Norrish 2004 *}
    74 
    74 
    75 nominal_primrec 
    75 nominal_function 
    76   is_app :: "lam \<Rightarrow> bool"
    76   is_app :: "lam \<Rightarrow> bool"
    77 where
    77 where
    78   "is_app (Var x) = False"
    78   "is_app (Var x) = False"
    79 | "is_app (App t1 t2) = True"
    79 | "is_app (App t1 t2) = True"
    80 | "is_app (Lam [x]. t) = False"
    80 | "is_app (Lam [x]. t) = False"
    91 thm is_app_def
    91 thm is_app_def
    92 thm is_app.eqvt
    92 thm is_app.eqvt
    93 
    93 
    94 thm eqvts
    94 thm eqvts
    95 
    95 
    96 nominal_primrec 
    96 nominal_function 
    97   rator :: "lam \<Rightarrow> lam option"
    97   rator :: "lam \<Rightarrow> lam option"
    98 where
    98 where
    99   "rator (Var x) = None"
    99   "rator (Var x) = None"
   100 | "rator (App t1 t2) = Some t1"
   100 | "rator (App t1 t2) = Some t1"
   101 | "rator (Lam [x]. t) = None"
   101 | "rator (Lam [x]. t) = None"
   106 apply(simp_all)
   106 apply(simp_all)
   107 done
   107 done
   108 
   108 
   109 termination (eqvt) by lexicographic_order
   109 termination (eqvt) by lexicographic_order
   110 
   110 
   111 nominal_primrec 
   111 nominal_function 
   112   rand :: "lam \<Rightarrow> lam option"
   112   rand :: "lam \<Rightarrow> lam option"
   113 where
   113 where
   114   "rand (Var x) = None"
   114   "rand (Var x) = None"
   115 | "rand (App t1 t2) = Some t2"
   115 | "rand (App t1 t2) = Some t2"
   116 | "rand (Lam [x]. t) = None"
   116 | "rand (Lam [x]. t) = None"
   121 apply(simp_all)
   121 apply(simp_all)
   122 done
   122 done
   123 
   123 
   124 termination (eqvt) by lexicographic_order
   124 termination (eqvt) by lexicographic_order
   125 
   125 
   126 nominal_primrec 
   126 nominal_function 
   127   is_eta_nf :: "lam \<Rightarrow> bool"
   127   is_eta_nf :: "lam \<Rightarrow> bool"
   128 where
   128 where
   129   "is_eta_nf (Var x) = True"
   129   "is_eta_nf (Var x) = True"
   130 | "is_eta_nf (App t1 t2) = (is_eta_nf t1 \<and> is_eta_nf t2)"
   130 | "is_eta_nf (App t1 t2) = (is_eta_nf t1 \<and> is_eta_nf t2)"
   131 | "is_eta_nf (Lam [x]. t) = (is_eta_nf t \<and> 
   131 | "is_eta_nf (Lam [x]. t) = (is_eta_nf t \<and> 
   152 apply(default)
   152 apply(default)
   153 apply(induct_tac "x::path" rule: path.induct)
   153 apply(induct_tac "x::path" rule: path.induct)
   154 apply(simp_all)
   154 apply(simp_all)
   155 done
   155 done
   156 
   156 
   157 nominal_primrec 
   157 nominal_function 
   158   var_pos :: "name \<Rightarrow> lam \<Rightarrow> (path list) set"
   158   var_pos :: "name \<Rightarrow> lam \<Rightarrow> (path list) set"
   159 where
   159 where
   160   "var_pos y (Var x) = (if y = x then {[]} else {})"
   160   "var_pos y (Var x) = (if y = x then {[]} else {})"
   161 | "var_pos y (App t1 t2) = (Cons Left ` (var_pos y t1)) \<union> (Cons Right ` (var_pos y t2))"
   161 | "var_pos y (App t1 t2) = (Cons Left ` (var_pos y t1)) \<union> (Cons Right ` (var_pos y t2))"
   162 | "atom x \<sharp> y \<Longrightarrow> var_pos y (Lam [x]. t) = (Cons In ` (var_pos y t))"
   162 | "atom x \<sharp> y \<Longrightarrow> var_pos y (Lam [x]. t) = (Cons In ` (var_pos y t))"
   198 done
   198 done
   199 
   199 
   200 
   200 
   201 text {* strange substitution operation *}
   201 text {* strange substitution operation *}
   202 
   202 
   203 nominal_primrec
   203 nominal_function
   204   subst' :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::== _]" [90, 90, 90] 90)
   204   subst' :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::== _]" [90, 90, 90] 90)
   205 where
   205 where
   206   "(Var x)[y ::== s] = (if x = y then s else (Var x))"
   206   "(Var x)[y ::== s] = (if x = y then s else (Var x))"
   207 | "(App t1 t2)[y ::== s] = App (t1[y ::== s]) (t2[y ::== s])"
   207 | "(App t1 t2)[y ::== s] = App (t1[y ::== s]) (t2[y ::== s])"
   208 | "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::== s] = Lam [x].(t[y ::== (App (Var y) s)])"
   208 | "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::== s] = Lam [x].(t[y ::== (App (Var y) s)])"
   232 
   232 
   233 section {* free name function *}
   233 section {* free name function *}
   234 
   234 
   235 text {* first returns an atom list *}
   235 text {* first returns an atom list *}
   236 
   236 
   237 nominal_primrec 
   237 nominal_function 
   238   frees_lst :: "lam \<Rightarrow> atom list"
   238   frees_lst :: "lam \<Rightarrow> atom list"
   239 where
   239 where
   240   "frees_lst (Var x) = [atom x]"
   240   "frees_lst (Var x) = [atom x]"
   241 | "frees_lst (App t1 t2) = frees_lst t1 @ frees_lst t2"
   241 | "frees_lst (App t1 t2) = frees_lst t1 @ frees_lst t2"
   242 | "frees_lst (Lam [x]. t) = removeAll (atom x) (frees_lst t)"
   242 | "frees_lst (Lam [x]. t) = removeAll (atom x) (frees_lst t)"
   258 lemma shows "supp t = set (frees_lst t)"
   258 lemma shows "supp t = set (frees_lst t)"
   259   by (induct t rule: frees_lst.induct) (simp_all add: lam.supp supp_at_base)
   259   by (induct t rule: frees_lst.induct) (simp_all add: lam.supp supp_at_base)
   260 
   260 
   261 text {* second returns an atom set - therefore needs an invariant *}
   261 text {* second returns an atom set - therefore needs an invariant *}
   262 
   262 
   263 nominal_primrec (invariant "\<lambda>x (y::atom set). finite y")
   263 nominal_function (invariant "\<lambda>x (y::atom set). finite y")
   264   frees_set :: "lam \<Rightarrow> atom set"
   264   frees_set :: "lam \<Rightarrow> atom set"
   265 where
   265 where
   266   "frees_set (Var x) = {atom x}"
   266   "frees_set (Var x) = {atom x}"
   267 | "frees_set (App t1 t2) = frees_set t1 \<union> frees_set t2"
   267 | "frees_set (App t1 t2) = frees_set t1 \<union> frees_set t2"
   268 | "frees_set (Lam [x]. t) = (frees_set t) - {atom x}"
   268 | "frees_set (Lam [x]. t) = (frees_set t) - {atom x}"
   286 lemma "frees_set t = supp t"
   286 lemma "frees_set t = supp t"
   287   by (induct rule: frees_set.induct) (simp_all add: lam.supp supp_at_base)
   287   by (induct rule: frees_set.induct) (simp_all add: lam.supp supp_at_base)
   288 
   288 
   289 section {* height function *}
   289 section {* height function *}
   290 
   290 
   291 nominal_primrec
   291 nominal_function
   292   height :: "lam \<Rightarrow> int"
   292   height :: "lam \<Rightarrow> int"
   293 where
   293 where
   294   "height (Var x) = 1"
   294   "height (Var x) = 1"
   295 | "height (App t1 t2) = max (height t1) (height t2) + 1"
   295 | "height (App t1 t2) = max (height t1) (height t2) + 1"
   296 | "height (Lam [x].t) = height t + 1"
   296 | "height (Lam [x].t) = height t + 1"
   309 thm height.simps
   309 thm height.simps
   310 
   310 
   311   
   311   
   312 section {* capture-avoiding substitution *}
   312 section {* capture-avoiding substitution *}
   313 
   313 
   314 nominal_primrec
   314 nominal_function
   315   subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::= _]" [90, 90, 90] 90)
   315   subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::= _]" [90, 90, 90] 90)
   316 where
   316 where
   317   "(Var x)[y ::= s] = (if x = y then s else (Var x))"
   317   "(Var x)[y ::= s] = (if x = y then s else (Var x))"
   318 | "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
   318 | "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
   319 | "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
   319 | "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
   499   shows "(p \<bullet> lookup xs n x) = lookup (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
   499   shows "(p \<bullet> lookup xs n x) = lookup (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
   500   by (induct xs arbitrary: n) (simp_all add: permute_pure)
   500   by (induct xs arbitrary: n) (simp_all add: permute_pure)
   501 
   501 
   502 text {* Function that translates lambda-terms into locally nameless terms *}
   502 text {* Function that translates lambda-terms into locally nameless terms *}
   503 
   503 
   504 nominal_primrec (invariant "\<lambda>(_, xs) y. atom ` set xs \<sharp>* y")
   504 nominal_function (invariant "\<lambda>(_, xs) y. atom ` set xs \<sharp>* y")
   505   trans :: "lam \<Rightarrow> name list \<Rightarrow> ln"
   505   trans :: "lam \<Rightarrow> name list \<Rightarrow> ln"
   506 where
   506 where
   507   "trans (Var x) xs = lookup xs 0 x"
   507   "trans (Var x) xs = lookup xs 0 x"
   508 | "trans (App t1 t2) xs = LNApp (trans t1 xs) (trans t2 xs)"
   508 | "trans (App t1 t2) xs = LNApp (trans t1 xs) (trans t2 xs)"
   509 | "atom x \<sharp> xs \<Longrightarrow> trans (Lam [x]. t) xs = LNLam (trans t (x # xs))"
   509 | "atom x \<sharp> xs \<Longrightarrow> trans (Lam [x]. t) xs = LNLam (trans t (x # xs))"
   534   by lexicographic_order
   534   by lexicographic_order
   535 
   535 
   536 
   536 
   537 text {* count the occurences of lambdas in a term *}
   537 text {* count the occurences of lambdas in a term *}
   538 
   538 
   539 nominal_primrec
   539 nominal_function
   540   cntlams :: "lam  \<Rightarrow> nat"
   540   cntlams :: "lam  \<Rightarrow> nat"
   541 where
   541 where
   542   "cntlams (Var x) = 0"
   542   "cntlams (Var x) = 0"
   543 | "cntlams (App t1 t2) = (cntlams t1) + (cntlams t2)"
   543 | "cntlams (App t1 t2) = (cntlams t1) + (cntlams t2)"
   544 | "cntlams (Lam [x]. t) = Suc (cntlams t)"
   544 | "cntlams (Lam [x]. t) = Suc (cntlams t)"
   561   by lexicographic_order
   561   by lexicographic_order
   562 
   562 
   563 
   563 
   564 text {* count the bound-variable occurences in a lambda-term *}
   564 text {* count the bound-variable occurences in a lambda-term *}
   565 
   565 
   566 nominal_primrec
   566 nominal_function
   567   cntbvs :: "lam \<Rightarrow> name list \<Rightarrow> nat"
   567   cntbvs :: "lam \<Rightarrow> name list \<Rightarrow> nat"
   568 where
   568 where
   569   "cntbvs (Var x) xs = (if x \<in> set xs then 1 else 0)"
   569   "cntbvs (Var x) xs = (if x \<in> set xs then 1 else 0)"
   570 | "cntbvs (App t1 t2) xs = (cntbvs t1 xs) + (cntbvs t2 xs)"
   570 | "cntbvs (App t1 t2) xs = (cntbvs t1 xs) + (cntbvs t2 xs)"
   571 | "atom x \<sharp> xs \<Longrightarrow> cntbvs (Lam [x]. t) xs = cntbvs t (x # xs)"
   571 | "atom x \<sharp> xs \<Longrightarrow> cntbvs (Lam [x]. t) xs = cntbvs t (x # xs)"
   619 
   619 
   620 lemma vindex_eqvt[eqvt]:
   620 lemma vindex_eqvt[eqvt]:
   621   "(p \<bullet> vindex l v n) = vindex (p \<bullet> l) (p \<bullet> v) (p \<bullet> n)"
   621   "(p \<bullet> vindex l v n) = vindex (p \<bullet> l) (p \<bullet> v) (p \<bullet> n)"
   622   by (induct l arbitrary: n) (simp_all add: permute_pure)
   622   by (induct l arbitrary: n) (simp_all add: permute_pure)
   623 
   623 
   624 nominal_primrec
   624 nominal_function
   625   transdb :: "lam \<Rightarrow> name list \<Rightarrow> db option"
   625   transdb :: "lam \<Rightarrow> name list \<Rightarrow> db option"
   626 where
   626 where
   627   "transdb (Var x) l = vindex l x 0"
   627   "transdb (Var x) l = vindex l x 0"
   628 | "transdb (App t1 t2) xs = 
   628 | "transdb (App t1 t2) xs = 
   629       Option.bind (transdb t1 xs) (\<lambda>d1. Option.bind (transdb t2 xs) (\<lambda>d2. Some (DBApp d1 d2)))"
   629       Option.bind (transdb t1 xs) (\<lambda>d1. Option.bind (transdb t2 xs) (\<lambda>d2. Some (DBApp d1 d2)))"
   677 lemma var_fresh_subst:
   677 lemma var_fresh_subst:
   678   "atom x \<sharp> s \<Longrightarrow> atom x \<sharp> (t[x ::= s])"
   678   "atom x \<sharp> s \<Longrightarrow> atom x \<sharp> (t[x ::= s])"
   679   by (induct t x s rule: subst.induct) (auto simp add: lam.supp  fresh_at_base)
   679   by (induct t x s rule: subst.induct) (auto simp add: lam.supp  fresh_at_base)
   680 
   680 
   681 (* function that evaluates a lambda term *)
   681 (* function that evaluates a lambda term *)
   682 nominal_primrec
   682 nominal_function
   683    eval :: "lam \<Rightarrow> lam" and
   683    eval :: "lam \<Rightarrow> lam" and
   684    apply_subst :: "lam \<Rightarrow> lam \<Rightarrow> lam"
   684    apply_subst :: "lam \<Rightarrow> lam \<Rightarrow> lam"
   685 where
   685 where
   686   "eval (Var x) = Var x"
   686   "eval (Var x) = Var x"
   687 | "eval (Lam [x].t) = Lam [x].(eval t)"
   687 | "eval (Lam [x].t) = Lam [x].(eval t)"
   732 done
   732 done
   733 *)
   733 *)
   734 
   734 
   735 
   735 
   736 text {* TODO: eqvt_at for the other side *}
   736 text {* TODO: eqvt_at for the other side *}
   737 nominal_primrec q where
   737 nominal_function q where
   738   "atom c \<sharp> (x, M) \<Longrightarrow> q (Lam [x]. M) (N :: lam) = Lam [x]. (Lam [c]. (App M (q (Var c) N)))"
   738   "atom c \<sharp> (x, M) \<Longrightarrow> q (Lam [x]. M) (N :: lam) = Lam [x]. (Lam [c]. (App M (q (Var c) N)))"
   739 | "q (Var x) N = Var x"
   739 | "q (Var x) N = Var x"
   740 | "q (App l r) N = App l r"
   740 | "q (App l r) N = App l r"
   741 apply(simp add: eqvt_def q_graph_aux_def)
   741 apply(simp add: eqvt_def q_graph_aux_def)
   742 apply (rule TrueI)
   742 apply (rule TrueI)
   755 apply (erule Abs_lst1_fcb)
   755 apply (erule Abs_lst1_fcb)
   756 oops
   756 oops
   757 
   757 
   758 text {* Working Examples *}
   758 text {* Working Examples *}
   759 
   759 
   760 nominal_primrec
   760 nominal_function
   761   map_term :: "(lam \<Rightarrow> lam) \<Rightarrow> lam \<Rightarrow> lam"
   761   map_term :: "(lam \<Rightarrow> lam) \<Rightarrow> lam \<Rightarrow> lam"
   762 where
   762 where
   763   "eqvt f \<Longrightarrow> map_term f (Var x) = f (Var x)"
   763   "eqvt f \<Longrightarrow> map_term f (Var x) = f (Var x)"
   764 | "eqvt f \<Longrightarrow> map_term f (App t1 t2) = App (f t1) (f t2)"
   764 | "eqvt f \<Longrightarrow> map_term f (App t1 t2) = App (f t1) (f t2)"
   765 | "eqvt f \<Longrightarrow> map_term f (Lam [x].t) = Lam [x].(f t)"
   765 | "eqvt f \<Longrightarrow> map_term f (Lam [x].t) = Lam [x].(f t)"
   819 apply(simp_all add: permute_pure)
   819 apply(simp_all add: permute_pure)
   820 done
   820 done
   821 *)
   821 *)
   822 
   822 
   823 (*
   823 (*
   824 nominal_primrec
   824 nominal_function
   825   trans2 :: "lam \<Rightarrow> atom list \<Rightarrow> db option"
   825   trans2 :: "lam \<Rightarrow> atom list \<Rightarrow> db option"
   826 where
   826 where
   827   "trans2 (Var x) xs = (index xs 0 (atom x) \<guillemotright>= (\<lambda>n::nat. Some (DBVar n)))"
   827   "trans2 (Var x) xs = (index xs 0 (atom x) \<guillemotright>= (\<lambda>n::nat. Some (DBVar n)))"
   828 | "trans2 (App t1 t2) xs = 
   828 | "trans2 (App t1 t2) xs = 
   829      ((trans2 t1 xs) \<guillemotright>= (\<lambda>db1::db. (trans2 t2 xs) \<guillemotright>= (\<lambda>db2::db. Some (DBApp db1 db2))))"
   829      ((trans2 t1 xs) \<guillemotright>= (\<lambda>db1::db. (trans2 t2 xs) \<guillemotright>= (\<lambda>db2::db. Some (DBApp db1 db2))))"
   830 | "trans2 (Lam [x].t) xs = (trans2 t (atom x # xs) \<guillemotright>= (\<lambda>db::db. Some (DBLam db)))"
   830 | "trans2 (Lam [x].t) xs = (trans2 t (atom x # xs) \<guillemotright>= (\<lambda>db::db. Some (DBLam db)))"
   831 oops
   831 oops
   832 *)
   832 *)
   833 
   833 
   834 nominal_primrec
   834 nominal_function
   835   CPS :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
   835   CPS :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
   836 where
   836 where
   837   "CPS (Var x) k = Var x"
   837   "CPS (Var x) k = Var x"
   838 | "CPS (App M N) k = CPS M (\<lambda>m. CPS N (\<lambda>n. n))"
   838 | "CPS (App M N) k = CPS M (\<lambda>m. CPS N (\<lambda>n. n))"
   839 oops
   839 oops
   840 
   840 
   841 consts b :: name
   841 consts b :: name
   842 nominal_primrec
   842 nominal_function
   843   Z :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
   843   Z :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
   844 where
   844 where
   845   "Z (App M N) k = Z M (%m. (Z N (%n.(App m n))))"
   845   "Z (App M N) k = Z M (%m. (Z N (%n.(App m n))))"
   846 | "Z (App M N) k = Z M (%m. (Z N (%n.(App (App m n) (Abs b (k (Var b)))))))"
   846 | "Z (App M N) k = Z M (%m. (Z N (%n.(App (App m n) (Abs b (k (Var b)))))))"
   847 apply(simp add: eqvt_def Z_graph_aux_def)
   847 apply(simp add: eqvt_def Z_graph_aux_def)
   869 using assms
   869 using assms
   870 by (auto simp add: fresh_star_def) 
   870 by (auto simp add: fresh_star_def) 
   871 
   871 
   872 
   872 
   873 
   873 
   874 nominal_primrec  (invariant "\<lambda>(_, _, xs) y. atom ` fst ` set xs \<sharp>* y \<and> atom ` snd ` set xs \<sharp>* y")
   874 nominal_function  (invariant "\<lambda>(_, _, xs) y. atom ` fst ` set xs \<sharp>* y \<and> atom ` snd ` set xs \<sharp>* y")
   875   aux :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool"
   875   aux :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool"
   876 where
   876 where
   877   "aux (Var x) (Var y) xs = ((x, y) \<in> set xs)"
   877   "aux (Var x) (Var y) xs = ((x, y) \<in> set xs)"
   878 | "aux (App t1 t2) (App s1 s2) xs = (aux t1 s1 xs \<and> aux t2 s2 xs)"
   878 | "aux (App t1 t2) (App s1 s2) xs = (aux t1 s1 xs \<and> aux t2 s2 xs)"
   879 | "aux (Var x) (App t1 t2) xs = False"
   879 | "aux (Var x) (App t1 t2) xs = False"
   917   and x y::"'a::at"
   917   and x y::"'a::at"
   918   shows "[[atom x]]lst. t = [[atom y]]lst. ta \<and> [[atom x]]lst. s = [[atom y]]lst. sa
   918   shows "[[atom x]]lst. t = [[atom y]]lst. ta \<and> [[atom x]]lst. s = [[atom y]]lst. sa
   919      \<longleftrightarrow> [[atom x]]lst. (t, s) = [[atom y]]lst. (ta, sa)"
   919      \<longleftrightarrow> [[atom x]]lst. (t, s) = [[atom y]]lst. (ta, sa)"
   920   by (cases "atom x = atom y") (auto simp add: Abs1_eq_iff assms fresh_Pair)
   920   by (cases "atom x = atom y") (auto simp add: Abs1_eq_iff assms fresh_Pair)
   921 
   921 
   922 nominal_primrec
   922 nominal_function
   923   aux2 :: "lam \<Rightarrow> lam \<Rightarrow> bool"
   923   aux2 :: "lam \<Rightarrow> lam \<Rightarrow> bool"
   924 where
   924 where
   925   "aux2 (Var x) (Var y) = (x = y)"
   925   "aux2 (Var x) (Var y) = (x = y)"
   926 | "aux2 (App t1 t2) (App s1 s2) = (aux2 t1 s1 \<and> aux2 t2 s2)"
   926 | "aux2 (App t1 t2) (App s1 s2) = (aux2 t1 s1 \<and> aux2 t2 s2)"
   927 | "aux2 (Var x) (App t1 t2) = False"
   927 | "aux2 (Var x) (App t1 t2) = False"
   959 text {* tests of functions containing if and case *}
   959 text {* tests of functions containing if and case *}
   960 
   960 
   961 consts P :: "lam \<Rightarrow> bool"
   961 consts P :: "lam \<Rightarrow> bool"
   962 
   962 
   963 (*
   963 (*
   964 nominal_primrec  
   964 nominal_function  
   965   A :: "lam => lam"
   965   A :: "lam => lam"
   966 where  
   966 where  
   967   "A (App M N) = (if (True \<or> P M) then (A M) else (A N))"
   967   "A (App M N) = (if (True \<or> P M) then (A M) else (A N))"
   968 | "A (Var x) = (Var x)" 
   968 | "A (Var x) = (Var x)" 
   969 | "A (App M N) = (if True then M else A N)"
   969 | "A (App M N) = (if True then M else A N)"
   970 oops
   970 oops
   971 
   971 
   972 nominal_primrec  
   972 nominal_function  
   973   C :: "lam => lam"
   973   C :: "lam => lam"
   974 where  
   974 where  
   975   "C (App M N) = (case (True \<or> P M) of True \<Rightarrow> (A M) | False \<Rightarrow> (A N))"
   975   "C (App M N) = (case (True \<or> P M) of True \<Rightarrow> (A M) | False \<Rightarrow> (A N))"
   976 | "C (Var x) = (Var x)" 
   976 | "C (Var x) = (Var x)" 
   977 | "C (App M N) = (if True then M else C N)"
   977 | "C (App M N) = (if True then M else C N)"
   978 oops
   978 oops
   979 
   979 
   980 nominal_primrec  
   980 nominal_function  
   981   A :: "lam => lam"
   981   A :: "lam => lam"
   982 where  
   982 where  
   983   "A (Lam [x].M) = (Lam [x].M)"
   983   "A (Lam [x].M) = (Lam [x].M)"
   984 | "A (Var x) = (Var x)"
   984 | "A (Var x) = (Var x)"
   985 | "A (App M N) = (if True then M else A N)"
   985 | "A (App M N) = (if True then M else A N)"
   986 oops
   986 oops
   987 
   987 
   988 nominal_primrec  
   988 nominal_function  
   989   B :: "lam => lam"
   989   B :: "lam => lam"
   990 where  
   990 where  
   991   "B (Lam [x].M) = (Lam [x].M)"
   991   "B (Lam [x].M) = (Lam [x].M)"
   992 | "B (Var x) = (Var x)"
   992 | "B (Var x) = (Var x)"
   993 | "B (App M N) = (if True then M else (B N))"
   993 | "B (App M N) = (if True then M else (B N))"