src/ZF/Constructible/Internalize.thy
changeset 13655 95b95cdb4704
parent 13651 ac80e101306a
child 13702 c7cf8fa66534
equal deleted inserted replaced
13654:b0d8bad27f42 13655:95b95cdb4704
    29 by simp
    29 by simp
    30 
    30 
    31 theorem Inl_reflection:
    31 theorem Inl_reflection:
    32      "REFLECTS[\<lambda>x. is_Inl(L,f(x),h(x)),
    32      "REFLECTS[\<lambda>x. is_Inl(L,f(x),h(x)),
    33                \<lambda>i x. is_Inl(**Lset(i),f(x),h(x))]"
    33                \<lambda>i x. is_Inl(**Lset(i),f(x),h(x))]"
    34 apply (simp only: is_Inl_def setclass_simps)
    34 apply (simp only: is_Inl_def)
    35 apply (intro FOL_reflections function_reflections)
    35 apply (intro FOL_reflections function_reflections)
    36 done
    36 done
    37 
    37 
    38 
    38 
    39 subsubsection{*The Formula @{term is_Inr}, Internalized*}
    39 subsubsection{*The Formula @{term is_Inr}, Internalized*}
    58 by simp
    58 by simp
    59 
    59 
    60 theorem Inr_reflection:
    60 theorem Inr_reflection:
    61      "REFLECTS[\<lambda>x. is_Inr(L,f(x),h(x)),
    61      "REFLECTS[\<lambda>x. is_Inr(L,f(x),h(x)),
    62                \<lambda>i x. is_Inr(**Lset(i),f(x),h(x))]"
    62                \<lambda>i x. is_Inr(**Lset(i),f(x),h(x))]"
    63 apply (simp only: is_Inr_def setclass_simps)
    63 apply (simp only: is_Inr_def)
    64 apply (intro FOL_reflections function_reflections)
    64 apply (intro FOL_reflections function_reflections)
    65 done
    65 done
    66 
    66 
    67 
    67 
    68 subsubsection{*The Formula @{term is_Nil}, Internalized*}
    68 subsubsection{*The Formula @{term is_Nil}, Internalized*}
    86 by simp
    86 by simp
    87 
    87 
    88 theorem Nil_reflection:
    88 theorem Nil_reflection:
    89      "REFLECTS[\<lambda>x. is_Nil(L,f(x)),
    89      "REFLECTS[\<lambda>x. is_Nil(L,f(x)),
    90                \<lambda>i x. is_Nil(**Lset(i),f(x))]"
    90                \<lambda>i x. is_Nil(**Lset(i),f(x))]"
    91 apply (simp only: is_Nil_def setclass_simps)
    91 apply (simp only: is_Nil_def)
    92 apply (intro FOL_reflections function_reflections Inl_reflection)
    92 apply (intro FOL_reflections function_reflections Inl_reflection)
    93 done
    93 done
    94 
    94 
    95 
    95 
    96 subsubsection{*The Formula @{term is_Cons}, Internalized*}
    96 subsubsection{*The Formula @{term is_Cons}, Internalized*}
   118 by simp
   118 by simp
   119 
   119 
   120 theorem Cons_reflection:
   120 theorem Cons_reflection:
   121      "REFLECTS[\<lambda>x. is_Cons(L,f(x),g(x),h(x)),
   121      "REFLECTS[\<lambda>x. is_Cons(L,f(x),g(x),h(x)),
   122                \<lambda>i x. is_Cons(**Lset(i),f(x),g(x),h(x))]"
   122                \<lambda>i x. is_Cons(**Lset(i),f(x),g(x),h(x))]"
   123 apply (simp only: is_Cons_def setclass_simps)
   123 apply (simp only: is_Cons_def)
   124 apply (intro FOL_reflections pair_reflection Inr_reflection)
   124 apply (intro FOL_reflections pair_reflection Inr_reflection)
   125 done
   125 done
   126 
   126 
   127 subsubsection{*The Formula @{term is_quasilist}, Internalized*}
   127 subsubsection{*The Formula @{term is_quasilist}, Internalized*}
   128 
   128 
   146 by simp
   146 by simp
   147 
   147 
   148 theorem quasilist_reflection:
   148 theorem quasilist_reflection:
   149      "REFLECTS[\<lambda>x. is_quasilist(L,f(x)),
   149      "REFLECTS[\<lambda>x. is_quasilist(L,f(x)),
   150                \<lambda>i x. is_quasilist(**Lset(i),f(x))]"
   150                \<lambda>i x. is_quasilist(**Lset(i),f(x))]"
   151 apply (simp only: is_quasilist_def setclass_simps)
   151 apply (simp only: is_quasilist_def)
   152 apply (intro FOL_reflections Nil_reflection Cons_reflection)
   152 apply (intro FOL_reflections Nil_reflection Cons_reflection)
   153 done
   153 done
   154 
   154 
   155 
   155 
   156 subsection{*Absoluteness for the Function @{term nth}*}
   156 subsection{*Absoluteness for the Function @{term nth}*}
   184 by simp
   184 by simp
   185 
   185 
   186 theorem hd_reflection:
   186 theorem hd_reflection:
   187      "REFLECTS[\<lambda>x. is_hd(L,f(x),g(x)), 
   187      "REFLECTS[\<lambda>x. is_hd(L,f(x),g(x)), 
   188                \<lambda>i x. is_hd(**Lset(i),f(x),g(x))]"
   188                \<lambda>i x. is_hd(**Lset(i),f(x),g(x))]"
   189 apply (simp only: is_hd_def setclass_simps)
   189 apply (simp only: is_hd_def)
   190 apply (intro FOL_reflections Nil_reflection Cons_reflection
   190 apply (intro FOL_reflections Nil_reflection Cons_reflection
   191              quasilist_reflection empty_reflection)  
   191              quasilist_reflection empty_reflection)  
   192 done
   192 done
   193 
   193 
   194 
   194 
   220 by simp
   220 by simp
   221 
   221 
   222 theorem tl_reflection:
   222 theorem tl_reflection:
   223      "REFLECTS[\<lambda>x. is_tl(L,f(x),g(x)),
   223      "REFLECTS[\<lambda>x. is_tl(L,f(x),g(x)),
   224                \<lambda>i x. is_tl(**Lset(i),f(x),g(x))]"
   224                \<lambda>i x. is_tl(**Lset(i),f(x),g(x))]"
   225 apply (simp only: is_tl_def setclass_simps)
   225 apply (simp only: is_tl_def)
   226 apply (intro FOL_reflections Nil_reflection Cons_reflection
   226 apply (intro FOL_reflections Nil_reflection Cons_reflection
   227              quasilist_reflection empty_reflection)
   227              quasilist_reflection empty_reflection)
   228 done
   228 done
   229 
   229 
   230 
   230 
   258 
   258 
   259 theorem bool_of_o_reflection:
   259 theorem bool_of_o_reflection:
   260      "REFLECTS [P(L), \<lambda>i. P(**Lset(i))] ==>
   260      "REFLECTS [P(L), \<lambda>i. P(**Lset(i))] ==>
   261       REFLECTS[\<lambda>x. is_bool_of_o(L, P(L,x), f(x)),  
   261       REFLECTS[\<lambda>x. is_bool_of_o(L, P(L,x), f(x)),  
   262                \<lambda>i x. is_bool_of_o(**Lset(i), P(**Lset(i),x), f(x))]"
   262                \<lambda>i x. is_bool_of_o(**Lset(i), P(**Lset(i),x), f(x))]"
   263 apply (simp (no_asm) only: is_bool_of_o_def setclass_simps)
   263 apply (simp (no_asm) only: is_bool_of_o_def)
   264 apply (intro FOL_reflections function_reflections, assumption+)
   264 apply (intro FOL_reflections function_reflections, assumption+)
   265 done
   265 done
   266 
   266 
   267 
   267 
   268 subsection{*More Internalizations*}
   268 subsection{*More Internalizations*}
   299       "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
   299       "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
   300        ==> sats(A, lambda_fm(p,x,y), env) <-> 
   300        ==> sats(A, lambda_fm(p,x,y), env) <-> 
   301            is_lambda(**A, nth(x,env), is_b, nth(y,env))"
   301            is_lambda(**A, nth(x,env), is_b, nth(y,env))"
   302 by (simp add: lambda_fm_def is_lambda_def is_b_iff_sats [THEN iff_sym]) 
   302 by (simp add: lambda_fm_def is_lambda_def is_b_iff_sats [THEN iff_sym]) 
   303 
   303 
   304 lemma is_lambda_iff_sats:
       
   305   assumes is_b_iff_sats: 
       
   306       "!!a0 a1 a2. 
       
   307         [|a0\<in>A; a1\<in>A; a2\<in>A|] 
       
   308         ==> is_b(a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,env))))"
       
   309   shows
       
   310   "[|nth(i,env) = x; nth(j,env) = y; 
       
   311       i \<in> nat; j \<in> nat; env \<in> list(A)|]
       
   312    ==> is_lambda(**A, x, is_b, y) <-> sats(A, lambda_fm(p,i,j), env)" 
       
   313 by (simp add: sats_lambda_fm [OF is_b_iff_sats])
       
   314 
       
   315 theorem is_lambda_reflection:
   304 theorem is_lambda_reflection:
   316   assumes is_b_reflection:
   305   assumes is_b_reflection:
   317     "!!f' f g h. REFLECTS[\<lambda>x. is_b(L, f'(x), f(x), g(x)), 
   306     "!!f' f g h. REFLECTS[\<lambda>x. is_b(L, f'(x), f(x), g(x)), 
   318                      \<lambda>i x. is_b(**Lset(i), f'(x), f(x), g(x))]"
   307                      \<lambda>i x. is_b(**Lset(i), f'(x), f(x), g(x))]"
   319   shows "REFLECTS[\<lambda>x. is_lambda(L, A(x), is_b(L,x), f(x)), 
   308   shows "REFLECTS[\<lambda>x. is_lambda(L, A(x), is_b(L,x), f(x)), 
   320                \<lambda>i x. is_lambda(**Lset(i), A(x), is_b(**Lset(i),x), f(x))]"
   309                \<lambda>i x. is_lambda(**Lset(i), A(x), is_b(**Lset(i),x), f(x))]"
   321 apply (simp (no_asm_use) only: is_lambda_def setclass_simps)
   310 apply (simp (no_asm_use) only: is_lambda_def)
   322 apply (intro FOL_reflections is_b_reflection pair_reflection)
   311 apply (intro FOL_reflections is_b_reflection pair_reflection)
   323 done
   312 done
   324 
   313 
   325 subsubsection{*The Operator @{term is_Member}, Internalized*}
   314 subsubsection{*The Operator @{term is_Member}, Internalized*}
   326 
   315 
   348 by (simp add: sats_Member_fm)
   337 by (simp add: sats_Member_fm)
   349 
   338 
   350 theorem Member_reflection:
   339 theorem Member_reflection:
   351      "REFLECTS[\<lambda>x. is_Member(L,f(x),g(x),h(x)),
   340      "REFLECTS[\<lambda>x. is_Member(L,f(x),g(x),h(x)),
   352                \<lambda>i x. is_Member(**Lset(i),f(x),g(x),h(x))]"
   341                \<lambda>i x. is_Member(**Lset(i),f(x),g(x),h(x))]"
   353 apply (simp only: is_Member_def setclass_simps)
   342 apply (simp only: is_Member_def)
   354 apply (intro FOL_reflections pair_reflection Inl_reflection)
   343 apply (intro FOL_reflections pair_reflection Inl_reflection)
   355 done
   344 done
   356 
   345 
   357 subsubsection{*The Operator @{term is_Equal}, Internalized*}
   346 subsubsection{*The Operator @{term is_Equal}, Internalized*}
   358 
   347 
   380 by (simp add: sats_Equal_fm)
   369 by (simp add: sats_Equal_fm)
   381 
   370 
   382 theorem Equal_reflection:
   371 theorem Equal_reflection:
   383      "REFLECTS[\<lambda>x. is_Equal(L,f(x),g(x),h(x)),
   372      "REFLECTS[\<lambda>x. is_Equal(L,f(x),g(x),h(x)),
   384                \<lambda>i x. is_Equal(**Lset(i),f(x),g(x),h(x))]"
   373                \<lambda>i x. is_Equal(**Lset(i),f(x),g(x),h(x))]"
   385 apply (simp only: is_Equal_def setclass_simps)
   374 apply (simp only: is_Equal_def)
   386 apply (intro FOL_reflections pair_reflection Inl_reflection Inr_reflection)
   375 apply (intro FOL_reflections pair_reflection Inl_reflection Inr_reflection)
   387 done
   376 done
   388 
   377 
   389 subsubsection{*The Operator @{term is_Nand}, Internalized*}
   378 subsubsection{*The Operator @{term is_Nand}, Internalized*}
   390 
   379 
   412 by (simp add: sats_Nand_fm)
   401 by (simp add: sats_Nand_fm)
   413 
   402 
   414 theorem Nand_reflection:
   403 theorem Nand_reflection:
   415      "REFLECTS[\<lambda>x. is_Nand(L,f(x),g(x),h(x)),
   404      "REFLECTS[\<lambda>x. is_Nand(L,f(x),g(x),h(x)),
   416                \<lambda>i x. is_Nand(**Lset(i),f(x),g(x),h(x))]"
   405                \<lambda>i x. is_Nand(**Lset(i),f(x),g(x),h(x))]"
   417 apply (simp only: is_Nand_def setclass_simps)
   406 apply (simp only: is_Nand_def)
   418 apply (intro FOL_reflections pair_reflection Inl_reflection Inr_reflection)
   407 apply (intro FOL_reflections pair_reflection Inl_reflection Inr_reflection)
   419 done
   408 done
   420 
   409 
   421 subsubsection{*The Operator @{term is_Forall}, Internalized*}
   410 subsubsection{*The Operator @{term is_Forall}, Internalized*}
   422 
   411 
   442 by (simp add: sats_Forall_fm)
   431 by (simp add: sats_Forall_fm)
   443 
   432 
   444 theorem Forall_reflection:
   433 theorem Forall_reflection:
   445      "REFLECTS[\<lambda>x. is_Forall(L,f(x),g(x)),
   434      "REFLECTS[\<lambda>x. is_Forall(L,f(x),g(x)),
   446                \<lambda>i x. is_Forall(**Lset(i),f(x),g(x))]"
   435                \<lambda>i x. is_Forall(**Lset(i),f(x),g(x))]"
   447 apply (simp only: is_Forall_def setclass_simps)
   436 apply (simp only: is_Forall_def)
   448 apply (intro FOL_reflections pair_reflection Inr_reflection)
   437 apply (intro FOL_reflections pair_reflection Inr_reflection)
   449 done
   438 done
   450 
   439 
   451 
   440 
   452 subsubsection{*The Operator @{term is_and}, Internalized*}
   441 subsubsection{*The Operator @{term is_and}, Internalized*}
   475 by simp
   464 by simp
   476 
   465 
   477 theorem is_and_reflection:
   466 theorem is_and_reflection:
   478      "REFLECTS[\<lambda>x. is_and(L,f(x),g(x),h(x)),
   467      "REFLECTS[\<lambda>x. is_and(L,f(x),g(x),h(x)),
   479                \<lambda>i x. is_and(**Lset(i),f(x),g(x),h(x))]"
   468                \<lambda>i x. is_and(**Lset(i),f(x),g(x),h(x))]"
   480 apply (simp only: is_and_def setclass_simps)
   469 apply (simp only: is_and_def)
   481 apply (intro FOL_reflections function_reflections)
   470 apply (intro FOL_reflections function_reflections)
   482 done
   471 done
   483 
   472 
   484 
   473 
   485 subsubsection{*The Operator @{term is_or}, Internalized*}
   474 subsubsection{*The Operator @{term is_or}, Internalized*}
   509 by simp
   498 by simp
   510 
   499 
   511 theorem is_or_reflection:
   500 theorem is_or_reflection:
   512      "REFLECTS[\<lambda>x. is_or(L,f(x),g(x),h(x)),
   501      "REFLECTS[\<lambda>x. is_or(L,f(x),g(x),h(x)),
   513                \<lambda>i x. is_or(**Lset(i),f(x),g(x),h(x))]"
   502                \<lambda>i x. is_or(**Lset(i),f(x),g(x),h(x))]"
   514 apply (simp only: is_or_def setclass_simps)
   503 apply (simp only: is_or_def)
   515 apply (intro FOL_reflections function_reflections)
   504 apply (intro FOL_reflections function_reflections)
   516 done
   505 done
   517 
   506 
   518 
   507 
   519 
   508 
   542 by simp
   531 by simp
   543 
   532 
   544 theorem is_not_reflection:
   533 theorem is_not_reflection:
   545      "REFLECTS[\<lambda>x. is_not(L,f(x),g(x)),
   534      "REFLECTS[\<lambda>x. is_not(L,f(x),g(x)),
   546                \<lambda>i x. is_not(**Lset(i),f(x),g(x))]"
   535                \<lambda>i x. is_not(**Lset(i),f(x),g(x))]"
   547 apply (simp only: is_not_def setclass_simps)
   536 apply (simp only: is_not_def)
   548 apply (intro FOL_reflections function_reflections)
   537 apply (intro FOL_reflections function_reflections)
   549 done
   538 done
   550 
   539 
   551 
   540 
   552 lemmas extra_reflections = 
   541 lemmas extra_reflections = 
   553     Inl_reflection Inr_reflection Nil_reflection Cons_reflection
   542     Inl_reflection Inr_reflection Nil_reflection Cons_reflection
   554     quasilist_reflection hd_reflection tl_reflection bool_of_o_reflection
   543     quasilist_reflection hd_reflection tl_reflection bool_of_o_reflection
   555     is_lambda_reflection Member_reflection Equal_reflection Nand_reflection
   544     is_lambda_reflection Member_reflection Equal_reflection Nand_reflection
   556     Forall_reflection is_and_reflection is_or_reflection is_not_reflection
   545     Forall_reflection is_and_reflection is_or_reflection is_not_reflection
   557 
       
   558 lemmas extra_iff_sats =
       
   559     Inl_iff_sats Inr_iff_sats Nil_iff_sats Cons_iff_sats quasilist_iff_sats
       
   560     hd_iff_sats tl_iff_sats is_bool_of_o_iff_sats is_lambda_iff_sats
       
   561     Member_iff_sats Equal_iff_sats Nand_iff_sats Forall_iff_sats 
       
   562     is_and_iff_sats is_or_iff_sats is_not_iff_sats
       
   563 
       
   564 
   546 
   565 subsection{*Well-Founded Recursion!*}
   547 subsection{*Well-Founded Recursion!*}
   566 
   548 
   567 subsubsection{*The Operator @{term M_is_recfun}*}
   549 subsubsection{*The Operator @{term M_is_recfun}*}
   568 
   550 
   641   assumes MH_reflection:
   623   assumes MH_reflection:
   642     "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
   624     "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
   643                      \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
   625                      \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
   644   shows "REFLECTS[\<lambda>x. M_is_recfun(L, MH(L,x), f(x), g(x), h(x)), 
   626   shows "REFLECTS[\<lambda>x. M_is_recfun(L, MH(L,x), f(x), g(x), h(x)), 
   645              \<lambda>i x. M_is_recfun(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]"
   627              \<lambda>i x. M_is_recfun(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]"
   646 apply (simp (no_asm_use) only: M_is_recfun_def setclass_simps)
   628 apply (simp (no_asm_use) only: M_is_recfun_def)
   647 apply (intro FOL_reflections function_reflections
   629 apply (intro FOL_reflections function_reflections
   648              restriction_reflection MH_reflection)
   630              restriction_reflection MH_reflection)
   649 done
   631 done
   650 
   632 
   651 subsubsection{*The Operator @{term is_wfrec}*}
   633 subsubsection{*The Operator @{term is_wfrec}*}
   652 
   634 
   653 text{*The three arguments of @{term p} are always 2, 1, 0*}
   635 text{*The three arguments of @{term p} are always 2, 1, 0;
       
   636       @{term p} is enclosed by 5 quantifiers.*}
   654 
   637 
   655 (* is_wfrec :: "[i=>o, i, [i,i,i]=>o, i, i] => o"
   638 (* is_wfrec :: "[i=>o, i, [i,i,i]=>o, i, i] => o"
   656     "is_wfrec(M,MH,r,a,z) == 
   639     "is_wfrec(M,MH,r,a,z) == 
   657       \<exists>f[M]. M_is_recfun(M,MH,r,a,f) & MH(a,f,z)" *)
   640       \<exists>f[M]. M_is_recfun(M,MH,r,a,f) & MH(a,f,z)" *)
   658 constdefs is_wfrec_fm :: "[i, i, i, i]=>i"
   641 constdefs is_wfrec_fm :: "[i, i, i, i]=>i"
   702   assumes MH_reflection:
   685   assumes MH_reflection:
   703     "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
   686     "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
   704                      \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
   687                      \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
   705   shows "REFLECTS[\<lambda>x. is_wfrec(L, MH(L,x), f(x), g(x), h(x)), 
   688   shows "REFLECTS[\<lambda>x. is_wfrec(L, MH(L,x), f(x), g(x), h(x)), 
   706                \<lambda>i x. is_wfrec(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]"
   689                \<lambda>i x. is_wfrec(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]"
   707 apply (simp (no_asm_use) only: is_wfrec_def setclass_simps)
   690 apply (simp (no_asm_use) only: is_wfrec_def)
   708 apply (intro FOL_reflections MH_reflection is_recfun_reflection)
   691 apply (intro FOL_reflections MH_reflection is_recfun_reflection)
   709 done
   692 done
   710 
   693 
   711 
   694 
   712 subsection{*For Datatypes*}
   695 subsection{*For Datatypes*}
   739 by (simp add: sats_cartprod_fm)
   722 by (simp add: sats_cartprod_fm)
   740 
   723 
   741 theorem cartprod_reflection:
   724 theorem cartprod_reflection:
   742      "REFLECTS[\<lambda>x. cartprod(L,f(x),g(x),h(x)),
   725      "REFLECTS[\<lambda>x. cartprod(L,f(x),g(x),h(x)),
   743                \<lambda>i x. cartprod(**Lset(i),f(x),g(x),h(x))]"
   726                \<lambda>i x. cartprod(**Lset(i),f(x),g(x),h(x))]"
   744 apply (simp only: cartprod_def setclass_simps)
   727 apply (simp only: cartprod_def)
   745 apply (intro FOL_reflections pair_reflection)
   728 apply (intro FOL_reflections pair_reflection)
   746 done
   729 done
   747 
   730 
   748 
   731 
   749 subsubsection{*Binary Sums, Internalized*}
   732 subsubsection{*Binary Sums, Internalized*}
   778 by simp
   761 by simp
   779 
   762 
   780 theorem sum_reflection:
   763 theorem sum_reflection:
   781      "REFLECTS[\<lambda>x. is_sum(L,f(x),g(x),h(x)),
   764      "REFLECTS[\<lambda>x. is_sum(L,f(x),g(x),h(x)),
   782                \<lambda>i x. is_sum(**Lset(i),f(x),g(x),h(x))]"
   765                \<lambda>i x. is_sum(**Lset(i),f(x),g(x),h(x))]"
   783 apply (simp only: is_sum_def setclass_simps)
   766 apply (simp only: is_sum_def)
   784 apply (intro FOL_reflections function_reflections cartprod_reflection)
   767 apply (intro FOL_reflections function_reflections cartprod_reflection)
   785 done
   768 done
   786 
   769 
   787 
   770 
   788 subsubsection{*The Operator @{term quasinat}*}
   771 subsubsection{*The Operator @{term quasinat}*}
   807 by simp
   790 by simp
   808 
   791 
   809 theorem quasinat_reflection:
   792 theorem quasinat_reflection:
   810      "REFLECTS[\<lambda>x. is_quasinat(L,f(x)),
   793      "REFLECTS[\<lambda>x. is_quasinat(L,f(x)),
   811                \<lambda>i x. is_quasinat(**Lset(i),f(x))]"
   794                \<lambda>i x. is_quasinat(**Lset(i),f(x))]"
   812 apply (simp only: is_quasinat_def setclass_simps)
   795 apply (simp only: is_quasinat_def)
   813 apply (intro FOL_reflections function_reflections)
   796 apply (intro FOL_reflections function_reflections)
   814 done
   797 done
   815 
   798 
   816 
   799 
   817 subsubsection{*The Operator @{term is_nat_case}*}
   800 subsubsection{*The Operator @{term is_nat_case}*}
   866   assumes is_b_reflection:
   849   assumes is_b_reflection:
   867     "!!h f g. REFLECTS[\<lambda>x. is_b(L, h(x), f(x), g(x)),
   850     "!!h f g. REFLECTS[\<lambda>x. is_b(L, h(x), f(x), g(x)),
   868                      \<lambda>i x. is_b(**Lset(i), h(x), f(x), g(x))]"
   851                      \<lambda>i x. is_b(**Lset(i), h(x), f(x), g(x))]"
   869   shows "REFLECTS[\<lambda>x. is_nat_case(L, f(x), is_b(L,x), g(x), h(x)),
   852   shows "REFLECTS[\<lambda>x. is_nat_case(L, f(x), is_b(L,x), g(x), h(x)),
   870                \<lambda>i x. is_nat_case(**Lset(i), f(x), is_b(**Lset(i), x), g(x), h(x))]"
   853                \<lambda>i x. is_nat_case(**Lset(i), f(x), is_b(**Lset(i), x), g(x), h(x))]"
   871 apply (simp (no_asm_use) only: is_nat_case_def setclass_simps)
   854 apply (simp (no_asm_use) only: is_nat_case_def)
   872 apply (intro FOL_reflections function_reflections
   855 apply (intro FOL_reflections function_reflections
   873              restriction_reflection is_b_reflection quasinat_reflection)
   856              restriction_reflection is_b_reflection quasinat_reflection)
   874 done
   857 done
   875 
   858 
   876 
   859 
   929     "!!f g h. REFLECTS[\<lambda>x. p(L, h(x), f(x), g(x)),
   912     "!!f g h. REFLECTS[\<lambda>x. p(L, h(x), f(x), g(x)),
   930                      \<lambda>i x. p(**Lset(i), h(x), f(x), g(x))]"
   913                      \<lambda>i x. p(**Lset(i), h(x), f(x), g(x))]"
   931  shows "REFLECTS[\<lambda>x. iterates_MH(L, p(L,x), e(x), f(x), g(x), h(x)),
   914  shows "REFLECTS[\<lambda>x. iterates_MH(L, p(L,x), e(x), f(x), g(x), h(x)),
   932                \<lambda>i x. iterates_MH(**Lset(i), p(**Lset(i),x), e(x), f(x), g(x), h(x))]"
   915                \<lambda>i x. iterates_MH(**Lset(i), p(**Lset(i),x), e(x), f(x), g(x), h(x))]"
   933 apply (simp (no_asm_use) only: iterates_MH_def)
   916 apply (simp (no_asm_use) only: iterates_MH_def)
   934 txt{*Must be careful: simplifying with @{text setclass_simps} above would
       
   935      change @{text "\<exists>gm[**Lset(i)]"} into @{text "\<exists>gm \<in> Lset(i)"}, when
       
   936      it would no longer match rule @{text is_nat_case_reflection}. *}
       
   937 apply (rule is_nat_case_reflection)
       
   938 apply (simp (no_asm_use) only: setclass_simps)
       
   939 apply (intro FOL_reflections function_reflections is_nat_case_reflection
   917 apply (intro FOL_reflections function_reflections is_nat_case_reflection
   940              restriction_reflection p_reflection)
   918              restriction_reflection p_reflection)
   941 done
   919 done
   942 
   920 
   943 
   921 
   944 
   922 subsubsection{*The Operator @{term is_iterates}*}
   945 subsubsection{*The Formula @{term is_eclose_n}, Internalized*}
   923 
   946 
   924 text{*The three arguments of @{term p} are always 2, 1, 0;
   947 (* is_eclose_n(M,A,n,Z) == 
   925       @{term p} is enclosed by 9 (??) quantifiers.*}
   948       \<exists>sn[M]. \<exists>msn[M]. 
   926 
   949        1       0
   927 (*    "is_iterates(M,isF,v,n,Z) == 
   950        successor(M,n,sn) & membership(M,sn,msn) &
   928       \<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
   951        is_wfrec(M, iterates_MH(M, big_union(M), A), msn, n, Z) *)
   929        1       0       is_wfrec(M, iterates_MH(M,isF,v), msn, n, Z)"*)
   952 
   930 
   953 constdefs eclose_n_fm :: "[i,i,i]=>i"
   931 constdefs is_iterates_fm :: "[i, i, i, i]=>i"
   954   "eclose_n_fm(A,n,Z) == 
   932  "is_iterates_fm(p,v,n,Z) == 
   955      Exists(Exists(
   933      Exists(Exists(
   956       And(succ_fm(n#+2,1),
   934       And(succ_fm(n#+2,1),
   957        And(Memrel_fm(1,0),
   935        And(Memrel_fm(1,0),
   958               is_wfrec_fm(iterates_MH_fm(big_union_fm(1,0),
   936               is_wfrec_fm(iterates_MH_fm(p, v#+7, 2, 1, 0), 
   959                                          A#+7, 2, 1, 0), 
   937                           0, n#+2, Z#+2)))))"
   960                            0, n#+2, Z#+2)))))"
   938 
       
   939 text{*We call @{term p} with arguments a, f, z by equating them with 
       
   940   the corresponding quantified variables with de Bruijn indices 2, 1, 0.*}
       
   941 
       
   942 
       
   943 lemma is_iterates_type [TC]:
       
   944      "[| p \<in> formula; x \<in> nat; y \<in> nat; z \<in> nat |] 
       
   945       ==> is_iterates_fm(p,x,y,z) \<in> formula"
       
   946 by (simp add: is_iterates_fm_def) 
       
   947 
       
   948 lemma sats_is_iterates_fm:
       
   949   assumes is_F_iff_sats:
       
   950       "!!a b c d e f g h i j k. 
       
   951               [| a \<in> A; b \<in> A; c \<in> A; d \<in> A; e \<in> A; f \<in> A; 
       
   952                  g \<in> A; h \<in> A; i \<in> A; j \<in> A; k \<in> A|]
       
   953               ==> is_F(a,b) <->
       
   954                   sats(A, p, Cons(b, Cons(a, Cons(c, Cons(d, Cons(e, Cons(f, 
       
   955                       Cons(g, Cons(h, Cons(i, Cons(j, Cons(k, env))))))))))))"
       
   956   shows 
       
   957       "[|x \<in> nat; y < length(env); z < length(env); env \<in> list(A)|]
       
   958        ==> sats(A, is_iterates_fm(p,x,y,z), env) <->
       
   959            is_iterates(**A, is_F, nth(x,env), nth(y,env), nth(z,env))"
       
   960 apply (frule_tac x=z in lt_length_in_nat, assumption)  
       
   961 apply (frule lt_length_in_nat, assumption)  
       
   962 apply (simp add: is_iterates_fm_def is_iterates_def sats_is_nat_case_fm 
       
   963               is_F_iff_sats [symmetric] sats_is_wfrec_fm sats_iterates_MH_fm)
       
   964 done
       
   965 
       
   966 
       
   967 lemma is_iterates_iff_sats:
       
   968   assumes is_F_iff_sats:
       
   969       "!!a b c d e f g h i j k. 
       
   970               [| a \<in> A; b \<in> A; c \<in> A; d \<in> A; e \<in> A; f \<in> A; 
       
   971                  g \<in> A; h \<in> A; i \<in> A; j \<in> A; k \<in> A|]
       
   972               ==> is_F(a,b) <->
       
   973                   sats(A, p, Cons(b, Cons(a, Cons(c, Cons(d, Cons(e, Cons(f, 
       
   974                       Cons(g, Cons(h, Cons(i, Cons(j, Cons(k, env))))))))))))"
       
   975   shows 
       
   976   "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
       
   977       i \<in> nat; j < length(env); k < length(env); env \<in> list(A)|]
       
   978    ==> is_iterates(**A, is_F, x, y, z) <->
       
   979        sats(A, is_iterates_fm(p,i,j,k), env)"
       
   980 by (simp add: sats_is_iterates_fm [OF is_F_iff_sats]) 
       
   981 
       
   982 text{*The second argument of @{term p} gives it direct access to @{term x},
       
   983   which is essential for handling free variable references.  Without this
       
   984   argument, we cannot prove reflection for @{term list_N}.*}
       
   985 theorem is_iterates_reflection:
       
   986   assumes p_reflection:
       
   987     "!!f g h. REFLECTS[\<lambda>x. p(L, h(x), f(x), g(x)),
       
   988                      \<lambda>i x. p(**Lset(i), h(x), f(x), g(x))]"
       
   989  shows "REFLECTS[\<lambda>x. is_iterates(L, p(L,x), f(x), g(x), h(x)),
       
   990                \<lambda>i x. is_iterates(**Lset(i), p(**Lset(i),x), f(x), g(x), h(x))]"
       
   991 apply (simp (no_asm_use) only: is_iterates_def)
       
   992 apply (intro FOL_reflections function_reflections p_reflection
       
   993              is_wfrec_reflection iterates_MH_reflection)
       
   994 done
       
   995 
       
   996 
       
   997 subsubsection{*The Formula @{term is_eclose_n}, Internalized*}
       
   998 
       
   999 (* is_eclose_n(M,A,n,Z) == is_iterates(M, big_union(M), A, n, Z) *)
       
  1000 
       
  1001 constdefs eclose_n_fm :: "[i,i,i]=>i"
       
  1002   "eclose_n_fm(A,n,Z) == is_iterates_fm(big_union_fm(1,0), A, n, Z)"
   961 
  1003 
   962 lemma eclose_n_fm_type [TC]:
  1004 lemma eclose_n_fm_type [TC]:
   963  "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> eclose_n_fm(x,y,z) \<in> formula"
  1005  "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> eclose_n_fm(x,y,z) \<in> formula"
   964 by (simp add: eclose_n_fm_def)
  1006 by (simp add: eclose_n_fm_def)
   965 
  1007 
   967    "[| x \<in> nat; y < length(env); z < length(env); env \<in> list(A)|]
  1009    "[| x \<in> nat; y < length(env); z < length(env); env \<in> list(A)|]
   968     ==> sats(A, eclose_n_fm(x,y,z), env) <->
  1010     ==> sats(A, eclose_n_fm(x,y,z), env) <->
   969         is_eclose_n(**A, nth(x,env), nth(y,env), nth(z,env))"
  1011         is_eclose_n(**A, nth(x,env), nth(y,env), nth(z,env))"
   970 apply (frule_tac x=z in lt_length_in_nat, assumption)  
  1012 apply (frule_tac x=z in lt_length_in_nat, assumption)  
   971 apply (frule_tac x=y in lt_length_in_nat, assumption)  
  1013 apply (frule_tac x=y in lt_length_in_nat, assumption)  
   972 apply (simp add: eclose_n_fm_def is_eclose_n_def sats_is_wfrec_fm 
  1014 apply (simp add: eclose_n_fm_def is_eclose_n_def 
   973                  sats_iterates_MH_fm) 
  1015                  sats_is_iterates_fm) 
   974 done
  1016 done
   975 
  1017 
   976 lemma eclose_n_iff_sats:
  1018 lemma eclose_n_iff_sats:
   977       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
  1019       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
   978           i \<in> nat; j < length(env); k < length(env); env \<in> list(A)|]
  1020           i \<in> nat; j < length(env); k < length(env); env \<in> list(A)|]
   980 by (simp add: sats_eclose_n_fm)
  1022 by (simp add: sats_eclose_n_fm)
   981 
  1023 
   982 theorem eclose_n_reflection:
  1024 theorem eclose_n_reflection:
   983      "REFLECTS[\<lambda>x. is_eclose_n(L, f(x), g(x), h(x)),  
  1025      "REFLECTS[\<lambda>x. is_eclose_n(L, f(x), g(x), h(x)),  
   984                \<lambda>i x. is_eclose_n(**Lset(i), f(x), g(x), h(x))]"
  1026                \<lambda>i x. is_eclose_n(**Lset(i), f(x), g(x), h(x))]"
   985 apply (simp only: is_eclose_n_def setclass_simps)
  1027 apply (simp only: is_eclose_n_def)
   986 apply (intro FOL_reflections function_reflections is_wfrec_reflection 
  1028 apply (intro FOL_reflections function_reflections is_iterates_reflection) 
   987              iterates_MH_reflection) 
       
   988 done
  1029 done
   989 
  1030 
   990 
  1031 
   991 subsubsection{*Membership in @{term "eclose(A)"}*}
  1032 subsubsection{*Membership in @{term "eclose(A)"}*}
   992 
  1033 
  1015 by simp
  1056 by simp
  1016 
  1057 
  1017 theorem mem_eclose_reflection:
  1058 theorem mem_eclose_reflection:
  1018      "REFLECTS[\<lambda>x. mem_eclose(L,f(x),g(x)),
  1059      "REFLECTS[\<lambda>x. mem_eclose(L,f(x),g(x)),
  1019                \<lambda>i x. mem_eclose(**Lset(i),f(x),g(x))]"
  1060                \<lambda>i x. mem_eclose(**Lset(i),f(x),g(x))]"
  1020 apply (simp only: mem_eclose_def setclass_simps)
  1061 apply (simp only: mem_eclose_def)
  1021 apply (intro FOL_reflections finite_ordinal_reflection eclose_n_reflection)
  1062 apply (intro FOL_reflections finite_ordinal_reflection eclose_n_reflection)
  1022 done
  1063 done
  1023 
  1064 
  1024 
  1065 
  1025 subsubsection{*The Predicate ``Is @{term "eclose(A)"}''*}
  1066 subsubsection{*The Predicate ``Is @{term "eclose(A)"}''*}
  1045 by simp
  1086 by simp
  1046 
  1087 
  1047 theorem is_eclose_reflection:
  1088 theorem is_eclose_reflection:
  1048      "REFLECTS[\<lambda>x. is_eclose(L,f(x),g(x)),
  1089      "REFLECTS[\<lambda>x. is_eclose(L,f(x),g(x)),
  1049                \<lambda>i x. is_eclose(**Lset(i),f(x),g(x))]"
  1090                \<lambda>i x. is_eclose(**Lset(i),f(x),g(x))]"
  1050 apply (simp only: is_eclose_def setclass_simps)
  1091 apply (simp only: is_eclose_def)
  1051 apply (intro FOL_reflections mem_eclose_reflection)
  1092 apply (intro FOL_reflections mem_eclose_reflection)
  1052 done
  1093 done
  1053 
  1094 
  1054 
  1095 
  1055 subsubsection{*The List Functor, Internalized*}
  1096 subsubsection{*The List Functor, Internalized*}
  1080 by simp
  1121 by simp
  1081 
  1122 
  1082 theorem list_functor_reflection:
  1123 theorem list_functor_reflection:
  1083      "REFLECTS[\<lambda>x. is_list_functor(L,f(x),g(x),h(x)),
  1124      "REFLECTS[\<lambda>x. is_list_functor(L,f(x),g(x),h(x)),
  1084                \<lambda>i x. is_list_functor(**Lset(i),f(x),g(x),h(x))]"
  1125                \<lambda>i x. is_list_functor(**Lset(i),f(x),g(x),h(x))]"
  1085 apply (simp only: is_list_functor_def setclass_simps)
  1126 apply (simp only: is_list_functor_def)
  1086 apply (intro FOL_reflections number1_reflection
  1127 apply (intro FOL_reflections number1_reflection
  1087              cartprod_reflection sum_reflection)
  1128              cartprod_reflection sum_reflection)
  1088 done
  1129 done
  1089 
  1130 
  1090 
  1131 
  1091 subsubsection{*The Formula @{term is_list_N}, Internalized*}
  1132 subsubsection{*The Formula @{term is_list_N}, Internalized*}
  1092 
  1133 
  1093 (* "is_list_N(M,A,n,Z) == 
  1134 (* "is_list_N(M,A,n,Z) == 
  1094       \<exists>zero[M]. \<exists>sn[M]. \<exists>msn[M]. 
  1135       \<exists>zero[M]. empty(M,zero) & 
  1095        empty(M,zero) & 
  1136                 is_iterates(M, is_list_functor(M,A), zero, n, Z)" *)
  1096        successor(M,n,sn) & membership(M,sn,msn) &
  1137 
  1097        is_wfrec(M, iterates_MH(M, is_list_functor(M,A),zero), msn, n, Z)" *)
       
  1098   
       
  1099 constdefs list_N_fm :: "[i,i,i]=>i"
  1138 constdefs list_N_fm :: "[i,i,i]=>i"
  1100   "list_N_fm(A,n,Z) == 
  1139   "list_N_fm(A,n,Z) == 
  1101      Exists(Exists(Exists(
  1140      Exists(
  1102        And(empty_fm(2),
  1141        And(empty_fm(0),
  1103          And(succ_fm(n#+3,1),
  1142            is_iterates_fm(list_functor_fm(A#+9#+3,1,0), 0, n#+1, Z#+1)))"
  1104           And(Memrel_fm(1,0),
       
  1105               is_wfrec_fm(iterates_MH_fm(list_functor_fm(A#+9#+3,1,0),
       
  1106                                          7,2,1,0), 
       
  1107                            0, n#+3, Z#+3)))))))"
       
  1108 
  1143 
  1109 lemma list_N_fm_type [TC]:
  1144 lemma list_N_fm_type [TC]:
  1110  "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> list_N_fm(x,y,z) \<in> formula"
  1145  "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> list_N_fm(x,y,z) \<in> formula"
  1111 by (simp add: list_N_fm_def)
  1146 by (simp add: list_N_fm_def)
  1112 
  1147 
  1114    "[| x \<in> nat; y < length(env); z < length(env); env \<in> list(A)|]
  1149    "[| x \<in> nat; y < length(env); z < length(env); env \<in> list(A)|]
  1115     ==> sats(A, list_N_fm(x,y,z), env) <->
  1150     ==> sats(A, list_N_fm(x,y,z), env) <->
  1116         is_list_N(**A, nth(x,env), nth(y,env), nth(z,env))"
  1151         is_list_N(**A, nth(x,env), nth(y,env), nth(z,env))"
  1117 apply (frule_tac x=z in lt_length_in_nat, assumption)  
  1152 apply (frule_tac x=z in lt_length_in_nat, assumption)  
  1118 apply (frule_tac x=y in lt_length_in_nat, assumption)  
  1153 apply (frule_tac x=y in lt_length_in_nat, assumption)  
  1119 apply (simp add: list_N_fm_def is_list_N_def sats_is_wfrec_fm 
  1154 apply (simp add: list_N_fm_def is_list_N_def sats_is_iterates_fm) 
  1120                  sats_iterates_MH_fm) 
       
  1121 done
  1155 done
  1122 
  1156 
  1123 lemma list_N_iff_sats:
  1157 lemma list_N_iff_sats:
  1124       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
  1158       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
  1125           i \<in> nat; j < length(env); k < length(env); env \<in> list(A)|]
  1159           i \<in> nat; j < length(env); k < length(env); env \<in> list(A)|]
  1127 by (simp add: sats_list_N_fm)
  1161 by (simp add: sats_list_N_fm)
  1128 
  1162 
  1129 theorem list_N_reflection:
  1163 theorem list_N_reflection:
  1130      "REFLECTS[\<lambda>x. is_list_N(L, f(x), g(x), h(x)),  
  1164      "REFLECTS[\<lambda>x. is_list_N(L, f(x), g(x), h(x)),  
  1131                \<lambda>i x. is_list_N(**Lset(i), f(x), g(x), h(x))]"
  1165                \<lambda>i x. is_list_N(**Lset(i), f(x), g(x), h(x))]"
  1132 apply (simp only: is_list_N_def setclass_simps)
  1166 apply (simp only: is_list_N_def)
  1133 apply (intro FOL_reflections function_reflections is_wfrec_reflection 
  1167 apply (intro FOL_reflections function_reflections 
  1134              iterates_MH_reflection list_functor_reflection) 
  1168              is_iterates_reflection list_functor_reflection) 
  1135 done
  1169 done
  1136 
  1170 
  1137 
  1171 
  1138 
  1172 
  1139 subsubsection{*The Predicate ``Is A List''*}
  1173 subsubsection{*The Predicate ``Is A List''*}
  1163 by simp
  1197 by simp
  1164 
  1198 
  1165 theorem mem_list_reflection:
  1199 theorem mem_list_reflection:
  1166      "REFLECTS[\<lambda>x. mem_list(L,f(x),g(x)),
  1200      "REFLECTS[\<lambda>x. mem_list(L,f(x),g(x)),
  1167                \<lambda>i x. mem_list(**Lset(i),f(x),g(x))]"
  1201                \<lambda>i x. mem_list(**Lset(i),f(x),g(x))]"
  1168 apply (simp only: mem_list_def setclass_simps)
  1202 apply (simp only: mem_list_def)
  1169 apply (intro FOL_reflections finite_ordinal_reflection list_N_reflection)
  1203 apply (intro FOL_reflections finite_ordinal_reflection list_N_reflection)
  1170 done
  1204 done
  1171 
  1205 
  1172 
  1206 
  1173 subsubsection{*The Predicate ``Is @{term "list(A)"}''*}
  1207 subsubsection{*The Predicate ``Is @{term "list(A)"}''*}
  1193 by simp
  1227 by simp
  1194 
  1228 
  1195 theorem is_list_reflection:
  1229 theorem is_list_reflection:
  1196      "REFLECTS[\<lambda>x. is_list(L,f(x),g(x)),
  1230      "REFLECTS[\<lambda>x. is_list(L,f(x),g(x)),
  1197                \<lambda>i x. is_list(**Lset(i),f(x),g(x))]"
  1231                \<lambda>i x. is_list(**Lset(i),f(x),g(x))]"
  1198 apply (simp only: is_list_def setclass_simps)
  1232 apply (simp only: is_list_def)
  1199 apply (intro FOL_reflections mem_list_reflection)
  1233 apply (intro FOL_reflections mem_list_reflection)
  1200 done
  1234 done
  1201 
  1235 
  1202 
  1236 
  1203 subsubsection{*The Formula Functor, Internalized*}
  1237 subsubsection{*The Formula Functor, Internalized*}
  1235 by simp
  1269 by simp
  1236 
  1270 
  1237 theorem formula_functor_reflection:
  1271 theorem formula_functor_reflection:
  1238      "REFLECTS[\<lambda>x. is_formula_functor(L,f(x),g(x)),
  1272      "REFLECTS[\<lambda>x. is_formula_functor(L,f(x),g(x)),
  1239                \<lambda>i x. is_formula_functor(**Lset(i),f(x),g(x))]"
  1273                \<lambda>i x. is_formula_functor(**Lset(i),f(x),g(x))]"
  1240 apply (simp only: is_formula_functor_def setclass_simps)
  1274 apply (simp only: is_formula_functor_def)
  1241 apply (intro FOL_reflections omega_reflection
  1275 apply (intro FOL_reflections omega_reflection
  1242              cartprod_reflection sum_reflection)
  1276              cartprod_reflection sum_reflection)
  1243 done
  1277 done
  1244 
  1278 
  1245 
  1279 
  1246 subsubsection{*The Formula @{term is_formula_N}, Internalized*}
  1280 subsubsection{*The Formula @{term is_formula_N}, Internalized*}
  1247 
  1281 
  1248 (* "is_formula_N(M,n,Z) == 
  1282 (*  "is_formula_N(M,n,Z) == 
  1249       \<exists>zero[M]. \<exists>sn[M]. \<exists>msn[M]. 
  1283       \<exists>zero[M]. empty(M,zero) & 
  1250           2       1       0
  1284                 is_iterates(M, is_formula_functor(M), zero, n, Z)" *) 
  1251        empty(M,zero) & 
       
  1252        successor(M,n,sn) & membership(M,sn,msn) &
       
  1253        is_wfrec(M, iterates_MH(M, is_formula_functor(M),zero), msn, n, Z)" *) 
       
  1254 constdefs formula_N_fm :: "[i,i]=>i"
  1285 constdefs formula_N_fm :: "[i,i]=>i"
  1255   "formula_N_fm(n,Z) == 
  1286   "formula_N_fm(n,Z) == 
  1256      Exists(Exists(Exists(
  1287      Exists(
  1257        And(empty_fm(2),
  1288        And(empty_fm(0),
  1258          And(succ_fm(n#+3,1),
  1289            is_iterates_fm(formula_functor_fm(1,0), 0, n#+1, Z#+1)))"
  1259           And(Memrel_fm(1,0),
       
  1260               is_wfrec_fm(iterates_MH_fm(formula_functor_fm(1,0),7,2,1,0), 
       
  1261                            0, n#+3, Z#+3)))))))"
       
  1262 
  1290 
  1263 lemma formula_N_fm_type [TC]:
  1291 lemma formula_N_fm_type [TC]:
  1264  "[| x \<in> nat; y \<in> nat |] ==> formula_N_fm(x,y) \<in> formula"
  1292  "[| x \<in> nat; y \<in> nat |] ==> formula_N_fm(x,y) \<in> formula"
  1265 by (simp add: formula_N_fm_def)
  1293 by (simp add: formula_N_fm_def)
  1266 
  1294 
  1268    "[| x < length(env); y < length(env); env \<in> list(A)|]
  1296    "[| x < length(env); y < length(env); env \<in> list(A)|]
  1269     ==> sats(A, formula_N_fm(x,y), env) <->
  1297     ==> sats(A, formula_N_fm(x,y), env) <->
  1270         is_formula_N(**A, nth(x,env), nth(y,env))"
  1298         is_formula_N(**A, nth(x,env), nth(y,env))"
  1271 apply (frule_tac x=y in lt_length_in_nat, assumption)  
  1299 apply (frule_tac x=y in lt_length_in_nat, assumption)  
  1272 apply (frule lt_length_in_nat, assumption)  
  1300 apply (frule lt_length_in_nat, assumption)  
  1273 apply (simp add: formula_N_fm_def is_formula_N_def sats_is_wfrec_fm sats_iterates_MH_fm) 
  1301 apply (simp add: formula_N_fm_def is_formula_N_def sats_is_iterates_fm) 
  1274 done
  1302 done
  1275 
  1303 
  1276 lemma formula_N_iff_sats:
  1304 lemma formula_N_iff_sats:
  1277       "[| nth(i,env) = x; nth(j,env) = y; 
  1305       "[| nth(i,env) = x; nth(j,env) = y; 
  1278           i < length(env); j < length(env); env \<in> list(A)|]
  1306           i < length(env); j < length(env); env \<in> list(A)|]
  1280 by (simp add: sats_formula_N_fm)
  1308 by (simp add: sats_formula_N_fm)
  1281 
  1309 
  1282 theorem formula_N_reflection:
  1310 theorem formula_N_reflection:
  1283      "REFLECTS[\<lambda>x. is_formula_N(L, f(x), g(x)),  
  1311      "REFLECTS[\<lambda>x. is_formula_N(L, f(x), g(x)),  
  1284                \<lambda>i x. is_formula_N(**Lset(i), f(x), g(x))]"
  1312                \<lambda>i x. is_formula_N(**Lset(i), f(x), g(x))]"
  1285 apply (simp only: is_formula_N_def setclass_simps)
  1313 apply (simp only: is_formula_N_def)
  1286 apply (intro FOL_reflections function_reflections is_wfrec_reflection 
  1314 apply (intro FOL_reflections function_reflections 
  1287              iterates_MH_reflection formula_functor_reflection) 
  1315              is_iterates_reflection formula_functor_reflection) 
  1288 done
  1316 done
  1289 
  1317 
  1290 
  1318 
  1291 
  1319 
  1292 subsubsection{*The Predicate ``Is A Formula''*}
  1320 subsubsection{*The Predicate ``Is A Formula''*}
  1315 by simp
  1343 by simp
  1316 
  1344 
  1317 theorem mem_formula_reflection:
  1345 theorem mem_formula_reflection:
  1318      "REFLECTS[\<lambda>x. mem_formula(L,f(x)),
  1346      "REFLECTS[\<lambda>x. mem_formula(L,f(x)),
  1319                \<lambda>i x. mem_formula(**Lset(i),f(x))]"
  1347                \<lambda>i x. mem_formula(**Lset(i),f(x))]"
  1320 apply (simp only: mem_formula_def setclass_simps)
  1348 apply (simp only: mem_formula_def)
  1321 apply (intro FOL_reflections finite_ordinal_reflection formula_N_reflection)
  1349 apply (intro FOL_reflections finite_ordinal_reflection formula_N_reflection)
  1322 done
  1350 done
  1323 
  1351 
  1324 
  1352 
  1325 
  1353 
  1344 by simp
  1372 by simp
  1345 
  1373 
  1346 theorem is_formula_reflection:
  1374 theorem is_formula_reflection:
  1347      "REFLECTS[\<lambda>x. is_formula(L,f(x)),
  1375      "REFLECTS[\<lambda>x. is_formula(L,f(x)),
  1348                \<lambda>i x. is_formula(**Lset(i),f(x))]"
  1376                \<lambda>i x. is_formula(**Lset(i),f(x))]"
  1349 apply (simp only: is_formula_def setclass_simps)
  1377 apply (simp only: is_formula_def)
  1350 apply (intro FOL_reflections mem_formula_reflection)
  1378 apply (intro FOL_reflections mem_formula_reflection)
  1351 done
  1379 done
  1352 
  1380 
  1353 
  1381 
  1354 subsubsection{*The Operator @{term is_transrec}*}
  1382 subsubsection{*The Operator @{term is_transrec}*}
  1411   assumes MH_reflection:
  1439   assumes MH_reflection:
  1412     "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
  1440     "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
  1413                      \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
  1441                      \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
  1414   shows "REFLECTS[\<lambda>x. is_transrec(L, MH(L,x), f(x), h(x)), 
  1442   shows "REFLECTS[\<lambda>x. is_transrec(L, MH(L,x), f(x), h(x)), 
  1415                \<lambda>i x. is_transrec(**Lset(i), MH(**Lset(i),x), f(x), h(x))]"
  1443                \<lambda>i x. is_transrec(**Lset(i), MH(**Lset(i),x), f(x), h(x))]"
  1416 apply (simp (no_asm_use) only: is_transrec_def setclass_simps)
  1444 apply (simp (no_asm_use) only: is_transrec_def)
  1417 apply (intro FOL_reflections function_reflections MH_reflection 
  1445 apply (intro FOL_reflections function_reflections MH_reflection 
  1418              is_wfrec_reflection is_eclose_reflection)
  1446              is_wfrec_reflection is_eclose_reflection)
  1419 done
  1447 done
  1420 
  1448 
  1421 end
  1449 end