src/HOL/Prolog/Test.thy
author wenzelm
Fri, 13 May 2011 22:55:00 +0200
changeset 42793 88bee9f6eec7
parent 41310 65631ca437c9
child 46473 a687b75f9fa8
permissions -rw-r--r--
proper Proof.context for classical tactics; reduced claset to snapshot of classical context; discontinued clasimpset;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13208
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     1
(*  Title:    HOL/Prolog/Test.thy
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     2
    Author:   David von Oheimb (based on a lecture on Lambda Prolog by Nadathur)
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     3
*)
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
     4
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
     5
header {* Basic examples *}
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
     6
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
     7
theory Test
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
     8
imports HOHH
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
     9
begin
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    10
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    11
typedecl nat
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    12
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    13
typedecl 'a list
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    14
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    15
consts
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    16
  Nil   :: "'a list"                                  ("[]")
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    17
  Cons  :: "'a => 'a list => 'a list"                 (infixr "#"  65)
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    18
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    19
syntax
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    20
  (* list Enumeration *)
35109
0015a0a99ae9 modernized syntax/translations;
wenzelm
parents: 34974
diff changeset
    21
  "_list"     :: "args => 'a list"                          ("[(_)]")
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    22
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    23
translations
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    24
  "[x, xs]"     == "x#[xs]"
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    25
  "[x]"         == "x#[]"
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    26
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    27
typedecl person
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    28
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    29
consts
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    30
  append  :: "['a list, 'a list, 'a list]            => bool"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    31
  reverse :: "['a list, 'a list]                     => bool"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    32
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    33
  mappred :: "[('a => 'b => bool), 'a list, 'b list] => bool"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    34
  mapfun  :: "[('a => 'b), 'a list, 'b list]         => bool"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    35
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    36
  bob     :: person
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    37
  sue     :: person
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    38
  ned     :: person
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    39
41310
65631ca437c9 proper identifiers for consts and types;
wenzelm
parents: 36319
diff changeset
    40
  nat23   :: nat          ("23")
65631ca437c9 proper identifiers for consts and types;
wenzelm
parents: 36319
diff changeset
    41
  nat24   :: nat          ("24")
