test/Tools/isac/ADDTESTS/accumulate-val/lucas_interpreter.sml
author Walther Neuper <walther.neuper@jku.at>
Sat, 04 Apr 2020 12:11:32 +0200
changeset 59850 f3cac3053e7b
parent 59417 3a7d1c9e91f3
child 59851 4dd533681fef
permissions -rw-r--r--
separate Rule_Set from Rule
     1 (* KEStore holds Knowledge and Exercises in Isac's Java front-end.
     2   In the front-end knowledge comprises theories, problems and methods.
     3   Elements of problems and methods are defined in theories alongside
     4   the development of respective language elements. 
     5   The structure of methods and problems is independent from theories' deductive
     6   structure. The respective structures are built in Build_Thydata.thy.
     7 *)
     8 signature KESTORE_ELEMS =
     9 sig
    10   val get_rlss: theory -> (Rule_Set.rls' * (Rule.theory' * Rule_Set.rls)) list
    11   val add_rlss: (Rule_Set.rls' * (Rule.theory' * Rule_Set.rls)) list -> theory -> theory
    12   val get_calcs: theory -> (Rule_Set.prog_calcID * (Rule.calID * Rule.eval_fn)) list
    13   val add_calcs: (Rule_Set.prog_calcID * (Rule.calID * Rule.eval_fn)) list -> theory -> theory
    14   (*etc*)
    15 end;                               
    16 
    17 structure Test_KEStore_Elems: KESTORE_ELEMS =
    18 struct
    19   fun union_overwrite eq l1 l2 = fold (insert eq) l2 (*..swapped..*) l1;
    20 
    21   fun rls_eq ((id1, (thyID1, _)), (id2, (thyID2, _))) = id1 = id2 (*andalso thyID1 = thyID2*)
    22   structure Data = Theory_Data (
    23     type T = (Rule_Set.rls' * (Rule.theory' * Rule_Set.rls)) list;
    24     val empty = [];
    25     val extend = I;
    26     val merge = merge rls_eq;
    27     );  
    28   fun get_rlss thy = Data.get thy
    29   fun add_rlss rlss = Data.map (union_overwrite rls_eq rlss)
    30 
    31   val calc_eq = rls_eq
    32   structure Data = Theory_Data (
    33     type T = (Rule_Set.prog_calcID * (Rule.calID * Rule.eval_fn)) list;
    34     val empty = [];
    35     val extend = I;
    36     val merge = merge calc_eq;
    37     );                                                              
    38   fun get_calcs thy = Data.get thy
    39   fun add_calcs calcs = Data.map (union_overwrite calc_eq calcs)
    40 
    41   (*etc*)
    42 end;