src/CTT/Bool.ML
author clasohm
Thu Sep 16 12:20:38 1993 +0200 (1993-09-16)
changeset 0 a5a9c433f639
child 360 2b74eebdbdb8
permissions -rw-r--r--
Initial revision
clasohm@0
     1
(*  Title: 	CTT/bool
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1991  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Theorems for bool.thy (booleans and conditionals)
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
open Bool;
clasohm@0
    10
clasohm@0
    11
val bool_defs = [Bool_def,true_def,false_def,cond_def];
clasohm@0
    12
clasohm@0
    13
(*Derivation of rules for the type Bool*)
clasohm@0
    14
clasohm@0
    15
(*formation rule*)
clasohm@0
    16
val boolF = prove_goal Bool.thy 
clasohm@0
    17
    "Bool type"
clasohm@0
    18
 (fn prems=>
clasohm@0
    19
  [ (rewrite_goals_tac bool_defs),
clasohm@0
    20
    (typechk_tac[]) ]);
clasohm@0
    21
clasohm@0
    22
clasohm@0
    23
(*introduction rules for true, false*)
clasohm@0
    24
clasohm@0
    25
val boolI_true = prove_goal Bool.thy 
clasohm@0
    26
    "true : Bool"
clasohm@0
    27
 (fn prems=>
clasohm@0
    28
  [ (rewrite_goals_tac bool_defs),
clasohm@0
    29
    (typechk_tac[]) ]);
clasohm@0
    30
clasohm@0
    31
val boolI_false = prove_goal Bool.thy 
clasohm@0
    32
    "false : Bool"
clasohm@0
    33
 (fn prems=>
clasohm@0
    34
  [ (rewrite_goals_tac bool_defs),
clasohm@0
    35
    (typechk_tac[]) ]);
clasohm@0
    36
clasohm@0
    37
(*elimination rule: typing of cond*)
clasohm@0
    38
val boolE = prove_goal Bool.thy 
clasohm@0
    39
    "[| p:Bool;  a : C(true);  b : C(false) |] ==> cond(p,a,b) : C(p)"
clasohm@0
    40
 (fn prems=>
clasohm@0
    41
  [ (cut_facts_tac prems 1),
clasohm@0
    42
    (rewrite_goals_tac bool_defs),
clasohm@0
    43
    (typechk_tac prems),
clasohm@0
    44
    (ALLGOALS (etac TE)),
clasohm@0
    45
    (typechk_tac prems) ]);
clasohm@0
    46
clasohm@0
    47
val boolEL = prove_goal Bool.thy 
clasohm@0
    48
    "[| p = q : Bool;  a = c : C(true);  b = d : C(false) |] ==> \
clasohm@0
    49
\    cond(p,a,b) = cond(q,c,d) : C(p)"
clasohm@0
    50
 (fn prems=>
clasohm@0
    51
  [ (cut_facts_tac prems 1),
clasohm@0
    52
    (rewrite_goals_tac bool_defs),
clasohm@0
    53
    (resolve_tac [PlusEL] 1),
clasohm@0
    54
    (REPEAT (eresolve_tac [asm_rl, refl_elem RS TEL] 1)) ]);
clasohm@0
    55
clasohm@0
    56
(*computation rules for true, false*)
clasohm@0
    57
clasohm@0
    58
val boolC_true = prove_goal Bool.thy 
clasohm@0
    59
    "[| a : C(true);  b : C(false) |] ==> cond(true,a,b) = a : C(true)"
clasohm@0
    60
 (fn prems=>
clasohm@0
    61
  [ (cut_facts_tac prems 1),
clasohm@0
    62
    (rewrite_goals_tac bool_defs),
clasohm@0
    63
    (resolve_tac comp_rls 1),
clasohm@0
    64
    (typechk_tac[]),
clasohm@0
    65
    (ALLGOALS (etac TE)),
clasohm@0
    66
    (typechk_tac prems) ]);
clasohm@0
    67
clasohm@0
    68
val boolC_false = prove_goal Bool.thy 
clasohm@0
    69
    "[| a : C(true);  b : C(false) |] ==> cond(false,a,b) = b : C(false)"
clasohm@0
    70
 (fn prems=>
clasohm@0
    71
  [ (cut_facts_tac prems 1),
clasohm@0
    72
    (rewrite_goals_tac bool_defs),
clasohm@0
    73
    (resolve_tac comp_rls 1),
clasohm@0
    74
    (typechk_tac[]),
clasohm@0
    75
    (ALLGOALS (etac TE)),
clasohm@0
    76
    (typechk_tac prems) ]);
clasohm@0
    77
clasohm@0
    78
writeln"Reached end of file.";
clasohm@0
    79