src/HOL/Tools/BNF/bnf_lfp_countable.ML
changeset 69597 ff784d5a5bfb
parent 69593 3dda49e08b9d
child 70494 41108e3e9ca5
equal deleted inserted replaced
69596:c8a2755bf220 69597:ff784d5a5bfb
    68   unfold_thms_tac ctxt @{thms inj_on_def ball_UNIV} THEN
    68   unfold_thms_tac ctxt @{thms inj_on_def ball_UNIV} THEN
    69   ALLGOALS (rtac ctxt exI THEN' rtac ctxt allI THEN' resolve_tac ctxt encode_injectives);
    69   ALLGOALS (rtac ctxt exI THEN' rtac ctxt allI THEN' resolve_tac ctxt encode_injectives);
    70 
    70 
    71 fun encode_sumN n k t =
    71 fun encode_sumN n k t =
    72   Balanced_Tree.access {init = t,
    72   Balanced_Tree.access {init = t,
    73       left = fn t => @{const sum_encode} $ (@{const Inl (nat, nat)} $ t),
    73       left = fn t => \<^const>\<open>sum_encode\<close> $ (@{const Inl (nat, nat)} $ t),
    74       right = fn t => @{const sum_encode} $ (@{const Inr (nat, nat)} $ t)}
    74       right = fn t => \<^const>\<open>sum_encode\<close> $ (@{const Inr (nat, nat)} $ t)}
    75     n k;
    75     n k;
    76 
    76 
    77 fun encode_tuple [] = \<^term>\<open>0 :: nat\<close>
    77 fun encode_tuple [] = \<^term>\<open>0 :: nat\<close>
    78   | encode_tuple ts =
    78   | encode_tuple ts =
    79     Balanced_Tree.make (fn (t, u) => @{const prod_encode} $ (@{const Pair (nat, nat)} $ u $ t)) ts;
    79     Balanced_Tree.make (fn (t, u) => \<^const>\<open>prod_encode\<close> $ (@{const Pair (nat, nat)} $ u $ t)) ts;
    80 
    80 
    81 fun mk_encode_funs ctxt fpTs ns ctrss0 recs0 =
    81 fun mk_encode_funs ctxt fpTs ns ctrss0 recs0 =
    82   let
    82   let
    83     val thy = Proof_Context.theory_of ctxt;
    83     val thy = Proof_Context.theory_of ctxt;
    84 
    84 
   179       |> HOLogic.conj_elims ctxt
   179       |> HOLogic.conj_elims ctxt
   180       |> Proof_Context.export names_ctxt ctxt
   180       |> Proof_Context.export names_ctxt ctxt
   181       |> map Thm.close_derivation
   181       |> map Thm.close_derivation
   182     end;
   182     end;
   183 
   183 
   184 fun get_countable_goal_type_name (@{const Trueprop} $ (Const (\<^const_name>\<open>Ex\<close>, _)
   184 fun get_countable_goal_type_name (\<^const>\<open>Trueprop\<close> $ (Const (\<^const_name>\<open>Ex\<close>, _)
   185     $ Abs (_, Type (_, [Type (s, _), _]), Const (\<^const_name>\<open>inj_on\<close>, _) $ Bound 0
   185     $ Abs (_, Type (_, [Type (s, _), _]), Const (\<^const_name>\<open>inj_on\<close>, _) $ Bound 0
   186         $ Const (\<^const_name>\<open>top\<close>, _)))) = s
   186         $ Const (\<^const_name>\<open>top\<close>, _)))) = s
   187   | get_countable_goal_type_name _ = error "Wrong goal format for datatype countability tactic";
   187   | get_countable_goal_type_name _ = error "Wrong goal format for datatype countability tactic";
   188 
   188 
   189 fun core_countable_datatype_tac ctxt st =
   189 fun core_countable_datatype_tac ctxt st =