src/HOL/Set.thy
changeset 14804 8de39d3e8eb6
parent 14752 3fc3c7b7e99d
child 14812 4b2c006d0534
equal deleted inserted replaced
14803:f7557773cc87 14804:8de39d3e8eb6
   136 
   136 
   137 translations
   137 translations
   138   "op \<subseteq>" => "op <= :: _ set => _ set => bool"
   138   "op \<subseteq>" => "op <= :: _ set => _ set => bool"
   139   "op \<subset>" => "op <  :: _ set => _ set => bool"
   139   "op \<subset>" => "op <  :: _ set => _ set => bool"
   140 
   140 
   141 
       
   142 typed_print_translation {*
   141 typed_print_translation {*
   143   let
   142   let
   144     fun le_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
   143     fun le_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
   145           list_comb (Syntax.const "_setle", ts)
   144           list_comb (Syntax.const "_setle", ts)
   146       | le_tr' _ _ _ = raise Match;
   145       | le_tr' _ _ _ = raise Match;
   148     fun less_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
   147     fun less_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
   149           list_comb (Syntax.const "_setless", ts)
   148           list_comb (Syntax.const "_setless", ts)
   150       | less_tr' _ _ _ = raise Match;
   149       | less_tr' _ _ _ = raise Match;
   151   in [("op <=", le_tr'), ("op <", less_tr')] end
   150   in [("op <=", le_tr'), ("op <", less_tr')] end
   152 *}
   151 *}
       
   152 
       
   153 
       
   154 subsubsection "Bounded quantifiers"
       
   155 
       
   156 syntax
       
   157   "_setlessAll" :: "[idt, 'a, bool] => bool"  ("(3ALL _<_./ _)"  [0, 0, 10] 10)
       
   158   "_setlessEx"  :: "[idt, 'a, bool] => bool"  ("(3EX _<_./ _)"  [0, 0, 10] 10)
       
   159   "_setleAll"   :: "[idt, 'a, bool] => bool"  ("(3ALL _<=_./ _)" [0, 0, 10] 10)
       
   160   "_setleEx"    :: "[idt, 'a, bool] => bool"  ("(3EX _<=_./ _)" [0, 0, 10] 10)
       
   161 
       
   162 syntax (xsymbols)
       
   163   "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subset>_./ _)"  [0, 0, 10] 10)
       
   164   "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subset>_./ _)"  [0, 0, 10] 10)
       
   165   "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subseteq>_./ _)" [0, 0, 10] 10)
       
   166   "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subseteq>_./ _)" [0, 0, 10] 10)
       
   167 
       
   168 syntax (HOL)
       
   169   "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
       
   170   "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
       
   171   "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
       
   172   "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
       
   173 
       
   174 syntax (HTML output)
       
   175   "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subset>_./ _)"  [0, 0, 10] 10)
       
   176   "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subset>_./ _)"  [0, 0, 10] 10)
       
   177   "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subseteq>_./ _)" [0, 0, 10] 10)
       
   178   "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subseteq>_./ _)" [0, 0, 10] 10)
       
   179 
       
   180 translations
       
   181  "\<forall>A\<subset>B. P"   =>  "ALL A. A \<subset> B --> P"
       
   182  "\<exists>A\<subset>B. P"    =>  "EX A. A \<subset> B & P"
       
   183  "\<forall>A\<subseteq>B. P"  =>  "ALL A. A \<subseteq> B --> P"
       
   184  "\<exists>A\<subseteq>B. P"   =>  "EX A. A \<subseteq> B & P"
       
   185 
       
   186 print_translation {*
       
   187 let
       
   188   fun
       
   189     all_tr' [Const ("_bound",_) $ Free (v,Type(T,_)), 
       
   190              Const("op -->",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
       
   191   (if v=v' andalso T="set"
       
   192    then Syntax.const "_setlessAll" $ Syntax.mark_bound v' $ n $ P
       
   193    else raise Match)
       
   194 
       
   195   | all_tr' [Const ("_bound",_) $ Free (v,Type(T,_)), 
       
   196              Const("op -->",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
       
   197   (if v=v' andalso T="set"
       
   198    then Syntax.const "_setleAll" $ Syntax.mark_bound v' $ n $ P
       
   199    else raise Match);
       
   200 
       
   201   fun
       
   202     ex_tr' [Const ("_bound",_) $ Free (v,Type(T,_)), 
       
   203             Const("op &",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
       
   204   (if v=v' andalso T="set"
       
   205    then Syntax.const "_setlessEx" $ Syntax.mark_bound v' $ n $ P
       
   206    else raise Match)
       
   207 
       
   208   | ex_tr' [Const ("_bound",_) $ Free (v,Type(T,_)), 
       
   209             Const("op &",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
       
   210   (if v=v' andalso T="set"
       
   211    then Syntax.const "_setleEx" $ Syntax.mark_bound v' $ n $ P
       
   212    else raise Match)
       
   213 in
       
   214 [("ALL ", all_tr'), ("EX ", ex_tr')]
       
   215 end
       
   216 *}
       
   217 
       
   218 
   153 
   219 
   154 text {*
   220 text {*
   155   \medskip Translate between @{text "{e | x1...xn. P}"} and @{text
   221   \medskip Translate between @{text "{e | x1...xn. P}"} and @{text
   156   "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is
   222   "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is
   157   only translated if @{text "[0..n] subset bvs(e)"}.
   223   only translated if @{text "[0..n] subset bvs(e)"}.