607 |
607 |
608 fun user_policy policy ctxt = if Config.get ctxt bnf_note_all then Note_All else policy; |
608 fun user_policy policy ctxt = if Config.get ctxt bnf_note_all then Note_All else policy; |
609 |
609 |
610 val smart_max_inline_term_size = 25; (*FUDGE*) |
610 val smart_max_inline_term_size = 25; (*FUDGE*) |
611 |
611 |
612 fun note_bnf_thms fact_policy qualify' bnf_b bnf = |
612 fun note_bnf_thms fact_policy qualify0 bnf_b bnf = |
613 let |
613 let |
614 val axioms = axioms_of_bnf bnf; |
614 val axioms = axioms_of_bnf bnf; |
615 val facts = facts_of_bnf bnf; |
615 val facts = facts_of_bnf bnf; |
616 val wits = wits_of_bnf bnf; |
616 val wits = wits_of_bnf bnf; |
617 val qualify = |
617 val qualify = |
618 let val (_, qs, _) = Binding.dest bnf_b; |
618 let val (_, qs, _) = Binding.dest bnf_b; |
619 in fold_rev (fn (s, mand) => Binding.qualify mand s) qs #> qualify' end; |
619 in fold_rev (fn (s, mand) => Binding.qualify mand s) qs #> qualify0 end; |
620 in |
620 in |
621 (if fact_policy = Note_All then |
621 (if fact_policy = Note_All then |
622 let |
622 let |
623 val witNs = if length wits = 1 then [witN] else map mk_witN (1 upto length wits); |
623 val witNs = if length wits = 1 then [witN] else map mk_witN (1 upto length wits); |
624 val notes = |
624 val notes = |
1344 (* arbitrarily use "Fun" as prefix for "fun"*) |
1344 (* arbitrarily use "Fun" as prefix for "fun"*) |
1345 (_, [], @{type_name fun}) => [(Context.theory_name @{theory Fun}, false)] |
1345 (_, [], @{type_name fun}) => [(Context.theory_name @{theory Fun}, false)] |
1346 | (_, qs, _) => qs) |
1346 | (_, qs, _) => qs) |
1347 in |
1347 in |
1348 thy |
1348 thy |
1349 (*|> Sign.root_path*) |
1349 |> Sign.root_path |
1350 (*|> fold (uncurry (fn true => Sign.mandatory_path | false => Sign.add_path) o swap) qualifiers*) |
1350 |> fold (uncurry (fn true => Sign.mandatory_path | false => Sign.add_path) o swap) qualifiers |
1351 |> (fn thy => f (morph_bnf (Morphism.transfer_morphism thy) bnf) thy) |
1351 |> (fn thy => f (morph_bnf (Morphism.transfer_morphism thy) bnf) thy) |
1352 (*|> Sign.restore_naming thy*) |
1352 |> Sign.restore_naming thy |
1353 end; |
1353 end; |
1354 |
1354 |
1355 fun bnf_interpretation f = BNF_Interpretation.interpretation (with_repaired_path f); |
1355 fun bnf_interpretation f = BNF_Interpretation.interpretation (with_repaired_path f); |
1356 |
1356 |
1357 fun register_bnf key bnf = |
1357 fun register_bnf key bnf = |
1405 let |
1405 let |
1406 fun pretty_set sets i = Pretty.block |
1406 fun pretty_set sets i = Pretty.block |
1407 [Pretty.str (mk_setN (i + 1) ^ ":"), Pretty.brk 1, |
1407 [Pretty.str (mk_setN (i + 1) ^ ":"), Pretty.brk 1, |
1408 Pretty.quote (Syntax.pretty_term ctxt (nth sets i))]; |
1408 Pretty.quote (Syntax.pretty_term ctxt (nth sets i))]; |
1409 |
1409 |
1410 fun pretty_bnf (key, BNF {T = T, map = map, sets = sets, bd = bd, |
1410 fun pretty_bnf (key, BNF {name, T, map, sets, bd, live, lives, dead, deads, ...}) = |
1411 live = live, lives = lives, dead = dead, deads = deads, ...}) = |
|
1412 Pretty.big_list |
1411 Pretty.big_list |
1413 (Pretty.string_of (Pretty.block [Pretty.str key, Pretty.str ":", Pretty.brk 1, |
1412 (Pretty.string_of (Pretty.block [Pretty.str key, Pretty.str ":", Pretty.brk 1, |
1414 Pretty.quote (Syntax.pretty_typ ctxt T)])) |
1413 Pretty.quote (Syntax.pretty_typ ctxt T)])) |
1415 ([Pretty.block [Pretty.str "live:", Pretty.brk 1, Pretty.str (string_of_int live), |
1414 ([Pretty.block [Pretty.str "live:", Pretty.brk 1, Pretty.str (string_of_int live), |
1416 Pretty.brk 3, Pretty.list "[" "]" (List.map (Syntax.pretty_typ ctxt) lives)], |
1415 Pretty.brk 3, Pretty.list "[" "]" (List.map (Syntax.pretty_typ ctxt) lives)], |