65631ca437c9 proper identifiers for consts and types;
wenzelm
parents: 36319
diff changeset
    42
  nat25   :: nat          ("25")
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    43
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    44
  age     :: "[person, nat]                          => bool"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    45
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    46
  eq      :: "['a, 'a]                               => bool"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    47
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    48
  empty   :: "['b]                                   => bool"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    49
  add     :: "['a, 'b, 'b]                           => bool"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    50
  remove  :: "['a, 'b, 'b]                           => bool"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    51
  bag_appl:: "['a, 'a, 'a, 'a]                       => bool"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    52
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    53
axioms
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    54
        append:  "append  []    xs  xs    ..
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    55
                  append (x#xs) ys (x#zs) :- append xs ys zs"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    56
        reverse: "reverse L1 L2 :- (!rev_aux.
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    57
                  (!L.          rev_aux  []    L  L )..
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    58
                  (!X L1 L2 L3. rev_aux (X#L1) L2 L3 :- rev_aux L1 L2 (X#L3))
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    59
                  => rev_aux L1 L2 [])"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    60
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    61
        mappred: "mappred P  []     []    ..
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    62
                  mappred P (x#xs) (y#ys) :- P x y  &  mappred P xs ys"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    63
        mapfun:  "mapfun f  []     []      ..
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    64
                  mapfun f (x#xs) (f x#ys) :- mapfun f xs ys"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    65
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    66
        age:     "age bob 24 ..
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    67
                  age sue 23 ..
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    68
                  age ned 23"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    69
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    70
        eq:      "eq x x"
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    71
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    72
(* actual definitions of empty and add is hidden -> yields abstract data type *)
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    73
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    74
        bag_appl: "bag_appl A B X Y:- (? S1 S2 S3 S4 S5.
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    75
                                empty    S1    &
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    76
                                add A    S1 S2 &
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    77
                                add B    S2 S3 &
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    78
                                remove X S3 S4 &
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    79
                                remove Y S4 S5 &
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    80
                                empty    S5)"
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
    81
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    82
lemmas prog_Test = append reverse mappred mapfun age eq bag_appl
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    83
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
    84
schematic_lemma "append ?x ?y [a,b,c,d]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    85
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    86
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    87
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    88
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    89
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    90
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    91
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
    92
schematic_lemma "append [a,b] y ?L"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    93
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    94
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    95
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
    96
schematic_lemma "!y. append [a,b] y (?L y)"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    97
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    98
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
    99
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   100
schematic_lemma "reverse [] ?L"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   101
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   102
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   103
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   104
schematic_lemma "reverse [23] ?L"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   105
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   106
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   107
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   108
schematic_lemma "reverse [23,24,?x] ?L"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   109
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   110
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   111
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   112
schematic_lemma "reverse ?L [23,24,?x]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   113
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   114
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   115
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   116
schematic_lemma "mappred age ?x [23,24]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   117
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   118
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   119
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   120
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   121
schematic_lemma "mappred (%x y. ? z. age z y) ?x [23,24]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   122
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   123
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   124
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   125
schematic_lemma "mappred ?P [bob,sue] [24,23]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   126
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   127
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   128
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   129
schematic_lemma "mapfun f [bob,bob,sue] [?x,?y,?z]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   130
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   131
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   132
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   133
schematic_lemma "mapfun (%x. h x 25) [bob,sue] ?L"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   134
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   135
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   136
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   137
schematic_lemma "mapfun ?F [24,25] [h bob 24,h bob 25]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   138
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   139
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   140
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   141
schematic_lemma "mapfun ?F [24] [h 24 24]"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   142
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   143
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   144
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   145
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   146
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   147
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   148
lemma "True"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   149
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   150
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   151
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   152
schematic_lemma "age ?x 24 & age ?y 23"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   153
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   154
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   155
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   156
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   157
schematic_lemma "age ?x 24 | age ?x 23"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   158
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   159
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   160
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   161
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   162
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   163
lemma "? x y. age x y"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   164
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   165
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   166
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   167
lemma "!x y. append [] x x"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   168
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   169
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   170
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   171
schematic_lemma "age sue 24 .. age bob 23 => age ?x ?y"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   172
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   173
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   174
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   175
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   176
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   177
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   178
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   179
(*set trace_DEPTH_FIRST;*)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   180
lemma "age bob 25 :- age bob 24 => age bob 25"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   181
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   182
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   183
(*reset trace_DEPTH_FIRST;*)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   184
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   185
schematic_lemma "(!x. age x 25 :- age x 23) => age ?x 25 & age ?y 25"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   186
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   187
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   188
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   189
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   190
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   191
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   192
lemma "!x. ? y. eq x y"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   193
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   194
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   195
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   196
schematic_lemma "? P. P & eq P ?x"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   197
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   198
(*
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   199
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   200
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   201
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   202
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   203
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   204
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   205
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   206
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   207
*)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   208
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   209
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   210
lemma "? P. eq P (True & True) & P"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   211
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   212
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   213
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   214
lemma "? P. eq P op | & P k True"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   215
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   216
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   217
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   218
lemma "? P. eq P (Q => True) & P"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   219
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   220
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   221
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   222
(* P flexible: *)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   223
lemma "(!P k l. P k l :- eq P Q) => Q a b"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   224
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   225
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   226
(*
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   227
loops:
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   228
lemma "(!P k l. P k l :- eq P (%x y. x | y)) => a | b"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   229
*)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   230
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   231
(* implication and disjunction in atom: *)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   232
lemma "? Q. (!p q. R(q :- p) => R(Q p q)) & Q (t | s) (s | t)"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   233
  by fast
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   234
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   235
(* disjunction in atom: *)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   236
lemma "(!P. g P :- (P => b | a)) => g(a | b)"
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 41310
diff changeset
   237
  apply (tactic "step_tac (put_claset HOL_cs @{context}) 1")
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 41310
diff changeset
   238
  apply (tactic "step_tac (put_claset HOL_cs @{context}) 1")
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 41310
diff changeset
   239
  apply (tactic "step_tac (put_claset HOL_cs @{context}) 1")
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   240
   prefer 2
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   241
   apply fast
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   242
  apply fast
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   243
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   244
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   245
(*
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   246
hangs:
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   247
lemma "(!P. g P :- (P => b | a)) => g(a | b)"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   248
  by fast
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   249
*)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   250
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   251
schematic_lemma "!Emp Stk.(
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   252
                       empty    (Emp::'b) .. 
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   253
         (!(X::nat) S. add    X (S::'b)         (Stk X S)) .. 
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   254
         (!(X::nat) S. remove X ((Stk X S)::'b) S))
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   255
 => bag_appl 23 24 ?X ?Y"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   256
  oops
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   257
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   258
schematic_lemma "!Qu. ( 
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   259
          (!L.            empty    (Qu L L)) .. 
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   260
          (!(X::nat) L K. add    X (Qu L (X#K)) (Qu L K)) ..
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   261
          (!(X::nat) L K. remove X (Qu (X#L) K) (Qu L K)))
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   262
 => bag_appl 23 24 ?X ?Y"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   263
  oops
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   264
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   265
lemma "D & (!y. E) :- (!x. True & True) :- True => D"
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   266
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   267
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   268
36319
8feb2c4bef1a mark schematic statements explicitly;
wenzelm
parents: 35109
diff changeset
   269
schematic_lemma "P x .. P y => P ?X"
21425
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   270
  apply (prolog prog_Test)
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   271
  back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   272
  done
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   273
(*
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   274
back
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   275
-> problem with DEPTH_SOLVE:
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   276
Exception- THM ("dest_state", 1, ["P x & P y --> P y"]) raised
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   277
Exception raised at run-time
c11ab38b78a7 HOL-Prolog: converted legacy ML scripts;
wenzelm
parents: 17311
diff changeset
   278
*)
17311
5b1d47d920ce converted to Isar theory format;
wenzelm
parents: 14981
diff changeset
   279
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
   280
end