equal
deleted
inserted
replaced
45 rhs_term: term, |
45 rhs_term: term, |
46 user_eqn: term |
46 user_eqn: term |
47 }; |
47 }; |
48 |
48 |
49 fun permute_args n t = list_comb (t, map Bound (0 :: (n downto 1))) |
49 fun permute_args n t = list_comb (t, map Bound (0 :: (n downto 1))) |
50 |> fold (K (fn u => Abs ("", dummyT, u))) (0 upto n); |
50 |> fold (K (fn u => Abs (Name.uu, dummyT, u))) (0 upto n); |
51 |
51 |
52 fun dissect_eqn lthy fun_names eqn' = |
52 fun dissect_eqn lthy fun_names eqn' = |
53 let |
53 let |
54 val eqn = subst_bounds (strip_qnt_vars @{const_name all} eqn' |> map Free |> rev, |
54 val eqn = subst_bounds (strip_qnt_vars @{const_name all} eqn' |> map Free |> rev, |
55 strip_qnt_body @{const_name all} eqn') |> HOLogic.dest_Trueprop |
55 strip_qnt_body @{const_name all} eqn') |> HOLogic.dest_Trueprop |
672 Abs (v, T, u)) abs_vars t); |
672 Abs (v, T, u)) abs_vars t); |
673 |
673 |
674 fun currys Ts t = if length Ts <= 1 then t else |
674 fun currys Ts t = if length Ts <= 1 then t else |
675 t $ foldr1 (fn (u, v) => HOLogic.pair_const dummyT dummyT $ u $ v) |
675 t $ foldr1 (fn (u, v) => HOLogic.pair_const dummyT dummyT $ u $ v) |
676 (length Ts - 1 downto 0 |> map Bound) |
676 (length Ts - 1 downto 0 |> map Bound) |
677 |> fold_rev (fn T => fn u => Abs ("", T, u)) Ts; |
677 |> fold_rev (fn T => fn u => Abs (Name.uu, T, u)) Ts; |
678 in |
678 in |
679 map (list_comb o rpair corec_args) corecs |
679 map (list_comb o rpair corec_args) corecs |
680 |> map2 (fn Ts => fn t => if length Ts = 0 then t $ HOLogic.unit else t) arg_Tss |
680 |> map2 (fn Ts => fn t => if length Ts = 0 then t $ HOLogic.unit else t) arg_Tss |
681 |> map2 currys arg_Tss |
681 |> map2 currys arg_Tss |
682 |> Syntax.check_terms lthy |
682 |> Syntax.check_terms lthy |
739 "define primitive corecursive functions" |
739 "define primitive corecursive functions" |
740 (Parse.opt_keyword "sequential" -- (Parse.fixes -- Parse_Spec.where_alt_specs) >> |
740 (Parse.opt_keyword "sequential" -- (Parse.fixes -- Parse_Spec.where_alt_specs) >> |
741 uncurry add_primcorec_cmd); |
741 uncurry add_primcorec_cmd); |
742 |
742 |
743 end; |
743 end; |
744 |
|