Update dedukti-presentation example to Isabelle 2023

This commit is contained in:
Nicolas Méric 2023-10-10 09:54:49 +02:00
parent 989ab3c315
commit fda02be889
4 changed files with 34 additions and 30 deletions

View File

@ -178,12 +178,12 @@ ML\<open>
val A = Free ("A", propT); val A = Free ("A", propT);
val B = Free ("B", propT); val B = Free ("B", propT);
val t = Logic.mk_equals (A, B) val t = Logic.mk_equals (A, B)
val tt = ISA_core.reify_term t val tt = Meta_ISA_core.reify_term t
\<close> \<close>
declare[[ML_print_depth = 30]] declare[[ML_print_depth = 30]]
ML\<open> ML\<open>
val t = Proofterm.combination_axm val t = Proofterm.combination_axm
val tt = ISA_core.reify_proofterm t val tt = Meta_ISA_core.reify_proofterm t
(*val ttt = Value_Command.value \<^context> tt*) (*val ttt = Value_Command.value \<^context> tt*)
\<close> \<close>
@ -218,8 +218,8 @@ proof_tag :: int <= "1"
text*[instance_test::class_test, proof_tag = "2"]\<open>\<close> text*[instance_test::class_test, proof_tag = "2"]\<open>\<close>
term*\<open>proof_tag @{class-test \<open>instance_test\<close>}\<close> term*\<open>proof_tag @{class_test \<open>instance_test\<close>}\<close>
value*\<open>proof_tag @{class-test \<open>instance_test\<close>}\<close> value*\<open>proof_tag @{class_test \<open>instance_test\<close>}\<close>
ML\<open> ML\<open>
val t = @{thm "refl"} val t = @{thm "refl"}
@ -264,21 +264,21 @@ value*\<open>proof @{thm \<open>four_is_even\<close>}\<close>
ML\<open>val t = Proofterm.equal_elim_axm\<close> ML\<open>val t = Proofterm.equal_elim_axm\<close>
ML\<open> ML\<open>
val tt = ISA_core.reify_proofterm t val tt = Meta_ISA_core.reify_proofterm t
\<close> \<close>
term*\<open>@{term \<open>proof_tag @{class-test \<open>instance_test\<close>}\<close>}\<close> term*\<open>@{term \<open>proof_tag @{class_test \<open>instance_test\<close>}\<close>}\<close>
value*\<open>@{term \<open>proof_tag @{class-test \<open>instance_test\<close>}\<close>}\<close> value*\<open>@{term \<open>proof_tag @{class_test \<open>instance_test\<close>}\<close>}\<close>
fun* pattern where fun* pattern where
"pattern (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]) = "pattern (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]) =
(if be = STR ''prop'' (if be = STR ''prop''
then (Appt (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]) then (Appt (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)])
(@{term \<open>proof_tag @{class-test \<open>instance_test\<close>}\<close>})) (@{term \<open>proof_tag @{class_test \<open>instance_test\<close>}\<close>}))
else (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]))" else (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]))"
| "pattern x = x" | "pattern x = x"
@ -317,8 +317,8 @@ term\<open>
term\<open>(constT b \<rightarrow> (constT b \<rightarrow> constT b))\<close> term\<open>(constT b \<rightarrow> (constT b \<rightarrow> constT b))\<close>
term\<open>Ty STR ''fun'' [(Ty STR ''fun'' [constT b, constT b]), constT b]\<close> term\<open>Ty STR ''fun'' [(Ty STR ''fun'' [constT b, constT b]), constT b]\<close>
ML\<open> ML\<open>
val t = \<^value_>\<open>@{class-test \<open>instance_test\<close>}\<close> val t = \<^value_>\<open>@{class_test \<open>instance_test\<close>}\<close>
val tt = ISA_core.reify_term t val tt = Meta_ISA_core.reify_term t
\<close> \<close>
(*fun* pattern where*) (*fun* pattern where*)
@ -337,15 +337,15 @@ val t = \<^value_>\<open>pattern (PAxm (mk_eq' propT Core.A Core.B \<longmapsto>
\<close>*) \<close>*)
ML\<open>\<close> ML\<open>\<close>
fun* get_proof where (*fun* get_proof where
"get_proof Appt ((PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)])) "get_proof Appt ((PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]))
(Ct _) = (Ct _) =
(if be = STR ''prop'' (if be = STR ''prop''
then (Appt (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]) then (Appt (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)])
(@{term \<open>@{class-test \<open>instance_test\<close>}\<close>})) (@{term \<open>@{class_test \<open>instance_test\<close>}\<close>}))
else (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]))" else (PAxm ((Ct a (Ty ba [constT bb, (Ty bc [constT bd, constT be])])) $ c $ d) [((Var e, f), constT g), ((Var h, i), j)]))"
(*| "pattern x = (Appt x (@{term \<open>@{cc-assumption-test \<open>cc_assumption_test_ref\<close>}\<close>}))"*) (*| "pattern x = (Appt x (@{term \<open>@{cc-assumption-test \<open>cc_assumption_test_ref\<close>}\<close>}))"*)
| "get_proof x = x" | "get_proof x = x"*)
(*fun* pattern' where (*fun* pattern' where
"pattern' (AppP "pattern' (AppP

View File

@ -129,7 +129,7 @@ fun prepare_function do_print prep fixspec eqns config lthy =
(K false) (map fst fixes) (K false) (map fst fixes)
in in
(info, (info,
lthy2 |> Local_Theory.declaration {syntax = false, pervasive = false} lthy2 |> Local_Theory.declaration {syntax = false, pervasive = false, pos = \<^here>}
(fn phi => add_function_data (transform_function_data phi info))) (fn phi => add_function_data (transform_function_data phi info)))
end end
in in
@ -209,7 +209,7 @@ fun prepare_termination_proof prep_binding prep_term raw_term_opt lthy =
in in
(info', (info',
lthy2 lthy2
|> Local_Theory.declaration {syntax = false, pervasive = false} |> Local_Theory.declaration {syntax = false, pervasive = false, pos = \<^here>}
(fn phi => add_function_data (transform_function_data phi info')) (fn phi => add_function_data (transform_function_data phi info'))
|> Spec_Rules.add Binding.empty Spec_Rules.equational_recdef fs tsimps) |> Spec_Rules.add Binding.empty Spec_Rules.equational_recdef fs tsimps)
end) end)

