diff --git a/metadata/metadata b/metadata/metadata --- a/metadata/metadata +++ b/metadata/metadata @@ -1,10909 +1,10962 @@ [Arith_Prog_Rel_Primes] title = Arithmetic progressions and relative primes author = José Manuel Rodríguez Caballero topic = Mathematics/Number theory date = 2020-02-01 notify = jose.manuel.rodriguez.caballero@ut.ee abstract = This article provides a formalization of the solution obtained by the author of the Problem “ARITHMETIC PROGRESSIONS” from the Putnam exam problems of 2002. The statement of the problem is as follows: For which integers n > 1 does the set of positive integers less than and relatively prime to n constitute an arithmetic progression? [Banach_Steinhaus] title = Banach-Steinhaus Theorem author = Dominique Unruh , Jose Manuel Rodriguez Caballero topic = Mathematics/Analysis date = 2020-05-02 notify = jose.manuel.rodriguez.caballero@ut.ee, unruh@ut.ee abstract = We formalize in Isabelle/HOL a result due to S. Banach and H. Steinhaus known as the Banach-Steinhaus theorem or Uniform boundedness principle: a pointwise-bounded family of continuous linear operators from a Banach space to a normed space is uniformly bounded. Our approach is an adaptation to Isabelle/HOL of a proof due to A. Sokal. [Complex_Geometry] title = Complex Geometry author = Filip Marić , Danijela Simić topic = Mathematics/Geometry date = 2019-12-16 notify = danijela@matf.bg.ac.rs, filip@matf.bg.ac.rs, boutry@unistra.fr abstract = A formalization of geometry of complex numbers is presented. Fundamental objects that are investigated are the complex plane extended by a single infinite point, its objects (points, lines and circles), and groups of transformations that act on them (e.g., inversions and Möbius transformations). Most objects are defined algebraically, but correspondence with classical geometric definitions is shown. [Poincare_Disc] title = Poincaré Disc Model author = Danijela Simić , Filip Marić , Pierre Boutry topic = Mathematics/Geometry date = 2019-12-16 notify = danijela@matf.bg.ac.rs, filip@matf.bg.ac.rs, boutry@unistra.fr abstract = We describe formalization of the Poincaré disc model of hyperbolic geometry within the Isabelle/HOL proof assistant. The model is defined within the extended complex plane (one dimensional complex projectives space ℂP1), formalized in the AFP entry “Complex Geometry”. Points, lines, congruence of pairs of points, betweenness of triples of points, circles, and isometries are defined within the model. It is shown that the model satisfies all Tarski's axioms except the Euclid's axiom. It is shown that it satisfies its negation and the limiting parallels axiom (which proves it to be a model of hyperbolic geometry). [Fourier] title = Fourier Series author = Lawrence C Paulson topic = Mathematics/Analysis date = 2019-09-06 notify = lp15@cam.ac.uk abstract = This development formalises the square integrable functions over the reals and the basics of Fourier series. It culminates with a proof that every well-behaved periodic function can be approximated by a Fourier series. The material is ported from HOL Light: https://github.com/jrh13/hol-light/blob/master/100/fourier.ml [Generic_Deriving] title = Deriving generic class instances for datatypes author = Jonas Rädle , Lars Hupel topic = Computer science/Data structures date = 2018-11-06 notify = jonas.raedle@gmail.com abstract =

We provide a framework for automatically deriving instances for generic type classes. Our approach is inspired by Haskell's generic-deriving package and Scala's shapeless library. In addition to generating the code for type class functions, we also attempt to automatically prove type class laws for these instances. As of now, however, some manual proofs are still required for recursive datatypes.

Note: There are already articles in the AFP that provide automatic instantiation for a number of classes. Concretely, Deriving allows the automatic instantiation of comparators, linear orders, equality, and hashing. Show instantiates a Haskell-style show class.

Our approach works for arbitrary classes (with some Isabelle/HOL overhead for each class), but a smaller set of datatypes.

[Partial_Order_Reduction] title = Partial Order Reduction author = Julian Brunner topic = Computer science/Automata and formal languages date = 2018-06-05 notify = brunnerj@in.tum.de abstract = This entry provides a formalization of the abstract theory of ample set partial order reduction. The formalization includes transition systems with actions, trace theory, as well as basics on finite, infinite, and lazy sequences. We also provide a basic framework for static analysis on concurrent systems with respect to the ample set condition. [CakeML] title = CakeML author = Lars Hupel , Yu Zhang <> contributors = Johannes Åman Pohjola <> topic = Computer science/Programming languages/Language definitions date = 2018-03-12 notify = hupel@in.tum.de abstract = CakeML is a functional programming language with a proven-correct compiler and runtime system. This entry contains an unofficial version of the CakeML semantics that has been exported from the Lem specifications to Isabelle. Additionally, there are some hand-written theory files that adapt the exported code to Isabelle and port proofs from the HOL4 formalization, e.g. termination and equivalence proofs. [CakeML_Codegen] title = A Verified Code Generator from Isabelle/HOL to CakeML author = Lars Hupel topic = Computer science/Programming languages/Compiling, Logic/Rewriting date = 2019-07-08 notify = lars@hupel.info abstract = This entry contains the formalization that accompanies my PhD thesis (see https://lars.hupel.info/research/codegen/). I develop a verified compilation toolchain from executable specifications in Isabelle/HOL to CakeML abstract syntax trees. This improves over the state-of-the-art in Isabelle by providing a trustworthy procedure for code generation. [DiscretePricing] title = Pricing in discrete financial models author = Mnacho Echenim topic = Mathematics/Probability theory, Mathematics/Games and economics date = 2018-07-16 notify = mnacho.echenim@univ-grenoble-alpes.fr abstract = We have formalized the computation of fair prices for derivative products in discrete financial models. As an application, we derive a way to compute fair prices of derivative products in the Cox-Ross-Rubinstein model of a financial market, thus completing the work that was presented in this paper. extra-history = Change history: [2019-05-12]: Renamed discr_mkt predicate to stk_strict_subs and got rid of predicate A for a more natural definition of the type discrete_market; renamed basic quantity processes for coherent notation; renamed value_process into val_process and closing_value_process to cls_val_process; relaxed hypothesis of lemma CRR_market_fair_price. Added functions to price some basic options. (revision 0b813a1a833f)
[Pell] title = Pell's Equation author = Manuel Eberl topic = Mathematics/Number theory date = 2018-06-23 notify = eberlm@in.tum.de abstract =

This article gives the basic theory of Pell's equation x2 = 1 + Dy2, where D ∈ ℕ is a parameter and x, y are integer variables.

The main result that is proven is the following: If D is not a perfect square, then there exists a fundamental solution (x0, y0) that is not the trivial solution (1, 0) and which generates all other solutions (x, y) in the sense that there exists some n ∈ ℕ such that |x| + |y| √D = (x0 + y0 √D)n. This also implies that the set of solutions is infinite, and it gives us an explicit and executable characterisation of all the solutions.

Based on this, simple executable algorithms for computing the fundamental solution and the infinite sequence of all non-negative solutions are also provided.

[WebAssembly] title = WebAssembly author = Conrad Watt topic = Computer science/Programming languages/Language definitions date = 2018-04-29 notify = caw77@cam.ac.uk abstract = This is a mechanised specification of the WebAssembly language, drawn mainly from the previously published paper formalisation of Haas et al. Also included is a full proof of soundness of the type system, together with a verified type checker and interpreter. We include only a partial procedure for the extraction of the type checker and interpreter here. For more details, please see our paper in CPP 2018. [Knuth_Morris_Pratt] title = The string search algorithm by Knuth, Morris and Pratt author = Fabian Hellauer , Peter Lammich topic = Computer science/Algorithms date = 2017-12-18 notify = hellauer@in.tum.de, lammich@in.tum.de abstract = The Knuth-Morris-Pratt algorithm is often used to show that the problem of finding a string s in a text t can be solved deterministically in O(|s| + |t|) time. We use the Isabelle Refinement Framework to formulate and verify the algorithm. Via refinement, we apply some optimisations and finally use the Sepref tool to obtain executable code in Imperative/HOL. [Minkowskis_Theorem] title = Minkowski's Theorem author = Manuel Eberl topic = Mathematics/Geometry, Mathematics/Number theory date = 2017-07-13 notify = eberlm@in.tum.de abstract =

Minkowski's theorem relates a subset of ℝn, the Lebesgue measure, and the integer lattice ℤn: It states that any convex subset of ℝn with volume greater than 2n contains at least one lattice point from ℤn\{0}, i. e. a non-zero point with integer coefficients.

A related theorem which directly implies this is Blichfeldt's theorem, which states that any subset of ℝn with a volume greater than 1 contains two different points whose difference vector has integer components.

The entry contains a proof of both theorems.

[Name_Carrying_Type_Inference] title = Verified Metatheory and Type Inference for a Name-Carrying Simply-Typed Lambda Calculus author = Michael Rawson topic = Computer science/Programming languages/Type systems date = 2017-07-09 notify = mr644@cam.ac.uk, michaelrawson76@gmail.com abstract = I formalise a Church-style simply-typed \(\lambda\)-calculus, extended with pairs, a unit value, and projection functions, and show some metatheory of the calculus, such as the subject reduction property. Particular attention is paid to the treatment of names in the calculus. A nominal style of binding is used, but I use a manual approach over Nominal Isabelle in order to extract an executable type inference algorithm. More information can be found in my undergraduate dissertation. [Propositional_Proof_Systems] title = Propositional Proof Systems author = Julius Michaelis , Tobias Nipkow topic = Logic/Proof theory date = 2017-06-21 notify = maintainafpppt@liftm.de abstract = We formalize a range of proof systems for classical propositional logic (sequent calculus, natural deduction, Hilbert systems, resolution) and prove the most important meta-theoretic results about semantics and proofs: compactness, soundness, completeness, translations between proof systems, cut-elimination, interpolation and model existence. [Optics] title = Optics author = Simon Foster , Frank Zeyda topic = Computer science/Functional programming, Mathematics/Algebra date = 2017-05-25 notify = simon.foster@york.ac.uk abstract = Lenses provide an abstract interface for manipulating data types through spatially-separated views. They are defined abstractly in terms of two functions, get, the return a value from the source type, and put that updates the value. We mechanise the underlying theory of lenses, in terms of an algebraic hierarchy of lenses, including well-behaved and very well-behaved lenses, each lens class being characterised by a set of lens laws. We also mechanise a lens algebra in Isabelle that enables their composition and comparison, so as to allow construction of complex lenses. This is accompanied by a large library of algebraic laws. Moreover we also show how the lens classes can be applied by instantiating them with a number of Isabelle data types. extra-history = Change history: [2020-03-02]: Added partial bijective and symmetric lenses. Improved alphabet command generating additional lenses and results. Several additional lens relations, including observational equivalence. Additional theorems throughout. Adaptations for Isabelle 2020. (revision 44e2e5c) [2021-01-27] Addition of new theorems throughout, particularly for prisms. New "chantype" command allows the definition of an algebraic datatype with generated prisms. New "dataspace" command allows the definition of a local-based state space, including lenses and prisms. Addition of various examples for the above. (revision 89cf045a) [Game_Based_Crypto] title = Game-based cryptography in HOL author = Andreas Lochbihler , S. Reza Sefidgar <>, Bhargav Bhatt topic = Computer science/Security/Cryptography date = 2017-05-05 notify = mail@andreas-lochbihler.de abstract =

In this AFP entry, we show how to specify game-based cryptographic security notions and formally prove secure several cryptographic constructions from the literature using the CryptHOL framework. Among others, we formalise the notions of a random oracle, a pseudo-random function, an unpredictable function, and of encryption schemes that are indistinguishable under chosen plaintext and/or ciphertext attacks. We prove the random-permutation/random-function switching lemma, security of the Elgamal and hashed Elgamal public-key encryption scheme and correctness and security of several constructions with pseudo-random functions.

Our proofs follow the game-hopping style advocated by Shoup and Bellare and Rogaway, from which most of the examples have been taken. We generalise some of their results such that they can be reused in other proofs. Thanks to CryptHOL's integration with Isabelle's parametricity infrastructure, many simple hops are easily justified using the theory of representation independence.

extra-history = Change history: [2018-09-28]: added the CryptHOL tutorial for game-based cryptography (revision 489a395764ae) [Multi_Party_Computation] title = Multi-Party Computation author = David Aspinall , David Butler topic = Computer science/Security date = 2019-05-09 notify = dbutler@turing.ac.uk abstract = We use CryptHOL to consider Multi-Party Computation (MPC) protocols. MPC was first considered by Yao in 1983 and recent advances in efficiency and an increased demand mean it is now deployed in the real world. Security is considered using the real/ideal world paradigm. We first define security in the semi-honest security setting where parties are assumed not to deviate from the protocol transcript. In this setting we prove multiple Oblivious Transfer (OT) protocols secure and then show security for the gates of the GMW protocol. We then define malicious security, this is a stronger notion of security where parties are assumed to be fully corrupted by an adversary. In this setting we again consider OT, as it is a fundamental building block of almost all MPC protocols. [Sigma_Commit_Crypto] title = Sigma Protocols and Commitment Schemes author = David Butler , Andreas Lochbihler topic = Computer science/Security/Cryptography date = 2019-10-07 notify = dbutler@turing.ac.uk abstract = We use CryptHOL to formalise commitment schemes and Sigma-protocols. Both are widely used fundamental two party cryptographic primitives. Security for commitment schemes is considered using game-based definitions whereas the security of Sigma-protocols is considered using both the game-based and simulation-based security paradigms. In this work, we first define security for both primitives and then prove secure multiple case studies: the Schnorr, Chaum-Pedersen and Okamoto Sigma-protocols as well as a construction that allows for compound (AND and OR statements) Sigma-protocols and the Pedersen and Rivest commitment schemes. We also prove that commitment schemes can be constructed from Sigma-protocols. We formalise this proof at an abstract level, only assuming the existence of a Sigma-protocol; consequently, the instantiations of this result for the concrete Sigma-protocols we consider come for free. [CryptHOL] title = CryptHOL author = Andreas Lochbihler topic = Computer science/Security/Cryptography, Computer science/Functional programming, Mathematics/Probability theory date = 2017-05-05 notify = mail@andreas-lochbihler.de abstract =

CryptHOL provides a framework for formalising cryptographic arguments in Isabelle/HOL. It shallowly embeds a probabilistic functional programming language in higher order logic. The language features monadic sequencing, recursion, random sampling, failures and failure handling, and black-box access to oracles. Oracles are probabilistic functions which maintain hidden state between different invocations. All operators are defined in the new semantic domain of generative probabilistic values, a codatatype. We derive proof rules for the operators and establish a connection with the theory of relational parametricity. Thus, the resuting proofs are trustworthy and comprehensible, and the framework is extensible and widely applicable.

The framework is used in the accompanying AFP entry "Game-based Cryptography in HOL". There, we show-case our framework by formalizing different game-based proofs from the literature. This formalisation continues the work described in the author's ESOP 2016 paper.

[Constructive_Cryptography] title = Constructive Cryptography in HOL author = Andreas Lochbihler , S. Reza Sefidgar<> topic = Computer science/Security/Cryptography, Mathematics/Probability theory date = 2018-12-17 notify = mail@andreas-lochbihler.de, reza.sefidgar@inf.ethz.ch abstract = Inspired by Abstract Cryptography, we extend CryptHOL, a framework for formalizing game-based proofs, with an abstract model of Random Systems and provide proof rules about their composition and equality. This foundation facilitates the formalization of Constructive Cryptography proofs, where the security of a cryptographic scheme is realized as a special form of construction in which a complex random system is built from simpler ones. This is a first step towards a fully-featured compositional framework, similar to Universal Composability framework, that supports formalization of simulation-based proofs. [Probabilistic_While] title = Probabilistic while loop author = Andreas Lochbihler topic = Computer science/Functional programming, Mathematics/Probability theory, Computer science/Algorithms date = 2017-05-05 notify = mail@andreas-lochbihler.de abstract = This AFP entry defines a probabilistic while operator based on sub-probability mass functions and formalises zero-one laws and variant rules for probabilistic loop termination. As applications, we implement probabilistic algorithms for the Bernoulli, geometric and arbitrary uniform distributions that only use fair coin flips, and prove them correct and terminating with probability 1. extra-history = Change history: [2018-02-02]: Added a proof that probabilistic conditioning can be implemented by repeated sampling. (revision 305867c4e911)
[Monad_Normalisation] title = Monad normalisation author = Joshua Schneider <>, Manuel Eberl , Andreas Lochbihler topic = Tools, Computer science/Functional programming, Logic/Rewriting date = 2017-05-05 notify = mail@andreas-lochbihler.de abstract = The usual monad laws can directly be used as rewrite rules for Isabelle’s simplifier to normalise monadic HOL terms and decide equivalences. In a commutative monad, however, the commutativity law is a higher-order permutative rewrite rule that makes the simplifier loop. This AFP entry implements a simproc that normalises monadic expressions in commutative monads using ordered rewriting. The simproc can also permute computations across control operators like if and case. [Monomorphic_Monad] title = Effect polymorphism in higher-order logic author = Andreas Lochbihler topic = Computer science/Functional programming date = 2017-05-05 notify = mail@andreas-lochbihler.de abstract = The notion of a monad cannot be expressed within higher-order logic (HOL) due to type system restrictions. We show that if a monad is used with values of only one type, this notion can be formalised in HOL. Based on this idea, we develop a library of effect specifications and implementations of monads and monad transformers. Hence, we can abstract over the concrete monad in HOL definitions and thus use the same definition for different (combinations of) effects. We illustrate the usefulness of effect polymorphism with a monadic interpreter for a simple language. extra-history = Change history: [2018-02-15]: added further specifications and implementations of non-determinism; more examples (revision bc5399eea78e)
[Constructor_Funs] title = Constructor Functions author = Lars Hupel topic = Tools date = 2017-04-19 notify = hupel@in.tum.de abstract = Isabelle's code generator performs various adaptations for target languages. Among others, constructor applications have to be fully saturated. That means that for constructor calls occuring as arguments to higher-order functions, synthetic lambdas have to be inserted. This entry provides tooling to avoid this construction altogether by introducing constructor functions. [Lazy_Case] title = Lazifying case constants author = Lars Hupel topic = Tools date = 2017-04-18 notify = hupel@in.tum.de abstract = Isabelle's code generator performs various adaptations for target languages. Among others, case statements are printed as match expressions. Internally, this is a sophisticated procedure, because in HOL, case statements are represented as nested calls to the case combinators as generated by the datatype package. Furthermore, the procedure relies on laziness of match expressions in the target language, i.e., that branches guarded by patterns that fail to match are not evaluated. Similarly, if-then-else is printed to the corresponding construct in the target language. This entry provides tooling to replace these special cases in the code generator by ignoring these target language features, instead printing case expressions and if-then-else as functions. [Dict_Construction] title = Dictionary Construction author = Lars Hupel topic = Tools date = 2017-05-24 notify = hupel@in.tum.de abstract = Isabelle's code generator natively supports type classes. For targets that do not have language support for classes and instances, it performs the well-known dictionary translation, as described by Haftmann and Nipkow. This translation happens outside the logic, i.e., there is no guarantee that it is correct, besides the pen-and-paper proof. This work implements a certified dictionary translation that produces new class-free constants and derives equality theorems. [Higher_Order_Terms] title = An Algebra for Higher-Order Terms author = Lars Hupel contributors = Yu Zhang <> topic = Computer science/Programming languages/Lambda calculi date = 2019-01-15 notify = lars@hupel.info abstract = In this formalization, I introduce a higher-order term algebra, generalizing the notions of free variables, matching, and substitution. The need arose from the work on a verified compiler from Isabelle to CakeML. Terms can be thought of as consisting of a generic (free variables, constants, application) and a specific part. As example applications, this entry provides instantiations for de-Bruijn terms, terms with named variables, and Blanchette’s λ-free higher-order terms. Furthermore, I implement translation functions between de-Bruijn terms and named terms and prove their correctness. [Subresultants] title = Subresultants author = Sebastiaan Joosten , René Thiemann , Akihisa Yamada topic = Mathematics/Algebra date = 2017-04-06 notify = rene.thiemann@uibk.ac.at abstract = We formalize the theory of subresultants and the subresultant polynomial remainder sequence as described by Brown and Traub. As a result, we obtain efficient certified algorithms for computing the resultant and the greatest common divisor of polynomials. [Comparison_Sort_Lower_Bound] title = Lower bound on comparison-based sorting algorithms author = Manuel Eberl topic = Computer science/Algorithms date = 2017-03-15 notify = eberlm@in.tum.de abstract =

This article contains a formal proof of the well-known fact that number of comparisons that a comparison-based sorting algorithm needs to perform to sort a list of length n is at least log2 (n!) in the worst case, i. e. Ω(n log n).

For this purpose, a shallow embedding for comparison-based sorting algorithms is defined: a sorting algorithm is a recursive datatype containing either a HOL function or a query of a comparison oracle with a continuation containing the remaining computation. This makes it possible to force the algorithm to use only comparisons and to track the number of comparisons made.

[Quick_Sort_Cost] title = The number of comparisons in QuickSort author = Manuel Eberl topic = Computer science/Algorithms date = 2017-03-15 notify = eberlm@in.tum.de abstract =

We give a formal proof of the well-known results about the number of comparisons performed by two variants of QuickSort: first, the expected number of comparisons of randomised QuickSort (i. e. QuickSort with random pivot choice) is 2 (n+1) Hn - 4 n, which is asymptotically equivalent to 2 n ln n; second, the number of comparisons performed by the classic non-randomised QuickSort has the same distribution in the average case as the randomised one.

[Random_BSTs] title = Expected Shape of Random Binary Search Trees author = Manuel Eberl topic = Computer science/Data structures date = 2017-04-04 notify = eberlm@in.tum.de abstract =

This entry contains proofs for the textbook results about the distributions of the height and internal path length of random binary search trees (BSTs), i. e. BSTs that are formed by taking an empty BST and inserting elements from a fixed set in random order.

In particular, we prove a logarithmic upper bound on the expected height and the Θ(n log n) closed-form solution for the expected internal path length in terms of the harmonic numbers. We also show how the internal path length relates to the average-case cost of a lookup in a BST.

[Randomised_BSTs] title = Randomised Binary Search Trees author = Manuel Eberl topic = Computer science/Data structures date = 2018-10-19 notify = eberlm@in.tum.de abstract =

This work is a formalisation of the Randomised Binary Search Trees introduced by Martínez and Roura, including definitions and correctness proofs.

Like randomised treaps, they are a probabilistic data structure that behaves exactly as if elements were inserted into a non-balancing BST in random order. However, unlike treaps, they only use discrete probability distributions, but their use of randomness is more complicated.

[E_Transcendental] title = The Transcendence of e author = Manuel Eberl topic = Mathematics/Analysis, Mathematics/Number theory date = 2017-01-12 notify = eberlm@in.tum.de abstract =

This work contains a proof that Euler's number e is transcendental. The proof follows the standard approach of assuming that e is algebraic and then using a specific integer polynomial to derive two inconsistent bounds, leading to a contradiction.

This kind of approach can be found in many different sources; this formalisation mostly follows a PlanetMath article by Roger Lipsett.

[Pi_Transcendental] title = The Transcendence of π author = Manuel Eberl topic = Mathematics/Number theory date = 2018-09-28 notify = eberlm@in.tum.de abstract =

This entry shows the transcendence of π based on the classic proof using the fundamental theorem of symmetric polynomials first given by von Lindemann in 1882, but the formalisation mostly follows the version by Niven. The proof reuses much of the machinery developed in the AFP entry on the transcendence of e.

[Hermite_Lindemann] title = The Hermite–Lindemann–Weierstraß Transcendence Theorem author = Manuel Eberl topic = Mathematics/Number theory date = 2021-03-03 notify = eberlm@in.tum.de abstract =

This article provides a formalisation of the Hermite-Lindemann-Weierstraß Theorem (also known as simply Hermite-Lindemann or Lindemann-Weierstraß). This theorem is one of the crowning achievements of 19th century number theory.

The theorem states that if $\alpha_1, \ldots, \alpha_n\in\mathbb{C}$ are algebraic numbers that are linearly independent over $\mathbb{Z}$, then $e^{\alpha_1},\ldots,e^{\alpha_n}$ are algebraically independent over $\mathbb{Q}$.

Like the previous formalisation in Coq by Bernard, I proceeded by formalising Baker's version of the theorem and proof and then deriving the original one from that. Baker's version states that for any algebraic numbers $\beta_1, \ldots, \beta_n\in\mathbb{C}$ and distinct algebraic numbers $\alpha_i, \ldots, \alpha_n\in\mathbb{C}$, we have $\beta_1 e^{\alpha_1} + \ldots + \beta_n e^{\alpha_n} = 0$ if and only if all the $\beta_i$ are zero.

This has a number of direct corollaries, e.g.:

  • $e$ and $\pi$ are transcendental
  • $e^z$, $\sin z$, $\tan z$, etc. are transcendental for algebraic $z\in\mathbb{C}\setminus\{0\}$
  • $\ln z$ is transcendental for algebraic $z\in\mathbb{C}\setminus\{0, 1\}$
[DFS_Framework] title = A Framework for Verifying Depth-First Search Algorithms author = Peter Lammich , René Neumann notify = lammich@in.tum.de date = 2016-07-05 topic = Computer science/Algorithms/Graph abstract =

This entry presents a framework for the modular verification of DFS-based algorithms, which is described in our [CPP-2015] paper. It provides a generic DFS algorithm framework, that can be parameterized with user-defined actions on certain events (e.g. discovery of new node). It comes with an extensible library of invariants, which can be used to derive invariants of a specific parameterization. Using refinement techniques, efficient implementations of the algorithms can easily be derived. Here, the framework comes with templates for a recursive and a tail-recursive implementation, and also with several templates for implementing the data structures required by the DFS algorithm. Finally, this entry contains a set of re-usable DFS-based algorithms, which illustrate the application of the framework.

[CPP-2015] Peter Lammich, René Neumann: A Framework for Verifying Depth-First Search Algorithms. CPP 2015: 137-146

[Flow_Networks] title = Flow Networks and the Min-Cut-Max-Flow Theorem author = Peter Lammich , S. Reza Sefidgar <> topic = Mathematics/Graph theory date = 2017-06-01 notify = lammich@in.tum.de abstract = We present a formalization of flow networks and the Min-Cut-Max-Flow theorem. Our formal proof closely follows a standard textbook proof, and is accessible even without being an expert in Isabelle/HOL, the interactive theorem prover used for the formalization. [Prpu_Maxflow] title = Formalizing Push-Relabel Algorithms author = Peter Lammich , S. Reza Sefidgar <> topic = Computer science/Algorithms/Graph, Mathematics/Graph theory date = 2017-06-01 notify = lammich@in.tum.de abstract = We present a formalization of push-relabel algorithms for computing the maximum flow in a network. We start with Goldberg's et al.~generic push-relabel algorithm, for which we show correctness and the time complexity bound of O(V^2E). We then derive the relabel-to-front and FIFO implementation. Using stepwise refinement techniques, we derive an efficient verified implementation. Our formal proof of the abstract algorithms closely follows a standard textbook proof. It is accessible even without being an expert in Isabelle/HOL, the interactive theorem prover used for the formalization. [Buildings] title = Chamber Complexes, Coxeter Systems, and Buildings author = Jeremy Sylvestre notify = jeremy.sylvestre@ualberta.ca date = 2016-07-01 topic = Mathematics/Algebra, Mathematics/Geometry abstract = We provide a basic formal framework for the theory of chamber complexes and Coxeter systems, and for buildings as thick chamber complexes endowed with a system of apartments. Along the way, we develop some of the general theory of abstract simplicial complexes and of groups (relying on the group_add class for the basics), including free groups and group presentations, and their universal properties. The main results verified are that the deletion condition is both necessary and sufficient for a group with a set of generators of order two to be a Coxeter system, and that the apartments in a (thick) building are all uniformly Coxeter. [Algebraic_VCs] title = Program Construction and Verification Components Based on Kleene Algebra author = Victor B. F. Gomes , Georg Struth notify = victor.gomes@cl.cam.ac.uk, g.struth@sheffield.ac.uk date = 2016-06-18 topic = Mathematics/Algebra abstract = Variants of Kleene algebra support program construction and verification by algebraic reasoning. This entry provides a verification component for Hoare logic based on Kleene algebra with tests, verification components for weakest preconditions and strongest postconditions based on Kleene algebra with domain and a component for step-wise refinement based on refinement Kleene algebra with tests. In addition to these components for the partial correctness of while programs, a verification component for total correctness based on divergence Kleene algebras and one for (partial correctness) of recursive programs based on domain quantales are provided. Finally we have integrated memory models for programs with pointers and a program trace semantics into the weakest precondition component. [C2KA_DistributedSystems] title = Communicating Concurrent Kleene Algebra for Distributed Systems Specification author = Maxime Buyse , Jason Jaskolka topic = Computer science/Automata and formal languages, Mathematics/Algebra date = 2019-08-06 notify = maxime.buyse@polytechnique.edu, jason.jaskolka@carleton.ca abstract = Communicating Concurrent Kleene Algebra (C²KA) is a mathematical framework for capturing the communicating and concurrent behaviour of agents in distributed systems. It extends Hoare et al.'s Concurrent Kleene Algebra (CKA) with communication actions through the notions of stimuli and shared environments. C²KA has applications in studying system-level properties of distributed systems such as safety, security, and reliability. In this work, we formalize results about C²KA and its application for distributed systems specification. We first formalize the stimulus structure and behaviour structure (CKA). Next, we combine them to formalize C²KA and its properties. Then, we formalize notions and properties related to the topology of distributed systems and the potential for communication via stimuli and via shared environments of agents, all within the algebraic setting of C²KA. [Card_Equiv_Relations] title = Cardinality of Equivalence Relations author = Lukas Bulwahn notify = lukas.bulwahn@gmail.com date = 2016-05-24 topic = Mathematics/Combinatorics abstract = This entry provides formulae for counting the number of equivalence relations and partial equivalence relations over a finite carrier set with given cardinality. To count the number of equivalence relations, we provide bijections between equivalence relations and set partitions, and then transfer the main results of the two AFP entries, Cardinality of Set Partitions and Spivey's Generalized Recurrence for Bell Numbers, to theorems on equivalence relations. To count the number of partial equivalence relations, we observe that counting partial equivalence relations over a set A is equivalent to counting all equivalence relations over all subsets of the set A. From this observation and the results on equivalence relations, we show that the cardinality of partial equivalence relations over a finite set of cardinality n is equal to the n+1-th Bell number. [Twelvefold_Way] title = The Twelvefold Way author = Lukas Bulwahn topic = Mathematics/Combinatorics date = 2016-12-29 notify = lukas.bulwahn@gmail.com abstract = This entry provides all cardinality theorems of the Twelvefold Way. The Twelvefold Way systematically classifies twelve related combinatorial problems concerning two finite sets, which include counting permutations, combinations, multisets, set partitions and number partitions. This development builds upon the existing formal developments with cardinality theorems for those structures. It provides twelve bijections from the various structures to different equivalence classes on finite functions, and hence, proves cardinality formulae for these equivalence classes on finite functions. [Chord_Segments] title = Intersecting Chords Theorem author = Lukas Bulwahn notify = lukas.bulwahn@gmail.com date = 2016-10-11 topic = Mathematics/Geometry abstract = This entry provides a geometric proof of the intersecting chords theorem. The theorem states that when two chords intersect each other inside a circle, the products of their segments are equal. After a short review of existing proofs in the literature, I decided to use a proof approach that employs reasoning about lengths of line segments, the orthogonality of two lines and the Pythagoras Law. Hence, one can understand the formalized proof easily with the knowledge of a few general geometric facts that are commonly taught in high-school. This theorem is the 55th theorem of the Top 100 Theorems list. [Category3] title = Category Theory with Adjunctions and Limits author = Eugene W. Stark notify = stark@cs.stonybrook.edu date = 2016-06-26 topic = Mathematics/Category theory abstract =

This article attempts to develop a usable framework for doing category theory in Isabelle/HOL. Our point of view, which to some extent differs from that of the previous AFP articles on the subject, is to try to explore how category theory can be done efficaciously within HOL, rather than trying to match exactly the way things are done using a traditional approach. To this end, we define the notion of category in an "object-free" style, in which a category is represented by a single partial composition operation on arrows. This way of defining categories provides some advantages in the context of HOL, including the ability to avoid the use of records and the possibility of defining functors and natural transformations simply as certain functions on arrows, rather than as composite objects. We define various constructions associated with the basic notions, including: dual category, product category, functor category, discrete category, free category, functor composition, and horizontal and vertical composite of natural transformations. A "set category" locale is defined that axiomatizes the notion "category of all sets at a type and all functions between them," and a fairly extensive set of properties of set categories is derived from the locale assumptions. The notion of a set category is used to prove the Yoneda Lemma in a general setting of a category equipped with a "hom embedding," which maps arrows of the category to the "universe" of the set category. We also give a treatment of adjunctions, defining adjunctions via left and right adjoint functors, natural bijections between hom-sets, and unit and counit natural transformations, and showing the equivalence of these definitions. We also develop the theory of limits, including representations of functors, diagrams and cones, and diagonal functors. We show that right adjoint functors preserve limits, and that limits can be constructed via products and equalizers. We characterize the conditions under which limits exist in a set category. We also examine the case of limits in a functor category, ultimately culminating in a proof that the Yoneda embedding preserves limits.

Revisions made subsequent to the first version of this article added material on equivalence of categories, cartesian categories, categories with pullbacks, categories with finite limits, and cartesian closed categories. A construction was given of the category of hereditarily finite sets and functions between them, and it was shown that this category is cartesian closed.

extra-history = Change history: [2018-05-29]: Revised axioms for the category locale. Introduced notation for composition and "in hom". (revision 8318366d4575)
[2020-02-15]: Move ConcreteCategory.thy from Bicategory to Category3 and use it systematically. Make other minor improvements throughout. (revision a51840d36867)
[2020-07-10]: Added new material, mostly centered around cartesian categories. (revision 06640f317a79)
[2020-11-04]: Minor modifications and extensions made in conjunction with the addition of new material to Bicategory. (revision 472cb2268826)
[MonoidalCategory] title = Monoidal Categories author = Eugene W. Stark topic = Mathematics/Category theory date = 2017-05-04 notify = stark@cs.stonybrook.edu abstract =

Building on the formalization of basic category theory set out in the author's previous AFP article, the present article formalizes some basic aspects of the theory of monoidal categories. Among the notions defined here are monoidal category, monoidal functor, and equivalence of monoidal categories. The main theorems formalized are MacLane's coherence theorem and the constructions of the free monoidal category and free strict monoidal category generated by a given category. The coherence theorem is proved syntactically, using a structurally recursive approach to reduction of terms that might have some novel aspects. We also give proofs of some results given by Etingof et al, which may prove useful in a formal setting. In particular, we show that the left and right unitors need not be taken as given data in the definition of monoidal category, nor does the definition of monoidal functor need to take as given a specific isomorphism expressing the preservation of the unit object. Our definitions of monoidal category and monoidal functor are stated so as to take advantage of the economy afforded by these facts.

Revisions made subsequent to the first version of this article added material on cartesian monoidal categories; showing that the underlying category of a cartesian monoidal category is a cartesian category, and that every cartesian category extends to a cartesian monoidal category.

extra-history = Change history: [2017-05-18]: Integrated material from MonoidalCategory/Category3Adapter into Category3/ and deleted adapter. (revision 015543cdd069)
[2018-05-29]: Modifications required due to 'Category3' changes. Introduced notation for "in hom". (revision 8318366d4575)
[2020-02-15]: Cosmetic improvements. (revision a51840d36867)
[2020-07-10]: Added new material on cartesian monoidal categories. (revision 06640f317a79)
[Card_Multisets] title = Cardinality of Multisets author = Lukas Bulwahn notify = lukas.bulwahn@gmail.com date = 2016-06-26 topic = Mathematics/Combinatorics abstract =

This entry provides three lemmas to count the number of multisets of a given size and finite carrier set. The first lemma provides a cardinality formula assuming that the multiset's elements are chosen from the given carrier set. The latter two lemmas provide formulas assuming that the multiset's elements also cover the given carrier set, i.e., each element of the carrier set occurs in the multiset at least once.

The proof of the first lemma uses the argument of the recurrence relation for counting multisets. The proof of the second lemma is straightforward, and the proof of the third lemma is easily obtained using the first cardinality lemma. A challenge for the formalization is the derivation of the required induction rule, which is a special combination of the induction rules for finite sets and natural numbers. The induction rule is derived by defining a suitable inductive predicate and transforming the predicate's induction rule.

[Posix-Lexing] title = POSIX Lexing with Derivatives of Regular Expressions author = Fahad Ausaf , Roy Dyckhoff , Christian Urban notify = christian.urban@kcl.ac.uk date = 2016-05-24 topic = Computer science/Automata and formal languages abstract = Brzozowski introduced the notion of derivatives for regular expressions. They can be used for a very simple regular expression matching algorithm. Sulzmann and Lu cleverly extended this algorithm in order to deal with POSIX matching, which is the underlying disambiguation strategy for regular expressions needed in lexers. In this entry we give our inductive definition of what a POSIX value is and show (i) that such a value is unique (for given regular expression and string being matched) and (ii) that Sulzmann and Lu's algorithm always generates such a value (provided that the regular expression matches the string). We also prove the correctness of an optimised version of the POSIX matching algorithm. [LocalLexing] title = Local Lexing author = Steven Obua topic = Computer science/Automata and formal languages date = 2017-04-28 notify = steven@recursivemind.com abstract = This formalisation accompanies the paper Local Lexing which introduces a novel parsing concept of the same name. The paper also gives a high-level algorithm for local lexing as an extension of Earley's algorithm. This formalisation proves the algorithm to be correct with respect to its local lexing semantics. As a special case, this formalisation thus also contains a proof of the correctness of Earley's algorithm. The paper contains a short outline of how this formalisation is organised. [MFMC_Countable] title = A Formal Proof of the Max-Flow Min-Cut Theorem for Countable Networks author = Andreas Lochbihler date = 2016-05-09 topic = Mathematics/Graph theory abstract = This article formalises a proof of the maximum-flow minimal-cut theorem for networks with countably many edges. A network is a directed graph with non-negative real-valued edge labels and two dedicated vertices, the source and the sink. A flow in a network assigns non-negative real numbers to the edges such that for all vertices except for the source and the sink, the sum of values on incoming edges equals the sum of values on outgoing edges. A cut is a subset of the vertices which contains the source, but not the sink. Our theorem states that in every network, there is a flow and a cut such that the flow saturates all the edges going out of the cut and is zero on all the incoming edges. The proof is based on the paper The Max-Flow Min-Cut theorem for countable networks by Aharoni et al. Additionally, we prove a characterisation of the lifting operation for relations on discrete probability distributions, which leads to a concise proof of its distributivity over relation composition. notify = mail@andreas-lochbihler.de extra-history = Change history: [2017-09-06]: derive characterisation for the lifting operation on discrete distributions from finite version of the max-flow min-cut theorem (revision a7a198f5bab0)
[2020-12-19]: simpler proof of linkability for bounded unhindered bipartite webs, leading to a simpler proof for networks with bounded out-capacities (revision 93ca33f4d915)
[2021-08-13]: generalize the derivation of the characterisation for the relator of discrete probability distributions to work for the bounded and unbounded MFMC theorem (revision 3c85bb52bbe6)
[Liouville_Numbers] title = Liouville numbers author = Manuel Eberl date = 2015-12-28 topic = Mathematics/Analysis, Mathematics/Number theory abstract =

Liouville numbers are a class of transcendental numbers that can be approximated particularly well with rational numbers. Historically, they were the first numbers whose transcendence was proven.

In this entry, we define the concept of Liouville numbers as well as the standard construction to obtain Liouville numbers (including Liouville's constant) and we prove their most important properties: irrationality and transcendence.

The proof is very elementary and requires only standard arithmetic, the Mean Value Theorem for polynomials, and the boundedness of polynomials on compact intervals.

notify = eberlm@in.tum.de [Triangle] title = Basic Geometric Properties of Triangles author = Manuel Eberl date = 2015-12-28 topic = Mathematics/Geometry abstract =

This entry contains a definition of angles between vectors and between three points. Building on this, we prove basic geometric properties of triangles, such as the Isosceles Triangle Theorem, the Law of Sines and the Law of Cosines, that the sum of the angles of a triangle is π, and the congruence theorems for triangles.

The definitions and proofs were developed following those by John Harrison in HOL Light. However, due to Isabelle's type class system, all definitions and theorems in the Isabelle formalisation hold for all real inner product spaces.

notify = eberlm@in.tum.de [Prime_Harmonic_Series] title = The Divergence of the Prime Harmonic Series author = Manuel Eberl date = 2015-12-28 topic = Mathematics/Number theory abstract =

In this work, we prove the lower bound ln(H_n) - ln(5/3) for the partial sum of the Prime Harmonic series and, based on this, the divergence of the Prime Harmonic Series ∑[p prime] · 1/p.

The proof relies on the unique squarefree decomposition of natural numbers. This is similar to Euler's original proof (which was highly informal and morally questionable). Its advantage over proofs by contradiction, like the famous one by Paul Erdős, is that it provides a relatively good lower bound for the partial sums.

notify = eberlm@in.tum.de [Descartes_Sign_Rule] title = Descartes' Rule of Signs author = Manuel Eberl date = 2015-12-28 topic = Mathematics/Analysis abstract =

Descartes' Rule of Signs relates the number of positive real roots of a polynomial with the number of sign changes in its coefficient sequence.

Our proof follows the simple inductive proof given by Rob Arthan, which was also used by John Harrison in his HOL Light formalisation. We proved most of the lemmas for arbitrary linearly-ordered integrity domains (e.g. integers, rationals, reals); the main result, however, requires the intermediate value theorem and was therefore only proven for real polynomials.

notify = eberlm@in.tum.de [Euler_MacLaurin] title = The Euler–MacLaurin Formula author = Manuel Eberl topic = Mathematics/Analysis date = 2017-03-10 notify = eberlm@in.tum.de abstract =

The Euler-MacLaurin formula relates the value of a discrete sum to that of the corresponding integral in terms of the derivatives at the borders of the summation and a remainder term. Since the remainder term is often very small as the summation bounds grow, this can be used to compute asymptotic expansions for sums.

This entry contains a proof of this formula for functions from the reals to an arbitrary Banach space. Two variants of the formula are given: the standard textbook version and a variant outlined in Concrete Mathematics that is more useful for deriving asymptotic estimates.

As example applications, we use that formula to derive the full asymptotic expansion of the harmonic numbers and the sum of inverse squares.

[Card_Partitions] title = Cardinality of Set Partitions author = Lukas Bulwahn date = 2015-12-12 topic = Mathematics/Combinatorics abstract = The theory's main theorem states that the cardinality of set partitions of size k on a carrier set of size n is expressed by Stirling numbers of the second kind. In Isabelle, Stirling numbers of the second kind are defined in the AFP entry `Discrete Summation` through their well-known recurrence relation. The main theorem relates them to the alternative definition as cardinality of set partitions. The proof follows the simple and short explanation in Richard P. Stanley's `Enumerative Combinatorics: Volume 1` and Wikipedia, and unravels the full details and implicit reasoning steps of these explanations. notify = lukas.bulwahn@gmail.com [Card_Number_Partitions] title = Cardinality of Number Partitions author = Lukas Bulwahn date = 2016-01-14 topic = Mathematics/Combinatorics abstract = This entry provides a basic library for number partitions, defines the two-argument partition function through its recurrence relation and relates this partition function to the cardinality of number partitions. The main proof shows that the recursively-defined partition function with arguments n and k equals the cardinality of number partitions of n with exactly k parts. The combinatorial proof follows the proof sketch of Theorem 2.4.1 in Mazur's textbook `Combinatorics: A Guided Tour`. This entry can serve as starting point for various more intrinsic properties about number partitions, the partition function and related recurrence relations. notify = lukas.bulwahn@gmail.com [Multirelations] title = Binary Multirelations author = Hitoshi Furusawa , Georg Struth date = 2015-06-11 topic = Mathematics/Algebra abstract = Binary multirelations associate elements of a set with its subsets; hence they are binary relations from a set to its power set. Applications include alternating automata, models and logics for games, program semantics with dual demonic and angelic nondeterministic choices and concurrent dynamic logics. This proof document supports an arXiv article that formalises the basic algebra of multirelations and proposes axiom systems for them, ranging from weak bi-monoids to weak bi-quantales. notify = [Noninterference_Generic_Unwinding] title = The Generic Unwinding Theorem for CSP Noninterference Security author = Pasquale Noce date = 2015-06-11 topic = Computer science/Security, Computer science/Concurrency/Process calculi abstract =

The classical definition of noninterference security for a deterministic state machine with outputs requires to consider the outputs produced by machine actions after any trace, i.e. any indefinitely long sequence of actions, of the machine. In order to render the verification of the security of such a machine more straightforward, there is a need of some sufficient condition for security such that just individual actions, rather than unbounded sequences of actions, have to be considered.

By extending previous results applying to transitive noninterference policies, Rushby has proven an unwinding theorem that provides a sufficient condition of this kind in the general case of a possibly intransitive policy. This condition has to be satisfied by a generic function mapping security domains into equivalence relations over machine states.

An analogous problem arises for CSP noninterference security, whose definition requires to consider any possible future, i.e. any indefinitely long sequence of subsequent events and any indefinitely large set of refused events associated to that sequence, for each process trace.

This paper provides a sufficient condition for CSP noninterference security, which indeed requires to just consider individual accepted and refused events and applies to the general case of a possibly intransitive policy. This condition follows Rushby's one for classical noninterference security, and has to be satisfied by a generic function mapping security domains into equivalence relations over process traces; hence its name, Generic Unwinding Theorem. Variants of this theorem applying to deterministic processes and trace set processes are also proven. Finally, the sufficient condition for security expressed by the theorem is shown not to be a necessary condition as well, viz. there exists a secure process such that no domain-relation map satisfying the condition exists.

notify = [Noninterference_Ipurge_Unwinding] title = The Ipurge Unwinding Theorem for CSP Noninterference Security author = Pasquale Noce date = 2015-06-11 topic = Computer science/Security abstract =

The definition of noninterference security for Communicating Sequential Processes requires to consider any possible future, i.e. any indefinitely long sequence of subsequent events and any indefinitely large set of refused events associated to that sequence, for each process trace. In order to render the verification of the security of a process more straightforward, there is a need of some sufficient condition for security such that just individual accepted and refused events, rather than unbounded sequences and sets of events, have to be considered.

Of course, if such a sufficient condition were necessary as well, it would be even more valuable, since it would permit to prove not only that a process is secure by verifying that the condition holds, but also that a process is not secure by verifying that the condition fails to hold.

This paper provides a necessary and sufficient condition for CSP noninterference security, which indeed requires to just consider individual accepted and refused events and applies to the general case of a possibly intransitive policy. This condition follows Rushby's output consistency for deterministic state machines with outputs, and has to be satisfied by a specific function mapping security domains into equivalence relations over process traces. The definition of this function makes use of an intransitive purge function following Rushby's one; hence the name given to the condition, Ipurge Unwinding Theorem.

Furthermore, in accordance with Hoare's formal definition of deterministic processes, it is shown that a process is deterministic just in case it is a trace set process, i.e. it may be identified by means of a trace set alone, matching the set of its traces, in place of a failures-divergences pair. Then, variants of the Ipurge Unwinding Theorem are proven for deterministic processes and trace set processes.

notify = [Relational_Method] title = The Relational Method with Message Anonymity for the Verification of Cryptographic Protocols author = Pasquale Noce topic = Computer science/Security date = 2020-12-05 notify = pasquale.noce.lavoro@gmail.com abstract = This paper introduces a new method for the formal verification of cryptographic protocols, the relational method, derived from Paulson's inductive method by means of some enhancements aimed at streamlining formal definitions and proofs, specially for protocols using public key cryptography. Moreover, this paper proposes a method to formalize a further security property, message anonymity, in addition to message confidentiality and authenticity. The relational method, including message anonymity, is then applied to the verification of a sample authentication protocol, comprising Password Authenticated Connection Establishment (PACE) with Chip Authentication Mapping followed by the explicit verification of an additional password over the PACE secure channel. [List_Interleaving] title = Reasoning about Lists via List Interleaving author = Pasquale Noce date = 2015-06-11 topic = Computer science/Data structures abstract =

Among the various mathematical tools introduced in his outstanding work on Communicating Sequential Processes, Hoare has defined "interleaves" as the predicate satisfied by any three lists such that the first list may be split into sublists alternately extracted from the other two ones, whatever is the criterion for extracting an item from either one list or the other in each step.

This paper enriches Hoare's definition by identifying such criterion with the truth value of a predicate taking as inputs the head and the tail of the first list. This enhanced "interleaves" predicate turns out to permit the proof of equalities between lists without the need of an induction. Some rules that allow to infer "interleaves" statements without induction, particularly applying to the addition or removal of a prefix to the input lists, are also proven. Finally, a stronger version of the predicate, named "Interleaves", is shown to fulfil further rules applying to the addition or removal of a suffix to the input lists.

notify = [Residuated_Lattices] title = Residuated Lattices author = Victor B. F. Gomes , Georg Struth date = 2015-04-15 topic = Mathematics/Algebra abstract = The theory of residuated lattices, first proposed by Ward and Dilworth, is formalised in Isabelle/HOL. This includes concepts of residuated functions; their adjoints and conjugates. It also contains necessary and sufficient conditions for the existence of these operations in an arbitrary lattice. The mathematical components for residuated lattices are linked to the AFP entry for relation algebra. In particular, we prove Jonsson and Tsinakis conditions for a residuated boolean algebra to form a relation algebra. notify = g.struth@sheffield.ac.uk [ConcurrentGC] title = Relaxing Safely: Verified On-the-Fly Garbage Collection for x86-TSO author = Peter Gammie , Tony Hosking , Kai Engelhardt <> date = 2015-04-13 topic = Computer science/Algorithms/Concurrent abstract =

We use ConcurrentIMP to model Schism, a state-of-the-art real-time garbage collection scheme for weak memory, and show that it is safe on x86-TSO.

This development accompanies the PLDI 2015 paper of the same name.

notify = peteg42@gmail.com [List_Update] title = Analysis of List Update Algorithms author = Maximilian P.L. Haslbeck , Tobias Nipkow date = 2016-02-17 topic = Computer science/Algorithms/Online abstract =

These theories formalize the quantitative analysis of a number of classical algorithms for the list update problem: 2-competitiveness of move-to-front, the lower bound of 2 for the competitiveness of deterministic list update algorithms and 1.6-competitiveness of the randomized COMB algorithm, the best randomized list update algorithm known to date. The material is based on the first two chapters of Online Computation and Competitive Analysis by Borodin and El-Yaniv.

For an informal description see the FSTTCS 2016 publication Verified Analysis of List Update Algorithms by Haslbeck and Nipkow.

notify = nipkow@in.tum.de [ConcurrentIMP] title = Concurrent IMP author = Peter Gammie date = 2015-04-13 topic = Computer science/Programming languages/Logics abstract = ConcurrentIMP extends the small imperative language IMP with control non-determinism and constructs for synchronous message passing. notify = peteg42@gmail.com [TortoiseHare] title = The Tortoise and Hare Algorithm author = Peter Gammie date = 2015-11-18 topic = Computer science/Algorithms abstract = We formalize the Tortoise and Hare cycle-finding algorithm ascribed to Floyd by Knuth, and an improved version due to Brent. notify = peteg42@gmail.com [UPF] title = The Unified Policy Framework (UPF) author = Achim D. Brucker , Lukas Brügger , Burkhart Wolff date = 2014-11-28 topic = Computer science/Security abstract = We present the Unified Policy Framework (UPF), a generic framework for modelling security (access-control) policies. UPF emphasizes the view that a policy is a policy decision function that grants or denies access to resources, permissions, etc. In other words, instead of modelling the relations of permitted or prohibited requests directly, we model the concrete function that implements the policy decision point in a system. In more detail, UPF is based on the following four principles: 1) Functional representation of policies, 2) No conflicts are possible, 3) Three-valued decision type (allow, deny, undefined), 4) Output type not containing the decision only. notify = adbrucker@0x5f.org, wolff@lri.fr, lukas.a.bruegger@gmail.com [UPF_Firewall] title = Formal Network Models and Their Application to Firewall Policies author = Achim D. Brucker , Lukas Brügger<>, Burkhart Wolff topic = Computer science/Security, Computer science/Networks date = 2017-01-08 notify = adbrucker@0x5f.org abstract = We present a formal model of network protocols and their application to modeling firewall policies. The formalization is based on the Unified Policy Framework (UPF). The formalization was originally developed with for generating test cases for testing the security configuration actual firewall and router (middle-boxes) using HOL-TestGen. Our work focuses on modeling application level protocols on top of tcp/ip. [AODV] title = Loop freedom of the (untimed) AODV routing protocol author = Timothy Bourke , Peter Höfner date = 2014-10-23 topic = Computer science/Concurrency/Process calculi abstract =

The Ad hoc On-demand Distance Vector (AODV) routing protocol allows the nodes in a Mobile Ad hoc Network (MANET) or a Wireless Mesh Network (WMN) to know where to forward data packets. Such a protocol is ‘loop free’ if it never leads to routing decisions that forward packets in circles.

This development mechanises an existing pen-and-paper proof of loop freedom of AODV. The protocol is modelled in the Algebra of Wireless Networks (AWN), which is the subject of an earlier paper and AFP mechanization. The proof relies on a novel compositional approach for lifting invariants to networks of nodes.

We exploit the mechanization to analyse several variants of AODV and show that Isabelle/HOL can re-establish most proof obligations automatically and identify exactly the steps that are no longer valid.

notify = tim@tbrk.org [Show] title = Haskell's Show Class in Isabelle/HOL author = Christian Sternagel , René Thiemann date = 2014-07-29 topic = Computer science/Functional programming license = LGPL abstract = We implemented a type class for "to-string" functions, similar to Haskell's Show class. Moreover, we provide instantiations for Isabelle/HOL's standard types like bool, prod, sum, nats, ints, and rats. It is further possible, to automatically derive show functions for arbitrary user defined datatypes similar to Haskell's "deriving Show". extra-history = Change history: [2015-03-11]: Adapted development to new-style (BNF-based) datatypes.
[2015-04-10]: Moved development for old-style datatypes into subdirectory "Old_Datatype".
notify = christian.sternagel@uibk.ac.at, rene.thiemann@uibk.ac.at [Certification_Monads] title = Certification Monads author = Christian Sternagel , René Thiemann date = 2014-10-03 topic = Computer science/Functional programming abstract = This entry provides several monads intended for the development of stand-alone certifiers via code generation from Isabelle/HOL. More specifically, there are three flavors of error monads (the sum type, for the case where all monadic functions are total; an instance of the former, the so called check monad, yielding either success without any further information or an error message; as well as a variant of the sum type that accommodates partial functions by providing an explicit bottom element) and a parser monad built on top. All of this monads are heavily used in the IsaFoR/CeTA project which thus provides many examples of their usage. notify = c.sternagel@gmail.com, rene.thiemann@uibk.ac.at [CISC-Kernel] title = Formal Specification of a Generic Separation Kernel author = Freek Verbeek , Sergey Tverdyshev , Oto Havle , Holger Blasum , Bruno Langenstein , Werner Stephan , Yakoub Nemouchi , Abderrahmane Feliachi , Burkhart Wolff , Julien Schmaltz date = 2014-07-18 topic = Computer science/Security abstract =

Intransitive noninterference has been a widely studied topic in the last few decades. Several well-established methodologies apply interactive theorem proving to formulate a noninterference theorem over abstract academic models. In joint work with several industrial and academic partners throughout Europe, we are helping in the certification process of PikeOS, an industrial separation kernel developed at SYSGO. In this process, established theories could not be applied. We present a new generic model of separation kernels and a new theory of intransitive noninterference. The model is rich in detail, making it suitable for formal verification of realistic and industrial systems such as PikeOS. Using a refinement-based theorem proving approach, we ensure that proofs remain manageable.

This document corresponds to the deliverable D31.1 of the EURO-MILS Project http://www.euromils.eu.

notify = [pGCL] title = pGCL for Isabelle author = David Cock date = 2014-07-13 topic = Computer science/Programming languages/Language definitions abstract =

pGCL is both a programming language and a specification language that incorporates both probabilistic and nondeterministic choice, in a unified manner. Program verification is by refinement or annotation (or both), using either Hoare triples, or weakest-precondition entailment, in the style of GCL.

This package provides both a shallow embedding of the language primitives, and an annotation and refinement framework. The generated document includes a brief tutorial.

notify = [Noninterference_CSP] title = Noninterference Security in Communicating Sequential Processes author = Pasquale Noce date = 2014-05-23 topic = Computer science/Security abstract =

An extension of classical noninterference security for deterministic state machines, as introduced by Goguen and Meseguer and elegantly formalized by Rushby, to nondeterministic systems should satisfy two fundamental requirements: it should be based on a mathematically precise theory of nondeterminism, and should be equivalent to (or at least not weaker than) the classical notion in the degenerate deterministic case.

This paper proposes a definition of noninterference security applying to Hoare's Communicating Sequential Processes (CSP) in the general case of a possibly intransitive noninterference policy, and proves the equivalence of this security property to classical noninterference security for processes representing deterministic state machines.

Furthermore, McCullough's generalized noninterference security is shown to be weaker than both the proposed notion of CSP noninterference security for a generic process, and classical noninterference security for processes representing deterministic state machines. This renders CSP noninterference security preferable as an extension of classical noninterference security to nondeterministic systems.

notify = pasquale.noce.lavoro@gmail.com [Floyd_Warshall] title = The Floyd-Warshall Algorithm for Shortest Paths author = Simon Wimmer , Peter Lammich topic = Computer science/Algorithms/Graph date = 2017-05-08 notify = wimmers@in.tum.de abstract = The Floyd-Warshall algorithm [Flo62, Roy59, War62] is a classic dynamic programming algorithm to compute the length of all shortest paths between any two vertices in a graph (i.e. to solve the all-pairs shortest path problem, or APSP for short). Given a representation of the graph as a matrix of weights M, it computes another matrix M' which represents a graph with the same path lengths and contains the length of the shortest path between any two vertices i and j. This is only possible if the graph does not contain any negative cycles. However, in this case the Floyd-Warshall algorithm will detect the situation by calculating a negative diagonal entry. This entry includes a formalization of the algorithm and of these key properties. The algorithm is refined to an efficient imperative version using the Imperative Refinement Framework. [Roy_Floyd_Warshall] title = Transitive closure according to Roy-Floyd-Warshall author = Makarius Wenzel <> date = 2014-05-23 topic = Computer science/Algorithms/Graph abstract = This formulation of the Roy-Floyd-Warshall algorithm for the transitive closure bypasses matrices and arrays, but uses a more direct mathematical model with adjacency functions for immediate predecessors and successors. This can be implemented efficiently in functional programming languages and is particularly adequate for sparse relations. notify = [GPU_Kernel_PL] title = Syntax and semantics of a GPU kernel programming language author = John Wickerson date = 2014-04-03 topic = Computer science/Programming languages/Language definitions abstract = This document accompanies the article "The Design and Implementation of a Verification Technique for GPU Kernels" by Adam Betts, Nathan Chong, Alastair F. Donaldson, Jeroen Ketema, Shaz Qadeer, Paul Thomson and John Wickerson. It formalises all of the definitions provided in Sections 3 and 4 of the article. notify = [AWN] title = Mechanization of the Algebra for Wireless Networks (AWN) author = Timothy Bourke date = 2014-03-08 topic = Computer science/Concurrency/Process calculi abstract =

AWN is a process algebra developed for modelling and analysing protocols for Mobile Ad hoc Networks (MANETs) and Wireless Mesh Networks (WMNs). AWN models comprise five distinct layers: sequential processes, local parallel compositions, nodes, partial networks, and complete networks.

This development mechanises the original operational semantics of AWN and introduces a variant 'open' operational semantics that enables the compositional statement and proof of invariants across distinct network nodes. It supports labels (for weakening invariants) and (abstract) data state manipulations. A framework for compositional invariant proofs is developed, including a tactic (inv_cterms) for inductive invariant proofs of sequential processes, lifting rules for the open versions of the higher layers, and a rule for transferring lifted properties back to the standard semantics. A notion of 'control terms' reduces proof obligations to the subset of subterms that act directly (in contrast to operators for combining terms and joining processes).

notify = tim@tbrk.org [Selection_Heap_Sort] title = Verification of Selection and Heap Sort Using Locales author = Danijela Petrovic date = 2014-02-11 topic = Computer science/Algorithms abstract = Stepwise program refinement techniques can be used to simplify program verification. Programs are better understood since their main properties are clearly stated, and verification of rather complex algorithms is reduced to proving simple statements connecting successive program specifications. Additionally, it is easy to analyze similar algorithms and to compare their properties within a single formalization. Usually, formal analysis is not done in educational setting due to complexity of verification and a lack of tools and procedures to make comparison easy. Verification of an algorithm should not only give correctness proof, but also better understanding of an algorithm. If the verification is based on small step program refinement, it can become simple enough to be demonstrated within the university-level computer science curriculum. In this paper we demonstrate this and give a formal analysis of two well known algorithms (Selection Sort and Heap Sort) using proof assistant Isabelle/HOL and program refinement techniques. notify = [Real_Impl] title = Implementing field extensions of the form Q[sqrt(b)] author = René Thiemann date = 2014-02-06 license = LGPL topic = Mathematics/Analysis abstract = We apply data refinement to implement the real numbers, where we support all numbers in the field extension Q[sqrt(b)], i.e., all numbers of the form p + q * sqrt(b) for rational numbers p and q and some fixed natural number b. To this end, we also developed algorithms to precisely compute roots of a rational number, and to perform a factorization of natural numbers which eliminates duplicate prime factors.

Our results have been used to certify termination proofs which involve polynomial interpretations over the reals. extra-history = Change history: [2014-07-11]: Moved NthRoot_Impl to Sqrt-Babylonian. notify = rene.thiemann@uibk.ac.at [ShortestPath] title = An Axiomatic Characterization of the Single-Source Shortest Path Problem author = Christine Rizkallah date = 2013-05-22 topic = Mathematics/Graph theory abstract = This theory is split into two sections. In the first section, we give a formal proof that a well-known axiomatic characterization of the single-source shortest path problem is correct. Namely, we prove that in a directed graph with a non-negative cost function on the edges the single-source shortest path function is the only function that satisfies a set of four axioms. In the second section, we give a formal proof of the correctness of an axiomatic characterization of the single-source shortest path problem for directed graphs with general cost functions. The axioms here are more involved because we have to account for potential negative cycles in the graph. The axioms are summarized in three Isabelle locales. notify = [Launchbury] title = The Correctness of Launchbury's Natural Semantics for Lazy Evaluation author = Joachim Breitner date = 2013-01-31 topic = Computer science/Programming languages/Lambda calculi, Computer science/Semantics abstract = In his seminal paper "Natural Semantics for Lazy Evaluation", John Launchbury proves his semantics correct with respect to a denotational semantics, and outlines an adequacy proof. We have formalized both semantics and machine-checked the correctness proof, clarifying some details. Furthermore, we provide a new and more direct adequacy proof that does not require intermediate operational semantics. extra-history = Change history: [2014-05-24]: Added the proof of adequacy, as well as simplified and improved the existing proofs. Adjusted abstract accordingly. [2015-03-16]: Booleans and if-then-else added to syntax and semantics, making this entry suitable to be used by the entry "Call_Arity". notify = [Call_Arity] title = The Safety of Call Arity author = Joachim Breitner date = 2015-02-20 topic = Computer science/Programming languages/Transformations abstract = We formalize the Call Arity analysis, as implemented in GHC, and prove both functional correctness and, more interestingly, safety (i.e. the transformation does not increase allocation).

We use syntax and the denotational semantics from the entry "Launchbury", where we formalized Launchbury's natural semantics for lazy evaluation.

The functional correctness of Call Arity is proved with regard to that denotational semantics. The operational properties are shown with regard to a small-step semantics akin to Sestoft's mark 1 machine, which we prove to be equivalent to Launchbury's semantics.

We use Christian Urban's Nominal2 package to define our terms and make use of Brian Huffman's HOLCF package for the domain-theoretical aspects of the development. extra-history = Change history: [2015-03-16]: This entry now builds on top of the Launchbury entry, and the equivalency proof of the natural and the small-step semantics was added. notify = [CCS] title = CCS in nominal logic author = Jesper Bengtson date = 2012-05-29 topic = Computer science/Concurrency/Process calculi abstract = We formalise a large portion of CCS as described in Milner's book 'Communication and Concurrency' using the nominal datatype package in Isabelle. Our results include many of the standard theorems of bisimulation equivalence and congruence, for both weak and strong versions. One main goal of this formalisation is to keep the machine-checked proofs as close to their pen-and-paper counterpart as possible.

This entry is described in detail in Bengtson's thesis. notify = [Pi_Calculus] title = The pi-calculus in nominal logic author = Jesper Bengtson date = 2012-05-29 topic = Computer science/Concurrency/Process calculi abstract = We formalise the pi-calculus using the nominal datatype package, based on ideas from the nominal logic by Pitts et al., and demonstrate an implementation in Isabelle/HOL. The purpose is to derive powerful induction rules for the semantics in order to conduct machine checkable proofs, closely following the intuitive arguments found in manual proofs. In this way we have covered many of the standard theorems of bisimulation equivalence and congruence, both late and early, and both strong and weak in a uniform manner. We thus provide one of the most extensive formalisations of a the pi-calculus ever done inside a theorem prover.

A significant gain in our formulation is that agents are identified up to alpha-equivalence, thereby greatly reducing the arguments about bound names. This is a normal strategy for manual proofs about the pi-calculus, but that kind of hand waving has previously been difficult to incorporate smoothly in an interactive theorem prover. We show how the nominal logic formalism and its support in Isabelle accomplishes this and thus significantly reduces the tedium of conducting completely formal proofs. This improves on previous work using weak higher order abstract syntax since we do not need extra assumptions to filter out exotic terms and can keep all arguments within a familiar first-order logic.

This entry is described in detail in Bengtson's thesis. notify = [Psi_Calculi] title = Psi-calculi in Isabelle author = Jesper Bengtson date = 2012-05-29 topic = Computer science/Concurrency/Process calculi abstract = Psi-calculi are extensions of the pi-calculus, accommodating arbitrary nominal datatypes to represent not only data but also communication channels, assertions and conditions, giving it an expressive power beyond the applied pi-calculus and the concurrent constraint pi-calculus.

We have formalised psi-calculi in the interactive theorem prover Isabelle using its nominal datatype package. One distinctive feature is that the framework needs to treat binding sequences, as opposed to single binders, in an efficient way. While different methods for formalising single binder calculi have been proposed over the last decades, representations for such binding sequences are not very well explored.

The main effort in the formalisation is to keep the machine checked proofs as close to their pen-and-paper counterparts as possible. This includes treating all binding sequences as atomic elements, and creating custom induction and inversion rules that to remove the bulk of manual alpha-conversions.

This entry is described in detail in Bengtson's thesis. notify = [Encodability_Process_Calculi] title = Analysing and Comparing Encodability Criteria for Process Calculi author = Kirstin Peters , Rob van Glabbeek date = 2015-08-10 topic = Computer science/Concurrency/Process calculi abstract = Encodings or the proof of their absence are the main way to compare process calculi. To analyse the quality of encodings and to rule out trivial or meaningless encodings, they are augmented with quality criteria. There exists a bunch of different criteria and different variants of criteria in order to reason in different settings. This leads to incomparable results. Moreover it is not always clear whether the criteria used to obtain a result in a particular setting do indeed fit to this setting. We show how to formally reason about and compare encodability criteria by mapping them on requirements on a relation between source and target terms that is induced by the encoding function. In particular we analyse the common criteria full abstraction, operational correspondence, divergence reflection, success sensitiveness, and respect of barbs; e.g. we analyse the exact nature of the simulation relation (coupled simulation versus bisimulation) that is induced by different variants of operational correspondence. This way we reduce the problem of analysing or comparing encodability criteria to the better understood problem of comparing relations on processes. notify = kirstin.peters@tu-berlin.de [Circus] title = Isabelle/Circus author = Abderrahmane Feliachi , Burkhart Wolff , Marie-Claude Gaudel contributors = Makarius Wenzel date = 2012-05-27 topic = Computer science/Concurrency/Process calculi, Computer science/System description languages abstract = The Circus specification language combines elements for complex data and behavior specifications, using an integration of Z and CSP with a refinement calculus. Its semantics is based on Hoare and He's Unifying Theories of Programming (UTP). Isabelle/Circus is a formalization of the UTP and the Circus language in Isabelle/HOL. It contains proof rules and tactic support that allows for proofs of refinement for Circus processes (involving both data and behavioral aspects).

The Isabelle/Circus environment supports a syntax for the semantic definitions which is close to textbook presentations of Circus. This article contains an extended version of corresponding VSTTE Paper together with the complete formal development of its underlying commented theories. extra-history = Change history: [2014-06-05]: More polishing, shorter proofs, added Circus syntax, added Makarius Wenzel as contributor. notify = [Dijkstra_Shortest_Path] title = Dijkstra's Shortest Path Algorithm author = Benedikt Nordhoff , Peter Lammich topic = Computer science/Algorithms/Graph date = 2012-01-30 abstract = We implement and prove correct Dijkstra's algorithm for the single source shortest path problem, conceived in 1956 by E. Dijkstra. The algorithm is implemented using the data refinement framework for monadic, nondeterministic programs. An efficient implementation is derived using data structures from the Isabelle Collection Framework. notify = lammich@in.tum.de [Refine_Monadic] title = Refinement for Monadic Programs author = Peter Lammich topic = Computer science/Programming languages/Logics date = 2012-01-30 abstract = We provide a framework for program and data refinement in Isabelle/HOL. The framework is based on a nondeterminism-monad with assertions, i.e., the monad carries a set of results or an assertion failure. Recursion is expressed by fixed points. For convenience, we also provide while and foreach combinators.

The framework provides tools to automatize canonical tasks, such as verification condition generation, finding appropriate data refinement relations, and refine an executable program to a form that is accepted by the Isabelle/HOL code generator.

This submission comes with a collection of examples and a user-guide, illustrating the usage of the framework. extra-history = Change history: [2012-04-23] Introduced ordered FOREACH loops
[2012-06] New features: REC_rule_arb and RECT_rule_arb allow for generalizing over variables. prepare_code_thms - command extracts code equations for recursion combinators.
[2012-07] New example: Nested DFS for emptiness check of Buchi-automata with witness.
New feature: fo_rule method to apply resolution using first-order matching. Useful for arg_conf, fun_cong.
[2012-08] Adaptation to ICF v2.
[2012-10-05] Adaptations to include support for Automatic Refinement Framework.
[2013-09] This entry now depends on Automatic Refinement
[2014-06] New feature: vc_solve method to solve verification conditions. Maintenace changes: VCG-rules for nfoldli, improved setup for FOREACH-loops.
[2014-07] Now defining recursion via flat domain. Dropped many single-valued prerequisites. Changed notion of data refinement. In single-valued case, this matches the old notion. In non-single valued case, the new notion allows for more convenient rules. In particular, the new definitions allow for projecting away ghost variables as a refinement step.
[2014-11] New features: le-or-fail relation (leof), modular reasoning about loop invariants. notify = lammich@in.tum.de [Refine_Imperative_HOL] title = The Imperative Refinement Framework author = Peter Lammich notify = lammich@in.tum.de date = 2016-08-08 topic = Computer science/Programming languages/Transformations,Computer science/Data structures abstract = We present the Imperative Refinement Framework (IRF), a tool that supports a stepwise refinement based approach to imperative programs. This entry is based on the material we presented in [ITP-2015, CPP-2016]. It uses the Monadic Refinement Framework as a frontend for the specification of the abstract programs, and Imperative/HOL as a backend to generate executable imperative programs. The IRF comes with tool support to synthesize imperative programs from more abstract, functional ones, using efficient imperative implementations for the abstract data structures. This entry also includes the Imperative Isabelle Collection Framework (IICF), which provides a library of re-usable imperative collection data structures. Moreover, this entry contains a quickstart guide and a reference manual, which provide an introduction to using the IRF for Isabelle/HOL experts. It also provids a collection of (partly commented) practical examples, some highlights being Dijkstra's Algorithm, Nested-DFS, and a generic worklist algorithm with subsumption. Finally, this entry contains benchmark scripts that compare the runtime of some examples against reference implementations of the algorithms in Java and C++. [ITP-2015] Peter Lammich: Refinement to Imperative/HOL. ITP 2015: 253--269 [CPP-2016] Peter Lammich: Refinement based verification of imperative data structures. CPP 2016: 27--36 [Automatic_Refinement] title = Automatic Data Refinement author = Peter Lammich topic = Computer science/Programming languages/Logics date = 2013-10-02 abstract = We present the Autoref tool for Isabelle/HOL, which automatically refines algorithms specified over abstract concepts like maps and sets to algorithms over concrete implementations like red-black-trees, and produces a refinement theorem. It is based on ideas borrowed from relational parametricity due to Reynolds and Wadler. The tool allows for rapid prototyping of verified, executable algorithms. Moreover, it can be configured to fine-tune the result to the user~s needs. Our tool is able to automatically instantiate generic algorithms, which greatly simplifies the implementation of executable data structures.

This AFP-entry provides the basic tool, which is then used by the Refinement and Collection Framework to provide automatic data refinement for the nondeterminism monad and various collection datastructures. notify = lammich@in.tum.de [EdmondsKarp_Maxflow] title = Formalizing the Edmonds-Karp Algorithm author = Peter Lammich , S. Reza Sefidgar<> notify = lammich@in.tum.de date = 2016-08-12 topic = Computer science/Algorithms/Graph abstract = We present a formalization of the Ford-Fulkerson method for computing the maximum flow in a network. Our formal proof closely follows a standard textbook proof, and is accessible even without being an expert in Isabelle/HOL--- the interactive theorem prover used for the formalization. We then use stepwise refinement to obtain the Edmonds-Karp algorithm, and formally prove a bound on its complexity. Further refinement yields a verified implementation, whose execution time compares well to an unverified reference implementation in Java. This entry is based on our ITP-2016 paper with the same title. [VerifyThis2018] title = VerifyThis 2018 - Polished Isabelle Solutions author = Peter Lammich , Simon Wimmer topic = Computer science/Algorithms date = 2018-04-27 notify = lammich@in.tum.de abstract = VerifyThis 2018 was a program verification competition associated with ETAPS 2018. It was the 7th event in the VerifyThis competition series. In this entry, we present polished and completed versions of our solutions that we created during the competition. [PseudoHoops] title = Pseudo Hoops author = George Georgescu <>, Laurentiu Leustean <>, Viorel Preoteasa topic = Mathematics/Algebra date = 2011-09-22 abstract = Pseudo-hoops are algebraic structures introduced by B. Bosbach under the name of complementary semigroups. In this formalization we prove some properties of pseudo-hoops and we define the basic concepts of filter and normal filter. The lattice of normal filters is isomorphic with the lattice of congruences of a pseudo-hoop. We also study some important classes of pseudo-hoops. Bounded Wajsberg pseudo-hoops are equivalent to pseudo-Wajsberg algebras and bounded basic pseudo-hoops are equivalent to pseudo-BL algebras. Some examples of pseudo-hoops are given in the last section of the formalization. notify = viorel.preoteasa@aalto.fi [MonoBoolTranAlgebra] title = Algebra of Monotonic Boolean Transformers author = Viorel Preoteasa topic = Computer science/Programming languages/Logics date = 2011-09-22 abstract = Algebras of imperative programming languages have been successful in reasoning about programs. In general an algebra of programs is an algebraic structure with programs as elements and with program compositions (sequential composition, choice, skip) as algebra operations. Various versions of these algebras were introduced to model partial correctness, total correctness, refinement, demonic choice, and other aspects. We formalize here an algebra which can be used to model total correctness, refinement, demonic and angelic choice. The basic model of this algebra are monotonic Boolean transformers (monotonic functions from a Boolean algebra to itself). notify = viorel.preoteasa@aalto.fi [LatticeProperties] title = Lattice Properties author = Viorel Preoteasa topic = Mathematics/Order date = 2011-09-22 abstract = This formalization introduces and collects some algebraic structures based on lattices and complete lattices for use in other developments. The structures introduced are modular, and lattice ordered groups. In addition to the results proved for the new lattices, this formalization also introduces theorems about latices and complete lattices in general. extra-history = Change history: [2012-01-05]: Removed the theory about distributive complete lattices which is in the standard library now. Added a theory about well founded and transitive relations and a result about fixpoints in complete lattices and well founded relations. Moved the results about conjunctive and disjunctive functions to a new theory. Removed the syntactic classes for inf and sup which are in the standard library now. notify = viorel.preoteasa@aalto.fi [Impossible_Geometry] title = Proving the Impossibility of Trisecting an Angle and Doubling the Cube author = Ralph Romanos , Lawrence C. Paulson topic = Mathematics/Algebra, Mathematics/Geometry date = 2012-08-05 abstract = Squaring the circle, doubling the cube and trisecting an angle, using a compass and straightedge alone, are classic unsolved problems first posed by the ancient Greeks. All three problems were proved to be impossible in the 19th century. The following document presents the proof of the impossibility of solving the latter two problems using Isabelle/HOL, following a proof by Carrega. The proof uses elementary methods: no Galois theory or field extensions. The set of points constructible using a compass and straightedge is defined inductively. Radical expressions, which involve only square roots and arithmetic of rational numbers, are defined, and we find that all constructive points have radical coordinates. Finally, doubling the cube and trisecting certain angles requires solving certain cubic equations that can be proved to have no rational roots. The Isabelle proofs require a great many detailed calculations. notify = ralph.romanos@student.ecp.fr, lp15@cam.ac.uk [IP_Addresses] title = IP Addresses author = Cornelius Diekmann , Julius Michaelis , Lars Hupel notify = diekmann@net.in.tum.de date = 2016-06-28 topic = Computer science/Networks abstract = This entry contains a definition of IP addresses and a library to work with them. Generic IP addresses are modeled as machine words of arbitrary length. Derived from this generic definition, IPv4 addresses are 32bit machine words, IPv6 addresses are 128bit words. Additionally, IPv4 addresses can be represented in dot-decimal notation and IPv6 addresses in (compressed) colon-separated notation. We support toString functions and parsers for both notations. Sets of IP addresses can be represented with a netmask (e.g. 192.168.0.0/255.255.0.0) or in CIDR notation (e.g. 192.168.0.0/16). To provide executable code for set operations on IP address ranges, the library includes a datatype to work on arbitrary intervals of machine words. [Simple_Firewall] title = Simple Firewall author = Cornelius Diekmann , Julius Michaelis , Maximilian Haslbeck notify = diekmann@net.in.tum.de, max.haslbeck@gmx.de date = 2016-08-24 topic = Computer science/Networks abstract = We present a simple model of a firewall. The firewall can accept or drop a packet and can match on interfaces, IP addresses, protocol, and ports. It was designed to feature nice mathematical properties: The type of match expressions was carefully crafted such that the conjunction of two match expressions is only one match expression. This model is too simplistic to mirror all aspects of the real world. In the upcoming entry "Iptables Semantics", we will translate the Linux firewall iptables to this model. For a fixed service (e.g. ssh, http), we provide an algorithm to compute an overview of the firewall's filtering behavior. The algorithm computes minimal service matrices, i.e. graphs which partition the complete IPv4 and IPv6 address space and visualize the allowed accesses between partitions. For a detailed description, see Verified iptables Firewall Analysis, IFIP Networking 2016. [Iptables_Semantics] title = Iptables Semantics author = Cornelius Diekmann , Lars Hupel notify = diekmann@net.in.tum.de, hupel@in.tum.de date = 2016-09-09 topic = Computer science/Networks abstract = We present a big step semantics of the filtering behavior of the Linux/netfilter iptables firewall. We provide algorithms to simplify complex iptables rulests to a simple firewall model (c.f. AFP entry Simple_Firewall) and to verify spoofing protection of a ruleset. Internally, we embed our semantics into ternary logic, ultimately supporting every iptables match condition by abstracting over unknowns. Using this AFP entry and all entries it depends on, we created an easy-to-use, stand-alone haskell tool called fffuu. The tool does not require any input —except for the iptables-save dump of the analyzed firewall— and presents interesting results about the user's ruleset. Real-Word firewall errors have been uncovered, and the correctness of rulesets has been proved, with the help of our tool. [Routing] title = Routing author = Julius Michaelis , Cornelius Diekmann notify = afp@liftm.de date = 2016-08-31 topic = Computer science/Networks abstract = This entry contains definitions for routing with routing tables/longest prefix matching. A routing table entry is modelled as a record of a prefix match, a metric, an output port, and an optional next hop. A routing table is a list of entries, sorted by prefix length and metric. Additionally, a parser and serializer for the output of the ip-route command, a function to create a relation from output port to corresponding destination IP space, and a model of a Linux-style router are included. [KBPs] title = Knowledge-based programs author = Peter Gammie topic = Computer science/Automata and formal languages date = 2011-05-17 abstract = Knowledge-based programs (KBPs) are a formalism for directly relating agents' knowledge and behaviour. Here we present a general scheme for compiling KBPs to executable automata with a proof of correctness in Isabelle/HOL. We develop the algorithm top-down, using Isabelle's locale mechanism to structure these proofs, and show that two classic examples can be synthesised using Isabelle's code generator. extra-history = Change history: [2012-03-06]: Add some more views and revive the code generation. notify = kleing@cse.unsw.edu.au [Tarskis_Geometry] title = The independence of Tarski's Euclidean axiom author = T. J. M. Makarios topic = Mathematics/Geometry date = 2012-10-30 abstract = Tarski's axioms of plane geometry are formalized and, using the standard real Cartesian model, shown to be consistent. A substantial theory of the projective plane is developed. Building on this theory, the Klein-Beltrami model of the hyperbolic plane is defined and shown to satisfy all of Tarski's axioms except his Euclidean axiom; thus Tarski's Euclidean axiom is shown to be independent of his other axioms of plane geometry.

An earlier version of this work was the subject of the author's MSc thesis, which contains natural-language explanations of some of the more interesting proofs. notify = tjm1983@gmail.com [IsaGeoCoq] title = Tarski's Parallel Postulate implies the 5th Postulate of Euclid, the Postulate of Playfair and the original Parallel Postulate of Euclid author = Roland Coghetto topic = Mathematics/Geometry license = LGPL date = 2021-01-31 notify = roland_coghetto@hotmail.com abstract =

The GeoCoq library contains a formalization of geometry using the Coq proof assistant. It contains both proofs about the foundations of geometry and high-level proofs in the same style as in high school. We port a part of the GeoCoq 2.4.0 library to Isabelle/HOL: more precisely, the files Chap02.v to Chap13_3.v, suma.v as well as the associated definitions and some useful files for the demonstration of certain parallel postulates. The synthetic approach of the demonstrations is directly inspired by those contained in GeoCoq. The names of the lemmas and theorems used are kept as far as possible as well as the definitions.

It should be noted that T.J.M. Makarios has done some proofs in Tarski's Geometry. It uses a definition that does not quite coincide with the definition used in Geocoq and here. Furthermore, corresponding definitions in the Poincaré Disc Model development are not identical to those defined in GeoCoq.

In the last part, it is formalized that, in the neutral/absolute space, the axiom of the parallels of Tarski's system implies the Playfair axiom, the 5th postulate of Euclid and Euclid's original parallel postulate. These proofs, which are not constructive, are directly inspired by Pierre Boutry, Charly Gries, Julien Narboux and Pascal Schreck.

[General-Triangle] title = The General Triangle Is Unique author = Joachim Breitner topic = Mathematics/Geometry date = 2011-04-01 abstract = Some acute-angled triangles are special, e.g. right-angled or isoscele triangles. Some are not of this kind, but, without measuring angles, look as if they were. In that sense, there is exactly one general triangle. This well-known fact is proven here formally. notify = mail@joachim-breitner.de [LightweightJava] title = Lightweight Java author = Rok Strniša , Matthew Parkinson topic = Computer science/Programming languages/Language definitions date = 2011-02-07 abstract = A fully-formalized and extensible minimal imperative fragment of Java. notify = rok@strnisa.com [Lower_Semicontinuous] title = Lower Semicontinuous Functions author = Bogdan Grechuk topic = Mathematics/Analysis date = 2011-01-08 abstract = We define the notions of lower and upper semicontinuity for functions from a metric space to the extended real line. We prove that a function is both lower and upper semicontinuous if and only if it is continuous. We also give several equivalent characterizations of lower semicontinuity. In particular, we prove that a function is lower semicontinuous if and only if its epigraph is a closed set. Also, we introduce the notion of the lower semicontinuous hull of an arbitrary function and prove its basic properties. notify = hoelzl@in.tum.de [RIPEMD-160-SPARK] title = RIPEMD-160 author = Fabian Immler topic = Computer science/Programming languages/Static analysis date = 2011-01-10 abstract = This work presents a verification of an implementation in SPARK/ADA of the cryptographic hash-function RIPEMD-160. A functional specification of RIPEMD-160 is given in Isabelle/HOL. Proofs for the verification conditions generated by the static-analysis toolset of SPARK certify the functional correctness of the implementation. extra-history = Change history: [2015-11-09]: Entry is now obsolete, moved to Isabelle distribution. notify = immler@in.tum.de [Regular-Sets] title = Regular Sets and Expressions author = Alexander Krauss , Tobias Nipkow contributors = Manuel Eberl topic = Computer science/Automata and formal languages date = 2010-05-12 abstract = This is a library of constructions on regular expressions and languages. It provides the operations of concatenation, Kleene star and derivative on languages. Regular expressions and their meaning are defined. An executable equivalence checker for regular expressions is verified; it does not need automata but works directly on regular expressions. By mapping regular expressions to binary relations, an automatic and complete proof method for (in)equalities of binary relations over union, concatenation and (reflexive) transitive closure is obtained.

Extended regular expressions with complement and intersection are also defined and an equivalence checker is provided. extra-history = Change history: [2011-08-26]: Christian Urban added a theory about derivatives and partial derivatives of regular expressions
[2012-05-10]: Tobias Nipkow added extended regular expressions
[2012-05-10]: Tobias Nipkow added equivalence checking with partial derivatives notify = nipkow@in.tum.de, krauss@in.tum.de, christian.urban@kcl.ac.uk [Regex_Equivalence] title = Unified Decision Procedures for Regular Expression Equivalence author = Tobias Nipkow , Dmitriy Traytel topic = Computer science/Automata and formal languages date = 2014-01-30 abstract = We formalize a unified framework for verified decision procedures for regular expression equivalence. Five recently published formalizations of such decision procedures (three based on derivatives, two on marked regular expressions) can be obtained as instances of the framework. We discover that the two approaches based on marked regular expressions, which were previously thought to be the same, are different, and one seems to produce uniformly smaller automata. The common framework makes it possible to compare the performance of the different decision procedures in a meaningful way. The formalization is described in a paper of the same name presented at Interactive Theorem Proving 2014. notify = nipkow@in.tum.de, traytel@in.tum.de [MSO_Regex_Equivalence] title = Decision Procedures for MSO on Words Based on Derivatives of Regular Expressions author = Dmitriy Traytel , Tobias Nipkow topic = Computer science/Automata and formal languages, Logic/General logic/Decidability of theories date = 2014-06-12 abstract = Monadic second-order logic on finite words (MSO) is a decidable yet expressive logic into which many decision problems can be encoded. Since MSO formulas correspond to regular languages, equivalence of MSO formulas can be reduced to the equivalence of some regular structures (e.g. automata). We verify an executable decision procedure for MSO formulas that is not based on automata but on regular expressions.

Decision procedures for regular expression equivalence have been formalized before, usually based on Brzozowski derivatives. Yet, for a straightforward embedding of MSO formulas into regular expressions an extension of regular expressions with a projection operation is required. We prove total correctness and completeness of an equivalence checker for regular expressions extended in that way. We also define a language-preserving translation of formulas into regular expressions with respect to two different semantics of MSO.

The formalization is described in this ICFP 2013 functional pearl. notify = traytel@in.tum.de, nipkow@in.tum.de [Formula_Derivatives] title = Derivatives of Logical Formulas author = Dmitriy Traytel topic = Computer science/Automata and formal languages, Logic/General logic/Decidability of theories date = 2015-05-28 abstract = We formalize new decision procedures for WS1S, M2L(Str), and Presburger Arithmetics. Formulas of these logics denote regular languages. Unlike traditional decision procedures, we do not translate formulas into automata (nor into regular expressions), at least not explicitly. Instead we devise notions of derivatives (inspired by Brzozowski derivatives for regular expressions) that operate on formulas directly and compute a syntactic bisimulation using these derivatives. The treatment of Boolean connectives and quantifiers is uniform for all mentioned logics and is abstracted into a locale. This locale is then instantiated by different atomic formulas and their derivatives (which may differ even for the same logic under different encodings of interpretations as formal words).

The WS1S instance is described in the draft paper A Coalgebraic Decision Procedure for WS1S by the author. notify = traytel@in.tum.de [Myhill-Nerode] title = The Myhill-Nerode Theorem Based on Regular Expressions author = Chunhan Wu <>, Xingyuan Zhang <>, Christian Urban contributors = Manuel Eberl topic = Computer science/Automata and formal languages date = 2011-08-26 abstract = There are many proofs of the Myhill-Nerode theorem using automata. In this library we give a proof entirely based on regular expressions, since regularity of languages can be conveniently defined using regular expressions (it is more painful in HOL to define regularity in terms of automata). We prove the first direction of the Myhill-Nerode theorem by solving equational systems that involve regular expressions. For the second direction we give two proofs: one using tagging-functions and another using partial derivatives. We also establish various closure properties of regular languages. Most details of the theories are described in our ITP 2011 paper. notify = christian.urban@kcl.ac.uk [Universal_Turing_Machine] title = Universal Turing Machine author = Jian Xu<>, Xingyuan Zhang<>, Christian Urban , Sebastiaan J. C. Joosten topic = Logic/Computability, Computer science/Automata and formal languages date = 2019-02-08 notify = sjcjoosten@gmail.com, christian.urban@kcl.ac.uk abstract = We formalise results from computability theory: recursive functions, undecidability of the halting problem, and the existence of a universal Turing machine. This formalisation is the AFP entry corresponding to the paper Mechanising Turing Machines and Computability Theory in Isabelle/HOL, ITP 2013. [CYK] title = A formalisation of the Cocke-Younger-Kasami algorithm author = Maksym Bortin date = 2016-04-27 topic = Computer science/Algorithms, Computer science/Automata and formal languages abstract = The theory provides a formalisation of the Cocke-Younger-Kasami algorithm (CYK for short), an approach to solving the word problem for context-free languages. CYK decides if a word is in the languages generated by a context-free grammar in Chomsky normal form. The formalized algorithm is executable. notify = maksym.bortin@nicta.com.au [Boolean_Expression_Checkers] title = Boolean Expression Checkers author = Tobias Nipkow date = 2014-06-08 topic = Computer science/Algorithms, Logic/General logic/Mechanization of proofs abstract = This entry provides executable checkers for the following properties of boolean expressions: satisfiability, tautology and equivalence. Internally, the checkers operate on binary decision trees and are reasonably efficient (for purely functional algorithms). extra-history = Change history: [2015-09-23]: Salomon Sickert added an interface that does not require the usage of the Boolean formula datatype. Furthermore the general Mapping type is used instead of an association list. notify = nipkow@in.tum.de [Presburger-Automata] title = Formalizing the Logic-Automaton Connection author = Stefan Berghofer , Markus Reiter <> date = 2009-12-03 topic = Computer science/Automata and formal languages, Logic/General logic/Decidability of theories abstract = This work presents a formalization of a library for automata on bit strings. It forms the basis of a reflection-based decision procedure for Presburger arithmetic, which is efficiently executable thanks to Isabelle's code generator. With this work, we therefore provide a mechanized proof of a well-known connection between logic and automata theory. The formalization is also described in a publication [TPHOLs 2009]. notify = berghofe@in.tum.de [Functional-Automata] title = Functional Automata author = Tobias Nipkow date = 2004-03-30 topic = Computer science/Automata and formal languages abstract = This theory defines deterministic and nondeterministic automata in a functional representation: the transition function/relation and the finality predicate are just functions. Hence the state space may be infinite. It is shown how to convert regular expressions into such automata. A scanner (generator) is implemented with the help of functional automata: the scanner chops the input up into longest recognized substrings. Finally we also show how to convert a certain subclass of functional automata (essentially the finite deterministic ones) into regular sets. notify = nipkow@in.tum.de [Statecharts] title = Formalizing Statecharts using Hierarchical Automata author = Steffen Helke , Florian Kammüller topic = Computer science/Automata and formal languages date = 2010-08-08 abstract = We formalize in Isabelle/HOL the abtract syntax and a synchronous step semantics for the specification language Statecharts. The formalization is based on Hierarchical Automata which allow a structural decomposition of Statecharts into Sequential Automata. To support the composition of Statecharts, we introduce calculating operators to construct a Hierarchical Automaton in a stepwise manner. Furthermore, we present a complete semantics of Statecharts including a theory of data spaces, which enables the modelling of racing effects. We also adapt CTL for Statecharts to build a bridge for future combinations with model checking. However the main motivation of this work is to provide a sound and complete basis for reasoning on Statecharts. As a central meta theorem we prove that the well-formedness of a Statechart is preserved by the semantics. notify = nipkow@in.tum.de [Stuttering_Equivalence] title = Stuttering Equivalence author = Stephan Merz topic = Computer science/Automata and formal languages date = 2012-05-07 abstract =

Two omega-sequences are stuttering equivalent if they differ only by finite repetitions of elements. Stuttering equivalence is a fundamental concept in the theory of concurrent and distributed systems. Notably, Lamport argues that refinement notions for such systems should be insensitive to finite stuttering. Peled and Wilke showed that all PLTL (propositional linear-time temporal logic) properties that are insensitive to stuttering equivalence can be expressed without the next-time operator. Stuttering equivalence is also important for certain verification techniques such as partial-order reduction for model checking.

We formalize stuttering equivalence in Isabelle/HOL. Our development relies on the notion of stuttering sampling functions that may skip blocks of identical sequence elements. We also encode PLTL and prove the theorem due to Peled and Wilke.

extra-history = Change history: [2013-01-31]: Added encoding of PLTL and proved Peled and Wilke's theorem. Adjusted abstract accordingly. notify = Stephan.Merz@loria.fr [Coinductive_Languages] title = A Codatatype of Formal Languages author = Dmitriy Traytel topic = Computer science/Automata and formal languages date = 2013-11-15 abstract =

We define formal languages as a codataype of infinite trees branching over the alphabet. Each node in such a tree indicates whether the path to this node constitutes a word inside or outside of the language. This codatatype is isormorphic to the set of lists representation of languages, but caters for definitions by corecursion and proofs by coinduction.

Regular operations on languages are then defined by primitive corecursion. A difficulty arises here, since the standard definitions of concatenation and iteration from the coalgebraic literature are not primitively corecursive-they require guardedness up-to union/concatenation. Without support for up-to corecursion, these operation must be defined as a composition of primitive ones (and proved being equal to the standard definitions). As an exercise in coinduction we also prove the axioms of Kleene algebra for the defined regular operations.

Furthermore, a language for context-free grammars given by productions in Greibach normal form and an initial nonterminal is constructed by primitive corecursion, yielding an executable decision procedure for the word problem without further ado.

notify = traytel@in.tum.de [Tree-Automata] title = Tree Automata author = Peter Lammich date = 2009-11-25 topic = Computer science/Automata and formal languages abstract = This work presents a machine-checked tree automata library for Standard-ML, OCaml and Haskell. The algorithms are efficient by using appropriate data structures like RB-trees. The available algorithms for non-deterministic automata include membership query, reduction, intersection, union, and emptiness check with computation of a witness for non-emptiness. The executable algorithms are derived from less-concrete, non-executable algorithms using data-refinement techniques. The concrete data structures are from the Isabelle Collections Framework. Moreover, this work contains a formalization of the class of tree-regular languages and its closure properties under set operations. notify = peter.lammich@uni-muenster.de, nipkow@in.tum.de [Depth-First-Search] title = Depth First Search author = Toshiaki Nishihara <>, Yasuhiko Minamide <> date = 2004-06-24 topic = Computer science/Algorithms/Graph abstract = Depth-first search of a graph is formalized with recdef. It is shown that it visits all of the reachable nodes from a given list of nodes. Executable ML code of depth-first search is obtained using the code generation feature of Isabelle/HOL. notify = lp15@cam.ac.uk, krauss@in.tum.de [FFT] title = Fast Fourier Transform author = Clemens Ballarin date = 2005-10-12 topic = Computer science/Algorithms/Mathematical abstract = We formalise a functional implementation of the FFT algorithm over the complex numbers, and its inverse. Both are shown equivalent to the usual definitions of these operations through Vandermonde matrices. They are also shown to be inverse to each other, more precisely, that composition of the inverse and the transformation yield the identity up to a scalar. notify = ballarin@in.tum.de [Gauss-Jordan-Elim-Fun] title = Gauss-Jordan Elimination for Matrices Represented as Functions author = Tobias Nipkow date = 2011-08-19 topic = Computer science/Algorithms/Mathematical, Mathematics/Algebra abstract = This theory provides a compact formulation of Gauss-Jordan elimination for matrices represented as functions. Its distinctive feature is succinctness. It is not meant for large computations. notify = nipkow@in.tum.de [UpDown_Scheme] title = Verification of the UpDown Scheme author = Johannes Hölzl date = 2015-01-28 topic = Computer science/Algorithms/Mathematical abstract = The UpDown scheme is a recursive scheme used to compute the stiffness matrix on a special form of sparse grids. Usually, when discretizing a Euclidean space of dimension d we need O(n^d) points, for n points along each dimension. Sparse grids are a hierarchical representation where the number of points is reduced to O(n * log(n)^d). One disadvantage of such sparse grids is that the algorithm now operate recursively in the dimensions and levels of the sparse grid.

The UpDown scheme allows us to compute the stiffness matrix on such a sparse grid. The stiffness matrix represents the influence of each representation function on the L^2 scalar product. For a detailed description see Dirk Pflüger's PhD thesis. This formalization was developed as an interdisciplinary project (IDP) at the Technische Universität München. notify = hoelzl@in.tum.de [GraphMarkingIBP] title = Verification of the Deutsch-Schorr-Waite Graph Marking Algorithm using Data Refinement author = Viorel Preoteasa , Ralph-Johan Back date = 2010-05-28 topic = Computer science/Algorithms/Graph abstract = The verification of the Deutsch-Schorr-Waite graph marking algorithm is used as a benchmark in many formalizations of pointer programs. The main purpose of this mechanization is to show how data refinement of invariant based programs can be used in verifying practical algorithms. The verification starts with an abstract algorithm working on a graph given by a relation next on nodes. Gradually the abstract program is refined into Deutsch-Schorr-Waite graph marking algorithm where only one bit per graph node of additional memory is used for marking. extra-history = Change history: [2012-01-05]: Updated for the new definition of data refinement and the new syntax for demonic and angelic update statements notify = viorel.preoteasa@aalto.fi [Efficient-Mergesort] title = Efficient Mergesort topic = Computer science/Algorithms date = 2011-11-09 author = Christian Sternagel abstract = We provide a formalization of the mergesort algorithm as used in GHC's Data.List module, proving correctness and stability. Furthermore, experimental data suggests that generated (Haskell-)code for this algorithm is much faster than for previous algorithms available in the Isabelle distribution. extra-history = Change history: [2012-10-24]: Added reference to journal article.
[2018-09-17]: Added theory Efficient_Mergesort that works exclusively with the mutual induction schemas generated by the function package.
[2018-09-19]: Added theory Mergesort_Complexity that proves an upper bound on the number of comparisons that are required by mergesort.
[2018-09-19]: Theory Efficient_Mergesort replaces theory Efficient_Sort but keeping the old name Efficient_Sort. [2020-11-20]: Additional theory Natural_Mergesort that developes an efficient mergesort algorithm without key-functions for educational purposes. notify = c.sternagel@gmail.com [SATSolverVerification] title = Formal Verification of Modern SAT Solvers author = Filip Marić date = 2008-07-23 topic = Computer science/Algorithms abstract = This document contains formal correctness proofs of modern SAT solvers. Following (Krstic et al, 2007) and (Nieuwenhuis et al., 2006), solvers are described using state-transition systems. Several different SAT solver descriptions are given and their partial correctness and termination is proved. These include:

  • a solver based on classical DPLL procedure (using only a backtrack-search with unit propagation),
  • a very general solver with backjumping and learning (similar to the description given in (Nieuwenhuis et al., 2006)), and
  • a solver with a specific conflict analysis algorithm (similar to the description given in (Krstic et al., 2007)).
Within the SAT solver correctness proofs, a large number of lemmas about propositional logic and CNF formulae are proved. This theory is self-contained and could be used for further exploring of properties of CNF based SAT algorithms. notify = [Transitive-Closure] title = Executable Transitive Closures of Finite Relations topic = Computer science/Algorithms/Graph date = 2011-03-14 author = Christian Sternagel , René Thiemann license = LGPL abstract = We provide a generic work-list algorithm to compute the transitive closure of finite relations where only successors of newly detected states are generated. This algorithm is then instantiated for lists over arbitrary carriers and red black trees (which are faster but require a linear order on the carrier), respectively. Our formalization was performed as part of the IsaFoR/CeTA project where reflexive transitive closures of large tree automata have to be computed. extra-history = Change history: [2014-09-04] added example simprocs in Finite_Transitive_Closure_Simprocs notify = c.sternagel@gmail.com, rene.thiemann@uibk.ac.at [Transitive-Closure-II] title = Executable Transitive Closures topic = Computer science/Algorithms/Graph date = 2012-02-29 author = René Thiemann license = LGPL abstract =

We provide a generic work-list algorithm to compute the (reflexive-)transitive closure of relations where only successors of newly detected states are generated. In contrast to our previous work, the relations do not have to be finite, but each element must only have finitely many (indirect) successors. Moreover, a subsumption relation can be used instead of pure equality. An executable variant of the algorithm is available where the generic operations are instantiated with list operations.

This formalization was performed as part of the IsaFoR/CeTA project, and it has been used to certify size-change termination proofs where large transitive closures have to be computed.

notify = rene.thiemann@uibk.ac.at [MuchAdoAboutTwo] title = Much Ado About Two author = Sascha Böhme date = 2007-11-06 topic = Computer science/Algorithms abstract = This article is an Isabelle formalisation of a paper with the same title. In a similar way as Knuth's 0-1-principle for sorting algorithms, that paper develops a 0-1-2-principle for parallel prefix computations. notify = boehmes@in.tum.de [DiskPaxos] title = Proving the Correctness of Disk Paxos date = 2005-06-22 author = Mauro Jaskelioff , Stephan Merz topic = Computer science/Algorithms/Distributed abstract = Disk Paxos is an algorithm for building arbitrary fault-tolerant distributed systems. The specification of Disk Paxos has been proved correct informally and tested using the TLC model checker, but up to now, it has never been fully formally verified. In this work we have formally verified its correctness using the Isabelle theorem prover and the HOL logic system, showing that Isabelle is a practical tool for verifying properties of TLA+ specifications. notify = kleing@cse.unsw.edu.au [GenClock] title = Formalization of a Generalized Protocol for Clock Synchronization author = Alwen Tiu date = 2005-06-24 topic = Computer science/Algorithms/Distributed abstract = We formalize the generalized Byzantine fault-tolerant clock synchronization protocol of Schneider. This protocol abstracts from particular algorithms or implementations for clock synchronization. This abstraction includes several assumptions on the behaviors of physical clocks and on general properties of concrete algorithms/implementations. Based on these assumptions the correctness of the protocol is proved by Schneider. His proof was later verified by Shankar using the theorem prover EHDM (precursor to PVS). Our formalization in Isabelle/HOL is based on Shankar's formalization. notify = kleing@cse.unsw.edu.au [ClockSynchInst] title = Instances of Schneider's generalized protocol of clock synchronization author = Damián Barsotti date = 2006-03-15 topic = Computer science/Algorithms/Distributed abstract = F. B. Schneider ("Understanding protocols for Byzantine clock synchronization") generalizes a number of protocols for Byzantine fault-tolerant clock synchronization and presents a uniform proof for their correctness. In Schneider's schema, each processor maintains a local clock by periodically adjusting each value to one computed by a convergence function applied to the readings of all the clocks. Then, correctness of an algorithm, i.e. that the readings of two clocks at any time are within a fixed bound of each other, is based upon some conditions on the convergence function. To prove that a particular clock synchronization algorithm is correct it suffices to show that the convergence function used by the algorithm meets Schneider's conditions. Using the theorem prover Isabelle, we formalize the proofs that the convergence functions of two algorithms, namely, the Interactive Convergence Algorithm (ICA) of Lamport and Melliar-Smith and the Fault-tolerant Midpoint algorithm of Lundelius-Lynch, meet Schneider's conditions. Furthermore, we experiment on handling some parts of the proofs with fully automatic tools like ICS and CVC-lite. These theories are part of a joint work with Alwen Tiu and Leonor P. Nieto "Verification of Clock Synchronization Algorithms: Experiments on a combination of deductive tools" in proceedings of AVOCS 2005. In this work the correctness of Schneider schema was also verified using Isabelle (entry GenClock in AFP). notify = kleing@cse.unsw.edu.au [Heard_Of] title = Verifying Fault-Tolerant Distributed Algorithms in the Heard-Of Model date = 2012-07-27 author = Henri Debrat , Stephan Merz topic = Computer science/Algorithms/Distributed abstract = Distributed computing is inherently based on replication, promising increased tolerance to failures of individual computing nodes or communication channels. Realizing this promise, however, involves quite subtle algorithmic mechanisms, and requires precise statements about the kinds and numbers of faults that an algorithm tolerates (such as process crashes, communication faults or corrupted values). The landmark theorem due to Fischer, Lynch, and Paterson shows that it is impossible to achieve Consensus among N asynchronously communicating nodes in the presence of even a single permanent failure. Existing solutions must rely on assumptions of "partial synchrony".

Indeed, there have been numerous misunderstandings on what exactly a given algorithm is supposed to realize in what kinds of environments. Moreover, the abundance of subtly different computational models complicates comparisons between different algorithms. Charron-Bost and Schiper introduced the Heard-Of model for representing algorithms and failure assumptions in a uniform framework, simplifying comparisons between algorithms.

In this contribution, we represent the Heard-Of model in Isabelle/HOL. We define two semantics of runs of algorithms with different unit of atomicity and relate these through a reduction theorem that allows us to verify algorithms in the coarse-grained semantics (where proofs are easier) and infer their correctness for the fine-grained one (which corresponds to actual executions). We instantiate the framework by verifying six Consensus algorithms that differ in the underlying algorithmic mechanisms and the kinds of faults they tolerate. notify = Stephan.Merz@loria.fr [Consensus_Refined] title = Consensus Refined date = 2015-03-18 author = Ognjen Maric <>, Christoph Sprenger topic = Computer science/Algorithms/Distributed abstract = Algorithms for solving the consensus problem are fundamental to distributed computing. Despite their brevity, their ability to operate in concurrent, asynchronous and failure-prone environments comes at the cost of complex and subtle behaviors. Accordingly, understanding how they work and proving their correctness is a non-trivial endeavor where abstraction is immensely helpful. Moreover, research on consensus has yielded a large number of algorithms, many of which appear to share common algorithmic ideas. A natural question is whether and how these similarities can be distilled and described in a precise, unified way. In this work, we combine stepwise refinement and lockstep models to provide an abstract and unified view of a sizeable family of consensus algorithms. Our models provide insights into the design choices underlying the different algorithms, and classify them based on those choices. notify = sprenger@inf.ethz.ch [Key_Agreement_Strong_Adversaries] title = Refining Authenticated Key Agreement with Strong Adversaries author = Joseph Lallemand , Christoph Sprenger topic = Computer science/Security license = LGPL date = 2017-01-31 notify = joseph.lallemand@loria.fr, sprenger@inf.ethz.ch abstract = We develop a family of key agreement protocols that are correct by construction. Our work substantially extends prior work on developing security protocols by refinement. First, we strengthen the adversary by allowing him to compromise different resources of protocol participants, such as their long-term keys or their session keys. This enables the systematic development of protocols that ensure strong properties such as perfect forward secrecy. Second, we broaden the class of protocols supported to include those with non-atomic keys and equationally defined cryptographic operators. We use these extensions to develop key agreement protocols including signed Diffie-Hellman and the core of IKEv1 and SKEME. [Security_Protocol_Refinement] title = Developing Security Protocols by Refinement author = Christoph Sprenger , Ivano Somaini<> topic = Computer science/Security license = LGPL date = 2017-05-24 notify = sprenger@inf.ethz.ch abstract = We propose a development method for security protocols based on stepwise refinement. Our refinement strategy transforms abstract security goals into protocols that are secure when operating over an insecure channel controlled by a Dolev-Yao-style intruder. As intermediate levels of abstraction, we employ messageless guard protocols and channel protocols communicating over channels with security properties. These abstractions provide insights on why protocols are secure and foster the development of families of protocols sharing common structure and properties. We have implemented our method in Isabelle/HOL and used it to develop different entity authentication and key establishment protocols, including realistic features such as key confirmation, replay caches, and encrypted tickets. Our development highlights that guard protocols and channel protocols provide fundamental abstractions for bridging the gap between security properties and standard protocol descriptions based on cryptographic messages. It also shows that our refinement approach scales to protocols of nontrivial size and complexity. [Abortable_Linearizable_Modules] title = Abortable Linearizable Modules author = Rachid Guerraoui , Viktor Kuncak , Giuliano Losa date = 2012-03-01 topic = Computer science/Algorithms/Distributed abstract = We define the Abortable Linearizable Module automaton (ALM for short) and prove its key composition property using the IOA theory of HOLCF. The ALM is at the heart of the Speculative Linearizability framework. This framework simplifies devising correct speculative algorithms by enabling their decomposition into independent modules that can be analyzed and proved correct in isolation. It is particularly useful when working in a distributed environment, where the need to tolerate faults and asynchrony has made current monolithic protocols so intricate that it is no longer tractable to check their correctness. Our theory contains a typical example of a refinement proof in the I/O-automata framework of Lynch and Tuttle. notify = giuliano@losa.fr, nipkow@in.tum.de [Amortized_Complexity] title = Amortized Complexity Verified author = Tobias Nipkow date = 2014-07-07 topic = Computer science/Data structures abstract = A framework for the analysis of the amortized complexity of functional data structures is formalized in Isabelle/HOL and applied to a number of standard examples and to the folowing non-trivial ones: skew heaps, splay trees, splay heaps and pairing heaps.

A preliminary version of this work (without pairing heaps) is described in a paper published in the proceedings of the conference on Interactive Theorem Proving ITP 2015. An extended version of this publication is available here. extra-history = Change history: [2015-03-17]: Added pairing heaps by Hauke Brinkop.
[2016-07-12]: Moved splay heaps from here to Splay_Tree
[2016-07-14]: Moved pairing heaps from here to the new Pairing_Heap notify = nipkow@in.tum.de [Dynamic_Tables] title = Parameterized Dynamic Tables author = Tobias Nipkow date = 2015-06-07 topic = Computer science/Data structures abstract = This article formalizes the amortized analysis of dynamic tables parameterized with their minimal and maximal load factors and the expansion and contraction factors.

A full description is found in a companion paper. notify = nipkow@in.tum.de [AVL-Trees] title = AVL Trees author = Tobias Nipkow , Cornelia Pusch <> date = 2004-03-19 topic = Computer science/Data structures abstract = Two formalizations of AVL trees with room for extensions. The first formalization is monolithic and shorter, the second one in two stages, longer and a bit simpler. The final implementation is the same. If you are interested in developing this further, please contact gerwin.klein@nicta.com.au. extra-history = Change history: [2011-04-11]: Ondrej Kuncar added delete function notify = kleing@cse.unsw.edu.au [BDD] title = BDD Normalisation author = Veronika Ortner <>, Norbert Schirmer <> date = 2008-02-29 topic = Computer science/Data structures abstract = We present the verification of the normalisation of a binary decision diagram (BDD). The normalisation follows the original algorithm presented by Bryant in 1986 and transforms an ordered BDD in a reduced, ordered and shared BDD. The verification is based on Hoare logics. notify = kleing@cse.unsw.edu.au, norbert.schirmer@web.de [BinarySearchTree] title = Binary Search Trees author = Viktor Kuncak date = 2004-04-05 topic = Computer science/Data structures abstract = The correctness is shown of binary search tree operations (lookup, insert and remove) implementing a set. Two versions are given, for both structured and linear (tactic-style) proofs. An implementation of integer-indexed maps is also verified. notify = lp15@cam.ac.uk [Splay_Tree] title = Splay Tree author = Tobias Nipkow notify = nipkow@in.tum.de date = 2014-08-12 topic = Computer science/Data structures abstract = Splay trees are self-adjusting binary search trees which were invented by Sleator and Tarjan [JACM 1985]. This entry provides executable and verified functional splay trees as well as the related splay heaps (due to Okasaki).

The amortized complexity of splay trees and heaps is analyzed in the AFP entry Amortized Complexity. extra-history = Change history: [2016-07-12]: Moved splay heaps here from Amortized_Complexity [Root_Balanced_Tree] title = Root-Balanced Tree author = Tobias Nipkow notify = nipkow@in.tum.de date = 2017-08-20 topic = Computer science/Data structures abstract =

Andersson introduced general balanced trees, search trees based on the design principle of partial rebuilding: perform update operations naively until the tree becomes too unbalanced, at which point a whole subtree is rebalanced. This article defines and analyzes a functional version of general balanced trees, which we call root-balanced trees. Using a lightweight model of execution time, amortized logarithmic complexity is verified in the theorem prover Isabelle.

This is the Isabelle formalization of the material decribed in the APLAS 2017 article Verified Root-Balanced Trees by the same author, which also presents experimental results that show competitiveness of root-balanced with AVL and red-black trees.

[Skew_Heap] title = Skew Heap author = Tobias Nipkow date = 2014-08-13 topic = Computer science/Data structures abstract = Skew heaps are an amazingly simple and lightweight implementation of priority queues. They were invented by Sleator and Tarjan [SIAM 1986] and have logarithmic amortized complexity. This entry provides executable and verified functional skew heaps.

The amortized complexity of skew heaps is analyzed in the AFP entry Amortized Complexity. notify = nipkow@in.tum.de [Pairing_Heap] title = Pairing Heap author = Hauke Brinkop , Tobias Nipkow date = 2016-07-14 topic = Computer science/Data structures abstract = This library defines three different versions of pairing heaps: a functional version of the original design based on binary trees [Fredman et al. 1986], the version by Okasaki [1998] and a modified version of the latter that is free of structural invariants.

The amortized complexity of pairing heaps is analyzed in the AFP article Amortized Complexity. extra-0 = Origin: This library was extracted from Amortized Complexity and extended. notify = nipkow@in.tum.de [Priority_Queue_Braun] title = Priority Queues Based on Braun Trees author = Tobias Nipkow date = 2014-09-04 topic = Computer science/Data structures abstract = This entry verifies priority queues based on Braun trees. Insertion and deletion take logarithmic time and preserve the balanced nature of Braun trees. Two implementations of deletion are provided. notify = nipkow@in.tum.de extra-history = Change history: [2019-12-16]: Added theory Priority_Queue_Braun2 with second version of del_min [Binomial-Queues] title = Functional Binomial Queues author = René Neumann date = 2010-10-28 topic = Computer science/Data structures abstract = Priority queues are an important data structure and efficient implementations of them are crucial. We implement a functional variant of binomial queues in Isabelle/HOL and show its functional correctness. A verification against an abstract reference specification of priority queues has also been attempted, but could not be achieved to the full extent. notify = florian.haftmann@informatik.tu-muenchen.de [Binomial-Heaps] title = Binomial Heaps and Skew Binomial Heaps author = Rene Meis , Finn Nielsen , Peter Lammich date = 2010-10-28 topic = Computer science/Data structures abstract = We implement and prove correct binomial heaps and skew binomial heaps. Both are data-structures for priority queues. While binomial heaps have logarithmic findMin, deleteMin, insert, and meld operations, skew binomial heaps have constant time findMin, insert, and meld operations, and only the deleteMin-operation is logarithmic. This is achieved by using skew links to avoid cascading linking on insert-operations, and data-structural bootstrapping to get constant-time findMin and meld operations. Our implementation follows the paper by Brodal and Okasaki. notify = peter.lammich@uni-muenster.de [Finger-Trees] title = Finger Trees author = Benedikt Nordhoff , Stefan Körner , Peter Lammich date = 2010-10-28 topic = Computer science/Data structures abstract = We implement and prove correct 2-3 finger trees. Finger trees are a general purpose data structure, that can be used to efficiently implement other data structures, such as priority queues. Intuitively, a finger tree is an annotated sequence, where the annotations are elements of a monoid. Apart from operations to access the ends of the sequence, the main operation is to split the sequence at the point where a monotone predicate over the sum of the left part of the sequence becomes true for the first time. The implementation follows the paper of Hinze and Paterson. The code generator can be used to get efficient, verified code. notify = peter.lammich@uni-muenster.de [Trie] title = Trie author = Andreas Lochbihler , Tobias Nipkow date = 2015-03-30 topic = Computer science/Data structures abstract = This article formalizes the ``trie'' data structure invented by Fredkin [CACM 1960]. It also provides a specialization where the entries in the trie are lists. extra-0 = Origin: This article was extracted from existing articles by the authors. notify = nipkow@in.tum.de [FinFun] title = Code Generation for Functions as Data author = Andreas Lochbihler date = 2009-05-06 topic = Computer science/Data structures abstract = FinFuns are total functions that are constant except for a finite set of points, i.e. a generalisation of finite maps. They are formalised as a new type in Isabelle/HOL such that the code generator can handle equality tests and quantification on FinFuns. On the code output level, FinFuns are explicitly represented by constant functions and pointwise updates, similarly to associative lists. Inside the logic, they behave like ordinary functions with extensionality. Via the update/constant pattern, a recursion combinator and an induction rule for FinFuns allow for defining and reasoning about operators on FinFun that are also executable. extra-history = Change history: [2010-08-13]: new concept domain of a FinFun as a FinFun (revision 34b3517cbc09)
[2010-11-04]: new conversion function from FinFun to list of elements in the domain (revision 0c167102e6ed)
[2012-03-07]: replace sets as FinFuns by predicates as FinFuns because the set type constructor has been reintroduced (revision b7aa87989f3a) notify = nipkow@in.tum.de [Collections] title = Collections Framework author = Peter Lammich contributors = Andreas Lochbihler , Thomas Tuerk <> date = 2009-11-25 topic = Computer science/Data structures abstract = This development provides an efficient, extensible, machine checked collections framework. The library adopts the concepts of interface, implementation and generic algorithm from object-oriented programming and implements them in Isabelle/HOL. The framework features the use of data refinement techniques to refine an abstract specification (using high-level concepts like sets) to a more concrete implementation (using collection datastructures, like red-black-trees). The code-generator of Isabelle/HOL can be used to generate efficient code. extra-history = Change history: [2010-10-08]: New Interfaces: OrderedSet, OrderedMap, List. Fifo now implements list-interface: Function names changed: put/get --> enqueue/dequeue. New Implementations: ArrayList, ArrayHashMap, ArrayHashSet, TrieMap, TrieSet. Invariant-free datastructures: Invariant implicitely hidden in typedef. Record-interfaces: All operations of an interface encapsulated as record. Examples moved to examples subdirectory.
[2010-12-01]: New Interfaces: Priority Queues, Annotated Lists. Implemented by finger trees, (skew) binomial queues.
[2011-10-10]: SetSpec: Added operations: sng, isSng, bexists, size_abort, diff, filter, iterate_rule_insertP MapSpec: Added operations: sng, isSng, iterate_rule_insertP, bexists, size, size_abort, restrict, map_image_filter, map_value_image_filter Some maintenance changes
[2012-04-25]: New iterator foundation by Tuerk. Various maintenance changes.
[2012-08]: Collections V2. New features: Polymorphic iterators. Generic algorithm instantiation where required. Naming scheme changed from xx_opname to xx.opname. A compatibility file CollectionsV1 tries to simplify porting of existing theories, by providing old naming scheme and the old monomorphic iterator locales.
[2013-09]: Added Generic Collection Framework based on Autoref. The GenCF provides: Arbitrary nesting, full integration with Autoref.
[2014-06]: Maintenace changes to GenCF: Optimized inj_image on list_set. op_set_cart (Cartesian product). big-Union operation. atLeastLessThan - operation ({a..<b})
notify = lammich@in.tum.de [Containers] title = Light-weight Containers author = Andreas Lochbihler contributors = René Thiemann date = 2013-04-15 topic = Computer science/Data structures abstract = This development provides a framework for container types like sets and maps such that generated code implements these containers with different (efficient) data structures. Thanks to type classes and refinement during code generation, this light-weight approach can seamlessly replace Isabelle's default setup for code generation. Heuristics automatically pick one of the available data structures depending on the type of elements to be stored, but users can also choose on their own. The extensible design permits to add more implementations at any time.

To support arbitrary nesting of sets, we define a linear order on sets based on a linear order of the elements and provide efficient implementations. It even allows to compare complements with non-complements. extra-history = Change history: [2013-07-11]: add pretty printing for sets (revision 7f3f52c5f5fa)
[2013-09-20]: provide generators for canonical type class instantiations (revision 159f4401f4a8 by René Thiemann)
[2014-07-08]: add support for going from partial functions to mappings (revision 7a6fc957e8ed)
[2018-03-05]: add two application examples: depth-first search and 2SAT (revision e5e1a1da2411) notify = mail@andreas-lochbihler.de [FileRefinement] title = File Refinement author = Karen Zee , Viktor Kuncak date = 2004-12-09 topic = Computer science/Data structures abstract = These theories illustrates the verification of basic file operations (file creation, file read and file write) in the Isabelle theorem prover. We describe a file at two levels of abstraction: an abstract file represented as a resizable array, and a concrete file represented using data blocks. notify = kkz@mit.edu [Datatype_Order_Generator] title = Generating linear orders for datatypes author = René Thiemann date = 2012-08-07 topic = Computer science/Data structures abstract = We provide a framework for registering automatic methods to derive class instances of datatypes, as it is possible using Haskell's ``deriving Ord, Show, ...'' feature.

We further implemented such automatic methods to derive (linear) orders or hash-functions which are required in the Isabelle Collection Framework. Moreover, for the tactic of Huffman and Krauss to show that a datatype is countable, we implemented a wrapper so that this tactic becomes accessible in our framework.

Our formalization was performed as part of the IsaFoR/CeTA project. With our new tactic we could completely remove tedious proofs for linear orders of two datatypes.

This development is aimed at datatypes generated by the "old_datatype" command. notify = rene.thiemann@uibk.ac.at [Deriving] title = Deriving class instances for datatypes author = Christian Sternagel , René Thiemann date = 2015-03-11 topic = Computer science/Data structures abstract =

We provide a framework for registering automatic methods to derive class instances of datatypes, as it is possible using Haskell's ``deriving Ord, Show, ...'' feature.

We further implemented such automatic methods to derive comparators, linear orders, parametrizable equality functions, and hash-functions which are required in the Isabelle Collection Framework and the Container Framework. Moreover, for the tactic of Blanchette to show that a datatype is countable, we implemented a wrapper so that this tactic becomes accessible in our framework. All of the generators are based on the infrastructure that is provided by the BNF-based datatype package.

Our formalization was performed as part of the IsaFoR/CeTA project. With our new tactics we could remove several tedious proofs for (conditional) linear orders, and conditional equality operators within IsaFoR and the Container Framework.

notify = rene.thiemann@uibk.ac.at [List-Index] title = List Index date = 2010-02-20 author = Tobias Nipkow topic = Computer science/Data structures abstract = This theory provides functions for finding the index of an element in a list, by predicate and by value. notify = nipkow@in.tum.de [List-Infinite] title = Infinite Lists date = 2011-02-23 author = David Trachtenherz <> topic = Computer science/Data structures abstract = We introduce a theory of infinite lists in HOL formalized as functions over naturals (folder ListInf, theories ListInf and ListInf_Prefix). It also provides additional results for finite lists (theory ListInf/List2), natural numbers (folder CommonArith, esp. division/modulo, naturals with infinity), sets (folder CommonSet, esp. cutting/truncating sets, traversing sets of naturals). notify = nipkow@in.tum.de [Matrix] title = Executable Matrix Operations on Matrices of Arbitrary Dimensions topic = Computer science/Data structures date = 2010-06-17 author = Christian Sternagel , René Thiemann license = LGPL abstract = We provide the operations of matrix addition, multiplication, transposition, and matrix comparisons as executable functions over ordered semirings. Moreover, it is proven that strongly normalizing (monotone) orders can be lifted to strongly normalizing (monotone) orders over matrices. We further show that the standard semirings over the naturals, integers, and rationals, as well as the arctic semirings satisfy the axioms that are required by our matrix theory. Our formalization is part of the CeTA system which contains several termination techniques. The provided theories have been essential to formalize matrix-interpretations and arctic interpretations. extra-history = Change history: [2010-09-17]: Moved theory on arbitrary (ordered) semirings to Abstract Rewriting. notify = rene.thiemann@uibk.ac.at, christian.sternagel@uibk.ac.at [Matrix_Tensor] title = Tensor Product of Matrices topic = Computer science/Data structures, Mathematics/Algebra date = 2016-01-18 author = T.V.H. Prathamesh abstract = In this work, the Kronecker tensor product of matrices and the proofs of some of its properties are formalized. Properties which have been formalized include associativity of the tensor product and the mixed-product property. notify = prathamesh@imsc.res.in [Huffman] title = The Textbook Proof of Huffman's Algorithm author = Jasmin Christian Blanchette date = 2008-10-15 topic = Computer science/Data structures abstract = Huffman's algorithm is a procedure for constructing a binary tree with minimum weighted path length. This report presents a formal proof of the correctness of Huffman's algorithm written using Isabelle/HOL. Our proof closely follows the sketches found in standard algorithms textbooks, uncovering a few snags in the process. Another distinguishing feature of our formalization is the use of custom induction rules to help Isabelle's automatic tactics, leading to very short proofs for most of the lemmas. notify = jasmin.blanchette@gmail.com [Partial_Function_MR] title = Mutually Recursive Partial Functions author = René Thiemann topic = Computer science/Functional programming date = 2014-02-18 license = LGPL abstract = We provide a wrapper around the partial-function command that supports mutual recursion. notify = rene.thiemann@uibk.ac.at [Lifting_Definition_Option] title = Lifting Definition Option author = René Thiemann topic = Computer science/Functional programming date = 2014-10-13 license = LGPL abstract = We implemented a command that can be used to easily generate elements of a restricted type {x :: 'a. P x}, provided the definition is of the form f ys = (if check ys then Some(generate ys :: 'a) else None) where ys is a list of variables y1 ... yn and check ys ==> P(generate ys) can be proved.

In principle, such a definition is also directly possible using the lift_definition command. However, then this definition will not be suitable for code-generation. To this end, we automated a more complex construction of Joachim Breitner which is amenable for code-generation, and where the test check ys will only be performed once. In the automation, one auxiliary type is created, and Isabelle's lifting- and transfer-package is invoked several times. notify = rene.thiemann@uibk.ac.at [Coinductive] title = Coinductive topic = Computer science/Functional programming author = Andreas Lochbihler contributors = Johannes Hölzl date = 2010-02-12 abstract = This article collects formalisations of general-purpose coinductive data types and sets. Currently, it contains coinductive natural numbers, coinductive lists, i.e. lazy lists or streams, infinite streams, coinductive terminated lists, coinductive resumptions, a library of operations on coinductive lists, and a version of König's lemma as an application for coinductive lists.
The initial theory was contributed by Paulson and Wenzel. Extensions and other coinductive formalisations of general interest are welcome. extra-history = Change history: [2010-06-10]: coinductive lists: setup for quotient package (revision 015574f3bf3c)
[2010-06-28]: new codatatype terminated lazy lists (revision e12de475c558)
[2010-08-04]: terminated lazy lists: setup for quotient package; more lemmas (revision 6ead626f1d01)
[2010-08-17]: Koenig's lemma as an example application for coinductive lists (revision f81ce373fa96)
[2011-02-01]: lazy implementation of coinductive (terminated) lists for the code generator (revision 6034973dce83)
[2011-07-20]: new codatatype resumption (revision 811364c776c7)
[2012-06-27]: new codatatype stream with operations (with contributions by Peter Gammie) (revision dd789a56473c)
[2013-03-13]: construct codatatypes with the BNF package and adjust the definitions and proofs, setup for lifting and transfer packages (revision f593eda5b2c0)
[2013-09-20]: stream theory uses type and operations from HOL/BNF/Examples/Stream (revision 692809b2b262)
[2014-04-03]: ccpo structure on codatatypes used to define ldrop, ldropWhile, lfilter, lconcat as least fixpoint; ccpo topology on coinductive lists contributed by Johannes Hölzl; added examples (revision 23cd8156bd42)
notify = mail@andreas-lochbihler.de [Stream-Fusion] title = Stream Fusion author = Brian Huffman topic = Computer science/Functional programming date = 2009-04-29 abstract = Stream Fusion is a system for removing intermediate list structures from Haskell programs; it consists of a Haskell library along with several compiler rewrite rules. (The library is available online.)

These theories contain a formalization of much of the Stream Fusion library in HOLCF. Lazy list and stream types are defined, along with coercions between the two types, as well as an equivalence relation for streams that generate the same list. List and stream versions of map, filter, foldr, enumFromTo, append, zipWith, and concatMap are defined, and the stream versions are shown to respect stream equivalence. notify = brianh@cs.pdx.edu [Tycon] title = Type Constructor Classes and Monad Transformers author = Brian Huffman date = 2012-06-26 topic = Computer science/Functional programming abstract = These theories contain a formalization of first class type constructors and axiomatic constructor classes for HOLCF. This work is described in detail in the ICFP 2012 paper Formal Verification of Monad Transformers by the author. The formalization is a revised and updated version of earlier joint work with Matthews and White.

Based on the hierarchy of type classes in Haskell, we define classes for functors, monads, monad-plus, etc. Each one includes all the standard laws as axioms. We also provide a new user command, tycondef, for defining new type constructors in HOLCF. Using tycondef, we instantiate the type class hierarchy with various monads and monad transformers. notify = huffman@in.tum.de [CoreC++] title = CoreC++ author = Daniel Wasserrab date = 2006-05-15 topic = Computer science/Programming languages/Language definitions abstract = We present an operational semantics and type safety proof for multiple inheritance in C++. The semantics models the behavior of method calls, field accesses, and two forms of casts in C++ class hierarchies. For explanations see the OOPSLA 2006 paper by Wasserrab, Nipkow, Snelting and Tip. notify = nipkow@in.tum.de [FeatherweightJava] title = A Theory of Featherweight Java in Isabelle/HOL author = J. Nathan Foster , Dimitrios Vytiniotis date = 2006-03-31 topic = Computer science/Programming languages/Language definitions abstract = We formalize the type system, small-step operational semantics, and type soundness proof for Featherweight Java, a simple object calculus, in Isabelle/HOL. notify = kleing@cse.unsw.edu.au [Jinja] title = Jinja is not Java author = Gerwin Klein , Tobias Nipkow date = 2005-06-01 topic = Computer science/Programming languages/Language definitions abstract = We introduce Jinja, a Java-like programming language with a formal semantics designed to exhibit core features of the Java language architecture. Jinja is a compromise between realism of the language and tractability and clarity of the formal semantics. The following aspects are formalised: a big and a small step operational semantics for Jinja and a proof of their equivalence; a type system and a definite initialisation analysis; a type safety proof of the small step semantics; a virtual machine (JVM), its operational semantics and its type system; a type safety proof for the JVM; a bytecode verifier, i.e. data flow analyser for the JVM; a correctness proof of the bytecode verifier w.r.t. the type system; a compiler and a proof that it preserves semantics and well-typedness. The emphasis of this work is not on particular language features but on providing a unified model of the source language, the virtual machine and the compiler. The whole development has been carried out in the theorem prover Isabelle/HOL. notify = kleing@cse.unsw.edu.au, nipkow@in.tum.de [JinjaThreads] title = Jinja with Threads author = Andreas Lochbihler date = 2007-12-03 topic = Computer science/Programming languages/Language definitions abstract = We extend the Jinja source code semantics by Klein and Nipkow with Java-style arrays and threads. Concurrency is captured in a generic framework semantics for adding concurrency through interleaving to a sequential semantics, which features dynamic thread creation, inter-thread communication via shared memory, lock synchronisation and joins. Also, threads can suspend themselves and be notified by others. We instantiate the framework with the adapted versions of both Jinja source and byte code and show type safety for the multithreaded case. Equally, the compiler from source to byte code is extended, for which we prove weak bisimilarity between the source code small step semantics and the defensive Jinja virtual machine. On top of this, we formalise the JMM and show the DRF guarantee and consistency. For description of the different parts, see Lochbihler's papers at FOOL 2008, ESOP 2010, ITP 2011, and ESOP 2012. extra-history = Change history: [2008-04-23]: added bytecode formalisation with arrays and threads, added thread joins (revision f74a8be156a7)
[2009-04-27]: added verified compiler from source code to bytecode; encapsulate native methods in separate semantics (revision e4f26541e58a)
[2009-11-30]: extended compiler correctness proof to infinite and deadlocking computations (revision e50282397435)
[2010-06-08]: added thread interruption; new abstract memory model with sequential consistency as implementation (revision 0cb9e8dbd78d)
[2010-06-28]: new thread interruption model (revision c0440d0a1177)
[2010-10-15]: preliminary version of the Java memory model for source code (revision 02fee0ef3ca2)
[2010-12-16]: improved version of the Java memory model, also for bytecode executable scheduler for source code semantics (revision 1f41c1842f5a)
[2011-02-02]: simplified code generator setup new random scheduler (revision 3059dafd013f)
[2011-07-21]: new interruption model, generalized JMM proof of DRF guarantee, allow class Object to declare methods and fields, simplified subtyping relation, corrected division and modulo implementation (revision 46e4181ed142)
[2012-02-16]: added example programs (revision bf0b06c8913d)
[2012-11-21]: type safety proof for the Java memory model, allow spurious wake-ups (revision 76063d860ae0)
[2013-05-16]: support for non-deterministic memory allocators (revision cc3344a49ced)
[2017-10-20]: add an atomic compare-and-swap operation for volatile fields (revision a6189b1d6b30)
notify = mail@andreas-lochbihler.de [Locally-Nameless-Sigma] title = Locally Nameless Sigma Calculus author = Ludovic Henrio , Florian Kammüller , Bianca Lutz , Henry Sudhof date = 2010-04-30 topic = Computer science/Programming languages/Language definitions abstract = We present a Theory of Objects based on the original functional sigma-calculus by Abadi and Cardelli but with an additional parameter to methods. We prove confluence of the operational semantics following the outline of Nipkow's proof of confluence for the lambda-calculus reusing his theory Commutation, a generic diamond lemma reduction. We furthermore formalize a simple type system for our sigma-calculus including a proof of type safety. The entire development uses the concept of Locally Nameless representation for binders. We reuse an earlier proof of confluence for a simpler sigma-calculus based on de Bruijn indices and lists to represent objects. notify = nipkow@in.tum.de [Attack_Trees] title = Attack Trees in Isabelle for GDPR compliance of IoT healthcare systems author = Florian Kammueller topic = Computer science/Security date = 2020-04-27 notify = florian.kammuller@gmail.com abstract = In this article, we present a proof theory for Attack Trees. Attack Trees are a well established and useful model for the construction of attacks on systems since they allow a stepwise exploration of high level attacks in application scenarios. Using the expressiveness of Higher Order Logic in Isabelle, we develop a generic theory of Attack Trees with a state-based semantics based on Kripke structures and CTL. The resulting framework allows mechanically supported logic analysis of the meta-theory of the proof calculus of Attack Trees and at the same time the developed proof theory enables application to case studies. A central correctness and completeness result proved in Isabelle establishes a connection between the notion of Attack Tree validity and CTL. The application is illustrated on the example of a healthcare IoT system and GDPR compliance verification. [AutoFocus-Stream] title = AutoFocus Stream Processing for Single-Clocking and Multi-Clocking Semantics author = David Trachtenherz <> date = 2011-02-23 topic = Computer science/Programming languages/Language definitions abstract = We formalize the AutoFocus Semantics (a time-synchronous subset of the Focus formalism) as stream processing functions on finite and infinite message streams represented as finite/infinite lists. The formalization comprises both the conventional single-clocking semantics (uniform global clock for all components and communications channels) and its extension to multi-clocking semantics (internal execution clocking of a component may be a multiple of the external communication clocking). The semantics is defined by generic stream processing functions making it suitable for simulation/code generation in Isabelle/HOL. Furthermore, a number of AutoFocus semantics properties are formalized using definitions from the IntervalLogic theories. notify = nipkow@in.tum.de [FocusStreamsCaseStudies] title = Stream Processing Components: Isabelle/HOL Formalisation and Case Studies author = Maria Spichkova date = 2013-11-14 topic = Computer science/Programming languages/Language definitions abstract = This set of theories presents an Isabelle/HOL formalisation of stream processing components introduced in Focus, a framework for formal specification and development of interactive systems. This is an extended and updated version of the formalisation, which was elaborated within the methodology "Focus on Isabelle". In addition, we also applied the formalisation on three case studies that cover different application areas: process control (Steam Boiler System), data transmission (FlexRay communication protocol), memory and processing components (Automotive-Gateway System). notify = lp15@cam.ac.uk, maria.spichkova@rmit.edu.au [Isabelle_Meta_Model] title = A Meta-Model for the Isabelle API author = Frédéric Tuong , Burkhart Wolff date = 2015-09-16 topic = Computer science/Programming languages/Language definitions abstract = We represent a theory of (a fragment of) Isabelle/HOL in Isabelle/HOL. The purpose of this exercise is to write packages for domain-specific specifications such as class models, B-machines, ..., and generally speaking, any domain-specific languages whose abstract syntax can be defined by a HOL "datatype". On this basis, the Isabelle code-generator can then be used to generate code for global context transformations as well as tactic code.

Consequently the package is geared towards parsing, printing and code-generation to the Isabelle API. It is at the moment not sufficiently rich for doing meta theory on Isabelle itself. Extensions in this direction are possible though.

Moreover, the chosen fragment is fairly rudimentary. However it should be easily adapted to one's needs if a package is written on top of it. The supported API contains types, terms, transformation of global context like definitions and data-type declarations as well as infrastructure for Isar-setups.

This theory is drawn from the Featherweight OCL project where it is used to construct a package for object-oriented data-type theories generated from UML class diagrams. The Featherweight OCL, for example, allows for both the direct execution of compiled tactic code by the Isabelle API as well as the generation of ".thy"-files for debugging purposes.

Gained experience from this project shows that the compiled code is sufficiently efficient for practical purposes while being based on a formal model on which properties of the package can be proven such as termination of certain transformations, correctness, etc. notify = tuong@users.gforge.inria.fr, wolff@lri.fr [Clean] title = Clean - An Abstract Imperative Programming Language and its Theory author = Frédéric Tuong , Burkhart Wolff topic = Computer science/Programming languages, Computer science/Semantics date = 2019-10-04 notify = wolff@lri.fr, ftuong@lri.fr abstract = Clean is based on a simple, abstract execution model for an imperative target language. “Abstract” is understood in contrast to “Concrete Semantics”; alternatively, the term “shallow-style embedding” could be used. It strives for a type-safe notion of program-variables, an incremental construction of the typed state-space, support of incremental verification, and open-world extensibility of new type definitions being intertwined with the program definitions. Clean is based on a “no-frills” state-exception monad with the usual definitions of bind and unit for the compositional glue of state-based computations. Clean offers conditionals and loops supporting C-like control-flow operators such as break and return. The state-space construction is based on the extensible record package. Direct recursion of procedures is supported. Clean’s design strives for extreme simplicity. It is geared towards symbolic execution and proven correct verification tools. The underlying libraries of this package, however, deliberately restrict themselves to the most elementary infrastructure for these tasks. The package is intended to serve as demonstrator semantic backend for Isabelle/C, or for the test-generation techniques. [PCF] title = Logical Relations for PCF author = Peter Gammie date = 2012-07-01 topic = Computer science/Programming languages/Lambda calculi abstract = We apply Andy Pitts's methods of defining relations over domains to several classical results in the literature. We show that the Y combinator coincides with the domain-theoretic fixpoint operator, that parallel-or and the Plotkin existential are not definable in PCF, that the continuation semantics for PCF coincides with the direct semantics, and that our domain-theoretic semantics for PCF is adequate for reasoning about contextual equivalence in an operational semantics. Our version of PCF is untyped and has both strict and non-strict function abstractions. The development is carried out in HOLCF. notify = peteg42@gmail.com [POPLmark-deBruijn] title = POPLmark Challenge Via de Bruijn Indices author = Stefan Berghofer date = 2007-08-02 topic = Computer science/Programming languages/Lambda calculi abstract = We present a solution to the POPLmark challenge designed by Aydemir et al., which has as a goal the formalization of the meta-theory of System F<:. The formalization is carried out in the theorem prover Isabelle/HOL using an encoding based on de Bruijn indices. We start with a relatively simple formalization covering only the basic features of System F<:, and explain how it can be extended to also cover records and more advanced binding constructs. notify = berghofe@in.tum.de [Lam-ml-Normalization] title = Strong Normalization of Moggis's Computational Metalanguage author = Christian Doczkal date = 2010-08-29 topic = Computer science/Programming languages/Lambda calculi abstract = Handling variable binding is one of the main difficulties in formal proofs. In this context, Moggi's computational metalanguage serves as an interesting case study. It features monadic types and a commuting conversion rule that rearranges the binding structure. Lindley and Stark have given an elegant proof of strong normalization for this calculus. The key construction in their proof is a notion of relational TT-lifting, using stacks of elimination contexts to obtain a Girard-Tait style logical relation. I give a formalization of their proof in Isabelle/HOL-Nominal with a particular emphasis on the treatment of bound variables. notify = doczkal@ps.uni-saarland.de, nipkow@in.tum.de [MiniML] title = Mini ML author = Wolfgang Naraschewski <>, Tobias Nipkow date = 2004-03-19 topic = Computer science/Programming languages/Type systems abstract = This theory defines the type inference rules and the type inference algorithm W for MiniML (simply-typed lambda terms with let) due to Milner. It proves the soundness and completeness of W w.r.t. the rules. notify = kleing@cse.unsw.edu.au [Simpl] title = A Sequential Imperative Programming Language Syntax, Semantics, Hoare Logics and Verification Environment author = Norbert Schirmer <> date = 2008-02-29 topic = Computer science/Programming languages/Language definitions, Computer science/Programming languages/Logics license = LGPL abstract = We present the theory of Simpl, a sequential imperative programming language. We introduce its syntax, its semantics (big and small-step operational semantics) and Hoare logics for both partial as well as total correctness. We prove soundness and completeness of the Hoare logic. We integrate and automate the Hoare logic in Isabelle/HOL to obtain a practically usable verification environment for imperative programs. Simpl is independent of a concrete programming language but expressive enough to cover all common language features: mutually recursive procedures, abrupt termination and exceptions, runtime faults, local and global variables, pointers and heap, expressions with side effects, pointers to procedures, partial application and closures, dynamic method invocation and also unbounded nondeterminism. notify = kleing@cse.unsw.edu.au, norbert.schirmer@web.de [Separation_Algebra] title = Separation Algebra author = Gerwin Klein , Rafal Kolanski , Andrew Boyton date = 2012-05-11 topic = Computer science/Programming languages/Logics license = BSD abstract = We present a generic type class implementation of separation algebra for Isabelle/HOL as well as lemmas and generic tactics which can be used directly for any instantiation of the type class.

The ex directory contains example instantiations that include structures such as a heap or virtual memory.

The abstract separation algebra is based upon "Abstract Separation Logic" by Calcagno et al. These theories are also the basis of the ITP 2012 rough diamond "Mechanised Separation Algebra" by the authors.

The aim of this work is to support and significantly reduce the effort for future separation logic developments in Isabelle/HOL by factoring out the part of separation logic that can be treated abstractly once and for all. This includes developing typical default rule sets for reasoning as well as automated tactic support for separation logic. notify = kleing@cse.unsw.edu.au, rafal.kolanski@nicta.com.au [Separation_Logic_Imperative_HOL] title = A Separation Logic Framework for Imperative HOL author = Peter Lammich , Rene Meis date = 2012-11-14 topic = Computer science/Programming languages/Logics license = BSD abstract = We provide a framework for separation-logic based correctness proofs of Imperative HOL programs. Our framework comes with a set of proof methods to automate canonical tasks such as verification condition generation and frame inference. Moreover, we provide a set of examples that show the applicability of our framework. The examples include algorithms on lists, hash-tables, and union-find trees. We also provide abstract interfaces for lists, maps, and sets, that allow to develop generic imperative algorithms and use data-refinement techniques.
As we target Imperative HOL, our programs can be translated to efficiently executable code in various target languages, including ML, OCaml, Haskell, and Scala. notify = lammich@in.tum.de [Inductive_Confidentiality] title = Inductive Study of Confidentiality author = Giampaolo Bella date = 2012-05-02 topic = Computer science/Security abstract = This document contains the full theory files accompanying article Inductive Study of Confidentiality --- for Everyone in Formal Aspects of Computing. They aim at an illustrative and didactic presentation of the Inductive Method of protocol analysis, focusing on the treatment of one of the main goals of security protocols: confidentiality against a threat model. The treatment of confidentiality, which in fact forms a key aspect of all protocol analysis tools, has been found cryptic by many learners of the Inductive Method, hence the motivation for this work. The theory files in this document guide the reader step by step towards design and proof of significant confidentiality theorems. These are developed against two threat models, the standard Dolev-Yao and a more audacious one, the General Attacker, which turns out to be particularly useful also for teaching purposes. notify = giamp@dmi.unict.it [Possibilistic_Noninterference] title = Possibilistic Noninterference author = Andrei Popescu , Johannes Hölzl date = 2012-09-10 topic = Computer science/Security, Computer science/Programming languages/Type systems abstract = We formalize a wide variety of Volpano/Smith-style noninterference notions for a while language with parallel composition. We systematize and classify these notions according to compositionality w.r.t. the language constructs. Compositionality yields sound syntactic criteria (a.k.a. type systems) in a uniform way.

An article about these proofs is published in the proceedings of the conference Certified Programs and Proofs 2012. notify = hoelzl@in.tum.de [SIFUM_Type_Systems] title = A Formalization of Assumptions and Guarantees for Compositional Noninterference author = Sylvia Grewe , Heiko Mantel , Daniel Schoepe date = 2014-04-23 topic = Computer science/Security, Computer science/Programming languages/Type systems abstract = Research in information-flow security aims at developing methods to identify undesired information leaks within programs from private (high) sources to public (low) sinks. For a concurrent system, it is desirable to have compositional analysis methods that allow for analyzing each thread independently and that nevertheless guarantee that the parallel composition of successfully analyzed threads satisfies a global security guarantee. However, such a compositional analysis should not be overly pessimistic about what an environment might do with shared resources. Otherwise, the analysis will reject many intuitively secure programs.

The paper "Assumptions and Guarantees for Compositional Noninterference" by Mantel et. al. presents one solution for this problem: an approach for compositionally reasoning about non-interference in concurrent programs via rely-guarantee-style reasoning. We present an Isabelle/HOL formalization of the concepts and proofs of this approach. notify = [Dependent_SIFUM_Type_Systems] title = A Dependent Security Type System for Concurrent Imperative Programs author = Toby Murray , Robert Sison<>, Edward Pierzchalski<>, Christine Rizkallah notify = toby.murray@unimelb.edu.au date = 2016-06-25 topic = Computer science/Security, Computer science/Programming languages/Type systems abstract = The paper "Compositional Verification and Refinement of Concurrent Value-Dependent Noninterference" by Murray et. al. (CSF 2016) presents a dependent security type system for compositionally verifying a value-dependent noninterference property, defined in (Murray, PLAS 2015), for concurrent programs. This development formalises that security definition, the type system and its soundness proof, and demonstrates its application on some small examples. It was derived from the SIFUM_Type_Systems AFP entry, by Sylvia Grewe, Heiko Mantel and Daniel Schoepe, and whose structure it inherits. extra-history = Change history: [2016-08-19]: Removed unused "stop" parameter and "stop_no_eval" assumption from the sifum_security locale. (revision dbc482d36372) [2016-09-27]: Added security locale support for the imposition of requirements on the initial memory. (revision cce4ceb74ddb) [Dependent_SIFUM_Refinement] title = Compositional Security-Preserving Refinement for Concurrent Imperative Programs author = Toby Murray , Robert Sison<>, Edward Pierzchalski<>, Christine Rizkallah notify = toby.murray@unimelb.edu.au date = 2016-06-28 topic = Computer science/Security abstract = The paper "Compositional Verification and Refinement of Concurrent Value-Dependent Noninterference" by Murray et. al. (CSF 2016) presents a compositional theory of refinement for a value-dependent noninterference property, defined in (Murray, PLAS 2015), for concurrent programs. This development formalises that refinement theory, and demonstrates its application on some small examples. extra-history = Change history: [2016-08-19]: Removed unused "stop" parameters from the sifum_refinement locale. (revision dbc482d36372) [2016-09-02]: TobyM extended "simple" refinement theory to be usable for all bisimulations. (revision 547f31c25f60) [Relational-Incorrectness-Logic] title = An Under-Approximate Relational Logic author = Toby Murray topic = Computer science/Programming languages/Logics, Computer science/Security date = 2020-03-12 notify = toby.murray@unimelb.edu.au abstract = Recently, authors have proposed under-approximate logics for reasoning about programs. So far, all such logics have been confined to reasoning about individual program behaviours. Yet there exist many over-approximate relational logics for reasoning about pairs of programs and relating their behaviours. We present the first under-approximate relational logic, for the simple imperative language IMP. We prove our logic is both sound and complete. Additionally, we show how reasoning in this logic can be decomposed into non-relational reasoning in an under-approximate Hoare logic, mirroring Beringer’s result for over-approximate relational logics. We illustrate the application of our logic on some small examples in which we provably demonstrate the presence of insecurity. [Strong_Security] title = A Formalization of Strong Security author = Sylvia Grewe , Alexander Lux , Heiko Mantel , Jens Sauer date = 2014-04-23 topic = Computer science/Security, Computer science/Programming languages/Type systems abstract = Research in information-flow security aims at developing methods to identify undesired information leaks within programs from private sources to public sinks. Noninterference captures this intuition. Strong security from Sabelfeld and Sands formalizes noninterference for concurrent systems.

We present an Isabelle/HOL formalization of strong security for arbitrary security lattices (Sabelfeld and Sands use a two-element security lattice in the original publication). The formalization includes compositionality proofs for strong security and a soundness proof for a security type system that checks strong security for programs in a simple while language with dynamic thread creation.

Our formalization of the security type system is abstract in the language for expressions and in the semantic side conditions for expressions. It can easily be instantiated with different syntactic approximations for these side conditions. The soundness proof of such an instantiation boils down to showing that these syntactic approximations imply the semantic side conditions. notify = [WHATandWHERE_Security] title = A Formalization of Declassification with WHAT-and-WHERE-Security author = Sylvia Grewe , Alexander Lux , Heiko Mantel , Jens Sauer date = 2014-04-23 topic = Computer science/Security, Computer science/Programming languages/Type systems abstract = Research in information-flow security aims at developing methods to identify undesired information leaks within programs from private sources to public sinks. Noninterference captures this intuition by requiring that no information whatsoever flows from private sources to public sinks. However, in practice this definition is often too strict: Depending on the intuitive desired security policy, the controlled declassification of certain private information (WHAT) at certain points in the program (WHERE) might not result in an undesired information leak.

We present an Isabelle/HOL formalization of such a security property for controlled declassification, namely WHAT&WHERE-security from "Scheduler-Independent Declassification" by Lux, Mantel, and Perner. The formalization includes compositionality proofs for and a soundness proof for a security type system that checks for programs in a simple while language with dynamic thread creation.

Our formalization of the security type system is abstract in the language for expressions and in the semantic side conditions for expressions. It can easily be instantiated with different syntactic approximations for these side conditions. The soundness proof of such an instantiation boils down to showing that these syntactic approximations imply the semantic side conditions.

This Isabelle/HOL formalization uses theories from the entry Strong Security. notify = [VolpanoSmith] title = A Correctness Proof for the Volpano/Smith Security Typing System author = Gregor Snelting , Daniel Wasserrab date = 2008-09-02 topic = Computer science/Programming languages/Type systems, Computer science/Security abstract = The Volpano/Smith/Irvine security type systems requires that variables are annotated as high (secret) or low (public), and provides typing rules which guarantee that secret values cannot leak to public output ports. This property of a program is called confidentiality. For a simple while-language without threads, our proof shows that typeability in the Volpano/Smith system guarantees noninterference. Noninterference means that if two initial states for program execution are low-equivalent, then the final states are low-equivalent as well. This indeed implies that secret values cannot leak to public ports. The proof defines an abstract syntax and operational semantics for programs, formalizes noninterference, and then proceeds by rule induction on the operational semantics. The mathematically most intricate part is the treatment of implicit flows. Note that the Volpano/Smith system is not flow-sensitive and thus quite unprecise, resulting in false alarms. However, due to the correctness property, all potential breaks of confidentiality are discovered. notify = [Abstract-Hoare-Logics] title = Abstract Hoare Logics author = Tobias Nipkow date = 2006-08-08 topic = Computer science/Programming languages/Logics abstract = These therories describe Hoare logics for a number of imperative language constructs, from while-loops to mutually recursive procedures. Both partial and total correctness are treated. In particular a proof system for total correctness of recursive procedures in the presence of unbounded nondeterminism is presented. notify = nipkow@in.tum.de [Stone_Algebras] title = Stone Algebras author = Walter Guttmann notify = walter.guttmann@canterbury.ac.nz date = 2016-09-06 topic = Mathematics/Order abstract = A range of algebras between lattices and Boolean algebras generalise the notion of a complement. We develop a hierarchy of these pseudo-complemented algebras that includes Stone algebras. Independently of this theory we study filters based on partial orders. Both theories are combined to prove Chen and Grätzer's construction theorem for Stone algebras. The latter involves extensive reasoning about algebraic structures in addition to reasoning in algebraic structures. [Kleene_Algebra] title = Kleene Algebra author = Alasdair Armstrong <>, Georg Struth , Tjark Weber date = 2013-01-15 topic = Computer science/Programming languages/Logics, Computer science/Automata and formal languages, Mathematics/Algebra abstract = These files contain a formalisation of variants of Kleene algebras and their most important models as axiomatic type classes in Isabelle/HOL. Kleene algebras are foundational structures in computing with applications ranging from automata and language theory to computational modeling, program construction and verification.

We start with formalising dioids, which are additively idempotent semirings, and expand them by axiomatisations of the Kleene star for finite iteration and an omega operation for infinite iteration. We show that powersets over a given monoid, (regular) languages, sets of paths in a graph, sets of computation traces, binary relations and formal power series form Kleene algebras, and consider further models based on lattices, max-plus semirings and min-plus semirings. We also demonstrate that dioids are closed under the formation of matrices (proofs for Kleene algebras remain to be completed).

On the one hand we have aimed at a reference formalisation of variants of Kleene algebras that covers a wide range of variants and the core theorems in a structured and modular way and provides readable proofs at text book level. On the other hand, we intend to use this algebraic hierarchy and its models as a generic algebraic middle-layer from which programming applications can quickly be explored, implemented and verified. notify = g.struth@sheffield.ac.uk, tjark.weber@it.uu.se [KAT_and_DRA] title = Kleene Algebra with Tests and Demonic Refinement Algebras author = Alasdair Armstrong <>, Victor B. F. Gomes , Georg Struth date = 2014-01-23 topic = Computer science/Programming languages/Logics, Computer science/Automata and formal languages, Mathematics/Algebra abstract = We formalise Kleene algebra with tests (KAT) and demonic refinement algebra (DRA) in Isabelle/HOL. KAT is relevant for program verification and correctness proofs in the partial correctness setting. While DRA targets similar applications in the context of total correctness. Our formalisation contains the two most important models of these algebras: binary relations in the case of KAT and predicate transformers in the case of DRA. In addition, we derive the inference rules for Hoare logic in KAT and its relational model and present a simple formally verified program verification tool prototype based on the algebraic approach. notify = g.struth@dcs.shef.ac.uk [KAD] title = Kleene Algebras with Domain author = Victor B. F. Gomes , Walter Guttmann , Peter Höfner , Georg Struth , Tjark Weber date = 2016-04-12 topic = Computer science/Programming languages/Logics, Computer science/Automata and formal languages, Mathematics/Algebra abstract = Kleene algebras with domain are Kleene algebras endowed with an operation that maps each element of the algebra to its domain of definition (or its complement) in abstract fashion. They form a simple algebraic basis for Hoare logics, dynamic logics or predicate transformer semantics. We formalise a modular hierarchy of algebras with domain and antidomain (domain complement) operations in Isabelle/HOL that ranges from domain and antidomain semigroups to modal Kleene algebras and divergence Kleene algebras. We link these algebras with models of binary relations and program traces. We include some examples from modal logics, termination and program analysis. notify = walter.guttman@canterbury.ac.nz, g.struth@sheffield.ac.uk, tjark.weber@it.uu.se [Regular_Algebras] title = Regular Algebras author = Simon Foster , Georg Struth date = 2014-05-21 topic = Computer science/Automata and formal languages, Mathematics/Algebra abstract = Regular algebras axiomatise the equational theory of regular expressions as induced by regular language identity. We use Isabelle/HOL for a detailed systematic study of regular algebras given by Boffa, Conway, Kozen and Salomaa. We investigate the relationships between these classes, formalise a soundness proof for the smallest class (Salomaa's) and obtain completeness of the largest one (Boffa's) relative to a deep result by Krob. In addition we provide a large collection of regular identities in the general setting of Boffa's axiom. Our regular algebra hierarchy is orthogonal to the Kleene algebra hierarchy in the Archive of Formal Proofs; we have not aimed at an integration for pragmatic reasons. notify = simon.foster@york.ac.uk, g.struth@sheffield.ac.uk [BytecodeLogicJmlTypes] title = A Bytecode Logic for JML and Types author = Lennart Beringer <>, Martin Hofmann date = 2008-12-12 topic = Computer science/Programming languages/Logics abstract = This document contains the Isabelle/HOL sources underlying the paper A bytecode logic for JML and types by Beringer and Hofmann, updated to Isabelle 2008. We present a program logic for a subset of sequential Java bytecode that is suitable for representing both, features found in high-level specification language JML as well as interpretations of high-level type systems. To this end, we introduce a fine-grained collection of assertions, including strong invariants, local annotations and VDM-reminiscent partial-correctness specifications. Thanks to a goal-oriented structure and interpretation of judgements, verification may proceed without recourse to an additional control flow analysis. The suitability for interpreting intensional type systems is illustrated by the proof-carrying-code style encoding of a type system for a first-order functional language which guarantees a constant upper bound on the number of objects allocated throughout an execution, be the execution terminating or non-terminating. Like the published paper, the formal development is restricted to a comparatively small subset of the JVML, lacking (among other features) exceptions, arrays, virtual methods, and static fields. This shortcoming has been overcome meanwhile, as our paper has formed the basis of the Mobius base logic, a program logic for the full sequential fragment of the JVML. Indeed, the present formalisation formed the basis of a subsequent formalisation of the Mobius base logic in the proof assistant Coq, which includes a proof of soundness with respect to the Bicolano operational semantics by Pichardie. notify = [DataRefinementIBP] title = Semantics and Data Refinement of Invariant Based Programs author = Viorel Preoteasa , Ralph-Johan Back date = 2010-05-28 topic = Computer science/Programming languages/Logics abstract = The invariant based programming is a technique of constructing correct programs by first identifying the basic situations (pre- and post-conditions and invariants) that can occur during the execution of the program, and then defining the transitions and proving that they preserve the invariants. Data refinement is a technique of building correct programs working on concrete datatypes as refinements of more abstract programs. In the theories presented here we formalize the predicate transformer semantics for invariant based programs and their data refinement. extra-history = Change history: [2012-01-05]: Moved some general complete lattice properties to the AFP entry Lattice Properties. Changed the definition of the data refinement relation to be more general and updated all corresponding theorems. Added new syntax for demonic and angelic update statements. notify = viorel.preoteasa@aalto.fi [RefinementReactive] title = Formalization of Refinement Calculus for Reactive Systems author = Viorel Preoteasa date = 2014-10-08 topic = Computer science/Programming languages/Logics abstract = We present a formalization of refinement calculus for reactive systems. Refinement calculus is based on monotonic predicate transformers (monotonic functions from sets of post-states to sets of pre-states), and it is a powerful formalism for reasoning about imperative programs. We model reactive systems as monotonic property transformers that transform sets of output infinite sequences into sets of input infinite sequences. Within this semantics we can model refinement of reactive systems, (unbounded) angelic and demonic nondeterminism, sequential composition, and other semantic properties. We can model systems that may fail for some inputs, and we can model compatibility of systems. We can specify systems that have liveness properties using linear temporal logic, and we can refine system specifications into systems based on symbolic transitions systems, suitable for implementations. notify = viorel.preoteasa@aalto.fi [SIFPL] title = Secure information flow and program logics author = Lennart Beringer <>, Martin Hofmann date = 2008-11-10 topic = Computer science/Programming languages/Logics, Computer science/Security abstract = We present interpretations of type systems for secure information flow in Hoare logic, complementing previous encodings in relational program logics. We first treat the imperative language IMP, extended by a simple procedure call mechanism. For this language we consider base-line non-interference in the style of Volpano et al. and the flow-sensitive type system by Hunt and Sands. In both cases, we show how typing derivations may be used to automatically generate proofs in the program logic that certify the absence of illicit flows. We then add instructions for object creation and manipulation, and derive appropriate proof rules for base-line non-interference. As a consequence of our work, standard verification technology may be used for verifying that a concrete program satisfies the non-interference property.

The present proof development represents an update of the formalisation underlying our paper [CSF 2007] and is intended to resolve any ambiguities that may be present in the paper. notify = lennart.beringer@ifi.lmu.de [TLA] title = A Definitional Encoding of TLA* in Isabelle/HOL author = Gudmund Grov , Stephan Merz date = 2011-11-19 topic = Computer science/Programming languages/Logics abstract = We mechanise the logic TLA* [Merz 1999], an extension of Lamport's Temporal Logic of Actions (TLA) [Lamport 1994] for specifying and reasoning about concurrent and reactive systems. Aiming at a framework for mechanising] the verification of TLA (or TLA*) specifications, this contribution reuses some elements from a previous axiomatic encoding of TLA in Isabelle/HOL by the second author [Merz 1998], which has been part of the Isabelle distribution. In contrast to that previous work, we give here a shallow, definitional embedding, with the following highlights:

  • a theory of infinite sequences, including a formalisation of the concepts of stuttering invariance central to TLA and TLA*;
  • a definition of the semantics of TLA*, which extends TLA by a mutually-recursive definition of formulas and pre-formulas, generalising TLA action formulas;
  • a substantial set of derived proof rules, including the TLA* axioms and Lamport's proof rules for system verification;
  • a set of examples illustrating the usage of Isabelle/TLA* for reasoning about systems.
Note that this work is unrelated to the ongoing development of a proof system for the specification language TLA+, which includes an encoding of TLA+ as a new Isabelle object logic [Chaudhuri et al 2010]. notify = ggrov@inf.ed.ac.uk [Compiling-Exceptions-Correctly] title = Compiling Exceptions Correctly author = Tobias Nipkow date = 2004-07-09 topic = Computer science/Programming languages/Compiling abstract = An exception compilation scheme that dynamically creates and removes exception handler entries on the stack. A formalization of an article of the same name by Hutton and Wright. notify = nipkow@in.tum.de [NormByEval] title = Normalization by Evaluation author = Klaus Aehlig , Tobias Nipkow date = 2008-02-18 topic = Computer science/Programming languages/Compiling abstract = This article formalizes normalization by evaluation as implemented in Isabelle. Lambda calculus plus term rewriting is compiled into a functional program with pattern matching. It is proved that the result of a successful evaluation is a) correct, i.e. equivalent to the input, and b) in normal form. notify = nipkow@in.tum.de [Program-Conflict-Analysis] title = Formalization of Conflict Analysis of Programs with Procedures, Thread Creation, and Monitors topic = Computer science/Programming languages/Static analysis author = Peter Lammich , Markus Müller-Olm date = 2007-12-14 abstract = In this work we formally verify the soundness and precision of a static program analysis that detects conflicts (e. g. data races) in programs with procedures, thread creation and monitors with the Isabelle theorem prover. As common in static program analysis, our program model abstracts guarded branching by nondeterministic branching, but completely interprets the call-/return behavior of procedures, synchronization by monitors, and thread creation. The analysis is based on the observation that all conflicts already occur in a class of particularly restricted schedules. These restricted schedules are suited to constraint-system-based program analysis. The formalization is based upon a flowgraph-based program model with an operational semantics as reference point. notify = peter.lammich@uni-muenster.de [Shivers-CFA] title = Shivers' Control Flow Analysis topic = Computer science/Programming languages/Static analysis author = Joachim Breitner date = 2010-11-16 abstract = In his dissertation, Olin Shivers introduces a concept of control flow graphs for functional languages, provides an algorithm to statically derive a safe approximation of the control flow graph and proves this algorithm correct. In this research project, Shivers' algorithms and proofs are formalized in the HOLCF extension of HOL. notify = mail@joachim-breitner.de, nipkow@in.tum.de [Slicing] title = Towards Certified Slicing author = Daniel Wasserrab date = 2008-09-16 topic = Computer science/Programming languages/Static analysis abstract = Slicing is a widely-used technique with applications in e.g. compiler technology and software security. Thus verification of algorithms in these areas is often based on the correctness of slicing, which should ideally be proven independent of concrete programming languages and with the help of well-known verifying techniques such as proof assistants. As a first step in this direction, this contribution presents a framework for dynamic and static intraprocedural slicing based on control flow and program dependence graphs. Abstracting from concrete syntax we base the framework on a graph representation of the program fulfilling certain structural and well-formedness properties.

The formalization consists of the basic framework (in subdirectory Basic/), the correctness proof for dynamic slicing (in subdirectory Dynamic/), the correctness proof for static intraprocedural slicing (in subdirectory StaticIntra/) and instantiations of the framework with a simple While language (in subdirectory While/) and the sophisticated object-oriented bytecode language of Jinja (in subdirectory JinjaVM/). For more information on the framework, see the TPHOLS 2008 paper by Wasserrab and Lochbihler and the PLAS 2009 paper by Wasserrab et al. notify = [HRB-Slicing] title = Backing up Slicing: Verifying the Interprocedural Two-Phase Horwitz-Reps-Binkley Slicer author = Daniel Wasserrab date = 2009-11-13 topic = Computer science/Programming languages/Static analysis abstract = After verifying dynamic and static interprocedural slicing, we present a modular framework for static interprocedural slicing. To this end, we formalized the standard two-phase slicer from Horwitz, Reps and Binkley (see their TOPLAS 12(1) 1990 paper) together with summary edges as presented by Reps et al. (see FSE 1994). The framework is again modular in the programming language by using an abstract CFG, defined via structural and well-formedness properties. Using a weak simulation between the original and sliced graph, we were able to prove the correctness of static interprocedural slicing. We also instantiate our framework with a simple While language with procedures. This shows that the chosen abstractions are indeed valid. notify = nipkow@in.tum.de [WorkerWrapper] title = The Worker/Wrapper Transformation author = Peter Gammie date = 2009-10-30 topic = Computer science/Programming languages/Transformations abstract = Gill and Hutton formalise the worker/wrapper transformation, building on the work of Launchbury and Peyton-Jones who developed it as a way of changing the type at which a recursive function operates. This development establishes the soundness of the technique and several examples of its use. notify = peteg42@gmail.com, nipkow@in.tum.de [JiveDataStoreModel] title = Jive Data and Store Model author = Nicole Rauch , Norbert Schirmer <> date = 2005-06-20 license = LGPL topic = Computer science/Programming languages/Misc abstract = This document presents the formalization of an object-oriented data and store model in Isabelle/HOL. This model is being used in the Java Interactive Verification Environment, Jive. notify = kleing@cse.unsw.edu.au, schirmer@in.tum.de [HotelKeyCards] title = Hotel Key Card System author = Tobias Nipkow date = 2006-09-09 topic = Computer science/Security abstract = Two models of an electronic hotel key card system are contrasted: a state based and a trace based one. Both are defined, verified, and proved equivalent in the theorem prover Isabelle/HOL. It is shown that if a guest follows a certain safety policy regarding her key cards, she can be sure that nobody but her can enter her room. notify = nipkow@in.tum.de [RSAPSS] title = SHA1, RSA, PSS and more author = Christina Lindenberg <>, Kai Wirt <> date = 2005-05-02 topic = Computer science/Security/Cryptography abstract = Formal verification is getting more and more important in computer science. However the state of the art formal verification methods in cryptography are very rudimentary. These theories are one step to provide a tool box allowing the use of formal methods in every aspect of cryptography. Moreover we present a proof of concept for the feasibility of verification techniques to a standard signature algorithm. notify = nipkow@in.tum.de [InformationFlowSlicing] title = Information Flow Noninterference via Slicing author = Daniel Wasserrab date = 2010-03-23 topic = Computer science/Security abstract =

In this contribution, we show how correctness proofs for intra- and interprocedural slicing can be used to prove that slicing is able to guarantee information flow noninterference. Moreover, we also illustrate how to lift the control flow graphs of the respective frameworks such that they fulfil the additional assumptions needed in the noninterference proofs. A detailed description of the intraprocedural proof and its interplay with the slicing framework can be found in the PLAS'09 paper by Wasserrab et al.

This entry contains the part for intra-procedural slicing. See entry InformationFlowSlicing_Inter for the inter-procedural part.

extra-history = Change history: [2016-06-10]: The original entry InformationFlowSlicing contained both the inter- and intra-procedural case was split into two for easier maintenance. notify = [InformationFlowSlicing_Inter] title = Inter-Procedural Information Flow Noninterference via Slicing author = Daniel Wasserrab date = 2010-03-23 topic = Computer science/Security abstract =

In this contribution, we show how correctness proofs for intra- and interprocedural slicing can be used to prove that slicing is able to guarantee information flow noninterference. Moreover, we also illustrate how to lift the control flow graphs of the respective frameworks such that they fulfil the additional assumptions needed in the noninterference proofs. A detailed description of the intraprocedural proof and its interplay with the slicing framework can be found in the PLAS'09 paper by Wasserrab et al.

This entry contains the part for inter-procedural slicing. See entry InformationFlowSlicing for the intra-procedural part.

extra-history = Change history: [2016-06-10]: The original entry InformationFlowSlicing contained both the inter- and intra-procedural case was split into two for easier maintenance. notify = [ComponentDependencies] title = Formalisation and Analysis of Component Dependencies author = Maria Spichkova date = 2014-04-28 topic = Computer science/System description languages abstract = This set of theories presents a formalisation in Isabelle/HOL of data dependencies between components. The approach allows to analyse system structure oriented towards efficient checking of system: it aims at elaborating for a concrete system, which parts of the system are necessary to check a given property. notify = maria.spichkova@rmit.edu.au [Verified-Prover] title = A Mechanically Verified, Efficient, Sound and Complete Theorem Prover For First Order Logic author = Tom Ridge <> date = 2004-09-28 topic = Logic/General logic/Mechanization of proofs abstract = Soundness and completeness for a system of first order logic are formally proved, building on James Margetson's formalization of work by Wainer and Wallen. The completeness proofs naturally suggest an algorithm to derive proofs. This algorithm, which can be implemented tail recursively, is formalized in Isabelle/HOL. The algorithm can be executed via the rewriting tactics of Isabelle. Alternatively, the definitions can be exported to OCaml, yielding a directly executable program. notify = lp15@cam.ac.uk [Completeness] title = Completeness theorem author = James Margetson <>, Tom Ridge <> date = 2004-09-20 topic = Logic/Proof theory abstract = The completeness of first-order logic is proved, following the first five pages of Wainer and Wallen's chapter of the book Proof Theory by Aczel et al., CUP, 1992. Their presentation of formulas allows the proofs to use symmetry arguments. Margetson formalized this theorem by early 2000. The Isar conversion is thanks to Tom Ridge. A paper describing the formalization is available [pdf]. notify = lp15@cam.ac.uk [Ordinal] title = Countable Ordinals author = Brian Huffman date = 2005-11-11 topic = Logic/Set theory abstract = This development defines a well-ordered type of countable ordinals. It includes notions of continuous and normal functions, recursively defined functions over ordinals, least fixed-points, and derivatives. Much of ordinal arithmetic is formalized, including exponentials and logarithms. The development concludes with formalizations of Cantor Normal Form and Veblen hierarchies over normal functions. notify = lcp@cl.cam.ac.uk [Ordinals_and_Cardinals] title = Ordinals and Cardinals author = Andrei Popescu date = 2009-09-01 topic = Logic/Set theory abstract = We develop a basic theory of ordinals and cardinals in Isabelle/HOL, up to the point where some cardinality facts relevant for the ``working mathematician" become available. Unlike in set theory, here we do not have at hand canonical notions of ordinal and cardinal. Therefore, here an ordinal is merely a well-order relation and a cardinal is an ordinal minim w.r.t. order embedding on its field. extra-history = Change history: [2012-09-25]: This entry has been discontinued because it is now part of the Isabelle distribution. notify = uuomul@yahoo.com, nipkow@in.tum.de [FOL-Fitting] title = First-Order Logic According to Fitting author = Stefan Berghofer contributors = Asta Halkjær From date = 2007-08-02 topic = Logic/General logic/Classical first-order logic abstract = We present a formalization of parts of Melvin Fitting's book "First-Order Logic and Automated Theorem Proving". The formalization covers the syntax of first-order logic, its semantics, the model existence theorem, a natural deduction proof calculus together with a proof of correctness and completeness, as well as the Löwenheim-Skolem theorem. extra-history = Change history: [2018-07-21]: Proved completeness theorem for open formulas. Proofs are now written in the declarative style. Enumeration of pairs and datatypes is automated using the Countable theory. notify = berghofe@in.tum.de [Epistemic_Logic] title = Epistemic Logic: Completeness of Modal Logics author = Asta Halkjær From topic = Logic/General logic/Logics of knowledge and belief date = 2018-10-29 notify = ahfrom@dtu.dk abstract = This work is a formalization of epistemic logic with countably many agents. It includes proofs of soundness and completeness for the axiom system K. The completeness proof is based on the textbook "Reasoning About Knowledge" by Fagin, Halpern, Moses and Vardi (MIT Press 1995). The extensions of system K (T, KB, K4, S4, S5) and their completeness proofs are based on the textbook "Modal Logic" by Blackburn, de Rijke and Venema (Cambridge University Press 2001). extra-history = Change history: [2021-04-15]: Added completeness of modal logics T, KB, K4, S4 and S5. [SequentInvertibility] title = Invertibility in Sequent Calculi author = Peter Chapman <> date = 2009-08-28 topic = Logic/Proof theory license = LGPL abstract = The invertibility of the rules of a sequent calculus is important for guiding proof search and can be used in some formalised proofs of Cut admissibility. We present sufficient conditions for when a rule is invertible with respect to a calculus. We illustrate the conditions with examples. It must be noted we give purely syntactic criteria; no guarantees are given as to the suitability of the rules. notify = pc@cs.st-andrews.ac.uk, nipkow@in.tum.de [LinearQuantifierElim] title = Quantifier Elimination for Linear Arithmetic author = Tobias Nipkow date = 2008-01-11 topic = Logic/General logic/Decidability of theories abstract = This article formalizes quantifier elimination procedures for dense linear orders, linear real arithmetic and Presburger arithmetic. In each case both a DNF-based non-elementary algorithm and one or more (doubly) exponential NNF-based algorithms are formalized, including the well-known algorithms by Ferrante and Rackoff and by Cooper. The NNF-based algorithms for dense linear orders are new but based on Ferrante and Rackoff and on an algorithm by Loos and Weisspfenning which simulates infenitesimals. All algorithms are directly executable. In particular, they yield reflective quantifier elimination procedures for HOL itself. The formalization makes heavy use of locales and is therefore highly modular. notify = nipkow@in.tum.de [Nat-Interval-Logic] title = Interval Temporal Logic on Natural Numbers author = David Trachtenherz <> date = 2011-02-23 topic = Logic/General logic/Temporal logic abstract = We introduce a theory of temporal logic operators using sets of natural numbers as time domain, formalized in a shallow embedding manner. The theory comprises special natural intervals (theory IL_Interval: open and closed intervals, continuous and modulo intervals, interval traversing results), operators for shifting intervals to left/right on the number axis as well as expanding/contracting intervals by constant factors (theory IL_IntervalOperators.thy), and ultimately definitions and results for unary and binary temporal operators on arbitrary natural sets (theory IL_TemporalOperators). notify = nipkow@in.tum.de [Recursion-Theory-I] title = Recursion Theory I author = Michael Nedzelsky <> date = 2008-04-05 topic = Logic/Computability abstract = This document presents the formalization of introductory material from recursion theory --- definitions and basic properties of primitive recursive functions, Cantor pairing function and computably enumerable sets (including a proof of existence of a one-complete computably enumerable set and a proof of the Rice's theorem). notify = MichaelNedzelsky@yandex.ru [Free-Boolean-Algebra] topic = Logic/General logic/Classical propositional logic title = Free Boolean Algebra author = Brian Huffman date = 2010-03-29 abstract = This theory defines a type constructor representing the free Boolean algebra over a set of generators. Values of type (α)formula represent propositional formulas with uninterpreted variables from type α, ordered by implication. In addition to all the standard Boolean algebra operations, the library also provides a function for building homomorphisms to any other Boolean algebra type. notify = brianh@cs.pdx.edu [Sort_Encodings] title = Sound and Complete Sort Encodings for First-Order Logic author = Jasmin Christian Blanchette , Andrei Popescu date = 2013-06-27 topic = Logic/General logic/Mechanization of proofs abstract = This is a formalization of the soundness and completeness properties for various efficient encodings of sorts in unsorted first-order logic used by Isabelle's Sledgehammer tool.

Essentially, the encodings proceed as follows: a many-sorted problem is decorated with (as few as possible) tags or guards that make the problem monotonic; then sorts can be soundly erased.

The development employs a formalization of many-sorted first-order logic in clausal form (clauses, structures and the basic properties of the satisfaction relation), which could be of interest as the starting point for other formalizations of first-order logic metatheory. notify = uuomul@yahoo.com [Lambda_Free_RPOs] title = Formalization of Recursive Path Orders for Lambda-Free Higher-Order Terms author = Jasmin Christian Blanchette , Uwe Waldmann , Daniel Wand date = 2016-09-23 topic = Logic/Rewriting abstract = This Isabelle/HOL formalization defines recursive path orders (RPOs) for higher-order terms without lambda-abstraction and proves many useful properties about them. The main order fully coincides with the standard RPO on first-order terms also in the presence of currying, distinguishing it from previous work. An optimized variant is formalized as well. It appears promising as the basis of a higher-order superposition calculus. notify = jasmin.blanchette@gmail.com [Lambda_Free_KBOs] title = Formalization of Knuth–Bendix Orders for Lambda-Free Higher-Order Terms author = Heiko Becker , Jasmin Christian Blanchette , Uwe Waldmann , Daniel Wand date = 2016-11-12 topic = Logic/Rewriting abstract = This Isabelle/HOL formalization defines Knuth–Bendix orders for higher-order terms without lambda-abstraction and proves many useful properties about them. The main order fully coincides with the standard transfinite KBO with subterm coefficients on first-order terms. It appears promising as the basis of a higher-order superposition calculus. notify = jasmin.blanchette@gmail.com [Lambda_Free_EPO] title = Formalization of the Embedding Path Order for Lambda-Free Higher-Order Terms author = Alexander Bentkamp topic = Logic/Rewriting date = 2018-10-19 notify = a.bentkamp@vu.nl abstract = This Isabelle/HOL formalization defines the Embedding Path Order (EPO) for higher-order terms without lambda-abstraction and proves many useful properties about it. In contrast to the lambda-free recursive path orders, it does not fully coincide with RPO on first-order terms, but it is compatible with arbitrary higher-order contexts. [Nested_Multisets_Ordinals] title = Formalization of Nested Multisets, Hereditary Multisets, and Syntactic Ordinals author = Jasmin Christian Blanchette , Mathias Fleury , Dmitriy Traytel date = 2016-11-12 topic = Logic/Rewriting abstract = This Isabelle/HOL formalization introduces a nested multiset datatype and defines Dershowitz and Manna's nested multiset order. The order is proved well founded and linear. By removing one constructor, we transform the nested multisets into hereditary multisets. These are isomorphic to the syntactic ordinals—the ordinals can be recursively expressed in Cantor normal form. Addition, subtraction, multiplication, and linear orders are provided on this type. notify = jasmin.blanchette@gmail.com [Abstract-Rewriting] title = Abstract Rewriting topic = Logic/Rewriting date = 2010-06-14 author = Christian Sternagel , René Thiemann license = LGPL abstract = We present an Isabelle formalization of abstract rewriting (see, e.g., the book by Baader and Nipkow). First, we define standard relations like joinability, meetability, conversion, etc. Then, we formalize important properties of abstract rewrite systems, e.g., confluence and strong normalization. Our main concern is on strong normalization, since this formalization is the basis of CeTA (which is mainly about strong normalization of term rewrite systems). Hence lemmas involving strong normalization constitute by far the biggest part of this theory. One of those is Newman's lemma. extra-history = Change history: [2010-09-17]: Added theories defining several (ordered) semirings related to strong normalization and giving some standard instances.
[2013-10-16]: Generalized delta-orders from rationals to Archimedean fields. notify = christian.sternagel@uibk.ac.at, rene.thiemann@uibk.ac.at [First_Order_Terms] title = First-Order Terms author = Christian Sternagel , René Thiemann topic = Logic/Rewriting, Computer science/Algorithms license = LGPL date = 2018-02-06 notify = c.sternagel@gmail.com, rene.thiemann@uibk.ac.at abstract = We formalize basic results on first-order terms, including matching and a first-order unification algorithm, as well as well-foundedness of the subsumption order. This entry is part of the Isabelle Formalization of Rewriting IsaFoR, where first-order terms are omni-present: the unification algorithm is used to certify several confluence and termination techniques, like critical-pair computation and dependency graph approximations; and the subsumption order is a crucial ingredient for completion. [Free-Groups] title = Free Groups author = Joachim Breitner date = 2010-06-24 topic = Mathematics/Algebra abstract = Free Groups are, in a sense, the most generic kind of group. They are defined over a set of generators with no additional relations in between them. They play an important role in the definition of group presentations and in other fields. This theory provides the definition of Free Group as the set of fully canceled words in the generators. The universal property is proven, as well as some isomorphisms results about Free Groups. extra-history = Change history: [2011-12-11]: Added the Ping Pong Lemma. notify = [CofGroups] title = An Example of a Cofinitary Group in Isabelle/HOL author = Bart Kastermans date = 2009-08-04 topic = Mathematics/Algebra abstract = We formalize the usual proof that the group generated by the function k -> k + 1 on the integers gives rise to a cofinitary group. notify = nipkow@in.tum.de [Finitely_Generated_Abelian_Groups] title = Finitely Generated Abelian Groups author = Joseph Thommes<>, Manuel Eberl topic = Mathematics/Algebra date = 2021-07-07 notify = joseph-thommes@gmx.de, eberlm@in.tum.de abstract = This article deals with the formalisation of some group-theoretic results including the fundamental theorem of finitely generated abelian groups characterising the structure of these groups as a uniquely determined product of cyclic groups. Both the invariant factor decomposition and the primary decomposition are covered. Additional work includes results about the direct product, the internal direct product and more group-theoretic lemmas. [Group-Ring-Module] title = Groups, Rings and Modules author = Hidetsune Kobayashi <>, L. Chen <>, H. Murao <> date = 2004-05-18 topic = Mathematics/Algebra abstract = The theory of groups, rings and modules is developed to a great depth. Group theory results include Zassenhaus's theorem and the Jordan-Hoelder theorem. The ring theory development includes ideals, quotient rings and the Chinese remainder theorem. The module development includes the Nakayama lemma, exact sequences and Tensor products. notify = lp15@cam.ac.uk [Robbins-Conjecture] title = A Complete Proof of the Robbins Conjecture author = Matthew Wampler-Doty <> date = 2010-05-22 topic = Mathematics/Algebra abstract = This document gives a formalization of the proof of the Robbins conjecture, following A. Mann, A Complete Proof of the Robbins Conjecture, 2003. notify = nipkow@in.tum.de [Valuation] title = Fundamental Properties of Valuation Theory and Hensel's Lemma author = Hidetsune Kobayashi <> date = 2007-08-08 topic = Mathematics/Algebra abstract = Convergence with respect to a valuation is discussed as convergence of a Cauchy sequence. Cauchy sequences of polynomials are defined. They are used to formalize Hensel's lemma. notify = lp15@cam.ac.uk [Rank_Nullity_Theorem] title = Rank-Nullity Theorem in Linear Algebra author = Jose Divasón , Jesús Aransay topic = Mathematics/Algebra date = 2013-01-16 abstract = In this contribution, we present some formalizations based on the HOL-Multivariate-Analysis session of Isabelle. Firstly, a generalization of several theorems of such library are presented. Secondly, some definitions and proofs involving Linear Algebra and the four fundamental subspaces of a matrix are shown. Finally, we present a proof of the result known in Linear Algebra as the ``Rank-Nullity Theorem'', which states that, given any linear map f from a finite dimensional vector space V to a vector space W, then the dimension of V is equal to the dimension of the kernel of f (which is a subspace of V) and the dimension of the range of f (which is a subspace of W). The proof presented here is based on the one given by Sheldon Axler in his book Linear Algebra Done Right. As a corollary of the previous theorem, and taking advantage of the relationship between linear maps and matrices, we prove that, for every matrix A (which has associated a linear map between finite dimensional vector spaces), the sum of its null space and its column space (which is equal to the range of the linear map) is equal to the number of columns of A. extra-history = Change history: [2014-07-14]: Added some generalizations that allow us to formalize the Rank-Nullity Theorem over finite dimensional vector spaces, instead of over the more particular euclidean spaces. Updated abstract. notify = jose.divasonm@unirioja.es, jesus-maria.aransay@unirioja.es [Affine_Arithmetic] title = Affine Arithmetic author = Fabian Immler date = 2014-02-07 topic = Mathematics/Analysis abstract = We give a formalization of affine forms as abstract representations of zonotopes. We provide affine operations as well as overapproximations of some non-affine operations like multiplication and division. Expressions involving those operations can automatically be turned into (executable) functions approximating the original expression in affine arithmetic. extra-history = Change history: [2015-01-31]: added algorithm for zonotope/hyperplane intersection
[2017-09-20]: linear approximations for all symbols from the floatarith data type notify = immler@in.tum.de [Laplace_Transform] title = Laplace Transform author = Fabian Immler topic = Mathematics/Analysis date = 2019-08-14 notify = fimmler@cs.cmu.edu abstract = This entry formalizes the Laplace transform and concrete Laplace transforms for arithmetic functions, frequency shift, integration and (higher) differentiation in the time domain. It proves Lerch's lemma and uniqueness of the Laplace transform for continuous functions. In order to formalize the foundational assumptions, this entry contains a formalization of piecewise continuous functions and functions of exponential order. [Cauchy] title = Cauchy's Mean Theorem and the Cauchy-Schwarz Inequality author = Benjamin Porter <> date = 2006-03-14 topic = Mathematics/Analysis abstract = This document presents the mechanised proofs of two popular theorems attributed to Augustin Louis Cauchy - Cauchy's Mean Theorem and the Cauchy-Schwarz Inequality. notify = kleing@cse.unsw.edu.au [Integration] title = Integration theory and random variables author = Stefan Richter date = 2004-11-19 topic = Mathematics/Analysis abstract = Lebesgue-style integration plays a major role in advanced probability. We formalize concepts of elementary measure theory, real-valued random variables as Borel-measurable functions, and a stepwise inductive definition of the integral itself. All proofs are carried out in human readable style using the Isar language. extra-note = Note: This article is of historical interest only. Lebesgue-style integration and probability theory are now available as part of the Isabelle/HOL distribution (directory Probability). notify = richter@informatik.rwth-aachen.de, nipkow@in.tum.de, hoelzl@in.tum.de [Ordinary_Differential_Equations] title = Ordinary Differential Equations author = Fabian Immler , Johannes Hölzl topic = Mathematics/Analysis date = 2012-04-26 abstract =

Session Ordinary-Differential-Equations formalizes ordinary differential equations (ODEs) and initial value problems. This work comprises proofs for local and global existence of unique solutions (Picard-Lindelöf theorem). Moreover, it contains a formalization of the (continuous or even differentiable) dependency of the flow on initial conditions as the flow of ODEs.

Not in the generated document are the following sessions:

  • HOL-ODE-Numerics: Rigorous numerical algorithms for computing enclosures of solutions based on Runge-Kutta methods and affine arithmetic. Reachability analysis with splitting and reduction at hyperplanes.
  • HOL-ODE-Examples: Applications of the numerical algorithms to concrete systems of ODEs.
  • Lorenz_C0, Lorenz_C1: Verified algorithms for checking C1-information according to Tucker's proof, computation of C0-information.

extra-history = Change history: [2014-02-13]: added an implementation of the Euler method based on affine arithmetic
[2016-04-14]: added flow and variational equation
[2016-08-03]: numerical algorithms for reachability analysis (using second-order Runge-Kutta methods, splitting, and reduction) implemented using Lammich's framework for automatic refinement
[2017-09-20]: added Poincare map and propagation of variational equation in reachability analysis, verified algorithms for C1-information and computations for C0-information of the Lorenz attractor. notify = immler@in.tum.de, hoelzl@in.tum.de [Polynomials] title = Executable Multivariate Polynomials author = Christian Sternagel , René Thiemann , Alexander Maletzky , Fabian Immler , Florian Haftmann , Andreas Lochbihler , Alexander Bentkamp date = 2010-08-10 topic = Mathematics/Analysis, Mathematics/Algebra, Computer science/Algorithms/Mathematical license = LGPL abstract = We define multivariate polynomials over arbitrary (ordered) semirings in combination with (executable) operations like addition, multiplication, and substitution. We also define (weak) monotonicity of polynomials and comparison of polynomials where we provide standard estimations like absolute positiveness or the more recent approach of Neurauter, Zankl, and Middeldorp. Moreover, it is proven that strongly normalizing (monotone) orders can be lifted to strongly normalizing (monotone) orders over polynomials. Our formalization was performed as part of the IsaFoR/CeTA-system which contains several termination techniques. The provided theories have been essential to formalize polynomial interpretations.

This formalization also contains an abstract representation as coefficient functions with finite support and a type of power-products. If this type is ordered by a linear (term) ordering, various additional notions, such as leading power-product, leading coefficient etc., are introduced as well. Furthermore, a lot of generic properties of, and functions on, multivariate polynomials are formalized, including the substitution and evaluation homomorphisms, embeddings of polynomial rings into larger rings (i.e. with one additional indeterminate), homogenization and dehomogenization of polynomials, and the canonical isomorphism between R[X,Y] and R[X][Y]. extra-history = Change history: [2010-09-17]: Moved theories on arbitrary (ordered) semirings to Abstract Rewriting.
[2016-10-28]: Added abstract representation of polynomials and authors Maletzky/Immler.
[2018-01-23]: Added authors Haftmann, Lochbihler after incorporating their formalization of multivariate polynomials based on Polynomial mappings. Moved material from Bentkamp's entry "Deep Learning".
[2019-04-18]: Added material about polynomials whose power-products are represented themselves by polynomial mappings. notify = rene.thiemann@uibk.ac.at, christian.sternagel@uibk.ac.at, alexander.maletzky@risc.jku.at, immler@in.tum.de [Sqrt_Babylonian] title = Computing N-th Roots using the Babylonian Method author = René Thiemann date = 2013-01-03 topic = Mathematics/Analysis license = LGPL abstract = We implement the Babylonian method to compute n-th roots of numbers. We provide precise algorithms for naturals, integers and rationals, and offer an approximation algorithm for square roots over linear ordered fields. Moreover, there are precise algorithms to compute the floor and the ceiling of n-th roots. extra-history = Change history: [2013-10-16]: Added algorithms to compute floor and ceiling of sqrt of integers. [2014-07-11]: Moved NthRoot_Impl from Real-Impl to this entry. notify = rene.thiemann@uibk.ac.at [Sturm_Sequences] title = Sturm's Theorem author = Manuel Eberl date = 2014-01-11 topic = Mathematics/Analysis abstract = Sturm's Theorem states that polynomial sequences with certain properties, so-called Sturm sequences, can be used to count the number of real roots of a real polynomial. This work contains a proof of Sturm's Theorem and code for constructing Sturm sequences efficiently. It also provides the “sturm” proof method, which can decide certain statements about the roots of real polynomials, such as “the polynomial P has exactly n roots in the interval I” or “P(x) > Q(x) for all x ∈ ℝ”. notify = eberlm@in.tum.de [Sturm_Tarski] title = The Sturm-Tarski Theorem author = Wenda Li date = 2014-09-19 topic = Mathematics/Analysis abstract = We have formalized the Sturm-Tarski theorem (also referred as the Tarski theorem), which generalizes Sturm's theorem. Sturm's theorem is usually used as a way to count distinct real roots, while the Sturm-Tarksi theorem forms the basis for Tarski's classic quantifier elimination for real closed field. notify = wl302@cam.ac.uk [Markov_Models] title = Markov Models author = Johannes Hölzl , Tobias Nipkow date = 2012-01-03 topic = Mathematics/Probability theory, Computer science/Automata and formal languages abstract = This is a formalization of Markov models in Isabelle/HOL. It builds on Isabelle's probability theory. The available models are currently Discrete-Time Markov Chains and a extensions of them with rewards.

As application of these models we formalize probabilistic model checking of pCTL formulas, analysis of IPv4 address allocation in ZeroConf and an analysis of the anonymity of the Crowds protocol. See here for the corresponding paper. notify = hoelzl@in.tum.de [Probabilistic_System_Zoo] title = A Zoo of Probabilistic Systems author = Johannes Hölzl , Andreas Lochbihler , Dmitriy Traytel date = 2015-05-27 topic = Computer science/Automata and formal languages abstract = Numerous models of probabilistic systems are studied in the literature. Coalgebra has been used to classify them into system types and compare their expressiveness. We formalize the resulting hierarchy of probabilistic system types by modeling the semantics of the different systems as codatatypes. This approach yields simple and concise proofs, as bisimilarity coincides with equality for codatatypes.

This work is described in detail in the ITP 2015 publication by the authors. notify = traytel@in.tum.de [Density_Compiler] title = A Verified Compiler for Probability Density Functions author = Manuel Eberl , Johannes Hölzl , Tobias Nipkow date = 2014-10-09 topic = Mathematics/Probability theory, Computer science/Programming languages/Compiling abstract = Bhat et al. [TACAS 2013] developed an inductive compiler that computes density functions for probability spaces described by programs in a probabilistic functional language. In this work, we implement such a compiler for a modified version of this language within the theorem prover Isabelle and give a formal proof of its soundness w.r.t. the semantics of the source and target language. Together with Isabelle's code generation for inductive predicates, this yields a fully verified, executable density compiler. The proof is done in two steps: First, an abstract compiler working with abstract functions modelled directly in the theorem prover's logic is defined and proved sound. Then, this compiler is refined to a concrete version that returns a target-language expression.

An article with the same title and authors is published in the proceedings of ESOP 2015. A detailed presentation of this work can be found in the first author's master's thesis. notify = hoelzl@in.tum.de [CAVA_Automata] title = The CAVA Automata Library author = Peter Lammich date = 2014-05-28 topic = Computer science/Automata and formal languages abstract = We report on the graph and automata library that is used in the fully verified LTL model checker CAVA. As most components of CAVA use some type of graphs or automata, a common automata library simplifies assembly of the components and reduces redundancy.

The CAVA Automata Library provides a hierarchy of graph and automata classes, together with some standard algorithms. Its object oriented design allows for sharing of algorithms, theorems, and implementations between its classes, and also simplifies extensions of the library. Moreover, it is integrated into the Automatic Refinement Framework, supporting automatic refinement of the abstract automata types to efficient data structures.

Note that the CAVA Automata Library is work in progress. Currently, it is very specifically tailored towards the requirements of the CAVA model checker. Nevertheless, the formalization techniques presented here allow an extension of the library to a wider scope. Moreover, they are not limited to graph libraries, but apply to class hierarchies in general.

The CAVA Automata Library is described in the paper: Peter Lammich, The CAVA Automata Library, Isabelle Workshop 2014. notify = lammich@in.tum.de [LTL] title = Linear Temporal Logic author = Salomon Sickert contributors = Benedikt Seidl date = 2016-03-01 topic = Logic/General logic/Temporal logic, Computer science/Automata and formal languages abstract = This theory provides a formalisation of linear temporal logic (LTL) and unifies previous formalisations within the AFP. This entry establishes syntax and semantics for this logic and decouples it from existing entries, yielding a common environment for theories reasoning about LTL. Furthermore a parser written in SML and an executable simplifier are provided. extra-history = Change history: [2019-03-12]: Support for additional operators, implementation of common equivalence relations, definition of syntactic fragments of LTL and the minimal disjunctive normal form.
notify = sickert@in.tum.de [LTL_to_GBA] title = Converting Linear-Time Temporal Logic to Generalized Büchi Automata author = Alexander Schimpf , Peter Lammich date = 2014-05-28 topic = Computer science/Automata and formal languages abstract = We formalize linear-time temporal logic (LTL) and the algorithm by Gerth et al. to convert LTL formulas to generalized Büchi automata. We also formalize some syntactic rewrite rules that can be applied to optimize the LTL formula before conversion. Moreover, we integrate the Stuttering Equivalence AFP-Entry by Stefan Merz, adapting the lemma that next-free LTL formula cannot distinguish between stuttering equivalent runs to our setting.

We use the Isabelle Refinement and Collection framework, as well as the Autoref tool, to obtain a refined version of our algorithm, from which efficiently executable code can be extracted. notify = lammich@in.tum.de [Gabow_SCC] title = Verified Efficient Implementation of Gabow's Strongly Connected Components Algorithm author = Peter Lammich date = 2014-05-28 topic = Computer science/Algorithms/Graph, Mathematics/Graph theory abstract = We present an Isabelle/HOL formalization of Gabow's algorithm for finding the strongly connected components of a directed graph. Using data refinement techniques, we extract efficient code that performs comparable to a reference implementation in Java. Our style of formalization allows for re-using large parts of the proofs when defining variants of the algorithm. We demonstrate this by verifying an algorithm for the emptiness check of generalized Büchi automata, re-using most of the existing proofs. notify = lammich@in.tum.de [Promela] title = Promela Formalization author = René Neumann date = 2014-05-28 topic = Computer science/System description languages abstract = We present an executable formalization of the language Promela, the description language for models of the model checker SPIN. This formalization is part of the work for a completely verified model checker (CAVA), but also serves as a useful (and executable!) description of the semantics of the language itself, something that is currently missing. The formalization uses three steps: It takes an abstract syntax tree generated from an SML parser, removes syntactic sugar and enriches it with type information. This further gets translated into a transition system, on which the semantic engine (read: successor function) operates. notify = [CAVA_LTL_Modelchecker] title = A Fully Verified Executable LTL Model Checker author = Javier Esparza , Peter Lammich , René Neumann , Tobias Nipkow , Alexander Schimpf , Jan-Georg Smaus date = 2014-05-28 topic = Computer science/Automata and formal languages abstract = We present an LTL model checker whose code has been completely verified using the Isabelle theorem prover. The checker consists of over 4000 lines of ML code. The code is produced using the Isabelle Refinement Framework, which allows us to split its correctness proof into (1) the proof of an abstract version of the checker, consisting of a few hundred lines of ``formalized pseudocode'', and (2) a verified refinement step in which mathematical sets and other abstract structures are replaced by implementations of efficient structures like red-black trees and functional arrays. This leads to a checker that, while still slower than unverified checkers, can already be used as a trusted reference implementation against which advanced implementations can be tested.

An early version of this model checker is described in the CAV 2013 paper with the same title. notify = lammich@in.tum.de [Fermat3_4] title = Fermat's Last Theorem for Exponents 3 and 4 and the Parametrisation of Pythagorean Triples author = Roelof Oosterhuis <> date = 2007-08-12 topic = Mathematics/Number theory abstract = This document presents the mechanised proofs of

  • Fermat's Last Theorem for exponents 3 and 4 and
  • the parametrisation of Pythagorean Triples.
notify = nipkow@in.tum.de, roelofoosterhuis@gmail.com [Perfect-Number-Thm] title = Perfect Number Theorem author = Mark Ijbema date = 2009-11-22 topic = Mathematics/Number theory abstract = These theories present the mechanised proof of the Perfect Number Theorem. notify = nipkow@in.tum.de [SumSquares] title = Sums of Two and Four Squares author = Roelof Oosterhuis <> date = 2007-08-12 topic = Mathematics/Number theory abstract = This document presents the mechanised proofs of the following results:
  • any prime number of the form 4m+1 can be written as the sum of two squares;
  • any natural number can be written as the sum of four squares
notify = nipkow@in.tum.de, roelofoosterhuis@gmail.com [Lehmer] title = Lehmer's Theorem author = Simon Wimmer , Lars Noschinski date = 2013-07-22 topic = Mathematics/Number theory abstract = In 1927, Lehmer presented criterions for primality, based on the converse of Fermat's litte theorem. This work formalizes the second criterion from Lehmer's paper, a necessary and sufficient condition for primality.

As a side product we formalize some properties of Euler's phi-function, the notion of the order of an element of a group, and the cyclicity of the multiplicative group of a finite field. notify = noschinl@gmail.com, simon.wimmer@tum.de [Pratt_Certificate] title = Pratt's Primality Certificates author = Simon Wimmer , Lars Noschinski date = 2013-07-22 topic = Mathematics/Number theory abstract = In 1975, Pratt introduced a proof system for certifying primes. He showed that a number p is prime iff a primality certificate for p exists. By showing a logarithmic upper bound on the length of the certificates in size of the prime number, he concluded that the decision problem for prime numbers is in NP. This work formalizes soundness and completeness of Pratt's proof system as well as an upper bound for the size of the certificate. notify = noschinl@gmail.com, simon.wimmer@tum.de [Monad_Memo_DP] title = Monadification, Memoization and Dynamic Programming author = Simon Wimmer , Shuwei Hu , Tobias Nipkow topic = Computer science/Programming languages/Transformations, Computer science/Algorithms, Computer science/Functional programming date = 2018-05-22 notify = wimmers@in.tum.de abstract = We present a lightweight framework for the automatic verified (functional or imperative) memoization of recursive functions. Our tool can turn a pure Isabelle/HOL function definition into a monadified version in a state monad or the Imperative HOL heap monad, and prove a correspondence theorem. We provide a variety of memory implementations for the two types of monads. A number of simple techniques allow us to achieve bottom-up computation and space-efficient memoization. The framework’s utility is demonstrated on a number of representative dynamic programming problems. A detailed description of our work can be found in the accompanying paper [2]. [Probabilistic_Timed_Automata] title = Probabilistic Timed Automata author = Simon Wimmer , Johannes Hölzl topic = Mathematics/Probability theory, Computer science/Automata and formal languages date = 2018-05-24 notify = wimmers@in.tum.de, hoelzl@in.tum.de abstract = We present a formalization of probabilistic timed automata (PTA) for which we try to follow the formula MDP + TA = PTA as far as possible: our work starts from our existing formalizations of Markov decision processes (MDP) and timed automata (TA) and combines them modularly. We prove the fundamental result for probabilistic timed automata: the region construction that is known from timed automata carries over to the probabilistic setting. In particular, this allows us to prove that minimum and maximum reachability probabilities can be computed via a reduction to MDP model checking, including the case where one wants to disregard unrealizable behavior. Further information can be found in our ITP paper [2]. [Hidden_Markov_Models] title = Hidden Markov Models author = Simon Wimmer topic = Mathematics/Probability theory, Computer science/Algorithms date = 2018-05-25 notify = wimmers@in.tum.de abstract = This entry contains a formalization of hidden Markov models [3] based on Johannes Hölzl's formalization of discrete time Markov chains [1]. The basic definitions are provided and the correctness of two main (dynamic programming) algorithms for hidden Markov models is proved: the forward algorithm for computing the likelihood of an observed sequence, and the Viterbi algorithm for decoding the most probable hidden state sequence. The Viterbi algorithm is made executable including memoization. Hidden markov models have various applications in natural language processing. For an introduction see Jurafsky and Martin [2]. [ArrowImpossibilityGS] title = Arrow and Gibbard-Satterthwaite author = Tobias Nipkow date = 2008-09-01 topic = Mathematics/Games and economics abstract = This article formalizes two proofs of Arrow's impossibility theorem due to Geanakoplos and derives the Gibbard-Satterthwaite theorem as a corollary. One formalization is based on utility functions, the other one on strict partial orders.

An article about these proofs is found here. notify = nipkow@in.tum.de [SenSocialChoice] title = Some classical results in Social Choice Theory author = Peter Gammie date = 2008-11-09 topic = Mathematics/Games and economics abstract = Drawing on Sen's landmark work "Collective Choice and Social Welfare" (1970), this development proves Arrow's General Possibility Theorem, Sen's Liberal Paradox and May's Theorem in a general setting. The goal was to make precise the classical statements and proofs of these results, and to provide a foundation for more recent results such as the Gibbard-Satterthwaite and Duggan-Schwartz theorems. notify = nipkow@in.tum.de [Vickrey_Clarke_Groves] title = VCG - Combinatorial Vickrey-Clarke-Groves Auctions author = Marco B. Caminati <>, Manfred Kerber , Christoph Lange, Colin Rowat date = 2015-04-30 topic = Mathematics/Games and economics abstract = A VCG auction (named after their inventors Vickrey, Clarke, and Groves) is a generalization of the single-good, second price Vickrey auction to the case of a combinatorial auction (multiple goods, from which any participant can bid on each possible combination). We formalize in this entry VCG auctions, including tie-breaking and prove that the functions for the allocation and the price determination are well-defined. Furthermore we show that the allocation function allocates goods only to participants, only goods in the auction are allocated, and no good is allocated twice. We also show that the price function is non-negative. These properties also hold for the automatically extracted Scala code. notify = mnfrd.krbr@gmail.com [Topology] title = Topology author = Stefan Friedrich <> date = 2004-04-26 topic = Mathematics/Topology abstract = This entry contains two theories. The first, Topology, develops the basic notions of general topology. The second, which can be viewed as a demonstration of the first, is called LList_Topology. It develops the topology of lazy lists. notify = lcp@cl.cam.ac.uk [Knot_Theory] title = Knot Theory author = T.V.H. Prathamesh date = 2016-01-20 topic = Mathematics/Topology abstract = This work contains a formalization of some topics in knot theory. The concepts that were formalized include definitions of tangles, links, framed links and link/tangle equivalence. The formalization is based on a formulation of links in terms of tangles. We further construct and prove the invariance of the Bracket polynomial. Bracket polynomial is an invariant of framed links closely linked to the Jones polynomial. This is perhaps the first attempt to formalize any aspect of knot theory in an interactive proof assistant. notify = prathamesh@imsc.res.in [Graph_Theory] title = Graph Theory author = Lars Noschinski date = 2013-04-28 topic = Mathematics/Graph theory abstract = This development provides a formalization of directed graphs, supporting (labelled) multi-edges and infinite graphs. A polymorphic edge type allows edges to be treated as pairs of vertices, if multi-edges are not required. Formalized properties are i.a. walks (and related concepts), connectedness and subgraphs and basic properties of isomorphisms.

This formalization is used to prove characterizations of Euler Trails, Shortest Paths and Kuratowski subgraphs. notify = noschinl@gmail.com [Planarity_Certificates] title = Planarity Certificates author = Lars Noschinski date = 2015-11-11 topic = Mathematics/Graph theory abstract = This development provides a formalization of planarity based on combinatorial maps and proves that Kuratowski's theorem implies combinatorial planarity. Moreover, it contains verified implementations of programs checking certificates for planarity (i.e., a combinatorial map) or non-planarity (i.e., a Kuratowski subgraph). notify = noschinl@gmail.com [Max-Card-Matching] title = Maximum Cardinality Matching author = Christine Rizkallah date = 2011-07-21 topic = Mathematics/Graph theory abstract =

A matching in a graph G is a subset M of the edges of G such that no two share an endpoint. A matching has maximum cardinality if its cardinality is at least as large as that of any other matching. An odd-set cover OSC of a graph G is a labeling of the nodes of G with integers such that every edge of G is either incident to a node labeled 1 or connects two nodes labeled with the same number i ≥ 2.

This article proves Edmonds theorem:
Let M be a matching in a graph G and let OSC be an odd-set cover of G. For any i ≥ 0, let n(i) be the number of nodes labeled i. If |M| = n(1) + ∑i ≥ 2(n(i) div 2), then M is a maximum cardinality matching.

notify = nipkow@in.tum.de [Girth_Chromatic] title = A Probabilistic Proof of the Girth-Chromatic Number Theorem author = Lars Noschinski date = 2012-02-06 topic = Mathematics/Graph theory abstract = This works presents a formalization of the Girth-Chromatic number theorem in graph theory, stating that graphs with arbitrarily large girth and chromatic number exist. The proof uses the theory of Random Graphs to prove the existence with probabilistic arguments. notify = noschinl@gmail.com [Random_Graph_Subgraph_Threshold] title = Properties of Random Graphs -- Subgraph Containment author = Lars Hupel date = 2014-02-13 topic = Mathematics/Graph theory, Mathematics/Probability theory abstract = Random graphs are graphs with a fixed number of vertices, where each edge is present with a fixed probability. We are interested in the probability that a random graph contains a certain pattern, for example a cycle or a clique. A very high edge probability gives rise to perhaps too many edges (which degrades performance for many algorithms), whereas a low edge probability might result in a disconnected graph. We prove a theorem about a threshold probability such that a higher edge probability will asymptotically almost surely produce a random graph with the desired subgraph. notify = hupel@in.tum.de [Flyspeck-Tame] title = Flyspeck I: Tame Graphs author = Gertrud Bauer <>, Tobias Nipkow date = 2006-05-22 topic = Mathematics/Graph theory abstract = These theories present the verified enumeration of tame plane graphs as defined by Thomas C. Hales in his proof of the Kepler Conjecture in his book Dense Sphere Packings. A Blueprint for Formal Proofs. [CUP 2012]. The values of the constants in the definition of tameness are identical to those in the Flyspeck project. The IJCAR 2006 paper by Nipkow, Bauer and Schultz refers to the original version of Hales' proof, the ITP 2011 paper by Nipkow refers to the Blueprint version of the proof. extra-history = Change history: [2010-11-02]: modified theories to reflect the modified definition of tameness in Hales' revised proof.
[2014-07-03]: modified constants in def of tameness and Archive according to the final state of the Flyspeck proof. notify = nipkow@in.tum.de [Well_Quasi_Orders] title = Well-Quasi-Orders author = Christian Sternagel date = 2012-04-13 topic = Mathematics/Combinatorics abstract = Based on Isabelle/HOL's type class for preorders, we introduce a type class for well-quasi-orders (wqo) which is characterized by the absence of "bad" sequences (our proofs are along the lines of the proof of Nash-Williams, from which we also borrow terminology). Our main results are instantiations for the product type, the list type, and a type of finite trees, which (almost) directly follow from our proofs of (1) Dickson's Lemma, (2) Higman's Lemma, and (3) Kruskal's Tree Theorem. More concretely:
  • If the sets A and B are wqo then their Cartesian product is wqo.
  • If the set A is wqo then the set of finite lists over A is wqo.
  • If the set A is wqo then the set of finite trees over A is wqo.
The research was funded by the Austrian Science Fund (FWF): J3202. extra-history = Change history: [2012-06-11]: Added Kruskal's Tree Theorem.
[2012-12-19]: New variant of Kruskal's tree theorem for terms (as opposed to variadic terms, i.e., trees), plus finite version of the tree theorem as corollary.
[2013-05-16]: Simplified construction of minimal bad sequences.
[2014-07-09]: Simplified proofs of Higman's lemma and Kruskal's tree theorem, based on homogeneous sequences.
[2016-01-03]: An alternative proof of Higman's lemma by open induction.
[2017-06-08]: Proved (classical) equivalence to inductive definition of almost-full relations according to the ITP 2012 paper "Stop When You Are Almost-Full" by Vytiniotis, Coquand, and Wahlstedt. notify = c.sternagel@gmail.com [Marriage] title = Hall's Marriage Theorem author = Dongchen Jiang , Tobias Nipkow date = 2010-12-17 topic = Mathematics/Combinatorics abstract = Two proofs of Hall's Marriage Theorem: one due to Halmos and Vaughan, one due to Rado. extra-history = Change history: [2011-09-09]: Added Rado's proof notify = nipkow@in.tum.de [Bondy] title = Bondy's Theorem author = Jeremy Avigad , Stefan Hetzl date = 2012-10-27 topic = Mathematics/Combinatorics abstract = A proof of Bondy's theorem following B. Bollabas, Combinatorics, 1986, Cambridge University Press. notify = avigad@cmu.edu, hetzl@logic.at [Ramsey-Infinite] title = Ramsey's theorem, infinitary version author = Tom Ridge <> date = 2004-09-20 topic = Mathematics/Combinatorics abstract = This formalization of Ramsey's theorem (infinitary version) is taken from Boolos and Jeffrey, Computability and Logic, 3rd edition, Chapter 26. It differs slightly from the text by assuming a slightly stronger hypothesis. In particular, the induction hypothesis is stronger, holding for any infinite subset of the naturals. This avoids the rather peculiar mapping argument between kj and aikj on p.263, which is unnecessary and slightly mars this really beautiful result. notify = lp15@cam.ac.uk [Derangements] title = Derangements Formula author = Lukas Bulwahn date = 2015-06-27 topic = Mathematics/Combinatorics abstract = The Derangements Formula describes the number of fixpoint-free permutations as a closed formula. This theorem is the 88th theorem in a list of the ``Top 100 Mathematical Theorems''. notify = lukas.bulwahn@gmail.com [Euler_Partition] title = Euler's Partition Theorem author = Lukas Bulwahn date = 2015-11-19 topic = Mathematics/Combinatorics abstract = Euler's Partition Theorem states that the number of partitions with only distinct parts is equal to the number of partitions with only odd parts. The combinatorial proof follows John Harrison's HOL Light formalization. This theorem is the 45th theorem of the Top 100 Theorems list. notify = lukas.bulwahn@gmail.com [Discrete_Summation] title = Discrete Summation author = Florian Haftmann contributors = Amine Chaieb <> date = 2014-04-13 topic = Mathematics/Combinatorics abstract = These theories introduce basic concepts and proofs about discrete summation: shifts, formal summation, falling factorials and stirling numbers. As proof of concept, a simple summation conversion is provided. notify = florian.haftmann@informatik.tu-muenchen.de [Open_Induction] title = Open Induction author = Mizuhito Ogawa <>, Christian Sternagel date = 2012-11-02 topic = Mathematics/Combinatorics abstract = A proof of the open induction schema based on J.-C. Raoult, Proving open properties by induction, Information Processing Letters 29, 1988, pp.19-23.

This research was supported by the Austrian Science Fund (FWF): J3202.

notify = c.sternagel@gmail.com [Category] title = Category Theory to Yoneda's Lemma author = Greg O'Keefe date = 2005-04-21 topic = Mathematics/Category theory license = LGPL abstract = This development proves Yoneda's lemma and aims to be readable by humans. It only defines what is needed for the lemma: categories, functors and natural transformations. Limits, adjunctions and other important concepts are not included. extra-history = Change history: [2010-04-23]: The definition of the constant equinumerous was slightly too weak in the original submission and has been fixed in revision 8c2b5b3c995f. notify = lcp@cl.cam.ac.uk [Category2] title = Category Theory author = Alexander Katovsky date = 2010-06-20 topic = Mathematics/Category theory abstract = This article presents a development of Category Theory in Isabelle/HOL. A Category is defined using records and locales. Functors and Natural Transformations are also defined. The main result that has been formalized is that the Yoneda functor is a full and faithful embedding. We also formalize the completeness of many sorted monadic equational logic. Extensive use is made of the HOLZF theory in both cases. For an informal description see here [pdf]. notify = alexander.katovsky@cantab.net [FunWithFunctions] title = Fun With Functions author = Tobias Nipkow date = 2008-08-26 topic = Mathematics/Misc abstract = This is a collection of cute puzzles of the form ``Show that if a function satisfies the following constraints, it must be ...'' Please add further examples to this collection! notify = nipkow@in.tum.de [FunWithTilings] title = Fun With Tilings author = Tobias Nipkow , Lawrence C. Paulson date = 2008-11-07 topic = Mathematics/Misc abstract = Tilings are defined inductively. It is shown that one form of mutilated chess board cannot be tiled with dominoes, while another one can be tiled with L-shaped tiles. Please add further fun examples of this kind! notify = nipkow@in.tum.de [Lazy-Lists-II] title = Lazy Lists II author = Stefan Friedrich <> date = 2004-04-26 topic = Computer science/Data structures abstract = This theory contains some useful extensions to the LList (lazy list) theory by Larry Paulson, including finite, infinite, and positive llists over an alphabet, as well as the new constants take and drop and the prefix order of llists. Finally, the notions of safety and liveness in the sense of Alpern and Schneider (1985) are defined. notify = lcp@cl.cam.ac.uk [Ribbon_Proofs] title = Ribbon Proofs author = John Wickerson <> date = 2013-01-19 topic = Computer science/Programming languages/Logics abstract = This document concerns the theory of ribbon proofs: a diagrammatic proof system, based on separation logic, for verifying program correctness. We include the syntax, proof rules, and soundness results for two alternative formalisations of ribbon proofs.

Compared to traditional proof outlines, ribbon proofs emphasise the structure of a proof, so are intelligible and pedagogical. Because they contain less redundancy than proof outlines, and allow each proof step to be checked locally, they may be more scalable. Where proof outlines are cumbersome to modify, ribbon proofs can be visually manoeuvred to yield proofs of variant programs. notify = [Koenigsberg_Friendship] title = The Königsberg Bridge Problem and the Friendship Theorem author = Wenda Li date = 2013-07-19 topic = Mathematics/Graph theory abstract = This development provides a formalization of undirected graphs and simple graphs, which are based on Benedikt Nordhoff and Peter Lammich's simple formalization of labelled directed graphs in the archive. Then, with our formalization of graphs, we show both necessary and sufficient conditions for Eulerian trails and circuits as well as the fact that the Königsberg Bridge Problem does not have a solution. In addition, we show the Friendship Theorem in simple graphs. notify = [Tree_Decomposition] title = Tree Decomposition author = Christoph Dittmann notify = date = 2016-05-31 topic = Mathematics/Graph theory abstract = We formalize tree decompositions and tree width in Isabelle/HOL, proving that trees have treewidth 1. We also show that every edge of a tree decomposition is a separation of the underlying graph. As an application of this theorem we prove that complete graphs of size n have treewidth n-1. [Menger] title = Menger's Theorem author = Christoph Dittmann topic = Mathematics/Graph theory date = 2017-02-26 notify = isabelle@christoph-d.de abstract = We present a formalization of Menger's Theorem for directed and undirected graphs in Isabelle/HOL. This well-known result shows that if two non-adjacent distinct vertices u, v in a directed graph have no separator smaller than n, then there exist n internally vertex-disjoint paths from u to v. The version for undirected graphs follows immediately because undirected graphs are a special case of directed graphs. [IEEE_Floating_Point] title = A Formal Model of IEEE Floating Point Arithmetic author = Lei Yu contributors = Fabian Hellauer , Fabian Immler date = 2013-07-27 topic = Computer science/Data structures abstract = This development provides a formal model of IEEE-754 floating-point arithmetic. This formalization, including formal specification of the standard and proofs of important properties of floating-point arithmetic, forms the foundation for verifying programs with floating-point computation. There is also a code generation setup for floats so that we can execute programs using this formalization in functional programming languages. notify = lp15@cam.ac.uk, immler@in.tum.de extra-history = Change history: [2017-09-25]: Added conversions from and to software floating point numbers (by Fabian Hellauer and Fabian Immler).
[2018-02-05]: 'Modernized' representation following the formalization in HOL4: former "float_format" and predicate "is_valid" is now encoded in a type "('e, 'f) float" where 'e and 'f encode the size of exponent and fraction. [Native_Word] title = Native Word author = Andreas Lochbihler contributors = Peter Lammich date = 2013-09-17 topic = Computer science/Data structures abstract = This entry makes machine words and machine arithmetic available for code generation from Isabelle/HOL. It provides a common abstraction that hides the differences between the different target languages. The code generator maps these operations to the APIs of the target languages. Apart from that, we extend the available bit operations on types int and integer, and map them to the operations in the target languages. extra-history = Change history: [2013-11-06]: added conversion function between native words and characters (revision fd23d9a7fe3a)
[2014-03-31]: added words of default size in the target language (by Peter Lammich) (revision 25caf5065833)
[2014-10-06]: proper test setup with compilation and execution of tests in all target languages (revision 5d7a1c9ae047)
[2017-09-02]: added 64-bit words (revision c89f86244e3c)
[2018-07-15]: added cast operators for default-size words (revision fc1f1fb8dd30)
notify = mail@andreas-lochbihler.de [XML] title = XML author = Christian Sternagel , René Thiemann date = 2014-10-03 topic = Computer science/Functional programming, Computer science/Data structures abstract = This entry provides an XML library for Isabelle/HOL. This includes parsing and pretty printing of XML trees as well as combinators for transforming XML trees into arbitrary user-defined data. The main contribution of this entry is an interface (fit for code generation) that allows for communication between verified programs formalized in Isabelle/HOL and the outside world via XML. This library was developed as part of the IsaFoR/CeTA project to which we refer for examples of its usage. notify = c.sternagel@gmail.com, rene.thiemann@uibk.ac.at [HereditarilyFinite] title = The Hereditarily Finite Sets author = Lawrence C. Paulson date = 2013-11-17 topic = Logic/Set theory abstract = The theory of hereditarily finite sets is formalised, following the development of Swierczkowski. An HF set is a finite collection of other HF sets; they enjoy an induction principle and satisfy all the axioms of ZF set theory apart from the axiom of infinity, which is negated. All constructions that are possible in ZF set theory (Cartesian products, disjoint sums, natural numbers, functions) without using infinite sets are possible here. The definition of addition for the HF sets follows Kirby. This development forms the foundation for the Isabelle proof of Gödel's incompleteness theorems, which has been formalised separately. extra-history = Change history: [2015-02-23]: Added the theory "Finitary" defining the class of types that can be embedded in hf, including int, char, option, list, etc. notify = lp15@cam.ac.uk [Incompleteness] title = Gödel's Incompleteness Theorems author = Lawrence C. Paulson date = 2013-11-17 topic = Logic/Proof theory abstract = Gödel's two incompleteness theorems are formalised, following a careful presentation by Swierczkowski, in the theory of hereditarily finite sets. This represents the first ever machine-assisted proof of the second incompleteness theorem. Compared with traditional formalisations using Peano arithmetic (see e.g. Boolos), coding is simpler, with no need to formalise the notion of multiplication (let alone that of a prime number) in the formalised calculus upon which the theorem is based. However, other technical problems had to be solved in order to complete the argument. notify = lp15@cam.ac.uk [Finite_Automata_HF] title = Finite Automata in Hereditarily Finite Set Theory author = Lawrence C. Paulson date = 2015-02-05 topic = Computer science/Automata and formal languages abstract = Finite Automata, both deterministic and non-deterministic, for regular languages. The Myhill-Nerode Theorem. Closure under intersection, concatenation, etc. Regular expressions define regular languages. Closure under reversal; the powerset construction mapping NFAs to DFAs. Left and right languages; minimal DFAs. Brzozowski's minimization algorithm. Uniqueness up to isomorphism of minimal DFAs. notify = lp15@cam.ac.uk [Decreasing-Diagrams] title = Decreasing Diagrams author = Harald Zankl license = LGPL date = 2013-11-01 topic = Logic/Rewriting abstract = This theory contains a formalization of decreasing diagrams showing that any locally decreasing abstract rewrite system is confluent. We consider the valley (van Oostrom, TCS 1994) and the conversion version (van Oostrom, RTA 2008) and closely follow the original proofs. As an application we prove Newman's lemma. notify = Harald.Zankl@uibk.ac.at [Decreasing-Diagrams-II] title = Decreasing Diagrams II author = Bertram Felgenhauer license = LGPL date = 2015-08-20 topic = Logic/Rewriting abstract = This theory formalizes the commutation version of decreasing diagrams for Church-Rosser modulo. The proof follows Felgenhauer and van Oostrom (RTA 2013). The theory also provides important specializations, in particular van Oostrom’s conversion version (TCS 2008) of decreasing diagrams. notify = bertram.felgenhauer@uibk.ac.at [GoedelGod] title = Gödel's God in Isabelle/HOL author = Christoph Benzmüller , Bruno Woltzenlogel Paleo date = 2013-11-12 topic = Logic/Philosophical aspects abstract = Dana Scott's version of Gödel's proof of God's existence is formalized in quantified modal logic KB (QML KB). QML KB is modeled as a fragment of classical higher-order logic (HOL); thus, the formalization is essentially a formalization in HOL. notify = lp15@cam.ac.uk, c.benzmueller@fu-berlin.de [Types_Tableaus_and_Goedels_God] title = Types, Tableaus and Gödel’s God in Isabelle/HOL author = David Fuenmayor , Christoph Benzmüller topic = Logic/Philosophical aspects date = 2017-05-01 notify = davfuenmayor@gmail.com, c.benzmueller@gmail.com abstract = A computer-formalisation of the essential parts of Fitting's textbook "Types, Tableaus and Gödel's God" in Isabelle/HOL is presented. In particular, Fitting's (and Anderson's) variant of the ontological argument is verified and confirmed. This variant avoids the modal collapse, which has been criticised as an undesirable side-effect of Kurt Gödel's (and Dana Scott's) versions of the ontological argument. Fitting's work is employing an intensional higher-order modal logic, which we shallowly embed here in classical higher-order logic. We then utilize the embedded logic for the formalisation of Fitting's argument. (See also the earlier AFP entry ``Gödel's God in Isabelle/HOL''.) [GewirthPGCProof] title = Formalisation and Evaluation of Alan Gewirth's Proof for the Principle of Generic Consistency in Isabelle/HOL author = David Fuenmayor , Christoph Benzmüller topic = Logic/Philosophical aspects date = 2018-10-30 notify = davfuenmayor@gmail.com, c.benzmueller@gmail.com abstract = An ambitious ethical theory ---Alan Gewirth's "Principle of Generic Consistency"--- is encoded and analysed in Isabelle/HOL. Gewirth's theory has stirred much attention in philosophy and ethics and has been proposed as a potential means to bound the impact of artificial general intelligence. extra-history = Change history: [2019-04-09]: added proof for a stronger variant of the PGC and examplary inferences (revision 88182cb0a2f6)
[Lowe_Ontological_Argument] title = Computer-assisted Reconstruction and Assessment of E. J. Lowe's Modal Ontological Argument author = David Fuenmayor , Christoph Benzmüller topic = Logic/Philosophical aspects date = 2017-09-21 notify = davfuenmayor@gmail.com, c.benzmueller@gmail.com abstract = Computers may help us to understand --not just verify-- philosophical arguments. By utilizing modern proof assistants in an iterative interpretive process, we can reconstruct and assess an argument by fully formal means. Through the mechanization of a variant of St. Anselm's ontological argument by E. J. Lowe, which is a paradigmatic example of a natural-language argument with strong ties to metaphysics and religion, we offer an ideal showcase for our computer-assisted interpretive method. [AnselmGod] title = Anselm's God in Isabelle/HOL author = Ben Blumson topic = Logic/Philosophical aspects date = 2017-09-06 notify = benblumson@gmail.com abstract = Paul Oppenheimer and Edward Zalta's formalisation of Anselm's ontological argument for the existence of God is automated by embedding a free logic for definite descriptions within Isabelle/HOL. [Tail_Recursive_Functions] title = A General Method for the Proof of Theorems on Tail-recursive Functions author = Pasquale Noce date = 2013-12-01 topic = Computer science/Functional programming abstract =

Tail-recursive function definitions are sometimes more straightforward than alternatives, but proving theorems on them may be roundabout because of the peculiar form of the resulting recursion induction rules.

This paper describes a proof method that provides a general solution to this problem by means of suitable invariants over inductive sets, and illustrates the application of such method by examining two case studies.

notify = pasquale.noce.lavoro@gmail.com [CryptoBasedCompositionalProperties] title = Compositional Properties of Crypto-Based Components author = Maria Spichkova date = 2014-01-11 topic = Computer science/Security abstract = This paper presents an Isabelle/HOL set of theories which allows the specification of crypto-based components and the verification of their composition properties wrt. cryptographic aspects. We introduce a formalisation of the security property of data secrecy, the corresponding definitions and proofs. Please note that here we import the Isabelle/HOL theory ListExtras.thy, presented in the AFP entry FocusStreamsCaseStudies-AFP. notify = maria.spichkova@rmit.edu.au [Featherweight_OCL] title = Featherweight OCL: A Proposal for a Machine-Checked Formal Semantics for OCL 2.5 author = Achim D. Brucker , Frédéric Tuong , Burkhart Wolff date = 2014-01-16 topic = Computer science/System description languages abstract = The Unified Modeling Language (UML) is one of the few modeling languages that is widely used in industry. While UML is mostly known as diagrammatic modeling language (e.g., visualizing class models), it is complemented by a textual language, called Object Constraint Language (OCL). The current version of OCL is based on a four-valued logic that turns UML into a formal language. Any type comprises the elements "invalid" and "null" which are propagated as strict and non-strict, respectively. Unfortunately, the former semi-formal semantics of this specification language, captured in the "Annex A" of the OCL standard, leads to different interpretations of corner cases. We formalize the core of OCL: denotational definitions, a logical calculus and operational rules that allow for the execution of OCL expressions by a mixture of term rewriting and code compilation. Our formalization reveals several inconsistencies and contradictions in the current version of the OCL standard. Overall, this document is intended to provide the basis for a machine-checked text "Annex A" of the OCL standard targeting at tool implementors. extra-history = Change history: [2015-10-13]: afp-devel@ea3b38fc54d6 and hol-testgen@12148
   Update of Featherweight OCL including a change in the abstract.
[2014-01-16]: afp-devel@9091ce05cb20 and hol-testgen@10241
   New Entry: Featherweight OCL notify = brucker@spamfence.net, tuong@users.gforge.inria.fr, wolff@lri.fr [Relation_Algebra] title = Relation Algebra author = Alasdair Armstrong <>, Simon Foster , Georg Struth , Tjark Weber date = 2014-01-25 topic = Mathematics/Algebra abstract = Tarski's algebra of binary relations is formalised along the lines of the standard textbooks of Maddux and Schmidt and Ströhlein. This includes relation-algebraic concepts such as subidentities, vectors and a domain operation as well as various notions associated to functions. Relation algebras are also expanded by a reflexive transitive closure operation, and they are linked with Kleene algebras and models of binary relations and Boolean matrices. notify = g.struth@sheffield.ac.uk, tjark.weber@it.uu.se [PSemigroupsConvolution] title = Partial Semigroups and Convolution Algebras author = Brijesh Dongol , Victor B. F. Gomes , Ian J. Hayes , Georg Struth topic = Mathematics/Algebra date = 2017-06-13 notify = g.struth@sheffield.ac.uk, victor.gomes@cl.cam.ac.uk abstract = Partial Semigroups are relevant to the foundations of quantum mechanics and combinatorics as well as to interval and separation logics. Convolution algebras can be understood either as algebras of generalised binary modalities over ternary Kripke frames, in particular over partial semigroups, or as algebras of quantale-valued functions which are equipped with a convolution-style operation of multiplication that is parametrised by a ternary relation. Convolution algebras provide algebraic semantics for various substructural logics, including categorial, relevance and linear logics, for separation logic and for interval logics; they cover quantitative and qualitative applications. These mathematical components for partial semigroups and convolution algebras provide uniform foundations from which models of computation based on relations, program traces or pomsets, and verification components for separation or interval temporal logics can be built with little effort. [Secondary_Sylow] title = Secondary Sylow Theorems author = Jakob von Raumer date = 2014-01-28 topic = Mathematics/Algebra abstract = These theories extend the existing proof of the first Sylow theorem (written by Florian Kammueller and L. C. Paulson) by what are often called the second, third and fourth Sylow theorems. These theorems state propositions about the number of Sylow p-subgroups of a group and the fact that they are conjugate to each other. The proofs make use of an implementation of group actions and their properties. notify = psxjv4@nottingham.ac.uk [Jordan_Hoelder] title = The Jordan-Hölder Theorem author = Jakob von Raumer date = 2014-09-09 topic = Mathematics/Algebra abstract = This submission contains theories that lead to a formalization of the proof of the Jordan-Hölder theorem about composition series of finite groups. The theories formalize the notions of isomorphism classes of groups, simple groups, normal series, composition series, maximal normal subgroups. Furthermore, they provide proofs of the second isomorphism theorem for groups, the characterization theorem for maximal normal subgroups as well as many useful lemmas about normal subgroups and factor groups. The proof is inspired by course notes of Stuart Rankin. notify = psxjv4@nottingham.ac.uk [Cayley_Hamilton] title = The Cayley-Hamilton Theorem author = Stephan Adelsberger , Stefan Hetzl , Florian Pollak date = 2014-09-15 topic = Mathematics/Algebra abstract = This document contains a proof of the Cayley-Hamilton theorem based on the development of matrices in HOL/Multivariate Analysis. notify = stvienna@gmail.com [Probabilistic_Noninterference] title = Probabilistic Noninterference author = Andrei Popescu , Johannes Hölzl date = 2014-03-11 topic = Computer science/Security abstract = We formalize a probabilistic noninterference for a multi-threaded language with uniform scheduling, where probabilistic behaviour comes from both the scheduler and the individual threads. We define notions probabilistic noninterference in two variants: resumption-based and trace-based. For the resumption-based notions, we prove compositionality w.r.t. the language constructs and establish sound type-system-like syntactic criteria. This is a formalization of the mathematical development presented at CPP 2013 and CALCO 2013. It is the probabilistic variant of the Possibilistic Noninterference AFP entry. notify = hoelzl@in.tum.de [HyperCTL] title = A shallow embedding of HyperCTL* author = Markus N. Rabe , Peter Lammich , Andrei Popescu date = 2014-04-16 topic = Computer science/Security, Logic/General logic/Temporal logic abstract = We formalize HyperCTL*, a temporal logic for expressing security properties. We first define a shallow embedding of HyperCTL*, within which we prove inductive and coinductive rules for the operators. Then we show that a HyperCTL* formula captures Goguen-Meseguer noninterference, a landmark information flow property. We also define a deep embedding and connect it to the shallow embedding by a denotational semantics, for which we prove sanity w.r.t. dependence on the free variables. Finally, we show that under some finiteness assumptions about the model, noninterference is given by a (finitary) syntactic formula. notify = uuomul@yahoo.com [Bounded_Deducibility_Security] title = Bounded-Deducibility Security author = Andrei Popescu , Peter Lammich , Thomas Bauereiss date = 2014-04-22 topic = Computer science/Security abstract = This is a formalization of bounded-deducibility security (BD security), a flexible notion of information-flow security applicable to arbitrary transition systems. It generalizes Sutherland's classic notion of nondeducibility by factoring in declassification bounds and trigger, whereas nondeducibility states that, in a system, information cannot flow between specified sources and sinks, BD security indicates upper bounds for the flow and triggers under which these upper bounds are no longer guaranteed. notify = uuomul@yahoo.com, lammich@in.tum.de, thomas@bauereiss.name extra-history = Change history: [2021-08-12]: Generalised BD Security from I/O automata to nondeterministic transition systems, with the former retained as an instance of the latter (renaming locale BD_Security to BD_Security_IO). Generalise unwinding conditions to allow making more than one transition at a time when constructing alternative traces. Add results about the expressivity of declassification triggers vs. bounds, due to Thomas Bauereiss (added as author). [Network_Security_Policy_Verification] title = Network Security Policy Verification author = Cornelius Diekmann date = 2014-07-04 topic = Computer science/Security abstract = We present a unified theory for verifying network security policies. A security policy is represented as directed graph. To check high-level security goals, security invariants over the policy are expressed. We cover monotonic security invariants, i.e. prohibiting more does not harm security. We provide the following contributions for the security invariant theory.
  • Secure auto-completion of scenario-specific knowledge, which eases usability.
  • Security violations can be repaired by tightening the policy iff the security invariants hold for the deny-all policy.
  • An algorithm to compute a security policy.
  • A formalization of stateful connection semantics in network security mechanisms.
  • An algorithm to compute a secure stateful implementation of a policy.
  • An executable implementation of all the theory.
  • Examples, ranging from an aircraft cabin data network to the analysis of a large real-world firewall.
  • More examples: A fully automated translation of high-level security goals to both firewall and SDN configurations (see Examples/Distributed_WebApp.thy).
For a detailed description, see extra-history = Change history: [2015-04-14]: Added Distributed WebApp example and improved graphviz visualization (revision 4dde08ca2ab8)
notify = diekmann@net.in.tum.de [Abstract_Completeness] title = Abstract Completeness author = Jasmin Christian Blanchette , Andrei Popescu , Dmitriy Traytel date = 2014-04-16 topic = Logic/Proof theory abstract = A formalization of an abstract property of possibly infinite derivation trees (modeled by a codatatype), representing the core of a proof (in Beth/Hintikka style) of the first-order logic completeness theorem, independent of the concrete syntax or inference rules. This work is described in detail in the IJCAR 2014 publication by the authors. The abstract proof can be instantiated for a wide range of Gentzen and tableau systems as well as various flavors of FOL---e.g., with or without predicates, equality, or sorts. Here, we give only a toy example instantiation with classical propositional logic. A more serious instance---many-sorted FOL with equality---is described elsewhere [Blanchette and Popescu, FroCoS 2013]. notify = traytel@in.tum.de [Pop_Refinement] title = Pop-Refinement author = Alessandro Coglio date = 2014-07-03 topic = Computer science/Programming languages/Misc abstract = Pop-refinement is an approach to stepwise refinement, carried out inside an interactive theorem prover by constructing a monotonically decreasing sequence of predicates over deeply embedded target programs. The sequence starts with a predicate that characterizes the possible implementations, and ends with a predicate that characterizes a unique program in explicit syntactic form. Pop-refinement enables more requirements (e.g. program-level and non-functional) to be captured in the initial specification and preserved through refinement. Security requirements expressed as hyperproperties (i.e. predicates over sets of traces) are always preserved by pop-refinement, unlike the popular notion of refinement as trace set inclusion. Two simple examples in Isabelle/HOL are presented, featuring program-level requirements, non-functional requirements, and hyperproperties. notify = coglio@kestrel.edu [VectorSpace] title = Vector Spaces author = Holden Lee date = 2014-08-29 topic = Mathematics/Algebra abstract = This formalisation of basic linear algebra is based completely on locales, building off HOL-Algebra. It includes basic definitions: linear combinations, span, linear independence; linear transformations; interpretation of function spaces as vector spaces; the direct sum of vector spaces, sum of subspaces; the replacement theorem; existence of bases in finite-dimensional; vector spaces, definition of dimension; the rank-nullity theorem. Some concepts are actually defined and proved for modules as they also apply there. Infinite-dimensional vector spaces are supported, but dimension is only supported for finite-dimensional vector spaces. The proofs are standard; the proofs of the replacement theorem and rank-nullity theorem roughly follow the presentation in Linear Algebra by Friedberg, Insel, and Spence. The rank-nullity theorem generalises the existing development in the Archive of Formal Proof (originally using type classes, now using a mix of type classes and locales). notify = holdenl@princeton.edu [Special_Function_Bounds] title = Real-Valued Special Functions: Upper and Lower Bounds author = Lawrence C. Paulson date = 2014-08-29 topic = Mathematics/Analysis abstract = This development proves upper and lower bounds for several familiar real-valued functions. For sin, cos, exp and sqrt, it defines and verifies infinite families of upper and lower bounds, mostly based on Taylor series expansions. For arctan, ln and exp, it verifies a finite collection of upper and lower bounds, originally obtained from the functions' continued fraction expansions using the computer algebra system Maple. A common theme in these proofs is to take the difference between a function and its approximation, which should be zero at one point, and then consider the sign of the derivative. The immediate purpose of this development is to verify axioms used by MetiTarski, an automatic theorem prover for real-valued special functions. Crucial to MetiTarski's operation is the provision of upper and lower bounds for each function of interest. notify = lp15@cam.ac.uk [Landau_Symbols] title = Landau Symbols author = Manuel Eberl date = 2015-07-14 topic = Mathematics/Analysis abstract = This entry provides Landau symbols to describe and reason about the asymptotic growth of functions for sufficiently large inputs. A number of simplification procedures are provided for additional convenience: cancelling of dominated terms in sums under a Landau symbol, cancelling of common factors in products, and a decision procedure for Landau expressions containing products of powers of functions like x, ln(x), ln(ln(x)) etc. notify = eberlm@in.tum.de [Error_Function] title = The Error Function author = Manuel Eberl topic = Mathematics/Analysis date = 2018-02-06 notify = eberlm@in.tum.de abstract =

This entry provides the definitions and basic properties of the complex and real error function erf and the complementary error function erfc. Additionally, it gives their full asymptotic expansions.

[Akra_Bazzi] title = The Akra-Bazzi theorem and the Master theorem author = Manuel Eberl date = 2015-07-14 topic = Mathematics/Analysis abstract = This article contains a formalisation of the Akra-Bazzi method based on a proof by Leighton. It is a generalisation of the well-known Master Theorem for analysing the complexity of Divide & Conquer algorithms. We also include a generalised version of the Master theorem based on the Akra-Bazzi theorem, which is easier to apply than the Akra-Bazzi theorem itself.

Some proof methods that facilitate applying the Master theorem are also included. For a more detailed explanation of the formalisation and the proof methods, see the accompanying paper (publication forthcoming). notify = eberlm@in.tum.de [Dirichlet_Series] title = Dirichlet Series author = Manuel Eberl topic = Mathematics/Number theory date = 2017-10-12 notify = eberlm@in.tum.de abstract = This entry is a formalisation of much of Chapters 2, 3, and 11 of Apostol's “Introduction to Analytic Number Theory”. This includes:

  • Definitions and basic properties for several number-theoretic functions (Euler's φ, Möbius μ, Liouville's λ, the divisor function σ, von Mangoldt's Λ)
  • Executable code for most of these functions, the most efficient implementations using the factoring algorithm by Thiemann et al.
  • Dirichlet products and formal Dirichlet series
  • Analytic results connecting convergent formal Dirichlet series to complex functions
  • Euler product expansions
  • Asymptotic estimates of number-theoretic functions including the density of squarefree integers and the average number of divisors of a natural number
These results are useful as a basis for developing more number-theoretic results, such as the Prime Number Theorem. [Gauss_Sums] title = Gauss Sums and the Pólya–Vinogradov Inequality author = Rodrigo Raya , Manuel Eberl topic = Mathematics/Number theory date = 2019-12-10 notify = manuel.eberl@tum.de abstract =

This article provides a full formalisation of Chapter 8 of Apostol's Introduction to Analytic Number Theory. Subjects that are covered are:

  • periodic arithmetic functions and their finite Fourier series
  • (generalised) Ramanujan sums
  • Gauss sums and separable characters
  • induced moduli and primitive characters
  • the Pólya—Vinogradov inequality
[Zeta_Function] title = The Hurwitz and Riemann ζ Functions author = Manuel Eberl topic = Mathematics/Number theory, Mathematics/Analysis date = 2017-10-12 notify = eberlm@in.tum.de abstract =

This entry builds upon the results about formal and analytic Dirichlet series to define the Hurwitz ζ function ζ(a,s) and, based on that, the Riemann ζ function ζ(s). This is done by first defining them for ℜ(z) > 1 and then successively extending the domain to the left using the Euler–MacLaurin formula.

Apart from the most basic facts such as analyticity, the following results are provided:

  • the Stieltjes constants and the Laurent expansion of ζ(s) at s = 1
  • the non-vanishing of ζ(s) for ℜ(z) ≥ 1
  • the relationship between ζ(a,s) and Γ
  • the special values at negative integers and positive even integers
  • Hurwitz's formula and the reflection formula for ζ(s)
  • the Hadjicostas–Chapman formula

The entry also contains Euler's analytic proof of the infinitude of primes, based on the fact that ζ(s) has a pole at s = 1.

[Linear_Recurrences] title = Linear Recurrences author = Manuel Eberl topic = Mathematics/Analysis date = 2017-10-12 notify = eberlm@in.tum.de abstract =

Linear recurrences with constant coefficients are an interesting class of recurrence equations that can be solved explicitly. The most famous example are certainly the Fibonacci numbers with the equation f(n) = f(n-1) + f(n - 2) and the quite non-obvious closed form (φn - (-φ)-n) / √5 where φ is the golden ratio.

In this work, I build on existing tools in Isabelle – such as formal power series and polynomial factorisation algorithms – to develop a theory of these recurrences and derive a fully executable solver for them that can be exported to programming languages like Haskell.

[Van_der_Waerden] title = Van der Waerden's Theorem author = Katharina Kreuzer , Manuel Eberl topic = Mathematics/Combinatorics date = 2021-06-22 notify = kreuzerk@in.tum.de, eberlm@in.tum.de abstract = This article formalises the proof of Van der Waerden's Theorem from Ramsey theory. Van der Waerden's Theorem states that for integers $k$ and $l$ there exists a number $N$ which guarantees that if an integer interval of length at least $N$ is coloured with $k$ colours, there will always be an arithmetic progression of length $l$ of the same colour in said interval. The proof goes along the lines of \cite{Swan}. The smallest number $N_{k,l}$ fulfilling Van der Waerden's Theorem is then called the Van der Waerden Number. Finding the Van der Waerden Number is still an open problem for most values of $k$ and $l$. [Lambert_W] title = The Lambert W Function on the Reals author = Manuel Eberl topic = Mathematics/Analysis date = 2020-04-24 notify = eberlm@in.tum.de abstract =

The Lambert W function is a multi-valued function defined as the inverse function of xx ex. Besides numerous applications in combinatorics, physics, and engineering, it also frequently occurs when solving equations containing both ex and x, or both x and log x.

This article provides a definition of the two real-valued branches W0(x) and W-1(x) and proves various properties such as basic identities and inequalities, monotonicity, differentiability, asymptotic expansions, and the MacLaurin series of W0(x) at x = 0.

[Cartan_FP] title = The Cartan Fixed Point Theorems author = Lawrence C. Paulson date = 2016-03-08 topic = Mathematics/Analysis abstract = The Cartan fixed point theorems concern the group of holomorphic automorphisms on a connected open set of Cn. Ciolli et al. have formalised the one-dimensional case of these theorems in HOL Light. This entry contains their proofs, ported to Isabelle/HOL. Thus it addresses the authors' remark that "it would be important to write a formal proof in a language that can be read by both humans and machines". notify = lp15@cam.ac.uk [Gauss_Jordan] title = Gauss-Jordan Algorithm and Its Applications author = Jose Divasón , Jesús Aransay topic = Computer science/Algorithms/Mathematical date = 2014-09-03 abstract = The Gauss-Jordan algorithm states that any matrix over a field can be transformed by means of elementary row operations to a matrix in reduced row echelon form. The formalization is based on the Rank Nullity Theorem entry of the AFP and on the HOL-Multivariate-Analysis session of Isabelle, where matrices are represented as functions over finite types. We have set up the code generator to make this representation executable. In order to improve the performance, a refinement to immutable arrays has been carried out. We have formalized some of the applications of the Gauss-Jordan algorithm. Thanks to this development, the following facts can be computed over matrices whose elements belong to a field: Ranks, Determinants, Inverses, Bases and dimensions and Solutions of systems of linear equations. Code can be exported to SML and Haskell. notify = jose.divasonm@unirioja.es, jesus-maria.aransay@unirioja.es [Echelon_Form] title = Echelon Form author = Jose Divasón , Jesús Aransay topic = Computer science/Algorithms/Mathematical, Mathematics/Algebra date = 2015-02-12 abstract = We formalize an algorithm to compute the Echelon Form of a matrix. We have proved its existence over Bézout domains and made it executable over Euclidean domains, such as the integer ring and the univariate polynomials over a field. This allows us to compute determinants, inverses and characteristic polynomials of matrices. The work is based on the HOL-Multivariate Analysis library, and on both the Gauss-Jordan and Cayley-Hamilton AFP entries. As a by-product, some algebraic structures have been implemented (principal ideal domains, Bézout domains...). The algorithm has been refined to immutable arrays and code can be generated to functional languages as well. notify = jose.divasonm@unirioja.es, jesus-maria.aransay@unirioja.es [QR_Decomposition] title = QR Decomposition author = Jose Divasón , Jesús Aransay topic = Computer science/Algorithms/Mathematical, Mathematics/Algebra date = 2015-02-12 abstract = QR decomposition is an algorithm to decompose a real matrix A into the product of two other matrices Q and R, where Q is orthogonal and R is invertible and upper triangular. The algorithm is useful for the least squares problem; i.e., the computation of the best approximation of an unsolvable system of linear equations. As a side-product, the Gram-Schmidt process has also been formalized. A refinement using immutable arrays is presented as well. The development relies, among others, on the AFP entry "Implementing field extensions of the form Q[sqrt(b)]" by René Thiemann, which allows execution of the algorithm using symbolic computations. Verified code can be generated and executed using floats as well. extra-history = Change history: [2015-06-18]: The second part of the Fundamental Theorem of Linear Algebra has been generalized to more general inner product spaces. notify = jose.divasonm@unirioja.es, jesus-maria.aransay@unirioja.es [Hermite] title = Hermite Normal Form author = Jose Divasón , Jesús Aransay topic = Computer science/Algorithms/Mathematical, Mathematics/Algebra date = 2015-07-07 abstract = Hermite Normal Form is a canonical matrix analogue of Reduced Echelon Form, but involving matrices over more general rings. In this work we formalise an algorithm to compute the Hermite Normal Form of a matrix by means of elementary row operations, taking advantage of the Echelon Form AFP entry. We have proven the correctness of such an algorithm and refined it to immutable arrays. Furthermore, we have also formalised the uniqueness of the Hermite Normal Form of a matrix. Code can be exported and some examples of execution involving integer matrices and polynomial matrices are presented as well. notify = jose.divasonm@unirioja.es, jesus-maria.aransay@unirioja.es [Imperative_Insertion_Sort] title = Imperative Insertion Sort author = Christian Sternagel date = 2014-09-25 topic = Computer science/Algorithms abstract = The insertion sort algorithm of Cormen et al. (Introduction to Algorithms) is expressed in Imperative HOL and proved to be correct and terminating. For this purpose we also provide a theory about imperative loop constructs with accompanying induction/invariant rules for proving partial and total correctness. Furthermore, the formalized algorithm is fit for code generation. notify = lp15@cam.ac.uk [Stream_Fusion_Code] title = Stream Fusion in HOL with Code Generation author = Andreas Lochbihler , Alexandra Maximova date = 2014-10-10 topic = Computer science/Functional programming abstract = Stream Fusion is a system for removing intermediate list data structures from functional programs, in particular Haskell. This entry adapts stream fusion to Isabelle/HOL and its code generator. We define stream types for finite and possibly infinite lists and stream versions for most of the fusible list functions in the theories List and Coinductive_List, and prove them correct with respect to the conversion functions between lists and streams. The Stream Fusion transformation itself is implemented as a simproc in the preprocessor of the code generator. [Brian Huffman's AFP entry formalises stream fusion in HOLCF for the domain of lazy lists to prove the GHC compiler rewrite rules correct. In contrast, this work enables Isabelle's code generator to perform stream fusion itself. To that end, it covers both finite and coinductive lists from the HOL library and the Coinductive entry. The fusible list functions require specification and proof principles different from Huffman's.] notify = mail@andreas-lochbihler.de [Case_Labeling] title = Generating Cases from Labeled Subgoals author = Lars Noschinski date = 2015-07-21 topic = Tools, Computer science/Programming languages/Misc abstract = Isabelle/Isar provides named cases to structure proofs. This article contains an implementation of a proof method casify, which can be used to easily extend proof tools with support for named cases. Such a proof tool must produce labeled subgoals, which are then interpreted by casify.

As examples, this work contains verification condition generators producing named cases for three languages: The Hoare language from HOL/Library, a monadic language for computations with failure (inspired by the AutoCorres tool), and a language of conditional expressions. These VCGs are demonstrated by a number of example programs. notify = noschinl@gmail.com [DPT-SAT-Solver] title = A Fast SAT Solver for Isabelle in Standard ML topic = Tools author = Armin Heller <> date = 2009-12-09 abstract = This contribution contains a fast SAT solver for Isabelle written in Standard ML. By loading the theory DPT_SAT_Solver, the SAT solver installs itself (under the name ``dptsat'') and certain Isabelle tools like Refute will start using it automatically. This is a port of the DPT (Decision Procedure Toolkit) SAT Solver written in OCaml. notify = jasmin.blanchette@gmail.com [Rep_Fin_Groups] title = Representations of Finite Groups topic = Mathematics/Algebra author = Jeremy Sylvestre date = 2015-08-12 abstract = We provide a formal framework for the theory of representations of finite groups, as modules over the group ring. Along the way, we develop the general theory of groups (relying on the group_add class for the basics), modules, and vector spaces, to the extent required for theory of group representations. We then provide formal proofs of several important introductory theorems in the subject, including Maschke's theorem, Schur's lemma, and Frobenius reciprocity. We also prove that every irreducible representation is isomorphic to a submodule of the group ring, leading to the fact that for a finite group there are only finitely many isomorphism classes of irreducible representations. In all of this, no restriction is made on the characteristic of the ring or field of scalars until the definition of a group representation, and then the only restriction made is that the characteristic must not divide the order of the group. notify = jsylvest@ualberta.ca [Noninterference_Inductive_Unwinding] title = The Inductive Unwinding Theorem for CSP Noninterference Security topic = Computer science/Security author = Pasquale Noce date = 2015-08-18 abstract =

The necessary and sufficient condition for CSP noninterference security stated by the Ipurge Unwinding Theorem is expressed in terms of a pair of event lists varying over the set of process traces. This does not render it suitable for the subsequent application of rule induction in the case of a process defined inductively, since rule induction may rather be applied to a single variable ranging over an inductively defined set.

Starting from the Ipurge Unwinding Theorem, this paper derives a necessary and sufficient condition for CSP noninterference security that involves a single event list varying over the set of process traces, and is thus suitable for rule induction; hence its name, Inductive Unwinding Theorem. Similarly to the Ipurge Unwinding Theorem, the new theorem only requires to consider individual accepted and refused events for each process trace, and applies to the general case of a possibly intransitive noninterference policy. Specific variants of this theorem are additionally proven for deterministic processes and trace set processes.

notify = pasquale.noce.lavoro@gmail.com [Password_Authentication_Protocol] title = Verification of a Diffie-Hellman Password-based Authentication Protocol by Extending the Inductive Method author = Pasquale Noce topic = Computer science/Security date = 2017-01-03 notify = pasquale.noce.lavoro@gmail.com abstract = This paper constructs a formal model of a Diffie-Hellman password-based authentication protocol between a user and a smart card, and proves its security. The protocol provides for the dispatch of the user's password to the smart card on a secure messaging channel established by means of Password Authenticated Connection Establishment (PACE), where the mapping method being used is Chip Authentication Mapping. By applying and suitably extending Paulson's Inductive Method, this paper proves that the protocol establishes trustworthy secure messaging channels, preserves the secrecy of users' passwords, and provides an effective mutual authentication service. What is more, these security properties turn out to hold independently of the secrecy of the PACE authentication key. [Jordan_Normal_Form] title = Matrices, Jordan Normal Forms, and Spectral Radius Theory topic = Mathematics/Algebra author = René Thiemann , Akihisa Yamada contributors = Alexander Bentkamp date = 2015-08-21 abstract =

Matrix interpretations are useful as measure functions in termination proving. In order to use these interpretations also for complexity analysis, the growth rate of matrix powers has to examined. Here, we formalized a central result of spectral radius theory, namely that the growth rate is polynomially bounded if and only if the spectral radius of a matrix is at most one.

To formally prove this result we first studied the growth rates of matrices in Jordan normal form, and prove the result that every complex matrix has a Jordan normal form using a constructive prove via Schur decomposition.

The whole development is based on a new abstract type for matrices, which is also executable by a suitable setup of the code generator. It completely subsumes our former AFP-entry on executable matrices, and its main advantage is its close connection to the HMA-representation which allowed us to easily adapt existing proofs on determinants.

All the results have been applied to improve CeTA, our certifier to validate termination and complexity proof certificates.

extra-history = Change history: [2016-01-07]: Added Schur-decomposition, Gram-Schmidt orthogonalization, uniqueness of Jordan normal forms
[2018-04-17]: Integrated lemmas from deep-learning AFP-entry of Alexander Bentkamp notify = rene.thiemann@uibk.ac.at, ayamada@trs.cm.is.nagoya-u.ac.jp [LTL_to_DRA] title = Converting Linear Temporal Logic to Deterministic (Generalized) Rabin Automata topic = Computer science/Automata and formal languages author = Salomon Sickert date = 2015-09-04 abstract = Recently, Javier Esparza and Jan Kretinsky proposed a new method directly translating linear temporal logic (LTL) formulas to deterministic (generalized) Rabin automata. Compared to the existing approaches of constructing a non-deterministic Buechi-automaton in the first step and then applying a determinization procedure (e.g. some variant of Safra's construction) in a second step, this new approach preservers a relation between the formula and the states of the resulting automaton. While the old approach produced a monolithic structure, the new method is compositional. Furthermore, in some cases the resulting automata are much smaller than the automata generated by existing approaches. In order to ensure the correctness of the construction, this entry contains a complete formalisation and verification of the translation. Furthermore from this basis executable code is generated. extra-history = Change history: [2015-09-23]: Enable code export for the eager unfolding optimisation and reduce running time of the generated tool. Moreover, add support for the mlton SML compiler.
[2016-03-24]: Make use of the LTL entry and include the simplifier. notify = sickert@in.tum.de [Timed_Automata] title = Timed Automata author = Simon Wimmer date = 2016-03-08 topic = Computer science/Automata and formal languages abstract = Timed automata are a widely used formalism for modeling real-time systems, which is employed in a class of successful model checkers such as UPPAAL [LPY97], HyTech [HHWt97] or Kronos [Yov97]. This work formalizes the theory for the subclass of diagonal-free timed automata, which is sufficient to model many interesting problems. We first define the basic concepts and semantics of diagonal-free timed automata. Based on this, we prove two types of decidability results for the language emptiness problem. The first is the classic result of Alur and Dill [AD90, AD94], which uses a finite partitioning of the state space into so-called `regions`. Our second result focuses on an approach based on `Difference Bound Matrices (DBMs)`, which is practically used by model checkers. We prove the correctness of the basic forward analysis operations on DBMs. One of these operations is the Floyd-Warshall algorithm for the all-pairs shortest paths problem. To obtain a finite search space, a widening operation has to be used for this kind of analysis. We use Patricia Bouyer's [Bou04] approach to prove that this widening operation is correct in the sense that DBM-based forward analysis in combination with the widening operation also decides language emptiness. The interesting property of this proof is that the first decidability result is reused to obtain the second one. notify = wimmers@in.tum.de [Parity_Game] title = Positional Determinacy of Parity Games author = Christoph Dittmann date = 2015-11-02 topic = Mathematics/Games and economics, Mathematics/Graph theory abstract = We present a formalization of parity games (a two-player game on directed graphs) and a proof of their positional determinacy in Isabelle/HOL. This proof works for both finite and infinite games. notify = [Ergodic_Theory] title = Ergodic Theory author = Sebastien Gouezel contributors = Manuel Eberl date = 2015-12-01 topic = Mathematics/Probability theory abstract = Ergodic theory is the branch of mathematics that studies the behaviour of measure preserving transformations, in finite or infinite measure. It interacts both with probability theory (mainly through measure theory) and with geometry as a lot of interesting examples are from geometric origin. We implement the first definitions and theorems of ergodic theory, including notably Poicaré recurrence theorem for finite measure preserving systems (together with the notion of conservativity in general), induced maps, Kac's theorem, Birkhoff theorem (arguably the most important theorem in ergodic theory), and variations around it such as conservativity of the corresponding skew product, or Atkinson lemma. notify = sebastien.gouezel@univ-rennes1.fr, hoelzl@in.tum.de [Latin_Square] title = Latin Square author = Alexander Bentkamp date = 2015-12-02 topic = Mathematics/Combinatorics abstract = A Latin Square is a n x n table filled with integers from 1 to n where each number appears exactly once in each row and each column. A Latin Rectangle is a partially filled n x n table with r filled rows and n-r empty rows, such that each number appears at most once in each row and each column. The main result of this theory is that any Latin Rectangle can be completed to a Latin Square. notify = bentkamp@gmail.com [Deep_Learning] title = Expressiveness of Deep Learning author = Alexander Bentkamp date = 2016-11-10 topic = Computer science/Machine learning, Mathematics/Analysis abstract = Deep learning has had a profound impact on computer science in recent years, with applications to search engines, image recognition and language processing, bioinformatics, and more. Recently, Cohen et al. provided theoretical evidence for the superiority of deep learning over shallow learning. This formalization of their work simplifies and generalizes the original proof, while working around the limitations of the Isabelle type system. To support the formalization, I developed reusable libraries of formalized mathematics, including results about the matrix rank, the Lebesgue measure, and multivariate polynomials, as well as a library for tensor analysis. notify = bentkamp@gmail.com [Inductive_Inference] title = Some classical results in inductive inference of recursive functions author = Frank J. Balbach topic = Logic/Computability, Computer science/Machine learning date = 2020-08-31 notify = frank-balbach@gmx.de abstract =

This entry formalizes some classical concepts and results from inductive inference of recursive functions. In the basic setting a partial recursive function ("strategy") must identify ("learn") all functions from a set ("class") of recursive functions. To that end the strategy receives more and more values $f(0), f(1), f(2), \ldots$ of some function $f$ from the given class and in turn outputs descriptions of partial recursive functions, for example, Gödel numbers. The strategy is considered successful if the sequence of outputs ("hypotheses") converges to a description of $f$. A class of functions learnable in this sense is called "learnable in the limit". The set of all these classes is denoted by LIM.

Other types of inference considered are finite learning (FIN), behaviorally correct learning in the limit (BC), and some variants of LIM with restrictions on the hypotheses: total learning (TOTAL), consistent learning (CONS), and class-preserving learning (CP). The main results formalized are the proper inclusions $\mathrm{FIN} \subset \mathrm{CP} \subset \mathrm{TOTAL} \subset \mathrm{CONS} \subset \mathrm{LIM} \subset \mathrm{BC} \subset 2^{\mathcal{R}}$, where $\mathcal{R}$ is the set of all total recursive functions. Further results show that for all these inference types except CONS, strategies can be assumed to be total recursive functions; that all inference types but CP are closed under the subset relation between classes; and that no inference type is closed under the union of classes.

The above is based on a formalization of recursive functions heavily inspired by the Universal Turing Machine entry by Xu et al., but different in that it models partial functions with codomain nat option. The formalization contains a construction of a universal partial recursive function, without resorting to Turing machines, introduces decidability and recursive enumerability, and proves some standard results: existence of a Kleene normal form, the s-m-n theorem, Rice's theorem, and assorted fixed-point theorems (recursion theorems) by Kleene, Rogers, and Smullyan.

[Applicative_Lifting] title = Applicative Lifting author = Andreas Lochbihler , Joshua Schneider <> date = 2015-12-22 topic = Computer science/Functional programming abstract = Applicative functors augment computations with effects by lifting function application to types which model the effects. As the structure of the computation cannot depend on the effects, applicative expressions can be analysed statically. This allows us to lift universally quantified equations to the effectful types, as observed by Hinze. Thus, equational reasoning over effectful computations can be reduced to pure types.

This entry provides a package for registering applicative functors and two proof methods for lifting of equations over applicative functors. The first method normalises applicative expressions according to the laws of applicative functors. This way, equations whose two sides contain the same list of variables can be lifted to every applicative functor.

To lift larger classes of equations, the second method exploits a number of additional properties (e.g., commutativity of effects) provided the properties have been declared for the concrete applicative functor at hand upon registration.

We declare several types from the Isabelle library as applicative functors and illustrate the use of the methods with two examples: the lifting of the arithmetic type class hierarchy to streams and the verification of a relabelling function on binary trees. We also formalise and verify the normalisation algorithm used by the first proof method.

extra-history = Change history: [2016-03-03]: added formalisation of lifting with combinators
[2016-06-10]: implemented automatic derivation of lifted combinator reductions; support arbitrary lifted relations using relators; improved compatibility with locale interpretation (revision ec336f354f37)
notify = mail@andreas-lochbihler.de [Stern_Brocot] title = The Stern-Brocot Tree author = Peter Gammie , Andreas Lochbihler date = 2015-12-22 topic = Mathematics/Number theory abstract = The Stern-Brocot tree contains all rational numbers exactly once and in their lowest terms. We formalise the Stern-Brocot tree as a coinductive tree using recursive and iterative specifications, which we have proven equivalent, and show that it indeed contains all the numbers as stated. Following Hinze, we prove that the Stern-Brocot tree can be linearised looplessly into Stern's diatonic sequence (also known as Dijkstra's fusc function) and that it is a permutation of the Bird tree.

The reasoning stays at an abstract level by appealing to the uniqueness of solutions of guarded recursive equations and lifting algebraic laws point-wise to trees and streams using applicative functors.

notify = mail@andreas-lochbihler.de [Algebraic_Numbers] title = Algebraic Numbers in Isabelle/HOL topic = Mathematics/Algebra author = René Thiemann , Akihisa Yamada , Sebastiaan Joosten contributors = Manuel Eberl date = 2015-12-22 abstract = Based on existing libraries for matrices, factorization of rational polynomials, and Sturm's theorem, we formalized algebraic numbers in Isabelle/HOL. Our development serves as an implementation for real and complex numbers, and it admits to compute roots and completely factorize real and complex polynomials, provided that all coefficients are rational numbers. Moreover, we provide two implementations to display algebraic numbers, an injective and expensive one, or a faster but approximative version.

To this end, we mechanized several results on resultants, which also required us to prove that polynomials over a unique factorization domain form again a unique factorization domain.

extra-history = Change history: [2016-01-29]: Split off Polynomial Interpolation and Polynomial Factorization
[2017-04-16]: Use certified Berlekamp-Zassenhaus factorization, use subresultant algorithm for computing resultants, improved bisection algorithm notify = rene.thiemann@uibk.ac.at, ayamada@trs.cm.is.nagoya-u.ac.jp, sebastiaan.joosten@uibk.ac.at [Polynomial_Interpolation] title = Polynomial Interpolation topic = Mathematics/Algebra author = René Thiemann , Akihisa Yamada date = 2016-01-29 abstract = We formalized three algorithms for polynomial interpolation over arbitrary fields: Lagrange's explicit expression, the recursive algorithm of Neville and Aitken, and the Newton interpolation in combination with an efficient implementation of divided differences. Variants of these algorithms for integer polynomials are also available, where sometimes the interpolation can fail; e.g., there is no linear integer polynomial p such that p(0) = 0 and p(2) = 1. Moreover, for the Newton interpolation for integer polynomials, we proved that all intermediate results that are computed during the algorithm must be integers. This admits an early failure detection in the implementation. Finally, we proved the uniqueness of polynomial interpolation.

The development also contains improved code equations to speed up the division of integers in target languages. notify = rene.thiemann@uibk.ac.at, ayamada@trs.cm.is.nagoya-u.ac.jp [Polynomial_Factorization] title = Polynomial Factorization topic = Mathematics/Algebra author = René Thiemann , Akihisa Yamada date = 2016-01-29 abstract = Based on existing libraries for polynomial interpolation and matrices, we formalized several factorization algorithms for polynomials, including Kronecker's algorithm for integer polynomials, Yun's square-free factorization algorithm for field polynomials, and Berlekamp's algorithm for polynomials over finite fields. By combining the last one with Hensel's lifting, we derive an efficient factorization algorithm for the integer polynomials, which is then lifted for rational polynomials by mechanizing Gauss' lemma. Finally, we assembled a combined factorization algorithm for rational polynomials, which combines all the mentioned algorithms and additionally uses the explicit formula for roots of quadratic polynomials and a rational root test.

As side products, we developed division algorithms for polynomials over integral domains, as well as primality-testing and prime-factorization algorithms for integers. notify = rene.thiemann@uibk.ac.at, ayamada@trs.cm.is.nagoya-u.ac.jp +[Cubic_Quartic_Equations] +title = Solving Cubic and Quartic Equations +author = René Thiemann +topic = Mathematics/Analysis +date = 2021-09-03 +notify = rene.thiemann@uibk.ac.at +abstract = +

We formalize Cardano's formula to solve a cubic equation + $$ax^3 + bx^2 + cx + d = 0,$$ as well as Ferrari's formula to + solve a quartic equation. We further turn both formulas into + executable algorithms based on the algebraic number implementation in + the AFP. To this end we also slightly extended this library, namely by + making the minimal polynomial of an algebraic number executable, and + by defining and implementing $n$-th roots of complex + numbers.

+ [Perron_Frobenius] title = Perron-Frobenius Theorem for Spectral Radius Analysis author = Jose Divasón , Ondřej Kunčar , René Thiemann , Akihisa Yamada notify = rene.thiemann@uibk.ac.at date = 2016-05-20 topic = Mathematics/Algebra abstract =

The spectral radius of a matrix A is the maximum norm of all eigenvalues of A. In previous work we already formalized that for a complex matrix A, the values in An grow polynomially in n if and only if the spectral radius is at most one. One problem with the above characterization is the determination of all complex eigenvalues. In case A contains only non-negative real values, a simplification is possible with the help of the Perron–Frobenius theorem, which tells us that it suffices to consider only the real eigenvalues of A, i.e., applying Sturm's method can decide the polynomial growth of An.

We formalize the Perron–Frobenius theorem based on a proof via Brouwer's fixpoint theorem, which is available in the HOL multivariate analysis (HMA) library. Since the results on the spectral radius is based on matrices in the Jordan normal form (JNF) library, we further develop a connection which allows us to easily transfer theorems between HMA and JNF. With this connection we derive the combined result: if A is a non-negative real matrix, and no real eigenvalue of A is strictly larger than one, then An is polynomially bounded in n.

extra-history = Change history: [2017-10-18]: added Perron-Frobenius theorem for irreducible matrices with generalization (revision bda1f1ce8a1c)
[2018-05-17]: prove conjecture of CPP'18 paper: Jordan blocks of spectral radius have maximum size (revision ffdb3794e5d5) [Stochastic_Matrices] title = Stochastic Matrices and the Perron-Frobenius Theorem author = René Thiemann topic = Mathematics/Algebra, Computer science/Automata and formal languages date = 2017-11-22 notify = rene.thiemann@uibk.ac.at abstract = Stochastic matrices are a convenient way to model discrete-time and finite state Markov chains. The Perron–Frobenius theorem tells us something about the existence and uniqueness of non-negative eigenvectors of a stochastic matrix. In this entry, we formalize stochastic matrices, link the formalization to the existing AFP-entry on Markov chains, and apply the Perron–Frobenius theorem to prove that stationary distributions always exist, and they are unique if the stochastic matrix is irreducible. [Formal_SSA] title = Verified Construction of Static Single Assignment Form author = Sebastian Ullrich , Denis Lohner date = 2016-02-05 topic = Computer science/Algorithms, Computer science/Programming languages/Transformations abstract =

We define a functional variant of the static single assignment (SSA) form construction algorithm described by Braun et al., which combines simplicity and efficiency. The definition is based on a general, abstract control flow graph representation using Isabelle locales.

We prove that the algorithm's output is semantically equivalent to the input according to a small-step semantics, and that it is in minimal SSA form for the common special case of reducible inputs. We then show the satisfiability of the locale assumptions by giving instantiations for a simple While language.

Furthermore, we use a generic instantiation based on typedefs in order to extract OCaml code and replace the unverified SSA construction algorithm of the CompCertSSA project with it.

A more detailed description of the verified SSA construction can be found in the paper Verified Construction of Static Single Assignment Form, CC 2016.

notify = denis.lohner@kit.edu [Minimal_SSA] title = Minimal Static Single Assignment Form author = Max Wagner , Denis Lohner topic = Computer science/Programming languages/Transformations date = 2017-01-17 notify = denis.lohner@kit.edu abstract =

This formalization is an extension to "Verified Construction of Static Single Assignment Form". In their work, the authors have shown that Braun et al.'s static single assignment (SSA) construction algorithm produces minimal SSA form for input programs with a reducible control flow graph (CFG). However Braun et al. also proposed an extension to their algorithm that they claim produces minimal SSA form even for irreducible CFGs.
In this formalization we support that claim by giving a mechanized proof.

As the extension of Braun et al.'s algorithm aims for removing so-called redundant strongly connected components of phi functions, we show that this suffices to guarantee minimality according to Cytron et al..

[PropResPI] title = Propositional Resolution and Prime Implicates Generation author = Nicolas Peltier notify = Nicolas.Peltier@imag.fr date = 2016-03-11 topic = Logic/General logic/Mechanization of proofs abstract = We provide formal proofs in Isabelle-HOL (using mostly structured Isar proofs) of the soundness and completeness of the Resolution rule in propositional logic. The completeness proofs take into account the usual redundancy elimination rules (tautology elimination and subsumption), and several refinements of the Resolution rule are considered: ordered resolution (with selection functions), positive and negative resolution, semantic resolution and unit resolution (the latter refinement is complete only for clause sets that are Horn- renamable). We also define a concrete procedure for computing saturated sets and establish its soundness and completeness. The clause sets are not assumed to be finite, so that the results can be applied to formulas obtained by grounding sets of first-order clauses (however, a total ordering among atoms is assumed to be given). Next, we show that the unrestricted Resolution rule is deductive- complete, in the sense that it is able to generate all (prime) implicates of any set of propositional clauses (i.e., all entailment- minimal, non-valid, clausal consequences of the considered set). The generation of prime implicates is an important problem, with many applications in artificial intelligence and verification (for abductive reasoning, knowledge compilation, diagnosis, debugging etc.). We also show that implicates can be computed in an incremental way, by fixing an ordering among all the atoms in the considered sets and resolving upon these atoms one by one in the considered order (with no backtracking). This feature is critical for the efficient computation of prime implicates. Building on these results, we provide a procedure for computing such implicates and establish its soundness and completeness. [SuperCalc] title = A Variant of the Superposition Calculus author = Nicolas Peltier notify = Nicolas.Peltier@imag.fr date = 2016-09-06 topic = Logic/Proof theory abstract = We provide a formalization of a variant of the superposition calculus, together with formal proofs of soundness and refutational completeness (w.r.t. the usual redundancy criteria based on clause ordering). This version of the calculus uses all the standard restrictions of the superposition rules, together with the following refinement, inspired by the basic superposition calculus: each clause is associated with a set of terms which are assumed to be in normal form -- thus any application of the replacement rule on these terms is blocked. The set is initially empty and terms may be added or removed at each inference step. The set of terms that are assumed to be in normal form includes any term introduced by previous unifiers as well as any term occurring in the parent clauses at a position that is smaller (according to some given ordering on positions) than a previously replaced term. The standard superposition calculus corresponds to the case where the set of irreducible terms is always empty. [Nominal2] title = Nominal 2 author = Christian Urban , Stefan Berghofer , Cezary Kaliszyk date = 2013-02-21 topic = Tools abstract =

Dealing with binders, renaming of bound variables, capture-avoiding substitution, etc., is very often a major problem in formal proofs, especially in proofs by structural and rule induction. Nominal Isabelle is designed to make such proofs easy to formalise: it provides an infrastructure for declaring nominal datatypes (that is alpha-equivalence classes) and for defining functions over them by structural recursion. It also provides induction principles that have Barendregt’s variable convention already built in.

This entry can be used as a more advanced replacement for HOL/Nominal in the Isabelle distribution.

notify = christian.urban@kcl.ac.uk [First_Welfare_Theorem] title = Microeconomics and the First Welfare Theorem author = Julian Parsert , Cezary Kaliszyk topic = Mathematics/Games and economics license = LGPL date = 2017-09-01 notify = julian.parsert@uibk.ac.at, cezary.kaliszyk@uibk.ac.at abstract = Economic activity has always been a fundamental part of society. Due to modern day politics, economic theory has gained even more influence on our lives. Thus we want models and theories to be as precise as possible. This can be achieved using certification with the help of formal proof technology. Hence we will use Isabelle/HOL to construct two economic models, that of the the pure exchange economy and a version of the Arrow-Debreu Model. We will prove that the First Theorem of Welfare Economics holds within both. The theorem is the mathematical formulation of Adam Smith's famous invisible hand and states that a group of self-interested and rational actors will eventually achieve an efficient allocation of goods and services. extra-history = Change history: [2018-06-17]: Added some lemmas and a theory file, also introduced Microeconomics folder.
[Noninterference_Sequential_Composition] title = Conservation of CSP Noninterference Security under Sequential Composition author = Pasquale Noce date = 2016-04-26 topic = Computer science/Security, Computer science/Concurrency/Process calculi abstract =

In his outstanding work on Communicating Sequential Processes, Hoare has defined two fundamental binary operations allowing to compose the input processes into another, typically more complex, process: sequential composition and concurrent composition. Particularly, the output of the former operation is a process that initially behaves like the first operand, and then like the second operand once the execution of the first one has terminated successfully, as long as it does.

This paper formalizes Hoare's definition of sequential composition and proves, in the general case of a possibly intransitive policy, that CSP noninterference security is conserved under this operation, provided that successful termination cannot be affected by confidential events and cannot occur as an alternative to other events in the traces of the first operand. Both of these assumptions are shown, by means of counterexamples, to be necessary for the theorem to hold.

notify = pasquale.noce.lavoro@gmail.com [Noninterference_Concurrent_Composition] title = Conservation of CSP Noninterference Security under Concurrent Composition author = Pasquale Noce notify = pasquale.noce.lavoro@gmail.com date = 2016-06-13 topic = Computer science/Security, Computer science/Concurrency/Process calculi abstract =

In his outstanding work on Communicating Sequential Processes, Hoare has defined two fundamental binary operations allowing to compose the input processes into another, typically more complex, process: sequential composition and concurrent composition. Particularly, the output of the latter operation is a process in which any event not shared by both operands can occur whenever the operand that admits the event can engage in it, whereas any event shared by both operands can occur just in case both can engage in it.

This paper formalizes Hoare's definition of concurrent composition and proves, in the general case of a possibly intransitive policy, that CSP noninterference security is conserved under this operation. This result, along with the previous analogous one concerning sequential composition, enables the construction of more and more complex processes enforcing noninterference security by composing, sequentially or concurrently, simpler secure processes, whose security can in turn be proven using either the definition of security, or unwinding theorems.

[ROBDD] title = Algorithms for Reduced Ordered Binary Decision Diagrams author = Julius Michaelis , Maximilian Haslbeck , Peter Lammich , Lars Hupel date = 2016-04-27 topic = Computer science/Algorithms, Computer science/Data structures abstract = We present a verified and executable implementation of ROBDDs in Isabelle/HOL. Our implementation relates pointer-based computation in the Heap monad to operations on an abstract definition of boolean functions. Internally, we implemented the if-then-else combinator in a recursive fashion, following the Shannon decomposition of the argument functions. The implementation mixes and adapts known techniques and is built with efficiency in mind. notify = bdd@liftm.de, haslbecm@in.tum.de [No_FTL_observers] title = No Faster-Than-Light Observers author = Mike Stannett , István Németi date = 2016-04-28 topic = Mathematics/Physics abstract = We provide a formal proof within First Order Relativity Theory that no observer can travel faster than the speed of light. Originally reported in Stannett & Németi (2014) "Using Isabelle/HOL to verify first-order relativity theory", Journal of Automated Reasoning 52(4), pp. 361-378. notify = m.stannett@sheffield.ac.uk [Groebner_Bases] title = Gröbner Bases Theory author = Fabian Immler , Alexander Maletzky date = 2016-05-02 topic = Mathematics/Algebra, Computer science/Algorithms/Mathematical abstract = This formalization is concerned with the theory of Gröbner bases in (commutative) multivariate polynomial rings over fields, originally developed by Buchberger in his 1965 PhD thesis. Apart from the statement and proof of the main theorem of the theory, the formalization also implements Buchberger's algorithm for actually computing Gröbner bases as a tail-recursive function, thus allowing to effectively decide ideal membership in finitely generated polynomial ideals. Furthermore, all functions can be executed on a concrete representation of multivariate polynomials as association lists. extra-history = Change history: [2019-04-18]: Specialized Gröbner bases to less abstract representation of polynomials, where power-products are represented as polynomial mappings.
notify = alexander.maletzky@risc.jku.at [Nullstellensatz] title = Hilbert's Nullstellensatz author = Alexander Maletzky topic = Mathematics/Algebra, Mathematics/Geometry date = 2019-06-16 notify = alexander.maletzky@risc-software.at abstract = This entry formalizes Hilbert's Nullstellensatz, an important theorem in algebraic geometry that can be viewed as the generalization of the Fundamental Theorem of Algebra to multivariate polynomials: If a set of (multivariate) polynomials over an algebraically closed field has no common zero, then the ideal it generates is the entire polynomial ring. The formalization proves several equivalent versions of this celebrated theorem: the weak Nullstellensatz, the strong Nullstellensatz (connecting algebraic varieties and radical ideals), and the field-theoretic Nullstellensatz. The formalization follows Chapter 4.1. of Ideals, Varieties, and Algorithms by Cox, Little and O'Shea. [Bell_Numbers_Spivey] title = Spivey's Generalized Recurrence for Bell Numbers author = Lukas Bulwahn date = 2016-05-04 topic = Mathematics/Combinatorics abstract = This entry defines the Bell numbers as the cardinality of set partitions for a carrier set of given size, and derives Spivey's generalized recurrence relation for Bell numbers following his elegant and intuitive combinatorial proof.

As the set construction for the combinatorial proof requires construction of three intermediate structures, the main difficulty of the formalization is handling the overall combinatorial argument in a structured way. The introduced proof structure allows us to compose the combinatorial argument from its subparts, and supports to keep track how the detailed proof steps are related to the overall argument. To obtain this structure, this entry uses set monad notation for the set construction's definition, introduces suitable predicates and rules, and follows a repeating structure in its Isar proof. notify = lukas.bulwahn@gmail.com [Randomised_Social_Choice] title = Randomised Social Choice Theory author = Manuel Eberl date = 2016-05-05 topic = Mathematics/Games and economics abstract = This work contains a formalisation of basic Randomised Social Choice, including Stochastic Dominance and Social Decision Schemes (SDSs) along with some of their most important properties (Anonymity, Neutrality, ex-post- and SD-Efficiency, SD-Strategy-Proofness) and two particular SDSs – Random Dictatorship and Random Serial Dictatorship (with proofs of the properties that they satisfy). Many important properties of these concepts are also proven – such as the two equivalent characterisations of Stochastic Dominance and the fact that SD-efficiency of a lottery only depends on the support. The entry also provides convenient commands to define Preference Profiles, prove their well-formedness, and automatically derive restrictions that sufficiently nice SDSs need to satisfy on the defined profiles. Currently, the formalisation focuses on weak preferences and Stochastic Dominance, but it should be easy to extend it to other domains – such as strict preferences – or other lottery extensions – such as Bilinear Dominance or Pairwise Comparison. notify = eberlm@in.tum.de [SDS_Impossibility] title = The Incompatibility of SD-Efficiency and SD-Strategy-Proofness author = Manuel Eberl date = 2016-05-04 topic = Mathematics/Games and economics abstract = This formalisation contains the proof that there is no anonymous and neutral Social Decision Scheme for at least four voters and alternatives that fulfils both SD-Efficiency and SD-Strategy- Proofness. The proof is a fully structured and quasi-human-redable one. It was derived from the (unstructured) SMT proof of the case for exactly four voters and alternatives by Brandl et al. Their proof relies on an unverified translation of the original problem to SMT, and the proof that lifts the argument for exactly four voters and alternatives to the general case is also not machine-checked. In this Isabelle proof, on the other hand, all of these steps are fully proven and machine-checked. This is particularly important seeing as a previously published informal proof of a weaker statement contained a mistake in precisely this lifting step. notify = eberlm@in.tum.de [Median_Of_Medians_Selection] title = The Median-of-Medians Selection Algorithm author = Manuel Eberl topic = Computer science/Algorithms date = 2017-12-21 notify = eberlm@in.tum.de abstract =

This entry provides an executable functional implementation of the Median-of-Medians algorithm for selecting the k-th smallest element of an unsorted list deterministically in linear time. The size bounds for the recursive call that lead to the linear upper bound on the run-time of the algorithm are also proven.

[Mason_Stothers] title = The Mason–Stothers Theorem author = Manuel Eberl topic = Mathematics/Algebra date = 2017-12-21 notify = eberlm@in.tum.de abstract =

This article provides a formalisation of Snyder’s simple and elegant proof of the Mason–Stothers theorem, which is the polynomial analogue of the famous abc Conjecture for integers. Remarkably, Snyder found this very elegant proof when he was still a high-school student.

In short, the statement of the theorem is that three non-zero coprime polynomials A, B, C over a field which sum to 0 and do not all have vanishing derivatives fulfil max{deg(A), deg(B), deg(C)} < deg(rad(ABC)) where the rad(P) denotes the radical of P, i. e. the product of all unique irreducible factors of P.

This theorem also implies a kind of polynomial analogue of Fermat’s Last Theorem for polynomials: except for trivial cases, An + Bn + Cn = 0 implies n ≤ 2 for coprime polynomials A, B, C over a field.

[FLP] title = A Constructive Proof for FLP author = Benjamin Bisping , Paul-David Brodmann , Tim Jungnickel , Christina Rickmann , Henning Seidler , Anke Stüber , Arno Wilhelm-Weidner , Kirstin Peters , Uwe Nestmann date = 2016-05-18 topic = Computer science/Concurrency abstract = The impossibility of distributed consensus with one faulty process is a result with important consequences for real world distributed systems e.g., commits in replicated databases. Since proofs are not immune to faults and even plausible proofs with a profound formalism can conclude wrong results, we validate the fundamental result named FLP after Fischer, Lynch and Paterson. We present a formalization of distributed systems and the aforementioned consensus problem. Our proof is based on Hagen Völzer's paper "A constructive proof for FLP". In addition to the enhanced confidence in the validity of Völzer's proof, we contribute the missing gaps to show the correctness in Isabelle/HOL. We clarify the proof details and even prove fairness of the infinite execution that contradicts consensus. Our Isabelle formalization can also be reused for further proofs of properties of distributed systems. notify = henning.seidler@mailbox.tu-berlin.de [IMAP-CRDT] title = The IMAP CmRDT author = Tim Jungnickel , Lennart Oldenburg <>, Matthias Loibl <> topic = Computer science/Algorithms/Distributed, Computer science/Data structures date = 2017-11-09 notify = tim.jungnickel@tu-berlin.de abstract = We provide our Isabelle/HOL formalization of a Conflict-free Replicated Datatype for Internet Message Access Protocol commands. We show that Strong Eventual Consistency (SEC) is guaranteed by proving the commutativity of concurrent operations. We base our formalization on the recently proposed "framework for establishing Strong Eventual Consistency for Conflict-free Replicated Datatypes" (AFP.CRDT) from Gomes et al. Hence, we provide an additional example of how the recently proposed framework can be used to design and prove CRDTs. [Incredible_Proof_Machine] title = The meta theory of the Incredible Proof Machine author = Joachim Breitner , Denis Lohner date = 2016-05-20 topic = Logic/Proof theory abstract = The Incredible Proof Machine is an interactive visual theorem prover which represents proofs as port graphs. We model this proof representation in Isabelle, and prove that it is just as powerful as natural deduction. notify = mail@joachim-breitner.de [Word_Lib] title = Finite Machine Word Library author = Joel Beeren<>, Matthew Fernandez<>, Xin Gao<>, Gerwin Klein , Rafal Kolanski<>, Japheth Lim<>, Corey Lewis<>, Daniel Matichuk<>, Thomas Sewell<> notify = kleing@unsw.edu.au date = 2016-06-09 topic = Computer science/Data structures abstract = This entry contains an extension to the Isabelle library for fixed-width machine words. In particular, the entry adds quickcheck setup for words, printing as hexadecimals, additional operations, reasoning about alignment, signed words, enumerations of words, normalisation of word numerals, and an extensive library of properties about generic fixed-width words, as well as an instantiation of many of these to the commonly used 32 and 64-bit bases. [Catalan_Numbers] title = Catalan Numbers author = Manuel Eberl notify = eberlm@in.tum.de date = 2016-06-21 topic = Mathematics/Combinatorics abstract =

In this work, we define the Catalan numbers Cn and prove several equivalent definitions (including some closed-form formulae). We also show one of their applications (counting the number of binary trees of size n), prove the asymptotic growth approximation Cn ∼ 4n / (√π · n1.5), and provide reasonably efficient executable code to compute them.

The derivation of the closed-form formulae uses algebraic manipulations of the ordinary generating function of the Catalan numbers, and the asymptotic approximation is then done using generalised binomial coefficients and the Gamma function. Thanks to these highly non-elementary mathematical tools, the proofs are very short and simple.

[Fisher_Yates] title = Fisher–Yates shuffle author = Manuel Eberl notify = eberlm@in.tum.de date = 2016-09-30 topic = Computer science/Algorithms abstract =

This work defines and proves the correctness of the Fisher–Yates algorithm for shuffling – i.e. producing a random permutation – of a list. The algorithm proceeds by traversing the list and in each step swapping the current element with a random element from the remaining list.

[Bertrands_Postulate] title = Bertrand's postulate author = Julian Biendarra<>, Manuel Eberl contributors = Lawrence C. Paulson topic = Mathematics/Number theory date = 2017-01-17 notify = eberlm@in.tum.de abstract =

Bertrand's postulate is an early result on the distribution of prime numbers: For every positive integer n, there exists a prime number that lies strictly between n and 2n. The proof is ported from John Harrison's formalisation in HOL Light. It proceeds by first showing that the property is true for all n greater than or equal to 600 and then showing that it also holds for all n below 600 by case distinction.

[Rewriting_Z] title = The Z Property author = Bertram Felgenhauer<>, Julian Nagele<>, Vincent van Oostrom<>, Christian Sternagel notify = bertram.felgenhauer@uibk.ac.at, julian.nagele@uibk.ac.at, c.sternagel@gmail.com date = 2016-06-30 topic = Logic/Rewriting abstract = We formalize the Z property introduced by Dehornoy and van Oostrom. First we show that for any abstract rewrite system, Z implies confluence. Then we give two examples of proofs using Z: confluence of lambda-calculus with respect to beta-reduction and confluence of combinatory logic. [Resolution_FOL] title = The Resolution Calculus for First-Order Logic author = Anders Schlichtkrull notify = andschl@dtu.dk date = 2016-06-30 topic = Logic/General logic/Mechanization of proofs abstract = This theory is a formalization of the resolution calculus for first-order logic. It is proven sound and complete. The soundness proof uses the substitution lemma, which shows a correspondence between substitutions and updates to an environment. The completeness proof uses semantic trees, i.e. trees whose paths are partial Herbrand interpretations. It employs Herbrand's theorem in a formulation which states that an unsatisfiable set of clauses has a finite closed semantic tree. It also uses the lifting lemma which lifts resolution derivation steps from the ground world up to the first-order world. The theory is presented in a paper in the Journal of Automated Reasoning [Sch18] which extends a paper presented at the International Conference on Interactive Theorem Proving [Sch16]. An earlier version was presented in an MSc thesis [Sch15]. The formalization mostly follows textbooks by Ben-Ari [BA12], Chang and Lee [CL73], and Leitsch [Lei97]. The theory is part of the IsaFoL project [IsaFoL].

[Sch18] Anders Schlichtkrull. "Formalization of the Resolution Calculus for First-Order Logic". Journal of Automated Reasoning, 2018.
[Sch16] Anders Schlichtkrull. "Formalization of the Resolution Calculus for First-Order Logic". In: ITP 2016. Vol. 9807. LNCS. Springer, 2016.
[Sch15] Anders Schlichtkrull. "Formalization of Resolution Calculus in Isabelle". https://people.compute.dtu.dk/andschl/Thesis.pdf. MSc thesis. Technical University of Denmark, 2015.
[BA12] Mordechai Ben-Ari. Mathematical Logic for Computer Science. 3rd. Springer, 2012.
[CL73] Chin-Liang Chang and Richard Char-Tung Lee. Symbolic Logic and Mechanical Theorem Proving. 1st. Academic Press, Inc., 1973.
[Lei97] Alexander Leitsch. The Resolution Calculus. Texts in theoretical computer science. Springer, 1997.
[IsaFoL] IsaFoL authors. IsaFoL: Isabelle Formalization of Logic. https://bitbucket.org/jasmin_blanchette/isafol. extra-history = Change history: [2018-01-24]: added several new versions of the soundness and completeness theorems as described in the paper [Sch18].
[2018-03-20]: added a concrete instance of the unification and completeness theorems using the First-Order Terms AFP-entry from IsaFoR as described in the papers [Sch16] and [Sch18]. [Surprise_Paradox] title = Surprise Paradox author = Joachim Breitner notify = mail@joachim-breitner.de date = 2016-07-17 topic = Logic/Proof theory abstract = In 1964, Fitch showed that the paradox of the surprise hanging can be resolved by showing that the judge’s verdict is inconsistent. His formalization builds on Gödel’s coding of provability. In this theory, we reproduce his proof in Isabelle, building on Paulson’s formalisation of Gödel’s incompleteness theorems. [Ptolemys_Theorem] title = Ptolemy's Theorem author = Lukas Bulwahn notify = lukas.bulwahn@gmail.com date = 2016-08-07 topic = Mathematics/Geometry abstract = This entry provides an analytic proof to Ptolemy's Theorem using polar form transformation and trigonometric identities. In this formalization, we use ideas from John Harrison's HOL Light formalization and the proof sketch on the Wikipedia entry of Ptolemy's Theorem. This theorem is the 95th theorem of the Top 100 Theorems list. [Falling_Factorial_Sum] title = The Falling Factorial of a Sum author = Lukas Bulwahn topic = Mathematics/Combinatorics date = 2017-12-22 notify = lukas.bulwahn@gmail.com abstract = This entry shows that the falling factorial of a sum can be computed with an expression using binomial coefficients and the falling factorial of its summands. The entry provides three different proofs: a combinatorial proof, an induction proof and an algebraic proof using the Vandermonde identity. The three formalizations try to follow their informal presentations from a Mathematics Stack Exchange page as close as possible. The induction and algebraic formalization end up to be very close to their informal presentation, whereas the combinatorial proof first requires the introduction of list interleavings, and significant more detail than its informal presentation. [InfPathElimination] title = Infeasible Paths Elimination by Symbolic Execution Techniques: Proof of Correctness and Preservation of Paths author = Romain Aissat<>, Frederic Voisin<>, Burkhart Wolff notify = wolff@lri.fr date = 2016-08-18 topic = Computer science/Programming languages/Static analysis abstract = TRACER is a tool for verifying safety properties of sequential C programs. TRACER attempts at building a finite symbolic execution graph which over-approximates the set of all concrete reachable states and the set of feasible paths. We present an abstract framework for TRACER and similar CEGAR-like systems. The framework provides 1) a graph- transformation based method for reducing the feasible paths in control-flow graphs, 2) a model for symbolic execution, subsumption, predicate abstraction and invariant generation. In this framework we formally prove two key properties: correct construction of the symbolic states and preservation of feasible paths. The framework focuses on core operations, leaving to concrete prototypes to “fit in” heuristics for combining them. The accompanying paper (published in ITP 2016) can be found at https://www.lri.fr/∼wolff/papers/conf/2016-itp-InfPathsNSE.pdf. [Stirling_Formula] title = Stirling's formula author = Manuel Eberl notify = eberlm@in.tum.de date = 2016-09-01 topic = Mathematics/Analysis abstract =

This work contains a proof of Stirling's formula both for the factorial $n! \sim \sqrt{2\pi n} (n/e)^n$ on natural numbers and the real Gamma function $\Gamma(x)\sim \sqrt{2\pi/x} (x/e)^x$. The proof is based on work by Graham Jameson.

This is then extended to the full asymptotic expansion $$\log\Gamma(z) = \big(z - \tfrac{1}{2}\big)\log z - z + \tfrac{1}{2}\log(2\pi) + \sum_{k=1}^{n-1} \frac{B_{k+1}}{k(k+1)} z^{-k}\\ {} - \frac{1}{n} \int_0^\infty B_n([t])(t + z)^{-n}\,\text{d}t$$ uniformly for all complex $z\neq 0$ in the cone $\text{arg}(z)\leq \alpha$ for any $\alpha\in(0,\pi)$, with which the above asymptotic relation for Γ is also extended to complex arguments.

[Lp] title = Lp spaces author = Sebastien Gouezel notify = sebastien.gouezel@univ-rennes1.fr date = 2016-10-05 topic = Mathematics/Analysis abstract = Lp is the space of functions whose p-th power is integrable. It is one of the most fundamental Banach spaces that is used in analysis and probability. We develop a framework for function spaces, and then implement the Lp spaces in this framework using the existing integration theory in Isabelle/HOL. Our development contains most fundamental properties of Lp spaces, notably the Hölder and Minkowski inequalities, completeness of Lp, duality, stability under almost sure convergence, multiplication of functions in Lp and Lq, stability under conditional expectation. [Berlekamp_Zassenhaus] title = The Factorization Algorithm of Berlekamp and Zassenhaus author = Jose Divasón , Sebastiaan Joosten , René Thiemann , Akihisa Yamada notify = rene.thiemann@uibk.ac.at date = 2016-10-14 topic = Mathematics/Algebra abstract =

We formalize the Berlekamp-Zassenhaus algorithm for factoring square-free integer polynomials in Isabelle/HOL. We further adapt an existing formalization of Yun’s square-free factorization algorithm to integer polynomials, and thus provide an efficient and certified factorization algorithm for arbitrary univariate polynomials.

The algorithm first performs a factorization in the prime field GF(p) and then performs computations in the integer ring modulo p^k, where both p and k are determined at runtime. Since a natural modeling of these structures via dependent types is not possible in Isabelle/HOL, we formalize the whole algorithm using Isabelle’s recent addition of local type definitions.

Through experiments we verify that our algorithm factors polynomials of degree 100 within seconds.

[Allen_Calculus] title = Allen's Interval Calculus author = Fadoua Ghourabi <> notify = fadouaghourabi@gmail.com date = 2016-09-29 topic = Logic/General logic/Temporal logic, Mathematics/Order abstract = Allen’s interval calculus is a qualitative temporal representation of time events. Allen introduced 13 binary relations that describe all the possible arrangements between two events, i.e. intervals with non-zero finite length. The compositions are pertinent to reasoning about knowledge of time. In particular, a consistency problem of relation constraints is commonly solved with a guideline from these compositions. We formalize the relations together with an axiomatic system. We proof the validity of the 169 compositions of these relations. We also define nests as the sets of intervals that share a meeting point. We prove that nests give the ordering properties of points without introducing a new datatype for points. [1] J.F. Allen. Maintaining Knowledge about Temporal Intervals. In Commun. ACM, volume 26, pages 832–843, 1983. [2] J. F. Allen and P. J. Hayes. A Common-sense Theory of Time. In Proceedings of the 9th International Joint Conference on Artificial Intelligence (IJCAI’85), pages 528–531, 1985. [Source_Coding_Theorem] title = Source Coding Theorem author = Quentin Hibon , Lawrence C. Paulson notify = qh225@cl.cam.ac.uk date = 2016-10-19 topic = Mathematics/Probability theory abstract = This document contains a proof of the necessary condition on the code rate of a source code, namely that this code rate is bounded by the entropy of the source. This represents one half of Shannon's source coding theorem, which is itself an equivalence. [Buffons_Needle] title = Buffon's Needle Problem author = Manuel Eberl topic = Mathematics/Probability theory, Mathematics/Geometry date = 2017-06-06 notify = eberlm@in.tum.de abstract = In the 18th century, Georges-Louis Leclerc, Comte de Buffon posed and later solved the following problem, which is often called the first problem ever solved in geometric probability: Given a floor divided into vertical strips of the same width, what is the probability that a needle thrown onto the floor randomly will cross two strips? This entry formally defines the problem in the case where the needle's position is chosen uniformly at random in a single strip around the origin (which is equivalent to larger arrangements due to symmetry). It then provides proofs of the simple solution in the case where the needle's length is no greater than the width of the strips and the more complicated solution in the opposite case. [SPARCv8] title = A formal model for the SPARCv8 ISA and a proof of non-interference for the LEON3 processor author = Zhe Hou , David Sanan , Alwen Tiu , Yang Liu notify = zhe.hou@ntu.edu.sg, sanan@ntu.edu.sg date = 2016-10-19 topic = Computer science/Security, Computer science/Hardware abstract = We formalise the SPARCv8 instruction set architecture (ISA) which is used in processors such as LEON3. Our formalisation can be specialised to any SPARCv8 CPU, here we use LEON3 as a running example. Our model covers the operational semantics for all the instructions in the integer unit of the SPARCv8 architecture and it supports Isabelle code export, which effectively turns the Isabelle model into a SPARCv8 CPU simulator. We prove the language-based non-interference property for the LEON3 processor. Our model is based on deterministic monad, which is a modified version of the non-deterministic monad from NICTA/l4v. [Separata] title = Separata: Isabelle tactics for Separation Algebra author = Zhe Hou , David Sanan , Alwen Tiu , Rajeev Gore , Ranald Clouston notify = zhe.hou@ntu.edu.sg date = 2016-11-16 topic = Computer science/Programming languages/Logics, Tools abstract = We bring the labelled sequent calculus $LS_{PASL}$ for propositional abstract separation logic to Isabelle. The tactics given here are directly applied on an extension of the Separation Algebra in the AFP. In addition to the cancellative separation algebra, we further consider some useful properties in the heap model of separation logic, such as indivisible unit, disjointness, and cross-split. The tactics are essentially a proof search procedure for the calculus $LS_{PASL}$. We wrap the tactics in an Isabelle method called separata, and give a few examples of separation logic formulae which are provable by separata. [LOFT] title = LOFT — Verified Migration of Linux Firewalls to SDN author = Julius Michaelis , Cornelius Diekmann notify = isabelleopenflow@liftm.de date = 2016-10-21 topic = Computer science/Networks abstract = We present LOFT — Linux firewall OpenFlow Translator, a system that transforms the main routing table and FORWARD chain of iptables of a Linux-based firewall into a set of static OpenFlow rules. Our implementation is verified against a model of a simplified Linux-based router and we can directly show how much of the original functionality is preserved. [Stable_Matching] title = Stable Matching author = Peter Gammie notify = peteg42@gmail.com date = 2016-10-24 topic = Mathematics/Games and economics abstract = We mechanize proofs of several results from the matching with contracts literature, which generalize those of the classical two-sided matching scenarios that go by the name of stable marriage. Our focus is on game theoretic issues. Along the way we develop executable algorithms for computing optimal stable matches. [Modal_Logics_for_NTS] title = Modal Logics for Nominal Transition Systems author = Tjark Weber , Lars-Henrik Eriksson , Joachim Parrow , Johannes Borgström , Ramunas Gutkovas notify = tjark.weber@it.uu.se date = 2016-10-25 topic = Computer science/Concurrency/Process calculi, Logic/General logic/Modal logic abstract = We formalize a uniform semantic substrate for a wide variety of process calculi where states and action labels can be from arbitrary nominal sets. A Hennessy-Milner logic for these systems is defined, and proved adequate for bisimulation equivalence. A main novelty is the construction of an infinitary nominal data type to model formulas with (finitely supported) infinite conjunctions and actions that may contain binding names. The logic is generalized to treat different bisimulation variants such as early, late and open in a systematic way. extra-history = Change history: [2017-01-29]: Formalization of weak bisimilarity added (revision c87cc2057d9c) [Abs_Int_ITP2012] title = Abstract Interpretation of Annotated Commands author = Tobias Nipkow notify = nipkow@in.tum.de date = 2016-11-23 topic = Computer science/Programming languages/Static analysis abstract = This is the Isabelle formalization of the material decribed in the eponymous ITP 2012 paper. It develops a generic abstract interpreter for a while-language, including widening and narrowing. The collecting semantics and the abstract interpreter operate on annotated commands: the program is represented as a syntax tree with the semantic information directly embedded, without auxiliary labels. The aim of the formalization is simplicity, not efficiency or precision. This is motivated by the inclusion of the material in a theorem prover based course on semantics. A similar (but more polished) development is covered in the book Concrete Semantics. [Complx] title = COMPLX: A Verification Framework for Concurrent Imperative Programs author = Sidney Amani<>, June Andronick<>, Maksym Bortin<>, Corey Lewis<>, Christine Rizkallah<>, Joseph Tuong<> notify = sidney.amani@data61.csiro.au, corey.lewis@data61.csiro.au date = 2016-11-29 topic = Computer science/Programming languages/Logics, Computer science/Programming languages/Language definitions abstract = We propose a concurrency reasoning framework for imperative programs, based on the Owicki-Gries (OG) foundational shared-variable concurrency method. Our framework combines the approaches of Hoare-Parallel, a formalisation of OG in Isabelle/HOL for a simple while-language, and Simpl, a generic imperative language embedded in Isabelle/HOL, allowing formal reasoning on C programs. We define the Complx language, extending the syntax and semantics of Simpl with support for parallel composition and synchronisation. We additionally define an OG logic, which we prove sound w.r.t. the semantics, and a verification condition generator, both supporting involved low-level imperative constructs such as function calls and abrupt termination. We illustrate our framework on an example that features exceptions, guards and function calls. We aim to then target concurrent operating systems, such as the interruptible eChronos embedded operating system for which we already have a model-level OG proof using Hoare-Parallel. extra-history = Change history: [2017-01-13]: Improve VCG for nested parallels and sequential sections (revision 30739dbc3dcb) [Paraconsistency] title = Paraconsistency author = Anders Schlichtkrull , Jørgen Villadsen topic = Logic/General logic/Paraconsistent logics date = 2016-12-07 notify = andschl@dtu.dk, jovi@dtu.dk abstract = Paraconsistency is about handling inconsistency in a coherent way. In classical and intuitionistic logic everything follows from an inconsistent theory. A paraconsistent logic avoids the explosion. Quite a few applications in computer science and engineering are discussed in the Intelligent Systems Reference Library Volume 110: Towards Paraconsistent Engineering (Springer 2016). We formalize a paraconsistent many-valued logic that we motivated and described in a special issue on logical approaches to paraconsistency (Journal of Applied Non-Classical Logics 2005). We limit ourselves to the propositional fragment of the higher-order logic. The logic is based on so-called key equalities and has a countably infinite number of truth values. We prove theorems in the logic using the definition of validity. We verify truth tables and also counterexamples for non-theorems. We prove meta-theorems about the logic and finally we investigate a case study. [Proof_Strategy_Language] title = Proof Strategy Language author = Yutaka Nagashima<> topic = Tools date = 2016-12-20 notify = Yutaka.Nagashima@data61.csiro.au abstract = Isabelle includes various automatic tools for finding proofs under certain conditions. However, for each conjecture, knowing which automation to use, and how to tweak its parameters, is currently labour intensive. We have developed a language, PSL, designed to capture high level proof strategies. PSL offloads the construction of human-readable fast-to-replay proof scripts to automatic search, making use of search-time information about each conjecture. Our preliminary evaluations show that PSL reduces the labour cost of interactive theorem proving. This submission contains the implementation of PSL and an example theory file, Example.thy, showing how to write poof strategies in PSL. [Concurrent_Ref_Alg] title = Concurrent Refinement Algebra and Rely Quotients author = Julian Fell , Ian J. Hayes , Andrius Velykis topic = Computer science/Concurrency date = 2016-12-30 notify = Ian.Hayes@itee.uq.edu.au abstract = The concurrent refinement algebra developed here is designed to provide a foundation for rely/guarantee reasoning about concurrent programs. The algebra builds on a complete lattice of commands by providing sequential composition, parallel composition and a novel weak conjunction operator. The weak conjunction operator coincides with the lattice supremum providing its arguments are non-aborting, but aborts if either of its arguments do. Weak conjunction provides an abstract version of a guarantee condition as a guarantee process. We distinguish between models that distribute sequential composition over non-deterministic choice from the left (referred to as being conjunctive in the refinement calculus literature) and those that don't. Least and greatest fixed points of monotone functions are provided to allow recursion and iteration operators to be added to the language. Additional iteration laws are available for conjunctive models. The rely quotient of processes c and i is the process that, if executed in parallel with i implements c. It represents an abstract version of a rely condition generalised to a process. [FOL_Harrison] title = First-Order Logic According to Harrison author = Alexander Birch Jensen , Anders Schlichtkrull , Jørgen Villadsen topic = Logic/General logic/Mechanization of proofs date = 2017-01-01 notify = aleje@dtu.dk, andschl@dtu.dk, jovi@dtu.dk abstract =

We present a certified declarative first-order prover with equality based on John Harrison's Handbook of Practical Logic and Automated Reasoning, Cambridge University Press, 2009. ML code reflection is used such that the entire prover can be executed within Isabelle as a very simple interactive proof assistant. As examples we consider Pelletier's problems 1-46.

Reference: Programming and Verifying a Declarative First-Order Prover in Isabelle/HOL. Alexander Birch Jensen, John Bruntse Larsen, Anders Schlichtkrull & Jørgen Villadsen. AI Communications 31:281-299 2018. https://content.iospress.com/articles/ai-communications/aic764

See also: Students' Proof Assistant (SPA). https://github.com/logic-tools/spa

extra-history = Change history: [2018-07-21]: Proof of Pelletier's problem 34 (Andrews's Challenge) thanks to Asta Halkjær From. [Bernoulli] title = Bernoulli Numbers author = Lukas Bulwahn, Manuel Eberl topic = Mathematics/Analysis, Mathematics/Number theory date = 2017-01-24 notify = eberlm@in.tum.de abstract =

Bernoulli numbers were first discovered in the closed-form expansion of the sum 1m + 2m + … + nm for a fixed m and appear in many other places. This entry provides three different definitions for them: a recursive one, an explicit one, and one through their exponential generating function.

In addition, we prove some basic facts, e.g. their relation to sums of powers of integers and that all odd Bernoulli numbers except the first are zero, and some advanced facts like their relationship to the Riemann zeta function on positive even integers.

We also prove the correctness of the Akiyama–Tanigawa algorithm for computing Bernoulli numbers with reasonable efficiency, and we define the periodic Bernoulli polynomials (which appear e.g. in the Euler–MacLaurin summation formula and the expansion of the log-Gamma function) and prove their basic properties.

[Stone_Relation_Algebras] title = Stone Relation Algebras author = Walter Guttmann topic = Mathematics/Algebra date = 2017-02-07 notify = walter.guttmann@canterbury.ac.nz abstract = We develop Stone relation algebras, which generalise relation algebras by replacing the underlying Boolean algebra structure with a Stone algebra. We show that finite matrices over extended real numbers form an instance. As a consequence, relation-algebraic concepts and methods can be used for reasoning about weighted graphs. We also develop a fixpoint calculus and apply it to compare different definitions of reflexive-transitive closures in semirings. extra-history = Change history: [2017-07-05]: generalised extended reals to linear orders (revision b8e703159177) [Stone_Kleene_Relation_Algebras] title = Stone-Kleene Relation Algebras author = Walter Guttmann topic = Mathematics/Algebra date = 2017-07-06 notify = walter.guttmann@canterbury.ac.nz abstract = We develop Stone-Kleene relation algebras, which expand Stone relation algebras with a Kleene star operation to describe reachability in weighted graphs. Many properties of the Kleene star arise as a special case of a more general theory of iteration based on Conway semirings extended by simulation axioms. This includes several theorems representing complex program transformations. We formally prove the correctness of Conway's automata-based construction of the Kleene star of a matrix. We prove numerous results useful for reasoning about weighted graphs. [Abstract_Soundness] title = Abstract Soundness author = Jasmin Christian Blanchette , Andrei Popescu , Dmitriy Traytel topic = Logic/Proof theory date = 2017-02-10 notify = jasmin.blanchette@gmail.com abstract = A formalized coinductive account of the abstract development of Brotherston, Gorogiannis, and Petersen [APLAS 2012], in a slightly more general form since we work with arbitrary infinite proofs, which may be acyclic. This work is described in detail in an article by the authors, published in 2017 in the Journal of Automated Reasoning. The abstract proof can be instantiated for various formalisms, including first-order logic with inductive predicates. [Differential_Dynamic_Logic] title = Differential Dynamic Logic author = Brandon Bohrer topic = Logic/General logic/Modal logic, Computer science/Programming languages/Logics date = 2017-02-13 notify = bbohrer@cs.cmu.edu abstract = We formalize differential dynamic logic, a logic for proving properties of hybrid systems. The proof calculus in this formalization is based on the uniform substitution principle. We show it is sound with respect to our denotational semantics, which provides increased confidence in the correctness of the KeYmaera X theorem prover based on this calculus. As an application, we include a proof term checker embedded in Isabelle/HOL with several example proofs. Published in: Brandon Bohrer, Vincent Rahli, Ivana Vukotic, Marcus Völp, André Platzer: Formally verified differential dynamic logic. CPP 2017. [Syntax_Independent_Logic] title = Syntax-Independent Logic Infrastructure author = Andrei Popescu , Dmitriy Traytel topic = Logic/Proof theory date = 2020-09-16 notify = a.popescu@sheffield.ac.uk, traytel@di.ku.dk abstract = We formalize a notion of logic whose terms and formulas are kept abstract. In particular, logical connectives, substitution, free variables, and provability are not defined, but characterized by their general properties as locale assumptions. Based on this abstract characterization, we develop further reusable reasoning infrastructure. For example, we define parallel substitution (along with proving its characterizing theorems) from single-point substitution. Similarly, we develop a natural deduction style proof system starting from the abstract Hilbert-style one. These one-time efforts benefit different concrete logics satisfying our locales' assumptions. We instantiate the syntax-independent logic infrastructure to Robinson arithmetic (also known as Q) in the AFP entry Robinson_Arithmetic and to hereditarily finite set theory in the AFP entries Goedel_HFSet_Semantic and Goedel_HFSet_Semanticless, which are part of our formalization of Gödel's Incompleteness Theorems described in our CADE-27 paper A Formally Verified Abstract Account of Gödel's Incompleteness Theorems. [Goedel_Incompleteness] title = An Abstract Formalization of Gödel's Incompleteness Theorems author = Andrei Popescu , Dmitriy Traytel topic = Logic/Proof theory date = 2020-09-16 notify = a.popescu@sheffield.ac.uk, traytel@di.ku.dk abstract = We present an abstract formalization of Gödel's incompleteness theorems. We analyze sufficient conditions for the theorems' applicability to a partially specified logic. Our abstract perspective enables a comparison between alternative approaches from the literature. These include Rosser's variation of the first theorem, Jeroslow's variation of the second theorem, and the Swierczkowski–Paulson semantics-based approach. This AFP entry is the main entry point to the results described in our CADE-27 paper A Formally Verified Abstract Account of Gödel's Incompleteness Theorems. As part of our abstract formalization's validation, we instantiate our locales twice in the separate AFP entries Goedel_HFSet_Semantic and Goedel_HFSet_Semanticless. [Goedel_HFSet_Semantic] title = From Abstract to Concrete Gödel's Incompleteness Theorems—Part I author = Andrei Popescu , Dmitriy Traytel topic = Logic/Proof theory date = 2020-09-16 notify = a.popescu@sheffield.ac.uk, traytel@di.ku.dk abstract = We validate an abstract formulation of Gödel's First and Second Incompleteness Theorems from a separate AFP entry by instantiating them to the case of finite sound extensions of the Hereditarily Finite (HF) Set theory, i.e., FOL theories extending the HF Set theory with a finite set of axioms that are sound in the standard model. The concrete results had been previously formalised in an AFP entry by Larry Paulson; our instantiation reuses the infrastructure developed in that entry. [Goedel_HFSet_Semanticless] title = From Abstract to Concrete Gödel's Incompleteness Theorems—Part II author = Andrei Popescu , Dmitriy Traytel topic = Logic/Proof theory date = 2020-09-16 notify = a.popescu@sheffield.ac.uk, traytel@di.ku.dk abstract = We validate an abstract formulation of Gödel's Second Incompleteness Theorem from a separate AFP entry by instantiating it to the case of finite consistent extensions of the Hereditarily Finite (HF) Set theory, i.e., consistent FOL theories extending the HF Set theory with a finite set of axioms. The instantiation draws heavily on infrastructure previously developed by Larry Paulson in his direct formalisation of the concrete result. It strengthens Paulson's formalization of Gödel's Second from that entry by not assuming soundness, and in fact not relying on any notion of model or semantic interpretation. The strengthening was obtained by first replacing some of Paulson’s semantic arguments with proofs within his HF calculus, and then plugging in some of Paulson's (modified) lemmas to instantiate our soundness-free Gödel's Second locale. [Robinson_Arithmetic] title = Robinson Arithmetic author = Andrei Popescu , Dmitriy Traytel topic = Logic/Proof theory date = 2020-09-16 notify = a.popescu@sheffield.ac.uk, traytel@di.ku.dk abstract = We instantiate our syntax-independent logic infrastructure developed in a separate AFP entry to the FOL theory of Robinson arithmetic (also known as Q). The latter was formalised using Nominal Isabelle by adapting Larry Paulson’s formalization of the Hereditarily Finite Set theory. [Elliptic_Curves_Group_Law] title = The Group Law for Elliptic Curves author = Stefan Berghofer topic = Computer science/Security/Cryptography date = 2017-02-28 notify = berghofe@in.tum.de abstract = We prove the group law for elliptic curves in Weierstrass form over fields of characteristic greater than 2. In addition to affine coordinates, we also formalize projective coordinates, which allow for more efficient computations. By specializing the abstract formalization to prime fields, we can apply the curve operations to parameters used in standard security protocols. [Example-Submission] title = Example Submission author = Gerwin Klein topic = Mathematics/Analysis, Mathematics/Number theory date = 2004-02-25 notify = kleing@cse.unsw.edu.au abstract =

This is an example submission to the Archive of Formal Proofs. It shows submission requirements and explains the structure of a simple typical submission.

Note that you can use HTML tags and LaTeX formulae like $\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}$ in the abstract. Display formulae like $$ \int_0^1 x^{-x}\,\text{d}x = \sum_{n=1}^\infty n^{-n}$$ are also possible. Please read the submission guidelines before using this.

extra-no-index = no-index: true [CRDT] title = A framework for establishing Strong Eventual Consistency for Conflict-free Replicated Datatypes author = Victor B. F. Gomes , Martin Kleppmann, Dominic P. Mulligan, Alastair R. Beresford topic = Computer science/Algorithms/Distributed, Computer science/Data structures date = 2017-07-07 notify = vb358@cam.ac.uk, dominic.p.mulligan@googlemail.com abstract = In this work, we focus on the correctness of Conflict-free Replicated Data Types (CRDTs), a class of algorithm that provides strong eventual consistency guarantees for replicated data. We develop a modular and reusable framework for verifying the correctness of CRDT algorithms. We avoid correctness issues that have dogged previous mechanised proofs in this area by including a network model in our formalisation, and proving that our theorems hold in all possible network behaviours. Our axiomatic network model is a standard abstraction that accurately reflects the behaviour of real-world computer networks. Moreover, we identify an abstract convergence theorem, a property of order relations, which provides a formal definition of strong eventual consistency. We then obtain the first machine-checked correctness theorems for three concrete CRDTs: the Replicated Growable Array, the Observed-Remove Set, and an Increment-Decrement Counter. [HOLCF-Prelude] title = HOLCF-Prelude author = Joachim Breitner, Brian Huffman<>, Neil Mitchell<>, Christian Sternagel topic = Computer science/Functional programming date = 2017-07-15 notify = c.sternagel@gmail.com, joachim@cis.upenn.edu, hupel@in.tum.de abstract = The Isabelle/HOLCF-Prelude is a formalization of a large part of Haskell's standard prelude in Isabelle/HOLCF. We use it to prove the correctness of the Eratosthenes' Sieve, in its self-referential implementation commonly used to showcase Haskell's laziness; prove correctness of GHC's "fold/build" rule and related rewrite rules; and certify a number of hints suggested by HLint. [Decl_Sem_Fun_PL] title = Declarative Semantics for Functional Languages author = Jeremy Siek topic = Computer science/Programming languages date = 2017-07-21 notify = jsiek@indiana.edu abstract = We present a semantics for an applied call-by-value lambda-calculus that is compositional, extensional, and elementary. We present four different views of the semantics: 1) as a relational (big-step) semantics that is not operational but instead declarative, 2) as a denotational semantics that does not use domain theory, 3) as a non-deterministic interpreter, and 4) as a variant of the intersection type systems of the Torino group. We prove that the semantics is correct by showing that it is sound and complete with respect to operational semantics on programs and that is sound with respect to contextual equivalence. We have not yet investigated whether it is fully abstract. We demonstrate that this approach to semantics is useful with three case studies. First, we use the semantics to prove correctness of a compiler optimization that inlines function application. Second, we adapt the semantics to the polymorphic lambda-calculus extended with general recursion and prove semantic type soundness. Third, we adapt the semantics to the call-by-value lambda-calculus with mutable references.
The paper that accompanies these Isabelle theories is available on arXiv. [DynamicArchitectures] title = Dynamic Architectures author = Diego Marmsoler topic = Computer science/System description languages date = 2017-07-28 notify = diego.marmsoler@tum.de abstract = The architecture of a system describes the system's overall organization into components and connections between those components. With the emergence of mobile computing, dynamic architectures have become increasingly important. In such architectures, components may appear or disappear, and connections may change over time. In the following we mechanize a theory of dynamic architectures and verify the soundness of a corresponding calculus. Therefore, we first formalize the notion of configuration traces as a model for dynamic architectures. Then, the behavior of single components is formalized in terms of behavior traces and an operator is introduced and studied to extract the behavior of a single component out of a given configuration trace. Then, behavior trace assertions are introduced as a temporal specification technique to specify behavior of components. Reasoning about component behavior in a dynamic context is formalized in terms of a calculus for dynamic architectures. Finally, the soundness of the calculus is verified by introducing an alternative interpretation for behavior trace assertions over configuration traces and proving the rules of the calculus. Since projection may lead to finite as well as infinite behavior traces, they are formalized in terms of coinductive lists. Thus, our theory is based on Lochbihler's formalization of coinductive lists. The theory may be applied to verify properties for dynamic architectures. extra-history = Change history: [2018-06-07]: adding logical operators to specify configuration traces (revision 09178f08f050)
[Stewart_Apollonius] title = Stewart's Theorem and Apollonius' Theorem author = Lukas Bulwahn topic = Mathematics/Geometry date = 2017-07-31 notify = lukas.bulwahn@gmail.com abstract = This entry formalizes the two geometric theorems, Stewart's and Apollonius' theorem. Stewart's Theorem relates the length of a triangle's cevian to the lengths of the triangle's two sides. Apollonius' Theorem is a specialisation of Stewart's theorem, restricting the cevian to be the median. The proof applies the law of cosines, some basic geometric facts about triangles and then simply transforms the terms algebraically to yield the conjectured relation. The formalization in Isabelle can closely follow the informal proofs described in the Wikipedia articles of those two theorems. [LambdaMu] title = The LambdaMu-calculus author = Cristina Matache , Victor B. F. Gomes , Dominic P. Mulligan topic = Computer science/Programming languages/Lambda calculi, Logic/General logic/Lambda calculus date = 2017-08-16 notify = victorborgesfg@gmail.com, dominic.p.mulligan@googlemail.com abstract = The propositions-as-types correspondence is ordinarily presented as linking the metatheory of typed λ-calculi and the proof theory of intuitionistic logic. Griffin observed that this correspondence could be extended to classical logic through the use of control operators. This observation set off a flurry of further research, leading to the development of Parigots λμ-calculus. In this work, we formalise λμ- calculus in Isabelle/HOL and prove several metatheoretical properties such as type preservation and progress. [Orbit_Stabiliser] title = Orbit-Stabiliser Theorem with Application to Rotational Symmetries author = Jonas Rädle topic = Mathematics/Algebra date = 2017-08-20 notify = jonas.raedle@tum.de abstract = The Orbit-Stabiliser theorem is a basic result in the algebra of groups that factors the order of a group into the sizes of its orbits and stabilisers. We formalize the notion of a group action and the related concepts of orbits and stabilisers. This allows us to prove the orbit-stabiliser theorem. In the second part of this work, we formalize the tetrahedral group and use the orbit-stabiliser theorem to prove that there are twelve (orientation-preserving) rotations of the tetrahedron. [PLM] title = Representation and Partial Automation of the Principia Logico-Metaphysica in Isabelle/HOL author = Daniel Kirchner topic = Logic/Philosophical aspects date = 2017-09-17 notify = daniel@ekpyron.org abstract =

We present an embedding of the second-order fragment of the Theory of Abstract Objects as described in Edward Zalta's upcoming work Principia Logico-Metaphysica (PLM) in the automated reasoning framework Isabelle/HOL. The Theory of Abstract Objects is a metaphysical theory that reifies property patterns, as they for example occur in the abstract reasoning of mathematics, as abstract objects and provides an axiomatic framework that allows to reason about these objects. It thereby serves as a fundamental metaphysical theory that can be used to axiomatize and describe a wide range of philosophical objects, such as Platonic forms or Leibniz' concepts, and has the ambition to function as a foundational theory of mathematics. The target theory of our embedding as described in chapters 7-9 of PLM employs a modal relational type theory as logical foundation for which a representation in functional type theory is known to be challenging.

Nevertheless we arrive at a functioning representation of the theory in the functional logic of Isabelle/HOL based on a semantical representation of an Aczel-model of the theory. Based on this representation we construct an implementation of the deductive system of PLM which allows to automatically and interactively find and verify theorems of PLM.

Our work thereby supports the concept of shallow semantical embeddings of logical systems in HOL as a universal tool for logical reasoning as promoted by Christoph Benzmüller.

The most notable result of the presented work is the discovery of a previously unknown paradox in the formulation of the Theory of Abstract Objects. The embedding of the theory in Isabelle/HOL played a vital part in this discovery. Furthermore it was possible to immediately offer several options to modify the theory to guarantee its consistency. Thereby our work could provide a significant contribution to the development of a proper grounding for object theory.

[KD_Tree] title = Multidimensional Binary Search Trees author = Martin Rau<> topic = Computer science/Data structures date = 2019-05-30 notify = martin.rau@tum.de, mrtnrau@googlemail.com abstract = This entry provides a formalization of multidimensional binary trees, also known as k-d trees. It includes a balanced build algorithm as well as the nearest neighbor algorithm and the range search algorithm. It is based on the papers Multidimensional binary search trees used for associative searching and An Algorithm for Finding Best Matches in Logarithmic Expected Time. extra-history = Change history: [2020-15-04]: Change representation of k-dimensional points from 'list' to HOL-Analysis.Finite_Cartesian_Product 'vec'. Update proofs to incorporate HOL-Analysis 'dist' and 'cbox' primitives. [Closest_Pair_Points] title = Closest Pair of Points Algorithms author = Martin Rau , Tobias Nipkow topic = Computer science/Algorithms/Geometry date = 2020-01-13 notify = martin.rau@tum.de, nipkow@in.tum.de abstract = This entry provides two related verified divide-and-conquer algorithms solving the fundamental Closest Pair of Points problem in Computational Geometry. Functional correctness and the optimal running time of O(n log n) are proved. Executable code is generated which is empirically competitive with handwritten reference implementations. extra-history = Change history: [2020-14-04]: Incorporate Time_Monad of the AFP entry Root_Balanced_Tree. [Approximation_Algorithms] title = Verified Approximation Algorithms author = Robin Eßmann , Tobias Nipkow , Simon Robillard , Ujkan Sulejmani<> topic = Computer science/Algorithms/Approximation date = 2020-01-16 notify = nipkow@in.tum.de abstract = We present the first formal verification of approximation algorithms for NP-complete optimization problems: vertex cover, set cover, independent set, center selection, load balancing, and bin packing. The proofs correct incompletenesses in existing proofs and improve the approximation ratio in one case. A detailed description of our work (excluding center selection) has been published in the proceedings of IJCAR 2020. [Diophantine_Eqns_Lin_Hom] title = Homogeneous Linear Diophantine Equations author = Florian Messner , Julian Parsert , Jonas Schöpf , Christian Sternagel topic = Computer science/Algorithms/Mathematical, Mathematics/Number theory, Tools license = LGPL date = 2017-10-14 notify = c.sternagel@gmail.com, julian.parsert@gmail.com abstract = We formalize the theory of homogeneous linear diophantine equations, focusing on two main results: (1) an abstract characterization of minimal complete sets of solutions, and (2) an algorithm computing them. Both, the characterization and the algorithm are based on previous work by Huet. Our starting point is a simple but inefficient variant of Huet's lexicographic algorithm incorporating improved bounds due to Clausen and Fortenbacher. We proceed by proving its soundness and completeness. Finally, we employ code equations to obtain a reasonably efficient implementation. Thus, we provide a formally verified solver for homogeneous linear diophantine equations. [Winding_Number_Eval] title = Evaluate Winding Numbers through Cauchy Indices author = Wenda Li topic = Mathematics/Analysis date = 2017-10-17 notify = wl302@cam.ac.uk, liwenda1990@hotmail.com abstract = In complex analysis, the winding number measures the number of times a path (counterclockwise) winds around a point, while the Cauchy index can approximate how the path winds. This entry provides a formalisation of the Cauchy index, which is then shown to be related to the winding number. In addition, this entry also offers a tactic that enables users to evaluate the winding number by calculating Cauchy indices. [Count_Complex_Roots] title = Count the Number of Complex Roots author = Wenda Li topic = Mathematics/Analysis date = 2017-10-17 notify = wl302@cam.ac.uk, liwenda1990@hotmail.com abstract = Based on evaluating Cauchy indices through remainder sequences, this entry provides an effective procedure to count the number of complex roots (with multiplicity) of a polynomial within a rectangle box or a half-plane. Potential applications of this entry include certified complex root isolation (of a polynomial) and testing the Routh-Hurwitz stability criterion (i.e., to check whether all the roots of some characteristic polynomial have negative real parts). [Buchi_Complementation] title = Büchi Complementation author = Julian Brunner topic = Computer science/Automata and formal languages date = 2017-10-19 notify = brunnerj@in.tum.de abstract = This entry provides a verified implementation of rank-based Büchi Complementation. The verification is done in three steps:
  1. Definition of odd rankings and proof that an automaton rejects a word iff there exists an odd ranking for it.
  2. Definition of the complement automaton and proof that it accepts exactly those words for which there is an odd ranking.
  3. Verified implementation of the complement automaton using the Isabelle Collections Framework.
[Transition_Systems_and_Automata] title = Transition Systems and Automata author = Julian Brunner topic = Computer science/Automata and formal languages date = 2017-10-19 notify = brunnerj@in.tum.de abstract = This entry provides a very abstract theory of transition systems that can be instantiated to express various types of automata. A transition system is typically instantiated by providing a set of initial states, a predicate for enabled transitions, and a transition execution function. From this, it defines the concepts of finite and infinite paths as well as the set of reachable states, among other things. Many useful theorems, from basic path manipulation rules to coinduction and run construction rules, are proven in this abstract transition system context. The library comes with instantiations for DFAs, NFAs, and Büchi automata. [Kuratowski_Closure_Complement] title = The Kuratowski Closure-Complement Theorem author = Peter Gammie , Gianpaolo Gioiosa<> topic = Mathematics/Topology date = 2017-10-26 notify = peteg42@gmail.com abstract = We discuss a topological curiosity discovered by Kuratowski (1922): the fact that the number of distinct operators on a topological space generated by compositions of closure and complement never exceeds 14, and is exactly 14 in the case of R. In addition, we prove a theorem due to Chagrov (1982) that classifies topological spaces according to the number of such operators they support. [Hybrid_Multi_Lane_Spatial_Logic] title = Hybrid Multi-Lane Spatial Logic author = Sven Linker topic = Logic/General logic/Modal logic date = 2017-11-06 notify = s.linker@liverpool.ac.uk abstract = We present a semantic embedding of a spatio-temporal multi-modal logic, specifically defined to reason about motorway traffic, into Isabelle/HOL. The semantic model is an abstraction of a motorway, emphasising local spatial properties, and parameterised by the types of sensors deployed in the vehicles. We use the logic to define controller constraints to ensure safety, i.e., the absence of collisions on the motorway. After proving safety with a restrictive definition of sensors, we relax these assumptions and show how to amend the controller constraints to still guarantee safety. [Dirichlet_L] title = Dirichlet L-Functions and Dirichlet's Theorem author = Manuel Eberl topic = Mathematics/Number theory, Mathematics/Algebra date = 2017-12-21 notify = eberlm@in.tum.de abstract =

This article provides a formalisation of Dirichlet characters and Dirichlet L-functions including proofs of their basic properties – most notably their analyticity, their areas of convergence, and their non-vanishing for ℜ(s) ≥ 1. All of this is built in a very high-level style using Dirichlet series. The proof of the non-vanishing follows a very short and elegant proof by Newman, which we attempt to reproduce faithfully in a similar level of abstraction in Isabelle.

This also leads to a relatively short proof of Dirichlet’s Theorem, which states that, if h and n are coprime, there are infinitely many primes p with ph (mod n).

[Symmetric_Polynomials] title = Symmetric Polynomials author = Manuel Eberl topic = Mathematics/Algebra date = 2018-09-25 notify = eberlm@in.tum.de abstract =

A symmetric polynomial is a polynomial in variables X1,…,Xn that does not discriminate between its variables, i. e. it is invariant under any permutation of them. These polynomials are important in the study of the relationship between the coefficients of a univariate polynomial and its roots in its algebraic closure.

This article provides a definition of symmetric polynomials and the elementary symmetric polynomials e1,…,en and proofs of their basic properties, including three notable ones:

  • Vieta's formula, which gives an explicit expression for the k-th coefficient of a univariate monic polynomial in terms of its roots x1,…,xn, namely ck = (-1)n-k en-k(x1,…,xn).
  • Second, the Fundamental Theorem of Symmetric Polynomials, which states that any symmetric polynomial is itself a uniquely determined polynomial combination of the elementary symmetric polynomials.
  • Third, as a corollary of the previous two, that given a polynomial over some ring R, any symmetric polynomial combination of its roots is also in R even when the roots are not.

Both the symmetry property itself and the witness for the Fundamental Theorem are executable.

[Taylor_Models] title = Taylor Models author = Christoph Traut<>, Fabian Immler topic = Computer science/Algorithms/Mathematical, Computer science/Data structures, Mathematics/Analysis, Mathematics/Algebra date = 2018-01-08 notify = immler@in.tum.de abstract = We present a formally verified implementation of multivariate Taylor models. Taylor models are a form of rigorous polynomial approximation, consisting of an approximation polynomial based on Taylor expansions, combined with a rigorous bound on the approximation error. Taylor models were introduced as a tool to mitigate the dependency problem of interval arithmetic. Our implementation automatically computes Taylor models for the class of elementary functions, expressed by composition of arithmetic operations and basic functions like exp, sin, or square root. [Green] title = An Isabelle/HOL formalisation of Green's Theorem author = Mohammad Abdulaziz , Lawrence C. Paulson topic = Mathematics/Analysis date = 2018-01-11 notify = mohammad.abdulaziz8@gmail.com, lp15@cam.ac.uk abstract = We formalise a statement of Green’s theorem—the first formalisation to our knowledge—in Isabelle/HOL. The theorem statement that we formalise is enough for most applications, especially in physics and engineering. Our formalisation is made possible by a novel proof that avoids the ubiquitous line integral cancellation argument. This eliminates the need to formalise orientations and region boundaries explicitly with respect to the outwards-pointing normal vector. Instead we appeal to a homological argument about equivalences between paths. [AI_Planning_Languages_Semantics] title = AI Planning Languages Semantics author = Mohammad Abdulaziz , Peter Lammich topic = Computer science/Artificial intelligence date = 2020-10-29 notify = mohammad.abdulaziz8@gmail.com abstract = This is an Isabelle/HOL formalisation of the semantics of the multi-valued planning tasks language that is used by the planning system Fast-Downward, the STRIPS fragment of the Planning Domain Definition Language (PDDL), and the STRIPS soundness meta-theory developed by Vladimir Lifschitz. It also contains formally verified checkers for checking the well-formedness of problems specified in either language as well the correctness of potential solutions. The formalisation in this entry was described in an earlier publication. [Verified_SAT_Based_AI_Planning] title = Verified SAT-Based AI Planning author = Mohammad Abdulaziz , Friedrich Kurz <> topic = Computer science/Artificial intelligence date = 2020-10-29 notify = mohammad.abdulaziz8@gmail.com abstract = We present an executable formally verified SAT encoding of classical AI planning that is based on the encodings by Kautz and Selman and the one by Rintanen et al. The encoding was experimentally tested and shown to be usable for reasonably sized standard AI planning benchmarks. We also use it as a reference to test a state-of-the-art SAT-based planner, showing that it sometimes falsely claims that problems have no solutions of certain lengths. The formalisation in this submission was described in an independent publication. [Gromov_Hyperbolicity] title = Gromov Hyperbolicity author = Sebastien Gouezel<> topic = Mathematics/Geometry date = 2018-01-16 notify = sebastien.gouezel@univ-rennes1.fr abstract = A geodesic metric space is Gromov hyperbolic if all its geodesic triangles are thin, i.e., every side is contained in a fixed thickening of the two other sides. While this definition looks innocuous, it has proved extremely important and versatile in modern geometry since its introduction by Gromov. We formalize the basic classical properties of Gromov hyperbolic spaces, notably the Morse lemma asserting that quasigeodesics are close to geodesics, the invariance of hyperbolicity under quasi-isometries, we define and study the Gromov boundary and its associated distance, and prove that a quasi-isometry between Gromov hyperbolic spaces extends to a homeomorphism of the boundaries. We also prove a less classical theorem, by Bonk and Schramm, asserting that a Gromov hyperbolic space embeds isometrically in a geodesic Gromov-hyperbolic space. As the original proof uses a transfinite sequence of Cauchy completions, this is an interesting formalization exercise. Along the way, we introduce basic material on isometries, quasi-isometries, Lipschitz maps, geodesic spaces, the Hausdorff distance, the Cauchy completion of a metric space, and the exponential on extended real numbers. [Ordered_Resolution_Prover] title = Formalization of Bachmair and Ganzinger's Ordered Resolution Prover author = Anders Schlichtkrull , Jasmin Christian Blanchette , Dmitriy Traytel , Uwe Waldmann topic = Logic/General logic/Mechanization of proofs date = 2018-01-18 notify = andschl@dtu.dk, j.c.blanchette@vu.nl abstract = This Isabelle/HOL formalization covers Sections 2 to 4 of Bachmair and Ganzinger's "Resolution Theorem Proving" chapter in the Handbook of Automated Reasoning. This includes soundness and completeness of unordered and ordered variants of ground resolution with and without literal selection, the standard redundancy criterion, a general framework for refutational theorem proving, and soundness and completeness of an abstract first-order prover. [Chandy_Lamport] title = A Formal Proof of The Chandy--Lamport Distributed Snapshot Algorithm author = Ben Fiedler , Dmitriy Traytel topic = Computer science/Algorithms/Distributed date = 2020-07-21 notify = ben.fiedler@inf.ethz.ch, traytel@inf.ethz.ch abstract = We provide a suitable distributed system model and implementation of the Chandy--Lamport distributed snapshot algorithm [ACM Transactions on Computer Systems, 3, 63-75, 1985]. Our main result is a formal termination and correctness proof of the Chandy--Lamport algorithm and its use in stable property detection. [BNF_Operations] title = Operations on Bounded Natural Functors author = Jasmin Christian Blanchette , Andrei Popescu , Dmitriy Traytel topic = Tools date = 2017-12-19 notify = jasmin.blanchette@gmail.com,uuomul@yahoo.com,traytel@inf.ethz.ch abstract = This entry formalizes the closure property of bounded natural functors (BNFs) under seven operations. These operations and the corresponding proofs constitute the core of Isabelle's (co)datatype package. To be close to the implemented tactics, the proofs are deliberately formulated as detailed apply scripts. The (co)datatypes together with (co)induction principles and (co)recursors are byproducts of the fixpoint operations LFP and GFP. Composition of BNFs is subdivided into four simpler operations: Compose, Kill, Lift, and Permute. The N2M operation provides mutual (co)induction principles and (co)recursors for nested (co)datatypes. [LLL_Basis_Reduction] title = A verified LLL algorithm author = Ralph Bottesch <>, Jose Divasón , Maximilian Haslbeck , Sebastiaan Joosten , René Thiemann , Akihisa Yamada<> topic = Computer science/Algorithms/Mathematical, Mathematics/Algebra date = 2018-02-02 notify = ralph.bottesch@uibk.ac.at, jose.divason@unirioja.es, maximilian.haslbeck@uibk.ac.at, s.j.c.joosten@utwente.nl, rene.thiemann@uibk.ac.at, ayamada@trs.cm.is.nagoya-u.ac.jp abstract = The Lenstra-Lenstra-Lovász basis reduction algorithm, also known as LLL algorithm, is an algorithm to find a basis with short, nearly orthogonal vectors of an integer lattice. Thereby, it can also be seen as an approximation to solve the shortest vector problem (SVP), which is an NP-hard problem, where the approximation quality solely depends on the dimension of the lattice, but not the lattice itself. The algorithm also possesses many applications in diverse fields of computer science, from cryptanalysis to number theory, but it is specially well-known since it was used to implement the first polynomial-time algorithm to factor polynomials. In this work we present the first mechanized soundness proof of the LLL algorithm to compute short vectors in lattices. The formalization follows a textbook by von zur Gathen and Gerhard. extra-history = Change history: [2018-04-16]: Integrated formal complexity bounds (Haslbeck, Thiemann) [2018-05-25]: Integrated much faster LLL implementation based on integer arithmetic (Bottesch, Haslbeck, Thiemann) [LLL_Factorization] title = A verified factorization algorithm for integer polynomials with polynomial complexity author = Jose Divasón , Sebastiaan Joosten , René Thiemann , Akihisa Yamada topic = Mathematics/Algebra date = 2018-02-06 notify = jose.divason@unirioja.es, s.j.c.joosten@utwente.nl, rene.thiemann@uibk.ac.at, ayamada@trs.cm.is.nagoya-u.ac.jp abstract = Short vectors in lattices and factors of integer polynomials are related. Each factor of an integer polynomial belongs to a certain lattice. When factoring polynomials, the condition that we are looking for an irreducible polynomial means that we must look for a small element in a lattice, which can be done by a basis reduction algorithm. In this development we formalize this connection and thereby one main application of the LLL basis reduction algorithm: an algorithm to factor square-free integer polynomials which runs in polynomial time. The work is based on our previous Berlekamp–Zassenhaus development, where the exponential reconstruction phase has been replaced by the polynomial-time basis reduction algorithm. Thanks to this formalization we found a serious flaw in a textbook. [Treaps] title = Treaps author = Maximilian Haslbeck , Manuel Eberl , Tobias Nipkow topic = Computer science/Data structures date = 2018-02-06 notify = eberlm@in.tum.de abstract =

A Treap is a binary tree whose nodes contain pairs consisting of some payload and an associated priority. It must have the search-tree property w.r.t. the payloads and the heap property w.r.t. the priorities. Treaps are an interesting data structure that is related to binary search trees (BSTs) in the following way: if one forgets all the priorities of a treap, the resulting BST is exactly the same as if one had inserted the elements into an empty BST in order of ascending priority. This means that a treap behaves like a BST where we can pretend the elements were inserted in a different order from the one in which they were actually inserted.

In particular, by choosing these priorities at random upon insertion of an element, we can pretend that we inserted the elements in random order, so that the shape of the resulting tree is that of a random BST no matter in what order we insert the elements. This is the main result of this formalisation.

[Skip_Lists] title = Skip Lists author = Max W. Haslbeck , Manuel Eberl topic = Computer science/Data structures date = 2020-01-09 notify = max.haslbeck@gmx.de abstract =

Skip lists are sorted linked lists enhanced with shortcuts and are an alternative to binary search trees. A skip lists consists of multiple levels of sorted linked lists where a list on level n is a subsequence of the list on level n − 1. In the ideal case, elements are skipped in such a way that a lookup in a skip lists takes O(log n) time. In a randomised skip list the skipped elements are choosen randomly.

This entry contains formalized proofs of the textbook results about the expected height and the expected length of a search path in a randomised skip list.

[Mersenne_Primes] title = Mersenne primes and the Lucas–Lehmer test author = Manuel Eberl topic = Mathematics/Number theory date = 2020-01-17 notify = eberlm@in.tum.de abstract =

This article provides formal proofs of basic properties of Mersenne numbers, i. e. numbers of the form 2n - 1, and especially of Mersenne primes.

In particular, an efficient, verified, and executable version of the Lucas–Lehmer test is developed. This test decides primality for Mersenne numbers in time polynomial in n.

[Hoare_Time] title = Hoare Logics for Time Bounds author = Maximilian P. L. Haslbeck , Tobias Nipkow topic = Computer science/Programming languages/Logics date = 2018-02-26 notify = haslbema@in.tum.de abstract = We study three different Hoare logics for reasoning about time bounds of imperative programs and formalize them in Isabelle/HOL: a classical Hoare like logic due to Nielson, a logic with potentials due to Carbonneaux et al. and a separation logic following work by Atkey, Chaguérand and Pottier. These logics are formally shown to be sound and complete. Verification condition generators are developed and are shown sound and complete too. We also consider variants of the systems where we abstract from multiplicative constants in the running time bounds, thus supporting a big-O style of reasoning. Finally we compare the expressive power of the three systems. [Architectural_Design_Patterns] title = A Theory of Architectural Design Patterns author = Diego Marmsoler topic = Computer science/System description languages date = 2018-03-01 notify = diego.marmsoler@tum.de abstract = The following document formalizes and verifies several architectural design patterns. Each pattern specification is formalized in terms of a locale where the locale assumptions correspond to the assumptions which a pattern poses on an architecture. Thus, pattern specifications may build on top of each other by interpreting the corresponding locale. A pattern is verified using the framework provided by the AFP entry Dynamic Architectures. Currently, the document consists of formalizations of 4 different patterns: the singleton, the publisher subscriber, the blackboard pattern, and the blockchain pattern. Thereby, the publisher component of the publisher subscriber pattern is modeled as an instance of the singleton pattern and the blackboard pattern is modeled as an instance of the publisher subscriber pattern. In general, this entry provides the first steps towards an overall theory of architectural design patterns. extra-history = Change history: [2018-05-25]: changing the major assumption for blockchain architectures from alternative minings to relative mining frequencies (revision 5043c5c71685)
[2019-04-08]: adapting the terminology: honest instead of trusted, dishonest instead of untrusted (revision 7af3431a22ae) [Weight_Balanced_Trees] title = Weight-Balanced Trees author = Tobias Nipkow , Stefan Dirix<> topic = Computer science/Data structures date = 2018-03-13 notify = nipkow@in.tum.de abstract = This theory provides a verified implementation of weight-balanced trees following the work of Hirai and Yamamoto who proved that all parameters in a certain range are valid, i.e. guarantee that insertion and deletion preserve weight-balance. Instead of a general theorem we provide parameterized proofs of preservation of the invariant that work for many (all?) valid parameters. [Fishburn_Impossibility] title = The Incompatibility of Fishburn-Strategyproofness and Pareto-Efficiency author = Felix Brandt , Manuel Eberl , Christian Saile , Christian Stricker topic = Mathematics/Games and economics date = 2018-03-22 notify = eberlm@in.tum.de abstract =

This formalisation contains the proof that there is no anonymous Social Choice Function for at least three agents and alternatives that fulfils both Pareto-Efficiency and Fishburn-Strategyproofness. It was derived from a proof of Brandt et al., which relies on an unverified translation of a fixed finite instance of the original problem to SAT. This Isabelle proof contains a machine-checked version of both the statement for exactly three agents and alternatives and the lifting to the general case.

[BNF_CC] title = Bounded Natural Functors with Covariance and Contravariance author = Andreas Lochbihler , Joshua Schneider topic = Computer science/Functional programming, Tools date = 2018-04-24 notify = mail@andreas-lochbihler.de, joshua.schneider@inf.ethz.ch abstract = Bounded natural functors (BNFs) provide a modular framework for the construction of (co)datatypes in higher-order logic. Their functorial operations, the mapper and relator, are restricted to a subset of the parameters, namely those where recursion can take place. For certain applications, such as free theorems, data refinement, quotients, and generalised rewriting, it is desirable that these operations do not ignore the other parameters. In this article, we formalise the generalisation BNFCC that extends the mapper and relator to covariant and contravariant parameters. We show that
  1. BNFCCs are closed under functor composition and least and greatest fixpoints,
  2. subtypes inherit the BNFCC structure under conditions that generalise those for the BNF case, and
  3. BNFCCs preserve quotients under mild conditions.
These proofs are carried out for abstract BNFCCs similar to the AFP entry BNF Operations. In addition, we apply the BNFCC theory to several concrete functors. [Modular_Assembly_Kit_Security] title = An Isabelle/HOL Formalization of the Modular Assembly Kit for Security Properties author = Oliver Bračevac , Richard Gay , Sylvia Grewe , Heiko Mantel , Henning Sudbrock , Markus Tasch topic = Computer science/Security date = 2018-05-07 notify = tasch@mais.informatik.tu-darmstadt.de abstract = The "Modular Assembly Kit for Security Properties" (MAKS) is a framework for both the definition and verification of possibilistic information-flow security properties at the specification-level. MAKS supports the uniform representation of a wide range of possibilistic information-flow properties and provides support for the verification of such properties via unwinding results and compositionality results. We provide a formalization of this framework in Isabelle/HOL. [AxiomaticCategoryTheory] title = Axiom Systems for Category Theory in Free Logic author = Christoph Benzmüller , Dana Scott topic = Mathematics/Category theory date = 2018-05-23 notify = c.benzmueller@gmail.com abstract = This document provides a concise overview on the core results of our previous work on the exploration of axioms systems for category theory. Extending the previous studies (http://arxiv.org/abs/1609.01493) we include one further axiomatic theory in our experiments. This additional theory has been suggested by Mac Lane in 1948. We show that the axioms proposed by Mac Lane are equivalent to the ones we studied before, which includes an axioms set suggested by Scott in the 1970s and another axioms set proposed by Freyd and Scedrov in 1990, which we slightly modified to remedy a minor technical issue. [OpSets] title = OpSets: Sequential Specifications for Replicated Datatypes author = Martin Kleppmann , Victor B. F. Gomes , Dominic P. Mulligan , Alastair R. Beresford topic = Computer science/Algorithms/Distributed, Computer science/Data structures date = 2018-05-10 notify = vb358@cam.ac.uk abstract = We introduce OpSets, an executable framework for specifying and reasoning about the semantics of replicated datatypes that provide eventual consistency in a distributed system, and for mechanically verifying algorithms that implement these datatypes. Our approach is simple but expressive, allowing us to succinctly specify a variety of abstract datatypes, including maps, sets, lists, text, graphs, trees, and registers. Our datatypes are also composable, enabling the construction of complex data structures. To demonstrate the utility of OpSets for analysing replication algorithms, we highlight an important correctness property for collaborative text editing that has traditionally been overlooked; algorithms that do not satisfy this property can exhibit awkward interleaving of text. We use OpSets to specify this correctness property and prove that although one existing replication algorithm satisfies this property, several other published algorithms do not. [Irrationality_J_Hancl] title = Irrational Rapidly Convergent Series author = Angeliki Koutsoukou-Argyraki , Wenda Li topic = Mathematics/Number theory, Mathematics/Analysis date = 2018-05-23 notify = ak2110@cam.ac.uk, wl302@cam.ac.uk abstract = We formalize with Isabelle/HOL a proof of a theorem by J. Hancl asserting the irrationality of the sum of a series consisting of rational numbers, built up by sequences that fulfill certain properties. Even though the criterion is a number theoretic result, the proof makes use only of analytical arguments. We also formalize a corollary of the theorem for a specific series fulfilling the assumptions of the theorem. [Optimal_BST] title = Optimal Binary Search Trees author = Tobias Nipkow , Dániel Somogyi <> topic = Computer science/Algorithms, Computer science/Data structures date = 2018-05-27 notify = nipkow@in.tum.de abstract = This article formalizes recursive algorithms for the construction of optimal binary search trees given fixed access frequencies. We follow Knuth (1971), Yao (1980) and Mehlhorn (1984). The algorithms are memoized with the help of the AFP article Monadification, Memoization and Dynamic Programming, thus yielding dynamic programming algorithms. [Projective_Geometry] title = Projective Geometry author = Anthony Bordg topic = Mathematics/Geometry date = 2018-06-14 notify = apdb3@cam.ac.uk abstract = We formalize the basics of projective geometry. In particular, we give a proof of the so-called Hessenberg's theorem in projective plane geometry. We also provide a proof of the so-called Desargues's theorem based on an axiomatization of (higher) projective space geometry using the notion of rank of a matroid. This last approach allows to handle incidence relations in an homogeneous way dealing only with points and without the need of talking explicitly about lines, planes or any higher entity. [Localization_Ring] title = The Localization of a Commutative Ring author = Anthony Bordg topic = Mathematics/Algebra date = 2018-06-14 notify = apdb3@cam.ac.uk abstract = We formalize the localization of a commutative ring R with respect to a multiplicative subset (i.e. a submonoid of R seen as a multiplicative monoid). This localization is itself a commutative ring and we build the natural homomorphism of rings from R to its localization. [Minsky_Machines] title = Minsky Machines author = Bertram Felgenhauer<> topic = Logic/Computability date = 2018-08-14 notify = int-e@gmx.de abstract =

We formalize undecidablity results for Minsky machines. To this end, we also formalize recursive inseparability.

We start by proving that Minsky machines can compute arbitrary primitive recursive and recursive functions. We then show that there is a deterministic Minsky machine with one argument and two final states such that the set of inputs that are accepted in one state is recursively inseparable from the set of inputs that are accepted in the other state.

As a corollary, the set of Minsky configurations that reach the first state but not the second recursively inseparable from the set of Minsky configurations that reach the second state but not the first. In particular both these sets are undecidable.

We do not prove that recursive functions can simulate Minsky machines.

[Neumann_Morgenstern_Utility] title = Von-Neumann-Morgenstern Utility Theorem author = Julian Parsert, Cezary Kaliszyk topic = Mathematics/Games and economics license = LGPL date = 2018-07-04 notify = julian.parsert@uibk.ac.at, cezary.kaliszyk@uibk.ac.at abstract = Utility functions form an essential part of game theory and economics. In order to guarantee the existence of utility functions most of the time sufficient properties are assumed in an axiomatic manner. One famous and very common set of such assumptions is that of expected utility theory. Here, the rationality, continuity, and independence of preferences is assumed. The von-Neumann-Morgenstern Utility theorem shows that these assumptions are necessary and sufficient for an expected utility function to exists. This theorem was proven by Neumann and Morgenstern in ``Theory of Games and Economic Behavior'' which is regarded as one of the most influential works in game theory. The formalization includes formal definitions of the underlying concepts including continuity and independence of preferences. [Simplex] title = An Incremental Simplex Algorithm with Unsatisfiable Core Generation author = Filip Marić , Mirko Spasić , René Thiemann topic = Computer science/Algorithms/Optimization date = 2018-08-24 notify = rene.thiemann@uibk.ac.at abstract = We present an Isabelle/HOL formalization and total correctness proof for the incremental version of the Simplex algorithm which is used in most state-of-the-art SMT solvers. It supports extraction of satisfying assignments, extraction of minimal unsatisfiable cores, incremental assertion of constraints and backtracking. The formalization relies on stepwise program refinement, starting from a simple specification, going through a number of refinement steps, and ending up in a fully executable functional implementation. Symmetries present in the algorithm are handled with special care. [Budan_Fourier] title = The Budan-Fourier Theorem and Counting Real Roots with Multiplicity author = Wenda Li topic = Mathematics/Analysis date = 2018-09-02 notify = wl302@cam.ac.uk, liwenda1990@hotmail.com abstract = This entry is mainly about counting and approximating real roots (of a polynomial) with multiplicity. We have first formalised the Budan-Fourier theorem: given a polynomial with real coefficients, we can calculate sign variations on Fourier sequences to over-approximate the number of real roots (counting multiplicity) within an interval. When all roots are known to be real, the over-approximation becomes tight: we can utilise this theorem to count real roots exactly. It is also worth noting that Descartes' rule of sign is a direct consequence of the Budan-Fourier theorem, and has been included in this entry. In addition, we have extended previous formalised Sturm's theorem to count real roots with multiplicity, while the original Sturm's theorem only counts distinct real roots. Compared to the Budan-Fourier theorem, our extended Sturm's theorem always counts roots exactly but may suffer from greater computational cost. [Quaternions] title = Quaternions author = Lawrence C. Paulson topic = Mathematics/Algebra, Mathematics/Geometry date = 2018-09-05 notify = lp15@cam.ac.uk abstract = This theory is inspired by the HOL Light development of quaternions, but follows its own route. Quaternions are developed coinductively, as in the existing formalisation of the complex numbers. Quaternions are quickly shown to belong to the type classes of real normed division algebras and real inner product spaces. And therefore they inherit a great body of facts involving algebraic laws, limits, continuity, etc., which must be proved explicitly in the HOL Light version. The development concludes with the geometric interpretation of the product of imaginary quaternions. [Octonions] title = Octonions author = Angeliki Koutsoukou-Argyraki topic = Mathematics/Algebra, Mathematics/Geometry date = 2018-09-14 notify = ak2110@cam.ac.uk abstract = We develop the basic theory of Octonions, including various identities and properties of the octonions and of the octonionic product, a description of 7D isometries and representations of orthogonal transformations. To this end we first develop the theory of the vector cross product in 7 dimensions. The development of the theory of Octonions is inspired by that of the theory of Quaternions by Lawrence Paulson. However, we do not work within the type class real_algebra_1 because the octonionic product is not associative. [Aggregation_Algebras] title = Aggregation Algebras author = Walter Guttmann topic = Mathematics/Algebra date = 2018-09-15 notify = walter.guttmann@canterbury.ac.nz abstract = We develop algebras for aggregation and minimisation for weight matrices and for edge weights in graphs. We verify the correctness of Prim's and Kruskal's minimum spanning tree algorithms based on these algebras. We also show numerous instances of these algebras based on linearly ordered commutative semigroups. extra-history = Change history: [2020-12-09]: moved Hoare logic to HOL-Hoare, moved spanning trees to Relational_Minimum_Spanning_Trees (revision dbb9bfaf4283) [Prime_Number_Theorem] title = The Prime Number Theorem author = Manuel Eberl , Lawrence C. Paulson topic = Mathematics/Number theory date = 2018-09-19 notify = eberlm@in.tum.de abstract =

This article provides a short proof of the Prime Number Theorem in several equivalent forms, most notably π(x) ~ x/ln x where π(x) is the number of primes no larger than x. It also defines other basic number-theoretic functions related to primes like Chebyshev's functions ϑ and ψ and the “n-th prime number” function pn. We also show various bounds and relationship between these functions are shown. Lastly, we derive Mertens' First and Second Theorem, i. e. ∑px ln p/p = ln x + O(1) and ∑px 1/p = ln ln x + M + O(1/ln x). We also give explicit bounds for the remainder terms.

The proof of the Prime Number Theorem builds on a library of Dirichlet series and analytic combinatorics. We essentially follow the presentation by Newman. The core part of the proof is a Tauberian theorem for Dirichlet series, which is proven using complex analysis and then used to strengthen Mertens' First Theorem to ∑px ln p/p = ln x + c + o(1).

A variant of this proof has been formalised before by Harrison in HOL Light, and formalisations of Selberg's elementary proof exist both by Avigad et al. in Isabelle and by Carneiro in Metamath. The advantage of the analytic proof is that, while it requires more powerful mathematical tools, it is considerably shorter and clearer. This article attempts to provide a short and clear formalisation of all components of that proof using the full range of mathematical machinery available in Isabelle, staying as close as possible to Newman's simple paper proof.

[Signature_Groebner] title = Signature-Based Gröbner Basis Algorithms author = Alexander Maletzky topic = Mathematics/Algebra, Computer science/Algorithms/Mathematical date = 2018-09-20 notify = alexander.maletzky@risc.jku.at abstract =

This article formalizes signature-based algorithms for computing Gröbner bases. Such algorithms are, in general, superior to other algorithms in terms of efficiency, and have not been formalized in any proof assistant so far. The present development is both generic, in the sense that most known variants of signature-based algorithms are covered by it, and effectively executable on concrete input thanks to Isabelle's code generator. Sample computations of benchmark problems show that the verified implementation of signature-based algorithms indeed outperforms the existing implementation of Buchberger's algorithm in Isabelle/HOL.

Besides total correctness of the algorithms, the article also proves that under certain conditions they a-priori detect and avoid all useless zero-reductions, and always return 'minimal' (in some sense) Gröbner bases if an input parameter is chosen in the right way.

The formalization follows the recent survey article by Eder and Faugère.

[Factored_Transition_System_Bounding] title = Upper Bounding Diameters of State Spaces of Factored Transition Systems author = Friedrich Kurz <>, Mohammad Abdulaziz topic = Computer science/Automata and formal languages, Mathematics/Graph theory date = 2018-10-12 notify = friedrich.kurz@tum.de, mohammad.abdulaziz@in.tum.de abstract = A completeness threshold is required to guarantee the completeness of planning as satisfiability, and bounded model checking of safety properties. One valid completeness threshold is the diameter of the underlying transition system. The diameter is the maximum element in the set of lengths of all shortest paths between pairs of states. The diameter is not calculated exactly in our setting, where the transition system is succinctly described using a (propositionally) factored representation. Rather, an upper bound on the diameter is calculated compositionally, by bounding the diameters of small abstract subsystems, and then composing those. We port a HOL4 formalisation of a compositional algorithm for computing a relatively tight upper bound on the system diameter. This compositional algorithm exploits acyclicity in the state space to achieve compositionality, and it was introduced by Abdulaziz et. al. The formalisation that we port is described as a part of another paper by Abdulaziz et. al. As a part of this porting we developed a libray about transition systems, which shall be of use in future related mechanisation efforts. [Smooth_Manifolds] title = Smooth Manifolds author = Fabian Immler , Bohua Zhan topic = Mathematics/Analysis, Mathematics/Topology date = 2018-10-22 notify = immler@in.tum.de, bzhan@ios.ac.cn abstract = We formalize the definition and basic properties of smooth manifolds in Isabelle/HOL. Concepts covered include partition of unity, tangent and cotangent spaces, and the fundamental theorem of path integrals. We also examine some concrete manifolds such as spheres and projective spaces. The formalization makes extensive use of the analysis and linear algebra libraries in Isabelle/HOL, in particular its “types-to-sets” mechanism. [Matroids] title = Matroids author = Jonas Keinholz<> topic = Mathematics/Combinatorics date = 2018-11-16 notify = eberlm@in.tum.de abstract =

This article defines the combinatorial structures known as Independence Systems and Matroids and provides basic concepts and theorems related to them. These structures play an important role in combinatorial optimisation, e. g. greedy algorithms such as Kruskal's algorithm. The development is based on Oxley's `What is a Matroid?'.

[Graph_Saturation] title = Graph Saturation author = Sebastiaan J. C. Joosten<> topic = Logic/Rewriting, Mathematics/Graph theory date = 2018-11-23 notify = sjcjoosten@gmail.com abstract = This is an Isabelle/HOL formalisation of graph saturation, closely following a paper by the author on graph saturation. Nine out of ten lemmas of the original paper are proven in this formalisation. The formalisation additionally includes two theorems that show the main premise of the paper: that consistency and entailment are decided through graph saturation. This formalisation does not give executable code, and it did not implement any of the optimisations suggested in the paper. [Functional_Ordered_Resolution_Prover] title = A Verified Functional Implementation of Bachmair and Ganzinger's Ordered Resolution Prover author = Anders Schlichtkrull , Jasmin Christian Blanchette , Dmitriy Traytel topic = Logic/General logic/Mechanization of proofs date = 2018-11-23 notify = andschl@dtu.dk,j.c.blanchette@vu.nl,traytel@inf.ethz.ch abstract = This Isabelle/HOL formalization refines the abstract ordered resolution prover presented in Section 4.3 of Bachmair and Ganzinger's "Resolution Theorem Proving" chapter in the Handbook of Automated Reasoning. The result is a functional implementation of a first-order prover. [Auto2_HOL] title = Auto2 Prover author = Bohua Zhan topic = Tools date = 2018-11-20 notify = bzhan@ios.ac.cn abstract = Auto2 is a saturation-based heuristic prover for higher-order logic, implemented as a tactic in Isabelle. This entry contains the instantiation of auto2 for Isabelle/HOL, along with two basic examples: solutions to some of the Pelletier’s problems, and elementary number theory of primes. [Order_Lattice_Props] title = Properties of Orderings and Lattices author = Georg Struth topic = Mathematics/Order date = 2018-12-11 notify = g.struth@sheffield.ac.uk abstract = These components add further fundamental order and lattice-theoretic concepts and properties to Isabelle's libraries. They follow by and large the introductory sections of the Compendium of Continuous Lattices, covering directed and filtered sets, down-closed and up-closed sets, ideals and filters, Galois connections, closure and co-closure operators. Some emphasis is on duality and morphisms between structures, as in the Compendium. To this end, three ad-hoc approaches to duality are compared. [Quantales] title = Quantales author = Georg Struth topic = Mathematics/Algebra date = 2018-12-11 notify = g.struth@sheffield.ac.uk abstract = These mathematical components formalise basic properties of quantales, together with some important models, constructions, and concepts, including quantic nuclei and conuclei. [Transformer_Semantics] title = Transformer Semantics author = Georg Struth topic = Mathematics/Algebra, Computer science/Semantics date = 2018-12-11 notify = g.struth@sheffield.ac.uk abstract = These mathematical components formalise predicate transformer semantics for programs, yet currently only for partial correctness and in the absence of faults. A first part for isotone (or monotone), Sup-preserving and Inf-preserving transformers follows Back and von Wright's approach, with additional emphasis on the quantalic structure of algebras of transformers. The second part develops Sup-preserving and Inf-preserving predicate transformers from the powerset monad, via its Kleisli category and Eilenberg-Moore algebras, with emphasis on adjunctions and dualities, as well as isomorphisms between relations, state transformers and predicate transformers. [Concurrent_Revisions] title = Formalization of Concurrent Revisions author = Roy Overbeek topic = Computer science/Concurrency date = 2018-12-25 notify = Roy.Overbeek@cwi.nl abstract = Concurrent revisions is a concurrency control model developed by Microsoft Research. It has many interesting properties that distinguish it from other well-known models such as transactional memory. One of these properties is determinacy: programs written within the model always produce the same outcome, independent of scheduling activity. The concurrent revisions model has an operational semantics, with an informal proof of determinacy. This document contains an Isabelle/HOL formalization of this semantics and the proof of determinacy. [Core_DOM] title = A Formal Model of the Document Object Model author = Achim D. Brucker , Michael Herzberg topic = Computer science/Data structures date = 2018-12-26 notify = adbrucker@0x5f.org abstract = In this AFP entry, we formalize the core of the Document Object Model (DOM). At its core, the DOM defines a tree-like data structure for representing documents in general and HTML documents in particular. It is the heart of any modern web browser. Formalizing the key concepts of the DOM is a prerequisite for the formal reasoning over client-side JavaScript programs and for the analysis of security concepts in modern web browsers. We present a formalization of the core DOM, with focus on the node-tree and the operations defined on node-trees, in Isabelle/HOL. We use the formalization to verify the functional correctness of the most important functions defined in the DOM standard. Moreover, our formalization is 1) extensible, i.e., can be extended without the need of re-proving already proven properties and 2) executable, i.e., we can generate executable code from our specification. [Core_SC_DOM] title = The Safely Composable DOM author = Achim D. Brucker , Michael Herzberg topic = Computer science/Data structures date = 2020-09-28 notify = adbrucker@0x5f.org, mail@michael-herzberg.de abstract = In this AFP entry, we formalize the core of the Safely Composable Document Object Model (SC DOM). The SC DOM improve the standard DOM (as formalized in the AFP entry "Core DOM") by strengthening the tree boundaries set by shadow roots: in the SC DOM, the shadow root is a sub-class of the document class (instead of a base class). This modifications also results in changes to some API methods (e.g., getOwnerDocument) to return the nearest shadow root rather than the document root. As a result, many API methods that, when called on a node inside a shadow tree, would previously ``break out'' and return or modify nodes that are possibly outside the shadow tree, now stay within its boundaries. This change in behavior makes programs that operate on shadow trees more predictable for the developer and allows them to make more assumptions about other code accessing the DOM. [Shadow_SC_DOM] title = A Formal Model of the Safely Composable Document Object Model with Shadow Roots author = Achim D. Brucker , Michael Herzberg topic = Computer science/Data structures date = 2020-09-28 notify = adbrucker@0x5f.org, mail@michael-herzberg.de abstract = In this AFP entry, we extend our formalization of the safely composable DOM with Shadow Roots. This is a proposal for Shadow Roots with stricter safety guarantess than the standard compliant formalization (see "Shadow DOM"). Shadow Roots are a recent proposal of the web community to support a component-based development approach for client-side web applications. Shadow roots are a significant extension to the DOM standard and, as web standards are condemned to be backward compatible, such extensions often result in complex specification that may contain unwanted subtleties that can be detected by a formalization. Our Isabelle/HOL formalization is, in the sense of object-orientation, an extension of our formalization of the core DOM and enjoys the same basic properties, i.e., it is extensible, i.e., can be extended without the need of re-proving already proven properties and executable, i.e., we can generate executable code from our specification. We exploit the executability to show that our formalization complies to the official standard of the W3C, respectively, the WHATWG. [SC_DOM_Components] title = A Formalization of Safely Composable Web Components author = Achim D. Brucker , Michael Herzberg topic = Computer science/Data structures date = 2020-09-28 notify = adbrucker@0x5f.org, mail@michael-herzberg.de abstract = While the (safely composable) DOM with shadow trees provide the technical basis for defining web components, it does neither defines the concept of web components nor specifies the safety properties that web components should guarantee. Consequently, the standard also does not discuss how or even if the methods for modifying the DOM respect component boundaries. In AFP entry, we present a formally verified model of safely composable web components and define safety properties which ensure that different web components can only interact with each other using well-defined interfaces. Moreover, our verification of the application programming interface (API) of the DOM revealed numerous invariants that implementations of the DOM API need to preserve to ensure the integrity of components. In comparison to the strict standard compliance formalization of Web Components in the AFP entry "DOM_Components", the notion of components in this entry (based on "SC_DOM" and "Shadow_SC_DOM") provides much stronger safety guarantees. [Store_Buffer_Reduction] title = A Reduction Theorem for Store Buffers author = Ernie Cohen , Norbert Schirmer topic = Computer science/Concurrency date = 2019-01-07 notify = norbert.schirmer@web.de abstract = When verifying a concurrent program, it is usual to assume that memory is sequentially consistent. However, most modern multiprocessors depend on store buffering for efficiency, and provide native sequential consistency only at a substantial performance penalty. To regain sequential consistency, a programmer has to follow an appropriate programming discipline. However, naïve disciplines, such as protecting all shared accesses with locks, are not flexible enough for building high-performance multiprocessor software. We present a new discipline for concurrent programming under TSO (total store order, with store buffer forwarding). It does not depend on concurrency primitives, such as locks. Instead, threads use ghost operations to acquire and release ownership of memory addresses. A thread can write to an address only if no other thread owns it, and can read from an address only if it owns it or it is shared and the thread has flushed its store buffer since it last wrote to an address it did not own. This discipline covers both coarse-grained concurrency (where data is protected by locks) as well as fine-grained concurrency (where atomic operations race to memory). We formalize this discipline in Isabelle/HOL, and prove that if every execution of a program in a system without store buffers follows the discipline, then every execution of the program with store buffers is sequentially consistent. Thus, we can show sequential consistency under TSO by ordinary assertional reasoning about the program, without having to consider store buffers at all. [IMP2] title = IMP2 – Simple Program Verification in Isabelle/HOL author = Peter Lammich , Simon Wimmer topic = Computer science/Programming languages/Logics, Computer science/Algorithms date = 2019-01-15 notify = lammich@in.tum.de abstract = IMP2 is a simple imperative language together with Isabelle tooling to create a program verification environment in Isabelle/HOL. The tools include a C-like syntax, a verification condition generator, and Isabelle commands for the specification of programs. The framework is modular, i.e., it allows easy reuse of already proved programs within larger programs. This entry comes with a quickstart guide and a large collection of examples, spanning basic algorithms with simple proofs to more advanced algorithms and proof techniques like data refinement. Some highlights from the examples are:
  • Bisection Square Root,
  • Extended Euclid,
  • Exponentiation by Squaring,
  • Binary Search,
  • Insertion Sort,
  • Quicksort,
  • Depth First Search.
The abstract syntax and semantics are very simple and well-documented. They are suitable to be used in a course, as extension to the IMP language which comes with the Isabelle distribution. While this entry is limited to a simple imperative language, the ideas could be extended to more sophisticated languages. [Farkas] title = Farkas' Lemma and Motzkin's Transposition Theorem author = Ralph Bottesch , Max W. Haslbeck , René Thiemann topic = Mathematics/Algebra date = 2019-01-17 notify = rene.thiemann@uibk.ac.at abstract = We formalize a proof of Motzkin's transposition theorem and Farkas' lemma in Isabelle/HOL. Our proof is based on the formalization of the simplex algorithm which, given a set of linear constraints, either returns a satisfying assignment to the problem or detects unsatisfiability. By reusing facts about the simplex algorithm we show that a set of linear constraints is unsatisfiable if and only if there is a linear combination of the constraints which evaluates to a trivially unsatisfiable inequality. [Auto2_Imperative_HOL] title = Verifying Imperative Programs using Auto2 author = Bohua Zhan topic = Computer science/Algorithms, Computer science/Data structures date = 2018-12-21 notify = bzhan@ios.ac.cn abstract = This entry contains the application of auto2 to verifying functional and imperative programs. Algorithms and data structures that are verified include linked lists, binary search trees, red-black trees, interval trees, priority queue, quicksort, union-find, Dijkstra's algorithm, and a sweep-line algorithm for detecting rectangle intersection. The imperative verification is based on Imperative HOL and its separation logic framework. A major goal of this work is to set up automation in order to reduce the length of proof that the user needs to provide, both for verifying functional programs and for working with separation logic. [UTP] title = Isabelle/UTP: Mechanised Theory Engineering for Unifying Theories of Programming author = Simon Foster , Frank Zeyda<>, Yakoub Nemouchi , Pedro Ribeiro<>, Burkhart Wolff topic = Computer science/Programming languages/Logics date = 2019-02-01 notify = simon.foster@york.ac.uk abstract = Isabelle/UTP is a mechanised theory engineering toolkit based on Hoare and He’s Unifying Theories of Programming (UTP). UTP enables the creation of denotational, algebraic, and operational semantics for different programming languages using an alphabetised relational calculus. We provide a semantic embedding of the alphabetised relational calculus in Isabelle/HOL, including new type definitions, relational constructors, automated proof tactics, and accompanying algebraic laws. Isabelle/UTP can be used to both capture laws of programming for different languages, and put these fundamental theorems to work in the creation of associated verification tools, using calculi like Hoare logics. This document describes the relational core of the UTP in Isabelle/HOL. [HOL-CSP] title = HOL-CSP Version 2.0 author = Safouan Taha , Lina Ye , Burkhart Wolff topic = Computer science/Concurrency/Process calculi, Computer science/Semantics date = 2019-04-26 notify = wolff@lri.fr abstract = This is a complete formalization of the work of Hoare and Roscoe on the denotational semantics of the Failure/Divergence Model of CSP. It follows essentially the presentation of CSP in Roscoe’s Book ”Theory and Practice of Concurrency” [8] and the semantic details in a joint Paper of Roscoe and Brooks ”An improved failures model for communicating processes". The present work is based on a prior formalization attempt, called HOL-CSP 1.0, done in 1997 by H. Tej and B. Wolff with the Isabelle proof technology available at that time. This work revealed minor, but omnipresent foundational errors in key concepts like the process invariant. The present version HOL-CSP profits from substantially improved libraries (notably HOLCF), improved automated proof techniques, and structured proof techniques in Isar and is substantially shorter but more complete. [Probabilistic_Prime_Tests] title = Probabilistic Primality Testing author = Daniel Stüwe<>, Manuel Eberl topic = Mathematics/Number theory date = 2019-02-11 notify = eberlm@in.tum.de abstract =

The most efficient known primality tests are probabilistic in the sense that they use randomness and may, with some probability, mistakenly classify a composite number as prime – but never a prime number as composite. Examples of this are the Miller–Rabin test, the Solovay–Strassen test, and (in most cases) Fermat's test.

This entry defines these three tests and proves their correctness. It also develops some of the number-theoretic foundations, such as Carmichael numbers and the Jacobi symbol with an efficient executable algorithm to compute it.

[Kruskal] title = Kruskal's Algorithm for Minimum Spanning Forest author = Maximilian P.L. Haslbeck , Peter Lammich , Julian Biendarra<> topic = Computer science/Algorithms/Graph date = 2019-02-14 notify = haslbema@in.tum.de, lammich@in.tum.de abstract = This Isabelle/HOL formalization defines a greedy algorithm for finding a minimum weight basis on a weighted matroid and proves its correctness. This algorithm is an abstract version of Kruskal's algorithm. We interpret the abstract algorithm for the cycle matroid (i.e. forests in a graph) and refine it to imperative executable code using an efficient union-find data structure. Our formalization can be instantiated for different graph representations. We provide instantiations for undirected graphs and symmetric directed graphs. [List_Inversions] title = The Inversions of a List author = Manuel Eberl topic = Computer science/Algorithms date = 2019-02-01 notify = eberlm@in.tum.de abstract =

This entry defines the set of inversions of a list, i.e. the pairs of indices that violate sortedness. It also proves the correctness of the well-known O(n log n) divide-and-conquer algorithm to compute the number of inversions.

[Prime_Distribution_Elementary] title = Elementary Facts About the Distribution of Primes author = Manuel Eberl topic = Mathematics/Number theory date = 2019-02-21 notify = eberlm@in.tum.de abstract =

This entry is a formalisation of Chapter 4 (and parts of Chapter 3) of Apostol's Introduction to Analytic Number Theory. The main topics that are addressed are properties of the distribution of prime numbers that can be shown in an elementary way (i. e. without the Prime Number Theorem), the various equivalent forms of the PNT (which imply each other in elementary ways), and consequences that follow from the PNT in elementary ways. The latter include, most notably, asymptotic bounds for the number of distinct prime factors of n, the divisor function d(n), Euler's totient function φ(n), and lcm(1,…,n).

[Safe_OCL] title = Safe OCL author = Denis Nikiforov <> topic = Computer science/Programming languages/Language definitions license = LGPL date = 2019-03-09 notify = denis.nikif@gmail.com abstract =

The theory is a formalization of the OCL type system, its abstract syntax and expression typing rules. The theory does not define a concrete syntax and a semantics. In contrast to Featherweight OCL, it is based on a deep embedding approach. The type system is defined from scratch, it is not based on the Isabelle HOL type system.

The Safe OCL distincts nullable and non-nullable types. Also the theory gives a formal definition of safe navigation operations. The Safe OCL typing rules are much stricter than rules given in the OCL specification. It allows one to catch more errors on a type checking phase.

The type theory presented is four-layered: classes, basic types, generic types, errorable types. We introduce the following new types: non-nullable types (T[1]), nullable types (T[?]), OclSuper. OclSuper is a supertype of all other types (basic types, collections, tuples). This type allows us to define a total supremum function, so types form an upper semilattice. It allows us to define rich expression typing rules in an elegant manner.

The Preliminaries Chapter of the theory defines a number of helper lemmas for transitive closures and tuples. It defines also a generic object model independent from OCL. It allows one to use the theory as a reference for formalization of analogous languages.

[QHLProver] title = Quantum Hoare Logic author = Junyi Liu<>, Bohua Zhan , Shuling Wang<>, Shenggang Ying<>, Tao Liu<>, Yangjia Li<>, Mingsheng Ying<>, Naijun Zhan<> topic = Computer science/Programming languages/Logics, Computer science/Semantics date = 2019-03-24 notify = bzhan@ios.ac.cn abstract = We formalize quantum Hoare logic as given in [1]. In particular, we specify the syntax and denotational semantics of a simple model of quantum programs. Then, we write down the rules of quantum Hoare logic for partial correctness, and show the soundness and completeness of the resulting proof system. As an application, we verify the correctness of Grover’s algorithm. [Transcendence_Series_Hancl_Rucki] title = The Transcendence of Certain Infinite Series author = Angeliki Koutsoukou-Argyraki , Wenda Li topic = Mathematics/Analysis, Mathematics/Number theory date = 2019-03-27 notify = wl302@cam.ac.uk, ak2110@cam.ac.uk abstract = We formalize the proofs of two transcendence criteria by J. Hančl and P. Rucki that assert the transcendence of the sums of certain infinite series built up by sequences that fulfil certain properties. Both proofs make use of Roth's celebrated theorem on diophantine approximations to algebraic numbers from 1955 which we implement as an assumption without having formalised its proof. [Binding_Syntax_Theory] title = A General Theory of Syntax with Bindings author = Lorenzo Gheri , Andrei Popescu topic = Computer science/Programming languages/Lambda calculi, Computer science/Functional programming, Logic/General logic/Mechanization of proofs date = 2019-04-06 notify = a.popescu@mdx.ac.uk, lor.gheri@gmail.com abstract = We formalize a theory of syntax with bindings that has been developed and refined over the last decade to support several large formalization efforts. Terms are defined for an arbitrary number of constructors of varying numbers of inputs, quotiented to alpha-equivalence and sorted according to a binding signature. The theory includes many properties of the standard operators on terms: substitution, swapping and freshness. It also includes bindings-aware induction and recursion principles and support for semantic interpretation. This work has been presented in the ITP 2017 paper “A Formalized General Theory of Syntax with Bindings”. [LTL_Master_Theorem] title = A Compositional and Unified Translation of LTL into ω-Automata author = Benedikt Seidl , Salomon Sickert topic = Computer science/Automata and formal languages date = 2019-04-16 notify = benedikt.seidl@tum.de, s.sickert@tum.de abstract = We present a formalisation of the unified translation approach of linear temporal logic (LTL) into ω-automata from [1]. This approach decomposes LTL formulas into ``simple'' languages and allows a clear separation of concerns: first, we formalise the purely logical result yielding this decomposition; second, we instantiate this generic theory to obtain a construction for deterministic (state-based) Rabin automata (DRA). We extract from this particular instantiation an executable tool translating LTL to DRAs. To the best of our knowledge this is the first verified translation from LTL to DRAs that is proven to be double exponential in the worst case which asymptotically matches the known lower bound.

[1] Javier Esparza, Jan Kretínský, Salomon Sickert. One Theorem to Rule Them All: A Unified Translation of LTL into ω-Automata. LICS 2018 [LambdaAuth] title = Formalization of Generic Authenticated Data Structures author = Matthias Brun<>, Dmitriy Traytel topic = Computer science/Security, Computer science/Programming languages/Lambda calculi date = 2019-05-14 notify = traytel@inf.ethz.ch abstract = Authenticated data structures are a technique for outsourcing data storage and maintenance to an untrusted server. The server is required to produce an efficiently checkable and cryptographically secure proof that it carried out precisely the requested computation. Miller et al. introduced λ• (pronounced lambda auth)—a functional programming language with a built-in primitive authentication construct, which supports a wide range of user-specified authenticated data structures while guaranteeing certain correctness and security properties for all well-typed programs. We formalize λ• and prove its correctness and security properties. With Isabelle's help, we uncover and repair several mistakes in the informal proofs and lemma statements. Our findings are summarized in an ITP'19 paper. [IMP2_Binary_Heap] title = Binary Heaps for IMP2 author = Simon Griebel<> topic = Computer science/Data structures, Computer science/Algorithms date = 2019-06-13 notify = s.griebel@tum.de abstract = In this submission array-based binary minimum heaps are formalized. The correctness of the following heap operations is proved: insert, get-min, delete-min and make-heap. These are then used to verify an in-place heapsort. The formalization is based on IMP2, an imperative program verification framework implemented in Isabelle/HOL. The verified heap functions are iterative versions of the partly recursive functions found in "Algorithms and Data Structures – The Basic Toolbox" by K. Mehlhorn and P. Sanders and "Introduction to Algorithms" by T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein. [Groebner_Macaulay] title = Gröbner Bases, Macaulay Matrices and Dubé's Degree Bounds author = Alexander Maletzky topic = Mathematics/Algebra date = 2019-06-15 notify = alexander.maletzky@risc.jku.at abstract = This entry formalizes the connection between Gröbner bases and Macaulay matrices (sometimes also referred to as `generalized Sylvester matrices'). In particular, it contains a method for computing Gröbner bases, which proceeds by first constructing some Macaulay matrix of the initial set of polynomials, then row-reducing this matrix, and finally converting the result back into a set of polynomials. The output is shown to be a Gröbner basis if the Macaulay matrix constructed in the first step is sufficiently large. In order to obtain concrete upper bounds on the size of the matrix (and hence turn the method into an effectively executable algorithm), Dubé's degree bounds on Gröbner bases are utilized; consequently, they are also part of the formalization. [Linear_Inequalities] title = Linear Inequalities author = Ralph Bottesch , Alban Reynaud <>, René Thiemann topic = Mathematics/Algebra date = 2019-06-21 notify = rene.thiemann@uibk.ac.at abstract = We formalize results about linear inqualities, mainly from Schrijver's book. The main results are the proof of the fundamental theorem on linear inequalities, Farkas' lemma, Carathéodory's theorem, the Farkas-Minkowsky-Weyl theorem, the decomposition theorem of polyhedra, and Meyer's result that the integer hull of a polyhedron is a polyhedron itself. Several theorems include bounds on the appearing numbers, and in particular we provide an a-priori bound on mixed-integer solutions of linear inequalities. [Linear_Programming] title = Linear Programming author = Julian Parsert , Cezary Kaliszyk topic = Mathematics/Algebra date = 2019-08-06 notify = julian.parsert@gmail.com, cezary.kaliszyk@uibk.ac.at abstract = We use the previous formalization of the general simplex algorithm to formulate an algorithm for solving linear programs. We encode the linear programs using only linear constraints. Solving these constraints also solves the original linear program. This algorithm is proven to be sound by applying the weak duality theorem which is also part of this formalization. [Differential_Game_Logic] title = Differential Game Logic author = André Platzer topic = Computer science/Programming languages/Logics date = 2019-06-03 notify = aplatzer@cs.cmu.edu abstract = This formalization provides differential game logic (dGL), a logic for proving properties of hybrid game. In addition to the syntax and semantics, it formalizes a uniform substitution calculus for dGL. Church's uniform substitutions substitute a term or formula for a function or predicate symbol everywhere. The uniform substitutions for dGL also substitute hybrid games for a game symbol everywhere. We prove soundness of one-pass uniform substitutions and the axioms of differential game logic with respect to their denotational semantics. One-pass uniform substitutions are faster by postponing soundness-critical admissibility checks with a linear pass homomorphic application and regain soundness by a variable condition at the replacements. The formalization is based on prior non-mechanized soundness proofs for dGL. [BenOr_Kozen_Reif] title = The BKR Decision Procedure for Univariate Real Arithmetic author = Katherine Cordwell , Yong Kiam Tan , André Platzer topic = Computer science/Algorithms/Mathematical date = 2021-04-24 notify = kcordwel@cs.cmu.edu, yongkiat@cs.cmu.edu, aplatzer@cs.cmu.edu abstract = We formalize the univariate case of Ben-Or, Kozen, and Reif's decision procedure for first-order real arithmetic (the BKR algorithm). We also formalize the univariate case of Renegar's variation of the BKR algorithm. The two formalizations differ mathematically in minor ways (that have significant impact on the multivariate case), but are quite similar in proof structure. Both rely on sign-determination (finding the set of consistent sign assignments for a set of polynomials). The method used for sign-determination is similar to Tarski's original quantifier elimination algorithm (it stores key information in a matrix equation), but with a reduction step to keep complexity low. [Complete_Non_Orders] title = Complete Non-Orders and Fixed Points author = Akihisa Yamada , Jérémy Dubut topic = Mathematics/Order date = 2019-06-27 notify = akihisayamada@nii.ac.jp, dubut@nii.ac.jp abstract = We develop an Isabelle/HOL library of order-theoretic concepts, such as various completeness conditions and fixed-point theorems. We keep our formalization as general as possible: we reprove several well-known results about complete orders, often without any properties of ordering, thus complete non-orders. In particular, we generalize the Knaster–Tarski theorem so that we ensure the existence of a quasi-fixed point of monotone maps over complete non-orders, and show that the set of quasi-fixed points is complete under a mild condition—attractivity—which is implied by either antisymmetry or transitivity. This result generalizes and strengthens a result by Stauti and Maaden. Finally, we recover Kleene’s fixed-point theorem for omega-complete non-orders, again using attractivity to prove that Kleene’s fixed points are least quasi-fixed points. [Priority_Search_Trees] title = Priority Search Trees author = Peter Lammich , Tobias Nipkow topic = Computer science/Data structures date = 2019-06-25 notify = lammich@in.tum.de abstract = We present a new, purely functional, simple and efficient data structure combining a search tree and a priority queue, which we call a priority search tree. The salient feature of priority search trees is that they offer a decrease-key operation, something that is missing from other simple, purely functional priority queue implementations. Priority search trees can be implemented on top of any search tree. This entry does the implementation for red-black trees. This entry formalizes the first part of our ITP-2019 proof pearl Purely Functional, Simple and Efficient Priority Search Trees and Applications to Prim and Dijkstra. [Prim_Dijkstra_Simple] title = Purely Functional, Simple, and Efficient Implementation of Prim and Dijkstra author = Peter Lammich , Tobias Nipkow topic = Computer science/Algorithms/Graph date = 2019-06-25 notify = lammich@in.tum.de abstract = We verify purely functional, simple and efficient implementations of Prim's and Dijkstra's algorithms. This constitutes the first verification of an executable and even efficient version of Prim's algorithm. This entry formalizes the second part of our ITP-2019 proof pearl Purely Functional, Simple and Efficient Priority Search Trees and Applications to Prim and Dijkstra. [MFOTL_Monitor] title = Formalization of a Monitoring Algorithm for Metric First-Order Temporal Logic author = Joshua Schneider , Dmitriy Traytel topic = Computer science/Algorithms, Logic/General logic/Temporal logic, Computer science/Automata and formal languages date = 2019-07-04 notify = joshua.schneider@inf.ethz.ch, traytel@inf.ethz.ch abstract = A monitor is a runtime verification tool that solves the following problem: Given a stream of time-stamped events and a policy formulated in a specification language, decide whether the policy is satisfied at every point in the stream. We verify the correctness of an executable monitor for specifications given as formulas in metric first-order temporal logic (MFOTL), an expressive extension of linear temporal logic with real-time constraints and first-order quantification. The verified monitor implements a simplified variant of the algorithm used in the efficient MonPoly monitoring tool. The formalization is presented in a RV 2019 paper, which also compares the output of the verified monitor to that of other monitoring tools on randomly generated inputs. This case study revealed several errors in the optimized but unverified tools. extra-history = Change history: [2020-08-13]: added the formalization of the abstract slicing framework and joint data slicer (revision b1639ed541b7)
[FOL_Seq_Calc1] title = A Sequent Calculus for First-Order Logic author = Asta Halkjær From contributors = Alexander Birch Jensen , Anders Schlichtkrull , Jørgen Villadsen topic = Logic/Proof theory date = 2019-07-18 notify = ahfrom@dtu.dk abstract = This work formalizes soundness and completeness of a one-sided sequent calculus for first-order logic. The completeness is shown via a translation from a complete semantic tableau calculus, the proof of which is based on the First-Order Logic According to Fitting theory. The calculi and proof techniques are taken from Ben-Ari's Mathematical Logic for Computer Science. [Szpilrajn] title = Order Extension and Szpilrajn's Extension Theorem author = Peter Zeller , Lukas Stevens topic = Mathematics/Order date = 2019-07-27 notify = p_zeller@cs.uni-kl.de abstract = This entry is concerned with the principle of order extension, i.e. the extension of an order relation to a total order relation. To this end, we prove a more general version of Szpilrajn's extension theorem employing terminology from the book "Consistency, Choice, and Rationality" by Bossert and Suzumura. We also formalize theorem 2.7 of their book. extra-history = Change history: [2021-03-22]: (by Lukas Stevens) generalise Szpilrajn's extension theorem and add material from the book "Consistency, Choice, and Rationality" [TESL_Language] title = A Formal Development of a Polychronous Polytimed Coordination Language author = Hai Nguyen Van , Frédéric Boulanger , Burkhart Wolff topic = Computer science/System description languages, Computer science/Semantics, Computer science/Concurrency date = 2019-07-30 notify = frederic.boulanger@centralesupelec.fr, burkhart.wolff@lri.fr abstract = The design of complex systems involves different formalisms for modeling their different parts or aspects. The global model of a system may therefore consist of a coordination of concurrent sub-models that use different paradigms. We develop here a theory for a language used to specify the timed coordination of such heterogeneous subsystems by addressing the following issues:

  • the behavior of the sub-systems is observed only at a series of discrete instants,
  • events may occur in different sub-systems at unrelated times, leading to polychronous systems, which do not necessarily have a common base clock,
  • coordination between subsystems involves causality, so the occurrence of an event may enforce the occurrence of other events, possibly after a certain duration has elapsed or an event has occurred a given number of times,
  • the domain of time (discrete, rational, continuous...) may be different in the subsystems, leading to polytimed systems,
  • the time frames of different sub-systems may be related (for instance, time in a GPS satellite and in a GPS receiver on Earth are related although they are not the same).
Firstly, a denotational semantics of the language is defined. Then, in order to be able to incrementally check the behavior of systems, an operational semantics is given, with proofs of progress, soundness and completeness with regard to the denotational semantics. These proofs are made according to a setup that can scale up when new operators are added to the language. In order for specifications to be composed in a clean way, the language should be invariant by stuttering (i.e., adding observation instants at which nothing happens). The proof of this invariance is also given. [Stellar_Quorums] title = Stellar Quorum Systems author = Giuliano Losa topic = Computer science/Algorithms/Distributed date = 2019-08-01 notify = giuliano@galois.com abstract = We formalize the static properties of personal Byzantine quorum systems (PBQSs) and Stellar quorum systems, as described in the paper ``Stellar Consensus by Reduction'' (to appear at DISC 2019). [IMO2019] title = Selected Problems from the International Mathematical Olympiad 2019 author = Manuel Eberl topic = Mathematics/Misc date = 2019-08-05 notify = eberlm@in.tum.de abstract =

This entry contains formalisations of the answers to three of the six problem of the International Mathematical Olympiad 2019, namely Q1, Q4, and Q5.

The reason why these problems were chosen is that they are particularly amenable to formalisation: they can be solved with minimal use of libraries. The remaining three concern geometry and graph theory, which, in the author's opinion, are more difficult to formalise resp. require a more complex library.

[Adaptive_State_Counting] title = Formalisation of an Adaptive State Counting Algorithm author = Robert Sachtleben topic = Computer science/Automata and formal languages, Computer science/Algorithms date = 2019-08-16 notify = rob_sac@uni-bremen.de abstract = This entry provides a formalisation of a refinement of an adaptive state counting algorithm, used to test for reduction between finite state machines. The algorithm has been originally presented by Hierons in the paper Testing from a Non-Deterministic Finite State Machine Using Adaptive State Counting. Definitions for finite state machines and adaptive test cases are given and many useful theorems are derived from these. The algorithm is formalised using mutually recursive functions, for which it is proven that the generated test suite is sufficient to test for reduction against finite state machines of a certain fault domain. Additionally, the algorithm is specified in a simple WHILE-language and its correctness is shown using Hoare-logic. [Jacobson_Basic_Algebra] title = A Case Study in Basic Algebra author = Clemens Ballarin topic = Mathematics/Algebra date = 2019-08-30 notify = ballarin@in.tum.de abstract = The focus of this case study is re-use in abstract algebra. It contains locale-based formalisations of selected parts of set, group and ring theory from Jacobson's Basic Algebra leading to the respective fundamental homomorphism theorems. The study is not intended as a library base for abstract algebra. It rather explores an approach towards abstract algebra in Isabelle. [Hybrid_Systems_VCs] title = Verification Components for Hybrid Systems author = Jonathan Julian Huerta y Munive <> topic = Mathematics/Algebra, Mathematics/Analysis date = 2019-09-10 notify = jjhuertaymunive1@sheffield.ac.uk, jonjulian23@gmail.com abstract = These components formalise a semantic framework for the deductive verification of hybrid systems. They support reasoning about continuous evolutions of hybrid programs in the style of differential dynamics logic. Vector fields or flows model these evolutions, and their verification is done with invariants for the former or orbits for the latter. Laws of modal Kleene algebra or categorical predicate transformers implement the verification condition generation. Examples show the approach at work. extra-history = Change history: [2020-12-13]: added components based on Kleene algebras with tests. These implement differential Hoare logic (dH) and a Morgan-style differential refinement calculus (dR) for verification of hybrid programs. [Generic_Join] title = Formalization of Multiway-Join Algorithms author = Thibault Dardinier<> topic = Computer science/Algorithms date = 2019-09-16 notify = tdardini@student.ethz.ch, traytel@inf.ethz.ch abstract = Worst-case optimal multiway-join algorithms are recent seminal achievement of the database community. These algorithms compute the natural join of multiple relational databases and improve in the worst case over traditional query plan optimizations of nested binary joins. In 2014, Ngo, Ré, and Rudra gave a unified presentation of different multi-way join algorithms. We formalized and proved correct their "Generic Join" algorithm and extended it to support negative joins. [Aristotles_Assertoric_Syllogistic] title = Aristotle's Assertoric Syllogistic author = Angeliki Koutsoukou-Argyraki topic = Logic/Philosophical aspects date = 2019-10-08 notify = ak2110@cam.ac.uk abstract = We formalise with Isabelle/HOL some basic elements of Aristotle's assertoric syllogistic following the article from the Stanford Encyclopedia of Philosophy by Robin Smith. To this end, we use a set theoretic formulation (covering both individual and general predication). In particular, we formalise the deductions in the Figures and after that we present Aristotle's metatheoretical observation that all deductions in the Figures can in fact be reduced to either Barbara or Celarent. As the formal proofs prove to be straightforward, the interest of this entry lies in illustrating the functionality of Isabelle and high efficiency of Sledgehammer for simple exercises in philosophy. [VerifyThis2019] title = VerifyThis 2019 -- Polished Isabelle Solutions author = Peter Lammich<>, Simon Wimmer topic = Computer science/Algorithms date = 2019-10-16 notify = lammich@in.tum.de, wimmers@in.tum.de abstract = VerifyThis 2019 (http://www.pm.inf.ethz.ch/research/verifythis.html) was a program verification competition associated with ETAPS 2019. It was the 8th event in the VerifyThis competition series. In this entry, we present polished and completed versions of our solutions that we created during the competition. [ZFC_in_HOL] title = Zermelo Fraenkel Set Theory in Higher-Order Logic author = Lawrence C. Paulson topic = Logic/Set theory date = 2019-10-24 notify = lp15@cam.ac.uk abstract =

This entry is a new formalisation of ZFC set theory in Isabelle/HOL. It is logically equivalent to Obua's HOLZF; the point is to have the closest possible integration with the rest of Isabelle/HOL, minimising the amount of new notations and exploiting type classes.

There is a type V of sets and a function elts :: V => V set mapping a set to its elements. Classes simply have type V set, and a predicate identifies the small classes: those that correspond to actual sets. Type classes connected with orders and lattices are used to minimise the amount of new notation for concepts such as the subset relation, union and intersection. Basic concepts — Cartesian products, disjoint sums, natural numbers, functions, etc. — are formalised.

More advanced set-theoretic concepts, such as transfinite induction, ordinals, cardinals and the transitive closure of a set, are also provided. The definition of addition and multiplication for general sets (not just ordinals) follows Kirby.

The theory provides two type classes with the aim of facilitating developments that combine V with other Isabelle/HOL types: embeddable, the class of types that can be injected into V (including V itself as well as V*V, etc.), and small, the class of types that correspond to some ZF set.

extra-history = Change history: [2020-01-28]: Generalisation of the "small" predicate and order types to arbitrary sets; ordinal exponentiation; introduction of the coercion ord_of_nat :: "nat => V"; numerous new lemmas. (revision 6081d5be8d08) [Interval_Arithmetic_Word32] title = Interval Arithmetic on 32-bit Words author = Brandon Bohrer topic = Computer science/Data structures date = 2019-11-27 notify = bjbohrer@gmail.com, bbohrer@cs.cmu.edu abstract = Interval_Arithmetic implements conservative interval arithmetic computations, then uses this interval arithmetic to implement a simple programming language where all terms have 32-bit signed word values, with explicit infinities for terms outside the representable bounds. Our target use case is interpreters for languages that must have a well-understood low-level behavior. We include a formalization of bounded-length strings which are used for the identifiers of our language. Bounded-length identifiers are useful in some applications, for example the Differential_Dynamic_Logic article, where a Euclidean space indexed by identifiers demands that identifiers are finitely many. [Generalized_Counting_Sort] title = An Efficient Generalization of Counting Sort for Large, possibly Infinite Key Ranges author = Pasquale Noce topic = Computer science/Algorithms, Computer science/Functional programming date = 2019-12-04 notify = pasquale.noce.lavoro@gmail.com abstract = Counting sort is a well-known algorithm that sorts objects of any kind mapped to integer keys, or else to keys in one-to-one correspondence with some subset of the integers (e.g. alphabet letters). However, it is suitable for direct use, viz. not just as a subroutine of another sorting algorithm (e.g. radix sort), only if the key range is not significantly larger than the number of the objects to be sorted. This paper describes a tail-recursive generalization of counting sort making use of a bounded number of counters, suitable for direct use in case of a large, or even infinite key range of any kind, subject to the only constraint of being a subset of an arbitrary linear order. After performing a pen-and-paper analysis of how such algorithm has to be designed to maximize its efficiency, this paper formalizes the resulting generalized counting sort (GCsort) algorithm and then formally proves its correctness properties, namely that (a) the counters' number is maximized never exceeding the fixed upper bound, (b) objects are conserved, (c) objects get sorted, and (d) the algorithm is stable. [Poincare_Bendixson] title = The Poincaré-Bendixson Theorem author = Fabian Immler , Yong Kiam Tan topic = Mathematics/Analysis date = 2019-12-18 notify = fimmler@cs.cmu.edu, yongkiat@cs.cmu.edu abstract = The Poincaré-Bendixson theorem is a classical result in the study of (continuous) dynamical systems. Colloquially, it restricts the possible behaviors of planar dynamical systems: such systems cannot be chaotic. In practice, it is a useful tool for proving the existence of (limiting) periodic behavior in planar systems. The theorem is an interesting and challenging benchmark for formalized mathematics because proofs in the literature rely on geometric sketches and only hint at symmetric cases. It also requires a substantial background of mathematical theories, e.g., the Jordan curve theorem, real analysis, ordinary differential equations, and limiting (long-term) behavior of dynamical systems. [Isabelle_C] title = Isabelle/C author = Frédéric Tuong , Burkhart Wolff topic = Computer science/Programming languages/Language definitions, Computer science/Semantics, Tools date = 2019-10-22 notify = tuong@users.gforge.inria.fr, wolff@lri.fr abstract = We present a framework for C code in C11 syntax deeply integrated into the Isabelle/PIDE development environment. Our framework provides an abstract interface for verification back-ends to be plugged-in independently. Thus, various techniques such as deductive program verification or white-box testing can be applied to the same source, which is part of an integrated PIDE document model. Semantic back-ends are free to choose the supported C fragment and its semantics. In particular, they can differ on the chosen memory model or the specification mechanism for framing conditions. Our framework supports semantic annotations of C sources in the form of comments. Annotations serve to locally control back-end settings, and can express the term focus to which an annotation refers. Both the logical and the syntactic context are available when semantic annotations are evaluated. As a consequence, a formula in an annotation can refer both to HOL or C variables. Our approach demonstrates the degree of maturity and expressive power the Isabelle/PIDE sub-system has achieved in recent years. Our integration technique employs Lex and Yacc style grammars to ensure efficient deterministic parsing. This is the core-module of Isabelle/C; the AFP package for Clean and Clean_wrapper as well as AutoCorres and AutoCorres_wrapper (available via git) are applications of this front-end. [Zeta_3_Irrational] title = The Irrationality of ζ(3) author = Manuel Eberl topic = Mathematics/Number theory date = 2019-12-27 notify = manuel.eberl@tum.de abstract =

This article provides a formalisation of Beukers's straightforward analytic proof that ζ(3) is irrational. This was first proven by Apéry (which is why this result is also often called ‘Apéry's Theorem’) using a more algebraic approach. This formalisation follows Filaseta's presentation of Beukers's proof.

[Hybrid_Logic] title = Formalizing a Seligman-Style Tableau System for Hybrid Logic author = Asta Halkjær From topic = Logic/General logic/Modal logic date = 2019-12-20 notify = ahfrom@dtu.dk abstract = This work is a formalization of soundness and completeness proofs for a Seligman-style tableau system for hybrid logic. The completeness result is obtained via a synthetic approach using maximally consistent sets of tableau blocks. The formalization differs from previous work in a few ways. First, to avoid the need to backtrack in the construction of a tableau, the formalized system has no unnamed initial segment, and therefore no Name rule. Second, I show that the full Bridge rule is admissible in the system. Third, I start from rules restricted to only extend the branch with new formulas, including only witnessing diamonds that are not already witnessed, and show that the unrestricted rules are admissible. Similarly, I start from simpler versions of the @-rules and show that these are sufficient. The GoTo rule is restricted using a notion of potential such that each application consumes potential and potential is earned through applications of the remaining rules. I show that if a branch can be closed then it can be closed starting from a single unit. Finally, Nom is restricted by a fixed set of allowed nominals. The resulting system should be terminating. extra-history = Change history: [2020-06-03]: The fully restricted system has been shown complete by updating the synthetic completeness proof. [Bicategory] title = Bicategories author = Eugene W. Stark topic = Mathematics/Category theory date = 2020-01-06 notify = stark@cs.stonybrook.edu abstract =

Taking as a starting point the author's previous work on developing aspects of category theory in Isabelle/HOL, this article gives a compatible formalization of the notion of "bicategory" and develops a framework within which formal proofs of facts about bicategories can be given. The framework includes a number of basic results, including the Coherence Theorem, the Strictness Theorem, pseudofunctors and biequivalence, and facts about internal equivalences and adjunctions in a bicategory. As a driving application and demonstration of the utility of the framework, it is used to give a formal proof of a theorem, due to Carboni, Kasangian, and Street, that characterizes up to biequivalence the bicategories of spans in a category with pullbacks. The formalization effort necessitated the filling-in of many details that were not evident from the brief presentation in the original paper, as well as identifying a few minor corrections along the way.

Revisions made subsequent to the first version of this article added additional material on pseudofunctors, pseudonatural transformations, modifications, and equivalence of bicategories; the main thrust being to give a proof that a pseudofunctor is a biequivalence if and only if it can be extended to an equivalence of bicategories.

extra-history = Change history: [2020-02-15]: Move ConcreteCategory.thy from Bicategory to Category3 and use it systematically. Make other minor improvements throughout. (revision a51840d36867)
[2020-11-04]: Added new material on equivalence of bicategories, with associated changes. (revision 472cb2268826)
[Subset_Boolean_Algebras] title = A Hierarchy of Algebras for Boolean Subsets author = Walter Guttmann , Bernhard Möller topic = Mathematics/Algebra date = 2020-01-31 notify = walter.guttmann@canterbury.ac.nz abstract = We present a collection of axiom systems for the construction of Boolean subalgebras of larger overall algebras. The subalgebras are defined as the range of a complement-like operation on a semilattice. This technique has been used, for example, with the antidomain operation, dynamic negation and Stone algebras. We present a common ground for these constructions based on a new equational axiomatisation of Boolean algebras. [Goodstein_Lambda] title = Implementing the Goodstein Function in λ-Calculus author = Bertram Felgenhauer topic = Logic/Rewriting date = 2020-02-21 notify = int-e@gmx.de abstract = In this formalization, we develop an implementation of the Goodstein function G in plain λ-calculus, linked to a concise, self-contained specification. The implementation works on a Church-encoded representation of countable ordinals. The initial conversion to hereditary base 2 is not covered, but the material is sufficient to compute the particular value G(16), and easily extends to other fixed arguments. [VeriComp] title = A Generic Framework for Verified Compilers author = Martin Desharnais topic = Computer science/Programming languages/Compiling date = 2020-02-10 notify = martin.desharnais@unibw.de abstract = This is a generic framework for formalizing compiler transformations. It leverages Isabelle/HOL’s locales to abstract over concrete languages and transformations. It states common definitions for language semantics, program behaviours, forward and backward simulations, and compilers. We provide generic operations, such as simulation and compiler composition, and prove general (partial) correctness theorems, resulting in reusable proof components. [Hello_World] title = Hello World author = Cornelius Diekmann , Lars Hupel topic = Computer science/Functional programming date = 2020-03-07 notify = diekmann@net.in.tum.de abstract = In this article, we present a formalization of the well-known "Hello, World!" code, including a formal framework for reasoning about IO. Our model is inspired by the handling of IO in Haskell. We start by formalizing the 🌍 and embrace the IO monad afterwards. Then we present a sample main :: IO (), followed by its proof of correctness. [WOOT_Strong_Eventual_Consistency] title = Strong Eventual Consistency of the Collaborative Editing Framework WOOT author = Emin Karayel , Edgar Gonzàlez topic = Computer science/Algorithms/Distributed date = 2020-03-25 notify = eminkarayel@google.com, edgargip@google.com, me@eminkarayel.de abstract = Commutative Replicated Data Types (CRDTs) are a promising new class of data structures for large-scale shared mutable content in applications that only require eventual consistency. The WithOut Operational Transforms (WOOT) framework is a CRDT for collaborative text editing introduced by Oster et al. (CSCW 2006) for which the eventual consistency property was verified only for a bounded model to date. We contribute a formal proof for WOOTs strong eventual consistency. [Furstenberg_Topology] title = Furstenberg's topology and his proof of the infinitude of primes author = Manuel Eberl topic = Mathematics/Number theory date = 2020-03-22 notify = manuel.eberl@tum.de abstract =

This article gives a formal version of Furstenberg's topological proof of the infinitude of primes. He defines a topology on the integers based on arithmetic progressions (or, equivalently, residue classes). Using some fairly obvious properties of this topology, the infinitude of primes is then easily obtained.

Apart from this, this topology is also fairly ‘nice’ in general: it is second countable, metrizable, and perfect. All of these (well-known) facts are formally proven, including an explicit metric for the topology given by Zulfeqarr.

[Saturation_Framework] title = A Comprehensive Framework for Saturation Theorem Proving author = Sophie Tourret topic = Logic/General logic/Mechanization of proofs date = 2020-04-09 notify = stourret@mpi-inf.mpg.de abstract = This Isabelle/HOL formalization is the companion of the technical report “A comprehensive framework for saturation theorem proving”, itself companion of the eponym IJCAR 2020 paper, written by Uwe Waldmann, Sophie Tourret, Simon Robillard and Jasmin Blanchette. It verifies a framework for formal refutational completeness proofs of abstract provers that implement saturation calculi, such as ordered resolution or superposition, and allows to model entire prover architectures in such a way that the static refutational completeness of a calculus immediately implies the dynamic refutational completeness of a prover implementing the calculus using a variant of the given clause loop. The technical report “A comprehensive framework for saturation theorem proving” is available on the Matryoshka website. The names of the Isabelle lemmas and theorems corresponding to the results in the report are indicated in the margin of the report. [Saturation_Framework_Extensions] title = Extensions to the Comprehensive Framework for Saturation Theorem Proving author = Jasmin Blanchette , Sophie Tourret topic = Logic/General logic/Mechanization of proofs date = 2020-08-25 notify = jasmin.blanchette@gmail.com abstract = This Isabelle/HOL formalization extends the AFP entry Saturation_Framework with the following contributions:
  • an application of the framework to prove Bachmair and Ganzinger's resolution prover RP refutationally complete, which was formalized in a more ad hoc fashion by Schlichtkrull et al. in the AFP entry Ordered_Resultion_Prover;
  • generalizations of various basic concepts formalized by Schlichtkrull et al., which were needed to verify RP and could be useful to formalize other calculi, such as superposition;
  • alternative proofs of fairness (and hence saturation and ultimately refutational completeness) for the given clause procedures GC and LGC, based on invariance.
[MFODL_Monitor_Optimized] title = Formalization of an Optimized Monitoring Algorithm for Metric First-Order Dynamic Logic with Aggregations author = Thibault Dardinier<>, Lukas Heimes<>, Martin Raszyk , Joshua Schneider , Dmitriy Traytel topic = Computer science/Algorithms, Logic/General logic/Modal logic, Computer science/Automata and formal languages date = 2020-04-09 notify = martin.raszyk@inf.ethz.ch, joshua.schneider@inf.ethz.ch, traytel@inf.ethz.ch abstract = A monitor is a runtime verification tool that solves the following problem: Given a stream of time-stamped events and a policy formulated in a specification language, decide whether the policy is satisfied at every point in the stream. We verify the correctness of an executable monitor for specifications given as formulas in metric first-order dynamic logic (MFODL), which combines the features of metric first-order temporal logic (MFOTL) and metric dynamic logic. Thus, MFODL supports real-time constraints, first-order parameters, and regular expressions. Additionally, the monitor supports aggregation operations such as count and sum. This formalization, which is described in a forthcoming paper at IJCAR 2020, significantly extends previous work on a verified monitor for MFOTL. Apart from the addition of regular expressions and aggregations, we implemented multi-way joins and a specialized sliding window algorithm to further optimize the monitor. [Sliding_Window_Algorithm] title = Formalization of an Algorithm for Greedily Computing Associative Aggregations on Sliding Windows author = Lukas Heimes<>, Dmitriy Traytel , Joshua Schneider<> topic = Computer science/Algorithms date = 2020-04-10 notify = heimesl@student.ethz.ch, traytel@inf.ethz.ch, joshua.schneider@inf.ethz.ch abstract = Basin et al.'s sliding window algorithm (SWA) is an algorithm for combining the elements of subsequences of a sequence with an associative operator. It is greedy and minimizes the number of operator applications. We formalize the algorithm and verify its functional correctness. We extend the algorithm with additional operations and provide an alternative interface to the slide operation that does not require the entire input sequence. [Lucas_Theorem] title = Lucas's Theorem author = Chelsea Edmonds topic = Mathematics/Number theory date = 2020-04-07 notify = cle47@cam.ac.uk abstract = This work presents a formalisation of a generating function proof for Lucas's theorem. We first outline extensions to the existing Formal Power Series (FPS) library, including an equivalence relation for coefficients modulo n, an alternate binomial theorem statement, and a formalised proof of the Freshman's dream (mod p) lemma. The second part of the work presents the formal proof of Lucas's Theorem. Working backwards, the formalisation first proves a well known corollary of the theorem which is easier to formalise, and then applies induction to prove the original theorem statement. The proof of the corollary aims to provide a good example of a formalised generating function equivalence proof using the FPS library. The final theorem statement is intended to be integrated into the formalised proof of Hilbert's 10th Problem. [ADS_Functor] title = Authenticated Data Structures As Functors author = Andreas Lochbihler , Ognjen Marić topic = Computer science/Data structures date = 2020-04-16 notify = andreas.lochbihler@digitalasset.com, mail@andreas-lochbihler.de abstract = Authenticated data structures allow several systems to convince each other that they are referring to the same data structure, even if each of them knows only a part of the data structure. Using inclusion proofs, knowledgeable systems can selectively share their knowledge with other systems and the latter can verify the authenticity of what is being shared. In this article, we show how to modularly define authenticated data structures, their inclusion proofs, and operations thereon as datatypes in Isabelle/HOL, using a shallow embedding. Modularity allows us to construct complicated trees from reusable building blocks, which we call Merkle functors. Merkle functors include sums, products, and function spaces and are closed under composition and least fixpoints. As a practical application, we model the hierarchical transactions of Canton, a practical interoperability protocol for distributed ledgers, as authenticated data structures. This is a first step towards formalizing the Canton protocol and verifying its integrity and security guarantees. [Power_Sum_Polynomials] title = Power Sum Polynomials author = Manuel Eberl topic = Mathematics/Algebra date = 2020-04-24 notify = eberlm@in.tum.de abstract =

This article provides a formalisation of the symmetric multivariate polynomials known as power sum polynomials. These are of the form pn(X1,…, Xk) = X1n + … + Xkn. A formal proof of the Girard–Newton Theorem is also given. This theorem relates the power sum polynomials to the elementary symmetric polynomials sk in the form of a recurrence relation (-1)k k sk = ∑i∈[0,k) (-1)i si pk-i .

As an application, this is then used to solve a generalised form of a puzzle given as an exercise in Dummit and Foote's Abstract Algebra: For k complex unknowns x1, …, xk, define pj := x1j + … + xkj. Then for each vector a ∈ ℂk, show that there is exactly one solution to the system p1 = a1, …, pk = ak up to permutation of the xi and determine the value of pi for i>k.

[Formal_Puiseux_Series] title = Formal Puiseux Series author = Manuel Eberl topic = Mathematics/Algebra date = 2021-02-17 notify = eberlm@in.tum.de abstract =

Formal Puiseux series are generalisations of formal power series and formal Laurent series that also allow for fractional exponents. They have the following general form: \[\sum_{i=N}^\infty a_{i/d} X^{i/d}\] where N is an integer and d is a positive integer.

This entry defines these series including their basic algebraic properties. Furthermore, it proves the Newton–Puiseux Theorem, namely that the Puiseux series over an algebraically closed field of characteristic 0 are also algebraically closed.

[Gaussian_Integers] title = Gaussian Integers author = Manuel Eberl topic = Mathematics/Number theory date = 2020-04-24 notify = eberlm@in.tum.de abstract =

The Gaussian integers are the subring ℤ[i] of the complex numbers, i. e. the ring of all complex numbers with integral real and imaginary part. This article provides a definition of this ring as well as proofs of various basic properties, such as that they form a Euclidean ring and a full classification of their primes. An executable (albeit not very efficient) factorisation algorithm is also provided.

Lastly, this Gaussian integer formalisation is used in two short applications:

  1. The characterisation of all positive integers that can be written as sums of two squares
  2. Euclid's formula for primitive Pythagorean triples

While elementary proofs for both of these are already available in the AFP, the theory of Gaussian integers provides more concise proofs and a more high-level view.

[Forcing] title = Formalization of Forcing in Isabelle/ZF author = Emmanuel Gunther , Miguel Pagano , Pedro Sánchez Terraf topic = Logic/Set theory date = 2020-05-06 notify = gunther@famaf.unc.edu.ar, pagano@famaf.unc.edu.ar, sterraf@famaf.unc.edu.ar abstract = We formalize the theory of forcing in the set theory framework of Isabelle/ZF. Under the assumption of the existence of a countable transitive model of ZFC, we construct a proper generic extension and show that the latter also satisfies ZFC. [Delta_System_Lemma] title = Cofinality and the Delta System Lemma author = Pedro Sánchez Terraf topic = Mathematics/Combinatorics, Logic/Set theory date = 2020-12-27 notify = sterraf@famaf.unc.edu.ar abstract = We formalize the basic results on cofinality of linearly ordered sets and ordinals and Šanin’s Lemma for uncountable families of finite sets. This last result is used to prove the countable chain condition for Cohen posets. We work in the set theory framework of Isabelle/ZF, using the Axiom of Choice as needed. [Recursion-Addition] title = Recursion Theorem in ZF author = Georgy Dunaev topic = Logic/Set theory date = 2020-05-11 notify = georgedunaev@gmail.com abstract = This document contains a proof of the recursion theorem. This is a mechanization of the proof of the recursion theorem from the text Introduction to Set Theory, by Karel Hrbacek and Thomas Jech. This implementation may be used as the basis for a model of Peano arithmetic in ZF. While recursion and the natural numbers are already available in Isabelle/ZF, this clean development is much easier to follow. [LTL_Normal_Form] title = An Efficient Normalisation Procedure for Linear Temporal Logic: Isabelle/HOL Formalisation author = Salomon Sickert topic = Computer science/Automata and formal languages, Logic/General logic/Temporal logic date = 2020-05-08 notify = s.sickert@tum.de abstract = In the mid 80s, Lichtenstein, Pnueli, and Zuck proved a classical theorem stating that every formula of Past LTL (the extension of LTL with past operators) is equivalent to a formula of the form $\bigwedge_{i=1}^n \mathbf{G}\mathbf{F} \varphi_i \vee \mathbf{F}\mathbf{G} \psi_i$, where $\varphi_i$ and $\psi_i$ contain only past operators. Some years later, Chang, Manna, and Pnueli built on this result to derive a similar normal form for LTL. Both normalisation procedures have a non-elementary worst-case blow-up, and follow an involved path from formulas to counter-free automata to star-free regular expressions and back to formulas. We improve on both points. We present an executable formalisation of a direct and purely syntactic normalisation procedure for LTL yielding a normal form, comparable to the one by Chang, Manna, and Pnueli, that has only a single exponential blow-up. [Matrices_for_ODEs] title = Matrices for ODEs author = Jonathan Julian Huerta y Munive topic = Mathematics/Analysis, Mathematics/Algebra date = 2020-04-19 notify = jonjulian23@gmail.com abstract = Our theories formalise various matrix properties that serve to establish existence, uniqueness and characterisation of the solution to affine systems of ordinary differential equations (ODEs). In particular, we formalise the operator and maximum norm of matrices. Then we use them to prove that square matrices form a Banach space, and in this setting, we show an instance of Picard-Lindelöf’s theorem for affine systems of ODEs. Finally, we use this formalisation to verify three simple hybrid programs. [Irrational_Series_Erdos_Straus] title = Irrationality Criteria for Series by Erdős and Straus author = Angeliki Koutsoukou-Argyraki , Wenda Li topic = Mathematics/Number theory, Mathematics/Analysis date = 2020-05-12 notify = ak2110@cam.ac.uk, wl302@cam.ac.uk, liwenda1990@hotmail.com abstract = We formalise certain irrationality criteria for infinite series of the form: \[\sum_{n=1}^\infty \frac{b_n}{\prod_{i=1}^n a_i} \] where $\{b_n\}$ is a sequence of integers and $\{a_n\}$ a sequence of positive integers with $a_n >1$ for all large n. The results are due to P. Erdős and E. G. Straus [1]. In particular, we formalise Theorem 2.1, Corollary 2.10 and Theorem 3.1. The latter is an application of Theorem 2.1 involving the prime numbers. [Knuth_Bendix_Order] title = A Formalization of Knuth–Bendix Orders author = Christian Sternagel , René Thiemann topic = Logic/Rewriting date = 2020-05-13 notify = c.sternagel@gmail.com, rene.thiemann@uibk.ac.at abstract = We define a generalized version of Knuth–Bendix orders, including subterm coefficient functions. For these orders we formalize several properties such as strong normalization, the subterm property, closure properties under substitutions and contexts, as well as ground totality. [Stateful_Protocol_Composition_and_Typing] title = Stateful Protocol Composition and Typing author = Andreas V. Hess , Sebastian Mödersheim , Achim D. Brucker topic = Computer science/Security date = 2020-04-08 notify = avhe@dtu.dk, andreasvhess@gmail.com, samo@dtu.dk, brucker@spamfence.net, andschl@dtu.dk abstract = We provide in this AFP entry several relative soundness results for security protocols. In particular, we prove typing and compositionality results for stateful protocols (i.e., protocols with mutable state that may span several sessions), and that focuses on reachability properties. Such results are useful to simplify protocol verification by reducing it to a simpler problem: Typing results give conditions under which it is safe to verify a protocol in a typed model where only "well-typed" attacks can occur whereas compositionality results allow us to verify a composed protocol by only verifying the component protocols in isolation. The conditions on the protocols under which the results hold are furthermore syntactic in nature allowing for full automation. The foundation presented here is used in another entry to provide fully automated and formalized security proofs of stateful protocols. [Automated_Stateful_Protocol_Verification] title = Automated Stateful Protocol Verification author = Andreas V. Hess , Sebastian Mödersheim , Achim D. Brucker , Anders Schlichtkrull topic = Computer science/Security, Tools date = 2020-04-08 notify = avhe@dtu.dk, andreasvhess@gmail.com, samo@dtu.dk, brucker@spamfence.net, andschl@dtu.dk abstract = In protocol verification we observe a wide spectrum from fully automated methods to interactive theorem proving with proof assistants like Isabelle/HOL. In this AFP entry, we present a fully-automated approach for verifying stateful security protocols, i.e., protocols with mutable state that may span several sessions. The approach supports reachability goals like secrecy and authentication. We also include a simple user-friendly transaction-based protocol specification language that is embedded into Isabelle. [Smith_Normal_Form] title = A verified algorithm for computing the Smith normal form of a matrix author = Jose Divasón topic = Mathematics/Algebra, Computer science/Algorithms/Mathematical date = 2020-05-23 notify = jose.divason@unirioja.es abstract = This work presents a formal proof in Isabelle/HOL of an algorithm to transform a matrix into its Smith normal form, a canonical matrix form, in a general setting: the algorithm is parameterized by operations to prove its existence over elementary divisor rings, while execution is guaranteed over Euclidean domains. We also provide a formal proof on some results about the generality of this algorithm as well as the uniqueness of the Smith normal form. Since Isabelle/HOL does not feature dependent types, the development is carried out switching conveniently between two different existing libraries: the Hermite normal form (based on HOL Analysis) and the Jordan normal form AFP entries. This permits to reuse results from both developments and it is done by means of the lifting and transfer package together with the use of local type definitions. [Nash_Williams] title = The Nash-Williams Partition Theorem author = Lawrence C. Paulson topic = Mathematics/Combinatorics date = 2020-05-16 notify = lp15@cam.ac.uk abstract = In 1965, Nash-Williams discovered a generalisation of the infinite form of Ramsey's theorem. Where the latter concerns infinite sets of n-element sets for some fixed n, the Nash-Williams theorem concerns infinite sets of finite sets (or lists) subject to a “no initial segment” condition. The present formalisation follows a monograph on Ramsey Spaces by Todorčević. [Safe_Distance] title = A Formally Verified Checker of the Safe Distance Traffic Rules for Autonomous Vehicles author = Albert Rizaldi , Fabian Immler topic = Computer science/Algorithms/Mathematical, Mathematics/Physics date = 2020-06-01 notify = albert.rizaldi@ntu.edu.sg, fimmler@andrew.cmu.edu, martin.rau@tum.de abstract = The Vienna Convention on Road Traffic defines the safe distance traffic rules informally. This could make autonomous vehicle liable for safe-distance-related accidents because there is no clear definition of how large a safe distance is. We provide a formally proven prescriptive definition of a safe distance, and checkers which can decide whether an autonomous vehicle is obeying the safe distance rule. Not only does our work apply to the domain of law, but it also serves as a specification for autonomous vehicle manufacturers and for online verification of path planners. [Relational_Paths] title = Relational Characterisations of Paths author = Walter Guttmann , Peter Höfner topic = Mathematics/Graph theory date = 2020-07-13 notify = walter.guttmann@canterbury.ac.nz, peter@hoefner-online.de abstract = Binary relations are one of the standard ways to encode, characterise and reason about graphs. Relation algebras provide equational axioms for a large fragment of the calculus of binary relations. Although relations are standard tools in many areas of mathematics and computing, researchers usually fall back to point-wise reasoning when it comes to arguments about paths in a graph. We present a purely algebraic way to specify different kinds of paths in Kleene relation algebras, which are relation algebras equipped with an operation for reflexive transitive closure. We study the relationship between paths with a designated root vertex and paths without such a vertex. Since we stay in first-order logic this development helps with mechanising proofs. To demonstrate the applicability of the algebraic framework we verify the correctness of three basic graph algorithms. [Amicable_Numbers] title = Amicable Numbers author = Angeliki Koutsoukou-Argyraki topic = Mathematics/Number theory date = 2020-08-04 notify = ak2110@cam.ac.uk abstract = This is a formalisation of Amicable Numbers, involving some relevant material including Euler's sigma function, some relevant definitions, results and examples as well as rules such as Thābit ibn Qurra's Rule, Euler's Rule, te Riele's Rule and Borho's Rule with breeders. [Ordinal_Partitions] title = Ordinal Partitions author = Lawrence C. Paulson topic = Mathematics/Combinatorics, Logic/Set theory date = 2020-08-03 notify = lp15@cam.ac.uk abstract = The theory of partition relations concerns generalisations of Ramsey's theorem. For any ordinal $\alpha$, write $\alpha \to (\alpha, m)^2$ if for each function $f$ from unordered pairs of elements of $\alpha$ into $\{0,1\}$, either there is a subset $X\subseteq \alpha$ order-isomorphic to $\alpha$ such that $f\{x,y\}=0$ for all $\{x,y\}\subseteq X$, or there is an $m$ element set $Y\subseteq \alpha$ such that $f\{x,y\}=1$ for all $\{x,y\}\subseteq Y$. (In both cases, with $\{x,y\}$ we require $x\not=y$.) In particular, the infinite Ramsey theorem can be written in this notation as $\omega \to (\omega, \omega)^2$, or if we restrict $m$ to the positive integers as above, then $\omega \to (\omega, m)^2$ for all $m$. This entry formalises Larson's proof of $\omega^\omega \to (\omega^\omega, m)^2$ along with a similar proof of a result due to Specker: $\omega^2 \to (\omega^2, m)^2$. Also proved is a necessary result by Erdős and Milner: $\omega^{1+\alpha\cdot n} \to (\omega^{1+\alpha}, 2^n)^2$. [Relational_Disjoint_Set_Forests] title = Relational Disjoint-Set Forests author = Walter Guttmann topic = Computer science/Data structures date = 2020-08-26 notify = walter.guttmann@canterbury.ac.nz abstract = We give a simple relation-algebraic semantics of read and write operations on associative arrays. The array operations seamlessly integrate with assignments in the Hoare-logic library. Using relation algebras and Kleene algebras we verify the correctness of an array-based implementation of disjoint-set forests with a naive union operation and a find operation with path compression. extra-history = Change history: [2021-06-19]: added path halving, path splitting, relational Peano structures, union by rank (revision 98c7aa03457d) [PAC_Checker] title = Practical Algebraic Calculus Checker author = Mathias Fleury , Daniela Kaufmann topic = Computer science/Algorithms date = 2020-08-31 notify = mathias.fleury@jku.at abstract = Generating and checking proof certificates is important to increase the trust in automated reasoning tools. In recent years formal verification using computer algebra became more important and is heavily used in automated circuit verification. An existing proof format which covers algebraic reasoning and allows efficient proof checking is the practical algebraic calculus (PAC). In this development, we present the verified checker Pastèque that is obtained by synthesis via the Refinement Framework. This is the formalization going with our FMCAD'20 tool presentation. [BirdKMP] title = Putting the `K' into Bird's derivation of Knuth-Morris-Pratt string matching author = Peter Gammie topic = Computer science/Functional programming date = 2020-08-25 notify = peteg42@gmail.com abstract = Richard Bird and collaborators have proposed a derivation of an intricate cyclic program that implements the Morris-Pratt string matching algorithm. Here we provide a proof of total correctness for Bird's derivation and complete it by adding Knuth's optimisation. [Extended_Finite_State_Machines] title = A Formal Model of Extended Finite State Machines author = Michael Foster , Achim D. Brucker , Ramsay G. Taylor , John Derrick topic = Computer science/Automata and formal languages date = 2020-09-07 notify = jmafoster1@sheffield.ac.uk, adbrucker@0x5f.org abstract = In this AFP entry, we provide a formalisation of extended finite state machines (EFSMs) where models are represented as finite sets of transitions between states. EFSMs execute traces to produce observable outputs. We also define various simulation and equality metrics for EFSMs in terms of traces and prove their strengths in relation to each other. Another key contribution is a framework of function definitions such that LTL properties can be phrased over EFSMs. Finally, we provide a simple example case study in the form of a drinks machine. [Extended_Finite_State_Machine_Inference] title = Inference of Extended Finite State Machines author = Michael Foster , Achim D. Brucker , Ramsay G. Taylor , John Derrick topic = Computer science/Automata and formal languages date = 2020-09-07 notify = jmafoster1@sheffield.ac.uk, adbrucker@0x5f.org abstract = In this AFP entry, we provide a formal implementation of a state-merging technique to infer extended finite state machines (EFSMs), complete with output and update functions, from black-box traces. In particular, we define the subsumption in context relation as a means of determining whether one transition is able to account for the behaviour of another. Building on this, we define the direct subsumption relation, which lifts the subsumption in context relation to EFSM level such that we can use it to determine whether it is safe to merge a given pair of transitions. Key proofs include the conditions necessary for subsumption to occur and that subsumption and direct subsumption are preorder relations. We also provide a number of different heuristics which can be used to abstract away concrete values into registers so that more states and transitions can be merged and provide proofs of the various conditions which must hold for these abstractions to subsume their ungeneralised counterparts. A Code Generator setup to create executable Scala code is also defined. [Physical_Quantities] title = A Sound Type System for Physical Quantities, Units, and Measurements author = Simon Foster , Burkhart Wolff topic = Mathematics/Physics, Computer science/Programming languages/Type systems date = 2020-10-20 notify = simon.foster@york.ac.uk, wolff@lri.fr abstract = The present Isabelle theory builds a formal model for both the International System of Quantities (ISQ) and the International System of Units (SI), which are both fundamental for physics and engineering. Both the ISQ and the SI are deeply integrated into Isabelle's type system. Quantities are parameterised by dimension types, which correspond to base vectors, and thus only quantities of the same dimension can be equated. Since the underlying "algebra of quantities" induces congruences on quantity and SI types, specific tactic support is developed to capture these. Our construction is validated by a test-set of known equivalences between both quantities and SI units. Moreover, the presented theory can be used for type-safe conversions between the SI system and others, like the British Imperial System (BIS). [Shadow_DOM] title = A Formal Model of the Document Object Model with Shadow Roots author = Achim D. Brucker , Michael Herzberg topic = Computer science/Data structures date = 2020-09-28 notify = adbrucker@0x5f.org, mail@michael-herzberg.de abstract = In this AFP entry, we extend our formalization of the core DOM with Shadow Roots. Shadow roots are a recent proposal of the web community to support a component-based development approach for client-side web applications. Shadow roots are a significant extension to the DOM standard and, as web standards are condemned to be backward compatible, such extensions often result in complex specification that may contain unwanted subtleties that can be detected by a formalization. Our Isabelle/HOL formalization is, in the sense of object-orientation, an extension of our formalization of the core DOM and enjoys the same basic properties, i.e., it is extensible, i.e., can be extended without the need of re-proving already proven properties and executable, i.e., we can generate executable code from our specification. We exploit the executability to show that our formalization complies to the official standard of the W3C, respectively, the WHATWG. [DOM_Components] title = A Formalization of Web Components author = Achim D. Brucker , Michael Herzberg topic = Computer science/Data structures date = 2020-09-28 notify = adbrucker@0x5f.org, mail@michael-herzberg.de abstract = While the DOM with shadow trees provide the technical basis for defining web components, the DOM standard neither defines the concept of web components nor specifies the safety properties that web components should guarantee. Consequently, the standard also does not discuss how or even if the methods for modifying the DOM respect component boundaries. In AFP entry, we present a formally verified model of web components and define safety properties which ensure that different web components can only interact with each other using well-defined interfaces. Moreover, our verification of the application programming interface (API) of the DOM revealed numerous invariants that implementations of the DOM API need to preserve to ensure the integrity of components. [Interpreter_Optimizations] title = Inline Caching and Unboxing Optimization for Interpreters author = Martin Desharnais topic = Computer science/Programming languages/Misc date = 2020-12-07 notify = martin.desharnais@unibw.de abstract = This Isabelle/HOL formalization builds on the VeriComp entry of the Archive of Formal Proofs to provide the following contributions:
  • an operational semantics for a realistic virtual machine (Std) for dynamically typed programming languages;
  • the formalization of an inline caching optimization (Inca), a proof of bisimulation with (Std), and a compilation function;
  • the formalization of an unboxing optimization (Ubx), a proof of bisimulation with (Inca), and a simple compilation function.
This formalization was described in the CPP 2021 paper Towards Efficient and Verified Virtual Machines for Dynamic Languages extra-history = Change history: [2021-06-14]: refactored function definitions to contain explicit basic blocks
[2021-06-25]: proved conditional completeness of compilation
[Isabelle_Marries_Dirac] title = Isabelle Marries Dirac: a Library for Quantum Computation and Quantum Information author = Anthony Bordg , Hanna Lachnitt, Yijun He topic = Computer science/Algorithms/Quantum computing, Mathematics/Physics/Quantum information date = 2020-11-22 notify = apdb3@cam.ac.uk, lachnitt@stanford.edu abstract = This work is an effort to formalise some quantum algorithms and results in quantum information theory. Formal methods being critical for the safety and security of algorithms and protocols, we foresee their widespread use for quantum computing in the future. We have developed a large library for quantum computing in Isabelle based on a matrix representation for quantum circuits, successfully formalising the no-cloning theorem, quantum teleportation, Deutsch's algorithm, the Deutsch-Jozsa algorithm and the quantum Prisoner's Dilemma. [Projective_Measurements] title = Quantum projective measurements and the CHSH inequality author = Mnacho Echenim topic = Computer science/Algorithms/Quantum computing, Mathematics/Physics/Quantum information date = 2021-03-03 notify = mnacho.echenim@univ-grenoble-alpes.fr abstract = This work contains a formalization of quantum projective measurements, also known as von Neumann measurements, which are based on elements of spectral theory. We also formalized the CHSH inequality, an inequality involving expectations in a probability space that is violated by quantum measurements, thus proving that quantum mechanics cannot be modeled with an underlying local hidden-variable theory. [Finite-Map-Extras] title = Finite Map Extras author = Javier Díaz topic = Computer science/Data structures date = 2020-10-12 notify = javier.diaz.manzi@gmail.com abstract = This entry includes useful syntactic sugar, new operators and functions, and their associated lemmas for finite maps which currently are not present in the standard Finite_Map theory. [Relational_Minimum_Spanning_Trees] title = Relational Minimum Spanning Tree Algorithms author = Walter Guttmann , Nicolas Robinson-O'Brien<> topic = Computer science/Algorithms/Graph date = 2020-12-08 notify = walter.guttmann@canterbury.ac.nz abstract = We verify the correctness of Prim's, Kruskal's and Borůvka's minimum spanning tree algorithms based on algebras for aggregation and minimisation. [Topological_Semantics] title = Topological semantics for paraconsistent and paracomplete logics author = David Fuenmayor topic = Logic/General logic date = 2020-12-17 notify = davfuenmayor@gmail.com abstract = We introduce a generalized topological semantics for paraconsistent and paracomplete logics by drawing upon early works on topological Boolean algebras (cf. works by Kuratowski, Zarycki, McKinsey & Tarski, etc.). In particular, this work exemplarily illustrates the shallow semantical embeddings approach (SSE) employing the proof assistant Isabelle/HOL. By means of the SSE technique we can effectively harness theorem provers, model finders and 'hammers' for reasoning with quantified non-classical logics. [CSP_RefTK] title = The HOL-CSP Refinement Toolkit author = Safouan Taha , Burkhart Wolff , Lina Ye topic = Computer science/Concurrency/Process calculi, Computer science/Semantics date = 2020-11-19 notify = wolff@lri.fr abstract = We use a formal development for CSP, called HOL-CSP2.0, to analyse a family of refinement notions, comprising classic and new ones. This analysis enables to derive a number of properties that allow to deepen the understanding of these notions, in particular with respect to specification decomposition principles for the case of infinite sets of events. The established relations between the refinement relations help to clarify some obscure points in the CSP literature, but also provide a weapon for shorter refinement proofs. Furthermore, we provide a framework for state-normalisation allowing to formally reason on parameterised process architectures. As a result, we have a modern environment for formal proofs of concurrent systems that allow for the combination of general infinite processes with locally finite ones in a logically safe way. We demonstrate these verification-techniques for classical, generalised examples: The CopyBuffer for arbitrary data and the Dijkstra's Dining Philosopher Problem of arbitrary size. [Hood_Melville_Queue] title = Hood-Melville Queue author = Alejandro Gómez-Londoño topic = Computer science/Data structures date = 2021-01-18 notify = nipkow@in.tum.de abstract = This is a verified implementation of a constant time queue. The original design is due to Hood and Melville. This formalization follows the presentation in Purely Functional Data Structuresby Okasaki. [JinjaDCI] title = JinjaDCI: a Java semantics with dynamic class initialization author = Susannah Mansky topic = Computer science/Programming languages/Language definitions date = 2021-01-11 notify = sjohnsn2@illinois.edu, susannahej@gmail.com abstract = We extend Jinja to include static fields, methods, and instructions, and dynamic class initialization, based on the Java SE 8 specification. This includes extension of definitions and proofs. This work is partially described in Mansky and Gunter's paper at CPP 2019 and Mansky's doctoral thesis (UIUC, 2020). [Blue_Eyes] title = Solution to the xkcd Blue Eyes puzzle author = Jakub Kądziołka topic = Logic/General logic/Logics of knowledge and belief date = 2021-01-30 notify = kuba@kadziolka.net abstract = In a puzzle published by Randall Munroe, perfect logicians forbidden from communicating are stranded on an island, and may only leave once they have figured out their own eye color. We present a method of modeling the behavior of perfect logicians and formalize a solution of the puzzle. [Laws_of_Large_Numbers] title = The Laws of Large Numbers author = Manuel Eberl topic = Mathematics/Probability theory date = 2021-02-10 notify = eberlm@in.tum.de abstract =

The Law of Large Numbers states that, informally, if one performs a random experiment $X$ many times and takes the average of the results, that average will be very close to the expected value $E[X]$.

More formally, let $(X_i)_{i\in\mathbb{N}}$ be a sequence of independently identically distributed random variables whose expected value $E[X_1]$ exists. Denote the running average of $X_1, \ldots, X_n$ as $\overline{X}_n$. Then:

  • The Weak Law of Large Numbers states that $\overline{X}_{n} \longrightarrow E[X_1]$ in probability for $n\to\infty$, i.e. $\mathcal{P}(|\overline{X}_{n} - E[X_1]| > \varepsilon) \longrightarrow 0$ as $n\to\infty$ for any $\varepsilon > 0$.
  • The Strong Law of Large Numbers states that $\overline{X}_{n} \longrightarrow E[X_1]$ almost surely for $n\to\infty$, i.e. $\mathcal{P}(\overline{X}_{n} \longrightarrow E[X_1]) = 1$.

In this entry, I formally prove the strong law and from it the weak law. The approach used for the proof of the strong law is a particularly quick and slick one based on ergodic theory, which was formalised by Gouëzel in another AFP entry.

[BTree] title = A Verified Imperative Implementation of B-Trees author = Niels Mündler topic = Computer science/Data structures date = 2021-02-24 notify = n.muendler@tum.de abstract = In this work, we use the interactive theorem prover Isabelle/HOL to verify an imperative implementation of the classical B-tree data structure invented by Bayer and McCreight [ACM 1970]. The implementation supports set membership, insertion and deletion queries with efficient binary search for intra-node navigation. This is accomplished by first specifying the structure abstractly in the functional modeling language HOL and proving functional correctness. Using manual refinement, we derive an imperative implementation in Imperative/HOL. We show the validity of this refinement using the separation logic utilities from the Isabelle Refinement Framework . The code can be exported to the programming languages SML, OCaml and Scala. We examine the runtime of all operations indirectly by reproducing results of the logarithmic relationship between height and the number of nodes. The results are discussed in greater detail in the corresponding Bachelor's Thesis. extra-history = Change history: [2021-05-02]: Add implementation and proof of correctness of imperative deletion operations. Further add the option to export code to OCaml.
[Sunflowers] title = The Sunflower Lemma of Erdős and Rado author = René Thiemann topic = Mathematics/Combinatorics date = 2021-02-25 notify = rene.thiemann@uibk.ac.at abstract = We formally define sunflowers and provide a formalization of the sunflower lemma of Erdős and Rado: whenever a set of size-k-sets has a larger cardinality than (r - 1)k · k!, then it contains a sunflower of cardinality r. [Mereology] title = Mereology author = Ben Blumson topic = Logic/Philosophical aspects date = 2021-03-01 notify = benblumson@gmail.com abstract = We use Isabelle/HOL to verify elementary theorems and alternative axiomatizations of classical extensional mereology. [Modular_arithmetic_LLL_and_HNF_algorithms] title = Two algorithms based on modular arithmetic: lattice basis reduction and Hermite normal form computation author = Ralph Bottesch <>, Jose Divasón , René Thiemann topic = Computer science/Algorithms/Mathematical date = 2021-03-12 notify = rene.thiemann@uibk.ac.at abstract = We verify two algorithms for which modular arithmetic plays an essential role: Storjohann's variant of the LLL lattice basis reduction algorithm and Kopparty's algorithm for computing the Hermite normal form of a matrix. To do this, we also formalize some facts about the modulo operation with symmetric range. Our implementations are based on the original papers, but are otherwise efficient. For basis reduction we formalize two versions: one that includes all of the optimizations/heuristics from Storjohann's paper, and one excluding a heuristic that we observed to often decrease efficiency. We also provide a fast, self-contained certifier for basis reduction, based on the efficient Hermite normal form algorithm. [Constructive_Cryptography_CM] title = Constructive Cryptography in HOL: the Communication Modeling Aspect author = Andreas Lochbihler , S. Reza Sefidgar <> topic = Computer science/Security/Cryptography, Mathematics/Probability theory date = 2021-03-17 notify = mail@andreas-lochbihler.de, reza.sefidgar@inf.ethz.ch abstract = Constructive Cryptography (CC) [ICS 2011, TOSCA 2011, TCC 2016] introduces an abstract approach to composable security statements that allows one to focus on a particular aspect of security proofs at a time. Instead of proving the properties of concrete systems, CC studies system classes, i.e., the shared behavior of similar systems, and their transformations. Modeling of systems communication plays a crucial role in composability and reusability of security statements; yet, this aspect has not been studied in any of the existing CC results. We extend our previous CC formalization [Constructive_Cryptography, CSF 2019] with a new semantic domain called Fused Resource Templates (FRT) that abstracts over the systems communication patterns in CC proofs. This widens the scope of cryptography proof formalizations in the CryptHOL library [CryptHOL, ESOP 2016, J Cryptol 2020]. This formalization is described in Abstract Modeling of Systems Communication in Constructive Cryptography using CryptHOL. [IFC_Tracking] title = Information Flow Control via Dependency Tracking author = Benedikt Nordhoff topic = Computer science/Security date = 2021-04-01 notify = b.n@wwu.de abstract = We provide a characterisation of how information is propagated by program executions based on the tracking data and control dependencies within executions themselves. The characterisation might be used for deriving approximative safety properties to be targeted by static analyses or checked at runtime. We utilise a simple yet versatile control flow graph model as a program representation. As our model is not assumed to be finite it can be instantiated for a broad class of programs. The targeted security property is indistinguishable security where executions produce sequences of observations and only non-terminating executions are allowed to drop a tail of those. A very crude approximation of our characterisation is slicing based on program dependence graphs, which we use as a minimal example and derive a corresponding soundness result. For further details and applications refer to the authors upcoming dissertation. [Grothendieck_Schemes] title = Grothendieck's Schemes in Algebraic Geometry author = Anthony Bordg , Lawrence Paulson , Wenda Li topic = Mathematics/Algebra, Mathematics/Geometry date = 2021-03-29 notify = apdb3@cam.ac.uk, lp15@cam.ac.uk abstract = We formalize mainstream structures in algebraic geometry culminating in Grothendieck's schemes: presheaves of rings, sheaves of rings, ringed spaces, locally ringed spaces, affine schemes and schemes. We prove that the spectrum of a ring is a locally ringed space, hence an affine scheme. Finally, we prove that any affine scheme is a scheme. [Progress_Tracking] title = Formalization of Timely Dataflow's Progress Tracking Protocol author = Matthias Brun<>, Sára Decova<>, Andrea Lattuada, Dmitriy Traytel topic = Computer science/Algorithms/Distributed date = 2021-04-13 notify = matthias.brun@inf.ethz.ch, traytel@di.ku.dk abstract = Large-scale stream processing systems often follow the dataflow paradigm, which enforces a program structure that exposes a high degree of parallelism. The Timely Dataflow distributed system supports expressive cyclic dataflows for which it offers low-latency data- and pipeline-parallel stream processing. To achieve high expressiveness and performance, Timely Dataflow uses an intricate distributed protocol for tracking the computation’s progress. We formalize this progress tracking protocol and verify its safety. Our formalization is described in detail in our forthcoming ITP'21 paper. [GaleStewart_Games] title = Gale-Stewart Games author = Sebastiaan Joosten topic = Mathematics/Games and economics date = 2021-04-23 notify = sjcjoosten@gmail.com abstract = This is a formalisation of the main result of Gale and Stewart from 1953, showing that closed finite games are determined. This property is now known as the Gale Stewart Theorem. While the original paper shows some additional theorems as well, we only formalize this main result, but do so in a somewhat general way. We formalize games of a fixed arbitrary length, including infinite length, using co-inductive lists, and show that defensive strategies exist unless the other player is winning. For closed games, defensive strategies are winning for the closed player, proving that such games are determined. For finite games, which are a special case in our formalisation, all games are closed. [Metalogic_ProofChecker] title = Isabelle's Metalogic: Formalization and Proof Checker author = Tobias Nipkow , Simon Roßkopf topic = Logic/General logic date = 2021-04-27 notify = rosskops@in.tum.de abstract = In this entry we formalize Isabelle's metalogic in Isabelle/HOL. Furthermore, we define a language of proof terms and an executable proof checker and prove its soundness wrt. the metalogic. The formalization is intentionally kept close to the Isabelle implementation(for example using de Brujin indices) to enable easy integration of generated code with the Isabelle system without a complicated translation layer. The formalization is described in our CADE 28 paper. [Regression_Test_Selection] title = Regression Test Selection author = Susannah Mansky topic = Computer science/Algorithms date = 2021-04-30 notify = sjohnsn2@illinois.edu, susannahej@gmail.com abstract = This development provides a general definition for safe Regression Test Selection (RTS) algorithms. RTS algorithms select which tests to rerun on revised code, reducing the time required to check for newly introduced errors. An RTS algorithm is considered safe if and only if all deselected tests would have unchanged results. This definition is instantiated with two class-collection-based RTS algorithms run over the JVM as modeled by JinjaDCI. This is achieved with a general definition for Collection Semantics, small-step semantics instrumented to collect information during execution. As the RTS definition mandates safety, these instantiations include proofs of safety. This work is described in Mansky and Gunter's LSFA 2020 paper and Mansky's doctoral thesis (UIUC, 2020). [Padic_Ints] title = Hensel's Lemma for the p-adic Integers author = Aaron Crighton topic = Mathematics/Number theory date = 2021-03-23 notify = crightoa@mcmaster.ca abstract = We formalize the ring of p-adic integers within the framework of the HOL-Algebra library. The carrier of the ring is formalized as the inverse limit of quotients of the integers by powers of a fixed prime p. We define an integer-valued valuation, as well as an extended-integer valued valuation which sends 0 to the infinite element. Basic topological facts about the p-adic integers are formalized, including completeness and sequential compactness. Taylor expansions of polynomials over a commutative ring are defined, culminating in the formalization of Hensel's Lemma based on a proof due to Keith Conrad. [Combinatorics_Words] title = Combinatorics on Words Basics author = Štěpán Holub , Martin Raška<>, Štěpán Starosta topic = Computer science/Automata and formal languages date = 2021-05-24 notify = holub@karlin.mff.cuni.cz, stepan.starosta@fit.cvut.cz abstract = We formalize basics of Combinatorics on Words. This is an extension of existing theories on lists. We provide additional properties related to prefix, suffix, factor, length and rotation. The topics include prefix and suffix comparability, mismatch, word power, total and reversed morphisms, border, periods, primitivity and roots. We also formalize basic, mostly folklore results related to word equations: equidivisibility, commutation and conjugation. Slightly advanced properties include the Periodicity lemma (often cited as the Fine and Wilf theorem) and the variant of the Lyndon-Schützenberger theorem for words. We support the algebraic point of view which sees words as generators of submonoids of a free monoid. This leads to the concepts of the (free) hull, the (free) basis (or code). [Combinatorics_Words_Lyndon] title = Lyndon words author = Štěpán Holub , Štěpán Starosta topic = Computer science/Automata and formal languages date = 2021-05-24 notify = holub@karlin.mff.cuni.cz, stepan.starosta@fit.cvut.cz abstract = Lyndon words are words lexicographically minimal in their conjugacy class. We formalize their basic properties and characterizations, in particular the concepts of the longest Lyndon suffix and the Lyndon factorization. Most of the work assumes a fixed lexicographical order. Nevertheless we also define the smallest relation guaranteeing lexicographical minimality of a given word (in its conjugacy class). [Combinatorics_Words_Graph_Lemma] title = Graph Lemma author = Štěpán Holub , Štěpán Starosta topic = Computer science/Automata and formal languages date = 2021-05-24 notify = holub@karlin.mff.cuni.cz, stepan.starosta@fit.cvut.cz abstract = Graph lemma quantifies the defect effect of a system of word equations. That is, it provides an upper bound on the rank of the system. We formalize the proof based on the decomposition of a solution into its free basis. A direct application is an alternative proof of the fact that two noncommuting words form a code. [Lifting_the_Exponent] title = Lifting the Exponent author = Jakub Kądziołka topic = Mathematics/Number theory date = 2021-04-27 notify = kuba@kadziolka.net abstract = We formalize the Lifting the Exponent Lemma, which shows how to find the largest power of $p$ dividing $a^n \pm b^n$, for a prime $p$ and positive integers $a$ and $b$. The proof follows Amir Hossein Parvardi's. [IMP_Compiler] title = A Shorter Compiler Correctness Proof for Language IMP author = Pasquale Noce topic = Computer science/Programming languages/Compiling date = 2021-06-04 notify = pasquale.noce.lavoro@gmail.com abstract = This paper presents a compiler correctness proof for the didactic imperative programming language IMP, introduced in Nipkow and Klein's book on formal programming language semantics (version of March 2021), whose size is just two thirds of the book's proof in the number of formal text lines. As such, it promises to constitute a further enhanced reference for the formal verification of compilers meant for larger, real-world programming languages. The presented proof does not depend on language determinism, so that the proposed approach can be applied to non-deterministic languages as well. As a confirmation, this paper extends IMP with an additional non-deterministic choice command, and proves compiler correctness, viz. the simulation of compiled code execution by source code, for such extended language. [Public_Announcement_Logic] title = Public Announcement Logic author = Asta Halkjær From topic = Logic/General logic/Logics of knowledge and belief date = 2021-06-17 notify = ahfrom@dtu.dk abstract = This work is a formalization of public announcement logic with countably many agents. It includes proofs of soundness and completeness for a variant of the axiom system PA + DIST! + NEC!. The completeness proof builds on the Epistemic Logic theory. [MiniSail] title = MiniSail - A kernel language for the ISA specification language SAIL author = Mark Wassell topic = Computer science/Programming languages/Type systems date = 2021-06-18 notify = mpwassell@gmail.com abstract = MiniSail is a kernel language for Sail, an instruction set architecture (ISA) specification language. Sail is an imperative language with a light-weight dependent type system similar to refinement type systems. From an ISA specification, the Sail compiler can generate theorem prover code and C (or OCaml) to give an executable emulator for an architecture. The idea behind MiniSail is to capture the key and novel features of Sail in terms of their syntax, typing rules and operational semantics, and to confirm that they work together by proving progress and preservation lemmas. We use the Nominal2 library to handle binding. [SpecCheck] title = SpecCheck - Specification-Based Testing for Isabelle/ML author = Kevin Kappelmann , Lukas Bulwahn , Sebastian Willenbrink topic = Tools date = 2021-07-01 notify = kevin.kappelmann@tum.de abstract = SpecCheck is a QuickCheck-like testing framework for Isabelle/ML. You can use it to write specifications for ML functions. SpecCheck then checks whether your specification holds by testing your function against a given number of generated inputs. It helps you to identify bugs by printing counterexamples on failure and provides you timing information. SpecCheck is customisable and allows you to specify your own input generators, test output formats, as well as pretty printers and shrinking functions for counterexamples among other things. [Relational_Forests] title = Relational Forests author = Walter Guttmann topic = Mathematics/Graph theory date = 2021-08-03 notify = walter.guttmann@canterbury.ac.nz abstract = We study second-order formalisations of graph properties expressed as first-order formulas in relation algebras extended with a Kleene star. The formulas quantify over relations while still avoiding quantification over elements of the base set. We formalise the property of undirected graphs being acyclic this way. This involves a study of various kinds of orientation of graphs. We also verify basic algorithms to constructively prove several second-order properties. [Fresh_Identifiers] title = Fresh identifiers author = Andrei Popescu , Thomas Bauereiss topic = Computer science/Data structures date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry defines a type class with an operator returning a fresh identifier, given a set of already used identifiers and a preferred identifier. The entry provides a default instantiation for any infinite type, as well as executable instantiations for natural numbers and strings. [CoCon] title = CoCon: A Confidentiality-Verified Conference Management System author = Andrei Popescu , Peter Lammich , Thomas Bauereiss topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry contains the confidentiality verification of the (functional kernel of) the CoCon conference management system [1, 2]. The confidentiality properties refer to the documents managed by the system, namely papers, reviews, discussion logs and acceptance/rejection decisions, and also to the assignment of reviewers to papers. They have all been formulated as instances of BD Security [3, 4] and verified using the BD Security unwinding technique. [BD_Security_Compositional] title = Compositional BD Security author = Thomas Bauereiss , Andrei Popescu topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = Building on a previous AFP entry that formalizes the Bounded-Deducibility Security (BD Security) framework [1], we formalize compositionality and transport theorems for information flow security. These results allow lifting BD Security properties from individual components specified as transition systems, to a composition of systems specified as communicating products of transition systems. The underlying ideas of these results are presented in the papers [1] and [2]. The latter paper also describes a major case study where these results have been used: on verifying the CoSMeDis distributed social media platform (itself formalized as an AFP entry that builds on this entry). [CoSMed] title = CoSMed: A confidentiality-verified social media platform author = Thomas Bauereiss , Andrei Popescu topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry contains the confidentiality verification of the (functional kernel of) the CoSMed social media platform. The confidentiality properties are formalized as instances of BD Security [1, 2]. An innovation in the deployment of BD Security compared to previous work is the use of dynamic declassification triggers, incorporated as part of inductive bounds, for providing stronger guarantees that account for the repeated opening and closing of access windows. To further strengthen the confidentiality guarantees, we also prove "traceback" properties about the accessibility decisions affecting the information managed by the system. [CoSMeDis] title = CoSMeDis: A confidentiality-verified distributed social media platform author = Thomas Bauereiss , Andrei Popescu topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry contains the confidentiality verification of the (functional kernel of) the CoSMeDis distributed social media platform presented in [1]. CoSMeDis is a multi-node extension the CoSMed prototype social media platform [2, 3, 4]. The confidentiality properties are formalized as instances of BD Security [5, 6]. The lifting of confidentiality properties from single nodes to the entire CoSMeDis network is performed using compositionality and transport theorems for BD Security, which are described in [1] and formalized in a separate AFP entry. +[Three_Circles] +title = The Theorem of Three Circles +author = Fox Thomson , Wenda Li +topic = Mathematics/Analysis +date = 2021-08-21 +notify = foxthomson0@gmail.com, wl302@cam.ac.uk +abstract = + The Descartes test based on Bernstein coefficients and Descartes’ rule + of signs effectively (over-)approximates the number of real roots of a + univariate polynomial over an interval. In this entry we formalise the + theorem of three circles, which gives sufficient conditions for when + the Descartes test returns 0 or 1. This is the first step for + efficient root isolation. + +[Design_Theory] +title = Combinatorial Design Theory +author = Chelsea Edmonds , Lawrence Paulson +topic = Mathematics/Combinatorics +date = 2021-08-13 +notify = cle47@cam.ac.uk +abstract = + Combinatorial design theory studies incidence set systems with certain + balance and symmetry properties. It is closely related to hypergraph + theory. This formalisation presents a general library for formal + reasoning on incidence set systems, designs and their applications, + including formal definitions and proofs for many key properties, + operations, and theorems on the construction and existence of designs. + Notably, this includes formalising t-designs, balanced incomplete + block designs (BIBD), group divisible designs (GDD), pairwise balanced + designs (PBD), design isomorphisms, and the relationship between + graphs and designs. A locale-centric approach has been used to manage + the relationships between the many different types of designs. + Theorems of particular interest include the necessary conditions for + existence of a BIBD, Wilson's construction on GDDs, and + Bose's inequality on resolvable designs. Parts of this + formalisation are explored in the paper "A Modular First + Formalisation of Combinatorial Design Theory", presented at CICM 2021. diff --git a/thys/Cubic_Quartic_Equations/Cardanos_Formula.thy b/thys/Cubic_Quartic_Equations/Cardanos_Formula.thy new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/Cardanos_Formula.thy @@ -0,0 +1,339 @@ +section \Cardano's formula for solving cubic equations\ + +theory Cardanos_Formula + imports + Polynomial_Factorization.Explicit_Roots + Polynomial_Interpolation.Ring_Hom_Poly + Complex_Geometry.More_Complex + Algebraic_Numbers.Complex_Roots_Real_Poly +begin + +subsection \Translation to depressed case\ + +text \Solving an arbitrary cubic equation can easily be turned into the depressed case, i.e., where + there is no quadratic part.\ + +lemma to_depressed_cubic: fixes a :: "'a :: field_char_0" + assumes a: "a \ 0" + and xy: "x = y - b / (3 * a)" + and e: "e = (c - b^2 / (3 * a)) / a" + and f: "f = (d + 2 * b^3 / (27 * a^2) - b * c / (3 * a)) / a" +shows "(a * x ^ 3 + b * x\<^sup>2 + c * x + d = 0) \ y^3 + e * y + f = 0" +proof - + let ?yexp = "y^3 + e * y + f" + have "a * x^3 + b * x^2 + c * x + d = 0 \ (a * x^3 + b * x^2 + c * x + d) / a = 0" + using a by auto + also have "(a * x^3 + b * x^2 + c * x + d) / a = ?yexp" unfolding xy e f power3_eq_cube power2_eq_square using a + by (simp add: field_simps) + finally show ?thesis . +qed + +subsection \Solving the depressed case in arbitrary fields\ + +lemma cubic_depressed: fixes e :: "'a :: field_char_0" + assumes yz: "e \ 0 \ z^2 - y * z - e / 3 = 0" + and u: "e \ 0 \ u = z^3" + and v: "v = - (e ^ 3 / 27)" +shows "y^3 + e * y + f = 0 \ (if e = 0 then y^3 = -f else u\<^sup>2 + f * u + v = 0)" +proof - + let ?yexp = "y^3 + e * y + f" + show ?thesis + proof (cases "e = 0") + case False + note yz = yz[OF False] + from yz have eyz: "e = 3 * (z^2 - y * z)" by auto + from yz False have z0: "z \ 0" by auto + have "?yexp = 0 \ z^3 * ?yexp = 0" using z0 by simp + also have "z^3 * ?yexp = z^6 + f * z^3 - e^3/27" unfolding eyz by algebra + also have "\ = u^2 + f * u + v" unfolding u[OF False] v by algebra + finally show ?thesis using False by auto + next + case True + show ?thesis unfolding True by (auto, algebra) + qed +qed + +subsection \Solving the depressed case for complex numbers\ + +text \In the complex-numbers-case, the quadratic equation for u is always solvable, + and the main challenge here is prove that it does not matter which solution of + the quadratic equation is considered (this is the diff:False case in the proof below.)\ +lemma solve_cubic_depressed_Cardano_complex: fixes e :: complex + assumes e0: "e \ 0" + and v: "v = - (e ^ 3 / 27)" + and u: "u^2 + f * u + v = 0" +shows "y^3 + e * y + f = 0 \ (\ z. z^3 = u \ y = z - e / (3 * z))" +proof - + from v e0 have v0: "v \ 0" by auto + from e0 have "(if e = 0 then x else y) = y" for x y :: bool by auto + note main = cubic_depressed[OF _ _ v, unfolded this] + show ?thesis (is "?l = ?r") + proof + assume ?r + then obtain z where z: "z^3 = u" and y: "y = z - e / (3 * z)" by auto + from u v0 have u0: "u \ 0" by auto + from z u0 have z0: "z \ 0" by auto + show ?l + proof (subst main) + show "u\<^sup>2 + f * u + v = 0" by fact + show "u = z^3" unfolding z by simp + show "z\<^sup>2 - y * z - e / 3 = 0" unfolding y using z0 + by (auto simp: field_simps power2_eq_square) + qed + next + assume ?l + let ?yexp = "y^3 + e * y + f" + have y0: "?yexp = 0" using \?l\ by auto + define p where "p = [: -e/3, -y, 1:]" + have deg: "degree p = 2" unfolding p_def by auto + define z where "z = hd (croots2 p)" + have "z \ set (croots2 p)" unfolding croots2_def Let_def z_def by auto + with croots2[OF deg] have pz: "poly p z = 0" by auto + from pz e0 have z0: "z \ 0" unfolding p_def by auto + from pz have yz: "y * z = z * z - e / 3" unfolding p_def by (auto simp: field_simps) + from arg_cong[OF this, of "\ x. x / z"] z0 have "y = z - e / (3 * z)" + by (auto simp: field_simps) + have "\ u z. u\<^sup>2 + f * u + v = 0 \ z^3 = u \ y = z - e / (3 * z)" + proof (intro exI conjI) + show "y = z - e / (3 * z)" by fact + from y0 have "0 = ?yexp * z^3" by auto + also have "\ = (y * z)^3 + e * (y * z) * z^2 + f * z^3" by algebra + also have "\ = (z^3)^2 + f * (z^3) + v" unfolding yz v by algebra + finally show "(z^3)^2 + f * (z^3) + v = 0" by simp + qed simp + then obtain uu z where + *: "uu\<^sup>2 + f * uu + v = 0" "z ^ 3 = uu" "y = z - e / (3 * z)" by blast + show ?r + proof (cases "uu = u") + case True + thus ?thesis using * by auto + next + case diff: False + define p where "p = [:v,f,1:]" + have p2: "degree p = 2" unfolding p_def by auto + have poly: "poly p u = 0" "poly p uu = 0" using u *(1) unfolding p_def + by (auto simp: field_simps power2_eq_square) + have u0: "u \ 0" "uu \ 0" using poly v0 unfolding p_def by auto + { + from poly(1) have "[:-u,1:] dvd p" by (meson poly_eq_0_iff_dvd) + then obtain q where pq: "p = q * [:-u,1:]" by auto + from poly(2)[unfolded pq poly_mult] diff have "poly q uu = 0" by auto + hence "[:-uu,1:] dvd q" by (meson poly_eq_0_iff_dvd) + then obtain q' where qq': "q = q' * [:-uu,1:]" by auto + with pq have pq: "p = q' * [:-uu,1:] * [:-u,1:]" by auto + from pq[unfolded p_def] have q': "q' \ 0" by auto + from arg_cong[OF pq, of degree, unfolded p2] + have "2 = degree (q' * [:- uu, 1:] * [:- u, 1:])" . + also have "\ = degree q' + degree [:- uu, 1:] + degree [:- u, 1:]" + apply (subst degree_mult_eq) + subgoal using q' by (metis mult_eq_0_iff pCons_eq_0_iff zero_neq_one) + subgoal by force + by (subst degree_mult_eq[OF q'], auto) + also have "\ = degree q' + 2" by simp + finally have dq: "degree q' = 0" by simp + from dq obtain c where q': "q' = [: c:]" by (metis degree_eq_zeroE) + from pq[unfolded q' p_def] have "c = 1" by auto + with q' have "q' = 1" by simp + with pq have "[: -u, 1:] * [: -uu, 1 :] = p" by simp + } + from this[unfolded p_def, simplified] have prod: "uu * u = v" by simp + hence uu: "u = v / uu" using u0 by (simp add: field_simps) + define zz where "zz = - e / (3 * z)" + show ?r using *(2-) uu unfolding v using u0 + by (intro exI[of _ zz], auto simp: zz_def field_simps) + qed + qed +qed + +subsection \Solving the depressed case for real numbers\ + +definition discriminant_cubic_depressed :: "'a :: comm_ring_1 \ 'a \ 'a" where + "discriminant_cubic_depressed e f = - (4 * e^3 + 27 * f^2)" + +lemma discriminant_cubic_depressed: assumes "[:-x,1:] * [:-y,1:] * [:-z,1:] = [:f,e,0,1:]" + shows "discriminant_cubic_depressed e f = (x-y)^2 * (x - z)^2 * (y - z)^2" +proof - + from assms have f: "f = - (z * (y * x))" and e: "e = y * x - z * (- y - x)" and + z: "z = - y - x" by auto + show ?thesis unfolding discriminant_cubic_depressed_def e f z + by (simp add: power2_eq_square power3_eq_cube field_simps) +qed + +text \If the discriminant is negative, then there is exactly one real root\ + +lemma solve_cubic_depressed_Cardano_real: fixes e f v u :: real + defines "y1 \ root 3 u - e / (3 * root 3 u)" + and "\ \ discriminant_cubic_depressed e f" + assumes e0: "e \ 0" + and v: "v = - (e ^ 3 / 27)" + and u: "u\<^sup>2 + f * u + v = 0" (* this implies \ \ 0 *) +shows "y1^3 + e * y1 + f = 0" + "\ \ 0 \ y^3 + e * y + f = 0 \ y = y1" (* this is the case \ < 0 *) +proof - + let ?c = complex_of_real + let ?y = "?c y" + let ?e = "?c e" + let ?u = "?c u" + let ?v = "?c v" + let ?f = "?c f" + { + fix y :: real + let ?y = "?c y" + have "y^3 + e * y + f = 0 \ ?c (y^3 + e * y + f) = ?c 0" + using of_real_eq_iff by blast + also have "\ \ ?y^3 + ?e * ?y + ?f = 0" by simp + also have "\ \ (\ z. z^3 = ?u \ ?y = z - ?e / (3 * z))" + proof (rule solve_cubic_depressed_Cardano_complex) + show "?e \ 0" using e0 by auto + show "?v = - (?e ^ 3 / 27)" unfolding v by simp + show "?u\<^sup>2 + ?f * ?u + ?v = 0" using arg_cong[OF u, of ?c] by simp + qed + finally have "y^3 + e * y + f = 0 \ (\ z. z^3 = ?u \ ?y = z - ?e / (3 * z))" . + } note pre = this + show y1: "y1^3 + e * y1 + f = 0" unfolding pre y1_def + by (intro exI[of _ "?c (root 3 u)"], simp only: of_real_power[symmetric], + simp del: of_real_power add: odd_real_root_pow) + from u have "{z. poly [:v,f,1:] z = 0} \ {}" + by (auto simp add: field_simps power2_eq_square) + hence "set (rroots2 [:v,f,1:]) \ {}" + by (subst rroots2[symmetric], auto) + hence "rroots2 [:v,f,1:] \ []" by simp + from this[unfolded rroots2_def Let_def, simplified] + have "f^2 - 4 * v \ 0" + by (auto split: if_splits simp: numeral_2_eq_2 field_simps power2_eq_square) + hence delta_le_0: "\ \ 0" unfolding \_def discriminant_cubic_depressed_def v by auto + + assume Delta_non_0: "\ \ 0" + with delta_le_0 have delta_neg: "\ < 0" by simp + let ?p = "[:f,e,0,1:]" + have poly: "poly ?p y = 0 \ y^3 + e * y + f = 0" for y + by (simp add: field_simps power2_eq_square power3_eq_cube) + from y1 have "poly ?p y1 = 0" unfolding poly . + hence "[:-y1,1:] dvd ?p" using poly_eq_0_iff_dvd by blast + then obtain q where pq: "?p = [:-y1,1:] * q" by blast + { + fix y2 + assume "poly ?p y2 = 0" "y2 \ y1" + from this[unfolded pq] poly_mult have "poly q y2 = 0" by auto + from this[unfolded poly_eq_0_iff_dvd] obtain r where qr: "q = [:-y2,1:] * r" by blast + { + have r0: "r \ 0" using pq unfolding qr poly_mult by auto + have "3 = degree ?p" by simp + also have "\ = 2 + degree r" unfolding pq qr + apply (subst degree_mult_eq, force) + subgoal using r0 pq qr by force + by (subst degree_mult_eq[OF _ r0], auto) + finally have "degree r = 1" by simp + from degree1_coeffs[OF this] obtain yy a where r: "r = [:yy,a:]" by auto + define y3 where "y3 = -yy" + with r have r: "r = [:-y3,a:]" by auto + from pq[unfolded qr r] have "a = 1" by auto + with r have "\ y3. r = [:-y3,1:]" by auto + } + then obtain y3 where r: "r = [:-y3,1:]" by auto + have py: "?p = [:-y1,1:] * [:-y2,1:] * [:-y3,1:]" unfolding pq qr r by algebra + from discriminant_cubic_depressed[OF this[symmetric], folded \_def] + have delta: "\ = (y1 - y2)\<^sup>2 * (y1 - y3)\<^sup>2 * (y2 - y3)\<^sup>2" . + have d0: "\ \ 0" unfolding delta by auto + with delta_neg have False by auto + } + with y1 show "y^3 + e * y + f = 0 \ y = y1" unfolding poly by auto +qed + +text \If the discriminant is non-negative, then all roots are real\ + +lemma solve_cubic_depressed_Cardano_all_real_roots: fixes e f v :: real and y :: complex + defines "\ \ discriminant_cubic_depressed e f" + assumes Delta: "\ \ 0" + and rt: "y^3 + e * y + f = 0" +shows "y \ \" +proof - + note powers = field_simps power3_eq_cube power2_eq_square + let ?c = complex_of_real + let ?e = "?c e" + let ?f = "?c f" + let ?cp = "[:?f,?e,0,1:]" + let ?p = "[:f,e,0,1:]" + from odd_degree_imp_real_root[of ?p] obtain x1 where "poly ?p x1 = 0" by auto + hence "[:-x1,1:] dvd ?p" using poly_eq_0_iff_dvd by blast + then obtain q where pq: "?p = [:-x1,1:] * q" by auto + from arg_cong[OF pq, of degree] + have "3 = degree ([:-x1,1:] * q)" by simp + also have "\ = 1 + degree q" + by (subst degree_mult_eq, insert pq, auto) + finally have dq: "degree q = 2" by auto + let ?cc = "map_poly ?c" + let ?q = "?cc q" + have cpq: "?cc ?p = ?cc [:-x1,1:] * ?q" unfolding pq hom_distribs by simp + let ?x1 = "?c x1" + have dq': "degree ?q = 2" using dq by simp + have "\ constant (poly ?q)" using dq by (simp add: constant_degree) + from fundamental_theorem_of_algebra[OF this] obtain x2 where x2: "poly ?q x2 = 0" by blast + have "x2 \ \" + proof (rule ccontr) + assume x2r: "x2 \ \" + define x3 where "x3 = cnj x2" + from x2r have x23: "x2 \ x3" unfolding x3_def using Reals_cnj_iff by force + have x3: "poly ?q x3 = 0" unfolding x3_def + by (rule complex_conjugate_root[OF _ x2], auto) + from x2[unfolded poly_eq_0_iff_dvd] obtain r where qr: "?q = [:-x2,1:] * r" by auto + from arg_cong[OF this[symmetric], of "\ x. poly x x3", unfolded poly_mult x3 mult_eq_0_iff] x23 + have x3: "poly r x3 = 0" by auto + from arg_cong[OF qr, of degree] + have "2 = degree ([:-x2,1:] * r)" using dq' by simp + also have "\ = 1 + degree r" by (subst degree_mult_eq, insert pq qr, auto) + finally have "degree r = 1" by simp + from degree1_coeffs[OF this] obtain a b where r: "r = [:a,b:]" by auto + from cpq[unfolded qr r] have b1: "b = 1" by simp + with x3 r have "a + x3 = 0" by simp + hence "a = - x3" by algebra + with b1 r have r: "r = [:-x3,1:]" by auto + have "?cc ?p = ?cc [:-x1,1:] * [:-x2,1:] * [:-x3,1:]" unfolding cpq qr r by algebra + also have "?cc [:-x1,1:] = [:-?x1,1:]" by simp + also have "?cc ?p = ?cp" by simp + finally have id: "[:-?x1,1:] * [:-x2,1:] * [:-x3,1:] = ?cp" by simp + define x23 where "x23 = - 4 * (Im x2)^2" + define x12c where "x12c = ?x1 - x2" + define x12 where "x12 = (Re x12c) ^ 2 + (Im x12c)^2" + have x23_0: "x23 < 0" unfolding x23_def using x2r using complex_is_Real_iff by force + have "Im x12c \ 0" unfolding x12c_def using x2r using complex_is_Real_iff by force + hence "(Im x12c)^2 > 0" by simp + hence x12: "x12 > 0" unfolding x12_def using sum_power2_gt_zero_iff by auto + from discriminant_cubic_depressed[OF id] + have "?c \ = ((?x1 - x2)\<^sup>2 * (?x1 - x3)\<^sup>2) * (x2 - x3)\<^sup>2" + unfolding \_def discriminant_cubic_depressed_def by simp + also have "(x2 - x3)^2 = ?c x23" unfolding x3_def x23_def by (simp add: complex_eq_iff power2_eq_square) + also have "(?x1 - x2)\<^sup>2 * (?x1 - x3)\<^sup>2 = ((?x1 - x2) * (?x1 - x3))^2" + by (simp add: power2_eq_square) + also have "?x1 - x3 = cnj (?x1 - x2)" unfolding x3_def by simp + also have "(?x1 - x2) = x12c" unfolding x12c_def .. + also have "x12c * cnj x12c = ?c x12" by (simp add: x12_def complex_eq_iff power2_eq_square) + finally have "?c \ = ?c (x12^2 * x23)" by simp + hence "\ = x12^2 * x23" by (rule of_real_hom.injectivity) + also have "\ < 0" using x12 x23_0 by (meson mult_pos_neg zero_less_power) + finally show False using Delta by simp + qed + with x2 obtain x2 where "poly ?q (?c x2) = 0" unfolding Reals_def by auto + hence x2: "poly q x2 = 0" by simp + from x2[unfolded poly_eq_0_iff_dvd] obtain r where qr: "q = [:-x2,1:] * r" by auto + from arg_cong[OF qr, of degree] + have "2 = degree ([:-x2,1:] * r)" using dq' by simp + also have "\ = 1 + degree r" by (subst degree_mult_eq, insert pq qr, auto) + finally have "degree r = 1" by simp + from degree1_coeffs[OF this] obtain a b where r: "r = [:a,b:]" by auto + from pq[unfolded qr r] have b1: "b = 1" by simp + define x3 where "x3 = -a" + have r: "r = [:-x3,1:]" unfolding r b1 x3_def by simp + let ?pp = "[:-x1,1:] * [:-x2,1:] * [:-x3,1:]" + have id: "?p = ?pp" unfolding pq qr r by linarith + have "True \ y^3 + e * y + f = 0" using rt by auto + also have "y^3 + e * y + f = poly (?cc ?p) y" by (simp add: powers) + also have "\ = poly (?cc ?pp) y" unfolding id by simp + also have "?cc ?pp = [:-?c x1, 1:] * [:-?c x2, 1:] * [:- ?c x3, 1:]" + by simp + also have "poly \ y = 0 \ y = ?c x1 \ y = ?c x2 \ y = ?c x3" + unfolding poly_mult mult_eq_0_iff by auto + finally show "y \ \" by auto +qed + +end \ No newline at end of file diff --git a/thys/Cubic_Quartic_Equations/Complex_Roots.thy b/thys/Cubic_Quartic_Equations/Complex_Roots.thy new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/Complex_Roots.thy @@ -0,0 +1,454 @@ +section \$n$-th roots of complex numbers\ + +theory Complex_Roots + imports + Complex_Geometry.More_Complex + Min_Int_Poly_Impl + "HOL-Library.Product_Lexorder" +begin + +subsection \An algorithm to compute all complex roots of (algebraic) complex numbers\ + +text \TODO: The filter instruction might be tuned by using interval arithmetic instead.\ +definition all_croots :: "nat \ complex \ complex list" where + "all_croots n x = (if n = 0 then [] else + if algebraic x then + (let p = min_int_poly x; + q = poly_nth_root n p; + xs = complex_roots_of_int_poly q + in filter (\ y. y^n = x) xs) + else (SOME ys. set ys = {y. y^n = x}))" + +lemma all_croots_code[code]: + "all_croots n x = (if n = 0 then [] else + if algebraic x then + (let p = min_int_poly x; + q = poly_nth_root n p; + xs = complex_roots_of_int_poly q + in filter (\ y. y^n = x) xs) + else Code.abort (STR ''all_croots invoked on non-algebraic number'') (\ _. all_croots n x))" + by (auto simp: all_croots_def) + +lemma all_croots: assumes n0: "n \ 0" shows "set (all_croots n x) = {y. y^n = x}" +proof (cases "algebraic x") + case True + hence id: "(if n = 0 then y else if algebraic x then z else u) = z" + for y z u :: "complex list" using n0 by auto + define p where "p = poly_nth_root n (min_int_poly x)" + show ?thesis unfolding Let_def p_def[symmetric] all_croots_def id + proof (standard, force, standard, simp) + fix y + assume y: "y ^n = x" + have "min_int_poly x represents x" using True by auto + from represents_nth_root[OF n0 y this] + have "p represents y" unfolding p_def by auto + thus "y \ set (complex_roots_of_int_poly p)" + by (subst complex_roots_of_int_poly, auto) + qed +next + case False + hence id: "(if n = 0 then y else if algebraic x then z else u) = u" + for y z u :: "complex list" using n0 by auto + show ?thesis unfolding Let_def all_croots_def id + by (rule someI_ex, rule finite_list, insert n0, blast) +qed + +subsection \A definition of \emph{the} complex root of a complex number\ + +text \While the definition of the complex root is quite natural and easy, + the main task is a criterion to determine which of all possible roots of a + complex number is the chosen one.\ + +definition croot :: "nat \ complex \ complex" where + "croot n x = (rcis (root n (cmod x)) (arg x / of_nat n))" + +lemma croot_0[simp]: "croot n 0 = 0" "croot 0 x = 0" + unfolding croot_def by auto + +lemma croot_power: assumes n: "n \ 0" + shows "(croot n x) ^ n = x" + unfolding croot_def DeMoivre2 + by (subst real_root_pow_pos2, insert n, auto simp: rcis_cmod_arg) + +lemma arg_of_real: "arg (of_real x) = + (if x < 0 then pi else 0)" +proof (cases "x = 0") + case False + hence "x < 0 \ x > 0" by auto + thus ?thesis by (intro arg_unique, auto + simp: complex_sgn_def scaleR_complex.ctr complex_eq_iff) +qed (auto simp: arg_def) + + +lemma arg_rcis_cis[simp]: assumes "x > 0" + shows "arg (rcis x y) = arg (cis y)" + using assms unfolding rcis_def by simp + +lemma cis_arg_1[simp]: "cis (arg 1) = 1" + using arg_of_real[of 1] by simp + +lemma cis_arg_power[simp]: assumes "x \ 0" + shows "cis (arg (x ^ n)) = cis (arg x * real n)" +proof (induct n) + case (Suc n) + show ?case unfolding power.simps + proof (subst cis_arg_mult) + show "cis (arg x + arg (x ^ n)) = cis (arg x * real (Suc n))" + unfolding mult.commute[of "arg x"] DeMoivre[symmetric] + unfolding power.simps using Suc + by (metis DeMoivre cis_mult mult.commute) + show "x * x ^ n \ 0" using assms by auto + qed +qed simp + +lemma arg_croot[simp]: "arg (croot n x) = arg x / real n" +proof (cases "n = 0 \ x = 0") + case True + thus ?thesis by (auto simp: arg_def) +next + case False + hence n: "n \ 0" and x: "x \ 0" by auto + let ?root = "croot n x" + from n have n1: "real n \ 1" "real n > 0" "real n \ 0" by auto + have bounded: "- pi < arg x / real n \ arg x / real n \ pi" + proof (cases "arg x < 0") + case True + from arg_bounded[of x] have "- pi < arg x" by auto + also have "\ \ arg x / real n" using n1 True + by (smt (z3) div_by_1 divide_minus_left frac_le) + finally have one: "- pi < arg x / real n" . + have "arg x / real n \ 0" using True n1 + by (smt (verit) divide_less_0_iff) + also have "\ \ pi" by simp + finally show ?thesis using one by auto + next + case False + hence ax: "arg x \ 0" by auto + have "arg x / real n \ arg x" using n1 ax + by (smt (verit) div_by_1 frac_le) + also have "\ \ pi" using arg_bounded[of x] by simp + finally have one: "arg x / real n \ pi" . + have "-pi < 0" by simp + also have "\ \ arg x / real n" using ax n1 by simp + finally show ?thesis using one by auto + qed + have "arg ?root = arg (cis (arg x / real n))" + unfolding croot_def using x n by simp + also have "\ = arg x / real n" + by (rule arg_unique, force, insert bounded, auto) + finally show ?thesis . +qed + +lemma cos_abs[simp]: "cos (abs x :: real) = cos x" +proof (cases "x < 0") + case True + hence abs: "abs x = - x" by simp + show ?thesis unfolding abs by simp +qed simp + +lemma cos_mono_le: assumes "abs x \ pi" + and "abs y \ pi" +shows "cos x \ cos y \ abs y \ abs x" +proof - + have "cos x \ cos y \ cos (abs x) \ cos (abs y)" by simp + also have "\ \ abs y \ abs x" + by (subst cos_mono_le_eq, insert assms, auto) + finally show ?thesis . +qed + +lemma abs_add_2_mult_bound: fixes x :: "'a :: linordered_idom" + assumes xy: "\x\ \ y" + shows "\x\ \ \x + 2 * of_int i * y\" +proof (cases "i = 0") + case i: False + let ?oi = "of_int :: int \ 'a" + from xy have y: "y \ 0" by auto + consider (pp) "x \ 0" "i \ 0" + | (nn) "x \ 0" "i \ 0" + | (pn) "x \ 0" "i \ 0" + | (np) "x \ 0" "i \ 0" + by linarith + thus ?thesis + proof cases + case pp + thus ?thesis using y by simp + next + case nn + have "x \ x + 2 * ?oi i * y" + using nn y by (simp add: mult_nonneg_nonpos2) + with nn show ?thesis by linarith + next + case pn + with i have "0 \ x" "i < 0" by auto + define j where "j = nat (-i) - 1" + define z where "z = x - 2 * y" + define u where "u = 2 * ?oi (nat j) * y" + have u: "u \ 0" unfolding u_def using y by auto + have i: "i = - int (Suc j)" + using \i < 0\ unfolding j_def by simp + have id: "x + 2 * ?oi i * y = z - u" + unfolding i z_def u_def by (simp add: field_simps) + have z: "z \ 0" "abs z \ x" using xy y pn(1) + unfolding z_def by auto + show ?thesis unfolding id using pn(1) z u by simp + next + case np + with i have "0 \ x" "i > 0" by auto + define j where "j = nat i - 1" + have i: "i = int (Suc j)" + using \i > 0\ unfolding j_def by simp + define u where "u = 2 * ?oi (nat j) * y" + have u: "u \ 0" unfolding u_def using y by auto + define z where "z = - x - 2 * y" + have id: "x + 2 * ?oi i * y = - z + u" + unfolding i z_def u_def by (simp add: field_simps) + have z: "z \ 0" "abs z \ - x" using xy y np(1) + unfolding z_def by auto + show ?thesis unfolding id using np(1) z u by simp + qed +qed simp + +lemma abs_eq_add_2_mult: fixes y :: "'a :: linordered_idom" + assumes abs_id: "\x\ = \x + 2 * of_int i * y\" + and xy: "- y < x" "x \ y" + and i: "i \ 0" +shows "x = y \ i = -1" +proof - + let ?oi = "of_int :: int \ 'a" + from xy have y: "y > 0" by auto + consider (pp) "x \ 0" "i \ 0" + | (nn) "x < 0" "i \ 0" + | (pn) "x \ 0" "i \ 0" + | (np) "x < 0" "i \ 0" + by linarith + hence "?thesis \ x = ?oi (- i) * y" + proof cases + case pp + thus ?thesis using y abs_id xy i by simp + next + case nn + hence "\x + 2 * ?oi i * y\ = + - (x + 2 * ?oi i * y)" + using y nn + by (intro abs_of_nonpos add_nonpos_nonpos, + force, simp, intro mult_nonneg_nonpos, auto) + thus ?thesis using y abs_id xy i nn + by auto + next + case pn + with i have "0 \ x" "i < 0" by auto + define j where "j = nat (-i) - 1" + define z where "z = x - 2 * y" + define u where "u = 2 * ?oi (nat j) * y" + have u: "u \ 0" unfolding u_def using y by auto + have i: "i = - int (Suc j)" + using \i < 0\ unfolding j_def by simp + have id: "x + 2 * ?oi i * y = z - u" + unfolding i z_def u_def by (simp add: field_simps) + have z: "z \ 0" "abs z \ x" using xy y pn(1) + unfolding z_def by auto + from abs_id[unfolded id] have "z - u = -x " + using z u pn by auto + from this[folded id] have "x = of_int (-i) * y" + by auto + thus ?thesis by auto + next + case np + with i have "0 \ x" "i > 0" by auto + define j where "j = nat i - 1" + have i: "i = int (Suc j)" + using \i > 0\ unfolding j_def by simp + define u where "u = 2 * ?oi (nat j) * y" + have u: "u \ 0" unfolding u_def using y by auto + define z where "z = - x - 2 * y" + have id: "x + 2 * ?oi i * y = - z + u" + unfolding i z_def u_def by (simp add: field_simps) + have z: "z \ 0" + using xy y np(1) unfolding z_def by auto + from abs_id[unfolded id] have "- z + u = - x" + using u z np by auto + from this[folded id] have "x = of_int (- i) * y" + by auto + thus ?thesis by auto + qed + thus ?thesis + proof + assume "x = ?oi (- i) * y" + with xy i y + show ?thesis + by (smt (verit, ccfv_SIG) less_le minus_less_iff mult_le_cancel_right2 mult_minus1_right mult_minus_left mult_of_int_commute of_int_hom.hom_one of_int_le_1_iff of_int_minus) + qed +qed + +text \This is the core lemma. It tells us that @{const croot} will choose the + principal root, i.e. the root with + largest real part and if there are two roots with identical real part, then the largest imaginary part. + This criterion will be crucial for implementing @{const croot}.\ + +lemma croot_principal: assumes n: "n \ 0" + and y: "y ^ n = x" + and neq: "y \ croot n x" +shows "Re y < Re (croot n x) \ Re y = Re (croot n x) \ Im y < Im (croot n x)" +proof (cases "x = 0") + case True + with neq y have False by auto + thus ?thesis .. +next + case x: False + let ?root = "croot n x" + from n have n1: "real n \ 1" "real n > 0" "real n \ 0" by auto + from x y n have y0: "y \ 0" by auto + from croot_power[OF n, of x] y + have id: "?root ^ n = y ^ n" by simp + hence "cmod (?root ^ n) = cmod (y ^ n)" by simp + hence norm_eq: "cmod ?root = cmod y" using n unfolding norm_power + by (meson gr_zeroI norm_ge_zero power_eq_imp_eq_base) + have "cis (arg y * real n) = cis (arg (y^n))" by (subst cis_arg_power[OF y0], simp) + also have "\ = cis (arg x)" using y by simp + finally have ciseq: "cis (arg y * real n) = cis (arg x)" by simp + from cis_eq[OF ciseq] obtain i where + "arg y * real n - arg x = 2 * real_of_int i * pi" + by auto + hence "arg y * real n = arg x + 2 * real_of_int i * pi" by auto + from arg_cong[OF this, of "\ x. x / real n"] n1 + have argy: "arg y = arg ?root + 2 * real_of_int i * pi / real n" + by (auto simp: field_simps) + have i0: "i \ 0" + proof + assume "i = 0" + hence "arg y = arg ?root" unfolding argy by simp + with norm_eq have "?root = y" by (metis rcis_cmod_arg) + with neq show False by simp + qed + from y0 have cy0: "cmod y > 0" by auto + from arg_bounded[of x] have abs_pi: "abs (arg x) \ pi" by auto + have "Re y \ Re ?root \ Re y / cmod y \ Re ?root / cmod y" + using cy0 unfolding divide_le_cancel by simp + also have cosy: "Re y / cmod y = cos (arg y)" unfolding cos_arg[OF y0] .. + also have cosrt: "Re ?root / cmod y = cos (arg ?root)" + unfolding norm_eq[symmetric] by (subst cos_arg, insert norm_eq cy0, auto) + also have "cos (arg y) \ cos (arg ?root) \ abs (arg ?root) \ abs (arg y)" + by (rule cos_mono_le, insert arg_bounded[of y] arg_bounded[of ?root], auto) + also have "\ \ abs (arg ?root) * real n \ abs (arg y) * real n" + unfolding mult_le_cancel_right using n1 by simp + also have "\ \ abs (arg x) \ \arg x + 2 * real_of_int i * pi\" + unfolding argy using n1 by (simp add: field_simps) + also have "\" using abs_pi + by (rule abs_add_2_mult_bound) + finally have le: "Re y \ Re (croot n x)" . + show ?thesis + proof (cases "Re y = Re (croot n x)") + case False + with le show ?thesis by auto + next + case True + hence "Re y / cmod y = Re ?root / cmod y" by simp + hence "cos (arg y) = cos (arg ?root)" unfolding cosy cosrt . + hence "cos (abs (arg y)) = cos (abs (arg ?root))" unfolding cos_abs . + from cos_inj_pi[OF _ _ _ _ this] + have "abs (arg y) = abs (arg ?root)" + using arg_bounded[of y] arg_bounded[of ?root] by auto + hence "abs (arg y) * real n = abs (arg ?root) * real n" by simp + hence "abs (arg x) = \arg x + 2 * real_of_int i * pi\" unfolding argy + using n1 by (simp add: field_simps) + from abs_eq_add_2_mult[OF this _ _ \i \ 0\] arg_bounded[of x] + have argx: "arg x = pi" and i: "i = -1" by auto + have argy: "arg y = -pi / real n" + unfolding argy arg_croot i argx by simp + have "Im ?root > Im y \ Im ?root / cmod ?root > Im y / cmod y" + unfolding norm_eq using cy0 + by (meson divide_less_cancel divide_strict_right_mono) + also have "\ \ sin (arg ?root) > sin (arg y)" + by (subst (1 2) sin_arg, insert y0 norm_eq, auto) + also have "\ \ sin (- pi / real n) < sin (pi / real n)" + unfolding argy arg_croot argx by simp + also have \ + proof - + have "sin (- pi / real n) < 0" + using n1 by (smt (verit) arg_bounded argy divide_neg_pos sin_gt_zero sin_minus) + also have "\ < sin (pi / real n)" + using n1 calculation by fastforce + finally show ?thesis . + qed + finally show ?thesis using le by auto + qed +qed + +lemma croot_unique: assumes n: "n \ 0" + and y: "y ^ n = x" + and y_max_Re_Im: "\ z. z ^ n = x \ + Re z < Re y \ Re z = Re y \ Im z \ Im y" +shows "croot n x = y" +proof (rule ccontr) + assume "croot n x \ y" + from croot_principal[OF n y this[symmetric]] + have "Re y < Re (croot n x) \ + Re y = Re (croot n x) \ Im y < Im (croot n x)" . + with y_max_Re_Im[OF croot_power[OF n]] + show False by auto +qed + +lemma csqrt_is_croot_2: "csqrt = croot 2" +proof + fix x + show "csqrt x = croot 2 x" + proof (rule sym, rule croot_unique, force, force) + let ?p = "[:-x,0,1:]" + let ?cx = "csqrt x" + have p: "?p = [:?cx,1:] * [:-?cx,1:]" + by (simp add: power2_eq_square[symmetric]) + fix y + assume "y^2 = x" + hence "True \ poly ?p y = 0" + by (auto simp: power2_eq_square) + also have "\ \ y = - ?cx \ y = ?cx" + unfolding p poly_mult mult_eq_0_iff poly_root_factor by auto + finally have "y = - ?cx \ y = ?cx" by simp + thus "Re y < Re ?cx \ Re y = Re ?cx \ Im y \ Im ?cx" + proof + assume y: "y = - ?cx" + show ?thesis + proof (cases "Re ?cx = 0") + case False + with csqrt_principal[of x] have "Re ?cx > 0" by simp + thus ?thesis unfolding y by simp + next + case True + with csqrt_principal[of x] have "Im ?cx \ 0" by simp + thus ?thesis unfolding y using True by auto + qed + qed auto + qed +qed + +lemma croot_via_root_selection: assumes roots: "set ys = { y. y^n = x}" + and n: "n \ 0" +shows "croot n x = arg_min_list (\ y. (- Re y, - Im y)) ys" + (is "_ = arg_min_list ?f ys") +proof (rule croot_unique[OF n]) + let ?y = "arg_min_list ?f ys" + have rt: "croot n x ^ n = x" using n by (rule croot_power) + hence "croot n x \ set ys" unfolding roots by auto + hence ys: "ys \ []" by auto + from arg_min_list_in[OF this] have "?y \ set ys" by auto + from this[unfolded roots] + show "?y^n = x" by auto + fix z + assume "z^n = x" + hence z: "z \ set ys" unfolding roots by auto + from f_arg_min_list_f[OF ys, of ?f] z + have "?f ?y \ ?f z" by simp + thus "Re z < Re ?y \ Re z = Re ?y \ Im z \ Im ?y" by auto +qed + +lemma croot_impl[code]: "croot n x = (if n = 0 then 0 else + arg_min_list (\ y. (- Re y, - Im y)) (all_croots n x))" +proof (cases "n = 0") + case n0: False + hence id: "(if n = 0 then y else z) = z" + for y z u :: complex by auto + show ?thesis unfolding id Let_def + by (rule croot_via_root_selection[OF _ n0], rule all_croots[OF n0]) +qed auto + +end \ No newline at end of file diff --git a/thys/Cubic_Quartic_Equations/Cubic_Polynomials.thy b/thys/Cubic_Quartic_Equations/Cubic_Polynomials.thy new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/Cubic_Polynomials.thy @@ -0,0 +1,259 @@ +section \Algorithms to compute all complex and real roots of a cubic polynomial\ + +theory Cubic_Polynomials + imports + Cardanos_Formula + Complex_Roots +begin + +hide_const (open) MPoly_Type.degree +hide_const (open) MPoly_Type.coeffs + +(* TODO: this should be integrated into distribution *) +lemma complex_of_real_code[code_unfold]: "complex_of_real = (\ x. Complex x 0)" + by (intro ext, auto simp: complex_eq_iff) + +text \The real case where a result is only delivered if the discriminant is negative\ + +definition solve_depressed_cubic_Cardano_real :: "real \ real \ real option" where + "solve_depressed_cubic_Cardano_real e f = ( + if e = 0 then Some (root 3 (-f)) else + let v = - (e ^ 3 / 27) in + case rroots2 [:v,f,1:] of + [u,_] \ let rt = root 3 u in Some (rt - e / (3 * rt)) + | _ \ None)" + +lemma solve_depressed_cubic_Cardano_real: + assumes "solve_depressed_cubic_Cardano_real e f = Some y" + shows "{y. y^3 + e * y + f = 0} = {y}" +proof (cases "e = 0") + case True + have "{y. y^3 + e * y + f = 0} = {y. y^3 = -f}" unfolding True + by (auto simp add: field_simps) + also have "\ = {root 3 (-f)}" + using odd_real_root_unique[of 3 _ "-f"] odd_real_root_pow[of 3] by auto + also have "root 3 (-f) = y" using assms unfolding True solve_depressed_cubic_Cardano_real_def + by auto + finally show ?thesis . +next + case False + define v where "v = - (e ^ 3 / 27)" + note * = assms[unfolded solve_depressed_cubic_Cardano_real_def Let_def, folded v_def] + let ?rr = "rroots2 [:v,f,1:]" + from * False obtain u u' where rr: "?rr = [u,u']" + by (cases ?rr; cases "tl ?rr"; cases "tl (tl ?rr)"; auto split: if_splits) + from *[unfolded rr list.simps] False + have y: "y = root 3 u - e / (3 * root 3 u)" by auto + have "u \ set (rroots2 [:v,f,1:])" unfolding rr by auto + also have "set (rroots2 [:v,f,1:]) = {u. poly [:v,f,1:] u = 0}" + by (subst rroots2, auto) + finally have u: "u^2 + f * u + v = 0" by (simp add: field_simps power2_eq_square) + note Cardano = solve_cubic_depressed_Cardano_real[OF False v_def u] + have 2: "2 = Suc (Suc 0)" by simp + from rr have 0: "f\<^sup>2 - 4 * v \ 0" unfolding rroots2_def Let_def + by (auto split: if_splits simp: 2) + hence 0: "discriminant_cubic_depressed e f \ 0" + unfolding discriminant_cubic_depressed_def v_def by auto + show ?thesis using Cardano(1) Cardano(2)[OF 0] unfolding y[symmetric] by blast +qed + +text \The complex case\ + +definition solve_depressed_cubic_complex :: "complex \ complex \ complex list" where + "solve_depressed_cubic_complex e f = (let + ys = (if e = 0 then all_croots 3 (- f) else (let + u = hd (croots2 [: - (e ^ 3 / 27) ,f,1:]); + zs = all_croots 3 u + in map (\ z. z - e / (3 * z)) zs)) + in remdups ys)" + +lemma solve_depressed_cubic_complex_code[code]: + "solve_depressed_cubic_complex e f = (let + ys = (if e = 0 then all_croots 3 (- f) else (let + f2 = f / 2; + u = - f2 + csqrt (f2^2 + e ^ 3 / 27); + zs = all_croots 3 u + in map (\ z. z - e / (3 * z)) zs)) + in remdups ys)" + unfolding solve_depressed_cubic_complex_def Let_def croots2_def + by (simp add: numeral_2_eq_2) + + +lemma solve_depressed_cubic_complex: "y \ set (solve_depressed_cubic_complex e f) + \ (y^3 + e * y + f = 0)" +proof (cases "e = 0") + case True + thus ?thesis by (simp add: solve_depressed_cubic_complex_def Let_def all_croots eq_neg_iff_add_eq_0) +next + case e0: False + hence id: "(if e = 0 then x else y) = y" for x y :: "complex list" by simp + define v where "v = - (e ^ 3 / 27)" + define p where "p = [:v, f, 1:]" + have p2: "degree p = 2" unfolding p_def by auto + let ?u = "hd (croots2 p)" + define u where "u = ?u" + have "u \ set (croots2 p)" unfolding croots2_def Let_def u_def by auto + with croots2[OF p2] have "poly p u = 0" by auto + hence u: "u^2 + f * u + v = 0" unfolding p_def + by (simp add: field_simps power2_eq_square) + note cube_roots = all_croots[of 3, simplified] + show ?thesis unfolding solve_depressed_cubic_complex_def Let_def set_remdups set_map id cube_roots + unfolding v_def[symmetric] p_def[symmetric] set_concat set_map + u_def[symmetric] + proof - + have p: "{x. poly p x = 0} = {u. u^2 + f * u + v = 0}" unfolding p_def by (auto simp: field_simps power2_eq_square) + have cube: "\ (set ` all_croots 3 ` {x. poly p x = 0}) = {z. \ u. u\<^sup>2 + f * u + v = 0 \ z ^ 3 = u}" + unfolding p by (auto simp: cube_roots) + show "(y \ (\z. z - e / (3 * z)) ` {y. y ^ 3 = u}) = (y ^ 3 + e * y + f = 0)" + using solve_cubic_depressed_Cardano_complex[OF e0 v_def u] cube by blast + qed +qed + +text \For the general real case, we first try Cardano with negative discrimiant and only if it is not applicable, + then we go for the calculation using complex numbers. Note that for for non-negative delta + no filter is required to identify the real roots from the list of complex roots, since in that case we + already know that all roots are real.\ +definition solve_depressed_cubic_real :: "real \ real \ real list" where + "solve_depressed_cubic_real e f = (case solve_depressed_cubic_Cardano_real e f + of Some y \ [y] + | None \ map Re (solve_depressed_cubic_complex (of_real e) (of_real f)))" + +lemma solve_depressed_cubic_real_code[code]: "solve_depressed_cubic_real e f = + (if e = 0 then [root 3 (-f)] else + let v = e ^ 3 / 27; + f2 = f / 2; + f2v = f2^2 + v in + if f2v > 0 then + let u = -f2 + sqrt f2v; + rt = root 3 u + in [rt - e / (3 * rt)] + else + let ce3 = of_real e / 3; + u = - of_real f2 + csqrt (of_real f2v) in + map Re (remdups (map (\rt. rt - ce3 / rt) (all_croots 3 u))))" +proof - + have id: "rroots2 [:v, f, 1:] = (let + f2 = f / 2; + bac = f2\<^sup>2 - v in + if bac = 0 then [- f2] else + if bac < 0 then [] else let e = sqrt bac in [- f2 + e, - f2 - e])" for v + unfolding rroots2_def Let_def numeral_2_eq_2 by auto + define foo :: "real \ real \ real option" where + "foo f2v f2 = (case (if f2v = 0 then [- f2] else []) of [] \ None | _ \ None)" + for f2v f2 + have "solve_depressed_cubic_real e f = (if e = 0 then [root 3 (-f)] else + let v = e ^ 3 / 27; + f2 = f / 2; + f2v = f2\<^sup>2 + v in + if f2v > 0 then + let u = -f2 + sqrt f2v; + rt = root 3 u + in [rt - e / (3 * rt)] + else + (case foo f2v f2 of + None \ let u = - cor f2 + csqrt (cor f2v) in + map Re + (remdups (map (\z. z - cor e / (3 * z)) (all_croots 3 u))) + | Some y \ []))" + unfolding solve_depressed_cubic_real_def solve_depressed_cubic_Cardano_real_def + solve_depressed_cubic_complex_code + Let_def id foo_def + by (auto split: if_splits) + also have id: "foo f2v f2 = None" + for f2v f2 unfolding foo_def by auto + ultimately show ?thesis by (auto simp: Let_def) +qed + +lemma solve_depressed_cubic_real: "y \ set (solve_depressed_cubic_real e f) + \ (y^3 + e * y + f = 0)" +proof (cases "solve_depressed_cubic_Cardano_real e f") + case (Some x) + show ?thesis unfolding solve_depressed_cubic_real_def Some option.simps + using solve_depressed_cubic_Cardano_real[OF Some] by auto +next + case None + from this[unfolded solve_depressed_cubic_Cardano_real_def Let_def rroots2_def] + have disc: "0 \ discriminant_cubic_depressed e f" unfolding discriminant_cubic_depressed_def + by (auto split: if_splits simp: numeral_2_eq_2) + let ?c = "complex_of_real" + let ?y = "?c y" + let ?e = "?c e" + let ?f = "?c f" + have sub: "set (solve_depressed_cubic_complex ?e ?f) \ \" + proof + fix y + assume y: "y \ set (solve_depressed_cubic_complex ?e ?f)" + show "y \ \" + by (rule solve_cubic_depressed_Cardano_all_real_roots[OF disc y[unfolded solve_depressed_cubic_complex]]) + qed + have "y^3 + e * y + f = 0 \ (?c (y^3 + e * y + f) = ?c 0)" unfolding of_real_eq_iff by simp + also have "\ \ ?y^3 + ?e * ?y + ?f = 0" by simp + also have "\ \ ?y \ set (solve_depressed_cubic_complex ?e ?f)" + unfolding solve_depressed_cubic_complex .. + also have "\ \ y \ Re ` set (solve_depressed_cubic_complex ?e ?f)" using sub by force + finally show ?thesis unfolding solve_depressed_cubic_real_def None by auto +qed + +text \Combining the various algorithms\ + +lemma degree3_coeffs: "degree p = 3 \ + \ a b c d. p = [: d, c, b, a :] \ a \ 0" + by (metis One_nat_def Suc_1 degree2_coeffs degree_pCons_eq_if nat.inject numeral_3_eq_3 pCons_cases zero_neq_numeral) + +definition roots3_generic :: "('a :: field_char_0 \ 'a \ 'a list) \ 'a poly \ 'a list" where + "roots3_generic depressed_solver p = (let + cs = coeffs p; + a = cs ! 3; b = cs ! 2; c = cs ! 1; d = cs ! 0; + a3 = 3 * a; + ba3 = b / a3; + b2 = b * b; + b3 = b2 * b; + e = (c - b2 / a3) / a; + f = (d + 2 * b3 / (27 * a^2) - b * c / a3) / a; + roots = depressed_solver e f + in map (\ y. y - ba3) roots)" + +lemma roots3_generic: assumes deg: "degree p = 3" + and solver: "\ e f y. y \ set (depressed_solver e f) \ y^3 + e * y + f = 0" + shows "set (roots3_generic depressed_solver p) = {x. poly p x = 0}" +proof - + note powers = field_simps power3_eq_cube power2_eq_square + from degree3_coeffs[OF deg] obtain a b c d where + p: "p = [:d,c,b,a:]" and a: "a \ 0" by auto + have coeffs: "coeffs p ! 3 = a" "coeffs p ! 2 = b" "coeffs p ! 1 = c" "coeffs p ! 0 = d" + unfolding p using a by auto + define e where "e = (c - b^2 / (3 * a)) / a" + define f where "f = (d + 2 * b^3 / (27 * a^2) - b * c / (3 * a)) / a" + note def = roots3_generic_def[of depressed_solver p, unfolded Let_def coeffs, + folded power3_eq_cube, folded power2_eq_square, folded e_def f_def] + { + fix x :: 'a + define y where "y = x + b / (3 * a)" + have xy: "x = y - b / (3 * a)" unfolding y_def by auto + have "poly p x = 0 \ a * x^3 + b * x^2 + c * x + d = 0" unfolding p + by (simp add: powers) + also have "\ \ (y ^ 3 + e * y + f = 0)" + unfolding to_depressed_cubic[OF a xy e_def f_def] .. + also have "\ \ y \ set (depressed_solver e f)" + unfolding solver .. + also have "\ \ x \ set (roots3_generic depressed_solver p)" unfolding xy def by auto + finally have "poly p x = 0 \ x \ set (roots3_generic depressed_solver p)" by auto + } + thus ?thesis by auto +qed + +definition croots3 :: "complex poly \ complex list" where + "croots3 = roots3_generic solve_depressed_cubic_complex" + +lemma croots3: assumes deg: "degree p = 3" + shows "set (croots3 p) = { x. poly p x = 0}" + unfolding croots3_def by (rule roots3_generic[OF deg solve_depressed_cubic_complex]) + +definition rroots3 :: "real poly \ real list" where + "rroots3 = roots3_generic solve_depressed_cubic_real" + +lemma rroots3: assumes deg: "degree p = 3" + shows "set (rroots3 p) = { x. poly p x = 0}" + unfolding rroots3_def by (rule roots3_generic[OF deg solve_depressed_cubic_real]) + +end \ No newline at end of file diff --git a/thys/Cubic_Quartic_Equations/Ferraris_Formula.thy b/thys/Cubic_Quartic_Equations/Ferraris_Formula.thy new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/Ferraris_Formula.thy @@ -0,0 +1,88 @@ +section \Ferrari's formula for solving quartic equations\ + +theory Ferraris_Formula + imports + Polynomial_Factorization.Explicit_Roots + Polynomial_Interpolation.Ring_Hom_Poly + Complex_Geometry.More_Complex +begin + +subsection \Translation to depressed case\ + +text \Solving an arbitrary quartic equation can easily be turned into the depressed case, i.e., where + there is no cubic part.\ + +lemma to_depressed_quartic: fixes a4 :: "'a :: field_char_0" + assumes a4: "a4 \ 0" + and b: "b = a3 / a4" + and c: "c = a2 / a4" + and d: "d = a1 / a4" + and e: "e = a0 / a4" + and p: "p = c - (3/8) * b^2" + and q: "q = (b^3 - 4*b*c + 8 * d) / 8" + and r: "r = ( -3 * b^4 + 256 * e - 64 * b * d + 16 * b^2 * c) / 256" + and x: "x = y - b/4" +shows "a4 * x^4 + a3 * x^3 + a2 * x^2 + a1 * x + a0 = 0 + \ y^4 + p * y^2 + q * y + r = 0" +proof - + have "a4 * x^4 + a3 * x^3 + a2 * x^2 + a1 * x + a0 = 0 \ + (a4 * x^4 + a3 * x^3 + a2 * x^2 + a1 * x + a0) / a4 = 0" using a4 by auto + also have "(a4 * x^4 + a3 * x^3 + a2 * x^2 + a1 * x + a0) / a4 + = x^4 + b * x^3 + c * x^2 + d * x + e" + unfolding b c d e using a4 by (simp add: field_simps) + also have "\ = y^4 + p * y^2 + q * y + r" + unfolding x p q r + by (simp add: field_simps power4_eq_xxxx power3_eq_cube power2_eq_square) + finally show ?thesis . +qed + +lemma biquadratic_solution: fixes p q :: "'a :: field_char_0" + shows "y^4 + p * y^2 + q = 0 \ (\ z. z^2 + p * z + q = 0 \ z = y^2)" + by (auto simp: field_simps power4_eq_xxxx power2_eq_square) + +subsection \Solving the depressed case via Ferrari's formula\ + +lemma depressed_quartic_Ferrari: fixes p q r :: "'a :: field_char_0" + assumes cubic_root: "8*m^3 + (8 * p) * m^2 + (2 * p^2 - 8 * r) * m - q^2 = 0" + and q0: "q \ 0" \ \otherwise m might be zero, so a is zero and then there is a division by zero in b1 and b2\ + and sqrt: "a * a = 2 * m" (* a = sqrt(2m), where the square-root might not be defined *) + and b1: "b1 = p / 2 + m - q / (2 * a)" + and b2: "b2 = p / 2 + m + q / (2 * a)" + shows "y^4 + p * y^2 + q * y + r = 0 \ poly [:b1,a,1:] y = 0 \ poly [:b2,-a,1:] y = 0" +proof - + let ?N = "y^2 + p / 2 + m" + let ?M = "a * y - q / (2 * a)" + from cubic_root q0 have m0: "m \ 0" by auto + from sqrt m0 have a0: "a \ 0" by auto + define N where "N = ?N" + define M where "M = ?M" + note powers = field_simps power4_eq_xxxx power3_eq_cube power2_eq_square + from cubic_root have "8*m^3 = - (8 * p) * m^2 - (2 * p^2 - 8 * r) * m + q^2" + by (simp add: powers) + from arg_cong[OF this, of "(*) 4"] + have id: "32 * m^3 = 4 * (- (8 * p) * m^2 - (2 * p^2 - 8 * r) * m + q^2)" by simp + let ?add = "2 * y^2 * m + p * m + m^2" + have "y^4 + p * y^2 + q * y + r = 0 \ + (y^2 + p / 2)^2 = -q * y - r + p^2 / 4" + by (simp add: powers, algebra) + also have "\ \ (y^2 + p / 2)^2 + ?add = -q * y - r + p^2 / 4 + ?add" by simp + also have "\ \ ?N^2 = 2 * m * y^2 - q * y + m^2 + m * p + p^2 / 4 - r" + by (simp add: powers) + also have "2 * m * y^2 - q * y + m^2 + m * p + p^2 / 4 - r = + ?M ^ 2" using m0 id a0 sqrt by (simp add: powers, algebra) + also have "?N^2 = ?M^2 \ (?N + ?M) * (?N - ?M) = 0" + unfolding N_def[symmetric] M_def[symmetric] by algebra + also have "\ \ ?N + ?M = 0 \ ?N - ?M = 0" by simp + also have "?N + ?M = y\<^sup>2 + a * y + b1" + by (simp add: b1) + also have "?N - ?M = y\<^sup>2 - a * y + b2" + by (simp add: b2) + also have "y\<^sup>2 + a * y + b1 = 0 \ poly [:b1,a,1:] y = 0" + by (simp add: powers) + also have "y\<^sup>2 - a * y + b2 = 0 \ poly [:b2,-a,1:] y = 0" + by (simp add: powers) + finally show ?thesis . +qed + + +end \ No newline at end of file diff --git a/thys/Cubic_Quartic_Equations/Min_Int_Poly_Impl.thy b/thys/Cubic_Quartic_Equations/Min_Int_Poly_Impl.thy new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/Min_Int_Poly_Impl.thy @@ -0,0 +1,171 @@ +section \Implementation of the minimal polynomial of a real or complex algebraic number\ + +text \This theory provides implementation of the minimal-representing-polynomial of an algebraic + number, for both the real-numbers and the complex-numbers.\ + +theory Min_Int_Poly_Impl + imports + Hermite_Lindemann.Min_Int_Poly + Algebraic_Numbers.Real_Algebraic_Numbers + Algebraic_Numbers.Complex_Algebraic_Numbers +begin + +definition min_int_poly_real_alg :: "real_alg \ int poly" where + "min_int_poly_real_alg x = (case info_real_alg x of Inl r \ poly_rat r | Inr (p,_) \ p)" + +lemma min_int_poly_of_rat: "min_int_poly (of_rat r :: 'a :: {field_char_0, field_gcd}) = poly_rat r" + by (intro min_int_poly_unique, auto) + +lemma min_int_poly_real_alg: "min_int_poly_real_alg x = min_int_poly (real_of x)" +proof (cases "info_real_alg x") + case (Inl r) + show ?thesis unfolding info_real_alg(2)[OF Inl] min_int_poly_real_alg_def Inl + by (simp add: min_int_poly_of_rat) +next + case (Inr pair) + then obtain p n where Inr: "info_real_alg x = Inr (p,n)" by (cases pair, auto) + hence "poly_cond p" by (transfer, transfer, auto simp: info_2_card) + hence "min_int_poly (real_of x) = p" using info_real_alg(1)[OF Inr] + by (intro min_int_poly_unique, auto) + thus ?thesis unfolding min_int_poly_real_alg_def Inr by simp +qed + +definition min_int_poly_real :: "real \ int poly" where + [simp]: "min_int_poly_real = min_int_poly" + +lemma min_int_poly_real_code_unfold [code_unfold]: "min_int_poly = min_int_poly_real" + by simp + +lemma min_int_poly_real_code[code]: "min_int_poly_real (real_of x) = min_int_poly_real_alg x" + by (simp add: min_int_poly_real_alg) + +text \Now let us head for the complex numbers\ + +definition complex_poly :: "int poly \ int poly \ int poly list" where + "complex_poly re im = (let i = [:1,0,1:] + in factors_of_int_poly (poly_add re (poly_mult im i)))" + +lemma complex_poly: assumes re: "re represents (Re x)" + and im: "im represents (Im x)" + shows "\ f \ set (complex_poly re im). f represents x" "\ f. f \ set (complex_poly re im) \ poly_cond f" +proof - + let ?p = "poly_add re (poly_mult im [:1, 0, 1:])" + from re have re: "re represents complex_of_real (Re x)" by simp + from im have im: "im represents complex_of_real (Im x)" by simp + have "[:1,0,1:] represents \" by auto + from represents_add[OF re represents_mult[OF im this]] + have "?p represents of_real (Re x) + complex_of_real (Im x) * \" by simp + also have "of_real (Re x) + complex_of_real (Im x) * \ = x" + by (metis complex_eq mult.commute) + finally have p: "?p represents x" by auto + have "factors_of_int_poly ?p = complex_poly re im" + unfolding complex_poly_def Let_def by simp + from factors_of_int_poly(1)[OF this] factors_of_int_poly(2)[OF this, of x] p + show "\ f \ set (complex_poly re im). f represents x" "\ f. f \ set (complex_poly re im) \ poly_cond f" + unfolding represents_def by auto +qed + + +definition algebraic_real :: "real \ bool" where + [simp]: "algebraic_real = algebraic" + +lemma algebraic_real_iff[code_unfold]: "algebraic = algebraic_real" by simp + +lemma algebraic_real_code[code]: "algebraic_real (real_of x) = True" +proof (cases "info_real_alg x") + case (Inl r) + show ?thesis using info_real_alg(2)[OF Inl] by (auto simp: algebraic_of_rat) +next + case (Inr pair) + then obtain p n where Inr: "info_real_alg x = Inr (p,n)" by (cases pair, auto) + from info_real_alg(1)[OF Inr] have "p represents (real_of x)" by auto + thus ?thesis by (auto simp: algebraic_altdef_ipoly) +qed + +lemma algebraic_complex_iff[code_unfold]: "algebraic x \ algebraic (Re x) \ algebraic (Im x)" +proof + assume "algebraic x" + from this[unfolded algebraic_altdef_ipoly] obtain p where "ipoly p x = 0" "p \ 0" by auto + from represents_root_poly[OF this] show "algebraic (Re x) \ algebraic (Im x)" + unfolding represents_def algebraic_altdef_ipoly by auto +next + assume "algebraic (Re x) \ algebraic (Im x)" + from this[unfolded algebraic_altdef_ipoly] obtain re im where + "re represents (Re x)" "im represents (Im x)" by blast + from complex_poly[OF this] show "algebraic x" + unfolding represents_def algebraic_altdef_ipoly by auto +qed + +lemma algebraic_0[simp]: "algebraic 0" + unfolding algebraic_altdef_ipoly + by (intro exI[of _ "[:0,1:]"], auto) + +lemma min_int_poly_complex_of_real[simp]: "min_int_poly (complex_of_real x) = min_int_poly x" +proof (cases "algebraic x") + case False + hence "\ algebraic (complex_of_real x)" unfolding algebraic_complex_iff by auto + with False show ?thesis unfolding min_int_poly_def by auto +next + case True + from min_int_poly_represents[OF True] + have "min_int_poly x represents x" by auto + thus ?thesis + by (intro min_int_poly_unique, auto simp: lead_coeff_min_int_poly_pos) +qed + + + +text \TODO: the implemention might be tuned, since the search process should be faster when + using interval arithmetic to figure out the correct factor. + (One might also implement the search via checking @{term "ipoly f x = 0"}, but because of complex-algebraic-number + arithmetic, I think that search would be slower than the current one via "@{term "x \ set (complex_roots_of_int_poly f)"}\ +definition min_int_poly_complex :: "complex \ int poly" where + "min_int_poly_complex x = (if algebraic x then if Im x = 0 then min_int_poly_real (Re x) + else the (find (\ f. x \ set (complex_roots_of_int_poly f)) (complex_poly (min_int_poly (Re x)) (min_int_poly (Im x)))) + else [:0,1:])" + +lemma min_int_poly_complex[code_unfold]: "min_int_poly = min_int_poly_complex" +proof (standard) + fix x + define fs where "fs = complex_poly (min_int_poly (Re x)) (min_int_poly (Im x))" + let ?f = "min_int_poly_complex x" + show "min_int_poly x = ?f" + proof (cases "algebraic x") + case False + thus ?thesis unfolding min_int_poly_def min_int_poly_complex_def by auto + next + case True + show ?thesis + proof (cases "Im x = 0") + case *: True + have id: "?f = min_int_poly_real (Re x)" unfolding min_int_poly_complex_def * using True by auto + show ?thesis unfolding id min_int_poly_real_code_unfold[symmetric] min_int_poly_complex_of_real[symmetric] + using * by (intro arg_cong[of _ _ min_int_poly] complex_eqI, auto) + next + case False + from True[unfolded algebraic_complex_iff] have "algebraic (Re x)" "algebraic (Im x)" by auto + from complex_poly[OF min_int_poly_represents[OF this(1)] min_int_poly_represents[OF this(2)]] + have fs: "\ f \ set fs. ipoly f x = 0" "\ f. f \ set fs \ poly_cond f" unfolding fs_def by auto + let ?fs = "find (\ f. ipoly f x = 0) fs" + let ?fs' = "find (\ f. x \ set (complex_roots_of_int_poly f)) fs" + have "?f = the ?fs'" unfolding min_int_poly_complex_def fs_def + using True False by auto + also have "?fs' = ?fs" + by (rule find_cong[OF refl], subst complex_roots_of_int_poly, insert fs, auto) + finally have id: "?f = the ?fs" . + from fs(1) have "?fs \ None" unfolding find_None_iff by auto + then obtain f where Some: "?fs = Some f" by auto + from find_Some_D[OF this] fs(2)[of f] + show ?thesis unfolding id Some + by (intro min_int_poly_unique, auto) + qed + qed +qed + +(* outcommented tests, since time-consuming: + +value (code) "min_int_poly (sqrt 2 + 3)" +value (code) "min_int_poly (sqrt 2 + \)" + +*) +end diff --git a/thys/Cubic_Quartic_Equations/Quartic_Polynomials.thy b/thys/Cubic_Quartic_Equations/Quartic_Polynomials.thy new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/Quartic_Polynomials.thy @@ -0,0 +1,229 @@ +section \Algorithms to compute all complex and real roots of a quartic polynomial\ + +theory Quartic_Polynomials + imports + Ferraris_Formula + Cubic_Polynomials +begin + +text \The complex case is straight-forward\ + +definition solve_depressed_quartic_complex :: "complex \ complex \ complex \ complex list" where + "solve_depressed_quartic_complex p q r = remdups (if q = 0 then + (concat (map (\ z. let y = csqrt z in [y,-y]) (croots2 [:r,p,1:]))) else + let cubics = croots3 [: - (q^2), 2 * p^2 - 8 * r, 8 * p, 8:]; + m = hd cubics; \ \select any root of the cubic polynomial\ + a = csqrt (2 * m); + p2m = p / 2 + m; + q2a = q / (2 * a); + b1 = p2m - q2a; + b2 = p2m + q2a + in (croots2 [:b1,a,1:] @ croots2 [:b2,-a,1:]))" + +lemma solve_depressed_quartic_complex: "x \ set (solve_depressed_quartic_complex p q r) + \ (x^4 + p * x^2 + q * x + r = 0)" +proof - + note powers = field_simps power4_eq_xxxx power3_eq_cube power2_eq_square + show ?thesis + proof (cases "q = 0") + case True + have csqrt: "z = x^2 \ (x = csqrt z \ x = - csqrt z)" for z + by (metis power2_csqrt power2_eq_iff) + have "(x ^ 4 + p * x\<^sup>2 + q * x + r = 0) \ (x ^ 4 + p * x\<^sup>2 + r = 0)" + unfolding True by simp + also have "\ \ (\z. z\<^sup>2 + p * z + r = 0 \ z = x\<^sup>2)" unfolding biquadratic_solution by simp + also have "\ \ (\ z. poly [:r,p,1:] z = 0 \ z = x^2)" + by (simp add: powers) + also have "\ \ (\ z \ set (croots2 [:r,p,1:]). z = x^2)" + by (subst croots2[symmetric], auto) + also have "\ \ (\ z \ set (croots2 [:r,p,1:]). x = csqrt z \ x = - csqrt z)" + unfolding csqrt .. + also have "\ \ (x \ set (solve_depressed_quartic_complex p q r))" + unfolding solve_depressed_quartic_complex_def id unfolding True Let_def by auto + finally show ?thesis .. + next + case q0: False + hence id: "(if q = 0 then x else y) = y" for x y :: "complex list" by auto + note powers = field_simps power4_eq_xxxx power3_eq_cube power2_eq_square + let ?poly = "[:- q\<^sup>2, 2 * p\<^sup>2 - 8 * r, 8 * p, 8:]" + from croots3[of ?poly] have croots: "set (croots3 ?poly) = {x. poly ?poly x = 0}" by auto + from fundamental_theorem_of_algebra_alt[of ?poly] + have "{x. poly ?poly x = 0} \ {}" by auto + with croots have "croots3 ?poly \ []" by auto + then obtain m rest where rts: "croots3 ?poly = m # rest" by (cases "croots3 ?poly", auto) + hence hd: "hd (croots3 ?poly) = m" by auto + from croots[unfolded rts] have "poly ?poly m = 0" by auto + hence mrt: "8*m^3 + (8 * p) * m^2 + (2 * p^2 - 8 * r) * m - q^2 = 0" + and m0: "m \ 0" using q0 + by (auto simp: powers) + define b1 where "b1 = p / 2 + m - q / (2 * csqrt (2 * m))" + define b2 where "b2 = p / 2 + m + q / (2 * csqrt (2 * m))" + have csqrt: "csqrt x * csqrt x = x" for x by (metis power2_csqrt power2_eq_square) + show ?thesis unfolding solve_depressed_quartic_complex_def id Let_def set_remdups set_append hd + unfolding b1_def[symmetric] b2_def[symmetric] + apply (subst depressed_quartic_Ferrari[OF mrt q0 csqrt b1_def b2_def]) + apply (subst (1 2) croots2[symmetric], auto) + done + qed +qed + +text \The main difference in the real case is that a specific cubic root has to be used, namely + a positive one. In the soundness proof we show that such a cubic root always exists.\ + +definition solve_depressed_quartic_real :: "real \ real \ real \ real list" where + "solve_depressed_quartic_real p q r = remdups (if q = 0 then + (concat (map (\ z. rroots2 [:-z,0,1:]) (rroots2 [:r,p,1:]))) else + let cubics = rroots3 [: - (q^2), 2 * p^2 - 8 * r, 8 * p, 8:]; + m = the (find (\ m. m > 0) cubics); \ \select any positive root of the cubic polynomial\ + a = sqrt (2 * m); + p2m = p / 2 + m; + q2a = q / (2 * a); + b1 = p2m - q2a; + b2 = p2m + q2a + in (rroots2 [:b1,a,1:] @ rroots2 [:b2,-a,1:]))" + +lemma solve_depressed_quartic_real: "x \ set (solve_depressed_quartic_real p q r) + \ (x^4 + p * x^2 + q * x + r = 0)" +proof - + note powers = field_simps power4_eq_xxxx power3_eq_cube power2_eq_square + show ?thesis + proof (cases "q = 0") + case True + have sqrt: "z = x^2 \ (x \ set (rroots2 [:-z,0,1:]))" for z + by (subst rroots2[symmetric], auto simp: powers) + have "(x ^ 4 + p * x\<^sup>2 + q * x + r = 0) \ (x ^ 4 + p * x\<^sup>2 + r = 0)" + unfolding True by simp + also have "\ \ (\z. z\<^sup>2 + p * z + r = 0 \ z = x\<^sup>2)" unfolding biquadratic_solution by simp + also have "\ \ (\ z. poly [:r,p,1:] z = 0 \ z = x^2)" + by (simp add: powers) + also have "\ \ (\ z \ set (rroots2 [:r,p,1:]). z = x^2)" + by (subst rroots2[symmetric], auto) + also have "\ \ (\ z \ set (rroots2 [:r,p,1:]). x \ set (rroots2 [:-z,0,1:]))" + unfolding sqrt .. + also have "\ \ (x \ set (solve_depressed_quartic_real p q r))" + unfolding solve_depressed_quartic_real_def id unfolding True Let_def by auto + finally show ?thesis .. + next + case q0: False + hence id: "(if q = 0 then x else y) = y" for x y :: "real list" by auto + note powers = field_simps power4_eq_xxxx power3_eq_cube power2_eq_square + let ?poly = "[:- q\<^sup>2, 2 * p\<^sup>2 - 8 * r, 8 * p, 8:]" + + define cubics where "cubics = rroots3 ?poly" + from rroots3[of ?poly, folded cubics_def] + have rroots: "set cubics = {x. poly ?poly x = 0}" by auto + from odd_degree_imp_real_root[of ?poly] + have "{x. poly ?poly x = 0} \ {}" by auto + with rroots have "cubics \ []" by auto + have "\ m. m \ set cubics \ m > 0" + proof (rule ccontr) + assume "\ ?thesis" + from this[unfolded rroots] have rt: "poly ?poly m = 0 \ m \ 0" for m by auto + have "poly ?poly 0 = - (q^2)" by simp + also have "\ < 0" using q0 by auto + finally have lt: "poly ?poly 0 \ 0" by simp + from poly_pinfty_gt_lc[of ?poly] obtain n0 where "\ n. n \ n0 \ 8 \ poly ?poly n" by auto + from this[of "max n0 0"] have "poly ?poly (max n0 0) \ 0" by auto + from IVT[of "poly ?poly", OF lt this] obtain m where "m \ 0" and poly: "poly ?poly m = 0" by auto + from rt[OF this(2)] this(1) have "m = 0" by auto + thus False using poly q0 by simp + qed + hence "find (\ m. m > 0) cubics \ None" unfolding find_None_iff by auto + then obtain m where find: "find (\ m. m > 0) cubics = Some m" by auto + from find_Some_D[OF this] have m: "m \ set cubics" and m_0: "m > 0" by auto + with rroots have "poly ?poly m = 0" by auto + hence mrt: "8*m^3 + (8 * p) * m^2 + (2 * p^2 - 8 * r) * m - q^2 = 0" + by (auto simp: powers) + from m_0 have sqrt: "sqrt (2 * m) * sqrt (2 * m) = 2 * m" by simp + define b1 where "b1 = p / 2 + m - q / (2 * sqrt (2 * m))" + define b2 where "b2 = p / 2 + m + q / (2 * sqrt (2 * m))" + show ?thesis unfolding solve_depressed_quartic_real_def id Let_def set_remdups set_append + cubics_def[symmetric] find option.sel + unfolding b1_def[symmetric] b2_def[symmetric] + apply (subst depressed_quartic_Ferrari[OF mrt q0 sqrt b1_def b2_def]) + apply (subst (1 2) rroots2[symmetric], auto) + done + qed +qed + +text \Combining the various algorithms\ + +lemma numeral_4_eq_4: "4 = Suc (Suc (Suc (Suc 0)))" + by (simp add: eval_nat_numeral) + +lemma degree4_coeffs: "degree p = 4 \ + \ a b c d e. p = [: e, d, c, b, a :] \ a \ 0" + using degree3_coeffs degree_pCons_eq_if nat.inject numeral_3_eq_3 numeral_4_eq_4 pCons_cases zero_neq_numeral + by metis + +definition roots4_generic :: "('a :: field_char_0 \ 'a \ 'a \ 'a list) \ 'a poly \ 'a list" where + "roots4_generic depressed_solver p = (let + cs = coeffs p; + cs = coeffs p; + a4 = cs ! 4; a3 = cs ! 3; a2 = cs ! 2; a1 = cs ! 1; a0 = cs ! 0; + b = a3 / a4; + c = a2 / a4; + d = a1 / a4; + e = a0 / a4; + b2 = b * b; + b3 = b2 * b; + b4 = b3 * b; + b4' = b / 4; + p = c - 3/8 * b2; + q = (b3 - 4*b*c + 8 * d) / 8; + r = ( -3 * b4 + 256 * e - 64 * b * d + 16 * b2 * c) / 256; + roots = depressed_solver p q r + in map (\ y. y - b4') roots)" + +lemma roots4_generic: assumes deg: "degree p = 4" + and solver: "\ p q r y. y \ set (depressed_solver p q r) \ y^4 + p * y^2 + q * y + r = 0" + shows "set (roots4_generic depressed_solver p) = {x. poly p x = 0}" +proof - + note powers = field_simps power4_eq_xxxx power3_eq_cube power2_eq_square + from degree4_coeffs[OF deg] obtain a4 a3 a2 a1 a0 where + p: "p = [:a0,a1,a2,a3,a4:]" and a4: "a4 \ 0" by auto + have coeffs: "coeffs p ! 4 = a4" "coeffs p ! 3 = a3" "coeffs p ! 2 = a2" "coeffs p ! 1 = a1" "coeffs p ! 0 = a0" + unfolding p using a4 by auto + define b where "b = a3 / a4" + define c where "c = a2 / a4" + define d where "d = a1 / a4" + define e where "e = a0 / a4" + note def = roots4_generic_def[of depressed_solver p, unfolded Let_def coeffs, folded b_def c_def d_def e_def, + folded power4_eq_xxxx, folded power3_eq_cube, folded power2_eq_square] + let ?p = p + { + fix x + define y where "y = x + b / 4" + define p where "p = c - (3/8) * b^2" + define q where "q = (b^3 - 4*b*c + 8 * d) / 8" + define r where "r = ( -3 * b^4 + 256 * e - 64 * b * d + 16 * b^2 * c) / 256" + note def = def[folded p_def q_def r_def] + have xy: "x = y - b / 4" unfolding y_def by auto + have "poly ?p x = 0 \ a4 * x^4 + a3 * x^3 + a2 * x^2 + a1 * x + a0 = 0" unfolding p + by (simp add: powers) + also have "\ \ (y ^ 4 + p * y\<^sup>2 + q * y + r = 0)" + unfolding to_depressed_quartic[OF a4 b_def c_def d_def e_def p_def q_def r_def xy] .. + also have "\ \ y \ set (depressed_solver p q r)" + unfolding solver .. + also have "\ \ x \ set (roots4_generic depressed_solver ?p)" unfolding xy def by auto + finally have "poly ?p x = 0 \ x \ set (roots4_generic depressed_solver ?p)" by auto + } + thus ?thesis by simp +qed + +definition croots4 :: "complex poly \ complex list" where + "croots4 = roots4_generic solve_depressed_quartic_complex" + +lemma croots4: assumes deg: "degree p = 4" + shows "set (croots4 p) = { x. poly p x = 0}" + unfolding croots4_def by (rule roots4_generic[OF deg solve_depressed_quartic_complex]) + +definition rroots4 :: "real poly \ real list" where + "rroots4 = roots4_generic solve_depressed_quartic_real" + +lemma rroots4: assumes deg: "degree p = 4" + shows "set (rroots4 p) = { x. poly p x = 0}" + unfolding rroots4_def by (rule roots4_generic[OF deg solve_depressed_quartic_real]) + + +end \ No newline at end of file diff --git a/thys/Cubic_Quartic_Equations/ROOT b/thys/Cubic_Quartic_Equations/ROOT new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/ROOT @@ -0,0 +1,12 @@ +chapter AFP + +session Cubic_Quartic_Equations (AFP) = Algebraic_Numbers + + options [timeout = 600] + sessions + Complex_Geometry + Hermite_Lindemann + theories + Quartic_Polynomials + document_files + "root.tex" + "root.bib" diff --git a/thys/Cubic_Quartic_Equations/document/root.bib b/thys/Cubic_Quartic_Equations/document/root.bib new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/document/root.bib @@ -0,0 +1,17 @@ +@book{AM, + title = {Ars Magna, The Great Art or the Rules of Algebra}, + author = {Gerolamo Cardano}, + year = 1545, + note = {\url{https://en.wikipedia.org/wiki/Ars_Magna_(Cardano_book)}} +} + +@article{Algebraic_Numbers-AFP, + author = {René Thiemann and Akihisa Yamada and Sebastiaan Joosten}, + title = {Algebraic Numbers in {I}sabelle/{HOL}}, + journal = {Archive of Formal Proofs}, + month = dec, + year = 2015, + note = {\url{https://isa-afp.org/entries/Algebraic_Numbers.html}, + Formal proof development}, + ISSN = {2150-914x}, +} diff --git a/thys/Cubic_Quartic_Equations/document/root.tex b/thys/Cubic_Quartic_Equations/document/root.tex new file mode 100644 --- /dev/null +++ b/thys/Cubic_Quartic_Equations/document/root.tex @@ -0,0 +1,46 @@ +\documentclass[11pt,a4paper]{article} + +\usepackage{isabelle,isabellesym} +\usepackage{url} + +\usepackage{pdfsetup} + +% urls in roman style, theory text in math-similar italics +\urlstyle{rm} +\isabellestyle{it} + +% for uniform font size +%\renewcommand{\isastyle}{\isastyleminor} + + +\begin{document} + +\title{Solving Cubic and Quartic Equations} +\author{Ren\'e Thiemann} +\maketitle + +\begin{abstract} +We formalize Cardano's formula to solve a cubic equation +\[ +ax^3 + bx^2 + cx + d = 0, +\] +as well as Ferrari's formula to solve a quartic equation \cite{AM}. +We further turn both formulas into executable algorithms +based on the algebraic number implementation in the AFP \cite{Algebraic_Numbers-AFP}. +To this end we also slightly extended this library, namely by making +the minimal polynomial of an algebraic number executable, and by defining and +implementing $n$-th roots of complex numbers. +\end{abstract} + +\tableofcontents + +% sane default for proof documents +\parindent 0pt\parskip 0.5ex + +% generated text of all theories +\input{session} + +\bibliographystyle{abbrv} +\bibliography{root} + +\end{document} diff --git a/thys/Design_Theory/BIBD.thy b/thys/Design_Theory/BIBD.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/BIBD.thy @@ -0,0 +1,943 @@ +(* Title: BIBD + Author: Chelsea Edmonds +*) + +theory BIBD imports Block_Designs +begin + +section \BIBD's\ +text \BIBD's are perhaps the most commonly studied type of design in combinatorial design theory, +and usually the first type of design explored in a design theory course. +These designs are a type of t-design, where $t = 2$\ + +subsection \BIBD Basics\ +locale bibd = t_design \ \ \ 2 \ + for point_set ("\") and block_collection ("\") + and u_block_size ("\") and index ("\") + +begin + +lemma min_block_size_2: "\ \ 2" + using block_size_t by simp + +lemma points_index_pair: "y \ \ \ x \ \ \ x \ y \ size ({# bl \# \ . {x, y} \ bl#}) = \" + using balanced card_2_iff empty_subsetI insert_subset points_index_def + by (metis of_nat_numeral) + +lemma index_one_empty_rm_blv [simp]: + assumes "\ = 1" and " blv \# \" and "p \ blv" and "card p = 2" + shows "{#bl \# remove1_mset blv \ . p \ bl#} = {#}" +proof - + have blv_in: "blv \# filter_mset ((\) p) \" + using assms by simp + have "p \ \" using assms wellformed by auto + then have "size (filter_mset ((\) p) \) = 1" + using balanced assms by (simp add: points_index_def) + then show ?thesis using blv_in filter_diff_mset filter_single_mset + by (metis (no_types, lifting) add_mset_eq_single assms(3) insert_DiffM size_1_singleton_mset) +qed + +lemma index_one_alt_bl_not_exist: + assumes "\ = 1" and " blv \# \" and "p \ blv" and "card p = 2" + shows" \ bl. bl \# remove1_mset blv \ \ \ (p \ bl) " + using index_one_empty_rm_blv + by (metis assms(1) assms(2) assms(3) assms(4) filter_mset_empty_conv) + +subsection \Necessary Conditions for Existence\ + +text \The necessary conditions on the existence of a $(v, k, \lambda)$-bibd are one of the +fundamental first theorems on designs. Proofs based off MATH3301 lecture notes \cite{HerkeLectureNotes2016} + and Stinson \cite{stinsonCombinatorialDesignsConstructions2004}\ + +lemma necess_cond_1_rhs: + assumes "x \ \" + shows "size ({# p \# (mset_set (\ - {x}) \# {# bl \# \ . x \ bl #}). fst p \ snd p#}) = \ * (\- 1)" +proof - + let ?M = "mset_set (\ - {x})" + let ?B = "{# bl \# \ . x \ bl #}" + have m_distinct: "distinct_mset ?M" using assms mset_points_distinct_diff_one by simp + have y_point: "\ y . y \# ?M \ y \ \" using assms + by (simp add: finite_sets) + have b_contents: "\ bl. bl \# ?B \ x \ bl" using assms by auto + have "\ y. y \# ?M \ y \ x" using assms + by (simp add: finite_sets) + then have "\ y .y \# ?M \ size ({# bl \# ?B . {x, y} \ bl#}) = nat \" + using points_index_pair filter_filter_mset_ss_member y_point assms finite_sets index_ge_zero + by (metis nat_0_le nat_int_comparison(1)) + then have "\ y .y \# ?M \ size ({# bl \# ?B . x \ bl \ y \ bl#}) = nat \" + by auto + then have bl_set_size: "\ y . y \# ?M \ size ({# bl \# ?B . y \ bl#}) = nat \" + using b_contents by (metis (no_types, lifting) filter_mset_cong) + then have final_size: "size (\p\#?M . ({#p#} \# {#bl \# ?B. p \ bl#})) = size (?M) * (nat \)" + using m_distinct size_Union_distinct_cart_prod_filter bl_set_size index_ge_zero by blast + have "size ?M = \ - 1" using v_non_zero + by (simp add: assms(1) finite_sets) + thus ?thesis using final_size + by (simp add: set_break_down_left index_ge_zero) +qed + +lemma necess_cond_1_lhs: + assumes "x \ \" + shows "size ({# p \# (mset_set (\ - {x}) \# {# bl \# \ . x \ bl #}). fst p \ snd p#}) + = (\ rep x) * (\ - 1)" + (is "size ({# p \# (?M \# ?B). fst p \ snd p#}) = (\ rep x) * (\ - 1) ") +proof - + have "\ y. y \# ?M \ y \ x" using assms + by (simp add: finite_sets) + have distinct_m: "distinct_mset ?M" using assms mset_points_distinct_diff_one by simp + have finite_M: "finite (\ - {x})" using finite_sets by auto + have block_choices: "size ?B = \ rep x" + by (simp add: assms(1) point_replication_number_def) + have bl_size: "\ bl \# ?B. card {p \ \ . p \ bl } = \ " using uniform_unfold_point_set by simp + have x_in_set: "\ bl \# ?B . {x} \ {p \ \. p \ bl}" using assms by auto + then have "\ bl \# ?B. card {p \ (\ - {x}) . p \ bl } = card ({p \ \ . p \ bl } - {x})" + by (simp add: set_filter_diff_card) + then have "\ bl \# ?B. card {p \ (\ - {x}) . p \ bl } = \ - 1" + using bl_size x_in_set card_Diff_subset finite_sets k_non_zero by auto + then have "\ bl . bl \# ?B \ size {#p \# ?M . p \ bl#} = nat (\ - 1)" + using assms finite_M card_size_filter_eq by auto + then have "size (\bl\#?B. ( {# p \# ?M . p \ bl #} \# {#bl#})) = size (?B) * nat (\ - 1)" + using distinct_m size_Union_distinct_cart_prod_filter2 by blast + thus ?thesis using block_choices k_non_zero by (simp add: set_break_down_right) +qed + +lemma r_constant: "x \ \ \ (\ rep x) * (\ -1) = \ * (\ - 1)" + using necess_cond_1_rhs necess_cond_1_lhs design_points_nempty by force + +lemma replication_number_value: + assumes "x \ \" + shows "(\ rep x) = \ * (\ - 1) div (\ - 1)" + using min_block_size_2 r_constant assms diff_gt_0_iff_gt diff_self zle_diff1_eq numeral_le_one_iff + by (metis less_int_code(1) linorder_neqE_linordered_idom nonzero_mult_div_cancel_right semiring_norm(69)) + +lemma r_constant_alt: "\ x \ \. \ rep x = \ * (\ - 1) div (\ - 1)" + using r_constant replication_number_value by blast + +end + +text \Using the first necessary condition, it is possible to show that a bibd has +a constant replication number\ + +sublocale bibd \ constant_rep_design \ \ "(\ * (\ - 1) div (\ - 1))" + using r_constant_alt by (unfold_locales) simp_all + +lemma (in t_design) bibdI [intro]: "\ = 2 \ bibd \ \ \ \\<^sub>t" + using t_lt_order block_size_t by (unfold_locales) (simp_all) + +context bibd +begin + +abbreviation "\ \ (\ * (\ - 1) div (\ - 1))" + +lemma necessary_condition_one: + shows "\ * (\ - 1) = \ * (\ - 1)" + using necess_cond_1_rhs necess_cond_1_lhs design_points_nempty rep_number by auto + +lemma bibd_point_occ_rep: + assumes "x \ bl" + assumes "bl \# \" + shows "(\ - {#bl#}) rep x = \ - 1" +proof - + have xin: "x \ \" using assms wf_invalid_point by blast + then have rep: "size {# blk \# \. x \ blk #} = \" using rep_number_unfold_set by simp + have "(\ - {#bl#}) rep x = size {# blk \# (\ - {#bl#}). x \ blk #}" + by (simp add: point_replication_number_def) + then have "(\ - {#bl#}) rep x = size {# blk \# \. x \ blk #} - 1" + by (simp add: assms size_Diff_singleton) + then show ?thesis using assms rep r_gzero by simp +qed + +lemma necess_cond_2_lhs: "size {# x \# (mset_set \ \# \) . (fst x) \ (snd x) #} = \ * \" +proof - + let ?M = "mset_set \" + have "\ p . p \# ?M \ size ({# bl \# \ . p \ bl #}) = nat (\)" + using finite_sets rep_number_unfold_set r_gzero nat_eq_iff2 by auto + then have "size (\p\#?M. ({#p#} \# {#bl \# \. p \ bl#})) = size ?M * nat (\)" + using mset_points_distinct size_Union_distinct_cart_prod_filter by blast + thus ?thesis using r_gzero + by (simp add: set_break_down_left) +qed + +lemma necess_cond_2_rhs: "size {# x \# (mset_set \ \# \) . (fst x) \ (snd x) #} = \*\" + (is "size {# x \# (?M \# ?B). (fst x) \ (snd x) #} = \*\") +proof - + have "\ bl . bl \# ?B \ size ({# p \# ?M . p \ bl #}) = nat \" + using uniform k_non_zero uniform_unfold_point_set_mset by fastforce + then have "size (\bl\#?B. ( {# p \# ?M . p \ bl #} \# {#bl#})) = size (?B) * (nat \)" + using mset_points_distinct size_Union_distinct_cart_prod_filter2 by blast + thus ?thesis using k_non_zero by (simp add: set_break_down_right) +qed + +lemma necessary_condition_two: + shows "\ * \ = \ * \" + using necess_cond_2_lhs necess_cond_2_rhs by simp + +theorem admissability_conditions: +"\ * (\ - 1) = \ * (\ - 1)" +"\ * \ = \ * \" + using necessary_condition_one necessary_condition_two by auto + +subsubsection \BIBD Param Relationships\ + +lemma bibd_block_number: "\ = \ * \ * (\ - 1) div (\ * (\-1))" +proof - + have "\ * \ = (\ * \)" using necessary_condition_two by simp + then have k_dvd: "\ dvd (\ * \)" by (metis dvd_triv_right) + then have "\ = (\ * \) div \" using necessary_condition_two min_block_size_2 by auto + then have "\ = (\ * ((\ * (\ - 1) div (\ - 1)))) div \" by simp + then have "\ = (\ * \ * (\ - 1)) div ((\ - 1)* \)" using necessary_condition_one + necessary_condition_two dvd_div_div_eq_mult dvd_div_eq_0_iff + by (smt (z3) dvd_triv_right mult.assoc mult.commute mult.left_commute mult_eq_0_iff ) + then show ?thesis by (simp add: mult.commute) +qed + +lemma symmetric_condition_1: "\ * (\ - 1) = \ * (\ - 1) \ \ = \ \ \ = \" + using b_non_zero bibd_block_number mult_eq_0_iff necessary_condition_two necessary_condition_one + by auto + +lemma index_lt_replication: "\ < \" +proof - + have 1: "\ * (\ - 1) = \ * (\ - 1)" using admissability_conditions by simp + have lhsnot0: "\ * (\ - 1) \ 0" + using no_zero_divisors rep_not_zero zdiv_eq_0_iff by blast + then have rhsnot0: "\ * (\ - 1) \ 0" using 1 by simp + have "\ - 1 < \ - 1" using incomplete b_non_zero bibd_block_number not_less_eq by fastforce + thus ?thesis using 1 lhsnot0 rhsnot0 + by (smt (verit, best) k_non_zero mult_le_less_imp_less r_gzero) +qed + +lemma index_not_zero: "\ \ 1" + using index_ge_zero index_lt_replication int_one_le_iff_zero_less by fastforce + +lemma r_ge_two: "\ \ 2" + using index_lt_replication index_not_zero by linarith + +lemma block_num_gt_rep: "\ > \" +proof - + have fact: "\ * \ = \ * \" using admissability_conditions by auto + have lhsnot0: "\ * \ \ 0" using k_non_zero b_non_zero by auto + then have rhsnot0: "\ * \ \ 0" using fact by simp + then show ?thesis using incomplete lhsnot0 + using complement_rep_number constant_rep_design.r_gzero incomplete_imp_incomp_block by fastforce +qed + +lemma bibd_subset_occ: + assumes "x \ bl" and "bl \# \" and "card x = 2" + shows "size {# blk \# (\ - {#bl#}). x \ blk #} = \ - 1" +proof - + have index: "size {# blk \# \. x \ blk #} = \" using points_index_def balanced assms + by (metis (full_types) of_nat_numeral subset_eq wf_invalid_point) + then have "size {# blk \# (\ - {#bl#}). x \ blk #} = size {# blk \# \. x \ blk #} - 1" + by (simp add: assms size_Diff_singleton) + then show ?thesis using assms index_not_zero index by simp +qed + +lemma necess_cond_one_param_balance: "\ > \ \ \ > \" + using necessary_condition_two + by (smt mult_nonneg_nonneg nonzero_mult_div_cancel_right of_nat_0_le_iff r_gzero zdiv_mono2) + +subsection \Constructing New bibd's\ +text \There are many constructions on bibd's to establish new bibds (or other types of designs). +This section demonstrates this using both existing constructions, and by defining new constructions.\ +subsubsection \BIBD Complement, Multiple, Combine\ + +lemma comp_params_index_pair: + assumes "{x, y} \ \" + assumes "x \ y" + shows "\\<^sup>C index {x, y} = \ + \ - 2*\" +proof - + have xin: "x \ \" and yin: "y \ \" using assms by auto + have ge: "2*\ \ \" using index_lt_replication + using r_gzero by linarith + have "size {# b \# \ . x \ b \ y \ b#} = \" using points_index_pair assms by simp + then have lambda: "size {# b \# \ . x \ b \ y \ b#} = nat \" + using index_ge_zero by auto + have "\\<^sup>C index {x, y} = size {# b \# \ . x \ b \ y \ b #}" + using complement_index_2 assms by simp + also have "\ = size \ - (size {# b \# \ . \ (x \ b \ y \ b) #})" + using size_filter_neg by blast + also have "... = size \ - (size {# b \# \ . x \ b \ y \ b#})" by auto + also have "... = \ - (size {# b \# \ . x \ b \ y \ b#})" by (simp add: of_nat_diff) + also have "... = \ - (size {# b \# \ . x \ b#} + + size {# b \# \ . y \ b#} - size {# b \# \ . x \ b \ y \ b#})" + by (simp add: mset_size_partition_dep) + also have "... = \ - (nat \ + nat \ - nat (\))" using rep_number_unfold_set lambda xin yin + by (metis (no_types, lifting) nat_int) + finally have "\\<^sup>C index {x, y} = \ - (2*\ - \)" + using index_ge_zero index_lt_replication by linarith + thus ?thesis using ge diff_diff_right by simp +qed + +lemma complement_bibd_index: + assumes "ps \ \" + assumes "card ps = 2" + shows "\\<^sup>C index ps = \ + \ - 2*\" +proof - + obtain x y where set: "ps = {x, y}" using b_non_zero bibd_block_number diff_is_0_eq incomplete + mult_0_right nat_less_le design_points_nempty assms by (metis card_2_iff) + then have "x \ y" using assms by auto + thus ?thesis using comp_params_index_pair assms + by (simp add: set) +qed + +lemma complement_bibd: + assumes "\ \ \ - 2" + shows "bibd \ \\<^sup>C (\ - \) (\ + \ - 2*\)" +proof - + interpret des: incomplete_design \ "\\<^sup>C" "(\ - \)" + using assms complement_incomplete by blast + show ?thesis proof (unfold_locales, simp_all) + show "2 \ des.\" using assms block_size_t by linarith + show "\ps. ps \ \ \ card ps = 2 \ + \\<^sup>C index ps = \ + \ - 2 * (\ * (des.\ - 1) div (\ - 1))" + using complement_bibd_index by simp + show "2 \ des.\ - \" using assms block_size_t by linarith + qed +qed + +lemma multiple_bibd: "n > 0 \ bibd \ (multiple_blocks n) \ (\ * n)" + using multiple_t_design by (simp add: bibd_def) + +end + +locale two_bibd_eq_points = two_t_designs_eq_points \ \ \ \' 2 \ \' + + des1: bibd \ \ \ \ + des2: bibd \ \' \ \' for \ \ \ \' \ \' +begin + +lemma combine_is_bibd: "bibd \\<^sup>+ \\<^sup>+ \ (\ + \')" + by (unfold_locales) + +sublocale combine_bibd: bibd "\\<^sup>+" "\\<^sup>+" "\" "(\ + \')" + by (unfold_locales) + +end + +subsubsection \Derived Designs\ +text \A derived bibd takes a block from a valid bibd as the new point sets, and the intersection +of that block with other blocks as it's block set\ + +locale bibd_block_transformations = bibd + + fixes block :: "'a set" ("bl") + assumes valid_block: "bl \# \" +begin + +definition derived_blocks :: "'a set multiset" ("(\\<^sup>D)") where +"\\<^sup>D \ {# bl \ b . b \# (\ - {#bl#}) #}" + +lemma derive_define_flip: "{# b \ bl . b \# (\ - {#bl#}) #} = \\<^sup>D" + by (simp add: derived_blocks_def inf_sup_aci(1)) + +lemma derived_points_order: "card bl = \" + using uniform valid_block by simp + +lemma derived_block_num: "bl \# \ \ size \\<^sup>D = \ - 1" + apply (simp add: derived_blocks_def size_remove1_mset_If valid_block) + using valid_block int_ops(6) by fastforce + +lemma derived_is_wellformed: "b \# \\<^sup>D \ b \ bl" + by (simp add: derived_blocks_def valid_block) (auto) + +lemma derived_point_subset_orig: "ps \ bl \ ps \ \" + by (simp add: valid_block incomplete_imp_proper_subset subset_psubset_trans) + +lemma derived_obtain_orig_block: + assumes "b \# \\<^sup>D" + obtains b2 where "b = b2 \ bl" and "b2 \# remove1_mset bl \" + using assms derived_blocks_def by auto + +sublocale derived_incidence_sys: incidence_system "bl" "\\<^sup>D" + using derived_is_wellformed valid_block by (unfold_locales) (auto) + +sublocale derived_fin_incidence_system: finite_incidence_system "bl" "\\<^sup>D" + using valid_block finite_blocks by (unfold_locales) simp_all + +lemma derived_blocks_nempty: + assumes "\ b .b \# remove1_mset bl \ \ bl |\| b > 0" + assumes "bld \# \\<^sup>D" + shows "bld \ {}" +proof - + obtain bl2 where inter: "bld = bl2 \ bl" and member: "bl2 \# remove1_mset bl \" + using assms derived_obtain_orig_block by blast + then have "bl |\| bl2 > 0" using assms(1) by blast + thus ?thesis using intersection_number_empty_iff finite_blocks valid_block + by (metis Int_commute dual_order.irrefl inter) +qed + +lemma derived_is_design: + assumes "\ b. b \# remove1_mset bl \ \ bl |\| b > 0" + shows "design bl \\<^sup>D" +proof - + interpret fin: finite_incidence_system "bl" "\\<^sup>D" + by (unfold_locales) + show ?thesis using assms derived_blocks_nempty by (unfold_locales) simp +qed + +lemma derived_is_proper: + assumes "\ b. b \# remove1_mset bl \ \ bl |\| b > 0" + shows "proper_design bl \\<^sup>D" +proof - + interpret des: design "bl" "\\<^sup>D" + using derived_is_design assms by fastforce + have "\ - 1 > 1" using block_num_gt_rep r_ge_two by linarith + then show ?thesis by (unfold_locales) (simp add: derived_block_num valid_block) +qed + + +subsubsection \Residual Designs\ +text \Similar to derived designs, a residual design takes the complement of a block bl as it's new +point set, and the complement of all other blocks with respect to bl.\ + +definition residual_blocks :: "'a set multiset" ("(\\<^sup>R)") where +"\\<^sup>R \ {# b - bl . b \# (\ - {#bl#}) #}" + +lemma residual_order: "card (bl\<^sup>c) = \ - \" + apply (simp add: valid_block wellformed block_complement_size) + using block_size_lt_v derived_points_order by auto + +lemma residual_block_num: "size (\\<^sup>R) = \ - 1" + using b_positive by (simp add: residual_blocks_def size_remove1_mset_If valid_block int_ops(6)) + +lemma residual_obtain_orig_block: + assumes "b \# \\<^sup>R" + obtains bl2 where "b = bl2 - bl" and "bl2 \# remove1_mset bl \" + using assms residual_blocks_def by auto + +lemma residual_blocks_ss: assumes "b \# \\<^sup>R" shows "b \ \" +proof - + have "b \ (bl\<^sup>c)" using residual_obtain_orig_block + by (metis Diff_mono assms block_complement_def in_diffD order_refl wellformed) + thus ?thesis + using block_complement_subset_points by auto +qed + +lemma residual_blocks_exclude: "b \# \\<^sup>R \ x \ b \ x \ bl" + using residual_obtain_orig_block by auto + +lemma residual_is_wellformed: "b \# \\<^sup>R \ b \ (bl\<^sup>c)" + apply (auto simp add: residual_blocks_def) + by (metis DiffI block_complement_def in_diffD wf_invalid_point) + +sublocale residual_incidence_sys: incidence_system "bl\<^sup>c" "\\<^sup>R" + using residual_is_wellformed by (unfold_locales) + +lemma residual_is_finite: "finite (bl\<^sup>c)" + by (simp add: block_complement_def finite_sets) + +sublocale residual_fin_incidence_sys: finite_incidence_system "bl\<^sup>c" "\\<^sup>R" + using residual_is_finite by (unfold_locales) + +lemma residual_blocks_nempty: + assumes "bld \# \\<^sup>R" + assumes "multiplicity bl = 1" + shows "bld \ {}" +proof - + obtain bl2 where inter: "bld = bl2 - bl" and member: "bl2 \# remove1_mset bl \" + using assms residual_blocks_def by auto + then have ne: "bl2 \ bl" using assms + by (metis count_eq_zero_iff in_diff_count less_one union_single_eq_member) + have "card bl2 = card bl" using uniform valid_block member + by (metis in_diffD of_nat_eq_iff) + then have "card (bl2 - bl) > 0" + using finite_blocks member uniform set_card_diff_ge_zero valid_block by (metis in_diffD ne) + thus ?thesis using inter by fastforce +qed + +lemma residual_is_design: "multiplicity bl = 1 \ design (bl\<^sup>c) \\<^sup>R" + using residual_blocks_nempty by (unfold_locales) + +lemma residual_is_proper: + assumes "multiplicity bl = 1" + shows "proper_design (bl\<^sup>c) \\<^sup>R" +proof - + interpret des: design "bl\<^sup>c" "\\<^sup>R" using residual_is_design assms by blast + have "\ - 1 > 1" using r_ge_two block_num_gt_rep by linarith + then show ?thesis using residual_block_num by (unfold_locales) auto +qed + +end + +subsection \Symmetric BIBD's\ +text \Symmetric bibd's are those where the order of the design equals the number of blocks\ + +locale symmetric_bibd = bibd + + assumes symmetric: "\ = \" +begin + +lemma rep_value_sym: "\ = \" + using b_non_zero local.symmetric necessary_condition_two by auto + +lemma symmetric_condition_2: "\ * (\ - 1) = \ * (\ - 1)" + using necessary_condition_one rep_value_sym by auto + +lemma sym_design_vk_gt_kl: + assumes "\ \ \ + 2" + shows "\ - \ > \ - \" +proof (rule ccontr) + assume "\ (\ - \ > \ - \)" + then have "\ \ 2 * \ - \" + by linarith + then have "\ - 1 \ 2 * \ - \ - 1" by linarith + then have "\* (\ - 1) \ \*( 2 * \ - \ - 1)" + using index_ge_zero mult_le_cancel_left by fastforce + then have "\ * (\ - 1) \ \*( 2 * \ - \ - 1)" + by (simp add: symmetric_condition_2) + then have "\ * (\ - 1) - \*( 2 * \ - \ - 1) \ 0" by linarith + then have "(\ - \)*(\ - \ - 1) \ 0" + by (simp add: mult.commute right_diff_distrib') + then have "\ = \ \ \ = \ + 1" + using mult_le_0_iff by force + thus False using assms + by simp +qed + +end + +context bibd +begin + +lemma symmetric_bibdI: "\ = \ \ symmetric_bibd \ \ \ \" + by unfold_locales simp + +lemma symmetric_bibdII: "\ * (\ - 1) = \ * (\ - 1) \ symmetric_bibd \ \ \ \" + using symmetric_condition_1 by unfold_locales blast + +lemma symmetric_not_admissable: "\ * (\ - 1) \ \ * (\ - 1) \ \ symmetric_bibd \ \ \ \" + using symmetric_bibd.symmetric_condition_2 by blast +end + +context symmetric_bibd +begin + +subsubsection \Intersection Property on Symmetric BIBDs\ +text \Below is a proof of an important property on symmetric BIBD's regarding the equivalence +of intersection numbers and the design index. This is an intuitive counting proof, and involved +significantly more work in a formal environment. Based of Lecture Note \cite{HerkeLectureNotes2016}\ + +lemma intersect_mult_set_eq_block: + assumes "blv \# \" + shows "p \# \\<^sub>#{# mset_set (bl \ blv) .bl \# (\ - {#blv#})#} \ p \ blv" +proof (auto, simp add: assms finite_blocks) + assume assm: "p \ blv" + then have "(\ - {#blv#}) rep p > 0" using bibd_point_occ_rep r_ge_two assms by auto + then obtain bl where "bl \# (\ - {#blv#}) \ p \ bl" using assms rep_number_g0_exists by metis + then show "\x\#remove1_mset blv \. p \# mset_set (x \ blv)" + using assms assm finite_blocks by auto +qed + +lemma intersect_mult_set_block_subset_iff: + assumes "blv \# \" + assumes "p \# \\<^sub>#{# mset_set {y .y \ blv \ b2 \ card y = 2} .b2 \# (\ - {#blv#})#}" + shows "p \ blv" +proof (rule subsetI) + fix x + assume asm: "x \ p" + obtain b2 where "p \# mset_set {y . y \ blv \ b2 \ card y = 2} \ b2 \#(\ - {#blv#})" + using assms by blast + then have "p \ blv \ b2" + by (metis (no_types, lifting) elem_mset_set equals0D infinite_set_mset_mset_set mem_Collect_eq) + thus "x \ blv" using asm by auto +qed + +lemma intersect_mult_set_block_subset_card: + assumes "blv \# \" + assumes "p \# \\<^sub>#{# mset_set {y .y \ blv \ b2 \ card y = 2} .b2 \# (\ - {#blv#})#}" + shows "card p = 2" +proof - + obtain b2 where "p \# mset_set {y . y \ blv \ b2 \ card y = 2} \ b2 \#(\ - {#blv#})" + using assms by blast + thus ?thesis + by (metis (mono_tags, lifting) elem_mset_set equals0D infinite_set_mset_mset_set mem_Collect_eq) +qed + +lemma intersect_mult_set_block_with_point_exists: + assumes "blv \# \" and "p \ blv" and "\ \ 2" and "card p = 2" + shows "\x\#remove1_mset blv \. p \# mset_set {y. y \ blv \ y \ x \ card y = 2}" +proof - + have "size {#b \# \ . p \ b#} = \" using points_index_def assms + by (metis balanced_alt_def_all dual_order.trans of_nat_numeral wellformed) + then have "size {#bl \# (\ - {#blv#}) . p \ bl#} \ 1" + using assms by (simp add: size_Diff_singleton) + then obtain bl where "bl \# (\ - {#blv#}) \ p \ bl" using assms filter_mset_empty_conv + by (metis diff_diff_cancel diff_is_0_eq' le_numeral_extra(4) size_empty zero_neq_one) + thus ?thesis + using assms finite_blocks by auto +qed + +lemma intersect_mult_set_block_subset_iff_2: + assumes "blv \# \" and "p \ blv" and "\ \ 2" and "card p = 2" + shows "p \# \\<^sub>#{# mset_set {y .y \ blv \ b2 \ card y = 2} .b2 \# (\ - {#blv#})#}" + by (auto simp add: intersect_mult_set_block_with_point_exists assms) + +lemma sym_sum_mset_inter_sets_count: + assumes "blv \# \" + assumes "p \ blv" + shows "count (\\<^sub>#{# mset_set (bl \ blv) .bl \# (\ - {#blv#})#}) p = \ - 1" + (is "count (\\<^sub>#?M) p = \ - 1") +proof - + have size_inter: "size {# mset_set (bl \ blv) | bl \# (\ - {#blv#}) . p \ bl#} = \ - 1" + using bibd_point_occ_rep point_replication_number_def + by (metis assms(1) assms(2) size_image_mset) + have inter_finite: "\ bl \# (\ - {#blv#}) . finite (bl \ blv)" + by (simp add: assms(1) finite_blocks) + have "\ bl . bl \# (\ - {#blv#}) \ p \ bl \ count (mset_set (bl \ blv)) p = 1" + using assms count_mset_set(1) inter_finite by simp + then have "\ bl . bl \# {#b1 \#(\ - {#blv#}) . p \ b1#} \ count (mset_set (bl \ blv)) p = 1" + by (metis (full_types) count_eq_zero_iff count_filter_mset) + then have pin: "\ P. P \# {# mset_set (bl \ blv) | bl \# (\ - {#blv#}) . p \ bl#} + \ count P p = 1" by blast + have "?M = {# mset_set (bl \ blv) | bl \# (\ - {#blv#}) . p \ bl#} + + {# mset_set (bl \ blv) | bl \# (\ - {#blv#}) . p \ bl#}" + by (metis image_mset_union multiset_partition) + then have "count (\\<^sub>#?M) p = size {# mset_set (bl \ blv) | bl \# (\ - {#blv#}) . p \ bl#} " + using pin by (auto simp add: count_sum_mset) + then show ?thesis using size_inter by linarith +qed + +lemma sym_sum_mset_inter_sets_size: + assumes "blv \# \" + shows "size (\\<^sub>#{# mset_set (bl \ blv) .bl \# (\ - {#blv#})#}) = \ * (\ - 1)" + (is "size (\\<^sub>#?M) = \* (\ - 1)") +proof - + have eq: "set_mset (\\<^sub>#{# mset_set (bl \ blv) .bl \# (\ - {#blv#})#}) = blv" + using intersect_mult_set_eq_block assms by auto + then have k: "card (set_mset (\\<^sub>#?M)) = \" + by (simp add: assms) + have "\ p. p \# (\\<^sub>#?M) \ count (\\<^sub>#?M) p = \ - 1" + using sym_sum_mset_inter_sets_count assms eq by blast + thus ?thesis using k size_multiset_int_count by metis +qed + +lemma sym_sum_inter_num: + assumes "b1 \# \" + shows "(\b2 \#(\ - {#b1#}). b1 |\| b2) = \* (\ - 1)" +proof - + have "(\b2 \#(\ - {#b1#}). b1 |\| b2) = (\b2 \#(\ - {#b1#}). size (mset_set (b1 \ b2)))" + by (simp add: intersection_number_def) + also have "... = size (\\<^sub>#{#mset_set (b1 \ bl). bl \# (\ - {#b1#})#})" + by (auto simp add: size_big_union_sum) + also have "... = size (\\<^sub>#{#mset_set (bl \ b1). bl \# (\ - {#b1#})#})" + by (metis Int_commute) + finally have "(\b2 \#(\ - {#b1#}). b1 |\| b2) = \ * (\ - 1)" + using sym_sum_mset_inter_sets_size assms by auto + then show ?thesis by simp +qed + +lemma choose_two_int: + assumes " x \ 0" + shows "nat (x :: int) choose 2 = ((x ::int) * ( x - 1)) div 2 " + using choose_two assms dvd_div_mult_self even_numeral int_nat_eq mult_cancel_right2 mult_eq_0_iff + mult_nonneg_nonneg nat_diff_distrib' nat_mult_distrib nat_one_as_int + numeral_Bit0_div_2 numerals(1) of_nat_numeral zdiv_int by (smt (verit)) (* Slow *) + +lemma sym_sum_mset_inter2_sets_count: + assumes "blv \# \" + assumes "p \ blv" + assumes "card p = 2" + shows "count (\\<^sub>#{#mset_set {y .y \ blv \ b2 \ card y = 2}. b2 \# (\ - {#blv#})#}) p = \ - 1" + (is "count (\\<^sub>#?M) p = \ - 1") +proof - + have size_inter: "size {# mset_set {y .y \ blv \ b2 \ card y = 2} | b2 \# (\ - {#blv#}) . p \ b2#} + = \ - 1" + using bibd_subset_occ assms by simp + have "\ b2 \# (\ - {#blv#}) . p \ b2 \ count (mset_set{y .y \ blv \ b2 \ card y = 2}) p = 1" + using assms(2) count_mset_set(1) assms(3) by (auto simp add: assms(1) finite_blocks) + then have "\ bl \# {#b1 \#(\ - {#blv#}) . p \ b1#}. + count (mset_set {y .y \ blv \ bl \ card y = 2}) p = 1" + using count_eq_zero_iff count_filter_mset by (metis (no_types, lifting)) + then have pin: "\ P \# {# mset_set {y .y \ blv \ b2 \ card y = 2} | b2 \# (\ - {#blv#}) . p \ b2#}. + count P p = 1" + using count_eq_zero_iff count_filter_mset by blast + have "?M = {# mset_set {y .y \ blv \ b2 \ card y = 2} | b2 \# (\ - {#blv#}) . p \ b2#} + + {# mset_set {y .y \ blv \ b2 \ card y = 2} | b2 \# (\ - {#blv#}) . \ (p \ b2)#}" + by (metis image_mset_union multiset_partition) + then have "count (\\<^sub>#?M) p = + size {# mset_set {y .y \ blv \ b2 \ card y = 2} | b2 \# (\ - {#blv#}) . p \ b2#}" + using pin by (auto simp add: count_sum_mset) + then show ?thesis using size_inter by linarith +qed + +lemma sym_sum_mset_inter2_sets_size: + assumes "blv \# \" + shows "size (\\<^sub>#{#mset_set {y .y \ blv \ b2 \ card y = 2}. b2 \# (\ - {#blv#})#}) = + ((nat \) choose 2) * (\ -1)" + (is "size (\\<^sub>#?M) = ((nat \) choose 2) * (\ -1)") +proof (cases "\ = 1") + case True + have empty: "\ b2 . b2 \# remove1_mset blv \ \ {y .y \ blv \ y \ b2 \ card y = 2} = {}" + using index_one_alt_bl_not_exist assms True by blast + then show ?thesis using sum_mset.neutral True by (simp add: empty) +next + case False + then have index_min: "\ \ 2" using index_not_zero by linarith + have subset_card: "\ x . x \# (\\<^sub>#?M) \ card x = 2" + proof - + fix x + assume a: "x \# (\\<^sub>#?M)" + then obtain b2 where "x \# mset_set {y . y \ blv \ b2 \ card y = 2} \ b2 \#(\ - {#blv#})" + by blast + thus "card x = 2" using mem_Collect_eq + by (metis (mono_tags, lifting) elem_mset_set equals0D infinite_set_mset_mset_set) + qed + have eq: "set_mset (\\<^sub>#?M) = {bl . bl \ blv \ card bl = 2}" + proof + show "set_mset (\\<^sub>#?M) \ {bl . bl \ blv \ card bl = 2}" + using subset_card intersect_mult_set_block_subset_iff assms by blast + show "{bl . bl \ blv \ card bl = 2} \ set_mset (\\<^sub>#?M)" + using intersect_mult_set_block_subset_iff_2 assms index_min by blast + qed + have "card blv = (nat \)" using uniform assms by (metis nat_int) + then have k: "card (set_mset (\\<^sub>#?M)) = ((nat \) choose 2)" using eq n_subsets + by (simp add: n_subsets assms finite_blocks) + thus ?thesis using k size_multiset_int_count sym_sum_mset_inter2_sets_count assms eq subset_card + by (metis (no_types, lifting) intersect_mult_set_block_subset_iff) +qed + +lemma sum_choose_two_inter_num: + assumes "b1 \# \" + shows "(\b2 \# (\ - {#b1#}). (nat (b1 |\| b2) choose 2)) = ((\ * (\ - 1) div 2)) * (\ -1)" +proof - + have div_fact: "2 dvd (\ * (\ - 1))"by simp + have div_fact_2: "2 dvd (\ * (\ - 1))" using symmetric_condition_2 by simp + have "(\b2 \# (\ - {#b1#}). (nat (b1 |\| b2) choose 2)) = (\b2 \# (\ - {#b1#}). nat (b1 |\|\<^sub>2 b2 ))" + using n_inter_num_choose_design_inter assms by (simp add: in_diffD) + then have sum_fact: "(\b2 \# (\ - {#b1#}).(nat (b1 |\| b2) choose 2)) + = ((nat \) choose 2) * (\ -1)" + using assms sym_sum_mset_inter2_sets_size + by (auto simp add: size_big_union_sum n_intersect_num_subset_def) + have "((nat \) choose 2) * (\ -1) = ((\ * (\ - 1) div 2)) * (\ -1)" + using choose_two_int symmetric_condition_2 k_non_zero by auto + then have "((nat \) choose 2) * (\ -1) = ((\ * (\ - 1) div 2)) * (\ -1)" + using div_fact div_fact_2 by (smt div_mult_swap mult.assoc mult.commute) + then show ?thesis using sum_fact by simp +qed + +lemma sym_sum_inter_num_sq: + assumes "b1 \# \" + shows "(\bl \# (remove1_mset b1 \). (b1 |\| bl)^2) = \^2 * ( \ - 1)" +proof - + have dvd: "2 dvd (( \ - 1) * (\ * (\ - 1)))" by simp + have a: "(\b2 \#(\ - {#b1#}). int (nat (b1 |\| b2) choose 2)) = + (\bl \# (remove1_mset b1 \). ((b1 |\| bl) * ((b1 |\| bl) - 1)) div 2)" + using choose_two_int by (simp add: intersection_num_non_neg) + have b: "(\b2 \#(\ - {#b1#}). int (nat (b1 |\| b2) choose 2)) = + (\b2 \#(\ - {#b1#}). (nat (b1 |\| b2) choose 2))" by simp + have "(\b2 \#(\ - {#b1#}). (nat (b1 |\| b2) choose 2)) = ((\ * (\ - 1)) div 2) * ( \ - 1)" + using sum_choose_two_inter_num assms by blast + then have start: "(\bl \# (remove1_mset b1 \). ((b1 |\| bl) * ((b1 |\| bl) - 1)) div 2) + = ((\ * (\ - 1)) div 2) * (\ - 1)" + using a b by linarith + have sum_dvd: "2 dvd (\bl \# (remove1_mset b1 \). (b1 |\| bl) * ((b1 |\| bl) - 1))" + by (simp add: sum_mset_dvd) + then have "(\bl \# (remove1_mset b1 \). (b1 |\| bl) * ((b1 |\| bl) - 1)) div 2 + = (\ - 1) * ((\ * (\ - 1)) div 2)" + using start by (simp add: sum_mset_distrib_div_if_dvd) + then have "(\bl \# (remove1_mset b1 \). (b1 |\| bl)^2) + - (\bl \# (remove1_mset b1 \). (b1 |\| bl)) = ((\ - 1) * (\ * (\ - 1)))" + using sum_dvd dvd + by (simp add: dvd_div_eq_iff div_mult_swap int_distrib(4) power2_eq_square sum_mset_add_diff) + then have "(\bl \# (remove1_mset b1 \). (b1 |\| bl)^2) - (\ * (\ - 1)) = ((\ - 1) * (\ * (\ - 1)))" + using sym_sum_inter_num assms rep_value_sym symmetric_condition_2 by auto + then have "(\bl \# (remove1_mset b1 \). (b1 |\| bl)^2) = (\ * (\ - 1)) * (\ - 1) + (\ * (\ - 1))" + using diff_eq_eq by fastforce + then have "(\bl \# (remove1_mset b1 \). (b1 |\| bl)^2) = (\ * (\ - 1)) * (\ - 1 + 1)" + using int_distrib(2) by (metis mult_numeral_1_right numeral_One) + thus ?thesis by (simp add: power2_eq_square) +qed + +lemma sym_sum_inter_num_to_zero: + assumes "b1 \# \" + shows "(\bl \# (remove1_mset b1 \). ((b1 |\| bl) - \)^2) = 0" +proof - + have rm1_size: "size (remove1_mset b1 \) = \ - 1" using assms b_non_zero int_ops(6) + by (auto simp add: symmetric size_remove1_mset_If) + have "\ bl . bl \# (remove1_mset b1 \) \ ((b1 |\| bl) - \)^2 = + (((b1 |\| bl)^2) - (2 * \ * (b1 |\| bl)) + (\^2))" + by (simp add: power2_diff) + then have "(\bl \# (remove1_mset b1 \). ((b1 |\| bl) - \)^2) = + (\bl \# (remove1_mset b1 \). (((b1 |\| bl)^2) - (2 * \ * (b1 |\| bl)) + (\^2)))" + using sum_over_fun_eq by auto + also have "... = \^2 * (\ - 1) - 2 * \ * (\bl \# (remove1_mset b1 \). ((b1 |\| bl))) + + (\ - 1) * (\^2)" + using sym_sum_inter_num_sq rm1_size + by (simp add: assms sum_mset.distrib sum_mset_add_diff sum_mset_distrib_left) + finally have "(\bl \# (remove1_mset b1 \). ((b1 |\| bl) - \)^2) = 0" + using rep_value_sym symmetric_condition_2 sym_sum_inter_num assms + by (auto simp add: power2_eq_square) + thus ?thesis by simp +qed + +theorem sym_block_intersections_index [simp]: + assumes "b1 \# \" + assumes "b2 \# (\ - {#b1#})" + shows "b1 |\| b2 = \" +proof - + have pos: "\ bl . ((b1 |\| bl) - \)^2 \ 0" by simp + have "(\bl \# (remove1_mset b1 \). ((b1 |\| bl) - \)^2) = 0" + using sym_sum_inter_num_to_zero assms by simp + then have "\ bl. bl \ set_mset (remove1_mset b1 \) \ ((b1 |\| bl) - \)^2 = 0" + using sum_mset_0_iff_ge_0 pos by (metis (no_types, lifting)) + thus ?thesis + using assms(2) by auto +qed + +subsubsection \Symmetric BIBD is Simple\ + +lemma sym_block_mult_one [simp]: + assumes "bl \# \" + shows "multiplicity bl = 1" +proof (rule ccontr) + assume "\ (multiplicity bl = 1)" + then have not: "multiplicity bl \ 1" by simp + have "multiplicity bl \ 0" using assms + by simp + then have m: "multiplicity bl \ 2" using not by linarith + then have blleft: "bl \# (\ - {#bl#})" + using in_diff_count by fastforce + have "bl |\| bl = \" using k_non_zero assms + by (simp add: intersection_number_def) + then have keql: "\ = \" using sym_block_intersections_index blleft assms by simp + then have "\ = \" + using keql index_lt_replication rep_value_sym block_size_lt_v diffs0_imp_equal k_non_zero zero_diff by linarith + then show False using incomplete + by simp +qed + +end + +sublocale symmetric_bibd \ simple_design + by unfold_locales simp + +subsubsection \Residual/Derived Sym BIBD Constructions\ +text \Using the intersect result, we can reason further on residual and derived designs. +Proofs based off lecture notes \cite{HerkeLectureNotes2016}\ + +locale symmetric_bibd_block_transformations = symmetric_bibd + bibd_block_transformations +begin + +lemma derived_block_size [simp]: + assumes "b \# \\<^sup>D" + shows "card b = \" +proof - + obtain bl2 where set: "bl2 \# remove1_mset bl \" and inter: "b = bl2 \ bl" + using derived_blocks_def assms by (meson derived_obtain_orig_block) + then have "card b = bl2 |\| bl" + by (simp add: intersection_number_def) + thus ?thesis using sym_block_intersections_index + using set intersect_num_commute valid_block by fastforce +qed + +lemma derived_points_index [simp]: + assumes "ps \ bl" + assumes "card ps = 2" + shows "\\<^sup>D index ps = \ - 1" +proof - + have b_in: "\ b . b \# (remove1_mset bl \) \ ps \ b \ ps \ b \ bl" + using assms by blast + then have orig: "ps \ \" + using valid_block assms wellformed by blast + then have lam: "size {# b \# \ . ps \ b #} = \" using balanced + by (simp add: assms(2) points_index_def) + then have "size {# b \# remove1_mset bl \ . ps \ b #} = size {# b \# \ . ps \ b #} - 1" + using assms valid_block by (simp add: size_Diff_submset) + then have "size {# b \# remove1_mset bl \ . ps \ b #} = \ - 1" + using lam index_not_zero by linarith + then have "size {# bl \ b | b \# (remove1_mset bl \) . ps \ bl \ b #} = \ - 1" + using b_in by (metis (no_types, lifting) Int_subset_iff filter_mset_cong size_image_mset) + then have "size {# x \# {# bl \ b . b \# (remove1_mset bl \) #} . ps \ x #} = \ - 1" + by (metis image_mset_filter_swap) + then have "size {# x \# \\<^sup>D . ps \ x #} = \ - 1" by (simp add: derived_blocks_def) + thus ?thesis by (simp add: points_index_def) +qed + +lemma sym_derive_design_bibd: + assumes "\ > 1" + shows "bibd bl \\<^sup>D \ (\ - 1)" +proof - + interpret des: proper_design bl "\\<^sup>D" using derived_is_proper assms valid_block by auto + have "\ < \" using index_lt_replication rep_value_sym by linarith + then show ?thesis using derived_block_size assms derived_points_index derived_points_order + by (unfold_locales) (simp_all) +qed + +lemma residual_block_size [simp]: + assumes "b \# \\<^sup>R" + shows "card b = \ - \" +proof - + obtain bl2 where sub: "b = bl2 - bl" and mem: "bl2 \# remove1_mset bl \" + using assms residual_blocks_def by auto + then have "card b = card bl2 - card (bl2 \ bl)" + using card_Diff_subset_Int valid_block finite_blocks + by (simp add: card_Diff_subset_Int) + then have "card b = card bl2 - bl2 |\| bl" + using intersection_number_def finite_blocks card_inter_lt_single + by (metis assms derived_fin_incidence_system.finite_sets finite_Diff2 of_nat_diff + residual_fin_incidence_sys.finite_blocks sub) + thus ?thesis using sym_block_intersections_index uniform + by (metis valid_block in_diffD intersect_num_commute mem) +qed + +lemma residual_index [simp]: + assumes "ps \ bl\<^sup>c" + assumes "card ps = 2" + shows "(\\<^sup>R) index ps = \" +proof - + have a: "\ b . (b \# remove1_mset bl \ \ ps \ b \ ps \ (b - bl))" using assms + by (smt DiffI block_comp_elem_alt_left in_diffD subset_eq wellformed) + have b: "\ b . (b \# remove1_mset bl \ \ ps \ (b - bl) \ ps \ b)" + by auto + have not_ss: "\ (ps \ bl)" using set_diff_non_empty_not_subset blocks_nempty t_non_zero assms + block_complement_def by fastforce + have "\\<^sup>R index ps = size {# x \# {# b - bl . b \# (remove1_mset bl \) #} . ps \ x #}" + using assms valid_block by (simp add: points_index_def residual_blocks_def) + also have "... = size {# b - bl | b \# (remove1_mset bl \) . ps \ b - bl #} " + by (metis image_mset_filter_swap) + finally have "\\<^sup>R index ps = size {# b \# (remove1_mset bl \) . ps \ b #} " using a b + by (metis (no_types, lifting) filter_mset_cong size_image_mset) + thus ?thesis + using balanced not_ss assms points_index_alt_def block_complement_subset_points by auto +qed + +lemma sym_residual_design_bibd: + assumes "\ \ \ + 2" + shows "bibd (bl\<^sup>c) \\<^sup>R (\ - \) \" +proof - + interpret des: proper_design "bl\<^sup>c" "\\<^sup>R" + using residual_is_proper assms(1) valid_block sym_block_mult_one by fastforce + show ?thesis using residual_block_size assms sym_design_vk_gt_kl residual_order residual_index + by(unfold_locales) simp_all +qed + +end + +subsection \BIBD's and Other Block Designs\ +text \BIBD's are closely related to other block designs by indirect inheritance\ + +sublocale bibd \ k_\_PBD \ \ \ \ + using block_size_gt_t by (unfold_locales) simp_all + +lemma incomplete_PBD_is_bibd: + assumes "k < card V" and "k_\_PBD V B \ k" + shows "bibd V B k \" +proof - + interpret inc: incomplete_design V B k using assms + by (auto simp add: block_design.incomplete_designI k_\_PBD.axioms(2)) + interpret pairwise_balance: pairwise_balance V B \ using assms + by (auto simp add: k_\_PBD.axioms(1)) + show ?thesis using assms k_\_PBD.block_size_t by (unfold_locales) (simp_all) +qed + +lemma (in bibd) bibd_to_pbdI[intro]: + assumes "\ = 1" + shows "k_PBD \ \ \" +proof - + interpret pbd: k_\_PBD \ \ \ \ + by (simp add: k_\_PBD_axioms) + show ?thesis using assms by (unfold_locales) (simp_all add: t_lt_order min_block_size_2) +qed + +locale incomplete_PBD = incomplete_design + k_\_PBD + +sublocale incomplete_PBD \ bibd + using block_size_t by (unfold_locales) simp + +end \ No newline at end of file diff --git a/thys/Design_Theory/Block_Designs.thy b/thys/Design_Theory/Block_Designs.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Block_Designs.thy @@ -0,0 +1,558 @@ +(* Title: Block_Designs.thy + Author: Chelsea Edmonds +*) + +section \Block and Balanced Designs\ +text \We define a selection of the many different types of block and balanced designs, building up +to properties required for defining a BIBD, in addition to several base generalisations\ + +theory Block_Designs imports Design_Operations +begin + +subsection \Block Designs\ +text \A block design is a design where all blocks have the same size.\ + +subsubsection \K Block Designs\ +text \An important generalisation of a typical block design is the $\mathcal{K}$ block design, +where all blocks must have a size $x$ where $x \in \mathcal{K}$\ +locale K_block_design = proper_design + + fixes sizes :: "int set" ("\") + assumes block_sizes: "bl \# \ \ (int (card bl)) \ \" + assumes positive_ints: "x \ \ \ x > 0" +begin + +lemma sys_block_size_subset: "sys_block_sizes \ \" + using block_sizes sys_block_sizes_obtain_bl by blast + +end + +subsubsection\Uniform Block Design\ +text \The typical uniform block design is defined below\ +locale block_design = proper_design + + fixes u_block_size :: int ("\") + assumes uniform [simp]: "bl \# \ \ card bl = \" +begin + +lemma k_non_zero: "\ \ 1" +proof - + obtain bl where bl_in: "bl \# \" + using design_blocks_nempty by auto + then have "int (card bl) \ 1" using block_size_gt_0 + by (metis less_not_refl less_one not_le_imp_less of_nat_1 of_nat_less_iff) + thus ?thesis by (simp add: bl_in) +qed + +lemma uniform_alt_def_all: "\ bl \# \ .card bl = \" + using uniform by auto + +lemma uniform_unfold_point_set: "bl \# \ \ card {p \ \. p \ bl} = \" + using uniform wellformed by (simp add: Collect_conj_eq inf.absorb_iff2) + +lemma uniform_unfold_point_set_mset: "bl \# \ \ size {#p \# mset_set \. p \ bl #} = \" + using uniform_unfold_point_set by (simp add: finite_sets) + +lemma sys_block_sizes_uniform [simp]: "sys_block_sizes = {\}" +proof - + have "sys_block_sizes = {bs . \ bl . bs = card bl \ bl\# \}" by (simp add: sys_block_sizes_def) + then have "sys_block_sizes = {bs . bs = \}" using uniform uniform_unfold_point_set + b_positive block_set_nempty_imp_block_ex + by (smt (verit, best) Collect_cong design_blocks_nempty) + thus ?thesis by auto +qed + +lemma sys_block_sizes_uniform_single: "is_singleton (sys_block_sizes)" + by simp + +lemma uniform_size_incomp: "\ \ \ - 1 \ bl \# \ \ incomplete_block bl" + using uniform k_non_zero of_nat_less_iff zle_diff1_eq by metis + +lemma uniform_complement_block_size: + assumes "bl \# \\<^sup>C" + shows "card bl = \ - \" +proof - + obtain bl' where bl_assm: "bl = bl'\<^sup>c \ bl' \# \" + using wellformed assms by (auto simp add: complement_blocks_def) + then have "int (card bl') = \" by simp + thus ?thesis using bl_assm block_complement_size wellformed + by (simp add: block_size_lt_order of_nat_diff) +qed + +lemma uniform_complement[intro]: + assumes "\ \ \ - 1" + shows "block_design \ \\<^sup>C (\ - \)" +proof - + interpret des: proper_design \ "\\<^sup>C" + using uniform_size_incomp assms complement_proper_design by auto + show ?thesis using assms uniform_complement_block_size by (unfold_locales) (simp) +qed + +lemma block_size_lt_v: "\ \ \" + using v_non_zero block_size_lt_v design_blocks_nempty uniform by auto + +end + +lemma (in proper_design) block_designI[intro]: "(\ bl . bl \# \ \ card bl = k) + \ block_design \ \ k" + by (unfold_locales) (auto) + +context block_design +begin + +lemma block_design_multiple: "n > 0 \ block_design \ (multiple_blocks n) \" + using elem_in_repeat_in_original multiple_proper_design proper_design.block_designI + by (metis block_set_nempty_imp_block_ex design_blocks_nempty int_int_eq uniform_alt_def_all) + +end +text \A uniform block design is clearly a type of $K$\_block\_design with a singleton $K$ set\ +sublocale block_design \ K_block_design \ \ "{\}" + using k_non_zero uniform by unfold_locales simp_all + +subsubsection \Incomplete Designs\ +text \An incomplete design is a design where $k < v$, i.e. no block is equal to the point set\ +locale incomplete_design = block_design + + assumes incomplete: "\ < \" + +begin + +lemma incomplete_imp_incomp_block: "bl \# \ \ incomplete_block bl" + using incomplete uniform uniform_size_incomp by fastforce + +lemma incomplete_imp_proper_subset: "bl \# \ \ bl \ \" + by (simp add: incomplete_block_proper_subset incomplete_imp_incomp_block wellformed) +end + +lemma (in block_design) incomplete_designI[intro]: "\ < \ \ incomplete_design \ \ \" + by unfold_locales auto + +context incomplete_design +begin + +lemma multiple_incomplete: "n > 0 \ incomplete_design \ (multiple_blocks n) \" + using block_design_multiple incomplete by (simp add: block_design.incomplete_designI) + +lemma complement_incomplete: "incomplete_design \ (\\<^sup>C) (\ - \)" +proof - + have "\ - \ < \" using v_non_zero k_non_zero by linarith + thus ?thesis using uniform_complement incomplete incomplete_designI + by (simp add: block_design.incomplete_designI) +qed + +end + +subsection \Balanced Designs\ +text \t-wise balance is a design with the property that all point subsets of size $t$ occur in +$\lambda_t$ blocks\ + +locale t_wise_balance = proper_design + + fixes grouping :: int ("\") and index :: int ("\\<^sub>t") + assumes t_non_zero: "\ \ 1" + assumes t_lt_order: "\ \ \" + assumes balanced [simp]: "ps \ \ \ card ps = \ \ \ index ps = \\<^sub>t" +begin + +lemma balanced_alt_def_all: "\ ps \ \ . card ps = \ \ \ index ps = \\<^sub>t" + using balanced by auto + +end + +lemma (in proper_design) t_wise_balanceI[intro]: "\ \ \ \ \ \ 1 \ + (\ ps . ps \ \ \ card ps = \ \ \ index ps = \\<^sub>t) \ t_wise_balance \ \ \ \\<^sub>t" + by (unfold_locales) auto + +context t_wise_balance +begin + +lemma obtain_t_subset_points: + obtains T where "T \ \" "card T = \" "finite T" + using obtain_subset_with_card_int_n design_points_nempty t_lt_order t_non_zero finite_sets + by (metis (no_types, hide_lams) dual_order.strict_trans2 not_le_imp_less of_nat_1 of_nat_less_0_iff) + +lemma multiple_t_wise_balance_index [simp]: + assumes "ps \ \" + assumes "card ps = \" + shows "(multiple_blocks n) index ps = \\<^sub>t * n" + using multiple_point_index balanced assms by fastforce + +lemma multiple_t_wise_balance: + assumes "n > 0" + shows "t_wise_balance \ (multiple_blocks n) \ (\\<^sub>t * n)" +proof - + interpret des: proper_design \ "(multiple_blocks n)" by (simp add: assms multiple_proper_design) + show ?thesis using t_non_zero t_lt_order multiple_t_wise_balance_index + by (unfold_locales) (simp_all) +qed + +lemma twise_set_pair_index: "ps \ \ \ ps2 \ \ \ ps \ ps2 \ card ps = \ \ card ps2 = \ + \ \ index ps = \ index ps2" + using balanced by (metis of_nat_eq_iff) + +lemma t_wise_balance_alt: "ps \ \ \ card ps = \ \ \ index ps = l2 + \ (\ ps . ps \ \ \ card ps = \ \ \ index ps = l2)" + using twise_set_pair_index by blast + +lemma index_ge_zero: "\\<^sub>t \ 0" +proof - + obtain ps where "ps \ \ \ card ps = \" using t_non_zero t_lt_order obtain_subset_with_card_n + by (metis dual_order.trans of_nat_le_iff zero_le_imp_eq_int zero_le_one) + thus ?thesis + using balanced_alt_def_all of_nat_0_le_iff by blast +qed + +lemma index_1_imp_mult_1 [simp]: + assumes "\\<^sub>t = 1" + assumes "bl \# \" + assumes "card bl \ \" + shows "multiplicity bl = 1" +proof (rule ccontr) + assume "\ (multiplicity bl = 1)" + then have not: "multiplicity bl \ 1" by simp + have "multiplicity bl \ 0" using assms by simp + then have m: "multiplicity bl \ 2" using not by linarith + obtain ps where ps: "ps \ bl \ card ps = \" + using assms obtain_t_subset_points + by (metis obtain_subset_with_card_int_n of_nat_0_le_iff) + then have "\ index ps \ 2" + using m points_index_count_min ps by blast + then show False using balanced ps antisym_conv2 not_numeral_less_zero numeral_le_one_iff + points_index_ps_nin semiring_norm(69) zero_neq_numeral + by (metis assms(1) int_int_eq int_ops(2)) +qed + +end + +subsubsection \Sub-types of t-wise balance\ + +text \Pairwise balance is when $t = 2$. These are commonly of interest\ +locale pairwise_balance = t_wise_balance \ \ 2 \ + for point_set ("\") and block_collection ("\") and index ("\") + +text \We can combine the balance properties with $K$\_block design to define tBD's +(t-wise balanced designs), and PBD's (pairwise balanced designs)\ + +locale tBD = t_wise_balance + K_block_design + + assumes block_size_gt_t: "k \ \ \ k \ \" + +locale \_PBD = pairwise_balance + K_block_design + + assumes block_size_gt_t: "k \ \ \ k \ 2" + +sublocale \_PBD \ tBD \ \ 2 \ \ + using t_lt_order block_size_gt_t by (unfold_locales) (simp_all) + +locale PBD = \_PBD \ \ 1 \ for point_set ("\") and block_collection ("\") and sizes ("\") +begin +lemma multiplicity_is_1: + assumes "bl \# \" + shows "multiplicity bl = 1" + using block_size_gt_t index_1_imp_mult_1 by (simp add: assms block_sizes) + +end + +sublocale PBD \ simple_design + using multiplicity_is_1 by (unfold_locales) + +text \PBD's are often only used in the case where $k$ is uniform, defined here.\ +locale k_\_PBD = pairwise_balance + block_design + + assumes block_size_t: "2 \ \" + +sublocale k_\_PBD \ \_PBD \ \ \ "{\}" + using k_non_zero uniform block_size_t by(unfold_locales) (simp_all) + +locale k_PBD = k_\_PBD \ \ 1 \ for point_set ("\") and block_collection ("\") and u_block_size ("\") + +sublocale k_PBD \ PBD \ \ "{\}" + using block_size_t by (unfold_locales, simp_all) + +subsubsection \Covering and Packing Designs\ +text \Covering and packing designs involve a looser balance restriction. Upper/lower bounds +are placed on the points index, instead of a strict equality\ + +text \A t-covering design is a relaxed version of a tBD, where, for all point subsets of size t, +a lower bound is put on the points index\ +locale t_covering_design = block_design + + fixes grouping :: int ("\") + fixes min_index :: int ("\\<^sub>t") + assumes covering: "ps \ \ \ card ps = \ \ \ index ps \ \\<^sub>t" + assumes block_size_t: "\ \ \" + assumes t_non_zero: "\ \ 1" +begin + +lemma covering_alt_def_all: "\ ps \ \ . card ps = \ \ \ index ps \ \\<^sub>t" + using covering by auto + +end + +lemma (in block_design) t_covering_designI [intro]: "t \ \ \ t \ 1 \ + (\ ps. ps \ \ \ card ps = t \ \ index ps \ \\<^sub>t) \ t_covering_design \ \ \ t \\<^sub>t" + by (unfold_locales) simp_all + +text \A t-packing design is a relaxed version of a tBD, where, for all point subsets of size t, +an upper bound is put on the points index\ +locale t_packing_design = block_design + + fixes grouping :: int ("\") + fixes min_index :: int ("\\<^sub>t") + assumes packing: "ps \ \ \ card ps = \ \ \ index ps \ \\<^sub>t" + assumes block_size_t: "\ \ \" + assumes t_non_zero: "\ \ 1" +begin + +lemma packing_alt_def_all: "\ ps \ \ . card ps = \ \ \ index ps \ \\<^sub>t" + using packing by auto + +end + +lemma (in block_design) t_packing_designI [intro]: "t \ \ \ t \ 1 \ + (\ ps . ps \ \ \ card ps = t \ \ index ps \ \\<^sub>t) \ t_packing_design \ \ \ t \\<^sub>t" + by (unfold_locales) simp_all + +lemma packing_covering_imp_balance: + assumes "t_packing_design V B k t \\<^sub>t" + assumes "t_covering_design V B k t \\<^sub>t" + shows "t_wise_balance V B t \\<^sub>t" +proof - + from assms interpret des: proper_design V B + using block_design.axioms(1) t_covering_design.axioms(1) by blast + show ?thesis + proof (unfold_locales) + show "1 \ t" using assms by (simp add: t_packing_design.t_non_zero) + show "t \ des.\" using block_design.block_size_lt_v t_packing_design.axioms(1) + by (metis assms(1) dual_order.trans t_packing_design.block_size_t) + show "\ps. ps \ V \ card ps = t \ B index ps = \\<^sub>t" + using t_packing_design.packing t_covering_design.covering by (metis assms dual_order.antisym) + qed +qed + +subsection \Constant Replication Design\ +text \When the replication number for all points in a design is constant, it is the +design replication number.\ +locale constant_rep_design = proper_design + + fixes design_rep_number :: int ("\") + assumes rep_number [simp]: "x \ \ \ \ rep x = \" + +begin + +lemma rep_number_alt_def_all: "\ x \ \. \ rep x = \" + by (simp) + +lemma rep_number_unfold_set: "x \ \ \ size {#bl \# \ . x \ bl#} = \" + using rep_number by (simp add: point_replication_number_def) + +lemma rep_numbers_constant [simp]: "replication_numbers = {\}" + unfolding replication_numbers_def using rep_number design_points_nempty Collect_cong finite.cases + finite_sets insertCI singleton_conv + by (smt (verit, ccfv_threshold) fst_conv snd_conv) + +lemma replication_number_single: "is_singleton (replication_numbers)" + using is_singleton_the_elem by simp + +lemma constant_rep_point_pair: "x1 \ \ \ x2 \ \ \ x1 \ x2 \ \ rep x1 = \ rep x2" + using rep_number by auto + +lemma constant_rep_alt: "x1 \ \ \ \ rep x1 = r2 \ (\ x . x \ \ \ \ rep x = r2)" + by (simp) + +lemma constant_rep_point_not_0: + assumes "x \ \" + shows "\ rep x \ 0" +proof (rule ccontr) + assume "\ \ rep x \ 0" + then have "\ x . x \ \ \ \ rep x = 0" using rep_number assms by auto + then have "\ x . x \ \ \ size {#bl \# \ . x \ bl#} = 0" + by (simp add: point_replication_number_def) + then show False using design_blocks_nempty wf_design wf_design_iff wf_invalid_point + by (metis ex_in_conv filter_mset_empty_conv multiset_nonemptyE size_eq_0_iff_empty) +qed + +lemma rep_not_zero: "\ \ 0" + using rep_number constant_rep_point_not_0 design_points_nempty by auto + +lemma r_gzero: "\ > 0" + using point_replication_number_def rep_number constant_rep_design.rep_not_zero + by (metis constant_rep_design.intro constant_rep_design_axioms.intro leI of_nat_less_0_iff + proper_design_axioms verit_la_disequality) + +lemma r_lt_eq_b: "\ \ \" + using rep_number max_point_rep + by (metis all_not_in_conv design_points_nempty) + +lemma complement_rep_number: + assumes "\ bl . bl \# \ \ incomplete_block bl" + shows "constant_rep_design \ \\<^sup>C (\ - \)" +proof - + interpret d: proper_design \ "(\\<^sup>C)" using complement_proper_design + by (simp add: assms) + show ?thesis using complement_rep_number rep_number by (unfold_locales) simp +qed + +lemma multiple_rep_number: + assumes "n > 0" + shows "constant_rep_design \ (multiple_blocks n) (\ * n)" +proof - + interpret d: proper_design \ "(multiple_blocks n)" using multiple_proper_design + by (simp add: assms) + show ?thesis using multiple_point_rep_num by (unfold_locales) (simp_all) +qed +end + +lemma (in proper_design) constant_rep_designI [intro]: "(\ x . x \ \ \ \ rep x = \) + \ constant_rep_design \ \ \" + by unfold_locales auto + +subsection \T-designs\ +text \All the before mentioned designs build up to the concept of a t-design, which has uniform +block size and is t-wise balanced. We limit $t$ to be less than $k$, so the balance condition has +relevance\ +locale t_design = incomplete_design + t_wise_balance + + assumes block_size_t: "\ \ \" +begin + +lemma point_indices_balanced: "point_indices \ = {\\<^sub>t}" +proof - + have "point_indices \ = {i . \ ps . i = \ index ps \ int (card ps) = \ \ ps \ \}" + by (simp add: point_indices_def) + then have "point_indices \ = {i . i = \\<^sub>t}" using balanced Collect_cong obtain_t_subset_points + by smt + thus ?thesis by auto +qed + +lemma point_indices_singleton: "is_singleton (point_indices \)" + using point_indices_balanced is_singleton_the_elem by simp + +end + +lemma t_designI [intro]: + assumes "incomplete_design V B k" + assumes "t_wise_balance V B t \\<^sub>t" + assumes "t \ k" + shows "t_design V B k t \\<^sub>t" + by (simp add: assms(1) assms(2) assms(3) t_design.intro t_design_axioms.intro) + +sublocale t_design \ t_covering_design \ \ \ \ \\<^sub>t + using t_non_zero by (unfold_locales) (auto simp add: block_size_t) + +sublocale t_design \ t_packing_design \ \ \ \ \\<^sub>t + using t_non_zero by (unfold_locales) (auto simp add: block_size_t) + +lemma t_design_pack_cov [intro]: + assumes "k < card V" + assumes "t_covering_design V B k t \\<^sub>t" + assumes "t_packing_design V B k t \\<^sub>t" + shows "t_design V B k t \\<^sub>t" +proof - + from assms interpret id: incomplete_design V B k + using block_design.incomplete_designI t_packing_design.axioms(1) + by (metis of_nat_less_iff) + from assms interpret balance: t_wise_balance V B t \\<^sub>t + using packing_covering_imp_balance by blast + show ?thesis using assms(3) + by (unfold_locales) (simp_all add: t_packing_design.block_size_t) +qed + +sublocale t_design \ tBD \ \ \ \\<^sub>t "{\}" + using uniform k_non_zero block_size_t by (unfold_locales) simp_all + +context t_design +begin + +lemma multiple_t_design: "n > 0 \ t_design \ (multiple_blocks n) \ \ (\\<^sub>t * n)" + using multiple_t_wise_balance multiple_incomplete block_size_t by (simp add: t_designI) + +lemma t_design_min_v: "\ > 1" + using k_non_zero incomplete by simp + +end + +subsection \Steiner Systems\ + +text \Steiner systems are a special type of t-design where $\Lambda_t = 1$\ +locale steiner_system = t_design \ \ \ \ 1 + for point_set ("\") and block_collection ("\") and u_block_size ("\") and grouping ("\") + +begin + +lemma block_multiplicity [simp]: + assumes "bl \# \" + shows "multiplicity bl = 1" + by (simp add: assms block_size_t) + +end + +sublocale steiner_system \ simple_design + by unfold_locales (simp) + +lemma (in t_design) steiner_systemI[intro]: "\\<^sub>t = 1 \ steiner_system \ \ \ \" + using t_non_zero t_lt_order block_size_t + by unfold_locales auto + +subsection \Combining block designs\ +text \We define some closure properties for various block designs under the combine operator. +This is done using locales to reason on multiple instances of the same type of design, building +on what was presented in the design operations theory\ + +locale two_t_wise_eq_points = two_designs_proper \ \ \ \' + des1: t_wise_balance \ \ \ \\<^sub>t + + des2: t_wise_balance \ \' \ \\<^sub>t' for \ \ \ \\<^sub>t \' \\<^sub>t' +begin + +lemma combine_t_wise_balance_index: "ps \ \ \ card ps = \ \ \\<^sup>+ index ps = (\\<^sub>t + \\<^sub>t')" + using des1.balanced des2.balanced by (simp add: combine_points_index) + +lemma combine_t_wise_balance: "t_wise_balance \\<^sup>+ \\<^sup>+ \ (\\<^sub>t + \\<^sub>t')" +proof (unfold_locales, simp add: des1.t_non_zero) + have "card \\<^sup>+ \ card \" by simp + then show "\ \ card (\\<^sup>+)" using des1.t_lt_order by linarith + show "\ps. ps \ \\<^sup>+ \ card ps = \ \ (\\<^sup>+ index ps) = \\<^sub>t + \\<^sub>t'" + using combine_t_wise_balance_index by blast +qed + +sublocale combine_t_wise_des: t_wise_balance "\\<^sup>+" "\\<^sup>+" "\" "(\\<^sub>t + \\<^sub>t')" + using combine_t_wise_balance by auto + +end + +locale two_k_block_designs = two_designs_proper \ \ \' \' + des1: block_design \ \ \ + + des2: block_design \' \' \ for \ \ \ \' \' +begin + +lemma block_design_combine: "block_design \\<^sup>+ \\<^sup>+ \" + using des1.uniform des2.uniform by (unfold_locales) (auto) + +sublocale combine_block_des: block_design "\\<^sup>+" "\\<^sup>+" "\" + using block_design_combine by simp + +end + +locale two_rep_designs_eq_points = two_designs_proper \ \ \ \' + des1: constant_rep_design \ \ \ + + des2: constant_rep_design \ \' \' for \ \ \ \' \' +begin + +lemma combine_rep_number: "constant_rep_design \\<^sup>+ \\<^sup>+ (\ + \')" + using combine_rep_number des1.rep_number des2.rep_number by (unfold_locales) (simp) + +sublocale combine_const_rep: constant_rep_design "\\<^sup>+" "\\<^sup>+" "(\ + \')" + using combine_rep_number by simp + +end + +locale two_incomplete_designs = two_k_block_designs \ \ \ \' \' + des1: incomplete_design \ \ \ + + des2: incomplete_design \' \' \ for \ \ \ \' \' +begin + +lemma combine_is_incomplete: "incomplete_design \\<^sup>+ \\<^sup>+ \" + using combine_order des1.incomplete des2.incomplete by (unfold_locales) (simp) + +sublocale combine_incomplete: incomplete_design "\\<^sup>+" "\\<^sup>+" "\" + using combine_is_incomplete by simp +end + +locale two_t_designs_eq_points = two_incomplete_designs \ \ \ \ \' + + two_t_wise_eq_points \ \ \ \\<^sub>t \' \\<^sub>t' + des1: t_design \ \ \ \ \\<^sub>t + + des2: t_design \ \' \ \ \\<^sub>t' for \ \ \ \' \ \\<^sub>t \\<^sub>t' +begin + +lemma combine_is_t_des: "t_design \\<^sup>+ \\<^sup>+ \ \ (\\<^sub>t + \\<^sub>t')" + using des1.block_size_t des2.block_size_t by (unfold_locales) + +sublocale combine_t_des: t_design "\\<^sup>+" "\\<^sup>+" "\" "\" "(\\<^sub>t + \\<^sub>t')" + using combine_is_t_des by blast + +end +end \ No newline at end of file diff --git a/thys/Design_Theory/Design_Basics.thy b/thys/Design_Theory/Design_Basics.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Design_Basics.thy @@ -0,0 +1,824 @@ +theory Design_Basics imports Main Multisets_Extras "HOL-Library.Disjoint_Sets" +begin + +section \Design Theory Basics\ +text \All definitions in this section reference the handbook of combinatorial designs + \cite{colbournHandbookCombinatorialDesigns2007}\ + +subsection \Initial setup\ + +text \Enable coercion of nats to ints to aid with reasoning on design properties\ +declare [[coercion_enabled]] +declare [[coercion "of_nat :: nat \ int"]] + +subsection \Incidence System\ + +text \An incidence system is defined to be a wellformed set system. i.e. each block is a subset +of the base point set. Alternatively, an incidence system can be looked at as the point set +and an incidence relation which indicates if they are in the same block\ + +locale incidence_system = + fixes point_set :: "'a set" ("\") + fixes block_collection :: "'a set multiset" ("\") + assumes wellformed: "b \# \ \ b \ \" +begin + +definition "\ \ { (x, b) . b \# \ \ x \ b}" (* incidence relation *) + +definition incident :: "'a \ 'a set \ bool" where +"incident p b \ (p, b) \ \" + +text \Defines common notation used to indicate number of points ($v$) and number of blocks ($b$)\ +abbreviation "\ \ int (card \)" + +abbreviation "\ \ int (size \)" + +text \Basic incidence lemmas\ + +lemma incidence_alt_def: + assumes "p \ \" + assumes "b \# \" + shows "incident p b \ p \ b" + by (auto simp add: incident_def \_def assms) + +lemma wf_invalid_point: "x \ \ \ b \# \ \ x \ b" + using wellformed by auto + +lemma block_set_nempty_imp_block_ex: "\ \ {#} \ \ bl . bl \# \" + by auto + +text \Abbreviations for all incidence systems\ +abbreviation multiplicity :: "'a set \ nat" where +"multiplicity b \ count \ b" + +abbreviation incomplete_block :: "'a set \ bool" where +"incomplete_block bl \ card bl < card \ \ bl \# \" + +lemma incomplete_alt_size: "incomplete_block bl \ card bl < \" + by simp + +lemma incomplete_alt_in: "incomplete_block bl \ bl \# \" + by simp + +lemma incomplete_alt_imp[intro]: "card bl < \ \ bl \# \ \ incomplete_block bl" + by simp + +definition design_support :: "'a set set" where +"design_support \ set_mset \" + +end + +subsection \Finite Incidence Systems\ + +text \These simply require the point set to be finite. +As multisets are only defined to be finite, it is implied that the block set must be finite already\ + +locale finite_incidence_system = incidence_system + + assumes finite_sets: "finite \" +begin + +lemma finite_blocks: "b \# \ \ finite b" + using wellformed finite_sets finite_subset by blast + +lemma mset_points_distinct: "distinct_mset (mset_set \)" + using finite_sets by (simp add: distinct_mset_def) + +lemma mset_points_distinct_diff_one: "distinct_mset (mset_set (\ - {x}))" + by (meson count_mset_set_le_one distinct_mset_count_less_1) + +lemma finite_design_support: "finite (design_support)" + using design_support_def by auto + +lemma block_size_lt_order: "bl \# \ \ card bl \ card \" + using wellformed by (simp add: card_mono finite_sets) + +end + +subsection \Designs\ + +text \There are many varied definitions of a design in literature. However, the most +commonly accepted definition is a finite point set, $V$ and collection of blocks $B$, where +no block in $B$ can be empty\ +locale design = finite_incidence_system + + assumes blocks_nempty: "bl \# \ \ bl \ {}" +begin + +lemma wf_design: "design \ \" by intro_locales + +lemma wf_design_iff: "bl \# \ \ design \ \ \ (bl \ \ \ finite \ \ bl \ {})" + using blocks_nempty wellformed finite_sets + by (simp add: wf_design) + +text \Reasoning on non empty properties and non zero parameters\ +lemma blocks_nempty_alt: "\ bl \# \. bl \ {}" + using blocks_nempty by auto + +lemma block_set_nempty_imp_points: "\ \ {#} \ \ \ {}" + using wf_design wf_design_iff by auto + +lemma b_non_zero_imp_v_non_zero: "\ > 0 \ \ > 0" + using block_set_nempty_imp_points finite_sets by fastforce + +lemma v_eq0_imp_b_eq_0: "\ = 0 \ \ = 0" + using b_non_zero_imp_v_non_zero by auto + +text \Size lemmas\ +lemma block_size_lt_v: "bl \# \ \ card bl \ \" + by (simp add: card_mono finite_sets wellformed) + +lemma block_size_gt_0: "bl \# \ \ card bl > 0" + using finite_sets blocks_nempty finite_blocks by fastforce + +lemma design_cart_product_size: "size ((mset_set \) \# \) = \ * \" + by (simp add: size_cartesian_product) + +end + +text \Intro rules for design locale\ + +lemma wf_design_implies: + assumes "(\ b . b \# \ \ b \ V)" + assumes "\ b . b \# \ \ b \ {}" + assumes "finite V" + assumes "\ \ {#}" + assumes "V \ {}" + shows "design V \" + using assms by (unfold_locales) simp_all + +lemma (in incidence_system) finite_sysI[intro]: "finite \ \ finite_incidence_system \ \" + by (unfold_locales) simp_all + +lemma (in finite_incidence_system) designI[intro]: "(\ b. b \# \ \ b \ {}) \ \ \ {#} + \ \ \ {} \ design \ \" + by (unfold_locales) simp_all + +subsection \Core Property Definitions\ + +subsubsection \Replication Number\ + +text \The replication number for a point is the number of blocks that point is incident with\ + +definition point_replication_number :: "'a set multiset \ 'a \ int" (infix "rep" 75) where +"B rep x \ size {#b \# B . x \ b#}" + +lemma max_point_rep: "B rep x \ size B" + using size_filter_mset_lesseq by (simp add: point_replication_number_def) + +lemma rep_number_g0_exists: + assumes "B rep x > 0" + obtains b where "b \# B" and "x \ b" +proof - + have "size {#b \# B . x \ b#} > 0" using assms point_replication_number_def + by (metis of_nat_0_less_iff) + thus ?thesis + by (metis filter_mset_empty_conv nonempty_has_size that) +qed + +lemma rep_number_on_set_def: "finite B \ (mset_set B) rep x = card {b \ B . x \ b}" + by (simp add: point_replication_number_def) + +lemma point_rep_number_split[simp]: "(A + B) rep x = A rep x + B rep x" + by (simp add: point_replication_number_def) + +lemma point_rep_singleton_val [simp]: "x \ b \ {#b#} rep x = 1" + by (simp add: point_replication_number_def) + +lemma point_rep_singleton_inval [simp]: "x \ b \ {#b#} rep x = 0" + by (simp add: point_replication_number_def) + +context incidence_system +begin + +lemma point_rep_number_alt_def: "\ rep x = size {# b \# \ . x \ b#}" + by (simp add: point_replication_number_def) + +lemma rep_number_non_zero_system_point: " \ rep x > 0 \ x \ \" + using rep_number_g0_exists wellformed + by (metis wf_invalid_point) + +lemma point_rep_non_existance [simp]: "x \ \ \ \ rep x = 0" + using wf_invalid_point by (simp add: point_replication_number_def filter_mset_empty_conv) + +lemma point_rep_number_inv: "size {# b \# \ . x \ b #} = \ - (\ rep x)" +proof - + have "\ = size {# b \# \ . x \ b #} + size {# b \# \ . x \ b #}" + using multiset_partition by (metis add.commute size_union) + thus ?thesis by (simp add: point_replication_number_def) +qed + +lemma point_rep_num_inv_non_empty: "(\ rep x) < \ \ \ \ {#} \ {# b \# \ . x \ b #} \ {#}" + by (metis diff_zero point_replication_number_def size_empty size_filter_neg verit_comp_simplify1(1)) + +end + +subsubsection \Point Index\ + +text \The point index of a subset of points in a design, is the number of times those points +occur together in a block of the design\ +definition points_index :: "'a set multiset \ 'a set \ nat" (infix "index" 75) where +"B index ps \ size {#b \# B . ps \ b#}" + +lemma points_index_empty [simp]: "{#} index ps = 0" + by (simp add: points_index_def) + +lemma point_index_distrib: "(B1 + B2) index ps = B1 index ps + B2 index ps" + by (simp add: points_index_def) + +lemma point_index_diff: "B1 index ps = (B1 + B2) index ps - B2 index ps" + by (simp add: points_index_def) + +lemma points_index_singleton: "{#b#} index ps = 1 \ ps \ b" + by (simp add: points_index_def) + +lemma points_index_singleton_zero: "\ (ps \ b) \ {#b#} index ps = 0" + by (simp add: points_index_def) + +lemma points_index_sum: "(\\<^sub># B ) index ps = (\b \# B . (b index ps))" + using points_index_empty by (induction B) (auto simp add: point_index_distrib) + +lemma points_index_block_image_add_eq: + assumes "x \ ps" + assumes "B index ps = l" + shows "{# insert x b . b \# B#} index ps = l" + using points_index_def by (metis (no_types, lifting) assms filter_mset_cong + image_mset_filter_swap2 points_index_def size_image_mset subset_insert) + +lemma points_index_on_set_def [simp]: + assumes "finite B" + shows "(mset_set B) index ps = card {b \ B. ps \ b}" + by (simp add: points_index_def assms) + +lemma points_index_single_rep_num: "B index {x} = B rep x" + by (simp add: points_index_def point_replication_number_def) + +lemma points_index_pair_rep_num: + assumes "\ b. b \# B \ x \ b" + shows "B index {x, y} = B rep y" + using point_replication_number_def points_index_def + by (metis assms empty_subsetI filter_mset_cong insert_subset) + +lemma points_index_0_left_imp: + assumes "B index ps = 0" + assumes "b \# B" + shows "\ (ps \ b)" +proof (rule ccontr) + assume "\ \ ps \ b" + then have a: "ps \ b" by auto + then have "b \# {#bl \# B . ps \ bl#}" by (simp add: assms(2)) + thus False by (metis assms(1) count_greater_eq_Suc_zero_iff count_size_set_repr not_less_eq_eq + points_index_def size_filter_mset_lesseq) +qed + +lemma points_index_0_right_imp: + assumes "\ b . b \# B \ (\ ps \ b)" + shows "B index ps = 0" + using assms by (simp add: filter_mset_empty_conv points_index_def) + +lemma points_index_0_iff: "B index ps = 0 \ (\ b. b \# B \ (\ ps \ b))" + using points_index_0_left_imp points_index_0_right_imp by metis + +lemma points_index_gt0_impl_existance: + assumes "B index ps > 0" + shows "(\ bl . (bl \# B \ ps \ bl))" +proof - + have "size {#bl \# B . ps \ bl#} > 0" + by (metis assms points_index_def) + then obtain bl where "bl \# B" and "ps \ bl" + by (metis filter_mset_empty_conv nonempty_has_size) + thus ?thesis by auto +qed + +lemma points_index_one_unique: + assumes "B index ps = 1" + assumes "bl \# B" and "ps \ bl" and "bl' \# B" and "ps \ bl'" + shows "bl = bl'" +proof (rule ccontr) + assume assm: "bl \ bl'" + then have bl1: "bl \# {#bl \# B . ps \ bl#}" using assms by simp + then have bl2: "bl'\# {#bl \# B . ps \ bl#}" using assms by simp + then have "{#bl, bl'#} \# {#bl \# B . ps \ bl#}" using assms by (metis bl1 bl2 points_index_def + add_mset_subseteq_single_iff assm mset_subset_eq_single size_single subseteq_mset_size_eql) + then have "size {#bl \# B . ps \ bl#} \ 2" using size_mset_mono by fastforce + thus False using assms by (metis numeral_le_one_iff points_index_def semiring_norm(69)) +qed + +lemma points_index_one_unique_block: + assumes "B index ps = 1" + shows "\! bl . (bl \# B \ ps \ bl)" + using assms points_index_gt0_impl_existance points_index_one_unique + by (metis zero_less_one) + +lemma points_index_one_not_unique_block: + assumes "B index ps = 1" + assumes "ps \ bl" + assumes "bl \# B" + assumes "bl' \# B - {#bl#}" + shows "\ ps \ bl'" +proof - + have "B = (B - {#bl#}) + {#bl#}" by (simp add: assms(3)) + then have "(B - {#bl#}) index ps = B index ps - {#bl#} index ps" + by (metis point_index_diff) + then have "(B - {#bl#}) index ps = 0" using assms points_index_singleton + by (metis diff_self_eq_0) + thus ?thesis using assms(4) points_index_0_left_imp by auto +qed + +lemma (in incidence_system) points_index_alt_def: "\ index ps = size {#b \# \ . ps \ b#}" + by (simp add: points_index_def) + +lemma (in incidence_system) points_index_ps_nin: "\ (ps \ \) \ \ index ps = 0" + using points_index_alt_def filter_mset_empty_conv in_mono size_empty subsetI wf_invalid_point + by metis + +lemma (in incidence_system) points_index_count_bl: + "multiplicity bl \ n \ ps \ bl \ count {#bl \# \ . ps \ bl#} bl \ n" + by simp + +lemma (in finite_incidence_system) points_index_zero: + assumes "card ps > card \" + shows "\ index ps = 0" +proof - + have "\ b. b \# \ \ card ps > card b" + using block_size_lt_order card_subset_not_gt_card finite_sets assms by fastforce + then have "{#b \# \ . ps \ b#} = {#}" + by (simp add: card_subset_not_gt_card filter_mset_empty_conv finite_blocks) + thus ?thesis using points_index_alt_def by simp +qed + +lemma (in design) points_index_subset: + "x \# {#bl \# \ . ps \ bl#} \ ps \ \ \ (\ index ps) \ (size x)" + by (simp add: points_index_def size_mset_mono) + +lemma (in design) points_index_count_min: "multiplicity bl \ n \ ps \ bl \ \ index ps \ n" + using points_index_alt_def set_count_size_min by (metis filter_mset.rep_eq) + +subsubsection \Intersection Number\ + +text \The intersection number of two blocks is the size of the intersection of those blocks. i.e. +the number of points which occur in both blocks\ +definition intersection_number :: "'a set \ 'a set \ int" (infix "|\|" 70) where +"b1 |\| b2 \ card (b1 \ b2)" + +lemma intersection_num_non_neg: "b1 |\| b2 \ 0" + by (simp add: intersection_number_def) + +lemma intersection_number_empty_iff: + assumes "finite b1" + shows "b1 \ b2 = {} \ b1 |\| b2 = 0" + by (simp add: intersection_number_def assms) + +lemma intersect_num_commute: "b1 |\| b2 = b2 |\| b1" + by (simp add: inf_commute intersection_number_def) + +definition n_intersect_number :: "'a set \ nat\ 'a set \ int" where +"n_intersect_number b1 n b2 \ card { x \ Pow (b1 \ b2) . card x = n}" + +notation n_intersect_number ("(_ |\|\<^sub>_ _)" [52, 51, 52] 50) + +lemma n_intersect_num_subset_def: "b1 |\|\<^sub>n b2 = card {x . x \ b1 \ b2 \ card x = n}" + using n_intersect_number_def by auto + +lemma n_inter_num_one: "finite b1 \ finite b2 \ b1 |\|\<^sub>1 b2 = b1 |\| b2" + using n_intersect_number_def intersection_number_def card_Pow_filter_one + by (metis (full_types) finite_Int) + +lemma n_inter_num_choose: "finite b1 \ finite b2 \ b1 |\|\<^sub>n b2 = (card (b1 \ b2) choose n)" + using n_subsets n_intersect_num_subset_def + by (metis (full_types) finite_Int) + +lemma set_filter_single: "x \ A \ {a \ A . a = x} = {x}" + by auto + +lemma (in design) n_inter_num_zero: + assumes "b1 \# \" and "b2 \# \" + shows "b1 |\|\<^sub>0 b2 = 1" +proof - + have empty: "\x . finite x \ card x = 0 \ x = {}" + by simp + have empt_in: "{} \ Pow (b1 \ b2)" by simp + have "finite (b1 \ b2)" using finite_blocks assms by simp + then have "\ x . x \ Pow (b1 \ b2) \ finite x" by (meson PowD finite_subset) + then have "{x \ Pow (b1 \ b2) . card x = 0} = {x \ Pow (b1 \ b2) . x = {}}" + using empty by (metis card.empty) + then have "{x \ Pow (b1 \ b2) . card x = 0} = {{}}" + by (simp add: empt_in set_filter_single Collect_conv_if) + thus ?thesis by (simp add: n_intersect_number_def) +qed + +lemma (in design) n_inter_num_choose_design: "b1 \# \ \ b2 \# \ + \ b1 |\|\<^sub>n b2 = (card (b1 \ b2) choose n) " + using finite_blocks by (simp add: n_inter_num_choose) + +lemma (in design) n_inter_num_choose_design_inter: "b1 \# \ \ b2 \# \ + \ b1 |\|\<^sub>n b2 = (nat (b1 |\| b2) choose n) " + using finite_blocks by (simp add: n_inter_num_choose intersection_number_def) + +subsection \Incidence System Set Property Definitions\ +context incidence_system +begin + +text \The set of replication numbers for all points of design\ +definition replication_numbers :: "int set" where +"replication_numbers \ {\ rep x | x . x \ \}" + +lemma replication_numbers_non_empty: + assumes "\ \ {}" + shows "replication_numbers \ {}" + by (simp add: assms replication_numbers_def) + +lemma obtain_point_with_rep: "r \ replication_numbers \ \ x. x \ \ \ \ rep x = r" + using replication_numbers_def by auto + +lemma point_rep_number_in_set: "x \ \ \ (\ rep x) \ replication_numbers" + by (auto simp add: replication_numbers_def) + +lemma (in finite_incidence_system) replication_numbers_finite: "finite replication_numbers" + using finite_sets by (simp add: replication_numbers_def) + +text \The set of all block sizes in a system\ + +definition sys_block_sizes :: "int set" where +"sys_block_sizes \ { (int (card bl)) | bl. bl \# \}" + +lemma block_sizes_non_empty_set: + assumes "\ \ {#}" + shows "sys_block_sizes \ {}" +by (simp add: sys_block_sizes_def assms) + +lemma finite_block_sizes: "finite (sys_block_sizes)" + by (simp add: sys_block_sizes_def) + +lemma block_sizes_non_empty: + assumes "\ \ {#}" + shows "card (sys_block_sizes) > 0" + using finite_block_sizes block_sizes_non_empty_set + by (simp add: assms card_gt_0_iff) + +lemma sys_block_sizes_in: "bl \# \ \ card bl \ sys_block_sizes" + unfolding sys_block_sizes_def by auto + +lemma sys_block_sizes_obtain_bl: "x \ sys_block_sizes \ (\ bl \# \. int (card bl) = x)" + by (auto simp add: sys_block_sizes_def) + +text \The set of all possible intersection numbers in a system.\ + +definition intersection_numbers :: "int set" where +"intersection_numbers \ { b1 |\| b2 | b1 b2 . b1 \# \ \ b2 \# (\ - {#b1#})}" + +lemma obtain_blocks_intersect_num: "n \ intersection_numbers \ + \ b1 b2. b1 \# \ \ b2 \# (\ - {#b1#}) \ b1 |\| b2 = n" + by (auto simp add: intersection_numbers_def) + +lemma intersect_num_in_set: "b1 \# \ \ b2 \# (\ - {#b1#}) \ b1 |\| b2 \ intersection_numbers" + by (auto simp add: intersection_numbers_def) + +text \The set of all possible point indices\ +definition point_indices :: "int \ int set" where +"point_indices t \ {\ index ps | ps. int (card ps) = t \ ps \ \}" + +lemma point_indices_elem_in: "ps \ \ \ card ps = t \ \ index ps \ point_indices t" + by (auto simp add: point_indices_def) + +lemma point_indices_alt_def: "point_indices t = { \ index ps | ps. int (card ps) = t \ ps \ \}" + by (simp add: point_indices_def) + +end + +subsection \Basic Constructions on designs\ + +text \This section defines some of the most common universal constructions found in design theory +involving only a single design\ + +subsubsection \Design Complements\ + +context incidence_system +begin + +text \The complement of a block are all the points in the design not in that block. +The complement of a design is therefore the original point sets, and set of all block complements\ +definition block_complement:: "'a set \ 'a set" ("_\<^sup>c" [56] 55) where +"block_complement b \ \ - b" + +definition complement_blocks :: "'a set multiset" ("(\\<^sup>C)")where +"complement_blocks \ {# bl\<^sup>c . bl \# \ #}" + +lemma block_complement_elem_iff: + assumes "ps \ \" + shows "ps \ bl\<^sup>c \ (\ x \ ps. x \ bl)" + using assms block_complement_def by (auto) + +lemma block_complement_inter_empty: "bl1\<^sup>c = bl2 \ bl1 \ bl2 = {}" + using block_complement_def by auto + +lemma block_complement_inv: + assumes "bl \# \" + assumes "bl\<^sup>c = bl2" + shows "bl2\<^sup>c = bl" + by (metis Diff_Diff_Int assms(1) assms(2) block_complement_def inf.absorb_iff2 wellformed) + +lemma block_complement_subset_points: "ps \ (bl\<^sup>c) \ ps \ \" + using block_complement_def by blast + +lemma obtain_comp_block_orig: + assumes "bl1 \# \\<^sup>C" + obtains bl2 where "bl2 \# \" and "bl1 = bl2\<^sup>c" + using wellformed assms by (auto simp add: complement_blocks_def) + +lemma complement_same_b [simp]: "size \\<^sup>C = size \" + by (simp add: complement_blocks_def) + +lemma block_comp_elem_alt_left: "x \ bl \ ps \ bl\<^sup>c \ x \ ps" + by (auto simp add: block_complement_def block_complement_elem_iff) + +lemma block_comp_elem_alt_right: "ps \ \ \ (\ x . x \ ps \ x \ bl) \ ps \ bl\<^sup>c" + by (auto simp add: block_complement_elem_iff) + +lemma complement_index: + assumes "ps \ \" + shows "\\<^sup>C index ps = size {# b \# \ . (\ x \ ps . x \ b) #}" +proof - + have "\\<^sup>C index ps = size {# b \# {# bl\<^sup>c . bl \# \#}. ps \ b #}" + by (simp add: complement_blocks_def points_index_def) + then have "\\<^sup>C index ps = size {# bl\<^sup>c | bl \# \ . ps \ bl\<^sup>c #}" + by (metis image_mset_filter_swap) + thus ?thesis using assms by (simp add: block_complement_elem_iff) +qed + +lemma complement_index_2: + assumes "{x, y} \ \" + shows "\\<^sup>C index {x, y} = size {# b \# \ . x \ b \ y \ b #}" +proof - + have a: "\ b. b \# \ \ \ x' \ {x, y} . x' \ b \ x \ b \ y \ b" + by simp + have "\ b. b \# \ \ x \ b \ y \ b \ \ x' \ {x, y} . x' \ b " + by simp + thus ?thesis using assms a complement_index + by (smt (verit) filter_mset_cong) +qed + +lemma complement_rep_number: + assumes "x \ \" and "\ rep x = r" + shows "\\<^sup>C rep x = \ - r" +proof - + have r: "size {#b \# \ . x \ b#} = r" using assms by (simp add: point_replication_number_def) + then have a: "\ b . b \# \ \ x \ b \ x \ b\<^sup>c" + by (simp add: block_complement_def) + have "\ b . b \# \ \ x \ b \ x \ b\<^sup>c" + by (simp add: assms(1) block_complement_def) + then have alt: "(image_mset block_complement \) rep x = size {#b \# \ . x \ b#}" + using a filter_mset_cong image_mset_filter_swap2 point_replication_number_def + by (smt (verit, ccfv_SIG) size_image_mset) + have "\ = size {#b \# \ . x \ b#} + size {#b \# \ . x \ b#}" + by (metis multiset_partition size_union) + thus ?thesis using alt + by (simp add: r complement_blocks_def) +qed + +lemma complement_blocks_wf: "bl \# \\<^sup>C \ bl \ \" + by (auto simp add: complement_blocks_def block_complement_def) + +lemma complement_wf [intro]: "incidence_system \ \\<^sup>C" + using complement_blocks_wf by (unfold_locales) + +interpretation sys_complement: incidence_system "\" "\\<^sup>C" + using complement_wf by simp +end + +context finite_incidence_system +begin +lemma block_complement_size: "b \ \ \ card (b\<^sup>c) = card \ - card b" + by (simp add: block_complement_def card_Diff_subset finite_subset card_mono of_nat_diff finite_sets) + +lemma block_comp_incomplete: "incomplete_block bl \ card (bl\<^sup>c) > 0" + using block_complement_size by (simp add: wellformed) + +lemma block_comp_incomplete_nempty: "incomplete_block bl \ bl\<^sup>c \ {}" + using wellformed block_complement_def finite_blocks + by (auto simp add: block_complement_size block_comp_incomplete card_subset_not_gt_card) + +lemma incomplete_block_proper_subset: "incomplete_block bl \ bl \ \" + using wellformed by fastforce + +lemma complement_finite: "finite_incidence_system \ \\<^sup>C" + using complement_wf finite_sets by (simp add: incidence_system.finite_sysI) + +interpretation comp_fin: finite_incidence_system \ "\\<^sup>C" + using complement_finite by simp + +end + +context design +begin +lemma (in design) complement_design: + assumes "\ bl . bl \# \ \ incomplete_block bl" + shows "design \ (\\<^sup>C)" +proof - + interpret fin: finite_incidence_system \ "\\<^sup>C" using complement_finite by simp + show ?thesis using assms block_comp_incomplete_nempty wellformed + by (unfold_locales) (auto simp add: complement_blocks_def) +qed + +end +subsubsection \Multiples\ +text \An easy way to construct new set systems is to simply multiply the block collection by some +constant\ + +context incidence_system +begin + +abbreviation multiple_blocks :: "nat \ 'a set multiset" where +"multiple_blocks n \ repeat_mset n \" + +lemma multiple_block_in_original: "b \# multiple_blocks n \ b \# \" + by (simp add: elem_in_repeat_in_original) + +lemma multiple_block_in: "n > 0 \ b \# \ \ b \# multiple_blocks n" + by (simp add: elem_in_original_in_repeat) + +lemma multiple_blocks_gt: "n > 0 \ size (multiple_blocks n) \ size \" + by (simp) + +lemma block_original_count_le: "n > 0 \ count \ b \ count (multiple_blocks n) b" + using count_repeat_mset by simp + +lemma multiple_blocks_sub: "n > 0 \ \ \# (multiple_blocks n)" + by (simp add: mset_subset_eqI block_original_count_le) + +lemma multiple_1_same: "multiple_blocks 1 = \" + by simp + +lemma multiple_unfold_1: "multiple_blocks (Suc n) = (multiple_blocks n) + \" + by simp + +lemma multiple_point_rep_num: "(multiple_blocks n) rep x = (\ rep x) * n" +proof (induction n) + case 0 + then show ?case by (simp add: point_replication_number_def) +next + case (Suc n) + then have "multiple_blocks (Suc n) rep x = \ rep x * n + (\ rep x)" + using Suc.IH Suc.prems by (simp add: union_commute point_replication_number_def) + then show ?case + by (simp add: int_distrib(2)) +qed + +lemma multiple_point_index: "(multiple_blocks n) index ps = (\ index ps) * n" + by (induction n) (auto simp add: points_index_def) + +lemma repeat_mset_block_point_rel: "\b x. b \# multiple_blocks n \ x \ b \ x \ \" + by (induction n) (auto, meson subset_iff wellformed) + +lemma multiple_is_wellformed: "incidence_system \ (multiple_blocks n)" + using repeat_mset_subset_in wellformed repeat_mset_block_point_rel by (unfold_locales) (auto) + +lemma multiple_blocks_num [simp]: "size (multiple_blocks n) = n*\" + by simp + +interpretation mult_sys: incidence_system \ "(multiple_blocks n)" + by (simp add: multiple_is_wellformed) + +lemma multiple_block_multiplicity [simp]: "mult_sys.multiplicity n bl = (multiplicity bl) * n" + by (simp) + +lemma multiple_block_sizes_same: + assumes "n > 0" + shows "sys_block_sizes = mult_sys.sys_block_sizes n" +proof - + have def: "mult_sys.sys_block_sizes n = {card bl | bl. bl \# (multiple_blocks n)}" + by (simp add: mult_sys.sys_block_sizes_def) + then have eq: "\ bl. bl \# (multiple_blocks n) \ bl \# \" + using assms multiple_block_in multiple_block_in_original by blast + thus ?thesis using def by (simp add: sys_block_sizes_def eq) +qed + +end + +context finite_incidence_system +begin + +lemma multiple_is_finite: "finite_incidence_system \ (multiple_blocks n)" + using multiple_is_wellformed finite_sets by (unfold_locales) (auto simp add: incidence_system_def) + +end + +context design +begin + +lemma multiple_is_design: "design \ (multiple_blocks n)" +proof - + interpret fis: finite_incidence_system \ "multiple_blocks n" using multiple_is_finite by simp + show ?thesis using blocks_nempty + by (unfold_locales) (auto simp add: elem_in_repeat_in_original repeat_mset_not_empty) +qed + +end + +subsection \Simple Designs\ + +text \Simple designs are those in which the multiplicity of each block is at most one. +In other words, the block collection is a set. This can significantly ease reasoning.\ + +locale simple_incidence_system = incidence_system + + assumes simple [simp]: "bl \# \ \ multiplicity bl = 1" + +begin + +lemma simple_alt_def_all: "\ bl \# \ . multiplicity bl = 1" + using simple by auto + +lemma simple_blocks_eq_sup: "mset_set (design_support) = \" + using distinct_mset_def simple design_support_def by (metis distinct_mset_set_mset_ident) + +lemma simple_block_size_eq_card: "\ = card (design_support)" + by (metis simple_blocks_eq_sup size_mset_set) + +lemma points_index_simple_def: "\ index ps = card {b \ design_support . ps \ b}" + using design_support_def points_index_def card_size_filter_eq simple_blocks_eq_sup + by (metis finite_set_mset) + +lemma replication_num_simple_def: "\ rep x = card {b \ design_support . x \ b}" + using design_support_def point_replication_number_def card_size_filter_eq simple_blocks_eq_sup + by (metis finite_set_mset) + +end + +locale simple_design = design + simple_incidence_system + +text \Additional reasoning about when something is not simple\ +context incidence_system +begin +lemma simple_not_multiplicity: "b \# \ \ multiplicity b > 1 \ \ simple_incidence_system \ \" + using simple_incidence_system_def simple_incidence_system_axioms_def by (metis nat_neq_iff) + +lemma multiple_not_simple: + assumes "n > 1" + assumes "\ \ {#}" + shows "\ simple_incidence_system \ (multiple_blocks n)" +proof (rule ccontr, simp) + assume "simple_incidence_system \ (multiple_blocks n)" + then have "\ bl. bl \# \ \ count (multiple_blocks n) bl = 1" + using assms(1) elem_in_original_in_repeat + by (metis not_gr_zero not_less_zero simple_incidence_system.simple) + thus False using assms by auto +qed + +end + +subsection \Proper Designs\ +text \Many types of designs rely on parameter conditions that only make sense for non-empty designs. +i.e. designs with at least one block, and therefore given well-formed condition, at least one point. +To this end we define the notion of a "proper" design\ + +locale proper_design = design + + assumes b_non_zero: "\ \ 0" +begin + +lemma is_proper: "proper_design \ \" by intro_locales + +lemma v_non_zero: "\ > 0" + using b_non_zero v_eq0_imp_b_eq_0 by auto + +lemma b_positive: "\ > 0" using b_non_zero + by (simp add: nonempty_has_size) + +lemma design_points_nempty: "\ \ {}" + using v_non_zero by auto + +lemma design_blocks_nempty: "\ \ {#}" + using b_non_zero by auto + +end + +text \Intro rules for a proper design\ +lemma (in design) proper_designI[intro]: "\ \ 0 \ proper_design \ \" + by (unfold_locales) simp + +lemma proper_designII[intro]: + assumes "design V B" and "B \ {#}" + shows "proper_design V B" +proof - + interpret des: design V B using assms by simp + show ?thesis using assms by unfold_locales simp +qed + +text \Reasoning on construction closure for proper designs\ +context proper_design +begin + +lemma multiple_proper_design: + assumes "n > 0" + shows "proper_design \ (multiple_blocks n)" + using multiple_is_design assms design_blocks_nempty multiple_block_in + by (metis block_set_nempty_imp_block_ex empty_iff proper_designII set_mset_empty) + +lemma complement_proper_design: + assumes "\ bl . bl \# \ \ incomplete_block bl" + shows "proper_design \ \\<^sup>C" +proof - + interpret des: design \ "\\<^sup>C" + by (simp add: assms complement_design) + show ?thesis using b_non_zero by (unfold_locales) auto +qed + +end +end \ No newline at end of file diff --git a/thys/Design_Theory/Design_Isomorphisms.thy b/thys/Design_Theory/Design_Isomorphisms.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Design_Isomorphisms.thy @@ -0,0 +1,398 @@ +(* Title: Design_Isomorphisms + Author: Chelsea Edmonds +*) + +section \Design Isomorphisms\ + +theory Design_Isomorphisms imports Design_Basics Sub_Designs +begin + +subsection \Images of Set Systems\ + +text \We loosely define the concept of taking the "image" of a set system, as done in isomorphisms. +Note that this is not based off mathematical theory, but is for ease of notation\ +definition blocks_image :: "'a set multiset \ ('a \ 'b) \ 'b set multiset" where +"blocks_image B f \ image_mset ((`) f) B" + +lemma image_block_set_constant_size: "size (B) = size (blocks_image B f)" + by (simp add: blocks_image_def) + +lemma (in incidence_system) image_set_system_wellformed: + "incidence_system (f ` \) (blocks_image \ f)" + by (unfold_locales, auto simp add: blocks_image_def) (meson image_eqI wf_invalid_point) + +lemma (in finite_incidence_system) image_set_system_finite: + "finite_incidence_system (f ` \) (blocks_image \ f)" + using image_set_system_wellformed finite_sets + by (intro_locales) (simp_all add: blocks_image_def finite_incidence_system_axioms.intro) + +subsection \Incidence System Isomorphisms\ + +text \Isomorphism's are defined by the Handbook of Combinatorial Designs +\cite{colbournHandbookCombinatorialDesigns2007}\ + +locale incidence_system_isomorphism = source: incidence_system \ \ + target: incidence_system \' \' + for "\" and "\" and "\'" and "\'" + fixes bij_map ("\") + assumes bij: "bij_betw \ \ \'" + assumes block_img: "image_mset ((`) \) \ = \'" +begin + +lemma iso_eq_order: "card \ = card \'" + using bij bij_betw_same_card by auto + +lemma iso_eq_block_num: "size \ = size \'" + using block_img by (metis size_image_mset) + +lemma iso_block_img_alt_rep: "{# \ ` bl . bl \# \#} = \'" + using block_img by simp + +lemma inv_iso_block_img: "image_mset ((`) (inv_into \ \)) \' = \" +proof - + have "\ x. x \ \ \ ((inv_into \ \) \ \) x = x" + using bij bij_betw_inv_into_left comp_apply by fastforce + then have "\ bl x . bl \# \ \ x \ bl \ ((inv_into \ \) \ \) x = x" + using source.wellformed by blast + then have img: "\ bl . bl \# \ \ image ((inv_into \ \) \ \) bl = bl" + by simp + have "image_mset ((`) (inv_into \ \)) \' = image_mset ((`) (inv_into \ \)) (image_mset ((`) \) \)" + using block_img by simp + then have "image_mset ((`) (inv_into \ \)) \' = image_mset ((`) ((inv_into \ \) \ \)) \" + by (metis (no_types, hide_lams) comp_apply image_comp multiset.map_comp multiset.map_cong0) + thus ?thesis using img by simp +qed + +lemma inverse_incidence_sys_iso: "incidence_system_isomorphism \' \' \ \ (inv_into \ \)" + using bij bij_betw_inv_into inv_iso_block_img by (unfold_locales) simp + +lemma iso_points_map: "\ ` \ = \'" + using bij by (simp add: bij_betw_imp_surj_on) + +lemma iso_points_inv_map: "(inv_into \ \) ` \' = \" + using incidence_system_isomorphism.iso_points_map inverse_incidence_sys_iso by blast + +lemma iso_points_ss_card: + assumes "ps \ \" + shows "card ps = card (\ ` ps)" + using assms bij bij_betw_same_card bij_betw_subset by blast + +lemma iso_block_in: "bl \# \ \ (\ ` bl) \# \'" + using iso_block_img_alt_rep + by (metis image_eqI in_image_mset) + +lemma iso_inv_block_in: "x \# \' \ x \ (`) \ ` set_mset \" + by (metis block_img in_image_mset) + +lemma iso_img_block_orig_exists: "x \# \' \ \ bl . bl \# \ \ x = \ ` bl" + using iso_inv_block_in by blast + +lemma iso_blocks_map_inj: "x \# \ \ y \# \ \ \ ` x = \ ` y \ x = y" + using image_inv_into_cancel incidence_system.wellformed iso_points_inv_map iso_points_map + by (metis (no_types, lifting) source.incidence_system_axioms subset_image_iff) + +lemma iso_bij_betwn_block_sets: "bij_betw ((`) \) (set_mset \) (set_mset \')" + apply ( simp add: bij_betw_def inj_on_def) + using iso_block_in iso_inv_block_in iso_blocks_map_inj by auto + +lemma iso_bij_betwn_block_sets_inv: "bij_betw ((`) (inv_into \ \)) (set_mset \') (set_mset \)" + using incidence_system_isomorphism.iso_bij_betwn_block_sets inverse_incidence_sys_iso by blast + +lemma iso_bij_betw_individual_blocks: "bl \# \ \ bij_betw \ bl (\ ` bl)" + using bij bij_betw_subset source.wellformed by blast + +lemma iso_bij_betw_individual_blocks_inv: "bl \# \ \ bij_betw (inv_into \ \) (\ ` bl) bl" + using bij bij_betw_subset source.wellformed bij_betw_inv_into_subset by fastforce + +lemma iso_bij_betw_individual_blocks_inv_alt: + "bl \# \' \ bij_betw (inv_into \ \) bl ((inv_into \ \) ` bl)" + using incidence_system_isomorphism.iso_bij_betw_individual_blocks inverse_incidence_sys_iso + by blast + +lemma iso_inv_block_in_alt: "(\ ` bl) \# \' \ bl \ \ \ bl \# \" + using image_eqI image_inv_into_cancel inv_iso_block_img iso_points_inv_map + by (metis (no_types, lifting) iso_points_map multiset.set_map subset_image_iff) + +lemma iso_img_block_not_in: + assumes "x \# \" + assumes "x \ \" + shows "(\ ` x) \# \'" +proof (rule ccontr) + assume a: "\ \ ` x \# \'" + then have a: "\ ` x \# \'" by simp + then have "\ y . y \ (\ ` x) \ (inv_into \ \) y \ \" + using target.wf_invalid_point iso_points_inv_map by auto + then have "((`) (inv_into \ \)) (\ ` x) \# \" + using iso_bij_betwn_block_sets_inv by (meson a bij_betw_apply) + thus False + using a assms(1) assms(2) iso_inv_block_in_alt by blast +qed + +lemma iso_block_multiplicity: + assumes "bl \ \" + shows "source.multiplicity bl = target.multiplicity (\ ` bl)" +proof (cases "bl \# \") + case True + have "inj_on ((`) \) (set_mset \)" + using bij_betw_imp_inj_on iso_bij_betwn_block_sets by auto + then have "count \ bl = count \' (\ ` bl)" + using count_image_mset_le_count_inj_on count_image_mset_ge_count True block_img inv_into_f_f + less_le_not_le order.not_eq_order_implies_strict by metis + thus ?thesis by simp +next + case False + have s_mult: "source.multiplicity bl = 0" + by (simp add: False count_eq_zero_iff) + then have "target.multiplicity (\ ` bl) = 0" + using False count_inI iso_inv_block_in_alt + by (metis assms) + thus ?thesis + using s_mult by simp +qed + +lemma iso_point_in_block_img_iff: "p \ \ \ bl \# \ \ p \ bl \ (\ p) \ (\ ` bl)" + by (metis bij bij_betw_imp_surj_on iso_bij_betw_individual_blocks_inv bij_betw_inv_into_left imageI) + +lemma iso_point_subset_block_iff: "p \ \ \ bl \# \ \ p \ bl \ (\ ` p) \ (\ ` bl)" + apply auto + using image_subset_iff iso_point_in_block_img_iff subset_iff by metis + +lemma iso_is_image_block: "\' = blocks_image \ \" + unfolding blocks_image_def by (simp add: block_img iso_points_map) + +end + +subsection \Design Isomorphisms\ +text \Apply the concept of isomorphisms to designs only\ + +locale design_isomorphism = incidence_system_isomorphism \ \ \' \' \ + source: design \ \ + + target: design \' \' for \ and \ and \' and \' and bij_map ("\") + +context design_isomorphism +begin + +lemma inverse_design_isomorphism: "design_isomorphism \' \' \ \ (inv_into \ \)" + using inverse_incidence_sys_iso source.wf_design target.wf_design + by (simp add: design_isomorphism.intro) + +end + +subsubsection \Isomorphism Operation\ +text \Define the concept of isomorphic designs outside the scope of locale\ + +definition isomorphic_designs (infixl "\\<^sub>D" 50) where +"\ \\<^sub>D \' \ (\ \ . design_isomorphism (fst \) (snd \) (fst \') (snd \') \)" + +lemma isomorphic_designs_symmetric: "(\, \) \\<^sub>D (\', \') \ (\', \') \\<^sub>D (\, \)" + using isomorphic_designs_def design_isomorphism.inverse_design_isomorphism + by metis + +lemma isomorphic_designs_implies_bij: "(\, \) \\<^sub>D (\', \') \ \ \ . bij_betw \ \ \'" + using incidence_system_isomorphism.bij isomorphic_designs_def + by (metis design_isomorphism.axioms(1) fst_conv) + +lemma isomorphic_designs_implies_block_map: "(\, \) \\<^sub>D (\', \') \ \ \ . image_mset ((`) \) \ = \'" + using incidence_system_isomorphism.block_img isomorphic_designs_def + using design_isomorphism.axioms(1) by fastforce + +context design +begin + +lemma isomorphic_designsI [intro]: "design \' \' \ bij_betw \ \ \' \ image_mset ((`) \) \ = \' + \ (\, \) \\<^sub>D (\', \')" + using design_isomorphism.intro isomorphic_designs_def wf_design image_set_system_wellformed + by (metis bij_betw_imp_surj_on blocks_image_def fst_conv incidence_system_axioms + incidence_system_isomorphism.intro incidence_system_isomorphism_axioms_def snd_conv) + +lemma eq_designs_isomorphic: + assumes "\ = \'" + assumes "\ = \'" + shows "(\, \) \\<^sub>D (\', \')" +proof - + interpret d1: design \ \ using assms + using wf_design by auto + interpret d2: design \' \' using assms + using wf_design by blast + have "design_isomorphism \ \ \' \' id" using assms by (unfold_locales) simp_all + thus ?thesis unfolding isomorphic_designs_def by auto +qed + +end + +context design_isomorphism +begin + +subsubsection \Design Properties/Operations under Isomorphism\ + +lemma design_iso_point_rep_num_eq: + assumes "p \ \" + shows "\ rep p = \' rep (\ p)" +proof - + have "{#b \# \ . p \ b#} = {#b \# \ . \ p \ \ ` b#}" + using assms filter_mset_cong iso_point_in_block_img_iff assms by force + then have "{#b \# \' . \ p \ b#} = image_mset ((`) \) {#b \# \ . p \ b#}" + by (simp add: image_mset_filter_swap block_img) + thus ?thesis + by (simp add: point_replication_number_def) +qed + +lemma design_iso_rep_numbers_eq: "source.replication_numbers = target.replication_numbers" + apply (simp add: source.replication_numbers_def target.replication_numbers_def) + using design_iso_point_rep_num_eq design_isomorphism.design_iso_point_rep_num_eq iso_points_map + by (metis (no_types, hide_lams) imageI inverse_design_isomorphism iso_points_inv_map) + +lemma design_iso_block_size_eq: "bl \# \ \ card bl = card (\ ` bl)" + using card_image_le finite_subset_image image_inv_into_cancel + by (metis iso_points_inv_map iso_points_map le_antisym source.finite_blocks source.wellformed) + +lemma design_iso_block_sizes_eq: "source.sys_block_sizes = target.sys_block_sizes" + apply (simp add: source.sys_block_sizes_def target.sys_block_sizes_def) + by (metis (no_types, hide_lams) design_iso_block_size_eq iso_block_in iso_img_block_orig_exists) + +lemma design_iso_points_index_eq: + assumes "ps \ \" + shows "\ index ps = \' index (\ ` ps)" +proof - + have "\ b . b \# \ \ ((ps \ b) = ((\ ` ps) \ \ ` b))" + using iso_point_subset_block_iff assms by blast + then have "{#b \# \ . ps \ b#} = {#b \# \ . (\ ` ps) \ (\ ` b)#}" + using assms filter_mset_cong by force + then have "{#b \# \' . \ ` ps \ b#} = image_mset ((`) \) {#b \# \ . ps \ b#}" + by (simp add: image_mset_filter_swap block_img) + thus ?thesis + by (simp add: points_index_def) +qed + +lemma design_iso_points_indices_imp: + assumes "x \ source.point_indices t" + shows "x \ target.point_indices t" +proof - + obtain ps where t: "card ps = t" and ss: "ps \ \" and x: "\ index ps = x" using assms + by (auto simp add: source.point_indices_def) + then have x_val: "x = \' index (\ ` ps)" using design_iso_points_index_eq by auto + have x_img: " (\ ` ps) \ \'" + using ss bij iso_points_map by fastforce + then have "card (\ ` ps) = t" using t ss iso_points_ss_card by auto + then show ?thesis using target.point_indices_elem_in x_img x_val by blast +qed + +lemma design_iso_points_indices_eq: "source.point_indices t = target.point_indices t" + using inverse_design_isomorphism design_isomorphism.design_iso_points_indices_imp + design_iso_points_indices_imp by blast + +lemma design_iso_block_intersect_num_eq: + assumes "b1 \# \" + assumes "b2 \# \" + shows "b1 |\| b2 = (\ ` b1) |\| (\ ` b2)" +proof - + have split: "\ ` (b1 \ b2) = (\ ` b1) \ (\ ` b2)" using assms bij bij_betw_inter_subsets + by (metis source.wellformed) + thus ?thesis using source.wellformed + by (simp add: intersection_number_def iso_points_ss_card split assms(2) inf.coboundedI2) +qed + +lemma design_iso_inter_numbers_imp: + assumes "x \ source.intersection_numbers" + shows "x \ target.intersection_numbers" +proof - + obtain b1 b2 where 1: "b1 \# \" and 2: "b2 \# (remove1_mset b1 \)" and xval: "x = b1 |\| b2" + using assms by (auto simp add: source.intersection_numbers_def) + then have pi1: "\ ` b1 \# \'" by (simp add: iso_block_in) + have pi2: "\ ` b2 \# (remove1_mset (\ ` b1) \')" using iso_block_in 2 + by (metis (no_types, lifting) "1" block_img image_mset_remove1_mset_if in_remove1_mset_neq + iso_blocks_map_inj more_than_one_mset_mset_diff multiset.set_map) + have "x = (\ ` b1) |\| (\ ` b2)" using 1 2 design_iso_block_intersect_num_eq + by (metis in_diffD xval) + then have "x \ {b1 |\| b2 | b1 b2 . b1 \# \' \ b2 \# (\' - {#b1#})}" + using pi1 pi2 by blast + then show ?thesis by (simp add: target.intersection_numbers_def) +qed + +lemma design_iso_intersection_numbers: "source.intersection_numbers = target.intersection_numbers" + using inverse_design_isomorphism design_isomorphism.design_iso_inter_numbers_imp + design_iso_inter_numbers_imp by blast + +lemma design_iso_n_intersect_num: + assumes "b1 \# \" + assumes "b2 \# \" + shows "b1 |\|\<^sub>n b2 = ((\ ` b1) |\|\<^sub>n (\ ` b2))" +proof - + let ?A = "{x . x \ b1 \ x \ b2 \ card x = n}" + let ?B = "{y . y \ (\ ` b1) \ y \ (\ ` b2) \ card y = n}" + have b1v: "b1 \ \" by (simp add: assms(1) source.wellformed) + have b2v: "b2 \ \" by (simp add: assms(2) source.wellformed) + then have "\x y . x \ b1 \ x \ b2 \ y \ b1 \ y \ b2 \ \ ` x = \ ` y \ x = y" + using b1v bij by (metis bij_betw_imp_surj_on bij_betw_inv_into_subset dual_order.trans) + then have inj: "inj_on ((`) \) ?A" by (simp add: inj_on_def) + have eqcard: "\xa. xa \ b1 \ xa \ b2 \ card (\ ` xa) = card xa" using b1v b2v bij + using iso_points_ss_card by auto + have surj: "\x. x \ \ ` b1 \ x \ \ ` b2 \ + x \ {(\ ` xa) | xa . xa \ b1 \ xa \ b2 \ card xa = card x}" + proof - + fix x + assume x1: "x \ \ ` b1" and x2: "x \ \ ` b2" + then obtain xa where eq_x: "\ ` xa = x" and ss: "xa \ \" + by (metis b1v dual_order.trans subset_imageE) + then have f1: "xa \ b1" by (simp add: x1 assms(1) iso_point_subset_block_iff) + then have f2: "xa \ b2" by (simp add: eq_x ss assms(2) iso_point_subset_block_iff x2) + then have f3: "card xa = card x" using bij by (simp add: eq_x ss iso_points_ss_card) + then show "x \ {(\ ` xa) | xa . xa \ b1 \ xa \ b2 \ card xa = card x}" + using f1 f2 f3 \\ ` xa = x\ by auto + qed + have "bij_betw ( (`) \) ?A ?B" + proof (auto simp add: bij_betw_def) + show "inj_on ((`) \) {x. x \ b1 \ x \ b2 \ card x = n}" using inj by simp + show "\xa. xa \ b1 \ xa \ b2 \ n = card xa \ card (\ ` xa) = card xa" + using eqcard by simp + show "\x. x \ \ ` b1 \ x \ \ ` b2 \ n = card x \ + x \ (`) \ ` {xa. xa \ b1 \ xa \ b2 \ card xa = card x}" + using surj by (simp add: setcompr_eq_image) + qed + thus ?thesis + using bij_betw_same_card by (auto simp add: n_intersect_number_def) +qed + +lemma subdesign_iso_implies: + assumes "sub_set_system V B \ \" + shows "sub_set_system (\ ` V) (blocks_image B \) \' \'" +proof (unfold_locales) + show "\ ` V \ \'" + by (metis assms image_mono iso_points_map sub_set_system.points_subset) + show "blocks_image B \ \# \'" + by (metis assms block_img blocks_image_def image_mset_subseteq_mono sub_set_system.blocks_subset) +qed + +lemma subdesign_image_is_design: + assumes "sub_set_system V B \ \" + assumes "design V B" + shows "design (\ ` V) (blocks_image B \)" +proof - + interpret fin: finite_incidence_system "(\ ` V)" "(blocks_image B \)" using assms(2) + by (simp add: design.axioms(1) finite_incidence_system.image_set_system_finite) + interpret des: sub_design V B \ \ using assms design.wf_design_iff + by (unfold_locales, auto simp add: sub_set_system.points_subset sub_set_system.blocks_subset) + have bl_img: "blocks_image B \ \# \'" + by (simp add: blocks_image_def des.blocks_subset image_mset_subseteq_mono iso_is_image_block) + then show ?thesis + proof (unfold_locales, auto) + show "{} \# blocks_image B \ \ False" + using assms subdesign_iso_implies target.blocks_nempty bl_img by auto + qed +qed + +lemma sub_design_isomorphism: + assumes "sub_set_system V B \ \" + assumes "design V B" + shows "design_isomorphism V B (\ ` V) (blocks_image B \) \" +proof - + interpret design "(\ ` V)" "(blocks_image B \)" + by (simp add: assms(1) assms(2) subdesign_image_is_design) + interpret des: design V B by fact + show ?thesis + proof (unfold_locales) + show "bij_betw \ V (\ ` V)" using bij + by (metis assms(1) bij_betw_subset sub_set_system.points_subset) + show "image_mset ((`) \) B = blocks_image B \" by (simp add: blocks_image_def) + qed +qed + +end +end \ No newline at end of file diff --git a/thys/Design_Theory/Design_Operations.thy b/thys/Design_Theory/Design_Operations.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Design_Operations.thy @@ -0,0 +1,528 @@ +theory Design_Operations imports Design_Basics +begin + +section \Design Operations\ +text \Incidence systems have a number of very typical computational operations +which can be used for constructions in design theory. Definitions in this section are based off +the handbook of combinatorial designs, hypergraph theory \cite{bergeHypergraphsCombinatoricsFinite1989}, +and the GAP design theory library \cite{soicherDesignsGroupsComputing2013}\ + +subsection \Incidence system definitions\ + +context incidence_system +begin + +text \The basic add point operation only affects the point set of a design\ +definition add_point :: "'a \ 'a set" where +"add_point p \ insert p \" + +lemma add_existing_point [simp]: "p \ \ \ add_point p = \" + using add_point_def by fastforce + +lemma add_point_wf: "incidence_system (add_point p) \" + using wf_invalid_point add_point_def by (unfold_locales) (auto) + +text \An extension of the basic add point operation also adds the point to a given set of blocks\ +definition add_point_to_blocks :: "'a \ 'a set set \ 'a set multiset" where +"add_point_to_blocks p bs \ {# (insert p b) | b \# \ . b \ bs#} + {# b \# \ . b \ bs#}" + +lemma add_point_blocks_blocks_alt: "add_point_to_blocks p bs = + image_mset (insert p) (filter_mset (\ b . b \ bs) \) + (filter_mset (\ b . b \ bs) \)" + using add_point_to_blocks_def by simp + +lemma add_point_existing_blocks: + assumes "(\ bl . bl \ bs \ p \ bl)" + shows "add_point_to_blocks p bs = \" +proof (simp add: add_point_to_blocks_def) + have "image_mset (insert p) {#b \# \. b \ bs#} = {#b \# \. b \ bs#}" using assms + by (simp add: image_filter_cong insert_absorb) + thus "image_mset (insert p) {#b \# \. b \ bs#} + {#b \# \. b \ bs#} = \" + using multiset_partition by simp +qed + +lemma add_new_point_rep_number: + assumes "p \ \" + shows "(add_point_to_blocks p bs) rep p = size {#b \# \ . b \ bs#}" +proof - + have "\ b. b \# \ \ b \ bs \ p \ b" + by (simp add: assms wf_invalid_point) + then have zero: "{# b \# \ . b \ bs#} rep p = 0" + by (simp add: filter_mset_empty_conv point_replication_number_def) + have "(add_point_to_blocks p bs) rep p = {# (insert p b) | b \# \ . b \ bs#} rep p + {# b \# \ . b \ bs#} rep p" + by (simp add: add_point_to_blocks_def) + then have eq: "(add_point_to_blocks p bs) rep p = {# (insert p b) | b \# \ . b \ bs#} rep p" + using zero by simp + have "\ bl . bl \# {# (insert p b) | b \# \ . b \ bs#} \ p \ bl" by auto + then have "{# (insert p b) | b \# \ . b \ bs#} rep p = size {# (insert p b) | b \# \ . b \ bs#}" + using point_replication_number_def by (metis filter_mset_True filter_mset_cong) + thus ?thesis by (simp add: eq) +qed + +lemma add_point_blocks_wf: "incidence_system (add_point p) (add_point_to_blocks p bs)" + by (unfold_locales) (auto simp add: add_point_def wf_invalid_point add_point_to_blocks_def) + +text \Basic (weak) delete point operation removes a point from both the point set and from any +blocks that contain it to maintain wellformed property\ +definition del_point :: "'a \ 'a set" where +"del_point p \ \ - {p}" + +definition del_point_blocks:: "'a \ 'a set multiset" where +"del_point_blocks p \ {# (bl - {p}) . bl \# \ #}" + +lemma del_point_block_count: "size (del_point_blocks p) = size \" + by (simp add: del_point_blocks_def) + +lemma remove_invalid_point_block: "p \ \ \ bl \# \ \ bl - {p} = bl" + using wf_invalid_point by blast + +lemma del_invalid_point: "p \ \ \ (del_point p) = \" + by (simp add: del_point_def) + +lemma del_invalid_point_blocks: "p \ \ \ (del_point_blocks p) = \" + using del_invalid_point + by (auto simp add: remove_invalid_point_block del_point_blocks_def) + +lemma delete_point_p_not_in_bl_blocks: "(\ bl. bl \# \ \ p \ bl) \ (del_point_blocks p) = \" + by (simp add: del_point_blocks_def) + +lemma delete_point_blocks_wf: "b \# (del_point_blocks p) \ b \ \ - {p}" + unfolding del_point_blocks_def using wellformed by auto + +lemma delete_point_blocks_sub: + assumes "b \# (del_point_blocks p)" + obtains bl where "bl \# \ \ b \ bl" + using assms by (auto simp add: del_point_blocks_def) + +lemma delete_point_split_blocks: "del_point_blocks p = + {# bl \#\ . p \ bl#} + {# bl - {p} | bl \# \ . p \ bl#}" +proof - + have sm: "\ bl . p \ bl \ bl - {p} = bl" by simp + have "del_point_blocks p = {# (bl - {p}) . bl \# \ #}" by (simp add: del_point_blocks_def) + also have "... = {# (bl - {p}) | bl \# \ . p \ bl #} + {# (bl - {p}) | bl \# \ . p \ bl #}" + using multiset_partition by (metis image_mset_union union_commute) + finally have "del_point_blocks p = {#bl | bl \# \ . p \ bl#} + + {# (bl - {p}) | bl \# \ . p \ bl #}" + using sm mem_Collect_eq + by (metis (mono_tags, lifting) Multiset.set_mset_filter multiset.map_cong) + thus ?thesis by simp +qed + +lemma delete_point_index_eq: + assumes "ps \ (del_point p)" + shows "(del_point_blocks p) index ps = \ index ps" +proof - + have eq: "filter_mset ((\) ps) {#bl - {p}. bl \# \#} = + image_mset (\ b . b - {p}) (filter_mset (\ b. ps \ b - {p}) \)" + using filter_mset_image_mset by blast + have "p \ ps" using assms del_point_def by blast + then have "\ bl . ps \ bl \ ps \ bl - {p}" by blast + then have "((filter_mset (\ b. ps \ b - {p}) \)) = (filter_mset (\ b . ps \ b) \)" by auto + then have "size (image_mset (\ b . b - {p}) (filter_mset (\ b. ps \ b - {p}) \)) + = \ index ps" + by (simp add: points_index_def) + thus ?thesis using eq + by (simp add: del_point_blocks_def points_index_def) +qed + +lemma delete_point_wf: "incidence_system (del_point p) (del_point_blocks p)" + using delete_point_blocks_wf del_point_def by (unfold_locales) auto + +text \The concept of a strong delete point comes from hypergraph theory. When a point is deleted, +any blocks containing it are also deleted\ +definition str_del_point_blocks :: "'a \ 'a set multiset" where +"str_del_point_blocks p \ {# bl \# \ . p \ bl#}" + +lemma str_del_point_blocks_alt: "str_del_point_blocks p = \ - {# bl \# \ . p \ bl#}" + using add_diff_cancel_left' multiset_partition by (metis str_del_point_blocks_def) + +lemma delete_point_strong_block_in: "p \ bl \ bl \# \ \ bl \# str_del_point_blocks p" + by (simp add: str_del_point_blocks_def) + +lemma delete_point_strong_block_not_in: "p \ bl \ bl \# (str_del_point_blocks) p" + by (simp add: str_del_point_blocks_def) + +lemma delete_point_strong_block_in_iff: "bl \# \ \ bl \# str_del_point_blocks p \ p \ bl" + using delete_point_strong_block_in delete_point_strong_block_not_in + by (simp add: str_del_point_blocks_def) + +lemma delete_point_strong_block_subset: "str_del_point_blocks p \# \" + by (simp add: str_del_point_blocks_def) + +lemma delete_point_strong_block_in_orig: "bl \# str_del_point_blocks p \ bl \# \" + using delete_point_strong_block_subset by (metis mset_subset_eqD) + +lemma delete_invalid_pt_strong_eq: "p \ \ \ \ = str_del_point_blocks p" + unfolding str_del_point_blocks_def using wf_invalid_point empty_iff + by (metis Multiset.diff_cancel filter_mset_eq_conv set_mset_empty subset_mset.order_refl) + +lemma strong_del_point_index_alt: + assumes "ps \ (del_point p)" + shows "(str_del_point_blocks p) index ps = + \ index ps - {# bl \# \ . p \ bl#} index ps" + using str_del_point_blocks_alt points_index_def + by (metis filter_diff_mset multiset_filter_mono multiset_filter_subset size_Diff_submset) + +lemma strong_del_point_incidence_wf: "incidence_system (del_point p) (str_del_point_blocks p)" + using wellformed str_del_point_blocks_def del_point_def by (unfold_locales) auto + +text \Add block operation\ + +definition add_block :: "'a set \ 'a set multiset" where +"add_block b \ \ + {#b#}" + +lemma add_block_alt: "add_block b = add_mset b \" + by (simp add: add_block_def) + +lemma add_block_rep_number_in: + assumes "x \ b" + shows "(add_block b) rep x = \ rep x + 1" +proof - + have "(add_block b) = {#b#} + \" by (simp add: add_block_def) + then have split: "(add_block b) rep x = {#b#} rep x + \ rep x" + by (metis point_rep_number_split) + have "{#b#} rep x = 1" using assms by simp + thus ?thesis using split by auto +qed + +lemma add_block_rep_number_not_in: "x \ b \ (add_block b) rep x = \ rep x" + using point_rep_number_split add_block_alt point_rep_singleton_inval + by (metis add.right_neutral union_mset_add_mset_right) + +lemma add_block_index_in: + assumes "ps \ b" + shows "(add_block b) index ps = \ index ps + 1" +proof - + have "(add_block b) = {#b#} + \" by (simp add: add_block_def) + then have split: "(add_block b) index ps = {#b#} index ps + \ index ps" + by (metis point_index_distrib) + have "{#b#} index ps = 1" using assms points_index_singleton by auto + thus ?thesis using split by simp +qed + +lemma add_block_index_not_in: "\ (ps \ b) \ (add_block b) index ps = \ index ps" + using point_index_distrib points_index_singleton_zero + by (metis add.right_neutral add_block_def) + +text \Note the add block incidence system is defined slightly differently then textbook +definitions due to the modification to the point set. This ensures the operation is closed, +where otherwise a condition that $b \subseteq \mathcal{V}$ would be required.\ +lemma add_block_wf: "incidence_system (\ \ b) (add_block b)" + using wellformed add_block_def by (unfold_locales) auto + +lemma add_block_wf_cond: "b \ \ \ incidence_system \ (add_block b)" + using add_block_wf by (metis sup.order_iff) + +text \Delete block removes a block from the block set. The point set is unchanged\ +definition del_block :: "'a set \ 'a set multiset" where +"del_block b \ \ - {#b#}" + +lemma delete_block_subset: "(del_block b) \# \" + by (simp add: del_block_def) + +lemma delete_invalid_block_eq: "b \# \ \ del_block b = \" + by (simp add: del_block_def) + +lemma delete_block_wf: "incidence_system \ (del_block b)" + by (unfold_locales) (simp add: del_block_def in_diffD wellformed) + +text \The strong delete block operation effectively deletes the block, as well as +all points in that block\ +definition str_del_block :: "'a set \ 'a set multiset" where +"str_del_block b \ {# bl - b | bl \# \ . bl \ b #}" + +lemma strong_del_block_alt_def: "str_del_block b = {# bl - b . bl \# removeAll_mset b \ #}" + by (simp add: filter_mset_neq str_del_block_def) + +lemma strong_del_block_wf: "incidence_system (\ - b) (str_del_block b)" + using wf_invalid_point str_del_block_def by (unfold_locales) auto + +lemma str_del_block_del_point: + assumes "{x} \# \" + shows "str_del_block {x} = (del_point_blocks x)" +proof - + have neqx: "\ bl. bl \# \ \ bl \ {x}" using assms by auto + have "str_del_block {x} = {# bl - {x} | bl \# \ . bl \ {x} #}" by (simp add: str_del_block_def) + then have "str_del_block {x} = {# bl - {x} . bl \# \ #}" using assms neqx + by (simp add: filter_mset_cong) + thus ?thesis by (simp add: del_point_blocks_def) +qed + +subsection \Incidence System Interpretations\ +text \It is easy to interpret all operations as incidence systems in there own right. +These can then be used to prove local properties on the new constructions, as well +as reason on interactions between different operation sequences\ + +interpretation add_point_sys: incidence_system "add_point p" "\" + using add_point_wf by simp + +lemma add_point_sys_rep_numbers: "add_point_sys.replication_numbers p = + replication_numbers \ {\ rep p}" + using add_point_sys.replication_numbers_def replication_numbers_def add_point_def by auto + +interpretation del_point_sys: incidence_system "del_point p" "del_point_blocks p" + using delete_point_wf by auto + +interpretation add_block_sys: incidence_system "\ \ bl" "add_block bl" + using add_block_wf by simp + +interpretation del_block_sys: incidence_system "\" "del_block bl" + using delete_block_wf by simp + +lemma add_del_block_inv: + assumes "bl \ \" + shows "add_block_sys.del_block bl bl = \" + using add_block_sys.del_block_def add_block_def by simp + +lemma del_add_block_inv: "bl \# \ \ del_block_sys.add_block bl bl = \" + using del_block_sys.add_block_def del_block_def wellformed by fastforce + +lemma del_invalid_add_block_eq: "bl \# \ \ del_block_sys.add_block bl bl = add_block bl" + using del_block_sys.add_block_def by (simp add: delete_invalid_block_eq) + +lemma add_delete_point_inv: + assumes "p \ \" + shows "add_point_sys.del_point p p = \" +proof - + have "(add_point_sys.del_point p p) = (insert p \) - {p}" + using add_point_sys.del_point_def del_block_sys.add_point_def by auto + thus ?thesis + by (simp add: assms) +qed +end + +subsection \Operation Closure for Designs\ + +context finite_incidence_system +begin + +lemma add_point_finite: "finite_incidence_system (add_point p) \" + using add_point_wf finite_sets add_point_def + by (unfold_locales) (simp_all add: incidence_system_def) + +lemma add_point_to_blocks_finite: "finite_incidence_system (add_point p) (add_point_to_blocks p bs)" + using add_point_blocks_wf add_point_finite finite_incidence_system.finite_sets + incidence_system.finite_sysI by blast + +lemma delete_point_finite: + "finite_incidence_system (del_point p) (del_point_blocks p)" + using finite_sets delete_point_wf + by (unfold_locales) (simp_all add: incidence_system_def del_point_def) + +lemma del_point_order: + assumes "p \ \" + shows "card (del_point p) = \ - 1" +proof - + have vg0: "card \ > 0" using assms finite_sets card_gt_0_iff by auto + then have "card (del_point p) = card \ - 1" using assms del_point_def + by (metis card_Diff_singleton finite_sets) + thus ?thesis + using vg0 by linarith +qed + +lemma strong_del_point_finite:"finite_incidence_system (del_point p) (str_del_point_blocks p)" + using strong_del_point_incidence_wf del_point_def + by (intro_locales) (simp_all add: finite_incidence_system_axioms_def finite_sets) + +lemma add_block_fin: "finite b \ finite_incidence_system (\ \ b) (add_block b)" + using wf_invalid_point finite_sets add_block_def by (unfold_locales) auto + +lemma add_block_fin_cond: "b \ \ \ finite_incidence_system \ (add_block b)" + using add_block_wf_cond finite_incidence_system_axioms.intro finite_sets + by (intro_locales) (simp_all) + +lemma delete_block_fin_incidence_sys: "finite_incidence_system \ (del_block b)" + using delete_block_wf finite_sets by (unfold_locales) (simp_all add: incidence_system_def) + +lemma strong_del_block_fin: "finite_incidence_system (\ - b) (str_del_block b)" + using strong_del_block_wf finite_sets finite_incidence_system_axioms_def by (intro_locales) auto + +end + +context design +begin +lemma add_point_design: "design (add_point p) \" + using add_point_wf finite_sets blocks_nempty add_point_def + by (unfold_locales) (auto simp add: incidence_system_def) + +lemma delete_point_design: + assumes "(\ bl . bl \# \ \ p \ bl \ card bl \ 2)" + shows "design (del_point p) (del_point_blocks p)" +proof (cases "p \ \") + case True + interpret fis: finite_incidence_system "(del_point p)" "(del_point_blocks p)" + using delete_point_finite by simp + show ?thesis + proof (unfold_locales) + show "\bl. bl \# (del_point_blocks p) \ bl \ {}" using assms del_point_def + proof - + fix bl + assume "bl \#(del_point_blocks p)" + then obtain bl' where block: "bl' \# \" and rem: "bl = bl' - {p}" + by (auto simp add: del_point_blocks_def) + then have eq: "p \ bl' \ bl \ {}" using block blocks_nempty by (simp add: rem) + have "p \ bl' \ card bl \ 1" using rem finite_blocks block assms block by fastforce + then show "bl \ {}" using eq assms by fastforce + qed + qed +next + case False + then show ?thesis using del_invalid_point del_invalid_point_blocks + by (simp add: wf_design) +qed + +lemma strong_del_point_design: "design (del_point p) (str_del_point_blocks p)" +proof - + interpret fin: finite_incidence_system "(del_point p)" "(str_del_point_blocks p)" + using strong_del_point_finite by simp + show ?thesis using wf_design wf_design_iff del_point_def str_del_point_blocks_def + by (unfold_locales) (auto) +qed + +lemma add_block_design: + assumes "finite bl" + assumes "bl \ {}" + shows "design (\ \ bl) (add_block bl)" +proof - + interpret fin: finite_incidence_system "(\ \ bl)" "(add_block bl)" + using add_block_fin assms by simp + show ?thesis using blocks_nempty assms add_block_def by (unfold_locales) auto +qed + +lemma add_block_design_cond: + assumes "bl \ \" and "bl \ {}" + shows "design \ (add_block bl)" +proof - + interpret fin: finite_incidence_system "\" "(add_block bl)" + using add_block_fin_cond assms by simp + show ?thesis using blocks_nempty assms add_block_def by (unfold_locales) auto +qed + +lemma delete_block_design: "design \ (del_block bl)" +proof - + interpret fin: finite_incidence_system \ "(del_block bl)" + using delete_block_fin_incidence_sys by simp + have "\ b . b \# (del_block bl) \ b \ {}" + using blocks_nempty delete_block_subset by blast + then show ?thesis by (unfold_locales) (simp_all) +qed + +lemma strong_del_block_des: + assumes "\ bl . bl \# \ \ \ (bl \ b)" + shows "design (\ - b) (str_del_block b)" +proof - + interpret fin: finite_incidence_system "\ - b" "(str_del_block b)" + using strong_del_block_fin by simp + show ?thesis using assms str_del_block_def by (unfold_locales) auto +qed + +end + +context proper_design +begin +lemma delete_point_proper: + assumes "\bl. bl \# \ \ p \ bl \ 2 \ card bl" + shows "proper_design (del_point p) (del_point_blocks p)" +proof - + interpret des: design "del_point p" "del_point_blocks p" + using delete_point_design assms by blast + show ?thesis using design_blocks_nempty del_point_def del_point_blocks_def + by (unfold_locales) simp +qed + +lemma strong_delete_point_proper: + assumes "\bl. bl \# \ \ p \ bl \ 2 \ card bl" + assumes "\ rep p < \" + shows "proper_design (del_point p) (str_del_point_blocks p)" +proof - + interpret des: design "del_point p" "str_del_point_blocks p" + using strong_del_point_design assms by blast + show ?thesis using assms design_blocks_nempty point_rep_num_inv_non_empty + str_del_point_blocks_def del_point_def by (unfold_locales) simp +qed + +end + +subsection \Combining Set Systems\ +text \Similar to multiple, another way to construct a new set system is to combine two existing ones. +We introduce a new locale enabling us to reason on two different incidence systems\ +locale two_set_systems = sys1: incidence_system \ \ + sys2: incidence_system \' \' + for \ :: "('a set)" and \ and \' :: "('a set)" and \' +begin + +abbreviation "combine_points \ \ \ \'" + +notation combine_points ("\\<^sup>+") + +abbreviation "combine_blocks \ \ + \'" + +notation combine_blocks ("\\<^sup>+") + +sublocale combine_sys: incidence_system "\\<^sup>+" "\\<^sup>+" + using sys1.wellformed sys2.wellformed by (unfold_locales) auto + +lemma combine_points_index: "\\<^sup>+ index ps = \ index ps + \' index ps" + by (simp add: point_index_distrib) + +lemma combine_rep_number: "\\<^sup>+ rep x = \ rep x + \' rep x" + by (simp add: point_replication_number_def) + +lemma combine_multiple1: "\ = \' \ \ = \' \ \\<^sup>+ = sys1.multiple_blocks 2" + by auto + +lemma combine_multiple2: "\ = \' \ \ = \' \ \\<^sup>+ = sys2.multiple_blocks 2" + by auto + +lemma combine_multiplicity: "combine_sys.multiplicity b = sys1.multiplicity b + sys2.multiplicity b" + by simp + +lemma combine_block_sizes: "combine_sys.sys_block_sizes = + sys1.sys_block_sizes \ sys2.sys_block_sizes" + using sys1.sys_block_sizes_def sys2.sys_block_sizes_def combine_sys.sys_block_sizes_def by (auto) + +end + +locale two_fin_set_systems = two_set_systems \ \ \' \' + sys1: finite_incidence_system \ \ + + sys2: finite_incidence_system \' \' for \ \ \' \' +begin + + +sublocale combine_fin_sys: finite_incidence_system "\\<^sup>+" "\\<^sup>+" + using sys1.finite_sets sys2.finite_sets by (unfold_locales) (simp) + +lemma combine_order: "card (\\<^sup>+) \ card \" + by (meson Un_upper1 card_mono combine_fin_sys.finite_sets) + +lemma combine_order_2: "card (\\<^sup>+) \ card \'" + by (meson Un_upper2 card_mono combine_fin_sys.finite_sets) + +end + +locale two_designs = two_fin_set_systems \ \ \' \' + des1: design \ \ + + des2: design \' \' for \ \ \' \' +begin + +sublocale combine_des: design "\\<^sup>+" "\\<^sup>+" + apply (unfold_locales) + using des1.blocks_nempty_alt des2.blocks_nempty_alt by fastforce + +end + +locale two_designs_proper = two_designs + + assumes blocks_nempty: "\ \ {#} \ \' \ {#}" +begin + +lemma des1_is_proper: "\ \ {#} \ proper_design \ \" + by (unfold_locales) (simp) + +lemma des2_is_proper: "\' \ {#} \ proper_design \' \'" + by (unfold_locales) (simp) + +lemma min_one_proper_design: "proper_design \ \ \ proper_design \' \'" + using blocks_nempty des1_is_proper des2_is_proper by (unfold_locales, blast) + +sublocale combine_proper_des: proper_design "\\<^sup>+" "\\<^sup>+" + apply (unfold_locales) + by (metis blocks_nempty of_nat_0_eq_iff size_eq_0_iff_empty subset_mset.zero_eq_add_iff_both_eq_0) +end + +end \ No newline at end of file diff --git a/thys/Design_Theory/Design_Theory_Root.thy b/thys/Design_Theory/Design_Theory_Root.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Design_Theory_Root.thy @@ -0,0 +1,21 @@ +(* Title: Design_Theory_Root.thy + Author: Chelsea Edmonds +*) + +theory Design_Theory_Root +imports + Multisets_Extras + + Design_Basics + Design_Operations + Block_Designs + BIBD + + Resolvable_Designs + Group_Divisible_Designs + Designs_And_Graphs + Design_Isomorphisms + Sub_Designs +begin + +end \ No newline at end of file diff --git a/thys/Design_Theory/Designs_And_Graphs.thy b/thys/Design_Theory/Designs_And_Graphs.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Designs_And_Graphs.thy @@ -0,0 +1,336 @@ +(* Title: Designs_And_Graphs.thy + Author: Chelsea Edmonds +*) + +section \Graphs and Designs\ +text \There are many links between graphs and design - most fundamentally that graphs are designs\ + +theory Designs_And_Graphs imports Block_Designs Graph_Theory.Digraph Graph_Theory.Digraph_Component +begin + +subsection \Non-empty digraphs\ +text \First, we define the concept of a non-empty digraph. This mirrors the idea of a "proper design" +in the design theory library\ +locale non_empty_digraph = wf_digraph + + assumes arcs_not_empty: "arcs G \ {}" + +begin + +lemma verts_not_empty: "verts G \ {}" + using wf arcs_not_empty head_in_verts by fastforce + +end + +subsection \Arcs to Blocks\ +text \A digraph uses a pair of points to define an ordered edge. In the case of simple graphs, +both possible orderings will be in the arcs set. Blocks are inherently unordered, and as such +a method is required to convert between the two representations\ +context graph +begin + +definition arc_to_block :: "'b \ 'a set" where + "arc_to_block e \ {tail G e, head G e}" + +lemma arc_to_block_to_ends: "{fst (arc_to_ends G e), snd (arc_to_ends G e)} = arc_to_block e" + by (simp add: arc_to_ends_def arc_to_block_def) + +lemma arc_to_block_to_ends_swap: "{snd (arc_to_ends G e), fst (arc_to_ends G e)} = arc_to_block e" + using arc_to_block_to_ends + by (simp add: arc_to_block_to_ends insert_commute) + +lemma arc_to_ends_to_block: "arc_to_block e = {x, y} \ + arc_to_ends G e = (x, y) \ arc_to_ends G e = (y, x)" + by (metis arc_to_block_def arc_to_ends_def doubleton_eq_iff) + +lemma arc_to_block_sym: "arc_to_ends G e1 = (u, v) \ arc_to_ends G e2 = (v, u) \ + arc_to_block e1 = arc_to_block e2" + by (simp add: arc_to_block_def arc_to_ends_def insert_commute) + +definition arcs_blocks :: "'a set multiset" where +"arcs_blocks \ mset_set (arc_to_block ` (arcs G))" + +lemma arcs_blocks_ends: "(x, y) \ arcs_ends G \ {x, y} \# arcs_blocks" +proof (auto simp add: arcs_ends_def arcs_blocks_def ) + fix xa + assume assm1: "(x, y) = arc_to_ends G xa" and assm2: "xa \ arcs G" + obtain z where zin: "z \ (arc_to_block ` (arcs G))" and "z = arc_to_block xa" + using assm2 by blast + thus "{x, y} \ arc_to_block ` (arcs G)" using assm1 arc_to_block_to_ends + by (metis fst_conv snd_conv) +qed + +lemma arc_ends_blocks_subset: "E \ arcs G \ (x, y) \ ((arc_to_ends G) ` E) \ + {x, y} \ (arc_to_block ` E)" + by (auto simp add: arc_to_ends_def arc_to_block_def ) + +lemma arc_blocks_end_subset: assumes "E \ arcs G" and "{x, y} \ (arc_to_block ` E)" + shows "(x, y) \ ((arc_to_ends G) ` E) \ (y, x) \ ((arc_to_ends G) ` E)" +proof - + obtain e where "e \ E" and "arc_to_block e = {x,y}" using assms + by fastforce + then have "arc_to_ends G e = (x, y) \ arc_to_ends G e = (y, x)" + using arc_to_ends_to_block by simp + thus ?thesis + by (metis \e \ E\ image_iff) +qed + +lemma arcs_ends_blocks: "{x, y} \# arcs_blocks \ (x, y) \ arcs_ends G \ (y, x) \ arcs_ends G" +proof (auto simp add: arcs_ends_def arcs_blocks_def ) + fix xa + assume assm1: "{x, y} = arc_to_block xa" and assm2: "xa \ (arcs G)" + obtain z where zin: "z \ (arc_to_ends G ` (arcs G))" and "z = arc_to_ends G xa" + using assm2 by blast + then have "z = (x, y) \ z = (y, x)" using arc_to_block_to_ends assm1 + by (metis arc_to_ends_def doubleton_eq_iff fst_conv snd_conv) (* Slow *) + thus "(x, y) \ arc_to_ends G ` (arcs G)" using assm2 + by (metis arcs_ends_def arcs_ends_symmetric sym_arcs zin) +next + fix xa + assume assm1: "{x, y} = arc_to_block xa" and assm2: "xa \ (arcs G)" + thus "(y, x) \ arc_to_ends G ` arcs G" using arcs_ends_def + by (metis (mono_tags, hide_lams) arc_blocks_end_subset graph_symmetric image_iff subset_refl) +qed + +lemma arcs_blocks_iff: "{x, y} \# arcs_blocks \ (x, y) \ arcs_ends G \ (y, x) \ arcs_ends G" + using arcs_ends_blocks arcs_blocks_ends by blast + +lemma arcs_ends_wf: "(x, y) \ arcs_ends G \ x \ verts G \ y \ verts G" + by auto + +lemma arcs_blocks_elem: "bl \# arcs_blocks \ \ x y . bl = {x, y}" + apply (auto simp add: arcs_blocks_def) + by (meson arc_to_block_def) + +lemma arcs_ends_blocks_wf: + assumes "bl \# arcs_blocks" + shows "bl \ verts G" +proof - + obtain x y where blpair: "bl = {x, y}" using arcs_blocks_elem assms + by fastforce + then have "(x, y) \ arcs_ends G" using arcs_ends_blocks assms by simp + thus ?thesis using arcs_ends_wf blpair by auto +qed + +lemma arcs_blocks_simple: "bl \# arcs_blocks \ count (arcs_blocks) bl = 1" + by (simp add: arcs_blocks_def) + +lemma arcs_blocks_ne: "arcs G \ {} \ arcs_blocks \ {#}" + by (simp add: arcs_blocks_iff arcs_blocks_def mset_set_empty_iff) + +end + +subsection \Graphs are designs\ + +text \Prove that a graph is a number of different types of designs\ +sublocale graph \ design "verts G" "arcs_blocks" + using arcs_ends_blocks_wf arcs_blocks_elem by (unfold_locales) (auto) + +sublocale graph \ simple_design "verts G" "arcs_blocks" + using arcs_ends_blocks_wf arcs_blocks_elem arcs_blocks_simple by (unfold_locales) (auto) + +locale non_empty_graph = graph + non_empty_digraph + +sublocale non_empty_graph \ proper_design "verts G" "arcs_blocks" + using arcs_blocks_ne arcs_not_empty by (unfold_locales) simp + +lemma (in graph) graph_block_size: assumes "bl \# arcs_blocks" shows "card bl = 2" +proof - + obtain x y where blrep: "bl = {x, y}" using assms arcs_blocks_elem + by fastforce + then have "(x, y) \ arcs_ends G" using arcs_ends_blocks assms by simp + then have "x \ y" using no_loops using adj_not_same by blast + thus ?thesis using blrep by simp +qed + +sublocale non_empty_graph \ block_design "verts G" "arcs_blocks" 2 + using arcs_not_empty graph_block_size arcs_blocks_ne by (unfold_locales) simp_all + +subsection \R-regular graphs\ +text \To reason on r-regular graphs and their link to designs, we require a number of extensions to +lemmas reasoning around the degrees of vertices\ +context sym_digraph +begin + +lemma in_out_arcs_reflexive: "v \ verts G \ (e \ (in_arcs G v) \ + \ e' . (e' \ (out_arcs G v) \ head G e' = tail G e))" + using symmetric_conv sym_arcs by fastforce + +lemma out_in_arcs_reflexive: "v \ verts G \ (e \ (out_arcs G v) \ + \ e' . (e' \ (in_arcs G v) \ tail G e' = head G e))" + using symmetric_conv sym_arcs by fastforce + +end + +context nomulti_digraph +begin + +lemma in_arcs_single_per_vert: + assumes "v \ verts G" and "u \ verts G" + assumes "e1 \ in_arcs G v" and " e2 \ in_arcs G v" + assumes "tail G e1 = u" and "tail G e2 = u" + shows "e1 = e2" +proof - + have in_arcs1: "e1 \ arcs G" and in_arcs2: "e2 \ arcs G" using assms by auto + have "arc_to_ends G e1 = arc_to_ends G e2" using assms arc_to_ends_def + by (metis in_in_arcs_conv) + thus ?thesis using in_arcs1 in_arcs2 no_multi_arcs by simp +qed + +lemma out_arcs_single_per_vert: + assumes "v \ verts G" and "u \ verts G" + assumes "e1 \ out_arcs G v" and " e2 \ out_arcs G v" + assumes "head G e1 = u" and "head G e2 = u" + shows "e1 = e2" +proof - + have in_arcs1: "e1 \ arcs G" and in_arcs2: "e2 \ arcs G" using assms by auto + have "arc_to_ends G e1 = arc_to_ends G e2" using assms arc_to_ends_def + by (metis in_out_arcs_conv) + thus ?thesis using in_arcs1 in_arcs2 no_multi_arcs by simp +qed + +end + +text \Some helpers on the transformation arc definition\ +context graph +begin + +lemma arc_to_block_is_inj_in_arcs: "inj_on arc_to_block (in_arcs G v)" + apply (auto simp add: arc_to_block_def inj_on_def) + by (metis arc_to_ends_def doubleton_eq_iff no_multi_arcs) + +lemma arc_to_block_is_inj_out_arcs: "inj_on arc_to_block (out_arcs G v)" + apply (auto simp add: arc_to_block_def inj_on_def) + by (metis arc_to_ends_def doubleton_eq_iff no_multi_arcs) + +lemma in_out_arcs_reflexive_uniq: "v \ verts G \ (e \ (in_arcs G v) \ + \! e' . (e' \ (out_arcs G v) \ head G e' = tail G e))" + apply auto + using symmetric_conv apply fastforce + using out_arcs_single_per_vert by (metis head_in_verts in_out_arcs_conv) + +lemma out_in_arcs_reflexive_uniq: "v \ verts G \ e \ (out_arcs G v) \ + \! e' . (e' \ (in_arcs G v) \ tail G e' = head G e)" + apply auto + using symmetric_conv apply fastforce + using in_arcs_single_per_vert by (metis tail_in_verts in_in_arcs_conv) + +lemma in_eq_out_arc_ends: "(u, v) \ ((arc_to_ends G) ` (in_arcs G v)) \ + (v, u) \ ((arc_to_ends G) ` (out_arcs G v))" + using arc_to_ends_def in_in_arcs_conv in_out_arcs_conv + by (smt (z3) Pair_inject adj_in_verts(1) dominatesI image_iff out_in_arcs_reflexive_uniq) + +lemma in_degree_eq_card_arc_ends: "in_degree G v = card ((arc_to_ends G) ` (in_arcs G v))" + apply (simp add: in_degree_def) + using no_multi_arcs by (metis card_image in_arcs_in_arcs inj_onI) + +lemma in_degree_eq_card_arc_blocks: "in_degree G v = card (arc_to_block ` (in_arcs G v))" + apply (simp add: in_degree_def) + using no_multi_arcs arc_to_block_is_inj_in_arcs by (simp add: card_image) + +lemma out_degree_eq_card_arc_blocks: "out_degree G v = card (arc_to_block ` (out_arcs G v))" + apply (simp add: out_degree_def) + using no_multi_arcs arc_to_block_is_inj_out_arcs by (simp add: card_image) + +lemma out_degree_eq_card_arc_ends: "out_degree G v = card ((arc_to_ends G) ` (out_arcs G v))" + apply (simp add: out_degree_def) + using no_multi_arcs by (metis card_image out_arcs_in_arcs inj_onI) + +lemma bij_betw_in_out_arcs: "bij_betw (\ (u, v) . (v, u)) ((arc_to_ends G) ` (in_arcs G v)) + ((arc_to_ends G) ` (out_arcs G v))" + apply (auto simp add: bij_betw_def) + apply (simp add: swap_inj_on) + apply (metis Pair_inject arc_to_ends_def image_eqI in_eq_out_arc_ends in_in_arcs_conv) + by (metis arc_to_ends_def imageI in_eq_out_arc_ends in_out_arcs_conv pair_imageI) + +lemma in_eq_out_degree: "in_degree G v = out_degree G v" + using bij_betw_in_out_arcs bij_betw_same_card in_degree_eq_card_arc_ends + out_degree_eq_card_arc_ends by auto + +lemma in_out_arcs_blocks: "arc_to_block ` (in_arcs G v) = arc_to_block ` (out_arcs G v)" +proof (auto) + fix xa + assume a1: "xa \ arcs G" and a2: "v = head G xa" + then have "xa \ in_arcs G v" by simp + then obtain e where out: "e \ out_arcs G v" and "head G e = tail G xa" + using out_in_arcs_reflexive_uniq by force + then have "arc_to_ends G e = (v, tail G xa)" + by (simp add: arc_to_ends_def) + then have "arc_to_block xa = arc_to_block e" + using arc_to_block_sym by (metis a2 arc_to_ends_def) + then show "arc_to_block xa \ arc_to_block ` out_arcs G (head G xa)" + using out a2 by blast +next + fix xa + assume a1: "xa \ arcs G" and a2: "v = tail G xa" + then have "xa \ out_arcs G v" by simp + then obtain e where ina: "e \ in_arcs G v" and "tail G e = head G xa" + using out_in_arcs_reflexive_uniq by force + then have "arc_to_ends G e = (head G xa, v)" + by (simp add: arc_to_ends_def) + then have "arc_to_block xa = arc_to_block e" + using arc_to_block_sym by (metis a2 arc_to_ends_def) + then show "arc_to_block xa \ arc_to_block ` in_arcs G (tail G xa)" + using ina a2 by blast +qed + +end + +text \A regular digraph is defined as one where the in degree equals the out degree which in turn +equals some fixed integer $\mathrm{r}$\ +locale regular_digraph = wf_digraph + + fixes \ :: int + assumes in_deg_r: "v \ verts G \ in_degree G v = \" + assumes out_deg_r: "v \ verts G \ out_degree G v = \" + +locale regular_graph = graph + regular_digraph +begin + +lemma rep_vertices_in_blocks [simp]: + assumes "x \ verts G" + shows "size {# e \# arcs_blocks . x \ e #} = \" +proof - + have "\ e . e \ (arc_to_block ` (arcs G)) \ x \ e \ e \ (arc_to_block ` in_arcs G x)" + using arc_to_block_def in_in_arcs_conv insert_commute insert_iff singleton_iff sym_arcs + symmetric_conv by fastforce + then have "{ e \ (arc_to_block ` (arcs G)) . x \ e} = (arc_to_block ` (in_arcs G x))" + using arc_to_block_def by auto + then have "card { e \ (arc_to_block ` (arcs G)) . x \ e} = \" + using in_deg_r in_degree_eq_card_arc_blocks assms by auto + thus ?thesis + using arcs_blocks_def finite_arcs by force +qed + +end + +text \Intro rules for regular graphs\ +lemma graph_in_degree_r_imp_reg[intro]: assumes "graph G" + assumes "(\ v . v \ (verts G) \ in_degree G v = \)" + shows "regular_graph G \" +proof - + interpret g: graph G using assms by simp + interpret wf: wf_digraph G by (simp add: g.wf_digraph_axioms) + show ?thesis + using assms(2) g.in_eq_out_degree by (unfold_locales) simp_all +qed + +lemma graph_out_degree_r_imp_reg[intro]: assumes "graph G" + assumes "(\ v . v \ (verts G) \ out_degree G v = \)" + shows "regular_graph G \" +proof - + interpret g: graph G using assms by simp + interpret wf: wf_digraph G by (simp add: g.wf_digraph_axioms) + show ?thesis + using assms(2) g.in_eq_out_degree by (unfold_locales) simp_all +qed + +text \Regular graphs (non-empty) can be shown to be a constant rep design\ +locale non_empty_regular_graph = regular_graph + non_empty_digraph + +sublocale non_empty_regular_graph \ non_empty_graph + by unfold_locales + +sublocale non_empty_regular_graph \ constant_rep_design "verts G" "arcs_blocks" \ + using arcs_blocks_ne arcs_not_empty + by (unfold_locales)(simp_all add: point_replication_number_def) + +end \ No newline at end of file diff --git a/thys/Design_Theory/Group_Divisible_Designs.thy b/thys/Design_Theory/Group_Divisible_Designs.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Group_Divisible_Designs.thy @@ -0,0 +1,1091 @@ +(* Title: Group_Divisible_Designs.thy + Author: Chelsea Edmonds +*) + +section \Group Divisible Designs\ +text \Definitions in this section taken from the handbook \cite{colbournHandbookCombinatorialDesigns2007} +and Stinson \cite{stinsonCombinatorialDesignsConstructions2004}\ +theory Group_Divisible_Designs imports Resolvable_Designs +begin + +subsection \Group design\ +text \We define a group design to have an additional paramater $G$ which is a partition on the point +set $V$. This is not defined in the handbook, but is a precursor to GDD's without index constraints\ + +locale group_design = proper_design + + fixes groups :: "'a set set" ("\") + assumes group_partitions: "partition_on \ \" + assumes groups_size: "card \ > 1" +begin + +lemma groups_not_empty: "\ \ {}" + using groups_size by auto + +lemma num_groups_lt_points: "card \ \ \" + by (simp add: partition_on_le_set_elements finite_sets group_partitions) + +lemma groups_disjoint: "disjoint \" + using group_partitions partition_onD2 by auto + +lemma groups_disjoint_pairwise: "G1 \ \ \ G2 \ \ \ G1 \ G2 \ disjnt G1 G2" + using group_partitions partition_onD2 pairwiseD by fastforce + +lemma point_in_one_group: "x \ G1 \ G1 \ \ \ G2 \ \ \ G1 \ G2 \ x \ G2" + using groups_disjoint_pairwise by (simp add: disjnt_iff) + +lemma point_has_unique_group: "x \ \ \ \!G. x \ G \ G \ \" + using partition_on_partition_on_unique group_partitions + by fastforce + +lemma rep_number_point_group_one: + assumes "x \ \" + shows "card {g \ \ . x \ g} = 1" +proof - + obtain g' where "g' \ \" and "x \ g'" + using assms point_has_unique_group by blast + then have "{g \ \ . x \ g} = {g'}" + using group_partitions partition_onD4 by force + thus ?thesis + by simp +qed + +lemma point_in_group: "G \ \ \ x \ G \ x \ \" + using group_partitions partition_onD1 by auto + +lemma point_subset_in_group: "G \ \ \ ps \ G \ ps \ \" + using point_in_group by auto + +lemma group_subset_point_subset: "G \ \ \ G' \ G \ ps \ G' \ ps \ \" + using point_subset_in_group by auto + +lemma groups_finite: "finite \" + using finite_elements finite_sets group_partitions by auto + +lemma group_elements_finite: "G \ \ \ finite G" + using groups_finite finite_sets group_partitions + by (meson finite_subset point_in_group subset_iff) + +lemma v_equals_sum_group_sizes: "\ = (\G \ \. card G)" + using group_partitions groups_disjoint partition_onD1 card_Union_disjoint group_elements_finite + by fastforce + +lemma gdd_min_v: "\ \ 2" +proof - + have assm: "card \ \ 2" using groups_size by simp + then have "\ G . G \ \ \ G \ {}" using partition_onD3 group_partitions by auto + then have "\ G . G \ \ \ card G \ 1" + using group_elements_finite card_0_eq by fastforce + then have " (\G \ \. card G) \ 2" using assm + using sum_mono by force + thus ?thesis using v_equals_sum_group_sizes + by linarith +qed + +lemma min_group_size: "G \ \ \ card G \ 1" + using partition_onD3 group_partitions + using group_elements_finite not_le_imp_less by fastforce + +lemma group_size_lt_v: + assumes "G \ \" + shows "card G < \" +proof - + have "(\G' \ \. card G') = \" using gdd_min_v v_equals_sum_group_sizes + by linarith + then have split_sum: "card G + (\G' \ (\ - {G}). card G') = \" using assms sum.remove + by (metis groups_finite v_equals_sum_group_sizes) + have "card (\ - {G}) \ 1" using groups_size + by (simp add: assms groups_finite) + then obtain G' where gin: "G' \ (\ - {G})" + by (meson elem_exists_non_empty_set less_le_trans less_numeral_extra(1)) + then have "card G' \ 1" using min_group_size by auto + then have "(\G' \ (\ - {G}). card G') \ 1" + by (metis gin finite_Diff groups_finite leI less_one sum_eq_0_iff) + thus ?thesis using split_sum + by linarith +qed + +subsubsection \Group Type\ + +text \GDD's have a "type", which is defined by a sequence of group sizes $g_i$, and the number +of groups of that size $a_i$: $g_1^{a_1}g2^{a_2}...g_n^{a_n}$\ +definition group_sizes :: "nat set" where +"group_sizes \ {card G | G . G \ \}" + +definition groups_of_size :: "nat \ nat" where +"groups_of_size g \ card { G \ \ . card G = g }" + +definition group_type :: "(nat \ nat) set" where +"group_type \ {(g, groups_of_size g) | g . g \ group_sizes }" + +lemma group_sizes_min: "x \ group_sizes \ x \ 1 " + unfolding group_sizes_def using min_group_size group_size_lt_v by auto + +lemma group_sizes_max: "x \ group_sizes \ x < \ " + unfolding group_sizes_def using min_group_size group_size_lt_v by auto + +lemma group_size_implies_group_existance: "x \ group_sizes \ \G. G \ \ \ card G = x" + unfolding group_sizes_def by auto + +lemma groups_of_size_zero: "groups_of_size 0 = 0" +proof - + have empty: "{G \ \ . card G = 0} = {}" using min_group_size + by fastforce + thus ?thesis unfolding groups_of_size_def + by (simp add: empty) +qed + +lemma groups_of_size_max: + assumes "g \ \" + shows "groups_of_size g = 0" +proof - + have "{G \ \ . card G = g} = {}" using group_size_lt_v assms by fastforce + thus ?thesis unfolding groups_of_size_def + by (simp add: \{G \ \. card G = g} = {}\) +qed + +lemma group_type_contained_sizes: "(g, a) \ group_type \ g \ group_sizes" + unfolding group_type_def by simp + +lemma group_type_contained_count: "(g, a) \ group_type \ card {G \ \ . card G = g} = a" + unfolding group_type_def groups_of_size_def by simp + +lemma group_card_in_sizes: "g \ \ \ card g \ group_sizes" + unfolding group_sizes_def by auto + +lemma group_card_non_zero_groups_of_size_min: + assumes "g \ \" + assumes "card g = a" + shows "groups_of_size a \ 1" +proof - + have "g \ {G \ \ . card G = a}" using assms by simp + then have "{G \ \ . card G = a} \ {}" by auto + then have "card {G \ \ . card G = a} \ 0" + by (simp add: groups_finite) + thus ?thesis unfolding groups_of_size_def by simp +qed + +lemma elem_in_group_sizes_min_of_size: + assumes "a \ group_sizes" + shows "groups_of_size a \ 1" + using assms group_card_non_zero_groups_of_size_min group_size_implies_group_existance by blast + +lemma group_card_non_zero_groups_of_size_max: + shows "groups_of_size a \ \" +proof - + have "{G \ \ . card G = a} \ \" by simp + then have "card {G \ \ . card G = a} \ card \" + by (simp add: card_mono groups_finite) + thus ?thesis + using groups_of_size_def num_groups_lt_points by auto +qed + +lemma group_card_in_type: "g \ \ \ \ x . (card g, x) \ group_type \ x \ 1" + unfolding group_type_def using group_card_non_zero_groups_of_size_min + by (simp add: group_card_in_sizes) + +lemma partition_groups_on_size: "partition_on \ {{ G \ \ . card G = g } | g . g \ group_sizes}" +proof (intro partition_onI, auto) + fix g + assume a1: "g \ group_sizes" + assume " \x. x \ \ \ card x \ g" + then show False using a1 group_size_implies_group_existance by auto +next + fix x + assume "x \ \" + then show "\xa. (\g. xa = {G \ \. card G = g} \ g \ group_sizes) \ x \ xa" + using group_card_in_sizes by auto +qed + +lemma group_size_partition_covers_points: "\(\{{ G \ \ . card G = g } | g . g \ group_sizes}) = \" + by (metis (no_types, lifting) group_partitions partition_groups_on_size partition_onD1) + +lemma groups_of_size_alt_def_count: "groups_of_size g = count {# card G . G \# mset_set \ #} g" +proof - + have a: "groups_of_size g = card { G \ \ . card G = g }" unfolding groups_of_size_def by simp + then have "groups_of_size g = size {# G \# (mset_set \) . card G = g #}" + using groups_finite by auto + then have size_repr: "groups_of_size g = size {# x \# {# card G . G \# mset_set \ #} . x = g #}" + using groups_finite by (simp add: filter_mset_image_mset) + have "group_sizes = set_mset ({# card G . G \# mset_set \ #})" + using group_sizes_def groups_finite by auto + thus ?thesis using size_repr by (simp add: count_size_set_repr) +qed + +lemma v_sum_type_rep: "\ = (\ g \ group_sizes . g * (groups_of_size g))" +proof - + have gs: "set_mset {# card G . G \# mset_set \ #} = group_sizes" + unfolding group_sizes_def using groups_finite by auto + have "\ = card (\(\{{ G \ \ . card G = g } | g . g \ group_sizes}))" + using group_size_partition_covers_points by simp + have v1: "\ = (\x \# {# card G . G \# mset_set \ #}. x)" + by (simp add: sum_unfold_sum_mset v_equals_sum_group_sizes) + then have "\ = (\x \ set_mset {# card G . G \# mset_set \ #} . x * (count {# card G . G \# mset_set \ #} x))" + using mset_set_size_card_count by (simp add: v1) + thus ?thesis using gs groups_of_size_alt_def_count by auto +qed + +end + +subsubsection \Uniform Group designs\ +text \A group design requiring all groups are the same size\ +locale uniform_group_design = group_design + + fixes u_group_size :: nat ("\") + assumes uniform_groups: "G \ \ \ card G = \" + +begin + +lemma m_positive: "\ \ 1" +proof - + obtain G where "G \ \" using groups_size elem_exists_non_empty_set gr_implies_not_zero by blast + thus ?thesis using uniform_groups min_group_size by fastforce +qed + +lemma uniform_groups_alt: " \ G \ \ . card G = \" + using uniform_groups by blast + +lemma uniform_groups_group_sizes: "group_sizes = {\}" + using design_points_nempty group_card_in_sizes group_size_implies_group_existance + point_has_unique_group uniform_groups_alt by force + +lemma uniform_groups_group_size_singleton: "is_singleton (group_sizes)" + using uniform_groups_group_sizes by auto + +lemma set_filter_eq_P_forall:"\ x \ X . P x \ Set.filter P X = X" + by (simp add: Collect_conj_eq Int_absorb2 Set.filter_def subsetI) + +lemma uniform_groups_groups_of_size_m: "groups_of_size \ = card \" +proof(simp add: groups_of_size_def) + have "{G \ \. card G = \} = \" using uniform_groups_alt set_filter_eq_P_forall by auto + thus "card {G \ \. card G = \} = card \" by simp +qed + +lemma uniform_groups_of_size_not_m: "x \ \ \ groups_of_size x = 0" + by (simp add: groups_of_size_def card_eq_0_iff uniform_groups) + +end + +subsection \GDD\ +text \A GDD extends a group design with an additional index parameter. +Each pair of elements must occur either \Lambda times if in diff groups, or 0 times if in the same +group\ + +locale GDD = group_design + + fixes index :: int ("\") + assumes index_ge_1: "\ \ 1" + assumes index_together: "G \ \ \ x \ G \ y \ G \ x \ y \ \ index {x, y} = 0" + assumes index_distinct: "G1 \ \ \ G2 \ \ \ G1 \ G2 \ x \ G1 \ y \ G2 \ + \ index {x, y} = \" +begin + +lemma points_sep_groups_ne: "G1 \ \ \ G2 \ \ \ G1 \ G2 \ x \ G1 \ y \ G2 \ x \ y" + by (meson point_in_one_group) + +lemma index_together_alt_ss: "ps \ G \ G \ \ \ card ps = 2 \ \ index ps = 0" + using index_together by (metis card_2_iff insert_subset) + +lemma index_distinct_alt_ss: "ps \ \ \ card ps = 2 \ (\ G . G \ \ \ \ ps \ G) \ + \ index ps = \" + using index_distinct by (metis card_2_iff empty_subsetI insert_subset point_has_unique_group) + +lemma gdd_index_options: "ps \ \ \ card ps = 2 \ \ index ps = 0 \ \ index ps = \" + using index_distinct_alt_ss index_together_alt_ss by blast + +lemma index_zero_implies_same_group: "ps \ \ \ card ps = 2 \ \ index ps = 0 \ + \ G \ \ . ps \ G" using index_distinct_alt_ss gr_implies_not_zero + by (metis index_ge_1 less_one of_nat_0 of_nat_1 of_nat_le_0_iff) + +lemma index_zero_implies_same_group_unique: "ps \ \ \ card ps = 2 \ \ index ps = 0 \ + \! G \ \ . ps \ G" + by (meson GDD.index_zero_implies_same_group GDD_axioms card_2_iff' group_design.point_in_one_group + group_design_axioms in_mono) + +lemma index_not_zero_impl_diff_group: "ps \ \ \ card ps = 2 \ \ index ps = \ \ + (\ G . G \ \ \ \ ps \ G)" + using index_ge_1 index_together_alt_ss by auto + +lemma index_zero_implies_one_group: + assumes "ps \ \" + and "card ps = 2" + and "\ index ps = 0" + shows "size {#b \# mset_set \ . ps \ b#} = 1" +proof - + obtain G where ging: "G \ \" and psin: "ps \ G" + using index_zero_implies_same_group groups_size assms by blast + then have unique: "\ G2 . G2 \ \ \ G \ G2 \ \ ps \ G2" + using index_zero_implies_same_group_unique by (metis assms) + have "\ G'. G' \ \ \ G' \# mset_set \" + by (simp add: groups_finite) + then have eq_mset: "{#b \# mset_set \ . ps \ b#} = mset_set {b \ \ . ps \ b}" + using filter_mset_mset_set groups_finite by blast + then have "{b \ \ . ps \ b} = {G}" using unique psin + by (smt Collect_cong ging singleton_conv) + thus ?thesis by (simp add: eq_mset) +qed + +lemma index_distinct_group_num_alt_def: "ps \ \ \ card ps = 2 \ + size {#b \# mset_set \ . ps \ b#} = 0 \ \ index ps = \" + by (metis gdd_index_options index_zero_implies_one_group numeral_One zero_neq_numeral) + +lemma index_non_zero_implies_no_group: + assumes "ps \ \" + and "card ps = 2" + and "\ index ps = \" + shows "size {#b \# mset_set \ . ps \ b#} = 0" +proof - + have "\ G . G \ \ \ \ ps \ G" using index_not_zero_impl_diff_group assms by simp + then have "{#b \# mset_set \ . ps \ b#} = {#}" + using filter_mset_empty_if_finite_and_filter_set_empty by force + thus ?thesis by simp +qed + +lemma gdd_index_non_zero_iff: "ps \ \ \ card ps = 2 \ + \ index ps = \ \ size {#b \# mset_set \ . ps \ b#} = 0" + using index_non_zero_implies_no_group index_distinct_group_num_alt_def by auto + +lemma gdd_index_zero_iff: "ps \ \ \ card ps = 2 \ + \ index ps = 0 \ size {#b \# mset_set \ . ps \ b#} = 1" + apply (auto simp add: index_zero_implies_one_group) + by (metis GDD.gdd_index_options GDD_axioms index_non_zero_implies_no_group old.nat.distinct(2)) + +lemma points_index_upper_bound: "ps \ \ \ card ps = 2 \ \ index ps \ \" + using gdd_index_options index_ge_1 + by (metis int_one_le_iff_zero_less le_refl of_nat_0 of_nat_0_le_iff of_nat_le_iff zero_less_imp_eq_int) + +lemma index_1_imp_mult_1: + assumes "\ = 1" + assumes "bl \# \" + assumes "card bl \ 2" + shows "multiplicity bl = 1" +proof (rule ccontr) + assume "\ (multiplicity bl = 1)" + then have "multiplicity bl \ 1" and "multiplicity bl \ 0" using assms by simp_all + then have m: "multiplicity bl \ 2" by linarith + obtain ps where ps: "ps \ bl \ card ps = 2" + using nat_int_comparison(3) obtain_subset_with_card_n by (metis assms(3)) + then have "\ index ps \ 2" + using m points_index_count_min ps by blast + then show False using assms index_distinct ps antisym_conv2 not_numeral_less_zero + numeral_le_one_iff points_index_ps_nin semiring_norm(69) zero_neq_numeral + by (metis gdd_index_options int_int_eq int_ops(2)) +qed + +lemma simple_if_block_size_gt_2: + assumes "\ bl . card bl \ 2" + assumes "\ = 1" + shows "simple_design \ \" + using index_1_imp_mult_1 assms apply (unfold_locales) + by (metis card.empty not_numeral_le_zero) + +end + +subsubsection \Sub types of GDD's\ + +text \In literature, a GDD is usually defined in a number of different ways, +including factors such as block size limitations\ +locale K_\_GDD = K_block_design + GDD + +locale k_\_GDD = block_design + GDD + +sublocale k_\_GDD \ K_\_GDD \ \ "{\}" \ \ + by (unfold_locales) + +locale K_GDD = K_\_GDD \ \ \ \ 1 + for point_set ("\") and block_collection ("\") and sizes ("\") and groups ("\") + +locale k_GDD = k_\_GDD \ \ \ \ 1 + for point_set ("\") and block_collection ("\") and u_block_size ("\") and groups ("\") + +sublocale k_GDD \ K_GDD \ \ "{\}" \ + by (unfold_locales) + +lemma (in K_GDD) multiplicity_1: "bl \# \ \ card bl \ 2 \ multiplicity bl = 1" + using index_1_imp_mult_1 by simp + +locale RGDD = GDD + resolvable_design + +subsection \GDD and PBD Constructions\ +text \GDD's are commonly studied alongside PBD's (pairwise balanced designs). Many constructions +have been developed for designs to create a GDD from a PBD and vice versa. In particular, +Wilsons Construction is a well known construction, which is formalised in this section. It +should be noted that many of the more basic constructions in this section are often stated without +proof/all the necessary assumptions in textbooks/course notes.\ + +context GDD +begin + +subsubsection \GDD Delete Point construction\ +lemma delete_point_index_zero: + assumes "G \ {g - {x} |g. g \ \ \ g \ {x}}" + and "y \ G" and "z \ G" and "z\ y" +shows "(del_point_blocks x) index {y, z} = 0" +proof - + have "y \ x" using assms(1) assms(2) by blast + have "z \ x" using assms(1) assms(3) by blast + obtain G' where ing: "G' \ \" and ss: "G \ G'" + using assms(1) by auto + have "{y, z} \ G" by (simp add: assms(2) assms(3)) + then have "{y, z} \ \" + by (meson ss ing group_subset_point_subset) + then have "{y, z} \ (del_point x)" + using \y \ x\ \z \ x\ del_point_def by fastforce + thus ?thesis using delete_point_index_eq index_together + by (metis assms(2) assms(3) assms(4) in_mono ing ss) +qed + +lemma delete_point_index: + assumes "G1 \ {g - {x} |g. g \ \ \ g \ {x}}" + assumes "G2 \ {g - {x} |g. g \ \ \ g \ {x}}" + assumes "G1 \ G2" and "y \ G1" and "z \ G2" + shows "del_point_blocks x index {y, z} = \" +proof - + have "y \ x" using assms by blast + have "z \ x" using assms by blast + obtain G1' where ing1: "G1' \ \" and t1: "G1 = G1' - {x}" + using assms(1) by auto + obtain G2' where ing2: "G2' \ \" and t2: "G2 = G2' - {x}" + using assms(2) by auto + then have ss1: "G1 \ G1'" and ss2: "G2 \ G2'" using t1 by auto + then have "{y, z} \ \" using ing1 ing2 ss1 ss2 assms(4) assms(5) + by (metis empty_subsetI insert_absorb insert_subset point_in_group) + then have "{y, z} \ del_point x" + using \y \ x\ \z \ x\ del_point_def by auto + then have indx: "del_point_blocks x index {y, z} = \ index {y, z}" + using delete_point_index_eq by auto + have "G1' \ G2'" using assms t1 t2 by fastforce + thus ?thesis using index_distinct + using indx assms(4) assms(5) ing1 ing2 t1 t2 by auto +qed + +lemma delete_point_group_size: + assumes "{x} \ \ \ card \ > 2" + shows "1 < card {g - {x} |g. g \ \ \ g \ {x}}" +proof (cases "{x} \ \") + case True + then have "\ g . g \ (\ - {{x}}) \ x \ g" + by (meson disjnt_insert1 groups_disjoint pairwise_alt) + then have simpg: "\ g . g \ (\ - {{x}}) \ g - {x} = g" + by simp + have "{g - {x} |g. g \ \ \ g \ {x}} = {g - {x} |g. (g \ \ - {{x}})}" using True + by force + then have "{g - {x} |g. g \ \ \ g \ {x}} = {g |g. (g \ \ - {{x}})}" using simpg + by (smt (verit) Collect_cong) + then have eq: "{g - {x} |g. g \ \ \ g \ {x}} = \ - {{x}}" using set_self_img_compr by blast + have "card (\ - {{x}}) = card \ - 1" using True + by (simp add: groups_finite) + then show ?thesis using True assms eq diff_is_0_eq' by force +next + case False + then have "\g' y. {x} \ \ \ g' \ \ \ y \ \ \ g' - {x} = y - {x} \ g' = y" + by (metis all_not_in_conv insert_Diff_single insert_absorb insert_iff points_sep_groups_ne) + then have inj: "inj_on (\ g . g - {x}) \" by (simp add: inj_onI False) + have "{g - {x} |g. g \ \ \ g \ {x}} = {g - {x} |g. g \ \}" using False by auto + then have "card {g - {x} |g. g \ \ \ g \ {x}} = card \" using inj groups_finite card_image + by (auto simp add: card_image setcompr_eq_image) + then show ?thesis using groups_size by presburger +qed + +lemma GDD_by_deleting_point: + assumes "\bl. bl \# \ \ x \ bl \ 2 \ card bl" + assumes "{x} \ \ \ card \ > 2" + shows "GDD (del_point x) (del_point_blocks x) {g - {x} | g . g \ \ \ g \ {x}} \" +proof - + interpret pd: proper_design "del_point x" "del_point_blocks x" + using delete_point_proper assms by blast + show ?thesis using delete_point_index_zero delete_point_index assms delete_point_group_size + by(unfold_locales) (simp_all add: partition_on_remove_pt group_partitions index_ge_1 del_point_def) +qed + +end + +context K_GDD begin + +subsubsection \PBD construction from GDD\ +text \Two well known PBD constructions involve taking a GDD and either combining the groups and +blocks to form a new block collection, or by adjoining a point\ + +text \First prove that combining the groups and block set results in a constant index\ +lemma kgdd1_points_index_group_block: + assumes "ps \ \" + and "card ps = 2" + shows "(\ + mset_set \) index ps = 1" +proof - + have index1: "(\ G . G \ \ \ \ ps \ G) \ \ index ps = 1" + using index_distinct_alt_ss assms by fastforce + have groups1: "\ index ps = 0 \ size {#b \# mset_set \ . ps \ b#} = 1" + using index_zero_implies_one_group assms by simp + then have "(\ + mset_set \) index ps = size (filter_mset ((\) ps) (\ + mset_set \))" + by (simp add: points_index_def) + thus ?thesis using index1 groups1 gdd_index_non_zero_iff gdd_index_zero_iff assms + gdd_index_options points_index_def filter_union_mset union_commute + by (smt (z3) empty_neutral(1) less_irrefl_nat nonempty_has_size of_nat_1_eq_iff) +qed + +text \Combining blocks and the group set forms a PBD\ +lemma combine_block_groups_pairwise: "pairwise_balance \ (\ + mset_set \) 1" +proof - + let ?B = "\ + mset_set \" + have ss: "\ G. G \ \ \ G \ \" + by (simp add: point_in_group subsetI) + have "\ G. G \ \ \ G \ {}" using group_partitions + using partition_onD3 by auto + then interpret inc: design \ ?B + proof (unfold_locales) + show "\b. (\G. G \ \ \ G \ {}) \ b \# \ + mset_set \ \ b \ \" + by (metis finite_set_mset_mset_set groups_finite ss union_iff wellformed) + show "(\G. G \ \ \ G \ {}) \ finite \" by (simp add: finite_sets) + show "\bl. (\G. G \ \ \ G \ {}) \ bl \# \ + mset_set \ \ bl \ {}" + using blocks_nempty groups_finite by auto + qed + show ?thesis proof (unfold_locales) + show "inc.\ \ 0" using b_positive by auto + show "(1 ::int) \ 2" by simp + show "2 \ inc.\" by (simp add: gdd_min_v) + then show "\ps. ps \ \ \ int (card ps) = 2 \ int ((\ + mset_set \) index ps) = 1" + using kgdd1_points_index_group_block by simp + qed +qed + +lemma combine_block_groups_PBD: + assumes "\ G. G \ \ \ card G \ \" + assumes "\ k . k \ \ \ k \ 2" + shows "PBD \ (\ + mset_set \) \" +proof - + let ?B = "\ + mset_set \" + interpret inc: pairwise_balance \ ?B 1 using combine_block_groups_pairwise by simp + show ?thesis using assms block_sizes groups_finite positive_ints + by (unfold_locales) auto +qed + +text \Prove adjoining a point to each group set results in a constant points index\ +lemma kgdd1_index_adjoin_group_block: + assumes "x \ \" + assumes "ps \ insert x \" + assumes "card ps = 2" + shows "(\ + mset_set {insert x g |g. g \ \}) index ps = 1" +proof - + have "inj_on ((insert) x) \" + by (meson assms(1) inj_onI insert_ident point_in_group) + then have eq: "mset_set {insert x g |g. g \ \} = {# insert x g . g \# mset_set \#}" + by (simp add: image_mset_mset_set setcompr_eq_image) + thus ?thesis + proof (cases "x \ ps") + case True + then obtain y where y_ps: "ps = {x, y}" using assms(3) + by (metis card_2_iff doubleton_eq_iff insertE singletonD) + then have ynex: "y \ x" using assms by fastforce + have yinv: "y \ \" + using assms(2) y_ps ynex by auto + have all_g: "\ g. g \# (mset_set {insert x g |g. g \ \}) \ x \ g" + using eq by force + have iff: "\ g . g \ \ \ y \ (insert x g) \ y \ g" using ynex by simp + have b: "\ index ps = 0" + using True assms(1) points_index_ps_nin by fastforce + then have "(\ + mset_set {insert x g |g. g \ \}) index ps = + (mset_set {insert x g |g. g \ \}) index ps" + using eq by (simp add: point_index_distrib) + also have "... = (mset_set {insert x g |g. g \ \}) rep y" using points_index_pair_rep_num + by (metis (no_types, lifting) all_g y_ps) + also have 0: "... = card {b \ {insert x g |g. g \ \} . y \ b}" + by (simp add: groups_finite rep_number_on_set_def) + also have 1: "... = card {insert x g |g. g \ \ \ y \ insert x g}" + by (smt (verit) Collect_cong mem_Collect_eq) + also have 2: " ... = card {insert x g |g. g \ \ \ y \ g}" + using iff by metis + also have "... = card {g \ \ . y \ g}" using 1 2 0 empty_iff eq groups_finite ynex insert_iff + by (metis points_index_block_image_add_eq points_index_single_rep_num rep_number_on_set_def) + finally have "(\ + mset_set {insert x g |g. g \ \}) index ps = 1" + using rep_number_point_group_one yinv by simp + then show ?thesis + by simp + next + case False + then have v: "ps \ \" using assms(2) by auto + then have "(\ + mset_set {insert x g |g. g \ \}) index ps = (\ + mset_set \) index ps" + using eq by (simp add: points_index_block_image_add_eq False point_index_distrib) + then show ?thesis using v assms kgdd1_points_index_group_block by simp + qed +qed + +lemma pairwise_by_adjoining_point: + assumes "x \ \" + shows "pairwise_balance (add_point x) (\ + mset_set { insert x g | g. g \ \}) 1" +proof - + let ?B = "\ + mset_set { insert x g | g. g \ \}" + let ?V = "add_point x" + have vdef: "?V = \ \ {x}" using add_point_def by simp + show ?thesis unfolding add_point_def using finite_sets b_positive + proof (unfold_locales, simp_all) + have "\ G. G \ \ \ insert x G \ ?V" + by (simp add: point_in_group subsetI vdef) + then have "\ G. G \# (mset_set { insert x g | g. g \ \}) \ G \ ?V" + by (smt (verit, del_insts) elem_mset_set empty_iff infinite_set_mset_mset_set mem_Collect_eq) + then show "\b. b \# \ \ b \# mset_set {insert x g |g. g \ \} \ b \ insert x \" + using wellformed add_point_def by fastforce + next + have "\ G. G \ \ \ insert x G \ {}" using group_partitions + using partition_onD3 by auto + then have gnempty: "\ G. G \# (mset_set { insert x g | g. g \ \}) \ G \ {}" + by (smt (verit, del_insts) elem_mset_set empty_iff infinite_set_mset_mset_set mem_Collect_eq) + then show "\bl. bl \# \ \ bl \# mset_set {insert x g |g. g \ \} \ bl \ {}" + using blocks_nempty by auto + next + have "card \ \ 2" using gdd_min_v by simp + then have "card (insert x \) \ 2" + by (meson card_insert_le dual_order.trans finite_sets) + then show "2 \ int (card (insert x \))" by auto + next + show "\ps. ps \ insert x \ \ + card ps = 2 \ (\ + mset_set {insert x g |g. g \ \}) index ps = Suc 0" + using kgdd1_index_adjoin_group_block by (simp add: assms) + qed +qed + +lemma PBD_by_adjoining_point: + assumes "x \ \" + assumes "\ k . k \ \ \ k \ 2" + shows "PBD (add_point x) (\ + mset_set { insert x g | g. g \ \}) (\ \ {(card g) + 1 | g . g \ \})" +proof - + let ?B = "\ + mset_set { insert x g | g. g \ \}" + let ?V = "(add_point x)" + interpret inc: pairwise_balance ?V ?B 1 using pairwise_by_adjoining_point assms by auto + show ?thesis using block_sizes positive_ints proof (unfold_locales) + have xg: "\ g. g \ \ \ x \ g" + using assms point_in_group by auto + have "\ bl . bl \# \ \ card bl \ \" by (simp add: block_sizes) + have "\ bl . bl \# mset_set {insert x g |g. g \ \} \ bl \ {insert x g | g . g \ \}" + by (simp add: groups_finite) + then have "\ bl . bl \# mset_set {insert x g |g. g \ \} \ + card bl \ {int (card g + 1) |g. g \ \}" + proof - + fix bl + assume "bl \# mset_set {insert x g |g. g \ \}" + then have "bl \ {insert x g | g . g \ \}" by (simp add: groups_finite) + then obtain g where gin: "g \ \" and i: "bl = insert x g" by auto + thus "card bl \ {int (card g + 1) |g. g \ \}" + using gin group_elements_finite i xg by auto + qed + then show "\bl. bl \# \ + mset_set {insert x g |g. g \ \} \ + int (card bl) \ \ \ {int (card g + 1) |g. g \ \}" + using UnI1 UnI2 block_sizes union_iff by (smt (z3) mem_Collect_eq) + show "\x. x \ \ \ {int (card g + 1) |g. g \ \} \ 0 < x" + using min_group_size positive_ints by auto + show "\k. k \ \ \ {int (card g + 1) |g. g \ \} \ 2 \ k" + using min_group_size positive_ints assms by fastforce + qed +qed + +subsubsection \Wilson's Construction\ +text \Wilson's construction involves the combination of multiple k-GDD's. This proof was +based of Stinson \cite{stinsonCombinatorialDesignsConstructions2004}\ + +lemma wilsons_construction_proper: + assumes "card I = w" + assumes "w > 0" + assumes "\ n. n \ \' \ n \ 2" + assumes "\ B . B \# \ \ K_GDD (B \ I) (f B) \' {{x} \ I |x . x \ B }" + shows "proper_design (\ \ I) (\B \# \. (f B))" (is "proper_design ?Y ?B") +proof (unfold_locales, simp_all) + show "\b. \x\#\. b \# f x \ b \ \ \ I" + proof - + fix b + assume "\x\#\. b \# f x" + then obtain B where "B \# \" and "b \# (f B)" by auto + then interpret kgdd: K_GDD "(B \ I)" "(f B)" \' "{{x} \ I |x . x \ B }" using assms by auto + show "b \ \ \ I" using kgdd.wellformed + using \B \# \\ \b \# f B\ wellformed by fastforce + qed + show "finite (\ \ I)" using finite_sets assms bot_nat_0.not_eq_extremum card.infinite by blast + show "\bl. \x\#\. bl \# f x \ bl \ {}" + proof - + fix bl + assume "\x\#\. bl \# f x" + then obtain B where "B \# \" and "bl \# (f B)" by auto + then interpret kgdd: K_GDD "(B \ I)" "(f B)" \' "{{x} \ I |x . x \ B }" using assms by auto + show "bl \ {}" using kgdd.blocks_nempty by (simp add: \bl \# f B\) + qed + show "\i\#\. f i \ {#}" + proof - + obtain B where "B \# \" + using design_blocks_nempty by auto + then interpret kgdd: K_GDD "(B \ I)" "(f B)" \' "{{x} \ I |x . x \ B }" using assms by auto + have "f B \ {#}" using kgdd.design_blocks_nempty by simp + then show "\i\#\. f i \ {#}" using \B \# \\ by auto + qed +qed + +lemma pair_construction_block_sizes: + assumes "K_GDD (B \ I) (f B) \' {{x} \ I |x . x \ B }" + assumes "B \# \" + assumes "b \# (f B)" + shows "card b \ \'" +proof - + interpret bkgdd: K_GDD "(B \ I)" "(f B)" \' "{{x} \ I |x . x \ B }" + using assms by simp + show "card b \ \'" using bkgdd.block_sizes by (simp add:assms) +qed + +lemma wilsons_construction_index_0: + assumes "\ B . B \# \ \ K_GDD (B \ I) (f B) \' {{x} \ I |x . x \ B }" + assumes "G \ {GG \ I |GG. GG \ \}" + assumes "X \ G" + assumes "Y \ G" + assumes "X \ Y" + shows "(\\<^sub># (image_mset f \)) index {X, Y} = 0" +proof - + obtain G' where gi: "G = G' \ I" and ging: "G' \ \" using assms by auto + obtain x y ix iy where xpair: "X = (x, ix)" and ypair: "Y = (y, iy)" using assms by auto + then have ixin: "ix \ I" and xing: "x \ G'" using assms gi by auto + have iyin: "iy \ I" and ying: "y \ G'" using assms ypair gi by auto + have ne_index_0: "x \ y \ \ index {x, y} = 0" + using ying xing index_together ging by simp + have "\ B. B \# \ \ (f B) index {(x, ix), (y, iy)} = 0" + proof - + fix B + assume assm: "B \# \" + then interpret kgdd: K_GDD "(B \ I)" "(f B)" \' "{{x} \ I |x . x \ B }" using assms by simp + have not_ss_0: "\ ({(x, ix), (y, iy)} \ (B \ I)) \ (f B) index {(x, ix), (y, iy)} = 0" + by (metis kgdd.points_index_ps_nin) + have "x \ y \ \ {x, y} \ B" using ne_index_0 assm points_index_0_left_imp by auto + then have "x \ y \ \ ({(x, ix), (y, iy)} \ (B \ I))" using assms + by (meson empty_subsetI insert_subset mem_Sigma_iff) + then have nexy: "x \ y \ (f B) index {(x, ix), (y, iy)} = 0" using not_ss_0 by simp + have "x = y \ ({(x, ix), (y, iy)} \ (B \ I)) \ (f B) index {(x, ix), (y, iy)} = 0" + proof - + assume eq: "x = y" + assume "({(x, ix), (y, iy)} \ (B \ I))" + then obtain g where "g \ {{x} \ I |x . x \ B }" and "(x, ix) \ g" and "(y, ix) \ g" + using eq by auto + then show ?thesis using kgdd.index_together + by (smt (verit, best) SigmaD1 SigmaD2 SigmaI assms(4) assms(5) gi mem_Collect_eq xpair ypair) + qed + then show "(f B) index {(x, ix), (y, iy)} = 0" using not_ss_0 nexy by auto + qed + then have "\ B. B \# (image_mset f \) \ B index {(x, ix), (y, iy)} = 0" by auto + then show "(\\<^sub># (image_mset f \)) index {X, Y} = 0" + by (simp add: points_index_sum xpair ypair) +qed + +lemma wilsons_construction_index_1: + assumes "\ B . B \# \ \ K_GDD (B \ I) (f B) \' {{x} \ I |x . x \ B }" + assumes "G1 \ {G \ I |G. G \ \}" + assumes "G2 \ {G \ I |G. G \ \}" + assumes "G1 \ G2" + and "(x, ix) \ G1" and "(y, iy) \ G2" + shows "(\\<^sub># (image_mset f \)) index {(x, ix), (y, iy)} = (1 ::int)" +proof - + obtain G1' where gi1: "G1 = G1' \ I" and ging1: "G1' \ \" using assms by auto + obtain G2' where gi2: "G2 = G2' \ I" and ging2: "G2' \ \" using assms by auto + have xing: "x \ G1'" using assms gi1 by simp + have ying: "y \ G2'" using assms gi2 by simp + have gne: "G1' \ G2'" using assms gi1 gi2 by auto + then have xyne: "x \ y" using xing ying ging1 ging2 point_in_one_group by blast + have "\! bl . bl \# \ \ {x, y} \ bl" using index_distinct points_index_one_unique_block + by (metis ging1 ging2 gne of_nat_1_eq_iff xing ying) + then obtain bl where blinb:"bl \# \" and xyblss: "{x, y} \ bl" by auto + then have "\ b . b \# \ - {#bl#} \ \ {x, y} \ b" using points_index_one_not_unique_block + by (metis ging1 ging2 gne index_distinct int_ops(2) nat_int_comparison(1) xing ying) + then have not_ss: "\ b . b \# \ - {#bl#} \ \ ({(x, ix), (y, iy)} \ (b \ I))" using assms + by (meson SigmaD1 empty_subsetI insert_subset) + then have pi0: "\ b . b \# \ - {#bl#} \ (f b) index {(x, ix), (y, iy)} = 0" + proof - + fix b + assume assm: "b \# \ - {#bl#}" + then have "b \# \" by (meson in_diffD) + then interpret kgdd: K_GDD "(b \ I)" "(f b)" \' "{{x} \ I |x . x \ b }" using assms by simp + show "(f b) index {(x, ix), (y, iy)} = 0" + using assm not_ss by (metis kgdd.points_index_ps_nin) + qed + let ?G = "{{x} \ I |x . x \ bl }" + interpret bkgdd: K_GDD "(bl \ I)" "(f bl)" \' ?G using assms blinb by simp + obtain g1 g2 where xing1: "(x, ix) \ g1" and ying2: "(y, iy) \ g2" and g1g: "g1 \ ?G" + and g2g: "g2 \ ?G" using assms(5) assms(6) gi1 gi2 + by (metis (no_types, lifting) bkgdd.point_has_unique_group insert_subset mem_Sigma_iff xyblss) + then have "g1 \ g2" using xyne by blast + then have pi1: "(f bl) index {(x, ix), (y, iy)} = 1" + using bkgdd.index_distinct xing1 ying2 g1g g2g by simp + have "(\\<^sub># (image_mset f \)) index {(x, ix), (y, iy)} = + (\B \# \. (f B) index {(x, ix), (y, iy)} )" + by (simp add: points_index_sum) + then have "(\\<^sub># (image_mset f \)) index {(x, ix), (y, iy)} = + (\B \# (\ - {#bl#}). (f B) index {(x, ix), (y, iy)}) + (f bl) index {(x, ix), (y, iy)}" + by (metis (no_types, lifting) add.commute blinb insert_DiffM sum_mset.insert) + thus ?thesis using pi0 pi1 by simp +qed + +theorem Wilsons_Construction: + assumes "card I = w" + assumes "w > 0" + assumes "\ n. n \ \' \ n \ 2" + assumes "\ B . B \# \ \ K_GDD (B \ I) (f B) \' {{x} \ I |x . x \ B }" + shows "K_GDD (\ \ I) (\B \# \. (f B)) \' {G \ I | G . G \ \}" +proof - + let ?Y = "\ \ I" and ?H = "{G \ I | G . G \ \}" and ?B = "\B \# \. (f B)" + interpret pd: proper_design ?Y ?B using wilsons_construction_proper assms by auto + have "\ bl . bl \# (\B \# \. (f B)) \ card bl \ \'" + using assms pair_construction_block_sizes by blast + then interpret kdes: K_block_design ?Y ?B \' + using assms(3) by (unfold_locales) (simp_all,fastforce) + interpret gdd: GDD ?Y ?B ?H "1:: int" + proof (unfold_locales) + show "partition_on (\ \ I) {G \ I |G. G \ \}" + using assms groups_not_empty design_points_nempty group_partitions + by (simp add: partition_on_cart_prod) + have "inj_on (\ G. G \ I) \" + using inj_on_def pd.design_points_nempty by auto + then have "card {G \ I |G. G \ \} = card \" using card_image by (simp add: Setcompr_eq_image) + then show "1 < card {G \ I |G. G \ \}" using groups_size by linarith + show "(1::int) \ 1" by simp + have gdd_fact: "\ B . B \# \ \ K_GDD (B \ I) (f B) \' {{x} \ I |x . x \ B }" + using assms by simp + show "\G X Y. G \ {GG \ I |GG. GG \ \} \ X \ G \ Y \ G \ X \ Y + \ (\\<^sub># (image_mset f \)) index {X, Y} = 0" + using wilsons_construction_index_0[OF assms(4)] by auto + show "\G1 G2 X Y. G1 \ {G \ I |G. G \ \} \ G2 \ {G \ I |G. G \ \} + \ G1 \ G2 \ X \ G1 \ Y \ G2 \ ((\\<^sub># (image_mset f \)) index {X, Y}) = (1 ::int)" + using wilsons_construction_index_1[OF assms(4)] by blast + qed + show ?thesis by (unfold_locales) +qed + +end + +context pairwise_balance +begin + +lemma PBD_by_deleting_point: + assumes "\ > 2" + assumes "\ bl . bl \# \ \ card bl \ 2" + shows "pairwise_balance (del_point x) (del_point_blocks x) \" +proof (cases "x \ \") + case True + interpret des: design "del_point x" "del_point_blocks x" + using delete_point_design assms by blast + show ?thesis using assms design_blocks_nempty del_point_def del_point_blocks_def + proof (unfold_locales, simp_all) + show "2 < \ \ (\bl. bl \# \ \ 2 \ card bl) \ 2 \ int (card (\ - {x}))" + using card_Diff_singleton_if diff_diff_cancel diff_le_mono2 finite_sets less_one + by (metis int_ops(3) less_nat_zero_code nat_le_linear verit_comp_simplify1(3) zle_int) + have "\ ps . ps \ \ - {x} \ ps \ \" by auto + then show "\ps. ps \ \ - {x} \ card ps = 2 \ {#bl - {x}. bl \# \#} index ps = \" + using delete_point_index_eq del_point_def del_point_blocks_def by simp + qed +next + case False + then show ?thesis + by (simp add: del_invalid_point del_invalid_point_blocks pairwise_balance_axioms) +qed +end + +context k_GDD +begin + +lemma bibd_from_kGDD: + assumes "\ > 1" + assumes "\ g. g \ \ \ card g = \ - 1" + assumes " x \ \" + shows "bibd (add_point x) (\ + mset_set { insert x g | g. g \ \}) (\) 1" +proof - + have "({\} \ {(card g) + 1 | g . g \ \}) = {\}" + using assms(2) by fastforce + then interpret pbd: PBD "(add_point x)" "\ + mset_set { insert x g | g. g \ \}" "{\}" + using PBD_by_adjoining_point assms sys_block_sizes_obtain_bl add_point_def + by (smt (verit, best) Collect_cong sys_block_sizes_uniform uniform_alt_def_all) + show ?thesis using assms pbd.block_sizes block_size_lt_v finite_sets add_point_def + by (unfold_locales) (simp_all) +qed + +end + +context PBD +begin + +lemma pbd_points_index1: "ps \ \ \ card ps = 2 \ \ index ps = 1" + using balanced by (metis int_eq_iff_numeral of_nat_1_eq_iff) + +lemma pbd_index1_points_imply_unique_block: + assumes "b1 \# \" and "b2 \# \" and "b1 \ b2" + assumes "x \ y" and "{x, y} \ b1" and "x \ b2" + shows "y \ b2" +proof (rule ccontr) + let ?ps = "{# b \# \ . {x, y} \ b#}" + assume "\ y \ b2" + then have a: "y \ b2" by linarith + then have "{x, y} \ b2" + by (simp add: assms(6)) + then have "b1 \# ?ps" and "b2 \# ?ps" using assms by auto + then have ss: "{#b1, b2#} \# ?ps" using assms + by (metis insert_noteq_member mset_add mset_subset_eq_add_mset_cancel single_subset_iff) + have "size {#b1, b2#} = 2" using assms by auto + then have ge2: "size ?ps \ 2" using assms ss by (metis size_mset_mono) + have pair: "card {x, y} = 2" using assms by auto + have "{x, y} \ \" using assms wellformed by auto + then have "\ index {x, y} = 1" using pbd_points_index1 pair by simp + then show False using points_index_def ge2 + by (metis numeral_le_one_iff semiring_norm(69)) +qed + +lemma strong_delete_point_groups_index_zero: + assumes "G \ {b - {x} |b. b \# \ \ x \ b}" + assumes "xa \ G" and "y \ G" and "xa \ y" + shows "(str_del_point_blocks x) index {xa, y} = 0" +proof (auto simp add: points_index_0_iff str_del_point_blocks_def) + fix b + assume a1: "b \# \" and a2: "x \ b" and a3: "xa \ b" and a4: "y \ b" + obtain b' where "G = b' - {x}" and "b' \# \" and "x \ b'" using assms by blast + then show False using a1 a2 a3 a4 assms pbd_index1_points_imply_unique_block + by fastforce +qed + +lemma strong_delete_point_groups_index_one: + assumes "G1 \ {b - {x} |b. b \# \ \ x \ b}" + assumes "G2 \ {b - {x} |b. b \# \ \ x \ b}" + assumes "G1 \ G2" and "xa \ G1" and "y \ G2" + shows "(str_del_point_blocks x) index {xa, y} = 1" +proof - + obtain b1 where gb1: "G1 = b1 - {x}" and b1in: "b1 \# \" and xin1: "x \ b1" using assms by blast + obtain b2 where gb2: "G2 = b2 - {x}" and b2in: "b2 \# \" and xin2:"x \ b2" using assms by blast + have bneq: "b1 \ b2 " using assms(3) gb1 gb2 by auto + have "xa \ y" using gb1 b1in xin1 gb2 b2in xin2 assms(3) assms(4) assms(5) insert_subset + by (smt (verit, best) Diff_eq_empty_iff Diff_iff empty_Diff insertCI pbd_index1_points_imply_unique_block) + then have pair: "card {xa, y} = 2" by simp + have inv: "{xa, y} \ \" using gb1 b1in gb2 b2in assms(4) assms(5) + by (metis Diff_cancel Diff_subset insert_Diff insert_subset wellformed) + have "{# bl \# \ . x \ bl#} index {xa, y} = 0" + proof (auto simp add: points_index_0_iff) + fix b assume a1: "b \# \" and a2: "x \ b" and a3: "xa \ b" and a4: "y \ b" + then have yxss: "{y, x} \ b2" + using assms(5) gb2 xin2 by blast + have "{xa, x} \ b1" + using assms(4) gb1 xin1 by auto + then have "xa \ b2" using pbd_index1_points_imply_unique_block + by (metis DiffE assms(4) b1in b2in bneq gb1 singletonI xin2) + then have "b2 \ b" using a3 by auto + then show False using pbd_index1_points_imply_unique_block + by (metis DiffD2 yxss a1 a2 a4 assms(5) b2in gb2 insertI1) + qed + then have "(str_del_point_blocks x) index {xa, y} = \ index {xa, y}" + by (metis multiset_partition plus_nat.add_0 point_index_distrib str_del_point_blocks_def) + thus ?thesis using pbd_points_index1 pair inv by fastforce +qed + +lemma blocks_with_x_partition: + assumes "x \ \" + shows "partition_on (\ - {x}) {b - {x} |b. b \# \ \ x \ b}" +proof (intro partition_onI ) + have gtt: "\ bl. bl \# \ \ card bl \ 2" using block_size_gt_t + by (simp add: block_sizes nat_int_comparison(3)) + show "\p. p \ {b - {x} |b. b \# \ \ x \ b} \ p \ {}" + proof - + fix p assume "p \ {b - {x} |b. b \# \ \ x \ b}" + then obtain b where ptx: "p = b - {x}" and "b \# \" and xinb: "x \ b" by blast + then have ge2: "card b \ 2" using gtt by (simp add: nat_int_comparison(3)) + then have "finite b" by (metis card.infinite not_numeral_le_zero) + then have "card p = card b - 1" using xinb ptx by simp + then have "card p \ 1" using ge2 by linarith + thus "p \ {}" by auto + qed + show "\ {b - {x} |b. b \# \ \ x \ b} = \ - {x}" + proof (intro subset_antisym subsetI) + fix xa + assume "xa \ \ {b - {x} |b. b \# \ \ x \ b}" + then obtain b where "xa \ b" and "b \# \" and "x \ b" and "xa \ x" by auto + then show "xa \ \ - {x}" using wf_invalid_point by blast + next + fix xa + assume a: "xa \ \ - {x}" + then have nex: "xa \ x" by simp + then have pair: "card {xa, x} = 2" by simp + have "{xa, x} \ \" using a assms by auto + then have "card {b \ design_support . {xa, x} \ b} = 1" + using balanced points_index_simple_def pbd_points_index1 assms by (metis pair) + then obtain b where des: "b \ design_support" and ss: "{xa, x} \ b" + by (metis (no_types, lifting) card_1_singletonE mem_Collect_eq singletonI) + then show "xa \ \ {b - {x} |b. b \# \ \ x \ b}" + using des ss nex design_support_def by auto + qed + show "\p p'. p \ {b - {x} |b. b \# \ \ x \ b} \ p' \ {b - {x} |b. b \# \ \ x \ b} \ + p \ p' \ p \ p' = {}" + proof - + fix p p' + assume p1: "p \ {b - {x} |b. b \# \ \ x \ b}" and p2: "p' \ {b - {x} |b. b \# \ \ x \ b}" + and pne: "p \ p'" + then obtain b where b1: "p = b - {x}" and b1in:"b \# \" and xinb1:"x \ b" by blast + then obtain b' where b2: "p' = b' - {x}" and b2in: "b' \# \" and xinb2: "x \ b'" + using p2 by blast + then have "b \ b'" using pne b1 by auto + then have "\ y. y \ b \ y \ x \ y \ b'" + using b1in b2in xinb1 xinb2 pbd_index1_points_imply_unique_block + by (meson empty_subsetI insert_subset) + then have "\ y. y \ p \ y \ p'" + by (metis Diff_iff b1 b2 insertI1) + then show "p \ p' = {}" using disjoint_iff by auto + qed +qed + +lemma KGDD_by_deleting_point: + assumes "x \ \" + assumes "\ rep x < \" + assumes "\ rep x > 1" + shows "K_GDD (del_point x) (str_del_point_blocks x) \ { b - {x} | b . b \# \ \ x \ b}" +proof - + have "\ bl. bl \# \ \ card bl \ 2" using block_size_gt_t + by (simp add: block_sizes nat_int_comparison(3)) + then interpret des: proper_design "(del_point x)" "(str_del_point_blocks x)" + using strong_delete_point_proper assms by blast + show ?thesis using blocks_with_x_partition strong_delete_point_groups_index_zero + strong_delete_point_groups_index_one str_del_point_blocks_def del_point_def + proof (unfold_locales, simp_all add: block_sizes positive_ints assms) + have ge1: "card {b . b \# \ \ x \ b} > 1" + using assms(3) replication_num_simple_def design_support_def by auto + have fin: "finite {b . b \# \ \ x \ b}" by simp + have inj: "inj_on (\ b . b - {x}) {b . b \# \ \ x \ b}" + using assms(2) inj_on_def mem_Collect_eq by auto + then have "card {b - {x} |b. b \# \ \ x \ b} = card {b . b \# \ \ x \ b}" + using card_image fin by (simp add: inj card_image setcompr_eq_image) + then show "Suc 0 < card {b - {x} |b. b \# \ \ x \ b}" using ge1 + by presburger + qed +qed + +lemma card_singletons_eq: "card {{a} | a . a \ A} = card A" + by (simp add: card_image Setcompr_eq_image) + +lemma KGDD_from_PBD: "K_GDD \ \ \ {{x} | x . x \ \}" +proof (unfold_locales,auto simp add: Setcompr_eq_image partition_on_singletons) + have "card ((\x. {x}) ` \) \ 2" using t_lt_order card_singletons_eq + by (metis Collect_mem_eq nat_leq_as_int of_nat_numeral setcompr_eq_image) + then show "Suc 0 < card ((\x. {x}) ` \)" by linarith + show "\xa xb. xa \ \ \ xb \ \ \ \ index {xa, xb} \ Suc 0 \ xa = xb" + proof (rule ccontr) + fix xa xb + assume ain: "xa \ \" and bin: "xb \ \" and ne1: "\ index {xa, xb} \ Suc 0" + assume "xa \ xb" + then have "card {xa, xb} = 2" by auto + then have "\ index {xa, xb} = 1" + by (simp add: ain bin pbd_points_index1) + thus False using ne1 by linarith + qed +qed + +end + +context bibd +begin +lemma kGDD_from_bibd: + assumes "\ = 1" + assumes "x \ \" + shows "k_GDD (del_point x) (str_del_point_blocks x) \ { b - {x} | b . b \# \ \ x \ b}" +proof - + interpret pbd: PBD \ \ "{\}" using assms + using PBD.intro \_PBD_axioms by auto + have lt: "\ rep x < \" using block_num_gt_rep + by (simp add: assms(2)) + have "\ rep x > 1" using r_ge_two assms by simp + then interpret kgdd: K_GDD "(del_point x)" "str_del_point_blocks x" + "{\}" "{ b - {x} | b . b \# \ \ x \ b}" + using pbd.KGDD_by_deleting_point lt assms by blast + show ?thesis using del_point_def str_del_point_blocks_def by (unfold_locales) (simp_all) +qed + +end +end \ No newline at end of file diff --git a/thys/Design_Theory/Multisets_Extras.thy b/thys/Design_Theory/Multisets_Extras.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Multisets_Extras.thy @@ -0,0 +1,792 @@ +(* Title: Multisets_Extras + Author: Chelsea Edmonds +*) + +section \Micellanious Helper Functions on Sets and Multisets\ + +theory Multisets_Extras imports Main "HOL-Library.Multiset" "Card_Partitions.Set_Partition" +"Nested_Multisets_Ordinals.Multiset_More" "HOL-Library.Disjoint_Sets" +begin + +subsection \Set Theory Extras\ + +text \A number of extra helper lemmas for reasoning on sets (finite) required for Design Theory +proofs\ + +lemma card_Pow_filter_one: + assumes "finite A" + shows "card {x \ Pow A . card x = 1} = card (A)" + using assms +proof (induct rule: finite_induct) + case empty + then show ?case by auto +next + case (insert x F) + have "Pow (insert x F) = Pow F \ insert x ` Pow F" + by (simp add: Pow_insert) + then have split: "{y \ Pow (insert x F) . card y = 1} = + {y \ (Pow F) . card y = 1} \ {y \ (insert x ` Pow F) . card y = 1}" + by blast + have "\ y . y \ (insert x ` Pow F) \ finite y" + using finite_subset insert.hyps(1) by fastforce + then have single: "\ y . y \ (insert x ` Pow F) \ card y = 1 \ y = {x}" + by (metis card_1_singletonE empty_iff image_iff insertCI insertE) + then have "card {y \ (insert x ` Pow F) . card y = 1} = 1" + using empty_iff imageI is_singletonI is_singletonI' is_singleton_altdef (* LONG *) + by (metis (full_types, lifting) Collect_empty_eq_bot Pow_bottom bot_empty_eq mem_Collect_eq) + then have " {y \ (insert x ` Pow F) . card y = 1} = {{x}}" + using single card_1_singletonE card_eq_0_iff + by (smt empty_Collect_eq mem_Collect_eq singletonD zero_neq_one) + then have split2:"{y \ Pow (insert x F) . card y = 1} = {y \ (Pow F) . card y = 1} \ {{x}}" + using split by simp + then show ?case + proof (cases "x \ F") + case True + then show ?thesis using insert.hyps(2) by auto + next + case False + then have "{y \ (Pow F) . card y = 1} \ {{x}} = {}" by blast + then have fact:"card {y \ Pow (insert x F) . card y = 1} = + card {y \ (Pow F) . card y = 1} + card {{x}}" + using split2 card_Un_disjoint insert.hyps(1) by auto + have "card (insert x F) = card F + 1" + using False card_insert_disjoint by (metis Suc_eq_plus1 insert.hyps(1)) + then show ?thesis using fact insert.hyps(3) by auto + qed +qed + +lemma elem_exists_non_empty_set: + assumes "card A > 0" + obtains x where "x \ A" + using assms card_gt_0_iff by fastforce + +lemma set_self_img_compr: "{a | a . a \ A} = A" + by blast + +lemma card_subset_not_gt_card: "finite A \ card ps > card A \ \ (ps \ A)" + using card_mono leD by auto + +lemma card_inter_lt_single: "finite A \ finite B \ card (A \ B) \ card A" + by (simp add: card_mono) + +lemma set_diff_non_empty_not_subset: + assumes "A \ (B - C)" + assumes "C \ {}" + assumes "A \ {}" + assumes "B \ {}" + shows " \ (A \ C)" +proof (rule ccontr) + assume " \ \ (A \ C)" + then have a: "\ x . x \ A \ x \ C" by blast + thus False using a assms by blast +qed + +lemma set_card_diff_ge_zero: "finite A \ finite B \ A \ B \ card A = card B \ + card (A - B) > 0" + by (meson Diff_eq_empty_iff card_0_eq card_subset_eq finite_Diff neq0_conv) + +lemma set_filter_diff: "{a \ A . P a } - {x} = {a \ (A - {x}) . (P a )}" + by (auto) + +lemma set_filter_diff_card: "card ({a \ A . P a } - {x}) = card {a \ (A - {x}) . (P a )}" + by (simp add: set_filter_diff) + +lemma obtain_subset_with_card_int_n: + assumes "(n ::int) \ of_nat (card S)" + assumes "(n ::int) \ 0" + obtains T where "T \ S" "of_nat (card T) = (n ::int)" "finite T" + using obtain_subset_with_card_n assms + by (metis nonneg_int_cases of_nat_le_iff) + +lemma transform_filter_img_empty_rm: + assumes "\ g . g \ G \ g \ {}" + shows "{g - {x} | g. g \ G \ g \ {x}} = {g - {x} | g. g \ G } - {{}}" +proof - + let ?f = "\ g . g - {x}" + have "\ g . g \ G \ g \ {x} \ ?f g \ {}" using assms + by (metis Diff_cancel Diff_empty Diff_insert0 insert_Diff) + thus ?thesis by auto +qed + +lemma bij_betw_inter_subsets: "bij_betw f A B \ a1 \ A \ a2 \ A + \ f ` (a1 \ a2) = (f ` a1) \ (f ` a2)" + by (meson bij_betw_imp_inj_on inj_on_image_Int) + +text\Partition related set theory lemmas\ + +lemma partition_on_remove_pt: + assumes "partition_on A G" + shows "partition_on (A - {x}) {g - {x} | g. g \ G \ g \ {x}}" +proof (intro partition_onI) + show "\p. p \ {g - {x} |g. g \ G \ g \ {x}} \ p \ {}" + using assms partition_onD3 subset_singletonD by force + let ?f = "(\ g . g - {x})" + have un_img: "\({?f g | g. g \ G }) = ?f (\ G)" by blast + have empty: "\ {g - {x} |g. g \ G \ g \ {x}} = \({g - {x} | g. g \ G } - {{}})" + by blast + then have "\({g - {x} | g. g \ G } - {{}}) = \({g - {x} | g. g \ G })" by blast + then show " \ {g - {x} |g. g \ G \ g \ {x}} = A - {x}" using partition_onD1 assms un_img + by (metis empty) + then show "\p p'. + p \ {g - {x} |g. g \ G \ g \ {x}} \ + p' \ {g - {x} |g. g \ G \ g \ {x}} \ p \ p' \ p \ p' = {}" + proof - + fix p1 p2 + assume p1: "p1 \ {g - {x} |g. g \ G \ g \ {x}}" + and p2: "p2 \ {g - {x} |g. g \ G \ g \ {x}}" + and ne: "p1 \ p2" + obtain p1' p2' where orig1: "p1 = p1' - {x}" and orig2: "p2 = p2' - {x}" + and origne: "p1' \ p2'" and ne1: "p1' \ {x}" and ne2:"p2' \ {x}" and ing1: "p1' \ G" + and ing2: "p2' \ G" + using p1 p2 using mem_Collect_eq ne by blast + then have "p1' \ p2' = {}" using assms partition_onD2 ing1 ing2 origne disjointD by blast + thus "p1 \ p2 = {}" using orig1 orig2 by blast + qed +qed + +lemma partition_on_cart_prod: + assumes "card I > 0" + assumes "A \ {}" + assumes "G \ {}" + assumes "partition_on A G" + shows "partition_on (A \ I) {g \ I |g. g \ G}" +proof (intro partition_onI) + show "\p. p \ {g \ I |g. g \ G} \ p \ {}" + using assms(1) assms(4) partition_onD3 by fastforce + show "\ {g \ I |g. g \ G} = A \ I" + by (metis Setcompr_eq_image Sigma_Union assms(4) partition_onD1) + show "\p p'. p \ {g \ I |g. g \ G} \ p' \ {g \ I |g. g \ G} \ p \ p' \ p \ p' = {}" + by (smt (verit, best) Sigma_Int_distrib1 Sigma_empty1 assms(4) mem_Collect_eq partition_onE) +qed + +subsection \Multiset Helpers\ + +text \Generic Size, count and card helpers\ + +lemma count_size_set_repr: "size {# x \# A . x = g#} = count A g" + by (simp add: filter_eq_replicate_mset) + +lemma mset_nempty_set_nempty: "A \ {#} \ (set_mset A) \ {}" + by simp + +lemma mset_size_ne0_set_card: "size A > 0 \ card (set_mset A) > 0" + using mset_nempty_set_nempty by fastforce + +lemma set_count_size_min: "count A a \ n \ size A \ n" + by (metis (full_types) count_le_replicate_mset_subset_eq size_mset_mono size_replicate_mset) + +lemma card_size_filter_eq: "finite A \ card {a \ A . P a} = size {#a \# mset_set A . P a#}" + by simp + +lemma size_multiset_int_count: + assumes "of_nat (card (set_mset A)) = (ca :: int)" + assumes "\p. p \# A \ of_nat (count A p) = (ca2 :: int)" + shows "of_nat (size A) = ((ca :: int) * ca2)" +proof - + have "size A = (\ p \ (set_mset A) . count A p)" using size_multiset_overloaded_eq by auto + then have "of_nat (size A) = (\ p \ (set_mset A) . ca2)" using assms by simp + thus ?thesis using assms(1) by auto +qed + +lemma mset_union_size: "size (A \# B) = size (A) + size (B - A)" + by (simp add: sup_subset_mset_def) + +lemma mset_union_size_inter: "size (A \# B) = size (A) + size B - size (A \# B)" + by (metis diff_add_inverse2 size_Un_Int) + +text \Lemmas for repeat\_mset\ + +lemma repeat_mset_size [simp]: "size (repeat_mset n A) = n * size A" + by (induction n) auto + +lemma repeat_mset_subset_in: + assumes "\ a . a \# A \ a \ B" + assumes "X \# repeat_mset n A" + assumes "x \ X" + shows " x \ B" + using assms by (induction n) auto + +lemma repeat_mset_not_empty: "n > 0 \ A \ {#} \ repeat_mset n A \ {#}" + by (induction n) auto + +lemma elem_in_repeat_in_original: "a \# repeat_mset n A \ a \# A" + by (metis count_inI count_repeat_mset in_countE mult.commute mult_zero_left nat.distinct(1)) + +lemma elem_in_original_in_repeat: "n > 0 \ a \# A \ a \# repeat_mset n A" + by (metis (full_types) Suc_pred repeat_mset.simps(2) union_iff) + +text \Lemmas on image and filter for multisets\ + +lemma multiset_add_filter_size: "size {# a \# (A1 + A2) . P a #} = size {# a \# A1 . P a #} + + size {# a \# A2 . P a #}" + by simp + +lemma size_filter_neg: "size {#a \# A . P a #} = size A - size {# a \# A . \ P a #}" + using size_filter_mset_lesseq size_union union_filter_mset_complement + by (metis ordered_cancel_comm_monoid_diff_class.le_imp_diff_is_add) + +lemma filter_filter_mset_cond_simp: + assumes "\ a . P a \ Q a" + shows "filter_mset P A = filter_mset P (filter_mset Q A)" +proof - + have "filter_mset P (filter_mset Q A) = filter_mset (\ a. Q a \ P a) A" + by (simp add: filter_filter_mset) + thus ?thesis using assms + by (metis (mono_tags, lifting) filter_mset_cong) +qed + +lemma filter_filter_mset_ss_member: "filter_mset (\ a . {x, y} \ a) A = + filter_mset (\ a . {x, y} \ a) (filter_mset (\ a . x \ a) A)" +proof - + have filter: "filter_mset (\ a . {x, y} \ a) (filter_mset (\ a . x \ a) A) = + filter_mset (\ a . x \ a \ {x, y} \ a) A" by (simp add: filter_filter_mset) + have "\ a. {x, y} \ a \ x \ a" by simp + thus ?thesis using filter by auto +qed + +lemma multiset_image_do_nothing: "(\ x .x \# A \ f x = x) \ image_mset f A = A" + by (induct A) auto + +lemma set_mset_filter: "set_mset {# f a . a \# A #} = {f a | a. a \# A}" + by (simp add: Setcompr_eq_image) + +lemma mset_exists_imply: "x \# {# f a . a \# A #} \ \ y \# A . x = f y" + by auto + +lemma filter_mset_image_mset: + "filter_mset P (image_mset f A) = image_mset f (filter_mset (\x. P (f x)) A)" + by (induction A) auto + +lemma mset_bunion_filter: "{# a \# A . P a \ Q a #} = {# a \# A . P a #} \# {# a \# A . Q a #}" + by (rule multiset_eqI) simp + +lemma mset_inter_filter: "{# a \# A . P a \ Q a #} = {# a \# A . P a #} \# {# a \# A . Q a #}" + by (rule multiset_eqI) simp + +lemma image_image_mset: "image_mset (\ x . f x) (image_mset (\ y . g y) A) = + image_mset (\ x. f (g x)) A" + by simp + +text \Big Union over multiset helpers\ + +lemma mset_big_union_obtain: + assumes "x \# \\<^sub># A" + obtains a where "a \# A" and "x \# a" + using assms by blast + +lemma size_big_union_sum: "size (\\<^sub># (M :: 'a multiset multiset)) = (\x \#M . size x)" + by (induct M) auto + +text \Cartesian Product on Multisets\ + +lemma size_cartesian_product_singleton [simp]: "size ({#a#} \# B) = size B" + by (simp add: Times_mset_single_left) + +lemma size_cartesian_product_singleton_right [simp]: "size (A \# {#b#}) = size A" + by (simp add: Times_mset_single_right) + +lemma size_cartesian_product_empty [simp]: "size (A \# {#}) = 0" + by simp + +lemma size_add_elem_step_eq: + assumes "size (A \# B) = size A * size B" + shows "size (add_mset x A \# B) = size (add_mset x A) * size B" +proof - + have "(add_mset x A \# B) = A \# B + {#x#} \# B" + by (metis Sigma_mset_plus_distrib1 add_mset_add_single) + then have "size (add_mset x A \# B) = size (A \# B) + size B" by auto + also have "... = size A * size B + size B" + by (simp add: assms) + finally have "size (add_mset x A \# B) = (size A + 1) * size B" + by auto + thus ?thesis by simp +qed + +lemma size_cartesian_product: "size (A \# B) = size A * size B" + by (induct A) (simp_all add: size_add_elem_step_eq) + +lemma cart_prod_distinct_mset: + assumes assm1: "distinct_mset A" + assumes assm2: "distinct_mset B" + shows "distinct_mset (A \# B)" + unfolding distinct_mset_count_less_1 +proof (rule allI) + fix x + have count_mult: "count (A \# B) x = count A (fst x) * count B (snd x)" + using count_Sigma_mset by (metis prod.exhaust_sel) + then have "count A (fst x) * count B (snd x) \ 1" using assm1 assm2 + unfolding distinct_mset_count_less_1 using mult_le_one by blast + thus "count (A \# B) x \ 1" using count_mult by simp +qed + +lemma cart_product_single_intersect: "x1 \ x2 \ ({#x1#} \# A) \# ({#x2#} \# B) = {#}" + using multiset_inter_single by fastforce + +lemma size_union_distinct_cart_prod: "x1 \ x2 \ size (({#x1#} \# A) \# ({#x2#} \# B)) = + size ({#x1#} \# A) + size ({#x2#} \# B)" + by (simp add: cart_product_single_intersect size_Un_disjoint) + +lemma size_Union_distinct_cart_prod: "distinct_mset M \ + size (\p\#M. ({#p#} \# B)) = size (M) * size (B)" + by (induction M) auto + +lemma size_Union_distinct_cart_prod_filter: "distinct_mset M \ + (\ p . p \# M \ size ({# b \# B . P p b #}) = c) \ + size (\p\#M. ({#p#} \# {# b \# B . P p b #})) = size (M) * c" + by (induction M) auto + +lemma size_Union_distinct_cart_prod_filter2: "distinct_mset V \ + (\ b . b \# B \ size ({# v \# V . P v b #}) = c) \ + size (\b\#B. ( {# v \# V . P v b #} \# {#b#})) = size (B) * c" + by (induction B) auto + +lemma cart_product_add_1: "(add_mset a A) \# B = ({#a#} \# B) + (A \# B)" + by (metis Sigma_mset_plus_distrib1 add_mset_add_single union_commute) + +lemma cart_product_add_1_filter: "{#m \# ((add_mset a M) \# N) . P m #} = + {#m \# (M \# N) . P m #} + {#m \# ({#a#} \# N) . P m #}" + unfolding add_mset_add_single [of a M] Sigma_mset_plus_distrib1 + by (simp add: Times_mset_single_left) + +lemma cart_product_add_1_filter2: "{#m \# (M \# (add_mset b N)) . P m #} = + {#m \# (M \# N) . P m #} + {#m \# (M \# {#b#}) . P m #}" + unfolding add_mset_add_single [of b N] Sigma_mset_plus_distrib1 + by (metis Times_insert_left Times_mset_single_right add_mset_add_single filter_union_mset) + +lemma cart_prod_singleton_right_gen: + assumes "\ x . x \# (A \# {#b#}) \ P x \ Q (fst x)" + shows "{#x \# (A \# {#b#}). P x#} = {# a \# A . Q a#} \# {#b#}" + using assms +proof (induction A) + case empty + then show ?case by simp +next + case (add x A) + have "add_mset x A \# {#b#} = add_mset (x, b) (A \# {#b#})" + by (simp add: Times_mset_single_right) + then have lhs: "filter_mset P (add_mset x A \# {#b#}) = filter_mset P (A \# {#b#}) + + filter_mset P {#(x, b)#}" by simp + have rhs: "filter_mset Q (add_mset x A) \# {#b#} = filter_mset Q A \# {#b#} + + filter_mset Q {#x#} \# {#b#}" + by (metis Sigma_mset_plus_distrib1 add_mset_add_single filter_union_mset) + have "filter_mset P {#(x, b)#} = filter_mset Q {#x#} \# {#b#}" + using add.prems by fastforce + then show ?case using lhs rhs add.IH add.prems by force +qed + +lemma cart_prod_singleton_left_gen: + assumes "\ x . x \# ({#a#} \# B) \ P x \ Q (snd x)" + shows "{#x \# ({#a#} \# B). P x#} = {#a#} \# {#b \# B . Q b#}" + using assms +proof (induction B) + case empty + then show ?case by simp +next + case (add x B) + have lhs: "filter_mset P ({#a#} \# add_mset x B) = filter_mset P ({#a#} \# B) + + filter_mset P {#(a, x)#}" + by (simp add: cart_product_add_1_filter2) + have rhs: "{#a#} \# filter_mset Q (add_mset x B) = {#a#} \# filter_mset Q B + + {#a#} \# filter_mset Q {#x#}" + using add_mset_add_single filter_union_mset by (metis Times_mset_single_left image_mset_union) + have "filter_mset P {#(a, x)#} = {#a#} \# filter_mset Q {#x#}" + using add.prems by fastforce + then show ?case using lhs rhs add.IH add.prems by force +qed + +lemma cart_product_singleton_left: "{#m \# ({#a#} \# N) . fst m \ snd m #} = + ({#a#} \# {# n \# N . a \ n #})" (is "?A = ?B") +proof - + have stmt: "\m. m \# ({#a#} \# N) \ fst m \ snd m \ a \ snd m" + by (simp add: mem_Times_mset_iff) + thus ?thesis by (metis (no_types, lifting) Sigma_mset_cong stmt cart_prod_singleton_left_gen) +qed + +lemma cart_product_singleton_right: "{#m \# (N \# {#b#}) . fst m \ snd m #} = + ({# n \# N . n \ b #} \# {# b #})" (is "?A = ?B") +proof - + have stmt: "\m. m \# (N \# {#b#}) \ fst m \ snd m \ fst m \b" + by (simp add: mem_Times_mset_iff) + thus ?thesis by (metis (no_types, lifting) Sigma_mset_cong stmt cart_prod_singleton_right_gen) +qed + +lemma cart_product_add_1_filter_eq: "{#m \# ((add_mset a M) \# N) . (fst m \ snd m) #} = + {#m \# (M \# N) . (fst m \ snd m) #} + ({#a#} \# {# n \# N . a \ n #})" + unfolding add_mset_add_single [of a M] Sigma_mset_plus_distrib1 + using cart_product_singleton_left cart_product_add_1_filter by fastforce + +lemma cart_product_add_1_filter_eq_mirror: "{#m \# M \# (add_mset b N) . (fst m \ snd m) #} = + {#m \# (M \# N) . (fst m \ snd m) #} + ({# n \# M . n \ b #} \# {#b#})" + unfolding add_mset_add_single [of b N] Sigma_mset_plus_distrib1 (* longish *) + by (metis (no_types) add_mset_add_single cart_product_add_1_filter2 cart_product_singleton_right) + +lemma set_break_down_left: + shows "{# m \# (M \# N) . (fst m) \ (snd m) #} = (\m\#M. ({#m#} \# {#n \# N. m \ n#}))" + by (induction M) (auto simp add: cart_product_add_1_filter_eq) + +lemma set_break_down_right: + shows "{# x \# M \# N . (fst x) \ (snd x) #} = (\n\#N. ({#m \# M. m \ n#} \# {#n#}))" + by (induction N) (auto simp add: cart_product_add_1_filter_eq_mirror) + +text \Reasoning on sums of elements over multisets\ + +lemma sum_over_fun_eq: + assumes "\ x . x \# A \ f x = g x" + shows "(\x \# A . f(x)) = (\ x \# A . g (x))" + using assms by auto + +context ring_1 +begin + +lemma sum_mset_add_diff: "(\ x \# A. f x - g x) = (\ x \# A . f x) - (\ x \# A . g x)" + by (induction A) (auto simp add: algebra_simps) + +end + +context ordered_ring +begin + +lemma sum_mset_ge0:"(\ x . f x \ 0) \ (\ x \# A. f x ) \ 0" +proof (induction A) + case empty + then show ?case by simp +next + case (add x A) + then have hyp2: "0 \ sum_mset (image_mset f A)" by blast + then have " sum_mset (image_mset f (add_mset x A)) = sum_mset (image_mset f A) + f x" + by (simp add: add_commute) + then show ?case + by (simp add: add.IH add.prems) +qed + +lemma sum_order_add_mset: "(\ x . f x \ 0) \ (\ x \# A. f x ) \ (\ x \# add_mset a A. f x )" + by simp + +lemma sum_mset_0_left: "(\ x . f x \ 0) \ (\ x \# A. f x ) = 0 \ (\ x \# A .f x = 0)" + apply (induction A) + apply auto + using local.add_nonneg_eq_0_iff sum_mset_ge0 apply blast + by (metis local.antisym local.sum_mset.insert sum_mset_ge0 sum_order_add_mset) + +lemma sum_mset_0_iff_ge_0: + assumes "(\ x . f x \ 0)" + shows "(\ x \# A. f x ) = 0 \ (\ x \ set_mset A .f x = 0)" + using sum_mset_0_left assms by auto + +end + +lemma mset_set_size_card_count: "(\x \# A. x) = (\x \ set_mset A . x * (count A x))" +proof (induction A) + case empty + then show ?case by simp +next + case (add y A) + have lhs: "(\x\#add_mset y A. x) = (\x\# A. x) + y" by simp + have rhs: "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + (\x\(insert y (set_mset A)) . x * count (add_mset y A) x)" + by simp + then show ?case + proof (cases "y \# A") + case True + have x_val: "\ x . x \ (insert y (set_mset A)) \ x \ y \ + x* count (add_mset y A) x = x * (count A x)" + by auto + have y_count: "count (add_mset y A) y = 1 + count A y" + using True count_inI by fastforce + then have "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + (y * (count (add_mset y A) y)) + (\x\(set_mset A) - {y}. x * count A x)" + using x_val finite_set_mset sum.cong sum.insert rhs + by (smt DiffD1 Diff_insert_absorb insert_absorb mk_disjoint_insert sum.insert_remove) + then have s1: "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + y + y * (count A y) + (\x\(set_mset A) - {y}. x * count A x)" + using y_count by simp + then have "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + y + (\x\insert y ((set_mset A) - {y} ) . x * count A x)" + by (simp add: sum.insert_remove) + then have "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + y + (\x\(set_mset A) . x * count A x)" + by (simp add: True insert_absorb) + then show ?thesis using lhs add.IH + by linarith + next + case False + have x_val: "\ x . x \ set_mset A \ x* count (add_mset y A) x = x * (count A x)" + using False by auto + have y_count: "count (add_mset y A) y = 1" using False count_inI by fastforce + have lhs: "(\x\#add_mset y A. x) = (\x\# A. x) + y" by simp + have "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + (y * count (add_mset y A) y) + (\x\set_mset A. x * count A x)" + using x_val rhs by (metis (no_types, lifting) False finite_set_mset sum.cong sum.insert) + then have "(\x\set_mset (add_mset y A). x * count (add_mset y A) x) = + y + (\x\set_mset A. x * count A x)" + using y_count by simp + then show ?thesis using lhs add.IH by linarith + qed +qed + +subsection \Partitions on Multisets\ + +text \A partition on a multiset A is a multiset of multisets, where the sum over P equals A and the +empty multiset is not in the partition. Based off set partition definition. +We note that unlike set partitions, there is no requirement for elements in the multisets to be +distinct due to the definition of union on multisets \cite{benderPartitionsMultisets1974}\ + +lemma mset_size_partition_dep: "size {# a \# A . P a \ Q a #} = + size {# a \# A . P a #} + size {# a \# A . Q a #} - size {# a \# A . P a \ Q a #}" + by (simp add: mset_bunion_filter mset_inter_filter mset_union_size_inter) + +definition partition_on_mset :: "'a multiset \ 'a multiset multiset \ bool" where +"partition_on_mset A P \ \\<^sub>#P = A \ {#} \# P" + +lemma partition_on_msetI [intro]: "\\<^sub>#P = A \ {#} \# P \ partition_on_mset A P" + by (simp add: partition_on_mset_def) + +lemma partition_on_msetD1: "partition_on_mset A P \ \\<^sub>#P = A" + by (simp add: partition_on_mset_def) + +lemma partition_on_msetD2: "partition_on_mset A P \ {#} \# P" + by (simp add: partition_on_mset_def) + +lemma partition_on_mset_empty: "partition_on_mset {#} P \ P = {#}" + unfolding partition_on_mset_def + using multiset_nonemptyE by fastforce + +lemma partition_on_mset_all: "A \ {#} \ partition_on_mset A {#A #}" + by (simp add: partition_on_mset_def) + +lemma partition_on_mset_singletons: "partition_on_mset A (image_mset (\ x . {#x#}) A)" + by (auto simp: partition_on_mset_def) + +lemma partition_on_mset_not_empty: "A \ {#} \ partition_on_mset A P \ P \ {#}" + by (auto simp: partition_on_mset_def) + +lemma partition_on_msetI2: "\\<^sub>#P = A \ (\ p . p \# P \ p \ {#}) \ partition_on_mset A P" + by (auto simp: partition_on_mset_def) + +lemma partition_on_mset_elems: "partition_on_mset A P \ p1 \# P \ x \# p1 \ x \# A" + by (auto simp: partition_on_mset_def) + +lemma partition_on_mset_sum_size_eq: "partition_on_mset A P \ (\x \# P. size x) = size A" + by (metis partition_on_msetD1 size_big_union_sum) + +lemma partition_on_mset_card: assumes "partition_on_mset A P" shows " size P \ size A" +proof (rule ccontr) + assume "\ size P \ size A" + then have a: "size P > size A" by simp + have "\ x . x \# P \ size x > 0" using partition_on_msetD2 + using assms nonempty_has_size by auto + then have " (\x \# P. size x) \ size P" + by (metis leI less_one not_less_zero size_eq_sum_mset sum_mset_mono) + thus False using a partition_on_mset_sum_size_eq + using assms by fastforce +qed + +lemma partition_on_mset_count_eq: "partition_on_mset A P \ a \# A \ + (\x \# P. count x a) = count A a" + by (metis count_sum_mset partition_on_msetD1) + +lemma partition_on_mset_subsets: "partition_on_mset A P \ x \# P \ x \# A" + by (auto simp add: partition_on_mset_def) + +lemma partition_on_mset_distinct: + assumes "partition_on_mset A P" + assumes "distinct_mset A" + shows "distinct_mset P" +proof (rule ccontr) + assume "\ distinct_mset P" + then obtain p1 where count: "count P p1 \ 2" + by (metis Suc_1 distinct_mset_count_less_1 less_Suc_eq_le not_less_eq) + then have cge: "\ x . x \# p1 \ (\p \# P. count p x ) \ 2" + by (smt count_greater_eq_one_iff count_sum_mset_if_1_0 dual_order.trans sum_mset_mono zero_le) + have elem_in: "\ x . x \# p1 \ x \# A" using partition_on_mset_elems + by (metis count assms(1) count_eq_zero_iff not_numeral_le_zero) + have "\ x . x \# A \ count A x = 1" using assms + by (simp add: distinct_mset_def) + thus False + using assms partition_on_mset_count_eq cge elem_in count_inI local.count multiset_nonemptyE + by (metis (mono_tags) not_numeral_le_zero numeral_One numeral_le_iff partition_on_mset_def semiring_norm(69)) +qed + +lemma partition_on_mset_distinct_disjoint: + assumes "partition_on_mset A P" + assumes "distinct_mset A" + assumes "p1 \# P" + assumes "p2 \# P - {#p1#}" + shows "p1 \# p2 = {#}" + using Diff_eq_empty_iff_mset assms diff_add_zero distinct_mset_add multiset_inter_assoc sum_mset.remove + by (smt partition_on_msetD1 subset_mset.inf.absorb_iff2 subset_mset.le_add_same_cancel1 subset_mset.le_iff_inf) + +lemma partition_on_mset_diff: + assumes "partition_on_mset A P" + assumes "Q \#P" + shows "partition_on_mset (A - \\<^sub>#Q) (P - Q)" + using assms partition_on_mset_def + by (smt diff_union_cancelL subset_mset.add_diff_inverse sum_mset.union union_iff) + +lemma sigma_over_set_partition_count: + assumes "finite A" + assumes "partition_on A P" + assumes "x \# \\<^sub># (mset_set (mset_set ` P))" + shows "count (\\<^sub># (mset_set (mset_set ` P))) x = 1" +proof - + have disj: "disjoint P" using assms partition_onD2 by auto + then obtain p where pin: "p \# mset_set (mset_set ` P)" and xin: "x \# p" + using assms by blast + then have "count (mset_set (mset_set ` P)) p = 1" + by (meson count_eq_zero_iff count_mset_set') + then have filter: "\ p' . p' \# ((mset_set (mset_set` P)) - {#p#}) \ p \ p'" + using count_eq_zero_iff count_single by fastforce + have zero: "\ p'. p' \# mset_set (mset_set ` P) \ p' \ p \ count p' x = 0" + proof (rule ccontr) + fix p' + assume assm: "p' \# mset_set (mset_set ` P)" and ne: "p' \ p" and n0: "count p' x \ 0" + then have xin2: "x \# p'" by auto + obtain p1 p2 where p1in: "p1 \ P" and p2in: "p2 \ P" and p1eq: "mset_set p1 = p" + and p2eq: "mset_set p2 = p'" using assm assms(1) assms(2) pin + by (metis (no_types, lifting) elem_mset_set finite_elements finite_imageI image_iff) + have origne: "p1 \ p2" using ne p1eq p2eq by auto + have "p1 = p2" using partition_onD4 xin xin2 + by (metis assms(2) count_eq_zero_iff count_mset_set' p1eq p1in p2eq p2in) + then show False using origne by simp + qed + have one: "count p x = 1" using pin xin assms count_eq_zero_iff count_greater_eq_one_iff + by (metis count_mset_set(3) count_mset_set_le_one image_iff le_antisym) + then have "count (\\<^sub># (mset_set (mset_set ` P))) x = + (\p' \# (mset_set (mset_set ` P)) . count p' x)" + using count_sum_mset by auto + also have "... = (count p x) + (\p' \# ((mset_set (mset_set ` P)) - {#p#}) . count p' x)" + by (metis (mono_tags, lifting) insert_DiffM pin sum_mset.insert) + also have "... = 1 + (\p' \# ((mset_set (mset_set ` P)) - {#p#}) . count p' x)" + using one by presburger + finally have "count (\\<^sub># (mset_set (mset_set ` P))) x = + 1 + (\p' \# ((mset_set (mset_set ` P)) - {#p#}) . 0)" + using zero filter by (metis (mono_tags, lifting) in_diffD sum_over_fun_eq) + then show "count (\\<^sub># (mset_set (mset_set ` P))) x = 1" by simp +qed + +lemma partition_on_mset_set: + assumes "finite A" + assumes "partition_on A P" + shows "partition_on_mset (mset_set A) (mset_set (image (\ x. mset_set x) P))" +proof (intro partition_on_msetI) + have partd1: "\P = A" using assms partition_onD1 by auto + have imp: "\x. x \# \\<^sub># (mset_set (mset_set ` P)) \ x \# mset_set A" + proof - + fix x + assume "x \# \\<^sub># (mset_set (mset_set ` P))" + then obtain p where "p \ (mset_set ` P)" and xin: "x \# p" + by (metis elem_mset_set equals0D infinite_set_mset_mset_set mset_big_union_obtain) + then have "set_mset p \ P" + by (metis empty_iff finite_set_mset_mset_set image_iff infinite_set_mset_mset_set) + then show "x \# mset_set A" + using partd1 xin assms(1) by auto + qed + have imp2: "\x . x \# mset_set A \ x \# \\<^sub># (mset_set (mset_set ` P))" + proof - + fix x + assume "x \# mset_set A" + then have "x \ A" by (simp add: assms(1)) + then obtain p where "p \ P" and "x \ p" using assms(2) using partd1 by blast + then obtain p' where "p' \ (mset_set ` P)" and "p' = mset_set p" by blast + thus "x \# \\<^sub># (mset_set (mset_set ` P))" using assms \p \ P\ \x \ p\ finite_elements partd1 + by (metis Sup_upper finite_imageI finite_set_mset_mset_set in_Union_mset_iff rev_finite_subset) + qed + have a1: "\ x . x \# mset_set A \ count (mset_set A) x = 1" + using assms(1) by fastforce + then show "\\<^sub># (mset_set (mset_set ` P)) = mset_set A" using imp imp2 a1 + by (metis assms(1) assms(2) count_eq_zero_iff multiset_eqI sigma_over_set_partition_count) + have "\ p. p \ P \ p \ {} " using assms partition_onD3 by auto + then have "\ p. p \ P \ mset_set p \ {#}" using mset_set_empty_iff + by (metis Union_upper assms(1) partd1 rev_finite_subset) + then show "{#} \# mset_set (mset_set ` P)" + by (metis elem_mset_set equals0D image_iff infinite_set_mset_mset_set) +qed + +lemma partition_on_mset_distinct_inter: + assumes "partition_on_mset A P" + assumes "distinct_mset A" + assumes "p1 \# P" and "p2 \# P" and "p1 \ p2" + shows "p1 \# p2 = {#}" + by (metis assms in_remove1_mset_neq partition_on_mset_distinct_disjoint) + +lemma partition_on_set_mset_distinct: + assumes "partition_on_mset A P" + assumes "distinct_mset A" + assumes "p \# image_mset set_mset P" + assumes "p' \# image_mset set_mset P" + assumes "p \ p'" + shows "p \ p' = {}" +proof - + obtain p1 where p1in: "p1 \# P" and p1eq: "set_mset p1 = p" using assms(3) + by blast + obtain p2 where p2in: "p2 \# P" and p2eq: "set_mset p2 = p'" using assms(4) by blast + have "distinct_mset P" using assms partition_on_mset_distinct by blast + then have "p1 \ p2" using assms using p1eq p2eq by fastforce + then have "p1 \# p2 = {#}" using partition_on_mset_distinct_inter + using assms(1) assms(2) p1in p2in by auto + thus ?thesis using p1eq p2eq + by (metis set_mset_empty set_mset_inter) +qed + +lemma partition_on_set_mset: + assumes "partition_on_mset A P" + assumes "distinct_mset A" + shows "partition_on (set_mset A) (set_mset (image_mset set_mset P))" +proof (intro partition_onI) + show "\p. p \# image_mset set_mset P \ p \ {}" + using assms(1) partition_on_msetD2 by fastforce +next + have "\ x . x \ set_mset A \ x \ \ (set_mset (image_mset set_mset P))" + by (metis Union_iff assms(1) image_eqI mset_big_union_obtain partition_on_msetD1 set_image_mset) + then show "\ (set_mset (image_mset set_mset P)) = set_mset A" + using set_eqI' partition_on_mset_elems assms by auto + show "\p p'. p \# image_mset set_mset P \ p' \# image_mset set_mset P \ + p \ p' \ p \ p' = {}" + using partition_on_set_mset_distinct assms by fastforce +qed + +lemma partition_on_mset_eq_imp_eq_carrier: + assumes "partition_on_mset A P" + assumes "partition_on_mset B P" + shows "A = B" + using assms partition_on_msetD1 by auto + +lemma partition_on_mset_add_single: + assumes "partition_on_mset A P" + shows "partition_on_mset (add_mset a A) (add_mset {#a#} P)" + using assms by (auto simp: partition_on_mset_def) + +lemma partition_on_mset_add_part: + assumes "partition_on_mset A P" + assumes "X \ {#}" + assumes "A + X = A'" + shows "partition_on_mset A' (add_mset X P)" + using assms by (auto simp: partition_on_mset_def) + +lemma partition_on_mset_add: + assumes "partition_on_mset A P" + assumes "X \# P" + assumes "add_mset a X = X'" + shows "partition_on_mset (add_mset a A) (add_mset X' (P - {#X#}))" + using add_mset_add_single assms empty_not_add_mset mset_subset_eq_single partition_on_mset_all + by (smt partition_on_mset_def subset_mset.add_diff_inverse sum_mset.add_mset sum_mset.remove union_iff union_mset_add_mset_left) + +lemma partition_on_mset_elem_exists_part: + assumes "partition_on_mset A P" + assumes "x \# A" + obtains p where "p \# P" and "x \# p" + using assms in_Union_mset_iff partition_on_msetD2 partition_on_msetI + by (metis partition_on_mset_eq_imp_eq_carrier) + +lemma partition_on_mset_combine: + assumes "partition_on_mset A P" + assumes "partition_on_mset B Q" + shows "partition_on_mset (A + B) (P + Q)" + unfolding partition_on_mset_def + using assms partition_on_msetD1 partition_on_msetD2 by auto + +lemma partition_on_mset_split: + assumes "partition_on_mset A (P + Q)" + shows "partition_on_mset (\\<^sub>#P) P" + using partition_on_mset_def partition_on_msetD2 assms by fastforce +end \ No newline at end of file diff --git a/thys/Design_Theory/ROOT b/thys/Design_Theory/ROOT new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/ROOT @@ -0,0 +1,13 @@ +chapter AFP + +session Design_Theory (AFP) = "HOL-Library" + + options [timeout = 600] + sessions + Card_Partitions + Nested_Multisets_Ordinals + Graph_Theory + theories + Design_Theory_Root + document_files + "root.bib" + "root.tex" diff --git a/thys/Design_Theory/Resolvable_Designs.thy b/thys/Design_Theory/Resolvable_Designs.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Resolvable_Designs.thy @@ -0,0 +1,204 @@ +(* Title: Resolvable_Designs.thy + Author: Chelsea Edmonds +*) + +section \Resolvable Designs\ +text \Resolvable designs have further structure, and can be "resolved" into a set of resolution +classes. A resolution class is a subset of blocks which exactly partitions the point set. +Definitions based off the handbook \cite{colbournHandbookCombinatorialDesigns2007} + and Stinson \cite{stinsonCombinatorialDesignsConstructions2004}. +This theory includes a proof of an alternate statement of Bose's theorem\ + +theory Resolvable_Designs imports BIBD +begin + +subsection \Resolutions and Resolution Classes\ +text \A resolution class is a partition of the point set using a set of blocks from the design +A resolution is a group of resolution classes partitioning the block collection\ + +context incidence_system +begin + +definition resolution_class :: "'a set set \ bool" where +"resolution_class S \ partition_on \ S \ (\ bl \ S . bl \# \)" + +lemma resolution_classI [intro]: "partition_on \ S \ (\ bl . bl \ S \ bl \# \) + \ resolution_class S" + by (simp add: resolution_class_def) + +lemma resolution_classD1: "resolution_class S \ partition_on \ S" + by (simp add: resolution_class_def) + +lemma resolution_classD2: "resolution_class S \ bl \ S \ bl \# \" + by (simp add: resolution_class_def) + +lemma resolution_class_empty_iff: "resolution_class {} \ \ = {}" + by (auto simp add: resolution_class_def partition_on_def) + +lemma resolution_class_complete: "\ \ {} \ \ \# \ \ resolution_class {\}" + by (auto simp add: resolution_class_def partition_on_space) + +lemma resolution_class_union: "resolution_class S \ \S = \ " + by (simp add: resolution_class_def partition_on_def) + +lemma (in finite_incidence_system) resolution_class_finite: "resolution_class S \ finite S" + using finite_elements finite_sets by (auto simp add: resolution_class_def) + +lemma (in design) resolution_class_sum_card: "resolution_class S \ (\bl \ S . card bl) = \" + using resolution_class_union finite_blocks + by (auto simp add: resolution_class_def partition_on_def card_Union_disjoint) + +definition resolution:: "'a set multiset multiset \ bool" where +"resolution P \ partition_on_mset \ P \ (\ S \# P . distinct_mset S \ resolution_class (set_mset S))" + +lemma resolutionI : "partition_on_mset \ P \ (\ S . S \#P \ distinct_mset S) \ + (\ S . S\# P \ resolution_class (set_mset S)) \ resolution P" + by (simp add: resolution_def) + +lemma (in proper_design) resolution_blocks: "distinct_mset \ \ disjoint (set_mset \) \ + \(set_mset \) = \ \ resolution {#\#}" + unfolding resolution_def resolution_class_def partition_on_mset_def partition_on_def + using design_blocks_nempty blocks_nempty by auto + +end + +subsection \Resolvable Design Locale\ +text \A resolvable design is one with a resolution P\ +locale resolvable_design = design + + fixes partition :: "'a set multiset multiset" ("\

") + assumes resolvable: "resolution \

" +begin + +lemma resolutionD1: "partition_on_mset \ \

" + using resolvable by (simp add: resolution_def) + +lemma resolutionD2: "S \#\

\ distinct_mset S" + using resolvable by (simp add: resolution_def) + +lemma resolutionD3: " S\# \

\ resolution_class (set_mset S)" + using resolvable by (simp add: resolution_def) + +lemma resolution_class_blocks_disjoint: "S \# \

\ disjoint (set_mset S)" + using resolutionD3 by (simp add: partition_on_def resolution_class_def) + +lemma resolution_not_empty: "\ \ {#} \ \

\ {#}" + using partition_on_mset_not_empty resolutionD1 by auto + +lemma resolution_blocks_subset: "S \# \

\ S \# \" + using partition_on_mset_subsets resolutionD1 by auto + +end + +lemma (in incidence_system) resolvable_designI [intro]: "resolution \

\ design \ \ \ + resolvable_design \ \ \

" + by (simp add: resolvable_design.intro resolvable_design_axioms.intro) + +subsection \Resolvable Block Designs\ +text \An RBIBD is a resolvable BIBD - a common subclass of interest for block designs\ +locale r_block_design = resolvable_design + block_design +begin +lemma resolution_class_blocks_constant_size: "S \# \

\ bl \# S \ card bl = \" + by (metis resolutionD3 resolution_classD2 uniform_alt_def_all) + +lemma resolution_class_size1: + assumes "S \# \

" + shows "\ = \ * size S" +proof - + have "(\bl \# S . card bl) = (\bl \ (set_mset S) . card bl)" using resolutionD2 assms + by (simp add: sum_unfold_sum_mset) + then have eqv: "(\bl \# S . card bl) = \" using resolutionD3 assms resolution_class_sum_card + by presburger + have "(\bl \# S . card bl) = (\bl \# S . \)" using resolution_class_blocks_constant_size assms + by auto + thus ?thesis using eqv by (metis mult.commute sum_mset_constant) +qed + +lemma resolution_class_size2: + assumes "S \# \

" + shows "size S = \ div \" + using resolution_class_size1 assms + by (metis nonzero_mult_div_cancel_left not_one_le_zero k_non_zero) + +lemma resolvable_necessary_cond_v: "\ dvd \" +proof - + obtain S where s_in: "S \#\

" using resolution_not_empty design_blocks_nempty by blast + then have "\ * size S = \" using resolution_class_size1 by simp + thus ?thesis by (metis dvd_triv_left) +qed + +end + +locale rbibd = r_block_design + bibd + +begin + +lemma resolvable_design_num_res_classes: "size \

= \" +proof - + have k_ne0: "\ \ 0" using k_non_zero by auto + have f1: "\ = (\S \# \

. size S)" + by (metis partition_on_msetD1 resolutionD1 size_big_union_sum) + then have "\ = (\S \# \

. \ div \)" using resolution_class_size2 f1 by auto + then have f2: "\ = (size \

) * (\ div \)" by simp + then have "size \

= \ div (\ div \)" + using b_non_zero by auto + then have "size \

= (\ * \) div \" using f2 resolvable_necessary_cond_v + by (metis div_div_div_same div_dvd_div dvd_triv_right k_ne0 nonzero_mult_div_cancel_right) + thus ?thesis using necessary_condition_two + by (metis nonzero_mult_div_cancel_left not_one_less_zero t_design_min_v) +qed + +lemma resolvable_necessary_cond_b: "\ dvd \" +proof - + have f1: "\ = (\S \# \

. size S)" + by (metis partition_on_msetD1 resolutionD1 size_big_union_sum) + then have "\ = (\S \# \

. \ div \)" using resolution_class_size2 f1 by auto + thus ?thesis using resolvable_design_num_res_classes by simp +qed + +subsubsection \Bose's Inequality\ +text \Boses inequality is an important theorem on RBIBD's. This is a proof +of an alternate statement of the thm, which does not require a linear algebraic approach, +taken directly from Stinson \cite{stinsonCombinatorialDesignsConstructions2004}\ +theorem bose_inequality_alternate: "\ \ \ + \ - 1 \ \ \ \ + \" +proof - + have kdvd: "\ dvd (\ * (\ - \))" + using necessary_condition_two by (simp add: right_diff_distrib') + have v_eq: "\ = (\ * (\ - 1) + \ ) div \" + using necessary_condition_one index_not_zero by auto + have ldvd: " \ x. \ dvd (x * (\ * (\ - 1) + \))" + using necessary_condition_one by auto + have "(\ \ \ + \ - 1) \ ((\ * \) div \ \ \ + \ - 1)" + using necessary_condition_two k_non_zero by auto + also have "... \ (((\ * \) - (\ * \)) div \ \ \ - 1)" + using k_non_zero div_mult_self3 k_non_zero necessary_condition_two by auto + also have f2: " ... \ ((\ * ( \ - \)) \ \ * ( \ - 1))" + using k_non_zero kdvd by (auto simp add: int_distrib(3) mult_of_nat_commute) + also have "... \ ((((\ * (\ - 1) + \ ) div \) * (\ - \)) \ \ * (\ - 1))" + using v_eq by presburger + also have "... \ ( (\ - \) * ((\ * (\ - 1) + \ ) div \) \ (\ * (\ - 1)))" + by (simp add: mult.commute) + also have " ... \ ( ((\ - \) * (\ * (\ - 1) + \ )) div \ \ (\ * (\ - 1)))" + by (metis div_mult_swap dvd_add_triv_right_iff dvd_triv_left necessary_condition_one) + also have " ... \ (((\ - \) * (\ * (\ - 1) + \ )) \ \ * (\ * (\ - 1)))" + using ldvd by (smt dvd_mult_div_cancel index_not_zero mult_strict_left_mono) + also have "... \ (((\ - \) * (\ * (\ - 1))) + ((\ - \) * \ ) \ \ * (\ * (\ - 1)))" + by (simp add: distrib_left) + also have "... \ (((\ - \) * \ * (\ - 1)) \ \ * \ * (\ - 1) - ((\ - \) * \ ))" + using mult.assoc by linarith + also have "... \ (((\ - \) * \ * (\ - 1)) \ (\ * \ * \) - (\ * \) - ((\ * \) -(\ * \ )))" + using distrib_right by (simp add: distrib_left right_diff_distrib' left_diff_distrib') + also have "... \ (((\ - \) * \ * (\ - 1)) \ (\ * \ * \) - ( \ * \))" + by (simp add: mult.commute) + also have "... \ (((\ - \) * \ * (\ - 1)) \ (\ * (\ * \)) - ( \ * \))" + by linarith + also have "... \ (((\ - \) * \ * (\ - 1)) \ (\ * (\ * \)) - ( \ * \))" + by (simp add: mult.commute) + also have "... \ (((\ - \) * \ * (\ - 1)) \ \ * \ * ( \ - 1))" + by (simp add: mult.assoc int_distrib(4)) + finally have "(\ \ \ + \ - 1) \ (\ \ \ + \)" + using index_lt_replication mult_right_le_imp_le r_gzero + by (smt mult_cancel_right k_non_zero) + thus ?thesis by simp +qed +end +end \ No newline at end of file diff --git a/thys/Design_Theory/Sub_Designs.thy b/thys/Design_Theory/Sub_Designs.thy new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/Sub_Designs.thy @@ -0,0 +1,202 @@ +(* Title: Sub_Designs.thy + Author: Chelsea Edmonds +*) + +section \Sub-designs\ +text \Sub designs are a relationship between two designs using the subset and submultiset relations +This theory defines the concept at the incidence system level, before extending to defining on +well defined designs\ + +theory Sub_Designs imports Design_Operations +begin + +subsection \Sub-system and Sub-design Locales\ +locale sub_set_system = incidence_system \ \ + for "\" and "\" and "\" and "\" + + assumes points_subset: "\ \ \" + assumes blocks_subset: "\ \# \" +begin + +lemma sub_points: "x \ \ \ x \ \" + using points_subset by auto + +lemma sub_blocks: "bl \# \ \ bl \# \" + using blocks_subset by auto + +lemma sub_blocks_count: "count \ b \ count \ b" + by (simp add: mset_subset_eq_count blocks_subset) + +end + +locale sub_incidence_system = sub_set_system + ins: incidence_system \ \ + +locale sub_design = sub_incidence_system + des: design \ \ +begin + +lemma sub_non_empty_blocks: "A \# \ \ A \ {}" + using des.blocks_nempty sub_blocks by simp + +sublocale sub_des: design \ \ + using des.finite_sets finite_subset points_subset sub_non_empty_blocks + by (unfold_locales) (auto) + +end + +locale proper_sub_set_system = incidence_system \ \ + for "\" and "\" and "\" and "\" + + assumes points_psubset: "\ \ \" + assumes blocks_subset: "\ \# \" +begin + +lemma point_sets_ne: "\ \ \" + using points_psubset by auto + +end + +sublocale proper_sub_set_system \ sub_set_system + using points_psubset blocks_subset by (unfold_locales) simp_all + +context sub_set_system +begin + +lemma sub_is_proper: "\ \ \ \ proper_sub_set_system \ \ \ \" + using blocks_subset incidence_system_axioms + by (simp add: points_subset proper_sub_set_system.intro proper_sub_set_system_axioms_def psubsetI) + +end + +locale proper_sub_incidence_system = proper_sub_set_system + ins: incidence_system \ \ + +sublocale proper_sub_incidence_system \ sub_incidence_system + by (unfold_locales) + +context sub_incidence_system +begin +lemma sub_is_proper: "\ \ \ \ proper_sub_incidence_system \ \ \ \" + by (simp add: ins.incidence_system_axioms proper_sub_incidence_system_def sub_is_proper) + +end + +locale proper_sub_design = proper_sub_incidence_system + des: design \ \ + +sublocale proper_sub_design \ sub_design + by (unfold_locales) + +context sub_design +begin +lemma sub_is_proper: "\ \ \ \ proper_sub_design \ \ \ \" + by (simp add: des.wf_design proper_sub_design.intro sub_is_proper) + +end + +lemma ss_proper_implies_sub [intro]: "proper_sub_set_system \ \ \ \ \ sub_set_system \ \ \ \" + using proper_sub_set_system.axioms(1) proper_sub_set_system.blocks_subset psubsetE + by (metis proper_sub_set_system.points_psubset sub_set_system.intro sub_set_system_axioms_def) + +lemma sub_ssI [intro!]: "incidence_system \ \ \ \ \ \ \ \ \# \ \ sub_set_system \ \ \ \" + using incidence_system_def subset_iff + by (unfold_locales) (simp_all add: incidence_system.wellformed) + +lemma sub_ss_equality: + assumes "sub_set_system \ \ \ \" + and "sub_set_system \ \ \ \" + shows "\ = \" and "\ = \" + using assms(1) assms(2) sub_set_system.points_subset apply blast + by (meson assms(1) assms(2) sub_set_system.blocks_subset subset_mset.eq_iff) + +subsection \Reasoning on Sub-designs\ + +subsubsection \Reasoning on Incidence Sys property relationships\ + +context sub_incidence_system +begin + +lemma sub_sys_block_sizes: "ins.sys_block_sizes \ sys_block_sizes" + by (auto simp add: sys_block_sizes_def ins.sys_block_sizes_def blocks_subset sub_blocks) + +lemma sub_point_rep_number_le: "x \ \ \ \ rep x \ \ rep x" + by (simp add: point_replication_number_def blocks_subset multiset_filter_mono size_mset_mono) + +lemma sub_point_index_le: "ps \ \ \ \ index ps \ \ index ps" + by (simp add: points_index_def blocks_subset multiset_filter_mono size_mset_mono) + +lemma sub_sys_intersection_numbers: "ins.intersection_numbers \ intersection_numbers" + apply (auto simp add: intersection_numbers_def ins.intersection_numbers_def) + by (metis blocks_subset insert_DiffM insert_subset_eq_iff) + +end + +subsubsection \Reasoning on Incidence Sys/Design operations\ +context incidence_system +begin + +lemma sub_set_sysI[intro]: "\ \ \ \ \ \# \ \ sub_set_system \ \ \ \" + by (simp add: sub_ssI incidence_system_axioms) + +lemma sub_inc_sysI[intro]: "incidence_system \ \ \ \ \ \ \ \ \# \ \ + sub_incidence_system \ \ \ \" + by (simp add: sub_incidence_system.intro sub_set_sysI) + +lemma multiple_orig_sub_system: + assumes "n > 0" + shows "sub_incidence_system \ \ \ (multiple_blocks n)" + using multiple_block_in_original wellformed multiple_blocks_sub assms + by (unfold_locales) simp_all + +lemma add_point_sub_sys: "sub_incidence_system \ \ (add_point p) \" + using add_point_wf add_point_def + by (simp add: sub_ssI subset_insertI incidence_system_axioms sub_incidence_system.intro) + +lemma strong_del_point_sub_sys: "sub_incidence_system (del_point p) (str_del_point_blocks p) \ \ " + using strong_del_point_incidence_wf wf_invalid_point del_point_def str_del_point_blocks_def + by (unfold_locales) (auto) + +lemma add_block_sub_sys: "sub_incidence_system \ \ (\ \ b) (add_block b)" + using add_block_wf wf_invalid_point add_block_def by (unfold_locales) (auto) + +lemma delete_block_sub_sys: "sub_incidence_system \ (del_block b) \ \ " + using delete_block_wf delete_block_subset incidence_system_def by (unfold_locales, auto) + +end + +lemma (in two_set_systems) combine_sub_sys: "sub_incidence_system \ \ \\<^sup>+ \\<^sup>+" + by (unfold_locales) (simp_all) + +lemma (in two_set_systems) combine_sub_sys_alt: "sub_incidence_system \' \' \\<^sup>+ \\<^sup>+" + by (unfold_locales) (simp_all) + +context design +begin + +lemma sub_designI [intro]: "design \ \ \ sub_incidence_system \ \ \ \ \ sub_design \ \ \ \" + by (simp add: sub_design.intro wf_design) + +lemma sub_designII [intro]: "design \ \ \ sub_incidence_system \ \ \ \ \ sub_design \ \ \ \" + by (simp add: sub_design_def) + +lemma multiple_orig_sub_des: + assumes "n > 0" + shows "sub_design \ \ \ (multiple_blocks n)" + using multiple_is_design assms multiple_orig_sub_system by (simp add: sub_design.intro) + +lemma add_point_sub_des: "sub_design \ \ (add_point p) \" + using add_point_design add_point_sub_sys sub_design.intro by fastforce + +lemma strong_del_point_sub_des: "sub_design (del_point p) (str_del_point_blocks p) \ \ " + using strong_del_point_sub_sys sub_design.intro wf_design by blast + +lemma add_block_sub_des: "finite b \ b \ {} \ sub_design \ \ (\ \ b) (add_block b)" + using add_block_sub_sys add_block_design sub_designII by fastforce + +lemma delete_block_sub_des: "sub_design \ (del_block b) \ \ " + using delete_block_design delete_block_sub_sys sub_designI by auto + +end + +lemma (in two_designs) combine_sub_des: "sub_design \ \ \\<^sup>+ \\<^sup>+" + by (unfold_locales) (simp_all) + +lemma (in two_designs) combine_sub_des_alt: "sub_design \' \' \\<^sup>+ \\<^sup>+" + by (unfold_locales) (simp_all) + +end \ No newline at end of file diff --git a/thys/Design_Theory/document/root.bib b/thys/Design_Theory/document/root.bib new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/document/root.bib @@ -0,0 +1,96 @@ +@book{bergeHypergraphsCombinatoricsFinite1989, + address = {{Amsterdam ; New York}}, + author = {Berge, Claude}, + file = {C\:\\Users\\cledm\\Zotero\\storage\\QD8ZYCD5\\Berge - 1989 - Hypergraphs combinatorics of finite sets.pdf}, + isbn = {978-0-444-87489-4}, + keywords = {Hypergraphs}, + language = {en}, + lccn = {QA166.23 .B4813 1989}, + number = {v. 45}, + publisher = {{North Holland : Distributors for the U.S.A. and Canada, Elsevier Science Pub. Co}}, + series = {North-{{Holland}} Mathematical Library}, + shorttitle = {Hypergraphs}, + title = {Hypergraphs: Combinatorics of Finite Sets}, + year = {1989}} + +@book{cameronCombinatoricsTopicsTechniques1994, + abstract = {Cambridge Core - Algorithmics, Complexity, Computer Algebra, Computational Geometry - Combinatorics - by Peter J. Cameron}, + address = {{Cambridge}}, + author = {Cameron, Peter J.}, + file = {C\:\\Users\\cledm\\Zotero\\storage\\V9GWRW39\\951A2163C96B61B09140F054E021A9FE.html}, + isbn = {978-0-521-45133-8 978-0-511-80388-8 978-0-521-45761-3}, + language = {en}, + month = oct, + note = {\url{/core/books/combinatorics/951A2163C96B61B09140F054E021A9FE}}, + publisher = {{Cambridge University Press}}, + shorttitle = {Combinatorics}, + title = {Combinatorics: {{Topics}}, {{Techniques}}, {{Algorithms}}}, + year = {1994}} + +@book{colbournHandbookCombinatorialDesigns2007, + author = {Colbourn, C. J and Dinitz, Jeffrey H.}, + date-modified = {2021-03-22 15:57:21 +0000}, + edition = {2nd}, + file = {C\:\\Users\\cledm\\Zotero\\storage\\ALJQH3YJ\\C. J Colbourn_Dinitz_2007_Handbook of combinatorial designs - edited by Charles J.pdf}, + isbn = {978-1-58488-506-1}, + keywords = {Combinatorial designs and configurations}, + language = {eng}, + lccn = {QA166.25 .H363 2007}, + publisher = {{Chapman \& Hall/CRC}}, + title = {Handbook of Combinatorial Designs / Edited by {{Charles J}}. {{Colbourn}}, {{Jeffrey H}}. {{Dinitz}}.}, + year = {2007}} + +@book{stinsonCombinatorialDesignsConstructions2004, + abstract = {Created to teach students many of the most important techniques used for constructing combinatorial designs, this is an ideal textbook for advanced undergraduate and graduate courses in combinatorial design theory. The text features clear explanations of basic designs, such as Steiner and Kirkman triple systems, mutual orthogonal Latin squares, finite projective and affine planes, and Steiner quadruple systems. In these settings, the student will master various construction techniques, both classic and modern, and will be well-prepared to construct a vast array of combinatorial designs. Design theory offers a progressive approach to the subject, with carefully ordered results. It begins with simple constructions that gradually increase in complexity. Each design has a construction that contains new ideas or that reinforces and builds upon similar ideas previously introduced. A new text/reference covering all apsects of modern combinatorial design theory. Graduates and professionals in computer science, applied mathematics, combinatorics, and applied statistics will find the book an essential resource.}, + annotation = {https://www.springer.com/gp/book/9780387954875}, + author = {Stinson, Douglas}, + date-modified = {2021-03-22 16:11:11 +0000}, + file = {C\:\\Users\\cledm\\Zotero\\storage\\WN767Z98\\Stinson_2004_Combinatorial Designs.pdf;C\:\\Users\\cledm\\Zotero\\storage\\FYAWHUHN\\9780387954875.html}, + isbn = {978-0-387-95487-5}, + language = {en}, + publisher = {Springer}, + shorttitle = {Combinatorial {{Designs}}}, + title = {Combinatorial {{Designs}}: {{Constructions}} and {{Analysis}}}, + year = {2004}} + +@misc{HerkeLectureNotes2016, + author = {Sara Herke}, + title = {MATH3301 Lecture Notes in Combinatorial Design Theory}, + month = {July}, + year = {2016}, + publisher = {University of Queensland} + } + +@article{benderPartitionsMultisets1974, + title = {Partitions of Multisets}, + author = {Bender, Edward A.}, + year = {1974}, + month = oct, + volume = {9}, + pages = {301--311}, + issn = {0012-365X}, + abstract = {A multiset is a set with repeated elements. There are four distinct partition numbers to consider, unlike the classical set partition case which involves only Stirling numbers of the second kind. Using inclusion-exclusion, we obtain generating functions when each element appears exactly r = 1, 2 or 3 times. The case r = 1 is classical and r = 2 was studied by Comtet and Bar\'oti using other methods. Our approach also leads to asymptotic formulae for the total number of partitions of multisets in which the repetition of elements is bounded. Another approach to multiset enumeration, using de Brujin's theorem for group reduced distributions, is described.}, + file = {C\:\\Users\\cledm\\Zotero\\storage\\SX6S3Q7F\\Bender_1974_Partitions of multisets.pdf;C\:\\Users\\cledm\\Zotero\\storage\\XFY2MHK8\\0012365X74900764.html}, + journal = {Discrete Mathematics}, + language = {en}, + number = {4} +} + +@incollection{soicherDesignsGroupsComputing2013, + abstract = {In this chapter we present some applications of groups and computing to the discovery, construction, classification and analysis of combinatorial designs. The focus is on certain block designs and their statistical efficiency measures, and in particular semiLatin squares, which are certain designs with additional block structure and which generalise Latin squares.}, + annotation = {https://doi.org/10.1007/978-1-4471-4814-2\_3}, + author = {Soicher, Leonard H.}, + booktitle = {Probabilistic {{Group Theory}}, {{Combinatorics}}, and {{Computing}}}, + date-modified = {2021-03-22 16:15:23 +0000}, + editor = {Detinko, Alla and Flannery, Dane and O'Brien, Eamonn}, + file = {C\:\\Users\\cledm\\Zotero\\storage\\5FDDDZAL\\Soicher_2013_Designs, Groups and Computing.pdf}, + isbn = {978-1-4471-4814-2}, + keywords = {Canonical Efficiency Factors,Generalized Latin Square,Statistical Efficiency Measures,Subdesign,Subsquares}, + language = {en}, + pages = {83--107}, + publisher = {{Springer}}, + series = {Lecture {{Notes}} in {{Mathematics}} 2070}, + title = {Designs, {{Groups}} and {{Computing}}}, + year = {2013}} + + diff --git a/thys/Design_Theory/document/root.tex b/thys/Design_Theory/document/root.tex new file mode 100644 --- /dev/null +++ b/thys/Design_Theory/document/root.tex @@ -0,0 +1,30 @@ +\documentclass[11pt,a4paper]{article} +\usepackage{isabelle,isabellesym} + +% this should be the last package used +\usepackage{pdfsetup} + +% urls in roman style, theory text in math-similar italics +\urlstyle{rm} +\isabellestyle{it} + + +\begin{document} + +\title{Design Theory} +\author{Chelsea Edmonds and Lawrence Paulson} +\maketitle + +\begin{abstract} + Combinatorial design theory studies incidence set systems with certain balance and symmetry properties. It is closely related to hypergraph theory. This formalisation presents a general library for formal reasoning on incidence set systems, designs and their applications, including formal definitions and proofs for many key properties, operations, and theorems on the construction and existence of designs. Notably, this includes formalising t-designs, balanced incomplete block designs (BIBD), group divisible designs (GDD), pairwise balanced designs (PBD), design isomorphisms, and the relationship between graphs and designs. A locale-centric approach has been used to manage the relationships between the many different types of designs. Theorems of particular interest include the necessary conditions for existence of a BIBD, Wilson's construction on GDDs, and Bose's inequality on resolvable designs. This formalisation is partly presented in the paper "A Modular First Formalisation of Combinatorial Design Theory", presented at CICM 2021. +\end{abstract} + +\tableofcontents + +% include generated text of all theories +\input{session} + +\bibliographystyle{abbrv} +\bibliography{root} + +\end{document} diff --git a/thys/ROOTS b/thys/ROOTS --- a/thys/ROOTS +++ b/thys/ROOTS @@ -1,615 +1,618 @@ ADS_Functor AI_Planning_Languages_Semantics AODV AVL-Trees AWN Abortable_Linearizable_Modules Abs_Int_ITP2012 Abstract-Hoare-Logics Abstract-Rewriting Abstract_Completeness Abstract_Soundness Adaptive_State_Counting Affine_Arithmetic Aggregation_Algebras Akra_Bazzi Algebraic_Numbers Algebraic_VCs Allen_Calculus Amicable_Numbers Amortized_Complexity AnselmGod Applicative_Lifting Approximation_Algorithms Architectural_Design_Patterns Aristotles_Assertoric_Syllogistic Arith_Prog_Rel_Primes ArrowImpossibilityGS Attack_Trees Auto2_HOL Auto2_Imperative_HOL AutoFocus-Stream Automated_Stateful_Protocol_Verification Automatic_Refinement AxiomaticCategoryTheory BDD BD_Security_Compositional BNF_CC BNF_Operations BTree Banach_Steinhaus Bell_Numbers_Spivey BenOr_Kozen_Reif Berlekamp_Zassenhaus Bernoulli Bertrands_Postulate Bicategory BinarySearchTree Binding_Syntax_Theory Binomial-Heaps Binomial-Queues BirdKMP Blue_Eyes Bondy Boolean_Expression_Checkers Bounded_Deducibility_Security Buchi_Complementation Budan_Fourier Buffons_Needle Buildings BytecodeLogicJmlTypes C2KA_DistributedSystems CAVA_Automata CAVA_LTL_Modelchecker CCS CISC-Kernel CRDT CSP_RefTK CYK CakeML CakeML_Codegen Call_Arity Card_Equiv_Relations Card_Multisets Card_Number_Partitions Card_Partitions Cartan_FP Case_Labeling Catalan_Numbers Category Category2 Category3 Cauchy Cayley_Hamilton Certification_Monads Chandy_Lamport Chord_Segments Circus Clean ClockSynchInst Closest_Pair_Points CoCon CofGroups Coinductive Coinductive_Languages Collections Combinatorics_Words Combinatorics_Words_Graph_Lemma Combinatorics_Words_Lyndon Comparison_Sort_Lower_Bound Compiling-Exceptions-Correctly Complete_Non_Orders Completeness Complex_Geometry Complx ComponentDependencies ConcurrentGC ConcurrentIMP Concurrent_Ref_Alg Concurrent_Revisions Consensus_Refined Constructive_Cryptography Constructive_Cryptography_CM Constructor_Funs Containers CoreC++ Core_DOM Core_SC_DOM CoSMed CoSMeDis Count_Complex_Roots CryptHOL CryptoBasedCompositionalProperties +Cubic_Quartic_Equations DFS_Framework DOM_Components DPT-SAT-Solver DataRefinementIBP Datatype_Order_Generator Decl_Sem_Fun_PL Decreasing-Diagrams Decreasing-Diagrams-II Deep_Learning Delta_System_Lemma Density_Compiler Dependent_SIFUM_Refinement Dependent_SIFUM_Type_Systems Depth-First-Search Derangements Deriving Descartes_Sign_Rule +Design_Theory Dict_Construction Differential_Dynamic_Logic Differential_Game_Logic Dijkstra_Shortest_Path Diophantine_Eqns_Lin_Hom Dirichlet_L Dirichlet_Series DiscretePricing Discrete_Summation DiskPaxos DynamicArchitectures Dynamic_Tables E_Transcendental Echelon_Form EdmondsKarp_Maxflow Efficient-Mergesort Elliptic_Curves_Group_Law Encodability_Process_Calculi Epistemic_Logic Ergodic_Theory Error_Function Euler_MacLaurin Euler_Partition Example-Submission Extended_Finite_State_Machine_Inference Extended_Finite_State_Machines FFT FLP FOL-Fitting FOL_Harrison FOL_Seq_Calc1 Factored_Transition_System_Bounding Falling_Factorial_Sum Farkas FeatherweightJava Featherweight_OCL Fermat3_4 FileRefinement FinFun Finger-Trees Finite-Map-Extras Finite_Automata_HF Finitely_Generated_Abelian_Groups First_Order_Terms First_Welfare_Theorem Fishburn_Impossibility Fisher_Yates Flow_Networks Floyd_Warshall Flyspeck-Tame FocusStreamsCaseStudies Forcing Formal_Puiseux_Series Formal_SSA Formula_Derivatives Fourier Free-Boolean-Algebra Free-Groups Fresh_Identifiers FunWithFunctions FunWithTilings Functional-Automata Functional_Ordered_Resolution_Prover Furstenberg_Topology GPU_Kernel_PL Gabow_SCC GaleStewart_Games Game_Based_Crypto Gauss-Jordan-Elim-Fun Gauss_Jordan Gauss_Sums Gaussian_Integers GenClock General-Triangle Generalized_Counting_Sort Generic_Deriving Generic_Join GewirthPGCProof Girth_Chromatic GoedelGod Goedel_HFSet_Semantic Goedel_HFSet_Semanticless Goedel_Incompleteness Goodstein_Lambda GraphMarkingIBP Graph_Saturation Graph_Theory Green Groebner_Bases Groebner_Macaulay Gromov_Hyperbolicity Grothendieck_Schemes Group-Ring-Module HOL-CSP HOLCF-Prelude HRB-Slicing Heard_Of Hello_World HereditarilyFinite Hermite Hermite_Lindemann Hidden_Markov_Models Higher_Order_Terms Hoare_Time Hood_Melville_Queue HotelKeyCards Huffman Hybrid_Logic Hybrid_Multi_Lane_Spatial_Logic Hybrid_Systems_VCs HyperCTL IEEE_Floating_Point IFC_Tracking IMAP-CRDT IMO2019 IMP2 IMP2_Binary_Heap IMP_Compiler IP_Addresses Imperative_Insertion_Sort Impossible_Geometry Incompleteness Incredible_Proof_Machine Inductive_Confidentiality Inductive_Inference InfPathElimination InformationFlowSlicing InformationFlowSlicing_Inter Integration Interpreter_Optimizations Interval_Arithmetic_Word32 Iptables_Semantics Irrational_Series_Erdos_Straus Irrationality_J_Hancl IsaGeoCoq Isabelle_C Isabelle_Marries_Dirac Isabelle_Meta_Model Jacobson_Basic_Algebra Jinja JinjaDCI JinjaThreads JiveDataStoreModel Jordan_Hoelder Jordan_Normal_Form KAD KAT_and_DRA KBPs KD_Tree Key_Agreement_Strong_Adversaries Kleene_Algebra Knot_Theory Knuth_Bendix_Order Knuth_Morris_Pratt Koenigsberg_Friendship Kruskal Kuratowski_Closure_Complement LLL_Basis_Reduction LLL_Factorization LOFT LTL LTL_Master_Theorem LTL_Normal_Form LTL_to_DRA LTL_to_GBA Lam-ml-Normalization LambdaAuth LambdaMu Lambda_Free_EPO Lambda_Free_KBOs Lambda_Free_RPOs Lambert_W Landau_Symbols Laplace_Transform Latin_Square LatticeProperties Launchbury Laws_of_Large_Numbers Lazy-Lists-II Lazy_Case Lehmer Lifting_Definition_Option Lifting_the_Exponent LightweightJava LinearQuantifierElim Linear_Inequalities Linear_Programming Linear_Recurrences Liouville_Numbers List-Index List-Infinite List_Interleaving List_Inversions List_Update LocalLexing Localization_Ring Locally-Nameless-Sigma Lowe_Ontological_Argument Lower_Semicontinuous Lp Lucas_Theorem MFMC_Countable MFODL_Monitor_Optimized MFOTL_Monitor MSO_Regex_Equivalence Markov_Models Marriage Mason_Stothers Matrices_for_ODEs Matrix Matrix_Tensor Matroids Max-Card-Matching Median_Of_Medians_Selection Menger Mereology Mersenne_Primes Metalogic_ProofChecker MiniML MiniSail Minimal_SSA Minkowskis_Theorem Minsky_Machines Modal_Logics_for_NTS Modular_Assembly_Kit_Security Modular_arithmetic_LLL_and_HNF_algorithms Monad_Memo_DP Monad_Normalisation MonoBoolTranAlgebra MonoidalCategory Monomorphic_Monad MuchAdoAboutTwo Multi_Party_Computation Multirelations Myhill-Nerode Name_Carrying_Type_Inference Nash_Williams Nat-Interval-Logic Native_Word Nested_Multisets_Ordinals Network_Security_Policy_Verification Neumann_Morgenstern_Utility No_FTL_observers Nominal2 Noninterference_CSP Noninterference_Concurrent_Composition Noninterference_Generic_Unwinding Noninterference_Inductive_Unwinding Noninterference_Ipurge_Unwinding Noninterference_Sequential_Composition NormByEval Nullstellensatz Octonions OpSets Open_Induction Optics Optimal_BST Orbit_Stabiliser Order_Lattice_Props Ordered_Resolution_Prover Ordinal Ordinal_Partitions Ordinals_and_Cardinals Ordinary_Differential_Equations PAC_Checker PCF PLM POPLmark-deBruijn PSemigroupsConvolution Padic_Ints Pairing_Heap Paraconsistency Parity_Game Partial_Function_MR Partial_Order_Reduction Password_Authentication_Protocol Pell Perfect-Number-Thm Perron_Frobenius Physical_Quantities Pi_Calculus Pi_Transcendental Planarity_Certificates Poincare_Bendixson Poincare_Disc Polynomial_Factorization Polynomial_Interpolation Polynomials Pop_Refinement Posix-Lexing Possibilistic_Noninterference Power_Sum_Polynomials Pratt_Certificate Presburger-Automata Prim_Dijkstra_Simple Prime_Distribution_Elementary Prime_Harmonic_Series Prime_Number_Theorem Priority_Queue_Braun Priority_Search_Trees Probabilistic_Noninterference Probabilistic_Prime_Tests Probabilistic_System_Zoo Probabilistic_Timed_Automata Probabilistic_While Program-Conflict-Analysis Progress_Tracking Projective_Geometry Projective_Measurements Promela Proof_Strategy_Language PropResPI Propositional_Proof_Systems Prpu_Maxflow PseudoHoops Psi_Calculi Ptolemys_Theorem Public_Announcement_Logic QHLProver QR_Decomposition Quantales Quaternions Quick_Sort_Cost RIPEMD-160-SPARK ROBDD RSAPSS Ramsey-Infinite Random_BSTs Random_Graph_Subgraph_Threshold Randomised_BSTs Randomised_Social_Choice Rank_Nullity_Theorem Real_Impl Recursion-Addition Recursion-Theory-I Refine_Imperative_HOL Refine_Monadic RefinementReactive Regex_Equivalence Regression_Test_Selection Regular-Sets Regular_Algebras Relation_Algebra Relational-Incorrectness-Logic Relational_Disjoint_Set_Forests Relational_Forests Relational_Method Relational_Minimum_Spanning_Trees Relational_Paths Rep_Fin_Groups Residuated_Lattices Resolution_FOL Rewriting_Z Ribbon_Proofs Robbins-Conjecture Robinson_Arithmetic Root_Balanced_Tree Routing Roy_Floyd_Warshall SATSolverVerification SC_DOM_Components SDS_Impossibility SIFPL SIFUM_Type_Systems SPARCv8 Safe_Distance Safe_OCL Saturation_Framework Saturation_Framework_Extensions Secondary_Sylow Security_Protocol_Refinement Selection_Heap_Sort SenSocialChoice Separata Separation_Algebra Separation_Logic_Imperative_HOL SequentInvertibility Shadow_DOM Shadow_SC_DOM Shivers-CFA ShortestPath Show Sigma_Commit_Crypto Signature_Groebner Simpl Simple_Firewall Simplex Skew_Heap Skip_Lists Slicing Sliding_Window_Algorithm Smith_Normal_Form Smooth_Manifolds Sort_Encodings Source_Coding_Theorem SpecCheck Special_Function_Bounds Splay_Tree Sqrt_Babylonian Stable_Matching Statecharts Stateful_Protocol_Composition_and_Typing Stellar_Quorums Stern_Brocot Stewart_Apollonius Stirling_Formula Stochastic_Matrices Stone_Algebras Stone_Kleene_Relation_Algebras Stone_Relation_Algebras Store_Buffer_Reduction Stream-Fusion Stream_Fusion_Code Strong_Security Sturm_Sequences Sturm_Tarski Stuttering_Equivalence Subresultants Subset_Boolean_Algebras SumSquares Sunflowers SuperCalc Surprise_Paradox Symmetric_Polynomials Syntax_Independent_Logic Szpilrajn TESL_Language TLA Tail_Recursive_Functions Tarskis_Geometry Taylor_Models +Three_Circles Timed_Automata Topological_Semantics Topology TortoiseHare Transcendence_Series_Hancl_Rucki Transformer_Semantics Transition_Systems_and_Automata Transitive-Closure Transitive-Closure-II Treaps Tree-Automata Tree_Decomposition Triangle Trie Twelvefold_Way Tycon Types_Tableaus_and_Goedels_God UPF UPF_Firewall UTP Universal_Turing_Machine UpDown_Scheme Valuation Van_der_Waerden VectorSpace VeriComp Verified-Prover Verified_SAT_Based_AI_Planning VerifyThis2018 VerifyThis2019 Vickrey_Clarke_Groves VolpanoSmith WHATandWHERE_Security WOOT_Strong_Eventual_Consistency WebAssembly Weight_Balanced_Trees Well_Quasi_Orders Winding_Number_Eval Word_Lib WorkerWrapper XML ZFC_in_HOL Zeta_3_Irrational Zeta_Function pGCL diff --git a/thys/Three_Circles/Bernstein.thy b/thys/Three_Circles/Bernstein.thy new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/Bernstein.thy @@ -0,0 +1,406 @@ +section \Bernstein Polynomials over any finite interval\ + +theory Bernstein + imports "Bernstein_01" +begin + +subsection \Definition and relation to Bernstein Polynomials over [0, 1]\ + +definition Bernstein_Poly :: "nat \ nat \ real \ real \ real poly" where + "Bernstein_Poly j p c d = smult ((p choose j)/(d - c)^p) + (((monom 1 j) \\<^sub>p [:-c, 1:]) * (monom 1 (p-j) \\<^sub>p [:d, -1:]))" + +lemma Bernstein_Poly_altdef: + assumes "c \ d" and "j \ p" + shows "Bernstein_Poly j p c d = smult (p choose j) + ([:-c/(d-c), 1/(d-c):]^j * [:d/(d-c), -1/(d-c):]^(p-j))" + (is "?L = ?R") +proof - + have "?L = smult (p choose j) (smult ((1/(d - c))^j) + (smult ((1/(d - c))^(p-j)) ([:-c, 1:]^j * [:d, -1:]^(p-j))))" + using assms by (auto simp: Bernstein_Poly_def monom_altdef hom_distribs + pcompose_pCons smult_eq_iff field_simps power_add[symmetric]) + also have "... = ?R" + apply (subst mult_smult_right[symmetric]) + apply (subst mult_smult_left[symmetric]) + apply (subst smult_power) + apply (subst smult_power) + by auto + finally show ?thesis . +qed + +lemma Bernstein_Poly_nonneg: + assumes "c \ x" and "x \ d" + shows "poly (Bernstein_Poly j p c d) x \ 0" + using assms by (auto simp: Bernstein_Poly_def poly_pcompose poly_monom) + +lemma Bernstein_Poly_01: "Bernstein_Poly j p 0 1 = Bernstein_Poly_01 j p" + by (auto simp: Bernstein_Poly_def Bernstein_Poly_01_def monom_altdef) + +lemma Bernstein_Poly_rescale: + assumes "a \ b" + shows "Bernstein_Poly j p c d \\<^sub>p [:a, 1:] \\<^sub>p [:0, b-a:] + = Bernstein_Poly j p ((c-a)/(b-a)) ((d-a)/(b-a))" + (is "?L = ?R") +proof - + have "?R = smult (real (p choose j) + / ((d - a) / (b - a) - (c - a) / (b - a)) ^ p) + ([:- ((c - a) / (b - a)), 1:] ^ j + * [:(d - a) / (b - a), - 1:] ^ (p - j))" + by (auto simp: Bernstein_Poly_def monom_altdef hom_distribs + pcompose_pCons) + also have "... = smult (real (p choose j) / ((d - c) / (b - a)) ^ p) + ([:- ((c - a) / (b - a)), 1:] ^ j * [:(d - a) / (b - a), - 1:] + ^ (p - j))" + by argo + also have "... = smult (real (p choose j) / (d - c) ^ p) + (smult ((b - a) ^ (p - j)) (smult ((b - a) ^ j) + ([:- ((c - a) / (b - a)), 1:] ^ j * [:(d - a) / (b - a), - 1:] + ^ (p - j))))" + by (auto simp: power_add[symmetric] power_divide) + also have "... = smult (real (p choose j) / (d - c) ^ p) + ([:- (c - a), b - a:] ^ j * [:d - a, -(b - a):] ^ (p - j))" + apply (subst mult_smult_left[symmetric]) + apply (subst mult_smult_right[symmetric]) + using assms by (auto simp: smult_power) + also have "... = ?L" + using assms + by (auto simp: Bernstein_Poly_def monom_altdef pcompose_mult + pcompose_smult hom_distribs pcompose_pCons) + finally show ?thesis by presburger +qed + +lemma Bernstein_Poly_rescale_01: + assumes "c \ d" + shows "Bernstein_Poly j p c d \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:] + = Bernstein_Poly_01 j p" + apply (subst Bernstein_Poly_rescale) + using assms by (auto simp: Bernstein_Poly_01) + +lemma Bernstein_Poly_eq_rescale_01: + assumes "c \ d" + shows "Bernstein_Poly j p c d = Bernstein_Poly_01 j p + \\<^sub>p [:0, 1/(d-c):] \\<^sub>p [:-c, 1:]" + apply (subst Bernstein_Poly_rescale_01[symmetric]) + using assms by (auto simp: pcompose_pCons pcompose_assoc[symmetric]) + +lemma coeff_Bernstein_sum: + fixes b::"nat \ real" and p::nat and c d::real + defines "P \ (\j = 0..p. (smult (b j) (Bernstein_Poly j p c d)))" + assumes "i \ p" and "c \ d" + shows "coeff ((reciprocal_poly p (P \\<^sub>p [:c, 1:] + \\<^sub>p [:0, d-c:])) \\<^sub>p [:1, 1:]) (p - i) = (p choose i) * (b i)" +proof - + have h: "P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:] + = (\j = 0..p. (smult (b j) (Bernstein_Poly_01 j p)))" + using assms + by (auto simp: P_def pcompose_sum pcompose_smult + pcompose_add Bernstein_Poly_rescale_01) + then show ?thesis + using coeff_Bernstein_sum_01 assms by simp +qed + +lemma Bernstein_sum: + assumes "c \ d" and "degree P \ p" + shows "P = (\j = 0..p. smult (inverse (real (p choose j)) + * coeff (reciprocal_poly p (P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:]) + \\<^sub>p [:1, 1:]) (p-j)) (Bernstein_Poly j p c d))" + apply (subst Bernstein_Poly_eq_rescale_01) + subgoal using assms by blast + subgoal + apply (subst pcompose_smult[symmetric]) + apply (subst pcompose_sum[symmetric]) + apply (subst pcompose_smult[symmetric]) + apply (subst pcompose_sum[symmetric]) + apply (subst Bernstein_sum_01[symmetric]) + using assms by (auto simp: degree_pcompose pcompose_assoc[symmetric] + pcompose_pCons) + done + +lemma Bernstein_Poly_span1: + assumes "c \ d" and "degree P \ p" + shows "P \ poly_vs.span {Bernstein_Poly x p c d | x. x \ p}" +proof (subst Bernstein_sum[OF assms], rule poly_vs.span_sum) + fix x :: nat + assume "x \ {0..p}" + then have "\n. Bernstein_Poly x p c d = Bernstein_Poly n p c d \ n \ p" + by auto + then have + "Bernstein_Poly x p c d \ poly_vs.span {Bernstein_Poly n p c d |n. n \ p}" + by (simp add: poly_vs.span_base) + thus "smult (inverse (real (p choose x)) * + coeff (reciprocal_poly p (P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d - c:]) \\<^sub>p [:1, 1:]) + (p - x)) (Bernstein_Poly x p c d) + \ poly_vs.span {Bernstein_Poly x p c d |x. x \ p}" + by (rule poly_vs.span_scale) +qed + +lemma Bernstein_Poly_span: + assumes "c \ d" + shows "poly_vs.span {Bernstein_Poly x p c d | x. x \ p} = {x. degree x \ p}" +proof (subst Bernstein_Poly_01_span[symmetric], subst poly_vs.span_eq, rule conjI) + show "{Bernstein_Poly x p c d |x. x \ p} + \ poly_vs.span {Bernstein_Poly_01 x p |x. x \ p}" + apply (subst Setcompr_subset) + apply (rule allI, rule impI) + apply (rule Bernstein_Poly_01_span1) + using assms by (auto simp: degree_Bernstein_le Bernstein_Poly_eq_rescale_01 + degree_pcompose) + + show "{Bernstein_Poly_01 x p |x. x \ p} + \ poly_vs.span {Bernstein_Poly x p c d |x. x \ p}" + apply (subst Setcompr_subset) + apply (rule allI, rule impI) + apply (rule Bernstein_Poly_span1) + using assms by (auto simp: degree_Bernstein_le) +qed + +lemma Bernstein_Poly_independent: assumes "c \ d" + shows "poly_vs.independent {Bernstein_Poly x p c d | x. x \ {..p}}" +proof (rule poly_vs.card_le_dim_spanning) + show "{Bernstein_Poly x p c d |x. x \ {.. p}} \ {x. degree x \ p}" + using assms + by (auto simp: degree_Bernstein Bernstein_Poly_eq_rescale_01 degree_pcompose) + show "{x. degree x \ p} \ poly_vs.span {Bernstein_Poly x p c d |x. x \ {..p}}" + using assms by (auto simp: Bernstein_Poly_span1) + show "finite {Bernstein_Poly x p c d |x. x \ {..p}}" by fastforce + show "card {Bernstein_Poly x p c d |x. x \ {..p}} \ poly_vs.dim {x. degree x \ p}" + apply (rule le_trans) + apply (subst image_Collect[symmetric], rule card_image_le, force) + by (force simp: dim_degree) +qed + +subsection \Bernstein coefficients and changes over any interval\ + +definition Bernstein_coeffs :: + "nat \ real \ real \ real poly \ real list" where + "Bernstein_coeffs p c d P = + [(inverse (real (p choose j)) * + coeff (reciprocal_poly p (P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:]) \\<^sub>p [:1, 1:]) (p-j)). + j \ [0..<(p+1)]]" + +lemma Bernstein_coeffs_eq_rescale: assumes "c \ d" + shows "Bernstein_coeffs p c d P = Bernstein_coeffs_01 p (P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:])" + using assms by (auto simp: pcompose_pCons pcompose_assoc[symmetric] + Bernstein_coeffs_def Bernstein_coeffs_01_def) + +lemma nth_default_Bernstein_coeffs: assumes "degree P \ p" + shows "nth_default 0 (Bernstein_coeffs p c d P) i = + inverse (p choose i) * coeff + (reciprocal_poly p (P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:]) \\<^sub>p [:1, 1:]) (p-i)" + apply (cases "p = i") + using assms by (auto simp: Bernstein_coeffs_def nth_default_append + nth_default_Cons Nitpick.case_nat_unfold binomial_eq_0) + +lemma Bernstein_coeffs_sum: assumes "c \ d" and hP: "degree P \ p" + shows "P = (\j = 0..p. smult (nth_default 0 (Bernstein_coeffs p c d P) j) + (Bernstein_Poly j p c d))" + apply (subst nth_default_Bernstein_coeffs[OF hP]) + apply (subst Bernstein_sum[OF assms]) + by argo + +definition Bernstein_changes :: "nat \ real \ real \ real poly \ int" where + "Bernstein_changes p c d P = nat (changes (Bernstein_coeffs p c d P))" + +lemma Bernstein_changes_eq_rescale: assumes "c \ d" and "degree P \ p" + shows "Bernstein_changes p c d P = + Bernstein_changes_01 p (P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d-c:])" + using assms by (auto simp: Bernstein_coeffs_eq_rescale Bernstein_changes_def + Bernstein_changes_01_def) + +text \This is related and mostly equivalent to previous Descartes test \cite{li2019counting}\ +lemma Bernstein_changes_test: + fixes P::"real poly" + assumes "degree P \ p" and "P \ 0" and "c < d" + shows "proots_count P {x. c < x \ x < d} \ Bernstein_changes p c d P \ + even (Bernstein_changes p c d P - proots_count P {x. c < x \ x < d})" +proof - + define Q where "Q=P \\<^sub>p [:c, 1:] \\<^sub>p [:0, d - c:]" + + have "int (proots_count Q {x. 0 < x \ x < 1}) + \ Bernstein_changes_01 p Q \ + even (Bernstein_changes_01 p Q - + int (proots_count Q {x. 0 < x \ x < 1}))" + unfolding Q_def + apply (rule Bernstein_changes_01_test) + subgoal using assms by fastforce + subgoal using assms by (auto simp: pcompose_eq_0) + done + moreover have "proots_count P {x. c < x \ x < d} = + proots_count Q {x. 0 < x \ x < 1}" + unfolding Q_def + proof (subst proots_pcompose) + have "poly [:c, 1:] ` poly [:0, d - c:] ` {x. 0 < x \ x < 1} = + {x. c < x \ x < d}" (is "?L = ?R") + proof + have "c + x * (d - c) < d" if "x < 1" for x + proof - + have "x * (d - c) < 1 * (d - c)" + using \c < d\ that by force + then show ?thesis by fastforce + qed + then show "?L \ ?R" + using assms by auto + next + show "?R \ ?L" + proof + fix x::real assume "x \ ?R" + hence "c < x" and "x < d" by auto + thus "x \ ?L" + proof (subst image_eqI) + show "x = poly [:c, 1:] (x - c)" by force + assume "c < x" and "x < d" + thus "x - c \ poly [:0, d - c:] ` {x. 0 < x \ x < 1}" + proof (subst image_eqI) + show "x - c = poly [:0, d - c:] ((x - c)/(d - c))" + using assms by fastforce + assume "c < x" and "x < d" + thus "(x - c) / (d - c) \ {x. 0 < x \ x < 1}" + by auto + qed fast + qed fast + qed + qed + then show "proots_count P {x. c < x \ x < d} = + proots_count (P \\<^sub>p [:c, 1:]) + (poly [:0, d - c:] ` {x. 0 < x \ x < 1})" + using assms by (auto simp:proots_pcompose) + show "P \\<^sub>p [:c, 1:] \ 0" + by (simp add: pcompose_eq_0 assms(2)) + show "degree [:0, d - c:] = 1" + using assms by auto + qed + moreover have " Bernstein_changes p c d P = Bernstein_changes_01 p Q" + unfolding Q_def + apply (rule Bernstein_changes_eq_rescale) + using assms by auto + ultimately show ?thesis by auto +qed + +subsection \The control polygon of a polynomial\ + +definition control_points :: + "nat \ real \ real \ real poly \ (real \ real) list" +where + "control_points p c d P = + [(((real i)*d + (real (p - i))*c)/p, + nth_default 0 (Bernstein_coeffs p c d P) i). + i \ [0..<(p+1)]]" + +lemma line_above: + fixes a b c d :: real and p :: nat and P :: "real poly" + assumes hline: "\i. i \ p \ a * (((real i)*d + (real (p - i))*c)/p) + b \ + nth_default 0 (Bernstein_coeffs p c d P) i" + and hp: "p \ 0" and hcd: "c \ d" and hP: "degree P \ p" + shows "\x. c \ x \ x \ d \ a*x + b \ poly P x" +proof - + fix x + assume hc: "c \ x" and hd: "x \ d" + + have bern_eq:"Bernstein_coeffs p c d [:b, a:] = + [a*(real i * d + real (p - i) * c)/p + b. i \ [0..<(p+1)]]" + proof - + have "Bernstein_coeffs p c d [:b, a:] = map (nth_default 0 + (Bernstein_coeffs_01 p ([:b, a:] \\<^sub>p [:c, 1:] \\<^sub>p [:0, d - c:]))) + [0..i. a * (real i * d + real (p - i) * c) / real p + b) [0..

set [0..

\<^sub>p [:c, 1:] \\<^sub>p [:0, d - c:])) x = + nth_default 0 (Bernstein_coeffs_01 p + (smult (b + a*c) 1 + smult (a*(d - c)) (monom 1 1))) x" + proof- + have "[:b, a:] \\<^sub>p [:c, 1:] \\<^sub>p [:0, d - c:] = + smult (b + a*c) 1 + smult (a*(d - c)) (monom 1 1)" + by (simp add: monom_altdef pcompose_pCons) + then show ?thesis by auto + qed + also have "... = + nth_default 0 (Bernstein_coeffs_01 p (smult (b + a * c) 1)) x + + nth_default 0 (Bernstein_coeffs_01 p (smult (a * (d - c)) (monom 1 1))) x" + apply (subst Bernstein_coeffs_01_add) + using hp by (auto simp: degree_monom_eq) + also have "... = + (b + a*c) * nth_default 0 (Bernstein_coeffs_01 p 1) x + + (a*(d - c)) * nth_default 0 (Bernstein_coeffs_01 p (monom 1 1)) x" + apply (subst Bernstein_coeffs_01_smult) + using hp by (auto simp: Bernstein_coeffs_01_smult degree_monom_eq) + also have "... = + (b + a * c) * (if x < p + 1 then 1 else 0) + + a * (d - c) * (real (nth_default 0 [0..

\<^sub>p [:c, 1:] \\<^sub>p [:0, d - c:])) x = + a * (real x * d + real (p - x) * c) / real p + b" . + qed blast + finally show ?thesis . + qed + + have nth_default_geq:"nth_default 0 (Bernstein_coeffs p c d [:b, a:]) i \ + nth_default 0 (Bernstein_coeffs p c d P) i" for i + proof - + show "nth_default 0 (Bernstein_coeffs p c d [:b, a:]) i \ + nth_default 0 (Bernstein_coeffs p c d P) i" + proof cases + define p1 where "p1 \ p+1" + assume h: "i \ p" + hence "nth_default 0 (Bernstein_coeffs p c d P) i \ + a * (((real i)*d + (real (p - i))*c)/p) + b" + by (rule hline) + also have "... = nth_default 0 (map (\i. a * (real i * d + + real (p - i) * c) / real p + b) [0..

i \ p" + thus ?thesis + using assms + by (auto simp: nth_default_def Bernstein_coeffs_eq_rescale + length_Bernstein_coeffs_01) + qed + qed + + have "poly P x = (\k = 0..p. + poly (smult (nth_default 0 (Bernstein_coeffs p c d P) k) + (Bernstein_Poly k p c d)) x)" + apply (subst Bernstein_coeffs_sum[OF hcd hP]) + by (rule poly_sum) + also have "... \ (\k = 0..p. + poly (smult (nth_default 0 (Bernstein_coeffs p c d [:b, a:]) k) + (Bernstein_Poly k p c d)) x)" + apply (rule sum_mono) + using mult_right_mono[OF nth_default_geq] Bernstein_Poly_nonneg[OF hc hd] + by auto + also have "... = poly [:b, a:] x" + apply (subst(2) Bernstein_coeffs_sum[of c d "[:b, a:]" p]) + using assms apply auto[2] + by (rule poly_sum[symmetric]) + also have "... = a*x + b" by force + finally show "poly P x \ a*x + b" . +qed + +end \ No newline at end of file diff --git a/thys/Three_Circles/Bernstein_01.thy b/thys/Three_Circles/Bernstein_01.thy new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/Bernstein_01.thy @@ -0,0 +1,619 @@ +section \Bernstein Polynomials over the interval [0, 1]\ + +theory Bernstein_01 + imports "HOL-Computational_Algebra.Computational_Algebra" + "Budan_Fourier.Budan_Fourier" + "RRI_Misc" +begin + +text \ +The theorem of three circles is a statement about the Bernstein coefficients of a polynomial, the +coefficients when a polynomial is expressed as a sum of Bernstein polynomials. These coefficients +behave nicely under translations and rescaling and are the coefficients of a particular polynomial +in the [0, 1] case. We shall define the [0, 1] case now and consider the general case later, +deriving all the results by rescaling. +\ + +subsection \Definition and basic results\ + +definition Bernstein_Poly_01 :: "nat \ nat \ real poly" where + "Bernstein_Poly_01 j p = (monom (p choose j) j) + * (monom 1 (p-j) \\<^sub>p [:1, -1:])" + +lemma degree_Bernstein: + assumes hb: "j \ p" + shows "degree (Bernstein_Poly_01 j p) = p" +proof - + have ha: "monom (p choose j) j \ (0::real poly)" using hb by force + have hb: "monom 1 (p-j) \\<^sub>p [:1, -1:] \ (0::real poly)" + proof + assume "monom 1 (p-j) \\<^sub>p [:1, -1:] = (0::real poly)" + hence "lead_coeff (monom 1 (p - j) \\<^sub>p [:1, -1:]) = (0::real)" + apply (subst leading_coeff_0_iff) + by simp + moreover have "lead_coeff (monom (1::real) (p - j) + \\<^sub>p [:1, -1:]) = (((- 1) ^ (p - j))::real)" + by (subst lead_coeff_comp, auto simp: degree_monom_eq) + ultimately show "False" by auto + qed + from ha hb show ?thesis + by (auto simp add: Bernstein_Poly_01_def degree_mult_eq + degree_monom_eq degree_pcompose) +qed + +lemma coeff_gt: + assumes hb: "j > p" + shows "Bernstein_Poly_01 j p = 0" + by (simp add: hb Bernstein_Poly_01_def) + +lemma degree_Bernstein_le: "degree (Bernstein_Poly_01 j p) \ p" + apply (cases "j \ p") + by (simp_all add: degree_Bernstein coeff_gt) + +lemma poly_Bernstein_nonneg: + assumes "x \ 0" and "1 \ x" + shows "poly (Bernstein_Poly_01 j p) x \ 0" + using assms by (simp add: poly_monom poly_pcompose Bernstein_Poly_01_def) + +lemma Bernstein_symmetry: + assumes "j \ p" + shows "(Bernstein_Poly_01 j p) \\<^sub>p [:1, -1:] = Bernstein_Poly_01 (p-j) p" +proof - + have "(Bernstein_Poly_01 j p) \\<^sub>p [:1, -1:] + = ((monom (p choose j) j) * (monom 1 (p-j) \\<^sub>p [:1, -1:])) \\<^sub>p [:1, -1:]" + by (simp add: Bernstein_Poly_01_def) + also have "... = (monom (p choose (p-j)) j * + (monom 1 (p-j) \\<^sub>p [:1, -1:])) \\<^sub>p [:1, -1:]" + by (fastforce simp: binomial_symmetric[OF assms]) + also have "... = monom (p choose (p-j)) j \\<^sub>p [:1, -1:] * + (monom 1 (p-j)) \\<^sub>p ([:1, -1:] \\<^sub>p [:1, -1:])" + by (force simp: pcompose_mult pcompose_assoc) + also have "... = (monom (p choose (p-j)) j \\<^sub>p [:1, -1:]) * monom 1 (p-j)" + by (force simp: pcompose_pCons) + also have "... = smult (p choose (p-j)) (monom 1 j \\<^sub>p [:1, -1:]) + * monom 1 (p-j)" + by (simp add: assms smult_monom pcompose_smult[symmetric]) + also have "... = (monom 1 j \\<^sub>p [:1, -1:]) * monom (p choose (p-j)) (p-j)" + apply (subst mult_smult_left) + apply (subst mult_smult_right[symmetric]) + apply (subst smult_monom) + by force + also have "... = Bernstein_Poly_01 (p-j) p" using assms + by (auto simp: Bernstein_Poly_01_def) + finally show ?thesis . +qed + +subsection \@{term Bernstein_Poly_01} and @{term reciprocal_poly}\ + +lemma Bernstein_reciprocal: + "reciprocal_poly p (Bernstein_Poly_01 i p) + = smult (p choose i) ([:-1, 1:]^(p-i))" +proof cases + assume "i \ p" + hence "reciprocal_poly p (Bernstein_Poly_01 i p) = + reciprocal_poly (degree (Bernstein_Poly_01 i p)) (Bernstein_Poly_01 i p)" + by (auto simp: degree_Bernstein) + also have "... = reflect_poly (Bernstein_Poly_01 i p)" + by (rule reciprocal_degree) + also have "... = smult (p choose i) ([:-1, 1:]^(p-i))" + by (auto simp: Bernstein_Poly_01_def reflect_poly_simps monom_altdef + pcompose_pCons reflect_poly_pCons' hom_distribs) + finally show ?thesis . +next + assume h:"\ i \ p" + hence "reciprocal_poly p (Bernstein_Poly_01 i p) = (0::real poly)" + by (auto simp: coeff_gt reciprocal_poly_def) + also have "... = smult (p choose i) ([:-1, 1:]^(p - i))" using h + by fastforce + finally show ?thesis . +qed + +lemma Bernstein_reciprocal_translate: + "reciprocal_poly p (Bernstein_Poly_01 i p) \\<^sub>p [:1, 1:] = + monom (p choose i) (p - i)" + by (auto simp: Bernstein_reciprocal pcompose_smult pcompose_pCons monom_altdef hom_distribs) + +lemma coeff_Bernstein_sum_01: fixes b::"nat \ real" assumes hi: "p \ i" + shows + "coeff (reciprocal_poly p + (\x = 0..p. smult (b x) (Bernstein_Poly_01 x p)) \\<^sub>p [:1, 1:]) + (p - i) = (p choose i) * (b i)" (is "?L = ?R") +proof - + define P where "P \ (\x = 0..p. (smult (b x) (Bernstein_Poly_01 x p)))" + + have "\x. degree (smult (b x) (Bernstein_Poly_01 x p)) \ p" + proof - + fix x + show "degree (smult (b x) (Bernstein_Poly_01 x p)) \ p" + apply (cases "x \ p") + by (auto simp: degree_Bernstein coeff_gt) + qed + hence "reciprocal_poly p P = + (\x = 0..p. reciprocal_poly p (smult (b x) (Bernstein_Poly_01 x p)))" + apply (subst P_def) + apply (rule reciprocal_sum) + by presburger + also have + "... = (\x = 0..p. (smult (b x * (p choose x)) ([:-1, 1:]^(p-x))))" + proof (rule sum.cong) + fix x assume "x \ {0..p}" + hence "x \ p" by simp + thus "reciprocal_poly p (smult (b x) (Bernstein_Poly_01 x p)) = + smult ((b x) * (p choose x)) ([:-1, 1:]^(p-x))" + by (auto simp add: reciprocal_smult degree_Bernstein Bernstein_reciprocal) + qed (simp) + finally have + "reciprocal_poly p P = + (\x = 0..p. (smult ((b x) * (p choose x)) ([:-1, 1:]^(p-x))))" . + hence + "(reciprocal_poly p P) \\<^sub>p [:1, 1:] = + (\x = 0..p. (smult ((b x) * (p choose x)) ([:-1, 1:]^(p-x))) \\<^sub>p [:1, 1:])" + by (simp add: pcompose_sum pcompose_add) + also have "... = (\x = 0..p. (monom ((b x) * (p choose x)) (p - x)))" + proof (rule sum.cong) + fix x assume "x \ {0..p}" + hence "x \ p" by simp + thus "smult (b x * (p choose x)) ([:- 1, 1:] ^ (p - x)) \\<^sub>p [:1, 1:] = + monom (b x * (p choose x)) (p - x)" + by (simp add: hom_distribs pcompose_smult pcompose_pCons monom_altdef) + qed (simp) + finally have "(reciprocal_poly p P) \\<^sub>p [:1, 1:] = + (\x = 0..p. (monom ((b x) * (p choose x)) (p - x)))" . + hence "?L = (\x = 0..p. if p - x = p - i then b x * real (p choose x) else 0)" + by (auto simp add: P_def coeff_sum) + also have "... = (\x = 0..p. if x = i then b x * real (p choose x) else 0)" + proof (rule sum.cong) + fix x assume "x \ {0..p}" + hence "x \ p" by simp + thus "(if p - x = p - i then b x * real (p choose x) else 0) = + (if x = i then b x * real (p choose x) else 0)" using hi + by (auto simp add: leI) + qed (simp) + also have "... = ?R" by simp + finally show ?thesis . +qed + +lemma Bernstein_sum_01: assumes hP: "degree P \ p" + shows + "P = (\j = 0..p. smult + (inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)) + (Bernstein_Poly_01 j p))" +proof - + define Q where "Q \ reciprocal_poly p P \\<^sub>p [:1, 1:]" + from hP Q_def have hQ: "degree Q \ p" + by (auto simp: degree_reciprocal degree_pcompose) + have "reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * coeff Q (p-j)) + (Bernstein_Poly_01 j p)) \\<^sub>p [:1, 1:] = Q" + proof (rule poly_eqI) + fix n + show "coeff (reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * coeff Q (p-j)) + (Bernstein_Poly_01 j p)) \\<^sub>p [:1, 1:]) n = coeff Q n" + (is "?L = ?R") + proof cases + assume hn: "n \ p" + hence "?L = coeff (reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * coeff Q (p-j)) + (Bernstein_Poly_01 j p)) \\<^sub>p [:1, 1:]) (p - (p - n))" + by force + also have "... = (p choose (p-n)) * + (inverse (real (p choose (p-n))) * + coeff Q (p-(p-n)))" + apply (subst coeff_Bernstein_sum_01) + by auto + also have "... = ?R" using hn + by fastforce + finally show "?L = ?R" . + next + assume hn: "\ n \ p" + have "degree (\j = 0..p. + smult (inverse (real (p choose j)) * coeff Q (p - j)) + (Bernstein_Poly_01 j p)) \ p" + proof (rule degree_sum_le) + fix q assume "q \ {0..p}" + hence "q \ p" by fastforce + thus "degree (smult (inverse (real (p choose q)) * + coeff Q (p - q)) (Bernstein_Poly_01 q p)) \ p" + by (auto simp add: degree_Bernstein degree_smult_le) + qed simp + hence "degree (reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * coeff Q (p - j)) + (Bernstein_Poly_01 j p)) \\<^sub>p [:1, 1:]) \ p" + by (auto simp add: degree_pcompose degree_reciprocal) + hence "?L = 0" using hn by (auto simp add: coeff_eq_0) + thus "?L = ?R" using hQ hn by (simp add: coeff_eq_0) + qed + qed + hence "reciprocal_poly p P \\<^sub>p [:1, 1:] = + reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)) + (Bernstein_Poly_01 j p)) \\<^sub>p [:1, 1:]" + by (auto simp: degree_reciprocal degree_pcompose Q_def) + hence "reciprocal_poly p P \\<^sub>p ([:1, 1:] \\<^sub>p [:-1, 1:]) = + reciprocal_poly p (\j = 0..p. smult (inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)) + (Bernstein_Poly_01 j p)) \\<^sub>p ([:1, 1:] \\<^sub>p [:-1, 1:])" + by (auto simp: pcompose_assoc) + hence "reciprocal_poly p P = reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)) (Bernstein_Poly_01 j p))" + by (auto simp: pcompose_pCons) + hence "reciprocal_poly p (reciprocal_poly p P) = + reciprocal_poly p (reciprocal_poly p (\j = 0..p. + smult (inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)) (Bernstein_Poly_01 j p)))" + by argo + thus "P = (\j = 0..p. smult (inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)) (Bernstein_Poly_01 j p))" + using hP by (auto simp: reciprocal_reciprocal degree_sum_le degree_smult_le + degree_Bernstein degree_add_le) +qed + +lemma Bernstein_Poly_01_span1: + assumes hP: "degree P \ p" + shows "P \ poly_vs.span {Bernstein_Poly_01 x p | x. x \ p}" +proof - + have "Bernstein_Poly_01 x p + \ poly_vs.span {Bernstein_Poly_01 x p |x. x \ p}" + if "x \ {0..p}" for x + proof - + have "\n. Bernstein_Poly_01 x p = Bernstein_Poly_01 n p \ n \ p" + using that by force + then show + "Bernstein_Poly_01 x p \ poly_vs.span {Bernstein_Poly_01 n p |n. n \ p}" + by (simp add: poly_vs.span_base) + qed + thus ?thesis + apply (subst Bernstein_sum_01[OF hP]) + apply (rule poly_vs.span_sum) + apply (rule poly_vs.span_scale) + by blast +qed + +lemma Bernstein_Poly_01_span: + "poly_vs.span {Bernstein_Poly_01 x p | x. x \ p} + = {x. degree x \ p}" + apply (subst monom_span[symmetric]) + apply (subst poly_vs.span_eq) + by (auto simp: monom_span degree_Bernstein_le + Bernstein_Poly_01_span1 degree_monom_eq) + +subsection \Bernstein coefficients and changes\ + +definition Bernstein_coeffs_01 :: "nat \ real poly \ real list" where + "Bernstein_coeffs_01 p P = + [(inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)). j \ [0..<(p+1)]]" + +lemma length_Bernstein_coeffs_01: "length (Bernstein_coeffs_01 p P) = p + 1" + by (auto simp: Bernstein_coeffs_01_def) + +lemma nth_default_Bernstein_coeffs_01: assumes "degree P \ p" + shows "nth_default 0 (Bernstein_coeffs_01 p P) i = + inverse (p choose i) * coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-i)" + apply (cases "p = i") + using assms by (auto simp: Bernstein_coeffs_01_def nth_default_append + nth_default_Cons Nitpick.case_nat_unfold binomial_eq_0) + +lemma Bernstein_coeffs_01_sum: assumes "degree P \ p" + shows "P = (\j = 0..p. smult (nth_default 0 (Bernstein_coeffs_01 p P) j) + (Bernstein_Poly_01 j p))" + apply (subst nth_default_Bernstein_coeffs_01[OF assms]) + apply (subst Bernstein_sum_01[OF assms]) + by argo + +definition Bernstein_changes_01 :: "nat \ real poly \ int" where + "Bernstein_changes_01 p P = nat (changes (Bernstein_coeffs_01 p P))" + +lemma Bernstein_changes_01_def': + "Bernstein_changes_01 p P = nat (changes [(inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p-j)). j \ [0..

p" + shows "Bernstein_changes_01 p P = + changes (coeffs ((reciprocal_poly p P) \\<^sub>p [:1, 1:]))" +proof (subst Bernstein_changes_01_def') + have h: + "map (\j. inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p - j)) [0..

j. inverse (real (p choose j)) * + nth_default 0 [nth_default 0 (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) + (p - j). j \ [0..

set [0.. p" by fastforce + moreover have 1: + "length (map (\j. nth_default 0 + (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) (p - j)) [0..

Suc p" + by force + moreover have "length (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) \ Suc p" + proof (cases "P=0") + case False + then have "reciprocal_poly p P \\<^sub>p [:1, 1:] \ 0" + using hP by (simp add: Missing_Polynomial.pcompose_eq_0 reciprocal_0_iff) + moreover have "Suc (degree (reciprocal_poly p P \\<^sub>p [:1, 1:])) \ Suc p" + using hP by (auto simp: degree_pcompose degree_reciprocal) + ultimately show ?thesis + using length_coeffs_degree by force + qed (auto simp: reciprocal_0) + ultimately have h: + "nth_default 0 (map (\j. nth_default 0 (coeffs + (reciprocal_poly p P \\<^sub>p [:1, 1:])) (p - j)) [0..

\<^sub>p [:1, 1:])) (p - x)" + (is "?L = ?R") + proof - + have "?L = (map (\j. nth_default 0 (coeffs + (reciprocal_poly p P \\<^sub>p [:1, 1:])) (p - j)) [0..

\<^sub>p [:1, 1:])) (p - [0..

\<^sub>p [:1, 1:]) (p - x) = + inverse (real (p choose x)) * + nth_default 0 (map (\j. nth_default 0 + (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) (p - j)) [0..

j. nth_default 0 (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) + (p - j)) [0..

j. nth_default 0 (coeffs + (reciprocal_poly p P \\<^sub>p [:1, 1:])) j) [0..

q. (q \ p \ rev [q-p..q. (q \ p \ rev [q-p.. q" + then have h: "rev [q - p.. set [0..

p" by fastforce + thus "nth_default 0 (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) (p - (p - y)) = + nth_default 0 (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) y" + by fastforce + qed + + have 2: "\ f. f \ 0 \ degree f \ p \ + map (nth_default 0 (coeffs f)) [0..

0 \ + degree f \ p \ + map (nth_default 0 (coeffs f)) [0..

degree f" + show ?thesis + proof + assume hf: "f \ 0" + show "degree f \ Suc p \ + map (nth_default 0 (coeffs f)) [0.. Suc p" + hence 1: "degree f \ p" using h' by fastforce + hence 2: "map (nth_default 0 (coeffs f)) [0..

degree f \ Suc p\ h' le_antisym le_degree by blast + also have "... = coeffs f @ replicate (Suc p - degree f) 0" using 1 + by (simp add: Suc_diff_le replicate_app_Cons_same) + finally show "map (nth_default 0 (coeffs f)) [0..j. inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p - j)) [0..

\<^sub>p [:1, 1:]))" + proof cases + assume hP: "P = 0" + show "int (nat (changes (map (\j. inverse (real (p choose j)) * + coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]) (p - j)) [0..

\<^sub>p [:1, 1:]))" (is "?L = ?R") + proof - + have "?L = int (nat (changes (map (\j. 0::real) [0.. 0" + thus ?thesis + apply (subst h) + apply (subst changes_scale) + apply auto[2] + apply (subst changes_rev[symmetric]) + apply (subst 1) + apply (subst 2) + apply (simp add: pcompose_eq_0 hP reciprocal_0_iff) + using assms apply (auto simp: degree_reciprocal)[1] + by (auto simp: changes_append_replicate_0 changes_nonneg) + qed +qed + +lemma Bernstein_changes_01_test: fixes P::"real poly" + assumes hP: "degree P \ p" and h0: "P \ 0" + shows "proots_count P {x. 0 < x \ x < 1} \ Bernstein_changes_01 p P \ + even (Bernstein_changes_01 p P - proots_count P {x. 0 < x \ x < 1})" +proof - + let ?Q = "(reciprocal_poly p P) \\<^sub>p [:1, 1:]" + + have 1: "changes (coeffs ?Q) \ proots_count ?Q {x. 0 < x} \ + even (changes (coeffs ?Q) - proots_count ?Q {x. 0 < x})" + apply (rule descartes_sign) + by (simp add: Missing_Polynomial.pcompose_eq_0 h0 hP reciprocal_0_iff) + + have "((+) (1::real) ` Collect ((<) (0::real))) = {x. (1::real) (+) 1 ` Collect ((<) 0)" + proof + fix x::real assume "x \ {x. 1 < x}" + hence "1 < x" by simp + hence "-1 + x \ Collect ((<) 0)" by auto + hence "1 + (-1 + x) \ (+) 1 ` Collect ((<) 0)" by blast + thus "x \ (+) 1 ` Collect ((<) 0)" by argo + qed + qed auto + hence 2: "proots_count P {x. 0 < x \ x < 1} = proots_count ?Q {x. 0 < x}" + using assms + by (auto simp: proots_pcompose reciprocal_0_iff proots_count_reciprocal') + + show ?thesis + apply (subst Bernstein_changes_01_eq_changes[OF hP]) + apply (subst Bernstein_changes_01_eq_changes[OF hP]) + apply (subst 2) + apply (subst 2) + by (rule 1) +qed + +subsection \Expression as a Bernstein sum\ + +lemma Bernstein_coeffs_01_0: "Bernstein_coeffs_01 p 0 = replicate (p+1) 0" + by (auto simp: Bernstein_coeffs_01_def reciprocal_0 map_replicate_trivial + replicate_append_same) + +lemma Bernstein_coeffs_01_1: "Bernstein_coeffs_01 p 1 = replicate (p+1) 1" +proof - + have "Bernstein_coeffs_01 p 1 = + map (\j. inverse (real (p choose j)) * + coeff (\k\p. smult (real (p choose k)) ([:0, 1:] ^ k)) (p - j)) [0..<(p+1)]" + by (auto simp: Bernstein_coeffs_01_def reciprocal_1 monom_altdef + hom_distribs pcompose_pCons poly_0_coeff_0[symmetric] poly_binomial) + also have "... = map (\j. inverse (real (p choose j)) * + real (p choose (p - j))) [0..<(p+1)]" + by (auto simp: monom_altdef[symmetric] coeff_sum binomial) + also have "... = map (\j. 1) [0..<(p+1)]" + apply (rule map_cong) + subgoal by argo + subgoal apply (subst binomial_symmetric) + by auto + done + also have "... = replicate (p+1) 1" + by (auto simp: map_replicate_trivial replicate_append_same) + finally show ?thesis . +qed + +lemma Bernstein_coeffs_01_x: assumes "p \ 0" + shows "Bernstein_coeffs_01 p (monom 1 1) = [i/p. i \ [0..<(p+1)]]" +proof - + have + "Bernstein_coeffs_01 p (monom 1 1) = map (\j. inverse (real (p choose j)) * + coeff (monom 1 (p - Suc 0) \\<^sub>p [:1, 1:]) (p - j)) [0..<(p+1)]" + using assms by (auto simp: Bernstein_coeffs_01_def reciprocal_monom) + also have + "... = map (\j. inverse (real (p choose j)) * + (\k\p - Suc 0. coeff (monom (real (p - 1 choose k)) k) (p - j))) [0..<(p+1)]" + by (auto simp: monom_altdef hom_distribs pcompose_pCons poly_binomial coeff_sum) + also have"... = map (\j. inverse (real (p choose j)) * + real (p - 1 choose (p - j))) [0..<(p+1)]" + by auto + also have "... = map (\j. j/p) [0..<(p+1)]" + proof (rule map_cong) + fix x assume "x \ set [0..<(p+1)]" + hence "x \ p" by force + thus "inverse (real (p choose x)) * real (p - 1 choose (p - x)) = + real x / real p" + proof (cases "x = 0") + show "x = 0 \ ?thesis" + using assms by fastforce + assume 1: "x \ p" and 2: "x \ 0" + hence "p - x \ p - 1" by force + hence "(p - 1 choose (p - x)) = (p - 1 choose (x - 1))" + apply (subst binomial_symmetric) + using 1 2 by auto + hence "x * (p choose x) = p * (p - 1 choose (p - x))" + using 2 times_binomial_minus1_eq by simp + hence "real x * real (p choose x) = real p * real (p - 1 choose (p - x))" + by (metis of_nat_mult) + thus ?thesis using 1 2 + by (auto simp: divide_simps) + qed + qed blast + finally show ?thesis . +qed + +lemma Bernstein_coeffs_01_add: + assumes "degree P \ p" and "degree Q \ p" + shows "nth_default 0 (Bernstein_coeffs_01 p (P + Q)) i = + nth_default 0 (Bernstein_coeffs_01 p P) i + + nth_default 0 (Bernstein_coeffs_01 p Q) i" + using assms by (auto simp: nth_default_Bernstein_coeffs_01 degree_add_le + reciprocal_add pcompose_add algebra_simps) + +lemma Bernstein_coeffs_01_smult: + assumes "degree P \ p" + shows "nth_default 0 (Bernstein_coeffs_01 p (smult a P)) i = + a * nth_default 0 (Bernstein_coeffs_01 p P) i" + using assms + by (auto simp: nth_default_Bernstein_coeffs_01 reciprocal_smult + pcompose_smult) + +end diff --git a/thys/Three_Circles/Normal_Poly.thy b/thys/Three_Circles/Normal_Poly.thy new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/Normal_Poly.thy @@ -0,0 +1,1106 @@ +section \Normal Polynomials\ + +theory Normal_Poly + imports "RRI_Misc" +begin + +text \ +Here we define normal polynomials as defined in + Basu, S., Pollack, R., Roy, M.-F.: Algorithms in Real Algebraic Geometry. + Springer Berlin Heidelberg, Berlin, Heidelberg (2016). +\ + +definition normal_poly :: "('a::{comm_ring_1,ord}) poly \ bool" where +"normal_poly p \ + (p \ 0) \ + (\ i. 0 \ coeff p i) \ + (\ i. coeff p i * coeff p (i+2) \ (coeff p (i+1))^2) \ + (\ i j k. i \ j \ j \ k \ 0 < coeff p i + \ 0 < coeff p k \ 0 < coeff p j)" + +lemma normal_non_zero: "normal_poly p \ p \ 0" + using normal_poly_def by blast + +lemma normal_coeff_nonneg: "normal_poly p \ 0 \ coeff p i" + using normal_poly_def by metis + +lemma normal_poly_coeff_mult: + "normal_poly p \ coeff p i * coeff p (i+2) \ (coeff p (i+1))^2" + using normal_poly_def by blast + +lemma normal_poly_pos_interval: + "normal_poly p \ i \ j \ j \ k \ 0 < coeff p i \ 0 < coeff p k + \ 0 < coeff p j" + using normal_poly_def by blast + +lemma normal_polyI: + assumes "(p \ 0)" + and "(\ i. 0 \ coeff p i)" + and "(\ i. coeff p i * coeff p (i+2) \ (coeff p (i+1))^2)" + and "(\ i j k. i \ j \ j \ k \ 0 < coeff p i \ 0 < coeff p k \ 0 < coeff p j)" + shows "normal_poly p" + using assms by (force simp: normal_poly_def) + +lemma linear_normal_iff: + fixes x::real + shows "normal_poly [:-x, 1:] \ x \ 0" +proof + assume "normal_poly [:-x, 1:]" + thus "x \ 0" using normal_coeff_nonneg[of "[:-x, 1:]" 0] by auto +next + assume "x \ 0" + then have "0 \ coeff [:- x, 1:] i" for i + by (cases i) (simp_all add: pCons_one) + moreover have "0 < coeff [:- x, 1:] j" + if "i \ j" "j \ k" "0 < coeff [:- x, 1:] i" + "0 < coeff [:- x, 1:] k" for i j k + apply (cases "k=0 \ i=0") + subgoal using that + by (smt (z3) bot_nat_0.extremum_uniqueI degree_pCons_eq_if + le_antisym le_degree not_less_eq_eq) + subgoal using that + by (smt (z3) One_nat_def degree_pCons_eq_if le_degree less_one + not_le one_neq_zero pCons_one verit_la_disequality) + done + ultimately show "normal_poly [:-x, 1:]" + unfolding normal_poly_def by auto +qed + +lemma quadratic_normal_iff: + fixes z::complex + shows "normal_poly [:(cmod z)\<^sup>2, -2*Re z, 1:] + \ Re z \ 0 \ 4*(Re z)^2 \ (cmod z)^2" +proof + assume "normal_poly [:(cmod z)\<^sup>2, - 2 * Re z, 1:]" + hence "-2*Re z \ 0 \ (cmod z)^2 \ 0 \ (-2*Re z)^2 \ (cmod z)^2" + using normal_coeff_nonneg[of _ 1] normal_poly_coeff_mult[of _ 0] + by fastforce + thus "Re z \ 0 \ 4*(Re z)^2 \ (cmod z)^2" + by auto +next + assume asm:"Re z \ 0 \ 4*(Re z)^2 \ (cmod z)^2" + define P where "P=[:(cmod z)\<^sup>2, - 2 * Re z, 1:]" + + have "0 \ coeff P i" for i + unfolding P_def using asm + apply (cases "i=0\i=1\i=2") + by (auto simp:numeral_2_eq_2 coeff_eq_0) + moreover have "coeff P i * coeff P (i + 2) \ (coeff P (i + 1))\<^sup>2" for i + apply (cases "i=0\i=1\i=2") + using asm + unfolding P_def by (auto simp:coeff_eq_0) + moreover have "0 < coeff P j" + if "0 < coeff P k" "0 < coeff P i" "j \ k" "i \ j" + for i j k + using that unfolding P_def + apply (cases "k=0 \ k=1 \ k=2") + subgoal using asm + by (smt (z3) One_nat_def Suc_1 bot_nat_0.extremum_uniqueI + coeff_pCons_0 coeff_pCons_Suc le_Suc_eq + zero_less_power2) + subgoal by (auto simp:coeff_eq_0) + done + moreover have "P\0" unfolding P_def by auto + ultimately show "normal_poly P" + unfolding normal_poly_def by blast +qed + +lemma normal_of_no_zero_root: + fixes f::"real poly" + assumes hzero: "poly f 0 \ 0" and hdeg: "i \ degree f" + and hnorm: "normal_poly f" + shows "0 < coeff f i" +proof - + have "coeff f 0 > 0" using hzero normal_coeff_nonneg[OF hnorm] + by (metis eq_iff not_le_imp_less poly_0_coeff_0) + moreover have "coeff f (degree f) > 0" using normal_coeff_nonneg[OF hnorm] normal_non_zero[OF hnorm] + by (meson dual_order.irrefl eq_iff eq_zero_or_degree_less not_le_imp_less) + moreover have "0 \ i" by simp + ultimately show "0 < coeff f i" using hdeg normal_poly_pos_interval[OF hnorm] by blast +qed + +lemma normal_divide_x: + fixes f::"real poly" + assumes hnorm: "normal_poly (f*[:0,1:])" + shows "normal_poly f" +proof (rule normal_polyI) + show "f \ 0" + using normal_non_zero[OF hnorm] by auto +next + fix i + show "0 \ coeff f i" + using normal_coeff_nonneg[OF hnorm, of "Suc i"] by (simp add: coeff_pCons) +next + fix i + show "coeff f i * coeff f (i + 2) \ (coeff f (i + 1))\<^sup>2" + using normal_poly_coeff_mult[OF hnorm, of "Suc i"] by (simp add: coeff_pCons) +next + fix i j k + show "i \ j \ j \ k \ 0 < coeff f i \ 0 < coeff f k \ 0 < coeff f j" + using normal_poly_pos_interval[of _ "Suc i" "Suc j" "Suc k", OF hnorm] + by (simp add: coeff_pCons) +qed + +lemma normal_mult_x: + fixes f::"real poly" + assumes hnorm: "normal_poly f" + shows "normal_poly (f * [:0, 1:])" +proof (rule normal_polyI) + show "f * [:0, 1:] \ 0" + using normal_non_zero[OF hnorm] by auto +next + fix i + show "0 \ coeff (f * [:0, 1:]) i" + using normal_coeff_nonneg[OF hnorm, of "i-1"] by (cases i, auto simp: coeff_pCons) +next + fix i + show "coeff (f * [:0, 1:]) i * coeff (f * [:0, 1:]) (i + 2) \ (coeff (f * [:0, 1:]) (i + 1))\<^sup>2" + using normal_poly_coeff_mult[OF hnorm, of "i-1"] by (cases i, auto simp: coeff_pCons) +next + fix i j k + show "i \ j \ j \ k \ 0 < coeff (f * [:0, 1:]) i \ 0 < coeff (f * [:0, 1:]) k \ 0 < coeff (f * [:0, 1:]) j" + using normal_poly_pos_interval[of _ "i-1" "j-1" "k-1", OF hnorm] + apply (cases i, force) + apply (cases j, force) + apply (cases k, force) + by (auto simp: coeff_pCons) +qed + +lemma normal_poly_general_coeff_mult: + fixes f::"real poly" + assumes "normal_poly f" and "h \ j" + shows "coeff f (h+1) * coeff f (j+1) \ coeff f h * coeff f (j+2)" +using assms proof (induction j) + case 0 + then show ?case + using normal_poly_coeff_mult by (auto simp: power2_eq_square)[1] +next + case (Suc j) + then show ?case + proof (cases "h = Suc j") + assume "h = Suc j" "normal_poly f" + thus ?thesis + using normal_poly_coeff_mult by (auto simp: power2_eq_square) + next + assume "(normal_poly f \ + h \ j \ coeff f h * coeff f (j + 2) \ coeff f (h + 1) * coeff f (j + 1))" + "normal_poly f" and h: "h \ Suc j" "h \ Suc j" + hence IH: "coeff f h * coeff f (j + 2) \ coeff f (h + 1) * coeff f (j + 1)" + by linarith + show ?thesis + proof (cases "coeff f (Suc j + 1) = 0", cases "coeff f (Suc j + 2) = 0") + show "coeff f (Suc j + 1) = 0 \ coeff f (Suc j + 2) = 0 \ + coeff f h * coeff f (Suc j + 2) \ coeff f (h + 1) * coeff f (Suc j + 1)" + by (metis assms(1) mult_zero_right normal_coeff_nonneg) + next + assume 1: "coeff f (Suc j + 1) = 0" "coeff f (Suc j + 2) \ 0" + hence "coeff f (Suc j + 2) > 0" "\coeff f (Suc j + 1) > 0" + using normal_coeff_nonneg[of f "Suc j + 2"] assms(1) by auto + hence "coeff f h > 0 \ False" + using normal_poly_pos_interval[of f h "Suc j + 1" "Suc j + 2"] assms(1) h by force + hence "coeff f h = 0" + using normal_coeff_nonneg[OF assms(1)] less_eq_real_def by auto + thus "coeff f h * coeff f (Suc j + 2) \ coeff f (h + 1) * coeff f (Suc j + 1)" + using 1 by fastforce + next + assume 1: "coeff f (Suc j + 1) \ 0" + show "coeff f h * coeff f (Suc j + 2) \ coeff f (h + 1) * coeff f (Suc j + 1)" + proof (cases "coeff f (Suc j) = 0") + assume 2: "coeff f (Suc j) = 0" + hence "coeff f (Suc j + 1) > 0" "\coeff f (Suc j) > 0" + using normal_coeff_nonneg[of f "Suc j + 1"] assms(1) 1 by auto + hence "coeff f h > 0 \ False" + using normal_poly_pos_interval[of f h "Suc j" "Suc j + 1"] assms(1) h by force + hence "coeff f h = 0" + using normal_coeff_nonneg[OF assms(1)] less_eq_real_def by auto + thus "coeff f h * coeff f (Suc j + 2) \ coeff f (h + 1) * coeff f (Suc j + 1)" + by (simp add: assms(1) normal_coeff_nonneg) + next + assume 2: "coeff f (Suc j) \ 0" + from normal_poly_coeff_mult[OF assms(1), of "Suc j"] normal_coeff_nonneg[OF assms(1), of "Suc j"] + normal_coeff_nonneg[OF assms(1), of "Suc (Suc j)"] 1 2 + have 3: "coeff f (Suc j + 1) / coeff f (Suc j) \ coeff f (Suc j + 2) / coeff f (Suc j + 1)" + by (auto simp: power2_eq_square divide_simps algebra_simps) + have "(coeff f h * coeff f (j + 2)) * (coeff f (Suc j + 2) / coeff f (Suc j + 1)) \ (coeff f (h + 1) * coeff f (j + 1)) * (coeff f (Suc j + 1) / coeff f (Suc j))" + apply (rule mult_mono[OF IH]) + using 3 by (simp_all add: assms(1) normal_coeff_nonneg) + thus "coeff f h * coeff f (Suc j + 2) \ coeff f (h + 1) * coeff f (Suc j + 1)" + using 1 2 by fastforce + qed + qed + qed +qed + +lemma normal_mult: + fixes f g::"real poly" + assumes hf: "normal_poly f" and hg: "normal_poly g" + defines "df \ degree f" and "dg \ degree g" + shows "normal_poly (f*g)" +using df_def hf proof (induction df arbitrary: f) +text \We shall first show that without loss of generality we may assume \poly f 0 \ 0\, + this is done by induction on the degree, if 0 is a root then we derive the result from \f/[:0,1:]\.\ + fix f::"real poly" fix i::nat + assume "0 = degree f" and hf: "normal_poly f" + then obtain a where "f = [:a:]" using degree_0_iff by auto + then show "normal_poly (f*g)" + apply (subst normal_polyI) + subgoal using normal_non_zero[OF hf] normal_non_zero[OF hg] by auto + subgoal + using normal_coeff_nonneg[of _ 0, OF hf] normal_coeff_nonneg[OF hg] + by simp + subgoal + using normal_coeff_nonneg[of _ 0, OF hf] normal_poly_coeff_mult[OF hg] + by (auto simp: algebra_simps power2_eq_square mult_left_mono)[1] + subgoal + using normal_non_zero[OF hf] normal_coeff_nonneg[of _ 0, OF hf] normal_poly_pos_interval[OF hg] + by (simp add: zero_less_mult_iff) + subgoal by simp + done +next + case (Suc df) + then show ?case + proof (cases "poly f 0 = 0") + assume "poly f 0 = 0" and hf:"normal_poly f" + moreover then obtain f' where hdiv: "f = f'*[:0,1:]" + by (smt (verit) dvdE mult.commute poly_eq_0_iff_dvd) + ultimately have hf': "normal_poly f'" using normal_divide_x by blast + assume "Suc df = degree f" + hence "degree f' = df" using hdiv normal_non_zero[OF hf'] by (auto simp: degree_mult_eq) + moreover assume "\f. df = degree f \ normal_poly f \ normal_poly (f * g)" + ultimately have "normal_poly (f'*g)" using hf' by blast + thus "normal_poly (f*g)" using hdiv normal_mult_x by fastforce + next + assume hf: "normal_poly f" and hf0: "poly f 0 \ 0" + define dg where "dg \ degree g" + show "normal_poly (f * g)" + using dg_def hg proof (induction dg arbitrary: g) + text \Similarly we may assume \poly g 0 \ 0\.\ + fix g::"real poly" fix i::nat + assume "0 = degree g" and hg: "normal_poly g" + then obtain a where "g = [:a:]" using degree_0_iff by auto + then show "normal_poly (f*g)" + apply (subst normal_polyI) + subgoal + using normal_non_zero[OF hg] normal_non_zero[OF hf] by auto + subgoal + using normal_coeff_nonneg[of _ 0, OF hg] normal_coeff_nonneg[OF hf] + by simp + subgoal + using normal_coeff_nonneg[of _ 0, OF hg] normal_poly_coeff_mult[OF hf] + by (auto simp: algebra_simps power2_eq_square mult_left_mono) + subgoal + using normal_non_zero[OF hf] normal_coeff_nonneg[of _ 0, OF hg] + normal_poly_pos_interval[OF hf] + by (simp add: zero_less_mult_iff) + by simp + next + case (Suc dg) + then show ?case + proof (cases "poly g 0 = 0") + assume "poly g 0 = 0" and hg:"normal_poly g" + moreover then obtain g' where hdiv: "g = g'*[:0,1:]" + by (smt (verit) dvdE mult.commute poly_eq_0_iff_dvd) + ultimately have hg': "normal_poly g'" using normal_divide_x by blast + assume "Suc dg = degree g" + hence "degree g' = dg" using hdiv normal_non_zero[OF hg'] by (auto simp: degree_mult_eq) + moreover assume "\g. dg = degree g \ normal_poly g \ normal_poly (f * g)" + ultimately have "normal_poly (f*g')" using hg' by blast + thus "normal_poly (f*g)" using hdiv normal_mult_x by fastforce + next + text \It now remains to show that $(fg)_i \geq 0$. This follows by decomposing $\{(h, j) \in + \mathbf{Z}^2 | h > j\} = \{(h, j) \in \mathbf{Z}^2 | h \leq j\} \cup \{(h, h - 1) \in + \mathbf{Z}^2 | h \in \mathbf{Z}\}$. + Note in order to avoid working with infinite sums over integers all these sets are + bounded, which adds some complexity compared to the proof of lemma 2.55 in + Basu, S., Pollack, R., Roy, M.-F.: Algorithms in Real Algebraic Geometry. + Springer Berlin Heidelberg, Berlin, Heidelberg (2016).\ + assume hg0: "poly g 0 \ 0" and hg: "normal_poly g" + have "f * g \ 0" using hf hg by (simp add: normal_non_zero Suc.prems) + moreover have "\i. coeff (f*g) i \ 0" + apply (subst coeff_mult, rule sum_nonneg, rule mult_nonneg_nonneg) + using normal_coeff_nonneg[OF hf] normal_coeff_nonneg[OF hg] by auto + moreover have " + coeff (f*g) i * coeff (f*g) (i+2) \ (coeff (f*g) (i+1))^2" for i + proof - + + text \$(fg)_{i+1}^2 - (fg)_i(fg)_{i+2} = \left(\sum_x f_xg_{i+1-x}\right)^2 - + \left(\sum_x f_xg_{i+2-x}\right)\left(\sum_x f_xg_{i-x}\right)$\ + have "(coeff (f*g) (i+1))^2 - coeff (f*g) i * coeff (f*g) (i+2) = + (\x\i+1. coeff f x * coeff g (i + 1 - x)) * + (\x\i+1. coeff f x * coeff g (i + 1 - x)) - + (\x\i+2. coeff f x * coeff g (i + 2 - x)) * + (\x\i. coeff f x * coeff g (i - x))" + by (auto simp: coeff_mult power2_eq_square algebra_simps) + + text \$\dots = \sum_{x, y} f_xg_{i+1-x}f_yg_{i+1-y} - \sum_{x, y} f_xg_{i+2-x}f_yg_{i-y}$\ + also have "... = + (\x\i+1. \y\i+1. coeff f x * coeff g (i + 1 - x) * + coeff f y * coeff g (i + 1 - y)) - + (\x\i+2. \y\i. coeff f x * coeff g (i + 2 - x) * + coeff f y * coeff g (i - y))" + by (subst sum_product, subst sum_product, auto simp: algebra_simps) + + text \$\dots = \sum_{h \leq j} f_hg_{i+1-h}f_jg_{i+1-j} + \sum_{h>j} f_hg_{i+1-h}f_jg_{i+1-j} + - \sum_{h \leq j} f_hg_{i+2-h}f_jg_{i-j} - \sum_{h>j} f_hg_{i+2-h}f_jg_{i-j}$\ + also have "... = + (\(h, j)\{(h, j). i+1 \ j \ j \ h}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j)) + + (\(h, j)\{(h, j). i+1 \ h \ h > j}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j)) - + ((\(h, j)\{(h, j). i \ j \ j \ h}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j)) + + (\(h, j)\{(h, j). i + 2 \ h \ h > j \ i \ j}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j)))" + proof - + have "(\x\i + 1. \y\i + 1. coeff f x * coeff g (i + 1 - x) * coeff f y * coeff g (i + 1 - y)) = + (\(h, j)\{(h, j). j \ i + 1 \ h \ j}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j)) + + (\(h, j)\{(h, j). h \ i + 1 \ j < h}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j))" + proof (subst sum.union_disjoint[symmetric]) + have H:"{(h, j). j \ i + 1 \ h \ j} \ {..i+1} \ {..i+1}" + "{(h, j). h \ i + 1 \ j < h} \ {..i+1} \ {..i+1}" + "finite ({..i+1} \ {..i+1})" + by (fastforce, fastforce, fastforce) + show "finite {(h, j). j \ i + 1 \ h \ j}" + apply (rule finite_subset) using H by (blast, blast) + show "finite {(h, j). h \ i + 1 \ j < h}" + apply (rule finite_subset) using H by (blast, blast) + show "{(h, j). j \ i + 1 \ h \ j} \ {(h, j). h \ i + 1 \ j < h} = {}" + by fastforce + show "(\x\i + 1. \y\i + 1. coeff f x * coeff g (i + 1 - x) * coeff f y * coeff g (i + 1 - y)) = + (\(h, j)\{(h, j). j \ i + 1 \ h \ j} \ {(h, j). h \ i + 1 \ j < h}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j))" + apply (subst sum.cartesian_product, rule sum.cong) + apply force by blast + qed + moreover have "(\x\i + 2. \y\i. coeff f x * coeff g (i + 2 - x) * coeff f y * coeff g (i - y)) = + (\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j)) + + (\(h, j)\{(h, j). i + 2 \ h \ h > j \ i \ j}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j))" + proof (subst sum.union_disjoint[symmetric]) + have H:"{(h, j). j \ i \ h \ j} \ {..i+2} \ {..i}" + "{(h, j). i + 2 \ h \ h > j \ i \ j} \ {..i+2} \ {..i}" + "finite ({..i+2} \ {..i})" + by (fastforce, fastforce, fastforce) + show "finite {(h, j). j \ i \ h \ j}" + apply (rule finite_subset) using H by (blast, blast) + show "finite {(h, j). i + 2 \ h \ h > j \ i \ j}" + apply (rule finite_subset) using H by (blast, blast) + show "{(h, j). j \ i \ h \ j} \ {(h, j). i + 2 \ h \ h > j \ i \ j} = {}" + by fastforce + show "(\x\i + 2. \y\i. coeff f x * coeff g (i + 2 - x) * coeff f y * coeff g (i - y)) = + (\(h, j)\{(h, j). j \ i \ h \ j} \ {(h, j). i + 2 \ h \ h > j \ i \ j}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j))" + apply (subst sum.cartesian_product, rule sum.cong) + apply force by blast + qed + ultimately show ?thesis by presburger + qed + + text \$\dots = \sum_{h \leq j} f_hg_{i+1-h}f_jg_{i+1-j} + \sum_{h \leq j} f_{j+1}g_{i-j}f_{h-2}g_{i+2-h} + + \sum_h f_hg_{i+1-h}f_{h-1}g_{i+2-h} - \sum_{h \leq j} f_hg_{i+2-h}f_jg_{i-j} + - \sum_{h \leq j} f_{j+1}g_{i+1-j}f_{h-2}g_{i+1-h} - \sum_h f_hg_{i+2-h}f_{h-1}g_{i+1-h}$\ + also have "... = + (\(h, j)\{(h, j). j \ i + 1 \ h \ j}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j)) + + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j+1) * coeff g (i - j) * coeff f (h-1) * coeff g (i + 2 - h)) + + (\h\{1..i+1}. + coeff f h * coeff g (i + 1 - h) * coeff f (h-1) * coeff g (i + 2 - h)) - + ((\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j)) + + (\(h, j)\{(h, j). j \ i + 1 \ h \ j \ 0 < h}. + coeff f (j+1) * coeff g (i + 1 - j) * coeff f (h-1) * coeff g (i + 1 - h)) + + (\h\{1..i+1}. + coeff f h * coeff g (i + 2 - h) * coeff f (h-1) * coeff g (i + 1 - h)))" + proof - + have "(\(h, j)\{(h, j). h \ i + 1 \ j < h}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j)) = + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i - j) * coeff f (h - 1) * coeff g (i + 2 - h)) + + (\h = 1..i + 1. coeff f h * coeff g (i + 1 - h) * coeff f (h - 1) * coeff g (i + 2 - h))" + proof - + have 1: "(\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i - j) * coeff f (h - 1) * coeff g (i + 2 - h)) = + (\(h, j)\{(h, j). h \ i + 1 \ j < h \ h \ j + 1}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j))" + proof (rule sum.reindex_cong) + show "{(h, j). j \ i \ h \ j \ 0 < h} = (\(h, j). (j+1, h-1)) ` {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" + proof + show "(\(h, j). (j + 1, h - 1)) ` {(h, j). h \ i + 1 \ j < h \ h \ j + 1} \ {(h, j). j \ i \ h \ j \ 0 < h}" + by fastforce + show "{(h, j). j \ i \ h \ j \ 0 < h} \ (\(h, j). (j + 1, h - 1)) ` {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" + proof + fix x + assume "x \ {(h, j). j \ i \ h \ j \ 0 < h}" + then obtain h j where "x = (h, j)" "j \ i" "h \ j" "0 < h" by blast + hence "j + 1 \ i + 1 \ h - 1 < j + 1 \ j + 1 \ h - 1 + 1 \ x = ((h - 1) + 1, (j + 1) - 1)" + by auto + thus "x \ (\(h, j). (j + 1, h - 1)) ` {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" + by (auto simp: image_iff) + qed + qed + show "inj_on (\(h, j). (j + 1, h - 1)) {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" + proof + fix x y::"nat\nat" + assume "x \ {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" "y \ {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" + thus "(case x of (h, j) \ (j + 1, h - 1)) = (case y of (h, j) \ (j + 1, h - 1)) \ x = y" + by auto + qed + show "\x. x \ {(h, j). h \ i + 1 \ j < h \ h \ j + 1} \ + (case case x of (h, j) \ (j + 1, h - 1) of + (h, j) \ coeff f (j + 1) * coeff g (i - j) * coeff f (h - 1) * coeff g (i + 2 - h)) = + (case x of (h, j) \ coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j))" + by fastforce + qed + have 2: "(\h = 1..i + 1. coeff f h * coeff g (i + 1 - h) * coeff f (h - 1) * coeff g (i + 2 - h)) = + (\(h, j)\{(h, j). h \ i + 1 \ j < h \ h = j + 1}. + coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j))" + proof (rule sum.reindex_cong) + show "{1..i + 1} = fst ` {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + proof + show "{1..i + 1} \ fst ` {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + proof + fix x + assume "x \ {1..i + 1}" + hence "x \ i + 1 \ x - 1 < x \ x = x - 1 + 1 \ x = fst (x, x-1)" + by auto + thus "x \ fst ` {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + by blast + qed + show "fst ` {(h, j). h \ i + 1 \ j < h \ h = j + 1} \ {1..i + 1}" + by force + qed + show "inj_on fst {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + proof + fix x y + assume "x \ {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + "y \ {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + hence "x = (fst x, fst x - 1)" "y = (fst y, fst y - 1)" "fst x > 0" "fst y > 0" + by auto + thus "fst x = fst y \ x = y" by presburger + qed + show "\x. x \ {(h, j). h \ i + 1 \ j < h \ h = j + 1} \ + coeff f (fst x) * coeff g (i + 1 - fst x) * coeff f (fst x - 1) * coeff g (i + 2 - fst x) = + (case x of (h, j) \ coeff f h * coeff g (i + 1 - h) * coeff f j * coeff g (i + 1 - j))" + by fastforce + qed + have H: "{(h, j). h \ i + 1 \ j < h \ h \ j + 1} \ {0..i+1}\{0..i+1}" + "{(h, j). h \ i + 1 \ j < h \ h = j + 1} \ {0..i+1}\{0..i+1}" + "finite ({0..i+1}\{0..i+1})" + by (fastforce, fastforce, fastforce) + have "finite {(h, j). h \ i + 1 \ j < h \ h \ j + 1}" + "finite {(h, j). h \ i + 1 \ j < h \ h = j + 1}" + apply (rule finite_subset) using H apply (simp, simp) + apply (rule finite_subset) using H apply (simp, simp) + done + thus ?thesis + apply (subst 1, subst 2, subst sum.union_disjoint[symmetric]) + apply auto[3] + apply (rule sum.cong) + by auto + qed + moreover have "(\(h, j)\{(h, j). h \ i + 2 \ j < h \ j \ i}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j)) = + (\(h, j)\{(h, j). j \ i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) + + (\h = 1..i + 1. coeff f h * coeff g (i + 2 - h) * coeff f (h - 1) * coeff g (i + 1 - h))" + proof - + have 1: "(\(h, j)\{(h, j). j \ i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) = + (\(h, j)\{(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j))" + proof (rule sum.reindex_cong) + show "{(h, j). j \ i + 1 \ h \ j \ 0 < h} = (\(h, j). (j+1, h-1)) ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" + proof + show "(\(h, j). (j + 1, h - 1)) ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1} \ {(h, j). j \ i + 1 \ h \ j \ 0 < h}" + by fastforce + show "{(h, j). j \ i + 1 \ h \ j \ 0 < h} \ (\(h, j). (j + 1, h - 1)) ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" + proof + fix x + assume "x \ {(h, j). j \ i + 1 \ h \ j \ 0 < h}" + then obtain h j where "x = (h, j)" "j \ i + 1" "h \ j" "0 < h" by blast + hence "j + 1 \ i + 2 \ h - 1 < j + 1 \ h - 1 \ i \ j + 1 \ h - 1 + 1 \ x = ((h - 1) + 1, (j + 1) - 1)" + by auto + thus "x \ (\(h, j). (j + 1, h - 1)) ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" + by (auto simp: image_iff) + qed + qed + show "inj_on (\(h, j). (j + 1, h - 1)) {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" + proof + fix x y::"nat\nat" + assume "x \ {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" "y \ {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" + thus "(case x of (h, j) \ (j + 1, h - 1)) = (case y of (h, j) \ (j + 1, h - 1)) \ x = y" + by auto + qed + show "\x. x \ {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1} \ + (case case x of (h, j) \ (j + 1, h - 1) of + (h, j) \ coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) = + (case x of (h, j) \ coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j))" + by fastforce + qed + have 2: "(\h = 1..i + 1. coeff f h * coeff g (i + 2 - h) * coeff f (h - 1) * coeff g (i + 1 - h)) = + (\(h, j)\{(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}. + coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j))" + proof (rule sum.reindex_cong) + show "{1..i + 1} = fst ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + proof + show "{1..i + 1} \ fst ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + proof + fix x + assume "x \ {1..i + 1}" + hence "x \ i + 2 \ x - 1 < x \ x - 1 \ i \ x = x - 1 + 1 \ x = fst (x, x-1)" + by auto + thus "x \ fst ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + by blast + qed + show "fst ` {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1} \ {1..i + 1}" + by force + qed + show "inj_on fst {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + proof + fix x y + assume "x \ {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + "y \ {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + hence "x = (fst x, fst x - 1)" "y = (fst y, fst y - 1)" "fst x > 0" "fst y > 0" + by auto + thus "fst x = fst y \ x = y" by presburger + qed + show "\x. x \ {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1} \ + coeff f (fst x) * coeff g (i + 2 - fst x) * coeff f (fst x - 1) * coeff g (i + 1 - fst x) = + (case x of (h, j) \ coeff f h * coeff g (i + 2 - h) * coeff f j * coeff g (i - j))" + by fastforce + qed + have H: "{(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1} \ {0..i+2}\{0..i}" + "{(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1} \ {0..i+2}\{0..i}" + "finite ({0..i+2}\{0..i})" + by (fastforce, fastforce, fastforce) + have "finite {(h, j). h \ i + 2 \ j < h \ j \ i \ h \ j + 1}" + "finite {(h, j). h \ i + 2 \ j < h \ j \ i \ h = j + 1}" + apply (rule finite_subset) using H apply (simp, simp) + apply (rule finite_subset) using H apply (simp, simp) + done + thus ?thesis + apply (subst 1, subst 2, subst sum.union_disjoint[symmetric]) + apply auto[3] + apply (rule sum.cong) + by auto + qed + ultimately show ?thesis + by algebra + qed + + text \$\dots = \sum_{h \leq j} f_hf_j\left(g_{i+1-h}g_{i+1-j} - g_{i+2-h}g_{i-j}\right) + + \sum_{h \leq j} f_{j+1}f_{h-1}\left(g_{i-j}g_{i+2-h} - g_{i+1-j}f_jg_{i+1-h}\right)$ + + Note we have to also consider the edge cases caused by making these sums finite.\ + also have "... = + (\(h, j)\{(h, j). j = i + 1 \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) + + (\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j))) + + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j+1) * coeff f (h-1) * (coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h))) - + ((\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j+1) * coeff g (i + 1 - j) * coeff f (h-1) * coeff g (i + 1 - h)))" (is "?L = ?R") + proof - + have "?R = + (\(h, j)\{(h, j). j = i + 1 \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) + + ((\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * coeff g (i + 1 - h) * coeff g (i + 1 - j)) - + (\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * coeff g (i + 2 - h) * coeff g (i - j))) + + ((\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j+1) * coeff f (h-1) * coeff g (i - j) * coeff g (i + 2 - h)) - + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j+1) * coeff f (h-1) * coeff g (i + 1 - j) * coeff g (i + 1 - h))) - + ((\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j+1) * coeff g (i + 1 - j) * coeff f (h-1) * coeff g (i + 1 - h)))" + apply (subst sum_subtractf[symmetric], subst sum_subtractf[symmetric]) + by (auto simp: algebra_simps split_beta) + also have "... = + ((\(h, j)\{(h, j). j = i + 1 \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) + + (\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j)))) - + (\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * coeff g (i + 2 - h) * coeff g (i - j)) + + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff f (h - 1) * coeff g (i - j) * coeff g (i + 2 - h)) - + ((\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) + + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)))" + by (auto simp: algebra_simps) + also have "... = ?L" + proof - + have "(\(h, j)\{(h, j). j = i + 1 \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) + + (\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) = + (\(h, j)\{(h, j). j \ i + 1 \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j)))" + proof (subst sum.union_disjoint[symmetric]) + have "{(h, j). j = i + 1 \ h \ j} \ {..i + 1} \ {..i + 1}" + "{(h, j). j \ i \ h \ j} \ {..i + 1} \ {..i + 1}" + by (fastforce, fastforce) + thus "finite {(h, j). j = i + 1 \ h \ j}" "finite {(h, j). j \ i \ h \ j}" + by (auto simp: finite_subset) + show "{(h, j). j = i + 1 \ h \ j} \ {(h, j). j \ i \ h \ j} = {}" + by fastforce + qed (rule sum.cong, auto) + moreover have "(\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) + + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) = + (\(h, j)\{(h, j). j \ i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h))" + proof (subst sum.union_disjoint[symmetric]) + have "{(h, j). j \ i \ h \ j \ 0 < h} \ {..i + 1} \ {..i + 1}" + "{(h, j). j = i + 1 \ h \ j \ 0 < h} \ {..i + 1} \ {..i + 1}" + by (fastforce, fastforce) + thus "finite {(h, j). j \ i \ h \ j \ 0 < h}" "finite {(h, j). j = i + 1 \ h \ j \ 0 < h}" + by (auto simp: finite_subset) + show "{(h, j). j \ i \ h \ j \ 0 < h} \ {(h, j). j = i + 1 \ h \ j \ 0 < h} = {}" + by fastforce + qed (rule sum.cong, auto) + ultimately show ?thesis + by (auto simp: algebra_simps) + qed + finally show ?thesis by presburger + qed + + text \$\dots = \sum_{h \leq j} \left(f_hf_j - f_{j+1}f_{h-1}\right) + \left(g_{i+1-h}g_{i+1-j} - g_{i+2-h}g_{i-j}\right)$\ + also have "... = + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + -(coeff f h * coeff f j - coeff f (j+1) * coeff f (h-1)) * (coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h))) + + (\(h, j)\{(h, j). j \ i \ h \ j \ h = 0}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j))) + + (\(h, j)\{(h, j). j = i + 1 \ h \ j}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) - + ((\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j+1) * coeff g (i + 1 - j) * coeff f (h-1) * coeff g (i + 1 - h)))" (is "?L = ?R") + proof - + have "(\(h, j)\{(h, j). j \ i \ h \ j}. + coeff f h * coeff f j * + (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j))) = + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f h * coeff f j * + (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j))) + + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 = h}. + coeff f h * coeff f j * + (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j)))" + proof (subst sum.union_disjoint[symmetric]) + have "{(h, j). j \ i \ h \ j \ 0 < h} \ {..i}\{..i}" "{(h, j). j \ i \ h \ j \ 0 = h} \ {..i}\{..i}" + by (force, force) + thus "finite {(h, j). j \ i \ h \ j \ 0 < h}" "finite {(h, j). j \ i \ h \ j \ 0 = h}" + by (auto simp: finite_subset) + show "{(h, j). j \ i \ h \ j \ 0 < h} \ {(h, j). j \ i \ h \ j \ 0 = h} = {}" + by fast + qed (rule sum.cong, auto) + + moreover have "(\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + (-coeff f h * coeff f j + coeff f (j + 1) * coeff f (h - 1)) * + (coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h))) = + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j))) + + (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff f (h - 1) * + (coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h)))" + by (subst sum.distrib[symmetric], rule sum.cong, fast, auto simp: algebra_simps) + + ultimately show ?thesis + by (auto simp: algebra_simps) + qed + + text \$\dots \geq 0$ by \normal_poly_general_coeff_mult\\ + also have "... \ 0" + proof - + have "0 \ (\(h, j)\{(h, j). j \ i \ h \ j \ 0 < h}. + - (coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1)) * + (coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h)))" + proof (rule sum_nonneg) + fix x assume "x \ {(h, j). j \ i \ h \ j \ 0 < h}" + then obtain h j where H: "x = (h, j)" "j \ i" "h \ j" "0 < h" by fast + hence "h - 1 \ j - 1" by force + hence 1: "coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1) \ 0" + using normal_poly_general_coeff_mult[OF hf, of "h-1" "j-1"] H + by (auto simp: algebra_simps) + from H have "i - j \ i - h" by force + hence 2: "coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h) \ 0" + using normal_poly_general_coeff_mult[OF hg, of "i - j" "i - h"] H + by (smt (verit, del_insts) Nat.add_diff_assoc2 le_trans) + show "0 \ (case x of + (h, j) \ + - (coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1)) * + (coeff g (i - j) * coeff g (i + 2 - h) - + coeff g (i + 1 - j) * coeff g (i + 1 - h)))" + apply (subst H(1), subst split, rule mult_nonpos_nonpos, subst neg_le_0_iff_le) + subgoal using 1 by blast + subgoal using 2 by blast + done + qed + moreover have "0 \ (\(h, j)\{(h, j). j \ i \ h \ j \ h = 0}. + coeff f h * coeff f j * + (coeff g (i + 1 - h) * coeff g (i + 1 - j) - coeff g (i + 2 - h) * coeff g (i - j)))" + proof (rule sum_nonneg) + fix x assume "x \ {(h, j). j \ i \ h \ j \ h = 0}" + then obtain h j where H: "x = (h, j)" "j \ i" "h \ j" "h = 0" by fast + have 1: "coeff f h * coeff f j \ 0" + by (simp add: hf normal_coeff_nonneg) + from H have "i - j \ i - h" by force + hence 2: "coeff g (i - j) * coeff g (i + 2 - h) - coeff g (i + 1 - j) * coeff g (i + 1 - h) \ 0" + using normal_poly_general_coeff_mult[OF hg, of "i - j" "i - h"] H + by (smt (verit, del_insts) Nat.add_diff_assoc2 le_trans) + show "0 \ (case x of + (h, j) \ + coeff f h * coeff f j * + (coeff g (i + 1 - h) * coeff g (i + 1 - j) - + coeff g (i + 2 - h) * coeff g (i - j)))" + apply (subst H(1), subst split, rule mult_nonneg_nonneg) + subgoal using 1 by blast + subgoal using 2 by argo + done + qed + moreover have "0 \ (\(h, j)\{(h, j). j = i + 1 \ h \ j}. coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) - + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h))" + proof - + have "(\(h, j)\{(h, j). j = i + 1 \ h \ j}. coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) - + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) = + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ h = 0}. coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) + + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) - + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h))" + proof (subst sum.union_disjoint[symmetric]) + have "{(h, j). j = i + 1 \ h \ j \ h = 0} = {(0, i + 1)}" + "{(h, j). j = i + 1 \ h \ j \ 0 < h} = {1..i+1} \ {i + 1}" + by (fastforce, force) + thus "finite {(h, j). j = i + 1 \ h \ j \ h = 0}" + "finite {(h, j). j = i + 1 \ h \ j \ 0 < h}" + by auto + show "{(h, j). j = i + 1 \ h \ j \ h = 0} \ {(h, j). j = i + 1 \ h \ j \ 0 < h} = {}" + by fastforce + have "{(h, j). j = i + 1 \ h \ j \ h = 0} \ {(h, j). j = i + 1 \ h \ j \ 0 < h} = {(h, j). j = i + 1 \ h \ j}" + by fastforce + thus "(\(h, j)\{(h, j). j = i + 1 \ h \ j}. coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) - + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h)) = + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ h = 0} \ {(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) - + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + coeff f (j + 1) * coeff g (i + 1 - j) * coeff f (h - 1) * coeff g (i + 1 - h))" + by presburger + qed + also have "... = + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ h = 0}. coeff f h * coeff f j * (coeff g (i + 1 - h) * coeff g (i + 1 - j))) + + (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + (coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1)) * (coeff g (i + 1 - h) * coeff g (i + 1 - j)))" + by (subst add_diff_eq[symmetric], subst sum_subtractf[symmetric], subst add_left_cancel, rule sum.cong, auto simp: algebra_simps) + also have "... \ 0" + proof (rule add_nonneg_nonneg) + show "0 \ (\(h, j)\{(h, j). j = i + 1 \ h \ j \ 0 < h}. + (coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1)) * + (coeff g (i + 1 - h) * coeff g (i + 1 - j)))" + proof (rule sum_nonneg) + fix x assume "x \ {(h, j). j = i + 1 \ h \ j \ 0 < h}" + then obtain h j where H: "x = (h, j)" "j = i + 1" "h \ j" "0 < h" by fast + hence "h - 1 \ j - 1" by force + hence 1: "coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1) \ 0" + using normal_poly_general_coeff_mult[OF hf, of "h-1" "j-1"] H + by (auto simp: algebra_simps) + hence 2: "0 \ coeff g (i + 1 - h) * coeff g (i + 1 - j)" + by (meson hg mult_nonneg_nonneg normal_coeff_nonneg) + show "0 \ (case x of + (h, j) \ + (coeff f h * coeff f j - coeff f (j + 1) * coeff f (h - 1)) * + (coeff g (i + 1 - h) * coeff g (i + 1 - j)))" + apply (subst H(1), subst split, rule mult_nonneg_nonneg) + subgoal using 1 by blast + subgoal using 2 by blast + done + qed + qed (rule sum_nonneg, auto simp: hf hg normal_coeff_nonneg)[1] + finally show ?thesis . + qed + ultimately show ?thesis by auto + qed + finally show "coeff (f * g) i * coeff (f * g) (i + 2) \ (coeff (f * g) (i + 1))\<^sup>2" by (auto simp: power2_eq_square) + qed + moreover have "\i j k. i \ j \ j \ k \ 0 < coeff (f*g) i \ 0 < coeff (f*g) k \ 0 < coeff (f*g) j" + proof - + fix j k + assume "0 < coeff (f * g) k" + hence "k \ degree (f * g)" using le_degree by force + moreover assume "j \ k" + ultimately have "j \ degree (f * g)" by auto + hence 1: "j \ degree f + degree g" + by (simp add: degree_mult_eq hf hg normal_non_zero) + show "0 < coeff (f * g) j" + apply (subst coeff_mult, rule sum_pos2[of _ "min j (degree f)"], simp, simp) + apply (rule mult_pos_pos, rule normal_of_no_zero_root, simp add: hf0, simp) + using hf apply auto[1] + apply (rule normal_of_no_zero_root) + apply (simp add: hg0) + using 1 apply force + using hg apply auto[1] + by (simp add: hf hg normal_coeff_nonneg) + qed + ultimately show "normal_poly (f*g)" + by (rule normal_polyI) + qed + qed + qed +qed + +lemma normal_poly_of_roots: + fixes p::"real poly" + assumes "\z. poly (map_poly complex_of_real p) z = 0 + \ Re z \ 0 \ 4*(Re z)^2 \ (cmod z)^2" + and "lead_coeff p = 1" + shows "normal_poly p" + using assms +proof (induction p rule: real_poly_roots_induct) + fix p::"real poly" and x::real + assume "lead_coeff (p * [:- x, 1:]) = 1" + hence 1: "lead_coeff p = 1" + by (metis coeff_degree_mult lead_coeff_pCons(1) mult_cancel_left1 pCons_one zero_neq_one) + assume h: "(\z. poly (map_poly complex_of_real (p * [:- x, 1:])) z = 0 \ + Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2)" + hence 2: "(\z. poly (map_poly complex_of_real p) z = 0 \ + Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2)" + by (metis (no_types, hide_lams) four_x_squared mult.commute mult_cancel_left1 of_real_poly_map_mult poly_mult) + have 3: "normal_poly [:-x, 1:]" + apply (subst linear_normal_iff, + subst Re_complex_of_real[symmetric], rule conjunct1) + by (rule h[of x], subst of_real_poly_map_poly[symmetric], force) + assume "(\z. poly (map_poly complex_of_real p) z = 0 + \ Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2) \ + lead_coeff p = 1 \ normal_poly p" + hence "normal_poly p" using 1 2 by fast + then show "normal_poly (p * [:-x, 1:])" + using 3 by (rule normal_mult) +next + fix p::"real poly" and a b::real + assume "lead_coeff (p * [:a * a + b * b, - 2 * a, 1:]) = 1" + hence 1: "lead_coeff p = 1" + by (smt (verit) coeff_degree_mult lead_coeff_pCons(1) mult_cancel_left1 pCons_eq_0_iff pCons_one) + assume h: "(\z. poly (map_poly complex_of_real (p * [:a * a + b * b, - 2 * a, 1:])) z = 0 \ + Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2)" + hence 2: "(\z. poly (map_poly complex_of_real p) z = 0 \ + Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2)" + proof - + fix z :: complex + assume "poly (map_poly complex_of_real p) z = 0" + then have "\q. 0 = poly (map_poly complex_of_real (p * q)) z" + by simp + then show "Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2" + using h by presburger + qed + have 3: "[:a * a + b * b, - 2 * a, 1:] = [:cmod (a + \*b) ^ 2, -2 * Re (a + \*b), 1:]" + by (force simp: cmod_def power2_eq_square) + interpret map_poly_idom_hom complex_of_real .. + have 4: "normal_poly [:a * a + b * b, - 2 * a, 1:]" + apply (subst 3, subst quadratic_normal_iff) + apply (rule h, unfold hom_mult poly_mult) + by (auto simp: algebra_simps) + assume "(\z. poly (map_poly complex_of_real p) z = 0 \ Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2) \ + lead_coeff p = 1 \ normal_poly p" + hence "normal_poly p" using 1 2 by fast + then show "normal_poly (p * [:a * a + b * b, - 2 * a, 1:])" + using 4 by (rule normal_mult) +next + fix a::real + assume "lead_coeff [:a:] = 1" + moreover have "\i j k. + lead_coeff [:a:] = 1 \ + i \ j \ + j \ k \ 0 < coeff [:a:] i \ 0 < coeff [:a:] k \ 0 < coeff [:a:] j" + by (metis bot_nat_0.extremum_uniqueI coeff_eq_0 degree_pCons_0 leI + less_numeral_extra(3)) + ultimately show "normal_poly [:a:]" + apply (subst normal_polyI) + by (auto simp:pCons_one) +qed + +lemma normal_changes: + fixes f::"real poly" + assumes hf: "normal_poly f" and hx: "x > 0" + defines "df \ degree f" + shows "changes (coeffs (f*[:-x,1:])) = 1" + using df_def hf +proof (induction df arbitrary: f) + case 0 + then obtain a where "f = [:a:]" using degree_0_iff by auto + thus "changes (coeffs (f*[:-x, 1:])) = 1" + using normal_non_zero[OF \normal_poly f\] hx + by (auto simp: algebra_simps zero_less_mult_iff mult_less_0_iff) +next + case (Suc df) + then show ?case + proof (cases "poly f 0 = 0") + assume "poly f 0 = 0" and hf:"normal_poly f" + moreover then obtain f' where hdiv: "f = f'*[:0, 1:]" + by (smt (verit) dvdE mult.commute poly_eq_0_iff_dvd) + ultimately have hf': "normal_poly f'" using normal_divide_x by blast + assume "Suc df = degree f" + hence "degree f' = df" using hdiv normal_non_zero[OF hf'] by (auto simp: degree_mult_eq) + moreover assume "\f::real poly. df = degree f \ normal_poly f \ changes (coeffs (f * [:- x, 1:])) = 1" + ultimately have "changes (coeffs (f' * [:- x, 1:])) = 1" using hf' by fast + thus "changes (coeffs (f * [:- x, 1:])) = 1" + apply (subst hdiv, subst mult_pCons_right, subst smult_0_left, subst add_0) + apply (subst mult_pCons_left, subst smult_0_left, subst add_0) + by (subst changes_pCons, auto) + next + assume hf:"normal_poly f" and "poly f 0 \ 0" + hence h': "\i. i \ degree f \ coeff f i > 0" + by (auto simp: normal_of_no_zero_root) + hence "\i. i < degree f - 1 \ (coeff f i)/(coeff f (i+1)) \ (coeff f (i+1))/(coeff f (i+2))" + using normal_poly_coeff_mult[OF hf] normal_coeff_nonneg[OF hf] + by (auto simp: divide_simps power2_eq_square) + hence h'': "\i. i < degree f - 1 \ (coeff f i)/(coeff f (i+1)) - x \ (coeff f (i+1))/(coeff f (i+2)) - x" + by fastforce + have hdeg: "degree (pCons 0 f - smult x f) = degree f + 1" + apply (subst diff_conv_add_uminus) + apply (subst degree_add_eq_left) + by (auto simp: hf normal_non_zero) + + let ?f = "\ z w. \i. if i=0 then z/(x * coeff f 0) else (if i = degree (pCons 0 f - smult x f) then w/(lead_coeff f) else inverse (coeff f i))" + + have 1: "\z w. 0 < z \ 0 < w \ changes (coeffs (f * [:-x, 1:])) = + changes (-z # map (\i. (coeff f (i-1))/(coeff f i) - x) [1..i. (coeff f (i-1))/(coeff f i) - x) [1..i. if i = 0 then -z else if i = degree (pCons 0 f - smult x f) then w else + (coeff f (i-1))/(coeff f i) - x) [0..i. coeff f (i - 1) / coeff f i - x) [1.. degree (pCons 0 f - smult x f)" + using hdeg Suc.hyps(2) by auto + then consider (a)"i = 0" | (b)"(0 < i \ i < degree (pCons 0 f - smult x f))" | + (c)"i = degree (pCons 0 f - smult x f)" + by fastforce + then show "(- z # + map (\i. coeff f (i - 1) / coeff f i - x) + [1..i. if i = 0 then - z + else if i = degree (pCons 0 f - smult x f) then w + else coeff f (i - 1) / coeff f i - x) + [0.. [0.. set [0.. i \ i < degree (pCons 0 f - smult x f))" | + (c)"i = degree (pCons 0 f - smult x f)" + by fastforce + then show "(if i = 0 then - z + else if i = degree (pCons 0 f - smult x f) then w + else coeff f (i - 1) / coeff f i - x) = + (if i = 0 then z / (x * coeff f 0) + else if i = degree (pCons 0 f - smult x f) then w / lead_coeff f + else inverse (coeff f i)) * + nth_default 0 (coeffs (f * [:- x, 1:])) i" + proof (cases) + case (a) + thus ?thesis using hx \poly f 0 \ 0\ by (auto simp: nth_default_coeffs_eq poly_0_coeff_0) + next + case (b) + thus ?thesis using hx h'[of i] hdeg + by (auto simp: field_simps nth_default_coeffs_eq coeff_pCons nat.split poly_0_coeff_0) + next + case (c) + thus ?thesis using hdeg by (auto simp: nth_default_coeffs_eq coeff_eq_0) + qed + qed force + + finally have 1: " - z # + map (\i. coeff f (i - 1) / coeff f i - x) [1..i. (if i = 0 then z / (x * coeff f 0) + else if i = degree (pCons 0 f - smult x f) then w / lead_coeff f + else inverse (coeff f i)) * + nth_default 0 (coeffs (f * [:- x, 1:])) i) + [0.. 0" using hdeg by force + + show "changes (coeffs (f * [:- x, 1:])) = + changes + (- z # + map (\i. coeff f (i - 1) / coeff f i - x) + [1..f * [:-x, 1:] \ 0\ + by (auto simp: length_coeffs) + done + qed + + hence "changes (coeffs (f * [:- x, 1:])) = + changes + (- (max 1 (-(coeff f 0 / coeff f 1 - x))) # + map (\i. coeff f (i - 1) / coeff f i - x) + [1..i. coeff f (i - 1) / coeff f i - x) [1.. i \ i < degree (pCons 0 f - smult x f) - 1" | + (c)"i = degree (pCons 0 f - smult x f) - 1" + by fastforce + then show "(- max 1 (- (coeff f 0 / coeff f 1 - x)) # + map (\i. coeff f (i - 1) / coeff f i - x) + [1.. (- max 1 (- (coeff f 0 / coeff f 1 - x)) # + map (\i. coeff f (i - 1) / coeff f i - x) + [1.. (coeff f (i - 1 + 1))\<^sup>2" + by (rule normal_poly_coeff_mult[OF hf, of "i - 1"]) + hence "coeff f (i - 1) / coeff f i \ coeff f i / coeff f (i + 1)" + using h'[of i] h'[of "i+1"] h'[of "i-1"] h' b hdeg + by (auto simp: power2_eq_square divide_simps) + then show ?thesis + using b by (auto simp: nth_append) + next + case c + then show ?thesis using hdeg by (auto simp: nth_append not_le) + qed + qed auto + + finally show "changes (coeffs (f * [:-x, 1:])) = 1" . + qed +qed + +end \ No newline at end of file diff --git a/thys/Three_Circles/ROOT b/thys/Three_Circles/ROOT new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/ROOT @@ -0,0 +1,12 @@ +chapter AFP + +session Three_Circles (AFP) = "HOL-Computational_Algebra" + + options [timeout = 600] + sessions + Budan_Fourier + Polynomial_Interpolation + theories + Three_Circles + document_files + "root.tex" + "root.bib" diff --git a/thys/Three_Circles/RRI_Misc.thy b/thys/Three_Circles/RRI_Misc.thy new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/RRI_Misc.thy @@ -0,0 +1,1101 @@ +section \Misc results about polynomials\ + +theory RRI_Misc imports + "HOL-Computational_Algebra.Computational_Algebra" + "Budan_Fourier.BF_Misc" + "Polynomial_Interpolation.Ring_Hom_Poly" +begin + +subsection \Misc\ + +declare pcompose_pCons[simp del] + +lemma Setcompr_subset: "\f P S. {f x | x. P x} \ S = (\ x. P x \ f x \ S)" + by blast + +lemma map_cong': + assumes "xs = map h ys" and "\y. y \ set ys \ f (h y) = g y" + shows "map f xs = map g ys" + using assms map_replicate_trivial by simp + +lemma nth_default_replicate_eq: + "nth_default dflt (replicate n x) i = (if i < n then x else dflt)" + by (auto simp: nth_default_def) + +lemma square_bounded_less: + fixes a b::"'a :: linordered_ring_strict" + shows "-a < b \ b < a \ b*b < a*a" + by (metis (no_types, lifting) leD leI minus_less_iff minus_mult_minus mult_strict_mono' + neg_less_eq_nonneg neg_less_pos verit_minus_simplify(4) zero_le_mult_iff zero_le_square) + +lemma square_bounded_le: + fixes a b::"'a :: linordered_ring_strict" + shows "-a \ b \ b \ a \ b*b \ a*a" + by (metis le_less minus_mult_minus square_bounded_less) + +context vector_space +begin + +lemma card_le_dim_spanning: + assumes BV: "B \ V" + and VB: "V \ span B" + and fB: "finite B" + and dVB: "dim V \ card B" + shows "independent B" +proof - + { + fix a + assume a: "a \ B" "a \ span (B - {a})" + from a fB have c0: "card B \ 0" + by auto + from a fB have cb: "card (B - {a}) = card B - 1" + by auto + { + fix x + assume x: "x \ V" + from a have eq: "insert a (B - {a}) = B" + by blast + from x VB have x': "x \ span B" + by blast + from span_trans[OF a(2), unfolded eq, OF x'] + have "x \ span (B - {a})" . + } + then have th1: "V \ span (B - {a})" + by blast + have th2: "finite (B - {a})" + using fB by auto + from dim_le_card[OF th1 th2] + have c: "dim V \ card (B - {a})" . + from c c0 dVB cb have False by simp + } + then show ?thesis + unfolding dependent_def by blast +qed + +end + +subsection \Misc results about polynomials\ + +lemma smult_power: "smult (x^n) (p^n) = smult x p ^ n" + apply (induction n) + subgoal by fastforce + by (metis (no_types, hide_lams) mult_smult_left mult_smult_right + power_Suc smult_smult) + +lemma reflect_poly_monom: "reflect_poly (monom n i) = monom n 0" + apply (induction i) + by (auto simp: coeffs_eq_iff coeffs_monom coeffs_reflect_poly) + +lemma poly_eq_by_eval: + fixes P Q :: "'a::{comm_ring_1,ring_no_zero_divisors,ring_char_0} poly" + assumes h: "\x. poly P x = poly Q x" shows "P = Q" +proof - + have "poly P = poly Q" using h by fast + thus ?thesis by (auto simp: poly_eq_poly_eq_iff) +qed + +lemma poly_binomial: + "[:(1::'a::comm_ring_1), 1:]^n = (\k\n. monom (of_nat (n choose k)) k)" +proof - + have "[:(1::'a::comm_ring_1), 1:]^n = (monom 1 1 + 1)^n" + by (metis (no_types, lifting) add.left_neutral add.right_neutral add_pCons + monom_altdef pCons_one power_one_right smult_1_left) + also have "... = (\k\n. of_nat (n choose k) * monom 1 1 ^ k)" + apply (subst binomial_ring) + by force + also have "... = (\k\n. monom (of_nat (n choose k)) k)" + by (auto simp: monom_altdef of_nat_poly) + finally show ?thesis . +qed + +lemma degree_0_iff: "degree P = 0 \ (\a. P = [:a:])" + by (meson degree_eq_zeroE degree_pCons_0) + +interpretation poly_vs: vector_space smult + by (simp add: vector_space_def smult_add_right smult_add_left) + +lemma degree_subspace: "poly_vs.subspace {x. degree x \ n}" + by (auto simp: poly_vs.subspace_def degree_add_le) + +lemma monom_span: + "poly_vs.span {monom 1 x | x. x \ p} = {(x::'a::field poly). degree x \ p}" +(is "?L = ?R") +proof + show "?L \ ?R" + proof + fix x assume "x \ ?L" + moreover have hfin: "finite {P. \x \ {..p}. P = monom 1 x}" + by auto + ultimately have + "x \ range (\u. \v\{monom 1 x | x. x \ {..p}}. smult (u v) v)" + by (simp add: poly_vs.span_finite) + hence "\ u. x = (\v\{monom 1 x | x. x \ {..p}}. smult (u v) v)" + by (auto simp: image_iff) + then obtain u + where p': "x = (\v\{monom 1 x | x. x \ {..p}}. smult (u v) v)" + by blast + have "\v. v \ {monom 1 x | x. x \ {..p}} \ degree (smult (u v) v) \ p" + by (auto simp add: degree_monom_eq) + hence "degree x \ p" using hfin + apply (subst p') + apply (rule degree_sum_le) + by auto + thus "x \ {x. degree x \ p}" by force + qed +next + show "?R \ ?L" + proof + fix x assume "x \ ?R" + hence "degree x \ p" by force + hence "x = (\i\p. monom (coeff x i) i)" + by (simp add: poly_as_sum_of_monoms') + also have + "... = (\i\p. smult (coeff x (degree (monom (1::'a) i))) (monom 1 i))" + by (auto simp add: smult_monom degree_monom_eq) + also have + "... = (\v\{monom 1 x | x. x \ {..p}}. smult ((\v. coeff x (degree v)) v) v)" + proof (rule sum.reindex_cong) + show "inj_on degree {monom (1::'a) x |x. x \ {..p}}" + proof + fix x + assume "x \ {monom (1::'a) x |x. x \ {..p}}" + hence "\ a. x = monom 1 a" by blast + then obtain a where hx: "x = monom 1 a" by blast + fix y + assume "y \ {monom (1::'a) x |x. x \ {..p}}" + hence "\ b. y = monom 1 b" by blast + then obtain b where hy: "y = monom 1 b" by blast + assume "degree x = degree y" + thus "x = y" using hx hy by (simp add: degree_monom_eq) + qed + show "{..p} = degree ` {monom (1::'a) x |x. x \ {..p}}" + proof + show "{..p} \ degree ` {monom (1::'a) x |x. x \ {..p}}" + proof + fix x assume "x \ {..p}" + hence "monom (1::'a) x \ {monom 1 x |x. x \ {..p}}" by force + moreover have "degree (monom (1::'a) x) = x" + by (simp add: degree_monom_eq) + ultimately show "x \ degree ` {monom (1::'a) x |x. x \ {..p}}" by auto + qed + show "degree ` {monom (1::'a) x |x. x \ {..p}} \ {..p}" + by (auto simp add: degree_monom_eq) + qed + next + fix y assume "y \ {monom (1::'a) x |x. x \ {..p}}" + hence "\z \ {..p}. y = monom (1::'a) z" by blast + then obtain z where "y = monom (1::'a) z" by blast + thus + "smult (coeff x (degree (monom (1::'a) (degree y)))) (monom (1::'a) (degree y)) = + smult (coeff x (degree y)) y" + by (simp add: smult_monom degree_monom_eq) + qed + finally have "x = (\v\{monom 1 x | x. x \ {..p}}. + smult ((\v. coeff x (degree v)) v) v)" . + thus "x \ ?L" by (auto simp add: poly_vs.span_finite) + qed +qed + +lemma monom_independent: + "poly_vs.independent {monom (1::'a::field) x | x. x \ p}" +proof (rule poly_vs.independent_if_scalars_zero) + fix f::"'a poly \ 'a" + assume h: "(\x\{monom 1 x |x. x \ p}. smult (f x) x) = 0" + have h': "(\i\p. monom (f (monom (1::'a) i)) i) = + (\x\{monom (1::'a) x |x. x \ p}. smult (f x) x)" + proof (rule sum.reindex_cong) + show "inj_on degree {monom (1::'a) x |x. x \ p}" + by (smt (verit) degree_monom_eq inj_on_def mem_Collect_eq zero_neq_one) + show "{..p} = degree ` {monom (1::'a) x |x. x \ p}" + proof + show "{..p} \ degree ` {monom (1::'a) x |x. x \ p}" + proof + fix x assume "x \ {..p}" + then have "x = degree (monom (1::'a) x) \ x \ p" + by (auto simp: degree_monom_eq) + thus "x \ degree ` {monom (1::'a) x |x. x \ p}" + by blast + qed + show "degree ` {monom (1::'a) x |x. x \ p} \ {..p}" + by (force simp: degree_monom_eq) + qed + qed (auto simp: degree_monom_eq smult_monom) + + fix x::"'a poly" + assume "x \ {monom 1 x |x. x \ p}" + then obtain y where "y \ p" and "x = monom 1 y" by blast + hence "f x = coeff (\x\{monom 1 x |x. x \ p}. smult (f x) x) y" + by (auto simp: coeff_sum h'[symmetric]) + thus "f x = 0" + using h by auto +qed force + +lemma dim_degree: "poly_vs.dim {x. degree x \ n} = n + 1" + using poly_vs.dim_eq_card_independent[OF monom_independent] + by (auto simp: monom_span[symmetric] card_image image_Collect[symmetric] + inj_on_def monom_eq_iff') + +lemma degree_div: + fixes p q::"('a::idom_divide) poly" + assumes "q dvd p" + shows "degree (p div q) = degree p - degree q" using assms + by (metis (no_types, lifting) add_diff_cancel_left' degree_0 degree_mult_eq + diff_add_zero diff_zero div_by_0 dvd_div_eq_0_iff dvd_mult_div_cancel) + +lemma lead_coeff_div: + fixes p q::"('a::{idom_divide, inverse}) poly" + assumes "q dvd p" + shows "lead_coeff (p div q) = lead_coeff p / lead_coeff q" using assms + by (smt (z3) div_by_0 dvd_div_mult_self lead_coeff_mult leading_coeff_0_iff + nonzero_mult_div_cancel_right) + +lemma complex_poly_eq: + "r = map_poly of_real (map_poly Re r) + smult \ (map_poly of_real (map_poly Im r))" + by (auto simp: poly_eq_iff coeff_map_poly complex_eq) + +lemma complex_poly_cong: + "(map_poly Re p = map_poly Re q \ map_poly Im p = map_poly Im q) = (p = q)" + by (metis complex_poly_eq) + +lemma map_poly_Im_of_real: "map_poly Im (map_poly of_real p) = 0" + by (auto simp: poly_eq_iff coeff_map_poly) + +lemma mult_map_poly_imp_map_poly: + assumes "map_poly complex_of_real q = r * map_poly complex_of_real p" + "p \ 0" + shows "r = map_poly complex_of_real (map_poly Re r)" +proof - + have h: "Im \ (*) \ \ complex_of_real = id" by fastforce + have "map_poly complex_of_real q = r * map_poly complex_of_real p" + using assms by blast + also have "... = (map_poly of_real (map_poly Re r) + + smult \ (map_poly of_real (map_poly Im r))) * + map_poly complex_of_real p" + using complex_poly_eq by fastforce + also have "... = map_poly of_real (map_poly Re r * p) + + smult \ (map_poly of_real (map_poly Im r * p))" + by (simp add: mult_poly_add_left) + finally have "map_poly complex_of_real q = + map_poly of_real (map_poly Re r * p) + + smult \ (map_poly of_real (map_poly Im r * p))" . + hence "0 = map_poly Im (map_poly of_real (map_poly Re r * p) + + smult \ (map_poly of_real (map_poly Im r * p)))" + by (auto simp: complex_poly_cong[symmetric] map_poly_Im_of_real) + also have "... = map_poly of_real (map_poly Im r * p)" + apply (rule poly_eqI) + by (auto simp: coeff_map_poly coeff_mult) + finally have "0 = map_poly complex_of_real (map_poly Im r) * + map_poly complex_of_real p" + by auto + hence "map_poly complex_of_real (map_poly Im r) = 0" using assms by fastforce + thus ?thesis apply (subst complex_poly_eq) by auto +qed + +lemma map_poly_dvd: + fixes p q::"real poly" + assumes hdvd: "map_poly complex_of_real p dvd + map_poly complex_of_real q" "q \ 0" + shows "p dvd q" +proof - + from hdvd obtain r + where h:"map_poly complex_of_real q = r * map_poly complex_of_real p" + by fastforce + hence "r = map_poly complex_of_real (map_poly Re r)" + using mult_map_poly_imp_map_poly assms by force + hence "map_poly complex_of_real q = map_poly complex_of_real (p * map_poly Re r)" + using h by auto + hence "q = p * map_poly Re r" using of_real_poly_eq_iff by blast + thus "p dvd q" by force +qed + +lemma div_poly_eq_0: + fixes p q::"('a::idom_divide) poly" + assumes "q dvd p" "poly (p div q) x = 0" "q \ 0" + shows "poly p x = 0" + using assms by fastforce + +lemma poly_map_poly_of_real_cnj: + "poly (map_poly of_real p) (cnj z) = cnj (poly (map_poly of_real p) z)" + apply (induction p) + by auto + +text \ +An induction rule on real polynomials, if $P \neq 0$ then either $(X-x)|P$ or +$(X-z)(X-cnj z)|P$, we induct by dividing by these polynomials. +\ +lemma real_poly_roots_induct: + fixes P::"real poly \ bool" and p::"real poly" + assumes IH_real: "\p x. P p \ P (p * [:-x, 1:])" + and IH_complex: "\p a b. b \ 0 \ P p + \ P (p * [: a*a + b*b, -2*a, 1 :])" + and H0: "\a. P [:a:]" + defines "d \ degree p" + shows "P p" + using d_def +proof (induction d arbitrary: p rule: less_induct) + fix p::"real poly" + assume IH: "(\q. degree q < degree p \ P q)" + show "P p" + proof (cases "0 = degree p") + fix p::"real poly" assume "0 = degree p" + hence "\ a. p = [:a:]" + by (simp add: degree_0_iff) + thus "P p" using H0 by blast + next + assume hdeg: "0 \ degree p" + hence "\ constant (poly (map_poly of_real p))" + by (metis (no_types, hide_lams) constant_def constant_degree + of_real_eq_iff of_real_poly_map_poly) + then obtain z::complex where h: "poly (map_poly of_real p) z = 0" + using fundamental_theorem_of_algebra by blast + show "P p" + proof cases + assume "Im z = 0" + hence "z = Re z" by (simp add: complex_is_Real_iff) + moreover have "[:-z, 1:] dvd map_poly of_real p" + using h poly_eq_0_iff_dvd by blast + ultimately have "[:-(Re z), 1:] dvd p" + by (smt (z3) dvd_iff_poly_eq_0 h of_real_0 of_real_eq_iff of_real_poly_map_poly) + hence 2:"P (p div [:-Re z, 1:])" + apply (subst IH) + using hdeg by (auto simp: degree_div) + moreover have 1:"p = (p div [:- Re z, 1:]) * [:-Re z, 1:]" + by (metis \[:- Re z, 1:] dvd p\ dvd_div_mult_self) + ultimately show "P p" + apply (subst 1) + by (rule IH_real[OF 2]) + next + assume "Im z \ 0" + hence hcnj: "cnj z \ z" by (metis cnj.simps(2) neg_equal_zero) + have h2: "poly (map_poly of_real p) (cnj z) = 0" + using h poly_map_poly_of_real_cnj by force + have "[:-z, 1:] * [:-cnj z, 1:] dvd map_poly of_real p" + proof (rule divides_mult) + have "\c. c dvd [:-z, 1:] \ c dvd [:- cnj z, 1:] \ is_unit c" + proof - + fix c + assume h:"c dvd [:-z, 1:]" hence "degree c \ 1" using divides_degree by fastforce + hence "degree c = 0 \ degree c = 1" by linarith + thus "c dvd [:- cnj z, 1:] \ is_unit c" + proof + assume "degree c = 0" + moreover have "c \ 0" using h by fastforce + ultimately show "is_unit c" by (simp add: is_unit_iff_degree) + next + assume hdeg: "degree c = 1" + then obtain x where 1:"[:-z, 1:] = x*c" using h by fastforce + hence "degree [:-z, 1:] = degree x + degree c" + by (metis add.inverse_neutral degree_mult_eq mult_cancel_right + mult_poly_0_left pCons_eq_0_iff zero_neq_neg_one) + hence "degree x = 0" using hdeg by auto + then obtain x' where 2: "x = [:x':]" using degree_0_iff by auto + assume "c dvd [:-cnj z, 1:]" + then obtain y where 3: "[:-cnj z, 1:] = y*c" by fastforce + hence "degree [:-cnj z, 1:] = degree y + degree c" + by (metis add.inverse_neutral degree_mult_eq mult_cancel_right + mult_poly_0_left pCons_eq_0_iff zero_neq_neg_one) + hence "degree y = 0" using hdeg by auto + then obtain y' where 4: "y = [:y':]" using degree_0_iff by auto + moreover from hdeg obtain a b where 5:"c = [:a, b:]" and 6: "b \ 0" + by (meson degree_eq_oneE) + from 1 2 5 6 have "x' = inverse b" by (auto simp: field_simps) + moreover from 3 4 5 6 have "y' = inverse b" by (auto simp: field_simps) + ultimately have "x = y" using 2 4 by presburger + then have "z = cnj z" using 1 3 by (metis neg_equal_iff_equal pCons_eq_iff) + thus "is_unit c" using hcnj by argo + qed + qed + thus "coprime [:- z, 1:] [:- cnj z, 1:]" by (meson not_coprimeE) + show "[:- z, 1:] dvd map_poly complex_of_real p" + using h poly_eq_0_iff_dvd by auto + show "[:- cnj z, 1:] dvd map_poly complex_of_real p" + using h2 poly_eq_0_iff_dvd by blast + qed + moreover have "[:- z, 1:] * [:- cnj z, 1:] = + map_poly of_real [:Re z*Re z + Im z*Im z, -2*Re z, 1:]" + by (auto simp: complex_eqI) + ultimately have hdvd: + "map_poly complex_of_real [:Re z*Re z + Im z*Im z, -2*Re z, 1:] dvd + map_poly complex_of_real p" + by force + hence "[:Re z*Re z + Im z*Im z, -2*Re z, 1:] dvd p" using map_poly_dvd + by blast + hence 2:"P (p div [:Re z*Re z + Im z*Im z, -2*Re z, 1:])" + apply (subst IH) + using hdeg by (auto simp: degree_div) + moreover have 1: + "p = (p div [:Re z*Re z + Im z*Im z, -2*Re z, 1:]) * + [:Re z*Re z + Im z*Im z, -2*Re z, 1:]" + apply (subst dvd_div_mult_self) + using \[:Re z*Re z + Im z*Im z, -2*Re z, 1:] dvd p\ by auto + ultimately show "P p" + apply (subst 1) + apply (rule IH_complex[of "Im z" _ "Re z"]) + apply (meson \Im z \ 0\) + by blast + qed + qed +qed + +subsection \The reciprocal polynomial\ + +definition reciprocal_poly :: "nat \ 'a::zero poly \ 'a poly" + where "reciprocal_poly p P = + Poly (rev ((coeffs P) @ (replicate (p - degree P) 0)))" + +lemma reciprocal_0: "reciprocal_poly p 0 = 0" by (simp add: reciprocal_poly_def) + +lemma reciprocal_1: "reciprocal_poly p 1 = monom 1 p" + by (simp add: reciprocal_poly_def monom_altdef Poly_append) + +lemma coeff_reciprocal: + assumes hi: "i \ p" and hP: "degree P \ p" + shows "coeff (reciprocal_poly p P) i = coeff P (p - i)" +proof cases + assume "i < p - degree P" + hence "degree P < p - i" using hP by linarith + thus "coeff (reciprocal_poly p P) i = coeff P (p - i)" + by (auto simp: reciprocal_poly_def nth_default_append coeff_eq_0) +next + assume h: "\i < p - degree P" + show "coeff (reciprocal_poly p P) i = coeff P (p - i)" + proof cases + assume "P = 0" + thus "coeff (reciprocal_poly p P) i = coeff P (p - i)" + by (simp add: reciprocal_0) + next + assume hP': "P \ 0" + have "degree P \ p - i" using h hP by linarith + moreover hence "(i - (p - degree P)) < length (rev (coeffs P))" + using hP' hP hi by (auto simp: length_coeffs) + thus "coeff (reciprocal_poly p P) i = coeff P (p - i)" + by (auto simp: reciprocal_poly_def nth_default_append coeff_eq_0 hP hP' + nth_default_nth rev_nth calculation coeffs_nth length_coeffs_degree) + qed +qed + +lemma coeff_reciprocal_less: + assumes hn: "p < i" and hP: "degree P \ p" + shows "coeff (reciprocal_poly p P) i = 0" +proof cases + assume "P = 0" + thus ?thesis by (auto simp: reciprocal_0) +next + assume "P \ 0" + thus ?thesis + using hn + by (auto simp: reciprocal_poly_def nth_default_append + nth_default_eq_dflt_iff hP length_coeffs) +qed + +lemma reciprocal_monom: + assumes "n \ p" + shows "reciprocal_poly p (monom a n) = monom a (p-n)" +proof (cases "a=0") + case True + then show ?thesis by (simp add: reciprocal_0) +next + case False + with \n\p\ show ?thesis + apply (rule_tac poly_eqI) + by (metis coeff_monom coeff_reciprocal coeff_reciprocal_less + diff_diff_cancel diff_le_self lead_coeff_monom not_le_imp_less) +qed + +lemma reciprocal_degree: "reciprocal_poly (degree P) P = reflect_poly P" + by (auto simp add: reciprocal_poly_def reflect_poly_def) + +lemma degree_reciprocal: + fixes P :: "('a::zero) poly" + assumes hP: "degree P \ p" + shows "degree (reciprocal_poly p P) \ p" +proof (auto simp add: reciprocal_poly_def) + have "degree (reciprocal_poly p P) \ + length (replicate (p - degree P) (0::'a) @ rev (coeffs P))" + by (metis degree_Poly reciprocal_poly_def rev_append rev_replicate) + thus "degree (Poly (replicate (p - degree P) 0 @ rev (coeffs P))) \ p" + by (smt Suc_le_mono add_Suc_right coeffs_Poly degree_0 hP le_SucE le_SucI + le_add_diff_inverse2 le_zero_eq length_append length_coeffs_degree + length_replicate length_rev length_strip_while_le reciprocal_0 + reciprocal_poly_def rev_append rev_replicate) +qed + +lemma reciprocal_0_iff: + assumes hP: "degree P \ p" + shows "(reciprocal_poly p P = 0) = (P = 0)" +proof + assume h: "reciprocal_poly p P = 0" + show "P = 0" + proof (rule poly_eqI) + fix n + show "coeff P n = coeff 0 n" + proof cases + assume hn: "n \ p" + hence "p - n \ p" by auto + hence "coeff (reciprocal_poly p P) (p - n) = coeff P n" + using hP hn by (auto simp: coeff_reciprocal) + thus ?thesis using h by auto + next + assume hn: "\ n \ p" + thus ?thesis using hP by (metis coeff_0 dual_order.trans le_degree) + qed + qed +next + assume "P = 0" + thus "reciprocal_poly p P = 0" using reciprocal_0 by fast +qed + +lemma poly_reciprocal: + fixes P::"'a::field poly" + assumes hp: "degree P \ p" and hx: "x \ 0" + shows "poly (reciprocal_poly p P) x = x^p * (poly P (inverse x))" +proof - + have "poly (reciprocal_poly p P) x + = poly ((Poly ((replicate (p - degree P) 0) @ rev (coeffs P)))) x" + by (auto simp add: hx reflect_poly_def reciprocal_poly_def) + also have "... = poly ((monom 1 (p - degree P)) * (reflect_poly P)) x" + by (auto simp add: reflect_poly_def Poly_append) + also have "... = x^(p - degree P) * x ^ degree P * poly P (inverse x)" + by (auto simp add: poly_reflect_poly_nz poly_monom hx) + also have "... = x^p * poly P (inverse x)" + by (auto simp add: hp power_add[symmetric]) + finally show ?thesis . +qed + +lemma reciprocal_fcompose: + fixes P::"('a::{ring_char_0,field}) poly" + assumes hP: "degree P \ p" + shows "reciprocal_poly p P = monom 1 (p - degree P) * fcompose P 1 [:0, 1:]" +proof (rule poly_eq_by_eval, cases) + fix x::'a + assume hx: "x = 0" + hence "poly (reciprocal_poly p P) x = coeff P p" + using hP by (auto simp: poly_0_coeff_0 coeff_reciprocal) + moreover have "poly (monom 1 (p - degree P) + * fcompose P 1 [:0, 1:]) x = coeff P p" + proof cases + assume "degree P = p" + thus ?thesis + apply (induction P arbitrary: p) + using hx by (auto simp: poly_monom degree_0_iff fcompose_pCons) + next + assume "degree P \ p" + hence "degree P < p" using hP by auto + thus ?thesis + using hx by (auto simp: poly_monom coeff_eq_0) + qed + ultimately show "poly (reciprocal_poly p P) x = poly (monom 1 (p - degree P) * fcompose P 1 [:0, 1:]) x" + by presburger +next + fix x::'a assume "x \ 0" + thus "poly (reciprocal_poly p P) x = + poly (monom 1 (p - degree P) * fcompose P 1 [:0, 1:]) x" + using hP + by (auto simp: poly_reciprocal poly_fcompose inverse_eq_divide + poly_monom power_diff) +qed + +lemma reciprocal_reciprocal: + fixes P :: "'a::{field,ring_char_0} poly" + assumes hP: "degree P \ p" + shows "reciprocal_poly p (reciprocal_poly p P) = P" +proof (rule poly_eq_by_eval) + fix x + show "poly (reciprocal_poly p (reciprocal_poly p P)) x = poly P x" + proof cases + assume "x = 0" + thus "poly (reciprocal_poly p (reciprocal_poly p P)) x = poly P x" + using hP + by (auto simp: poly_0_coeff_0 coeff_reciprocal degree_reciprocal) + next + assume hx: "x \ 0" + hence "poly (reciprocal_poly p (reciprocal_poly p P)) x + = x ^ p * (inverse x ^ p * poly P x)" using hP + by (auto simp: poly_reciprocal degree_reciprocal) + thus "poly (reciprocal_poly p (reciprocal_poly p P)) x = poly P x" + using hP hx left_right_inverse_power right_inverse by auto + qed +qed + +lemma reciprocal_smult: + fixes P :: "'a::idom poly" + assumes h: "degree P \ p" + shows "reciprocal_poly p (smult n P) = smult n (reciprocal_poly p P)" +proof cases + assume "n = 0" + thus ?thesis by (auto simp add: reciprocal_poly_def) +next + assume "n \ 0" + thus ?thesis + by (auto simp add: reciprocal_poly_def smult_Poly coeffs_smult + rev_map[symmetric]) +qed + +lemma reciprocal_add: + fixes P Q :: "'a::comm_semiring_0 poly" + assumes "degree P \ p" and "degree Q \ p" + shows "reciprocal_poly p (P + Q) = reciprocal_poly p P + reciprocal_poly p Q" +(is "?L = ?R") +proof (rule poly_eqI, cases) + fix n + assume "n \ p" + then show "coeff ?L n = coeff ?R n" + using assms by (auto simp: degree_add_le coeff_reciprocal) +next + fix n assume "\n \ p" + then show "coeff ?L n = coeff ?R n" + using assms by (auto simp: degree_add_le coeff_reciprocal_less) +qed + +lemma reciprocal_diff: + fixes P Q :: "'a::comm_ring poly" + assumes "degree P \ p" and "degree Q \ p" + shows "reciprocal_poly p (P - Q) = reciprocal_poly p P - reciprocal_poly p Q" + by (metis (no_types, lifting) ab_group_add_class.ab_diff_conv_add_uminus assms + add_diff_cancel degree_add_le degree_minus diff_add_cancel reciprocal_add) + +lemma reciprocal_sum: + fixes P :: "'a \ 'b::comm_semiring_0 poly" + assumes hP: "\k. degree (P k) \ p" + shows "reciprocal_poly p (\k\A. P k) = (\k\A. reciprocal_poly p (P k))" +proof (induct A rule: infinite_finite_induct) + case (infinite A) + then show ?case by (simp add: reciprocal_0) +next + case empty + then show ?case by (simp add: reciprocal_0) +next + case (insert x F) + assume "x \ F" + and "reciprocal_poly p (sum P F) = (\k\F. reciprocal_poly p (P k))" + and "finite F" + moreover hence "reciprocal_poly p (sum P (insert x F)) + = reciprocal_poly p (P x) + reciprocal_poly p (sum P F)" + by (auto simp add: reciprocal_add hP degree_sum_le) + ultimately show "reciprocal_poly p (sum P (insert x F)) + = (\k\insert x F. reciprocal_poly p (P k))" + by (auto simp: Groups_Big.comm_monoid_add_class.sum.insert_if) +qed + +lemma reciprocal_mult: + fixes P Q::"'a::{ring_char_0,field} poly" + assumes "degree (P * Q) \ p" + and "degree P \ p" and "degree Q \ p" + shows "monom 1 p * reciprocal_poly p (P * Q) = + reciprocal_poly p P * reciprocal_poly p Q" +proof (cases "P=0 \ Q=0") + case True + then show ?thesis using assms(1) + by (auto simp: reciprocal_fcompose fcompose_mult) +next + case False + then show ?thesis + using assms + by (auto simp: degree_mult_eq mult_monom reciprocal_fcompose fcompose_mult) +qed + +lemma reciprocal_reflect_poly: + fixes P::"'a::{ring_char_0,field} poly" + assumes hP: "degree P \ p" + shows "reciprocal_poly p P = monom 1 (p - degree P) * reflect_poly P" +proof (rule poly_eqI) + fix n + show "coeff (reciprocal_poly p P) n = + coeff (monom 1 (p - degree P) * reflect_poly P) n" + proof cases + assume "n \ p" + thus ?thesis using hP + by (auto simp: coeff_reciprocal coeff_monom_mult coeff_reflect_poly coeff_eq_0) + next + assume "\ n \ p" + thus ?thesis using hP + by (auto simp: coeff_reciprocal_less coeff_monom_mult coeff_reflect_poly) + qed +qed + +lemma map_poly_reciprocal: + assumes "degree P \ p" and "f 0 = 0" + shows "map_poly f (reciprocal_poly p P) = reciprocal_poly p (map_poly f P)" +proof (rule poly_eqI) + fix n + show "coeff (map_poly f (reciprocal_poly p P)) n = + coeff (reciprocal_poly p (map_poly f P)) n" + proof (cases "n\p") + case True + then show ?thesis + apply (subst coeff_reciprocal[OF True]) + subgoal by (meson assms(1) assms(2) degree_map_poly_le le_trans) + by (simp add: assms(1) assms(2) coeff_map_poly coeff_reciprocal) + next + case False + then show ?thesis + by (metis assms(1) assms(2) coeff_map_poly coeff_reciprocal_less + degree_map_poly_le dual_order.trans leI) + qed +qed + +subsection \More about @{term proots_count}\ + +lemma proots_count_monom: + assumes "0 \ A" + shows "proots_count (monom 1 d) A = 0" + using assms by (auto simp: proots_count_def poly_monom) + +lemma proots_count_reciprocal: + fixes P::"'a::{ring_char_0,field} poly" + assumes hP: "degree P \ p" and h0: "P \ 0" and h0': "0 \ A" + shows "proots_count (reciprocal_poly p P) A = proots_count P {x. inverse x \ A}" +proof - + have "proots_count (reciprocal_poly p P) A = + proots_count (fcompose P 1 [:0, 1:]) A" + apply (subst reciprocal_fcompose[OF hP], subst proots_count_times) + subgoal using h0 by (metis hP reciprocal_0_iff reciprocal_fcompose) + subgoal using h0' by (auto simp: proots_count_monom) + done + + also have "... = proots_count P {x. inverse x \ A}" + proof (rule proots_fcompose_bij_eq[symmetric]) + show "bij_betw (\x. poly 1 x / poly [:0, 1:] x) A {x. inverse x \ A}" + proof (rule bij_betw_imageI) + show "inj_on (\x. poly 1 x / poly [:0, 1:] x) A" + by (simp add: inj_on_def) + + show "(\x. poly 1 x / poly [:0, 1:] x) ` A = {x. inverse x \ A}" + proof + show "(\x. poly 1 x / poly [:0, 1:] x) ` A \ {x. inverse x \ A}" + by force + show "{x. inverse x \ A} \ (\x. poly 1 x / poly [:0, 1:] x) ` A" + proof + fix x assume "x \ {x::'a. inverse x \ A}" + hence "x = poly 1 (inverse x) / poly [:0, 1:] (inverse x) \ inverse x \ A" + by (auto simp: inverse_eq_divide) + thus "x \ (\x. poly 1 x / poly [:0, 1:] x) ` A" by blast + qed + qed + qed + next + show "\c. 1 \ smult c [:0, 1:]" + by (metis coeff_pCons_0 degree_1 lead_coeff_1 pCons_0_0 pcompose_0' + pcompose_smult smult_0_right zero_neq_one) + qed (auto simp: assms infinite_UNIV_char_0) + finally show ?thesis by linarith +qed + +lemma proots_count_reciprocal': + fixes P::"real poly" + assumes hP: "degree P \ p" and h0: "P \ 0" + shows "proots_count P {x. 0 < x \ x < 1} = + proots_count (reciprocal_poly p P) {x. 1 < x}" +proof (subst proots_count_reciprocal) + show "proots_count P {x. 0 < x \ x < 1} = + proots_count P {x. inverse x \ Collect ((<) 1)}" + apply (rule arg_cong[of _ _ "proots_count P"]) + using one_less_inverse_iff by fastforce +qed (use assms in auto) + +lemma proots_count_pos: + assumes "proots_count P S > 0" + shows "\x \ S. poly P x = 0" +proof (rule ccontr) + assume "\ (\x\S. poly P x = 0)" + hence "\x. x \ S \ poly P x \ 0" by blast + hence "\x. x \ S \ order x P = 0" using order_0I by blast + hence "proots_count P S = 0" by (force simp: proots_count_def) + thus False using assms by presburger +qed + +lemma proots_count_of_root_set: + assumes "P \ 0" "R \ S" and "\x. x\R \ poly P x = 0" + shows "proots_count P S \ card R" +proof - + have "card R \ card (proots_within P S)" + apply (rule card_mono) + subgoal using assms by auto + subgoal using assms(2) assms(3) by (auto simp: proots_within_def) + done + also have "... \ proots_count P S" + by (rule card_proots_within_leq[OF assms(1)]) + finally show ?thesis . +qed + +lemma proots_count_of_root: assumes "P \ 0" "x\S" "poly P x = 0" + shows "proots_count P S > 0" + using proots_count_of_root_set[of P "{x}" S] assms by force + +subsection \More about @{term changes}\ + +lemma changes_nonneg: "0 \ changes xs" + apply (induction xs rule: changes.induct) + by simp_all + +lemma changes_replicate_0: shows "changes (replicate n 0) = 0" + apply (induction n) + by auto + +lemma changes_append_replicate_0: "changes (xs @ replicate n 0) = changes xs" +proof (induction xs rule: changes.induct) + case (2 uu) + then show ?case + apply (induction n) + by auto +qed (auto simp: changes_replicate_0) + +lemma changes_scale_Cons: + fixes xs:: "real list" assumes hs: "s > 0" + shows "changes (s * x # xs) = changes (x # xs)" + apply (induction xs rule: changes.induct) + using assms by (auto simp: mult_less_0_iff zero_less_mult_iff) + +lemma changes_scale: + fixes xs::"('a::linordered_idom) list" + assumes hs: "\i. i < n \ s i > 0" and hn: "length xs \ n" + shows "changes [s i * (nth_default 0 xs i). i \ [0..i. s i * nth_default 0 [uu] i) [0..i. s i * nth_default 0 [uu] i) [0..i. s i * nth_default 0 [uu] i) [0..i. s i * nth_default 0 (a # b # xs) i) [0..i. + (\ i. s (i+2)) i * nth_default 0 (xs) i) [0..a*b<0 \ \b=0" by linarith + then show ?case + proof (cases) + case neg + hence + "changes (map (\i. s i * nth_default 0 (a # b # xs) i) [0..i. (\ i. s (i+2)) i + * nth_default 0 (xs) i) [0..i. s (Suc i) * nth_default 0 (b # xs) i) [0.. x. 1 + changes x"]) + apply (induction m) + by auto + also have "... = changes (a # b # xs)" + apply (subst 3(1)[OF neg]) + using 3 neg hn by auto + finally show ?thesis . + next + case nil + hence "changes (map (\i. s i * nth_default 0 (a # b # xs) i) [0..i. (\ i. s (i+2)) i * nth_default 0 (xs) i) [0..i. s (if i = 0 then 0 else Suc i) * nth_default 0 (a # xs) i) + [0.. x. changes x"]) + apply (induction m) + by auto + also have "... = changes (a # b # xs)" + apply (subst 3(2)) + using 3 nil hn by auto + finally show ?thesis . + next + case pos + hence "changes (map (\i. s i * nth_default 0 (a # b # xs) i) [0..i. (\ i. s (i+2)) i * nth_default 0 (xs) i) [0..i. s (Suc i) * nth_default 0 (b # xs) i) [0.. x. changes x"]) + apply (induction m) + by auto + also have "... = changes (a # b # xs)" + apply (subst 3(3)) + using 3 pos hn by auto + finally show ?thesis . + qed +qed + +lemma changes_scale_const: fixes xs::"'a::linordered_idom list" + assumes hs: "s \ 0" + shows "changes (map ((*) s) xs) = changes xs" + apply (induction xs rule: changes.induct) + apply (simp, force) + using hs by (auto simp: mult_less_0_iff zero_less_mult_iff) + +lemma changes_snoc: fixes xs::"'a::linordered_idom list" + shows "changes (xs @ [b, a]) = (if a * b < 0 then 1 + changes (xs @ [b]) + else if b = 0 then changes (xs @ [a]) else changes (xs @ [b]))" + apply (induction xs rule: changes.induct) + subgoal by (force simp: mult_less_0_iff) + subgoal by (force simp: mult_less_0_iff) + subgoal by force + done + +lemma changes_rev: fixes xs:: "'a::linordered_idom list" + shows "changes (rev xs) = changes xs" + apply (induction xs rule: changes.induct) + by (auto simp: changes_snoc) + +lemma changes_rev_about: fixes xs:: "'a::linordered_idom list" + shows "changes (replicate (p - length xs) 0 @ rev xs) = changes xs" +proof (induction p) + case (Suc p) + then show ?case + proof cases + assume "\Suc p \ length xs" + hence "Suc p - length xs = Suc (p - length xs)" by linarith + thus ?case using Suc.IH changes_rev by auto + qed (auto simp: changes_rev) +qed (auto simp: changes_rev) + +lemma changes_add_between: + assumes "a \ x" and "x \ b" + shows "changes (as @ [a, b] @ bs) = changes (as @ [a, x, b] @ bs)" +proof (induction as rule: changes.induct) + case 1 + then show ?case using assms + apply (induction bs) + by (auto simp: mult_less_0_iff) +next + case (2 c) + then show ?case + apply (induction bs) + using assms by (auto simp: mult_less_0_iff) +next + case (3 y z as) + then show ?case + using assms by (auto simp: mult_less_0_iff) +qed + +lemma changes_all_nonneg: assumes "\i. nth_default 0 xs i \ 0" shows "changes xs = 0" + using assms +proof (induction xs rule: changes.induct) + case (3 x1 x2 xs) + moreover assume "(\i. 0 \ nth_default 0 (x1 # x2 # xs) i)" + moreover hence "(\i. 0 \ nth_default 0 (x1 # xs) i)" + and "(\i. 0 \ nth_default 0 (x2 # xs) i)" + and "x1 * x2 \ 0" + proof - + fix i + assume h:"(\i. 0 \ nth_default 0 (x1 # x2 # xs) i)" + show "0 \ nth_default 0 (x1 # xs) i" + proof (cases i) + case 0 + then show ?thesis using h[of 0] by force + next + case (Suc nat) + then show ?thesis using h[of "Suc (Suc nat)"] by force + qed + show "0 \ nth_default 0 (x2 # xs) i" using h[of "Suc i"] by simp + show "x1*x2 \ 0" using h[of 0] h[of 1] by simp + qed + ultimately show ?case by auto +qed auto + +lemma changes_pCons: "changes (coeffs (pCons 0 f)) = changes (coeffs f)" + by (auto simp: cCons_def) + +lemma changes_increasing: + assumes "\i. i < length xs - 1 \ xs ! (i + 1) \ xs ! i" + and "length xs > 1" + and "hd xs < 0" + and "last xs > 0" + shows "changes xs = 1" + using assms +proof (induction xs rule:changes.induct) + case (3 x y xs) + consider (neg)"x*y<0" | (nil)"y=0" | (pos)"\x*y<0 \ \y=0" by linarith + then show ?case + proof cases + case neg + have "changes (y # xs) = 0" + proof (rule changes_all_nonneg) + fix i + show "0 \ nth_default 0 (y # xs) i" + proof (cases "i < length (y # xs)") + case True + then show ?thesis using 3(4)[of i] + apply (induction i) + subgoal using 3(6) neg by (fastforce simp: mult_less_0_iff) + subgoal using 3(4) by (auto simp: nth_default_def) + done + next + case False + then show ?thesis by (simp add: nth_default_def) + qed + qed + thus "changes (x # y # xs) = 1" + using neg by force + next + case nil + hence "xs \ []" using 3(7) by force + have h: "\i. i < length (x # xs) - 1 \ (x # xs) ! i \ (x # xs) ! (i + 1)" + proof - + fix i assume "i < length (x # xs) - 1" + thus "(x # xs) ! i \ (x # xs) ! (i + 1)" + apply (cases "i = 0") + subgoal using 3(4)[of 0] 3(4)[of 1] \xs \ []\ by force + using 3(4)[of "i+1"] by simp + qed + have "changes (x # xs) = 1" + apply (rule 3(2)) + using nil h \xs \ []\ 3(6) 3(7) by auto + thus ?thesis + using nil by force + next + case pos + hence "xs \ []" using 3(6) 3(7) by (fastforce simp: mult_less_0_iff) + have "changes (y # xs) = 1" + proof (rule 3(3)) + show "\ x * y < 0" "y \ 0" + using pos by auto + show "\i. i < length (y # xs) - 1 + \ (y # xs) ! i \ (y # xs) ! (i + 1)" + using 3(4) by force + show "1 < length (y # xs)" + using \xs \ []\ by force + show "hd (y # xs) < 0" + using 3(6) pos by (force simp: mult_less_0_iff) + show "0 < last (y # xs)" + using 3(7) by force + qed + thus ?thesis using pos by auto + qed +qed auto + +end \ No newline at end of file diff --git a/thys/Three_Circles/Three_Circles.thy b/thys/Three_Circles/Three_Circles.thy new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/Three_Circles.thy @@ -0,0 +1,769 @@ +section \Proof of the theorem of three circles\ + +theory Three_Circles + imports "Bernstein" "Normal_Poly" +begin + +text \ +The theorem of three circles is a result in real algebraic geometry about the number of real roots +in an interval. It says if the number of roots in certain circles in the complex plane are zero or +one then the number of roots in the circles is equal to the sign changes of the Bernstein +coefficients on that interval for which the circles intersect the real line. This can then be used +to determine if an interval has a real root in the bisection procedure, which is more efficient than +Descartes' rule of signs. + +The proof here follows Theorem 10.50 in + Basu, S., Pollack, R., Roy, M.-F.: Algorithms in Real Algebraic Geometry. + Springer Berlin Heidelberg, Berlin, Heidelberg (2016). + +This theorem has also been fomalised in Coq \cite{zsido2014theorem}. The relationship +between this theorem and root isolation has been elaborated in Eigenwillig's PhD +thesis \cite{eigenwillig2008real}. +\ + +subsection \No sign changes case\ + +declare degree_pcompose[simp del] + +corollary descartes_sign_zero: + fixes p::"real poly" + assumes "\x::complex. poly (map_poly of_real p) x = 0 \ Re x \ 0" + and "lead_coeff p = 1" + shows "coeff p i \ 0" + using assms +proof (induction p arbitrary: i rule: real_poly_roots_induct) + case (1 p x) + interpret map_poly_idom_hom complex_of_real .. + have h: "\ i. 0 \ coeff p i" + apply (rule 1(1)) + using 1(2) apply (metis lambda_zero of_real_poly_map_mult poly_mult) + using 1(3) apply (metis lead_coeff_1 lead_coeff_mult lead_coeff_pCons(1) + mult_cancel_right2 pCons_one zero_neq_one) + done + have "x \ 0" + apply (subst Re_complex_of_real[symmetric]) + apply (rule 1(2)) + apply (subst hom_mult) + by (auto) + thus ?case + apply (cases i) + subgoal using h[of i] h[of "i-1"] + by (fastforce simp: coeff_pCons mult_nonneg_nonpos2) + subgoal using h[of i] h[of "i-1"] mult_left_mono_neg + by (fastforce simp: coeff_pCons) + done +next + case (2 p a b) + interpret map_poly_idom_hom complex_of_real .. + have h: "\ i. 0 \ coeff p i" + apply (rule 2(2)) + using 2(3) apply (metis lambda_zero of_real_poly_map_mult poly_mult) + using 2(4) apply (metis lead_coeff_1 lead_coeff_mult lead_coeff_pCons(1) + mult_cancel_right2 pCons_one zero_neq_one) + done + have "Re (a + b * \) \ 0" + apply (rule 2(3)) + apply (subst hom_mult) + by (auto simp: algebra_simps) + hence 1: "0 \ - 2 * a" by fastforce + have 2: "0 \ a * a + b * b" by fastforce + have "\ x. 0 \ coeff [:a * a + b * b, - 2 * a, 1:] x" + proof - + fix x + show "0 \ coeff [:a * a + b * b, - 2 * a, 1:] x" + using 2 apply (cases "x = 0", fastforce) + using 1 apply (cases "x = 1", fastforce) + apply (cases "x = 2", fastforce simp: coeff_pCons) + by (auto simp: coeff_eq_0) + qed + thus ?case + apply (subst mult.commute, subst coeff_mult) + apply (rule sum_nonneg, rule mult_nonneg_nonneg[OF _ h]) + by auto +next + case (3 a) + then show ?case + by (smt (z3) bot_nat_0.extremum_uniqueI degree_1 le_degree + lead_coeff_pCons(2) pCons_one) +qed + +definition circle_01_diam :: "complex set" where +"circle_01_diam = + {x. cmod (x - (of_nat 1 :: complex)/(of_nat 2)) < (real 1)/(real 2)}" + +lemma pos_real_map: + "{x::complex. 1 / x \ (\x. x + 1) ` {x. 0 < Re x}} = circle_01_diam" +proof + show "{x. 1 / x \ (\x. x + 1) ` {x. 0 < Re x}} \ circle_01_diam" + proof + fix x assume "x \ {x. 1 / x \ (\x. x + 1) ` {x. 0 < Re x}}" + then obtain y where h: "1 / x = y + 1" and hy: "0 < Re y" by blast + hence hy': "y = 1 / x - 1" by fastforce + hence hy'': "y + 1 \ 0" using h hy by fastforce + hence "x = 1 / (y + 1)" using h + by (metis div_by_1 divide_divide_eq_right mult.left_neutral) + have "\Re y - 1\ < \Re y + 1\" using hy by simp + hence "cmod (y - 1) < cmod (y + 1)" + by (smt (z3) cmod_Re_le_iff minus_complex.simps(1) minus_complex.simps(2) + one_complex.simps plus_complex.simps(1) plus_complex.simps(2)) + hence "cmod ((y - 1)/(y + 1)) < 1" + by (smt (verit) divide_less_eq_1_pos nonzero_norm_divide zero_less_norm_iff) + thus "x \ circle_01_diam" using hy' hy'' + by (auto simp: field_simps norm_minus_commute circle_01_diam_def) + qed + show "circle_01_diam \ {x. 1 / x \ (\x. x + 1) ` {x. 0 < Re x}}" + proof + fix x assume "x \ circle_01_diam" + hence "cmod (x - 1 / 2) * 2 < 1" by (auto simp: circle_01_diam_def) + hence h: "x \ 0" and "cmod (x - 1 / 2) * cmod 2 < 1" by auto + hence "cmod (2*x - 1) < 1" + by (smt (verit) dbl_simps(3) dbl_simps(5) div_self times_divide_eq_left + left_diff_distrib_numeral mult.commute mult_numeral_1 + norm_eq_zero norm_mult norm_numeral norm_one numeral_One) + hence "cmod (((1/x - 1) - 1)/((1/x - 1) + 1)) < 1" + by (auto simp: divide_simps norm_minus_commute) + hence "cmod (((1/x - 1) - 1)/ cmod ((1/x - 1) + 1)) < 1" + by (metis (no_types, lifting) abs_norm_cancel norm_divide norm_of_real) + hence "cmod ((1/x - 1) - 1) < cmod ((1/x - 1) + 1)" using h + by (smt (verit) diff_add_cancel divide_eq_0_iff divide_less_eq_1_pos + norm_divide norm_of_real zero_less_norm_iff zero_neq_one) + hence "\Re (1/x - 1) - 1\ < \Re (1/x - 1) + 1\" + by (smt (z3) cmod_Re_le_iff minus_complex.simps(1) minus_complex.simps(2) + one_complex.simps plus_complex.simps(1) plus_complex.simps(2)) + hence "0 < Re (1/x - 1)" by linarith + moreover have "1 / x = (1/x - 1) + 1" by simp + ultimately have "0 < Re (1/x - 1) \ 1 / x = (1/x - 1) + 1" by blast + hence "\xa. 0 < Re xa \ 1 / x = xa + 1" by blast + thus "x \ {x. 1 / x \ (\x. x + 1) ` {x. 0 < Re x}}" by blast + qed +qed + +lemma one_circle_01: fixes P::"real poly" assumes hP: "degree P \ p" and "P \ 0" + and "proots_count (map_poly of_real P) circle_01_diam = 0" +shows "Bernstein_changes_01 p P = 0" +proof - + let ?Q = "(reciprocal_poly p P) \\<^sub>p [:1, 1:]" + have hQ: "?Q \ 0" + using assms + by (simp add: Missing_Polynomial.pcompose_eq_0 reciprocal_0_iff) + + hence 1: "changes (coeffs ?Q) \ proots_count ?Q {x. 0 < x} \ + even (changes (coeffs ?Q) - proots_count ?Q {x. 0 < x})" + by (rule descartes_sign) + + have hdeg: "degree (map_poly complex_of_real P) \ p" + by (rule le_trans, rule degree_map_poly_le, auto simp: assms) + have hx: "\x. 1 + x = 0 \ 0 < Re x \ False" + proof - + fix x::complex assume "1 + x = 0" + hence "x = -1" by algebra + thus "0 < Re x \ False" by auto + qed + + have 2: "proots_count (map_poly of_real P) circle_01_diam = + proots_count (map_poly of_real ?Q) {x. 0 < Re x}" + apply (subst pos_real_map[symmetric]) + apply (subst of_real_hom.map_poly_pcompose) + apply (subst map_poly_reciprocal) using assms apply auto[2] + apply (subst proots_pcompose) + using assms apply (auto simp: reciprocal_0_iff degree_map_poly)[2] + apply (subst proots_count_reciprocal) + using assms apply (auto simp: degree_map_poly inverse_eq_divide)[2] + using hx apply fastforce + by (auto simp: inverse_eq_divide algebra_simps) + + hence 3:"proots_count (map_poly of_real ?Q) {x. 0 < Re x} = 0" + using assms(3) by presburger + + hence "\x::complex. + poly (map_poly of_real (smult (inverse (lead_coeff ?Q)) ?Q)) x = 0 \ + Re x \ 0" + proof cases + fix x::complex show "Re x \ 0 \ Re x \ 0" by fast + assume "\Re x \ 0" hence h:"0 < Re x" by simp + assume "poly (map_poly of_real (smult (inverse (lead_coeff ?Q)) ?Q)) x = 0" + hence h2:"poly (map_poly of_real ?Q) x = 0" by fastforce + hence "order x (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])) > 0" + using assms by (fastforce simp: order_root pcompose_eq_0 reciprocal_0_iff) + hence "proots_count (map_poly of_real ?Q) {x. 0 < Re x} \ 0" + proof - + have h3: "finite {x. poly (map_poly complex_of_real + (reciprocal_poly p P \\<^sub>p [:1, 1:])) x = 0}" + apply (rule poly_roots_finite) + using assms by (fastforce simp: order_root pcompose_eq_0 reciprocal_0_iff) + have "0 < order x (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:]))" + using h2 assms by (fastforce simp: order_root pcompose_eq_0 reciprocal_0_iff) + also have "... \ (\r\{x. 0 < Re x \ + poly (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])) x = + 0}. + order r (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])))" + apply (rule member_le_sum) using h h2 h3 by auto + finally have + "0 < (\r\{x. 0 < Re x \ + poly (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])) x = 0}. + order r (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])))" . + thus + "0 < order x (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])) \ + proots_count (map_poly complex_of_real (reciprocal_poly p P \\<^sub>p [:1, 1:])) + {x. 0 < Re x} \ 0 " + by (auto simp: proots_count_def proots_within_def) + qed + thus "Re x \ 0" using 3 by blast + qed + hence "\i. coeff (smult (inverse (lead_coeff ?Q)) ?Q) i \ 0" + apply (frule descartes_sign_zero) + using assms by (fastforce simp: pcompose_eq_0 reciprocal_0_iff) + hence "changes (coeffs (smult (inverse (lead_coeff ?Q)) ?Q)) = 0" + by (subst changes_all_nonneg, auto simp: nth_default_coeffs_eq) + hence "changes (coeffs ?Q) = 0" + using hQ by (auto simp: coeffs_smult changes_scale_const) + + thus ?thesis + apply (subst Bernstein_changes_01_eq_changes["OF" hP]) + by blast +qed + +definition circle_diam :: "real \ real \ complex set" where +"circle_diam l r = {x. cmod ((x - l) - (r - l)/2) < (r - l)/2}" + +lemma circle_diam_rescale: assumes "l < r" + shows "circle_diam l r = (\ x . (x*(r - l) + l)) ` circle_01_diam" +proof + show "circle_diam l r \ (\x. x * (complex_of_real r - complex_of_real l) + + complex_of_real l) ` circle_01_diam" + proof + fix x assume "x \ circle_diam l r" + hence "cmod ((x - l) - (r - l)/2) < (r - l)/2" by (auto simp: circle_diam_def) + hence "cmod ((r - l) * ((x - l)/(r - l) - 1/2)) < (r - l)/2" using assms + by (subst right_diff_distrib, fastforce) + hence "(r - l) * cmod ((x - l)/(r - l) - 1/2) < (r - l) * 1/2" + apply (subst(2) abs_of_pos[symmetric]) + subgoal using assms by argo + subgoal + apply (subst norm_scaleR[symmetric]) + by (simp add: scaleR_conv_of_real) + done + hence "cmod ((x - l)/(r - l) - 1/2) < 1/2" + apply (subst mult_less_cancel_left_pos[of "r-l",symmetric]) + using assms by auto + hence + "cmod ((x-l)/(r-l) - 1 / 2) * 2 < 1 \ + x = (x-l)/(r-l) * (complex_of_real r - complex_of_real l) + complex_of_real l" + by force + thus "x \ (\x. x * (complex_of_real r - complex_of_real l) + complex_of_real l) ` + circle_01_diam" + by (force simp: circle_01_diam_def) + qed + show "(\x. x * (complex_of_real r - complex_of_real l) + complex_of_real l) ` + circle_01_diam \ circle_diam l r" + proof + fix x::complex + assume + "x \ (\x. x * (complex_of_real r - complex_of_real l) + complex_of_real l) ` + circle_01_diam" + then obtain y::complex where "x = y * (r - l) + l" "cmod (y - 1/2) < 1/2" + by (fastforce simp: circle_01_diam_def) + moreover hence "y = (x - l) / (r - l)" using assms by force + ultimately have "cmod ((x - l) / (r - l) - 1/2) < 1/2" by presburger + hence "(r - l) * (cmod ((x - l) / (r - l) - 1/2)) < (r - l) * (1/2)" + apply (subst mult_less_cancel_left_pos) + using assms by auto + hence "cmod ((x - l) - (r - l)/2) < (r - l)/2" + apply (subst(asm) (2) abs_of_pos[symmetric]) + using assms apply argo + apply (subst(asm) norm_scaleR[symmetric]) + by (smt (verit, del_insts) + \x = y * complex_of_real (r - l) + complex_of_real l\ + \y = (x - complex_of_real l) / complex_of_real (r - l)\ + add_diff_cancel divide_divide_eq_right divide_numeral_1 mult.commute + of_real_1 of_real_add of_real_divide one_add_one scaleR_conv_of_real + scale_right_diff_distrib times_divide_eq_right) + thus "x \ circle_diam l r" + by (force simp: circle_diam_def) + qed +qed + +lemma one_circle: fixes P::"real poly" assumes "l < r" + and "proots_count (map_poly of_real P) (circle_diam l r) = 0" + and "P \ 0" + and "degree P \ p" +shows "Bernstein_changes p l r P = 0" +proof (subst Bernstein_changes_eq_rescale) + show "l \ r" using assms(1) by force + show "degree P \ p" using assms(4) by blast + show "Bernstein_changes_01 p (P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:]) = 0" + proof (rule one_circle_01) + show "degree (P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:]) \ p" + using assms(4) by (force simp: degree_pcompose) + show "P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:] \ 0" + using assms by (smt (z3) degree_0_iff gr_zeroI pCons_eq_0_iff pCons_eq_iff + pcompose_eq_0) + + have "proots_count (map_poly of_real P) (circle_diam l r) = + proots_count (map_poly complex_of_real (P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:])) + circle_01_diam" + apply (subst of_real_hom.map_poly_pcompose) + apply (subst proots_pcompose) + apply (metis assms(3) degree_eq_zeroE of_real_poly_eq_0_iff + pCons_eq_iff pCons_one pcompose_eq_0 zero_neq_one) + using assms(1) apply fastforce + apply (subst of_real_hom.map_poly_pcompose) + apply (subst proots_pcompose) + apply (auto simp: assms(3))[2] + apply (subst circle_diam_rescale[OF assms(1)]) + apply (rule arg_cong[of _ _ "proots_count (map_poly complex_of_real P)"]) + by fastforce + + thus "proots_count (map_poly complex_of_real (P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:])) + circle_01_diam = 0" + using assms(2) by presburger + qed +qed + +subsection \One sign change case\ + +definition upper_circle_01 :: "complex set" where +"upper_circle_01 = {x. cmod (x - (1/2 + sqrt(3)/6 * \)) < sqrt 3 / 3}" + +lemma upper_circle_map: + "{x::complex. 1 / x \ (\x. x + 1) ` {x. Im x < sqrt 3 * Re x}} = upper_circle_01" +proof + show "{x::complex. 1 / x \ (\x. x + 1) ` {x. Im x < sqrt 3 * Re x}} \ upper_circle_01" + proof + fix x + assume "x \ {x. 1 / x \ (\x. x + 1) ` {x. Im x < sqrt 3 * Re x}}" + then obtain y where "1 / x = y + 1" and h: "Im y < sqrt 3 * Re y" by fastforce + hence hy: "y = 1/x - 1" by simp + hence hx: "x = 1/(y+1)" by auto + from h have hy1: "y \ -1" by fastforce + hence hx0: "x \ 0" using hy by fastforce + from h have "0 < Re ((\ + sqrt 3) * y)" by fastforce + hence "cmod ((\ + sqrt 3) * y - 1) < cmod ((\ + sqrt 3) * y + 1)" + by (auto simp: cmod_def power2_eq_square algebra_simps) + hence 1: "cmod (((\ + sqrt 3) * y - 1)/((\ + sqrt 3) * y + 1)) < 1" + by (auto simp: norm_divide divide_simps) + also have "cmod (((\ + sqrt 3) * y - 1)/((\ + sqrt 3) * y + 1)) = + cmod (((\ + sqrt 3) * y * x - x)/((\ + sqrt 3) * y * x + x))" + apply (subst mult_divide_mult_cancel_right[symmetric, OF hx0]) + apply (subst ring_distribs(2)[of _ _ x]) + apply (subst left_diff_distrib[of _ _ x]) + by simp + also have "... = cmod + (((-1 - complex_of_real (sqrt 3) - \) * x + (complex_of_real (sqrt 3) + \)) / + (( 1 - complex_of_real (sqrt 3) - \) * x + (complex_of_real (sqrt 3) + \)))" + by (auto simp: hy algebra_simps hx0) + + also have + "... = cmod ((-1 - complex_of_real (sqrt 3) - \) * x + + (complex_of_real (sqrt 3) + \)) / + cmod (( 1 - complex_of_real (sqrt 3) - \) * x + + (complex_of_real (sqrt 3) + \))" + by (auto simp: norm_divide) + + finally have + "cmod ((-1 - complex_of_real (sqrt 3) - \) * x + (complex_of_real (sqrt 3) + \)) + < cmod ((1 - complex_of_real (sqrt 3) - \) * x + (complex_of_real (sqrt 3) + \))" + proof (subst divide_less_eq_1_pos[symmetric], subst zero_less_norm_iff) + show "(1 - complex_of_real (sqrt 3) - \) * x + (complex_of_real (sqrt 3) + \) \ 0" + proof + have "-\ + 1 \ complex_of_real (sqrt 3)" by (auto simp: complex_eq_iff) + moreover assume + "(1 - complex_of_real (sqrt 3) - \) * x + (complex_of_real (sqrt 3) + \) = 0" + ultimately have + "x = (-complex_of_real (sqrt 3) - \)/(1 - complex_of_real (sqrt 3) - \)" + by (auto simp: divide_simps algebra_simps) + thus False + using h by (auto simp: hy field_simps Im_divide Re_divide) + qed + qed + + hence "cmod (x - (1/2 + sqrt(3)/6 * \)) < sqrt 3 / 3" + apply (subst(3) abs_of_pos[symmetric, of 3]) apply auto[1] + apply (subst real_sqrt_abs2[symmetric], subst real_sqrt_divide[symmetric]) + apply (subst cmod_def, subst real_sqrt_less_iff) + apply (rule mult_right_less_imp_less[of _ "sqrt 3 /3"]) + by (auto simp: cmod_def power2_eq_square algebra_simps) + + thus "x \ upper_circle_01" + by (auto simp: upper_circle_01_def) + qed + + show "upper_circle_01 \ {x. 1 / x \ (\x. x + 1) ` {x. sqrt 3 * Re x > Im x}}" + proof + fix x assume "x \ upper_circle_01" + hence "cmod (x - (1/2 + sqrt(3)/6 * \)) < sqrt 3 / 3" + by (force simp: upper_circle_01_def) + hence "sqrt ((Re x - 1/2)^2 + (Im x - sqrt(3)/6)^2) < sqrt (1/3)" + by (auto simp: cmod_def sqrt_divide_self_eq real_sqrt_inverse[symmetric]) + hence 1: "- Im x * sqrt 3 + (Im x * (Im x * 3) + Re x * (Re x * 3)) < Re x * 3" + by (auto simp: power2_eq_square algebra_simps) + have 2: "- Im x + (Im x * (Im x * sqrt 3) + Re x * (Re x * sqrt 3)) < Re x * sqrt 3" + apply (rule mult_right_less_imp_less[of _ "sqrt 3"]) + apply (subst mult.assoc[of _ "sqrt 3"], subst real_sqrt_mult_self) + using 1 by (auto simp: algebra_simps) + have "sqrt 3 + (-Im x) / (Im x * Im x + Re x * Re x) < + Re x * sqrt 3 / (Im x * Im x + Re x * Re x)" + apply (rule mult_right_less_imp_less[of _ "(Im x * Im x + Re x * Re x)"]) + apply (rule subst, rule arg_cong2[of _ _ _ _ "(<)"]) + prefer 3 apply (rule 2) + apply (subst distrib_right) + using 2 apply auto + by (auto simp: algebra_simps) + + hence "0 < - Im (1/x-1) + sqrt 3 * Re (1/x-1)" + by (auto simp: power2_eq_square algebra_simps Re_divide Im_divide) + hence "sqrt 3 * Re (1/x-1) > Im (1/x-1)" + by argo + hence "(1/x-1) \ {x. sqrt 3 * Re x > Im x}" by fast + moreover have "1/x = (1/x-1) + 1" by simp + ultimately show "x \ {x. 1 / x \ (\x. x + 1) ` {x. sqrt 3 * Re x > Im x}}" + by blast + qed +qed + +definition lower_circle_01 :: "complex set" where +"lower_circle_01 = {x. cmod (x - (1/2 - sqrt(3)/6 * \)) < sqrt 3 / 3}" + +lemma cnj_upper_circle_01: "cnj ` upper_circle_01 = lower_circle_01" +proof + show "cnj ` upper_circle_01 \ lower_circle_01" + proof + fix x assume "x \ cnj ` upper_circle_01" + then obtain y where "y \ upper_circle_01" and "x = cnj y" by blast + thus "x \ lower_circle_01" + apply (subst lower_circle_01_def, subst complex_mod_cnj[symmetric]) + by (auto simp add: upper_circle_01_def del: complex_mod_cnj) + qed + show "lower_circle_01 \ cnj ` upper_circle_01" + proof + fix x assume "x \ lower_circle_01" + hence "cnj x \ upper_circle_01" and "x = cnj (cnj x)" + apply (subst upper_circle_01_def, subst complex_mod_cnj[symmetric]) + by (auto simp add: lower_circle_01_def del: complex_mod_cnj) + thus "x \ cnj ` upper_circle_01" + by blast + qed +qed + +lemma lower_circle_map: + "{x::complex. 1 / x \ (\x. x + 1) ` {x. Im x > - sqrt 3 * Re x}} = lower_circle_01" +proof (subst cnj_upper_circle_01[symmetric], subst upper_circle_map[symmetric]) + have "{x. 1 / x \ (\x. x + 1) ` {x. - sqrt 3 * Re x < Im x}} = + {x. 1 / x \ (\x. x + 1) ` {x. sqrt 3 * Re (cnj x) > Im (cnj x)}}" + by auto + also have "... = {x. 1 / x \ (\x. x + 1) ` cnj ` {x. sqrt 3 * Re x > Im x}}" + apply (subst(2) bij_image_Collect_eq) + apply (metis bijI' complex_cnj_cnj) + by (auto simp: inj_def inj_imp_inv_eq[of _ cnj]) + also have "... = {x. 1 / x \ cnj ` (\x. x + 1) ` {x. sqrt 3 * Re x > Im x}}" + by (auto simp: image_image) + also have "... = {x. cnj (1 / x) \ (\x. x + 1) ` {x. sqrt 3 * Re x > Im x}}" + by (metis (no_types, lifting) complex_cnj_cnj image_iff) + also have "... = cnj ` {x. 1 / x \ (\x. x + 1) ` {x. sqrt 3 * Re x > Im x}}" + apply (subst(2) bij_image_Collect_eq) + apply (metis bijI' complex_cnj_cnj) + by (auto simp: inj_def inj_imp_inv_eq[of _ cnj]) + finally show "{x. 1 / x \ (\x. x + 1) ` {x. - sqrt 3 * Re x < Im x}} = + cnj ` {x. 1 / x \ (\x. x + 1) ` {x. Im x < sqrt 3 * Re x}}" . +qed + +lemma two_circles_01: + fixes P::"real poly" + assumes hP: "degree P \ p" and hP0: "P \ 0" and hp0: "p \ 0" + and h: "proots_count (map_poly of_real P) + (upper_circle_01 \ lower_circle_01) = 1" +shows "Bernstein_changes_01 p P = 1" +proof (subst Bernstein_changes_01_eq_changes[OF hP]) + let ?Q = "reciprocal_poly p P \\<^sub>p [:1, 1:]" + have hQ0: "?Q \ 0" using hP0 + by (simp add: pcompose_eq_0 hP reciprocal_0_iff) + + from h obtain x' where hroot': "poly (map_poly of_real P) x' = 0" + and hx':"x' \ upper_circle_01 \ lower_circle_01" + using proots_count_pos by (metis less_numeral_extra(1)) + + obtain x where hxx': "x' = complex_of_real x" + proof (cases "Im x' = 0") + assume "Im x' = 0" and h: "\x. x' = complex_of_real x \ thesis" + then show thesis using h[of "Re x'"] by (simp add: complex_is_Real_iff) + next + assume hx'': "Im x' \ 0" + have 1: "card {x', cnj x'} = 2" + proof (subst card_2_iff) + from hx'' have "x' \ cnj x'" and "{x', cnj x'} = {x', cnj x'}" + by (metis cnj.simps(2) neg_equal_zero, argo) + thus "\x y. {x', cnj x'} = {x, y} \ x \ y" by blast + qed + moreover have "{x', cnj x'} \ upper_circle_01 \ lower_circle_01" using hx' + apply (rule UnE) + by (auto simp: cnj_upper_circle_01[symmetric]) + moreover have "\x. x \ {x', cnj x'} \ poly (map_poly of_real P) x = 0" + using hroot' poly_map_poly_of_real_cnj by auto + ultimately have + "proots_count (map_poly of_real P) (upper_circle_01 \ lower_circle_01) \ 2" + apply (subst 1[symmetric]) + apply (rule proots_count_of_root_set) + using assms(2) of_real_poly_eq_0_iff by (blast, blast, blast) + thus thesis using assms(4) by linarith + qed + hence hroot: "poly P x = 0" + using hroot' by (metis of_real_0 of_real_eq_iff of_real_poly_map_poly) + have that: "3 * sqrt (x * x + 1 / 3 - x) < sqrt 3" using hx' + apply (rule UnE) + by (auto simp: cmod_def power2_eq_square algebra_simps upper_circle_01_def + lower_circle_01_def hxx') + have hx: "0 < x \ x < 1" + proof - + have "3 * sqrt (x * x + 1 / 3 - x) = sqrt (9 * (x * x + 1 / 3 - x))" + by (subst real_sqrt_mult, simp) + hence "9 * (x * x + 1 / 3 - x) < 3" using that real_sqrt_less_iff by metis + hence "x*x - x < 0" by auto + thus "0 < x \ x < 1" + using mult_eq_0_iff mult_less_cancel_right_disj by fastforce + qed + + let ?y = "1/x - 1" + from hroot hx assms have "poly ?Q ?y = 0" + by (auto simp: poly_pcompose poly_reciprocal) + hence "[:-?y, 1:] dvd ?Q" using poly_eq_0_iff_dvd by blast + then obtain R where hR: "?Q = R * [:-?y, 1:]" by auto + hence hR0: "R \ 0" using hQ0 by force + interpret map_poly_idom_hom complex_of_real .. + + + have "normal_poly (smult (inverse (lead_coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]))) R)" + proof (rule normal_poly_of_roots) + show "\z. poly (map_poly complex_of_real + (smult (inverse (lead_coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]))) R)) z = 0 \ + Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2" + proof - + fix z + assume + "poly (map_poly complex_of_real + (smult (inverse (lead_coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]))) R)) z = 0" + hence hroot2: "poly (map_poly complex_of_real R) z = 0" + by (auto simp: map_poly_smult hQ0) + show "Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2" + proof (rule ccontr) + assume "\ (Re z \ 0 \ (cmod z)\<^sup>2 \ 4 * (Re z)\<^sup>2)" + hence 1: "0 < Re z \ 4 * (Re z)\<^sup>2 < (cmod z)\<^sup>2" by linarith + hence hz: "z \ -1" by force + have "Im z > - sqrt 3 * Re z \ sqrt 3 * Re z > Im z" + proof (cases "Im z \ sqrt 3 * Re z", cases "- sqrt 3 * Re z \ Im z") + assume 2: "sqrt 3 * Re z \ Im z" "Im z \ - sqrt 3 * Re z" + hence "sqrt 3 * Re z \ sqrt 3 * - Re z" by force + hence "Re z \ - Re z" + apply (rule mult_left_le_imp_le) + by fastforce + hence "Re z \ 0" by simp + moreover have "(Im z)^2 \ (-sqrt 3 * Re z)^2" + apply (subst power2_eq_square, subst power2_eq_square) + apply (rule square_bounded_le) + using 2 by auto + ultimately have False using 1 + by (auto simp: power2_eq_square cmod_def algebra_simps) + thus ?thesis by fast + qed auto + + hence "z \ {z. - sqrt 3 * Re z < Im z} \ {z. Im z < sqrt 3 * Re z}" + by blast + + hence 1: "inverse (1 + z) \ upper_circle_01 \ lower_circle_01" + by (force simp: inverse_eq_divide upper_circle_map[symmetric] + lower_circle_map[symmetric]) + + have hRdeg': "degree R < p" + apply (rule less_le_trans[of "degree R" "degree ?Q"]) + apply (subst hR, subst degree_mult_eq[OF hR0], fastforce, fastforce) + by (auto simp: degree_pcompose degree_reciprocal hP) + hence hRdeg: "degree R \ p" by fastforce + have 2: "map_poly complex_of_real (reciprocal_poly p (R \\<^sub>p [:-1, 1:])) \ 0" + apply (subst of_real_poly_eq_0_iff, subst reciprocal_0_iff) + apply (force simp: hRdeg degree_pcompose) + using hR0 pcompose_eq_0 + by (metis degree_eq_zeroE gr_zeroI pCons_eq_iff pCons_one zero_neq_one) + have 3: + "poly (map_poly complex_of_real (reciprocal_poly p (R \\<^sub>p [:-1, 1:]))) + (inverse (1 + z)) = 0" + apply (subst map_poly_reciprocal) + using hRdeg apply (force simp: degree_pcompose) + apply auto[1] + apply (subst poly_reciprocal) + using hRdeg apply (force simp: degree_map_poly degree_pcompose) + using hz apply (metis inverse_nonzero_iff_nonzero neg_eq_iff_add_eq_0) + by (auto simp: of_real_hom.map_poly_pcompose poly_pcompose hroot2) + + have "proots_count (map_poly of_real (reciprocal_poly p (R \\<^sub>p [:-1, 1:]))) + (upper_circle_01 \ lower_circle_01) > 0" + by (rule proots_count_of_root[OF 2 1 3]) + moreover have "proots_count + (map_poly complex_of_real + (reciprocal_poly p ([:1 - 1 / x, 1:] \\<^sub>p [:- 1, 1:]))) + (upper_circle_01 \ lower_circle_01) > 0" + apply (subst map_poly_reciprocal) + using hp0 less_eq_Suc_le apply (simp add: degree_pcompose) + apply simp + apply (subst proots_count_reciprocal) + using hp0 less_eq_Suc_le + apply (simp add: degree_pcompose degree_map_poly) + apply (auto simp: pcompose_pCons)[1] + apply (auto simp: cmod_def power2_eq_square real_sqrt_divide + real_div_sqrt upper_circle_01_def lower_circle_01_def)[1] + apply (subst of_real_hom.map_poly_pcompose) + apply (subst proots_pcompose, fastforce, force) + apply (subst lower_circle_map[symmetric]) + apply (subst upper_circle_map[symmetric]) + apply (rule proots_count_of_root[of _ "of_real (1/x - 1)"]) + apply simp + apply (auto simp: bij_image_Collect_eq bij_def inj_def image_iff + inverse_eq_divide inj_imp_inv_eq[of _ "\ x. x+1"] hx)[1] + by force + + ultimately have "proots_count + (map_poly complex_of_real (reciprocal_poly p (R \\<^sub>p [:- 1, 1:]))) + (upper_circle_01 \ lower_circle_01) + + proots_count + (map_poly complex_of_real + (reciprocal_poly p ([:1 - 1 / x, 1:] \\<^sub>p [:- 1, 1:]))) + (upper_circle_01 \ lower_circle_01) > 1" + by fastforce + also have "... = proots_count (map_poly complex_of_real + (monom 1 p * reciprocal_poly p (?Q \\<^sub>p [:- 1, 1:]))) + (upper_circle_01 \ lower_circle_01)" + apply (subst eq_commute, subst hR, subst pcompose_mult) + apply (subst reciprocal_mult, subst degree_mult_eq) + using hR0 apply (fastforce simp: pcompose_eq_0) + apply (fastforce simp: pcompose_pCons) + using hRdeg' apply (simp add: degree_pcompose) + using hRdeg apply (simp add: degree_pcompose) + using hp0 apply (auto simp: degree_pcompose)[1] + apply (subst hom_mult) + apply (subst proots_count_times) + using hp0 hRdeg' hR0 + apply (fastforce simp: reciprocal_0_iff degree_pcompose pcompose_eq_0 + pcompose_pCons) + by simp + also have "... = proots_count + (map_poly complex_of_real + (reciprocal_poly p (reciprocal_poly p P \\<^sub>p [:1, 1:] \\<^sub>p [:- 1, 1:]))) + (upper_circle_01 \ lower_circle_01)" + apply (subst hom_mult) + apply (subst proots_count_times) + using hp0 hP hP0 + apply (auto simp: map_poly_reciprocal degree_pcompose + degree_reciprocal of_real_hom.map_poly_pcompose + reciprocal_0_iff degree_map_poly pcompose_eq_0)[1] + apply (subst map_poly_monom, fastforce) + apply (subst of_real_1, subst proots_count_monom) + apply (auto simp: cmod_def power2_eq_square real_sqrt_divide + real_div_sqrt upper_circle_01_def lower_circle_01_def)[1] + by presburger + also have "... = 1" + by (auto simp: pcompose_assoc["symmetric"] pcompose_pCons + reciprocal_reciprocal hP h) + finally show False by blast + qed + qed + show "lead_coeff + (smult (inverse (lead_coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]))) R) = 1" + by (auto simp: hR degree_add_eq_right hR0 coeff_eq_0) + qed + + hence "changes (coeffs (smult (inverse (lead_coeff ?Q)) ?Q)) = 1" + apply (subst hR, subst mult_smult_left[symmetric], rule normal_changes) + by (auto simp: hx) + + moreover have "changes (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) = + changes (coeffs (smult (inverse (lead_coeff (reciprocal_poly p P \\<^sub>p [:1, 1:]))) + (reciprocal_poly p P \\<^sub>p [:1, 1:])))" + by (auto simp: pcompose_eq_0 reciprocal_0_iff hP hP0 coeffs_smult + changes_scale_const[symmetric]) + + ultimately show "changes (coeffs (reciprocal_poly p P \\<^sub>p [:1, 1:])) = 1" by argo +qed + +definition upper_circle :: "real \ real \ complex set" where +"upper_circle l r = {x::complex. + cmod ((x-of_real l)/(of_real (r-l)) - (1/2 + of_real (sqrt(3))/6 * \)) < sqrt 3 / 3}" + +lemma upper_circle_rescale: assumes "l < r" + shows "upper_circle l r = (\ x . (x*(r - l) + l)) ` upper_circle_01" +proof + show "upper_circle l r \ + (\x. x * (of_real r - of_real l) + of_real l) ` upper_circle_01" + apply (rule subsetI) + apply (rule image_eqI[of _ _ "(_ - of_real l)/(of_real r - of_real l)"]) + using assms apply (auto simp: divide_simps)[1] + by (auto simp: upper_circle_01_def upper_circle_def) + show "(\x. x * (of_real r - of_real l) + of_real l) ` upper_circle_01 \ + upper_circle l r" + apply (rule subsetI, subst(asm) image_iff) + using assms by (auto simp: upper_circle_01_def upper_circle_def) +qed + +definition lower_circle :: "real \ real \ complex set" where +"lower_circle l r = {x::complex. + cmod ((x-of_real l)/(of_real (r-l)) - (1/2 - of_real (sqrt(3))/6 * \)) < sqrt 3 / 3}" + +lemma lower_circle_rescale: + assumes "l < r" + shows "lower_circle l r = (\ x . (x*(r - l) + l)) ` lower_circle_01" +proof + show "lower_circle l r \ (\x. x * (of_real r - of_real l) + of_real l) ` + lower_circle_01" + apply (rule subsetI) + apply (rule image_eqI[of _ _ "(_ - of_real l)/(of_real r - of_real l)"]) + using assms apply (auto simp: divide_simps)[1] + by (auto simp: lower_circle_01_def lower_circle_def) + show "(\x. x * (of_real r - of_real l) + of_real l) ` lower_circle_01 \ + lower_circle l r" + apply (rule subsetI, subst(asm) image_iff) + using assms by (auto simp: lower_circle_01_def lower_circle_def) +qed + +lemma two_circles: + fixes P::"real poly" and l r::real + assumes hlr: "l < r" + and hP: "degree P \ p" + and hP0: "P \ 0" + and hp0: "p \ 0" + and h: "proots_count (map_poly of_real P) + (upper_circle l r \ lower_circle l r) = 1" +shows "Bernstein_changes p l r P = 1" +proof - + have 1: "Bernstein_changes p l r P = + Bernstein_changes_01 p (P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:])" + using assms by (force simp: Bernstein_changes_eq_rescale) + have "proots_count (map_poly complex_of_real (P \\<^sub>p [:l, 1:] \\<^sub>p [:0, r - l:])) + (upper_circle_01 \ lower_circle_01) = 1" + using assms + by (auto simp: upper_circle_rescale lower_circle_rescale proots_pcompose image_Un + of_real_hom.map_poly_pcompose pcompose_eq_0 image_image algebra_simps) + thus ?thesis + apply (subst 1) + apply (rule two_circles_01) + using hP apply (force simp: degree_pcompose) + using hP0 hlr apply (fastforce simp: pcompose_eq_0) + using hp0 apply blast + by blast +qed + +subsection \The theorem of three circles\ + +theorem three_circles: + fixes P::"real poly" and l r::real + assumes "l < r" + and hP: "degree P \ p" + and hP0: "P \ 0" + and hp0: "p \ 0" +shows "proots_count (map_poly of_real P) (circle_diam l r) = 0 \ + Bernstein_changes p l r P = 0" + and "proots_count (map_poly of_real P) + (upper_circle l r \ lower_circle l r) = 1 \ + Bernstein_changes p l r P = 1" + apply (rule one_circle) + using assms apply auto[4] + apply (rule two_circles) + using assms by auto + +end \ No newline at end of file diff --git a/thys/Three_Circles/document/root.bib b/thys/Three_Circles/document/root.bib new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/document/root.bib @@ -0,0 +1,42 @@ +@article{eigenwillig2008real, + title={Real root isolation for exact and approximate polynomials using Descartes' rule of signs}, + author={Eigenwillig, Arno}, + year={2008} +} + +@inproceedings{li2019counting, + title={Counting polynomial roots in Isabelle/HOL: a formal proof of the Budan-Fourier theorem}, + author={Li, Wenda and Paulson, Lawrence C}, + booktitle={Proceedings of the 8th ACM SIGPLAN International Conference on Certified Programs and Proofs}, + pages={52--64}, + year={2019} +} + +@article{zsido2014theorem, + title={Theorem of three circles in Coq}, + author={Zsid{\'o}, Julianna}, + journal={Journal of automated reasoning}, + volume={53}, + number={2}, + pages={105--127}, + year={2014}, + publisher={Springer} +} + +@book{Basu:2016bo, + author = {Basu, Saugata and Pollack, Richard and Roy, Marie-Franco̧ise}, + title = {{Algorithms in Real Algebraic Geometry}}, + publisher = {Springer Berlin Heidelberg}, + year = {2016}, + volume = {10}, + series = {Algorithms and Computation in Mathematics}, + address = {Berlin, Heidelberg} +} + + + + + + + + diff --git a/thys/Three_Circles/document/root.tex b/thys/Three_Circles/document/root.tex new file mode 100644 --- /dev/null +++ b/thys/Three_Circles/document/root.tex @@ -0,0 +1,75 @@ +\documentclass[11pt,a4paper]{article} +\usepackage{isabelle,isabellesym} + +% further packages required for unusual symbols (see also +% isabellesym.sty), use only when needed + +%\usepackage{amssymb} + %for \, \, \, \, \, \, + %\, \, \, \, \, + %\, \, \ + +%\usepackage{eurosym} + %for \ + +%\usepackage[only,bigsqcap]{stmaryrd} + %for \ + +%\usepackage{eufrak} + %for \ ... \, \ ... \ (also included in amssymb) + +%\usepackage{textcomp} + %for \, \, \, \, \, + %\ + +% this should be the last package used +\usepackage{pdfsetup} + +% urls in roman style, theory text in math-similar italics +\urlstyle{rm} +\isabellestyle{it} + +% for uniform font size +%\renewcommand{\isastyle}{\isastyleminor} + + +\begin{document} + +\title{The Theorem of Three Circles} +\author{Fox Thomson, Wenda Li} +\maketitle + + +\begin{abstract} + The Descartes test based on Bernstein coefficients and Descartes' rule of signs + effectively (over-)approximates the number of real roots of a univariate polynomial over + an interval. In this entry we formalise the theorem of three circles (Theorem 10.50 in \cite{Basu:2016bo}), + which gives sufficient conditions for when the Descartes test + returns 0 or 1. This is the first step for efficient root isolation. +\end{abstract} + +\tableofcontents + + +% sane default for proof documents +\parindent 0pt\parskip 0.5ex + +% generated text of all theories +\input{session} + + +\section{Acknowledgements} + +The work has been jointly supported by the Cambridge Mathematics Placements (CMP) +Programme and the ERC Advanced Grant ALEXANDRIA (Project GA 742178). + +% optional bibliography +\bibliographystyle{abbrv} +\bibliography{root} + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff --git a/web/entries/Algebraic_Numbers.html b/web/entries/Algebraic_Numbers.html --- a/web/entries/Algebraic_Numbers.html +++ b/web/entries/Algebraic_Numbers.html @@ -1,241 +1,241 @@ Algebraic Numbers in Isabelle/HOL - Archive of Formal Proofs

 

 

 

 

 

 

Algebraic Numbers in Isabelle/HOL

 

- +
Title: Algebraic Numbers in Isabelle/HOL
Authors: René Thiemann (rene /dot/ thiemann /at/ uibk /dot/ ac /dot/ at), Akihisa Yamada and Sebastiaan Joosten
Contributor: Manuel Eberl
Submission date: 2015-12-22
Abstract: Based on existing libraries for matrices, factorization of rational polynomials, and Sturm's theorem, we formalized algebraic numbers in Isabelle/HOL. Our development serves as an implementation for real and complex numbers, and it admits to compute roots and completely factorize real and complex polynomials, provided that all coefficients are rational numbers. Moreover, we provide two implementations to display algebraic numbers, an injective and expensive one, or a faster but approximative version.

To this end, we mechanized several results on resultants, which also required us to prove that polynomials over a unique factorization domain form again a unique factorization domain.

Change history: [2016-01-29]: Split off Polynomial Interpolation and Polynomial Factorization
[2017-04-16]: Use certified Berlekamp-Zassenhaus factorization, use subresultant algorithm for computing resultants, improved bisection algorithm
BibTeX:
@article{Algebraic_Numbers-AFP,
   author  = {René Thiemann and Akihisa Yamada and Sebastiaan Joosten},
   title   = {Algebraic Numbers in Isabelle/HOL},
   journal = {Archive of Formal Proofs},
   month   = dec,
   year    = 2015,
   note    = {\url{https://isa-afp.org/entries/Algebraic_Numbers.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Berlekamp_Zassenhaus, Sturm_Sequences
Used by:BenOr_Kozen_Reif, Hermite_Lindemann, LLL_Basis_Reduction
BenOr_Kozen_Reif, Cubic_Quartic_Equations, Hermite_Lindemann, LLL_Basis_Reduction

\ No newline at end of file diff --git a/web/entries/BD_Security_Compositional.html b/web/entries/BD_Security_Compositional.html --- a/web/entries/BD_Security_Compositional.html +++ b/web/entries/BD_Security_Compositional.html @@ -1,202 +1,202 @@ Compositional BD Security - Archive of Formal Proofs

 

 

 

 

 

 

Compositional BD Security

 

Title: Compositional BD Security
Authors: Thomas Bauereiss (thomas /at/ bauereiss /dot/ name) and Andrei Popescu
Submission date: 2021-08-16
Abstract: Building on a previous AFP entry that formalizes the Bounded-Deducibility Security (BD Security) framework [1], we formalize compositionality and transport theorems for information flow security. These results allow lifting BD Security properties from individual components specified as transition systems, to a composition of systems specified as communicating products of transition systems. The underlying ideas of these results are presented in the papers [1] and [2]. The latter paper also describes a major case study where these results have been used: on verifying the CoSMeDis distributed social media platform (itself formalized as an AFP entry that builds on this entry).
BibTeX:
@article{BD_Security_Compositional-AFP,
   author  = {Thomas Bauereiss and Andrei Popescu},
   title   = {Compositional BD Security},
   journal = {Archive of Formal Proofs},
   month   = aug,
   year    = 2021,
   note    = {\url{https://isa-afp.org/entries/BD_Security_Compositional.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Bounded_Deducibility_Security
Used by: CoSMeDis

- + \ No newline at end of file diff --git a/web/entries/Budan_Fourier.html b/web/entries/Budan_Fourier.html --- a/web/entries/Budan_Fourier.html +++ b/web/entries/Budan_Fourier.html @@ -1,228 +1,228 @@ The Budan-Fourier Theorem and Counting Real Roots with Multiplicity - Archive of Formal Proofs

 

 

 

 

 

 

The Budan-Fourier Theorem and Counting Real Roots with Multiplicity

 

- +
Title: The Budan-Fourier Theorem and Counting Real Roots with Multiplicity
Author: Wenda Li
Submission date: 2018-09-02
Abstract: This entry is mainly about counting and approximating real roots (of a polynomial) with multiplicity. We have first formalised the Budan-Fourier theorem: given a polynomial with real coefficients, we can calculate sign variations on Fourier sequences to over-approximate the number of real roots (counting multiplicity) within an interval. When all roots are known to be real, the over-approximation becomes tight: we can utilise this theorem to count real roots exactly. It is also worth noting that Descartes' rule of sign is a direct consequence of the Budan-Fourier theorem, and has been included in this entry. In addition, we have extended previous formalised Sturm's theorem to count real roots with multiplicity, while the original Sturm's theorem only counts distinct real roots. Compared to the Budan-Fourier theorem, our extended Sturm's theorem always counts roots exactly but may suffer from greater computational cost.
BibTeX:
@article{Budan_Fourier-AFP,
   author  = {Wenda Li},
   title   = {The Budan-Fourier Theorem and Counting Real Roots with Multiplicity},
   journal = {Archive of Formal Proofs},
   month   = sep,
   year    = 2018,
   note    = {\url{https://isa-afp.org/entries/Budan_Fourier.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Sturm_Tarski
Used by:Winding_Number_Eval
Three_Circles, Winding_Number_Eval

\ No newline at end of file diff --git a/web/entries/Card_Partitions.html b/web/entries/Card_Partitions.html --- a/web/entries/Card_Partitions.html +++ b/web/entries/Card_Partitions.html @@ -1,232 +1,232 @@ Cardinality of Set Partitions - Archive of Formal Proofs

 

 

 

 

 

 

Cardinality of Set Partitions

 

- +
Title: Cardinality of Set Partitions
Author: Lukas Bulwahn (lukas /dot/ bulwahn /at/ gmail /dot/ com)
Submission date: 2015-12-12
Abstract: The theory's main theorem states that the cardinality of set partitions of size k on a carrier set of size n is expressed by Stirling numbers of the second kind. In Isabelle, Stirling numbers of the second kind are defined in the AFP entry `Discrete Summation` through their well-known recurrence relation. The main theorem relates them to the alternative definition as cardinality of set partitions. The proof follows the simple and short explanation in Richard P. Stanley's `Enumerative Combinatorics: Volume 1` and Wikipedia, and unravels the full details and implicit reasoning steps of these explanations.
BibTeX:
@article{Card_Partitions-AFP,
   author  = {Lukas Bulwahn},
   title   = {Cardinality of Set Partitions},
   journal = {Archive of Formal Proofs},
   month   = dec,
   year    = 2015,
   note    = {\url{https://isa-afp.org/entries/Card_Partitions.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Discrete_Summation
Used by:Bell_Numbers_Spivey, Falling_Factorial_Sum, Twelvefold_Way
Bell_Numbers_Spivey, Design_Theory, Falling_Factorial_Sum, Twelvefold_Way

\ No newline at end of file diff --git a/web/entries/CoSMeDis.html b/web/entries/CoSMeDis.html --- a/web/entries/CoSMeDis.html +++ b/web/entries/CoSMeDis.html @@ -1,209 +1,209 @@ CoSMeDis: A confidentiality-verified distributed social media platform - Archive of Formal Proofs

 

 

 

 

 

 

CoSMeDis: A confidentiality-verified distributed social media platform

 

Title: CoSMeDis: A confidentiality-verified distributed social media platform
Authors: Thomas Bauereiss (thomas /at/ bauereiss /dot/ name) and Andrei Popescu
Submission date: 2021-08-16
Abstract: This entry contains the confidentiality verification of the (functional kernel of) the CoSMeDis distributed social media platform presented in [1]. CoSMeDis is a multi-node extension the CoSMed prototype social media platform [2, 3, 4]. The confidentiality properties are formalized as instances of BD Security [5, 6]. The lifting of confidentiality properties from single nodes to the entire CoSMeDis network is performed using compositionality and transport theorems for BD Security, which are described in [1] and formalized in a separate AFP entry.
BibTeX:
@article{CoSMeDis-AFP,
   author  = {Thomas Bauereiss and Andrei Popescu},
   title   = {CoSMeDis: A confidentiality-verified distributed social media platform},
   journal = {Archive of Formal Proofs},
   month   = aug,
   year    = 2021,
   note    = {\url{https://isa-afp.org/entries/CoSMeDis.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: BD_Security_Compositional, Fresh_Identifiers

- + \ No newline at end of file diff --git a/web/entries/Complex_Geometry.html b/web/entries/Complex_Geometry.html --- a/web/entries/Complex_Geometry.html +++ b/web/entries/Complex_Geometry.html @@ -1,200 +1,200 @@ Complex Geometry - Archive of Formal Proofs

 

 

 

 

 

 

Complex Geometry

 

- +
Title: Complex Geometry
Authors: Filip Marić (filip /at/ matf /dot/ bg /dot/ ac /dot/ rs) and Danijela Simić
Submission date: 2019-12-16
Abstract: A formalization of geometry of complex numbers is presented. Fundamental objects that are investigated are the complex plane extended by a single infinite point, its objects (points, lines and circles), and groups of transformations that act on them (e.g., inversions and Möbius transformations). Most objects are defined algebraically, but correspondence with classical geometric definitions is shown.
BibTeX:
@article{Complex_Geometry-AFP,
   author  = {Filip Marić and Danijela Simić},
   title   = {Complex Geometry},
   journal = {Archive of Formal Proofs},
   month   = dec,
   year    = 2019,
   note    = {\url{https://isa-afp.org/entries/Complex_Geometry.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Used by:Poincare_Disc
Cubic_Quartic_Equations, Poincare_Disc

\ No newline at end of file diff --git a/web/entries/Cubic_Quartic_Equations.html b/web/entries/Cubic_Quartic_Equations.html new file mode 100644 --- /dev/null +++ b/web/entries/Cubic_Quartic_Equations.html @@ -0,0 +1,195 @@ + + + + +Solving Cubic and Quartic Equations - Archive of Formal Proofs + + + + + + + + + + + + + + + + + + + + + + + + +
+

 

+ + + +

 

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

 

+

 

+
+
+

 

+

Solving + + Cubic + + and + + Quartic + + Equations + +

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:Solving Cubic and Quartic Equations
+ Author: + + René Thiemann (rene /dot/ thiemann /at/ uibk /dot/ ac /dot/ at) +
Submission date:2021-09-03
Abstract: +

We formalize Cardano's formula to solve a cubic equation +$$ax^3 + bx^2 + cx + d = 0,$$ as well as Ferrari's formula to +solve a quartic equation. We further turn both formulas into +executable algorithms based on the algebraic number implementation in +the AFP. To this end we also slightly extended this library, namely by +making the minimal polynomial of an algebraic number executable, and +by defining and implementing $n$-th roots of complex +numbers.

BibTeX: +
@article{Cubic_Quartic_Equations-AFP,
+  author  = {René Thiemann},
+  title   = {Solving Cubic and Quartic Equations},
+  journal = {Archive of Formal Proofs},
+  month   = sep,
+  year    = 2021,
+  note    = {\url{https://isa-afp.org/entries/Cubic_Quartic_Equations.html},
+            Formal proof development},
+  ISSN    = {2150-914x},
+}
+
License:BSD License
Depends on:Algebraic_Numbers, Complex_Geometry, Hermite_Lindemann
+ +

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/web/entries/Design_Theory.html b/web/entries/Design_Theory.html new file mode 100644 --- /dev/null +++ b/web/entries/Design_Theory.html @@ -0,0 +1,200 @@ + + + + +Combinatorial Design Theory - Archive of Formal Proofs + + + + + + + + + + + + + + + + + + + + + + + + +
+

 

+ + + +

 

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

 

+

 

+
+
+

 

+

Combinatorial + + Design + + Theory + +

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:Combinatorial Design Theory
+ Authors: + + Chelsea Edmonds and + Lawrence Paulson +
Submission date:2021-08-13
Abstract: +Combinatorial design theory studies incidence set systems with certain +balance and symmetry properties. It is closely related to hypergraph +theory. This formalisation presents a general library for formal +reasoning on incidence set systems, designs and their applications, +including formal definitions and proofs for many key properties, +operations, and theorems on the construction and existence of designs. +Notably, this includes formalising t-designs, balanced incomplete +block designs (BIBD), group divisible designs (GDD), pairwise balanced +designs (PBD), design isomorphisms, and the relationship between +graphs and designs. A locale-centric approach has been used to manage +the relationships between the many different types of designs. +Theorems of particular interest include the necessary conditions for +existence of a BIBD, Wilson's construction on GDDs, and +Bose's inequality on resolvable designs. Parts of this +formalisation are explored in the paper "A Modular First +Formalisation of Combinatorial Design Theory", presented at CICM 2021.
BibTeX: +
@article{Design_Theory-AFP,
+  author  = {Chelsea Edmonds and Lawrence Paulson},
+  title   = {Combinatorial Design Theory},
+  journal = {Archive of Formal Proofs},
+  month   = aug,
+  year    = 2021,
+  note    = {\url{https://isa-afp.org/entries/Design_Theory.html},
+            Formal proof development},
+  ISSN    = {2150-914x},
+}
+
License:BSD License
Depends on:Card_Partitions, Graph_Theory, Nested_Multisets_Ordinals
+ +

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/web/entries/Graph_Theory.html b/web/entries/Graph_Theory.html --- a/web/entries/Graph_Theory.html +++ b/web/entries/Graph_Theory.html @@ -1,239 +1,239 @@ Graph Theory - Archive of Formal Proofs

 

 

 

 

 

 

Graph Theory

 

- +
Title: Graph Theory
Author: Lars Noschinski
Submission date: 2013-04-28
Abstract: This development provides a formalization of directed graphs, supporting (labelled) multi-edges and infinite graphs. A polymorphic edge type allows edges to be treated as pairs of vertices, if multi-edges are not required. Formalized properties are i.a. walks (and related concepts), connectedness and subgraphs and basic properties of isomorphisms.

This formalization is used to prove characterizations of Euler Trails, Shortest Paths and Kuratowski subgraphs.

BibTeX:
@article{Graph_Theory-AFP,
   author  = {Lars Noschinski},
   title   = {Graph Theory},
   journal = {Archive of Formal Proofs},
   month   = apr,
   year    = 2013,
   note    = {\url{https://isa-afp.org/entries/Graph_Theory.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Used by:Parity_Game, Planarity_Certificates, ShortestPath
Design_Theory, Parity_Game, Planarity_Certificates, ShortestPath

\ No newline at end of file diff --git a/web/entries/Hermite_Lindemann.html b/web/entries/Hermite_Lindemann.html --- a/web/entries/Hermite_Lindemann.html +++ b/web/entries/Hermite_Lindemann.html @@ -1,210 +1,212 @@ The Hermite–Lindemann–Weierstraß Transcendence Theorem - Archive of Formal Proofs

 

 

 

 

 

 

The Hermite–Lindemann–Weierstraß Transcendence Theorem

 

- + + +
Title: The Hermite–Lindemann–Weierstraß Transcendence Theorem
Author: Manuel Eberl
Submission date: 2021-03-03
Abstract:

This article provides a formalisation of the Hermite-Lindemann-Weierstraß Theorem (also known as simply Hermite-Lindemann or Lindemann-Weierstraß). This theorem is one of the crowning achievements of 19th century number theory.

The theorem states that if $\alpha_1, \ldots, \alpha_n\in\mathbb{C}$ are algebraic numbers that are linearly independent over $\mathbb{Z}$, then $e^{\alpha_1},\ldots,e^{\alpha_n}$ are algebraically independent over $\mathbb{Q}$.

Like the previous formalisation in Coq by Bernard, I proceeded by formalising Baker's version of the theorem and proof and then deriving the original one from that. Baker's version states that for any algebraic numbers $\beta_1, \ldots, \beta_n\in\mathbb{C}$ and distinct algebraic numbers $\alpha_i, \ldots, \alpha_n\in\mathbb{C}$, we have $\beta_1 e^{\alpha_1} + \ldots + \beta_n e^{\alpha_n} = 0$ if and only if all the $\beta_i$ are zero.

This has a number of direct corollaries, e.g.:

  • $e$ and $\pi$ are transcendental
  • $e^z$, $\sin z$, $\tan z$, etc. are transcendental for algebraic $z\in\mathbb{C}\setminus\{0\}$
  • $\ln z$ is transcendental for algebraic $z\in\mathbb{C}\setminus\{0, 1\}$
BibTeX:
@article{Hermite_Lindemann-AFP,
   author  = {Manuel Eberl},
   title   = {The Hermite–Lindemann–Weierstraß Transcendence Theorem},
   journal = {Archive of Formal Proofs},
   month   = mar,
   year    = 2021,
   note    = {\url{https://isa-afp.org/entries/Hermite_Lindemann.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Algebraic_Numbers, Pi_Transcendental, Power_Sum_Polynomials
Used by:Cubic_Quartic_Equations

\ No newline at end of file diff --git a/web/entries/Lucas_Theorem.html b/web/entries/Lucas_Theorem.html --- a/web/entries/Lucas_Theorem.html +++ b/web/entries/Lucas_Theorem.html @@ -1,198 +1,198 @@ Lucas's Theorem - Archive of Formal Proofs

 

 

 

 

 

 

Lucas's Theorem

 

Title: Lucas's Theorem
Author: - Chelsea Edmonds (cle47 /at/ cam /dot/ ac /dot/ uk) + Chelsea Edmonds
Submission date: 2020-04-07
Abstract: This work presents a formalisation of a generating function proof for Lucas's theorem. We first outline extensions to the existing Formal Power Series (FPS) library, including an equivalence relation for coefficients modulo n, an alternate binomial theorem statement, and a formalised proof of the Freshman's dream (mod p) lemma. The second part of the work presents the formal proof of Lucas's Theorem. Working backwards, the formalisation first proves a well known corollary of the theorem which is easier to formalise, and then applies induction to prove the original theorem statement. The proof of the corollary aims to provide a good example of a formalised generating function equivalence proof using the FPS library. The final theorem statement is intended to be integrated into the formalised proof of Hilbert's 10th Problem.
BibTeX:
@article{Lucas_Theorem-AFP,
   author  = {Chelsea Edmonds},
   title   = {Lucas's Theorem},
   journal = {Archive of Formal Proofs},
   month   = apr,
   year    = 2020,
   note    = {\url{https://isa-afp.org/entries/Lucas_Theorem.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License

\ No newline at end of file diff --git a/web/entries/Nested_Multisets_Ordinals.html b/web/entries/Nested_Multisets_Ordinals.html --- a/web/entries/Nested_Multisets_Ordinals.html +++ b/web/entries/Nested_Multisets_Ordinals.html @@ -1,225 +1,225 @@ Formalization of Nested Multisets, Hereditary Multisets, and Syntactic Ordinals - Archive of Formal Proofs

 

 

 

 

 

 

Formalization of Nested Multisets, Hereditary Multisets, and Syntactic Ordinals

 

- +
Title: Formalization of Nested Multisets, Hereditary Multisets, and Syntactic Ordinals
Authors: Jasmin Christian Blanchette (j /dot/ c /dot/ blanchette /at/ vu /dot/ nl), Mathias Fleury and Dmitriy Traytel
Submission date: 2016-11-12
Abstract: This Isabelle/HOL formalization introduces a nested multiset datatype and defines Dershowitz and Manna's nested multiset order. The order is proved well founded and linear. By removing one constructor, we transform the nested multisets into hereditary multisets. These are isomorphic to the syntactic ordinals—the ordinals can be recursively expressed in Cantor normal form. Addition, subtraction, multiplication, and linear orders are provided on this type.
BibTeX:
@article{Nested_Multisets_Ordinals-AFP,
   author  = {Jasmin Christian Blanchette and Mathias Fleury and Dmitriy Traytel},
   title   = {Formalization of Nested Multisets, Hereditary Multisets, and Syntactic Ordinals},
   journal = {Archive of Formal Proofs},
   month   = nov,
   year    = 2016,
   note    = {\url{https://isa-afp.org/entries/Nested_Multisets_Ordinals.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: List-Index, Ordinal
Used by:Functional_Ordered_Resolution_Prover, Lambda_Free_KBOs, Lambda_Free_RPOs, Ordered_Resolution_Prover, PAC_Checker, Progress_Tracking
Design_Theory, Functional_Ordered_Resolution_Prover, Lambda_Free_KBOs, Lambda_Free_RPOs, Ordered_Resolution_Prover, PAC_Checker, Progress_Tracking

\ No newline at end of file diff --git a/web/entries/Polynomial_Interpolation.html b/web/entries/Polynomial_Interpolation.html --- a/web/entries/Polynomial_Interpolation.html +++ b/web/entries/Polynomial_Interpolation.html @@ -1,229 +1,229 @@ Polynomial Interpolation - Archive of Formal Proofs

 

 

 

 

 

 

Polynomial Interpolation

 

- +
Title: Polynomial Interpolation
Authors: René Thiemann (rene /dot/ thiemann /at/ uibk /dot/ ac /dot/ at) and Akihisa Yamada
Submission date: 2016-01-29
Abstract: We formalized three algorithms for polynomial interpolation over arbitrary fields: Lagrange's explicit expression, the recursive algorithm of Neville and Aitken, and the Newton interpolation in combination with an efficient implementation of divided differences. Variants of these algorithms for integer polynomials are also available, where sometimes the interpolation can fail; e.g., there is no linear integer polynomial p such that p(0) = 0 and p(2) = 1. Moreover, for the Newton interpolation for integer polynomials, we proved that all intermediate results that are computed during the algorithm must be integers. This admits an early failure detection in the implementation. Finally, we proved the uniqueness of polynomial interpolation.

The development also contains improved code equations to speed up the division of integers in target languages.

BibTeX:
@article{Polynomial_Interpolation-AFP,
   author  = {René Thiemann and Akihisa Yamada},
   title   = {Polynomial Interpolation},
   journal = {Archive of Formal Proofs},
   month   = jan,
   year    = 2016,
   note    = {\url{https://isa-afp.org/entries/Polynomial_Interpolation.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Sqrt_Babylonian
Used by:Deep_Learning, Formal_Puiseux_Series, Gauss_Sums, Polynomial_Factorization
Deep_Learning, Formal_Puiseux_Series, Gauss_Sums, Polynomial_Factorization, Three_Circles

\ No newline at end of file diff --git a/web/entries/Three_Circles.html b/web/entries/Three_Circles.html new file mode 100644 --- /dev/null +++ b/web/entries/Three_Circles.html @@ -0,0 +1,194 @@ + + + + +The Theorem of Three Circles - Archive of Formal Proofs + + + + + + + + + + + + + + + + + + + + + + + + +
+

 

+ + + +

 

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

 

+

 

+
+
+

 

+

The + + Theorem + + of + + Three + + Circles + +

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:The Theorem of Three Circles
+ Authors: + + Fox Thomson (foxthomson0 /at/ gmail /dot/ com) and + Wenda Li +
Submission date:2021-08-21
Abstract: +The Descartes test based on Bernstein coefficients and Descartes’ rule +of signs effectively (over-)approximates the number of real roots of a +univariate polynomial over an interval. In this entry we formalise the +theorem of three circles, which gives sufficient conditions for when +the Descartes test returns 0 or 1. This is the first step for +efficient root isolation.
BibTeX: +
@article{Three_Circles-AFP,
+  author  = {Fox Thomson and Wenda Li},
+  title   = {The Theorem of Three Circles},
+  journal = {Archive of Formal Proofs},
+  month   = aug,
+  year    = 2021,
+  note    = {\url{https://isa-afp.org/entries/Three_Circles.html},
+            Formal proof development},
+  ISSN    = {2150-914x},
+}
+
License:BSD License
Depends on:Budan_Fourier, Polynomial_Interpolation
+ +

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/web/index.html b/web/index.html --- a/web/index.html +++ b/web/index.html @@ -1,5624 +1,5650 @@ Archive of Formal Proofs

 

 

 

 

 

 

Archive of Formal Proofs

 

The Archive of Formal Proofs is a collection of proof libraries, examples, and larger scientific developments, mechanically checked in the theorem prover Isabelle. It is organized in the way of a scientific journal, is indexed by dblp and has an ISSN: 2150-914x. Submissions are refereed. The preferred citation style is available [here]. We encourage companion AFP submissions to conference and journal publications.

A development version of the archive is available as well.

 

 

+ + + + + + + + +
2021
+ 2021-09-03: Solving Cubic and Quartic Equations +
+ Author: + René Thiemann +
+ 2021-08-21: The Theorem of Three Circles +
+ Authors: + Fox Thomson + and Wenda Li +
2021-08-16: Fresh identifiers
Authors: Andrei Popescu and Thomas Bauereiss
2021-08-16: CoSMed: A confidentiality-verified social media platform
Authors: Thomas Bauereiss and Andrei Popescu
2021-08-16: CoSMeDis: A confidentiality-verified distributed social media platform
Authors: Thomas Bauereiss and Andrei Popescu
2021-08-16: CoCon: A Confidentiality-Verified Conference Management System
Authors: Andrei Popescu, Peter Lammich and Thomas Bauereiss
2021-08-16: Compositional BD Security
Authors: Thomas Bauereiss and Andrei Popescu
+ 2021-08-13: Combinatorial Design Theory +
+ Authors: + Chelsea Edmonds + and Lawrence Paulson +
2021-08-03: Relational Forests
Author: Walter Guttmann
2021-07-07: Finitely Generated Abelian Groups
Authors: Joseph Thommes and Manuel Eberl
2021-07-01: SpecCheck - Specification-Based Testing for Isabelle/ML
Authors: Kevin Kappelmann, Lukas Bulwahn and Sebastian Willenbrink
2021-06-22: Van der Waerden's Theorem
Authors: Katharina Kreuzer and Manuel Eberl
2021-06-18: MiniSail - A kernel language for the ISA specification language SAIL
Author: Mark Wassell
2021-06-17: Public Announcement Logic
Author: Asta Halkjær From
2021-06-04: A Shorter Compiler Correctness Proof for Language IMP
Author: Pasquale Noce
2021-05-24: Lyndon words
Authors: Štěpán Holub and Štěpán Starosta
2021-05-24: Graph Lemma
Authors: Štěpán Holub and Štěpán Starosta
2021-05-24: Combinatorics on Words Basics
Authors: Štěpán Holub, Martin Raška and Štěpán Starosta
2021-04-30: Regression Test Selection
Author: Susannah Mansky
2021-04-27: Isabelle's Metalogic: Formalization and Proof Checker
Authors: Tobias Nipkow and Simon Roßkopf
2021-04-27: Lifting the Exponent
Author: Jakub Kądziołka
2021-04-24: The BKR Decision Procedure for Univariate Real Arithmetic
Authors: Katherine Cordwell, Yong Kiam Tan and André Platzer
2021-04-23: Gale-Stewart Games
Author: Sebastiaan Joosten
2021-04-13: Formalization of Timely Dataflow's Progress Tracking Protocol
Authors: Matthias Brun, Sára Decova, Andrea Lattuada and Dmitriy Traytel
2021-04-01: Information Flow Control via Dependency Tracking
Author: Benedikt Nordhoff
2021-03-29: Grothendieck's Schemes in Algebraic Geometry
Authors: Anthony Bordg, Lawrence Paulson and Wenda Li
2021-03-23: Hensel's Lemma for the p-adic Integers
Author: Aaron Crighton
2021-03-17: Constructive Cryptography in HOL: the Communication Modeling Aspect
Authors: Andreas Lochbihler and S. Reza Sefidgar
2021-03-12: Two algorithms based on modular arithmetic: lattice basis reduction and Hermite normal form computation
Authors: Ralph Bottesch, Jose Divasón and René Thiemann
2021-03-03: Quantum projective measurements and the CHSH inequality
Author: Mnacho Echenim
2021-03-03: The Hermite–Lindemann–Weierstraß Transcendence Theorem
Author: Manuel Eberl
2021-03-01: Mereology
Author: Ben Blumson
2021-02-25: The Sunflower Lemma of Erdős and Rado
Author: René Thiemann
2021-02-24: A Verified Imperative Implementation of B-Trees
Author: Niels Mündler
2021-02-17: Formal Puiseux Series
Author: Manuel Eberl
2021-02-10: The Laws of Large Numbers
Author: Manuel Eberl
2021-01-31: Tarski's Parallel Postulate implies the 5th Postulate of Euclid, the Postulate of Playfair and the original Parallel Postulate of Euclid
Author: Roland Coghetto
2021-01-30: Solution to the xkcd Blue Eyes puzzle
Author: Jakub Kądziołka
2021-01-18: Hood-Melville Queue
Author: Alejandro Gómez-Londoño
2021-01-11: JinjaDCI: a Java semantics with dynamic class initialization
Author: Susannah Mansky

 

2020
2020-12-27: Cofinality and the Delta System Lemma
Author: Pedro Sánchez Terraf
2020-12-17: Topological semantics for paraconsistent and paracomplete logics
Author: David Fuenmayor
2020-12-08: Relational Minimum Spanning Tree Algorithms
Authors: Walter Guttmann and Nicolas Robinson-O'Brien
2020-12-07: Inline Caching and Unboxing Optimization for Interpreters
Author: Martin Desharnais
2020-12-05: The Relational Method with Message Anonymity for the Verification of Cryptographic Protocols
Author: Pasquale Noce
2020-11-22: Isabelle Marries Dirac: a Library for Quantum Computation and Quantum Information
Authors: Anthony Bordg, Hanna Lachnitt and Yijun He
2020-11-19: The HOL-CSP Refinement Toolkit
Authors: Safouan Taha, Burkhart Wolff and Lina Ye
2020-10-29: Verified SAT-Based AI Planning
Authors: Mohammad Abdulaziz and Friedrich Kurz
2020-10-29: AI Planning Languages Semantics
Authors: Mohammad Abdulaziz and Peter Lammich
2020-10-20: A Sound Type System for Physical Quantities, Units, and Measurements
Authors: Simon Foster and Burkhart Wolff
2020-10-12: Finite Map Extras
Author: Javier Díaz
2020-09-28: A Formal Model of the Safely Composable Document Object Model with Shadow Roots
Authors: Achim D. Brucker and Michael Herzberg
2020-09-28: A Formal Model of the Document Object Model with Shadow Roots
Authors: Achim D. Brucker and Michael Herzberg
2020-09-28: A Formalization of Safely Composable Web Components
Authors: Achim D. Brucker and Michael Herzberg
2020-09-28: A Formalization of Web Components
Authors: Achim D. Brucker and Michael Herzberg
2020-09-28: The Safely Composable DOM
Authors: Achim D. Brucker and Michael Herzberg
2020-09-16: Syntax-Independent Logic Infrastructure
Authors: Andrei Popescu and Dmitriy Traytel
2020-09-16: Robinson Arithmetic
Authors: Andrei Popescu and Dmitriy Traytel
2020-09-16: An Abstract Formalization of Gödel's Incompleteness Theorems
Authors: Andrei Popescu and Dmitriy Traytel
2020-09-16: From Abstract to Concrete Gödel's Incompleteness Theorems—Part II
Authors: Andrei Popescu and Dmitriy Traytel
2020-09-16: From Abstract to Concrete Gödel's Incompleteness Theorems—Part I
Authors: Andrei Popescu and Dmitriy Traytel
2020-09-07: A Formal Model of Extended Finite State Machines
Authors: Michael Foster, Achim D. Brucker, Ramsay G. Taylor and John Derrick
2020-09-07: Inference of Extended Finite State Machines
Authors: Michael Foster, Achim D. Brucker, Ramsay G. Taylor and John Derrick
2020-08-31: Practical Algebraic Calculus Checker
Authors: Mathias Fleury and Daniela Kaufmann
2020-08-31: Some classical results in inductive inference of recursive functions
Author: Frank J. Balbach
2020-08-26: Relational Disjoint-Set Forests
Author: Walter Guttmann
2020-08-25: Extensions to the Comprehensive Framework for Saturation Theorem Proving
Authors: Jasmin Blanchette and Sophie Tourret
2020-08-25: Putting the `K' into Bird's derivation of Knuth-Morris-Pratt string matching
Author: Peter Gammie
2020-08-04: Amicable Numbers
Author: Angeliki Koutsoukou-Argyraki
2020-08-03: Ordinal Partitions
Author: Lawrence C. Paulson
2020-07-21: A Formal Proof of The Chandy--Lamport Distributed Snapshot Algorithm
Authors: Ben Fiedler and Dmitriy Traytel
2020-07-13: Relational Characterisations of Paths
Authors: Walter Guttmann and Peter Höfner
2020-06-01: A Formally Verified Checker of the Safe Distance Traffic Rules for Autonomous Vehicles
Authors: Albert Rizaldi and Fabian Immler
2020-05-23: A verified algorithm for computing the Smith normal form of a matrix
Author: Jose Divasón
2020-05-16: The Nash-Williams Partition Theorem
Author: Lawrence C. Paulson
2020-05-13: A Formalization of Knuth–Bendix Orders
Authors: Christian Sternagel and René Thiemann
2020-05-12: Irrationality Criteria for Series by Erdős and Straus
Authors: Angeliki Koutsoukou-Argyraki and Wenda Li
2020-05-11: Recursion Theorem in ZF
Author: Georgy Dunaev
2020-05-08: An Efficient Normalisation Procedure for Linear Temporal Logic: Isabelle/HOL Formalisation
Author: Salomon Sickert
2020-05-06: Formalization of Forcing in Isabelle/ZF
Authors: Emmanuel Gunther, Miguel Pagano and Pedro Sánchez Terraf
2020-05-02: Banach-Steinhaus Theorem
Authors: Dominique Unruh and Jose Manuel Rodriguez Caballero
2020-04-27: Attack Trees in Isabelle for GDPR compliance of IoT healthcare systems
Author: Florian Kammueller
2020-04-24: Power Sum Polynomials
Author: Manuel Eberl
2020-04-24: The Lambert W Function on the Reals
Author: Manuel Eberl
2020-04-24: Gaussian Integers
Author: Manuel Eberl
2020-04-19: Matrices for ODEs
Author: Jonathan Julian Huerta y Munive
2020-04-16: Authenticated Data Structures As Functors
Authors: Andreas Lochbihler and Ognjen Marić
2020-04-10: Formalization of an Algorithm for Greedily Computing Associative Aggregations on Sliding Windows
Authors: Lukas Heimes, Dmitriy Traytel and Joshua Schneider
2020-04-09: A Comprehensive Framework for Saturation Theorem Proving
Author: Sophie Tourret
2020-04-09: Formalization of an Optimized Monitoring Algorithm for Metric First-Order Dynamic Logic with Aggregations
Authors: Thibault Dardinier, Lukas Heimes, Martin Raszyk, Joshua Schneider and Dmitriy Traytel
2020-04-08: Stateful Protocol Composition and Typing
Authors: Andreas V. Hess, Sebastian Mödersheim and Achim D. Brucker
2020-04-08: Automated Stateful Protocol Verification
Authors: Andreas V. Hess, Sebastian Mödersheim, Achim D. Brucker and Anders Schlichtkrull
2020-04-07: Lucas's Theorem
Author: - Chelsea Edmonds + Chelsea Edmonds
2020-03-25: Strong Eventual Consistency of the Collaborative Editing Framework WOOT
Authors: Emin Karayel and Edgar Gonzàlez
2020-03-22: Furstenberg's topology and his proof of the infinitude of primes
Author: Manuel Eberl
2020-03-12: An Under-Approximate Relational Logic
Author: Toby Murray
2020-03-07: Hello World
Authors: Cornelius Diekmann and Lars Hupel
2020-02-21: Implementing the Goodstein Function in λ-Calculus
Author: Bertram Felgenhauer
2020-02-10: A Generic Framework for Verified Compilers
Author: Martin Desharnais
2020-02-01: Arithmetic progressions and relative primes
Author: José Manuel Rodríguez Caballero
2020-01-31: A Hierarchy of Algebras for Boolean Subsets
Authors: Walter Guttmann and Bernhard Möller
2020-01-17: Mersenne primes and the Lucas–Lehmer test
Author: Manuel Eberl
2020-01-16: Verified Approximation Algorithms
Authors: Robin Eßmann, Tobias Nipkow, Simon Robillard and Ujkan Sulejmani
2020-01-13: Closest Pair of Points Algorithms
Authors: Martin Rau and Tobias Nipkow
2020-01-09: Skip Lists
Authors: Max W. Haslbeck and Manuel Eberl
2020-01-06: Bicategories
Author: Eugene W. Stark

 

2019
2019-12-27: The Irrationality of ζ(3)
Author: Manuel Eberl
2019-12-20: Formalizing a Seligman-Style Tableau System for Hybrid Logic
Author: Asta Halkjær From
2019-12-18: The Poincaré-Bendixson Theorem
Authors: Fabian Immler and Yong Kiam Tan
2019-12-16: Poincaré Disc Model
Authors: Danijela Simić, Filip Marić and Pierre Boutry
2019-12-16: Complex Geometry
Authors: Filip Marić and Danijela Simić
2019-12-10: Gauss Sums and the Pólya–Vinogradov Inequality
Authors: Rodrigo Raya and Manuel Eberl
2019-12-04: An Efficient Generalization of Counting Sort for Large, possibly Infinite Key Ranges
Author: Pasquale Noce
2019-11-27: Interval Arithmetic on 32-bit Words
Author: Brandon Bohrer
2019-10-24: Zermelo Fraenkel Set Theory in Higher-Order Logic
Author: Lawrence C. Paulson
2019-10-22: Isabelle/C
Authors: Frédéric Tuong and Burkhart Wolff
2019-10-16: VerifyThis 2019 -- Polished Isabelle Solutions
Authors: Peter Lammich and Simon Wimmer
2019-10-08: Aristotle's Assertoric Syllogistic
Author: Angeliki Koutsoukou-Argyraki
2019-10-07: Sigma Protocols and Commitment Schemes
Authors: David Butler and Andreas Lochbihler
2019-10-04: Clean - An Abstract Imperative Programming Language and its Theory
Authors: Frédéric Tuong and Burkhart Wolff
2019-09-16: Formalization of Multiway-Join Algorithms
Author: Thibault Dardinier
2019-09-10: Verification Components for Hybrid Systems
Author: Jonathan Julian Huerta y Munive
2019-09-06: Fourier Series
Author: Lawrence C Paulson
2019-08-30: A Case Study in Basic Algebra
Author: Clemens Ballarin
2019-08-16: Formalisation of an Adaptive State Counting Algorithm
Author: Robert Sachtleben
2019-08-14: Laplace Transform
Author: Fabian Immler
2019-08-06: Linear Programming
Authors: Julian Parsert and Cezary Kaliszyk
2019-08-06: Communicating Concurrent Kleene Algebra for Distributed Systems Specification
Authors: Maxime Buyse and Jason Jaskolka
2019-08-05: Selected Problems from the International Mathematical Olympiad 2019
Author: Manuel Eberl
2019-08-01: Stellar Quorum Systems
Author: Giuliano Losa
2019-07-30: A Formal Development of a Polychronous Polytimed Coordination Language
Authors: Hai Nguyen Van, Frédéric Boulanger and Burkhart Wolff
2019-07-27: Order Extension and Szpilrajn's Extension Theorem
Authors: Peter Zeller and Lukas Stevens
2019-07-18: A Sequent Calculus for First-Order Logic
Author: Asta Halkjær From
2019-07-08: A Verified Code Generator from Isabelle/HOL to CakeML
Author: Lars Hupel
2019-07-04: Formalization of a Monitoring Algorithm for Metric First-Order Temporal Logic
Authors: Joshua Schneider and Dmitriy Traytel
2019-06-27: Complete Non-Orders and Fixed Points
Authors: Akihisa Yamada and Jérémy Dubut
2019-06-25: Priority Search Trees
Authors: Peter Lammich and Tobias Nipkow
2019-06-25: Purely Functional, Simple, and Efficient Implementation of Prim and Dijkstra
Authors: Peter Lammich and Tobias Nipkow
2019-06-21: Linear Inequalities
Authors: Ralph Bottesch, Alban Reynaud and René Thiemann
2019-06-16: Hilbert's Nullstellensatz
Author: Alexander Maletzky
2019-06-15: Gröbner Bases, Macaulay Matrices and Dubé's Degree Bounds
Author: Alexander Maletzky
2019-06-13: Binary Heaps for IMP2
Author: Simon Griebel
2019-06-03: Differential Game Logic
Author: André Platzer
2019-05-30: Multidimensional Binary Search Trees
Author: Martin Rau
2019-05-14: Formalization of Generic Authenticated Data Structures
Authors: Matthias Brun and Dmitriy Traytel
2019-05-09: Multi-Party Computation
Authors: David Aspinall and David Butler
2019-04-26: HOL-CSP Version 2.0
Authors: Safouan Taha, Lina Ye and Burkhart Wolff
2019-04-16: A Compositional and Unified Translation of LTL into ω-Automata
Authors: Benedikt Seidl and Salomon Sickert
2019-04-06: A General Theory of Syntax with Bindings
Authors: Lorenzo Gheri and Andrei Popescu
2019-03-27: The Transcendence of Certain Infinite Series
Authors: Angeliki Koutsoukou-Argyraki and Wenda Li
2019-03-24: Quantum Hoare Logic
Authors: Junyi Liu, Bohua Zhan, Shuling Wang, Shenggang Ying, Tao Liu, Yangjia Li, Mingsheng Ying and Naijun Zhan
2019-03-09: Safe OCL
Author: Denis Nikiforov
2019-02-21: Elementary Facts About the Distribution of Primes
Author: Manuel Eberl
2019-02-14: Kruskal's Algorithm for Minimum Spanning Forest
Authors: Maximilian P.L. Haslbeck, Peter Lammich and Julian Biendarra
2019-02-11: Probabilistic Primality Testing
Authors: Daniel Stüwe and Manuel Eberl
2019-02-08: Universal Turing Machine
Authors: Jian Xu, Xingyuan Zhang, Christian Urban and Sebastiaan J. C. Joosten
2019-02-01: Isabelle/UTP: Mechanised Theory Engineering for Unifying Theories of Programming
Authors: Simon Foster, Frank Zeyda, Yakoub Nemouchi, Pedro Ribeiro and Burkhart Wolff
2019-02-01: The Inversions of a List
Author: Manuel Eberl
2019-01-17: Farkas' Lemma and Motzkin's Transposition Theorem
Authors: Ralph Bottesch, Max W. Haslbeck and René Thiemann
2019-01-15: IMP2 – Simple Program Verification in Isabelle/HOL
Authors: Peter Lammich and Simon Wimmer
2019-01-15: An Algebra for Higher-Order Terms
Author: Lars Hupel
2019-01-07: A Reduction Theorem for Store Buffers
Authors: Ernie Cohen and Norbert Schirmer

 

2018
2018-12-26: A Formal Model of the Document Object Model
Authors: Achim D. Brucker and Michael Herzberg
2018-12-25: Formalization of Concurrent Revisions
Author: Roy Overbeek
2018-12-21: Verifying Imperative Programs using Auto2
Author: Bohua Zhan
2018-12-17: Constructive Cryptography in HOL
Authors: Andreas Lochbihler and S. Reza Sefidgar
2018-12-11: Transformer Semantics
Author: Georg Struth
2018-12-11: Quantales
Author: Georg Struth
2018-12-11: Properties of Orderings and Lattices
Author: Georg Struth
2018-11-23: Graph Saturation
Author: Sebastiaan J. C. Joosten
2018-11-23: A Verified Functional Implementation of Bachmair and Ganzinger's Ordered Resolution Prover
Authors: Anders Schlichtkrull, Jasmin Christian Blanchette and Dmitriy Traytel
2018-11-20: Auto2 Prover
Author: Bohua Zhan
2018-11-16: Matroids
Author: Jonas Keinholz
2018-11-06: Deriving generic class instances for datatypes
Authors: Jonas Rädle and Lars Hupel
2018-10-30: Formalisation and Evaluation of Alan Gewirth's Proof for the Principle of Generic Consistency in Isabelle/HOL
Authors: David Fuenmayor and Christoph Benzmüller
2018-10-29: Epistemic Logic: Completeness of Modal Logics
Author: Asta Halkjær From
2018-10-22: Smooth Manifolds
Authors: Fabian Immler and Bohua Zhan
2018-10-19: Randomised Binary Search Trees
Author: Manuel Eberl
2018-10-19: Formalization of the Embedding Path Order for Lambda-Free Higher-Order Terms
Author: Alexander Bentkamp
2018-10-12: Upper Bounding Diameters of State Spaces of Factored Transition Systems
Authors: Friedrich Kurz and Mohammad Abdulaziz
2018-09-28: The Transcendence of π
Author: Manuel Eberl
2018-09-25: Symmetric Polynomials
Author: Manuel Eberl
2018-09-20: Signature-Based Gröbner Basis Algorithms
Author: Alexander Maletzky
2018-09-19: The Prime Number Theorem
Authors: Manuel Eberl and Lawrence C. Paulson
2018-09-15: Aggregation Algebras
Author: Walter Guttmann
2018-09-14: Octonions
Author: Angeliki Koutsoukou-Argyraki
2018-09-05: Quaternions
Author: Lawrence C. Paulson
2018-09-02: The Budan-Fourier Theorem and Counting Real Roots with Multiplicity
Author: Wenda Li
2018-08-24: An Incremental Simplex Algorithm with Unsatisfiable Core Generation
Authors: Filip Marić, Mirko Spasić and René Thiemann
2018-08-14: Minsky Machines
Author: Bertram Felgenhauer
2018-07-16: Pricing in discrete financial models
Author: Mnacho Echenim
2018-07-04: Von-Neumann-Morgenstern Utility Theorem
Authors: Julian Parsert and Cezary Kaliszyk
2018-06-23: Pell's Equation
Author: Manuel Eberl
2018-06-14: Projective Geometry
Author: Anthony Bordg
2018-06-14: The Localization of a Commutative Ring
Author: Anthony Bordg
2018-06-05: Partial Order Reduction
Author: Julian Brunner
2018-05-27: Optimal Binary Search Trees
Authors: Tobias Nipkow and Dániel Somogyi
2018-05-25: Hidden Markov Models
Author: Simon Wimmer
2018-05-24: Probabilistic Timed Automata
Authors: Simon Wimmer and Johannes Hölzl
2018-05-23: Irrational Rapidly Convergent Series
Authors: Angeliki Koutsoukou-Argyraki and Wenda Li
2018-05-23: Axiom Systems for Category Theory in Free Logic
Authors: Christoph Benzmüller and Dana Scott
2018-05-22: Monadification, Memoization and Dynamic Programming
Authors: Simon Wimmer, Shuwei Hu and Tobias Nipkow
2018-05-10: OpSets: Sequential Specifications for Replicated Datatypes
Authors: Martin Kleppmann, Victor B. F. Gomes, Dominic P. Mulligan and Alastair R. Beresford
2018-05-07: An Isabelle/HOL Formalization of the Modular Assembly Kit for Security Properties
Authors: Oliver Bračevac, Richard Gay, Sylvia Grewe, Heiko Mantel, Henning Sudbrock and Markus Tasch
2018-04-29: WebAssembly
Author: Conrad Watt
2018-04-27: VerifyThis 2018 - Polished Isabelle Solutions
Authors: Peter Lammich and Simon Wimmer
2018-04-24: Bounded Natural Functors with Covariance and Contravariance
Authors: Andreas Lochbihler and Joshua Schneider
2018-03-22: The Incompatibility of Fishburn-Strategyproofness and Pareto-Efficiency
Authors: Felix Brandt, Manuel Eberl, Christian Saile and Christian Stricker
2018-03-13: Weight-Balanced Trees
Authors: Tobias Nipkow and Stefan Dirix
2018-03-12: CakeML
Authors: Lars Hupel and Yu Zhang
2018-03-01: A Theory of Architectural Design Patterns
Author: Diego Marmsoler
2018-02-26: Hoare Logics for Time Bounds
Authors: Maximilian P. L. Haslbeck and Tobias Nipkow
2018-02-06: Treaps
Authors: Maximilian Haslbeck, Manuel Eberl and Tobias Nipkow
2018-02-06: A verified factorization algorithm for integer polynomials with polynomial complexity
Authors: Jose Divasón, Sebastiaan Joosten, René Thiemann and Akihisa Yamada
2018-02-06: First-Order Terms
Authors: Christian Sternagel and René Thiemann
2018-02-06: The Error Function
Author: Manuel Eberl
2018-02-02: A verified LLL algorithm
Authors: Ralph Bottesch, Jose Divasón, Maximilian Haslbeck, Sebastiaan Joosten, René Thiemann and Akihisa Yamada
2018-01-18: Formalization of Bachmair and Ganzinger's Ordered Resolution Prover
Authors: Anders Schlichtkrull, Jasmin Christian Blanchette, Dmitriy Traytel and Uwe Waldmann
2018-01-16: Gromov Hyperbolicity
Author: Sebastien Gouezel
2018-01-11: An Isabelle/HOL formalisation of Green's Theorem
Authors: Mohammad Abdulaziz and Lawrence C. Paulson
2018-01-08: Taylor Models
Authors: Christoph Traut and Fabian Immler

 

2017
2017-12-22: The Falling Factorial of a Sum
Author: Lukas Bulwahn
2017-12-21: The Median-of-Medians Selection Algorithm
Author: Manuel Eberl
2017-12-21: The Mason–Stothers Theorem
Author: Manuel Eberl
2017-12-21: Dirichlet L-Functions and Dirichlet's Theorem
Author: Manuel Eberl
2017-12-19: Operations on Bounded Natural Functors
Authors: Jasmin Christian Blanchette, Andrei Popescu and Dmitriy Traytel
2017-12-18: The string search algorithm by Knuth, Morris and Pratt
Authors: Fabian Hellauer and Peter Lammich
2017-11-22: Stochastic Matrices and the Perron-Frobenius Theorem
Author: René Thiemann
2017-11-09: The IMAP CmRDT
Authors: Tim Jungnickel, Lennart Oldenburg and Matthias Loibl
2017-11-06: Hybrid Multi-Lane Spatial Logic
Author: Sven Linker
2017-10-26: The Kuratowski Closure-Complement Theorem
Authors: Peter Gammie and Gianpaolo Gioiosa
2017-10-19: Transition Systems and Automata
Author: Julian Brunner
2017-10-19: Büchi Complementation
Author: Julian Brunner
2017-10-17: Evaluate Winding Numbers through Cauchy Indices
Author: Wenda Li
2017-10-17: Count the Number of Complex Roots
Author: Wenda Li
2017-10-14: Homogeneous Linear Diophantine Equations
Authors: Florian Messner, Julian Parsert, Jonas Schöpf and Christian Sternagel
2017-10-12: The Hurwitz and Riemann ζ Functions
Author: Manuel Eberl
2017-10-12: Linear Recurrences
Author: Manuel Eberl
2017-10-12: Dirichlet Series
Author: Manuel Eberl
2017-09-21: Computer-assisted Reconstruction and Assessment of E. J. Lowe's Modal Ontological Argument
Authors: David Fuenmayor and Christoph Benzmüller
2017-09-17: Representation and Partial Automation of the Principia Logico-Metaphysica in Isabelle/HOL
Author: Daniel Kirchner
2017-09-06: Anselm's God in Isabelle/HOL
Author: Ben Blumson
2017-09-01: Microeconomics and the First Welfare Theorem
Authors: Julian Parsert and Cezary Kaliszyk
2017-08-20: Root-Balanced Tree
Author: Tobias Nipkow
2017-08-20: Orbit-Stabiliser Theorem with Application to Rotational Symmetries
Author: Jonas Rädle
2017-08-16: The LambdaMu-calculus
Authors: Cristina Matache, Victor B. F. Gomes and Dominic P. Mulligan
2017-07-31: Stewart's Theorem and Apollonius' Theorem
Author: Lukas Bulwahn
2017-07-28: Dynamic Architectures
Author: Diego Marmsoler
2017-07-21: Declarative Semantics for Functional Languages
Author: Jeremy Siek
2017-07-15: HOLCF-Prelude
Authors: Joachim Breitner, Brian Huffman, Neil Mitchell and Christian Sternagel
2017-07-13: Minkowski's Theorem
Author: Manuel Eberl
2017-07-09: Verified Metatheory and Type Inference for a Name-Carrying Simply-Typed Lambda Calculus
Author: Michael Rawson
2017-07-07: A framework for establishing Strong Eventual Consistency for Conflict-free Replicated Datatypes
Authors: Victor B. F. Gomes, Martin Kleppmann, Dominic P. Mulligan and Alastair R. Beresford
2017-07-06: Stone-Kleene Relation Algebras
Author: Walter Guttmann
2017-06-21: Propositional Proof Systems
Authors: Julius Michaelis and Tobias Nipkow
2017-06-13: Partial Semigroups and Convolution Algebras
Authors: Brijesh Dongol, Victor B. F. Gomes, Ian J. Hayes and Georg Struth
2017-06-06: Buffon's Needle Problem
Author: Manuel Eberl
2017-06-01: Formalizing Push-Relabel Algorithms
Authors: Peter Lammich and S. Reza Sefidgar
2017-06-01: Flow Networks and the Min-Cut-Max-Flow Theorem
Authors: Peter Lammich and S. Reza Sefidgar
2017-05-25: Optics
Authors: Simon Foster and Frank Zeyda
2017-05-24: Developing Security Protocols by Refinement
Authors: Christoph Sprenger and Ivano Somaini
2017-05-24: Dictionary Construction
Author: Lars Hupel
2017-05-08: The Floyd-Warshall Algorithm for Shortest Paths
Authors: Simon Wimmer and Peter Lammich
2017-05-05: Probabilistic while loop
Author: Andreas Lochbihler
2017-05-05: Effect polymorphism in higher-order logic
Author: Andreas Lochbihler
2017-05-05: Monad normalisation
Authors: Joshua Schneider, Manuel Eberl and Andreas Lochbihler
2017-05-05: Game-based cryptography in HOL
Authors: Andreas Lochbihler, S. Reza Sefidgar and Bhargav Bhatt
2017-05-05: CryptHOL
Author: Andreas Lochbihler
2017-05-04: Monoidal Categories
Author: Eugene W. Stark
2017-05-01: Types, Tableaus and Gödel’s God in Isabelle/HOL
Authors: David Fuenmayor and Christoph Benzmüller
2017-04-28: Local Lexing
Author: Steven Obua
2017-04-19: Constructor Functions
Author: Lars Hupel
2017-04-18: Lazifying case constants
Author: Lars Hupel
2017-04-06: Subresultants
Authors: Sebastiaan Joosten, René Thiemann and Akihisa Yamada
2017-04-04: Expected Shape of Random Binary Search Trees
Author: Manuel Eberl
2017-03-15: The number of comparisons in QuickSort
Author: Manuel Eberl
2017-03-15: Lower bound on comparison-based sorting algorithms
Author: Manuel Eberl
2017-03-10: The Euler–MacLaurin Formula
Author: Manuel Eberl
2017-02-28: The Group Law for Elliptic Curves
Author: Stefan Berghofer
2017-02-26: Menger's Theorem
Author: Christoph Dittmann
2017-02-13: Differential Dynamic Logic
Author: Brandon Bohrer
2017-02-10: Abstract Soundness
Authors: Jasmin Christian Blanchette, Andrei Popescu and Dmitriy Traytel
2017-02-07: Stone Relation Algebras
Author: Walter Guttmann
2017-01-31: Refining Authenticated Key Agreement with Strong Adversaries
Authors: Joseph Lallemand and Christoph Sprenger
2017-01-24: Bernoulli Numbers
Authors: Lukas Bulwahn and Manuel Eberl
2017-01-17: Minimal Static Single Assignment Form
Authors: Max Wagner and Denis Lohner
2017-01-17: Bertrand's postulate
Authors: Julian Biendarra and Manuel Eberl
2017-01-12: The Transcendence of e
Author: Manuel Eberl
2017-01-08: Formal Network Models and Their Application to Firewall Policies
Authors: Achim D. Brucker, Lukas Brügger and Burkhart Wolff
2017-01-03: Verification of a Diffie-Hellman Password-based Authentication Protocol by Extending the Inductive Method
Author: Pasquale Noce
2017-01-01: First-Order Logic According to Harrison
Authors: Alexander Birch Jensen, Anders Schlichtkrull and Jørgen Villadsen

 

2016
2016-12-30: Concurrent Refinement Algebra and Rely Quotients
Authors: Julian Fell, Ian J. Hayes and Andrius Velykis
2016-12-29: The Twelvefold Way
Author: Lukas Bulwahn
2016-12-20: Proof Strategy Language
Author: Yutaka Nagashima
2016-12-07: Paraconsistency
Authors: Anders Schlichtkrull and Jørgen Villadsen
2016-11-29: COMPLX: A Verification Framework for Concurrent Imperative Programs
Authors: Sidney Amani, June Andronick, Maksym Bortin, Corey Lewis, Christine Rizkallah and Joseph Tuong
2016-11-23: Abstract Interpretation of Annotated Commands
Author: Tobias Nipkow
2016-11-16: Separata: Isabelle tactics for Separation Algebra
Authors: Zhe Hou, David Sanan, Alwen Tiu, Rajeev Gore and Ranald Clouston
2016-11-12: Formalization of Nested Multisets, Hereditary Multisets, and Syntactic Ordinals
Authors: Jasmin Christian Blanchette, Mathias Fleury and Dmitriy Traytel
2016-11-12: Formalization of Knuth–Bendix Orders for Lambda-Free Higher-Order Terms
Authors: Heiko Becker, Jasmin Christian Blanchette, Uwe Waldmann and Daniel Wand
2016-11-10: Expressiveness of Deep Learning
Author: Alexander Bentkamp
2016-10-25: Modal Logics for Nominal Transition Systems
Authors: Tjark Weber, Lars-Henrik Eriksson, Joachim Parrow, Johannes Borgström and Ramunas Gutkovas
2016-10-24: Stable Matching
Author: Peter Gammie
2016-10-21: LOFT — Verified Migration of Linux Firewalls to SDN
Authors: Julius Michaelis and Cornelius Diekmann
2016-10-19: Source Coding Theorem
Authors: Quentin Hibon and Lawrence C. Paulson
2016-10-19: A formal model for the SPARCv8 ISA and a proof of non-interference for the LEON3 processor
Authors: Zhe Hou, David Sanan, Alwen Tiu and Yang Liu
2016-10-14: The Factorization Algorithm of Berlekamp and Zassenhaus
Authors: Jose Divasón, Sebastiaan Joosten, René Thiemann and Akihisa Yamada
2016-10-11: Intersecting Chords Theorem
Author: Lukas Bulwahn
2016-10-05: Lp spaces
Author: Sebastien Gouezel
2016-09-30: Fisher–Yates shuffle
Author: Manuel Eberl
2016-09-29: Allen's Interval Calculus
Author: Fadoua Ghourabi
2016-09-23: Formalization of Recursive Path Orders for Lambda-Free Higher-Order Terms
Authors: Jasmin Christian Blanchette, Uwe Waldmann and Daniel Wand
2016-09-09: Iptables Semantics
Authors: Cornelius Diekmann and Lars Hupel
2016-09-06: A Variant of the Superposition Calculus
Author: Nicolas Peltier
2016-09-06: Stone Algebras
Author: Walter Guttmann
2016-09-01: Stirling's formula
Author: Manuel Eberl
2016-08-31: Routing
Authors: Julius Michaelis and Cornelius Diekmann
2016-08-24: Simple Firewall
Authors: Cornelius Diekmann, Julius Michaelis and Maximilian Haslbeck
2016-08-18: Infeasible Paths Elimination by Symbolic Execution Techniques: Proof of Correctness and Preservation of Paths
Authors: Romain Aissat, Frederic Voisin and Burkhart Wolff
2016-08-12: Formalizing the Edmonds-Karp Algorithm
Authors: Peter Lammich and S. Reza Sefidgar
2016-08-08: The Imperative Refinement Framework
Author: Peter Lammich
2016-08-07: Ptolemy's Theorem
Author: Lukas Bulwahn
2016-07-17: Surprise Paradox
Author: Joachim Breitner
2016-07-14: Pairing Heap
Authors: Hauke Brinkop and Tobias Nipkow
2016-07-05: A Framework for Verifying Depth-First Search Algorithms
Authors: Peter Lammich and René Neumann
2016-07-01: Chamber Complexes, Coxeter Systems, and Buildings
Author: Jeremy Sylvestre
2016-06-30: The Z Property
Authors: Bertram Felgenhauer, Julian Nagele, Vincent van Oostrom and Christian Sternagel
2016-06-30: The Resolution Calculus for First-Order Logic
Author: Anders Schlichtkrull
2016-06-28: IP Addresses
Authors: Cornelius Diekmann, Julius Michaelis and Lars Hupel
2016-06-28: Compositional Security-Preserving Refinement for Concurrent Imperative Programs
Authors: Toby Murray, Robert Sison, Edward Pierzchalski and Christine Rizkallah
2016-06-26: Category Theory with Adjunctions and Limits
Author: Eugene W. Stark
2016-06-26: Cardinality of Multisets
Author: Lukas Bulwahn
2016-06-25: A Dependent Security Type System for Concurrent Imperative Programs
Authors: Toby Murray, Robert Sison, Edward Pierzchalski and Christine Rizkallah
2016-06-21: Catalan Numbers
Author: Manuel Eberl
2016-06-18: Program Construction and Verification Components Based on Kleene Algebra
Authors: Victor B. F. Gomes and Georg Struth
2016-06-13: Conservation of CSP Noninterference Security under Concurrent Composition
Author: Pasquale Noce
2016-06-09: Finite Machine Word Library
Authors: Joel Beeren, Matthew Fernandez, Xin Gao, Gerwin Klein, Rafal Kolanski, Japheth Lim, Corey Lewis, Daniel Matichuk and Thomas Sewell
2016-05-31: Tree Decomposition
Author: Christoph Dittmann
2016-05-24: POSIX Lexing with Derivatives of Regular Expressions
Authors: Fahad Ausaf, Roy Dyckhoff and Christian Urban
2016-05-24: Cardinality of Equivalence Relations
Author: Lukas Bulwahn
2016-05-20: Perron-Frobenius Theorem for Spectral Radius Analysis
Authors: Jose Divasón, Ondřej Kunčar, René Thiemann and Akihisa Yamada
2016-05-20: The meta theory of the Incredible Proof Machine
Authors: Joachim Breitner and Denis Lohner
2016-05-18: A Constructive Proof for FLP
Authors: Benjamin Bisping, Paul-David Brodmann, Tim Jungnickel, Christina Rickmann, Henning Seidler, Anke Stüber, Arno Wilhelm-Weidner, Kirstin Peters and Uwe Nestmann
2016-05-09: A Formal Proof of the Max-Flow Min-Cut Theorem for Countable Networks
Author: Andreas Lochbihler
2016-05-05: Randomised Social Choice Theory
Author: Manuel Eberl
2016-05-04: The Incompatibility of SD-Efficiency and SD-Strategy-Proofness
Author: Manuel Eberl
2016-05-04: Spivey's Generalized Recurrence for Bell Numbers
Author: Lukas Bulwahn
2016-05-02: Gröbner Bases Theory
Authors: Fabian Immler and Alexander Maletzky
2016-04-28: No Faster-Than-Light Observers
Authors: Mike Stannett and István Németi
2016-04-27: Algorithms for Reduced Ordered Binary Decision Diagrams
Authors: Julius Michaelis, Maximilian Haslbeck, Peter Lammich and Lars Hupel
2016-04-27: A formalisation of the Cocke-Younger-Kasami algorithm
Author: Maksym Bortin
2016-04-26: Conservation of CSP Noninterference Security under Sequential Composition
Author: Pasquale Noce
2016-04-12: Kleene Algebras with Domain
Authors: Victor B. F. Gomes, Walter Guttmann, Peter Höfner, Georg Struth and Tjark Weber
2016-03-11: Propositional Resolution and Prime Implicates Generation
Author: Nicolas Peltier
2016-03-08: Timed Automata
Author: Simon Wimmer
2016-03-08: The Cartan Fixed Point Theorems
Author: Lawrence C. Paulson
2016-03-01: Linear Temporal Logic
Author: Salomon Sickert
2016-02-17: Analysis of List Update Algorithms
Authors: Maximilian P.L. Haslbeck and Tobias Nipkow
2016-02-05: Verified Construction of Static Single Assignment Form
Authors: Sebastian Ullrich and Denis Lohner
2016-01-29: Polynomial Interpolation
Authors: René Thiemann and Akihisa Yamada
2016-01-29: Polynomial Factorization
Authors: René Thiemann and Akihisa Yamada
2016-01-20: Knot Theory
Author: T.V.H. Prathamesh
2016-01-18: Tensor Product of Matrices
Author: T.V.H. Prathamesh
2016-01-14: Cardinality of Number Partitions
Author: Lukas Bulwahn

 

2015
2015-12-28: Basic Geometric Properties of Triangles
Author: Manuel Eberl
2015-12-28: The Divergence of the Prime Harmonic Series
Author: Manuel Eberl
2015-12-28: Liouville numbers
Author: Manuel Eberl
2015-12-28: Descartes' Rule of Signs
Author: Manuel Eberl
2015-12-22: The Stern-Brocot Tree
Authors: Peter Gammie and Andreas Lochbihler
2015-12-22: Applicative Lifting
Authors: Andreas Lochbihler and Joshua Schneider
2015-12-22: Algebraic Numbers in Isabelle/HOL
Authors: René Thiemann, Akihisa Yamada and Sebastiaan Joosten
2015-12-12: Cardinality of Set Partitions
Author: Lukas Bulwahn
2015-12-02: Latin Square
Author: Alexander Bentkamp
2015-12-01: Ergodic Theory
Author: Sebastien Gouezel
2015-11-19: Euler's Partition Theorem
Author: Lukas Bulwahn
2015-11-18: The Tortoise and Hare Algorithm
Author: Peter Gammie
2015-11-11: Planarity Certificates
Author: Lars Noschinski
2015-11-02: Positional Determinacy of Parity Games
Author: Christoph Dittmann
2015-09-16: A Meta-Model for the Isabelle API
Authors: Frédéric Tuong and Burkhart Wolff
2015-09-04: Converting Linear Temporal Logic to Deterministic (Generalized) Rabin Automata
Author: Salomon Sickert
2015-08-21: Matrices, Jordan Normal Forms, and Spectral Radius Theory
Authors: René Thiemann and Akihisa Yamada
2015-08-20: Decreasing Diagrams II
Author: Bertram Felgenhauer
2015-08-18: The Inductive Unwinding Theorem for CSP Noninterference Security
Author: Pasquale Noce
2015-08-12: Representations of Finite Groups
Author: Jeremy Sylvestre
2015-08-10: Analysing and Comparing Encodability Criteria for Process Calculi
Authors: Kirstin Peters and Rob van Glabbeek
2015-07-21: Generating Cases from Labeled Subgoals
Author: Lars Noschinski
2015-07-14: Landau Symbols
Author: Manuel Eberl
2015-07-14: The Akra-Bazzi theorem and the Master theorem
Author: Manuel Eberl
2015-07-07: Hermite Normal Form
Authors: Jose Divasón and Jesús Aransay
2015-06-27: Derangements Formula
Author: Lukas Bulwahn
2015-06-11: The Ipurge Unwinding Theorem for CSP Noninterference Security
Author: Pasquale Noce
2015-06-11: The Generic Unwinding Theorem for CSP Noninterference Security
Author: Pasquale Noce
2015-06-11: Binary Multirelations
Authors: Hitoshi Furusawa and Georg Struth
2015-06-11: Reasoning about Lists via List Interleaving
Author: Pasquale Noce
2015-06-07: Parameterized Dynamic Tables
Author: Tobias Nipkow
2015-05-28: Derivatives of Logical Formulas
Author: Dmitriy Traytel
2015-05-27: A Zoo of Probabilistic Systems
Authors: Johannes Hölzl, Andreas Lochbihler and Dmitriy Traytel
2015-04-30: VCG - Combinatorial Vickrey-Clarke-Groves Auctions
Authors: Marco B. Caminati, Manfred Kerber, Christoph Lange and Colin Rowat
2015-04-15: Residuated Lattices
Authors: Victor B. F. Gomes and Georg Struth
2015-04-13: Concurrent IMP
Author: Peter Gammie
2015-04-13: Relaxing Safely: Verified On-the-Fly Garbage Collection for x86-TSO
Authors: Peter Gammie, Tony Hosking and Kai Engelhardt
2015-03-30: Trie
Authors: Andreas Lochbihler and Tobias Nipkow
2015-03-18: Consensus Refined
Authors: Ognjen Maric and Christoph Sprenger
2015-03-11: Deriving class instances for datatypes
Authors: Christian Sternagel and René Thiemann
2015-02-20: The Safety of Call Arity
Author: Joachim Breitner
2015-02-12: QR Decomposition
Authors: Jose Divasón and Jesús Aransay
2015-02-12: Echelon Form
Authors: Jose Divasón and Jesús Aransay
2015-02-05: Finite Automata in Hereditarily Finite Set Theory
Author: Lawrence C. Paulson
2015-01-28: Verification of the UpDown Scheme
Author: Johannes Hölzl

 

2014
2014-11-28: The Unified Policy Framework (UPF)
Authors: Achim D. Brucker, Lukas Brügger and Burkhart Wolff
2014-10-23: Loop freedom of the (untimed) AODV routing protocol
Authors: Timothy Bourke and Peter Höfner
2014-10-13: Lifting Definition Option
Author: René Thiemann
2014-10-10: Stream Fusion in HOL with Code Generation
Authors: Andreas Lochbihler and Alexandra Maximova
2014-10-09: A Verified Compiler for Probability Density Functions
Authors: Manuel Eberl, Johannes Hölzl and Tobias Nipkow
2014-10-08: Formalization of Refinement Calculus for Reactive Systems
Author: Viorel Preoteasa
2014-10-03: XML
Authors: Christian Sternagel and René Thiemann
2014-10-03: Certification Monads
Authors: Christian Sternagel and René Thiemann
2014-09-25: Imperative Insertion Sort
Author: Christian Sternagel
2014-09-19: The Sturm-Tarski Theorem
Author: Wenda Li
2014-09-15: The Cayley-Hamilton Theorem
Authors: Stephan Adelsberger, Stefan Hetzl and Florian Pollak
2014-09-09: The Jordan-Hölder Theorem
Author: Jakob von Raumer
2014-09-04: Priority Queues Based on Braun Trees
Author: Tobias Nipkow
2014-09-03: Gauss-Jordan Algorithm and Its Applications
Authors: Jose Divasón and Jesús Aransay
2014-08-29: Vector Spaces
Author: Holden Lee
2014-08-29: Real-Valued Special Functions: Upper and Lower Bounds
Author: Lawrence C. Paulson
2014-08-13: Skew Heap
Author: Tobias Nipkow
2014-08-12: Splay Tree
Author: Tobias Nipkow
2014-07-29: Haskell's Show Class in Isabelle/HOL
Authors: Christian Sternagel and René Thiemann
2014-07-18: Formal Specification of a Generic Separation Kernel
Authors: Freek Verbeek, Sergey Tverdyshev, Oto Havle, Holger Blasum, Bruno Langenstein, Werner Stephan, Yakoub Nemouchi, Abderrahmane Feliachi, Burkhart Wolff and Julien Schmaltz
2014-07-13: pGCL for Isabelle
Author: David Cock
2014-07-07: Amortized Complexity Verified
Author: Tobias Nipkow
2014-07-04: Network Security Policy Verification
Author: Cornelius Diekmann
2014-07-03: Pop-Refinement
Author: Alessandro Coglio
2014-06-12: Decision Procedures for MSO on Words Based on Derivatives of Regular Expressions
Authors: Dmitriy Traytel and Tobias Nipkow
2014-06-08: Boolean Expression Checkers
Author: Tobias Nipkow
2014-05-28: Promela Formalization
Author: René Neumann
2014-05-28: Converting Linear-Time Temporal Logic to Generalized Büchi Automata
Authors: Alexander Schimpf and Peter Lammich
2014-05-28: Verified Efficient Implementation of Gabow's Strongly Connected Components Algorithm
Author: Peter Lammich
2014-05-28: A Fully Verified Executable LTL Model Checker
Authors: Javier Esparza, Peter Lammich, René Neumann, Tobias Nipkow, Alexander Schimpf and Jan-Georg Smaus
2014-05-28: The CAVA Automata Library
Author: Peter Lammich
2014-05-23: Transitive closure according to Roy-Floyd-Warshall
Author: Makarius Wenzel
2014-05-23: Noninterference Security in Communicating Sequential Processes
Author: Pasquale Noce
2014-05-21: Regular Algebras
Authors: Simon Foster and Georg Struth
2014-04-28: Formalisation and Analysis of Component Dependencies
Author: Maria Spichkova
2014-04-23: A Formalization of Declassification with WHAT-and-WHERE-Security
Authors: Sylvia Grewe, Alexander Lux, Heiko Mantel and Jens Sauer
2014-04-23: A Formalization of Strong Security
Authors: Sylvia Grewe, Alexander Lux, Heiko Mantel and Jens Sauer
2014-04-23: A Formalization of Assumptions and Guarantees for Compositional Noninterference
Authors: Sylvia Grewe, Heiko Mantel and Daniel Schoepe
2014-04-22: Bounded-Deducibility Security
Authors: Andrei Popescu, Peter Lammich and Thomas Bauereiss
2014-04-16: A shallow embedding of HyperCTL*
Authors: Markus N. Rabe, Peter Lammich and Andrei Popescu
2014-04-16: Abstract Completeness
Authors: Jasmin Christian Blanchette, Andrei Popescu and Dmitriy Traytel
2014-04-13: Discrete Summation
Author: Florian Haftmann
2014-04-03: Syntax and semantics of a GPU kernel programming language
Author: John Wickerson
2014-03-11: Probabilistic Noninterference
Authors: Andrei Popescu and Johannes Hölzl
2014-03-08: Mechanization of the Algebra for Wireless Networks (AWN)
Author: Timothy Bourke
2014-02-18: Mutually Recursive Partial Functions
Author: René Thiemann
2014-02-13: Properties of Random Graphs -- Subgraph Containment
Author: Lars Hupel
2014-02-11: Verification of Selection and Heap Sort Using Locales
Author: Danijela Petrovic
2014-02-07: Affine Arithmetic
Author: Fabian Immler
2014-02-06: Implementing field extensions of the form Q[sqrt(b)]
Author: René Thiemann
2014-01-30: Unified Decision Procedures for Regular Expression Equivalence
Authors: Tobias Nipkow and Dmitriy Traytel
2014-01-28: Secondary Sylow Theorems
Author: Jakob von Raumer
2014-01-25: Relation Algebra
Authors: Alasdair Armstrong, Simon Foster, Georg Struth and Tjark Weber
2014-01-23: Kleene Algebra with Tests and Demonic Refinement Algebras
Authors: Alasdair Armstrong, Victor B. F. Gomes and Georg Struth
2014-01-16: Featherweight OCL: A Proposal for a Machine-Checked Formal Semantics for OCL 2.5
Authors: Achim D. Brucker, Frédéric Tuong and Burkhart Wolff
2014-01-11: Sturm's Theorem
Author: Manuel Eberl
2014-01-11: Compositional Properties of Crypto-Based Components
Author: Maria Spichkova

 

2013
2013-12-01: A General Method for the Proof of Theorems on Tail-recursive Functions
Author: Pasquale Noce
2013-11-17: Gödel's Incompleteness Theorems
Author: Lawrence C. Paulson
2013-11-17: The Hereditarily Finite Sets
Author: Lawrence C. Paulson
2013-11-15: A Codatatype of Formal Languages
Author: Dmitriy Traytel
2013-11-14: Stream Processing Components: Isabelle/HOL Formalisation and Case Studies
Author: Maria Spichkova
2013-11-12: Gödel's God in Isabelle/HOL
Authors: Christoph Benzmüller and Bruno Woltzenlogel Paleo
2013-11-01: Decreasing Diagrams
Author: Harald Zankl
2013-10-02: Automatic Data Refinement
Author: Peter Lammich
2013-09-17: Native Word
Author: Andreas Lochbihler
2013-07-27: A Formal Model of IEEE Floating Point Arithmetic
Author: Lei Yu
2013-07-22: Pratt's Primality Certificates
Authors: Simon Wimmer and Lars Noschinski
2013-07-22: Lehmer's Theorem
Authors: Simon Wimmer and Lars Noschinski
2013-07-19: The Königsberg Bridge Problem and the Friendship Theorem
Author: Wenda Li
2013-06-27: Sound and Complete Sort Encodings for First-Order Logic
Authors: Jasmin Christian Blanchette and Andrei Popescu
2013-05-22: An Axiomatic Characterization of the Single-Source Shortest Path Problem
Author: Christine Rizkallah
2013-04-28: Graph Theory
Author: Lars Noschinski
2013-04-15: Light-weight Containers
Author: Andreas Lochbihler
2013-02-21: Nominal 2
Authors: Christian Urban, Stefan Berghofer and Cezary Kaliszyk
2013-01-31: The Correctness of Launchbury's Natural Semantics for Lazy Evaluation
Author: Joachim Breitner
2013-01-19: Ribbon Proofs
Author: John Wickerson
2013-01-16: Rank-Nullity Theorem in Linear Algebra
Authors: Jose Divasón and Jesús Aransay
2013-01-15: Kleene Algebra
Authors: Alasdair Armstrong, Georg Struth and Tjark Weber
2013-01-03: Computing N-th Roots using the Babylonian Method
Author: René Thiemann

 

2012
2012-11-14: A Separation Logic Framework for Imperative HOL
Authors: Peter Lammich and Rene Meis
2012-11-02: Open Induction
Authors: Mizuhito Ogawa and Christian Sternagel
2012-10-30: The independence of Tarski's Euclidean axiom
Author: T. J. M. Makarios
2012-10-27: Bondy's Theorem
Authors: Jeremy Avigad and Stefan Hetzl
2012-09-10: Possibilistic Noninterference
Authors: Andrei Popescu and Johannes Hölzl
2012-08-07: Generating linear orders for datatypes
Author: René Thiemann
2012-08-05: Proving the Impossibility of Trisecting an Angle and Doubling the Cube
Authors: Ralph Romanos and Lawrence C. Paulson
2012-07-27: Verifying Fault-Tolerant Distributed Algorithms in the Heard-Of Model
Authors: Henri Debrat and Stephan Merz
2012-07-01: Logical Relations for PCF
Author: Peter Gammie
2012-06-26: Type Constructor Classes and Monad Transformers
Author: Brian Huffman
2012-05-29: Psi-calculi in Isabelle
Author: Jesper Bengtson
2012-05-29: The pi-calculus in nominal logic
Author: Jesper Bengtson
2012-05-29: CCS in nominal logic
Author: Jesper Bengtson
2012-05-27: Isabelle/Circus
Authors: Abderrahmane Feliachi, Burkhart Wolff and Marie-Claude Gaudel
2012-05-11: Separation Algebra
Authors: Gerwin Klein, Rafal Kolanski and Andrew Boyton
2012-05-07: Stuttering Equivalence
Author: Stephan Merz
2012-05-02: Inductive Study of Confidentiality
Author: Giampaolo Bella
2012-04-26: Ordinary Differential Equations
Authors: Fabian Immler and Johannes Hölzl
2012-04-13: Well-Quasi-Orders
Author: Christian Sternagel
2012-03-01: Abortable Linearizable Modules
Authors: Rachid Guerraoui, Viktor Kuncak and Giuliano Losa
2012-02-29: Executable Transitive Closures
Author: René Thiemann
2012-02-06: A Probabilistic Proof of the Girth-Chromatic Number Theorem
Author: Lars Noschinski
2012-01-30: Refinement for Monadic Programs
Author: Peter Lammich
2012-01-30: Dijkstra's Shortest Path Algorithm
Authors: Benedikt Nordhoff and Peter Lammich
2012-01-03: Markov Models
Authors: Johannes Hölzl and Tobias Nipkow

 

2011
2011-11-19: A Definitional Encoding of TLA* in Isabelle/HOL
Authors: Gudmund Grov and Stephan Merz
2011-11-09: Efficient Mergesort
Author: Christian Sternagel
2011-09-22: Pseudo Hoops
Authors: George Georgescu, Laurentiu Leustean and Viorel Preoteasa
2011-09-22: Algebra of Monotonic Boolean Transformers
Author: Viorel Preoteasa
2011-09-22: Lattice Properties
Author: Viorel Preoteasa
2011-08-26: The Myhill-Nerode Theorem Based on Regular Expressions
Authors: Chunhan Wu, Xingyuan Zhang and Christian Urban
2011-08-19: Gauss-Jordan Elimination for Matrices Represented as Functions
Author: Tobias Nipkow
2011-07-21: Maximum Cardinality Matching
Author: Christine Rizkallah
2011-05-17: Knowledge-based programs
Author: Peter Gammie
2011-04-01: The General Triangle Is Unique
Author: Joachim Breitner
2011-03-14: Executable Transitive Closures of Finite Relations
Authors: Christian Sternagel and René Thiemann
2011-02-23: Interval Temporal Logic on Natural Numbers
Author: David Trachtenherz
2011-02-23: Infinite Lists
Author: David Trachtenherz
2011-02-23: AutoFocus Stream Processing for Single-Clocking and Multi-Clocking Semantics
Author: David Trachtenherz
2011-02-07: Lightweight Java
Authors: Rok Strniša and Matthew Parkinson
2011-01-10: RIPEMD-160
Author: Fabian Immler
2011-01-08: Lower Semicontinuous Functions
Author: Bogdan Grechuk

 

2010
2010-12-17: Hall's Marriage Theorem
Authors: Dongchen Jiang and Tobias Nipkow
2010-11-16: Shivers' Control Flow Analysis
Author: Joachim Breitner
2010-10-28: Finger Trees
Authors: Benedikt Nordhoff, Stefan Körner and Peter Lammich
2010-10-28: Functional Binomial Queues
Author: René Neumann
2010-10-28: Binomial Heaps and Skew Binomial Heaps
Authors: Rene Meis, Finn Nielsen and Peter Lammich
2010-08-29: Strong Normalization of Moggis's Computational Metalanguage
Author: Christian Doczkal
2010-08-10: Executable Multivariate Polynomials
Authors: Christian Sternagel, René Thiemann, Alexander Maletzky, Fabian Immler, Florian Haftmann, Andreas Lochbihler and Alexander Bentkamp
2010-08-08: Formalizing Statecharts using Hierarchical Automata
Authors: Steffen Helke and Florian Kammüller
2010-06-24: Free Groups
Author: Joachim Breitner
2010-06-20: Category Theory
Author: Alexander Katovsky
2010-06-17: Executable Matrix Operations on Matrices of Arbitrary Dimensions
Authors: Christian Sternagel and René Thiemann
2010-06-14: Abstract Rewriting
Authors: Christian Sternagel and René Thiemann
2010-05-28: Verification of the Deutsch-Schorr-Waite Graph Marking Algorithm using Data Refinement
Authors: Viorel Preoteasa and Ralph-Johan Back
2010-05-28: Semantics and Data Refinement of Invariant Based Programs
Authors: Viorel Preoteasa and Ralph-Johan Back
2010-05-22: A Complete Proof of the Robbins Conjecture
Author: Matthew Wampler-Doty
2010-05-12: Regular Sets and Expressions
Authors: Alexander Krauss and Tobias Nipkow
2010-04-30: Locally Nameless Sigma Calculus
Authors: Ludovic Henrio, Florian Kammüller, Bianca Lutz and Henry Sudhof
2010-03-29: Free Boolean Algebra
Author: Brian Huffman
2010-03-23: Inter-Procedural Information Flow Noninterference via Slicing
Author: Daniel Wasserrab
2010-03-23: Information Flow Noninterference via Slicing
Author: Daniel Wasserrab
2010-02-20: List Index
Author: Tobias Nipkow
2010-02-12: Coinductive
Author: Andreas Lochbihler

 

2009
2009-12-09: A Fast SAT Solver for Isabelle in Standard ML
Author: Armin Heller
2009-12-03: Formalizing the Logic-Automaton Connection
Authors: Stefan Berghofer and Markus Reiter
2009-11-25: Tree Automata
Author: Peter Lammich
2009-11-25: Collections Framework
Author: Peter Lammich
2009-11-22: Perfect Number Theorem
Author: Mark Ijbema
2009-11-13: Backing up Slicing: Verifying the Interprocedural Two-Phase Horwitz-Reps-Binkley Slicer
Author: Daniel Wasserrab
2009-10-30: The Worker/Wrapper Transformation
Author: Peter Gammie
2009-09-01: Ordinals and Cardinals
Author: Andrei Popescu
2009-08-28: Invertibility in Sequent Calculi
Author: Peter Chapman
2009-08-04: An Example of a Cofinitary Group in Isabelle/HOL
Author: Bart Kastermans
2009-05-06: Code Generation for Functions as Data
Author: Andreas Lochbihler
2009-04-29: Stream Fusion
Author: Brian Huffman

 

2008
2008-12-12: A Bytecode Logic for JML and Types
Authors: Lennart Beringer and Martin Hofmann
2008-11-10: Secure information flow and program logics
Authors: Lennart Beringer and Martin Hofmann
2008-11-09: Some classical results in Social Choice Theory
Author: Peter Gammie
2008-11-07: Fun With Tilings
Authors: Tobias Nipkow and Lawrence C. Paulson
2008-10-15: The Textbook Proof of Huffman's Algorithm
Author: Jasmin Christian Blanchette
2008-09-16: Towards Certified Slicing
Author: Daniel Wasserrab
2008-09-02: A Correctness Proof for the Volpano/Smith Security Typing System
Authors: Gregor Snelting and Daniel Wasserrab
2008-09-01: Arrow and Gibbard-Satterthwaite
Author: Tobias Nipkow
2008-08-26: Fun With Functions
Author: Tobias Nipkow
2008-07-23: Formal Verification of Modern SAT Solvers
Author: Filip Marić
2008-04-05: Recursion Theory I
Author: Michael Nedzelsky
2008-02-29: A Sequential Imperative Programming Language Syntax, Semantics, Hoare Logics and Verification Environment
Author: Norbert Schirmer
2008-02-29: BDD Normalisation
Authors: Veronika Ortner and Norbert Schirmer
2008-02-18: Normalization by Evaluation
Authors: Klaus Aehlig and Tobias Nipkow
2008-01-11: Quantifier Elimination for Linear Arithmetic
Author: Tobias Nipkow

 

2007
2007-12-14: Formalization of Conflict Analysis of Programs with Procedures, Thread Creation, and Monitors
Authors: Peter Lammich and Markus Müller-Olm
2007-12-03: Jinja with Threads
Author: Andreas Lochbihler
2007-11-06: Much Ado About Two
Author: Sascha Böhme
2007-08-12: Sums of Two and Four Squares
Author: Roelof Oosterhuis
2007-08-12: Fermat's Last Theorem for Exponents 3 and 4 and the Parametrisation of Pythagorean Triples
Author: Roelof Oosterhuis
2007-08-08: Fundamental Properties of Valuation Theory and Hensel's Lemma
Author: Hidetsune Kobayashi
2007-08-02: POPLmark Challenge Via de Bruijn Indices
Author: Stefan Berghofer
2007-08-02: First-Order Logic According to Fitting
Author: Stefan Berghofer

 

2006
2006-09-09: Hotel Key Card System
Author: Tobias Nipkow
2006-08-08: Abstract Hoare Logics
Author: Tobias Nipkow
2006-05-22: Flyspeck I: Tame Graphs
Authors: Gertrud Bauer and Tobias Nipkow
2006-05-15: CoreC++
Author: Daniel Wasserrab
2006-03-31: A Theory of Featherweight Java in Isabelle/HOL
Authors: J. Nathan Foster and Dimitrios Vytiniotis
2006-03-15: Instances of Schneider's generalized protocol of clock synchronization
Author: Damián Barsotti
2006-03-14: Cauchy's Mean Theorem and the Cauchy-Schwarz Inequality
Author: Benjamin Porter

 

2005
2005-11-11: Countable Ordinals
Author: Brian Huffman
2005-10-12: Fast Fourier Transform
Author: Clemens Ballarin
2005-06-24: Formalization of a Generalized Protocol for Clock Synchronization
Author: Alwen Tiu
2005-06-22: Proving the Correctness of Disk Paxos
Authors: Mauro Jaskelioff and Stephan Merz
2005-06-20: Jive Data and Store Model
Authors: Nicole Rauch and Norbert Schirmer
2005-06-01: Jinja is not Java
Authors: Gerwin Klein and Tobias Nipkow
2005-05-02: SHA1, RSA, PSS and more
Authors: Christina Lindenberg and Kai Wirt
2005-04-21: Category Theory to Yoneda's Lemma
Author: Greg O'Keefe

 

2004
2004-12-09: File Refinement
Authors: Karen Zee and Viktor Kuncak
2004-11-19: Integration theory and random variables
Author: Stefan Richter
2004-09-28: A Mechanically Verified, Efficient, Sound and Complete Theorem Prover For First Order Logic
Author: Tom Ridge
2004-09-20: Ramsey's theorem, infinitary version
Author: Tom Ridge
2004-09-20: Completeness theorem
Authors: James Margetson and Tom Ridge
2004-07-09: Compiling Exceptions Correctly
Author: Tobias Nipkow
2004-06-24: Depth First Search
Authors: Toshiaki Nishihara and Yasuhiko Minamide
2004-05-18: Groups, Rings and Modules
Authors: Hidetsune Kobayashi, L. Chen and H. Murao
2004-04-26: Topology
Author: Stefan Friedrich
2004-04-26: Lazy Lists II
Author: Stefan Friedrich
2004-04-05: Binary Search Trees
Author: Viktor Kuncak
2004-03-30: Functional Automata
Author: Tobias Nipkow
2004-03-19: Mini ML
Authors: Wolfgang Naraschewski and Tobias Nipkow
2004-03-19: AVL Trees
Authors: Tobias Nipkow and Cornelia Pusch
\ No newline at end of file diff --git a/web/rss.xml b/web/rss.xml --- a/web/rss.xml +++ b/web/rss.xml @@ -1,563 +1,561 @@ Archive of Formal Proofs https://www.isa-afp.org The Archive of Formal Proofs is a collection of proof libraries, examples, and larger scientific developments, mechanically checked in the theorem prover Isabelle. - 16 Aug 2021 00:00:00 +0000 + 03 Sep 2021 00:00:00 +0000 + + Solving Cubic and Quartic Equations + https://www.isa-afp.org/entries/Cubic_Quartic_Equations.html + https://www.isa-afp.org/entries/Cubic_Quartic_Equations.html + René Thiemann + 03 Sep 2021 00:00:00 +0000 + +<p>We formalize Cardano's formula to solve a cubic equation +$$ax^3 + bx^2 + cx + d = 0,$$ as well as Ferrari's formula to +solve a quartic equation. We further turn both formulas into +executable algorithms based on the algebraic number implementation in +the AFP. To this end we also slightly extended this library, namely by +making the minimal polynomial of an algebraic number executable, and +by defining and implementing $n$-th roots of complex +numbers.</p> + + + The Theorem of Three Circles + https://www.isa-afp.org/entries/Three_Circles.html + https://www.isa-afp.org/entries/Three_Circles.html + Fox Thomson, Wenda Li + 21 Aug 2021 00:00:00 +0000 + +The Descartes test based on Bernstein coefficients and Descartes’ rule +of signs effectively (over-)approximates the number of real roots of a +univariate polynomial over an interval. In this entry we formalise the +theorem of three circles, which gives sufficient conditions for when +the Descartes test returns 0 or 1. This is the first step for +efficient root isolation. + Fresh identifiers https://www.isa-afp.org/entries/Fresh_Identifiers.html https://www.isa-afp.org/entries/Fresh_Identifiers.html Andrei Popescu, Thomas Bauereiss 16 Aug 2021 00:00:00 +0000 This entry defines a type class with an operator returning a fresh identifier, given a set of already used identifiers and a preferred identifier. The entry provides a default instantiation for any infinite type, as well as executable instantiations for natural numbers and strings. CoSMed: A confidentiality-verified social media platform https://www.isa-afp.org/entries/CoSMed.html https://www.isa-afp.org/entries/CoSMed.html Thomas Bauereiss, Andrei Popescu 16 Aug 2021 00:00:00 +0000 This entry contains the confidentiality verification of the (functional kernel of) the CoSMed social media platform. The confidentiality properties are formalized as instances of BD Security [<a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">1</a>, <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">2</a>]. An innovation in the deployment of BD Security compared to previous work is the use of dynamic declassification triggers, incorporated as part of inductive bounds, for providing stronger guarantees that account for the repeated opening and closing of access windows. To further strengthen the confidentiality guarantees, we also prove "traceback" properties about the accessibility decisions affecting the information managed by the system. CoSMeDis: A confidentiality-verified distributed social media platform https://www.isa-afp.org/entries/CoSMeDis.html https://www.isa-afp.org/entries/CoSMeDis.html Thomas Bauereiss, Andrei Popescu 16 Aug 2021 00:00:00 +0000 This entry contains the confidentiality verification of the (functional kernel of) the CoSMeDis distributed social media platform presented in [<a href="https://doi.org/10.1109/SP.2017.24">1</a>]. CoSMeDis is a multi-node extension the CoSMed prototype social media platform [<a href="https://doi.org/10.1007/978-3-319-43144-4_6">2</a>, <a href="https://doi.org/10.1007/s10817-017-9443-3">3</a>, <a href="https://www.isa-afp.org/entries/CoSMed.html">4</a>]. The confidentiality properties are formalized as instances of BD Security [<a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">5</a>, <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">6</a>]. The lifting of confidentiality properties from single nodes to the entire CoSMeDis network is performed using compositionality and transport theorems for BD Security, which are described in [<a href="https://doi.org/10.1109/SP.2017.24">1</a>] and formalized in a separate <a href="https://www.isa-afp.org/entries/BD_Security_Compositional.html">AFP entry</a>. CoCon: A Confidentiality-Verified Conference Management System https://www.isa-afp.org/entries/CoCon.html https://www.isa-afp.org/entries/CoCon.html Andrei Popescu, Peter Lammich, Thomas Bauereiss 16 Aug 2021 00:00:00 +0000 This entry contains the confidentiality verification of the (functional kernel of) the CoCon conference management system [<a href="https://doi.org/10.1007/978-3-319-08867-9_11">1</a>, <a href="https://doi.org/10.1007/s10817-020-09566-9">2</a>]. The confidentiality properties refer to the documents managed by the system, namely papers, reviews, discussion logs and acceptance/rejection decisions, and also to the assignment of reviewers to papers. They have all been formulated as instances of BD Security [<a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">3</a>, <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">4</a>] and verified using the BD Security unwinding technique. Compositional BD Security https://www.isa-afp.org/entries/BD_Security_Compositional.html https://www.isa-afp.org/entries/BD_Security_Compositional.html Thomas Bauereiss, Andrei Popescu 16 Aug 2021 00:00:00 +0000 Building on a previous <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">AFP entry</a> that formalizes the Bounded-Deducibility Security (BD Security) framework <a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">[1]</a>, we formalize compositionality and transport theorems for information flow security. These results allow lifting BD Security properties from individual components specified as transition systems, to a composition of systems specified as communicating products of transition systems. The underlying ideas of these results are presented in the papers <a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">[1]</a> and <a href="https://doi.org/10.1109/SP.2017.24">[2]</a>. The latter paper also describes a major case study where these results have been used: on verifying the CoSMeDis distributed social media platform (itself formalized as an <a href="https://www.isa-afp.org/entries/CoSMeDis.html">AFP entry</a> that builds on this entry). + Combinatorial Design Theory + https://www.isa-afp.org/entries/Design_Theory.html + https://www.isa-afp.org/entries/Design_Theory.html + Chelsea Edmonds, Lawrence Paulson + 13 Aug 2021 00:00:00 +0000 + +Combinatorial design theory studies incidence set systems with certain +balance and symmetry properties. It is closely related to hypergraph +theory. This formalisation presents a general library for formal +reasoning on incidence set systems, designs and their applications, +including formal definitions and proofs for many key properties, +operations, and theorems on the construction and existence of designs. +Notably, this includes formalising t-designs, balanced incomplete +block designs (BIBD), group divisible designs (GDD), pairwise balanced +designs (PBD), design isomorphisms, and the relationship between +graphs and designs. A locale-centric approach has been used to manage +the relationships between the many different types of designs. +Theorems of particular interest include the necessary conditions for +existence of a BIBD, Wilson's construction on GDDs, and +Bose's inequality on resolvable designs. Parts of this +formalisation are explored in the paper "A Modular First +Formalisation of Combinatorial Design Theory", presented at CICM 2021. + + Relational Forests https://www.isa-afp.org/entries/Relational_Forests.html https://www.isa-afp.org/entries/Relational_Forests.html Walter Guttmann 03 Aug 2021 00:00:00 +0000 We study second-order formalisations of graph properties expressed as first-order formulas in relation algebras extended with a Kleene star. The formulas quantify over relations while still avoiding quantification over elements of the base set. We formalise the property of undirected graphs being acyclic this way. This involves a study of various kinds of orientation of graphs. We also verify basic algorithms to constructively prove several second-order properties. Finitely Generated Abelian Groups https://www.isa-afp.org/entries/Finitely_Generated_Abelian_Groups.html https://www.isa-afp.org/entries/Finitely_Generated_Abelian_Groups.html Joseph Thommes, Manuel Eberl 07 Jul 2021 00:00:00 +0000 This article deals with the formalisation of some group-theoretic results including the fundamental theorem of finitely generated abelian groups characterising the structure of these groups as a uniquely determined product of cyclic groups. Both the invariant factor decomposition and the primary decomposition are covered. Additional work includes results about the direct product, the internal direct product and more group-theoretic lemmas. SpecCheck - Specification-Based Testing for Isabelle/ML https://www.isa-afp.org/entries/SpecCheck.html https://www.isa-afp.org/entries/SpecCheck.html Kevin Kappelmann, Lukas Bulwahn, Sebastian Willenbrink 01 Jul 2021 00:00:00 +0000 SpecCheck is a <a href="https://en.wikipedia.org/wiki/QuickCheck">QuickCheck</a>-like testing framework for Isabelle/ML. You can use it to write specifications for ML functions. SpecCheck then checks whether your specification holds by testing your function against a given number of generated inputs. It helps you to identify bugs by printing counterexamples on failure and provides you timing information. SpecCheck is customisable and allows you to specify your own input generators, test output formats, as well as pretty printers and shrinking functions for counterexamples among other things. Van der Waerden's Theorem https://www.isa-afp.org/entries/Van_der_Waerden.html https://www.isa-afp.org/entries/Van_der_Waerden.html Katharina Kreuzer, Manuel Eberl 22 Jun 2021 00:00:00 +0000 This article formalises the proof of Van der Waerden's Theorem from Ramsey theory. Van der Waerden's Theorem states that for integers $k$ and $l$ there exists a number $N$ which guarantees that if an integer interval of length at least $N$ is coloured with $k$ colours, there will always be an arithmetic progression of length $l$ of the same colour in said interval. The proof goes along the lines of \cite{Swan}. The smallest number $N_{k,l}$ fulfilling Van der Waerden's Theorem is then called the Van der Waerden Number. Finding the Van der Waerden Number is still an open problem for most values of $k$ and $l$. MiniSail - A kernel language for the ISA specification language SAIL https://www.isa-afp.org/entries/MiniSail.html https://www.isa-afp.org/entries/MiniSail.html Mark Wassell 18 Jun 2021 00:00:00 +0000 MiniSail is a kernel language for Sail, an instruction set architecture (ISA) specification language. Sail is an imperative language with a light-weight dependent type system similar to refinement type systems. From an ISA specification, the Sail compiler can generate theorem prover code and C (or OCaml) to give an executable emulator for an architecture. The idea behind MiniSail is to capture the key and novel features of Sail in terms of their syntax, typing rules and operational semantics, and to confirm that they work together by proving progress and preservation lemmas. We use the Nominal2 library to handle binding. Public Announcement Logic https://www.isa-afp.org/entries/Public_Announcement_Logic.html https://www.isa-afp.org/entries/Public_Announcement_Logic.html Asta Halkjær From 17 Jun 2021 00:00:00 +0000 This work is a formalization of public announcement logic with countably many agents. It includes proofs of soundness and completeness for a variant of the axiom system PA + DIST! + NEC!. The completeness proof builds on the Epistemic Logic theory. A Shorter Compiler Correctness Proof for Language IMP https://www.isa-afp.org/entries/IMP_Compiler.html https://www.isa-afp.org/entries/IMP_Compiler.html Pasquale Noce 04 Jun 2021 00:00:00 +0000 This paper presents a compiler correctness proof for the didactic imperative programming language IMP, introduced in Nipkow and Klein's book on formal programming language semantics (version of March 2021), whose size is just two thirds of the book's proof in the number of formal text lines. As such, it promises to constitute a further enhanced reference for the formal verification of compilers meant for larger, real-world programming languages. The presented proof does not depend on language determinism, so that the proposed approach can be applied to non-deterministic languages as well. As a confirmation, this paper extends IMP with an additional non-deterministic choice command, and proves compiler correctness, viz. the simulation of compiled code execution by source code, for such extended language. Lyndon words https://www.isa-afp.org/entries/Combinatorics_Words_Lyndon.html https://www.isa-afp.org/entries/Combinatorics_Words_Lyndon.html Štěpán Holub, Štěpán Starosta 24 May 2021 00:00:00 +0000 Lyndon words are words lexicographically minimal in their conjugacy class. We formalize their basic properties and characterizations, in particular the concepts of the longest Lyndon suffix and the Lyndon factorization. Most of the work assumes a fixed lexicographical order. Nevertheless we also define the smallest relation guaranteeing lexicographical minimality of a given word (in its conjugacy class). Graph Lemma https://www.isa-afp.org/entries/Combinatorics_Words_Graph_Lemma.html https://www.isa-afp.org/entries/Combinatorics_Words_Graph_Lemma.html Štěpán Holub, Štěpán Starosta 24 May 2021 00:00:00 +0000 Graph lemma quantifies the defect effect of a system of word equations. That is, it provides an upper bound on the rank of the system. We formalize the proof based on the decomposition of a solution into its free basis. A direct application is an alternative proof of the fact that two noncommuting words form a code. Combinatorics on Words Basics https://www.isa-afp.org/entries/Combinatorics_Words.html https://www.isa-afp.org/entries/Combinatorics_Words.html Štěpán Holub, Martin Raška, Štěpán Starosta 24 May 2021 00:00:00 +0000 We formalize basics of Combinatorics on Words. This is an extension of existing theories on lists. We provide additional properties related to prefix, suffix, factor, length and rotation. The topics include prefix and suffix comparability, mismatch, word power, total and reversed morphisms, border, periods, primitivity and roots. We also formalize basic, mostly folklore results related to word equations: equidivisibility, commutation and conjugation. Slightly advanced properties include the Periodicity lemma (often cited as the Fine and Wilf theorem) and the variant of the Lyndon-Schützenberger theorem for words. We support the algebraic point of view which sees words as generators of submonoids of a free monoid. This leads to the concepts of the (free) hull, the (free) basis (or code). Regression Test Selection https://www.isa-afp.org/entries/Regression_Test_Selection.html https://www.isa-afp.org/entries/Regression_Test_Selection.html Susannah Mansky 30 Apr 2021 00:00:00 +0000 This development provides a general definition for safe Regression Test Selection (RTS) algorithms. RTS algorithms select which tests to rerun on revised code, reducing the time required to check for newly introduced errors. An RTS algorithm is considered safe if and only if all deselected tests would have unchanged results. This definition is instantiated with two class-collection-based RTS algorithms run over the JVM as modeled by JinjaDCI. This is achieved with a general definition for Collection Semantics, small-step semantics instrumented to collect information during execution. As the RTS definition mandates safety, these instantiations include proofs of safety. This work is described in Mansky and Gunter's LSFA 2020 paper and Mansky's doctoral thesis (UIUC, 2020). Isabelle's Metalogic: Formalization and Proof Checker https://www.isa-afp.org/entries/Metalogic_ProofChecker.html https://www.isa-afp.org/entries/Metalogic_ProofChecker.html Tobias Nipkow, Simon Roßkopf 27 Apr 2021 00:00:00 +0000 In this entry we formalize Isabelle's metalogic in Isabelle/HOL. Furthermore, we define a language of proof terms and an executable proof checker and prove its soundness wrt. the metalogic. The formalization is intentionally kept close to the Isabelle implementation(for example using de Brujin indices) to enable easy integration of generated code with the Isabelle system without a complicated translation layer. The formalization is described in our <a href="https://arxiv.org/pdf/2104.12224.pdf">CADE 28 paper</a>. Lifting the Exponent https://www.isa-afp.org/entries/Lifting_the_Exponent.html https://www.isa-afp.org/entries/Lifting_the_Exponent.html Jakub Kądziołka 27 Apr 2021 00:00:00 +0000 We formalize the <i>Lifting the Exponent Lemma</i>, which shows how to find the largest power of $p$ dividing $a^n \pm b^n$, for a prime $p$ and positive integers $a$ and $b$. The proof follows <a href="https://s3.amazonaws.com/aops-cdn.artofproblemsolving.com/resources/articles/lifting-the-exponent.pdf">Amir Hossein Parvardi's</a>. The BKR Decision Procedure for Univariate Real Arithmetic https://www.isa-afp.org/entries/BenOr_Kozen_Reif.html https://www.isa-afp.org/entries/BenOr_Kozen_Reif.html Katherine Cordwell, Yong Kiam Tan, André Platzer 24 Apr 2021 00:00:00 +0000 We formalize the univariate case of Ben-Or, Kozen, and Reif's decision procedure for first-order real arithmetic (the BKR algorithm). We also formalize the univariate case of Renegar's variation of the BKR algorithm. The two formalizations differ mathematically in minor ways (that have significant impact on the multivariate case), but are quite similar in proof structure. Both rely on sign-determination (finding the set of consistent sign assignments for a set of polynomials). The method used for sign-determination is similar to Tarski's original quantifier elimination algorithm (it stores key information in a matrix equation), but with a reduction step to keep complexity low. Gale-Stewart Games https://www.isa-afp.org/entries/GaleStewart_Games.html https://www.isa-afp.org/entries/GaleStewart_Games.html Sebastiaan Joosten 23 Apr 2021 00:00:00 +0000 This is a formalisation of the main result of Gale and Stewart from 1953, showing that closed finite games are determined. This property is now known as the Gale Stewart Theorem. While the original paper shows some additional theorems as well, we only formalize this main result, but do so in a somewhat general way. We formalize games of a fixed arbitrary length, including infinite length, using co-inductive lists, and show that defensive strategies exist unless the other player is winning. For closed games, defensive strategies are winning for the closed player, proving that such games are determined. For finite games, which are a special case in our formalisation, all games are closed. Formalization of Timely Dataflow's Progress Tracking Protocol https://www.isa-afp.org/entries/Progress_Tracking.html https://www.isa-afp.org/entries/Progress_Tracking.html Matthias Brun, Sára Decova, Andrea Lattuada, Dmitriy Traytel 13 Apr 2021 00:00:00 +0000 Large-scale stream processing systems often follow the dataflow paradigm, which enforces a program structure that exposes a high degree of parallelism. The Timely Dataflow distributed system supports expressive cyclic dataflows for which it offers low-latency data- and pipeline-parallel stream processing. To achieve high expressiveness and performance, Timely Dataflow uses an intricate distributed protocol for tracking the computation’s progress. We formalize this progress tracking protocol and verify its safety. Our formalization is described in detail in our forthcoming <a href="https://traytel.bitbucket.io/papers/itp21-progress_tracking/safe.pdf">ITP'21 paper</a>. Information Flow Control via Dependency Tracking https://www.isa-afp.org/entries/IFC_Tracking.html https://www.isa-afp.org/entries/IFC_Tracking.html Benedikt Nordhoff 01 Apr 2021 00:00:00 +0000 We provide a characterisation of how information is propagated by program executions based on the tracking data and control dependencies within executions themselves. The characterisation might be used for deriving approximative safety properties to be targeted by static analyses or checked at runtime. We utilise a simple yet versatile control flow graph model as a program representation. As our model is not assumed to be finite it can be instantiated for a broad class of programs. The targeted security property is indistinguishable security where executions produce sequences of observations and only non-terminating executions are allowed to drop a tail of those. A very crude approximation of our characterisation is slicing based on program dependence graphs, which we use as a minimal example and derive a corresponding soundness result. For further details and applications refer to the authors upcoming dissertation. Grothendieck's Schemes in Algebraic Geometry https://www.isa-afp.org/entries/Grothendieck_Schemes.html https://www.isa-afp.org/entries/Grothendieck_Schemes.html Anthony Bordg, Lawrence Paulson, Wenda Li 29 Mar 2021 00:00:00 +0000 We formalize mainstream structures in algebraic geometry culminating in Grothendieck's schemes: presheaves of rings, sheaves of rings, ringed spaces, locally ringed spaces, affine schemes and schemes. We prove that the spectrum of a ring is a locally ringed space, hence an affine scheme. Finally, we prove that any affine scheme is a scheme. Hensel's Lemma for the p-adic Integers https://www.isa-afp.org/entries/Padic_Ints.html https://www.isa-afp.org/entries/Padic_Ints.html Aaron Crighton 23 Mar 2021 00:00:00 +0000 We formalize the ring of <em>p</em>-adic integers within the framework of the HOL-Algebra library. The carrier of the ring is formalized as the inverse limit of quotients of the integers by powers of a fixed prime <em>p</em>. We define an integer-valued valuation, as well as an extended-integer valued valuation which sends 0 to the infinite element. Basic topological facts about the <em>p</em>-adic integers are formalized, including completeness and sequential compactness. Taylor expansions of polynomials over a commutative ring are defined, culminating in the formalization of Hensel's Lemma based on a proof due to Keith Conrad. Constructive Cryptography in HOL: the Communication Modeling Aspect https://www.isa-afp.org/entries/Constructive_Cryptography_CM.html https://www.isa-afp.org/entries/Constructive_Cryptography_CM.html Andreas Lochbihler, S. Reza Sefidgar 17 Mar 2021 00:00:00 +0000 Constructive Cryptography (CC) [<a href="https://conference.iiis.tsinghua.edu.cn/ICS2011/content/papers/14.html">ICS 2011</a>, <a href="https://doi.org/10.1007/978-3-642-27375-9_3">TOSCA 2011</a>, <a href="https://doi.org/10.1007/978-3-662-53641-4_1">TCC 2016</a>] introduces an abstract approach to composable security statements that allows one to focus on a particular aspect of security proofs at a time. Instead of proving the properties of concrete systems, CC studies system classes, i.e., the shared behavior of similar systems, and their transformations. Modeling of systems communication plays a crucial role in composability and reusability of security statements; yet, this aspect has not been studied in any of the existing CC results. We extend our previous CC formalization [<a href="https://isa-afp.org/entries/Constructive_Cryptography.html">Constructive_Cryptography</a>, <a href="https://doi.org/10.1109/CSF.2019.00018">CSF 2019</a>] with a new semantic domain called Fused Resource Templates (FRT) that abstracts over the systems communication patterns in CC proofs. This widens the scope of cryptography proof formalizations in the CryptHOL library [<a href="https://isa-afp.org/entries/CryptHOL.html">CryptHOL</a>, <a href="https://doi.org/10.1007/978-3-662-49498-1_20">ESOP 2016</a>, <a href="https://doi.org/10.1007/s00145-019-09341-z">J Cryptol 2020</a>]. This formalization is described in <a href="http://www.andreas-lochbihler.de/pub/basin2021.pdf">Abstract Modeling of Systems Communication in Constructive Cryptography using CryptHOL</a>. Two algorithms based on modular arithmetic: lattice basis reduction and Hermite normal form computation https://www.isa-afp.org/entries/Modular_arithmetic_LLL_and_HNF_algorithms.html https://www.isa-afp.org/entries/Modular_arithmetic_LLL_and_HNF_algorithms.html Ralph Bottesch, Jose Divasón, René Thiemann 12 Mar 2021 00:00:00 +0000 We verify two algorithms for which modular arithmetic plays an essential role: Storjohann's variant of the LLL lattice basis reduction algorithm and Kopparty's algorithm for computing the Hermite normal form of a matrix. To do this, we also formalize some facts about the modulo operation with symmetric range. Our implementations are based on the original papers, but are otherwise efficient. For basis reduction we formalize two versions: one that includes all of the optimizations/heuristics from Storjohann's paper, and one excluding a heuristic that we observed to often decrease efficiency. We also provide a fast, self-contained certifier for basis reduction, based on the efficient Hermite normal form algorithm. Quantum projective measurements and the CHSH inequality https://www.isa-afp.org/entries/Projective_Measurements.html https://www.isa-afp.org/entries/Projective_Measurements.html Mnacho Echenim 03 Mar 2021 00:00:00 +0000 This work contains a formalization of quantum projective measurements, also known as von Neumann measurements, which are based on elements of spectral theory. We also formalized the CHSH inequality, an inequality involving expectations in a probability space that is violated by quantum measurements, thus proving that quantum mechanics cannot be modeled with an underlying local hidden-variable theory. - - The Hermite–Lindemann–Weierstraß Transcendence Theorem - https://www.isa-afp.org/entries/Hermite_Lindemann.html - https://www.isa-afp.org/entries/Hermite_Lindemann.html - Manuel Eberl - 03 Mar 2021 00:00:00 +0000 - -<p>This article provides a formalisation of the -Hermite-Lindemann-Weierstraß Theorem (also known as simply -Hermite-Lindemann or Lindemann-Weierstraß). This theorem is one of the -crowning achievements of 19th century number theory.</p> -<p>The theorem states that if $\alpha_1, \ldots, -\alpha_n\in\mathbb{C}$ are algebraic numbers that are linearly -independent over $\mathbb{Z}$, then $e^{\alpha_1},\ldots,e^{\alpha_n}$ -are algebraically independent over $\mathbb{Q}$.</p> -<p>Like the <a -href="https://doi.org/10.1007/978-3-319-66107-0_5">previous -formalisation in Coq by Bernard</a>, I proceeded by formalising -<a -href="https://doi.org/10.1017/CBO9780511565977">Baker's -version of the theorem and proof</a> and then deriving the -original one from that. Baker's version states that for any -algebraic numbers $\beta_1, \ldots, \beta_n\in\mathbb{C}$ and distinct -algebraic numbers $\alpha_i, \ldots, \alpha_n\in\mathbb{C}$, we have -$\beta_1 e^{\alpha_1} + \ldots + \beta_n e^{\alpha_n} = 0$ if and only -if all the $\beta_i$ are zero.</p> <p>This has a number of -direct corollaries, e.g.:</p> <ul> <li>$e$ and $\pi$ -are transcendental</li> <li>$e^z$, $\sin z$, $\tan z$, -etc. are transcendental for algebraic -$z\in\mathbb{C}\setminus\{0\}$</li> <li>$\ln z$ is -transcendental for algebraic $z\in\mathbb{C}\setminus\{0, -1\}$</li> </ul> - - - Mereology - https://www.isa-afp.org/entries/Mereology.html - https://www.isa-afp.org/entries/Mereology.html - Ben Blumson - 01 Mar 2021 00:00:00 +0000 - -We use Isabelle/HOL to verify elementary theorems and alternative -axiomatizations of classical extensional mereology. - - - The Sunflower Lemma of Erdős and Rado - https://www.isa-afp.org/entries/Sunflowers.html - https://www.isa-afp.org/entries/Sunflowers.html - René Thiemann - 25 Feb 2021 00:00:00 +0000 - -We formally define sunflowers and provide a formalization of the -sunflower lemma of Erd&odblac;s and Rado: whenever a set of -size-<i>k</i>-sets has a larger cardinality than -<i>(r - 1)<sup>k</sup> &middot; k!</i>, -then it contains a sunflower of cardinality <i>r</i>. - diff --git a/web/statistics.html b/web/statistics.html --- a/web/statistics.html +++ b/web/statistics.html @@ -1,307 +1,307 @@ Archive of Formal Proofs

 

 

 

 

 

 

Statistics

 

Statistics

- - + + - +
Number of Articles:614
Number of Authors:392
Number of Articles:617
Number of Authors:393
Number of lemmas:~174,000
Lines of Code:~3,066,300
Lines of Code:~3,049,000

Most used AFP articles:

NameUsed by ? articles
1. List-Index 18
2. Show 13
3. Coinductive 12
Collections 12
Regular-Sets 12
4. Landau_Symbols 11
5. Jordan_Normal_Form 10
Polynomial_Factorization 10
6. Abstract-Rewriting 9
Automatic_Refinement 9
Deriving 9
Native_Word 9

Growth in number of articles:

Growth in lines of code:

Growth in number of authors:

Size of articles:

\ No newline at end of file diff --git a/web/topics.html b/web/topics.html --- a/web/topics.html +++ b/web/topics.html @@ -1,975 +1,978 @@ Archive of Formal Proofs

 

 

 

 

 

 

Index by Topic

 

Computer science

Artificial intelligence

Automata and formal languages

Algorithms

Knuth_Morris_Pratt   Probabilistic_While   Comparison_Sort_Lower_Bound   Quick_Sort_Cost   TortoiseHare   Selection_Heap_Sort   VerifyThis2018   CYK   Boolean_Expression_Checkers   Efficient-Mergesort   SATSolverVerification   MuchAdoAboutTwo   First_Order_Terms   Monad_Memo_DP   Hidden_Markov_Models   Imperative_Insertion_Sort   Formal_SSA   ROBDD   Median_Of_Medians_Selection   Fisher_Yates   Optimal_BST   IMP2   Auto2_Imperative_HOL   List_Inversions   IMP2_Binary_Heap   MFOTL_Monitor   Adaptive_State_Counting   Generic_Join   VerifyThis2019   Generalized_Counting_Sort   MFODL_Monitor_Optimized   Sliding_Window_Algorithm   PAC_Checker   Regression_Test_Selection   Graph: DFS_Framework   Prpu_Maxflow   Floyd_Warshall   Roy_Floyd_Warshall   Dijkstra_Shortest_Path   EdmondsKarp_Maxflow   Depth-First-Search   GraphMarkingIBP   Transitive-Closure   Transitive-Closure-II   Gabow_SCC   Kruskal   Prim_Dijkstra_Simple   Relational_Minimum_Spanning_Trees   Distributed: DiskPaxos   GenClock   ClockSynchInst   Heard_Of   Consensus_Refined   Abortable_Linearizable_Modules   IMAP-CRDT   CRDT   Chandy_Lamport   OpSets   Stellar_Quorums   WOOT_Strong_Eventual_Consistency   Progress_Tracking   Concurrent: ConcurrentGC   Online: List_Update   Geometry: Closest_Pair_Points   Approximation: Approximation_Algorithms   Mathematical: FFT   Gauss-Jordan-Elim-Fun   UpDown_Scheme   Polynomials   Gauss_Jordan   Echelon_Form   QR_Decomposition   Hermite   Groebner_Bases   Diophantine_Eqns_Lin_Hom   Taylor_Models   LLL_Basis_Reduction   Signature_Groebner   BenOr_Kozen_Reif   Smith_Normal_Form   Safe_Distance   Modular_arithmetic_LLL_and_HNF_algorithms   Optimization: Simplex   Quantum computing: Isabelle_Marries_Dirac   Projective_Measurements  

Concurrency

Data structures

Functional programming

Hardware

SPARCv8  

Machine learning

Networks

Programming languages

Clean   Decl_Sem_Fun_PL   Language definitions: CakeML   WebAssembly   pGCL   GPU_Kernel_PL   LightweightJava   CoreC++   FeatherweightJava   Jinja   JinjaThreads   Locally-Nameless-Sigma   AutoFocus-Stream   FocusStreamsCaseStudies   Isabelle_Meta_Model   Simpl   Complx   Safe_OCL   Isabelle_C   JinjaDCI   Lambda calculi: Higher_Order_Terms   Launchbury   PCF   POPLmark-deBruijn   Lam-ml-Normalization   LambdaMu   Binding_Syntax_Theory   LambdaAuth   Type systems: Name_Carrying_Type_Inference   MiniML   Possibilistic_Noninterference   SIFUM_Type_Systems   Dependent_SIFUM_Type_Systems   Strong_Security   WHATandWHERE_Security   VolpanoSmith   Physical_Quantities   MiniSail   Logics: ConcurrentIMP   Refine_Monadic   Automatic_Refinement   MonoBoolTranAlgebra   Simpl   Separation_Algebra   Separation_Logic_Imperative_HOL   Relational-Incorrectness-Logic   Abstract-Hoare-Logics   Kleene_Algebra   KAT_and_DRA   KAD   BytecodeLogicJmlTypes   DataRefinementIBP   RefinementReactive   SIFPL   TLA   Ribbon_Proofs   Separata   Complx   Differential_Dynamic_Logic   Hoare_Time   IMP2   UTP   QHLProver   Differential_Game_Logic   Compiling: CakeML_Codegen   Compiling-Exceptions-Correctly   NormByEval   Density_Compiler   VeriComp   IMP_Compiler   Static analysis: RIPEMD-160-SPARK   Program-Conflict-Analysis   Shivers-CFA   Slicing   HRB-Slicing   InfPathElimination   Abs_Int_ITP2012   Transformations: Call_Arity   Refine_Imperative_HOL   WorkerWrapper   Monad_Memo_DP   Formal_SSA   Minimal_SSA   Misc: JiveDataStoreModel   Pop_Refinement   Case_Labeling   Interpreter_Optimizations  

Security

Semantics

System description languages

Logic

Philosophical aspects

General logic

Computability

Set theory

Proof theory

Rewriting

Mathematics

Order

Algebra

Analysis

Probability theory

Number theory

Games and economics

Geometry

Topology

Graph theory

Combinatorics

Category theory

Physics

Misc

Tools

\ No newline at end of file