src/HOL/Prolog/Test.ML
author oheimb
Fri Jun 02 12:44:04 2000 +0200 (2000-06-02)
changeset 9015 8006e9009621
child 12486 0ed8bdd883e0
permissions -rw-r--r--
added HOL/Prolog
oheimb@9015
     1
open Test;
oheimb@9015
     2
oheimb@9015
     3
val prog_Test = prog_HOHH@[append, reverse, mappred, mapfun, age, eq, bag_appl];
oheimb@9015
     4
fun pgoal s = (case Goal s of _ => by(prolog_tac prog_Test));
oheimb@9015
     5
val p = ptac prog_Test 1;
oheimb@9015
     6
oheimb@9015
     7
pgoal "append ?x ?y [a,b,c,d]";
oheimb@9015
     8
back();
oheimb@9015
     9
back();
oheimb@9015
    10
back();
oheimb@9015
    11
back();
oheimb@9015
    12
oheimb@9015
    13
pgoal "append [a,b] y ?L";
oheimb@9015
    14
pgoal "!y. append [a,b] y (?L y)";
oheimb@9015
    15
oheimb@9015
    16
pgoal "reverse [] ?L";
oheimb@9015
    17
oheimb@9015
    18
pgoal "reverse [23] ?L";
oheimb@9015
    19
pgoal "reverse [23,24,?x] ?L";
oheimb@9015
    20
pgoal "reverse ?L [23,24,?x]";
oheimb@9015
    21
oheimb@9015
    22
pgoal "mappred age ?x [23,24]";
oheimb@9015
    23
back();
oheimb@9015
    24
oheimb@9015
    25
pgoal "mappred (%x y. ? z. age z y) ?x [23,24]";
oheimb@9015
    26
oheimb@9015
    27
pgoal "mappred ?P [bob,sue] [24,23]";
oheimb@9015
    28
oheimb@9015
    29
pgoal "mapfun f [bob,bob,sue] [?x,?y,?z]";
oheimb@9015
    30
oheimb@9015
    31
pgoal "mapfun (%x. h x 25) [bob,sue] ?L";
oheimb@9015
    32
oheimb@9015
    33
pgoal "mapfun ?F [24,25] [h bob 24,h bob 25]";
oheimb@9015
    34
oheimb@9015
    35
pgoal "mapfun ?F [24] [h 24 24]";
oheimb@9015
    36
back();
oheimb@9015
    37
back();
oheimb@9015
    38
back();
oheimb@9015
    39
oheimb@9015
    40
oheimb@9015
    41
(*
oheimb@9015
    42
goal thy "f a = ?g a a & ?g = x"; 
oheimb@9015
    43
by(rtac conjI 1);
oheimb@9015
    44
by(rtac refl 1);
oheimb@9015
    45
back();
oheimb@9015
    46
back();
oheimb@9015
    47
*)
oheimb@9015
    48
oheimb@9015
    49
pgoal "True";
oheimb@9015
    50
oheimb@9015
    51
pgoal "age ?x 24 & age ?y 23";
oheimb@9015
    52
back();
oheimb@9015
    53
oheimb@9015
    54
pgoal "age ?x 24 | age ?x 23";
oheimb@9015
    55
back();
oheimb@9015
    56
back();
oheimb@9015
    57
oheimb@9015
    58
pgoal "? x y. age x y";
oheimb@9015
    59
oheimb@9015
    60
pgoal "!x y. append [] x x";
oheimb@9015
    61
oheimb@9015
    62
pgoal "age sue 24 .. age bob 23 => age ?x ?y";
oheimb@9015
    63
back();
oheimb@9015
    64
back();
oheimb@9015
    65
back();
oheimb@9015
    66
back();
oheimb@9015
    67
oheimb@9015
    68
(*set trace_DEPTH_FIRST;*)
oheimb@9015
    69
pgoal "age bob 25 :- age bob 24 => age bob 25";
oheimb@9015
    70
(*reset trace_DEPTH_FIRST;*)
oheimb@9015
    71
oheimb@9015
    72
pgoal "(!x. age x 25 :- age x 23) => age ?x 25 & age ?y 25";
oheimb@9015
    73