View File

@ -260,21 +260,19 @@ fun gen_def prep_spec prep_att raw_var raw_params raw_prems ((a, raw_atts), raw_
val ((lhs, (_, raw_th)), lthy2) = lthy val ((lhs, (_, raw_th)), lthy2) = lthy
|> Local_Theory.define_internal ((b, mx), ((Binding.suffix_name "_raw" name, []), rhs)); |> Local_Theory.define_internal ((b, mx), ((Binding.suffix_name "_raw" name, []), rhs));
val th = prove lthy2 raw_th; val ([(def_name, [th])], lthy3) = lthy2
val lthy3 = lthy2 |> Spec_Rules.add name Spec_Rules.equational [lhs] [th]; |> Local_Theory.notes [((name, atts), [([prove lthy2 raw_th], [])])];
val ([(def_name, [th'])], lthy4) = lthy3 val lthy4 = lthy3
|> Local_Theory.notes [((name, atts), [([th], [])])]; |> Spec_Rules.add name Spec_Rules.equational [lhs] [th]
|> Code.declare_default_eqns [(th, true)];
val lthy5 = lthy4 val lhs' = Morphism.term (Local_Theory.target_morphism lthy4) lhs;
|> Code.declare_default_eqns [(th', true)];
val lhs' = Morphism.term (Local_Theory.target_morphism lthy5) lhs;
val _ = val _ =
Proof_Display.print_consts int (Position.thread_data ()) lthy5 Proof_Display.print_consts int (Position.thread_data ()) lthy4
(Frees.defined (Frees.build (Frees.add_frees lhs'))) [(x, T)]; (Frees.defined (Frees.build (Frees.add_frees lhs'))) [(x, T)];
in ((lhs, (def_name, th')), lthy5) end; in ((lhs, (def_name, th)), lthy4) end;
fun definition xs ys As B = gen_def check_spec_open (K I) xs ys As B false; fun definition xs ys As B = gen_def check_spec_open (K I) xs ys As B false;
val definition_cmd = gen_def read_spec_open Attrib.check_src; val definition_cmd = gen_def read_spec_open Attrib.check_src;
@ -346,7 +344,10 @@ fun gen_theorems prep_fact prep_att add_fixes
|> Attrib.partial_evaluation ctxt' |> Attrib.partial_evaluation ctxt'
|> Attrib.transform_facts (Proof_Context.export_morphism ctxt' lthy); |> Attrib.transform_facts (Proof_Context.export_morphism ctxt' lthy);
val (res, lthy') = lthy |> Local_Theory.notes_kind kind facts'; val (res, lthy') = lthy |> Local_Theory.notes_kind kind facts';
val _ = Proof_Display.print_results int (Position.thread_data ()) lthy' ((kind, ""), res); val _ =
Proof_Display.print_results
{interactive = int, pos = Position.thread_data (), proof_state = false}
lthy' ((kind, ""), res);
in (res, lthy') end; in (res, lthy') end;
in in
@ -399,6 +400,9 @@ fun gen_theorem schematic bundle_includes prep_att prep_stmt
val atts = more_atts @ map (prep_att lthy) raw_atts; val atts = more_atts @ map (prep_att lthy) raw_atts;
val pos = Position.thread_data (); val pos = Position.thread_data ();
val print_results =
Proof_Display.print_results {interactive = int, pos = pos, proof_state = false};
fun after_qed' results goal_ctxt' = fun after_qed' results goal_ctxt' =
let let
val results' = val results' =
@ -409,13 +413,13 @@ fun gen_theorem schematic bundle_includes prep_att prep_stmt
Local_Theory.notes_kind kind Local_Theory.notes_kind kind
(map2 (fn (b, _) => fn ths => (b, [(ths, [])])) stmt results') lthy; (map2 (fn (b, _) => fn ths => (b, [(ths, [])])) stmt results') lthy;
val lthy'' = val lthy'' =
if Binding.is_empty_atts (name, atts) then if Binding.is_empty_atts (name, atts)
(Proof_Display.print_results int pos lthy' ((kind, ""), res); lthy') then (print_results lthy' ((kind, ""), res); lthy')
else else
let let
val ([(res_name, _)], lthy'') = val ([(res_name, _)], lthy'') =
Local_Theory.notes_kind kind [((name, atts), [(maps #2 res, [])])] lthy'; Local_Theory.notes_kind kind [((name, atts), [(maps #2 res, [])])] lthy';
val _ = Proof_Display.print_results int pos lthy' ((kind, res_name), res); val _ = print_results lthy' ((kind, res_name), res);
in lthy'' end; in lthy'' end;
in after_qed results' lthy'' end; in after_qed results' lthy'' end;