src/CTT/Bool.thy
author wenzelm
Wed, 26 Jul 2006 00:44:44 +0200
changeset 20207 4c57e850e8d5
parent 19762 957bcf55c98f
child 21404 eb85850d3eb7
permissions -rw-r--r--
added Pure/subgoal.ML;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1474
3f7d67927fe2 expanded tabs
clasohm
parents: 0
diff changeset
     1
(*  Title:      CTT/bool
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1474
3f7d67927fe2 expanded tabs
clasohm
parents: 0
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
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
17441
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     7
header {* The two-element type (booleans and conditionals) *}
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     8
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     9
theory Bool
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    10
imports CTT
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    11
begin
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
19762
wenzelm
parents: 19761
diff changeset
    13
definition
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    14
  Bool :: "t"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    15
  "Bool == T+T"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    16
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    17
  true :: "i"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    18
  "true == inl(tt)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    19
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    20
  false :: "i"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    21
  "false == inr(tt)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    22
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    23
  cond :: "[i,i,i]=>i"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    24
  "cond(a,b,c) == when(a, %u. b, %u. c)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    25
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    26
lemmas bool_defs = Bool_def true_def false_def cond_def
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    27
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    28
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    29
subsection {* Derivation of rules for the type Bool *}
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    30
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    31
(*formation rule*)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    32
lemma boolF: "Bool type"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    33
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    34
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    35
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    36
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    37
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    38
(*introduction rules for true, false*)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    39
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    40
lemma boolI_true: "true : Bool"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    41
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    42
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    43
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    44
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    45
lemma boolI_false: "false : Bool"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    46
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    47
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    48
done
17441
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    49
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    50
(*elimination rule: typing of cond*)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    51
lemma boolE: 
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    52
    "[| p:Bool;  a : C(true);  b : C(false) |] ==> cond(p,a,b) : C(p)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    53
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    54
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    55
apply (erule_tac [!] TE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    56
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    57
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    58
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    59
lemma boolEL: 
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    60
    "[| p = q : Bool;  a = c : C(true);  b = d : C(false) |]  
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    61
     ==> cond(p,a,b) = cond(q,c,d) : C(p)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    62
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    63
apply (rule PlusEL)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    64
apply (erule asm_rl refl_elem [THEN TEL])+
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    65
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    66
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    67
(*computation rules for true, false*)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    68
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    69
lemma boolC_true: 
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    70
    "[| a : C(true);  b : C(false) |] ==> cond(true,a,b) = a : C(true)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    71
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    72
apply (rule comp_rls)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    73
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    74
apply (erule_tac [!] TE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    75
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    76
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    77
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    78
lemma boolC_false: 
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    79
    "[| a : C(true);  b : C(false) |] ==> cond(false,a,b) = b : C(false)"
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    80
apply (unfold bool_defs)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    81
apply (rule comp_rls)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    82
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    83
apply (erule_tac [!] TE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    84
apply (tactic "typechk_tac []")
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents: 17441
diff changeset
    85
done
17441
5b5feca0344a converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    86
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
end