equal
deleted
inserted
replaced
90 signature PRIVATE_CONTEXT = |
90 signature PRIVATE_CONTEXT = |
91 sig |
91 sig |
92 include CONTEXT |
92 include CONTEXT |
93 structure Theory_Data: |
93 structure Theory_Data: |
94 sig |
94 sig |
95 val declare: Position.T -> Object.T -> (Object.T -> Object.T) -> |
95 val declare: Position.T -> Any.T -> (Any.T -> Any.T) -> |
96 (pretty -> Object.T * Object.T -> Object.T) -> serial |
96 (pretty -> Any.T * Any.T -> Any.T) -> serial |
97 val get: serial -> (Object.T -> 'a) -> theory -> 'a |
97 val get: serial -> (Any.T -> 'a) -> theory -> 'a |
98 val put: serial -> ('a -> Object.T) -> 'a -> theory -> theory |
98 val put: serial -> ('a -> Any.T) -> 'a -> theory -> theory |
99 end |
99 end |
100 structure Proof_Data: |
100 structure Proof_Data: |
101 sig |
101 sig |
102 val declare: (theory -> Object.T) -> serial |
102 val declare: (theory -> Any.T) -> serial |
103 val get: serial -> (Object.T -> 'a) -> Proof.context -> 'a |
103 val get: serial -> (Any.T -> 'a) -> Proof.context -> 'a |
104 val put: serial -> ('a -> Object.T) -> 'a -> Proof.context -> Proof.context |
104 val put: serial -> ('a -> Any.T) -> 'a -> Proof.context -> Proof.context |
105 end |
105 end |
106 end; |
106 end; |
107 |
107 |
108 structure Context: PRIVATE_CONTEXT = |
108 structure Context: PRIVATE_CONTEXT = |
109 struct |
109 struct |
117 val timing = Unsynchronized.ref false; |
117 val timing = Unsynchronized.ref false; |
118 |
118 |
119 (*private copy avoids potential conflict of table exceptions*) |
119 (*private copy avoids potential conflict of table exceptions*) |
120 structure Datatab = Table(type key = int val ord = int_ord); |
120 structure Datatab = Table(type key = int val ord = int_ord); |
121 |
121 |
122 datatype pretty = Pretty of Object.T; |
122 datatype pretty = Pretty of Any.T; |
123 |
123 |
124 local |
124 local |
125 |
125 |
126 type kind = |
126 type kind = |
127 {pos: Position.T, |
127 {pos: Position.T, |
128 empty: Object.T, |
128 empty: Any.T, |
129 extend: Object.T -> Object.T, |
129 extend: Any.T -> Any.T, |
130 merge: pretty -> Object.T * Object.T -> Object.T}; |
130 merge: pretty -> Any.T * Any.T -> Any.T}; |
131 |
131 |
132 val kinds = Synchronized.var "Theory_Data" (Datatab.empty: kind Datatab.table); |
132 val kinds = Synchronized.var "Theory_Data" (Datatab.empty: kind Datatab.table); |
133 |
133 |
134 fun invoke name f k x = |
134 fun invoke name f k x = |
135 (case Datatab.lookup (Synchronized.value kinds) k of |
135 (case Datatab.lookup (Synchronized.value kinds) k of |
168 {self: theory Unsynchronized.ref option, (*dynamic self reference -- follows theory changes*) |
168 {self: theory Unsynchronized.ref option, (*dynamic self reference -- follows theory changes*) |
169 draft: bool, (*draft mode -- linear destructive changes*) |
169 draft: bool, (*draft mode -- linear destructive changes*) |
170 id: serial, (*identifier*) |
170 id: serial, (*identifier*) |
171 ids: unit Inttab.table} * (*cumulative identifiers of non-drafts -- symbolic body content*) |
171 ids: unit Inttab.table} * (*cumulative identifiers of non-drafts -- symbolic body content*) |
172 (*data*) |
172 (*data*) |
173 Object.T Datatab.table * (*body content*) |
173 Any.T Datatab.table * (*body content*) |
174 (*ancestry*) |
174 (*ancestry*) |
175 {parents: theory list, (*immediate predecessors*) |
175 {parents: theory list, (*immediate predecessors*) |
176 ancestors: theory list} * (*all predecessors -- canonical reverse order*) |
176 ancestors: theory list} * (*all predecessors -- canonical reverse order*) |
177 (*history*) |
177 (*history*) |
178 {name: string, (*official theory name*) |
178 {name: string, (*official theory name*) |
462 |
462 |
463 (* datatype Proof.context *) |
463 (* datatype Proof.context *) |
464 |
464 |
465 structure Proof = |
465 structure Proof = |
466 struct |
466 struct |
467 datatype context = Context of Object.T Datatab.table * theory_ref; |
467 datatype context = Context of Any.T Datatab.table * theory_ref; |
468 end; |
468 end; |
469 |
469 |
470 fun theory_of_proof (Proof.Context (_, thy_ref)) = deref thy_ref; |
470 fun theory_of_proof (Proof.Context (_, thy_ref)) = deref thy_ref; |
471 fun data_of_proof (Proof.Context (data, _)) = data; |
471 fun data_of_proof (Proof.Context (data, _)) = data; |
472 fun map_prf f (Proof.Context (data, thy_ref)) = Proof.Context (f data, thy_ref); |
472 fun map_prf f (Proof.Context (data, thy_ref)) = Proof.Context (f data, thy_ref); |
474 |
474 |
475 (* proof data kinds *) |
475 (* proof data kinds *) |
476 |
476 |
477 local |
477 local |
478 |
478 |
479 val kinds = Synchronized.var "Proof_Data" (Datatab.empty: (theory -> Object.T) Datatab.table); |
479 val kinds = Synchronized.var "Proof_Data" (Datatab.empty: (theory -> Any.T) Datatab.table); |
480 |
480 |
481 fun invoke_init k = |
481 fun invoke_init k = |
482 (case Datatab.lookup (Synchronized.value kinds) k of |
482 (case Datatab.lookup (Synchronized.value kinds) k of |
483 SOME init => init |
483 SOME init => init |
484 | NONE => raise Fail "Invalid proof data identifier"); |
484 | NONE => raise Fail "Invalid proof data identifier"); |