src/HOL/Orderings.thy
changeset 46553 50a7e97fe653
parent 45931 99cf6e470816
child 46557 ae926869a311
equal deleted inserted replaced
46552:5d33a3269029 46553:50a7e97fe653
  1109   "a \<noteq> \<top> \<longleftrightarrow> a < \<top>"
  1109   "a \<noteq> \<top> \<longleftrightarrow> a < \<top>"
  1110   by (auto simp add: less_le_not_le intro!: antisym)
  1110   by (auto simp add: less_le_not_le intro!: antisym)
  1111 
  1111 
  1112 end
  1112 end
  1113 
  1113 
  1114 no_notation
       
  1115   bot ("\<bottom>") and
       
  1116   top ("\<top>")
       
  1117 
       
  1118 
  1114 
  1119 subsection {* Dense orders *}
  1115 subsection {* Dense orders *}
  1120 
  1116 
  1121 class dense_linorder = linorder + 
  1117 class dense_linorder = linorder + 
  1122   assumes gt_ex: "\<exists>y. x < y" 
  1118   assumes gt_ex: "\<exists>y. x < y" 
  1237 
  1233 
  1238 definition
  1234 definition
  1239   [simp]: "(P\<Colon>bool) < Q \<longleftrightarrow> \<not> P \<and> Q"
  1235   [simp]: "(P\<Colon>bool) < Q \<longleftrightarrow> \<not> P \<and> Q"
  1240 
  1236 
  1241 definition
  1237 definition
  1242   [simp]: "bot \<longleftrightarrow> False"
  1238   [simp]: "\<bottom> \<longleftrightarrow> False"
  1243 
  1239 
  1244 definition
  1240 definition
  1245   [simp]: "top \<longleftrightarrow> True"
  1241   [simp]: "\<top> \<longleftrightarrow> True"
  1246 
  1242 
  1247 instance proof
  1243 instance proof
  1248 qed auto
  1244 qed auto
  1249 
  1245 
  1250 end
  1246 end
  1259   by simp
  1255   by simp
  1260 
  1256 
  1261 lemma le_boolD: "P \<le> Q \<Longrightarrow> P \<longrightarrow> Q"
  1257 lemma le_boolD: "P \<le> Q \<Longrightarrow> P \<longrightarrow> Q"
  1262   by simp
  1258   by simp
  1263 
  1259 
  1264 lemma bot_boolE: "bot \<Longrightarrow> P"
  1260 lemma bot_boolE: "\<bottom> \<Longrightarrow> P"
  1265   by simp
  1261   by simp
  1266 
  1262 
  1267 lemma top_boolI: top
  1263 lemma top_boolI: \<top>
  1268   by simp
  1264   by simp
  1269 
  1265 
  1270 lemma [code]:
  1266 lemma [code]:
  1271   "False \<le> b \<longleftrightarrow> True"
  1267   "False \<le> b \<longleftrightarrow> True"
  1272   "True \<le> b \<longleftrightarrow> b"
  1268   "True \<le> b \<longleftrightarrow> b"
  1299 
  1295 
  1300 instantiation "fun" :: (type, bot) bot
  1296 instantiation "fun" :: (type, bot) bot
  1301 begin
  1297 begin
  1302 
  1298 
  1303 definition
  1299 definition
  1304   "bot = (\<lambda>x. bot)"
  1300   "\<bottom> = (\<lambda>x. \<bottom>)"
  1305 
  1301 
  1306 lemma bot_apply:
  1302 lemma bot_apply:
  1307   "bot x = bot"
  1303   "\<bottom> x = \<bottom>"
  1308   by (simp add: bot_fun_def)
  1304   by (simp add: bot_fun_def)
  1309 
  1305 
  1310 instance proof
  1306 instance proof
  1311 qed (simp add: le_fun_def bot_apply)
  1307 qed (simp add: le_fun_def bot_apply)
  1312 
  1308 
  1314 
  1310 
  1315 instantiation "fun" :: (type, top) top
  1311 instantiation "fun" :: (type, top) top
  1316 begin
  1312 begin
  1317 
  1313 
  1318 definition
  1314 definition
  1319   [no_atp]: "top = (\<lambda>x. top)"
  1315   [no_atp]: "\<top> = (\<lambda>x. \<top>)"
  1320 declare top_fun_def_raw [no_atp]
  1316 declare top_fun_def_raw [no_atp]
  1321 
  1317 
  1322 lemma top_apply:
  1318 lemma top_apply:
  1323   "top x = top"
  1319   "\<top> x = \<top>"
  1324   by (simp add: top_fun_def)
  1320   by (simp add: top_fun_def)
  1325 
  1321 
  1326 instance proof
  1322 instance proof
  1327 qed (simp add: le_fun_def top_apply)
  1323 qed (simp add: le_fun_def top_apply)
  1328 
  1324 
  1334 lemma le_funE: "f \<le> g \<Longrightarrow> (f x \<le> g x \<Longrightarrow> P) \<Longrightarrow> P"
  1330 lemma le_funE: "f \<le> g \<Longrightarrow> (f x \<le> g x \<Longrightarrow> P) \<Longrightarrow> P"
  1335   unfolding le_fun_def by simp
  1331   unfolding le_fun_def by simp
  1336 
  1332 
  1337 lemma le_funD: "f \<le> g \<Longrightarrow> f x \<le> g x"
  1333 lemma le_funD: "f \<le> g \<Longrightarrow> f x \<le> g x"
  1338   unfolding le_fun_def by simp
  1334   unfolding le_fun_def by simp
       
  1335 
       
  1336 
       
  1337 subsection {* Order on unary and binary predicates *}
       
  1338 
       
  1339 lemma predicate1I:
       
  1340   assumes PQ: "\<And>x. P x \<Longrightarrow> Q x"
       
  1341   shows "P \<le> Q"
       
  1342   apply (rule le_funI)
       
  1343   apply (rule le_boolI)
       
  1344   apply (rule PQ)
       
  1345   apply assumption
       
  1346   done
       
  1347 
       
  1348 lemma predicate1D [Pure.dest?, dest?]:
       
  1349   "P \<le> Q \<Longrightarrow> P x \<Longrightarrow> Q x"
       
  1350   apply (erule le_funE)
       
  1351   apply (erule le_boolE)
       
  1352   apply assumption+
       
  1353   done
       
  1354 
       
  1355 lemma rev_predicate1D:
       
  1356   "P x \<Longrightarrow> P \<le> Q \<Longrightarrow> Q x"
       
  1357   by (rule predicate1D)
       
  1358 
       
  1359 lemma predicate2I [Pure.intro!, intro!]:
       
  1360   assumes PQ: "\<And>x y. P x y \<Longrightarrow> Q x y"
       
  1361   shows "P \<le> Q"
       
  1362   apply (rule le_funI)+
       
  1363   apply (rule le_boolI)
       
  1364   apply (rule PQ)
       
  1365   apply assumption
       
  1366   done
       
  1367 
       
  1368 lemma predicate2D [Pure.dest, dest]:
       
  1369   "P \<le> Q \<Longrightarrow> P x y \<Longrightarrow> Q x y"
       
  1370   apply (erule le_funE)+
       
  1371   apply (erule le_boolE)
       
  1372   apply assumption+
       
  1373   done
       
  1374 
       
  1375 lemma rev_predicate2D:
       
  1376   "P x y \<Longrightarrow> P \<le> Q \<Longrightarrow> Q x y"
       
  1377   by (rule predicate2D)
       
  1378 
       
  1379 lemma bot1E [no_atp, elim!]: "\<bottom> x \<Longrightarrow> P"
       
  1380   by (simp add: bot_fun_def)
       
  1381 
       
  1382 lemma bot2E [elim!]: "\<bottom> x y \<Longrightarrow> P"
       
  1383   by (simp add: bot_fun_def)
       
  1384 
       
  1385 lemma top1I [intro!]: "\<top> x"
       
  1386   by (simp add: top_fun_def)
       
  1387 
       
  1388 lemma top2I [intro!]: "\<top> x y"
       
  1389   by (simp add: top_fun_def)
  1339 
  1390 
  1340 
  1391 
  1341 subsection {* Name duplicates *}
  1392 subsection {* Name duplicates *}
  1342 
  1393 
  1343 lemmas order_eq_refl = preorder_class.eq_refl
  1394 lemmas order_eq_refl = preorder_class.eq_refl
  1373 lemmas linorder_neqE = linorder_class.neqE
  1424 lemmas linorder_neqE = linorder_class.neqE
  1374 lemmas linorder_antisym_conv1 = linorder_class.antisym_conv1
  1425 lemmas linorder_antisym_conv1 = linorder_class.antisym_conv1
  1375 lemmas linorder_antisym_conv2 = linorder_class.antisym_conv2
  1426 lemmas linorder_antisym_conv2 = linorder_class.antisym_conv2
  1376 lemmas linorder_antisym_conv3 = linorder_class.antisym_conv3
  1427 lemmas linorder_antisym_conv3 = linorder_class.antisym_conv3
  1377 
  1428 
  1378 end
  1429 no_notation
       
  1430   top ("\<top>") and
       
  1431   bot ("\<bottom>")
       
  1432 
       
  1433 end