src/Pure/theory.ML
changeset 23655 d2d1138e0ddc
parent 23600 5a5332e1351b
child 24137 8d7896398147
equal deleted inserted replaced
23654:a2ad1c166ac8 23655:d2d1138e0ddc
    94   oracles: ((theory * Object.T -> term) * stamp) NameSpace.table};
    94   oracles: ((theory * Object.T -> term) * stamp) NameSpace.table};
    95 
    95 
    96 fun make_thy (axioms, defs, oracles) =
    96 fun make_thy (axioms, defs, oracles) =
    97   Thy {axioms = axioms, defs = defs, oracles = oracles};
    97   Thy {axioms = axioms, defs = defs, oracles = oracles};
    98 
    98 
    99 fun err_dup_axms dups = error ("Duplicate axiom(s): " ^ commas_quote dups);
    99 fun err_dup_axm dup = error ("Duplicate axiom: " ^ quote dup);
   100 fun err_dup_oras dups = error ("Duplicate oracle(s): " ^ commas_quote dups);
   100 fun err_dup_ora dup = error ("Duplicate oracle: " ^ quote dup);
   101 
   101 
   102 structure ThyData = TheoryDataFun
   102 structure ThyData = TheoryDataFun
   103 (
   103 (
   104   type T = thy;
   104   type T = thy;
   105   val empty = make_thy (NameSpace.empty_table, Defs.empty, NameSpace.empty_table);
   105   val empty = make_thy (NameSpace.empty_table, Defs.empty, NameSpace.empty_table);
   113       val Thy {axioms = _, defs = defs2, oracles = oracles2} = thy2;
   113       val Thy {axioms = _, defs = defs2, oracles = oracles2} = thy2;
   114 
   114 
   115       val axioms = NameSpace.empty_table;
   115       val axioms = NameSpace.empty_table;
   116       val defs = Defs.merge pp (defs1, defs2);
   116       val defs = Defs.merge pp (defs1, defs2);
   117       val oracles = NameSpace.merge_tables (eq_snd (op =)) (oracles1, oracles2)
   117       val oracles = NameSpace.merge_tables (eq_snd (op =)) (oracles1, oracles2)
   118         handle Symtab.DUPS dups => err_dup_oras dups;
   118         handle Symtab.DUP dup => err_dup_ora dup;
   119     in make_thy (axioms, defs, oracles) end;
   119     in make_thy (axioms, defs, oracles) end;
   120 );
   120 );
   121 
   121 
   122 fun rep_theory thy = ThyData.get thy |> (fn Thy args => args);
   122 fun rep_theory thy = ThyData.get thy |> (fn Thy args => args);
   123 
   123 
   180 
   180 
   181 fun gen_add_axioms prep_axm raw_axms thy = thy |> map_axioms (fn axioms =>
   181 fun gen_add_axioms prep_axm raw_axms thy = thy |> map_axioms (fn axioms =>
   182   let
   182   let
   183     val axms = map (apsnd (Compress.term thy o Logic.varify) o prep_axm thy) raw_axms;
   183     val axms = map (apsnd (Compress.term thy o Logic.varify) o prep_axm thy) raw_axms;
   184     val axioms' = NameSpace.extend_table (Sign.naming_of thy) axms axioms
   184     val axioms' = NameSpace.extend_table (Sign.naming_of thy) axms axioms
   185       handle Symtab.DUPS dups => err_dup_axms dups;
   185       handle Symtab.DUP dup => err_dup_axm dup;
   186   in axioms' end);
   186   in axioms' end);
   187 
   187 
   188 in
   188 in
   189 
   189 
   190 val add_axioms = gen_add_axioms read_axm;
   190 val add_axioms = gen_add_axioms read_axm;
   305 
   305 
   306 (** add oracle **)
   306 (** add oracle **)
   307 
   307 
   308 fun add_oracle (bname, oracle) thy = thy |> map_oracles (fn oracles =>
   308 fun add_oracle (bname, oracle) thy = thy |> map_oracles (fn oracles =>
   309   NameSpace.extend_table (Sign.naming_of thy) [(bname, (oracle, stamp ()))] oracles
   309   NameSpace.extend_table (Sign.naming_of thy) [(bname, (oracle, stamp ()))] oracles
   310     handle Symtab.DUPS dups => err_dup_oras dups);
   310     handle Symtab.DUP dup => err_dup_ora dup);
   311 
   311 
   312 end;
   312 end;
   313 
   313 
   314 structure BasicTheory: BASIC_THEORY = Theory;
   314 structure BasicTheory: BASIC_THEORY = Theory;
   315 open BasicTheory;
   315 open BasicTheory;