diff -r 95b42288294e -r 438703674711 ProgTutorial/Tactical.thy --- a/ProgTutorial/Tactical.thy Fri May 17 11:21:09 2019 +0200 +++ b/ProgTutorial/Tactical.thy Tue May 21 14:37:39 2019 +0200 @@ -47,7 +47,7 @@ text \ This proof translates to the following ML-code. -@{ML_matchresult_fake [display,gray] +@{ML_response [display,gray] \let val ctxt = @{context} val goal = @{prop "P \ Q \ Q \ P"} @@ -763,17 +763,19 @@ constraints is by pre-instantiating theorems with other theorems. The function @{ML_ind RS in Drule}, for example, does this. - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \@{thm disjI1} RS @{thm conjI}\ \\?P1; ?Q\ \ (?P1 \ ?Q1) \ ?Q\} In this example it instantiates the first premise of the \conjI\-theorem with the theorem \disjI1\. If the instantiation is impossible, as in the case of - @{ML_matchresult_fake_both [display,gray] + @{ML_response [display,gray] \@{thm conjI} RS @{thm mp}\ -\*** Exception- THM ("RSN: no unifiers", 1, -["\?P; ?Q\ \ ?P \ ?Q", "\?P \ ?Q; ?P\ \ ?Q"]) raised\} +\exception THM 1 raised\ + RSN: no unifiers + \?P; ?Q\ \ ?P \ ?Q + \?P \ ?Q; ?P\ \ ?Q\} then the function raises an exception. The function @{ML_ind RSN in Drule} is similar to @{ML RS}, but takes an additional number as argument. This @@ -782,7 +784,7 @@ If you want to instantiate more than one premise of a theorem, you can use the function @{ML_ind MRS in Drule}: - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \[@{thm disjI1}, @{thm disjI2}] MRS @{thm conjI}\ \\?P2; ?Q1\ \ (?P2 \ ?Q2) \ (?P1 \ ?Q1)\} @@ -791,17 +793,17 @@ example in the code below, every theorem in the second list is instantiated with every theorem in the first. - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val list1 = [@{thm impI}, @{thm disjI2}] val list2 = [@{thm conjI}, @{thm disjI1}] in list1 RL list2 end\ -\[\?P1 \ ?Q1; ?Q\ \ (?P1 \ ?Q1) \ ?Q, - \?Q1; ?Q\ \ (?P1 \ ?Q1) \ ?Q, - (?P1 \ ?Q1) \ (?P1 \ ?Q1) \ ?Q, - ?Q1 \ (?P1 \ ?Q1) \ ?Q]\} +\["\?P1 \ ?Q1; ?Q\ \ (?P1 \ ?Q1) \ ?Q", + "\?Q1; ?Q\ \ (?P1 \ ?Q1) \ ?Q", + "(?P1 \ ?Q1) \ (?P1 \ ?Q1) \ ?Q", + "?Q1 \ (?P1 \ ?Q1) \ ?Q"]\} \begin{readmore} The combinators for instantiating theorems with other theorems are @@ -1458,7 +1460,7 @@ prints out some parts of a simpset. If you use it to print out the components of the empty simpset, i.e., @{ML_ind empty_ss in Raw_Simplifier} - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \print_ss @{context} empty_ss\ \Simplification rules: Congruences rules: @@ -1474,10 +1476,10 @@ text \ Printing then out the components of the simpset gives: - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \print_ss @{context} (Raw_Simplifier.simpset_of ss1)\ \Simplification rules: - ??.unknown: A - B \ C \ A - B \ (A - C) + ??.unknown: A1 - B1 \ C1 \ A1 - B1 \ (A1 - C1) Congruences rules: Simproc patterns:\} @@ -1491,12 +1493,12 @@ text \ gives - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \print_ss @{context} (Raw_Simplifier.simpset_of ss2)\ \Simplification rules: - ??.unknown: A - B \ C \ A - B \ (A - C) + ??.unknown: A1 - B1 \ C1 \ A1 - B1 \ (A1 - C1) Congruences rules: - Complete_Lattices.Inf_class.INFIMUM: + Complete_Lattices.Inf_class.Inf: \A1 = B1; \x. x \ B1 =simp=> C1 x = D1 x\ \ INFIMUM A1 C1 \ INFIMUM B1 D1 Simproc patterns:\} @@ -1508,7 +1510,7 @@ In the context of HOL, the first really useful simpset is @{ML_ind HOL_basic_ss in Simpdata}. While printing out the components of this simpset - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \print_ss @{context} HOL_basic_ss\ \Simplification rules: Congruences rules: @@ -1534,6 +1536,7 @@ apply(tactic \ALLGOALS (simp_tac (put_simpset HOL_basic_ss @{context}))\) done +declare [[ML_print_depth = 200]] text \ This behaviour is not because of simplification rules, but how the subgoaler, solver and looper are set up in @{ML HOL_basic_ss}. @@ -1542,17 +1545,17 @@ already many useful simplification and congruence rules for the logical connectives in HOL. - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \print_ss @{context} HOL_ss\ \Simplification rules: Pure.triv_forall_equality: (\x. PROP V) \ PROP V HOL.the_eq_trivial: THE x. x = y \ y - HOL.the_sym_eq_trivial: THE ya. y = ya \ y + HOL.the_sym_eq_trivial: THE y. y = y \ y \ Congruences rules: HOL.simp_implies: \ \ (PROP P =simp=> PROP Q) \ (PROP P' =simp=> PROP Q') - op -->: \P \ P'; P' \ Q \ Q'\ \ P \ Q \ P' \ Q' + HOL.implies: \P \ P'; P' \ Q \ Q'\ \ P \ Q \ P' \ Q' Simproc patterns: \\} @@ -2064,16 +2067,16 @@ is the function @{ML_ind all_conv in Conv}, which maps a @{ML_type cterm} to an instance of the (meta)reflexivity theorem. For example: - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \Conv.all_conv @{cterm "Foo \ Bar"}\ \Foo \ Bar \ Foo \ Bar\} Another simple conversion is @{ML_ind no_conv in Conv} which always raises the exception @{ML CTERM}. - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \Conv.no_conv @{cterm True}\ - \*** Exception- CTERM ("no conversion", []) raised\} + \exception CTERM \: no conversion\} A more interesting conversion is the function @{ML_ind beta_conversion in Thm}: it produces a meta-equation between a term and its beta-normal form. For example @@ -2111,7 +2114,7 @@ or in the pretty-printed form - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val add = @{cterm "\x y. x + (y::nat)"} val two = @{cterm "2::nat"} @@ -2146,7 +2149,7 @@ It can be used for example to rewrite @{term "True \ (Foo \ Bar)"} to @{term "Foo \ Bar"}. The code is as follows. - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val ctrm = @{cterm "True \ (Foo \ Bar)"} in @@ -2182,7 +2185,7 @@ The conversion combinator @{ML_ind else_conv in Conv} tries out the first one, and if it does not apply, tries the second. For example - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val conv = Conv.rewr_conv @{thm true_conj1} else_conv Conv.all_conv val ctrm1 = @{cterm "True \ Q"} @@ -2190,7 +2193,7 @@ in (conv ctrm1, conv ctrm2) end\ -\(True \ Q \ Q, P \ True \ Q \ P \ True \ Q)\} +\("True \ Q \ Q", "P \ True \ Q \ P \ True \ Q")\} Here the conversion @{thm [source] true_conj1} only applies in the first case, but fails in the second. The whole conversion @@ -2199,7 +2202,7 @@ behaviour can also be achieved with conversion combinator @{ML_ind try_conv in Conv}. For example - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val conv = Conv.try_conv (Conv.rewr_conv @{thm true_conj1}) val ctrm = @{cterm "True \ P"} @@ -2220,14 +2223,14 @@ a conversion to the first, respectively second, argument of an application. For example - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val conv = Conv.arg_conv (Conv.rewr_conv @{thm true_conj1}) val ctrm = @{cterm "P \ (True \ Q)"} in conv ctrm end\ -\P \ (True \ Q) \ P \ Q\} +\P \ True \ Q \ P \ Q\} The reason for this behaviour is that \(op \)\ expects two arguments. Therefore the term must be of the form \(Const \ $ t1) $ t2\. The @@ -2238,14 +2241,14 @@ The function @{ML_ind abs_conv in Conv} applies a conversion under an abstraction. For example: - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val conv = Conv.rewr_conv @{thm true_conj1} val ctrm = @{cterm "\P. True \ (P \ Foo)"} in Conv.abs_conv (K conv) @{context} ctrm end\ - \\P. True \ (P \ Foo) \ \P. P \ Foo\} + \"\P. True \ P \ Foo \ \P. P \ Foo"\} Note that this conversion needs a context as an argument. We also give the conversion as \(K conv)\, which is a function that ignores its @@ -2279,7 +2282,7 @@ to be able to pattern-match the term. To see this conversion in action, consider the following example: -@{ML_matchresult_fake [display,gray] +@{ML_response [display,gray] \let val conv = true_conj1_conv @{context} val ctrm = @{cterm "distinct [1::nat, x] \ True \ 1 \ x"} @@ -2358,7 +2361,7 @@ soon as it found one redex. Here is an example for this conversion: - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val ctrm = @{cterm "if P (True \ 1 \ (2::nat)) then True \ True else True \ False"} @@ -2382,7 +2385,7 @@ Using the conversion you can transform this theorem into a new theorem as follows - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \let val conv = Conv.fconv_rule (true_conj1_conv @{context}) val thm = @{thm foo_test} @@ -2465,7 +2468,7 @@ into @{thm [source] id2_def} by abstracting all variables on the left-hand side in the right-hand side. - @{ML_matchresult_fake [display,gray] + @{ML_response [display,gray] \Drule.abs_def @{thm id1_def}\ \id1 \ \x. x\} @@ -2513,7 +2516,7 @@ export the context \ctxt'\ back to \ctxt\ in order to produce meta-variables for the theorem. An example is as follows. - @{ML_matchresult_fake [display, gray] + @{ML_response [display, gray] \unabs_def @{context} @{thm id2_def}\ \id2 ?x1 \ ?x1\} \