src/Pure/isac/smltest/Scripts/listg.sml
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 21 Jul 2010 13:53:39 +0200
branchisac-from-Isabelle2009-2
changeset 37871 875b6efa7ced
permissions -rw-r--r--
added isac-hook in Pure/thm and isac-code
neuper@37871
     1
(* tests for ListG
neuper@37871
     2
   author: Walther Neuper 1.5.03
neuper@37871
     3
neuper@37871
     4
use"../smltest/Scripts/listg.sml";
neuper@37871
     5
use"listg.sml";
neuper@37871
     6
*)
neuper@37871
     7
neuper@37871
     8
neuper@37871
     9
neuper@37871
    10
"--------------------- nth_ ----------------------------------------------";
neuper@37871
    11
"--------------------- nth_ ----------------------------------------------";
neuper@37871
    12
"--------------------- nth_ ----------------------------------------------";
neuper@37871
    13
val t = str2term "nth_ 3 [a,b,c,d,e]";
neuper@37871
    14
atomty t;
neuper@37871
    15
val thm = (#prop o rep_thm o num_str) nth_Cons_;
neuper@37871
    16
atomty thm;
neuper@37871
    17
val Some (t',_) = rewrite_ thy dummy_ord Poly_erls false (num_str nth_Cons_) t;
neuper@37871
    18
if term2str t' = "nth_ (3 + - 1) [b, c, d, e]" then () 
neuper@37871
    19
else raise error "list_rls.sml, nth_ (3 + - 1) [b, c, d, e]";
neuper@37871
    20
neuper@37871
    21
val t = str2term "nth_ 1 [a,b,c,d,e]";
neuper@37871
    22
atomty t;
neuper@37871
    23
val thm = (#prop o rep_thm o num_str) nth_Nil_;
neuper@37871
    24
atomty thm;
neuper@37871
    25
val Some (t',_) = rewrite_ thy dummy_ord Poly_erls false (num_str nth_Nil_) t;
neuper@37871
    26
term2str t';
neuper@37871
    27
"a";
neuper@37871
    28
neuper@37871
    29
val t = str2term "nth_ 3 [a,b,c,d,e]";
neuper@37871
    30
atomty t;
neuper@37871
    31
trace_rewrite:=true;
neuper@37871
    32
val Some (t',_) = rewrite_set_ thy false list_rls t;
neuper@37871
    33
trace_rewrite:=false;
neuper@37871
    34
term2str t';
neuper@37871
    35
"c";
neuper@37871
    36
neuper@37871
    37
(*-------------------------------------------------------------------*)
neuper@37871
    38
val Some (Thm (_,thm)) = rls_get_thm list_rls "nth_Nil_";
neuper@37871
    39
val ttt = (#prop o rep_thm) thm;
neuper@37871
    40
atomty ttt;
neuper@37871
    41
(*Free ( 1, real)   ...OK, Var ((x, 0), ?'a) OK*)
neuper@37871
    42
neuper@37871
    43
neuper@37871
    44
neuper@37871
    45
"--------------------- length_ -------------------------------------------";
neuper@37871
    46
"--------------------- length_ -------------------------------------------";
neuper@37871
    47
"--------------------- length_ -------------------------------------------";
neuper@37871
    48
val thy' = "ListG.thy";
neuper@37871
    49
val ct = "length_ [1,1,1]";
neuper@37871
    50
val thm = ("length_Cons_","");
neuper@37871
    51
val (ct,asm) = the (rewrite thy' "tless_true" ("tval_rls") false thm ct);
neuper@37871
    52
val (ct,asm) = the (rewrite thy' "tless_true" ("tval_rls") false thm ct);
neuper@37871
    53
val (ct,asm) = the (rewrite thy' "tless_true" ("tval_rls") false thm ct);
neuper@37871
    54
val thm = ("length_Nil_","");
neuper@37871
    55
val (ct,asm) = the (rewrite thy' "tless_true" ("tval_rls") false thm ct);
neuper@37871
    56
if ct="1 + (1 + (1 + 0))"then()
neuper@37871
    57
else raise error ("list_rls.sml 1: behaviour of test-expl changed: "^ct);
neuper@37871
    58
neuper@37871
    59
neuper@37871
    60
val ct = "length_ [1,1,1]";
neuper@37871
    61
val rls = "list_rls";
neuper@37871
    62
val (ct,asm) = the (rewrite_set thy' false rls ct);
neuper@37871
    63
if ct="3"then()
neuper@37871
    64
else raise error ("list_rls.sml 2: behaviour of test-expl changed: "^ct);
neuper@37871
    65
neuper@37871
    66
neuper@37871
    67
val ct = "length_ [1,1,1]";
neuper@37871
    68
val t = (term_of o the o (parse ListG.thy)) ct;
neuper@37871
    69
val t = eval_listexpr_ ListG.thy list_rls t;
neuper@37871
    70
case t of Free ("3",_) => () 
neuper@37871
    71
| _ => raise error ("list-rls.sml 3: behaviour of test-expl changed: "^ct);
neuper@37871
    72
neuper@37871
    73
neuper@37871
    74
"--------------------- 29.4.03: union ------------------------------------";
neuper@37871
    75
"--------------------- 29.4.03: union ------------------------------------";
neuper@37871
    76
"--------------------- 29.4.03: union ------------------------------------";
neuper@37871
    77
neuper@37871
    78
fun ins_ x xs = if x mem xs then xs else x :: xs;
neuper@37871
    79
fun union_ xs [] = xs
neuper@37871
    80
  | union_ [] ys = ys
neuper@37871
    81
  | union_ (x :: xs) ys = union_ xs (ins_ x ys);
neuper@37871
    82
neuper@37871
    83
neuper@37871
    84
val t = (term_of o the o (parse ListG.thy)) "1 mem []";
neuper@37871
    85
atomty t;
neuper@37871
    86
neuper@37871
    87