374 |
374 |
375 \begin{quotation} |
375 \begin{quotation} |
376 \verb|Sign.declare_const: Markup.property list -> bstring * typ * mixfix|\isasep\isanewline% |
376 \verb|Sign.declare_const: Markup.property list -> bstring * typ * mixfix|\isasep\isanewline% |
377 \verb| -> theory -> term * theory| |
377 \verb| -> theory -> term * theory| |
378 |
378 |
379 \verb|Thm.add_def: bool -> bstring * term -> theory -> thm * theory| |
379 \verb|Thm.add_def: bool -> bool -> bstring * term -> theory -> thm * theory| |
380 \end{quotation} |
380 \end{quotation} |
381 |
381 |
382 Written with naive application, an addition of constant |
382 Written with naive application, an addition of constant |
383 \isa{bar} with type \isa{foo\ {\isasymRightarrow}\ foo} and |
383 \isa{bar} with type \isa{foo\ {\isasymRightarrow}\ foo} and |
384 a corresponding definition \isa{bar\ {\isasymequiv}\ {\isasymlambda}x{\isachardot}\ x} would look like: |
384 a corresponding definition \isa{bar\ {\isasymequiv}\ {\isasymlambda}x{\isachardot}\ x} would look like: |
385 |
385 |
386 \begin{quotation} |
386 \begin{quotation} |
387 \verb|(fn (t, thy) => Thm.add_def false|\isasep\isanewline% |
387 \verb|(fn (t, thy) => Thm.add_def false false|\isasep\isanewline% |
388 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})) thy)|\isasep\isanewline% |
388 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})) thy)|\isasep\isanewline% |
389 \verb| (Sign.declare_const []|\isasep\isanewline% |
389 \verb| (Sign.declare_const []|\isasep\isanewline% |
390 \verb| ("bar", @{typ "foo => foo"}, NoSyn) thy)| |
390 \verb| ("bar", @{typ "foo => foo"}, NoSyn) thy)| |
391 \end{quotation} |
391 \end{quotation} |
392 |
392 |
401 for more convenient notation, most notably reverse application: |
401 for more convenient notation, most notably reverse application: |
402 \begin{quotation} |
402 \begin{quotation} |
403 \verb|thy|\isasep\isanewline% |
403 \verb|thy|\isasep\isanewline% |
404 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
404 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
405 \verb||\verb,|,\verb|> (fn (t, thy) => thy|\isasep\isanewline% |
405 \verb||\verb,|,\verb|> (fn (t, thy) => thy|\isasep\isanewline% |
406 \verb||\verb,|,\verb|> Thm.add_def false|\isasep\isanewline% |
406 \verb||\verb,|,\verb|> Thm.add_def false false|\isasep\isanewline% |
407 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})))| |
407 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})))| |
408 \end{quotation}% |
408 \end{quotation}% |
409 \end{isamarkuptext}% |
409 \end{isamarkuptext}% |
410 \isamarkuptrue% |
410 \isamarkuptrue% |
411 % |
411 % |
438 set of combinators is at hand, most notably \verb|op |\verb,|,\verb|->| |
438 set of combinators is at hand, most notably \verb|op |\verb,|,\verb|->| |
439 which allows curried access to side results: |
439 which allows curried access to side results: |
440 \begin{quotation} |
440 \begin{quotation} |
441 \verb|thy|\isasep\isanewline% |
441 \verb|thy|\isasep\isanewline% |
442 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
442 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
443 \verb||\verb,|,\verb|-> (fn t => Thm.add_def false|\isasep\isanewline% |
443 \verb||\verb,|,\verb|-> (fn t => Thm.add_def false false|\isasep\isanewline% |
444 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})))|\isasep\isanewline% |
444 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})))|\isasep\isanewline% |
445 |
445 |
446 \end{quotation} |
446 \end{quotation} |
447 |
447 |
448 \noindent \verb|op |\verb,|,\verb|>>| allows for processing side results on their own: |
448 \noindent \verb|op |\verb,|,\verb|>>| allows for processing side results on their own: |
449 \begin{quotation} |
449 \begin{quotation} |
450 \verb|thy|\isasep\isanewline% |
450 \verb|thy|\isasep\isanewline% |
451 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
451 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
452 \verb||\verb,|,\verb|>> (fn t => Logic.mk_equals (t, @{term "%x. x"}))|\isasep\isanewline% |
452 \verb||\verb,|,\verb|>> (fn t => Logic.mk_equals (t, @{term "%x. x"}))|\isasep\isanewline% |
453 \verb||\verb,|,\verb|-> (fn def => Thm.add_def false ("bar_def", def))|\isasep\isanewline% |
453 \verb||\verb,|,\verb|-> (fn def => Thm.add_def false false ("bar_def", def))|\isasep\isanewline% |
454 |
454 |
455 \end{quotation} |
455 \end{quotation} |
456 |
456 |
457 \noindent Orthogonally, \verb|op |\verb,|,\verb||\verb,|,\verb|>| applies a transformation |
457 \noindent Orthogonally, \verb|op |\verb,|,\verb||\verb,|,\verb|>| applies a transformation |
458 in the presence of side results which are left unchanged: |
458 in the presence of side results which are left unchanged: |
459 \begin{quotation} |
459 \begin{quotation} |
460 \verb|thy|\isasep\isanewline% |
460 \verb|thy|\isasep\isanewline% |
461 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
461 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
462 \verb||\verb,|,\verb||\verb,|,\verb|> Sign.add_path "foobar"|\isasep\isanewline% |
462 \verb||\verb,|,\verb||\verb,|,\verb|> Sign.add_path "foobar"|\isasep\isanewline% |
463 \verb||\verb,|,\verb|-> (fn t => Thm.add_def false|\isasep\isanewline% |
463 \verb||\verb,|,\verb|-> (fn t => Thm.add_def false false|\isasep\isanewline% |
464 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})))|\isasep\isanewline% |
464 \verb| ("bar_def", Logic.mk_equals (t, @{term "%x. x"})))|\isasep\isanewline% |
465 \verb||\verb,|,\verb||\verb,|,\verb|> Sign.restore_naming thy|\isasep\isanewline% |
465 \verb||\verb,|,\verb||\verb,|,\verb|> Sign.restore_naming thy|\isasep\isanewline% |
466 |
466 |
467 \end{quotation} |
467 \end{quotation} |
468 |
468 |
469 \noindent \indexml{op ||$>$$>$}\verb|op |\verb,|,\verb||\verb,|,\verb|>>| accumulates side results: |
469 \noindent \indexml{op ||$>$$>$}\verb|op |\verb,|,\verb||\verb,|,\verb|>>| accumulates side results: |
470 \begin{quotation} |
470 \begin{quotation} |
471 \verb|thy|\isasep\isanewline% |
471 \verb|thy|\isasep\isanewline% |
472 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
472 \verb||\verb,|,\verb|> Sign.declare_const [] ("bar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
473 \verb||\verb,|,\verb||\verb,|,\verb|>> Sign.declare_const [] ("foobar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
473 \verb||\verb,|,\verb||\verb,|,\verb|>> Sign.declare_const [] ("foobar", @{typ "foo => foo"}, NoSyn)|\isasep\isanewline% |
474 \verb||\verb,|,\verb|-> (fn (t1, t2) => Thm.add_def false|\isasep\isanewline% |
474 \verb||\verb,|,\verb|-> (fn (t1, t2) => Thm.add_def false false|\isasep\isanewline% |
475 \verb| ("bar_def", Logic.mk_equals (t1, t2)))|\isasep\isanewline% |
475 \verb| ("bar_def", Logic.mk_equals (t1, t2)))|\isasep\isanewline% |
476 |
476 |
477 \end{quotation}% |
477 \end{quotation}% |
478 \end{isamarkuptext}% |
478 \end{isamarkuptext}% |
479 \isamarkuptrue% |
479 \isamarkuptrue% |
529 \verb| thy|\isasep\isanewline% |
529 \verb| thy|\isasep\isanewline% |
530 \verb| |\verb,|,\verb|> fold_map (fn const => Sign.declare_const []|\isasep\isanewline% |
530 \verb| |\verb,|,\verb|> fold_map (fn const => Sign.declare_const []|\isasep\isanewline% |
531 \verb| (const, @{typ "foo => foo"}, NoSyn)) consts|\isasep\isanewline% |
531 \verb| (const, @{typ "foo => foo"}, NoSyn)) consts|\isasep\isanewline% |
532 \verb| |\verb,|,\verb|>> map (fn t => Logic.mk_equals (t, @{term "%x. x"}))|\isasep\isanewline% |
532 \verb| |\verb,|,\verb|>> map (fn t => Logic.mk_equals (t, @{term "%x. x"}))|\isasep\isanewline% |
533 \verb| |\verb,|,\verb|-> (fn defs => fold_map (fn def =>|\isasep\isanewline% |
533 \verb| |\verb,|,\verb|-> (fn defs => fold_map (fn def =>|\isasep\isanewline% |
534 \verb| Thm.add_def false ("", def)) defs)|\isasep\isanewline% |
534 \verb| Thm.add_def false false ("", def)) defs)|\isasep\isanewline% |
535 \verb|end|\isasep\isanewline% |
535 \verb|end|\isasep\isanewline% |
536 |
536 |
537 \end{quotation}% |
537 \end{quotation}% |
538 \end{isamarkuptext}% |
538 \end{isamarkuptext}% |
539 \isamarkuptrue% |
539 \isamarkuptrue% |