author | haftmann |
Mon, 10 Nov 2008 19:42:21 +0100 | |
changeset 28733 | 18ffcbf1b3ae |
parent 28084 | a05ca48ef263 |
child 28737 | 8cbb7cfcfb5b |
permissions | -rw-r--r-- |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
1 |
(* Title: Pure/Isar/element.ML |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
2 |
ID: $Id$ |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
3 |
Author: Makarius |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
4 |
|
19777 | 5 |
Explicit data structures for some Isar language elements, with derived |
6 |
logical operations. |
|
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
7 |
*) |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
8 |
|
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
9 |
signature ELEMENT = |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
10 |
sig |
19259 | 11 |
datatype ('typ, 'term) stmt = |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
12 |
Shows of (Attrib.binding * ('term * 'term list) list) list | |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
13 |
Obtains of (Name.binding * ((Name.binding * 'typ option) list * 'term list)) list |
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
25739
diff
changeset
|
14 |
type statement = (string, string) stmt |
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
25739
diff
changeset
|
15 |
type statement_i = (typ, term) stmt |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
16 |
datatype ('typ, 'term, 'fact) ctxt = |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
17 |
Fixes of (Name.binding * 'typ option * mixfix) list | |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
18 |
Constrains of (string * 'typ) list | |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
19 |
Assumes of (Attrib.binding * ('term * 'term list) list) list | |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
20 |
Defines of (Attrib.binding * ('term * 'term list)) list | |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
21 |
Notes of string * (Attrib.binding * ('fact * Attrib.src list) list) list |
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
25739
diff
changeset
|
22 |
type context = (string, string, Facts.ref) ctxt |
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
25739
diff
changeset
|
23 |
type context_i = (typ, term, thm list) ctxt |
21581 | 24 |
val facts_map: (('typ, 'term, 'fact) ctxt -> ('a, 'b, 'c) ctxt) -> |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
25 |
(Attrib.binding * ('fact * Attrib.src list) list) list -> |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
26 |
(Attrib.binding * ('c * Attrib.src list) list) list |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
27 |
val map_ctxt: {name: Name.binding -> Name.binding, |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
28 |
var: Name.binding * mixfix -> Name.binding * mixfix, |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
29 |
typ: 'typ -> 'a, term: 'term -> 'b, fact: 'fact -> 'c, |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
30 |
attrib: Attrib.src -> Attrib.src} -> ('typ, 'term, 'fact) ctxt -> ('a, 'b, 'c) ctxt |
21528 | 31 |
val map_ctxt_attrib: (Attrib.src -> Attrib.src) -> |
32 |
('typ, 'term, 'fact) ctxt -> ('typ, 'term, 'fact) ctxt |
|
21481 | 33 |
val morph_ctxt: morphism -> context_i -> context_i |
19808 | 34 |
val params_of: context_i -> (string * typ) list |
35 |
val prems_of: context_i -> term list |
|
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
36 |
val facts_of: theory -> context_i -> (Attrib.binding * (thm list * Attrib.src list) list) list |
19777 | 37 |
val pretty_stmt: Proof.context -> statement_i -> Pretty.T list |
38 |
val pretty_ctxt: Proof.context -> context_i -> Pretty.T list |
|
39 |
val pretty_statement: Proof.context -> string -> thm -> Pretty.T |
|
40 |
type witness |
|
41 |
val map_witness: (term * thm -> term * thm) -> witness -> witness |
|
21481 | 42 |
val morph_witness: morphism -> witness -> witness |
19777 | 43 |
val witness_prop: witness -> term |
44 |
val witness_hyps: witness -> term list |
|
45 |
val assume_witness: theory -> term -> witness |
|
20058 | 46 |
val prove_witness: Proof.context -> term -> tactic -> witness |
25624 | 47 |
val close_witness: witness -> witness |
19777 | 48 |
val conclude_witness: witness -> thm |
49 |
val mark_witness: term -> term |
|
50 |
val make_witness: term -> thm -> witness |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19897
diff
changeset
|
51 |
val dest_witness: witness -> term * thm |
20068
19c7361db4a3
New function transfer_witness lifting Thm.transfer to witnesses.
ballarin
parents:
20058
diff
changeset
|
52 |
val transfer_witness: theory -> witness -> witness |
19808 | 53 |
val refine_witness: Proof.state -> Proof.state Seq.seq |
22658
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
54 |
val pretty_witness: Proof.context -> witness -> Pretty.T |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
55 |
val rename: (string * (string * mixfix option)) list -> string -> string |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
56 |
val rename_var_name: (string * (string * mixfix option)) list -> |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
57 |
string * mixfix -> string * mixfix |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
58 |
val rename_var: (string * (string * mixfix option)) list -> |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
59 |
Name.binding * mixfix -> Name.binding * mixfix |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
60 |
val rename_term: (string * (string * mixfix option)) list -> term -> term |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
61 |
val rename_thm: (string * (string * mixfix option)) list -> thm -> thm |
21481 | 62 |
val rename_morphism: (string * (string * mixfix option)) list -> morphism |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
63 |
val instT_type: typ Symtab.table -> typ -> typ |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
64 |
val instT_term: typ Symtab.table -> term -> term |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
65 |
val instT_thm: theory -> typ Symtab.table -> thm -> thm |
21481 | 66 |
val instT_morphism: theory -> typ Symtab.table -> morphism |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
67 |
val inst_term: typ Symtab.table * term Symtab.table -> term -> term |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
68 |
val inst_thm: theory -> typ Symtab.table * term Symtab.table -> thm -> thm |
21481 | 69 |
val inst_morphism: theory -> typ Symtab.table * term Symtab.table -> morphism |
19777 | 70 |
val satisfy_thm: witness list -> thm -> thm |
21481 | 71 |
val satisfy_morphism: witness list -> morphism |
20264 | 72 |
val satisfy_facts: witness list -> |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
73 |
(Attrib.binding * (thm list * Attrib.src list) list) list -> |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
74 |
(Attrib.binding * (thm list * Attrib.src list) list) list |
21581 | 75 |
val generalize_facts: Proof.context -> Proof.context -> |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
76 |
(Attrib.binding * (thm list * Attrib.src list) list) list -> |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
77 |
(Attrib.binding * (thm list * Attrib.src list) list) list |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
78 |
end; |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
79 |
|
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
80 |
structure Element: ELEMENT = |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
81 |
struct |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
82 |
|
19777 | 83 |
(** language elements **) |
84 |
||
85 |
(* statement *) |
|
19259 | 86 |
|
87 |
datatype ('typ, 'term) stmt = |
|
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
88 |
Shows of (Attrib.binding * ('term * 'term list) list) list | |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
89 |
Obtains of (Name.binding * ((Name.binding * 'typ option) list * 'term list)) list; |
19259 | 90 |
|
91 |
type statement = (string, string) stmt; |
|
92 |
type statement_i = (typ, term) stmt; |
|
93 |
||
94 |
||
19777 | 95 |
(* context *) |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
96 |
|
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
97 |
datatype ('typ, 'term, 'fact) ctxt = |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
98 |
Fixes of (Name.binding * 'typ option * mixfix) list | |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
99 |
Constrains of (string * 'typ) list | |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
100 |
Assumes of (Attrib.binding * ('term * 'term list) list) list | |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
101 |
Defines of (Attrib.binding * ('term * 'term list)) list | |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
102 |
Notes of string * (Attrib.binding * ('fact * Attrib.src list) list) list; |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
103 |
|
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
25739
diff
changeset
|
104 |
type context = (string, string, Facts.ref) ctxt; |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
105 |
type context_i = (typ, term, thm list) ctxt; |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
106 |
|
21581 | 107 |
fun facts_map f facts = Notes ("", facts) |> f |> (fn Notes (_, facts') => facts'); |
108 |
||
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
109 |
fun map_ctxt {name, var, typ, term, fact, attrib} = |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
110 |
fn Fixes fixes => Fixes (fixes |> map (fn (x, T, mx) => |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
111 |
let val (x', mx') = var (x, mx) in (x', Option.map typ T, mx') end)) |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
112 |
| Constrains xs => Constrains (xs |> map (fn (x, T) => |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
113 |
let val x' = Name.name_of (#1 (var (Name.binding x, NoSyn))) in (x', typ T) end)) |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
114 |
| Assumes asms => Assumes (asms |> map (fn ((a, atts), propps) => |
19585 | 115 |
((name a, map attrib atts), propps |> map (fn (t, ps) => (term t, map term ps))))) |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
116 |
| Defines defs => Defines (defs |> map (fn ((a, atts), (t, ps)) => |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
117 |
((name a, map attrib atts), (term t, map term ps)))) |
21440 | 118 |
| Notes (kind, facts) => Notes (kind, facts |> map (fn ((a, atts), bs) => |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
119 |
((name a, map attrib atts), bs |> map (fn (ths, btts) => (fact ths, map attrib btts))))); |
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
120 |
|
21528 | 121 |
fun map_ctxt_attrib attrib = |
122 |
map_ctxt {name = I, var = I, typ = I, term = I, fact = I, attrib = attrib}; |
|
123 |
||
21481 | 124 |
fun morph_ctxt phi = map_ctxt |
125 |
{name = Morphism.name phi, |
|
126 |
var = Morphism.var phi, |
|
127 |
typ = Morphism.typ phi, |
|
128 |
term = Morphism.term phi, |
|
21521 | 129 |
fact = Morphism.fact phi, |
21481 | 130 |
attrib = Args.morph_values phi}; |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
131 |
|
19808 | 132 |
|
133 |
(* logical content *) |
|
134 |
||
19777 | 135 |
fun params_of (Fixes fixes) = fixes |> map |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
136 |
(fn (x, SOME T, _) => (Name.name_of x, T) |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
137 |
| (x, _, _) => raise TERM ("Untyped context element parameter " ^ quote (Name.name_of x), [])) |
19777 | 138 |
| params_of _ = []; |
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
139 |
|
19777 | 140 |
fun prems_of (Assumes asms) = maps (map fst o snd) asms |
141 |
| prems_of (Defines defs) = map (fst o snd) defs |
|
142 |
| prems_of _ = []; |
|
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
143 |
|
20233 | 144 |
fun assume thy t = Assumption.assume (Thm.cterm_of thy t); |
19808 | 145 |
|
146 |
fun facts_of thy (Assumes asms) = map (apsnd (map (fn (t, _) => ([assume thy t], [])))) asms |
|
147 |
| facts_of thy (Defines defs) = map (apsnd (fn (t, _) => [([assume thy t], [])])) defs |
|
21440 | 148 |
| facts_of _ (Notes (_, facts)) = facts |
19808 | 149 |
| facts_of _ _ = []; |
150 |
||
18894 | 151 |
|
152 |
||
19259 | 153 |
(** pretty printing **) |
154 |
||
19267 | 155 |
fun pretty_items _ _ [] = [] |
156 |
| pretty_items keyword sep (x :: ys) = |
|
157 |
Pretty.block [Pretty.keyword keyword, Pretty.brk 1, x] :: |
|
158 |
map (fn y => Pretty.block [Pretty.str " ", Pretty.keyword sep, Pretty.brk 1, y]) ys; |
|
19259 | 159 |
|
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
160 |
fun pretty_name_atts ctxt (binding, atts) sep = |
28733 | 161 |
let |
162 |
val name = NameSpace.implode |
|
163 |
(map fst (Name.prefix_of binding) @ [Name.name_of binding]); |
|
164 |
in if name = "" andalso null atts then [] |
|
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
165 |
else [Pretty.block |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
166 |
(Pretty.breaks (Pretty.str name :: Attrib.pretty_attribs ctxt atts @ [Pretty.str sep]))] |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
167 |
end; |
19259 | 168 |
|
169 |
||
170 |
(* pretty_stmt *) |
|
171 |
||
172 |
fun pretty_stmt ctxt = |
|
173 |
let |
|
24920 | 174 |
val prt_typ = Pretty.quote o Syntax.pretty_typ ctxt; |
175 |
val prt_term = Pretty.quote o Syntax.pretty_term ctxt; |
|
19267 | 176 |
val prt_terms = separate (Pretty.keyword "and") o map prt_term; |
19259 | 177 |
val prt_name_atts = pretty_name_atts ctxt; |
178 |
||
179 |
fun prt_show (a, ts) = |
|
19267 | 180 |
Pretty.block (Pretty.breaks (prt_name_atts a ":" @ prt_terms (map fst ts))); |
19259 | 181 |
|
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
182 |
fun prt_var (x, SOME T) = Pretty.block |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
183 |
[Pretty.str (Name.name_of x ^ " ::"), Pretty.brk 1, prt_typ T] |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
184 |
| prt_var (x, NONE) = Pretty.str (Name.name_of x); |
26721 | 185 |
val prt_vars = separate (Pretty.keyword "and") o map prt_var; |
19259 | 186 |
|
19267 | 187 |
fun prt_obtain (_, ([], ts)) = Pretty.block (Pretty.breaks (prt_terms ts)) |
19259 | 188 |
| prt_obtain (_, (xs, ts)) = Pretty.block (Pretty.breaks |
19585 | 189 |
(prt_vars xs @ [Pretty.keyword "where"] @ prt_terms ts)); |
19259 | 190 |
in |
19267 | 191 |
fn Shows shows => pretty_items "shows" "and" (map prt_show shows) |
192 |
| Obtains obtains => pretty_items "obtains" "|" (map prt_obtain obtains) |
|
19259 | 193 |
end; |
194 |
||
18894 | 195 |
|
19259 | 196 |
(* pretty_ctxt *) |
197 |
||
198 |
fun pretty_ctxt ctxt = |
|
199 |
let |
|
24920 | 200 |
val prt_typ = Pretty.quote o Syntax.pretty_typ ctxt; |
201 |
val prt_term = Pretty.quote o Syntax.pretty_term ctxt; |
|
19259 | 202 |
val prt_thm = Pretty.backquote o ProofContext.pretty_thm ctxt; |
203 |
val prt_name_atts = pretty_name_atts ctxt; |
|
204 |
||
19267 | 205 |
fun prt_mixfix NoSyn = [] |
206 |
| prt_mixfix mx = [Pretty.brk 2, Syntax.pretty_mixfix mx]; |
|
207 |
||
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
208 |
fun prt_fix (x, SOME T, mx) = Pretty.block (Pretty.str (Name.name_of x ^ " ::") :: |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
209 |
Pretty.brk 1 :: prt_typ T :: Pretty.brk 1 :: prt_mixfix mx) |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
210 |
| prt_fix (x, NONE, mx) = Pretty.block (Pretty.str (Name.name_of x) :: |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
211 |
Pretty.brk 1 :: prt_mixfix mx); |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
212 |
fun prt_constrain (x, T) = prt_fix (Name.binding x, SOME T, NoSyn); |
18894 | 213 |
|
19259 | 214 |
fun prt_asm (a, ts) = |
215 |
Pretty.block (Pretty.breaks (prt_name_atts a ":" @ map (prt_term o fst) ts)); |
|
216 |
fun prt_def (a, (t, _)) = |
|
217 |
Pretty.block (Pretty.breaks (prt_name_atts a ":" @ [prt_term t])); |
|
218 |
||
219 |
fun prt_fact (ths, []) = map prt_thm ths |
|
220 |
| prt_fact (ths, atts) = Pretty.enclose "(" ")" |
|
21032 | 221 |
(Pretty.breaks (map prt_thm ths)) :: Attrib.pretty_attribs ctxt atts; |
19259 | 222 |
fun prt_note (a, ths) = |
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19466
diff
changeset
|
223 |
Pretty.block (Pretty.breaks (flat (prt_name_atts a "=" :: map prt_fact ths))); |
19259 | 224 |
in |
19267 | 225 |
fn Fixes fixes => pretty_items "fixes" "and" (map prt_fix fixes) |
226 |
| Constrains xs => pretty_items "constrains" "and" (map prt_constrain xs) |
|
227 |
| Assumes asms => pretty_items "assumes" "and" (map prt_asm asms) |
|
228 |
| Defines defs => pretty_items "defines" "and" (map prt_def defs) |
|
21440 | 229 |
| Notes ("", facts) => pretty_items "notes" "and" (map prt_note facts) |
230 |
| Notes (kind, facts) => pretty_items ("notes " ^ kind) "and" (map prt_note facts) |
|
19259 | 231 |
end; |
18894 | 232 |
|
19267 | 233 |
|
234 |
(* pretty_statement *) |
|
235 |
||
236 |
local |
|
237 |
||
238 |
fun thm_name kind th prts = |
|
239 |
let val head = |
|
27865
27a8ad9612a3
moved basic thm operations from structure PureThy to Thm (cf. more_thm.ML);
wenzelm
parents:
26721
diff
changeset
|
240 |
if Thm.has_name_hint th then |
21965
7120ef5bc378
pretty_statement: more careful handling of name_hint;
wenzelm
parents:
21646
diff
changeset
|
241 |
Pretty.block [Pretty.command kind, |
27865
27a8ad9612a3
moved basic thm operations from structure PureThy to Thm (cf. more_thm.ML);
wenzelm
parents:
26721
diff
changeset
|
242 |
Pretty.brk 1, Pretty.str (Sign.base_name (Thm.get_name_hint th) ^ ":")] |
21965
7120ef5bc378
pretty_statement: more careful handling of name_hint;
wenzelm
parents:
21646
diff
changeset
|
243 |
else Pretty.command kind |
19267 | 244 |
in Pretty.block (Pretty.fbreaks (head :: prts)) end; |
245 |
||
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
246 |
fun fix (x, T) = (Name.binding x, SOME T); |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
247 |
|
19267 | 248 |
fun obtain prop ctxt = |
249 |
let |
|
20150 | 250 |
val ((xs, prop'), ctxt') = Variable.focus prop ctxt; |
251 |
val As = Logic.strip_imp_prems (Thm.term_of prop'); |
|
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
252 |
in ((Name.no_binding, (map (fix o Term.dest_Free o Thm.term_of) xs, As)), ctxt') end; |
19267 | 253 |
|
254 |
in |
|
255 |
||
256 |
fun pretty_statement ctxt kind raw_th = |
|
257 |
let |
|
258 |
val thy = ProofContext.theory_of ctxt; |
|
20150 | 259 |
val cert = Thm.cterm_of thy; |
260 |
||
21605 | 261 |
val th = MetaSimplifier.norm_hhf raw_th; |
20150 | 262 |
val is_elim = ObjectLogic.is_elim th; |
19267 | 263 |
|
26716
8690e75e1395
print_statement: reset body mode, i.e. invent global frees (no need for revert_skolem);
wenzelm
parents:
26628
diff
changeset
|
264 |
val ((_, [th']), ctxt') = Variable.import_thms true [th] (Variable.set_body false ctxt); |
20150 | 265 |
val prop = Thm.prop_of th'; |
266 |
val (prems, concl) = Logic.strip_horn prop; |
|
267 |
val concl_term = ObjectLogic.drop_judgment thy concl; |
|
19267 | 268 |
|
20150 | 269 |
val fixes = fold_aterms (fn v as Free (x, T) => |
270 |
if Variable.newly_fixed ctxt' ctxt x andalso not (v aconv concl_term) |
|
26716
8690e75e1395
print_statement: reset body mode, i.e. invent global frees (no need for revert_skolem);
wenzelm
parents:
26628
diff
changeset
|
271 |
then insert (op =) (x, T) else I | _ => I) prop [] |> rev; |
20150 | 272 |
val (assumes, cases) = take_suffix (fn prem => |
273 |
is_elim andalso concl aconv Logic.strip_assums_concl prem) prems; |
|
19267 | 274 |
in |
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
275 |
pretty_ctxt ctxt' (Fixes (map (fn (x, T) => (Name.binding x, SOME T, NoSyn)) fixes)) @ |
28084
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
276 |
pretty_ctxt ctxt' (Assumes (map (fn t => (Attrib.no_binding, [(t, [])])) assumes)) @ |
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents:
28079
diff
changeset
|
277 |
(if null cases then pretty_stmt ctxt' (Shows [(Attrib.no_binding, [(concl, [])])]) |
26716
8690e75e1395
print_statement: reset body mode, i.e. invent global frees (no need for revert_skolem);
wenzelm
parents:
26628
diff
changeset
|
278 |
else |
8690e75e1395
print_statement: reset body mode, i.e. invent global frees (no need for revert_skolem);
wenzelm
parents:
26628
diff
changeset
|
279 |
let val (clauses, ctxt'') = fold_map (obtain o cert) cases ctxt' |
8690e75e1395
print_statement: reset body mode, i.e. invent global frees (no need for revert_skolem);
wenzelm
parents:
26628
diff
changeset
|
280 |
in pretty_stmt ctxt'' (Obtains clauses) end) |
19267 | 281 |
end |> thm_name kind raw_th; |
282 |
||
18140
691c64d615a5
Explicit data structures for some Isar language elements.
wenzelm
parents:
diff
changeset
|
283 |
end; |
19267 | 284 |
|
19777 | 285 |
|
286 |
||
287 |
(** logical operations **) |
|
288 |
||
289 |
(* witnesses -- hypotheses as protected facts *) |
|
290 |
||
291 |
datatype witness = Witness of term * thm; |
|
292 |
||
293 |
fun map_witness f (Witness witn) = Witness (f witn); |
|
294 |
||
21481 | 295 |
fun morph_witness phi = map_witness (fn (t, th) => (Morphism.term phi t, Morphism.thm phi th)); |
296 |
||
19777 | 297 |
fun witness_prop (Witness (t, _)) = t; |
298 |
fun witness_hyps (Witness (_, th)) = #hyps (Thm.rep_thm th); |
|
299 |
||
300 |
fun assume_witness thy t = |
|
301 |
Witness (t, Goal.protect (Thm.assume (Thm.cterm_of thy t))); |
|
302 |
||
20058 | 303 |
fun prove_witness ctxt t tac = |
26628
63306cb94313
replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents:
26336
diff
changeset
|
304 |
Witness (t, Thm.close_derivation (Goal.prove ctxt [] [] (Logic.protect t) (fn _ => |
25202
3a539d9995fb
proven witness: proper Goal.close_result save huge amounts of resources when using proof terms;
wenzelm
parents:
24920
diff
changeset
|
305 |
Tactic.rtac Drule.protectI 1 THEN tac))); |
19777 | 306 |
|
26628
63306cb94313
replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents:
26336
diff
changeset
|
307 |
val close_witness = map_witness (fn (t, th) => (t, Thm.close_derivation th)); |
25624 | 308 |
|
25202
3a539d9995fb
proven witness: proper Goal.close_result save huge amounts of resources when using proof terms;
wenzelm
parents:
24920
diff
changeset
|
309 |
fun conclude_witness (Witness (_, th)) = |
26628
63306cb94313
replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents:
26336
diff
changeset
|
310 |
Thm.close_derivation (MetaSimplifier.norm_hhf_protect (Goal.conclude th)); |
19777 | 311 |
|
25302 | 312 |
fun compose_witness (Witness (_, th)) r = |
313 |
let |
|
314 |
val th' = Goal.conclude th; |
|
315 |
val A = Thm.cprem_of r 1; |
|
25739 | 316 |
in |
317 |
Thm.implies_elim |
|
318 |
(Conv.gconv_rule Drule.beta_eta_conversion 1 r) |
|
319 |
(Conv.fconv_rule Drule.beta_eta_conversion |
|
320 |
(Thm.instantiate (Thm.match (Thm.cprop_of th', A)) th')) |
|
321 |
end; |
|
25302 | 322 |
|
19777 | 323 |
val mark_witness = Logic.protect; |
324 |
||
325 |
fun make_witness t th = Witness (t, th); |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19897
diff
changeset
|
326 |
fun dest_witness (Witness w) = w; |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19897
diff
changeset
|
327 |
|
20068
19c7361db4a3
New function transfer_witness lifting Thm.transfer to witnesses.
ballarin
parents:
20058
diff
changeset
|
328 |
fun transfer_witness thy (Witness (t, th)) = Witness (t, Thm.transfer thy th); |
19c7361db4a3
New function transfer_witness lifting Thm.transfer to witnesses.
ballarin
parents:
20058
diff
changeset
|
329 |
|
19777 | 330 |
val refine_witness = |
331 |
Proof.refine (Method.Basic (K (Method.RAW_METHOD |
|
332 |
(K (ALLGOALS |
|
23414
927203ad4b3a
tuned conjunction tactics: slightly smaller proof terms;
wenzelm
parents:
23351
diff
changeset
|
333 |
(CONJUNCTS (ALLGOALS |
927203ad4b3a
tuned conjunction tactics: slightly smaller proof terms;
wenzelm
parents:
23351
diff
changeset
|
334 |
(CONJUNCTS (TRYALL (Tactic.rtac Drule.protectI)))))))), Position.none)); |
19777 | 335 |
|
22658
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
336 |
fun pretty_witness ctxt witn = |
24920 | 337 |
let val prt_term = Pretty.quote o Syntax.pretty_term ctxt in |
22658
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
338 |
Pretty.block (prt_term (witness_prop witn) :: |
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
339 |
(if ! show_hyps then [Pretty.brk 2, Pretty.list "[" "]" |
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
340 |
(map prt_term (witness_hyps witn))] else [])) |
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
341 |
end; |
263d42253f53
Experimental interpretation code for definitions.
ballarin
parents:
22568
diff
changeset
|
342 |
|
19777 | 343 |
|
344 |
(* derived rules *) |
|
345 |
||
20007 | 346 |
fun instantiate_tfrees thy subst th = |
19777 | 347 |
let |
348 |
val certT = Thm.ctyp_of thy; |
|
20007 | 349 |
val idx = Thm.maxidx_of th + 1; |
350 |
fun cert_inst (a, (S, T)) = (certT (TVar ((a, idx), S)), certT T); |
|
351 |
||
352 |
fun add_inst (a, S) insts = |
|
353 |
if AList.defined (op =) insts a then insts |
|
354 |
else (case AList.lookup (op =) subst a of NONE => insts | SOME T => (a, (S, T)) :: insts); |
|
355 |
val insts = |
|
356 |
Term.fold_types (Term.fold_atyps (fn TFree v => add_inst v | _ => I)) |
|
357 |
(Thm.full_prop_of th) []; |
|
19777 | 358 |
in |
20007 | 359 |
th |
360 |
|> Thm.generalize (map fst insts, []) idx |
|
361 |
|> Thm.instantiate (map cert_inst insts, []) |
|
19777 | 362 |
end; |
363 |
||
364 |
fun instantiate_frees thy subst = |
|
365 |
let val cert = Thm.cterm_of thy in |
|
366 |
Drule.forall_intr_list (map (cert o Free o fst) subst) #> |
|
367 |
Drule.forall_elim_list (map (cert o snd) subst) |
|
368 |
end; |
|
369 |
||
370 |
fun hyps_rule rule th = |
|
21521 | 371 |
let val {hyps, ...} = Thm.crep_thm th in |
19777 | 372 |
Drule.implies_elim_list |
373 |
(rule (Drule.implies_intr_list hyps th)) |
|
21521 | 374 |
(map (Thm.assume o Drule.cterm_rule rule) hyps) |
19777 | 375 |
end; |
376 |
||
377 |
||
378 |
(* rename *) |
|
379 |
||
380 |
fun rename ren x = |
|
381 |
(case AList.lookup (op =) ren (x: string) of |
|
382 |
NONE => x |
|
383 |
| SOME (x', _) => x'); |
|
384 |
||
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
385 |
fun rename_var_name ren (x, mx) = |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
386 |
(case (AList.lookup (op =) ren x, mx) of |
19777 | 387 |
(NONE, _) => (x, mx) |
388 |
| (SOME (x', NONE), Structure) => (x', mx) |
|
389 |
| (SOME (x', SOME _), Structure) => |
|
390 |
error ("Attempt to change syntax of structure parameter " ^ quote x) |
|
391 |
| (SOME (x', NONE), _) => (x', NoSyn) |
|
392 |
| (SOME (x', SOME mx'), _) => (x', mx')); |
|
393 |
||
28079
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
394 |
fun rename_var ren (binding, mx) = |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
395 |
let |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
396 |
val x = Name.name_of binding; |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
397 |
val (x', mx') = rename_var_name ren (x, mx); |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
398 |
in (Name.binding x', mx') end; |
955c42c8a5e4
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27865
diff
changeset
|
399 |
|
19777 | 400 |
fun rename_term ren (Free (x, T)) = Free (rename ren x, T) |
401 |
| rename_term ren (t $ u) = rename_term ren t $ rename_term ren u |
|
402 |
| rename_term ren (Abs (x, T, t)) = Abs (x, T, rename_term ren t) |
|
403 |
| rename_term _ a = a; |
|
404 |
||
405 |
fun rename_thm ren th = |
|
406 |
let |
|
20304 | 407 |
val thy = Thm.theory_of_thm th; |
22691 | 408 |
val subst = (Thm.fold_terms o Term.fold_aterms) |
20304 | 409 |
(fn Free (x, T) => |
19777 | 410 |
let val x' = rename ren x |
20304 | 411 |
in if x = x' then I else insert (eq_fst (op =)) ((x, T), Free (x', T)) end |
412 |
| _ => I) th []; |
|
19777 | 413 |
in |
414 |
if null subst then th |
|
20304 | 415 |
else th |> hyps_rule (instantiate_frees thy subst) |
19777 | 416 |
end; |
417 |
||
21481 | 418 |
fun rename_morphism ren = Morphism.morphism |
21521 | 419 |
{name = I, var = rename_var ren, typ = I, term = rename_term ren, fact = map (rename_thm ren)}; |
19777 | 420 |
|
421 |
||
422 |
(* instantiate types *) |
|
423 |
||
424 |
fun instT_type env = |
|
425 |
if Symtab.is_empty env then I |
|
426 |
else Term.map_type_tfree (fn (x, S) => the_default (TFree (x, S)) (Symtab.lookup env x)); |
|
427 |
||
428 |
fun instT_term env = |
|
429 |
if Symtab.is_empty env then I |
|
20548
8ef25fe585a8
renamed Term.map_term_types to Term.map_types (cf. Term.fold_types);
wenzelm
parents:
20304
diff
changeset
|
430 |
else Term.map_types (instT_type env); |
19777 | 431 |
|
22691 | 432 |
fun instT_subst env th = (Thm.fold_terms o Term.fold_types o Term.fold_atyps) |
20304 | 433 |
(fn T as TFree (a, _) => |
434 |
let val T' = the_default T (Symtab.lookup env a) |
|
435 |
in if T = T' then I else insert (op =) (a, T') end |
|
436 |
| _ => I) th []; |
|
19777 | 437 |
|
438 |
fun instT_thm thy env th = |
|
439 |
if Symtab.is_empty env then th |
|
440 |
else |
|
441 |
let val subst = instT_subst env th |
|
442 |
in if null subst then th else th |> hyps_rule (instantiate_tfrees thy subst) end; |
|
443 |
||
22672
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
444 |
fun instT_morphism thy env = |
24137
8d7896398147
replaced Theory.self_ref by Theory.check_thy, which now produces a checked ref;
wenzelm
parents:
23414
diff
changeset
|
445 |
let val thy_ref = Theory.check_thy thy in |
22672
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
446 |
Morphism.morphism |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
447 |
{name = I, var = I, |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
448 |
typ = instT_type env, |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
449 |
term = instT_term env, |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
450 |
fact = map (fn th => instT_thm (Theory.deref thy_ref) env th)} |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
451 |
end; |
19777 | 452 |
|
453 |
||
454 |
(* instantiate types and terms *) |
|
455 |
||
456 |
fun inst_term (envT, env) = |
|
457 |
if Symtab.is_empty env then instT_term envT |
|
458 |
else |
|
459 |
let |
|
460 |
val instT = instT_type envT; |
|
461 |
fun inst (Const (x, T)) = Const (x, instT T) |
|
462 |
| inst (Free (x, T)) = |
|
463 |
(case Symtab.lookup env x of |
|
464 |
NONE => Free (x, instT T) |
|
465 |
| SOME t => t) |
|
466 |
| inst (Var (xi, T)) = Var (xi, instT T) |
|
467 |
| inst (b as Bound _) = b |
|
468 |
| inst (Abs (x, T, t)) = Abs (x, instT T, inst t) |
|
469 |
| inst (t $ u) = inst t $ inst u; |
|
470 |
in Envir.beta_norm o inst end; |
|
471 |
||
472 |
fun inst_thm thy (envT, env) th = |
|
473 |
if Symtab.is_empty env then instT_thm thy envT th |
|
474 |
else |
|
475 |
let |
|
476 |
val substT = instT_subst envT th; |
|
22691 | 477 |
val subst = (Thm.fold_terms o Term.fold_aterms) |
20304 | 478 |
(fn Free (x, T) => |
19777 | 479 |
let |
480 |
val T' = instT_type envT T; |
|
481 |
val t = Free (x, T'); |
|
482 |
val t' = the_default t (Symtab.lookup env x); |
|
20304 | 483 |
in if t aconv t' then I else insert (eq_fst (op =)) ((x, T'), t') end |
484 |
| _ => I) th []; |
|
19777 | 485 |
in |
486 |
if null substT andalso null subst then th |
|
487 |
else th |> hyps_rule |
|
488 |
(instantiate_tfrees thy substT #> |
|
489 |
instantiate_frees thy subst #> |
|
22900 | 490 |
Conv.fconv_rule (Thm.beta_conversion true)) |
19777 | 491 |
end; |
492 |
||
22672
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
493 |
fun inst_morphism thy envs = |
24137
8d7896398147
replaced Theory.self_ref by Theory.check_thy, which now produces a checked ref;
wenzelm
parents:
23414
diff
changeset
|
494 |
let val thy_ref = Theory.check_thy thy in |
22672
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
495 |
Morphism.morphism |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
496 |
{name = I, var = I, |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
497 |
typ = instT_type (#1 envs), |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
498 |
term = inst_term envs, |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
499 |
fact = map (fn th => inst_thm (Theory.deref thy_ref) envs th)} |
777af26d5713
inst(T)_morphism: avoid reference to static theory value;
wenzelm
parents:
22658
diff
changeset
|
500 |
end; |
19777 | 501 |
|
502 |
||
503 |
(* satisfy hypotheses *) |
|
504 |
||
505 |
fun satisfy_thm witns thm = thm |> fold (fn hyp => |
|
506 |
(case find_first (fn Witness (t, _) => Thm.term_of hyp aconv t) witns of |
|
507 |
NONE => I |
|
25302 | 508 |
| SOME w => Thm.implies_intr hyp #> compose_witness w)) (#hyps (Thm.crep_thm thm)); |
19777 | 509 |
|
21497 | 510 |
fun satisfy_morphism witns = Morphism.thm_morphism (satisfy_thm witns); |
19843 | 511 |
|
21581 | 512 |
fun satisfy_facts witns = facts_map (morph_ctxt (satisfy_morphism witns)); |
20264 | 513 |
|
514 |
||
515 |
(* generalize type/term parameters *) |
|
516 |
||
517 |
val maxidx_atts = fold Args.maxidx_values; |
|
518 |
||
21581 | 519 |
fun generalize_facts inner outer facts = |
20264 | 520 |
let |
521 |
val thy = ProofContext.theory_of inner; |
|
522 |
val maxidx = |
|
523 |
fold (fn ((_, atts), bs) => maxidx_atts atts #> fold (maxidx_atts o #2) bs) facts ~1; |
|
21581 | 524 |
val exp_fact = map (Thm.adjust_maxidx_thm maxidx) #> Variable.export inner outer; |
21521 | 525 |
val exp_term = Drule.term_rule thy (singleton exp_fact); |
526 |
val exp_typ = Logic.type_map exp_term; |
|
527 |
val morphism = |
|
528 |
Morphism.morphism {name = I, var = I, typ = exp_typ, term = exp_term, fact = exp_fact}; |
|
21581 | 529 |
in facts_map (morph_ctxt morphism) facts end; |
20886
f26672c248ee
replaced generalize_facts by full export_(standard_)facts;
wenzelm
parents:
20548
diff
changeset
|
530 |
|
19267 | 531 |
end; |