src/FOLP/ex/if.ML
author nipkow
Wed, 07 Feb 1996 12:22:32 +0100
changeset 1481 03f096efa26d
parent 0 a5a9c433f639
permissions -rw-r--r--
Modified datatype com. Added (part of) relative completeness proof for Hoare logic.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	FOLP/ex/if
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
For ex/if.thy.  First-Order Logic: the 'if' example
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
open If;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
open Cla;    (*in case structure Int is open!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
val prems = goalw If.thy [if_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
    "[| !!x.x:P ==> f(x):Q; !!x.x:~P ==> g(x):R |] ==> ?p:if(P,Q,R)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
by (fast_tac (FOLP_cs addIs prems) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
val ifI = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
val major::prems = goalw If.thy [if_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
   "[| p:if(P,Q,R);  !!x y.[| x:P; y:Q |] ==> f(x,y):S; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
\                    !!x y.[| x:~P; y:R |] ==> g(x,y):S |] ==> ?p:S";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
by (cut_facts_tac [major] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
by (fast_tac (FOLP_cs addIs prems) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
val ifE = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
goal If.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
    "?p : if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
by (resolve_tac [iffI] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
by (eresolve_tac [ifE] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
by (eresolve_tac [ifE] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
by (resolve_tac [ifI] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
by (resolve_tac [ifI] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
choplev 0;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
val if_cs = FOLP_cs addSIs [ifI] addSEs[ifE];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
by (fast_tac if_cs 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
val if_commute = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
goal If.thy "?p : if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
by (fast_tac if_cs 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
val nested_ifs = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
writeln"Reached end of file.";