src/FOL/ex/Quantifiers_Int.thy
author wenzelm
Sun, 12 Mar 2017 18:50:02 +0100
changeset 65202 187277b77d50
parent 62020 5d208fd2507d
child 69590 e65314985426
permissions -rw-r--r--
suppress vacuous messages;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     1
(*  Title:      FOL/ex/Quantifiers_Int.thy
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     3
    Copyright   1991  University of Cambridge
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     4
*)
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     5
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
     6
section \<open>First-Order Logic: quantifier examples (intuitionistic version)\<close>
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     7
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     8
theory Quantifiers_Int
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
     9
imports IFOL
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    10
begin
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    11
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    12
lemma "(\<forall>x y. P(x,y)) \<longrightarrow> (\<forall>y x. P(x,y))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    13
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    14
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    15
lemma "(\<exists>x y. P(x,y)) \<longrightarrow> (\<exists>y x. P(x,y))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    16
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    17
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    18
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    19
\<comment> \<open>Converse is false\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    20
lemma "(\<forall>x. P(x)) \<or> (\<forall>x. Q(x)) \<longrightarrow> (\<forall>x. P(x) \<or> Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    21
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    22
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    23
lemma "(\<forall>x. P \<longrightarrow> Q(x)) \<longleftrightarrow> (P \<longrightarrow> (\<forall>x. Q(x)))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    24
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    25
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    26
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    27
lemma "(\<forall>x. P(x) \<longrightarrow> Q) \<longleftrightarrow> ((\<exists>x. P(x)) \<longrightarrow> Q)"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    28
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    29
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    30
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    31
text \<open>Some harder ones\<close>
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    32
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    33
lemma "(\<exists>x. P(x) \<or> Q(x)) \<longleftrightarrow> (\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    34
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    35
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    36
\<comment> \<open>Converse is false\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    37
lemma "(\<exists>x. P(x) \<and> Q(x)) \<longrightarrow> (\<exists>x. P(x)) \<and> (\<exists>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    38
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    39
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    40
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    41
text \<open>Basic test of quantifier reasoning\<close>
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    42
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    43
\<comment> \<open>TRUE\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    44
lemma "(\<exists>y. \<forall>x. Q(x,y)) \<longrightarrow> (\<forall>x. \<exists>y. Q(x,y))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    45
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    46
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    47
lemma "(\<forall>x. Q(x)) \<longrightarrow> (\<exists>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    48
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    49
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    50
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    51
text \<open>The following should fail, as they are false!\<close>
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    52
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    53
lemma "(\<forall>x. \<exists>y. Q(x,y)) \<longrightarrow> (\<exists>y. \<forall>x. Q(x,y))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    54
  apply (tactic "IntPr.fast_tac @{context} 1")?
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    55
  oops
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    56
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    57
lemma "(\<exists>x. Q(x)) \<longrightarrow> (\<forall>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    58
  apply (tactic "IntPr.fast_tac @{context} 1")?
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    59
  oops
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    60
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    61
schematic_goal "P(?a) \<longrightarrow> (\<forall>x. P(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    62
  apply (tactic "IntPr.fast_tac @{context} 1")?
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    63
  oops
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    64
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    65
schematic_goal "(P(?a) \<longrightarrow> (\<forall>x. Q(x))) \<longrightarrow> (\<forall>x. P(x) \<longrightarrow> Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    66
  apply (tactic "IntPr.fast_tac @{context} 1")?
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    67
  oops
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    68
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    69
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    70
text \<open>Back to things that are provable \dots\<close>
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    71
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    72
lemma "(\<forall>x. P(x) \<longrightarrow> Q(x)) \<and> (\<exists>x. P(x)) \<longrightarrow> (\<exists>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    73
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    74
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    75
\<comment> \<open>An example of why exI should be delayed as long as possible\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    76
lemma "(P \<longrightarrow> (\<exists>x. Q(x))) \<and> P \<longrightarrow> (\<exists>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    77
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    78
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    79
schematic_goal "(\<forall>x. P(x) \<longrightarrow> Q(f(x))) \<and> (\<forall>x. Q(x) \<longrightarrow> R(g(x))) \<and> P(d) \<longrightarrow> R(?a)"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    80
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    81
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    82
lemma "(\<forall>x. Q(x)) \<longrightarrow> (\<exists>x. Q(x))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    83
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    84
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    85
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    86
text \<open>Some slow ones\<close>
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    87
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    88
\<comment> \<open>Principia Mathematica *11.53\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    89
lemma "(\<forall>x y. P(x) \<longrightarrow> Q(y)) \<longleftrightarrow> ((\<exists>x. P(x)) \<longrightarrow> (\<forall>y. Q(y)))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    90
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    91
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    92
(*Principia Mathematica *11.55  *)
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    93
lemma "(\<exists>x y. P(x) \<and> Q(x,y)) \<longleftrightarrow> (\<exists>x. P(x) \<and> (\<exists>y. Q(x,y)))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    94
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    95
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    96
(*Principia Mathematica *11.61  *)
61489
b8d375aee0df more symbols;
wenzelm
parents: 61337
diff changeset
    97
lemma "(\<exists>y. \<forall>x. P(x) \<longrightarrow> Q(x,y)) \<longrightarrow> (\<forall>x. P(x) \<longrightarrow> (\<exists>y. Q(x,y)))"
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 36319
diff changeset
    98
  by (tactic "IntPr.fast_tac @{context} 1")
23914
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
    99
3e0424305fa4 turned ex/prop.ML, ex/quant.ML into proper theories;
wenzelm
parents:
diff changeset
   100
end