src/HOLCF/ex/Coind.ML
changeset 1043 ffa68eb2730b
parent 892 d0dc8d057929
child 1168 74be52691d62
equal deleted inserted replaced
1042:04ef9b8ef1af 1043:ffa68eb2730b
    22 (* ------------------------------------------------------------------------- *)
    22 (* ------------------------------------------------------------------------- *)
    23 (* recursive  properties                                                     *)
    23 (* recursive  properties                                                     *)
    24 (* ------------------------------------------------------------------------- *)
    24 (* ------------------------------------------------------------------------- *)
    25 
    25 
    26 
    26 
    27 qed_goal "from" Coind.thy "from[n] = scons[n][from[dsucc[n]]]"
    27 val from = prove_goal Coind.thy "from[n] = scons[n][from[dsucc[n]]]"
    28  (fn prems =>
    28  (fn prems =>
    29 	[
    29 	[
    30 	(rtac trans 1),
    30 	(rtac trans 1),
    31 	(rtac (from_def2 RS ssubst) 1),
    31 	(rtac (from_def2 RS ssubst) 1),
    32 	(simp_tac HOLCF_ss  1),
    32 	(simp_tac HOLCF_ss  1),
    33 	(rtac refl 1)
    33 	(rtac refl 1)
    34 	]);
    34 	]);
    35 
    35 
    36 
    36 
    37 qed_goal "from1" Coind.thy "from[UU] = UU"
    37 val from1 = prove_goal Coind.thy "from[UU] = UU"
    38  (fn prems =>
    38  (fn prems =>
    39 	[
    39 	[
    40 	(rtac trans 1),
    40 	(rtac trans 1),
    41 	(rtac (from RS ssubst) 1),
    41 	(rtac (from RS ssubst) 1),
    42 	(resolve_tac  stream_constrdef 1),
    42 	(resolve_tac  stream_constrdef 1),
    51 (* the example                                                               *)
    51 (* the example                                                               *)
    52 (* prove:        nats = from[dzero]                                          *)
    52 (* prove:        nats = from[dzero]                                          *)
    53 (* ------------------------------------------------------------------------- *)
    53 (* ------------------------------------------------------------------------- *)
    54 
    54 
    55 
    55 
    56 qed_goal "coind_lemma1" Coind.thy "iterator[n][smap[dsucc]][nats] =\
    56 val coind_lemma1 = prove_goal Coind.thy "iterator[n][smap[dsucc]][nats] =\
    57 \		 scons[n][iterator[dsucc[n]][smap[dsucc]][nats]]"
    57 \		 scons[n][iterator[dsucc[n]][smap[dsucc]][nats]]"
    58  (fn prems =>
    58  (fn prems =>
    59 	[
    59 	[
    60 	(res_inst_tac [("s","n")] dnat_ind 1),
    60 	(res_inst_tac [("s","n")] dnat_ind 1),
    61 	(simp_tac (HOLCF_ss addsimps (coind_rews @ stream_rews)) 1),
    61 	(simp_tac (HOLCF_ss addsimps (coind_rews @ stream_rews)) 1),
    72 	(rtac cfun_arg_cong 1),
    72 	(rtac cfun_arg_cong 1),
    73 	(asm_simp_tac (HOLCF_ss addsimps ([iterator3 RS sym] @ dnat_rews)) 1)
    73 	(asm_simp_tac (HOLCF_ss addsimps ([iterator3 RS sym] @ dnat_rews)) 1)
    74 	]);
    74 	]);
    75 
    75 
    76 
    76 
    77 qed_goal "nats_eq_from" Coind.thy "nats = from[dzero]"
    77 val nats_eq_from = prove_goal Coind.thy "nats = from[dzero]"
    78  (fn prems =>
    78  (fn prems =>
    79 	[
    79 	[
    80 	(res_inst_tac [("R",
    80 	(res_inst_tac [("R",
    81 "% p q.? n. p = iterator[n][smap[dsucc]][nats] & q = from[n]")] stream_coind 1),
    81 "% p q.? n. p = iterator[n][smap[dsucc]][nats] & q = from[n]")] stream_coind 1),
    82 	(res_inst_tac [("x","dzero")] exI 2),
    82 	(res_inst_tac [("x","dzero")] exI 2),
    88 	(rtac disjI1 1),
    88 	(rtac disjI1 1),
    89 	(asm_simp_tac (HOLCF_ss addsimps coind_rews) 1),
    89 	(asm_simp_tac (HOLCF_ss addsimps coind_rews) 1),
    90 	(rtac disjI2 1),
    90 	(rtac disjI2 1),
    91 	(etac conjE 1),
    91 	(etac conjE 1),
    92 	(hyp_subst_tac 1),
    92 	(hyp_subst_tac 1),
    93 	(hyp_subst_tac 1),
       
    94 	(res_inst_tac [("x","n")] exI 1),
    93 	(res_inst_tac [("x","n")] exI 1),
    95 	(res_inst_tac [("x","iterator[dsucc[n]][smap[dsucc]][nats]")] exI 1),
    94 	(res_inst_tac [("x","iterator[dsucc[n]][smap[dsucc]][nats]")] exI 1),
    96 	(res_inst_tac [("x","from[dsucc[n]]")] exI 1),
    95 	(res_inst_tac [("x","from[dsucc[n]]")] exI 1),
    97 	(etac conjI 1),
    96 	(etac conjI 1),
    98 	(rtac conjI 1),
    97 	(rtac conjI 1),
   103 	(fast_tac HOL_cs 1)
   102 	(fast_tac HOL_cs 1)
   104 	]);
   103 	]);
   105 
   104 
   106 (* another proof using stream_coind_lemma2 *)
   105 (* another proof using stream_coind_lemma2 *)
   107 
   106 
   108 qed_goal "nats_eq_from" Coind.thy "nats = from[dzero]"
   107 val nats_eq_from = prove_goal Coind.thy "nats = from[dzero]"
   109  (fn prems =>
   108  (fn prems =>
   110 	[
   109 	[
   111 	(res_inst_tac [("R","% p q.? n. p = \
   110 	(res_inst_tac [("R","% p q.? n. p = \
   112 \	iterator[n][smap[dsucc]][nats] & q = from[n]")] stream_coind 1),
   111 \	iterator[n][smap[dsucc]][nats] & q = from[n]")] stream_coind 1),
   113 	(rtac stream_coind_lemma2 1),
   112 	(rtac stream_coind_lemma2 1),
   116 	(res_inst_tac [("Q","n=UU")] classical2 1),
   115 	(res_inst_tac [("Q","n=UU")] classical2 1),
   117 	(asm_simp_tac (HOLCF_ss addsimps coind_rews) 1),
   116 	(asm_simp_tac (HOLCF_ss addsimps coind_rews) 1),
   118 	(res_inst_tac [("x","UU::dnat")] exI 1),
   117 	(res_inst_tac [("x","UU::dnat")] exI 1),
   119 	(simp_tac (HOLCF_ss addsimps coind_rews addsimps stream_rews) 1),
   118 	(simp_tac (HOLCF_ss addsimps coind_rews addsimps stream_rews) 1),
   120 	(etac conjE 1),
   119 	(etac conjE 1),
   121 	(hyp_subst_tac 1),
       
   122 	(hyp_subst_tac 1),
   120 	(hyp_subst_tac 1),
   123 	(rtac conjI 1),
   121 	(rtac conjI 1),
   124 	(rtac (coind_lemma1 RS ssubst) 1),
   122 	(rtac (coind_lemma1 RS ssubst) 1),
   125 	(rtac (from RS ssubst) 1),
   123 	(rtac (from RS ssubst) 1),
   126 	(asm_simp_tac (HOLCF_ss addsimps stream_rews) 1),
   124 	(asm_simp_tac (HOLCF_ss addsimps stream_rews) 1),