Skip to content

Commit bb15963

Browse files
rozlyndmuenchnerkindl
authored andcommitted
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]>
1 parent 547e31d commit bb15963

File tree

6 files changed

+203
-152
lines changed

6 files changed

+203
-152
lines changed

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 ()));

isabelle/SMT.thy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
(* This material is now obsolete but included because it may still become relevant. *)
2+
13
header {* Normalization rules used in the SMT backend *}
24

35
theory SMT

library/BagsTheorems_proofs.tla

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ SeqToBag(seq) == [ x \in Range(seq) |-> Cardinality({i \in DOMAIN seq: seq[i]=x}
3838

3939

4040
(***************************************************************************)
41-
(* Equality of bags via DOMAIN and CopiesIn. *)
41+
(* Two bags are equal if they agree on all numbers of copies. *)
4242
(***************************************************************************)
4343
THEOREM BagEquality ==
4444
ASSUME NEW B1, NEW B2, IsABag(B1), IsABag(B2),
45-
DOMAIN B1 = DOMAIN B2,
4645
\A e : CopiesIn(e, B1) = CopiesIn(e, B2)
4746
PROVE B1 = B2
48-
BY DEF IsABag, CopiesIn, BagIn, BagToSet
47+
<1>1. \A e : e \in DOMAIN B1 <=> e \in DOMAIN B2
48+
BY DEF IsABag, CopiesIn, BagIn, BagToSet
49+
<1>2. DOMAIN B1 = DOMAIN B2
50+
BY <1>1
51+
<1>. QED BY <1>2 DEF IsABag, CopiesIn, BagIn, BagToSet
4952

5053
(***************************************************************************)
5154
(* \sqsubseteq is a PARTIAL ORDER relattion *)

library/SequenceTheorems_proofs.tla

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ THEOREM ConcatSimplifications ==
128128

129129
THEOREM SubSeqProperties ==
130130
ASSUME NEW S, NEW s \in Seq(S), NEW m \in Int, NEW n \in Int,
131-
1 <= m, m <= n, n <= Len(s),
131+
m > n \/ (1 <= m /\ n <= Len(s)),
132132
\A i \in m .. n : s[i] \in S
133133
PROVE /\ SubSeq(s,m,n) \in Seq(S)
134134
/\ Len(SubSeq(s,m,n)) = IF m<=n THEN n-m+1 ELSE 0
135135
/\ \A i \in 1 .. n-m+1 : SubSeq(s,m,n)[i] = s[m+i-1]
136136
OBVIOUS
137137

138138
THEOREM SubSeqEmpty ==
139-
ASSUME NEW s, NEW m \in Int, NEW n \in Int, n < m
139+
ASSUME NEW S, NEW s \in Seq(S), NEW m \in Int, NEW n \in Int, n < m
140140
PROVE SubSeq(s,m,n) = << >>
141141
OBVIOUS
142142

@@ -240,7 +240,7 @@ THEOREM HeadTailAppend ==
240240
ASSUME NEW S, NEW seq \in Seq(S), NEW elt
241241
PROVE /\ Head(Append(seq, elt)) = IF seq = <<>> THEN elt ELSE Head(seq)
242242
/\ Tail(Append(seq, elt)) = IF seq = <<>> THEN <<>> ELSE Append(Tail(seq), elt)
243-
OBVIOUS
243+
BY seq \in Seq(S \union {elt})
244244

245245
THEOREM AppendInjective ==
246246
ASSUME NEW S, NEW e \in S, NEW s \in Seq(S), NEW f \in S, NEW t \in Seq(S)
@@ -252,11 +252,18 @@ THEOREM SequenceEmptyOrAppend ==
252252
PROVE \E s \in Seq(S), elt \in S : seq = Append(s, elt)
253253
<1>. DEFINE front == [i \in 1 .. Len(seq)-1 |-> seq[i]]
254254
last == seq[Len(seq)]
255-
<1>. /\ front \in Seq(S)
256-
/\ last \in S
257-
/\ seq = Append(front, last)
255+
<1>1. /\ front \in Seq(S)
256+
/\ Len(front) = Len(seq)-1
257+
/\ last \in S
258+
OBVIOUS
259+
<1>2. Len(seq) = Len(Append(front, last))
260+
OBVIOUS
261+
<1>3. ASSUME NEW i \in 1 .. Len(seq)
262+
PROVE seq[i] = Append(front, last)[i]
258263
OBVIOUS
259-
<1>. QED BY Zenon
264+
<1>4. seq = Append(front, last)
265+
BY <1>2, <1>3
266+
<1>. QED BY <1>1, <1>4
260267

261268
(***************************************************************************)
262269
(* Inductive reasoning for sequences *)

0 commit comments

Comments
 (0)