diff --git a/metadata/metadata b/metadata/metadata --- a/metadata/metadata +++ b/metadata/metadata @@ -1,12005 +1,12051 @@ [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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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)
[2021-11-15] Improvement of alphabet and chantype commands to support code generation. Addition of a tactic "rename_alpha_vars" that removes the subscript vs in proof goals. Bug fixes and improvements to alphabet command ML implementation. Additional laws for scenes. (revisions 9f8bcd71c121 and c061bf9f46f3)
[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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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)
[2021-07-22]: Minor changes to sublocale declarations related to functor/natural transformation to avoid issues with global interpretations reported 2/2/2021 by Filip Smola. (revision 49d3aa43c180)
[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 = manuel@pruvisto.org [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 = manuel@pruvisto.org [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 = manuel@pruvisto.org [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 = manuel@pruvisto.org [Euler_MacLaurin] title = The Euler–MacLaurin Formula author = Manuel Eberl topic = Mathematics/Analysis date = 2017-03-10 notify = manuel@pruvisto.org 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). Papers: https://doi.org/10.1007/978-3-030-88853-4_1, https://doi.org/10.1007/978-3-030-90138-7_2. 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, manuel@pruvisto.org 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 = manuel@pruvisto.org [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 [MDP-Rewards] title = Markov Decision Processes with Rewards author = Maximilian Schäffeler , Mohammad Abdulaziz topic = Mathematics/Probability theory date = 2021-12-16 notify = schaeffm@in.tum.de, mansour@in.tum.de abstract = We present a formalization of Markov Decision Processes with rewards. In particular we first build on Hölzl's formalization of MDPs (AFP entry: Markov_Models) and extend them with rewards. We proceed with an analysis of the expected total discounted reward criterion for infinite horizon MDPs. The central result is the construction of the iteration rule for the Bellman operator. We prove the optimality equations for this operator and show the existence of an optimal stationary deterministic solution. The analysis can be used to obtain dynamic programming algorithms such as value iteration and policy iteration to solve MDPs with formal guarantees. Our formalization is based on chapters 5 and 6 in Puterman's book "Markov Decision Processes: Discrete Stochastic Dynamic Programming". [MDP-Algorithms] title = Verified Algorithms for Solving Markov Decision Processes author = Maximilian Schäffeler , Mohammad Abdulaziz topic = Mathematics/Probability theory, Computer science/Algorithms date = 2021-12-16 notify = schaeffm@in.tum.de, mansour@in.tum.de abstract = We present a formalization of algorithms for solving Markov Decision Processes (MDPs) with formal guarantees on the optimality of their solutions. In particular we build on our analysis of the Bellman operator for discounted infinite horizon MDPs. From the iterator rule on the Bellman operator we directly derive executable value iteration and policy iteration algorithms to iteratively solve finite MDPs. We also prove correct optimized versions of value iteration that use matrix splittings to improve the convergence rate. In particular, we formally verify Gauss-Seidel value iteration and modified policy iteration. The algorithms are evaluated on two standard examples from the literature, namely, inventory management and gridworld. Our formalization covers most of chapter 6 in Puterman's book "Markov Decision Processes: Discrete Stochastic Dynamic Programming". [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 [Actuarial_Mathematics] title = Actuarial Mathematics author = Yosuke Ito topic = Mathematics/Games and economics date = 2022-01-23 notify = glacier345@gmail.com abstract = Actuarial Mathematics is a theory in applied mathematics, which is mainly used for determining the prices of insurance products and evaluating the liability of a company associating with insurance contracts. It is related to calculus, probability theory and financial theory, etc. In this entry, I formalize the very basic part of Actuarial Mathematics in Isabelle/HOL. The first formalization is about the theory of interest which deals with interest rates, present value factors, an annuity certain, etc. I have already formalized the basic part of Actuarial Mathematics in Coq (https://github.com/Yosuke-Ito-345/Actuary). This entry is currently the partial translation and a little generalization of the Coq formalization. The further translation in Isabelle/HOL is now proceeding. [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 = manuel@pruvisto.org [Error_Function] title = The Error Function author = Manuel Eberl topic = Mathematics/Analysis date = 2018-02-06 notify = manuel@pruvisto.org 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 = manuel@pruvisto.org [Dirichlet_Series] title = Dirichlet Series author = Manuel Eberl topic = Mathematics/Number theory date = 2017-10-12 notify = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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, manuel@pruvisto.org 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 = manuel@pruvisto.org 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 [Schutz_Spacetime] title = Schutz' Independent Axioms for Minkowski Spacetime author = Richard Schmoetten , Jake Palmer , Jacques Fleuriot topic = Mathematics/Physics, Mathematics/Geometry date = 2021-07-27 notify = s1311325@sms.ed.ac.uk abstract = This is a formalisation of Schutz' system of axioms for Minkowski spacetime published under the name "Independent axioms for Minkowski space-time" in 1997, as well as most of the results in the third chapter ("Temporal Order on a Path") of the above monograph. Many results are proven here that cannot be found in Schutz, either preceding the theorem they are needed for, or within their own thematic section. [Real_Power] title = Real Exponents as the Limits of Sequences of Rational Exponents author = Jacques D. Fleuriot topic = Mathematics/Analysis date = 2021-11-08 notify = jdf@ed.ac.uk abstract = In this formalisation, we construct real exponents as the limits of sequences of rational exponents. In particular, if $a \ge 1$ and $x \in \mathbb{R}$, we choose an increasing rational sequence $r_n$ such that $\lim_{n\to\infty} {r_n} = x$. Then the sequence $a^{r_n}$ is increasing and if $r$ is any rational number such that $r > x$, $a^{r_n}$ is bounded above by $a^r$. By the convergence criterion for monotone sequences, $a^{r_n}$ converges. We define $a^ x = \lim_{n\to\infty} a^{r_n}$ and show that it has the expected properties (for $a \ge 0$). This particular construction of real exponents is needed instead of the usual one using the natural logarithm and exponential functions (which already exists in Isabelle) to support our mechanical derivation of Euler's exponential series as an ``infinite polynomial". Aside from helping us avoid circular reasoning, this is, as far as we are aware, the first time real exponents are mechanised in this way within a proof assistant. [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 = manuel@pruvisto.org [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 = manuel@pruvisto.org [Median_Of_Medians_Selection] title = The Median-of-Medians Selection Algorithm author = Manuel Eberl topic = Computer science/Algorithms date = 2017-12-21 notify = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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. extra-history = Change history: [2021-02-08]: added theory Approx_SC_Hoare (Set Cover) by Robin Eßmann
[2021-06-29]: added theory Center_Selection by Ujkan Sulejmani [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 various shapes (e.g., rectangle, circle and 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). extra-history = Change history: [2021-10-26]: resolved the roots-on-the-border problem in the rectangular case (revision 82a159e398cf). [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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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. Paper: http://ceur-ws.org/Vol-3002/paper7.pdf. [FOL_Seq_Calc2] title = A Sequent Calculus Prover for First-Order Logic with Functions author = Asta Halkjær From , Frederik Krogsdal Jacobsen topic = Logic/General logic/Classical first-order logic, Logic/Proof theory, Logic/General logic/Mechanization of proofs date = 2022-01-31 notify = ahfrom@dtu.dk, fkjac@dtu.dk abstract = We formalize an automated theorem prover for first-order logic with functions. The proof search procedure is based on sequent calculus and we verify its soundness and completeness using the Abstract Soundness and Abstract Completeness theories. Our analytic completeness proof covers both open and closed formulas. Since our deterministic prover considers only the subset of terms relevant to proving a given sequent, we do so as well when building a countermodel from a failed proof. We formally connect our prover with the proof system and semantics of the existing SeCaV system. In particular, the prover's output can be post-processed in Haskell to generate human-readable SeCaV proofs which are also machine-verifiable proof certificates. [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 = manuel@pruvisto.org 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)
[2021-07-22]: Added new material: "concrete bicategories" and "bicategory of categories". (revision 49d3aa43c180)
[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. extra-history = Change history: [2021-10-19]: corrected a mistake in the calculation of median aggregations (reported by Nicolas Kaletsch, revision 02b14c9bf3da)
[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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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 = manuel@pruvisto.org 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. [Transitive_Models] title = Transitive Models of Fragments of ZFC author = Emmanuel Gunther , Miguel Pagano , Pedro Sánchez Terraf , and Matías Steinberg topic = Logic/Set theory date = 2022-03-03 notify = sterraf@famaf.unc.edu.ar, miguel.pagano@unc.edu.ar abstract = We extend the ZF-Constructibility library by relativizing theories of the Isabelle/ZF and Delta System Lemma sessions to a transitive class. We also relativize Paulson's work on Aleph and our former treatment of the Axiom of Dependent Choices. This work is a prerrequisite to our formalization of the independence of the Continuum Hypothesis. [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 = m.foster@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 = m.foster@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 = manuel@pruvisto.org 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. Paper: https://doi.org/10.1007/978-3-030-90138-7_2. [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. [Logging_Independent_Anonymity] title = Logging-independent Message Anonymity in the Relational Method author = Pasquale Noce topic = Computer science/Security date = 2021-08-26 notify = pasquale.noce.lavoro@gmail.com abstract = In the context of formal cryptographic protocol verification, logging-independent message anonymity is the property for a given message to remain anonymous despite the attacker's capability of mapping messages of that sort to agents based on some intrinsic feature of such messages, rather than by logging the messages exchanged by legitimate agents as with logging-dependent message anonymity. This paper illustrates how logging-independent message anonymity can be formalized according to the relational method for formal protocol verification by considering a real-world protocol, namely the Restricted Identification one by the BSI. This sample model is used to verify that the pseudonymous identifiers output by user identification tokens remain anonymous under the expected conditions. [Dominance_CHK] title = A data flow analysis algorithm for computing dominators author = Nan Jiang<> topic = Computer science/Programming languages/Static analysis date = 2021-09-05 notify = nanjiang@whu.edu.cn abstract = This entry formalises the fast iterative algorithm for computing dominators due to Cooper, Harvey and Kennedy. It gives a specification of computing dominators on a control flow graph where each node refers to its reverse post order number. A semilattice of reversed-ordered list which represents dominators is built and a Kildall-style algorithm on the semilattice is defined for computing dominators. Finally the soundness and completeness of the algorithm are proved w.r.t. the specification. [Conditional_Simplification] title = Conditional Simplification author = Mihails Milehins topic = Tools date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = The article provides a collection of experimental general-purpose proof methods for the object logic Isabelle/HOL of the formal proof assistant Isabelle. The methods in the collection offer functionality that is similar to certain aspects of the functionality provided by the standard proof methods of Isabelle that combine classical reasoning and rewriting, such as the method auto, but use a different approach for rewriting. More specifically, these methods allow for the side conditions of the rewrite rules to be solved via intro-resolution. [Intro_Dest_Elim] title = IDE: Introduction, Destruction, Elimination author = Mihails Milehins topic = Tools date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = The article provides the command mk_ide for the object logic Isabelle/HOL of the formal proof assistant Isabelle. The command mk_ide enables the automated synthesis of the introduction, destruction and elimination rules from arbitrary definitions of constant predicates stated in Isabelle/HOL. [CZH_Foundations] title = Category Theory for ZFC in HOL I: Foundations: Design Patterns, Set Theory, Digraphs, Semicategories author = Mihails Milehins topic = Mathematics/Category theory, Logic/Set theory date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = This article provides a foundational framework for the formalization of category theory in the object logic ZFC in HOL of the formal proof assistant Isabelle. More specifically, this article provides a formalization of canonical set-theoretic constructions internalized in the type V associated with the ZFC in HOL, establishes a design pattern for the formalization of mathematical structures using sequences and locales, and showcases the developed infrastructure by providing formalizations of the elementary theories of digraphs and semicategories. The methodology chosen for the formalization of the theories of digraphs and semicategories (and categories in future articles) rests on the ideas that were originally expressed in the article Set-Theoretical Foundations of Category Theory written by Solomon Feferman and Georg Kreisel. Thus, in the context of this work, each of the aforementioned mathematical structures is represented as a term of the type V embedded into a stage of the von Neumann hierarchy. [CZH_Elementary_Categories] title = Category Theory for ZFC in HOL II: Elementary Theory of 1-Categories author = Mihails Milehins topic = Mathematics/Category theory date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = This article provides a formalization of the foundations of the theory of 1-categories in the object logic ZFC in HOL of the formal proof assistant Isabelle. The article builds upon the foundations that were established in the AFP entry Category Theory for ZFC in HOL I: Foundations: Design Patterns, Set Theory, Digraphs, Semicategories. [CZH_Universal_Constructions] title = Category Theory for ZFC in HOL III: Universal Constructions author = Mihails Milehins topic = Mathematics/Category theory date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = The article provides a formalization of elements of the theory of universal constructions for 1-categories (such as limits, adjoints and Kan extensions) in the object logic ZFC in HOL of the formal proof assistant Isabelle. The article builds upon the foundations established in the AFP entry Category Theory for ZFC in HOL II: Elementary Theory of 1-Categories. [Conditional_Transfer_Rule] title = Conditional Transfer Rule author = Mihails Milehins topic = Tools date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = This article provides a collection of experimental utilities for unoverloading of definitions and synthesis of conditional transfer rules for the object logic Isabelle/HOL of the formal proof assistant Isabelle written in Isabelle/ML. [Types_To_Sets_Extension] title = Extension of Types-To-Sets author = Mihails Milehins topic = Tools date = 2021-09-06 notify = mihailsmilehins@gmail.com abstract = In their article titled From Types to Sets by Local Type Definitions in Higher-Order Logic and published in the proceedings of the conference Interactive Theorem Proving in 2016, Ondřej Kunčar and Andrei Popescu propose an extension of the logic Isabelle/HOL and an associated algorithm for the relativization of the type-based theorems to more flexible set-based theorems, collectively referred to as Types-To-Sets. One of the aims of their work was to open an opportunity for the development of a software tool for applied relativization in the implementation of the logic Isabelle/HOL of the proof assistant Isabelle. In this article, we provide a prototype of a software framework for the interactive automated relativization of theorems in Isabelle/HOL, developed as an extension of the proof language Isabelle/Isar. The software framework incorporates the implementation of the proposed extension of the logic, and builds upon some of the ideas for further work expressed in the original article on Types-To-Sets by Ondřej Kunčar and Andrei Popescu and the subsequent article Smooth Manifolds and Types to Sets for Linear Algebra in Isabelle/HOL that was written by Fabian Immler and Bohua Zhan and published in the proceedings of the International Conference on Certified Programs and Proofs in 2019. [Complex_Bounded_Operators] title = Complex Bounded Operators author = Jose Manuel Rodriguez Caballero , Dominique Unruh topic = Mathematics/Analysis date = 2021-09-18 notify = unruh@ut.ee abstract = We present a formalization of bounded operators on complex vector spaces. Our formalization contains material on complex vector spaces (normed spaces, Banach spaces, Hilbert spaces) that complements and goes beyond the developments of real vectors spaces in the Isabelle/HOL standard library. We define the type of bounded operators between complex vector spaces (cblinfun) and develop the theory of unitaries, projectors, extension of bounded linear functions (BLT theorem), adjoints, Loewner order, closed subspaces and more. For the finite-dimensional case, we provide code generation support by identifying finite-dimensional operators with matrices as formalized in the Jordan_Normal_Form AFP entry. [Weighted_Path_Order] title = A Formalization of Weighted Path Orders and Recursive Path Orders author = Christian Sternagel , René Thiemann , Akihisa Yamada topic = Logic/Rewriting date = 2021-09-16 notify = rene.thiemann@uibk.ac.at abstract = We define the weighted path order (WPO) and formalize several properties such as strong normalization, the subterm property, and closure properties under substitutions and contexts. Our definition of WPO extends the original definition by also permitting multiset comparisons of arguments instead of just lexicographic extensions. Therefore, our WPO not only subsumes lexicographic path orders (LPO), but also recursive path orders (RPO). We formally prove these subsumptions and therefore all of the mentioned properties of WPO are automatically transferable to LPO and RPO as well. Such a transformation is not required for Knuth–Bendix orders (KBO), since they have already been formalized. Nevertheless, we still provide a proof that WPO subsumes KBO and thereby underline the generality of WPO. [FOL_Axiomatic] title = Soundness and Completeness of an Axiomatic System for First-Order Logic author = Asta Halkjær From topic = Logic/General logic/Classical first-order logic, Logic/Proof theory date = 2021-09-24 notify = ahfrom@dtu.dk abstract = This work is a formalization of the soundness and completeness of an axiomatic system for first-order logic. The proof system is based on System Q1 by Smullyan and the completeness proof follows his textbook "First-Order Logic" (Springer-Verlag 1968). The completeness proof is in the Henkin style where a consistent set is extended to a maximal consistent set using Lindenbaum's construction and Henkin witnesses are added during the construction to ensure saturation as well. The resulting set is a Hintikka set which, by the model existence theorem, is satisfiable in the Herbrand universe. [Virtual_Substitution] title = Verified Quadratic Virtual Substitution for Real Arithmetic author = Matias Scharager , Katherine Cordwell , Stefan Mitsch , André Platzer topic = Computer science/Algorithms/Mathematical date = 2021-10-02 notify = mscharag@cs.cmu.edu, kcordwel@cs.cmu.edu, smitsch@cs.cmu.edu, aplatzer@cs.cmu.edu abstract = This paper presents a formally verified quantifier elimination (QE) algorithm for first-order real arithmetic by linear and quadratic virtual substitution (VS) in Isabelle/HOL. The Tarski-Seidenberg theorem established that the first-order logic of real arithmetic is decidable by QE. However, in practice, QE algorithms are highly complicated and often combine multiple methods for performance. VS is a practically successful method for QE that targets formulas with low-degree polynomials. To our knowledge, this is the first work to formalize VS for quadratic real arithmetic including inequalities. The proofs necessitate various contributions to the existing multivariate polynomial libraries in Isabelle/HOL. Our framework is modularized and easily expandable (to facilitate integrating future optimizations), and could serve as a basis for developing practical general-purpose QE algorithms. Further, as our formalization is designed with practicality in mind, we export our development to SML and test the resulting code on 378 benchmarks from the literature, comparing to Redlog, Z3, Wolfram Engine, and SMT-RAT. This identified inconsistencies in some tools, underscoring the significance of a verified approach for the intricacies of real arithmetic. [Correctness_Algebras] title = Algebras for Iteration, Infinite Executions and Correctness of Sequential Computations author = Walter Guttmann topic = Computer science/Programming languages/Logics date = 2021-10-12 notify = walter.guttmann@canterbury.ac.nz abstract = We study models of state-based non-deterministic sequential computations and describe them using algebras. We propose algebras that describe iteration for strict and non-strict computations. They unify computation models which differ in the fixpoints used to represent iteration. We propose algebras that describe the infinite executions of a computation. They lead to a unified approximation order and results that connect fixpoints in the approximation and refinement orders. This unifies the semantics of recursion for a range of computation models. We propose algebras that describe preconditions and the effect of while-programs under postconditions. They unify correctness statements in two dimensions: one statement applies in various computation models to various correctness claims. [Belief_Revision] title = Belief Revision Theory author = Valentin Fouillard , Safouan Taha , Frédéric Boulanger , Nicolas Sabouret <> topic = Logic/General logic/Logics of knowledge and belief date = 2021-10-19 notify = safouan.taha@lri.fr, valentin.fouillard@limsi.fr abstract = The 1985 paper by Carlos Alchourrón, Peter Gärdenfors, and David Makinson (AGM), “On the Logic of Theory Change: Partial Meet Contraction and Revision Functions” launches a large and rapidly growing literature that employs formal models and logics to handle changing beliefs of a rational agent and to take into account new piece of information observed by this agent. In 2011, a review book titled "AGM 25 Years: Twenty-Five Years of Research in Belief Change" was edited to summarize the first twenty five years of works based on AGM. This HOL-based AFP entry is a faithful formalization of the AGM operators (e.g. contraction, revision, remainder ...) axiomatized in the original paper. It also contains the proofs of all the theorems stated in the paper that show how these operators combine. Both proofs of Harper and Levi identities are established. [X86_Semantics] title = X86 instruction semantics and basic block symbolic execution author = Freek Verbeek , Abhijith Bharadwaj <>, Joshua Bockenek <>, Ian Roessle <>, Timmy Weerwag <>, Binoy Ravindran <> topic = Computer science/Hardware, Computer science/Semantics date = 2021-10-13 notify = freek@vt.edu abstract = This AFP entry provides semantics for roughly 120 different X86-64 assembly instructions. These instructions include various moves, arithmetic/logical operations, jumps, call/return, SIMD extensions and others. External functions are supported by allowing a user to provide custom semantics for these calls. Floating-point operations are mapped to uninterpreted functions. The model provides semantics for register aliasing and a byte-level little-endian memory model. The semantics are purposefully incomplete, but overapproximative. For example, the precise effect of flags may be undefined for certain instructions, or instructions may simply have no semantics at all. In those cases, the semantics are mapped to universally quantified uninterpreted terms from a locale. Second, this entry provides a method to symbolic execution of basic blocks. The method, called ''se_step'' (for: symbolic execution step) fetches an instruction and updates the current symbolic state while keeping track of assumptions made over the memory model. A key component is a set of theorems that prove how reads from memory resolve after writes have occurred. Thirdly, this entry provides a parser that allows the user to copy-paste the output of the standard disassembly tool objdump into Isabelle/HOL. A couple small and explanatory examples are included, including functions from the word count program. Several examples can be supplied upon request (they are not included due to the running time of verification): functions from the floating-point modulo function from FDLIBM, the GLIBC strlen function and the CoreUtils SHA256 implementation. [Registers] title = Quantum and Classical Registers author = Dominique Unruh topic = Computer science/Algorithms/Quantum computing, Computer science/Programming languages/Logics, Computer science/Semantics date = 2021-10-28 notify = unruh@ut.ee abstract = A formalization of the theory of quantum and classical registers as developed by (Unruh, Quantum and Classical Registers). In a nutshell, a register refers to a part of a larger memory or system that can be accessed independently. Registers can be constructed from other registers and several (compatible) registers can be composed. This formalization develops both the generic theory of registers as well as specific instantiations for classical and quantum registers. [Szemeredi_Regularity] title = Szemerédi's Regularity Lemma author = Chelsea Edmonds , Angeliki Koutsoukou-Argyraki , Lawrence C. Paulson topic = Mathematics/Graph theory, Mathematics/Combinatorics date = 2021-11-05 notify = lp15@cam.ac.uk abstract = Szemerédi's regularity lemma is a key result in the study of large graphs. It asserts the existence of an upper bound on the number of parts the vertices of a graph need to be partitioned into such that the edges between the parts are random in a certain sense. This bound depends only on the desired precision and not on the graph itself, in the spirit of Ramsey's theorem. The formalisation follows online course notes by Tim Gowers and Yufei Zhao. [Factor_Algebraic_Polynomial] title = Factorization of Polynomials with Algebraic Coefficients author = Manuel Eberl , René Thiemann topic = Mathematics/Algebra date = 2021-11-08 notify = rene.thiemann@uibk.ac.at abstract = The AFP already contains a verified implementation of algebraic numbers. However, it is has a severe limitation in its factorization algorithm of real and complex polynomials: the factorization is only guaranteed to succeed if the coefficients of the polynomial are rational numbers. In this work, we verify an algorithm to factor all real and complex polynomials whose coefficients are algebraic. The existence of such an algorithm proves in a constructive way that the set of complex algebraic numbers is algebraically closed. Internally, the algorithm is based on resultants of multivariate polynomials and an approximation algorithm using interval arithmetic. [PAL] title = Automating Public Announcement Logic and the Wise Men Puzzle in Isabelle/HOL author = Christoph Benzmüller , Sebastian Reiche topic = Logic/General logic/Logics of knowledge and belief date = 2021-11-08 notify = c.benzmueller@gmail.com abstract = We present a shallow embedding of public announcement logic (PAL) with relativized general knowledge in HOL. We then use PAL to obtain an elegant encoding of the wise men puzzle, which we solve automatically using sledgehammer. [SimplifiedOntologicalArgument] title = Exploring Simplified Variants of Gödel’s Ontological Argument in Isabelle/HOL author = Christoph Benzmüller topic = Logic/Philosophical aspects, Logic/General logic/Modal logic date = 2021-11-08 notify = c.benzmueller@gmail.com abstract =

Simplified variants of Gödel's ontological argument are explored. Among those is a particularly interesting simplified argument which is (i) valid already in basic modal logics K or KT, (ii) which does not suffer from modal collapse, and (iii) which avoids the rather complex predicates of essence (Ess.) and necessary existence (NE) as used by Gödel.

Whether the presented variants increase or decrease the attractiveness and persuasiveness of the ontological argument is a question I would like to pass on to philosophy and theology.

[Van_Emde_Boas_Trees] title = van Emde Boas Trees author = Thomas Ammer<>, Peter Lammich<> topic = Computer science/Data structures date = 2021-11-23 notify = lammich@in.tum.de abstract = The van Emde Boas tree or van Emde Boas priority queue is a data structure supporting membership test, insertion, predecessor and successor search, minimum and maximum determination and deletion in O(log log U) time, where U = 0,...,2n-1 is the overall range to be considered.

The presented formalization follows Chapter 20 of the popular Introduction to Algorithms (3rd ed.) by Cormen, Leiserson, Rivest and Stein (CLRS), extending the list of formally verified CLRS algorithms. Our current formalization is based on the first author's bachelor's thesis.

First, we prove correct a functional implementation, w.r.t. an abstract data type for sets. Apart from functional correctness, we show a resource bound, and runtime bounds w.r.t. manually defined timing functions for the operations.

Next, we refine the operations to Imperative HOL with time, and show correctness and complexity. This yields a practically more efficient implementation, and eliminates the manually defined timing functions from the trusted base of the proof. [Hahn_Jordan_Decomposition] title = The Hahn and Jordan Decomposition Theorems author = Marie Cousin , Mnacho Echenim , Hervé Guiol topic = Mathematics/Measure theory date = 2021-11-19 notify = mnacho.echenim@univ-grenoble-alpes.fr abstract = In this work we formalize the Hahn decomposition theorem for signed measures, namely that any measure space for a signed measure can be decomposed into a positive and a negative set, where every measurable subset of the positive one has a positive measure, and every measurable subset of the negative one has a negative measure. We also formalize the Jordan decomposition theorem as a corollary, which states that the signed measure under consideration admits a unique decomposition into a difference of two positive measures, at least one of which is finite. [Simplicial_complexes_and_boolean_functions] title = Simplicial Complexes and Boolean functions author = Jesús Aransay , Alejandro del Campo , Julius Michaelis topic = Mathematics/Topology date = 2021-11-29 notify = jesus-maria.aransay@unirioja.es abstract = In this work we formalise the isomorphism between simplicial complexes of dimension $n$ and monotone Boolean functions in $n$ variables, mainly following the definitions and results as introduced by N. A. Scoville. We also take advantage of the AFP representation of ROBDD (Reduced Ordered Binary Decision Diagrams) to compute the ROBDD representation of a given simplicial complex (by means of the isomorphism to Boolean functions). Some examples of simplicial complexes and associated Boolean functions are also presented. [Foundation_of_geometry] title = Foundation of geometry in planes, and some complements: Excluding the parallel axioms author = Fumiya Iwama <> topic = Mathematics/Geometry date = 2021-11-22 notify = d1623001@s.konan-u.ac.jp abstract = "Foundations of Geometry" is a mathematical book written by Hilbert in 1899. This entry is a complete formalization of "Incidence" (excluding cubic axioms), "Order" and "Congruence" (excluding point sequences) of the axioms constructed in this book. In addition, the theorem of the problem about the part that is treated implicitly and is not clearly stated in it is being carried out in parallel. [Regular_Tree_Relations] title = Regular Tree Relations author = Alexander Lochmann , Bertram Felgenhauer<>, Christian Sternagel , René Thiemann , Thomas Sternagel<> topic = Computer science/Automata and formal languages date = 2021-12-15 notify = alexander.lochmann@uibk.ac.at abstract = Tree automata have good closure properties and therefore a commonly used to prove/disprove properties. This formalization contains among other things the proofs of many closure properties of tree automata (anchored) ground tree transducers and regular relations. Additionally it includes the well known pumping lemma and a lifting of the Myhill Nerode theorem for regular languages to tree languages. We want to mention the existence of a tree automata APF-entry developed by Peter Lammich. His work is based on epsilon free top-down tree automata, while this entry builds on bottom-up tree auotamta with epsilon transitions. Moreover our formalization relies on the Collections Framework, also by Peter Lammich, to obtain efficient code. All proven constructions of the closure properties are exportable using the Isabelle/HOL code generation facilities. [Roth_Arithmetic_Progressions] title = Roth's Theorem on Arithmetic Progressions author = Chelsea Edmonds , Angeliki Koutsoukou-Argyraki , Lawrence C. Paulson topic = Mathematics/Graph theory, Mathematics/Combinatorics date = 2021-12-28 notify = lp15@cam.ac.uk abstract = We formalise a proof of Roth's Theorem on Arithmetic Progressions, a major result in additive combinatorics on the existence of 3-term arithmetic progressions in subsets of natural numbers. To this end, we follow a proof using graph regularity. We employ our recent formalisation of Szemerédi's Regularity Lemma, a major result in extremal graph theory, which we use here to prove the Triangle Counting Lemma and the Triangle Removal Lemma. Our sources are Yufei Zhao's MIT lecture notes "Graph Theory and Additive Combinatorics" (revised version here) and W.T. Gowers's Cambridge lecture notes "Topics in Combinatorics". We also refer to the University of Georgia notes by Stephanie Bell and Will Grodzicki, "Using Szemerédi's Regularity Lemma to Prove Roth's Theorem". [Gale_Shapley] title = Gale-Shapley Algorithm author = Tobias Nipkow topic = Computer science/Algorithms, Mathematics/Games and economics date = 2021-12-29 notify = nipkow@in.tum.de abstract = This is a stepwise refinement and proof of the Gale-Shapley stable matching (or marriage) algorithm down to executable code. Both a purely functional implementation based on lists and a functional implementation based on efficient arrays (provided by the Collections Framework in the AFP) are developed. The latter implementation runs in time O(n2) where n is the cardinality of the two sets to be matched. [Knights_Tour] title = Knight's Tour Revisited Revisited author = Lukas Koller topic = Mathematics/Graph theory date = 2022-01-04 notify = lukas.koller@tum.de abstract = This is a formalization of the article Knight's Tour Revisited by Cull and De Curtins where they prove the existence of a Knight's path for arbitrary n × m-boards with min(n,m) ≥ 5. If n · m is even, then there exists a Knight's circuit. A Knight's Path is a sequence of moves of a Knight on a chessboard s.t. the Knight visits every square of a chessboard exactly once. Finding a Knight's path is a an instance of the Hamiltonian path problem. A Knight's circuit is a Knight's path, where additionally the Knight can move from the last square to the first square of the path, forming a loop. During the formalization two mistakes in the original proof were discovered. These mistakes are corrected in this formalization. [Hyperdual] title = Hyperdual Numbers and Forward Differentiation author = Filip Smola <>, Jacques Fleuriot topic = Mathematics/Algebra, Mathematics/Analysis date = 2021-12-31 notify = f.smola@sms.ed.ac.uk, Jacques.Fleuriot@ed.ac.uk abstract =

Hyperdual numbers are ones with a real component and a number of infinitesimal components, usually written as $a_0 + a_1 \cdot \epsilon_1 + a_2 \cdot \epsilon_2 + a_3 \cdot \epsilon_1\epsilon_2$. They have been proposed by Fike and Alonso in an approach to automatic differentiation.

In this entry we formalise hyperdual numbers and their application to forward differentiation. We show them to be an instance of multiple algebraic structures and then, along with facts about twice-differentiability, we define what we call the hyperdual extensions of functions on real-normed fields. This extension formally represents the proposed way that the first and second derivatives of a function can be automatically calculated. We demonstrate it on the standard logistic function $f(x) = \frac{1}{1 + e^{-x}}$ and also reproduce the example analytic function $f(x) = \frac{e^x}{\sqrt{sin(x)^3 + cos(x)^3}}$ used for demonstration by Fike and Alonso.

[Median_Method] title = Median Method author = Emin Karayel topic = Mathematics/Probability theory date = 2022-01-25 notify = me@eminkarayel.de abstract =

The median method is an amplification result for randomized approximation algorithms described in [1]. Given an algorithm whose result is in a desired interval with a probability larger than 1/2, it is possible to improve the success probability, by running the algorithm multiple times independently and using the median. In contrast to using the mean, the amplification of the success probability grows exponentially with the number of independent runs.

This entry contains a formalization of the underlying theorem: Given a sequence of n independent random variables, which are in a desired interval with a probability 1/2 + a. Then their median will be in the desired interval with a probability of 1 − exp(−2a2 n). In particular, the success probability approaches 1 exponentially with the number of variables.

In addition to that, this entry also contains a proof that order-statistics of Borel-measurable random variables are themselves measurable and that generalized intervals in linearly ordered Borel-spaces are measurable.

[Irrationals_From_THEBOOK] title = Irrational numbers from THE BOOK author = Lawrence C Paulson topic = Mathematics/Number theory date = 2022-01-08 notify = lp15@cam.ac.uk abstract = An elementary proof is formalised: that exp r is irrational for every nonzero rational number r. The mathematical development comes from the well-known volume Proofs from THE BOOK, by Aigner and Ziegler, who credit the idea to Hermite. The development illustrates a number of basic Isabelle techniques: the manipulation of summations, the calculation of quite complicated derivatives and the estimation of integrals. We also see how to import another AFP entry (Stirling's formula). As for the theorem itself, note that a much stronger and more general result (the Hermite--Lindemann--Weierstraß transcendence theorem) is already available in the AFP. [Interpolation_Polynomials_HOL_Algebra] title = Interpolation Polynomials (in HOL-Algebra) author = Emin Karayel topic = Mathematics/Algebra date = 2022-01-29 notify = me@eminkarayel.de abstract =

A well known result from algebra is that, on any field, there is exactly one polynomial of degree less than n interpolating n points [1, §7].

This entry contains a formalization of the above result, as well as the following generalization in the case of finite fields F: There are |F|m-n polynomials of degree less than m ≥ n interpolating the same n points, where |F| denotes the size of the domain of the field. To establish the result the entry also includes a formalization of Lagrange interpolation, which might be of independent interest.

The formalized results are defined on the algebraic structures from HOL-Algebra, which are distinct from the type-class based structures defined in HOL. Note that there is an existing formalization for polynomial interpolation and, in particular, Lagrange interpolation by Thiemann and Yamada [2] on the type-class based structures in HOL.

[Quasi_Borel_Spaces] title = Quasi-Borel Spaces author = Michikazu Hirata <>, Yasuhiko Minamide , Tetsuya Sato topic = Computer science/Semantics date = 2022-02-03 notify = hirata.m.ac@m.titech.ac.jp, minamide@is.titech.ac.jp, tsato@c.titech.ac.jp abstract = The notion of quasi-Borel spaces was introduced by Heunen et al. The theory provides a suitable denotational model for higher-order probabilistic programming languages with continuous distributions. This entry is a formalization of the theory of quasi-Borel spaces, including construction of quasi-Borel spaces (product, coproduct, function spaces), the adjunction between the category of measurable spaces and the category of quasi-Borel spaces, and the probability monad on quasi-Borel spaces. This entry also contains the formalization of the Bayesian regression presented in the work of Heunen et al. This work is a part of the work by same authors, Program Logic for Higher-Order Probabilistic Programs in Isabelle/HOL, which will be published in the proceedings of the 16th International Symposium on Functional and Logic Programming (FLOPS 2022). [Youngs_Inequality] title = Young's Inequality for Increasing Functions author = Lawrence C Paulson topic = Mathematics/Analysis date = 2022-01-31 notify = lp15@cam.ac.uk abstract = Young's inequality states that $$ ab \leq \int_0^a f(x)dx + \int_0^b f^{-1}(y) dy $$ where $a\geq 0$, $b\geq 0$ and $f$ is strictly increasing and continuous. Its proof is formalised following the development by Cunningham and Grossman. Their idea is to make the intuitive, geometric folklore proof rigorous by reasoning about step functions. The lack of the Riemann integral makes the development longer than one would like, but their argument is reproduced faithfully. [LP_Duality] title = Duality of Linear Programming author = René Thiemann topic = Mathematics/Algebra date = 2022-02-03 notify = rene.thiemann@uibk.ac.at abstract = We formalize the weak and strong duality theorems of linear programming. For the strong duality theorem we provide three sufficient preconditions: both the primal problem and the dual problem are satisfiable, the primal problem is satisfiable and bounded, or the dual problem is satisfiable and bounded. The proofs are based on an existing formalization of Farkas' Lemma. [Equivalence_Relation_Enumeration] title = Enumeration of Equivalence Relations author = Emin Karayel topic = Mathematics/Combinatorics, Computer science/Algorithms/Mathematical date = 2022-02-04 notify = me@eminkarayel.de abstract =

This entry contains a formalization of an algorithm enumerating all equivalence relations on an initial segment of the natural numbers. The approach follows the method described by Stanton and White [5,§ 1.5] using restricted growth functions.

The algorithm internally enumerates restricted growth functions (as lists), whose equivalence kernels then form the equivalence relations. This has the advantage that the representation is compact and lookup of the relation reduces to a list lookup operation.

The algorithm can also be used within a proof and an example application is included, where a sequence of variables is split by the possible partitions they can form.

[FO_Theory_Rewriting] title = First-Order Theory of Rewriting author = Alexander Lochmann , Bertram Felgenhauer<> topic = Computer science/Automata and formal languages, Logic/Rewriting, Logic/Proof theory date = 2022-02-02 notify = alexander.lochmann@uibk.ac.at abstract = The first-order theory of rewriting (FORT) is a decidable theory for linear variable-separated rewrite systems. The decision procedure is based on tree automata technique and an inference system presented in "Certifying Proofs in the First-Order Theory of Rewriting". This AFP entry provides a formalization of the underlying decision procedure. Moreover it allows to generate a function that can verify each inference step via the code generation facility of Isabelle/HOL. Additionally it contains the specification of a certificate language (that allows to state proofs in FORT) and a formalized function that allows to verify the validity of the proof. This gives software tool authors, that implement the decision procedure, the possibility to verify their output. [VYDRA_MDL] title = Multi-Head Monitoring of Metric Dynamic Logic author = Martin Raszyk topic = Computer science/Algorithms date = 2022-02-13 notify = m.raszyk@gmail.com abstract = Runtime monitoring (or runtime verification) is an approach to checking compliance of a system's execution with a specification (e.g., a temporal query). The system's execution is logged into a trace---a sequence of time-points, each consisting of a time-stamp and observed events. A monitor is an algorithm that produces verdicts on the satisfaction of a temporal query on a trace. We formalize a monitoring algorithm for metric dynamic logic, an extension of metric temporal logic with regular expressions. The monitor computes whether a given query is satisfied at every position in an input trace of time-stamped events. We formalize the time-stamps as an abstract algebraic structure satisfying certain assumptions. Instances of this structure include natural numbers, real numbers, and lexicographic combinations of them. Our monitor follows the multi-head paradigm: it reads the input simultaneously at multiple positions and moves its reading heads asynchronously. This mode of operation results in unprecedented time and space complexity guarantees for metric dynamic logic: The monitor's amortized time complexity to process a time-point and the monitor's space complexity neither depends on the event-rate, i.e., the number of events within a fixed time-unit, nor on the numeric constants occurring in the quantitative temporal constraints in the given query. The multi-head monitoring algorithm for metric dynamic logic is reported in our paper "Multi-Head Monitoring of Metric Dynamic Logic" published at ATVA 2020. We have also formalized unpublished specialized algorithms for the temporal operators of metric temporal logic. [Eval_FO] title = First-Order Query Evaluation author = Martin Raszyk topic = Logic/General logic/Classical first-order logic date = 2022-02-15 notify = m.raszyk@gmail.com abstract = We formalize first-order query evaluation over an infinite domain with equality. We first define the syntax and semantics of first-order logic with equality. Next we define a locale eval_fo abstracting a representation of a potentially infinite set of tuples satisfying a first-order query over finite relations. Inside the locale, we define a function eval checking if the set of tuples satisfying a first-order query over a database (an interpretation of the query's predicates) is finite (i.e., deciding relative safety) and computing the set of satisfying tuples if it is finite. Altogether the function eval solves capturability (Avron and Hirshfeld, 1991) of first-order logic with equality. We also use the function eval to prove a code equation for the semantics of first-order logic, i.e., the function checking if a first-order query over a database is satisfied by a variable assignment.
We provide an interpretation of the locale eval_fo based on the approach by Ailamazyan et al. A core notion in the interpretation is the active domain of a query and a database that contains all domain elements that occur in the database or interpret the query's constants. We prove the main theorem of Ailamazyan et al. relating the satisfaction of a first-order query over an infinite domain to the satisfaction of this query over a finite domain consisting of the active domain and a few additional domain elements (outside the active domain) whose number only depends on the query. In our interpretation of the locale eval_fo, we use a potentially higher number of the additional domain elements, but their number still only depends on the query and thus has no effect on the data complexity (Vardi, 1982) of query evaluation. Our interpretation yields an executable function eval. The time complexity of eval on a query is linear in the total number of tuples in the intermediate relations for the subqueries. Specifically, we build a database index to evaluate a conjunction. We also optimize the case of a negated subquery in a conjunction. Finally, we export code for the infinite domain of natural numbers. [Wetzels_Problem] title = Wetzel's Problem and the Continuum Hypothesis author = Lawrence C Paulson<> topic = Mathematics/Analysis, Logic/Set theory date = 2022-02-18 notify = lp15@cam.ac.uk abstract = Let $F$ be a set of analytic functions on the complex plane such that, for each $z\in\mathbb{C}$, the set $\{f(z) \mid f\in F\}$ is countable; must then $F$ itself be countable? The answer is yes if the Continuum Hypothesis is false, i.e., if the cardinality of $\mathbb{R}$ exceeds $\aleph_1$. But if CH is true then such an $F$, of cardinality $\aleph_1$, can be constructed by transfinite recursion. The formal proof illustrates reasoning about complex analysis (analytic and homomorphic functions) and set theory (transfinite cardinalities) in a single setting. The mathematical text comes from Proofs from THE BOOK by Aigner and Ziegler. [Universal_Hash_Families] title = Universal Hash Families author = Emin Karayel topic = Mathematics/Probability theory, Computer science/Algorithms date = 2022-02-20 notify = me@eminkarayel.de abstract = A k-universal hash family is a probability space of functions, which have uniform distribution and form k-wise independent random variables. They can often be used in place of classic (or cryptographic) hash functions and allow the rigorous analysis of the performance of randomized algorithms and data structures that rely on hash functions. In 1981 Wegman and Carter introduced a generic construction for such families with arbitrary k using polynomials over a finite field. This entry contains a formalization of them and establishes the property of k-universality. To be useful the formalization also provides an explicit construction of finite fields using the factor ring of integers modulo a prime. Additionally, some generic results about independent families are shown that might be of independent interest. +[ResiduatedTransitionSystem] +title = Residuated Transition Systems +author = Eugene W. Stark +topic = Computer science/Automata and formal languages, Computer science/Concurrency, Computer science/Programming languages/Lambda calculi +date = 2022-02-28 +notify = stark@cs.stonybrook.edu +abstract = +

A residuated transition system (RTS) is + a transition system that is equipped with a certain partial binary + operation, called residuation, on transitions. + Using the residuation operation, one can express nuances, such as a + distinction between nondeterministic and concurrent choice, as well as + partial commutativity relationships between transitions, which are not + captured by ordinary transition systems. A version of residuated + transition systems was introduced in previous work by the author, in + which they were called “concurrent transition systems” in view of the + original motivation for their definition from the study of + concurrency. In the first part of the present article, we give a + formal development that generalizes and subsumes the original + presentation. We give an axiomatic definition of residuated transition + systems that assumes only a single partial binary operation as given + structure. From the axioms, we derive notions of “arrow“ (transition), + “source”, “target”, “identity”, as well as “composition” and “join” of + transitions; thereby recovering structure that in the previous work + was assumed as given. We formalize and generalize the result, that + residuation extends from transitions to transition paths, and we + systematically develop the properties of this extension. A significant + generalization made in the present work is the identification of a + general notion of congruence on RTS’s, along with an associated + quotient construction.

In the second part of this + article, we use the RTS framework to formalize several results in the + theory of reduction in Church’s λ-calculus. Using a de Bruijn + index-based syntax in which terms represent parallel reduction steps, + we define residuation on terms and show that it satisfies the axioms + for an RTS. An application of the results on paths from the first part + of the article allows us to prove the classical Church-Rosser Theorem + with little additional effort. We then use residuation to define the + notion of “development” and we prove the Finite Developments Theorem, + that every development is finite, formalizing and adapting to de + Bruijn indices a proof by de Vrijer. We also use residuation to define + the notion of a “standard reduction path”, and we prove the + Standardization Theorem: that every reduction path is congruent to a + standard one. As a corollary of the Standardization Theorem, we obtain + the Leftmost Reduction Theorem: that leftmost reduction is a + normalizing strategy.

+ diff --git a/thys/ROOTS b/thys/ROOTS --- a/thys/ROOTS +++ b/thys/ROOTS @@ -1,667 +1,668 @@ 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 Actuarial_Mathematics 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 Belief_Revision 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 CZH_Elementary_Categories CZH_Foundations CZH_Universal_Constructions 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 CoSMeDis CoSMed 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_Bounded_Operators Complex_Geometry Complx ComponentDependencies ConcurrentGC ConcurrentIMP Concurrent_Ref_Alg Concurrent_Revisions Conditional_Simplification Conditional_Transfer_Rule Consensus_Refined Constructive_Cryptography Constructive_Cryptography_CM Constructor_Funs Containers CoreC++ Core_DOM Core_SC_DOM Correctness_Algebras 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 Dominance_CHK DynamicArchitectures Dynamic_Tables E_Transcendental Echelon_Form EdmondsKarp_Maxflow Efficient-Mergesort Elliptic_Curves_Group_Law Encodability_Process_Calculi Epistemic_Logic Equivalence_Relation_Enumeration Ergodic_Theory Error_Function Euler_MacLaurin Euler_Partition Eval_FO Example-Submission Extended_Finite_State_Machine_Inference Extended_Finite_State_Machines FFT FLP FOL-Fitting FOL_Axiomatic FOL_Harrison FOL_Seq_Calc1 FOL_Seq_Calc2 Factor_Algebraic_Polynomial 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 Foundation_of_geometry Fourier FO_Theory_Rewriting Free-Boolean-Algebra Free-Groups Fresh_Identifiers FunWithFunctions FunWithTilings Functional-Automata Functional_Ordered_Resolution_Prover Furstenberg_Topology GPU_Kernel_PL Gabow_SCC GaleStewart_Games Gale_Shapley 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 Hahn_Jordan_Decomposition 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 Hyperdual 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 Interpolation_Polynomials_HOL_Algebra Interpreter_Optimizations Interval_Arithmetic_Word32 Intro_Dest_Elim Iptables_Semantics Irrational_Series_Erdos_Straus Irrationality_J_Hancl Irrationals_From_THEBOOK 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 Knights_Tour 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 Logging_Independent_Anonymity Lowe_Ontological_Argument Lower_Semicontinuous Lp LP_Duality Lucas_Theorem MDP-Algorithms MDP-Rewards 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_Method 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 PAL 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 Quasi_Borel_Spaces 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 Real_Power Recursion-Addition Recursion-Theory-I Refine_Imperative_HOL Refine_Monadic RefinementReactive Regex_Equivalence Registers Regression_Test_Selection Regular-Sets Regular_Algebras Regular_Tree_Relations Relation_Algebra Relational-Incorrectness-Logic Relational_Disjoint_Set_Forests Relational_Forests Relational_Method Relational_Minimum_Spanning_Trees Relational_Paths Rep_Fin_Groups +ResiduatedTransitionSystem Residuated_Lattices Resolution_FOL Rewriting_Z Ribbon_Proofs Robbins-Conjecture Robinson_Arithmetic Root_Balanced_Tree Roth_Arithmetic_Progressions Routing Roy_Floyd_Warshall SATSolverVerification SC_DOM_Components SDS_Impossibility SIFPL SIFUM_Type_Systems SPARCv8 Safe_Distance Safe_OCL Saturation_Framework Saturation_Framework_Extensions Schutz_Spacetime 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 Simplicial_complexes_and_boolean_functions SimplifiedOntologicalArgument 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 Szemeredi_Regularity 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 Transitive_Models Treaps Tree-Automata Tree_Decomposition Triangle Trie Twelvefold_Way Tycon Types_Tableaus_and_Goedels_God Types_To_Sets_Extension UPF UPF_Firewall UTP Universal_Hash_Families Universal_Turing_Machine UpDown_Scheme Valuation Van_Emde_Boas_Trees Van_der_Waerden VectorSpace VeriComp Verified-Prover Verified_SAT_Based_AI_Planning VerifyThis2018 VerifyThis2019 Vickrey_Clarke_Groves Virtual_Substitution VolpanoSmith VYDRA_MDL WHATandWHERE_Security WOOT_Strong_Eventual_Consistency WebAssembly Weight_Balanced_Trees Weighted_Path_Order Well_Quasi_Orders Wetzels_Problem Winding_Number_Eval Word_Lib WorkerWrapper X86_Semantics XML Youngs_Inequality ZFC_in_HOL Zeta_3_Irrational Zeta_Function pGCL diff --git a/thys/ResiduatedTransitionSystem/LambdaCalculus.thy b/thys/ResiduatedTransitionSystem/LambdaCalculus.thy new file mode 100644 --- /dev/null +++ b/thys/ResiduatedTransitionSystem/LambdaCalculus.thy @@ -0,0 +1,10903 @@ +chapter "The Lambda Calculus" + + text \ + In this second part of the article, we apply the residuated transition system framework + developed in the first part to the theory of reductions in Church's \\\-calculus. + The underlying idea is to exhibit \\\-terms as states (identities) of an RTS, + with reduction steps as non-identity transitions. We represent both states and transitions + in a unified, variable-free syntax based on de Bruijn indices. + A difficulty one faces in regarding the \\\-calculus as an RTS is that + ``elementary reductions'', in which just one redex is contracted, are not preserved by + residuation: an elementary reduction can have zero or more residuals along another + elementary reduction. However, ``parallel reductions'', which permit the contraction of + multiple redexes existing in a term to be contracted in a single step, are preserved + by residuation. For this reason, in our syntax each term represents a parallel reduction + of zero or more redexes; a parallel reduction of zero redexes representing an identity. + We have syntactic constructors for variables, \\\-abstractions, and applications. + An additional constructor represents a \\\-redex that has been marked for contraction. + This is a slightly different approach that that taken by other authors + (\emph{e.g.}~\cite{barendregt} or \cite{huet-residual-theory}), in which it is the + application constructor that is marked to indicate a redex to be contracted, + but it seems more natural in the present setting in which a single syntax is used to + represent both terms and reductions. + + Once the syntax has been defined, we define the residuation operation and prove + that it satisfies the conditions for a weakly extensional RTS. In this RTS, the source + of a term is obtained by ``erasing'' the markings on redexes, leaving an identity term. + The target of a term is the contractum of the parallel reduction it represents. + As the definition of residuation involves the use of substitution, a necessary prerequisite + is to develop the theory of substitution using de Bruijn indices. + In addition, various properties concerning the commutation of residuation and substitution + have to be proved. This part of the work has benefited greatly from previous work + of Huet \cite{huet-residual-theory}, in which the theory of residuation was formalized + in the proof assistant Coq. In particular, it was very helpful to have already available + known-correct statements of various lemmas regarding indices, substitution, and residuation. + The development of the theory culminates in the proof of L\'{e}vy's ``Cube Lemma'' + \cite{levy}, which is the key axiom in the definition of RTS. + + Once reductions in the \\\-calculus have been cast as transitions of an RTS, + we are able to take advantage of generic results already proved for RTS's; in particular, + the construction of the RTS of paths, which represent reduction sequences. + Very little additional effort is required at this point to prove the Church-Rosser Theorem. + Then, after proving a series of miscellaneous lemmas about reduction paths, + we turn to the study of developments. A development of a term is a reduction path from + that term in which the only redexes that are contracted are those that are residuals of + redexes in the original term. We prove the Finite Developments Theorem: all developments + are finite. The proof given here follows that given by de Vrijer \cite{deVrijer}, + except that here we make the adaptations necessary for a syntax based on de Bruijn + indices, rather than the classical named-variable syntax used by de Vrijer. + Using the Finite Developments Theorem, we define a function that takes a term and constructs + a ``complete development'' of that term, which is a development in which no residuals of + original redexes remain to be contracted. + + We then turn our attention to ``standard reduction paths'', which are reduction paths in + which redexes are contracted in a left-to-right order, perhaps with some skips. + After giving a definition of standard reduction paths, we define a function that takes a + term and constructs a complete development that is also standard. + Using this function as a base case, we then define a function that takes an arbitrary + parallel reduction path and transforms it into a standard reduction path that is congruent + to the given path. The algorithm used is roughly analogous to insertion sort. + We use this function to prove strong form of the Standardization Theorem: every reduction + path is congruent to a standard reduction path. As a corollary of the Standardization + Theorem, we prove the Leftmost Reduction Theorem: leftmost reduction is a normalizing + reduction strategy. + + It should be noted that, in this article, we consider only the \\\\-calculus. + In the early stages of this work, I made an exploratory attempt to incorporate \\\-reduction + as well, but after encountering some unanticipated difficulties I decided not to attempt that + extension until the \\\-only case had been well-developed. + \ + +theory LambdaCalculus +imports Main ResiduatedTransitionSystem +begin + + section "Syntax" + + locale lambda_calculus + begin + + text \ + The syntax of terms has constructors \Var\ for variables, \Lam\ for \\\-abstraction, + and \App\ for application. In addition, there is a constructor \Beta\ which is used + to represent a \\\-redex that has been marked for contraction. The idea is that + a term \Beta t u\ represents a marked version of the term \App (Lam t) u\. + Finally, there is a constructor \Nil\ which is used to represent the null element + required for the residuation operation. + \ + + datatype (discs_sels) lambda = + Nil + | Var nat + | Lam lambda + | App lambda lambda + | Beta lambda lambda + + text \ + The following notation renders \Beta t u\ as a ``marked'' version of \App (Lam t) u\, + even though the former is a single constructor, whereas the latter contains two + constructors. + \ + + notation Nil ("\<^bold>\") + notation Var ("\<^bold>\_\<^bold>\") + notation Lam ("\<^bold>\\<^bold>[_\<^bold>]") + notation App (infixl "\<^bold>\" 55) + notation Beta ("(\<^bold>\\<^bold>[_\<^bold>] \<^bold>\ _)" [55, 56] 55) + + text \ + The following function computes the set of free variables of a term. + Note that since variables are represented by numeric indices, this is a set of numbers. + \ + + fun FV + where "FV \<^bold>\ = {}" + | "FV \<^bold>\i\<^bold>\ = {i}" + | "FV \<^bold>\\<^bold>[t\<^bold>] = (\n. n - 1) ` (FV t - {0})" + | "FV (t \<^bold>\ u) = FV t \ FV u" + | "FV (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = (\n. n - 1) ` (FV t - {0}) \ FV u" + + subsection "Some Orderings for Induction" + + text \ + We will need to do some simultaneous inductions on pairs and triples of subterms + of given terms. We prove the well-foundedness of the associated relations using + the following size measure. + \ + + fun size :: "lambda \ nat" + where "size \<^bold>\ = 0" + | "size \<^bold>\_\<^bold>\ = 1" + | "size \<^bold>\\<^bold>[t\<^bold>] = size t + 1" + | "size (t \<^bold>\ u) = size t + size u + 1" + | "size (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = (size t + 1) + size u + 1" + + lemma wf_if_img_lt: + fixes r :: "('a * 'a) set" and f :: "'a \ nat" + assumes "\x y. (x, y) \ r \ f x < f y" + shows "wf r" + using assms + by (metis in_measure wf_iff_no_infinite_down_chain wf_measure) + + inductive subterm + where "\t. subterm t \<^bold>\\<^bold>[t\<^bold>]" + | "\t u. subterm t (t \<^bold>\ u)" + | "\t u. subterm u (t \<^bold>\ u)" + | "\t u. subterm t (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + | "\t u. subterm u (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + | "\t u v. \subterm t u; subterm u v\ \ subterm t v" + + lemma subterm_implies_smaller: + shows "subterm t u \ size t < size u" + by (induct rule: subterm.induct) auto + + abbreviation subterm_rel + where "subterm_rel \ {(t, u). subterm t u}" + + lemma wf_subterm_rel: + shows "wf subterm_rel" + using subterm_implies_smaller wf_if_img_lt + by (metis case_prod_conv mem_Collect_eq) + + abbreviation subterm_pair_rel + where "subterm_pair_rel \ {((t1, t2), u1, u2). subterm t1 u1 \ subterm t2 u2}" + + lemma wf_subterm_pair_rel: + shows "wf subterm_pair_rel" + using subterm_implies_smaller + wf_if_img_lt [of subterm_pair_rel "\(t1, t2). max (size t1) (size t2)"] + by fastforce + + abbreviation subterm_triple_rel + where "subterm_triple_rel \ + {((t1, t2, t3), u1, u2, u3). subterm t1 u1 \ subterm t2 u2 \ subterm t3 u3}" + + lemma wf_subterm_triple_rel: + shows "wf subterm_triple_rel" + using subterm_implies_smaller + wf_if_img_lt [of subterm_triple_rel + "\(t1, t2, t3). max (max (size t1) (size t2)) (size t3)"] + by fastforce + + lemma subterm_lemmas: + shows "subterm t \<^bold>\\<^bold>[t\<^bold>]" + and "subterm t (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ subterm u (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + and "subterm t (t \<^bold>\ u) \ subterm u (t \<^bold>\ u)" + and "subterm t (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ subterm u (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + by (metis subterm.simps)+ + + subsection "Arrows and Identities" + + text \ + Here we define some special classes of terms. + An ``arrow'' is a term that contains no occurrences of \Nil\. + An ``identity'' is an arrow that contains no occurrences of \Beta\. + It will be important for the commutation of substitution and residuation later on + that substitution not be used in a way that could create any marked redexes; + for example, we don't want the substitution of \Lam (Var 0)\ for \Var 0\ in an + application \App (Var 0) (Var 0)\ to create a new ``marked'' redex. + The use of the separate constructor \Beta\ for marked redexes automatically avoids this. + \ + + fun Arr + where "Arr \<^bold>\ = False" + | "Arr \<^bold>\_\<^bold>\ = True" + | "Arr \<^bold>\\<^bold>[t\<^bold>] = Arr t" + | "Arr (t \<^bold>\ u) = (Arr t \ Arr u)" + | "Arr (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = (Arr t \ Arr u)" + + lemma Arr_not_Nil: + assumes "Arr t" + shows "t \ \<^bold>\" + using assms by auto + + fun Ide + where "Ide \<^bold>\ = False" + | "Ide \<^bold>\_\<^bold>\ = True" + | "Ide \<^bold>\\<^bold>[t\<^bold>] = Ide t" + | "Ide (t \<^bold>\ u) = (Ide t \ Ide u)" + | "Ide (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = False" + + lemma Ide_implies_Arr: + shows "Ide t \ Arr t" + by (induct t) auto + + lemma ArrE [elim]: + assumes "Arr t" + and "\i. t = \<^bold>\i\<^bold>\ \ T" + and "\u. t = \<^bold>\\<^bold>[u\<^bold>] \ T" + and "\u v. t = u \<^bold>\ v \ T" + and "\u v. t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v \ T" + shows T + using assms + by (cases t) auto + + subsection "Raising Indices" + + text \ + For substitution, we need to be able to raise the indices of all free variables + in a subterm by a specified amount. To do this recursively, we need to keep track + of the depth of nesting of \\\'s and only raise the indices of variables that are + already greater than or equal to that depth, as these are the variables that are free + in the current context. This leads to defining a function \Raise\ that has two arguments: + the depth threshold \d\ and the increment \n\ to be added to indices above that threshold. + \ + + fun Raise + where "Raise _ _ \<^bold>\ = \<^bold>\" + | "Raise d n \<^bold>\i\<^bold>\ = (if i \ d then \<^bold>\i+n\<^bold>\ else \<^bold>\i\<^bold>\)" + | "Raise d n \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[Raise (Suc d) n t\<^bold>]" + | "Raise d n (t \<^bold>\ u) = Raise d n t \<^bold>\ Raise d n u" + | "Raise d n (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[Raise (Suc d) n t\<^bold>] \<^bold>\ Raise d n u" + + text \ + Ultimately, the definition of substitution will only directly involve the function + that raises all indices of variables that are free in the outermost context; + in a term, so we introduce an abbreviation for this special case. + \ + + abbreviation raise + where "raise == Raise 0" + + lemma size_Raise: + shows "\d. size (Raise d n t) = size t" + by (induct t) auto + + lemma Raise_not_Nil: + assumes "t \ \<^bold>\" + shows "Raise d n t \ \<^bold>\" + using assms + by (cases t) auto + + lemma FV_Raise: + shows "\d n. FV (Raise d n t) = (\x. if x \ d then x + n else x) ` FV t" + apply (induct t) + apply auto[3] + apply force + apply force + apply force + apply force + apply fastforce + proof - + fix t u d n + assume ind1: "\d n. FV (Raise d n t) = (\x. if d \ x then x + n else x) ` FV t" + assume ind2: "\d n. FV (Raise d n u) = (\x. if d \ x then x + n else x) ` FV u" + have "FV (Raise d n (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)) = + (\x. x - Suc 0) ` ((\x. x + n) ` + (FV t \ {x. Suc d \ x}) \ FV t \ {x. \ Suc d \ x} - {0}) \ + ((\x. x + n) ` (FV u \ {x. d \ x}) \ FV u \ {x. \ d \ x})" + using ind1 ind2 by simp + also have "... = (\x. if d \ x then x + n else x) ` FV (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + apply simp + by force + finally show "FV (Raise d n (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)) = + (\x. if d \ x then x + n else x) ` FV (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + by blast + qed + + lemma Arr_Raise: + shows "\d n. Arr t \ Arr (Raise d n t)" + using FV_Raise + by (induct t) auto + + lemma Ide_Raise: + shows "\d n. Ide t \ Ide (Raise d n t)" + by (induct t) auto + + lemma Raise_0: + shows "\d n. Raise d 0 t = t" + by (induct t) auto + + lemma Raise_Suc: + shows "\d n. Raise d (Suc n) t = Raise d 1 (Raise d n t)" + by (induct t) auto + + lemma Raise_Var: + shows "Raise d n \<^bold>\i\<^bold>\ = \<^bold>\if i < d then i else i + n\<^bold>\" + by auto + + text \ + The following development of the properties of raising indices, substitution, and + residuation has benefited greatly from the previous work by Huet \cite{huet-residual-theory}. + In particular, it was very helpful to have correct statements of various lemmas + available, rather than having to reconstruct them. + \ + + lemma Raise_plus: + shows "\d m n. Raise d (m + n) t = Raise (d + m) n (Raise d m t)" + by (induct t) auto + + lemma Raise_plus': + shows "\n m d d'. \d' \ d + n; d \ d'\ \ Raise d (m + n) t = Raise d' m (Raise d n t)" + by (induct t) auto + + lemma Raise_Raise: + shows "\i k n p. i \ n \ Raise i p (Raise n k t) = Raise (p + n) k (Raise i p t)" + by (induct t) auto + + lemma raise_plus: + shows "\n m d. d \ n \ raise (m + n) t = Raise d m (raise n t)" + using Raise_plus' by auto + + lemma raise_Raise: + shows "\k p n. raise p (Raise n k t) = Raise (p + n) k (raise p t)" + by (simp add: Raise_Raise) + + lemma Raise_inj: + shows "\d n u. Raise d n t = Raise d n u \ t = u" + proof (induct t) + show "\d n u. Raise d n \<^bold>\ = Raise d n u \ \<^bold>\ = u" + by (metis Raise.simps(1) Raise_not_Nil) + show "\x d n. Raise d n \<^bold>\x\<^bold>\ = Raise d n u \ \<^bold>\x\<^bold>\ = u" for u + using Raise_Var + apply (cases u, auto) + by (metis add_lessD1 add_right_imp_eq) + show "\t d n. \\d n u'. Raise d n t = Raise d n u' \ t = u'; + Raise d n \<^bold>\\<^bold>[t\<^bold>] = Raise d n u\ + \ \<^bold>\\<^bold>[t\<^bold>] = u" + for u + apply (cases u, auto) + by (metis lambda.distinct(9)) + show "\t1 t2 d n. \\d n u'. Raise d n t1 = Raise d n u' \ t1 = u'; + \d n u'. Raise d n t2 = Raise d n u' \ t2 = u'; + Raise d n (t1 \<^bold>\ t2) = Raise d n u\ + \ t1 \<^bold>\ t2 = u" + for u + apply (cases u, auto) + by (metis lambda.distinct(11)) + show "\t1 t2 d n. \\d n u'. Raise d n t1 = Raise d n u' \ t1 = u'; + \d n u'. Raise d n t2 = Raise d n u' \ t2 = u'; + Raise d n (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) = Raise d n u\ + \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 = u" + for u + apply (cases u, auto) + by (metis lambda.distinct(13)) + qed + + subsection "Substitution" + + text \ + Following \cite{huet-residual-theory}, we now define a generalized substitution operation + with adjustment of indices. The ultimate goal is to define the result of contraction + of a marked redex \Beta t u\ to be \subst u t\. However, to be able to give a proper + recursive definition of \subst\, we need to introduce a parameter \n\ to keep track of the + depth of nesting of \Lam\'s as we descend into the the term \t\. So, instead of \subst u t\ + simply substituting \u\ for occurrences of \Var 0\, \Subst n u t\ will be substituting + for occurrences of \Var n\, and the term \u\ will have the indices of its free variables + raised by \n\ before replacing \Var n\. In addition, any variables in \t\ that have + indices greater than \n\ will have these indices lowered by one, to account for the + outermost \Lam\ that is being removed by the contraction. We can then define + \subst u t\ to be \Subst 0 u t\. + \ + + fun Subst + where "Subst _ _ \<^bold>\ = \<^bold>\" + | "Subst n v \<^bold>\i\<^bold>\ = (if n < i then \<^bold>\i-1\<^bold>\ else if n = i then raise n v else \<^bold>\i\<^bold>\)" + | "Subst n v \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[Subst (Suc n) v t\<^bold>]" + | "Subst n v (t \<^bold>\ u) = Subst n v t \<^bold>\ Subst n v u" + | "Subst n v (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[Subst (Suc n) v t\<^bold>] \<^bold>\ Subst n v u" + + abbreviation subst + where "subst \ Subst 0" + + lemma Subst_Nil: + shows "Subst n v \<^bold>\ = \<^bold>\" + by (cases "v = \<^bold>\") auto + + lemma Subst_not_Nil: + assumes "v \ \<^bold>\" and "t \ \<^bold>\" + shows "\n. t \ \<^bold>\ \ Subst n v t \ \<^bold>\" + using assms Raise_not_Nil + by (induct t) auto + + text \ + The following expression summarizes how the set of free variables of a term \Subst d u t\, + obtained by substituting \u\ into \t\ at depth \d\, relates to the sets of free variables + of \t\ and \u\. This expression is not used in the subsequent formal development, + but it has been left here as an aid to understanding. + \ + + abbreviation FVS + where "FVS d v t \ (FV t \ {x. x < d}) \ + (\x. x - 1) ` {x. x > d \ x \ FV t} \ + (\x. x + d) ` {x. d \ FV t \ x \ FV v}" + + lemma FV_Subst: + shows "\d v. FV (Subst d v t) = FVS d v t" + proof (induct t) + have "\d t v. (\x. x - 1) ` (FVS (Suc d) v t - {0}) = FVS d v \<^bold>\\<^bold>[t\<^bold>]" + by auto force+ (* 8 sec *) + thus "\d t v. (\d v. FV (Subst d v t) = FVS d v t) + \ FV (Subst d v \<^bold>\\<^bold>[t\<^bold>]) = FVS d v \<^bold>\\<^bold>[t\<^bold>]" + by simp + have "\t u v d. (\x. x - 1) ` (FVS (Suc d) v t - {0}) \ FVS d v u = FVS d v (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + by auto force+ (* 25 sec *) + thus "\t u v d. \\d v. FV (Subst d v t) = FVS d v t; + \d v. FV (Subst d v u) = FVS d v u\ + \ FV (Subst d v (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)) = FVS d v (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + by simp + qed (auto simp add: FV_Raise) + + lemma Arr_Subst: + assumes "Arr v" + shows "\n. Arr t \ Arr (Subst n v t)" + using assms Arr_Raise FV_Subst + by (induct t) auto + + lemma vacuous_Subst: + shows "\i v. \Arr v; i \ FV t\ \ Raise i 1 (Subst i v t) = t" + apply (induct t, auto) + by force+ + + lemma Ide_Subst_iff: + shows "\n. Ide (Subst n v t) \ Ide t \ (n \ FV t \ Ide v)" + using Ide_Raise vacuous_Subst + apply (induct t) + apply auto[5] + apply fastforce + by (metis Diff_empty Diff_insert0 One_nat_def diff_Suc_1 image_iff insertE + insert_Diff nat.distinct(1)) + + lemma Ide_Subst: + shows "\n. \Ide t; Ide v\ \ Ide (Subst n v t)" + using Ide_Raise + by (induct t) auto + + lemma Raise_Subst: + shows "\v k p n. Raise (p + n) k (Subst p v t) = + Subst p (Raise n k v) (Raise (Suc (p + n)) k t)" + using raise_Raise + apply (induct t, auto) + by (metis add_Suc)+ + + lemma Raise_Subst': + assumes "t \ \<^bold>\" + shows "\v n p k. \v \ \<^bold>\; k \ n\ \ Raise k p (Subst n v t) = Subst (p + n) v (Raise k p t)" + using assms raise_plus + apply (induct t, auto) + apply (metis Raise.simps(1) Subst_Nil Suc_le_mono add_Suc_right) + apply fastforce + apply fastforce + apply (metis Raise.simps(1) Subst_Nil Suc_le_mono add_Suc_right) + by fastforce + + lemma Raise_subst: + shows "\v k n. Raise n k (subst v t) = subst (Raise n k v) (Raise (Suc n) k t)" + using Raise_0 + apply (induct t, auto) + by (metis One_nat_def Raise_Subst plus_1_eq_Suc)+ + + lemma raise_Subst: + assumes "t \ \<^bold>\" + shows "\v n p. v \ \<^bold>\ \ raise p (Subst n v t) = Subst (p + n) v (raise p t)" + using assms Raise_plus raise_Raise Raise_Subst' + apply (induct t) + by (meson zero_le)+ + + lemma Subst_Raise: + shows "\v m n d. \v \ \<^bold>\; d \ m; m \ n + d\ + \ Subst m v (Raise d (Suc n) t) = Raise d n t" + by (induct t) auto + + lemma Subst_raise: + shows "\v m n. \v \ \<^bold>\; m \ n\ \ Subst m v (raise (Suc n) t) = raise n t" + using Subst_Raise + by (induct t) auto + + lemma Subst_Subst: + shows "\v w m n. \v \ \<^bold>\; w \ \<^bold>\\ \ + Subst (m + n) w (Subst m v t) = + Subst m (Subst n w v) (Subst (Suc (m + n)) w t)" + using Raise_0 raise_Subst Subst_not_Nil Subst_raise + apply (induct t, auto) + by (metis add_Suc)+ + + text \ + The Substitution Lemma, as given by Huet \cite{huet-residual-theory}. + \ + + lemma substitution_lemma: + shows "\v w n. \v \ \<^bold>\; w \ \<^bold>\\ \ + Subst n v (subst w t) = subst (Subst n v w) (Subst (Suc n) v t)" + using Subst_not_Nil Raise_0 Subst_Subst Subst_raise + apply (induct t, auto) + apply (metis Suc_lessD Suc_pred less_imp_le zero_less_diff) + by (metis One_nat_def plus_1_eq_Suc)+ + + section "Lambda-Calculus as an RTS" + + subsection "Residuation" + + text \ + We now define residuation on terms. + Residuation is an operation which, when defined for terms \t\ and \u\, + produces terms \t \ u\ and \u \ t\ that represent, respectively, what remains + of the reductions of \t\ after performing the reductions in \u\, + and what remains of the reductions of \u\ after performing the reductions in \t\. + + The definition ensures that, if residuation is defined for two terms, then those + terms in must be arrows that are \emph{coinitial} (\emph{i.e.}~they are the same + after erasing marks on redexes). The residual \t \ u\ then has marked redexes at + positions corresponding to redexes that were originally marked in \t\ and that + were not contracted by any of the reductions of \u\. + + This definition has also benefited from the presentation in \cite{huet-residual-theory}. + \ + + fun resid (infix "\\" 70) + where "\<^bold>\i\<^bold>\ \\ \<^bold>\i'\<^bold>\ = (if i = i' then \<^bold>\i\<^bold>\ else \<^bold>\)" + | "\<^bold>\\<^bold>[t\<^bold>] \\ \<^bold>\\<^bold>[t'\<^bold>] = (if t \\ t' = \<^bold>\ then \<^bold>\ else \<^bold>\\<^bold>[t \\ t'\<^bold>])" + | "(t \<^bold>\ u) \\ (t'\<^bold>\ u') = (if t \\ t' = \<^bold>\ \ u \\ u' = \<^bold>\ then \<^bold>\ else (t \\ t') \<^bold>\ (u \\ u'))" + | "(\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \\ (\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u') = (if t \\ t' = \<^bold>\ \ u \\ u' = \<^bold>\ then \<^bold>\ else subst (u \\ u') (t \\ t'))" + | "(\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \\ (\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u') = (if t \\ t' = \<^bold>\ \ u \\ u' = \<^bold>\ then \<^bold>\ else subst (u \\ u') (t \\ t'))" + | "(\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \\ (\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u') = (if t \\ t' = \<^bold>\ \ u \\ u' = \<^bold>\ then \<^bold>\ else \<^bold>\\<^bold>[t \\ t'\<^bold>] \<^bold>\ (u \\ u'))" + | "resid _ _ = \<^bold>\" + + text \ + Terms t and u are \emph{consistent} if residuation is defined for them. + \ + + abbreviation Con (infix "\" 50) + where "Con t u \ resid t u \ \<^bold>\" + + lemma ConE [elim]: + assumes "t \ t'" + and "\i. \t = \<^bold>\i\<^bold>\; t' = \<^bold>\i\<^bold>\; resid t t' = \<^bold>\i\<^bold>\\ \ T" + and "\u u'. \t = \<^bold>\\<^bold>[u\<^bold>]; t' = \<^bold>\\<^bold>[u'\<^bold>]; u \ u'; t \\ t' = \<^bold>\\<^bold>[u \\ u'\<^bold>]\ \ T" + and "\u v u' v'. \t = u \<^bold>\ v; t' = u' \<^bold>\ v'; u \ u'; v \ v'; + t \\ t' = (u \\ u') \<^bold>\ (v \\ v')\ \ T" + and "\u v u' v'. \t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v; t' = \<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v'; u \ u'; v \ v'; + t \\ t' = subst (v \\ v') (u \\ u')\ \ T" + and "\u v u' v'. \t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v; t' = Beta u' v'; u \ u'; v \ v'; + t \\ t' = subst (v \\ v') (u \\ u')\ \ T" + and "\u v u' v'. \t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v; t' = \<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v'; u \ u'; v \ v'; + t \\ t' = \<^bold>\\<^bold>[u \\ u'\<^bold>] \<^bold>\ (v \\ v')\ \ T" + shows T + using assms + apply (cases t; cases t') + apply simp_all + apply metis + apply metis + apply metis + apply (cases "un_App1 t", simp_all) + apply metis + apply (cases "un_App1 t'", simp_all) + apply metis + by metis + + text \ + A term can only be consistent with another if both terms are ``arrows''. + \ + + lemma Con_implies_Arr1: + shows "\u. t \ u \ Arr t" + apply (induct t) + apply auto[3] + proof - + fix u v t' + assume ind1: "\u'. u \ u' \ Arr u" + assume ind2: "\v'. v \ v' \ Arr v" + show "u \<^bold>\ v \ t' \ Arr (u \<^bold>\ v)" + using ind1 ind2 + apply (cases t', simp_all) + apply metis + apply (cases u, simp_all) + by (metis lambda.distinct(3) resid.simps(2)) + show "\<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v \ t' \ Arr (\<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v)" + using ind1 ind2 + apply (cases t', simp_all) + apply (cases "un_App1 t'", simp_all) + by metis+ + qed + + lemma Con_implies_Arr2: + shows "\t. t \ u \ Arr u" + apply (induct u) + apply auto[3] + proof - + fix u' v' t + assume ind1: "\u. u \ u' \ Arr u'" + assume ind2: "\v. v \ v' \ Arr v'" + show "t \ u' \<^bold>\ v' \ Arr (u' \<^bold>\ v')" + using ind1 ind2 + apply (cases t, simp_all) + apply metis + apply (cases u', simp_all) + by (metis lambda.distinct(3) resid.simps(2)) + show "t \ (\<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v') \ Arr (\<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v')" + using ind1 ind2 + apply (cases t, simp_all) + apply (cases "un_App1 t", simp_all) + by metis+ + qed + + lemma ConD: + shows "t \<^bold>\ u \ t' \<^bold>\ u' \ t \ t' \ u \ u'" + and "\<^bold>\\<^bold>[v\<^bold>] \<^bold>\ u \ \<^bold>\\<^bold>[v'\<^bold>] \<^bold>\ u' \ \<^bold>\\<^bold>[v\<^bold>] \ \<^bold>\\<^bold>[v'\<^bold>] \ u \ u'" + and "\<^bold>\\<^bold>[v\<^bold>] \<^bold>\ u \ t' \<^bold>\ u' \ \<^bold>\\<^bold>[v\<^bold>] \ t' \ u \ u'" + and "t \<^bold>\ u \ \<^bold>\\<^bold>[v'\<^bold>] \<^bold>\ u' \ t \ \<^bold>\\<^bold>[v'\<^bold>] \ u \ u'" + by auto + + text \ + Residuation on consistent terms preserves arrows. + \ + + lemma Arr_resid_ind: + shows "\u. t \ u \ Arr (t \\ u)" + apply (induct t) + apply auto + proof - + fix t1 t2 u + assume ind1: "\u. t1 \ u \ Arr (t1 \\ u)" + assume ind2: "\u. t2 \ u \ Arr (t2 \\ u)" + show "t1 \<^bold>\ t2 \ u \ Arr ((t1 \<^bold>\ t2) \\ u)" + using ind1 ind2 Arr_Subst + apply (cases u, auto) + apply (cases t1, auto) + by (metis Arr.simps(3) ConD(2) resid.simps(2) resid.simps(4)) + show "\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u \ Arr ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u)" + using ind1 ind2 Arr_Subst + by (cases u) auto + qed + + lemma Arr_resid: + shows "\u. t \ u \ Arr (t \\ u)" + using Arr_resid_ind by auto + + subsection "Source and Target" + + text \ + Here we give syntactic versions of the \emph{source} and \emph{target} of a term. + These will later be shown to agree (on arrows) with the versions derived from the residuation. + The underlying idea here is that a term stands for a reduction sequence in which + all marked redexes (corresponding to instances of the constructor \Beta\) are contracted + in a bottom-up fashion. A term without any marked redexes stands for an empty reduction + sequence; such terms will be shown to be the identities derived from the residuation. + The source of term is the identity obtained by erasing all markings; that is, by replacing + all subterms of the form \Beta t u\ by \App (Lam t) u\. The target of a term is the + identity that is the result of contracting all the marked redexes. + \ + + fun Src + where "Src \<^bold>\ = \<^bold>\" + | "Src \<^bold>\i\<^bold>\ = \<^bold>\i\<^bold>\" + | "Src \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[Src t\<^bold>]" + | "Src (t \<^bold>\ u) = Src t \<^bold>\ Src u" + | "Src (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u" + + fun Trg + where "Trg \<^bold>\i\<^bold>\ = \<^bold>\i\<^bold>\" + | "Trg \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[Trg t\<^bold>]" + | "Trg (t \<^bold>\ u) = Trg t \<^bold>\ Trg u" + | "Trg (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = subst (Trg u) (Trg t)" + | "Trg _ = \<^bold>\" + + lemma Ide_Src: + shows "Arr t \ Ide (Src t)" + by (induct t) auto + + lemma Ide_iff_Src_self: + assumes "Arr t" + shows "Ide t \ Src t = t" + using assms Ide_Src + by (induct t) auto + + lemma Arr_Src [simp]: + assumes "Arr t" + shows "Arr (Src t)" + using assms Ide_Src Ide_implies_Arr by blast + + lemma Con_Src: + shows "\t u. \size t + size u \ n; t \ u\ \ Src t \ Src u" + by (induct n) auto + + lemma Src_eq_iff: + shows "Src \<^bold>\i\<^bold>\ = Src \<^bold>\i'\<^bold>\ \ i = i'" + and "Src (t \<^bold>\ u) = Src (t' \<^bold>\ u') \ Src t = Src t' \ Src u = Src u'" + and "Src (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = Src (\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u') \ Src t = Src t' \ Src u = Src u'" + and "Src (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = Src (\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u') \ Src t = Src t' \ Src u = Src u'" + by auto + + lemma Src_Raise: + shows "\d. Src (Raise d n t) = Raise d n (Src t)" + by (induct t) auto + + lemma Src_Subst [simp]: + shows "\d X. \Arr t; Arr u\ \ Src (Subst d t u) = Subst d (Src t) (Src u)" + using Src_Raise + by (induct u) auto + + lemma Ide_Trg: + shows "Arr t \ Ide (Trg t)" + using Ide_Subst + by (induct t) auto + + lemma Ide_iff_Trg_self: + shows "Arr t \ Ide t \ Trg t = t" + apply (induct t) + apply auto + by (metis Ide.simps(5) Ide_Subst Ide_Trg)+ + + lemma Arr_Trg [simp]: + assumes "Arr X" + shows "Arr (Trg X)" + using assms Ide_Trg Ide_implies_Arr by blast + + lemma Src_Src [simp]: + assumes "Arr t" + shows "Src (Src t) = Src t" + using assms Ide_Src Ide_iff_Src_self Ide_implies_Arr by blast + + lemma Trg_Src [simp]: + assumes "Arr t" + shows "Trg (Src t) = Src t" + using assms Ide_Src Ide_iff_Trg_self Ide_implies_Arr by blast + + lemma Trg_Trg [simp]: + assumes "Arr t" + shows "Trg (Trg t) = Trg t" + using assms Ide_Trg Ide_iff_Trg_self Ide_implies_Arr by blast + + lemma Src_Trg [simp]: + assumes "Arr t" + shows "Src (Trg t) = Trg t" + using assms Ide_Trg Ide_iff_Src_self Ide_implies_Arr by blast + + text \ + Two terms are syntactically \emph{coinitial} if they are arrows with the same source; + that is, they represent two reductions from the same starting term. + \ + + abbreviation Coinitial + where "Coinitial t u \ Arr t \ Arr u \ Src t = Src u" + + text \ + We now show that terms are consistent if and only if they are coinitial. + \ + + lemma Coinitial_cases: + assumes "Arr t" and "Arr t'" and "Src t = Src t'" + shows "(t = \<^bold>\ \ t' = \<^bold>\) \ + (\x. t = \<^bold>\x\<^bold>\ \ t' = \<^bold>\x\<^bold>\) \ + (\u u'. t = \<^bold>\\<^bold>[u\<^bold>] \ t' = \<^bold>\\<^bold>[u'\<^bold>]) \ + (\u v u' v'. t = u \<^bold>\ v \ t' = u' \<^bold>\ v') \ + (\u v u' v'. t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v \ t' = \<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v') \ + (\u v u' v'. t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v \ t' = \<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v') \ + (\u v u' v'. t = \<^bold>\\<^bold>[u\<^bold>] \<^bold>\ v \ t' = \<^bold>\\<^bold>[u'\<^bold>] \<^bold>\ v')" + using assms + by (cases t; cases t') auto + + lemma Con_implies_Coinitial_ind: + shows "\t u. \size t + size u \ n; t \ u\ \ Coinitial t u" + using Con_implies_Arr1 Con_implies_Arr2 + by (induct n) auto + + lemma Coinitial_implies_Con_ind: + shows "\t u. \size (Src t) \ n; Coinitial t u\ \ t \ u" + proof (induct n) + show "\t u. \size (Src t) \ 0; Coinitial t u\ \ t \ u" + by auto + fix n t u + assume Coinitial: "Coinitial t u" + assume n: "size (Src t) \ Suc n" + assume ind: "\t u. \size (Src t) \ n; Coinitial t u\ \ t \ u" + show "t \ u" + using n ind Coinitial Coinitial_cases [of t u] Subst_not_Nil by auto + qed + + lemma Coinitial_iff_Con: + shows "Coinitial t u \ t \ u" + using Coinitial_implies_Con_ind Con_implies_Coinitial_ind by blast + + lemma Coinitial_Raise_Raise: + shows "\d n u. Coinitial t u \ Coinitial (Raise d n t) (Raise d n u)" + using Arr_Raise Src_Raise + apply (induct t, auto) + by (metis Raise.simps(3-4)) + + lemma Con_sym: + shows "t \ u \ u \ t" + by (metis Coinitial_iff_Con) + + lemma ConI [intro, simp]: + assumes "Arr t" and "Arr u" and "Src t = Src u" + shows "Con t u" + using assms Coinitial_iff_Con by blast + + lemma Con_Arr_Src [simp]: + assumes "Arr t" + shows "t \ Src t" and "Src t \ t" + using assms + by (auto simp add: Ide_Src Ide_implies_Arr) + + lemma resid_Arr_self: + shows "Arr t \ t \\ t = Trg t" + by (induct t) auto + + text \ + The following result is not used in the formal development that follows, + but it requires some proof and might eventually be useful. + \ + + lemma finite_branching: + shows "Ide a \ finite {t. Arr t \ Src t = a}" + proof (induct a) + show "Ide \<^bold>\ \ finite {t. Arr t \ Src t = \<^bold>\}" + by simp + fix x + have "\t. Src t = \<^bold>\x\<^bold>\ \ t = \<^bold>\x\<^bold>\" + using Src.elims by blast + thus "finite {t. Arr t \ Src t = \<^bold>\x\<^bold>\}" + by simp + next + fix a + assume a: "Ide \<^bold>\\<^bold>[a\<^bold>]" + assume ind: "Ide a \ finite {t. Arr t \ Src t = a}" + have "{t. Arr t \ Src t = \<^bold>\\<^bold>[a\<^bold>]} = Lam ` {t. Arr t \ Src t = a}" + proof + show "Lam ` {t. Arr t \ Src t = a} \ {t. Arr t \ Src t = \<^bold>\\<^bold>[a\<^bold>]}" + by auto + show "{t. Arr t \ Src t = \<^bold>\\<^bold>[a\<^bold>]} \ Lam ` {t. Arr t \ Src t = a}" + proof + fix t + assume t: "t \ {t. Arr t \ Src t = \<^bold>\\<^bold>[a\<^bold>]}" + show "t \ Lam ` {t. Arr t \ Src t = a}" + using t by (cases t) auto + qed + qed + thus "finite {t. Arr t \ Src t = \<^bold>\\<^bold>[a\<^bold>]}" + using a ind by simp + next + fix a1 a2 + assume ind1: "Ide a1 \ finite {t. Arr t \ Src t = a1}" + assume ind2: "Ide a2 \ finite {t. Arr t \ Src t = a2}" + assume a: "Ide (\<^bold>\\<^bold>[a1\<^bold>] \<^bold>\ a2)" + show "finite {t. Arr t \ Src t = \<^bold>\\<^bold>[a1\<^bold>] \<^bold>\ a2}" + using a ind1 ind2 by simp + next + fix a1 a2 + assume ind1: "Ide a1 \ finite {t. Arr t \ Src t = a1}" + assume ind2: "Ide a2 \ finite {t. Arr t \ Src t = a2}" + assume a: "Ide (a1 \<^bold>\ a2)" + have "{t. Arr t \ Src t = a1 \<^bold>\ a2} = + ({t. is_App t} \ ({t. Arr t \ Src (un_App1 t) = a1 \ Src (un_App2 t) = a2})) \ + ({t. is_Beta t \ is_Lam a1} \ + ({t. Arr t \ is_Lam a1 \ Src (un_Beta1 t) = un_Lam a1 \ Src (un_Beta2 t) = a2}))" + by fastforce + have "{t. Arr t \ Src t = a1 \<^bold>\ a2} = + (\(t1, t2). t1 \<^bold>\ t2) ` ({t1. Arr t1 \ Src t1 = a1} \ {t2. Arr t2 \ Src t2 = a2}) \ + (\(t1, t2). \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) ` + ({t1t2. is_Lam a1} \ + {t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2})" + proof + show "(\(t1, t2). t1 \<^bold>\ t2) ` ({t1. Arr t1 \ Src t1 = a1} \ {t2. Arr t2 \ Src t2 = a2}) \ + (\(t1, t2). \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) ` + ({t1t2. is_Lam a1} \ + {t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2}) + \ {t. Arr t \ Src t = a1 \<^bold>\ a2}" + by auto + show "{t. Arr t \ Src t = a1 \<^bold>\ a2} + \ (\(t1, t2). t1 \<^bold>\ t2) ` + ({t1. Arr t1 \ Src t1 = a1} \ {t2. Arr t2 \ Src t2 = a2}) \ + (\(t1, t2). \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) ` + ({t1t2. is_Lam a1} \ + {t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2})" + proof + fix t + assume t: "t \ {t. Arr t \ Src t = a1 \<^bold>\ a2}" + have "is_App t \ is_Beta t" + using t by auto + moreover have "is_App t \ t \ (\(t1, t2). t1 \<^bold>\ t2) ` + ({t1. Arr t1 \ Src t1 = a1} \ {t2. Arr t2 \ Src t2 = a2})" + using t image_iff is_App_def by fastforce + moreover have "is_Beta t \ + t \ (\(t1, t2). \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) ` + ({t1t2. is_Lam a1} \ + {t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2})" + using t is_Beta_def by fastforce + ultimately show "t \ (\(t1, t2). t1 \<^bold>\ t2) ` + ({t1. Arr t1 \ Src t1 = a1} \ {t2. Arr t2 \ Src t2 = a2}) \ + (\(t1, t2). \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) ` + ({t1t2. is_Lam a1} \ + {t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2})" + by blast + qed + qed + moreover have "finite ({t1. Arr t1 \ Src t1 = a1} \ {t2. Arr t2 \ Src t2 = a2})" + using a ind1 ind2 Ide.simps(4) by blast + moreover have "is_Lam a1 \ + finite ({t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2})" + proof - + assume a1: "is_Lam a1" + have "Ide (un_Lam a1)" + using a a1 is_Lam_def by force + have "Lam ` {t1. Arr t1 \ Src t1 = un_Lam a1} = {t. Arr t \ Src t = a1}" + proof + show "Lam ` {t1. Arr t1 \ Src t1 = un_Lam a1} \ {t. Arr t \ Src t = a1}" + using a1 by fastforce + show "{t. Arr t \ Src t = a1} \ Lam ` {t1. Arr t1 \ Src t1 = un_Lam a1}" + proof + fix t + assume t: "t \ {t. Arr t \ Src t = a1}" + have "is_Lam t" + using a1 t by auto + hence "un_Lam t \ {t1. Arr t1 \ Src t1 = un_Lam a1}" + using is_Lam_def t by force + thus "t \ Lam ` {t1. Arr t1 \ Src t1 = un_Lam a1}" + by (metis \is_Lam t\ lambda.collapse(2) rev_image_eqI) + qed + qed + moreover have "inj Lam" + using inj_on_def by blast + ultimately have "finite {t1. Arr t1 \ Src t1 = un_Lam a1}" + by (metis (mono_tags, lifting) Ide.simps(4) a finite_imageD ind1 injD inj_onI) + moreover have "finite {t2. Arr t2 \ Src t2 = a2}" + using Ide.simps(4) a ind2 by blast + ultimately + show "finite ({t1. Arr t1 \ Src t1 = un_Lam a1} \ {t2. Arr t2 \ Src t2 = a2})" + by blast + qed + ultimately show "finite {t. Arr t \ Src t = a1 \<^bold>\ a2}" + using a ind1 ind2 by simp + qed + + subsection "Residuation and Substitution" + + text \ + We now develop a series of lemmas that involve the interaction of residuation + and substitution. + \ + + lemma Raise_resid: + shows "\t u k n. t \ u \ Raise k n (t \\ u) = Raise k n t \\ Raise k n u" + proof - + (* + * Note: This proof uses subterm induction because the hypothesis Con t u yields + * cases in which App and Beta terms are compared, so that the first argument to App + * needs to be unfolded. + *) + fix t u k n + let ?P = "\(t, u). \k n. t \ u \ Raise k n (t \\ u) = Raise k n t \\ Raise k n u" + have "\t u. + \t' u'. ((t', u'), (t, u)) \ subterm_pair_rel \ + (\k n. t' \ u' \ + Raise k n (t' \\ u') = Raise k n t' \\ Raise k n u') \ + (\k n. t \ u \ Raise k n (t \\ u) = Raise k n t \\ Raise k n u)" + using subterm_lemmas Coinitial_iff_Con Coinitial_Raise_Raise Raise_subst by auto + thus "\t u k n. t \ u \ Raise k n (t \\ u) = Raise k n t \\ Raise k n u" + using wf_subterm_pair_rel wf_induct [of subterm_pair_rel ?P] by blast + qed + + lemma Con_Raise: + shows "\d n u. t \ u \ Raise d n t \ Raise d n u" + apply (induct t) + apply auto[3] + by (metis Raise_not_Nil Raise_resid)+ + + text \ + The following is Huet's Commutation Theorem \cite{huet-residual-theory}: + ``substitution commutes with residuation''. + \ + + lemma resid_Subst: + assumes "t \ t'" and "u \ u'" + shows "Subst n t u \\ Subst n t' u' = Subst n (t \\ t') (u \\ u')" + proof - + let ?P = "\(u, u'). \n t t'. t \ t' \ u \ u' \ + Subst n t u \\ Subst n t' u' = Subst n (t \\ t') (u \\ u')" + have "\u u'. \w w'. ((w, w'), (u, u')) \ subterm_pair_rel \ + (\n v v'. v \ v' \ w \ w' \ + Subst n v w \\ Subst n v' w' = Subst n (v \\ v') (w \\ w')) \ + \n t t'. t \ t' \ u \ u' \ + Subst n t u \\ Subst n t' u' = Subst n (t \\ t') (u \\ u')" + using subterm_lemmas Raise_resid Subst_not_Nil Con_Raise Raise_subst substitution_lemma + by auto + thus "Subst n t u \\ Subst n t' u' = Subst n (t \\ t') (u \\ u')" + using assms wf_subterm_pair_rel wf_induct [of subterm_pair_rel ?P] by auto + qed + + lemma Trg_Subst [simp]: + shows "\d t. \Arr t; Arr u\ \ Trg (Subst d t u) = Subst d (Trg t) (Trg u)" + by (metis Arr_Subst Arr_Trg Arr_not_Nil resid_Arr_self resid_Subst) + + lemma Src_resid: + shows "\t. t \ u \ Src (t \\ u) = Trg u" + proof (induct u, auto simp add: Arr_resid_ind) + fix t t1' + show "\t2'. \\t1. t1 \ t1' \ Src (t1 \\ t1') = Trg t1'; + \t2. t2 \ t2' \ Src (t2 \\ t2') = Trg t2'; + t \ t1' \<^bold>\ t2'\ + \ Src (t \\ (t1' \<^bold>\ t2')) = Trg t1' \<^bold>\ Trg t2'" + apply (cases t; cases t1') + apply auto + by (metis Src.simps(3) lambda.distinct(3) lambda.sel(2) resid.simps(2)) + qed + + lemma Coinitial_resid_resid: + assumes "t \ v" and "u \ v" + shows "Coinitial (t \\ v) (u \\ v)" + using assms Src_resid Arr_resid Coinitial_iff_Con by presburger + + lemma Con_implies_is_Lam_iff_is_Lam: + assumes "t \ u" + shows "is_Lam t \ is_Lam u" + using assms by auto + + lemma Con_implies_Coinitial3: + assumes "t \\ v \ u \\ v" + shows "Coinitial v u" and "Coinitial v t" and "Coinitial u t" + using assms + by (metis Coinitial_iff_Con resid.simps(7))+ + + text \ + We can now prove L\'{e}vy's ``Cube Lemma'' \cite{levy}, which is the key axiom + for a residuated transition system. + \ + + lemma Cube: + shows "v \\ t \ u \\ t \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + proof - + let ?P = "\(t, u, v). v \\ t \ u \\ t \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + have "\t u v. + \t' u' v'. + ((t', u', v'), (t, u, v)) \ subterm_triple_rel \ ?P (t', u', v') \ + v \\ t \ u \\ t \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + proof - + fix t u v + assume ind: "\t' u' v'. + ((t', u', v'), (t, u, v)) \ subterm_triple_rel \ ?P (t', u', v')" + show "v \\ t \ u \\ t \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + proof (intro impI) + assume con: "v \\ t \ u \\ t" + have "Con v t" + using con by auto + moreover have "Con u t" + using con by auto + ultimately show "(v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + using subterm_lemmas ind Coinitial_iff_Con Coinitial_resid_resid resid_Subst + apply (elim ConE [of v t] ConE [of u t]) + apply simp_all + apply metis + apply metis + apply (cases "un_App1 t"; cases "un_App1 v", simp_all) + apply metis + apply metis + apply metis + apply metis + apply metis + apply (cases "un_App1 u", simp_all) + apply metis + by metis + qed + qed + hence "?P (t, u, v)" + using wf_subterm_triple_rel wf_induct [of subterm_triple_rel ?P] by blast + thus "v \\ t \ u \\ t \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + by simp + qed + + subsection "Residuation Determines an RTS" + + text \ + We are now in a position to verify that the residuation operation that we have defined + satisfies the axioms for a residuated transition system, and that various notions + which we have defined syntactically above (\emph{e.g.}~arrow, source, target) agree + with the versions derived abstractly from residuation. + \ + + sublocale partial_magma resid + apply unfold_locales + by (metis Arr.simps(1) Coinitial_iff_Con) + + lemma null_char [simp]: + shows "null = \<^bold>\" + using null_def + by (metis null_is_zero(2) resid.simps(7)) + + sublocale residuation resid + using null_char Arr_resid Coinitial_iff_Con Cube + apply (unfold_locales, auto) + by metis+ + + (* TODO: Try to understand when notation is and is not inherited. *) + notation resid (infix "\\" 70) + + lemma resid_is_residuation: + shows "residuation resid" + .. + + lemma arr_char [iff]: + shows "arr t \ Arr t" + using Coinitial_iff_Con arr_def con_def null_char by auto + + lemma ide_char [iff]: + shows "ide t \ Ide t" + by (metis Ide_iff_Trg_self Ide_implies_Arr arr_char arr_resid_iff_con ide_def + resid_Arr_self) + + lemma resid_Arr_Ide: + shows "\a. \Ide a; Coinitial t a\ \ t \\ a = t" + using Ide_iff_Src_self + by (induct t, auto) + + lemma resid_Ide_Arr: + shows "\t. \Ide a; Coinitial a t\ \ Ide (a \\ t)" + apply (induct a) + apply auto[2] + by (metis ConI conI cube ideI ide_char null_char resid_Arr_Ide)+ + + lemma resid_Arr_Src [simp]: + assumes "Arr t" + shows "t \\ Src t = t" + using assms Ide_Src + by (simp add: Ide_implies_Arr resid_Arr_Ide) + + lemma resid_Src_Arr [simp]: + assumes "Arr t" + shows "Src t \\ t = Trg t" + using assms + by (metis (full_types) Con_Arr_Src(2) Con_implies_Arr1 Src_Src Src_resid cube + resid_Arr_Src resid_Arr_self) + + sublocale rts resid + proof + show "\a t. \ide a; con t a\ \ t \\ a = t" + using ide_char resid_Arr_Ide + by (metis Coinitial_iff_Con con_def null_char) + show "\t. arr t \ ide (trg t)" + by (simp add: Ide_Trg resid_Arr_self trg_def) + show "\a t. \ide a; con a t\ \ ide (resid a t)" + using ide_char null_char resid_Ide_Arr Coinitial_iff_Con con_def by force + show "\t u. con t u \ \a. ide a \ con a t \ con a u" + by (metis Coinitial_iff_Con Ide_Src Ide_iff_Src_self Ide_implies_Arr con_def + ide_char null_char) + show "\t u v. \ide (resid t u); con u v\ \ con (resid t u) (resid v u)" + by (metis Coinitial_resid_resid ide_char not_arr_null null_char resid_Ide_Arr + con_def con_sym ide_implies_arr) + qed + + lemma is_rts: + shows "rts resid" + .. + + lemma sources_char\<^sub>\: + shows "sources t = (if Arr t then {Src t} else {})" + proof (cases "Arr t") + show "\ Arr t \ ?thesis" + using arr_char arr_iff_has_source by auto + assume t: "Arr t" + have 1: "{Src t} \ sources t" + using t Ide_Src by force + moreover have "sources t \ {Src t}" + by (metis Coinitial_iff_Con Ide_iff_Src_self ide_char in_sourcesE null_char + con_def singleton_iff subsetI) + ultimately show ?thesis + using t by auto + qed + + lemma sources_simp [simp]: + assumes "Arr t" + shows "sources t = {Src t}" + using assms sources_char\<^sub>\ by auto + + lemma sources_simps [simp]: + shows "sources \<^bold>\ = {}" + and "sources \<^bold>\x\<^bold>\ = {\<^bold>\x\<^bold>\}" + and "arr t \ sources \<^bold>\\<^bold>[t\<^bold>] = {\<^bold>\\<^bold>[Src t\<^bold>]}" + and "\arr t; arr u\ \ sources (t \<^bold>\ u) = {Src t \<^bold>\ Src u}" + and "\arr t; arr u\ \ sources (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = {\<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u}" + using sources_char\<^sub>\ by auto + + lemma targets_char\<^sub>\: + shows "targets t = (if Arr t then {Trg t} else {})" + proof (cases "Arr t") + show "\ Arr t \ ?thesis" + by (meson arr_char arr_iff_has_target) + assume t: "Arr t" + have 1: "{Trg t} \ targets t" + using t resid_Arr_self trg_def trg_in_targets by force + moreover have "targets t \ {Trg t}" + by (metis 1 Ide_iff_Src_self arr_char ide_char ide_implies_arr + in_targetsE insert_subset prfx_implies_con resid_Arr_self + sources_resid sources_simp t) + ultimately show ?thesis + using t by auto + qed + + lemma targets_simp [simp]: + assumes "Arr t" + shows "targets t = {Trg t}" + using assms targets_char\<^sub>\ by auto + + lemma targets_simps [simp]: + shows "targets \<^bold>\ = {}" + and "targets \<^bold>\x\<^bold>\ = {\<^bold>\x\<^bold>\}" + and "arr t \ targets \<^bold>\\<^bold>[t\<^bold>] = {\<^bold>\\<^bold>[Trg t\<^bold>]}" + and "\arr t; arr u\ \ targets (t \<^bold>\ u) = {Trg t \<^bold>\ Trg u}" + and "\arr t; arr u\ \ targets (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = {subst (Trg u) (Trg t)}" + using targets_char\<^sub>\ by auto + + lemma seq_char: + shows "seq t u \ Arr t \ Arr u \ Trg t = Src u" + using seq_def arr_char sources_char\<^sub>\ targets_char\<^sub>\ by force + + lemma seqI\<^sub>\ [intro, simp]: + assumes "Arr t" and "Arr u" and "Trg t = Src u" + shows "seq t u" + using assms seq_char by simp + + lemma seqE\<^sub>\ [elim]: + assumes "seq t u" + and "\Arr t; Arr u; Trg t = Src u\ \ T" + shows T + using assms seq_char by blast + + text \ + The following classifies the ways that transitions can be sequential. It is useful + for later proofs by case analysis. + \ + + lemma seq_cases: + assumes "seq t u" + shows "(is_Var t \ is_Var u) \ + (is_Lam t \ is_Lam u) \ + (is_App t \ is_App u) \ + (is_App t \ is_Beta u \ is_Lam (un_App1 t)) \ + (is_App t \ is_Beta u \ is_Beta (un_App1 t)) \ + is_Beta t" + using assms seq_char + by (cases t; cases u) auto + + sublocale confluent_rts resid + by (unfold_locales) fastforce + + lemma is_confluent_rts: + shows "confluent_rts resid" + .. + + lemma con_char [iff]: + shows "con t u \ Con t u" + by fastforce + + lemma coinitial_char [iff]: + shows "coinitial t u \ Coinitial t u" + by fastforce + + lemma sources_Raise: + assumes "Arr t" + shows "sources (Raise d n t) = {Raise d n (Src t)}" + using assms + by (simp add: Coinitial_Raise_Raise Src_Raise) + + lemma targets_Raise: + assumes "Arr t" + shows "targets (Raise d n t) = {Raise d n (Trg t)}" + using assms + by (metis Arr_Raise ConI Raise_resid resid_Arr_self targets_char\<^sub>\) + + lemma sources_subst [simp]: + assumes "Arr t" and "Arr u" + shows "sources (subst t u) = {subst (Src t) (Src u)}" + using assms sources_char\<^sub>\ Arr_Subst arr_char by simp + + lemma targets_subst [simp]: + assumes "Arr t" and "Arr u" + shows "targets (subst t u) = {subst (Trg t) (Trg u)}" + using assms targets_char\<^sub>\ Arr_Subst arr_char by simp + + notation prfx (infix "\" 50) + notation cong (infix "\" 50) + + lemma prfx_char [iff]: + shows "t \ u \ Ide (t \\ u)" + using ide_char by simp + + lemma prfx_Var_iff: + shows "u \ \<^bold>\i\<^bold>\ \ u = \<^bold>\i\<^bold>\" + by (metis Arr.simps(2) Coinitial_iff_Con Ide.simps(1) Ide_iff_Src_self Src.simps(2) + ide_char resid_Arr_Ide) + + lemma prfx_Lam_iff: + shows "u \ Lam t \ is_Lam u \ un_Lam u \ t" + using ide_char Arr_not_Nil Con_implies_is_Lam_iff_is_Lam Ide_implies_Arr is_Lam_def + by fastforce + + lemma prfx_App_iff: + shows "u \ t1 \<^bold>\ t2 \ is_App u \ un_App1 u \ t1 \ un_App2 u \ t2" + using ide_char + by (cases u; cases t1) auto + + lemma prfx_Beta_iff: + shows "u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ + (is_App u \ un_App1 u \ \<^bold>\\<^bold>[t1\<^bold>] \ un_App2 u \ t2 \ + (0 \ FV (un_Lam (un_App1 u) \\ t1) \ un_App2 u \ t2)) \ + (is_Beta u \ un_Beta1 u \ t1 \ un_Beta2 u \ t2 \ + (0 \ FV (un_Beta1 u \\ t1) \ un_Beta2 u \ t2))" + using ide_char Ide_Subst_iff + by (cases u; cases "un_App1 u") auto + + lemma cong_Ide_are_eq: + assumes "t \ u" and "Ide t" and "Ide u" + shows "t = u" + using assms + by (metis Coinitial_iff_Con Ide_iff_Src_self con_char prfx_implies_con) + + lemma eq_Ide_are_cong: + assumes "t = u" and "Ide t" + shows "t \ u" + using assms Ide_implies_Arr resid_Ide_Arr by blast + + sublocale weakly_extensional_rts resid + apply unfold_locales + by (metis Coinitial_iff_Con Ide_iff_Src_self Ide_implies_Arr ide_char ide_def) + + lemma is_weakly_extensional_rts: + shows "weakly_extensional_rts resid" + .. + + lemma src_char [simp]: + shows "src t = (if Arr t then Src t else \<^bold>\)" + using src_def by force + + lemma trg_char [simp]: + shows "trg t = (if Arr t then Trg t else \<^bold>\)" + by (metis Coinitial_iff_Con resid_Arr_self trg_def) + + text \ + We ``almost'' have an extensional RTS. + The case that fails is \\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 = u\. + This is because \t1\ might ignore its argument, so that \subst t2 t1 = subst t2' t1\, + with both sides being identities, even if \t2 \ t2'\. + + The following gives a concrete example of such a situation. + \ + + abbreviation non_extensional_ex1 + where "non_extensional_ex1 \ \<^bold>\\<^bold>[\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>]\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>])" + + abbreviation non_extensional_ex2 + where "non_extensional_ex2 \ \<^bold>\\<^bold>[\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>]\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>])" + + lemma non_extensional: + shows "\<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ non_extensional_ex1 \ \<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ non_extensional_ex2" + and "\<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ non_extensional_ex1 \ \<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ non_extensional_ex2" + by auto + + text \ + The following gives an example of two terms that are both coinitial and coterminal, + but which are not congruent. + \ + + abbreviation cong_nontrivial_ex1 + where "cong_nontrivial_ex1 \ + \<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>])" + + abbreviation cong_nontrivial_ex2 + where "cong_nontrivial_ex2 \ + \<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\\<^bold>[\<^bold>\0\<^bold>\ \<^bold>\ \<^bold>\0\<^bold>\\<^bold>])" + + lemma cong_nontrivial: + shows "coinitial cong_nontrivial_ex1 cong_nontrivial_ex2" + and "coterminal cong_nontrivial_ex1 cong_nontrivial_ex2" + and "\ cong cong_nontrivial_ex1 cong_nontrivial_ex2" + by auto + + text \ + Every two coinitial transitions have a join, obtained structurally by unioning the sets + of marked redexes. + \ + + fun Join (infix "\" 52) + where "\<^bold>\x\<^bold>\ \ \<^bold>\x'\<^bold>\ = (if x = x' then \<^bold>\x\<^bold>\ else \<^bold>\)" + | "\<^bold>\\<^bold>[t\<^bold>] \ \<^bold>\\<^bold>[t'\<^bold>] = \<^bold>\\<^bold>[t \ t'\<^bold>]" + | "\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u \ \<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u' = \<^bold>\\<^bold>[(t \ t')\<^bold>] \<^bold>\ (u \ u')" + | "\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u \ \<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u' = \<^bold>\\<^bold>[(t \ t')\<^bold>] \<^bold>\ (u \ u')" + | "t \<^bold>\ u \ t'\<^bold>\ u' = (t \ t') \<^bold>\ (u \ u')" + | "\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u \ \<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u' = \<^bold>\\<^bold>[(t \ t')\<^bold>] \<^bold>\ (u \ u')" + | "_ \ _ = \<^bold>\" + + lemma Join_sym: + shows "t \ u = u \ t" + using Join.induct [of "\t u. t \ u = u \ t"] by auto + + lemma Src_Join: + shows "\u. Coinitial t u \ Src (t \ u) = Src t" + proof (induct t) + show "\u. Coinitial \<^bold>\ u \ Src (\<^bold>\ \ u) = Src \<^bold>\" + by simp + show "\x u. Coinitial \<^bold>\x\<^bold>\ u \ Src (\<^bold>\x\<^bold>\ \ u) = Src \<^bold>\x\<^bold>\" + by auto + fix t u + assume ind: "\u. Coinitial t u \ Src (t \ u) = Src t" + assume tu: "Coinitial \<^bold>\\<^bold>[t\<^bold>] u" + show "Src (\<^bold>\\<^bold>[t\<^bold>] \ u) = Src \<^bold>\\<^bold>[t\<^bold>]" + using tu ind + by (cases u) auto + next + fix t1 t2 u + assume ind1: "\u1. Coinitial t1 u1 \ Src (t1 \ u1) = Src t1" + assume ind2: "\u2. Coinitial t2 u2 \ Src (t2 \ u2) = Src t2" + assume tu: "Coinitial (t1 \<^bold>\ t2) u" + show "Src (t1 \<^bold>\ t2 \ u) = Src (t1 \<^bold>\ t2)" + using tu ind1 ind2 + apply (cases u, simp_all) + apply (cases t1, simp_all) + by (metis Arr.simps(3) Join.simps(2) Src.simps(3) lambda.sel(2)) + next + fix t1 t2 u + assume ind1: "\u1. Coinitial t1 u1 \ Src (t1 \ u1) = Src t1" + assume ind2: "\u2. Coinitial t2 u2 \ Src (t2 \ u2) = Src t2" + assume tu: "Coinitial (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u" + show "Src ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \ u) = Src (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + using tu ind1 ind2 + apply (cases u, simp_all) + by (cases "un_App1 u") auto + qed + + lemma resid_Join: + shows "\u. Coinitial t u \ (t \ u) \\ u = t \\ u" + proof (induct t) + show "\u. Coinitial \<^bold>\ u \ (\<^bold>\ \ u) \\ u = \<^bold>\ \\ u" + by auto + show "\x u. Coinitial \<^bold>\x\<^bold>\ u \ (\<^bold>\x\<^bold>\ \ u) \\ u = \<^bold>\x\<^bold>\ \\ u" + by auto + fix t u + assume ind: "\u. Coinitial t u \ (t \ u) \\ u = t \\ u" + assume tu: "Coinitial \<^bold>\\<^bold>[t\<^bold>] u" + show "(\<^bold>\\<^bold>[t\<^bold>] \ u) \\ u = \<^bold>\\<^bold>[t\<^bold>] \\ u" + using tu ind + by (cases u) auto + next + fix t1 t2 u + assume ind1: "\u1. Coinitial t1 u1 \ (t1 \ u1) \\ u1 = t1 \\ u1" + assume ind2: "\u2. Coinitial t2 u2 \ (t2 \ u2) \\ u2 = t2 \\ u2" + assume tu: "Coinitial (t1 \<^bold>\ t2) u" + show "(t1 \<^bold>\ t2 \ u) \\ u = (t1 \<^bold>\ t2) \\ u" + using tu ind1 ind2 Coinitial_iff_Con + apply (cases u, simp_all) + proof - + fix u1 u2 + assume u: "u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2" + have t2u2: "t2 \ u2" + using Arr_not_Nil Arr_resid tu u by simp + have t1u1: "Coinitial (un_Lam t1 \ u1) u1" + proof - + have "Arr (un_Lam t1 \ u1)" + by (metis Arr.simps(3-5) Coinitial_iff_Con Con_implies_is_Lam_iff_is_Lam + Join.simps(2) Src.simps(3-5) ind1 lambda.collapse(2) lambda.disc(8) + lambda.sel(3) tu u) + thus ?thesis + using Src_Join + by (metis Arr.simps(3-5) Coinitial_iff_Con Con_implies_is_Lam_iff_is_Lam + Src.simps(3-5) lambda.collapse(2) lambda.disc(8) lambda.sel(2-3) tu u) + qed + have "un_Lam t1 \ u1" + using t1u1 + by (metis Coinitial_iff_Con Con_implies_is_Lam_iff_is_Lam ConD(4) lambda.collapse(2) + lambda.disc(8) resid.simps(2) tu u) + thus "(t1 \<^bold>\ t2 \ \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2) = (t1 \<^bold>\ t2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)" + using u tu t1u1 t2u2 ind1 ind2 + apply (cases t1, auto) + proof - + fix v + assume v: "t1 = \<^bold>\\<^bold>[v\<^bold>]" + show "subst (t2 \\ u2) ((v \ u1) \\ u1) = subst (t2 \\ u2) (v \\ u1)" + proof - + have "subst (t2 \\ u2) ((v \ u1) \\ u1) = (t1 \<^bold>\ t2 \ \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)" + by (simp add: Coinitial_iff_Con ind2 t2u2 v) + also have "... = (t1 \<^bold>\ t2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)" + proof - + have "(t1 \<^bold>\ t2 \ \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2) = + (\<^bold>\\<^bold>[(v \ u1)\<^bold>] \<^bold>\ (t2 \ u2)) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)" + using v by simp + also have "... = subst (t2 \\ u2) ((v \ u1) \\ u1)" + by (simp add: Coinitial_iff_Con ind2 t2u2) + also have "... = subst (t2 \\ u2) (v \\ u1)" + proof - + have "(t1 \ \<^bold>\\<^bold>[u1\<^bold>]) \\ \<^bold>\\<^bold>[u1\<^bold>] = t1 \\ \<^bold>\\<^bold>[u1\<^bold>]" + using u tu ind1 by simp + thus ?thesis + using \un_Lam t1 \ u1 \ \<^bold>\\ t1u1 v by force + qed + also have "... = (t1 \<^bold>\ t2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)" + using tu u v by force + finally show ?thesis by blast + qed + also have "... = subst (t2 \\ u2) (v \\ u1)" + by (simp add: t2u2 v) + finally show ?thesis by auto + qed + qed + qed + next + fix t1 t2 u + assume ind1: "\u1. Coinitial t1 u1 \ (t1 \ u1) \\ u1 = t1 \\ u1" + assume ind2: "\u2. Coinitial t2 u2 \ (t2 \ u2) \\ u2 = t2 \\ u2" + assume tu: "Coinitial (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u" + show "((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \ u) \\ u = (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u" + using tu ind1 ind2 Coinitial_iff_Con + apply (cases u, simp_all) + proof - + fix u1 u2 + assume u: "u = u1 \<^bold>\ u2" + show "(\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u1 \<^bold>\ u2) \\ (u1 \<^bold>\ u2) = (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ (u1 \<^bold>\ u2)" + using ind1 ind2 tu u + by (cases u1) auto + qed + qed + + lemma prfx_Join: + shows "\u. Coinitial t u \ u \ t \ u" + proof (induct t) + show "\u. Coinitial \<^bold>\ u \ u \ \<^bold>\ \ u" + by simp + show "\x u. Coinitial \<^bold>\x\<^bold>\ u \ u \ \<^bold>\x\<^bold>\ \ u" + by auto + fix t u + assume ind: "\u. Coinitial t u \ u \ t \ u" + assume tu: "Coinitial \<^bold>\\<^bold>[t\<^bold>] u" + show "u \ \<^bold>\\<^bold>[t\<^bold>] \ u" + using tu ind + apply (cases u, auto) + by force + next + fix t1 t2 u + assume ind1: "\u1. Coinitial t1 u1 \ u1 \ t1 \ u1" + assume ind2: "\u2. Coinitial t2 u2 \ u2 \ t2 \ u2" + assume tu: "Coinitial (t1 \<^bold>\ t2) u" + show "u \ t1 \<^bold>\ t2 \ u" + using tu ind1 ind2 Coinitial_iff_Con + apply (cases u, simp_all) + apply (metis Ide.simps(1)) + proof - + fix u1 u2 + assume u: "u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2" + assume 1: "Arr t1 \ Arr t2 \ Arr u1 \ Arr u2 \ Src t1 = \<^bold>\\<^bold>[Src u1\<^bold>] \ Src t2 = Src u2" + have 2: "u1 \ un_Lam t1 \ u1" + by (metis "1" Coinitial_iff_Con Con_implies_is_Lam_iff_is_Lam Con_Arr_Src(2) + lambda.collapse(2) lambda.disc(8) resid.simps(2) resid_Join) + have 3: "u2 \ t2 \ u2" + by (metis "1" conE ind2 null_char prfx_implies_con) + show "Ide ((\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2) \\ (t1 \<^bold>\ t2 \ \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2))" + using u tu 1 2 3 ind1 ind2 + apply (cases t1, simp_all) + by (metis Arr.simps(3) Ide.simps(3) Ide_Subst Join.simps(2) Src.simps(3) resid.simps(2)) + qed + next + fix t1 t2 u + assume ind1: "\u1. Coinitial t1 u1 \ u1 \ t1 \ u1" + assume ind2: "\u2. Coinitial t2 u2 \ u2 \ t2 \ u2" + assume tu: "Coinitial (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u" + show "u \ (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \ u" + using tu ind1 ind2 Coinitial_iff_Con + apply (cases u, simp_all) + apply (cases "un_App1 u", simp_all) + by (metis Ide.simps(1) Ide_Subst)+ + qed + + lemma Ide_resid_Join: + shows "\u. Coinitial t u \ Ide (u \\ (t \ u))" + using ide_char prfx_Join by blast + + lemma join_of_Join: + assumes "Coinitial t u" + shows "join_of t u (t \ u)" + proof (unfold join_of_def composite_of_def, intro conjI) + show "t \ t \ u" + using assms Join_sym prfx_Join [of u t] by simp + show "u \ t \ u" + using assms Ide_resid_Join ide_char by simp + show "(t \ u) \\ t \ u \\ t" + by (metis \prfx u (Join t u)\ arr_char assms cong_subst_right(2) prfx_implies_con + prfx_reflexive resid_Join con_sym cube) + show "u \\ t \ (t \ u) \\ t" + by (metis Coinitial_resid_resid \prfx t (Join t u)\ \prfx u (Join t u)\ conE ide_char + null_char prfx_implies_con resid_Ide_Arr cube) + show "(t \ u) \\ u \ t \\ u" + using \(t \ u) \ t \ u \ t\ cube by auto + show "t \\ u \ (t \ u) \\ u" + by (metis \(t \ u) \ t \ u \ t\ assms cube resid_Join) + qed + + sublocale rts_with_joins resid + using join_of_Join + apply unfold_locales + by (metis Coinitial_iff_Con conE joinable_def null_char) + + lemma is_rts_with_joins: + shows "rts_with_joins resid" + .. + + subsection "Simulations from Syntactic Constructors" + + text \ + Here we show that the syntactic constructors \Lam\ and \App\, as well as the substitution + operation \subst\, determine simulations. In addition, we show that \Beta\ determines + a transformation from \App \ (Lam \ Id)\ to \subst\. + \ + + abbreviation Lam\<^sub>e\<^sub>x\<^sub>t + where "Lam\<^sub>e\<^sub>x\<^sub>t t \ if arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\" + + lemma Lam_is_simulation: + shows "simulation resid resid Lam\<^sub>e\<^sub>x\<^sub>t" + using Arr_resid Coinitial_iff_Con + by unfold_locales auto + + interpretation Lam: simulation resid resid Lam\<^sub>e\<^sub>x\<^sub>t + using Lam_is_simulation by simp + + interpretation \x\: product_of_weakly_extensional_rts resid resid + .. + + abbreviation App\<^sub>e\<^sub>x\<^sub>t + where "App\<^sub>e\<^sub>x\<^sub>t t \ if \x\.arr t then fst t \<^bold>\ snd t else \<^bold>\" + + lemma App_is_binary_simulation: + shows "binary_simulation resid resid resid App\<^sub>e\<^sub>x\<^sub>t" + proof + show "\t. \ \x\.arr t \ App\<^sub>e\<^sub>x\<^sub>t t = null" + by auto + show "\t u. \x\.con t u \ con (App\<^sub>e\<^sub>x\<^sub>t t) (App\<^sub>e\<^sub>x\<^sub>t u)" + using \x\.con_char Coinitial_iff_Con by auto + show "\t u. \x\.con t u \ App\<^sub>e\<^sub>x\<^sub>t (\x\.resid t u) = App\<^sub>e\<^sub>x\<^sub>t t \\ App\<^sub>e\<^sub>x\<^sub>t u" + using \x\.arr_char \x\.resid_def + apply simp + by (metis Arr_resid_ind Con_implies_Arr1 Con_implies_Arr2) + qed + + interpretation App: binary_simulation resid resid resid App\<^sub>e\<^sub>x\<^sub>t + using App_is_binary_simulation by simp + + abbreviation subst\<^sub>e\<^sub>x\<^sub>t + where "subst\<^sub>e\<^sub>x\<^sub>t \ \t. if \x\.arr t then subst (snd t) (fst t) else \<^bold>\" + + lemma subst_is_binary_simulation: + shows "binary_simulation resid resid resid subst\<^sub>e\<^sub>x\<^sub>t" + proof + show "\t. \ \x\.arr t \ subst\<^sub>e\<^sub>x\<^sub>t t = null" + by auto + show "\t u. \x\.con t u \ con (subst\<^sub>e\<^sub>x\<^sub>t t) (subst\<^sub>e\<^sub>x\<^sub>t u)" + using \x\.con_char con_char Subst_not_Nil resid_Subst \x\.coinitialE + \x\.con_imp_coinitial + apply simp + by metis + show "\t u. \x\.con t u \ subst\<^sub>e\<^sub>x\<^sub>t (\x\.resid t u) = subst\<^sub>e\<^sub>x\<^sub>t t \\ subst\<^sub>e\<^sub>x\<^sub>t u" + using \x\.arr_char \x\.resid_def + apply simp + by (metis Arr_resid_ind Con_implies_Arr1 Con_implies_Arr2 resid_Subst) + qed + + interpretation subst: binary_simulation resid resid resid subst\<^sub>e\<^sub>x\<^sub>t + using subst_is_binary_simulation by simp + + interpretation Id: identity_simulation resid + .. + interpretation Lam_Id: product_simulation resid resid resid resid Lam\<^sub>e\<^sub>x\<^sub>t Id.map + .. + interpretation App_o_Lam_Id: composite_simulation \x\.resid \x\.resid resid Lam_Id.map App\<^sub>e\<^sub>x\<^sub>t + .. + + abbreviation Beta\<^sub>e\<^sub>x\<^sub>t + where "Beta\<^sub>e\<^sub>x\<^sub>t t \ if \x\.arr t then \<^bold>\\<^bold>[fst t\<^bold>] \<^bold>\ snd t else \<^bold>\" + + lemma Beta_is_transformation: + shows "transformation \x\.resid resid App_o_Lam_Id.map subst\<^sub>e\<^sub>x\<^sub>t Beta\<^sub>e\<^sub>x\<^sub>t" + proof + show "\f. \ \x\.arr f \ Beta\<^sub>e\<^sub>x\<^sub>t f = null" + by simp + show "\f. \x\.arr f \ src (Beta\<^sub>e\<^sub>x\<^sub>t f) = App_o_Lam_Id.map (\x\.src f)" + using \x\.src_char Lam_Id.map_def by simp + show "\f. \x\.arr f \ trg (Beta\<^sub>e\<^sub>x\<^sub>t f) = subst\<^sub>e\<^sub>x\<^sub>t (\x\.trg f)" + using \x\.trg_char by simp + show "\f. \x\.arr f \ + Beta\<^sub>e\<^sub>x\<^sub>t (\x\.src f) \\ App_o_Lam_Id.map f = Beta\<^sub>e\<^sub>x\<^sub>t (\x\.trg f)" + using \x\.src_char \x\.trg_char Arr_Trg Arr_not_Nil Lam_Id.map_def by simp + show "\f. \x\.arr f \ App_o_Lam_Id.map f \\ Beta\<^sub>e\<^sub>x\<^sub>t (\x\.src f) = subst\<^sub>e\<^sub>x\<^sub>t f" + using \x\.src_char \x\.trg_char Lam_Id.map_def by auto + qed + + text \ + The next two results are used to show that mapping App over lists of transitions + preserves paths. + \ + + lemma App_is_simulation1: + assumes "ide a" + shows "simulation resid resid (\t. if arr t then t \<^bold>\ a else \<^bold>\)" + proof - + have "(\t. if \x\.arr (t, a) then fst (t, a) \<^bold>\ snd (t, a) else \<^bold>\) = + (\t. if arr t then t \<^bold>\ a else \<^bold>\)" + using assms ide_implies_arr by force + thus ?thesis + using assms App.fixing_ide_gives_simulation_2 [of a] by auto + qed + + lemma App_is_simulation2: + assumes "ide a" + shows "simulation resid resid (\t. if arr t then a \<^bold>\ t else \<^bold>\)" + proof - + have "(\t. if \x\.arr (a, t) then fst (a, t) \<^bold>\ snd (a, t) else \<^bold>\) = + (\t. if arr t then a \<^bold>\ t else \<^bold>\)" + using assms ide_implies_arr by force + thus ?thesis + using assms App.fixing_ide_gives_simulation_1 [of a] by auto + qed + + subsection "Reduction and Conversion" + + text \ + Here we define the usual relations of reduction and conversion. + Reduction is the least transitive relation that relates \a\ to \b\ if there exists + an arrow \t\ having \a\ as its source and \b\ as its target. + Conversion is the least transitive relation that relates \a\ to b if there exists + an arrow \t\ in either direction between \a\ and \b\. + \ + + inductive red + where "Arr t \ red (Src t) (Trg t)" + | "\red a b; red b c\ \ red a c" + + inductive cnv + where "Arr t \ cnv (Src t) (Trg t)" + | "Arr t \ cnv (Trg t) (Src t)" + | "\cnv a b; cnv b c\ \ cnv a c" + + lemma cnv_refl: + assumes "Ide a" + shows "cnv a a" + using assms + by (metis Ide_iff_Src_self Ide_implies_Arr cnv.simps) + + lemma cnv_sym: + shows "cnv a b \ cnv b a" + apply (induct rule: cnv.induct) + using cnv.intros(1-2) + apply auto[2] + using cnv.intros(3) by blast + + lemma red_imp_cnv: + shows "red a b \ cnv a b" + using cnv.intros(1,3) red.inducts by blast + + end + + text \ + We now define a locale that extends the residuation operation defined above + to paths, using general results that have already been shown for paths in an RTS. + In particular, we are taking advantage of the general proof of the Cube Lemma for + residuation on paths. + + Our immediate goal is to prove the Church-Rosser theorem, so we first prove a lemma + that connects the reduction relation to paths. Later, we will prove many more + facts in this locale, thereby developing a general framework for reasoning about + reduction paths in the \\\-calculus. + \ + + locale reduction_paths = + \: lambda_calculus + begin + + sublocale \: rts \.resid + by (simp add: \.is_rts_with_joins rts_with_joins.axioms(1)) + sublocale paths_in_weakly_extensional_rts \.resid + .. + sublocale paths_in_confluent_rts \.resid + using confluent_rts.axioms(1) \.is_confluent_rts paths_in_rts_def + paths_in_confluent_rts.intro + by blast + + notation \.resid (infix "\\" 70) + notation \.con (infix "\" 50) + notation \.prfx (infix "\" 50) + notation \.cong (infix "\" 50) + + notation Resid (infix "\<^sup>*\\\<^sup>*" 70) + notation Resid1x (infix "\<^sup>1\\\<^sup>*" 70) + notation Residx1 (infix "\<^sup>*\\\<^sup>1" 70) + notation con (infix "\<^sup>*\\<^sup>*" 50) + notation prfx (infix "\<^sup>*\\<^sup>*" 50) + notation cong (infix "\<^sup>*\\<^sup>*" 50) + + lemma red_iff: + shows "\.red a b \ (\T. Arr T \ Src T = a \ Trg T = b)" + proof + show "\.red a b \ \T. Arr T \ Src T = a \ Trg T = b" + proof (induct rule: \.red.induct) + show "\t. \.Arr t \ \T. Arr T \ Src T = \.Src t \ Trg T = \.Trg t" + by (metis Arr.simps(2) Srcs.simps(2) Srcs_simp\<^sub>P\<^sub>W\<^sub>E Trg.simps(2) \.trg_def + \.arr_char \.resid_Arr_self \.sources_char\<^sub>\ singleton_insert_inj_eq') + show "\a b c. \\T. Arr T \ Src T = a \ Trg T = b; + \T. Arr T \ Src T = b \ Trg T = c\ + \ \T. Arr T \ Src T = a \ Trg T = c" + by (metis Arr.simps(1) Arr_appendI\<^sub>P\<^sub>W\<^sub>E Srcs_append Srcs_simp\<^sub>P\<^sub>W\<^sub>E Trgs_append + Trgs_simp\<^sub>P\<^sub>W\<^sub>E singleton_insert_inj_eq') + qed + show "\T. Arr T \ Src T = a \ Trg T = b \ \.red a b" + proof - + have "Arr T \ \.red (Src T) (Trg T)" for T + proof (induct T) + show "Arr [] \ \.red (Src []) (Trg [])" + by auto + fix t T + assume ind: "Arr T \ \.red (Src T) (Trg T)" + assume Arr: "Arr (t # T)" + show "\.red (Src (t # T)) (Trg (t # T))" + proof (cases "T = []") + show "T = [] \ ?thesis" + using Arr arr_char \.red.intros(1) by simp + assume T: "T \ []" + have "\.red (Src (t # T)) (\.Trg t)" + apply simp + by (meson Arr Arr.simps(2) Con_Arr_self Con_implies_Arr(1) Con_initial_left + \.arr_char \.red.intros(1)) + moreover have "\.Trg t = Src T" + using Arr + by (metis Arr.elims(2) Srcs_simp\<^sub>P\<^sub>W\<^sub>E T \.arr_iff_has_target insert_subset + \.targets_char\<^sub>\ list.sel(1) list.sel(3) singleton_iff) + ultimately show ?thesis + using ind + by (metis (no_types, opaque_lifting) Arr Con_Arr_self Con_implies_Arr(2) + Resid_cons(2) T Trg.simps(3) \.red.intros(2) neq_Nil_conv) + qed + qed + thus "\T. Arr T \ Src T = a \ Trg T = b \ \.red a b" + by blast + qed + qed + + end + + subsection "The Church-Rosser Theorem" + + context lambda_calculus + begin + + interpretation \x: reduction_paths . + + theorem church_rosser: + shows "cnv a b \ \c. red a c \ red b c" + proof (induct rule: cnv.induct) + show "\t. Arr t \ \c. red (Src t) c \ red (Trg t) c" + by (metis Ide_Trg Ide_iff_Src_self Ide_iff_Trg_self Ide_implies_Arr red.intros(1)) + thus "\t. Arr t \ \c. red (Trg t) c \ red (Src t) c" + by auto + show "\a b c. \cnv a b; cnv b c; \x. red a x \ red b x; \y. red b y \ red c y\ + \ \z. red a z \ red c z" + proof - + fix a b c + assume ind1: "\x. red a x \ red b x" and ind2: "\y. red b y \ red c y" + obtain x where x: "red a x \ red b x" + using ind1 by blast + obtain y where y: "red b y \ red c y" + using ind2 by blast + obtain T1 U1 where 1: "\x.Arr T1 \ \x.Arr U1 \ \x.Src T1 = a \ \x.Src U1 = b \ + \x.Trgs T1 = \x.Trgs U1" + using x \x.red_iff [of a x] \x.red_iff [of b x] by fastforce + obtain T2 U2 where 2: "\x.Arr T2 \ \x.Arr U2 \ \x.Src T2 = b \ \x.Src U2 = c \ + \x.Trgs T2 = \x.Trgs U2" + using y \x.red_iff [of b y] \x.red_iff [of c y] by fastforce + show "\e. red a e \ red c e" + proof - + let ?T = "T1 @ (\x.Resid T2 U1)" and ?U = "U2 @ (\x.Resid U1 T2)" + have 3: "\x.Arr ?T \ \x.Arr ?U \ \x.Src ?T = a \ \x.Src ?U = c" + using 1 2 + by (metis \x.Arr_appendI\<^sub>P\<^sub>W\<^sub>E \x.Arr_has_Trg \x.Con_imp_Arr_Resid \x.Src_append + \x.Src_resid \x.Srcs_simp\<^sub>P\<^sub>W\<^sub>E \x.Trgs.simps(1) \x.Trgs_simp\<^sub>P\<^sub>W\<^sub>E \x.arrI\<^sub>P + \x.arr_append_imp_seq \x.confluence_ind singleton_insert_inj_eq') + moreover have "\x.Trgs ?T = \x.Trgs ?U" + using 1 2 3 \x.Srcs_simp\<^sub>P\<^sub>W\<^sub>E \x.Trgs_Resid_sym \x.Trgs_append \x.confluence_ind + by presburger + ultimately have "\T U. \x.Arr T \ \x.Arr U \ \x.Src T = a \ \x.Src U = c \ + \x.Trgs T = \x.Trgs U" + by blast + thus ?thesis + using \x.red_iff \x.Arr_has_Trg by fastforce + qed + qed + qed + + corollary weak_diamond: + assumes "red a b" and "red a b'" + obtains c where "red b c" and "red b' c" + proof - + have "cnv b b'" + using assms + by (metis cnv.intros(1) cnv.intros(3) cnv_sym red.induct) + thus ?thesis + using that church_rosser by blast + qed + + text \ + As a consequence of the Church-Rosser Theorem, the collection of all reduction + paths forms a coherent normal sub-RTS of the RTS of reduction paths, and on identities + the congruence induced by this normal sub-RTS coincides with convertibility. + The quotient of the \\\-calculus RTS by this congruence is then obviously discrete: + the only transitions are identities. + \ + + interpretation Red: normal_sub_rts \x.Resid \Collect \x.Arr\ + proof + show "\t. t \ Collect \x.Arr \ \x.arr t" + by blast + show "\a. \x.ide a \ a \ Collect \x.Arr" + using \x.Ide_char \x.ide_char by blast + show "\u t. \u \ Collect \x.Arr; \x.coinitial t u\ \ \x.Resid u t \ Collect \x.Arr" + by (metis \x.Con_imp_Arr_Resid \x.Resid.simps(1) \x.con_sym \x.confluence\<^sub>P \x.ide_def + \\a. \x.ide a \ a \ Collect \x.Arr\ mem_Collect_eq \x.arr_resid_iff_con) + show "\u t. \u \ Collect \x.Arr; \x.Resid t u \ Collect \x.Arr\ \ t \ Collect \x.Arr" + by (metis \x.Arr.simps(1) \x.Con_implies_Arr(1) mem_Collect_eq) + show "\u t. \u \ Collect \x.Arr; \x.seq u t\ \ \v. \x.composite_of u t v" + by (meson \x.obtains_composite_of) + show "\u t. \u \ Collect \x.Arr; \x.seq t u\ \ \v. \x.composite_of t u v" + by (meson \x.obtains_composite_of) + qed + + interpretation Red: coherent_normal_sub_rts \x.Resid \Collect \x.Arr\ + apply unfold_locales + by (metis Red.Cong_closure_props(4) Red.Cong_imp_arr(2) \x.Con_imp_Arr_Resid + \x.arr_resid_iff_con \x.con_char \x.sources_resid mem_Collect_eq) + + lemma cnv_iff_Cong: + assumes "ide a" and "ide b" + shows "cnv a b \ Red.Cong [a] [b]" + proof + assume 1: "Red.Cong [a] [b]" + obtain U V + where UV: "\x.Arr U \ \x.Arr V \ Red.Cong\<^sub>0 (\x.Resid [a] U) (\x.Resid [b] V)" + using 1 Red.Cong_def [of "[a]" "[b]"] by blast + have "red a (\x.Trg U) \ red b (\x.Trg V)" + by (metis UV \x.Arr.simps(1) \x.Con_implies_Arr(1) \x.Resid_single_ide(2) \x.Src_resid + \x.Trg.simps(2) assms(1-2) mem_Collect_eq reduction_paths.red_iff trg_ide) + moreover have "\x.Trg U = \x.Trg V" + using UV + by (metis (no_types, lifting) Red.Cong\<^sub>0_imp_con \x.Arr.simps(1) \x.Con_Arr_self + \x.Con_implies_Arr(1) \x.Resid_single_ide(2) \x.Src_resid \x.cube \x.ide_def + \x.resid_arr_ide assms(1) mem_Collect_eq) + ultimately show "cnv a b" + by (metis cnv_sym cnv.intros(3) red_imp_cnv) + next + assume 1: "cnv a b" + obtain c where c: "red a c \ red b c" + using 1 church_rosser by blast + obtain U where U: "\x.Arr U \ \x.Src U = a \ \x.Trg U = c" + using c \x.red_iff by blast + obtain V where V: "\x.Arr V \ \x.Src V = b \ \x.Trg V = c" + using c \x.red_iff by blast + have "\x.Resid1x a U = c \ \x.Resid1x b V = c" + by (metis U V \x.Con_single_ide_ind \x.Ide.simps(2) \x.Resid1x_as_Resid + \x.Resid_Ide_Arr_ind \x.Resid_single_ide(2) \x.Srcs_simp\<^sub>P\<^sub>W\<^sub>E \x.Trg.simps(2) + \x.Trg_resid_sym \x.ex_un_Src assms(1-2) singletonD trg_ide) + hence "Red.Cong\<^sub>0 (\x.Resid [a] U) (\x.Resid [b] V)" + by (metis Red.Cong\<^sub>0_reflexive U V \x.Con_single_ideI(1) \x.Resid1x_as_Resid + \x.Srcs_simp\<^sub>P\<^sub>W\<^sub>E \x.arr_resid \x.con_char assms(1-2) empty_set + list.set_intros(1) list.simps(15)) + thus "Red.Cong [a] [b]" + using U V Red.Cong_def [of "[a]" "[b]"] by blast + qed + + interpretation \q: quotient_by_coherent_normal \x.Resid \Collect \x.Arr\ + .. + + lemma quotient_by_cnv_is_discrete: + shows "\q.arr t \ \q.ide t" + by (metis Red.Cong_class_memb_is_arr \q.arr_char \q.ide_char' \x.arr_char + mem_Collect_eq subsetI) + + subsection "Normalization" + + text \ + A \emph{normal form} is an identity that is not the source of any non-identity arrow. + \ + + definition NF + where "NF a \ Ide a \ (\t. Arr t \ Src t = a \ Ide t)" + + lemma (in reduction_paths) path_from_NF_is_Ide: + assumes "\.NF a" + shows "\Arr U; Src U = a\ \ Ide U" + proof (induct U, simp) + fix u U + assume ind: "\Arr U; Src U = a\ \ Ide U" + assume uU: "Arr (u # U)" and a: "Src (u # U) = a" + have "\.Ide u" + using assms a \.NF_def uU by force + thus "Ide (u # U)" + using uU ind + apply (cases "U = []") + apply simp + by (metis Arr_consE Con_Arr_self Con_initial_right Ide.simps(2) Ide_consI + Resid_Arr_Ide_ind Src_resid Trg.simps(2) a \.ide_char) + qed + + lemma NF_reduct_is_trivial: + assumes "NF a" and "red a b" + shows "a = b" + proof - + interpret \x: reduction_paths . + have "\U. \\x.Arr U; a \ \x.Srcs U\ \ \x.Ide U" + using assms \x.path_from_NF_is_Ide + by (simp add: \x.Srcs_simp\<^sub>P\<^sub>W\<^sub>E) + thus ?thesis + using assms \x.red_iff + by (metis \x.Con_Arr_self \x.Resid_Arr_Ide_ind \x.Src_resid \x.path_from_NF_is_Ide) + qed + + lemma NF_unique: + assumes "red t u" and "red t u'" and "NF u" and "NF u'" + shows "u = u'" + using assms weak_diamond NF_reduct_is_trivial by metis + + text \ + A term is \emph{normalizable} if it is an identity that is reducible to a normal form. + \ + + definition normalizable + where "normalizable a \ Ide a \ (\b. red a b \ NF b)" + + end + + section "Reduction Paths" + + text \ + In this section we develop further facts about reduction paths for the \\\-calculus. + \ + + context reduction_paths + begin + + subsection "Sources and Targets" + + lemma Srcs_simp\<^sub>\\<^sub>P: + shows "Arr t \ Srcs t = {\.Src (hd t)}" + by (metis Arr_has_Src Srcs.elims list.sel(1) \.sources_char\<^sub>\) + + lemma Trgs_simp\<^sub>\\<^sub>P: + shows "Arr t \ Trgs t = {\.Trg (last t)}" + by (metis Arr.simps(1) Arr_has_Trg Trgs.simps(2) Trgs_append + append_butlast_last_id not_Cons_self2 \.targets_char\<^sub>\) + + lemma sources_single_Src [simp]: + assumes "\.Arr t" + shows "sources [\.Src t] = sources [t]" + using assms + by (metis \.Con_Arr_Src(1) \.Ide_Src Ide.simps(2) Resid.simps(3) con_char ideE + ide_char sources_resid \.con_char \.ide_char list.discI \.resid_Arr_Src) + + lemma targets_single_Trg [simp]: + assumes "\.Arr t" + shows "targets [\.Trg t] = targets [t]" + using assms + by (metis (full_types) Resid.simps(3) conI\<^sub>P \.Arr_Trg \.arr_char \.resid_Arr_Src + \.resid_Src_Arr \.arr_resid_iff_con targets_resid_sym) + + lemma sources_single_Trg [simp]: + assumes "\.Arr t" + shows "sources [\.Trg t] = targets [t]" + using assms + by (metis \.Ide_Trg Ide.simps(2) ideE ide_char sources_resid \.ide_char + targets_single_Trg) + + lemma targets_single_Src [simp]: + assumes "\.Arr t" + shows "targets [\.Src t] = sources [t]" + using assms + by (metis \.Arr_Src \.Trg_Src sources_single_Src sources_single_Trg) + + lemma single_Src_hd_in_sources: + assumes "Arr T" + shows "[\.Src (hd T)] \ sources T" + using assms + by (metis Arr.simps(1) Arr_has_Src Ide.simps(2) Resid_Arr_Src Srcs_simp\<^sub>P + \.source_is_ide conI\<^sub>P empty_set ide_char in_sourcesI \.sources_char\<^sub>\ + list.set_intros(1) list.simps(15)) + + lemma single_Trg_last_in_targets: + assumes "Arr T" + shows "[\.Trg (last T)] \ targets T" + using assms targets_char\<^sub>P Arr_imp_arr_last Trgs_simp\<^sub>\\<^sub>P \.Ide_Trg by fastforce + + lemma in_sources_iff: + assumes "Arr T" + shows "A \ sources T \ A \<^sup>*\\<^sup>* [\.Src (hd T)]" + using assms + by (meson single_Src_hd_in_sources sources_are_cong sources_cong_closed) + + lemma in_targets_iff: + assumes "Arr T" + shows "B \ targets T \ B \<^sup>*\\<^sup>* [\.Trg (last T)]" + using assms + by (meson single_Trg_last_in_targets targets_are_cong targets_cong_closed) + + lemma seq_imp_cong_Trg_last_Src_hd: + assumes "seq T U" + shows "\.Trg (last T) \ \.Src (hd U)" + using assms Arr_imp_arr_hd Arr_imp_arr_last Srcs_simp\<^sub>P\<^sub>W\<^sub>E Trgs_simp\<^sub>P\<^sub>W\<^sub>E + \.cong_reflexive seq_char + by (metis Srcs_simp\<^sub>\\<^sub>P Trgs_simp\<^sub>\\<^sub>P \.Arr_Trg \.arr_char singleton_inject) + + lemma sources_char\<^sub>\\<^sub>P: + shows "sources T = {A. Arr T \ A \<^sup>*\\<^sup>* [\.Src (hd T)]}" + using in_sources_iff arr_char sources_char\<^sub>P by auto + + lemma targets_char\<^sub>\\<^sub>P: + shows "targets T = {B. Arr T \ B \<^sup>*\\<^sup>* [\.Trg (last T)]}" + using in_targets_iff arr_char targets_char by auto + + lemma Src_hd_eqI: + assumes "cong T U" + shows "\.Src (hd T) = \.Src (hd U)" + using assms + by (metis Con_imp_eq_Srcs Con_implies_Arr(1) Ide.simps(1) Srcs_simp\<^sub>\\<^sub>P ide_char + singleton_insert_inj_eq') + + lemma Trg_last_eqI: + assumes "cong T U" + shows "\.Trg (last T) = \.Trg (last U)" + proof - + have 1: "[\.Trg (last T)] \ targets T \ [\.Trg (last U)] \ targets U" + using assms + by (metis Con_implies_Arr(1) Ide.simps(1) ide_char single_Trg_last_in_targets) + have "\.cong (\.Trg (last T)) (\.Trg (last U))" + by (metis "1" Ide.simps(2) Resid.simps(3) assms con_char cong_implies_coterminal + coterminal_iff ide_char prfx_implies_con targets_are_cong) + moreover have "\.Ide (\.Trg (last T)) \ \.Ide (\.Trg (last U))" + using "1" Ide.simps(2) ide_char by blast + ultimately show ?thesis + using \.weak_extensionality by blast + qed + + lemma Trg_last_Src_hd_eqI: + assumes "seq T U" + shows "\.Trg (last T) = \.Src (hd U)" + using assms Arr_imp_arr_hd Arr_imp_arr_last \.Ide_Src \.weak_extensionality \.Ide_Trg + seq_char seq_imp_cong_Trg_last_Src_hd + by force + + lemma seqI\<^sub>\\<^sub>P [intro]: + assumes "Arr T" and "Arr U" and "\.Trg (last T) = \.Src (hd U)" + shows "seq T U" + by (metis assms Arr_imp_arr_last Srcs_simp\<^sub>\\<^sub>P \.arr_char \.targets_char\<^sub>\ + Trgs_simp\<^sub>P seq_char) + + lemma conI\<^sub>\\<^sub>P [intro]: + assumes "arr T" and "arr U" and "\.Src (hd T) = \.Src (hd U)" + shows "T \<^sup>*\\<^sup>* U" + using assms + by (simp add: Srcs_simp\<^sub>\\<^sub>P arr_char con_char confluence_ind) + + subsection "Mapping Constructors over Paths" + + lemma Arr_map_Lam: + assumes "Arr T" + shows "Arr (map \.Lam T)" + proof - + interpret Lam: simulation \.resid \.resid \\t. if \.arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\\ + using \.Lam_is_simulation by simp + interpret simulation Resid Resid + \\T. if Arr T then map (\t. if \.arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\) T else []\ + using assms Lam.lifts_to_paths by blast + have "map (\t. if \.Arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\) T = map \.Lam T" + using assms set_Arr_subset_arr by fastforce + thus ?thesis + using assms preserves_reflects_arr [of T] arr_char + by (simp add: \map (\t. if \.Arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\) T = map \.Lam T\) + qed + + lemma Arr_map_App1: + assumes "\.Ide b" and "Arr T" + shows "Arr (map (\t. t \<^bold>\ b) T)" + proof - + interpret App1: simulation \.resid \.resid \\t. if \.arr t then t \<^bold>\ b else \<^bold>\\ + using assms \.App_is_simulation1 [of b] by simp + interpret simulation Resid Resid + \\T. if Arr T then map (\t. if \.arr t then t \<^bold>\ b else \<^bold>\) T else []\ + using assms App1.lifts_to_paths by blast + have "map (\t. if \.arr t then t \<^bold>\ b else \<^bold>\) T = map (\t. t \<^bold>\ b) T" + using assms set_Arr_subset_arr by auto + thus ?thesis + using assms preserves_reflects_arr arr_char + by (metis (mono_tags, lifting)) + qed + + lemma Arr_map_App2: + assumes "\.Ide a" and "Arr T" + shows "Arr (map (\.App a) T)" + proof - + interpret App2: simulation \.resid \.resid \\u. if \.arr u then a \<^bold>\ u else \<^bold>\\ + using assms \.App_is_simulation2 by simp + interpret simulation Resid Resid + \\T. if Arr T then map (\u. if \.arr u then a \<^bold>\ u else \<^bold>\) T else []\ + using assms App2.lifts_to_paths by blast + have "map (\u. if \.arr u then a \<^bold>\ u else \<^bold>\) T = map (\u. a \<^bold>\ u) T" + using assms set_Arr_subset_arr by auto + thus ?thesis + using assms preserves_reflects_arr arr_char + by (metis (mono_tags, lifting)) + qed + + interpretation \\<^sub>L\<^sub>a\<^sub>m: sub_rts \.resid \\t. \.Arr t \ \.is_Lam t\ + proof + show "\t. \.Arr t \ \.is_Lam t \ \.arr t" + by blast + show "\t. \.Arr t \ \.is_Lam t \ \.sources t \ {t. \.Arr t \ \.is_Lam t}" + by auto + show "\\.Arr t \ \.is_Lam t; \.Arr u \ \.is_Lam u; \.con t u\ + \ \.Arr (t \\ u) \ \.is_Lam (t \\ u)" + for t u + apply (cases t; cases u) + apply simp_all + using \.Coinitial_resid_resid + by presburger + qed + + interpretation un_Lam: simulation \\<^sub>L\<^sub>a\<^sub>m.resid \.resid + \\t. if \\<^sub>L\<^sub>a\<^sub>m.arr t then \.un_Lam t else \<^bold>\\ + proof + let ?un_Lam = "\t. if \\<^sub>L\<^sub>a\<^sub>m.arr t then \.un_Lam t else \<^bold>\" + show "\t. \ \\<^sub>L\<^sub>a\<^sub>m.arr t \ ?un_Lam t = \.null" + by auto + show "\t u. \\<^sub>L\<^sub>a\<^sub>m.con t u \ \.con (?un_Lam t) (?un_Lam u)" + by auto + show "\t u. \\<^sub>L\<^sub>a\<^sub>m.con t u \ ?un_Lam (\\<^sub>L\<^sub>a\<^sub>m.resid t u) = ?un_Lam t \\ ?un_Lam u" + using \\<^sub>L\<^sub>a\<^sub>m.resid_closed \\<^sub>L\<^sub>a\<^sub>m.resid_def by auto + qed + + lemma Arr_map_un_Lam: + assumes "Arr T" and "set T \ Collect \.is_Lam" + shows "Arr (map \.un_Lam T)" + proof - + have "map (\t. if \\<^sub>L\<^sub>a\<^sub>m.arr t then \.un_Lam t else \<^bold>\) T = map \.un_Lam T" + using assms set_Arr_subset_arr by auto + thus ?thesis + using assms + by (metis (no_types, lifting) \\<^sub>L\<^sub>a\<^sub>m.path_reflection \.arr_char mem_Collect_eq + set_Arr_subset_arr subset_code(1) un_Lam.preserves_paths) + qed + + interpretation \\<^sub>A\<^sub>p\<^sub>p: sub_rts \.resid \\t. \.Arr t \ \.is_App t\ + proof + show "\t. \.Arr t \ \.is_App t \ \.arr t" + by blast + show "\t. \.Arr t \ \.is_App t \ \.sources t \ {t. \.Arr t \ \.is_App t}" + by auto + show "\\.Arr t \ \.is_App t; \.Arr u \ \.is_App u; \.con t u\ + \ \.Arr (t \\ u) \ \.is_App (t \\ u)" + for t u + using \.Arr_resid_ind + by (cases t; cases u) auto + qed + + interpretation un_App1: simulation \\<^sub>A\<^sub>p\<^sub>p.resid \.resid + \\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App1 t else \<^bold>\\ + proof + let ?un_App1 = "\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App1 t else \<^bold>\" + show "\t. \ \\<^sub>A\<^sub>p\<^sub>p.arr t \ ?un_App1 t = \.null" + by auto + show "\t u. \\<^sub>A\<^sub>p\<^sub>p.con t u \ \.con (?un_App1 t) (?un_App1 u)" + by auto + show "\\<^sub>A\<^sub>p\<^sub>p.con t u \ ?un_App1 (\\<^sub>A\<^sub>p\<^sub>p.resid t u) = ?un_App1 t \\ ?un_App1 u" + for t u + using \\<^sub>A\<^sub>p\<^sub>p.resid_def \.Arr_resid_ind + by (cases t; cases u) auto + qed + + interpretation un_App2: simulation \\<^sub>A\<^sub>p\<^sub>p.resid \.resid + \\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App2 t else \<^bold>\\ + proof + let ?un_App2 = "\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App2 t else \<^bold>\" + show "\t. \ \\<^sub>A\<^sub>p\<^sub>p.arr t \ ?un_App2 t = \.null" + by auto + show "\t u. \\<^sub>A\<^sub>p\<^sub>p.con t u \ \.con (?un_App2 t) (?un_App2 u)" + by auto + show "\\<^sub>A\<^sub>p\<^sub>p.con t u \ ?un_App2 (\\<^sub>A\<^sub>p\<^sub>p.resid t u) = ?un_App2 t \\ ?un_App2 u" + for t u + using \\<^sub>A\<^sub>p\<^sub>p.resid_def \.Arr_resid_ind + by (cases t; cases u) auto + qed + + lemma Arr_map_un_App1: + assumes "Arr T" and "set T \ Collect \.is_App" + shows "Arr (map \.un_App1 T)" + proof - + interpret P\<^sub>A\<^sub>p\<^sub>p: paths_in_rts \\<^sub>A\<^sub>p\<^sub>p.resid + .. + interpret un_App1: simulation P\<^sub>A\<^sub>p\<^sub>p.Resid Resid + \\T. if P\<^sub>A\<^sub>p\<^sub>p.Arr T then + map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App1 t else \<^bold>\) T + else []\ + using un_App1.lifts_to_paths by simp + have 1: "map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App1 t else \<^bold>\) T = map \.un_App1 T" + using assms set_Arr_subset_arr by auto + have 2: "P\<^sub>A\<^sub>p\<^sub>p.Arr T" + using assms set_Arr_subset_arr \\<^sub>A\<^sub>p\<^sub>p.path_reflection [of T] by blast + hence "arr (if P\<^sub>A\<^sub>p\<^sub>p.Arr T then map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App1 t else \<^bold>\) T else [])" + using un_App1.preserves_reflects_arr [of T] by blast + hence "Arr (if P\<^sub>A\<^sub>p\<^sub>p.Arr T then map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App1 t else \<^bold>\) T else [])" + using arr_char by auto + hence "Arr (if P\<^sub>A\<^sub>p\<^sub>p.Arr T then map \.un_App1 T else [])" + using 1 by metis + thus ?thesis + using 2 by simp + qed + + lemma Arr_map_un_App2: + assumes "Arr T" and "set T \ Collect \.is_App" + shows "Arr (map \.un_App2 T)" + proof - + interpret P\<^sub>A\<^sub>p\<^sub>p: paths_in_rts \\<^sub>A\<^sub>p\<^sub>p.resid + .. + interpret un_App2: simulation P\<^sub>A\<^sub>p\<^sub>p.Resid Resid + \\T. if P\<^sub>A\<^sub>p\<^sub>p.Arr T then + map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App2 t else \<^bold>\) T + else []\ + using un_App2.lifts_to_paths by simp + have 1: "map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App2 t else \<^bold>\) T = map \.un_App2 T" + using assms set_Arr_subset_arr by auto + have 2: "P\<^sub>A\<^sub>p\<^sub>p.Arr T" + using assms set_Arr_subset_arr \\<^sub>A\<^sub>p\<^sub>p.path_reflection [of T] by blast + hence "arr (if P\<^sub>A\<^sub>p\<^sub>p.Arr T then map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App2 t else \<^bold>\) T else [])" + using un_App2.preserves_reflects_arr [of T] by blast + hence "Arr (if P\<^sub>A\<^sub>p\<^sub>p.Arr T then map (\t. if \\<^sub>A\<^sub>p\<^sub>p.arr t then \.un_App2 t else \<^bold>\) T else [])" + using arr_char by blast + hence "Arr (if P\<^sub>A\<^sub>p\<^sub>p.Arr T then map \.un_App2 T else [])" + using 1 by metis + thus ?thesis + using 2 by simp + qed + + lemma map_App_map_un_App1: + shows "\Arr U; set U \ Collect \.is_App; \.Ide b; \.un_App2 ` set U \ {b}\ \ + map (\t. \.App t b) (map \.un_App1 U) = U" + by (induct U) auto + + lemma map_App_map_un_App2: + shows "\Arr U; set U \ Collect \.is_App; \.Ide a; \.un_App1 ` set U \ {a}\ \ + map (\.App a) (map \.un_App2 U) = U" + by (induct U) auto + + lemma map_Lam_Resid: + assumes "coinitial T U" + shows "map \.Lam (T \<^sup>*\\\<^sup>* U) = map \.Lam T \<^sup>*\\\<^sup>* map \.Lam U" + proof - + interpret Lam: simulation \.resid \.resid \\t. if \.arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\\ + using \.Lam_is_simulation by simp + interpret Lamx: simulation Resid Resid + \\T. if Arr T then + map (\t. if \.arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\) T + else []\ + using Lam.lifts_to_paths by simp + have "\T. Arr T \ map (\t. if \.arr t then \<^bold>\\<^bold>[t\<^bold>] else \<^bold>\) T = map \.Lam T" + using set_Arr_subset_arr by auto + moreover have "Arr (T \<^sup>*\\\<^sup>* U)" + using assms confluence\<^sub>P Con_imp_Arr_Resid con_char by force + moreover have "T \<^sup>*\\<^sup>* U" + using assms confluence by simp + moreover have "Arr T \ Arr U" + using assms arr_char by auto + ultimately show ?thesis + using assms Lamx.preserves_resid [of T U] by presburger + qed + + lemma map_App1_Resid: + assumes "\.Ide x" and "coinitial T U" + shows "map (\.App x) (T \<^sup>*\\\<^sup>* U) = map (\.App x) T \<^sup>*\\\<^sup>* map (\.App x) U" + proof - + interpret App: simulation \.resid \.resid \\t. if \.arr t then x \<^bold>\ t else \<^bold>\\ + using assms \.App_is_simulation2 by simp + interpret Appx: simulation Resid Resid + \\T. if Arr T then map (\t. if \.arr t then x \<^bold>\ t else \<^bold>\) T else []\ + using App.lifts_to_paths by simp + have "\T. Arr T \ map (\t. if \.arr t then x \<^bold>\ t else \<^bold>\) T = map (\.App x) T" + using set_Arr_subset_arr by auto + moreover have "Arr (T \<^sup>*\\\<^sup>* U)" + using assms confluence\<^sub>P Con_imp_Arr_Resid con_char by force + moreover have "T \<^sup>*\\<^sup>* U" + using assms confluence by simp + moreover have "Arr T \ Arr U" + using assms arr_char by auto + ultimately show ?thesis + using assms Appx.preserves_resid [of T U] by presburger + qed + + lemma map_App2_Resid: + assumes "\.Ide x" and "coinitial T U" + shows "map (\t. t \<^bold>\ x) (T \<^sup>*\\\<^sup>* U) = map (\t. t \<^bold>\ x) T \<^sup>*\\\<^sup>* map (\t. t \<^bold>\ x) U" + proof - + interpret App: simulation \.resid \.resid \\t. if \.arr t then t \<^bold>\ x else \<^bold>\\ + using assms \.App_is_simulation1 by simp + interpret Appx: simulation Resid Resid + \\T. if Arr T then map (\t. if \.arr t then t \<^bold>\ x else \<^bold>\) T else []\ + using App.lifts_to_paths by simp + have "\T. Arr T \ map (\t. if \.arr t then t \<^bold>\ x else \<^bold>\) T = map (\t. t \<^bold>\ x) T" + using set_Arr_subset_arr by auto + moreover have "Arr (T \<^sup>*\\\<^sup>* U)" + using assms confluence\<^sub>P Con_imp_Arr_Resid con_char by force + moreover have "T \<^sup>*\\<^sup>* U" + using assms confluence by simp + moreover have "Arr T \ Arr U" + using assms arr_char by auto + ultimately show ?thesis + using assms Appx.preserves_resid [of T U] by presburger + qed + + lemma cong_map_Lam: + shows "\T. T \<^sup>*\\<^sup>* U \ map \.Lam T \<^sup>*\\<^sup>* map \.Lam U" + apply (induct U) + apply (simp add: ide_char) + by (metis map_Lam_Resid cong_implies_coinitial cong_reflexive ideE + map_is_Nil_conv Con_imp_Arr_Resid arr_char) + + lemma cong_map_App1: + shows "\x T. \\.Ide x; T \<^sup>*\\<^sup>* U\ \ map (\.App x) T \<^sup>*\\<^sup>* map (\.App x) U" + apply (induct U) + apply (simp add: ide_char) + apply (intro conjI) + by (metis Nil_is_map_conv arr_resid_iff_con con_char con_imp_coinitial + cong_reflexive ideE map_App1_Resid)+ + + lemma cong_map_App2: + shows "\x T. \\.Ide x; T \<^sup>*\\<^sup>* U\ \ map (\X. X \<^bold>\ x) T \<^sup>*\\<^sup>* map (\X. X \<^bold>\ x) U" + apply (induct U) + apply (simp add: ide_char) + apply (intro conjI) + by (metis Nil_is_map_conv arr_resid_iff_con con_char cong_implies_coinitial + cong_reflexive ide_def arr_char ideE map_App2_Resid)+ + + subsection "Decomposition of `App Paths'" + + text \ + The following series of results is aimed at showing that a reduction path, all of whose + transitions have \App\ as their top-level constructor, can be factored up to congruence + into a reduction path in which only the ``rator'' components are reduced, followed + by a reduction path in which only the ``rand'' components are reduced. + \ + + lemma orthogonal_App_single_single: + assumes "\.Arr t" and "\.Arr u" + shows "[\.Src t \<^bold>\ u] \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src u] = [\.Trg t \<^bold>\ u]" + and "[t \<^bold>\ \.Src u] \<^sup>*\\\<^sup>* [\.Src t \<^bold>\ u] = [t \<^bold>\ \.Trg u]" + using assms arr_char \.Arr_not_Nil by auto + + lemma orthogonal_App_single_Arr: + shows "\t. \Arr [t]; Arr U\ \ + map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd U)] = map (\.App (\.Trg t)) U \ + [t \<^bold>\ \.Src (hd U)] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) U = [t \<^bold>\ \.Trg (last U)]" + proof (induct U) + show "\t. \Arr [t]; Arr []\ \ + map (\.App (\.Src t)) [] \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd [])] = map (\.App (\.Trg t)) [] \ + [t \<^bold>\ \.Src (hd [])] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) [] = [t \<^bold>\ \.Trg (last [])]" + by fastforce + fix t u U + assume ind: "\t. \Arr [t]; Arr U\ \ + map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd U)] = + map (\.App (\.Trg t)) U \ + [t \<^bold>\ \.Src (hd U)] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) U = [t \<^bold>\ \.Trg (last U)]" + assume t: "Arr [t]" + assume uU: "Arr (u # U)" + show "map (\.App (\.Src t)) (u # U) \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd (u # U))] = + map (\.App (\.Trg t)) (u # U) \ + [t \<^bold>\ \.Src (hd (u # U))] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) (u # U) = + [t \<^bold>\ \.Trg (last (u # U))]" + proof (cases "U = []") + show "U = [] \ ?thesis" + using t uU orthogonal_App_single_single by simp + assume U: "U \ []" + have 2: "coinitial ([\.Src t \<^bold>\ u] @ map (\.App (\.Src t)) U) [t \<^bold>\ \.Src u]" + proof + show 3: "arr ([\.Src t \<^bold>\ u] @ map (\.App (\.Src t)) U)" + using t uU + by (metis Arr_iff_Con_self Arr_map_App2 Con_rec(1) append_Cons append_Nil arr_char + \.Con_implies_Arr2 \.Ide_Src \.con_char list.simps(9)) + show "sources ([\.Src t \<^bold>\ u] @ map (\.App (\.Src t)) U) = sources [t \<^bold>\ \.Src u]" + proof - + have "seq [\.Src t \<^bold>\ u] (map (\.App (\.Src t)) U)" + using U 3 arr_append_imp_seq by force + thus ?thesis + using sources_append [of "[\.Src t \<^bold>\ u]" "map (\.App (\.Src t)) U"] + sources_single_Src [of "\.Src t \<^bold>\ u"] + sources_single_Src [of "t \<^bold>\ \.Src u"] + using arr_char t + by (simp add: seq_char) + qed + qed + show ?thesis + proof + show 4: "map (\.App (\.Src t)) (u # U) \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd (u # U))] = + map (\.App (\.Trg t)) (u # U)" + proof - + have "map (\.App (\.Src t)) (u # U) \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd (u # U))] = + ([\.Src t \<^bold>\ u] @ map (\.App (\.Src t)) U) \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src u]" + by simp + also have "... = [\.Src t \<^bold>\ u] \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src u] @ + map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* ([t \<^bold>\ \.Src u] \<^sup>*\\\<^sup>* [\.Src t \<^bold>\ u])" + by (meson "2" Resid_append(1) con_char confluence not_Cons_self2) + also have "... = [\.Trg t \<^bold>\ u] @ map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* [t \<^bold>\ \.Trg u]" + using t \.Arr_not_Nil + by (metis Arr_imp_arr_hd \.arr_char list.sel(1) orthogonal_App_single_single(1) + orthogonal_App_single_single(2) uU) + also have "... = [\.Trg t \<^bold>\ u] @ map (\.App (\.Trg t)) U" + proof - + have "\.Src (hd U) = \.Trg u" + using U uU Arr.elims(2) Srcs_simp\<^sub>\\<^sub>P by force + thus ?thesis + using t uU ind Arr.elims(2) by fastforce + qed + also have "... = map (\.App (\.Trg t)) (u # U)" + by auto + finally show ?thesis by blast + qed + show "[t \<^bold>\ \.Src (hd (u # U))] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) (u # U) = + [t \<^bold>\ \.Trg (last (u # U))]" + proof - + have "[t \<^bold>\ \.Src (hd (u # U))] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) (u # U) = + ([t \<^bold>\ \.Src (hd (u # U))] \<^sup>*\\\<^sup>* [\.Src t \<^bold>\ u]) \<^sup>*\\\<^sup>* map (\.App (\.Src t)) U" + by (metis U 4 Con_sym Resid_cons(2) list.distinct(1) list.simps(9) map_is_Nil_conv) + also have "... = [t \<^bold>\ \.Trg u] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) U" + by (metis Arr_imp_arr_hd lambda_calculus.arr_char list.sel(1) + orthogonal_App_single_single(2) t uU) + also have "... = [t \<^bold>\ \.Trg (last (u # U))]" + by (metis 2 t U uU Con_Arr_self Con_cons(1) Con_implies_Arr(1) Trg_last_Src_hd_eqI + arr_append_imp_seq coinitialE ind \.Src.simps(4) \.Trg.simps(3) + \.lambda.inject(3) last.simps list.distinct(1) list.map_sel(1) map_is_Nil_conv) + finally show ?thesis by blast + qed + qed + qed + qed + + lemma orthogonal_App_Arr_Arr: + shows "\U. \Arr T; Arr U\ \ + map (\.App (\.Src (hd T))) U \<^sup>*\\\<^sup>* map (\X. \.App X (\.Src (hd U))) T = + map (\.App (\.Trg (last T))) U \ + map (\X. X \<^bold>\ \.Src (hd U)) T \<^sup>*\\\<^sup>* map (\.App (\.Src (hd T))) U = + map (\X. X \<^bold>\ \.Trg (last U)) T" + proof (induct T) + show "\U. \Arr []; Arr U\ + \ map (\.App (\.Src (hd []))) U \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Src (hd U)) [] = + map (\.App (\.Trg (last []))) U \ + map (\X. X \<^bold>\ \.Src (hd U)) [] \<^sup>*\\\<^sup>* map (\.App (\.Src (hd []))) U = + map (\X. X \<^bold>\ \.Trg (last U)) []" + by simp + fix t T U + assume ind: "\U. \Arr T; Arr U\ + \ map (\.App (\.Src (hd T))) U \<^sup>*\\\<^sup>* + map (\X. \.App X (\.Src (hd U))) T = + map (\.App (\.Trg (last T))) U \ + map (\X. X \<^bold>\ \.Src (hd U)) T \<^sup>*\\\<^sup>* map (\.App (\.Src (hd T))) U = + map (\X. X \<^bold>\ \.Trg (last U)) T" + assume tT: "Arr (t # T)" + assume U: "Arr U" + show "map (\.App (\.Src (hd (t # T)))) U \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Src (hd U)) (t # T) = + map (\.App (\.Trg (last (t # T)))) U \ + map (\X. X \<^bold>\ \.Src (hd U)) (t # T) \<^sup>*\\\<^sup>* map (\.App (\.Src (hd (t # T)))) U = + map (\X. X \<^bold>\ \.Trg (last U)) (t # T)" + proof (cases "T = []") + show "T = [] \ ?thesis" + using tT U + by (simp add: orthogonal_App_single_Arr) + assume T: "T \ []" + have 1: "Arr T" + using T tT Arr_imp_Arr_tl by fastforce + have 2: "\.Src (hd T) = \.Trg t" + using tT T Arr.elims(2) Srcs_simp\<^sub>\\<^sub>P by force + show ?thesis + proof + show 3: "map (\.App (\.Src (hd (t # T)))) U \<^sup>*\\\<^sup>* + map (\X. X \<^bold>\ \.Src (hd U)) (t # T) = + map (\.App (\.Trg (last (t # T)))) U" + proof - + have "map (\.App (\.Src (hd (t # T)))) U \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Src (hd U)) (t # T) = + map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* + ([\.App t (\.Src (hd U))] @ map (\X. X \<^bold>\ \.Src (hd U)) T)" + using tT U by simp + also have "... = (map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd U)]) \<^sup>*\\\<^sup>* + map (\X. X \<^bold>\ \.Src (hd U)) T" + using tT U Resid_append(2) + by (metis Con_appendI(2) Resid.simps(1) T map_is_Nil_conv not_Cons_self2) + also have "... = map (\.App (\.Trg t)) U \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Src (hd U)) T" + using tT U orthogonal_App_single_Arr Arr_imp_arr_hd by fastforce + also have "... = map (\.App (\.Trg (last (t # T)))) U" + using tT U 1 2 ind by auto + finally show ?thesis by blast + qed + show "map (\X. X \<^bold>\ \.Src (hd U)) (t # T) \<^sup>*\\\<^sup>* + map (\.App (\.Src (hd (t # T)))) U = + map (\X. X \<^bold>\ \.Trg (last U)) (t # T)" + proof - + have "map (\X. X \<^bold>\ \.Src (hd U)) (t # T) \<^sup>*\\\<^sup>* + map (\.App (\.Src (hd (t # T)))) U = + ([t \<^bold>\ \.Src (hd U)] @ map (\X. X \<^bold>\ \.Src (hd U)) T) \<^sup>*\\\<^sup>* + map (\.App (\.Src t)) U" + using tT U by simp + also have "... = ([t \<^bold>\ \.Src (hd U)] \<^sup>*\\\<^sup>* map (\.App (\.Src t)) U) @ + (map (\X. X \<^bold>\ \.Src (hd U)) T \<^sup>*\\\<^sup>* + (map (\.App (\.Src t)) U \<^sup>*\\\<^sup>* [t \<^bold>\ \.Src (hd U)]))" + using tT U 3 Con_sym + Resid_append(1) + [of "[t \<^bold>\ \.Src (hd U)]" "map (\X. X \<^bold>\ \.Src (hd U)) T" + "map (\.App (\.Src t)) U"] + by fastforce + also have "... = [t \<^bold>\ \.Trg (last U)] @ + map (\X. X \<^bold>\ \.Src (hd U)) T \<^sup>*\\\<^sup>* map (\.App (\.Trg t)) U" + using tT U Arr_imp_arr_hd orthogonal_App_single_Arr by fastforce + also have "... = [t \<^bold>\ \.Trg (last U)] @ map (\X. X \<^bold>\ \.Trg (last U)) T" + using tT U "1" "2" ind by presburger + also have "... = map (\X. X \<^bold>\ \.Trg (last U)) (t # T)" + by simp + finally show ?thesis by blast + qed + qed + qed + qed + + lemma orthogonal_App_cong: + assumes "Arr T" and "Arr U" + shows "map (\X. X \<^bold>\ \.Src (hd U)) T @ map (\.App (\.Trg (last T))) U \<^sup>*\\<^sup>* + map (\.App (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T" + (* + using assms orthogonal_App_Arr_Arr [of T U] + by (smt (verit, best) Con_Arr_self Con_imp_Arr_Resid Con_implies_Arr(1) Con_sym + Nil_is_append_conv Resid_append_ind arr_char cube map_is_Nil_conv prfx_reflexive) + *) + proof + have 1: "Arr (map (\X. X \<^bold>\ \.Src (hd U)) T)" + using assms Arr_imp_arr_hd Arr_map_App1 \.Ide_Src by force + have 2: "Arr (map (\.App (\.Trg (last T))) U)" + using assms Arr_imp_arr_last Arr_map_App2 \.Ide_Trg by force + have 3: "Arr (map (\.App (\.Src (hd T))) U)" + using assms Arr_imp_arr_hd Arr_map_App2 \.Ide_Src by force + have 4: "Arr (map (\X. X \<^bold>\ \.Trg (last U)) T)" + using assms Arr_imp_arr_last Arr_map_App1 \.Ide_Trg by force + have 5: "Arr (map (\X. X \<^bold>\ \.Src (hd U)) T @ map (\.App (\.Trg (last T))) U)" + using assms + by (metis (no_types, lifting) 1 2 Arr.simps(2) Arr_has_Src Arr_imp_arr_last + Srcs.simps(1) Srcs_Resid_Arr_single Trgs_simp\<^sub>P arr_append arr_char last_map + orthogonal_App_single_Arr seq_char) + have 6: "Arr (map (\.App (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T)" + using assms + by (metis (no_types, lifting) 3 4 Arr.simps(2) Arr_has_Src Arr_imp_arr_hd + Srcs.simps(1) Srcs.simps(2) Srcs_Resid Srcs_simp\<^sub>P arr_append arr_char hd_map + orthogonal_App_single_Arr seq_char) + have 7: "Con (map (\X. X \<^bold>\ \.Src (hd U)) T @ map ((\<^bold>\) (\.Trg (last T))) U) + (map ((\<^bold>\) (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T)" + using assms orthogonal_App_Arr_Arr [of T U] + by (metis 1 2 5 6 Con_imp_eq_Srcs Resid.simps(1) Srcs_append confluence_ind) + have 8: "Con (map ((\<^bold>\) (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T) + (map (\X. X \<^bold>\ \.Src (hd U)) T @ map ((\<^bold>\) (\.Trg (last T))) U)" + using 7 Con_sym by simp + show "map (\X. X \<^bold>\ \.Src (hd U)) T @ map ((\<^bold>\) (\.Trg (last T))) U \<^sup>*\\<^sup>* + map ((\<^bold>\) (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T" + proof - + have "(map (\X. X \<^bold>\ \.Src (hd U)) T @ map ((\<^bold>\) (\.Trg (last T))) U) \<^sup>*\\\<^sup>* + (map ((\<^bold>\) (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T) = + map (\X. X \<^bold>\ \.Trg (last U)) T \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Trg (last U)) T @ + (map ((\<^bold>\) (\.Trg (last T))) U \<^sup>*\\\<^sup>* map ((\<^bold>\) (\.Trg (last T))) U) \<^sup>*\\\<^sup>* + (map (\X. X \<^bold>\ \.Trg (last U)) T \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Trg (last U)) T)" + using assms 7 orthogonal_App_Arr_Arr + Resid_append2 + [of "map (\X. X \<^bold>\ \.Src (hd U)) T" "map (\.App (\.Trg (last T))) U" + "map (\.App (\.Src (hd T))) U" "map (\X. X \<^bold>\ \.Trg (last U)) T"] + by fastforce + moreover have "Ide ..." + using assms 1 2 3 4 5 6 7 Resid_Arr_self + by (metis Arr_append_iff\<^sub>P Con_Arr_self Con_imp_Arr_Resid Ide_appendI\<^sub>P + Resid_Ide_Arr_ind append_Nil2 calculation) + ultimately show ?thesis + using ide_char by presburger + qed + show "map ((\<^bold>\) (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ \.Src (hd U)) T @ map ((\<^bold>\) (\.Trg (last T))) U" + proof - + have "map ((\<^bold>\) (\.Src (hd T))) U \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Src (hd U)) T = + map ((\<^bold>\) (\.Trg (last T))) U" + by (simp add: assms orthogonal_App_Arr_Arr) + have "(map ((\<^bold>\) (\.Src (hd T))) U @ map (\X. X \<^bold>\ \.Trg (last U)) T) \<^sup>*\\\<^sup>* + (map (\X. X \<^bold>\ \.Src (hd U)) T @ map ((\<^bold>\) (\.Trg (last T))) U) = + (map ((\<^bold>\) (\.Trg (last T))) U) \<^sup>*\\\<^sup>* map ((\<^bold>\) (\.Trg (last T))) U @ + (map (\X. X \<^bold>\ \.Trg (last U)) T \<^sup>*\\\<^sup>* map (\X. X \<^bold>\ \.Trg (last U)) T) \<^sup>*\\\<^sup>* + (map ((\<^bold>\) (\.Trg (last T))) U \<^sup>*\\\<^sup>* map ((\<^bold>\) (\.Trg (last T))) U)" + using assms 8 orthogonal_App_Arr_Arr [of T U] + Resid_append2 + [of "map (\.App (\.Src (hd T))) U" "map (\X. X \<^bold>\ \.Trg (last U)) T" + "map (\X. X \<^bold>\ \.Src (hd U)) T" "map (\.App (\.Trg (last T))) U"] + by fastforce + moreover have "Ide ..." + using assms 1 2 3 4 5 6 8 Resid_Arr_self Arr_append_iff\<^sub>P Con_sym + by (metis Con_Arr_self Con_imp_Arr_Resid Ide_appendI\<^sub>P Resid_Ide_Arr_ind + append_Nil2 calculation) + ultimately show ?thesis + using ide_char by presburger + qed + qed + + text \ + We arrive at the final objective of this section: factorization, up to congruence, + of a path whose transitions all have \App\ as the top-level constructor, + into the composite of a path that reduces only the ``rators'' and a path + that reduces only the ``rands''. + \ + + lemma map_App_decomp: + shows "\Arr U; set U \ Collect \.is_App\ \ + map (\X. X \<^bold>\ \.Src (\.un_App2 (hd U))) (map \.un_App1 U) @ + map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U) \<^sup>*\\<^sup>* + U" + proof (induct U) + show "Arr [] \ map (\X. X \<^bold>\ \.Src (\.un_App2 (hd []))) (map \.un_App1 []) @ + map (\.App (\.Trg (\.un_App1 (last [])))) (map \.un_App2 []) \<^sup>*\\<^sup>* + []" + by simp + fix u U + assume ind: "\Arr U; set U \ Collect \.is_App\ \ + map (\X. \.App X (\.Src (\.un_App2 (hd U)))) (map \.un_App1 U) @ + map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U) \<^sup>*\\<^sup>* + U" + assume uU: "Arr (u # U)" + assume set: "set (u # U) \ Collect \.is_App" + have u: "\.Arr u \ \.is_App u" + using set set_Arr_subset_arr uU by fastforce + show "map (\X. X \<^bold>\ \.Src (\.un_App2 (hd (u # U)))) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + u # U" + proof (cases "U = []") + assume U: "U = []" + show ?thesis + using u U \.Con_sym \.Ide_iff_Src_self \.resid_Arr_self \.resid_Src_Arr + \.resid_Arr_Src \.Src_resid \.Arr_resid ide_char \.Arr_not_Nil + by (cases u, simp_all) + next + assume U: "U \ []" + have 1: "Arr (map \.un_App1 U)" + using U set Arr_map_un_App1 uU + by (metis Arr_imp_Arr_tl list.distinct(1) list.map_disc_iff list.map_sel(2) list.sel(3)) + have 2: "Arr [\.un_App2 u]" + using U uU set + by (metis Arr.simps(2) Arr_imp_arr_hd Arr_map_un_App2 hd_map list.discI list.sel(1)) + have 3: "\.Arr (\.un_App1 u) \ \.Arr (\.un_App2 u)" + using uU set + by (metis Arr_imp_arr_hd Arr_map_un_App1 Arr_map_un_App2 \.arr_char + list.distinct(1) list.map_sel(1) list.sel(1)) + have 4: "map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u] \<^sup>*\\<^sup>* + [\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u] @ + map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U)" + proof - + have "map (\X. X \<^bold>\ \.Src (hd [\.un_App2 u])) (map \.un_App1 U) = + map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U)" + using U uU set by simp + moreover have "map (\.App (\.Trg (last (map \.un_App1 U)))) [\.un_App2 u] = + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]" + by (simp add: U last_map) + moreover have "map (\.App (\.Src (hd (map \.un_App1 U)))) [\.un_App2 u] = + [\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u]" + by simp + moreover have "map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U) = + map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U)" + using U uU set by blast + ultimately show ?thesis + using U uU set last_map hd_map 1 2 3 + orthogonal_App_cong [of "map \.un_App1 U" "[\.un_App2 u]"] + by presburger + qed + have 5: "\.Arr (\.un_App1 u \<^bold>\ \.Src (\.un_App2 u))" + by (simp add: 3) + have 6: "Arr (map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U))" + by (metis 1 Arr_imp_arr_last Arr_map_App2 Arr_map_un_App2 Con_implies_Arr(2) + Ide.simps(1) Resid_Arr_self Resid_cons(2) U insert_subset + \.Ide_Trg \.arr_char last_map list.simps(15) set uU) + have 7: "\.Arr (\.Trg (\.un_App1 (last U)))" + by (metis 4 Arr.simps(2) Arr_append_iff\<^sub>P Con_implies_Arr(2) Ide.simps(1) + U ide_char \.Arr.simps(4) \.arr_char list.map_disc_iff not_Cons_self2) + have 8: "\.Src (hd (map \.un_App1 U)) = \.Trg (\.un_App1 u)" + proof - + have "\.Src (hd U) = \.Trg u" + using u uU U by fastforce + thus ?thesis + using u uU U set + apply (cases u; cases "hd U") + apply (simp_all add: list.map_sel(1)) + using list.set_sel(1) + by fastforce + qed + have 9: "\.Src (\.un_App2 (hd U)) = \.Trg (\.un_App2 u)" + proof - + have "\.Src (hd U) = \.Trg u" + using u uU U by fastforce + thus ?thesis + using u uU U set + apply (cases u; cases "hd U") + apply simp_all + by (metis lambda_calculus.lambda.disc(15) list.set_sel(1) mem_Collect_eq + subset_code(1)) + qed + have "map (\X. X \<^bold>\ \.Src (\.un_App2 (hd (u # U)))) (map \.un_App1 (u # U)) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last (u # U))))) (map \.un_App2 (u # U)) = + [\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + (map (\X. X \<^bold>\ \.Src (\.un_App2 u)) + (map \.un_App1 U) @ [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last U)))) (map \.un_App2 U)" + using uU U by simp + also have 12: "cong ... ([\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + ([\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u] @ + map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U)) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last U)))) (map \.un_App2 U))" + proof (intro cong_append [of "[\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)]"] + cong_append [where U = "map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) + (map \.un_App2 U)"]) + show "[\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] \<^sup>*\\<^sup>* [\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)]" + using 5 arr_char cong_reflexive Arr.simps(2) \.arr_char by presburger + show "map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U) \<^sup>*\\<^sup>* + map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U)" + using 6 cong_reflexive by auto + show "map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u] \<^sup>*\\<^sup>* + [\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u] @ + map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U)" + using 4 by simp + show 10: "seq [\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] + ((map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]) @ + map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U))" + proof + show "Arr [\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)]" + using 5 Arr.simps(2) by blast + show "Arr ((map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]) @ + map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U))" + proof (intro Arr_appendI\<^sub>P\<^sub>W\<^sub>E) + show "Arr (map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U))" + using 1 3 Arr_map_App1 lambda_calculus.Ide_Src by blast + show "Arr [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]" + by (simp add: 3 7) + show "Trg (map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U)) = + Src [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]" + by (metis 4 Arr_appendE\<^sub>P\<^sub>W\<^sub>E Con_implies_Arr(2) Ide.simps(1) U ide_char + list.map_disc_iff not_Cons_self2) + show "Arr (map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U))" + using 6 by simp + show "Trg (map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]) = + Src (map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U))" + using U uU set 1 3 6 7 9 Srcs_simp\<^sub>P\<^sub>W\<^sub>E Arr_imp_arr_hd Arr_imp_arr_last + apply auto + by (metis Nil_is_map_conv hd_map \.Src.simps(4) \.Src_Trg \.Trg_Trg + last_map list.map_comp) + qed + show "\.Trg (last [\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)]) = + \.Src (hd ((map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]) @ + map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U)))" + using 8 9 + by (simp add: 3 U hd_map) + qed + show "seq (map (\X. X \<^bold>\ \.Src (\.un_App2 u)) (map \.un_App1 U) @ + [\.Trg (\.un_App1 (last U)) \<^bold>\ \.un_App2 u]) + (map (\X. \.Trg (\.un_App1 (last U)) \<^bold>\ X) (map \.un_App2 U))" + by (metis Nil_is_map_conv U 10 append_is_Nil_conv arr_append_imp_seq seqE) + qed + also have 11: "[\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + ([\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u] @ + map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U)) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last U)))) (map \.un_App2 U) = + ([\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + [\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u]) @ + map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last U)))) (map \.un_App2 U)" + by simp + also have "cong ... ([u] @ U)" + proof (intro cong_append) + show "seq ([\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + [\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u]) + (map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last U)))) (map \.un_App2 U))" + by (metis 5 11 12 U Arr.simps(1-2) Con_implies_Arr(2) Ide.simps(1) Nil_is_map_conv + append_is_Nil_conv arr_append_imp_seq arr_char ide_char \.arr_char) + show "[\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + [\.Src (hd (map \.un_App1 U)) \<^bold>\ \.un_App2 u] \<^sup>*\\<^sup>* + [u]" + proof - + have "[\.un_App1 u \<^bold>\ \.Src (\.un_App2 u)] @ + [\.Trg (\.un_App1 u) \<^bold>\ \.un_App2 u] \<^sup>*\\<^sup>* + [u]" + using u uU U \.Arr_Trg \.Arr_not_Nil \.resid_Arr_self + apply (cases u) + apply auto + by force+ + thus ?thesis using 8 by simp + qed + show "map (\X. X \<^bold>\ \.Trg (last [\.un_App2 u])) (map \.un_App1 U) @ + map ((\<^bold>\) (\.Trg (\.un_App1 (last U)))) (map \.un_App2 U) \<^sup>*\\<^sup>* + U" + using ind set 9 + apply simp + using U uU by blast + qed + also have "[u] @ U = u # U" + by simp + finally show ?thesis by blast + qed + qed + + subsection "Miscellaneous" + + lemma Resid_parallel: + assumes "cong t t'" and "coinitial t u" + shows "u \<^sup>*\\\<^sup>* t = u \<^sup>*\\\<^sup>* t'" + proof - + have "u \<^sup>*\\\<^sup>* t = (u \<^sup>*\\\<^sup>* t) \<^sup>*\\\<^sup>* (t' \<^sup>*\\\<^sup>* t)" + using assms + by (metis con_target conI\<^sub>P con_sym resid_arr_ide) + also have "... = (u \<^sup>*\\\<^sup>* t') \<^sup>*\\\<^sup>* (t \<^sup>*\\\<^sup>* t')" + using cube by auto + also have "... = u \<^sup>*\\\<^sup>* t'" + using assms + by (metis con_target conI\<^sub>P con_sym resid_arr_ide) + finally show ?thesis by blast + qed + + lemma set_Ide_subset_single_hd: + shows "Ide T \ set T \ {hd T}" + apply (induct T, auto) + using \.coinitial_ide_are_cong + by (metis Arr_imp_arr_hd Ide_consE Ide_imp_Ide_hd Ide_implies_Arr Srcs_simp\<^sub>P\<^sub>W\<^sub>E Srcs_simp\<^sub>\\<^sub>P + \.trg_ide equals0D \.Ide_iff_Src_self \.arr_char \.ide_char set_empty singletonD + subset_code(1)) + + text \ + A single parallel reduction with \Beta\ as the top-level operator factors, + up to congruence, either as a path in which the top-level redex is + contracted first, or as a path in which the top-level redex is contracted last. + \ + + lemma Beta_decomp: + assumes "\.Arr t" and "\.Arr u" + shows "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + and "[\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] @ [\<^bold>\\<^bold>[\.Trg t\<^bold>] \<^bold>\ \.Trg u] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + using assms \.Arr_not_Nil \.Subst_not_Nil ide_char \.Ide_Subst \.Ide_Trg + \.Arr_Subst \.resid_Arr_self + by auto + + text \ + If a reduction path follows an initial reduction whose top-level constructor is \Lam\, + then all the terms in the path have \Lam\ as their top-level constructor. + \ + + lemma seq_Lam_Arr_implies: + shows "\t. \seq [t] U; \.is_Lam t\ \ set U \ Collect \.is_Lam" + proof (induct U) + show "\t. \seq [t] []; \.is_Lam t\ \ set [] \ Collect \.is_Lam" + by simp + fix u U t + assume ind: "\t. \seq [t] U; \.is_Lam t\ \ set U \ Collect \.is_Lam" + assume uU: "seq [t] (u # U)" + assume t: "\.is_Lam t" + show "set (u # U) \ Collect \.is_Lam" + proof - + have "\.is_Lam u" + proof - + have "\.seq t u" + by (metis Arr_imp_arr_hd Trg_last_Src_hd_eqI \.arr_char \.seq_char last_ConsL + list.sel(1) seq_char uU) + thus ?thesis + using \.seq_cases t by blast + qed + moreover have "set U \ Collect \.is_Lam" + proof (cases "U = []") + show "U = [] \ ?thesis" + by simp + assume U: "U \ []" + have "seq [u] U" + by (metis U append_Cons arr_append_imp_seq not_Cons_self2 self_append_conv2 + seqE uU) + thus ?thesis + using ind calculation by simp + qed + ultimately show ?thesis by auto + qed + qed + + lemma seq_map_un_Lam: + assumes "seq [\<^bold>\\<^bold>[t\<^bold>]] U" + shows "seq [t] (map \.un_Lam U)" + proof - + have "Arr (\<^bold>\\<^bold>[t\<^bold>] # U)" + using assms + by (simp add: seq_char) + hence "Arr (map \.un_Lam (\<^bold>\\<^bold>[t\<^bold>] # U)) \ Arr U" + using seq_Lam_Arr_implies + by (metis Arr_map_un_Lam \seq [\<^bold>\\<^bold>[t\<^bold>]] U\ \.lambda.discI(2) mem_Collect_eq + seq_char set_ConsD subset_code(1)) + hence "Arr (\.un_Lam \<^bold>\\<^bold>[t\<^bold>] # map \.un_Lam U) \ Arr U" + by simp + thus ?thesis + using seq_char + by (metis (no_types, lifting) Arr.simps(1) Con_imp_eq_Srcs Con_implies_Arr(2) + Con_initial_right Resid_rec(1) Resid_rec(3) Srcs_Resid \.lambda.sel(2) + map_is_Nil_conv confluence_ind) + qed + + end + + section "Developments" + + text \ + A \emph{development} is a reduction path from a term in which at each step exactly one + redex is contracted, and the only redexes that are contracted are those that are residuals + of redexes present in the original term. That is, no redexes are contracted that were + newly created as a result of the previous reductions. The main theorem about developments + is the Finite Developments Theorem, which states that all developments are finite. + A proof of this theorem was published by Hindley \cite{hindley}, who attributes the + result to Schroer \cite{schroer}. Other proofs were published subsequently. + Here we follow the paper by de Vrijer \cite{deVrijer}, which may in some sense be considered + the definitive work because de Vrijer's proof gives an exact bound on the number of steps + in a development. Since de Vrijer used a classical, named-variable representation of + \\\-terms, for the formalization given in the present article it was necessary to find the + correct way to adapt de Vrijer's proof to the de Bruijn index representation of terms. + I found this to be a somewhat delicate matter and to my knowledge it has not been done + previously. + \ + + context lambda_calculus + begin + + text \ + We define an \emph{elementary reduction} defined to be a term with exactly one marked redex. + These correspond to the most basic computational steps. + \ + + fun elementary_reduction + where "elementary_reduction \<^bold>\ \ False" + | "elementary_reduction (\<^bold>\_\<^bold>\) \ False" + | "elementary_reduction \<^bold>\\<^bold>[t\<^bold>] \ elementary_reduction t" + | "elementary_reduction (t \<^bold>\ u) \ + (elementary_reduction t \ Ide u) \ (Ide t \ elementary_reduction u)" + | "elementary_reduction (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ Ide t \ Ide u" + + text \ + It is tempting to imagine that elementary reductions would be atoms with respect to the + preorder \\\, but this is not necessarily the case. + For example, suppose \t = \<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\0\<^bold>\)\ and \u = \<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\0\<^bold>\)\. + Then \t\ is an elementary reduction, \u \ t\ (in fact \u \ t\) but \u\ is not an identity, + nor is it elementary. + \ + + lemma elementary_reduction_is_arr: + shows "elementary_reduction t \ arr t" + using Ide_implies_Arr arr_char + by (induct t) auto + + lemma elementary_reduction_not_ide: + shows "elementary_reduction t \ \ ide t" + using ide_char + by (induct t) auto + + lemma elementary_reduction_Raise_iff: + shows "\d n. elementary_reduction (Raise d n t) \ elementary_reduction t" + using Ide_Raise + by (induct t) auto + + lemma elementary_reduction_Lam_iff: + shows "is_Lam t \ elementary_reduction t \ elementary_reduction (un_Lam t)" + by (metis elementary_reduction.simps(3) lambda.collapse(2)) + + lemma elementary_reduction_App_iff: + shows "is_App t \ elementary_reduction t \ + (elementary_reduction (un_App1 t) \ ide (un_App2 t)) \ + (ide (un_App1 t) \ elementary_reduction (un_App2 t))" + using ide_char + by (metis elementary_reduction.simps(4) lambda.collapse(3)) + + lemma elementary_reduction_Beta_iff: + shows "is_Beta t \ elementary_reduction t \ ide (un_Beta1 t) \ ide (un_Beta2 t)" + using ide_char + by (metis elementary_reduction.simps(5) lambda.collapse(4)) + + lemma cong_elementary_reductions_are_equal: + shows "\u. \elementary_reduction t; elementary_reduction u; t \ u\ \ t = u" + proof (induct t) + show "\u. \elementary_reduction \<^bold>\; elementary_reduction u; \<^bold>\ \ u\ \ \<^bold>\ = u" + by simp + show "\x u. \elementary_reduction \<^bold>\x\<^bold>\; elementary_reduction u; \<^bold>\x\<^bold>\ \ u\ \ \<^bold>\x\<^bold>\ = u" + by simp + show "\t u. \\u. \elementary_reduction t; elementary_reduction u; t \ u\ \ t = u; + elementary_reduction \<^bold>\\<^bold>[t\<^bold>]; elementary_reduction u; \<^bold>\\<^bold>[t\<^bold>] \ u\ + \ \<^bold>\\<^bold>[t\<^bold>] = u" + by (metis elementary_reduction_Lam_iff lambda.collapse(2) lambda.inject(2) prfx_Lam_iff) + show "\t1 t2. \\u. \elementary_reduction t1; elementary_reduction u; t1 \ u\ \ t1 = u; + \u. \elementary_reduction t2; elementary_reduction u; t2 \ u\ \ t2 = u; + elementary_reduction (t1 \<^bold>\ t2); elementary_reduction u; t1 \<^bold>\ t2 \ u\ + \ t1 \<^bold>\ t2 = u" + for u + using prfx_App_iff + apply (cases u) + apply auto[3] + apply (metis elementary_reduction_App_iff ide_backward_stable lambda.sel(3-4) + weak_extensionality) + by auto + show "\t1 t2. \\u. \elementary_reduction t1; elementary_reduction u; t1 \ u\ \ t1 = u; + \u. \elementary_reduction t2; elementary_reduction u; t2 \ u\ \ t2 = u; + elementary_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2); elementary_reduction u; \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u\ + \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 = u" + for u + using prfx_App_iff + apply (cases u, simp_all) + by (metis (full_types) Coinitial_iff_Con Ide_iff_Src_self Ide.simps(1)) + qed + + text \ + An \emph{elementary reduction path} is a path in which each step is an elementary reduction. + It will be convenient to regard the empty list as an elementary reduction path, even though + it is not actually a path according to our previous definition of that notion. + \ + + definition (in reduction_paths) elementary_reduction_path + where "elementary_reduction_path T \ + (T = [] \ Arr T \ set T \ Collect \.elementary_reduction)" + + text \ + In the formal definition of ``development'' given below, we represent a set of + redexes simply by a term, in which the occurrences of \Beta\ correspond to the redexes + in the set. To express the idea that an elementary reduction \u\ is a member of + the set of redexes represented by term \t\, it is not adequate to say \u \ t\. + To see this, consider the developments of a term of the form \\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\. + Intuitively, such developments should consist of a (possibly empty) initial segment + containing only transitions of the form \t1 \<^bold>\ t2\, followed by a transition of the form + \\<^bold>\\<^bold>[u1'\<^bold>] \<^bold>\ u2'\, followed by a development of the residual of the original \\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ + after what has come so far. + The requirement \u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ is not a strong enough constraint on the + transitions in the initial segment, because \\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2 \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ + can hold for \t2\ and \u2\ coinitial, but otherwise without any particular relationship + between their sets of marked redexes. In particular, this can occur when + \u2\ and \t2\ occur as subterms that can be deleted by the contraction of an outer redex. + So we need to introduce a notion of containment between terms that is stronger + and more ``syntactic'' than \\\. The notion ``subsumed by'' defined below serves + this purpose. Term \u\ is subsumed by term \t\ if both terms are arrows with exactly + the same form except that \t\ may contain \\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ (a marked redex) in places + where \u\ contains \\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\. + \ + + fun subs (infix "\" 50) + where "\<^bold>\i\<^bold>\ \ \<^bold>\i'\<^bold>\ \ i = i'" + | "\<^bold>\\<^bold>[t\<^bold>] \ \<^bold>\\<^bold>[t'\<^bold>] \ t \ t'" + | "t \<^bold>\ u \ t' \<^bold>\ u' \ t \ t' \ u \ u'" + | "\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u \ \<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u' \ t \ t' \ u \ u'" + | "\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u \ \<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u' \ t \ t' \ u \ u'" + | "_ \ _ \ False" + + lemma subs_implies_prfx: + shows "\u. t \ u \ t \ u" + apply (induct t) + apply auto[1] + using subs.elims(2) + apply fastforce + proof - + show "\t. \\u. t \ u \ t \ u; \<^bold>\\<^bold>[t\<^bold>] \ u\ \ \<^bold>\\<^bold>[t\<^bold>] \ u" for u + by (cases u, auto) fastforce + show "\t2. \\u1. t1 \ u1 \ t1 \ u1; + \u2. t2 \ u2 \ t2 \ u2; + t1 \<^bold>\ t2 \ u\ + \ t1 \<^bold>\ t2 \ u" for t1 u + apply (cases t1; cases u) + apply simp_all + apply fastforce+ + apply (metis Ide_Subst con_char lambda.sel(2) subs.simps(2) prfx_Lam_iff prfx_char + prfx_implies_con) + by fastforce+ + show "\t1 t2. \\u1. t1 \ u1 \ t1 \ u1; + \u2. t2 \ u2 \ t2 \ u2; + \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u\ + \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u" for u + using Ide_Subst + apply (cases u, simp_all) + by (metis Ide.simps(1)) + qed + + text \ + The following is an example showing that two terms can be related by \\\ without being + related by \\\. + \ + + lemma subs_example: + shows "\<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\0\<^bold>\) \ \<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\0\<^bold>\) = True" + and "\<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\0\<^bold>\) \ \<^bold>\\<^bold>[\<^bold>\1\<^bold>\\<^bold>] \<^bold>\ (\<^bold>\\<^bold>[\<^bold>\0\<^bold>\\<^bold>] \<^bold>\ \<^bold>\0\<^bold>\) = False" + by auto + + lemma subs_Ide: + shows "\u. \ide u; Src t = Src u\ \ u \ t" + using Ide_Src Ide_implies_Arr Ide_iff_Src_self + by (induct t, simp_all) force+ + + lemma subs_App: + shows "u \ t1 \<^bold>\ t2 \ is_App u \ un_App1 u \ t1 \ un_App2 u \ t2" + by (metis lambda.collapse(3) prfx_App_iff subs.simps(3) subs_implies_prfx) + + end + + context reduction_paths + begin + + text \ + We now formally define a \emph{development of \t\} to be an elementary reduction path \U\ + that is coinitial with \[t]\ and is such that each transition \u\ in \U\ is subsumed by + the residual of \t\ along the prefix of \U\ coming before \u\. Stated another way, + each transition in \U\ corresponds to the contraction of a single redex that is the residual + of a redex originally marked in \t\. + \ + + fun development + where "development t [] \ \.Arr t" + | "development t (u # U) \ + \.elementary_reduction u \ u \ t \ development (t \\ u) U" + + lemma development_imp_Arr: + assumes "development t U" + shows "\.Arr t" + using assms + by (metis \.Con_implies_Arr2 \.Ide.simps(1) \.ide_char \.subs_implies_prfx + development.elims(2)) + + lemma development_Ide: + shows "\t. \.Ide t \ development t U \ U = []" + using \.Ide_implies_Arr + apply (induct U) + apply auto + by (meson \.elementary_reduction_not_ide \.ide_backward_stable \.ide_char + \.subs_implies_prfx) + + lemma development_implies: + shows "\t. development t U \ elementary_reduction_path U \ (U \ [] \ U \<^sup>*\\<^sup>* [t])" + apply (induct U) + using elementary_reduction_path_def + apply simp + proof - + fix t u U + assume ind: "\t. development t U \ + elementary_reduction_path U \ (U \ [] \ U \<^sup>*\\<^sup>* [t])" + show "development t (u # U) \ + elementary_reduction_path (u # U) \ (u # U \ [] \ u # U \<^sup>*\\<^sup>* [t])" + proof (cases "U = []") + assume uU: "development t (u # U)" + show "U = [] \ ?thesis" + using uU \.subs_implies_prfx ide_char \.elementary_reduction_is_arr + elementary_reduction_path_def prfx_implies_con + by force + assume U: "U \ []" + have "\.elementary_reduction u \ u \ t \ development (t \\ u) U" + using U uU development.elims(1) by blast + hence 1: "\.elementary_reduction u \ elementary_reduction_path U \ u \ t \ + (U \ [] \ U \<^sup>*\\<^sup>* [t \\ u])" + using U uU ind by auto + show ?thesis + proof (unfold elementary_reduction_path_def, intro conjI) + show "u # U = [] \ Arr (u # U) \ set (u # U) \ Collect \.elementary_reduction" + using U 1 + by (metis Con_implies_Arr(1) Con_rec(2) con_char prfx_implies_con + elementary_reduction_path_def insert_subset list.simps(15) mem_Collect_eq + \.prfx_implies_con \.subs_implies_prfx) + show "u # U \ [] \ u # U \<^sup>*\\<^sup>* [t]" + proof - + have "u # U \<^sup>*\\<^sup>* [t] \ ide ([u \\ t] @ U \<^sup>*\\\<^sup>* [t \\ u])" + using 1 U Con_rec(2) Resid_rec(2) con_char prfx_implies_con + \.prfx_implies_con \.subs_implies_prfx + by simp + also have "... \ True" + using U 1 ide_char Ide_append_iff\<^sub>P\<^sub>W\<^sub>E [of "[u \\ t]" "U \<^sup>*\\\<^sup>* [t \\ u]"] + by (metis Ide.simps(2) Ide_appendI\<^sub>P\<^sub>W\<^sub>E Src_resid Trg.simps(2) \.prfx_implies_con + \.trg_resid_sym con_char \.subs_implies_prfx prfx_implies_con) + finally show ?thesis by blast + qed + qed + qed + qed + + text \ + The converse of the previous result does not hold, because there could be a stage \i\ + at which \u\<^sub>i \ t\<^sub>i\, but \t\<^sub>i\ deletes the redex contracted in \u\<^sub>i\, so there is nothing + forcing that redex to have been originally marked in \t\. So \U\ being a development + of \t\ is a stronger property than \U\ just being an elementary reduction path such + that \U \<^sup>*\\<^sup>* [t]\. + \ + + lemma development_append: + shows "\t V. \development t U; development (t \<^sup>1\\\<^sup>* U) V\ \ development t (U @ V)" + using development_imp_Arr null_char + apply (induct U) + apply auto + by (metis Resid1x.simps(2-3) append_Nil neq_Nil_conv) + + lemma development_map_Lam: + shows "\t. development t T \ development \<^bold>\\<^bold>[t\<^bold>] (map \.Lam T)" + using \.Arr_not_Nil development_imp_Arr + by (induct T) auto + + lemma development_map_App_1: + shows "\t. \development t T; \.Arr u\ + \ development (t \<^bold>\ u) (map (\x. x \<^bold>\ \.Src u) T)" + apply (induct T) + apply (simp add: \.Ide_implies_Arr) + proof - + fix t T t' + assume ind: "\t. \development t T; \.Arr u\ + \ development (t \<^bold>\ u) (map (\x. x \<^bold>\ \.Src u) T)" + assume t'T: "development t (t' # T)" + assume u: "\.Arr u" + show "development (t \<^bold>\ u) (map (\x. x \<^bold>\ \.Src u) (t' # T))" + using u t'T ind + apply simp + using \.Arr_not_Nil \.Ide_Src development_imp_Arr \.subs_Ide by force + qed + + lemma development_map_App_2: + shows "\u. \\.Arr t; development u U\ + \ development (t \<^bold>\ u) (map (\x. \.App (\.Src t) x) U)" + apply (induct U) + apply (simp add: \.Ide_implies_Arr) + proof - + fix u U u' + assume ind: "\u. \\.Arr t; development u U\ + \ development (t \<^bold>\ u) (map (\.App (\.Src t)) U)" + assume u'U: "development u (u' # U)" + assume t: "\.Arr t" + show "development (t \<^bold>\ u) (map (\.App (\.Src t)) (u' # U)) " + using t u'U ind + apply simp + by (metis \.Coinitial_iff_Con \.Ide_Src \.Ide_iff_Src_self \.Ide_implies_Arr + development_imp_Arr \.ide_char \.resid_Arr_Ide \.subs_Ide) + qed + + subsection "Finiteness of Developments" + + text \ + A term \t\ has the finite developments property if there exists a finite value + that bounds the length of all developments of \t\. The goal of this section is + to prove the Finite Developments Theorem: every term has the finite developments + property. + \ + + definition FD + where "FD t \ \n. \U. development t U \ length U \ n" + + end + + text \ + In \cite{hindley}, Hindley proceeds by using structural induction to establish + a bound on the length of a development of a term. + The only case that poses any difficulty is the case of a \\\-redex, which is + \\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u\ in the notation used here. He notes that there is an easy bound on the + length of a development of a special form in which all the contractions of residuals of \t\ + occur before the contraction of the top-level redex. The development first + takes \\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u\ to \\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u'\, then to \subst u' t'\, then continues with + independent developments of \u'\. The number of independent developments of \u'\ + is given by the number of free occurrences of \Var 0\ in \t'\. As there can be + only finitely many such \t'\, we can use the maximum number of free occurrences + of \Var 0\ over all such \t'\ to bound the steps in the independent developments of \u'\. + + In the general case, the problem is that reductions of residuals of t can + increase the number of free occurrences of \Var 0\, so we can't readily count + them at any particular stage. Hindley shows that developments in which + there are reductions of residuals of \t\ that occur after the contraction of the + top-level redex are equivalent to reductions of the special form, by a + transformation with a bounded increase in length. This can be considered as a + weak form of standardization for developments. + + A later paper by de Vrijer \cite{deVrijer} obtains an explicit function for the + exact number of steps in a development of maximal length. His proof is very + straightforward and amenable to formalization, and it is what we follow here. + The main issue for us is that de Vrijer uses a classical representation of \\\-terms, + with variable names and \\\-equivalence, whereas here we are using de Bruijn indices. + This means that we have to discover the correct modification of de Vrijer's definitions + to apply to the present situation. + \ + + context lambda_calculus + begin + + text \ + Our first definition is that of the ``multiplicity'' of a free variable in a term. + This is a count of the maximum number of times a variable could occur free in a term + reachable in a development. The main issue in adjusting to de Bruijn indices + is that the same variable will have different indices depending on the depth at which + it occurs in the term. So, we need to keep track of how the indices of variables change + as we move through the term. Our modified definitions adjust the parameter to the + multiplicity function on each recursive call, to account for the contextual depth + (\emph{i.e.}~the number of binders on a path from the root of the term). + + The definition of this function is readily understandable, except perhaps for the + \Beta\ case. The multiplicity \mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)\ has to be at least as large as + \mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)\, to account for developments in which the top-level redex is not + contracted. However, if the top-level redex \\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u\ is contracted, then the contractum + is \subst u t\, so the multiplicity has to be at least as large as \mtp x (subst u t)\. + This leads to the relation: + \begin{center} + \mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = max (mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)) (mtp x (subst u t))\ + \end{center} + This is not directly suitable for use in a definition of the function \mtp\, because + proving the termination is problematic. Instead, we have to guess the correct + expression for \mtp x (subst u t)\ and use that. + + Now, each variable \x\ in \subst u t\ other than the variable \0\ that is substituted for + still has all the occurrences that it does in \\<^bold>\\<^bold>[t\<^bold>]\. In addition, the variable being + substituted for (which has index \0\ in the outermost context of \t\) will in general have + multiple free occurrences in \t\, with a total multiplicity given by \mtp 0 t\. + The substitution operation replaces each free occurrence by \u\, which has the effect of + multiplying the multiplicity of a variable \x\ in \t\ by a factor of \mtp 0 t\. + These considerations lead to the following: + \begin{center} + \mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = max (mtp x \<^bold>\\<^bold>[t\<^bold>] + mtp x u) (mtp x \<^bold>\\<^bold>[t\<^bold>] + mtp x u * mtp 0 t)\ + \end{center} + However, we can simplify this to: + \begin{center} + \mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = mtp x \<^bold>\\<^bold>[t\<^bold>] + mtp x u * max 1 (mtp 0 t)\ + \end{center} + and replace the \mtp x \<^bold>\\<^bold>[t\<^bold>]\ by \mtp (Suc x) t\ to simplify the ordering necessary + for the termination proof and allow it to be done automatically. + + The final result is perhaps about the first thing one would think to write down, + but there are possible ways to go wrong and it is of course still necessary to discover + the proper form required for the various induction proofs. I followed a long path + of rather more complicated-looking definitions, until I eventually managed to find the + proper inductive forms for all the lemmas and eventually arrive back at this definition. + \ + + fun mtp :: "nat \ lambda \ nat" + where "mtp x \<^bold>\ = 0" + | "mtp x \<^bold>\z\<^bold>\ = (if z = x then 1 else 0)" + | "mtp x \<^bold>\\<^bold>[t\<^bold>] = mtp (Suc x) t" + | "mtp x (t \<^bold>\ u) = mtp x t + mtp x u" + | "mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = mtp (Suc x) t + mtp x u * max 1 (mtp 0 t)" + + text \ + The multiplicity function generalizes the free variable predicate. + This is not actually used, but is included for explanatory purposes. + \ + + lemma mtp_gt_0_iff_in_FV: + shows "\x. mtp x t > 0 \ x \ FV t" + proof (induct t) + show "\x. 0 < mtp x \<^bold>\ \ x \ FV \<^bold>\" + by simp + show "\x z. 0 < mtp x \<^bold>\z\<^bold>\ \ x \ FV \<^bold>\z\<^bold>\" + by auto + show Lam: "\t x. (\x. 0 < mtp x t \ x \ FV t) + \ 0 < mtp x \<^bold>\\<^bold>[t\<^bold>] \ x \ FV \<^bold>\\<^bold>[t\<^bold>]" + proof - + fix t and x :: nat + assume ind: "\x. 0 < mtp x t \ x \ FV t" + show "0 < mtp x \<^bold>\\<^bold>[t\<^bold>] \ x \ FV \<^bold>\\<^bold>[t\<^bold>]" + using ind + apply auto + apply (metis Diff_iff One_nat_def diff_Suc_1 empty_iff imageI insert_iff + nat.distinct(1)) + by (metis Suc_pred neq0_conv) + qed + show "\t u x. + \\x. 0 < mtp x t \ x \ FV t; + \x. 0 < mtp x u \ x \ FV u\ + \ 0 < mtp x (t \<^bold>\ u) \ x \ FV (t \<^bold>\ u)" + by simp + show "\t u x. + \\x. 0 < mtp x t \ x \ FV t; + \x. 0 < mtp x u \ x \ FV u\ + \ 0 < mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ x \ FV (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + proof - + fix t u and x :: nat + assume ind1: "\x. 0 < mtp x t \ x \ FV t" + assume ind2: "\x. 0 < mtp x u \ x \ FV u" + show "0 < mtp x (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ x \ FV (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + using ind1 ind2 + apply simp + by force + qed + qed + + text \ + We now establish a fact about commutation of multiplicity and Raise that will be + needed subsequently. + \ + + lemma mtpE_eq_Raise: + shows "\x k d. x < d \ mtp x (Raise d k t) = mtp x t" + by (induct t) auto + + lemma mtp_Raise_ind: + shows "\d x k l t. \l \ d; size t \ s\ \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + proof (induct s) + show "\d x k l. \l \ d; size t \ 0\ \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + for t + by (cases t) auto + show "\s d x k l. + \\d x k l t. \l \ d; size t \ s\ \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t; + l \ d; size t \ Suc s\ + \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + for t + proof (cases t) + show "\d x k l s. t = \<^bold>\ \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + by simp + show "\z d x k l s. \l \ d; t = \<^bold>\z\<^bold>\\ + \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + by simp + show "\u d x k l s. \l \ d; size t \ Suc s; t = \<^bold>\\<^bold>[u\<^bold>]; + (\d x k l u. \l \ d; size u \ s\ + \ mtp (x + d + k) (Raise l k u) = mtp (x + d) u)\ + \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + proof - + fix u d x s and k l :: nat + assume l: "l \ d" and s: "size t \ Suc s" and t: "t = \<^bold>\\<^bold>[u\<^bold>]" + assume ind: "\d x k l u. \l \ d; size u \ s\ + \ mtp (x + d + k) (Raise l k u) = mtp (x + d) u" + show "mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + proof - + have "mtp (x + d + k) (Raise l k t) = mtp (Suc (x + d + k)) (Raise (Suc l) k u)" + using t by simp + also have "... = mtp (x + Suc d) u" + proof - + have "size u \ s" + using t s by force + thus ?thesis + using l s ind [of "Suc l" "Suc d"] by simp + qed + also have "... = mtp (x + d) t" + using t by auto + finally show ?thesis by blast + qed + qed + show "\t1 t2 d x k l s. + \\d x k l t1. \l \ d; size t1 \ s\ + \ mtp (x + d + k) (Raise l k t1) = mtp (x + d) t1; + \d x k l t2. \l \ d; size t2 \ s\ + \ mtp (x + d + k) (Raise l k t2) = mtp (x + d) t2; + l \ d; size t \ Suc s; t = t1 \<^bold>\ t2\ + \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + proof - + fix t1 t2 s + assume s: "size t \ Suc s" and t: "t = t1 \<^bold>\ t2" + have "size t1 \ s \ size t2 \ s" + using s t by auto + thus "\d x k l. + \\d x k l t1. \l \ d; size t1 \ s\ + \ mtp (x + d + k) (Raise l k t1) = mtp (x + d) t1; + \d x k l t2. \l \ d; size t2 \ s\ + \ mtp (x + d + k) (Raise l k t2) = mtp (x + d) t2; + l \ d; size t \ Suc s; t = t1 \<^bold>\ t2\ + \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + by simp + qed + show "\t1 t2 d x k l s. + \\d x k l t1. \l \ d; size t1 \ s\ + \ mtp (x + d + k) (Raise l k t1) = mtp (x + d) t1; + \d x k l t2. \l \ d; size t2 \ s\ + \ mtp (x + d + k) (Raise l k t2) = mtp (x + d) t2; + l \ d; size t \ Suc s; t = \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ + \ mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + proof - + fix t1 t2 d x s and k l :: nat + assume l: "l \ d" and s: "size t \ Suc s" and t: "t = \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2" + assume ind: "\d x k l N. \l \ d; size N \ s\ + \ mtp (x + d + k) (Raise l k N) = mtp (x + d) N" + show "mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + proof - + have 1: "size t1 \ s \ size t2 \ s" + using s t by auto + have "mtp (x + d + k) (Raise l k t) = + mtp (Suc (x + d + k)) (Raise (Suc l) k t1) + + mtp (x + d + k) (Raise l k t2) * max 1 (mtp 0 (Raise (Suc l) k t1))" + using t l by simp + also have "... = mtp (Suc (x + d + k)) (Raise (Suc l) k t1) + + mtp (x + d) t2 * max 1 (mtp 0 (Raise (Suc l) k t1))" + using l 1 ind by auto + also have "... = mtp (x + Suc d) t1 + mtp (x + d) t2 * max 1 (mtp 0 t1)" + proof - + have "mtp (x + Suc d + k) (Raise (Suc l) k t1) = mtp (x + Suc d) t1" + using l 1 ind [of "Suc l" "Suc d" t1] by simp + moreover have "mtp 0 (Raise (Suc l) k t1) = mtp 0 t1" + (* Raising indices already > 0 does not affect mtp\<^sub>0. *) + using l 1 ind [of "Suc l" "Suc d" t1 k] mtpE_eq_Raise by simp + ultimately show ?thesis + by simp + qed + also have "... = mtp (x + d) t" + using t by auto + finally show ?thesis by blast + qed + qed + qed + qed + + lemma mtp_Raise: + assumes "l \ d" + shows "mtp (x + d + k) (Raise l k t) = mtp (x + d) t" + using assms mtp_Raise_ind by blast + + lemma mtp_Raise': + shows "\k l. mtp l (Raise l (Suc k) t) = 0" + by (induct t) auto + + lemma mtp_raise: + shows "mtp (x + Suc d) (raise d t) = mtp (Suc x) t" + by (metis Suc_eq_plus1 add.assoc le_add2 le_add_same_cancel2 mtp_Raise plus_1_eq_Suc) + + lemma mtp_Subst_cancel: + shows "\k d n. mtp k (Subst (Suc d + k) u t) = mtp k t" + proof (induct t) + show "\k d n. mtp k (Subst (Suc d + k) u \<^bold>\) = mtp k \<^bold>\" + by simp + show "\k z d n. mtp k (Subst (Suc d + k) u \<^bold>\z\<^bold>\) = mtp k \<^bold>\z\<^bold>\" + using mtp_Raise' + apply auto + by (metis add_Suc_right add_Suc_shift order_refl raise_plus) + show "\t k d n. (\k d n. mtp k (Subst (Suc d + k) u t) = mtp k t) + \ mtp k (Subst (Suc d + k) u \<^bold>\\<^bold>[t\<^bold>]) = mtp k \<^bold>\\<^bold>[t\<^bold>]" + by (metis Subst.simps(3) add_Suc_right mtp.simps(3)) + show "\t1 t2 k d n. + \\k d n. mtp k (Subst (Suc d + k) u t1) = mtp k t1; + \k d n. mtp k (Subst (Suc d + k) u t2) = mtp k t2\ + \ mtp k (Subst (Suc d + k) u (t1 \<^bold>\ t2)) = mtp k (t1 \<^bold>\ t2)" + by auto + show "\t1 t2 k d n. + \\k d n. mtp k (Subst (Suc d + k) u t1) = mtp k t1; + \k d n. mtp k (Subst (Suc d + k) u t2) = mtp k t2\ + \ mtp k (Subst (Suc d + k) u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = mtp k (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + using mtp_Raise' + apply auto + by (metis Nat.add_0_right add_Suc_right) + qed + + lemma mtp\<^sub>0_Subst_cancel: + shows "mtp 0 (Subst (Suc d) u t) = mtp 0 t" + using mtp_Subst_cancel [of 0] by simp + + text \ + We can now (!) prove the desired generalization of de Vrijer's formula for the + commutation of multiplicity and substitution. This is the main lemma whose form + is difficult to find. To get this right, the proper relationships have to exist + between the various depth parameters to \Subst\ and the arguments to \mtp\. + \ + + lemma mtp_Subst': + shows "\d x u. mtp (x + Suc d) (Subst d u t) = + mtp (x + Suc (Suc d)) t + mtp (Suc x) u * mtp d t" + proof (induct t) + show "\d x u. mtp (x + Suc d) (Subst d u \<^bold>\) = + mtp (x + Suc (Suc d)) \<^bold>\ + mtp (Suc x) u * mtp d \<^bold>\" + by simp + show "\z d x u. mtp (x + Suc d) (Subst d u \<^bold>\z\<^bold>\) = + mtp (x + Suc (Suc d)) \<^bold>\z\<^bold>\ + mtp (Suc x) u * mtp d \<^bold>\z\<^bold>\" + using mtp_raise by auto + show "\t d x u. + (\d x u. mtp (x + Suc d) (Subst d u t) = + mtp (x + Suc (Suc d)) t + mtp (Suc x) u * mtp d t) + \ mtp (x + Suc d) (Subst d u \<^bold>\\<^bold>[t\<^bold>]) = + mtp (x + Suc (Suc d)) \<^bold>\\<^bold>[t\<^bold>] + mtp (Suc x) u * mtp d \<^bold>\\<^bold>[t\<^bold>]" + proof - + fix t u d x + assume ind: "\d x N. mtp (x + Suc d) (Subst d N t) = + mtp (x + Suc (Suc d)) t + mtp (Suc x) N * mtp d t" + have "mtp (x + Suc d) (Subst d u \<^bold>\\<^bold>[t\<^bold>]) = + mtp (Suc x + Suc (Suc d)) t + + mtp (x + Suc (Suc d)) (raise (Suc d) u) * mtp (Suc d) t" + using ind mtp_raise add_Suc_shift + by (metis Subst.simps(3) add_Suc_right mtp.simps(3)) + also have "... = mtp (x + Suc (Suc d)) \<^bold>\\<^bold>[t\<^bold>] + mtp (Suc x) u * mtp d \<^bold>\\<^bold>[t\<^bold>]" + using Raise_Suc + by (metis add_Suc_right add_Suc_shift mtp.simps(3) mtp_raise) + finally show "mtp (x + Suc d) (Subst d u \<^bold>\\<^bold>[t\<^bold>]) = + mtp (x + Suc (Suc d)) \<^bold>\\<^bold>[t\<^bold>] + mtp (Suc x) u * mtp d \<^bold>\\<^bold>[t\<^bold>]" + by blast + qed + show "\t1 t2 u d x. + \\d x u. mtp (x + Suc d) (Subst d u t1) = + mtp (x + Suc (Suc d)) t1 + mtp (Suc x) u * mtp d t1; + \d x u. mtp (x + Suc d) (Subst d u t2) = + mtp (x + Suc (Suc d)) t2 + mtp (Suc x) u * mtp d t2\ + \ mtp (x + Suc d) (Subst d u (t1 \<^bold>\ t2)) = + mtp (x + Suc (Suc d)) (t1 \<^bold>\ t2) + mtp (Suc x) u * mtp d (t1 \<^bold>\ t2)" + by (simp add: add_mult_distrib2) + show "\t1 t2 u d x. + \\d x N. mtp (x + Suc d) (Subst d N t1) = + mtp (x + Suc (Suc d)) t1 + mtp (Suc x) N * mtp d t1; + \d x N. mtp (x + Suc d) (Subst d N t2) = + mtp (x + Suc (Suc d)) t2 + mtp (Suc x) N * mtp d t2\ + \ mtp (x + Suc d) (Subst d u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = + mtp (x + Suc (Suc d)) (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + mtp (Suc x) u * mtp d (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix t1 t2 u d x + assume ind1: "\d x N. mtp (x + Suc d) (Subst d N t1) = + mtp (x + Suc (Suc d)) t1 + mtp (Suc x) N * mtp d t1" + assume ind2: "\d x N. mtp (x + Suc d) (Subst d N t2) = + mtp (x + Suc (Suc d)) t2 + mtp (Suc x) N * mtp d t2" + show "mtp (x + Suc d) (Subst d u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = + mtp (x + Suc (Suc d)) (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + mtp (Suc x) u * mtp d (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + let ?A = "mtp (Suc x + Suc (Suc d)) t1" + let ?B = "mtp (Suc x + Suc d) t2" + let ?M1 = "mtp (Suc d) t1" + let ?M2 = "mtp d t2" + let ?M1\<^sub>0 = "mtp 0 (Subst (Suc d) u t1)" + let ?M1\<^sub>0' = "mtp 0 t1" + let ?N = "mtp (Suc x) u" + have "mtp (x + Suc d) (Subst d u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = + mtp (x + Suc d) (\<^bold>\\<^bold>[Subst (Suc d) u t1\<^bold>] \<^bold>\ Subst d u t2)" + by simp + also have "... = mtp (x + Suc (Suc d)) (Subst (Suc d) u t1) + + mtp (x + Suc d) (Subst d u t2) * + max 1 (mtp 0 (Subst (Suc d) u t1))" + by simp + also have "... = (?A + ?N * ?M1) + (?B + ?N * ?M2) * max 1 ?M1\<^sub>0" + using ind1 ind2 add_Suc_shift by presburger + also have "... = ?A + ?N * ?M1 + ?B * max 1 ?M1\<^sub>0 + ?N * ?M2 * max 1 ?M1\<^sub>0" + by algebra + also have "... = ?A + ?B * max 1 ?M1\<^sub>0' + ?N * ?M1 + ?N * ?M2 * max 1 ?M1\<^sub>0'" + proof - + have "?M1\<^sub>0 = ?M1\<^sub>0'" + (* The u-dependence on the LHS is via raise (Suc d) u, which does not have + any free occurrences of 0. So mtp 0 0 yields the same on both. *) + using mtp\<^sub>0_Subst_cancel by blast + thus ?thesis by auto + qed + also have "... = ?A + ?B * max 1 ?M1\<^sub>0' + ?N * (?M1 + ?M2 * max 1 ?M1\<^sub>0')" + by algebra + also have "... = mtp (Suc x + Suc d) (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + mtp (Suc x) u * mtp d (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by simp + finally show ?thesis by simp + qed + qed + qed + + text \ + The following lemma provides expansions that apply when the parameter to \mtp\ is \0\, + as opposed to the previous lemma, which only applies for parameters greater than \0\. + \ + + lemma mtp_Subst: + shows "\u k. mtp k (Subst k u t) = mtp (Suc k) t + mtp k (raise k u) * mtp k t" + proof (induct t) + show "\u k. mtp k (Subst k u \<^bold>\) = mtp (Suc k) \<^bold>\ + mtp k (raise k u) * mtp k \<^bold>\" + by simp + show "\x u k. mtp k (Subst k u \<^bold>\x\<^bold>\) = + mtp (Suc k) \<^bold>\x\<^bold>\ + mtp k (raise k u) * mtp k \<^bold>\x\<^bold>\" + by auto + show "\t u k. (\u k. mtp k (Subst k u t) = mtp (Suc k) t + mtp k (raise k u) * mtp k t) + \ mtp k (Subst k u \<^bold>\\<^bold>[t\<^bold>]) = + mtp (Suc k) \<^bold>\\<^bold>[t\<^bold>] + mtp k (Raise 0 k u) * mtp k \<^bold>\\<^bold>[t\<^bold>]" + using mtp_Raise [of 0] + apply auto + by (metis add.left_neutral) + show "\t1 t2 u k. + \\u k. mtp k (Subst k u t1) = mtp (Suc k) t1 + mtp k (raise k u) * mtp k t1; + \u k. mtp k (Subst k u t2) = mtp (Suc k) t2 + mtp k (raise k u) * mtp k t2\ + \ mtp k (Subst k u (t1 \<^bold>\ t2)) = + mtp (Suc k) (t1 \<^bold>\ t2) + mtp k (raise k u) * mtp k (t1 \<^bold>\ t2)" + by (auto simp add: distrib_left) + show "\t1 t2 u k. + \\u k. mtp k (Subst k u t1) = mtp (Suc k) t1 + mtp k (raise k u) * mtp k t1; + \u k. mtp k (Subst k u t2) = mtp (Suc k) t2 + mtp k (raise k u) * mtp k t2\ + \ mtp k (Subst k u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = + mtp (Suc k) (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + mtp k (raise k u) * mtp k (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix t1 t2 u k + assume ind1: "\u k. mtp k (Subst k u t1) = + mtp (Suc k) t1 + mtp k (raise k u) * mtp k t1" + assume ind2: "\u k. mtp k (Subst k u t2) = + mtp (Suc k) t2 + mtp k (raise k u) * mtp k t2" + show "mtp k (Subst k u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = + mtp (Suc k) (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + mtp k (raise k u) * mtp k (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + have "mtp (Suc k) (Raise 0 (Suc k) u) * mtp (Suc k) t1 + + (mtp (Suc k) t2 + mtp k (Raise 0 k u) * mtp k t2) * max (Suc 0) (mtp 0 t1) = + mtp (Suc k) t2 * max (Suc 0) (mtp 0 t1) + + mtp k (Raise 0 k u) * (mtp (Suc k) t1 + mtp k t2 * max (Suc 0) (mtp 0 t1))" + proof - + have "mtp (Suc k) (Raise 0 (Suc k) u) * mtp (Suc k) t1 + + (mtp (Suc k) t2 + mtp k (Raise 0 k u) * mtp k t2) * max (Suc 0) (mtp 0 t1) = + mtp (Suc k) t2 * max (Suc 0) (mtp 0 t1) + + mtp (Suc k) (Raise 0 (Suc k) u) * mtp (Suc k) t1 + + mtp k (Raise 0 k u) * mtp k t2 * max (Suc 0) (mtp 0 t1)" + by algebra + also have "... = mtp (Suc k) t2 * max (Suc 0) (mtp 0 t1) + + mtp (Suc k) (Raise 0 (Suc k) u) * mtp (Suc k) t1 + + mtp 0 u * mtp k t2 * max (Suc 0) (mtp 0 t1)" + using mtp_Raise [of 0 0 0 k u] by auto + also have "... = mtp (Suc k) t2 * max (Suc 0) (mtp 0 t1) + + mtp k (Raise 0 k u) * + (mtp (Suc k) t1 + mtp k t2 * max (Suc 0) (mtp 0 t1))" + by (metis (no_types, lifting) ab_semigroup_add_class.add_ac(1) + ab_semigroup_mult_class.mult_ac(1) add_mult_distrib2 le_add1 mtp_Raise + plus_nat.add_0) + finally show ?thesis by blast + qed + thus ?thesis + using ind1 ind2 mtp\<^sub>0_Subst_cancel by auto + qed + qed + qed + + lemma mtp0_subst_le: + shows "mtp 0 (subst u t) \ mtp 1 t + mtp 0 u * max 1 (mtp 0 t)" + proof (cases t) + show "t = \<^bold>\ \ mtp 0 (subst u t) \ mtp 1 t + mtp 0 u * max 1 (mtp 0 t)" + by auto + show "\z. t = \<^bold>\z\<^bold>\ \ mtp 0 (subst u t) \ mtp 1 t + mtp 0 u * max 1 (mtp 0 t)" + using Raise_0 by force + show "\P. t = \<^bold>\\<^bold>[P\<^bold>] \ mtp 0 (subst u t) \ mtp 1 t + mtp 0 u * max 1 (mtp 0 t)" + using mtp_Subst [of 0 u t] Raise_0 by force + show "\t1 t2. t = t1 \<^bold>\ t2 \ mtp 0 (subst u t) \ mtp 1 t + mtp 0 u * max 1 (mtp 0 t)" + using mtp_Subst Raise_0 add_mult_distrib2 nat_mult_max_right by auto + show "\t1 t2. t = \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ mtp 0 (subst u t) \ mtp 1 t + mtp 0 u * max 1 (mtp 0 t)" + using mtp_Subst Raise_0 + by (metis Nat.add_0_right dual_order.eq_iff max_def mult.commute mult_zero_left + not_less_eq_eq plus_1_eq_Suc trans_le_add1) + qed + + lemma elementary_reduction_nonincreases_mtp: + shows "\u x. \elementary_reduction u; u \ t\ \ mtp x (resid t u) \ mtp x t" + proof (induct t) + show "\u x. \elementary_reduction u; u \ \<^bold>\\ \ mtp x (resid \<^bold>\ u) \ mtp x \<^bold>\" + by simp + show "\x u i. \elementary_reduction u; u \ \<^bold>\i\<^bold>\\ + \ mtp x (resid \<^bold>\i\<^bold>\ u) \ mtp x \<^bold>\i\<^bold>\" + by (meson Ide.simps(2) elementary_reduction_not_ide ide_backward_stable ide_char + subs_implies_prfx) + fix u + show "\t x. \\u x. \elementary_reduction u; u \ t\ \ mtp x (resid t u) \ mtp x t; + elementary_reduction u; u \ \<^bold>\\<^bold>[t\<^bold>]\ + \ mtp x (\<^bold>\\<^bold>[t\<^bold>] \\ u) \ mtp x \<^bold>\\<^bold>[t\<^bold>]" + by (cases u) auto + show "\t1 t2 x. + \\u x. \elementary_reduction u; u \ t1\ \ mtp x (resid t1 u) \ mtp x t1; + \u x. \elementary_reduction u; u \ t2\ \ mtp x (resid t2 u) \ mtp x t2; + elementary_reduction u; u \ t1 \<^bold>\ t2\ + \ mtp x (resid (t1 \<^bold>\ t2) u) \ mtp x (t1 \<^bold>\ t2)" + apply (cases u) + apply auto + apply (metis Coinitial_iff_Con add_mono_thms_linordered_semiring(3) resid_Arr_Ide) + by (metis Coinitial_iff_Con add_mono_thms_linordered_semiring(2) resid_Arr_Ide) + (* + * TODO: Isabelle is sensitive to the order of assumptions in the induction hypotheses + * stated in the "show". Why? + *) + show "\t1 t2 x. + \\u1 x. \elementary_reduction u1; u1 \ t1\ \ mtp x (resid t1 u1) \ mtp x t1; + \u2 x. \elementary_reduction u2; u2 \ t2\ \ mtp x (resid t2 u2) \ mtp x t2; + elementary_reduction u; u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ + \ mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) \ mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix t1 t2 x + assume ind1: "\u1 x. \elementary_reduction u1; u1 \ t1\ + \ mtp x (t1 \\ u1) \ mtp x t1" + assume ind2: "\u2 x. \elementary_reduction u2; u2 \ t2\ + \ mtp x (t2 \\ u2) \ mtp x t2" + assume u: "elementary_reduction u" + assume subs: "u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2" + have 1: "is_App u \ is_Beta u" + using subs by (metis prfx_Beta_iff subs_implies_prfx) + have "is_App u \ mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) \ mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + assume 2: "is_App u" + obtain u1 u2 where u1u2: "u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2" + using 2 u + by (metis ConD(3) Con_implies_is_Lam_iff_is_Lam Con_sym con_def is_App_def is_Lam_def + lambda.disc(8) null_char prfx_implies_con subs subs_implies_prfx) + have "mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) = mtp x (\<^bold>\\<^bold>[t1 \\ u1\<^bold>] \<^bold>\ (t2 \\ u2))" + using u1u2 subs + by (metis Con_sym Ide.simps(1) ide_char resid.simps(6) subs_implies_prfx) + also have "... = mtp (Suc x) (resid t1 u1) + + mtp x (resid t2 u2) * max 1 (mtp 0 (resid t1 u1))" + by simp + also have "... \ mtp (Suc x) t1 + mtp x (resid t2 u2) * max 1 (mtp 0 (resid t1 u1))" + using u1u2 ind1 [of u1 "Suc x"] con_sym ide_char resid_arr_ide prfx_implies_con + subs subs_implies_prfx u + by force + also have "... \ mtp (Suc x) t1 + mtp x t2 * max 1 (mtp 0 (resid t1 u1))" + using u1u2 ind2 [of u2 x] + by (metis (no_types, lifting) Con_implies_Coinitial_ind add_left_mono + dual_order.eq_iff elementary_reduction.simps(4) lambda.disc(11) + mult_le_cancel2 prfx_App_iff resid.simps(31) resid_Arr_Ide subs subs.simps(4) + subs_implies_prfx u) + also have "... \ mtp (Suc x) t1 + mtp x t2 * max 1 (mtp 0 t1)" + using ind1 [of u1 0] + by (metis Con_implies_Coinitial_ind Ide.simps(3) elementary_reduction.simps(3) + elementary_reduction.simps(4) lambda.disc(11) max.mono mult_le_mono + nat_add_left_cancel_le nat_le_linear prfx_App_iff resid.simps(31) resid_Arr_Ide + subs subs.simps(4) subs_implies_prfx u u1u2) + also have "... = mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by auto + finally show "mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) \ mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" by blast + qed + moreover have "is_Beta u \ mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) \ mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + assume 2: "is_Beta u" + obtain u1 u2 where u1u2: "u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2" + using 2 u is_Beta_def by auto + have "mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) = mtp x (subst (t2 \\ u2) (t1 \\ u1))" + using u1u2 subs + by (metis con_def con_sym null_char prfx_implies_con resid.simps(4) subs_implies_prfx) + also have "... \ mtp (Suc x) (resid t1 u1) + + mtp x (resid t2 u2) * max 1 (mtp 0 (resid t1 u1))" + apply (cases "x = 0") + using mtp0_subst_le Raise_0 mtp_Subst' [of "x - 1" 0 "resid t2 u2" "resid t1 u1"] + by auto + also have "... \ mtp (Suc x) t1 + mtp x t2 * max 1 (mtp 0 t1)" + using ind1 ind2 + apply simp + by (metis Coinitial_iff_Con Ide.simps(1) dual_order.eq_iff elementary_reduction.simps(5) + ide_char resid.simps(4) resid_Arr_Ide subs subs_implies_prfx u u1u2) + also have "... = mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by simp + finally show "mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) \ mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" by blast + qed + ultimately show "mtp x ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) \ mtp x (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + using 1 by blast + qed + qed + + text \ + Next we define the ``height'' of a term. This counts the number of steps in a development + of maximal length of the given term. + \ + + fun hgt + where "hgt \<^bold>\ = 0" + | "hgt \<^bold>\_\<^bold>\ = 0" + | "hgt \<^bold>\\<^bold>[t\<^bold>] = hgt t" + | "hgt (t \<^bold>\ u) = hgt t + hgt u" + | "hgt (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = Suc (hgt t + hgt u * max 1 (mtp 0 t))" + + lemma hgt_resid_ide: + shows "\ide u; u \ t\ \ hgt (resid t u) \ hgt t" + by (metis con_sym eq_imp_le resid_arr_ide prfx_implies_con subs_implies_prfx) + + lemma hgt_Raise: + shows "\l k. hgt (Raise l k t) = hgt t" + using mtpE_eq_Raise + by (induct t) auto + + lemma hgt_Subst: + shows "\u k. Arr u \ hgt (Subst k u t) = hgt t + hgt u * mtp k t" + proof (induct t) + show "\u k. Arr u \ hgt (Subst k u \<^bold>\) = hgt \<^bold>\ + hgt u * mtp k \<^bold>\" + by simp + show "\x u k. Arr u \ hgt (Subst k u \<^bold>\x\<^bold>\) = hgt \<^bold>\x\<^bold>\ + hgt u * mtp k \<^bold>\x\<^bold>\" + using hgt_Raise by auto + show "\t u k. \\u k. Arr u \ hgt (Subst k u t) = hgt t + hgt u * mtp k t; Arr u\ + \ hgt (Subst k u \<^bold>\\<^bold>[t\<^bold>]) = hgt \<^bold>\\<^bold>[t\<^bold>] + hgt u * mtp k \<^bold>\\<^bold>[t\<^bold>]" + by auto + show "\t1 t2 u k. + \\u k. Arr u \ hgt (Subst k u t1) = hgt t1 + hgt u * mtp k t1; + \u k. Arr u \ hgt (Subst k u t2) = hgt t2 + hgt u * mtp k t2; Arr u\ + \ hgt (Subst k u (t1 \<^bold>\ t2)) = hgt (t1 \<^bold>\ t2) + hgt u * mtp k (t1 \<^bold>\ t2)" + by (simp add: distrib_left) + show "\t1 t2 u k. + \\u k. Arr u \ hgt (Subst k u t1) = hgt t1 + hgt u * mtp k t1; + \u k. Arr u \ hgt (Subst k u t2) = hgt t2 + hgt u * mtp k t2; Arr u\ + \ hgt (Subst k u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + hgt u * mtp k (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix t1 t2 u k + assume ind1: "\u k. Arr u \ hgt (Subst k u t1) = hgt t1 + hgt u * mtp k t1" + assume ind2: "\u k. Arr u \ hgt (Subst k u t2) = hgt t2 + hgt u * mtp k t2" + assume u: "Arr u" + show "hgt (Subst k u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + hgt u * mtp k (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + have "hgt (Subst k u (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = + Suc (hgt (Subst (Suc k) u t1) + + hgt (Subst k u t2) * max 1 (mtp 0 (Subst (Suc k) u t1)))" + by simp + also have "... = Suc ((hgt t1 + hgt u * mtp (Suc k) t1) + + (hgt t2 + hgt u * mtp k t2) * max 1 (mtp 0 (Subst (Suc k) u t1)))" + using u ind1 [of u "Suc k"] ind2 [of u k] by simp + also have "... = Suc (hgt t1 + hgt t2 * max 1 (mtp 0 (Subst (Suc k) u t1)) + + hgt u * mtp (Suc k) t1) + + hgt u * mtp k t2 * max 1 (mtp 0 (Subst (Suc k) u t1))" + using comm_semiring_class.distrib by force + also have "... = Suc (hgt t1 + hgt t2 * max 1 (mtp 0 (Subst (Suc k) u t1)) + + hgt u * (mtp (Suc k) t1 + + mtp k t2 * max 1 (mtp 0 (Subst (Suc k) u t1))))" + by (simp add: distrib_left) + also have "... = Suc (hgt t1 + hgt t2 * max 1 (mtp 0 t1) + + hgt u * (mtp (Suc k) t1 + + mtp k t2 * max 1 (mtp 0 t1)))" + proof - + have "mtp 0 (Subst (Suc k) u t1) = mtp 0 t1" + using mtp\<^sub>0_Subst_cancel by auto + thus ?thesis by simp + qed + also have "... = hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) + hgt u * mtp k (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by simp + finally show ?thesis by blast + qed + qed + qed + + lemma elementary_reduction_decreases_hgt: + shows "\u. \elementary_reduction u; u \ t\ \ hgt (t \\ u) < hgt t" + proof (induct t) + show "\u. \elementary_reduction u; u \ \<^bold>\\ \ hgt (\<^bold>\ \\ u) < hgt \<^bold>\" + by simp + show "\u x. \elementary_reduction u; u \ \<^bold>\x\<^bold>\\ \ hgt (\<^bold>\x\<^bold>\ \\ u) < hgt \<^bold>\x\<^bold>\" + using Ide.simps(2) elementary_reduction_not_ide ide_backward_stable ide_char + subs_implies_prfx + by blast + show "\t u. \\u. \elementary_reduction u; u \ t\ \ hgt (t \\ u) < hgt t; + elementary_reduction u; u \ \<^bold>\\<^bold>[t\<^bold>]\ + \ hgt (\<^bold>\\<^bold>[t\<^bold>] \\ u) < hgt \<^bold>\\<^bold>[t\<^bold>]" + proof - + fix t u + assume ind: "\u. \elementary_reduction u; u \ t\ \ hgt (t \\ u) < hgt t" + assume u: "elementary_reduction u" + assume subs: "u \ \<^bold>\\<^bold>[t\<^bold>]" + show "hgt (\<^bold>\\<^bold>[t\<^bold>] \\ u) < hgt \<^bold>\\<^bold>[t\<^bold>]" + using u subs ind + apply (cases u) + apply simp_all + by fastforce + qed + show "\t1 t2 u. + \\u. \elementary_reduction u; u \ t1\ \ hgt (t1 \\ u) < hgt t1; + \u. \elementary_reduction u; u \ t2\ \ hgt (t2 \\ u) < hgt t2; + elementary_reduction u; u \ t1 \<^bold>\ t2\ + \ hgt ((t1 \<^bold>\ t2) \\ u) < hgt (t1 \<^bold>\ t2)" + proof - + fix t1 t2 u + assume ind1: "\u. \elementary_reduction u; u \ t1\ \ hgt (t1 \\ u) < hgt t1" + assume ind2: "\u. \elementary_reduction u; u \ t2\ \ hgt (t2 \\ u) < hgt t2" + assume u: "elementary_reduction u" + assume subs: "u \ t1 \<^bold>\ t2" + show "hgt ((t1 \<^bold>\ t2) \\ u) < hgt (t1 \<^bold>\ t2)" + using u subs ind1 ind2 + apply (cases u) + apply simp_all + by (metis add_le_less_mono add_less_le_mono hgt_resid_ide ide_char not_less0 + zero_less_iff_neq_zero) + qed + show "\t1 t2 u. + \\u. \elementary_reduction u; u \ t1\ \ hgt (t1 \\ u) < hgt t1; + \u. \elementary_reduction u; u \ t2\ \ hgt (t2 \\ u) < hgt t2; + elementary_reduction u; u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2\ + \ hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix t1 t2 u + assume ind1: "\u. \elementary_reduction u; u \ t1\ \ hgt (t1 \\ u) < hgt t1" + assume ind2: "\u. \elementary_reduction u; u \ t2\ \ hgt (t2 \\ u) < hgt t2" + assume u: "elementary_reduction u" + assume subs: "u \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2" + have "is_App u \ is_Beta u" + using subs by (metis prfx_Beta_iff subs_implies_prfx) + moreover have "is_App u \ hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix u1 u2 + assume 0: "is_App u" + obtain u1 u1' u2 where 1: "u = u1 \<^bold>\ u2 \ u1 = \<^bold>\\<^bold>[u1'\<^bold>]" + using u 0 + by (metis ConD(3) Con_implies_is_Lam_iff_is_Lam Con_sym con_def is_App_def is_Lam_def + null_char prfx_implies_con subs subs_implies_prfx) + have "hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) = hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ (u1 \<^bold>\ u2))" + using 1 by simp + also have "... = hgt (\<^bold>\\<^bold>[t1 \\ u1'\<^bold>] \<^bold>\ t2 \\ u2)" + by (metis "1" Con_sym Ide.simps(1) ide_char resid.simps(6) subs subs_implies_prfx) + also have "... = Suc (hgt (t1 \\ u1') + hgt (t2 \\ u2) * max (Suc 0) (mtp 0 (t1 \\ u1')))" + by auto + also have "... < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + have "elementary_reduction (un_App1 u) \ ide (un_App2 u) \ + ide (un_App1 u) \ elementary_reduction (un_App2 u)" + using u 1 elementary_reduction_App_iff [of u] by simp + moreover have "elementary_reduction (un_App1 u) \ ide (un_App2 u) \ ?thesis" + proof - + assume 2: "elementary_reduction (un_App1 u) \ ide (un_App2 u)" + have "elementary_reduction u1' \ ide (un_App2 u)" + using 1 2 u elementary_reduction_Lam_iff by force + moreover have "mtp 0 (t1 \\ u1') \ mtp 0 t1" + using 1 calculation elementary_reduction_nonincreases_mtp subs + subs.simps(4) + by blast + moreover have "mtp 0 (t2 \\ u2) \ mtp 0 t2" + using 1 hgt_resid_ide [of u2 t2] + by (metis calculation(1) con_sym eq_refl resid_arr_ide lambda.sel(4) + prfx_implies_con subs subs.simps(4) subs_implies_prfx) + ultimately show ?thesis + using 1 2 ind1 [of u1'] hgt_resid_ide + apply simp + by (metis "1" Suc_le_mono \mtp 0 (t1 \ u1') \ mtp 0 t1\ add_less_le_mono + le_add1 le_add_same_cancel1 max.mono mult_le_mono subs subs.simps(4)) + qed + moreover have "ide (un_App1 u) \ elementary_reduction (un_App2 u) \ ?thesis" + proof - + assume 2: "ide (un_App1 u) \ elementary_reduction (un_App2 u)" + have "ide (un_App1 u) \ elementary_reduction u2" + using 1 2 u elementary_reduction_Lam_iff by force + moreover have "mtp 0 (t1 \\ u1') \ mtp 0 t1" + using 1 hgt_resid_ide [of u1' t1] + by (metis Ide.simps(3) calculation con_sym eq_refl ide_char resid_arr_ide + lambda.sel(3) prfx_implies_con subs subs.simps(4) subs_implies_prfx) + moreover have "mtp 0 (t2 \\ u2) \ mtp 0 t2" + using 1 elementary_reduction_nonincreases_mtp subs calculation(1) subs.simps(4) + by blast + ultimately show ?thesis + using 1 2 ind2 [of u2] + apply simp + by (metis Coinitial_iff_Con Ide_iff_Src_self Nat.add_0_right add_le_less_mono + ide_char Ide.simps(1) subs.simps(4) le_add1 max_nat.neutr_eq_iff + mult_less_cancel2 nat.distinct(1) neq0_conv resid_Arr_Src subs + subs_implies_prfx) + qed + ultimately show ?thesis by blast + qed + also have "... = Suc (hgt t1 + hgt t2 * max 1 (mtp 0 t1))" + by simp + also have "... = hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by simp + finally show "hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by blast + qed + moreover have "is_Beta u \ hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + fix u1 u2 + assume 0: "is_Beta u" + obtain u1 u2 where 1: "u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2" + using u 0 by (metis lambda.collapse(4)) + have "hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) = hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2))" + using 1 by simp + also have "... = hgt (subst (resid t2 u2) (resid t1 u1))" + by (metis "1" con_def con_sym null_char prfx_implies_con resid.simps(4) + subs subs_implies_prfx) + also have "... = hgt (resid t1 u1) + hgt (resid t2 u2) * mtp 0 (resid t1 u1)" + proof - + have "Arr (resid t2 u2)" + by (metis "1" Coinitial_resid_resid Con_sym Ide.simps(1) ide_char resid.simps(4) + subs subs_implies_prfx) + thus ?thesis + using hgt_Subst [of "resid t2 u2" 0 "resid t1 u1"] by simp + qed + also have "... < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + proof - + have "ide u1 \ ide u2" + using u 1 elementary_reduction_Beta_iff [of u] by auto + thus ?thesis + using 1 hgt_resid_ide + by (metis add_le_mono con_sym hgt.simps(5) resid_arr_ide less_Suc_eq_le + max.cobounded2 nat_mult_max_right prfx_implies_con subs subs.simps(5) + subs_implies_prfx) + qed + finally show "hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + by blast + qed + ultimately show "hgt ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u) < hgt (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" by blast + qed + qed + + end + + context reduction_paths + begin + + lemma length_devel_le_hgt: + shows "\t. development t U \ length U \ \.hgt t" + using \.elementary_reduction_decreases_hgt + by (induct U, auto, fastforce) + + text \ + We finally arrive at the main result of this section: + the Finite Developments Theorem. + \ + + theorem finite_developments: + shows "FD t" + using length_devel_le_hgt [of t] FD_def by auto + + subsection "Complete Developments" + + text \ + A \emph{complete development} is a development in which there are no residuals of originally + marked redexes left to contract. + \ + + definition complete_development + where "complete_development t U \ development t U \ (\.Ide t \ [t] \<^sup>*\\<^sup>* U)" + + lemma complete_development_Ide_iff: + shows "complete_development t U \ \.Ide t \ U = []" + using complete_development_def development_Ide Ide.simps(1) ide_char + by (induct t) auto + + lemma complete_development_cons: + assumes "complete_development t (u # U)" + shows "complete_development (t \\ u) U" + using assms complete_development_def + by (metis Ide.simps(1) Ide.simps(2) Resid_rec(1) Resid_rec(3) + complete_development_Ide_iff ide_char development.simps(2) + \.ide_char list.simps(3)) + + lemma complete_development_cong: + shows "\t. \complete_development t U; \ \.Ide t\ \ [t] \<^sup>*\\<^sup>* U" + using complete_development_def development_implies + by (induct U) auto + + lemma complete_developments_cong: + assumes "\ \.Ide t" and "complete_development t U" and "complete_development t V" + shows "U \<^sup>*\\<^sup>* V" + using assms complete_development_cong [of "t"] cong_symmetric cong_transitive + by blast + + lemma Trgs_complete_development: + shows "\t. \complete_development t U; \ \.Ide t\ \ Trgs U = {\.Trg t}" + using complete_development_cong Ide.simps(1) Srcs_Resid Trgs.simps(2) + Trgs_Resid_sym ide_char complete_development_def development_imp_Arr \.targets_char\<^sub>\ + apply simp + by (metis Srcs_Resid Trgs.simps(2) con_char ide_def) + + text \ + Now that we know all developments are finite, it is easy to construct a complete development + by an iterative process that at each stage contracts one of the remaining marked redexes + at each stage. It is also possible to construct a complete development by structural + induction without using the finite developments property, but it is more work to prove the + correctness. + \ + + fun (in lambda_calculus) bottom_up_redex + where "bottom_up_redex \<^bold>\ = \<^bold>\" + | "bottom_up_redex \<^bold>\x\<^bold>\ = \<^bold>\x\<^bold>\" + | "bottom_up_redex \<^bold>\\<^bold>[M\<^bold>] = \<^bold>\\<^bold>[bottom_up_redex M\<^bold>]" + | "bottom_up_redex (M \<^bold>\ N) = + (if \ Ide M then bottom_up_redex M \<^bold>\ Src N else M \<^bold>\ bottom_up_redex N)" + | "bottom_up_redex (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) = + (if \ Ide M then \<^bold>\\<^bold>[bottom_up_redex M\<^bold>] \<^bold>\ Src N + else if \ Ide N then \<^bold>\\<^bold>[M\<^bold>] \<^bold>\ bottom_up_redex N + else \<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N)" + + lemma (in lambda_calculus) elementary_reduction_bottom_up_redex: + shows "\Arr t; \ Ide t\ \ elementary_reduction (bottom_up_redex t)" + using Ide_Src + by (induct t) auto + + lemma (in lambda_calculus) subs_bottom_up_redex: + shows "Arr t \ bottom_up_redex t \ t" + apply (induct t) + apply auto[3] + apply (metis Arr.simps(4) Ide.simps(4) Ide_Src Ide_iff_Src_self Ide_implies_Arr + bottom_up_redex.simps(4) ide_char lambda.disc(14) lambda.sel(3) lambda.sel(4) + subs_App subs_Ide) + by (metis Arr.simps(5) Ide_Src Ide_iff_Src_self Ide_implies_Arr bottom_up_redex.simps(5) + ide_char subs.simps(4) subs.simps(5) subs_Ide) + + function (sequential) bottom_up_development + where "bottom_up_development t = + (if \ \.Arr t \ \.Ide t then [] + else \.bottom_up_redex t # (bottom_up_development (t \\ \.bottom_up_redex t)))" + by pat_completeness auto + + termination bottom_up_development + using \.elementary_reduction_decreases_hgt \.elementary_reduction_bottom_up_redex + \.subs_bottom_up_redex + by (relation "measure \.hgt") auto + + lemma complete_development_bottom_up_development_ind: + shows "\t. \\.Arr t; length (bottom_up_development t) \ n\ + \ complete_development t (bottom_up_development t)" + proof (induct n) + show "\t. \\.Arr t; length (bottom_up_development t) \ 0\ + \ complete_development t (bottom_up_development t)" + using complete_development_def development_Ide by auto + show "\n t. \\t. \\.Arr t; length (bottom_up_development t) \ n\ + \ complete_development t (bottom_up_development t); + \.Arr t; length (bottom_up_development t) \ Suc n\ + \ complete_development t (bottom_up_development t)" + proof - + fix n t + assume t: "\.Arr t" + assume n: "length (bottom_up_development t) \ Suc n" + assume ind: "\t. \\.Arr t; length (bottom_up_development t) \ n\ + \ complete_development t (bottom_up_development t)" + show "complete_development t (bottom_up_development t)" + proof (cases "bottom_up_development t") + show "bottom_up_development t = [] \ ?thesis" + using ind t by force + fix u U + assume uU: "bottom_up_development t = u # U" + have 1: "\.elementary_reduction u \ u \ t" + using t uU + by (metis bottom_up_development.simps \.elementary_reduction_bottom_up_redex + list.inject list.simps(3) \.subs_bottom_up_redex) + moreover have "complete_development (\.resid t u) U" + using 1 ind + by (metis Suc_le_length_iff \.arr_char \.arr_resid_iff_con bottom_up_development.simps + list.discI list.inject n not_less_eq_eq \.prfx_implies_con + \.con_sym \.subs_implies_prfx uU) + ultimately show ?thesis + by (metis Con_sym Ide.simps(2) Resid_rec(1) Resid_rec(3) + complete_development_Ide_iff complete_development_def ide_char + development.simps(2) development_implies \.ide_char list.simps(3) uU) + qed + qed + qed + + lemma complete_development_bottom_up_development: + assumes "\.Arr t" + shows "complete_development t (bottom_up_development t)" + using assms complete_development_bottom_up_development_ind by blast + + end + + section "Reduction Strategies" + + context lambda_calculus + begin + + text \ + A \emph{reduction strategy} is a function taking an identity term to an arrow having that + identity as its source. + \ + + definition reduction_strategy + where "reduction_strategy f \ (\t. Ide t \ Coinitial (f t) t)" + + text \ + The following defines the iterated application of a reduction strategy to an identity term. + \ + + fun reduce + where "reduce f a 0 = a" + | "reduce f a (Suc n) = reduce f (Trg (f a)) n" + + lemma red_reduce: + assumes "reduction_strategy f" + shows "\a. Ide a \ red a (reduce f a n)" + apply (induct n, auto) + apply (metis Ide_iff_Src_self Ide_iff_Trg_self Ide_implies_Arr red.simps) + by (metis Ide_Trg Ide_iff_Src_self assms red.intros(1) red.intros(2) reduction_strategy_def) + + text \ + A reduction strategy is \emph{normalizing} if iterated application of it to a normalizable + term eventually yields a normal form. + \ + + definition normalizing_strategy + where "normalizing_strategy f \ (\a. normalizable a \ (\n. NF (reduce f a n)))" + + end + + context reduction_paths + begin + + text \ + The following function constructs the reduction path that results by iterating the + application of a reduction strategy to a term. + \ + + fun apply_strategy + where "apply_strategy f a 0 = []" + | "apply_strategy f a (Suc n) = f a # apply_strategy f (\.Trg (f a)) n" + + lemma apply_strategy_gives_path_ind: + assumes "\.reduction_strategy f" + shows "\a. \\.Ide a; n > 0\ \ Arr (apply_strategy f a n) \ + length (apply_strategy f a n) = n \ + Src (apply_strategy f a n) = a \ + Trg (apply_strategy f a n) = \.reduce f a n" + proof (induct n, simp) + fix n a + assume ind: "\a. \\.Ide a; 0 < n\ \ Arr (apply_strategy f a n) \ + length (apply_strategy f a n) = n \ + Src (apply_strategy f a n) = a \ + Trg (apply_strategy f a n) = \.reduce f a n" + assume a: "\.Ide a" + show "Arr (apply_strategy f a (Suc n)) \ + length (apply_strategy f a (Suc n)) = Suc n \ + Src (apply_strategy f a (Suc n)) = a \ + Trg (apply_strategy f a (Suc n)) = \.reduce f a (Suc n)" + proof (intro conjI) + have 1: "\.Arr (f a) \ \.Src (f a) = a" + using assms a \.reduction_strategy_def + by (metis \.Ide_iff_Src_self) + show "Arr (apply_strategy f a (Suc n))" + using "1" Arr.elims(3) ind \.targets_char\<^sub>\ \.Ide_Trg by fastforce + show "Src (apply_strategy f a (Suc n)) = a" + by (simp add: "1") + show "length (apply_strategy f a (Suc n)) = Suc n" + by (metis "1" \.Ide_Trg One_nat_def Suc_eq_plus1 ind list.size(3) list.size(4) + neq0_conv apply_strategy.simps(1) apply_strategy.simps(2)) + show "Trg (apply_strategy f a (Suc n)) = \.reduce f a (Suc n)" + proof (cases "apply_strategy f (\.Trg (f a)) n = []") + show "apply_strategy f (\.Trg (f a)) n = [] \ ?thesis" + using a 1 ind [of "\.Trg (f a)"] \.Ide_Trg \.targets_char\<^sub>\ by force + assume 2: "apply_strategy f (\.Trg (f a)) n \ []" + have "Trg (apply_strategy f a (Suc n)) = Trg (apply_strategy f (\.Trg (f a)) n)" + using a 1 ind [of "\.Trg (f a)"] + by (simp add: "2") + also have "... = \.reduce f a (Suc n)" + using 1 2 \.Ide_Trg ind [of "\.Trg (f a)"] by fastforce + finally show ?thesis by blast + qed + qed + qed + + lemma apply_strategy_gives_path: + assumes "\.reduction_strategy f" and "\.Ide a" and "n > 0" + shows "Arr (apply_strategy f a n)" + and "length (apply_strategy f a n) = n" + and "Src (apply_strategy f a n) = a" + and "Trg (apply_strategy f a n) = \.reduce f a n" + using assms apply_strategy_gives_path_ind by auto + + lemma reduce_eq_Trg_apply_strategy: + assumes "\.reduction_strategy S" and "\.Ide a" + shows "n > 0 \ \.reduce S a n = Trg (apply_strategy S a n)" + using assms + apply (induct n) + apply simp_all + by (metis Arr.simps(1) Trg_simp apply_strategy_gives_path_ind \.Ide_Trg + \.reduce.simps(1) \.reduction_strategy_def \.trg_char neq0_conv + apply_strategy.simps(1)) + + end + + subsection "Parallel Reduction" + + context lambda_calculus + begin + + text \ + \emph{Parallel reduction} is the strategy that contracts all available redexes at each step. + \ + + fun parallel_strategy + where "parallel_strategy \<^bold>\i\<^bold>\ = \<^bold>\i\<^bold>\" + | "parallel_strategy \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[parallel_strategy t\<^bold>]" + | "parallel_strategy (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[parallel_strategy t\<^bold>] \<^bold>\ parallel_strategy u" + | "parallel_strategy (t \<^bold>\ u) = parallel_strategy t \<^bold>\ parallel_strategy u" + | "parallel_strategy (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[parallel_strategy t\<^bold>] \<^bold>\ parallel_strategy u" + | "parallel_strategy \<^bold>\ = \<^bold>\" + + lemma parallel_strategy_is_reduction_strategy: + shows "reduction_strategy parallel_strategy" + proof (unfold reduction_strategy_def, intro allI impI) + fix t + show "Ide t \ Coinitial (parallel_strategy t) t" + using Ide_implies_Arr + apply (induct t, auto) + by force+ + qed + + lemma parallel_strategy_Src_eq: + shows "Arr t \ parallel_strategy (Src t) = parallel_strategy t" + by (induct t) auto + + lemma subs_parallel_strategy_Src: + shows "Arr t \ t \ parallel_strategy (Src t)" + by (induct t) auto + + end + + context reduction_paths + begin + + text \ + Parallel reduction is a universal strategy in the sense that every reduction path is + \\<^sup>*\\<^sup>*\-below the path generated by the parallel reduction strategy. + \ + + lemma parallel_strategy_is_universal: + shows "\U. \n > 0; n \ length U; Arr U\ + \ take n U \<^sup>*\\<^sup>* apply_strategy \.parallel_strategy (Src U) n" + proof (induct n, simp) + fix n a and U :: "\.lambda list" + assume n: "Suc n \ length U" + assume U: "Arr U" + assume ind: "\U. \0 < n; n \ length U; Arr U\ + \ take n U \<^sup>*\\<^sup>* apply_strategy \.parallel_strategy (Src U) n" + have 1: "take (Suc n) U = hd U # take n (tl U)" + by (metis U Arr.simps(1) take_Suc) + have 2: "hd U \ \.parallel_strategy (Src U)" + by (metis Arr_imp_arr_hd Con_single_ideI(2) Resid_Arr_Src Src_resid Srcs_simp\<^sub>\\<^sub>P + Trg.simps(2) U \.source_is_ide \.trg_ide empty_set \.arr_char \.sources_char\<^sub>\ + \.subs_parallel_strategy_Src list.set_intros(1) list.simps(15)) + show "take (Suc n) U \<^sup>*\\<^sup>* apply_strategy \.parallel_strategy (Src U) (Suc n)" + proof (cases "apply_strategy \.parallel_strategy (Src U) (Suc n)") + show "apply_strategy \.parallel_strategy (Src U) (Suc n) = [] \ + take (Suc n) U \<^sup>*\\<^sup>* apply_strategy \.parallel_strategy (Src U) (Suc n)" + by simp + fix v V + assume 3: "apply_strategy \.parallel_strategy (Src U) (Suc n) = v # V" + show "take (Suc n) U \<^sup>*\\<^sup>* apply_strategy \.parallel_strategy (Src U) (Suc n)" + proof (cases "V = []") + show "V = [] \ ?thesis" + using 1 2 3 ind ide_char + by (metis Suc_inject Ide.simps(2) Resid.simps(3) list.discI list.inject + \.prfx_implies_con apply_strategy.elims \.subs_implies_prfx take0) + assume V: "V \ []" + have 4: "Arr (v # V)" + using 3 apply_strategy_gives_path(1) + by (metis Arr_imp_arr_hd Srcs_simp\<^sub>P\<^sub>W\<^sub>E Srcs_simp\<^sub>\\<^sub>P U \.Ide_Src \.arr_iff_has_target + \.parallel_strategy_is_reduction_strategy \.targets_char\<^sub>\ singleton_insert_inj_eq' + zero_less_Suc) + have 5: "Arr (hd U # take n (tl U))" + by (metis 1 U Arr_append_iff\<^sub>P id_take_nth_drop list.discI not_less take_all_iff) + have 6: "Srcs (hd U # take n (tl U)) = Srcs (v # V)" + by (metis 2 3 \.Coinitial_iff_Con \.Ide.simps(1) Srcs.simps(2) Srcs.simps(3) + \.ide_char list.exhaust_sel list.inject apply_strategy.simps(2) \.sources_char\<^sub>\ + \.subs_implies_prfx) + have "take (Suc n) U \<^sup>*\\\<^sup>* apply_strategy \.parallel_strategy (Src U) (Suc n) = + [hd U \\ v] \<^sup>*\\\<^sup>* V @ (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* [hd U \\ v])" + using U V 1 3 4 5 6 + by (metis Resid.simps(1) Resid_cons(1) Resid_rec(3-4) confluence_ind) + moreover have "Ide ..." + proof + have 7: "v = \.parallel_strategy (Src U) \ + V = apply_strategy \.parallel_strategy (Src U \\ v) n" + using 3 \.subs_implies_prfx \.subs_parallel_strategy_Src + apply simp + by (metis (full_types) \.Coinitial_iff_Con \.Ide.simps(1) \.Trg.simps(5) + \.parallel_strategy.simps(9) \.resid_Src_Arr) + show 8: "Ide ([hd U \\ v] \<^sup>*\\\<^sup>* V)" + by (metis 2 4 5 6 7 V Con_initial_left Ide.simps(2) + confluence_ind Con_rec(3) Resid_Ide_Arr_ind \.subs_implies_prfx) + show 9: "Ide ((take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* [hd U \\ v]))" + proof - + have 10: "\.Ide (hd U \\ v)" + using 2 7 \.ide_char \.subs_implies_prfx by presburger + have 11: "V = apply_strategy \.parallel_strategy (\.Trg v) n" + using 3 by auto + have "(take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* [hd U \\ v]) = + (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) \<^sup>*\\\<^sup>* + apply_strategy \.parallel_strategy (\.Trg v) n" + by (metis 8 10 11 Ide.simps(1) Resid_single_ide(2) \.prfx_char) + moreover have "Ide ..." + proof - + have "Ide (take n (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) \<^sup>*\\\<^sup>* + apply_strategy \.parallel_strategy (\.Trg v) n)" + proof - + have "0 < n" + proof - + have "length V = n" + using apply_strategy_gives_path + by (metis 10 11 V \.Coinitial_iff_Con \.Ide_Trg \.Arr_not_Nil + \.Ide_implies_Arr \.parallel_strategy_is_reduction_strategy neq0_conv + apply_strategy.simps(1)) + thus ?thesis + using V by blast + qed + moreover have "n \ length (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U])" + proof - + have "length (take n (tl U)) = n" + using n by force + thus ?thesis + using n U length_Resid [of "take n (tl U)" "[v \\ hd U]"] + by (metis 4 5 6 Arr.simps(1) Con_cons(2) Con_rec(2) + confluence_ind dual_order.eq_iff) + qed + moreover have "\.Trg v = Src (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U])" + proof - + have "Src (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) = Trg [v \\ hd U]" + by (metis Src_resid calculation(1-2) linorder_not_less list.size(3)) + also have "... = \.Trg v" + by (metis 10 Trg.simps(2) \.Arr_not_Nil \.apex_sym \.trg_ide + \.Ide_iff_Src_self \.Ide_implies_Arr \.Src_resid \.prfx_char) + finally show ?thesis by simp + qed + ultimately show ?thesis + using ind [of "Resid (take n (tl U)) [\.resid v (hd U)]"] ide_char + by (metis Con_imp_Arr_Resid le_zero_eq less_not_refl list.size(3)) + qed + moreover have "take n (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) = + take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]" + proof - + have "Arr (take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U])" + by (metis Con_imp_Arr_Resid Con_implies_Arr(1) Ide.simps(1) calculation + take_Nil) + thus ?thesis + by (metis 1 Arr.simps(1) length_Resid dual_order.eq_iff length_Cons + length_take min.absorb2 n old.nat.inject take_all) + qed + ultimately show ?thesis by simp + qed + ultimately show ?thesis by auto + qed + show "Trg ([hd U \\ v] \<^sup>*\\\<^sup>* V) = + Src ((take n (tl U) \<^sup>*\\\<^sup>* [v \\ hd U]) \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* [hd U \\ v]))" + by (metis 9 Ide.simps(1) Src_resid Trg_resid_sym) + qed + ultimately show ?thesis + using ide_char by presburger + qed + qed + qed + + end + + context lambda_calculus + begin + + text \ + Parallel reduction is a normalizing strategy. + \ + + lemma parallel_strategy_is_normalizing: + shows "normalizing_strategy parallel_strategy" + proof - + interpret \x: reduction_paths . + (* TODO: Notation is not inherited here. *) + have "\a. normalizable a \ \n. NF (reduce parallel_strategy a n)" + proof - + fix a + assume 1: "normalizable a" + obtain U b where U: "\x.Arr U \ \x.Src U = a \ \x.Trg U = b \ NF b" + using 1 normalizable_def \x.red_iff by blast + have 2: "\n. \0 < n; n \ length U\ + \ \x.Ide (\x.Resid (take n U) (\x.apply_strategy parallel_strategy a n))" + using U \x.parallel_strategy_is_universal \x.ide_char by blast + let ?PR = "\x.apply_strategy parallel_strategy a (length U)" + have "\x.Trg ?PR = b" + proof - + have 3: "\x.Ide (\x.Resid U ?PR)" + using U 2 [of "length U"] by force + have "\x.Trg (\x.Resid ?PR U) = b" + by (metis "3" NF_reduct_is_trivial U \x.Con_imp_Arr_Resid \x.Con_sym \x.Ide.simps(1) + \x.Src_resid reduction_paths.red_iff) + thus ?thesis + by (metis 3 \x.Con_Arr_self \x.Ide_implies_Arr \x.Resid_Arr_Ide_ind + \x.Src_resid \x.Trg_resid_sym) + qed + hence "reduce parallel_strategy a (length U) = b" + using 1 U + by (metis \x.Arr.simps(1) length_greater_0_conv normalizable_def + \x.apply_strategy_gives_path(4) parallel_strategy_is_reduction_strategy) + thus "\n. NF (reduce parallel_strategy a n)" + using U by blast + qed + thus ?thesis + using normalizing_strategy_def by blast + qed + + text \ + An alternative characterization of a normal form is a term on which the parallel + reduction strategy yields an identity. + \ + + abbreviation has_redex + where "has_redex t \ Arr t \ \ Ide (parallel_strategy t)" + + lemma NF_iff_has_no_redex: + shows "Arr t \ NF t \ \ has_redex t" + proof (induct t) + show "Arr \<^bold>\ \ NF \<^bold>\ \ \ has_redex \<^bold>\" + using NF_def by simp + show "\x. Arr \<^bold>\x\<^bold>\ \ NF \<^bold>\x\<^bold>\ \ \ has_redex \<^bold>\x\<^bold>\" + using NF_def by force + show "\t. \Arr t \ NF t \ \ has_redex t; Arr \<^bold>\\<^bold>[t\<^bold>]\ \ NF \<^bold>\\<^bold>[t\<^bold>] \ \ has_redex \<^bold>\\<^bold>[t\<^bold>]" + proof - + fix t + assume ind: "Arr t \ NF t \ \ has_redex t" + assume t: "Arr \<^bold>\\<^bold>[t\<^bold>]" + show "NF \<^bold>\\<^bold>[t\<^bold>] \ \ has_redex \<^bold>\\<^bold>[t\<^bold>]" + proof + show "NF \<^bold>\\<^bold>[t\<^bold>] \ \ has_redex \<^bold>\\<^bold>[t\<^bold>]" + using t ind + by (metis NF_def Arr.simps(3) Ide.simps(3) Src.simps(3) parallel_strategy.simps(2)) + show "\ has_redex \<^bold>\\<^bold>[t\<^bold>] \ NF \<^bold>\\<^bold>[t\<^bold>]" + using t ind + by (metis NF_def ide_backward_stable ide_char parallel_strategy_Src_eq + subs_implies_prfx subs_parallel_strategy_Src) + qed + qed + show "\t1 t2. \Arr t1 \ NF t1 \ \ has_redex t1; + Arr t2 \ NF t2 \ \ has_redex t2; + Arr (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)\ + \ NF (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \ \ has_redex (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + using NF_def Ide.simps(5) parallel_strategy.simps(8) by presburger + show "\t1 t2. \Arr t1 \ NF t1 \ \ has_redex t1; + Arr t2 \ NF t2 \ \ has_redex t2; + Arr (t1 \<^bold>\ t2)\ + \ NF (t1 \<^bold>\ t2) \ \ has_redex (t1 \<^bold>\ t2)" + proof - + fix t1 t2 + assume ind1: "Arr t1 \ NF t1 \ \ has_redex t1" + assume ind2: "Arr t2 \ NF t2 \ \ has_redex t2" + assume t: "Arr (t1 \<^bold>\ t2)" + show "NF (t1 \<^bold>\ t2) \ \ has_redex (t1 \<^bold>\ t2)" + using t ind1 ind2 NF_def + apply (intro iffI) + apply (metis Ide_iff_Src_self parallel_strategy_is_reduction_strategy + reduction_strategy_def) + apply (cases t1) + apply simp_all + apply (metis Ide_iff_Src_self ide_char parallel_strategy.simps(1,5) + parallel_strategy_is_reduction_strategy reduction_strategy_def resid_Arr_Src + subs_implies_prfx subs_parallel_strategy_Src) + by (metis Ide_iff_Src_self ide_char ind1 Arr.simps(4) parallel_strategy.simps(6) + parallel_strategy_is_reduction_strategy reduction_strategy_def resid_Arr_Src + subs_implies_prfx subs_parallel_strategy_Src) + qed + qed + + lemma (in lambda_calculus) not_NF_elim: + assumes "\ NF t" and "Ide t" + obtains u where "coinitial t u \ \ Ide u" + using assms NF_def by auto + + lemma (in lambda_calculus) NF_Lam_iff: + shows "NF \<^bold>\\<^bold>[t\<^bold>] \ NF t" + using NF_def + by (metis Ide_implies_Arr NF_iff_has_no_redex Ide.simps(3) parallel_strategy.simps(2)) + + lemma (in lambda_calculus) NF_App_iff: + shows "NF (t1 \<^bold>\ t2) \ \ is_Lam t1 \ NF t1 \ NF t2" + proof - + have "\ NF (t1 \<^bold>\ t2) \ is_Lam t1 \ \ NF t1 \ \ NF t2" + apply (cases "is_Lam t1") + apply simp_all + apply (cases t1) + apply simp_all + using NF_def Ide.simps(1) apply presburger + apply (metis Ide_implies_Arr NF_def NF_iff_has_no_redex Ide.simps(4) + parallel_strategy.simps(5)) + apply (metis Ide_implies_Arr NF_def NF_iff_has_no_redex Ide.simps(4) + parallel_strategy.simps(6)) + using NF_def Ide.simps(5) by presburger + moreover have "is_Lam t1 \ \ NF t1 \ \ NF t2 \ \ NF (t1 \<^bold>\ t2)" + proof - + have "is_Lam t1 \ \NF (t1 \<^bold>\ t2)" + by (metis Ide_implies_Arr NF_def NF_iff_has_no_redex Ide.simps(5) lambda.collapse(2) + parallel_strategy.simps(3,8)) + moreover have "\ NF t1 \ \NF (t1 \<^bold>\ t2)" + using NF_def Ide_iff_Src_self Ide_implies_Arr + apply auto + by (metis (full_types) Arr.simps(4) Ide.simps(4) Src.simps(4)) + moreover have "\ NF t2 \ \NF (t1 \<^bold>\ t2)" + using NF_def Ide_iff_Src_self Ide_implies_Arr + apply auto + by (metis (full_types) Arr.simps(4) Ide.simps(4) Src.simps(4)) + ultimately show "is_Lam t1 \ \ NF t1 \ \ NF t2 \ \ NF (t1 \<^bold>\ t2)" + by auto + qed + ultimately show ?thesis by blast + qed + + subsection "Head Reduction" + + text \ + \emph{Head reduction} is the strategy that only contracts a redex at the ``head'' position, + which is found at the end of the ``left spine'' of applications, and does nothing if there is + no such redex. + + The following function applies to an arbitrary arrow \t\, and it marks the redex at + the head position, if any, otherwise it yields \Src t\. + \ + + fun head_strategy + where "head_strategy \<^bold>\i\<^bold>\ = \<^bold>\i\<^bold>\" + | "head_strategy \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[head_strategy t\<^bold>]" + | "head_strategy (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u" + | "head_strategy (t \<^bold>\ u) = head_strategy t \<^bold>\ Src u" + | "head_strategy (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u" + | "head_strategy \<^bold>\ = \<^bold>\" + + lemma Arr_head_strategy: + shows "Arr t \ Arr (head_strategy t)" + apply (induct t) + apply auto + proof - + fix t u + assume ind: "Arr (head_strategy t)" + assume t: "Arr t" and u: "Arr u" + show "Arr (head_strategy (t \<^bold>\ u))" + using t u ind + by (cases t) auto + qed + + lemma Src_head_strategy: + shows "Arr t \ Src (head_strategy t) = Src t" + apply (induct t) + apply auto + proof - + fix t u + assume ind: "Src (head_strategy t) = Src t" + assume t: "Arr t" and u: "Arr u" + have "Src (head_strategy (t \<^bold>\ u)) = Src (head_strategy t \<^bold>\ Src u)" + using t ind + by (cases t) auto + also have "... = Src t \<^bold>\ Src u" + using t u ind by auto + finally show "Src (head_strategy (t \<^bold>\ u)) = Src t \<^bold>\ Src u" by simp + qed + + lemma Con_head_strategy: + shows "Arr t \ Con t (head_strategy t)" + apply (induct t) + apply auto + apply (simp add: Arr_head_strategy Src_head_strategy) + using Arr_Subst Arr_not_Nil by auto + + lemma head_strategy_Src: + shows "Arr t \ head_strategy (Src t) = head_strategy t" + apply (induct t) + apply auto + using Arr.elims(2) by fastforce + + lemma head_strategy_is_elementary: + shows "\Arr t; \ Ide (head_strategy t)\ \ elementary_reduction (head_strategy t)" + using Ide_Src + apply (induct t) + apply auto + proof - + fix t1 t2 + assume t1: "Arr t1" and t2: "Arr t2" + assume t: "\ Ide (head_strategy (t1 \<^bold>\ t2))" + assume 1: "\ Ide (head_strategy t1) \ elementary_reduction (head_strategy t1)" + assume 2: "\ Ide (head_strategy t2) \ elementary_reduction (head_strategy t2)" + show "elementary_reduction (head_strategy (t1 \<^bold>\ t2))" + using t t1 t2 1 2 Ide_Src Ide_implies_Arr + by (cases t1) auto + qed + + lemma head_strategy_is_reduction_strategy: + shows "reduction_strategy head_strategy" + proof (unfold reduction_strategy_def, intro allI impI) + fix t + show "Ide t \ Coinitial (head_strategy t) t" + proof (induct t) + show "Ide \<^bold>\ \ Coinitial (head_strategy \<^bold>\) \<^bold>\" + by simp + show "\x. Ide \<^bold>\x\<^bold>\ \ Coinitial (head_strategy \<^bold>\x\<^bold>\) \<^bold>\x\<^bold>\" + by simp + show "\t. \Ide t \ Coinitial (head_strategy t) t; Ide \<^bold>\\<^bold>[t\<^bold>]\ + \ Coinitial (head_strategy \<^bold>\\<^bold>[t\<^bold>]) \<^bold>\\<^bold>[t\<^bold>]" + by simp + fix t1 t2 + assume ind1: "Ide t1 \ Coinitial (head_strategy t1) t1" + assume ind2: "Ide t2 \ Coinitial (head_strategy t2) t2" + assume t: "Ide (t1 \<^bold>\ t2)" + show "Coinitial (head_strategy (t1 \<^bold>\ t2)) (t1 \<^bold>\ t2)" + using t ind1 Ide_implies_Arr Ide_iff_Src_self + by (cases t1) simp_all + next + fix t1 t2 + assume ind1: "Ide t1 \ Coinitial (head_strategy t1) t1" + assume ind2: "Ide t2 \ Coinitial (head_strategy t2) t2" + assume t: "Ide (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + show "Coinitial (head_strategy (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + using t by auto + qed + qed + + text \ + The following function tests whether a term is an elementary reduction of the head redex. + \ + + fun is_head_reduction + where "is_head_reduction \<^bold>\_\<^bold>\ \ False" + | "is_head_reduction \<^bold>\\<^bold>[t\<^bold>] \ is_head_reduction t" + | "is_head_reduction (\<^bold>\\<^bold>[_\<^bold>] \<^bold>\ _) \ False" + | "is_head_reduction (t \<^bold>\ u) \ is_head_reduction t \ Ide u" + | "is_head_reduction (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ Ide t \ Ide u" + | "is_head_reduction \<^bold>\ \ False" + + lemma is_head_reduction_char: + shows "is_head_reduction t \ elementary_reduction t \ head_strategy (Src t) = t" + apply (induct t) + apply simp_all + proof - + fix t1 t2 + assume ind: "is_head_reduction t1 \ + elementary_reduction t1 \ head_strategy (Src t1) = t1" + show "is_head_reduction (t1 \<^bold>\ t2) \ + (elementary_reduction t1 \ Ide t2 \ Ide t1 \ elementary_reduction t2) \ + head_strategy (Src t1 \<^bold>\ Src t2) = t1 \<^bold>\ t2" + using ind Ide_implies_Arr Ide_iff_Src_self Ide_Src elementary_reduction_not_ide + ide_char + apply (cases t1) + apply simp_all + apply (metis Ide_Src arr_char elementary_reduction_is_arr) + apply (metis Ide_Src arr_char elementary_reduction_is_arr) + by metis + next + fix t1 t2 + show "Ide t1 \ Ide t2 \ Ide t1 \ Ide t2 \ Src (Src t1) = t1 \ Src (Src t2) = t2" + by (metis Ide_iff_Src_self Ide_implies_Arr) + qed + + lemma is_head_reductionI: + assumes "Arr t" and "elementary_reduction t" and "head_strategy (Src t) = t" + shows "is_head_reduction t" + using assms is_head_reduction_char by blast + + text \ + The following function tests whether a redex in the head position of a term is marked. + \ + + fun contains_head_reduction + where "contains_head_reduction \<^bold>\_\<^bold>\ \ False" + | "contains_head_reduction \<^bold>\\<^bold>[t\<^bold>] \ contains_head_reduction t" + | "contains_head_reduction (\<^bold>\\<^bold>[_\<^bold>] \<^bold>\ _) \ False" + | "contains_head_reduction (t \<^bold>\ u) \ contains_head_reduction t \ Arr u" + | "contains_head_reduction (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ Arr t \ Arr u" + | "contains_head_reduction \<^bold>\ \ False" + + lemma is_head_reduction_imp_contains_head_reduction: + shows "is_head_reduction t \ contains_head_reduction t" + using Ide_implies_Arr + apply (induct t) + apply auto + proof - + fix t1 t2 + assume ind1: "is_head_reduction t1 \ contains_head_reduction t1" + assume ind2: "is_head_reduction t2 \ contains_head_reduction t2" + assume t: "is_head_reduction (t1 \<^bold>\ t2)" + show "contains_head_reduction (t1 \<^bold>\ t2)" + using t ind1 ind2 Ide_implies_Arr + by (cases t1) auto + qed + + text \ + An \emph{internal reduction} is one that does not contract any redex at the head position. + \ + + fun is_internal_reduction + where "is_internal_reduction \<^bold>\_\<^bold>\ \ True" + | "is_internal_reduction \<^bold>\\<^bold>[t\<^bold>] \ is_internal_reduction t" + | "is_internal_reduction (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ Arr t \ Arr u" + | "is_internal_reduction (t \<^bold>\ u) \ is_internal_reduction t \ Arr u" + | "is_internal_reduction (\<^bold>\\<^bold>[_\<^bold>] \<^bold>\ _) \ False" + | "is_internal_reduction \<^bold>\ \ False" + + lemma is_internal_reduction_iff: + shows "is_internal_reduction t \ Arr t \ \ contains_head_reduction t" + apply (induct t) + apply simp_all + proof - + fix t1 t2 + assume ind1: "is_internal_reduction t1 \ Arr t1 \ \ contains_head_reduction t1" + assume ind2: "is_internal_reduction t2 \ Arr t2 \ \ contains_head_reduction t2" + show "is_internal_reduction (t1 \<^bold>\ t2) \ + Arr t1 \ Arr t2 \ \ contains_head_reduction (t1 \<^bold>\ t2)" + using ind1 ind2 + apply (cases t1) + apply simp_all + by blast + qed + + text \ + Head reduction steps are either \\\-prefixes of, or are preserved by, residuation along + arbitrary reductions. + \ + + lemma is_head_reduction_resid: + shows "\u. \is_head_reduction t; Arr u; Src t = Src u\ + \ t \ u \ is_head_reduction (t \\ u)" + proof (induct t) + show "\u. \is_head_reduction \<^bold>\; Arr u; Src \<^bold>\ = Src u\ + \ \<^bold>\ \ u \ is_head_reduction (\<^bold>\ \\ u)" + by auto + show "\x u. \is_head_reduction \<^bold>\x\<^bold>\; Arr u; Src \<^bold>\x\<^bold>\ = Src u\ + \ \<^bold>\x\<^bold>\ \ u \ is_head_reduction (\<^bold>\x\<^bold>\ \\ u)" + by auto + fix t u + assume ind: "\u. \is_head_reduction t; Arr u; Src t = Src u\ + \ t \ u \ is_head_reduction (t \\ u)" + assume t: "is_head_reduction \<^bold>\\<^bold>[t\<^bold>]" + assume u: "Arr u" + assume tu: "Src \<^bold>\\<^bold>[t\<^bold>] = Src u" + have 1: "Arr t" + by (metis Arr_head_strategy head_strategy_Src is_head_reduction_char Arr.simps(3) t tu u) + show " \<^bold>\\<^bold>[t\<^bold>] \ u \ is_head_reduction (\<^bold>\\<^bold>[t\<^bold>] \\ u)" + using t u tu 1 ind + by (cases u) auto + next + fix t1 t2 u + assume ind1: "\u1. \is_head_reduction t1; Arr u1; Src t1 = Src u1\ + \ t1 \ u1 \ is_head_reduction (t1 \\ u1)" + assume ind2: "\u2. \is_head_reduction t2; Arr u2; Src t2 = Src u2\ + \ t2 \ u2 \ is_head_reduction (t2 \\ u2)" + assume t: "is_head_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + assume u: "Arr u" + assume tu: "Src (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) = Src u" + show "\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 \ u \ is_head_reduction ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u)" + using t u tu ind1 ind2 Coinitial_iff_Con Ide_implies_Arr ide_char resid_Ide_Arr Ide_Subst + by (cases u; cases "un_App1 u") auto + next + fix t1 t2 u + assume ind1: "\u1. \is_head_reduction t1; Arr u1; Src t1 = Src u1\ + \ t1 \ u1 \ is_head_reduction (t1 \\ u1)" + assume ind2: "\u2. \is_head_reduction t2; Arr u2; Src t2 = Src u2\ + \ t2 \ u2 \ is_head_reduction (t2 \\ u2)" + assume t: "is_head_reduction (t1 \<^bold>\ t2)" + assume u: "Arr u" + assume tu: "Src (t1 \<^bold>\ t2) = Src u" + have "Arr (t1 \<^bold>\ t2)" + using is_head_reduction_char elementary_reduction_is_arr t by blast + hence t1: "Arr t1" and t2: "Arr t2" + by auto + have 0: "\ is_Lam t1" + using t is_Lam_def by fastforce + have 1: "is_head_reduction t1" + using t t1 by force + show "t1 \<^bold>\ t2 \ u \ is_head_reduction ((t1 \<^bold>\ t2) \\ u) " + proof - + have "\ Ide ((t1 \<^bold>\ t2) \\ u) \ is_head_reduction ((t1 \<^bold>\ t2) \\ u)" + proof (intro is_head_reductionI) + assume 2: "\ Ide ((t1 \<^bold>\ t2) \\ u)" + have 3: "is_App u \ \ Ide (t1 \\ un_App1 u) \ \ Ide (t2 \\ un_App2 u)" + by (metis "2" ide_char lambda.collapse(3) lambda.discI(3) lambda.sel(3-4) prfx_App_iff) + have 4: "is_Beta u \ \ Ide (t1 \\ un_Beta1 u) \ \ Ide (t2 \\ un_Beta2 u)" + using u tu 2 + by (metis "0" ConI Con_implies_is_Lam_iff_is_Lam \Arr (t1 \<^bold>\ t2)\ + ConD(4) lambda.collapse(4) lambda.disc(8)) + show 5: "Arr ((t1 \<^bold>\ t2) \\ u)" + using Arr_resid \Arr (t1 \<^bold>\ t2)\ tu u by auto + show "head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + proof (cases u) + show "u = \<^bold>\ \ head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + by simp + show "\x. u = \<^bold>\x\<^bold>\ \ head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + by auto + show "\v. u = \<^bold>\\<^bold>[v\<^bold>] \ head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + by simp + show "\u1 u2. u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2 \ head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + by (metis "0" "5" Arr_not_Nil ConD(4) Con_implies_is_Lam_iff_is_Lam lambda.disc(8)) + show "\u1 u2. u = App u1 u2 \ head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + proof - + fix u1 u2 + assume u1u2: "u = u1 \<^bold>\ u2" + have "head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = + head_strategy (Src (t1 \\ u1) \<^bold>\ Src (t2 \\ u2))" + using u u1u2 tu t1 t2 Coinitial_iff_Con by auto + also have "... = head_strategy (Trg u1 \<^bold>\ Trg u2)" + using 5 u1u2 Src_resid + by (metis Arr_not_Nil ConD(1)) + also have "... = (t1 \<^bold>\ t2) \\ u" + proof (cases "Trg u1") + show "Trg u1 = \<^bold>\ \ head_strategy (Trg u1 \<^bold>\ Trg u2) = (t1 \<^bold>\ t2) \\ u" + using Arr_not_Nil u u1u2 by force + show "\x. Trg u1 = \<^bold>\x\<^bold>\ \ head_strategy (Trg u1 \<^bold>\ Trg u2) = (t1 \<^bold>\ t2) \\ u" + using tu t u t1 t2 u1u2 Arr_not_Nil Ide_iff_Src_self + by (cases u1; cases t1) auto + show "\v. Trg u1 = \<^bold>\\<^bold>[v\<^bold>] \ head_strategy (Trg u1 \<^bold>\ Trg u2) = (t1 \<^bold>\ t2) \\ u" + using tu t u t1 t2 u1u2 Arr_not_Nil Ide_iff_Src_self + apply (cases u1; cases t1) + apply auto + by (metis 2 5 Src_resid Trg.simps(3-4) resid.simps(3-4) resid_Src_Arr) + show "\u11 u12. Trg u1 = u11 \<^bold>\ u12 + \ head_strategy (Trg u1 \<^bold>\ Trg u2) = (t1 \<^bold>\ t2) \\ u" + proof - + fix u11 u12 + assume u1: "Trg u1 = u11 \<^bold>\ u12" + show "head_strategy (Trg u1 \<^bold>\ Trg u2) = (t1 \<^bold>\ t2) \\ u" + proof (cases "Trg u1") + show "Trg u1 = \<^bold>\ \ ?thesis" + using u1 by simp + show "\x. Trg u1 = \<^bold>\x\<^bold>\ \ ?thesis" + apply simp + using u1 by force + show "\v. Trg u1 = \<^bold>\\<^bold>[v\<^bold>] \ ?thesis" + using u1 by simp + show "\u11 u12. Trg u1 = u11 \<^bold>\ u12 \ ?thesis" + using t u tu u1u2 1 2 ind1 elementary_reduction_not_ide + is_head_reduction_char Src_resid Ide_iff_Src_self + \Arr (t1 \<^bold>\ t2)\ Coinitial_iff_Con + by fastforce + show "\u11 u12. Trg u1 = \<^bold>\\<^bold>[u11\<^bold>] \<^bold>\ u12 \ ?thesis" + using u1 by simp + qed + qed + show "\u11 u12. Trg u1 = \<^bold>\\<^bold>[u11\<^bold>] \<^bold>\ u12 \ ?thesis" + using u1u2 u Ide_Trg by fastforce + qed + finally show "head_strategy (Src ((t1 \<^bold>\ t2) \\ u)) = (t1 \<^bold>\ t2) \\ u" + by simp + qed + qed + thus "elementary_reduction ((t1 \<^bold>\ t2) \\ u)" + by (metis 2 5 Ide_Src Ide_implies_Arr head_strategy_is_elementary) + qed + thus ?thesis by blast + qed + qed + + text \ + Internal reductions are closed under residuation. + \ + + lemma is_internal_reduction_resid: + shows "\u. \is_internal_reduction t; is_internal_reduction u; Src t = Src u\ + \ is_internal_reduction (t \\ u)" + apply (induct t) + apply auto + apply (metis Con_implies_Arr2 con_char weak_extensionality Arr.simps(2) Src.simps(2) + parallel_strategy.simps(1) prfx_implies_con resid_Arr_Src subs_Ide + subs_implies_prfx subs_parallel_strategy_Src) + proof - + fix t u + assume ind: "\u. \is_internal_reduction u; Src t = Src u\ \ is_internal_reduction (t \\ u)" + assume t: "is_internal_reduction t" + assume u: "is_internal_reduction u" + assume tu: "\<^bold>\\<^bold>[Src t\<^bold>] = Src u" + show "is_internal_reduction (\<^bold>\\<^bold>[t\<^bold>] \\ u)" + using t u tu ind + apply (cases u) + by auto fastforce + next + fix t1 t2 u + assume ind1: "\u. \is_internal_reduction t1; is_internal_reduction u; Src t1 = Src u\ + \ is_internal_reduction (t1 \\ u)" + assume t: "is_internal_reduction (t1 \<^bold>\ t2)" + assume u: "is_internal_reduction u" + assume tu: "Src t1 \<^bold>\ Src t2 = Src u" + show "is_internal_reduction ((t1 \<^bold>\ t2) \\ u)" + using t u tu ind1 Coinitial_resid_resid Coinitial_iff_Con Arr_Src + is_internal_reduction_iff + apply auto + apply (metis Arr.simps(4) Src.simps(4)) + proof - + assume t1: "Arr t1" and t2: "Arr t2" and u: "Arr u" + assume tu: "Src t1 \<^bold>\ Src t2 = Src u" + assume 1: "\ contains_head_reduction u" + assume 2: "\ contains_head_reduction (t1 \<^bold>\ t2)" + assume 3: "contains_head_reduction ((t1 \<^bold>\ t2) \\ u)" + show False + using t1 t2 u tu 1 2 3 is_internal_reduction_iff + apply (cases u) + apply simp_all + apply (cases t1; cases "un_App1 u") + apply simp_all + by (metis Coinitial_iff_Con ind1 Arr.simps(4) Src.simps(4) resid.simps(3)) + qed + qed + + text \ + A head reduction is preserved by residuation along an internal reduction, + so a head reduction can only be canceled by a transition that contains a head reduction. + \ + + lemma is_head_reduction_resid': + shows "\u. \is_head_reduction t; is_internal_reduction u; Src t = Src u\ + \ is_head_reduction (t \\ u)" + proof (induct t) + show "\u. \is_head_reduction \<^bold>\; is_internal_reduction u; Src \<^bold>\ = Src u\ + \ is_head_reduction (\<^bold>\ \\ u)" + by simp + show "\x u. \is_head_reduction \<^bold>\x\<^bold>\; is_internal_reduction u; Src \<^bold>\x\<^bold>\ = Src u\ + \ is_head_reduction (\<^bold>\x\<^bold>\ \\ u)" + by simp + show "\t. \\u. \is_head_reduction t; is_internal_reduction u; Src t = Src u\ + \ is_head_reduction (t \\ u); + is_head_reduction \<^bold>\\<^bold>[t\<^bold>]; is_internal_reduction u; Src \<^bold>\\<^bold>[t\<^bold>] = Src u\ + \ is_head_reduction (\<^bold>\\<^bold>[t\<^bold>] \\ u)" + for u + by (cases u, simp_all) fastforce + fix t1 t2 u + assume ind1: "\u. \is_head_reduction t1; is_internal_reduction u; Src t1 = Src u\ + \ is_head_reduction (t1 \\ u)" + assume t: "is_head_reduction (t1 \<^bold>\ t2)" + assume u: "is_internal_reduction u" + assume tu: "Src (t1 \<^bold>\ t2) = Src u" + show "is_head_reduction ((t1 \<^bold>\ t2) \\ u)" + using t u tu ind1 + apply (cases u) + apply simp_all + proof (intro conjI impI) + fix u1 u2 + assume u1u2: "u = u1 \<^bold>\ u2" + show 1: "Con t1 u1" + using Coinitial_iff_Con tu u1u2 ide_char + by (metis ConD(1) Ide.simps(1) is_head_reduction.simps(9) is_head_reduction_resid + is_internal_reduction.simps(9) is_internal_reduction_resid t u) + show "Con t2 u2" + using Coinitial_iff_Con tu u1u2 ide_char + by (metis ConD(1) Ide.simps(1) is_head_reduction.simps(9) is_head_reduction_resid + is_internal_reduction.simps(9) is_internal_reduction_resid t u) + show "is_head_reduction (t1 \\ u1 \<^bold>\ t2 \\ u2)" + using t u u1u2 1 Coinitial_iff_Con \Con t2 u2\ ide_char ind1 resid_Ide_Arr + apply (cases t1; simp_all; cases u1; simp_all; cases "un_App1 u1") + apply auto + by (metis 1 ind1 is_internal_reduction.simps(6) resid.simps(3)) + qed + next + fix t1 t2 u + assume ind1: "\u. \is_head_reduction t1; is_internal_reduction u; Src t1 = Src u\ + \ is_head_reduction (t1 \\ u)" + assume t: "is_head_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + assume u: "is_internal_reduction u" + assume tu: "Src (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) = Src u" + show "is_head_reduction ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u)" + using t u tu ind1 + apply (cases u) + apply simp_all + by (metis Con_implies_Arr1 is_head_reduction_resid is_internal_reduction.simps(9) + is_internal_reduction_resid lambda.disc(15) prfx_App_iff t tu) + qed + + text \ + The following function differs from \head_strategy\ in that it only selects an already-marked + redex, whereas \head_strategy\ marks the redex at the head position. + \ + + fun head_redex + where "head_redex \<^bold>\ = \<^bold>\" + | "head_redex \<^bold>\x\<^bold>\ = \<^bold>\x\<^bold>\" + | "head_redex \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[head_redex t\<^bold>]" + | "head_redex (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u" + | "head_redex (t \<^bold>\ u) = head_redex t \<^bold>\ Src u" + | "head_redex (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = (\<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u)" + + lemma elementary_reduction_head_redex: + shows "\Arr t; \ Ide (head_redex t)\ \ elementary_reduction (head_redex t)" + using Ide_Src + apply (induct t) + apply auto + proof - + show "\t2. \\ Ide (head_redex t1) \ elementary_reduction (head_redex t1); + \ Ide (head_redex (t1 \<^bold>\ t2)); + \t. Arr t \ Ide (Src t); Arr t1; Arr t2\ + \ elementary_reduction (head_redex (t1 \<^bold>\ t2))" + for t1 + using Ide_Src + by (cases t1) auto + qed + + lemma subs_head_redex: + shows "Arr t \ head_redex t \ t" + using Ide_Src subs_Ide + apply (induct t) + apply simp_all + proof - + show "\t2. \head_redex t1 \ t1; head_redex t2 \ t2; + Arr t1 \ Arr t2; \t. Arr t \ Ide (Src t); + \u t. \Ide u; Src t = Src u\ \ u \ t\ + \ head_redex (t1 \<^bold>\ t2) \ t1 \<^bold>\ t2" + for t1 + using Ide_Src subs_Ide + by (cases t1) auto + qed + + lemma contains_head_reduction_iff: + shows "contains_head_reduction t \ Arr t \ \ Ide (head_redex t)" + apply (induct t) + apply simp_all + proof - + show "\t2. contains_head_reduction t1 = (Arr t1 \ \ Ide (head_redex t1)) + \ contains_head_reduction (t1 \<^bold>\ t2) = + (Arr t1 \ Arr t2 \ \ Ide (head_redex (t1 \<^bold>\ t2)))" + for t1 + using Ide_Src + by (cases t1) auto + qed + + lemma head_redex_is_head_reduction: + shows "\Arr t; contains_head_reduction t\ \ is_head_reduction (head_redex t)" + using Ide_Src + apply (induct t) + apply simp_all + proof - + show "\t2. \contains_head_reduction t1 \ is_head_reduction (head_redex t1); + Arr t1 \ Arr t2; + contains_head_reduction (t1 \<^bold>\ t2); \t. Arr t \ Ide (Src t)\ + \ is_head_reduction (head_redex (t1 \<^bold>\ t2))" + for t1 + using Ide_Src contains_head_reduction_iff subs_implies_prfx + by (cases t1) auto + qed + + lemma Arr_head_redex: + assumes "Arr t" + shows "Arr (head_redex t)" + using assms Ide_implies_Arr elementary_reduction_head_redex elementary_reduction_is_arr + by blast + + lemma Src_head_redex: + assumes "Arr t" + shows "Src (head_redex t) = Src t" + using assms + by (metis Coinitial_iff_Con Ide.simps(1) ide_char subs_head_redex subs_implies_prfx) + + lemma Con_Arr_head_redex: + assumes "Arr t" + shows "Con t (head_redex t)" + using assms + by (metis Con_sym Ide.simps(1) ide_char subs_head_redex subs_implies_prfx) + + lemma is_head_reduction_if: + shows "\contains_head_reduction u; elementary_reduction u\ \ is_head_reduction u" + apply (induct u) + apply auto + using contains_head_reduction.elims(2) + apply fastforce + proof - + fix u1 u2 + assume u1: "Ide u1" + assume u2: "elementary_reduction u2" + assume 1: "contains_head_reduction (u1 \<^bold>\ u2)" + have False + using u1 u2 1 + apply (cases u1) + apply auto + by (metis Arr_head_redex Ide_iff_Src_self Src_head_redex contains_head_reduction_iff + ide_char resid_Arr_Src subs_head_redex subs_implies_prfx u1) + thus "is_head_reduction (u1 \<^bold>\ u2)" + by blast + qed + + lemma (in reduction_paths) head_redex_decomp: + assumes "\.Arr t" + shows "[\.head_redex t] @ [t \\ \.head_redex t] \<^sup>*\\<^sup>* [t]" + using assms prfx_decomp \.subs_head_redex \.subs_implies_prfx + by (metis Ide.simps(2) Resid.simps(3) \.prfx_implies_con ide_char) + + text \ + An internal reduction cannot create a new head redex. + \ + + lemma internal_reduction_preserves_no_head_redex: + shows "\is_internal_reduction u; Ide (head_strategy (Src u))\ + \ Ide (head_strategy (Trg u))" + apply (induct u) + apply simp_all + proof - + fix u1 u2 + assume ind1: "\is_internal_reduction u1; Ide (head_strategy (Src u1))\ + \ Ide (head_strategy (Trg u1))" + assume ind2: "\is_internal_reduction u2; Ide (head_strategy (Src u2))\ + \ Ide (head_strategy (Trg u2))" + assume u: "is_internal_reduction (u1 \<^bold>\ u2)" + assume 1: "Ide (head_strategy (Src u1 \<^bold>\ Src u2))" + show "Ide (head_strategy (Trg u1 \<^bold>\ Trg u2))" + using u 1 ind1 ind2 Ide_Src Ide_Trg Ide_implies_Arr + by (cases u1) auto + qed + + lemma head_reduction_unique: + shows "\is_head_reduction t; is_head_reduction u; coinitial t u\ \ t = u" + by (metis Coinitial_iff_Con con_def confluence is_head_reduction_char null_char) + + text \ + Residuation along internal reductions preserves head reductions. + \ + + lemma resid_head_strategy_internal: + shows "is_internal_reduction u \ head_strategy (Src u) \\ u = head_strategy (Trg u)" + using internal_reduction_preserves_no_head_redex Arr_head_strategy Ide_iff_Src_self + Src_head_strategy Src_resid head_strategy_is_elementary is_head_reduction_char + is_head_reduction_resid' is_internal_reduction_iff + apply (cases u) + apply simp_all + apply (metis head_strategy_Src resid_Src_Arr) + apply (metis head_strategy_Src Arr.simps(4) Src.simps(4) Trg.simps(3) resid_Src_Arr) + by blast + + text \ + An internal reduction followed by a head reduction can be expressed + as a join of the internal reduction with a head reduction. + \ + + lemma resid_head_strategy_Src: + assumes "is_internal_reduction t" and "is_head_reduction u" + and "seq t u" + shows "head_strategy (Src t) \\ t = u" + and "composite_of t u (Join (head_strategy (Src t)) t)" + proof - + show 1: "head_strategy (Src t) \\ t = u" + using assms internal_reduction_preserves_no_head_redex resid_head_strategy_internal + elementary_reduction_not_ide ide_char is_head_reduction_char seq_char + by force + show "composite_of t u (Join (head_strategy (Src t)) t)" + using assms(3) 1 Arr_head_strategy Src_head_strategy join_of_Join join_of_def seq_char + by force + qed + + lemma App_Var_contains_no_head_reduction: + shows "\ contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ u)" + by simp + + lemma hgt_resid_App_head_redex: + assumes "Arr (t \<^bold>\ u)" and "\ Ide (head_redex (t \<^bold>\ u))" + shows "hgt ((t \<^bold>\ u) \\ head_redex (t \<^bold>\ u)) < hgt (t \<^bold>\ u)" + using assms contains_head_reduction_iff elementary_reduction_decreases_hgt + elementary_reduction_head_redex subs_head_redex + by blast + + subsection "Leftmost Reduction" + + text \ + Leftmost (or normal-order) reduction is the strategy that produces an elementary + reduction path by contracting the leftmost redex at each step. It agrees with + head reduction as long as there is a head redex, otherwise it continues on with the next + subterm to the right. + \ + + fun leftmost_strategy + where "leftmost_strategy \<^bold>\x\<^bold>\ = \<^bold>\x\<^bold>\" + | "leftmost_strategy \<^bold>\\<^bold>[t\<^bold>] = \<^bold>\\<^bold>[leftmost_strategy t\<^bold>]" + | "leftmost_strategy (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u" + | "leftmost_strategy (t \<^bold>\ u) = + (if \ Ide (leftmost_strategy t) + then leftmost_strategy t \<^bold>\ u + else t \<^bold>\ leftmost_strategy u)" + | "leftmost_strategy (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = \<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u" + | "leftmost_strategy \<^bold>\ = \<^bold>\" + + (* TODO: Consider if is_head_reduction should be done this way. *) + definition is_leftmost_reduction + where "is_leftmost_reduction t \ elementary_reduction t \ leftmost_strategy (Src t) = t" + + lemma leftmost_strategy_is_reduction_strategy: + shows "reduction_strategy leftmost_strategy" + proof (unfold reduction_strategy_def, intro allI impI) + fix t + show "Ide t \ Coinitial (leftmost_strategy t) t" + proof (induct t, auto) + show "\t2. \Arr (leftmost_strategy t1); Arr (leftmost_strategy t2); + Ide t1; Ide t2; + Arr t1; Src (leftmost_strategy t1) = Src t1; + Arr t2; Src (leftmost_strategy t2) = Src t2\ + \ Arr (leftmost_strategy (t1 \<^bold>\ t2))" + for t1 + by (cases t1) auto + qed + qed + + lemma elementary_reduction_leftmost_strategy: + shows "Ide t \ elementary_reduction (leftmost_strategy t) \ Ide (leftmost_strategy t)" + apply (induct t) + apply simp_all + proof - + fix t1 t2 + show "\elementary_reduction (leftmost_strategy t1) \ Ide (leftmost_strategy t1); + elementary_reduction (leftmost_strategy t2) \ Ide (leftmost_strategy t2); + Ide t1 \ Ide t2\ + \ elementary_reduction (leftmost_strategy (t1 \<^bold>\ t2)) \ + Ide (leftmost_strategy (t1 \<^bold>\ t2))" + by (cases t1) auto + qed + + lemma (in lambda_calculus) leftmost_strategy_selects_head_reduction: + shows "is_head_reduction t \ t = leftmost_strategy (Src t)" + proof (induct t) + show "\t1 t2. \is_head_reduction t1 \ t1 = leftmost_strategy (Src t1); + is_head_reduction (t1 \<^bold>\ t2)\ + \ t1 \<^bold>\ t2 = leftmost_strategy (Src (t1 \<^bold>\ t2))" + proof - + fix t1 t2 + assume ind1: "is_head_reduction t1 \ t1 = leftmost_strategy (Src t1)" + assume t: "is_head_reduction (t1 \<^bold>\ t2)" + show "t1 \<^bold>\ t2 = leftmost_strategy (Src (t1 \<^bold>\ t2))" + using t ind1 + apply (cases t1) + apply simp_all + apply (cases "Src t1") + apply simp_all + using ind1 + apply force + using ind1 + apply force + using ind1 + apply force + apply (metis Ide_iff_Src_self Ide_implies_Arr elementary_reduction_not_ide + ide_char ind1 is_head_reduction_char) + using ind1 + apply force + by (metis Ide_iff_Src_self Ide_implies_Arr) + qed + show "\t1 t2. \is_head_reduction t1 \ t1 = leftmost_strategy (Src t1); + is_head_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)\ + \ \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2 = leftmost_strategy (Src (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2))" + by (metis Ide_iff_Src_self Ide_implies_Arr Src.simps(5) + is_head_reduction.simps(8) leftmost_strategy.simps(3)) + qed auto + + lemma has_redex_iff_not_Ide_leftmost_strategy: + shows "Arr t \ has_redex t \ \ Ide (leftmost_strategy (Src t))" + apply (induct t) + apply simp_all + proof - + fix t1 t2 + assume ind1: "Ide (parallel_strategy t1) \ Ide (leftmost_strategy (Src t1))" + assume ind2: "Ide (parallel_strategy t2) \ Ide (leftmost_strategy (Src t2))" + assume t: "Arr t1 \ Arr t2" + show "Ide (parallel_strategy (t1 \<^bold>\ t2)) \ + Ide (leftmost_strategy (Src t1 \<^bold>\ Src t2))" + using t ind1 ind2 Ide_Src Ide_iff_Src_self + by (cases t1) auto + qed + + lemma leftmost_reduction_preservation: + shows "\u. \is_leftmost_reduction t; elementary_reduction u; \ is_leftmost_reduction u; + coinitial t u\ \ is_leftmost_reduction (t \\ u)" + proof (induct t) + show "\u. coinitial \<^bold>\ u \ is_leftmost_reduction (\<^bold>\ \\ u)" + by simp + show "\x u. is_leftmost_reduction \<^bold>\x\<^bold>\ \ is_leftmost_reduction (\<^bold>\x\<^bold>\ \\ u)" + by (simp add: is_leftmost_reduction_def) + fix t u + show "\\u. \is_leftmost_reduction t; elementary_reduction u; + \ is_leftmost_reduction u; coinitial t u\ \ is_leftmost_reduction (t \\ u); + is_leftmost_reduction (Lam t); elementary_reduction u; + \ is_leftmost_reduction u; coinitial \<^bold>\\<^bold>[t\<^bold>] u\ + \ is_leftmost_reduction (\<^bold>\\<^bold>[t\<^bold>] \\ u)" + using is_leftmost_reduction_def + by (cases u) auto + next + fix t1 t2 u + show "\is_leftmost_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2); elementary_reduction u; \ is_leftmost_reduction u; + coinitial (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u\ + \ is_leftmost_reduction ((\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \\ u)" + using is_leftmost_reduction_def Src_resid Ide_Trg Ide_iff_Src_self Arr_Trg Arr_not_Nil + apply (cases u) + apply simp_all + by (cases "un_App1 u") auto + assume ind1: "\u. \is_leftmost_reduction t1; elementary_reduction u; + \ is_leftmost_reduction u; coinitial t1 u\ + \ is_leftmost_reduction (t1 \\ u)" + assume ind2: "\u. \is_leftmost_reduction t2; elementary_reduction u; + \ is_leftmost_reduction u; coinitial t2 u\ + \ is_leftmost_reduction (t2 \\ u)" + assume 1: "is_leftmost_reduction (t1 \<^bold>\ t2)" + assume 2: "elementary_reduction u" + assume 3: "\ is_leftmost_reduction u" + assume 4: "coinitial (t1 \<^bold>\ t2) u" + show "is_leftmost_reduction ((t1 \<^bold>\ t2) \\ u)" + using 1 2 3 4 ind1 ind2 is_leftmost_reduction_def Src_resid + apply (cases u) + apply auto[3] + proof - + show "\u1 u2. u = \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2 \ is_leftmost_reduction ((t1 \<^bold>\ t2) \\ u)" + by (metis 2 3 is_leftmost_reduction_def elementary_reduction.simps(5) + is_head_reduction.simps(8) leftmost_strategy_selects_head_reduction) + fix u1 u2 + assume u: "u = u1 \<^bold>\ u2" + show "is_leftmost_reduction ((t1 \<^bold>\ t2) \\ u)" + using u 1 2 3 4 ind1 ind2 is_leftmost_reduction_def Src_resid Ide_Trg + elementary_reduction_not_ide + apply (cases u) + apply simp_all + apply (cases u1) + apply simp_all + apply auto[1] + using Ide_iff_Src_self + apply simp_all + proof - + fix u11 u12 + assume u: "u = u11 \<^bold>\ u12 \<^bold>\ u2" + assume u1: "u1 = u11 \<^bold>\ u12" + have A: "(elementary_reduction t1 \ Src u2 = t2 \ + Src u11 \<^bold>\ Src u12 = t1 \ elementary_reduction t2) \ + (if \ Ide (leftmost_strategy (Src u11 \<^bold>\ Src u12)) + then leftmost_strategy (Src u11 \<^bold>\ Src u12) \<^bold>\ Src u2 + else Src u11 \<^bold>\ Src u12 \<^bold>\ leftmost_strategy (Src u2)) = t1 \<^bold>\ t2" + using 1 4 Ide_iff_Src_self is_leftmost_reduction_def u by auto + have B: "(elementary_reduction u11 \ Src u12 = u12 \ + Src u11 = u11 \ elementary_reduction u12) \ Src u2 = u2 \ + Src u11 = u11 \ Src u12 = u12 \ elementary_reduction u2" + using "2" "4" Ide_iff_Src_self u by force + have C: "t1 = u11 \<^bold>\ u12 \ t2 \ u2" + using 1 3 u by fastforce + have D: "Arr t1 \ Arr t2 \ Arr u11 \ Arr u12 \ Arr u2 \ + Src t1 = Src u11 \<^bold>\ Src u12 \ Src t2 = Src u2" + using 4 u by force + have E: "\u. \elementary_reduction t1 \ leftmost_strategy (Src u) = t1; + elementary_reduction u; + t1 \ u; + Arr u \ Src u11 \<^bold>\ Src u12 = Src u\ + \ elementary_reduction (t1 \\ u) \ + leftmost_strategy (Trg u) = t1 \\ u" + using D Src_resid ind1 is_leftmost_reduction_def by auto + have F: "\u. \elementary_reduction t2 \ leftmost_strategy (Src u) = t2; + elementary_reduction u; + t2 \ u; + Arr u \ Src u2 = Src u\ + \ elementary_reduction (t2 \\ u) \ + leftmost_strategy (Trg u) = t2 \\ u" + using D Src_resid ind2 is_leftmost_reduction_def by auto + have G: "\t. elementary_reduction t \ \ Ide t" + using elementary_reduction_not_ide ide_char by blast + have H: "elementary_reduction (t1 \\ (u11 \<^bold>\ u12)) \ Ide (t2 \\ u2) \ + Ide (t1 \\ (u11 \<^bold>\ u12)) \ elementary_reduction (t2 \\ u2)" + proof (cases "Ide (t2 \\ u2)") + assume 1: "Ide (t2 \\ u2)" + hence "elementary_reduction (t1 \\ (u11 \<^bold>\ u12))" + by (metis A B C D E F G Ide_Src Arr.simps(4) Src.simps(4) + elementary_reduction.simps(4) lambda.inject(3) resid_Arr_Src) + thus ?thesis + using 1 by auto + next + assume 1: "\ Ide (t2 \\ u2)" + hence "Ide (t1 \\ (u11 \<^bold>\ u12)) \ elementary_reduction (t2 \\ u2)" + apply (intro conjI) + apply (metis 1 A D Ide_Src Arr.simps(4) Src.simps(4) resid_Ide_Arr) + by (metis A B C D F Ide_iff_Src_self lambda.inject(3) resid_Arr_Src resid_Ide_Arr) + thus ?thesis by simp + qed + show "(\ Ide (leftmost_strategy (Trg u11 \<^bold>\ Trg u12)) \ + (elementary_reduction (t1 \\ (u11 \<^bold>\ u12)) \ Ide (t2 \\ u2) \ + Ide (t1 \\ (u11 \<^bold>\ u12)) \ elementary_reduction (t2 \\ u2)) \ + leftmost_strategy (Trg u11 \<^bold>\ Trg u12) = t1 \\ (u11 \<^bold>\ u12) \ Trg u2 = t2 \\ u2) \ + (Ide (leftmost_strategy (Trg u11 \<^bold>\ Trg u12)) \ + (elementary_reduction (t1 \\ (u11 \<^bold>\ u12)) \ Ide (t2 \\ u2) \ + Ide (t1 \\ (u11 \<^bold>\ u12)) \ elementary_reduction (t2 \\ u2)) \ + Trg u11 \<^bold>\ Trg u12 = t1 \\ (u11 \<^bold>\ u12) \ leftmost_strategy (Trg u2) = t2 \\ u2)" + proof (intro conjI impI) + show H: "elementary_reduction (t1 \\ (u11 \<^bold>\ u12)) \ Ide (t2 \\ u2) \ + Ide (t1 \\ (u11 \<^bold>\ u12)) \ elementary_reduction (t2 \\ u2)" + by fact + show H: "elementary_reduction (t1 \\ (u11 \<^bold>\ u12)) \ Ide (t2 \\ u2) \ + Ide (t1 \\ (u11 \<^bold>\ u12)) \ elementary_reduction (t2 \\ u2)" + by fact + assume K: "\ Ide (leftmost_strategy (Trg u11 \<^bold>\ Trg u12))" + show J: "Trg u2 = t2 \\ u2" + using A B D G K has_redex_iff_not_Ide_leftmost_strategy + NF_def NF_iff_has_no_redex NF_App_iff resid_Arr_Src resid_Src_Arr + by (metis lambda.inject(3)) + show "leftmost_strategy (Trg u11 \<^bold>\ Trg u12) = t1 \\ (u11 \<^bold>\ u12)" + using 2 A B C D E G H J u Ide_Trg Src_Src + has_redex_iff_not_Ide_leftmost_strategy resid_Arr_Ide resid_Src_Arr + by (metis Arr.simps(4) Ide.simps(4) Src.simps(4) Trg.simps(3) + elementary_reduction.simps(4) lambda.inject(3)) + next + assume K: "Ide (leftmost_strategy (Trg u11 \<^bold>\ Trg u12))" + show I: "Trg u11 \<^bold>\ Trg u12 = t1 \\ (u11 \<^bold>\ u12)" + using 2 A D E K u Coinitial_resid_resid ConI resid_Arr_self resid_Ide_Arr + resid_Arr_Ide Ide_iff_Src_self Src_resid + apply (cases "Ide (leftmost_strategy (Src u11 \<^bold>\ Src u12))") + apply simp + using lambda_calculus.Con_Arr_Src(2) + apply force + apply simp + using u1 G H Coinitial_iff_Con + apply (cases "elementary_reduction u11"; + cases "elementary_reduction u12") + apply simp_all + apply metis + apply (metis Src.simps(4) Trg.simps(3) elementary_reduction.simps(1,4)) + apply (metis Src.simps(4) Trg.simps(3) elementary_reduction.simps(1,4)) + by (metis Trg_Src) + show "leftmost_strategy (Trg u2) = t2 \\ u2" + using 2 A C D F G H I u Ide_Trg Ide_iff_Src_self NF_def NF_iff_has_no_redex + has_redex_iff_not_Ide_leftmost_strategy resid_Ide_Arr + by (metis Arr.simps(4) Src.simps(4) Trg.simps(3) elementary_reduction.simps(4) + lambda.inject(3)) + qed + qed + qed + qed + + end + + section "Standard Reductions" + + text \ + In this section, we define the notion of a \emph{standard reduction}, which is an + elementary reduction path that performs reductions from left to right, possibly + skipping some redexes that could be contracted. Once a redex has been skipped, + neither that redex nor any redex to its left will subsequently be contracted. + We then define and prove correct a function that transforms an arbitrary + elementary reduction path into a congruent standard reduction path. + Using this function, we prove the Standardization Theorem, which says that + every elementary reduction path is congruent to a standard reduction path. + We then show that a standard reduction path that reaches a normal form is in + fact a leftmost reduction path. From this fact and the Standardization Theorem + we prove the Leftmost Reduction Theorem: leftmost reduction is a normalizing + strategy. + + The Standardization Theorem was first proved by Curry and Feys \cite{curry-and-feys}, + with subsequent proofs given by a number of authors. Formalized proofs have also + been given; a recent one (using Agda) is presented in \cite{copes}, with references + to earlier work. The version of the theorem that we formalize here is a ``strong'' + version, which asserts the existence of a standard reduction path congruent to a + a given elementary reduction path. At the core of the proof is a function that + directly transforms a given reduction path into a standard one, using an algorithm + roughly analogous to insertion sort. The Finite Development Theorem is used in the + proof of termination. The proof of correctness is long, due to the number of cases that + have to be considered, but the use of a proof assistant makes this manageable. + \ + + subsection "Standard Reduction Paths" + + subsubsection "`Standardly Sequential' Reductions" + + text \ + We first need to define the notion of a ``standard reduction''. In contrast to what + is typically done by other authors, we define this notion by direct comparison of adjacent + terms in an elementary reduction path, rather than by using devices such as a numbering + of subterms from left to right. + + The following function decides when two terms \t\ and \u\ are elementary reductions that are + ``standardly sequential''. This means that \t\ and \u\ are sequential, but in addition + no marked redex in \u\ is the residual of an (unmarked) redex ``to the left of'' any + marked redex in \t\. Some care is required to make sure that the recursive definition + captures what we intend. Most of the clauses are readily understandable. + One clause that perhaps could use some explanation is the one for + \sseq ((\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \<^bold>\ v) w\. Referring to the previously proved fact \seq_cases\, + which classifies the way in which two terms \t\ and \u\ can be sequential, + we see that one case that must be covered is when \t\ has the form \\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ v) \<^bold>\ w\ + and the top-level constructor of \u\ is \Beta\. In this case, it is the reduction + of \t\ that creates the top-level redex contracted in \u\, so it is impossible for \u\ to + be a residual of a redex that already exists in \Src t\. + \ + + context lambda_calculus + begin + + fun sseq + where "sseq _ \<^bold>\ = False" + | "sseq \<^bold>\_\<^bold>\ \<^bold>\_\<^bold>\ = False" + | "sseq \<^bold>\\<^bold>[t\<^bold>] \<^bold>\\<^bold>[t'\<^bold>] = sseq t t'" + | "sseq (t \<^bold>\ u) (t' \<^bold>\ u') = + ((sseq t t' \ Ide u \ u = u') \ + (Ide t \ t = t' \ sseq u u') \ + (elementary_reduction t \ Trg t = t' \ + (u = Src u' \ elementary_reduction u')))" + | "sseq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) (\<^bold>\\<^bold>[t'\<^bold>] \<^bold>\ u') = False" + | "sseq ((\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \<^bold>\ v) w = + (Ide t \ Ide u \ Ide v \ elementary_reduction w \ seq ((\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \<^bold>\ v) w)" + | "sseq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) v = (Ide t \ Ide u \ elementary_reduction v \ seq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) v)" + | "sseq _ _ = False" + + lemma sseq_imp_seq: + shows "\u. sseq t u \ seq t u" + proof (induct t) + show "\u. sseq \<^bold>\ u \ seq \<^bold>\ u" + using sseq.elims(1) by blast + fix u + show "\x. sseq \<^bold>\x\<^bold>\ u \ seq \<^bold>\x\<^bold>\ u" + using sseq.elims(1) by blast + show "\t. \\u. sseq t u \ seq t u; sseq \<^bold>\\<^bold>[t\<^bold>] u\ \ seq \<^bold>\\<^bold>[t\<^bold>] u" + using seq_char by (cases u) auto + show "\t1 t2. \\u. sseq t1 u \ seq t1 u; \u. sseq t2 u \ seq t2 u; + sseq (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u\ + \ seq (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u" + using seq_char Ide_implies_Arr + by (cases u) auto + fix t1 t2 + show "\\u. sseq t1 u \ seq t1 u; \u. sseq t2 u \ seq t2 u; sseq (t1 \<^bold>\ t2) u\ + \ seq (t1 \<^bold>\ t2) u" + proof - + assume ind1: "\u. sseq t1 u \ seq t1 u" + assume ind2: "\u. sseq t2 u \ seq t2 u" + assume 1: "sseq (t1 \<^bold>\ t2) u" + show ?thesis + using 1 ind1 ind2 seq_char arr_char elementary_reduction_is_arr + Ide_Src Ide_Trg Ide_implies_Arr Coinitial_iff_Con resid_Arr_self + apply (cases u, simp_all) + apply (cases t1, simp_all) + apply (cases t1, simp_all) + apply (cases "Ide t1"; cases "Ide t2") + apply simp_all + apply (metis Ide_iff_Src_self Ide_iff_Trg_self) + apply (metis Ide_iff_Src_self Ide_iff_Trg_self) + apply (metis Ide_iff_Trg_self Src_Trg) + by (cases t1) auto + qed + qed + + lemma sseq_imp_elementary_reduction1: + shows "\t. sseq t u \ elementary_reduction t" + proof (induct u) + show "\t. sseq t \<^bold>\ \ elementary_reduction t" + by simp + show "\x t. sseq t \<^bold>\x\<^bold>\ \ elementary_reduction t" + using elementary_reduction.simps(2) sseq.elims(1) by blast + show "\u. \\t. sseq t u \ elementary_reduction t; sseq t \<^bold>\\<^bold>[u\<^bold>]\ + \ elementary_reduction t" for t + using seq_cases sseq_imp_seq + apply (cases t, simp_all) + by force + show "\u1 u2. \\t. sseq t u1 \ elementary_reduction t; + \t. sseq t u2 \ elementary_reduction t; + sseq t (u1 \<^bold>\ u2)\ + \ elementary_reduction t" for t + using seq_cases sseq_imp_seq Ide_Src elementary_reduction_is_arr + apply (cases t, simp_all) + by blast + show "\u1 u2. + \\t. sseq t u1 \ elementary_reduction t; \t. sseq t u2 \ elementary_reduction t; + sseq t (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)\ + \ elementary_reduction t" for t + using seq_cases sseq_imp_seq + apply (cases t, simp_all) + by fastforce + qed + + lemma sseq_imp_elementary_reduction2: + shows "\t. sseq t u \ elementary_reduction u" + proof (induct u) + show "\t. sseq t \<^bold>\ \ elementary_reduction \<^bold>\" + by simp + show "\x t. sseq t \<^bold>\x\<^bold>\ \ elementary_reduction \<^bold>\x\<^bold>\" + using elementary_reduction.simps(2) sseq.elims(1) by blast + show "\u. \\t. sseq t u \ elementary_reduction u; sseq t \<^bold>\\<^bold>[u\<^bold>]\ + \ elementary_reduction \<^bold>\\<^bold>[u\<^bold>]" for t + using seq_cases sseq_imp_seq + apply (cases t, simp_all) + by force + show "\u1 u2. \\t. sseq t u1 \ elementary_reduction u1; + \t. sseq t u2 \ elementary_reduction u2; + sseq t (u1 \<^bold>\ u2)\ + \ elementary_reduction (u1 \<^bold>\ u2)" for t + using seq_cases sseq_imp_seq Ide_Trg elementary_reduction_is_arr + by (cases t) auto + show "\u1 u2. \\t. sseq t u1 \ elementary_reduction u1; + \t. sseq t u2 \ elementary_reduction u2; + sseq t (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)\ + \ elementary_reduction (\<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2)" for t + using seq_cases sseq_imp_seq + apply (cases t, simp_all) + by fastforce + qed + + lemma sseq_Beta: + shows "sseq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) v \ Ide t \ Ide u \ elementary_reduction v \ seq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) v" + by (cases v) auto + + lemma sseq_BetaI [intro]: + assumes "Ide t" and "Ide u" and "elementary_reduction v" and "seq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) v" + shows "sseq (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) v" + using assms sseq_Beta by simp + + text \ + A head reduction is standardly sequential with any elementary reduction that + can be performed after it. + \ + + lemma sseq_head_reductionI: + shows "\u. \is_head_reduction t; elementary_reduction u; seq t u\ \ sseq t u" + proof (induct t) + show "\u. \is_head_reduction \<^bold>\; elementary_reduction u; seq \<^bold>\ u\ \ sseq \<^bold>\ u" + by simp + show "\x u. \is_head_reduction \<^bold>\x\<^bold>\; elementary_reduction u; seq \<^bold>\x\<^bold>\ u\ \ sseq \<^bold>\x\<^bold>\ u" + by auto + show "\t. \\u. \is_head_reduction t; elementary_reduction u; seq t u\ \ sseq t u; + is_head_reduction \<^bold>\\<^bold>[t\<^bold>]; elementary_reduction u; seq \<^bold>\\<^bold>[t\<^bold>] u\ + \ sseq \<^bold>\\<^bold>[t\<^bold>] u" for u + by (cases u) auto + show "\t2. \\u. \is_head_reduction t1; elementary_reduction u; seq t1 u\ \ sseq t1 u; + \u. \is_head_reduction t2; elementary_reduction u; seq t2 u\ \ sseq t2 u; + is_head_reduction (t1 \<^bold>\ t2); elementary_reduction u; seq (t1 \<^bold>\ t2) u\ + \ sseq (t1 \<^bold>\ t2) u" for t1 u + using seq_char + apply (cases u) + apply simp_all + apply (metis ArrE Ide_iff_Src_self Ide_iff_Trg_self App_Var_contains_no_head_reduction + is_head_reduction_char is_head_reduction_imp_contains_head_reduction + is_head_reduction.simps(3,6-7)) + by (cases t1) auto + show "\t1 t2 u. \\u. \is_head_reduction t1; elementary_reduction u; seq t1 u\ \ sseq t1 u; + \u. \is_head_reduction t2; elementary_reduction u; seq t2 u\ \ sseq t2 u; + is_head_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2); elementary_reduction u; seq (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u\ + \ sseq (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u" + by auto + qed + + text \ + Once a head reduction is skipped in an application, then all terms that follow it + in a standard reduction path are also applications that do not contain head reductions. + \ + + lemma sseq_preserves_App_and_no_head_reduction: + shows "\u. \sseq t u; is_App t \ \ contains_head_reduction t\ + \ is_App u \ \ contains_head_reduction u" + apply (induct t) + apply simp_all + proof - + fix t1 t2 u + assume ind1: "\u. \sseq t1 u; is_App t1 \ \ contains_head_reduction t1\ + \ is_App u \ \ contains_head_reduction u" + assume ind2: "\u. \sseq t2 u; is_App t2 \ \ contains_head_reduction t2\ + \ is_App u \ \ contains_head_reduction u" + assume sseq: "sseq (t1 \<^bold>\ t2) u" + assume t: "\ contains_head_reduction (t1 \<^bold>\ t2)" + have u: "\ is_Beta u" + using sseq t sseq_imp_seq seq_cases + by (cases t1; cases u) auto + have 1: "is_App u" + using u sseq sseq_imp_seq + apply (cases u) + apply simp_all + by fastforce+ + moreover have "\ contains_head_reduction u" + proof (cases u) + show "\v. u = \<^bold>\\<^bold>[v\<^bold>] \ \ contains_head_reduction u" + using 1 by auto + show "\v w. u = \<^bold>\\<^bold>[v\<^bold>] \<^bold>\ w \ \ contains_head_reduction u" + using u by auto + fix u1 u2 + assume u: "u = u1 \<^bold>\ u2" + have 1: "(sseq t1 u1 \ Ide t2 \ t2 = u2) \ (Ide t1 \ t1 = u1 \ sseq t2 u2) \ + (elementary_reduction t1 \ u1 = Trg t1 \ t2 = Src u2 \ elementary_reduction u2)" + using sseq u by force + moreover have "Ide t1 \ t1 = u1 \ sseq t2 u2 \ ?thesis" + using Ide_implies_Arr ide_char sseq_imp_seq t u by fastforce + moreover have "elementary_reduction t1 \ u1 = Trg t1 \ t2 = Src u2 \ + elementary_reduction u2 + \ ?thesis" + proof - + assume 2: "elementary_reduction t1 \ u1 = Trg t1 \ t2 = Src u2 \ + elementary_reduction u2" + have "contains_head_reduction u \ contains_head_reduction u1" + using u + apply simp + using contains_head_reduction.elims(2) by fastforce + hence "contains_head_reduction u \ \ Ide u1" + using contains_head_reduction_iff + by (metis Coinitial_iff_Con Ide_iff_Src_self Ide_implies_Arr ide_char resid_Arr_Src + subs_head_redex subs_implies_prfx) + thus ?thesis + using 2 + by (metis Arr.simps(4) Ide_Trg seq_char sseq sseq_imp_seq) + qed + moreover have "sseq t1 u1 \ Ide t2 \ t2 = u2 \ ?thesis" + using t u ind1 [of u1] Ide_implies_Arr sseq_imp_elementary_reduction1 + apply (cases t1, simp_all) + using elementary_reduction.simps(1) + apply blast + using elementary_reduction.simps(2) + apply blast + using contains_head_reduction.elims(2) + apply fastforce + apply (metis contains_head_reduction.simps(6) is_App_def) + using sseq_Beta by blast + ultimately show ?thesis by blast + qed auto + ultimately show "is_App u \ \ contains_head_reduction u" + by blast + qed + + end + + subsubsection "Standard Reduction Paths" + + context reduction_paths + begin + + text \ + A \emph{standard reduction path} is an elementary reduction path in which + successive reductions are standardly sequential. + \ + + fun Std + where "Std [] = True" + | "Std [t] = \.elementary_reduction t" + | "Std (t # U) = (\.sseq t (hd U) \ Std U)" + + lemma Std_consE [elim]: + assumes "Std (t # U)" + and "\\.Arr t; U \ [] \ \.sseq t (hd U); Std U\ \ thesis" + shows thesis + using assms + by (metis \.arr_char \.elementary_reduction_is_arr \.seq_char \.sseq_imp_seq + list.exhaust_sel list.sel(1) Std.simps(1-3)) + + lemma Std_imp_Arr [simp]: + shows "\Std T; T \ []\ \ Arr T" + proof (induct T) + show "[] \ [] \ Arr []" + by simp + fix t U + assume ind: "\Std U; U \ []\ \ Arr U" + assume tU: "Std (t # U)" + show "Arr (t # U)" + proof (cases "U = []") + show "U = [] \ Arr (t # U)" + using \.elementary_reduction_is_arr tU \.Ide_implies_Arr Std.simps(2) Arr.simps(2) + by blast + assume U: "U \ []" + show "Arr (t # U)" + proof - + have "\.sseq t (hd U)" + using tU U + by (metis list.exhaust_sel reduction_paths.Std.simps(3)) + thus ?thesis + using U ind \.sseq_imp_seq + apply auto + using reduction_paths.Std.elims(3) tU + by fastforce + qed + qed + qed + + lemma Std_imp_sseq_last_hd: + shows "\U. \Std (T @ U); T \ []; U \ []\ \ \.sseq (last T) (hd U)" + apply (induct T) + apply simp_all + by (metis Std.elims(3) Std.simps(3) append_self_conv2 neq_Nil_conv) + + lemma Std_implies_set_subset_elementary_reduction: + shows "Std U \ set U \ Collect \.elementary_reduction" + apply (induct U) + apply auto + by (metis Std.simps(2) Std.simps(3) neq_Nil_conv \.sseq_imp_elementary_reduction1) + + lemma Std_map_Lam: + shows "Std T \ Std (map \.Lam T)" + proof (induct T) + show "Std [] \ Std (map \.Lam [])" + by simp + fix t U + assume ind: "Std U \ Std (map \.Lam U)" + assume tU: "Std (t # U)" + have "Std (map \.Lam (t # U)) \ Std (\<^bold>\\<^bold>[t\<^bold>] # map \.Lam U)" + by auto + also have "... = True" + apply (cases "U = []") + apply simp_all + using Arr.simps(3) Std.simps(2) arr_char tU + apply presburger + proof - + assume U: "U \ []" + have "Std (\<^bold>\\<^bold>[t\<^bold>] # map \.Lam U) \ \.sseq \<^bold>\\<^bold>[t\<^bold>] \<^bold>\\<^bold>[hd U\<^bold>] \ Std (map \.Lam U)" + using U + by (metis Nil_is_map_conv Std.simps(3) hd_map list.exhaust_sel) + also have "... \ \.sseq t (hd U) \ Std (map \.Lam U)" + by auto + also have "... = True" + using ind tU U + by (metis Std.simps(3) list.exhaust_sel) + finally show "Std (\<^bold>\\<^bold>[t\<^bold>] # map \.Lam U)" by blast + qed + finally show "Std (map \.Lam (t # U))" by blast + qed + + lemma Std_map_App1: + shows "\\.Ide b; Std T\ \ Std (map (\X. X \<^bold>\ b) T)" + proof (induct T) + show "\\.Ide b; Std []\ \ Std (map (\X. X \<^bold>\ b) [])" + by simp + fix t U + assume ind: "\\.Ide b; Std U\ \ Std (map (\X. X \<^bold>\ b) U)" + assume b: "\.Ide b" + assume tU: "Std (t # U)" + show "Std (map (\v. v \<^bold>\ b) (t # U))" + proof (cases "U = []") + show "U = [] \ ?thesis" + using Ide_implies_Arr b \.arr_char tU by force + assume U: "U \ []" + have "Std (map (\v. v \<^bold>\ b) (t # U)) = Std ((t \<^bold>\ b) # map (\X. X \<^bold>\ b) U)" + by simp + also have "... = (\.sseq (t \<^bold>\ b) (hd U \<^bold>\ b) \ Std (map (\X. X \<^bold>\ b) U))" + using U reduction_paths.Std.simps(3) hd_map + by (metis Nil_is_map_conv neq_Nil_conv) + also have "... = True" + using b tU U ind + by (metis Std.simps(3) list.exhaust_sel \.sseq.simps(4)) + finally show "Std (map (\v. v \<^bold>\ b) (t # U))" by blast + qed + qed + + lemma Std_map_App2: + shows "\\.Ide a; Std T\ \ Std (map (\u. a \<^bold>\ u) T)" + proof (induct T) + show "\\.Ide a; Std []\ \ Std (map (\u. a \<^bold>\ u) [])" + by simp + fix t U + assume ind: "\\.Ide a; Std U\ \ Std (map (\u. a \<^bold>\ u) U)" + assume a: "\.Ide a" + assume tU: "Std (t # U)" + show "Std (map (\u. a \<^bold>\ u) (t # U))" + proof (cases "U = []") + show "U = [] \ ?thesis" + using a tU by force + assume U: "U \ []" + have "Std (map (\u. a \<^bold>\ u) (t # U)) = Std ((a \<^bold>\ t) # map (\u. a \<^bold>\ u) U)" + by simp + also have "... = (\.sseq (a \<^bold>\ t) (a \<^bold>\ hd U) \ Std (map (\u. a \<^bold>\ u) U))" + using U + by (metis Nil_is_map_conv Std.simps(3) hd_map list.exhaust_sel) + also have "... = True" + using a tU U ind + by (metis Std.simps(3) list.exhaust_sel \.sseq.simps(4)) + finally show "Std (map (\u. a \<^bold>\ u) (t # U))" by blast + qed + qed + + lemma Std_map_un_Lam: + shows "\Std T; set T \ Collect \.is_Lam\ \ Std (map \.un_Lam T)" + proof (induct T) + show "\Std []; set [] \ Collect \.is_Lam\ \ Std (map \.un_Lam [])" + by simp + fix t T + assume ind: "\Std T; set T \ Collect \.is_Lam\ \ Std (map \.un_Lam T)" + assume tT: "Std (t # T)" + assume 1: "set (t # T) \ Collect \.is_Lam" + show "Std (map \.un_Lam (t # T))" + proof (cases "T = []") + show "T = [] \ Std (map \.un_Lam (t # T))" + by (metis "1" Std.simps(2) \.elementary_reduction.simps(3) \.lambda.collapse(2) + list.set_intros(1) list.simps(8) list.simps(9) mem_Collect_eq subset_code(1) tT) + assume T: "T \ []" + show "Std (map \.un_Lam (t # T))" + using T tT 1 ind Std.simps(3) [of "\.un_Lam t" "\.un_Lam (hd T)" "map \.un_Lam (tl T)"] + by (metis \.lambda.collapse(2) \.sseq.simps(3) list.exhaust_sel list.sel(1) + list.set_intros(1) map_eq_Cons_conv mem_Collect_eq reduction_paths.Std.simps(3) + set_subset_Cons subset_code(1)) + qed + qed + + lemma Std_append_single: + shows "\Std T; T \ []; \.sseq (last T) u\ \ Std (T @ [u])" + proof (induct T) + show "\Std []; [] \ []; \.sseq (last []) u\ \ Std ([] @ [u])" + by blast + fix t T + assume ind: "\Std T; T \ []; \.sseq (last T) u\ \ Std (T @ [u])" + assume tT: "Std (t # T)" + assume sseq: "\.sseq (last (t # T)) u" + have "Std (t # (T @ [u]))" + using \.sseq_imp_elementary_reduction2 sseq ind tT + apply (cases "T = []") + apply simp + by (metis append_Cons last_ConsR list.sel(1) neq_Nil_conv reduction_paths.Std.simps(3)) + thus "Std ((t # T) @ [u])" by simp + qed + + lemma Std_append: + shows "\T. \Std T; Std U; T = [] \ U = [] \ \.sseq (last T) (hd U)\ \ Std (T @ U)" + proof (induct U) + show "\T. \Std T; Std []; T = [] \ [] = [] \ \.sseq (last T) (hd [])\ \ Std (T @ [])" + by simp + fix u T U + assume ind: "\T. \Std T; Std U; T = [] \ U = [] \ \.sseq (last T) (hd U)\ + \ Std (T @ U)" + assume T: "Std T" + assume uU: "Std (u # U)" + have U: "Std U" + using uU Std.elims(3) by fastforce + assume seq: "T = [] \ u # U = [] \ \.sseq (last T) (hd (u # U))" + show "Std (T @ (u # U))" + by (metis Std_append_single T U append.assoc append.left_neutral append_Cons + ind last_snoc list.distinct(1) list.exhaust_sel list.sel(1) Std.simps(3) seq uU) + qed + + subsubsection "Projections of Standard `App Paths'" + + text \ + Given a standard reduction path, all of whose transitions have App as their top-level + constructor, we can apply \un_App1\ or \un_App2\ to each transition to project the path + onto paths formed from the ``rator'' and the ``rand'' of each application. These projected + paths are not standard, since the projection operation will introduce identities, + in general. However, in this section we show that if we remove the identities, then + in fact we do obtain standard reduction paths. + \ + + abbreviation notIde + where "notIde \ \u. \ \.Ide u" + + lemma filter_notIde_Ide: + shows "Ide U \ filter notIde U = []" + by (induct U) auto + + lemma cong_filter_notIde: + shows "\Arr U; \ Ide U\ \ filter notIde U \<^sup>*\\<^sup>* U" + proof (induct U) + show "\Arr []; \ Ide []\ \ filter notIde [] \<^sup>*\\<^sup>* []" + by simp + fix u U + assume ind: "\Arr U; \ Ide U\ \ filter notIde U \<^sup>*\\<^sup>* U" + assume Arr: "Arr (u # U)" + assume 1: "\ Ide (u # U)" + show "filter notIde (u # U) \<^sup>*\\<^sup>* (u # U)" + proof (cases "\.Ide u") + assume u: "\.Ide u" + have U: "Arr U \ \ Ide U" + using Arr u 1 Ide.elims(3) by fastforce + have "filter notIde (u # U) = filter notIde U" + using u by simp + also have "... \<^sup>*\\<^sup>* U" + using U ind by blast + also have "U \<^sup>*\\<^sup>* [u] @ U" + using u + by (metis (full_types) Arr Arr_has_Src Cons_eq_append_conv Ide.elims(3) Ide.simps(2) + Srcs.simps(1) U arrI\<^sub>P arr_append_imp_seq cong_append_ideI(3) ide_char + \.ide_char not_Cons_self2) + also have "[u] @ U = u # U" + by simp + finally show ?thesis by blast + next + assume u: "\ \.Ide u" + show ?thesis + proof (cases "Ide U") + assume U: "Ide U" + have "filter notIde (u # U) = [u]" + using u U filter_notIde_Ide by simp + moreover have "[u] \<^sup>*\\<^sup>* [u] @ U" + using u U cong_append_ideI(4) [of "[u]" U] + by (metis Arr Con_Arr_self Cons_eq_appendI Resid_Ide(1) arr_append_imp_seq + arr_char ide_char ide_implies_arr neq_Nil_conv self_append_conv2) + moreover have "[u] @ U = u # U" + by simp + ultimately show ?thesis by auto + next + assume U: "\ Ide U" + have "filter notIde (u # U) = [u] @ filter notIde U" + using u U Arr by simp + also have "... \<^sup>*\\<^sup>* [u] @ U" + proof (cases "U = []") + show "U = [] \ ?thesis" + by (metis Arr arr_char cong_reflexive append_Nil2 filter.simps(1)) + assume 1: "U \ []" + have "seq [u] (filter notIde U)" + by (metis (full_types) 1 Arr Arr.simps(2-3) Con_imp_eq_Srcs Con_implies_Arr(1) + Ide.elims(3) Ide.simps(1) Trgs.simps(2) U ide_char ind seq_char + seq_implies_Trgs_eq_Srcs) + thus ?thesis + using u U Arr ind cong_append [of "[u]" "filter notIde U" "[u]" U] + by (meson 1 Arr_consE cong_reflexive seqE) + qed + also have "[u] @ U = u # U" + by simp + finally show ?thesis by argo + qed + qed + qed + + lemma Std_filter_map_un_App1: + shows "\Std U; set U \ Collect \.is_App\ \ Std (filter notIde (map \.un_App1 U))" + proof (induct U) + show "\Std []; set [] \ Collect \.is_App\ \ Std (filter notIde (map \.un_App1 []))" + by simp + fix u U + assume ind: "\Std U; set U \ Collect \.is_App\ \ Std (filter notIde (map \.un_App1 U))" + assume 1: "Std (u # U)" + assume 2: "set (u # U) \ Collect \.is_App" + show "Std (filter notIde (map \.un_App1 (u # U)))" + using 1 2 ind + apply (cases u) + apply simp_all + proof - + fix u1 u2 + assume uU: "Std ((u1 \<^bold>\ u2) # U)" + assume set: "set U \ Collect \.is_App" + assume ind: "Std U \ Std (filter notIde (map \.un_App1 U))" + assume u: "u = u1 \<^bold>\ u2" + show "(\ \.Ide u1 \ Std (u1 # filter notIde (map \.un_App1 U))) \ + (\.Ide u1 \ Std (filter notIde (map \.un_App1 U)))" + proof (intro conjI impI) + assume u1: "\.Ide u1" + show "Std (filter notIde (map \.un_App1 U))" + by (metis 1 Std.simps(1) Std.simps(3) ind neq_Nil_conv) + next + assume u1: "\ \.Ide u1" + show "Std (u1 # filter notIde (map \.un_App1 U))" + proof (cases "Ide (map \.un_App1 U)") + show "Ide (map \.un_App1 U) \ ?thesis" + proof - + assume U: "Ide (map \.un_App1 U)" + have "filter notIde (map \.un_App1 U) = []" + by (metis U Ide_char filter_False \.ide_char + mem_Collect_eq subsetD) + thus ?thesis + by (metis Std.elims(1) Std.simps(2) \.elementary_reduction.simps(4) list.discI + list.sel(1) \.sseq_imp_elementary_reduction1 u1 uU) + qed + assume U: "\ Ide (map \.un_App1 U)" + show ?thesis + proof (cases "U = []") + show "U = [] \ ?thesis" + using 1 u u1 by fastforce + assume "U \ []" + hence U: "U \ [] \ \ Ide (map \.un_App1 U)" + using U by simp + have "\.sseq u1 (hd (filter notIde (map \.un_App1 U)))" + proof - + have "\u1 u2. \set U \ Collect \.is_App; \ Ide (map \.un_App1 U); U \ []; + Std ((u1 \<^bold>\ u2) # U); \ \.Ide u1\ + \ \.sseq u1 (hd (filter notIde (map \.un_App1 U)))" + for U + apply (induct U) + apply simp_all + apply (intro conjI impI) + proof - + fix u U u1 u2 + assume ind: "\u1 u2. \\ Ide (map \.un_App1 U); U \ []; + Std ((u1 \<^bold>\ u2) # U); \ \.Ide u1\ + \ \.sseq u1 (hd (filter notIde (map \.un_App1 U)))" + assume 1: "\.is_App u \ set U \ Collect \.is_App" + assume 2: "\ Ide (\.un_App1 u # map \.un_App1 U)" + assume 3: "\.sseq (u1 \<^bold>\ u2) u \ Std (u # U)" + show "\ \.Ide (\.un_App1 u) \ \.sseq u1 (\.un_App1 u)" + by (metis 1 3 \.Arr.simps(4) \.Ide_Trg \.lambda.collapse(3) \.seq_char + \.sseq.simps(4) \.sseq_imp_seq) + assume 4: "\ \.Ide u1" + assume 5: "\.Ide (\.un_App1 u)" + have u1: "\.elementary_reduction u1" + using 3 4 \.elementary_reduction.simps(4) \.sseq_imp_elementary_reduction1 + by blast + have 6: "Arr (\.un_App1 u # map \.un_App1 U)" + using 1 3 Std_imp_Arr Arr_map_un_App1 [of "u # U"] by auto + have 7: "Arr (map \.un_App1 U)" + using 1 2 3 5 6 Arr_map_un_App1 Std_imp_Arr \.ide_char by fastforce + have 8: "\ Ide (map \.un_App1 U)" + using 2 5 6 set_Ide_subset_ide by fastforce + have 9: "\.seq u (hd U)" + by (metis 3 7 Std.simps(3) Arr.simps(1) list.collapse list.simps(8) + \.sseq_imp_seq) + show "\.sseq u1 (hd (filter notIde (map \.un_App1 U)))" + proof - + have "\.sseq (u1 \<^bold>\ \.Trg (\.un_App2 u)) (hd U)" + proof (cases "\.Ide (\.un_App1 (hd U))") + assume 10: "\.Ide (\.un_App1 (hd U))" + hence "\.elementary_reduction (\.un_App2 (hd U))" + by (metis (full_types) 1 3 7 Std.elims(2) Arr.simps(1) + \.elementary_reduction_App_iff \.elementary_reduction_not_ide + \.ide_char list.sel(2) list.sel(3) list.set_sel(1) list.simps(8) + mem_Collect_eq \.sseq_imp_elementary_reduction2 subsetD) + moreover have "\.Trg u1 = \.un_App1 (hd U)" + proof - + have "\.Trg u1 = \.Src (\.un_App1 u)" + by (metis 1 3 5 \.Ide_iff_Src_self \.Ide_implies_Arr \.Trg_Src + \.elementary_reduction_not_ide \.ide_char \.lambda.collapse(3) + \.sseq.simps(4) \.sseq_imp_elementary_reduction2) + also have "... = \.Trg (\.un_App1 u)" + by (metis 5 \.Ide_iff_Src_self \.Ide_iff_Trg_self + \.Ide_implies_Arr) + also have "... = \.un_App1 (hd U)" + using 1 3 5 7 \.Ide_iff_Trg_self + by (metis 9 10 Arr.simps(1) lambda_calculus.Ide_iff_Src_self + \.Ide_implies_Arr \.Src_Src \.Src_eq_iff(2) \.Trg.simps(3) + \.lambda.collapse(3) \.seqE\<^sub>\ list.set_sel(1) list.simps(8) + mem_Collect_eq subsetD) + finally show ?thesis by argo + qed + moreover have "\.Trg (\.un_App2 u) = \.Src (\.un_App2 (hd U))" + by (metis 1 7 9 Arr.simps(1) hd_in_set \.Src.simps(4) \.Src_Src + \.Trg.simps(3) \.lambda.collapse(3) \.lambda.sel(4) + \.seq_char list.simps(8) mem_Collect_eq subset_code(1)) + ultimately show ?thesis + using \.sseq.simps(4) + by (metis 1 7 u1 Arr.simps(1) hd_in_set \.lambda.collapse(3) + list.simps(8) mem_Collect_eq subsetD) + next + assume 10: "\ \.Ide (\.un_App1 (hd U))" + have False + proof - + have "\.elementary_reduction (\.un_App2 u)" + using 1 3 5 \.elementary_reduction_App_iff + \.elementary_reduction_not_ide \.sseq_imp_elementary_reduction2 + by blast + moreover have "\.sseq u (hd U)" + by (metis 3 7 Std.simps(3) Arr.simps(1) + hd_Cons_tl list.simps(8)) + moreover have "\.elementary_reduction (\.un_App1 (hd U))" + by (metis 1 7 10 Nil_is_map_conv Arr.simps(1) + calculation(2) \.elementary_reduction_App_iff hd_in_set \.ide_char + mem_Collect_eq \.sseq_imp_elementary_reduction2 subset_iff) + ultimately show ?thesis + using \.sseq.simps(4) + by (metis 1 5 7 Arr.simps(1) \.elementary_reduction_not_ide + hd_in_set \.ide_char \.lambda.collapse(3) list.simps(8) + mem_Collect_eq subset_iff) + qed + thus ?thesis by argo + qed + hence " Std ((u1 \<^bold>\ \.Trg (\.un_App2 u)) # U)" + by (metis 3 7 Std.simps(3) Arr.simps(1) list.exhaust_sel list.simps(8)) + thus ?thesis + using ind + by (metis 7 8 u1 Arr.simps(1) \.elementary_reduction_not_ide \.ide_char + list.simps(8)) + qed + qed + thus ?thesis + using U set u1 uU by blast + qed + thus ?thesis + by (metis 1 Std.simps(2-3) \U \ []\ ind list.exhaust_sel list.sel(1) + \.sseq_imp_elementary_reduction1) + qed + qed + qed + qed + qed + + lemma Std_filter_map_un_App2: + shows "\Std U; set U \ Collect \.is_App\ \ Std (filter notIde (map \.un_App2 U))" + proof (induct U) + show "\Std []; set [] \ Collect \.is_App\ \ Std (filter notIde (map \.un_App2 []))" + by simp + fix u U + assume ind: "\Std U; set U \ Collect \.is_App\ \ Std (filter notIde (map \.un_App2 U))" + assume 1: "Std (u # U)" + assume 2: "set (u # U) \ Collect \.is_App" + show "Std (filter notIde (map \.un_App2 (u # U)))" + using 1 2 ind + apply (cases u) + apply simp_all + proof - + fix u1 u2 + assume uU: "Std ((u1 \<^bold>\ u2) # U)" + assume set: "set U \ Collect \.is_App" + assume ind: "Std U \ Std (filter notIde (map \.un_App2 U))" + assume u: "u = u1 \<^bold>\ u2" + show "(\ \.Ide u2 \ Std (u2 # filter notIde (map \.un_App2 U))) \ + (\.Ide u2 \ Std (filter notIde (map \.un_App2 U)))" + proof (intro conjI impI) + assume u2: "\.Ide u2" + show "Std (filter notIde (map \.un_App2 U))" + by (metis 1 Std.simps(1) Std.simps(3) ind neq_Nil_conv) + next + assume u2: "\ \.Ide u2" + show "Std (u2 # filter notIde (map \.un_App2 U))" + proof (cases "Ide (map \.un_App2 U)") + show "Ide (map \.un_App2 U) \ ?thesis" + proof - + assume U: "Ide (map \.un_App2 U)" + have "filter notIde (map \.un_App2 U) = []" + by (metis U Ide_char filter_False \.ide_char mem_Collect_eq subsetD) + thus ?thesis + by (metis Std.elims(1) Std.simps(2) \.elementary_reduction.simps(4) list.discI + list.sel(1) \.sseq_imp_elementary_reduction1 u2 uU) + qed + assume U: "\ Ide (map \.un_App2 U)" + show ?thesis + proof (cases "U = []") + show "U = [] \ ?thesis" + using "1" u u2 by fastforce + assume "U \ []" + hence U: "U \ [] \ \ Ide (map \.un_App2 U)" + using U by simp + have "\.sseq u2 (hd (filter notIde (map \.un_App2 U)))" + proof - + have "\u1 u2. \set U \ Collect \.is_App; \ Ide (map \.un_App2 U); U \ []; + Std ((u1 \<^bold>\ u2) # U); \ \.Ide u2\ + \ \.sseq u2 (hd (filter notIde (map \.un_App2 U)))" + for U + apply (induct U) + apply simp_all + apply (intro conjI impI) + proof - + fix u U u1 u2 + assume ind: "\u1 u2. \\ Ide (map \.un_App2 U); U \ []; + Std ((u1 \<^bold>\ u2) # U); \ \.Ide u2\ + \ \.sseq u2 (hd (filter notIde (map \.un_App2 U)))" + assume 1: "\.is_App u \ set U \ Collect \.is_App" + assume 2: "\ Ide (\.un_App2 u # map \.un_App2 U)" + assume 3: "\.sseq (u1 \<^bold>\ u2) u \ Std (u # U)" + assume 4: "\ \.Ide u2" + show "\ \.Ide (\.un_App2 u) \ \.sseq u2 (\.un_App2 u)" + by (metis 1 3 4 \.elementary_reduction.simps(4) + \.elementary_reduction_not_ide \.ide_char \.lambda.collapse(3) + \.sseq.simps(4) \.sseq_imp_elementary_reduction1) + assume 5: "\.Ide (\.un_App2 u)" + have False + by (metis 1 3 4 5 \.elementary_reduction_not_ide \.ide_char + \.lambda.collapse(3) \.sseq.simps(4) \.sseq_imp_elementary_reduction2) + thus "\.sseq u2 (hd (filter notIde (map \.un_App2 U)))" by argo + qed + thus ?thesis + using U set u2 uU by blast + qed + thus ?thesis + by (metis "1" Std.simps(2) Std.simps(3) \U \ []\ ind list.exhaust_sel list.sel(1) + \.sseq_imp_elementary_reduction1) + qed + qed + qed + qed + qed + + text \ + If the first step in a standard reduction path contracts a redex that is + not at the head position, then all subsequent terms have \App\ as their + top-level operator. + \ + + lemma seq_App_Std_implies: + shows "\t. \Std (t # U); \.is_App t \ \ \.contains_head_reduction t\ + \ set U \ Collect \.is_App" + proof (induct U) + show "\t. \Std [t]; \.is_App t \ \ \.contains_head_reduction t\ + \ set [] \ Collect \.is_App" + by simp + fix t u U + assume ind: "\t. \Std (t # U); \.is_App t \ \ \.contains_head_reduction t\ + \ set U \ Collect \.is_App" + assume Std: "Std (t # u # U)" + assume t: "\.is_App t \ \ \.contains_head_reduction t" + have U: "set (u # U) \ Collect \.elementary_reduction" + using Std Std_implies_set_subset_elementary_reduction by fastforce + have u: "\.elementary_reduction u" + using U by simp + have "set U \ Collect \.elementary_reduction" + using U by simp + show "set (u # U) \ Collect \.is_App" + proof (cases "U = []") + show "U = [] \ ?thesis" + by (metis Std empty_set empty_subsetI insert_subset + \.sseq_preserves_App_and_no_head_reduction list.sel(1) list.simps(15) + mem_Collect_eq reduction_paths.Std.simps(3) t) + assume U: "U \ []" + have "\.sseq t u" + using Std by auto + hence "\.is_App u \ \ \.Ide u \ \ \.contains_head_reduction u" + using t u U \.sseq_preserves_App_and_no_head_reduction [of t u] + \.elementary_reduction_not_ide + by blast + thus ?thesis + using Std ind [of u] \set U \ Collect \.elementary_reduction\ by simp + qed + qed + + subsection "Standard Developments" + + text \ + The following function takes a term \t\ (representing a parallel reduction) + and produces a standard reduction path that is a complete development of \t\ + and is thus congruent to \[t]\. The proof of termination makes use of the + Finite Development Theorem. + \ + + function (sequential) standard_development + where "standard_development \<^bold>\ = []" + | "standard_development \<^bold>\_\<^bold>\ = []" + | "standard_development \<^bold>\\<^bold>[t\<^bold>] = map \.Lam (standard_development t)" + | "standard_development (t \<^bold>\ u) = + (if \.Arr t \ \.Arr u then + map (\v. v \<^bold>\ \.Src u) (standard_development t) @ + map (\v. \.Trg t \<^bold>\ v) (standard_development u) + else [])" + | "standard_development (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = + (if \.Arr t \ \.Arr u then + (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) # standard_development (\.subst u t) + else [])" + by pat_completeness auto + + abbreviation (in lambda_calculus) stddev_term_rel + where "stddev_term_rel \ mlex_prod hgt subterm_rel" + + lemma (in lambda_calculus) subst_lt_Beta: + assumes "Arr t" and "Arr u" + shows "(subst u t, \<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ stddev_term_rel" + proof - + have "(\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \\ (\<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u) = subst u t" + using assms + by (metis Arr_not_Nil Ide_Src Ide_iff_Src_self Ide_implies_Arr resid.simps(4) + resid_Arr_Ide) + moreover have "elementary_reduction (\<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u)" + by (simp add: assms Ide_Src) + moreover have "\<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u \ \<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u" + by (metis assms Arr.simps(5) head_redex.simps(9) subs_head_redex) + ultimately show ?thesis + using assms elementary_reduction_decreases_hgt [of "\<^bold>\\<^bold>[Src t\<^bold>] \<^bold>\ Src u" "\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u"] + by (metis mlex_less) + qed + + termination standard_development + proof (relation \.stddev_term_rel) + show "wf \.stddev_term_rel" + using \.wf_subterm_rel wf_mlex by blast + show "\t. (t, \<^bold>\\<^bold>[t\<^bold>]) \ \.stddev_term_rel" + by (simp add: \.subterm_lemmas(1) mlex_prod_def) + show "\t u. (t, t \<^bold>\ u) \ \.stddev_term_rel" + using \.subterm_lemmas(3) + by (metis antisym_conv1 \.hgt.simps(4) le_add1 mem_Collect_eq mlex_iff old.prod.case) + show "\t u. (u, t \<^bold>\ u) \ \.stddev_term_rel" + using \.subterm_lemmas(3) by (simp add: mlex_leq) + show "\t u. \.Arr t \ \.Arr u \ (\.subst u t, \<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ \.stddev_term_rel" + using \.subst_lt_Beta by simp + qed + + lemma Ide_iff_standard_development_empty: + shows "\.Arr t \ \.Ide t \ standard_development t = []" + by (induct t) auto + + lemma set_standard_development: + shows "\.Arr t \ set (standard_development t) \ Collect \.elementary_reduction" + apply (rule standard_development.induct) + using \.Ide_Src \.Ide_Trg \.Arr_Subst by auto + + lemma cong_standard_development: + shows "\.Arr t \ \ \.Ide t \ standard_development t \<^sup>*\\<^sup>* [t]" + proof (rule standard_development.induct) + show "\.Arr \<^bold>\ \ \ \.Ide \<^bold>\ \ standard_development \<^bold>\ \<^sup>*\\<^sup>* [\<^bold>\]" + by simp + show "\x. \.Arr \<^bold>\x\<^bold>\ \ \ \.Ide \<^bold>\x\<^bold>\ + \ standard_development \<^bold>\x\<^bold>\ \<^sup>*\\<^sup>* [\<^bold>\x\<^bold>\]" + by simp + show "\t. \.Arr t \ \ \.Ide t \ standard_development t \<^sup>*\\<^sup>* [t] \ + \.Arr \<^bold>\\<^bold>[t\<^bold>] \ \ \.Ide \<^bold>\\<^bold>[t\<^bold>] \ standard_development \<^bold>\\<^bold>[t\<^bold>] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>]]" + by (metis (mono_tags, lifting) cong_map_Lam \.Arr.simps(3) \.Ide.simps(3) + list.simps(8,9) standard_development.simps(3)) + show "\t u. \\.Arr t \ \.Arr u + \ \.Arr t \ \ \.Ide t \ standard_development t \<^sup>*\\<^sup>* [t]; + \.Arr t \ \.Arr u + \ \.Arr u \ \ \.Ide u \ standard_development u \<^sup>*\\<^sup>* [u]\ + \ \.Arr (t \<^bold>\ u) \ \ \.Ide (t \<^bold>\ u) \ + standard_development (t \<^bold>\ u) \<^sup>*\\<^sup>* [t \<^bold>\ u]" + proof + fix t u + assume ind1: "\.Arr t \ \.Arr u + \ \.Arr t \ \ \.Ide t \ standard_development t \<^sup>*\\<^sup>* [t]" + assume ind2: "\.Arr t \ \.Arr u + \ \.Arr u \ \ \.Ide u \ standard_development u \<^sup>*\\<^sup>* [u]" + assume 1: "\.Arr (t \<^bold>\ u) \ \ \.Ide (t \<^bold>\ u)" + show "standard_development (t \<^bold>\ u) \<^sup>*\\<^sup>* [t \<^bold>\ u]" + proof (cases "standard_development t = []") + show "standard_development t = [] \ ?thesis" + using 1 ind2 cong_map_App1 Ide_iff_standard_development_empty \.Ide_iff_Trg_self + apply simp + by (metis (no_types, opaque_lifting) list.simps(8,9)) + assume t: "standard_development t \ []" + show ?thesis + proof (cases "standard_development u = []") + assume u: "standard_development u = []" + have "standard_development (t \<^bold>\ u) = map (\X. X \<^bold>\ u) (standard_development t)" + using u 1 \.Ide_iff_Src_self ide_char ind2 by auto + also have "... \<^sup>*\\<^sup>* map (\a. a \<^bold>\ u) [t]" + using cong_map_App2 [of u] + by (meson 1 \.Arr.simps(4) Ide_iff_standard_development_empty t u ind1) + also have "map (\a. a \<^bold>\ u) [t] = [t \<^bold>\ u]" + by simp + finally show ?thesis by blast + next + assume u: "standard_development u \ []" + have "standard_development (t \<^bold>\ u) = + map (\a. a \<^bold>\ \.Src u) (standard_development t) @ + map (\b. \.Trg t \<^bold>\ b) (standard_development u)" + using 1 by force + moreover have "map (\a. a \<^bold>\ \.Src u) (standard_development t) \<^sup>*\\<^sup>* [t \<^bold>\ \.Src u]" + proof - + have "map (\a. a \<^bold>\ \.Src u) (standard_development t) \<^sup>*\\<^sup>* map (\a. a \<^bold>\ \.Src u) [t]" + using t u 1 ind1 \.Ide_Src Ide_iff_standard_development_empty cong_map_App2 + by (metis \.Arr.simps(4)) + also have "map (\a. a \<^bold>\ \.Src u) [t] = [t \<^bold>\ \.Src u]" + by simp + finally show ?thesis by blast + qed + moreover have "map (\b. \.Trg t \<^bold>\ b) (standard_development u) \<^sup>*\\<^sup>* [\.Trg t \<^bold>\ u]" + using t u 1 ind2 \.Ide_Trg Ide_iff_standard_development_empty cong_map_App1 + by (metis (mono_tags, opaque_lifting) \.Arr.simps(4) list.simps(8,9)) + moreover have "seq (map (\a. a \<^bold>\ \.Src u) (standard_development t)) + (map (\b. \.Trg t \<^bold>\ b) (standard_development u))" + using 1 u seqI\<^sub>\\<^sub>P Con_implies_Arr(1) Ide.simps(1) calculation(2) ide_char + Ide_iff_standard_development_empty Src_hd_eqI Trg_last_eqI + calculation(2-3) hd_map ind2 \.Arr.simps(4) \.Src.simps(4) + \.Src_Trg \.Trg.simps(3) \.Trg_Src last_ConsL list.sel(1) + by (metis (no_types, lifting)) + ultimately have "standard_development (t \<^bold>\ u) \<^sup>*\\<^sup>* [t \<^bold>\ \.Src u] @ [\.Trg t \<^bold>\ u]" + using cong_append [of "map (\a. a \<^bold>\ \.Src u) (standard_development t)" + "map (\b. \.Trg t \<^bold>\ b) (standard_development u)" + "[t \<^bold>\ \.Src u]" "[\.Trg t \<^bold>\ u]"] + by simp + moreover have "[t \<^bold>\ \.Src u] @ [\.Trg t \<^bold>\ u] \<^sup>*\\<^sup>* [t \<^bold>\ u]" + using 1 \.Ide_Trg \.resid_Arr_Src \.resid_Arr_self \.null_char + ide_char \.Arr_not_Nil + by simp + ultimately show ?thesis + using cong_transitive by blast + qed + qed + qed + show "\t u. (\.Arr t \ \.Arr u \ + \.Arr (\.subst u t) \ \ \.Ide (\.subst u t) + \ standard_development (\.subst u t) \<^sup>*\\<^sup>* [\.subst u t]) \ + \.Arr (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ \ \.Ide (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ + standard_development (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + proof + fix t u + assume 1: "\.Arr (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \ \ \.Ide (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + assume ind: "\.Arr t \ \.Arr u \ + \.Arr (\.subst u t) \ \ \.Ide (\.subst u t) + \ standard_development (\.subst u t) \<^sup>*\\<^sup>* [\.subst u t]" + show "standard_development (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + proof (cases "\.Ide (\.subst u t)") + assume 2: "\.Ide (\.subst u t)" + have "standard_development (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u]" + using 1 2 Ide_iff_standard_development_empty [of "\.subst u t"] \.Arr_Subst + by simp + also have "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + using 1 2 \.Ide_Src \.Ide_implies_Arr ide_char \.resid_Arr_Ide + apply (intro conjI) + apply simp_all + apply (metis \.Ide.simps(1) \.Ide_Subst_iff \.Ide_Trg) + by fastforce + finally show ?thesis by blast + next + assume 2: "\ \.Ide (\.subst u t)" + have "standard_development (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) = + [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ standard_development (\.subst u t)" + using 1 by auto + also have "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ standard_development (\.subst u t) \<^sup>*\\<^sup>* + [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t]" + proof (intro cong_append) + show "seq [\.Beta (\.Src t) (\.Src u)] (standard_development (\.subst u t))" + using 1 2 ind arr_char ide_implies_arr \.Arr_Subst Con_implies_Arr(1) Src_hd_eqI + apply (intro seqI\<^sub>\\<^sub>P) + apply simp_all + by (metis Arr.simps(1)) + show "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u]" + using 1 + by (metis \.Arr.simps(5) \.Ide_Src \.Ide_implies_Arr Arr.simps(2) Resid_Arr_self + ide_char \.arr_char) + show "standard_development (\.subst u t) \<^sup>*\\<^sup>* [\.subst u t]" + using 1 2 \.Arr_Subst ind by simp + qed + also have "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + proof + show "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]" + proof - + have "t \\ \.Src t \ \<^bold>\ \ u \\ \.Src u \ \<^bold>\" + by (metis "1" \.Arr.simps(5) \.Coinitial_iff_Con \.Ide_Src \.Ide_iff_Src_self + \.Ide_implies_Arr) + moreover have "\.con (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + by (metis "1" \.head_redex.simps(9) \.prfx_implies_con \.subs_head_redex + \.subs_implies_prfx) + ultimately have "([\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t]) \<^sup>*\\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] = + [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] \<^sup>*\\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] @ + [\.subst u t] \<^sup>*\\\<^sup>* ([\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] \<^sup>*\\\<^sup>* [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u])" + using Resid_append(1) + [of "[\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u]" "[\.subst u t]" "[\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u]"] + apply simp + by (metis \.Arr_Subst \.Coinitial_iff_Con \.Ide_Src \.resid_Arr_Ide) + also have "... = [\.subst (\.Trg u) (\.Trg t)] @ ([\.subst u t] \<^sup>*\\\<^sup>* [\.subst u t])" + proof - + have "t \\ \.Src t \ \<^bold>\ \ u \\ \.Src u \ \<^bold>\" + by (metis "1" \.Arr.simps(5) \.Coinitial_iff_Con \.Ide_Src + \.Ide_iff_Src_self \.Ide_implies_Arr) + moreover have "\.Src t \\ t \ \<^bold>\ \ \.Src u \\ u \ \<^bold>\" + using \.Con_sym calculation(1) by presburger + moreover have "\.con (\.subst u t) (\.subst u t)" + by (meson \.Arr_Subst \.Con_implies_Arr2 \.arr_char \.arr_def calculation(2)) + moreover have "\.con (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u)" + using \\.con (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)\ \.con_sym by blast + moreover have "\.con (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)" + using \\.con (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u)\ by blast + moreover have "\.con (\.subst u t) (\.subst (u \\ \.Src u) (t \\ \.Src t))" + by (metis \.Coinitial_iff_Con \.Ide_Src calculation(1-3) \.resid_Arr_Ide) + ultimately show ?thesis + using "1" by auto + qed + finally have "([\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t]) \<^sup>*\\\<^sup>* [\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] = + [\.subst (\.Trg u) (\.Trg t)] @ [\.subst u t] \<^sup>*\\\<^sup>* [\.subst u t]" + by blast + moreover have "Ide ..." + by (metis "1" "2" \.Arr.simps(5) \.Arr_Subst \.Ide_Subst \.Ide_Trg + Nil_is_append_conv Arr_append_iff\<^sub>P\<^sub>W\<^sub>E Con_implies_Arr(2) Ide.simps(1-2) + Ide_appendI\<^sub>P\<^sub>W\<^sub>E Resid_Arr_self ide_char calculation \.ide_char ind + Con_imp_Arr_Resid) + ultimately show ?thesis + using ide_char by presburger + qed + show "[\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t]" + proof - + have "[\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] \<^sup>*\\\<^sup>* ([\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t]) = + ([\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] \<^sup>*\\\<^sup>* [\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u]) \<^sup>*\\\<^sup>* [\.subst u t]" + by fastforce + also have "... = [\.subst u t] \<^sup>*\\\<^sup>* [\.subst u t]" + proof - + have "t \\ \.Src t \ \<^bold>\ \ u \\ \.Src u \ \<^bold>\" + by (metis "1" \.Arr.simps(5) \.Coinitial_iff_Con \.Ide_Src + \.Ide_iff_Src_self \.Ide_implies_Arr) + moreover have "\.con (\.subst u t) (\.subst u t)" + by (metis "1" \.Arr.simps(5) \.Arr_Subst \.Coinitial_iff_Con + \.con_def \.null_char) + moreover have "\.con (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u)" + by (metis "1" \.Con_sym \.con_def \.head_redex.simps(9) \.null_char + \.prfx_implies_con \.subs_head_redex \.subs_implies_prfx) + moreover have "\.con (\.subst (u \\ \.Src u) (t \\ \.Src t)) (\.subst u t)" + by (metis \.Coinitial_iff_Con \.Ide_Src calculation(1) calculation(2) + \.resid_Arr_Ide) + ultimately show ?thesis + using \.resid_Arr_Ide + apply simp + by (metis \.Coinitial_iff_Con \.Ide_Src) + qed + finally have "[\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u] \<^sup>*\\\<^sup>* ([\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u] @ [\.subst u t]) = + [\.subst u t] \<^sup>*\\\<^sup>* [\.subst u t]" + by blast + moreover have "Ide ..." + by (metis "1" "2" \.Arr.simps(5) \.Arr_Subst Con_implies_Arr(2) Resid_Arr_self + ind ide_char) + ultimately show ?thesis + using ide_char by presburger + qed + qed + finally show ?thesis by blast + qed + qed + qed + + lemma Src_hd_standard_development: + assumes "\.Arr t" and "\ \.Ide t" + shows "\.Src (hd (standard_development t)) = \.Src t" + by (metis assms Src_hd_eqI cong_standard_development list.sel(1)) + + lemma Trg_last_standard_development: + assumes "\.Arr t" and "\ \.Ide t" + shows "\.Trg (last (standard_development t)) = \.Trg t" + by (metis assms Trg_last_eqI cong_standard_development last_ConsL) + + lemma Srcs_standard_development: + shows "\\.Arr t; standard_development t \ []\ + \ Srcs (standard_development t) = {\.Src t}" + by (metis Con_implies_Arr(1) Ide.simps(1) Ide_iff_standard_development_empty + Src_hd_standard_development Srcs_simp\<^sub>\\<^sub>P cong_standard_development ide_char) + + lemma Trgs_standard_development: + shows "\\.Arr t; standard_development t \ []\ + \ Trgs (standard_development t) = {\.Trg t}" + by (metis Con_implies_Arr(2) Ide.simps(1) Ide_iff_standard_development_empty + Trg_last_standard_development Trgs_simp\<^sub>\\<^sub>P cong_standard_development ide_char) + + lemma development_standard_development: + shows "\.Arr t \ development t (standard_development t)" + apply (rule standard_development.induct) + apply blast + apply simp + apply (simp add: development_map_Lam) + proof + fix t1 t2 + assume ind1: "\.Arr t1 \ \.Arr t2 + \ \.Arr t1 \ development t1 (standard_development t1)" + assume ind2: "\.Arr t1 \ \.Arr t2 + \ \.Arr t2 \ development t2 (standard_development t2)" + assume t: "\.Arr (t1 \<^bold>\ t2)" + show "development (t1 \<^bold>\ t2) (standard_development (t1 \<^bold>\ t2))" + proof (cases "standard_development t1 = []") + show "standard_development t1 = [] + \ development (t1 \<^bold>\ t2) (standard_development (t1 \<^bold>\ t2))" + using t ind2 \.Ide_Src \.Ide_Trg \.Ide_iff_Src_self \.Ide_iff_Trg_self + Ide_iff_standard_development_empty + development_map_App_2 [of "\.Src t1" t2 "standard_development t2"] + by fastforce + assume t1: "standard_development t1 \ []" + show "development (t1 \<^bold>\ t2) (standard_development (t1 \<^bold>\ t2))" + proof (cases "standard_development t2 = []") + assume t2: "standard_development t2 = []" + show ?thesis + using t t2 ind1 Ide_iff_standard_development_empty development_map_App_1 by simp + next + assume t2: "standard_development t2 \ []" + have "development (t1 \<^bold>\ t2) (map (\a. a \<^bold>\ \.Src t2) (standard_development t1))" + using \.Arr.simps(4) development_map_App_1 ind1 t by presburger + moreover have "development ((t1 \<^bold>\ t2) \<^sup>1\\\<^sup>* + map (\a. a \<^bold>\ \.Src t2) (standard_development t1)) + (map (\a. \.Trg t1 \<^bold>\ a) (standard_development t2))" + proof - + have "\.App t1 t2 \<^sup>1\\\<^sup>* map (\a. a \<^bold>\ \.Src t2) (standard_development t1) = + \.Trg t1 \<^bold>\ t2" + proof - + have "map (\a. a \<^bold>\ \.Src t2) (standard_development t1) \<^sup>*\\<^sup>* [t1 \<^bold>\ \.Src t2]" + proof - + have "map (\a. a \<^bold>\ \.Src t2) (standard_development t1) = + standard_development (t1 \<^bold>\ \.Src t2)" + by (metis \.Arr.simps(4) \.Ide_Src \.Ide_iff_Src_self + Ide_iff_standard_development_empty \.Ide_implies_Arr Nil_is_map_conv + append_Nil2 standard_development.simps(4) t) + also have "standard_development (t1 \<^bold>\ \.Src t2) \<^sup>*\\<^sup>* [t1 \<^bold>\ \.Src t2]" + by (metis \.Arr.simps(4) \.Ide.simps(4) \.Ide_Src \.Ide_implies_Arr + cong_standard_development development_Ide ind1 t t1) + finally show ?thesis by blast + qed + hence "[t1 \<^bold>\ t2] \<^sup>*\\\<^sup>* map (\a. a \<^bold>\ \.Src t2) (standard_development t1) = + [t1 \<^bold>\ t2] \<^sup>*\\\<^sup>* [t1 \<^bold>\ \.Src t2]" + by (metis Resid_parallel con_imp_coinitial prfx_implies_con calculation + development_implies map_is_Nil_conv t1) + also have "[t1 \<^bold>\ t2] \<^sup>*\\\<^sup>* [t1 \<^bold>\ \.Src t2] = [\.Trg t1 \<^bold>\ t2]" + using t \.arr_resid_iff_con \.resid_Arr_self + by simp force + finally have "[t1 \<^bold>\ t2] \<^sup>*\\\<^sup>* map (\a. a \<^bold>\ \.Src t2) (standard_development t1) = + [\.Trg t1 \<^bold>\ t2]" + by blast + thus ?thesis + by (simp add: Resid1x_as_Resid') + qed + thus ?thesis + by (metis ind2 \.Arr.simps(4) \.Ide_Trg \.Ide_iff_Src_self development_map_App_2 + \.reduction_strategy_def \.head_strategy_is_reduction_strategy t) + qed + ultimately show ?thesis + using t development_append [of "t1 \<^bold>\ t2" + "map (\a. a \<^bold>\ \.Src t2) (standard_development t1)" + "map (\b. \.Trg t1 \<^bold>\ b) (standard_development t2)"] + by auto + qed + qed + next + fix t1 t2 + assume ind: "\.Arr t1 \ \.Arr t2 \ + \.Arr (\.subst t2 t1) + \ development (\.subst t2 t1) (standard_development (\.subst t2 t1))" + show "\.Arr (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) \ development (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) (standard_development (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2))" + proof + assume 1: "\.Arr (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)" + have "development (\.subst t2 t1) (standard_development (\.subst t2 t1))" + using 1 ind by (simp add: \.Arr_Subst) + thus "development (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) (standard_development (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2))" + using 1 \.Ide_Src \.subs_Ide by auto + qed + qed + + lemma Std_standard_development: + shows "Std (standard_development t)" + apply (rule standard_development.induct) + apply simp_all + using Std_map_Lam + apply blast + proof + fix t u + assume t: "\.Arr t \ \.Arr u \ Std (standard_development t)" + assume u: "\.Arr t \ \.Arr u \ Std (standard_development u)" + assume 0: "\.Arr t \ \.Arr u" + show "Std (map (\a. a \<^bold>\ \.Src u) (standard_development t) @ + map (\b. \.Trg t \<^bold>\ b) (standard_development u))" + proof (cases "\.Ide t") + show "\.Ide t \ ?thesis" + using 0 \.Ide_iff_Trg_self Ide_iff_standard_development_empty u Std_map_App2 + by fastforce + assume 1: "\ \.Ide t" + show ?thesis + proof (cases "\.Ide u") + show "\.Ide u \ ?thesis" + using t u 0 1 Std_map_App1 [of "\.Src u" "standard_development t"] \.Ide_Src + by (metis Ide_iff_standard_development_empty append_Nil2 list.simps(8)) + assume 2: "\ \.Ide u" + show ?thesis + proof (intro Std_append) + show 3: "Std (map (\a. a \<^bold>\ \.Src u) (standard_development t))" + using t 0 Std_map_App1 \.Ide_Src by blast + show "Std (map (\b. \.Trg t \<^bold>\ b) (standard_development u))" + using u 0 Std_map_App2 \.Ide_Trg by simp + show "map (\a. a \<^bold>\ \.Src u) (standard_development t) = [] \ + map (\b. \.Trg t \<^bold>\ b) (standard_development u) = [] \ + \.sseq (last (map (\a. a \<^bold>\ \.Src u) (standard_development t))) + (hd (map (\b. \.Trg t \<^bold>\ b) (standard_development u)))" + proof - + have "\.sseq (last (map (\a. a \<^bold>\ \.Src u) (standard_development t))) + (hd (map (\b. \.Trg t \<^bold>\ b) (standard_development u)))" + proof - + obtain x where x: "last (map (\a. a \<^bold>\ \.Src u) (standard_development t)) = + x \<^bold>\ \.Src u" + using 0 1 Ide_iff_standard_development_empty last_map by auto + obtain y where y: "hd (map (\b. \.Trg t \<^bold>\ b) (standard_development u)) = + \.Trg t \<^bold>\ y" + using 0 2 Ide_iff_standard_development_empty list.map_sel(1) by auto + have "\.elementary_reduction x" + proof - + have "\.elementary_reduction (x \<^bold>\ \.Src u)" + using x + by (metis 0 1 3 Ide_iff_standard_development_empty Nil_is_map_conv Std.simps(2) + Std_imp_sseq_last_hd append_butlast_last_id append_self_conv2 list.discI + list.sel(1) \.sseq_imp_elementary_reduction2) + thus ?thesis + using 0 \.Ide_Src \.elementary_reduction_not_ide by auto + qed + moreover have "\.elementary_reduction y" + proof - + have "\.elementary_reduction (\.Trg t \<^bold>\ y)" + using y + by (metis 0 2 \.Ide_Trg Ide_iff_standard_development_empty + u Std.elims(2) \.elementary_reduction.simps(4) list.map_sel(1) list.sel(1) + \.sseq_imp_elementary_reduction1) + thus ?thesis + using 0 \.Ide_Trg \.elementary_reduction_not_ide by auto + qed + moreover have "\.Trg t = \.Trg x" + by (metis 0 1 Ide_iff_standard_development_empty Trg_last_standard_development + x \.lambda.inject(3) last_map) + moreover have "\.Src u = \.Src y" + using y + by (metis 0 2 \.Arr_not_Nil \.Coinitial_iff_Con + Ide_iff_standard_development_empty development.elims(2) development_imp_Arr + development_standard_development \.lambda.inject(3) list.map_sel(1) + list.sel(1)) + ultimately show ?thesis + using x y by simp + qed + thus ?thesis by blast + qed + qed + qed + qed + next + fix t u + assume ind: "\.Arr t \ \.Arr u \ Std (standard_development (\.subst u t))" + show "\.Arr t \ \.Arr u + \ Std ((\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) # standard_development (\.subst u t))" + proof + assume 1: "\.Arr t \ \.Arr u" + show "Std ((\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) # standard_development (\.subst u t))" + proof (cases "\.Ide (\.subst u t)") + show "\.Ide (\.subst u t) + \ Std ((\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) # standard_development (\.subst u t))" + using 1 \.Arr_Subst \.Ide_Src Ide_iff_standard_development_empty by simp + assume 2: "\ \.Ide (\.subst u t)" + show "Std ((\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) # standard_development (\.subst u t))" + proof - + have "\.sseq (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) (hd (standard_development (\.subst u t)))" + proof - + have "\.elementary_reduction (hd (standard_development (\.subst u t)))" + using ind + by (metis 1 2 \.Arr_Subst Ide_iff_standard_development_empty + Std.elims(2) list.sel(1) \.sseq_imp_elementary_reduction1) + moreover have "\.seq (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) + (hd (standard_development (\.subst u t)))" + using 1 2 Src_hd_standard_development calculation \.Arr.simps(5) + \.Arr_Src \.Arr_Subst \.Src_Subst \.Trg.simps(4) \.Trg_Src \.arr_char + \.elementary_reduction_is_arr \.seq_char + by presburger + ultimately show ?thesis + using 1 \.Ide_Src \.sseq_Beta by auto + qed + moreover have "Std (standard_development (\.subst u t))" + using 1 ind by blast + ultimately show ?thesis + by (metis 1 2 \.Arr_Subst Ide_iff_standard_development_empty Std.simps(3) + list.collapse) + qed + qed + qed + qed + + subsection "Standardization" + + text \ + In this section, we define and prove correct a function that takes an arbitrary + reduction path and produces a standard reduction path congruent to it. + The method is roughly analogous to insertion sort: given a path, recursively + standardize the tail and then ``insert'' the head into to the result. + A complication is that in general the head may be a parallel reduction instead + of an elementary reduction, and in any case elementary reductions are + not preserved under residuation so we need to be able to handle the parallel + reductions that arise from permuting elementary reductions. + In general, this means that parallel reduction steps have to be decomposed into factors, + and then each factor has to be inserted at its proper position. + Another issue is that reductions don't all happen at the top level of a term, + so we need to be able to descend recursively into terms during the insertion + procedure. The key idea here is: in a standard reduction, once a step has occurred + that is not a head reduction, then all subsequent terms will have \App\ as their + top-level constructor. So, once we have passed a step that is not a head reduction, + we can recursively descend into the subsequent applications and treat the ``rator'' + and the ``rand'' parts independently. + + The following function performs the core insertion part of the standardization + algorithm. It assumes that it is given an arbitrary parallel reduction \t\ and + an already-standard reduction path \U\, and it inserts \t\ into \U\, producing a + standard reduction path that is congruent to \t # U\. A somewhat elaborate case + analysis is required to determine whether \t\ needs to be factored and whether + part of it might need to be permuted with the head of \U\. The recursion is complicated + by the need to make sure that the second argument \U\ is always a standard reduction + path. This is so that it is possible to decide when the rest of the steps will be + applications and it is therefore possible to recurse into them. This constrains what + recursive calls we can make, since we are not able to make a recursive call in which + an identity has been prepended to \U\. Also, if \t # U\ consists completely of + identities, then its standardization is the empty list \[]\, which is not a path + and cannot be congruent to \t # U\. So in order to be able to apply the induction + hypotheses in the correctness proof, we need to make sure that we don't make + recursive calls when \U\ itself would consist entirely of identities. + Finally, when we descend through an application, the step \t\ and the path \U\ are + projected to their ``rator'' and ``rand'' components, which are treated separately + and the results concatenated. However, the projection operations can introduce + identities and therefore do not preserve elementary reductions. To handle this, + we need to filter out identities after projection but before the recursive call. + + Ensuring termination also involves some care: we make recursive calls in which + the length of the second argument is increased, but the ``height'' of the first + argument is decreased. So we use a lexicographic order that makes the height + of the first argument more significant and the length of the second argument + secondary. The base cases either discard paths that consist entirely of + identities, or else they expand a single parallel reduction \t\ into a standard + development. + \ + + function (sequential) stdz_insert + where "stdz_insert t [] = standard_development t" + | "stdz_insert \<^bold>\_\<^bold>\ U = stdz_insert (hd U) (tl U)" + | "stdz_insert \<^bold>\\<^bold>[t\<^bold>] U = + (if \.Ide t then + stdz_insert (hd U) (tl U) + else + map \.Lam (stdz_insert t (map \.un_Lam U)))" + | "stdz_insert (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) ((\<^bold>\\<^bold>[_\<^bold>] \<^bold>\ _) # U) = stdz_insert (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) U" + | "stdz_insert (t \<^bold>\ u) U = + (if \.Ide (t \<^bold>\ u) then + stdz_insert (hd U) (tl U) + else if \.seq (t \<^bold>\ u) (hd U) then + if \.contains_head_reduction (t \<^bold>\ u) then + if \.Ide ((t \<^bold>\ u) \\ \.head_redex (t \<^bold>\ u)) then + \.head_redex (t \<^bold>\ u) # stdz_insert (hd U) (tl U) + else + \.head_redex (t \<^bold>\ u) # stdz_insert ((t \<^bold>\ u) \\ \.head_redex (t \<^bold>\ u)) U + else if \.contains_head_reduction (hd U) then + if \.Ide ((t \<^bold>\ u) \\ \.head_strategy (t \<^bold>\ u)) then + stdz_insert (\.head_strategy (t \<^bold>\ u)) (tl U) + else + \.head_strategy (t \<^bold>\ u) # stdz_insert ((t \<^bold>\ u) \\ \.head_strategy (t \<^bold>\ u)) (tl U) + else + map (\a. a \<^bold>\ \.Src u) + (stdz_insert t (filter notIde (map \.un_App1 U))) @ + map (\b. \.Trg (\.un_App1 (last U)) \<^bold>\ b) + (stdz_insert u (filter notIde (map \.un_App2 U))) + else [])" + | "stdz_insert (\<^bold>\\<^bold>[t\<^bold>] \<^bold>\ u) U = + (if \.Arr t \ \.Arr u then + (\<^bold>\\<^bold>[\.Src t\<^bold>] \<^bold>\ \.Src u) # stdz_insert (\.subst u t) U + else [])" + | "stdz_insert _ _ = []" + by pat_completeness auto + + (* + * TODO: + * In the case "stdz_insert (M \<^bold>\ N) U": + * The "if \.seq (M \<^bold>\ N) (hd U)" is needed for the termination proof. + * The first "if \.Ide (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N)))" + * cannot be removed because the resulting induction rule does not contain + * the induction hypotheses necessary to prove the correctness. + * The second "if \.Ide (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N)))" + * results in a similar, but different problem. + * In the case "stdz_insert (\.Beta M N) U": + * The "if \.Arr M \ \.Arr N" is needed for the termination proof. + * It is possible that the function would still be correct if some of the tests + * for whether the term being inserted is an identity were omitted, but if these + * tests are removed, then the correctness proof fails ways that are not obviously + * repairable, probably due to the induction rule not having all the needed + * induction hypotheses. + *) + + fun standardize + where "standardize [] = []" + | "standardize U = stdz_insert (hd U) (standardize (tl U))" + + abbreviation stdzins_rel + where "stdzins_rel \ mlex_prod (length o snd) (inv_image (mlex_prod \.hgt \.subterm_rel) fst)" + + termination stdz_insert + using \.subterm.intros(2-3) \.hgt_Subst less_Suc_eq_le \.elementary_reduction_decreases_hgt + \.elementary_reduction_head_redex \.contains_head_reduction_iff + \.elementary_reduction_is_arr \.Src_head_redex \.App_Var_contains_no_head_reduction + \.hgt_resid_App_head_redex \.seq_char + apply (relation stdzins_rel) + apply (auto simp add: wf_mlex \.wf_subterm_rel mlex_iff mlex_less \.subterm_lemmas(1)) + by (meson dual_order.eq_iff length_filter_le not_less_eq_eq)+ + + lemma stdz_insert_Ide: + shows "\t. Ide (t # U) \ stdz_insert t U = []" + proof (induct U) + show "\t. Ide [t] \ stdz_insert t [] = []" + by (metis Ide_iff_standard_development_empty \.Ide_implies_Arr Ide.simps(2) + \.ide_char stdz_insert.simps(1)) + show "\U. \\t. Ide (t # U) \ stdz_insert t U = []; Ide (t # u # U)\ + \ stdz_insert t (u # U) = []" + for t u + using \.ide_char + apply (cases t; cases u) + apply simp_all + by fastforce + qed + + lemma stdz_insert_Ide_Std: + shows "\u. \\.Ide u; seq [u] U; Std U\ \ stdz_insert u U = stdz_insert (hd U) (tl U)" + proof (induct U) + show "\u. \\.Ide u; seq [u] []; Std []\ \ stdz_insert u [] = stdz_insert (hd []) (tl [])" + by (simp add: seq_char) + fix u v U + assume u: "\.Ide u" + assume seq: "seq [u] (v # U)" + assume Std: "Std (v # U)" + assume ind: "\u. \\.Ide u; seq [u] U; Std U\ + \ stdz_insert u U = stdz_insert (hd U) (tl U)" + show "stdz_insert u (v # U) = stdz_insert (hd (v # U)) (tl (v # U))" + using u ind stdz_insert_Ide Ide_implies_Arr + apply (cases u; cases v) + apply simp_all + proof - + fix x y a b + assume xy: "\.Ide x \ \.Ide y" + assume u': "u = x \<^bold>\ y" + assume v': "v = \<^bold>\\<^bold>[a\<^bold>] \<^bold>\ b" + have ab: "\.Ide a \ \.Ide b" + using Std \v = \<^bold>\\<^bold>[a\<^bold>] \<^bold>\ b\ Std.elims(2) \.sseq_Beta + by (metis Std_consE \.elementary_reduction.simps(5) Std.simps(2)) + have "x = \<^bold>\\<^bold>[a\<^bold>] \ y = b" + using xy ab u u' v' seq seq_char + by (metis \.Ide_iff_Src_self \.Ide_iff_Trg_self \.Ide_implies_Arr \.Src.simps(5) + Srcs_simp\<^sub>\\<^sub>P Trgs.simps(2) \.lambda.inject(3) list.sel(1) singleton_insert_inj_eq + \.targets_char\<^sub>\) + thus "stdz_insert (x \<^bold>\ y) ((\<^bold>\\<^bold>[a\<^bold>] \<^bold>\ b) # U) = stdz_insert (\<^bold>\\<^bold>[a\<^bold>] \<^bold>\ b) U" + using u u' stdz_insert.simps(4) by presburger + qed + qed + + text \ + Insertion of a term with \Beta\ as its top-level constructor always + leaves such a term at the head of the result. Stated another way, + \Beta\ at the top-level must always come first in a standard reduction path. + \ + + lemma stdz_insert_Beta_ind: + shows "\t U. \\.hgt t + length U \ n; \.is_Beta t; seq [t] U\ + \ \.is_Beta (hd (stdz_insert t U))" + proof (induct n) + show "\t U. \\.hgt t + length U \ 0; \.is_Beta t; seq [t] U\ + \ \.is_Beta (hd (stdz_insert t U))" + using Arr.simps(1) seq_char by blast + fix n t U + assume ind: "\t U. \\.hgt t + length U \ n; \.is_Beta t; seq [t] U\ + \ \.is_Beta (hd (stdz_insert t U))" + assume seq: "seq [t] U" + assume n: "\.hgt t + length U \ Suc n" + assume t: "\.is_Beta t" + show "\.is_Beta (hd (stdz_insert t U))" + using t seq seq_char + by (cases U; cases t; cases "hd U") auto + qed + + lemma stdz_insert_Beta: + assumes "\.is_Beta t" and "seq [t] U" + shows "\.is_Beta (hd (stdz_insert t U))" + using assms stdz_insert_Beta_ind by blast + + text \ + This is the correctness lemma for insertion: + Given a term \t\ and standard reduction path \U\ sequential with it, + the result of insertion is a standard reduction path which is + congruent to \t # U\ unless \t # U\ consists entirely of identities. + + The proof is very long. Its structure parallels that of the definition + of the function \stdz_insert\. For really understanding the details, + I strongly suggest viewing the proof in Isabelle/JEdit and using the + code folding feature to unfold the proof a little bit at a time. + \ + + lemma stdz_insert_correctness: + shows "seq [t] U \ Std U \ + Std (stdz_insert t U) \ (\ Ide (t # U) \ cong (stdz_insert t U) (t # U))" + (is "?P t U") + proof (rule stdz_insert.induct [of ?P]) + show "\t. ?P t []" + using seq_char by simp + show "\u U. ?P \<^bold>\ (u # U)" + using seq_char not_arr_null null_char by auto + show "\x u U. ?P (hd (u # U)) (tl (u # U)) \ ?P \<^bold>\x\<^bold>\ (u # U)" + proof - + fix x u U + assume ind: "?P (hd (u # U)) (tl (u # U))" + show "?P \<^bold>\x\<^bold>\ (u # U)" + proof (intro impI, elim conjE, intro conjI) + assume seq: "seq [\<^bold>\x\<^bold>\] (u # U)" + assume Std: "Std (u # U)" + have 1: "stdz_insert \<^bold>\x\<^bold>\ (u # U) = stdz_insert u U" + by simp + have 2: "U \ [] \ seq [u] U" + using Std Std_imp_Arr + by (simp add: arrI\<^sub>P arr_append_imp_seq) + show "Std (stdz_insert \<^bold>\x\<^bold>\ (u # U))" + using ind + by (metis 1 2 Std Std_standard_development list.exhaust_sel list.sel(1) list.sel(3) + reduction_paths.Std.simps(3) reduction_paths.stdz_insert.simps(1)) + show "\ Ide (\<^bold>\x\<^bold>\ # u # U) \ stdz_insert \<^bold>\x\<^bold>\ (u # U) \<^sup>*\\<^sup>* \<^bold>\x\<^bold>\ # u # U" + proof (cases "U = []") + show "U = [] \ ?thesis" + using cong_standard_development cong_cons_ideI(1) + apply simp + by (metis Arr.simps(1-2) Arr_iff_Con_self Con_rec(3) \.in_sourcesI con_char + cong_transitive ideE \.Ide.simps(2) \.arr_char \.ide_char seq) + assume U: "U \ []" + show ?thesis + using 1 2 ind seq seq_char cong_cons_ideI(1) + apply simp + by (metis Std Std_consE U \.Arr.simps(2) \.Ide.simps(2) \.targets_simps(2) + prfx_transitive) + qed + qed + qed + show "\M u U. \\.Ide M \ ?P (hd (u # U)) (tl (u # U)); + \ \.Ide M \ ?P M (map \.un_Lam (u # U))\ + \ ?P \<^bold>\\<^bold>[M\<^bold>] (u # U)" + proof - + fix M u U + assume ind1: "\.Ide M \ ?P (hd (u # U)) (tl (u # U))" + assume ind2: "\ \.Ide M \ ?P M (map \.un_Lam (u # U))" + show "?P \<^bold>\\<^bold>[M\<^bold>] (u # U)" + proof (intro impI, elim conjE) + assume seq: "seq [\<^bold>\\<^bold>[M\<^bold>]] (u # U)" + assume Std: "Std (u # U)" + have u: "\.is_Lam u" + using seq + by (metis insert_subset \.lambda.disc(8) list.simps(15) mem_Collect_eq + seq_Lam_Arr_implies) + have U: "set U \ Collect \.is_Lam" + using u seq + by (metis insert_subset \.lambda.disc(8) list.simps(15) seq_Lam_Arr_implies) + show "Std (stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U)) \ + (\ Ide (\<^bold>\\<^bold>[M\<^bold>] # u # U) \ stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) \<^sup>*\\<^sup>* \<^bold>\\<^bold>[M\<^bold>] # u # U)" + proof (cases "\.Ide M") + assume M: "\.Ide M" + have 1: "stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) = stdz_insert u U" + using M by simp + show ?thesis + proof (cases "Ide (u # U)") + show "Ide (u # U) \ ?thesis" + using 1 Std_standard_development Ide_iff_standard_development_empty + by (metis Ide_imp_Ide_hd Std Std_implies_set_subset_elementary_reduction + \.elementary_reduction_not_ide list.sel(1) list.set_intros(1) + mem_Collect_eq subset_code(1)) + assume 2: "\ Ide (u # U)" + show ?thesis + proof (cases "U = []") + assume 3: "U = []" + have 4: "standard_development u \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[M\<^bold>]] @ [u]" + using M 2 3 seq ide_char cong_standard_development [of u] + cong_append_ideI(1) [of "[\<^bold>\\<^bold>[M\<^bold>]]" "[u]"] + by (metis Arr_imp_arr_hd Ide.simps(2) Std Std_imp_Arr cong_transitive + \.Ide.simps(3) \.arr_char \.ide_char list.sel(1) not_Cons_self2) + show ?thesis + using 1 3 4 Std_standard_development by force + next + assume 3: "U \ []" + have "stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) = stdz_insert u U" + using M 3 by simp + have 5: "\.Arr u \ \ \.Ide u" + by (meson "3" Std Std_consE \.elementary_reduction_not_ide \.ide_char + \.sseq_imp_elementary_reduction1) + have 4: "standard_development u @ U \<^sup>*\\<^sup>* ([\<^bold>\\<^bold>[M\<^bold>]] @ [u]) @ U" + proof (intro cong_append seqI\<^sub>\\<^sub>P) + show "Arr (standard_development u)" + using 5 Std_standard_development Std_imp_Arr Ide_iff_standard_development_empty + by force + show "Arr U" + using Std 3 by auto + show "\.Trg (last (standard_development u)) = \.Src (hd U)" + by (metis "3" "5" Std Std_consE Trg_last_standard_development \.seq_char + \.sseq_imp_seq) + show "standard_development u \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[M\<^bold>]] @ [u]" + using M 5 Std Std_imp_Arr cong_standard_development [of u] + cong_append_ideI(3) [of "[\<^bold>\\<^bold>[M\<^bold>]]" "[u]"] + by (metis (no_types, lifting) Arr.simps(2) Ide.simps(2) arr_char ide_char + \.Ide.simps(3) \.arr_char \.ide_char prfx_transitive seq seq_def + sources_cons) + show "U \<^sup>*\\<^sup>* U" + by (simp add: \Arr U\ arr_char prfx_reflexive) + qed + show ?thesis + proof (intro conjI) + show "Std (stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U))" + by (metis (no_types, lifting) 1 3 M Std Std_consE append_Cons + append_eq_append_conv2 append_self_conv arr_append_imp_seq ind1 + list.sel(1) list.sel(3) not_Cons_self2 seq seq_def) + show "\ Ide (\<^bold>\\<^bold>[M\<^bold>] # u # U) \ stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) \<^sup>*\\<^sup>* \<^bold>\\<^bold>[M\<^bold>] # u # U" + proof + have "seq [u] U \ Std U" + using 2 3 Std + by (metis Cons_eq_appendI Std_consE arr_append_imp_seq neq_Nil_conv + self_append_conv2 seq seqE) + thus "stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) \<^sup>*\\<^sup>* \<^bold>\\<^bold>[M\<^bold>] # u # U" + using M 1 2 3 4 ind1 cong_cons_ideI(1) [of "\<^bold>\\<^bold>[M\<^bold>]" "u # U"] + apply simp + by (meson cong_transitive seq) + qed + qed + qed + qed + next + assume M: "\ \.Ide M" + have 1: "stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) = + map \.Lam (stdz_insert M (\.un_Lam u # map \.un_Lam U))" + using M by simp + show ?thesis + proof (intro conjI) + show "Std (stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U))" + by (metis "1" M Std Std_map_Lam Std_map_un_Lam ind2 \.lambda.disc(8) + list.simps(9) seq seq_Lam_Arr_implies seq_map_un_Lam) + show "\ Ide (\<^bold>\\<^bold>[M\<^bold>] # u # U) \ stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) \<^sup>*\\<^sup>* \<^bold>\\<^bold>[M\<^bold>] # u # U" + proof + have "map \.Lam (stdz_insert M (\.un_Lam u # map \.un_Lam U)) \<^sup>*\\<^sup>* + \<^bold>\\<^bold>[M\<^bold>] # u # U" + proof - + have "map \.Lam (stdz_insert M (\.un_Lam u # map \.un_Lam U)) \<^sup>*\\<^sup>* + map \.Lam (M # \.un_Lam u # map \.un_Lam U)" + by (metis (mono_tags, opaque_lifting) Ide_imp_Ide_hd M Std Std_map_un_Lam + cong_map_Lam ind2 \.ide_char \.lambda.discI(2) + list.sel(1) list.simps(9) seq seq_Lam_Arr_implies seq_map_un_Lam) + thus ?thesis + using u U + by (simp add: map_idI subset_code(1)) + qed + thus "stdz_insert \<^bold>\\<^bold>[M\<^bold>] (u # U) \<^sup>*\\<^sup>* \<^bold>\\<^bold>[M\<^bold>] # u # U" + using "1" by presburger + qed + qed + qed + qed + qed + show "\M N A B U. ?P (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) U \ ?P (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)" + proof - + fix M N A B U + assume ind: "?P (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) U" + show "?P (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)" + proof (intro impI, elim conjE) + assume seq: "seq [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)" + assume Std: "Std ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)" + have MN: "\.Arr M \ \.Arr N" + using seq + by (simp add: seq_char) + have AB: "\.Trg M = A \ \.Trg N = B" + proof - + have 1: "\.Ide A \ \.Ide B" + using Std + by (metis Std.simps(2) Std.simps(3) \.elementary_reduction.simps(5) + list.exhaust_sel \.sseq_Beta) + moreover have "Trgs [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] = Srcs [\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B]" + using 1 seq seq_char + by (simp add: \.Ide_implies_Arr Srcs_simp\<^sub>\\<^sub>P) + ultimately show ?thesis + by (metis \.Ide_iff_Src_self \.Ide_implies_Arr \.Src.simps(5) Srcs_simp\<^sub>\\<^sub>P + \.Trg.simps(2-3) Trgs_simp\<^sub>\\<^sub>P \.lambda.inject(2) \.lambda.sel(3-4) + last.simps list.sel(1) seq_char seq the_elem_eq) + qed + have 1: "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) = stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) U" + by auto + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)) \ + (\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \ + stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)" + proof (cases "U = []") + assume U: "U = []" + have 1: "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) = + standard_development (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N)" + using U by simp + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U))" + using 1 Std_standard_development by presburger + show "\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \ + stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U" + proof (intro impI) + assume 2: "\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U)" + have "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) = + (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) # standard_development (\.subst N M)" + using 1 MN by simp + also have "... \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N]" + using MN AB cong_standard_development + by (metis 1 calculation \.Arr.simps(5) \.Ide.simps(5)) + also have "[\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U" + using AB MN U Beta_decomp(2) [of M N] by simp + finally show "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \<^sup>*\\<^sup>* + (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U" + by blast + qed + qed + next + assume U: "U \ []" + have 1: "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) = stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) U" + using U by simp + have 2: "seq [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] U" + using MN AB U Std \.sseq_imp_seq + apply (intro seqI\<^sub>\\<^sub>P) + apply auto + by fastforce + have 3: "Std U" + using Std by fastforce + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U))" + using 2 3 ind by simp + show "\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \ + stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U" + proof + have "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ U" + by (metis "1" "2" "3" \.Ide.simps(5) U Ide.simps(3) append.left_neutral + append_Cons \.ide_char ind list.exhaust) + also have "[\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ U \<^sup>*\\<^sup>* ([\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ [\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B]) @ U" + using MN AB Beta_decomp + by (meson "2" cong_append cong_reflexive seqE) + also have "([\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ [\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B]) @ U = (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U" + by simp + finally show "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) ((\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U) \<^sup>*\\<^sup>* + (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # (\<^bold>\\<^bold>[A\<^bold>] \<^bold>\ B) # U" + by argo + qed + qed + qed + qed + qed + show "\M N u U. (\.Arr M \ \.Arr N \ ?P (\.subst N M) (u # U)) + \ ?P (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U)" + proof - + fix M N u U + assume ind: "\.Arr M \ \.Arr N \ ?P (\.subst N M) (u # U)" + show "?P (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U)" + proof (intro impI, elim conjE) + assume seq: "seq [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] (u # U)" + assume Std: "Std (u # U)" + have MN: "\.Arr M \ \.Arr N" + using seq seq_char by simp + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U)) \ + (\ Ide (\.Beta M N # u # U) \ + cong (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U)) ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U))" + proof (cases "\.Ide (\.subst N M)") + assume 1: "\.Ide (\.subst N M)" + have 2: "\ Ide (u # U)" + using Std Std_implies_set_subset_elementary_reduction \.elementary_reduction_not_ide + by force + have 3: "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) = (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) # stdz_insert u U" + using MN 1 seq seq_char Std stdz_insert_Ide_Std [of "\.subst N M" "u # U"] + \.Ide_implies_Arr + by (cases "U = []") auto + show ?thesis + proof (cases "U = []") + assume U: "U = []" + have 3: "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) = + (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) # standard_development u" + using 2 3 U by force + have 4: "\.seq (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) (hd (standard_development u))" + proof + show "\.Arr (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N)" + using MN by simp + show "\.Arr (hd (standard_development u))" + by (metis 2 Arr_imp_arr_hd Ide.simps(2) Ide_iff_standard_development_empty + Std Std_consE Std_imp_Arr Std_standard_development U \.arr_char + \.ide_char) + show "\.Trg (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) = \.Src (hd (standard_development u))" + by (metis 1 2 Ide.simps(2) MN Src_hd_standard_development Std Std_consE + Trg_last_Src_hd_eqI U \.Ide_iff_Src_self \.Ide_implies_Arr \.Src_Subst + \.Trg.simps(4) \.Trg_Src \.Trg_Subst \.ide_char last_ConsL list.sel(1) seq) + qed + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) (hd (standard_development u))" + using MN 2 4 U \.Ide_Src + apply (intro \.sseq_BetaI) + apply auto + by (metis Ide.simps(1) Resid.simps(2) Std Std_consE + Std_standard_development cong_standard_development hd_Cons_tl ide_char + \.sseq_imp_elementary_reduction1 Std.simps(2)) + thus ?thesis + by (metis 3 Std.simps(2-3) Std_standard_development hd_Cons_tl + \.sseq_imp_elementary_reduction1) + qed + show "\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U) + \ stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + proof + have "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) = + [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ standard_development u" + using 3 by simp + also have 5: "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ standard_development u \<^sup>*\\<^sup>* + [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [u]" + proof (intro cong_append) + show "seq [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] (standard_development u)" + by (metis 2 3 Ide.simps(2) Ide_iff_standard_development_empty + Std Std_consE Std_imp_Arr U \Std (stdz_insert (\.Beta M N) (u # U))\ + arr_append_imp_seq arr_char calculation \.ide_char neq_Nil_conv) + thus "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N]" + using cong_reflexive by blast + show "standard_development u \<^sup>*\\<^sup>* [u]" + by (metis 2 Arr.simps(2) Ide.simps(2) Std Std_imp_Arr U + cong_standard_development \.arr_char \.ide_char not_Cons_self2) + qed + also have "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [u] \<^sup>*\\<^sup>* + ([\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [\.subst N M]) @ [u]" + proof (intro cong_append) + show "seq [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] [u]" + by (metis 5 Con_implies_Arr(1) Ide.simps(1) arr_append_imp_seq + arr_char ide_char not_Cons_self2) + show "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [\.subst N M]" + by (metis (full_types) 1 MN Ide_iff_standard_development_empty + cong_standard_development cong_transitive \.Arr.simps(5) \.Arr_Subst + \.Ide.simps(5) Beta_decomp(1) standard_development.simps(5)) + show "[u] \<^sup>*\\<^sup>* [u]" + using Resid_Arr_self Std Std_imp_Arr U ide_char by blast + qed + also have "([\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [\.subst N M]) @ [u] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ [u]" + by (metis Beta_decomp(1) MN U Resid_Arr_self cong_append + ide_char seq_char seq) + also have "[\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ [u] = (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + using U by simp + finally show "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + by blast + qed + qed + next + assume U: "U \ []" + have 4: "seq [u] U" + by (simp add: Std U arrI\<^sub>P arr_append_imp_seq) + have 5: "Std U" + using Std by auto + have 6: "Std (stdz_insert u U) \ + set (stdz_insert u U) \ {a. \.elementary_reduction a} \ + (\ Ide (u # U) \ + cong (stdz_insert u U) (u # U))" + proof - + have "seq [\.subst N M] (u # U) \ Std (u # U)" + using MN Std Std_imp_Arr \.Arr_Subst + apply (intro conjI seqI\<^sub>\\<^sub>P) + apply simp_all + by (metis Trg_last_Src_hd_eqI \.Trg.simps(4) last_ConsL list.sel(1) seq) + thus ?thesis + using MN 1 2 3 4 5 ind Std_implies_set_subset_elementary_reduction + stdz_insert_Ide_Std + apply simp + by (meson cong_cons_ideI(1) cong_transitive lambda_calculus.ide_char) + qed + have 7: "\.seq (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) (hd (stdz_insert u U))" + using MN 1 2 6 Arr_imp_arr_hd Con_implies_Arr(2) ide_char \.arr_char + Ide_iff_standard_development_empty Src_hd_eqI Trg_last_Src_hd_eqI + Trg_last_standard_development \.Ide_implies_Arr seq + apply (intro \.seqI\<^sub>\) + apply simp + apply (metis Ide.simps(1)) + by (metis \.Arr.simps(5) \.Ide.simps(5) last.simps standard_development.simps(5)) + have 8: "seq [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] (stdz_insert u U)" + by (metis 2 6 7 seqI\<^sub>\\<^sub>P Arr.simps(2) Con_implies_Arr(2) + Ide.simps(1) ide_char last.simps \.seqE \.seq_char) + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) (hd (stdz_insert u U))" + by (metis MN 2 6 7 \.Ide_Src Std.elims(2) Ide.simps(1) + Resid.simps(2) ide_char list.sel(1) \.sseq_BetaI + \.sseq_imp_elementary_reduction1) + thus ?thesis + by (metis 2 3 6 Std.simps(3) Resid.simps(1) con_char prfx_implies_con + list.exhaust_sel) + qed + show "\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U) + \ stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + proof + have "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) = [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ stdz_insert u U" + using 3 by simp + also have "... \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ u # U" + using MN 2 3 6 8 cong_append + by (meson cong_reflexive seqE) + also have "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ u # U \<^sup>*\\<^sup>* + ([\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [\.subst N M]) @ u # U" + using MN 1 2 6 8 Beta_decomp(1) Std Src_hd_eqI Trg_last_Src_hd_eqI + \.Arr_Subst \.ide_char ide_char + apply (intro cong_append cong_append_ideI seqI\<^sub>\\<^sub>P) + apply auto[2] + apply metis + apply auto[4] + by (metis cong_transitive) + also have "([\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [\.subst N M]) @ u # U \<^sup>*\\<^sup>* + [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ u # U" + by (meson MN 2 6 Beta_decomp(1) cong_append prfx_transitive seq) + also have "[\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ u # U = (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + by simp + qed + qed + qed + next + assume 1: "\ \.Ide (\.subst N M)" + have 2: "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) = + (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) # stdz_insert (\.subst N M) (u # U)" + using 1 MN by simp + have 3: "seq [\.subst N M] (u # U)" + using \.Arr_Subst MN seq_char seq by force + have 4: "Std (stdz_insert (\.subst N M) (u # U)) \ + set (stdz_insert (\.subst N M) (u # U)) \ {a. \.elementary_reduction a} \ + stdz_insert (\.Subst 0 N M) (u # U) \<^sup>*\\<^sup>* \.subst N M # u # U" + using 1 3 Std ind MN Ide.simps(3) \.ide_char + Std_implies_set_subset_elementary_reduction + by presburger + have 5: "\.seq (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) (hd (stdz_insert (\.subst N M) (u # U)))" + using MN 4 + apply (intro \.seqI\<^sub>\) + apply simp + apply (metis Arr_imp_arr_hd Con_implies_Arr(1) Ide.simps(1) ide_char \.arr_char) + using Src_hd_eqI + by force + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N) (hd (stdz_insert (\.subst N M) (u # U)))" + using 5 + by (metis 4 MN \.Ide_Src Std.elims(2) Ide.simps(1) Resid.simps(2) + ide_char list.sel(1) \.sseq_BetaI \.sseq_imp_elementary_reduction1) + thus ?thesis + by (metis 2 4 Std.simps(3) Arr.simps(1) Con_implies_Arr(2) + Ide.simps(1) ide_char list.exhaust_sel) + qed + show "\ Ide ((\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U) + \ stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + proof + have "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) = + [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ stdz_insert (\.subst N M) (u # U)" + using 2 by simp + also have "... \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ \.subst N M # u # U" + proof (intro cong_append) + show "seq [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] (stdz_insert (\.subst N M) (u # U))" + by (metis 4 5 Arr.simps(2) Con_implies_Arr(1) Ide.simps(1) ide_char + \.arr_char \.seq_char last_ConsL seqI\<^sub>\\<^sub>P) + show "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N]" + by (meson MN cong_transitive \.Arr_Src Beta_decomp(1)) + show "stdz_insert (\.subst N M) (u # U) \<^sup>*\\<^sup>* \.subst N M # u # U" + using 4 by fastforce + qed + also have "[\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ \.subst N M # u # U = + ([\<^bold>\\<^bold>[\.Src M\<^bold>] \<^bold>\ \.Src N] @ [\.subst N M]) @ u # U" + by simp + also have "... \<^sup>*\\<^sup>* [\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ u # U" + by (meson Beta_decomp(1) MN cong_append cong_reflexive seqE seq) + also have "[\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N] @ u # U = (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (\<^bold>\\<^bold>[M\<^bold>] \<^bold>\ N) # u # U" + by blast + qed + qed + qed + qed + qed + text \ + Because of the way the function package processes the pattern matching in the + definition of \stdz_insert\, it produces eight separate subgoals for the remainder + of the proof, even though these subgoals are all simple consequences of a single, + more general fact. We first prove this fact, then use it to discharge the eight + subgoals. + \ + have *: "\M N u U. + \\ (\.is_Lam M \ \.is_Beta u); + \.Ide (M \<^bold>\ N) \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (M \<^bold>\ N); + \.Ide (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N)))\ + \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (M \<^bold>\ N); + \ \.Ide (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N)))\ + \ ?P (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N))) (u # U); + \\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \.Ide (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N)))\ + \ ?P (\.head_strategy (M \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \ \.Ide (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N)))\ + \ ?P (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N))) (tl (u # U)); + \\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P M (filter notIde (map \.un_App1 (u # U))); + \\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P N (filter notIde (map \.un_App2 (u # U)))\ + \ ?P (M \<^bold>\ N) (u # U)" + proof - + fix M N u U + assume ind1: "\.Ide (M \<^bold>\ N) \ ?P (hd (u # U)) (tl (u # U))" + assume ind2: "\\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (M \<^bold>\ N); + \.Ide (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N)))\ + \ ?P (hd (u # U)) (tl (u # U))" + assume ind3: "\\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (M \<^bold>\ N); + \ \.Ide (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N)))\ + \ ?P (\.resid (M \<^bold>\ N) (\.head_redex (M \<^bold>\ N))) (u # U)" + assume ind4: "\\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \.Ide (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N)))\ + \ ?P (\.head_strategy (M \<^bold>\ N)) (tl (u # U))" + assume ind5: "\\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \ \.Ide (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N)))\ + \ ?P (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N))) (tl (u # U))" + assume ind7: "\\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P M (filter notIde (map \.un_App1 (u # U)))" + assume ind8: "\\ \.Ide (M \<^bold>\ N); + \.seq (M \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P N (filter notIde (map \.un_App2 (u # U)))" + assume *: "\ (\.is_Lam M \ \.is_Beta u)" + show "?P (M \<^bold>\ N) (u # U)" + proof (intro impI, elim conjE) + assume seq: "seq [M \<^bold>\ N] (u # U)" + assume Std: "Std (u # U)" + have MN: "\.Arr M \ \.Arr N" + using seq_char seq by force + have u: "\.Arr u" + using Std + by (meson Std_imp_Arr Arr.simps(2) Con_Arr_self Con_implies_Arr(1) + Con_initial_left \.arr_char list.simps(3)) + have "U \ [] \ Arr U" + using Std Std_imp_Arr Arr.simps(3) + by (metis Arr.elims(3) list.discI) + have "\.is_App u \ \.is_Beta u" + using * seq MN u seq_char \.arr_char Srcs_simp\<^sub>\\<^sub>P \.targets_char\<^sub>\ + by (cases M; cases u) auto + have **: "\.seq (M \<^bold>\ N) u" + using Srcs_simp\<^sub>\\<^sub>P seq_char seq \.seq_def u by force + show "Std (stdz_insert (M \<^bold>\ N) (u # U)) \ + (\ Ide ((M \<^bold>\ N) # u # U) + \ cong (stdz_insert (M \<^bold>\ N) (u # U)) ((M \<^bold>\ N) # u # U))" + proof (cases "\.Ide (M \<^bold>\ N)") + assume 1: "\.Ide (M \<^bold>\ N)" + have MN: "\.Arr M \ \.Arr N \ \.Ide M \ \.Ide N" + using MN 1 by simp + have 2: "stdz_insert (M \<^bold>\ N) (u # U) = stdz_insert u U" + using MN 1 + by (simp add: Std seq stdz_insert_Ide_Std) + show ?thesis + proof (cases "U = []") + assume U: "U = []" + have 2: "stdz_insert (M \<^bold>\ N) (u # U) = standard_development u" + using 1 2 U by simp + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + using "2" Std_standard_development by presburger + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by (metis "1" "2" Ide.simps(2) U cong_cons_ideI(1) cong_standard_development + ide_backward_stable ide_char \.ide_char prfx_transitive seq u) + qed + next + assume U: "U \ []" + have 2: "stdz_insert (M \<^bold>\ N) (u # U) = stdz_insert u U" + using 1 2 U by simp + have 3: "seq [u] U" + by (simp add: Std U arrI\<^sub>P arr_append_imp_seq) + have 4: "Std (stdz_insert u U) \ + set (stdz_insert u U) \ {a. \.elementary_reduction a} \ + (\ Ide (u # U) \ cong (stdz_insert u U) (u # U))" + using MN 3 Std ind1 Std_implies_set_subset_elementary_reduction + by (metis "1" Std.simps(3) U list.sel(1) list.sel(3) standardize.cases) + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + by (metis "1" "2" "3" Std Std.simps(3) U ind1 list.exhaust_sel list.sel(1,3)) + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + assume 5: "\ Ide ((M \<^bold>\ N) # u # U)" + have "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* u # U" + using "1" "2" "4" "5" seq_char seq by force + also have "u # U \<^sup>*\\<^sup>* [M \<^bold>\ N] @ u # U" + using "1" Ide.simps(2) cong_append_ideI(1) ide_char seq by blast + also have "[M \<^bold>\ N] @ (u # U) = (M \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + qed + next + assume 1: "\ \.Ide (M \<^bold>\ N)" + show ?thesis + proof (cases "\.contains_head_reduction (M \<^bold>\ N)") + assume 2: "\.contains_head_reduction (M \<^bold>\ N)" + show ?thesis + proof (cases "\.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))") + assume 3: "\.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))" + have 4: "\ Ide (u # U)" + by (metis Std Std_implies_set_subset_elementary_reduction in_mono + \.elementary_reduction_not_ide list.set_intros(1) mem_Collect_eq + set_Ide_subset_ide) + have 5: "stdz_insert (M \<^bold>\ N) (u # U) = \.head_redex (M \<^bold>\ N) # stdz_insert u U" + using MN 1 2 3 4 ** by auto + show ?thesis + proof (cases "U = []") + assume U: "U = []" + have u: "\.Arr u \ \ \.Ide u" + using 4 U u by force + have 5: "stdz_insert (M \<^bold>\ N) (u # U) = + \.head_redex (M \<^bold>\ N) # standard_development u" + using 5 U by simp + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\.head_redex (M \<^bold>\ N)) (hd (standard_development u))" + proof - + have "\.seq (\.head_redex (M \<^bold>\ N)) (hd (standard_development u))" + proof + show "\.Arr (\.head_redex (M \<^bold>\ N))" + using MN \.Arr.simps(4) \.Arr_head_redex by presburger + show "\.Arr (hd (standard_development u))" + using Arr_imp_arr_hd Ide_iff_standard_development_empty + Std_standard_development u + by force + show "\.Trg (\.head_redex (M \<^bold>\ N)) = \.Src (hd (standard_development u))" + proof - + have "\.Trg (\.head_redex (M \<^bold>\ N)) = + \.Trg ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))" + by (metis 3 MN \.Con_Arr_head_redex \.Src_resid + \.Arr.simps(4) \.Ide_iff_Src_self \.Ide_iff_Trg_self + \.Ide_implies_Arr) + also have "... = \.Src u" + using MN + by (metis Trg_last_Src_hd_eqI Trg_last_eqI head_redex_decomp + \.Arr.simps(4) last_ConsL last_appendR list.sel(1) + not_Cons_self2 seq) + also have "... = \.Src (hd (standard_development u))" + using ** 2 3 u MN Src_hd_standard_development [of u] by metis + finally show ?thesis by blast + qed + qed + thus ?thesis + by (metis 2 u MN \.Arr.simps(4) Ide_iff_standard_development_empty + development.simps(2) development_standard_development + \.head_redex_is_head_reduction list.exhaust_sel + \.sseq_head_reductionI) + qed + thus ?thesis + by (metis 5 Ide_iff_standard_development_empty Std.simps(3) + Std_standard_development list.exhaust u) + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + [\.head_redex (M \<^bold>\ N)] @ standard_development u" + using 5 by simp + also have "... \<^sup>*\\<^sup>* [\.head_redex (M \<^bold>\ N)] @ [u]" + using u cong_standard_development [of u] cong_append + by (metis 2 5 Ide_iff_standard_development_empty Std_imp_Arr + \Std (stdz_insert (M \<^bold>\ N) (u # U))\ + arr_append_imp_seq arr_char calculation cong_standard_development + cong_transitive \.Arr_head_redex \.contains_head_reduction_iff + list.distinct(1)) + also have "[\.head_redex (M \<^bold>\ N)] @ [u] \<^sup>*\\<^sup>* + ([\.head_redex (M \<^bold>\ N)] @ [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]) @ [u]" + proof - + have "[\.head_redex (M \<^bold>\ N)] \<^sup>*\\<^sup>* + [\.head_redex (M \<^bold>\ N)] @ [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]" + by (metis (no_types, lifting) 1 3 MN Arr_iff_Con_self Ide.simps(2) + Resid.simps(2) arr_append_imp_seq arr_char cong_append_ideI(4) + cong_transitive head_redex_decomp ide_backward_stable ide_char + \.Arr.simps(4) \.ide_char not_Cons_self2) + thus ?thesis + using MN U u seq + by (meson cong_append head_redex_decomp \.Arr.simps(4) prfx_transitive) + qed + also have "([\.head_redex (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]) @ [u] \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ [u]" + by (metis \.Arr.simps(4) MN U Resid_Arr_self cong_append ide_char + seq_char head_redex_decomp seq) + also have "[M \<^bold>\ N] @ [u] = (M \<^bold>\ N) # u # U" + using U by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + next + assume U: "U \ []" + have 6: "Std (stdz_insert u U) \ + set (stdz_insert u U) \ {a. \.elementary_reduction a} \ + cong (stdz_insert u U) (u # U)" + proof - + have "seq [u] U" + by (simp add: Std U arrI\<^sub>P arr_append_imp_seq) + moreover have "Std U" + using Std Std.elims(2) U by blast + ultimately show ?thesis + using ind2 ** 1 2 3 4 Std_implies_set_subset_elementary_reduction + by force + qed + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\.head_redex (M \<^bold>\ N)) (hd (stdz_insert u U))" + proof - + have "\.seq (\.head_redex (M \<^bold>\ N)) (hd (stdz_insert u U))" + proof + show "\.Arr (\.head_redex (M \<^bold>\ N))" + using MN \.Arr_head_redex by force + show "\.Arr (hd (stdz_insert u U))" + using 6 + by (metis Arr_imp_arr_hd Con_implies_Arr(2) Ide.simps(1) ide_char + \.arr_char) + show "\.Trg (\.head_redex (M \<^bold>\ N)) = \.Src (hd (stdz_insert u U))" + proof - + have "\.Trg (\.head_redex (M \<^bold>\ N)) = + \.Trg ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))" + by (metis 3 \.Arr_not_Nil \.Ide_iff_Src_self + \.Ide_iff_Trg_self \.Ide_implies_Arr \.Src_resid) + also have "... = \.Trg (M \<^bold>\ N)" + by (metis 1 MN Trg_last_eqI Trg_last_standard_development + cong_standard_development head_redex_decomp \.Arr.simps(4) + last_snoc) + also have "... = \.Src (hd (stdz_insert u U))" + by (metis ** 6 Src_hd_eqI \.seqE\<^sub>\ list.sel(1)) + finally show ?thesis by blast + qed + qed + thus ?thesis + by (metis 2 6 MN \.Arr.simps(4) Std.elims(1) Ide.simps(1) + Resid.simps(2) ide_char \.head_redex_is_head_reduction + list.sel(1) \.sseq_head_reductionI \.sseq_imp_elementary_reduction1) + qed + thus ?thesis + by (metis 5 6 Std.simps(3) Arr.simps(1) Con_implies_Arr(1) + con_char prfx_implies_con list.exhaust_sel) + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + [\.head_redex (M \<^bold>\ N)] @ stdz_insert u U" + using 5 by simp + also have 7: "[\.head_redex (M \<^bold>\ N)] @ stdz_insert u U \<^sup>*\\<^sup>* + [\.head_redex (M \<^bold>\ N)] @ u # U" + using 6 cong_append [of "[\.head_redex (M \<^bold>\ N)]" "stdz_insert u U" + "[\.head_redex (M \<^bold>\ N)]" "u # U"] + by (metis 2 5 Arr.simps(1) Resid.simps(2) Std_imp_Arr + \Std (stdz_insert (M \<^bold>\ N) (u # U))\ + arr_append_imp_seq arr_char calculation cong_standard_development + cong_transitive ide_implies_arr \.Arr_head_redex + \.contains_head_reduction_iff list.distinct(1)) + also have "[\.head_redex (M \<^bold>\ N)] @ u # U \<^sup>*\\<^sup>* + ([\.head_redex (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]) @ u # U" + proof - + have "[\.head_redex (M \<^bold>\ N)] \<^sup>*\\<^sup>* + [\.head_redex (M \<^bold>\ N)] @ [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]" + by (metis 2 3 head_redex_decomp \.Arr_head_redex + \.Con_Arr_head_redex \.Ide_iff_Src_self \.Ide_implies_Arr + \.Src_resid \.contains_head_reduction_iff \.resid_Arr_self + prfx_decomp prfx_transitive) + moreover have "seq [\.head_redex (M \<^bold>\ N)] (u # U)" + by (metis 7 arr_append_imp_seq cong_implies_coterminal coterminalE + list.distinct(1)) + ultimately show ?thesis + using 3 ide_char cong_symmetric cong_append + by (meson 6 prfx_transitive) + qed + also have "([\.head_redex (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]) @ u # U \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ u # U" + by (meson 6 MN \.Arr.simps(4) cong_append prfx_transitive + head_redex_decomp seq) + also have "[M \<^bold>\ N] @ (u # U) = (M \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + qed + next + assume 3: "\ \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))" + have 4: "stdz_insert (M \<^bold>\ N) (u # U) = + \.head_redex (M \<^bold>\ N) # + stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U)" + using MN 1 2 3 ** by auto + have 5: "Std (stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U)) \ + set (stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U)) + \ {a. \.elementary_reduction a} \ + stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U) \<^sup>*\\<^sup>* + (M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N) # u # U" + proof - + have "seq [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)] (u # U)" + by (metis (full_types) MN arr_append_imp_seq cong_implies_coterminal + coterminalE head_redex_decomp \.Arr.simps(4) not_Cons_self2 + seq seq_def targets_append) + thus ?thesis + using ind3 1 2 3 ** Std Std_implies_set_subset_elementary_reduction + by auto + qed + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\.head_redex (M \<^bold>\ N)) + (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U)))" + proof - + have "\.seq (\.head_redex (M \<^bold>\ N)) + (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U)))" + using MN 5 \.Arr_head_redex + by (metis (no_types, lifting) Arr_imp_arr_hd Con_implies_Arr(2) + Ide.simps(1) Src_hd_eqI ide_char \.Arr.simps(4) \.Arr_head_redex + \.Con_Arr_head_redex \.Src_resid \.arr_char \.seq_char list.sel(1)) + moreover have "\.elementary_reduction + (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) + (u # U)))" + using 5 + by (metis Arr.simps(1) Con_implies_Arr(2) Ide.simps(1) hd_in_set + ide_char mem_Collect_eq subset_code(1)) + ultimately show ?thesis + using MN 2 \.head_redex_is_head_reduction \.sseq_head_reductionI + by simp + qed + thus ?thesis + by (metis 4 5 Std.simps(3) Arr.simps(1) Con_implies_Arr(2) + Ide.simps(1) ide_char list.exhaust_sel) + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + [\.head_redex (M \<^bold>\ N)] @ + stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U)" + using 4 by simp + also have "... \<^sup>*\\<^sup>* [\.head_redex (M \<^bold>\ N)] @ + ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N) # u # U)" + proof (intro cong_append) + show "seq [\.head_redex (M \<^bold>\ N)] + (stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U))" + by (metis 4 5 Ide.simps(1) Resid.simps(1) Std_imp_Arr + \Std (stdz_insert (M \<^bold>\ N) (u # U))\ arrI\<^sub>P arr_append_imp_seq + calculation ide_char list.discI) + show "[\.head_redex (M \<^bold>\ N)] \<^sup>*\\<^sup>* [\.head_redex (M \<^bold>\ N)]" + using MN \.cong_reflexive ide_char \.Arr_head_redex by force + show "stdz_insert ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) \\ + \.head_redex (M \<^bold>\ N) # u # U" + using 5 by fastforce + qed + also have "([\.head_redex (M \<^bold>\ N)] @ + ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N) # u # U)) = + ([\.head_redex (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]) @ (u # U)" + by simp + also have "([\.head_redex (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)]) @ u # U \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ u # U" + by (meson ** cong_append cong_reflexive seqE head_redex_decomp + seq \.seq_char) + also have "[M \<^bold>\ N] @ (u # U) = (M \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + qed + next + assume 2: "\ \.contains_head_reduction (M \<^bold>\ N)" + show ?thesis + proof (cases "\.contains_head_reduction u") + assume 3: "\.contains_head_reduction u" + have B: "[\.head_strategy (M \<^bold>\ N)] @ [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)] \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ [u]" + proof - + have "[M \<^bold>\ N] @ [u] \<^sup>*\\<^sup>* [\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N]" + proof - + have "\.is_internal_reduction (M \<^bold>\ N)" + using 2 ** \.is_internal_reduction_iff by blast + moreover have "\.is_head_reduction u" + proof - + have "\.elementary_reduction u" + by (metis Std lambda_calculus.sseq_imp_elementary_reduction1 + list.discI list.sel(1) reduction_paths.Std.elims(2)) + thus ?thesis + using \.is_head_reduction_if 3 by force + qed + moreover have "\.head_strategy (\.Src (M \<^bold>\ N)) \\ (M \<^bold>\ N) = u" + using \.resid_head_strategy_Src(1) ** calculation(1-2) by fastforce + moreover have "[M \<^bold>\ N] \<^sup>*\\<^sup>* [\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N]" + using MN \.prfx_implies_con ide_char \.Arr_head_strategy + \.Src_head_strategy \.prfx_Join + by force + ultimately show ?thesis + using u \.Coinitial_iff_Con \.Arr_not_Nil \.resid_Join + prfx_decomp [of "M \<^bold>\ N" "\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N"] + by simp + qed + also have "[\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N] \<^sup>*\\<^sup>* + [\.head_strategy (\.Src (M \<^bold>\ N))] @ + [(M \<^bold>\ N) \\ \.head_strategy (\.Src (M \<^bold>\ N))]" + proof - + have 3: "\.composite_of + (\.head_strategy (\.Src (M \<^bold>\ N))) + ((M \<^bold>\ N) \\ \.head_strategy (\.Src (M \<^bold>\ N))) + (\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N)" + using \.Arr_head_strategy MN \.Src_head_strategy \.join_of_Join + \.join_of_def + by force + hence "composite_of + [\.head_strategy (\.Src (M \<^bold>\ N))] + [(M \<^bold>\ N) \\ \.head_strategy (\.Src (M \<^bold>\ N))] + [\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N]" + using composite_of_single_single + by (metis (no_types, lifting) \.Con_sym Ide.simps(2) Resid.simps(3) + composite_ofI \.composite_ofE \.con_char ide_char \.prfx_implies_con) + hence "[\.head_strategy (\.Src (M \<^bold>\ N))] @ + [(M \<^bold>\ N) \\ \.head_strategy (\.Src (M \<^bold>\ N))] \<^sup>*\\<^sup>* + [\.head_strategy (\.Src (M \<^bold>\ N)) \ M \<^bold>\ N]" + using \.resid_Join + by (meson 3 composite_of_single_single composite_of_unq_upto_cong) + thus ?thesis by blast + qed + also have "[\.head_strategy (\.Src (M \<^bold>\ N))] @ + [(M \<^bold>\ N) \\ \.head_strategy (\.Src (M \<^bold>\ N))] \<^sup>*\\<^sup>* + [\.head_strategy (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]" + by (metis (full_types) \.Arr.simps(4) MN prfx_transitive calculation + \.head_strategy_Src) + finally show ?thesis by blast + qed + show ?thesis + proof (cases "\.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))") + assume 4: "\.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))" + have A: "[\.head_strategy (M \<^bold>\ N)] \<^sup>*\\<^sup>* + [\.head_strategy (M \<^bold>\ N)] @ [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]" + by (meson 4 B Con_implies_Arr(1) Ide.simps(2) arr_append_imp_seq arr_char + con_char cong_append_ideI(2) ide_char \.ide_char not_Cons_self2 + prfx_implies_con) + have 5: "\ Ide (u # U)" + by (meson 3 Ide_consE \.ide_backward_stable \.subs_head_redex + \.subs_implies_prfx \.contains_head_reduction_iff + \.elementary_reduction_head_redex \.elementary_reduction_not_ide) + have 6: "stdz_insert (M \<^bold>\ N) (u # U) = + stdz_insert (\.head_strategy (M \<^bold>\ N)) U" + using 1 2 3 4 5 * ** \\.is_App u \ \.is_Beta u\ + apply (cases u) + apply simp_all + apply blast + by (cases M) auto + show ?thesis + proof (cases "U = []") + assume U: "U = []" + have u: "\ \.Ide u" + using 5 U by simp + have 6: "stdz_insert (M \<^bold>\ N) (u # U) = + standard_development (\.head_strategy (M \<^bold>\ N))" + using 6 U by simp + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + using "6" Std_standard_development by presburger + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* [\.head_strategy (M \<^bold>\ N)]" + using 4 6 cong_standard_development ** 1 2 3 \.Arr.simps(4) + \.Arr_head_strategy MN \.ide_backward_stable \.ide_char + by metis + also have "[\.head_strategy (M \<^bold>\ N)] \<^sup>*\\<^sup>* [M \<^bold>\ N] @ [u]" + by (meson A B prfx_transitive) + also have "[M \<^bold>\ N] @ [u] = (M \<^bold>\ N) # u # U" + using U by auto + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + next + assume U: "U \ []" + have 7: "seq [\.head_strategy (M \<^bold>\ N)] U" + proof + show "Arr [\.head_strategy (M \<^bold>\ N)]" + by (meson A Con_implies_Arr(1) con_char prfx_implies_con) + show "Arr U" + using U \U \ [] \ Arr U\ by presburger + show "\.Trg (last [\.head_strategy (M \<^bold>\ N)]) = \.Src (hd U)" + by (metis A B Std Std_consE Trg_last_eqI U \.seqE\<^sub>\ \.sseq_imp_seq last_snoc) + qed + have 8: "Std (stdz_insert (\.head_strategy (M \<^bold>\ N)) U) \ + set (stdz_insert (\.head_strategy (M \<^bold>\ N)) U) + \ {a. \.elementary_reduction a} \ + stdz_insert (\.head_strategy (M \<^bold>\ N)) U \<^sup>*\\<^sup>* + \.head_strategy (M \<^bold>\ N) # U" + proof - + have "Std U" + by (metis Std Std.simps(3) U list.exhaust_sel) + moreover have "\ Ide (\.head_strategy (M \<^bold>\ N) # tl (u # U))" + using 1 4 \.ide_backward_stable by blast + ultimately show ?thesis + using ind4 ** 1 2 3 4 7 Std_implies_set_subset_elementary_reduction + by force + qed + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + using 6 8 by presburger + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + stdz_insert (\.head_strategy (M \<^bold>\ N)) U" + using 6 by simp + also have "... \<^sup>*\\<^sup>* [\.head_strategy (M \<^bold>\ N)] @ U" + using 8 by simp + also have "[\.head_strategy (M \<^bold>\ N)] @ U \<^sup>*\\<^sup>* ([M \<^bold>\ N] @ [u]) @ U" + by (meson A B U 7 Resid_Arr_self cong_append ide_char + prfx_transitive \U \ [] \ Arr U\) + also have "([M \<^bold>\ N] @ [u]) @ U = (M \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + qed + next + assume 4: "\ \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))" + show ?thesis + proof (cases "U = []") + assume U: "U = []" + have 5: "stdz_insert (M \<^bold>\ N) (u # U) = + \.head_strategy (M \<^bold>\ N) # + standard_development ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))" + using 1 2 3 4 U * ** \\.is_App u \ \.is_Beta u\ + apply (cases u) + apply simp_all + apply blast + apply (cases M) + apply simp_all + by blast+ + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\.head_strategy (M \<^bold>\ N)) + (hd (standard_development + ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))))" + proof - + have "\.seq (\.head_strategy (M \<^bold>\ N)) + (hd (standard_development + ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))))" + using MN ** 4 \.Arr_head_strategy Arr_imp_arr_hd + Ide_iff_standard_development_empty Src_hd_standard_development + Std_imp_Arr Std_standard_development \.Arr_resid + \.Src_head_strategy \.Src_resid + by force + moreover have "\.elementary_reduction + (hd (standard_development + ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))))" + by (metis 4 Ide_iff_standard_development_empty MN Std_consE + Std_standard_development hd_Cons_tl \.Arr.simps(4) + \.Arr_resid_ind \.Con_head_strategy + \.sseq_imp_elementary_reduction1 Std.simps(2)) + ultimately show ?thesis + using \.sseq_head_reductionI Std_standard_development + by (metis ** 2 3 Std U \.internal_reduction_preserves_no_head_redex + \.is_internal_reduction_iff \.Src_head_strategy + \.elementary_reduction_not_ide \.head_strategy_Src + \.head_strategy_is_elementary \.ide_char \.is_head_reduction_char + \.is_head_reduction_if \.seqE\<^sub>\ Std.simps(2)) + qed + thus ?thesis + by (metis 4 5 MN Ide_iff_standard_development_empty + Std_standard_development \.Arr.simps(4) \.Arr_resid_ind + \.Con_head_strategy list.exhaust_sel Std.simps(3)) + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + [\.head_strategy (M \<^bold>\ N)] @ + standard_development ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))" + using 5 by simp + also have "... \<^sup>*\\<^sup>* [\.head_strategy (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]" + proof (intro cong_append) + show 6: "seq [\.head_strategy (M \<^bold>\ N)] + (standard_development + ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)))" + using 4 Ide_iff_standard_development_empty MN + \Std (stdz_insert (M \<^bold>\ N) (u # U))\ + arr_append_imp_seq arr_char calculation \.Arr_head_strategy + \.Arr_resid lambda_calculus.Src_head_strategy + by force + show "[\.head_strategy (M \<^bold>\ N)] \<^sup>*\\<^sup>* [\.head_strategy (M \<^bold>\ N)]" + by (meson MN 6 cong_reflexive seqE) + show "standard_development ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) \<^sup>*\\<^sup>* + [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]" + using 4 MN cong_standard_development \.Arr.simps(4) + \.Arr_resid_ind \.Con_head_strategy + by presburger + qed + also have "[\.head_strategy (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)] \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ [u]" + using B by blast + also have "[M \<^bold>\ N] @ [u] = (M \<^bold>\ N) # u # U" + using U by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + next + assume U: "U \ []" + have 5: "stdz_insert (M \<^bold>\ N) (u # U) = + \.head_strategy (M \<^bold>\ N) # + stdz_insert (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N))) U" + using 1 2 3 4 U * ** \\.is_App u \ \.is_Beta u\ + apply (cases u) + apply simp_all + apply blast + apply (cases M) + apply simp_all + by blast+ + have 6: "Std (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U) \ + set (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U) + \ {a. \.elementary_reduction a} \ + stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U \<^sup>*\\<^sup>* + (M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N) # U" + proof - + have "seq [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)] U" + proof + show "Arr [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]" + by (simp add: MN lambda_calculus.Arr_resid_ind \.Con_head_strategy) + show "Arr U" + using U \U \ [] \ Arr U\ by blast + show "\.Trg (last [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]) = \.Src (hd U)" + by (metis (mono_tags, lifting) B U Std Std_consE Trg_last_eqI + \.seq_char \.sseq_imp_seq last_ConsL last_snoc) + qed + thus ?thesis + using ind5 Std_implies_set_subset_elementary_reduction + by (metis ** 1 2 3 4 Std Std.simps(3) Arr_iff_Con_self Ide.simps(3) + Resid.simps(1) seq_char \.ide_char list.exhaust_sel list.sel(1,3)) + qed + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "\.sseq (\.head_strategy (M \<^bold>\ N)) + (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U))" + proof - + have "\.seq (\.head_strategy (M \<^bold>\ N)) + (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U))" + proof + show "\.Arr (\.head_strategy (M \<^bold>\ N))" + using MN \.Arr_head_strategy by force + show "\.Arr (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U))" + using 6 + by (metis Ide.simps(1) Resid.simps(2) Std_consE hd_Cons_tl ide_char) + show "\.Trg (\.head_strategy (M \<^bold>\ N)) = + \.Src (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U))" + using 6 + by (metis MN Src_hd_eqI \.Arr.simps(4) \.Con_head_strategy + \.Src_resid list.sel(1)) + qed + moreover have "\.is_head_reduction (\.head_strategy (M \<^bold>\ N))" + using ** 1 2 3 \.Src_head_strategy \.head_strategy_is_elementary + \.head_strategy_Src \.is_head_reduction_char \.seq_char + by (metis \.Src_head_redex \.contains_head_reduction_iff + \.head_redex_is_head_reduction + \.internal_reduction_preserves_no_head_redex + \.is_internal_reduction_iff) + moreover have "\.elementary_reduction + (hd (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U))" + by (metis 6 Ide.simps(1) Resid.simps(2) ide_char hd_in_set + in_mono mem_Collect_eq) + ultimately show ?thesis + using \.sseq_head_reductionI by blast + qed + thus ?thesis + by (metis 5 6 Std.simps(3) Arr.simps(1) Con_implies_Arr(1) + con_char prfx_implies_con list.exhaust_sel) + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + [\.head_strategy (M \<^bold>\ N)] @ + stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U" + using 5 by simp + also have 10: "... \<^sup>*\\<^sup>* [\.head_strategy (M \<^bold>\ N)] @ + ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N) # U)" + proof (intro cong_append) + show 10: "seq [\.head_strategy (M \<^bold>\ N)] + (stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U)" + by (metis 5 6 Ide.simps(1) Resid.simps(1) Std_imp_Arr + \Std (stdz_insert (M \<^bold>\ N) (u # U))\ arr_append_imp_seq + arr_char calculation ide_char list.distinct(1)) + show "[\.head_strategy (M \<^bold>\ N)] \<^sup>*\\<^sup>* [\.head_strategy (M \<^bold>\ N)]" + using MN 10 cong_reflexive by blast + show "stdz_insert ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) U \<^sup>*\\<^sup>* + (M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N) # U" + using 6 by auto + qed + also have 11: "[\.head_strategy (M \<^bold>\ N)] @ + ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N) # U) = + ([\.head_strategy (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]) @ U" + by simp + also have "... \<^sup>*\\<^sup>* (([M \<^bold>\ N] @ [u]) @ U)" + proof - + have "seq ([\.head_strategy (M \<^bold>\ N)] @ + [(M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)]) U" + by (metis U 10 11 append_is_Nil_conv arr_append_imp_seq + cong_implies_coterminal coterminalE not_Cons_self2) + thus ?thesis + using B cong_append cong_reflexive by blast + qed + also have "([M \<^bold>\ N] @ [u]) @ U = (M \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + qed + qed + next + assume 3: "\ \.contains_head_reduction u" + have u: "\.Arr u \ \.is_App u \ \ \.contains_head_reduction u" + using "3" \\.is_App u \ \.is_Beta u\ \.is_Beta_def u by force + have 5: "\ \.Ide u" + by (metis Std Std.simps(2) Std.simps(3) \.elementary_reduction_not_ide + \.ide_char neq_Nil_conv \.sseq_imp_elementary_reduction1) + show ?thesis + proof - + have 4: "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. \.App X (\.Src N)) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))" + using MN 1 2 3 5 * ** \\.is_App u \ \.is_Beta u\ + apply (cases "U = []"; cases M; cases u) + apply simp_all + by blast+ + have ***: "set U \ Collect \.is_App" + using u 5 Std seq_App_Std_implies by blast + have X: "Std (filter notIde (map \.un_App1 (u # U)))" + by (metis *** Std Std_filter_map_un_App1 insert_subset list.simps(15) + mem_Collect_eq u) + have Y: "Std (filter notIde (map \.un_App2 (u # U)))" + by (metis *** u Std Std_filter_map_un_App2 insert_subset list.simps(15) + mem_Collect_eq) + have A: "\ \.un_App1 ` set (u # U) \ Collect \.Ide \ + Std (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) \ + set (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) + \ {a. \.elementary_reduction a} \ + stdz_insert M (filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + M # filter notIde (map \.un_App1 (u # U))" + proof - + assume *: "\ \.un_App1 ` set (u # U) \ Collect \.Ide" + have "seq [M] (filter notIde (map \.un_App1 (u # U)))" + proof + show "Arr [M]" + using MN by simp + show "Arr (filter notIde (map \.un_App1 (u # U)))" + by (metis (mono_tags, lifting) "*" Std_imp_Arr X empty_filter_conv + list.set_map mem_Collect_eq subset_code(1)) + show "\.Trg (last [M]) = \.Src (hd (filter notIde (map \.un_App1 (u # U))))" + proof - + have "\.Trg (last [M]) = \.Src (hd (map \.un_App1 (u # U)))" + using ** u by fastforce + also have "... = \.Src (hd (filter notIde (map \.un_App1 (u # U))))" + proof - + have "Arr (map \.un_App1 (u # U))" + using u *** + by (metis Arr_map_un_App1 Std Std_imp_Arr insert_subset + list.simps(15) mem_Collect_eq neq_Nil_conv) + moreover have "\ Ide (map \.un_App1 (u # U))" + by (metis "*" Collect_cong \.ide_char list.set_map set_Ide_subset_ide) + ultimately show ?thesis + using Src_hd_eqI cong_filter_notIde by blast + qed + finally show ?thesis by blast + qed + qed + moreover have "\ Ide (M # filter notIde (map \.un_App1 (u # U)))" + using * + by (metis (no_types, lifting) *** Arr_map_un_App1 Std Std_imp_Arr + Arr.simps(1) Ide.elims(2) Resid_Arr_Ide_ind ide_char + seq_char calculation(1) cong_filter_notIde filter_notIde_Ide + insert_subset list.discI list.sel(3) list.simps(15) mem_Collect_eq u) + ultimately show ?thesis + by (metis X 1 2 3 ** ind7 Std_implies_set_subset_elementary_reduction + list.sel(1)) + qed + have B: "\ \.un_App2 ` set (u # U) \ Collect \.Ide \ + Std (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) \ + set (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) + \ {a. \.elementary_reduction a} \ + stdz_insert N (filter notIde (map \.un_App2 (u # U))) \<^sup>*\\<^sup>* + N # filter notIde (map \.un_App2 (u # U))" + proof - + assume **: "\ \.un_App2 ` set (u # U) \ Collect \.Ide" + have "seq [N] (filter notIde (map \.un_App2 (u # U)))" + proof + show "Arr [N]" + using MN by simp + show "Arr (filter (\u. \ \.Ide u) (map \.un_App2 (u # U)))" + by (metis (mono_tags, lifting) ** Std_imp_Arr Y empty_filter_conv + list.set_map mem_Collect_eq subset_code(1)) + show "\.Trg (last [N]) = \.Src (hd (filter notIde (map \.un_App2 (u # U))))" + proof - + have "\.Trg (last [N]) = \.Src (hd (map \.un_App2 (u # U)))" + by (metis u seq Trg_last_Src_hd_eqI \.Src.simps(4) + \.Trg.simps(3) \.is_App_def \.lambda.sel(4) last_ConsL + list.discI list.map_sel(1) list.sel(1)) + also have "... = \.Src (hd (filter notIde (map \.un_App2 (u # U))))" + proof - + have "Arr (map \.un_App2 (u # U))" + using u *** + by (metis Arr_map_un_App2 Std Std_imp_Arr list.distinct(1) + mem_Collect_eq set_ConsD subset_code(1)) + moreover have "\ Ide (map \.un_App2 (u # U))" + by (metis ** Collect_cong \.ide_char list.set_map set_Ide_subset_ide) + ultimately show ?thesis + using Src_hd_eqI cong_filter_notIde by blast + qed + finally show ?thesis by blast + qed + qed + moreover have "\.seq (M \<^bold>\ N) u" + by (metis u Srcs_simp\<^sub>\\<^sub>P Arr.simps(2) Trgs.simps(2) seq_char \.arr_char + list.sel(1) seq \.seqI \.sources_char\<^sub>\) + moreover have "\ Ide (N # filter notIde (map \.un_App2 (u # U)))" + using u * + by (metis (no_types, lifting) *** Arr_map_un_App2 Std Std_imp_Arr + Arr.simps(1) Ide.elims(2) Resid_Arr_Ide_ind ide_char + seq_char calculation(1) cong_filter_notIde filter_notIde_Ide + insert_subset list.discI list.sel(3) list.simps(15) mem_Collect_eq) + ultimately show ?thesis + using * 1 2 3 Y ind8 Std_implies_set_subset_elementary_reduction + by simp + qed + show ?thesis + proof (cases "\.un_App1 ` set (u # U) \ Collect \.Ide"; + cases "\.un_App2 ` set (u # U) \ Collect \.Ide") + show "\\.un_App1 ` set (u # U) \ Collect \.Ide; + \.un_App2 ` set (u # U) \ Collect \.Ide\ + \ ?thesis" + proof - + assume *: "\.un_App1 ` set (u # U) \ Collect \.Ide" + assume **: "\.un_App2 ` set (u # U) \ Collect \.Ide" + have False + using u 5 * ** Ide_iff_standard_development_empty + by (metis \.Ide.simps(4) image_subset_iff \.lambda.collapse(3) + list.set_intros(1) mem_Collect_eq) + thus ?thesis by blast + qed + show "\\.un_App1 ` set (u # U) \ Collect \.Ide; + \ \.un_App2 ` set (u # U) \ Collect \.Ide\ + \ ?thesis" + proof - + assume *: "\.un_App1 ` set (u # U) \ Collect \.Ide" + assume **: "\ \.un_App2 ` set (u # U) \ Collect \.Ide" + have 6: "\.Trg (\.un_App1 (last (u # U))) = \.Trg M" + proof - + have "\.Trg M = \.Src (hd (map \.un_App1 (u # U)))" + by (metis u seq Trg_last_Src_hd_eqI hd_map \.Src.simps(4) \.Trg.simps(3) + \.is_App_def \.lambda.sel(3) last_ConsL list.discI list.sel(1)) + also have "... = \.Trg (last (map \.un_App1 (u # U)))" + proof - + have 6: "Ide (map \.un_App1 (u # U))" + using * *** u Std Std_imp_Arr Ide_char ide_char Arr_map_un_App1 + by (metis (mono_tags, lifting) Collect_cong insert_subset + \.ide_char list.distinct(1) list.set_map list.simps(15) + mem_Collect_eq) + hence "Src (map \.un_App1 (u # U)) = Trg (map \.un_App1 (u # U))" + using Ide_imp_Src_eq_Trg by blast + thus ?thesis + using 6 Ide_implies_Arr by force + qed + also have "... = \.Trg (\.un_App1 (last (u # U)))" + by (simp add: last_map) + finally show ?thesis by simp + qed + have "filter notIde (map \.un_App1 (u # U)) = []" + using * by (simp add: subset_eq) + hence 4: "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. X \<^bold>\ \.Src N) (standard_development M) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))" + using u 4 5 * ** Ide_iff_standard_development_empty MN + by simp + show ?thesis + proof (intro conjI) + have "Std (map (\X. X \<^bold>\ \.Src N) (standard_development M) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))))" + proof (intro Std_append) + show "Std (map (\X. X \<^bold>\ \.Src N) (standard_development M))" + using Std_map_App1 Std_standard_development MN \.Ide_Src + by force + show "Std (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))))" + using "**" B MN 6 Std_map_App2 \.Ide_Trg by presburger + show "map (\X. X \<^bold>\ \.Src N) (standard_development M) = [] \ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) = [] \ + \.sseq (last (map (\X. X \<^bold>\ \.Src N) (standard_development M))) + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde + (map \.un_App2 (u # U))))))" + proof (cases "\.Ide M") + show "\.Ide M \ ?thesis" + using Ide_iff_standard_development_empty MN by blast + assume M: "\ \.Ide M" + have "\.sseq (last (map (\X. X \<^bold>\ \.Src N) (standard_development M))) + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde + (map \.un_App2 (u # U))))))" + proof - + have "last (map (\X. X \<^bold>\ \.Src N) (standard_development M)) = + \.App (last (standard_development M)) (\.Src N)" + using M + by (simp add: Ide_iff_standard_development_empty MN last_map) + moreover have "hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde + (map \.un_App2 (u # U))))) = + \.App (\.Trg (\.un_App1 (last (u # U)))) + (hd (stdz_insert N (filter notIde + (map \.un_App2 (u # U)))))" + by (metis ** B Ide.simps(1) Resid.simps(2) hd_map ide_char) + moreover + have "\.sseq (\.App (last (standard_development M)) (\.Src N)) + ..." + proof - + have "\.elementary_reduction (last (standard_development M))" + using M MN Std_standard_development + Ide_iff_standard_development_empty last_in_set + mem_Collect_eq set_standard_development subsetD + by metis + moreover have "\.elementary_reduction + (hd (stdz_insert N + (filter notIde (map \.un_App2 (u # U)))))" + using ** B + by (metis Arr.simps(1) Con_implies_Arr(2) Ide.simps(1) + ide_char in_mono list.set_sel(1) mem_Collect_eq) + moreover have "\.Trg (last (standard_development M)) = + \.Trg (\.un_App1 (last (u # U)))" + using M MN 6 Trg_last_standard_development by presburger + moreover have "\.Src N = + \.Src (hd (stdz_insert N + (filter notIde (map \.un_App2 (u # U)))))" + by (metis "**" B Src_hd_eqI list.sel(1)) + ultimately show ?thesis + by simp + qed + ultimately show ?thesis by simp + qed + thus ?thesis by blast + qed + qed + thus "Std (stdz_insert (M \<^bold>\ N) (u # U))" + using 4 by simp + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof (cases "\.Ide M") + assume M: "\.Ide M" + have "stdz_insert (M \<^bold>\ N) (u # U) = + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))" + using 4 M MN Ide_iff_standard_development_empty by simp + also have "... \<^sup>*\\<^sup>* (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # filter notIde (map \.un_App2 (u # U))))" + proof - + have "\.Ide (\.Trg (\.un_App1 (last (u # U))))" + using M 6 \.Ide_Trg \.Ide_implies_Arr by fastforce + thus ?thesis + using ** *** B u cong_map_App1 by blast + qed + also have "map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # filter notIde (map \.un_App2 (u # U))) = + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (filter notIde (N # map \.un_App2 (u # U)))" + using 1 M by force + also have "map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (filter notIde (N # map \.un_App2 (u # U))) \<^sup>*\\<^sup>* + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # map \.un_App2 (u # U))" + proof - + have "Arr (N # map \.un_App2 (u # U))" + proof + show "\.arr N" + using MN by blast + show "Arr (map \.un_App2 (u # U))" + using *** u Std Arr_map_un_App2 + by (metis Std_imp_Arr insert_subset list.distinct(1) + list.simps(15) mem_Collect_eq) + show "\.trg N = Src (map \.un_App2 (u # U))" + using u \\.seq (M \<^bold>\ N) u\ \.seq_char \.is_App_def by auto + qed + moreover have "\ Ide (N # map \.un_App2 (u # U))" + using 1 M by force + moreover have "\.Ide (\.Trg (\.un_App1 (last (u # U))))" + using M 6 \.Ide_Trg \.Ide_implies_Arr by presburger + ultimately show ?thesis + using cong_filter_notIde cong_map_App1 by blast + qed + also have "map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # map \.un_App2 (u # U)) = + map (\.App M) (N # map \.un_App2 (u # U))" + using M MN \\.Trg (\.un_App1 (last (u # U))) = \.Trg M\ + \.Ide_iff_Trg_self + by force + also have "... = (M \<^bold>\ N) # map (\.App M) (map \.un_App2 (u # U))" + by simp + also have "... = (M \<^bold>\ N) # u # U" + proof - + have "Arr (u # U)" + using Std Std_imp_Arr by blast + moreover have "set (u # U) \ Collect \.is_App" + using *** u by simp + moreover have "\.un_App1 u = M" + by (metis * u M seq Trg_last_Src_hd_eqI \.Ide_iff_Src_self + \.Ide_iff_Trg_self \.Ide_implies_Arr \.Src.simps(4) + \.Trg.simps(3) \.lambda.collapse(3) \.lambda.sel(3) + last.simps list.distinct(1) list.sel(1) list.set_intros(1) + list.set_map list.simps(9) mem_Collect_eq standardize.cases + subset_iff) + moreover have "\.un_App1 ` set (u # U) \ {M}" + proof - + have "Ide (map \.un_App1 (u # U))" + using * *** Std Std_imp_Arr Arr_map_un_App1 + by (metis Collect_cong Ide_char calculation(1-2) \.ide_char + list.set_map) + thus ?thesis + by (metis calculation(3) hd_map list.discI list.sel(1) + list.set_map set_Ide_subset_single_hd) + qed + ultimately show ?thesis + using M map_App_map_un_App2 by blast + qed + finally show ?thesis by blast + next + assume M: "\ \.Ide M" + have "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. X \<^bold>\ \.Src N) (standard_development M) @ + map (\X. \.Trg M \<^bold>\ X) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))" + using 4 6 by simp + also have "... \<^sup>*\\<^sup>* [M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N] @ + map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U)))" + proof (intro cong_append) + show "map (\X. X \<^bold>\ \.Src N) (standard_development M) \<^sup>*\\<^sup>* + [M \<^bold>\ \.Src N]" + using MN M cong_standard_development \.Ide_Src + cong_map_App2 [of "\.Src N" "standard_development M" "[M]"] + by simp + show "map (\X. \.Trg M \<^bold>\ X) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) \<^sup>*\\<^sup>* + [\.Trg M \<^bold>\ N] @ + map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U)))" + proof - + have "map (\X. \.Trg M \<^bold>\ X) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) \<^sup>*\\<^sup>* + map (\X. \.Trg M \<^bold>\ X) + (N # filter notIde (map \.un_App2 (u # U)))" + using ** B MN cong_map_App1 lambda_calculus.Ide_Trg + by presburger + also have "map (\X. \.Trg M \<^bold>\ X) + (N # filter notIde (map \.un_App2 (u # U))) = + [\.Trg M \<^bold>\ N] @ + map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U)))" + by simp + finally show ?thesis by blast + qed + show "seq (map (\X. X \<^bold>\ \.Src N) (standard_development M)) + (map (\X. \.Trg M \<^bold>\ X) + (stdz_insert N (filter notIde + (map \.un_App2 (u # U)))))" + using MN M ** B cong_standard_development [of M] + by (metis Nil_is_append_conv Resid.simps(2) Std_imp_Arr + \Std (stdz_insert (M \<^bold>\ N) (u # U))\ arr_append_imp_seq + arr_char calculation complete_development_Ide_iff + complete_development_def list.map_disc_iff development.simps(1)) + qed + also have "[M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N] @ + map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U))) = + ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) @ + map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U)))" + by simp + also have "([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) @ + map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U))) \<^sup>*\\<^sup>* + ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) @ + map (\X. \.Trg M \<^bold>\ X) (map \.un_App2 (u # U))" + proof (intro cong_append) + show "seq ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) + (map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U))))" + proof + show "Arr ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N])" + by (simp add: MN) + show 9: "Arr (map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U))))" + proof - + have "Arr (map \.un_App2 (u # U))" + using *** u Arr_map_un_App2 + by (metis Std Std_imp_Arr list.distinct(1) mem_Collect_eq + set_ConsD subset_code(1)) + moreover have "\ Ide (map \.un_App2 (u # U))" + using ** + by (metis Collect_cong \.ide_char list.set_map + set_Ide_subset_ide) + ultimately show ?thesis + using cong_filter_notIde + by (metis Arr_map_App2 Con_implies_Arr(2) Ide.simps(1) + MN ide_char \.Ide_Trg) + qed + show "\.Trg (last ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N])) = + \.Src (hd (map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U)))))" + proof - + have "\.Trg (last ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N])) = + \.Trg M \<^bold>\ \.Trg N" + using MN by auto + also have "... = \.Src u" + using Trg_last_Src_hd_eqI seq by force + also have "... = \.Src (\.Trg M \<^bold>\ \.un_App2 u)" + using MN \\.App (\.Trg M) (\.Trg N) = \.Src u\ u by auto + also have 8: "... = \.Trg M \<^bold>\ \.Src (\.un_App2 u)" + using MN by simp + also have 7: "... = \.Trg M \<^bold>\ + \.Src (hd (filter notIde + (map \.un_App2 (u # U))))" + using u 5 list.simps(9) cong_filter_notIde + \filter notIde (map \.un_App1 (u # U)) = []\ + by auto + also have "... = \.Src (hd (map (\X. \.Trg M \<^bold>\ X) + (filter notIde + (map \.un_App2 (u # U)))))" + (* TODO: Figure out what is going on with 7 8 9. *) + by (metis 7 8 9 Arr.simps(1) hd_map \.Src.simps(4) + \.lambda.sel(4) list.simps(8)) + finally show "\.Trg (last ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N])) = + \.Src (hd (map (\X. \.Trg M \<^bold>\ X) + (filter notIde + (map \.un_App2 (u # U)))))" + by blast + qed + qed + show "seq [M \<^bold>\ \.Src N] [\.Trg M \<^bold>\ N]" + using MN by fastforce + show "[M \<^bold>\ \.Src N] \<^sup>*\\<^sup>* [M \<^bold>\ \.Src N]" + using MN + by (meson head_redex_decomp \.Arr.simps(4) \.Arr_Src + prfx_transitive) + show "[\.Trg M \<^bold>\ N] \<^sup>*\\<^sup>* [\.Trg M \<^bold>\ N]" + using MN + by (meson \seq [M \<^bold>\ \.Src N] [\.Trg M \<^bold>\ N]\ cong_reflexive seqE) + show "map (\X. \.Trg M \<^bold>\ X) + (filter notIde (map \.un_App2 (u # U))) \<^sup>*\\<^sup>* + map (\X. \.Trg M \<^bold>\ X) (map \.un_App2 (u # U))" + proof - + have "Arr (map \.un_App2 (u # U))" + using *** u Arr_map_un_App2 + by (metis Std Std_imp_Arr list.distinct(1) mem_Collect_eq + set_ConsD subset_code(1)) + moreover have "\ Ide (map \.un_App2 (u # U))" + using ** + by (metis Collect_cong \.ide_char list.set_map + set_Ide_subset_ide) + ultimately show ?thesis + using M MN cong_filter_notIde cong_map_App1 \.Ide_Trg + by presburger + qed + qed + also have "([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) @ + map (\X. \.Trg M \<^bold>\ X) (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ u # U" + proof (intro cong_append) + show "seq ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) + (map (\X. \.Trg M \<^bold>\ X) (map \.un_App2 (u # U)))" + by (metis Nil_is_append_conv Nil_is_map_conv arr_append_imp_seq + calculation cong_implies_coterminal coterminalE + list.distinct(1)) + show "[M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N] \<^sup>*\\<^sup>* [M \<^bold>\ N]" + using MN \.resid_Arr_self \.Arr_not_Nil \.Ide_Trg ide_char by simp + show " map (\X. \.Trg M \<^bold>\ X) (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* u # U" + proof - + have "map (\X. \.Trg M \<^bold>\ X) (map \.un_App2 (u # U)) = u # U" + proof (intro map_App_map_un_App2) + show "Arr (u # U)" + using Std Std_imp_Arr by blast + show "set (u # U) \ Collect \.is_App" + using *** u by auto + show "\.Ide (\.Trg M)" + using MN \.Ide_Trg by blast + show "\.un_App1 ` set (u # U) \ {\.Trg M}" + proof - + have "\.un_App1 u = \.Trg M" + using * u seq seq_char + apply (cases u) + apply simp_all + by (metis Trg_last_Src_hd_eqI \.Ide_iff_Src_self + \.Src_Src \.Src_Trg \.Src_eq_iff(2) \.Trg.simps(3) + last_ConsL list.sel(1) seq u) + moreover have "Ide (map \.un_App1 (u # U))" + using * Std Std_imp_Arr Arr_map_un_App1 + by (metis Collect_cong Ide_char + \Arr (u # U)\ \set (u # U) \ Collect \.is_App\ + \.ide_char list.set_map) + ultimately show ?thesis + using set_Ide_subset_single_hd by force + qed + qed + thus ?thesis + by (simp add: Resid_Arr_self Std ide_char) + qed + qed + also have "[M \<^bold>\ N] @ u # U = (M \<^bold>\ N) # u # U" + by simp + finally show ?thesis by blast + qed + qed + qed + qed + show "\\ \.un_App1 ` set (u # U) \ Collect \.Ide; + \.un_App2 ` set (u # U) \ Collect \.Ide\ + \ ?thesis" + proof - + assume *: "\ \.un_App1 ` set (u # U) \ Collect \.Ide" + assume **: "\.un_App2 ` set (u # U) \ Collect \.Ide" + have 10: "filter notIde (map \.un_App2 (u # U)) = []" + using ** by (simp add: subset_eq) + hence 4: "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N)" + using u 4 5 * ** Ide_iff_standard_development_empty MN + by simp + have 6: "\.Ide (\.Trg (\.un_App1 (last (u # U))))" + using *** u Std Std_imp_Arr + by (metis Arr_imp_arr_last in_mono \.Arr.simps(4) \.Ide_Trg \.arr_char + \.lambda.collapse(3) last.simps last_in_set list.discI mem_Collect_eq) + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "Std (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N))" + proof (intro Std_append) + show "Std (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde + (map \.un_App1 (u # U)))))" + using * A MN Std_map_App1 \.Ide_Src by presburger + show "Std (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N))" + using MN 6 Std_map_App2 Std_standard_development by simp + show "map (\X. X \<^bold>\ \.Src N) + (stdz_insert M + (filter notIde (map \.un_App1 (u # U)))) = [] \ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N) = [] \ + \.sseq (last (map (\X. \.App X (\.Src N)) + (stdz_insert M + (filter notIde (map \.un_App1 (u # U)))))) + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N)))" + proof (cases "\.Ide N") + show "\.Ide N \ ?thesis" + using Ide_iff_standard_development_empty MN by blast + assume N: "\ \.Ide N" + have "\.sseq (last (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M + (filter notIde (map \.un_App1 (u # U)))))) + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N)))" + proof - + have "hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N)) = + \.App (\.Trg (\.un_App1 (last (u # U)))) + (hd (standard_development N))" + by (meson Ide_iff_standard_development_empty MN N list.map_sel(1)) + moreover have "last (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M + (filter notIde (map \.un_App1 (u # U))))) = + \.App (last (stdz_insert M + (filter notIde + (map \.un_App1 (u # U))))) + (\.Src N)" + by (metis * A Ide.simps(1) Resid.simps(1) ide_char last_map) + moreover have "\.sseq ... (\.App (\.Trg (\.un_App1 (last (u # U)))) + (hd (standard_development N)))" + proof - + have 7: "\.elementary_reduction + (last (stdz_insert M (filter notIde + (map \.un_App1 (u # U)))))" + using * A + by (metis Ide.simps(1) Resid.simps(2) ide_char last_in_set + mem_Collect_eq subset_iff) + moreover + have "\.elementary_reduction (hd (standard_development N))" + using MN N hd_in_set set_standard_development + Ide_iff_standard_development_empty + by blast + moreover have "\.Src N = \.Src (hd (standard_development N))" + using MN N Src_hd_standard_development by auto + moreover have "\.Trg (last (stdz_insert M + (filter notIde + (map \.un_App1 (u # U))))) = + \.Trg (\.un_App1 (last (u # U)))" + proof - + have "[\.Trg (last (stdz_insert M + (filter notIde + (map \.un_App1 (u # U)))))] = + [\.Trg (\.un_App1 (last (u # U)))]" + proof - + have "\.Trg (last (stdz_insert M + (filter notIde + (map \.un_App1 (u # U))))) = + \.Trg (last (map \.un_App1 (u # U)))" + proof - + have "\.Trg (last (stdz_insert M + (filter notIde (map \.un_App1 (u # U))))) = + \.Trg (last (M # filter notIde (map \.un_App1 (u # U))))" + using * A Trg_last_eqI by blast + also have "... = \.Trg (last ([M] @ filter notIde + (map \.un_App1 (u # U))))" + by simp + also have "... = \.Trg (last (filter notIde + (map \.un_App1 (u # U))))" + proof - + have "seq [M] (filter notIde (map \.un_App1 (u # U)))" + proof + show "Arr [M]" + using MN by simp + show "Arr (filter notIde (map \.un_App1 (u # U)))" + using * Std_imp_Arr + by (metis (no_types, lifting) + X empty_filter_conv list.set_map mem_Collect_eq subsetI) + show "\.Trg (last [M]) = + \.Src (hd (filter notIde (map \.un_App1 (u # U))))" + proof - + have "\.Trg (last [M]) = \.Trg M" + using MN by simp + also have "... = \.Src (\.un_App1 u)" + by (metis Trg_last_Src_hd_eqI \.Src.simps(4) + \.Trg.simps(3) \.lambda.collapse(3) + \.lambda.inject(3) last_ConsL list.sel(1) seq u) + also have "... = \.Src (hd (map \.un_App1 (u # U)))" + by auto + also have "... = \.Src (hd (filter notIde + (map \.un_App1 (u # U))))" + using u 5 10 by force + finally show ?thesis by blast + qed + qed + thus ?thesis by fastforce + qed + also have "... = \.Trg (last (map \.un_App1 (u # U)))" + proof - + have "filter (\u. \ \.Ide u) (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* + map \.un_App1 (u # U)" + using * *** u Std Std_imp_Arr Arr_map_un_App1 [of "u # U"] + cong_filter_notIde + by (metis (mono_tags, lifting) empty_filter_conv + filter_notIde_Ide list.discI list.set_map + mem_Collect_eq set_ConsD subset_code(1)) + thus ?thesis + using cong_implies_coterminal Trg_last_eqI + by presburger + qed + finally show ?thesis by blast + qed + thus ?thesis + by (simp add: last_map) + qed + moreover + have "\.Ide (\.Trg (last (stdz_insert M + (filter notIde + (map \.un_App1 (u # U))))))" + using 7 \.Ide_Trg \.elementary_reduction_is_arr by blast + moreover have "\.Ide (\.Trg (\.un_App1 (last (u # U))))" + using 6 by blast + ultimately show ?thesis by simp + qed + ultimately show ?thesis + using \.sseq.simps(4) by blast + qed + ultimately show ?thesis by argo + qed + thus ?thesis by blast + qed + qed + thus ?thesis + using 4 by simp + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof (cases "\.Ide N") + assume N: "\.Ide N" + have "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. X \<^bold>\ N) + (stdz_insert M (filter notIde + (map \.un_App1 (u # U))))" + using 4 N MN Ide_iff_standard_development_empty \.Ide_iff_Src_self + by force + also have "... \<^sup>*\\<^sup>* map (\X. X \<^bold>\ N) + (M # filter notIde + (map \.un_App1 (u # U)))" + using * A MN N \.Ide_Src cong_map_App2 \.Ide_iff_Src_self + by blast + also have "map (\X. X \<^bold>\ N) + (M # filter notIde + (map \.un_App1 (u # U))) = + [M \<^bold>\ N] @ + map (\X. \.App X N) + (filter notIde (map \.un_App1 (u # U)))" + by auto + also have "[M \<^bold>\ N] @ + map (\X. X \<^bold>\ N) + (filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ map (\X. X \<^bold>\ N) (map \.un_App1 (u # U))" + proof (intro cong_append) + show "seq [M \<^bold>\ N] + (map (\X. X \<^bold>\ N) + (filter notIde (map \.un_App1 (u # U))))" + proof + have 20: "Arr (map \.un_App1 (u # U))" + using *** u Std Arr_map_un_App1 + by (metis Std_imp_Arr insert_subset list.discI list.simps(15) + mem_Collect_eq) + show "Arr [M \<^bold>\ N]" + using MN by auto + show 21: "Arr (map (\X. X \<^bold>\ N) + (filter notIde (map \.un_App1 (u # U))))" + proof - + have "Arr (filter notIde (map \.un_App1 (u # U)))" + using u 20 cong_filter_notIde + by (metis (no_types, lifting) * Std_imp_Arr + \Std (filter notIde (map \.un_App1 (u # U)))\ + empty_filter_conv list.set_map mem_Collect_eq subsetI) + thus ?thesis + using MN N Arr_map_App1 \.Ide_Src by presburger + qed + show "\.Trg (last [M \<^bold>\ N]) = + \.Src (hd (map (\X. X \<^bold>\ N) + (filter notIde (map \.un_App1 (u # U)))))" + proof - + have "\.Trg (last [M \<^bold>\ N]) = \.Trg M \<^bold>\ N" + using MN N \.Ide_iff_Trg_self by simp + also have "... = \.Src (\.un_App1 u) \<^bold>\ N" + using MN u seq seq_char + by (metis Trg_last_Src_hd_eqI calculation \.Src_Src \.Src_Trg + \.Src_eq_iff(2) \.is_App_def \.lambda.sel(3) list.sel(1)) + also have "... = \.Src (\.un_App1 u \<^bold>\ N)" + using MN N \.Ide_iff_Src_self by simp + also have "... = \.Src (hd (map (\X. X \<^bold>\ N) + (map \.un_App1 (u # U))))" + by simp + also have "... = \.Src (hd (map (\X. X \<^bold>\ N) + (filter notIde + (map \.un_App1 (u # U)))))" + proof - + have "cong (map \.un_App1 (u # U)) + (filter notIde (map \.un_App1 (u # U)))" + using * 20 21 cong_filter_notIde + by (metis Arr.simps(1) filter_notIde_Ide map_is_Nil_conv) + thus ?thesis + by (metis (no_types, lifting) Ide.simps(1) Resid.simps(2) + Src_hd_eqI hd_map ide_char \.Src.simps(4) + list.distinct(1) list.simps(9)) + qed + finally show ?thesis by blast + qed + qed + show "cong [M \<^bold>\ N] [M \<^bold>\ N]" + using MN + by (meson head_redex_decomp \.Arr.simps(4) \.Arr_Src + prfx_transitive) + show "map (\X. X \<^bold>\ N) (filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ N) (map \.un_App1 (u # U))" + proof - + have "Arr (map \.un_App1 (u # U))" + using *** u Std Arr_map_un_App1 + by (metis Std_imp_Arr insert_subset list.discI list.simps(15) + mem_Collect_eq) + moreover have "\ Ide (map \.un_App1 (u # U))" + using * + by (metis Collect_cong \.ide_char list.set_map + set_Ide_subset_ide) + ultimately show ?thesis + using *** u MN N cong_filter_notIde cong_map_App2 + by (meson \.Ide_Src) + qed + qed + also have "[M \<^bold>\ N] @ map (\X. X \<^bold>\ N) (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ u # U" + proof - + have "map (\X. X \<^bold>\ N) (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* u # U" + proof - + have "map (\X. X \<^bold>\ N) (map \.un_App1 (u # U)) = u # U" + proof (intro map_App_map_un_App1) + show "Arr (u # U)" + using Std Std_imp_Arr by simp + show "set (u # U) \ Collect \.is_App" + using *** u by auto + show "\.Ide N" + using N by simp + show "\.un_App2 ` set (u # U) \ {N}" + proof - + have "\.Src (\.un_App2 u) = \.Trg N" + using ** seq u seq_char N + apply (cases u) + apply simp_all + by (metis Trg_last_Src_hd_eqI \.Src.simps(4) \.Trg.simps(3) + \.lambda.inject(3) last_ConsL list.sel(1) seq) + moreover have "\.Ide (\.un_App2 u) \ \.Ide N" + using ** N by simp + moreover have "Ide (map \.un_App2 (u # U))" + using ** Std Std_imp_Arr Arr_map_un_App2 + by (metis Collect_cong Ide_char + \Arr (u # U)\ \set (u # U) \ Collect \.is_App\ + \.ide_char list.set_map) + ultimately show ?thesis + by (metis hd_map \.Ide_iff_Src_self \.Ide_iff_Trg_self + \.Ide_implies_Arr list.discI list.sel(1) + list.set_map set_Ide_subset_single_hd) + qed + qed + thus ?thesis + by (simp add: Resid_Arr_self Std ide_char) + qed + thus ?thesis + using MN cong_append + by (metis (no_types, lifting) 1 cong_standard_development + cong_transitive \.Arr.simps(4) seq) + qed + also have "[M \<^bold>\ N] @ (u # U) = (M \<^bold>\ N) # u # U" + by simp + finally show ?thesis by blast + next + assume N: "\ \.Ide N" + have "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N)" + using 4 by simp + also have "... \<^sup>*\\<^sup>* map (\X. X \<^bold>\ \.Src N) + (M # filter notIde (map \.un_App1 (u # U))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]" + proof (intro cong_append) + show 23: "map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ \.Src N) + (M # filter notIde (map \.un_App1 (u # U)))" + using * A MN \.Ide_Src cong_map_App2 by blast + show 22: "map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N) \<^sup>*\\<^sup>* + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]" + using 6 *** u Std Std_imp_Arr MN N cong_standard_development + cong_map_App1 + by presburger + show "seq (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde + (map \.un_App1 (u # U))))) + (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (standard_development N))" + proof - + have "seq (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U)))) + (map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N])" + proof + show 26: "Arr (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U))))" + by (metis 23 Con_implies_Arr(2) Ide.simps(1) ide_char) + show "Arr (map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N])" + by (meson 22 arr_char con_implies_arr(2) prfx_implies_con) + show "\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U))))) = + \.Src (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + [N]))" + proof - + have "\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U)))) + \ + \.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U)))))" + proof - + have "targets (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U)))) = + targets (map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U)))" + proof - + have "map (\X. X \<^bold>\ \.Src N) + (M # filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U))" + proof - + have "map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U)) = + map (\X. X \<^bold>\ \.Src N) + ([M] @ map \.un_App1 (u # U))" + by simp + also have "cong ... (map (\X. X \<^bold>\ \.Src N) + ([M] @ filter notIde + (map \.un_App1 (u # U))))" + proof - + have "[M] @ map \.un_App1 (u # U) \<^sup>*\\<^sup>* + [M] @ filter notIde + (map \.un_App1 (u # U))" + proof (intro cong_append) + show "cong [M] [M]" + using MN + by (meson head_redex_decomp prfx_transitive) + show "seq [M] (map \.un_App1 (u # U))" + proof + show "Arr [M]" + using MN by simp + show "Arr (map \.un_App1 (u # U))" + using *** u Std Arr_map_un_App1 + by (metis Std_imp_Arr insert_subset list.discI + list.simps(15) mem_Collect_eq) + show "\.Trg (last [M]) = + \.Src (hd (map \.un_App1 (u # U)))" + using MN u seq seq_char Srcs_simp\<^sub>\\<^sub>P by auto + qed + show "cong (map \.un_App1 (u # U)) + (filter notIde + (map \.un_App1 (u # U)))" + proof - + have "Arr (map \.un_App1 (u # U))" + by (metis *** Arr_map_un_App1 Std Std_imp_Arr + insert_subset list.discI list.simps(15) + mem_Collect_eq u) + moreover have "\ Ide (map \.un_App1 (u # U))" + using * set_Ide_subset_ide by fastforce + ultimately show ?thesis + using cong_filter_notIde by blast + qed + qed + thus "map (\X. X \<^bold>\ \.Src N) + ([M] @ map \.un_App1 (u # U)) \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ \.Src N) + ([M] @ filter notIde (map \.un_App1 (u # U)))" + using MN cong_map_App2 \.Ide_Src by presburger + qed + finally show ?thesis by simp + qed + thus ?thesis + using cong_implies_coterminal by blast + qed + moreover have "[\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U))))] \ + targets (map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U)))" + by (metis (no_types, lifting) 26 calculation mem_Collect_eq + single_Trg_last_in_targets targets_char\<^sub>\\<^sub>P) + moreover have "[\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U)))))] \ + targets (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U))))" + using 26 single_Trg_last_in_targets by blast + ultimately show ?thesis + by (metis (no_types, lifting) 26 Ide.simps(1-2) Resid_rec(1) + in_targets_iff ide_char) + qed + moreover have "\.Ide (\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U)))))" + by (metis 6 MN \.Ide.simps(4) \.Ide_Src \.Trg.simps(3) + \.Trg_Src last_ConsR last_map list.distinct(1) + list.simps(9)) + moreover have "\.Ide (\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (M # filter notIde + (map \.un_App1 (u # U))))))" + using \.ide_backward_stable calculation(1-2) by fast + ultimately show ?thesis + by (metis (no_types, lifting) 6 MN hd_map + \.Ide_iff_Src_self \.Ide_implies_Arr \.Src.simps(4) + \.Trg.simps(3) \.Trg_Src \.cong_Ide_are_eq + last.simps last_map list.distinct(1) list.map_disc_iff + list.sel(1)) + qed + qed + thus ?thesis + using 22 23 cong_respects_seq\<^sub>P by presburger + qed + qed + also have "map (\X. X \<^bold>\ \.Src N) + (M # filter notIde (map \.un_App1 (u # U))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N] = + [M \<^bold>\ \.Src N] @ + map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U))) @ + [\.App (\.Trg (\.un_App1 (last (u # U)))) N]" + by simp + also have 1: "[M \<^bold>\ \.Src N] @ + map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U))) @ + [\.App (\.Trg (\.un_App1 (last (u # U)))) N] \<^sup>*\\<^sup>* + [M \<^bold>\ \.Src N] @ + map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + [\.App (\.Trg (\.un_App1 (last (u # U)))) N]" + proof (intro cong_append) + show "[M \<^bold>\ \.Src N] \<^sup>*\\<^sup>* [M \<^bold>\ \.Src N]" + using MN + by (meson head_redex_decomp lambda_calculus.Arr.simps(4) + lambda_calculus.Arr_Src prfx_transitive) + show 21: "map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U))" + proof - + have "filter notIde (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* + map \.un_App1 (u # U)" + proof - + have "\ Ide (map \.un_App1 (u # U))" + using * + by (metis Collect_cong \.ide_char list.set_map + set_Ide_subset_ide) + thus ?thesis + using *** u Std Std_imp_Arr Arr_map_un_App1 + cong_filter_notIde + by (metis \\ Ide (map \.un_App1 (u # U))\ + list.distinct(1) mem_Collect_eq set_ConsD + subset_code(1)) + qed + thus ?thesis + using MN cong_map_App2 [of "\.Src N"] \.Ide_Src by presburger + qed + show "[\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] \<^sup>*\\<^sup>* + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]" + by (metis "6" Con_implies_Arr(1) MN \.Ide_implies_Arr arr_char + cong_reflexive \.Ide_iff_Src_self neq_Nil_conv + orthogonal_App_single_single(1)) + show "seq (map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U)))) + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]" + proof + show "Arr (map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U))))" + by (metis 21 Con_implies_Arr(2) Ide.simps(1) ide_char) + show "Arr [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]" + by (metis Con_implies_Arr(2) Ide.simps(1) + \[\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] \<^sup>*\\<^sup>* + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]\ + ide_char) + show "\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (filter notIde + (map \.un_App1 (u # U))))) = + \.Src (hd [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N])" + by (metis (no_types, lifting) 6 21 MN Trg_last_eqI + \.Ide_iff_Src_self \.Ide_implies_Arr \.Src.simps(4) + \.Trg.simps(3) \.Trg_Src last_map list.distinct(1) + list.map_disc_iff list.sel(1)) + qed + show "seq [M \<^bold>\ \.Src N] + (map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U))) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N])" + proof + show "Arr [M \<^bold>\ \.Src N]" + using MN by simp + show "Arr (map (\X. X \<^bold>\ \.Src N) + (filter notIde (map \.un_App1 (u # U))) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N])" + apply (intro Arr_appendI\<^sub>P) + apply (metis 21 Con_implies_Arr(2) Ide.simps(1) ide_char) + apply (metis Con_implies_Arr(1) Ide.simps(1) + \[\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] \<^sup>*\\<^sup>* + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]\ ide_char) + by (metis (no_types, lifting) "21" Arr.simps(1) + Arr_append_iff\<^sub>P Con_implies_Arr(2) Ide.simps(1) + append_is_Nil_conv calculation ide_char not_Cons_self2) + show "\.Trg (last [M \<^bold>\ \.Src N]) = + \.Src (hd (map (\X. X \<^bold>\ \.Src N) + (filter notIde + (map \.un_App1 (u # U))) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]))" + by (metis (no_types, lifting) Con_implies_Arr(2) Ide.simps(1) + Trg_last_Src_hd_eqI append_is_Nil_conv arr_append_imp_seq + arr_char calculation ide_char not_Cons_self2) + qed + qed + also have "[M \<^bold>\ \.Src N] @ + map (\X. X \<^bold>\ \.Src N)(map \.un_App1 (u # U)) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] \<^sup>*\\<^sup>* + [M \<^bold>\ \.Src N] @ + [\.Trg M \<^bold>\ N] @ + map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))" + proof (intro cong_append [of "[\.App M (\.Src N)]"]) + show "seq [M \<^bold>\ \.Src N] + (map (\X. X \<^bold>\ \.Src N) + (map \.un_App1 (u # U)) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N])" + proof + show "Arr [M \<^bold>\ \.Src N]" + using MN by simp + show "Arr (map (\X. X \<^bold>\ \.Src N) + (map \.un_App1 (u # U)) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N])" + by (metis (no_types, lifting) 1 Con_append(2) Con_implies_Arr(2) + Ide.simps(1) append_is_Nil_conv ide_char not_Cons_self2) + show "\.Trg (last [M \<^bold>\ \.Src N]) = + \.Src (hd (map (\X. X \<^bold>\ \.Src N) + (map \.un_App1 (u # U)) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N]))" + proof - + have "\.Trg M = \.Src (\.un_App1 u)" + using u seq + by (metis Trg_last_Src_hd_eqI \.Src.simps(4) \.Trg.simps(3) + \.lambda.collapse(3) \.lambda.inject(3) last_ConsL + list.sel(1)) + thus ?thesis + using MN by auto + qed + qed + show "[M \<^bold>\ \.Src N] \<^sup>*\\<^sup>* [M \<^bold>\ \.Src N]" + using MN + by (metis head_redex_decomp \.Arr.simps(4) \.Arr_Src + prfx_transitive) + show "map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + [\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] \<^sup>*\\<^sup>* + [\.Trg M \<^bold>\ N] @ + map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))" + proof - + have "map (\X. X \<^bold>\ \.Src (hd [N])) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (last (map \.un_App1 (u # U))))) [N] \<^sup>*\\<^sup>* + map (\.App (\.Src (hd (map \.un_App1 (u # U))))) [N] @ + map (\X. X \<^bold>\ \.Trg (last [N])) (map \.un_App1 (u # U))" + proof - + have "Arr (map \.un_App1 (u # U))" + using Std *** u Arr_map_un_App1 + by (metis Std_imp_Arr insert_subset list.discI list.simps(15) + mem_Collect_eq) + moreover have "Arr [N]" + using MN by simp + ultimately show ?thesis + using orthogonal_App_cong by blast + qed + moreover + have "map (\.App (\.Src (hd (map \.un_App1 (u # U))))) [N] = + [\.Trg M \<^bold>\ N]" + by (metis Trg_last_Src_hd_eqI lambda_calculus.Src.simps(4) + \.Trg.simps(3) \.lambda.collapse(3) \.lambda.sel(3) + last_ConsL list.sel(1) list.simps(8) list.simps(9) seq u) + moreover have "[\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] = + map (\.App (\.Trg (last (map \.un_App1 (u # U))))) [N]" + by (simp add: last_map) + ultimately show ?thesis + using last_map by auto + qed + qed + also have "[M \<^bold>\ \.Src N] @ + [\.Trg M \<^bold>\ N] @ + map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)) = + ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) @ + map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))" + by simp + also have "... \<^sup>*\\<^sup>* [M \<^bold>\ N] @ (u # U)" + proof (intro cong_append) + show "[M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N] \<^sup>*\\<^sup>* [M \<^bold>\ N]" + using MN \.resid_Arr_self \.Arr_not_Nil \.Ide_Trg ide_char + by auto + show 1: "map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* u # U" + proof - + have "map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)) = u # U" + proof (intro map_App_map_un_App1) + show "Arr (u # U)" + using Std Std_imp_Arr by simp + show "set (u # U) \ Collect \.is_App" + using "***" u by auto + show "\.Ide (\.Trg N)" + using MN \.Ide_Trg by simp + show "\.un_App2 ` set (u # U) \ {\.Trg N}" + proof - + have "\.Src (\.un_App2 u) = \.Trg N" + using u seq seq_char + apply (cases u) + apply simp_all + by (metis Trg_last_Src_hd_eqI \.Src.simps(4) \.Trg.simps(3) + \.lambda.inject(3) last_ConsL list.sel(1) seq) + moreover have "\.Ide (\.un_App2 u)" + using ** by simp + moreover have "Ide (map \.un_App2 (u # U))" + using ** Std Std_imp_Arr Arr_map_un_App2 + by (metis Collect_cong Ide_char + \Arr (u # U)\ \set (u # U) \ Collect \.is_App\ + \.ide_char list.set_map) + ultimately show ?thesis + by (metis \.Ide_iff_Src_self \.Ide_implies_Arr list.sel(1) + list.set_map list.simps(9) set_Ide_subset_single_hd + singleton_insert_inj_eq) + qed + qed + thus ?thesis + by (simp add: Resid_Arr_self Std ide_char) + qed + show "seq ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N]) + (map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)))" + proof + show "Arr ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N])" + using MN by simp + show "Arr (map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)))" + using MN Std Std_imp_Arr Arr_map_un_App1 Arr_map_App1 + by (metis 1 Con_implies_Arr(1) Ide.simps(1) ide_char) + show "\.Trg (last ([M \<^bold>\ \.Src N] @ [\.Trg M \<^bold>\ N])) = + \.Src (hd (map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))))" + using MN Std Std_imp_Arr Arr_map_un_App1 Arr_map_App1 + seq seq_char u Srcs_simp\<^sub>\\<^sub>P by auto + qed + qed + also have "[M \<^bold>\ N] @ (u # U) = (M \<^bold>\ N) # u # U" + by simp + finally show ?thesis by blast + qed + qed + qed + qed + show "\\ \.un_App1 ` set (u # U) \ Collect \.Ide; + \ \.un_App2 ` set (u # U) \ Collect \.Ide\ + \ ?thesis" + proof - + assume *: "\ \.un_App1 ` set (u # U) \ Collect \.Ide" + assume **: "\ \.un_App2 ` set (u # U) \ Collect \.Ide" + show ?thesis + proof (intro conjI) + show "Std (stdz_insert (M \<^bold>\ N) (u # U))" + proof - + have "Std (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))))" + proof (intro Std_append) + show "Std (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))))" + using * A \.Ide_Src MN Std_map_App1 by presburger + show "Std (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))))" + proof - + have "\.Arr (\.un_App1 (last (u # U)))" + by (metis *** \.Arr.simps(4) Std Std_imp_Arr Arr.simps(2) + Arr_append_iff\<^sub>P append_butlast_last_id append_self_conv2 + \.arr_char \.lambda.collapse(3) last.simps last_in_set + list.discI mem_Collect_eq subset_code(1) u) + thus ?thesis + using ** B \.Ide_Trg MN Std_map_App2 by presburger + qed + show "map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) = [] \ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) = [] \ + \.sseq (last (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))))) + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))))" + proof - + have "\.sseq (last (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))))) + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))))" + proof - + let ?M = "\.un_App1 (last (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M + (filter notIde + (map \.un_App1 (u # U))))))" + let ?M' = "\.Trg (\.un_App1 (last (u # U)))" + let ?N = "\.Src N" + let ?N' = "\.un_App2 + (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N + (filter notIde + (map \.un_App2 (u # U))))))" + have M: "?M = last (stdz_insert M + (filter notIde (map \.un_App1 (u # U))))" + by (metis * A Ide.simps(1) Resid.simps(1) ide_char + \.lambda.sel(3) last_map) + have N': "?N' = hd (stdz_insert N + (filter notIde (map \.un_App2 (u # U))))" + by (metis ** B Ide.simps(1) Resid.simps(2) ide_char + \.lambda.sel(4) hd_map) + have AppMN: "last (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M + (filter notIde (map \.un_App1 (u # U))))) = + ?M \<^bold>\ ?N" + by (metis * A Ide.simps(1) M Resid.simps(2) ide_char last_map) + moreover + have 4: "hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N + (filter notIde (map \.un_App2 (u # U))))) = + ?M' \<^bold>\ ?N'" + by (metis (no_types, lifting) ** B Resid.simps(2) con_char + prfx_implies_con \.lambda.collapse(3) \.lambda.discI(3) + \.lambda.inject(3) list.map_sel(1)) + moreover have MM: "\.elementary_reduction ?M" + by (metis * A Arr.simps(1) Con_implies_Arr(2) Ide.simps(1) + M ide_char in_mono last_in_set mem_Collect_eq) + moreover have NN': "\.elementary_reduction ?N'" + using ** B N' + by (metis Arr.simps(1) Con_implies_Arr(2) Ide.simps(1) + ide_char in_mono list.set_sel(1) mem_Collect_eq) + moreover have "\.Trg ?M = ?M'" + proof - + have 1: "[\.Trg ?M] \<^sup>*\\<^sup>* [?M']" + proof - + have "[\.Trg ?M] \<^sup>*\\<^sup>* + [\.Trg (last (M # filter notIde (map \.un_App1 (u # U))))]" + proof - + have "targets (stdz_insert M + (filter notIde (map \.un_App1 (u # U)))) = + targets (M # filter notIde (map \.un_App1 (u # U)))" + using * A cong_implies_coterminal by blast + moreover + have "[\.Trg (last (M # filter notIde (map \.un_App1 (u # U))))] + \ targets (M # filter notIde (map \.un_App1 (u # U)))" + by (metis (no_types, lifting) * A \.Arr_Trg \.Ide_Trg + Arr.simps(2) Arr_append_iff\<^sub>P Arr_iff_Con_self + Con_implies_Arr(2) Ide.simps(1) Ide.simps(2) + Resid_Arr_Ide_ind ide_char append_butlast_last_id + append_self_conv2 \.arr_char in_targets_iff \.ide_char + list.discI) + ultimately show ?thesis + using * A M in_targets_iff + by (metis (no_types, lifting) Con_implies_Arr(1) + con_char prfx_implies_con in_targets_iff) + qed + also have 2: "[\.Trg (last (M # filter notIde + (map \.un_App1 (u # U))))] \<^sup>*\\<^sup>* + [\.Trg (last (filter notIde + (map \.un_App1 (u # U))))]" + by (metis (no_types, lifting) * prfx_transitive + calculation empty_filter_conv last_ConsR list.set_map + mem_Collect_eq subsetI) + also have "[\.Trg (last (filter notIde + (map \.un_App1 (u # U))))] \<^sup>*\\<^sup>* + [\.Trg (last (map \.un_App1 (u # U)))]" + proof - + have "map \.un_App1 (u # U) \<^sup>*\\<^sup>* + filter notIde (map \.un_App1 (u # U))" + by (metis (mono_tags, lifting) * *** Arr_map_un_App1 + Std Std_imp_Arr cong_filter_notIde empty_filter_conv + filter_notIde_Ide insert_subset list.discI list.set_map + list.simps(15) mem_Collect_eq subsetI u) + thus ?thesis + by (metis 2 Trg_last_eqI prfx_transitive) + qed + also have "[\.Trg (last (map \.un_App1 (u # U)))] = [?M']" + by (simp add: last_map) + finally show ?thesis by blast + qed + have 3: "\.Trg ?M = \.Trg ?M \\ ?M'" + by (metis (no_types, lifting) 1 * A M Con_implies_Arr(2) + Ide.simps(1) Resid_Arr_Ide_ind Resid_rec(1) + ide_char target_is_ide in_targets_iff list.inject) + also have "... = ?M'" + by (metis (no_types, lifting) 1 4 Arr.simps(2) Con_implies_Arr(2) + Ide.simps(1) Ide.simps(2) MM NN' Resid_Arr_Ide_ind + Resid_rec(1) Src_hd_eqI calculation ide_char + \.Ide_iff_Src_self \.Src_Trg \.arr_char + \.elementary_reduction.simps(4) + \.elementary_reduction_App_iff \.elementary_reduction_is_arr + \.elementary_reduction_not_ide \.lambda.discI(3) + \.lambda.sel(3) list.sel(1)) + finally show ?thesis by blast + qed + moreover have "?N = \.Src ?N'" + proof - + have 1: "[\.Src ?N'] \<^sup>*\\<^sup>* [?N]" + proof - + have "sources (stdz_insert N + (filter notIde (map \.un_App2 (u # U)))) = + sources [N]" + using ** B + by (metis Con_implies_Arr(2) Ide.simps(1) coinitialE + cong_implies_coinitial ide_char sources_cons) + thus ?thesis + by (metis (no_types, lifting) AppMN ** B \.Ide_Src + MM MN N' NN' \.Trg_Src Arr.simps(1) Arr.simps(2) + Con_implies_Arr(1) Ide.simps(2) con_char ideE ide_char + sources_cons \.arr_char in_targets_iff + \.elementary_reduction.simps(4) \.elementary_reduction_App_iff + \.elementary_reduction_is_arr \.elementary_reduction_not_ide + \.lambda.disc(14) \.lambda.sel(4) last_ConsL list.exhaust_sel + targets_single_Src) + qed + have "\.Src ?N' = \.Src ?N' \\ ?N" + by (metis (no_types, lifting) 1 MN \.Coinitial_iff_Con + \.Ide_Src Arr.simps(2) Ide.simps(1) Ide_implies_Arr + Resid_rec(1) ide_char \.not_arr_null \.null_char + \.resid_Arr_Ide) + also have "... = ?N" + by (metis 1 MN NN' Src_hd_eqI calculation \.Src_Src \.arr_char + \.elementary_reduction_is_arr list.sel(1)) + finally show ?thesis by simp + qed + ultimately show ?thesis + using u \.sseq.simps(4) + by (metis (mono_tags, lifting)) + qed + thus ?thesis by blast + qed + qed + thus ?thesis + using 4 by presburger + qed + show "\ Ide ((M \<^bold>\ N) # u # U) \ + stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + proof + have "stdz_insert (M \<^bold>\ N) (u # U) = + map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U))))" + using 4 by simp + also have "... \<^sup>*\\<^sup>* map (\X. X \<^bold>\ \.Src N) + (M # map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # map \.un_App2 (u # U))" + proof (intro cong_append) + have X: "stdz_insert M (filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + M # map \.un_App1 (u # U)" + proof - + have "stdz_insert M (filter notIde (map \.un_App1 (u # U))) \<^sup>*\\<^sup>* + [M] @ filter notIde (map \.un_App1 (u # U))" + using * A by simp + also have "[M] @ filter notIde (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* + [M] @ map \.un_App1 (u # U)" + proof - + have "filter notIde (map \.un_App1 (u # U)) \<^sup>*\\<^sup>* + map \.un_App1 (u # U)" + using * cong_filter_notIde + by (metis (mono_tags, lifting) *** Arr_map_un_App1 Std + Std_imp_Arr empty_filter_conv filter_notIde_Ide insert_subset + list.discI list.set_map list.simps(15) mem_Collect_eq subsetI u) + moreover have "seq [M] (filter notIde (map \.un_App1 (u # U)))" + by (metis * A Arr.simps(1) Con_implies_Arr(1) append_Cons + append_Nil arr_append_imp_seq arr_char calculation + ide_implies_arr list.discI) + ultimately show ?thesis + using cong_append cong_reflexive by blast + qed + also have "[M] @ map \.un_App1 (u # U) = + M # map \.un_App1 (u # U)" + by simp + finally show ?thesis by blast + qed + have Y: "stdz_insert N (filter notIde (map \.un_App2 (u # U))) \<^sup>*\\<^sup>* + N # map \.un_App2 (u # U)" + proof - + have 5: "stdz_insert N (filter notIde (map \.un_App2 (u # U))) \<^sup>*\\<^sup>* + [N] @ filter notIde (map \.un_App2 (u # U))" + using ** B by simp + also have "[N] @ filter notIde (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + [N] @ map \.un_App2 (u # U)" + proof - + have "filter notIde (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + map \.un_App2 (u # U)" + using ** cong_filter_notIde + by (metis (mono_tags, lifting) *** Arr_map_un_App2 Std + Std_imp_Arr empty_filter_conv filter_notIde_Ide insert_subset + list.discI list.set_map list.simps(15) mem_Collect_eq subsetI u) + moreover have "seq [N] (filter notIde (map \.un_App2 (u # U)))" + by (metis 5 Arr.simps(1) Con_implies_Arr(2) Ide.simps(1) + arr_append_imp_seq arr_char calculation ide_char not_Cons_self2) + ultimately show ?thesis + using cong_append cong_reflexive by blast + qed + also have "[N] @ map \.un_App2 (u # U) = + N # map \.un_App2 (u # U)" + by simp + finally show ?thesis by blast + qed + show "seq (map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U))))) + (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))))" + by (metis 4 * ** A B Ide.simps(1) Nil_is_append_conv Nil_is_map_conv + Resid.simps(1) Std_imp_Arr \Std (stdz_insert (M \<^bold>\ N) (u # U))\ + arr_append_imp_seq arr_char ide_char) + show "map (\X. X \<^bold>\ \.Src N) + (stdz_insert M (filter notIde (map \.un_App1 (u # U)))) \<^sup>*\\<^sup>* + map (\X. X \<^bold>\ \.Src N) (M # map \.un_App1 (u # U))" + using X cong_map_App2 MN lambda_calculus.Ide_Src by presburger + show "map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (stdz_insert N (filter notIde (map \.un_App2 (u # U)))) \<^sup>*\\<^sup>* + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # map \.un_App2 (u # U))" + proof - + have "set U \ Collect \.Arr \ Collect \.is_App" + using *** Std Std_implies_set_subset_elementary_reduction + \.elementary_reduction_is_arr + by blast + hence "\.Ide (\.Trg (\.un_App1 (last (u # U))))" + by (metis inf.boundedE \.Arr.simps(4) \.Ide_Trg + \.lambda.collapse(3) last.simps last_in_set mem_Collect_eq + subset_eq u) + thus ?thesis + using Y cong_map_App1 by blast + qed + qed + also have "map (\X. X \<^bold>\ \.Src N) (M # map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + [M \<^bold>\ N] @ [u] @ U" + proof - + have "(map (\X. X \<^bold>\ \.Src N) (M # map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (N # map \.un_App2 (u # U))) = + ([M \<^bold>\ \.Src N] @ + map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U))) @ + ([\.Trg (\.un_App1 (last (u # U))) \<^bold>\ N] @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)))" + by simp + also have "... = [M \<^bold>\ \.Src N] @ + (map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))" + by auto + also have "... \<^sup>*\\<^sup>* [M \<^bold>\ \.Src N] @ + (map (\.App (\.Src (\.un_App1 u))) [N] @ + map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))" + proof - + (* + * TODO: (intro congI) does not work because it breaks the expression + * down too far, resulting in a false subgoal. + *) + have "(map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + (map (\.App (\.Src (\.un_App1 u))) [N] @ + map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))" + proof - + have 1: "Arr (map \.un_App1 (u # U))" + using u *** + by (metis Arr_map_un_App1 Std Std_imp_Arr list.discI + mem_Collect_eq set_ConsD subset_code(1)) + have "map (\X. \.App X (\.Src N)) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N] \<^sup>*\\<^sup>* + map (\.App (\.Src (\.un_App1 u))) [N] @ + map (\X. \.App X (\.Trg N)) (map \.un_App1 (u # U))" + proof - + have "Arr [N]" + using MN by simp + moreover have "\.Trg (last (map \.un_App1 (u # U))) = + \.Trg (\.un_App1 (last (u # U)))" + by (simp add: last_map) + ultimately show ?thesis + using 1 orthogonal_App_cong [of "map \.un_App1 (u # U)" "[N]"] + by simp + qed + moreover have "seq (map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]) + (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)))" + proof + show "Arr (map (\X. X \<^bold>\ \.Src N) + (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N])" + by (metis Con_implies_Arr(1) Ide.simps(1) calculation ide_char) + show "Arr (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)))" + using u *** + by (metis 1 Arr_imp_arr_last Arr_map_App2 Arr_map_un_App2 + Std Std_imp_Arr \.Ide_Trg \.arr_char last_map list.discI + mem_Collect_eq set_ConsD subset_code(1)) + show "\.Trg (last (map (\X. X \<^bold>\ \.Src N) + (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + [N])) = + \.Src (hd (map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))))" + proof - + have 1: "\.Arr (\.un_App1 u)" + using u \.is_App_def by force + have 2: "U \ [] \ \.Arr (\.un_App1 (last U))" + by (metis *** Arr_imp_arr_last Arr_map_un_App1 + \U \ [] \ Arr U\ \.arr_char last_map) + have 3: "\.Trg N = \.Src (\.un_App2 u)" + by (metis Trg_last_Src_hd_eqI \.Src.simps(4) \.Trg.simps(3) + \.lambda.collapse(3) \.lambda.inject(3) last_ConsL + list.sel(1) seq u) + show ?thesis + using u *** seq 1 2 3 + by (cases "U = []") auto + qed + qed + moreover have "map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))" + using calculation(2) cong_reflexive by blast + ultimately show ?thesis + using cong_append by blast + qed + moreover have "seq [M \<^bold>\ \.Src N] + ((map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)))" + proof + show "Arr [M \<^bold>\ \.Src N]" + using MN by simp + show "Arr ((map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)))" + using MN u seq + by (metis Con_implies_Arr(1) Ide.simps(1) calculation ide_char) + show "\.Trg (last [M \<^bold>\ \.Src N]) = + \.Src (hd ((map (\X. X \<^bold>\ \.Src N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) [N]) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))))" + using MN u seq seq_char Srcs_simp\<^sub>\\<^sub>P + by (cases u) auto + qed + ultimately show ?thesis + using cong_append + by (meson Resid_Arr_self ide_char seq_char) + qed + also have "[M \<^bold>\ \.Src N] @ + (map (\.App (\.Src (\.un_App1 u))) [N] @ + map (\X. \.App X (\.Trg N)) (map \.un_App1 (u # U))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)) = + ([M \<^bold>\ \.Src N] @ [\.Src (\.un_App1 u) \<^bold>\ N]) @ + (map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U))) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U))" + by simp + also have "... \<^sup>*\\<^sup>* ([M \<^bold>\ N] @ [u] @ U)" + proof - + have "[M \<^bold>\ \.Src N] @ [\.Src (\.un_App1 u) \<^bold>\ N] \<^sup>*\\<^sup>* [M \<^bold>\ N]" + proof - + have "\.Src (\.un_App1 u) = \.Trg M" + by (metis Trg_last_Src_hd_eqI \.Src.simps(4) \.Trg.simps(3) + \.lambda.collapse(3) \.lambda.inject(3) last.simps + list.sel(1) seq u) + thus ?thesis + using MN u seq seq_char \.Arr_not_Nil \.resid_Arr_self ide_char + \.Ide_Trg + by simp + qed + moreover have "map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)) \<^sup>*\\<^sup>* + [u] @ U" + proof - + have "Arr ([u] @ U)" + by (simp add: Std) + moreover have "set ([u] @ U) \ Collect \.is_App" + using *** u by auto + moreover have "\.Src (\.un_App2 (hd ([u] @ U))) = \.Trg N" + proof - + have "\.Ide (\.Trg N)" + using MN lambda_calculus.Ide_Trg by presburger + moreover have "\.Ide (\.Src (\.un_App2 (hd ([u] @ U))))" + by (metis Std Std_implies_set_subset_elementary_reduction + \.Ide_Src \.arr_iff_has_source \.ide_implies_arr + \set ([u] @ U) \ Collect \.is_App\ append_Cons + \.elementary_reduction_App_iff \.elementary_reduction_is_arr + \.sources_char\<^sub>\ list.sel(1) list.set_intros(1) + mem_Collect_eq subset_code(1)) + moreover have "\.Src (\.Trg N) = + \.Src (\.Src (\.un_App2 (hd ([u] @ U))))" + proof - + have "\.Src (\.Trg N) = \.Trg N" + using MN by simp + also have "... = \.Src (\.un_App2 u)" + using u seq seq_char Srcs_simp\<^sub>\\<^sub>P + by (cases u) auto + also have "... = \.Src (\.Src (\.un_App2 (hd ([u] @ U))))" + by (metis \.Ide_iff_Src_self \.Ide_implies_Arr + \\.Ide (\.Src (\.un_App2 (hd ([u] @ U))))\ + append_Cons list.sel(1)) + finally show ?thesis by blast + qed + ultimately show ?thesis + by (metis \.Ide_iff_Src_self \.Ide_implies_Arr) + qed + ultimately show ?thesis + using map_App_decomp + by (metis append_Cons append_Nil) + qed + moreover have "seq ([M \<^bold>\ \.Src N] @ [\.Src (\.un_App1 u) \<^bold>\ N]) + (map (\X. X \<^bold>\ \.Trg N) (map \.un_App1 (u # U)) @ + map (\.App (\.Trg (\.un_App1 (last (u # U))))) + (map \.un_App2 (u # U)))" + using calculation(1-2) cong_respects_seq\<^sub>P seq by auto + ultimately show ?thesis + using cong_append by presburger + qed + finally show ?thesis by blast + qed + also have "[M \<^bold>\ N] @ [u] @ U = (M \<^bold>\ N) # u # U" + by simp + finally show "stdz_insert (M \<^bold>\ N) (u # U) \<^sup>*\\<^sup>* (M \<^bold>\ N) # u # U" + by blast + qed + qed + qed + qed + qed + qed + qed + qed + qed + qed + text \ + The eight remaining subgoals are now trivial consequences of fact \*\. + Unfortunately, I haven't found a way to discharge them without having to state each + one of them explicitly. + \ + show "\N u U. \\.Ide (\<^bold>\ \<^bold>\ N) \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\ \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (\<^bold>\ \<^bold>\ N); + \.Ide ((\<^bold>\ \<^bold>\ N) \\ \.head_redex (\<^bold>\ \<^bold>\ N))\ + \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\ \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (\<^bold>\ \<^bold>\ N); + \ \.Ide ((\<^bold>\ \<^bold>\ N) \\ \.head_redex (\<^bold>\ \<^bold>\ N))\ + \ ?P ((\<^bold>\ \<^bold>\ N) \\ \.head_redex (\<^bold>\ \<^bold>\ N)) (u # U); + \\ \.Ide (\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\ \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \.Ide ((\<^bold>\ \<^bold>\ N) \\ \.head_strategy (\<^bold>\ \<^bold>\ N))\ + \ ?P (\.head_strategy (\<^bold>\ \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\ \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \ \.Ide ((\<^bold>\ \<^bold>\ N) \\ \.head_strategy (\<^bold>\ \<^bold>\ N))\ + \ ?P (\.resid (\<^bold>\ \<^bold>\ N) (\.head_strategy (\<^bold>\ \<^bold>\ N))) (tl (u # U)); + \\ \.Ide (\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\ \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P \<^bold>\ (filter notIde (map \.un_App1 (u # U))); + \\ \.Ide (\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\ \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P N (filter notIde (map \.un_App2 (u # U)))\ + \ ?P (\<^bold>\ \<^bold>\ N) (u # U)" + using * \.lambda.disc(6) by presburger + show "\x N u U. \\.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N) \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\x\<^bold>\ \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ N); + \.Ide ((\<^bold>\x\<^bold>\ \<^bold>\ N) \\ \.head_redex (\<^bold>\x\<^bold>\ \<^bold>\ N))\ + \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\x\<^bold>\ \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ N); + \ \.Ide ((\<^bold>\x\<^bold>\ \<^bold>\ N) \\ \.head_redex (\<^bold>\x\<^bold>\ \<^bold>\ N))\ + \ ?P ((\<^bold>\x\<^bold>\ \<^bold>\ N) \\ \.head_redex (\<^bold>\x\<^bold>\ \<^bold>\ N)) (u # U); + \\ \.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\x\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \.Ide ((\<^bold>\x\<^bold>\ \<^bold>\ N) \\ \.head_strategy (\<^bold>\x\<^bold>\ \<^bold>\ N))\ + \ ?P (\.head_strategy (\<^bold>\x\<^bold>\ \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\x\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \ \.Ide ((\<^bold>\x\<^bold>\ \<^bold>\ N) \\ \.head_strategy (\<^bold>\x\<^bold>\ \<^bold>\ N))\ + \ ?P ((\<^bold>\x\<^bold>\ \<^bold>\ N) \\ \.head_strategy (\<^bold>\x\<^bold>\ \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\x\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P \<^bold>\x\<^bold>\ (filter notIde (map \.un_App1 (u # U))); + \\ \.Ide (\<^bold>\x\<^bold>\ \<^bold>\ N); \.seq (\<^bold>\x\<^bold>\ \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\x\<^bold>\ \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P N (filter notIde (map \.un_App2 (u # U)))\ + \ ?P (\<^bold>\x\<^bold>\ \<^bold>\ N) (u # U)" + using * \.lambda.disc(7) by presburger + show "\M1 M2 N u U. \\.Ide (M1 \<^bold>\ M2 \<^bold>\ N) \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (M1 \<^bold>\ M2 \<^bold>\ N); \.seq (M1 \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (M1 \<^bold>\ M2 \<^bold>\ N); + \.Ide ((M1 \<^bold>\ M2 \<^bold>\ N) \\ \.head_redex (M1 \<^bold>\ M2 \<^bold>\ N))\ + \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (M1 \<^bold>\ M2 \<^bold>\ N); \.seq (M1 \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (M1 \<^bold>\ M2 \<^bold>\ N); + \ \.Ide ((M1 \<^bold>\ M2 \<^bold>\ N) \\ \.head_redex (M1 \<^bold>\ M2 \<^bold>\ N))\ + \ ?P ((M1 \<^bold>\ M2 \<^bold>\ N) \\ \.head_redex (M1 \<^bold>\ M2 \<^bold>\ N)) (u # U); + \\ \.Ide (M1 \<^bold>\ M2 \<^bold>\ N); \.seq (M1 \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M1 \<^bold>\ M2 \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \.Ide ((M1 \<^bold>\ M2 \<^bold>\ N) \\ \.head_strategy (M1 \<^bold>\ M2 \<^bold>\ N))\ + \ ?P (\.head_strategy (M1 \<^bold>\ M2 \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (M1 \<^bold>\ M2 \<^bold>\ N); \.seq (M1 \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M1 \<^bold>\ M2 \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \ \.Ide ((M1 \<^bold>\ M2 \<^bold>\ N) \\ \.head_strategy (M1 \<^bold>\ M2 \<^bold>\ N))\ + \ ?P ((M1 \<^bold>\ M2 \<^bold>\ N) \\ \.head_strategy (M1 \<^bold>\ M2 \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (M1 \<^bold>\ M2 \<^bold>\ N); \.seq (M1 \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M1 \<^bold>\ M2 \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P (M1 \<^bold>\ M2) (filter notIde (map \.un_App1 (u # U))); + \\ \.Ide (M1 \<^bold>\ M2 \<^bold>\ N); \.seq (M1 \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (M1 \<^bold>\ M2 \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P N (filter notIde (map \.un_App2 (u # U)))\ + \ ?P (M1 \<^bold>\ M2 \<^bold>\ N) (u # U)" + using * \.lambda.disc(9) by presburger + show "\M1 M2 N u U. \\.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); \.seq (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); + \.Ide ((\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) \\ (\.head_redex (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N)))\ + \ ?P (hd (u # U)) (tl (u # U)); + \\ \.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); \.seq (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \.contains_head_reduction (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); + \ \.Ide ((\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) \\ (\.head_redex (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N)))\ + \ ?P (\.resid (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (\.head_redex (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N))) + (u # U); + \\ \.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); \.seq (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \.Ide ((\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) \\ \.head_strategy (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N))\ + \ ?P (\.head_strategy (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N)) (tl (u # U)); + \\ \.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); \.seq (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); + \.contains_head_reduction (hd (u # U)); + \ \.Ide ((\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) \\ \.head_strategy (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N))\ + \ ?P ((\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) \\ \.head_strategy (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N)) + (tl (u # U)); + \\ \.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); \.seq (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2) (filter notIde (map \.un_App1 (u # U))); + \\ \.Ide (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); \.seq (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (hd (u # U)); + \ \.contains_head_reduction (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N); + \ \.contains_head_reduction (hd (u # U))\ + \ ?P N (filter notIde (map \.un_App2 (u # U)))\ + \ ?P (\<^bold>\\<^bold>[M1\<^bold>] \<^bold>\ M2 \<^bold>\ N) (u # U)" + using * \.lambda.disc(10) by presburger + show "\M N U. \\.Ide (M \<^bold>\ N) \ ?P (hd (\<^bold>\ # U)) (tl (\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\ # U)); + \.contains_head_reduction (M \<^bold>\ N); + \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P (hd (\<^bold>\ # U)) (tl (\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\ # U)); + \.contains_head_reduction (M \<^bold>\ N); + \ \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (\<^bold>\ # U); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (\<^bold>\ # U)); + \.Ide (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N)))\ + \ ?P (\.head_strategy (M \<^bold>\ N)) (tl (\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (\<^bold>\ # U)); + \ \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) (tl (\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (\<^bold>\ # U))\ + \ ?P M (filter notIde (map \.un_App1 (\<^bold>\ # U))); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (\<^bold>\ # U))\ + \ ?P N (filter notIde (map \.un_App2 (\<^bold>\ # U)))\ + \ ?P (M \<^bold>\ N) (\<^bold>\ # U)" + using * \.lambda.disc(16) by presburger + show "\M N x U. \\.Ide (M \<^bold>\ N) \ ?P (hd (\<^bold>\x\<^bold>\ # U)) (tl (\<^bold>\x\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\x\<^bold>\ # U)); + \.contains_head_reduction (M \<^bold>\ N); + \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P (hd (\<^bold>\x\<^bold>\ # U)) (tl (\<^bold>\x\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\x\<^bold>\ # U)); + \.contains_head_reduction (M \<^bold>\ N); + \ \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (\<^bold>\x\<^bold>\ # U); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\x\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (\<^bold>\x\<^bold>\ # U)); + \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P (\.head_strategy (M \<^bold>\ N)) (tl (\<^bold>\x\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\x\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (\<^bold>\x\<^bold>\ # U)); + \ \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) (tl (\<^bold>\x\<^bold>\ # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\x\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (\<^bold>\x\<^bold>\ # U))\ + \ ?P M (filter notIde (map \.un_App1 (\<^bold>\x\<^bold>\ # U))); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\x\<^bold>\ # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (\<^bold>\x\<^bold>\ # U))\ + \ ?P N (filter notIde (map \.un_App2 (\<^bold>\x\<^bold>\ # U)))\ + \ ?P (M \<^bold>\ N) (\<^bold>\x\<^bold>\ # U)" + using * \.lambda.disc(17) by presburger + show "\M N P U. \\.Ide (M \<^bold>\ N) \ ?P (hd (\<^bold>\\<^bold>[P\<^bold>] # U)) (tl (\<^bold>\\<^bold>[P\<^bold>] # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \.contains_head_reduction (M \<^bold>\ N); + \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P (hd (\<^bold>\\<^bold>[P\<^bold>] # U)) (tl (\<^bold>\\<^bold>[P\<^bold>] # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \.contains_head_reduction (M \<^bold>\ N); + \ \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) (\<^bold>\\<^bold>[P\<^bold>] # U); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P (\.head_strategy (M \<^bold>\ N)) (tl (\<^bold>\\<^bold>[P\<^bold>] # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \ \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P (\.resid (M \<^bold>\ N) (\.head_strategy (M \<^bold>\ N))) (tl (\<^bold>\\<^bold>[P\<^bold>] # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (\<^bold>\\<^bold>[P\<^bold>] # U))\ + \ ?P M (filter notIde (map \.un_App1 (\<^bold>\\<^bold>[P\<^bold>] # U))); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd (\<^bold>\\<^bold>[P\<^bold>] # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd (\<^bold>\\<^bold>[P\<^bold>] # U))\ + \ ?P N (filter notIde (map \.un_App2 (\<^bold>\\<^bold>[P\<^bold>] # U)))\ + \ ?P (M \<^bold>\ N) (\<^bold>\\<^bold>[P\<^bold>] # U)" + using * \.lambda.disc(18) by presburger + show "\M N P1 P2 U. \\.Ide (M \<^bold>\ N) + \ ?P (hd ((P1 \<^bold>\ P2) # U)) (tl ((P1 \<^bold>\ P2) # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd ((P1 \<^bold>\ P2) # U)); + \.contains_head_reduction (M \<^bold>\ N); + \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P (hd ((P1 \<^bold>\ P2) # U)) (tl((P1 \<^bold>\ P2) # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd ((P1 \<^bold>\ P2) # U)); + \.contains_head_reduction (M \<^bold>\ N); + \ \.Ide ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_redex (M \<^bold>\ N)) ((P1 \<^bold>\ P2) # U); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd ((P1 \<^bold>\ P2) # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd ((P1 \<^bold>\ P2) # U)); + \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P (\.head_strategy (M \<^bold>\ N)) (tl ((P1 \<^bold>\ P2) # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd ((P1 \<^bold>\ P2) # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \.contains_head_reduction (hd ((P1 \<^bold>\ P2) # U)); + \ \.Ide ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N))\ + \ ?P ((M \<^bold>\ N) \\ \.head_strategy (M \<^bold>\ N)) (tl ((P1 \<^bold>\ P2) # U)); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd ((P1 \<^bold>\ P2) # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd ((P1 \<^bold>\ P2) # U))\ + \ ?P M (filter notIde (map \.un_App1 ((P1 \<^bold>\ P2) # U))); + \\ \.Ide (M \<^bold>\ N); \.seq (M \<^bold>\ N) (hd ((P1 \<^bold>\ P2) # U)); + \ \.contains_head_reduction (M \<^bold>\ N); + \ \.contains_head_reduction (hd ((P1 \<^bold>\ P2) # U))\ + \ ?P N (filter notIde (map \.un_App2 ((P1 \<^bold>\ P2) # U)))\ + \ ?P (M \<^bold>\ N) ((P1 \<^bold>\ P2) # U)" + using * \.lambda.disc(19) by presburger + qed + + subsubsection "The Standardization Theorem" + + text \ + Using the function \standardize\, we can now prove the Standardization Theorem. + There is still a little bit more work to do, because we have to deal with various + cases in which the reduction path to be standardized is empty or consists + entirely of identities. + \ + + theorem standardization_theorem: + shows "Arr T \ Std (standardize T) \ (Ide T \ standardize T = []) \ + (\ Ide T \ cong (standardize T) T)" + proof (induct T) + show "Arr [] \ Std (standardize []) \ (Ide [] \ standardize [] = []) \ + (\ Ide [] \ cong (standardize []) [])" + by simp + fix t T + assume ind: "Arr T \ Std (standardize T) \ (Ide T \ standardize T = []) \ + (\ Ide T \ cong (standardize T) T)" + assume tT: "Arr (t # T)" + have t: "\.Arr t" + using tT Arr_imp_arr_hd by force + show "Std (standardize (t # T)) \ (Ide (t # T) \ standardize (t # T) = []) \ + (\ Ide (t # T) \ cong (standardize (t # T)) (t # T))" + proof (cases "T = []") + show "T = [] \ ?thesis" + using t tT Ide_iff_standard_development_empty Std_standard_development + cong_standard_development + by simp + assume 0: "T \ []" + hence T: "Arr T" + using tT + by (metis Arr_imp_Arr_tl list.sel(3)) + show ?thesis + proof (intro conjI) + show "Std (standardize (t # T))" + proof - + have 1: "\ Ide T \ seq [t] (standardize T)" + using t T ind 0 ide_char Con_implies_Arr(1) + apply (intro seqI\<^sub>\\<^sub>P) + apply simp + apply (metis Con_implies_Arr(1) Ide.simps(1) ide_char) + by (metis Src_hd_eqI Trg_last_Src_hd_eqI \T \ []\ append_Cons arrI\<^sub>P + arr_append_imp_seq list.distinct(1) self_append_conv2 tT) + show ?thesis + using T 1 ind Std_standard_development stdz_insert_correctness by auto + qed + show "Ide (t # T) \ standardize (t # T) = []" + using Ide_consE Ide_iff_standard_development_empty Ide_implies_Arr ind + \.Ide_implies_Arr \.ide_char + by (metis list.sel(1,3) standardize.simps(1-2) stdz_insert.simps(1)) + show "\ Ide (t # T) \ standardize (t # T) \<^sup>*\\<^sup>* t # T" + proof + assume 1: "\ Ide (t # T)" + show "standardize (t # T) \<^sup>*\\<^sup>* t # T" + proof (cases "\.Ide t") + assume t: "\.Ide t" + have 2: "\ Ide T" + using 1 t tT by fastforce + have "standardize (t # T) = stdz_insert t (standardize T)" + by simp + also have "... \<^sup>*\\<^sup>* t # T" + proof - + have 3: "Std (standardize T) \ standardize T \<^sup>*\\<^sup>* T" + using T 2 ind by blast + have "stdz_insert t (standardize T) = + stdz_insert (hd (standardize T)) (tl (standardize T))" + proof - + have "seq [t] (standardize T)" + using 0 2 tT ind + by (metis Arr.elims(2) Con_imp_eq_Srcs Con_implies_Arr(1) Ide.simps(1-2) + Ide_implies_Arr Trgs.simps(2) ide_char \.ide_char list.inject + seq_char seq_implies_Trgs_eq_Srcs t) + thus ?thesis + using t 3 stdz_insert_Ide_Std by blast + qed + also have "... \<^sup>*\\<^sup>* hd (standardize T) # tl (standardize T)" + proof - + have "\ Ide (standardize T)" + using 2 3 ide_backward_stable ide_char by blast + moreover have "tl (standardize T) \ [] \ + seq [hd (standardize T)] (tl (standardize T)) \ + Std (tl (standardize T))" + by (metis 3 Std_consE Std_imp_Arr append.left_neutral append_Cons + arr_append_imp_seq arr_char hd_Cons_tl list.discI tl_Nil) + ultimately show ?thesis + by (metis "2" Ide.simps(2) Resid.simps(1) Std_consE T cong_standard_development + ide_char ind \.ide_char list.exhaust_sel stdz_insert.simps(1) + stdz_insert_correctness) + qed + also have "hd (standardize T) # tl (standardize T) = standardize T" + by (metis 3 Arr.simps(1) Con_implies_Arr(2) Ide.simps(1) ide_char + list.exhaust_sel) + also have "standardize T \<^sup>*\\<^sup>* T" + using 3 by simp + also have "T \<^sup>*\\<^sup>* t # T" + using 0 t tT arr_append_imp_seq arr_char cong_cons_ideI(2) by simp + finally show ?thesis by blast + qed + thus ?thesis by auto + next + assume t: "\ \.Ide t" + show ?thesis + proof (cases "Ide T") + assume T: "Ide T" + have "standardize (t # T) = standard_development t" + using t T Ide_implies_Arr ind by simp + also have "... \<^sup>*\\<^sup>* [t]" + using t T tT cong_standard_development [of t] by blast + also have "[t] \<^sup>*\\<^sup>* [t] @ T" + using t T tT cong_append_ideI(4) [of "[t]" T] + by (simp add: 0 arrI\<^sub>P arr_append_imp_seq ide_char) + finally show ?thesis by auto + next + assume T: "\ Ide T" + have 1: "Std (standardize T) \ standardize T \<^sup>*\\<^sup>* T" + using T \Arr T\ ind by blast + have 2: "seq [t] (standardize T)" + by (metis 0 Arr.simps(2) Arr.simps(3) Con_imp_eq_Srcs Con_implies_Arr(2) + Ide.elims(3) Ide.simps(1) T Trgs.simps(2) ide_char ind + seq_char seq_implies_Trgs_eq_Srcs tT) + have "stdz_insert t (standardize T) \<^sup>*\\<^sup>* t # standardize T" + using t 1 2 stdz_insert_correctness [of t "standardize T"] by blast + also have "t # standardize T \<^sup>*\\<^sup>* t # T" + using 1 2 + by (meson Arr.simps(2) \.prfx_reflexive cong_cons seq_char) + finally show ?thesis by auto + qed + qed + qed + qed + qed + qed + + subsubsection "The Leftmost Reduction Theorem" + + text \ + In this section we prove the Leftmost Reduction Theorem, which states that + leftmost reduction is a normalizing strategy. + + We first show that if a standard reduction path reaches a normal form, + then the path must be the one produced by following the leftmost reduction strategy. + This is because, in a standard reduction path, once a leftmost redex is skipped, + all subsequent reductions occur ``to the right of it'', hence they are all non-leftmost + reductions that do not contract the skipped redex, which remains in the leftmost position. + + The Leftmost Reduction Theorem then follows from the Standardization Theorem. + If a term is normalizable, there is a reduction path from that term to a normal form. + By the Standardization Theorem we may as well assume that path is standard. + But a standard reduction path to a normal form is the path generated by following + the leftmost reduction strategy, hence leftmost reduction reaches a normal form after + a finite number of steps. + \ + + lemma sseq_reflects_leftmost_reduction: + assumes "\.sseq t u" and "\.is_leftmost_reduction u" + shows "\.is_leftmost_reduction t" + proof - + have *: "\u. u = \.leftmost_strategy (\.Src t) \\ t \ \ \.sseq t u" for t + proof (induct t) + show "\u. \ \.sseq \<^bold>\ u" + using \.sseq_imp_seq by blast + show "\x u. \ \.sseq \<^bold>\x\<^bold>\ u" + using \.elementary_reduction.simps(2) \.sseq_imp_elementary_reduction1 by blast + show "\t u. \\u. u = \.leftmost_strategy (\.Src t) \\ t \ \ \.sseq t u; + u = \.leftmost_strategy (\.Src \<^bold>\\<^bold>[t\<^bold>]) \\ \<^bold>\\<^bold>[t\<^bold>]\ + \ \ \.sseq \<^bold>\\<^bold>[t\<^bold>] u" + by auto + show "\t1 t2 u. \\u. u = \.leftmost_strategy (\.Src t1) \\ t1 \ \ \.sseq t1 u; + \u. u = \.leftmost_strategy (\.Src t2) \\ t2 \ \ \.sseq t2 u; + u = \.leftmost_strategy (\.Src (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) \\ (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)\ + \ \ \.sseq (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2) u" + apply simp + by (metis \.sseq_imp_elementary_reduction2 \.Coinitial_iff_Con \.Ide_Src + \.Ide_Subst \.elementary_reduction_not_ide \.ide_char \.resid_Ide_Arr) + show "\t1 t2. \\u. u = \.leftmost_strategy (\.Src t1) \\ t1 \ \ \.sseq t1 u; + \u. u = \.leftmost_strategy (\.Src t2) \\ t2 \ \ \.sseq t2 u; + u = \.leftmost_strategy (\.Src (\.App t1 t2)) \\ \.App t1 t2\ + \ \ \.sseq (\.App t1 t2) u" for u + apply (cases u) + apply simp_all + apply (metis \.elementary_reduction.simps(2) \.sseq_imp_elementary_reduction2) + apply (metis \.Src.simps(3) \.Src_resid \.Trg.simps(3) \.lambda.distinct(15) + \.lambda.distinct(3)) + proof - + show "\t1 t2 u1 u2. + \\ \.sseq t1 (\.leftmost_strategy (\.Src t1) \\ t1); + \ \.sseq t2 (\.leftmost_strategy (\.Src t2) \\ t2); + \<^bold>\\<^bold>[u1\<^bold>] \<^bold>\ u2 = \.leftmost_strategy (\.App (\.Src t1) (\.Src t2)) \\ \.App t1 t2; + u = \.leftmost_strategy (\.App (\.Src t1) (\.Src t2)) \\ \.App t1 t2\ + \ \ \.sseq (\.App t1 t2) + (\.leftmost_strategy (\.App (\.Src t1) (\.Src t2)) \\ \.App t1 t2)" + by (metis \.sseq_imp_elementary_reduction1 \.Arr.simps(5) \.Arr_resid_ind + \.Coinitial_iff_Con \.Ide.simps(5) \.Ide_iff_Src_self \.Src.simps(4) + \.Src_resid \.contains_head_reduction.simps(8) \.is_head_reduction_if + \.lambda.discI(3) \.lambda.distinct(7) + \.leftmost_strategy_selects_head_reduction \.resid_Arr_self + \.sseq_preserves_App_and_no_head_reduction) + show "\u1 u2. + \\ \.sseq t1 (\.leftmost_strategy (\.Src t1) \\ t1); + \ \.sseq t2 (\.leftmost_strategy (\.Src t2) \\ t2); + \.App u1 u2 = \.leftmost_strategy (\.App (\.Src t1) (\.Src t2)) \\ \.App t1 t2; + u = \.leftmost_strategy (\.App (\.Src t1) (\.Src t2)) \\ \.App t1 t2\ + \ \ \.sseq (\.App t1 t2) + (\.leftmost_strategy (\.App (\.Src t1) (\.Src t2)) \\ \.App t1 t2)" + for t1 t2 + apply (cases "\ \.Arr t1") + apply simp_all + apply (meson \.Arr.simps(4) \.seq_char \.sseq_imp_seq) + apply (cases "\ \.Arr t2") + apply simp_all + apply (meson \.Arr.simps(4) \.seq_char \.sseq_imp_seq) + using \.Arr_not_Nil + apply (cases t1) + apply simp_all + using \.NF_iff_has_no_redex \.has_redex_iff_not_Ide_leftmost_strategy + \.Ide_iff_Src_self \.Ide_iff_Trg_self + \.NF_def \.elementary_reduction_not_ide \.eq_Ide_are_cong + \.leftmost_strategy_is_reduction_strategy \.reduction_strategy_def + \.resid_Arr_Src + apply simp + apply (metis \.Arr.simps(4) \.Ide.simps(4) \.Ide_Trg \.Src.simps(4) + \.sseq_imp_elementary_reduction2) + by (metis \.Ide_Trg \.elementary_reduction_not_ide \.ide_char) + qed + qed + have "t \ \.leftmost_strategy (\.Src t) \ False" + proof - + assume 1: "t \ \.leftmost_strategy (\.Src t)" + have 2: "\ \.Ide (\.leftmost_strategy (\.Src t))" + by (meson assms(1) \.NF_def \.NF_iff_has_no_redex \.arr_char + \.elementary_reduction_is_arr \.elementary_reduction_not_ide + \.has_redex_iff_not_Ide_leftmost_strategy \.ide_char + \.sseq_imp_elementary_reduction1) + have "\.is_leftmost_reduction (\.leftmost_strategy (\.Src t) \\ t)" + proof - + have "\.is_leftmost_reduction (\.leftmost_strategy (\.Src t))" + by (metis assms(1) 2 \.Ide_Src \.Ide_iff_Src_self \.arr_char + \.elementary_reduction_is_arr \.elementary_reduction_leftmost_strategy + \.is_leftmost_reduction_def \.leftmost_strategy_is_reduction_strategy + \.reduction_strategy_def \.sseq_imp_elementary_reduction1) + moreover have 3: "\.elementary_reduction t" + using assms \.sseq_imp_elementary_reduction1 by simp + moreover have "\ \.is_leftmost_reduction t" + using 1 \.is_leftmost_reduction_def by auto + moreover have "\.coinitial (\.leftmost_strategy (\.Src t)) t" + using 3 \.leftmost_strategy_is_reduction_strategy \.reduction_strategy_def + \.Ide_Src \.elementary_reduction_is_arr + by force + ultimately show ?thesis + using 1 \.leftmost_reduction_preservation by blast + qed + moreover have "\.coinitial (\.leftmost_strategy (\.Src t) \\ t) u" + using assms(1) calculation \.Arr_not_Nil \.Src_resid \.elementary_reduction_is_arr + \.is_leftmost_reduction_def \.seq_char \.sseq_imp_seq + by force + moreover have "\v. \\.is_leftmost_reduction v; \.coinitial v u\ \ v = u" + by (metis \.arr_iff_has_source \.arr_resid_iff_con \.confluence assms(2) + \.Arr_not_Nil \.Coinitial_iff_Con \.is_leftmost_reduction_def \.sources_char\<^sub>\) + ultimately have "\.leftmost_strategy (\.Src t) \\ t = u" + by blast + thus ?thesis + using assms(1) * by blast + qed + thus ?thesis + using assms(1) \.is_leftmost_reduction_def \.sseq_imp_elementary_reduction1 by force + qed + + lemma elementary_reduction_to_NF_is_leftmost: + shows "\\.elementary_reduction t; \.NF (Trg [t])\ \ \.leftmost_strategy (\.Src t) = t" + proof (induct t) + show "\.leftmost_strategy (\.Src \<^bold>\) = \<^bold>\" + by simp + show "\x. \\.elementary_reduction \<^bold>\x\<^bold>\; \.NF (Trg [\<^bold>\x\<^bold>\])\ + \ \.leftmost_strategy (\.Src \<^bold>\x\<^bold>\) = \<^bold>\x\<^bold>\" + by auto + show "\t. \\\.elementary_reduction t; \.NF (Trg [t])\ + \ \.leftmost_strategy (\.Src t) = t; + \.elementary_reduction \<^bold>\\<^bold>[t\<^bold>]; \.NF (Trg [\<^bold>\\<^bold>[t\<^bold>]])\ + \ \.leftmost_strategy (\.Src \<^bold>\\<^bold>[t\<^bold>]) = \<^bold>\\<^bold>[t\<^bold>]" + using lambda_calculus.NF_Lam_iff lambda_calculus.elementary_reduction_is_arr by force + show "\t1 t2. \\\.elementary_reduction t1; \.NF (Trg [t1])\ + \ \.leftmost_strategy (\.Src t1) = t1; + \\.elementary_reduction t2; \.NF (Trg [t2])\ + \ \.leftmost_strategy (\.Src t2) = t2; + \.elementary_reduction (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2); \.NF (Trg [\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2])\ + \ \.leftmost_strategy (\.Src (\<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2)) = \<^bold>\\<^bold>[t1\<^bold>] \<^bold>\ t2" + apply simp + by (metis \.Ide_iff_Src_self \.Ide_implies_Arr) + fix t1 t2 + assume ind1: "\\.elementary_reduction t1; \.NF (Trg [t1])\ + \ \.leftmost_strategy (\.Src t1) = t1" + assume ind2: "\\.elementary_reduction t2; \.NF (Trg [t2])\ + \ \.leftmost_strategy (\.Src t2) = t2" + assume t: "\.elementary_reduction (\.App t1 t2)" + have t1: "\.Arr t1" + using t \.Arr.simps(4) \.elementary_reduction_is_arr by blast + have t2: "\.Arr t2" + using t \.Arr.simps(4) \.elementary_reduction_is_arr by blast + assume NF: "\.NF (Trg [\.App t1 t2])" + have 1: "\ \.is_Lam t1" + using NF \.NF_def + apply (cases t1) + apply simp_all + by (metis (mono_tags) \.Ide.simps(1) \.NF_App_iff \.Trg.simps(2-3) \.lambda.discI(2)) + have 2: "\.NF (\.Trg t1) \ \.NF (\.Trg t2)" + using NF t1 t2 1 \.NF_App_iff by simp + show "\.leftmost_strategy (\.Src (\.App t1 t2)) = \.App t1 t2" + using t t1 t2 1 2 ind1 ind2 + apply (cases t1) + apply simp_all + apply (metis \.Ide.simps(4) \.Ide_iff_Src_self \.Ide_iff_Trg_self + \.NF_iff_has_no_redex \.elementary_reduction_not_ide \.eq_Ide_are_cong + \.has_redex_iff_not_Ide_leftmost_strategy \.resid_Arr_Src t1) + using \.Ide_iff_Src_self by blast + qed + + lemma Std_path_to_NF_is_leftmost: + shows "\Std T; \.NF (Trg T)\ \ set T \ Collect \.is_leftmost_reduction" + proof - + have 1: "\t. \Std (t # T); \.NF (Trg (t # T))\ \ \.is_leftmost_reduction t" for T + proof (induct T) + show "\t. \Std [t]; \.NF (Trg [t])\ \ \.is_leftmost_reduction t" + using elementary_reduction_to_NF_is_leftmost \.is_leftmost_reduction_def by simp + fix t u T + assume ind: "\t. \Std (t # T); \.NF (Trg (t # T))\ \ \.is_leftmost_reduction t" + assume Std: "Std (t # u # T)" + assume "\.NF (Trg (t # u # T))" + show "\.is_leftmost_reduction t" + using Std \\.NF (Trg (t # u # T))\ ind sseq_reflects_leftmost_reduction by auto + qed + show "\Std T; \.NF (Trg T)\ \ set T \ Collect \.is_leftmost_reduction" + proof (induct T) + show "set [] \ Collect \.is_leftmost_reduction" + by simp + fix t T + assume ind: "\Std T; \.NF (Trg T)\ \ set T \ Collect \.is_leftmost_reduction" + assume Std: "Std (t # T)" and NF: "\.NF (Trg (t # T))" + show "set (t # T) \ Collect \.is_leftmost_reduction" + proof (cases "T = []") + show "T = [] \ ?thesis" + by (metis 1 NF Std \set [] \ Collect \.is_leftmost_reduction\ + mem_Collect_eq set_ConsD subset_code(1)) + assume T: "T \ []" + have "\.is_leftmost_reduction t" + using 1 NF Std elementary_reduction_to_NF_is_leftmost by blast + thus ?thesis + using T NF Std ind by auto + qed + qed + qed + + theorem leftmost_reduction_theorem: + shows "\.normalizing_strategy \.leftmost_strategy" + proof (unfold \.normalizing_strategy_def, intro allI impI) + fix a + assume a: "\.normalizable a" + show "\n. \.NF (\.reduce \.leftmost_strategy a n)" + proof (cases "\.NF a") + show "\.NF a \ ?thesis" + by (metis lambda_calculus.reduce.simps(1)) + assume 1: "\ \.NF a" + obtain T where T: "Arr T \ Src T = a \ \.NF (Trg T)" + using a \.normalizable_def red_iff by auto + have 2: "\ Ide T" + using T 1 Ide_imp_Src_eq_Trg by fastforce + obtain U where U: "Std U \ cong T U" + using T 2 standardization_theorem by blast + have 3: "set U \ Collect \.is_leftmost_reduction" + using 1 U Std_path_to_NF_is_leftmost + by (metis Con_Arr_self Resid_parallel Src_resid T cong_implies_coinitial) + have "\U. \Arr U; length U = n; set U \ Collect \.is_leftmost_reduction\ \ + U = apply_strategy \.leftmost_strategy (Src U) (length U)" for n + proof (induct n) + show "\U. \Arr U; length U = 0; set U \ Collect \.is_leftmost_reduction\ + \ U = apply_strategy \.leftmost_strategy (Src U) (length U)" + by simp + fix n U + assume ind: "\U. \Arr U; length U = n; set U \ Collect \.is_leftmost_reduction\ + \ U = apply_strategy \.leftmost_strategy (Src U) (length U)" + assume U: "Arr U" + assume n: "length U = Suc n" + assume set: "set U \ Collect \.is_leftmost_reduction" + show "U = apply_strategy \.leftmost_strategy (Src U) (length U)" + proof (cases "n = 0") + show "n = 0 \ ?thesis" + using U n 1 set \.is_leftmost_reduction_def + by (cases U) auto + assume 5: "n \ 0" + have 4: "hd U = \.leftmost_strategy (Src U)" + using n U set \.is_leftmost_reduction_def + by (cases U) auto + have 6: "tl U \ []" + using 4 5 n U + by (metis Suc_length_conv list.sel(3) list.size(3)) + show ?thesis + using 4 5 6 n U set ind [of "tl U"] + apply (cases n) + apply simp_all + by (metis (no_types, lifting) Arr_consE Nil_tl Nitpick.size_list_simp(2) + ind [of "tl U"] \.arr_char \.trg_char list.collapse list.set_sel(2) + old.nat.inject reduction_paths.apply_strategy.simps(2) subset_code(1)) + qed + qed + hence "U = apply_strategy \.leftmost_strategy (Src U) (length U)" + by (metis 3 Con_implies_Arr(1) Ide.simps(1) U ide_char) + moreover have "Src U = a" + using T U cong_implies_coinitial + by (metis Con_imp_eq_Srcs Con_implies_Arr(2) Ide.simps(1) Srcs_simp\<^sub>P\<^sub>W\<^sub>E empty_set + ex_un_Src ide_char list.set_intros(1) list.simps(15)) + ultimately have "Trg U = \.reduce \.leftmost_strategy a (length U)" + using reduce_eq_Trg_apply_strategy + by (metis Arr.simps(1) Con_implies_Arr(1) Ide.simps(1) U a ide_char + \.leftmost_strategy_is_reduction_strategy \.normalizable_def length_greater_0_conv) + thus ?thesis + by (metis Ide.simps(1) Ide_imp_Src_eq_Trg Src_resid T Trg_resid_sym U ide_char) + qed + qed + + end + +end + + diff --git a/thys/ResiduatedTransitionSystem/ROOT b/thys/ResiduatedTransitionSystem/ROOT new file mode 100644 --- /dev/null +++ b/thys/ResiduatedTransitionSystem/ROOT @@ -0,0 +1,9 @@ +chapter AFP + +session "ResiduatedTransitionSystem" (AFP) = "HOL-Library" + + options [timeout = 1500, names_unique = false] + theories + ResiduatedTransitionSystem LambdaCalculus + document_files + "root.bib" + "root.tex" diff --git a/thys/ResiduatedTransitionSystem/ResiduatedTransitionSystem.thy b/thys/ResiduatedTransitionSystem/ResiduatedTransitionSystem.thy new file mode 100644 --- /dev/null +++ b/thys/ResiduatedTransitionSystem/ResiduatedTransitionSystem.thy @@ -0,0 +1,8848 @@ +chapter "Residuated Transition Systems" + +theory ResiduatedTransitionSystem +imports Main +begin + + section "Basic Definitions and Properties" + + subsection "Partial Magmas" + + text \ + A \emph{partial magma} consists simply of a partial binary operation. + We represent the partiality by assuming the existence of a unique value \null\ + that behaves as a zero for the operation. + \ + + (* TODO: Possibly unify with Category3.partial_magma? *) + locale partial_magma = + fixes OP :: "'a \ 'a \ 'a" + assumes ex_un_null: "\!n. \t. OP n t = n \ OP t n = n" + begin + + definition null :: 'a + where "null = (THE n. \t. OP n t = n \ OP t n = n)" + + lemma null_eqI: + assumes "\t. OP n t = n \ OP t n = n" + shows "n = null" + using assms null_def ex_un_null the1_equality [of "\n. \t. OP n t = n \ OP t n = n"] + by auto + + lemma null_is_zero [simp]: + shows "OP null t = null" and "OP t null = null" + using null_def ex_un_null theI' [of "\n. \t. OP n t = n \ OP t n = n"] + by auto + + end + + subsection "Residuation" + + text \ + A \emph{residuation} is a partial binary operation subject to three axioms. + The first, \con_sym_ax\, states that the domain of a residuation is symmetric. + The second, \con_imp_arr_resid\, constrains the results of residuation either to be \null\, + which indicates inconsistency, or something that is self-consistent, which we will + define below to be an ``arrow''. + The ``cube axiom'', \cube_ax\, states that if \v\ can be transported by residuation + around one side of the ``commuting square'' formed by \t\ and \u \ t\, then it can also + be transported around the other side, formed by \u\ and \t \ u\, with the same result. + \ + + type_synonym 'a resid = "'a \ 'a \ 'a" + + locale residuation = partial_magma resid + for resid :: "'a resid" (infix "\\" 70) + + assumes con_sym_ax: "t \\ u \ null \ u \\ t \ null" + and con_imp_arr_resid: "t \\ u \ null \ (t \\ u) \\ (t \\ u) \ null" + and cube_ax: "(v \\ t) \\ (u \\ t) \ null \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + begin + + text \ + The axiom \cube_ax\ is equivalent to the following unconditional form. + The locale assumptions use the weaker form to avoid having to treat + the case \(v \ t) \ (u \ t) = null\ specially for every interpretation. + \ + + lemma cube: + shows "(v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + using cube_ax by metis + + text \ + We regard \t\ and \u\ as \emph{consistent} if the residuation \t \ u\ is defined. + It is convenient to make this a definition, with associated notation. + \ + + definition con (infix "\" 50) + where "t \ u \ t \\ u \ null" + + lemma conI [intro]: + assumes "t \\ u \ null" + shows "t \ u" + using assms con_def by blast + + lemma conE [elim]: + assumes "t \ u" + and "t \\ u \ null \ T" + shows T + using assms con_def by simp + + lemma con_sym: + assumes "t \ u" + shows "u \ t" + using assms con_def con_sym_ax by blast + + text \ + We call \t\ an \emph{arrow} if it is self-consistent. + \ + + definition arr + where "arr t \ t \ t" + + lemma arrI [intro]: + assumes "t \ t" + shows "arr t" + using assms arr_def by simp + + lemma arrE [elim]: + assumes "arr t" + and "t \ t \ T" + shows T + using assms arr_def by simp + + lemma not_arr_null [simp]: + shows "\ arr null" + by (auto simp add: con_def) + + lemma con_implies_arr: + assumes "t \ u" + shows "arr t" and "arr u" + using assms + by (metis arrI con_def con_imp_arr_resid cube null_is_zero(2))+ + + lemma arr_resid [simp]: + assumes "t \ u" + shows "arr (t \\ u)" + using assms con_imp_arr_resid by blast + + lemma arr_resid_iff_con: + shows "arr (t \\ u) \ t \ u" + by auto + + text \ + The residuation of an arrow along itself is the \emph{canonical target} of the arrow. + \ + + definition trg + where "trg t \ t \\ t" + + lemma resid_arr_self: + shows "t \\ t = trg t" + using trg_def by auto + + text \ + An \emph{identity} is an arrow that is its own target. + \ + + definition ide + where "ide a \ a \ a \ a \\ a = a" + + lemma ideI [intro]: + assumes "a \ a" and "a \\ a = a" + shows "ide a" + using assms ide_def by auto + + lemma ideE [elim]: + assumes "ide a" + and "\a \ a; a \\ a = a\ \ T" + shows T + using assms ide_def by blast + + lemma ide_implies_arr [simp]: + assumes "ide a" + shows "arr a" + using assms by blast + + end + + subsection "Residuated Transition System" + + text \ + A \emph{residuated transition system} consists of a residuation subject to + additional axioms that concern the relationship between identities and residuation. + These axioms make it possible to sensibly associate with each arrow certain nonempty + sets of identities called the \emph{sources} and \emph{targets} of the arrow. + Axiom \ide_trg\ states that the canonical target \trg t\ of an arrow \t\ is an identity. + Axiom \resid_arr_ide\ states that identities are right units for residuation, + when it is defined. + Axiom \resid_ide_arr\ states that the residuation of an identity along an arrow is + again an identity, assuming that the residuation is defined. + Axiom \con_imp_coinitial_ax\ states that if arrows \t\ and \u\ are consistent, + then there is an identity that is consistent with both of them (\emph{i.e.}~they + have a common source). + Axiom \con_target\ states that an identity of the form \t \ u\ + (which may be regarded as a ``target'' of \u\) is consistent with any other + arrow \v \ u\ obtained by residuation along \u\. + We note that replacing the premise \ide (t \ u)\ in this axiom by either \arr (t \ u)\ + or \t \ u\ would result in a strictly stronger statement. + \ + + locale rts = residuation + + assumes ide_trg [simp]: "arr t \ ide (trg t)" + and resid_arr_ide: "\ide a; t \ a\ \ t \\ a = t" + and resid_ide_arr [simp]: "\ide a; a \ t\ \ ide (a \\ t)" + and con_imp_coinitial_ax: "t \ u \ \a. ide a \ a \ t \ a \ u" + and con_target: "\ide (t \\ u); u \ v\ \ t \\ u \ v \\ u" + begin + + text \ + We define the \emph{sources} of an arrow \t\ to be the identities that + are consistent with \t\. + \ + + definition sources + where "sources t = {a. ide a \ t \ a}" + + text \ + We define the \emph{targets} of an arrow \t\ to be the identities that + are consistent with the canonical target \trg t\. + \ + + definition targets + where "targets t = {b. ide b \ trg t \ b}" + + lemma in_sourcesI [intro, simp]: + assumes "ide a" and "t \ a" + shows "a \ sources t" + using assms sources_def by simp + + lemma in_sourcesE [elim]: + assumes "a \ sources t" + and "\ide a; t \ a\ \ T" + shows T + using assms sources_def by auto + + lemma in_targetsI [intro, simp]: + assumes "ide b" and "trg t \ b" + shows "b \ targets t" + using assms targets_def resid_arr_self by simp + + lemma in_targetsE [elim]: + assumes "b \ targets t" + and "\ide b; trg t \ b\ \ T" + shows T + using assms targets_def resid_arr_self by force + + lemma trg_in_targets: + assumes "arr t" + shows "trg t \ targets t" + using assms + by (meson ideE ide_trg in_targetsI) + + lemma source_is_ide: + assumes "a \ sources t" + shows "ide a" + using assms by blast + + lemma target_is_ide: + assumes "a \ targets t" + shows "ide a" + using assms by blast + + text \ + Consistent arrows have a common source. + \ + + lemma con_imp_common_source: + assumes "t \ u" + shows "sources t \ sources u \ {}" + using assms + by (meson disjoint_iff in_sourcesI con_imp_coinitial_ax con_sym) + + text \ + Arrows are characterized by the property of having a nonempty set of sources, + or equivalently, by that of having a nonempty set of targets. + \ + + lemma arr_iff_has_source: + shows "arr t \ sources t \ {}" + using con_imp_common_source con_implies_arr(1) sources_def by blast + + lemma arr_iff_has_target: + shows "arr t \ targets t \ {}" + using trg_def trg_in_targets by fastforce + + text \ + The residuation of a source of an arrow along that arrow gives a target + of the same arrow. + However, it is \emph{not} true that every target of an arrow \t\ is of the + form \u \ t\ for some \u\ with \t \ u\. + \ + + lemma resid_source_in_targets: + assumes "a \ sources t" + shows "a \\ t \ targets t" + by (metis arr_resid assms con_target con_sym resid_arr_ide ide_trg + in_sourcesE resid_ide_arr in_targetsI resid_arr_self) + + text \ + Residuation along an identity reflects identities. + \ + + lemma ide_backward_stable: + assumes "ide a" and "ide (t \\ a)" + shows "ide t" + by (metis assms ideE resid_arr_ide arr_resid_iff_con) + + lemma resid_reflects_con: + assumes "t \ v" and "u \ v" and "t \\ v \ u \\ v" + shows "t \ u" + using assms cube + by (elim conE) auto + + lemma con_transitive_on_ide: + assumes "ide a" and "ide b" and "ide c" + shows "\a \ b; b \ c\ \ a \ c" + using assms + by (metis resid_arr_ide con_target con_sym) + + lemma sources_are_con: + assumes "a \ sources t" and "a' \ sources t" + shows "a \ a'" + using assms + by (metis (no_types, lifting) CollectD con_target con_sym resid_ide_arr + sources_def resid_reflects_con) + + lemma sources_con_closed: + assumes "a \ sources t" and "ide a'" and "a \ a'" + shows "a' \ sources t" + using assms + by (metis (no_types, lifting) con_target con_sym resid_arr_ide + mem_Collect_eq sources_def) + + lemma sources_eqI: + assumes "sources t \ sources t' \ {}" + shows "sources t = sources t'" + using assms sources_def sources_are_con sources_con_closed by blast + + lemma targets_are_con: + assumes "b \ targets t" and "b' \ targets t" + shows "b \ b'" + using assms sources_are_con sources_def targets_def by blast + + lemma targets_con_closed: + assumes "b \ targets t" and "ide b'" and "b \ b'" + shows "b' \ targets t" + using assms sources_con_closed sources_def targets_def by blast + + lemma targets_eqI: + assumes "targets t \ targets t' \ {}" + shows "targets t = targets t'" + using assms targets_def targets_are_con targets_con_closed by blast + + text \ + Arrows are \emph{coinitial} if they have a common source, and \emph{coterminal} + if they have a common target. + \ + + definition coinitial + where "coinitial t u \ sources t \ sources u \ {}" + + definition coterminal + where "coterminal t u \ targets t \ targets u \ {}" + + lemma coinitialI [intro]: + assumes "arr t" and "sources t = sources u" + shows "coinitial t u" + using assms coinitial_def arr_iff_has_source by simp + + lemma coinitialE [elim]: + assumes "coinitial t u" + and "\arr t; arr u; sources t = sources u\ \ T" + shows T + using assms coinitial_def sources_eqI arr_iff_has_source by auto + + lemma con_imp_coinitial: + assumes "t \ u" + shows "coinitial t u" + using assms + by (simp add: coinitial_def con_imp_common_source) + + lemma coinitial_iff: + shows "coinitial t t' \ arr t \ arr t' \ sources t = sources t'" + by (metis arr_iff_has_source coinitial_def inf_idem sources_eqI) + + lemma coterminal_iff: + shows "coterminal t t' \ arr t \ arr t' \ targets t = targets t'" + by (metis arr_iff_has_target coterminal_def inf_idem targets_eqI) + + lemma coterminal_iff_con_trg: + shows "coterminal t u \ trg t \ trg u" + by (metis coinitial_iff con_imp_coinitial coterminal_iff in_targetsE trg_in_targets + resid_arr_self arr_resid_iff_con sources_def targets_def) + + lemma coterminalI [intro]: + assumes "arr t" and "targets t = targets u" + shows "coterminal t u" + using assms coterminal_iff arr_iff_has_target by auto + + lemma coterminalE [elim]: + assumes "coterminal t u" + and "\arr t; arr u; targets t = targets u\ \ T" + shows T + using assms coterminal_iff by auto + + lemma sources_resid [simp]: + assumes "t \ u" + shows "sources (t \\ u) = targets u" + unfolding targets_def trg_def + using assms conI conE + by (metis con_imp_arr_resid assms coinitial_iff con_imp_coinitial + cube ex_un_null sources_def) + + lemma targets_resid_sym: + assumes "t \ u" + shows "targets (t \\ u) = targets (u \\ t)" + using assms + apply (intro targets_eqI) + by (metis (no_types, opaque_lifting) assms cube inf_idem arr_iff_has_target arr_def + arr_resid_iff_con sources_resid) + + text \ + Arrows \t\ and \u\ are \emph{sequential} if the set of targets of \t\ equals + the set of sources of \u\. + \ + + definition seq + where "seq t u \ arr t \ arr u \ targets t = sources u" + + lemma seqI [intro]: + assumes "arr t" and "arr u" and "targets t = sources u" + shows "seq t u" + using assms seq_def by auto + + lemma seqE [elim]: + assumes "seq t u" + and "\arr t; arr u; targets t = sources u\ \ T" + shows T + using assms seq_def by blast + + subsubsection "Congruence of Transitions" + + text \ + Residuation induces a preorder \\\ on transitions, defined by \t \ u\ if and only if + \t \ u\ is an identity. + \ + + abbreviation prfx (infix "\" 50) + where "t \ u \ ide (t \\ u)" + + lemma prfx_implies_con: + assumes "t \ u" + shows "t \ u" + using assms arr_resid_iff_con by blast + + lemma prfx_reflexive: + assumes "arr t" + shows "t \ t" + by (simp add: assms resid_arr_self) + + lemma prfx_transitive [trans]: + assumes "t \ u" and "u \ v" + shows "t \ v" + using assms con_target resid_ide_arr ide_backward_stable cube conI + by metis + + text \ + The equivalence \\\ associated with \\\ is substitutive with respect to residuation. + \ + + abbreviation cong (infix "\" 50) + where "t \ u \ t \ u \ u \ t" + + lemma cong_reflexive: + assumes "arr t" + shows "t \ t" + using assms prfx_reflexive by simp + + lemma cong_symmetric: + assumes "t \ u" + shows "u \ t" + using assms by simp + + lemma cong_transitive [trans]: + assumes "t \ u" and "u \ v" + shows "t \ v" + using assms prfx_transitive by auto + + lemma cong_subst_left: + assumes "t \ t'" and "t \ u" + shows "t' \ u" and "t \\ u \ t' \\ u" + apply (meson assms con_sym con_target prfx_implies_con resid_reflects_con) + by (metis assms con_sym con_target cube prfx_implies_con resid_ide_arr resid_reflects_con) + + lemma cong_subst_right: + assumes "u \ u'" and "t \ u" + shows "t \ u'" and "t \\ u \ t \\ u'" + proof - + have 1: "t \ u' \ t \\ u' \ u \\ u' \ + (t \\ u) \\ (u' \\ u) = (t \\ u') \\ (u \\ u')" + using assms cube con_sym con_target cong_subst_left(1) by meson + show "t \ u'" + using 1 by simp + show "t \\ u \ t \\ u'" + by (metis 1 arr_resid_iff_con assms(1) cong_reflexive resid_arr_ide) + qed + + lemma cong_implies_coinitial: + assumes "u \ u'" + shows "coinitial u u'" + using assms con_imp_coinitial prfx_implies_con by simp + + lemma cong_implies_coterminal: + assumes "u \ u'" + shows "coterminal u u'" + using assms + by (metis con_implies_arr(1) coterminalI ideE prfx_implies_con sources_resid + targets_resid_sym) + + lemma ide_imp_con_iff_cong: + assumes "ide t" and "ide u" + shows "t \ u \ t \ u" + using assms + by (metis con_sym resid_ide_arr prfx_implies_con) + + lemma sources_are_cong: + assumes "a \ sources t" and "a' \ sources t" + shows "a \ a'" + using assms sources_are_con + by (metis CollectD ide_imp_con_iff_cong sources_def) + + lemma sources_cong_closed: + assumes "a \ sources t" and "a \ a'" + shows "a' \ sources t" + using assms sources_def + by (meson in_sourcesE in_sourcesI cong_subst_right(1) ide_backward_stable) + + lemma targets_are_cong: + assumes "b \ targets t" and "b' \ targets t" + shows "b \ b'" + using assms(1-2) sources_are_cong sources_def targets_def by blast + + lemma targets_cong_closed: + assumes "b \ targets t" and "b \ b'" + shows "b' \ targets t" + using assms targets_def sources_cong_closed sources_def by blast + + lemma targets_char: + shows "targets t = {b. arr t \ t \\ t \ b}" + unfolding targets_def + by (metis (no_types, lifting) con_def con_implies_arr(2) con_sym cong_reflexive + ide_def resid_arr_ide trg_def) + + lemma coinitial_ide_are_cong: + assumes "ide a" and "ide a'" and "coinitial a a'" + shows "a \ a'" + using assms coinitial_def + by (metis ideE in_sourcesI coinitialE sources_are_cong) + + lemma cong_respects_seq: + assumes "seq t u" and "cong t t'" and "cong u u'" + shows "seq t' u'" + by (metis assms coterminalE rts.coinitialE rts.cong_implies_coinitial + rts.cong_implies_coterminal rts_axioms seqE seqI) + + end + + subsection "Weakly Extensional RTS" + + text \ + A \emph{weakly extensional} RTS is an RTS that satisfies the additional condition that + identity arrows have trivial congruence classes. This axiom has a number of useful + consequences, including that each arrow has a unique source and target. + \ + + locale weakly_extensional_rts = rts + + assumes weak_extensionality: "\t \ u; ide t; ide u\ \ t = u" + begin + + lemma con_ide_are_eq: + assumes "ide a" and "ide a'" and "a \ a'" + shows "a = a'" + using assms ide_imp_con_iff_cong weak_extensionality by blast + + lemma coinitial_ide_are_eq: + assumes "ide a" and "ide a'" and "coinitial a a'" + shows "a = a'" + using assms coinitial_def con_ide_are_eq by blast + + lemma arr_has_un_source: + assumes "arr t" + shows "\!a. a \ sources t" + using assms + by (meson arr_iff_has_source con_ide_are_eq ex_in_conv in_sourcesE sources_are_con) + + lemma arr_has_un_target: + assumes "arr t" + shows "\!b. b \ targets t" + using assms + by (metis arrE arr_has_un_source arr_resid sources_resid) + + definition src + where "src t \ if arr t then THE a. a \ sources t else null" + + lemma src_in_sources: + assumes "arr t" + shows "src t \ sources t" + using assms src_def arr_has_un_source + the1I2 [of "\a. a \ sources t" "\a. a \ sources t"] + by simp + + lemma src_eqI: + assumes "ide a" and "a \ t" + shows "src t = a" + using assms src_in_sources + by (metis arr_has_un_source resid_arr_ide in_sourcesI arr_resid_iff_con con_sym) + + lemma sources_char: + shows "sources t = {a. arr t \ src t = a}" + using src_in_sources arr_has_un_source arr_iff_has_source by auto + + lemma targets_char\<^sub>W\<^sub>E: + shows "targets t = {b. arr t \ trg t = b}" + using trg_in_targets arr_has_un_target arr_iff_has_target by auto + + lemma arr_src_iff_arr [iff]: + shows "arr (src t) \ arr t" + by (metis arrI conE null_is_zero(2) sources_are_con arrE src_def src_in_sources) + + lemma arr_trg_iff_arr [iff]: + shows "arr (trg t) \ arr t" + by (metis arrI arrE arr_resid_iff_con resid_arr_self) + + lemma con_imp_eq_src: + assumes "t \ u" + shows "src t = src u" + using assms + by (metis con_imp_coinitial_ax src_eqI) + + lemma src_resid [simp]: + assumes "t \ u" + shows "src (t \\ u) = trg u" + using assms + by (metis arr_resid_iff_con con_implies_arr(2) arr_has_un_source trg_in_targets + sources_resid src_in_sources) + + lemma trg_resid_sym: + assumes "t \ u" + shows "trg (t \\ u) = trg (u \\ t)" + using assms + by (metis arr_has_un_target arr_resid con_sym targets_resid_sym trg_in_targets) + + lemma apex_sym: + shows "trg (t \\ u) = trg (u \\ t)" + using trg_resid_sym con_def by metis + + lemma seqI\<^sub>W\<^sub>E [intro, simp]: + assumes "arr u" and "arr t" and "trg t = src u" + shows "seq t u" + using assms + by (metis (mono_tags, lifting) arrE in_sourcesE resid_arr_ide sources_resid + resid_arr_self seqI sources_are_con src_in_sources) + + lemma seqE\<^sub>W\<^sub>E [elim]: + assumes "seq t u" + and "\arr u; arr t; trg t = src u\ \ T" + shows T + using assms + by (metis arr_has_un_source seq_def src_in_sources trg_in_targets) + + lemma coinitial_iff\<^sub>W\<^sub>E: + shows "coinitial t u \ arr t \ arr u \ src t = src u" + by (metis arr_has_un_source coinitial_def coinitial_iff disjoint_iff_not_equal + src_in_sources) + + lemma coterminal_iff\<^sub>W\<^sub>E: + shows "coterminal t u \ arr t \ arr u \ trg t = trg u" + by (metis arr_has_un_target coterminal_iff_con_trg coterminal_iff trg_in_targets) + + lemma coinitialI\<^sub>W\<^sub>E [intro]: + assumes "arr t" and "src t = src u" + shows "coinitial t u" + using assms coinitial_iff\<^sub>W\<^sub>E by (metis arr_src_iff_arr) + + lemma coinitialE\<^sub>W\<^sub>E [elim]: + assumes "coinitial t u" + and "\arr t; arr u; src t = src u\ \ T" + shows T + using assms coinitial_iff\<^sub>W\<^sub>E by blast + + lemma coterminalI\<^sub>W\<^sub>E [intro]: + assumes "arr t" and "trg t = trg u" + shows "coterminal t u" + using assms coterminal_iff\<^sub>W\<^sub>E by (metis arr_trg_iff_arr) + + lemma coterminalE\<^sub>W\<^sub>E [elim]: + assumes "coterminal t u" + and "\arr t; arr u; trg t = trg u\ \ T" + shows T + using assms coterminal_iff\<^sub>W\<^sub>E by blast + + lemma ide_src [simp]: + assumes "arr t" + shows "ide (src t)" + using assms + by (metis arrE con_imp_coinitial_ax src_eqI) + + lemma src_ide [simp]: + assumes "ide a" + shows "src a = a" + using arrI assms src_eqI by blast + + lemma trg_ide [simp]: + assumes "ide a" + shows "trg a = a" + using assms resid_arr_self by force + + lemma ide_iff_src_self: + assumes "arr a" + shows "ide a \ src a = a" + using assms by (metis ide_src src_ide) + + lemma ide_iff_trg_self: + assumes "arr a" + shows "ide a \ trg a = a" + using assms ide_def resid_arr_self by auto + + lemma src_src [simp]: + shows "src (src t) = src t" + using ide_src src_def src_ide by auto + + lemma trg_trg [simp]: + shows "trg (trg t) = trg t" + by (metis con_def cong_reflexive ide_def null_is_zero(2) resid_arr_self + residuation.con_implies_arr(1) residuation_axioms) + + lemma src_trg [simp]: + shows "src (trg t) = trg t" + by (metis con_def not_arr_null src_def src_resid trg_def) + + lemma trg_src [simp]: + shows "trg (src t) = src t" + by (metis ide_src null_is_zero(2) resid_arr_self src_def trg_ide) + + lemma resid_ide: + assumes "ide a" and "coinitial a t" + shows (* [simp]: *) "t \\ a = t" and "a \\ t = trg t" + using assms resid_arr_ide apply blast + using assms + by (metis con_def con_sym_ax ideE in_sourcesE in_sourcesI resid_ide_arr + coinitialE src_ide src_resid) + + end + + subsection "Extensional RTS" + + text \ + An \emph{extensional} RTS is an RTS in which all arrows have trivial congruence classes; + that is, congruent arrows are equal. + \ + + locale extensional_rts = rts + + assumes extensional: "t \ u \ t = u" + begin + + sublocale weakly_extensional_rts + using extensional + by unfold_locales auto + + lemma cong_char: + shows "t \ u \ arr t \ t = u" + by (metis arrI cong_reflexive prfx_implies_con extensional) + + end + + subsection "Composites of Transitions" + + text \ + Residuation can be used to define a notion of composite of transitions. + Composites are not unique, but they are unique up to congruence. + \ + + context rts + begin + + definition composite_of + where "composite_of u t v \ u \ v \ v \\ u \ t" + + lemma composite_ofI [intro]: + assumes "u \ v" and "v \\ u \ t" + shows "composite_of u t v" + using assms composite_of_def by blast + + lemma composite_ofE [elim]: + assumes "composite_of u t v" + and "\u \ v; v \\ u \ t\ \ T" + shows T + using assms composite_of_def by auto + + lemma arr_composite_of: + assumes "composite_of u t v" + shows "arr v" + using assms + by (meson composite_of_def con_implies_arr(2) prfx_implies_con) + + lemma composite_of_unq_upto_cong: + assumes "composite_of u t v" and "composite_of u t v'" + shows "v \ v'" + using assms cube ide_backward_stable prfx_transitive + by (elim composite_ofE) metis + + lemma composite_of_ide_arr: + assumes "ide a" + shows "composite_of a t t \ t \ a" + using assms + by (metis composite_of_def con_implies_arr(1) con_sym resid_arr_ide resid_ide_arr + prfx_implies_con prfx_reflexive) + + lemma composite_of_arr_ide: + assumes "ide b" + shows "composite_of t b t \ t \\ t \ b" + using assms + by (metis arr_resid_iff_con composite_of_def ide_imp_con_iff_cong con_implies_arr(1) + prfx_implies_con prfx_reflexive) + + lemma composite_of_source_arr: + assumes "arr t" and "a \ sources t" + shows "composite_of a t t" + using assms composite_of_ide_arr sources_def by auto + + lemma composite_of_arr_target: + assumes "arr t" and "b \ targets t" + shows "composite_of t b t" + by (metis arrE assms composite_of_arr_ide in_sourcesE sources_resid) + + lemma composite_of_ide_self: + assumes "ide a" + shows "composite_of a a a" + using assms composite_of_ide_arr by blast + + lemma con_prfx_composite_of: + assumes "composite_of t u w" + shows "t \ w" and "w \ v \ t \ v" + using assms apply force + using assms composite_of_def con_target prfx_implies_con + resid_reflects_con con_sym + by meson + + lemma sources_composite_of: + assumes "composite_of u t v" + shows "sources v = sources u" + using assms + by (meson arr_resid_iff_con composite_of_def con_imp_coinitial cong_implies_coinitial + coinitial_iff) + + lemma targets_composite_of: + assumes "composite_of u t v" + shows "targets v = targets t" + proof - + have "targets t = targets (v \\ u)" + using assms composite_of_def + by (meson cong_implies_coterminal coterminal_iff) + also have "... = targets (u \\ v)" + using assms targets_resid_sym con_prfx_composite_of by metis + also have "... = targets v" + using assms composite_of_def + by (metis prfx_implies_con sources_resid ideE) + finally show ?thesis by auto + qed + + lemma resid_composite_of: + assumes "composite_of t u w" and "w \ v" + shows "v \\ t \ w \\ t" + and "v \\ t \ u" + and "v \\ w \ (v \\ t) \\ u" + and "composite_of (t \\ v) (u \\ (v \\ t)) (w \\ v)" + proof - + show 0: "v \\ t \ w \\ t" + using assms con_def + by (metis con_target composite_ofE conE con_sym cube) + show 1: "v \\ w \ (v \\ t) \\ u" + proof - + have "v \\ w = (v \\ w) \\ (t \\ w)" + using assms composite_of_def + by (metis (no_types, opaque_lifting) con_target con_sym resid_arr_ide) + also have "... = (v \\ t) \\ (w \\ t)" + using assms cube by metis + also have "... \ (v \\ t) \\ u" + using assms 0 cong_subst_right(2) [of "w \\ t" u "v \\ t"] by blast + finally show ?thesis by blast + qed + show 2: "v \\ t \ u" + using assms 1 by force + show "composite_of (t \\ v) (u \\ (v \\ t)) (w \\ v)" + proof (unfold composite_of_def, intro conjI) + show "t \\ v \ w \\ v" + using assms cube con_target composite_of_def resid_ide_arr by metis + show "(w \\ v) \\ (t \\ v) \ u \\ (v \\ t)" + by (metis assms(1) 2 composite_ofE con_sym cong_subst_left(2) cube) + thus "u \\ (v \\ t) \ (w \\ v) \\ (t \\ v)" + using assms + by (metis composite_of_def con_implies_arr(2) cong_subst_left(2) + prfx_implies_con arr_resid_iff_con cube) + qed + qed + + lemma con_composite_of_iff: + assumes "composite_of t u v" + shows "w \ v \ w \\ t \ u" + by (meson arr_resid_iff_con assms composite_ofE con_def con_implies_arr(1) + con_sym_ax cong_subst_right(1) resid_composite_of(2) resid_reflects_con) + + definition composable + where "composable t u \ \v. composite_of t u v" + + lemma composableD [dest]: + assumes "composable t u" + shows "arr t" and "arr u" and "targets t = sources u" + using assms arr_composite_of arr_iff_has_source composable_def sources_composite_of + arr_composite_of arr_iff_has_target composable_def targets_composite_of + apply auto[2] + by (metis assms composable_def composite_ofE con_prfx_composite_of(1) con_sym + cong_implies_coinitial coinitial_iff sources_resid) + + lemma composable_imp_seq: + assumes "composable t u" + shows "seq t u" + using assms by blast + + lemma bounded_imp_con: + assumes "composite_of t u v" and "composite_of t' u' v" + shows "con t t'" + by (meson assms composite_of_def con_prfx_composite_of prfx_implies_con + arr_resid_iff_con con_implies_arr(2)) + + lemma composite_of_cancel_left: + assumes "composite_of t u v" and "composite_of t u' v" + shows "u \ u'" + using assms composite_of_def cong_transitive by blast + + end + + subsubsection "RTS with Composites" + + locale rts_with_composites = rts + + assumes has_composites: "seq t u \ composable t u" + begin + + lemma composable_iff_seq: + shows "composable g f \ seq g f" + using composable_imp_seq has_composites by blast + + lemma obtains_composite_of: + assumes "seq g f" + obtains h where "composite_of g f h" + using assms has_composites composable_def by blast + + lemma diamond_commutes_upto_cong: + assumes "composite_of t (u \\ t) v" and "composite_of u (t \\ u) v'" + shows "v \ v'" + using assms cube ide_backward_stable prfx_transitive + by (elim composite_ofE) metis + + end + + subsection "Joins of Transitions" + + context rts + begin + + text \ + Transition \v\ is a \emph{join} of \u\ and \v\ when \v\ is the diagonal of the square + formed by \u\, \v\, and their residuals. As was the case for composites, + joins in an RTS are not unique, but they are unique up to congruence. + \ + + definition join_of + where "join_of t u v \ composite_of t (u \\ t) v \ composite_of u (t \\ u) v" + + lemma join_ofI [intro]: + assumes "composite_of t (u \\ t) v" and "composite_of u (t \\ u) v" + shows "join_of t u v" + using assms join_of_def by simp + + lemma join_ofE [elim]: + assumes "join_of t u v" + and "\composite_of t (u \\ t) v; composite_of u (t \\ u) v\ \ T" + shows T + using assms join_of_def by simp + + definition joinable + where "joinable t u \ \v. join_of t u v" + + lemma joinable_implies_con: + assumes "joinable t u" + shows "t \ u" + by (meson assms bounded_imp_con join_of_def joinable_def) + + lemma joinable_implies_coinitial: + assumes "joinable t u" + shows "coinitial t u" + using assms + by (simp add: con_imp_coinitial joinable_implies_con) + + lemma join_of_un_upto_cong: + assumes "join_of t u v" and "join_of t u v'" + shows "v \ v'" + using assms join_of_def composite_of_unq_upto_cong by auto + + lemma join_of_symmetric: + assumes "join_of t u v" + shows "join_of u t v" + using assms join_of_def by simp + + lemma join_of_arr_self: + assumes "arr t" + shows "join_of t t t" + by (meson assms composite_of_arr_ide ideE join_of_def prfx_reflexive) + + lemma join_of_arr_src: + assumes "arr t" and "a \ sources t" + shows "join_of a t t" and "join_of t a t" + proof - + show "join_of a t t" + by (meson assms composite_of_arr_target composite_of_def composite_of_source_arr join_of_def + prfx_transitive resid_source_in_targets) + thus "join_of t a t" + using join_of_symmetric by blast + qed + + lemma sources_join_of: + assumes "join_of t u v" + shows "sources t = sources v" and "sources u = sources v" + using assms join_of_def sources_composite_of by blast+ + + lemma targets_join_of: + assumes "join_of t u v" + shows "targets (t \\ u) = targets v" and "targets (u \\ t) = targets v" + using assms join_of_def targets_composite_of by blast+ + + lemma join_of_resid: + assumes "join_of t u w" and "con v w" + shows "join_of (t \\ v) (u \\ v) (w \\ v)" + using assms con_sym cube join_of_def resid_composite_of(4) by fastforce + + lemma con_with_join_of_iff: + assumes "join_of t u w" + shows "u \ v \ v \\ u \ t \\ u \ w \ v" + and "w \ v \ t \ v \ v \\ t \ u \\ t" + proof - + have *: "t \ v \ v \\ t \ u \\ t \ u \ v \ v \\ u \ t \\ u" + by (metis arr_resid_iff_con con_implies_arr(1) con_sym cube) + show "u \ v \ v \\ u \ t \\ u \ w \ v" + by (meson assms con_composite_of_iff con_sym join_of_def) + show "w \ v \ t \ v \ v \\ t \ u \\ t" + by (meson assms con_prfx_composite_of join_of_def resid_composite_of(2)) + qed + + end + + subsubsection "RTS with Joins" + + locale rts_with_joins = rts + + assumes has_joins: "t \ u \ joinable t u" + + subsection "Joins and Composites in a Weakly Extensional RTS" + + context weakly_extensional_rts + begin + + lemma src_composite_of: + assumes "composite_of u t v" + shows "src v = src u" + using assms + by (metis con_imp_eq_src con_prfx_composite_of(1)) + + lemma trg_composite_of: + assumes "composite_of u t v" + shows "trg v = trg t" + by (metis arr_composite_of arr_has_un_target arr_iff_has_target assms + targets_composite_of trg_in_targets) + + lemma src_join_of: + assumes "join_of t u v" + shows "src t = src v" and "src u = src v" + by (metis assms join_ofE src_composite_of)+ + + lemma trg_join_of: + assumes "join_of t u v" + shows "trg (t \\ u) = trg v" and "trg (u \\ t) = trg v" + by (metis assms join_of_def trg_composite_of)+ + + end + + subsection "Joins and Composites in an Extensional RTS" + + context extensional_rts + begin + + lemma composite_of_unique: + assumes "composite_of t u v" and "composite_of t u v'" + shows "v = v'" + using assms composite_of_unq_upto_cong extensional by fastforce + + text \ + Here we define composition of transitions. Note that we compose transitions + in diagram order, rather than in the order used for function composition. + This may eventually lead to confusion, but here (unlike in the case of a category) + transitions are typically not functions, so we don't have the constraint of having + to conform to the order of function application and composition, and diagram order + seems more natural. + \ + + definition comp (infixl "\" 55) + where "t \ u \ if composable t u then THE v. composite_of t u v else null" + + lemma comp_is_composite_of: + assumes "composite_of t u v" + shows "composite_of t u (t \ u)" and "t \ u = v" + proof - + show "composite_of t u (t \ u)" + using assms comp_def composite_of_unique the1I2 [of "composite_of t u" "composite_of t u"] + composable_def + by metis + thus "t \ u = v" + using assms composite_of_unique by simp + qed + + lemma comp_null [simp]: + shows "null \ t = null" and "t \ null = null" + by (meson composableD not_arr_null comp_def)+ + + lemma composable_iff_arr_comp: + shows "composable t u \ arr (t \ u)" + by (metis arr_composite_of comp_is_composite_of(2) composable_def comp_def not_arr_null) + + lemma composable_iff_comp_not_null: + shows "composable t u \ t \ u \ null" + by (metis composable_iff_arr_comp comp_def not_arr_null) + + lemma comp_src_arr [simp]: + assumes "arr t" and "src t = a" + shows "a \ t = t" + using assms comp_is_composite_of(2) composite_of_source_arr src_in_sources by blast + + lemma comp_arr_trg [simp]: + assumes "arr t" and "trg t = b" + shows "t \ b = t" + using assms comp_is_composite_of(2) composite_of_arr_target trg_in_targets by blast + + lemma comp_ide_self: + assumes "ide a" + shows "a \ a = a" + using assms comp_is_composite_of(2) composite_of_ide_self by fastforce + + lemma arr_comp [intro, simp]: + assumes "composable t u" + shows "arr (t \ u)" + using assms composable_iff_arr_comp by blast + + lemma trg_comp [simp]: + assumes "composable t u" + shows "trg (t \ u) = trg u" + by (metis arr_has_un_target assms comp_is_composite_of(2) composable_def + composable_imp_seq arr_iff_has_target seq_def targets_composite_of trg_in_targets) + + lemma src_comp [simp]: + assumes "composable t u" + shows "src (t \ u) = src t" + using assms comp_is_composite_of arr_iff_has_source sources_composite_of src_def + composable_def + by auto + + lemma con_comp_iff: + shows "w \ t \ u \ composable t u \ w \\ t \ u" + by (meson comp_is_composite_of(1) con_composite_of_iff con_sym con_implies_arr(2) + composable_def composable_iff_arr_comp) + + lemma con_compI [intro]: + assumes "composable t u" and "w \\ t \ u" + shows "w \ t \ u" and "t \ u \ w" + using assms con_comp_iff con_sym by blast+ + + lemma resid_comp: + assumes "t \ u \ w" + shows "w \\ (t \ u) = (w \\ t) \\ u" + and "(t \ u) \\ w = (t \\ w) \ (u \\ (w \\ t))" + proof - + have 1: "composable t u" + using assms composable_iff_comp_not_null by force + show "w \\ (t \ u) = (w \\ t) \\ u" + using 1 + by (meson assms cong_char composable_def resid_composite_of(3) comp_is_composite_of(1)) + show "(t \ u) \\ w = (t \\ w) \ (u \\ (w \\ t))" + using assms 1 composable_def comp_is_composite_of(2) resid_composite_of + by metis + qed + + lemma prfx_decomp: + assumes "t \ u" + shows "t \ (u \\ t) = u" + by (meson assms arr_resid_iff_con comp_is_composite_of(2) composite_of_def con_sym + cong_reflexive prfx_implies_con) + + lemma prfx_comp: + assumes "arr u" and "t \ v = u" + shows "t \ u" + by (metis assms comp_is_composite_of(2) composable_def composable_iff_arr_comp + composite_of_def) + + lemma comp_eqI: + assumes "t \ v" and "u = v \\ t" + shows "t \ u = v" + by (metis assms prfx_decomp) + + lemma comp_assoc: + assumes "composable (t \ u) v" + shows "t \ (u \ v) = (t \ u) \ v" + proof - + have 1: "t \ (t \ u) \ v" + by (meson assms composable_iff_arr_comp composableD prfx_comp + prfx_transitive) + moreover have "((t \ u) \ v) \\ t = u \ v" + proof - + have "((t \ u) \ v) \\ t = ((t \ u) \\ t) \ (v \\ (t \\ (t \ u)))" + by (meson assms calculation con_sym prfx_implies_con resid_comp(2)) + also have "... = u \ v" + proof - + have 2: "(t \ u) \\ t = u" + by (metis assms comp_is_composite_of(2) composable_def composable_iff_arr_comp + composable_imp_seq composite_of_def extensional seqE) + moreover have "v \\ (t \\ (t \ u)) = v" + using assms + by (meson 1 con_comp_iff con_sym composable_imp_seq resid_arr_ide + prfx_implies_con prfx_comp seqE) + ultimately show ?thesis by simp + qed + finally show ?thesis by blast + qed + ultimately show "t \ (u \ v) = (t \ u) \ v" + by (metis comp_eqI) + qed + + text \ + We note the following assymmetry: \composable (t \ u) v \ composable u v\ is true, + but \composable t (u \ v) \ composable t u\ is not. + \ + + lemma comp_cancel_left: + assumes "arr (t \ u)" and "t \ u = t \ v" + shows "u = v" + using assms + by (metis composable_def composable_iff_arr_comp composite_of_cancel_left extensional + comp_is_composite_of(2)) + + lemma comp_resid_prfx [simp]: + assumes "arr (t \ u)" + shows "(t \ u) \\ t = u" + using assms + by (metis comp_cancel_left comp_eqI prfx_comp) + + lemma bounded_imp_con\<^sub>E: + assumes "t \ u \ t' \ u'" + shows "t \ t'" + by (metis arr_resid_iff_con assms con_comp_iff con_implies_arr(2) prfx_implies_con + con_sym) + + lemma join_of_unique: + assumes "join_of t u v" and "join_of t u v'" + shows "v = v'" + using assms join_of_def composite_of_unique by blast + + definition join (infix "\" 52) + where "t \ u \ if joinable t u then THE v. join_of t u v else null" + + lemma join_is_join_of: + assumes "joinable t u" + shows "join_of t u (t \ u)" + using assms joinable_def join_def join_of_unique the1I2 [of "join_of t u" "join_of t u"] + by force + + lemma joinable_iff_arr_join: + shows "joinable t u \ arr (t \ u)" + by (metis cong_char join_is_join_of join_of_un_upto_cong not_arr_null join_def) + + lemma joinable_iff_join_not_null: + shows "joinable t u \ t \ u \ null" + by (metis join_def joinable_iff_arr_join not_arr_null) + + lemma join_sym: + assumes "t \ u \ null" + shows "t \ u = u \ t" + using assms + by (meson join_def join_is_join_of join_of_symmetric join_of_unique joinable_def) + + lemma src_join: + assumes "joinable t u" + shows "src (t \ u) = src t" + using assms + by (metis con_imp_eq_src con_prfx_composite_of(1) join_is_join_of join_of_def) + + lemma trg_join: + assumes "joinable t u" + shows "trg (t \ u) = trg (t \\ u)" + using assms + by (metis arr_resid_iff_con join_is_join_of joinable_iff_arr_join joinable_implies_con + in_targetsE src_eqI targets_join_of(1) trg_in_targets) + + lemma resid_join\<^sub>E [simp]: + assumes "joinable t u" and "v \ t \ u" + shows "v \\ (t \ u) = (v \\ u) \\ (t \\ u)" + and "v \\ (t \ u) = (v \\ t) \\ (u \\ t)" + and "(t \ u) \\ v = (t \\ v) \ (u \\ v)" + proof - + show 1: "v \\ (t \ u) = (v \\ u) \\ (t \\ u)" + by (meson assms con_sym join_of_def resid_composite_of(3) extensional join_is_join_of) + show "v \\ (t \ u) = (v \\ t) \\ (u \\ t)" + by (metis "1" cube) + show "(t \ u) \\ v = (t \\ v) \ (u \\ v)" + using assms joinable_def join_of_resid join_is_join_of extensional + by (meson join_of_unique) + qed + + lemma join_eqI: + assumes "t \ v" and "u \ v" and "v \\ u = t \\ u" and "v \\ t = u \\ t" + shows "t \ u = v" + using assms composite_of_def cube ideE join_of_def joinable_def join_of_unique + join_is_join_of trg_def + by metis + + lemma comp_join: + assumes "joinable (t \ u) (t \ u')" + shows "composable t (u \ u')" + and "t \ (u \ u') = t \ u \ t \ u'" + proof - + have "t \ t \ u \ t \ u'" + using assms + by (metis composable_def composite_of_def join_of_def join_is_join_of + joinable_implies_con prfx_transitive comp_is_composite_of(2) con_comp_iff) + moreover have "(t \ u \ t \ u') \\ t = u \ u'" + by (metis arr_resid_iff_con assms calculation comp_resid_prfx con_implies_arr(2) + joinable_implies_con resid_join\<^sub>E(3) con_implies_arr(1) ide_implies_arr) + ultimately show "t \ (u \ u') = t \ u \ t \ u'" + by (metis comp_eqI) + thus "composable t (u \ u')" + by (metis assms joinable_iff_join_not_null comp_def) + qed + + lemma join_src: + assumes "arr t" + shows "src t \ t = t" + using assms joinable_def join_of_arr_src join_is_join_of join_of_unique src_in_sources + by meson + + lemma join_self: + assumes "arr t" + shows "t \ t = t" + using assms joinable_def join_of_arr_self join_is_join_of join_of_unique by blast + + lemma arr_prfx_join_self: + assumes "joinable t u" + shows "t \ t \ u" + using assms + by (meson composite_of_def join_is_join_of join_of_def) + + text \ + We note that it is not the case that the existence of either of \t \ (u \ v)\ + or \(t \ u) \ v\ implies that of the other. For example, if \(t \ u) \ v \ null\, + then it is not necessarily the case that \u \ v \ null\. + \ + + end + + subsubsection "Extensional RTS with Joins" + + locale extensional_rts_with_joins = + rts_with_joins + + extensional_rts + begin + + lemma joinable_iff_con: + shows "joinable t u \ t \ u" + by (meson has_joins joinable_implies_con) + + lemma src_join\<^sub>E\<^sub>J [simp]: + assumes "t \ u" + shows "src (t \ u) = src t" + using assms + by (meson has_joins src_join) + + lemma trg_join\<^sub>E\<^sub>J: + assumes "t \ u" + shows "trg (t \ u) = trg (t \\ u)" + using assms + by (meson has_joins trg_join) + + lemma resid_join\<^sub>E\<^sub>J [simp]: + assumes "t \ u" and "v \ t \ u" + shows "v \\ (t \ u) = (v \\ t) \\ (u \\ t)" + and "(t \ u) \\ v = (t \\ v) \ (u \\ v)" + using assms has_joins resid_join\<^sub>E by blast+ + + lemma join_assoc: + shows "t \ (u \ v) = (t \ u) \ v" + proof - + have *: "\t u v. con (t \ u) v \ t \ (u \ v) = (t \ u) \ v" + proof - + fix t u v + assume 1: "con (t \ u) v" + have vt_ut: "v \\ t \ u \\ t" + using 1 + by (metis con_implies_arr(1) con_with_join_of_iff(2) join_is_join_of not_arr_null + join_def) + have tv_uv: "t \\ v \ u \\ v" + using vt_ut cube con_sym + by (metis arr_resid_iff_con) + have 2: "(t \ u) \ v = (t \ (u \\ t)) \ (v \\ (t \ (u \\ t)))" + using 1 + by (metis comp_is_composite_of(2) con_implies_arr(1) has_joins join_is_join_of + join_of_def joinable_iff_arr_join) + also have "... = t \ ((u \\ t) \ (v \\ (t \ (u \\ t))))" + using 1 + by (metis calculation has_joins joinable_iff_join_not_null comp_assoc comp_def) + also have "... = t \ ((u \\ t) \ ((v \\ t) \\ (u \\ t)))" + using 1 + by (metis 2 comp_null(2) con_compI(2) con_comp_iff has_joins resid_comp(1) + conI joinable_iff_join_not_null) + also have "... = t \ ((v \\ t) \ (u \\ t))" + by (metis vt_ut comp_is_composite_of(2) has_joins join_of_def join_is_join_of) + also have "... = t \ ((u \\ t) \ (v \\ t))" + using join_sym by metis + also have "... = t \ ((u \ v) \\ t)" + by (metis tv_uv vt_ut con_implies_arr(2) con_sym con_with_join_of_iff(1) has_joins + join_is_join_of arr_resid_iff_con resid_join\<^sub>E(3)) + also have "... = t \ (u \ v)" + by (metis comp_is_composite_of(2) comp_null(2) conI has_joins join_is_join_of + join_of_def joinable_iff_join_not_null) + finally show "t \ (u \ v) = (t \ u) \ v" + by simp + qed + thus ?thesis + by (metis (full_types) has_joins joinable_iff_join_not_null joinable_implies_con con_sym) + qed + + lemma join_is_lub: + assumes "t \ v" and "u \ v" + shows "t \ u \ v" + proof - + have "(t \ u) \\ v = (t \\ v) \ (u \\ v)" + using assms resid_join\<^sub>E(3) [of t u v] + by (metis arr_prfx_join_self con_target con_sym join_assoc joinable_iff_con + joinable_iff_join_not_null prfx_implies_con resid_reflects_con) + also have "... = trg v \ trg v" + using assms + by (metis ideE prfx_implies_con src_resid trg_ide) + also have "... = trg v" + by (metis assms(2) ide_iff_src_self ide_implies_arr join_self prfx_implies_con + src_resid) + finally have "(t \ u) \\ v = trg v" by blast + moreover have "ide (trg v)" + using assms + by (metis con_implies_arr(2) prfx_implies_con cong_char trg_def) + ultimately show ?thesis by simp + qed + + end + + subsubsection "Extensional RTS with Composites" + + text \ + If an extensional RTS is assumed to have composites for all composable pairs of transitions, + then the ``semantic'' property of transitions being composable can be replaced by the + ``syntactic'' property of transitions being sequential. This results in simpler + statements of a number of properties. + \ + + locale extensional_rts_with_composites = + rts_with_composites + + extensional_rts + begin + + lemma seq_implies_arr_comp: + assumes "seq t u" + shows "arr (t \ u)" + using assms + by (meson composable_iff_arr_comp composable_iff_seq) + + lemma arr_comp\<^sub>E\<^sub>C [intro, simp]: + assumes "arr t" and "arr u" and "trg t = src u" + shows "arr (t \ u)" + using assms + by (simp add: seq_implies_arr_comp) + + lemma arr_compE\<^sub>E\<^sub>C [elim]: + assumes "arr (t \ u)" + and "\arr t; arr u; trg t = src u\ \ T" + shows T + using assms composable_iff_arr_comp composable_iff_seq by blast + + lemma trg_comp\<^sub>E\<^sub>C [simp]: + assumes "seq t u" + shows "trg (t \ u) = trg u" + by (meson assms has_composites trg_comp) + + lemma src_comp\<^sub>E\<^sub>C [simp]: + assumes "seq t u" + shows "src (t \ u) = src t" + using assms src_comp has_composites by simp + + lemma con_comp_iff\<^sub>E\<^sub>C [simp]: + shows "w \ t \ u \ seq t u \ u \ w \\ t" + and "t \ u \ w \ seq t u \ u \ w \\ t" + using composable_iff_seq con_comp_iff con_sym by meson+ + + lemma comp_assoc\<^sub>E\<^sub>C: + shows "t \ (u \ v) = (t \ u) \ v" + apply (cases "seq t u") + apply (metis arr_comp comp_assoc comp_def not_arr_null arr_compE\<^sub>E\<^sub>C arr_comp\<^sub>E\<^sub>C + seq_implies_arr_comp trg_comp\<^sub>E\<^sub>C) + by (metis comp_def composable_iff_arr_comp seqI\<^sub>W\<^sub>E src_comp arr_compE\<^sub>E\<^sub>C) + + lemma diamond_commutes: + shows "t \ (u \\ t) = u \ (t \\ u)" + proof (cases "t \ u") + show "\ t \ u \ ?thesis" + by (metis comp_null(2) conI con_sym) + assume con: "t \ u" + have "(t \ (u \\ t)) \\ u = (t \\ u) \ ((u \\ t) \\ (u \\ t))" + using con + by (metis (no_types, lifting) arr_resid_iff_con con_compI(2) con_implies_arr(1) + resid_comp(2) con_imp_arr_resid con_sym comp_def arr_comp\<^sub>E\<^sub>C src_resid conI) + moreover have "u \ t \ (u \\ t)" + by (metis arr_resid_iff_con calculation con cong_reflexive comp_arr_trg resid_arr_self + resid_comp(1) trg_resid_sym) + ultimately show ?thesis + by (metis comp_eqI con comp_arr_trg resid_arr_self arr_resid trg_resid_sym) + qed + + lemma mediating_transition: + assumes "t \ v = u \ w" + shows "v \\ (u \\ t) = w \\ (t \\ u)" + proof (cases "seq t v") + assume 1: "seq t v" + hence 2: "arr (u \ w)" + using assms by (metis arr_comp\<^sub>E\<^sub>C seqE\<^sub>W\<^sub>E) + have 3: "v \\ (u \\ t) = ((t \ v) \\ t) \\ (u \\ t)" + by (metis "1" comp_is_composite_of(1) composite_of_def obtains_composite_of extensional) + also have "... = (t \ v) \\ (t \ (u \\ t))" + by (metis (no_types, lifting) "2" assms con_comp_iff\<^sub>E\<^sub>C(2) con_imp_eq_src + con_implies_arr(2) con_sym comp_resid_prfx prfx_comp resid_comp(1) + arr_compE\<^sub>E\<^sub>C arr_comp\<^sub>E\<^sub>C prfx_implies_con) + also have "... = (u \ w) \\ (u \ (t \\ u))" + using assms diamond_commutes by presburger + also have "... = ((u \ w) \\ u) \\ (t \\ u)" + by (metis 3 assms calculation cube) + also have "... = w \\ (t \\ u)" + using 2 by simp + finally show ?thesis by blast + next + assume 1: "\ seq t v" + have "v \\ (u \\ t) = null" + using 1 + by (metis (mono_tags, lifting) arr_resid_iff_con coinitial_iff\<^sub>W\<^sub>E con_imp_coinitial + seqI\<^sub>W\<^sub>E src_resid conI) + also have "... = w \\ (t \\ u)" + by (metis (no_types, lifting) "1" arr_comp\<^sub>E\<^sub>C assms composable_imp_seq con_imp_eq_src + con_implies_arr(1) con_implies_arr(2) comp_def not_arr_null conI src_resid) + finally show ?thesis by blast + qed + + lemma induced_arrow: + assumes "seq t u" and "t \ u = t' \ u'" + shows "(t' \\ t) \ (u \\ (t' \\ t)) = u" + and "(t \\ t') \ (u \\ (t' \\ t)) = u'" + and "(t' \\ t) \ v = u \ v = u \\ (t' \\ t)" + apply (metis assms comp_eqI arr_compE\<^sub>E\<^sub>C prfx_comp resid_comp(1) arr_resid_iff_con + seq_implies_arr_comp) + apply (metis assms comp_resid_prfx arr_compE\<^sub>E\<^sub>C resid_comp(2) arr_resid_iff_con + seq_implies_arr_comp) + by (metis assms(1) comp_resid_prfx seq_def) + + text \ + If an extensional RTS has composites, then it automatically has joins. + \ + + sublocale extensional_rts_with_joins + proof + fix t u + assume con: "t \ u" + have 1: "con u (t \ (u \\ t))" + using con_compI(1) [of t "u \\ t" u] + by (metis con con_implies_arr(1) con_sym diamond_commutes prfx_implies_con arr_resid + prfx_comp src_resid arr_comp\<^sub>E\<^sub>C) + have "t \ u = t \ (u \\ t)" + proof (intro join_eqI) + show "t \ t \ (u \\ t)" + by (metis 1 composable_def comp_is_composite_of(2) composite_of_def con_comp_iff) + moreover show 2: "u \ t \ (u \\ t)" + using 1 arr_resid con con_sym prfx_reflexive resid_comp(1) by metis + moreover show "(t \ (u \\ t)) \\ u = t \\ u" + using 1 diamond_commutes induced_arrow(2) resid_comp(2) by force + ultimately show "(t \ (u \\ t)) \\ t = u \\ t" + by (metis con_comp_iff\<^sub>E\<^sub>C(1) con_sym prfx_implies_con resid_comp(2) induced_arrow(1)) + qed + thus "joinable t u" + by (metis "1" con_implies_arr(2) joinable_iff_join_not_null not_arr_null) + qed + + lemma join_expansion: + assumes "t \ u" + shows "t \ u = t \ (u \\ t)" and "seq t (u \\ t)" + proof - + show "t \ u = t \ (u \\ t)" + by (metis assms comp_is_composite_of(2) has_joins join_is_join_of join_of_def) + thus "seq t (u \\ t)" + by (meson assms composable_def composable_iff_seq has_joins join_is_join_of join_of_def) + qed + + lemma join3_expansion: + assumes "t \ u" and "t \ v" and "u \ v" + shows "(t \ u) \ v = (t \ (u \\ t)) \ ((v \\ t) \\ (u \\ t))" + proof (cases "v \\ t \ u \\ t") + show "\ v \\ t \ u \\ t \ ?thesis" + by (metis assms(1) comp_null(2) join_expansion(1) joinable_implies_con + resid_comp(1) join_def conI) + assume 1: "v \\ t \ u \\ t " + have "(t \ u) \ v = (t \ u) \ (v \\ (t \ u))" + by (metis comp_null(1) diamond_commutes ex_un_null join_expansion(1) + joinable_implies_con null_is_zero(2) join_def conI) + also have "... = (t \ (u \\ t)) \ (v \\ (t \ u))" + using join_expansion [of t u] assms(1) by presburger + also have "... = (t \ (u \\ t)) \ ((v \\ u) \\ (t \\ u))" + using assms 1 join_of_resid(1) [of t u v] cube [of v t u] + by (metis con_compI(2) con_implies_arr(2) join_expansion(1) not_arr_null resid_comp(1) + con_sym comp_def src_resid arr_comp\<^sub>E\<^sub>C) + also have "... = (t \ (u \\ t)) \ ((v \\ t) \\ (u \\ t))" + by (metis cube) + finally show ?thesis by blast + qed + + lemma resid_common_prefix: + assumes "t \ u \ t \ v" + shows "(t \ u) \\ (t \ v) = u \\ v" + using assms + by (metis con_comp_iff con_sym con_comp_iff\<^sub>E\<^sub>C(2) con_implies_arr(2) induced_arrow(1) + resid_comp(1) resid_comp(2) residuation.arr_resid_iff_con residuation_axioms) + + end + + subsection "Confluence" + + text \ + An RTS is \emph{confluent} if every coinitial pair of transitions is consistent. + \ + + locale confluent_rts = rts + + assumes confluence: "coinitial t u \ con t u" + + section "Simulations" + + text \ + \emph{Simulations} are morphism of residuated transition systems. + They are assumed to preserve consistency and residuation. + \ + + locale simulation = + A: rts A + + B: rts B + for A :: "'a resid" (infixr "\\\<^sub>A" 70) + and B :: "'b resid" (infixr "\\\<^sub>B" 70) + and F :: "'a \ 'b" + + assumes extensional: "\ A.arr t \ F t = B.null" + and preserves_con [simp]: "A.con t u \ B.con (F t) (F u)" + and preserves_resid [simp]: "A.con t u \ F (t \\\<^sub>A u) = F t \\\<^sub>B F u" + begin + + lemma preserves_reflects_arr [iff]: + shows "B.arr (F t) \ A.arr t" + by (metis A.arr_def B.con_implies_arr(2) B.not_arr_null extensional preserves_con) + + lemma preserves_ide [simp]: + assumes "A.ide a" + shows "B.ide (F a)" + by (metis A.ideE assms preserves_con preserves_resid B.ideI) + + lemma preserves_sources: + shows "F ` A.sources t \ B.sources (F t)" + using A.sources_def B.sources_def preserves_con preserves_ide by auto + + lemma preserves_targets: + shows "F ` A.targets t \ B.targets (F t)" + by (metis A.arrE B.arrE A.sources_resid B.sources_resid equals0D image_subset_iff + A.arr_iff_has_target preserves_reflects_arr preserves_resid preserves_sources) + + lemma preserves_trg: + assumes "A.arr t" + shows "F (A.trg t) = B.trg (F t)" + using assms A.trg_def B.trg_def by auto + + lemma preserves_composites: + assumes "A.composite_of t u v" + shows "B.composite_of (F t) (F u) (F v)" + using assms + by (metis A.composite_ofE A.prfx_implies_con B.composite_of_def preserves_ide + preserves_resid A.con_sym) + + lemma preserves_joins: + assumes "A.join_of t u v" + shows "B.join_of (F t) (F u) (F v)" + using assms A.join_of_def B.join_of_def A.joinable_def + by (metis A.joinable_implies_con preserves_composites preserves_resid) + + lemma preserves_prfx: + assumes "A.prfx t u" + shows "B.prfx (F t) (F u)" + using assms + by (metis A.prfx_implies_con preserves_ide preserves_resid) + + lemma preserves_cong: + assumes "A.cong t u" + shows "B.cong (F t) (F u)" + using assms preserves_prfx by simp + + end + + subsection "Identity Simulation" + + locale identity_simulation = + rts + begin + + abbreviation map + where "map \ \t. if arr t then t else null" + + sublocale simulation resid resid map + using con_implies_arr con_sym arr_resid_iff_con + by unfold_locales auto + + end + + subsection "Composite of Simulations" + + lemma simulation_comp: + assumes "simulation A B F" and "simulation B C G" + shows "simulation A C (G o F)" + proof - + interpret F: simulation A B F using assms(1) by auto + interpret G: simulation B C G using assms(2) by auto + show "simulation A C (G o F)" + using F.extensional G.extensional by unfold_locales auto + qed + + locale composite_simulation = + F: simulation A B F + + G: simulation B C G + for A :: "'a resid" + and B :: "'b resid" + and C :: "'c resid" + and F :: "'a \ 'b" + and G :: "'b \ 'c" + begin + + abbreviation map + where "map \ G o F" + + sublocale simulation A C map + using simulation_comp F.simulation_axioms G.simulation_axioms by blast + + lemma is_simulation: + shows "simulation A C map" + .. + + end + + subsection "Simulations into a Weakly Extensional RTS" + + locale simulation_to_weakly_extensional_rts = + simulation + + B: weakly_extensional_rts B + begin + + lemma preserves_src: + shows "\a. a \ A.sources t \ B.src (F t) = F a" + by (metis equals0D image_subset_iff B.arr_iff_has_source + preserves_sources B.arr_has_un_source B.src_in_sources) + + lemma preserves_trg: + shows "\b. b \ A.targets t \ B.trg (F t) = F b" + by (metis equals0D image_subset_iff B.arr_iff_has_target + preserves_targets B.arr_has_un_target B.trg_in_targets) + + end + + subsection "Simulations into an Extensional RTS" + + locale simulation_to_extensional_rts = + simulation + + B: extensional_rts B + begin + + lemma preserves_comp: + assumes "A.composite_of t u v" + shows "F v = B.comp (F t) (F u)" + using assms + by (metis preserves_composites B.comp_is_composite_of(2)) + + lemma preserves_join: + assumes "A.join_of t u v" + shows "F v = B.join (F t) (F u)" + using assms preserves_joins + by (meson B.join_is_join_of B.join_of_unique B.joinable_def) + + end + + subsection "Simulations between Extensional RTS's" + + locale simulation_between_extensional_rts = + simulation_to_extensional_rts + + A: extensional_rts A + begin + + lemma preserves_src: + shows "B.src (F t) = F (A.src t)" + by (metis A.arr_src_iff_arr A.src_in_sources extensional image_subset_iff + preserves_reflects_arr preserves_sources B.arr_has_un_source B.src_def + B.src_in_sources) + + lemma preserves_trg: + shows "B.trg (F t) = F (A.trg t)" + by (metis A.arr_trg_iff_arr A.residuation_axioms A.trg_def B.null_is_zero(2) B.trg_def + extensional preserves_resid residuation.arrE) + + lemma preserves_comp: + assumes "A.composable t u" + shows "F (A.comp t u) = B.comp (F t) (F u)" + using assms + by (metis A.arr_comp A.comp_resid_prfx A.composableD(2) A.not_arr_null + A.prfx_comp A.residuation_axioms B.comp_eqI preserves_prfx preserves_resid + residuation.conI) + + lemma preserves_join: + assumes "A.joinable t u" + shows "F (A.join t u) = B.join (F t) (F u)" + using assms + by (meson A.join_is_join_of B.joinable_def preserves_joins B.join_is_join_of + B.join_of_unique) + + end + + subsection "Transformations" + + text \ + A \emph{transformation} is a morphism of simulations, analogously to how a natural + transformation is a morphism of functors, except the normal commutativity + condition for that ``naturality squares'' is replaced by the requirement that + the arrows at the apex of such a square are given by residuation of the + arrows at the base. If the codomain RTS is extensional, then this + condition implies the commutativity of the square with respect to composition, + as would be the case for a natural transformation between functors. + + The proper way to define a transformation when the domain and codomain are + general RTS's is not yet clear to me. However, if the domain and codomain are + weakly extensional, then we have unique sources and targets, so there is no problem. + The definition below is limited to that case. I do not make any attempt here + to develop facts about transformations. My main reason for including this + definition here is so that in the subsequent application to the \\\-calculus, + I can exhibit \\\-reduction as an example of a transformation. + \ + + locale transformation = + A: weakly_extensional_rts A + + B: weakly_extensional_rts B + + F: simulation A B F + + G: simulation A B G + for A :: "'a resid" (infixr "\\\<^sub>A" 70) + and B :: "'b resid" (infixr "\\\<^sub>B" 70) + and F :: "'a \ 'b" + and G :: "'a \ 'b" + and \ :: "'a \ 'b" + + assumes extensional: "\ A.arr f \ \ f = B.null" + and preserves_src: "A.arr f \ B.src (\ f) = F (A.src f)" + and preserves_trg: "A.arr f \ B.trg (\ f) = G (A.trg f)" + and naturality1: "A.arr f \ \ (A.src f) \\\<^sub>B F f = \ (A.trg f)" + and naturality2: "A.arr f \ F f \\\<^sub>B \ (A.src f) = G f" + + section "Normal Sub-RTS's and Congruence" + + text \ + We now develop a general quotient construction on an RTS. + We define a \emph{normal sub-RTS} of an RTS to be a collection of transitions \\\ having + certain ``local'' closure properties. A normal sub-RTS induces an equivalence + relation \\\<^sub>0\, which we call \emph{semi-congruence}, by defining \t \\<^sub>0 u\ to hold exactly + when \t \ u\ and \u \ t\ are both in \\\. This relation generalizes the relation \\\ + defined for an arbitrary RTS, in the sense that \\\ is obtained when \\\ consists of + all and only the identity transitions. However, in general the relation \\\<^sub>0\ is fully + substitutive only in the left argument position of residuation; for the right argument position, + a somewhat weaker property is satisfied. We then coarsen \\\<^sub>0\ to a relation \\\, by defining + \t \ u\ to hold exactly when \t\ and \u\ can be transported by residuation along transitions + in \\\ to a common source, in such a way that the residuals are related by \\\<^sub>0\. + To obtain full substitutivity of \\\ with respect to residuation, we need to impose an + additional condition on \\\. This condition, which we call \emph{coherence}, + states that transporting a transition \t\ along parallel transitions \u\ and \v\ in \\\ always + yields residuals \t \ u\ and \u \ t\ that are related by \\\<^sub>0\. We show that, under the + assumption of coherence, the relation \\\ is fully substitutive, and the quotient of the + original RTS by this relation is an extensional RTS which has the \\\-connected components of + the original RTS as identities. Although the coherence property has a somewhat \emph{ad hoc} + feel to it, we show that, in the context of the other conditions assumed for \\\, coherence is + in fact equivalent to substitutivity for \\\. + \ + + subsection "Normal Sub-RTS's" + + locale normal_sub_rts = + R: rts + + fixes \ :: "'a set" + assumes elements_are_arr: "t \ \ \ R.arr t" + and ide_closed: "R.ide a \ a \ \" + and forward_stable: "\ u \ \; R.coinitial t u \ \ u \\ t \ \" + and backward_stable: "\ u \ \; t \\ u \ \ \ \ t \ \" + and composite_closed_left: "\ u \ \; R.seq u t \ \ \v. R.composite_of u t v" + and composite_closed_right: "\ u \ \; R.seq t u \ \ \v. R.composite_of t u v" + begin + + lemma prfx_closed: + assumes "u \ \" and "R.prfx t u" + shows "t \ \" + using assms backward_stable ide_closed by blast + + lemma composite_closed: + assumes "t \ \" and "u \ \" and "R.composite_of t u v" + shows "v \ \" + using assms backward_stable R.composite_of_def prfx_closed by blast + + lemma factor_closed: + assumes "R.composite_of t u v" and "v \ \" + shows "t \ \" and "u \ \" + apply (metis assms R.composite_of_def prfx_closed) + by (meson assms R.composite_of_def R.con_imp_coinitial forward_stable prfx_closed + R.prfx_implies_con) + + lemma resid_along_elem_preserves_con: + assumes "t \ t'" and "R.coinitial t u" and "u \ \" + shows "t \\ u \ t' \\ u" + proof - + have "R.coinitial (t \\ t') (u \\ t')" + by (metis assms R.arr_resid_iff_con R.coinitialI R.con_imp_common_source forward_stable + elements_are_arr R.con_implies_arr(2) R.sources_resid R.sources_eqI) + hence "t \\ t' \ u \\ t'" + by (metis assms(3) R.coinitial_iff R.con_imp_coinitial R.con_sym elements_are_arr + forward_stable R.arr_resid_iff_con) + thus ?thesis + using assms R.cube forward_stable by fastforce + qed + + end + + subsubsection "Normal Sub-RTS's of an Extensional RTS with Composites" + + locale normal_in_extensional_rts_with_composites = + R: extensional_rts + + R: rts_with_composites + + normal_sub_rts + begin + + lemma factor_closed\<^sub>E\<^sub>C: + assumes "t \ u \ \" + shows "t \ \" and "u \ \" + using assms factor_closed + by (metis R.arrE R.composable_def R.comp_is_composite_of(2) R.con_comp_iff + elements_are_arr)+ + + lemma comp_in_normal_iff: + shows "t \ u \ \ \ t \ \ \ u \ \ \ R.seq t u" + by (metis R.comp_is_composite_of(2) composite_closed elements_are_arr + factor_closed(1-2) R.composable_def R.has_composites R.rts_with_composites_axioms + R.extensional_rts_axioms extensional_rts_with_composites.arr_compE\<^sub>E\<^sub>C + extensional_rts_with_composites_def R.seqI\<^sub>W\<^sub>E) + + end + + subsection "Semi-Congruence" + + context normal_sub_rts + begin + + text \ + We will refer to the elements of \\\ as \emph{normal transitions}. + Generalizing identity transitions to normal transitions in the definition of congruence, + we obtain the notion of \emph{semi-congruence} of transitions with respect to a + normal sub-RTS. + \ + + abbreviation Cong\<^sub>0 (infix "\\<^sub>0" 50) + where "t \\<^sub>0 t' \ t \\ t' \ \ \ t' \\ t \ \" + + lemma Cong\<^sub>0_reflexive: + assumes "R.arr t" + shows "t \\<^sub>0 t" + using assms R.cong_reflexive ide_closed by simp + + lemma Cong\<^sub>0_symmetric: + assumes "t \\<^sub>0 t'" + shows "t' \\<^sub>0 t" + using assms by simp + + lemma Cong\<^sub>0_transitive [trans]: + assumes "t \\<^sub>0 t'" and "t' \\<^sub>0 t''" + shows "t \\<^sub>0 t''" + by (metis (full_types) R.arr_resid_iff_con assms backward_stable forward_stable + elements_are_arr R.coinitialI R.cube R.sources_resid) + + lemma Cong\<^sub>0_imp_con: + assumes "t \\<^sub>0 t'" + shows "R.con t t'" + using assms R.arr_resid_iff_con elements_are_arr by blast + + lemma Cong\<^sub>0_imp_coinitial: + assumes "t \\<^sub>0 t'" + shows "R.sources t = R.sources t'" + using assms by (meson Cong\<^sub>0_imp_con R.coinitial_iff R.con_imp_coinitial) + + text \ + Semi-congruence is preserved and reflected by residuation along normal transitions. + \ + + lemma Resid_along_normal_preserves_Cong\<^sub>0: + assumes "t \\<^sub>0 t'" and "u \ \" and "R.sources t = R.sources u" + shows "t \\ u \\<^sub>0 t' \\ u" + by (metis Cong\<^sub>0_imp_coinitial R.arr_resid_iff_con R.coinitialI R.coinitial_def + R.cube R.sources_resid assms elements_are_arr forward_stable) + + lemma Resid_along_normal_reflects_Cong\<^sub>0: + assumes "t \\ u \\<^sub>0 t' \\ u" and "u \ \" + shows "t \\<^sub>0 t'" + using assms + by (metis backward_stable R.con_imp_coinitial R.cube R.null_is_zero(2) + forward_stable R.conI) + + text \ + Semi-congruence is substitutive for the left-hand argument of residuation. + \ + + lemma Cong\<^sub>0_subst_left: + assumes "t \\<^sub>0 t'" and "t \ u" + shows "t' \ u" and "t \\ u \\<^sub>0 t' \\ u" + proof - + have 1: "t \ u \ t \ t' \ u \\ t \ t' \\ t" + using assms + by (metis Resid_along_normal_preserves_Cong\<^sub>0 Cong\<^sub>0_imp_con Cong\<^sub>0_reflexive R.con_sym + R.null_is_zero(2) R.arr_resid_iff_con R.sources_resid R.conI) + hence 2: "t' \ u \ u \\ t \ t' \\ t \ + (t \\ u) \\ (t' \\ u) = (t \\ t') \\ (u \\ t') \ + (t' \\ u) \\ (t \\ u) = (t' \\ t) \\ (u \\ t)" + by (meson R.con_sym R.cube R.resid_reflects_con) + show "t' \ u" + using 2 by simp + show "t \\ u \\<^sub>0 t' \\ u" + using assms 1 2 + by (metis R.arr_resid_iff_con R.con_imp_coinitial R.cube forward_stable) + qed + + text \ + Semi-congruence is not exactly substitutive for residuation on the right. + Instead, the following weaker property is satisfied. Obtaining exact substitutivity + on the right is the motivation for defining a coarser notion of congruence below. + \ + + lemma Cong\<^sub>0_subst_right: + assumes "u \\<^sub>0 u'" and "t \ u" + shows "t \ u'" and "(t \\ u) \\ (u' \\ u) \\<^sub>0 (t \\ u') \\ (u \\ u')" + using assms + apply (meson Cong\<^sub>0_subst_left(1) R.con_sym) + using assms + by (metis R.sources_resid Cong\<^sub>0_imp_con Cong\<^sub>0_reflexive Resid_along_normal_preserves_Cong\<^sub>0 + R.arr_resid_iff_con residuation.cube R.residuation_axioms) + + lemma Cong\<^sub>0_subst_Con: + assumes "t \\<^sub>0 t'" and "u \\<^sub>0 u'" + shows "t \ u \ t' \ u'" + using assms + by (meson Cong\<^sub>0_subst_left(1) Cong\<^sub>0_subst_right(1)) + + lemma Cong\<^sub>0_cancel_left: + assumes "R.composite_of t u v" and "R.composite_of t u' v'" and "v \\<^sub>0 v'" + shows "u \\<^sub>0 u'" + proof - + have "u \\<^sub>0 v \\ t" + using assms(1) ide_closed by blast + also have "v \\ t \\<^sub>0 v' \\ t" + by (meson assms(1,3) Cong\<^sub>0_subst_left(2) R.composite_of_def R.con_sym R.prfx_implies_con) + also have "v' \\ t \\<^sub>0 u'" + using assms(2) ide_closed by blast + finally show ?thesis by auto + qed + + lemma Cong\<^sub>0_iff: + shows "t \\<^sub>0 t' \ + (\u u' v v'. u \ \ \ u' \ \ \ v \\<^sub>0 v' \ + R.composite_of t u v \ R.composite_of t' u' v')" + proof (intro iffI) + show "\u u' v v'. u \ \ \ u' \ \ \ v \\<^sub>0 v' \ + R.composite_of t u v \ R.composite_of t' u' v' + \ t \\<^sub>0 t'" + by (meson Cong\<^sub>0_transitive R.composite_of_def ide_closed prfx_closed) + show "t \\<^sub>0 t' \ \u u' v v'. u \ \ \ u' \ \ \ v \\<^sub>0 v' \ + R.composite_of t u v \ R.composite_of t' u' v'" + by (metis Cong\<^sub>0_imp_con Cong\<^sub>0_transitive R.composite_of_def R.prfx_reflexive + R.arrI R.ideE) + qed + + lemma diamond_commutes_upto_Cong\<^sub>0: + assumes "t \ u" and "R.composite_of t (u \\ t) v" and "R.composite_of u (t \\ u) v'" + shows "v \\<^sub>0 v'" + proof - + have "v \\ v \\<^sub>0 v' \\ v \ v' \\ v' \\<^sub>0 v \\ v'" + proof- + have 1: "(v \\ t) \\ (u \\ t) \\<^sub>0 (v' \\ u) \\ (t \\ u)" + using assms(2-3) R.cube [of v t u] + by (metis R.con_target R.composite_ofE R.ide_imp_con_iff_cong ide_closed + R.conI) + have 2: "v \\ v \\<^sub>0 v' \\ v" + proof - + have "v \\ v \\<^sub>0 (v \\ t) \\ (u \\ t)" + using assms R.composite_of_def ide_closed + by (meson R.composite_of_unq_upto_cong R.prfx_implies_con R.resid_composite_of(3)) + also have "(v \\ t) \\ (u \\ t) \\<^sub>0 (v' \\ u) \\ (t \\ u)" + using 1 by simp + also have "(v' \\ u) \\ (t \\ u) \\<^sub>0 (v' \\ t) \\ (u \\ t)" + by (metis "1" Cong\<^sub>0_transitive R.cube) + also have "(v' \\ t) \\ (u \\ t) \\<^sub>0 v' \\ v" + using assms R.composite_of_def ide_closed + by (metis "1" R.conI R.con_sym_ax R.cube R.null_is_zero(2) R.resid_composite_of(3)) + finally show ?thesis by auto + qed + moreover have "v' \\ v' \\<^sub>0 v \\ v'" + proof - + have "v' \\ v' \\<^sub>0 (v' \\ u) \\ (t \\ u)" + using assms R.composite_of_def ide_closed + by (meson R.composite_of_unq_upto_cong R.prfx_implies_con R.resid_composite_of(3)) + also have "(v' \\ u) \\ (t \\ u) \\<^sub>0 (v \\ t) \\ (u \\ t)" + using 1 by simp + also have "(v \\ t) \\ (u \\ t) \\<^sub>0 (v \\ u) \\ (t \\ u)" + using R.cube [of v t u] ide_closed + by (metis Cong\<^sub>0_reflexive R.arr_resid_iff_con assms(2) R.composite_of_def + R.prfx_implies_con) + also have "(v \\ u) \\ (t \\ u) \\<^sub>0 v \\ v'" + using assms R.composite_of_def ide_closed + by (metis 2 R.conI elements_are_arr R.not_arr_null R.null_is_zero(2) + R.resid_composite_of(3)) + finally show ?thesis by auto + qed + ultimately show ?thesis by blast + qed + thus ?thesis + by (metis assms(2-3) R.composite_of_unq_upto_cong R.resid_arr_ide Cong\<^sub>0_imp_con) + qed + + subsection "Congruence" + + text \ + We use semi-congruence to define a coarser relation as follows. + \ + + definition Cong (infix "\" 50) + where "Cong t t' \ \u u'. u \ \ \ u' \ \ \ t \\ u \\<^sub>0 t' \\ u'" + + lemma CongI [intro]: + assumes "u \ \" and "u' \ \" and "t \\ u \\<^sub>0 t' \\ u'" + shows "Cong t t'" + using assms Cong_def by auto + + lemma CongE [elim]: + assumes "t \ t'" + obtains u u' + where "u \ \" and "u' \ \" and "t \\ u \\<^sub>0 t' \\ u'" + using assms Cong_def by auto + + lemma Cong_imp_arr: + assumes "t \ t'" + shows "R.arr t" and "R.arr t'" + using assms Cong_def + by (meson R.arr_resid_iff_con R.con_implies_arr(2) R.con_sym elements_are_arr)+ + + lemma Cong_reflexive: + assumes "R.arr t" + shows "t \ t" + by (metis CongI Cong\<^sub>0_reflexive assms R.con_imp_coinitial_ax ide_closed + R.resid_arr_ide R.arrE R.con_sym) + + lemma Cong_symmetric: + assumes "t \ t'" + shows "t' \ t" + using assms Cong_def by auto + + text \ + The existence of composites of normal transitions is used in the following. + \ + + lemma Cong_transitive [trans]: + assumes "t \ t''" and "t'' \ t'" + shows "t \ t'" + proof - + obtain u u'' where uu'': "u \ \ \ u'' \ \ \ t \\ u \\<^sub>0 t'' \\ u''" + using assms Cong_def by blast + obtain v' v'' where v'v'': "v' \ \ \ v'' \ \ \ t'' \\ v'' \\<^sub>0 t' \\ v'" + using assms Cong_def by blast + let ?w = "(t \\ u) \\ (v'' \\ u'')" + let ?w' = "(t' \\ v') \\ (u'' \\ v'')" + let ?w'' = "(t'' \\ v'') \\ (u'' \\ v'')" + have w'': "?w'' = (t'' \\ u'') \\ (v'' \\ u'')" + by (metis R.cube) + have u''v'': "R.coinitial u'' v''" + by (metis (full_types) R.coinitial_iff elements_are_arr R.con_imp_coinitial + R.arr_resid_iff_con uu'' v'v'') + hence v''u'': "R.coinitial v'' u''" + by (meson R.con_imp_coinitial elements_are_arr forward_stable R.arr_resid_iff_con v'v'') + have 1: "?w \\ ?w'' \ \" + proof - + have "(v'' \\ u'') \\ (t'' \\ u'') \ \" + by (metis Cong\<^sub>0_transitive R.con_imp_coinitial forward_stable Cong\<^sub>0_imp_con + resid_along_elem_preserves_con R.arrI R.arr_resid_iff_con u''v'' uu'' v'v'') + thus ?thesis + by (metis Cong\<^sub>0_subst_left(2) R.con_sym R.null_is_zero(1) uu'' w'' R.conI) + qed + have 2: "?w'' \\ ?w \ \" + by (metis 1 Cong\<^sub>0_subst_left(2) uu'' w'' R.conI) + have 3: "R.seq u (v'' \\ u'')" + by (metis (full_types) 2 Cong\<^sub>0_imp_coinitial R.sources_resid + Cong\<^sub>0_imp_con R.arr_resid_iff_con R.con_implies_arr(2) R.seqI uu'' R.conI) + have 4: "R.seq v' (u'' \\ v'')" + by (metis 1 Cong\<^sub>0_imp_coinitial Cong\<^sub>0_imp_con R.arr_resid_iff_con + R.con_implies_arr(2) R.seq_def R.sources_resid v'v'' R.conI) + obtain x where x: "R.composite_of u (v'' \\ u'') x" + using 3 composite_closed_left uu'' by blast + obtain x' where x': "R.composite_of v' (u'' \\ v'') x'" + using 4 composite_closed_left v'v'' by presburger + have "?w \\<^sub>0 ?w'" + proof - + have "?w \\<^sub>0 ?w'' \ ?w' \\<^sub>0 ?w''" + using 1 2 + by (metis Cong\<^sub>0_subst_left(2) R.null_is_zero(2) v'v'' R.conI) + thus ?thesis + using Cong\<^sub>0_transitive by blast + qed + moreover have "x \ \ \ ?w \\<^sub>0 t \\ x" + apply (intro conjI) + apply (meson composite_closed forward_stable u''v'' uu'' v'v'' x) + apply (metis (full_types) R.arr_resid_iff_con R.con_implies_arr(2) R.con_sym + ide_closed forward_stable R.composite_of_def R.resid_composite_of(3) + Cong\<^sub>0_subst_right(1) prfx_closed u''v'' uu'' v'v'' x R.conI) + by (metis (no_types, lifting) 1 R.con_composite_of_iff ide_closed + R.resid_composite_of(3) R.arr_resid_iff_con R.con_implies_arr(1) R.con_sym x R.conI) + moreover have "x' \ \ \ ?w' \\<^sub>0 t' \\ x'" + apply (intro conjI) + apply (meson composite_closed forward_stable uu'' v''u'' v'v'' x') + apply (metis (full_types) Cong\<^sub>0_subst_right(1) R.composite_ofE R.con_sym + ide_closed forward_stable R.con_imp_coinitial prfx_closed + R.resid_composite_of(3) R.arr_resid_iff_con R.con_implies_arr(1) uu'' v'v'' x' R.conI) + by (metis (full_types) Cong\<^sub>0_subst_left(1) R.composite_ofE R.con_sym ide_closed + forward_stable R.con_imp_coinitial prfx_closed R.resid_composite_of(3) + R.arr_resid_iff_con R.con_implies_arr(1) uu'' v'v'' x' R.conI) + ultimately show "t \ t'" + using Cong_def Cong\<^sub>0_transitive by metis + qed + + lemma Cong_closure_props: + shows "t \ u \ u \ t" + and "\t \ u; u \ v\ \ t \ v" + and "t \\<^sub>0 u \ t \ u" + and "\u \ \; R.sources t = R.sources u\ \ t \ t \\ u" + proof - + show "t \ u \ u \ t" + using Cong_symmetric by blast + show "\t \ u; u \ v\ \ t \ v" + using Cong_transitive by blast + show "t \\<^sub>0 u \ t \ u" + by (metis Cong\<^sub>0_subst_left(2) Cong_def Cong_reflexive R.con_implies_arr(1) + R.null_is_zero(2) R.conI) + show "\u \ \; R.sources t = R.sources u\ \ t \ t \\ u" + proof - + assume u: "u \ \" and coinitial: "R.sources t = R.sources u" + obtain a where a: "a \ R.targets u" + by (meson elements_are_arr empty_subsetI R.arr_iff_has_target subsetI subset_antisym u) + have "t \\ u \\<^sub>0 (t \\ u) \\ a" + proof - + have "R.arr t" + using R.arr_iff_has_source coinitial elements_are_arr u by presburger + thus ?thesis + by (meson u a R.arr_resid_iff_con coinitial ide_closed forward_stable + elements_are_arr R.coinitial_iff R.composite_of_arr_target R.resid_composite_of(3)) + qed + thus ?thesis + using Cong_def + by (metis a R.composite_of_arr_target elements_are_arr factor_closed(2) u) + qed + qed + + lemma Cong\<^sub>0_implies_Cong: + assumes "t \\<^sub>0 t'" + shows "t \ t'" + using assms Cong_closure_props(3) by simp + + lemma in_sources_respects_Cong: + assumes "t \ t'" and "a \ R.sources t" and "a' \ R.sources t'" + shows "a \ a'" + proof - + obtain u u' where uu': "u \ \ \ u' \ \ \ t \\ u \\<^sub>0 t' \\ u'" + using assms Cong_def by blast + show "a \ a'" + proof + show "u \ \" + using uu' by simp + show "u' \ \" + using uu' by simp + show "a \\ u \\<^sub>0 a' \\ u'" + proof - + have "a \\ u \ R.targets u" + by (metis Cong\<^sub>0_imp_con R.arr_resid_iff_con assms(2) R.con_imp_common_source + R.con_implies_arr(1) R.resid_source_in_targets R.sources_eqI uu') + moreover have "a' \\ u' \ R.targets u'" + by (metis Cong\<^sub>0_imp_con R.arr_resid_iff_con assms(3) R.con_imp_common_source + R.resid_source_in_targets R.con_implies_arr(1) R.sources_eqI uu') + moreover have "R.targets u = R.targets u'" + by (metis Cong\<^sub>0_imp_coinitial Cong\<^sub>0_imp_con R.arr_resid_iff_con + R.con_implies_arr(1) R.sources_resid uu') + ultimately show ?thesis + using ide_closed R.targets_are_cong by presburger + qed + qed + qed + + lemma in_targets_respects_Cong: + assumes "t \ t'" and "b \ R.targets t" and "b' \ R.targets t'" + shows "b \ b'" + proof - + obtain u u' where uu': "u \ \ \ u' \ \ \ t \\ u \\<^sub>0 t' \\ u'" + using assms Cong_def by blast + have seq: "R.seq (u \\ t) ((t' \\ u') \\ (t \\ u)) \ R.seq (u' \\ t') ((t \\ u) \\ (t' \\ u'))" + by (metis R.arr_iff_has_source R.arr_iff_has_target R.conI elements_are_arr R.not_arr_null + R.seqI R.sources_resid R.targets_resid_sym uu') + obtain v where v: "R.composite_of (u \\ t) ((t' \\ u') \\ (t \\ u)) v" + using seq composite_closed_right uu' by presburger + obtain v' where v': "R.composite_of (u' \\ t') ((t \\ u) \\ (t' \\ u')) v'" + using seq composite_closed_right uu' by presburger + show "b \ b'" + proof + show v_in_\: "v \ \" + by (metis composite_closed R.con_imp_coinitial R.con_implies_arr(1) forward_stable + R.composite_of_def R.prfx_implies_con R.arr_resid_iff_con R.con_sym uu' v) + show v'_in_\: "v' \ \" + by (metis backward_stable R.composite_of_def R.con_imp_coinitial forward_stable + R.null_is_zero(2) prfx_closed uu' v' R.conI) + show "b \\ v \\<^sub>0 b' \\ v'" + using assms uu' v v' + by (metis R.arr_resid_iff_con ide_closed R.seq_def R.sources_resid R.targets_resid_sym + R.resid_source_in_targets seq R.sources_composite_of R.targets_are_cong + R.targets_composite_of) + qed + qed + + lemma sources_are_Cong: + assumes "a \ R.sources t" and "a' \ R.sources t" + shows "a \ a'" + using assms + by (simp add: ide_closed R.sources_are_cong Cong_closure_props(3)) + + lemma targets_are_Cong: + assumes "b \ R.targets t" and "b' \ R.targets t" + shows "b \ b'" + using assms + by (simp add: ide_closed R.targets_are_cong Cong_closure_props(3)) + + text \ + It is \emph{not} the case that sources and targets are \\\-closed; + \emph{i.e.} \t \ t' \ sources t = sources t'\ and \t \ t' \ targets t = targets t'\ + do not hold, in general. + \ + + lemma Resid_along_normal_preserves_reflects_con: + assumes "u \ \" and "R.sources t = R.sources u" + shows "t \\ u \ t' \\ u \ t \ t'" + by (metis R.arr_resid_iff_con assms R.con_implies_arr(1-2) elements_are_arr R.coinitial_iff + R.resid_reflects_con resid_along_elem_preserves_con) + + text \ + We can alternatively characterize \\\ as the least symmetric and transitive + relation on transitions that extends \\\<^sub>0\ and has the property + of being preserved by residuation along transitions in \\\. + \ + + inductive Cong' + where "\t u. Cong' t u \ Cong' u t" + | "\t u v. \Cong' t u; Cong' u v\ \ Cong' t v" + | "\t u. t \\<^sub>0 u \ Cong' t u" + | "\t u. \R.arr t; u \ \; R.sources t = R.sources u\ \ Cong' t (t \\ u)" + + lemma Cong'_if: + shows "\u \ \; u' \ \; t \\ u \\<^sub>0 t' \\ u'\ \ Cong' t t'" + proof - + assume u: "u \ \" and u': "u' \ \" and 1: "t \\ u \\<^sub>0 t' \\ u'" + show "Cong' t t'" + using u u' 1 + by (metis (no_types, lifting) Cong'.simps Cong\<^sub>0_imp_con R.arr_resid_iff_con + R.coinitial_iff R.con_imp_coinitial) + qed + + lemma Cong_char: + shows "Cong t t' \ Cong' t t'" + proof - + have "Cong t t' \ Cong' t t'" + using Cong_def Cong'_if by blast + moreover have "Cong' t t' \ Cong t t'" + apply (induction rule: Cong'.induct) + using Cong_symmetric apply simp + using Cong_transitive apply simp + using Cong_closure_props(3) apply simp + using Cong_closure_props(4) by simp + ultimately show ?thesis + using Cong_def by blast + qed + + lemma normal_is_Cong_closed: + assumes "t \ \" and "t \ t'" + shows "t' \ \" + using assms + by (metis (full_types) CongE R.con_imp_coinitial forward_stable + R.null_is_zero(2) backward_stable R.conI) + + subsection "Congruence Classes" + + text \ + Here we develop some notions relating to the congruence classes of \\\. + \ + + definition Cong_class ("\_\") + where "Cong_class t \ {t'. t \ t'}" + + definition is_Cong_class + where "is_Cong_class \ \ \t. t \ \ \ \ = \t\" + + definition Cong_class_rep + where "Cong_class_rep \ \ SOME t. t \ \" + + lemma Cong_class_is_nonempty: + assumes "is_Cong_class \" + shows "\ \ {}" + using assms is_Cong_class_def Cong_class_def by auto + + lemma rep_in_Cong_class: + assumes "is_Cong_class \" + shows "Cong_class_rep \ \ \" + using assms is_Cong_class_def Cong_class_rep_def someI_ex [of "\t. t \ \"] + by metis + + lemma arr_in_Cong_class: + assumes "R.arr t" + shows "t \ \t\" + using assms Cong_class_def Cong_reflexive by simp + + lemma is_Cong_classI: + assumes "R.arr t" + shows "is_Cong_class \t\" + using assms Cong_class_def is_Cong_class_def Cong_reflexive by blast + + lemma is_Cong_classI' [intro]: + assumes "\ \ {}" + and "\t t'. \t \ \; t' \ \\ \ t \ t'" + and "\t t'. \t \ \; t' \ t\ \ t' \ \" + shows "is_Cong_class \" + proof - + obtain t where t: "t \ \" + using assms by auto + have "\ = \t\" + unfolding Cong_class_def + using assms(2-3) t by blast + thus ?thesis + using is_Cong_class_def t by blast + qed + + lemma Cong_class_memb_is_arr: + assumes "is_Cong_class \" and "t \ \" + shows "R.arr t" + using assms Cong_class_def is_Cong_class_def Cong_imp_arr(2) by force + + lemma Cong_class_membs_are_Cong: + assumes "is_Cong_class \" and "t \ \" and "t' \ \" + shows "Cong t t'" + using assms Cong_class_def is_Cong_class_def + by (metis CollectD Cong_closure_props(2) Cong_symmetric) + + lemma Cong_class_eqI: + assumes "t \ t'" + shows "\t\ = \t'\" + using assms Cong_class_def + by (metis (full_types) Collect_cong Cong'.intros(1-2) Cong_char) + + lemma Cong_class_eqI': + assumes "is_Cong_class \" and "is_Cong_class \" and "\ \ \ \ {}" + shows "\ = \" + using assms is_Cong_class_def Cong_class_eqI Cong_class_membs_are_Cong + by (metis (no_types, lifting) Int_emptyI) + + lemma is_Cong_classE [elim]: + assumes "is_Cong_class \" + and "\\ \ {}; \t t'. \t \ \; t' \ \\ \ t \ t'; \t t'. \t \ \; t' \ t\ \ t' \ \\ \ T" + shows T + proof - + have \: "\ \ {}" + using assms Cong_class_is_nonempty by simp + moreover have 1: "\t t'. \t \ \; t' \ \\ \ t \ t'" + using assms Cong_class_membs_are_Cong by metis + moreover have "\t t'. \t \ \; t' \ t\ \ t' \ \" + using assms Cong_class_def + by (metis 1 Cong_class_eqI Cong_imp_arr(1) is_Cong_class_def arr_in_Cong_class) + ultimately show ?thesis + using assms by blast + qed + + lemma Cong_class_rep [simp]: + assumes "is_Cong_class \" + shows "\Cong_class_rep \\ = \" + by (metis Cong_class_membs_are_Cong Cong_class_eqI assms is_Cong_class_def rep_in_Cong_class) + + lemma Cong_class_memb_Cong_rep: + assumes "is_Cong_class \" and "t \ \" + shows "Cong t (Cong_class_rep \)" + using assms Cong_class_membs_are_Cong rep_in_Cong_class by simp + + lemma composite_of_normal_arr: + shows "\ R.arr t; u \ \; R.composite_of u t t' \ \ t' \ t" + by (meson Cong'.intros(3) Cong_char R.composite_of_def R.con_implies_arr(2) + ide_closed R.prfx_implies_con Cong_closure_props(2,4) R.sources_composite_of) + + lemma composite_of_arr_normal: + shows "\ arr t; u \ \; R.composite_of t u t' \ \ t' \\<^sub>0 t" + by (meson Cong_closure_props(3) R.composite_of_def ide_closed prfx_closed) + + end + + subsection "Coherent Normal Sub-RTS's" + + text \ + A \emph{coherent} normal sub-RTS is one that satisfies a parallel moves property with respect + to arbitrary transitions. The congruence \\\ induced by a coherent normal sub-RTS is + fully substitutive with respect to consistency and residuation, + and in fact coherence is equivalent to substitutivity in this context. + \ + + locale coherent_normal_sub_rts = normal_sub_rts + + assumes coherent: "\ R.arr t; u \ \; u' \ \; R.sources u = R.sources u'; + R.targets u = R.targets u'; R.sources t = R.sources u \ + \ t \\ u \\<^sub>0 t \\ u'" + + (* + * TODO: Should coherence be part of normality, or is it an additional property that guarantees + * the existence of the quotient? + * + * e.g. see http://nlab-pages.s3.us-east-2.amazonaws.com/nlab/show/normal+subobject + * Maybe also http://www.tac.mta.ca/tac/volumes/36/3/36-03.pdf for recent work. + *) + + context normal_sub_rts + begin + + text \ + The above ``parallel moves'' formulation of coherence is equivalent to the following + formulation, which involves ``opposing spans''. + \ + + lemma coherent_iff: + shows "(\t u u'. R.arr t \ u \ \ \ u' \ \ \ R.sources t = R.sources u \ + R.sources u = R.sources u' \ R.targets u = R.targets u' + \ t \\ u \\<^sub>0 t \\ u') + \ + (\t t' v v' w w'. v \ \ \ v' \ \ \ w \ \ \ w' \ \ \ + R.sources v = R.sources w \ R.sources v' = R.sources w' \ + R.targets w = R.targets w' \ t \\ v \\<^sub>0 t' \\ v' + \ t \\ w \\<^sub>0 t' \\ w')" + proof + assume 1: "\t t' v v' w w'. v \ \ \ v' \ \ \ w \ \ \ w' \ \ \ + R.sources v = R.sources w \ R.sources v' = R.sources w' \ + R.targets w = R.targets w' \ t \\ v \\<^sub>0 t' \\ v' + \ t \\ w \\<^sub>0 t' \\ w'" + show "\t u u'. R.arr t \ u \ \ \ u' \ \ \ R.sources t = R.sources u \ + R.sources u = R.sources u' \ R.targets u = R.targets u' + \ t \\ u \\<^sub>0 t \\ u'" + proof (intro allI impI, elim conjE) + fix t u u' + assume t: "R.arr t" and u: "u \ \" and u': "u' \ \" + and tu: "R.sources t = R.sources u" and sources: "R.sources u = R.sources u'" + and targets: "R.targets u = R.targets u'" + show "t \\ u \\<^sub>0 t \\ u'" + by (metis 1 Cong\<^sub>0_reflexive Resid_along_normal_preserves_Cong\<^sub>0 sources t targets + tu u u') + qed + next + assume 1: "\t u u'. R.arr t \ u \ \ \ u' \ \ \ R.sources t = R.sources u \ + R.sources u = R.sources u' \ R.targets u = R.targets u' + \ t \\ u \\<^sub>0 t \\ u'" + show "\t t' v v' w w'. v \ \ \ v' \ \ \ w \ \ \ w' \ \ \ + R.sources v = R.sources w \ R.sources v' = R.sources w' \ + R.targets w = R.targets w' \ t \\ v \\<^sub>0 t' \\ v' + \ t \\ w \\<^sub>0 t' \\ w'" + proof (intro allI impI, elim conjE) + fix t t' v v' w w' + assume v: "v \ \" and v': "v' \ \" and w: "w \ \" and w': "w' \ \" + and vw: "R.sources v = R.sources w" and v'w': "R.sources v' = R.sources w'" + and ww': "R.targets w = R.targets w'" + and tvt'v': "(t \\ v) \\ (t' \\ v') \ \" and t'v'tv: "(t' \\ v') \\ (t \\ v) \ \" + show "t \\ w \\<^sub>0 t' \\ w'" + proof - + have 3: "R.sources t = R.sources v \ R.sources t' = R.sources v'" + using R.con_imp_coinitial + by (meson Cong\<^sub>0_imp_con tvt'v' t'v'tv + R.coinitial_iff R.arr_resid_iff_con) + have 2: "t \\ w \ t' \\ w'" + using Cong_closure_props + by (metis tvt'v' t'v'tv 3 vw v'w' v v' w w') + obtain z z' where zz': "z \ \ \ z' \ \ \ (t \\ w) \\ z \\<^sub>0 (t' \\ w') \\ z'" + using 2 by auto + have "(t \\ w) \\ z \\<^sub>0 (t \\ w) \\ z'" + proof - + have "R.coinitial ((t \\ w) \\ z) ((t \\ w) \\ z')" + by (metis Cong\<^sub>0_imp_coinitial Cong_imp_arr(1) + Resid_along_normal_preserves_reflects_con R.arr_def R.coinitialI + R.con_imp_common_source Cong_closure_props(3) R.arr_resid_iff_con R.sources_eqI + R.sources_resid ww' zz') + thus ?thesis + apply (intro conjI) + by (metis 1 R.coinitial_iff R.con_imp_coinitial R.arr_resid_iff_con + R.sources_resid zz')+ + qed + hence "(t \\ w) \\ z' \\<^sub>0 (t' \\ w') \\ z'" + using zz' Cong\<^sub>0_transitive Cong\<^sub>0_symmetric by blast + thus ?thesis + using zz' Resid_along_normal_reflects_Cong\<^sub>0 by metis + qed + qed + qed + + end + + context coherent_normal_sub_rts + begin + + text \ + The proof of the substitutivity of \\\ with respect to residuation only uses + coherence in the ``opposing spans'' form. + \ + + lemma coherent': + assumes "v \ \" and "v' \ \" and "w \ \" and "w' \ \" + and "R.sources v = R.sources w" and "R.sources v' = R.sources w'" + and "R.targets w = R.targets w'" and "t \\ v \\<^sub>0 t' \\ v'" + shows "t \\ w \\<^sub>0 t' \\ w'" + using assms coherent coherent_iff by metis (* 6 sec *) + + text \ + The relation \\\ is substitutive with respect to both arguments of residuation. + \ + + lemma Cong_subst: + assumes "t \ t'" and "u \ u'" and "t \ u" and "R.sources t' = R.sources u'" + shows "t' \ u'" and "t \\ u \ t' \\ u'" + proof - + obtain v v' where vv': "v \ \ \ v' \ \ \ t \\ v \\<^sub>0 t' \\ v'" + using assms by auto + obtain w w' where ww': "w \ \ \ w' \ \ \ u \\ w \\<^sub>0 u' \\ w'" + using assms by auto + let ?x = "t \\ v" and ?x' = "t' \\ v'" + let ?y = "u \\ w" and ?y' = "u' \\ w'" + have xx': "?x \\<^sub>0 ?x'" + using assms vv' by blast + have yy': "?y \\<^sub>0 ?y'" + using assms ww' by blast + have 1: "t \\ w \\<^sub>0 t' \\ w'" + proof - + have "R.sources v = R.sources w" + by (metis (no_types, lifting) Cong\<^sub>0_imp_con R.arr_resid_iff_con assms(3) + R.con_imp_common_source R.con_implies_arr(2) R.sources_eqI ww' xx') + moreover have "R.sources v' = R.sources w'" + by (metis (no_types, lifting) assms(4) R.coinitial_iff R.con_imp_coinitial + Cong\<^sub>0_imp_con R.arr_resid_iff_con ww' xx') + moreover have "R.targets w = R.targets w'" + by (metis Cong\<^sub>0_implies_Cong Cong\<^sub>0_imp_coinitial Cong_imp_arr(1) + R.arr_resid_iff_con R.sources_resid ww') + ultimately show ?thesis + using assms vv' ww' + by (intro coherent' [of v v' w w' t]) auto + qed + have 2: "t' \\ w' \ u' \\ w'" + using assms 1 ww' + by (metis Cong\<^sub>0_subst_left(1) Cong\<^sub>0_subst_right(1) Resid_along_normal_preserves_reflects_con + R.arr_resid_iff_con R.coinitial_iff R.con_imp_coinitial elements_are_arr) + thus 3: "t' \ u'" + using ww' R.cube by force + have "t \\ u \ ((t \\ u) \\ (w \\ u)) \\ (?y' \\ ?y)" + proof - + have "t \\ u \ (t \\ u) \\ (w \\ u)" + by (metis Cong_closure_props(4) assms(3) R.con_imp_coinitial + elements_are_arr forward_stable R.arr_resid_iff_con R.con_implies_arr(1) + R.sources_resid ww') + also have "... \ ((t \\ u) \\ (w \\ u)) \\ (?y' \\ ?y)" + by (metis Cong\<^sub>0_imp_con Cong_closure_props(4) Cong_imp_arr(2) + R.arr_resid_iff_con calculation R.con_implies_arr(2) R.targets_resid_sym + R.sources_resid ww') + finally show ?thesis by simp + qed + also have "... \ (((t \\ w) \\ ?y) \\ (?y' \\ ?y))" + using ww' + by (metis Cong_imp_arr(2) Cong_reflexive calculation R.cube) + also have "... \ (((t' \\ w') \\ ?y) \\ (?y' \\ ?y))" + using 1 Cong\<^sub>0_subst_left(2) [of "t \\ w" "(t' \\ w')" ?y] + Cong\<^sub>0_subst_left(2) [of "(t \\ w) \\ ?y" "(t' \\ w') \\ ?y" "?y' \\ ?y"] + by (meson 2 Cong\<^sub>0_implies_Cong Cong\<^sub>0_subst_Con Cong_imp_arr(2) + R.arr_resid_iff_con calculation ww') + also have "... \ ((t' \\ w') \\ ?y') \\ (?y \\ ?y')" + using 2 Cong\<^sub>0_implies_Cong Cong\<^sub>0_subst_right(2) ww' by presburger + also have 4: "... \ (t' \\ u') \\ (w' \\ u')" + using 2 ww' + by (metis Cong\<^sub>0_imp_con Cong_closure_props(4) Cong_symmetric R.cube R.sources_resid) + also have "... \ t' \\ u'" + using ww' 3 4 + by (metis Cong_closure_props(4) Cong_imp_arr(2) Cong_symmetric R.con_imp_coinitial + R.con_implies_arr(2) forward_stable R.sources_resid R.arr_resid_iff_con) + finally show "t \\ u \ t' \\ u'" by simp + qed + + lemma Cong_subst_con: + assumes "R.sources t = R.sources u" and "R.sources t' = R.sources u'" and "t \ t'" and "u \ u'" + shows "t \ u \ t' \ u'" + using assms by (meson Cong_subst(1) Cong_symmetric) + + lemma Cong\<^sub>0_composite_of_arr_normal: + assumes "R.composite_of t u t'" and "u \ \" + shows "t' \\<^sub>0 t" + using assms backward_stable R.composite_of_def ide_closed by blast + + lemma Cong_composite_of_normal_arr: + assumes "R.composite_of u t t'" and "u \ \" + shows "t' \ t" + using assms + by (meson Cong_closure_props(2-4) R.arr_composite_of ide_closed R.composite_of_def + R.sources_composite_of) + + end + + context normal_sub_rts + begin + + text \ + Coherence is not an arbitrary property: here we show that substitutivity of + congruence in residuation is equivalent to the ``opposing spans'' form of coherence. + \ + + lemma Cong_subst_iff_coherent': + shows "(\t t' u u'. t \ t' \ u \ u' \ t \ u \ R.sources t' = R.sources u' + \ t' \ u' \ t \\ u \ t' \\ u') + \ + (\t t' v v' w w'. v \ \ \ v' \ \ \ w \ \ \ w' \ \ \ + R.sources v = R.sources w \ R.sources v' = R.sources w' \ + R.targets w = R.targets w' \ t \\ v \\<^sub>0 t' \\ v' + \ t \\ w \\<^sub>0 t' \\ w')" + proof + assume 1: "\t t' u u'. t \ t' \ u \ u' \ t \ u \ R.sources t' = R.sources u' + \ t' \ u' \ t \\ u \ t' \\ u'" + show "\t t' v v' w w'. v \ \ \ v' \ \ \ w \ \ \ w' \ \ \ + R.sources v = R.sources w \ R.sources v' = R.sources w' \ + R.targets w = R.targets w' \ t \\ v \\<^sub>0 t' \\ v' + \ t \\ w \\<^sub>0 t' \\ w'" + proof (intro allI impI, elim conjE) + fix t t' v v' w w' + assume v: "v \ \" and v': "v' \ \" and w: "w \ \" and w': "w' \ \" + and sources_vw: "R.sources v = R.sources w" + and sources_v'w': "R.sources v' = R.sources w'" + and targets_ww': "R.targets w = R.targets w'" + and tt': "(t \\ v) \\ (t' \\ v') \ \" and t't: "(t' \\ v') \\ (t \\ v) \ \" + show "t \\ w \\<^sub>0 t' \\ w'" + proof - + have 2: "\t t' u u'. \t \ t'; u \ u'; t \ u; R.sources t' = R.sources u'\ + \ t' \ u' \ t \\ u \ t' \\ u'" + using 1 by blast + have 3: "t \\ w \ t \\ v \ t' \\ w' \ t' \\ v'" + by (metis tt' t't sources_vw sources_v'w' Cong\<^sub>0_subst_right(2) Cong_closure_props(4) + Cong_def R.arr_resid_iff_con Cong_closure_props(3) Cong_imp_arr(1) + normal_is_Cong_closed v w v' w') + have "(t \\ w) \\ (t' \\ w') \ (t \\ v) \\ (t' \\ v')" + using 2 [of "t \\ w" "t \\ v" "t' \\ w'" "t' \\ v'"] 3 + by (metis tt' t't targets_ww' 1 Cong\<^sub>0_imp_con Cong_imp_arr(1) Cong_symmetric + R.arr_resid_iff_con R.sources_resid) + moreover have "(t' \\ w') \\ (t \\ w) \ (t' \\ v') \\ (t \\ v)" + using 2 3 + by (metis tt' t't targets_ww' Cong\<^sub>0_imp_con Cong_symmetric + Cong_imp_arr(1) R.arr_resid_iff_con R.sources_resid) + ultimately show ?thesis + by (meson tt' t't normal_is_Cong_closed Cong_symmetric) + qed + qed + next + assume 1: "\t t' v v' w w'. v \ \ \ v' \ \ \ w \ \ \ w' \ \ \ + R.sources v = R.sources w \ R.sources v' = R.sources w' \ + R.targets w = R.targets w' \ t \\ v \\<^sub>0 t' \\ v' + \ t \\ w \\<^sub>0 t' \\ w'" + show "\t t' u u'. t \ t' \ u \ u' \ t \ u \ R.sources t' = R.sources u' + \ t' \ u' \ t \\ u \ t' \\ u'" + proof (intro allI impI, elim conjE, intro conjI) + have *: "\t t' v v' w w'. \v \ \; v' \ \; w \ \; w' \ \; + R.sources v = R.sources w; R.sources v' = R.sources w'; + R.targets v = R.targets v'; R.targets w = R.targets w'; + t \\ v \\<^sub>0 t' \\ v'\ + \ t \\ w \\<^sub>0 t' \\ w'" + using 1 by metis + fix t t' u u' + assume tt': "t \ t'" and uu': "u \ u'" and con: "t \ u" + and t'u': "R.sources t' = R.sources u'" + obtain v v' where vv': "v \ \ \ v' \ \ \ t \\ v \\<^sub>0 t' \\ v'" + using tt' by auto + obtain w w' where ww': "w \ \ \ w' \ \ \ u \\ w \\<^sub>0 u' \\ w'" + using uu' by auto + let ?x = "t \\ v" and ?x' = "t' \\ v'" + let ?y = "u \\ w" and ?y' = "u' \\ w'" + have xx': "?x \\<^sub>0 ?x'" + using tt' vv' by blast + have yy': "?y \\<^sub>0 ?y'" + using uu' ww' by blast + have 1: "t \\ w \\<^sub>0 t' \\ w'" + proof - + have "R.sources v = R.sources w \ R.sources v' = R.sources w'" + proof + show "R.sources v' = R.sources w'" + using Cong\<^sub>0_imp_con R.arr_resid_iff_con R.coinitial_iff R.con_imp_coinitial + t'u' vv' ww' + by metis + show "R.sources v = R.sources w" + by (metis con elements_are_arr R.not_arr_null R.null_is_zero(2) R.conI + R.con_imp_common_source rts.sources_eqI R.rts_axioms vv' ww') + qed + moreover have "R.targets v = R.targets v' \ R.targets w = R.targets w'" + by (metis Cong\<^sub>0_imp_coinitial Cong\<^sub>0_imp_con R.arr_resid_iff_con + R.con_implies_arr(2) R.sources_resid vv' ww') + ultimately show ?thesis + using vv' ww' xx' + by (intro * [of v v' w w' t t']) auto + qed + have 2: "t' \\ w' \ u' \\ w'" + using 1 tt' ww' + by (meson Cong\<^sub>0_imp_con Cong\<^sub>0_subst_Con R.arr_resid_iff_con con R.con_imp_coinitial + R.con_implies_arr(2) resid_along_elem_preserves_con) + thus 3: "t' \ u'" + using ww' R.cube by force + have "t \\ u \ (t \\ u) \\ (w \\ u)" + by (metis Cong_closure_props(4) R.arr_resid_iff_con con R.con_imp_coinitial + elements_are_arr forward_stable R.con_implies_arr(2) R.sources_resid ww') + also have "(t \\ u) \\ (w \\ u) \ ((t \\ u) \\ (w \\ u)) \\ (?y' \\ ?y)" + using yy' + by (metis Cong\<^sub>0_imp_con Cong_closure_props(4) Cong_imp_arr(2) + R.arr_resid_iff_con calculation R.con_implies_arr(2) R.sources_resid R.targets_resid_sym) + also have "... \ (((t \\ w) \\ ?y) \\ (?y' \\ ?y))" + using ww' + by (metis Cong_imp_arr(2) Cong_reflexive calculation R.cube) + also have "... \ (((t' \\ w') \\ ?y) \\ (?y' \\ ?y))" + proof - + have "((t \\ w) \\ ?y) \\ (?y' \\ ?y) \\<^sub>0 ((t' \\ w') \\ ?y) \\ (?y' \\ ?y)" + using 1 2 Cong\<^sub>0_subst_left(2) + by (meson Cong\<^sub>0_subst_Con calculation Cong_imp_arr(2) R.arr_resid_iff_con ww') + thus ?thesis + using Cong\<^sub>0_implies_Cong by presburger + qed + also have "... \ ((t' \\ w') \\ ?y') \\ (?y \\ ?y')" + by (meson "2" Cong\<^sub>0_implies_Cong Cong\<^sub>0_subst_right(2) ww') + also have 4: "... \ (t' \\ u') \\ (w' \\ u')" + using 2 ww' + by (metis Cong\<^sub>0_imp_con Cong_closure_props(4) Cong_symmetric R.cube R.sources_resid) + also have "... \ t' \\ u'" + using ww' 2 3 4 + by (metis Cong'.intros(1) Cong'.intros(4) Cong_char Cong_imp_arr(2) + R.arr_resid_iff_con forward_stable R.con_imp_coinitial R.sources_resid + R.con_implies_arr(2)) + finally show "t \\ u \ t' \\ u'" by simp + qed + qed + + end + + subsection "Quotient by Coherent Normal Sub-RTS" + + text \ + We now define the quotient of an RTS by a coherent normal sub-RTS and show that it is + an extensional RTS. + \ + + locale quotient_by_coherent_normal = + R: rts + + N: coherent_normal_sub_rts + begin + + definition Resid (infix "\\\\" 70) + where "\ \\\\ \ \ + if N.is_Cong_class \ \ N.is_Cong_class \ \ (\t u. t \ \ \ u \ \ \ t \ u) + then N.Cong_class + (fst (SOME tu. fst tu \ \ \ snd tu \ \ \ fst tu \ snd tu) \\ + snd (SOME tu. fst tu \ \ \ snd tu \ \ \ fst tu \ snd tu)) + else {}" + + sublocale partial_magma Resid + using N.Cong_class_is_nonempty Resid_def + by unfold_locales metis + + lemma is_partial_magma: + shows "partial_magma Resid" + .. + + lemma null_char: + shows "null = {}" + using N.Cong_class_is_nonempty Resid_def + by (metis null_is_zero(2)) + + lemma Resid_by_members: + assumes "N.is_Cong_class \" and "N.is_Cong_class \" and "t \ \" and "u \ \" and "t \ u" + shows "\ \\\\ \ = \t \\ u\" + using assms Resid_def someI_ex [of "\tu. fst tu \ \ \ snd tu \ \ \ fst tu \ snd tu"] + apply simp + by (meson N.Cong_class_membs_are_Cong N.Cong_class_eqI N.Cong_subst(2) + R.coinitial_iff R.con_imp_coinitial) + + abbreviation Con (infix "\\\" 50) + where "\ \\\ \ \ \ \\\\ \ \ {}" + + lemma Con_char: + shows "\ \\\ \ \ + N.is_Cong_class \ \ N.is_Cong_class \ \ (\t u. t \ \ \ u \ \ \ t \ u)" + by (metis (no_types, opaque_lifting) N.Cong_class_is_nonempty N.is_Cong_classI + Resid_def Resid_by_members R.arr_resid_iff_con) + + lemma Con_sym: + assumes "Con \ \" + shows "Con \ \" + using assms Con_char R.con_sym by meson + + lemma is_Cong_class_Resid: + assumes "\ \\\ \" + shows "N.is_Cong_class (\ \\\\ \)" + using assms Con_char Resid_by_members R.arr_resid_iff_con N.is_Cong_classI by auto + + lemma Con_witnesses: + assumes "\ \\\ \" and "t \ \" and "u \ \" + shows "\v w. v \ \ \ w \ \ \ t \\ v \ u \\ w" + proof - + have 1: "N.is_Cong_class \ \ N.is_Cong_class \ \ (\t u. t \ \ \ u \ \ \ t \ u)" + using assms Con_char by simp + obtain t' u' where t'u': "t' \ \ \ u' \ \ \ t' \ u'" + using 1 by auto + have 2: "t' \ t \ u' \ u" + using assms 1 t'u' N.Cong_class_membs_are_Cong by auto + obtain v v' where vv': "v \ \ \ v' \ \ \ t' \\ v \\<^sub>0 t \\ v'" + using 2 by auto + obtain w w' where ww': "w \ \ \ w' \ \ \ u' \\ w \\<^sub>0 u \\ w'" + using 2 by auto + have 3: "w \ v" + by (metis R.arr_resid_iff_con R.con_def R.con_imp_coinitial R.ex_un_null + N.elements_are_arr R.null_is_zero(2) N.resid_along_elem_preserves_con t'u' vv' ww') + have "R.seq v (w \\ v)" + by (simp add: N.elements_are_arr R.seq_def 3 vv') + obtain x where x: "R.composite_of v (w \\ v) x" + using N.composite_closed_left \R.seq v (w \ v)\ vv' by blast + obtain x' where x': "R.composite_of v' (w \\ v) x'" + using x vv' N.composite_closed_left + by (metis N.Cong\<^sub>0_implies_Cong N.Cong\<^sub>0_imp_coinitial N.Cong_imp_arr(1) + R.composable_def R.composable_imp_seq R.con_implies_arr(2) + R.seq_def R.sources_resid R.arr_resid_iff_con) + have *: "t' \\ x \\<^sub>0 t \\ x'" + by (metis N.coherent' N.composite_closed N.forward_stable R.con_imp_coinitial + R.targets_composite_of 3 R.con_sym R.sources_composite_of vv' ww' x x') + obtain y where y: "R.composite_of w (v \\ w) y" + using x vv' ww' + by (metis R.arr_resid_iff_con R.composable_def R.composable_imp_seq + R.con_imp_coinitial R.seq_def R.sources_resid N.elements_are_arr + N.forward_stable N.composite_closed_left) + obtain y' where y': "R.composite_of w' (v \\ w) y'" + using y ww' + by (metis N.Cong\<^sub>0_imp_coinitial N.Cong_closure_props(3) N.Cong_imp_arr(1) + R.composable_def R.composable_imp_seq R.con_implies_arr(2) R.seq_def + R.sources_resid N.composite_closed_left R.arr_resid_iff_con) + have **: "u' \\ y \\<^sub>0 u \\ y'" + by (metis N.composite_closed N.forward_stable R.con_imp_coinitial R.targets_composite_of + \w \ v\ N.coherent' R.sources_composite_of vv' ww' y y') + have 4: "x \ \ \ y \ \" + using x y vv' ww' * ** + by (metis 3 N.composite_closed N.forward_stable R.con_imp_coinitial R.con_sym) + have "t \\ x' \ u \\ y'" + proof - + have "t \\ x' \\<^sub>0 t' \\ x" + using * by simp + moreover have "t' \\ x \ u' \\ y" + proof - + have "t' \\ x \ u' \\ x" + using t'u' vv' ww' 4 * + by (metis N.Resid_along_normal_preserves_reflects_con N.elements_are_arr + R.coinitial_iff R.con_imp_coinitial R.arr_resid_iff_con) + moreover have "u' \\ x \\<^sub>0 u' \\ y" + using ww' x y + by (metis 4 N.Cong\<^sub>0_imp_coinitial N.Cong\<^sub>0_imp_con N.Cong\<^sub>0_transitive + N.coherent' N.factor_closed(2) R.sources_composite_of + R.targets_composite_of R.targets_resid_sym) + ultimately show ?thesis + using N.Cong\<^sub>0_subst_right by blast + qed + moreover have "u' \\ y \\<^sub>0 u \\ y'" + using ** R.con_sym by simp + ultimately show ?thesis + using N.Cong\<^sub>0_subst_Con by auto + qed + moreover have "x' \ \ \ y' \ \" + using x' y' vv' ww' + by (metis N.Cong_composite_of_normal_arr N.Cong_imp_arr(2) N.composite_closed + R.con_imp_coinitial N.forward_stable R.arr_resid_iff_con) + ultimately show ?thesis by auto + qed + + abbreviation Arr + where "Arr \ \ Con \ \" + + lemma Arr_Resid: + assumes "Con \ \" + shows "Arr (\ \\\\ \)" + by (metis Con_char N.Cong_class_memb_is_arr R.arrE N.rep_in_Cong_class + assms is_Cong_class_Resid) + + lemma Cube: + assumes "Con (\ \\\\ \) (\ \\\\ \)" + shows "(\ \\\\ \) \\\\ (\ \\\\ \) = (\ \\\\ \) \\\\ (\ \\\\ \)" + proof - + obtain t u where tu: "t \ \ \ u \ \ \ t \ u \ \ \\\\ \ = \t \\ u\" + using assms + by (metis Con_char N.Cong_class_is_nonempty R.con_sym Resid_by_members) + obtain t' v where t'v: "t' \ \ \ v \ \ \ t' \ v \ \ \\\\ \ = \t' \\ v\" + using assms + by (metis Con_char N.Cong_class_is_nonempty Resid_by_members Con_sym) + have tt': "t \ t'" + using assms + by (metis N.Cong_class_membs_are_Cong N.Cong_class_is_nonempty Resid_def t'v tu) + obtain w w' where ww': "w \ \ \ w' \ \ \ t \\ w \\<^sub>0 t' \\ w'" + using tu t'v tt' by auto + have 1: "\ \\\\ \ = \u \\ t\ \ \ \\\\ \ = \v \\ t'\" + by (metis Con_char N.Cong_class_is_nonempty R.con_sym Resid_by_members assms t'v tu) + obtain x x' where xx': "x \ \ \ x' \ \ \ (u \\ t) \\ x \ (v \\ t') \\ x'" + using 1 Con_witnesses [of "\ \\\\ \" "\ \\\\ \" "u \\ t" "v \\ t'"] + by (metis N.arr_in_Cong_class R.con_sym t'v tu assms Con_sym R.arr_resid_iff_con) + have "R.seq t x" + by (metis R.arr_resid_iff_con R.coinitial_iff R.con_imp_coinitial R.seqI + R.sources_resid xx') + have "R.seq t' x'" + by (metis R.arr_resid_iff_con R.sources_resid R.coinitialE R.con_imp_coinitial + R.seqI xx') + obtain tx where tx: "R.composite_of t x tx" + using xx' \R.seq t x\ N.composite_closed_right [of x t] R.composable_def by auto + obtain t'x' where t'x': "R.composite_of t' x' t'x'" + using xx' \R.seq t' x'\ N.composite_closed_right [of x' t'] R.composable_def by auto + let ?tx_w = "tx \\ w" and ?t'x'_w' = "t'x' \\ w'" + let ?w_tx = "(w \\ t) \\ x" and ?w'_t'x' = "(w' \\ t') \\ x'" + let ?u_tx = "(u \\ t) \\ x" and ?v_t'x' = "(v \\ t') \\ x'" + let ?u_w = "u \\ w" and ?v_w' = "v \\ w'" + let ?w_u = "w \\ u" and ?w'_v = "w' \\ v" + have w_tx_in_\: "?w_tx \ \" + using tx ww' xx' R.con_composite_of_iff [of t x tx w] + by (metis (full_types) N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_left(1) + N.forward_stable R.null_is_zero(2) R.con_imp_coinitial R.conI R.con_sym) + have w'_t'x'_in_\: "?w'_t'x' \ \" + using t'x' ww' xx' R.con_composite_of_iff [of t' x' t'x' w'] + by (metis (full_types) N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_left(1) + R.con_sym N.forward_stable R.null_is_zero(2) R.con_imp_coinitial R.conI) + have 2: "?tx_w \\<^sub>0 ?t'x'_w'" + proof - + have "?tx_w \\<^sub>0 t \\ w" + using t'x' tx ww' xx' N.Cong\<^sub>0_composite_of_arr_normal [of t x tx] N.Cong\<^sub>0_subst_left(2) + by (metis N.Cong\<^sub>0_transitive R.conI) + also have "t \\ w \\<^sub>0 t' \\ w'" + using ww' by blast + also have "t' \\ w' \\<^sub>0 ?t'x'_w'" + using t'x' tx ww' xx' N.Cong\<^sub>0_composite_of_arr_normal [of t' x' t'x'] N.Cong\<^sub>0_subst_left(2) + by (metis N.Cong\<^sub>0_transitive R.conI) + finally show ?thesis by blast + qed + obtain z where z: "R.composite_of ?tx_w (?t'x'_w' \\ ?tx_w) z" + by (metis "2" R.arr_resid_iff_con R.con_implies_arr(2) N.elements_are_arr + N.composite_closed_right R.seqI R.sources_resid) + obtain z' where z': "R.composite_of ?t'x'_w' (?tx_w \\ ?t'x'_w') z'" + by (metis "2" R.arr_resid_iff_con R.con_implies_arr(2) N.elements_are_arr + N.composite_closed_right R.seqI R.sources_resid) + have 3: "z \\<^sub>0 z'" + using 2 N.diamond_commutes_upto_Cong\<^sub>0 N.Cong\<^sub>0_imp_con z z' by blast + have "R.targets z = R.targets z'" + by (metis R.targets_resid_sym z z' R.targets_composite_of R.conI) + have Con_z_uw: "z \ ?u_w" + proof - + have "?tx_w \ ?u_w" + by (meson 3 N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_left(1) + R.bounded_imp_con R.con_implies_arr(1) R.con_imp_coinitial + N.resid_along_elem_preserves_con tu tx ww' xx' z z' R.arr_resid_iff_con) + thus ?thesis + using 2 N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_left(1) z by blast + qed + moreover have Con_z'_vw': "z' \ ?v_w'" + proof - + have "?t'x'_w' \ ?v_w'" + by (meson 3 N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_left(1) + R.bounded_imp_con t'v t'x' ww' xx' z z' R.con_imp_coinitial + N.resid_along_elem_preserves_con R.arr_resid_iff_con R.con_implies_arr(1)) + thus ?thesis + by (meson 2 N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_left(1) z') + qed + moreover have Con_z_vw': "z \ ?v_w'" + using 3 Con_z'_vw' N.Cong\<^sub>0_subst_left(1) by blast + moreover have *: "?u_w \\ z \ ?v_w' \\ z" + proof - + obtain y where y: "R.composite_of (w \\ tx) (?t'x'_w' \\ ?tx_w) y" + by (metis 2 R.arr_resid_iff_con R.composable_def R.composable_imp_seq + R.con_imp_coinitial N.elements_are_arr N.composite_closed_right + R.seq_def R.targets_resid_sym ww' z N.forward_stable) + obtain y' where y': "R.composite_of (w' \\ t'x') (?tx_w \\ ?t'x'_w') y'" + by (metis 2 R.arr_resid_iff_con R.composable_def R.composable_imp_seq + R.con_imp_coinitial N.elements_are_arr N.composite_closed_right + R.targets_resid_sym ww' z' R.seq_def N.forward_stable) + have y_comp: "R.composite_of (w \\ tx) ((t'x' \\ w') \\ (tx \\ w)) y" + using y by simp + have y_in_normal: "y \ \" + by (metis 2 Con_z_uw R.arr_iff_has_source R.arr_resid_iff_con N.composite_closed + R.con_imp_coinitial R.con_implies_arr(1) N.forward_stable + R.sources_composite_of ww' y_comp z) + have y_coinitial: "R.coinitial y (u \\ tx)" + using y R.coinitial_def + by (metis Con_z_uw R.con_def R.con_prfx_composite_of(2) R.con_sym R.cube + R.sources_composite_of R.con_imp_common_source z) + have y_con: "y \ u \\ tx" + using y_in_normal y_coinitial + by (metis R.coinitial_iff N.elements_are_arr N.forward_stable + R.arr_resid_iff_con) + have A: "?u_w \\ z \ (u \\ tx) \\ y" + proof - + have "(u \\ tx) \\ y \ ((u \\ tx) \\ (w \\ tx)) \\ (?t'x'_w' \\ ?tx_w)" + using y_comp y_con + R.resid_composite_of(3) [of "w \\ tx" "?t'x'_w' \\ ?tx_w" y "u \\ tx"] + by simp + also have "((u \\ tx) \\ (w \\ tx)) \\ (?t'x'_w' \\ ?tx_w) \ ?u_w \\ z" + by (metis Con_z_uw R.resid_composite_of(3) z R.cube) + finally show ?thesis by blast + qed + have y'_comp: "R.composite_of (w' \\ t'x') (?tx_w \\ ?t'x'_w') y'" + using y' by simp + have y'_in_normal: "y' \ \" + by (metis 2 Con_z'_vw' R.arr_iff_has_source R.arr_resid_iff_con + N.composite_closed R.con_imp_coinitial R.con_implies_arr(1) + N.forward_stable R.sources_composite_of ww' y'_comp z') + have y'_coinitial: "R.coinitial y' (v \\ t'x')" + using y' R.coinitial_def + by (metis Con_z'_vw' R.arr_resid_iff_con R.composite_ofE R.con_imp_coinitial + R.con_implies_arr(1) R.cube R.prfx_implies_con R.resid_composite_of(1) + R.sources_resid z') + have y'_con: "y' \ v \\ t'x'" + using y'_in_normal y'_coinitial + by (metis R.coinitial_iff N.elements_are_arr N.forward_stable + R.arr_resid_iff_con) + have B: "?v_w' \\ z' \ (v \\ t'x') \\ y'" + proof - + have "(v \\ t'x') \\ y' \ ((v \\ t'x') \\ (w' \\ t'x')) \\ (?tx_w \\ ?t'x'_w')" + using y'_comp y'_con + R.resid_composite_of(3) [of "w' \\ t'x'" "?tx_w \\ ?t'x'_w'" y' "v \\ t'x'"] + by blast + also have "((v \\ t'x') \\ (w' \\ t'x')) \\ (?tx_w \\ ?t'x'_w') \ ?v_w' \\ z'" + by (metis Con_z'_vw' R.cube R.resid_composite_of(3) z') + finally show ?thesis by blast + qed + have C: "u \\ tx \ v \\ t'x'" + using tx t'x' xx' R.con_sym R.cong_subst_right(1) R.resid_composite_of(3) + by (meson R.coinitial_iff R.arr_resid_iff_con y'_coinitial y_coinitial) + have D: "y \\<^sub>0 y'" + proof - + have "y \\<^sub>0 w \\ tx" + using 2 N.Cong\<^sub>0_composite_of_arr_normal y_comp by blast + also have "w \\ tx \\<^sub>0 w' \\ t'x'" + proof - + have "w \\ tx \ \ \ w' \\ t'x' \ \" + using N.factor_closed(1) y_comp y_in_normal y'_comp y'_in_normal by blast + moreover have "R.coinitial (w \\ tx) (w' \\ t'x')" + by (metis C R.coinitial_def R.con_implies_arr(2) N.elements_are_arr + R.sources_resid calculation R.con_imp_coinitial R.arr_resid_iff_con y_con) + ultimately show ?thesis + by (meson R.arr_resid_iff_con R.con_imp_coinitial N.forward_stable + N.elements_are_arr) + qed + also have "w' \\ t'x' \\<^sub>0 y'" + using 2 N.Cong\<^sub>0_composite_of_arr_normal y'_comp by blast + finally show ?thesis by blast + qed + have par_y_y': "R.sources y = R.sources y' \ R.targets y = R.targets y'" + using D N.Cong\<^sub>0_imp_coinitial R.targets_composite_of y'_comp y_comp z z' + \R.targets z = R.targets z'\ + by presburger + have E: "(u \\ tx) \\ y \ (v \\ t'x') \\ y'" + proof - + have "(u \\ tx) \\ y \ (v \\ t'x') \\ y" + using C N.Resid_along_normal_preserves_reflects_con R.coinitial_iff + y_coinitial y_in_normal + by presburger + moreover have "(v \\ t'x') \\ y \\<^sub>0 (v \\ t'x') \\ y'" + using par_y_y' N.coherent R.coinitial_iff y'_coinitial y'_in_normal y_in_normal + by presburger + ultimately show ?thesis + using N.Cong\<^sub>0_subst_right(1) by blast + qed + hence "?u_w \\ z \ ?v_w' \\ z'" + proof - + have "(u \\ tx) \\ y \ ?u_w \\ z" + using A by simp + moreover have "(u \\ tx) \\ y \ (v \\ t'x') \\ y'" + using E by blast + moreover have "(v \\ t'x') \\ y' \ ?v_w' \\ z'" + using B R.cong_symmetric by blast + moreover have "R.sources ((u \\ w) \\ z) = R.sources ((v \\ w') \\ z')" + by (simp add: Con_z'_vw' Con_z_uw R.con_sym \R.targets z = R.targets z'\) + ultimately show ?thesis + by (meson N.Cong\<^sub>0_subst_Con N.ide_closed) + qed + moreover have "?v_w' \\ z' \ ?v_w' \\ z" + by (meson 3 Con_z_vw' N.CongI N.Cong\<^sub>0_subst_right(2) R.con_sym) + moreover have "R.sources ((v \\ w') \\ z) = R.sources ((u \\ w) \\ z)" + by (metis R.con_implies_arr(1) R.sources_resid calculation(1) calculation(2) + N.Cong_imp_arr(2) R.arr_resid_iff_con) + ultimately show ?thesis + by (metis N.Cong_reflexive N.Cong_subst(1) R.con_implies_arr(1)) + qed + ultimately have **: "?v_w' \\ z \ ?u_w \\ z \ + (?v_w' \\ z) \\ (?u_w \\ z) = (?v_w' \\ ?u_w) \\ (z \\ ?u_w)" + by (meson R.con_sym R.cube) + have Cong_t_z: "t \ z" + by (metis 2 N.Cong\<^sub>0_composite_of_arr_normal N.Cong_closure_props(2-3) + N.Cong_closure_props(4) N.Cong_imp_arr(2) R.coinitial_iff R.con_imp_coinitial + tx ww' xx' z R.arr_resid_iff_con) + have Cong_u_uw: "u \ ?u_w" + by (meson Con_z_uw N.Cong_closure_props(4) R.coinitial_iff R.con_imp_coinitial + ww' R.arr_resid_iff_con) + have Cong_v_vw': "v \ ?v_w'" + by (meson Con_z_vw' N.Cong_closure_props(4) R.coinitial_iff ww' R.con_imp_coinitial + R.arr_resid_iff_con) + have \: "N.is_Cong_class \ \ z \ \" + by (metis (no_types, lifting) Cong_t_z N.Cong_class_eqI N.Cong_class_is_nonempty + N.Cong_class_memb_Cong_rep N.Cong_class_rep N.Cong_imp_arr(2) N.arr_in_Cong_class + tu assms Con_char) + have \: "N.is_Cong_class \ \ ?u_w \ \" + by (metis Con_char Con_z_uw Cong_u_uw Int_iff N.Cong_class_eqI' N.Cong_class_eqI + N.arr_in_Cong_class R.con_implies_arr(2) N.is_Cong_classI tu assms empty_iff) + have \: "N.is_Cong_class \ \ ?v_w' \ \" + by (metis Con_char Con_z_vw' Cong_v_vw' Int_iff N.Cong_class_eqI' N.Cong_class_eqI + N.arr_in_Cong_class R.con_implies_arr(2) N.is_Cong_classI t'v assms empty_iff) + show "(\ \\\\ \) \\\\ (\ \\\\ \) = (\ \\\\ \) \\\\ (\ \\\\ \)" + proof - + have "(\ \\\\ \) \\\\ (\ \\\\ \) = \(?v_w' \\ z) \\ (?u_w \\ z)\" + using \ \ \ * Resid_by_members + by (metis ** Con_char N.arr_in_Cong_class R.arr_resid_iff_con assms R.con_implies_arr(2)) + moreover have "(\ \\\\ \) \\\\ (\ \\\\ \) = \(?v_w' \\ ?u_w) \\ (z \\ ?u_w)\" + using Resid_by_members [of \ \ ?v_w' ?u_w] Resid_by_members [of \ \ z ?u_w] + Resid_by_members [of "\ \\\\ \" "\ \\\\ \" "?v_w' \\ ?u_w" "z \\ ?u_w"] + by (metis \ \ \ * ** N.arr_in_Cong_class R.con_implies_arr(2) N.is_Cong_classI + R.resid_reflects_con R.arr_resid_iff_con) + ultimately show ?thesis + using ** by simp + qed + qed + + sublocale residuation Resid + using null_char Con_sym Arr_Resid Cube + by unfold_locales metis+ + + lemma is_residuation: + shows "residuation Resid" + .. + + lemma arr_char: + shows "arr \ \ N.is_Cong_class \" + by (metis N.is_Cong_class_def arrI not_arr_null null_char N.Cong_class_memb_is_arr + Con_char R.arrE arrE arr_resid conI) + + lemma ide_char: + shows "ide \ \ arr \ \ \ \ \ \ {}" + proof + show "ide \ \ arr \ \ \ \ \ \ {}" + apply (elim ideE) + by (metis Con_char N.Cong\<^sub>0_reflexive Resid_by_members disjoint_iff null_char + N.arr_in_Cong_class R.arrE R.arr_resid arr_resid conE) + show "arr \ \ \ \ \ \ {} \ ide \" + proof - + assume \: "arr \ \ \ \ \ \ {}" + obtain u where u: "R.arr u \ u \ \ \ \" + using \ arr_char + by (metis IntI N.Cong_class_memb_is_arr disjoint_iff) + show ?thesis + by (metis IntD1 IntD2 N.Cong_class_eqI N.Cong_closure_props(4) N.arr_in_Cong_class + N.is_Cong_classI Resid_by_members \ arrE arr_char disjoint_iff ideI + N.Cong_class_eqI' R.arrE u) + qed + qed + + lemma ide_char': + shows "ide \ \ arr \ \ \ \ \" + by (metis Int_absorb2 Int_emptyI N.Cong_class_memb_Cong_rep N.Cong_closure_props(1) + ide_char not_arr_null null_char N.normal_is_Cong_closed arr_char subsetI) + + lemma con_char\<^sub>Q\<^sub>C\<^sub>N: + shows "con \ \ \ + N.is_Cong_class \ \ N.is_Cong_class \ \ (\t u. t \ \ \ u \ \ \ t \ u)" + by (metis Con_char conE conI null_char) + + (* + * TODO: Does the stronger form of con_char hold in this context? + * I am currently only able to prove it for the more special context of paths, + * but it doesn't seem like that should be required. + * + * The issue is that congruent paths have the same sets of sources, + * but this does not necessarily hold in general. If we know that all representatives + * of a congruence class have the same sets of sources, then we known that if any + * pair of representatives is consistent, then the arbitrarily chosen representatives + * of the congruence class are consistent. This is by substitutivity of congruence, + * which has coinitiality as a hypothesis. + * + * In the general case, we have to reason as follows: if t and u are consistent + * representatives of \ and \, and if t' and u' are arbitrary coinitial representatives + * of \ and \, then we can obtain "opposing spans" connecting t u and t' u'. + * The opposing span form of coherence then implies that t' and u' are consistent. + * So we should be able to show that if congruence classes \ and \ are consistent, + * then all pairs of coinitial representatives are consistent. + *) + + lemma con_imp_coinitial_members_are_con: + assumes "con \ \" and "t \ \" and "u \ \" and "R.sources t = R.sources u" + shows "t \ u" + by (meson assms N.Cong_subst(1) N.is_Cong_classE con_char\<^sub>Q\<^sub>C\<^sub>N) + + sublocale rts Resid + proof + show 1: "\\ \. \ide \; con \ \\ \ \ \\\\ \ = \" + proof - + fix \ \ + assume \: "ide \" and con: "con \ \" + obtain t a where ta: "t \ \ \ a \ \ \ R.con t a \ \ \\\\ \ = \t \\ a\" + using con con_char\<^sub>Q\<^sub>C\<^sub>N Resid_by_members by auto + have "a \ \" + using \ ta ide_char' by auto + hence "t \\ a \ t" + by (meson N.Cong_closure_props(4) N.Cong_symmetric R.coinitialE R.con_imp_coinitial + ta) + thus "\ \\\\ \ = \" + using ta + by (metis N.Cong_class_eqI N.Cong_class_memb_Cong_rep N.Cong_class_rep con con_char\<^sub>Q\<^sub>C\<^sub>N) + qed + show "\\. arr \ \ ide (trg \)" + by (metis N.Cong\<^sub>0_reflexive Resid_by_members disjoint_iff ide_char N.Cong_class_memb_is_arr + N.arr_in_Cong_class N.is_Cong_class_def arr_char R.arrE R.arr_resid resid_arr_self) + show "\\ \. \ide \; con \ \\ \ ide (\ \\\\ \)" + by (metis 1 arrE arr_resid con_sym ideE ideI cube) + show "\\ \. con \ \ \ \\. ide \ \ con \ \ \ con \ \" + proof - + fix \ \ + assume \\: "con \ \" + obtain t u where tu: "\ = \t\ \ \ = \u\ \ t \ u" + using \\ con_char\<^sub>Q\<^sub>C\<^sub>N arr_char + by (metis N.Cong_class_memb_Cong_rep N.Cong_class_eqI N.Cong_class_rep) + obtain a where a: "a \ R.sources t" + using \\ tu R.con_implies_arr(1) R.arr_iff_has_source by blast + have "ide \a\ \ con \a\ \ \ con \a\ \" + proof (intro conjI) + have 2: "a \ \" + using \\ tu a arr_char N.ide_closed R.sources_def by force + show 3: "ide \a\" + using \\ tu 2 a ide_char arr_char con_char\<^sub>Q\<^sub>C\<^sub>N + by (metis IntI N.arr_in_Cong_class N.is_Cong_classI empty_iff N.elements_are_arr) + show "con \a\ \" + using \\ tu 2 3 a ide_char arr_char con_char\<^sub>Q\<^sub>C\<^sub>N + by (metis N.arr_in_Cong_class R.composite_of_source_arr + R.composite_of_def R.prfx_implies_con R.con_implies_arr(1)) + show "con \a\ \" + using \\ tu a ide_char arr_char con_char\<^sub>Q\<^sub>C\<^sub>N + by (metis N.arr_in_Cong_class R.composite_of_source_arr R.con_prfx_composite_of + N.is_Cong_classI R.con_implies_arr(1) R.con_implies_arr(2)) + qed + thus "\\. ide \ \ con \ \ \ con \ \" by auto + qed + show "\\ \ \. \ide (\ \\\\ \); con \ \\ \ con (\ \\\\ \) (\ \\\\ \)" + proof - + fix \ \ \ + assume \\: "ide (\ \\\\ \)" + assume \\: "con \ \" + obtain t u where tu: "t \ \ \ u \ \ \ t \ u \ \ \\\\ \ = \t \\ u\" + using \\ + by (meson Resid_by_members ide_implies_arr quotient_by_coherent_normal.con_char\<^sub>Q\<^sub>C\<^sub>N + quotient_by_coherent_normal_axioms arr_resid_iff_con) + obtain v u' where vu': "v \ \ \ u' \ \ \ v \ u' \ \ \\\\ \ = \v \\ u'\" + by (meson R.con_sym Resid_by_members \\ con_char\<^sub>Q\<^sub>C\<^sub>N) + have 1: "u \ u'" + using \\ tu vu' + by (meson N.Cong_class_membs_are_Cong con_char\<^sub>Q\<^sub>C\<^sub>N) + obtain w w' where ww': "w \ \ \ w' \ \ \ u \\ w \\<^sub>0 u' \\ w'" + using 1 by auto + have 2: "((t \\ u) \\ (w \\ u)) \\ ((u' \\ w') \\ (u \\ w)) \ + ((v \\ u') \\ (w' \\ u')) \\ ((u \\ w) \\ (u' \\ w'))" + proof - + have "((t \\ u) \\ (w \\ u)) \\ ((u' \\ w') \\ (u \\ w)) \ \" + proof - + have "t \\ u \ \" + using tu N.arr_in_Cong_class R.arr_resid_iff_con \\ ide_char' by blast + hence "(t \\ u) \\ (w \\ u) \ \" + by (metis N.Cong_closure_props(4) N.forward_stable R.null_is_zero(2) + R.con_imp_coinitial R.sources_resid N.Cong_imp_arr(2) R.arr_resid_iff_con + tu ww' R.conI) + thus ?thesis + by (metis N.Cong_closure_props(4) N.normal_is_Cong_closed R.sources_resid + R.targets_resid_sym N.elements_are_arr R.arr_resid_iff_con ww' R.conI) + qed + moreover have "R.sources (((t \\ u) \\ (w \\ u)) \\ ((u' \\ w') \\ (u \\ w))) = + R.sources (((v \\ u') \\ (w' \\ u')) \\ ((u \\ w) \\ (u' \\ w')))" + proof - + have "R.sources (((t \\ u) \\ (w \\ u)) \\ ((u' \\ w') \\ (u \\ w))) = + R.targets ((u' \\ w') \\ (u \\ w))" + using R.arr_resid_iff_con N.elements_are_arr R.sources_resid calculation by blast + also have "... = R.targets ((u \\ w) \\ (u' \\ w'))" + by (metis R.targets_resid_sym R.conI) + also have "... = R.sources (((v \\ u') \\ (w' \\ u')) \\ ((u \\ w) \\ (u' \\ w')))" + using R.arr_resid_iff_con N.elements_are_arr R.sources_resid + by (metis N.Cong_closure_props(4) N.Cong_imp_arr(2) R.con_implies_arr(1) + R.con_imp_coinitial N.forward_stable R.targets_resid_sym vu' ww') + finally show ?thesis by simp + qed + ultimately show ?thesis + by (metis (no_types, lifting) N.Cong\<^sub>0_imp_con N.Cong_closure_props(4) + N.Cong_imp_arr(2) R.arr_resid_iff_con R.con_imp_coinitial N.forward_stable + R.null_is_zero(2) R.conI) + qed + moreover have "t \\ u \ ((t \\ u) \\ (w \\ u)) \\ ((u' \\ w') \\ (u \\ w))" + by (metis (no_types, opaque_lifting) N.Cong_closure_props(4) N.Cong_transitive + N.forward_stable R.arr_resid_iff_con R.con_imp_coinitial R.rts_axioms calculation + rts.coinitial_iff ww') + moreover have "v \\ u' \ ((v \\ u') \\ (w' \\ u')) \\ ((u \\ w) \\ (u' \\ w'))" + proof - + have "w' \\ u' \ \" + by (meson R.con_implies_arr(2) R.con_imp_coinitial N.forward_stable + ww' N.Cong\<^sub>0_imp_con R.arr_resid_iff_con) + moreover have "(u \\ w) \\ (u' \\ w') \ \" + using ww' by blast + ultimately show ?thesis + by (meson 2 N.Cong_closure_props(2) N.Cong_closure_props(4) R.arr_resid_iff_con + R.coinitial_iff R.con_imp_coinitial) + qed + ultimately show "con (\ \\\\ \) (\ \\\\ \)" + using con_char\<^sub>Q\<^sub>C\<^sub>N N.Cong_class_def N.is_Cong_classI tu vu' R.arr_resid_iff_con + by auto + qed + qed + + lemma is_rts: + shows "rts Resid" + .. + + sublocale extensional_rts Resid + proof + fix \ \ + assume \\: "cong \ \" + show "\ = \" + proof - + obtain t u where tu: "\ = \t\ \ \ = \u\ \ t \ u" + by (metis Con_char N.Cong_class_eqI N.Cong_class_memb_Cong_rep N.Cong_class_rep + \\ ide_char not_arr_null null_char) + have "t \\<^sub>0 u" + proof + show "t \\ u \ \" + using tu \\ Resid_by_members [of \ \ t u] + by (metis (full_types) N.arr_in_Cong_class R.con_implies_arr(1-2) + N.is_Cong_classI ide_char' R.arr_resid_iff_con subset_iff) + show "u \\ t \ \" + using tu \\ Resid_by_members [of \ \ u t] R.con_sym + by (metis (full_types) N.arr_in_Cong_class R.con_implies_arr(1-2) + N.is_Cong_classI ide_char' R.arr_resid_iff_con subset_iff) + qed + hence "t \ u" + using N.Cong\<^sub>0_implies_Cong by simp + thus "\ = \" + by (simp add: N.Cong_class_eqI tu) + qed + qed + + theorem is_extensional_rts: + shows "extensional_rts Resid" + .. + + lemma sources_char\<^sub>Q\<^sub>C\<^sub>N: + shows "sources \ = {\. arr \ \ \ = {a. \t a'. t \ \ \ a' \ R.sources t \ a' \ a}}" + proof - + let ?\ = "{a. \t a'. t \ \ \ a' \ R.sources t \ a' \ a}" + have 1: "arr \ \ ide ?\" + proof (unfold ide_char', intro conjI) + assume \: "arr \" + show "?\ \ \" + using N.ide_closed N.normal_is_Cong_closed by blast + show "arr ?\" + proof - + have "N.is_Cong_class ?\" + proof + show "?\ \ {}" + by (metis (mono_tags, lifting) Collect_empty_eq N.Cong_class_def N.Cong_imp_arr(1) + N.is_Cong_class_def N.sources_are_Cong R.arr_iff_has_source R.sources_def + \ arr_char mem_Collect_eq) + show "\t t'. \t \ ?\; t' \ t\ \ t' \ ?\" + using N.Cong_symmetric N.Cong_transitive by blast + show "\a a'. \a \ ?\; a' \ ?\\ \ a \ a'" + proof - + fix a a' + assume a: "a \ ?\" and a': "a' \ ?\" + obtain t b where b: "t \ \ \ b \ R.sources t \ b \ a" + using a by blast + obtain t' b' where b': "t' \ \ \ b' \ R.sources t' \ b' \ a'" + using a' by blast + have "b \ b'" + using \ arr_char b b' + by (meson IntD1 N.Cong_class_membs_are_Cong N.in_sources_respects_Cong) + thus "a \ a'" + by (meson N.Cong_symmetric N.Cong_transitive b b') + qed + qed + thus ?thesis + using arr_char by auto + qed + qed + moreover have "arr \ \ con \ ?\" + proof - + assume \: "arr \" + obtain t a where a: "t \ \ \ a \ R.sources t" + using \ arr_char + by (metis N.Cong_class_is_nonempty R.arr_iff_has_source empty_subsetI + N.Cong_class_memb_is_arr subsetI subset_antisym) + have "t \ \ \ a \ {a. \t a'. t \ \ \ a' \ R.sources t \ a' \ a} \ t \ a" + using a N.Cong_reflexive R.sources_def R.con_implies_arr(2) by fast + thus ?thesis + using \ 1 arr_char con_char\<^sub>Q\<^sub>C\<^sub>N [of \ ?\] by auto + qed + ultimately have "arr \ \ ?\ \ sources \" + using sources_def by blast + thus ?thesis + using "1" ide_char sources_char by auto + qed + + lemma targets_char\<^sub>Q\<^sub>C\<^sub>N: + shows "targets \ = {\. arr \ \ \ = \ \\\\ \}" + proof - + have "targets \ = {\. ide \ \ con (\ \\\\ \) \}" + by (simp add: targets_def trg_def) + also have "... = {\. arr \ \ ide \ \ (\t u. t \ \ \\\\ \ \ u \ \ \ t \ u)}" + using arr_resid_iff_con con_char\<^sub>Q\<^sub>C\<^sub>N arr_char arr_def by auto + also have "... = {\. arr \ \ ide \ \ + (\t t' b u. t \ \ \ t' \ \ \ t \ t' \ b \ \t \\ t'\ \ u \ \ \ b \ u)}" + using arr_char ide_char Resid_by_members [of \ \] N.Cong_class_memb_is_arr + N.is_Cong_class_def R.arr_def + by auto metis+ + also have "... = {\. arr \ \ ide \ \ + (\t t' b. t \ \ \ t' \ \ \ t \ t' \ b \ \t \\ t'\ \ b \ \)}" + proof - + have "\\ t t' b. \arr \; ide \; t \ \; t' \ \; t \ t'; b \ \t \\ t'\\ + \ (\u. u \ \ \ b \ u) \ b \ \" + proof - + fix \ t t' b + assume \: "arr \" and \: "ide \" and t: "t \ \" and t': "t' \ \" + and tt': "t \ t'" and b: "b \ \t \\ t'\" + have 0: "b \ \" + by (metis Resid_by_members \ b ide_char' ide_trg arr_char subsetD t t' trg_def tt') + show "(\u. u \ \ \ b \ u) \ b \ \" + using 0 + by (meson N.Cong_closure_props(3) N.forward_stable N.elements_are_arr + \ arr_char R.con_imp_coinitial N.is_Cong_classE ide_char' R.arrE + R.con_sym subsetD) + qed + thus ?thesis + using ide_char arr_char + by (metis (no_types, lifting)) + qed + also have "... = {\. arr \ \ ide \ \ (\t t'. t \ \ \ t' \ \ \ t \ t' \ \t \\ t'\ \ \)}" + proof - + have "\\ t t' b. \arr \; ide \; t \ \; t' \ \; t \ t'\ + \ (\b. b \ \t \\ t'\ \ b \ \) \ \t \\ t'\ \ \" + using ide_char arr_char + apply (intro iffI) + apply (metis IntI N.Cong_class_eqI' R.arr_resid_iff_con N.is_Cong_classI empty_iff + set_eq_subset) + by (meson N.arr_in_Cong_class R.arr_resid_iff_con subsetD) + thus ?thesis + using ide_char arr_char + by (metis (no_types, lifting)) + qed + also have "... = {\. arr \ \ ide \ \ \ \\\\ \ \ \}" + using arr_char ide_char Resid_by_members [of \ \] + by (metis (no_types, opaque_lifting) arrE con_char\<^sub>Q\<^sub>C\<^sub>N) + also have "... = {\. arr \ \ \ = \ \\\\ \}" + by (metis (no_types, lifting) arr_has_un_target calculation con_ide_are_eq + cong_reflexive mem_Collect_eq targets_def trg_def) + finally show ?thesis by blast + qed + + lemma src_char\<^sub>Q\<^sub>C\<^sub>N: + shows "src \ = {a. arr \ \ (\t a'. t \ \ \ a' \ R.sources t \ a' \ a)}" + using sources_char\<^sub>Q\<^sub>C\<^sub>N [of \] + by (simp add: null_char src_def) + + lemma trg_char\<^sub>Q\<^sub>C\<^sub>N: + shows "trg \ = \ \\\\ \" + unfolding trg_def by blast + + subsubsection "Quotient Map" + + abbreviation quot + where "quot t \ \t\" + + sublocale quot: simulation resid Resid quot + proof + show "\t. \ R.arr t \ \t\ = null" + using N.Cong_class_def N.Cong_imp_arr(1) null_char by force + show "\t u. t \ u \ con \t\ \u\" + by (meson N.arr_in_Cong_class N.is_Cong_classI R.con_implies_arr(1-2) con_char\<^sub>Q\<^sub>C\<^sub>N) + show "\t u. t \ u \ \t \\ u\ = \t\ \\\\ \u\" + by (metis N.arr_in_Cong_class N.is_Cong_classI R.con_implies_arr(1-2) Resid_by_members) + qed + + lemma quotient_is_simulation: + shows "simulation resid Resid quot" + .. + + (* + * TODO: Show couniversality. + *) + + end + + subsection "Identities form a Coherent Normal Sub-RTS" + + text \ + We now show that the collection of identities of an RTS form a coherent normal sub-RTS, + and that the associated congruence \\\ coincides with \\\. + Thus, every RTS can be factored by the relation \\\ to obtain an extensional RTS. + Although we could have shown that fact much earlier, we have delayed proving it so that + we could simply obtain it as a special case of our general quotient result without + redundant work. + \ + + context rts + begin + + interpretation normal_sub_rts resid \Collect ide\ + proof + show "\t. t \ Collect ide \ arr t" + by blast + show 1: "\a. ide a \ a \ Collect ide" + by blast + show "\u t. \u \ Collect ide; coinitial t u\ \ u \\ t \ Collect ide" + by (metis 1 CollectD arr_def coinitial_iff + con_sym in_sourcesE in_sourcesI resid_ide_arr) + show "\u t. \u \ Collect ide; t \\ u \ Collect ide\ \ t \ Collect ide" + using ide_backward_stable by blast + show "\u t. \u \ Collect ide; seq u t\ \ \v. composite_of u t v" + by (metis composite_of_source_arr ide_def in_sourcesI mem_Collect_eq seq_def + resid_source_in_targets) + show "\u t. \u \ Collect ide; seq t u\ \ \v. composite_of t u v" + by (metis arrE composite_of_arr_target in_sourcesI seqE mem_Collect_eq) + qed + + lemma identities_form_normal_sub_rts: + shows "normal_sub_rts resid (Collect ide)" + .. + + interpretation coherent_normal_sub_rts resid \Collect ide\ + apply unfold_locales + by (metis CollectD Cong\<^sub>0_reflexive Cong_closure_props(4) Cong_imp_arr(2) + arr_resid_iff_con resid_arr_ide) + + lemma identities_form_coherent_normal_sub_rts: + shows "coherent_normal_sub_rts resid (Collect ide)" + .. + + lemma Cong_iff_cong: + shows "Cong t u \ t \ u" + by (metis CollectD Cong_def ide_closed resid_arr_ide + Cong_closure_props(3) Cong_imp_arr(2) arr_resid_iff_con) + + end + + section "Paths" + + text \ + A \emph{path} in an RTS is a nonempty list of arrows such that the set + of targets of each arrow suitably matches the set of sources of its successor. + The residuation on the given RTS extends inductively to a residuation on + paths, so that paths also form an RTS. The append operation on lists + yields a composite for each pair of compatible paths. + \ + + locale paths_in_rts = + R: rts + begin + + fun Srcs + where "Srcs [] = {}" + | "Srcs [t] = R.sources t" + | "Srcs (t # T) = R.sources t" + + fun Trgs + where "Trgs [] = {}" + | "Trgs [t] = R.targets t" + | "Trgs (t # T) = Trgs T" + + fun Arr + where "Arr [] = False" + | "Arr [t] = R.arr t" + | "Arr (t # T) = (R.arr t \ Arr T \ R.targets t \ Srcs T)" + + fun Ide + where "Ide [] = False" + | "Ide [t] = R.ide t" + | "Ide (t # T) = (R.ide t \ Ide T \ R.targets t \ Srcs T)" + + lemma set_Arr_subset_arr: + shows "Arr T \ set T \ Collect R.arr" + apply (induct T) + apply auto + using Arr.elims(2) + apply blast + by (metis Arr.simps(3) Ball_Collect list.set_cases) + + lemma Arr_imp_arr_hd [simp]: + assumes "Arr T" + shows "R.arr (hd T)" + using assms + by (metis Arr.simps(1) CollectD hd_in_set set_Arr_subset_arr subset_code(1)) + + lemma Arr_imp_arr_last [simp]: + assumes "Arr T" + shows "R.arr (last T)" + using assms + by (metis Arr.simps(1) CollectD in_mono last_in_set set_Arr_subset_arr) + + lemma Arr_imp_Arr_tl [simp]: + assumes "Arr T" and "tl T \ []" + shows "Arr (tl T)" + using assms + by (metis Arr.simps(3) list.exhaust_sel list.sel(2)) + + lemma set_Ide_subset_ide: + shows "Ide T \ set T \ Collect R.ide" + apply (induct T) + apply auto + using Ide.elims(2) + apply blast + by (metis Ide.simps(3) Ball_Collect list.set_cases) + + lemma Ide_imp_Ide_hd [simp]: + assumes "Ide T" + shows "R.ide (hd T)" + using assms + by (metis Ide.simps(1) CollectD hd_in_set set_Ide_subset_ide subset_code(1)) + + lemma Ide_imp_Ide_last [simp]: + assumes "Ide T" + shows "R.ide (last T)" + using assms + by (metis Ide.simps(1) CollectD in_mono last_in_set set_Ide_subset_ide) + + lemma Ide_imp_Ide_tl [simp]: + assumes "Ide T" and "tl T \ []" + shows "Ide (tl T)" + using assms + by (metis Ide.simps(3) list.exhaust_sel list.sel(2)) + + lemma Ide_implies_Arr: + shows "Ide T \ Arr T" + apply (induct T) + apply simp + using Ide.elims(2) by fastforce + + lemma const_ide_is_Ide: + shows "\T \ []; R.ide (hd T); set T \ {hd T}\ \ Ide T" + apply (induct T) + apply auto + by (metis Ide.simps(2-3) R.ideE R.sources_resid Srcs.simps(2-3) empty_iff insert_iff + list.exhaust_sel list.set_sel(1) order_refl subset_singletonD) + + lemma Ide_char: + shows "Ide T \ Arr T \ set T \ Collect R.ide" + apply (induct T) + apply auto[1] + by (metis Arr.simps(3) Ide.simps(2-3) Ide_implies_Arr empty_subsetI + insert_subset list.simps(15) mem_Collect_eq neq_Nil_conv set_empty) + + lemma IdeI [intro]: + assumes "Arr T" and "set T \ Collect R.ide" + shows "Ide T" + using assms Ide_char by force + + lemma Arr_has_Src: + shows "Arr T \ Srcs T \ {}" + apply (cases T) + apply simp + by (metis R.arr_iff_has_source Srcs.elims Arr.elims(2) list.distinct(1) list.sel(1)) + + lemma Arr_has_Trg: + shows "Arr T \ Trgs T \ {}" + using R.arr_iff_has_target + apply (induct T) + apply simp + by (metis Arr.simps(2) Arr.simps(3) Trgs.simps(2-3) list.exhaust_sel) + + lemma Srcs_are_ide: + shows "Srcs T \ Collect R.ide" + apply (cases T) + apply simp + by (metis (no_types, lifting) Srcs.elims list.distinct(1) mem_Collect_eq + R.sources_def subsetI) + + lemma Trgs_are_ide: + shows "Trgs T \ Collect R.ide" + apply (induct T) + apply simp + by (metis R.arr_iff_has_target R.sources_resid Srcs.simps(2) Trgs.simps(2-3) + Srcs_are_ide empty_subsetI list.exhaust R.arrE) + + lemma Srcs_are_con: + assumes "a \ Srcs T" and "a' \ Srcs T" + shows "a \ a'" + using assms + by (metis Srcs.elims empty_iff R.sources_are_con) + + lemma Srcs_con_closed: + assumes "a \ Srcs T" and "R.ide a'" and "a \ a'" + shows "a' \ Srcs T" + using assms R.sources_con_closed + apply (cases T, auto) + by (metis Srcs.simps(2-3) neq_Nil_conv) + + lemma Srcs_eqI: + assumes "Srcs T \ Srcs T' \ {}" + shows "Srcs T = Srcs T'" + using assms R.sources_eqI + apply (cases T; cases T') + apply auto + apply (metis IntI Srcs.simps(2-3) empty_iff neq_Nil_conv) + by (metis Srcs.simps(2-3) assms neq_Nil_conv) + + lemma Trgs_are_con: + shows "\b b'. \b \ Trgs T; b' \ Trgs T\ \ b \ b'" + apply (induct T) + apply auto + by (metis R.targets_are_con Trgs.simps(2-3) list.exhaust_sel) + + lemma Trgs_con_closed: + shows "\b \ Trgs T; R.ide b'; b \ b'\ \ b' \ Trgs T" + apply (induct T) + apply auto + by (metis R.targets_con_closed Trgs.simps(2-3) neq_Nil_conv) + + lemma Trgs_eqI: + assumes "Trgs T \ Trgs T' \ {}" + shows "Trgs T = Trgs T'" + using assms Trgs_are_ide Trgs_are_con Trgs_con_closed by blast + + lemma Srcs_simp\<^sub>P: + assumes "Arr T" + shows "Srcs T = R.sources (hd T)" + using assms + by (metis Arr_has_Src Srcs.simps(1) Srcs.simps(2) Srcs.simps(3) list.exhaust_sel) + + lemma Trgs_simp\<^sub>P: + shows "Arr T \ Trgs T = R.targets (last T)" + apply (induct T) + apply simp + by (metis Arr.simps(3) Trgs.simps(2) Trgs.simps(3) last_ConsL last_ConsR neq_Nil_conv) + + subsection "Residuation on Paths" + + text \ + It was more difficult than I thought to get a correct formal definition for residuation + on paths and to prove things from it. Straightforward attempts to write a single + recursive definition ran into problems with being able to prove termination, + as well as getting the cases correct so that the domain of definition was symmetric. + Eventually I found the definition below, which simplifies the termination proof + to some extent through the use of two auxiliary functions, and which has a + symmetric form that makes symmetry easier to prove. However, there was still + some difficulty in proving the recursive expansions with respect to cons and + append that I needed. + \ + + text \ + The following defines residuation of a single transition along a path, yielding a transition. + \ + + fun Resid1x (infix "\<^sup>1\\\<^sup>*" 70) + where "t \<^sup>1\\\<^sup>* [] = R.null" + | "t \<^sup>1\\\<^sup>* [u] = t \\ u" + | "t \<^sup>1\\\<^sup>* (u # U) = (t \\ u) \<^sup>1\\\<^sup>* U" + + text \ + Next, we have residuation of a path along a single transition, yielding a path. + \ + + fun Residx1 (infix "\<^sup>*\\\<^sup>1" 70) + where "[] \<^sup>*\\\<^sup>1 u = []" + | "[t] \<^sup>*\\\<^sup>1 u = (if t \ u then [t \\ u] else [])" + | "(t # T) \<^sup>*\\\<^sup>1 u = + (if t \ u \ T \<^sup>*\\\<^sup>1 (u \\ t) \ [] then (t \\ u) # T \<^sup>*\\\<^sup>1 (u \\ t) else [])" + + text \ + Finally, residuation of a path along a path, yielding a path. + \ + + function (sequential) Resid (infix "\<^sup>*\\\<^sup>*" 70) + where "[] \<^sup>*\\\<^sup>* _ = []" + | "_ \<^sup>*\\\<^sup>* [] = []" + | "[t] \<^sup>*\\\<^sup>* [u] = (if t \ u then [t \\ u] else [])" + | "[t] \<^sup>*\\\<^sup>* (u # U) = + (if t \ u \ (t \\ u) \<^sup>1\\\<^sup>* U \ R.null then [(t \\ u) \<^sup>1\\\<^sup>* U] else [])" + | "(t # T) \<^sup>*\\\<^sup>* [u] = + (if t \ u \ T \<^sup>*\\\<^sup>1 (u \\ t) \ [] then (t \\ u) # (T \<^sup>*\\\<^sup>1 (u \\ t)) else [])" + | "(t # T) \<^sup>*\\\<^sup>* (u # U) = + (if t \ u \ (t \\ u) \<^sup>1\\\<^sup>* U \ R.null \ + (T \<^sup>*\\\<^sup>1 (u \\ t)) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>1 (t \\ u)) \ [] + then (t \\ u) \<^sup>1\\\<^sup>* U # (T \<^sup>*\\\<^sup>1 (u \\ t)) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>1 (t \\ u)) + else [])" + by pat_completeness auto + + text \ + Residuation of a path along a single transition is length non-increasing. + Actually, it is length-preserving, except in case the path and the transition + are not consistent. We will show that later, but for now this is what we + need to establish termination for (\\\). + \ + + lemma length_Residx1: + shows "\u. length (T \<^sup>*\\\<^sup>1 u) \ length T" + proof (induct T) + show "\u. length ([] \<^sup>*\\\<^sup>1 u) \ length []" + by simp + fix t T u + assume ind: "\u. length (T \<^sup>*\\\<^sup>1 u) \ length T" + show "length ((t # T) \<^sup>*\\\<^sup>1 u) \ length (t # T)" + using ind + by (cases T, cases "t \ u", cases "T \<^sup>*\\\<^sup>1 (u \\ t)") auto + qed + + termination Resid + proof (relation "measure (\(T, U). length T + length U)") + show "wf (measure (\(T, U). length T + length U))" + by simp + fix t t' T u U + have "length ((t' # T) \<^sup>*\\\<^sup>1 (u \\ t)) + length (U \<^sup>*\\\<^sup>1 (t \\ u)) + < length (t # t' # T) + length (u # U)" + using length_Residx1 + by (metis add_less_le_mono impossible_Cons le_neq_implies_less list.size(4) trans_le_add1) + thus 1: "(((t' # T) \<^sup>*\\\<^sup>1 (u \\ t), U \<^sup>*\\\<^sup>1 (t \\ u)), t # t' # T, u # U) + \ measure (\(T, U). length T + length U)" + by simp + show "(((t' # T) \<^sup>*\\\<^sup>1 (u \\ t), U \<^sup>*\\\<^sup>1 (t \\ u)), t # t' # T, u # U) + \ measure (\(T, U). length T + length U)" + using 1 length_Residx1 by blast + have "length (T \<^sup>*\\\<^sup>1 (u \\ t)) + length (U \<^sup>*\\\<^sup>1 (t \\ u)) \ length T + length U" + using length_Residx1 by (simp add: add_mono) + thus 2: "((T \<^sup>*\\\<^sup>1 (u \\ t), U \<^sup>*\\\<^sup>1 (t \\ u)), t # T, u # U) + \ measure (\(T, U). length T + length U)" + by simp + show "((T \<^sup>*\\\<^sup>1 (u \\ t), U \<^sup>*\\\<^sup>1 (t \\ u)), t # T, u # U) + \ measure (\(T, U). length T + length U)" + using 2 length_Residx1 by blast + qed + + lemma Resid1x_null: + shows "R.null \<^sup>1\\\<^sup>* T = R.null" + apply (induct T) + apply auto + by (metis R.null_is_zero(1) Resid1x.simps(2-3) list.exhaust) + + lemma Resid1x_ide: + shows "\a. \R.ide a; a \<^sup>1\\\<^sup>* T \ R.null\ \ R.ide (a \<^sup>1\\\<^sup>* T)" + proof (induct T) + show "\a. a \<^sup>1\\\<^sup>* [] \ R.null \ R.ide (a \<^sup>1\\\<^sup>* [])" + by simp + fix a t T + assume a: "R.ide a" + assume ind: "\a. \R.ide a; a \<^sup>1\\\<^sup>* T \ R.null\ \ R.ide (a \<^sup>1\\\<^sup>* T)" + assume con: "a \<^sup>1\\\<^sup>* (t # T) \ R.null" + have 1: "a \ t" + using con + by (metis R.con_def Resid1x.simps(2-3) Resid1x_null list.exhaust) + show "R.ide (a \<^sup>1\\\<^sup>* (t # T))" + using a 1 con ind R.resid_ide_arr + by (metis Resid1x.simps(2-3) list.exhaust) + qed + + (* + * TODO: Try to make this a definition, rather than an abbreviation. + * + * I made an attempt at this, but there are many, many places where the + * definition needs to be unwound. It is not clear how valuable it might + * end up being to have this as a definition. + *) + abbreviation Con (infix "\<^sup>*\\<^sup>*" 50) + where "T \<^sup>*\\<^sup>* U \ T \<^sup>*\\\<^sup>* U \ []" + + lemma Con_sym1: + shows "\u. T \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* T \ R.null" + proof (induct T) + show "\u. [] \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* [] \ R.null" + by simp + show "\t T u. (\u. T \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* T \ R.null) + \ (t # T) \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* (t # T) \ R.null" + proof - + fix t T u + assume ind: "\u. T \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* T \ R.null" + show "(t # T) \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* (t # T) \ R.null" + proof + show "(t # T) \<^sup>*\\\<^sup>1 u \ [] \ u \<^sup>1\\\<^sup>* (t # T) \ R.null" + by (metis R.con_sym Resid1x.simps(2-3) Residx1.simps(2-3) + ind neq_Nil_conv R.conE) + show "u \<^sup>1\\\<^sup>* (t # T) \ R.null \ (t # T) \<^sup>*\\\<^sup>1 u \ []" + using ind R.con_sym + apply (cases T) + apply auto + by (metis R.conI Resid1x_null) + qed + qed + qed + + lemma Con_sym_ind: + shows "\T U. length T + length U \ n \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + proof (induct n) + show "\T U. length T + length U \ 0 \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + by simp + fix n and T U :: "'a list" + assume ind: "\T U. length T + length U \ n \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + assume 1: "length T + length U \ Suc n" + show "T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + using R.con_sym Con_sym1 + apply (cases T; cases U) + apply auto[3] + proof - + fix t u T' U' + assume T: "T = t # T'" and U: "U = u # U'" + show "T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + proof (cases "T' = []") + show "T' = [] \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + using T U Con_sym1 R.con_sym + by (cases U') auto + show "T' \ [] \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + proof (cases "U' = []") + show "\T' \ []; U' = []\ \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + using T U R.con_sym Con_sym1 + by (cases T') auto + show "\T' \ []; U' \ []\ \ T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + proof - + assume T': "T' \ []" and U': "U' \ []" + have 2: "length (U' \<^sup>*\\\<^sup>1 (t \\ u)) + length (T' \<^sup>*\\\<^sup>1 (u \\ t)) \ n" + proof - + have "length (U' \<^sup>*\\\<^sup>1 (t \\ u)) + length (T' \<^sup>*\\\<^sup>1 (u \\ t)) + \ length U' + length T'" + by (simp add: add_le_mono length_Residx1) + also have "... \ length T' + length U'" + using T' add.commute not_less_eq_eq by auto + also have "... \ n" + using 1 T U by simp + finally show ?thesis by blast + qed + show "T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + proof + assume Con: "T \<^sup>*\\<^sup>* U" + have 3: "t \ u \ T' \<^sup>*\\\<^sup>1 (u \\ t) \ [] \ (t \\ u) \<^sup>1\\\<^sup>* U' \ R.null \ + (T' \<^sup>*\\\<^sup>1 (u \\ t)) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>1 (t \\ u)) \ []" + using Con T U T' U' Con_sym1 + apply (cases T', cases U') + apply simp_all + by (metis Resid.simps(1) Resid.simps(6) neq_Nil_conv) + hence "u \ t \ U' \<^sup>*\\\<^sup>1 (t \\ u) \ [] \ (u \\ t) \<^sup>1\\\<^sup>* T' \ R.null" + using T' U' R.con_sym Con_sym1 by simp + moreover have "(U' \<^sup>*\\\<^sup>1 (t \\ u)) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>1 (u \\ t)) \ []" + using 2 3 ind by simp + ultimately show "U \<^sup>*\\<^sup>* T" + using T U T' U' + by (cases T'; cases U') auto + next + assume Con: "U \<^sup>*\\<^sup>* T" + have 3: "u \ t \ U' \<^sup>*\\\<^sup>1 (t \\ u) \ [] \ (u \\ t) \<^sup>1\\\<^sup>* T' \ R.null \ + (U' \<^sup>*\\\<^sup>1 (t \\ u)) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>1 (u \\ t)) \ []" + using Con T U T' U' Con_sym1 + apply (cases T'; cases U') + apply auto + apply argo + by force + hence "t \ u \ T' \<^sup>*\\\<^sup>1 (u \\ t) \ [] \ (t \\ u) \<^sup>1\\\<^sup>* U' \ R.null" + using T' U' R.con_sym Con_sym1 by simp + moreover have "(T' \<^sup>*\\\<^sup>1 (u \\ t)) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>1 (t \\ u)) \ []" + using 2 3 ind by simp + ultimately show "T \<^sup>*\\<^sup>* U" + using T U T' U' + by (cases T'; cases U') auto + qed + qed + qed + qed + qed + qed + + lemma Con_sym: + shows "T \<^sup>*\\<^sup>* U \ U \<^sup>*\\<^sup>* T" + using Con_sym_ind by blast + + lemma Residx1_as_Resid: + shows "T \<^sup>*\\\<^sup>1 u = T \<^sup>*\\\<^sup>* [u]" + proof (induct T) + show "[] \<^sup>*\\\<^sup>1 u = [] \<^sup>*\\\<^sup>* [u]" by simp + fix t T + assume ind: "T \<^sup>*\\\<^sup>1 u = T \<^sup>*\\\<^sup>* [u]" + show "(t # T) \<^sup>*\\\<^sup>1 u = (t # T) \<^sup>*\\\<^sup>* [u]" + by (cases T) auto + qed + + lemma Resid1x_as_Resid': + shows "t \<^sup>1\\\<^sup>* U = (if [t] \<^sup>*\\\<^sup>* U \ [] then hd ([t] \<^sup>*\\\<^sup>* U) else R.null)" + proof (induct U) + show "t \<^sup>1\\\<^sup>* [] = (if [t] \<^sup>*\\\<^sup>* [] \ [] then hd ([t] \<^sup>*\\\<^sup>* []) else R.null)" by simp + fix u U + assume ind: "t \<^sup>1\\\<^sup>* U = (if [t] \<^sup>*\\\<^sup>* U \ [] then hd ([t] \<^sup>*\\\<^sup>* U) else R.null)" + show "t \<^sup>1\\\<^sup>* (u # U) = (if [t] \<^sup>*\\\<^sup>* (u # U) \ [] then hd ([t] \<^sup>*\\\<^sup>* (u # U)) else R.null)" + using Resid1x_null + by (cases U) auto + qed + + text \ + The following recursive expansion for consistency of paths is an intermediate + result that is not yet quite in the form we really want. + \ + + lemma Con_rec: + shows "[t] \<^sup>*\\<^sup>* [u] \ t \ u" + and "T \ [] \ t # T \<^sup>*\\<^sup>* [u] \ t \ u \ T \<^sup>*\\<^sup>* [u \\ t]" + and "U \ [] \ [t] \<^sup>*\\<^sup>* (u # U) \ t \ u \ [t \\ u] \<^sup>*\\<^sup>* U" + and "\T \ []; U \ []\ \ + t # T \<^sup>*\\<^sup>* u # U \ t \ u \ T \<^sup>*\\<^sup>* [u \\ t] \ [t \\ u] \<^sup>*\\<^sup>* U \ + T \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t \\ u]" + proof - + show "[t] \<^sup>*\\<^sup>* [u] \ t \ u" + by simp + show "T \ [] \ t # T \<^sup>*\\<^sup>* [u] \ t \ u \ T \<^sup>*\\<^sup>* [u \\ t]" + using Residx1_as_Resid + by (cases T) auto + show "U \ [] \ [t] \<^sup>*\\<^sup>* (u # U) \ t \ u \ [t \\ u] \<^sup>*\\<^sup>* U" + using Resid1x_as_Resid' Con_sym Con_sym1 Resid1x.simps(3) Residx1_as_Resid + by (cases U) auto + show "\T \ []; U \ []\ \ + t # T \<^sup>*\\<^sup>* u # U \ t \ u \ T \<^sup>*\\<^sup>* [u \\ t] \ [t \\ u] \<^sup>*\\<^sup>* U \ + T \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t \\ u]" + using Residx1_as_Resid Resid1x_as_Resid' Con_sym1 Con_sym R.con_sym + by (cases T; cases U) auto + qed + + text \ + This version is a more appealing form of the previously proved fact \Resid1x_as_Resid'\. + \ + + lemma Resid1x_as_Resid: + assumes "[t] \<^sup>*\\\<^sup>* U \ []" + shows "[t] \<^sup>*\\\<^sup>* U = [t \<^sup>1\\\<^sup>* U]" + using assms Con_rec(2,4) + apply (cases U; cases "tl U") + apply auto + by argo+ (* TODO: Why can auto no longer complete this proof? *) + + text \ + The following is an intermediate version of a recursive expansion for residuation, + to be improved subsequently. + \ + + lemma Resid_rec: + shows [simp]: "[t] \<^sup>*\\<^sup>* [u] \ [t] \<^sup>*\\\<^sup>* [u] = [t \\ u]" + and "\T \ []; t # T \<^sup>*\\<^sup>* [u]\ \ (t # T) \<^sup>*\\\<^sup>* [u] = (t \\ u) # (T \<^sup>*\\\<^sup>* [u \\ t])" + and "\U \ []; Con [t] (u # U)\ \ [t] \<^sup>*\\\<^sup>* (u # U) = [t \\ u] \<^sup>*\\\<^sup>* U" + and "\T \ []; U \ []; Con (t # T) (u # U)\ \ + (t # T) \<^sup>*\\\<^sup>* (u # U) = ([t \\ u] \<^sup>*\\\<^sup>* U) @ ((T \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t \\ u]))" + proof - + show "[t] \<^sup>*\\<^sup>* [u] \ Resid [t] [u] = [t \\ u]" + by (meson Resid.simps(3)) + show "\T \ []; t # T \<^sup>*\\<^sup>* [u]\ \ (t # T) \<^sup>*\\\<^sup>* [u] = (t \\ u) # (T \<^sup>*\\\<^sup>* [u \\ t])" + using Residx1_as_Resid + by (metis Residx1.simps(3) list.exhaust_sel) + show 1: "\U \ []; [t] \<^sup>*\\<^sup>* u # U\ \ [t] \<^sup>*\\\<^sup>* (u # U) = [t \\ u] \<^sup>*\\\<^sup>* U" + by (metis Con_rec(3) Resid1x.simps(3) Resid1x_as_Resid list.exhaust) + show "\T \ []; U \ []; t # T \<^sup>*\\<^sup>* u # U\ \ + (t # T) \<^sup>*\\\<^sup>* (u # U) = ([t \\ u] \<^sup>*\\\<^sup>* U) @ ((T \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t \\ u]))" + proof - + assume T: "T \ []" and U: "U \ []" and Con: "Con (t # T) (u # U)" + have tu: "t \ u" + using Con Con_rec by metis + have "(t # T) \<^sup>*\\\<^sup>* (u # U) = ((t \\ u) \<^sup>1\\\<^sup>* U) # ((T \<^sup>*\\\<^sup>1 (u \\ t)) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>1 (t \\ u)))" + using T U Con tu + by (cases T; cases U) auto + also have "... = ([t \\ u] \<^sup>*\\\<^sup>* U) @ ((T \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t \\ u]))" + using T U Con tu Con_rec(4) Resid1x_as_Resid Residx1_as_Resid by force + finally show ?thesis by simp + qed + qed + + text \ + For consistent paths, residuation is length-preserving. + \ + + lemma length_Resid_ind: + shows "\T U. \length T + length U \ n; T \<^sup>*\\<^sup>* U\ \ length (T \<^sup>*\\\<^sup>* U) = length T" + apply (induct n) + apply simp + proof - + fix n T U + assume ind: "\T U. \length T + length U \ n; T \<^sup>*\\<^sup>* U\ + \ length (T \<^sup>*\\\<^sup>* U) = length T" + assume Con: "T \<^sup>*\\<^sup>* U" + assume len: "length T + length U \ Suc n" + show "length (T \<^sup>*\\\<^sup>* U) = length T" + using Con len ind Resid1x_as_Resid length_Cons Con_rec(2) Resid_rec(2) + apply (cases T; cases U) + apply auto + apply (cases "tl T = []"; cases "tl U = []") + apply auto + apply metis + apply fastforce + proof - + fix t T' u U' + assume T: "T = t # T'" and U: "U = u # U'" + assume T': "T' \ []" and U': "U' \ []" + show "length ((t # T') \<^sup>*\\\<^sup>* (u # U')) = Suc (length T')" + using Con Con_rec(4) Con_sym Resid_rec(4) T T' U U' ind len by auto + qed + qed + + lemma length_Resid: + assumes "T \<^sup>*\\<^sup>* U" + shows "length (T \<^sup>*\\\<^sup>* U) = length T" + using assms length_Resid_ind by auto + + lemma Con_initial_left: + shows "\t T. t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U" + apply (induct U) + apply simp + by (metis Con_rec(1-4)) + + lemma Con_initial_right: + shows "\u U. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u]" + apply (induct T) + apply simp + by (metis Con_rec(1-4)) + + lemma Resid_cons_ind: + shows "\T U. \T \ []; U \ []; length T + length U \ n\ \ + (\t. t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U) \ + (\t. t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U)" + proof (induct n) + show "\T U. \T \ []; U \ []; length T + length U \ 0\ \ + (\t. t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U) \ + (\t. t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U)" + by simp + fix n and T U :: "'a list" + assume ind: "\T U. \T \ []; U \ []; length T + length U \ n\ \ + (\t. t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U) \ + (\t. t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U)" + assume T: "T \ []" and U: "U \ []" + assume len: "length T + length U \ Suc n" + show "(\t. t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U) \ + (\t. t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) \ + (\u. T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U)" + proof (intro allI conjI iffI impI) + fix t + show 1: "t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + proof (cases U) + show "U = [] \ ?thesis" + using U by simp + fix u U' + assume U: "U = u # U'" + assume Con: "t # T \<^sup>*\\<^sup>* U" + show ?thesis + proof (cases "U' = []") + show "U' = [] \ ?thesis" + using T U Con R.con_sym Con_rec(2) Resid_rec(2) by auto + assume U': "U' \ []" + have "(t # T) \<^sup>*\\\<^sup>* U = [t \\ u] \<^sup>*\\\<^sup>* U' @ (T \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + using T U U' Con Resid_rec(4) by fastforce + also have 1: "... = [t] \<^sup>*\\\<^sup>* U @ (T \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + using T U U' Con Con_rec(3-4) Resid_rec(3) by auto + also have "... = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* ((u \\ t) # (U' \<^sup>*\\\<^sup>* [t \\ u]))" + proof - + have "T \<^sup>*\\\<^sup>* ((u \\ t) # (U' \<^sup>*\\\<^sup>* [t \\ u])) = (T \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + using T U U' ind [of T "U' \<^sup>*\\\<^sup>* [t \\ u]"] Con Con_rec(4) Con_sym len length_Resid + by fastforce + thus ?thesis by auto + qed + also have "... = [t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + using T U U' 1 Con Con_rec(4) Con_sym1 Residx1_as_Resid + Resid1x_as_Resid Resid_rec(2) Con_sym Con_initial_left + by auto + finally show ?thesis by simp + qed + qed + show "t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U" + by (simp add: Con_initial_left) + show "t # T \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + by (metis "1" Suc_inject T append_Nil2 length_0_conv length_Cons length_Resid) + show "[t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t] \ t # T \<^sup>*\\<^sup>* U" + proof (cases U) + show "\[t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]; U = []\ \ t # T \<^sup>*\\<^sup>* U" + using U by simp + fix u U' + assume U: "U = u # U'" + assume Con: "[t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]" + show "t # T \<^sup>*\\<^sup>* U" + proof (cases "U' = []") + show "U' = [] \ ?thesis" + using T U Con + by (metis Con_rec(2) Resid.simps(3) R.con_sym) + assume U': "U' \ []" + show ?thesis + proof - + have "t \ u" + using T U U' Con Con_rec(3) by blast + moreover have "T \<^sup>*\\<^sup>* [u \\ t]" + using T U U' Con Con_initial_right Con_sym1 Residx1_as_Resid + Resid1x_as_Resid Resid_rec(2) + by (metis Con_sym) + moreover have "[t \\ u] \<^sup>*\\<^sup>* U'" + using T U U' Con Resid_rec(3) by force + moreover have "T \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* U' \<^sup>*\\\<^sup>* [t \\ u]" + by (metis (no_types, opaque_lifting) Con Con_sym Resid_rec(2) Suc_le_mono + T U U' add_Suc_right calculation(3) ind len length_Cons length_Resid) + ultimately show ?thesis + using T U U' Con_rec(4) by simp + qed + qed + qed + next + fix u + show 1: "T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U" + proof (cases T) + show 2: "\T \<^sup>*\\<^sup>* u # U; T = []\ \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U" + using T by simp + fix t T' + assume T: "T = t # T'" + assume Con: "T \<^sup>*\\<^sup>* u # U" + show ?thesis + proof (cases "T' = []") + show "T' = [] \ ?thesis" + using T U Con Con_rec(3) Resid1x_as_Resid Resid_rec(3) by force + assume T': "T' \ []" + have "T \<^sup>*\\\<^sup>* (u # U) = [t \\ u] \<^sup>*\\\<^sup>* U @ (T' \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t \\ u])" + using T U T' Con Resid_rec(4) [of T' U t u] by simp + also have "... = ((t \\ u) # (T' \<^sup>*\\\<^sup>* [u \\ t])) \<^sup>*\\\<^sup>* U" + proof - + have "length (T' \<^sup>*\\\<^sup>* [u \\ t]) + length U \ n" + by (metis (no_types, lifting) Con Con_rec(4) One_nat_def Suc_eq_plus1 Suc_leI + T T' U add_Suc le_less_trans len length_Resid lessI list.size(4) + not_le) + thus ?thesis + using ind [of "T' \<^sup>*\\\<^sup>* [u \\ t]" U] Con Con_rec(4) T T' U by auto + qed + also have "... = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U" + using T U T' Con Con_rec(2,4) Resid_rec(2) by force + finally show ?thesis by simp + qed + qed + show "T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u]" + using 1 by force + show "T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U" + using 1 by fastforce + show "T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* u # U" + proof (cases T) + show "\T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U; T = []\ \ T \<^sup>*\\<^sup>* u # U" + using T by simp + fix t T' + assume T: "T = t # T'" + assume Con: "T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U" + show "Con T (u # U)" + proof (cases "T' = []") + show "T' = [] \ ?thesis" + using Con T U Con_rec(1,3) by auto + assume T': "T' \ []" + have "t \ u" + using Con T U T' Con_rec(2) by blast + moreover have 2: "T' \<^sup>*\\<^sup>* [u \\ t]" + using Con T U T' Con_rec(2) by blast + moreover have "[t \\ u] \<^sup>*\\<^sup>* U" + using Con T U T' + by (metis Con_initial_left Resid_rec(2)) + moreover have "T' \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t \\ u]" + proof - + have 0: "length (U \<^sup>*\\\<^sup>* [t \\ u]) = length U" + using Con T U T' length_Resid Con_sym calculation(3) by blast + hence 1: "length T' + length (U \<^sup>*\\\<^sup>* [t \\ u]) \ n" + using Con T U T' len length_Resid Con_sym by simp + have "length ((T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U) = + length ([t \\ u] \<^sup>*\\\<^sup>* U) + length ((T' \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t \\ u]))" + proof - + have "(T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U = + [t \\ u] \<^sup>*\\\<^sup>* U @ (T' \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t \\ u])" + by (metis 0 1 2 Con Resid_rec(2) T T' U ind length_Resid) + thus ?thesis + using Con T U T' length_Resid by simp + qed + moreover have "length ((T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U) = length T" + using Con T U T' length_Resid by metis + moreover have "length ([t \\ u] \<^sup>*\\\<^sup>* U) \ 1" + using Con T U T' Resid1x_as_Resid + by (metis One_nat_def length_Cons list.size(3) order_refl zero_le) + ultimately show ?thesis + using Con T U T' length_Resid by auto + qed + ultimately show "T \<^sup>*\\<^sup>* u # U" + using T Con_rec(4) [of T' U t u] by fastforce + qed + qed + qed + qed + + text \ + The following are the final versions of recursive expansion for consistency + and residuation on paths. These are what I really wanted the original definitions + to look like, but if this is tried, then \Con\ and \Resid\ end up having to be mutually + recursive, expressing the definitions so that they are single-valued becomes an issue, + and proving termination is more problematic. + \ + + lemma Con_cons: + assumes "T \ []" and "U \ []" + shows "t # T \<^sup>*\\<^sup>* U \ [t] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]" + and "T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\<^sup>* [u] \ T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U" + using assms Resid_cons_ind [of T U] by blast+ + + lemma Con_consI [intro, simp]: + shows "\T \ []; U \ []; [t] \<^sup>*\\<^sup>* U; T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]\ \ t # T \<^sup>*\\<^sup>* U" + and "\T \ []; U \ []; T \<^sup>*\\<^sup>* [u]; T \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* U\ \ T \<^sup>*\\<^sup>* u # U" + using Con_cons by auto + + (* TODO: Making this a simp currently seems to produce undesirable breakage. *) + lemma Resid_cons: + assumes "U \ []" + shows "t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = ([t] \<^sup>*\\\<^sup>* U) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + and "T \<^sup>*\\<^sup>* u # U \ T \<^sup>*\\\<^sup>* (u # U) = (T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U" + using assms Resid_cons_ind [of T U] Resid.simps(1) + by blast+ + + text \ + The following expansion of residuation with respect to the first argument + is stated in terms of the more primitive cons, rather than list append, + but as a result \\<^sup>1\\<^sup>*\ has to be used. + \ + + (* TODO: Making this a simp seems to produce similar breakage as above. *) + lemma Resid_cons': + assumes "T \ []" + shows "t # T \<^sup>*\\<^sup>* U \ (t # T) \<^sup>*\\\<^sup>* U = (t \<^sup>1\\\<^sup>* U) # (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + using assms + by (metis Con_sym Resid.simps(1) Resid1x_as_Resid Resid_cons(1) + append_Cons append_Nil) + + lemma Srcs_Resid_Arr_single: + assumes "T \<^sup>*\\<^sup>* [u]" + shows "Srcs (T \<^sup>*\\\<^sup>* [u]) = R.targets u" + proof (cases T) + show "T = [] \ Srcs (T \<^sup>*\\\<^sup>* [u]) = R.targets u" + using assms by simp + fix t T' + assume T: "T = t # T'" + show "Srcs (T \<^sup>*\\\<^sup>* [u]) = R.targets u" + proof (cases "T' = []") + show "T' = [] \ ?thesis" + using assms T R.sources_resid by auto + assume T': "T' \ []" + have "Srcs (T \<^sup>*\\\<^sup>* [u]) = Srcs ((t # T') \<^sup>*\\\<^sup>* [u])" + using T by simp + also have "... = Srcs ((t \\ u) # (T' \<^sup>*\\\<^sup>* ([u] \<^sup>*\\\<^sup>* T')))" + using assms T + by (metis Resid_rec(2) Srcs.elims T' list.distinct(1) list.sel(1)) + also have "... = R.sources (t \\ u)" + using Srcs.elims by blast + also have "... = R.targets u" + using assms Con_rec(2) T T' R.sources_resid by force + finally show ?thesis by blast + qed + qed + + lemma Srcs_Resid_single_Arr: + shows "\u. [u] \<^sup>*\\<^sup>* T \ Srcs ([u] \<^sup>*\\\<^sup>* T) = Trgs T" + proof (induct T) + show "\u. [u] \<^sup>*\\<^sup>* [] \ Srcs ([u] \<^sup>*\\\<^sup>* []) = Trgs []" + by simp + fix t u T + assume ind: "\u. [u] \<^sup>*\\<^sup>* T \ Srcs ([u] \<^sup>*\\\<^sup>* T) = Trgs T" + assume Con: "[u] \<^sup>*\\<^sup>* t # T" + show "Srcs ([u] \<^sup>*\\\<^sup>* (t # T)) = Trgs (t # T)" + proof (cases "T = []") + show "T = [] \ ?thesis" + using Con Srcs_Resid_Arr_single Trgs.simps(2) by presburger + assume T: "T \ []" + have "Srcs ([u] \<^sup>*\\\<^sup>* (t # T)) = Srcs ([u \\ t] \<^sup>*\\\<^sup>* T)" + using Con Resid_rec(3) T by force + also have "... = Trgs T" + using Con ind Con_rec(3) T by auto + also have "... = Trgs (t # T)" + by (metis T Trgs.elims Trgs.simps(3)) + finally show ?thesis by simp + qed + qed + + lemma Trgs_Resid_sym_Arr_single: + shows "\u. T \<^sup>*\\<^sup>* [u] \ Trgs (T \<^sup>*\\\<^sup>* [u]) = Trgs ([u] \<^sup>*\\\<^sup>* T)" + proof (induct T) + show "\u. [] \<^sup>*\\<^sup>* [u] \ Trgs ([] \<^sup>*\\\<^sup>* [u]) = Trgs ([u] \<^sup>*\\\<^sup>* [])" + by simp + fix t u T + assume ind: "\u. T \<^sup>*\\<^sup>* [u] \ Trgs (T \<^sup>*\\\<^sup>* [u]) = Trgs ([u] \<^sup>*\\\<^sup>* T)" + assume Con: "t # T \<^sup>*\\<^sup>* [u]" + show "Trgs ((t # T) \<^sup>*\\\<^sup>* [u]) = Trgs ([u] \<^sup>*\\\<^sup>* (t # T))" + proof (cases "T = []") + show "T = [] \ ?thesis" + using R.targets_resid_sym + by (simp add: R.con_sym) + assume T: "T \ []" + show ?thesis + proof - + have "Trgs ((t # T) \<^sup>*\\\<^sup>* [u]) = Trgs ((t \\ u) # (T \<^sup>*\\\<^sup>* [u \\ t]))" + using Con Resid_rec(2) T by auto + also have "... = Trgs (T \<^sup>*\\\<^sup>* [u \\ t])" + using T Con Con_rec(2) [of T t u] + by (metis Trgs.elims Trgs.simps(3)) + also have "... = Trgs ([u \\ t] \<^sup>*\\\<^sup>* T)" + using T Con ind Con_sym by metis + also have "... = Trgs ([u] \<^sup>*\\\<^sup>* (t # T))" + using T Con Con_sym Resid_rec(3) by presburger + finally show ?thesis by blast + qed + qed + qed + + lemma Srcs_Resid [simp]: + shows "\T. T \<^sup>*\\<^sup>* U \ Srcs (T \<^sup>*\\\<^sup>* U) = Trgs U" + proof (induct U) + show "\T. T \<^sup>*\\<^sup>* [] \ Srcs (T \<^sup>*\\\<^sup>* []) = Trgs []" + using Con_sym Resid.simps(1) by blast + fix u U T + assume ind: "\T. T \<^sup>*\\<^sup>* U \ Srcs (T \<^sup>*\\\<^sup>* U) = Trgs U" + assume Con: "T \<^sup>*\\<^sup>* u # U" + show "Srcs (T \<^sup>*\\\<^sup>* (u # U)) = Trgs (u # U)" + by (metis Con Resid_cons(2) Srcs_Resid_Arr_single Trgs.simps(2-3) ind + list.exhaust_sel) + qed + + lemma Trgs_Resid_sym [simp]: + shows "\T. T \<^sup>*\\<^sup>* U \ Trgs (T \<^sup>*\\\<^sup>* U) = Trgs (U \<^sup>*\\\<^sup>* T)" + proof (induct U) + show "\T. T \<^sup>*\\<^sup>* [] \ Trgs (T \<^sup>*\\\<^sup>* []) = Trgs ([] \<^sup>*\\\<^sup>* T)" + by (meson Con_sym Resid.simps(1)) + fix u U T + assume ind: "\T. T \<^sup>*\\<^sup>* U \ Trgs (T \<^sup>*\\\<^sup>* U) = Trgs (U \<^sup>*\\\<^sup>* T)" + assume Con: "T \<^sup>*\\<^sup>* u # U" + show "Trgs (T \<^sup>*\\\<^sup>* (u # U)) = Trgs ((u # U) \<^sup>*\\\<^sup>* T)" + proof (cases "U = []") + show "U = [] \ ?thesis" + using Con Trgs_Resid_sym_Arr_single by blast + assume U: "U \ []" + show ?thesis + proof - + have "Trgs (T \<^sup>*\\\<^sup>* (u # U)) = Trgs ((T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U)" + using U by (metis Con Resid_cons(2)) + also have "... = Trgs (U \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* [u]))" + using U Con by (metis Con_sym ind) + also have "... = Trgs ((u # U) \<^sup>*\\\<^sup>* T)" + by (metis (no_types, opaque_lifting) Con_cons(1) Con_sym Resid.simps(1) Resid_cons' + Trgs.simps(3) U neq_Nil_conv) + finally show ?thesis by simp + qed + qed + qed + + lemma img_Resid_Srcs: + shows "Arr T \ (\a. [a] \<^sup>*\\\<^sup>* T) ` Srcs T \ (\b. [b]) ` Trgs T" + proof (induct T) + show "Arr [] \ (\a. [a] \<^sup>*\\\<^sup>* []) ` Srcs [] \ (\b. [b]) ` Trgs []" + by simp + fix t :: 'a and T :: "'a list" + assume tT: "Arr (t # T)" + assume ind: "Arr T \ (\a. [a] \<^sup>*\\\<^sup>* T) ` Srcs T \ (\b. [b]) ` Trgs T" + show "(\a. [a] \<^sup>*\\\<^sup>* (t # T)) ` Srcs (t # T) \ (\b. [b]) ` Trgs (t # T)" + proof + fix B + assume B: "B \ (\a. [a] \<^sup>*\\\<^sup>* (t # T)) ` Srcs (t # T)" + show "B \ (\b. [b]) ` Trgs (t # T)" + proof (cases "T = []") + assume T: "T = []" + obtain a where a: "a \ R.sources t \ [a \\ t] = B" + by (metis (no_types, lifting) B R.composite_of_source_arr R.con_prfx_composite_of(1) + Resid_rec(1) Srcs.simps(2) T Arr.simps(2) Con_rec(1) imageE tT) + have "a \\ t \ Trgs (t # T)" + using tT T a + by (simp add: R.resid_source_in_targets) + thus ?thesis + using B a image_iff by fastforce + next + assume T: "T \ []" + obtain a where a: "a \ R.sources t \ [a] \<^sup>*\\\<^sup>* (t # T) = B" + using tT T B Srcs.elims by blast + have "[a \\ t] \<^sup>*\\\<^sup>* T = B" + using tT T B a + by (metis Con_rec(3) R.arrI R.resid_source_in_targets R.targets_are_cong + Resid_rec(3) R.arr_resid_iff_con R.ide_implies_arr) + moreover have "a \\ t \ Srcs T" + using a tT + by (metis Arr.simps(3) R.resid_source_in_targets T neq_Nil_conv subsetD) + ultimately show ?thesis + using T tT ind + by (metis Trgs.simps(3) Arr.simps(3) image_iff list.exhaust_sel subsetD) + qed + qed + qed + + lemma Resid_Arr_Src: + shows "\a. \Arr T; a \ Srcs T\ \ T \<^sup>*\\\<^sup>* [a] = T" + proof (induct T) + show "\a. \Arr []; a \ Srcs []\ \ [] \<^sup>*\\\<^sup>* [a] = []" + by simp + fix a t T + assume ind: "\a. \Arr T; a \ Srcs T\ \ T \<^sup>*\\\<^sup>* [a] = T" + assume Arr: "Arr (t # T)" + assume a: "a \ Srcs (t # T)" + show "(t # T) \<^sup>*\\\<^sup>* [a] = t # T" + proof (cases "T = []") + show "T = [] \ ?thesis" + using a R.resid_arr_ide R.sources_def by auto + assume T: "T \ []" + show "(t # T) \<^sup>*\\\<^sup>* [a] = t # T" + proof - + have 1: "R.arr t \ Arr T \ R.targets t \ Srcs T" + using Arr T + by (metis Arr.elims(2) list.sel(1) list.sel(3)) + have 2: "t # T \<^sup>*\\<^sup>* [a]" + using T a Arr Con_rec(2) + by (metis (no_types, lifting) img_Resid_Srcs Con_sym imageE image_subset_iff + list.distinct(1)) + have "(t # T) \<^sup>*\\\<^sup>* [a] = (t \\ a) # (T \<^sup>*\\\<^sup>* [a \\ t])" + using 2 T Resid_rec(2) by simp + moreover have "t \\ a = t" + using Arr a R.sources_def + by (metis "2" CollectD Con_rec(2) T Srcs_are_ide in_mono R.resid_arr_ide) + moreover have "T \<^sup>*\\\<^sup>* [a \\ t] = T" + by (metis "1" "2" R.in_sourcesI R.resid_source_in_targets Srcs_are_ide T a + Con_rec(2) in_mono ind mem_Collect_eq) + ultimately show ?thesis by simp + qed + qed + qed + + lemma Con_single_ide_ind: + shows "\a. R.ide a \ [a] \<^sup>*\\<^sup>* T \ Arr T \ a \ Srcs T" + proof (induct T) + show "\a. [a] \<^sup>*\\<^sup>* [] \ Arr [] \ a \ Srcs []" + by simp + fix a t T + assume ind: "\a. R.ide a \ [a] \<^sup>*\\<^sup>* T \ Arr T \ a \ Srcs T" + assume a: "R.ide a" + show "[a] \<^sup>*\\<^sup>* (t # T) \ Arr (t # T) \ a \ Srcs (t # T)" + proof (cases "T = []") + show "T = [] \ ?thesis" + using a Con_sym + by (metis Arr.simps(2) Resid_Arr_Src Srcs.simps(2) R.arr_iff_has_source + Con_rec(1) empty_iff R.in_sourcesI list.distinct(1)) + assume T: "T \ []" + have 1: "[a] \<^sup>*\\<^sup>* (t # T) \ a \ t \ [a \\ t] \<^sup>*\\<^sup>* T" + using a T Con_cons(2) [of "[a]" T t] by simp + also have 2: "... \ a \ t \ Arr T \ a \\ t \ Srcs T" + using a T ind R.resid_ide_arr by blast + also have "... \ Arr (t # T) \ a \ Srcs (t # T)" + using a T Con_sym R.con_sym Resid_Arr_Src R.con_implies_arr Srcs_are_ide + apply (cases T) + apply simp + by (metis Arr.simps(3) R.resid_arr_ide R.targets_resid_sym Srcs.simps(3) + Srcs_Resid_Arr_single calculation dual_order.eq_iff list.distinct(1) + R.in_sourcesI) + finally show ?thesis by simp + qed + qed + + lemma Con_single_ide_iff: + assumes "R.ide a" + shows "[a] \<^sup>*\\<^sup>* T \ Arr T \ a \ Srcs T" + using assms Con_single_ide_ind by simp + + lemma Con_single_ideI [intro]: + assumes "R.ide a" and "Arr T" and "a \ Srcs T" + shows "[a] \<^sup>*\\<^sup>* T" and "T \<^sup>*\\<^sup>* [a]" + using assms Con_single_ide_iff Con_sym by auto + + lemma Resid_single_ide: + assumes "R.ide a" and "[a] \<^sup>*\\<^sup>* T" + shows "[a] \<^sup>*\\\<^sup>* T \ (\b. [b]) ` Trgs T" and [simp]: "T \<^sup>*\\\<^sup>* [a] = T" + using assms Con_single_ide_ind img_Resid_Srcs Resid_Arr_Src Con_sym + by blast+ + + lemma Resid_Arr_Ide_ind: + shows "\Ide A; T \<^sup>*\\<^sup>* A\ \ T \<^sup>*\\\<^sup>* A = T" + proof (induct A) + show "\Ide []; T \<^sup>*\\<^sup>* []\ \ T \<^sup>*\\\<^sup>* [] = T" + by simp + fix a A + assume ind: "\Ide A; T \<^sup>*\\<^sup>* A\ \ T \<^sup>*\\\<^sup>* A = T" + assume Ide: "Ide (a # A)" + assume Con: "T \<^sup>*\\<^sup>* a # A" + show "T \<^sup>*\\\<^sup>* (a # A) = T" + by (metis (no_types, lifting) Con Con_initial_left Con_sym Ide Ide.elims(2) + Resid_cons(2) Resid_single_ide(2) ind list.inject) + qed + + lemma Resid_Ide_Arr_ind: + shows "\Ide A; A \<^sup>*\\<^sup>* T\ \ Ide (A \<^sup>*\\\<^sup>* T)" + proof (induct A) + show "\Ide []; [] \<^sup>*\\<^sup>* T\ \ Ide ([] \<^sup>*\\\<^sup>* T)" + by simp + fix a A + assume ind: "\Ide A; A \<^sup>*\\<^sup>* T\ \ Ide (A \<^sup>*\\\<^sup>* T)" + assume Ide: "Ide (a # A)" + assume Con: "a # A \<^sup>*\\<^sup>* T" + have T: "Arr T" + using Con Ide Con_single_ide_ind Con_initial_left Ide.elims(2) + by blast + show "Ide ((a # A) \<^sup>*\\\<^sup>* T)" + proof (cases "A = []") + show "A = [] \ ?thesis" + by (metis Con Con_sym1 Ide Ide.simps(2) Resid1x_as_Resid Resid1x_ide + Residx1_as_Resid Con_sym) + assume A: "A \ []" + show ?thesis + proof - + have "Ide ([a] \<^sup>*\\\<^sup>* T)" + by (metis Con Con_initial_left Con_sym Con_sym1 Ide Ide.simps(3) + Resid1x_as_Resid Residx1_as_Resid Ide.simps(2) Resid1x_ide + list.exhaust_sel) + moreover have "Trgs ([a] \<^sup>*\\\<^sup>* T) \ Srcs (A \<^sup>*\\\<^sup>* T)" + using A T Ide Con + by (metis (no_types, lifting) Con_sym Ide.elims(2) Ide.simps(2) Resid_Arr_Ide_ind + Srcs_Resid Trgs_Resid_sym Con_cons(2) dual_order.eq_iff list.inject) + moreover have "Ide (A \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* [a]))" + by (metis A Con Con_cons(1) Con_sym Ide Ide.simps(3) Resid_Arr_Ide_ind + Resid_single_ide(2) ind list.exhaust_sel) + moreover have "Ide ((a # A) \<^sup>*\\\<^sup>* T) \ + Ide ([a] \<^sup>*\\\<^sup>* T) \ Ide (A \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* [a])) \ + Trgs ([a] \<^sup>*\\\<^sup>* T) \ Srcs (A \<^sup>*\\\<^sup>* T)" + using calculation(1-3) + by (metis Arr.simps(1) Con Ide Ide.simps(3) Resid1x_as_Resid Resid_cons' + Trgs.simps(2) Con_single_ide_iff Ide.simps(2) Ide_implies_Arr Resid_Arr_Src + list.exhaust_sel) + ultimately show ?thesis by blast + qed + qed + qed + + lemma Resid_Ide: + assumes "Ide A" and "A \<^sup>*\\<^sup>* T" + shows "T \<^sup>*\\\<^sup>* A = T" and "Ide (A \<^sup>*\\\<^sup>* T)" + using assms Resid_Ide_Arr_ind Resid_Arr_Ide_ind Con_sym by auto + + lemma Con_Ide_iff: + shows "Ide A \ A \<^sup>*\\<^sup>* T \ Arr T \ Srcs T = Srcs A" + proof (induct A) + show "Ide [] \ [] \<^sup>*\\<^sup>* T \ Arr T \ Srcs T = Srcs []" + by simp + fix a A + assume ind: "Ide A \ A \<^sup>*\\<^sup>* T \ Arr T \ Srcs T = Srcs A" + assume Ide: "Ide (a # A)" + show "a # A \<^sup>*\\<^sup>* T \ Arr T \ Srcs T = Srcs (a # A)" + proof (cases "A = []") + show "A = [] \ ?thesis" + using Con_single_ide_ind Ide + by (metis Arr.simps(2) Con_sym Ide.simps(2) Ide_implies_Arr R.arrE + Resid_Arr_Src Srcs.simps(2) Srcs_Resid R.in_sourcesI) + assume A: "A \ []" + have "a # A \<^sup>*\\<^sup>* T \ [a] \<^sup>*\\<^sup>* T \ A \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* [a]" + using A Ide Con_cons(1) [of A T a] by fastforce + also have 1: "... \ Arr T \ a \ Srcs T" + by (metis A Arr_has_Src Con_single_ide_ind Ide Ide.elims(2) Resid_Arr_Src + Srcs_Resid_Arr_single Con_sym Srcs_eqI ind inf.absorb_iff2 list.inject) + also have "... \ Arr T \ Srcs T = Srcs (a # A)" + by (metis A 1 Con_sym Ide Ide.simps(3) R.ideE + R.sources_resid Resid_Arr_Src Srcs.simps(3) Srcs_Resid_Arr_single + list.exhaust_sel R.in_sourcesI) + finally show "a # A \<^sup>*\\<^sup>* T \ Arr T \ Srcs T = Srcs (a # A)" + by blast + qed + qed + + lemma Con_IdeI: + assumes "Ide A" and "Arr T" and "Srcs T = Srcs A" + shows "A \<^sup>*\\<^sup>* T" and "T \<^sup>*\\<^sup>* A" + using assms Con_Ide_iff Con_sym by auto + + lemma Con_Arr_self: + shows "Arr T \ T \<^sup>*\\<^sup>* T" + proof (induct T) + show "Arr [] \ [] \<^sup>*\\<^sup>* []" + by simp + fix t T + assume ind: "Arr T \ T \<^sup>*\\<^sup>* T" + assume Arr: "Arr (t # T)" + show "t # T \<^sup>*\\<^sup>* t # T" + proof (cases "T = []") + show "T = [] \ ?thesis" + using Arr R.arrE by simp + assume T: "T \ []" + have "t \ t \ T \<^sup>*\\<^sup>* [t \\ t] \ [t \\ t] \<^sup>*\\<^sup>* T \ T \<^sup>*\\\<^sup>* [t \\ t] \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* [t \\ t]" + proof - + have "t \ t" + using Arr Arr.elims(1) by auto + moreover have "T \<^sup>*\\<^sup>* [t \\ t]" + proof - + have "Ide [t \\ t]" + by (simp add: R.arr_def R.prfx_reflexive calculation) + moreover have "Srcs [t \\ t] = Srcs T" + by (metis Arr Arr.simps(2) Arr_has_Trg R.arrE R.sources_resid Srcs.simps(2) + Srcs_eqI T Trgs.simps(2) Arr.simps(3) inf.absorb_iff2 list.exhaust) + ultimately show ?thesis + by (metis Arr Con_sym T Arr.simps(3) Con_Ide_iff neq_Nil_conv) + qed + ultimately show ?thesis + by (metis Con_single_ide_ind Con_sym R.prfx_reflexive + Resid_single_ide(2) ind R.con_implies_arr(1)) + qed + thus ?thesis + using Con_rec(4) [of T T t t] by force + qed + qed + + lemma Resid_Arr_self: + shows "Arr T \ Ide (T \<^sup>*\\\<^sup>* T)" + proof (induct T) + show "Arr [] \ Ide ([] \<^sup>*\\\<^sup>* [])" + by simp + fix t T + assume ind: "Arr T \ Ide (T \<^sup>*\\\<^sup>* T)" + assume Arr: "Arr (t # T)" + show "Ide ((t # T) \<^sup>*\\\<^sup>* (t # T))" + proof (cases "T = []") + show "T = [] \ ?thesis" + using Arr R.prfx_reflexive by auto + assume T: "T \ []" + have 1: "(t # T) \<^sup>*\\\<^sup>* (t # T) = t \<^sup>1\\\<^sup>* (t # T) # T \<^sup>*\\\<^sup>* ((t # T) \<^sup>*\\\<^sup>* [t])" + using Arr T Resid_cons' [of T t "t # T"] Con_Arr_self by presburger + also have "... = (t \\ t) \<^sup>1\\\<^sup>* T # T \<^sup>*\\\<^sup>* (t \<^sup>1\\\<^sup>* [t] # T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t]))" + using Arr T Resid_cons' [of T t "[t]"] + by (metis Con_initial_right Resid1x.simps(3) calculation neq_Nil_conv) + also have "... = (t \\ t) \<^sup>1\\\<^sup>* T # (T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t])) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t]))" + by (metis 1 Resid1x.simps(2) Residx1.simps(2) Residx1_as_Resid T calculation + Con_cons(1) Con_rec(4) Resid_cons(2) list.distinct(1) list.inject) + finally have 2: "(t # T) \<^sup>*\\\<^sup>* (t # T) = + (t \\ t) \<^sup>1\\\<^sup>* T # (T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t])) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t]))" + by blast + moreover have "Ide ..." + proof - + have "R.ide ((t \\ t) \<^sup>1\\\<^sup>* T)" + using Arr T + by (metis Con_initial_right Con_rec(2) Con_sym1 R.con_implies_arr(1) + Resid1x_ide Con_Arr_self Residx1_as_Resid R.prfx_reflexive) + moreover have "Ide ((T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t])) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t])))" + using Arr T + by (metis Con_Arr_self Con_rec(4) Resid_single_ide(2) Con_single_ide_ind + Resid.simps(3) ind R.prfx_reflexive R.con_implies_arr(2)) + moreover have "R.targets ((t \\ t) \<^sup>1\\\<^sup>* T) \ + Srcs ((T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t])) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [t])))" + by (metis (no_types, lifting) 1 2 Con_cons(1) Resid1x_as_Resid T Trgs.simps(2) + Trgs_Resid_sym Srcs_Resid dual_order.eq_iff list.discI list.inject) + ultimately show ?thesis + using Arr T + by (metis Ide.simps(1,3) list.exhaust_sel) + qed + ultimately show ?thesis by auto + qed + qed + + lemma Con_imp_eq_Srcs: + assumes "T \<^sup>*\\<^sup>* U" + shows "Srcs T = Srcs U" + proof (cases T) + show "T = [] \ ?thesis" + using assms by simp + fix t T' + assume T: "T = t # T'" + show "Srcs T = Srcs U" + proof (cases U) + show "U = [] \ ?thesis" + using assms T by simp + fix u U' + assume U: "U = u # U'" + show "Srcs T = Srcs U" + by (metis Con_initial_right Con_rec(1) Con_sym R.con_imp_common_source + Srcs.simps(2-3) Srcs_eqI T Trgs.cases U assms) + qed + qed + + lemma Arr_iff_Con_self: + shows "Arr T \ T \<^sup>*\\<^sup>* T" + proof (induct T) + show "Arr [] \ [] \<^sup>*\\<^sup>* []" + by simp + fix t T + assume ind: "Arr T \ T \<^sup>*\\<^sup>* T" + show "Arr (t # T) \ t # T \<^sup>*\\<^sup>* t # T" + proof (cases "T = []") + show "T = [] \ ?thesis" + by auto + assume T: "T \ []" + show ?thesis + proof + show "Arr (t # T) \ t # T \<^sup>*\\<^sup>* t # T" + using Con_Arr_self by simp + show "t # T \<^sup>*\\<^sup>* t # T \ Arr (t # T)" + proof - + assume Con: "t # T \<^sup>*\\<^sup>* t # T" + have "R.arr t" + using T Con Con_rec(4) [of T T t t] by blast + moreover have "Arr T" + using T Con Con_rec(4) [of T T t t] ind R.arrI + by (meson R.prfx_reflexive Con_single_ide_ind) + moreover have "R.targets t \ Srcs T" + using T Con + by (metis Con_cons(2) Con_imp_eq_Srcs Trgs.simps(2) + Srcs_Resid list.distinct(1) subsetI) + ultimately show ?thesis + by (cases T) auto + qed + qed + qed + qed + + lemma Arr_Resid_single: + shows "\u. T \<^sup>*\\<^sup>* [u] \ Arr (T \<^sup>*\\\<^sup>* [u])" + proof (induct T) + show "\u. [] \<^sup>*\\<^sup>* [u] \ Arr ([] \<^sup>*\\\<^sup>* [u])" + by simp + fix t u T + assume ind: "\u. T \<^sup>*\\<^sup>* [u] \ Arr (T \<^sup>*\\\<^sup>* [u])" + assume Con: "t # T \<^sup>*\\<^sup>* [u]" + show "Arr ((t # T) \<^sup>*\\\<^sup>* [u])" + proof (cases "T = []") + show "T = [] \ ?thesis" + using Con Arr_iff_Con_self R.con_imp_arr_resid Con_rec(1) by fastforce + assume T: "T \ []" + have "Arr ((t # T) \<^sup>*\\\<^sup>* [u]) \ Arr ((t \\ u) # (T \<^sup>*\\\<^sup>* [u \\ t]))" + using Con T Resid_rec(2) by auto + also have "... \ R.arr (t \\ u) \ Arr (T \<^sup>*\\\<^sup>* [u \\ t]) \ + R.targets (t \\ u) \ Srcs (T \<^sup>*\\\<^sup>* [u \\ t])" + using Con T + by (metis Arr.simps(3) Con_rec(2) neq_Nil_conv) + also have "... \ R.con t u \ Arr (T \<^sup>*\\\<^sup>* [u \\ t])" + using Con T + by (metis Srcs_Resid_Arr_single Con_rec(2) R.arr_resid_iff_con subsetI + R.targets_resid_sym) + also have "... \ True" + using Con ind T Con_rec(2) by blast + finally show ?thesis by auto + qed + qed + + lemma Con_imp_Arr_Resid: + shows "\T. T \<^sup>*\\<^sup>* U \ Arr (T \<^sup>*\\\<^sup>* U)" + proof (induct U) + show "\T. T \<^sup>*\\<^sup>* [] \ Arr (T \<^sup>*\\\<^sup>* [])" + by (meson Con_sym Resid.simps(1)) + fix u U T + assume ind: "\T. T \<^sup>*\\<^sup>* U \ Arr (T \<^sup>*\\\<^sup>* U)" + assume Con: "T \<^sup>*\\<^sup>* u # U" + show "Arr (T \<^sup>*\\\<^sup>* (u # U))" + by (metis Arr_Resid_single Con Resid_cons(2) ind) + qed + + lemma Cube_ind: + shows "\T U V. \T \<^sup>*\\<^sup>* U; V \<^sup>*\\<^sup>* T; length T + length U + length V \ n\ \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U) \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U))" + proof (induct n) + show "\T U V. \T \<^sup>*\\<^sup>* U; V \<^sup>*\\<^sup>* T; length T + length U + length V \ 0\ \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U) \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U))" + by simp + fix n and T U V :: "'a list" + assume Con_TU: "T \<^sup>*\\<^sup>* U" and Con_VT: "V \<^sup>*\\<^sup>* T" + have T: "T \ []" + using Con_TU by auto + have U: "U \ []" + using Con_TU Con_sym Resid.simps(1) by blast + have V: "V \ []" + using Con_VT by auto + assume len: "length T + length U + length V \ Suc n" + assume ind: "\T U V. \T \<^sup>*\\<^sup>* U; V \<^sup>*\\<^sup>* T; length T + length U + length V \ n\ \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U) \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U))" + show "(V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U) \ + (V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U))" + proof (cases V) + show "V = [] \ ?thesis" + using V by simp + (* + * TODO: I haven't found a better way to do this than just consider each combination + * of T U V being a singleton. + *) + fix v V' + assume V: "V = v # V'" + show ?thesis + proof (cases U) + show "U = [] \ ?thesis" + using U by simp + fix u U' + assume U: "U = u # U'" + show ?thesis + proof (cases T) + show "T = [] \ ?thesis" + using T by simp + fix t T' + assume T: "T = t # T'" + show ?thesis + proof (cases "V' = []", cases "U' = []", cases "T' = []") + show "\V' = []; U' = []; T' = []\ \ ?thesis" + using T U V R.cube Con_TU Resid.simps(2) Resid.simps(3) R.arr_resid_iff_con + R.con_implies_arr Con_sym + by metis + assume T': "T' \ []" and V': "V' = []" and U': "U' = []" + have 1: "U \<^sup>*\\<^sup>* [t]" + using T Con_TU Con_cons(2) Con_sym Resid.simps(2) by metis + have 2: "V \<^sup>*\\<^sup>* [t]" + using V Con_VT Con_initial_right T by blast + show ?thesis + proof (intro conjI impI) + have 3: "length [t] + length U + length V \ n" + using T T' le_Suc_eq len by fastforce + show *: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T'" + using Con_TU Con_VT Con_sym Resid_cons(2) T T' by force + also have "... \ V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t] \ + (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + proof (intro iffI conjI) + show "(V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \ V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]" + using T U V T' U' V' 1 ind len Con_TU Con_rec(2) Resid_rec(1) + Resid.simps(1) length_Cons Suc_le_mono add_Suc + by (metis (no_types)) + show "(V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \ + (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + using T U V T' U' V' + by (metis Con_sym Resid.simps(1) Resid_rec(1) Suc_le_mono ind len + length_Cons list.size(3-4)) + show "V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t] \ + (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \ + (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T'" + using T U V T' U' V' 1 ind len Con_TU Con_VT Con_rec(1-3) + by (metis (no_types, lifting) One_nat_def Resid_rec(1) Suc_le_mono + add.commute list.size(3) list.size(4) plus_1_eq_Suc) + qed + also have "... \ (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + by (metis 2 3 Con_sym ind Resid.simps(1)) + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + using Con_rec(2) [of T' t] + by (metis (no_types, lifting) "1" Con_TU Con_cons(2) Resid.simps(1) + Resid.simps(3) Resid_rec(2) T T' U U') + finally show ?thesis by simp + qed + assume Con: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T" + show "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + have "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* ((U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T')" + using Con_TU Con_VT Con_sym Resid_cons(2) T T' by force + also have "... = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + using T U V T' U' V' 1 Con ind [of T' "Resid U [t]" "Resid V [t]"] + by (metis One_nat_def add.commute calculation len length_0_conv length_Resid + list.size(4) nat_add_left_cancel_le Con_sym plus_1_eq_Suc) + also have "... = ((V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U)) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + by (metis "1" "2" "3" Con_sym ind) + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + using T U T' U' Con * + by (metis Con_sym Resid_rec(1-2) Resid.simps(1) Resid_cons(2)) + finally show ?thesis by simp + qed + qed + next + assume U': "U' \ []" and V': "V' = []" + show ?thesis + proof (intro conjI impI) + show *: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof (cases "T' = []") + assume T': "T' = []" + show ?thesis + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* (u \\ t) # (U' \<^sup>*\\\<^sup>* [t \\ u])" + using Con_TU Con_sym Resid_rec(2) T T' U U' by auto + also have "... \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* U' \<^sup>*\\\<^sup>* [t \\ u]" + by (metis Con_TU Con_cons(2) Con_rec(3) Con_sym Resid.simps(1) T U U') + also have "... \ (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u] \<^sup>*\\<^sup>* U' \<^sup>*\\\<^sup>* [t \\ u]" + using T U V V' R.cube_ax + apply simp + by (metis R.con_implies_arr(1) R.not_arr_null R.con_def) + also have "... \ (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U' \<^sup>*\\<^sup>* [t \\ u] \<^sup>*\\\<^sup>* U'" + proof - + have "length [t \\ u] + length U' + length (V \<^sup>*\\\<^sup>* [u]) \ n" + using T U V V' len by force + thus ?thesis + by (metis Con_sym Resid.simps(1) add.commute ind) + qed + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + by (metis Con_TU Resid_cons(2) Resid_rec(3) T T' U U' Con_cons(2) + length_Resid length_0_conv) + finally show ?thesis by simp + qed + next + assume T': "T' \ []" + show ?thesis + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* ((U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T')" + using Con_TU Con_VT Con_sym Resid_cons(2) T T' by force + also have "... \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + proof - + have "length T' + length (U \<^sup>*\\\<^sup>* [t]) + length (V \<^sup>*\\\<^sup>* [t]) \ n" + by (metis (no_types, lifting) Con_TU Con_VT Con_initial_right Con_sym + One_nat_def Suc_eq_plus1 T ab_semigroup_add_class.add_ac(1) + add_le_imp_le_left len length_Resid list.size(4) plus_1_eq_Suc) + thus ?thesis + by (metis Con_TU Con_VT Con_cons(1) Con_cons(2) T T' U V ind list.discI) + qed + also have "... \ (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + proof - + have "length [t] + length U + length V \ n" + using T T' le_Suc_eq len by fastforce + thus ?thesis + by (metis Con_TU Con_VT Con_initial_left Con_initial_right T ind) + qed + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + by (metis Con_cons(2) Con_sym Resid.simps(1) Resid1x_as_Resid + Residx1_as_Resid Resid_cons' T T') + finally show ?thesis by blast + qed + qed + show "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + assume Con: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T" + show ?thesis + proof (cases "T' = []") + assume T': "T' = []" + show ?thesis + proof - + have 1: "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* ((u \\ t) # (U'\<^sup>*\\\<^sup>* [t \\ u]))" + using Con_TU Con_sym Resid_rec(2) T T' U U' by force + also have "... = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + by (metis Con Con_TU Con_rec(2) Con_sym Resid_cons(2) T T' U U' + calculation) + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + by (metis "*" Con Con_rec(3) R.cube Resid.simps(1,3) T T' U V V' + calculation R.conI R.conE) + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ([t \\ u] \<^sup>*\\\<^sup>* U')" + proof - + have "length [t \\ u] + length (U' \<^sup>*\\\<^sup>* [t \\ u]) + length (V \<^sup>*\\\<^sup>* [u]) \ n" + by (metis (no_types, lifting) Nat.le_diff_conv2 One_nat_def T U V V' + add.commute add_diff_cancel_left' add_leD2 len length_Cons + length_Resid list.size(3) plus_1_eq_Suc) + thus ?thesis + by (metis Con_sym add.commute Resid.simps(1) ind length_Resid) + qed + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + by (metis Con_TU Con_cons(2) Resid_cons(2) T T' U U' + Resid_rec(3) length_0_conv length_Resid) + finally show ?thesis by blast + qed + next + assume T': "T' \ []" + show ?thesis + proof - + have "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = + ((V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* ([u] \<^sup>*\\\<^sup>* T)) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* [u]))" + by (metis Con Con_TU Resid.simps(2) Resid1x_as_Resid U U' + Con_cons(2) Con_sym Resid_cons' Resid_cons(2)) + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* [u])) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* [u]))" + proof - + have "length T + length [u] + length V \ n" + using U U' antisym_conv len not_less_eq_eq by fastforce + thus ?thesis + by (metis Con_TU Con_VT Con_initial_right U ind) + qed + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ((T \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U')" + proof - + have "length (T \<^sup>*\\\<^sup>* [u]) + length U' + length (V \<^sup>*\\\<^sup>* [u]) \ n" + using Con_TU Con_initial_right U V V' len length_Resid by force + thus ?thesis + by (metis Con Con_TU Con_cons(2) U U' calculation ind length_0_conv + length_Resid) + qed + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + by (metis "*" Con Con_TU Resid_cons(2) U U' length_Resid length_0_conv) + finally show ?thesis by blast + qed + qed + qed + qed + next + assume V': "V' \ []" + show ?thesis + proof (cases "U' = []") + assume U': "U' = []" + show ?thesis + proof (cases "T' = []") + assume T': "T' = []" + show ?thesis + proof (intro conjI impI) + show *: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ (v \\ t) # (V' \<^sup>*\\\<^sup>* [t \\ v]) \<^sup>*\\<^sup>* [u \\ t]" + using Con_TU Con_VT Con_sym Resid_rec(1-2) T T' U U' V V' + by metis + also have "... \ [v \\ t] \<^sup>*\\<^sup>* [u \\ t] \ + V' \<^sup>*\\\<^sup>* [t \\ v] \<^sup>*\\<^sup>* [u \\ v] \<^sup>*\\\<^sup>* [t \\ v]" + by (metis T T' V V' Con_VT Con_rec(1-2) Con_sym R.con_def R.cube + Resid.simps(3)) + also have "... \ [v \\ t] \<^sup>*\\<^sup>* [u \\ t] \ + V' \<^sup>*\\\<^sup>* [u \\ v] \<^sup>*\\<^sup>* [t \\ v] \<^sup>*\\\<^sup>* [u \\ v]" + proof - + have "length [t \\ v] + length [u \\ v] + length V' \ n" + using T U V len by fastforce + thus ?thesis + by (metis Con_imp_Arr_Resid Arr_has_Src Con_VT T T' Trgs.simps(1) + Trgs_Resid_sym V V' Con_rec(2) Srcs_Resid ind) + qed + also have "... \ [v \\ t] \<^sup>*\\<^sup>* [u \\ t] \ + V' \<^sup>*\\\<^sup>* [u \\ v] \<^sup>*\\<^sup>* [t \\ u] \<^sup>*\\\<^sup>* [v \\ u]" + by (simp add: R.con_def R.cube) + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof + assume 1: "V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + have tu_vu: "t \\ u \ v \\ u" + by (metis (no_types, lifting) 1 T T' U U' V V' Con_rec(3) + Resid_rec(1-2) Con_sym length_Resid length_0_conv) + have vt_ut: "v \\ t \ u \\ t" + using 1 + by (metis R.con_def R.con_sym R.cube tu_vu) + show "[v \\ t] \<^sup>*\\<^sup>* [u \\ t] \ V' \<^sup>*\\\<^sup>* [u \\ v] \<^sup>*\\<^sup>* [t \\ u] \<^sup>*\\\<^sup>* [v \\ u]" + by (metis (no_types, lifting) "1" Con_TU Con_cons(1) Con_rec(1-2) + Resid_rec(1) T T' U U' V V' Resid_rec(2) length_Resid + length_0_conv vt_ut) + next + assume 1: "[v \\ t] \<^sup>*\\<^sup>* [u \\ t] \ + V' \<^sup>*\\\<^sup>* [u \\ v] \<^sup>*\\<^sup>* [t \\ u] \<^sup>*\\\<^sup>* [v \\ u]" + have tu_vu: "t \\ u \ v \\ u \ v \\ t \ u \\ t" + by (metis 1 Con_sym Resid.simps(1) Residx1.simps(2) + Residx1_as_Resid) + have tu: "t \ u" + using Con_TU Con_rec(1) T T' U U' by blast + show "V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + by (metis (no_types, opaque_lifting) 1 Con_rec(2) Con_sym + R.con_implies_arr(2) Resid.simps(1,3) T T' U U' V V' + Resid_rec(2) R.arr_resid_iff_con) + qed + finally show ?thesis by simp + qed + show "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + assume Con: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T" + have "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = ((v \\ t) # (V' \<^sup>*\\\<^sup>* [t \\ v])) \<^sup>*\\\<^sup>* [u \\ t]" + using Con_TU Con_VT Con_sym Resid_rec(1-2) T T' U U' V V' by metis + also have 1: "... = ((v \\ t) \\ (u \\ t)) # + (V' \<^sup>*\\\<^sup>* [t \\ v]) \<^sup>*\\\<^sup>* ([u \\ v] \<^sup>*\\\<^sup>* [t \\ v])" + apply simp + by (metis Con Con_VT Con_rec(2) R.conE R.conI R.con_sym R.cube + Resid_rec(2) T T' V V' calculation(1)) + also have "... = ((v \\ t) \\ (u \\ t)) # + (V' \<^sup>*\\\<^sup>* [u \\ v]) \<^sup>*\\\<^sup>* ([t \\ v] \<^sup>*\\\<^sup>* [u \\ v])" + proof - + have "length [t \\ v] + length [u \\ v] + length V' \ n" + using T U V len by fastforce + moreover have "u \\ v \ t \\ v" + by (metis 1 Con_VT Con_rec(2) R.con_sym_ax T T' V V' list.discI + R.conE R.conI R.cube) + moreover have "t \\ v \ u \\ v" + using R.con_sym calculation(2) by blast + ultimately show ?thesis + by (metis Con_VT Con_rec(2) T T' V V' Con_rec(1) ind) + qed + also have "... = ((v \\ t) \\ (u \\ t)) # + ((V' \<^sup>*\\\<^sup>* [u \\ v]) \<^sup>*\\\<^sup>* ([t \\ u] \<^sup>*\\\<^sup>* [v \\ u]))" + using R.cube by fastforce + also have "... = ((v \\ u) \\ (t \\ u)) # + ((V' \<^sup>*\\\<^sup>* [u \\ v]) \<^sup>*\\\<^sup>* ([t \\ u] \<^sup>*\\\<^sup>* [v \\ u]))" + by (metis R.cube) + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + have "(V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U) = ((v \\ u) # ((V' \<^sup>*\\\<^sup>* [u \\ v]))) \<^sup>*\\\<^sup>* [t \\ u]" + using T T' U U' V Resid_cons(1) [of "[u]" v V'] + by (metis "*" Con Con_TU Resid.simps(1) Resid_rec(1) Resid_rec(2)) + also have "... = ((v \\ u) \\ (t \\ u)) # + ((V' \<^sup>*\\\<^sup>* [u \\ v]) \<^sup>*\\\<^sup>* ([t \\ u] \<^sup>*\\\<^sup>* [v \\ u]))" + by (metis "*" Con Con_initial_left calculation Con_sym Resid.simps(1) + Resid_rec(1-2)) + finally show ?thesis by simp + qed + finally show ?thesis by simp + qed + qed + next + assume T': "T' \ []" + show ?thesis + proof (intro conjI impI) + show *: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* [u \\ t] \<^sup>*\\\<^sup>* T'" + using Con_TU Con_VT Con_sym Resid_cons(2) Resid_rec(3) T T' U U' + by force + also have "... \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* [u \\ t]" + proof - + have "length [u \\ t] + length T' + length (V \<^sup>*\\\<^sup>* [t]) \ n" + using Con_VT Con_initial_right T U length_Resid len by fastforce + thus ?thesis + by (metis Con_TU Con_VT Con_rec(2) T T' U V add.commute Con_cons(2) + ind list.discI) + qed + also have "... \ (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u] \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* [u \\ t]" + proof - + have "length [t] + length [u] + length V \ n" + using T T' U le_Suc_eq len by fastforce + hence "(V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* ([u] \<^sup>*\\\<^sup>* [t]) = (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* [u])" + using ind [of "[t]" "[u]" V] + by (metis Con_TU Con_VT Con_initial_left Con_initial_right T U) + thus ?thesis + by (metis (full_types) Con_TU Con_initial_left Con_sym Resid_rec(1) T U) + qed + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + by (metis Con_TU Con_cons(2) Con_rec(2) Resid.simps(1) Resid_rec(2) + T T' U U') + finally show ?thesis by simp + qed + show "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + assume Con: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T" + have "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* ([u \\ t] \<^sup>*\\\<^sup>* T')" + using Con_TU Con_VT Con_sym Resid_cons(2) Resid_rec(3) T T' U U' + by force + also have "... = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* [u \\ t])" + proof - + have "length [u \\ t] + length T' + length (Resid V [t]) \ n" + using Con_VT Con_initial_right T U length_Resid len by fastforce + thus ?thesis + by (metis Con_TU Con_VT Con_cons(2) Con_rec(2) T T' U V add.commute + ind list.discI) + qed + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u]) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* [u \\ t])" + proof - + have "length [t] + length [u] + length V \ n" + using T T' U le_Suc_eq len by fastforce + thus ?thesis + using ind [of "[t]" "[u]" V] + by (metis Con_TU Con_VT Con_initial_left Con_sym Resid_rec(1) T U) + qed + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + using * Con Con_TU Con_rec(2) Resid_cons(2) Resid_rec(2) T T' U U' + by auto + finally show ?thesis by simp + qed + qed + qed + next + assume U': "U' \ []" + show ?thesis + proof (cases "T' = []") + assume T': "T' = []" + show ?thesis + proof (intro conjI impI) + show *: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* (u \\ t) # (U' \<^sup>*\\\<^sup>* [t \\ u])" + using T U V T' U' V' Con_TU Con_VT Con_sym Resid_rec(2) by auto + also have "... \ V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* [u \\ t] \ + (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u \\ t] \<^sup>*\\<^sup>* U' \<^sup>*\\\<^sup>* [t \\ u]" + by (metis Con_TU Con_VT Con_cons(2) Con_initial_right + Con_rec(2) Con_sym T U U') + also have "... \ V \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* [u \\ t] \ + (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u] \<^sup>*\\<^sup>* U' \<^sup>*\\\<^sup>* [t \\ u]" + proof - + have "length [u] + length [t] + length V \ n" + using T U V T' U' V' len not_less_eq_eq order_trans by fastforce + thus ?thesis + using ind [of "[t]" "[u]" V] + by (metis Con_TU Con_VT Con_initial_right Resid_rec(1) T U + Con_sym length_Cons) + qed + also have "... \ V \<^sup>*\\\<^sup>* [u] \<^sup>*\\<^sup>* [t \\ u] \ + (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u] \<^sup>*\\<^sup>* U' \<^sup>*\\\<^sup>* [t \\ u]" + proof - + have "length [t] + length [u] + length V \ n" + using T U V T' U' V' len antisym_conv not_less_eq_eq by fastforce + thus ?thesis + by (metis (full_types) Con_TU Con_VT Con_initial_right Con_sym + Resid_rec(1) T U ind) + qed + also have "... \ (V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U' \<^sup>*\\<^sup>* [t \\ u] \<^sup>*\\\<^sup>* U'" + proof - + have "length [t \\ u] + length U' + length (V \<^sup>*\\\<^sup>* [u]) \ n" + by (metis T T' U add.assoc add.right_neutral add_leD1 + add_le_cancel_left length_Resid len length_Cons list.size(3) + plus_1_eq_Suc) + thus ?thesis + by (metis (no_types, opaque_lifting) Con_sym Resid.simps(1) + add.commute ind) + qed + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + by (metis Con_TU Resid_cons(2) Resid_rec(3) T T' U U' + Con_cons(2) length_Resid length_0_conv) + finally show ?thesis by blast + qed + show "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ + (V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + assume Con: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T" + have "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = + (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* ((u \\ t) # (U' \<^sup>*\\\<^sup>* [t \\ u]))" + using Con_TU Con_sym Resid_rec(2) T T' U U' by auto + also have "... = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u \\ t]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + by (metis Con Con_TU Con_rec(2) Con_sym T T' U U' calculation + Resid_cons(2)) + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* [t \\ u]) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t \\ u])" + proof - + have "length [t] + length [u] + length V \ n" + using T U U' le_Suc_eq len by fastforce + thus ?thesis + using T U Con_TU Con_VT Con_sym ind [of "[t]" "[u]" V] + by (metis (no_types, opaque_lifting) Con_initial_right Resid.simps(3)) + qed + also have "... = ((V \<^sup>*\\\<^sup>* [u]) \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ([t \\ u] \<^sup>*\\\<^sup>* U')" + proof - + have "length [t \\ u] + length U' + length (V \<^sup>*\\\<^sup>* [u]) \ n" + by (metis (no_types, opaque_lifting) T T' U add.left_commute + add.right_neutral add_leD2 add_le_cancel_left len length_Cons + length_Resid list.size(3) plus_1_eq_Suc) + thus ?thesis + by (metis Con Con_TU Con_rec(3) T T' U U' calculation + ind length_0_conv length_Resid) + qed + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + by (metis "*" Con Con_TU Resid_rec(3) T T' U U' Resid_cons(2) + length_Resid length_0_conv) + finally show ?thesis by blast + qed + qed + next + assume T': "T' \ []" + show ?thesis + proof (intro conjI impI) + have 1: "U \<^sup>*\\<^sup>* [t]" + using T Con_TU + by (metis Con_cons(2) Con_sym Resid.simps(2)) + have 2: "V \<^sup>*\\<^sup>* [t]" + using V Con_VT Con_initial_right T by blast + have 3: "length T' + length (U \<^sup>*\\\<^sup>* [t]) + length (V \<^sup>*\\\<^sup>* [t]) \ n" + using "1" "2" T len length_Resid by force + have 4: "length [t] + length U + length V \ n" + using T T' len antisym_conv not_less_eq_eq by fastforce + show *: "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + proof - + have "V \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* T \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T' \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T'" + using Con_TU Con_VT Con_sym Resid_cons(2) T T' by force + also have "... \ (V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + by (metis 3 Con_TU Con_VT Con_cons(1) Con_cons(2) T T' U V ind + list.discI) + also have "... \ (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U) \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + by (metis 1 2 4 Con_sym ind) + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* hd ([t] \<^sup>*\\\<^sup>* U) # T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + by (metis 1 Con_TU Con_cons(1) Con_cons(2) Resid.simps(1) + Resid1x_as_Resid T T' list.sel(1)) + also have "... \ V \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T \<^sup>*\\\<^sup>* U" + using 1 Resid_cons' [of T' t U] Con_TU T T' Resid1x_as_Resid + Con_sym + by force + finally show ?thesis by simp + qed + show "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + proof - + have "(V \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T) = + ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* ((U \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* T')" + using Con_TU Con_VT Con_sym Resid_cons(2) T T' by force + also have "... = ((V \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + by (metis (no_types, lifting) "3" Con_TU Con_VT T T' U V Con_cons(1) + Con_cons(2) ind list.simps(3)) + also have "... = ((V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U)) \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + by (metis 1 2 4 Con_sym ind) + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ((t # T') \<^sup>*\\\<^sup>* U)" + by (metis "*" Con_TU Con_cons(1) Resid1x_as_Resid + Resid_cons' T T' U calculation Resid_cons(2) list.distinct(1)) + also have "... = (V \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* U)" + using T by fastforce + finally show ?thesis by simp + qed + qed + qed + qed + qed + qed + qed + qed + qed + + lemma Cube: + shows "T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* V \<^sup>*\\\<^sup>* U \ T \<^sup>*\\\<^sup>* V \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* V" + and "T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* V \<^sup>*\\\<^sup>* U \ (T \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* U) = (T \<^sup>*\\\<^sup>* V) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* V)" + proof - + show "T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* V \<^sup>*\\\<^sup>* U \ T \<^sup>*\\\<^sup>* V \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* V" + using Cube_ind by (metis Con_sym Resid.simps(1) le_add2) + show "T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* V \<^sup>*\\\<^sup>* U \ (T \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* U) = (T \<^sup>*\\\<^sup>* V) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* V)" + using Cube_ind by (metis Con_sym Resid.simps(1) order_refl) + qed + + lemma Con_implies_Arr: + assumes "T \<^sup>*\\<^sup>* U" + shows "Arr T" and "Arr U" + using assms Con_sym + by (metis Con_imp_Arr_Resid Arr_iff_Con_self Cube(1) Resid.simps(1))+ + + sublocale partial_magma Resid + by (unfold_locales, metis Resid.simps(1) Con_sym) + + lemma is_partial_magma: + shows "partial_magma Resid" + .. + + lemma null_char: + shows "null = []" + by (metis null_is_zero(2) Resid.simps(1)) + + sublocale residuation Resid + using null_char Con_sym Arr_iff_Con_self Con_imp_Arr_Resid Cube null_is_zero(2) + by unfold_locales auto + + lemma is_residuation: + shows "residuation Resid" + .. + + lemma arr_char: + shows "arr T \ Arr T" + using null_char Arr_iff_Con_self by fastforce + + lemma arrI\<^sub>P [intro]: + assumes "Arr T" + shows "arr T" + using assms arr_char by auto + + lemma ide_char: + shows "ide T \ Ide T" + by (metis Con_Arr_self Ide_implies_Arr Resid_Arr_Ide_ind Resid_Arr_self arr_char ide_def + arr_def) + + lemma con_char: + shows "con T U \ Con T U" + using null_char by auto + + lemma conI\<^sub>P [intro]: + assumes "Con T U" + shows "con T U" + using assms con_char by auto + + sublocale rts Resid + proof + show "\A T. \ide A; con T A\ \ T \<^sup>*\\\<^sup>* A = T" + using Resid_Arr_Ide_ind ide_char null_char by auto + show "\T. arr T \ ide (trg T)" + by (metis arr_char Resid_Arr_self ide_char resid_arr_self) + show "\A T. \ide A; con A T\ \ ide (A \<^sup>*\\\<^sup>* T)" + by (simp add: Resid_Ide_Arr_ind con_char ide_char) + show "\T U. con T U \ \A. ide A \ con A T \ con A U" + proof - + fix T U + assume TU: "con T U" + have 1: "Srcs T = Srcs U" + using TU Con_imp_eq_Srcs con_char by force + obtain a where a: "a \ Srcs T \ Srcs U" + using 1 + by (metis Int_absorb Int_emptyI TU arr_char Arr_has_Src con_implies_arr(1)) + show "\A. ide A \ con A T \ con A U" + using a 1 + by (metis (full_types) Ball_Collect Con_single_ide_ind Ide.simps(2) Int_absorb TU + Srcs_are_ide arr_char con_char con_implies_arr(1-2) ide_char) + qed + show "\T U V. \ide (Resid T U); con U V\ \ con (T \<^sup>*\\\<^sup>* U) (V \<^sup>*\\\<^sup>* U)" + using null_char ide_char + by (metis Con_imp_Arr_Resid Con_Ide_iff Srcs_Resid con_char con_sym arr_resid_iff_con + ide_implies_arr) + qed + + theorem is_rts: + shows "rts Resid" + .. + + notation cong (infix "\<^sup>*\\<^sup>*" 50) + notation prfx (infix "\<^sup>*\\<^sup>*" 50) + + lemma sources_char\<^sub>P: + shows "sources T = {A. Ide A \ Arr T \ Srcs A = Srcs T}" + using Con_Ide_iff Con_sym con_char ide_char sources_def by fastforce + + lemma sources_cons: + shows "Arr (t # T) \ sources (t # T) = sources [t]" + apply (induct T) + apply simp + using sources_char\<^sub>P by auto + + lemma targets_char\<^sub>P: + shows "targets T = {B. Ide B \ Arr T \ Srcs B = Trgs T}" + unfolding targets_def + by (metis (no_types, lifting) trg_def Arr.simps(1) Ide_implies_Arr Resid_Arr_self + arr_char Con_Ide_iff Srcs_Resid con_char ide_char con_implies_arr(1)) + + lemma seq_char': + shows "seq T U \ Arr T \ Arr U \ Trgs T \ Srcs U \ {}" + proof + show "seq T U \ Arr T \ Arr U \ Trgs T \ Srcs U \ {}" + unfolding seq_def + using Arr_has_Trg arr_char Con_Arr_self sources_char\<^sub>P trg_def trg_in_targets + by fastforce + assume 1: "Arr T \ Arr U \ Trgs T \ Srcs U \ {}" + have "targets T = sources U" + proof - + obtain a where a: "R.ide a \ a \ Trgs T \ a \ Srcs U" + using 1 Trgs_are_ide by blast + have "Trgs [a] = Trgs T" + using a 1 + by (metis Con_single_ide_ind Con_sym Resid_Arr_Src Srcs_Resid Trgs_eqI) + moreover have "Srcs [a] = Srcs U" + using a 1 Con_single_ide_ind Con_imp_eq_Srcs by blast + moreover have "Trgs [a] = Srcs [a]" + using a + by (metis R.residuation_axioms R.sources_resid Srcs.simps(2) Trgs.simps(2) + residuation.ideE) + ultimately show ?thesis + using 1 sources_char\<^sub>P targets_char\<^sub>P by auto + qed + thus "seq T U" + using 1 by blast + qed + + lemma seq_char: + shows "seq T U \ Arr T \ Arr U \ Trgs T = Srcs U" + by (metis Int_absorb Srcs_Resid Arr_has_Src Arr_iff_Con_self Srcs_eqI seq_char') + + lemma seqI\<^sub>P [intro]: + assumes "Arr T" and "Arr U" and "Trgs T \ Srcs U \ {}" + shows "seq T U" + using assms seq_char' by auto + + lemma Ide_imp_sources_eq_targets: + assumes "Ide T" + shows "sources T = targets T" + using assms + by (metis Resid_Arr_Ide_ind arr_iff_has_source arr_iff_has_target con_char + arr_def sources_resid) + + subsection "Inclusion Map" + + text \ + Inclusion of an RTS to the RTS of its paths. + \ + + abbreviation incl + where "incl \ \t. if R.arr t then [t] else null" + + lemma incl_is_simulation: + shows "simulation resid Resid incl" + using R.con_implies_arr(1-2) con_char R.arr_resid_iff_con null_char + by unfold_locales auto + + lemma incl_is_injective: + shows "inj_on incl (Collect R.arr)" + by (intro inj_onI) simp + + lemma reflects_con: + assumes "incl t \<^sup>*\\<^sup>* incl u" + shows "t \ u" + using assms + by (metis (full_types) Arr.simps(1) Con_implies_Arr(1-2) Con_rec(1) null_char) + + end + + subsection "Composites of Paths" + + text \ + The RTS of paths has composites, given by the append operation on lists. + \ + + context paths_in_rts + begin + + lemma Srcs_append [simp]: + assumes "T \ []" + shows "Srcs (T @ U) = Srcs T" + by (metis Nil_is_append_conv Srcs.simps(2) Srcs.simps(3) assms hd_append list.exhaust_sel) + + lemma Trgs_append [simp]: + shows "U \ [] \ Trgs (T @ U) = Trgs U" + proof (induct T) + show "U \ [] \ Trgs ([] @ U) = Trgs U" + by auto + show "\t T. \U \ [] \ Trgs (T @ U) = Trgs U; U \ []\ + \ Trgs ((t # T) @ U) = Trgs U" + by (metis Nil_is_append_conv Trgs.simps(3) append_Cons list.exhaust) + qed + + lemma seq_implies_Trgs_eq_Srcs: + shows "\Arr T; Arr U; Trgs T \ Srcs U\ \ Trgs T = Srcs U" + by (metis inf.orderE Arr_has_Trg seqI\<^sub>P seq_char) + + lemma Arr_append_iff\<^sub>P: + shows "\U. \T \ []; U \ []\ \ Arr (T @ U) \ Arr T \ Arr U \ Trgs T \ Srcs U" + proof (induct T) + show "\U. \[] \ []; U \ []\ \ Arr ([] @ U) = (Arr [] \ Arr U \ Trgs [] \ Srcs U)" + by simp + fix t T and U :: "'a list" + assume ind: "\U. \T \ []; U \ []\ + \ Arr (T @ U) = (Arr T \ Arr U \ Trgs T \ Srcs U)" + assume U: "U \ []" + show "Arr ((t # T) @ U) \ Arr (t # T) \ Arr U \ Trgs (t # T) \ Srcs U" + proof (cases "T = []") + show "T = [] \ ?thesis" + using Arr.elims(1) U by auto + assume T: "T \ []" + have "Arr ((t # T) @ U) \ Arr (t # (T @ U))" + by simp + also have "... \ R.arr t \ Arr (T @ U) \ R.targets t \ Srcs (T @ U)" + using T U + by (metis Arr.simps(3) Nil_is_append_conv neq_Nil_conv) + also have "... \ R.arr t \ Arr T \ Arr U \ Trgs T \ Srcs U \ R.targets t \ Srcs T" + using T U ind by auto + also have "... \ Arr (t # T) \ Arr U \ Trgs (t # T) \ Srcs U" + using T U + by (metis Arr.simps(3) Trgs.simps(3) neq_Nil_conv) + finally show ?thesis by auto + qed + qed + + lemma Arr_consI\<^sub>P [intro, simp]: + assumes "R.arr t" and "Arr U" and "R.targets t \ Srcs U" + shows "Arr (t # U)" + using assms Arr.elims(3) by blast + + lemma Arr_appendI\<^sub>P [intro, simp]: + assumes "Arr T" and "Arr U" and "Trgs T \ Srcs U" + shows "Arr (T @ U)" + using assms + by (metis Arr.simps(1) Arr_append_iff\<^sub>P) + + lemma Arr_appendE\<^sub>P [elim]: + assumes "Arr (T @ U)" and "T \ []" and "U \ []" + and "\Arr T; Arr U; Trgs T = Srcs U\ \ thesis" + shows thesis + using assms Arr_append_iff\<^sub>P seq_implies_Trgs_eq_Srcs by force + + lemma Ide_append_iff\<^sub>P: + shows "\U. \T \ []; U \ []\ \ Ide (T @ U) \ Ide T \ Ide U \ Trgs T \ Srcs U" + using Ide_char by auto + + lemma Ide_appendI\<^sub>P [intro, simp]: + assumes "Ide T" and "Ide U" and "Trgs T \ Srcs U" + shows "Ide (T @ U)" + using assms + by (metis Ide.simps(1) Ide_append_iff\<^sub>P) + + lemma Resid_append_ind: + shows "\T U. \T \ []; U \ []; V \ []\ \ + (V @ T \<^sup>*\\<^sup>* U \ V \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* V) \ + (T \<^sup>*\\<^sup>* V @ U \ T \<^sup>*\\<^sup>* V \ T \<^sup>*\\\<^sup>* V \<^sup>*\\<^sup>* U) \ + (V @ T \<^sup>*\\<^sup>* U \ (V @ T) \<^sup>*\\\<^sup>* U = V \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* V)) \ + (T \<^sup>*\\<^sup>* V @ U \ T \<^sup>*\\\<^sup>* (V @ U) = (T \<^sup>*\\\<^sup>* V) \<^sup>*\\\<^sup>* U)" + proof (induct V) + show "\T U. \T \ []; U \ []; [] \ []\ \ + ([] @ T \<^sup>*\\<^sup>* U \ [] \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* []) \ + (T \<^sup>*\\<^sup>* [] @ U \ T \<^sup>*\\<^sup>* [] \ T \<^sup>*\\\<^sup>* [] \<^sup>*\\<^sup>* U) \ + ([] @ T \<^sup>*\\<^sup>* U \ ([] @ T) \<^sup>*\\\<^sup>* U = [] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [])) \ + (T \<^sup>*\\<^sup>* [] @ U \ T \<^sup>*\\\<^sup>* ([] @ U) = (T \<^sup>*\\\<^sup>* []) \<^sup>*\\\<^sup>* U)" + by simp + fix v :: 'a and T U V :: "'a list" + assume ind: "\T U. \T \ []; U \ []; V \ []\ \ + (V @ T \<^sup>*\\<^sup>* U \ V \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* V) \ + (T \<^sup>*\\<^sup>* V @ U \ T \<^sup>*\\<^sup>* V \ T \<^sup>*\\\<^sup>* V \<^sup>*\\<^sup>* U) \ + (V @ T \<^sup>*\\<^sup>* U \ (V @ T) \<^sup>*\\\<^sup>* U = V \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* V)) \ + (T \<^sup>*\\<^sup>* V @ U \ T \<^sup>*\\\<^sup>* (V @ U) = (T \<^sup>*\\\<^sup>* V) \<^sup>*\\\<^sup>* U)" + assume T: "T \ []" and U: "U \ []" + show "((v # V) @ T \<^sup>*\\<^sup>* U \ (v # V) \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* (v # V)) \ + (T \<^sup>*\\<^sup>* (v # V) @ U \ T \<^sup>*\\<^sup>* (v # V) \ T \<^sup>*\\\<^sup>* (v # V) \<^sup>*\\<^sup>* U) \ + ((v # V) @ T \<^sup>*\\<^sup>* U \ + ((v # V) @ T) \<^sup>*\\\<^sup>* U = (v # V) \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* (v # V))) \ + (T \<^sup>*\\<^sup>* (v # V) @ U \ T \<^sup>*\\\<^sup>* ((v # V) @ U) = (T \<^sup>*\\\<^sup>* (v # V)) \<^sup>*\\\<^sup>* U)" + proof (intro conjI iffI impI) + show 1: "(v # V) @ T \<^sup>*\\<^sup>* U \ + ((v # V) @ T) \<^sup>*\\\<^sup>* U = (v # V) \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* (v # V))" + proof (cases "V = []") + show "V = [] \ (v # V) @ T \<^sup>*\\<^sup>* U \ ?thesis" + using T U Resid_cons(1) U by auto + assume V: "V \ []" + assume Con: "(v # V) @ T \<^sup>*\\<^sup>* U" + have "((v # V) @ T) \<^sup>*\\\<^sup>* U = (v # (V @ T)) \<^sup>*\\\<^sup>* U" + by simp + also have "... = [v] \<^sup>*\\\<^sup>* U @ (V @ T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [v])" + using T U Con Resid_cons by simp + also have "... = [v] \<^sup>*\\\<^sup>* U @ V \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [v]) @ T \<^sup>*\\\<^sup>* ((U \<^sup>*\\\<^sup>* [v]) \<^sup>*\\\<^sup>* V)" + using T U V Con ind Resid_cons + by (metis Con_sym Cons_eq_appendI append_is_Nil_conv Con_cons(1)) + also have "... = (v # V) \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* (v # V))" + by (metis Con Con_cons(2) Cons_eq_appendI Resid_cons(1) Resid_cons(2) T U V + append.assoc append_is_Nil_conv Con_sym ind) + finally show ?thesis by simp + qed + show 2: "T \<^sup>*\\<^sup>* (v # V) @ U \ T \<^sup>*\\\<^sup>* ((v # V) @ U) = (T \<^sup>*\\\<^sup>* (v # V)) \<^sup>*\\\<^sup>* U" + proof (cases "V = []") + show "V = [] \ T \<^sup>*\\<^sup>* (v # V) @ U \ ?thesis" + using Resid_cons(2) T U by auto + assume V: "V \ []" + assume Con: "T \<^sup>*\\<^sup>* (v # V) @ U" + have "T \<^sup>*\\\<^sup>* ((v # V) @ U) = T \<^sup>*\\\<^sup>* (v # (V @ U))" + by simp + also have 1: "... = (T \<^sup>*\\\<^sup>* [v]) \<^sup>*\\\<^sup>* (V @ U)" + using V Con Resid_cons(2) T by force + also have "... = ((T \<^sup>*\\\<^sup>* [v]) \<^sup>*\\\<^sup>* V) \<^sup>*\\\<^sup>* U" + using T U V 1 Con ind + by (metis Con_initial_right Cons_eq_appendI) + also have "... = (T \<^sup>*\\\<^sup>* (v # V)) \<^sup>*\\\<^sup>* U" + using T V Con + by (metis Con_cons(2) Con_initial_right Cons_eq_appendI Resid_cons(2)) + finally show ?thesis by blast + qed + show "(v # V) @ T \<^sup>*\\<^sup>* U \ v # V \<^sup>*\\<^sup>* U" + by (metis 1 Con_sym Resid.simps(1) append_Nil) + show "(v # V) @ T \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* (v # V)" + using T U Con_sym + by (metis 1 Con_initial_right Resid_cons(1-2) append.simps(2) ind self_append_conv) + show "T \<^sup>*\\<^sup>* (v # V) @ U \ T \<^sup>*\\<^sup>* v # V" + using 2 by fastforce + show "T \<^sup>*\\<^sup>* (v # V) @ U \ T \<^sup>*\\\<^sup>* (v # V) \<^sup>*\\<^sup>* U" + using 2 by fastforce + show "T \<^sup>*\\<^sup>* v # V \ T \<^sup>*\\\<^sup>* (v # V) \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* (v # V) @ U" + proof - + assume Con: "T \<^sup>*\\<^sup>* v # V \ T \<^sup>*\\\<^sup>* (v # V) \<^sup>*\\<^sup>* U" + have "T \<^sup>*\\<^sup>* (v # V) @ U \ T \<^sup>*\\<^sup>* v # (V @ U)" + by simp + also have "... \ T \<^sup>*\\<^sup>* [v] \ T \<^sup>*\\\<^sup>* [v] \<^sup>*\\<^sup>* V @ U" + using T U Con_cons(2) by simp + also have "... \ T \<^sup>*\\\<^sup>* [v] \<^sup>*\\<^sup>* V @ U" + by fastforce + also have "... \ True" + using Con ind + by (metis Con_cons(2) Resid_cons(2) T U self_append_conv2) + finally show ?thesis by blast + qed + show "v # V \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* (v # V) \ (v # V) @ T \<^sup>*\\<^sup>* U" + proof - + assume Con: "v # V \<^sup>*\\<^sup>* U \ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* (v # V)" + have "(v # V) @ T \<^sup>*\\<^sup>* U \v # (V @ T) \<^sup>*\\<^sup>* U" + by simp + also have "... \ [v] \<^sup>*\\<^sup>* U \ V @ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [v]" + using T U Con_cons(1) by simp + also have "... \ V @ T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [v]" + by (metis Con Con_cons(1) U) + also have "... \ True" + using Con ind + by (metis Con_cons(1) Con_sym Resid_cons(2) T U append_self_conv2) + finally show ?thesis by blast + qed + qed + qed + + lemma Con_append: + assumes "T \ []" and "U \ []" and "V \ []" + shows "T @ U \<^sup>*\\<^sup>* V \ T \<^sup>*\\<^sup>* V \ U \<^sup>*\\<^sup>* V \<^sup>*\\\<^sup>* T" + and "T \<^sup>*\\<^sup>* U @ V \ T \<^sup>*\\<^sup>* U \ T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* V" + using assms Resid_append_ind by blast+ + + lemma Con_appendI [intro]: + shows "\T \<^sup>*\\<^sup>* V; U \<^sup>*\\<^sup>* V \<^sup>*\\\<^sup>* T\ \ T @ U \<^sup>*\\<^sup>* V" + and "\T \<^sup>*\\<^sup>* U; T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* V\ \ T \<^sup>*\\<^sup>* U @ V" + by (metis Con_append(1) Con_sym Resid.simps(1))+ + + lemma Resid_append [intro, simp]: + shows "\T \ []; T @ U \<^sup>*\\<^sup>* V\ \ (T @ U) \<^sup>*\\\<^sup>* V = (T \<^sup>*\\\<^sup>* V) @ (U \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* T))" + and "\U \ []; V \ []; T \<^sup>*\\<^sup>* U @ V\ \ T \<^sup>*\\\<^sup>* (U @ V) = (T \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* V" + using Resid_append_ind + apply (metis Con_sym Resid.simps(1) append_self_conv) + using Resid_append_ind + by (metis Resid.simps(1)) + + lemma Resid_append2 [simp]: + assumes "T \ []" and "U \ []" and "V \ []" and "W \ []" + and "T @ U \<^sup>*\\<^sup>* V @ W" + shows "(T @ U) \<^sup>*\\\<^sup>* (V @ W) = + (T \<^sup>*\\\<^sup>* V) \<^sup>*\\\<^sup>* W @ (U \<^sup>*\\\<^sup>* (V \<^sup>*\\\<^sup>* T)) \<^sup>*\\\<^sup>* (W \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* V))" + using assms Resid_append + by (metis Con_append(1-2) append_is_Nil_conv) + + lemma append_is_composite_of: + assumes "seq T U" + shows "composite_of T U (T @ U)" + unfolding composite_of_def + using assms + apply (intro conjI) + apply (metis Arr.simps(1) Resid_Arr_self Resid_Ide_Arr_ind Arr_appendI\<^sub>P + Resid_append_ind ide_char order_refl seq_char) + apply (metis Arr.simps(1) Arr_appendI\<^sub>P Con_Arr_self Resid_Arr_self Resid_append_ind + ide_char seq_char order_refl) + by (metis Arr.simps(1) Con_Arr_self Con_append(1) Resid_Arr_self Arr_appendI\<^sub>P + Ide_append_iff\<^sub>P Resid_append(1) ide_char seq_char order_refl) + + sublocale rts_with_composites Resid + using append_is_composite_of composable_def by unfold_locales blast + + theorem is_rts_with_composites: + shows "rts_with_composites Resid" + .. + + (* TODO: This stuff might be redundant. *) + lemma arr_append [intro, simp]: + assumes "seq T U" + shows "arr (T @ U)" + using assms arrI\<^sub>P seq_char by simp + + lemma arr_append_imp_seq: + assumes "T \ []" and "U \ []" and "arr (T @ U)" + shows "seq T U" + using assms arr_char seq_char Arr_append_iff\<^sub>P seq_implies_Trgs_eq_Srcs by simp + + lemma sources_append [simp]: + assumes "seq T U" + shows "sources (T @ U) = sources T" + using assms + by (meson append_is_composite_of sources_composite_of) + + lemma targets_append [simp]: + assumes "seq T U" + shows "targets (T @ U) = targets U" + using assms + by (meson append_is_composite_of targets_composite_of) + + lemma cong_respects_seq\<^sub>P: + assumes "seq T U" and "T \<^sup>*\\<^sup>* T'" and "U \<^sup>*\\<^sup>* U'" + shows "seq T' U'" + by (meson assms cong_respects_seq) + + lemma cong_append [intro]: + assumes "seq T U" and "T \<^sup>*\\<^sup>* T'" and "U \<^sup>*\\<^sup>* U'" + shows "T @ U \<^sup>*\\<^sup>* T' @ U'" + proof + have 1: "\T U T' U'. \seq T U; T \<^sup>*\\<^sup>* T'; U \<^sup>*\\<^sup>* U'\ \ seq T' U'" + using assms cong_respects_seq\<^sub>P by simp + have 2: "\T U T' U'. \seq T U; T \<^sup>*\\<^sup>* T'; U \<^sup>*\\<^sup>* U'\ \ T @ U \<^sup>*\\<^sup>* T' @ U'" + proof - + fix T U T' U' + assume TU: "seq T U" and TT': "T \<^sup>*\\<^sup>* T'" and UU': "U \<^sup>*\\<^sup>* U'" + have T'U': "seq T' U'" + using TU TT' UU' cong_respects_seq\<^sub>P by simp + have 3: "Ide (T \<^sup>*\\\<^sup>* T') \ Ide (T' \<^sup>*\\\<^sup>* T) \ Ide (U \<^sup>*\\\<^sup>* U') \ Ide (U' \<^sup>*\\\<^sup>* U)" + using TU TT' UU' ide_char by blast + have "(T @ U) \<^sup>*\\\<^sup>* (T' @ U') = + ((T \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* U') @ U \<^sup>*\\\<^sup>* ((T' \<^sup>*\\\<^sup>* T) @ U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* T'))" + proof - + have 4: "T \ [] \ U \ [] \ T' \ [] \ U' \ []" + using TU TT' UU' Arr.simps(1) seq_char ide_char by auto + moreover have "(T @ U) \<^sup>*\\\<^sup>* (T' @ U') \ []" + proof (intro Con_appendI) + show "T \<^sup>*\\\<^sup>* T' \ []" + using "3" by force + show "(T \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* U' \ []" + using "3" T'U' \T \<^sup>*\\<^sup>* T' \ []\ Con_Ide_iff seq_char by fastforce + show "U \<^sup>*\\\<^sup>* ((T' @ U') \<^sup>*\\\<^sup>* T) \ []" + proof - + have "U \<^sup>*\\\<^sup>* ((T' @ U') \<^sup>*\\\<^sup>* T) = U \<^sup>*\\\<^sup>* ((T' \<^sup>*\\\<^sup>* T) @ U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* T'))" + by (metis Con_appendI(1) Resid_append(1) \(T \<^sup>*\\<^sup>* T') \<^sup>*\\<^sup>* U' \ []\ + \T \<^sup>*\\<^sup>* T' \ []\ calculation Con_sym) + also have "... = (U \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* T)) \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* T'))" + by (metis Arr.simps(1) Con_append(2) Resid_append(2) \(T \<^sup>*\\<^sup>* T') \<^sup>*\\<^sup>* U' \ []\ + Con_implies_Arr(1) Con_sym) + also have "... = U \<^sup>*\\\<^sup>* U'" + by (metis (mono_tags, lifting) "3" Ide.simps(1) Resid_Ide(1) Srcs_Resid TU + \(T \<^sup>*\\<^sup>* T') \<^sup>*\\<^sup>* U' \ []\ Con_Ide_iff seq_char) + finally show ?thesis + using 3 UU' by force + qed + qed + ultimately show ?thesis + using Resid_append2 [of T U T' U'] seq_char + by (metis Con_append(2) Con_sym Resid_append(2) Resid.simps(1)) + qed + moreover have "Ide ..." + proof + have 3: "Ide (T \<^sup>*\\\<^sup>* T') \ Ide (T' \<^sup>*\\\<^sup>* T) \ Ide (U \<^sup>*\\\<^sup>* U') \ Ide (U' \<^sup>*\\\<^sup>* U)" + using TU TT' UU' ide_char by blast + show 4: "Ide ((T \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* U')" + using TU T'U' TT' UU' 1 3 + by (metis (full_types) Srcs_Resid Con_Ide_iff Resid_Ide_Arr_ind seq_char) + show 5: "Ide (U \<^sup>*\\\<^sup>* ((T' \<^sup>*\\\<^sup>* T) @ U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* T')))" + proof - + have "U \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* T) = U" + by (metis (full_types) "3" TT' TU Con_Ide_iff Resid_Ide(1) Srcs_Resid + con_char seq_char prfx_implies_con) + moreover have "U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* T') = U'" + by (metis "3" "4" Ide.simps(1) Resid_Ide(1)) + ultimately show ?thesis + by (metis "3" "4" Arr.simps(1) Con_append(2) Ide.simps(1) Resid_append(2) + TU Con_sym seq_char) + qed + show "Trgs ((T \<^sup>*\\\<^sup>* T') \<^sup>*\\\<^sup>* U') \ Srcs (U \<^sup>*\\\<^sup>* (T' \<^sup>*\\\<^sup>* T @ U' \<^sup>*\\\<^sup>* (T \<^sup>*\\\<^sup>* T')))" + by (metis 4 5 Arr_append_iff\<^sub>P Ide.simps(1) Nil_is_append_conv + calculation Con_imp_Arr_Resid) + qed + ultimately show "T @ U \<^sup>*\\<^sup>* T' @ U'" + using ide_char by presburger + qed + show "T @ U \<^sup>*\\<^sup>* T' @ U'" + using assms 2 by simp + show "T' @ U' \<^sup>*\\<^sup>* T @ U" + using assms 1 2 cong_symmetric by blast + qed + + lemma cong_cons [intro]: + assumes "seq [t] U" and "t \ t'" and "U \<^sup>*\\<^sup>* U'" + shows "t # U \<^sup>*\\<^sup>* t' # U'" + using assms cong_append [of "[t]" U "[t']" U'] + by (simp add: R.prfx_implies_con ide_char) + + lemma cong_append_ideI [intro]: + assumes "seq T U" + shows "ide T \ T @ U \<^sup>*\\<^sup>* U" and "ide U \ T @ U \<^sup>*\\<^sup>* T" + and "ide T \ U \<^sup>*\\<^sup>* T @ U" and "ide U \ T \<^sup>*\\<^sup>* T @ U" + proof - + show 1: "ide T \ T @ U \<^sup>*\\<^sup>* U" + using assms + by (metis append_is_composite_of composite_ofE resid_arr_ide prfx_implies_con + con_sym) + show 2: "ide U \ T @ U \<^sup>*\\<^sup>* T" + by (meson assms append_is_composite_of composite_ofE ide_backward_stable) + show "ide T \ U \<^sup>*\\<^sup>* T @ U" + using 1 cong_symmetric by auto + show "ide U \ T \<^sup>*\\<^sup>* T @ U" + using 2 cong_symmetric by auto + qed + + lemma cong_cons_ideI [intro]: + assumes "seq [t] U" and "R.ide t" + shows "t # U \<^sup>*\\<^sup>* U" and "U \<^sup>*\\<^sup>* t # U" + using assms cong_append_ideI [of "[t]" U] + by (auto simp add: ide_char) + + lemma prfx_decomp: + assumes "[t] \<^sup>*\\<^sup>* [u]" + shows "[t] @ [u \\ t] \<^sup>*\\<^sup>* [u]" + proof + (* TODO: I really want these to be doable by auto. *) + show 1: "[u] \<^sup>*\\<^sup>* [t] @ [u \\ t]" + using assms + by (metis Con_imp_Arr_Resid Con_rec(3) Resid.simps(3) Resid_rec(3) R.con_sym + append.left_neutral append_Cons arr_char cong_reflexive list.distinct(1)) + show "[t] @ [u \\ t] \<^sup>*\\<^sup>* [u]" + proof - + have "([t] @ [u \\ t]) \<^sup>*\\\<^sup>* [u] = ([t] \<^sup>*\\\<^sup>* [u]) @ ([u \\ t] \<^sup>*\\\<^sup>* [u \\ t])" + using assms + by (metis Arr_Resid_single Con_Arr_self Con_appendI(1) Con_sym Resid_append(1) + Resid_rec(1) con_char list.discI prfx_implies_con) + moreover have "Ide ..." + using assms + by (metis 1 Con_sym append_Nil2 arr_append_imp_seq calculation cong_append_ideI(4) + ide_backward_stable Con_implies_Arr(2) Resid_Arr_self con_char ide_char + prfx_implies_con arr_resid_iff_con) + ultimately show ?thesis + using ide_char by presburger + qed + qed + + lemma composite_of_single_single: + assumes "R.composite_of t u v" + shows "composite_of [t] [u] ([t] @ [u])" + proof + show "[t] \<^sup>*\\<^sup>* [t] @ [u]" + proof - + have "[t] \<^sup>*\\\<^sup>* ([t] @ [u]) = ([t] \<^sup>*\\\<^sup>* [t]) \<^sup>*\\\<^sup>* [u]" + using assms by auto + moreover have "Ide ..." + by (metis (no_types, lifting) Con_implies_Arr(2) R.bounded_imp_con + R.con_composite_of_iff R.con_prfx_composite_of(1) assms resid_ide_arr + Con_rec(1) Resid.simps(3) Resid_Arr_self con_char ide_char) + ultimately show ?thesis + using ide_char by presburger + qed + show "([t] @ [u]) \<^sup>*\\\<^sup>* [t] \<^sup>*\\<^sup>* [u]" + using assms + by (metis \prfx [t] ([t] @ [u])\ append_is_composite_of arr_append_imp_seq + composite_ofE con_def not_Cons_self2 Con_implies_Arr(2) arr_char null_char + prfx_implies_con) + qed + + end + + subsection "Paths in a Weakly Extensional RTS" + + locale paths_in_weakly_extensional_rts = + R: weakly_extensional_rts + + paths_in_rts + begin + + lemma ex_un_Src: + assumes "Arr T" + shows "\!a. a \ Srcs T" + using assms + by (simp add: R.weakly_extensional_rts_axioms Srcs_simp\<^sub>P R.arr_has_un_source) + + fun Src + where "Src T = R.src (hd T)" + + lemma Srcs_simp\<^sub>P\<^sub>W\<^sub>E: + assumes "Arr T" + shows "Srcs T = {Src T}" + proof - + have "[R.src (hd T)] \ sources T" + by (metis Arr_imp_arr_hd Con_single_ide_ind Ide.simps(2) Srcs_simp\<^sub>P assms + con_char ide_char in_sourcesI con_sym R.ide_src R.src_in_sources) + hence "R.src (hd T) \ Srcs T" + using assms + by (metis Srcs.elims Arr_has_Src list.sel(1) R.arr_iff_has_source R.src_in_sources) + thus ?thesis + using assms ex_un_Src by auto + qed + + lemma ex_un_Trg: + assumes "Arr T" + shows "\!b. b \ Trgs T" + using assms + apply (induct T) + apply auto[1] + by (metis Con_Arr_self Ide_implies_Arr Resid_Arr_self Srcs_Resid ex_un_Src) + + fun Trg + where "Trg [] = R.null" + | "Trg [t] = R.trg t" + | "Trg (t # T) = Trg T" + + lemma Trg_simp [simp]: + shows "T \ [] \ Trg T = R.trg (last T)" + apply (induct T) + apply auto + by (metis Trg.simps(3) list.exhaust_sel) + + lemma Trgs_simp\<^sub>P\<^sub>W\<^sub>E [simp]: + assumes "Arr T" + shows "Trgs T = {Trg T}" + using assms + by (metis Arr_imp_arr_last Con_Arr_self Con_imp_Arr_Resid R.trg_in_targets + Srcs.simps(1) Srcs_Resid Srcs_simp\<^sub>P\<^sub>W\<^sub>E Trg_simp insertE insert_absorb insert_not_empty + Trgs_simp\<^sub>P) + + lemma Src_resid [simp]: + assumes "T \<^sup>*\\<^sup>* U" + shows "Src (T \<^sup>*\\\<^sup>* U) = Trg U" + using assms Con_imp_Arr_Resid Con_implies_Arr(2) Srcs_Resid Srcs_simp\<^sub>P\<^sub>W\<^sub>E by force + + lemma Trg_resid_sym: + assumes "T \<^sup>*\\<^sup>* U" + shows "Trg (T \<^sup>*\\\<^sup>* U) = Trg (U \<^sup>*\\\<^sup>* T)" + using assms Con_imp_Arr_Resid Con_sym Trgs_Resid_sym by auto + + lemma Src_append [simp]: + assumes "seq T U" + shows "Src (T @ U) = Src T" + using assms + by (metis Arr.simps(1) Src.simps hd_append seq_char) + + lemma Trg_append [simp]: + assumes "seq T U" + shows "Trg (T @ U) = Trg U" + using assms + by (metis Ide.simps(1) Resid.simps(1) Trg_simp append_is_Nil_conv ide_char ide_trg + last_appendR seqE trg_def) + + lemma Arr_append_iff\<^sub>P\<^sub>W\<^sub>E: + assumes "T \ []" and "U \ []" + shows "Arr (T @ U) \ Arr T \ Arr U \ Trg T = Src U" + using assms Arr_appendE\<^sub>P Srcs_simp\<^sub>P\<^sub>W\<^sub>E by auto + + lemma Arr_consI\<^sub>P\<^sub>W\<^sub>E [intro, simp]: + assumes "R.arr t" and "Arr U" and "R.trg t = Src U" + shows "Arr (t # U)" + using assms + by (metis Arr.simps(2) Srcs_simp\<^sub>P\<^sub>W\<^sub>E Trg.simps(2) Trgs.simps(2) Trgs_simp\<^sub>P\<^sub>W\<^sub>E + dual_order.eq_iff Arr_consI\<^sub>P) + + lemma Arr_consE [elim]: + assumes "Arr (t # U)" + and "\R.arr t; U \ [] \ Arr U; U \ [] \ R.trg t = Src U\ \ thesis" + shows thesis + using assms + by (metis Arr_append_iff\<^sub>P\<^sub>W\<^sub>E Trg.simps(2) append_Cons append_Nil list.distinct(1) + Arr.simps(2)) + + lemma Arr_appendI\<^sub>P\<^sub>W\<^sub>E [intro, simp]: + assumes "Arr T" and "Arr U" and "Trg T = Src U" + shows "Arr (T @ U)" + using assms + by (metis Arr.simps(1) Arr_append_iff\<^sub>P\<^sub>W\<^sub>E) + + lemma Arr_appendE\<^sub>P\<^sub>W\<^sub>E [elim]: + assumes "Arr (T @ U)" and "T \ []" and "U \ []" + and "\Arr T; Arr U; Trg T = Src U\ \ thesis" + shows thesis + using assms Arr_append_iff\<^sub>P\<^sub>W\<^sub>E seq_implies_Trgs_eq_Srcs by force + + lemma Ide_append_iff\<^sub>P\<^sub>W\<^sub>E: + assumes "T \ []" and "U \ []" + shows "Ide (T @ U) \ Ide T \ Ide U \ Trg T = Src U" + using assms Ide_char by auto + + lemma Ide_appendI\<^sub>P\<^sub>W\<^sub>E [intro, simp]: + assumes "Ide T" and "Ide U" and "Trg T = Src U" + shows "Ide (T @ U)" + using assms + by (metis Ide.simps(1) Ide_append_iff\<^sub>P\<^sub>W\<^sub>E) + + lemma Ide_appendE [elim]: + assumes "Ide (T @ U)" and "T \ []" and "U \ []" + and "\Ide T; Ide U; Trg T = Src U\ \ thesis" + shows thesis + using assms Ide_append_iff\<^sub>P\<^sub>W\<^sub>E by metis + + lemma Ide_consI [intro, simp]: + assumes "R.ide t" and "Ide U" and "R.trg t = Src U" + shows "Ide (t # U)" + using assms + by (simp add: Ide_char) + + lemma Ide_consE [elim]: + assumes "Ide (t # U)" + and "\R.ide t; U \ [] \ Ide U; U \ [] \ R.trg t = Src U\ \ thesis" + shows thesis + using assms + by (metis Con_rec(4) Ide.simps(2) Ide_imp_Ide_hd Ide_imp_Ide_tl R.trg_def R.trg_ide + Resid_Arr_Ide_ind Trg.simps(2) ide_char list.sel(1) list.sel(3) list.simps(3) + Src_resid ide_def) + + lemma Ide_imp_Src_eq_Trg: + assumes "Ide T" + shows "Src T = Trg T" + using assms + by (metis Ide.simps(1) Src_resid ide_char ide_def) + + end + + subsection "Paths in a Confluent RTS" + + text \ + Here we show that confluence of an RTS extends to confluence of the RTS of its paths. + \ + + locale paths_in_confluent_rts = + paths_in_rts + + R: confluent_rts + begin + + lemma confluence_single: + assumes "\t u. R.coinitial t u \ t \ u" + shows "\t. \R.arr t; Arr U; R.sources t = Srcs U\ \ [t] \<^sup>*\\<^sup>* U" + proof (induct U) + show "\t. \R.arr t; Arr []; R.sources t = Srcs []\ \ [t] \<^sup>*\\<^sup>* []" + by simp + fix t u U + assume ind: "\t. \R.arr t; Arr U; R.sources t = Srcs U\ \ [t] \<^sup>*\\<^sup>* U" + assume t: "R.arr t" + assume uU: "Arr (u # U)" + assume coinitial: "R.sources t = Srcs (u # U)" + hence 1: "R.coinitial t u" + using t uU + by (metis Arr.simps(2) Con_implies_Arr(1) Con_imp_eq_Srcs Con_initial_left + Srcs.simps(2) Con_Arr_self R.coinitial_iff) + show "[t] \<^sup>*\\<^sup>* u # U" + proof (cases "U = []") + show "U = [] \ ?thesis" + using assms t uU coinitial R.coinitial_iff by fastforce + assume U: "U \ []" + show ?thesis + proof - + have 2: "Arr [t \\ u] \ Arr U \ Srcs [t \\ u] = Srcs U" + using assms 1 t uU U R.arr_resid_iff_con + apply (intro conjI) + apply simp + apply (metis Con_Arr_self Con_implies_Arr(2) Resid_cons(2)) + by (metis (full_types) Con_cons(2) Srcs.simps(2) Srcs_Resid Trgs.simps(2) + Con_Arr_self Con_imp_eq_Srcs list.simps(3) R.sources_resid) + have "[t] \<^sup>*\\<^sup>* u # U \ t \ u \ [t \\ u] \<^sup>*\\<^sup>* U" + using U Con_rec(3) [of U t u] by simp + also have "... \ True" + using assms t uU U 1 2 ind by force + finally show ?thesis by blast + qed + qed + qed + + lemma confluence_ind: + shows "\U. \Arr T; Arr U; Srcs T = Srcs U\ \ T \<^sup>*\\<^sup>* U" + proof (induct T) + show "\U. \Arr []; Arr U; Srcs [] = Srcs U\ \ [] \<^sup>*\\<^sup>* U" + by simp + fix t T U + assume ind: "\U. \Arr T; Arr U; Srcs T = Srcs U\ \ T \<^sup>*\\<^sup>* U" + assume tT: "Arr (t # T)" + assume U: "Arr U" + assume coinitial: "Srcs (t # T) = Srcs U" + show "t # T \<^sup>*\\<^sup>* U" + proof (cases "T = []") + show "T = [] \ ?thesis" + using U tT coinitial confluence_single [of t U] R.confluence by simp + assume T: "T \ []" + show ?thesis + proof - + have 1: "[t] \<^sup>*\\<^sup>* U" + using tT U coinitial R.confluence + by (metis R.arr_def Srcs.simps(2) T Con_Arr_self Con_imp_eq_Srcs + Con_initial_right Con_rec(4) confluence_single) + moreover have "T \<^sup>*\\<^sup>* U \<^sup>*\\\<^sup>* [t]" + using 1 tT U T coinitial ind [of "U \<^sup>*\\\<^sup>* [t]"] + by (metis (full_types) Con_imp_Arr_Resid Arr_iff_Con_self Con_implies_Arr(2) + Con_imp_eq_Srcs Con_sym R.sources_resid Srcs.simps(2) Srcs_Resid + Trgs.simps(2) Con_rec(4)) + ultimately show ?thesis + using Con_cons(1) [of T U t] by fastforce + qed + qed + qed + + lemma confluence\<^sub>P: + assumes "coinitial T U" + shows "con T U" + using assms confluence_ind sources_char\<^sub>P coinitial_def con_char by auto + + sublocale confluent_rts Resid + apply (unfold_locales) + using confluence\<^sub>P by simp + + lemma is_confluent_rts: + shows "confluent_rts Resid" + .. + + end + + subsection "Simulations Lift to Paths" + + text \ + In this section we show that a simulation from RTS \A\ to RTS \B\ determines a simulation + from the RTS of paths in \A\ to the RTS of paths in \B\. In other words, the path-RTS + construction is functorial with respect to simulation. + \ + + context simulation + begin + + interpretation P\<^sub>A: paths_in_rts A + .. + interpretation P\<^sub>B: paths_in_rts B + .. + + lemma map_Resid_single: + shows "\u. P\<^sub>A.con T [u] \ map F (P\<^sub>A.Resid T [u]) = P\<^sub>B.Resid (map F T) [F u]" + apply (induct T) + apply simp + proof - + fix t u T + assume ind: "\u. P\<^sub>A.con T [u] \ map F (P\<^sub>A.Resid T [u]) = P\<^sub>B.Resid (map F T) [F u]" + assume 1: "P\<^sub>A.con (t # T) [u]" + show "map F (P\<^sub>A.Resid (t # T) [u]) = P\<^sub>B.Resid (map F (t # T)) [F u]" + proof (cases "T = []") + show "T = [] \ ?thesis" + using "1" P\<^sub>A.null_char by fastforce + assume T: "T \ []" + show ?thesis + using T 1 ind P\<^sub>A.con_def P\<^sub>A.null_char P\<^sub>A.Con_rec(2) P\<^sub>A.Resid_rec(2) P\<^sub>B.Con_rec(2) + P\<^sub>B.Resid_rec(2) + apply simp + by (metis A.con_sym Nil_is_map_conv preserves_con preserves_resid) + qed + qed + + lemma map_Resid: + shows "\T. P\<^sub>A.con T U \ map F (P\<^sub>A.Resid T U) = P\<^sub>B.Resid (map F T) (map F U)" + apply (induct U) + using P\<^sub>A.Resid.simps(1) P\<^sub>A.con_char P\<^sub>A.con_sym + apply blast + proof - + fix u U T + assume ind: "\T. P\<^sub>A.con T U \ + map F (P\<^sub>A.Resid T U) = P\<^sub>B.Resid (map F T) (map F U)" + assume 1: "P\<^sub>A.con T (u # U)" + show "map F (P\<^sub>A.Resid T (u # U)) = P\<^sub>B.Resid (map F T) (map F (u # U))" + proof (cases "U = []") + show "U = [] \ ?thesis" + using "1" map_Resid_single by force + assume U: "U \ []" + have "P\<^sub>B.Resid (map F T) (map F (u # U)) = + P\<^sub>B.Resid (P\<^sub>B.Resid (map F T) [F u]) (map F U)" + using U 1 P\<^sub>B.Resid_cons(2) + apply simp + by (metis P\<^sub>B.Arr.simps(1) P\<^sub>B.Con_consI(2) P\<^sub>B.Con_implies_Arr(1) list.map_disc_iff) + also have "... = map F (P\<^sub>A.Resid (P\<^sub>A.Resid T [u]) U)" + using U 1 ind + by (metis P\<^sub>A.Con_initial_right P\<^sub>A.Resid_cons(2) P\<^sub>A.con_char map_Resid_single) + also have "... = map F (P\<^sub>A.Resid T (u # U))" + using "1" P\<^sub>A.Resid_cons(2) P\<^sub>A.con_char U by auto + finally show ?thesis by simp + qed + qed + + lemma preserves_paths: + shows "P\<^sub>A.Arr T \ P\<^sub>B.Arr (map F T)" + by (metis P\<^sub>A.Con_Arr_self P\<^sub>A.conI\<^sub>P P\<^sub>B.Arr_iff_Con_self map_Resid map_is_Nil_conv) + + interpretation Fx: simulation P\<^sub>A.Resid P\<^sub>B.Resid \\T. if P\<^sub>A.Arr T then map F T else []\ + proof + let ?Fx = "\T. if P\<^sub>A.Arr T then map F T else []" + show "\T. \ P\<^sub>A.arr T \ ?Fx T = P\<^sub>B.null" + by (simp add: P\<^sub>A.arr_char P\<^sub>B.null_char) + show "\T U. P\<^sub>A.con T U \ P\<^sub>B.con (?Fx T) (?Fx U)" + using P\<^sub>A.Con_implies_Arr(1) P\<^sub>A.Con_implies_Arr(2) P\<^sub>A.con_char map_Resid by fastforce + show "\T U. P\<^sub>A.con T U \ ?Fx (P\<^sub>A.Resid T U) = P\<^sub>B.Resid (?Fx T) (?Fx U)" + by (simp add: P\<^sub>A.Con_imp_Arr_Resid P\<^sub>A.Con_implies_Arr(1) P\<^sub>A.Con_implies_Arr(2) + P\<^sub>A.con_char map_Resid) + qed + + lemma lifts_to_paths: + shows "simulation P\<^sub>A.Resid P\<^sub>B.Resid (\T. if P\<^sub>A.Arr T then map F T else [])" + .. + + end + + subsection "Normal Sub-RTS's Lift to Paths" + + text \ + Here we show that a normal sub-RTS \N\ of an RTS \R\ lifts to a normal sub-RTS + of the RTS of paths in \N\, and that it is coherent if \N\ is. + \ + + locale paths_in_rts_with_normal = + R: rts + + N: normal_sub_rts + + paths_in_rts + begin + + text \ + We define a ``normal path'' to be a path that consists entirely of normal transitions. + We show that the collection of all normal paths is a normal sub-RTS of the RTS of paths. + \ + + definition NPath + where "NPath T \ (Arr T \ set T \ \)" + + lemma Ide_implies_NPath: + assumes "Ide T" + shows "NPath T" + using assms + by (metis Ball_Collect NPath_def Ide_implies_Arr N.ide_closed set_Ide_subset_ide + subsetI) + + lemma NPath_implies_Arr: + assumes "NPath T" + shows "Arr T" + using assms NPath_def by simp + + lemma NPath_append: + assumes "T \ []" and "U \ []" + shows "NPath (T @ U) \ NPath T \ NPath U \ Trgs T \ Srcs U" + using assms NPath_def by auto + + lemma NPath_appendI [intro, simp]: + assumes "NPath T" and "NPath U" and "Trgs T \ Srcs U" + shows "NPath (T @ U)" + using assms NPath_def by simp + + lemma NPath_Resid_single_Arr: + shows "\t. \t \ \; Arr U; R.sources t = Srcs U\ \ NPath (Resid [t] U)" + proof (induct U) + show "\t. \t \ \; Arr []; R.sources t = Srcs []\ \ NPath (Resid [t] [])" + by simp + fix t u U + assume ind: "\t. \t \ \; Arr U; R.sources t = Srcs U\ \ NPath (Resid [t] U)" + assume t: "t \ \" + assume uU: "Arr (u # U)" + assume src: "R.sources t = Srcs (u # U)" + show "NPath (Resid [t] (u # U))" + proof (cases "U = []") + show "U = [] \ ?thesis" + using NPath_def t src + apply simp + by (metis Arr.simps(2) R.arr_resid_iff_con R.coinitialI N.forward_stable + N.elements_are_arr uU) + assume U: "U \ []" + show ?thesis + proof - + have "NPath (Resid [t] (u # U)) \ NPath (Resid [t \\ u] U)" + using t U uU src + by (metis Arr.simps(2) Con_implies_Arr(1) Resid_rec(3) Con_rec(3) R.arr_resid_iff_con) + also have "... \ True" + proof - + have "t \\ u \ \" + using t U uU src N.forward_stable [of t u] + by (metis Con_Arr_self Con_imp_eq_Srcs Con_initial_left + Srcs.simps(2) inf.idem Arr_has_Src R.coinitial_def) + moreover have "Arr U" + using U uU + by (metis Arr.simps(3) neq_Nil_conv) + moreover have "R.sources (t \\ u) = Srcs U" + using t uU src + by (metis Con_Arr_self Srcs.simps(2) U calculation(1) Con_imp_eq_Srcs + Con_rec(4) N.elements_are_arr R.sources_resid R.arr_resid_iff_con) + ultimately show ?thesis + using ind [of "t \\ u"] by simp + qed + finally show ?thesis by blast + qed + qed + qed + + lemma NPath_Resid_Arr_single: + shows "\u. \ NPath T; R.arr u; Srcs T = R.sources u \ \ NPath (Resid T [u])" + proof (induct T) + show "\u. \NPath []; R.arr u; Srcs [] = R.sources u\ \ NPath (Resid [] [u])" + by simp + fix t u T + assume ind: "\u. \NPath T; R.arr u; Srcs T = R.sources u\ \ NPath (Resid T [u])" + assume tT: "NPath (t # T)" + assume u: "R.arr u" + assume src: "Srcs (t # T) = R.sources u" + show "NPath (Resid (t # T) [u])" + proof (cases "T = []") + show "T = [] \ ?thesis" + using tT u src NPath_def + by (metis Arr.simps(2) NPath_Resid_single_Arr Srcs.simps(2) list.set_intros(1) subsetD) + assume T: "T \ []" + have "R.coinitial u t" + by (metis R.coinitialI Srcs.simps(3) T list.exhaust_sel src u) + hence con: "t \ u" + using tT T u src R.con_sym NPath_def + by (metis N.forward_stable N.elements_are_arr R.not_arr_null + list.set_intros(1) R.conI subsetD) + have 1: "NPath (Resid (t # T) [u]) \ NPath ((t \\ u) # Resid T [u \\ t])" + proof - + have "t # T \<^sup>*\\<^sup>* [u]" + proof - + have 2: "[t] \<^sup>*\\<^sup>* [u]" + by (simp add: Con_rec(1) con) + moreover have "T \<^sup>*\\<^sup>* Resid [u] [t]" + proof - + have "NPath T" + using tT T NPath_def + by (metis NPath_append append_Cons append_Nil) + moreover have 3: "R.arr (u \\ t)" + using con by (meson R.arr_resid_iff_con R.con_sym) + moreover have "Srcs T = R.sources (u \\ t)" + using tT T u src con + by (metis "3" Arr_iff_Con_self Con_cons(2) Con_imp_eq_Srcs + R.sources_resid Srcs_Resid Trgs.simps(2) NPath_implies_Arr list.discI + R.arr_resid_iff_con) + ultimately show ?thesis + using 2 ind [of "u \\ t"] NPath_def by auto + qed + ultimately show ?thesis + using tT T u src Con_cons(1) [of T "[u]" t] by simp + qed + thus ?thesis + using tT T u src Resid_cons(1) [of T t "[u]"] Resid_rec(2) by presburger + qed + also have "... \ True" + proof - + have 2: "t \\ u \ \ \ R.arr (u \\ t)" + using tT u src con NPath_def + by (meson R.arr_resid_iff_con R.con_sym N.forward_stable \R.coinitial u t\ + list.set_intros(1) subsetD) + moreover have 3: "NPath (T \<^sup>*\\\<^sup>* [u \\ t])" + using tT ind [of "u \\ t"] NPath_def + by (metis Con_Arr_self Con_imp_eq_Srcs Con_rec(4) R.arr_resid_iff_con + R.sources_resid Srcs.simps(2) T calculation insert_subset list.exhaust + list.simps(15) Arr.simps(3)) + moreover have "R.targets (t \\ u) \ Srcs (Resid T [u \\ t])" + using tT T u src NPath_def + by (metis "3" Arr.simps(1) R.targets_resid_sym Srcs_Resid_Arr_single con subset_refl) + ultimately show ?thesis + using NPath_def + by (metis Arr_consI\<^sub>P N.elements_are_arr insert_subset list.simps(15)) + qed + finally show ?thesis by blast + qed + qed + + lemma NPath_Resid [simp]: + shows "\U. \NPath T; Arr U; Srcs T = Srcs U\ \ NPath (T \<^sup>*\\\<^sup>* U)" + proof (induct T) + show "\U. \NPath []; Arr U; Srcs [] = Srcs U\ \ NPath ([] \<^sup>*\\\<^sup>* U)" + by simp + fix t T U + assume ind: "\U. \NPath T; Arr U; Srcs T = Srcs U\ \ NPath (T \<^sup>*\\\<^sup>* U)" + assume tT: "NPath (t # T)" + assume U: "Arr U" + assume Coinitial: "Srcs (t # T) = Srcs U" + show "NPath ((t # T) \<^sup>*\\\<^sup>* U)" + proof (cases "T = []") + show "T = [] \ ?thesis" + using tT U Coinitial NPath_Resid_single_Arr [of t U] NPath_def by force + assume T: "T \ []" + have 0: "NPath ((t # T) \<^sup>*\\\<^sup>* U) \ NPath ([t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + proof - + have "U \ []" + using U by auto + moreover have "(t # T) \<^sup>*\\<^sup>* U" + proof - + have "t \ \" + using tT NPath_def by auto + moreover have "R.sources t = Srcs U" + using Coinitial + by (metis Srcs.elims U list.sel(1) Arr_has_Src) + ultimately have 1: "[t] \<^sup>*\\<^sup>* U" + using U NPath_Resid_single_Arr [of t U] NPath_def by auto + moreover have "T \<^sup>*\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + proof - + have "Srcs T = Srcs (U \<^sup>*\\\<^sup>* [t])" + using tT U Coinitial 1 + by (metis Con_Arr_self Con_cons(2) Con_imp_eq_Srcs Con_sym Srcs_Resid_Arr_single + T list.discI NPath_implies_Arr) + hence "NPath (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + using tT U Coinitial 1 Con_sym ind [of "Resid U [t]"] NPath_def + by (metis Con_imp_Arr_Resid Srcs.elims T insert_subset list.simps(15) + Arr.simps(3)) + thus ?thesis + using NPath_def by auto + qed + ultimately show ?thesis + using Con_cons(1) [of T U t] by fastforce + qed + ultimately show ?thesis + using tT U T Coinitial Resid_cons(1) by auto + qed + also have "... \ True" + proof (intro iffI, simp_all) + have 1: "NPath ([t] \<^sup>*\\\<^sup>* U)" + by (metis Coinitial NPath_Resid_single_Arr Srcs_simp\<^sub>P U insert_subset + list.sel(1) list.simps(15) NPath_def tT) + moreover have 2: "NPath (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + by (metis "0" Arr.simps(1) Con_cons(1) Con_imp_eq_Srcs Con_implies_Arr(1-2) + NPath_def T append_Nil2 calculation ind insert_subset list.simps(15) tT) + moreover have "Trgs ([t] \<^sup>*\\\<^sup>* U) \ Srcs (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + by (metis Arr.simps(1) NPath_def Srcs_Resid Trgs_Resid_sym calculation(2) + dual_order.refl) + ultimately show "NPath ([t] \<^sup>*\\\<^sup>* U @ T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + using NPath_append [of "T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" "[t] \<^sup>*\\\<^sup>* U"] by fastforce + qed + finally show ?thesis by blast + qed + qed + + lemma Backward_stable_single: + shows "\t. \NPath U; NPath ([t] \<^sup>*\\\<^sup>* U)\ \ NPath [t]" + proof (induct U) + show "\t. \NPath []; NPath ([t] \<^sup>*\\\<^sup>* [])\ \ NPath [t]" + using NPath_def by simp + fix t u U + assume ind: "\t. \NPath U; NPath ([t] \<^sup>*\\\<^sup>* U)\ \ NPath [t]" + assume uU: "NPath (u # U)" + assume resid: "NPath ([t] \<^sup>*\\\<^sup>* (u # U))" + show "NPath [t]" + using uU ind NPath_def + by (metis Arr.simps(1) Arr.simps(2) Con_implies_Arr(2) N.backward_stable + N.elements_are_arr Resid_rec(1) Resid_rec(3) insert_subset list.simps(15) resid) + qed + + lemma Backward_stable: + shows "\U. \NPath U; NPath (T \<^sup>*\\\<^sup>* U)\ \ NPath T" + proof (induct T) + show "\U. \NPath U; NPath ([] \<^sup>*\\\<^sup>* U)\ \ NPath []" + by simp + fix t T U + assume ind: "\U. \NPath U; NPath (T \<^sup>*\\\<^sup>* U)\ \ NPath T" + assume U: "NPath U" + assume resid: "NPath ((t # T) \<^sup>*\\\<^sup>* U)" + show "NPath (t # T)" + proof (cases "T = []") + show "T = [] \ ?thesis" + using U resid Backward_stable_single by blast + assume T: "T \ []" + have 1: "NPath ([t] \<^sup>*\\\<^sup>* U) \ NPath (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + using T U NPath_append resid NPath_def + by (metis Arr.simps(1) Con_cons(1) Resid_cons(1)) + have 2: "t \ \" + using 1 U Backward_stable_single NPath_def by simp + moreover have "NPath T" + using 1 U resid ind + by (metis 2 Arr.simps(2) Con_imp_eq_Srcs NPath_Resid N.elements_are_arr) + moreover have "R.targets t \ Srcs T" + using resid 1 Con_imp_eq_Srcs Con_sym Srcs_Resid_Arr_single NPath_def + by (metis Arr.simps(1) dual_order.eq_iff) + ultimately show ?thesis + using NPath_def + by (simp add: N.elements_are_arr) + qed + qed + + sublocale normal_sub_rts Resid \Collect NPath\ + using Ide_implies_NPath NPath_implies_Arr arr_char ide_char coinitial_def + sources_char\<^sub>P append_is_composite_of + apply unfold_locales + apply auto + using Backward_stable + by metis+ + + theorem normal_extends_to_paths: + shows "normal_sub_rts Resid (Collect NPath)" + .. + + lemma Resid_NPath_preserves_reflects_Con: + assumes "NPath U" and "Srcs T = Srcs U" + shows "T \<^sup>*\\\<^sup>* U \<^sup>*\\<^sup>* T' \<^sup>*\\\<^sup>* U \ T \<^sup>*\\<^sup>* T'" + using assms NPath_def NPath_Resid con_char con_imp_coinitial resid_along_elem_preserves_con + Con_implies_Arr(2) Con_sym Cube(1) + by (metis Arr.simps(1) mem_Collect_eq) + + notation Cong\<^sub>0 (infix "\\<^sup>*\<^sub>0" 50) + notation Cong (infix "\\<^sup>*" 50) + + (* + * TODO: Leave these for now -- they still seem a little difficult to prove + * in this context, but are probably useful. + *) + lemma Cong\<^sub>0_cancel_left\<^sub>C\<^sub>S: + assumes "T @ U \\<^sup>*\<^sub>0 T @ U'" and "T \ []" and "U \ []" and "U' \ []" + shows "U \\<^sup>*\<^sub>0 U'" + using assms Cong\<^sub>0_cancel_left [of T U "T @ U" U' "T @ U'"] Cong\<^sub>0_reflexive + append_is_composite_of + by (metis Cong\<^sub>0_implies_Cong Cong_imp_arr(1) arr_append_imp_seq) + + lemma Srcs_respects_Cong: + assumes "T \\<^sup>* T'" and "a \ Srcs T" and "a' \ Srcs T'" + shows "[a] \\<^sup>* [a']" + proof - + obtain U U' where UU': "NPath U \ NPath U' \ T \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 T' \<^sup>*\\\<^sup>* U'" + using assms(1) by blast + show ?thesis + proof + show "U \ Collect NPath" + using UU' by simp + show "U' \ Collect NPath" + using UU' by simp + show "[a] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [a'] \<^sup>*\\\<^sup>* U'" + proof - + have "NPath ([a] \<^sup>*\\\<^sup>* U) \ NPath ([a'] \<^sup>*\\\<^sup>* U')" + by (metis Arr.simps(1) Con_imp_eq_Srcs Con_implies_Arr(1) Con_single_ide_ind + NPath_implies_Arr N.ide_closed R.in_sourcesE Srcs.simps(2) Srcs_simp\<^sub>P + UU' assms(2-3) elements_are_arr not_arr_null null_char NPath_Resid_single_Arr) + thus ?thesis + using UU' + by (metis Con_imp_eq_Srcs Cong\<^sub>0_imp_con NPath_Resid Srcs_Resid + con_char NPath_implies_Arr mem_Collect_eq arr_resid_iff_con con_implies_arr(2)) + qed + qed + qed + + lemma Trgs_respects_Cong: + assumes "T \\<^sup>* T'" and "b \ Trgs T" and "b' \ Trgs T'" + shows "[b] \\<^sup>* [b']" + proof - + have "[b] \ targets T \ [b'] \ targets T'" + proof - + have 1: "Ide [b] \ Ide [b']" + using assms + by (metis Ball_Collect Trgs_are_ide Ide.simps(2)) + moreover have "Srcs [b] = Trgs T" + using assms + by (metis 1 Con_imp_Arr_Resid Con_imp_eq_Srcs Cong_imp_arr(1) Ide.simps(2) + Srcs_Resid Con_single_ide_ind con_char arrE) + moreover have "Srcs [b'] = Trgs T'" + using assms + by (metis Con_imp_Arr_Resid Con_imp_eq_Srcs Cong_imp_arr(2) Ide.simps(2) + Srcs_Resid 1 Con_single_ide_ind con_char arrE) + ultimately show ?thesis + unfolding targets_char\<^sub>P + using assms Cong_imp_arr(2) arr_char by blast + qed + thus ?thesis + using assms targets_char in_targets_respects_Cong [of T T' "[b]" "[b']"] by simp + qed + + lemma Cong\<^sub>0_append_resid_NPath: + assumes "NPath (T \<^sup>*\\\<^sup>* U)" + shows "Cong\<^sub>0 (T @ (U \<^sup>*\\\<^sup>* T)) U" + proof (intro conjI) + show 0: "(T @ U \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* U \ Collect NPath" + proof - + have 1: "(T @ U \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* U = T \<^sup>*\\\<^sup>* U @ (U \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* T)" + by (metis Arr.simps(1) NPath_implies_Arr assms Con_append(1) Con_implies_Arr(2) + Con_sym Resid_append(1) con_imp_arr_resid null_char) + moreover have "NPath ..." + using assms + by (metis 1 Arr_append_iff\<^sub>P NPath_append NPath_implies_Arr Ide_implies_NPath + Nil_is_append_conv Resid_Arr_self arr_char con_char arr_resid_iff_con + self_append_conv) + ultimately show ?thesis by simp + qed + show "U \<^sup>*\\\<^sup>* (T @ U \<^sup>*\\\<^sup>* T) \ Collect NPath" + using assms 0 + by (metis Arr.simps(1) Con_implies_Arr(2) Cong\<^sub>0_reflexive Resid_append(2) + append.right_neutral arr_char Con_sym) + qed + + end + + locale paths_in_rts_with_coherent_normal = + R: rts + + N: coherent_normal_sub_rts + + paths_in_rts + begin + + sublocale paths_in_rts_with_normal resid \ .. + + notation Cong\<^sub>0 (infix "\\<^sup>*\<^sub>0" 50) + notation Cong (infix "\\<^sup>*" 50) + + text \ + Since composites of normal transitions are assumed to exist, normal paths can be + ``folded'' by composition down to single transitions. + \ + + lemma NPath_folding: + shows "NPath U \ \u. u \ \ \ R.sources u = Srcs U \ R.targets u = Trgs U \ + (\t. con [t] U \ [t] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [t \\ u])" + proof (induct U) + show "NPath [] \ \u. u \ \ \ R.sources u = Srcs [] \ R.targets u = Trgs [] \ + (\t. con [t] [] \ [t] \<^sup>*\\\<^sup>* [] \\<^sup>*\<^sub>0 [t \\ u])" + using NPath_def by auto + fix v U + assume ind: "NPath U \ \u. u \ \ \ R.sources u = Srcs U \ R.targets u = Trgs U \ + (\t. con [t] U \ [t] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [t \\ u])" + assume vU: "NPath (v # U)" + show "\vU. vU \ \ \ R.sources vU = Srcs (v # U) \ R.targets vU = Trgs (v # U) \ + (\t. con [t] (v # U) \ [t] \<^sup>*\\\<^sup>* (v # U) \\<^sup>*\<^sub>0 [t \\ vU])" + proof (cases "U = []") + show "U = [] \ \vU. vU \ \ \ R.sources vU = Srcs (v # U) \ + R.targets vU = Trgs (v # U) \ + (\t. con [t] (v # U) \ [t] \<^sup>*\\\<^sup>* (v # U) \\<^sup>*\<^sub>0 [t \\ vU])" + using vU Resid_rec(1) con_char + by (metis Cong\<^sub>0_reflexive NPath_def Srcs.simps(2) Trgs.simps(2) arr_resid_iff_con + insert_subset list.simps(15)) + assume "U \ []" + hence U: "NPath U" + using vU by (metis NPath_append append_Cons append_Nil) + obtain u where u: "u \ \ \ R.sources u = Srcs U \ R.targets u = Trgs U \ + (\t. con [t] U \ [t] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [t \\ u])" + using U ind by blast + have seq: "R.seq v u" + proof + show "R.arr v" + using vU + by (metis Con_Arr_self Con_rec(4) NPath_implies_Arr \U \ []\ R.arrI) + show "R.arr u" + by (simp add: N.elements_are_arr u) + show "R.targets v = R.sources u" + by (metis (full_types) NPath_implies_Arr R.sources_resid Srcs.simps(2) \U \ []\ + Con_Arr_self Con_imp_eq_Srcs Con_initial_right Con_rec(2) u vU) + qed + obtain vu where vu: "R.composite_of v u vu" + using N.composite_closed_right seq u by presburger + have "vu \ \ \ R.sources vu = Srcs (v # U) \ R.targets vu = Trgs (v # U) \ + (\t. con [t] (v # U) \ [t] \<^sup>*\\\<^sup>* (v # U) \\<^sup>*\<^sub>0 [t \\ vu])" + proof (intro conjI allI) + show "vu \ \" + by (meson NPath_def N.composite_closed list.set_intros(1) subsetD u vU vu) + show "R.sources vu = Srcs (v # U)" + by (metis Con_imp_eq_Srcs Con_initial_right NPath_implies_Arr + R.sources_composite_of Srcs.simps(2) Arr_iff_Con_self vU vu) + show "R.targets vu = Trgs (v # U)" + by (metis R.targets_composite_of Trgs.simps(3) \U \ []\ list.exhaust_sel u vu) + fix t + show "con [t] (v # U) \ [t] \<^sup>*\\\<^sup>* (v # U) \\<^sup>*\<^sub>0 [t \\ vu]" + proof (intro impI) + assume t: "con [t] (v # U)" + have 1: "[t] \<^sup>*\\\<^sup>* (v # U) = [t \\ v] \<^sup>*\\\<^sup>* U" + using t Resid_rec(3) \U \ []\ con_char by force + also have "... \\<^sup>*\<^sub>0 [(t \\ v) \\ u]" + using 1 t u by force + also have "[(t \\ v) \\ u] \\<^sup>*\<^sub>0 [t \\ vu]" + proof - + have "(t \\ v) \\ u \ t \\ vu" + using vu R.resid_composite_of + by (metis (no_types, lifting) N.Cong\<^sub>0_composite_of_arr_normal N.Cong\<^sub>0_subst_right(1) + \U \ []\ Con_rec(3) con_char R.con_sym t u) + thus ?thesis + using Ide.simps(2) R.prfx_implies_con Resid.simps(3) ide_char ide_closed + by presburger + qed + finally show "[t] \<^sup>*\\\<^sup>* (v # U) \\<^sup>*\<^sub>0 [t \\ vu]" by blast + qed + qed + thus ?thesis by blast + qed + qed + + text \ + Coherence for single transitions extends inductively to paths. + \ + + lemma Coherent_single: + assumes "R.arr t" and "NPath U" and "NPath U'" + and "R.sources t = Srcs U" and "Srcs U = Srcs U'" and "Trgs U = Trgs U'" + shows "[t] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [t] \<^sup>*\\\<^sup>* U'" + proof - + have 1: "con [t] U \ con [t] U'" + using assms + by (metis Arr.simps(1-2) Arr_iff_Con_self Resid_NPath_preserves_reflects_Con + Srcs.simps(2) con_char) + obtain u where u: "u \ \ \ R.sources u = Srcs U \ R.targets u = Trgs U \ + (\t. con [t] U \ [t] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [t \\ u])" + using assms NPath_folding by metis + obtain u' where u': "u' \ \ \ R.sources u' = Srcs U' \ R.targets u' = Trgs U' \ + (\t. con [t] U' \ [t] \<^sup>*\\\<^sup>* U' \\<^sup>*\<^sub>0 [t \\ u'])" + using assms NPath_folding by metis + have "[t] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [t \\ u]" + using u 1 by blast + also have "[t \\ u] \\<^sup>*\<^sub>0 [t \\ u']" + using assms(1,4-6) N.Cong\<^sub>0_imp_con N.coherent u u' NPath_def by simp + also have "[t \\ u'] \\<^sup>*\<^sub>0 [t] \<^sup>*\\\<^sup>* U'" + using u' 1 by simp + finally show ?thesis by simp + qed + + lemma Coherent: + shows "\U U'. \ Arr T; NPath U; NPath U'; Srcs T = Srcs U; + Srcs U = Srcs U'; Trgs U = Trgs U' \ + \ T \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 T \<^sup>*\\\<^sup>* U'" + proof (induct T) + show "\U U'. \ Arr []; NPath U; NPath U'; Srcs [] = Srcs U; + Srcs U = Srcs U'; Trgs U = Trgs U' \ + \ [] \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 [] \<^sup>*\\\<^sup>* U'" + by (simp add: arr_char) + fix t T U U' + assume tT: "Arr (t # T)" and U: "NPath U" and U': "NPath U'" + and Srcs1: "Srcs (t # T) = Srcs U" and Srcs2: "Srcs U = Srcs U'" + and Trgs: "Trgs U = Trgs U'" + and ind: "\U U'. \ Arr T; NPath U; NPath U'; Srcs T = Srcs U; + Srcs U = Srcs U'; Trgs U = Trgs U' \ + \ T \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 T \<^sup>*\\\<^sup>* U'" + have t: "R.arr t" + using tT by (metis Arr.simps(2) Con_Arr_self Con_rec(4) R.arrI) + show "(t # T) \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 (t # T) \<^sup>*\\\<^sup>* U'" + proof (cases "T = []") + show "T = [] \ ?thesis" + by (metis Srcs.simps(2) Srcs1 Srcs2 Trgs U U' Coherent_single Arr.simps(2) tT) + assume T: "T \ []" + let ?t = "[t] \<^sup>*\\\<^sup>* U" and ?t' = "[t] \<^sup>*\\\<^sup>* U'" + let ?T = "T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])" + let ?T' = "T \<^sup>*\\\<^sup>* (U' \<^sup>*\\\<^sup>* [t])" + have 0: "(t # T) \<^sup>*\\\<^sup>* U = ?t @ ?T \ (t # T) \<^sup>*\\\<^sup>* U' = ?t' @ ?T'" + using tT U U' Srcs1 Srcs2 + by (metis Arr_has_Src Arr_iff_Con_self Resid_cons(1) Srcs.simps(1) + Resid_NPath_preserves_reflects_Con) + have 1: "?t \\<^sup>*\<^sub>0 ?t'" + by (metis Srcs1 Srcs2 Srcs_simp\<^sub>P Trgs U U' list.sel(1) Coherent_single t tT) + have A: "?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t) = T \<^sup>*\\\<^sup>* ((U \<^sup>*\\\<^sup>* [t]) @ (?t' \<^sup>*\\\<^sup>* ?t))" + using 1 Arr.simps(1) Con_append(2) Con_sym Resid_append(2) Con_implies_Arr(1) + NPath_def + by (metis arr_char elements_are_arr) + have B: "?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t') = T \<^sup>*\\\<^sup>* ((U' \<^sup>*\\\<^sup>* [t]) @ (?t \<^sup>*\\\<^sup>* ?t'))" + by (metis "1" Con_appendI(2) Con_sym Resid.simps(1) Resid_append(2) elements_are_arr + not_arr_null null_char) + have E: "?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t) \\<^sup>*\<^sub>0 ?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')" + proof - + have "Arr T" + using Arr.elims(1) T tT by blast + moreover have "NPath (U \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U))" + using 1 U t tT Srcs1 Srcs_simp\<^sub>P + apply (intro NPath_appendI) + apply auto + by (metis Arr.simps(1) NPath_def Srcs_Resid Trgs_Resid_sym) + moreover have "NPath (U' \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U'))" + using t U' 1 Con_imp_eq_Srcs Trgs_Resid_sym + apply (intro NPath_appendI) + apply auto + apply (metis Arr.simps(2) NPath_Resid Resid.simps(1)) + by (metis Arr.simps(1) NPath_def Srcs_Resid) + moreover have "Srcs T = Srcs (U \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U))" + using A B + by (metis (full_types) "0" "1" Arr_has_Src Con_cons(1) Con_implies_Arr(1) + Srcs.simps(1) Srcs_append T elements_are_arr not_arr_null null_char + Con_imp_eq_Srcs) + moreover have "Srcs (U \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U)) = + Srcs (U' \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U'))" + by (metis "1" Con_implies_Arr(2) Con_sym Cong\<^sub>0_imp_con Srcs_Resid Srcs_append + arr_char con_char arr_resid_iff_con) + moreover have "Trgs (U \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U)) = + Trgs (U' \<^sup>*\\\<^sup>* [t] @ ([t] \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ([t] \<^sup>*\\\<^sup>* U'))" + using "1" Cong\<^sub>0_imp_con con_char by force + ultimately show ?thesis + using A B ind [of "(U \<^sup>*\\\<^sup>* [t]) @ (?t' \<^sup>*\\\<^sup>* ?t)" "(U' \<^sup>*\\\<^sup>* [t]) @ (?t \<^sup>*\\\<^sup>* ?t')"] + by simp + qed + have C: "NPath ((?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)) \<^sup>*\\\<^sup>* (?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')))" + using E by blast + have D: "NPath ((?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')) \<^sup>*\\\<^sup>* (?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)))" + using E by blast + show ?thesis + proof + have 2: "((t # T) \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ((t # T) \<^sup>*\\\<^sup>* U') = + ((?t \<^sup>*\\\<^sup>* ?t') \<^sup>*\\\<^sup>* ?T') @ ((?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)) \<^sup>*\\\<^sup>* (?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')))" + proof - + have "((t # T) \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ((t # T) \<^sup>*\\\<^sup>* U') = (?t @ ?T) \<^sup>*\\\<^sup>* (?t' @ ?T')" + using 0 by fastforce + also have "... = ((?t @ ?T) \<^sup>*\\\<^sup>* ?t') \<^sup>*\\\<^sup>* ?T'" + using tT T U U' Srcs1 Srcs2 0 + by (metis Con_appendI(2) Con_cons(1) Con_sym Resid.simps(1) Resid_append(2)) + also have "... = ((?t \<^sup>*\\\<^sup>* ?t') @ (?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t))) \<^sup>*\\\<^sup>* ?T'" + by (metis (no_types, lifting) Arr.simps(1) Con_appendI(1) Con_implies_Arr(1) + D NPath_def Resid_append(1) null_is_zero(2)) + also have "... = ((?t \<^sup>*\\\<^sup>* ?t') \<^sup>*\\\<^sup>* ?T') @ + ((?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)) \<^sup>*\\\<^sup>* (?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')))" + proof - + have "?t \<^sup>*\\\<^sup>* ?t' @ ?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t) \<^sup>*\\<^sup>* ?T'" + using C D E Con_sym + by (metis Con_append(2) Cong\<^sub>0_imp_con con_char arr_resid_iff_con + con_implies_arr(2)) + thus ?thesis + using Resid_append(1) + by (metis Con_sym append.right_neutral Resid.simps(1)) + qed + finally show ?thesis by simp + qed + moreover have 3: "NPath ..." + proof - + have "NPath ((?t \<^sup>*\\\<^sup>* ?t') \<^sup>*\\\<^sup>* ?T')" + using 0 1 E + by (metis Con_imp_Arr_Resid Con_imp_eq_Srcs NPath_Resid Resid.simps(1) + ex_un_null mem_Collect_eq) + moreover have "Trgs ((?t \<^sup>*\\\<^sup>* ?t') \<^sup>*\\\<^sup>* ?T') = + Srcs ((?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)) \<^sup>*\\\<^sup>* (?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')))" + using C + by (metis NPath_implies_Arr Srcs.simps(1) Srcs_Resid + Trgs_Resid_sym Arr_has_Src) + ultimately show ?thesis + using C by blast + qed + ultimately show "((t # T) \<^sup>*\\\<^sup>* U) \<^sup>*\\\<^sup>* ((t # T) \<^sup>*\\\<^sup>* U') \ Collect NPath" + by simp + + have 4: "((t # T) \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ((t # T) \<^sup>*\\\<^sup>* U) = + ((?t' \<^sup>*\\\<^sup>* ?t) \<^sup>*\\\<^sup>* ?T) @ ((?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')) \<^sup>*\\\<^sup>* (?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)))" + by (metis "0" "2" "3" Arr.simps(1) Con_implies_Arr(1) Con_sym D NPath_def Resid_append2) + moreover have "NPath ..." + proof - + have "NPath ((?t' \<^sup>*\\\<^sup>* ?t) \<^sup>*\\\<^sup>* ?T)" + by (metis "1" CollectD Cong\<^sub>0_imp_con E con_imp_coinitial forward_stable + arr_resid_iff_con con_implies_arr(2)) + moreover have "NPath ((?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')) \<^sup>*\\\<^sup>* (?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)))" + using U U' 1 D ind Coherent_single [of t U' U] by blast + moreover have "Trgs ((?t' \<^sup>*\\\<^sup>* ?t) \<^sup>*\\\<^sup>* ?T) = + Srcs ((?T' \<^sup>*\\\<^sup>* (?t \<^sup>*\\\<^sup>* ?t')) \<^sup>*\\\<^sup>* (?T \<^sup>*\\\<^sup>* (?t' \<^sup>*\\\<^sup>* ?t)))" + by (metis Arr.simps(1) NPath_def Srcs_Resid Trgs_Resid_sym calculation(2)) + ultimately show ?thesis by blast + qed + ultimately show "((t # T) \<^sup>*\\\<^sup>* U') \<^sup>*\\\<^sup>* ((t # T) \<^sup>*\\\<^sup>* U) \ Collect NPath" + by simp + qed + qed + qed + + sublocale rts_with_composites Resid + using is_rts_with_composites by simp + + sublocale coherent_normal_sub_rts Resid \Collect NPath\ + proof + fix T U U' + assume T: "arr T" and U: "U \ Collect NPath" and U': "U' \ Collect NPath" + assume sources_UU': "sources U = sources U'" and targets_UU': "targets U = targets U'" + and TU: "sources T = sources U" + have "Srcs T = Srcs U" + using TU sources_char\<^sub>P T arr_iff_has_source by auto + moreover have "Srcs U = Srcs U'" + by (metis Con_imp_eq_Srcs T TU con_char con_imp_coinitial_ax con_sym in_sourcesE + in_sourcesI arr_def sources_UU') + moreover have "Trgs U = Trgs U'" + using U U' targets_UU' targets_char + by (metis (full_types) arr_iff_has_target composable_def composable_iff_seq + composite_of_arr_target elements_are_arr equals0I seq_char) + ultimately show "T \<^sup>*\\\<^sup>* U \\<^sup>*\<^sub>0 T \<^sup>*\\\<^sup>* U'" + using T U U' Coherent [of T U U'] arr_char by blast + qed + + theorem coherent_normal_extends_to_paths: + shows "coherent_normal_sub_rts Resid (Collect NPath)" + .. + + lemma Cong\<^sub>0_append_Arr_NPath: + assumes "T \ []" and "Arr (T @ U)" and "NPath U" + shows "Cong\<^sub>0 (T @ U) T" + using assms + by (metis Arr.simps(1) Arr_appendE\<^sub>P NPath_implies_Arr append_is_composite_of arrI\<^sub>P + arr_append_imp_seq composite_of_arr_normal mem_Collect_eq) + + lemma Cong_append_NPath_Arr: + assumes "T \ []" and "Arr (U @ T)" and "NPath U" + shows "U @ T \\<^sup>* T" + using assms + by (metis (full_types) Arr.simps(1) Con_Arr_self Con_append(2) Con_implies_Arr(2) + Con_imp_eq_Srcs composite_of_normal_arr Srcs_Resid append_is_composite_of arr_char + NPath_implies_Arr mem_Collect_eq seq_char) + + subsubsection "Permutation Congruence" + + text \ + Here we show that \\<^sup>*\\<^sup>*\ coincides with ``permutation congruence'': + the least congruence respecting composition that relates \[t, u \ t]\ and \[u, t \ u]\ + whenever \t \ u\ and that relates \T @ [b]\ and \T\ whenever \b\ is an identity + such that \seq T [b]\. + \ + + inductive PCong + where "Arr T \ PCong T T" + | "PCong T U \ PCong U T" + | "\PCong T U; PCong U V\ \ PCong T V" + | "\seq T U; PCong T T'; PCong U U'\ \ PCong (T @ U) (T' @ U')" + | "\seq T [b]; R.ide b\ \ PCong (T @ [b]) T" + | "t \ u \ PCong [t, u \\ t] [u, t \\ u]" + + lemmas PCong.intros(3) [trans] + + lemma PCong_append_Ide: + shows "\seq T B; Ide B\ \ PCong (T @ B) T" + proof (induct B) + show "\seq T []; Ide []\ \ PCong (T @ []) T" + by auto + fix b B T + assume ind: "\seq T B; Ide B\ \ PCong (T @ B) T" + assume seq: "seq T (b # B)" + assume Ide: "Ide (b # B)" + have "T @ (b # B) = (T @ [b]) @ B" + by simp + also have "PCong ... (T @ B)" + apply (cases "B = []") + using Ide PCong.intros(5) seq apply force + using seq Ide PCong.intros(4) [of "T @ [b]" B T B] + by (metis Arr.simps(1) Ide_imp_Ide_hd PCong.intros(1) PCong.intros(5) + append_is_Nil_conv arr_append arr_append_imp_seq arr_char calculation + list.distinct(1) list.sel(1) seq_char) + also have "PCong (T @ B) T" + proof (cases "B = []") + show "B = [] \ ?thesis" + using PCong.intros(1) seq seq_char by force + assume B: "B \ []" + have "seq T B" + using B seq Ide + by (metis Con_imp_eq_Srcs Ide_imp_Ide_hd Trgs_append \T @ b # B = (T @ [b]) @ B\ + append_is_Nil_conv arr_append arr_append_imp_seq arr_char cong_cons_ideI(2) + list.distinct(1) list.sel(1) not_arr_null null_char seq_char ide_implies_arr) + thus ?thesis + using seq Ide ind + by (metis Arr.simps(1) Ide.elims(3) Ide.simps(3) seq_char) + qed + finally show "PCong (T @ (b # B)) T" by blast + qed + + lemma PCong_imp_Cong: + shows "PCong T U \ T \<^sup>*\\<^sup>* U" + proof (induct rule: PCong.induct) + show "\T. Arr T \ T \<^sup>*\\<^sup>* T" + using cong_reflexive by blast + show "\T U. \PCong T U; T \<^sup>*\\<^sup>* U\ \ U \<^sup>*\\<^sup>* T" + by blast + show "\T U V. \PCong T U; T \<^sup>*\\<^sup>* U; PCong U V; U \<^sup>*\\<^sup>* V\ \ T \<^sup>*\\<^sup>* V" + using cong_transitive by blast + show "\T U U' T'. \seq T U; PCong T T'; T \<^sup>*\\<^sup>* T'; PCong U U'; U \<^sup>*\\<^sup>* U'\ + \ T @ U \<^sup>*\\<^sup>* T' @ U'" + using cong_append by simp + show "\T b. \seq T [b]; R.ide b\ \ T @ [b] \<^sup>*\\<^sup>* T" + using cong_append_ideI(4) ide_char by force + show "\t u. t \ u \ [t, u \\ t] \<^sup>*\\<^sup>* [u, t \\ u]" + proof - + have "\t u. t \ u \ [t, u \\ t] \<^sup>*\\<^sup>* [u, t \\ u]" + proof - + fix t u + assume con: "t \ u" + have "([t] @ [u \\ t]) \<^sup>*\\\<^sup>* ([u] @ [t \\ u]) = + [(t \\ u) \\ (t \\ u), ((u \\ t) \\ (u \\ t)) \\ ((t \\ u) \\ (t \\ u))]" + using con Resid_append2 [of "[t]" "[u \\ t]" "[u]" "[t \\ u]"] + apply simp + by (metis R.arr_resid_iff_con R.con_target R.conE R.con_sym + R.prfx_implies_con R.prfx_reflexive R.cube) + moreover have "Ide ..." + using con + by (metis Arr.simps(2) Arr.simps(3) Ide.simps(2) Ide.simps(3) R.arr_resid_iff_con + R.con_sym R.resid_ide_arr R.prfx_reflexive calculation Con_imp_Arr_Resid) + ultimately show"[t, u \\ t] \<^sup>*\\<^sup>* [u, t \\ u]" + using ide_char by auto + qed + thus "\t u. t \ u \ [t, u \\ t] \<^sup>*\\<^sup>* [u, t \\ u]" + using R.con_sym by blast + qed + qed + + lemma PCong_permute_single: + shows "\t. [t] \<^sup>*\\<^sup>* U \ PCong ([t] @ (U \<^sup>*\\\<^sup>* [t])) (U @ ([t] \<^sup>*\\\<^sup>* U))" + proof (induct U) + show "\t. [t] \<^sup>*\\<^sup>* [] \ PCong ([t] @ [] \<^sup>*\\\<^sup>* [t]) ([] @ [t] \<^sup>*\\\<^sup>* [])" + by auto + fix t u U + assume ind: "\t. [t] \<^sup>*\\\<^sup>* U \ [] \ PCong ([t] @( U \<^sup>*\\\<^sup>* [t])) (U @ ([t] \<^sup>*\\\<^sup>* U))" + assume con: "[t] \<^sup>*\\<^sup>* u # U" + show "PCong ([t] @ (u # U) \<^sup>*\\\<^sup>* [t]) ((u # U) @ [t] \<^sup>*\\\<^sup>* (u # U))" + proof (cases "U = []") + show "U = [] \ ?thesis" + by (metis PCong.intros(6) Resid.simps(3) append_Cons append_eq_append_conv2 + append_self_conv con_char con_def con con_sym_ax) + assume U: "U \ []" + show "PCong ([t] @ ((u # U) \<^sup>*\\\<^sup>* [t])) ((u # U) @ ([t] \<^sup>*\\\<^sup>* (u # U)))" + proof - + have "[t] @ ((u # U) \<^sup>*\\\<^sup>* [t]) = [t] @ ([u \\ t] @ (U \<^sup>*\\\<^sup>* [t \\ u]))" + using Con_sym Resid_rec(2) U con by auto + also have "... = ([t] @ [u \\ t]) @ (U \<^sup>*\\\<^sup>* [t \\ u])" + by auto + also have "PCong ... (([u] @ [t \\ u]) @ (U \<^sup>*\\\<^sup>* [t \\ u]))" + proof - + have "PCong ([t] @ [u \\ t]) ([u] @ [t \\ u])" + using con + by (simp add: Con_rec(3) PCong.intros(6) U) + thus ?thesis + by (metis Arr_Resid_single Con_implies_Arr(1) Con_rec(2) Con_sym + PCong.intros(1,4) Srcs_Resid U append_is_Nil_conv append_is_composite_of + arr_append_imp_seq arr_char calculation composite_of_unq_upto_cong + con not_arr_null null_char ide_implies_arr seq_char) + qed + also have "([u] @ [t \\ u]) @ (U \<^sup>*\\\<^sup>* [t \\ u]) = [u] @ ([t \\ u] @ (U \<^sup>*\\\<^sup>* [t \\ u]))" + by simp + also have "PCong ... ([u] @ (U @ ([t \\ u] \<^sup>*\\\<^sup>* U)))" + proof - + have "PCong ([t \\ u] @ (U \<^sup>*\\\<^sup>* [t \\ u])) (U @ ([t \\ u] \<^sup>*\\\<^sup>* U))" + using ind + by (metis Resid_rec(3) U con) + moreover have "seq [u] ([t \\ u] @ U \<^sup>*\\\<^sup>* [t \\ u])" + proof + show "Arr [u]" + using Con_implies_Arr(2) Con_initial_right con by blast + show "Arr ([t \\ u] @ U \<^sup>*\\\<^sup>* [t \\ u])" + using Con_implies_Arr(1) U con Con_imp_Arr_Resid Con_rec(3) Con_sym + by fastforce + show "Trgs [u] \ Srcs ([t \\ u] @ U \<^sup>*\\\<^sup>* [t \\ u]) \ {}" + by (metis Arr.simps(1) Arr.simps(2) Arr_has_Trg Con_implies_Arr(1) + Int_absorb R.arr_resid_iff_con R.sources_resid Resid_rec(3) + Srcs.simps(2) Srcs_append Trgs.simps(2) U \Arr [u]\ con) + qed + moreover have "PCong [u] [u]" + using PCong.intros(1) calculation(2) seq_char by force + ultimately show ?thesis + using U arr_append arr_char con seq_char + PCong.intros(4) [of "[u]" "[t \\ u] @ (U \<^sup>*\\\<^sup>* [t \\ u])" + "[u]" "U @ ([t \\ u] \<^sup>*\\\<^sup>* U)"] + by blast + qed + also have "([u] @ (U @ ([t \\ u] \<^sup>*\\\<^sup>* U))) = ((u # U) @ [t] \<^sup>*\\\<^sup>* (u # U))" + by (metis Resid_rec(3) U append_Cons append_Nil con) + finally show ?thesis by blast + qed + qed + qed + + lemma PCong_permute: + shows "\U. T \<^sup>*\\<^sup>* U \ PCong (T @ (U \<^sup>*\\\<^sup>* T)) (U @ (T \<^sup>*\\\<^sup>* U))" + proof (induct T) + show "\U. [] \<^sup>*\\\<^sup>* U \ [] \ PCong ([] @ U \<^sup>*\\\<^sup>* []) (U @ [] \<^sup>*\\\<^sup>* U)" + by simp + fix t T U + assume ind: "\U. T \<^sup>*\\<^sup>* U \ PCong (T @ (U \<^sup>*\\\<^sup>* T)) (U @ (T \<^sup>*\\\<^sup>* U))" + assume con: "t # T \<^sup>*\\<^sup>* U" + show "PCong ((t # T) @ (U \<^sup>*\\\<^sup>* (t # T))) (U @ ((t # T) \<^sup>*\\\<^sup>* U))" + proof (cases "T = []") + assume T: "T = []" + have "(t # T) @ (U \<^sup>*\\\<^sup>* (t # T)) = [t] @ (U \<^sup>*\\\<^sup>* [t])" + using con T by simp + also have "PCong ... (U @ ([t] \<^sup>*\\\<^sup>* U))" + using PCong_permute_single T con by blast + finally show ?thesis + using T by fastforce + next + assume T: "T \ []" + have "(t # T) @ (U \<^sup>*\\\<^sup>* (t # T)) = [t] @ (T @ (U \<^sup>*\\\<^sup>* (t # T)))" + by simp + also have "PCong ... ([t] @ (U \<^sup>*\\\<^sup>* [t]) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])))" + using ind [of "U \<^sup>*\\\<^sup>* [t]"] + by (metis Arr.simps(1) Con_imp_Arr_Resid Con_implies_Arr(2) Con_sym + PCong.intros(1,4) Resid_cons(2) Srcs_Resid T arr_append arr_append_imp_seq + calculation con not_arr_null null_char seq_char) + also have "[t] @ (U \<^sup>*\\\<^sup>* [t]) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) = + ([t] @ (U \<^sup>*\\\<^sup>* [t])) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))" + by simp + also have "PCong (([t] @ (U \<^sup>*\\\<^sup>* [t])) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t]))) + ((U @ ([t] \<^sup>*\\\<^sup>* U)) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])))" + by (metis Arr.simps(1) Con_cons(1) Con_imp_Arr_Resid Con_implies_Arr(2) + PCong.intros(1,4) PCong_permute_single Srcs_Resid T Trgs_append arr_append + arr_char con seq_char) + also have "(U @ ([t] \<^sup>*\\\<^sup>* U)) @ (T \<^sup>*\\\<^sup>* (U \<^sup>*\\\<^sup>* [t])) = U @ ((t # T) \<^sup>*\\\<^sup>* U)" + by (metis Resid.simps(2) Resid_cons(1) append.assoc con) + finally show ?thesis by blast + qed + qed + + lemma Cong_imp_PCong: + assumes "T \<^sup>*\\<^sup>* U" + shows "PCong T U" + proof - + have "PCong T (T @ (U \<^sup>*\\\<^sup>* T))" + using assms PCong.intros(2) PCong_append_Ide + by (metis Con_implies_Arr(1) Ide.simps(1) Srcs_Resid ide_char Con_imp_Arr_Resid + seq_char) + also have "PCong (T @ (U \<^sup>*\\\<^sup>* T)) (U @ (T \<^sup>*\\\<^sup>* U))" + using PCong_permute assms con_char prfx_implies_con by presburger + also have "PCong (U @ (T \<^sup>*\\\<^sup>* U)) U" + using assms PCong_append_Ide + by (metis Con_imp_Arr_Resid Con_implies_Arr(1) Srcs_Resid arr_resid_iff_con + ide_implies_arr con_char ide_char seq_char) + finally show ?thesis by blast + qed + + lemma Cong_iff_PCong: + shows "T \<^sup>*\\<^sup>* U \ PCong T U" + using PCong_imp_Cong Cong_imp_PCong by blast + + end + + section "Composite Completion" + + text \ + The RTS of paths in an RTS factors via the coherent normal sub-RTS of identity + paths into an extensional RTS with composites, which can be regarded as a + ``composite completion'' of the original RTS. + \ + + locale composite_completion = + R: rts + begin + + interpretation N: coherent_normal_sub_rts resid \Collect R.ide\ + using R.rts_axioms R.identities_form_coherent_normal_sub_rts by auto + sublocale P: paths_in_rts_with_coherent_normal resid \Collect R.ide\ .. + sublocale quotient_by_coherent_normal P.Resid \Collect P.NPath\ .. + + notation P.Resid (infix "\<^sup>*\\\<^sup>*" 70) + notation P.Con (infix "\<^sup>*\\<^sup>*" 50) + notation P.Cong (infix "\<^sup>*\\<^sup>*" 50) + notation P.Cong\<^sub>0 (infix "\<^sup>*\\<^sub>0\<^sup>*" 50) + notation P.Cong_class ("\_\") + + notation Resid (infix "\\<^sup>*\\\<^sup>*\" 70) + notation con (infix "\\<^sup>*\\<^sup>*\" 50) + notation prfx (infix "\\<^sup>*\\<^sup>*\" 50) + + lemma NPath_char: + shows "P.NPath T \ P.Ide T" + using P.NPath_def P.Ide_implies_NPath by blast + + lemma Cong_eq_Cong\<^sub>0: + shows "T \<^sup>*\\<^sup>* T' \ T \<^sup>*\\<^sub>0\<^sup>* T'" + by (metis P.Cong_iff_cong P.ide_char P.ide_closed CollectD Collect_cong + NPath_char) + + lemma Srcs_respects_Cong: + assumes "T \<^sup>*\\<^sup>* T'" + shows "P.Srcs T = P.Srcs T'" + using assms + by (meson P.Con_imp_eq_Srcs P.Cong\<^sub>0_imp_con P.con_char Cong_eq_Cong\<^sub>0) + + lemma sources_respects_Cong: + assumes "T \<^sup>*\\<^sup>* T'" + shows "P.sources T = P.sources T'" + using assms + by (meson P.Cong\<^sub>0_imp_coinitial Cong_eq_Cong\<^sub>0) + + lemma Trgs_respects_Cong: + assumes "T \<^sup>*\\<^sup>* T'" + shows "P.Trgs T = P.Trgs T'" + proof - + have "P.Trgs T = P.Trgs (T @ (T' \<^sup>*\\\<^sup>* T))" + using assms NPath_char P.Arr.simps(1) P.Con_imp_Arr_Resid + P.Con_sym P.Cong_def P.Con_Arr_self + P.Con_implies_Arr(2) P.Resid_Ide(1) P.Srcs_Resid P.Trgs_append + by (metis P.Cong\<^sub>0_imp_con P.con_char CollectD) + also have "... = P.Trgs (T' @ (T \<^sup>*\\\<^sup>* T'))" + using P.Cong\<^sub>0_imp_con P.con_char Cong_eq_Cong\<^sub>0 assms by force + also have "... = P.Trgs T'" + using assms NPath_char P.Arr.simps(1) P.Con_imp_Arr_Resid + P.Con_sym P.Cong_def P.Con_Arr_self + P.Con_implies_Arr(2) P.Resid_Ide(1) P.Srcs_Resid P.Trgs_append + by (metis P.Cong\<^sub>0_imp_con P.con_char CollectD) + finally show ?thesis by blast + qed + + lemma targets_respects_Cong: + assumes "T \<^sup>*\\<^sup>* T'" + shows "P.targets T = P.targets T'" + using assms P.Cong_imp_arr(1) P.Cong_imp_arr(2) P.arr_iff_has_target + P.targets_char\<^sub>P Trgs_respects_Cong + by force + + lemma ide_char\<^sub>C\<^sub>C: + shows "ide \ \ arr \ \ (\T. T \ \ \ P.Ide T)" + using NPath_char ide_char' by force + + lemma con_char\<^sub>C\<^sub>C: + shows "\ \\<^sup>*\\<^sup>*\ \ \ arr \ \ arr \ \ P.Cong_class_rep \ \<^sup>*\\<^sup>* P.Cong_class_rep \" + proof + show "arr \ \ arr \ \ P.Cong_class_rep \ \<^sup>*\\<^sup>* P.Cong_class_rep \ \ \ \\<^sup>*\\<^sup>*\ \" + using arr_char P.con_char + by (meson P.rep_in_Cong_class con_char\<^sub>Q\<^sub>C\<^sub>N) + show "\ \\<^sup>*\\<^sup>*\ \ \ arr \ \ arr \ \ P.Cong_class_rep \ \<^sup>*\\<^sup>* P.Cong_class_rep \" + proof - + assume con: "\ \\<^sup>*\\<^sup>*\ \" + have 1: "arr \ \ arr \" + using con coinitial_iff con_imp_coinitial by blast + moreover have "P.Cong_class_rep \ \<^sup>*\\<^sup>* P.Cong_class_rep \" + proof - + obtain T U where TU: "T \ \ \ U \ \ \ P.Con T U" + using con Resid_def + by (meson P.con_char con_char\<^sub>Q\<^sub>C\<^sub>N) + have "T \<^sup>*\\<^sup>* P.Cong_class_rep \ \ U \<^sup>*\\<^sup>* P.Cong_class_rep \" + using TU 1 by (meson P.Cong_class_memb_Cong_rep arr_char) + thus ?thesis + using TU P.Cong_subst(1) [of T "P.Cong_class_rep \" U "P.Cong_class_rep \"] + by (metis P.coinitial_iff P.con_char P.con_imp_coinitial sources_respects_Cong) + qed + ultimately show ?thesis by simp + qed + qed + + lemma con_char\<^sub>C\<^sub>C': + shows "\ \\<^sup>*\\<^sup>*\ \ \ arr \ \ arr \ \ (\T U. T \ \ \ U \ \ \ T \<^sup>*\\<^sup>* U)" + proof + show "arr \ \ arr \ \ (\T U. T \ \ \ U \ \ \ T \<^sup>*\\<^sup>* U) \ \ \\<^sup>*\\<^sup>*\ \" + using con_char\<^sub>C\<^sub>C + by (simp add: P.rep_in_Cong_class arr_char) + show "\ \\<^sup>*\\<^sup>*\ \ \ arr \ \ arr \ \ (\T U. T \ \ \ U \ \ \ T \<^sup>*\\<^sup>* U)" + proof (intro conjI allI impI) + assume 1: "\ \\<^sup>*\\<^sup>*\ \" + show "arr \" + using 1 con_implies_arr by simp + show "arr \" + using 1 con_implies_arr by simp + fix T U + assume 2: "T \ \ \ U \ \" + show "T \<^sup>*\\<^sup>* U" + using 1 2 P.Cong_class_memb_Cong_rep + by (meson P.Cong\<^sub>0_subst_Con P.con_char Cong_eq_Cong\<^sub>0 arr_char con_char\<^sub>C\<^sub>C) + qed + qed + + lemma resid_char: + shows "\ \\<^sup>*\\\<^sup>*\ \ = + (if \ \\<^sup>*\\<^sup>*\ \ then \P.Cong_class_rep \ \<^sup>*\\\<^sup>* P.Cong_class_rep \\ else {})" + by (metis P.con_char P.rep_in_Cong_class Resid_by_members arr_char arr_resid_iff_con + con_char\<^sub>C\<^sub>C is_Cong_class_Resid) + + lemma src_char': + shows "src \ = {A. arr \ \ P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A}" + proof (cases "arr \") + show "\ arr \ \ ?thesis" + by (simp add: null_char src_def) + assume \: "arr \" + have 1: "\A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A" + by (metis P.Arr.simps(1) P.Con_imp_eq_Srcs P.Cong\<^sub>0_imp_con + P.Cong_class_memb_Cong_rep P.Cong_def P.con_char P.rep_in_Cong_class + CollectD \ NPath_char P.Con_implies_Arr(1) arr_char) + let ?A = "SOME A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A" + have A: "P.Ide ?A \ P.Srcs (P.Cong_class_rep \) = P.Srcs ?A" + using 1 someI_ex [of "\A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A"] by simp + have a: "arr \?A\" + using A P.ide_char P.is_Cong_classI arr_char by blast + have ide_a: "ide \?A\" + using a A P.Cong_class_def P.normal_is_Cong_closed NPath_char ide_char\<^sub>C\<^sub>C by auto + have "sources \ = {\?A\}" + proof - + have "\ \\<^sup>*\\<^sup>*\ \?A\" + by (metis (no_types, lifting) A P.Con_Ide_iff P.Cong_class_memb_Cong_rep + P.Cong_imp_arr(1) P.arr_char P.arr_in_Cong_class P.ide_char + P.ide_implies_arr P.rep_in_Cong_class Con_char a \ P.con_char + null_char arr_char P.con_sym conI) + hence "\?A\ \ sources \" + using ide_a in_sourcesI by simp + thus ?thesis + using sources_char by auto + qed + moreover have "\?A\ = {A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A}" + proof + show "{A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A} \ \?A\" + using A P.Cong_class_def P.Cong_closure_props(3) P.Ide_implies_Arr + P.ide_closed P.ide_char + by fastforce + show "\?A\ \ {A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A}" + using a A P.Cong_class_def Srcs_respects_Cong ide_a ide_char\<^sub>C\<^sub>C by blast + qed + ultimately show ?thesis + using \ src_in_sources by force + qed + + lemma src_char: + shows "src \ = {A. arr \ \ P.Ide A \ (\T. T \ \ \ P.Srcs T = P.Srcs A)}" + proof (cases "arr \") + show "\ arr \ \ ?thesis" + by (simp add: null_char src_def) + assume \: "arr \" + have "\T. T \ \ \ P.Srcs T = P.Srcs (P.Cong_class_rep \)" + using \ P.Cong_class_memb_Cong_rep Srcs_respects_Cong arr_char by auto + thus ?thesis + using \ src_char' P.is_Cong_class_def arr_char by force + qed + + lemma trg_char': + shows "trg \ = {B. arr \ \ P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B}" + proof (cases "arr \") + show "\ arr \ \ ?thesis" + by (metis (no_types, lifting) Collect_empty_eq arrI resid_arr_self resid_char) + assume \: "arr \" + have 1: "\B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B" + by (metis P.Con_implies_Arr(2) P.Resid_Arr_self P.Srcs_Resid \ con_char\<^sub>C\<^sub>C arrE) + define B where "B = (SOME B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B)" + have B: "P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B" + unfolding B_def + using 1 someI_ex [of "\B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B"] by simp + hence 2: "P.Ide B \ P.Con (P.Resid (P.Cong_class_rep \) (P.Cong_class_rep \)) B" + using \ + by (metis (no_types, lifting) P.Con_Ide_iff P.Ide_implies_Arr P.Resid_Arr_self + P.Srcs_Resid arrE P.Con_implies_Arr(2) con_char\<^sub>C\<^sub>C) + have b: "arr \B\" + by (simp add: "2" P.ide_char P.is_Cong_classI arr_char) + have ide_b: "ide \B\" + by (meson "2" P.arr_in_Cong_class P.ide_char P.ide_closed + b disjoint_iff ide_char P.ide_implies_arr) + have "targets \ = {\B\}" + proof - + have "cong (\ \\<^sup>*\\\<^sup>*\ \) \B\" + proof - + have "\ \\<^sup>*\\\<^sup>*\ \ = \B\" + by (metis (no_types, lifting) "2" P.Cong_class_eqI P.Cong_closure_props(3) + P.Resid_Arr_Ide_ind P.Resid_Ide(1) NPath_char \ con_char\<^sub>C\<^sub>C resid_char + P.Con_implies_Arr(2) P.Resid_Arr_self mem_Collect_eq) + thus ?thesis + using b cong_reflexive by presburger + qed + thus ?thesis + using \ targets_char\<^sub>Q\<^sub>C\<^sub>N [of \] cong_char by auto + qed + moreover have "\B\ = {B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B}" + proof + show "{B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B} \ \B\" + using B P.Cong_class_def P.Cong_closure_props(3) P.Ide_implies_Arr + P.ide_closed P.ide_char + by force + show "\B\ \ {B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B}" + proof - + have "\B'. P.Cong B' B \ P.Ide B' \ P.Trgs (P.Cong_class_rep \) = P.Srcs B'" + using B NPath_char P.normal_is_Cong_closed Srcs_respects_Cong + by (metis P.Cong_closure_props(1) mem_Collect_eq) + thus ?thesis + using P.Cong_class_def by blast + qed + qed + ultimately show ?thesis + using \ trg_in_targets by force + qed + + lemma trg_char: + shows "trg \ = {B. arr \ \ P.Ide B \ (\T. T \ \ \ P.Trgs T = P.Srcs B)}" + proof (cases "arr \") + show "\ arr \ \ ?thesis" + using trg_char' by presburger + assume \: "arr \" + have "\T. T \ \ \ P.Trgs T = P.Trgs (P.Cong_class_rep \)" + using \ + by (metis P.Cong_class_memb_Cong_rep Trgs_respects_Cong arr_char) + thus ?thesis + using \ trg_char' P.is_Cong_class_def arr_char by force + qed + + lemma is_extensional_rts_with_composites: + shows "extensional_rts_with_composites Resid" + proof + fix \ \ + assume seq: "seq \ \" + obtain T where T: "\ = \T\" + using seq P.Cong_class_rep arr_char seq_def by blast + obtain U where U: "\ = \U\" + using seq P.Cong_class_rep arr_char seq_def by blast + have 1: "P.Arr T \ P.Arr U" + using seq T U P.Con_implies_Arr(2) P.Cong\<^sub>0_subst_right(1) P.Cong_class_def + P.con_char seq_def + by (metis Collect_empty_eq P.Cong_imp_arr(1) P.arr_char P.rep_in_Cong_class + empty_iff arr_char) + have 2: "P.Trgs T = P.Srcs U" + proof - + have "targets \ = sources \" + using seq seq_def sources_char targets_char\<^sub>W\<^sub>E by force + hence 3: "trg \ = src \" + using seq arr_has_un_source arr_has_un_target + by (metis seq_def src_in_sources trg_in_targets) + hence "{B. P.Ide B \ P.Trgs (P.Cong_class_rep \) = P.Srcs B} = + {A. P.Ide A \ P.Srcs (P.Cong_class_rep \) = P.Srcs A}" + using seq seq_def src_char' [of \] trg_char' [of \] by force + hence "P.Trgs (P.Cong_class_rep \) = P.Srcs (P.Cong_class_rep \)" + using seq seq_def arr_char + by (metis (mono_tags, lifting) "3" P.Cong_class_is_nonempty Collect_empty_eq + arr_src_iff_arr mem_Collect_eq trg_char') + thus ?thesis + using seq seq_def arr_char T U P.Srcs_respects_Cong P.Trgs_respects_Cong + P.Cong_class_memb_Cong_rep P.Cong_symmetric + by (metis "1" P.arr_char P.arr_in_Cong_class Srcs_respects_Cong Trgs_respects_Cong) + qed + have "P.Arr (T @ U)" + using 1 2 by simp + moreover have "P.Ide (T \<^sup>*\\\<^sup>* (T @ U))" + by (metis "1" P.Con_append(2) P.Con_sym P.Resid_Arr_self P.Resid_Ide_Arr_ind + P.Resid_append(2) P.Trgs.simps(1) calculation P.Arr_has_Trg) + moreover have "(T @ U) \<^sup>*\\\<^sup>* T \<^sup>*\\<^sup>* U" + by (metis "1" P.Arr.simps(1) P.Con_sym P.Cong\<^sub>0_append_resid_NPath P.Cong\<^sub>0_cancel_left\<^sub>C\<^sub>S + P.Ide.simps(1) calculation(2) Cong_eq_Cong\<^sub>0 NPath_char) + ultimately have "composite_of \ \ \T @ U\" + proof (unfold composite_of_def, intro conjI) + show "prfx \ (P.Cong_class (T @ U))" + proof - + have "ide (\ \\<^sup>*\\\<^sup>*\ \T @ U\)" + proof (unfold ide_char, intro conjI) + have 3: "T \<^sup>*\\\<^sup>* (T @ U) \ \ \\<^sup>*\\\<^sup>*\ \T @ U\" + proof - + have "\ \\<^sup>*\\\<^sup>*\ \T @ U\ = \T \<^sup>*\\\<^sup>* (T @ U)\" + by (metis "1" P.Ide.simps(1) P.arr_char P.arr_in_Cong_class P.con_char + P.is_Cong_classI Resid_by_members T \P.Arr (T @ U)\ + \P.Ide (T \<^sup>*\\<^sup>* (T @ U))\) + thus ?thesis + by (simp add: P.arr_in_Cong_class P.elements_are_arr NPath_char + \P.Ide (T \<^sup>*\\<^sup>* (T @ U))\) + qed + show "arr (\ \\<^sup>*\\\<^sup>*\ \T @ U\)" + using 3 arr_char is_Cong_class_Resid by blast + show "\ \\<^sup>*\\\<^sup>*\ \T @ U\ \ Collect P.NPath \ {}" + using 3 P.ide_closed P.ide_char \P.Ide (T \<^sup>*\\<^sup>* (T @ U))\ by blast + qed + thus ?thesis by blast + qed + show "\T @ U\ \\<^sup>*\\\<^sup>*\ \ \\<^sup>*\\<^sup>*\ \" + proof - + have 3: "((T @ U) \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* U \ (\T @ U\ \\<^sup>*\\\<^sup>*\ \) \\<^sup>*\\\<^sup>*\ \" + proof - + have "(\T @ U\ \\<^sup>*\\\<^sup>*\ \) \\<^sup>*\\\<^sup>*\ \ = \((T @ U) \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* U\" + proof - + have "\T @ U\ \\<^sup>*\\\<^sup>*\ \ = \(T @ U) \<^sup>*\\\<^sup>* T\" + by (metis "1" P.Cong_imp_arr(1) P.arr_char P.arr_in_Cong_class + P.is_Cong_classI T \P.Arr (T @ U)\ \(T @ U) \<^sup>*\\<^sup>* T \<^sup>*\\<^sup>* U\ + Resid_by_members P.arr_resid_iff_con) + moreover + have "\(T @ U) \<^sup>*\\\<^sup>* T\ \\<^sup>*\\\<^sup>*\ \ = \((T @ U) \<^sup>*\\\<^sup>* T) \<^sup>*\\\<^sup>* U\" + by (metis "1" P.Cong_class_eqI P.Cong_imp_arr(1) P.arr_char + P.arr_in_Cong_class P.con_char P.is_Cong_classI arr_char arrE U + \(T @ U) \<^sup>*\\<^sup>* T \<^sup>*\\<^sup>* U\ con_char\<^sub>C\<^sub>C' Resid_by_members) + ultimately show ?thesis by auto + qed + thus ?thesis + by (metis "1" P.Arr.simps(1) P.Cong\<^sub>0_reflexive P.Resid_append(2) P.arr_char + P.arr_in_Cong_class P.elements_are_arr \P.Arr (T @ U)\) + qed + have "\T @ U\ \\<^sup>*\\\<^sup>*\ \ \\<^sup>*\\<^sup>*\ \" + proof (unfold ide_char, intro conjI) + show "arr ((\T @ U\ \\<^sup>*\\\<^sup>*\ \) \\<^sup>*\\\<^sup>*\ \)" + using 3 arr_char is_Cong_class_Resid by blast + show "(\T @ U\ \\<^sup>*\\\<^sup>*\ \) \\<^sup>*\\\<^sup>*\ \ \ Collect P.NPath \ {}" + by (metis 1 3 P.Arr.simps(1) P.Resid_append(2) P.con_char + IntI \P.Arr (T @ U)\ NPath_char P.Resid_Arr_self P.arr_char empty_iff + mem_Collect_eq P.arrE) + qed + thus ?thesis by blast + qed + show "\ \\<^sup>*\\<^sup>*\ \T @ U\ \\<^sup>*\\\<^sup>*\ \" + proof (unfold ide_char, intro conjI) + have 3: "U \<^sup>*\\\<^sup>* ((T @ U) \<^sup>*\\\<^sup>* T) \ \ \\<^sup>*\\\<^sup>*\ (\T @ U\ \\<^sup>*\\\<^sup>*\ \)" + proof - + have "\ \\<^sup>*\\\<^sup>*\ (\T @ U\ \\<^sup>*\\\<^sup>*\ \) = \U \<^sup>*\\\<^sup>* ((T @ U) \<^sup>*\\\<^sup>* T)\" + proof - + have "\T @ U\ \\<^sup>*\\\<^sup>*\ \ = \(T @ U) \<^sup>*\\\<^sup>* T\" + by (metis "1" P.Con_sym P.Ide.simps(1) P.arr_char P.arr_in_Cong_class + P.con_char P.is_Cong_classI Resid_by_members T \P.Arr (T @ U)\ + \P.Ide (T \<^sup>*\\<^sup>* (T @ U))\) + moreover have "\ \\<^sup>*\\\<^sup>*\ (\T @ U\ \\<^sup>*\\\<^sup>*\ \) = \U \<^sup>*\\\<^sup>* ((T @ U) \<^sup>*\\\<^sup>* T)\" + by (metis "1" P.Cong_class_eqI P.Cong_imp_arr(1) P.arr_char + P.arr_in_Cong_class P.con_char P.is_Cong_classI prfx_implies_con + U \(T @ U) \<^sup>*\\<^sup>* T \<^sup>*\\<^sup>* U\ \\T @ U\ \\<^sup>*\\<^sup>*\ \ \\<^sup>*\\<^sup>*\ \\ + calculation con_char\<^sub>C\<^sub>C' Resid_by_members) + ultimately show ?thesis by blast + qed + thus ?thesis + by (metis "1" P.Arr.simps(1) P.Resid_append_ind P.arr_in_Cong_class + P.con_char \P.Arr (T @ U)\ P.Con_Arr_self P.arr_resid_iff_con) + qed + show "arr (\ \\<^sup>*\\\<^sup>*\ (\T @ U\ \\<^sup>*\\\<^sup>*\ \))" + by (metis "3" arr_resid_iff_con empty_iff resid_char) + show "\ \\<^sup>*\\\<^sup>*\ (\T @ U\ \\<^sup>*\\\<^sup>*\ \) \ Collect P.NPath \ {}" + by (metis "1" "3" P.Arr.simps(1) P.Cong\<^sub>0_append_resid_NPath P.Cong\<^sub>0_cancel_left\<^sub>C\<^sub>S + P.Cong_imp_arr(1) P.arr_char NPath_char IntI \(T @ U) \<^sup>*\\<^sup>* T \<^sup>*\\<^sup>* U\ + \P.Ide (T \<^sup>*\\<^sup>* (T @ U))\ empty_iff) + qed + qed + thus "composable \ \" + using composable_def by auto + qed + + sublocale extensional_rts_with_composites Resid + using is_extensional_rts_with_composites by simp + + subsection "Inclusion Map" + + abbreviation incl + where "incl t \ \[t]\" + + text \ + The inclusion into the composite completion preserves consistency and residuation. + \ + + lemma incl_preserves_con: + assumes "t \ u" + shows "\[t]\ \\<^sup>*\\<^sup>*\ \[u]\" + using assms + by (meson P.Con_rec(1) P.arr_in_Cong_class P.con_char P.is_Cong_classI + con_char\<^sub>Q\<^sub>C\<^sub>N P.con_implies_arr(1-2)) + + lemma incl_preserves_resid: + shows "\[t \\ u]\ = \[t]\ \\<^sup>*\\\<^sup>*\ \[u]\" + proof (cases "t \ u") + show "t \ u \ ?thesis" + proof - + assume 1: "t \ u" + have "P.is_Cong_class \[t]\ \ P.is_Cong_class \[u]\" + using 1 con_char\<^sub>Q\<^sub>C\<^sub>N incl_preserves_con by presburger + moreover have "[t] \ \[t]\ \ [u] \ \[u]\" + using 1 + by (meson P.Con_rec(1) P.arr_in_Cong_class P.con_char + P.Con_implies_Arr(2) P.arr_char P.con_implies_arr(1)) + moreover have "P.con [t] [u]" + using 1 by (simp add: P.con_char) + ultimately show ?thesis + using Resid_by_members [of "\[t]\" "\[u]\" "[t]" "[u]"] + by (simp add: "1") + qed + assume 1: "\ t \ u" + have "\[t \\ u]\ = {}" + using 1 R.arrI + by (metis Collect_empty_eq P.Con_Arr_self P.Con_rec(1) + P.Cong_class_def P.Cong_imp_arr(1) P.arr_char R.arr_resid_iff_con) + also have "... = \[t]\ \\<^sup>*\\\<^sup>*\ \[u]\" + by (metis (full_types) "1" Con_char CollectD P.Con_rec(1) P.Cong_class_def + P.Cong_imp_arr(1) P.arr_in_Cong_class con_char\<^sub>C\<^sub>C' null_char conI) + finally show ?thesis by simp + qed + + lemma incl_reflects_con: + assumes "\[t]\ \\<^sup>*\\<^sup>*\ \[u]\" + shows "t \ u" + by (metis P.Con_rec(1) P.Cong_class_def P.Cong_imp_arr(1) P.arr_in_Cong_class + CollectD assms con_char\<^sub>C\<^sub>C' con_char\<^sub>Q\<^sub>C\<^sub>N) + + text \ + The inclusion map is a simulation. + \ + + sublocale incl: simulation resid Resid incl + proof + show "\t. \ R.arr t \ incl t = null" + by (metis Collect_empty_eq P.Cong_class_def P.Cong_imp_arr(1) P.Ide.simps(2) + P.Resid_rec(1) P.cong_reflexive P.elements_are_arr P.ide_char P.ide_closed + P.not_arr_null P.null_char R.prfx_implies_con null_char R.con_implies_arr(1)) + show "\t u. t \ u \ incl t \\<^sup>*\\<^sup>*\ incl u" + using incl_preserves_con by blast + show "\t u. t \ u \ incl (t \\ u) = incl t \\<^sup>*\\\<^sup>*\ incl u" + using incl_preserves_resid by blast + qed + + lemma inclusion_is_simulation: + shows "simulation resid Resid incl" + .. + + lemma incl_preserves_arr: + assumes "R.arr a" + shows "arr \[a]\" + using assms incl_preserves_con by auto + + lemma incl_preserves_ide: + assumes "R.ide a" + shows "ide \[a]\" + by (metis assms incl_preserves_con incl_preserves_resid R.ide_def ide_def) + + lemma cong_iff_eq_incl: + assumes "R.arr t" and "R.arr u" + shows "\[t]\ = \[u]\ \ t \ u" + proof + show "\[t]\ = \[u]\ \ t \ u" + by (metis P.Con_rec(1) P.Ide.simps(2) P.Resid.simps(3) P.arr_in_Cong_class + P.con_char R.arr_def R.cong_reflexive assms(1) ide_char\<^sub>C\<^sub>C + incl_preserves_con incl_preserves_ide incl_preserves_resid incl_reflects_con + P.arr_resid_iff_con) + show "t \ u \ \[t]\ = \[u]\" + using assms + by (metis incl_preserves_resid extensional incl_preserves_ide) + qed + + text \ + The inclusion is surjective on identities. + \ + + lemma img_incl_ide: + shows "incl ` (Collect R.ide) = Collect ide" + proof + show "incl ` Collect R.ide \ Collect ide" + by (simp add: image_subset_iff) + show "Collect ide \ incl ` Collect R.ide" + proof + fix \ + assume \: "\ \ Collect ide" + obtain A where A: "A \ \" + using \ ide_char by blast + have "P.NPath A" + by (metis A Ball_Collect \ ide_char' mem_Collect_eq) + obtain a where a: "a \ P.Srcs A" + using \P.NPath A\ + by (meson P.NPath_implies_Arr equals0I P.Arr_has_Src) + have "P.Cong\<^sub>0 A [a]" + proof - + have "P.Ide [a]" + by (metis NPath_char P.Con_Arr_self P.Ide.simps(2) P.NPath_implies_Arr + P.Resid_Ide(1) P.Srcs.elims R.in_sourcesE \P.NPath A\ a) + thus ?thesis + using a A + by (metis P.Ide.simps(2) P.ide_char P.ide_closed \P.NPath A\ NPath_char + P.Con_single_ide_iff P.Ide_implies_Arr P.Resid_Arr_Ide_ind P.Resid_Arr_Src) + qed + have "\ = \[a]\" + by (metis A P.Cong\<^sub>0_imp_con P.Cong\<^sub>0_implies_Cong P.Cong\<^sub>0_transitive P.Cong_class_eqI + P.ide_char P.resid_arr_ide Resid_by_members \ \A \<^sup>*\\<^sub>0\<^sup>* [a]\ \P.NPath A\ arr_char + NPath_char ideE ide_implies_arr mem_Collect_eq) + thus "\ \ incl ` Collect R.ide" + using NPath_char P.Ide.simps(2) P.backward_stable \A \<^sup>*\\<^sub>0\<^sup>* [a]\ \P.NPath A\ by blast + qed + qed + + end + + subsection "Composite Completion of an Extensional RTS" + + locale composite_completion_of_extensional_rts = + R: extensional_rts + + composite_completion + begin + + sublocale P: paths_in_weakly_extensional_rts resid .. + + notation comp (infixl "\\<^sup>*\\<^sup>*\" 55) + + text \ + When applied to an extensional RTS, the composite completion construction does not + identify any states that are distinct in the original RTS. + \ + + lemma incl_injective_on_ide: + shows "inj_on incl (Collect R.ide)" + using R.extensional cong_iff_eq_incl + by (intro inj_onI) auto + + text \ + When applied to an extensional RTS, the composite completion construction + is a bijection between the states of the original RTS and the states of its completion. + \ + + lemma incl_bijective_on_ide: + shows "bij_betw incl (Collect R.ide) (Collect ide)" + using incl_injective_on_ide img_incl_ide bij_betw_def by blast + + end + + subsection "Freeness of Composite Completion" + + text \ + In this section we show that the composite completion construction is free: + any simulation from RTS \A\ to an extensional RTS with composites \B\ + extends uniquely to a simulation on the composite completion of \A\. + \ + + locale extension_of_simulation = + A: paths_in_rts resid\<^sub>A + + B: extensional_rts_with_composites resid\<^sub>B + + F: simulation resid\<^sub>A resid\<^sub>B F + for resid\<^sub>A :: "'a resid" (infix "\\\<^sub>A" 70) + and resid\<^sub>B :: "'b resid" (infix "\\\<^sub>B" 70) + and F :: "'a \ 'b" + begin + + notation A.Resid (infix "\<^sup>*\\\<^sub>A\<^sup>*" 70) + notation A.Resid1x (infix "\<^sup>1\\\<^sub>A\<^sup>*" 70) + notation A.Residx1 (infix "\<^sup>*\\\<^sub>A\<^sup>1" 70) + notation A.Con (infix "\<^sup>*\\<^sub>A\<^sup>*" 70) + notation B.comp (infixl "\\<^sub>B" 55) + notation B.con (infix "\\<^sub>B" 50) + + fun map + where "map [] = B.null" + | "map [t] = F t" + | "map (t # T) = (if A.arr (t # T) then F t \\<^sub>B map T else B.null)" + + lemma map_o_incl_eq: + shows "map (A.incl t) = F t" + by (simp add: A.null_char F.extensional) + + lemma extensional: + shows "\ A.arr T \ map T = B.null" + using F.extensional A.arr_char + by (metis A.Arr.simps(2) map.elims) + + lemma preserves_comp: + shows "\U. \T \ []; U \ []; A.Arr (T @ U)\ \ map (T @ U) = map T \\<^sub>B map U" + proof (induct T) + show "\U. [] \ [] \ map ([] @ U) = map [] \\<^sub>B map U" + by simp + fix t and T U :: "'a list" + assume ind: "\U. \T \ []; U \ []; A.Arr (T @ U)\ + \ map (T @ U) = map T \\<^sub>B map U" + assume U: "U \ []" + assume Arr: "A.Arr ((t # T) @ U)" + hence 1: "A.Arr (t # (T @ U))" + by simp + have 2: "A.Arr (t # T)" + by (metis A.Con_Arr_self A.Con_append(1) A.Con_implies_Arr(1) Arr U append_is_Nil_conv + list.distinct(1)) + show "map ((t # T) @ U) = B.comp (map (t # T)) (map U)" + proof (cases "T = []") + show "T = [] \ ?thesis" + by (metis (full_types) "1" A.arr_char U append_Cons append_Nil list.exhaust + map.simps(2) map.simps(3)) + assume T: "T \ []" + have "map ((t # T) @ U) = map (t # (T @ U))" + by simp + also have "... = F t \\<^sub>B map (T @ U)" + using T 1 + by (metis A.arr_char Nil_is_append_conv list.exhaust map.simps(3)) + also have "... = F t \\<^sub>B (map T \\<^sub>B map U)" + using ind + by (metis "1" A.Con_Arr_self A.Con_implies_Arr(1) A.Con_rec(4) T U append_is_Nil_conv) + also have "... = F t \\<^sub>B map T \\<^sub>B map U" + using B.comp_assoc\<^sub>E\<^sub>C by blast + also have "... = map (t # T) \\<^sub>B map U" + using T 2 + by (metis A.arr_char list.exhaust map.simps(3)) + finally show "map ((t # T) @ U) = map (t # T) \\<^sub>B map U" by simp + qed + qed + + lemma preserves_arr_ind: + shows "\a. \A.arr T; a \ A.Srcs T\ \ B.arr (map T) \ B.src (map T) = F a" + proof (induct T) + show "\a. \A.arr []; a \ A.Srcs []\ \ B.arr (map []) \ B.src (map []) = F a" + using A.arr_char by simp + fix a t T + assume a: "a \ A.Srcs (t # T)" + assume tT: "A.arr (t # T)" + assume ind: "\a. \A.arr T; a \ A.Srcs T\ \ B.arr (map T) \ B.src (map T) = F a" + have 1: "a \ A.R.sources t" + using a tT A.Con_imp_eq_Srcs A.Con_initial_right A.Srcs.simps(2) A.con_char + by blast + show "B.arr (map (t # T)) \ B.src (map (t # T)) = F a" + proof (cases "T = []") + show "T = [] \ ?thesis" + by (metis "1" A.Arr.simps(2) A.arr_char B.arr_has_un_source B.src_in_sources + F.preserves_reflects_arr F.preserves_sources image_subset_iff map.simps(2) tT) + assume T: "T \ []" + obtain a' where a': "a' \ A.R.targets t" + using tT "1" A.R.resid_source_in_targets by auto + have 2: "a' \ A.Srcs T" + using a' tT + by (metis A.Con_Arr_self A.R.sources_resid A.Srcs.simps(2) A.arr_char T + A.Con_imp_eq_Srcs A.Con_rec(4)) + have "B.arr (map (t # T)) \ B.arr (F t \\<^sub>B map T)" + using tT T by (metis map.simps(3) neq_Nil_conv) + also have 2: "... \ True" + by (metis (no_types, lifting) "2" A.arr_char B.arr_comp\<^sub>E\<^sub>C B.arr_has_un_target + B.trg_in_targets F.preserves_reflects_arr F.preserves_targets T a' + A.Arr.elims(2) image_subset_iff ind list.sel(1) list.sel(3) tT) + finally have "B.arr (map (t # T))" by simp + moreover have "B.src (map (t # T)) = F a" + proof - + have "B.src (map (t # T)) = B.src (F t \\<^sub>B map T)" + using tT T by (metis map.simps(3) neq_Nil_conv) + also have "... = B.src (F t)" + using "2" B.con_comp_iff by force + also have "... = F a" + by (meson "1" B.weakly_extensional_rts_axioms F.simulation_axioms + simulation_to_weakly_extensional_rts.preserves_src + simulation_to_weakly_extensional_rts_def) + finally show ?thesis by simp + qed + ultimately show ?thesis by simp + qed + qed + + lemma preserves_arr: + shows "A.arr T \ B.arr (map T)" + using preserves_arr_ind A.arr_char A.Arr_has_Src by blast + + lemma preserves_src: + assumes "A.arr T" and "a \ A.Srcs T" + shows "B.src (map T) = F a" + using assms preserves_arr_ind by simp + + lemma preserves_trg: + shows "\A.arr T; b \ A.Trgs T\ \ B.trg (map T) = F b" + proof (induct T) + show "\A.arr []; b \ A.Trgs []\ \ B.trg (map []) = F b" + by simp + fix t T + assume tT: "A.arr (t # T)" + assume b: "b \ A.Trgs (t # T)" + assume ind: "\A.arr T; b \ A.Trgs T\ \ B.trg (map T) = F b" + show "B.trg (map (t # T)) = F b" + proof (cases "T = []") + show "T = [] \ ?thesis" + using tT b + by (metis A.Trgs.simps(2) B.arr_has_un_target B.trg_in_targets F.preserves_targets + preserves_arr image_subset_iff map.simps(2)) + assume T: "T \ []" + have 1: "B.trg (map (t # T)) = B.trg (F t \\<^sub>B map T)" + using tT T b + by (metis map.simps(3) neq_Nil_conv) + also have "... = B.trg (map T)" + by (metis B.arr_trg_iff_arr B.composable_iff_arr_comp B.trg_comp calculation + preserves_arr tT) + also have "... = F b" + using tT b ind + by (metis A.Trgs.simps(3) T A.Arr.simps(3) A.arr_char list.exhaust) + finally show ?thesis by simp + qed + qed + + lemma preserves_Resid1x_ind: + shows "\t. t \<^sup>1\\\<^sub>A\<^sup>* U \ A.R.null \ F t \\<^sub>B map U \ F (t \<^sup>1\\\<^sub>A\<^sup>* U) = F t \\\<^sub>B map U" + proof (induct U) + show "\t. t \<^sup>1\\\<^sub>A\<^sup>* [] \ A.R.null \ F t \\<^sub>B map [] \ F (t \<^sup>1\\\<^sub>A\<^sup>* []) = F t \\\<^sub>B map []" + by simp + fix t u U + assume uU: "t \<^sup>1\\\<^sub>A\<^sup>* (u # U) \ A.R.null" + assume ind: "\t. t \<^sup>1\\\<^sub>A\<^sup>* U \ A.R.null + \ F t \\<^sub>B map U \ F (t \<^sup>1\\\<^sub>A\<^sup>* U) = F t \\\<^sub>B map U" + show "F t \\<^sub>B map (u # U) \ F (t \<^sup>1\\\<^sub>A\<^sup>* (u # U)) = F t \\\<^sub>B map (u # U)" + proof + show 1: "F t \\<^sub>B map (u # U)" + proof (cases "U = []") + show "U = [] \ ?thesis" + using A.Resid1x.simps(2) map.simps(2) F.preserves_con uU by fastforce + assume U: "U \ []" + have 3: "[t] \<^sup>*\\\<^sub>A\<^sup>* [u] \ [] \ ([t] \<^sup>*\\\<^sub>A\<^sup>* [u]) \<^sup>*\\\<^sub>A\<^sup>* U \ []" + using A.Con_cons(2) [of "[t]" U u] + by (meson A.Resid1x_as_Resid' U not_Cons_self2 uU) + hence 2: "F t \\<^sub>B F u \ F t \\\<^sub>B F u \\<^sub>B map U" + by (metis A.Con_rec(1) A.Con_sym A.Con_sym1 A.Residx1_as_Resid A.Resid_rec(1) + F.preserves_con F.preserves_resid ind) + moreover have "B.seq (F u) (map U)" + by (metis B.coinitial_iff\<^sub>W\<^sub>E B.con_imp_coinitial B.seqI\<^sub>W\<^sub>E B.src_resid calculation) + ultimately have "F t \\<^sub>B map ([u] @ U)" + using B.con_comp_iff\<^sub>E\<^sub>C(1) [of "F t" "F u" "map U"] B.con_sym preserves_comp + by (metis 3 A.Con_cons(2) A.Con_implies_Arr(2) + append.left_neutral append_Cons map.simps(2) not_Cons_self2) + thus ?thesis by simp + qed + show "F (t \<^sup>1\\\<^sub>A\<^sup>* (u # U)) = F t \\\<^sub>B map (u # U)" + proof (cases "U = []") + show "U = [] \ ?thesis" + using A.Resid1x.simps(2) F.preserves_resid map.simps(2) uU by fastforce + assume U: "U \ []" + have "F (t \<^sup>1\\\<^sub>A\<^sup>* (u # U)) = F ((t \\\<^sub>A u) \<^sup>1\\\<^sub>A\<^sup>* U)" + using A.Resid1x_as_Resid' A.Resid_rec(3) U uU by metis + also have "... = F (t \\\<^sub>A u) \\\<^sub>B map U" + using uU U ind A.Con_rec(3) A.Resid1x_as_Resid [of "t \\\<^sub>A u" U] + by (metis A.Resid1x.simps(3) list.exhaust) + also have "... = (F t \\\<^sub>B F u) \\\<^sub>B map U" + using uU U + by (metis A.Resid1x_as_Resid' F.preserves_resid A.Con_rec(3)) + also have "... = F t \\\<^sub>B (F u \\<^sub>B map U)" + by (metis B.comp_null(2) B.composable_iff_comp_not_null B.con_compI(2) B.conI + B.con_sym_ax B.mediating_transition B.null_is_zero(2) B.resid_comp(1)) + also have "... = F t \\\<^sub>B map (u # U)" + by (metis A.Resid1x_as_Resid' A.con_char U map.simps(3) neq_Nil_conv + A.con_implies_arr(2) uU) + finally show ?thesis by simp + qed + qed + qed + + lemma preserves_Residx1_ind: + shows "\t. U \<^sup>*\\\<^sub>A\<^sup>1 t \ [] \ map U \\<^sub>B F t \ map (U \<^sup>*\\\<^sub>A\<^sup>1 t) = map U \\\<^sub>B F t" + proof (induct U) + show "\t. [] \<^sup>*\\\<^sub>A\<^sup>1 t \ [] \ map [] \\<^sub>B F t \ map ([] \<^sup>*\\\<^sub>A\<^sup>1 t) = map [] \\\<^sub>B F t" + by simp + fix t u U + assume ind: "\t. U \<^sup>*\\\<^sub>A\<^sup>1 t \ [] \ map U \\<^sub>B F t \ map (U \<^sup>*\\\<^sub>A\<^sup>1 t) = map U \\\<^sub>B F t" + assume uU: "(u # U) \<^sup>*\\\<^sub>A\<^sup>1 t \ []" + show "map (u # U) \\<^sub>B F t \ map ((u # U) \<^sup>*\\\<^sub>A\<^sup>1 t) = map (u # U) \\\<^sub>B F t" + proof (cases "U = []") + show "U = [] \ ?thesis" + using A.Residx1.simps(2) F.preserves_con F.preserves_resid map.simps(2) uU + by presburger + assume U: "U \ []" + show ?thesis + proof + show "map (u # U) \\<^sub>B F t" + using uU U A.Con_sym1 B.con_sym preserves_Resid1x_ind by blast + show "map ((u # U) \<^sup>*\\\<^sub>A\<^sup>1 t) = map (u # U) \\\<^sub>B F t" + proof - + have "map ((u # U) \<^sup>*\\\<^sub>A\<^sup>1 t) = map ((u \\\<^sub>A t) # U \<^sup>*\\\<^sub>A\<^sup>1 (t \\\<^sub>A u))" + using uU U A.Residx1_as_Resid A.Resid_rec(2) by fastforce + also have "... = F (u \\\<^sub>A t) \\<^sub>B map (U \<^sup>*\\\<^sub>A\<^sup>1 (t \\\<^sub>A u))" + by (metis A.Residx1_as_Resid A.arr_char U A.Con_imp_Arr_Resid + A.Con_rec(2) A.Resid_rec(2) list.exhaust map.simps(3) uU) + also have "... = F (u \\\<^sub>A t) \\<^sub>B map U \\\<^sub>B F (t \\\<^sub>A u)" + using uU U ind A.Con_rec(2) A.Residx1_as_Resid by force + also have "... = (F u \\\<^sub>B F t) \\<^sub>B map U \\\<^sub>B (F t \\\<^sub>B F u)" + using uU U + by (metis A.Con_initial_right A.Con_rec(1) A.Con_sym1 A.Resid1x_as_Resid' + A.Residx1_as_Resid F.preserves_resid) + also have "... = (F u \\<^sub>B map U) \\\<^sub>B F t" + by (metis B.comp_null(2) B.composable_iff_comp_not_null B.con_compI(2) B.con_sym + B.mediating_transition B.null_is_zero(2) B.resid_comp(2) B.con_def) + also have "... = map (u # U) \\\<^sub>B F t" + by (metis A.Con_implies_Arr(2) A.Con_sym A.Residx1_as_Resid U + A.arr_char map.simps(3) neq_Nil_conv uU) + finally show ?thesis by simp + qed + qed + qed + qed + + lemma preserves_resid_ind: + shows "\U. A.con T U \ map T \\<^sub>B map U \ map (T \<^sup>*\\\<^sub>A\<^sup>* U) = map T \\\<^sub>B map U" + proof (induct T) + show "\U. A.con [] U \ map [] \\<^sub>B map U \ map ([] \<^sup>*\\\<^sub>A\<^sup>* U) = map [] \\\<^sub>B map U" + using A.con_char A.Resid.simps(1) by blast + fix t T U + assume tT: "A.con (t # T) U" + assume ind: "\U. A.con T U \ + map T \\<^sub>B map U \ map (T \<^sup>*\\\<^sub>A\<^sup>* U) = map T \\\<^sub>B map U" + show "map (t # T) \\<^sub>B map U \ map ((t # T) \<^sup>*\\\<^sub>A\<^sup>* U) = map (t # T) \\\<^sub>B map U" + proof (cases "T = []") + assume T: "T = []" + show ?thesis + using T tT + apply simp + by (metis A.Resid1x_as_Resid A.Residx1_as_Resid A.con_char + A.Con_sym A.Con_sym1 map.simps(2) preserves_Resid1x_ind) + next + assume T: "T \ []" + have 1: "map (t # T) = F t \\<^sub>B map T" + using tT T + by (metis A.con_implies_arr(1) list.exhaust map.simps(3)) + show ?thesis + proof + show 2: "B.con (map (t # T)) (map U)" + using T tT + by (metis "1" A.Con_cons(1) A.Residx1_as_Resid A.con_char A.not_arr_null + A.null_char B.composable_iff_comp_not_null B.con_compI(2) B.con_sym + B.not_arr_null preserves_arr ind preserves_Residx1_ind A.con_implies_arr(1-2)) + show "map ((t # T) \<^sup>*\\\<^sub>A\<^sup>* U) = map (t # T) \\\<^sub>B map U" + proof - + have "map ((t # T) \<^sup>*\\\<^sub>A\<^sup>* U) = map (([t] \<^sup>*\\\<^sub>A\<^sup>* U) @ (T \<^sup>*\\\<^sub>A\<^sup>* (U \<^sup>*\\\<^sub>A\<^sup>* [t])))" + by (metis A.Resid.simps(1) A.Resid_cons(1) A.con_char A.ex_un_null tT) + also have "... = map ([t] \<^sup>*\\\<^sub>A\<^sup>* U) \\<^sub>B map (T \<^sup>*\\\<^sub>A\<^sup>* (U \<^sup>*\\\<^sub>A\<^sup>* [t]))" + by (metis A.Arr.simps(1) A.Con_imp_Arr_Resid A.Con_implies_Arr(2) A.Con_sym + A.Resid_cons(1-2) A.con_char T preserves_comp tT) + also have "... = (map [t] \\\<^sub>B map U) \\<^sub>B map (T \<^sup>*\\\<^sub>A\<^sup>* (U \<^sup>*\\\<^sub>A\<^sup>* [t]))" + by (metis A.Con_initial_right A.Con_sym A.Resid1x_as_Resid + A.Residx1_as_Resid A.con_char A.Con_sym1 map.simps(2) + preserves_Resid1x_ind tT) + also have "... = (map [t] \\\<^sub>B map U) \\<^sub>B (map T \\\<^sub>B map (U \<^sup>*\\\<^sub>A\<^sup>* [t]))" + using tT T ind + by (metis A.Con_cons(1) A.Con_sym A.Resid.simps(1) A.con_char) + also have "... = (map [t] \\\<^sub>B map U) \\<^sub>B (map T \\\<^sub>B (map U \\\<^sub>B map [t]))" + using tT T + by (metis A.Con_cons(1) A.Con_sym A.Resid.simps(2) A.Residx1_as_Resid + A.con_char map.simps(2) preserves_Residx1_ind) + also have "... = (F t \\\<^sub>B map U) \\<^sub>B (map T \\\<^sub>B (map U \\\<^sub>B F t))" + using tT T by simp + also have "... = map (t # T) \\\<^sub>B map U" + using 1 2 B.resid_comp(2) by presburger + finally show ?thesis by simp + qed + qed + qed + qed + + lemma preserves_con: + assumes "A.con T U" + shows "map T \\<^sub>B map U" + using assms preserves_resid_ind by simp + + lemma preserves_resid: + assumes "A.con T U" + shows "map (T \<^sup>*\\\<^sub>A\<^sup>* U) = map T \\\<^sub>B map U" + using assms preserves_resid_ind by simp + + sublocale simulation A.Resid resid\<^sub>B map + using A.con_char preserves_con preserves_resid extensional + by unfold_locales auto + + sublocale simulation_to_extensional_rts A.Resid resid\<^sub>B map .. + + lemma is_universal: + assumes "rts_with_composites resid\<^sub>B" and "simulation resid\<^sub>A resid\<^sub>B F" + shows "\!F'. simulation A.Resid resid\<^sub>B F' \ F' o A.incl = F" + proof + interpret B: rts_with_composites resid\<^sub>B + using assms by auto + interpret F: simulation resid\<^sub>A resid\<^sub>B F + using assms by auto + show "simulation A.Resid resid\<^sub>B map \ map \ A.incl = F" + using map_o_incl_eq simulation_axioms by auto + show "\F'. simulation A.Resid resid\<^sub>B F' \ F' o A.incl = F \ F' = map" + proof + fix F' T + assume F': "simulation A.Resid resid\<^sub>B F' \ F' o A.incl = F" + interpret F': simulation A.Resid resid\<^sub>B F' + using F' by simp + show "F' T = map T" + proof (induct T) + show "F' [] = map []" + by (simp add: A.arr_char F'.extensional) + fix t T + assume ind: "F' T = map T" + show "F' (t # T) = map (t # T)" + proof (cases "A.Arr (t # T)") + show "\ A.Arr (t # T) \ ?thesis" + by (simp add: A.arr_char F'.extensional extensional) + assume tT: "A.Arr (t # T)" + show ?thesis + proof (cases "T = []") + show 2: "T = [] \ ?thesis" + using F' tT by auto + assume T: "T \ []" + have "F' (t # T) = F' [t] \\<^sub>B map T" + proof - + have "F' (t # T) = F' ([t] @ T)" + by simp + also have "... = F' [t] \\<^sub>B F' T" + proof - + have "A.composite_of [t] T ([t] @ T)" + using T tT + by (metis (full_types) A.Arr.simps(2) A.Con_Arr_self + A.append_is_composite_of A.Con_implies_Arr(1) A.Con_imp_eq_Srcs + A.Con_rec(4) A.Resid_rec(1) A.Srcs_Resid A.seq_char A.R.arrI) + thus ?thesis + using F'.preserves_composites [of "[t]" T "[t] @ T"] B.comp_is_composite_of + by auto + qed + also have "... = F' [t] \\<^sub>B map T" + using T ind by simp + finally show ?thesis by simp + qed + also have "... = (F' \ A.incl) t \\<^sub>B map T" + using tT + by (simp add: A.arr_char A.null_char F'.extensional) + also have "... = F t \\<^sub>B map T" + using F' by simp + also have "... = map (t # T)" + using T tT + by (metis A.arr_char list.exhaust map.simps(3)) + finally show ?thesis by simp + qed + qed + qed + qed + qed + + end + + (* + * TODO: Localize to context rts? + *) + lemma composite_completion_of_rts: + assumes "rts A" + shows "\(C :: 'a list resid) I. rts_with_composites C \ simulation A C I \ + (\B (J :: 'a \ 'c). extensional_rts_with_composites B \ simulation A B J + \ (\!J'. simulation C B J' \ J' o I = J))" + proof (intro exI conjI) + interpret A: rts A + using assms by auto + interpret P\<^sub>A: paths_in_rts A .. + show "rts_with_composites P\<^sub>A.Resid" + using P\<^sub>A.rts_with_composites_axioms by simp + show "simulation A P\<^sub>A.Resid P\<^sub>A.incl" + using P\<^sub>A.incl_is_simulation by simp + show "\B (J :: 'a \ 'c). extensional_rts_with_composites B \ simulation A B J + \ (\!J'. simulation P\<^sub>A.Resid B J' \ J' o P\<^sub>A.incl = J)" + proof (intro allI impI) + fix B :: "'c resid" and J + assume 1: "extensional_rts_with_composites B \ simulation A B J" + interpret B: extensional_rts_with_composites B + using 1 by simp + interpret J: simulation A B J + using 1 by simp + interpret J: extension_of_simulation A B J + .. + have "simulation P\<^sub>A.Resid B J.map" + using J.simulation_axioms by simp + moreover have "J.map o P\<^sub>A.incl = J" + using J.map_o_incl_eq by auto + moreover have "\J'. simulation P\<^sub>A.Resid B J' \ J' o P\<^sub>A.incl = J \ J' = J.map" + using "1" B.rts_with_composites_axioms J.is_universal J.simulation_axioms + calculation(2) + by blast + ultimately show "\!J'. simulation P\<^sub>A.Resid B J' \ J' \ P\<^sub>A.incl = J" by auto + qed + qed + + section "Constructions on RTS's" + + subsection "Products of RTS's" + + locale product_rts = + R1: rts R1 + + R2: rts R2 + for R1 :: "'a1 resid" (infix "\\\<^sub>1" 70) + and R2 :: "'a2 resid" (infix "\\\<^sub>2" 70) + begin + + type_synonym ('aa1, 'aa2) arr = "'aa1 * 'aa2" + + abbreviation (input) Null :: "('a1, 'a2) arr" + where "Null \ (R1.null, R2.null)" + + definition resid :: "('a1, 'a2) arr \ ('a1, 'a2) arr \ ('a1, 'a2) arr" + where "resid t u = (if R1.con (fst t) (fst u) \ R2.con (snd t) (snd u) + then (fst t \\\<^sub>1 fst u, snd t \\\<^sub>2 snd u) + else Null)" + + notation resid (infix "\\" 70) + + sublocale partial_magma resid + by unfold_locales + (metis R1.con_implies_arr(1-2) R1.not_arr_null fst_conv resid_def) + + lemma is_partial_magma: + shows "partial_magma resid" + .. + + lemma null_char [simp]: + shows "null = Null" + by (metis R2.null_is_zero(1) R2.residuation_axioms ex_un_null null_is_zero(1) + resid_def residuation.conE snd_conv) + + sublocale residuation resid + proof + show "\t u. t \\ u \ null \ u \\ t \ null" + by (metis R1.con_def R1.con_sym null_char prod.inject resid_def R2.con_sym) + show "\t u. t \\ u \ null \ (t \\ u) \\ (t \\ u) \ null" + by (metis (no_types, lifting) R1.arrE R2.con_def R2.con_imp_arr_resid fst_conv null_char + resid_def R1.arr_resid snd_conv) + show "\v t u. (v \\ t) \\ (u \\ t) \ null \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + proof - + fix t u v + assume 1: "(v \\ t) \\ (u \\ t) \ null" + have "(fst v \\\<^sub>1 fst t) \\\<^sub>1 (fst u \\\<^sub>1 fst t) \ R1.null" + by (metis 1 R1.not_arr_null fst_conv null_char null_is_zero(1-2) + resid_def R1.arr_resid) + moreover have "(snd v \\\<^sub>2 snd t) \\\<^sub>2 (snd u \\\<^sub>2 snd t) \ R2.null" + by (metis 1 R2.not_arr_null snd_conv null_char null_is_zero(1-2) + resid_def R2.arr_resid) + ultimately show "(v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + using resid_def null_char R1.con_def R2.con_def R1.cube R2.cube + apply simp + by (metis (no_types, lifting) R1.conI R1.con_sym_ax R1.resid_reflects_con + R2.con_sym_ax R2.null_is_zero(1)) + qed + qed + + lemma is_residuation: + shows "residuation resid" + .. + + lemma arr_char [iff]: + shows "arr t \ R1.arr (fst t) \ R2.arr (snd t)" + by (metis (no_types, lifting) R1.arr_def R2.arr_def R2.conE null_char resid_def + residuation.arr_def residuation.con_def residuation_axioms snd_eqD) + + lemma ide_char [iff]: + shows "ide t \ R1.ide (fst t) \ R2.ide (snd t)" + by (metis (no_types, lifting) R1.residuation_axioms R2.residuation_axioms + arr_char arr_def fst_conv null_char prod.collapse resid_def residuation.conE + residuation.ide_def residuation.ide_implies_arr residuation_axioms snd_conv) + + lemma con_char [iff]: + shows "con t u \ R1.con (fst t) (fst u) \ R2.con (snd t) (snd u)" + by (simp add: R2.residuation_axioms con_def resid_def residuation.con_def) + + lemma trg_char: + shows "trg t = (if arr t then (R1.trg (fst t), R2.trg (snd t)) else Null)" + using R1.trg_def R2.trg_def resid_def trg_def by auto + + sublocale rts resid + proof + show "\t. arr t \ ide (trg t)" + by (simp add: trg_char) + show "\a t. \ide a; con t a\ \ t \\ a = t" + by (simp add: R1.resid_arr_ide R2.resid_arr_ide resid_def) + show "\a t. \ide a; con a t\ \ ide (a \\ t)" + by (metis \\t a. \ide a; con t a\ \ t \ a = t\ con_sym cube ideE ideI + residuation.con_def residuation_axioms) + show "\t u. con t u \ \a. ide a \ con a t \ con a u" + proof - + fix t u + assume tu: "con t u" + obtain a1 where a1: "a1 \ R1.sources (fst t) \ R1.sources (fst u)" + by (meson R1.con_imp_common_source all_not_in_conv con_char tu) + obtain a2 where a2: "a2 \ R2.sources (snd t) \ R2.sources (snd u)" + by (meson R2.con_imp_common_source all_not_in_conv con_char tu) + have "ide (a1, a2) \ con (a1, a2) t \ con (a1, a2) u" + using a1 a2 ide_char con_char + by (metis R1.con_imp_common_source R1.in_sourcesE R1.sources_eqI + R2.con_imp_common_source R2.in_sourcesE R2.sources_eqI con_sym + fst_conv inf_idem snd_conv tu) + thus "\a. ide a \ con a t \ con a u" by blast + qed + show "\t u v. \ide (t \\ u); con u v\ \ con (t \\ u) (v \\ u)" + proof - + fix t u v + assume tu: "ide (t \\ u)" + assume uv: "con u v" + have "R1.ide (fst t \\\<^sub>1 fst u) \ R2.ide (snd t \\\<^sub>2 snd u)" + using tu ide_char + by (metis conI con_char fst_eqD ide_implies_arr not_arr_null resid_def snd_conv) + moreover have "R1.con (fst u) (fst v) \ R2.con (snd u) (snd v)" + using uv con_char by blast + ultimately show "con (t \\ u) (v \\ u)" + by (simp add: R1.con_target R1.con_sym R1.prfx_implies_con + R2.con_target R2.con_sym R2.prfx_implies_con resid_def) + qed + qed + + lemma is_rts: + shows "rts resid" + .. + + lemma sources_char: + shows "sources t = R1.sources (fst t) \ R2.sources (snd t)" + by force + + lemma targets_char: + shows "targets t = R1.targets (fst t) \ R2.targets (snd t)" + proof + show "targets t \ R1.targets (fst t) \ R2.targets (snd t)" + using targets_def ide_char con_char resid_def trg_char trg_def by auto + show "R1.targets (fst t) \ R2.targets (snd t) \ targets t" + proof + fix a + assume a: "a \ R1.targets (fst t) \ R2.targets (snd t)" + show "a \ targets t" + proof + show "ide a" + using a ide_char by auto + show "con (trg t) a" + using a trg_char con_char [of "trg t" a] + by (metis (no_types, lifting) SigmaE arr_char con_char con_implies_arr(1) + fst_conv R1.in_targetsE R2.in_targetsE R1.arr_resid_iff_con R2.arr_resid_iff_con + R1.trg_def R2.trg_def snd_conv) + qed + qed + qed + + lemma prfx_char: + shows "prfx t u \ R1.prfx (fst t) (fst u) \ R2.prfx (snd t) (snd u)" + using R1.prfx_implies_con R2.prfx_implies_con resid_def by auto + + lemma cong_char: + shows "cong t u \ R1.cong (fst t) (fst u) \ R2.cong (snd t) (snd u)" + using prfx_char by auto + + end + + locale product_of_weakly_extensional_rts = + R1: weakly_extensional_rts R1 + + R2: weakly_extensional_rts R2 + + product_rts + begin + + sublocale weakly_extensional_rts resid + proof + show "\t u. \cong t u; ide t; ide u\ \ t = u" + by (metis cong_char ide_char prod.exhaust_sel R1.weak_extensionality R2.weak_extensionality) + qed + + lemma src_char: + shows "src t = (if arr t then (R1.src (fst t), R2.src (snd t)) else null)" + proof (cases "arr t") + show "\ arr t \ ?thesis" + using src_def by presburger + assume t: "arr t" + show ?thesis + proof (intro src_eqI) + show "ide (if arr t then (R1.src (fst t), R2.src (snd t)) else null)" + using t by simp + show "con (if arr t then (R1.src (fst t), R2.src (snd t)) else null) t" + using t con_char arr_char + apply (cases t) + apply simp_all + by (metis R1.con_imp_coinitial_ax R1.residuation_axioms R1.src_eqI R2.con_sym + R2.in_sourcesE R2.src_in_sources residuation.arr_def) + qed + qed + + end + + locale product_of_extensional_rts = + R1: extensional_rts R1 + + R2: extensional_rts R2 + + product_of_weakly_extensional_rts + begin + + sublocale extensional_rts resid + proof + show "\t u. cong t u \ t = u" + by (metis R1.extensional R2.extensional cong_char prod.collapse) + qed + + end + + subsubsection "Product Simulations" + + locale product_simulation = + A1: rts A1 + + A2: rts A2 + + B1: rts B1 + + B2: rts B2 + + A1xA2: product_rts A1 A2 + + B1xB2: product_rts B1 B2 + + F1: simulation A1 B1 F1 + + F2: simulation A2 B2 F2 + for A1 :: "'a1 resid" (infix "\\\<^sub>A\<^sub>1" 70) + and A2 :: "'a2 resid" (infix "\\\<^sub>A\<^sub>2" 70) + and B1 :: "'b1 resid" (infix "\\\<^sub>B\<^sub>1" 70) + and B2 :: "'b2 resid" (infix "\\\<^sub>B\<^sub>2" 70) + and F1 :: "'a1 \ 'b1" + and F2 :: "'a2 \ 'b2" + begin + + definition map + where "map = (\a. if A1xA2.arr a then (F1 (fst a), F2 (snd a)) else B1xB2.null)" + + lemma map_simp [simp]: + assumes "A1.arr a1" and "A2.arr a2" + shows "map (a1, a2) = (F1 a1, F2 a2)" + using assms map_def by auto + + sublocale simulation A1xA2.resid B1xB2.resid map + proof + show "\t. \ A1xA2.arr t \ map t = B1xB2.null" + using map_def by auto + show "\t u. A1xA2.con t u \ B1xB2.con (map t) (map u)" + using A1xA2.con_char B1xB2.con_char A1.con_implies_arr A2.con_implies_arr by auto + show "\t u. A1xA2.con t u \ map (A1xA2.resid t u) = B1xB2.resid (map t) (map u)" + using A1xA2.resid_def B1xB2.resid_def A1.con_implies_arr A2.con_implies_arr + by auto + qed + + lemma is_simulation: + shows "simulation A1xA2.resid B1xB2.resid map" + .. + + end + + subsubsection "Binary Simulations" + + locale binary_simulation = + A1: rts A1 + + A2: rts A2 + + A: product_rts A1 A2 + + B: rts B + + simulation A.resid B F + for A1 :: "'a1 resid" (infixr "\\\<^sub>A\<^sub>1" 70) + and A2 :: "'a2 resid" (infixr "\\\<^sub>A\<^sub>2" 70) + and B :: "'b resid" (infixr "\\\<^sub>B" 70) + and F :: "'a1 * 'a2 \ 'b" + begin + + lemma fixing_ide_gives_simulation_1: + assumes "A1.ide a1" + shows "simulation A2 B (\t2. F (a1, t2))" + proof + show "\t2. \ A2.arr t2 \ F (a1, t2) = B.null" + using assms extensional A.arr_char by simp + show "\t2 u2. A2.con t2 u2 \ B.con (F (a1, t2)) (F (a1, u2))" + using assms A.con_char preserves_con by auto + show "\t2 u2. A2.con t2 u2 \ F (a1, t2 \\\<^sub>A\<^sub>2 u2) = F (a1, t2) \\\<^sub>B F (a1, u2)" + using assms A.con_char A.resid_def preserves_resid + by (metis A1.ideE fst_conv snd_conv) + qed + + lemma fixing_ide_gives_simulation_2: + assumes "A2.ide a2" + shows "simulation A1 B (\t1. F (t1, a2))" + proof + show "\t1. \ A1.arr t1 \ F (t1, a2) = B.null" + using assms extensional A.arr_char by simp + show "\t1 u1. A1.con t1 u1 \ B.con (F (t1, a2)) (F (u1, a2))" + using assms A.con_char preserves_con by auto + show "\t1 u1. A1.con t1 u1 \ F (t1 \\\<^sub>A\<^sub>1 u1, a2) = F (t1, a2) \\\<^sub>B F (u1, a2)" + using assms A.con_char A.resid_def preserves_resid + by (metis A2.ideE fst_conv snd_conv) + qed + + end + + subsection "Sub-RTS's" + + locale sub_rts = + R: rts R + for R :: "'a resid" (infix "\\\<^sub>R" 70) + and Arr :: "'a \ bool" + + assumes inclusion: "Arr t \ R.arr t" + and sources_closed: "Arr t \ R.sources t \ Collect Arr" + and resid_closed: "\Arr t; Arr u; R.con t u\ \ Arr (t \\\<^sub>R u)" + begin + + definition resid (infix "\\" 70) + where "t \\ u \ (if Arr t \ Arr u \ R.con t u then t \\\<^sub>R u else R.null)" + + sublocale partial_magma resid + by unfold_locales + (metis R.ex_un_null R.null_is_zero(2) resid_def) + + lemma is_partial_magma: + shows "partial_magma resid" + .. + + lemma null_char [simp]: + shows "null = R.null" + by (metis R.null_is_zero(1) ex_un_null null_is_zero(1) resid_def) + + sublocale residuation resid + proof + show "\t u. t \\ u \ null \ u \\ t \ null" + by (metis R.con_sym R.con_sym_ax null_char resid_def) + show "\t u. t \\ u \ null \ (t \\ u) \\ (t \\ u) \ null" + by (metis R.arrE R.arr_resid R.not_arr_null null_char resid_closed resid_def) + show "\v t u. (v \\ t) \\ (u \\ t) \ null \ (v \\ t) \\ (u \\ t) = (v \\ u) \\ (t \\ u)" + by (metis R.cube R.ex_un_null R.null_is_zero(1) R.residuation_axioms null_is_zero(2) + resid_closed resid_def residuation.conE residuation.conI) + qed + + lemma is_residuation: + shows "residuation resid" + .. + + lemma arr_char [iff]: + shows "arr t \ Arr t" + proof + show "arr t \ Arr t" + by (metis arrE conE null_char resid_def) + show "Arr t \ arr t" + by (metis R.arrE R.conE conI con_implies_arr(2) inclusion null_char resid_def) + qed + + lemma ide_char [iff]: + shows "ide t \ Arr t \ R.ide t" + by (metis R.ide_def arrE arr_char conE ide_def null_char resid_def) + + lemma con_char [iff]: + shows "con t u \ Arr t \ Arr u \ R.con t u" + using con_def resid_def by auto + + lemma trg_char: + shows "trg t = (if arr t then R.trg t else null)" + using R.trg_def arr_def resid_def trg_def by force + + sublocale rts resid + proof + show "\t. arr t \ ide (trg t)" + by (metis R.ide_trg arrE arr_char arr_resid ide_char inclusion trg_char trg_def) + show "\a t. \ide a; con t a\ \ t \\ a = t" + by (simp add: R.resid_arr_ide resid_def) + show "\a t. \ide a; con a t\ \ ide (a \\ t)" + by (metis R.resid_ide_arr arr_resid_iff_con arr_char con_char ide_char resid_def) + show "\t u. con t u \ \a. ide a \ con a t \ con a u" + by (metis (full_types) R.con_imp_coinitial_ax R.con_sym R.in_sourcesI + con_char ide_char in_mono mem_Collect_eq sources_closed) + show "\t u v. \ide (t \\ u); con u v\ \ con (t \\ u) (v \\ u)" + by (metis R.con_target arr_resid_iff_con con_char con_sym ide_char + ide_implies_arr resid_closed resid_def) + qed + + lemma is_rts: + shows "rts resid" + .. + + lemma sources_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S: + shows "sources t = {a. Arr t \ a \ R.sources t}" + using sources_closed by auto + + lemma targets_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S: + shows "targets t = {b. Arr t \ b \ R.targets t}" + proof + show "targets t \ {b. Arr t \ b \ R.targets t}" + proof + fix b + assume b: "b \ targets t" + show "b \ {b. Arr t \ b \ R.targets t}" + proof + have "Arr t" + using arr_iff_has_target b by force + moreover have "Arr b" + using b by blast + moreover have "b \ R.targets t" + by (metis R.in_targetsI b calculation(1) con_char in_targetsE + arr_char ide_char trg_char) + ultimately show "Arr t \ b \ R.targets t" by blast + qed + qed + show "{b. Arr t \ b \ R.targets t} \ targets t" + proof + fix b + assume b: "b \ {b. Arr t \ b \ R.targets t}" + show "b \ targets t" + proof (intro in_targetsI) + show "ide b" + using b + by (metis R.arrE ide_char inclusion mem_Collect_eq R.sources_resid + R.target_is_ide resid_closed sources_closed subset_eq) + show "con (trg t) b" + using b + using \ide b\ ide_trg trg_char by auto + qed + qed + qed + + lemma prfx_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S: + shows "prfx t u \ Arr t \ Arr u \ R.prfx t u" + by (metis R.prfx_implies_con con_char ide_char prfx_implies_con resid_closed resid_def) + + lemma cong_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S: + shows "cong t u \ Arr t \ Arr u \ R.cong t u" + using prfx_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S by force + + lemma inclusion_is_simulation: + shows "simulation resid R (\t. if arr t then t else null)" + using resid_closed resid_def + by unfold_locales auto + + interpretation P\<^sub>R: paths_in_rts R + .. + interpretation P: paths_in_rts resid + .. + + lemma path_reflection: + shows "\P\<^sub>R.Arr T; set T \ Collect Arr\ \ P.Arr T" + apply (induct T) + apply simp + proof - + fix t T + assume ind: "\P\<^sub>R.Arr T; set T \ Collect Arr\ \ P.Arr T" + assume tT: "P\<^sub>R.Arr (t # T)" + assume set: "set (t # T) \ Collect Arr" + have 1: "R.arr t" + using tT + by (metis P\<^sub>R.Arr_imp_arr_hd list.sel(1)) + show "P.Arr (t # T)" + proof (cases "T = []") + show "T = [] \ ?thesis" + using 1 set by simp + assume T: "T \ []" + show ?thesis + proof + show "arr t" + using 1 arr_char set by simp + show "P.Arr T" + using T tT P\<^sub>R.Arr_imp_Arr_tl + by (metis ind insert_subset list.sel(3) list.simps(15) set) + show "targets t \ P.Srcs T" + proof - + have "targets t \ R.targets t" + using targets_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S by blast + also have "... \ R.sources (hd T)" + using T tT + by (metis P\<^sub>R.Arr.simps(3) P\<^sub>R.Srcs_simp\<^sub>P list.collapse) + also have "... \ P.Srcs T" + using P.Arr_imp_arr_hd P.Srcs_simp\<^sub>P \P.Arr T\ sources_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S by force + finally show ?thesis by blast + qed + qed + qed + qed + + end + + locale sub_weakly_extensional_rts = + sub_rts + + R: weakly_extensional_rts R + begin + + sublocale weakly_extensional_rts resid + apply unfold_locales + using R.weak_extensionality cong_char\<^sub>S\<^sub>R\<^sub>T\<^sub>S + by blast + + lemma is_weakly_extensional_rts: + shows "weakly_extensional_rts resid" + .. + + lemma src_char: + shows "src t = (if arr t then R.src t else null)" + proof (cases "arr t") + show "\ arr t \ ?thesis" + by (simp add: src_def) + assume t: "arr t" + show ?thesis + proof (intro src_eqI) + show "ide (if arr t then R.src t else null)" + using t sources_closed inclusion R.src_in_sources by auto + show "con (if arr t then R.src t else null) t" + using t con_char + by (metis (full_types) R.con_sym R.in_sourcesE R.src_in_sources + \ide (if arr t then R.src t else null)\ arr_char ide_char inclusion) + qed + qed + + end + + text \ + Here we justify the terminology ``normal sub-RTS'', which was introduced earlier, + by showing that a normal sub-RTS really is a sub-RTS. + \ + + lemma (in normal_sub_rts) is_sub_rts: + shows "sub_rts resid (\t. t \ \)" + using elements_are_arr ide_closed + apply unfold_locales + apply auto[2] + by (meson R.con_imp_coinitial R.con_sym forward_stable) + +end diff --git a/thys/ResiduatedTransitionSystem/document/root.bib b/thys/ResiduatedTransitionSystem/document/root.bib new file mode 100644 --- /dev/null +++ b/thys/ResiduatedTransitionSystem/document/root.bib @@ -0,0 +1,91 @@ +@article{Category3-AFP, + author = {Eugene W. Stark}, + title = {Category Theory with Adjunctions and Limits}, + journal = {Archive of Formal Proofs}, + month = jun, + year = 2016, + note = {\url{http://isa-afp.org/entries/Category3.shtml}, Formal proof development}, + ISSN = {2150-914x}, +} +@article{cts, + author = "E. W. Stark", + title = "Concurrent Transition Systems", + journal = "Theoretical Computer Science", + volume = 64, + month = JUL, + pages = "221--269", + year = 1989 +} +@article{huet-residual-theory, + author = "G. Huet", + title = "Residual theory in \lambda-calculus: A formal development", + journal = "Journal of Functional Programming", + volume = 4, + number = 3, + pages = "371--394", + year = 1994 +} +@book{barendregt, + author = "H. Barendregt", + title = "The Lambda-calculus: Its Syntax and Semantics", + year = 1984, + publisher = "North-Holland" +} +@phdthesis{levy, + author = "J.-J. Lévy", + title = "Réductions correctes et optimales dans le \lambda-calcul", + school = "U. Paris VII", + year = 1978, + note = "Th\`ese d'Etat" +} +@phdthesis{schroer, + author = "D. E. Schroer", + title = "The Church-Rosser Theorem", + school = "Cornell University", + year = 1965 +} +@article{deBruijn, + author = "N. G. {de Bruijn}", + title = "Lambda-Calculus notation with nameless dummies, a tool for automatic + formula manipulation, with application to the Church-Rosser theorem", + journal = {Indagationes Mathematicae (Proceedings)}, + volume = 34, + number = 5, + pages = "381--392", + year = 1972 +} +@article{deVrijer, + author = "R. {de Vrijer}", + title = "A Direct Proof of the Finite Developments Theorem", + volume = "50", + number = "2", + month = JUN, + year = 1985, + pages = "339--343", + journal = "The Journal of Symbolic Logic" +} +@article{hindley, + author = "R. Hindley", + title = "Reductions of Residuals are Finite", + volume = 240, + year = 1978, + month = JUN, + pages = "345--361", + journal = "Transactions of the American Mathematical Society" +} +@book{curry-and-feys, + author = "H. B. Curry and R. Feys", + title = "Combinatory Logic", + volume = 1, + year = 1958, + publisher = "North-Holland" +} +@mastersthesis{copes, + author = "M. Copes", + title = "A machine-checked proof of the Standardization Theorem in Lambda Calculus + using multiple substitution", + school = "Universidad ORT Uruguay", + year = 2018, + note = {\url{https://dspace.ort.edu.uy/bitstream/handle/20.500.11968/3725/Material%20completo.pdf}}, +} + diff --git a/thys/ResiduatedTransitionSystem/document/root.tex b/thys/ResiduatedTransitionSystem/document/root.tex new file mode 100644 --- /dev/null +++ b/thys/ResiduatedTransitionSystem/document/root.tex @@ -0,0 +1,241 @@ +\documentclass[11pt,notitlepage,a4paper]{report} +\usepackage[T1]{fontenc} +\usepackage{isabelle,isabellesym,eufrak} +\usepackage{amssymb,amsmath} +\usepackage[english]{babel} + +% this should be the last package used +\usepackage{pdfsetup} + +% urls in roman style, theory text in math-similar italics +\urlstyle{rm} +\isabellestyle{it} + +% Even though I stayed within the default boundary in the JEdit buffer, +% some proof lines wrap around in the PDF document. To minimize this, +% increase the text width a bit from the default. +\addtolength\textwidth{60pt} +\addtolength\oddsidemargin{-30pt} +\addtolength\evensidemargin{-30pt} + +\newcommand\after{\backslash} + +\begin{document} + +\title{Residuated Transition Systems} +\author{Eugene W. Stark\\[\medskipamount] + Department of Computer Science\\ + Stony Brook University\\ + Stony Brook, New York 11794 USA} +\maketitle + +\begin{abstract} +A \emph{residuated transition system} (RTS) is a transition system that is equipped with a +certain partial binary operation, called \emph{residuation}, on transitions. +Using the residuation operation, one can express nuances, such as a distinction +between nondeterministic and concurrent choice, as well as partial commutativity +relationships between transitions, which are not captured by ordinary transition systems. +A version of residuated transition systems was introduced by the author in \cite{cts}, +where they were called ``concurrent transition systems'' in view of the original +motivation for their definition from the study of concurrency. +In the first part of the present article, we give a formal development that generalizes +and subsumes the original presentation. We give an axiomatic definition of residuated transition +systems that assumes only a single partial binary operation as given structure. +From the axioms, we derive notions of ``arrow'' (transition), ``source'', ``target'', ``identity'', +as well as ``composition'' and ``join'' of transitions; thereby recovering structure that in the +previous work was assumed as given. We formalize and generalize the result, that residuation +extends from transitions to transition paths, and we systematically develop the properties of +this extension. A significant generalization made in the present work is the identification of a +general notion of congruence on RTS's, along with an associated quotient construction. + +In the second part of this article, we use the RTS framework to formalize several results in +the theory of reduction in Church's $\lambda$-calculus. Using a de Bruijn index-based syntax +in which terms represent parallel reduction steps, we define residuation on terms and show that +it satisfies the axioms for an RTS. An application of the results on paths from the +first part of the article allows us to prove the classical Church-Rosser Theorem with little +additional effort. We then use residuation to define the notion of ``development'' +and we prove the Finite Developments Theorem, that every development is finite, +formalizing and adapting to de Bruijn indices a proof by de Vrijer. +We also use residuation to define the notion of a ``standard reduction path'', and we prove +the Standardization Theorem: that every reduction path is congruent to a standard one. +As a corollary of the Standardization Theorem, we obtain the Leftmost Reduction Theorem: +that leftmost reduction is a normalizing strategy. +\end{abstract} + +\tableofcontents + +\chapter{Introduction} + +A {\em transition system} is a graph used to represent the dynamics of a computational +process. It consists simply of nodes, called {\em states}, and edges, called {\em transitions}. +Paths through a transition system correspond to possible computations. +A {\em residuated transition system} is a transition system that is equipped with a +partial binary operation, called {\em residuation}, on transitions, subject to certain axioms. +Among other things, these axioms imply that if residuation is defined for transitions +$t$ and $u$, then $t$ and $u$ must be {\em coinitial}; that is, they must have a common +source state. +If the residuation is defined for coinitial transitions $t$ and $u$, then we regard +transitions $t$ and $u$ as {\em consistent}, otherwise they are {\em in conflict}. +The residuation $t \after u$ of $t$ along $u$ can be thought of as what remains of transition $t$ +after the portion that it has in common with $u$ has been cancelled. + +A version of residuated transition systems was introduced in \cite{cts}, where I called them +``concurrent transition systems'', because my motivation for the definition was to be +able to have a way of representing information about concurrency and nondeterministic choice. +Indeed, transitions that are in conflict can be thought of as representing a nondeterministic +choice between steps that cannot occur in a single computation, whereas consistent transitions +represent steps that can so occur and are therefore in some sense concurrent with each other. +Whereas performing a product construction on ordinary transition system results in a +transition system that records no information about commutativity of concurrent steps, +with residuated transition systems the residuation operation makes it possible to represent +such information. + +In \cite{cts}, concurrent transition systems were defined in terms of graphs, consisting +of states, transitions, and a pair of functions that assign to each transition a {\em source} +(or domain) state and a {\em target} (or codomain) state. In addition, the presence of +transitions that are {\em identities} for the residuation was assumed. +Identity transitions had the same source and target state, and they could be thought of as +representing empty computational steps. +The key axiom for concurrent transition systems is the ``cube axiom'', which +is a parallel moves property stating that the same result is achieved when transporting a +transition by residuation along the two paths from the base to the apex of a ``commuting diamond''. +Using the residuation operation and the associated cube axiom, it becomes possible to define +notions of ``join'' and ``composition'' of transitions. +The residuation also induces a notion of congruence of transitions; namely, transitions +$t$ and $u$ are congruent whenever they are coinitial and both $t \after u$ and $u \after t$ +are identities. +In \cite{cts}, the basic definition of concurrent transition system included an axiom, +called ``extensionality'', which states that the congruence relation is trivial +({\em i.e.}~coincides with equality). An advantage of the extensionality axiom is that, +in its presence, joins and composites of transitions are uniquely defined when they exist. +It was shown in \cite{cts} that a concurrent transition system could always be quotiented +by congruence to achieve extensionality. + +A focus of the basic theory developed in \cite{cts} was to show that the residuation +operation $\after$ on individual transitions extended in a natural way to a residuation +operation $\after^\ast$ on paths, so that a concurrent transition system could be completed +to one having a composite for each ``composable'' pair of transitions. The construction +involved quotienting by the congruence on paths obtained by declaring paths $T$ and $U$ +to be congruent if they are coinitial and both $T \after^\ast U$ and $U \after^\ast T$ +are paths consisting ony of identities. Besides collapsing paths of identities, this +congruence reflects permutation relations induced by the residuation. In particular, +if $t$ and $u$ are consistent, then the paths $t (u \after t)$ and $u (t \after u)$ +are congruent. + +Imposing the extensionality requirement as part of the basic definition of concurrent +transition systems does not end up being particularly desirable, since natural examples +of situations where there is a residuation on transitions (such as on reductions in +the $\lambda$-calculus) often do not naturally satisfy the extensionality condition +and can only be made to do so if a quotient construction is applied. +Also, the treatment of identity transitions and quotienting in \cite{cts} was not entirely +satisfactory. The definition of ``strong congruence'' given there was somewhat awkward +and basically existed to capture the specific congruence that was induced on paths +by the underlying residuation. It was clear that a more general quotient construction +ought to be possible than the one used in \cite{cts}, but it was not clear what the right +general definition ought to be. + +In the present article we revisit the notion of transition systems equipped with a +residuation operation, with the idea of developing a more general theory that does not +require the assumption of extensionality as part of the basic axioms, and of clarifying +the general notion of congruence that applies to such structures. +We use the term ``residuated transition systems'' to refer to the more general structures +defined here, as the name is perhaps more suggestive of what the theory is about and +it does not seem to limit the interpretation of the residuation operation only to settings +that have something to do with concurrency. + +Rather than starting out by assuming source, target, and identities as basic structure, +here we develop residuated transition systems purely as a theory about a partial binary +operation (residuation) that is subject to certain axioms. The axioms will allow us to +introduce sources, targets, and identities as defined notions, and we will be able to +recover the properties of this additional structure that in \cite{cts} were taken as +axiomatic. This idea of defining residuated transition systems purely in terms of +a partial binary operation of residuation is similar to the approach taken in +\cite{Category3-AFP}, where we formalized categories purely in terms of a partial binary +operation of composition. + +This article comprises two parts. In the first part, we give the definition of +residuated transition systems and systematically develop the basic theory. +We show how sources, composites, and identities can be defined in terms of the residuation +operation. We also show how residuation can be used to define the notions of join +and composite of transitions, as well as the simple notion of congruence that relates +transitions $t$ and $u$ whenever both $t \after u$ and $u \after t$ are identities. +We then present a much more general notion of congruence, based a definition of +``coherent normal sub-RTS'', which abstracts the properties enjoyed by the sub-RTS of +identity transitions. After defining this general notion of congruence, we show that +it admits a quotient construction, which yields a quotient RTS having the extensionality +property. +After studying congruences and quotients, we consider paths in an RTS, represented +as nonempty lists of transitions whose sources and targets match up in the expected +``domino fashion''. +We show that the residuation operation of an RTS lifts to a residuation on its paths, +yielding an ``RTS of paths'' in which composites of paths are given by list concatenation. +The collection of paths that consist entirely of identity transitions is then shown to form +a coherent normal sub-RTS of the RTS of paths. The associated congruence on paths +can be seen as ``permutation congruence'': the least congruence respecting composition +that relates the two-element lists $[t, t\after u]$ and $[u, u\after t]$ whenever +$t$ and $u$ are consistent, and that relates $[t, b]$ and $[t]$ whenever $b$ is an +identity transition that is a target of $t$. +Quotienting by the associated congruence results in a free ``composite completion'' of +the original RTS. The composite completion has a composite for each pair of ``composable'' +transitions, and it will in general exhibit nontrivial equations between composites, +as a result of the congruence induced on paths by the underlying residuation. +In summary, the first part of this article can be seen as a significant generalization +and more satisfactory development of the results originally presented in \cite{cts}. + +The second part of this article applies the formal framework developed in the first part +to prove various results about reduction in Church's $\lambda$-calculus. +Although many of these results have had machine-checked proofs given by other authors +(\emph{e.g.}~the basic formalization of residuation in the $\lambda$-calculus given +by Huet \cite{huet-residual-theory}), the presentation here develops a number of such +results in a single formal framework: that of residuated transition systems. +For the presentation of the $\lambda$-calculus given here we employ (as was also done in +\cite{huet-residual-theory}) the device of de Bruijn indices \cite{deBruijn}, in order +to avoid having to treat the issue of $\alpha$-convertibility. +The terms in our syntax represent reductions in which multiple redexes are contracted +in parallel; this is done to deal with the well-known fact that contractions of single +redexes are not preserved by residuation, in general. +We treat only $\beta$-reduction here; leaving the extension to the $\beta\eta$-calculus +for future work. +We define residuation on terms essentially as is done in \cite{huet-residual-theory} and we develop +a similar series of lemmas concerning residuation, substitution, and de Bruijn indices, +culminating in L\'{e}vy's ``Cube Lemma'' \cite{levy}, which is the key property needed +to show that a residuated transition system is obtained. +In this residuated transition system, the identities correspond to the usual $\lambda$-terms, +and transitions correspond to parallel reductions, represented by $\lambda$-terms with +``marked redexes''. The source of a transition is obtained by erasing the markings on +the redexes; the target is obtained by contracting all the marked redexes. + +Once having obtained an RTS whose transitions represent parallel reductions, +we exploit the general results proved in the first part of this article to extend the +residuation to sequences of reductions. It is then possible to prove the Church-Rosser +Theorem with very little additional effort. After that, we turn our attention to the notion +of a ``development'', which is a reduction sequence in which the only redexes contracted +are those that are residuals of redexes in some originally marked set. +We give a formal proof of the Finite Developments Theorem (\cite{schroer, hindley}), +which states that all developments are finite. +The proof here follows the one by de Vrijer \cite{deVrijer}, with the difference that here we +are using de Bruijn indices, whereas de Vrijer used a classical $\lambda$-calculus syntax. +The modifications of de Vrijer's proof required for de Bruijn indices were not entirely +straightforward to find. +We then proceed to define the notion of ``standard reduction path'', which is a reduction +sequence that in some sense contracts redexes in a left-to-right fashion, perhaps with +some jumps. We give a formal proof of the Standardization Theorem (\cite{curry-and-feys}), +stated in the strong form which asserts that every reduction is permutation congruent to +a standard reduction. The proof presented here proceeds by stating and proving correct +the definition of a recursive function that transforms a given path of parallel reductions +into a standard reduction path, using a technique roughly analogous to insertion sort. +Finally, as a corollary of the Standardization Theorem, we prove the Leftmost Reduction +Theorem, which is the well-known result that the leftmost (or normal-order) reduction +strategy is normalizing. + +% include generated text of all theories +\input{session} + +\clearpage +\phantomsection +\addcontentsline{toc}{chapter}{Bibliography} + +\bibliographystyle{abbrv} +\bibliography{root} + +\end{document} diff --git a/web/entries/ResiduatedTransitionSystem.html b/web/entries/ResiduatedTransitionSystem.html new file mode 100644 --- /dev/null +++ b/web/entries/ResiduatedTransitionSystem.html @@ -0,0 +1,219 @@ + + + + +Residuated Transition Systems - Archive of Formal Proofs + + + + + + + + + + + + + + + + + + + + + + + + +
+

 

+ + + +

 

+

 

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

 

+

 

+
+
+

 

+

Residuated + + Transition + + Systems + +

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:Residuated Transition Systems
+ Author: + + Eugene W. Stark (stark /at/ cs /dot/ stonybrook /dot/ edu) +
Submission date:2022-02-28
Abstract: +

A residuated transition system (RTS) is +a transition system that is equipped with a certain partial binary +operation, called residuation, on transitions. +Using the residuation operation, one can express nuances, such as a +distinction between nondeterministic and concurrent choice, as well as +partial commutativity relationships between transitions, which are not +captured by ordinary transition systems. A version of residuated +transition systems was introduced in previous work by the author, in +which they were called “concurrent transition systems” in view of the +original motivation for their definition from the study of +concurrency. In the first part of the present article, we give a +formal development that generalizes and subsumes the original +presentation. We give an axiomatic definition of residuated transition +systems that assumes only a single partial binary operation as given +structure. From the axioms, we derive notions of “arrow“ (transition), +“source”, “target”, “identity”, as well as “composition” and “join” of +transitions; thereby recovering structure that in the previous work +was assumed as given. We formalize and generalize the result, that +residuation extends from transitions to transition paths, and we +systematically develop the properties of this extension. A significant +generalization made in the present work is the identification of a +general notion of congruence on RTS’s, along with an associated +quotient construction.

In the second part of this +article, we use the RTS framework to formalize several results in the +theory of reduction in Church’s λ-calculus. Using a de Bruijn +index-based syntax in which terms represent parallel reduction steps, +we define residuation on terms and show that it satisfies the axioms +for an RTS. An application of the results on paths from the first part +of the article allows us to prove the classical Church-Rosser Theorem +with little additional effort. We then use residuation to define the +notion of “development” and we prove the Finite Developments Theorem, +that every development is finite, formalizing and adapting to de +Bruijn indices a proof by de Vrijer. We also use residuation to define +the notion of a “standard reduction path”, and we prove the +Standardization Theorem: that every reduction path is congruent to a +standard one. As a corollary of the Standardization Theorem, we obtain +the Leftmost Reduction Theorem: that leftmost reduction is a +normalizing strategy.

BibTeX: +
@article{ResiduatedTransitionSystem-AFP,
+  author  = {Eugene W. Stark},
+  title   = {Residuated Transition Systems},
+  journal = {Archive of Formal Proofs},
+  month   = feb,
+  year    = 2022,
+  note    = {\url{https://isa-afp.org/entries/ResiduatedTransitionSystem.html},
+            Formal proof development},
+  ISSN    = {2150-914x},
+}
+
License:BSD License
+ +

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + \ 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,6092 +1,6100 @@ 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.

 

 

+ + +
2022
2022-03-03: Transitive Models of Fragments of ZFC
Authors: Emmanuel Gunther, Miguel Pagano, Pedro Sánchez Terraf and and Matías Steinberg
+ 2022-02-28: Residuated Transition Systems +
+ Author: + Eugene W. Stark +
2022-02-20: Universal Hash Families
Author: Emin Karayel
2022-02-18: Wetzel's Problem and the Continuum Hypothesis
Author: Lawrence C Paulson
2022-02-15: First-Order Query Evaluation
Author: Martin Raszyk
2022-02-13: Multi-Head Monitoring of Metric Dynamic Logic
Author: Martin Raszyk
2022-02-04: Enumeration of Equivalence Relations
Author: Emin Karayel
2022-02-03: Quasi-Borel Spaces
Authors: Michikazu Hirata, Yasuhiko Minamide and Tetsuya Sato
2022-02-03: Duality of Linear Programming
Author: René Thiemann
2022-02-02: First-Order Theory of Rewriting
Authors: Alexander Lochmann and Bertram Felgenhauer
2022-01-31: Young's Inequality for Increasing Functions
Author: Lawrence C Paulson
2022-01-31: A Sequent Calculus Prover for First-Order Logic with Functions
Authors: Asta Halkjær From and Frederik Krogsdal Jacobsen
2022-01-29: Interpolation Polynomials (in HOL-Algebra)
Author: Emin Karayel
2022-01-25: Median Method
Author: Emin Karayel
2022-01-23: Actuarial Mathematics
Author: Yosuke Ito
2022-01-08: Irrational numbers from THE BOOK
Author: Lawrence C Paulson
2022-01-04: Knight's Tour Revisited Revisited
Author: Lukas Koller

 

2021
2021-12-31: Hyperdual Numbers and Forward Differentiation
Authors: Filip Smola and Jacques Fleuriot
2021-12-29: Gale-Shapley Algorithm
Author: Tobias Nipkow
2021-12-28: Roth's Theorem on Arithmetic Progressions
Authors: Chelsea Edmonds, Angeliki Koutsoukou-Argyraki and Lawrence C. Paulson
2021-12-16: Markov Decision Processes with Rewards
Authors: Maximilian Schäffeler and Mohammad Abdulaziz
2021-12-16: Verified Algorithms for Solving Markov Decision Processes
Authors: Maximilian Schäffeler and Mohammad Abdulaziz
2021-12-15: Regular Tree Relations
Authors: Alexander Lochmann, Bertram Felgenhauer, Christian Sternagel, René Thiemann and Thomas Sternagel
2021-11-29: Simplicial Complexes and Boolean functions
Authors: Jesús Aransay, Alejandro del Campo and Julius Michaelis
2021-11-23: van Emde Boas Trees
Authors: Thomas Ammer and Peter Lammich
2021-11-22: Foundation of geometry in planes, and some complements: Excluding the parallel axioms
Author: Fumiya Iwama
2021-11-19: The Hahn and Jordan Decomposition Theorems
Authors: Marie Cousin, Mnacho Echenim and Hervé Guiol
2021-11-08: Exploring Simplified Variants of Gödel’s Ontological Argument in Isabelle/HOL
Author: Christoph Benzmüller
2021-11-08: Real Exponents as the Limits of Sequences of Rational Exponents
Author: Jacques D. Fleuriot
2021-11-08: Automating Public Announcement Logic and the Wise Men Puzzle in Isabelle/HOL
Authors: Christoph Benzmüller and Sebastian Reiche
2021-11-08: Factorization of Polynomials with Algebraic Coefficients
Authors: Manuel Eberl and René Thiemann
2021-11-05: Szemerédi's Regularity Lemma
Authors: Chelsea Edmonds, Angeliki Koutsoukou-Argyraki and Lawrence C. Paulson
2021-10-28: Quantum and Classical Registers
Author: Dominique Unruh
2021-10-19: Belief Revision Theory
Authors: Valentin Fouillard, Safouan Taha, Frédéric Boulanger and Nicolas Sabouret
2021-10-13: X86 instruction semantics and basic block symbolic execution
Authors: Freek Verbeek, Abhijith Bharadwaj, Joshua Bockenek, Ian Roessle, Timmy Weerwag and Binoy Ravindran
2021-10-12: Algebras for Iteration, Infinite Executions and Correctness of Sequential Computations
Author: Walter Guttmann
2021-10-02: Verified Quadratic Virtual Substitution for Real Arithmetic
Authors: Matias Scharager, Katherine Cordwell, Stefan Mitsch and André Platzer
2021-09-24: Soundness and Completeness of an Axiomatic System for First-Order Logic
Author: Asta Halkjær From
2021-09-18: Complex Bounded Operators
Authors: Jose Manuel Rodriguez Caballero and Dominique Unruh
2021-09-16: A Formalization of Weighted Path Orders and Recursive Path Orders
Authors: Christian Sternagel, René Thiemann and Akihisa Yamada
2021-09-06: Extension of Types-To-Sets
Author: Mihails Milehins
2021-09-06: IDE: Introduction, Destruction, Elimination
Author: Mihails Milehins
2021-09-06: Conditional Transfer Rule
Author: Mihails Milehins
2021-09-06: Conditional Simplification
Author: Mihails Milehins
2021-09-06: Category Theory for ZFC in HOL III: Universal Constructions
Author: Mihails Milehins
2021-09-06: Category Theory for ZFC in HOL I: Foundations: Design Patterns, Set Theory, Digraphs, Semicategories
Author: Mihails Milehins
2021-09-06: Category Theory for ZFC in HOL II: Elementary Theory of 1-Categories
Author: Mihails Milehins
2021-09-05: A data flow analysis algorithm for computing dominators
Author: Nan Jiang
2021-09-03: Solving Cubic and Quartic Equations
Author: René Thiemann
2021-08-26: Logging-independent Message Anonymity in the Relational Method
Author: Pasquale Noce
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-27: Schutz' Independent Axioms for Minkowski Spacetime
Authors: Richard Schmoetten, Jake Palmer and Jacques Fleuriot
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
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,652 +1,680 @@ 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. 03 Mar 2022 00:00:00 +0000 Transitive Models of Fragments of ZFC https://www.isa-afp.org/entries/Transitive_Models.html https://www.isa-afp.org/entries/Transitive_Models.html Emmanuel Gunther, Miguel Pagano, Pedro Sánchez Terraf, and Matías Steinberg 03 Mar 2022 00:00:00 +0000 We extend the ZF-Constructibility library by relativizing theories of the Isabelle/ZF and Delta System Lemma sessions to a transitive class. We also relativize Paulson's work on Aleph and our former treatment of the Axiom of Dependent Choices. This work is a prerrequisite to our formalization of the independence of the Continuum Hypothesis. + Residuated Transition Systems + https://www.isa-afp.org/entries/ResiduatedTransitionSystem.html + https://www.isa-afp.org/entries/ResiduatedTransitionSystem.html + Eugene W. Stark + 28 Feb 2022 00:00:00 +0000 + +<p> A <em>residuated transition system</em> (RTS) is +a transition system that is equipped with a certain partial binary +operation, called <em>residuation</em>, on transitions. +Using the residuation operation, one can express nuances, such as a +distinction between nondeterministic and concurrent choice, as well as +partial commutativity relationships between transitions, which are not +captured by ordinary transition systems. A version of residuated +transition systems was introduced in previous work by the author, in +which they were called “concurrent transition systems” in view of the +original motivation for their definition from the study of +concurrency. In the first part of the present article, we give a +formal development that generalizes and subsumes the original +presentation. We give an axiomatic definition of residuated transition +systems that assumes only a single partial binary operation as given +structure. From the axioms, we derive notions of “arrow“ (transition), +“source”, “target”, “identity”, as well as “composition” and “join” of +transitions; thereby recovering structure that in the previous work +was assumed as given. We formalize and generalize the result, that +residuation extends from transitions to transition paths, and we +systematically develop the properties of this extension. A significant +generalization made in the present work is the identification of a +general notion of congruence on RTS’s, along with an associated +quotient construction. </p> <p> In the second part of this +article, we use the RTS framework to formalize several results in the +theory of reduction in Church’s λ-calculus. Using a de Bruijn +index-based syntax in which terms represent parallel reduction steps, +we define residuation on terms and show that it satisfies the axioms +for an RTS. An application of the results on paths from the first part +of the article allows us to prove the classical Church-Rosser Theorem +with little additional effort. We then use residuation to define the +notion of “development” and we prove the Finite Developments Theorem, +that every development is finite, formalizing and adapting to de +Bruijn indices a proof by de Vrijer. We also use residuation to define +the notion of a “standard reduction path”, and we prove the +Standardization Theorem: that every reduction path is congruent to a +standard one. As a corollary of the Standardization Theorem, we obtain +the Leftmost Reduction Theorem: that leftmost reduction is a +normalizing strategy. </p> + + Universal Hash Families https://www.isa-afp.org/entries/Universal_Hash_Families.html https://www.isa-afp.org/entries/Universal_Hash_Families.html Emin Karayel 20 Feb 2022 00:00:00 +0000 A <i>k</i>-universal hash family is a probability space of functions, which have uniform distribution and form <i>k</i>-wise independent random variables. They can often be used in place of classic (or cryptographic) hash functions and allow the rigorous analysis of the performance of randomized algorithms and data structures that rely on hash functions. In 1981 <a href="https://doi.org/10.1016/0022-0000(81)90033-7">Wegman and Carter</a> introduced a generic construction for such families with arbitrary <i>k</i> using polynomials over a finite field. This entry contains a formalization of them and establishes the property of <i>k</i>-universality. To be useful the formalization also provides an explicit construction of finite fields using the factor ring of integers modulo a prime. Additionally, some generic results about independent families are shown that might be of independent interest. Wetzel's Problem and the Continuum Hypothesis https://www.isa-afp.org/entries/Wetzels_Problem.html https://www.isa-afp.org/entries/Wetzels_Problem.html Lawrence C Paulson 18 Feb 2022 00:00:00 +0000 Let $F$ be a set of analytic functions on the complex plane such that, for each $z\in\mathbb{C}$, the set $\{f(z) \mid f\in F\}$ is countable; must then $F$ itself be countable? The answer is yes if the Continuum Hypothesis is false, i.e., if the cardinality of $\mathbb{R}$ exceeds $\aleph_1$. But if CH is true then such an $F$, of cardinality $\aleph_1$, can be constructed by transfinite recursion. The formal proof illustrates reasoning about complex analysis (analytic and homomorphic functions) and set theory (transfinite cardinalities) in a single setting. The mathematical text comes from <em>Proofs from THE BOOK</em> by Aigner and Ziegler. First-Order Query Evaluation https://www.isa-afp.org/entries/Eval_FO.html https://www.isa-afp.org/entries/Eval_FO.html Martin Raszyk 15 Feb 2022 00:00:00 +0000 We formalize first-order query evaluation over an infinite domain with equality. We first define the syntax and semantics of first-order logic with equality. Next we define a locale <i>eval&lowbar;fo</i> abstracting a representation of a potentially infinite set of tuples satisfying a first-order query over finite relations. Inside the locale, we define a function <i>eval</i> checking if the set of tuples satisfying a first-order query over a database (an interpretation of the query's predicates) is finite (i.e., deciding <i>relative safety</i>) and computing the set of satisfying tuples if it is finite. Altogether the function <i>eval</i> solves <i>capturability</i> (Avron and Hirshfeld, 1991) of first-order logic with equality. We also use the function <i>eval</i> to prove a code equation for the semantics of first-order logic, i.e., the function checking if a first-order query over a database is satisfied by a variable assignment.<br/> We provide an interpretation of the locale <i>eval&lowbar;fo</i> based on the approach by Ailamazyan et al. A core notion in the interpretation is the active domain of a query and a database that contains all domain elements that occur in the database or interpret the query's constants. We prove the main theorem of Ailamazyan et al. relating the satisfaction of a first-order query over an infinite domain to the satisfaction of this query over a finite domain consisting of the active domain and a few additional domain elements (outside the active domain) whose number only depends on the query. In our interpretation of the locale <i>eval&lowbar;fo</i>, we use a potentially higher number of the additional domain elements, but their number still only depends on the query and thus has no effect on the data complexity (Vardi, 1982) of query evaluation. Our interpretation yields an <i>executable</i> function <i>eval</i>. The time complexity of <i>eval</i> on a query is linear in the total number of tuples in the intermediate relations for the subqueries. Specifically, we build a database index to evaluate a conjunction. We also optimize the case of a negated subquery in a conjunction. Finally, we export code for the infinite domain of natural numbers. Multi-Head Monitoring of Metric Dynamic Logic https://www.isa-afp.org/entries/VYDRA_MDL.html https://www.isa-afp.org/entries/VYDRA_MDL.html Martin Raszyk 13 Feb 2022 00:00:00 +0000 Runtime monitoring (or runtime verification) is an approach to checking compliance of a system's execution with a specification (e.g., a temporal query). The system's execution is logged into a trace---a sequence of time-points, each consisting of a time-stamp and observed events. A monitor is an algorithm that produces verdicts on the satisfaction of a temporal query on a trace. We formalize a monitoring algorithm for metric dynamic logic, an extension of metric temporal logic with regular expressions. The monitor computes whether a given query is satisfied at every position in an input trace of time-stamped events. We formalize the time-stamps as an abstract algebraic structure satisfying certain assumptions. Instances of this structure include natural numbers, real numbers, and lexicographic combinations of them. Our monitor follows the multi-head paradigm: it reads the input simultaneously at multiple positions and moves its reading heads asynchronously. This mode of operation results in unprecedented time and space complexity guarantees for metric dynamic logic: The monitor's amortized time complexity to process a time-point and the monitor's space complexity neither depends on the event-rate, i.e., the number of events within a fixed time-unit, nor on the numeric constants occurring in the quantitative temporal constraints in the given query. The multi-head monitoring algorithm for metric dynamic logic is reported in our paper "Multi-Head Monitoring of Metric Dynamic Logic" published at ATVA 2020. We have also formalized unpublished specialized algorithms for the temporal operators of metric temporal logic. Enumeration of Equivalence Relations https://www.isa-afp.org/entries/Equivalence_Relation_Enumeration.html https://www.isa-afp.org/entries/Equivalence_Relation_Enumeration.html Emin Karayel 04 Feb 2022 00:00:00 +0000 <p>This entry contains a formalization of an algorithm enumerating all equivalence relations on an initial segment of the natural numbers. The approach follows the method described by Stanton and White <a href="https://doi.org/10.1007/978-1-4612-4968-9">[5,§ 1.5]</a> using restricted growth functions.</p> <p>The algorithm internally enumerates restricted growth functions (as lists), whose equivalence kernels then form the equivalence relations. This has the advantage that the representation is compact and lookup of the relation reduces to a list lookup operation.</p> <p>The algorithm can also be used within a proof and an example application is included, where a sequence of variables is split by the possible partitions they can form.</p> Quasi-Borel Spaces https://www.isa-afp.org/entries/Quasi_Borel_Spaces.html https://www.isa-afp.org/entries/Quasi_Borel_Spaces.html Michikazu Hirata, Yasuhiko Minamide, Tetsuya Sato 03 Feb 2022 00:00:00 +0000 The notion of quasi-Borel spaces was introduced by <a href="https://dl.acm.org/doi/10.5555/3329995.3330072"> Heunen et al</a>. The theory provides a suitable denotational model for higher-order probabilistic programming languages with continuous distributions. This entry is a formalization of the theory of quasi-Borel spaces, including construction of quasi-Borel spaces (product, coproduct, function spaces), the adjunction between the category of measurable spaces and the category of quasi-Borel spaces, and the probability monad on quasi-Borel spaces. This entry also contains the formalization of the Bayesian regression presented in the work of Heunen et al. This work is a part of the work by same authors, <i>Program Logic for Higher-Order Probabilistic Programs in Isabelle/HOL</i>, which will be published in the proceedings of the 16th International Symposium on Functional and Logic Programming (FLOPS 2022). Duality of Linear Programming https://www.isa-afp.org/entries/LP_Duality.html https://www.isa-afp.org/entries/LP_Duality.html René Thiemann 03 Feb 2022 00:00:00 +0000 We formalize the weak and strong duality theorems of linear programming. For the strong duality theorem we provide three sufficient preconditions: both the primal problem and the dual problem are satisfiable, the primal problem is satisfiable and bounded, or the dual problem is satisfiable and bounded. The proofs are based on an existing formalization of Farkas' Lemma. First-Order Theory of Rewriting https://www.isa-afp.org/entries/FO_Theory_Rewriting.html https://www.isa-afp.org/entries/FO_Theory_Rewriting.html Alexander Lochmann, Bertram Felgenhauer 02 Feb 2022 00:00:00 +0000 The first-order theory of rewriting (FORT) is a decidable theory for linear variable-separated rewrite systems. The decision procedure is based on tree automata technique and an inference system presented in "Certifying Proofs in the First-Order Theory of Rewriting". This AFP entry provides a formalization of the underlying decision procedure. Moreover it allows to generate a function that can verify each inference step via the code generation facility of Isabelle/HOL. Additionally it contains the specification of a certificate language (that allows to state proofs in FORT) and a formalized function that allows to verify the validity of the proof. This gives software tool authors, that implement the decision procedure, the possibility to verify their output. Young's Inequality for Increasing Functions https://www.isa-afp.org/entries/Youngs_Inequality.html https://www.isa-afp.org/entries/Youngs_Inequality.html Lawrence C Paulson 31 Jan 2022 00:00:00 +0000 Young's inequality states that $$ ab \leq \int_0^a f(x)dx + \int_0^b f^{-1}(y) dy $$ where $a\geq 0$, $b\geq 0$ and $f$ is strictly increasing and continuous. Its proof is formalised following <a href="https://www.jstor.org/stable/2318018">the development</a> by Cunningham and Grossman. Their idea is to make the intuitive, geometric folklore proof rigorous by reasoning about step functions. The lack of the Riemann integral makes the development longer than one would like, but their argument is reproduced faithfully. A Sequent Calculus Prover for First-Order Logic with Functions https://www.isa-afp.org/entries/FOL_Seq_Calc2.html https://www.isa-afp.org/entries/FOL_Seq_Calc2.html Asta Halkjær From, Frederik Krogsdal Jacobsen 31 Jan 2022 00:00:00 +0000 We formalize an automated theorem prover for first-order logic with functions. The proof search procedure is based on sequent calculus and we verify its soundness and completeness using the Abstract Soundness and Abstract Completeness theories. Our analytic completeness proof covers both open and closed formulas. Since our deterministic prover considers only the subset of terms relevant to proving a given sequent, we do so as well when building a countermodel from a failed proof. We formally connect our prover with the proof system and semantics of the existing SeCaV system. In particular, the prover's output can be post-processed in Haskell to generate human-readable SeCaV proofs which are also machine-verifiable proof certificates. Interpolation Polynomials (in HOL-Algebra) https://www.isa-afp.org/entries/Interpolation_Polynomials_HOL_Algebra.html https://www.isa-afp.org/entries/Interpolation_Polynomials_HOL_Algebra.html Emin Karayel 29 Jan 2022 00:00:00 +0000 <p>A well known result from algebra is that, on any field, there is exactly one polynomial of degree less than n interpolating n points [<a href="https://doi.org/10.1017/CBO9780511814549">1</a>, §7].</p> <p>This entry contains a formalization of the above result, as well as the following generalization in the case of finite fields <i>F</i>: There are <i>|F|<sup>m-n</sup></i> polynomials of degree less than <i>m ≥ n</i> interpolating the same n points, where <i>|F|</i> denotes the size of the domain of the field. To establish the result the entry also includes a formalization of Lagrange interpolation, which might be of independent interest.</p> <p>The formalized results are defined on the algebraic structures from HOL-Algebra, which are distinct from the type-class based structures defined in HOL. Note that there is an existing formalization for polynomial interpolation and, in particular, Lagrange interpolation by Thiemann and Yamada [<a href="https://www.isa-afp.org/entries/Polynomial_Interpolation.html">2</a>] on the type-class based structures in HOL.</p> Median Method https://www.isa-afp.org/entries/Median_Method.html https://www.isa-afp.org/entries/Median_Method.html Emin Karayel 25 Jan 2022 00:00:00 +0000 <p>The median method is an amplification result for randomized approximation algorithms described in [<a href="https://doi.org/10.1006/jcss.1997.1545">1</a>]. Given an algorithm whose result is in a desired interval with a probability larger than <i>1/2</i>, it is possible to improve the success probability, by running the algorithm multiple times independently and using the median. In contrast to using the mean, the amplification of the success probability grows exponentially with the number of independent runs.</p> <p>This entry contains a formalization of the underlying theorem: Given a sequence of n independent random variables, which are in a desired interval with a probability <i>1/2 + a</i>. Then their median will be in the desired interval with a probability of <i>1 − exp(−2a<sup>2</sup> n)</i>. In particular, the success probability approaches <i>1</i> exponentially with the number of variables.</p> <p>In addition to that, this entry also contains a proof that order-statistics of Borel-measurable random variables are themselves measurable and that generalized intervals in linearly ordered Borel-spaces are measurable.</p> Actuarial Mathematics https://www.isa-afp.org/entries/Actuarial_Mathematics.html https://www.isa-afp.org/entries/Actuarial_Mathematics.html Yosuke Ito 23 Jan 2022 00:00:00 +0000 Actuarial Mathematics is a theory in applied mathematics, which is mainly used for determining the prices of insurance products and evaluating the liability of a company associating with insurance contracts. It is related to calculus, probability theory and financial theory, etc. In this entry, I formalize the very basic part of Actuarial Mathematics in Isabelle/HOL. The first formalization is about the theory of interest which deals with interest rates, present value factors, an annuity certain, etc. I have already formalized the basic part of Actuarial Mathematics in Coq (https://github.com/Yosuke-Ito-345/Actuary). This entry is currently the partial translation and a little generalization of the Coq formalization. The further translation in Isabelle/HOL is now proceeding. Irrational numbers from THE BOOK https://www.isa-afp.org/entries/Irrationals_From_THEBOOK.html https://www.isa-afp.org/entries/Irrationals_From_THEBOOK.html Lawrence C Paulson 08 Jan 2022 00:00:00 +0000 An elementary proof is formalised: that <em>exp r</em> is irrational for every nonzero rational number <em>r</em>. The mathematical development comes from the well-known volume <em>Proofs from THE BOOK</em>, by Aigner and Ziegler, who credit the idea to Hermite. The development illustrates a number of basic Isabelle techniques: the manipulation of summations, the calculation of quite complicated derivatives and the estimation of integrals. We also see how to import another AFP entry (Stirling's formula). As for the theorem itself, note that a much stronger and more general result (the Hermite--Lindemann--Weierstraß transcendence theorem) is already available in the AFP. Knight's Tour Revisited Revisited https://www.isa-afp.org/entries/Knights_Tour.html https://www.isa-afp.org/entries/Knights_Tour.html Lukas Koller 04 Jan 2022 00:00:00 +0000 This is a formalization of the article <i>Knight's Tour Revisited</i> by Cull and De Curtins where they prove the existence of a Knight's path for arbitrary <i>n &times; m</i>-boards with <i>min(n,m) &ge; 5</i>. If <i>n &middot; m</i> is even, then there exists a Knight's circuit. A Knight's Path is a sequence of moves of a Knight on a chessboard s.t. the Knight visits every square of a chessboard exactly once. Finding a Knight's path is a an instance of the Hamiltonian path problem. A Knight's circuit is a Knight's path, where additionally the Knight can move from the last square to the first square of the path, forming a loop. During the formalization two mistakes in the original proof were discovered. These mistakes are corrected in this formalization. Hyperdual Numbers and Forward Differentiation https://www.isa-afp.org/entries/Hyperdual.html https://www.isa-afp.org/entries/Hyperdual.html Filip Smola, Jacques Fleuriot 31 Dec 2021 00:00:00 +0000 <p>Hyperdual numbers are ones with a real component and a number of infinitesimal components, usually written as $a_0 + a_1 \cdot \epsilon_1 + a_2 \cdot \epsilon_2 + a_3 \cdot \epsilon_1\epsilon_2$. They have been proposed by <a href="https://doi.org/10.2514/6.2011-886">Fike and Alonso</a> in an approach to automatic differentiation.</p> <p>In this entry we formalise hyperdual numbers and their application to forward differentiation. We show them to be an instance of multiple algebraic structures and then, along with facts about twice-differentiability, we define what we call the hyperdual extensions of functions on real-normed fields. This extension formally represents the proposed way that the first and second derivatives of a function can be automatically calculated. We demonstrate it on the standard logistic function $f(x) = \frac{1}{1 + e^{-x}}$ and also reproduce the example analytic function $f(x) = \frac{e^x}{\sqrt{sin(x)^3 + cos(x)^3}}$ used for demonstration by Fike and Alonso.</p> Gale-Shapley Algorithm https://www.isa-afp.org/entries/Gale_Shapley.html https://www.isa-afp.org/entries/Gale_Shapley.html Tobias Nipkow 29 Dec 2021 00:00:00 +0000 This is a stepwise refinement and proof of the Gale-Shapley stable matching (or marriage) algorithm down to executable code. Both a purely functional implementation based on lists and a functional implementation based on efficient arrays (provided by the Collections Framework in the AFP) are developed. The latter implementation runs in time <i>O(n<sup>2</sup>)</i> where <i>n</i> is the cardinality of the two sets to be matched. Roth's Theorem on Arithmetic Progressions https://www.isa-afp.org/entries/Roth_Arithmetic_Progressions.html https://www.isa-afp.org/entries/Roth_Arithmetic_Progressions.html Chelsea Edmonds, Angeliki Koutsoukou-Argyraki, Lawrence C. Paulson 28 Dec 2021 00:00:00 +0000 We formalise a proof of Roth's Theorem on Arithmetic Progressions, a major result in additive combinatorics on the existence of 3-term arithmetic progressions in subsets of natural numbers. To this end, we follow a proof using graph regularity. We employ our recent formalisation of Szemerédi's Regularity Lemma, a major result in extremal graph theory, which we use here to prove the Triangle Counting Lemma and the Triangle Removal Lemma. Our sources are Yufei Zhao's MIT lecture notes "<a href="https://ocw.mit.edu/courses/mathematics/18-217-graph-theory-and-additive-combinatorics-fall-2019/lecture-notes/MIT18_217F19_ch3.pdf">Graph Theory and Additive Combinatorics</a>" (revised version <a href="https://yufeizhao.com/gtac/gtac17.pdf">here</a>) and W.T. Gowers's Cambridge lecture notes "<a href="https://www.dpmms.cam.ac.uk/~par31/notes/tic.pdf">Topics in Combinatorics</a>". We also refer to the University of Georgia notes by Stephanie Bell and Will Grodzicki, "<a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.432.327">Using Szemerédi's Regularity Lemma to Prove Roth's Theorem</a>". Markov Decision Processes with Rewards https://www.isa-afp.org/entries/MDP-Rewards.html https://www.isa-afp.org/entries/MDP-Rewards.html Maximilian Schäffeler, Mohammad Abdulaziz 16 Dec 2021 00:00:00 +0000 We present a formalization of Markov Decision Processes with rewards. In particular we first build on Hölzl's formalization of MDPs (AFP entry: Markov_Models) and extend them with rewards. We proceed with an analysis of the expected total discounted reward criterion for infinite horizon MDPs. The central result is the construction of the iteration rule for the Bellman operator. We prove the optimality equations for this operator and show the existence of an optimal stationary deterministic solution. The analysis can be used to obtain dynamic programming algorithms such as value iteration and policy iteration to solve MDPs with formal guarantees. Our formalization is based on chapters 5 and 6 in Puterman's book "Markov Decision Processes: Discrete Stochastic Dynamic Programming". Verified Algorithms for Solving Markov Decision Processes https://www.isa-afp.org/entries/MDP-Algorithms.html https://www.isa-afp.org/entries/MDP-Algorithms.html Maximilian Schäffeler, Mohammad Abdulaziz 16 Dec 2021 00:00:00 +0000 We present a formalization of algorithms for solving Markov Decision Processes (MDPs) with formal guarantees on the optimality of their solutions. In particular we build on our analysis of the Bellman operator for discounted infinite horizon MDPs. From the iterator rule on the Bellman operator we directly derive executable value iteration and policy iteration algorithms to iteratively solve finite MDPs. We also prove correct optimized versions of value iteration that use matrix splittings to improve the convergence rate. In particular, we formally verify Gauss-Seidel value iteration and modified policy iteration. The algorithms are evaluated on two standard examples from the literature, namely, inventory management and gridworld. Our formalization covers most of chapter 6 in Puterman's book "Markov Decision Processes: Discrete Stochastic Dynamic Programming". Regular Tree Relations https://www.isa-afp.org/entries/Regular_Tree_Relations.html https://www.isa-afp.org/entries/Regular_Tree_Relations.html Alexander Lochmann, Bertram Felgenhauer, Christian Sternagel, René Thiemann, Thomas Sternagel 15 Dec 2021 00:00:00 +0000 Tree automata have good closure properties and therefore a commonly used to prove/disprove properties. This formalization contains among other things the proofs of many closure properties of tree automata (anchored) ground tree transducers and regular relations. Additionally it includes the well known pumping lemma and a lifting of the Myhill Nerode theorem for regular languages to tree languages. We want to mention the existence of a <a href="https://www.isa-afp.org/entries/Tree-Automata.html">tree automata APF-entry</a> developed by Peter Lammich. His work is based on epsilon free top-down tree automata, while this entry builds on bottom-up tree auotamta with epsilon transitions. Moreover our formalization relies on the <a href="https://www.isa-afp.org/entries/Collections.html">Collections Framework</a>, also by Peter Lammich, to obtain efficient code. All proven constructions of the closure properties are exportable using the Isabelle/HOL code generation facilities. Simplicial Complexes and Boolean functions https://www.isa-afp.org/entries/Simplicial_complexes_and_boolean_functions.html https://www.isa-afp.org/entries/Simplicial_complexes_and_boolean_functions.html Jesús Aransay, Alejandro del Campo, Julius Michaelis 29 Nov 2021 00:00:00 +0000 In this work we formalise the isomorphism between simplicial complexes of dimension $n$ and monotone Boolean functions in $n$ variables, mainly following the definitions and results as introduced by N. A. Scoville. We also take advantage of the AFP representation of <a href="https://www.isa-afp.org/entries/ROBDD.html">ROBDD</a> (Reduced Ordered Binary Decision Diagrams) to compute the ROBDD representation of a given simplicial complex (by means of the isomorphism to Boolean functions). Some examples of simplicial complexes and associated Boolean functions are also presented. van Emde Boas Trees https://www.isa-afp.org/entries/Van_Emde_Boas_Trees.html https://www.isa-afp.org/entries/Van_Emde_Boas_Trees.html Thomas Ammer, Peter Lammich 23 Nov 2021 00:00:00 +0000 The <em>van Emde Boas tree</em> or <em>van Emde Boas priority queue</em> is a data structure supporting membership test, insertion, predecessor and successor search, minimum and maximum determination and deletion in <em>O(log log U)</em> time, where <em>U = 0,...,2<sup>n-1</sup></em> is the overall range to be considered. <p/> The presented formalization follows Chapter 20 of the popular <em>Introduction to Algorithms (3rd ed.)</em> by Cormen, Leiserson, Rivest and Stein (CLRS), extending the list of formally verified CLRS algorithms. Our current formalization is based on the first author's bachelor's thesis. <p/> First, we prove correct a <em>functional</em> implementation, w.r.t. an abstract data type for sets. Apart from functional correctness, we show a resource bound, and runtime bounds w.r.t. manually defined timing functions for the operations. <p/> Next, we refine the operations to Imperative HOL with time, and show correctness and complexity. This yields a practically more efficient implementation, and eliminates the manually defined timing functions from the trusted base of the proof. Foundation of geometry in planes, and some complements: Excluding the parallel axioms https://www.isa-afp.org/entries/Foundation_of_geometry.html https://www.isa-afp.org/entries/Foundation_of_geometry.html Fumiya Iwama 22 Nov 2021 00:00:00 +0000 "Foundations of Geometry" is a mathematical book written by Hilbert in 1899. This entry is a complete formalization of "Incidence" (excluding cubic axioms), "Order" and "Congruence" (excluding point sequences) of the axioms constructed in this book. In addition, the theorem of the problem about the part that is treated implicitly and is not clearly stated in it is being carried out in parallel. The Hahn and Jordan Decomposition Theorems https://www.isa-afp.org/entries/Hahn_Jordan_Decomposition.html https://www.isa-afp.org/entries/Hahn_Jordan_Decomposition.html Marie Cousin, Mnacho Echenim, Hervé Guiol 19 Nov 2021 00:00:00 +0000 In this work we formalize the Hahn decomposition theorem for signed measures, namely that any measure space for a signed measure can be decomposed into a positive and a negative set, where every measurable subset of the positive one has a positive measure, and every measurable subset of the negative one has a negative measure. We also formalize the Jordan decomposition theorem as a corollary, which states that the signed measure under consideration admits a unique decomposition into a difference of two positive measures, at least one of which is finite. Exploring Simplified Variants of Gödel’s Ontological Argument in Isabelle/HOL https://www.isa-afp.org/entries/SimplifiedOntologicalArgument.html https://www.isa-afp.org/entries/SimplifiedOntologicalArgument.html Christoph Benzmüller 08 Nov 2021 00:00:00 +0000 <p>Simplified variants of Gödel's ontological argument are explored. Among those is a particularly interesting simplified argument which is (i) valid already in basic modal logics K or KT, (ii) which does not suffer from modal collapse, and (iii) which avoids the rather complex predicates of essence (Ess.) and necessary existence (NE) as used by Gödel. </p><p> Whether the presented variants increase or decrease the attractiveness and persuasiveness of the ontological argument is a question I would like to pass on to philosophy and theology. </p> Real Exponents as the Limits of Sequences of Rational Exponents https://www.isa-afp.org/entries/Real_Power.html https://www.isa-afp.org/entries/Real_Power.html Jacques D. Fleuriot 08 Nov 2021 00:00:00 +0000 In this formalisation, we construct real exponents as the limits of sequences of rational exponents. In particular, if $a \ge 1$ and $x \in \mathbb{R}$, we choose an increasing rational sequence $r_n$ such that $\lim_{n\to\infty} {r_n} = x$. Then the sequence $a^{r_n}$ is increasing and if $r$ is any rational number such that $r > x$, $a^{r_n}$ is bounded above by $a^r$. By the convergence criterion for monotone sequences, $a^{r_n}$ converges. We define $a^ x = \lim_{n\to\infty} a^{r_n}$ and show that it has the expected properties (for $a \ge 0$). This particular construction of real exponents is needed instead of the usual one using the natural logarithm and exponential functions (which already exists in Isabelle) to support our mechanical derivation of Euler's exponential series as an ``infinite polynomial". Aside from helping us avoid circular reasoning, this is, as far as we are aware, the first time real exponents are mechanised in this way within a proof assistant. Automating Public Announcement Logic and the Wise Men Puzzle in Isabelle/HOL https://www.isa-afp.org/entries/PAL.html https://www.isa-afp.org/entries/PAL.html Christoph Benzmüller, Sebastian Reiche 08 Nov 2021 00:00:00 +0000 We present a shallow embedding of public announcement logic (PAL) with relativized general knowledge in HOL. We then use PAL to obtain an elegant encoding of the wise men puzzle, which we solve automatically using sledgehammer. - - Factorization of Polynomials with Algebraic Coefficients - https://www.isa-afp.org/entries/Factor_Algebraic_Polynomial.html - https://www.isa-afp.org/entries/Factor_Algebraic_Polynomial.html - Manuel Eberl, René Thiemann - 08 Nov 2021 00:00:00 +0000 - -The AFP already contains a verified implementation of algebraic -numbers. However, it is has a severe limitation in its factorization -algorithm of real and complex polynomials: the factorization is only -guaranteed to succeed if the coefficients of the polynomial are -rational numbers. In this work, we verify an algorithm to factor all -real and complex polynomials whose coefficients are algebraic. The -existence of such an algorithm proves in a constructive way that the -set of complex algebraic numbers is algebraically closed. Internally, -the algorithm is based on resultants of multivariate polynomials and -an approximation algorithm using interval arithmetic. - diff --git a/web/statistics.html b/web/statistics.html --- a/web/statistics.html +++ b/web/statistics.html @@ -1,302 +1,302 @@ Archive of Formal Proofs

 

 

 

 

 

 

Statistics

 

Statistics

- + - +
Number of Articles:666
Number of Articles:667
Number of Authors:424
Number of lemmas:~195,100
Lines of Code:~3,354,600
Lines of Code:~3,372,900

Most used AFP articles:

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

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,1049 +1,1052 @@ 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   MDP-Algorithms   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   Gale_Shapley   VYDRA_MDL   Universal_Hash_Families   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   Virtual_Substitution   Equivalence_Relation_Enumeration   Optimization: Simplex   Quantum computing: Isabelle_Marries_Dirac   Projective_Measurements   Registers  

Concurrency

Data structures

Functional programming

Hardware

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   + ResiduatedTransitionSystem   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   Correctness_Algebras   Registers   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   Dominance_CHK   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

Optics   Subresultants   Buildings   Algebraic_VCs   C2KA_DistributedSystems   Multirelations   Residuated_Lattices   PseudoHoops   Impossible_Geometry   Gauss-Jordan-Elim-Fun   Matrix_Tensor   Kleene_Algebra   KAT_and_DRA   KAD   Regular_Algebras   Free-Groups   CofGroups   Finitely_Generated_Abelian_Groups   Group-Ring-Module   Robbins-Conjecture   Valuation   Rank_Nullity_Theorem   Polynomials   Relation_Algebra   PSemigroupsConvolution   Secondary_Sylow   Jordan_Hoelder   Cayley_Hamilton   VectorSpace   Echelon_Form   QR_Decomposition   Hermite   Rep_Fin_Groups   Jordan_Normal_Form   Algebraic_Numbers   Polynomial_Interpolation   Polynomial_Factorization   Perron_Frobenius   Stochastic_Matrices   Groebner_Bases   Nullstellensatz   Mason_Stothers   Berlekamp_Zassenhaus   Stone_Relation_Algebras   Stone_Kleene_Relation_Algebras   Orbit_Stabiliser   Dirichlet_L   Symmetric_Polynomials   Taylor_Models   LLL_Basis_Reduction   LLL_Factorization   Localization_Ring   Quaternions   Octonions   Aggregation_Algebras   Signature_Groebner   Quantales   Transformer_Semantics   Farkas   Groebner_Macaulay   Linear_Inequalities   Linear_Programming   Jacobson_Basic_Algebra   Hybrid_Systems_VCs   Subset_Boolean_Algebras   Power_Sum_Polynomials   Formal_Puiseux_Series   Matrices_for_ODEs   Smith_Normal_Form   Grothendieck_Schemes   Factor_Algebraic_Polynomial   Hyperdual   Interpolation_Polynomials_HOL_Algebra   LP_Duality  

Analysis

Measure theory

Probability theory

Number theory

Games and economics

Geometry

Topology

Graph theory

Combinatorics

Category theory

Physics

Misc

Tools

\ No newline at end of file