test/Tools/isac/ProgLang/listC.sml
author Walther Neuper <neuper@ist.tugraz.at>
Mon, 21 Oct 2013 09:03:50 +0200
changeset 52148 aabc6c8e930a
parent 42390 96174a374a7a
child 59188 c477d0f79ab9
permissions -rw-r--r--
"axiomatization" replaces "axioms" preparing for Isabelle2013-1

Note the text at begin of ListC.thy
     1 (* Title: tests for ListC
     2    Author: Walther Neuper 030501
     3    (c) copyright due to lincense terms.
     4 *)
     5 
     6 "-----------------------------------------------------------------------------";
     7 "-----------------------------------------------------------------------------";
     8 "table of contents -----------------------------------------------------------";
     9 "-----------------------------------------------------------------------------";
    10 "--------------------- NTH ---------------------------------------------------";
    11 "--------------------- LENGTH ------------------------------------------------";
    12 "--------------------- tl ----------------------------------------------------";
    13 "-----------------------------------------------------------------------------";
    14 "-----------------------------------------------------------------------------";
    15 
    16 
    17 "--------------------- NTH ---------------------------------------------------";
    18 "--------------------- NTH ---------------------------------------------------";
    19 "--------------------- NTH ---------------------------------------------------";
    20 val list_rls = assoc_rls "list_rls"
    21 
    22 val t = str2term "NTH 1 [a,b,c,d,e]";
    23 atomty t;
    24 val thm = (#prop o rep_thm o num_str) @{thm NTH_NIL};
    25 atomty thm;
    26 val SOME (t', _) = rewrite_ thy dummy_ord list_rls false (num_str @{thm NTH_NIL}) t;
    27 if term2str t' = "a" then () 
    28 else error "NTH 1 [a,b,c,d,e] = a ..changed";
    29 
    30 val t = str2term "NTH 3 [a,b,c,d,e]";
    31 val Const ("ListC.NTH", _) $ Free ("3", _) $ (Const ("List.list.Cons", _) $ Free ("a", _) $
    32   (Const ("List.list.Cons", _) $ Free ("b", _) $ 
    33     (Const _ $ Free _ $ (Const _ $ Free _ $ (Const _ $ Free _ $ Const _))))) = t;
    34 atomty t;
    35 val thm = (#prop o rep_thm o num_str) @{thm NTH_CONS};
    36 atomty thm;
    37 val SOME (t', _) = rewrite_ thy dummy_ord list_rls false (num_str @{thm NTH_CONS}) t;
    38 if term2str t' = "NTH (3 + -1) [b, c, d, e]" then () 
    39 else error "NTH 3 [a,b,c,d,e] = NTH (3 + - 1) [b, c, d, e] ..changed";
    40 
    41 (* now the argument "(3 + - 1)" etc needs to be evaluated in the assumption of NTH_CONS *)
    42 val t = str2term "NTH 3 [a,b,c,d,e]";
    43 atomty t;
    44 trace_rewrite := true;
    45 val SOME (t', _) = rewrite_set_ thy false list_rls t;
    46 trace_rewrite := false;
    47 if term2str t' = "c" then () 
    48 else error "NTH 3 [a,b,c,d,e] = c ..changed";
    49 
    50 "--------------------- LENGTH ------------------------------------------------";
    51 "--------------------- LENGTH ------------------------------------------------";
    52 "--------------------- LENGTH ------------------------------------------------";
    53 val list_rls = assoc_rls "list_rls"
    54 
    55 val thy = @{theory ListC};
    56 val t = str2term "LENGTH [1, 1, 1]";
    57 val SOME (t, asm) = rewrite_ thy tless_true tval_rls false @{thm LENGTH_CONS} t;
    58 term2str t = "1 + LENGTH [1, 1]";
    59 val SOME (t, asm) = rewrite_ thy tless_true tval_rls false @{thm LENGTH_CONS} t;
    60 term2str t = "1 + (1 + LENGTH [1])";
    61 val SOME (t, asm) = rewrite_ thy tless_true tval_rls false @{thm LENGTH_CONS} t;
    62 term2str t = "1 + (1 + (1 + LENGTH []))";
    63 val NONE          = rewrite_ thy tless_true tval_rls false @{thm LENGTH_CONS} t;
    64 val SOME (t, asm) = rewrite_ thy tless_true tval_rls false @{thm LENGTH_NIL} t;
    65 val NONE          = rewrite_ thy tless_true tval_rls false @{thm LENGTH_NIL} t;
    66 if term2str t = "1 + (1 + (1 + 0))" then () 
    67 else error "LENGTH [1, 1, 1] = 1 + (1 + (1 + 0))  ..changed";
    68 
    69 val t = str2term "LENGTH [1, 1, 1]";
    70 val SOME (t, asm) = rewrite_set_ thy false list_rls t;
    71 if term2str t = "3" then ()
    72 else error "LENGTH [1, 1, 1] = 3  ..list_rls changed";
    73 
    74 val t = str2term "LENGTH [1, 1, 1]";
    75 val t = eval_listexpr_ thy list_rls t;
    76 case t of Free ("3", _) => () 
    77 | _ => error "LENGTH [1, 1, 1] = 3  ..eval_listexpr_ changed";
    78