back();
oheimb@9015
    74
back();
oheimb@9015
    75
back();
oheimb@9015
    76
oheimb@9015
    77
pgoal "!x. ? y. eq x y";
oheimb@9015
    78
oheimb@9015
    79
pgoal "? P. P & eq P ?x";
oheimb@9015
    80
(*
oheimb@9015
    81
back();
oheimb@9015
    82
back();
oheimb@9015
    83
back();
oheimb@9015
    84
back();
oheimb@9015
    85
back();
oheimb@9015
    86
back();
oheimb@9015
    87
back();
oheimb@9015
    88
back();
oheimb@9015
    89
*)
oheimb@9015
    90
oheimb@9015
    91
pgoal "? P. eq P (True & True) & P";
oheimb@9015
    92
oheimb@9015
    93
pgoal "? P. eq P op | & P k True";
oheimb@9015
    94
oheimb@9015
    95
pgoal "? P. eq P (Q => True) & P";
oheimb@9015
    96
oheimb@9015
    97
(* P flexible: *)
oheimb@9015
    98
pgoal "(!P k l. P k l :- eq P Q) => Q a b";
oheimb@9015
    99
(*
oheimb@9015
   100
loops:
oheimb@9015
   101
pgoal "(!P k l. P k l :- eq P (%x y. x | y)) => a | b";
oheimb@9015
   102
*)
oheimb@9015
   103
oheimb@9015
   104
(* implication and disjunction in atom: *)
oheimb@9015
   105
goal thy "? Q. (!p q. R(q :- p) => R(Q p q)) & Q (t | s) (s | t)";
oheimb@9015
   106
by(fast_tac HOL_cs 1);
oheimb@9015
   107
oheimb@9015
   108
(* disjunction in atom: *)
oheimb@9015
   109
goal thy "(!P. g P :- (P => b | a)) => g(a | b)";
oheimb@9015
   110
by(step_tac HOL_cs 1);
oheimb@9015
   111
by(step_tac HOL_cs 1);
oheimb@9015
   112
by(step_tac HOL_cs 1);
oheimb@9015
   113
by(fast_tac HOL_cs 2);
oheimb@9015
   114
by(fast_tac HOL_cs 1);
oheimb@9015
   115
(*
oheimb@9015
   116
hangs:
oheimb@9015
   117
goal thy "(!P. g P :- (P => b | a)) => g(a | b)";
oheimb@9015
   118
by(fast_tac HOL_cs 1);
oheimb@9015
   119
*)
oheimb@9015
   120
oheimb@9015
   121
pgoal "!Emp Stk.(\
oheimb@9015
   122
\                       empty    (Emp::'b) .. \
oheimb@9015
   123
\         (!(X::nat) S. add    X (S::'b)         (Stk X S)) .. \
oheimb@9015
   124
\         (!(X::nat) S. remove X ((Stk X S)::'b) S))\
oheimb@9015
   125
\ => bag_appl 23 24 ?X ?Y";
oheimb@9015
   126
oheimb@9015
   127
pgoal "!Qu. ( \
oheimb@9015
   128
\          (!L.            empty    (Qu L L)) .. \
oheimb@9015
   129
\          (!(X::nat) L K. add    X (Qu L (X#K)) (Qu L K)) ..\
oheimb@9015
   130
\          (!(X::nat) L K. remove X (Qu (X#L) K) (Qu L K)))\
oheimb@9015
   131
\ => bag_appl 23 24 ?X ?Y";
oheimb@9015
   132
oheimb@9015
   133
pgoal "D & (!y. E) :- (!x. True & True) :- True => D";
oheimb@9015
   134
oheimb@9015
   135
pgoal "P x .. P y => P ?X";
oheimb@9015
   136
back();
oheimb@9015
   137
(*
oheimb@9015
   138
back();
oheimb@9015
   139
-> problem with DEPTH_SOLVE:
oheimb@9015
   140
Exception- THM ("dest_state", 1, ["P x & P y --> P y"]) raised
oheimb@9015
   141
Exception raised at run-time
oheimb@9015
   142
*)