# HG changeset patch # User wenzelm # Date 1461704365 -7200 # Node ID 60406bf310f8e9598bb08638d941a97036f5ecf3 # Parent 4a108f280dc25e292927fd32086b4d8b913f824d# Parent 21ebc2f5c571d9a2086ccdbb27af4cfb067cd778 merged diff -r 4a108f280dc2 -r 60406bf310f8 Admin/Release/CHECKLIST --- a/Admin/Release/CHECKLIST Fri Apr 22 17:22:29 2016 +0200 +++ b/Admin/Release/CHECKLIST Tue Apr 26 22:59:25 2016 +0200 @@ -69,10 +69,13 @@ Packaging ========= -- fully-automated packaging (requires Mac OS X with gnutar, avoid Mavericks): +- fully-automated packaging: hg up -r DISTNAME && Admin/Release/build -O -l -r DISTNAME /home/isabelle/dist + Mac OS X: requires gnutar, avoid Mavericks (problems with hdiutil?) + Linux: avoid Debian (bitmap fonts for prog-prove) + Final release stage =================== diff -r 4a108f280dc2 -r 60406bf310f8 Admin/lib/Tools/makedist --- a/Admin/lib/Tools/makedist Fri Apr 22 17:22:29 2016 +0200 +++ b/Admin/lib/Tools/makedist Tue Apr 26 22:59:25 2016 +0200 @@ -180,7 +180,7 @@ echo "### Preparing distribution $DISTNAME" -find . "(" -name \*.thy -o -name \*.ML -o -name \*.scala ")" -perm +111 -print | xargs chmod -f -x +find . "(" -name \*.thy -o -name \*.ML -o -name \*.scala ")" -print | xargs chmod -f -x find . -print | xargs chmod -f u+rw export CLASSPATH="$ISABELLE_CLASSPATH" diff -r 4a108f280dc2 -r 60406bf310f8 Admin/lib/Tools/makedist_bundle --- a/Admin/lib/Tools/makedist_bundle Fri Apr 22 17:22:29 2016 +0200 +++ b/Admin/lib/Tools/makedist_bundle Tue Apr 26 22:59:25 2016 +0200 @@ -320,8 +320,13 @@ "contrib/cygwin/isabelle/." done - find . -type f -not -name '*.exe' -not -name '*.dll' -perm +100 \ - -print0 > "contrib/cygwin/isabelle/executables" + if [ "$ISABELLE_PLATFORM_FAMILY" = macos ]; then + find . -type f -not -name '*.exe' -not -name '*.dll' -perm +100 \ + -print0 > "contrib/cygwin/isabelle/executables" + else + find . -type f -not -name '*.exe' -not -name '*.dll' -executable \ + -print0 > "contrib/cygwin/isabelle/executables" + fi find . -type l -exec echo "{}" ";" -exec readlink "{}" ";" \ > "contrib/cygwin/isabelle/symlinks" diff -r 4a108f280dc2 -r 60406bf310f8 NEWS --- a/NEWS Fri Apr 22 17:22:29 2016 +0200 +++ b/NEWS Tue Apr 26 22:59:25 2016 +0200 @@ -64,6 +64,9 @@ 'definition' and 'obtain'. It fits better into the Isar language than old 'def', which is now a legacy feature. +* Command 'obtain' supports structured statements with 'if' / 'for' +context. + * Command '\' is an alias for 'sorry', with different typesetting. E.g. to produce proof holes in examples and documentation. diff -r 4a108f280dc2 -r 60406bf310f8 src/Doc/Isar_Ref/Proof.thy --- a/src/Doc/Isar_Ref/Proof.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/Doc/Isar_Ref/Proof.thy Tue Apr 26 22:59:25 2016 +0200 @@ -1322,8 +1322,12 @@ @{rail \ @@{command consider} @{syntax obtain_clauses} ; - @@{command obtain} @{syntax par_name}? (@{syntax "fixes"} + @'and') - @'where' (@{syntax props} + @'and') + @@{command obtain} @{syntax par_name}? (@{syntax "fixes"} + @'and') \ + @'where' concl prems @{syntax for_fixes} + ; + concl: (@{syntax props} + @'and') + ; + prems: (@'if' (@{syntax props'} + @'and'))? ; @@{command guess} (@{syntax "fixes"} + @'and') \} diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/ContNotDenum.thy --- a/src/HOL/Library/ContNotDenum.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/ContNotDenum.thy Tue Apr 26 22:59:25 2016 +0200 @@ -41,9 +41,10 @@ by (auto simp add: not_le cong: conj_cong) (metis dense le_less_linear less_linear less_trans order_refl) then obtain i j where ij: - "\a b c::real. a < b \ i a b c < j a b c" - "\a b c. a < b \ {i a b c .. j a b c} \ {a .. b}" - "\a b c. a < b \ c \ {i a b c .. j a b c}" + "a < b \ i a b c < j a b c" + "a < b \ {i a b c .. j a b c} \ {a .. b}" + "a < b \ c \ {i a b c .. j a b c}" + for a b c :: real by metis define ivl where "ivl = @@ -78,7 +79,7 @@ finally show "I 0 \ (\i\S. I i) \ {}" by auto qed (auto simp: I_def) - then obtain x where "\n. x \ I n" + then obtain x where "x \ I n" for n by blast moreover from \surj f\ obtain j where "x = f j" by blast diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Extended_Nonnegative_Real.thy --- a/src/HOL/Library/Extended_Nonnegative_Real.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Extended_Nonnegative_Real.thy Tue Apr 26 22:59:25 2016 +0200 @@ -1483,7 +1483,7 @@ case (real r) then have "\x. \q\0. g x \ c \ (g x = ennreal q \ q \ r)" by (auto simp: le_ennreal_iff) - then obtain f where *: "\x. g x \ c \ 0 \ f x" "\x. g x \ c \ g x = ennreal (f x)" "\x. g x \ c \ f x \ r" + then obtain f where *: "0 \ f x" "g x = ennreal (f x)" "f x \ r" if "g x \ c" for x by metis from ae have ae2: "\\<^sub>F x in F. c - g x = ennreal (r - f x) \ f x \ r \ g x = ennreal (f x) \ 0 \ f x" proof eventually_elim diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Extended_Real.thy Tue Apr 26 22:59:25 2016 +0200 @@ -1696,7 +1696,7 @@ shows "\x. (\y\S. y \ x) \ (\z. (\y\S. y \ z) \ x \ z)" proof (cases "\x. \a\S. a \ ereal x") case True - then obtain y where y: "\a. a\S \ a \ ereal y" + then obtain y where y: "a \ ereal y" if "a\S" for a by auto then have "\ \ S" by force @@ -1705,7 +1705,7 @@ case True with \\ \ S\ obtain x where x: "x \ S" "\x\ \ \" by auto - obtain s where s: "\x\ereal -` S. x \ s" "\z. (\x\ereal -` S. x \ z) \ s \ z" + obtain s where s: "\x\ereal -` S. x \ s" "(\x\ereal -` S. x \ z) \ s \ z" for z proof (atomize_elim, rule complete_real) show "\x. x \ ereal -` S" using x by auto @@ -1919,7 +1919,7 @@ assumes *: "bdd_below A" "A \ {}" shows "ereal (Inf A) = (INF a:A. ereal a)" proof (rule ereal_Inf) - from * obtain l u where "\x. x \ A \ l \ x" "u \ A" + from * obtain l u where "x \ A \ l \ x" "u \ A" for x by (auto simp: bdd_below_def) then have "l \ (INF x:A. ereal x)" "(INF x:A. ereal x) \ u" by (auto intro!: INF_greatest INF_lower) @@ -2193,7 +2193,7 @@ by (auto intro!: exI[of _ "\_. -\"] simp: bot_ereal_def) next assume "Sup A \ -\" - then obtain l where "incseq l" and l: "\i::nat. l i < Sup A" and l_Sup: "l \ Sup A" + then obtain l where "incseq l" and l: "l i < Sup A" and l_Sup: "l \ Sup A" for i :: nat by (auto dest: countable_approach) have "\f. \n. (f n \ A \ l n \ f n) \ (f n \ f (Suc n))" @@ -2456,7 +2456,7 @@ from \open S\ have "open (ereal -` S)" by (rule ereal_openE) - then obtain e where "e > 0" and e: "\y. dist y (real_of_ereal x) < e \ ereal y \ S" + then obtain e where "e > 0" and e: "dist y (real_of_ereal x) < e \ ereal y \ S" for y using assms unfolding open_dist by force show thesis proof (intro that subsetI) @@ -2830,11 +2830,12 @@ assume "open S" and "x \ S" then have "open (ereal -` S)" unfolding open_ereal_def by auto - with \x \ S\ obtain r where "0 < r" and dist: "\y. dist y rx < r \ ereal y \ S" + with \x \ S\ obtain r where "0 < r" and dist: "dist y rx < r \ ereal y \ S" for y unfolding open_dist rx by auto - then obtain n where - upper: "\N. n \ N \ u N < x + ereal r" and - lower: "\N. n \ N \ x < u N + ereal r" + then obtain n + where upper: "u N < x + ereal r" + and lower: "x < u N + ereal r" + if "n \ N" for N using assms(2)[of "ereal r"] by auto show "\N. \n\N. u n \ S" proof (safe intro!: exI[of _ n]) diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Fun_Lexorder.thy --- a/src/HOL/Library/Fun_Lexorder.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Fun_Lexorder.thy Tue Apr 26 22:59:25 2016 +0200 @@ -24,9 +24,9 @@ assumes "less_fun f g" shows "\ less_fun g f" proof - from assms obtain k1 where k1: "f k1 < g k1" "\k'. k' < k1 \ f k' = g k'" + from assms obtain k1 where k1: "f k1 < g k1" "k' < k1 \ f k' = g k'" for k' by (blast elim!: less_funE) - assume "less_fun g f" then obtain k2 where k2: "g k2 < f k2" "\k'. k' < k2 \ g k' = f k'" + assume "less_fun g f" then obtain k2 where k2: "g k2 < f k2" "k' < k2 \ g k' = f k'" for k' by (blast elim!: less_funE) show False proof (cases k1 k2 rule: linorder_cases) case equal with k1 k2 show False by simp @@ -52,9 +52,9 @@ assumes "less_fun f g" and "less_fun g h" shows "less_fun f h" proof (rule less_funI) - from \less_fun f g\ obtain k1 where k1: "f k1 < g k1" "\k'. k' < k1 \ f k' = g k'" - by (blast elim!: less_funE) - from \less_fun g h\ obtain k2 where k2: "g k2 < h k2" "\k'. k' < k2 \ g k' = h k'" + from \less_fun f g\ obtain k1 where k1: "f k1 < g k1" "k' < k1 \ f k' = g k'" for k' + by (blast elim!: less_funE) + from \less_fun g h\ obtain k2 where k2: "g k2 < h k2" "k' < k2 \ g k' = h k'" for k' by (blast elim!: less_funE) show "\k. f k < h k \ (\k' (\ i\I. \n. A n i)" then have "\i\I. \n. f i \ A n i" by auto - from bchoice[OF this] obtain n where n: "\i. i \ I \ f i \ (A (n i) i)" + from bchoice[OF this] obtain n where n: "f i \ A (n i) i" if "i \ I" for i by auto - obtain k where k: "\i. i \ I \ n i \ k" + obtain k where k: "n i \ k" if "i \ I" for i using \finite I\ finite_nat_set_iff_bounded_le[of "n`I"] by auto have "f \ Pi I (A k)" proof (intro Pi_I) diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Function_Growth.thy --- a/src/HOL/Library/Function_Growth.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Function_Growth.thy Tue Apr 26 22:59:25 2016 +0200 @@ -163,7 +163,7 @@ and "\c n. c > 0 \ \m>n. c * f m < g m" proof - from assms have "f \ g" and "\ g \ f" by (simp_all add: less_fun_def) - from \f \ g\ obtain n c where *:"c > 0" "\m. m > n \ f m \ c * g m" + from \f \ g\ obtain n c where *:"c > 0" "m > n \ f m \ c * g m" for m by (rule less_eq_funE) blast { fix c n :: nat assume "c > 0" @@ -202,8 +202,8 @@ shows "f \ g" proof (rule less_funI) have "1 > (0::nat)" by simp - from assms \1 > 0\ have "\n. \m>n. 1 * f m < g m" . - then obtain n where *: "\m. m > n \ 1 * f m < g m" by blast + with assms [OF this] obtain n where *: "m > n \ 1 * f m < g m" for m + by blast have "\m>n. f m \ 1 * g m" proof (rule allI, rule impI) fix m @@ -214,7 +214,7 @@ with \1 > 0\ show "\c>0. \n. \m>n. f m \ c * g m" by blast fix c n :: nat assume "c > 0" - with assms obtain q where "\m. m > q \ c * f m < g m" by blast + with assms obtain q where "m > q \ c * f m < g m" for m by blast then have "c * f (Suc (q + n)) < g (Suc (q + n))" by simp moreover have "Suc (q + n) > n" by simp ultimately show "\m>n. c * f m < g m" by blast diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Fundamental_Theorem_Algebra.thy --- a/src/HOL/Library/Fundamental_Theorem_Algebra.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Fundamental_Theorem_Algebra.thy Tue Apr 26 22:59:25 2016 +0200 @@ -312,7 +312,7 @@ assumes ep: "e > 0" shows "\d >0. \w. 0 < norm (w - z) \ norm (w - z) < d \ norm (poly p w - poly p z) < e" proof - - obtain q where q: "degree q = degree p" "\x. poly q x = poly p (z + x)" + obtain q where q: "degree q = degree p" "poly q x = poly p (z + x)" for x proof show "degree (offset_poly p z) = degree p" by (rule degree_offset_poly) @@ -329,7 +329,7 @@ next case (pCons c cs) from poly_bound_exists[of 1 "cs"] - obtain m where m: "m > 0" "\z. norm z \ 1 \ norm (poly cs z) \ m" + obtain m where m: "m > 0" "norm z \ 1 \ norm (poly cs z) \ m" for z by blast from ep m(1) have em0: "e/m > 0" by (simp add: field_simps) @@ -535,12 +535,14 @@ proof (cases "cs = 0") case False from poly_infinity[OF False, of "cmod (poly (pCons c cs) 0)" c] - obtain r where r: "\z. r \ cmod z \ cmod (poly (pCons c cs) 0) \ cmod (poly (pCons c cs) z)" + obtain r where r: "cmod (poly (pCons c cs) 0) \ cmod (poly (pCons c cs) z)" + if "r \ cmod z" for z by blast have ath: "\z r. r \ cmod z \ cmod z \ \r\" by arith from poly_minimum_modulus_disc[of "\r\" "pCons c cs"] - obtain v where v: "\w. cmod w \ \r\ \ cmod (poly (pCons c cs) v) \ cmod (poly (pCons c cs) w)" + obtain v where v: "cmod (poly (pCons c cs) v) \ cmod (poly (pCons c cs) w)" + if "cmod w \ \r\" for w by blast have "cmod (poly (pCons c cs) v) \ cmod (poly (pCons c cs) z)" if z: "r \ cmod z" for z using v[of 0] r[OF z] by simp diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Multiset.thy Tue Apr 26 22:59:25 2016 +0200 @@ -2075,7 +2075,7 @@ "a \# K" "\b. b \# K \ b < a" proof - from assms obtain a M0 K where "M = M0 + {#a#}" "N = M0 + K" - "\b. b \# K \ b < a" by (blast elim: mult1E) + "b \# K \ b < a" for b by (blast elim: mult1E) moreover from this(3) [of a] have "a \# K" by auto ultimately show thesis by (auto intro: that) qed diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Polynomial.thy --- a/src/HOL/Library/Polynomial.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Polynomial.thy Tue Apr 26 22:59:25 2016 +0200 @@ -3353,7 +3353,7 @@ fix p assume rat: "\i. coeff p i \ \" and root: "poly p x = 0" and nz: "p \ 0" define cs where "cs = coeffs p" from rat have "\c\range (coeff p). \c'. c = of_rat c'" unfolding Rats_def by blast - then obtain f where f: "\i. coeff p i = of_rat (f (coeff p i))" + then obtain f where f: "coeff p i = of_rat (f (coeff p i))" for i by (subst (asm) bchoice_iff) blast define cs' where "cs' = map (quotient_of \ f) (coeffs p)" define d where "d = Lcm (set (map snd cs'))" @@ -3392,9 +3392,8 @@ moreover from root have "poly p' x = 0" by (simp add: p'_def) ultimately show "algebraic x" unfolding algebraic_def by blast next - assume "algebraic x" - then obtain p where p: "\i. coeff p i \ \" "poly p x = 0" "p \ 0" + then obtain p where p: "coeff p i \ \" "poly p x = 0" "p \ 0" for i by (force simp: algebraic_def) moreover have "coeff p i \ \ \ coeff p i \ \" for i by (elim Ints_cases) simp ultimately show "(\p. (\i. coeff p i \ \) \ p \ 0 \ poly p x = 0)" by auto diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Library/Ramsey.thy --- a/src/HOL/Library/Ramsey.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Library/Ramsey.thy Tue Apr 26 22:59:25 2016 +0200 @@ -231,8 +231,8 @@ qed qed from dependent_choice [OF transr propr0 proprstep] - obtain g where pg: "!!n::nat. ?propr (g n)" - and rg: "!!n m. n (g n, g m) \ ?ramr" by blast + obtain g where pg: "?propr (g n)" and rg: "n (g n, g m) \ ?ramr" for n m :: nat + by blast let ?gy = "fst o g" let ?gt = "snd o snd o g" have rangeg: "\k. range ?gt \ {.. 0" and "b \ 0" and "c \ 0" by simp_all - then obtain A B C where fact: - "factorization a = Some A" "factorization b = Some B" "factorization c = Some C" + then obtain A B C + where fact: "factorization a = Some A" "factorization b = Some B" "factorization c = Some C" and norm: "normalize a = msetprod A" "normalize b = msetprod B" "normalize c = msetprod C" - and A: "0 \# A" "\p. p \# A \ normalize p = p" "\p. p \# A \ is_prime p" - and B: "0 \# B" "\p. p \# B \ normalize p = p" "\p. p \# B \ is_prime p" - and C: "0 \# C" "\p. p \# C \ normalize p = p" "\p. p \# C \ is_prime p" + and A: "0 \# A" "p \# A \ normalize p = p" "p \# A \ is_prime p" + and B: "0 \# B" "p \# B \ normalize p = p" "p \# B \ is_prime p" + and C: "0 \# C" "p \# C \ normalize p = p" "p \# C \ is_prime p" + for p by (blast elim!: factorizationE) moreover from that have "normalize c dvd normalize a" and "normalize c dvd normalize b" by simp_all diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/Proofs/Lambda/WeakNorm.thy --- a/src/HOL/Proofs/Lambda/WeakNorm.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/Proofs/Lambda/WeakNorm.thy Tue Apr 26 22:59:25 2016 +0200 @@ -40,9 +40,9 @@ by (rule types_snocE) from snoc have "listall ?R bs" by simp with bs have "\bs'. ?ex Vs bs bs'" by (rule snoc) - then obtain bs' where - bsred: "\j. Var j \\ map (\t. f (t[u/i])) bs \\<^sub>\\<^sup>* Var j \\ map f bs'" - and bsNF: "\j. NF (Var j \\ map f bs')" by iprover + then obtain bs' where bsred: "Var j \\ map (\t. f (t[u/i])) bs \\<^sub>\\<^sup>* Var j \\ map f bs'" + and bsNF: "NF (Var j \\ map f bs')" for j + by iprover from snoc have "?R b" by simp with bT and uNF and uT have "\b'. b[u/i] \\<^sub>\\<^sup>* b' \ NF b'" by iprover diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/Abstract_NAT.thy --- a/src/HOL/ex/Abstract_NAT.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/Abstract_NAT.thy Tue Apr 26 22:59:25 2016 +0200 @@ -23,13 +23,13 @@ by (rule succ_neq_zero [symmetric]) -text \\medskip Primitive recursion as a (functional) relation -- polymorphic!\ +text \\<^medskip> Primitive recursion as a (functional) relation -- polymorphic!\ inductive Rec :: "'a \ ('n \ 'a \ 'a) \ 'n \ 'a \ bool" for e :: 'a and r :: "'n \ 'a \ 'a" where - Rec_zero: "Rec e r zero e" - | Rec_succ: "Rec e r m n \ Rec e r (succ m) (r m n)" + Rec_zero: "Rec e r zero e" +| Rec_succ: "Rec e r m n \ Rec e r (succ m) (r m n)" lemma Rec_functional: fixes x :: 'n @@ -42,26 +42,30 @@ show "\!y. ?R zero y" proof show "?R zero e" .. - fix y assume "?R zero y" - then show "y = e" by cases simp_all + show "y = e" if "?R zero y" for y + using that by cases simp_all qed next case (succ m) from \\!y. ?R m y\ - obtain y where y: "?R m y" - and yy': "\y'. ?R m y' \ y = y'" by blast + obtain y where y: "?R m y" and yy': "\y'. ?R m y' \ y = y'" + by blast show "\!z. ?R (succ m) z" proof from y show "?R (succ m) (r m y)" .. - fix z assume "?R (succ m) z" - then obtain u where "z = r m u" and "?R m u" by cases simp_all - with yy' show "z = r m y" by (simp only:) + next + fix z + assume "?R (succ m) z" + then obtain u where "z = r m u" and "?R m u" + by cases simp_all + with yy' show "z = r m y" + by (simp only:) qed qed qed -text \\medskip The recursion operator -- polymorphic!\ +text \\<^medskip> The recursion operator -- polymorphic!\ definition rec :: "'a \ ('n \ 'a \ 'a) \ 'n \ 'a" where "rec e r x = (THE y. Rec e r x y)" @@ -86,7 +90,7 @@ qed -text \\medskip Example: addition (monomorphic)\ +text \\<^medskip> Example: addition (monomorphic)\ definition add :: "'n \ 'n \ 'n" where "add m n = rec n (\_ k. succ k) m" @@ -109,7 +113,7 @@ by simp -text \\medskip Example: replication (polymorphic)\ +text \\<^medskip> Example: replication (polymorphic)\ definition repl :: "'n \ 'a \ 'a list" where "repl n x = rec [] (\_ xs. x # xs) n" @@ -124,17 +128,17 @@ end -text \\medskip Just see that our abstract specification makes sense \dots\ +text \\<^medskip> Just see that our abstract specification makes sense \dots\ interpretation NAT 0 Suc proof (rule NAT.intro) fix m n show "Suc m = Suc n \ m = n" by simp show "Suc m \ 0" by simp - fix P - assume zero: "P 0" + show "P n" + if zero: "P 0" and succ: "\n. P n \ P (Suc n)" - show "P n" + for P proof (induct n) case 0 show ?case by (rule zero) diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/CTL.thy --- a/src/HOL/ex/CTL.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/CTL.thy Tue Apr 26 22:59:25 2016 +0200 @@ -25,9 +25,8 @@ type_synonym 'a ctl = "'a set" -definition - imp :: "'a ctl \ 'a ctl \ 'a ctl" (infixr "\" 75) where - "p \ q = - p \ q" +definition imp :: "'a ctl \ 'a ctl \ 'a ctl" (infixr "\" 75) + where "p \ q = - p \ q" lemma [intro!]: "p \ p \ q \ q" unfolding imp_def by auto lemma [intro!]: "p \ (q \ p)" unfolding imp_def by rule @@ -43,37 +42,38 @@ axiomatization \ :: "('a \ 'a) set" text \ - The operators \\\, \\\, \\\ are taken as primitives, while - \\\, \\\, \\\ are defined as derived ones. The formula \\ p\ - holds in a state @{term s}, iff there is a successor state @{term s'} (with - respect to the model @{term \}), such that @{term p} holds in @{term s'}. - The formula \\ p\ holds in a state @{term s}, iff there is a path in - \\\, starting from @{term s}, such that there exists a state @{term s'} on - the path, such that @{term p} holds in @{term s'}. The formula \\ p\ - holds in a state @{term s}, iff there is a path, starting from @{term s}, - such that for all states @{term s'} on the path, @{term p} holds in @{term - s'}. It is easy to see that \\ p\ and \\ p\ may be expressed using - least and greatest fixed points @{cite "McMillan-PhDThesis"}. + The operators \\<^bold>E\<^bold>X\, \\<^bold>E\<^bold>F\, \\<^bold>E\<^bold>G\ are taken as primitives, while \\<^bold>A\<^bold>X\, + \\<^bold>A\<^bold>F\, \\<^bold>A\<^bold>G\ are defined as derived ones. The formula \\<^bold>E\<^bold>X p\ holds in a + state \s\, iff there is a successor state \s'\ (with respect to the model + \\\), such that \p\ holds in \s'\. The formula \\<^bold>E\<^bold>F p\ holds in a state + \s\, iff there is a path in \\\, starting from \s\, such that there exists a + state \s'\ on the path, such that \p\ holds in \s'\. The formula \\<^bold>E\<^bold>G p\ + holds in a state \s\, iff there is a path, starting from \s\, such that for + all states \s'\ on the path, \p\ holds in \s'\. It is easy to see that \\<^bold>E\<^bold>F + p\ and \\<^bold>E\<^bold>G p\ may be expressed using least and greatest fixed points + @{cite "McMillan-PhDThesis"}. \ -definition EX ("\ _" [80] 90) - where [simp]: "\ p = {s. \s'. (s, s') \ \ \ s' \ p}" -definition EF ("\ _" [80] 90) - where [simp]: "\ p = lfp (\s. p \ \ s)" -definition EG ("\ _" [80] 90) - where [simp]: "\ p = gfp (\s. p \ \ s)" +definition EX ("\<^bold>E\<^bold>X _" [80] 90) + where [simp]: "\<^bold>E\<^bold>X p = {s. \s'. (s, s') \ \ \ s' \ p}" + +definition EF ("\<^bold>E\<^bold>F _" [80] 90) + where [simp]: "\<^bold>E\<^bold>F p = lfp (\s. p \ \<^bold>E\<^bold>X s)" + +definition EG ("\<^bold>E\<^bold>G _" [80] 90) + where [simp]: "\<^bold>E\<^bold>G p = gfp (\s. p \ \<^bold>E\<^bold>X s)" text \ - \\\, \\\ and \\\ are now defined dually in terms of \\\, - \\\ and \\\. + \\<^bold>A\<^bold>X\, \\<^bold>A\<^bold>F\ and \\<^bold>A\<^bold>G\ are now defined dually in terms of \\<^bold>E\<^bold>X\, + \\<^bold>E\<^bold>F\ and \\<^bold>E\<^bold>G\. \ -definition AX ("\ _" [80] 90) - where [simp]: "\ p = - \ - p" -definition AF ("\ _" [80] 90) - where [simp]: "\ p = - \ - p" -definition AG ("\ _" [80] 90) - where [simp]: "\ p = - \ - p" +definition AX ("\<^bold>A\<^bold>X _" [80] 90) + where [simp]: "\<^bold>A\<^bold>X p = - \<^bold>E\<^bold>X - p" +definition AF ("\<^bold>A\<^bold>F _" [80] 90) + where [simp]: "\<^bold>A\<^bold>F p = - \<^bold>E\<^bold>G - p" +definition AG ("\<^bold>A\<^bold>G _" [80] 90) + where [simp]: "\<^bold>A\<^bold>G p = - \<^bold>E\<^bold>F - p" subsection \Basic fixed point properties\ @@ -86,8 +86,7 @@ proof show "lfp f \ - gfp (\s. - f (- s))" proof - fix x assume l: "x \ lfp f" - show "x \ - gfp (\s. - f (- s))" + show "x \ - gfp (\s. - f (- s))" if l: "x \ lfp f" for x proof assume "x \ gfp (\s. - f (- s))" then obtain u where "x \ u" and "u \ - f (- u)" @@ -100,7 +99,8 @@ qed show "- gfp (\s. - f (- s)) \ lfp f" proof (rule lfp_greatest) - fix u assume "f u \ u" + fix u + assume "f u \ u" then have "- u \ - f u" by auto then have "- u \ - f (- (- u))" by simp then have "- u \ gfp (\s. - f (- s))" by (rule gfp_upperbound) @@ -115,43 +115,44 @@ by (simp add: lfp_gfp) text \ - In order to give dual fixed point representations of @{term "\ p"} and - @{term "\ p"}: + In order to give dual fixed point representations of @{term "\<^bold>A\<^bold>F p"} and + @{term "\<^bold>A\<^bold>G p"}: \ -lemma AF_lfp: "\ p = lfp (\s. p \ \ s)" - by (simp add: lfp_gfp) -lemma AG_gfp: "\ p = gfp (\s. p \ \ s)" +lemma AF_lfp: "\<^bold>A\<^bold>F p = lfp (\s. p \ \<^bold>A\<^bold>X s)" by (simp add: lfp_gfp) -lemma EF_fp: "\ p = p \ \ \ p" +lemma AG_gfp: "\<^bold>A\<^bold>G p = gfp (\s. p \ \<^bold>A\<^bold>X s)" + by (simp add: lfp_gfp) + +lemma EF_fp: "\<^bold>E\<^bold>F p = p \ \<^bold>E\<^bold>X \<^bold>E\<^bold>F p" proof - - have "mono (\s. p \ \ s)" by rule auto + have "mono (\s. p \ \<^bold>E\<^bold>X s)" by rule auto then show ?thesis by (simp only: EF_def) (rule lfp_unfold) qed -lemma AF_fp: "\ p = p \ \ \ p" +lemma AF_fp: "\<^bold>A\<^bold>F p = p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>F p" proof - - have "mono (\s. p \ \ s)" by rule auto + have "mono (\s. p \ \<^bold>A\<^bold>X s)" by rule auto then show ?thesis by (simp only: AF_lfp) (rule lfp_unfold) qed -lemma EG_fp: "\ p = p \ \ \ p" +lemma EG_fp: "\<^bold>E\<^bold>G p = p \ \<^bold>E\<^bold>X \<^bold>E\<^bold>G p" proof - - have "mono (\s. p \ \ s)" by rule auto + have "mono (\s. p \ \<^bold>E\<^bold>X s)" by rule auto then show ?thesis by (simp only: EG_def) (rule gfp_unfold) qed text \ - From the greatest fixed point definition of @{term "\ p"}, we derive as + From the greatest fixed point definition of @{term "\<^bold>A\<^bold>G p"}, we derive as a consequence of the Knaster-Tarski theorem on the one hand that @{term - "\ p"} is a fixed point of the monotonic function - @{term "\s. p \ \ s"}. + "\<^bold>A\<^bold>G p"} is a fixed point of the monotonic function + @{term "\s. p \ \<^bold>A\<^bold>X s"}. \ -lemma AG_fp: "\ p = p \ \ \ p" +lemma AG_fp: "\<^bold>A\<^bold>G p = p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" proof - - have "mono (\s. p \ \ s)" by rule auto + have "mono (\s. p \ \<^bold>A\<^bold>X s)" by rule auto then show ?thesis by (simp only: AG_gfp) (rule gfp_unfold) qed @@ -160,27 +161,27 @@ of \\\, which is an instance of the overloaded \\\ in Isabelle/HOL). \ -lemma AG_fp_1: "\ p \ p" +lemma AG_fp_1: "\<^bold>A\<^bold>G p \ p" proof - - note AG_fp also have "p \ \ \ p \ p" by auto + note AG_fp also have "p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p \ p" by auto finally show ?thesis . qed -lemma AG_fp_2: "\ p \ \ \ p" +lemma AG_fp_2: "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" proof - - note AG_fp also have "p \ \ \ p \ \ \ p" by auto + note AG_fp also have "p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" by auto finally show ?thesis . qed text \ On the other hand, we have from the Knaster-Tarski fixed point theorem that - any other post-fixed point of @{term "\s. p \ \ s"} is smaller than - @{term "\ p"}. A post-fixed point is a set of states @{term q} such that - @{term "q \ p \ \ q"}. This leads to the following co-induction - principle for @{term "\ p"}. + any other post-fixed point of @{term "\s. p \ \<^bold>A\<^bold>X s"} is smaller than + @{term "\<^bold>A\<^bold>G p"}. A post-fixed point is a set of states \q\ such that @{term + "q \ p \ \<^bold>A\<^bold>X q"}. This leads to the following co-induction principle for + @{term "\<^bold>A\<^bold>G p"}. \ -lemma AG_I: "q \ p \ \ q \ q \ \ p" +lemma AG_I: "q \ p \ \<^bold>A\<^bold>X q \ q \ \<^bold>A\<^bold>G p" by (simp only: AG_gfp) (rule gfp_upperbound) @@ -188,92 +189,91 @@ text \ With the most basic facts available, we are now able to establish a few more - interesting results, leading to the \<^emph>\tree induction\ principle for \\\ + interesting results, leading to the \<^emph>\tree induction\ principle for \\<^bold>A\<^bold>G\ (see below). We will use some elementary monotonicity and distributivity rules. \ -lemma AX_int: "\ (p \ q) = \ p \ \ q" by auto -lemma AX_mono: "p \ q \ \ p \ \ q" by auto -lemma AG_mono: "p \ q \ \ p \ \ q" - by (simp only: AG_gfp, rule gfp_mono) auto +lemma AX_int: "\<^bold>A\<^bold>X (p \ q) = \<^bold>A\<^bold>X p \ \<^bold>A\<^bold>X q" by auto +lemma AX_mono: "p \ q \ \<^bold>A\<^bold>X p \ \<^bold>A\<^bold>X q" by auto +lemma AG_mono: "p \ q \ \<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G q" + by (simp only: AG_gfp, rule gfp_mono) auto text \ The formula @{term "AG p"} implies @{term "AX p"} (we use substitution of \\\ with monotonicity). \ -lemma AG_AX: "\ p \ \ p" +lemma AG_AX: "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X p" proof - - have "\ p \ \ \ p" by (rule AG_fp_2) - also have "\ p \ p" by (rule AG_fp_1) + have "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" by (rule AG_fp_2) + also have "\<^bold>A\<^bold>G p \ p" by (rule AG_fp_1) moreover note AX_mono finally show ?thesis . qed text \ - Furthermore we show idempotency of the \\\ operator. The proof is a good + Furthermore we show idempotency of the \\<^bold>A\<^bold>G\ operator. The proof is a good example of how accumulated facts may get used to feed a single rule step. \ -lemma AG_AG: "\ \ p = \ p" +lemma AG_AG: "\<^bold>A\<^bold>G \<^bold>A\<^bold>G p = \<^bold>A\<^bold>G p" proof - show "\ \ p \ \ p" by (rule AG_fp_1) + show "\<^bold>A\<^bold>G \<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G p" by (rule AG_fp_1) next - show "\ p \ \ \ p" + show "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G \<^bold>A\<^bold>G p" proof (rule AG_I) - have "\ p \ \ p" .. - moreover have "\ p \ \ \ p" by (rule AG_fp_2) - ultimately show "\ p \ \ p \ \ \ p" .. + have "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G p" .. + moreover have "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" by (rule AG_fp_2) + ultimately show "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" .. qed qed text \ \<^smallskip> - We now give an alternative characterization of the \\\ operator, which - describes the \\\ operator in an ``operational'' way by tree induction: - In a state holds @{term "AG p"} iff in that state holds @{term p}, and in - all reachable states @{term s} follows from the fact that @{term p} holds in - @{term s}, that @{term p} also holds in all successor states of @{term s}. - We use the co-induction principle @{thm [source] AG_I} to establish this in - a purely algebraic manner. + We now give an alternative characterization of the \\<^bold>A\<^bold>G\ operator, which + describes the \\<^bold>A\<^bold>G\ operator in an ``operational'' way by tree induction: + In a state holds @{term "AG p"} iff in that state holds \p\, and in all + reachable states \s\ follows from the fact that \p\ holds in \s\, that \p\ + also holds in all successor states of \s\. We use the co-induction principle + @{thm [source] AG_I} to establish this in a purely algebraic manner. \ -theorem AG_induct: "p \ \ (p \ \ p) = \ p" +theorem AG_induct: "p \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p) = \<^bold>A\<^bold>G p" proof - show "p \ \ (p \ \ p) \ \ p" (is "?lhs \ _") + show "p \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p) \ \<^bold>A\<^bold>G p" (is "?lhs \ _") proof (rule AG_I) - show "?lhs \ p \ \ ?lhs" + show "?lhs \ p \ \<^bold>A\<^bold>X ?lhs" proof show "?lhs \ p" .. - show "?lhs \ \ ?lhs" + show "?lhs \ \<^bold>A\<^bold>X ?lhs" proof - { - have "\ (p \ \ p) \ p \ \ p" by (rule AG_fp_1) - also have "p \ p \ \ p \ \ p" .. - finally have "?lhs \ \ p" by auto - } + have "\<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p) \ p \ \<^bold>A\<^bold>X p" by (rule AG_fp_1) + also have "p \ p \ \<^bold>A\<^bold>X p \ \<^bold>A\<^bold>X p" .. + finally have "?lhs \ \<^bold>A\<^bold>X p" by auto + } moreover { - have "p \ \ (p \ \ p) \ \ (p \ \ p)" .. - also have "\ \ \ \" by (rule AG_fp_2) - finally have "?lhs \ \ \ (p \ \ p)" . - } - ultimately have "?lhs \ \ p \ \ \ (p \ \ p)" .. - also have "\ = \ ?lhs" by (simp only: AX_int) + have "p \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p) \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p)" .. + also have "\ \ \<^bold>A\<^bold>X \" by (rule AG_fp_2) + finally have "?lhs \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p)" . + } + ultimately have "?lhs \ \<^bold>A\<^bold>X p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p)" .. + also have "\ = \<^bold>A\<^bold>X ?lhs" by (simp only: AX_int) finally show ?thesis . qed qed qed next - show "\ p \ p \ \ (p \ \ p)" + show "\<^bold>A\<^bold>G p \ p \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p)" proof - show "\ p \ p" by (rule AG_fp_1) - show "\ p \ \ (p \ \ p)" + show "\<^bold>A\<^bold>G p \ p" by (rule AG_fp_1) + show "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p)" proof - - have "\ p = \ \ p" by (simp only: AG_AG) - also have "\ p \ \ p" by (rule AG_AX) moreover note AG_mono - also have "\ p \ (p \ \ p)" .. moreover note AG_mono + have "\<^bold>A\<^bold>G p = \<^bold>A\<^bold>G \<^bold>A\<^bold>G p" by (simp only: AG_AG) + also have "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X p" by (rule AG_AX) moreover note AG_mono + also have "\<^bold>A\<^bold>X p \ (p \ \<^bold>A\<^bold>X p)" .. moreover note AG_mono finally show ?thesis . qed qed @@ -284,30 +284,30 @@ text \ Further interesting properties of CTL expressions may be demonstrated with - the help of tree induction; here we show that \\\ and \\\ commute. + the help of tree induction; here we show that \\<^bold>A\<^bold>X\ and \\<^bold>A\<^bold>G\ commute. \ -theorem AG_AX_commute: "\ \ p = \ \ p" +theorem AG_AX_commute: "\<^bold>A\<^bold>G \<^bold>A\<^bold>X p = \<^bold>A\<^bold>X \<^bold>A\<^bold>G p" proof - - have "\ \ p = \ p \ \ \ \ p" by (rule AG_fp) - also have "\ = \ (p \ \ \ p)" by (simp only: AX_int) - also have "p \ \ \ p = \ p" (is "?lhs = _") - proof - have "\ p \ p \ \ p" .. - also have "p \ \ (p \ \ p) = \ p" by (rule AG_induct) + have "\<^bold>A\<^bold>G \<^bold>A\<^bold>X p = \<^bold>A\<^bold>X p \ \<^bold>A\<^bold>X \<^bold>A\<^bold>G \<^bold>A\<^bold>X p" by (rule AG_fp) + also have "\ = \<^bold>A\<^bold>X (p \ \<^bold>A\<^bold>G \<^bold>A\<^bold>X p)" by (simp only: AX_int) + also have "p \ \<^bold>A\<^bold>G \<^bold>A\<^bold>X p = \<^bold>A\<^bold>G p" (is "?lhs = _") + proof + have "\<^bold>A\<^bold>X p \ p \ \<^bold>A\<^bold>X p" .. + also have "p \ \<^bold>A\<^bold>G (p \ \<^bold>A\<^bold>X p) = \<^bold>A\<^bold>G p" by (rule AG_induct) also note Int_mono AG_mono - ultimately show "?lhs \ \ p" by fast - next - have "\ p \ p" by (rule AG_fp_1) - moreover + ultimately show "?lhs \ \<^bold>A\<^bold>G p" by fast + next + have "\<^bold>A\<^bold>G p \ p" by (rule AG_fp_1) + moreover { - have "\ p = \ \ p" by (simp only: AG_AG) - also have "\ p \ \ p" by (rule AG_AX) + have "\<^bold>A\<^bold>G p = \<^bold>A\<^bold>G \<^bold>A\<^bold>G p" by (simp only: AG_AG) + also have "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>X p" by (rule AG_AX) also note AG_mono - ultimately have "\ p \ \ \ p" . - } - ultimately show "\ p \ ?lhs" .. - qed + ultimately have "\<^bold>A\<^bold>G p \ \<^bold>A\<^bold>G \<^bold>A\<^bold>X p" . + } + ultimately show "\<^bold>A\<^bold>G p \ ?lhs" .. + qed finally show ?thesis . qed diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/Cartouche_Examples.thy --- a/src/HOL/ex/Cartouche_Examples.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/Cartouche_Examples.thy Tue Apr 26 22:59:25 2016 +0200 @@ -13,14 +13,14 @@ subsection \Regular outer syntax\ -text \Text cartouches may be used in the outer syntax category "text", - as alternative to the traditional "verbatim" tokens. An example is +text \Text cartouches may be used in the outer syntax category \text\, + as alternative to the traditional \verbatim\ tokens. An example is this text block.\ \ \The same works for small side-comments.\ notepad begin txt \Moreover, cartouches work as additional syntax in the - "altstring" category, for literal fact references. For example:\ + \altstring\ category, for literal fact references. For example:\ fix x y :: 'a assume "x = y" diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/Coherent.thy --- a/src/HOL/ex/Coherent.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/Coherent.thy Tue Apr 26 22:59:25 2016 +0200 @@ -16,65 +16,63 @@ relcomp (infixr "O" 75) lemma p1p2: - assumes - "col a b c l \ col d e f m" - "col b f g n \ col c e g o" - "col b d h p \ col a e h q" - "col c d i r \ col a f i s" - "el n o \ goal" - "el p q \ goal" - "el s r \ goal" - "\A. el A A \ pl g A \ pl h A \ pl i A \ goal" - "\A B C D. col A B C D \ pl A D" - "\A B C D. col A B C D \ pl B D" - "\A B C D. col A B C D \ pl C D" - "\A B. pl A B \ ep A A" - "\A B. ep A B \ ep B A" - "\A B C. ep A B \ ep B C \ ep A C" - "\A B. pl A B \ el B B" - "\A B. el A B \ el B A" - "\A B C. el A B \ el B C \ el A C" - "\A B C. ep A B \ pl B C \ pl A C" - "\A B C. pl A B \ el B C \ pl A C" - "\A B C D E F G H I J K L M N O P Q. - col A B C D \ col E F G H \ col B G I J \ col C F I K \ - col B E L M \ col A F L N \ col C E O P \ col A G O Q \ - (\ R. col I L O R) \ pl A H \ pl B H \ pl C H \ pl E D \ pl F D \ pl G D" - "\A B C D. pl A B \ pl A C \ pl D B \ pl D C \ ep A D \ el B C" - "\A B. ep A A \ ep B B \ \C. pl A C \ pl B C" + assumes "col a b c l \ col d e f m" + and "col b f g n \ col c e g o" + and "col b d h p \ col a e h q" + and "col c d i r \ col a f i s" + and "el n o \ goal" + and "el p q \ goal" + and "el s r \ goal" + and "\A. el A A \ pl g A \ pl h A \ pl i A \ goal" + and "\A B C D. col A B C D \ pl A D" + and "\A B C D. col A B C D \ pl B D" + and "\A B C D. col A B C D \ pl C D" + and "\A B. pl A B \ ep A A" + and "\A B. ep A B \ ep B A" + and "\A B C. ep A B \ ep B C \ ep A C" + and "\A B. pl A B \ el B B" + and "\A B. el A B \ el B A" + and "\A B C. el A B \ el B C \ el A C" + and "\A B C. ep A B \ pl B C \ pl A C" + and "\A B C. pl A B \ el B C \ pl A C" + and "\A B C D E F G H I J K L M N O P Q. + col A B C D \ col E F G H \ col B G I J \ col C F I K \ + col B E L M \ col A F L N \ col C E O P \ col A G O Q \ + (\ R. col I L O R) \ pl A H \ pl B H \ pl C H \ pl E D \ pl F D \ pl G D" + and "\A B C D. pl A B \ pl A C \ pl D B \ pl D C \ ep A D \ el B C" + and "\A B. ep A A \ ep B B \ \C. pl A C \ pl B C" shows goal using assms by coherent lemma p2p1: - assumes - "col a b c l \ col d e f m" - "col b f g n \ col c e g o" - "col b d h p \ col a e h q" - "col c d i r \ col a f i s" - "pl a m \ goal" - "pl b m \ goal" - "pl c m \ goal" - "pl d l \ goal" - "pl e l \ goal" - "pl f l \ goal" - "\A. pl g A \ pl h A \ pl i A \ goal" - "\A B C D. col A B C D \ pl A D" - "\A B C D. col A B C D \ pl B D" - "\A B C D. col A B C D \ pl C D" - "\A B. pl A B \ ep A A" - "\A B. ep A B \ ep B A" - "\A B C. ep A B \ ep B C \ ep A C" - "\A B. pl A B \ el B B" - "\A B. el A B \ el B A" - "\A B C. el A B \ el B C \ el A C" - "\A B C. ep A B \ pl B C \ pl A C" - "\A B C. pl A B \ el B C \ pl A C" - "\A B C D E F G H I J K L M N O P Q. - col A B C J \ col D E F K \ col B F G L \ col C E G M \ - col B D H N \ col A E H O \ col C D I P \ col A F I Q \ - (\ R. col G H I R) \ el L M \ el N O \ el P Q" - "\A B C D. pl C A \ pl C B \ pl D A \ pl D B \ ep C D \ el A B" - "\A B C. ep A A \ ep B B \ \C. pl A C \ pl B C" + assumes "col a b c l \ col d e f m" + and "col b f g n \ col c e g o" + and "col b d h p \ col a e h q" + and "col c d i r \ col a f i s" + and "pl a m \ goal" + and "pl b m \ goal" + and "pl c m \ goal" + and "pl d l \ goal" + and "pl e l \ goal" + and "pl f l \ goal" + and "\A. pl g A \ pl h A \ pl i A \ goal" + and "\A B C D. col A B C D \ pl A D" + and "\A B C D. col A B C D \ pl B D" + and "\A B C D. col A B C D \ pl C D" + and "\A B. pl A B \ ep A A" + and "\A B. ep A B \ ep B A" + and "\A B C. ep A B \ ep B C \ ep A C" + and "\A B. pl A B \ el B B" + and "\A B. el A B \ el B A" + and "\A B C. el A B \ el B C \ el A C" + and "\A B C. ep A B \ pl B C \ pl A C" + and "\A B C. pl A B \ el B C \ pl A C" + and "\A B C D E F G H I J K L M N O P Q. + col A B C J \ col D E F K \ col B F G L \ col C E G M \ + col B D H N \ col A E H O \ col C D I P \ col A F I Q \ + (\ R. col G H I R) \ el L M \ el N O \ el P Q" + and "\A B C D. pl C A \ pl C B \ pl D A \ pl D B \ ep C D \ el A B" + and "\A B C. ep A A \ ep B B \ \C. pl A C \ pl B C" shows goal using assms by coherent @@ -82,16 +80,15 @@ subsection \Preservation of the Diamond Property under reflexive closure\ lemma diamond: - assumes - "reflexive_rewrite a b" "reflexive_rewrite a c" - "\A. reflexive_rewrite b A \ reflexive_rewrite c A \ goal" - "\A. equalish A A" - "\A B. equalish A B \ equalish B A" - "\A B C. equalish A B \ reflexive_rewrite B C \ reflexive_rewrite A C" - "\A B. equalish A B \ reflexive_rewrite A B" - "\A B. rewrite A B \ reflexive_rewrite A B" - "\A B. reflexive_rewrite A B \ equalish A B \ rewrite A B" - "\A B C. rewrite A B \ rewrite A C \ \D. rewrite B D \ rewrite C D" + assumes "reflexive_rewrite a b" "reflexive_rewrite a c" + and "\A. reflexive_rewrite b A \ reflexive_rewrite c A \ goal" + and "\A. equalish A A" + and "\A B. equalish A B \ equalish B A" + and "\A B C. equalish A B \ reflexive_rewrite B C \ reflexive_rewrite A C" + and "\A B. equalish A B \ reflexive_rewrite A B" + and "\A B. rewrite A B \ reflexive_rewrite A B" + and "\A B. reflexive_rewrite A B \ equalish A B \ rewrite A B" + and "\A B C. rewrite A B \ rewrite A C \ \D. rewrite B D \ rewrite C D" shows goal using assms by coherent diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/Cubic_Quartic.thy --- a/src/HOL/ex/Cubic_Quartic.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/Cubic_Quartic.thy Tue Apr 26 22:59:25 2016 +0200 @@ -2,144 +2,160 @@ Author: Amine Chaieb *) -section "The Cubic and Quartic Root Formulas" +section \The Cubic and Quartic Root Formulas\ theory Cubic_Quartic imports Complex_Main begin -section "The Cubic Formula" +section \The Cubic Formula\ definition "ccbrt z = (SOME (w::complex). w^3 = z)" lemma ccbrt: "(ccbrt z) ^ 3 = z" -proof- - from rcis_Ex obtain r a where ra: "z = rcis r a" by blast +proof - + from rcis_Ex obtain r a where ra: "z = rcis r a" + by blast let ?r' = "if r < 0 then - root 3 (-r) else root 3 r" let ?a' = "a/3" - have "rcis ?r' ?a' ^ 3 = rcis r a" by (cases "r<0", simp_all add: DeMoivre2) - hence th: "\w. w^3 = z" unfolding ra by blast - from someI_ex[OF th] show ?thesis unfolding ccbrt_def by blast + have "rcis ?r' ?a' ^ 3 = rcis r a" + by (cases "r < 0") (simp_all add: DeMoivre2) + then have *: "\w. w^3 = z" + unfolding ra by blast + from someI_ex [OF *] show ?thesis + unfolding ccbrt_def by blast qed -text "The reduction to a simpler form:" + +text \The reduction to a simpler form:\ lemma cubic_reduction: fixes a :: complex - assumes H: "a \ 0 \ x = y - b / (3 * a) \ p = (3* a * c - b^2) / (9 * a^2) \ - q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d) / (54 * a^3)" + assumes + "a \ 0 \ x = y - b / (3 * a) \ p = (3* a * c - b^2) / (9 * a^2) \ + q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d) / (54 * a^3)" shows "a * x^3 + b * x^2 + c * x + d = 0 \ y^3 + 3 * p * y - 2 * q = 0" -proof- - from H have "3*a \ 0" "9*a^2 \ 0" "54*a^3 \ 0" by auto - hence th: "x = y - b / (3 * a) \ (3*a) * x = (3*a) * y - b" - "p = (3* a * c - b^2) / (9 * a^2) \ (9 * a^2) * p = (3* a * c - b^2)" - "q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d) / (54 * a^3) \ - (54 * a^3) * q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d)" +proof - + from assms have "3 * a \ 0" "9 * a^2 \ 0" "54 * a^3 \ 0" by auto + then have *: + "x = y - b / (3 * a) \ (3*a) * x = (3*a) * y - b" + "p = (3* a * c - b^2) / (9 * a^2) \ (9 * a^2) * p = (3* a * c - b^2)" + "q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d) / (54 * a^3) \ + (54 * a^3) * q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d)" by (simp_all add: field_simps) - from H[unfolded th] show ?thesis by algebra + from assms [unfolded *] show ?thesis + by algebra qed -text "The solutions of the special form:" -lemma cubic_basic: +text \The solutions of the special form:\ + +lemma cubic_basic: fixes s :: complex - assumes H: "s^2 = q^2 + p^3 \ - s1^3 = (if p = 0 then 2 * q else q + s) \ - s2 = -s1 * (1 + i * t) / 2 \ - s3 = -s1 * (1 - i * t) / 2 \ - i^2 + 1 = 0 \ - t^2 = 3" - shows + assumes + "s^2 = q^2 + p^3 \ + s1^3 = (if p = 0 then 2 * q else q + s) \ + s2 = -s1 * (1 + i * t) / 2 \ + s3 = -s1 * (1 - i * t) / 2 \ + i^2 + 1 = 0 \ + t^2 = 3" + shows "if p = 0 then y^3 + 3 * p * y - 2 * q = 0 \ y = s1 \ y = s2 \ y = s3 else s1 \ 0 \ - (y^3 + 3 * p * y - 2 * q = 0 \ (y = s1 - p / s1 \ y = s2 - p / s2 \ y = s3 - p / s3))" -proof- - { assume p0: "p = 0" - with H have ?thesis by (simp add: field_simps) algebra - } - moreover - { assume p0: "p \ 0" - with H have th1: "s1 \ 0" by (simp add: field_simps) algebra - from p0 H th1 have th0: "s2 \ 0" "s3 \0" - by (simp_all add: field_simps) algebra+ - from th1 th0 - have th: "y = s1 - p / s1 \ s1*y = s1^2 - p" - "y = s2 - p / s2 \ s2*y = s2^2 - p" - "y = s3 - p / s3 \ s3*y = s3^2 - p" - by (simp_all add: field_simps power2_eq_square) - from p0 H have ?thesis unfolding th by (simp add: field_simps) algebra - } - ultimately show ?thesis by blast + (y^3 + 3 * p * y - 2 * q = 0 \ (y = s1 - p / s1 \ y = s2 - p / s2 \ y = s3 - p / s3))" +proof (cases "p = 0") + case True + with assms show ?thesis + by (simp add: field_simps) algebra +next + case False + with assms have *: "s1 \ 0" by (simp add: field_simps) algebra + with assms False have "s2 \ 0" "s3 \ 0" + by (simp_all add: field_simps) algebra+ + with * have **: + "y = s1 - p / s1 \ s1 * y = s1^2 - p" + "y = s2 - p / s2 \ s2 * y = s2^2 - p" + "y = s3 - p / s3 \ s3 * y = s3^2 - p" + by (simp_all add: field_simps power2_eq_square) + from assms False show ?thesis + unfolding ** by (simp add: field_simps) algebra qed -text "Explicit formula for the roots:" + +text \Explicit formula for the roots:\ lemma cubic: assumes a0: "a \ 0" - shows " - let p = (3 * a * c - b^2) / (9 * a^2) ; + shows + "let + p = (3 * a * c - b^2) / (9 * a^2); q = (9 * a * b * c - 2 * b^3 - 27 * a^2 * d) / (54 * a^3); s = csqrt(q^2 + p^3); s1 = (if p = 0 then ccbrt(2 * q) else ccbrt(q + s)); s2 = -s1 * (1 + ii * csqrt 3) / 2; s3 = -s1 * (1 - ii * csqrt 3) / 2 - in if p = 0 then - a * x^3 + b * x^2 + c * x + d = 0 \ - x = s1 - b / (3 * a) \ - x = s2 - b / (3 * a) \ - x = s3 - b / (3 * a) + in + if p = 0 then + a * x^3 + b * x^2 + c * x + d = 0 \ + x = s1 - b / (3 * a) \ + x = s2 - b / (3 * a) \ + x = s3 - b / (3 * a) else s1 \ 0 \ - (a * x^3 + b * x^2 + c * x + d = 0 \ + (a * x^3 + b * x^2 + c * x + d = 0 \ x = s1 - p / s1 - b / (3 * a) \ x = s2 - p / s2 - b / (3 * a) \ x = s3 - p / s3 - b / (3 * a))" -proof- +proof - let ?p = "(3 * a * c - b^2) / (9 * a^2)" let ?q = "(9 * a * b * c - 2 * b^3 - 27 * a^2 * d) / (54 * a^3)" - let ?s = "csqrt(?q^2 + ?p^3)" + let ?s = "csqrt (?q^2 + ?p^3)" let ?s1 = "if ?p = 0 then ccbrt(2 * ?q) else ccbrt(?q + ?s)" let ?s2 = "- ?s1 * (1 + ii * csqrt 3) / 2" let ?s3 = "- ?s1 * (1 - ii * csqrt 3) / 2" let ?y = "x + b / (3 * a)" - from a0 have zero: "9 * a^2 \ 0" "a^3 * 54 \ 0" "(a*3)\ 0" by auto - have eq:"a * x^3 + b * x^2 + c * x + d = 0 \ ?y^3 + 3 * ?p * ?y - 2 * ?q = 0" + from a0 have zero: "9 * a^2 \ 0" "a^3 * 54 \ 0" "(a * 3) \ 0" + by auto + have eq: "a * x^3 + b * x^2 + c * x + d = 0 \ ?y^3 + 3 * ?p * ?y - 2 * ?q = 0" by (rule cubic_reduction) (auto simp add: field_simps zero a0) have "csqrt 3^2 = 3" by (rule power2_csqrt) - hence th0: "?s^2 = ?q^2 + ?p ^ 3 \ ?s1^ 3 = (if ?p = 0 then 2 * ?q else ?q + ?s) \ - ?s2 = - ?s1 * (1 + ii * csqrt 3) / 2 \ - ?s3 = - ?s1 * (1 - ii * csqrt 3) / 2 \ - ii^2 + 1 = 0 \ csqrt 3^2 = 3" + then have th0: + "?s^2 = ?q^2 + ?p ^ 3 \ ?s1^ 3 = (if ?p = 0 then 2 * ?q else ?q + ?s) \ + ?s2 = - ?s1 * (1 + ii * csqrt 3) / 2 \ + ?s3 = - ?s1 * (1 - ii * csqrt 3) / 2 \ + ii^2 + 1 = 0 \ csqrt 3^2 = 3" using zero by (simp add: field_simps ccbrt) from cubic_basic[OF th0, of ?y] - show ?thesis + show ?thesis apply (simp only: Let_def eq) using zero apply (simp add: field_simps ccbrt) using zero - apply (cases "a * (c * 3) = b^2", simp_all add: field_simps) + apply (cases "a * (c * 3) = b^2") + apply (simp_all add: field_simps) done qed -section "The Quartic Formula" +section \The Quartic Formula\ lemma quartic: - "(y::real)^3 - b * y^2 + (a * c - 4 * d) * y - a^2 * d + 4 * b * d - c^2 = 0 \ - R^2 = a^2 / 4 - b + y \ - s^2 = y^2 - 4 * d \ - (D^2 = (if R = 0 then 3 * a^2 / 4 - 2 * b + 2 * s - else 3 * a^2 / 4 - R^2 - 2 * b + (4 * a * b - 8 * c - a^3) / (4 * R))) \ - (E^2 = (if R = 0 then 3 * a^2 / 4 - 2 * b - 2 * s - else 3 * a^2 / 4 - R^2 - 2 * b - (4 * a * b - 8 * c - a^3) / (4 * R))) + "(y::real)^3 - b * y^2 + (a * c - 4 * d) * y - a^2 * d + 4 * b * d - c^2 = 0 \ + R^2 = a^2 / 4 - b + y \ + s^2 = y^2 - 4 * d \ + (D^2 = (if R = 0 then 3 * a^2 / 4 - 2 * b + 2 * s + else 3 * a^2 / 4 - R^2 - 2 * b + (4 * a * b - 8 * c - a^3) / (4 * R))) \ + (E^2 = (if R = 0 then 3 * a^2 / 4 - 2 * b - 2 * s + else 3 * a^2 / 4 - R^2 - 2 * b - (4 * a * b - 8 * c - a^3) / (4 * R))) \ x^4 + a * x^3 + b * x^2 + c * x + d = 0 \ x = -a / 4 + R / 2 + D / 2 \ x = -a / 4 + R / 2 - D / 2 \ x = -a / 4 - R / 2 + E / 2 \ x = -a / 4 - R / 2 - E / 2" -apply (cases "R=0", simp_all add: field_simps divide_minus_left[symmetric] del: divide_minus_left) - apply algebra -apply algebra -done + apply (cases "R = 0") + apply (simp_all add: field_simps divide_minus_left[symmetric] del: divide_minus_left) + apply algebra + apply algebra + done end diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/Gauge_Integration.thy --- a/src/HOL/ex/Gauge_Integration.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/Gauge_Integration.thy Tue Apr 26 22:59:25 2016 +0200 @@ -133,7 +133,7 @@ proof (cases "b < x") case True with 2 obtain N where *: "N < length D" - and **: "\ d t e. D ! N = (d,t,e) \ d < x \ x \ e" by auto + and **: "D ! N = (d,t,e) \ d < x \ x \ e" for d t e by auto hence "Suc N < length ((a,t,b)#D) \ (\ d t' e. ((a,t,b)#D) ! Suc N = (d,t',e) \ d < x \ x \ e)" by auto thus ?thesis by auto @@ -372,11 +372,11 @@ hence "a < b" and "b < c" by auto obtain \1 where \1_gauge: "gauge {a..b} \1" - and I1: "\ D. fine \1 (a,b) D \ \ rsum D f - x1 \ < (\ / 2)" + and I1: "fine \1 (a,b) D \ \ rsum D f - x1 \ < (\ / 2)" for D using IntegralE [OF \Integral (a, b) f x1\ \0 < \/2\] by auto obtain \2 where \2_gauge: "gauge {b..c} \2" - and I2: "\ D. fine \2 (b,c) D \ \ rsum D f - x2 \ < (\ / 2)" + and I2: "fine \2 (b,c) D \ \ rsum D f - x2 \ < (\ / 2)" for D using IntegralE [OF \Integral (b, c) f x2\ \0 < \/2\] by auto define \ where "\ x = @@ -541,7 +541,7 @@ then have "\r>0. \s>0. \z. z \ x \ \z - x\ < s \ \(f z - f x) / (z - x) - f' x\ < r" by (simp add: DERIV_iff2 LIM_eq) with \0 < e\ obtain s - where "\z. z \ x \ \z - x\ < s \ \(f z - f x) / (z - x) - f' x\ < e/2" and "0 < s" + where "z \ x \ \z - x\ < s \ \(f z - f x) / (z - x) - f' x\ < e/2" and "0 < s" for z by (drule_tac x="e/2" in spec, auto) with strad1 [of x s f f' e] have strad: "\z. \z - x\ < s \ \f z - f x - f' x * (z - x)\ \ e/2 * \z - x\" @@ -586,8 +586,8 @@ from lemma_straddle [OF f' this] obtain \ where "gauge {a..b} \" - and \: "\x u v. \a \ u; u \ x; x \ v; v \ b; v - u < \ x\ \ - \f v - f u - f' x * (v - u)\ \ e * (v - u) / (b - a)" by auto + and \: "\a \ u; u \ x; x \ v; v \ b; v - u < \ x\ \ + \f v - f u - f' x * (v - u)\ \ e * (v - u) / (b - a)" for x u v by auto have "\D. fine \ (a, b) D \ \rsum D f' - (f b - f a)\ \ e" proof (clarify) diff -r 4a108f280dc2 -r 60406bf310f8 src/HOL/ex/document/root.tex --- a/src/HOL/ex/document/root.tex Fri Apr 22 17:22:29 2016 +0200 +++ b/src/HOL/ex/document/root.tex Tue Apr 26 22:59:25 2016 +0200 @@ -10,14 +10,6 @@ \urlstyle{rm} \isabellestyle{it} -\newcommand{\isasymEX}{\isamath{\mathrm{EX}}} -\newcommand{\isasymEF}{\isamath{\mathrm{EF}}} -\newcommand{\isasymEG}{\isamath{\mathrm{EG}}} -\newcommand{\isasymAX}{\isamath{\mathrm{AX}}} -\newcommand{\isasymAF}{\isamath{\mathrm{AF}}} -\newcommand{\isasymAG}{\isamath{\mathrm{AG}}} - - \begin{document} diff -r 4a108f280dc2 -r 60406bf310f8 src/Pure/Isar/obtain.ML --- a/src/Pure/Isar/obtain.ML Fri Apr 22 17:22:29 2016 +0200 +++ b/src/Pure/Isar/obtain.ML Tue Apr 26 22:59:25 2016 +0200 @@ -15,8 +15,10 @@ val consider: Element.obtains_i -> bool -> Proof.state -> Proof.state val consider_cmd: Element.obtains -> bool -> Proof.state -> Proof.state val obtain: binding -> (binding * typ option * mixfix) list -> + (binding * typ option * mixfix) list -> (term * term list) list list -> (Thm.binding * (term * term list) list) list -> bool -> Proof.state -> Proof.state val obtain_cmd: binding -> (binding * string option * mixfix) list -> + (binding * string option * mixfix) list -> (string * string list) list list -> (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state val result: (Proof.context -> tactic) -> thm list -> Proof.context -> ((string * cterm) list * thm list) * Proof.context @@ -193,28 +195,32 @@ local -fun gen_obtain prep_spec prep_att that_binding raw_vars raw_asms int state = +fun gen_obtain prep_stmt prep_att that_binding raw_decls raw_fixes raw_prems raw_concls int state = let val _ = Proof.assert_forward_or_chain state; val ((_, thesis), thesis_ctxt) = obtain_thesis (Proof.context_of state); - val (((vars, xs, params), propss, binds, binds'), params_ctxt) = - prep_spec raw_vars (map #2 raw_asms) thesis_ctxt; - val cparams = map (Thm.cterm_of params_ctxt) params; - val asms = - map (fn ((b, raw_atts), _) => (b, map (prep_att params_ctxt) raw_atts)) raw_asms ~~ - map (map (rpair [])) propss; + val ((vars, propss, binds, binds'), params_ctxt) = + prep_stmt (raw_decls @ raw_fixes) (raw_prems @ map #2 raw_concls) thesis_ctxt; + val (decls, fixes) = chop (length raw_decls) vars ||> map #2; + val (premss, conclss) = chop (length raw_prems) propss; + val propss' = (map o map) (Logic.close_prop fixes (flat premss)) conclss; val that_prop = - Logic.list_rename_params xs - (fold_rev Logic.all params (Logic.list_implies (flat propss, thesis))); + Logic.list_rename_params (map (#1 o #2) decls) + (fold_rev (Logic.all o #2 o #2) decls (Logic.list_implies (flat propss', thesis))); + + val cparams = map (Thm.cterm_of params_ctxt o #2 o #2) decls; + val asms = + map (fn ((b, raw_atts), _) => (b, map (prep_att params_ctxt) raw_atts)) raw_concls ~~ + map (map (rpair [])) propss'; fun after_qed (result_ctxt, results) state' = let val [rule] = Proof_Context.export result_ctxt (Proof.context_of state') (flat results) in state' - |> Proof.fix vars - |> Proof.map_context (fold Variable.bind_term binds) + |> Proof.fix (map #1 decls) + |> Proof.map_context (fold (Variable.bind_term o apsnd (Logic.close_term fixes)) binds) |> Proof.assm (obtain_export params_ctxt rule cparams) [] [] asms end; in @@ -229,8 +235,8 @@ in -val obtain = gen_obtain Proof_Context.cert_spec (K I); -val obtain_cmd = gen_obtain Proof_Context.read_spec Attrib.attribute_cmd; +val obtain = gen_obtain Proof_Context.cert_stmt (K I); +val obtain_cmd = gen_obtain Proof_Context.read_stmt Attrib.attribute_cmd; end; diff -r 4a108f280dc2 -r 60406bf310f8 src/Pure/Isar/proof.ML --- a/src/Pure/Isar/proof.ML Fri Apr 22 17:22:29 2016 +0200 +++ b/src/Pure/Isar/proof.ML Tue Apr 26 22:59:25 2016 +0200 @@ -641,66 +641,18 @@ end; -(* structured clause *) - -fun export_binds ctxt' ctxt binds = - let - val rhss = - map (the_list o snd) binds - |> burrow (Variable.export_terms ctxt' ctxt) - |> map (try the_single); - in map fst binds ~~ rhss end; - -fun prep_clause prep_var prep_propp raw_fixes raw_assumes raw_shows ctxt = - let - (*fixed variables*) - val ((xs', vars), fix_ctxt) = ctxt - |> fold_map prep_var raw_fixes - |-> (fn vars => Proof_Context.add_fixes vars ##>> pair vars); - - (*propositions with term bindings*) - val (all_propss, binds) = prep_propp fix_ctxt (raw_assumes @ raw_shows); - val (assumes_propss, shows_propss) = chop (length raw_assumes) all_propss; - - (*params*) - val (ps, params_ctxt) = fix_ctxt - |> (fold o fold) Variable.declare_term all_propss - |> fold Variable.bind_term binds - |> fold_map Proof_Context.inferred_param xs'; - val xs = map (Variable.check_name o #1) vars; - val params = xs ~~ map Free ps; - - val _ = Variable.warn_extra_tfrees fix_ctxt params_ctxt; - - (*result term bindings*) - val shows_props = flat shows_propss; - val binds' = - (case try List.last shows_props of - NONE => [] - | SOME prop => map (apsnd (SOME o Auto_Bind.abs_params prop)) binds); - val result_binds = - (Auto_Bind.facts params_ctxt shows_props @ binds') - |> (map o apsnd o Option.map) (fold_rev Term.dependent_lambda_name params) - |> export_binds params_ctxt ctxt; - in ((params, assumes_propss, shows_propss, result_binds), params_ctxt) end; - - (* assume *) local -fun gen_assume prep_var prep_propp prep_att export raw_fixes raw_prems raw_concls state = +fun gen_assume prep_statement prep_att export raw_fixes raw_prems raw_concls state = let val ctxt = context_of state; val bindings = map (apsnd (map (prep_att ctxt)) o fst) raw_concls; - val (params, prems_propss, concl_propss, result_binds) = - #1 (prep_clause prep_var prep_propp raw_fixes raw_prems (map snd raw_concls) ctxt); - - fun close prop = - fold_rev Logic.dependent_all_name params - (Logic.list_implies (flat prems_propss, prop)); - val propss = (map o map) close concl_propss; + val ((params, prems_propss, concl_propss, result_binds), _) = + prep_statement raw_fixes raw_prems (map snd raw_concls) ctxt; + val propss = (map o map) (Logic.close_prop params (flat prems_propss)) concl_propss; in state |> assert_forward @@ -716,8 +668,8 @@ in -val assm = gen_assume Proof_Context.cert_var Proof_Context.cert_propp (K I); -val assm_cmd = gen_assume Proof_Context.read_var Proof_Context.read_propp Attrib.attribute_cmd; +val assm = gen_assume Proof_Context.cert_statement (K I); +val assm_cmd = gen_assume Proof_Context.read_statement Attrib.attribute_cmd; val assume = assm Assumption.assume_export; val assume_cmd = assm_cmd Assumption.assume_export; @@ -893,45 +845,37 @@ local -fun match_defs (((b, _, mx), x) :: more_decls) ((((a, _), t), _) :: more_defs) = - if x = a then ((b, mx), (Thm.empty_binding, t)) :: match_defs more_decls more_defs - else error ("Mismatch of declaration " ^ quote x ^ " wrt. definition " ^ quote a) - | match_defs [] [] = [] - | match_defs more_decls more_defs = - error ("Mismatch of declarations " ^ commas_quote (map #2 more_decls) ^ - (if null more_decls then "" else " ") ^ - "wrt. definitions " ^ commas_quote (map (#1 o #1 o #1) more_defs)); - -fun invisible_fixes vars ctxt = ctxt - |> Context_Position.set_visible false - |> Proof_Context.add_fixes vars |> #2 - |> Context_Position.restore_visible ctxt; - -fun gen_define prep_spec prep_att raw_vars raw_fixes raw_defs state = +fun gen_define prep_stmt prep_att raw_decls raw_fixes raw_defs state = let val _ = assert_forward state; val ctxt = context_of state; (*vars*) - val n_vars = length raw_vars; - val (((all_vars, _, all_params), defss, _, binds'), _) = - prep_spec (raw_vars @ raw_fixes) (map snd raw_defs) ctxt; - val (vars, fixes) = chop n_vars all_vars; - val (params, _) = chop n_vars all_params; + val ((vars, propss, _, binds'), vars_ctxt) = + prep_stmt (raw_decls @ raw_fixes) (map snd raw_defs) ctxt; + val (decls, fixes) = chop (length raw_decls) vars; + val show_term = Syntax.string_of_term vars_ctxt; (*defs*) - val derived_def = Local_Defs.derived_def (invisible_fixes vars ctxt) {conditional = false}; - val defs1 = map derived_def (flat defss); - val defs2 = match_defs (vars ~~ map (#1 o dest_Free) params) defs1; + fun match_defs (((b, _, mx), (_, Free (x, T))) :: more_decls) ((((y, U), t), _) :: more_defs) = + if x = y then ((b, mx), (Thm.empty_binding, t)) :: match_defs more_decls more_defs + else + error ("Mismatch of declaration " ^ show_term (Free (x, T)) ^ " wrt. definition " ^ + show_term (Free (y, U))) + | match_defs [] [] = [] + | match_defs more_decls more_defs = + error ("Mismatch of declarations " ^ commas (map (show_term o #2 o #2) more_decls) ^ + (if null more_decls then "" else " ") ^ + "wrt. definitions " ^ commas (map (show_term o Free o #1 o #1) more_defs)); + + val derived_def = Local_Defs.derived_def ctxt {conditional = false}; + val defs1 = map (derived_def o Logic.close_prop (map #2 fixes) []) (flat propss); + val defs2 = match_defs decls defs1; val (defs3, defs_ctxt) = Local_Defs.add_defs defs2 ctxt; - (*fixes*) - val fixes_ctxt = invisible_fixes fixes defs_ctxt; - val export = singleton (Variable.export fixes_ctxt defs_ctxt); - (*notes*) val def_thmss = - map (fn (((_, prove), ((b, _), _)), (_, (_, th))) => (b, export (prove fixes_ctxt th))) + map (fn (((_, prove), ((b, _), _)), (_, (_, th))) => (b, prove defs_ctxt th)) (defs1 ~~ defs2 ~~ defs3) |> unflat (map snd raw_defs); val notes = @@ -947,8 +891,8 @@ in -val define = gen_define Proof_Context.cert_spec (K I); -val define_cmd = gen_define Proof_Context.read_spec Attrib.attribute_cmd; +val define = gen_define Proof_Context.cert_stmt (K I); +val define_cmd = gen_define Proof_Context.read_stmt Attrib.attribute_cmd; end; @@ -1128,7 +1072,7 @@ (* local goals *) -fun local_goal print_results prep_att prep_propp prep_var strict_asm +fun local_goal print_results prep_statement prep_att strict_asm kind before_qed after_qed raw_fixes raw_assumes raw_shows state = let val ctxt = context_of state; @@ -1139,7 +1083,7 @@ (*params*) val ((params, assumes_propss, shows_propss, result_binds), params_ctxt) = ctxt - |> prep_clause prep_var prep_propp raw_fixes (map snd raw_assumes) (map snd raw_shows); + |> prep_statement raw_fixes (map snd raw_assumes) (map snd raw_shows); (*prems*) val (assumes_bindings, shows_bindings) = @@ -1254,18 +1198,16 @@ (* common goal statements *) fun internal_goal print_results mode = - local_goal print_results (K I) (Proof_Context.cert_propp o Proof_Context.set_mode mode) - Proof_Context.cert_var; + local_goal print_results + (fn a => fn b => fn c => Proof_Context.cert_statement a b c o Proof_Context.set_mode mode) (K I); local -fun gen_have prep_att prep_propp prep_var - strict_asm before_qed after_qed fixes assumes shows int = +fun gen_have prep_statement prep_att strict_asm before_qed after_qed fixes assumes shows int = local_goal (Proof_Display.print_results int (Position.thread_data ())) - prep_att prep_propp prep_var strict_asm "have" before_qed after_qed fixes assumes shows; + prep_statement prep_att strict_asm "have" before_qed after_qed fixes assumes shows; -fun gen_show prep_att prep_propp prep_var - strict_asm before_qed after_qed fixes assumes shows int state = +fun gen_show prep_statement prep_att strict_asm before_qed after_qed fixes assumes shows int state = let val testing = Unsynchronized.ref false; val rule = Unsynchronized.ref (NONE: thm option); @@ -1296,7 +1238,7 @@ |> after_qed (result_ctxt, results); in state - |> local_goal print_results prep_att prep_propp prep_var strict_asm + |> local_goal print_results prep_statement prep_att strict_asm "show" before_qed after_qed' fixes assumes shows ||> int ? (fn goal_state => (case test_proof (map_context (Context_Position.set_visible false) goal_state) of @@ -1306,10 +1248,10 @@ in -val have = gen_have (K I) Proof_Context.cert_propp Proof_Context.cert_var; -val have_cmd = gen_have Attrib.attribute_cmd Proof_Context.read_propp Proof_Context.read_var; -val show = gen_show (K I) Proof_Context.cert_propp Proof_Context.cert_var; -val show_cmd = gen_show Attrib.attribute_cmd Proof_Context.read_propp Proof_Context.read_var; +val have = gen_have Proof_Context.cert_statement (K I); +val have_cmd = gen_have Proof_Context.read_statement Attrib.attribute_cmd; +val show = gen_show Proof_Context.cert_statement (K I); +val show_cmd = gen_show Proof_Context.read_statement Attrib.attribute_cmd; end; diff -r 4a108f280dc2 -r 60406bf310f8 src/Pure/Isar/proof_context.ML --- a/src/Pure/Isar/proof_context.ML Fri Apr 22 17:22:29 2016 +0200 +++ b/src/Pure/Isar/proof_context.ML Tue Apr 26 22:59:25 2016 +0200 @@ -166,12 +166,22 @@ val generic_add_abbrev: string -> binding * term -> Context.generic -> (term * term) * Context.generic val generic_revert_abbrev: string -> string -> Context.generic -> Context.generic - val cert_spec: (binding * typ option * mixfix) list -> (term * term list) list list -> - Proof.context -> (((binding * typ option * mixfix) list * string list * term list) * - term list list * (indexname * term) list * (indexname * term) list) * Proof.context - val read_spec: (binding * string option * mixfix) list -> (string * string list) list list -> - Proof.context -> (((binding * typ option * mixfix) list * string list * term list) * - term list list * (indexname * term) list * (indexname * term) list) * Proof.context + val cert_stmt: + (binding * typ option * mixfix) list -> (term * term list) list list -> Proof.context -> + (((binding * typ option * mixfix) * (string * term)) list * term list list * + (indexname * term) list * (indexname * term) list) * Proof.context + val read_stmt: + (binding * string option * mixfix) list -> (string * string list) list list -> Proof.context -> + (((binding * typ option * mixfix) * (string * term)) list * term list list * + (indexname * term) list * (indexname * term) list) * Proof.context + val cert_statement: (binding * typ option * mixfix) list -> + (term * term list) list list -> (term * term list) list list -> Proof.context -> + ((string * term) list * term list list * term list list * (indexname * term option) list) * + Proof.context + val read_statement: (binding * string option * mixfix) list -> + (string * string list) list list -> (string * string list) list list -> Proof.context -> + ((string * term) list * term list list * term list list * (indexname * term option) list) * + Proof.context val print_syntax: Proof.context -> unit val print_abbrevs: bool -> Proof.context -> unit val pretty_term_bindings: Proof.context -> Pretty.T list @@ -1326,38 +1336,60 @@ end; -(* specification with parameters *) +(* structured statements *) local -fun prep_spec prep_var prep_propp raw_vars raw_propps ctxt = +fun export_binds ctxt' ctxt params binds = + let + val rhss = + map (the_list o Option.map (Logic.close_term params) o snd) binds + |> burrow (Variable.export_terms ctxt' ctxt) + |> map (try the_single); + in map fst binds ~~ rhss end; + +fun prep_stmt prep_var prep_propp raw_vars raw_propps ctxt = let - (*vars*) - val ((xs', vars), vars_ctxt) = ctxt - |> fold_map prep_var raw_vars - |-> (fn vars => add_fixes vars ##>> pair vars); + val (vars, vars_ctxt) = fold_map prep_var raw_vars ctxt; val xs = map (Variable.check_name o #1) vars; + val (xs', fixes_ctxt) = add_fixes vars vars_ctxt; - (*propps*) - val (propss, binds) = prep_propp vars_ctxt raw_propps; - val props = flat propss; + val (propss, binds) = prep_propp fixes_ctxt raw_propps; + val (ps, params_ctxt) = fixes_ctxt + |> (fold o fold) Variable.declare_term propss + |> fold_map inferred_param xs'; + val params = xs ~~ map Free ps; - (*params*) - val (ps, params_ctxt) = vars_ctxt - |> fold Variable.declare_term props - |> fold Variable.bind_term binds - |> fold_map inferred_param xs'; - val params = map Free ps; - val binds' = (map o apsnd) (fold_rev Term.dependent_lambda_name (xs ~~ params)) binds; val vars' = map2 (fn (b, _, mx) => fn (_, T) => (b, SOME T, mx)) vars ps; + val binds' = binds + |> map (apsnd SOME) + |> export_binds params_ctxt ctxt params + |> map (apsnd the); - val _ = Variable.warn_extra_tfrees vars_ctxt params_ctxt; - in (((vars', xs, params), propss, binds, binds'), params_ctxt) end; + val _ = Variable.warn_extra_tfrees fixes_ctxt params_ctxt; + in ((vars' ~~ params, propss, binds, binds'), params_ctxt) end; + +fun prep_statement prep_var prep_propp raw_fixes raw_assumes raw_shows ctxt = + let + val ((fixes, (assumes, shows), binds), ctxt') = ctxt + |> prep_stmt prep_var prep_propp raw_fixes (raw_assumes @ raw_shows) + |-> (fn (vars, propss, binds, _) => + fold Variable.bind_term binds #> + pair (map #2 vars, chop (length raw_assumes) propss, binds)); + val binds' = + (Auto_Bind.facts ctxt' (flat shows) @ + (case try List.last (flat shows) of + NONE => [] + | SOME prop => map (apsnd (SOME o Auto_Bind.abs_params prop)) binds)) + |> export_binds ctxt' ctxt fixes; + in ((fixes, assumes, shows, binds'), ctxt') end; in -val cert_spec = prep_spec cert_var cert_propp; -val read_spec = prep_spec read_var read_propp; +val cert_stmt = prep_stmt cert_var cert_propp; +val read_stmt = prep_stmt read_var read_propp; +val cert_statement = prep_statement cert_var cert_propp; +val read_statement = prep_statement read_var read_propp; end; diff -r 4a108f280dc2 -r 60406bf310f8 src/Pure/Pure.thy --- a/src/Pure/Pure.thy Fri Apr 22 17:22:29 2016 +0200 +++ b/src/Pure/Pure.thy Tue Apr 26 22:59:25 2016 +0200 @@ -758,8 +758,8 @@ val _ = Outer_Syntax.command @{command_keyword obtain} "generalized elimination" - (Parse.parbinding -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement - >> (fn ((x, y), z) => Toplevel.proof' (Obtain.obtain_cmd x y z))); + (Parse.parbinding -- Scan.optional (Parse.fixes --| Parse.where_) [] -- structured_statement + >> (fn ((a, b), (c, d, e)) => Toplevel.proof' (Obtain.obtain_cmd a b c d e))); val _ = Outer_Syntax.command @{command_keyword guess} "wild guessing (unstructured)" diff -r 4a108f280dc2 -r 60406bf310f8 src/Pure/logic.ML --- a/src/Pure/logic.ML Fri Apr 22 17:22:29 2016 +0200 +++ b/src/Pure/logic.ML Tue Apr 26 22:59:25 2016 +0200 @@ -26,6 +26,8 @@ val strip_prems: int * term list * term -> term list * term val count_prems: term -> int val nth_prem: int * term -> term + val close_term: (string * term) list -> term -> term + val close_prop: (string * term) list -> term list -> term -> term val true_prop: term val conjunction: term val mk_conjunction: term * term -> term @@ -147,7 +149,6 @@ end; - (** equality **) fun mk_equals (t, u) = @@ -204,6 +205,11 @@ fun strip_horn A = (strip_imp_prems A, strip_imp_concl A); +(* close *) + +val close_term = fold_rev Term.dependent_lambda_name; +fun close_prop xs As B = fold_rev dependent_all_name xs (list_implies (As, B)); + (** conjunction **)