Skip to content

Commit e26fb2b

Browse files
muenchnerkindlrozlyndkape1395
authored
Isabelle2025 (#217)
* upgrade to Isabelle 2025 and fix of library proofs Signed-off-by: Stephan Merz <[email protected]> * Fixed SubSeq axiom for case n < m (#216) Signed-off-by: rozlynd <[email protected]> * upgrade to Isabelle 2025 and fix library proofs Signed-off-by: Stephan Merz <[email protected]> * upgrade to Isabelle 2025 and fix of library proofs Signed-off-by: Stephan Merz <[email protected]> * Fixed SubSeq axiom for case n < m (#216) Signed-off-by: rozlynd <[email protected]> upgrade to Isabelle 2025 and fix library proofs Signed-off-by: Stephan Merz <[email protected]> * make CI check FunctionTheorems Signed-off-by: Stephan Merz <[email protected]> * second attempt to run FunctionTheorem proofs from the CI Signed-off-by: Stephan Merz <[email protected]> * more detailed proof of one step in FunctionTheorems_proofs Signed-off-by: Stephan Merz <[email protected]> * third attempt to fix the proof Signed-off-by: Stephan Merz <[email protected]> * (hopefully) fixed all library proofs Signed-off-by: Stephan Merz <[email protected]> * reformulating a proof Signed-off-by: Stephan Merz <[email protected]> * Decompose proofs so that they pass on my PC. (#220) Signed-off-by: Karolis Petrauskas <[email protected]> --------- Signed-off-by: Stephan Merz <[email protected]> Signed-off-by: rozlynd <[email protected]> Signed-off-by: Karolis Petrauskas <[email protected]> Co-authored-by: rozlynd <[email protected]> Co-authored-by: Karolis Petrauskas <[email protected]>
1 parent e3d5637 commit e26fb2b

26 files changed

+494
-366
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ jobs:
6464
- name: Check library proofs
6565
run: |
6666
find ./library -type f -iname "*_proofs.tla" \
67-
\( \
68-
-not -name "BagsTheorems_proofs.tla" \
69-
-and -not -name "FiniteSetTheorems_proofs.tla" \
70-
-and -not -name "FunctionTheorems_proofs.tla" \
71-
-and -not -name "NaturalsInduction_proofs.tla" \
72-
-and -not -name "SequenceTheorems_proofs.tla" \
73-
-and -not -name "SequencesExtTheorems_proofs.tla" \
74-
-and -not -name "WellFoundedInduction_proofs.tla" \
75-
\) \
7667
-print0 | xargs --null --max-args=1 --no-run-if-empty \
7768
./_build/tlapm/bin/tlapm --cleanfp
7869
- name: Run tests

deps/isabelle/dune.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
OS_TYPE=$(patsubst CYGWIN%,Cygwin,$(shell uname))
55
HOST_CPU=$(shell uname -m)
66

7-
ISABELLE_VSN=Isabelle2024
7+
ISABELLE_VSN=Isabelle2025
88

99
ifeq ($(OS_TYPE),Linux)
10-
ISABELLE_SHA256=603aaaf8abea36597af3b0651d2c162a86c0a0dd4420766f47e5724039639267
10+
ISABELLE_SHA256=3d1d66de371823fe31aa8ae66638f73575bac244f00b31aee1dcb62f38147c56
1111
ISABELLE_ARCHIVE=$(ISABELLE_VSN)_linux.tar.gz
1212
ISABELLE_ARCHIVE_TYPE=tgz
1313
ISABELLE_ARCHIVE_DIR=$(ISABELLE_VSN)
1414
FIND_EXEC=-executable
1515
endif
1616
ifeq ($(OS_TYPE),Darwin)
17-
ISABELLE_SHA256=22035f996f71ea1f03063f6f144195eb6a04974d4d916ed0772cd79569a28bc7
17+
ISABELLE_SHA256=ea5754c228857f5d9d3ae254ec9814797f2453ea290df20b2f6dcb2ef0e2e7f8
1818
ISABELLE_ARCHIVE=$(ISABELLE_VSN)_macos.tar.gz
1919
ISABELLE_ARCHIVE_TYPE=tgz
2020
ISABELLE_ARCHIVE_DIR=$(ISABELLE_VSN).app
@@ -64,12 +64,12 @@ ifeq ($(ISABELLE_ARCHIVE_TYPE),tgz)
6464
tar -xzf $<
6565
mv $(ISABELLE_ARCHIVE_DIR) $(ISABELLE_DIR)
6666
endif
67-
cd $(ISABELLE_DIR) && rm -rf ./contrib/e-3.0.03-1/src/lib/
67+
cd $(ISABELLE_DIR) && rm -rf ./contrib/e-3.1-1/src/lib/
6868
ifeq ($(OS_TYPE),Darwin)
69-
cd $(ISABELLE_DIR) && cd contrib/jdk-21.0.3/arm64-darwin/ \
69+
cd $(ISABELLE_DIR) && cd contrib/jdk-21.0.6/arm64-darwin/ \
7070
&& (find . -type link | xargs rm) \
7171
&& mv zulu-21.jdk/Contents/Home/* ./
72-
cd $(ISABELLE_DIR) && cd contrib/jdk-21.0.3/x86_64-darwin/ \
72+
cd $(ISABELLE_DIR) && cd contrib/jdk-21.0.6/x86_64-darwin/ \
7373
&& (find . -type link | xargs rm) \
7474
&& mv zulu-21.jdk/Contents/Home/* ./
7575
endif

isabelle/Constant.thy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/Constant.thy
22
Author: Stephan Merz, LORIA
3-
Copyright (C) 2008-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2008-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open> Main theory for constant-level Isabelle/\tlaplus{} \<close>

isabelle/FixedPoints.thy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/FixedPoints.thy
22
Author: Stephan Merz, Inria Nancy
3-
Copyright (C) 2008-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2008-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open>Fixed points for set-theoretical constructions\<close>

isabelle/Functions.thy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/Functions.thy
22
Author: Stephan Merz, Inria Nancy
3-
Copyright (C) 2008-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2008-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open> \tlaplus{} Functions \<close>

isabelle/IntegerArithmetic.thy

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/IntegerArithmetic.thy
22
Author: Stephan Merz, Inria Nancy
3-
Copyright (C) 2009-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2009-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open> Arithmetic (except division) for the integers \<close>
@@ -829,23 +829,8 @@ text \<open>
829829
From now on, we reduce the set @{text "Nat"} to the set of
830830
non-negative integers.
831831
\<close>
832-
lemma nat_iff_int_geq0' (*[simp]*) : "n \<in> Nat = (n \<in> Int \<and> 0 \<le> n)"
833-
by (auto simp: int_leq_def)
834-
835-
text \<open>
836-
We will use \<open>nat_is_int_geq0\<close> for simplification instead
837-
of \<open>nat_iff_int_geq0'\<close> for rewriting \<open>Nat\<close> to \<open>Int\<close> to
838-
handle also the cases where no \<open>Nat\<close> is used without
839-
the \<open>\<in>\<close> operator, e.g. in function sets.
840-
\<close>
841832
lemma nat_is_int_geq0 [simp] : "Nat = {x \<in> Int : 0 \<le> x}"
842-
proof
843-
show "\<And>x. x \<in> Nat \<Longrightarrow> x \<in> {x \<in> Int : 0 \<le> x}"
844-
using nat_iff_int_geq0' by auto
845-
next
846-
show "\<And>x. x \<in> {x \<in> Int : 0 \<le> x} \<Longrightarrow> x \<in> Nat"
847-
using nat_iff_int_geq0' by auto
848-
qed
833+
by (auto simp: int_leq_def)
849834

850835

851836
declare natIsInt [simp del]
@@ -1717,13 +1702,26 @@ lemma trans_leq_diff_nat2 [simp]:
17171702

17181703
lemma int_leq_iff_add:
17191704
assumes "i \<in> Int" and "j \<in> Int"
1720-
shows "(i \<le> j) = (\<exists>k \<in> Nat: j = i + k)" (is "?lhs = ?rhs")
1721-
using assms by (auto intro: int_leq_imp_add simp del: nat_is_int_geq0 simp add: nat_iff_int_geq0')
1705+
shows "(i \<le> j) = (\<exists>k \<in> Nat: j = i + k)"
1706+
using assms by (auto intro: int_leq_imp_add simp: nat_zero_leq simp del: nat_is_int_geq0)
17221707

17231708
lemma int_less_iff_succ_add:
17241709
assumes "i \<in> Int" and "j \<in> Int"
17251710
shows "(i < j) = (\<exists>k \<in> Nat: j = succ[i + k])" (is "?lhs = ?rhs")
1726-
using assms by (auto intro: int_less_imp_succ_add simp del: nat_is_int_geq0 simp add: nat_iff_int_geq0')
1711+
proof -
1712+
{
1713+
assume ?lhs then have ?rhs
1714+
using assms by (blast dest: int_less_imp_succ_add)
1715+
}
1716+
moreover
1717+
{
1718+
assume ?rhs
1719+
then obtain k where k: "k \<in> Int" "0 \<le> k" "j = succ[i+k]" by auto
1720+
with assms have ?lhs by auto
1721+
}
1722+
ultimately
1723+
show ?thesis by blast
1724+
qed
17271725

17281726
lemma leq_add_self1 [simp]:
17291727
assumes "i \<in> Int" and "j \<in> Int"

isabelle/IntegerDivision.thy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/IntegerDivision.thy
22
Author: Stephan Merz, Inria Nancy
3-
Copyright (C) 2009-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2009-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open> The division operators div and mod on the integers \<close>

isabelle/Integers.thy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/Integers.thy
22
Author: Stephan Merz, Inria Nancy
3-
Copyright (C) 2008-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2008-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open> The set of integer numbers \<close>

isabelle/NewSMT.thy

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ subsection \<open>Integers\<close>
107107
lemma PlusTyping: "x \<in> Int \<and> y \<in> Int \<Rightarrow> x+y \<in> Int"
108108
by simp
109109

110-
lemma UminusTyping: "x \<in> Int \<Rightarrow> -.x \<in> Int"
110+
lemma UminusTyping: "x \<in> Int \<Rightarrow> -x \<in> Int"
111111
by simp
112112

113113
lemma MinusTyping: "x \<in> Int \<and> y \<in> Int \<Rightarrow> x-y \<in> Int"
@@ -116,33 +116,14 @@ lemma MinusTyping: "x \<in> Int \<and> y \<in> Int \<Rightarrow> x-y \<in> Int"
116116
lemma TimesTyping: "x \<in> Int \<and> y \<in> Int \<Rightarrow> x*y \<in> Int"
117117
by simp
118118

119-
(* Isabelle currently provides integer division only for natural
120-
numbers, so we cannot prove the following.
121-
122-
lemma DivTyping: "x \<in> Int \<and> y \<in> Int \<and> y \<noteq> 0 \<Rightarrow> x \\div y \<in> Int"
123-
*)
119+
lemma DivTyping: "x \<in> Int \<and> y \<in> Int \<and> y > 0 \<Rightarrow> x div y \<in> Int"
120+
by simp
124121

125122
lemma NatDef: "x \<in> Nat \<Leftrightarrow> x \<in> Int \<and> 0 \<le> x"
126-
proof
127-
assume "x \<in> Nat"
128-
then show "x \<in> Int \<and> 0 \<le> x" by simp
129-
next
130-
assume "x \<in> Int \<and> 0 \<le> x"
131-
hence "x \<in> Int" "0 \<le> x" by blast+
132-
from \<open>x \<in> Int\<close> show "x \<in> Nat"
133-
proof (rule intCases)
134-
fix m
135-
assume "m \<in> Nat" "x = -.m"
136-
with \<open>0 \<le> x\<close> show ?thesis
137-
by (cases m) auto
138-
qed
139-
qed
140-
141-
(* Isabelle currently does not support integer intervals,
142-
so we cannot prove the following.
123+
by simp
143124

144125
lemma RangeDef: "x \<in> a .. b \<Leftrightarrow> x \<in> Int \<and> a \<le> x \<and> x \<le> b"
145-
*)
126+
by simp
146127

147128

148129
subsection \<open>Booleans\<close>
@@ -219,7 +200,16 @@ lemma SeqIntro:
219200
"\<forall>i : i \<in> DOMAIN s \<Leftrightarrow> i \<in> Nat \<and> 1 \<le> i \<and> i \<le> Len(s)"
220201
"\<forall>i \<in> Nat : 1 \<le> i \<and> i \<le> Len(s) \<Rightarrow> s[i] \<in> a"
221202
shows "s \<in> Seq(a)"
222-
using assms by auto
203+
proof
204+
from assms show "isASeq(s)" by auto
205+
next
206+
fix k
207+
assume "k \<in> 1 .. Len(s)"
208+
hence k: "k \<in> Int" "1 \<le> k" "k \<le> Len(s)" by auto
209+
with \<open>Len(s) \<in> Nat\<close> have "k \<in> Nat" by auto
210+
with \<open>\<forall>i \<in> Nat : 1 \<le> i \<and> i \<le> Len(s) \<Rightarrow> s[i] \<in> a\<close> k
211+
show "s[k] \<in> a" by blast
212+
qed
223213

224214
lemma SeqElim1:
225215
"s \<in> Seq(a) \<Rightarrow> isAFcn(s) \<and> Len(s) \<in> Nat \<and> DOMAIN s = 1 .. Len(s)"
@@ -258,14 +248,24 @@ text \<open>
258248
\<close>
259249
lemma AppendApp1:
260250
assumes "Len(s) \<in> Nat" (* missing from original formulation *)
261-
"i \<in> Nat" (* changed from Int because Isabelle doesn't support Int intervals *)
251+
"i \<in> Int"
262252
"1 \<le> i" "i \<le> Len(s)"
263253
shows "Append(s,x)[i] = s[i]"
264254
using assms unfolding Append_def by auto
265255

266256
lemma AppendApp2:
267-
"Len(s) \<in> Nat \<Rightarrow> Append(s,x)[Len(s)+1] = x"
268-
unfolding Append_def by auto
257+
assumes "Len(s) \<in> Nat"
258+
shows "Append(s,x)[Len(s)+1] = x"
259+
proof -
260+
from assms have "Len(s)+1 = succ[Len(s)]"
261+
by simp
262+
moreover
263+
from assms have "Len(s)+1 \<in> DOMAIN Append(s,x)"
264+
by (auto simp: Append_def)
265+
ultimately
266+
show ?thesis
267+
using assms by (auto simp: Append_def)
268+
qed
269269

270270
text \<open>
271271
Isabelle/TLA+ doesn't know about the remaining operations on sequences.

isabelle/PredicateLogic.thy

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* Title: TLA+/PredicateLogic.thy
22
Author: Stephan Merz, Inria Nancy
3-
Copyright (C) 2008-2024 INRIA and Microsoft Corporation
3+
Copyright (C) 2008-2025 INRIA and Microsoft Corporation
44
License: BSD
5-
Version: Isabelle2024
5+
Version: Isabelle2025
66
*)
77

88
section \<open>First-Order Logic for TLA+\<close>
@@ -1355,8 +1355,6 @@ text \<open>
13551355
development of FOL, we introduce a set of ``shadow connectives''
13561356
that will only be used for this purpose.
13571357
\<close>
1358-
1359-
(* lemmas cases = case_split [case_names True False] *)
13601358
context
13611359
begin
13621360

@@ -1425,37 +1423,33 @@ ML \<open>
14251423
)
14261424
\<close>
14271425

1426+
simproc_setup passive swap_cases_false ("cases_false \<Longrightarrow> PROP P \<Longrightarrow> PROP Q") =
1427+
\<open>fn _ => fn _ => fn ct =>
1428+
(case Thm.term_of ct of
1429+
_ $ (P as _ $ \<^Const_>\<open>cases_false\<close>) $ (_ $ Q $ _) =>
1430+
if P <> Q then SOME Drule.swap_prems_eq else NONE
1431+
| _ => NONE)\<close>
1432+
1433+
simproc_setup passive cases_equal_conj_curry ("cases_conj(P, Q) \<Longrightarrow> PROP R") =
1434+
\<open>fn _ => fn _ => fn ct =>
1435+
(case Thm.term_of ct of
1436+
_ $ (_ $ P) $ _ =>
1437+
let
1438+
fun is_conj \<^Const_>\<open>cases_conj for P Q\<close> = is_conj P andalso is_conj Q
1439+
| is_conj \<^Const_>\<open>cases_equal\<close> = true
1440+
| is_conj \<^Const_>\<open>cases_true\<close> = true
1441+
| is_conj \<^Const_>\<open>cases_false\<close> = true
1442+
| is_conj _ = false
1443+
in if is_conj P then SOME @{thm cases_conj_curry} else NONE end
1444+
| _ => NONE)\<close>
1445+
14281446
declaration \<open>
1429-
fn _ => Induct.map_simpset (fn ss => ss
1430-
addsimprocs
1431-
[Simplifier.make_simproc @{context}
1432-
{name = "swap_cases_false",
1433-
lhss = [@{term "cases_false \<Longrightarrow> PROP P \<Longrightarrow> PROP Q"}],
1434-
proc = fn _ => fn _ => fn ct =>
1435-
(case Thm.term_of ct of
1436-
_ $ (P as _ $ @{const cases_false}) $ (_ $ Q $ _) =>
1437-
if P <> Q then SOME Drule.swap_prems_eq else NONE
1438-
| _ => NONE),
1439-
identifier = []},
1440-
Simplifier.make_simproc @{context}
1441-
{name = "cases_equal_conj_curry",
1442-
lhss = [@{term "cases_conj(P, Q) \<Longrightarrow> PROP R"}],
1443-
proc = fn _ => fn _ => fn ct =>
1444-
(case Thm.term_of ct of
1445-
_ $ (_ $ P) $ _ =>
1446-
let
1447-
fun is_conj (@{const cases_conj} $ P $ Q) =
1448-
is_conj P andalso is_conj Q
1449-
| is_conj (Const (@{const_name cases_equal}, _) $ _ $ _) = true
1450-
| is_conj @{const cases_true} = true
1451-
| is_conj @{const cases_false} = true
1452-
| is_conj _ = false
1453-
in if is_conj P then SOME @{thm cases_conj_curry} else NONE end
1454-
| _ => NONE),
1455-
identifier = []}]
1456-
|> Simplifier.set_mksimps (fn ctxt =>
1447+
K (Induct.map_simpset
1448+
(Simplifier.add_proc \<^simproc>\<open>swap_cases_false\<close> #>
1449+
Simplifier.add_proc \<^simproc>\<open>cases_equal_conj_curry\<close> #>
1450+
Simplifier.set_mksimps (fn ctxt =>
14571451
Simpdata.mksimps Simpdata.mksimps_pairs ctxt #>
1458-
map (rewrite_rule ctxt (map Thm.symmetric @{thms cases_rulify_fallback}))))
1452+
map (rewrite_rule ctxt (map Thm.symmetric @{thms cases_rulify_fallback})))))
14591453
\<close>
14601454

14611455
text \<open> Pre-simplification of induction and cases rules \<close>
@@ -1523,7 +1517,8 @@ subsection \<open> Propositional simplification \<close>
15231517
subsubsection \<open> Conversion to Boolean values \<close>
15241518

15251519
text \<open>
1526-
Because \tlaplus{} is untyped, equivalence is different from equality,
1520+
Because \tlaplus{} does not distinguish between terms and formulas,
1521+
equivalence is different from equality,
15271522
and one has to be careful about stating the laws of propositional
15281523
logic. For example, although the equivalence @{text "(TRUE \<and> A) \<Leftrightarrow> A"}
15291524
is valid, we cannot state the law @{text "(TRUE \<and> A) = A"}
@@ -1945,7 +1940,6 @@ struct
19451940
(
19461941
type T = ((term -> bool) * stamp) list;
19471942
val empty = [];
1948-
val extend = I;
19491943
fun merge data : T = Library.merge (eq_snd (op =)) data;
19501944
);
19511945
fun add m = Data.map (cons (m, stamp ()));

0 commit comments

Comments
 (0)