101 sorts: sort Ord_List.T, (*declared sort occurrences*) |
100 sorts: sort Ord_List.T, (*declared sort occurrences*) |
102 constraints: |
101 constraints: |
103 typ Vartab.table * (*type constraints*) |
102 typ Vartab.table * (*type constraints*) |
104 sort Vartab.table}; (*default sorts*) |
103 sort Vartab.table}; (*default sorts*) |
105 |
104 |
106 fun make_data |
105 fun make_data (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) = |
107 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) = |
106 Data {names = names, consts = consts, bounds = bounds, fixes = fixes, binds = binds, |
108 Data {is_body = is_body, names = names, consts = consts, bounds = bounds, fixes = fixes, |
107 type_occs = type_occs, maxidx = maxidx, sorts = sorts, constraints = constraints}; |
109 binds = binds, type_occs = type_occs, maxidx = maxidx, sorts = sorts, constraints = constraints}; |
|
110 |
108 |
111 val empty_data = |
109 val empty_data = |
112 make_data (false, Name.context, Symtab.empty, (0, []), empty_fixes, Vartab.empty, |
110 make_data (Name.context, Symtab.empty, (0, []), empty_fixes, Vartab.empty, |
113 Symtab.empty, ~1, [], (Vartab.empty, Vartab.empty)); |
111 Symtab.empty, ~1, [], (Vartab.empty, Vartab.empty)); |
114 |
112 |
115 structure Data = Proof_Data |
113 structure Data = Proof_Data |
116 ( |
114 ( |
117 type T = data; |
115 type T = data; |
118 fun init _ = empty_data; |
116 fun init _ = empty_data; |
119 ); |
117 ); |
120 |
118 |
121 fun map_data f = |
119 fun map_data f = |
122 Data.map (fn |
120 Data.map (fn Data {names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints} => |
123 Data {is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints} => |
121 make_data (f (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints))); |
124 make_data |
|
125 (f (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints))); |
|
126 |
122 |
127 fun map_names f = |
123 fun map_names f = |
128 map_data (fn |
124 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
129 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
125 (f names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
130 (is_body, f names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
|
131 |
126 |
132 fun map_consts f = |
127 fun map_consts f = |
133 map_data (fn |
128 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
134 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
129 (names, f consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
135 (is_body, names, f consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
|
136 |
130 |
137 fun map_bounds f = |
131 fun map_bounds f = |
138 map_data (fn |
132 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
139 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
133 (names, consts, f bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
140 (is_body, names, consts, f bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
|
141 |
134 |
142 fun map_fixes f = |
135 fun map_fixes f = |
143 map_data (fn |
136 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
144 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
137 (names, consts, bounds, f fixes, binds, type_occs, maxidx, sorts, constraints)); |
145 (is_body, names, consts, bounds, f fixes, binds, type_occs, maxidx, sorts, constraints)); |
|
146 |
138 |
147 fun map_binds f = |
139 fun map_binds f = |
148 map_data (fn |
140 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
149 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
141 (names, consts, bounds, fixes, f binds, type_occs, maxidx, sorts, constraints)); |
150 (is_body, names, consts, bounds, fixes, f binds, type_occs, maxidx, sorts, constraints)); |
|
151 |
142 |
152 fun map_type_occs f = |
143 fun map_type_occs f = |
153 map_data (fn |
144 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
154 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
145 (names, consts, bounds, fixes, binds, f type_occs, maxidx, sorts, constraints)); |
155 (is_body, names, consts, bounds, fixes, binds, f type_occs, maxidx, sorts, constraints)); |
|
156 |
146 |
157 fun map_maxidx f = |
147 fun map_maxidx f = |
158 map_data (fn |
148 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
159 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
149 (names, consts, bounds, fixes, binds, type_occs, f maxidx, sorts, constraints)); |
160 (is_body, names, consts, bounds, fixes, binds, type_occs, f maxidx, sorts, constraints)); |
|
161 |
150 |
162 fun map_sorts f = |
151 fun map_sorts f = |
163 map_data (fn |
152 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
164 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
153 (names, consts, bounds, fixes, binds, type_occs, maxidx, f sorts, constraints)); |
165 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, f sorts, constraints)); |
|
166 |
154 |
167 fun map_constraints f = |
155 fun map_constraints f = |
168 map_data (fn |
156 map_data (fn (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
169 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
157 (names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, f constraints)); |
170 (is_body, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, f constraints)); |
|
171 |
158 |
172 fun rep_data ctxt = Data.get ctxt |> (fn Data rep => rep); |
159 fun rep_data ctxt = Data.get ctxt |> (fn Data rep => rep); |
173 |
|
174 val is_body = #is_body o rep_data; |
|
175 |
|
176 fun set_body b = |
|
177 map_data (fn (_, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints) => |
|
178 (b, names, consts, bounds, fixes, binds, type_occs, maxidx, sorts, constraints)); |
|
179 |
|
180 fun restore_body ctxt = set_body (is_body ctxt); |
|
181 |
160 |
182 val names_of = #names o rep_data; |
161 val names_of = #names o rep_data; |
183 val fixes_of = #fixes o rep_data; |
162 val fixes_of = #fixes o rep_data; |
184 val fixes_space = Name_Space.space_of_table o fixes_of; |
163 val fixes_space = Name_Space.space_of_table o fixes_of; |
185 val binds_of = #binds o rep_data; |
164 val binds_of = #binds o rep_data; |