doc-src/TutorialI/Rules/Tacticals.thy
author wenzelm
Wed, 21 Sep 2011 16:04:29 +0200
changeset 45025 33a1af99b3a2
parent 16417 9bc16273c2d4
permissions -rw-r--r--
more hints on Z3 configuration;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 12390
diff changeset
     1
theory Tacticals imports Main begin
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     2
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     3
text{*REPEAT*}
10963
f2c1a280f1e3 added a "pr" example; tidied
paulson
parents: 10956
diff changeset
     4
lemma "\<lbrakk>P\<longrightarrow>Q; Q\<longrightarrow>R; R\<longrightarrow>S; P\<rbrakk> \<Longrightarrow> S"
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     5
apply (drule mp, assumption)
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     6
apply (drule mp, assumption)
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     7
apply (drule mp, assumption)
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     8
apply (assumption)
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
     9
done
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    10
10963
f2c1a280f1e3 added a "pr" example; tidied
paulson
parents: 10956
diff changeset
    11
lemma "\<lbrakk>P\<longrightarrow>Q; Q\<longrightarrow>R; R\<longrightarrow>S; P\<rbrakk> \<Longrightarrow> S"
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    12
by (drule mp, assumption)+
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    13
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    14
text{*ORELSE with REPEAT*}
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11407
diff changeset
    15
lemma "\<lbrakk>Q\<longrightarrow>R; P\<longrightarrow>Q; x<5\<longrightarrow>P;  Suc x < 5\<rbrakk> \<Longrightarrow> R" 
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    16
by (drule mp, (assumption|arith))+
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    17
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    18
text{*exercise: what's going on here?*}
10963
f2c1a280f1e3 added a "pr" example; tidied
paulson
parents: 10956
diff changeset
    19
lemma "\<lbrakk>P\<and>Q\<longrightarrow>R; P\<longrightarrow>Q; P\<rbrakk> \<Longrightarrow> R"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11711
diff changeset
    20
by (drule mp, (intro conjI)?, assumption+)+
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    21
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    22
text{*defer and prefer*}
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    23
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    24
lemma "hard \<and> (P \<or> ~P) \<and> (Q\<longrightarrow>Q)"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11711
diff changeset
    25
apply (intro conjI)   --{* @{subgoals[display,indent=0,margin=65]} *}
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    26
defer 1   --{* @{subgoals[display,indent=0,margin=65]} *}
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    27
apply blast+   --{* @{subgoals[display,indent=0,margin=65]} *}
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    28
oops
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    29
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    30
lemma "ok1 \<and> ok2 \<and> doubtful"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11711
diff changeset
    31
apply (intro conjI)   --{* @{subgoals[display,indent=0,margin=65]} *}
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    32
prefer 3   --{* @{subgoals[display,indent=0,margin=65]} *}
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    33
oops
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    34
10987
c36733b147e8 fixed the pr example
paulson
parents: 10963
diff changeset
    35
lemma "bigsubgoal1 \<and> bigsubgoal2 \<and> bigsubgoal3 \<and> bigsubgoal4 \<and> bigsubgoal5 \<and> bigsubgoal6"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11711
diff changeset
    36
apply (intro conjI)   --{* @{subgoals[display,indent=0,margin=65]} *}
10987
c36733b147e8 fixed the pr example
paulson
parents: 10963
diff changeset
    37
txt{* @{subgoals[display,indent=0,margin=65]} 
c36733b147e8 fixed the pr example
paulson
parents: 10963
diff changeset
    38
A total of 6 subgoals...
c36733b147e8 fixed the pr example
paulson
parents: 10963
diff changeset
    39
*}
10963
f2c1a280f1e3 added a "pr" example; tidied
paulson
parents: 10956
diff changeset
    40
oops
f2c1a280f1e3 added a "pr" example; tidied
paulson
parents: 10956
diff changeset
    41
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    42
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    43
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    44
(*needed??*)
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    45
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    46
lemma "(P\<or>Q) \<and> (R\<or>S) \<Longrightarrow> PP"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11711
diff changeset
    47
apply (elim conjE disjE)
10956
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    48
oops
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    49
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    50
lemma "((P\<or>Q) \<and> R) \<and> (Q \<and> (P\<or>S)) \<Longrightarrow> PP"
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    51
apply (elim conjE)
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    52
oops
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    53
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    54
lemma "((P\<or>Q) \<and> R) \<and> (Q \<and> (P\<or>S)) \<Longrightarrow> PP"
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    55
apply (erule conjE)+
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    56
oops
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    57
1db8b894ada0 new examples theory Rules/Tacticals.thy
paulson
parents:
diff changeset
    58
end