src/HOLCF/ex/Classlib.thy
changeset 2642 3c3a84cc85a9
parent 2570 24d7e8fb8261
child 3154 6e20bf579edb
equal deleted inserted replaced
2641:533a84b3bedd 2642:3c3a84cc85a9
     3     Author:     Franz Regensburger
     3     Author:     Franz Regensburger
     4     Copyright   1995 Technical University Munich
     4     Copyright   1995 Technical University Munich
     5 
     5 
     6 Introduce various type classes
     6 Introduce various type classes
     7 
     7 
     8 The 8bit package is needed for this theory
     8 The type void of HOLCF/One.thy is a witness for all the introduced classes.
     9 
       
    10 The type void of HOLCF/Void.thy is a witness for all the introduced classes.
       
    11 Inspect theory Witness.thy for all the proofs. 
     9 Inspect theory Witness.thy for all the proofs. 
    12 
    10 
    13 the trivial instance for ++ -- ** // is LAM x y.(UU::void) 
    11 !!! Witness and Claslib have to be adapted to axclasses !!!
    14 the trivial instance for .= and .<=  is LAM x y.(UU::tr)
    12 ------------------------------------------------------------
       
    13 
       
    14 the trivial instance for ++ -- ** // is circ
       
    15 the trivial instance for .= and .<=  is bullet
    15 
    16 
    16 the class hierarchy is as follows
    17 the class hierarchy is as follows
    17 
    18 
    18         pcpo 
    19         pcpo 
    19          |        
    20          |        
    40 (* -------------------------------------------------------------------- *)
    41 (* -------------------------------------------------------------------- *)
    41 (* class cplus with characteristic constant  ++                         *)
    42 (* class cplus with characteristic constant  ++                         *)
    42  
    43  
    43 classes cplus < pcpo	
    44 classes cplus < pcpo	
    44 
    45 
    45 arities void :: cplus
    46 arities lift :: (term)cplus
    46 
    47 
    47 ops curried 
    48 ops curried 
    48 	"++"	:: "'a::cplus -> 'a -> 'a"		(cinfixl 65)
    49 	"++"	:: "'a::cplus -> 'a -> 'a"		(cinfixl 65)
    49 
    50 
    50 
    51 
    54 (* -------------------------------------------------------------------- *)
    55 (* -------------------------------------------------------------------- *)
    55 (* class cminus with characteristic constant --                         *)
    56 (* class cminus with characteristic constant --                         *)
    56  
    57  
    57 classes cminus < pcpo	
    58 classes cminus < pcpo	
    58 
    59 
    59 arities void :: cminus
    60 arities lift :: (term)cminus
    60 
    61 
    61 ops curried 
    62 ops curried 
    62 	"--"	:: "'a::cminus -> 'a -> 'a"		(cinfixl 65)
    63 	"--"	:: "'a::cminus -> 'a -> 'a"		(cinfixl 65)
    63 
    64 
    64 (* class cminus has no characteristic axioms                            *)
    65 (* class cminus has no characteristic axioms                            *)
    67 (* -------------------------------------------------------------------- *)
    68 (* -------------------------------------------------------------------- *)
    68 (* class ctimes with characteristic constant **                         *)
    69 (* class ctimes with characteristic constant **                         *)
    69  
    70  
    70 classes ctimes < pcpo	
    71 classes ctimes < pcpo	
    71 
    72 
    72 arities void :: ctimes
    73 arities lift :: (term)ctimes
    73 
    74 
    74 ops curried 
    75 ops curried 
    75 	"**"	:: "'a::ctimes -> 'a -> 'a"		(cinfixl 70)
    76 	"**"	:: "'a::ctimes -> 'a -> 'a"		(cinfixl 70)
    76 
    77 
    77 (* class ctimes has no characteristic axioms                            *)
    78 (* class ctimes has no characteristic axioms                            *)
    80 (* -------------------------------------------------------------------- *)
    81 (* -------------------------------------------------------------------- *)
    81 (* class cdiv with characteristic constant //                           *)
    82 (* class cdiv with characteristic constant //                           *)
    82  
    83  
    83 classes cdiv < pcpo	
    84 classes cdiv < pcpo	
    84 
    85 
    85 arities void :: cdiv
    86 arities lift :: (term)cdiv
    86 
    87 
    87 ops curried 
    88 ops curried 
    88 	"//"	:: "'a::cdiv -> 'a -> 'a"		(cinfixl 70)
    89 	"//"	:: "'a::cdiv -> 'a -> 'a"		(cinfixl 70)
    89 
    90 
    90 (* class cdiv has no characteristic axioms                              *)
    91 (* class cdiv has no characteristic axioms                              *)
    93 (* -------------------------------------------------------------------- *)
    94 (* -------------------------------------------------------------------- *)
    94 (* class per with characteristic constant .=                            *)
    95 (* class per with characteristic constant .=                            *)
    95  
    96  
    96 classes per < pcpo	
    97 classes per < pcpo	
    97 
    98 
    98 arities void :: per
    99 arities lift :: (term)per
    99 
   100 
   100 ops curried 
   101 ops curried 
   101 	".="	:: "'a::per -> 'a -> tr"	(cinfixl 55)
   102 	".="	:: "'a::per -> 'a -> tr"	(cinfixl 55)
   102 syntax (symbols)
   103 syntax (symbols)
   103 	"op .=" :: "'a::per => 'a => tr"	(infixl "\\<doteq>" 55)
   104 	"op .=" :: "'a::per => 'a => tr"	(infixl "\\<doteq>" 55)
   104 
   105 
   105 rules 
   106 rules 
   106 
   107 
   107 strict_per	"(UU .= x) = UU & (x .= UU) = UU"
   108 strict_per	"(UU .= x) = UU & (x .= UU) = UU"
   108 total_per	"[|x ~= UU; y ~= UU|] ==> (x .= y) ~= UU"
   109 total_per	"[|x ~= UU; y ~= UU|] ==> (x .= y) ~= UU"
   109 flat_per	"flat (UU::'a::per)"
   110 flat_per	"flat (x::'a::per)"
   110 
   111 
   111 sym_per		"(x .= y) = (y .= x)"
   112 sym_per		"(x .= y) = (y .= x)"
   112 trans_per	"[| (x .= y)=TT; (y .= z)=TT |] ==> (x .= z)=TT"
   113 trans_per	"[| (x .= y)=TT; (y .= z)=TT |] ==> (x .= z)=TT"
   113 
   114 
   114 (* -------------------------------------------------------------------- *)
   115 (* -------------------------------------------------------------------- *)
   116 (* -------------------------------------------------------------------- *)
   117 (* -------------------------------------------------------------------- *)
   117 (* class equiv is a refinement of of class per                          *)
   118 (* class equiv is a refinement of of class per                          *)
   118  
   119  
   119 classes equiv < per 	
   120 classes equiv < per 	
   120 
   121 
   121 arities void :: equiv
   122 arities lift :: (term)equiv
   122 
   123 
   123 rules 
   124 rules 
   124 
   125 
   125 refl_per	"[|(x::'a::equiv) ~= UU|] ==> (x .= x)=TT"
   126 refl_per	"[|(x::'a::equiv) ~= UU|] ==> (x .= x)=TT"
   126 
   127 
   129 (* -------------------------------------------------------------------- *)
   130 (* -------------------------------------------------------------------- *)
   130 (* class eq is a refinement of of class equiv                           *)
   131 (* class eq is a refinement of of class equiv                           *)
   131  
   132  
   132 classes eq < equiv  	
   133 classes eq < equiv  	
   133 
   134 
   134 arities void :: eq
   135 arities lift :: (term)eq
   135 
   136 
   136 rules 
   137 rules 
   137 
   138 
   138 weq	"[| (x::'a::eq) ~= UU; y ~= UU |] ==> 
   139 weq	"[| (x::'a::eq) ~= UU; y ~= UU |] ==> 
   139 	 (x = y --> (x .=y) = TT) & (x ~= y --> (x .= y)=FF)"
   140 	 (x = y --> (x .=y) = TT) & (x ~= y --> (x .= y)=FF)"
   140 
   141 
   141 (* -------------------------------------------------------------------- *)
       
   142 
       
   143 (* -------------------------------------------------------------------- *)
       
   144 (* class qpo with characteristic constant .<=                           *)
       
   145 (*  .<= is a partial order wrt an equivalence                           *)
       
   146  
       
   147 classes qpo < equiv	
       
   148 
       
   149 arities void :: qpo
       
   150 
       
   151 ops curried 
       
   152 	".<="	:: "'a::qpo -> 'a -> tr"	(cinfixl 55)
       
   153 syntax (symbols)
       
   154 	"op .<=":: "'a::qpo => 'a => tr"	(infixl "\\<preceq>" 55)
       
   155 rules 
       
   156 
       
   157 strict_qpo	"(UU .<= x) = UU & (x .<= UU) = UU"
       
   158 total_qpo	"[|x ~= UU; y ~= UU|] ==> (x .<= y) ~= UU"
       
   159 
       
   160 refl_qpo	"[|x ~= UU|] ==> (x .<= x)=TT"
       
   161 antisym_qpo	"[| (x .<= y)=TT; (y .<= x)=TT |] ==> (x .=  y)=TT"
       
   162 trans_qpo	"[| (x .<= y)=TT; (y .<= z)=TT |] ==> (x .<= z)=TT"
       
   163 
       
   164 antisym_qpo_rev	"(x .= y)=TT ==> (x .<= y)=TT & (y .<= x)=TT" 
       
   165 
       
   166 (* -------------------------------------------------------------------- *)
       
   167 
       
   168 (* -------------------------------------------------------------------- *)
       
   169 (* irreflexive part .< defined via .<=                                  *)
       
   170  
       
   171 ops curried 
       
   172 	".<"	:: "'a::qpo -> 'a -> tr"	(cinfixl 55)
       
   173 syntax (symbols)
       
   174 	"op .<"	:: "'a::qpo => 'a => tr"	(infixl "\\<prec>" 55)
       
   175 
       
   176 defs
       
   177 
       
   178 qless_def	"(op .<) Ú LAM x y.If x .= y then FF else x .<= y fi"
       
   179 
       
   180 (* -------------------------------------------------------------------- *)
       
   181 
       
   182 (* -------------------------------------------------------------------- *)
       
   183 (* class qlinear is a refinement of of class qpo                        *)
       
   184  
       
   185 classes qlinear < qpo  	
       
   186 
       
   187 arities void :: qlinear
       
   188 
       
   189 rules 
       
   190 
       
   191 qlinear	"[|(x::'a::qlinear) ~= UU; y ~= UU|] ==> (x .<= y)=TT Á (y .<= x)=TT "
       
   192 
       
   193 (* -------------------------------------------------------------------- *)
       
   194 
       
   195 end
   142 end