# HG changeset patch # User paulson # Date 1589448393 -3600 # Node ID 0bbe0866b7e6f0e94bf0fdacf44e3d123a2dcb50 # Parent 5656ec95493cd94278f8652a3fbb70d3c3554a5d The Uniq quantifier for FOL too diff -r 5656ec95493c -r 0bbe0866b7e6 NEWS --- a/NEWS Wed May 13 13:00:03 2020 +0200 +++ b/NEWS Thu May 14 10:26:33 2020 +0100 @@ -42,6 +42,10 @@ * For the natural numbers, Sup{} = 0. +*** FOL *** + +* Added the "at most 1" quantifier, Uniq, as in HOL. + New in Isabelle2020 (April 2020) -------------------------------- diff -r 5656ec95493c -r 0bbe0866b7e6 src/FOL/IFOL.thy --- a/src/FOL/IFOL.thy Wed May 13 13:00:03 2020 +0200 +++ b/src/FOL/IFOL.thy Thu May 14 10:26:33 2020 +0100 @@ -5,7 +5,9 @@ section \Intuitionistic first-order logic\ theory IFOL -imports Pure + imports Pure +abbrevs "?<" = "\\<^sub>\\<^sub>1" + begin ML_file \~~/src/Tools/misc_legacy.ML\ @@ -87,6 +89,9 @@ definition iff (infixr \\\ 25) where \P \ Q \ (P \ Q) \ (Q \ P)\ +definition Uniq :: "('a \ o) \ o" + where \Uniq(P) \ (\x y. P(x) \ P(y) \ y = x)\ + definition Ex1 :: \('a \ o) \ o\ (binder \\!\ 10) where ex1_def: \\!x. P(x) \ \x. P(x) \ (\y. P(y) \ y = x)\ @@ -97,6 +102,13 @@ abbreviation not_equal :: \['a, 'a] \ o\ (infixl \\\ 50) where \x \ y \ \ (x = y)\ +syntax "_Uniq" :: "pttrn \ o \ o" ("(2\\<^sub>\\<^sub>1 _./ _)" [0, 10] 10) +translations "\\<^sub>\\<^sub>1x. P" \ "CONST Uniq (\x. P)" + +print_translation \ + [Syntax_Trans.preserve_binder_abs_tr' \<^const_syntax>\Uniq\ \<^syntax_const>\_Uniq\] +\ \ \to avoid eta-contraction of body\ + subsubsection \Old-style ASCII syntax\ @@ -126,38 +138,42 @@ assumes major: \P \ Q\ and r: \\P; Q\ \ R\ shows \R\ - apply (rule r) - apply (rule major [THEN conjunct1]) - apply (rule major [THEN conjunct2]) - done +proof (rule r) + show "P" + by (rule major [THEN conjunct1]) + show "Q" + by (rule major [THEN conjunct2]) +qed lemma impE: assumes major: \P \ Q\ and \P\ and r: \Q \ R\ shows \R\ - apply (rule r) - apply (rule major [THEN mp]) - apply (rule \P\) - done +proof (rule r) + show "Q" + by (rule mp [OF major \P\]) +qed lemma allE: assumes major: \\x. P(x)\ and r: \P(x) \ R\ shows \R\ - apply (rule r) - apply (rule major [THEN spec]) - done +proof (rule r) + show "P(x)" + by (rule major [THEN spec]) +qed text \Duplicates the quantifier; for use with \<^ML>\eresolve_tac\.\ lemma all_dupE: assumes major: \\x. P(x)\ and r: \\P(x); \x. P(x)\ \ R\ shows \R\ - apply (rule r) - apply (rule major [THEN spec]) - apply (rule major) - done +proof (rule r) + show "P(x)" + by (rule major [THEN spec]) +qed (rule major) + subsubsection \Negation rules, which translate between \\ P\ and \P \ False\\ @@ -215,18 +231,16 @@ subsection \If-and-only-if\ lemma iffI: \\P \ Q; Q \ P\ \ P \ Q\ - apply (unfold iff_def) - apply (rule conjI) - apply (erule impI) - apply (erule impI) - done + unfolding iff_def + by (rule conjI; erule impI) lemma iffE: assumes major: \P \ Q\ - and r: \P \ Q \ Q \ P \ R\ + and r: \\P \ Q; Q \ P\ \ R\ shows \R\ - apply (insert major, unfold iff_def) - apply (erule conjE) + using major + unfolding iff_def + apply (rule conjE) apply (erule r) apply assumption done @@ -235,13 +249,13 @@ subsubsection \Destruct rules for \\\ similar to Modus Ponens\ lemma iffD1: \\P \ Q; P\ \ Q\ - apply (unfold iff_def) + unfolding iff_def apply (erule conjunct1 [THEN mp]) apply assumption done lemma iffD2: \\P \ Q; Q\ \ P\ - apply (unfold iff_def) + unfolding iff_def apply (erule conjunct2 [THEN mp]) apply assumption done @@ -283,7 +297,7 @@ \ lemma ex1I: \P(a) \ (\x. P(x) \ x = a) \ \!x. P(x)\ - apply (unfold ex1_def) + unfolding ex1_def apply (assumption | rule exI conjI allI impI)+ done @@ -296,7 +310,7 @@ done lemma ex1E: \\! x. P(x) \ (\x. \P(x); \y. P(y) \ y = x\ \ R) \ R\ - apply (unfold ex1_def) + unfolding ex1_def apply (assumption | erule exE conjE)+ done @@ -424,77 +438,6 @@ done -subsubsection \Polymorphic congruence rules\ - -lemma subst_context: \a = b \ t(a) = t(b)\ - apply (erule ssubst) - apply (rule refl) - done - -lemma subst_context2: \\a = b; c = d\ \ t(a,c) = t(b,d)\ - apply (erule ssubst)+ - apply (rule refl) - done - -lemma subst_context3: \\a = b; c = d; e = f\ \ t(a,c,e) = t(b,d,f)\ - apply (erule ssubst)+ - apply (rule refl) - done - -text \ - Useful with \<^ML>\eresolve_tac\ for proving equalities from known - equalities. - - a = b - | | - c = d -\ -lemma box_equals: \\a = b; a = c; b = d\ \ c = d\ - apply (rule trans) - apply (rule trans) - apply (rule sym) - apply assumption+ - done - -text \Dual of \box_equals\: for proving equalities backwards.\ -lemma simp_equals: \\a = c; b = d; c = d\ \ a = b\ - apply (rule trans) - apply (rule trans) - apply assumption+ - apply (erule sym) - done - - -subsubsection \Congruence rules for predicate letters\ - -lemma pred1_cong: \a = a' \ P(a) \ P(a')\ - apply (rule iffI) - apply (erule (1) subst) - apply (erule (1) ssubst) - done - -lemma pred2_cong: \\a = a'; b = b'\ \ P(a,b) \ P(a',b')\ - apply (rule iffI) - apply (erule subst)+ - apply assumption - apply (erule ssubst)+ - apply assumption - done - -lemma pred3_cong: \\a = a'; b = b'; c = c'\ \ P(a,b,c) \ P(a',b',c')\ - apply (rule iffI) - apply (erule subst)+ - apply assumption - apply (erule ssubst)+ - apply assumption - done - -text \Special case for the equality predicate!\ -lemma eq_cong: \\a = a'; b = b'\ \ a = b \ a' = b'\ - apply (erule (1) pred2_cong) - done - - subsection \Simplifications of assumed implications\ text \ @@ -531,9 +474,7 @@ Still UNSAFE since ~P must be provable -- backtracking needed.\ lemma not_impE: \\ P \ S \ (P \ False) \ (S \ R) \ R\ apply (drule mp) - apply (rule notI) - apply assumption - apply assumption + apply (rule notI | assumption)+ done text \Simplifies the implication. UNSAFE.\ @@ -543,8 +484,7 @@ and r2: \\Q; P \ S\ \ P\ and r3: \S \ R\ shows \R\ - apply (assumption | rule iffI impI major [THEN mp] r1 r2 r3)+ - done + by (assumption | rule iffI impI major [THEN mp] r1 r2 r3)+ text \What if \(\x. \ \ P(x)) \ \ \ (\x. P(x))\ is an assumption? UNSAFE.\ @@ -553,8 +493,7 @@ and r1: \\x. P(x)\ and r2: \S \ R\ shows \R\ - apply (rule allI impI major [THEN mp] r1 r2)+ - done + by (rule allI impI major [THEN mp] r1 r2)+ text \ Unsafe: \\x. P(x)) \ S\ is equivalent @@ -563,8 +502,7 @@ assumes major: \(\x. P(x)) \ S\ and r: \P(x) \ S \ R\ shows \R\ - apply (assumption | rule exI impI major [THEN mp] r)+ - done + by (assumption | rule exI impI major [THEN mp] r)+ text \Courtesy of Krzysztof Grabczewski.\ lemma disj_imp_disj: \P \ Q \ (P \ R) \ (Q \ S) \ R \ S\ @@ -658,9 +596,50 @@ lemma eq_commute: \a = b \ b = a\ - apply (rule iffI) - apply (erule sym)+ - done + by iprover + + +subsection \Polymorphic congruence rules\ + +lemma subst_context: \a = b \ t(a) = t(b)\ + by iprover + +lemma subst_context2: \\a = b; c = d\ \ t(a,c) = t(b,d)\ + by iprover + +lemma subst_context3: \\a = b; c = d; e = f\ \ t(a,c,e) = t(b,d,f)\ + by iprover + +text \ + Useful with \<^ML>\eresolve_tac\ for proving equalities from known + equalities. + + a = b + | | + c = d +\ +lemma box_equals: \\a = b; a = c; b = d\ \ c = d\ + by iprover + +text \Dual of \box_equals\: for proving equalities backwards.\ +lemma simp_equals: \\a = c; b = d; c = d\ \ a = b\ + by iprover + + +subsubsection \Congruence rules for predicate letters\ + +lemma pred1_cong: \a = a' \ P(a) \ P(a')\ + by iprover + +lemma pred2_cong: \\a = a'; b = b'\ \ P(a,b) \ P(a',b')\ + by iprover + +lemma pred3_cong: \\a = a'; b = b'; c = c'\ \ P(a,b,c) \ P(a',b',c')\ + by iprover + +text \Special case for the equality predicate!\ +lemma eq_cong: \\a = a'; b = b'\ \ a = b \ a' = b'\ + by iprover subsection \Atomizing meta-level rules\ @@ -776,7 +755,7 @@ lemma LetI: assumes \\x. x = t \ P(u(x))\ shows \P(let x = t in u(x))\ - apply (unfold Let_def) + unfolding Let_def apply (rule refl [THEN assms]) done