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

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

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

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

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

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

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

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

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

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

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

The entry contains a proof of both theorems.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Not in the generated document are the following sessions:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[BTree] title = A Verified Imperative Implementation of B-Trees author = Niels Mündler topic = Computer science/Data structures date = 2021-02-24 notify = n.muendler@tum.de abstract = In this work, we use the interactive theorem prover Isabelle/HOL to verify an imperative implementation of the classical B-tree data structure invented by Bayer and McCreight [ACM 1970]. The implementation supports set membership, insertion and deletion queries with efficient binary search for intra-node navigation. This is accomplished by first specifying the structure abstractly in the functional modeling language HOL and proving functional correctness. Using manual refinement, we derive an imperative implementation in Imperative/HOL. We show the validity of this refinement using the separation logic utilities from the Isabelle Refinement Framework . The code can be exported to the programming languages SML, OCaml and Scala. We examine the runtime of all operations indirectly by reproducing results of the logarithmic relationship between height and the number of nodes. The results are discussed in greater detail in the corresponding Bachelor's Thesis. extra-history = Change history: [2021-05-02]: Add implementation and proof of correctness of imperative deletion operations. Further add the option to export code to OCaml.
[Sunflowers] title = The Sunflower Lemma of Erdős and Rado author = René Thiemann topic = Mathematics/Combinatorics date = 2021-02-25 notify = rene.thiemann@uibk.ac.at abstract = We formally define sunflowers and provide a formalization of the sunflower lemma of Erdős and Rado: whenever a set of size-k-sets has a larger cardinality than (r - 1)k · k!, then it contains a sunflower of cardinality r. [Mereology] title = Mereology author = Ben Blumson topic = Logic/Philosophical aspects date = 2021-03-01 notify = benblumson@gmail.com abstract = We use Isabelle/HOL to verify elementary theorems and alternative axiomatizations of classical extensional mereology. [Modular_arithmetic_LLL_and_HNF_algorithms] title = Two algorithms based on modular arithmetic: lattice basis reduction and Hermite normal form computation author = Ralph Bottesch <>, Jose Divasón , René Thiemann topic = Computer science/Algorithms/Mathematical date = 2021-03-12 notify = rene.thiemann@uibk.ac.at abstract = We verify two algorithms for which modular arithmetic plays an essential role: Storjohann's variant of the LLL lattice basis reduction algorithm and Kopparty's algorithm for computing the Hermite normal form of a matrix. To do this, we also formalize some facts about the modulo operation with symmetric range. Our implementations are based on the original papers, but are otherwise efficient. For basis reduction we formalize two versions: one that includes all of the optimizations/heuristics from Storjohann's paper, and one excluding a heuristic that we observed to often decrease efficiency. We also provide a fast, self-contained certifier for basis reduction, based on the efficient Hermite normal form algorithm. [Constructive_Cryptography_CM] title = Constructive Cryptography in HOL: the Communication Modeling Aspect author = Andreas Lochbihler , S. Reza Sefidgar <> topic = Computer science/Security/Cryptography, Mathematics/Probability theory date = 2021-03-17 notify = mail@andreas-lochbihler.de, reza.sefidgar@inf.ethz.ch abstract = Constructive Cryptography (CC) [ICS 2011, TOSCA 2011, TCC 2016] introduces an abstract approach to composable security statements that allows one to focus on a particular aspect of security proofs at a time. Instead of proving the properties of concrete systems, CC studies system classes, i.e., the shared behavior of similar systems, and their transformations. Modeling of systems communication plays a crucial role in composability and reusability of security statements; yet, this aspect has not been studied in any of the existing CC results. We extend our previous CC formalization [Constructive_Cryptography, CSF 2019] with a new semantic domain called Fused Resource Templates (FRT) that abstracts over the systems communication patterns in CC proofs. This widens the scope of cryptography proof formalizations in the CryptHOL library [CryptHOL, ESOP 2016, J Cryptol 2020]. This formalization is described in Abstract Modeling of Systems Communication in Constructive Cryptography using CryptHOL. [IFC_Tracking] title = Information Flow Control via Dependency Tracking author = Benedikt Nordhoff topic = Computer science/Security date = 2021-04-01 notify = b.n@wwu.de abstract = We provide a characterisation of how information is propagated by program executions based on the tracking data and control dependencies within executions themselves. The characterisation might be used for deriving approximative safety properties to be targeted by static analyses or checked at runtime. We utilise a simple yet versatile control flow graph model as a program representation. As our model is not assumed to be finite it can be instantiated for a broad class of programs. The targeted security property is indistinguishable security where executions produce sequences of observations and only non-terminating executions are allowed to drop a tail of those. A very crude approximation of our characterisation is slicing based on program dependence graphs, which we use as a minimal example and derive a corresponding soundness result. For further details and applications refer to the authors upcoming dissertation. [Grothendieck_Schemes] title = Grothendieck's Schemes in Algebraic Geometry author = Anthony Bordg , Lawrence Paulson , Wenda Li topic = Mathematics/Algebra, Mathematics/Geometry date = 2021-03-29 notify = apdb3@cam.ac.uk, lp15@cam.ac.uk abstract = We formalize mainstream structures in algebraic geometry culminating in Grothendieck's schemes: presheaves of rings, sheaves of rings, ringed spaces, locally ringed spaces, affine schemes and schemes. We prove that the spectrum of a ring is a locally ringed space, hence an affine scheme. Finally, we prove that any affine scheme is a scheme. [Progress_Tracking] title = Formalization of Timely Dataflow's Progress Tracking Protocol author = Matthias Brun<>, Sára Decova<>, Andrea Lattuada, Dmitriy Traytel topic = Computer science/Algorithms/Distributed date = 2021-04-13 notify = matthias.brun@inf.ethz.ch, traytel@di.ku.dk abstract = Large-scale stream processing systems often follow the dataflow paradigm, which enforces a program structure that exposes a high degree of parallelism. The Timely Dataflow distributed system supports expressive cyclic dataflows for which it offers low-latency data- and pipeline-parallel stream processing. To achieve high expressiveness and performance, Timely Dataflow uses an intricate distributed protocol for tracking the computation’s progress. We formalize this progress tracking protocol and verify its safety. Our formalization is described in detail in our forthcoming ITP'21 paper. [GaleStewart_Games] title = Gale-Stewart Games author = Sebastiaan Joosten topic = Mathematics/Games and economics date = 2021-04-23 notify = sjcjoosten@gmail.com abstract = This is a formalisation of the main result of Gale and Stewart from 1953, showing that closed finite games are determined. This property is now known as the Gale Stewart Theorem. While the original paper shows some additional theorems as well, we only formalize this main result, but do so in a somewhat general way. We formalize games of a fixed arbitrary length, including infinite length, using co-inductive lists, and show that defensive strategies exist unless the other player is winning. For closed games, defensive strategies are winning for the closed player, proving that such games are determined. For finite games, which are a special case in our formalisation, all games are closed. [Metalogic_ProofChecker] title = Isabelle's Metalogic: Formalization and Proof Checker author = Tobias Nipkow , Simon Roßkopf topic = Logic/General logic date = 2021-04-27 notify = rosskops@in.tum.de abstract = In this entry we formalize Isabelle's metalogic in Isabelle/HOL. Furthermore, we define a language of proof terms and an executable proof checker and prove its soundness wrt. the metalogic. The formalization is intentionally kept close to the Isabelle implementation(for example using de Brujin indices) to enable easy integration of generated code with the Isabelle system without a complicated translation layer. The formalization is described in our CADE 28 paper. [Regression_Test_Selection] title = Regression Test Selection author = Susannah Mansky topic = Computer science/Algorithms date = 2021-04-30 notify = sjohnsn2@illinois.edu, susannahej@gmail.com abstract = This development provides a general definition for safe Regression Test Selection (RTS) algorithms. RTS algorithms select which tests to rerun on revised code, reducing the time required to check for newly introduced errors. An RTS algorithm is considered safe if and only if all deselected tests would have unchanged results. This definition is instantiated with two class-collection-based RTS algorithms run over the JVM as modeled by JinjaDCI. This is achieved with a general definition for Collection Semantics, small-step semantics instrumented to collect information during execution. As the RTS definition mandates safety, these instantiations include proofs of safety. This work is described in Mansky and Gunter's LSFA 2020 paper and Mansky's doctoral thesis (UIUC, 2020). [Padic_Ints] title = Hensel's Lemma for the p-adic Integers author = Aaron Crighton topic = Mathematics/Number theory date = 2021-03-23 notify = crightoa@mcmaster.ca abstract = We formalize the ring of p-adic integers within the framework of the HOL-Algebra library. The carrier of the ring is formalized as the inverse limit of quotients of the integers by powers of a fixed prime p. We define an integer-valued valuation, as well as an extended-integer valued valuation which sends 0 to the infinite element. Basic topological facts about the p-adic integers are formalized, including completeness and sequential compactness. Taylor expansions of polynomials over a commutative ring are defined, culminating in the formalization of Hensel's Lemma based on a proof due to Keith Conrad. [Combinatorics_Words] title = Combinatorics on Words Basics author = Štěpán Holub , Martin Raška<>, Štěpán Starosta topic = Computer science/Automata and formal languages date = 2021-05-24 notify = holub@karlin.mff.cuni.cz, stepan.starosta@fit.cvut.cz abstract = We formalize basics of Combinatorics on Words. This is an extension of existing theories on lists. We provide additional properties related to prefix, suffix, factor, length and rotation. The topics include prefix and suffix comparability, mismatch, word power, total and reversed morphisms, border, periods, primitivity and roots. We also formalize basic, mostly folklore results related to word equations: equidivisibility, commutation and conjugation. Slightly advanced properties include the Periodicity lemma (often cited as the Fine and Wilf theorem) and the variant of the Lyndon-Schützenberger theorem for words. We support the algebraic point of view which sees words as generators of submonoids of a free monoid. This leads to the concepts of the (free) hull, the (free) basis (or code). [Combinatorics_Words_Lyndon] title = Lyndon words author = Štěpán Holub , Štěpán Starosta topic = Computer science/Automata and formal languages date = 2021-05-24 notify = holub@karlin.mff.cuni.cz, stepan.starosta@fit.cvut.cz abstract = Lyndon words are words lexicographically minimal in their conjugacy class. We formalize their basic properties and characterizations, in particular the concepts of the longest Lyndon suffix and the Lyndon factorization. Most of the work assumes a fixed lexicographical order. Nevertheless we also define the smallest relation guaranteeing lexicographical minimality of a given word (in its conjugacy class). [Combinatorics_Words_Graph_Lemma] title = Graph Lemma author = Štěpán Holub , Štěpán Starosta topic = Computer science/Automata and formal languages date = 2021-05-24 notify = holub@karlin.mff.cuni.cz, stepan.starosta@fit.cvut.cz abstract = Graph lemma quantifies the defect effect of a system of word equations. That is, it provides an upper bound on the rank of the system. We formalize the proof based on the decomposition of a solution into its free basis. A direct application is an alternative proof of the fact that two noncommuting words form a code. [Lifting_the_Exponent] title = Lifting the Exponent author = Jakub Kądziołka topic = Mathematics/Number theory date = 2021-04-27 notify = kuba@kadziolka.net abstract = We formalize the Lifting the Exponent Lemma, which shows how to find the largest power of $p$ dividing $a^n \pm b^n$, for a prime $p$ and positive integers $a$ and $b$. The proof follows Amir Hossein Parvardi's. [IMP_Compiler] title = A Shorter Compiler Correctness Proof for Language IMP author = Pasquale Noce topic = Computer science/Programming languages/Compiling date = 2021-06-04 notify = pasquale.noce.lavoro@gmail.com abstract = This paper presents a compiler correctness proof for the didactic imperative programming language IMP, introduced in Nipkow and Klein's book on formal programming language semantics (version of March 2021), whose size is just two thirds of the book's proof in the number of formal text lines. As such, it promises to constitute a further enhanced reference for the formal verification of compilers meant for larger, real-world programming languages. The presented proof does not depend on language determinism, so that the proposed approach can be applied to non-deterministic languages as well. As a confirmation, this paper extends IMP with an additional non-deterministic choice command, and proves compiler correctness, viz. the simulation of compiled code execution by source code, for such extended language. [Public_Announcement_Logic] title = Public Announcement Logic author = Asta Halkjær From topic = Logic/General logic/Logics of knowledge and belief date = 2021-06-17 notify = ahfrom@dtu.dk abstract = This work is a formalization of public announcement logic with countably many agents. It includes proofs of soundness and completeness for a variant of the axiom system PA + DIST! + NEC!. The completeness proof builds on the Epistemic Logic theory. [MiniSail] title = MiniSail - A kernel language for the ISA specification language SAIL author = Mark Wassell topic = Computer science/Programming languages/Type systems date = 2021-06-18 notify = mpwassell@gmail.com abstract = MiniSail is a kernel language for Sail, an instruction set architecture (ISA) specification language. Sail is an imperative language with a light-weight dependent type system similar to refinement type systems. From an ISA specification, the Sail compiler can generate theorem prover code and C (or OCaml) to give an executable emulator for an architecture. The idea behind MiniSail is to capture the key and novel features of Sail in terms of their syntax, typing rules and operational semantics, and to confirm that they work together by proving progress and preservation lemmas. We use the Nominal2 library to handle binding. [SpecCheck] title = SpecCheck - Specification-Based Testing for Isabelle/ML author = Kevin Kappelmann , Lukas Bulwahn , Sebastian Willenbrink topic = Tools date = 2021-07-01 notify = kevin.kappelmann@tum.de abstract = SpecCheck is a QuickCheck-like testing framework for Isabelle/ML. You can use it to write specifications for ML functions. SpecCheck then checks whether your specification holds by testing your function against a given number of generated inputs. It helps you to identify bugs by printing counterexamples on failure and provides you timing information. SpecCheck is customisable and allows you to specify your own input generators, test output formats, as well as pretty printers and shrinking functions for counterexamples among other things. [Relational_Forests] title = Relational Forests author = Walter Guttmann topic = Mathematics/Graph theory date = 2021-08-03 notify = walter.guttmann@canterbury.ac.nz abstract = We study second-order formalisations of graph properties expressed as first-order formulas in relation algebras extended with a Kleene star. The formulas quantify over relations while still avoiding quantification over elements of the base set. We formalise the property of undirected graphs being acyclic this way. This involves a study of various kinds of orientation of graphs. We also verify basic algorithms to constructively prove several second-order properties. [Fresh_Identifiers] title = Fresh identifiers author = Andrei Popescu , Thomas Bauereiss topic = Computer science/Data structures date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry defines a type class with an operator returning a fresh identifier, given a set of already used identifiers and a preferred identifier. The entry provides a default instantiation for any infinite type, as well as executable instantiations for natural numbers and strings. [CoCon] title = CoCon: A Confidentiality-Verified Conference Management System author = Andrei Popescu , Peter Lammich , Thomas Bauereiss topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry contains the confidentiality verification of the (functional kernel of) the CoCon conference management system [1, 2]. The confidentiality properties refer to the documents managed by the system, namely papers, reviews, discussion logs and acceptance/rejection decisions, and also to the assignment of reviewers to papers. They have all been formulated as instances of BD Security [3, 4] and verified using the BD Security unwinding technique. [BD_Security_Compositional] title = Compositional BD Security author = Thomas Bauereiss , Andrei Popescu topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = Building on a previous AFP entry that formalizes the Bounded-Deducibility Security (BD Security) framework [1], we formalize compositionality and transport theorems for information flow security. These results allow lifting BD Security properties from individual components specified as transition systems, to a composition of systems specified as communicating products of transition systems. The underlying ideas of these results are presented in the papers [1] and [2]. The latter paper also describes a major case study where these results have been used: on verifying the CoSMeDis distributed social media platform (itself formalized as an AFP entry that builds on this entry). [CoSMed] title = CoSMed: A confidentiality-verified social media platform author = Thomas Bauereiss , Andrei Popescu topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry contains the confidentiality verification of the (functional kernel of) the CoSMed social media platform. The confidentiality properties are formalized as instances of BD Security [1, 2]. An innovation in the deployment of BD Security compared to previous work is the use of dynamic declassification triggers, incorporated as part of inductive bounds, for providing stronger guarantees that account for the repeated opening and closing of access windows. To further strengthen the confidentiality guarantees, we also prove "traceback" properties about the accessibility decisions affecting the information managed by the system. [CoSMeDis] title = CoSMeDis: A confidentiality-verified distributed social media platform author = Thomas Bauereiss , Andrei Popescu topic = Computer science/Security date = 2021-08-16 notify = thomas@bauereiss.name, a.popescu@sheffield.ac.uk abstract = This entry contains the confidentiality verification of the (functional kernel of) the CoSMeDis distributed social media platform presented in [1]. CoSMeDis is a multi-node extension the CoSMed prototype social media platform [2, 3, 4]. The confidentiality properties are formalized as instances of BD Security [5, 6]. The lifting of confidentiality properties from single nodes to the entire CoSMeDis network is performed using compositionality and transport theorems for BD Security, which are described in [1] and formalized in a separate AFP entry. [Three_Circles] title = The Theorem of Three Circles author = Fox Thomson , Wenda Li topic = Mathematics/Analysis date = 2021-08-21 notify = foxthomson0@gmail.com, wl302@cam.ac.uk abstract = The Descartes test based on Bernstein coefficients and Descartes’ rule of signs effectively (over-)approximates the number of real roots of a univariate polynomial over an interval. In this entry we formalise the theorem of three circles, which gives sufficient conditions for when the Descartes test returns 0 or 1. This is the first step for efficient root isolation. [Design_Theory] title = Combinatorial Design Theory author = Chelsea Edmonds , Lawrence Paulson topic = Mathematics/Combinatorics date = 2021-08-13 notify = cle47@cam.ac.uk abstract = Combinatorial design theory studies incidence set systems with certain balance and symmetry properties. It is closely related to hypergraph theory. This formalisation presents a general library for formal reasoning on incidence set systems, designs and their applications, including formal definitions and proofs for many key properties, operations, and theorems on the construction and existence of designs. Notably, this includes formalising t-designs, balanced incomplete block designs (BIBD), group divisible designs (GDD), pairwise balanced designs (PBD), design isomorphisms, and the relationship between graphs and designs. A locale-centric approach has been used to manage the relationships between the many different types of designs. Theorems of particular interest include the necessary conditions for existence of a BIBD, Wilson's construction on GDDs, and Bose's inequality on resolvable designs. Parts of this formalisation are explored in the paper "A Modular First Formalisation of Combinatorial Design Theory", presented at CICM 2021. [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. + diff --git a/thys/ROOTS b/thys/ROOTS --- a/thys/ROOTS +++ b/thys/ROOTS @@ -1,631 +1,632 @@ ADS_Functor AI_Planning_Languages_Semantics AODV AVL-Trees AWN Abortable_Linearizable_Modules Abs_Int_ITP2012 Abstract-Hoare-Logics Abstract-Rewriting Abstract_Completeness Abstract_Soundness Adaptive_State_Counting Affine_Arithmetic Aggregation_Algebras Akra_Bazzi Algebraic_Numbers Algebraic_VCs Allen_Calculus Amicable_Numbers Amortized_Complexity AnselmGod Applicative_Lifting Approximation_Algorithms Architectural_Design_Patterns Aristotles_Assertoric_Syllogistic Arith_Prog_Rel_Primes ArrowImpossibilityGS Attack_Trees Auto2_HOL Auto2_Imperative_HOL AutoFocus-Stream Automated_Stateful_Protocol_Verification Automatic_Refinement AxiomaticCategoryTheory BDD BD_Security_Compositional BNF_CC BNF_Operations BTree Banach_Steinhaus Bell_Numbers_Spivey BenOr_Kozen_Reif Berlekamp_Zassenhaus Bernoulli Bertrands_Postulate Bicategory BinarySearchTree Binding_Syntax_Theory Binomial-Heaps Binomial-Queues BirdKMP Blue_Eyes Bondy Boolean_Expression_Checkers Bounded_Deducibility_Security Buchi_Complementation Budan_Fourier Buffons_Needle Buildings BytecodeLogicJmlTypes C2KA_DistributedSystems CAVA_Automata CAVA_LTL_Modelchecker CCS CISC-Kernel CRDT CSP_RefTK CYK 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 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 CoSMed CoSMeDis Count_Complex_Roots CryptHOL CryptoBasedCompositionalProperties Cubic_Quartic_Equations DFS_Framework DOM_Components DPT-SAT-Solver DataRefinementIBP Datatype_Order_Generator Decl_Sem_Fun_PL Decreasing-Diagrams Decreasing-Diagrams-II Deep_Learning Delta_System_Lemma Density_Compiler Dependent_SIFUM_Refinement Dependent_SIFUM_Type_Systems Depth-First-Search Derangements Deriving Descartes_Sign_Rule Design_Theory Dict_Construction Differential_Dynamic_Logic Differential_Game_Logic Dijkstra_Shortest_Path Diophantine_Eqns_Lin_Hom Dirichlet_L Dirichlet_Series DiscretePricing Discrete_Summation DiskPaxos Dominance_CHK DynamicArchitectures Dynamic_Tables E_Transcendental Echelon_Form EdmondsKarp_Maxflow Efficient-Mergesort Elliptic_Curves_Group_Law Encodability_Process_Calculi Epistemic_Logic Ergodic_Theory Error_Function Euler_MacLaurin Euler_Partition Example-Submission Extended_Finite_State_Machine_Inference Extended_Finite_State_Machines FFT FLP FOL-Fitting FOL_Axiomatic FOL_Harrison FOL_Seq_Calc1 Factored_Transition_System_Bounding Falling_Factorial_Sum Farkas FeatherweightJava Featherweight_OCL Fermat3_4 FileRefinement FinFun Finger-Trees Finite-Map-Extras Finite_Automata_HF Finitely_Generated_Abelian_Groups First_Order_Terms First_Welfare_Theorem Fishburn_Impossibility Fisher_Yates Flow_Networks Floyd_Warshall Flyspeck-Tame FocusStreamsCaseStudies Forcing Formal_Puiseux_Series Formal_SSA Formula_Derivatives Fourier Free-Boolean-Algebra Free-Groups Fresh_Identifiers FunWithFunctions FunWithTilings Functional-Automata Functional_Ordered_Resolution_Prover Furstenberg_Topology GPU_Kernel_PL Gabow_SCC GaleStewart_Games Game_Based_Crypto Gauss-Jordan-Elim-Fun Gauss_Jordan Gauss_Sums Gaussian_Integers GenClock General-Triangle Generalized_Counting_Sort Generic_Deriving Generic_Join GewirthPGCProof Girth_Chromatic GoedelGod Goedel_HFSet_Semantic Goedel_HFSet_Semanticless Goedel_Incompleteness Goodstein_Lambda GraphMarkingIBP Graph_Saturation Graph_Theory Green Groebner_Bases Groebner_Macaulay Gromov_Hyperbolicity Grothendieck_Schemes Group-Ring-Module HOL-CSP HOLCF-Prelude HRB-Slicing Heard_Of Hello_World HereditarilyFinite Hermite Hermite_Lindemann Hidden_Markov_Models Higher_Order_Terms Hoare_Time Hood_Melville_Queue HotelKeyCards Huffman Hybrid_Logic Hybrid_Multi_Lane_Spatial_Logic Hybrid_Systems_VCs HyperCTL IEEE_Floating_Point IFC_Tracking IMAP-CRDT IMO2019 IMP2 IMP2_Binary_Heap IMP_Compiler IP_Addresses Imperative_Insertion_Sort Impossible_Geometry Incompleteness Incredible_Proof_Machine Inductive_Confidentiality Inductive_Inference InfPathElimination InformationFlowSlicing InformationFlowSlicing_Inter Integration Interpreter_Optimizations Interval_Arithmetic_Word32 Intro_Dest_Elim Iptables_Semantics Irrational_Series_Erdos_Straus Irrationality_J_Hancl IsaGeoCoq Isabelle_C Isabelle_Marries_Dirac Isabelle_Meta_Model Jacobson_Basic_Algebra Jinja JinjaDCI JinjaThreads JiveDataStoreModel Jordan_Hoelder Jordan_Normal_Form KAD KAT_and_DRA KBPs KD_Tree Key_Agreement_Strong_Adversaries Kleene_Algebra Knot_Theory Knuth_Bendix_Order Knuth_Morris_Pratt Koenigsberg_Friendship Kruskal Kuratowski_Closure_Complement LLL_Basis_Reduction LLL_Factorization LOFT LTL LTL_Master_Theorem LTL_Normal_Form LTL_to_DRA LTL_to_GBA Lam-ml-Normalization LambdaAuth LambdaMu Lambda_Free_EPO Lambda_Free_KBOs Lambda_Free_RPOs Lambert_W Landau_Symbols Laplace_Transform Latin_Square LatticeProperties Launchbury Laws_of_Large_Numbers Lazy-Lists-II Lazy_Case Lehmer Lifting_Definition_Option Lifting_the_Exponent LightweightJava LinearQuantifierElim Linear_Inequalities Linear_Programming Linear_Recurrences Liouville_Numbers List-Index List-Infinite List_Interleaving List_Inversions List_Update LocalLexing Localization_Ring Locally-Nameless-Sigma Logging_Independent_Anonymity Lowe_Ontological_Argument Lower_Semicontinuous Lp Lucas_Theorem MFMC_Countable MFODL_Monitor_Optimized MFOTL_Monitor MSO_Regex_Equivalence Markov_Models Marriage Mason_Stothers Matrices_for_ODEs Matrix Matrix_Tensor Matroids Max-Card-Matching Median_Of_Medians_Selection Menger Mereology Mersenne_Primes Metalogic_ProofChecker MiniML MiniSail Minimal_SSA Minkowskis_Theorem Minsky_Machines Modal_Logics_for_NTS Modular_Assembly_Kit_Security Modular_arithmetic_LLL_and_HNF_algorithms Monad_Memo_DP Monad_Normalisation MonoBoolTranAlgebra MonoidalCategory Monomorphic_Monad MuchAdoAboutTwo Multi_Party_Computation Multirelations Myhill-Nerode Name_Carrying_Type_Inference Nash_Williams Nat-Interval-Logic Native_Word Nested_Multisets_Ordinals Network_Security_Policy_Verification Neumann_Morgenstern_Utility No_FTL_observers Nominal2 Noninterference_CSP Noninterference_Concurrent_Composition Noninterference_Generic_Unwinding Noninterference_Inductive_Unwinding Noninterference_Ipurge_Unwinding Noninterference_Sequential_Composition NormByEval Nullstellensatz Octonions OpSets Open_Induction Optics Optimal_BST Orbit_Stabiliser Order_Lattice_Props Ordered_Resolution_Prover Ordinal Ordinal_Partitions Ordinals_and_Cardinals Ordinary_Differential_Equations PAC_Checker PCF PLM POPLmark-deBruijn PSemigroupsConvolution Padic_Ints Pairing_Heap Paraconsistency Parity_Game Partial_Function_MR Partial_Order_Reduction Password_Authentication_Protocol Pell Perfect-Number-Thm Perron_Frobenius Physical_Quantities Pi_Calculus Pi_Transcendental Planarity_Certificates Poincare_Bendixson Poincare_Disc Polynomial_Factorization Polynomial_Interpolation Polynomials Pop_Refinement Posix-Lexing Possibilistic_Noninterference Power_Sum_Polynomials Pratt_Certificate Presburger-Automata Prim_Dijkstra_Simple Prime_Distribution_Elementary Prime_Harmonic_Series Prime_Number_Theorem Priority_Queue_Braun Priority_Search_Trees Probabilistic_Noninterference Probabilistic_Prime_Tests Probabilistic_System_Zoo Probabilistic_Timed_Automata Probabilistic_While Program-Conflict-Analysis Progress_Tracking Projective_Geometry Projective_Measurements Promela Proof_Strategy_Language PropResPI Propositional_Proof_Systems Prpu_Maxflow PseudoHoops Psi_Calculi Ptolemys_Theorem Public_Announcement_Logic QHLProver QR_Decomposition Quantales Quaternions Quick_Sort_Cost RIPEMD-160-SPARK ROBDD RSAPSS Ramsey-Infinite Random_BSTs Random_Graph_Subgraph_Threshold Randomised_BSTs Randomised_Social_Choice Rank_Nullity_Theorem Real_Impl Recursion-Addition Recursion-Theory-I Refine_Imperative_HOL Refine_Monadic RefinementReactive Regex_Equivalence Regression_Test_Selection Regular-Sets Regular_Algebras Relation_Algebra Relational-Incorrectness-Logic Relational_Disjoint_Set_Forests Relational_Forests Relational_Method Relational_Minimum_Spanning_Trees Relational_Paths Rep_Fin_Groups Residuated_Lattices Resolution_FOL Rewriting_Z Ribbon_Proofs Robbins-Conjecture Robinson_Arithmetic Root_Balanced_Tree Routing Roy_Floyd_Warshall SATSolverVerification SC_DOM_Components SDS_Impossibility SIFPL SIFUM_Type_Systems SPARCv8 Safe_Distance Safe_OCL Saturation_Framework Saturation_Framework_Extensions 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 Skew_Heap Skip_Lists Slicing Sliding_Window_Algorithm Smith_Normal_Form Smooth_Manifolds Sort_Encodings Source_Coding_Theorem SpecCheck Special_Function_Bounds Splay_Tree Sqrt_Babylonian Stable_Matching Statecharts Stateful_Protocol_Composition_and_Typing Stellar_Quorums Stern_Brocot Stewart_Apollonius Stirling_Formula Stochastic_Matrices Stone_Algebras Stone_Kleene_Relation_Algebras Stone_Relation_Algebras Store_Buffer_Reduction Stream-Fusion Stream_Fusion_Code Strong_Security Sturm_Sequences Sturm_Tarski Stuttering_Equivalence Subresultants Subset_Boolean_Algebras SumSquares Sunflowers SuperCalc Surprise_Paradox Symmetric_Polynomials Syntax_Independent_Logic Szpilrajn TESL_Language TLA Tail_Recursive_Functions Tarskis_Geometry Taylor_Models Three_Circles Timed_Automata Topological_Semantics Topology TortoiseHare Transcendence_Series_Hancl_Rucki Transformer_Semantics Transition_Systems_and_Automata Transitive-Closure Transitive-Closure-II Treaps Tree-Automata Tree_Decomposition Triangle Trie Twelvefold_Way Tycon Types_Tableaus_and_Goedels_God Types_To_Sets_Extension UPF UPF_Firewall UTP Universal_Turing_Machine UpDown_Scheme Valuation Van_der_Waerden VectorSpace VeriComp Verified-Prover Verified_SAT_Based_AI_Planning VerifyThis2018 VerifyThis2019 Vickrey_Clarke_Groves +Virtual_Substitution VolpanoSmith WHATandWHERE_Security WOOT_Strong_Eventual_Consistency WebAssembly Weighted_Path_Order Weight_Balanced_Trees Well_Quasi_Orders Winding_Number_Eval Word_Lib WorkerWrapper XML ZFC_in_HOL Zeta_3_Irrational Zeta_Function pGCL diff --git a/thys/Virtual_Substitution/DNF.thy b/thys/Virtual_Substitution/DNF.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/DNF.thy @@ -0,0 +1,416 @@ +section "QE Algorithm Proofs" +subsection "DNF" +theory DNF + imports VSAlgos +begin + + +theorem dnf_eval : + "(\(al,fl)\set (dnf \). + (\a\set al. aEval a xs) + \ (\f\set fl. eval f xs)) + = eval \ xs" +proof(induction \) + case (And \1 \2) + define f where "f = (\a. case a of + (al, fl) \ (\a\set al. aEval a xs) \ (\f\set fl. eval f xs))" + have h1:"(\a\set (dnf (And \1 \2)). f a) = (\a\set (dnf \1). \a'\set(dnf \2). f a \ f a')" + apply simp unfolding f_def apply auto + apply blast + apply blast + subgoal for a b c d + apply(rule bexI[where x="(a,b)"]) + apply(rule exI[where x="a@c"]) + apply(rule exI[where x="b@d"]) + by auto + done + also have h2 : "... = ((\a\set (dnf \1). f a)\(\a\set(dnf \2). f a))" + by auto + show ?case unfolding f_def[symmetric] unfolding h1 h2 unfolding f_def using And by auto +qed auto + + +theorem dnf_modified_eval : + "(\(al,fl,n)\set (dnf_modified \). + (\L. (length L = n + \ (\a\set al. aEval a (L@xs)) + \ (\f\set fl. eval f (L@xs))))) = eval \ xs" +proof(induction \ arbitrary:xs) + case (Atom x) + then show ?case + by (cases x, auto) +next + case (And \1 \2) + {fix d1 d2 A A' B B' L1 L2 + assume A : "(A,A',length (L1::real list))\set (dnf_modified \1)" and "(B,B',length (L2::real list))\set (dnf_modified \2)" + have "( + (\a\set ((map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B)). aEval a ((L1@L2) @ xs)) + \ (\f\set ( map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). eval f ((L1@L2) @ xs))) = + ( + (\a\set(map (liftAtom (length L1) (length L2)) A) \ set( map (liftAtom 0 (length L1)) B). aEval a ((L1@L2) @ xs)) + \ (\f\set( map (liftFm (length L1) (length L2)) A') \ set(map (liftFm 0 (length L1)) B'). eval f ((L1@L2) @ xs)))" + by auto + also have "... = ( + (\a\set(map (liftAtom (length L1) (length L2)) A).aEval a ((L1@L2) @ xs)) + \ (\a\set(map (liftAtom 0 (length L1)) B). aEval a ((L1@L2) @ xs)) + \ (\f\set(map (liftFm (length L1) (length L2)) A').eval f ((L1@L2) @ xs)) + \ (\f\set(map (liftFm 0 (length L1)) B'). eval f ((L1@L2) @ xs)))" + by blast + also have "... = ( + (\a\set A. aEval (liftAtom (length L1) (length L2) a) ((L1@L2) @ xs)) + \ (\a\set B. aEval (liftAtom 0 (length L1) a) ((L1@L2) @ xs)) + \ (\f\set A'. eval (liftFm (length L1) (length L2) f) ((L1@L2) @ xs)) + \ (\f\set B'. eval (liftFm 0 (length L1) f) ((L1@L2) @ xs)))" + by simp + also have "... = ( + (\a\set A. aEval (liftAtom (length L1) (length L2) a) (insert_into (L1 @ xs) (length L1) L2)) + \ (\a\set B. aEval (liftAtom 0 (length L1) a) (insert_into (L2 @ xs) 0 L1)) + \ (\f\set A'. eval (liftFm (length L1) (length L2) f) (insert_into (L1 @ xs) (length L1) L2)) + \ (\f\set B'. eval (liftFm 0 (length L1) f) (insert_into (L2 @ xs) 0 L1)))" + by auto + also have "... = ( + ((\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + ((\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs))) )" + proof safe + fix a + show "\a\set A. aEval (liftAtom (length L1) (length L2) a) (insert_into (L1 @ xs) (length L1) L2) \ + a \ set A \ aEval a (L1 @ xs)" + using eval_liftFm[of L2 "length L2" "length L1" "L1 @ xs" "Atom a", OF refl] + by auto + next + fix f + show "\f\set A'. eval (liftFm (length L1) (length L2) f) (insert_into (L1 @ xs) (length L1) L2) \ + f \ set A' \ eval f (L1 @ xs)" + using eval_liftFm[of L2 "length L2" "length L1" "L1 @ xs" f, OF refl] by auto + next + fix a + show " \a\set B. aEval (liftAtom 0 (length L1) a) (insert_into (L2 @ xs) 0 L1) \ + a \ set B \ aEval a (L2 @ xs)" + using eval_liftFm[of L1 "length L1" "0" "L2@xs" "Atom a", OF refl] by auto + next + fix f + show " \f\set B'. eval (liftFm 0 (length L1) f) (insert_into (L2 @ xs) 0 L1) \ f \ set B' \ eval f (L2 @ xs)" + using eval_liftFm[of L1 "length L1" "0" "L2 @ xs" f, OF refl] by auto + next + fix a + show " \a\set A. aEval a (L1 @ xs) \ + a \ set A \ aEval (liftAtom (length L1) (length L2) a) (insert_into (L1 @ xs) (length L1) L2)" + using eval_liftFm[of L2 "length L2" "length L1" "L1 @ xs" "Atom a", OF refl] by auto + next + fix a + show "\a\set B. aEval a (L2 @ xs) \ a \ set B \ aEval (liftAtom 0 (length L1) a) (insert_into (L2 @ xs) 0 L1)" + using eval_liftFm[of L1 "length L1" "0" "L2@xs" "Atom a", OF refl] by auto + next + fix f + show "\f\set A'. eval f (L1 @ xs) \ + f \ set A' \ eval (liftFm (length L1) (length L2) f) (insert_into (L1 @ xs) (length L1) L2)" + using eval_liftFm[of L2 "length L2" "length L1" "L1 @ xs" f, OF refl] by auto + next + fix f + show "\f\set B'. eval f (L2 @ xs) \ f \ set B' \ eval (liftFm 0 (length L1) f) (insert_into (L2 @ xs) 0 L1)" + using eval_liftFm[of L1 "length L1" "0" "L2 @ xs" f, OF refl] by auto + qed + finally have "( + (\a\set ((map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B)). aEval a ((L1@L2) @ xs)) + \ (\f\set ( map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). eval f ((L1@L2) @ xs))) = ( + ((\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + ((\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs))) )" + by simp + } + then have h : "(\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (\L1.\L2. length L1 = d1 \ length L2 = d2 \ + (\a\set ((map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B)). aEval a ((L1@L2) @ xs)) + \ (\f\set ( map (liftFm d1 d2) A' @ map (liftFm 0 d1) B'). eval f ((L1@L2) @ xs)))) = ((\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set(dnf_modified \2). + (\L1. length L1 = d1 \ (\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + (\L2. length L2 = d2 \ (\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs))) ))" + proof safe + fix A A' B B' L1 L2 + assume prev : "(\A A' L1 B B' L2. + (A, A', length L1) \ set (dnf_modified \1) \ + (B, B', length L2) \ set (dnf_modified \2) \ + ((\a\set (map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B). + aEval a ((L1 @ L2) @ xs)) \ + (\f\set (map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). + eval f ((L1 @ L2) @ xs))) = + (((\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + (\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs))))" + and A: "(A,A',length L1)\set (dnf_modified \1)" and B: "(B,B',length L2)\set (dnf_modified \2)" + and h1 : "\a\set (map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B). + aEval a ((L1 @ L2) @ xs)" + and h2 : "\f\set (map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). + eval f ((L1 @ L2) @ xs)" + have h : "((\a\set (map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B). + aEval a ((L1 @ L2) @ xs)) \ + (\f\set (map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). + eval f ((L1 @ L2) @ xs))) = + (((\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + (\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs)))" + using prev[where A="A", where A'="A'", where B="B", where B'="B'"] A B by simp + show "\(A, A', d1)\set (dnf_modified \1). + \(B, B', d2)\set (dnf_modified \2). + (\L1. length L1 = d1 \ (\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + (\L2. length L2 = d2 \ (\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs)))" + apply (rule bexI[where x="(A, A', length L1)", OF _ A]) + apply auto defer + apply (rule bexI[where x="(B, B', length L2)", OF _ B]) + apply auto + using h h1 h2 + by auto + next + fix A A' d1 B B' d2 L1 L2 + assume prev : "(\A A' L1 B B' L2. + (A, A', length L1) \ set (dnf_modified \1) \ + (B, B', length L2) \ set (dnf_modified \2) \ + ((\a\set (map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B). + aEval a ((L1 @ L2) @ xs)) \ + (\f\set (map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). + eval f ((L1 @ L2) @ xs))) = + (((\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + (\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs))))" + and A: "(A,A',length L1)\set (dnf_modified \1)" and B: "(B,B',length L2)\set (dnf_modified \2)" + and h1 : "\a\set A. aEval a (L1 @ xs)" "\f\set A'. eval f (L1 @ xs)" + "\a\set B. aEval a (L2 @ xs)" "\f\set B'. eval f (L2 @ xs)" + have h : "((\a\set (map (liftAtom (length L1) (length L2)) A @ map (liftAtom 0 (length L1)) B). + aEval a ((L1 @ L2) @ xs)) \ + (\f\set (map (liftFm (length L1) (length L2)) A' @ map (liftFm 0 (length L1)) B'). + eval f ((L1 @ L2) @ xs))) = + (((\a\set A. aEval a (L1 @ xs)) \ (\f\set A'. eval f (L1 @ xs))) \ + (\a\set B. aEval a (L2 @ xs)) \ (\f\set B'. eval f (L2 @ xs)))" + using prev[where A="A", where A'="A'", where B="B", where B'="B'"] h1 A B by simp + show "\(A, A', d1)\set (dnf_modified \1). + \(B, B', d2)\set (dnf_modified \2). + \L1 L2. + length L1 = d1 \ + length L2 = d2 \ + (\a\set (map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B). aEval a ((L1 @ L2) @ xs)) \ + (\f\set (map (liftFm d1 d2) A' @ map (liftFm 0 d1) B'). eval f ((L1 @ L2) @ xs))" + apply (rule bexI[where x="(A, A', length L1)", OF _ A]) + apply auto defer + apply (rule bexI[where x="(B, B', length L2)", OF _ B]) + apply auto + apply (rule exI[where x="L1"]) + apply auto + apply (rule exI[where x="L2"]) + apply auto + using h h1 by auto + qed + + define f where "f (x:: (atom list * atom fm list * nat)) = (case x of (al,fl,n) \ (\L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))))" for x + define g where "((g (uuaa::atom list) (uua::atom fm list) (uu::nat) x):: (atom list * atom fm list * nat)) = ( + case x of + (B, B', d2) \ + (map (liftAtom uu d2) uuaa @ map (liftAtom 0 uu) B, + map (\x. map_fm_binders (\a x. liftAtom (uu + x) d2 a) x 0) uua @ + map (\x. map_fm_binders (\a x. liftAtom (0 + x) uu a) x 0) B', + uu + d2))" for uuaa uua uu x + + define f' where "f' L A A' d1 B B' d2 = ((\a\set ((map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B)). aEval a (L @ xs)) + \ (\f\set ( map (liftFm d1 d2) A' @ map (liftFm 0 d1) B'). eval f (L @ xs)))" for L A A' d1 B B' d2 + have "(\(al, fl, n)\set (dnf_modified (And \1 \2)). + \L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))) + = (\y\set (dnf_modified (And \1 \2)). f y)" + unfolding f_def by simp + also have "... = (\y\set (dnf_modified \1). + \a aa b. + (\uu uua uuaa. + (uuaa, uua, uu) = y \ + (a, aa, b) + \ (g uuaa uua uu) ` + set (dnf_modified \2)) \ + f (a, aa, b))" + using g_def by simp + also have "... = (\(A,A',d1)\set (dnf_modified \1). + \x\set (dnf_modified \2). + f (g A A' d1 x))" + by (smt case_prodE f_def imageE image_eqI prod.simps(2)) + also have "... = (\(A,A',d1)\set (dnf_modified \1). + \x\set (dnf_modified \2). + f (case x of (B,B',d2) \ (map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B, + map (\x. liftFm d1 d2 x) A' @ + map (\x. liftFm 0 d1 x) B', + d1 + d2)))" + using g_def by simp + also have "... = (\(A,A',d1)\set (dnf_modified \1). \x\set (dnf_modified \2). + (case (case x of (B,B',d2) \ (map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B, + map (\x. liftFm d1 d2 x) A' @ map (\x. liftFm 0 d1 x) B', + d1 + d2)) of (al,fl,n) \ (\L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs)))) +)" + using f_def by simp + also have "... = (\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (case ((map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B, + map (\x. liftFm d1 d2 x) A' @ map (\x. liftFm 0 d1 x) B', + d1 + d2)) of (al,fl,n) \ (\L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs)))) +)" + by(smt case_prodE case_prodE2 old.prod.case) + also have "... = (\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (\L. length L = d1 + d2 \ + (\a\set ((map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B)). aEval a (L @ xs)) + \ (\f\set ( map (liftFm d1 d2) A' @ map (liftFm 0 d1) B'). eval f (L @ xs))))" + by(smt case_prodE case_prodE2 old.prod.case) + also have "... = (\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (\L. length L = d1 + d2 \ (f' L A A' d1 B B' d2)))" + using f'_def by simp + also have "... = (\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (\L1.\L2. length L1 = d1 \ length L2 = d2 \ (f' (L1@L2) A A' d1 B B' d2)))" + proof safe + fix A A' d1 B B' d2 L + assume A: "(A,A',d1)\set (dnf_modified \1)" and B: "(B,B',d2)\set (dnf_modified \2)" + and L: "length L = d1 + d2" "(f' L A A' d1 B B' d2)" + show "\(A, A', d1)\set (dnf_modified \1). + \(B, B', d2)\set (dnf_modified \2). \L1 L2. length L1 = d1 \ length L2 = d2 \ f' (L1 @ L2) A A' d1 B B' d2" + apply (rule bexI[where x="(A, A', d1)", OF _ A]) + apply auto + apply (rule bexI[where x="(B, B', d2)", OF _ B]) + apply auto + apply (rule exI[where x="take d1 L"]) + apply auto defer + apply (rule exI[where x="drop d1 L"]) + using L + by auto + next + fix A A' d1 B B' d2 L1 L2 + assume A: "(A,A', length L1)\set (dnf_modified \1)" and B: "(B,B',length L2)\set (dnf_modified \2)" + and L: "(f' (L1 @ L2) A A' (length L1) B B' (length L2))" + thm exI + thm bexI + show "\(A, A', d1)\set (dnf_modified \1). \(B, B', d2)\set (dnf_modified \2). \L. length L = d1 + d2 \ f' L A A' d1 B B' d2 " + apply (rule bexI[where x="(A, A', length L1)", OF _ A]) + apply auto + apply (rule bexI[where x="(B, B', length L2)", OF _ B]) + apply auto + apply (rule exI[where x="L1 @ L2"]) + using L + by auto + qed + + also have "... = (\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (\L1.\L2. length L1 = d1 \ length L2 = d2 \ + (\a\set ((map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B)). aEval a ((L1@L2) @ xs)) + \ (\f\set ( map (liftFm d1 d2) A' @ map (liftFm 0 d1) B'). eval f ((L1@L2) @ xs))))" + unfolding f'_def by simp + (*also have "... = (\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set (dnf_modified \2). + (\L1.\L2. length L1 = d1 \ length L2 = d2 \ + (\a\set (map (liftAtom d1 d2) A) \ set ( map (liftAtom 0 d1) B). aEval a ((L1@L2) @ xs)) + \ (\f\set ( map (liftFm d1 d2) A' @ map (liftFm 0 d1) B'). eval f ((L1@L2) @ xs))))" + proof - + have *: "(\a\set (map (liftAtom d1 d2) A @ map (liftAtom 0 d1) B). aEval a ((L1 @ L2) @ xs)) + = (\a\set (map (liftAtom d1 d2) A) \ set ( map (liftAtom 0 d1) B). aEval a ((L1@L2) @ xs))" + for d1 d2 A B L1 L2 by auto + then show ?thesis apply (subst * ) .. + qed (* + apply (rule bex_cong[OF refl]) + unfolding split_beta + apply (rule bex_cong[OF refl]) + apply (rule ex_cong1)+ + apply (rule conj_cong refl)+ + by auto *) + *) + also have "... = ((\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set(dnf_modified \2). + (\L. length L = d1 \ (\a\set A. aEval a (L @ xs)) \ (\f\set A'. eval f (L @ xs))) \ + (\L. length L = d2 \ (\a\set B. aEval a (L @ xs)) \ (\f\set B'. eval f (L @ xs))) ))" + using h by simp + also have "... = ((\(A,A',d1)\set (dnf_modified \1). \(B,B',d2)\set(dnf_modified \2). + f (A,A',d1) \ + f (B,B',d2)))" + using f_def by simp + also have "... = ((\a\set (dnf_modified \1). \a1\set(dnf_modified \2). f a \ f a1))" + by (simp add: Bex_def_raw) + also have "... = ((\a\set (dnf_modified \1). f a) \ (\a\set (dnf_modified \2). f a))" + by blast + also have "... = eval (And \1 \2) xs" + using And f_def by simp + finally have "(\(al, fl, n)\set (dnf_modified (And \1 \2)). + \L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))) = + eval (And \1 \2) xs" + by simp + then show ?case by simp +next + case (Or \1 \2) + have h1 : "eval (Or \1 \2) xs = eval \1 xs \ eval \2 xs" + using eval.simps(5) by blast + have h2 : "set (dnf_modified (Or \1 \2)) = set(dnf_modified \1) \ set(dnf_modified \2)" + by simp + show ?case using Or h1 h2 + by (metis (no_types, lifting) Un_iff eval.simps(5)) +next + case (ExQ \) + have h1 : "((\x. (\(al, fl, n)\set (dnf_modified \). + \L. length L = n \ (\a\set al. aEval a (L @ (x#xs))) \ (\f\set fl. eval f (L @ (x#xs))))) + = + (\(al, fl, n)\set (dnf_modified \). + (\x.\L. length L = n \ (\a\set al. aEval a ((L@[x]) @ xs)) \ (\f\set fl. eval f ((L@[x]) @ xs)))))" + apply simp by blast + { fix n al fl + define f where "f L = (length (L:: real list) = ((n::nat)+1) \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs)))" for L + have "(\x.\L. f (L@[x])) = (\L. f L)" + by (metis (full_types) One_nat_def add_Suc_right f_def list.size(3) nat.simps(3) rev_exhaust) + then have "((\x. \L. length (L@[x]) = (n+1) \ (\a\set al. aEval a ((L@[x]) @ xs)) \ (\f\set fl. eval f ((L@[x]) @ xs))) + = + (\L. length L = (n+1) \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))))" + unfolding f_def by simp + } + then have h2 : "\n al fl. ( + (\x. \L. length (L@[x]) = (n+1) \ (\a\set al. aEval a ((L@[x]) @ xs)) \ (\f\set fl. eval f ((L@[x]) @ xs))) + = + (\L. length L = (n+1) \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))) + )" + by simp + { fix al fl n + define f where "f al fl n = (\L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs)))" for al fl n + have "f al fl (n+1) = (case (case (al, fl, n) of (A, A', d) \ (A, A',d+1)) of + (al, fl, n) \ f al fl n)" + by simp + then have "(\L. length L = (n+1) \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))) + = ( + case (case (al, fl, n) of (A, A', d) \ (A, A',d+1)) of + (al, fl, n) \ + \L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs)))" + unfolding f_def by simp + } + then have h3 : " + (\(al, fl, n)\set (dnf_modified \). + \L. length L = (n+1) \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))) + = (\a\set (dnf_modified \). + case (case a of (A, A', d) \ (A, A',d+1)) of + (al, fl, n) \ + \L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs)))" + by (smt case_prodE case_prodI2) (* takes a second *) + show ?case using ExQ h1 h2 h3 by simp +next + case (ExN x1 \) + + show ?case + apply simp proof safe + fix a aa b L + have takedrop: "(take b L @ drop b L @ xs) = (L @ xs)" by auto + assume h: "(a, aa, b) \ set (dnf_modified \)" "length L = b + x1" "\a\set a. aEval a (L @ xs)" "\f\set aa. eval f (L @ xs)" + show "\l. length l = x1 \ eval \ (l @ xs)" + apply(rule exI[where x="drop b L"]) + apply auto + using h(2) apply simp + unfolding ExN[symmetric] + apply(rule bexI[where x="(a,aa,b)"]) + apply simp + apply(rule exI[where x="take b L"]) + apply auto + using h apply simp + unfolding takedrop + using h by auto + next + fix l + assume h: "eval \ (l @ xs)" "x1 = length l" + obtain al fl n where h1 : "(al, fl, n)\set (dnf_modified \)" "\L. length L = n \ (\a\set al. aEval a (L @ l @ xs)) \ (\f\set fl. eval f (L @ l @ xs))" + using h(1) unfolding ExN[symmetric] + by blast + obtain L where h2 : "length L = n" "(\a\set al. aEval a (L @ l @ xs))" "(\f\set fl. eval f (L @ l @ xs))" using h1(2) by metis + show "\x\set (dnf_modified \). + case case x of (A, A', d) \ (A, A', d + length l) of + (al, fl, n) \ \L. length L = n \ (\a\set al. aEval a (L @ xs)) \ (\f\set fl. eval f (L @ xs))" + apply(rule bexI[where x="(al,fl,n)"]) + apply simp + apply(rule exI[where x="L@l"]) + apply auto + using h2 h1 by auto + qed +qed auto +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/DNFUni.thy b/thys/Virtual_Substitution/DNFUni.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/DNFUni.thy @@ -0,0 +1,100 @@ +subsection "Overall General VS Proofs" +theory DNFUni + imports QE InfinitesimalsUni +begin + +fun DNFUni :: "atomUni fmUni \ atomUni list list" where + "DNFUni (AtomUni a) = [[a]]"| + "DNFUni (TrueFUni) = [[]]" | + "DNFUni (FalseFUni) = []"| + "DNFUni (AndUni A B) = [A' @ B'. A' \ DNFUni A, B' \ DNFUni B]"| + "DNFUni (OrUni A B) = DNFUni A @ DNFUni B" + +lemma eval_DNFUni : "evalUni F x = evalUni (list_disj_Uni(map (list_conj_Uni o (map AtomUni)) (DNFUni F))) x" +proof(induction F) + case TrueFUni + then show ?case by auto +next + case FalseFUni + then show ?case by auto +next + case (AtomUni x) + then show ?case by auto +next + case (AndUni F1 F2) + show ?case unfolding DNFUni.simps eval_list_disj_Uni evalUni.simps AndUni List.map_concat List.set_concat apply simp + unfolding eval_list_conj_Uni_append + by blast +next + case (OrUni F1 F2) + then show ?case unfolding DNFUni.simps List.map_append eval_list_disj_Uni List.set_append evalUni.simps + by blast +qed + +fun elimVarUni_atom :: "atomUni list \ atomUni \ atomUni fmUni" where + "elimVarUni_atom F (EqUni (a,b,c)) = +(OrUni + (AndUni + (AndUni (AtomUni (EqUni (0,0,a))) (AtomUni (NeqUni (0,0,b)))) + (list_conj_Uni (map (linearSubstitutionUni b c) F))) + (AndUni (AtomUni (NeqUni (0,0,a))) (AndUni (AtomUni(LeqUni (0,0,-(b^2)+4*a*c))) + (OrUni + (list_conj_Uni (map (quadraticSubUni (-b) 1 (b^2-4*a*c) (2*a)) F)) + (list_conj_Uni (map (quadraticSubUni (-b) (-1) (b^2-4*a*c) (2*a)) F)) + ) + ) + ) +) +" | + "elimVarUni_atom F (LeqUni (a,b,c)) = +(OrUni + (AndUni + (AndUni (AtomUni (EqUni (0,0,a))) (AtomUni (NeqUni (0,0,b)))) + (list_conj_Uni (map (linearSubstitutionUni b c) F))) + (AndUni (AtomUni (NeqUni (0,0,a))) (AndUni (AtomUni(LeqUni (0,0,-(b^2)+4*a*c))) + (OrUni + (list_conj_Uni (map (quadraticSubUni (-b) 1 (b^2-4*a*c) (2*a)) F)) + (list_conj_Uni (map (quadraticSubUni (-b) (-1) (b^2-4*a*c) (2*a)) F)) + ) + ) + ) +) +" | + "elimVarUni_atom F (LessUni (a,b,c)) = +(OrUni + (AndUni + (AndUni (AtomUni (EqUni (0,0,a))) (AtomUni (NeqUni (0,0,b)))) + (list_conj_Uni (map (substInfinitesimalLinearUni b c) F))) + (AndUni (AtomUni (NeqUni (0,0,a))) (AndUni (AtomUni(LeqUni (0,0,-(b^2)+4*a*c))) + (OrUni + (list_conj_Uni (map(substInfinitesimalQuadraticUni (-b) 1 (b^2-4*a*c) (2*a)) F)) + (list_conj_Uni (map(substInfinitesimalQuadraticUni (-b) (-1) (b^2-4*a*c) (2*a)) F)) + ) + ) + ) +) +"| + "elimVarUni_atom F (NeqUni (a,b,c)) = +(OrUni + (AndUni + (AndUni (AtomUni (EqUni (0,0,a))) (AtomUni (NeqUni (0,0,b)))) + (list_conj_Uni (map (substInfinitesimalLinearUni b c) F))) + (AndUni (AtomUni (NeqUni (0,0,a))) (AndUni (AtomUni(LeqUni (0,0,-(b^2)+4*a*c))) + (OrUni + (list_conj_Uni (map(substInfinitesimalQuadraticUni (-b) 1 (b^2-4*a*c) (2*a)) F)) + (list_conj_Uni (map(substInfinitesimalQuadraticUni (-b) (-1) (b^2-4*a*c) (2*a)) F)) + ) + ) + ) +) +" + + + + +fun generalVS_DNF :: "atomUni list \ atomUni fmUni" where + "generalVS_DNF L = list_disj_Uni (list_conj_Uni(map substNegInfinityUni L) # (map (\A. elimVarUni_atom L A) L))" + + + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/Debruijn.thy b/thys/Virtual_Substitution/Debruijn.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/Debruijn.thy @@ -0,0 +1,897 @@ +section "Debruijn Indicies Formulation" +theory Debruijn + imports PolyAtoms +begin +subsection "Lift and Lower Functions" + +text "these functions are required for debruijn notation + the (liftPoly n a p) functions increment each variable greater n in polynomial p by a + the (lowerPoly n a p) functions lower each variable greater than n by a so variables n through n+a-1 shouldn't exist +" +context includes poly_mapping.lifting begin + +definition "inc_above b i x = (if x < b then x else x + i::nat)" +definition "dec_above b i x = (if x \ b then x else x - i::nat)" + +lemma inc_above_dec_above: "x < b \ b + i \ x \ inc_above b i (dec_above b i x) = x" + by (auto simp: inc_above_def dec_above_def) +lemma dec_above_inc_above: "dec_above b i (inc_above b i x) = x" + by (auto simp: inc_above_def dec_above_def) + +lemma inc_above_dec_above_iff: "inc_above b i (dec_above b i x) = x \ x < b \ b + i \ x" + by (auto simp: inc_above_def dec_above_def) + +lemma inj_on_dec_above: "inj_on (dec_above b i) {x. x < b \ b + i \ x}" + by (rule inj_on_inverseI[where g = "inc_above b i"]) (auto simp: inc_above_dec_above) + +lemma finite_inc_above_ne: "finite {x. f x \ c} \ finite {x. f (inc_above b i x) \ c}" +proof - + fix b and f::"nat\'a" + assume f: "finite {x. f x \ c}" + moreover + have "finite {x. f (x + i) \ c}" + proof - + have "{x. f (x + i) \ c} = (+) i -` {x. f x \ c}" + by (auto simp: ac_simps) + also have "finite \" + by (rule finite_vimageI) (use f in auto) + finally show ?thesis . + qed + ultimately have "finite ({x. f x \ c} \ {x. f (x + i) \ c})" + by auto + from _ this show "finite {x. f (inc_above b i x) \ c}" + by (rule finite_subset) (auto simp: inc_above_def) +qed + +lemma finite_dec_above_ne: "finite {x. f x \ c} \ finite {x. f (dec_above b i x) \ c}" +proof - + fix b and f::"nat\'a" + assume f: "finite {x. f x \ c}" + moreover + have "finite {x. f (x - i) \ c}" + proof - + have "{x. f (x - i) \ c} \ {0..i} \ ((\x. x - i) -` {x. f x \ c} \ {i<..})" + by auto + also have "finite \" + apply (rule finite_UnI[OF finite_atLeastAtMost]) + by (rule finite_vimage_IntI) (use f in \auto simp: inj_on_def\) + finally (finite_subset) show ?thesis . + qed + ultimately have "finite ({x. f x \ c} \ {x. f (x - i) \ c} \ {b})" + by auto + from _ this show "finite {x. f (dec_above b i x) \ c}" + by (rule finite_subset) (auto simp: dec_above_def) +qed + +lift_definition lowerPowers::"nat \ nat \ (nat \\<^sub>0 'a) \ (nat \\<^sub>0 'a::zero)" + is "\b i p x. if x \ {b.. 'a" + assume "finite {x. p x \ 0}" + then have "finite {x. p (dec_above b i x) \ 0}" + by (rule finite_dec_above_ne) + from _ this show "finite {x. (if x \ {b.. 0}" + by (rule finite_subset) auto +qed + +lift_definition higherPowers::"nat \ nat \ (nat \\<^sub>0 'a) \ (nat \\<^sub>0 'a::zero)" + is "\b i p x. p (inc_above b i x)::'a" + by (simp_all add: finite_inc_above_ne) + +lemma higherPowers_lowerPowers: "higherPowers n i (lowerPowers n i x) = x" + by transfer (force simp: dec_above_def inc_above_def antisym_conv2) + +lemma inj_lowerPowers: "inj (lowerPowers b i)" + using higherPowers_lowerPowers + by (rule inj_on_inverseI) + +lemma lowerPowers_higherPowers: + "(\j. n \ j \ j < n + i \ lookup x j = 0) \ lowerPowers n i (higherPowers n i x) = x" + by (transfer fixing: n i) (force simp: inc_above_dec_above) + +lemma inj_on_higherPowers: "inj_on (higherPowers n i) {x. \j. n \ j \ j < n + i \ lookup x j = 0}" + using lowerPowers_higherPowers + by (rule inj_on_inverseI) auto + +lemma higherPowers_eq: "lookup (higherPowers b i p) x = lookup p (inc_above b i x)" + by (simp_all add: higherPowers.rep_eq) + +lemma lowerPowers_eq: "lookup (lowerPowers b i p) x = (if b \ x \ x < b + i then 0 else lookup p (dec_above b i x))" + by (auto simp add: lowerPowers.rep_eq) + +lemma keys_higherPowers: "keys (higherPowers b i m) = dec_above b i ` (keys m \ {x. x \ {b..f::"nat \ nat \ (nat, 'a) fmap \ (nat, 'a::zero) fmap" + is "\b i p x. if x \ {b.. 'a option" + assume "finite (dom p)" + then have "finite {x. p x \ None}" by (simp add: dom_def) + + have "dom (\x. p (dec_above b i x)) = {x. p (dec_above b i x) \ None}" + by auto + also have "finite \" + by (rule finite_dec_above_ne) fact + finally + have "finite (dom (\x. p (dec_above b i x)))" . + from _ this + show "finite (dom (\x. if x \ {b..f::"nat \ nat \ (nat, 'a) fmap \ (nat, 'a) fmap" + is "\b i f x. f (inc_above b i x)" +proof - + fix b i::nat and f::"nat \ 'a option" + assume "finite (dom f)" + then have "finite {i. f i \ None}" by (simp add: dom_def) + + have "dom (\x. f (inc_above b i x)) = {x. f (inc_above b i x) \ None}" + by auto + also have "finite \" + by (rule finite_inc_above_ne) fact + finally show "finite (dom (\x. f (inc_above b i x)))" + . +qed + +lemma map_of_map_key_inverse_fun_eq: + "map_of (map (\(k, y). (f k, y)) xs) x = map_of xs (g x)" + if "\x. x \ set xs \ g (f (fst x)) = fst x" "f (g x) = x" + for f::"'a \ 'b" + using that +proof (induction xs) + case Nil + then show ?case by simp +next + case (Cons a xs) + from Cons + have IH: "map_of (map (\a. (f (fst a), snd a)) xs) x = map_of xs (g x)" + by (auto simp: split_beta') + have inv_into: "g (f (fst a)) = fst a" + by (rule Cons) simp + show ?case + using Cons + by (auto simp add: split_beta' inv_into IH) +qed + +lemma map_of_filter_key_in: "P x \ map_of (filter (\(k, v). P k) xs) x = map_of xs x" + by (induction xs) (auto simp: ) + +lemma map_of_eq_NoneI: "x\fst`set xs \ map_of xs x = None" + by (induction xs) (auto simp: ) + +lemma compute_higherPowers\<^sub>f[code]: "higherPowers\<^sub>f b i (fmap_of_list xs) = + fmap_of_list (map (\(k, v). (if k < b then k else k - i, v)) (filter (\(k, v). k \ {b..(k, y). (if k < b then k else k - i, y)) (filter (\(k, v). b \ k \ \ k < b + i) xs)) x = + map_of (filter (\(k, v). b \ k \ \ k < b + i) xs) (if x < b then x else x + i)" + for x + by (rule map_of_map_key_inverse_fun_eq[where g="\k. if k < b then k else k + i" + and f = "\k. if k < b then k else k - i"]) auto + show ?thesis + by (auto + simp add: * higherPowers\<^sub>f.rep_eq lowerPowers\<^sub>f.rep_eq fmlookup_of_list fmlookup_default_def + inc_above_def + map_of_filter_key_in + split: option.splits + intro!: fmap_ext) +qed + +lemma compute_lowerPowers\<^sub>f[code]: "lowerPowers\<^sub>f b i (fmap_of_list xs) = + fmap_of_list (map (\(k, v). (if k < b then k else k + i, v)) xs)" + apply (auto + simp add: lowerPowers\<^sub>f.rep_eq fmlookup_of_list fmlookup_default_def + dec_above_def + map_of_filter_key_in + split: option.splits + intro!: fmap_ext) + subgoal by (rule map_of_eq_NoneI[symmetric]) (auto split: if_splits) + subgoal by (subst map_of_map_key_inverse_fun_eq[where g="\k. if k < b then k else k - i"]) auto + subgoal by (subst map_of_map_key_inverse_fun_eq[where g="\k. if k < b then k else k - i"]) auto + subgoal by (rule map_of_eq_NoneI[symmetric]) (auto split: if_splits) + subgoal by (subst map_of_map_key_inverse_fun_eq[where g="\k. if k < b then k else k - i"]) auto + done + +lemma compute_higherPowers[code]: "higherPowers n i (Pm_fmap xs) = Pm_fmap (higherPowers\<^sub>f n i xs)" + by (rule poly_mapping_eqI) + (auto simp: higherPowers\<^sub>f.rep_eq higherPowers.rep_eq fmlookup_default_def dec_above_def + split: option.splits) + +lemma compute_lowerPowers[code]: "lowerPowers n i (Pm_fmap xs) = Pm_fmap (lowerPowers\<^sub>f n i xs)" + by (rule poly_mapping_eqI) + (auto simp: lowerPowers\<^sub>f.rep_eq lowerPowers.rep_eq fmlookup_default_def dec_above_def + split: option.splits) + +lemma finite_nonzero_coeff: "finite {x. MPoly_Type.coeff mpoly x \ 0}" + by transfer auto + +lift_definition lowerPoly\<^sub>0::"nat \ nat \ ((nat\\<^sub>0nat)\\<^sub>0'a::zero) \ ((nat\\<^sub>0nat)\\<^sub>0 'a)" is + "\b i (mp::(nat\\<^sub>0nat)\'a) mon. mp (lowerPowers b i mon)" +proof - + fix b i and mp::"(nat \\<^sub>0 nat) \ 'a" + assume "finite {x. mp x \ 0}" + have "{x. mp (lowerPowers b i x) \ 0} = (lowerPowers b i -` {x. mp x \ 0})" + (is "?set = ?vimage") + by auto + also + from finite_vimageI[OF \finite _\ inj_lowerPowers] + have "finite ?vimage" . + finally show "finite ?set" . +qed + +lemma higherPowers_zero[simp]: "higherPowers b i 0 = 0" + by transfer auto + +lemma keys_lowerPoly\<^sub>0: "keys (lowerPoly\<^sub>0 b i mp) = higherPowers b i ` (keys mp \ {x. \j\{b..0.rep_eq lowerPowers.rep_eq) + done + subgoal for x + apply (auto simp: in_keys_iff lowerPoly\<^sub>0.rep_eq) + apply (subst (asm) lowerPowers_higherPowers) + apply auto + done + done + + +lift_definition higherPoly\<^sub>0::"nat \ nat \ ((nat\\<^sub>0nat)\\<^sub>0'a::zero) \ ((nat\\<^sub>0nat)\\<^sub>0 'a)" is + "\b i (mp::(nat\\<^sub>0nat)\'a) mon. + if (\j\{b.. 0) + then 0 + else mp (higherPowers b i mon)" +proof - + fix b i and mp::"(nat \\<^sub>0 nat) \ 'a" + assume "finite {x. mp x \ 0}" + have "{x. (if \j\{b.. 0} \ + insert 0 (higherPowers b i -` {x. mp x \ 0} \ {x. \j\{b.. ?vimage") + by auto + also + from finite_vimage_IntI[OF \finite _\ inj_on_higherPowers, of b i] + have "finite ?vimage" by (auto simp: Ball_def) + finally (finite_subset) show "finite ?set" . +qed + + +context includes fmap.lifting begin + +lift_definition lowerPoly\<^sub>f::"nat \ nat \ ((nat\\<^sub>0nat), 'a::zero)fmap \ ((nat\\<^sub>0nat), 'a)fmap" is + "\b i (mp::((nat\\<^sub>0nat)\'a)) mon::(nat\\<^sub>0nat). mp (lowerPowers b i mon)" +proof -\ \TODO: this is exactly the same proof as the one for \lowerPoly\<^sub>0\\ + fix b i and mp::"(nat \\<^sub>0 nat) \ 'a option" + assume "finite (dom mp)" + also have "dom mp = {x. mp x \ None}" by auto + finally have "finite {x. mp x \ None}" . + have "(dom (\mon. mp (lowerPowers b i mon))) = {mon. mp (lowerPowers b i mon) \ None}" + (is "?set = _") + by (auto split: if_splits) + also have "\ = lowerPowers b i -` {x. mp x \ None}" (is "_ = ?vimage") + by auto + also + from finite_vimageI[OF \finite {x. mp x \ None}\ inj_lowerPowers] + have "finite ?vimage" . + finally show "finite ?set" . +qed + +lift_definition higherPoly\<^sub>f::"nat \ nat \ ((nat\\<^sub>0nat), 'a::zero)fmap \ ((nat\\<^sub>0nat), 'a)fmap" is + "\b i (mp::((nat\\<^sub>0nat)\'a)) mon::(nat\\<^sub>0nat). + if (\j\{b.. 0) + then None + else mp (higherPowers b i mon)" +proof - + fix b i and mp::"(nat \\<^sub>0 nat) \ 'a" + assume "finite (dom mp)" + have "dom (\x. (if \j\{b.. + insert 0 (higherPowers b i -` (dom mp) \ {x. \j\{b.. ?vimage") + by (auto split: if_splits) + also + from finite_vimage_IntI[OF \finite _\ inj_on_higherPowers, of b i] + have "finite ?vimage" by (auto simp: Ball_def) + finally (finite_subset) show "finite ?set" . +qed + + +lemma keys_lowerPowers: "keys (lowerPowers b i m) = inc_above b i ` (keys m)" + apply safe + subgoal for x + apply (rule image_eqI[where x="dec_above b i x"]) + apply (auto simp: inc_above_dec_above in_keys_iff lowerPowers.rep_eq) + apply (metis inc_above_dec_above not_less) + by meson + by (metis higherPowers.rep_eq higherPowers_lowerPowers in_keys_iff) + + +lemma keys_higherPoly\<^sub>0: "keys (higherPoly\<^sub>0 b i mp) = lowerPowers b i ` (keys mp)" + apply (auto ) + subgoal for x + apply (rule image_eqI[where x="higherPowers b i x"]) + apply (auto simp: lowerPowers_higherPowers in_keys_iff higherPoly\<^sub>0.rep_eq higherPowers.rep_eq) + apply (metis atLeastLessThan_iff lowerPowers_higherPowers neq0_conv) + by meson + subgoal for x + apply (auto simp: in_keys_iff higherPoly\<^sub>0.rep_eq) + apply (simp add: lowerPowers_eq) + by (simp add: higherPowers_lowerPowers) + done + +end + +lemma inc_above_id[simp]: "n < m \ inc_above m i n = n" by (auto simp: inc_above_def) +lemma inc_above_Suc[simp]: "n \ m \ inc_above m i n = n + i" by (auto simp: inc_above_def) + +lemma compute_lowerPoly\<^sub>0[code]: "lowerPoly\<^sub>0 n i (Pm_fmap m) = Pm_fmap (lowerPoly\<^sub>f n i m)" + by (auto simp: lowerPoly\<^sub>0.rep_eq fmlookup_default_def lowerPoly\<^sub>f.rep_eq + split: option.splits + intro!: poly_mapping_eqI) + +lemma compute_higherPoly\<^sub>0[code]: "higherPoly\<^sub>0 n i (Pm_fmap m) = Pm_fmap (higherPoly\<^sub>f n i m)" + by (auto simp: higherPoly\<^sub>0.rep_eq fmlookup_default_def higherPoly\<^sub>f.rep_eq + split: option.splits + intro!: poly_mapping_eqI) + +lemma compute_lowerPoly\<^sub>f[code]: "lowerPoly\<^sub>f n i (fmap_of_list xs) = + (fmap_of_list (map (\(mon, c). (higherPowers n i mon, c)) + (filter (\(mon, v). \j\{n..f.rep_eq fmlookup_of_list + apply (subst map_of_map_key_inverse_fun_eq[where g="lowerPowers n i"]) + subgoal + by (auto simp add: lowerPowers_higherPowers) + subgoal by (auto simp add: higherPowers_lowerPowers) + apply (auto simp: fmlookup_of_list lowerPoly\<^sub>f.rep_eq map_of_eq_None_iff map_of_filter_key_in + fmdom'_fmap_of_list higherPowers.rep_eq lowerPowers.rep_eq dec_above_def + intro!: fmap_ext) + done + +lemma compute_higherPoly\<^sub>f[code]: "higherPoly\<^sub>f n i (fmap_of_list xs) = + fmap_of_list (filter (\(mon, v). \j\{n..(mon, c). (lowerPowers n i mon, c)) xs))" + apply (rule sym) + apply (rule fmap_ext) + unfolding higherPoly\<^sub>f.rep_eq fmlookup_of_list + apply auto + subgoal + by (rule map_of_eq_NoneI) auto + subgoal + apply (subst map_of_filter_key_in) + apply auto + apply (subst map_of_map_key_inverse_fun_eq[where g="higherPowers n i"]) + subgoal + by (auto simp add: higherPowers_lowerPowers) + subgoal by (auto simp add: lowerPowers_higherPowers) + apply (auto simp: fmlookup_of_list lowerPoly\<^sub>f.rep_eq map_of_eq_None_iff map_of_filter_key_in + fmdom'_fmap_of_list higherPowers.rep_eq lowerPowers.rep_eq dec_above_def + intro!: fmap_ext) + done + done + +end + +lift_definition lowerPoly::"nat \ nat \ 'a::zero mpoly \ 'a mpoly" is lowerPoly\<^sub>0 . +lift_definition liftPoly::"nat \ nat \ 'a::zero mpoly \ 'a mpoly" is higherPoly\<^sub>0 . + +lemma coeff_lowerPoly: "MPoly_Type.coeff (lowerPoly b i mp) x = MPoly_Type.coeff mp (lowerPowers b i x)" + by (transfer') (simp add: lowerPoly\<^sub>0.rep_eq lowerPowers.rep_eq) + +lemma coeff_liftPoly: "MPoly_Type.coeff (liftPoly b i mp) x = (if (\j\{b.. 0) + then 0 + else MPoly_Type.coeff mp (higherPowers b i x))" + by (transfer') (simp add: higherPowers.rep_eq higherPoly\<^sub>0.rep_eq ) + +lemma monomials_lowerPoly: "monomials (lowerPoly b i mp) = higherPowers b i ` (monomials mp \ {x. \j\{b..0) + + +lemma monomials_liftPoly: "monomials (liftPoly b i mp) = lowerPowers b i ` (monomials mp) " + using keys_higherPoly\<^sub>0 + by (simp add: keys_higherPoly\<^sub>0 liftPoly.rep_eq monomials.rep_eq) + + +value [code] "lowerPoly 1 1 (1 * Var 0 + 2 * Var 2 ^ 2 + 3 * Var 3 ^ 4::int mpoly) = (Var 0 + 2 * Var 1^2 + 3 * Var 2^4::int mpoly)" +value [code] "lowerPoly 1 3 (1 * Var 0 + 2 * Var 4 ^ 2 + 3 * Var 5 ^ 4::int mpoly) = (Var 0 + 2 * Var 1^2 + 3 * Var 2^4::int mpoly)" + +value [code] "liftPoly 1 3 (1 * Var 0 + 2 * Var 4 ^ 2 + 3 * Var 5 ^ 4::int mpoly) = (Var 0 + 2 * Var 7^2 + 3 * Var 8^4::int mpoly)" + +fun lowerAtom :: "nat \ nat \ atom \ atom" where + "lowerAtom d amount (Eq p) = Eq(lowerPoly d amount p)"| + "lowerAtom d amount (Less p) = Less(lowerPoly d amount p)"| + "lowerAtom d amount (Leq p) = Leq(lowerPoly d amount p)"| + "lowerAtom d amount (Neq p) = Neq(lowerPoly d amount p)" + +lemma lookup_not_in_vars_eq_zero: "x \ monomials p \ i \ vars p \ lookup x i = 0" + by (meson degree_eq_iff varNotIn_degree) + +lemma nth_dec_above: + assumes "length xs = i" "length ys = j" "k \ {i.. {i.. {x. \j\{i.. {x. \k. i \ k \ k < i + j \ lookup x k = 0}" + by force + have "?lhs = (\m\monomials (lowerPoly i j p). MPoly_Type.coeff (lowerPoly i j p) m * (\k\keys m. (nth_default 0 (prfx @ L)) k ^ lookup m k))" + unfolding insertion_code .. + also have "\ = (\m\monomials p. + MPoly_Type.coeff p m * (\k\keys m. (nth_default 0 (prfx @ xs @ L) k) ^ lookup m k))" + proof (rule sum.reindex_cong) + note inj_on_higherPowers[of i j] + moreover note \monomials p \ _\ + ultimately show "inj_on (higherPowers i j) (monomials p)" + by (rule inj_on_subset) + next + show "monomials (lowerPoly i j p) = higherPowers i j ` monomials p" + unfolding monomials_lowerPoly * .. + next + fix m + assume m: "m \ monomials p" + from m \monomials p \ _\ have "keys m \ {x. x \ {i.. k" "k < i + j" for k + using that by (auto simp: in_keys_iff) + then have "lowerPowers i j (higherPowers i j m) = m" + by (rule lowerPowers_higherPowers) + then have "MPoly_Type.coeff (lowerPoly i j p) (higherPowers i j m) = MPoly_Type.coeff p m" + unfolding coeff_lowerPoly by simp + moreover + have "(\k\keys (higherPowers i j m). (nth_default 0 (prfx @ L)) k ^ lookup (higherPowers i j m) k) = + (\k\keys m. (nth_default 0 (prfx @ xs @ L)) k ^ lookup m k)" + proof (rule prod.reindex_cong) + show "keys (higherPowers i j m) = dec_above i j ` keys m" + unfolding keys_higherPowers using \keys m \ _\ by auto + next + from inj_on_dec_above[of i j] + show "inj_on (dec_above i j) (keys m)" + by (rule inj_on_subset) (use \keys m \ _\ in auto) + next + fix k assume k: "k \ keys m" + from k \keys m \ _\ have "k \ {i..keys m \ _\ + have "inc_above i j (dec_above i j k) = k" + by (subst inc_above_dec_above) auto + then have "lookup (higherPowers i j m) (dec_above i j k) = lookup m k" + unfolding higherPowers.rep_eq by simp + moreover have "nth_default 0 (prfx @ L) (dec_above i j k) = (nth_default 0 (prfx @ xs @ L)) k" + apply (rule nth_dec_above) + using assms \k \ _\ + by auto + ultimately + show "((nth_default 0 (prfx @ L)) (dec_above i j k)) ^ lookup (higherPowers i j m) (dec_above i j k) = ((nth_default 0 (prfx @ xs @ L)) k) ^ lookup m k" + by simp + qed + ultimately + show "MPoly_Type.coeff (lowerPoly i j p) (higherPowers i j m) * (\k\keys (higherPowers i j m). (nth_default 0(prfx @ L)) k ^ lookup (higherPowers i j m) k) = + MPoly_Type.coeff p m * (\k\keys m. (nth_default 0 (prfx @ xs @ L)) k ^ lookup m k)" + by simp + qed + finally show ?thesis + unfolding insertion_code . +qed + +lemma insertion_lowerPoly1: + assumes i_notin: "i \ vars p" + and lprfx: "length prfx = i" + shows "insertion (nth_default 0 (prfx@x#L)) p = insertion (nth_default 0 (prfx@L)) (lowerPoly i 1 p)" + using assms nth_default_def apply simp + by (subst insertion_lowerPoly[where xs="[x]"]) auto + +lemma insertion_lowerPoly01: + assumes i_notin: "0 \ vars p" + shows "insertion (nth_default 0 (x#L)) p = insertion (nth_default 0 L) (lowerPoly 0 1 p)" + using insertion_lowerPoly1[OF assms, of Nil x L] + by simp + +lemma aEval_lowerAtom : "(freeIn 0 (Atom A)) \ (aEval A (x#L) = aEval (lowerAtom 0 1 A) L)" + by (cases A) (simp_all add:insertion_lowerPoly01) + + +fun map_fm_binders :: "(atom \ nat \ atom) \ atom fm \ nat \ atom fm" where + "map_fm_binders f TrueF n = TrueF"| + "map_fm_binders f FalseF n = FalseF"| + "map_fm_binders f (Atom \) n = Atom (f \ n)"| + "map_fm_binders f (And \ \) n = And (map_fm_binders f \ n) (map_fm_binders f \ n)"| + "map_fm_binders f (Or \ \) n = Or (map_fm_binders f \ n) (map_fm_binders f \ n)"| + "map_fm_binders f (ExQ \) n = ExQ(map_fm_binders f \ (n+1))"| + "map_fm_binders f (AllQ \) n = AllQ(map_fm_binders f \ (n+1))"| + "map_fm_binders f (AllN i \) n = AllN i (map_fm_binders f \ (n+i))"| + "map_fm_binders f (ExN i \) n = ExN i (map_fm_binders f \ (n+i))"| + "map_fm_binders f (Neg \) n = Neg(map_fm_binders f \ n)" + + + +fun lowerFm :: "nat \ nat \ atom fm \ atom fm" where + "lowerFm d amount f = map_fm_binders (\a. \x. lowerAtom (d+x) amount a) f 0" + +fun delete_nth :: "nat \ real list \ real list" where + "delete_nth n xs = take n xs @ drop n xs" + +lemma eval_lowerFm_helper : + assumes "freeIn i F" + assumes "length init = i" + shows "eval (lowerFm i 1 F) (init @xs) = eval F (init@[x]@xs)" + using assms +proof(induction F arbitrary : i init) + case TrueF + then show ?case by simp +next + case FalseF + then show ?case by simp +next + case (Atom A) + then show ?case apply(cases A) by (simp_all add: insertion_lowerPoly1) +next + case (And F1 F2) + then show ?case by auto +next + case (Or F1 F2) + then show ?case by auto +next + case (Neg F) + then show ?case by simp +next + case (ExQ F) + have map: "\y. (map_fm_binders (\a x. lowerAtom (i + x) 1 a) F (y + 1)) = (map_fm_binders (\a x. lowerAtom (i + 1 + x) 1 a) F y)" + apply(induction F) by(simp_all) + show ?case apply simp apply(rule ex_cong1) + subgoal for xa + using map[of 0] ExQ(1)[of "Suc i" "xa#init"] ExQ(2) ExQ(3) + by simp + done +next + case (AllQ F) + have map: "\y. (map_fm_binders (\a x. lowerAtom (i + x) 1 a) F (y + 1)) = (map_fm_binders (\a x. lowerAtom (i + 1 + x) 1 a) F y)" + apply(induction F) by(simp_all) + show ?case apply simp apply(rule all_cong1) + subgoal for xa + using map[of 0] AllQ(1)[of "Suc i" "xa#init"] AllQ(2) AllQ(3) + by simp + done +next + case (ExN x1 F) + have map: "\y. (map_fm_binders (\a x. lowerAtom (i + x) 1 a) F (y + x1)) = (map_fm_binders (\a x. lowerAtom (i + x1 + x) 1 a) F y)" + apply(induction F) apply(simp_all add:add.commute add.left_commute) + apply (metis add_Suc) + apply (metis add_Suc) + apply (metis add.assoc) + by (metis add.assoc) + show ?case apply simp apply(rule ex_cong1) + subgoal for l + using map[of 0] ExN(1)[of "i+x1" "l@init"] ExN(2) ExN(3) + by auto + done +next + case (AllN x1 F) + have map: "\y. (map_fm_binders (\a x. lowerAtom (i + x) 1 a) F (y + x1)) = (map_fm_binders (\a x. lowerAtom (i + x1 + x) 1 a) F y)" + apply(induction F) apply(simp_all add:add.commute add.left_commute) + apply (metis add_Suc) + apply (metis add_Suc) + apply (metis add.assoc) + by (metis add.assoc) + show ?case apply simp apply(rule all_cong1) + subgoal for l + using map[of 0] AllN(1)[of "i+x1" "l@init"] AllN(2) AllN(3) + by auto + done +qed + +lemma eval_lowerFm : + assumes h : "freeIn 0 F" + shows " \xs. (eval (lowerFm 0 1 F) xs = eval (ExQ F) xs)" + using eval_lowerFm_helper[OF h] by simp + +fun liftAtom :: "nat \ nat \ atom \ atom" where + "liftAtom d amount (Eq p) = Eq(liftPoly d amount p)"| + "liftAtom d amount (Less p) = Less(liftPoly d amount p)"| + "liftAtom d amount (Leq p) = Leq(liftPoly d amount p)"| + "liftAtom d amount (Neq p) = Neq(liftPoly d amount p)" + + +fun liftFm :: "nat \ nat \ atom fm \ atom fm" where + "liftFm d amount f = map_fm_binders (\a. \x. liftAtom (d+x) amount a) f 0" + +fun insert_into :: "real list \ nat \ real list \ real list" where + "insert_into xs n l = take n xs @ l @ drop n xs" + + +lemma higherPoly\<^sub>0_add : "higherPoly\<^sub>0 x y (p + q) = higherPoly\<^sub>0 x y p + higherPoly\<^sub>0 x y q" + using poly_mapping_eq_iff[where a = "higherPoly\<^sub>0 x y (p + q)", where b = "higherPoly\<^sub>0 x y p + higherPoly\<^sub>0 x y q"] + plus_poly_mapping.rep_eq[where x = "higherPoly\<^sub>0 x y (p + q)", where xa = "higherPoly\<^sub>0 x y p + higherPoly\<^sub>0 x y q"] + apply (auto) + by (simp add: higherPoly\<^sub>0.rep_eq lookup_add poly_mapping_eqI) + +lemma liftPoly_add: "liftPoly w z (a + b) = (liftPoly w z a) + (liftPoly w z b)" + unfolding liftPoly_def apply (auto) +proof - + have h1: "mapping_of (a + b) = mapping_of a + mapping_of b" + by (simp add: plus_mpoly.rep_eq) + have h2: "MPoly (higherPoly\<^sub>0 w z (mapping_of a + mapping_of b)) = + MPoly (higherPoly\<^sub>0 w z (mapping_of a)) + MPoly (higherPoly\<^sub>0 w z (mapping_of b))" + proof - + have h0a: "higherPoly\<^sub>0 w z (mapping_of a + mapping_of b) = (higherPoly\<^sub>0 w z (mapping_of a)) + (higherPoly\<^sub>0 w z (mapping_of b))" + using higherPoly\<^sub>0_add[of w z _ _ ] by auto + then show ?thesis + by (simp add: plus_mpoly.abs_eq) + qed + show "MPoly (higherPoly\<^sub>0 w z (mapping_of (a + b))) = + MPoly (higherPoly\<^sub>0 w z (mapping_of a)) + + MPoly (higherPoly\<^sub>0 w z (mapping_of b))" using h1 h2 by auto +qed + + +lemma vars_lift_add : "vars(liftPoly a b (p+q)) \ vars(liftPoly a b (p))\ vars(liftPoly a b (q))" + using liftPoly_add[of a b p q] + using vars_add[of "liftPoly a b p" "liftPoly a b q"] + by auto + +lemma mapping_of_lift_add : "mapping_of (liftPoly x y (a + b)) = mapping_of (liftPoly x y a) + mapping_of (liftPoly x y b)" + unfolding liftPoly.rep_eq plus_mpoly.rep_eq + using higherPoly\<^sub>0_add . + +lemma coeff_lift_add : "MPoly_Type.coeff (liftPoly x y (a + b)) m = MPoly_Type.coeff (liftPoly x y a) m + MPoly_Type.coeff (liftPoly x y b) m" +proof- + have "MPoly_Type.coeff (liftPoly x y (a + b)) m = MPoly_Type.coeff (liftPoly x y a + liftPoly x y b) m" + apply( simp add : mapping_of_lift_add coeff_def ) using lookup_add + by (simp add: plus_mpoly.rep_eq) + also have "... = MPoly_Type.coeff (liftPoly x y a) m + MPoly_Type.coeff (liftPoly x y b) m" + using MPolyExtension.coeff_add[of "liftPoly x y a" "liftPoly x y b" m] . + finally show ?thesis + by auto +qed + +lemma lift_add : "insertion (f::nat\real) (liftPoly 0 z (a + b)) = insertion f (liftPoly 0 z a + liftPoly 0 z b)" + using liftPoly_add[of 0 z a b] + by simp + +lemma lower_power_zero : "lowerPowers a b 0 = 0" + unfolding lowerPowers_def dec_above_def id_def apply auto + unfolding Poly_Mapping.lookup_zero by auto + +lemma lift_vars_monom : "vars (liftPoly i j ((MPoly_Type.monom m a)::real mpoly)) = (\x. if x\i then x+j else x) ` vars(MPoly_Type.monom m a)" +proof(cases "a=0") + case True + then show ?thesis + by (smt MPolyExtension.monom_zero add.left_neutral add_diff_cancel_right' image_empty liftPoly_add vars_monom_single_cases) +next + case False + have h1: "vars (liftPoly i j (MPoly_Type.monom m a)) = keys (lowerPowers i j m)" + unfolding liftPoly_def + unfolding keys_lowerPowers keys_higherPoly\<^sub>0 vars_def apply auto + apply (smt imageE keys_higherPoly\<^sub>0 keys_lowerPowers lookup_eq_zero_in_keys_contradict lookup_single_not_eq mapping_of_inverse monomials.abs_eq) + by (metis False higherPowers.rep_eq higherPowers_lowerPowers image_eqI in_keys_iff keys_higherPoly\<^sub>0 lookup_single_eq mapping_of_inverse monomials.abs_eq) + show ?thesis + unfolding h1 vars_monom_keys[OF False] + keys_lowerPowers inc_above_def by auto +qed + +lemma lift_clear_vars : "vars (liftPoly i j (p::real mpoly)) \ {i.. {x. \j\{i..ja\{i.. monomials p2 = {}" using sum + by (metis Int_insert_right_if0 inf_bot_right monomials_monom) + have h4 : "monomials (lowerPoly i j (liftPoly i j (p1 + p2))) = monomials (lowerPoly i j (liftPoly i j (p1))) \ monomials (lowerPoly i j (liftPoly i j (p2)))" + using monomials_lowerPoly monomials_liftPoly monomials_add_disjoint[OF h1] + by (simp add: monomials_liftPoly monomials_lowerPoly Int_Un_distrib2 image_Un) + have h5 : "MPoly_Type.coeff (lowerPoly i j (liftPoly i j (p1 + p2))) = MPoly_Type.coeff (lowerPoly i j (liftPoly i j (p1))) + MPoly_Type.coeff (lowerPoly i j (liftPoly i j (p2)))" + unfolding coeff_lowerPoly coeff_liftPoly MPolyExtension.coeff_add by auto + show ?case + unfolding MPolyExtension.coeff_add + unfolding h4 h5 + unfolding monomials_add_disjoint[OF h1] + by (smt IntE coeff_eq_zero_iff disjoint_iff_not_equal finite_monomials h1 higherPowers_lowerPowers imageE monomials_liftPoly monomials_lowerPoly plus_fun_apply sum.IH(1) sum.IH(2) sum.cong sum.union_disjoint + ) +qed +lemma lift_insertion : " \init. + length init = (i::nat) \ + (\I xs. + (insertion (nth_default 0 (init @ xs)) (p::real mpoly)) = (insertion ((nth_default 0) (init @ I @ xs)) (liftPoly i (length I) p)))" +proof safe + fix init I xs + assume "i = length (init::real list)" + then have i_len : "length init = i" by auto + have h: "higherPoly\<^sub>0 i (length (I::real list)) (mapping_of p) \ UNIV" + by simp + have h2 : "vars (liftPoly i (length I) p) \ {i..y. (map_fm_binders (\a x. liftAtom (i + x) (amount) a) F (y + Suc 0)) = (map_fm_binders (\a x. liftAtom (i + 1 + x) amount a) F y)" + apply(induction F) by(simp_all) + show ?case apply simp apply(rule ex_cong1) + subgoal for x + using map[of 0] using ExQ(1)[of "x#init" "i+1"] ExQ(2) + by simp + done +next + case (AllQ F) + have map: "\y. (map_fm_binders (\a x. liftAtom (i + x) (amount) a) F (y + Suc 0)) = (map_fm_binders (\a x. liftAtom (i + 1 + x) amount a) F y)" + apply(induction F) by(simp_all) + show ?case apply simp apply(rule all_cong1) + subgoal for x + using map[of 0] using AllQ(1)[of "x#init" "i+1"] AllQ(2) + by simp + done +next + case (ExN x1 F) + have map: "\y. (map_fm_binders (\a x. liftAtom (i + x) (amount) a) F (y + x1)) = (map_fm_binders (\a x. liftAtom (i + x1 + x) amount a) F y)" + apply(induction F) apply(simp_all add: add.commute add.left_commute) + apply (metis add_Suc) + apply (metis add_Suc) + apply (metis add.assoc) + by (metis add.assoc) + show ?case apply simp apply(rule ex_cong1) + subgoal for l + using map[of 0] ExN(1)[of "l@init" "i+x1"] ExN(2) + by auto + done +next + case (AllN x1 F) + have map: "\y. (map_fm_binders (\a x. liftAtom (i + x) (amount) a) F (y + x1)) = (map_fm_binders (\a x. liftAtom (i + x1 + x) amount a) F y)" + apply(induction F) apply(simp_all add: add.commute add.left_commute) + apply (metis add_Suc) + apply (metis add_Suc) + apply (metis add.assoc) + by (metis add.assoc) + show ?case apply simp apply(rule all_cong1) + subgoal for l + using map[of 0] AllN(1)[of "l@init" "i+x1"] AllN(2) + by auto + done +qed auto + +lemma eval_liftFm : + assumes "length I = amount" + assumes "length L \ d" + shows "eval F L = eval (liftFm d amount F) (insert_into L d I)" +proof - + define init where "init = take d L" + then have "length init = d" using assms by simp + then have "(eval F (init @ (drop d L)) = eval (liftFm d amount F) (init @ I @ (drop d L)))" + using eval_liftFm_helper[of init d I amount F "(drop d L)"] assms by auto + then show ?thesis + unfolding insert_into.simps assms init_def by auto +qed + + +lemma not_in_lift : "var\vars(p::real mpoly) \ var+z\vars(liftPoly 0 z p)" +proof(induction p rule: mpoly_induct) + case (monom m a) + then show ?case + using lift_vars_monom[of 0 z m a] by auto +next + case (sum p1 p2 m a) + show ?case + using sum using vars_lift_add[of 0 z p1 p2] + vars_add[of p1 p2] + by (metis (no_types, lifting) Set.basic_monos(7) Un_iff monomials.rep_eq vars_add_monom) +qed + +lemma lift_const : "insertion f (liftPoly 0 z (Const (C::real))) = insertion f (Const C :: real mpoly)" + apply(cases "C=0") + unfolding insertion_code monomials_Const coeff_Const monomials_liftPoly apply auto + unfolding lower_power_zero[of 0 z] lookup_zero power.power_0 comm_monoid_mult_class.prod.neutral_const coeff_liftPoly coeff_Const + unfolding higherPowers_def by auto + +lemma liftPoly_sub: "liftPoly 0 z (a - b) = (liftPoly 0 z a) - (liftPoly 0 z b)" + unfolding liftPoly_def apply (auto) +proof - + have h1: "mapping_of (a - b) = mapping_of a - mapping_of b" + by (simp add: minus_mpoly.rep_eq) + have h2: "MPoly (higherPoly\<^sub>0 0 z (mapping_of a - mapping_of b)) = + MPoly (higherPoly\<^sub>0 0 z (mapping_of a)) - MPoly (higherPoly\<^sub>0 0 z (mapping_of b))" + proof - + have h0a: "higherPoly\<^sub>0 0 z (mapping_of a - mapping_of b) = (higherPoly\<^sub>0 0 z (mapping_of a)) - (higherPoly\<^sub>0 0 z (mapping_of b))" + using poly_mapping_eq_iff[where a = "higherPoly\<^sub>0 0 z (mapping_of a - mapping_of b)", where b = "(higherPoly\<^sub>0 0 z (mapping_of a)) - (higherPoly\<^sub>0 0 z (mapping_of b))"] + minus_poly_mapping.rep_eq[where x = "higherPoly\<^sub>0 0 z (mapping_of a - mapping_of b)", where xa = "(higherPoly\<^sub>0 0 z (mapping_of a)) - (higherPoly\<^sub>0 0 z (mapping_of b))"] + apply (auto) + by (simp add: higherPoly\<^sub>0.rep_eq poly_mapping_eqI minus_poly_mapping.rep_eq) + then show ?thesis + by (simp add: minus_mpoly.abs_eq) + qed + show "MPoly (higherPoly\<^sub>0 0 z (mapping_of (a - b))) = + MPoly (higherPoly\<^sub>0 0 z (mapping_of a)) - + MPoly (higherPoly\<^sub>0 0 z (mapping_of b))" using h1 h2 by auto +qed + +lemma lift_sub : "insertion (f::nat\real) (liftPoly 0 z (a - b)) = insertion f (liftPoly 0 z a - liftPoly 0 z b)" + using liftPoly_sub[of "z" "a" "b"] by auto + +lemma lift_minus : + assumes "insertion (f::nat \ real) (liftPoly 0 z (c - Const (C::real))) = 0" + shows "insertion f (liftPoly 0 z c) = C" +proof- + have "insertion f (liftPoly 0 z (c - Const C)) = insertion f ((liftPoly 0 z c) - (liftPoly 0 z (Const C)))" + by (simp add: lift_sub) + have "... = insertion f (liftPoly 0 z c) - (insertion f (liftPoly 0 z (Const C)))" + using insertion_sub by auto + also have "... = insertion f (liftPoly 0 z c) - C" + using lift_const[of f z C] insertion_const by auto + then show ?thesis + using \insertion f (liftPoly 0 z (c - Const C)) = insertion f (liftPoly 0 z c - liftPoly 0 z (Const C))\ assms calculation by auto +qed + +end + +lemma lift00 : "liftPoly 0 0 (a::real mpoly) = a" + unfolding liftPoly_def apply auto + unfolding higherPoly\<^sub>0_def apply auto + unfolding higherPowers_def apply auto + by (simp add: mapping_of_inverse) + +end diff --git a/thys/Virtual_Substitution/EliminateVariable.thy b/thys/Virtual_Substitution/EliminateVariable.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/EliminateVariable.thy @@ -0,0 +1,683 @@ +subsection "Lemmas of the elimVar function" + +theory EliminateVariable + imports LinearCase QuadraticCase "HOL-Library.Quadratic_Discriminant" +begin + + + + +lemma elimVar_eq : + assumes hlength : "length xs = var" + assumes in_list : "Eq p \ set(L)" + assumes low_pow : "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + shows "((\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = + ((\x. eval (elimVar var L F (Eq p)) (xs @ x # \)))\ (\x. aEval (Eq p) (xs @ x # \)))" +proof- + + { fix x + define A where "A = (isolate_variable_sparse p var 2)" + define B where "B = (isolate_variable_sparse p var 1)" + define C where "C = (isolate_variable_sparse p var 0)" + have freeA : "var \ vars A" + unfolding A_def + by (simp add: not_in_isovarspar) + have freeB : "var \ vars B" + unfolding B_def + by (simp add: not_in_isovarspar) + have freeC : "var \ vars C" + unfolding C_def + by (simp add: not_in_isovarspar) + assume "eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)" + then have h : "(\a\set L. aEval a (xs @ x # \)) \ (\f\set F. eval f (xs @ x # \))" + apply(simp add:eval_list_conj) + by (meson Un_iff eval.simps(1) image_eqI) + define X where "X=xs@x#\" + have Xlength : "length X > var" + using X_def hlength by auto + define Aval where "Aval = insertion (nth_default 0 (list_update X var x)) A" + define Bval where "Bval = insertion (nth_default 0 (list_update X var x)) B" + define Cval where "Cval = insertion (nth_default 0 (list_update X var x)) C" + have hinsert : "(xs @ x # \)[var := x] = (xs @ x #\)" + using hlength by auto + have allAval : "\x. insertion (nth_default 0 (xs @ x # \)) A = Aval" + using Aval_def + using not_contains_insertion[where var="var", where p = "A", OF freeA, where L = "xs @ x #\", where x="x", where val="Aval"] + unfolding X_def hinsert using hlength by auto + have allBval : "\x. insertion (nth_default 0 (xs @ x # \)) B = Bval" + using Bval_def + using not_contains_insertion[where var="var", where p = "B", OF freeB, where L = "xs @ x #\", where x="x", where val="Bval"] + unfolding X_def hinsert using hlength by auto + have allCval : "\x. insertion (nth_default 0 (xs @ x # \)) C = Cval" + using Cval_def + using not_contains_insertion[where var="var", where p = "C", OF freeC, where L = "xs @ x #\", where x="x", where val="Cval"] + unfolding X_def hinsert using hlength by auto + have insertion_p : "insertion (nth_default 0 X) p = 0" + using in_list h aEval.simps(1) X_def by fastforce + have express_p : "p = A * Var var ^ 2 + B * Var var + C" + using express_poly[OF low_pow] unfolding A_def B_def C_def + by fastforce + have insertion_p' : "Aval *x^2+Bval *x+Cval = 0" + using express_p insertion_p unfolding Aval_def Bval_def Cval_def X_def hinsert + apply(simp add: insertion_add insertion_mult insertion_pow) + using insertion_var by (metis X_def Xlength hinsert) + have biglemma : " + ((Aval = 0 \ + Bval \ 0 \ + (\f\set L. aEval (linear_substitution var (-C) B f) (xs @ x # \)) \ + (\f\set F. eval (linear_substitution_fm var (-C) B f) (xs @ x # \)) \ + Aval \ 0 \ + insertion (nth_default 0 (xs @ x # \)) 4 * + Aval * + Cval + \ (Bval)\<^sup>2 \ + ((\f\set L. eval (quadratic_sub var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \))\ + (\f\set F. eval (quadratic_sub_fm var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)) \ + (\f\set L. eval (quadratic_sub var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)) \ + (\f\set F. eval (quadratic_sub_fm var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \))) \ + Aval = 0 \ + Bval = 0 \ + Cval = 0))" + proof(cases "Aval=0") + case True + then have aval0 : "Aval=0" by simp + show ?thesis proof(cases "Bval=0") + case True + then have bval0 : "Bval=0" by simp + have h : "eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)" + using hlength h unfolding X_def + using \eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)\ by blast + show ?thesis proof(cases "Cval=0") + case True + show ?thesis + by(simp add:aval0 True bval0) + next + case False + show ?thesis + using insertion_p' aval0 bval0 False by(simp) + qed + next + case False + have bh : "insertion (nth_default 0 (X[var := - Cval / Bval])) B = Bval" + using allBval unfolding X_def + using Bval_def X_def freeB not_contains_insertion by blast + have ch : "insertion (nth_default 0 (X[var := - Cval / Bval])) C = Cval" + using allCval unfolding X_def + using Cval_def X_def freeC not_contains_insertion by blast + have xh : "x=-Cval/Bval" + proof- + have "Bval*x+Cval = 0" + using insertion_p' aval0 + by simp + then show ?thesis using False + by (smt nonzero_mult_div_cancel_left) + qed + have freecneg : "var \ vars (-C)" using freeC not_in_neg by auto + have h1: "(\a\set L. aEval (linear_substitution var (-C) (B) a) (X[var := x]))" + using h xh Bval_def Cval_def False LinearCase.linear[OF Xlength False freecneg freeB, of "-Cval"] freeB freeC freecneg + by (metis X_def hinsert insertion_neg) + have h2 : "\f\set F. eval (linear_substitution_fm var (-C) B f) (X[var := x])" + using h xh Bval_def Cval_def False LinearCase.linear_fm[OF Xlength False freecneg freeB, of "-Cval"] freeB freeC + by (metis X_def hinsert insertion_neg) + show ?thesis using h1 h2 apply(simp add:aval0 False) + using X_def hlength + using hinsert by auto + qed + next + case False + then have aval0 : "Aval \0" by simp + have h4 : "insertion (nth_default 0 (X[var := x])) 4 = 4" + using insertion_const[where f = "(nth_default 0 (X[var := x]))", where c="4"] + by (metis MPoly_Type.insertion_one insertion_add numeral_Bit0 one_add_one) + show ?thesis proof(cases "4 * Aval * Cval \ Bval\<^sup>2") + case True + have h1a : "var\vars(-B)" + by(simp add: freeB not_in_neg) + have h1b : "var\vars(1::real mpoly)" + using isolate_var_one not_in_isovarspar by blast + have h1c : "var\vars(-1::real mpoly)" + by(simp add: h1b not_in_neg) + have h1d : "var\vars(4::real mpoly)" + by (metis h1b not_in_add numeral_Bit0 one_add_one) + have h1e : "var\vars(B^2-4*A*C)" + by(simp add: freeB h1d freeA freeC not_in_mult not_in_pow not_in_sub) + have h1f : "var\vars(2::real mpoly)" + using h1b not_in_add by fastforce + have h1g : "var\vars(2*A)" + by(simp add: freeA h1f not_in_mult) + have h1h : "freeIn var (quadratic_sub var (-B) (1) (B^2-4*A*C) (2*A) a)" + using free_in_quad h1a h1b h1e h1g by blast + have h1i : "freeIn var (quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A) a)" + using free_in_quad h1a h1c h1e h1g by blast + have h2 : "2*Aval \ 0" using aval0 by auto + have h3 : "0 \ (Bval^2-4*Aval*Cval)" using True by auto + have h4a : "var \ vars 4" + by (metis monom_numeral notInKeys_notInVars not_in_add not_in_isovarspar not_in_pow one_add_one power.simps(1) rel_simps(76) vars_monom_keys) + have h4 : "var \ vars (B^2-4*A*C)" by(simp add: h4a freeA freeB freeC not_in_pow not_in_mult not_in_sub) + have h5 : "\x. insertion (nth_default 0 (list_update X var x)) (-B) = -Bval " + using allBval apply(simp add: insertion_neg) + by (simp add: B_def Bval_def insertion_isovarspars_free) + have h6 : "\x. insertion (nth_default 0 (list_update X var x)) 1 = 1" by simp + have h6a : "\x. insertion (nth_default 0 (list_update X var x)) (-1) = (-1)" using h6 by (simp add: insertion_neg) + have h7a : "\x. insertion (nth_default 0 (list_update X var x)) 4 = 4" by (metis h6 insertion_add numeral_Bit0 one_add_one) + have h7b : "var \ vars(4*A*C)" using freeA freeC by (simp add: h4a not_in_mult) + have h7c : "var \ vars(B^2)" using freeB not_in_pow by auto + have h7 : "\x. insertion (nth_default 0 (list_update X var x)) (B^2-4*A*C) = (Bval^2-4*Aval*Cval)" + using h7a allAval allBval allCval unfolding X_def using hlength + apply (simp add: insertion_mult insertion_sub power2_eq_square) + by (metis A_def Aval_def Bval_def C_def Cval_def X_def freeB insertion_isovarspars_free not_contains_insertion) + have h8a : "\x. insertion (nth_default 0 (list_update X var x)) 2 = 2" by (metis h6 insertion_add one_add_one) + have h8 : "\x. insertion (nth_default 0 (list_update X var x)) (2*A) = (2*Aval)" + apply(simp add: allAval h8a insertion_mult) + by (simp add: A_def Aval_def insertion_isovarspars_free) + + have h1 : "- Bval\<^sup>2 + 4 * Aval * Cval \ 0" + using True by simp + have xh : "x = (- Bval + sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)\x=(- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)" + using insertion_p' aval0 h1 + discriminant_iff unfolding discrim_def by blast + have p1 : "x = (- Bval + sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval) \ + ((\a\ set L. eval (quadratic_sub var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x])))" + proof- + assume x_def : "x = (- Bval + sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)" + then have h : "(\a\set L. aEval a (X[var := (- Bval + sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)])) \ (\f\set F. eval f (X[var := (- Bval + sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)]))" + using h + using X_def hinsert by auto + { fix a + assume in_list : "a\ set L" + have "eval (quadratic_sub var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x])" + using free_in_quad[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1b h1e h1g] + using quadratic_sub[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="1", OF h6 h7 h8] + h in_list + using var_not_in_eval by fastforce + + } + then have left : "(\a\set L. eval (quadratic_sub var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x]))" + by simp + + + { fix a + assume in_list : "a\ set F" + have "eval (quadratic_sub_fm var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x])" + using free_in_quad_fm[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1b h1e h1g] + using quadratic_sub_fm[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="1", OF h6 h7 h8] + h in_list + using var_not_in_eval by fastforce + + } + then have right : "(\a\set F. eval (quadratic_sub_fm var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x]))" + by simp + show ?thesis + using right left by simp + qed + + have p2 : "x = (- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval) \ + ((\a\ set L. eval (quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x])))" + proof - + assume x_def : "x = (- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)" + then have h : "(\a\set L. aEval a (X[var := (- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)])) \ (\f\set F. eval f (X[var := (- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)]))" + using h + using X_def hinsert by auto + then have "(\a\set L. aEval a (X[var := (- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)])) \ (\f\set F. eval f (X[var := (- Bval - sqrt (Bval\<^sup>2 - 4 * Aval * Cval)) / (2 * Aval)]))" + using h by simp + { fix a + assume in_list : "a\ set L" + have "eval (quadratic_sub var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x])" + using free_in_quad[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1c h1e h1g] + using quadratic_sub[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="-1", OF h6a h7 h8] + h in_list + using var_not_in_eval by fastforce + + } + then have left : "(\a\set L. eval (quadratic_sub var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x]))" + by simp + + + { fix a + assume in_list : "a\ set F" + have "eval (quadratic_sub_fm var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x])" + using free_in_quad_fm[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1c h1e h1g] + using quadratic_sub_fm[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="-1", OF h6a h7 h8] + h in_list + using var_not_in_eval by fastforce + + } + then have right : "(\a\set F. eval (quadratic_sub_fm var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) a) (X[var := x]))" + by simp + show ?thesis + using right left by simp + qed + have subst4 : "insertion (nth_default 0 (xs @ x # \)) 4 = 4" using h7a hlength X_def by auto + have disj: "(\a\set L. eval (quadratic_sub var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) a) (xs @ x # \)) \ + (\a\set F. eval (quadratic_sub_fm var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) a) (xs @ x # \)) \ + (\a\set L. eval (quadratic_sub var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) a) (xs @ x # \)) \ + (\a\set F. eval (quadratic_sub_fm var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) a) (xs @ x # \))" + using xh p1 p2 + unfolding X_def hinsert by blast + show ?thesis apply(simp add: aval0 True h7a subst4) using disj + unfolding X_def hinsert by auto + next + case False + then have det : "0 < - Bval\<^sup>2 + 4 * Aval * Cval" + by simp + show ?thesis apply(simp add: aval0 False h4) using discriminant_negative unfolding discrim_def + using insertion_p' + using aval0 det by auto + qed + qed + have "(\x. + (insertion (nth_default 0 (xs @ x # \)) A = 0 \ + insertion (nth_default 0 (xs @ x # \)) B \ 0 \ + (\f\set L. aEval (linear_substitution var (-C) (B) f) (xs @ x # \)) \ + (\f\set F. eval (linear_substitution_fm var (-C) B f) (xs @ x # \)) \ + insertion (nth_default 0 (xs @ x # \)) A \ 0 \ + insertion (nth_default 0 (xs @ x # \)) 4 * + insertion (nth_default 0 (xs @ x # \)) A * + insertion (nth_default 0 (xs @ x # \)) C + \ (insertion (nth_default 0 (xs @ x # \)) B)\<^sup>2 \ + ((\f\set L. eval (quadratic_sub var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \))\ + (\f\set F. eval (quadratic_sub_fm var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)) \ + (\f\set L. eval (quadratic_sub var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)) \ + (\f\set F. eval (quadratic_sub_fm var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)))) \ + (Aval = 0 \ + Bval = 0 \ + Cval = 0))" + apply(rule exI[where x=x]) + using biglemma + using allAval allBval allCval unfolding A_def B_def C_def Aval_def Bval_def Cval_def X_def hinsert + by auto + then obtain x where x : "(insertion (nth_default 0 (xs @ x # \)) A = 0 \ + insertion (nth_default 0 (xs @ x # \)) B \ 0 \ + (\f\set L. aEval (linear_substitution var (-C) (B) f) (xs @ x # \)) \ + (\f\set F. eval (linear_substitution_fm var (-C) B f) (xs @ x # \)) \ + insertion (nth_default 0 (xs @ x # \)) A \ 0 \ + insertion (nth_default 0 (xs @ x # \)) 4 * + insertion (nth_default 0 (xs @ x # \)) A * + insertion (nth_default 0 (xs @ x # \)) C + \ (insertion (nth_default 0 (xs @ x # \)) B)\<^sup>2 \ + ((\f\set L. eval (quadratic_sub var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \))\ + (\f\set F. eval (quadratic_sub_fm var (- B) 1 (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)) \ + (\f\set L. eval (quadratic_sub var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)) \ + (\f\set F. eval (quadratic_sub_fm var (- B) (-1) (B\<^sup>2 - 4 * A * C) (2 * A) f) (xs @ x # \)))) \ + (Aval = 0 \ + Bval = 0 \ + Cval = 0)" by auto + have h : "(\x. eval (elimVar var L F (Eq p)) (xs @ x # \))\(Aval = 0 \ Bval = 0 \ Cval = 0)" + proof(cases "(Aval = 0 \ Bval = 0 \ Cval = 0)") + case True + then show ?thesis by simp + next + case False + have "(\x. eval (elimVar var L F (Eq p)) (xs @ x # \))" + apply(rule exI[where x=x]) + apply(simp add: eval_list_conj insertion_mult insertion_sub insertion_pow insertion_add + del: quadratic_sub.simps linear_substitution.simps quadratic_sub_fm.simps linear_substitution_fm.simps) + unfolding A_def[symmetric] B_def[symmetric] C_def[symmetric] One_nat_def[symmetric] X_def[symmetric] + using hlength x + by (auto simp add:False) + then show ?thesis by auto + qed + have "(\x. eval (elimVar var L F (Eq p)) (xs @ x # \))\(\x. aEval (Eq p) (xs@ x# \))" + proof(cases "(\x. eval (elimVar var L F (Eq p)) (xs @ x # \))") + case True + then show ?thesis by auto + next + case False + then have "(Aval = 0 \ Bval = 0 \ Cval = 0)" + using h by auto + then have "(\x. aEval (Eq p) (xs @ x # \))" + unfolding express_p + apply(simp add:insertion_add insertion_mult insertion_pow) + using allAval allBval allCval by auto + then show ?thesis by auto + qed + } + then have left : "(\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) \ + ((\x. eval (elimVar var L F (Eq p)) (xs @ x # \))\(\x. aEval (Eq p) (xs@ x# \)))" + by blast + + + { + assume hlength : "length (xs::real list) = var" + define A where "A = (isolate_variable_sparse p var 2)" + define B where "B = (isolate_variable_sparse p var 1)" + define C where "C = (isolate_variable_sparse p var 0)" + have freeA : "var \ vars A" + unfolding A_def + by (simp add: not_in_isovarspar) + have freeB : "var \ vars B" + unfolding B_def + by (simp add: not_in_isovarspar) + have freeC : "var \ vars C" + unfolding C_def + by (simp add: not_in_isovarspar) + have express_p : "p = A*(Var var)^2+B*(Var var)+C" + using express_poly[OF low_pow] unfolding A_def B_def C_def + by fastforce + assume h : "(\x. (eval (elimVar var L F (Eq p)) (list_update (xs@x#\) var x)))" + fix x + define X where "X=xs@x#\" + have Xlength : "length X > var" + using X_def hlength by auto + define Aval where "Aval = insertion (nth_default 0 (list_update X var x)) A" + define Bval where "Bval = insertion (nth_default 0 (list_update X var x)) B" + define Cval where "Cval = insertion (nth_default 0 (list_update X var x)) C" + have allAval : "\x. insertion (nth_default 0 (list_update X var x)) A = Aval" + using freeA Aval_def + using not_contains_insertion by blast + have allBval : "\x. insertion (nth_default 0 (list_update X var x)) B = Bval" + using freeB Bval_def + using not_contains_insertion by blast + have allCval : "\x. insertion (nth_default 0 (list_update X var x)) C = Cval" + using freeC Cval_def + using not_contains_insertion by blast + assume "(eval (elimVar var L F (Eq p)) (list_update (xs@x#\) var x))" + then have h : "(eval (elimVar var L F (Eq p)) (list_update X var x))" + unfolding X_def . + + have "(Aval = 0 \ Bval \ 0 \ + (\f\(\a. Atom(linear_substitution var (-C) B a)) ` set L \ + linear_substitution_fm var (-C) B ` + set F. + eval f (X[var := x])) \ + Aval \ 0 \ + insertion (nth_default 0 (X[var := x])) 4 * Aval * Cval \ Bval\<^sup>2 \ + ((\f\(quadratic_sub var (-B) 1 (B^2-4*A*C) (2*A)) ` + set L \ + (quadratic_sub_fm var (-B) 1 (B^2-4*A*C) (2*A)) ` + set F. + eval f (X[var := x])) + \(\f\(quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A)) ` + set L \ + (quadratic_sub_fm var (-B) (-1) (B^2-4*A*C) (2*A)) ` + set F. + eval f (X[var := x])) + ))" + unfolding Aval_def Bval_def Cval_def A_def B_def C_def + using h by(simp add: eval_list_conj insertion_mult insertion_sub insertion_pow insertion_add insertion_var Xlength) + then have h : "(Aval = 0 \ Bval \ 0 \ + ((\a\ set L. aEval (linear_substitution var (-C) B a) (X[var := x])) \ + (\a\ set F. eval (linear_substitution_fm var (-C) B a) (X[var := x]))) \ + Aval \ 0 \ insertion (nth_default 0 (X[var := x])) 4 * Aval * Cval \ Bval\<^sup>2 \ + (((\a\ set L. eval (quadratic_sub var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x]))) + \((\a\ set L. eval (quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x]))))) + " + apply(cases "Aval = 0 ") + apply auto + by (meson Un_iff eval.simps(1) imageI) + have h : "(\x. ((\a\set L . aEval a ((xs@x#\)[var := x])) \ (\f\set F. eval f ((xs@x#\)[var := x]))))\(Aval=0\Bval=0\Cval=0)" + proof(cases "Aval=0") + case True + then have aval0 : "Aval=0" + by simp + show ?thesis proof(cases "Bval = 0") + case True + then have bval0 : "Bval = 0" by simp + show ?thesis proof(cases "Cval=0") + case True + then show ?thesis using aval0 bval0 True by auto + next + case False + then show ?thesis using h by(simp add:aval0 bval0 False) + qed + next + case False + have hb : "insertion (nth_default 0 (X[var := - Cval / Bval])) B = Bval" + using allBval by simp + have hc : "insertion (nth_default 0 (X[var := - Cval / Bval])) (-C) = -Cval" + using allCval + by (simp add: insertion_neg) + have freecneg : "var\vars(-C)" using freeC not_in_neg by auto + have p1 : "(\a\set L. aEval a ((xs @ x # \)[var := - Cval / Bval]))" + using h apply(simp add: False aval0) + using linear[OF Xlength False freecneg freeB hc hb] + list_update_length var_not_in_linear[OF freecneg freeB] + unfolding X_def using hlength + by (metis divide_minus_left) + + have p2 : "(\a\set F. eval a ((xs @ x # \)[var := - Cval / Bval]))" + using h apply(simp add: False aval0) + using linear_fm[OF Xlength False freecneg freeB hc hb] + list_update_length var_not_in_linear_fm[OF freecneg freeB] + unfolding X_def using hlength var_not_in_eval + by (metis divide_minus_left linear_substitution_fm.elims linear_substitution_fm_helper.elims) + show ?thesis + using p1 p2 hlength by fastforce + qed + next + case False + then have aval0 : "Aval \ 0" + by simp + have h4 : "insertion (nth_default 0 (X[var := x])) 4 = 4" + using insertion_const[where f = "(nth_default 0 (X[var := x]))", where c="4"] + by (metis MPoly_Type.insertion_one insertion_add numeral_Bit0 one_add_one) + show ?thesis proof(cases "4 * Aval * Cval \ Bval\<^sup>2") + case True + then have h1 : "- Bval\<^sup>2 + 4 * Aval * Cval \ 0" + by simp + have h : "(((\a\ set L. eval (quadratic_sub var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x]))) + \((\a\ set L. eval (quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x]))))" + using h by(simp add: h1 aval0) + have h1a : "var\vars(-B)" + by(simp add: freeB not_in_neg) + have h1b : "var\vars(1::real mpoly)" + using isolate_var_one not_in_isovarspar by blast + have h1c : "var\vars(-1::real mpoly)" + by(simp add: h1b not_in_neg) + have h1d : "var\vars(4::real mpoly)" + by (metis h1b not_in_add numeral_Bit0 one_add_one) + have h1e : "var\vars(B^2-4*A*C)" + by(simp add: freeB h1d freeA freeC not_in_mult not_in_pow not_in_sub) + have h1f : "var\vars(2::real mpoly)" + using h1b not_in_add by fastforce + have h1g : "var\vars(2*A)" + by(simp add: freeA h1f not_in_mult) + have h1h : "freeIn var (quadratic_sub var (-B) (1) (B^2-4*A*C) (2*A) a)" + using free_in_quad h1a h1b h1e h1g by blast + have h1i : "freeIn var (quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A) a)" + using free_in_quad h1a h1c h1e h1g by blast + have h2 : "2*Aval \ 0" using aval0 by auto + have h3 : "0 \ (Bval^2-4*Aval*Cval)" using True by auto + have h4a : "var \ vars 4" + by (metis monom_numeral notInKeys_notInVars not_in_add not_in_isovarspar not_in_pow one_add_one power.simps(1) rel_simps(76) vars_monom_keys) + have h4 : "var \ vars (B^2-4*A*C)" by(simp add: h4a freeA freeB freeC not_in_pow not_in_mult not_in_sub) + have h5 : "\x. insertion (nth_default 0 (list_update X var x)) (-B) = -Bval " using allBval by(simp add: insertion_neg) + have h6 : "\x. insertion (nth_default 0 (list_update X var x)) 1 = 1" by simp + have h6a : "\x. insertion (nth_default 0 (list_update X var x)) (-1) = (-1)" using h6 by (simp add: insertion_neg) + have h7a : "\x. insertion (nth_default 0 (list_update X var x)) 4 = 4" by (metis h6 insertion_add numeral_Bit0 one_add_one) + have h7b : "var \ vars(4*A*C)" using freeA freeC by (simp add: h4a not_in_mult) + have h7c : "var \ vars(B^2)" using freeB not_in_pow by auto + have h7 : "\x. insertion (nth_default 0 (list_update X var x)) (B^2-4*A*C) = (Bval^2-4*Aval*Cval)" + by (simp add: h7a allAval allBval allCval insertion_mult insertion_sub power2_eq_square) + have h8a : "\x. insertion (nth_default 0 (list_update X var x)) 2 = 2" by (metis h6 insertion_add one_add_one) + have h8 : "\x. insertion (nth_default 0 (list_update X var x)) (2*A) = (2*Aval)" by(simp add: allAval h8a insertion_mult) + + have p1 : "(\a\ set L. eval (quadratic_sub var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x])) + \ \x. length xs = var \ ((\a\set L . aEval a ((xs@x#\)[var := x])) \ (\f\set F. eval f ((xs@x#\)[var := x])))" + proof- + assume p1 : "(\a\ set L. eval (quadratic_sub var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x]))" + assume p2 : "(\a\ set F. eval (quadratic_sub_fm var (-B) 1 (B^2-4*A*C) (2*A) a) (X[var := x]))" + show ?thesis + using free_in_quad[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1b h1e h1g] + using quadratic_sub[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="1", OF h6 h7 h8] + using free_in_quad_fm[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1b h1e h1g] + using quadratic_sub_fm[where a="-B",where b="1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="1", OF h6 h7 h8] + p1 p2 + using var_not_in_eval + by (metis X_def hlength list_update_length) + qed + have p2 : "(\a\ set L. eval (quadratic_sub var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x])) + \(\a\ set F. eval (quadratic_sub_fm var (-B) (-1) (B^2-4*A*C) (2*A) a) (X[var := x])) + \\x. length xs = var \ ((\a\set L . aEval a ((xs@x#\)[var := x])) \ (\f\set F. eval f ((xs@x#\)[var := x])))" + using free_in_quad[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1c h1e h1g] + using quadratic_sub[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="-1", OF h6a h7 h8] + + using free_in_quad_fm[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var",OF h1a h1c h1e h1g] + using quadratic_sub_fm[where a="-B",where b="-1", where c="(B^2-4*A*C)", where d="2*A",where var="var", where L="X", OF Xlength, + where Dv="2*Aval", OF h2, where Cv="(Bval^2-4*Aval*Cval)", OF h3, where Av="-Bval", OF h4 h5, where Bv="-1", OF h6a h7 h8] + + using var_not_in_eval by (metis X_def hlength list_update_length) + then show ?thesis + using h p1 p2 by blast + next + case False + then show ?thesis using h by(simp add: aval0 False h4) + qed + qed + have "(\x.((\a\set L . aEval a ((xs@x#\)[var := x])) \ (\f\set F. eval f ((xs@x#\)[var := x]))))\(\x. aEval (Eq p) (xs @ x#\))" + proof(cases "(\x.((\a\set L . aEval a ((xs@x#\)[var := x])) \ (\f\set F. eval f ((xs@x#\)[var := x]))))") + case True + then show ?thesis by auto + next + case False + then have "Aval=0\Bval=0\Cval=0" using h by auto + then have "(\x. aEval (Eq p) (xs @ x # \))" + unfolding express_p apply(simp add:insertion_add insertion_mult insertion_pow) + using allAval allBval allCval hlength unfolding X_def by auto + then show ?thesis by auto + qed + } + + + then have right : "(\x. eval (elimVar var L F (Eq p)) (xs @ x # \)) \ + ((\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \))\(\x. aEval (Eq p) (xs @ x # \)))" + by (smt UnE eval.simps(1) eval_list_conj hlength imageE list_update_length set_append set_map) + + + show ?thesis using right left by blast +qed + +text "simply states that the variable is free in the equality case of the elimVar function" +lemma freeIn_elimVar_eq : "freeIn var (elimVar var L F (Eq p))" +proof- + have h4 : "var \ vars(4:: real mpoly)" using var_not_in_Const + by (metis (full_types) isolate_var_one monom_numeral not_in_isovarspar numeral_One vars_monom_keys zero_neq_numeral) + have hlinear: "\f\set(map (\a. Atom(linear_substitution var (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) a)) L @ + map (linear_substitution_fm var (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0))) + F). freeIn var f" + using + var_not_in_linear[where c="(isolate_variable_sparse p var (Suc 0))", where b="(- isolate_variable_sparse p var 0)", where var="var"] + var_not_in_linear_fm[where c="(isolate_variable_sparse p var (Suc 0))", where b="(-isolate_variable_sparse p var 0)", where var="var"] + not_in_isovarspar not_in_neg by auto + have freeA : "var \ vars (- isolate_variable_sparse p var (Suc 0))" + using not_in_isovarspar not_in_neg by auto + have freeB1 : "var \ vars (1::real mpoly)" + by (metis h4 monom_numeral monom_one notInKeys_notInVars vars_monom_keys zero_neq_numeral) + have freeC : "var \ vars (((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0))" + using not_in_isovarspar not_in_pow not_in_sub not_in_mult h4 by auto + have freeD : "var \ vars ((2 * isolate_variable_sparse p var 2))" + using not_in_isovarspar not_in_mult + by (metis mult_2 not_in_add) + have freeB2 : "var\vars (-1::real mpoly)" + using freeB1 not_in_neg by auto + have quadratic1 : "\f\set(map (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2)) + L @ + map (quadratic_sub_fm var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2)) + F). freeIn var f" + using free_in_quad[OF freeA freeB1 freeC freeD] + free_in_quad_fm[OF freeA freeB1 freeC freeD] by auto + have quadratic2 : "\f\set(map (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) (-1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2)) + L @ + map (quadratic_sub_fm var (- isolate_variable_sparse p var (Suc 0)) (-1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2)) + F). freeIn var f" + using free_in_quad[OF freeA freeB2 freeC freeD] + free_in_quad_fm[OF freeA freeB2 freeC freeD] by auto + show ?thesis + using not_in_mult not_in_add h4 not_in_pow not_in_sub freeIn_list_conj not_in_isovarspar hlinear quadratic1 quadratic2 + by(simp add: ) +qed + + +text "Theorem 20.2 in the textbook" +lemma elimVar_eq_2 : + assumes hlength : "length xs = var" + assumes in_list : "Eq p \ set(L)" + assumes low_pow : "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + assumes nonzero : "\x. + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 2) \ 0 + \ insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 1) \ 0 + \ insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 0) \ 0" (is ?non0) + shows "(\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = + (\x. eval (elimVar var L F (Eq p)) (xs @ x # \))" +proof- + define A where "A = (isolate_variable_sparse p var 2)" + define B where "B = (isolate_variable_sparse p var 1)" + define C where "C = (isolate_variable_sparse p var 0)" + have freeA : "var \ vars A" + unfolding A_def + by (simp add: not_in_isovarspar) + have freeB : "var \ vars B" + unfolding B_def + by (simp add: not_in_isovarspar) + have freeC : "var \ vars C" + unfolding C_def + by (simp add: not_in_isovarspar) + have express_p : "p = A*(Var var)^2+B*(Var var)+C" + using express_poly[OF low_pow] unfolding A_def B_def C_def + by fastforce + have af : "isolate_variable_sparse p var 2 = A" + using A_def by auto + have bf : "isolate_variable_sparse p var (Suc 0) = B" + using B_def by auto + have cf : "isolate_variable_sparse p var 0 = C" + using C_def by auto + have xlength : "\x. (insertion (nth_default 0 (xs @ x # \)) (Var var))= x" + using hlength insertion_var + by (metis add.commute add_strict_increasing length_append length_greater_0_conv list.distinct(1) list_update_id nth_append_length order_refl) + fix x + define c where "c i = (insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var i))" for i + have c2 : "\x. insertion (nth_default 0 (xs @ x # \)) A = c 2" + using freeA apply(simp add: A_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have c1 : "\x. insertion (nth_default 0 (xs @ x # \)) B = c 1" + using freeB apply(simp add: B_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have c0 : "\x. insertion (nth_default 0 (xs @ x # \)) C = c 0" + using freeC apply(simp add: C_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have sum : "\x. c 2 * x\<^sup>2 + c (Suc 0) * x + c 0 = (\i\2. c i * x ^ i)" + by (simp add: numerals(2)) + have "(\x. aEval (Eq p) (xs @ x # \)) = (\?non0)" + apply(simp add : af bf cf) + unfolding express_p apply(simp add:insertion_add insertion_mult insertion_pow xlength) + apply(simp add:c2 c1 c0) + apply(simp add: sum) + using polyfun_eq_0[where c="c", where n="2"] + using sum by auto + then have "\(\x. aEval (Eq p) (xs @ x \))" + using nonzero by auto + then show ?thesis + using disjE[OF elimVar_eq[OF hlength in_list, where F="F", where \="\"], where R="?thesis"] + using \(\x. aEval (Eq p) (xs @ x # \)) = (\ (\x. insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 2) \ 0 \ insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 1) \ 0 \ insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 0) \ 0))\ low_pow nonzero by blast +qed + + + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/EqualityVS.thy b/thys/Virtual_Substitution/EqualityVS.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/EqualityVS.thy @@ -0,0 +1,450 @@ +subsection "Overall Equality VS Proofs" +theory EqualityVS + imports EliminateVariable LuckyFind +begin + + +lemma degree_find_eq : + assumes "find_eq var L = (A,L')" + shows "\p\set(A). MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" using assms(1) +proof(induction L arbitrary: A L') + case Nil + then show ?case by auto +next + case (Cons a L) + then show ?case proof(cases a) + case (Less p) + {fix A' L' + assume h : "find_eq var L = (A', L')" + have "A=A'" + using Less Cons h by(simp) + then have "\p\set A. MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using Cons h by auto + } + then show ?thesis by (meson surj_pair) + next + case (Eq p) + then show ?thesis proof(cases "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2") + case True + {fix A' L' + assume h : "find_eq var L = (A', L')" + have "A= (p#A')" + using Eq Cons h True by auto + then have "\p\set A. MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using Cons h True by auto + } + then show ?thesis by (meson surj_pair) + next + case False + {fix A' L' + assume h : "find_eq var L = (A', L')" + have "A=A'" + using Eq Cons h False + by (smt One_nat_def case_prod_conv find_eq.simps(3) less_2_cases less_SucE numeral_2_eq_2 numeral_3_eq_3 prod.sel(1)) + then have "\p\set A. MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using Cons h by auto + } + then show ?thesis by (meson surj_pair) + qed + next + case (Leq p) + {fix A' L' + assume h : "find_eq var L = (A', L')" + have "A=A'" + using Leq Cons h by(simp) + then have "\p\set A. MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using Cons h by auto + } + then show ?thesis by (meson surj_pair) + next + case (Neq p) + {fix A' L' + assume h : "find_eq var L = (A', L')" + have "A=A'" + using Neq Cons h by(simp) + then have "\p\set A. MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using Cons h by auto + } + then show ?thesis by (meson surj_pair) + qed +qed + +lemma list_in_find_eq : + assumes "find_eq var L = (A,L')" + shows "set(map Eq A @ L') = set L"using assms(1) +proof(induction L arbitrary: A L') + case Nil + then show ?case by auto +next + case (Cons a L) + then show ?case proof(cases a) + case (Less p) + {fix A' L'' + assume h : "find_eq var L = (A', L'')" + have A : "A=A'" + using Less Cons h by(simp) + have L : "L'=Less p # L''" + using Less Cons h by simp + have "set (map Eq A @ L') = set (a # L)" + apply(simp add: A L Less) using Cons(1)[OF h] by auto + } + then show ?thesis by (meson surj_pair) + next + case (Eq p) + then show ?thesis proof(cases "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2") + case True + {fix A' L'' + assume h : "find_eq var L = (A', L'')" + have A : "A=(p#A')" + using Eq Cons h True by auto + have L : "L'= L''" + using Eq Cons h True by auto + have "set (map Eq A @ L') = set (a # L)" + apply(simp add: A L Eq) using Cons(1)[OF h] by auto + } + then show ?thesis by (meson surj_pair) + next + case False + {fix A' L'' + assume h : "find_eq var L = (A', L'')" + have A : "A=A'" + using Eq Cons h False + by (smt case_prod_conv degree_find_eq find_eq.simps(3) list.set_intros(1) prod.sel(1)) + have L : "L'=Eq p # L''" + using Eq Cons h + by (smt A case_prod_conv find_eq.simps(3) not_Cons_self2 prod.sel(1) prod.sel(2)) + have "set (map Eq A @ L') = set (a # L)" + apply(simp add: A L Eq) using Cons(1)[OF h] by auto + } + then show ?thesis by (meson surj_pair) + qed + next + case (Leq p) + {fix A' L'' + assume h : "find_eq var L = (A', L'')" + have A : "A=A'" + using Leq Cons h by(simp) + have L : "L'=Leq p # L''" + using Leq Cons h by simp + have "set (map Eq A @ L') = set (a # L)" + apply(simp add: A L Leq) using Cons(1)[OF h] by auto + } + then show ?thesis by (meson surj_pair) + next + case (Neq p) + {fix A' L'' + assume h : "find_eq var L = (A', L'')" + have A : "A=A'" + using Neq Cons h by(simp) + have L : "L'=Neq p # L''" + using Neq Cons h by simp + have "set (map Eq A @ L') = set (a # L)" + apply(simp add: A L Neq) using Cons(1)[OF h] by auto + } + then show ?thesis by (meson surj_pair) + qed +qed + + +lemma qe_eq_one_eval : + assumes hlength : "length xs = var" + shows "(\x. (eval (list_conj ((map Atom L) @ F)) (xs @ (x#\)))) = (\x.(eval (qe_eq_one var L F) (xs @ (x#\))))" +proof(cases "find_eq var L") + case (Pair A L') + then show ?thesis proof(cases A) + case Nil + show ?thesis proof safe + fix x + assume h : "eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)" + show "\x. eval (qe_eq_one var L F) (xs @ x # \)" apply(simp) using Nil Pair h by auto + next + fix x + assume h : "eval (qe_eq_one var L F) (xs @ x # \)" + show "\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)" + apply(rule exI[where x="x"]) using Nil Pair h by auto + qed + next + case (Cons p A') + have "set(map Eq (p # A') @ L') = set L" + using list_in_find_eq[OF Pair] Cons by auto + then have in_p: "Eq p \ set (L)" + by auto + have "p\(set A)" using Cons by auto + then have low_pow : "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using degree_find_eq[OF Pair] by auto + have "(\x.(eval (qe_eq_one var L F) (xs @ (x#\)))) = + (\x.(eval (Or (And (Neg (split_p var p)) + ((elimVar var L F) (Eq p)) + ) + (And (split_p var p) + (list_conj (map Atom ((map Eq A') @ L') @ F)) + )) (xs @ (x#\))))" + apply(rule ex_cong1) apply(simp only: qe_eq_one.simps) using Pair Cons by auto + also have "... = (\x. ((\eval (split_p var p) (xs @ x # \)) \ eval (elimVar var L F (Eq p)) (xs @ x # \)) \ + eval (split_p var p) (xs @ x # \) \ + (\f\set (map fm.Atom (map Eq A' @ L') @ F). eval f (xs @ x # \)))" + by(simp add: eval_list_conj) + also have "... = (\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \))" + proof(cases "\x. insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 2) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 1) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 0) \ 0") + case True + have "(\x. ((\eval (split_p var p) (xs @ x # \)) \ eval (elimVar var L F (Eq p)) (xs @ x # \)) \ + eval (split_p var p) (xs @ x # \) \ + (\f\set (map fm.Atom (map Eq A' @ L') @ F). eval f (xs @ x # \))) = + (\x. eval (elimVar var L F (Eq p)) (xs @ x # \))" + proof safe + fix x + assume "eval (elimVar var L F (Eq p)) (xs @ x # \)" + then show "\x. eval (elimVar var L F (Eq p)) (xs @ x # \)" by auto + next + fix x + assume h : "eval (split_p var p) (xs @ x # \)" + have "\ eval (split_p var p) (xs @ x # \)" + using True by simp + then show "\x. eval (elimVar var L F (Eq p)) (xs @ x # \)" using h by simp + next + fix x + assume "eval (elimVar var L F (Eq p)) (xs @ x # \)" + then show "\x. \ eval (split_p var p) (xs @ x # \) \ eval (elimVar var L F (Eq p)) (xs @ x # \) \ + eval (split_p var p) (xs @ x # \) \ + (\f\set (map fm.Atom (map Eq A' @ L') @ F). eval f (xs @ x # \))" + by auto + qed + then show ?thesis using elimVar_eq_2[OF hlength in_p low_pow True] by simp + next + case False + have h1: "\x. eval (split_p var p) (xs @ x # \)" + using False apply(simp) using not_in_isovarspar + by (metis hlength insertion_lowerPoly1) + have "set(map Eq (p # A') @ L') = set L" + using list_in_find_eq[OF Pair] Cons by auto + then have h5 : "set(map fm.Atom (map Eq (p # A') @ L') @ F) = set(map fm.Atom L @ F)" + by auto + have h4 : "(\x. (aEval (Eq p) (xs @ x # \)) \ + (\f\set (map fm.Atom (map Eq A' @ L') @ F). eval f (xs @ x # \))) = + (\x.(\f\set (map fm.Atom (map Eq (p#A') @ L') @ F). eval f (xs @ x # \)))" + by(simp) + have h2 : "(\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = (\x. (aEval (Eq p) (xs @ x # \)) \ + (\f\set (map fm.Atom (map Eq A' @ L') @ F). eval f (xs @ x # \)))" + by(simp only: h4 h5 eval_list_conj) + have h3 : "\x. (aEval (Eq p) (xs @ x # \))" + proof- + define A where "A = (isolate_variable_sparse p var 2)" + define B where "B = (isolate_variable_sparse p var 1)" + define C where "C = (isolate_variable_sparse p var 0)" + have freeA : "var \ vars A" + unfolding A_def + by (simp add: not_in_isovarspar) + have freeB : "var \ vars B" + unfolding B_def + by (simp add: not_in_isovarspar) + have freeC : "var \ vars C" + unfolding C_def + by (simp add: not_in_isovarspar) + have express_p : "p = A*(Var var)^2+B*(Var var)+C" + using express_poly[OF low_pow] unfolding A_def B_def C_def + by fastforce + have xlength : "\x. (insertion (nth_default 0 (xs @ x # \)) (Var var))= x" + using hlength insertion_var + by (metis add.commute add_strict_increasing length_append length_greater_0_conv list.distinct(1) list_update_id nth_append_length order_refl) + fix x + define c where "c i = (insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var i))" for i + have c2 : "\x. insertion (nth_default 0 (xs @ x # \)) A = c 2" + using freeA apply(simp add: A_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have c1 : "\x. insertion (nth_default 0 (xs @ x # \)) B = c 1" + using freeB apply(simp add: B_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have c0 : "\x. insertion (nth_default 0 (xs @ x # \)) C = c 0" + using freeC apply(simp add: C_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have sum : "\x. c 2 * x\<^sup>2 + c (Suc 0) * x + c 0 = (\i\2. c i * x ^ i)" + by (simp add: numerals(2)) + show ?thesis unfolding express_p apply(simp add:insertion_add insertion_mult insertion_pow xlength) + apply(simp add:c2 c1 c0 sum polyfun_eq_0[where c="c", where n="2"]) + using False apply(simp) + by (metis A_def B_def C_def One_nat_def c0 c1 c2 le_SucE le_zero_eq numeral_2_eq_2) + qed + show ?thesis apply(simp only: h1 h2) using h3 by(simp) + qed + finally show ?thesis by auto + qed +qed + + + + +lemma qe_eq_repeat_helper_eval_case1 : + assumes hlength : "length xs = var" + assumes degreeGood : "\p\set(A). MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + shows "((eval (list_conj ((map (Atom o Eq) A) @ (map Atom L) @ F)) (xs @ (x#\)))) + \ (eval (qe_eq_repeat_helper var A L F) (xs @ x # \))" +proof(induction A rule : in_list_induct) + case Nil + then show ?case by auto +next + case (Cons p A') + assume assm : "((eval (list_conj ((map (Atom o Eq) (p#A')) @ (map Atom L) @ F)) (xs @ (x#\)))) " + then have h : "insertion (nth_default 0 (xs @ x # \)) p = 0 \ (eval (qe_eq_repeat_helper var A' L F) (xs @ x # \))" + using Cons by(simp add: eval_list_conj) + have "\ eval (split_p var p) (xs @ x # \) \ eval (elimVar var ((map Eq (p# A')) @ L) F (Eq p)) (xs @ x # \) \ + eval (split_p var p) (xs @ x # \) \ eval (qe_eq_repeat_helper var A' L F) (xs @ x # \)" + proof(cases "eval (split_p var p) (xs @ x # \)") + case True + then show ?thesis using h by blast + next + case False + have all0 : " \x. insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 2) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 1) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 0) \ 0" + using False apply(simp) using not_in_isovarspar + by (metis hlength insertion_lowerPoly1) + have in_p : "Eq p\set((map Eq (p # A') @ L))" + by auto + have "p\(set A)" using Cons by auto + then have low_pow : "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using degreeGood by auto + have list_manipulate : "map fm.Atom (map Eq (p # A') @ L) = map (fm.Atom \ Eq) (p # A') @ map fm.Atom L" + by(simp) + have "eval (elimVar var ((map Eq (p# A')) @ L) F (Eq p)) (xs @ x # \)" + using elimVar_eq_2[OF hlength in_p low_pow all0, where F="F"] apply(simp only: list_manipulate) + using assm freeIn_elimVar_eq[where var="var", where L="(map Eq (p # A') @ L)", where F="F", where p="p"] + by (metis append.assoc hlength list_update_length var_not_in_eval) + then show ?thesis apply(simp only: False) by blast + qed + then show ?case by(simp only: qe_eq_repeat_helper.simps eval.simps) +qed + +lemma qe_eq_repeat_helper_eval_case2 : + assumes hlength : "length xs = var" + assumes degreeGood : "\p\set(A). MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + shows "(eval (qe_eq_repeat_helper var A L F) (xs @ x # \)) + \ \x. ((eval (list_conj ((map (Atom o Eq) A) @ (map Atom L) @ F)) (xs @ (x#\))))" +proof(induction A rule : in_list_induct) + case Nil + then show ?case apply(simp) apply(rule exI[where x=x]) by simp +next + case (Cons p A') + have h : "\ eval (split_p var p) (xs @ x # \) \ eval (elimVar var ((map Eq (p# A')) @ L) F (Eq p)) (xs @ x # \) \ + eval (split_p var p) (xs @ x # \) \ eval (qe_eq_repeat_helper var A' L F) (xs @ x # \)" + using Cons by(simp only:qe_eq_repeat_helper.simps eval.simps) + have "p\set(A)" using Cons(1) . + then have degp : "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using degreeGood by auto + show ?case proof(cases "eval (split_p var p) (xs @ x # \)") + case True + have "\x. eval (list_conj (map (fm.Atom \ Eq) A' @ map fm.Atom L @ F)) (xs @ x # \)" + using h True Cons by blast + then obtain x where x_def : "eval (list_conj (map (fm.Atom \ Eq) A' @ map fm.Atom L @ F)) (xs @ x # \)" by metis + define A where "A = (isolate_variable_sparse p var 2)" + define B where "B = (isolate_variable_sparse p var 1)" + define C where "C = (isolate_variable_sparse p var 0)" + have express_p : "p = A * Var var ^2+B * Var var+C" + proof(cases "MPoly_Type.degree p var = 1") + case True + have a0 : "A = 0" apply(simp add: A_def) using True + by (simp add: isovar_greater_degree) + show ?thesis using sum_over_zero[where mp="p", where x="var"] apply(subst (asm) True) by(simp add:a0 B_def C_def add.commute) + next + case False + then have deg : "MPoly_Type.degree p var = 2" using degp by blast + have flip : "A * (Var var)\<^sup>2 + B * Var var + C = C + B * Var var + A * (Var var)^2" using add.commute by auto + show ?thesis using sum_over_zero[where mp="p", where x="var"] apply(subst (asm) deg) apply(simp add: flip) apply(simp add: A_def B_def C_def) + by (simp add: numeral_2_eq_2) + qed + have insert_x : "insertion (nth_default 0 (xs @ x # \)) (Var var) = x" using hlength + by (metis add.commute add_strict_increasing insertion_var length_append length_greater_0_conv list.distinct(1) list_update_id nth_append_length order_refl) + + have h : "(aEval (Eq p) (xs @ x # \))" + proof- + have freeA : "var \ vars A" + unfolding A_def + by (simp add: not_in_isovarspar) + have freeB : "var \ vars B" + unfolding B_def + by (simp add: not_in_isovarspar) + have freeC : "var \ vars C" + unfolding C_def + by (simp add: not_in_isovarspar) + have xlength : "(insertion (nth_default 0 (xs @ x # \)) (Var var))= x" + using hlength insertion_var + using insert_x by blast + define c where "c i = (insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var i))" for i + have c2 : "\x. insertion (nth_default 0 (xs @ x # \)) A = c 2" + using freeA apply(simp add: A_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have c1 : "\x. insertion (nth_default 0 (xs @ x # \)) B = c 1" + using freeB apply(simp add: B_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have c0 : "\x. insertion (nth_default 0 (xs @ x # \)) C = c 0" + using freeC apply(simp add: C_def c_def) + by (simp add: hlength insertion_lowerPoly1) + have sum : "c 2 * x\<^sup>2 + c (Suc 0) * x + c 0 = (\i\2. c i * x ^ i)" + by (simp add: numerals(2)) + show ?thesis apply(subst express_p) apply(simp add:insertion_add insertion_mult insertion_pow xlength) + apply(simp add:c2 c1 c0 sum polyfun_eq_0[where c="c", where n="2"]) + using True apply(simp) using le_SucE numeral_2_eq_2 + by (metis (no_types) A_def B_def C_def One_nat_def add.left_neutral c0 c1 c2 mult_zero_class.mult_zero_left sum) + qed + show ?thesis apply(rule exI[where x=x]) using x_def h apply(simp only:eval_list_conj) by(simp) + next + case False + have all0 : " \x. insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 2) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 1) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 0) \ 0" + using False apply(simp) using not_in_isovarspar + by (metis hlength insertion_lowerPoly1) + have h : "eval (elimVar var ((map Eq (p# A')) @ L) F (Eq p)) (xs @ x # \)" + using False h by blast + have in_list : "Eq p \ set (((map Eq (p# A')) @ L))" + by(simp) + show ?thesis using elimVar_eq_2[OF hlength in_list, where F="F", OF degp all0] h + by (metis append_assoc map_append map_map) + qed +qed + + + +lemma qe_eq_repeat_eval : + assumes hlength : "length xs = var" + shows "(\x. (eval (list_conj ((map Atom L) @ F)) (xs @ (x#\)))) = (\x.(eval (qe_eq_repeat var L F) (xs @ (x#\))))" +proof(cases "luckyFind var L F") + case None + then show ?thesis proof(cases "find_eq var L") + case (Pair A L') + have degGood : "\p\set A. MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using degree_find_eq[OF Pair] . + have "(\x. eval (qe_eq_repeat var L F) (xs @ x # \)) =(\x. eval + (qe_eq_repeat_helper var A L' F) + (xs @ x # \))" + using Pair None by auto + also have "... + = (\x. ((eval (list_conj ((map (Atom o Eq) A) @ (map Atom L') @ F)) (xs @ (x#\)))))" + using qe_eq_repeat_helper_eval_case1[OF hlength degGood, where L="L'", where F="F", where \="\"] + qe_eq_repeat_helper_eval_case2[OF hlength degGood, where L="L'", where F="F", where \="\"] + by blast + also have "... = (\x. (eval (list_conj ((map Atom L) @ F)) (xs @ (x#\))))" + proof- + have list_manipulate : "map (fm.Atom \ Eq) A @ map fm.Atom L' = map fm.Atom (map Eq A @ L')" + by simp + have changeA : "map (fm.Atom \ Eq) A = map Atom (map Eq A)" by auto + have split : "(\x. \f\set ((map (fm.Atom \ Eq) A) @ + (map fm.Atom L') @ F). + eval f (xs @ x # \)) = (\x. \f\ (Atom ` set ((map (Eq) A) @ L')) \ set(F). + eval f (xs @ x # \))" + apply (rule ex_cong1) + apply(subst changeA) + by auto + show ?thesis apply(simp only: eval_list_conj split list_in_find_eq[OF Pair]) by auto + qed + finally have ?thesis by simp + then show ?thesis by auto + qed +next + case (Some a) + then show ?thesis using luckyFind_eval[OF Some assms(1)] by auto +qed + + +end diff --git a/thys/Virtual_Substitution/ExecutiblePolyProps.thy b/thys/Virtual_Substitution/ExecutiblePolyProps.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/ExecutiblePolyProps.thy @@ -0,0 +1,1083 @@ +text "Executable Polynomial Properties" +theory ExecutiblePolyProps + imports + Polynomials.MPoly_Type_Univariate + MPolyExtension +begin + +text \(Univariate) Polynomial hiding\ + +lifting_update poly.lifting +lifting_forget poly.lifting + +text \\ + +no_notation MPoly_Type.div (infixl "div" 70) +no_notation MPoly_Type.mod (infixl "mod" 70) + +subsection "Lemmas with Monomial and Monomials" + +lemma of_nat_monomial: "of_nat p = monomial p 0" + by (auto simp: poly_mapping_eq_iff lookup_of_nat fun_eq_iff lookup_single) + +lemma of_nat_times_monomial: "of_nat p * monomial c i = monomial (p*c) i" + by (auto simp: poly_mapping_eq_iff prod_fun_def fun_eq_iff of_nat_monomial + lookup_single mult_single) + +lemma monomial_adds_nat_iff: "monomial p i adds c \ lookup c i \ p" for p::"nat" + apply (auto simp: adds_def lookup_add) + by (metis add.left_commute nat_le_iff_add remove_key_sum single_add) + +lemma update_minus_monomial: "Poly_Mapping.update k i (m - monomial i k) = Poly_Mapping.update k i m" + by (auto simp: poly_mapping_eq_iff lookup_update update.rep_eq fun_eq_iff lookup_minus + lookup_single) + +lemma monomials_Var: "monomials (Var x::'a::zero_neq_one mpoly) = {Poly_Mapping.single x 1}" + by transfer (auto simp: Var\<^sub>0_def) + +lemma monomials_Const: "monomials (Const x) = (if x = 0 then {} else {0})" + by transfer' (auto simp: Const\<^sub>0_def) + +lemma coeff_eq_zero_iff: "MPoly_Type.coeff c p = 0 \ p \ monomials c" + by transfer (simp add: not_in_keys_iff_lookup_eq_zero) + +lemma monomials_1[simp]: "monomials 1 = {0}" + by transfer auto + +lemma monomials_and_monoms: + shows "(k \ monomials m) = (\ (a::nat). a \ 0 \ (monomials (MPoly_Type.monom k a)) \ monomials m)" +proof - + show ?thesis using monomials_monom by auto +qed + +lemma mult_monomials_dir_one: + shows "monomials (p*q) \ {a+b | a b . a \ monomials p \ b \ monomials q}" + using monomials_and_monoms mult_monom + by (simp add: keys_mult monomials.rep_eq times_mpoly.rep_eq) + +lemma monom_eq_zero_iff[simp]: "MPoly_Type.monom a b = 0 \ b = 0" + by (metis MPolyExtension.coeff_monom MPolyExtension.monom_zero) + +lemma update_eq_plus_monomial: + "v \ lookup m k \ Poly_Mapping.update k v m = m + monomial (v - lookup m k) k" + for v n::nat + by transfer auto + +lemma coeff_monom_mult': + "MPoly_Type.coeff ((MPoly_Type.monom m' a) * q) (m'm) = a * MPoly_Type.coeff q (m'm - m')" + if *: "m'm = m' + (m'm - m')" + by (subst *) (rule More_MPoly_Type.coeff_monom_mult) + +lemma monomials_zero[simp]: "monomials 0 = {}" + by transfer auto + +lemma in_monomials_iff: "x \ monomials m \ MPoly_Type.coeff m x \ 0" + using coeff_eq_zero_iff[of m x] by auto + +lemma monomials_monom_mult: "monomials (MPoly_Type.monom mon a * q) = (if a = 0 then {} else (+) mon ` monomials q)" + for q::"'a::semiring_no_zero_divisors mpoly" + apply auto + subgoal by transfer' (auto elim!: in_keys_timesE) + subgoal by (simp add: in_monomials_iff More_MPoly_Type.coeff_monom_mult) + done + +subsection "Simplification Lemmas for Const 0 and Const 1" +lemma add_zero : "P + Const 0 = P" +proof - + have h:"P + 0 = P" using add_0_right by auto + show ?thesis unfolding Const_def using h by (simp add: Const\<^sub>0_zero zero_mpoly.abs_eq) +qed + +(* example *) +lemma add_zero_example : "((Var 0)^2 - (Const 1)) + Const 0 = ((Var 0)^2 - (Const 1))" +proof - + show ?thesis by (simp add : add_zero) +qed + +lemma mult_zero_left : "Const 0 * P = Const 0" +proof - + have h:"0*P = 0" by simp + show ?thesis unfolding Const_def using h by (simp add: Const\<^sub>0_zero zero_mpoly_def) +qed + +lemma mult_zero_right : "P * Const 0 = Const 0" + by (metis mult_zero_left mult_zero_right) + +lemma mult_one_left : "Const 1 * (P :: real mpoly) = P" + by (simp add: Const.abs_eq Const\<^sub>0_one one_mpoly_def) + +lemma mult_one_right : "(P::real mpoly) * Const 1 = P" + by (simp add: Const.abs_eq Const\<^sub>0_one one_mpoly_def) + + +subsection "Coefficient Lemmas" +lemma coeff_zero[simp]: "MPoly_Type.coeff 0 x = 0" + by transfer auto + +lemma coeff_sum: "MPoly_Type.coeff (sum f S) x = sum (\i. MPoly_Type.coeff (f i) x) S" + apply (induction S rule: infinite_finite_induct) + apply (auto) + by (metis More_MPoly_Type.coeff_add) + +lemma coeff_mult_Var: "MPoly_Type.coeff (x * Var i ^ p) c = (MPoly_Type.coeff x (c - monomial p i) when lookup c i \ p)" + by transfer' + (auto simp: Var\<^sub>0_def pprod.monomial_power lookup_times_monomial_right + of_nat_times_monomial monomial_adds_nat_iff) + +lemma lookup_update_self[simp]: "Poly_Mapping.update i (lookup m i) m = m" + by (auto simp: lookup_update intro!: poly_mapping_eqI) + +lemma coeff_Const: "MPoly_Type.coeff (Const p) m = (p when m = 0)" + by transfer' (auto simp: Const\<^sub>0_def lookup_single) + +lemma coeff_Var: "MPoly_Type.coeff (Var p) m = (1 when m = monomial 1 p)" + by transfer' (auto simp: Var\<^sub>0_def lookup_single when_def) + +subsection "Miscellaneous" +lemma update_0_0[simp]: "Poly_Mapping.update x 0 0 = 0" + by (metis lookup_update_self lookup_zero) + +lemma mpoly_eq_iff: "p = q \ (\m. MPoly_Type.coeff p m = MPoly_Type.coeff q m)" + by transfer (auto simp: poly_mapping_eqI) + +lemma power_both_sides : + assumes Ah : "(A::real) \0" + assumes Bh : "(B::real) \0" + shows "(A\B) = (A^2\B^2)" + using Ah Bh by (meson power2_le_imp_le power_mono) + +lemma in_list_induct_helper: + assumes "set(xs)\X" + assumes "P []" + assumes "(\x. x\X \ ( \xs. P xs \ P (x # xs)))" + shows "P xs" using assms(1) +proof(induction xs) + case Nil + then show ?case using assms by auto +next + case (Cons a xs) + then show ?case using assms(3) by auto +qed + +theorem in_list_induct [case_names Nil Cons]: + assumes "P []" + assumes "(\x. x\set(xs) \ ( \xs. P xs \ P (x # xs)))" + shows "P xs" + using in_list_induct_helper[of xs "set(xs)" P] using assms by auto + +subsubsection "Keys and vars" + +lemma inKeys_inVars : "a\0 \ x \ keys m \ x \ vars(MPoly_Type.monom m a)" + by(simp add: vars_def) + +lemma notInKeys_notInVars : "x \ keys m \ x \ vars(MPoly_Type.monom m a)" + by(simp add: vars_def) + +lemma lookupNotIn : "x \ keys m \ lookup m x = 0" + by (simp add: in_keys_iff) + +subsection "Degree Lemmas" + +lemma degree_le_iff: "MPoly_Type.degree p x \ k \ (\m\monomials p. lookup m x \ k)" + by transfer simp + +lemma degree_less_iff: "MPoly_Type.degree p x < k \ (k>0 \ (\m\monomials p. lookup m x < k))" + by (transfer fixing: k) (cases "k = 0"; simp) + +lemma degree_ge_iff: "k > 0 \ MPoly_Type.degree p x \ k \ (\m\monomials p. lookup m x \ k)" + using Max_ge_iff by (meson degree_less_iff not_less) + +lemma degree_greater_iff: "MPoly_Type.degree p x > k \ (\m\monomials p. lookup m x > k)" + by transfer' (auto simp: Max_gr_iff) + +lemma degree_eq_iff: + "MPoly_Type.degree p x = k \ (if k = 0 + then (\m\monomials p. lookup m x = 0) + else (\m\monomials p. lookup m x = k) \ (\m\monomials p. lookup m x \ k))" + by (subst eq_iff) (force simp: degree_le_iff degree_ge_iff intro!: antisym) + +declare poly_mapping.lookup_inject[simp del] + +lemma lookup_eq_and_update_lemma: "lookup m var = deg \ Poly_Mapping.update var 0 m = x \ + m = Poly_Mapping.update var deg x \ lookup x var = 0" + unfolding poly_mapping_eq_iff + by (force simp: update.rep_eq fun_eq_iff) + + +lemma degree_const : "MPoly_Type.degree (Const (z::real)) (x::nat) = 0" + by (simp add: degree_eq_iff monomials_Const) + +lemma degree_one : "MPoly_Type.degree (Var x :: real mpoly) x = 1" + by(simp add: degree_eq_iff monomials_Var) + +subsection "Lemmas on treating a multivariate polynomial as univariate " +lemma coeff_isolate_variable_sparse: + "MPoly_Type.coeff (isolate_variable_sparse p var deg) x = + (if lookup x var = 0 + then MPoly_Type.coeff p (Poly_Mapping.update var deg x) + else 0)" + apply (transfer fixing: x var deg p) + unfolding lookup_sum + unfolding lookup_single + apply (auto simp: when_def) + apply (subst sum.inter_filter[symmetric]) + subgoal by simp + subgoal by (simp add: lookup_eq_and_update_lemma Collect_conv_if) + by (auto intro!: sum.neutral simp add: lookup_update) + +lemma isovarspar_sum: + "isolate_variable_sparse (p+q) var deg = + isolate_variable_sparse (p) var deg + + isolate_variable_sparse (q) var deg" + apply (auto simp add: mpoly_eq_iff coeff_isolate_variable_sparse ) + apply (metis More_MPoly_Type.coeff_add coeff_isolate_variable_sparse) + by (metis More_MPoly_Type.coeff_add add.comm_neutral coeff_isolate_variable_sparse less_numeral_extra(3)) + +lemma isolate_zero[simp]: "isolate_variable_sparse 0 var n = 0" + by transfer' (auto simp: mpoly_eq_iff) + +lemma coeff_isolate_variable_sparse_minus_monomial: + "MPoly_Type.coeff (isolate_variable_sparse mp var i) (m - monomial i var) = + (if lookup m var \ i then MPoly_Type.coeff mp (Poly_Mapping.update var i m) else 0)" + by (simp add: coeff_isolate_variable_sparse lookup_minus update_minus_monomial) + +lemma sum_over_zero: "(mp::real mpoly) = (\i::nat \MPoly_Type.degree mp x. isolate_variable_sparse mp x i * Var x^i)" + by (auto simp add: mpoly_eq_iff coeff_sum coeff_mult_Var if_if_eq_conj not_le + coeff_isolate_variable_sparse_minus_monomial when_def lookup_update degree_less_iff + simp flip: eq_iff + intro!: coeff_not_in_monomials) + +lemma const_lookup_zero : "isolate_variable_sparse (Const p ::real mpoly) (x::nat) (0::nat) = Const p" + by (auto simp: mpoly_eq_iff coeff_isolate_variable_sparse coeff_Const when_def) + (metis lookup_update_self) + +lemma const_lookup_suc : "isolate_variable_sparse (Const p :: real mpoly) x (Suc i) = 0" + apply(auto simp add: mpoly_eq_iff coeff_isolate_variable_sparse coeff_Const when_def) + by (metis lookup_update lookup_zero nat.distinct(1)) + +lemma isovar_greater_degree : "\i > MPoly_Type.degree p var. isolate_variable_sparse p var i = 0" + apply(auto simp add: mpoly_eq_iff coeff_isolate_variable_sparse degree_less_iff) + by (metis coeff_not_in_monomials less_irrefl_nat lookup_update) + +lemma isolate_var_0 : "isolate_variable_sparse (Var x::real mpoly) x 0 = 0" + apply(auto simp add: mpoly_eq_iff coeff_isolate_variable_sparse coeff_Var when_def) + by (metis gr0I lookup_single_eq lookup_update_self n_not_Suc_n) + +lemma isolate_var_one : "isolate_variable_sparse (Var x :: real mpoly) x 1 = 1" + by (auto simp add: mpoly_eq_iff coeff_isolate_variable_sparse coeff_Var coeff_eq_zero_iff) + (smt More_MPoly_Type.coeff_monom One_nat_def add_diff_cancel_left' lookup_eq_and_update_lemma + lookup_single_eq lookup_update_self monom_one plus_1_eq_Suc single_diff single_zero update_minus_monomial) + +lemma isovarspase_monom : + assumes notInKeys : "x \ keys m" + assumes notZero : "a \ 0" + shows "isolate_variable_sparse (MPoly_Type.monom m a) x 0 = (MPoly_Type.monom m a :: real mpoly)" + using assms + by (auto simp add: mpoly_eq_iff coeff_isolate_variable_sparse coeff_eq_zero_iff in_keys_iff) + (metis lookup_update_self) + +lemma isolate_variable_spase_zero : "lookup m x = 0 \ + insertion (nth L) ((MPoly_Type.monom m a)::real mpoly) = 0 \ + a \ 0 \ insertion (nth L) (isolate_variable_sparse (MPoly_Type.monom m a) x 0) = 0" + by (simp add: isovarspase_monom lookup_eq_zero_in_keys_contradict notInKeys_notInVars) + +lemma isovarsparNotIn : "x \ vars (p::real mpoly) \ isolate_variable_sparse p x 0 = p" +proof(induction p rule: mpoly_induct) + case (monom m a) + then show ?case + apply(cases "a=0") + by (simp_all add: isovarspase_monom vars_monom_keys) +next + case (sum p1 p2 m a) + then show ?case + by (simp add: monomials.rep_eq vars_add_monom isovarspar_sum) +qed + + +lemma degree0isovarspar : + assumes deg0 : "MPoly_Type.degree (p::real mpoly) x = 0" + shows "isolate_variable_sparse p x 0 = p" +proof - + have h1 : "p = (\i::nat \MPoly_Type.degree p x. isolate_variable_sparse p x i * Var x ^ i)" + using sum_over_zero by auto + have h2a : "\f. (\i::nat \0. f i) = f 0" + apply(simp add: sum_def) + by (metis add.right_neutral comm_monoid_add_class.sum_def finite.emptyI insert_absorb insert_not_empty sum.empty sum.insert) + have h2 : "p = isolate_variable_sparse p x 0 * Var x ^ 0" + using deg0 h1 h2a by auto + show ?thesis using h2 + by auto +qed + + +subsection "Summation Lemmas" + +lemma summation_normalized : + assumes nonzero : "(B ::real) \0" + shows "(\i = 0..<((n::nat)+1). (f i :: real) * B ^ (n - i)) = (\i = 0..<(n+1). (f i) / (B ^ i)) * (B^n)" +proof - + have h1a : "\x::real. ((\i = 0..<(n+1). (f i) / (B ^ i)) * x = (\i = 0..<(n+1). ((f i) / (B ^ i)) * x))" + apply(induction n ) + apply(auto) + by (simp add: distrib_right) + have h1 : "(\i = 0..<(n+1). (f i) / (B ^ i)) * (B^n) = (\i = 0..<(n+1). ((f i) / (B ^ i)) * (B^n))" + using h1a by auto + have h2 : "(\i = 0..<(n+1). ((f i) / (B ^ i)) * (B^n)) = (\i = 0..<(n+1). (f i) * ((B^n) / (B ^ i)))" + by auto + have h3 : "(\i = 0..<(n+1). (f i) * ((B^n) / (B ^ i))) = (\i = 0..<(n+1). (f i) * B ^ (n - i))" + using add.right_neutral nonzero power_diff by fastforce + show ?thesis using h1 h2 h3 by auto +qed + +lemma normalize_summation : + assumes nonzero : "(B::real)\0" + shows "(\i = 0.. + (\i = 0..<(n::nat)+1. (f i::real) / (B ^ i)) = 0" +proof - + have pow_zero : "\i. B^(i :: nat)\0" using nonzero by(auto) + have single_division_zero : "\X. B*(X::real)=0 \ X=0" using nonzero by(auto) + have h1: "(\i = 0.. ((\i = 0..i = 0..i = 0..0" + shows "(\i = 0..<(n+1). (f i) * B ^ (n - i)) * B ^ (n mod 2) < 0 + \ + (\i = 0..<((n::nat)+1). (f i::real) / (B ^ i)) < 0" +proof - + have h1 : "(\i = 0..<(n+1). (f i) * B ^ (n - i)) * B ^ (n mod 2) < 0 + \ (\i = 0..<(n+1). (f i) / (B ^ i)) * (B^n) * B ^ (n mod 2) < 0" + using summation_normalized nonzero by auto + have h2a : "n mod 2 = 0 \ n mod 2 = 1" by auto + have h2b : "n mod 2 = 1 \ odd n" by auto + have h2c : "(B^n) * B ^ (n mod 2) > 0" + using h2a h2b apply auto + using nonzero apply presburger + by (metis even_Suc mult.commute nonzero power_Suc zero_less_power_eq) + have h2 : "\x. ((x * (B^n) * B ^ (n mod 2) < 0) = (x<0))" + using h2c using mult.assoc by (metis mult_less_0_iff not_square_less_zero) + show ?thesis using h1 h2 by auto +qed + +subsection "Additional Lemmas with Vars" + +lemma not_in_isovarspar : "isolate_variable_sparse (p::real mpoly) var x = (q::real mpoly) \ var\(vars q)" + apply(simp add: isolate_variable_sparse_def vars_def) +proof - + assume a1: "MPoly (\m | m \ monomials p \ lookup m var = x. monomial (MPoly_Type.coeff p m) (Poly_Mapping.update var 0 m)) = q" + { fix pp :: "nat \\<^sub>0 nat" + have "isolate_variable_sparse p var x = q" + using a1 isolate_variable_sparse.abs_eq by blast + then have "var \ keys pp \ pp \ keys (mapping_of q)" + by (metis (no_types) coeff_def coeff_isolate_variable_sparse in_keys_iff) } + then show "\p\keys (mapping_of q). var \ keys p" + by meson +qed + +lemma not_in_add : "var\(vars (p::real mpoly)) \ var\(vars (q::real mpoly)) \ var\(vars (p+q))" + by (meson UnE in_mono vars_add) + +lemma not_in_mult : "var\(vars (p::real mpoly)) \ var\(vars (q::real mpoly)) \ var\(vars (p*q))" + by (meson UnE in_mono vars_mult) + +lemma not_in_neg : "var\(vars(p::real mpoly)) \ var\(vars(-p))" +proof - + have h: "var \ (vars (-1::real mpoly))" by (metis add_diff_cancel_right' add_neg_numeral_special(8) isolate_var_one isolate_zero isovarsparNotIn isovarspar_sum not_in_isovarspar) + show ?thesis using not_in_mult using h by fastforce +qed + +lemma not_in_sub : "var\(vars (p::real mpoly)) \ var\(vars (q::real mpoly)) \ var\(vars (p-q))" + using not_in_add not_in_neg by fastforce + + +lemma not_in_pow : "var\(vars(p::real mpoly)) \ var\(vars(p^i))" +proof (induction i) + case 0 + then show ?case using isolate_var_one not_in_isovarspar + by (metis power_0) +next + case (Suc i) + then show ?case using not_in_mult by simp +qed + +lemma not_in_sum_var: "(\i. var\(vars(f(i)::real mpoly))) \ var\(vars(\i\{0..<(n::nat)}.f(i)))" +proof (induction n) + case 0 + then show ?case using isolate_zero not_in_isovarspar by fastforce +next + case (Suc n) + have h1: "(sum f {0.. vars (f n)" by (simp add: Suc.prems) + then show ?case using h1 vars_add by (simp add: Suc.IH Suc.prems not_in_add) +qed + +lemma not_in_sum : "(\i. var\(vars(f(i)::real mpoly))) \ \(n::nat). var\(vars(\i\{0..x\keys (mapping_of p). var \ keys x \ + (\k f. (k \ keys f) = (lookup f k = 0)) \ + lookup (mapping_of p) a = 0 \ + (\aa. (if aa < length L then L[var := y] ! aa else 0) ^ lookup a aa) = + (\aa. (if aa < length L then L[var := x] ! aa else 0) ^ lookup a aa)" + apply(cases "lookup (mapping_of p) a = 0") + apply auto + apply(rule Prod_any.cong) + apply auto + using lookupNotIn nth_list_update_neq power_0 by smt + +lemma not_contains_insertion : + assumes notIn : "var \ vars (p:: real mpoly)" + assumes exists : "insertion (nth_default 0 (list_update L var x)) p = val" + shows "insertion (nth_default 0 (list_update L var y)) p = val" + using notIn exists + apply(simp add: insertion_def insertion_aux_def insertion_fun_def) + unfolding vars_def nth_default_def + using not_in_keys_iff_lookup_eq_zero + apply auto + apply(rule Sum_any.cong) + apply simp + using not_contains_insertion_helper[of p var _ L y x] +proof - + fix a :: "nat \\<^sub>0 nat" + assume a1: "\x\keys (mapping_of p). var \ keys x" + assume "\k f. ((k::'a) \ keys f) = (lookup f k = 0)" + then show "lookup (mapping_of p) a = 0 \ (\n. (if n < length L then L[var := y] ! n else 0) ^ lookup a n) = (\n. (if n < length L then L[var := x] ! n else 0) ^ lookup a n)" + using a1 \\a. \\x\keys (mapping_of p). var \ keys x; \k f. (k \ keys f) = (lookup f k = 0)\ \ lookup (mapping_of p) a = 0 \ (\aa. (if aa < length L then L[var := y] ! aa else 0) ^ lookup a aa) = (\aa. (if aa < length L then L[var := x] ! aa else 0) ^ lookup a aa)\ by blast +qed + + +subsection "Insertion Lemmas" +lemma insertion_sum_var : "((insertion f (\i\{0..<(n::nat)}.g(i))) = (\i\{0..(n::nat). ((insertion f (\i\{0..i\{0..(n::nat). ((insertion f (\i\n. g(i))) = (\i\n. insertion f (g i)))" + by (metis (no_types, lifting) fun_sum_commute insertion_add insertion_zero sum.cong) + +lemma insertion_pow : "insertion f (p^i) = (insertion f p)^i" +proof (induction i) + case 0 + then show ?case by auto +next + case (Suc n) + then show ?case by (simp add: insertion_mult) +qed + +lemma insertion_neg : "insertion f (-p) = -insertion f p" + by (metis add.inverse_inverse insertionNegative) + +lemma insertion_var : + "length L > var \ insertion (nth_default 0 (list_update L var x)) (Var var) = x" + by (auto simp: monomials_Var coeff_Var insertion_code nth_default_def) + +lemma insertion_var_zero : "insertion (nth_default 0 (x#xs)) (Var 0) = x" using insertion_var + by fastforce + +lemma notIn_insertion_sub : "x\vars(p::real mpoly) \ x\vars(q::real mpoly) + \ insertion f (p-q) = insertion f p - insertion f q" + by (metis ab_group_add_class.ab_diff_conv_add_uminus insertion_add insertion_neg) + +lemma insertion_sub : "insertion f (A-B :: real mpoly) = insertion f A - insertion f B" + using insertion_neg insertion_add + by (metis uminus_add_conv_diff) + +lemma insertion_four : "insertion ((nth_default 0) xs) 4 = 4" + by (metis (no_types, lifting) insertion_add insertion_one numeral_plus_numeral one_add_one semiring_norm(2) semiring_norm(6)) + +lemma insertion_add_ind_basecase: + "insertion (nth (list_update L var x)) ((\i::nat \ 0. isolate_variable_sparse p var i * (Var var)^i)) + = (\i = 0..<(0+1). insertion (nth (list_update L var x)) (isolate_variable_sparse p var i * (Var var)^i))" +proof - + have h1: "((\i::nat \ 0. isolate_variable_sparse p var i * (Var var)^i)) + = (isolate_variable_sparse p var 0 * (Var var)^0)" + by auto + show ?thesis using h1 + by auto +qed + +lemma insertion_add_ind: + "insertion (nth_default 0 (list_update L var x)) ((\i::nat \ d. isolate_variable_sparse p var i * (Var var)^i)) + = (\i = 0..<(d+1). insertion (nth_default 0 (list_update L var x)) (isolate_variable_sparse p var i * (Var var)^i))" +proof (induction d) + case 0 + then show ?case using insertion_add_ind_basecase nth_default_def + by auto +next + case (Suc n) + then show ?case using insertion_add apply auto + by (simp add: insertion_add) +qed + +lemma sum_over_degree_insertion : + assumes lLength : "length L > var" + assumes deg : "MPoly_Type.degree (p::real mpoly) var = d" + shows "(\i = 0..<(d+1). insertion (nth_default 0 (list_update L var x)) (isolate_variable_sparse p var i) * (x^i)) + = insertion (nth_default 0 (list_update L var x)) p" +proof - + have h1: "(p::real mpoly) = (\i::nat \(MPoly_Type.degree p var). isolate_variable_sparse p var i * (Var var)^i)" using sum_over_zero by auto + have h2: "insertion (nth_default 0 (list_update L var x)) p = + insertion (nth_default 0 (list_update L var x)) ((\i::nat \ d. isolate_variable_sparse p var i * (Var var)^i))" using h1 deg by auto + have h3: "insertion (nth_default 0 (list_update L var x)) p = (\i = 0..<(d+1). insertion (nth_default 0 (list_update L var x)) (isolate_variable_sparse p var i * (Var var)^i))" + using h2 insertion_add_ind nth_default_def + by (simp add: ) + show ?thesis using h3 insertion_var insertion_pow + by (metis (no_types, lifting) insertion_mult lLength sum.cong) +qed + + + +lemma insertion_isovarspars_free : + "insertion (nth_default 0 (list_update L var x)) (isolate_variable_sparse (p::real mpoly) var (i::nat)) + =insertion (nth_default 0 (list_update L var y)) (isolate_variable_sparse (p::real mpoly) var (i::nat))" +proof - + have h : "var \ vars(isolate_variable_sparse (p::real mpoly) var (i::nat))" + by (simp add: not_in_isovarspar) + then show ?thesis using not_contains_insertion + by blast +qed +lemma insertion_zero : "insertion f (Const 0 ::real mpoly) = 0" + by (metis add_cancel_right_right add_zero insertion_zero) + +lemma insertion_one : "insertion f (Const 1 ::real mpoly) = 1" + by (metis insertion_one mult.right_neutral mult_one_left) + +lemma insertion_const : "insertion f (Const c::real mpoly) = (c::real)" + by (auto simp: monomials_Const coeff_Const insertion_code) + + +subsection "Putting Things Together" +subsubsection "More Degree Lemmas" +lemma degree_add_leq : + assumes h1 : "MPoly_Type.degree a var \ x" + assumes h2 : "MPoly_Type.degree b var \ x" + shows "MPoly_Type.degree (a+b) var \ x" + using degree_eq_iff coeff_add coeff_not_in_monomials + by (smt (z3) More_MPoly_Type.coeff_add add.left_neutral coeff_eq_zero_iff degree_le_iff h1 h2) + +lemma degree_add_less : + assumes h1 : "MPoly_Type.degree a var < x" + assumes h2 : "MPoly_Type.degree b var < x" + shows "MPoly_Type.degree (a+b) var < x" +proof - + obtain pp :: "nat \ nat \ 'a mpoly \ nat \\<^sub>0 nat" where + "\x0 x1 x2. (\v3. v3 \ monomials x2 \ \ lookup v3 x1 < x0) = (pp x0 x1 x2 \ monomials x2 \ \ lookup (pp x0 x1 x2) x1 < x0)" + by moura + then have f1: "\m n na. (\ MPoly_Type.degree m n < na \ 0 < na \ (\p. p \ monomials m \ lookup p n < na)) \ (MPoly_Type.degree m n < na \ \ 0 < na \ pp na n m \ monomials m \ \ lookup (pp na n m) n < na)" + by (metis (no_types) degree_less_iff) + then have "0 < x \ (\p. p \ monomials a \ lookup p var < x)" + using assms(1) by presburger + then show ?thesis + using f1 by (metis MPolyExtension.coeff_add add.left_neutral assms(2) coeff_eq_zero_iff) +qed + +lemma degree_sum : "(\i\{0..n::nat}. MPoly_Type.degree (f i :: real mpoly) var \ x) \ (MPoly_Type.degree (\x\{0..n}. f x) var) \ x" +proof(induction n) + case 0 + then show ?case by auto +next + case (Suc n) + then show ?case by(simp add: degree_add_leq) +qed + +lemma degree_sum_less : "(\i\{0..n::nat}. MPoly_Type.degree (f i :: real mpoly) var < x) \ (MPoly_Type.degree (\x\{0..n}. f x) var) < x" +proof(induction n) + case 0 + then show ?case by auto +next + case (Suc n) + then show ?case by(simp add: degree_add_less) +qed + + +lemma varNotIn_degree : + assumes "var \ vars p" + shows "MPoly_Type.degree p var = 0" +proof- + have "\m\monomials p. lookup m var = 0" + using assms unfolding vars_def keys_def + using monomials.rep_eq by fastforce + then show ?thesis + using degree_less_iff by blast +qed + +lemma degree_mult_leq : + assumes pnonzero: "(p::real mpoly)\0" + assumes qnonzero: "(q::real mpoly)\0" + shows "MPoly_Type.degree ((p::real mpoly) * (q::real mpoly)) var \ (MPoly_Type.degree p var) + (MPoly_Type.degree q var)" +proof(cases "MPoly_Type.degree (p*q) var =0") + case True + then show ?thesis by simp +next + case False + have hp: "\m\monomials p. lookup m var \ MPoly_Type.degree p var" using degree_eq_iff + by (metis zero_le) + have hq: "\m\monomials q. lookup m var \ MPoly_Type.degree q var" using degree_eq_iff + by (metis zero_le) + have hpq: "\m\{a+b | a b . a \ monomials p \ b \ monomials q}. + lookup m var \ (MPoly_Type.degree p var) + (MPoly_Type.degree q var)" + by (smt add_le_mono hp hq mem_Collect_eq plus_poly_mapping.rep_eq) + have h1: "(\m\monomials (p*q). lookup m var \ (MPoly_Type.degree p var) + (MPoly_Type.degree q var))" + using mult_monomials_dir_one hpq + by blast + then show ?thesis using h1 degree_eq_iff False + by (simp add: degree_le_iff) +qed + +lemma degree_exists_monom: + assumes "p\0" + shows "\m\monomials p. lookup m var = MPoly_Type.degree p var" +proof(cases "MPoly_Type.degree p var =0") + case True + have h1: "\m\monomials p. lookup m var = 0" unfolding monomials_def + by (metis True assms(1) aux degree_eq_iff in_keys_iff mapping_of_inject monomials.rep_eq monomials_def zero_mpoly.rep_eq) + then show ?thesis using h1 + using True by simp +next + case False + then show ?thesis using degree_eq_iff assms(1) apply(auto) + by (metis degree_eq_iff dual_order.strict_iff_order) +qed + +lemma degree_not_exists_monom: + assumes "p\0" + shows "\ (\ m\monomials p. lookup m var > MPoly_Type.degree p var)" +proof - + show ?thesis using degree_less_iff by blast +qed + +lemma degree_monom: "MPoly_Type.degree (MPoly_Type.monom x y) v = (if y = 0 then 0 else lookup x v)" + by (auto simp: degree_eq_iff) + +lemma degree_plus_disjoint: + "MPoly_Type.degree (p + MPoly_Type.monom m c) v = max (MPoly_Type.degree p v) (MPoly_Type.degree (MPoly_Type.monom m c) v)" + if "m \ monomials p" + for p::"real mpoly" + using that + apply (subst degree_eq_iff) + apply (auto simp: monomials_add_disjoint) + apply (auto simp: degree_eq_iff degree_monom) + apply (metis MPoly_Type.degree_zero degree_exists_monom less_numeral_extra(3)) + using degree_le_iff apply blast + using degree_eq_iff + apply (metis max_def neq0_conv) + apply (metis degree_eq_iff max.coboundedI1 neq0_conv) + apply (metis MPoly_Type.degree_zero degree_exists_monom max_def zero_le) + using degree_le_iff max.cobounded1 by blast + +subsubsection "More isolate\\_variable\\_sparse lemmas" + +lemma isolate_variable_sparse_ne_zeroD: + "isolate_variable_sparse mp v x \ 0 \ x \ MPoly_Type.degree mp v" + using isovar_greater_degree leI by blast + +context includes poly.lifting begin +lift_definition mpoly_to_nested_poly::"'a::comm_monoid_add mpoly \ nat \ 'a mpoly Polynomial.poly" is + "\(mp::'a mpoly) (v::nat) (p::nat). isolate_variable_sparse mp v p" + \ \note \<^const>\extract_var\ nests the other way around\ + unfolding MOST_iff_cofinite +proof - + fix mp::"'a mpoly" and v::nat + have "{p. isolate_variable_sparse mp v p \ 0} \ {0..MPoly_Type.degree mp v}" + (is "?s \ _") + by (auto dest!: isolate_variable_sparse_ne_zeroD) + also have "finite \" by simp + finally (finite_subset) show "finite ?s" . +qed + +lemma degree_eq_0_mpoly_to_nested_polyI: + "mpoly_to_nested_poly mp v = 0 \ MPoly_Type.degree mp v = 0" + apply transfer' + apply (simp add: degree_eq_iff) + apply transfer' + apply (auto simp: fun_eq_iff) +proof - + fix mpa :: "'a mpoly" and va :: nat and m :: "nat \\<^sub>0 nat" + assume a1: "\x. (\m | m \ monomials mpa \ lookup m va = x. monomial (MPoly_Type.coeff mpa m) (Poly_Mapping.update va 0 m)) = 0" + assume a2: "m \ monomials mpa" + have f3: "\m p. lookup (mapping_of m) p \ (0::'a) \ p \ monomials m" + by (metis (full_types) coeff_def coeff_eq_zero_iff) + have f4: "\n. mapping_of (isolate_variable_sparse mpa va n) = 0" + using a1 by (simp add: isolate_variable_sparse.rep_eq) + have "\p n. lookup 0 (p::nat \\<^sub>0 nat) = (0::'a) \ (0::nat) = n" + by simp + then show "lookup m va = 0" + using f4 f3 a2 by (metis coeff_def coeff_isolate_variable_sparse lookup_eq_and_update_lemma) +qed + +lemma coeff_eq_zero_mpoly_to_nested_polyD: "mpoly_to_nested_poly mp v = 0 \ MPoly_Type.coeff mp 0 = 0" + apply transfer' + apply transfer' + by (metis (no_types) coeff_def coeff_isolate_variable_sparse isolate_variable_sparse.rep_eq lookup_zero update_0_0) + +lemma mpoly_to_nested_poly_eq_zero_iff[simp]: + "mpoly_to_nested_poly mp v = 0 \ mp = 0" + apply (auto simp: coeff_eq_zero_mpoly_to_nested_polyD degree_eq_0_mpoly_to_nested_polyI) +proof - + show "mpoly_to_nested_poly mp v = 0 \ mp = 0" + apply (frule degree_eq_0_mpoly_to_nested_polyI) + apply (frule coeff_eq_zero_mpoly_to_nested_polyD) + apply (transfer' fixing: mp v) + apply (transfer' fixing: mp v) + apply (auto simp: fun_eq_iff mpoly_eq_iff intro!: sum.neutral) + proof - + fix m :: "nat \\<^sub>0 nat" + assume a1: "\x. (\m | m \ monomials mp \ lookup m v = x. monomial (MPoly_Type.coeff mp m) (Poly_Mapping.update v 0 m)) = 0" + assume a2: "MPoly_Type.degree mp v = 0" + have "\n. isolate_variable_sparse mp v n = 0" + using a1 by (simp add: isolate_variable_sparse.abs_eq zero_mpoly.abs_eq) + then have f3: "\p. MPoly_Type.coeff mp p = MPoly_Type.coeff 0 p \ lookup p v \ 0" + by (metis (no_types) coeff_isolate_variable_sparse lookup_update_self) + then show "MPoly_Type.coeff mp m = 0" + using a2 coeff_zero + by (metis coeff_not_in_monomials degree_eq_iff) + qed + show "mp = 0 \ mpoly_to_nested_poly 0 v = 0" + subgoal + apply transfer' + apply transfer' + by (auto simp: fun_eq_iff intro!: sum.neutral) + done +qed + +lemma isolate_variable_sparse_degree_eq_zero_iff: "isolate_variable_sparse p v (MPoly_Type.degree p v) = 0 \ p = 0" + apply (transfer') + apply auto +proof - + fix pa :: "'a mpoly" and va :: nat + assume "(\m | m \ monomials pa \ lookup m va = MPoly_Type.degree pa va. monomial (MPoly_Type.coeff pa m) (Poly_Mapping.update va 0 m)) = 0" + then have "mapping_of (isolate_variable_sparse pa va (MPoly_Type.degree pa va)) = 0" + by (simp add: isolate_variable_sparse.rep_eq) + then show "pa = 0" + by (metis (no_types) coeff_def coeff_eq_zero_iff coeff_isolate_variable_sparse degree_exists_monom lookup_eq_and_update_lemma lookup_zero) +qed + +lemma degree_eq_univariate_degree: "MPoly_Type.degree p v = + (if p = 0 then 0 else Polynomial.degree (mpoly_to_nested_poly p v))" + apply auto + apply (rule antisym) + subgoal + apply (rule Polynomial.le_degree) + apply (auto simp: ) + apply transfer' + by (simp add: isolate_variable_sparse_degree_eq_zero_iff) + subgoal apply (rule Polynomial.degree_le) + apply (auto simp: elim!: degree_eq_zeroE) + apply transfer' + by (simp add: isovar_greater_degree) + done + +lemma compute_mpoly_to_nested_poly[code]: + "coeffs (mpoly_to_nested_poly mp v) = + (if mp = 0 then [] + else map (isolate_variable_sparse mp v) [0.. lookup m v \ i then 0 else MPoly_Type.monom (Poly_Mapping.update v 0 m) a)" +proof - + have *: "{x. x = m \ lookup x v = i} = (if lookup m v = i then {m} else {})" + by auto + show ?thesis + by (transfer' fixing: m a v i) (simp add:*) +qed + + + +lemma isolate_variable_sparse_monom_mult: + "isolate_variable_sparse (MPoly_Type.monom m a * q) v n = + (if n \ lookup m v + then MPoly_Type.monom (Poly_Mapping.update v 0 m) a * isolate_variable_sparse q v (n - lookup m v) + else 0)" + for q::"'a::semiring_no_zero_divisors mpoly" + apply (auto simp: MPoly_Type.mult_monom) + subgoal + apply transfer' + subgoal for mon v i a q + apply (auto simp add: monomials_monom_mult sum_distrib_left) + apply (rule sum.reindex_bij_witness_not_neutral[where + j="\a. a - mon" + and i="\a. mon + a" + and S'="{}" + and T'="{}" + ]) + apply (auto simp: lookup_add) + apply (auto simp: poly_mapping_eq_iff fun_eq_iff single.rep_eq Poly_Mapping.mult_single) + apply (auto simp: when_def More_MPoly_Type.coeff_monom_mult) + by (auto simp: lookup_update lookup_add split: if_splits) + done + subgoal + apply transfer' + apply (auto intro!: sum.neutral simp: monomials_monom_mult ) + apply (rule poly_mapping_eqI) + apply (auto simp: lookup_single when_def) + by (simp add: lookup_add) + done + +lemma isolate_variable_sparse_mult: + "isolate_variable_sparse (p * q) v n = (\i\n. isolate_variable_sparse p v i * isolate_variable_sparse q v (n - i))" + for p q::"'a::semiring_no_zero_divisors mpoly" +proof (induction p rule: mpoly_induct) + case (monom m a) + then show ?case + by (cases "a = 0") + (auto simp add: mpoly_eq_iff coeff_sum coeff_mult if_conn if_distrib if_distribR + isolate_variable_sparse_monom isolate_variable_sparse_monom_mult + cong: if_cong) +next + case (sum p1 p2 m a) + then show ?case + by (simp add: distrib_right isovarspar_sum sum.distrib) +qed + +subsubsection "More Miscellaneous" +lemma var_not_in_Const : "var\vars (Const x :: real mpoly)" + unfolding vars_def keys_def + by (smt UN_iff coeff_def coeff_isolate_variable_sparse const_lookup_zero keys_def lookup_eq_zero_in_keys_contradict) + +lemma mpoly_to_nested_poly_mult: + "mpoly_to_nested_poly (p * q) v = mpoly_to_nested_poly p v * mpoly_to_nested_poly q v" + for p q::"'a::{comm_semiring_0, semiring_no_zero_divisors} mpoly" + by (auto simp: poly_eq_iff coeff_mult mpoly_to_nested_poly.rep_eq isolate_variable_sparse_mult) + +lemma get_if_const_insertion : + assumes "get_if_const (p::real mpoly) = Some r" + shows "insertion f p = r" +proof- + have "Set.is_empty (vars p)" + apply(cases "Set.is_empty (vars p)") + apply(simp) using assms by(simp) + then have "(MPoly_Type.coeff p 0) = r" + using assms by simp + then show ?thesis + by (metis Set.is_empty_def \Set.is_empty (vars p)\ empty_iff insertion_irrelevant_vars insertion_trivial) +qed + +subsubsection "Yet more Degree Lemmas" +lemma degree_mult: + fixes p q::"'a::{comm_semiring_0, ring_1_no_zero_divisors} mpoly" + assumes "p \ 0" + assumes "q \ 0" + shows "MPoly_Type.degree (p * q) v = MPoly_Type.degree p v + MPoly_Type.degree q v" + using assms + by (auto simp add: degree_eq_univariate_degree mpoly_to_nested_poly_mult Polynomial.degree_mult_eq) + +lemma degree_eq: + assumes "(p::real mpoly) = (q:: real mpoly)" + shows "MPoly_Type.degree p x = MPoly_Type.degree q x" + by (simp add: assms) + +lemma degree_var_i : "MPoly_Type.degree (((Var x)^i:: real mpoly)) x = i" +proof (induct i) + case 0 + then show ?case using degree_const + by simp +next + case (Suc i) + have multh: "(Var x)^(Suc i) = ((Var x)^i::real mpoly) * (Var x:: real mpoly)" + using power_Suc2 by blast + have deg0h: "MPoly_Type.degree 0 x = 0" + by simp + have deg1h: "MPoly_Type.degree (Var x::real mpoly) x = 1" + using degree_one + by blast + have nonzeroh1: "(Var x:: real mpoly) \ 0" + using degree_eq deg0h deg1h by auto + have nonzeroh2: "((Var x)^i:: real mpoly) \ 0" + using degree_eq deg0h Suc.hyps + by (metis one_neq_zero power_0) + have sumh: "(MPoly_Type.degree (((Var x)^i:: real mpoly) * (Var x:: real mpoly)) x) = (MPoly_Type.degree ((Var x)^i::real mpoly) x) + (MPoly_Type.degree (Var x::real mpoly) x)" + using degree_mult[where p = "(Var x)^i::real mpoly", where q = "Var x::real mpoly"] nonzeroh1 nonzeroh2 + by blast + then show ?case using sumh deg1h + by (metis Suc.hyps Suc_eq_plus1 multh) +qed + + +lemma degree_less_sum: + assumes "MPoly_Type.degree (p::real mpoly) var = n" + assumes "MPoly_Type.degree (q::real mpoly) var = m" + assumes "m < n" + shows "MPoly_Type.degree (p + q) var = n" +proof - + have h1: "n > 0" + using assms(3) neq0_conv by blast + have h2: "(\m\monomials p. lookup m var = n) \ (\m\monomials p. lookup m var \ n)" + using degree_eq_iff assms(1) + by (metis degree_ge_iff h1 order_refl) + have h3: "(\m\monomials (p + q). lookup m var = n)" + using h2 + by (metis MPolyExtension.coeff_add add.right_neutral assms(2) assms(3) coeff_eq_zero_iff degree_not_exists_monom) + have h4: "(\m\monomials (p + q). lookup m var \ n)" + using h2 assms(3) assms(2) + using degree_add_leq degree_le_iff dual_order.strict_iff_order by blast + show ?thesis using degree_eq_iff h3 h4 + by (metis assms(3) gr_implies_not0) +qed + +lemma degree_less_sum': + assumes "MPoly_Type.degree (p::real mpoly) var = n" + assumes "MPoly_Type.degree (q::real mpoly) var = m" + assumes "n < m" + shows "MPoly_Type.degree (p + q) var = m" using degree_less_sum[OF assms(2) assms(1) assms(3)] + by (simp add: add.commute) + +(* Result on the degree of the derivative *) + +lemma nonzero_const_is_nonzero: + assumes "(k::real) \ 0" + shows "((Const k)::real mpoly) \ 0" + by (metis MPoly_Type.insertion_zero assms insertion_const) + +lemma degree_derivative : + assumes "MPoly_Type.degree p x > 0" + shows "MPoly_Type.degree p x = MPoly_Type.degree (derivative x p) x + 1" +proof - + define f where "f i = (isolate_variable_sparse p x (i+1) * (Var x)^(i) * (Const (i+1)))" for i + define n where "n = MPoly_Type.degree p x-1" + have d : "\m\monomials p. lookup m x = n+1" + using n_def degree_eq_iff assms + by (metis add.commute less_not_refl2 less_one linordered_semidom_class.add_diff_inverse) + have h1a : "\i. MPoly_Type.degree (isolate_variable_sparse p x i) x = 0" + by (simp add: not_in_isovarspar varNotIn_degree) + have h1b : "\i::nat. MPoly_Type.degree ((Var x)^i:: real mpoly) x = i" + using degree_var_i by auto + have h1c1 : "\i. (Var(x)^(i)::real mpoly)\0" + by (metis MPoly_Type.degree_zero h1b power_0 zero_neq_one) + have h1c1var: "((Var x)^i:: real mpoly) \ 0" using h1c1 by blast + have h1c2 : "((Const ((i::nat) + 1))::real mpoly)\0" + using nonzero_const_is_nonzero + by auto + have h1c3: "(isolate_variable_sparse p x (n + 1)) \ 0" using d + by (metis One_nat_def Suc_pred add.commute assms isolate_variable_sparse_degree_eq_zero_iff n_def not_gr_zero not_in_isovarspar plus_1_eq_Suc varNotIn_degree) + have h3: "(isolate_variable_sparse p x (i+1) = 0) \ (MPoly_Type.degree (f i) x) = 0" + by (simp add: f_def) + have degh1: "(MPoly_Type.degree (((Const ((i::nat)+1))::real mpoly)*(Var x)^i) x) = + ((MPoly_Type.degree ((Const (i+1))::real mpoly) x) + (MPoly_Type.degree ((Var x)^i:: real mpoly) x))" + using h1c2 h1c1var degree_mult[where p="((Const ((i::nat)+1))::real mpoly)", where q="((Var x)^i:: real mpoly)"] + by blast + then have degh2: "(MPoly_Type.degree (((Const ((i::nat)+1))::real mpoly)*(Var x)^i) x) = i" + using degree_var_i degree_const + by simp + have nonzerohyp: "(((Const ((i::nat)+1))::real mpoly)*(Var x)^i) \ 0" + proof (induct i) + case 0 + then show ?case + by (simp add: nonzero_const_is_nonzero) + next + case (Suc i) + then show ?case using degree_eq degh2 + by (metis Suc_eq_plus1 h1c1 mult_eq_0_iff nat.simps(3) nonzero_const_is_nonzero of_nat_eq_0_iff) + qed + have h4a1: "(isolate_variable_sparse p x (i+1) \ 0) \ (MPoly_Type.degree (isolate_variable_sparse p x (i+1) * ((Var x)^(i) * (Const (i+1)))::real mpoly) x = + (MPoly_Type.degree (isolate_variable_sparse p x (i+1):: real mpoly) x) + (MPoly_Type.degree (((Const (i+1)) * (Var x)^(i))::real mpoly) x))" + using nonzerohyp degree_mult[where p = "(isolate_variable_sparse p x (i+1))::real mpoly", where q = "((Const (i+1)) * (Var x)^(i)):: real mpoly", where v = "x"] + by (simp add: mult.commute) + have h4: "(isolate_variable_sparse p x (i+1) \ 0) \ (MPoly_Type.degree (f i) x) = i" + using h4a1 f_def degh2 h1a + by (metis (no_types, hide_lams) add.left_neutral mult.commute mult.left_commute of_nat_1 of_nat_add) + have h5: "(MPoly_Type.degree (f i) x) \ i" using h3 h4 by auto + have h6: "(MPoly_Type.degree (f n) x) = n" using h1c3 h4 + by (smt One_nat_def add.right_neutral add_Suc_right degree_const degree_mult divisors_zero f_def h1a h1b h1c1 mult.commute nonzero_const_is_nonzero of_nat_1 of_nat_add of_nat_neq_0) + have h7a: "derivative x p = (\i\{0..MPoly_Type.degree p x-1}. isolate_variable_sparse p x (i+1) * (Var x)^i * (Const (i+1)))" using derivative_def by auto + have h7b: "(\i\{0..MPoly_Type.degree p x-1}. isolate_variable_sparse p x (i+1) * (Var x)^i * (Const (i+1))) = (\i\{0..MPoly_Type.degree p x-1}. (f i))" using f_def + by (metis Suc_eq_plus1 add.commute semiring_1_class.of_nat_simps(2)) + have h7c: "derivative x p = (\i\{0..MPoly_Type.degree p x-1}. (f i))" using h7a h7b by auto + have h7: "derivative x p = (\i\{0..n}. (f i))" using n_def h7c + by blast + have h8: "n > 0 \ ((MPoly_Type.degree (\i\{0..(n-1)}. (f i)) x) < n)" + proof (induct n) + case 0 + then show ?case + by blast + next + case (Suc n) + then show ?case using h5 degree_less_sum + by (smt add_cancel_right_right atLeastAtMost_iff degree_const degree_mult degree_sum_less degree_var_i diff_Suc_1 f_def h1a le_imp_less_Suc mult.commute mult_eq_0_iff) + qed + have h9a: "n = 0 \ MPoly_Type.degree (\i\{0..n}. (f i)) x = n" using h6 + by auto + have h9b: "n > 0 \ MPoly_Type.degree (\i\{0..n}. (f i)) x = n" + proof - + have h9bhyp: "n > 0 \ (MPoly_Type.degree (\i\{0..n}. (f i)) x = MPoly_Type.degree ((\i\{0..(n-1)}. (f i)) + (f n)) x)" + by (metis Suc_diff_1 sum.atLeast0_atMost_Suc) + have h9bhyp2: "n > 0 \ ((MPoly_Type.degree ((\i\{0..(n-1)}. (f i)) + (f n)) x) = n)" + using h6 h8 degree_less_sum + by (simp add: add.commute) + then show ?thesis using h9bhyp2 h9bhyp + by linarith + qed + have h9: "MPoly_Type.degree (\i\{0..n}. (f i)) x = n" using h9a h9b + by blast + have h10: "MPoly_Type.degree (derivative x p) x = n" using h9 h7 + by simp + show ?thesis using h10 n_def + using assms by linarith +qed + + +lemma express_poly : + assumes h : "MPoly_Type.degree (p::real mpoly) var = 1 \ MPoly_Type.degree p var = 2" + shows "p = + (isolate_variable_sparse p var 2)*(Var var)^2 + +(isolate_variable_sparse p var 1)*(Var var) + +(isolate_variable_sparse p var 0)" +proof- + have h1a: "MPoly_Type.degree p var = 1 \ p = + isolate_variable_sparse p var 0 + + isolate_variable_sparse p var 1 * Var var" + using sum_over_zero[where mp="p",where x="var"] + by auto + have h1b: "MPoly_Type.degree p var = 1 \ isolate_variable_sparse p var 2 = 0" + using isovar_greater_degree + by (simp add: isovar_greater_degree) + have h1: "MPoly_Type.degree p var = 1 \ p = + isolate_variable_sparse p var 0 + + isolate_variable_sparse p var 1 * Var var + + isolate_variable_sparse p var 2 * (Var var)^2" using h1a h1b by auto + have h2a: "MPoly_Type.degree p var = 2 \ p = (\i::nat \ 2. isolate_variable_sparse p var i * Var var^i)" + using sum_over_zero[where mp="p", where x="var"] by auto + have h2b: "(\i::nat \ 2. isolate_variable_sparse p var i * Var var^i) = + (\i::nat \ 1. isolate_variable_sparse p var i * Var var^i) + + isolate_variable_sparse p var 2 * (Var var)^2" apply auto + by (simp add: numerals(2)) + have h2: "MPoly_Type.degree p var = 2 \ p = + isolate_variable_sparse p var 0 + + isolate_variable_sparse p var 1 * Var var + + isolate_variable_sparse p var 2 * (Var var)^2" + using h2a h2b by auto + have h3: "isolate_variable_sparse p var 0 + + isolate_variable_sparse p var 1 * Var var + + isolate_variable_sparse p var 2 * (Var var)^2 = + isolate_variable_sparse p var 2 * (Var var)^2 + + isolate_variable_sparse p var 1 * Var var + + isolate_variable_sparse p var 0" by (simp add: add.commute) + + show ?thesis using h h1 h2 h3 by presburger +qed + +lemma degree_isovarspar : "MPoly_Type.degree (isolate_variable_sparse (p::real mpoly) x i) x = 0" + using not_in_isovarspar varNotIn_degree by blast + + +end diff --git a/thys/Virtual_Substitution/ExportProofs.thy b/thys/Virtual_Substitution/ExportProofs.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/ExportProofs.thy @@ -0,0 +1,128 @@ +subsection "Top-Level Algorithm Proofs" +theory ExportProofs + imports HeuristicProofs Exports + (*"HOL-Library.Code_Real_Approx_By_Float"*) + HOL.String "HOL-Library.Code_Target_Int" "HOL-Library.Code_Target_Nat" PrettyPrinting Show.Show_Real +begin + + +theorem "eval (Unpower f) L = eval f L" unfolding unpower_eval Unpower_def by auto + + +theorem VSLuckiest: "\xs. eval (VSLuckiest \) xs = eval \ xs" + unfolding VSLuckiest_def Unpower_def opt_def + using QE_dnf_eval[OF luckiestFind_eval' opt_no_group] opt_no_group + by fastforce + +theorem VSLuckiestBlocks : "\xs. eval (VSLuckiestBlocks \) xs = eval \ xs" + unfolding VSLuckiestBlocks_def Unpower_def opt_group_def + using QE_dnf'_eval[OF the_real_step_augment[OF luckiestFind_eval, of "\x _ _. x"] opt] + using opt + by fastforce + +theorem VSEquality : "\xs. eval (VSEquality \) xs = eval \ xs" + unfolding VSEquality_def Unpower_def opt_def + using QE_dnf_eval[OF qe_eq_repeat_eval' opt_no_group] + using opt_no_group VSLuckiest + by fastforce + + +theorem VSEqualityBlocks : "\xs. eval (VSEqualityBlocks \) xs = eval \ xs" + unfolding VSEqualityBlocks_def Unpower_def opt_group_def + using QE_dnf'_eval[OF the_real_step_augment[OF qe_eq_repeat_eval, of "\x _ _. x"] opt] + using opt VSLuckiestBlocks + by fastforce + +theorem VSGeneralBlocks : "\xs. eval (VSGeneralBlocks \) xs = eval \ xs" + unfolding VSGeneralBlocks_def Unpower_def opt_group_def + using QE_dnf'_eval[OF the_real_step_augment[OF gen_qe_eval, of "\x _ _. x"] opt] + using opt VSLuckiestBlocks + by fastforce + +theorem VSLuckyBlocks : "\xs. eval (VSLuckyBlocks \) xs = eval \ xs" + unfolding VSLuckyBlocks_def Unpower_def opt_group_def + using QE_dnf'_eval[OF the_real_step_augment[OF luckyFind'_eval, of "\x _ _. x"] opt] + using opt VSLuckiestBlocks + by fastforce + +theorem VSLEGBlocks : "\xs. eval (VSLEGBlocks \) xs = eval \ xs" + unfolding VSLEGBlocks_def opt_group_def + using VSEqualityBlocks VSGeneralBlocks VSLuckyBlocks + by fastforce + +theorem VSEqualityBlocksLimited : "\xs. eval (VSEqualityBlocksLimited \) xs = eval \ xs" + unfolding VSEqualityBlocksLimited_def Unpower_def opt_group_def + using QE_dnf_eval[OF qe_eq_repeat_eval_augment opt] opt VSLuckiestBlocks + by fastforce + + +theorem VSEquality_3_times : "\xs. eval (VSEquality_3_times \) xs = eval \ xs" + using VSEquality unfolding VSEquality_3_times_def by auto + +theorem VSGeneral: "\xs. eval (VSGeneral \) xs = eval \ xs" + unfolding VSGeneral_def Unpower_def Unpower_def opt_def + using QE_dnf_eval[OF gen_qe_eval' opt_no_group] + using opt_no_group VSLuckiest + by fastforce + +theorem VSGeneralBlocksLimited: "\xs. eval (VSGeneralBlocksLimited \) xs = eval \ xs" + unfolding VSGeneralBlocksLimited_def Unpower_def opt_group_def + using QE_dnf_eval[OF gen_qe_eval_augment opt] opt VSLuckiestBlocks + by fastforce + +theorem VSBrowns: "\xs. eval (VSBrowns \) xs = eval \ xs" + unfolding VSBrowns_def Unpower_def opt_group_def + using QE_dnf_eval[OF step_augmenter_eval[of gen_qe brownsHeuristic, OF gen_qe_eval brownHueristic_less_than] opt] opt VSLuckiestBlocks + by fastforce + + +theorem VSGeneral_3_times : "\xs. eval (VSGeneral_3_times \) xs = eval \ xs" + unfolding VSGeneral_3_times_def using VSGeneral + by auto + +theorem VSLucky: "\xs. eval (VSLucky \) xs = eval \ xs" + unfolding VSLucky_def Unpower_def opt_def + using QE_dnf_eval[OF luckyFind_eval' opt_no_group] opt_no_group VSLuckiest + by fastforce + +theorem VSLuckyBlocksLimited: "\xs. eval (VSLuckyBlocksLimited \) xs = eval \ xs" + unfolding VSLuckyBlocksLimited_def Unpower_def opt_group_def + using QE_dnf_eval[OF luckyFind_eval_augment opt] opt VSLuckiestBlocks + by fastforce + +theorem VSLEG: "\xs. eval (VSLEG \) xs = eval \ xs" + unfolding VSLEG_def + using VSLucky VSEquality VSGeneral by auto + +theorem VSHeuristic : "\xs. eval(VSHeuristic \) xs = eval \ xs" + unfolding VSHeuristic_def Unpower_def opt_group_def + using QE_dnf_eval[OF superPicker_eval opt] opt VSLuckiestBlocks + by fastforce + + +theorem VSLuckiestRepeat : "\xs. eval (VSLuckiestRepeat \) xs = eval \ xs" + unfolding VSLuckiestRepeat_def using repeatAmountOfQuantifiers_eval[OF] using VSLuckiest + by blast + + +export_code + print_mpoly + VSGeneral VSEquality VSLucky VSLEG VSLuckiest + VSGeneralBlocksLimited VSEqualityBlocksLimited VSLuckyBlocksLimited + VSGeneralBlocks VSEqualityBlocks VSLuckyBlocks VSLEGBlocks VSLuckiestBlocks + QE_dnf + gen_qe qe_eq_repeat + simpfm push_forall nnf Unpower + is_quantifier_free is_solved + add mult C V pow minus + Eq Or is_quantifier_free + +real_of_int real_mult real_div real_plus real_minus + +VSGeneral_3_times VSEquality_3_times VSHeuristic VSLuckiestRepeat VSBrowns +in SML module_name VS + + + + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/Exports.thy b/thys/Virtual_Substitution/Exports.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/Exports.thy @@ -0,0 +1,100 @@ +subsection "Top-Level Algorithms" +theory Exports + imports Heuristic VSAlgos Optimizations + (*"HOL-Library.Code_Real_Approx_By_Float"*) + HOL.String "HOL-Library.Code_Target_Int" "HOL-Library.Code_Target_Nat" PrettyPrinting Show.Show_Real +begin + + +definition "opt = (push_forall \ nnf \ unpower 0 o clearQuantifiers)" +definition "opt_group = (push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)" + +definition "VSLuckiest = opt o (QE_dnf opt (\amount. luckiestFind)) o opt" +definition "VSLuckiestBlocks =opt_group o (QE_dnf' opt_group (the_real_step_augment luckiestFind)) o opt_group" +definition "VSEquality =opt o (QE_dnf opt(\x. qe_eq_repeat)) o VSLuckiest o opt " +definition "VSEqualityBlocks =opt_group o (QE_dnf' opt_group (the_real_step_augment qe_eq_repeat)) o VSLuckiestBlocks o opt_group" +definition "VSGeneralBlocks =opt_group o (QE_dnf' opt_group (the_real_step_augment gen_qe))o VSLuckiestBlocks o opt_group" +definition "VSLuckyBlocks =opt_group o (QE_dnf' opt_group (the_real_step_augment luckyFind'))o VSLuckiestBlocks o opt_group" +definition "VSLEGBlocks = VSGeneralBlocks o VSEqualityBlocks o VSLuckyBlocks" +definition "VSEqualityBlocksLimited =opt_group o (QE_dnf opt_group (step_augment qe_eq_repeat IdentityHeuristic)) o VSLuckiestBlocks o opt_group" +definition "VSEquality_3_times = VSEquality o VSEquality o VSEquality" +definition "VSGeneral = opt o (QE_dnf opt (\x. gen_qe)) o VSLuckiest o opt" +definition "VSGeneralBlocksLimited = opt_group o (QE_dnf opt_group (step_augment gen_qe IdentityHeuristic)) o VSLuckiestBlocks o opt_group" +definition "VSBrowns = opt_group o (QE_dnf opt_group (step_augment gen_qe brownsHeuristic)) o VSLuckiestBlocks o opt_group" +definition "VSGeneral_3_times = VSGeneral o VSGeneral o VSGeneral" +definition "VSLucky = opt o (QE_dnf opt (\amount. luckyFind')) o VSLuckiest o opt" +definition "VSLuckyBlocksLimited = opt_group o (QE_dnf opt_group (step_augment luckyFind' IdentityHeuristic)) o VSLuckiestBlocks o opt_group" +definition "VSLEG = VSGeneral o VSEquality o VSLucky" +definition "VSHeuristic = opt_group o (QE_dnf opt_group (superPicker)) o VSLuckiestBlocks o opt_group" +definition "VSLuckiestRepeat = repeatAmountOfQuantifiers VSLuckiest" + + +definition add :: "real mpoly \ real mpoly \ real mpoly" where + "add p q = p + q" + +definition minus :: "real mpoly \ real mpoly \ real mpoly" where + "minus p q = p - q" + +definition mult :: "real mpoly \ real mpoly \ real mpoly" where + "mult p q = p * q" + +definition pow :: "real mpoly \ integer \ real mpoly" where + "pow p n = p ^ (nat_of_integer n)" + +definition C :: "real \ real mpoly" where + "C r = Const r" + +definition V :: "integer \ real mpoly" where + "V n = Var (nat_of_integer n)" + +definition real_of_int :: "integer \ real" + where "real_of_int n = real (nat_of_integer n)" + +definition real_mult :: "real \ real \ real" + where "real_mult n m = n * m" + +definition real_div :: "real \ real \ real" + where "real_div n m = n / m" + +definition real_plus :: "real \ real \ real" + where "real_plus n m = n + m" + +definition real_minus :: "real \ real \ real" + where "real_minus n m = n - m" + +fun is_quantifier_free :: "atom fm \ bool" where + "is_quantifier_free (ExQ x) =False"| + "is_quantifier_free (AllQ x) =False"| + "is_quantifier_free (And a b) =(is_quantifier_free a \ is_quantifier_free b)"| + "is_quantifier_free (Or a b) =(is_quantifier_free a \ is_quantifier_free b)"| + "is_quantifier_free (Neg a) =is_quantifier_free a"| + "is_quantifier_free a = True" + +fun is_solved :: "atom fm \ bool" where + "is_solved TrueF = True"| + "is_solved FalseF = True"| + "is_solved A = False" + +definition print_mpoly :: "(real \ String.literal)\ real mpoly \ String.literal" where + "print_mpoly f p = String.implode ((shows_mpoly True (\x.\y. (String.explode o f) x @ y)) p '''')" + +definition "Unpower = unpower 0" + +export_code + print_mpoly + VSGeneral VSEquality VSLucky VSLEG VSLuckiest + VSGeneralBlocksLimited VSEqualityBlocksLimited VSLuckyBlocksLimited + VSGeneralBlocks VSEqualityBlocks VSLuckyBlocks VSLEGBlocks VSLuckiestBlocks + QE_dnf + gen_qe qe_eq_repeat + simpfm push_forall nnf Unpower + is_quantifier_free is_solved + add mult C V pow minus + Eq Or is_quantifier_free + +real_of_int real_mult real_div real_plus real_minus + +VSGeneral_3_times VSEquality_3_times VSHeuristic VSLuckiestRepeat VSBrowns +in SML module_name VS + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/GeneralVSProofs.thy b/thys/Virtual_Substitution/GeneralVSProofs.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/GeneralVSProofs.thy @@ -0,0 +1,2390 @@ +theory GeneralVSProofs + imports DNFUni EqualityVS VSAlgos +begin + + +fun separateAtoms :: "atomUni list \ (real * real * real) list * (real * real * real) list * (real * real * real) list * (real * real * real) list" where + "separateAtoms [] = ([],[],[],[])"| + "separateAtoms (EqUni p # L) = (let (a,b,c,d) = separateAtoms(L) in (p#a,b,c,d))"| + "separateAtoms (LessUni p # L) = (let (a,b,c,d) = separateAtoms(L) in (a,p#b,c,d))"| + "separateAtoms (LeqUni p # L) = (let (a,b,c,d) = separateAtoms(L) in (a,b,p#c,d))"| + "separateAtoms (NeqUni p # L) = (let (a,b,c,d) = separateAtoms(L) in (a,b,c,p#d))" + + +lemma separate_aEval : + assumes "separateAtoms L = (a,b,c,d)" + shows "(\l\set L. aEvalUni l x) = + ((\(a,b,c)\set a. a*x^2+b*x+c=0) \ (\(a,b,c)\set b. a*x^2+b*x+c<0) \ + (\(a,b,c)\set c. a*x^2+b*x+c\0) \ (\(a,b,c)\set d. a*x^2+b*x+c\0))" + using assms proof(induction L arbitrary :a b c d) + case Nil + then show ?case by auto +next + case (Cons At L) + then have Cons1 : "\a b c d. separateAtoms L = (a, b, c, d) \ + (\l\set L. aEvalUni l x) = + ((\a\set a. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c = 0) \ + (\a\set b. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0)\ + (\a\set c. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0) \ + (\a\set d. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0))" " + separateAtoms (At # L) = (a, b,c,d)" by auto + then show ?case proof(cases At) + case (LessUni p) + show ?thesis proof(cases b) + case Nil + show ?thesis using Cons(2) unfolding LessUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' b') + then have p_def : "p' = p" using Cons1(2) unfolding LessUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a,b',c,d)" using Cons Cons1(2) unfolding LessUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # b'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0) = ( + (\a\set (b'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0)\ (case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0))" + by auto + have h3 : "(\l\set (LessUni p # L). aEvalUni l x) = ((\l\set (L). aEvalUni l x)\(case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0))" + by auto + show ?thesis unfolding Cons LessUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + next + case (EqUni p) + show ?thesis proof(cases a) + case Nil + show ?thesis using Cons(2) unfolding EqUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' a') + then have p_def : "p' = p" using Cons1(2) unfolding EqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a',b,c,d)" using Cons Cons1(2) unfolding EqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # a'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c = 0) = ( + (\a\set (a'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c = 0)\ (case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c = 0))" + by auto + have h3 : "(\l\set (EqUni p # L). aEvalUni l x) = ((\l\set (L). aEvalUni l x)\(case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c = 0))" + by auto + show ?thesis unfolding Cons EqUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + next + case (LeqUni p) + then show ?thesis proof(cases c) + case Nil + show ?thesis using Cons(2) unfolding LeqUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' a') + then have p_def : "p' = p" using Cons1(2) unfolding LeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a,b,a',d)" using Cons Cons1(2) unfolding LeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # a'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0) = ( + (\a\set (a'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0)\ (case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0))" + by auto + have h3 : "(\l\set (LeqUni p # L). aEvalUni l x) = ((\l\set (L). aEvalUni l x)\(case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0))" + by auto + show ?thesis unfolding Cons LeqUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + next + case (NeqUni p) + then show ?thesis proof(cases d) + case Nil + show ?thesis using Cons(2) unfolding NeqUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' a') + then have p_def : "p' = p" using Cons1(2) unfolding NeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a,b,c,a')" using Cons Cons1(2) unfolding NeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # a'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0) = ( + (\a\set (a'). case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0)\ (case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0))" + by auto + have h3 : "(\l\set (NeqUni p # L). aEvalUni l x) = ((\l\set (L). aEvalUni l x)\(case p of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0))" + by auto + show ?thesis unfolding Cons NeqUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + qed +qed + +lemma splitAtoms_negInfinity : + assumes "separateAtoms L = (a,b,c,d)" + shows "(\l\set L. evalUni (substNegInfinityUni l) x) = ( + (\(a,b,c)\set a.(\x. \y + (\(a,b,c)\set b.(\x. \y + (\(a,b,c)\set c.(\x. \y0))\ + (\(a,b,c)\set d.(\x. \y0)))" + using assms proof(induction L arbitrary :a b c d) + case Nil + then show ?case by auto +next + case (Cons At L) + then have Cons1 : "\a b c d. separateAtoms L = (a, b, c, d) \ + (\l\set L. evalUni (substNegInfinityUni l) x) = + ((\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" "separateAtoms (At # L) = (a, b, c, d)" by auto + then show ?case proof(cases At) + case (LessUni p) + show ?thesis using LessUni Cons proof(induction b rule : list.induct) + case Nil + then have Nil : "b = []" + using Cons.prems by auto + show ?case using Cons(2) unfolding LessUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' b') + then have p_def : "p' = p" using Cons1(2) unfolding LessUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a,b',c,d)" using Cons Cons1(2) unfolding LessUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # b'). case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0) = ( + (\a\set ( b'). case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ (case p of (a, ba, c) \ \x. \y2 + ba * y + c < 0))" + by auto + have one: "(\x. \y \x. \y2 + ba * y + c < 0)" + apply(cases p) by simp + have "(\l\set (LessUni p # L). evalUni (substNegInfinityUni l) x) = ((evalUni (substNegInfinityUni (LessUni p)) x)\(\l\set ( L). evalUni (substNegInfinityUni l) x))" + by auto + also have "... = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b'. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + unfolding infinity_evalUni[of "LessUni p" x, symmetric] Cons(3)[OF h1] LessUni one by simp + finally have h3 : "(\l\set (LessUni p # L). evalUni (substNegInfinityUni l) x) = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b'. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0) )" + by auto + show ?case unfolding Cons LessUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + next + case (EqUni p) + show ?thesis using EqUni Cons proof(induction a rule : list.induct) + case Nil + then have Nil : "a = []" + using Cons.prems by auto + show ?case using Cons(2) unfolding EqUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' a') + then have p_def : "p' = p" using Cons1(2) unfolding EqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a',b,c,d)" using Cons Cons1(2) unfolding EqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # a'). case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) = ( + (\a\set ( a'). case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0)\ (case p of (a, ba, c) \ \x. \y2 + ba * y + c = 0))" + by auto + have one: "(\x. \y \x. \y2 + ba * y + c = 0)" + apply(cases p) by simp + have "(\l\set (EqUni p # L). evalUni (substNegInfinityUni l) x) = ((evalUni (substNegInfinityUni (EqUni p)) x)\(\l\set ( L). evalUni (substNegInfinityUni l) x))" + by auto + also have "... = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c = 0)\ + (\a\set a'. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + unfolding infinity_evalUni[of "EqUni p" x, symmetric] Cons(3)[OF h1] EqUni one by simp + finally have h3 : "(\l\set (EqUni p # L). evalUni (substNegInfinityUni l) x) = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c = 0)\ + (\a\set a'. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + by auto + show ?case unfolding Cons EqUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + next + case (LeqUni p) + show ?thesis using LeqUni Cons proof(induction c rule : list.induct) + case Nil + then have Nil : "c = []" + using Cons.prems by auto + show ?case using Cons(2) unfolding LeqUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' c') + then have p_def : "p' = p" using Cons1(2) unfolding LeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a,b,c',d)" using Cons Cons1(2) unfolding LeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # c'). case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0) = ( + (\a\set ( c'). case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ (case p of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + by auto + have one: "(\x. \y \x. \y2 + ba * y + c \ 0)" + apply(cases p) by simp + have "(\l\set (LeqUni p # L). evalUni (substNegInfinityUni l) x) = ((evalUni (substNegInfinityUni (LeqUni p)) x)\(\l\set ( L). evalUni (substNegInfinityUni l) x))" + by auto + also have "... = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c'. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + unfolding infinity_evalUni[of "LeqUni p" x, symmetric] Cons(3)[OF h1] LeqUni one + by simp + finally have h3 : "(\l\set (LeqUni p # L). evalUni (substNegInfinityUni l) x) = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c'. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0) )" + by auto + show ?case unfolding Cons LeqUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + next + case (NeqUni p) + show ?thesis using NeqUni Cons proof(induction d rule : list.induct) + case Nil + then have Nil : "d = []" + using Cons.prems by auto + show ?case using Cons(2) unfolding NeqUni separateAtoms.simps Nil + apply(cases "separateAtoms L") by simp + next + case (Cons p' d') + then have p_def : "p' = p" using Cons1(2) unfolding NeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h1 : "separateAtoms L = (a,b,c,d')" using Cons Cons1(2) unfolding NeqUni separateAtoms.simps + apply(cases "separateAtoms L") by simp + have h2 : "(\a\set (p # d'). case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0) = ( + (\a\set ( d'). case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ (case p of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + by auto + have one: "(\x. \y \x. \y2 + ba * y + c \ 0)" + apply(cases p) by simp + have "(\l\set (NeqUni p # L). evalUni (substNegInfinityUni l) x) = ((evalUni (substNegInfinityUni (NeqUni p)) x)\(\l\set ( L). evalUni (substNegInfinityUni l) x))" + by auto + also have "... = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d'. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0))" + unfolding infinity_evalUni[of "NeqUni p" x, symmetric] Cons(3)[OF h1] NeqUni one + by simp + finally have h3 : "(\l\set (NeqUni p # L). evalUni (substNegInfinityUni l) x) = ( + (case p of (a,ba,c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set a. case a of (a, ba, c) \ \x. \y2 + ba * y + c = 0) \ + (\a\set b. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0)\ + (\a\set c. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0)\ + (\a\set d'. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0) )" + by auto + show ?case unfolding Cons NeqUni p_def h2 h3 using Cons1(1)[OF h1] + by auto + qed + qed +qed + +lemma set_split : + assumes "separateAtoms L = (eq,les,leq,neq)" + shows "set L = set (map EqUni eq @ map LessUni les @ map LeqUni leq @ map NeqUni neq)" + using assms proof(induction L arbitrary :eq les leq neq) + case Nil + then show ?case by auto +next + case (Cons At L) + then show ?case proof(cases At) + case (LessUni p) + have "\les'. p#les' = les \ separateAtoms L = (eq, les', leq, neq)" using Cons(2) unfolding LessUni apply (cases "separateAtoms L") by auto + then obtain les' where les' : "p#les' = les" "separateAtoms L = (eq, les', leq, neq)" by auto + show ?thesis unfolding LessUni les'(1)[symmetric] using Cons(1)[OF les'(2)] by auto + next + case (EqUni p) + have "\eq'. p#eq' = eq \ separateAtoms L = (eq', les, leq, neq)" using Cons(2) unfolding EqUni apply (cases "separateAtoms L") by auto + then obtain eq' where eq' : "p#eq' = eq" "separateAtoms L = (eq', les, leq, neq)" by auto + show ?thesis unfolding EqUni eq'(1)[symmetric] using Cons(1)[OF eq'(2)] by auto + next + case (LeqUni p) + have "\leq'. p#leq' = leq \ separateAtoms L = (eq, les, leq', neq)" using Cons(2) unfolding LeqUni apply (cases "separateAtoms L") + by auto + then obtain leq' where leq' : "p#leq' = leq" "separateAtoms L = (eq, les, leq', neq)" by auto + show ?thesis unfolding LeqUni leq'(1)[symmetric] using Cons(1)[OF leq'(2)] by auto + next + case (NeqUni p) + have "\neq'. p#neq' = neq \ separateAtoms L = (eq, les, leq, neq')" using Cons(2) unfolding NeqUni apply (cases "separateAtoms L") + by auto + then obtain neq' where neq' : "p#neq' = neq" "separateAtoms L = (eq, les, leq, neq')" by auto + show ?thesis unfolding NeqUni neq'(1)[symmetric] using Cons(1)[OF neq'(2)] by auto + qed +qed + +lemma set_split' : assumes "separateAtoms L = (eq,les,leq,neq)" + shows "set (map P L) = set (map (P o EqUni) eq @ map (P o LessUni) les @ map (P o LeqUni) leq @ map (P o NeqUni) neq)" + unfolding image_set[symmetric] set_split[OF assms] + unfolding image_set map_append map_map by auto + +lemma split_elimVar : + assumes "separateAtoms L = (eq,les,leq,neq)" + shows "(\l\set L. evalUni (elimVarUni_atom L' l) x) = + ((\(a',b',c')\set eq. (evalUni (elimVarUni_atom L' (EqUni(a',b',c'))) x)) + \ (\(a',b',c')\set les. + (evalUni (elimVarUni_atom L' (LessUni(a',b',c'))) x)) +\ (\(a',b',c')\set leq. + (evalUni (elimVarUni_atom L' (LeqUni(a',b',c'))) x)) +\ (\(a',b',c')\set neq. + (evalUni (elimVarUni_atom L' (NeqUni(a',b',c'))) x)))" +proof- + have c1: "(\l\set eq. evalUni (elimVarUni_atom L' (EqUni l)) x) = (\(a', b', c')\set eq. evalUni (elimVarUni_atom L' (EqUni (a', b', c'))) x)" + by (metis (no_types, lifting) case_prodE case_prodI2) + have c2: "(\l\set les. evalUni (elimVarUni_atom L' (LessUni l)) x) = (\(a', b', c')\set les. evalUni (elimVarUni_atom L' (LessUni (a', b', c'))) x)" + by (metis (no_types, lifting) case_prodE case_prodI2) + have c3: "(\l\set leq. evalUni (elimVarUni_atom L' (LeqUni l)) x) = (\(a', b', c')\set leq. evalUni (elimVarUni_atom L' (LeqUni (a', b', c'))) x)" + by (metis (no_types, lifting) case_prodE case_prodI2) + have c4: "(\l\set neq. evalUni (elimVarUni_atom L' (NeqUni l)) x) = (\(a', b', c')\set neq. evalUni (elimVarUni_atom L' (NeqUni (a', b', c'))) x)" + by (metis (no_types, lifting) case_prodE case_prodI2) + have h : "((\l\EqUni ` set eq. evalUni (elimVarUni_atom L' l) x) \ + (\l\LessUni ` set les. evalUni (elimVarUni_atom L' l) x) \ + (\l\LeqUni ` set leq. evalUni (elimVarUni_atom L' l) x) \ + (\l\NeqUni ` set neq. evalUni (elimVarUni_atom L' l) x) + ) = + ((\l\set eq. evalUni (elimVarUni_atom L' (EqUni l)) x) \ + (\l\set les. evalUni (elimVarUni_atom L' (LessUni l)) x) \ + (\l\set leq. evalUni (elimVarUni_atom L' (LeqUni l)) x) \ + (\l\set neq. evalUni (elimVarUni_atom L' (NeqUni l)) x) + )" + by auto + then have "... = ((\(a', b', c')\set eq. evalUni (elimVarUni_atom L' (EqUni (a', b', c'))) x) \ + (\(a', b', c')\set les. evalUni (elimVarUni_atom L' (LessUni (a', b', c'))) x) \ + (\(a', b', c')\set leq. evalUni (elimVarUni_atom L' (LeqUni (a', b', c'))) x) \ + (\(a', b', c')\set neq. evalUni (elimVarUni_atom L' (NeqUni (a', b', c'))) x))" + using c1 c2 c3 c4 by auto + then show ?thesis + unfolding set_split[OF assms] set_append bex_Un image_set[symmetric] + using case_prodE case_prodI2 by auto +qed + +lemma split_elimvar : + assumes "separateAtoms L = (eq,les,leq,neq)" + shows "evalUni (elimVarUni_atom L At) x = evalUni (elimVarUni_atom ((map EqUni eq)@(map LessUni les) @ map LeqUni leq @ map NeqUni neq) At) x" +proof(cases At) + case (LessUni p) + then show ?thesis apply(cases p) apply simp unfolding eval_list_conj_Uni set_split'[OF assms] by simp +next + case (EqUni p) + then show ?thesis apply(cases p) apply simp unfolding eval_list_conj_Uni set_split'[OF assms] by simp +next + case (LeqUni p) + then show ?thesis apply(cases p) apply simp unfolding eval_list_conj_Uni set_split'[OF assms] by simp +next + case (NeqUni p) + then show ?thesis apply(cases p) apply simp unfolding eval_list_conj_Uni set_split'[OF assms] by simp +qed + + + + +lemma less : " + ((a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. evalUni (substInfinitesimalLinearUni b' c' (EqUni (d, e, f))) x) \ + (\(d, e, f)\set b. evalUni (substInfinitesimalLinearUni b' c' (LessUni (d, e, f))) x) \ + (\(d, e, f)\set c. evalUni (substInfinitesimalLinearUni b' c' (LeqUni (d, e, f))) x) \ + (\(d, e, f)\set d. evalUni (substInfinitesimalLinearUni b' c' (NeqUni (d, e, f))) x) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + evalUni + (substInfinitesimalQuadraticUni (- b') 1 (b'\<^sup>2 - 4 * a' * c') (2 * a') + (EqUni (d, e, f))) + x) \ + (\(d, e, f)\set b. + evalUni + (substInfinitesimalQuadraticUni (- b') 1 (b'\<^sup>2 - 4 * a' * c') (2 * a') + (LessUni (d, e, f))) + x) \ + (\(d, e, f)\set c. + evalUni + (substInfinitesimalQuadraticUni (- b') 1 (b'\<^sup>2 - 4 * a' * c') (2 * a') + (LeqUni (d, e, f))) + x) \ + (\(d, e, f)\set d. + evalUni + (substInfinitesimalQuadraticUni (- b') 1 (b'\<^sup>2 - 4 * a' * c') (2 * a') + (NeqUni (d, e, f))) + x) \ + (\(d, e, f)\set a. + evalUni + (substInfinitesimalQuadraticUni (- b') (- 1) (b'\<^sup>2 - 4 * a' * c') (2 * a') + (EqUni (d, e, f))) + x) \ + (\(d, e, f)\set b. + evalUni + (substInfinitesimalQuadraticUni (- b') (- 1) (b'\<^sup>2 - 4 * a' * c') (2 * a') + (LessUni (d, e, f))) + x) \ + (\(d, e, f)\set c. + evalUni + (substInfinitesimalQuadraticUni (- b') (- 1) (b'\<^sup>2 - 4 * a' * c') (2 * a') + (LeqUni (d, e, f))) + x) \ + (\(d, e, f)\set d. + evalUni + (substInfinitesimalQuadraticUni (- b') (- 1) (b'\<^sup>2 - 4 * a' * c') (2 * a') + (NeqUni (d, e, f))) + x))) = + + ((a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + (\y'::real>-c'/b'. \x::real \{-c'/b'<..y'}. aEvalUni (EqUni (d, e, f)) x)) \ + (\(d, e, f)\set b. + (\y'::real>-c'/b'. \x::real \{-c'/b'<..y'}. aEvalUni (LessUni (d, e, f)) x))\ + (\(d, e, f)\set c. + (\y'::real>-c'/b'. \x::real \{-c'/b'<..y'}. aEvalUni (LeqUni (d, e, f)) x)) \ + (\(d, e, f)\set d. + (\y'::real>-c'/b'. \x::real \{-c'/b'<..y'}. aEvalUni (NeqUni (d, e, f)) x)) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + (\y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (EqUni (d,e,f)) x)) \ + (\(d, e, f)\set b. + (\y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (LessUni (d,e,f)) x)) \ + (\(d, e, f)\set c. + (\y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (LeqUni (d,e,f)) x)) \ + (\(d, e, f)\set d. + (\y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (NeqUni (d,e,f)) x)) \ + (\(d, e, f)\set a. + (\y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (EqUni (d,e,f)) x)) \ + (\(d, e, f)\set b. + (\y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (LessUni (d,e,f)) x)) \ + (\(d, e, f)\set c. + (\y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (LeqUni (d,e,f)) x)) \ + (\(d, e, f)\set d. + (\y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + aEvalUni (NeqUni (d,e,f)) x))))" +proof(cases "a'=0") + case True + then have a' : "a'=0" by auto + then show ?thesis proof(cases "b'=0") + case True + then show ?thesis using a' by auto + next + case False + then show ?thesis using True unfolding infinitesimal_linear'[of b' c' _ x, symmetric, OF False] by auto + qed +next + case False + then have a' : "a' \ 0" by auto + then have d : "2 * a' \ 0" by auto + show ?thesis proof(cases "0 \ b'\<^sup>2 - 4 * a' * c'") + case True + then show ?thesis using False + unfolding infinitesimal_quad[OF d True, of "-b'", symmetric] by auto + next + case False + then show ?thesis using a' by auto + qed +qed + +lemma eq_inf : "(\(a, b, c)\set (a::(real*real*real) list). \x. \y2 + b * y + c = 0) = (\(a, b, c)\set a. a=0\b=0\c=0)" + using infinity_evalUni_EqUni[of _ x] by auto + + + +text "This is the main quantifier elimination lemma, in the simplified framework. We are located directly underneath +the most internal existential quantifier so F is completely free in quantifier and consists only of conjunction and disjunction. +The variable we are evaluating on, x, is removed in the generalVS\\_DNF converted formula as expanding out the evalUni function +determines that x doesn't play a role in the computation of it. It would be okay to replace the x in the second half with any variable, +but it is simplier this way + +This conversion is defined as a \"veritcal\" translation as we remain within the univariate framework in both sides of the expression" + +lemma eval_generalVS'' : "(\x. evalUni (list_conj_Uni (map AtomUni L)) x) = + evalUni (generalVS_DNF L) x" +proof(cases "separateAtoms L") + case (fields a b c d) + have a : "\ P. (\l\set (map EqUni a) \ (set (map LessUni b) \ (set (map LeqUni c) \ set (map NeqUni d))).P l) = + ((\(d,e,f)\set a. P (EqUni (d,e,f))) \ (\(d,e,f)\set b. P (LessUni (d,e,f))) \ (\(d,e,f)\set c. P (LeqUni (d,e,f))) \ (\(d,e,f)\set d. P (NeqUni (d,e,f))))" + by auto + show ?thesis apply(simp add: eval_list_conj_Uni separate_aEval[OF fields] + splitAtoms_negInfinity[OF fields] eval_list_disj_Uni + del:elimVar.simps) + + unfolding eval_conj_atom generalVS_DNF.simps + split_elimVar[OF fields ] + +split_elimvar[OF fields] + + unfolding elimVarUni_atom.simps evalUni.simps aEvalUni.simps + Rings.mult_zero_class.mult_zero_left Groups.add_0 eval_list_conj_Uni Groups.group_add_class.minus_zero + eval_map_all linearSubstitutionUni.simps quadraticSubUni.simps evalUni_if aEvalUni.simps + set_append a less eq_inf + using qe by auto +qed + + +lemma forallx_substNegInf : "(\evalUni (map_atomUni substNegInfinityUni F) x) = (\x. \ evalUni (map_atomUni substNegInfinityUni F) x)" +proof(induction F) + case TrueFUni + then show ?case by simp +next + case FalseFUni + then show ?case by simp +next + case (AtomUni At) + then show ?case apply(cases At) by auto +next + case (AndUni F1 F2) + then show ?case by auto +next + case (OrUni F1 F2) + then show ?case by auto +qed + +lemma linear_subst_map: "evalUni (map_atomUni (linearSubstitutionUni b c) F) x = evalUni F (-c/b)" + apply(induction F)by auto + +lemma quadratic_subst_map : "evalUni (map_atomUni (quadraticSubUni a b c d) F) x = evalUni F ((a+b*sqrt(c))/d)" + apply(induction F)by auto + + + + +fun convert_atom_list :: "nat \ atom list \ real list \ (atomUni list) option" where + "convert_atom_list var [] xs = Some []"| + "convert_atom_list var (a#as) xs = ( + case convert_atom var a xs of Some(a) \ + (case convert_atom_list var as xs of Some(as) \ Some(a#as) | None \ None) + | None \ None +)" + + + + + +lemma convert_atom_list_change : + assumes "length xs' = var" + shows "convert_atom_list var L (xs' @ x # \) = convert_atom_list var L (xs' @ x' # \)" + apply(induction L)using convert_atom_change[OF assms] apply simp_all + by (metis) + +lemma negInf_convert : + assumes "convert_atom_list var L (xs' @ x # xs) = Some L'" + assumes "length xs' = var" + shows "(\f\set L. eval (substNegInfinity var f) (xs' @ x # xs)) + = (\f\set L'. evalUni (substNegInfinityUni f) x)" + using assms +proof(induction L arbitrary : L') + case Nil + then show ?case by auto +next + case (Cons a L) + then show ?case proof(cases a) + case (Less p) + have h: "MPoly_Type.degree p var < 3 \ + eval (substNegInfinity var (Less p)) (xs' @ x # xs) = evalUni + (substNegInfinityUni + (LessUni + (insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0)), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)))) + x" + using convert_substNegInfinity[of var "Less p" xs' x xs, OF _ assms(2)] by simp + show ?thesis using Cons(2)[symmetric] Cons(1) unfolding Less apply(cases " MPoly_Type.degree p var < 3") + defer apply simp apply(cases "convert_atom_list var L (xs' @ x # xs)") apply (simp_all del: substNegInfinity.simps substNegInfinityUni.simps) + unfolding h + using assms(2) by presburger + next + case (Eq p) + have h: "MPoly_Type.degree p var < 3 \ + eval (substNegInfinity var (Eq p)) (xs' @ x # xs) = evalUni + (substNegInfinityUni + (EqUni + (insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0)), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)))) + x" + using convert_substNegInfinity[of var "Eq p", OF _ assms(2)] by simp + show ?thesis using Cons(2)[symmetric] Cons(1) unfolding Eq apply(cases " MPoly_Type.degree p var < 3") + defer apply simp apply(cases "convert_atom_list var L (xs' @ x # xs)") apply (simp_all del: substNegInfinity.simps substNegInfinityUni.simps) + unfolding h assms by auto + next + case (Leq p) + have h: "MPoly_Type.degree p var < 3 \ + eval (substNegInfinity var (Leq p)) (xs' @ x # xs) = evalUni + (substNegInfinityUni + (LeqUni + (insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0)), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)))) + x" + using convert_substNegInfinity[of var "Leq p", OF _ assms(2)] by simp + show ?thesis using Cons(2) unfolding Leq apply(cases " MPoly_Type.degree p var < 3") + defer apply simp + apply(cases "convert_atom_list var L (xs' @ x # xs)") + apply (simp_all del: substNegInfinity.simps substNegInfinityUni.simps) + unfolding h using Cons.IH assms by auto + next + case (Neq p) + have h: "MPoly_Type.degree p var < 3 \ + eval (substNegInfinity var (Neq p)) (xs' @ x # xs) = evalUni + (substNegInfinityUni + (NeqUni + (insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0)), + insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)))) + x" + using convert_substNegInfinity[of var "Neq p", OF _ assms(2)] by simp + show ?thesis using Cons(2) unfolding Neq apply(cases " MPoly_Type.degree p var < 3") defer apply simp + apply(cases "convert_atom_list var L (xs' @ x # xs)") + apply (simp_all del: substNegInfinity.simps substNegInfinityUni.simps) + unfolding h using Cons.IH assms by auto + qed +qed + +lemma elimVar_atom_single : + assumes "convert_atom var A (xs' @ x # xs) = Some A'" + assumes "convert_atom_list var L2 (xs' @ x # xs) = Some L2'" + assumes "length xs' = var" + shows "eval (elimVar var L2 [] A) (xs' @ x # xs) = evalUni (elimVarUni_atom L2' A') x" +proof(cases A) + case (Less p) + define a where "a = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2)" + have a_def' : "a = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var 2)" unfolding a_def + using insertion_isovarspars_free[of "(xs' @ x # xs)" var x p 2 0] assms by auto + define b where "b = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0))" + have b_def' : "b = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var (Suc 0))" unfolding b_def + using insertion_isovarspars_free[of "(xs' @ x # xs)" var x p "(Suc 0)" 0] assms by auto + define c where "c = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)" + have c_def' : "c = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var 0)" unfolding c_def + using insertion_isovarspars_free[of "(xs' @ x # xs)" var x p 0 0] assms by auto + have linear : "b\0 \ (\f\set L2. + eval + (substInfinitesimalLinear var (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)) = (\l\set L2'. evalUni (substInfinitesimalLinearUni b c l) x)" + using assms(2) proof(induction L2 arbitrary : L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(3) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(3) At' + by (simp_all add: L2's) + have h : "eval + (substInfinitesimalLinear var (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) + At) + (xs' @ x # xs) = evalUni (substInfinitesimalLinearUni b c At') x" + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by simp_all + next + case (Some a) + have h1 : "var \ vars (isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar) + have h2 : "var \ vars (isolate_variable_sparse p var 0)"by (simp add: not_in_isovarspar) + have h : "evalUni (substInfinitesimalLinearUni b c a) x = + evalUni (substInfinitesimalLinearUni b c At') x" + proof(cases At) + case (Less p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq x3) + then show ?thesis using At' Some by auto + next + case (Neq x4) + then show ?thesis using At' Some by auto + qed + show ?thesis unfolding convert_substInfinitesimalLinear[OF Some b_def[symmetric] c_def[symmetric] Cons(2) h1 h2 assms(3)] + using h . + qed + show ?case unfolding L2' using h Cons(1)[OF Cons(2) L2's] by auto + qed + have quadratic_1 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \ (\f\set L2. + eval + (substInfinitesimalQuadratic var + (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni + (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) l) + x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) 1 = 1" by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @ xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_lowerPoly1 list_update_length not_in_isovarspar) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(1::real mpoly)" + by (metis h9 not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (substInfinitesimalQuadratic var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = evalUni + (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof (cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by auto + next + case (Some aT) + have h1 : "insertion (nth_default 0 (xs' @ x # xs)) (- isolate_variable_sparse p var (Suc 0)) = (-b)" unfolding b_def insertion_neg by auto + have h2 : "insertion (nth_default 0 (xs' @ x # xs)) 1 = 1" by auto + have h3 : "insertion (nth_default 0 (xs' @ x # xs)) (((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)) = (b\<^sup>2 - 4 * a * c)" + unfolding insertion_mult insertion_pow insertion_four insertion_neg insertion_sub a_def b_def c_def + by auto + have h4 : "insertion (nth_default 0 (xs' @ x # xs)) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def + by (metis insertion_add insertion_mult mult_2) + have h5 : "2 * a \ 0" using Cons by auto + have h6 : "0 \ b\<^sup>2 - 4 * a * c" using Cons by auto + have h7 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h8 : "var\vars(1::real mpoly)" + by (metis h9 not_in_pow power.simps(1)) + have h9 : "var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * + isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h10 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "evalUni (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) aT) + x = + evalUni (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) At') + x"proof(cases At) + case (Less p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Eq p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Leq x3) + then show ?thesis using At' using Some by auto + next + case (Neq x4) + then show ?thesis using At' using Some by auto + qed + show ?thesis unfolding convert_substInfinitesimalQuadratic[OF Some h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 assms(3)] + using h . + qed + + + show ?case + unfolding L2' apply(simp del : substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h + by auto + qed + have quadratic_2 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \ (\f\set L2. + eval + (substInfinitesimalQuadratic var + (- isolate_variable_sparse p var (Suc 0)) (- 1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni + (substInfinitesimalQuadraticUni (- b) (- 1) (b\<^sup>2 - 4 * a * c) (2 * a) + l) + x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (-1) = (-1)" unfolding insertion_neg by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) using assms + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @ xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto using assms + by (metis (no_types, hide_lams) MPoly_Type.insertion_one add.inverse_inverse add_uminus_conv_diff arith_special(3) insertion_isovarspars_free insertion_neg insertion_sub list_update_id) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(- 1::real mpoly)" + by (metis h9 not_in_neg not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (substInfinitesimalQuadratic var (- isolate_variable_sparse p var (Suc 0)) (-1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = evalUni + (substInfinitesimalQuadraticUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof (cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by auto + next + case (Some aT) + have h1 : "insertion (nth_default 0 (xs' @ x # xs)) (- isolate_variable_sparse p var (Suc 0)) = (-b)" unfolding b_def insertion_neg by auto + have h2 : "insertion (nth_default 0 (xs' @ x # xs)) (-1) = -1" unfolding insertion_neg by auto + have h3 : "insertion (nth_default 0 (xs' @ x # xs)) (((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)) = (b\<^sup>2 - 4 * a * c)" + unfolding insertion_mult insertion_pow insertion_four insertion_neg insertion_sub a_def b_def c_def using assms + by auto + have h4 : "insertion (nth_default 0 (xs' @ x # xs)) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def + by (metis insertion_add insertion_mult mult_2) + have h5 : "2 * a \ 0" using Cons by auto + have h6 : "0 \ b\<^sup>2 - 4 * a * c" using Cons by auto + have h7 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h8 : "var\vars(- 1::real mpoly)" + by (simp add: h10 not_in_neg) + have h9 : "var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * + isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h10 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "evalUni (substInfinitesimalQuadraticUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) aT) + x = + evalUni (substInfinitesimalQuadraticUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) At') + x"proof(cases At) + case (Less p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Eq p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Leq x3) + then show ?thesis using At' + using Some option.inject by auto + next + case (Neq x4) + then show ?thesis using At' + using Some by auto + qed + show ?thesis unfolding convert_substInfinitesimalQuadratic[OF Some h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 assms(3)] + using h . + qed + + + show ?case + unfolding L2' apply(simp del : substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h + by auto + qed + + show ?thesis using assms(1)[symmetric] unfolding Less apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(simp del : substInfinitesimalLinear.simps substInfinitesimalLinearUni.simps substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps + add: insertion_neg insertion_mult insertion_add insertion_pow insertion_sub insertion_four + a_def[symmetric] b_def[symmetric] c_def[symmetric] a_def'[symmetric] b_def'[symmetric] c_def'[symmetric] eval_list_conj + eval_list_conj_Uni + ) using linear quadratic_1 quadratic_2 by smt +next + case (Eq p) + define a where "a = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2)" + have a_def' : "a = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var 2)" unfolding a_def + using insertion_isovarspars_free[of "xs' @x#xs" var x p 2 0] using assms by auto + define b where "b = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0))" + have b_def' : "b = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var (Suc 0))" unfolding b_def + using insertion_isovarspars_free[of "xs' @x#xs" var x p "(Suc 0)" 0] using assms by auto + define c where "c = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)" + have c_def' : "c = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var 0)" unfolding c_def + using insertion_isovarspars_free[of "xs' @x#xs" var x p 0 0]using assms by auto + have linear : "a=0 \ b\0 \ (\f\set L2. + aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)) = (\l\set L2'. evalUni (linearSubstitutionUni b c l) x)" + + using assms(2) + proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var \ vars (isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar) + have h2 : "var \ vars (isolate_variable_sparse p var 0)"by (simp add: not_in_isovarspar) + have h : "aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) At) + (xs' @ x # xs) = evalUni (linearSubstitutionUni b c At') x" + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by auto + next + case (Some a) + have h : "a=At'" + using At' Some by auto + show ?thesis unfolding convert_linearSubstitutionUni[OF Some b_def[symmetric] c_def[symmetric] Cons(3) h1 h2 assms(3)] + unfolding h by auto + qed + have "(\f\set (At # L2). + aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)) = (aEval + (linear_substitution var + (-isolate_variable_sparse p var 0)(isolate_variable_sparse p var (Suc 0)) At) + (xs' @ x # xs)\ (\f\set (L2). + aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)))" by auto + also have "... = (evalUni (linearSubstitutionUni b c At') x \ + (\l\set L2's. evalUni (linearSubstitutionUni b c l) x))" + unfolding h Cons(1)[OF Cons(2) Cons(3) L2's] by auto + finally show ?case unfolding L2' by auto + qed + + have quadratic_1 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \(\f\set L2. + eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni (quadraticSubUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) l) x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) 1 = 1" by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @ xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_add insertion_isovarspars_free insertion_mult list_update_length mult_2) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(1::real mpoly)" + by (metis h9 not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = aEval At (xs' @ (((- b + 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)) # xs))" + using quadratic_sub[OF h1 h2 h3 h4 h5 h6 h7 h8, symmetric, of At] + free_in_quad[OF h9 h10 h4 h11] + by (metis assms(3) list_update_length var_not_in_eval3) + have h2 : "aEval At (xs' @ (- b + 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) # xs) = evalUni (quadraticSubUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof(cases At) + case (Less p) + then show ?thesis + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Less apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Eq p) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Eq apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Leq x3) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Leq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + next + case (Neq x4) + then show ?thesis + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Neq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + qed + show ?case + unfolding L2' apply(simp del : quadratic_sub.simps quadraticSubUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h h2 + by auto + qed + have quadratic_2 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \ (\f\set L2. + eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) (- 1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni (quadraticSubUni (- b) (- 1) (b\<^sup>2 - 4 * a * c) (2 * a) l) x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" using assms by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (-1) = -1" + unfolding insertion_neg + by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_lowerPoly1 list_update_length not_in_isovarspar) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(-1::real mpoly)" + by (metis h9 not_in_neg not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) (-1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = aEval At (xs' @ (((- b - 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)) # xs))" + using quadratic_sub[OF h1 h2 h3 h4 h5 h6 h7 h8, symmetric, of At] + var_not_in_eval3 free_in_quad[OF h9 h10 h4 h11] + using assms(3) by fastforce + have h2 : "aEval At (xs' @ (- b - 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) # xs) = evalUni (quadraticSubUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof(cases At) + case (Less p) + then show ?thesis + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Less apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Eq p) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Eq apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Leq x3) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Leq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + next + case (Neq x4) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Neq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + qed + show ?case + unfolding L2' apply(simp del : quadratic_sub.simps quadraticSubUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h h2 + by auto + qed + show ?thesis using assms(1)[symmetric] unfolding Eq apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(simp del : linearSubstitutionUni.simps quadraticSubUni.simps + add: insertion_neg insertion_mult insertion_add insertion_pow insertion_sub insertion_four + a_def[symmetric] b_def[symmetric] c_def[symmetric] a_def'[symmetric] b_def'[symmetric] c_def'[symmetric] eval_list_conj + eval_list_conj_Uni )using linear + using quadratic_1 quadratic_2 + by smt +next + case (Leq p) + define a where "a = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2)" + have a_def' : "a = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var 2)" unfolding a_def + using insertion_isovarspars_free[of "xs'@ x#xs" var x p 2 0] using assms by auto + define b where "b = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0))" + have b_def' : "b = insertion (nth_default 0 (xs'@ 0 # xs)) (isolate_variable_sparse p var (Suc 0))" unfolding b_def + using insertion_isovarspars_free[of "xs'@x#xs" var x p "(Suc 0)" 0] using assms by auto + define c where "c = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)" + have c_def' : "c = insertion (nth_default 0 (xs'@ 0 # xs)) (isolate_variable_sparse p var 0)" unfolding c_def + using insertion_isovarspars_free[of "xs'@ x#xs" var x p 0 0] using assms by auto + have linear : "a=0 \ b\0 \ (\f\set L2. + aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)) = (\l\set L2'. evalUni (linearSubstitutionUni b c l) x)" + using assms(2) + proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var \ vars (isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar) + have h2 : "var \ vars (isolate_variable_sparse p var 0)"by (simp add: not_in_isovarspar) + have h : "aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) At) + (xs' @ x # xs) = evalUni (linearSubstitutionUni b c At') x" + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by auto + next + case (Some a) + have h : "a=At'" + using At' Some by auto + show ?thesis unfolding convert_linearSubstitutionUni[OF Some b_def[symmetric] c_def[symmetric] Cons(3) h1 h2 assms(3)] + unfolding h by auto + qed + have "(\f\set (At # L2). + aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)) = (aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) At) + (xs' @ x # xs)\ (\f\set (L2). + aEval + (linear_substitution var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)))" by auto + also have "... = (evalUni (linearSubstitutionUni b c At') x \ + (\l\set L2's. evalUni (linearSubstitutionUni b c l) x))" + unfolding h Cons(1)[OF Cons(2) Cons(3) L2's] by auto + finally show ?case unfolding L2' by auto + qed + + have quadratic_1 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \(\f\set L2. + eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni (quadraticSubUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) l) x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) 1 = 1" by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_lowerPoly1 list_update_length not_in_isovarspar) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(1::real mpoly)" + by (metis h9 not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = aEval At (xs' @ (((- b + 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)) # xs))" + using quadratic_sub[OF h1 h2 h3 h4 h5 h6 h7 h8, symmetric, of At] + var_not_in_eval3 free_in_quad[OF h9 h10 h4 h11] + by (metis assms(3) list_update_length) + have h2 : "aEval At (xs' @ (- b + 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) # xs) = evalUni (quadraticSubUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof(cases At) + case (Less p) + then show ?thesis + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Less apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Eq p) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Eq apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Leq x3) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Leq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + next + case (Neq x4) + then show ?thesis + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Neq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + qed + show ?case + unfolding L2' apply(simp del : quadratic_sub.simps quadraticSubUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h h2 + by auto + qed + have quadratic_2 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \ (\f\set L2. + eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) (- 1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni (quadraticSubUni (- b) (- 1) (b\<^sup>2 - 4 * a * c) (2 * a) l) x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (-1) = -1" + unfolding insertion_neg + by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @ xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_lowerPoly1 list_update_length not_in_isovarspar) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(-1::real mpoly)" + by (metis h9 not_in_neg not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (quadratic_sub var (- isolate_variable_sparse p var (Suc 0)) (-1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = aEval At (xs' @(((- b - 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)) # xs))" + using quadratic_sub[OF h1 h2 h3 h4 h5 h6 h7 h8, symmetric, of At] + var_not_in_eval3 free_in_quad[OF h9 h10 h4 h11] + using assms(3) by fastforce + have h2 : "aEval At (xs' @(- b - 1 * sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) # xs) = evalUni (quadraticSubUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof(cases At) + case (Less p) + then show ?thesis + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Less apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Eq p) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Eq apply(cases "MPoly_Type.degree p var < 3") by simp_all + qed + next + case (Leq x3) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Leq apply(cases "MPoly_Type.degree p var < 3") + by (auto) + qed + next + case (Neq x4) + then show ?thesis proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis + using At'[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Some aT) + then have Some : "\x. convert_atom var At (xs' @ x # xs) = Some aT" + by (metis assms(3) convert_atom_change) + show ?thesis unfolding aEval_aEvalUni[OF Some assms(3)] + using At'[symmetric] Some[symmetric] + unfolding Neq apply(cases "MPoly_Type.degree p var < 3") by auto + qed + qed + show ?case + unfolding L2' apply(simp del : quadratic_sub.simps quadraticSubUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h h2 + by auto + qed + show ?thesis using assms(1)[symmetric] unfolding Leq apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(simp del : linearSubstitutionUni.simps quadraticSubUni.simps + add: insertion_neg insertion_mult insertion_add insertion_pow insertion_sub insertion_four + a_def[symmetric] b_def[symmetric] c_def[symmetric] a_def'[symmetric] b_def'[symmetric] c_def'[symmetric] eval_list_conj + eval_list_conj_Uni ) using linear + using quadratic_1 quadratic_2 + by smt +next + case (Neq p) + define a where "a = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2)" + have a_def' : "a = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var 2)" unfolding a_def + using insertion_isovarspars_free[of "xs' @x#xs" var x p 2 0] using assms by auto + define b where "b = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0))" + have b_def' : "b = insertion (nth_default 0 (xs' @ 0 # xs)) (isolate_variable_sparse p var (Suc 0))" unfolding b_def + using insertion_isovarspars_free[of "xs'@x#xs" var x p "(Suc 0)" 0] using assms by auto + define c where "c = insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0)" + have c_def' : "c = insertion (nth_default 0 (xs'@0 # xs)) (isolate_variable_sparse p var 0)" unfolding c_def + using insertion_isovarspars_free[of "xs'@x#xs" var x p 0 0] using assms by auto + have linear : "b\0 \ (\f\set L2. + eval + (substInfinitesimalLinear var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) f) + (xs' @ x # xs)) = (\l\set L2'. evalUni (substInfinitesimalLinearUni b c l) x)" + using assms(2) proof(induction L2 arbitrary : L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(3) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(3) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(3) At' + by (simp_all add: L2's) + have h : "eval + (substInfinitesimalLinear var + (-isolate_variable_sparse p var 0) (isolate_variable_sparse p var (Suc 0)) At) + (xs' @ x # xs) = evalUni (substInfinitesimalLinearUni b c At') x" + proof(cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by simp_all + next + case (Some a) + have h1 : "var \ vars (isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar) + have h2 : "var \ vars (isolate_variable_sparse p var 0)"by (simp add: not_in_isovarspar) + have h : "evalUni (substInfinitesimalLinearUni b c a) x = + evalUni (substInfinitesimalLinearUni b c At') x" + proof(cases At) + case (Less p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq x3) + then show ?thesis using At' Some by auto + next + case (Neq x4) + then show ?thesis using At' Some by auto + qed + show ?thesis unfolding convert_substInfinitesimalLinear[OF Some b_def[symmetric] c_def[symmetric] Cons(2) h1 h2 assms(3)] + using h . + qed + show ?case unfolding L2' using h Cons(1)[OF Cons(2) L2's] by auto + qed + have quadratic_1 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \ (\f\set L2. + eval + (substInfinitesimalQuadratic var + (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni + (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) l) + x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length (xs' @ x # xs)" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) 1 = 1" by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_lowerPoly1 list_update_length not_in_isovarspar) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(1::real mpoly)" + by (metis h9 not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (substInfinitesimalQuadratic var (- isolate_variable_sparse p var (Suc 0)) 1 + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = evalUni + (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof (cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by auto + next + case (Some aT) + have h1 : "insertion (nth_default 0 (xs' @ x # xs)) (- isolate_variable_sparse p var (Suc 0)) = (-b)" unfolding b_def insertion_neg by auto + have h2 : "insertion (nth_default 0 (xs' @ x # xs)) 1 = 1" by auto + have h3 : "insertion (nth_default 0 (xs' @ x # xs)) (((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)) = (b\<^sup>2 - 4 * a * c)" + unfolding insertion_mult insertion_pow insertion_four insertion_neg insertion_sub a_def b_def c_def + by auto + have h4 : "insertion (nth_default 0 (xs' @ x # xs)) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def + by (metis insertion_add insertion_mult mult_2) + have h5 : "2 * a \ 0" using Cons by auto + have h6 : "0 \ b\<^sup>2 - 4 * a * c" using Cons by auto + have h7 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h8 : "var\vars(1::real mpoly)" + by (metis h9 not_in_pow power.simps(1)) + have h9 : "var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * + isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h10 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "evalUni (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) aT) + x = + evalUni (substInfinitesimalQuadraticUni (- b) 1 (b\<^sup>2 - 4 * a * c) (2 * a) At') + x"proof(cases At) + case (Less p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Eq p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Leq x3) + then show ?thesis using At' using Some by auto + next + case (Neq x4) + then show ?thesis using At' using Some by auto + qed + show ?thesis unfolding convert_substInfinitesimalQuadratic[OF Some h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 assms(3)] + using h . + qed + + + show ?case + unfolding L2' apply(simp del : substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h + by auto + qed + have quadratic_2 : "(a \ 0) \ + (4 * a * c \ b\<^sup>2) \ (\f\set L2. + eval + (substInfinitesimalQuadratic var + (- isolate_variable_sparse p var (Suc 0)) (- 1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) f) + (xs' @ x # xs)) = (\l\set L2'. + evalUni + (substInfinitesimalQuadraticUni (- b) (- 1) (b\<^sup>2 - 4 * a * c) (2 * a) + l) + x)" + using assms(2) proof(induction L2 arbitrary: L2') + case Nil + then show ?case by auto + next + case (Cons At L2) + have "\At'. convert_atom var At (xs' @ x # xs) = Some At'" proof(cases At) + case (Less p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Eq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by simp_all + next + case (Leq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Neq p) + then show ?thesis using Cons(4) apply simp apply(cases "MPoly_Type.degree p var < 3") by auto + qed + then obtain At' where At' : "convert_atom var At (xs' @ x # xs) = Some At'" by auto + have "\L2's. convert_atom_list var L2 (xs' @ x # xs) = Some L2's" + using Cons(4) At' + apply(cases "convert_atom_list var L2 (xs' @ x # xs)") by auto + then obtain L2's where L2's : "convert_atom_list var L2 (xs' @ x # xs) = Some L2's" by auto + have L2' : "L2' = At' # L2's" + using Cons(4) At' apply(cases At) apply auto + by (simp_all add: L2's) + have h1 : "var < length ((xs' @ x # xs))" using assms by auto + have h2 : "2*a \0" using Cons by auto + have h3 : "0\b^2-4*a*c" using Cons(3) by auto + have h4 : "var\vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h5 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (- isolate_variable_sparse p var (Suc 0)) = -b" + unfolding insertion_neg b_def + by (metis insertion_isovarspars_free list_update_id) + have h6 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (-1) = (-1)" unfolding insertion_neg by auto + have h7 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) = + b\<^sup>2 - 4 * a * c" apply(simp add: insertion_four insertion_mult insertion_sub insertion_pow b_def a_def c_def) + by (metis insertion_isovarspars_free list_update_id) + have "\xa. insertion (nth_default 0 (xs' @ xa # xs)) (2::real mpoly) = (2::real)" + by (metis MPoly_Type.insertion_one insertion_add one_add_one) + then have h8 : "\xa. insertion (nth_default 0 ((xs' @ x # xs)[var := xa])) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def apply auto + by (metis assms(3) insertion_lowerPoly1 list_update_length not_in_isovarspar) + have h9 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h10 : "var\vars(- 1::real mpoly)" + by (metis h9 not_in_neg not_in_pow power.simps(1)) + have h11 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "eval + (substInfinitesimalQuadratic var (- isolate_variable_sparse p var (Suc 0)) (-1) + ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) + (2 * isolate_variable_sparse p var 2) At) + (xs' @ x # xs) = evalUni + (substInfinitesimalQuadraticUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) At') x" + proof (cases "convert_atom var At (xs' @ x # xs)") + case None + then show ?thesis using At' apply(cases At) by auto + next + case (Some aT) + have h1 : "insertion (nth_default 0 (xs' @ x # xs)) (- isolate_variable_sparse p var (Suc 0)) = (-b)" unfolding b_def insertion_neg by auto + have h2 : "insertion (nth_default 0 (xs' @ x # xs)) (-1) = -1" unfolding insertion_neg by auto + have h3 : "insertion (nth_default 0 (xs' @ x # xs)) (((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)) = (b\<^sup>2 - 4 * a * c)" + unfolding insertion_mult insertion_pow insertion_four insertion_neg insertion_sub a_def b_def c_def + by auto + have h4 : "insertion (nth_default 0 (xs' @ x # xs)) (2 * isolate_variable_sparse p var 2) = 2 * a" + unfolding insertion_mult a_def + by (metis insertion_add insertion_mult mult_2) + have h5 : "2 * a \ 0" using Cons by auto + have h6 : "0 \ b\<^sup>2 - 4 * a * c" using Cons by auto + have h7 : "var\vars(- isolate_variable_sparse p var (Suc 0))" + by (simp add: not_in_isovarspar not_in_neg) + have h8 : "var\vars(- 1::real mpoly)" + by (simp add: h10 not_in_neg) + have h9 : "var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * + isolate_variable_sparse p var 0)" + by (metis add_uminus_conv_diff not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow num_double numeral_times_numeral one_add_one power_0) + have h10 : "var\vars(2 * isolate_variable_sparse p var 2)" + by (metis isovarspar_sum mult_2 not_in_isovarspar) + have h : "evalUni (substInfinitesimalQuadraticUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) aT) + x = + evalUni (substInfinitesimalQuadraticUni (- b) (-1) (b\<^sup>2 - 4 * a * c) (2 * a) At') + x"proof(cases At) + case (Less p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Eq p) + then show ?thesis using At'[symmetric] Some[symmetric] apply(cases "MPoly_Type.degree p var < 3") by auto + next + case (Leq x3) + then show ?thesis using At' + using Some option.inject by auto + next + case (Neq x4) + then show ?thesis using At' + using Some by auto + qed + show ?thesis unfolding convert_substInfinitesimalQuadratic[OF Some h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 assms(3)] + using h . + qed + + + show ?case + unfolding L2' apply(simp del : substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps) + unfolding + Cons(1)[OF Cons(2) Cons(3) L2's] + unfolding h + by auto + qed + + show ?thesis using assms(1)[symmetric] unfolding Neq apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(simp del : substInfinitesimalLinear.simps substInfinitesimalLinearUni.simps substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps + add: insertion_neg insertion_mult insertion_add insertion_pow insertion_sub insertion_four + a_def[symmetric] b_def[symmetric] c_def[symmetric] a_def'[symmetric] b_def'[symmetric] c_def'[symmetric] eval_list_conj + eval_list_conj_Uni + ) using linear quadratic_1 quadratic_2 by smt +qed + +lemma convert_list : + assumes "convert_atom_list var L (xs' @ x # xs) = Some L'" + assumes "l\set(L)" + shows "\l'\ set L'. convert_atom var l (xs' @ x # xs) = Some l'" + using assms +proof(induction L arbitrary : L') + case Nil + then show ?case by auto +next + case (Cons At L) + then show ?case proof(cases At) + case (Less p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Less apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all apply(cases "l = Less p") by simp_all + next + case (Eq p) + show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Eq apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all apply(cases "l = Eq p") by simp_all + next + case (Leq p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Leq apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all apply(cases "l = Leq p") by simp_all + next + case (Neq p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Neq apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all apply(cases "l = Neq p") by simp_all + qed +qed + +lemma convert_list2 : + assumes "convert_atom_list var L (xs' @ x # xs) = Some L'" + assumes "l'\set(L')" + shows "\l\ set L. convert_atom var l (xs' @ x # xs) = Some l'" + using assms +proof(induction L arbitrary : L') + case Nil + then show ?case by auto +next + case (Cons At L) + then show ?case proof(cases At) + case (Less p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Less apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all + by blast + next + case (Eq p) + show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Eq apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all by blast + next + case (Leq p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Leq apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all by blast + next + case (Neq p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Neq apply simp apply(cases "MPoly_Type.degree p var < 3") apply simp_all + apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all by blast + qed +qed + +lemma elimVar_atom_convert : + assumes "convert_atom_list var L (xs' @ x # xs) = Some L'" + assumes "convert_atom_list var L2 (xs' @ x # xs) = Some L2'" + assumes "length xs' = var" + shows "(\f\set L. eval (elimVar var L2 [] f) (xs' @ x # xs)) + = (\f\set L'. evalUni (elimVarUni_atom L2' f) x)" +proof safe + fix f + assume h : "f \ set L" + "eval (elimVar var L2 [] f) (xs' @ x # xs)" + have "\f'\set L'. convert_atom var f (xs' @ x # xs) = Some f'" + using convert_list h assms by auto + then obtain f' where f' : "f'\set L'" "convert_atom var f (xs' @ x # xs) = Some f'" by metis + show "\f\set L'. evalUni (elimVarUni_atom L2' f) x" + apply(rule bexI[where x=f']) using f' elimVar_atom_single[OF f'(2) assms(2) assms(3)] h by auto +next + fix f' + assume h : "f' \ set L'" + "evalUni (elimVarUni_atom L2' f') x" + have "\f\set L. convert_atom var f (xs' @ x # xs) = Some f'" using convert_list2 h assms by auto + then obtain f where f : "f\set L" "convert_atom var f (xs' @ x # xs) = Some f'" by metis + show "\f\set L. eval (elimVar var L2 [] f) (xs' @ x # xs)" + apply(rule bexI[where x=f]) using f elimVar_atom_single[OF f(2) assms(2) assms(3)] h by auto +qed + + +lemma eval_convert : + assumes "convert_atom_list var L (xs' @ x # xs) = Some L'" + assumes "length xs' = var" + shows "(\f\set L. aEval f (xs' @ x # xs)) = (\f\set L'. aEvalUni f x)" + using assms +proof(induction L arbitrary : L') + case Nil + then show ?case by auto +next + case (Cons a L) + then show ?case proof(cases a) + case (Less p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Less apply(cases " MPoly_Type.degree p var < 3") + apply simp_all apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all + by (simp add: poly_to_univar) + next + case (Eq p) + then show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Eq apply(cases " MPoly_Type.degree p var < 3") + apply simp_all apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all + by (simp add: poly_to_univar) + next + case (Leq p) + show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Leq apply(cases " MPoly_Type.degree p var < 3") + apply simp_all apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all + by (simp add: poly_to_univar) + next + case (Neq p) + show ?thesis using Cons(2)[symmetric] Cons(1) Cons(3) unfolding Neq apply(cases " MPoly_Type.degree p var < 3") + apply simp_all apply(cases "convert_atom_list var L (xs' @ x # xs)") apply simp_all + by (simp add: poly_to_univar) + qed +qed +lemma all_degree_2_convert : + assumes "all_degree_2 var L" + shows "\L'. convert_atom_list var L xs = Some L'" + using assms +proof(induction L) + case Nil + then show ?case by auto +next + case (Cons a L) + then show ?case proof(cases a) + case (Less p) + show ?thesis using Cons unfolding Less all_degree_2.simps convert_atom_list.simps convert_atom.simps + using degree_convert_eq[of var p xs] by auto + next + case (Eq p) + then show ?thesis using Cons unfolding Eq all_degree_2.simps convert_atom_list.simps convert_atom.simps + using degree_convert_eq[of var p xs] by auto + next + case (Leq x3) + then show ?thesis using Cons by auto + next + case (Neq x4) + then show ?thesis using Cons by auto + qed +qed +lemma gen_qe_eval : + assumes hlength : "length xs = var" + shows "(\x. (eval (list_conj ((map Atom L) @ F)) (xs @ (x#\)))) = (\x.(eval (gen_qe var L F) (xs @ (x#\))))" +proof(cases "luckyFind var L []") + case None + then have notLucky : "luckyFind var L [] = None" by auto + then show ?thesis proof(cases F) + case Nil + then show ?thesis proof(cases "all_degree_2 var L") + case True + then have "\x.\L'. convert_atom_list var L (xs@x#\) = Some L'" using all_degree_2_convert[of var L "xs@_#\"] by auto + then obtain L' where L' : "convert_atom_list var L (xs@x#\) = Some L'" by metis + then have L' : "\x. convert_atom_list var L (xs@x#\) = Some L'" + by (metis convert_atom_list_change hlength) + show ?thesis + unfolding Nil apply (simp add:eval_list_conj eval_list_disj True del:luckyFind.simps) unfolding notLucky apply (simp add:eval_list_conj eval_list_disj) + using negInf_convert[OF L' assms] elimVar_atom_convert[OF L' L' assms] eval_convert[OF L' assms] + using eval_generalVS''[of L'] unfolding eval_list_conj_Uni generalVS_DNF.simps eval_list_conj_Uni eval_list_disj_Uni eval_append eval_map eval_map_all + evalUni.simps + + by auto + next + case False + then show ?thesis using notLucky unfolding Nil False apply simp + by (metis append_Nil2 hlength notLucky option.simps(4) qe_eq_repeat.simps qe_eq_repeat_eval) + qed + next + case (Cons a list) + show ?thesis + apply(simp add:Cons del:qe_eq_repeat.simps) + apply(rule qe_eq_repeat_eval[of xs var L "a # list" \]) + using assms . + qed +next + case (Some a) + then show ?thesis + using luckyFind_eval[OF Some assms] apply(cases F) apply simp + apply(simp add:Cons del:qe_eq_repeat.simps) + using qe_eq_repeat_eval[of xs var L _ \] + using assms by auto +qed + + +lemma freeIn_elimVar : "freeIn var (elimVar var L F A)" +proof(cases A) + case (Less p) + have two: "2 = Suc(Suc 0)" by auto + have notIn4: "var \ vars (4::real mpoly)" + by (metis isolate_var_one not_in_add not_in_isovarspar numeral_plus_numeral one_add_one semiring_norm(2) semiring_norm(6)) + show ?thesis using Less apply auto + using not_in_isovarspar apply force+ + apply (rule freeIn_list_conj) + apply auto + defer defer + using not_in_isovarspar apply force+ + using not_in_sub[OF not_in_mult[of var 4, OF _ not_in_mult[of var "isolate_variable_sparse p var 2" "isolate_variable_sparse p var 0"]], of "(isolate_variable_sparse p var (Suc 0))\<^sup>2"] + apply (simp add:not_in_isovarspar two) + using not_in_mult[of var "isolate_variable_sparse p var (Suc 0)" "isolate_variable_sparse p var (Suc 0)"] + apply (simp add:not_in_isovarspar notIn4) + apply (simp add: ideal.scale_scale) + apply(rule freeIn_list_conj) + apply auto + defer defer + apply(rule freeIn_list_conj) + apply auto + apply(rule freeIn_substInfinitesimalQuadratic) apply auto + using not_in_isovarspar not_in_neg apply blast + apply (metis not_in_isovarspar not_in_neg not_in_pow power_0) + using notIn4 not_in_isovarspar not_in_mult not_in_pow not_in_sub apply auto[1] + apply (metis isovarspar_sum mult_2 not_in_isovarspar) + using freeIn_substInfinitesimalQuadratic_fm[of var "(- isolate_variable_sparse p var (Suc 0))" "-1" "((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" "(2 * isolate_variable_sparse p var 2)"] apply auto[1] + apply (metis (no_types, lifting) mult_2 notIn4 not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow not_in_sub power_0) + apply(rule freeIn_substInfinitesimalLinear) + apply (meson not_in_isovarspar not_in_neg) + apply (simp add: not_in_isovarspar) + using freeIn_substInfinitesimalLinear_fm + using not_in_isovarspar not_in_neg apply force + apply (metis (no_types, lifting) \\var \ vars 4; var \ vars (isolate_variable_sparse p var 2); var \ vars (isolate_variable_sparse p var 0); var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2)\ \ var \ vars (4 * (isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) - (isolate_variable_sparse p var (Suc 0))\<^sup>2)\ freeIn_substInfinitesimalQuadratic minus_diff_eq mult.assoc mult_2 notIn4 not_in_add not_in_isovarspar not_in_neg not_in_pow power_0) + using freeIn_substInfinitesimalQuadratic_fm[of var "(- isolate_variable_sparse p var (Suc 0))" 1 "((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" "(2 * isolate_variable_sparse p var 2)"] + apply auto + by (metis (no_types, lifting) \\var \ vars 4; var \ vars (isolate_variable_sparse p var 2); var \ vars (isolate_variable_sparse p var 0); var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2)\ \ var \ vars (4 * (isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) - (isolate_variable_sparse p var (Suc 0))\<^sup>2)\ ideal.scale_scale minus_diff_eq mult_2 notIn4 not_in_add not_in_isovarspar not_in_neg not_in_pow power_0) +next + case (Eq p) + then show ?thesis using freeIn_elimVar_eq by auto +next + case (Leq p) + then show ?thesis using freeIn_elimVar_eq by auto +next + case (Neq p) + have two: "2 = Suc(Suc 0)" by auto + have notIn4: "var \ vars (4::real mpoly)" + by (metis isolate_var_one not_in_add not_in_isovarspar numeral_plus_numeral one_add_one semiring_norm(2) semiring_norm(6)) + show ?thesis using Neq apply auto + using not_in_isovarspar apply force+ + apply (rule freeIn_list_conj) + apply auto + defer defer + using not_in_isovarspar apply force+ + using not_in_sub[OF not_in_mult[of var 4, OF _ not_in_mult[of var "isolate_variable_sparse p var 2" "isolate_variable_sparse p var 0"]], of "(isolate_variable_sparse p var (Suc 0))\<^sup>2"] + apply (simp add:not_in_isovarspar two) + using not_in_mult[of var "isolate_variable_sparse p var (Suc 0)" "isolate_variable_sparse p var (Suc 0)"] + apply (simp add:not_in_isovarspar notIn4) + apply (simp add: ideal.scale_scale) + apply(rule freeIn_list_conj) + apply auto + defer defer + apply(rule freeIn_list_conj) + apply auto + apply(rule freeIn_substInfinitesimalQuadratic) apply auto + using not_in_isovarspar not_in_neg apply blast + apply (metis not_in_isovarspar not_in_neg not_in_pow power_0) + using notIn4 not_in_isovarspar not_in_mult not_in_pow not_in_sub apply auto[1] + apply (metis isovarspar_sum mult_2 not_in_isovarspar) + using freeIn_substInfinitesimalQuadratic_fm[of var "(- isolate_variable_sparse p var (Suc 0))" "-1" "((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" "(2 * isolate_variable_sparse p var 2)"] apply auto[1] + apply (metis (no_types, lifting) mult_2 notIn4 not_in_add not_in_isovarspar not_in_mult not_in_neg not_in_pow not_in_sub power_0) + apply(rule freeIn_substInfinitesimalLinear) + apply (meson not_in_isovarspar not_in_neg) + apply (simp add: not_in_isovarspar) + using freeIn_substInfinitesimalLinear_fm + using not_in_isovarspar not_in_neg apply force + apply (metis (no_types, lifting) \\var \ vars 4; var \ vars (isolate_variable_sparse p var 2); var \ vars (isolate_variable_sparse p var 0); var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2)\ \ var \ vars (4 * (isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) - (isolate_variable_sparse p var (Suc 0))\<^sup>2)\ freeIn_substInfinitesimalQuadratic minus_diff_eq mult.assoc mult_2 notIn4 not_in_add not_in_isovarspar not_in_neg not_in_pow power_0) + using freeIn_substInfinitesimalQuadratic_fm[of var "(- isolate_variable_sparse p var (Suc 0))" 1 "((isolate_variable_sparse p var (Suc 0))\<^sup>2 - + 4 * isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0)" "(2 * isolate_variable_sparse p var 2)"] + apply auto + by (metis (no_types, lifting) \\var \ vars 4; var \ vars (isolate_variable_sparse p var 2); var \ vars (isolate_variable_sparse p var 0); var \ vars ((isolate_variable_sparse p var (Suc 0))\<^sup>2)\ \ var \ vars (4 * (isolate_variable_sparse p var 2 * isolate_variable_sparse p var 0) - (isolate_variable_sparse p var (Suc 0))\<^sup>2)\ ideal.scale_scale minus_diff_eq mult_2 notIn4 not_in_add not_in_isovarspar not_in_neg not_in_pow power_0) +qed + +lemma freeInDisj: "freeIn var (list_disj (list_conj (map (substNegInfinity var) L) # map (elimVar var L []) L))" + apply(rule freeIn_list_disj) + apply(auto) + apply(rule freeIn_list_conj) + apply simp + + using freeIn_substNegInfinity[of var] + apply simp + using freeIn_elimVar + by simp + +lemma gen_qe_eval' : + assumes "all_degree_2 var L" + assumes "length xs' = var" + shows "(\x. (eval (list_conj (map Atom L)) (xs'@x#\))) = (\x.(eval (gen_qe var L []) (xs'@x#\)))" + "freeIn var (gen_qe var L [])" +proof- + have h : "(\x. (eval (list_conj (map Atom L)) (xs'@x#\))) = (\x. eval (gen_qe var L []) (xs'@x # \))" + using gen_qe_eval[OF assms(2), of L "[]" \] unfolding List.append.left_neutral by auto + show "(\x. (eval (list_conj (map Atom L)) (xs'@x#\))) = (\x.(eval (gen_qe var L []) (xs'@x#\)))" + unfolding h + apply (simp add:assms) + apply(cases "find_lucky_eq var L") + apply simp using freeInDisj[of var L] + using var_not_in_eval3[OF _ assms(2)] apply blast + subgoal for a + using freeIn_elimVar_eq[of var L "[]" a] + apply(simp del:elimVar.simps) + using var_not_in_eval3[OF _ assms(2)] by blast + done +next + show "freeIn var (gen_qe var L []) " + apply(simp add:assms) + apply(cases "find_lucky_eq var L") apply (simp add:freeInDisj) + subgoal for a + using freeIn_elimVar_eq[of var L "[]" a] + by(simp del:elimVar.simps) + done +qed + + + +lemma gen_qe_eval'' : + assumes "all_degree_2 var L" + assumes "length xs' = var" + shows "(\x. (eval (list_conj (map Atom L)) (xs'@x#\))) = (\x.(eval (list_disj + (list_conj (map (substNegInfinity var) L) # map (elimVar var L []) L)) (xs'@x#\)))" +proof(cases "convert_atom_list var L (xs'@x#\)") + case None + then show ?thesis using all_degree_2_convert[OF assms(1), of "(xs' @ x # \)"] by auto +next + case (Some a) + then have Some : "\x. convert_atom_list var L (xs'@x#\) = Some a" using convert_atom_list_change[OF assms(2), of L x \] + by fastforce + + show ?thesis + apply (simp add: eval_list_conj eval_list_disj) + using negInf_convert[OF Some assms(2)] elimVar_atom_convert[OF Some Some assms(2)] eval_convert[OF Some assms(2)] + using eval_generalVS''[of a] unfolding eval_list_conj_Uni generalVS_DNF.simps eval_list_conj_Uni eval_list_disj_Uni eval_append eval_map eval_map_all + evalUni.simps + by auto +qed + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/Heuristic.thy b/thys/Virtual_Substitution/Heuristic.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/Heuristic.thy @@ -0,0 +1,157 @@ +subsection "Heuristic Algorithms" +theory Heuristic + imports VSAlgos Reindex Optimizations +begin +fun IdentityHeuristic :: "nat \ atom list \ atom fm list \ nat" where + "IdentityHeuristic n _ _ = n" + +fun step_augment :: "(nat \ atom list \ atom fm list \ atom fm) \ (nat \ atom list \ atom fm list \ nat) \ nat \ nat \ atom list \ atom fm list \ atom fm" where + "step_augment step heuristic 0 var L F = list_conj (map fm.Atom L @ F)" | + "step_augment step heuristic (Suc 0) 0 L F = step 0 L F" | + "step_augment step heuristic _ 0 L F = list_conj (map fm.Atom L @ F)" | + "step_augment step heuristic (Suc amount) (Suc i) L F =( + let var = heuristic (Suc i) L F in + let swappedL = map (swap_atom (i+1) var) L in + let swappedF = map (swap_fm (i+1) var) F in + list_disj[step_augment step heuristic amount i al fl. (al,fl)<-dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (i+1) swappedL swappedF))])" + + +fun the_real_step_augment :: "(nat \ atom list \ atom fm list \ atom fm) \ nat \ (atom list * atom fm list * nat) list \ atom fm" where + "the_real_step_augment step 0 F = list_disj (map (\(L,F,n). ExN n (list_conj (map fm.Atom L @ F))) F)" | + "the_real_step_augment step (Suc amount) F =( + ExQ (the_real_step_augment step amount (dnf_modified ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(list_disj(map (\(L,F,n). ExN n (step (n+amount) L F)) F))))))" + + +fun aquireData :: "nat \ atom list \ (nat fset*nat fset*nat fset)"where + "aquireData n L = fold (\A (l,e,g). + case A of + Eq p \ + ( + funion l (fset_of_list(filter (\v. let (a,b,c) = get_coeffs v p in + ((MPoly_Type.degree p v = 1 \ MPoly_Type.degree p v = 2) \ (check_nonzero_const a \ check_nonzero_const b \ check_nonzero_const c))) [0..<(n+1)])), + funion e (fset_of_list(filter (\v.(MPoly_Type.degree p v = 1 \ MPoly_Type.degree p v = 2)) [0..<(n+1)])) + ,ffilter (\v. MPoly_Type.degree p v \ 2) g) + | Leq p \ (l,e,ffilter (\v. MPoly_Type.degree p v \ 2) g) + | Neq p \ (l,e,ffilter (\v. MPoly_Type.degree p v \ 2) g) + | Less p \ (l,e,ffilter (\v. MPoly_Type.degree p v \ 2) g) +) L (fempty,fempty,fset_of_list [0..<(n+1)])" + + +datatype natpair = Pair "nat*nat" + +instantiation natpair :: linorder +begin +definition [simp]: "less_eq (A::natpair) B = (case A of Pair(a,b) \ (case B of Pair(c,d) \ if a=c then b\d else a (case B of Pair(c,d) \ if a=c then b) x y" + unfolding x y by auto + show "x\x" unfolding x by auto + show "x\ y \ y\ z \ x\ z" unfolding x y z apply auto + apply (metis dual_order.trans not_less_iff_gr_or_eq) + by (metis less_trans) + show "x \ y \ y \ x \ x = y" unfolding x y apply auto + apply (metis not_less_iff_gr_or_eq) + by (metis antisym_conv not_less_iff_gr_or_eq) + show "x \ y \ y \ x" unfolding x y by auto +qed +end + +fun getBest :: "nat fset \ atom list \ nat option" where + "getBest S L = (let X = fset_of_list(map (\x. Pair(count_list (map (\l. case l of + Eq p \ MPoly_Type.degree p x = 0 +| Less p \ MPoly_Type.degree p x = 0 +| Neq p \ MPoly_Type.degree p x = 0 +| Leq p \ MPoly_Type.degree p x = 0 +) L) False,x)) (sorted_list_of_fset S)) in +(case (sorted_list_of_fset X) of [] \ None | Cons (Pair(x,v)) _ \ Some v)) +" + +fun heuristicPicker :: "nat \ atom list \ atom fm list \ (nat*(nat \ atom list \ atom fm list \ atom fm)) option"where + "heuristicPicker n L F = (case (let (l,e,g) = aquireData n L in +(case getBest l L of + None \ (case F of + [] \ + (case getBest g L of + None \ (case getBest e L of None \ None | Some v \ Some(v,qe_eq_repeat)) + | Some v \ Some(v,gen_qe) + ) + | _ \ (case getBest e L of None \ None | Some v \ Some(v,qe_eq_repeat)) + ) +| Some v \ Some(v,luckyFind') +)) of None => None | Some(var,step) => (if var > n then None else Some(var,step)))" + + +fun superPicker :: "nat \ nat \ atom list \ atom fm list \ atom fm" where + "superPicker 0 var L F = list_conj (map fm.Atom L @ F)"| + "superPicker amount 0 L F = (case heuristicPicker 0 L F of Some(0,step) \ step 0 L F | _ \ list_conj (map fm.Atom L @ F))" | + "superPicker (Suc amount) (Suc i) L F =( + case heuristicPicker (Suc i) L F of + Some(var,step) \ + let swappedL = map (swap_atom (i+1) var) L in + let swappedF = map (swap_fm (i+1) var) F in + list_disj[superPicker amount i al fl. (al,fl)<-dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (i+1) swappedL swappedF))] + | None \ list_conj (map fm.Atom L @ F))" + + +datatype quadnat = Quad "nat \ nat \ nat \ nat" + +instantiation quadnat :: linorder begin +definition [simp]:"A (case B of Quad(a2,b2,c2,d2) \ + (if a1=a2 then ( + if b1=b2 then ( + if c1=c2 then d1B = + (case A of Quad(a1,b1,c1,d1) \ (case B of Quad(a2,b2,c2,d2) \ + (if a1=a2 then ( + if b1=b2 then ( + if c1=c2 then d1\d2 else c1) x y" unfolding x y by auto + show "x \ x" unfolding x by auto + show "x \ y \ y \ z \ x \ z" unfolding x y z apply auto + apply (metis dual_order.trans not_less_iff_gr_or_eq) + apply (metis less_trans) + apply (metis dual_order.strict_trans not_less_iff_gr_or_eq) + apply (metis less_trans) + apply (metis dual_order.strict_trans not_less_iff_gr_or_eq) + apply (metis less_trans) + apply (metis less_trans not_less_iff_gr_or_eq) + by (metis less_trans) + show "x \ y \ y \ x \ x = y" unfolding x y apply auto + apply (metis less_imp_not_less) + apply (metis not_less_iff_gr_or_eq) + apply (metis not_less_iff_gr_or_eq) + by (metis antisym_conv not_less_iff_gr_or_eq) + show "x \ y \ y \ x" unfolding x y by auto +qed +end + +fun brownsHeuristic :: "nat \ atom list \ atom fm list \ nat" where + "brownsHeuristic n L _ = (case sorted_list_of_fset (fset_of_list (map (\x. + case (foldl (\(maxdeg,totaldeg,appearancecount) l. + let p = case l of Eq p \ p | Less p \ p | Leq p \ p | Neq p \ p in + let deg = MPoly_Type.degree p x in + (max maxdeg deg,totaldeg+deg,appearancecount+(if deg>0 then 1 else 0))) (0,0,0) L) of (a,b,c) \ Quad(a,b,c,x) + ) [0.. n | Cons (Quad(_,_,_,x)) _ \ if x>n then n else x)" + + +end diff --git a/thys/Virtual_Substitution/HeuristicProofs.thy b/thys/Virtual_Substitution/HeuristicProofs.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/HeuristicProofs.thy @@ -0,0 +1,551 @@ +subsection "Heuristic Proofs" +theory HeuristicProofs + imports VSQuad Heuristic OptimizationProofs +begin + +lemma the_real_step_augment: + assumes steph : "\xs var L F \. length xs = var \ (\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = (\x. eval (step var L F) (xs @ x # \))" + shows "(\xs. (length xs = amount \ eval (list_disj (map(\(L,F,n). ExN n (list_conj (map fm.Atom L @ F))) F)) (xs @ \))) = (eval (the_real_step_augment step amount F) \)" +proof(induction amount arbitrary: F \) + case 0 + then show ?case by auto +next + case (Suc amount) + have h1 : "\F. (\x xs. length xs = amount \ F (xs @ x # \)) = (\xs. length xs = Suc amount \ F (xs @ \))" + by (smt (z3) Suc_inject append.assoc append_Cons append_Nil2 append_eq_conv_conj length_append_singleton lessI self_append_conv2 take_hd_drop) + + have h2: "\X x \. (\f\set (dnf_modified X). + eval (case f of (L, F, n) \ ExN n (list_conj (map fm.Atom L @ F))) (x @ \)) = (\(al, fl, n)\set (dnf_modified X). \L. length L = n \ (\a\set al. aEval a (L @ (x @ \))) \ (\f\set fl. eval f (L @ (x @ \))))" + subgoal for X x \ + apply(rule bex_cong) + apply simp_all + subgoal for f + apply(cases f) + apply(auto simp add:eval_list_conj) + by (metis Un_iff eval.simps(1) imageI) + done + done + have h3 : "\G. (\x. \f\set F. G x f) = (\f\set F. \x. G x f)" + by blast + show ?case + apply simp + unfolding Suc[symmetric] + unfolding eval_list_disj + apply simp + unfolding h1[symmetric, of "\x. (\f\set F. eval (case f of (L, F, n) \ ExN n (list_conj (map fm.Atom L @ F))) x)"] + unfolding HOL.ex_comm[of "\x xs. length xs = amount \ (\f\set F. eval (case f of (L, F, n) \ ExN n (list_conj (map fm.Atom L @ F))) (xs @ x # \))"] + unfolding HOL.ex_comm[of "\x xs. length xs = amount \ + (\f\set (dnf_modified (push_forall + (nnf (unpower 0 + (groupQuantifiers + (clearQuantifiers(list_disj (map (\(L, F, n). ExN n (step (n + amount) L F)) F)))))))). + eval (case f of (L, F, n) \ ExN n (list_conj (map fm.Atom L @ F))) (xs @ x # \))"] + apply(rule ex_cong1) + apply simp + subgoal for xs + unfolding h2 + unfolding dnf_modified_eval + unfolding opt' + unfolding eval_list_disj + unfolding List.set_map Set.bex_simps(7) + unfolding h3 + apply(cases "length xs = amount") + apply (simp_all add:opt) + apply(rule bex_cong) + apply simp_all + subgoal for f + apply(cases f) + apply simp + subgoal for a b c + unfolding HOL.ex_comm[of "\x l. length l = c \ eval (list_conj (map fm.Atom a @ b)) (l @ xs @ x # \)"] + unfolding HOL.ex_comm[of "\x l. length l = c \ eval (step (c + amount) a b) (l @ xs @ x # \)"] + apply(rule ex_cong1) + apply simp + subgoal for l + apply(cases "length l = c") + apply simp_all + using steph[of "l @ xs" "c + amount" a b \] + by simp + done + done + done + done +qed + +lemma step_converter : + assumes steph : "\xs var L F \. length xs = var \ (\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = (\x. eval (step var L F) (xs @ x # \))" + shows "\var L F \. (\xs. length xs = var + 1 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = (var + 1)) \ eval (step var L F) (xs @ \))" +proof safe + fix var L F \ xs + assume h : "length xs = var + 1" + "eval (list_conj (map fm.Atom L @ F)) (xs @ \)" + have h1 : "length (take var xs) = var" using h by auto + have h2 : "(\x. eval (step var L F) (take var xs @ x # \))" + using h steph[OF h1] + by (metis Cons_nth_drop_Suc One_nat_def add.right_neutral add_Suc_right append.assoc append_Cons append_Nil append_take_drop_id drop_all lessI order_refl) + then obtain x where h3: "eval (step var L F) (take var xs @ x # \)" by auto + show "\xs. length xs = var + 1 \ eval (step var L F) (xs @ \)" + apply(rule exI[where x="take var xs @[x]"]) + apply (auto) + using h(1) apply simp + using h3 by simp +next + fix var L F \ xs + assume h: "length xs = var + 1" + "eval (step var L F) (xs @ \)" + have h1 : "length (take var xs) = var" using h by auto + have h2 : "(\x. eval (list_conj (map fm.Atom L @ F)) (take var xs @ x # \))" + using h steph[OF h1] + by (metis Cons_nth_drop_Suc One_nat_def add.right_neutral add_Suc_right append.assoc append_Cons append_Nil append_take_drop_id drop_all lessI order_refl) + then obtain x where h3: "eval (list_conj (map fm.Atom L @ F)) (take var xs @ x # \)" by auto + show "\xs. length xs = var + 1 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)" + apply(rule exI[where x="take var xs @[x]"]) + apply (auto) + using h(1) apply simp + using h3 by simp +qed + +lemma step_augmenter_eval : + assumes steph : "\xs var L F \. length xs = var \ (\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = (\x. eval (step var L F) (xs @ x # \))" + assumes heuristic: "\n var L F. heuristic n L F = var \ var \ n" + shows "\var amount L F \. + amount \ var + 1 \ + (\xs. length xs = var + 1 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = (var + 1)) \ eval (step_augment step heuristic amount var L F) (xs @ \))" + subgoal for var amount L F \ + proof(induction var arbitrary: L F \ amount) + case 0 + then have "amount = 0 \ amount = Suc 0" by auto + then show ?case apply simp using steph[of "[]" 0 L F \] apply auto + apply (metis append_Cons length_Cons list.size(3) self_append_conv2) + apply (metis append_Cons length_Cons list.size(3) self_append_conv2) + apply (metis Suc_length_conv append_Cons length_0_conv self_append_conv2) + by (metis Suc_length_conv append_Cons append_self_conv2 length_0_conv) + next + case (Suc var) + define heu where "heu = heuristic (Suc var) L F" + have heurange : "heu \ Suc var" unfolding heu_def + by (simp add: heuristic) + have lessThan1 : "1 \ var + 1" by auto + + { + fix amount + assume amountLessThan: "amount \ var + 1" + have "(\xs. length xs = Suc (Suc var) \ + eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = (\xs. length xs = Suc (Suc var) \ + eval + (step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)) + (xs @ \))" + proof(safe) + fix xs + assume h: "length (xs::real list) = Suc (Suc var)" "eval (list_conj (map fm.Atom L @ F)) (xs @ \)" + then have length : "length (take (Suc var) (swap_list (Suc var) heu xs)) = Suc var" by auto + have take: "(take (Suc var) (swap_list (Suc var) heu xs) @ xs ! heu # \) = (swap_list (Suc var) heu (xs @ \)) " using h(1) + unfolding swap_list.simps + by (smt (verit, ccfv_threshold) Cons_nth_drop_Suc append.right_neutral append_Nil2 append_assoc append_eq_conv_conj append_self_conv2 append_take_drop_id drop0 heu_def heurange le_imp_less_Suc length_greater_0_conv length_list_update lessI list.sel(1) list.sel(3) list.simps(3) list.size(3) list_update_append nth_Cons_0 nth_append nth_append_length nth_list_update_eq take0 take_hd_drop) + have length1 : "Suc var < length (xs @ \)" using h by auto + have length2 : "heu < length (xs @ \)" using h heurange by auto + have h1: "(\x. eval + (step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)) + (take (Suc var) (swap_list (Suc var) heu xs) @ x # \))" + unfolding steph[OF length, symmetric] + apply(rule exI[where x="nth xs heu"]) + using h unfolding eval_list_conj take apply (auto simp del:swap_list.simps) + unfolding swap_fm[OF length1 length2,symmetric] swap_atom[OF length1 length2,symmetric] + by (meson UnCI eval.simps(1) imageI)+ + then obtain x where heval: "eval + (step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)) + (take (Suc var) (swap_list (Suc var) heu xs) @ x # \)" by auto + show "\xs. length xs = Suc (Suc var) \ + eval + (step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)) + (xs @ \)" + apply(rule exI[where x="take (Suc var) (swap_list (Suc var) heu xs) @ [x]"]) + apply auto + using h apply simp + using heval by auto + next + fix xs + assume h : "length xs = Suc (Suc var)"" + eval + (step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)) + (xs @ \)" + define choppedXS where "choppedXS = take (Suc var) xs" + then have length : "length choppedXS = Suc var" + using h(1) by force + have "(\x. eval (step (Suc var) (map (swap_atom (Suc var) heu) L) (map (swap_fm (Suc var) heu) F)) (choppedXS @ x # \))" + using h(2) choppedXS_def + by (metis append.assoc append_Cons append_Nil2 append_eq_conv_conj h(1) lessI take_hd_drop) + then have "\x. (\l\ set L. aEval (swap_atom (Suc var) heu l) (choppedXS@x#\)) \ (\f\ set F. eval (swap_fm (Suc var) heu f) (choppedXS@x#\))" + unfolding steph[symmetric, OF length, of "(map (swap_atom (Suc var) heu) L)" "(map (swap_fm (Suc var) heu) F)" \] eval_list_conj apply auto + by (metis Un_iff eval.simps(1) imageI) + then obtain x where x : "(\l\set L. aEval (swap_atom (Suc var) heu l) (choppedXS @ x # \)) \ + (\f\set F. eval (swap_fm (Suc var) heu f) (choppedXS @ x # \))" by auto + have length1 : "Suc var < length (swap_list (Suc var) heu (choppedXS @ [x]) @ \)" + by (simp add: length) + have length2 : "heu < length (swap_list (Suc var) heu (choppedXS @ [x]) @ \)" + using \Suc var < length (swap_list (Suc var) heu (choppedXS @ [x]) @ \)\ heurange by linarith + have swapswap : "(swap_list (Suc var) heu (swap_list (Suc var) heu (choppedXS @ [x]) @ \)) = (choppedXS @ [x]) @ \" apply auto + by (smt (z3) Cons_nth_drop_Suc append_eq_conv_conj append_same_eq heurange id_take_nth_drop le_neq_implies_less length length1 length_append_singleton lessI list.sel(1) list_update_append1 list_update_length list_update_swap nth_append nth_append_length nth_list_update_neq swap_list.simps take_hd_drop take_update_swap upd_conv_take_nth_drop) + show "\xs. length xs = Suc (Suc var) \ + eval (list_conj (map fm.Atom L @ F)) (xs @ \)" + apply(rule exI[where x="swap_list (Suc var) heu (choppedXS @ [x])"]) + apply(auto simp add: eval_list_conj simp del: swap_list.simps) + apply(simp add :length) + unfolding swap_atom[OF length1 length2] swap_fm[OF length1 length2] swapswap + using x by auto + qed + also have "... = (\xs. length xs = Suc (Suc var) \ + (\f\set (dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)))). + eval (case f of (x, xa) \ step_augment step heuristic amount var x xa) + (xs @ \)))" + unfolding opt[of "(step (Suc var) (map (swap_atom (Suc var) heu) L) (map (swap_fm (Suc var) heu) F))", symmetric] + unfolding dnf_eval[of "(push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F))", symmetric] + proof(safe) + fix xs a b + assume h: "length xs = Suc (Suc var)"" + (a, b) + \ set (dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)))) "" + \a\set a. aEval a (xs @ \) "" + \f\set b. eval f (xs @ \)" + have "(\xs'. length xs' = var + 1 \ + eval (step_augment step heuristic amount var a b) (xs' @ xs ! Suc var # \))" + unfolding Suc(1)[of amount a b "nth xs (Suc var)#\", OF amountLessThan, symmetric] + apply(rule exI[where x="take (Suc var) xs"]) + using h(1) h(3-4) apply(auto simp add: eval_list_conj) + apply (metis Cons_nth_drop_Suc append_Cons append_eq_append_conv2 append_eq_conv_conj append_take_drop_id lessI) + by (metis Cons_nth_drop_Suc append_Cons append_eq_append_conv2 append_eq_conv_conj append_take_drop_id lessI) + then obtain xs' where xs': "length xs' = var + 1" "eval (step_augment step heuristic amount var a b) (xs' @ xs ! Suc var # \)" + by auto + + show "\xs. length xs = Suc (Suc var) \ + (\f\set (dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)))). + eval (case f of (x, xa) \ step_augment step heuristic amount var x xa) + (xs @ \))" + apply(rule exI[where x="xs' @[ xs ! Suc var]"]) + apply auto + using xs' apply simp + apply(rule bexI[where x="(a,b)"]) + using xs' h apply(cases amount) apply (simp_all add:eval_list_conj) + using h(2) by auto + next + fix xs a b + assume h: "length xs = Suc (Suc var) "" + (a, b) + \ set (dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)))) "" + eval (step_augment step heuristic amount var a b) (xs @ \)" + have "(\xs'. length xs' = var + 1 \ + eval (list_conj (map fm.Atom a @ b)) (xs' @ xs ! Suc var # \))" + unfolding Suc(1)[of amount a b "nth xs (Suc var)#\", OF amountLessThan] + apply(rule exI[where x="take (Suc var) xs"]) + using h(1) h(3) apply auto + by (metis Cons_nth_drop_Suc append.right_neutral append_Cons append_assoc append_eq_conv_conj append_self_conv2 append_take_drop_id lessI) + then obtain xs' where xs': "length xs' = var + 1" " eval (list_conj (map fm.Atom a @ b)) (xs' @ xs ! Suc var # \)" + by auto + show "\xs. length xs = Suc (Suc var) \ + (\(al, fl) + \set (dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers)(step (Suc var) (map (swap_atom (Suc var) heu) L) + (map (swap_fm (Suc var) heu) F)))). + (\a\set al. aEval a (xs @ \)) \ + (\f\set fl. eval f (xs @ \)))" + apply(rule exI[where x="xs' @[ xs ! Suc var]"]) + apply auto + using xs' apply simp + apply(rule bexI[where x="(a,b)"]) + using xs' h apply (simp_all add: eval_list_conj) + proof - + assume "\f\fm.Atom ` set a \ set b. eval f (xs' @ xs ! Suc var # \)" + then have "\f. f \ fm.Atom ` set a \ set b \ eval f (xs' @ xs ! Suc var # \)" + by meson + then have f1: "v \ set a \ eval (fm.Atom v) (xs' @ xs ! Suc var # \)" for v + by blast + obtain aa :: atom where + "(\v0. v0 \ set a \ \ eval (fm.Atom v0) (xs' @ xs ! Suc var # \)) = (aa \ set a \ \ eval (fm.Atom aa) (xs' @ xs ! Suc var # \))" + by blast + then show "\a\set a. aEval a (xs' @ xs ! Suc var # \)" + using f1 eval.simps(1) by auto + qed + + qed + finally have "(\xs. length xs = Suc (Suc var) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. length xs = Suc (Suc var) \ + (\f\set (dnf ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers) (step (Suc var) (map (swap_atom (Suc var) heu) L) (map (swap_fm (Suc var) heu) F)))). + eval (case f of (x, xa) \ step_augment step heuristic amount var x xa) (xs @ \)))" + by auto + }then show ?case apply(cases amount) using Suc(2) by (simp_all add:eval_list_disj heu_def[symmetric]) + qed + done + +lemma qe_eq_repeat_eval_augment : "amount \ var+1 \ + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (step_augment qe_eq_repeat IdentityHeuristic amount var L F) (xs @ \))" + apply(rule step_augmenter_eval[of qe_eq_repeat IdentityHeuristic amount var L F \]) + using qe_eq_repeat_eval apply blast by auto + +lemma qe_eq_repeat_eval' : " + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (qe_eq_repeat var L F) (xs @ \))" + apply(rule step_converter[of qe_eq_repeat var L F \]) + using qe_eq_repeat_eval by blast + +lemma gen_qe_eval_augment : "amount \ var+1 \ + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (step_augment gen_qe IdentityHeuristic amount var L F) (xs @ \))" + apply(rule step_augmenter_eval[of gen_qe IdentityHeuristic amount var L F \]) + using gen_qe_eval apply blast by auto + +lemma gen_qe_eval' : " + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (gen_qe var L F) (xs @ \))" + apply(rule step_converter[of gen_qe var L F \]) + using gen_qe_eval by blast + +lemma luckyFind_eval_augment : "amount \ var+1 \ + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (step_augment luckyFind' IdentityHeuristic amount var L F) (xs @ \))" + apply(rule step_augmenter_eval[of luckyFind' IdentityHeuristic amount var L F \]) + using luckyFind'_eval apply blast by auto + +lemma luckyFind_eval' : " + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (luckyFind' var L F) (xs @ \))" + apply(rule step_converter[of luckyFind' var L F \]) + using luckyFind'_eval by blast + +lemma luckiestFind_eval' : " + (\xs. (length xs = var + 1) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = var + 1) \ eval (luckiestFind var L F) (xs @ \))" + apply(rule step_converter[of luckiestFind var L F \]) + using luckiestFind_eval by blast + + +lemma sortedListMember : "sorted_list_of_fset b = var # list \ fmember var b " + by (metis fset_of_list_elem list.set_intros(1) sorted_list_of_fset_simps(2)) + +lemma rangeHeuristic : + assumes "heuristicPicker n L F = Some (var, step)" + shows "var\n" +proof(cases "aquireData n L") + case (fields a b c) + then show ?thesis using assms apply(simp_all del: aquireData.simps getBest.simps) + apply(cases "getBest a L") + apply(simp_all del: aquireData.simps getBest.simps) + apply(cases F) apply(simp_all del: aquireData.simps getBest.simps) + apply(cases "getBest c L") apply(simp_all del: aquireData.simps getBest.simps) + apply(cases "getBest b L")apply(simp_all del: aquireData.simps getBest.simps) + apply (metis not_le_imp_less option.distinct(1) option.inject prod.inject) + apply (metis not_le_imp_less option.distinct(1) option.inject prod.inject) + apply(cases "getBest b L")apply(simp_all del: aquireData.simps getBest.simps) + by (metis not_le_imp_less option.distinct(1) option.inject prod.inject)+ +qed + +lemma pickedOneOfThem : + assumes "heuristicPicker n L F = Some (var, step)" + shows "step = qe_eq_repeat \ step = gen_qe \ step = luckyFind'" + using assms + apply(cases "aquireData n L") + subgoal for l e g + using assms apply(simp_all del: aquireData.simps getBest.simps) + apply(cases "getBest l L") + apply(simp_all del: aquireData.simps getBest.simps) + apply(cases F) apply(simp_all del: aquireData.simps getBest.simps) + apply(cases "getBest g L") apply(simp_all del: aquireData.simps getBest.simps) + apply(cases "getBest e L")apply(simp_all del: aquireData.simps getBest.simps) + apply (metis option.distinct(1) option.inject prod.inject) + apply (metis option.distinct(1) option.inject prod.inject) + apply(cases "getBest e L")apply(simp_all del: aquireData.simps getBest.simps) + by (metis option.distinct(1) option.inject prod.inject)+ + done + +lemma superPicker_eval : + "amount\ var+1 \ (\xs. length xs = var + 1 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. (length xs = (var + 1)) \ eval (superPicker amount var L F) (xs @ \))" +proof(induction var arbitrary : L F \ amount) + case 0 + then show ?case apply(simp del:heuristicPicker.simps) + apply(cases "heuristicPicker 0 L F") apply(cases amount) + apply (simp_all del:heuristicPicker.simps) + subgoal for a + apply(cases a) + apply (simp_all del:heuristicPicker.simps) + subgoal for var step + apply(cases var) apply(cases amount) + apply(simp_all del:heuristicPicker.simps) + proof- + assume h: "heuristicPicker 0 L F = Some (0, step)" + show "(\xs. length xs = Suc 0 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. length xs = Suc 0 \ eval (step 0 L F) (xs @ \)) " + using pickedOneOfThem[OF h] + using qe_eq_repeat_eval'[of 0 L F \] gen_qe_eval'[of 0 L F \] luckyFind_eval'[of 0 L F \] + by auto + next + show "\nat. amount \ Suc 0 \ + heuristicPicker 0 L F = Some (Suc nat, step) \ + a = (Suc nat, step) \ + var = Suc nat \ + (\xs. length xs = Suc 0 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. length xs = Suc 0 \ eval (superPicker amount 0 L F) (xs @ \)) " + apply(cases amount) by(simp_all del:heuristicPicker.simps) + qed + done + done +next + case (Suc i) + then show ?case apply(cases "heuristicPicker (Suc i) L F") apply(cases amount) + apply(simp_all del:heuristicPicker.simps) + subgoal for a + apply(cases a) + apply(simp_all del:heuristicPicker.simps) apply(cases amount) apply simp + apply(cases amount) apply(simp_all del:heuristicPicker.simps) + subgoal for var step amountPred amountPred' + proof- + assume amountPred : "amountPred \ Suc i" + assume ih: "(\amount L F \. + amount \ Suc i \ + (\xs. length xs = Suc i \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)) = + (\xs. length xs = Suc i \ eval (superPicker amount i L F) (xs @ \)))" + assume h0 : "heuristicPicker (Suc i) L F = Some (var, step)" + have h1: "\xs X F. (\f\set (map (\(x, y). F x y) + (dnf X)). + eval f (xs)) = (\(al,fl)\set(dnf X). + eval (F al fl) (xs))" + subgoal for xs X F + apply auto + subgoal for a b + apply(rule bexI[where x="(a,b)"]) + apply simp_all + done + done + done + have eval_map : "\al fl xs \.(\f\set (map fm.Atom al @ fl). eval f (xs @ \)) = ((\a\set al. aEval a (xs @ \)) \ (\f\set fl. eval f (xs @ \)))" + apply auto + by (meson Un_iff eval.simps(1) imageI) + have rearangeExists : "\ X F.((\xs. length xs = Suc (Suc i) \ + (\(al, fl)\set (dnf X). F al fl xs)) = + (\(al,fl)\set (dnf X).(\xs. length xs = Suc (Suc i) \ + F al fl xs)))" + by blast + have dropTheEnd : "\F \.(\xs. length xs = Suc (Suc i) \ F (xs @ \)) = (\x. (\xs. length xs = i+1 \ F (xs @ x#\)))" + apply(safe) + subgoal for F \ xs + apply(rule exI[where x="nth xs (i+1)"]) + apply(rule exI[where x="take (i+1) xs"]) apply auto + by (metis Cons_nth_drop_Suc append.right_neutral append_Cons append_assoc append_eq_conv_conj append_self_conv2 append_take_drop_id lessI) + subgoal for F \ x xs + apply(rule exI[where x="xs@[x]"]) + by auto + done + have h2 : "\X \ amount. amount\ Suc i \((\xs. length xs = Suc (Suc i) \ + (\(al, fl)\set (dnf X). + eval (superPicker amount i al fl) (xs @ \))) + = (\xs. length xs = Suc (Suc i) \ + (\(al, fl)\set (dnf X). + (\a\set al. aEval a (xs@\))\(\f\set fl. eval f (xs@\)))))" + subgoal for X \ amount + unfolding rearangeExists + apply(rule bex_cong) + apply simp + subgoal for x + apply (cases x) + apply simp + subgoal for al fl + unfolding dropTheEnd + unfolding dropTheEnd[of"\xs. (\a\set al. aEval a xs) \ (\f\set fl. eval f xs)"] + apply simp + unfolding ih[of amount al fl "_#\",symmetric] + unfolding eval_list_conj + apply(rule ex_cong1) + subgoal for xa + apply(rule ex_cong1) + subgoal for xab apply auto + by (meson Un_iff eval.simps(1) image_eqI) + done + done + done + done + done + have h3 : "\L F. (\xs. length xs = Suc (Suc i) \ eval (step (Suc i) L F) (xs@\)) = (\xs. length xs = Suc (Suc i) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \))" + subgoal for L F + using pickedOneOfThem[OF h0] + using qe_eq_repeat_eval'[of "Suc i" L F \] gen_qe_eval'[of "Suc i" L F \] luckyFind_eval'[of "Suc i" L F \] + by auto + done + have heurange : "var\ Suc i" using rangeHeuristic[OF h0] by auto + show ?thesis + unfolding eval_list_disj + unfolding h1 + unfolding h2[OF amountPred] + unfolding dnf_eval + unfolding opt' + unfolding h3 + proof(safe) + fix xs + assume h : "length xs = Suc (Suc i)" "eval (list_conj (map fm.Atom L @ F)) (xs @ \)" + have h3 : "var < length (xs @ \)" using h heurange by auto + have h1: "(swap_list (Suc i) var (xs @ \)) = (swap_list (Suc i) var xs @ \)" + using h(1) heurange apply simp + by (simp add: list_update_append nth_append) + have h2 : "Suc i < length (xs @ \)" using h by auto + + show "\xs. length xs = Suc (Suc i) \ + eval (list_conj (map fm.Atom (map (swap_atom (Suc i) var) L) @ map (swap_fm (Suc i) var) F)) (xs @ \)" + apply(rule exI[where x="swap_list (Suc i) var xs"]) + apply(auto simp add:h eval_list_conj simp del:swap_list.simps) + apply(simp add: h) + using swap_fm[OF h2 h3] swap_atom[OF h2 h3] unfolding h1 + using h(2) unfolding eval_list_conj + apply auto + + by (meson Un_iff eval.simps(1) imageI) + next + fix xs + assume h : "length xs = Suc (Suc i)""eval (list_conj (map fm.Atom (map (swap_atom (Suc i) var) L) @ map (swap_fm (Suc i) var) F)) (xs @ \)" + have h3 : "var < length (swap_list (Suc i) var xs @ \)" using h heurange by auto + have h1: "swap_list (Suc i) var (swap_list (Suc i) var xs @ \) = xs @ \" + apply auto + using h(1) heurange + by (smt (z3) le_imp_less_Suc length_list_update lessI list_update_append list_update_id list_update_overwrite list_update_swap nth_append nth_list_update_eq) + have h2 : "Suc i < length (swap_list (Suc i) var xs @ \)" using h by auto + show "\xs. length xs = Suc (Suc i) \ eval (list_conj (map fm.Atom L @ F)) (xs @ \)" + apply(rule exI[where x="swap_list (Suc i) var xs"]) + apply(auto simp add:eval_list_conj simp del:swap_list.simps) + apply(simp add: h) + unfolding swap_fm[OF h2 h3] swap_atom[OF h2 h3] + unfolding h1 + using h(2) unfolding eval_list_conj + apply auto + apply (meson Un_iff eval.simps(1) imageI) + done + qed + qed + done + done +qed + + +lemma brownHueristic_less_than: "brownsHeuristic n L F = var \ var\ n" + apply simp + apply(cases "sorted_list_of_fset + ((\x. case foldl + (\(maxdeg, totaldeg, appearancecount) l. + let deg = MPoly_Type.degree (case l of Less p \ p | Eq p \ p | Leq p \ p | Neq p \ p) x + in (max maxdeg deg, totaldeg + deg, appearancecount + (if 0 < deg then 1 else 0))) + (0, 0, 0) L of + (a, b, c) \ Quad (a, b, c, x)) |`| + fset_of_list [0.. vars a" + "var \ vars b" + "var \ vars c" + "var \ vars d" + shows "freeIn var (substInfinitesimalQuadratic var a b c d At)" +proof(cases At) + case (Less p) + show ?thesis unfolding substInfinitesimalQuadratic.simps Less + apply(rule free_in_quad_fm[of var a b c d "(convertDerivative var p)"]) + using assms by auto +next + case (Eq p) + then show ?thesis apply simp + apply(rule freeIn_list_conj) + apply auto + using not_in_isovarspar by simp_all +next + case (Leq p) + then show ?thesis unfolding substInfinitesimalQuadratic.simps Leq freeIn.simps + using free_in_quad_fm[of var a b c d "(convertDerivative var p)", OF assms] apply simp + apply(rule freeIn_list_conj) + using not_in_isovarspar by simp_all +next + case (Neq p) + then show ?thesis apply (auto simp add:neg_def) + apply(rule freeIn_list_conj) + apply auto + using not_in_isovarspar by simp_all +qed + +lemma freeIn_substInfinitesimalQuadratic_fm : assumes "var \ vars a" + "var \ vars b" + "var \ vars c" + "var \ vars d" +shows"freeIn var (substInfinitesimalQuadratic_fm var a b c d F)" +proof- + {fix z + have "freeIn (var+z) + (liftmap + (\x. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) + (liftPoly 0 x c) (liftPoly 0 x d)) + F z)" + apply(induction F arbitrary:z) apply auto + apply(rule freeIn_substInfinitesimalQuadratic) + apply (simp_all add: assms not_in_lift) + apply (metis (no_types, lifting) add_Suc_right) + apply (metis (mono_tags, lifting) add_Suc_right) + apply (simp add: ab_semigroup_add_class.add_ac(1)) + by (simp add: add.assoc) + }then show ?thesis + unfolding substInfinitesimalQuadratic_fm.simps + by (metis (no_types, lifting) add.right_neutral) +qed + +lemma freeIn_substInfinitesimalLinear: + assumes "var \ vars a" "var \ vars b" + shows "freeIn var (substInfinitesimalLinear var a b At)" +proof(cases At) + case (Less p) + show ?thesis unfolding Less substInfinitesimalLinear.simps + using var_not_in_linear_fm[of var a b "(convertDerivative var p)", OF assms] + unfolding linear_substitution_fm.simps linear_substitution_fm_helper.simps . +next + case (Eq p) + then show ?thesis apply simp apply(rule freeIn_list_conj) + apply auto + using not_in_isovarspar by simp_all +next + case (Leq p) + show ?thesis unfolding Leq substInfinitesimalLinear.simps freeIn.simps + using var_not_in_linear_fm[of var a b "(convertDerivative var p)", OF assms] + unfolding linear_substitution_fm.simps linear_substitution_fm_helper.simps apply simp apply(rule freeIn_list_conj) + apply auto + using not_in_isovarspar by simp_all +next + case (Neq p) + then show ?thesis apply (auto simp add:neg_def) apply(rule freeIn_list_conj) + apply auto + using not_in_isovarspar by simp_all +qed + +lemma freeIn_substInfinitesimalLinear_fm: + assumes "var \ vars a" "var \ vars b" + shows "freeIn var (substInfinitesimalLinear_fm var a b F)" +proof- + {fix z + have "freeIn (var+z) + (liftmap (\x. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)" + apply(induction F arbitrary:z) apply auto + apply(rule freeIn_substInfinitesimalLinear) + apply (simp_all add: assms not_in_lift) + apply (metis (full_types) Suc_eq_plus1 ab_semigroup_add_class.add_ac(1)) + apply (metis (full_types) Suc_eq_plus1 ab_semigroup_add_class.add_ac(1)) + apply (simp add: add.assoc) + by (simp add: add.assoc) + } + then show ?thesis + unfolding substInfinitesimalLinear_fm.simps + by (metis (no_types, lifting) add.right_neutral) +qed + +end diff --git a/thys/Virtual_Substitution/InfinitesimalsUni.thy b/thys/Virtual_Substitution/InfinitesimalsUni.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/InfinitesimalsUni.thy @@ -0,0 +1,1301 @@ +theory InfinitesimalsUni + imports Infinitesimals UniAtoms NegInfinityUni QE + +begin + + + +fun convertDerivativeUni :: "real * real * real \ atomUni fmUni" where + "convertDerivativeUni (a,b,c) = + OrUni(AtomUni(LessUni(a,b,c)))(AndUni(AtomUni(EqUni(a,b,c)))( + OrUni(AtomUni(LessUni(0,2*a,b)))(AndUni(AtomUni(EqUni(0,2*a,b)))( + (AtomUni(LessUni(0,0,2*a))) + )) + )) +" + + + +lemma convert_convertDerivative : + assumes "convert_poly var p (xs'@x#xs) = Some(a,b,c)" + assumes "length xs' = var" + shows "eval (convertDerivative var p) (xs'@x#xs) = evalUni (convertDerivativeUni (a,b,c)) x" +proof(cases "MPoly_Type.degree p var = 0") + case True + then show ?thesis using assms apply (simp add: isovar_greater_degree eval_or eval_and insertion_mult insertion_const) + using sum_over_zero[of p var] by auto +next + case False + then have nonzero: "MPoly_Type.degree p var \ 0" by auto + then show ?thesis proof(cases "MPoly_Type.degree p var = 1") + case True + have h1 : "MPoly_Type.degree p var < 3" using True by auto + have h2 : "get_coeffs var p = (isolate_variable_sparse p var 2, isolate_variable_sparse p var 1, isolate_variable_sparse p var 0)" by auto + have h : "insertion (nth_default 0 (xs' @ x # xs)) p = b * x + c" + using poly_to_univar[OF h1 h2 _ _ _ assms(2), of a x xs b c x] using assms(1) apply(cases "MPoly_Type.degree p var < 3") apply simp_all + using isovar_greater_degree[of p var] unfolding True by simp + have h3: "MPoly_Type.degree (isolate_variable_sparse p var (Suc 0) * Const 1) var = 0" + using degree_mult[of "isolate_variable_sparse p var (Suc 0)" "Const 1" var] + using degree_isovarspar mult_one_right by presburger + show ?thesis + using assms True + unfolding convertDerivative.simps[of _ p] convertDerivative.simps[of _ "(derivative var p)"] + apply (simp add: derivative_def isovar_greater_degree eval_or eval_and insertion_add insertion_mult insertion_const HOL.arg_cong[OF sum_over_zero[of p var], of "insertion (nth_default var (xs'@x#xs))"] insertion_var_zero del:convertDerivative.simps) + unfolding h h3 by(simp del:convertDerivative.simps) + next + case False + then have deg2 : "MPoly_Type.degree p var = 2" + by (metis One_nat_def assms(1) convert_poly.simps le_SucE less_Suc0 less_Suc_eq_le nonzero numeral_2_eq_2 numeral_3_eq_3 option.distinct(1)) + then have first : "isolate_variable_sparse p var (Suc (Suc 0)) \ 0" + by (metis MPoly_Type.degree_zero isolate_variable_sparse_degree_eq_zero_iff nat.distinct(1) numeral_2_eq_2) + have second : "(isolate_variable_sparse p var (Suc (Suc 0)) * Var var)\0" + by (metis MPoly_Type.degree_zero One_nat_def ExecutiblePolyProps.degree_one Zero_not_Suc first mult_eq_0_iff) + have other : "Const (2::real)\0" + by (simp add: nonzero_const_is_nonzero) + have thing: "(Var var::real mpoly) \ 0" + using second by auto + have degree: "MPoly_Type.degree + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var - + Suc 0 = 0" + apply simp apply(rule Nat.eq_imp_le) apply(rule degree_less_sum'[of _ _ 0]) + apply (simp add: degree_isovarspar mult_one_right) apply auto + unfolding degree_mult[OF second other, of var] degree_const apply simp + unfolding degree_mult[OF first thing] degree_one + using degree_isovarspar by force + have insertion: "insertion (nth_default 0 (xs'@x#xs)) (\(i::nat)\2. isolate_variable_sparse p var i * Var var ^ i) = a * x^2 + b * x + c" + proof(cases "MPoly_Type.degree p var = 1") + case True + then show ?thesis + using False by blast + next + case False + then have deg2 : "MPoly_Type.degree p var = 2" + by (metis One_nat_def assms(1) convert_poly.simps le_SucE less_Suc0 less_Suc_eq_le nonzero numeral_2_eq_2 numeral_3_eq_3 option.distinct(1)) + then have degless3 : "MPoly_Type.degree p var < 3" by auto + have thing : "vari\2. isolate_variable_sparse p var i * Var var ^ i) = p" + using deg2 + by (metis sum_over_zero) + have three: "(3::nat) = Suc(Suc(Suc(0)))" by auto + have "(\i = 0..<3. insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var i) * x ^ i) = + (insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) * x ^ 0) + + (insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (1::nat)) * x ^ (1::nat)) + + (insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (2::nat)) * x ^ (2::nat))" + unfolding Set_Interval.comm_monoid_add_class.sum.atLeast0_lessThan_Suc three + proof - + have "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (MPoly_Type.degree p var)) * x ^ MPoly_Type.degree p var + (x * insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 1) + (insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) + (\n = 0..<0. insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var n) * x ^ n))) = insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) + x * insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 1) + insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (MPoly_Type.degree p var)) * x ^ MPoly_Type.degree p var" + by auto + then show "(\n = 0..<0. insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var n) * x ^ n) + insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) * x ^ 0 + insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (Suc 0)) * x ^ Suc 0 + insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (Suc (Suc 0))) * x ^ Suc (Suc 0) = insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) * x ^ 0 + insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 1) * x ^ 1 + insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 2) * x\<^sup>2" + by (metis (no_types) One_nat_def Suc_1 add.commute deg2 mult.commute mult.left_neutral power_0 power_one_right) + qed + also have "... = a * x\<^sup>2 + b * x + c" + unfolding Power.power_class.power.power_0 Power.monoid_mult_class.power_one_right Groups.monoid_mult_class.mult_1_right + using assms unfolding convert_poly.simps using degless3 by simp + finally have h2 :"(\i = 0..<3. insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var i) * x ^ i) = a * x\<^sup>2 + b * x + c " + . + show ?thesis using sum_over_degree_insertion[OF thing deg2, of x] apply auto using h h2 using assms(2) by auto + qed + have insertionb: "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (Suc 0)) = b" + using assms apply(cases "MPoly_Type.degree p var < 3") by simp_all + have insertiona : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (Suc (Suc 0))) = a" + using assms apply(cases "MPoly_Type.degree p var < 3") apply simp_all + by (simp add: numeral_2_eq_2) + have x : "insertion (nth_default 0 (xs' @ x # xs)) (Var var) = x" using insertion_var[of var "(xs' @ x # xs)" x] using assms(2) by auto + have zero1 : "insertion (nth_default 0 (xs' @ x # xs)) + (isolate_variable_sparse (isolate_variable_sparse p var (Suc 0)) var (Suc 0)) = 0" + by (simp add: degree_isovarspar isovar_greater_degree) + have zero2 : "insertion (nth_default 0 (xs' @ x # xs)) + (isolate_variable_sparse (isolate_variable_sparse p var (Suc (Suc 0))) var 0) = a" + using degree0isovarspar degree_isovarspar insertiona by presburger + have zero3 : "insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse (Var var) var (Suc 0)) = 1" using isolate_var_one + using MPoly_Type.insertion_one by fastforce + have zero4 : "insertion (nth_default 0 (xs' @ x # xs)) + (isolate_variable_sparse (isolate_variable_sparse p var (Suc (Suc 0))) var (Suc 0)) = 0" + by (simp add: degree_isovarspar isovar_greater_degree) + have insertion_deriv : "insertion (nth_default 0 (xs'@x#xs)) + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0)) = 2*a" + unfolding isovarspar_sum isolate_variable_sparse_mult apply auto + unfolding const_lookup_suc const_lookup_zero Rings.mult_zero_class.mult_zero_right + Groups.group_add_class.add.group_left_neutral + unfolding insertion_add insertion_mult insertion_const apply auto + unfolding zero1 zero2 zero3 zero4 by simp + have deg2 : "MPoly_Type.degree p var = 2" using degree_convert_eq[OF assms(1)] False nonzero by auto + then show ?thesis + using assms + unfolding convertDerivative.simps[of _ p] convertDerivative.simps[of _ "(derivative var p)"] convertDerivative.simps[of _ "(derivative var (derivative var p))"] + apply (simp add: x insertionb insertiona insertion_deriv insertion degree derivative_def isovar_greater_degree eval_or eval_and insertion_add insertion_mult insertion_const HOL.arg_cong[OF sum_over_zero[of p var], of "insertion (nth_default 0 (xs'@x#xs))"] insertion_var_zero del:convertDerivative.simps) + by (smt (z3) One_nat_def degree_isovarspar distrib_right insertion_deriv isolate_variable_sparse_ne_zeroD mult_one_right neq0_conv not_one_le_zero zero1) + qed +qed + +fun linearSubstitutionUni :: "real \ real \ atomUni \ atomUni fmUni" where + "linearSubstitutionUni b c a = (if aEvalUni a (-c/b) then TrueFUni else FalseFUni)" + +lemma convert_linearSubstitutionUni: + assumes "convert_atom var a (xs'@x#xs) = Some(a')" + assumes "insertion (nth_default 0 (xs'@x#xs)) b = B" + assumes "insertion (nth_default 0 (xs'@x#xs)) c = C" + assumes "B \ 0" + assumes "var\(vars b)" + assumes "var\(vars c)" + assumes "length xs' = var" + shows "aEval (linear_substitution var (-c) b a) (xs'@x#xs) = evalUni (linearSubstitutionUni B C a') x" + using assms +proof - + have "aEval a (xs'@(-C/B)#xs) = evalUni (linearSubstitutionUni B C a') x" + using assms(1) proof(cases "a") + case (Less p) + then have "MPoly_Type.degree p var < 3" using assms(1)apply(cases "MPoly_Type.degree p var < 3") by auto + then show ?thesis + using Less assms apply simp + using poly_to_univar by force + next + case (Eq p) + then have "MPoly_Type.degree p var < 3" using assms(1)apply(cases "MPoly_Type.degree p var < 3") by auto + then show ?thesis + using Eq assms apply simp + using poly_to_univar by force + next + case (Leq p) + then have "MPoly_Type.degree p var < 3" using assms(1)apply(cases "MPoly_Type.degree p var < 3") by auto + then show ?thesis + using Leq assms apply simp + using poly_to_univar by force + next + case (Neq p) + then have "MPoly_Type.degree p var < 3" using assms(1)apply(cases "MPoly_Type.degree p var < 3") by auto + then show ?thesis + using Neq assms apply simp + using poly_to_univar by force + qed + then have subst : "aEval a ((xs'@x#xs)[var := - C / B]) = evalUni (linearSubstitutionUni B C a') x" using assms by auto + have hlength : "var< length (xs'@x#xs)" using assms by auto + have inB : "insertion (nth_default 0 ((xs'@x#xs)[var := - C / B])) b = B" using assms apply auto apply(cases a) apply auto + by (simp add: insertion_lowerPoly1)+ + have inC : "insertion (nth_default 0 ((xs'@x#xs)[var := - C / B])) (-c) = -C" using assms apply auto apply(cases a) apply auto + by (simp add: insertion_lowerPoly1 insertion_neg)+ + have freenegc : "var\vars(-c)" using assms not_in_neg by auto + show ?thesis using linear[OF hlength assms(4) freenegc assms(5) inC inB, of a ] subst + using var_not_in_eval3[OF var_not_in_linear[OF freenegc assms(5)] assms(7)] + by (metis assms(7) list_update_length) +qed + (* + substInfinitesimalLinear var b c A + substitutes -c/b+epsilon for variable var in atom A + assumes b is nonzero + defined in page 615 +*) +fun substInfinitesimalLinearUni :: "real \ real \ atomUni \ atomUni fmUni" where + "substInfinitesimalLinearUni b c (EqUni p) = allZero' p"| + "substInfinitesimalLinearUni b c (LessUni p) = + map_atomUni (linearSubstitutionUni b c) (convertDerivativeUni p)"| + "substInfinitesimalLinearUni b c (LeqUni p) = +OrUni + (allZero' p) + (map_atomUni (linearSubstitutionUni b c) (convertDerivativeUni p))"| + "substInfinitesimalLinearUni b c (NeqUni p) = negUni (allZero' p)" + + +lemma convert_linear_subst_fm : + assumes "convert_atom var a (xs'@x#xs) = Some a'" + assumes "insertion (nth_default 0 (xs'@x#xs)) b = B" + assumes "insertion (nth_default 0 (xs'@x#xs)) c = C" + assumes "B \ 0" + assumes "var\(vars b)" + assumes "var\(vars c)" + assumes "length xs' = var" + shows "aEval (linear_substitution (var + 0) (liftPoly 0 0 (-c)) (liftPoly 0 0 b) a) (xs'@x#xs) = + evalUni (linearSubstitutionUni B C a') x" +proof- + have lb : "insertion (nth_default 0 (xs'@x#xs)) (liftPoly 0 0 b) = B" unfolding lift00 using assms(2) by auto + have lc : "insertion (nth_default 0 (xs'@x#xs)) (liftPoly 0 0 c) = C" unfolding lift00 using assms(3) insertion_neg by auto + have nb : "var \ vars (liftPoly 0 0 b)" using not_in_lift[OF assms(5), of 0] by auto + have nc : "var \ vars (liftPoly 0 0 c)" using not_in_lift[OF assms(6)] not_in_neg + using assms(6) lift00 by auto + then show ?thesis using assms using lb lc convert_linearSubstitutionUni[OF assms(1) lb lc assms(4) nb nc] + by (simp add: lift00) +qed + +lemma evalUni_if : "evalUni (if cond then TrueFUni else FalseFUni) x = cond" + by(cases cond)(auto) + +lemma degree_less_sum' : "MPoly_Type.degree (p::real mpoly) var = n \ MPoly_Type.degree (q::real mpoly) var = m \ n < m \ MPoly_Type.degree (p + q) var = m" + using degree_less_sum[of q var m p n] + by (simp add: add.commute) + +lemma convert_substInfinitesimalLinear_less : + assumes "convert_poly var p (xs'@x#xs) = Some(p')" + assumes "insertion (nth_default 0 (xs'@x#xs)) b = B" + assumes "insertion (nth_default 0 (xs'@x#xs)) c = C" + assumes "B \ 0" + assumes "var\(vars b)" + assumes "var\(vars c)" + assumes "length xs' = var" + shows " +eval (liftmap + (\x. \A. Atom(linear_substitution (var+x) (liftPoly 0 x (-c)) (liftPoly 0 x b) A)) + (convertDerivative var p) + 0) (xs'@x#xs) = +evalUni (map_atomUni (linearSubstitutionUni B C) (convertDerivativeUni p')) x" +proof(cases p') + case (fields a' b' c') + have h : "convert_poly var p (xs'@x#xs) = Some (a', b', c')" + using assms fields by auto + have h2 : "\F'. convert_fm var (convertDerivative var p) xs = Some F'" + unfolding convertDerivative.simps[of _ p] convertDerivative.simps[of _ "derivative var p"] convertDerivative.simps[of _ "derivative var (derivative var p)"] + apply( auto simp del: convertDerivative.simps) + using degree_convert_eq h apply blast + using assms(1) degree_convert_eq apply blast + apply (metis Suc_eq_plus1 degree_derivative gr_implies_not0 less_trans_Suc nat_neq_iff) + using assms(1) degree_convert_eq apply blast + apply (meson assms(1) degree_convert_eq) + apply (metis One_nat_def Suc_eq_plus1 degree_derivative less_2_cases less_Suc_eq nat_neq_iff numeral_3_eq_3 one_add_one) + using assms(1) degree_convert_eq apply blast + using degree_derivative apply force + using assms(1) degree_convert_eq apply blast + apply (meson assms(1) degree_convert_eq) + apply (metis degree_derivative eq_numeral_Suc less_add_one less_trans_Suc not_less_eq numeral_2_eq_2 pred_numeral_simps(3)) + apply (meson assms(1) degree_convert_eq) + using degree_derivative apply fastforce + by (meson assms(1) degree_convert_eq) + have c'_insertion : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) = c'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") by auto + have b'_insertion : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (Suc 0)) = b'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") by auto + then have b'_insertion2 : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 1) = b'" + by auto + have a'_insertion : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 2) = a'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") by auto + have liftb : "liftPoly 0 0 b = b" using lift00 by auto + have liftc : "liftPoly 0 0 c = c" using lift00 by auto + have b'_insertion' : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse (isolate_variable_sparse p var (Suc 0)) var 0) = b'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") apply auto + by (simp add: degree0isovarspar degree_isovarspar) + have insertion_into_1 : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse (Const 1) var 0) = 1" + by (simp add: const_lookup_zero insertion_const) + have twominusone : "((2-1)::nat) = 1" by auto + show ?thesis + proof(cases "MPoly_Type.degree p var = 0") + case True + have simp: "(convertDerivative var p)=Atom(Less p)" + using True + by auto + have azero : "a'=0" + by (metis MPoly_Type.insertion_zero True a'_insertion isolate_variable_sparse_ne_zeroD nat.simps(3) not_less numeral_2_eq_2 zero_less_iff_neq_zero) + have bzero : "b'=0" + using True b'_insertion isovar_greater_degree by fastforce + show ?thesis unfolding fields substInfinitesimalLinearUni.simps + convertDerivativeUni.simps linearSubstitutionUni.simps map_atomUni.simps evalUni.simps evalUni_if aEvalUni.simps + Rings.mult_zero_class.mult_zero_left Rings.mult_zero_class.mult_zero_right Groups.add_0 azero bzero + substInfinitesimalLinear.simps convertDerivative.simps[of _ p] True simp liftmap.simps + linear_substitution.simps + apply (auto simp add:True) + unfolding c'_insertion by auto + next + case False + then have degnot0 : "MPoly_Type.degree p var \ 0" by auto + then show ?thesis + proof(cases "MPoly_Type.degree p var = 1") + case True + then have simp : "convertDerivative var p = Or (fm.Atom (Less p)) (And (fm.Atom (Eq p)) (fm.Atom (Less (derivative var p))))" + by (metis One_nat_def Suc_eq_plus1 add_right_imp_eq convertDerivative.simps degnot0 degree_derivative zero_less_one) + have azero : "a'=0" + by (metis MPoly_Type.insertion_zero One_nat_def True a'_insertion isovar_greater_degree lessI numeral_2_eq_2) + have degderiv : "MPoly_Type.degree (isolate_variable_sparse p var (Suc 0) * Const 1) var = 0" + using degree_mult + by (simp add: degree_isovarspar mult_one_right) + show ?thesis + unfolding fields substInfinitesimalLinearUni.simps + convertDerivativeUni.simps linearSubstitutionUni.simps map_atomUni.simps evalUni.simps evalUni_if aEvalUni.simps + Rings.mult_zero_class.mult_zero_left Rings.mult_zero_class.mult_zero_right Groups.add_0 azero + substInfinitesimalLinear.simps True simp liftmap.simps + linear_substitution.simps eval_Or eval_And liftb liftc + apply auto + unfolding derivative_def True insertion_sub insertion_mult c'_insertion b'_insertion assms lift00 apply auto + unfolding insertion_sub insertion_mult c'_insertion b'_insertion assms lift00 + apply (smt diff_divide_eq_iff divide_less_0_iff mult_less_0_iff) + apply (smt mult_imp_less_div_pos neg_less_divide_eq zero_le_mult_iff) + using assms(4) mult.commute nonzero_mult_div_cancel_left + apply smt + unfolding degderiv apply auto + unfolding isolate_variable_sparse_mult apply auto + unfolding insertion_mult defer + apply (smt assms(4) diff_divide_eq_iff divide_less_0_iff mult_less_0_iff) + defer + using assms(4) apply blast + unfolding b'_insertion' insertion_into_1 apply auto + by (smt assms(4) less_divide_eq mult_pos_neg2 no_zero_divisors zero_less_mult_pos) + next + case False + then have degreetwo : "MPoly_Type.degree p var = 2" using degnot0 + by (metis One_nat_def degree_convert_eq h less_2_cases less_Suc_eq numeral_2_eq_2 numeral_3_eq_3) + have two : "(2::nat) = Suc(Suc 0)" by auto + have sum : "(\i = 0..<2. isolate_variable_sparse p var i * (- c) ^ i * b ^ (2 - i)) = + isolate_variable_sparse p var 0 * (- c) ^ 0 * b ^ (2 - 0) + isolate_variable_sparse p var 1 * (- c) ^ 1 * b ^ (2 - 1) " + unfolding Set_Interval.comm_monoid_add_class.sum.atLeast0_lessThan_Suc two by auto + have a : "isolate_variable_sparse p var (Suc (Suc 0)) \ 0" + by (metis degnot0 degree_isovarspar degreetwo isolate_variable_sparse_degree_eq_zero_iff numeral_2_eq_2) + have b : "((Var var * Const 2) :: real mpoly) \ (0::real mpoly)" + by (metis MPoly_Type.degree_zero ExecutiblePolyProps.degree_one mult_eq_0_iff nonzero_const_is_nonzero zero_neq_numeral zero_neq_one) + have degreedeg1 : "MPoly_Type.degree + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var = 1" + apply(rule degree_less_sum'[where n ="0"]) + apply (simp add: degree_isovarspar mult_one_right) defer + apply simp + using degree_mult[OF a b, of var] + by (metis (no_types, hide_lams) ExecutiblePolyProps.degree_one add.left_neutral b degree_const degree_isovarspar degree_mult mult.commute mult_zero_class.mult_zero_right) + have simp : "(convertDerivative var p) = Or (fm.Atom (Less p)) + (And (fm.Atom (Eq p)) + (Or (fm.Atom (Less (derivative var p))) + (And (fm.Atom (Eq (derivative var p))) (fm.Atom (Less (derivative var (derivative var p)))))))" + using degreetwo + by (metis One_nat_def Suc_1 Suc_eq_plus1 add_diff_cancel_right' convertDerivative.simps degree_derivative neq0_conv zero_less_Suc) + have a : "insertion (nth_default 0 (xs'@x#xs)) + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var 0) = b'" unfolding isovarspar_sum isolate_variable_sparse_mult apply auto + unfolding const_lookup_suc const_lookup_zero Rings.mult_zero_class.mult_zero_right + Groups.group_add_class.add.group_left_neutral + by (simp add: b'_insertion' isolate_var_0 mult_one_right) + have b : "insertion (nth_default 0 (xs'@x#xs)) + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0)) = 2 * a'" + unfolding isovarspar_sum isolate_variable_sparse_mult apply auto + unfolding const_lookup_suc const_lookup_zero Rings.mult_zero_class.mult_zero_right + Groups.group_add_class.add.group_left_neutral + unfolding insertion_add insertion_mult insertion_const + by (metis MPoly_Type.insertion_one MPoly_Type.insertion_zero One_nat_def a'_insertion add.commute add.right_neutral degree0isovarspar degree_isovarspar isolate_var_one isovar_greater_degree mult.commute mult.right_neutral mult_zero_class.mult_zero_right numeral_2_eq_2 zero_less_one) + have simp_insertion_blob : "insertion (nth_default 0 (xs'@x#xs)) + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var 0 * + b - + isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0) * + c) = b' * B - 2 * a' * C" + unfolding insertion_sub insertion_mult assms a b by auto + have a : "isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0) \ 0" + by (metis MPoly_Type.degree_zero One_nat_def degreedeg1 isolate_variable_sparse_degree_eq_zero_iff zero_neq_one) + have b' : "(Const 1::real mpoly) \ 0" + by (simp add: nonzero_const_is_nonzero) + have degreeblob : "MPoly_Type.degree + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0) * + Const 1) + var = 0" + unfolding degree_mult[OF a b', of var] + by (simp add: degree_isovarspar degree_eq_iff monomials_Const) + have otherblob : "insertion (nth_default 0 (xs'@x#xs)) + (isolate_variable_sparse + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0) * + Const 1) + var 0) = 2 * a'" using b + by (simp add: degree0isovarspar degree_isovarspar mult_one_right) + + have "(c' * B\<^sup>2 - b' * C * B + a' * C\<^sup>2 < 0) = ((c' * B\<^sup>2 - b' * C * B + a' * C\<^sup>2)/(B\<^sup>2) < 0)" + by (simp add: assms(4) divide_less_0_iff) + also have "... = (((c' * B\<^sup>2)/(B\<^sup>2) - (b' * C * B)/(B\<^sup>2) + (a' * C\<^sup>2)/(B\<^sup>2)) < 0)" + by (metis (no_types, lifting) add_divide_distrib diff_divide_distrib ) + also have "... = (a' * (C / B)\<^sup>2 - b' * C / B + c' < 0)" + proof - + { assume "c' + a' * (C / B)\<^sup>2 - b' * (C / B) < 0" + then have ?thesis + by (simp add: assms(4) power2_eq_square) } + moreover + { assume "\ c' + a' * (C / B)\<^sup>2 - b' * (C / B) < 0" + then have ?thesis + by (simp add: power2_eq_square) } + ultimately show ?thesis + by fastforce + qed + finally have h1: "(c' * B\<^sup>2 - b' * C * B + a' * C\<^sup>2 < 0) = (a' * (C / B)\<^sup>2 - b' * C / B + c' < 0)" + . + have "(c' * B\<^sup>2 - b' * C * B + a' * C\<^sup>2 = 0) = ((c' * B\<^sup>2 - b' * C * B + a' * C\<^sup>2)/(B\<^sup>2) = 0)" + by (simp add: assms(4)) + also have "... = (((c' * B\<^sup>2)/(B\<^sup>2) - (b' * C * B)/(B\<^sup>2) + (a' * C\<^sup>2)/(B\<^sup>2)) = 0)" + by (metis (no_types, lifting) add_divide_distrib diff_divide_distrib ) + also have "... = (a' * (C / B)\<^sup>2 - b' * C / B + c' = 0)" + proof - + { assume "c' + a' * (C * (C / (B * B))) - b' * (C / B) \ 0" + then have ?thesis + by (simp add: assms(4) power2_eq_square) } + moreover + { assume "c' + a' * (C * (C / (B * B))) - b' * (C / B) = 0" + then have ?thesis + by (simp add: power2_eq_square) } + ultimately show ?thesis + by fastforce + qed + finally have h2 : "(c' * B\<^sup>2 - b' * C * B + a' * C\<^sup>2 = 0) = (a' * (C / B)\<^sup>2 - b' * C / B + c' = 0)" + . + have h3 : "((b' * B - 2 * a' * C) * B < 0) = (b' < 2 * a' * C / B)" + by (smt assms(4) less_divide_eq zero_le_mult_iff) + have h4 : "(b' * B = 2 * a' * C) = (b' = 2 * a' * C / B)" + by (simp add: assms(4) nonzero_eq_divide_eq) + show ?thesis unfolding fields substInfinitesimalLinearUni.simps + convertDerivativeUni.simps linearSubstitutionUni.simps map_atomUni.simps evalUni.simps evalUni_if aEvalUni.simps + Rings.mult_zero_class.mult_zero_left Rings.mult_zero_class.mult_zero_right Groups.add_0 + substInfinitesimalLinear.simps degreetwo simp liftmap.simps + linear_substitution.simps eval_Or eval_And liftb liftc + apply simp + unfolding derivative_def degreetwo insertion_sub insertion_mult c'_insertion b'_insertion assms apply simp + unfolding sum insertion_add insertion_mult insertion_pow insertion_neg assms + unfolding b'_insertion2 c'_insertion a'_insertion + unfolding Power.power_class.power.power_0 Groups.monoid_mult_class.mult_1_right + Groups.cancel_comm_monoid_add_class.diff_zero Power.monoid_mult_class.power_one_right + twominusone degreedeg1 apply simp + unfolding insertion_mult assms simp_insertion_blob degreeblob + unfolding insertion_mult insertion_sub assms otherblob apply simp + unfolding otherblob h1 h2 h3 h4 unfolding lift00 insertion_neg assms insertion_isovarspars_free insertion_sum insertion_mult insertion_sub degree0isovarspar degree_isovarspar mult_one_right insertion_sum_var insertion_pow insertion_neg sum + unfolding assms b'_insertion c'_insertion a'_insertion insertion_neg insertion_mult insertion_add insertion_pow apply simp + by (smt assms(2) assms(3) b'_insertion h1 h2 h3 h4 insertion_mult insertion_sub mult_one_right simp_insertion_blob) + qed + qed +qed +lemma convert_substInfinitesimalLinear: + assumes "convert_atom var a (xs'@x#xs) = Some(a')" + assumes "insertion (nth_default 0 (xs'@x#xs)) b = B" + assumes "insertion (nth_default 0 (xs'@x#xs)) c = C" + assumes "B \ 0" + assumes "var\(vars b)" + assumes "var\(vars c)" + assumes "length xs' = var" + shows "eval (substInfinitesimalLinear var (-c) b a) (xs'@x#xs) = evalUni (substInfinitesimalLinearUni B C a') x" + using assms +proof(cases a) + case (Less p) + have "\p'. convert_poly var p (xs'@x#xs) = Some p'" + using Less assms(1) apply(cases "MPoly_Type.degree p var < 3") by auto + then obtain p' where p'_def : "convert_poly var p (xs'@x#xs) = Some p'" by auto + have A'_simp : "a' = LessUni p'" + using assms Less + using p'_def by auto + have h1 : "eval (convertDerivative var p) (xs'@x#xs) = evalUni (convertDerivativeUni p') x" using convert_convertDerivative + apply ( cases p') + using A'_simp Less assms by auto + show ?thesis unfolding A'_simp using convert_substInfinitesimalLinear_less[OF p'_def assms(2-7)] unfolding Less by auto +next + case (Eq p) + define p' where "p' = (case convert_poly var p (xs'@x#xs) of Some p' \ p')" + have A'_simp : "a' = EqUni p'" + using assms Eq + using p'_def by auto + show ?thesis + unfolding Eq A'_simp substInfinitesimalLinear.simps substInfinitesimalLinearUni.simps + using convert_allZero A'_simp Eq assms by auto +next + case (Leq p) + have "\p'. convert_poly var p (xs' @ x # xs) = Some p'" + using assms(1) unfolding Leq apply auto apply(cases "MPoly_Type.degree p var < 3") by auto + then obtain p' where p'_def : "convert_poly var p (xs' @ x # xs) = Some p'" by metis + have A'_simp : "a' = LeqUni p'" + using assms Leq + using p'_def by auto + have h1 : "eval (convertDerivative var p) (xs'@x#xs) = evalUni (convertDerivativeUni p') x" using convert_convertDerivative + apply(cases p') + using A'_simp Leq assms by auto + show ?thesis unfolding A'_simp Leq substInfinitesimalLinear.simps eval_Or substInfinitesimalLinearUni.simps evalUni.simps + using convert_substInfinitesimalLinear_less[OF p'_def assms(2-7)] + convert_allZero[OF p'_def assms(7)] by simp +next + case (Neq p) + have "\p'. convert_poly var p (xs' @ x # xs) = Some p'" + using assms(1) unfolding Neq apply auto apply(cases "MPoly_Type.degree p var < 3") by auto + then obtain p' where p'_def : "convert_poly var p (xs' @ x # xs) = Some p'" by metis + have A'_simp : "a' = NeqUni p'" + using assms Neq + using p'_def by auto + show ?thesis + unfolding Neq A'_simp substInfinitesimalLinear.simps substInfinitesimalLinearUni.simps + using convert_allZero[OF p'_def assms(7)] + by (metis A'_simp Neq assms(1) assms(7) convert_substNegInfinity eval.simps(6) eval_neg substNegInfinityUni.simps(4) substNegInfinity.simps(4)) +qed + + +lemma either_or: + fixes r :: "real" + assumes a: "(\y'>r. \x\{r<..y'}. (aEvalUni (EqUni (a, b, c)) x) \ (aEvalUni (LessUni (a, b, c)) x))" + shows "(\y'>r. \x\{r<..y'}. (aEvalUni (EqUni (a, b, c)) x)) \ + (\y'>r. \x\{r<..y'}. (aEvalUni (LessUni (a, b, c)) x))" +proof (cases "a = 0 \ b = 0 \ c= 0") + case True + then have "(\y'>r. \x\{r<..y'}. (aEvalUni (EqUni (a, b, c)) x))" + using assms by auto + then show ?thesis + by blast +next + case False + then have noz: "a\0 \ b\0 \ c\0" by auto + obtain y1' where y1prop: "y1' > r \ (\x\{r<..y1'}. (aEvalUni (EqUni (a, b, c)) x) \ (aEvalUni (LessUni (a, b, c)) x))" + using a by auto + obtain y2' where y2prop: "y2' > r \ (\x\{r<..y2'}. a * x\<^sup>2 + b * x + c \ 0)" + using noz nonzcoeffs[of a b c] by auto + let ?y = "min y1' y2'" + have ygt: "?y > r" using y1prop y2prop by auto + have "\x\{r<..?y}. (aEvalUni (LessUni (a, b, c)) x)" + using y1prop y2prop greaterThanAtMost_iff + by force + then show ?thesis using ygt + by blast +qed + +lemma infinitesimal_linear'_helper : + assumes at_is: "At = LessUni p \ At = EqUni p" + assumes "B \ 0" + shows "((\y'::real>-C/B. \x::real \{-C/B<..y'}. aEvalUni At x) + = evalUni (substInfinitesimalLinearUni B C At) x)" +proof (cases "At = LessUni p") + case True + then have LessUni: "At = LessUni p" by auto + then show ?thesis proof(cases p) + case (fields a b c) + then show ?thesis + unfolding LessUni fields + using one_root_a_lt0[where r="C/B", where a= "a", where b="b",where c= "c"] apply(auto) + using continuity_lem_lt0_expanded[where a= "a", where b = "2 * a * C / B ", where c = "c"] apply (auto) + using continuity_lem_gt0_expanded[where a = "a", where b = "2 * a * C / B",where c = "c", where r = "- (C / B)"] apply (auto) + apply (meson less_eq_real_def linorder_not_less) + using one_root_a_gt0[where r = "C/B", where a = "a", where b="b", where c="c"] apply (auto) + using continuity_lem_lt0_expanded[where a= "a", where b = "2 * a * C / B", where c= "c"] + apply (auto) + using continuity_lem_gt0_expanded[where a = "a", where b = "2 * a * C / B",where c = "c", where r = "- (C / B)"] + apply (auto) apply (meson less_eq_real_def linorder_not_less) + using case_d1 apply (auto) + using continuity_lem_lt0_expanded[where a= "a", where b = "b", where c= "c"] + apply (auto) + using continuity_lem_gt0_expanded[where a = "a", where b = "b",where c = "c", where r = "- (C / B)"] + apply (auto) apply (meson less_eq_real_def linorder_not_less) + using case_d4 apply (auto) + using continuity_lem_lt0_expanded[where a= "a", where b = "b", where c= "c"] + apply (auto) + using continuity_lem_gt0_expanded[where a = "a", where b = "b",where c = "c", where r = "- (C / B)"] + apply (auto) + by (meson less_eq_real_def linorder_not_le) + qed +next + case False + then have EqUni: "At = EqUni p" using at_is by auto + then show ?thesis proof(cases p) + case (fields a b c) + show ?thesis + apply(auto simp add:EqUni fields) + using continuity_lem_eq0[where r= "-(C/B)"] apply blast + using continuity_lem_eq0[where r= "-(C/B)"] apply blast + using continuity_lem_eq0[where r= "-(C/B)"] apply blast + using linordered_field_no_ub by blast + qed +qed + +(* I assume substInfinitesimalLinearUni' was supposed to be substInfinitesimalLinearUni?*) +lemma infinitesimal_linear' : + assumes "B \ 0" + shows "(\y'::real>-C/B. \x::real \{-C/B<..y'}. aEvalUni At x) + = evalUni (substInfinitesimalLinearUni B C At) x" +proof(cases At) + case (LessUni p) + then show ?thesis using infinitesimal_linear'_helper[of At p B C] assms by auto +next + case (EqUni p) + then show ?thesis using infinitesimal_linear'_helper[of At p B C] assms by (auto) +next + case (LeqUni p) + then show ?thesis proof(cases p) + case (fields a b c) + have same: "\x. aEvalUni (LeqUni p) x = (aEvalUni (EqUni p) x) \ (aEvalUni (LessUni p) x)" + apply (simp add: fields) + by force + have "\a b c. + At = LeqUni p \ + p = (a, b, c) \ + (\y'>- C / B. \x\{- C / B<..y'}. aEvalUni At x) = + evalUni (substInfinitesimalLinearUni B C At) x " + proof - + fix a b c + assume atis: "At = LeqUni p" + assume p_is: " p = (a, b, c)" + have s1: "(\y'>- C / B. \x\{- C / B<..y'}. aEvalUni At x) = (\y'>- C / B. \x\{- C / B<..y'}. (aEvalUni (EqUni p) x) \ (aEvalUni (LessUni p) x))" + using atis same aEvalUni.simps(2) aEvalUni.simps(3) fields less_eq_real_def + by blast + have s2: "... = (\y'>- C / B. \x\{- C / B<..y'}. (aEvalUni (EqUni p) x)) \ (\y'>- C / B. \x\{- C / B<..y'}. (aEvalUni (LessUni p) x))" + using either_or[where r = "-C/B"] p_is + by blast + have eq1: "(\y'>- C / B. \x\{- C / B<..y'}. (aEvalUni (EqUni p) x)) = (evalUni (substInfinitesimalLinearUni B C (EqUni p)) x)" + using infinitesimal_linear'_helper[where At = "EqUni p", where p = "p", where B = "B", where C= "C"] + assms by auto + have eq2: "(\y'>- C / B. \x\{- C / B<..y'}. (aEvalUni (LessUni p) x)) = (evalUni (substInfinitesimalLinearUni B C (LessUni p)) x)" + using infinitesimal_linear'_helper[where At = "LessUni p", where p = "p", where B = "B", where C= "C"] + assms by auto + have z1: "(\y'>- C / B. \x\{- C / B<..y'}. aEvalUni At x) = ((evalUni (substInfinitesimalLinearUni B C (EqUni p)) x) \ (evalUni (substInfinitesimalLinearUni B C (LessUni p)) x))" + using s1 s2 eq1 eq2 by auto + have z2: "(evalUni (substInfinitesimalLinearUni B C (EqUni p)) x) \ (evalUni (substInfinitesimalLinearUni B C (LessUni p)) x) = evalUni (substInfinitesimalLinearUni B C (LeqUni p)) x" + by auto + have z3: "(evalUni (substInfinitesimalLinearUni B C At) x) = evalUni (substInfinitesimalLinearUni B C (LeqUni p)) x" + using LeqUni by auto + then have z4: "(evalUni (substInfinitesimalLinearUni B C (EqUni p)) x) \ (evalUni (substInfinitesimalLinearUni B C (LessUni p)) x) = (evalUni (substInfinitesimalLinearUni B C At) x) " + using z2 z3 by auto + let ?a = "(evalUni (substInfinitesimalLinearUni B C (EqUni p)) x) \ (evalUni (substInfinitesimalLinearUni B C (LessUni p)) x)" + let ?b = "(\y'>- C / B. \x\{- C / B<..y'}. aEvalUni At x)" + let ?c = "(evalUni (substInfinitesimalLinearUni B C At) x)" + have t1: "?b = ?a" using z1 by auto + have t2: "?a = ?c" using z4 + by (simp add: atis) + then have "?b = ?c" using t1 t2 by auto + then show "(\y'>- C / B. \x\{- C / B<..y'}. aEvalUni At x) = evalUni (substInfinitesimalLinearUni B C At) x" + by auto + qed + then show ?thesis + using LeqUni fields by blast + qed +next + case (NeqUni p) + then show ?thesis proof(cases p) + case (fields a b c) + then show ?thesis unfolding NeqUni fields using nonzcoeffs by (auto) + qed +qed + +fun quadraticSubUni :: "real \ real \ real \ real \ atomUni \ atomUni fmUni" where + "quadraticSubUni a b c d A = (if aEvalUni A ((a+b*sqrt(c))/d) then TrueFUni else FalseFUni)" + +fun substInfinitesimalQuadraticUni :: "real \ real \ real \ real \ atomUni \ atomUni fmUni" where + "substInfinitesimalQuadraticUni a b c d (EqUni p) = allZero' p"| + "substInfinitesimalQuadraticUni a b c d (LessUni p) = map_atomUni (quadraticSubUni a b c d) (convertDerivativeUni p)"| + "substInfinitesimalQuadraticUni a b c d (LeqUni p) = OrUni(map_atomUni (quadraticSubUni a b c d) (convertDerivativeUni p)) (allZero' p)"| + "substInfinitesimalQuadraticUni a b c d (NeqUni p) = negUni (allZero' p)" + + +lemma weird : + fixes D::"real" + assumes dneq: "D \ (0::real)" + shows + "((a'::real) * (((A::real) + (B::real) * sqrt (C::real)) / (D::real))\<^sup>2 + (b'::real) * (A + B * sqrt C) / D + c' < 0 \ + a' * ((A + B * sqrt C) / D)\<^sup>2 + b' * (A + B * sqrt C) / D + (c'::real) = 0 \ + (b' + a' * (A + B * sqrt C) * 2 / D < 0 \ + b' + a' * (A + B * sqrt C) * 2 / D = 0 \ 2 * a' < 0)) = + (a' * ((A + B * sqrt C) / D)\<^sup>2 + b' * (A + B * sqrt C) / D + c' < 0 \ + a' * ((A + B * sqrt C) / D)\<^sup>2 + b' * (A + B * sqrt C) / D + c' = 0 \ + (2 * a' * (A + B * sqrt C) / D + b' < 0 \ + 2 * a' * (A + B * sqrt C) / D + b' = 0 \ a' < 0))" +proof (cases "(a' * ((A + B * sqrt C) / D)\<^sup>2 + b' * (A + B * sqrt C) / D + c' < 0)") + case True + then show ?thesis + by auto +next + case False + have "a' * (A + B * sqrt C) * 2 = 2 * a' * (A + B * sqrt C)" by auto + then have "a' * (A + B * sqrt C) * 2 / D =2 * a' * (A + B * sqrt C) / D " + using dneq by simp + then have "b' + a' * (A + B * sqrt C) * 2 / D = 2 * a' * (A + B * sqrt C) / D + b'" + using add.commute by simp + then have "(b' + a' * (A + B * sqrt C) * 2 / D < 0 \ b' + a' * (A + B * sqrt C) * 2 / D = 0 \ a' < 0) + = (2 * a' * (A + B * sqrt C) / D + b' < 0 \ 2 * a' * (A + B * sqrt C) / D + b' = 0 \ a' < 0)" + by (simp add: \b' + a' * (A + B * sqrt C) * 2 / D = 2 * a' * (A + B * sqrt C) / D + b'\) + then have "(a' * ((A + B * sqrt C) / D)\<^sup>2 + b' * (A + B * sqrt C) / D + c' = 0 \ + (b' + a' * (A + B * sqrt C) * 2 / D < 0 \ b' + a' * (A + B * sqrt C) * 2 / D = 0 \ a' < 0)) = + (a' * ((A + B * sqrt C) / D)\<^sup>2 + b' * (A + B * sqrt C) / D + c' = 0 \ + (2 * a' * (A + B * sqrt C) / D + b' < 0 \ 2 * a' * (A + B * sqrt C) / D + b' = 0 \ a' < 0))" + by blast + then show ?thesis using False by simp +qed + +lemma convert_substInfinitesimalQuadratic_less : + assumes "convert_poly var p (xs'@x#xs) = Some p'" + assumes "insertion (nth_default 0 (xs'@x#xs)) a = A" + assumes "insertion (nth_default 0 (xs'@x#xs)) b = B" + assumes "insertion (nth_default 0 (xs'@x#xs)) c = C" + assumes "insertion (nth_default 0 (xs'@x#xs)) d = D" + assumes "D \ 0" + assumes "0 \ C" + assumes "var\(vars a)" + assumes "var\(vars b)" + assumes "var\(vars c)" + assumes "var\(vars d)" + assumes "length xs' = var" + shows "eval (quadratic_sub_fm var a b c d (convertDerivative var p)) (xs'@x#xs) = evalUni (map_atomUni (quadraticSubUni A B C D) (convertDerivativeUni p')) x" +proof(cases p') + case (fields a' b' c') + have h : "convert_poly var p (xs'@x#xs) = Some (a', b', c')" + using assms fields by auto + have h2 : "\F'. convert_fm var (convertDerivative var p) (xs'@x#xs) = Some F'" + unfolding convertDerivative.simps[of _ p] convertDerivative.simps[of _ "derivative var p"] convertDerivative.simps[of _ "derivative var (derivative var p)"] + apply (auto simp del: convertDerivative.simps) + using degree_convert_eq h apply blast + using assms(1) degree_convert_eq apply blast + using degree_derivative apply fastforce + apply (metis degree_convert_eq h numeral_3_eq_3 ) + apply (metis (no_types, lifting) One_nat_def add.right_neutral add_Suc_right degree_derivative less_Suc_eq_0_disj less_Suc_eq_le neq0_conv numeral_3_eq_3) + apply (metis One_nat_def Suc_eq_plus1 degree_derivative less_2_cases less_Suc_eq nat_neq_iff numeral_3_eq_3 one_add_one) + apply (meson assms(1) degree_convert_eq) + using degree_derivative apply fastforce + using assms(1) degree_convert_eq apply blast + apply (meson assms(1) degree_convert_eq) + apply (metis degree_derivative less_Suc_eq less_add_one not_less_eq numeral_3_eq_3) + apply (meson assms(1) degree_convert_eq) + apply (metis (no_types, hide_lams) Suc_1 Suc_eq_plus1 degree_derivative less_2_cases less_Suc_eq numeral_3_eq_3) + using assms(1) degree_convert_eq by blast + have c'_insertion : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 0) = c'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") by auto + then have c'_insertion'' : "\x. insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 0) = c'" + using assms(12) not_in_isovarspar[of p var 0 "isolate_variable_sparse p var 0", OF HOL.refl] + by (metis list_update_length not_contains_insertion) + have b'_insertion : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var (Suc 0)) = b'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") by auto + then have b'_insertion'' : "\x. insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var (Suc 0)) = b'" + using assms(12) not_in_isovarspar[of p var "Suc 0" "isolate_variable_sparse p var (Suc 0)", OF HOL.refl] + by (metis list_update_length not_contains_insertion) + then have b'_insertion2 : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 1) = b'" + by auto + have a'_insertion : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse p var 2) = a'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") by auto + then have a'_insertion'' : "\x. insertion (nth_default 0 (xs' @ x # xs)) (isolate_variable_sparse p var 2) = a'" + using assms(12) not_in_isovarspar[of p var 2 "isolate_variable_sparse p var 2", OF HOL.refl] + by (metis list_update_length not_contains_insertion) + have liftb : "liftPoly 0 0 b = b" using lift00 by auto + have liftc : "liftPoly 0 0 c = c" using lift00 by auto + have b'_insertion' : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse (isolate_variable_sparse p var (Suc 0)) var 0) = b'" + using assms fields unfolding convert_poly.simps apply(cases "MPoly_Type.degree p var < 3") apply auto + using degree0isovarspar degree_isovarspar by auto + have insertion_into_1 : "insertion (nth_default 0 (xs'@x#xs)) (isolate_variable_sparse (Const 1) var 0) = 1" + by (simp add: const_lookup_zero insertion_const) + have twominusone : "((2-1)::nat) = 1" by auto + have length0 : "var < length (xs'@x#xs)" using assms by auto + have altinserta : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) a = A" + using assms by (metis list_update_length not_contains_insertion) + have altinserta' : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) a = A" + using assms by (metis list_update_length not_contains_insertion) + have altinsertb : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) b = B" + using assms by (metis list_update_length not_contains_insertion) + have altinsertb' : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) b = B" + using assms by (metis list_update_length not_contains_insertion) + have altinsertc : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) c = C" + using assms by (metis list_update_length not_contains_insertion) + have altinsertc' : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) c = C" + using assms by (metis list_update_length not_contains_insertion) + have altinsertd : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) d = D" + using assms by (metis list_update_length not_contains_insertion) + have altinsertd' : "\xa. insertion (nth_default 0 ((xs'@x#xs)[var := xa])) d = D" + using assms by (metis list_update_length not_contains_insertion) + have freeInQuadraticSub : "\At. eval (quadratic_sub var a b c d At) ((xs'@x#xs)[var := sqrt C]) = eval (quadratic_sub var a b c d At) ((xs'@x#xs))" + by (metis assms(10) assms(11) assms(8) assms(9) free_in_quad list_update_id var_not_in_eval) + have quad : "\At. (eval (quadratic_sub var a b c d At) (xs'@x#xs) = + aEval At ((xs'@x#xs)[var := (A + B * sqrt C) / D]))" + using quadratic_sub[OF length0 assms(6-7) assms(10) altinserta altinsertb altinsertc altinsertd, symmetric] + using freeInQuadraticSub by auto + show ?thesis + proof(cases "MPoly_Type.degree p var = 0") + case True + then have simp: "(convertDerivative var p)=Atom(Less p)" + by auto + have azero : "a'=0" + by (metis MPoly_Type.insertion_zero True a'_insertion isolate_variable_sparse_ne_zeroD nat.simps(3) not_less numeral_2_eq_2 zero_less_iff_neq_zero) + have bzero : "b'=0" + using True b'_insertion isovar_greater_degree by fastforce + define p1 where "p1 = isolate_variable_sparse p var 0" + have degree_p1: "MPoly_Type.degree p1 var = 0" unfolding p1_def + by (simp add: degree_isovarspar) + define p2 where "p2 = isolate_variable_sparse p1 var 0 * Const 0 * Var var + isolate_variable_sparse p1 var 0 * Const 1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var (Suc 0)" + show ?thesis + unfolding substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps + fields + convertDerivativeUni.simps map_atomUni.simps quadraticSubUni.simps aEvalUni.simps evalUni.simps evalUni_if + Rings.mult_zero_class.mult_zero_left Groups.add_0 Rings.mult_zero_class.mult_zero_right + True simp azero bzero + quadratic_sub_fm.simps quadratic_sub_fm_helper.simps liftmap.simps lift00 + quad aEval.simps + apply (simp add:True c'_insertion p1_def[symmetric] degree_p1 p2_def[symmetric] A_def[symmetric] B_def[symmetric]) + unfolding A_def B_def p2_def p1_def degree0isovarspar[OF True] isovarspar_sum mult_one_right mult_zero_right mult_zero_left const_lookup_zero const_lookup_suc + apply simp + unfolding insertion_add insertion_sub insertion_mult insertion_pow insertion_const c'_insertion apply simp + using \isolate_variable_sparse p var 0 = p\ b'_insertion2 bzero c'_insertion by force + next + case False + then have degreenonzero : "MPoly_Type.degree p var \0" by auto + show ?thesis + proof(cases "MPoly_Type.degree p var = 1") + case True + then have simp : "convertDerivative var p = Or (fm.Atom (Less p)) (And (fm.Atom (Eq p)) (fm.Atom (Less (derivative var p))))" + by (metis One_nat_def Suc_eq_plus1 add_right_imp_eq convertDerivative.simps degree_derivative degreenonzero less_numeral_extra(1)) + have azero : "a'=0" + by (metis MPoly_Type.insertion_zero One_nat_def True a'_insertion isovar_greater_degree lessI numeral_2_eq_2) + have degderiv : "MPoly_Type.degree (isolate_variable_sparse p var (Suc 0) * Const 1) var = 0" + using degree_mult + by (simp add: degree_isovarspar mult_one_right) + have thing : "var2 + b' * (A + B * sqrt C) / D + c'" + using sum_over_degree_insertion[OF insertionp degree2, of "(A + B * sqrt C) / D", symmetric] unfolding + a'_insertion[symmetric] b'_insertion[symmetric] c'_insertion[symmetric] + insertion_isovarspars_free[of _ _ "(A + B * sqrt C) / D" _ _ x] + unfolding two apply simp + using assms(12) by force + have insertion_simp : "insertion (nth_default 0 ((xs' @ x # xs)[var := (A + B * sqrt C) / D])) = insertion (nth_default 0 ((xs' @ ((A + B * sqrt C) / D) # xs)))" + using assms + by (metis list_update_length) + have degreeone : "MPoly_Type.degree + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var = 1" + apply(rule degree_less_sum'[where n=0]) + apply (simp add: degree_isovarspar mult_one_right) + apply (smt One_nat_def ExecutiblePolyProps.degree_one degree2 degree_const degree_isovarspar degree_mult degreenonzero isolate_variable_sparse_degree_eq_zero_iff mult.commute nonzero_const_is_nonzero numeral_2_eq_2 plus_1_eq_Suc) + by simp + have zero1 : " insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) + (isolate_variable_sparse (isolate_variable_sparse p var (Suc 0)) var (Suc 0)) = 0" + by (simp add: degree_isovarspar isovar_greater_degree) + have zero2 : "insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) + (isolate_variable_sparse (isolate_variable_sparse p var (Suc (Suc 0))) var 0) = a'" + using a'_insertion'' degree0isovarspar degree_isovarspar numeral_2_eq_2 by force + have zero3 : "insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) (isolate_variable_sparse (Var var) var (Suc 0)) = 1" + using isolate_var_one by fastforce + have zero4 : "insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) + (isolate_variable_sparse (isolate_variable_sparse p var (Suc (Suc 0))) var (Suc 0)) = 0" + by (simp add: degree_isovarspar isovar_greater_degree) + have insertiona' : " insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) + (isolate_variable_sparse + (isolate_variable_sparse p var (Suc 0) * Const 1 + + isolate_variable_sparse p var (Suc (Suc 0)) * Var var * Const 2) + var (Suc 0) * + Const 1) = 2 * a'" + unfolding isovarspar_sum isolate_variable_sparse_mult apply auto + unfolding const_lookup_suc const_lookup_zero Rings.mult_zero_class.mult_zero_right + Groups.group_add_class.add.group_left_neutral + unfolding insertion_add insertion_mult insertion_const b'_insertion' apply auto + unfolding zero1 zero2 zero3 zero4 by auto + have a' : "insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) (isolate_variable_sparse p var (Suc (Suc 0))) = a'" + unfolding two[symmetric] unfolding a'_insertion'' by auto + have var: "insertion (nth_default 0 (xs' @ (A + B * sqrt C) / D # xs)) (Var var) = (A + B * sqrt C) / D" using assms + by (metis insertion_simp insertion_var length0) + show ?thesis + unfolding substInfinitesimalQuadratic.simps substInfinitesimalQuadraticUni.simps + fields + convertDerivativeUni.simps map_atomUni.simps quadraticSubUni.simps aEvalUni.simps evalUni.simps evalUni_if + Rings.mult_zero_class.mult_zero_left Groups.add_0 Rings.mult_zero_class.mult_zero_right + degree2 simp + quadratic_sub_fm.simps quadratic_sub_fm_helper.simps liftmap.simps lift00 Groups.monoid_add_class.add_0_right + quad aEval.simps eval.simps derivative_def apply (simp add:insertion_sum insertion_add insertion_mult insertion_const insertion_var_zero) + unfolding insertionp + unfolding insertion_simp + unfolding b'_insertion'' a'_insertion'' + unfolding + degreeone apply simp + unfolding a' var + unfolding insertiona' + using weird[OF assms(6)] by auto + qed + qed +qed + +lemma convert_substInfinitesimalQuadratic: + assumes "convert_atom var At (xs'@ x#xs) = Some(At')" + assumes "insertion (nth_default 0 (xs'@ x#xs)) a = A" + assumes "insertion (nth_default 0 (xs'@ x#xs)) b = B" + assumes "insertion (nth_default 0 (xs'@ x#xs)) c = C" + assumes "insertion (nth_default 0 (xs'@ x#xs)) d = D" + assumes "D \ 0" + assumes "0 \ C" + assumes "var\(vars a)" + assumes "var\(vars b)" + assumes "var\(vars c)" + assumes "var\(vars d)" + assumes "length xs' = var" + shows "eval (substInfinitesimalQuadratic var a b c d At) (xs'@ x#xs) = evalUni (substInfinitesimalQuadraticUni A B C D At') x" + using assms +proof(cases At) + case (Less p) + define p' where "p' = (case convert_poly var p (xs'@ x#xs) of Some p' \ p')" + have At'_simp : "At' = LessUni p'" + using assms Less + using p'_def by auto + show ?thesis + using convert_substInfinitesimalQuadratic_less[OF _ assms(2-12)] + by (metis At'_simp Less None_eq_map_option_iff assms(1) convert_atom.simps(1) option.distinct(1) option.exhaust_sel option.the_def p'_def substInfinitesimalQuadraticUni.simps(2) substInfinitesimalQuadratic.simps(2)) +next + case (Eq p) + define p' where "p' = (case convert_poly var p (xs'@ x#xs) of Some p' \ p')" + have At'_simp : "At' = EqUni p'" + using assms Eq + using p'_def by auto + show ?thesis + unfolding At'_simp Eq substInfinitesimalQuadraticUni.simps substInfinitesimalQuadratic.simps + using At'_simp Eq assms(1) convert_substNegInfinity assms(12) by fastforce +next + case (Leq p) + define p' where "p' = (case convert_poly var p (xs'@ x#xs) of Some p' \ p')" + have At'_simp : "At' = LeqUni p'" + using assms Leq + using p'_def by auto + have allzero : "eval (allZero p var) (xs'@ x#xs) = evalUni (allZero' p') x" + using Leq assms(1) convert_allZero p'_def assms(12) by force + have less : "eval (quadratic_sub_fm var a b c d (convertDerivative var p)) (xs'@ x#xs) = evalUni (map_atomUni (quadraticSubUni A B C D) (convertDerivativeUni p')) x" + using convert_substInfinitesimalQuadratic_less[OF _ assms(2-12)] + by (metis Leq assms(1) convert_atom.simps(3) option.distinct(1) option.exhaust_sel option.map(1) option.the_def p'_def) + show ?thesis + unfolding At'_simp Leq substInfinitesimalQuadraticUni.simps substInfinitesimalQuadratic.simps + eval.simps evalUni.simps + using allzero less by auto +next + case (Neq p) + define p' where "p' = (case convert_poly var p (xs'@ x#xs) of Some p' \ p')" + have At'_simp : "At' = NeqUni p'" + using assms Neq + using p'_def by auto + show ?thesis + unfolding At'_simp Neq substInfinitesimalQuadraticUni.simps substInfinitesimalQuadratic.simps + by (metis assms(12) At'_simp Neq assms(1) convert_substNegInfinity eval.simps(6) eval_neg substNegInfinityUni.simps(4) substNegInfinity.simps(4)) +qed + +lemma infinitesimal_quad_helper: + fixes A B C D:: "real" + assumes at_is: "At = LessUni p \ At = EqUni p" + assumes "D\0" + assumes "C\0" + shows "(\y'::real>((A+B * sqrt(C))/(D)). \x::real \{((A+B * sqrt(C))/(D))<..y'}. aEvalUni At x) + = (evalUni (substInfinitesimalQuadraticUni A B C D At) x)" +proof(cases "At = LessUni p") + case True + then have LessUni: "At = LessUni p" by auto + then show ?thesis proof(cases p) + case (fields a b c) + show ?thesis + proof(cases "2 * (a::real) * (A + B * sqrt C) / D + b = 0") + case True + then have True1 : "2 * a * (A + B * sqrt C) / D + b = 0" by auto + show ?thesis proof(cases "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0") + case True + then have True2 : "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0" by auto + then show ?thesis proof(cases "a<0") + case True + then show ?thesis unfolding LessUni fields apply (simp add:True1 True2 True) + using True1 True2 True + proof - + assume beq: "2 * a * (A + B * sqrt C) / D + b = 0" + assume root: "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0" + assume alt: "a < 0 " + let ?r = "-((A + B * sqrt C) / D)" + have beq_var: "b = 2 * a * ?r" using beq + by auto + have root_var: " a * ?r^2 - 2*a*?r*?r + c = 0" using root + by (simp add: beq_var) + have "\y'>- ?r. \x\{- ?r<..y'}. a * x\<^sup>2 + 2 * a *?r * x + c < 0" + using beq_var root_var alt one_root_a_lt0[where a = "a", where b="b", where c="c", where r="?r"] + by auto + then show "\y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0" + using beq_var by auto + qed + next + case False + then show ?thesis unfolding LessUni fields apply (simp add:True1 True2 False) + using True1 True2 False + proof clarsimp + fix y' + assume beq: " 2 * a * (A + B * sqrt C) / D + b = 0" + assume root: " a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0" + assume agteq: "\ a < 0 " + assume y_prop: "(A + B * sqrt C) / D < y'" + have beq_var: "b = 2 * a * (- A - B * sqrt C) / D" using beq + by (metis (no_types, hide_lams) ab_group_add_class.ab_diff_conv_add_uminus add.left_neutral add_diff_cancel_left' divide_inverse mult.commute mult_minus_right) + have root_var: " a * ((- A - B * sqrt C) / D)\<^sup>2 - 2 * a * (- A - B * sqrt C) * (- A - B * sqrt C) / (D * D) + c = 0" + using root + proof - + have f1: "\r ra. - ((r::real) + ra) = - r - ra" + by auto + have f2: "\r ra. r * (a * 2 * (- A - B * sqrt C)) / (ra * D) = r / (ra / b)" + by (simp add: beq_var) + have f3: "c - 0 + a * ((A + B * sqrt C) / D)\<^sup>2 = - (b * (A + B * sqrt C) / D)" + using root by force + have f4: "\r ra rb. ((- (r::real) - ra) / rb)\<^sup>2 = ((r + ra) / rb)\<^sup>2" + using f1 by (metis (no_types) divide_minus_left power2_minus) + have "\r ra rb rc. - ((r::real) * (ra + rb) / rc) = r * (- ra - rb) / rc" + using f1 by (metis divide_divide_eq_right divide_minus_left mult.commute) + then show ?thesis + using f4 f3 f2 by (simp add: mult.commute) + qed + have y_prop_var: "- ((- A - B * sqrt C) / D) < y'" using y_prop + by (metis add.commute diff_minus_eq_add divide_minus_left minus_diff_eq) + have "\x\{- (- (A + B * sqrt C) / D)<..y'}. \ a * x\<^sup>2 + 2 * a * (- (A + B * sqrt C) / D) * x + c < 0" + using y_prop_var beq_var root_var agteq one_root_a_gt0[where a = "a", where b ="b", where c = "c", where r= "-(A + B * sqrt C) / D"] + by auto + then show " \x\{(A + B * sqrt C) / D<..y'}. \ a * x\<^sup>2 + b * x + c < 0" + proof - + have f1: "2 * a * (A + B * sqrt C) * inverse D + b = 0" + by (metis True1 divide_inverse) + obtain rr :: real where + f2: "rr \ {- (- (A + B * sqrt C) / D)<..y'} \ \ a * rr\<^sup>2 + 2 * a * (- (A + B * sqrt C) / D) * rr + c < 0" + using \\x\{- (- (A + B * sqrt C) / D)<..y'}. \ a * x\<^sup>2 + 2 * a * (- (A + B * sqrt C) / D) * x + c < 0\ by blast + have f3: "a * ((A + B * sqrt C) * (inverse D * 2)) = - b" + using f1 by linarith + have f4: "\r. - (- (r::real)) = r" + by simp + have f5: "\r ra. (ra::real) * - r = r * - ra" + by simp + have f6: "a * ((A + B * sqrt C) * (inverse D * - 2)) = b" + using f3 by simp + have f7: "\r ra rb. (rb::real) * (ra * r) = r * (rb * ra)" + by auto + have f8: "\r ra. - (ra::real) * r = ra * - r" + by linarith + then have f9: "a * (inverse D * ((A + B * sqrt C) * - 2)) = b" + using f7 f6 f5 by presburger + have f10: "rr \ {inverse D * (A + B * sqrt C)<..y'}" + using f4 f2 by (metis (no_types) divide_inverse mult.commute mult_minus_right) + have "\ c + (rr * b + a * rr\<^sup>2) < 0" + using f9 f8 f7 f2 by (metis (no_types) add.commute divide_inverse mult.commute mult_minus_right) + then show ?thesis + using f10 by (metis (no_types) add.commute divide_inverse mult.commute) + qed + qed + qed + next + case False + then have False1 : "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c \ 0" by auto + show ?thesis proof(cases "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c < 0") + case True + show ?thesis unfolding LessUni fields apply (simp add: True1 True) + using True1 True + proof - + let ?r = "(A + B * sqrt C) / D" + assume " 2 * a * (A + B * sqrt C) / D + b = 0" + assume "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c < 0 " + then have " \y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. poly [:c, b, a:] x < 0" using continuity_lem_lt0[where r= "(A + B * sqrt C) / D", where c = "c", where b = "b", where a="a"] + quadratic_poly_eval[of c b a ?r] by auto + then show "\y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0" + using quadratic_poly_eval[of c b a] + by fastforce + qed + next + case False + then have False' : "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c > 0" using False1 by auto + show ?thesis unfolding LessUni fields apply(simp add: True1 False False1) + using True1 False' continuity_lem_gt0_expanded[where a = "a", where b = "b",where c = "c", where r = "((A + B * sqrt C) / D)"] + by (metis mult_less_0_iff not_square_less_zero times_divide_eq_right) + qed + qed + next + case False + then have False1 : "2 * a * (A + B * sqrt C) / D + b \ 0" by auto + have c1: "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0 \ + 2 * a * (A + B * sqrt C) / D + b < 0 \ + \y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0" + proof - + assume root: "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0" + assume blt: " 2 * a * (A + B * sqrt C) / D + b < 0" + let ?r = "-(A + B * sqrt C) / D" + have bltvar: "b < 2 * a * ?r" using blt divide_minus_left mult_2 mult_minus_right real_add_less_0_iff + by (metis times_divide_eq_right) + have rootvar: "a * ?r^2 - b * ?r + c = 0" using root + proof - + have f1: "\r ra. - (ra::real) * r = ra * - r" + by simp + have f2: "\r ra. ((ra::real) * - r)\<^sup>2 = (ra * r)\<^sup>2" + by simp + have f3: "a * (inverse D * (A - B * - sqrt C))\<^sup>2 - inverse D * (b * - (A - B * - sqrt C)) - - c = 0" + by (metis (no_types) diff_minus_eq_add divide_inverse mult.commute mult_minus_left root) + have f4: "\r ra rb. (rb::real) * (ra * r) = ra * (r * rb)" + by simp + have "\r ra. (ra::real) * - r = r * - ra" + by simp + then have "a * (inverse D * (A - B * - sqrt C))\<^sup>2 - b * (inverse D * - (A - B * - sqrt C)) - - c = 0" + using f4 f3 f1 by (metis (no_types)) + then have "a * (inverse D * - (A - B * - sqrt C))\<^sup>2 - b * (inverse D * - (A - B * - sqrt C)) - - c = 0" + using f2 by presburger + then show ?thesis + by (simp add: divide_inverse mult.commute) + qed + have "\y'> ((A + B * sqrt C) / D). \x\{((A + B * sqrt C) / D)<..y'}. a * x\<^sup>2 + b * x + c < 0" + using rootvar bltvar case_d1[where a= "a", where b = "b", where c = "c", where r = ?r] + by (metis add.inverse_inverse divide_inverse mult_minus_left) + then show ?thesis + by blast + qed + have c2: " \y'. a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0 \ + \ 2 * a * (A + B * sqrt C) / D + b < 0 \ + (A + B * sqrt C) / D < y' \ + \x\{(A + B * sqrt C) / D<..y'}. \ a * x\<^sup>2 + b * x + c < 0" + proof - + let ?r = "(A + B * sqrt C) / D" + fix y' + assume h1: "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c = 0" + assume h2: "\ 2 * a * (A + B * sqrt C) / D + b < 0" + assume h3: " (A + B * sqrt C) / D < y'" + have eq: "2 * a * (A + B * sqrt C) / D + b = 0 \ \x\{(A + B * sqrt C) / D..y'}. \ a * x\<^sup>2 + b * x + c < 0" + using False1 by blast + have "2 * a * (A + B * sqrt C) / D + b > 0 \ \x\{?r<..y'}. \ a * x\<^sup>2 + b * x + c < 0" + using case_d4[where a = "a", where b = "b", where c= "c", where r = "-?r"] h1 h2 h3 by auto + then show "\x\{(A + B * sqrt C) / D<..y'}. \ a * x\<^sup>2 + b * x + c < 0" using h2 eq + using False1 by linarith + qed + have c3: "((a::real) * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c < 0) \ + (\y'>((A + B * sqrt C) / D). \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0)" + proof clarsimp + assume assump: "a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c < 0 " + have "a * ((A + B * sqrt C) / D)\<^sup>2 + b * ((A + B * sqrt C) / D) + c < 0 \ + \y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0" + using continuity_lem_lt0_expanded[where a= "a", where b = "b", where c = "c", where r = "((A + B * sqrt C) / D)::real"] + by auto + then have "\y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0" using assump by auto + then obtain y where y_prop: "y >(A + B * sqrt C) / D \ (\x\{(A + B * sqrt C) / D<..y}. a * x\<^sup>2 + b * x + c < 0)" by auto + then have h: "\ k. k >(A + B * sqrt C) / D \ k < y" using dense + by blast + then obtain k where k_prop: "k >(A + B * sqrt C) / D \ k < y" by auto + then have "\x\{(A + B * sqrt C) / D..k}. a * x\<^sup>2 + b * x + c < 0" using y_prop + using assump by force + then show "\y'>((A + B * sqrt C) / D::real). \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c < 0" + using k_prop by auto + qed + have c4: "\y'. a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c \ 0 \ + \ a * ((A + B * sqrt C) / D)\<^sup>2 + b * (A + B * sqrt C) / D + c < 0 \ + (A + B * sqrt C) / D < y' \ + \x\{(A + B * sqrt C) / D<..y'}. \ a * x\<^sup>2 + b * x + c < 0" + using continuity_lem_gt0_expanded[where a= "a", where b = "b", where c = "c", where r= "(A + B * sqrt C) / D"] + by (metis Groups.mult_ac(1) divide_inverse less_eq_real_def linorder_not_le) + show ?thesis unfolding LessUni fields apply(simp add: False1) + using c1 c2 c3 c4 by auto + qed + qed +next + case False + then have EqUni: "At = EqUni p" using at_is by auto + then show ?thesis proof(cases p) + case (fields a b c) + have " \y'. (A + B * sqrt C) / D < y' \ + \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c = 0 \ (a = 0 \ b = 0 \ c = 0)" + proof - + fix y' + assume "(A + B * sqrt C) / D < y'" + then show " \x\{(A + B * sqrt C) / D<..y'}. a * x\<^sup>2 + b * x + c = 0 \ (a = 0 \ b = 0 \ c = 0)" using assms continuity_lem_eq0[where r = "(A + B * sqrt C) / D", where p = "y'", where a= "a", where b ="b", where c="c"] + by auto + qed + then show ?thesis + apply (auto simp add:EqUni fields ) + using linordered_field_no_ub by blast + qed +qed + +lemma infinitesimal_quad: + fixes A B C D:: "real" + assumes "D\0" + assumes "C\0" + shows "(\y'::real>((A+B * sqrt(C))/(D)). \x::real \{((A+B * sqrt(C))/(D))<..y'}. aEvalUni At x) + = (evalUni (substInfinitesimalQuadraticUni A B C D At) x)" +proof(cases At) + case (LessUni p) + then show ?thesis using infinitesimal_quad_helper assms + by blast +next + case (EqUni p) + then show ?thesis + using infinitesimal_quad_helper assms + by blast +next + case (LeqUni p) + then show ?thesis + proof (cases p) + case (fields a b c) + have same: "\x. aEvalUni (LeqUni p) x = (aEvalUni (EqUni p) x) \ (aEvalUni (LessUni p) x)" + apply (simp add: fields) + by force + let ?r = "(A + B * sqrt C) / D" + have "\a b c. + At = LeqUni p \ + p = (a, b, c) \ + (\y'>(A + B * sqrt C) / D. \x\{(A + B * sqrt C) / D<..y'}. aEvalUni At x) = + evalUni (substInfinitesimalQuadraticUni A B C D At) x" + proof - + fix a b c + assume atis: "At = LeqUni p" + assume p_is: " p = (a, b, c)" + have s1: "(\y'>?r. \x\{?r<..y'}. aEvalUni At x) = (\y'>?r. \x\{?r<..y'}. (aEvalUni (EqUni p) x) \ (aEvalUni (LessUni p) x))" + using atis same aEvalUni.simps(2) aEvalUni.simps(3) fields less_eq_real_def + by blast + have s2: "... = (\y'>?r. \x\{?r<..y'}. (aEvalUni (EqUni p) x)) \ (\y'>?r. \x\{?r<..y'}. (aEvalUni (LessUni p) x))" + using either_or[where r = "?r"] p_is + by blast + have eq1: "(\y'>?r. \x\{?r<..y'}. (aEvalUni (EqUni p) x)) = (evalUni (substInfinitesimalQuadraticUni A B C D (EqUni p)) x)" + using infinitesimal_quad_helper[where At = "EqUni p", where p = "p", where B = "B", where C= "C", where A= "A", where D="D"] + assms by auto + have eq2: "(\y'>?r. \x\{?r<..y'}. (aEvalUni (LessUni p) x)) = (evalUni (substInfinitesimalQuadraticUni A B C D (LessUni p)) x)" + using infinitesimal_quad_helper[where At = "LessUni p", where p = "p", where B = "B", where C= "C", where A= "A", where D="D"] + assms by auto + have z1: "(\y'>?r. \x\{?r<..y'}. aEvalUni At x) = ((evalUni (substInfinitesimalQuadraticUni A B C D (EqUni p)) x) \ (evalUni (substInfinitesimalQuadraticUni A B C D (LessUni p)) x))" + using s1 s2 eq1 eq2 by auto + have z2: "(evalUni (substInfinitesimalQuadraticUni A B C D (EqUni p)) x) \ (evalUni (substInfinitesimalQuadraticUni A B C D (LessUni p)) x) = evalUni (substInfinitesimalQuadraticUni A B C D (LeqUni p)) x" + by auto + have z3: "(evalUni (substInfinitesimalQuadraticUni A B C D At) x) = evalUni (substInfinitesimalQuadraticUni A B C D (LeqUni p)) x" + using LeqUni by auto + then have z4: "(evalUni (substInfinitesimalQuadraticUni A B C D (EqUni p)) x) \ (evalUni (substInfinitesimalQuadraticUni A B C D (LessUni p)) x) = (evalUni (substInfinitesimalQuadraticUni A B C D At) x) " + using z2 z3 by auto + let ?a = "(evalUni (substInfinitesimalQuadraticUni A B C D (EqUni p)) x) \ (evalUni (substInfinitesimalQuadraticUni A B C D (LessUni p)) x)" + let ?b = "(\y'>?r. \x\{?r<..y'}. aEvalUni At x)" + let ?c = "(evalUni (substInfinitesimalQuadraticUni A B C D At) x)" + have t1: "?b = ?a" using z1 by auto + have t2: "?a = ?c" using z4 + using atis by auto + then have "?b = ?c" using t1 t2 by auto + then show "(\y'>?r. \x\{?r<..y'}. aEvalUni At x) = evalUni (substInfinitesimalQuadraticUni A B C D At) x" + by auto + qed + then show ?thesis + using LeqUni fields by blast + qed +next + case (NeqUni p) + then show ?thesis + proof (cases p) + case (fields a b c) + then show ?thesis unfolding NeqUni fields using nonzcoeffs by auto + qed +qed + + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/LinearCase.thy b/thys/Virtual_Substitution/LinearCase.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/LinearCase.thy @@ -0,0 +1,386 @@ +section "Equality VS Proofs" +subsection "Linear Case" +theory LinearCase + imports VSAlgos +begin + + + + +theorem var_not_in_linear : + assumes "var \ vars b" + assumes "var \ vars c" + shows "freeIn var (Atom (linear_substitution var b c A))" +proof(cases A) + case (Less p) define d where "d = MPoly_Type.degree p var" + then show ?thesis using Less apply simp unfolding d_def[symmetric] + apply simp using not_in_sum + using not_in_isovarspar assms not_in_mult not_in_neg not_in_pow not_in_add + by (metis (no_types, lifting)) +next + case (Eq p) + define d where "d = MPoly_Type.degree p var" + then show ?thesis using Eq apply simp unfolding d_def[symmetric] + apply simp using not_in_sum + using not_in_isovarspar assms not_in_mult not_in_neg not_in_pow not_in_add + by (metis (no_types, lifting)) +next + case (Leq p) + define d where "d = MPoly_Type.degree p var" + then show ?thesis using Leq apply simp unfolding d_def[symmetric] + apply simp using not_in_sum + using not_in_isovarspar assms not_in_mult not_in_neg not_in_pow not_in_add + by (metis (no_types, lifting)) +next + case (Neq p) + define d where "d = MPoly_Type.degree p var" + then show ?thesis using Neq apply simp unfolding d_def[symmetric] + apply simp using not_in_sum + using not_in_isovarspar assms not_in_mult not_in_neg not_in_pow not_in_add + by (metis (no_types, lifting)) +qed + +(* ----------------------------------------------------------------------------------------------- *) +lemma linear_eq : + assumes lLength : "length L > var" + assumes nonzero : "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes hb : "insertion (nth_default 0 (list_update L var( B/C))) b = (B::real)" + assumes hc : "insertion (nth_default 0 (list_update L var (B/C))) c = (C::real)" + shows "aEval (Eq(p)) (list_update L var (B/C)) = (aEval (linear_substitution var b c (Eq(p))) (list_update L var v))" +proof - + define d where "d = MPoly_Type.degree p var" + define f where "f i = (insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i::real)" for i + have h : "((\i = 0..i = 0..i = 0..i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i * C ^ (d - i)) = 0)" + using assms by(simp add: insertion_sum insertion_mult insertion_add insertion_pow insertion_neg lLength) + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i/ (C ^ i)) = 0)" + using h by(simp add: f_def) + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * ((B/C) ^ i)) = 0)" + by (metis (no_types, lifting) power_divide sum.cong times_divide_eq_right) + also have "... = aEval (Eq(p :: real mpoly)) (list_update L var (B/C))" + using sum_over_degree_insertion d_def lLength by auto + finally show ?thesis using assms plugInLinear var_not_in_linear var_not_in_eval + by (meson var_not_in_aEval) +qed + + + + + +(* -------------------------------------------------------------------------------------------- *) + + +lemma linear_less : + assumes lLength : "length L > var" + assumes nonzero : "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes "insertion (nth_default 0 (list_update L var (B/C))) b = (B::real)" + assumes "insertion (nth_default 0 (list_update L var (B/C))) c = (C::real)" + shows "aEval (Less(p)) (list_update L var (B/C)) = (aEval (linear_substitution var b c (Less(p))) (list_update L var v))" +proof- + define d where "d = MPoly_Type.degree p var" + define f where "f i = (insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i::real)" for i + have h : "(\i = 0..<(d+1). (f i) * C ^ (d - i)) * C ^ (d mod 2) < 0 \ (\i = 0..<((d::nat)+1). (f i::real) / (C ^ i)) < 0" + using nonzero normalize_summation_less by auto + have "aEval (linear_substitution var b c (Less(p))) (list_update L var (B/C))=aEval (Less((\i\{0..<(d+1)}. isolate_variable_sparse p var i * (b^i) * (c^(d-i))) * (c ^ (d mod 2)))) (list_update L var (B/C))" + by (metis (no_types, lifting) d_def linear_substitution.simps(2) sum.cong) + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i * C ^ (d - i)) * C ^ (d mod 2) < 0)" + using assms by(simp add: insertion_sum insertion_mult insertion_add insertion_pow insertion_neg lLength) + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (((B) ^ i) / (C ^ i))) < 0)" + using f_def h by auto + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B/C)^i) < 0)" + by (metis (no_types, lifting) power_divide sum.cong) + also have "... = aEval (Less(p)) (list_update L var (B/C))" + using d_def sum_over_degree_insertion lLength by auto + finally show ?thesis using assms plugInLinear var_not_in_linear var_not_in_eval + by (meson var_not_in_aEval) +qed + + + +(* -------------------------------------------------------------------------------------------- *) + +lemma linear_leq : + assumes lLength : "length L > var" + assumes nonzero : "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes "insertion (nth_default 0 (list_update L var (B/C))) b = (B::real)" + assumes "insertion (nth_default 0 (list_update L var (B/C))) c = (C::real)" + shows "aEval (Leq(p)) (list_update L var (B/C)) = (aEval (linear_substitution var b c (Leq(p))) (list_update L var v))" +proof - + define d where "d = MPoly_Type.degree p var" + define f where "f i = (insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i::real)" for i + have h1a : "((\i = 0..<(d+1). (f i) * C ^ (d - i)) * C ^ (d mod 2) < 0 ) = ((\i = 0..<((d::nat)+1). (f i::real) / (C ^ i)) < 0)" + using nonzero normalize_summation_less by auto + have "((\i = 0..i = 0..i = 0..i = 0..<(d+1). (f i) * C ^ (d - i)) * C ^ (d mod 2) \ 0 ) = ((\i = 0..<((d::nat)+1). (f i::real) / (C ^ i)) \ 0)" + using h1a by smt + have "aEval (linear_substitution var b c (Leq(p))) (list_update L var (B/C))=aEval (Leq((\i\{0..<(d+1)}. isolate_variable_sparse p var i * (b^i) * (c^(d-i))) * (c ^ (d mod 2)))) (list_update L var (B/C))" + by (metis (no_types, lifting) d_def linear_substitution.simps(3) sum.cong) + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i * C ^ (d - i)) * C ^ (d mod 2) \ 0)" + using assms by(simp add: insertion_sum insertion_mult insertion_add insertion_pow insertion_neg lLength) + also have"...= ((\i = 0..<(d+1). (insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B) ^ i) / (C ^ i)) \ 0)" + using h1 f_def by auto + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (((B) ^ i) / (C ^ i))) \ 0)" + by auto + also have "... = ((\i = 0..<(d+1). insertion (nth_default 0 (list_update L var (B/C))) (isolate_variable_sparse p var i) * (B/C)^i) \ 0)" + by (metis (no_types, lifting) power_divide sum.cong) + also have "... = aEval (Leq(p)) (list_update L var (B/C))" + using d_def sum_over_degree_insertion lLength by auto + finally show ?thesis using assms plugInLinear var_not_in_eval var_not_in_linear + by (meson var_not_in_aEval) +qed + (* ----------------------------------------------------------------------------------------------- *) + + +lemma linear_neq : + assumes lLength : "length L > var" + assumes nonzero : "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes "insertion (nth_default 0 (list_update L var (B/C))) b = (B::real)" + assumes "insertion (nth_default 0 (list_update L var (B/C))) c = (C::real)" + shows "aEval (Neq(p)) (list_update L var (B/C)) = (aEval (linear_substitution var b c (Neq(p))) (list_update L var v))" +proof - + define d where "d = MPoly_Type.degree p var" + have "aEval (Eq(p)) (list_update L var (B/C)) = (\v. aEval (linear_substitution var b c (Eq(p))) (list_update L var v))" + using linear_eq assms by auto + also have "... = (\v. eval (Atom (Eq ((\i = 0..(\v. eval (Atom (Neq ((\i = 0..(\v. aEval (linear_substitution var b c (Neq(p))) (list_update L var v)))" + by (metis (full_types) d_def eval.simps(1) linear_substitution.simps(4)) + finally have "... = (\(aEval (Neq(p)) (list_update L var (B/C))))" by simp + then show ?thesis + using assms(3) assms(4) var_not_in_aEval var_not_in_linear by blast +qed + +(* -------------------------------------------------------------------------------------------- *) + + + +theorem linear : + assumes lLength : "length L > var" + assumes "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes "insertion (nth_default 0 (list_update L var (B/C))) b = (B::real)" + assumes "insertion (nth_default 0 (list_update L var (B/C))) c = (C::real)" + shows "aEval A (list_update L var (B/C)) = (aEval (linear_substitution var b c A) (list_update L var v))" + apply(cases A) using linear_less[OF assms(1-6)] linear_eq[OF assms(1-6)] linear_leq[OF assms(1-6)] linear_neq[OF assms(1-6)] by auto + + + + +lemma var_not_in_linear_fm_helper : + assumes "var \ vars b" + assumes "var \ vars c" + shows "freeIn (var+z) (linear_substitution_fm_helper var b c F z)" +proof(induction F arbitrary: z) + case TrueF + then show ?case by(simp) +next + case FalseF + then show ?case by simp +next + case (Atom x) + show ?case unfolding linear_substitution_fm_helper.simps liftmap.simps + using var_not_in_linear[OF not_in_lift[OF assms(1)] not_in_lift[OF assms(2)], of z] by blast +next + case (And F1 F2) + then show ?case by simp +next + case (Or F1 F2) + then show ?case by simp +next + case (Neg F) + then show ?case by simp +next + case (ExQ F) + show ?case using ExQ[of "z+1"] by simp +next + case (AllQ F) + show ?case using AllQ[of "z+1"] by simp +next + case (ExN x1 \) + then show ?case + by (metis (no_types, lifting) freeIn.simps(13) group_cancel.add1 liftmap.simps(10) linear_substitution_fm_helper.simps) +next + case (AllN x1 \) + then show ?case + by (metis (no_types, lifting) freeIn.simps(12) group_cancel.add1 liftmap.simps(9) linear_substitution_fm_helper.simps) +qed + +theorem var_not_in_linear_fm : + assumes "var \ vars b" + assumes "var \ vars c" + shows "freeIn var (linear_substitution_fm var b c F)" + using var_not_in_linear_fm_helper[OF assms, of 0] by auto + +lemma linear_fm_helper : + assumes "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes "insertion (nth_default 0 (list_update (drop z L) var (B/C))) b = (B::real)" + assumes "insertion (nth_default 0 (list_update (drop z L) var (B/C))) c = (C::real)" + assumes lLength : "length L > var+z" + shows "eval F (list_update L (var+z) (B/C)) = (eval (linear_substitution_fm_helper var b c F z) (list_update L (var+z) v))" + using assms proof(induction F arbitrary:z L) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom x) + define L1 where "L1 = drop z L" + define L2 where "L2 = take z L" + have L_def : "L = L2 @ L1" using L1_def L2_def by auto + have h1a : "insertion (nth_default 0 L1) b = B" + using not_contains_insertion[OF Atom(2), of L1 "B/C" B] Atom(4) unfolding L1_def nth_default_def + by (metis list_update_id) + have lengthl2 : "length L2 = z" using L2_def + using Atom.prems(6) min.absorb2 by auto + have "(\I amount. + length I = amount \ + (\xs. eval (fm.Atom (Eq (b - Const B))) ([] @ xs) = + eval (liftFm 0 amount (fm.Atom (Eq (b - Const B)))) ([] @ I @ xs)))" + by (metis eval_liftFm_helper list.size(3)) + then have "eval (Atom(Eq (b-Const B))) ([] @ L1) = eval (liftFm 0 z (Atom(Eq (b- Const B)))) ([] @ L2 @ L1)" + using lengthl2 by auto + then have "(insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z (b - Const B)) = 0)" + apply(simp add: insertion_sub insertion_const) using h1a by auto + then have "insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z b) = B" + using lift_minus by blast + then have h1 : "insertion (nth_default 0 (L[var + z := B/C])) (liftPoly 0 z b) = B" + using not_in_lift[OF Atom(2), of z] L_def + by (metis list_update_id not_contains_insertion) + have h2a : "insertion (nth_default 0 L1) c = C" + using not_contains_insertion[OF Atom(3), of L1 "B/C" C] Atom(5) unfolding L1_def + by (metis list_update_id) + have "(\I amount. + length I = amount \ + (\xs. eval (fm.Atom (Eq (c - Const C))) ([] @ xs) = + eval (liftFm 0 amount (fm.Atom (Eq (c - Const C)))) ([] @ I @ xs)))" + by (metis eval_liftFm_helper list.size(3)) + then have "eval (Atom(Eq (c-Const C))) ([] @ L1) = eval (liftFm 0 z (Atom(Eq (c- Const C)))) ([] @ L2 @ L1)" + using lengthl2 by auto + then have "(insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z (c - Const C)) = 0)" + apply(simp add: insertion_sub insertion_const) using h2a by auto + then have "insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) = C" + using lift_minus by blast + then have h2 : "insertion (nth_default 0 (L[var + z := B/C])) (liftPoly 0 z c) = C" + using not_in_lift[OF Atom(3), of z] L_def + by (metis list_update_id not_contains_insertion) + show ?case using linear[OF Atom(6) Atom(1) not_in_lift[OF Atom(2)] not_in_lift[OF Atom(3)], of B, of x, OF h1 h2] unfolding linear_substitution_fm_helper.simps liftmap.simps eval.simps + . +next + case (And F1 F2) + then show ?case by auto +next + case (Or F1 F2) + then show ?case using var_not_in_linear_fm_helper var_not_in_eval unfolding linear_substitution_fm_helper.simps liftmap.simps eval.simps + by blast +next + case (Neg F) + then show ?case using var_not_in_linear_fm_helper var_not_in_eval unfolding linear_substitution_fm_helper.simps liftmap.simps eval.simps + by blast +next + case (ExQ F) + have droph : "(drop (z + 1) (x#L)) = (drop z L)" for x by auto + have l : "x # L[var + z := v] = ((x#L)[var+(z+1):=v])" for x v + by auto + have "eval (ExQ F) (L[var + z := B/C]) = + (\x. eval F ((x # L)[var + (z + 1) := B/C])) " + apply(simp) unfolding l done + + also have "... = (\x. eval + (liftmap (\x. \a. Atom(linear_substitution (var + x) (liftPoly 0 x b) (liftPoly 0 x c) a)) F (z + 1)) + ((x # L)[var + (z + 1) := v]))" + apply(rule ex_cong1) + using ExQ(1)[of "z+1", OF assms(1) assms(2) assms(3)] droph + unfolding linear_substitution_fm_helper.simps liftmap.simps + by (metis (mono_tags, lifting) ExQ.prems(4) ExQ.prems(5) ExQ.prems(6) One_nat_def Suc_eq_plus1 Suc_less_eq add_Suc_right list.size(4)) + also have "... = (eval (linear_substitution_fm_helper var b c (ExQ F) z) (L[var + z := v]))" + unfolding linear_substitution_fm_helper.simps liftmap.simps eval.simps l by simp + finally show ?case by simp +next + case (AllQ F) + have droph : "(drop (z + 1) (x#L)) = (drop z L)" for x by auto + have l : "x # L[var + z := v] = ((x#L)[var+(z+1):=v])" for x v + by auto + have "eval (AllQ F) (L[var + z := B/C]) = + (\x. eval F ((x # L)[var + (z + 1) := B/C])) " + apply(simp) unfolding l done + also have "... = (\x. eval + (liftmap (\x.\a. Atom(linear_substitution (var + x) (liftPoly 0 x b) (liftPoly 0 x c) a)) F (z + 1)) + ((x # L)[var + (z + 1) := v]))" + apply(rule all_cong1) + using AllQ(1)[of "z+1", OF assms(1) assms(2) assms(3)] + var_not_in_linear_fm_helper[OF assms(2) assms(3)] var_not_in_eval droph + unfolding linear_substitution_fm_helper.simps liftmap.simps + by (metis (mono_tags, lifting) AllQ(7) AllQ.prems(4) AllQ.prems(5) One_nat_def Suc_eq_plus1 Suc_less_eq add_Suc_right list.size(4)) + also have "... = (eval (linear_substitution_fm_helper var b c (AllQ F) z) (L[var + z := v]))" + unfolding linear_substitution_fm_helper.simps liftmap.simps eval.simps l by auto + finally show ?case by simp +next + case (ExN x1 \) + have list : "\l. length l=x1 \ ((drop (z + x1) l @ drop (z + x1 - length l) L)[var := B / C]) = ((drop z L)[var := B / C])" + by auto + have map : "\ z L. eval (liftmap (\x A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x b) (liftPoly 0 x c) A)) \ (z + x1)) + L = eval (liftmap (\x A. fm.Atom (linear_substitution (var + x1 + x) (liftPoly 0 (x+x1) b) (liftPoly 0 (x+x1) c) A)) \ z) + L" + apply(induction \) apply(simp_all add:add.commute add.left_commute) + apply force + apply force + by (metis (mono_tags, lifting) ab_semigroup_add_class.add_ac(1))+ + show ?case + apply simp apply(rule ex_cong1) + subgoal for l + using map[of z] ExN(1)[OF ExN(2-4), of "z+x1" "l@L"] ExN(5-7) list + apply simp + by (smt (z3) add.commute add.left_commute add_diff_cancel_left' add_mono_thms_linordered_field(4) list list_update_append not_add_less1 order_refl) + done +next + case (AllN x1 \) + have list : "\l. length l=x1 \ ((drop (z + x1) l @ drop (z + x1 - length l) L)[var := B / C]) = ((drop z L)[var := B / C])" + by auto + have map : "\ z L. eval (liftmap (\x A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x b) (liftPoly 0 x c) A)) \ (z + x1)) + L = eval (liftmap (\x A. fm.Atom (linear_substitution (var + x1 + x) (liftPoly 0 (x+x1) b) (liftPoly 0 (x+x1) c) A)) \ z) + L" + apply(induction \) apply(simp_all add:add.commute add.left_commute) + apply force + apply force + by (metis (mono_tags, lifting) ab_semigroup_add_class.add_ac(1))+ + show ?case + apply simp apply(rule all_cong1) + subgoal for l + using map[of z] AllN(1)[OF AllN(2-4), of "z+x1" "l@L"] AllN(5-7) list + apply simp + by (smt (z3) add.commute add.left_commute add_diff_cancel_left' add_mono_thms_linordered_field(4) list list_update_append not_add_less1 order_refl) + done +qed + +theorem linear_fm : + assumes lLength : "length L > var" + assumes "C \ 0" + assumes "var \ vars b" + assumes "var \ vars c" + assumes "insertion (nth_default 0 (list_update L var (B/C))) b = (B::real)" + assumes "insertion (nth_default 0 (list_update L var (B/C))) c = (C::real)" + shows "eval F (list_update L var (B/C)) = (\v. eval (linear_substitution_fm var b c F) (list_update L var v))" + unfolding linear_substitution_fm.simps using linear_fm_helper[OF assms(2) assms(3) assms(4), of 0 L B] assms(1) assms(5) assms(6) + by (simp add: lLength) +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/LuckyFind.thy b/thys/Virtual_Substitution/LuckyFind.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/LuckyFind.thy @@ -0,0 +1,206 @@ +subsection "Overall LuckyFind Proofs" +theory LuckyFind + imports EliminateVariable +begin + + + +theorem luckyFind_eval: + assumes "luckyFind x L F = Some F'" + assumes "length xs = x" + shows "(\x. (eval (list_conj ((map Atom L) @ F)) (xs @ (x#\)))) = (\x.(eval F' (xs @ (x#\))))" +proof(cases "find_lucky_eq x L") + case None + then show ?thesis using assms by auto +next + case (Some p) + have inset : "Eq p \ set L" + using Some proof(induction L) + case Nil + then show ?case by auto + next + case (Cons a L) + then show ?case proof(cases a) + case (Less x1) + then show ?thesis using Cons by auto + next + case (Eq p') + show ?thesis using Cons + unfolding Eq apply simp apply(cases "(MPoly_Type.degree p' x = Suc 0 \ MPoly_Type.degree p' x = 2)") apply simp_all + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 2)") apply(simp_all) + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 1)") apply(simp_all) + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 0)") by(simp_all) + next + case (Leq x3) + then show ?thesis using Cons by auto + next + case (Neq x4) + then show ?thesis using Cons by auto + qed + qed + have degree : "MPoly_Type.degree p x = 1 \ MPoly_Type.degree p x = 2" + using Some proof(induction L) + case Nil + then show ?case by auto + next + case (Cons a L) + then show ?case proof(cases a) + case (Less x1) + then show ?thesis using Cons by auto + next + case (Eq p') + show ?thesis using Cons + unfolding Eq apply simp apply(cases "(MPoly_Type.degree p' x = Suc 0 \ MPoly_Type.degree p' x = 2)") apply simp_all + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 2)") apply(simp_all) + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 1)") apply(simp_all) + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 0)") by(simp_all) + next + case (Leq x3) + then show ?thesis using Cons by auto + next + case (Neq x4) + then show ?thesis using Cons by auto + qed + qed + have nonzero : "\xa. insertion (nth_default 0 (xs @ xa # \)) (isolate_variable_sparse p x 2) \ 0 \ + insertion (nth_default 0 (xs @ xa # \)) (isolate_variable_sparse p x 1) \ 0 \ + insertion (nth_default 0 (xs @ xa # \)) (isolate_variable_sparse p x 0) \ 0" + using Some proof(induction L) + case Nil + then show ?case by auto + next + case (Cons a L) + then show ?case proof(cases a) + case (Less x1) + then show ?thesis using Cons by auto + next + case (Eq p') + have h : "\p xa. check_nonzero_const p \ insertion (nth_default 0 (xs @ xa # \)) p \ 0" + proof- + fix p xa + assume h : "check_nonzero_const p" + show "insertion (nth_default 0 (xs @ xa # \)) p \ 0" + apply(cases "get_if_const p") + using h get_if_const_insertion by simp_all + qed + show ?thesis using Cons(2) + unfolding Eq apply (simp del:get_if_const.simps) apply(cases "(MPoly_Type.degree p' x = Suc 0 \ MPoly_Type.degree p' x = 2)") defer using Cons apply simp + apply (simp del:get_if_const.simps) + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 2)") + apply(simp del:get_if_const.simps) using h + apply simp + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 1)") + apply(simp del:get_if_const.simps) using h + apply simp + apply(cases "check_nonzero_const (isolate_variable_sparse p' x 0)") + apply(simp del:get_if_const.simps) using h + apply simp + using Cons by auto + next + case (Leq x3) + then show ?thesis using Cons by auto + next + case (Neq x4) + then show ?thesis using Cons by auto + qed + qed + show ?thesis + using elimVar_eq_2[OF assms(2) inset degree nonzero] Some assms by auto +qed + + +lemma luckyFind'_eval : + assumes "length xs = var" + shows "(\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = (\x. eval (luckyFind' var L F) (xs @ x # \))" +proof(cases "find_lucky_eq var L") + case None + show ?thesis apply(simp add:eval_list_conj None) + apply(rule ex_cong1) + apply auto + by (meson UnCI eval.simps(1) image_eqI) +next + case (Some p) + have "\F'. luckyFind var L F = Some F'" by (simp add:Some) + then obtain F' where F'_def: "luckyFind var L F = Some F'" by metis + show ?thesis + unfolding luckyFind_eval[OF F'_def assms] + using F'_def Some by auto +qed + + + +lemma luckiestFind_eval : + assumes "length xs = var" + shows "(\x. eval (list_conj (map fm.Atom L @ F)) (xs @ x # \)) = (\x. eval (luckiestFind var L F) (xs @ x # \))" +proof(cases "find_luckiest_eq var L") + case None + show ?thesis apply(simp add:eval_list_conj None) + apply(rule ex_cong1) + apply auto + by (meson UnCI eval.simps(1) image_eqI) +next + case (Some p) + have h1: "Eq p \ set L" + using Some apply(induction L arbitrary:p) + apply simp + subgoal for a L p + apply(rule find_luckiest_eq.elims[of var "a#L" "Some p"]) + apply simp_all + subgoal for v p' + apply(cases "MPoly_Type.degree p' v = Suc 0 \ MPoly_Type.degree p' v = 2") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v 2))") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v (Suc 0)))") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v 0))") apply simp_all + apply(cases "MPoly_Type.coeff (isolate_variable_sparse p' v (Suc 0)) 0 = 0 \ + MPoly_Type.coeff (isolate_variable_sparse p' v 2) 0 = 0 \ MPoly_Type.coeff (isolate_variable_sparse p' v 0) 0 \ 0") by simp_all + done + done + have h2 : "MPoly_Type.degree p var = 1 \ MPoly_Type.degree p var = 2" + using Some apply(induction L arbitrary:p) + apply simp + subgoal for a L p + apply(rule find_luckiest_eq.elims[of var "a#L" "Some p"]) + apply simp_all + subgoal for v p' + apply(cases "MPoly_Type.degree p' v = Suc 0 \ MPoly_Type.degree p' v = 2") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v 2))") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v (Suc 0)))") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v 0))") apply simp_all + apply(cases "MPoly_Type.coeff (isolate_variable_sparse p' v (Suc 0)) 0 = 0 \ + MPoly_Type.coeff (isolate_variable_sparse p' v 2) 0 = 0 \ MPoly_Type.coeff (isolate_variable_sparse p' v 0) 0 \ 0") by simp_all + done + done + have h : "\p xa. check_nonzero_const p \ insertion (nth_default 0 (xs @ xa # \)) p \ 0" + proof- + fix p xa + assume h : "check_nonzero_const p" + show "insertion (nth_default 0 (xs @ xa # \)) p \ 0" + apply(cases "get_if_const p") + using h get_if_const_insertion by simp_all + qed + + have h3 : "\x. insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 2) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 1) \ 0 \ + insertion (nth_default 0 (xs @ x # \)) (isolate_variable_sparse p var 0) \ 0" + using Some apply(induction L arbitrary:p) + apply simp + subgoal for a L p + apply(rule find_luckiest_eq.elims[of var "a#L" "Some p"]) + apply simp_all + subgoal for v p' + apply(cases "MPoly_Type.degree p' v = Suc 0 \ MPoly_Type.degree p' v = 2") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v 2))") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v (Suc 0)))") apply simp_all + apply(cases "Set.is_empty (vars (isolate_variable_sparse p' v 0))") apply simp_all + apply(cases "MPoly_Type.coeff (isolate_variable_sparse p' v (Suc 0)) 0 = 0 \ + MPoly_Type.coeff (isolate_variable_sparse p' v 2) 0 = 0 \ MPoly_Type.coeff (isolate_variable_sparse p' v 0) 0 \ 0") apply simp_all + using h[of "isolate_variable_sparse p' v 0"] h[of "isolate_variable_sparse p' v (Suc 0)"] h[of "isolate_variable_sparse p' v 2"] apply simp + by blast + done + done + show ?thesis apply(simp_all add:Some del:elimVar.simps) + apply(rule elimVar_eq_2) using assms apply simp using h1 h2 h3 by auto + +qed + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/MPolyExtension.thy b/thys/Virtual_Substitution/MPolyExtension.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/MPolyExtension.thy @@ -0,0 +1,192 @@ +section "Multivariate Polynomials Extension" +theory MPolyExtension + imports Polynomials.Polynomials (*MPoly_Type_Efficient_Code*) Polynomials.MPoly_Type_Class_FMap +begin + +subsection "Definition Lifting" + +lift_definition coeff_code::"'a::zero mpoly \ (nat \\<^sub>0 nat) \ 'a" is + "lookup" . + +lemma coeff_code[code]: "coeff = coeff_code" + unfolding coeff_def apply(transfer) by auto + +lemma coeff_transfer[transfer_rule]:\ \TODO: coeff should be defined via +lifting, this gives us the illusion\ + "rel_fun cr_mpoly (=) lookup coeff" using coeff_code.transfer[folded + coeff_code] . + +lemmas coeff_add = coeff_add[symmetric] + +lemma plus_monom_zero[simp]: "p + MPoly_Type.monom m 0 = p" + by transfer auto + +lift_definition monomials::"'a::zero mpoly \ (nat \\<^sub>0 nat) set" is + "Poly_Mapping.keys::((nat\\<^sub>0nat) \\<^sub>0 'a) \ _ set" . + +lemma mpoly_induct [case_names monom sum]:\ \TODO: overwrites @{thm +mpoly_induct}\ + assumes monom:"\m a. P (MPoly_Type.monom m a)" + and sum:"(\p1 p2 m a. P p1 \ P p2 \ p2 = (MPoly_Type.monom m a) \ m \ monomials p1 +\ a \ 0 \ P (p1+p2))" + shows "P p" using assms +proof (induction p rule: mpoly_induct) + case (sum p1 p2 m a) + then show ?case + by (cases "a = 0") (auto simp: monomials.rep_eq) +qed simp + +value "monomials ((Var 0 + Const (3::int) * Var 1)^2)" + +lemma Sum_any_lookup_times_eq: + "(\k. ((lookup (x::'a\\<^sub>0('b::comm_semiring_1)) (k::'a)) * ((f:: 'a\('b::comm_semiring_1)) k))) = (\k\keys +x. (lookup x (k::'a)) * (f k))" + by (subst Sum_any.conditionalize) (auto simp: in_keys_iff intro!: + Sum_any.cong) + +lemma Prod_any_power_lookup_eq: + "(\k::'a. f k ^ lookup (x::'a\\<^sub>0nat) k) = (\k\keys x. f k ^ lookup x k)" + by (subst Prod_any.conditionalize) (auto simp: in_keys_iff intro!: + Prod_any.cong) + +lemma insertion_monom: "insertion i (monom m a) = a * (\k\keys m. i k ^ +lookup m k)" + by transfer (auto simp: insertion_aux_def insertion_fun_def + Sum_any_lookup_times_eq Prod_any_power_lookup_eq) + +lemma monomials_monom[simp]: "monomials (monom m a) = (if a = 0 then {} +else {m})" + by transfer auto + +lemma finite_monomials[simp]: "finite (monomials m)" + by transfer auto + +lemma monomials_add_disjoint: + "monomials (a + b) = monomials a \ monomials b" if "monomials a \ +monomials b = {}" + using that + by transfer (auto simp add: keys_plus_eqI) + +lemma coeff_monom[simp]: "coeff (monom m a) m = a" + by transfer simp + +lemma coeff_not_in_monomials[simp]: "coeff m x = 0" if "x \ monomials m" + using that + by transfer (simp add: in_keys_iff) + +code_thms insertion + +lemma insertion_code[code]: "insertion i mp = + (\m\monomials mp. (coeff mp m) * (\k\keys m. i k ^ lookup m k))" +proof (induction mp rule: mpoly_induct) + case (monom m a) + show ?case + by (simp add: insertion_monom) +next + case (sum p1 p2 m a) + have monomials_add: "monomials (p1 + p2) = insert m (monomials p1)" + using sum.hyps + by (auto simp: monomials_add_disjoint) + have *: "coeff (monom m a) x = 0" if "x \ monomials p1" for x + using sum.hyps that + by (subst coeff_not_in_monomials) auto + show ?case + unfolding insertion_add monomials_add sum.IH + using sum.hyps + by (auto simp: coeff_add * algebra_simps) +qed + + +(* insertion f p + takes in a mapping from natural numbers to the type of the polynomial and substitutes in + the constant (f var) for each var variable in polynomial p +*) +code_thms insertion + +value "insertion (nth [1, 2.3]) ((Var 0 + Const (3::int) * Var 1)^2)" + + +(* isolate_variable_sparse p var degree + returns the coefficient of the term a*var^degree in polynomial p + *) +lift_definition isolate_variable_sparse::"'a::comm_monoid_add mpoly \ +nat \ nat \ 'a mpoly" is + "\(mp::'a mpoly) x d. sum + (\m. monomial (coeff mp m) (Poly_Mapping.update x 0 m)) + {m \ monomials mp. lookup m x = d}" . + +lemma Poly_Mapping_update_code[code]: "Poly_Mapping.update a b (Pm_fmap +fm) = Pm_fmap (fmupd a b fm)" + by (auto intro!: poly_mapping_eqI simp: update.rep_eq + fmlookup_default_def) + + +lemma monom_zero [simp] : "monom m 0 = 0" + by (simp add: coeff_all_0) + + +lemma remove_key_code[code]: "remove_key v (Pm_fmap fm) = Pm_fmap +(fmdrop v fm)" + by (auto simp: remove_key_lookup fmlookup_default_def intro!: + poly_mapping_eqI) +lemma extract_var_code[code]: + "extract_var p v = + (\m\monomials p. monom (remove_key v m) (monom (Poly_Mapping.single +v (lookup m v)) (coeff p m)))" + apply (rule extract_var_finite_set[where S="monomials p"]) + using coeff_not_in_monomials by auto +value "extract_var ((Var 0 + Const (3::real) * Var 1)^2) 0" + + + +(* degree p var + takes in polynomial p and a variable var and finds the degree of that variable in the polynomial + missing code theorems? still manages to evaluate +*) +code_thms degree +value "degree ((Var 0 + Const (3::real) * Var 1)^2) 0" + + +(* this function gives a set of all the variables in the polynomial +*) +lemma vars_code[code]: "vars p = \ (keys ` monomials p)" + unfolding monomials.rep_eq vars_def .. + +value "vars ((Var 0 + Const (3::real) * Var 1)^2)" + + +(* return true if the polynomial contains no variables +*) +fun is_constant :: "'a::zero mpoly \ bool" where + "is_constant p = Set.is_empty (vars p)" + +value "is_constant (Const (0::int))" + + +(* + if the polynomial is constant, returns the real value associated with the polynomial, + otherwise returns none +*) +fun get_if_const :: "real mpoly \ real option" where + "get_if_const p = (if is_constant p then Some (coeff p 0) else None)" + +term "coeff p 0" + + +lemma insertionNegative : "insertion f p = - insertion f (-p)" + by (metis (no_types, hide_lams) add_eq_0_iff cancel_comm_monoid_add_class.diff_cancel insertion_add insertion_zero uminus_add_conv_diff) + + +definition derivative :: "nat \ real mpoly \ real mpoly" where + "derivative x p = (\i\{0..degree p x-1}. isolate_variable_sparse p x (i+1) * (Var x)^i * (Const (i+1)))" + +text "get\\_coeffs $x$ $p$ + gets the tuple of coefficients $a$ $b$ $c$ of the term $a*x^2+b*x+c$ in polynomial $p$" +fun get_coeffs :: "nat \ real mpoly \ real mpoly * real mpoly * real mpoly" where + "get_coeffs var x = ( + isolate_variable_sparse x var 2, + isolate_variable_sparse x var 1, + isolate_variable_sparse x var 0) +" + +end diff --git a/thys/Virtual_Substitution/NegInfinity.thy b/thys/Virtual_Substitution/NegInfinity.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/NegInfinity.thy @@ -0,0 +1,132 @@ +subsection "Negative Infinity" +theory NegInfinity + imports "HOL-Analysis.Poly_Roots" VSAlgos +begin + + + +lemma freeIn_allzero : "freeIn var (allZero p var)" + by (simp add: not_in_isovarspar freeIn_list_conj) + +lemma allzero_eval : + assumes lLength : "var < length L" + shows"(\x. \yx. eval (allZero p var) (list_update L var x))" +proof- + define n where "n = MPoly_Type.degree p var" + define k where "k i x =((insertion (nth_default 0(list_update L var x)) (isolate_variable_sparse p var i)))" for i x + {fix x + have "(eval (allZero p var) (list_update L var x)) = + (\i\{0..<(MPoly_Type.degree p var)+1}. aEval (Eq(isolate_variable_sparse p var i)) (list_update L var x))" + by (simp add: eval_list_conj atLeast0_lessThan_Suc) + also have "... = (\i\{0..<(MPoly_Type.degree p var)+1}. (insertion (nth_default 0(list_update L var x)) (isolate_variable_sparse p var i))=0)" + by simp + also have "... = (\i\(MPoly_Type.degree p var). (insertion (nth_default 0(list_update L var x)) (isolate_variable_sparse p var i))=0)" + by fastforce + also have "... = (\y. (\i\(MPoly_Type.degree p var). ((insertion (nth_default 0(list_update L var x)) (isolate_variable_sparse p var i)) * y ^ i))=0)" + using polyfun_eq_const[where n="MPoly_Type.degree p var", where k="0", where c="\i. (insertion (nth_default 0(list_update L var x)) (isolate_variable_sparse p var i))"] + by (metis (no_types, lifting) le_add2 le_add_same_cancel2) + also have "... = (\y. (\i\n. (k i x) * y ^ i)=0)" + using k_def n_def by simp + finally have "(eval (allZero p var) (list_update L var x)) = (\y. (\i\n. (k i x) * y ^ i)=0)" + by simp + } + then have h1 : "(\x. (eval (allZero p var) (list_update L var x))) = (\x.(\y. (\i\n. (k i x) * y ^ i)=0))" + by simp + + have "(\y. \xi\n. (k i x)* x^i)= 0) = (\y. \xi\(MPoly_Type.degree p var). (insertion (nth_default 0 (list_update L var x))(isolate_variable_sparse p var i))* x^i)= 0)" + using k_def n_def by simp + also have "... = (\y. \xi\(MPoly_Type.degree p var). (isolate_variable_sparse p var i)* Var var^i)= 0)" + by(simp add: insertion_sum' insertion_mult insertion_pow insertion_var lLength) + also have "... = (\y. \xy. \xy. \xy. \xi\n. (k i x)* x^i)= 0)" + by simp + + have k_all : "\x y i. k i x = k i y" + unfolding k_def + by (simp add: insertion_isovarspars_free) + have h3a : "(\y. \xi\n. (k i x)* x^i)= 0) \ (\x.(\y. (\i\n. (k i x) * y ^ i)=0))" + proof- + assume h : "(\y. \xi\n. (k i x)* x^i)= 0)" + {fix z y + assume h : "(\xi\n. (k i x)* x^i)= 0)" + have "\xi\n. k i x = k i z" + unfolding k_def + using insertion_isovarspars_free by blast + then have * : "\xi\n. k i x * x ^ i = k i z * x^i" + by auto + then have "\xi\n. k i x * x ^ i) = (\i\n. k i z * x ^ i)" + by (metis (no_types, lifting) k_all sum.cong) + then have "\xi\n. (k i z)* x^i)= 0" + using h by simp + then have "\(finite {x. (\i\n. k i z * x ^ i) = 0})" + using infinite_Iio[where a="y"] Inf_many_def[where P="\x. (\i\n. k i z * x ^ i) = 0"] + by (smt INFM_iff_infinite frequently_mono lessThan_def) + then have "\i\n. k i z = 0" + using polyfun_rootbound[where n="n", where c = "\i. k i z" ] + by blast + } + then have "\x.\i\n. k i x = 0" + using h + by (meson gt_ex) + then show ?thesis by simp + qed + have h3b : "(\x.(\y. (\i\n. (k i x) * y ^ i)=0)) \ (\y. \xi\n. (k i x)* x^i)= 0)" + proof- + assume h : "(\x.(\y. (\i\n. (k i x) * y ^ i)=0))" + {fix z y x + have "(\i\n. (k i z)* x^i)= 0" + using h k_all by blast + then have "\i\n. k i z = 0" + using polyfun_eq_const[where k="0", where c = "\i. k i z", where n="n"] + by (metis h) + } + then have "\x.\i\n. k i x = 0" + by (meson gt_ex) + then show ?thesis by simp + qed + have h3 : "(\y. \xi\n. (k i x)* x^i)= 0) = (\x.(\y. (\i\n. (k i x) * y ^ i)=0))" + using h3a h3b by auto + show ?thesis using h1 h2 h3 by simp +qed + + + + +lemma freeIn_altNegInf : "freeIn var (alternateNegInfinity p var)" +proof- + have h1 : "\i. var \ (vars (if (i::nat) mod 2 = 0 then (Const(1)::real mpoly) else (Const(-1)::real mpoly)))" + using var_not_in_Const[where var = "var", where x="1"] var_not_in_Const[where var = "var", where x="-1"] + by simp + define g where "g = (\F.\i. + let a_n = isolate_variable_sparse p var i in + let exp = (if i mod 2 = 0 then Const(1) else Const(-1)) in + or (Atom(Less (exp * a_n))) + (and (Atom (Eq a_n)) F) + )" + have h3 : "\i. \F. (freeIn var F \ freeIn var (g F i))" + using g_def h1 + by (smt PolyAtoms.and_def not_in_isovarspar PolyAtoms.or_def freeIn.simps(1) freeIn.simps(2) freeIn.simps(7) freeIn.simps(8) not_in_mult) + define L where "L = ([0..<((MPoly_Type.degree p var)+1)])" + have "\F. freeIn var F \ freeIn var (foldl (g::atom fm \ nat \ atom fm) F (L::nat list))" + proof(induction L) + case Nil + then show ?case by simp + next + case (Cons a L) + then show ?case using h3 by simp + qed + then have "freeIn var (foldl g FalseF L)" + using freeIn.simps(6) by blast + then show ?thesis using g_def L_def by simp +qed + + + +theorem freeIn_substNegInfinity : "freeIn var (substNegInfinity var A)" + apply(cases A) using freeIn_altNegInf freeIn_allzero by simp_all + + +end diff --git a/thys/Virtual_Substitution/NegInfinityUni.thy b/thys/Virtual_Substitution/NegInfinityUni.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/NegInfinityUni.thy @@ -0,0 +1,632 @@ +theory NegInfinityUni + imports UniAtoms NegInfinity QE +begin + +fun allZero' :: "real * real * real \ atomUni fmUni" where + "allZero' (a,b,c) = AndUni(AndUni(AtomUni(EqUni(0,0,a))) (AtomUni(EqUni(0,0,b)))) (AtomUni(EqUni(0,0,c)))" + +lemma convert_allZero : + assumes "convert_poly var p (xs'@x#xs) = Some p'" + assumes "length xs' = var" + shows "eval (allZero p var) (xs'@x#xs) = evalUni (allZero' p') x" +proof(cases p') + case (fields a b c) + then show ?thesis proof(cases "MPoly_Type.degree p var = 0") + case True + then show ?thesis + using assms fields + by(simp add:eval_list_conj isovar_greater_degree) + next + case False + then have nonzero : "MPoly_Type.degree p var \ 0" by auto + then show ?thesis + proof(cases "MPoly_Type.degree p var = 1") + case True + then show ?thesis + using assms fields + apply(simp add:eval_list_conj isovar_greater_degree) + by (metis) + next + case False + then have degree2 : "MPoly_Type.degree p var = 2" using degree_convert_eq[OF assms(1)] nonzero by auto + then show ?thesis + using assms + apply(simp add:eval_list_conj isovar_greater_degree) + using insertion_isovarspars_free list_update_code(2) + apply auto + by (metis One_nat_def Suc_1 less_2_cases less_Suc_eq numeral_3_eq_3) + qed + qed +qed + + + +fun alternateNegInfinity' :: "real * real * real \ atomUni fmUni" where + "alternateNegInfinity' (a,b,c) = +OrUni(AtomUni(LessUni(0,0,a)))( +AndUni(AtomUni(EqUni(0,0,a))) ( + OrUni(AtomUni(LessUni(0,0,-b)))( + AndUni(AtomUni(EqUni(0,0,b)))( + AtomUni(LessUni(0,0,c)) + )) +)) +" + +lemma convert_alternateNegInfinity : + assumes "convert_poly var p (xs'@x#xs) = Some X" + assumes "length xs' = var" + shows "eval (alternateNegInfinity p var) (xs'@x#xs) = evalUni (alternateNegInfinity' X) x" +proof(cases X) + case (fields a b c) + then show ?thesis proof(cases "MPoly_Type.degree p var = 0") + case True + then show ?thesis + using assms + apply (simp add: isovar_greater_degree) + apply auto + apply (metis aEval.simps(2) eval.simps(1) eval_and eval_false eval_or mult_one_left) + by (metis aEval.simps(2) eval.simps(1) eval_or mult_one_left) + next + case False + then have nonzero : "MPoly_Type.degree p var \ 0" by auto + then show ?thesis + proof(cases "MPoly_Type.degree p var = 1") + case True + have letbind: "eval + (let a_n = isolate_variable_sparse p var (Suc 0) + in or (fm.Atom (Less (Const (- 1) * a_n))) + (and (fm.Atom (Eq a_n)) + (let a_n = isolate_variable_sparse p var 0 + in or (fm.Atom (Less (Const 1 * a_n))) (and (fm.Atom (Eq a_n)) FalseF)))) + (xs'@x#xs) = + eval + (or (fm.Atom (Less (Const (- 1) * (isolate_variable_sparse p var (Suc 0))))) + (and (fm.Atom (Eq (isolate_variable_sparse p var (Suc 0)))) + (or (fm.Atom (Less (Const 1 * (isolate_variable_sparse p var 0)))) (and (fm.Atom (Eq (isolate_variable_sparse p var 0))) FalseF)))) + (xs'@x#xs)" + by meson + show ?thesis + using assms True unfolding fields + by (simp add: isovar_greater_degree letbind eval_or eval_and insertion_mult insertion_const) + next + case False + then have degree2 : "MPoly_Type.degree p var = 2" using degree_convert_eq[OF assms(1)] nonzero by auto + have "[0..<3] = [0,1,2]" + by (simp add: upt_rec) + then have unfold : " (foldl + (\F i. let a_n = isolate_variable_sparse p var i + in or (fm.Atom (Less ((if i mod 2 = 0 then Const 1 else Const (- 1)) * a_n))) + (and (fm.Atom (Eq a_n)) F)) + FalseF [0..<3]) = + (let a_n = isolate_variable_sparse p var 2 + in or (fm.Atom (Less ((Const 1) * a_n))) + (and (fm.Atom (Eq a_n)) + (let a_n = isolate_variable_sparse p var (Suc 0) + in or (fm.Atom (Less (Const (- 1) * a_n))) + (and (fm.Atom (Eq a_n)) + (let a_n = isolate_variable_sparse p var 0 + in or (fm.Atom (Less (Const 1 * a_n))) (and (fm.Atom (Eq a_n)) FalseF))))))" + by auto + have letbind : "eval + (foldl + (\F i. let a_n = isolate_variable_sparse p var i + in or (fm.Atom (Less ((if i mod 2 = 0 then Const 1 else Const (- 1)) * a_n))) + (and (fm.Atom (Eq a_n)) F)) + FalseF [0..<3]) (xs'@x#xs) = + eval + +(or (fm.Atom (Less ( Const 1 * (isolate_variable_sparse p var 2)))) + (and (fm.Atom (Eq (isolate_variable_sparse p var 2))) +(or (fm.Atom (Less (Const (- 1) * (isolate_variable_sparse p var (Suc 0))))) + (and (fm.Atom (Eq (isolate_variable_sparse p var (Suc 0)))) + (or (fm.Atom (Less (Const 1 * (isolate_variable_sparse p var 0)))) (and (fm.Atom (Eq (isolate_variable_sparse p var 0))) FalseF)))))) +(xs'@x#xs)" apply (simp add:unfold) by metis + show ?thesis + using degree2 assms unfolding fields by (simp add: isovar_greater_degree eval_or eval_and letbind insertion_mult insertion_const) + qed + qed +qed + + + +fun substNegInfinityUni :: "atomUni \ atomUni fmUni" where + "substNegInfinityUni (EqUni p) = allZero' p " | + "substNegInfinityUni (LessUni p) = alternateNegInfinity' p"| + "substNegInfinityUni (LeqUni p) = OrUni (alternateNegInfinity' p) (allZero' p)"| + "substNegInfinityUni (NeqUni p) = negUni (allZero' p)" + + +lemma convert_substNegInfinity : + assumes "convert_atom var A (xs'@x#xs) = Some(A')" + assumes "length xs' = var" + shows "eval (substNegInfinity var A) (xs'@x#xs) = evalUni (substNegInfinityUni A') x" + using assms +proof(cases A) + case (Less p) + have "\X. convert_poly var p (xs' @ x # xs) = Some X" using assms Less apply(cases "MPoly_Type.degree p var < 3") by (simp_all) + then obtain X where X_def: "convert_poly var p (xs' @ x # xs) = Some X" by auto + then have A' : "A' = LessUni X" using assms Less apply(cases "MPoly_Type.degree p var < 3") by (simp_all) + show ?thesis unfolding Less substNegInfinity.simps + unfolding convert_alternateNegInfinity[OF X_def assms(2)] A' + apply(cases X) by simp +next + case (Eq p) + then show ?thesis using assms convert_allZero by auto +next + case (Leq p) + define p' where "p' = (case convert_poly var p (xs'@x#xs) of Some p' \ p')" + have A'_simp : "A' = LeqUni p'" + using assms Leq + using p'_def by auto + have allZ : "eval (allZero p var) (xs'@x#xs) = evalUni (allZero' p') x" using convert_allZero + using Leq assms p'_def by auto + have altNeg : "eval (alternateNegInfinity p var) (xs'@x#xs) = evalUni (alternateNegInfinity' p') x" using convert_alternateNegInfinity + using Leq assms p'_def by auto + show ?thesis + unfolding Leq substNegInfinity.simps eval_Or A'_simp substNegInfinityUni.simps evalUni.simps + using allZ altNeg by auto +next + case (Neq p) + then show ?thesis using assms convert_allZero convert_neg by auto +qed + +lemma change_eval_eq: + fixes x y:: "real" + assumes "((aEvalUni (EqUni(a,b,c)) x \ aEvalUni (EqUni(a,b,c)) y) \ x < y)" + shows "(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + using assms by auto +lemma change_eval_lt: + fixes x y:: "real" + assumes "((aEvalUni (LessUni (a,b,c)) x \ aEvalUni (LessUni (a,b,c)) y) \ x < y)" + shows "(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" +proof - + let ?p = "[:c, b, a:]" + have "sign ?p x \ sign ?p y" + using assms unfolding sign_def + apply (simp add: distrib_left mult.commute mult.left_commute power2_eq_square) + by linarith + then have "(\w \ (root_list ?p). x \ w \ w \ y)" using changes_sign + assms by auto + then obtain w where w_prop: "w \ (root_list ?p) \ x \ w \ w \ y" by auto + then have "a*w^2 + b*w + c = 0" unfolding root_list_def + using add.commute distrib_right mult.assoc mult.commute power2_eq_square + using quadratic_poly_eval by force + then show ?thesis using w_prop by auto +qed + +lemma no_change_eval_lt: + fixes x y:: "real" + assumes "x < y" + assumes "\(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + shows "((aEvalUni (LessUni (a,b,c)) x = aEvalUni (LessUni (a,b,c)) y))" + using change_eval_lt + using assms(1) assms(2) by blast + + +lemma change_eval_neq: + fixes x y:: "real" + assumes "((aEvalUni (NeqUni (a,b,c)) x \ aEvalUni (NeqUni (a,b,c)) y) \ x < y)" + shows "(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + using assms by auto + +lemma change_eval_leq: + fixes x y:: "real" + assumes "((aEvalUni (LeqUni (a,b,c)) x \ aEvalUni (LeqUni (a,b,c)) y) \ x < y)" + shows "(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" +proof - + let ?p = "[:c, b, a:]" + have "sign ?p x \ sign ?p y" + using assms unfolding sign_def + apply (simp add: distrib_left mult.commute mult.left_commute power2_eq_square) + by linarith + then have "(\w \ (root_list ?p). x \ w \ w \ y)" using changes_sign + assms by auto + then obtain w where w_prop: "w \ (root_list ?p) \ x \ w \ w \ y" by auto + then have "a*w^2 + b*w + c = 0" unfolding root_list_def + using add.commute distrib_right mult.assoc mult.commute power2_eq_square + using quadratic_poly_eval by force + then show ?thesis using w_prop by auto +qed + +lemma change_eval: + fixes x y:: "real" + fixes At:: "atomUni" + assumes xlt: "x < y" + assumes noteq: "((aEvalUni At) x \ aEvalUni (At) y)" + assumes "getPoly At = (a, b, c)" + shows "(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" +proof - + have four_types: "At = (EqUni (a,b,c)) \ At = (LessUni (a,b,c)) \ At = (LeqUni (a,b,c)) \ At = (NeqUni (a,b,c))" + using getPoly.elims assms(3) by force + have eq_h: "At = (EqUni (a,b,c)) \ (\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + using assms(1) assms(2) change_eval_eq + by blast + have less_h: "At = (LessUni(a,b,c)) \ (\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + using change_eval_lt assms + by blast + have leq_h: "At = (LeqUni(a,b,c)) \ (\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + using change_eval_leq assms + by blast + have neq_h: "At = (NeqUni(a,b,c)) \ (\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + using change_eval_neq assms + by blast + show ?thesis + using four_types eq_h less_h leq_h neq_h + by blast +qed + +lemma no_change_eval: + fixes x y:: "real" + assumes "getPoly At = (a, b, c)" + assumes "x < y" + assumes "\(\w. x \ w \ w \ y \ a*w^2 + b*w + c = 0)" + shows "((aEvalUni At) x = aEvalUni (At) y \ x < y)" + using change_eval + using assms(1) assms(2) assms(3) by blast + + +lemma same_eval'' : + assumes "getPoly At = (a, b, c)" + assumes nonz: "a \ 0 \ b \ 0 \ c \ 0" + shows "\x. \yy. poly ?p y = a*y^2 + b*y + c" + by (simp add: distrib_left power2_eq_square) + have "?p \ 0" using nonz by auto + then have "finite {y. poly ?p y = 0}" + using poly_roots_finite + by blast + then have "finite {y. c + (a * y\<^sup>2 + b * y) = 0} \ + \y. y * (b + y * a) = a * y\<^sup>2 + b * y \ + finite {y. a * y\<^sup>2 + b * y + c = 0}" + proof - + assume a1: "finite {y. c + (a * y\<^sup>2 + b * y) = 0}" + have "\x0. c + (a * x0\<^sup>2 + b * x0) = a * x0\<^sup>2 + b * x0 + c" + by simp + then show ?thesis + using a1 by presburger + qed + then have finset: "finite {y. a*y^2 + b*y + c = 0}" + using poly_eval + by (metis \finite {y. poly [:c, b, a:] y = 0}\ poly_roots_set_same) + then have "\x. (\y. a*y^2 + b*y + c = 0 \ x < y)" + proof - + let ?l = "sorted_list_of_set {y. a*y^2 + b*y + c = 0}" + have "\x. x < ?l ! 0" + using infzeros nonz by blast + then obtain x where x_prop: "x < ?l! 0" by auto + then have "\ y. List.member ?l y \ x < y" + proof clarsimp + fix y + assume "List.member ?l y" + then have "\n. n < length ?l \ ?l ! n = y" + by (meson in_set_conv_nth in_set_member) + then obtain n where n_prop: "n < length ?l \ ?l ! n = y" + by auto + have h: "\n < length ?l. ?l ! n \ ?l !0" using sorted_iff_nth_mono + using sorted_sorted_list_of_set by blast + then have h: "y \ ?l ! 0" using n_prop by auto + then show "x < y" using x_prop by auto + qed + then show ?thesis + using finset set_sorted_list_of_set in_set_member + by (metis (mono_tags, lifting) mem_Collect_eq) + qed + then obtain x where x_prop: "(\y. a*y^2 + b*y + c = 0 \ x < y)" by auto + then have same_as: "\yx0. (x0 < x) = (\ 0 \ x0 + - 1 * x)" + by auto + have f2: "(0 \ - 1 * x + v0_0) = (x + - 1 * v0_0 \ 0)" + by auto + have f3: "v0_0 + - 1 * x = - 1 * x + v0_0" + by auto + have f4: "\x0 x1 x2 x3. (x3::real) * x0\<^sup>2 + x2 * x0 + x1 = x1 + x3 * x0\<^sup>2 + x2 * x0" + by auto + have f5: "\x3 x4 x5. (aEvalUni x3 x5 \ aEvalUni x3 x4) = ((\ aEvalUni x3 x5) = aEvalUni x3 x4)" + by fastforce + have f6: "\x0 x1 x2 x3 x4 x5. (x5 < x4 \ (\ aEvalUni x3 x5) = aEvalUni x3 x4 \ getPoly x3 = (x2, x1, x0) \ (\v6\x5. v6 \ x4 \ x0 + x2 * v6\<^sup>2 + x1 * v6 = 0)) = ((\ x5 < x4 \ (\ aEvalUni x3 x5) \ aEvalUni x3 x4 \ getPoly x3 \ (x2, x1, x0)) \ (\v6\x5. v6 \ x4 \ x0 + x2 * v6\<^sup>2 + x1 * v6 = 0))" + by fastforce + have f7: "\x0 x5. ((x0::real) \ x5) = (x0 + - 1 * x5 \ 0)" + by auto + have f8: "\x0 x6. ((x6::real) \ x0) = (0 \ x0 + - 1 * x6)" + by auto + have "\x4 x5. ((x5::real) < x4) = (\ x4 + - 1 * x5 \ 0)" + by auto + then have "(\r ra a rb rc rd. r < ra \ aEvalUni a r \ aEvalUni a ra \ getPoly a = (rb, rc, rd) \ (\re\r. re \ ra \ rb * re\<^sup>2 + rc * re + rd = 0)) = (\r ra a rb rc rd. (ra + - 1 * r \ 0 \ (\ aEvalUni a r) \ aEvalUni a ra \ getPoly a \ (rb, rc, rd)) \ (\re. 0 \ re + - 1 * r \ re + - 1 * ra \ 0 \ rd + rb * re\<^sup>2 + rc * re = 0))" + using f8 f7 f6 f5 f4 by presburger + then have f9: "\r ra a rb rc rd. (ra + - 1 * r \ 0 \ (\ aEvalUni a r) \ aEvalUni a ra \ getPoly a \ (rb, rc, rd)) \ (\re. 0 \ re + - 1 * r \ re + - 1 * ra \ 0 \ rd + rb * re\<^sup>2 + rc * re = 0)" + by (meson change_eval) + obtain rr :: "real \ real \ real \ real \ real \ real" where + "\x0 x1 x2 x4 x5. (\v6. 0 \ v6 + - 1 * x5 \ v6 + - 1 * x4 \ 0 \ x0 + x2 * v6\<^sup>2 + x1 * v6 = 0) = (0 \ rr x0 x1 x2 x4 x5 + - 1 * x5 \ rr x0 x1 x2 x4 x5 + - 1 * x4 \ 0 \ x0 + x2 * (rr x0 x1 x2 x4 x5)\<^sup>2 + x1 * rr x0 x1 x2 x4 x5 = 0)" + by moura + then have f10: "\r ra a rb rc rd. ra + - 1 * r \ 0 \ aEvalUni a r = aEvalUni a ra \ getPoly a \ (rb, rc, rd) \ r + - 1 * rr rd rc rb ra r \ 0 \ 0 \ ra + - 1 * rr rd rc rb ra r \ rd + rb * (rr rd rc rb ra r)\<^sup>2 + rc * rr rd rc rb ra r = 0" + using f9 by simp + have f11: "(rr c b a x v0_0 + - 1 * x \ 0) = (0 \ x + - 1 * rr c b a x v0_0)" + by force + have "\x0. (x < x0) = (\ x0 + - 1 * x \ 0)" + by auto + then have f12: "\r. c + a * r\<^sup>2 + b * r \ 0 \ \ r + - 1 * x \ 0" + using x_prop by auto + obtain rra :: real where + "(\v0. \ 0 \ v0 + - 1 * x \ aEvalUni At v0 \ aEvalUni At x) = (\ 0 \ rra + - 1 * x \ aEvalUni At rra \ aEvalUni At x)" + by moura + then show ?thesis + using f12 f11 f10 f3 f2 f1 + proof - + have f1: "\x0. (x0 < x) = (\ 0 \ x0 + - 1 * x)" + by auto + have f2: "(0 \ v0_0a + - 1 * x) = (x + - 1 * v0_0a \ 0)" + by auto + have f3: "(rr c b a x v0_0a + - 1 * x \ 0) = (0 \ x + - 1 * rr c b a x v0_0a)" + by auto + obtain rrb :: real where + "(\v0. \ 0 \ v0 + - 1 * x \ aEvalUni At v0 \ aEvalUni At x) = (\ 0 \ rrb + - 1 * x \ aEvalUni At rrb \ aEvalUni At x)" + by blast + then show ?thesis + using f3 f2 f1 assms(1) f10 f12 + by smt + qed + qed + then show ?thesis by auto +qed + + +lemma inequality_case : "(\(x::real). \(y::real)2 + (b::real) * y + (c::real) < 0) = + (a < 0 \ a = 0 \ (0 < b \ b = 0 \ c < 0))" +proof- + let ?At = "(LessUni (a, b, c))" + have firsth : "\x. (\y2 + b * y + c < 0 \ a\0)" + proof - + fix x + assume lt: "\y2 + b * y + c < 0" + have "\w. \y < w. y^2 > (-b/a)*y - c/a" using ysq_dom_y_plus_coeff[where b = "-b/a", where c = "-c/a"] + by auto + then have gtdomhelp: "a > 0 \ \w. \y < w. a*y^2 > a*((-b/a)*y - c/a)" + by auto + have "\y. (a > 0 \ a*((-b/a)*y - c/a) = -b*y - c)" + by (simp add: right_diff_distrib') + then have gtdom: "a > 0 \ \w.\y < w. a*y^2 > -b*y - c" + using gtdomhelp + by simp + then have " a > 0 \ False" + proof - + assume "a > 0" + then have "\w.\y < w. a*y^2 > -b*y - c" using gtdom by auto + then obtain w where w_prop: "\y < w. a*y^2 + b*y + c > 0" + by fastforce + let ?mn = "min w x - 1" + have gtz: "a*?mn^2 + b*?mn + c > 0" using w_prop + by auto + have ltz: "a*?mn^2 + b*?mn + c < 0" using lt by auto + then show "False" using gtz ltz by auto + qed + then show "a \ 0" + by fastforce + qed + have bleq0 : "\x. (\y b\0)" + proof - + fix x + assume lt: "\y \w.\y < w. b*y > - c" + by (metis mult.commute neg_less_divide_eq) + then have "b < 0 \ False" + proof - + assume "b < 0" + then have "\w.\y < w. b*y > - c" using gtdom by auto + then obtain w where w_prop: "\y < w .b*y + c > 0" + by fastforce + let ?mn = "min w x - 1" + have gtz: "b*?mn + c > 0" using w_prop + by auto + have ltz: "b*?mn + c < 0" using lt by auto + then show "False" using gtz ltz by auto + qed + then show "b \ 0" + by fastforce + qed + have secondh: "\x. (\y2 + b * y + c < 0 \ \ a < 0 \ \ 0 < b \ b = 0)" + using firsth bleq0 + by (metis add.commute add.right_neutral less_eq_real_def mult_zero_class.mult_zero_left) + have thirdh : "\x. \y2 + b * y + c < 0 \ \ a < 0 \ \ 0 < b \ c < 0" + using firsth secondh add.commute add.right_neutral infzeros mult_zero_class.mult_zero_left not_numeral_le_zero order_refl + by (metis less_eq_real_def) + have fourthh : "a < 0 \ \x. \y2 + b * y + c < 0" + proof - + assume aleq: "a < 0" + have "\(w::real). \(y::real). (y < w \ y^2 > (-b/a)*y + (-c/a))" + using ysq_dom_y_plus_coeff[where b = "-b/a", where c = "-c/a"] + by blast + then have hyp:"\(w::real). \(y::real). (y < w \ a*y^2 \ a*(-b/a)*y + a*(-c/a))" + by (metis (no_types, hide_lams) \a < 0\ distrib_left less_eq_real_def linorder_not_le mult.assoc mult_less_cancel_left) + have "\y. a*(-b/a)*y + a*(-c/a) = -b*y -c" + using \a < 0\ by auto + then have "\(w::real). \(y::real). (y < w \ a*y^2 \ -b*y - c)" + using hyp by auto + then have "\(w::real). \(y::real). (y < w \ a*y^2 + b*y + c \ 0)" + by (metis add.commute add_uminus_conv_diff le_diff_eq mult_minus_left real_add_le_0_iff) + then obtain w where w_prop: "\(y::real). (y < w \ a*y^2 + b*y + c \ 0)" by auto + have "\x. \y < x. aEvalUni ?At x = aEvalUni ?At y" using same_eval'' + proof - + have f1: "\x0 x1. ((x0::real) < x1) = (\ 0 \ x0 + - 1 * x1)" + by linarith + have "a \ 0" + using \a < 0\ by force + then obtain rr :: "atomUni \ real" where + "\r. 0 \ r + - 1 * rr (LessUni (a, b, c)) \ aEvalUni (LessUni (a, b, c)) r = aEvalUni (LessUni (a, b, c)) (rr (LessUni (a, b, c)))" + using f1 by (metis getPoly.simps(4) same_eval'') + then show ?thesis + using f1 by meson + qed + then obtain x where x_prop: "\y < x. aEvalUni ?At x = aEvalUni ?At y" by auto + let ?mn = "min x w - 1" + have "\y < ?mn. aEvalUni ?At y = True \ aEvalUni ?At y = False" + using x_prop by auto + have "\ y < ?mn. aEvalUni ?At y = False \ a*y^2 + b*y + c \ 0" + by auto + then have "\y. \y2 + b * y + c \ 0 \ + y < min x w - 1 \ + \ a * y\<^sup>2 + b * y + c < 0 \ + a * y\<^sup>2 + b * y + c = 0" + proof - + fix y :: real + assume a1: "y < min x w - 1" + assume a2: "\ a * y\<^sup>2 + b * y + c < 0" + assume a3: "\y2 + b * y + c \ 0" + have "y < w" + using a1 by linarith + then show "a * y\<^sup>2 + b * y + c = 0" + using a3 a2 less_eq_real_def by blast + qed + then have "\ y < ?mn. aEvalUni ?At y = False \ a*y^2 + b*y + c = 0" + using w_prop by auto + then have "\ y < ?mn. aEvalUni ?At y = False \ False" using infzeros aleq + by (metis power_zero_numeral zero_less_power2) + then have "\ y < ?mn. aEvalUni ?At y = True" + proof - + { fix rr :: real + have "\r ra. (ra::real) < r \ \ ra < r + - 1" + by linarith + then have "\ rr < min x w - 1 \ aEvalUni (LessUni (a, b, c)) rr" + by (metis (no_types) \\y False\ ab_group_add_class.ab_diff_conv_add_uminus less_eq_real_def min_less_iff_disj not_le x_prop) } + then show ?thesis + by blast + qed + then show ?thesis by auto + qed + have fifthh : "b > 0 \ \x. \y 0" + show "\x. \y(x::real). \(y::real)2 + (b::real) * y + (c::real) > 0) = + (a > 0 \ a = 0 \ (0 > b \ b = 0 \ c > 0))" +proof - + have s1: "\y. - 1 * a * y\<^sup>2 + - 1 * b * y + - 1 * c < 0 \ a * y\<^sup>2 + b * y + c > 0" + by auto + have s2: "(- 1 * a < 0 \ - 1 * a = 0 \ (0 < - 1 * b \ - 1 * b = 0 \ - 1 * c < 0)) \ + (a > 0 \ a = 0 \ (0 > b \ b = 0 \ c > 0)) " + by auto + have "(\x. \y2 + - 1 * b * y + - 1 * c < 0) = + (- 1 * a < 0 \ - 1 * a = 0 \ (0 < - 1 * b \ - 1 * b = 0 \ - 1 * c < 0))" + using inequality_case[where a = "-1*a", where b = "-1*b", where c= "-1*c"] + by auto + then show ?thesis + using s1 s2 by auto +qed + +lemma infinity_evalUni_LessUni : "(\x. \yx. \yx. \yx. \yx. \y2 + b * y + c < 0) \ (\x. \y2 + b * y + c = 0)) \ (\x. \y2 + b * y + c \ 0)" + using less_eq_real_def + by auto + have h2: "(\x. \y2 + b * y + c \ 0) \ ((\x. \y2 + b * y + c < 0) \ (\x. \y2 + b * y + c = 0))" + proof - + assume a1: "(\x. \y2 + b * y + c \ 0)" + have "\(\x. \y2 + b * y + c = 0) \ (\x. \y2 + b * y + c < 0) " + proof - + assume a2: "\(\x. \y2 + b * y + c = 0)" + then have "a \ 0 \ b \ 0 \ c \ 0" by auto + then have "(a < 0 \ a = 0 \ (0 < b \ b = 0 \ c < 0))" + proof - + have x1: "a > 0 \ False" + proof - + assume "a > 0" + then have "(\(x::real). \(y::real)2 + (b::real) * y + (c::real) > 0)" using inequality_case_geq + by auto + then show ?thesis + using a1 + by (meson a2 linorder_not_le min_less_iff_conj) + qed + then have x2: "a = 0 \ 0 > b \ False" + proof - + assume "a = 0 \ 0 > b" + then have "(\(x::real). \(y::real)2 + (b::real) * y + (c::real) > 0)" using inequality_case_geq + by blast + then show ?thesis + using a1 + by (meson a2 linorder_not_le min_less_iff_conj) + qed + then have x3: "a = 0 \ b = 0 \ c > 0 \ False " + using a1 a2 by auto + show ?thesis using x1 x2 x3 + by (meson \a \ 0 \ b \ 0 \ c \ 0\ linorder_neqE_linordered_idom) + qed + then show "(\x. \y2 + b * y + c < 0)" using inequality_case + by auto + qed + then show ?thesis + by auto + qed + have "(\x. \y2 + b * y + c \ 0) = (\x. \y2 + b * y + c < 0) \ (\x. \y2 + b * y + c = 0)" + using h1 h2 by auto + then show "(\x. \y2 + b * y + c \ 0) = + (a < 0 \ a = 0 \ (0 < b \ b = 0 \ c < 0) \ a = 0 \ b = 0 \ c = 0)" + using inequality_case[of a b c] infzeros[of _ a b c] by auto + qed +qed + +text "This is the vertical translation for substNegInfinityUni where we represent the virtual +substution of negative infinity in the univariate case" +lemma infinity_evalUni : + shows "(\x. \y\. (\ eval (nnf (Neg \)) \) = eval (nnf \) \" + apply(induction \) + apply(simp_all) + using aNeg_aEval apply blast + using aNeg_aEval by blast + +theorem eval_nnf : "\\. eval \ \ = eval (nnf \) \" + apply(induction \)apply(simp_all) using neg_nnf by blast + + +theorem negation_free_nnf : "negation_free (nnf \)" +proof(induction "depth \" arbitrary : \ rule: nat_less_induct ) + case 1 + then show ?case + proof(induction \) + case (And \1 \2) + then show ?case apply simp + by (metis less_Suc_eq_le max.cobounded1 max.cobounded2) + next + case (Or \1 \2) + then show ?case apply simp + by (metis less_Suc_eq_le max.cobounded1 max.cobounded2) + next + case (Neg \) + then show ?case proof (induction \) + case (And \1 \2) + then show ?case apply simp + by (metis less_Suc_eq max_less_iff_conj not_less_eq) + next + case (Or \1 \2) + then show ?case apply simp + by (metis less_Suc_eq max_less_iff_conj not_less_eq) + next + case (Neg \) + then show ?case + by (metis Suc_eq_plus1 add_lessD1 depth.simps(6) lessI nnf.simps(12)) + qed auto + qed auto +qed + + +lemma groupQuantifiers_eval : "eval F L = eval (groupQuantifiers F) L" + apply(induction F arbitrary: L rule:groupQuantifiers.induct) + unfolding doubleExist unwrapExist unwrapExist' unwrapExist'' doubleForall unwrapForall unwrapForall' unwrapForall'' + apply (auto) + using doubleExist doubleExist unwrapExist unwrapExist' unwrapExist'' doubleForall unwrapForall unwrapForall' unwrapForall'' apply auto + by metis+ + + +theorem simp_atom_eval : "aEval a xs = eval (simp_atom a) xs" +proof(cases a) + case (Less p) + then show ?thesis by(cases "get_if_const p")(simp_all add:get_if_const_insertion) +next + case (Eq p) + then show ?thesis by(cases "get_if_const p")(simp_all add:get_if_const_insertion) +next + case (Leq p) + then show ?thesis by(cases "get_if_const p")(simp_all add:get_if_const_insertion) +next + case (Neq p) + then show ?thesis by(cases "get_if_const p")(simp_all add:get_if_const_insertion) +qed + +lemma simpfm_eval : "\L. eval \ L = eval (simpfm \) L" + apply(induction \) + apply(simp_all add: simp_atom_eval eval_and eval_or) + using eval_neg by blast + +lemma exQ_clearQuantifiers: + assumes ExQ : "\xs. eval (clearQuantifiers \) xs = eval \ xs" + shows "eval (clearQuantifiers (ExQ \)) xs = eval (ExQ \) xs" +proof- + define \' where "\' = clearQuantifiers \" + have h : "freeIn 0 \' \ (eval (lowerFm 0 1 \') xs = eval (ExQ \') xs)" + using eval_lowerFm by simp + have "eval (clearQuantifiers (ExQ \)) xs = + eval (if freeIn 0 \' then lowerFm 0 1 \' else ExQ \') xs" + using \'_def by simp + also have "... = eval (ExQ \) xs" + apply(cases "freeIn 0 \'") + using h ExQ \'_def by(simp_all) + finally show ?thesis + by simp +qed + +lemma allQ_clearQuantifiers : + assumes AllQ : "\xs. eval (clearQuantifiers \) xs = eval \ xs" + shows "eval (clearQuantifiers (AllQ \)) xs = eval (AllQ \) xs" +proof- + define \' where "\' = clearQuantifiers \" + have "freeIn 0 \' \ (eval (ExQ \') xs) = eval (AllQ \') xs" + by (simp add: var_not_in_eval2) + then have h : "freeIn 0 \' \ (eval (lowerFm 0 1 \') xs = eval (AllQ \') xs)" + using eval_lowerFm by simp + have "eval (clearQuantifiers (AllQ \)) xs = + eval (if freeIn 0 \' then lowerFm 0 1 \' else AllQ \') xs" + using \'_def by simp + also have "... = eval (AllQ \) xs" + apply(cases "freeIn 0 \'") + using h AllQ \'_def by(simp_all) + finally show ?thesis + by simp +qed + +lemma clearQuantifiers_eval : "eval (clearQuantifiers \) xs = eval \ xs" +proof(induction \ arbitrary : xs) + case (Atom x) + then show ?case using simp_atom_eval by simp +next + case (And \1 \2) + then show ?case using eval_and by simp +next + case (Or \1 \2) + then show ?case using eval_or by simp +next + case (Neg \) + then show ?case using eval_neg by auto +next + case (ExQ \) + then show ?case using exQ_clearQuantifiers by simp +next + case (AllQ \) + then show ?case using allQ_clearQuantifiers by simp +next + case (ExN x1 \) + then show ?case proof(induction x1 arbitrary:\) + case 0 + then show ?case by auto + next + case (Suc x1) + show ?case + using Suc(1)[of "ExQ \", OF exQ_clearQuantifiers[OF Suc(2)]] + apply simp + using Suc_eq_plus1 \eval (clearQuantifiers (ExN x1 (ExQ \))) xs = eval (ExN x1 (ExQ \)) xs\ eval.simps(10) unwrapExist' by presburger + qed +next + case (AllN x1 \) + then show ?case proof(induction x1 arbitrary:\) + case 0 + then show ?case by auto + next + case (Suc x1) + show ?case + using Suc(1)[of "AllQ \", OF allQ_clearQuantifiers[OF Suc(2)]] + apply simp + using unwrapForall' by force + qed +qed auto + +lemma push_forall_eval_AllQ : "\xs. eval (AllQ \) xs = eval (push_forall (AllQ \)) xs" +proof(induction \) + case TrueF + then show ?case by simp +next + case FalseF + then show ?case by simp +next + case (Atom x) + then show ?case + using aEval_lowerAtom eval.simps(1) eval.simps(8) push_forall.simps(11) by presburger +next + case (And \1 \2) + {fix xs + have "eval (AllQ (And \1 \2)) xs = (\x. eval \1 (x#xs) \ eval \2 (x#xs))" + by simp + also have "... = ((\x. eval \1 (x#xs)) \ (\x. eval \2 (x#xs)))" + by blast + also have "... = eval (push_forall (AllQ (And \1 \2))) xs" + using And eval_and by(simp) + finally have "eval (AllQ (And \1 \2)) xs = eval (push_forall (AllQ (And \1 \2))) xs" + by simp + } + then show ?case by simp +next + case (Or \1 \2) + then show ?case proof(cases "freeIn 0 \1") + case True + then have h : "freeIn 0 \1" + by simp + then show ?thesis proof(cases "freeIn 0 \2") + case True + {fix xs + have "\x. eval \1 (x # xs) = eval (lowerFm 0 1 \1) xs" + using eval_lowerFm h eval.simps(7) by blast + then have h1 : "\x. eval \1 (x # xs) = eval (lowerFm 0 1 \1) xs" + using h var_not_in_eval2 by blast + have "\x. eval \2 (x # xs) = eval (lowerFm 0 1 \2) xs" + using eval_lowerFm True eval.simps(7) by blast + then have h2 : "\x. eval \2 (x # xs) = eval (lowerFm 0 1 \2) xs" + using True var_not_in_eval2 by blast + have "eval (AllQ (Or \1 \2)) xs = eval (push_forall (AllQ (Or \1 \2))) xs" + by(simp add:h h1 h2 True eval_or) + } + then show ?thesis by simp + next + case False + {fix xs + have "\x. eval \1 (x # xs) = eval (lowerFm 0 1 \1) xs" + using eval_lowerFm h eval.simps(7) by blast + then have "\x. eval \1 (x # xs) = eval (lowerFm 0 1 \1) xs" + using True var_not_in_eval2 by blast + then have "eval (AllQ (Or \1 \2)) xs = eval (push_forall (AllQ (Or \1 \2))) xs" + by(simp add:h False eval_or) + } + then show ?thesis by simp + qed + next + case False + then have h : "\freeIn 0 \1" + by simp + then show ?thesis proof(cases "freeIn 0 \2") + case True + {fix xs + have "\x. eval \2 (x # xs) = eval (lowerFm 0 1 \2) xs" + using eval_lowerFm True eval.simps(7) by blast + then have "\x. eval \2 (x # xs) = eval (lowerFm 0 1 \2) xs" + using True var_not_in_eval2 by blast + then have "eval (AllQ (Or \1 \2)) xs = eval (push_forall (AllQ (Or \1 \2))) xs" + by(simp add:h True eval_or) + } + then show ?thesis by simp + next + case False + then show ?thesis by(simp add:h False eval_or) + qed + qed +next + case (Neg \) + {fix xs + have "freeIn 0 (Neg \) \ (eval (ExQ (Neg \)) xs) = eval (AllQ (Neg \)) xs" + using var_not_in_eval2 eval.simps(7) eval.simps(8) by blast + then have h : "freeIn 0 (Neg \) \ (eval (lowerFm 0 1 (Neg \)) xs = eval (AllQ (Neg \)) xs)" + using eval_lowerFm by blast + have "eval (push_forall (AllQ (Neg \))) xs = + eval (if freeIn 0 (Neg \) then lowerFm 0 1 (Neg \) else AllQ (Neg \)) xs" + by simp + also have "... = eval (AllQ (Neg \)) xs" + apply(cases "freeIn 0 (Neg \)") + using h by(simp_all) + finally have "eval (push_forall (AllQ (Neg \))) xs = eval (AllQ (Neg \)) xs" + by simp + } + then show ?case by simp +next + case (ExQ \) + {fix xs + have "freeIn 0 (ExQ \) \ (eval (ExQ (ExQ \)) xs) = eval (AllQ (ExQ \)) xs" + using var_not_in_eval2 eval.simps(7) eval.simps(8) by blast + then have h : "freeIn 0 (ExQ \) \ (eval (lowerFm 0 1 (ExQ \)) xs = eval (AllQ (ExQ \)) xs)" + using eval_lowerFm by blast + have "eval (push_forall (AllQ (ExQ \))) xs = + eval (if freeIn 0 (ExQ \) then lowerFm 0 1 (ExQ \) else AllQ (ExQ \)) xs" + by simp + also have "... = eval (AllQ (ExQ \)) xs" + apply(cases "freeIn 0 (ExQ \)") + using h by(simp_all) + finally have "eval (push_forall (AllQ (ExQ \))) xs = eval (AllQ (ExQ \)) xs" + by simp + } + then show ?case by simp +next + case (AllQ \) + {fix xs + have "freeIn 0 (AllQ \) \ (eval (ExQ (AllQ \)) xs) = eval (AllQ (AllQ \)) xs" + using var_not_in_eval2 eval.simps(7) eval.simps(8) by blast + then have h : "freeIn 0 (AllQ \) \ (eval (lowerFm 0 1 (AllQ \)) xs = eval (AllQ (AllQ \)) xs)" + using eval_lowerFm by blast + have "eval (push_forall (AllQ (AllQ \))) xs = + eval (if freeIn 0 (AllQ \) then lowerFm 0 1 (AllQ \) else AllQ (AllQ \)) xs" + by simp + also have "... = eval (AllQ (AllQ \)) xs" + apply(cases "freeIn 0 (AllQ \)") + using h AllQ by(simp_all) + finally have "eval (push_forall (AllQ (AllQ \))) xs = eval (AllQ (AllQ \)) xs" + by simp + } + then show ?case by simp +next + case (ExN x1 \) + then show ?case + using eval.simps(7) eval.simps(8) eval_lowerFm push_forall.simps(17) var_not_in_eval2 by presburger +next + case (AllN x1 \) + then show ?case + using eval.simps(7) eval.simps(8) eval_lowerFm push_forall.simps(18) var_not_in_eval2 by presburger +qed + +lemma push_forall_eval : "\xs. eval \ xs = eval (push_forall \) xs" +proof(induction \) + case (Atom x) + then show ?case using simp_atom_eval by simp +next + case (And \1 \2) + then show ?case using eval_and by auto +next + case (Or \1 \2) + then show ?case using eval_or by auto +next + case (Neg \) + then show ?case using eval_neg by auto +next + case (AllQ \) + then show ?case using push_forall_eval_AllQ by blast +next + case (ExN x1 \) + then show ?case + using eval.simps(10) push_forall.simps(7) by presburger +qed auto + +lemma map_fm_binders_negation_free : + assumes "negation_free \" + shows "negation_free (map_fm_binders f \ n)" + using assms apply(induction \ arbitrary : n) by auto + +lemma negation_free_and : + assumes "negation_free \" + assumes "negation_free \" + shows "negation_free (and \ \)" + using assms unfolding and_def by simp + +lemma negation_free_or : + assumes "negation_free \" + assumes "negation_free \" + shows "negation_free (or \ \)" + using assms unfolding or_def by simp + +lemma push_forall_negation_free_all : + assumes "negation_free \" + shows "negation_free (push_forall (AllQ \))" + using assms proof(induction \) + case (And \1 \2) + show ?case apply auto + apply(rule negation_free_and) + using And by auto +next + case (Or \1 \2) + show ?case + apply auto + apply(rule negation_free_or) + using Or map_fm_binders_negation_free negation_free_or by auto +next + case (ExQ \) + then show ?case using map_fm_binders_negation_free by auto +next + case (AllQ \) + then show ?case using map_fm_binders_negation_free by auto +next + case (ExN x1 \) + then show ?case using map_fm_binders_negation_free by auto +next + case (AllN x1 \) + then show ?case using map_fm_binders_negation_free by auto +qed auto + +lemma push_forall_negation_free : + assumes "negation_free \" + shows "negation_free(push_forall \)" + using assms proof(induction \) + case (Atom A) + then show ?case apply(cases A) by auto +next + case (And \1 \2) + then show ?case by (auto simp add: and_def) +next + case (Or \1 \2) + then show ?case by (auto simp add: or_def) +next + case (AllQ \) + then show ?case using push_forall_negation_free_all by auto +qed auto + + +lemma to_list_insertion: "insertion f p = sum_list [insertion f term * (f v) ^ i. (term,i)\(to_list v p)]" +proof- + have h1 : "insertion f p = insertion f (\i\MPoly_Type.degree p v. isolate_variable_sparse p v i * Var v ^ i)" + using sum_over_zero by auto + have h2 : "insertion f (Var v) = f v" by (auto simp: monomials_Var coeff_Var insertion_code) + define d where "d = MPoly_Type.degree p v" + define g where "g = (\x. insertion f (isolate_variable_sparse p v x) * f v ^ x)" + have h3 : "insertion f (isolate_variable_sparse p v d) * f v ^ d = g d" using g_def by auto + show ?thesis unfolding h1 + insertion_sum' insertion_mult insertion_pow h2 apply auto unfolding d_def[symmetric] g_def[symmetric] + h3 proof(induction d) + case 0 + then show ?case by auto + next + case (Suc d) + show ?case + apply (auto simp add: Suc ) unfolding g_def by auto + qed +qed + +lemma to_list_p: "p = sum_list [term * (Var v) ^ i. (term,i)\(to_list v p)]" +proof- + define d where "d = MPoly_Type.degree p v" + have "(\i\MPoly_Type.degree p v. isolate_variable_sparse p v i * Var v ^ i) = (\(term, i)\to_list v p. term * Var v ^ i)" + unfolding to_list.simps d_def[symmetric] apply(induction d) by auto + then show ?thesis + using sum_over_zero[of p v] + by auto +qed + + +fun chophelper :: "(real mpoly * nat) list \ (real mpoly * nat) list \ (real mpoly * nat) list * (real mpoly * nat) list" where + "chophelper [] L = (L,[])"| + "chophelper ((p,i)#L) R = (if p=0 then chophelper L (R @ [(p,i)]) else (R,(p,i)#L))" + +lemma preserve : + assumes "(a,b)=chophelper L L'" + shows "a@b=L'@L" + using assms +proof(induction L arbitrary : a b L') + case Nil + then show ?case using assms by auto +next + case (Cons A L) + then show ?case proof(cases A) + case (Pair p i) + show ?thesis using Cons unfolding Pair apply(cases "p=0") by auto + qed +qed +lemma compare : + assumes "(a,b)=chophelper L L'" + shows "chop L = b" + using assms +proof(induction L arbitrary : a b L') + case Nil + then show ?case by auto +next + case (Cons A L) + then show ?case proof(cases A) + case (Pair p i) + show ?thesis using Cons unfolding Pair apply(cases "p=0") by auto + qed +qed +lemma allzero: + assumes "\(p,i)\set(L'). p=0" + assumes "(a,b)=chophelper L L'" + shows "\(p,i)\set(a). p=0" + using assms proof(induction L arbitrary : a b L') + case Nil + then show ?case by auto +next + case (Cons t L) + then show ?case + proof(cases t) + case (Pair p i) + show ?thesis proof(cases "p=0") + case True + have h1: "\x\set (L' @ [(0, i)]). case x of (p, i) \ p = 0" + using Cons(2) by auto + show ?thesis using Cons(1)[OF h1] Cons(3) True unfolding Pair by auto + next + case False + then show ?thesis using Cons unfolding Pair by auto + qed + qed +qed + +lemma separate: + assumes "(a,b)=chophelper (to_list v p) []" + shows "insertion f p = sum_list [insertion f term * (f v) ^ i. (term,i)\a] + sum_list [insertion f term * (f v) ^ i. (term,i)\b]" + using to_list_insertion[of f p v] preserve[OF assms, symmetric] unfolding List.append.left_neutral + by (simp del: to_list.simps) + +lemma chopped : + assumes "(a,b)=chophelper (to_list v p) []" + shows "insertion f p = sum_list [insertion f term * (f v) ^ i. (term,i)\b]" +proof- + have h1 : "\(p, i)\set []. p = 0" by auto + have "(\(term, i)\a. insertion f term * f v ^ i) = 0" + using allzero[OF h1 assms] proof(induction a) + case Nil + then show ?case by auto + next + case (Cons a1 a2) + then show ?case + apply(cases a1) by simp + qed + then show ?thesis using separate[OF assms, of f] by auto +qed + +lemma insertion_chop : + shows "insertion f p = sum_list [insertion f term * (f v) ^ i. (term,i)\(chop (to_list v p))]" +proof(cases "chophelper (to_list v p) []") + case (Pair a b) + show ?thesis using chopped[OF Pair[symmetric], of f] unfolding compare[OF Pair[symmetric], symmetric] . +qed + +lemma sorted : "sorted_wrt (\(_,i).\(_,i'). ix. (isolate_variable_sparse p v x, x)) [0..x. (isolate_variable_sparse p v x, x)) [0..(chop (to_list v p))] * (f v)^i" +proof- + have h : "sorted_wrt (\(_, i) (_, y). i < y) (chop (to_list v p))" + proof- + define L where "L = to_list v p" + show ?thesis using sublist[of "to_list v p"] sorted[of v p] unfolding L_def[symmetric] + by (metis sorted_wrt_append sublist_def) + qed + then have "\(term,d)\set(chop (to_list v p)). d\i" + unfolding assms[symmetric] by fastforce + then have simp : "\(term,d)\set(chop(to_list v p)). f v ^ (d - i) * f v ^ i = f v ^ d" + unfolding HOL.no_atp(118) by(auto simp del: to_list.simps) + have "insertion f p = sum_list [insertion f term * (f v) ^ i. (term,i)\(chop (to_list v p))]" using insertion_chop[of f p v] . + also have "...= (\(term, d)\chop (to_list v p). insertion f term * f v ^ (d-i) * f v ^ i)" + using simp + by (smt Pair_inject case_prodE map_eq_conv mult.assoc split_cong) + also have "... = (\(term, d)\chop (to_list v p). insertion f term * f v ^ (d - i)) * f v ^ i" + proof- + define d where "d = chop(to_list v p)" + define a where "a = f v ^ i" + define b where "b = (\(term, d). insertion f term * f v ^ (d - i))" + have h : "(\(term, d)\d. insertion f term * f v ^ (d - i) * a) = (\(term, d)\d. b (term,d) * a)" + using b_def by auto + show ?thesis unfolding d_def[symmetric] a_def[symmetric] b_def[symmetric] h apply(induction d) apply simp apply auto + by (simp add: ring_class.ring_distribs(2)) + qed + finally show ?thesis by auto +qed + +lemma insert_Var_Zero : "insertion f (Var v) = f v" + unfolding insertion_code monomials_Var apply auto + unfolding coeff_Var by simp + + +lemma decreasePower_insertion : + assumes "decreasePower v p = (p',i)" + shows "insertion f p = insertion f p'* (f v)^i" +proof(cases "chop (to_list v p)") + case Nil + then show ?thesis + using assms by auto +next + case (Cons a list) + then show ?thesis + proof(cases a) + case (Pair coef i') + have i'_def : "i'=i" using Cons assms Pair by auto + have chop: "chop (to_list v p) = (coef, i) # list" using Cons assms unfolding i'_def Pair by auto + have p'_def : "p' = (\(term, x)\chop (to_list v p). term * Var v ^ (x - i))" + using assms Cons Pair by auto + have p'_insertion : "insertion f p' = (\(term, x)\chop (to_list v p). insertion f term * f v ^ (x - i))" + proof- + define d where "d = chop (to_list v p)" + have "insertion f p' = insertion f (\(term, x)\chop (to_list v p). term * Var v ^ (x - i))" using p'_def by auto + also have "... = (\(term, x)\chop (to_list v p). insertion f (term * Var v ^ (x - i)))" + unfolding d_def[symmetric] apply(induction d) apply simp apply(simp add:insertion_add) by auto + also have "... = (\(term, x)\chop (to_list v p). insertion f term * f v ^ (x - i))" unfolding insertion_mult insertion_pow insert_Var_Zero by auto + finally show ?thesis by auto + qed + have h : "(coef, i') # list = chop (to_list v p)" using Cons unfolding Pair by auto + show ?thesis unfolding p'_insertion + using move_exp[OF h, of f] unfolding i'_def . + qed +qed + + +lemma unpower_eval: "eval (unpower v \) L = eval \ L" +proof(induction \ arbitrary: v L) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom At) + then show ?case proof(cases At) + case (Less p) + obtain q i where h: "decreasePower v p = (q, i)" + using prod.exhaust_sel by blast + have p : "\f. insertion f p = insertion f q* (f v)^i" + using decreasePower_insertion[OF h] by auto + show ?thesis + proof(cases "i=0") + case True + then show ?thesis unfolding Less unpower.simps h by auto + next + case False + obtain x where x_def : "Suc x = i" using False + using not0_implies_Suc by auto + have h1 : "i mod 2 = 0 \ + (insertion (nth_default 0 L) q < 0 \ + insertion (nth_default 0 L) (Var v) \ 0) = + (insertion (nth_default 0 L) q * nth_default 0 L v ^ i < 0)" + proof - + assume "i mod 2 = 0" + then have "\r. \ (r::real) ^ i < 0" + by presburger + then show ?thesis + by (metis \\thesis. (\x. Suc x = i \ thesis) \ thesis\ insert_Var_Zero linorder_neqE_linordered_idom mult_less_0_iff power_0_Suc power_eq_0_iff) + qed + show ?thesis unfolding Less unpower.simps h x_def[symmetric] apply simp + unfolding x_def p apply(cases "i mod 2 = 0") using h1 apply simp_all + by (smt insert_Var_Zero insertion_neg mod_Suc mod_eq_0D mult_less_0_iff nat.inject odd_power_less_zero power_0 power_Suc0_right power_eq_0_iff x_def zero_less_Suc zero_less_power) + qed + next + case (Eq p) + obtain q i where h: "decreasePower v p = (q, i)" + using prod.exhaust_sel by blast + have p : "\f. insertion f p = insertion f q* (f v)^i" + using decreasePower_insertion[OF h] by auto + show ?thesis unfolding Eq unpower.simps h apply simp apply(cases i) apply simp + apply simp unfolding p apply simp + by (metis insert_Var_Zero) + next + case (Leq p) + obtain q i where h: "decreasePower v p = (q, i)" + using prod.exhaust_sel by blast + have p : "\f. insertion f p = insertion f q* (f v)^i" + using decreasePower_insertion[OF h] by auto + show ?thesis + proof(cases "i=0") + case True + then show ?thesis unfolding Leq unpower.simps h by auto + next + case False + obtain x where x_def : "Suc x = i" using False + using not0_implies_Suc by auto + define a where "a = insertion (nth_default 0 L) q" + define x' where "x' = nth_default 0 L v" + show ?thesis unfolding Leq unpower.simps h x_def[symmetric] apply simp + unfolding x_def p apply(cases "i mod 2 = 0") unfolding insert_Var_Zero insertion_mult insertion_pow insertion_neg apply simp_all + unfolding a_def[symmetric] x'_def[symmetric] + proof- + assume "i mod 2 = 0" + then have "x' ^ i \0" + by (simp add: \i mod 2 = 0\ even_iff_mod_2_eq_zero zero_le_even_power) + then show "(a \ 0 \ x' = 0) = (a * x' ^ i \ 0)" + using Rings.ordered_semiring_0_class.mult_nonpos_nonneg[of a "x'^i"] + apply auto + unfolding Rings.linordered_ring_strict_class.mult_le_0_iff + apply auto + by (simp add: False power_0_left) + next + assume h: "i mod 2 = Suc 0" + show "(a = 0 \ a < 0 \ 0 \ x' \ 0 < a \ x' \ 0) = (a * x' ^ i \ 0)" + using h + by (smt even_iff_mod_2_eq_zero mult_less_cancel_right mult_neg_neg mult_nonneg_nonpos mult_pos_pos not_mod2_eq_Suc_0_eq_0 power_0_Suc x_def zero_le_power_eq zero_less_mult_pos2 zero_less_power) + qed + qed + next + case (Neq p) + obtain q i where h: "decreasePower v p = (q, i)" + using prod.exhaust_sel by blast + have p : "\f. insertion f p = insertion f q* (f v)^i" + using decreasePower_insertion[OF h] by auto + show ?thesis unfolding Neq unpower.simps h apply simp apply(cases i) apply simp + apply simp unfolding p apply simp + by (metis insert_Var_Zero) + qed +qed auto + +lemma to_list_filter: "p = sum_list [term * (Var v) ^ i. (term,i)\((filter (\(x,_). x\0) (to_list v p)))]" +proof- + define L where "L = to_list v p" + have "(\(term, i)\to_list v p. term * Var v ^ i) = (\(term, i)\filter (\(x, _). x \ 0) (to_list v p). term * Var v ^ i)" + unfolding L_def[symmetric] apply(induction L) by auto + then show ?thesis + using to_list_p[of p v] by auto +qed + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/Optimizations.thy b/thys/Virtual_Substitution/Optimizations.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/Optimizations.thy @@ -0,0 +1,186 @@ +section "Optimizations" +theory Optimizations + imports Debruijn +begin + +text "Does negation normal form conversion" +fun nnf :: "atom fm \ atom fm" where + "nnf TrueF = TrueF" | + "nnf FalseF = FalseF " | + "nnf (Atom a) = Atom a" | + "nnf (And \\<^sub>1 \\<^sub>2) = And (nnf \\<^sub>1) (nnf \\<^sub>2)" | + "nnf (Or \\<^sub>1 \\<^sub>2) = Or (nnf \\<^sub>1) (nnf \\<^sub>2)" | + "nnf (ExQ \) = ExQ (nnf \)" | + "nnf (AllQ \) = AllQ (nnf \)"| + "nnf (AllN i \) = AllN i (nnf \)"| + "nnf (ExN i \) = ExN i (nnf \)" | + "nnf (Neg TrueF) = FalseF" | + "nnf (Neg FalseF) = TrueF" | + "nnf (Neg (Neg \)) = (nnf \)" | + "nnf (Neg (And \\<^sub>1 \\<^sub>2)) = (Or (nnf (Neg \\<^sub>1)) (nnf (Neg \\<^sub>2)))" | + "nnf (Neg (Or \\<^sub>1 \\<^sub>2)) = (And (nnf (Neg \\<^sub>1)) (nnf (Neg \\<^sub>2)))" | + "nnf (Neg (Atom a)) = Atom(aNeg a)" | + "nnf (Neg (ExQ \)) = AllQ (nnf (Neg \))" | + "nnf (Neg (AllQ \)) = ExQ (nnf (Neg \))"| + "nnf (Neg (AllN i \)) = ExN i (nnf (Neg \))"| + "nnf (Neg (ExN i \)) = AllN i (nnf (Neg \))" + + +subsection "Simplify Constants" + +fun simp_atom :: "atom \ atom fm" where + "simp_atom (Eq p) = (case get_if_const p of None \ Atom(Eq p) | Some(r) \ (if r=0 then TrueF else FalseF))"| + "simp_atom (Less p) = (case get_if_const p of None \ Atom(Less p) | Some(r) \ (if r<0 then TrueF else FalseF))"| + "simp_atom (Leq p) = (case get_if_const p of None \ Atom(Leq p) | Some(r) \ (if r\0 then TrueF else FalseF))"| + "simp_atom (Neq p) = (case get_if_const p of None \ Atom(Neq p) | Some(r) \ (if r\0 then TrueF else FalseF))" + +fun simpfm :: "atom fm \ atom fm" where + "simpfm TrueF = TrueF"| + "simpfm FalseF = FalseF"| + "simpfm (Atom a) = simp_atom a"| + "simpfm (And \ \) = and (simpfm \) (simpfm \)"| + "simpfm (Or \ \) = or (simpfm \) (simpfm \)"| + "simpfm (ExQ \) = ExQ (simpfm \)"| + "simpfm (Neg \) = neg (simpfm \)"| + "simpfm (AllQ \) = AllQ(simpfm \)"| + "simpfm (AllN i \) = AllN i (simpfm \)"| + "simpfm (ExN i \) = ExN i (simpfm \)" + + +subsection "Group Quantifiers" + +fun groupQuantifiers :: "atom fm \ atom fm" where + "groupQuantifiers TrueF = TrueF"| + "groupQuantifiers FalseF = FalseF"| + "groupQuantifiers (And A B) = And (groupQuantifiers A) (groupQuantifiers B)"| + "groupQuantifiers (Or A B) = Or (groupQuantifiers A) (groupQuantifiers B)"| + "groupQuantifiers (Neg A) = Neg (groupQuantifiers A)"| + "groupQuantifiers (Atom A) = Atom A"| + "groupQuantifiers (ExQ (ExQ A)) = groupQuantifiers (ExN 2 A)"| + "groupQuantifiers (ExQ (ExN j A)) = groupQuantifiers (ExN (j+1) A)"| + "groupQuantifiers (ExN j (ExQ A)) = groupQuantifiers (ExN (j+1) A)"| + "groupQuantifiers (ExN i (ExN j A)) = groupQuantifiers (ExN (i+j) A)"| + "groupQuantifiers (ExQ A) = ExQ (groupQuantifiers A)"| + "groupQuantifiers (AllQ (AllQ A)) = groupQuantifiers (AllN 2 A)"| + "groupQuantifiers (AllQ (AllN j A)) = groupQuantifiers (AllN (j+1) A)"| + "groupQuantifiers (AllN j (AllQ A)) = groupQuantifiers (AllN (j+1) A)"| + "groupQuantifiers (AllN i (AllN j A)) = groupQuantifiers (AllN (i+j) A)"| + "groupQuantifiers (AllQ A) = AllQ (groupQuantifiers A)"| + "groupQuantifiers (AllN j A) = AllN j A"| + "groupQuantifiers (ExN j A) = ExN j A" + +subsection "Clear Quantifiers" + +text "clearQuantifiers F goes through the formula F and removes all quantifiers who's variables +are not present in the formula. For example, clearQuantifiers (ExQ(TrueF)) evaluates to TrueF. This +preserves the truth value of the formula as shown in the clearQuantifiers\\_eval proof. This is used +within the QE overall procedure to eliminate quantifiers in the cases where QE was successful." +fun depth' :: "'a fm \ nat"where + "depth' TrueF = 1"| + "depth' FalseF = 1"| + "depth' (Atom _) = 1"| + "depth' (And \ \) = max (depth' \) (depth' \) + 1"| + "depth' (Or \ \) = max (depth' \) (depth' \) + 1"| + "depth' (Neg \) = depth' \ + 1"| + "depth' (ExQ \) = depth' \ + 1"| + "depth' (AllQ \) = depth' \ + 1"| + "depth' (AllN i \) = depth' \ + i * 2 + 1"| + "depth' (ExN i \) = depth' \ + i * 2 + 1" + +function clearQuantifiers :: "atom fm \ atom fm" where + "clearQuantifiers TrueF = TrueF"| + "clearQuantifiers FalseF = FalseF"| + "clearQuantifiers (Atom a) = simp_atom a"| + "clearQuantifiers (And \ \) = and (clearQuantifiers \) (clearQuantifiers \)"| + "clearQuantifiers (Or \ \) = or (clearQuantifiers \) (clearQuantifiers \)"| + "clearQuantifiers (Neg \) = neg (clearQuantifiers \)"| + "clearQuantifiers (ExQ \) = + (let \' = clearQuantifiers \ in + (if freeIn 0 \' then lowerFm 0 1 \' else ExQ \'))"| + "clearQuantifiers (AllQ \) = + (let \' = clearQuantifiers \ in + (if freeIn 0 \' then lowerFm 0 1 \' else AllQ \'))"| + "clearQuantifiers (ExN 0 \) = clearQuantifiers \"| + "clearQuantifiers (ExN (Suc i) \) = clearQuantifiers (ExN i (ExQ \))"| + "clearQuantifiers (AllN 0 \) = clearQuantifiers \"| + "clearQuantifiers (AllN (Suc i) \) = clearQuantifiers (AllN i (AllQ \))" + by pat_completeness auto +termination + apply(relation "measures [\A. depth' A]") + by auto + +subsection "Push Forall" + +fun push_forall :: "atom fm \ atom fm" where + "push_forall TrueF = TrueF"| + "push_forall FalseF = FalseF"| + "push_forall (Atom a) = simp_atom a"| + "push_forall (And \ \) = and (push_forall \) (push_forall \)"| + "push_forall (Or \ \) = or (push_forall \) (push_forall \)"| + "push_forall (ExQ \) = ExQ (push_forall \)"| + "push_forall (ExN i \) = ExN i (push_forall \)"| + "push_forall (Neg \) = neg (push_forall \)"| + "push_forall (AllQ TrueF) = TrueF"| + "push_forall (AllQ FalseF) = FalseF"| + "push_forall (AllQ (Atom a)) = (if freeIn 0 (Atom a) then Atom(lowerAtom 0 1 a) else AllQ (Atom a))"| + "push_forall (AllQ (And \ \)) = and (push_forall (AllQ \)) (push_forall (AllQ \))"| + "push_forall (AllQ (Or \ \)) = ( + if freeIn 0 \ + then( + if freeIn 0 \ + then or (lowerFm 0 1 \) (lowerFm 0 1 \) + else or (lowerFm 0 1 \) (AllQ \)) + else ( + if freeIn 0 \ + then or (AllQ \) (lowerFm 0 1 \) + else AllQ (or \ \)) +)"| + "push_forall (AllQ \) = (if freeIn 0 \ then lowerFm 0 1 \ else AllQ \)"| + "push_forall (AllN i \) = AllN i (push_forall \)" (* TODO, several bugs in this *) + + +subsection "Unpower" + +fun to_list :: "nat \ real mpoly \ (real mpoly * nat) list" where + "to_list v p = [(isolate_variable_sparse p v x, x). x \ [0..<(MPoly_Type.degree p v)+1]]" + +fun chop :: "(real mpoly * nat) list \ (real mpoly * nat) list"where + "chop [] = []"| + "chop ((p,i)#L) = (if p=0 then chop L else (p,i)#L)" + +fun decreasePower :: "nat \ real mpoly \ real mpoly * nat"where + "decreasePower v p = (case chop (to_list v p) of [] \ (p,0) | ((p,i)#L) \ (sum_list [term * (Var v) ^ (x-i). (term,x)\((p,i)#L)],i))" + +fun unpower :: "nat \ atom fm \ atom fm" where + "unpower v (Atom (Eq p)) = (case decreasePower v p of (_,0) \ Atom(Eq p)| (p,_) \ Or(Atom (Eq p))(Atom (Eq (Var v))) )"| + "unpower v (Atom (Neq p)) = (case decreasePower v p of (_,0) \ Atom(Neq p)| (p,_) \ And(Atom (Neq p))(Atom (Neq (Var v))) )"| + "unpower v (Atom (Less p)) = (case decreasePower v p of (_,0) \ Atom(Less p)| (p,n) \ + if n mod 2 = 0 then + And(Atom (Less p))(Atom(Neq (Var v))) + else + Or + (And (Atom (Less ( p))) (Atom (Less (-Var v)))) + (And (Atom (Less (-p))) (Atom (Less (Var v)))) + )"| + "unpower v (Atom (Leq p)) = (case decreasePower v p of (_,0) \ Atom(Leq p)| (p,n) \ + if n mod 2 = 0 then + Or (Atom (Leq p)) (Atom (Eq (Var v))) + else + Or (Atom (Eq p)) + (Or + (And (Atom (Less ( p))) (Atom (Leq (-Var v)))) + (And (Atom (Less (-p))) (Atom (Leq (Var v))))) + )"| + "unpower v (And a b) = And (unpower v a) (unpower v b)"| + "unpower v (Or a b) = Or (unpower v a) (unpower v b)"| + "unpower v (Neg a) = Neg (unpower v a)"| + "unpower v (TrueF) = TrueF"| + "unpower v (FalseF) = FalseF"| + "unpower v (AllQ F) = AllQ(unpower (v+1) F)"| + "unpower v (ExQ F) = ExQ (unpower (v+1) F)"| + "unpower v (AllN x F) = AllN x (unpower (v+x) F)"| + "unpower v (ExN x F) = ExN x (unpower (v+x) F)" + + + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/PolyAtoms.thy b/thys/Virtual_Substitution/PolyAtoms.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/PolyAtoms.thy @@ -0,0 +1,457 @@ +section "Atoms" +theory PolyAtoms + imports ExecutiblePolyProps +begin + +subsection "Definition" + +datatype (atoms: 'a) fm = + TrueF | FalseF | Atom 'a | And "'a fm" "'a fm" | Or "'a fm" "'a fm" | + Neg "'a fm" | ExQ "'a fm" | AllQ "'a fm" | ExN "nat" "'a fm" | AllN "nat" "'a fm" + +definition neg where + "neg \ = (if \=TrueF then FalseF else if \=FalseF then TrueF else Neg \)" + +definition "and" :: "'a fm \ 'a fm \ 'a fm" where + "and \\<^sub>1 \\<^sub>2 = + (if \\<^sub>1=TrueF then \\<^sub>2 else if \\<^sub>2=TrueF then \\<^sub>1 else + if \\<^sub>1=FalseF \ \\<^sub>2=FalseF then FalseF else And \\<^sub>1 \\<^sub>2)" + +definition or :: "'a fm \ 'a fm \ 'a fm" where + "or \\<^sub>1 \\<^sub>2 = + (if \\<^sub>1=FalseF then \\<^sub>2 else if \\<^sub>2=FalseF then \\<^sub>1 else + if \\<^sub>1=TrueF \ \\<^sub>2=TrueF then TrueF else Or \\<^sub>1 \\<^sub>2)" + +definition list_conj :: "'a fm list \ 'a fm" where + "list_conj fs = foldr and fs TrueF" + +definition list_disj :: "'a fm list \ 'a fm" where + "list_disj fs = foldr or fs FalseF" + +text " +The atom datatype corresponds to the defined in Tobias's LinearQuantifierElim. +" + +datatype atom = Less "real mpoly" | Eq "real mpoly" | Leq "real mpoly" | Neq "real mpoly" + +text + " +For each atom, the real mpoly corresponds to a polynomial from the Polynomials library where +we allow for real valued coefficients. + +The variables in the polynomials are in De Bruijn notation where variable 0 corresponds to the +variable of the innermost quantifier, then variable 1 is the next quantifier out from that, and +so on. Any variable number greater than the number of quantifiers is a free variable. This means +that we have a list of infinite free variables we can pick from and if we want to refer to the +ith free variable (indexed at 0) within an atom that is bound in j quantifiers, then we would use +var (i+j). + +The polynomials are all standardized so that they are compared to a 0 on the right. This means +the atom Less p corresponds to $p\\leq0$ and the atom Eq p corresponds to $p=0$ and so on. This +restriction doesn't lose any generality and having all 4 of these kinds of atoms prevents loss +of efficiency as the negation of these atoms do not introduce additional logical connectives. The +following aNeg function demonstrates this. +" + +fun aNeg :: "atom \ atom" where + "aNeg (Less p) = Leq (-p)" | + "aNeg (Eq p) = Neq p" | + "aNeg (Leq p) = Less (-p)" | + "aNeg (Neq p) = Eq p" + +subsection "Evaluation" + +text " +In order to do any proofs with these atoms, we need a method of comparing two atoms to check if they +are equal. Instead of trying to manipulate the polynomials to a standard form to compare them, it +is a lot easier to plug in values for every variable and check if the results are equal. If every +single real value input for each variable matches in truth value for both atoms, then they are equal. + +aEval a l corresponds to plugging in the real value list l into the variables of atom a and then +evaluating the truth value of it +" +fun aEval :: "atom \ real list \ bool" where + "aEval (Eq p) L = (insertion (nth_default 0 L) p = 0)" | + "aEval (Less p) L = (insertion (nth_default 0 L) p < 0)" | + "aEval (Leq p) L = (insertion (nth_default 0 L) p \ 0)" | + "aEval (Neq p) L = (insertion (nth_default 0 L) p \ 0)" + + +text " +aNeg\\_aEval shows the general format for how things are proven equal. Plugging in the values to an +original atom a will results in the opposite truth value if we transformed with the aNeg function. +" +lemma aNeg_aEval : "aEval a L \ (\ aEval (aNeg a) L)" + apply(cases a) + apply(auto) + apply(smt insertionNegative) + apply(smt insertionNegative) + apply(smt insertionNegative) + apply(smt insertionNegative) + done + +text " +We can extend this to formulas instead of just atoms. Given a formula in prenex normal form, +we simply iterate through and apply the quantifiers +" + + +fun eval :: "atom fm \ real list \ bool" where + "eval (Atom a) \ = aEval a \" | + "eval (TrueF) _ = True" | + "eval (FalseF) _ = False" | + "eval (And \ \) \ = ((eval \ \) \ (eval \ \))" | + "eval (Or \ \) \ = ((eval \ \) \ (eval \ \))" | + "eval (Neg \) \ = (\ (eval \ \))" | + "eval (ExQ \) \ = (\x. (eval \ (x#\)))" | + "eval (AllQ \) \ = (\x. (eval \ (x#\)))"| + "eval (AllN i \) \ = (\l. length l = i \ (eval \ (l @ \)))"| + "eval (ExN i \) \ = (\l. length l = i \ (eval \ (l @ \)))" + + +lemma "eval (ExQ (Or (Atom A) (Atom B))) xs = eval (Or (ExQ(Atom A)) (ExQ(Atom B))) xs" + by(auto) + + +lemma eval_neg_neg : "eval (neg (neg f)) L \ eval f L" + by (simp add: neg_def) + +lemma eval_neg : "(\ eval (neg f) L) \ eval f L" + by (simp add: neg_def) + +lemma eval_and : "eval (and a b) L \ (eval a L \ eval b L)" + by (simp add: and_def) + +lemma eval_or : "eval (or a b) L \ (eval a L \ eval b L)" + by (simp add: or_def) + +lemma eval_Or : "eval (Or a b) L \ (eval a L \ eval b L)" + by (simp) + +lemma eval_And : "eval (And a b) L \ (eval a L \ eval b L)" + by (simp) + +lemma eval_not : "eval (neg a) L \ \(eval a L)" + by (simp add: neg_def) + +lemma eval_true : "eval TrueF L" + by simp + +lemma eval_false : "\(eval FalseF L)" + by simp + +lemma eval_Neg : "eval (Neg \) L = eval (neg \) L" + by (simp add: eval_not) + +lemma eval_Neg_Neg : "eval (Neg (Neg \)) L = eval \ L" + by (simp add: eval_not) + + +lemma eval_Neg_And : "eval (Neg (And \ \)) L = eval (Or (Neg \) (Neg \)) L" + by simp + +lemma aEval_leq : "aEval (Leq p) L = (aEval (Less p) L \ aEval (Eq p) L)" + by auto + +text "This function is misleading because it is true iff + the variable given doesn't occur as a free variable in the atom fm" +fun freeIn :: "nat \ atom fm \ bool" where + "freeIn var (Atom(Eq p)) = (var \ (vars p))"| + "freeIn var (Atom(Less p)) = (var \ (vars p))"| + "freeIn var (Atom(Leq p)) = (var \ (vars p))"| + "freeIn var (Atom(Neq p)) = (var \ (vars p))"| + "freeIn var (TrueF) = True"| + "freeIn var (FalseF) = True"| + "freeIn var (And a b) = ((freeIn var a) \ (freeIn var b))"| + "freeIn var (Or a b) = ((freeIn var a) \ (freeIn var b))"| + "freeIn var (Neg a) = freeIn var a"| + "freeIn var (ExQ a) = freeIn (var+1) a"| + "freeIn var (AllQ a) = freeIn (var+1) a"| + "freeIn var (AllN i a) = freeIn (var+i) a"| + "freeIn var (ExN i a) = freeIn (var+i) a" + + + +fun liftmap :: "(nat \ atom \ atom fm) \ atom fm \ nat \ atom fm" where + "liftmap f TrueF var = TrueF"| + "liftmap f FalseF var = FalseF"| + "liftmap f (Atom a) var = f var a"| + "liftmap f (And \ \) var = And (liftmap f \ var) (liftmap f \ var)"| + "liftmap f (Or \ \) var = Or (liftmap f \ var) (liftmap f \ var)"| + "liftmap f (Neg \) var = Neg (liftmap f \ var)"| + "liftmap f (ExQ \) var = ExQ (liftmap f \ (var+1))"| + "liftmap f (AllQ \) var = AllQ (liftmap f \ (var+1))"| + "liftmap f (AllN i \) var = AllN i (liftmap f \ (var+i))"| + "liftmap f (ExN i \) var = ExN i (liftmap f \ (var+i))" + +(* +fun greatestFreeVariable :: "atom fm \ nat option" where +"greatestFreeVariable F = None" + +fun is_closed :: "atom fm \ real list \ bool" where +"is_closed F xs = (case greatestFreeVariable F of Some x \ (x = length xs) | None \ (0=length xs))" +*) + +fun depth :: "'a fm \ nat"where + "depth TrueF = 1"| + "depth FalseF = 1"| + "depth (Atom _) = 1"| + "depth (And \ \) = max (depth \) (depth \) + 1"| + "depth (Or \ \) = max (depth \) (depth \) + 1"| + "depth (Neg \) = depth \ + 1"| + "depth (ExQ \) = depth \ + 1"| + "depth (AllQ \) = depth \ + 1"| + "depth (AllN i \) = depth \ + 1"| + "depth (ExN i \) = depth \ + 1" + +value "AllQ (And + (ExQ (Atom (Eq (Var 1 * Var 2 - (Var 0)^2 * Var 3)))) + (Neg (AllQ (Atom (Leq (Const 5 * (Var 1)^2 - Var 0))))) +)" + +fun negation_free :: "atom fm \ bool" where + "negation_free TrueF = True" | + "negation_free FalseF = True " | + "negation_free (Atom a) = True" | + "negation_free (And \\<^sub>1 \\<^sub>2) = ((negation_free \\<^sub>1) \ (negation_free \\<^sub>2))" | + "negation_free (Or \\<^sub>1 \\<^sub>2) = ((negation_free \\<^sub>1) \ (negation_free \\<^sub>2))" | + "negation_free (ExQ \) = negation_free \" | + "negation_free (AllQ \) = negation_free \" | + "negation_free (AllN i \) = negation_free \" | + "negation_free (ExN i \) = negation_free \" | + "negation_free (Neg _) = False" + +subsection "Useful Properties" + +lemma sum_eq : "eval (Atom(Eq p)) L \ eval (Atom(Eq q)) L \ eval (Atom(Eq(p + q))) L" + by (simp add: insertion_add) + +lemma freeIn_list_conj : "(\f\set(F). freeIn var f) \ freeIn var (list_conj F)" +proof(induct F) + case Nil + then show ?case by(simp add: list_conj_def) +next + case (Cons a F) + then show ?case by (simp add: PolyAtoms.and_def list_conj_def) +qed + +lemma freeIn_list_disj : + assumes "\f\set (L::atom fm list). freeIn var f" + shows "freeIn var (list_disj L)" + using assms +proof(induction L) + case Nil + then show ?case unfolding list_disj_def by auto +next + case (Cons a L) + then show ?case unfolding list_disj_def or_def by simp +qed + +lemma var_not_in_aEval : "freeIn var (Atom \) \ (\x. aEval \ (list_update L var x)) = (\x. aEval \ (list_update L var x))" +proof(induction \) + case (Less p) + then show ?case + apply(auto) + using not_contains_insertion + by metis +next + case (Eq p) + then show ?case + apply(auto) + using not_contains_insertion + by blast +next + case (Leq p) + then show ?case + apply(auto) + using not_contains_insertion + by metis +next + case (Neq p) + then show ?case + apply(auto) + using not_contains_insertion + by metis +qed + +lemma var_not_in_aEval2 : "freeIn 0 (Atom \) \ (\x. aEval \ (x#L)) = (\x. aEval \ (x#L))" + by (metis list_update_code(2) var_not_in_aEval) + +lemma plugInLinear : + assumes lLength : "length L>var" + assumes nonzero : "B\0" + assumes hb : "\v. insertion (nth_default 0 (list_update L var v)) b = B" + assumes hc : "\v. insertion (nth_default 0 (list_update L var v)) c = C" + shows "aEval (Eq(b*Var var + c)) (list_update L var (-C/B))" + by(simp add: lLength insertion_add insertion_mult nonzero hb hc insertion_var) + + +subsection "Some eval results" +lemma doubleExist : "eval (ExN 2 A) L = eval (ExQ (ExQ A)) L" + apply(simp) +proof(safe) + fix l + assume h : "length l = 2" "eval A (l @ L)" + show "\x xa. eval A (xa # x # L)" + proof(cases l) + case Nil + then show ?thesis using h by auto + next + case (Cons a list) + then have Cons' : "l = a # list" by auto + then show ?thesis proof(cases list) + case Nil + then show ?thesis using h Cons by auto + next + case (Cons b list) + show ?thesis + apply(rule exI[where x=b])apply(rule exI[where x=a]) + using h Cons' Cons by auto + qed + qed +next + fix x xa + assume h : "eval A (xa # x # L)" + show "\l. length l = 2 \ eval A (l @ L)" + apply(rule exI[where x="[xa,x]"]) using h by simp +qed + +lemma doubleForall : "eval (AllN 2 A) L = eval (AllQ (AllQ A)) L" + apply(simp)using doubleExist eval_neg by fastforce + +lemma unwrapExist : "eval (ExN (j + 1) A) L = eval (ExQ (ExN j A)) L" + apply simp + apply safe + subgoal for l + apply(rule exI[where x="nth l j"]) + apply(rule exI[where x="take j l"]) + apply auto + by (metis Cons_nth_drop_Suc append.assoc append_Cons append_eq_append_conv_if append_take_drop_id lessI) + subgoal for x l + apply(rule exI[where x="l @ [x]"]) + by auto + done + +lemma unwrapExist' : "eval (ExN (j + 1) A) L = eval (ExN j (ExQ A)) L" + apply simp + apply safe + subgoal for l + apply(rule exI[where x="drop 1 l"]) + apply auto + apply(rule exI[where x="nth l 0"]) + by (metis Cons_nth_drop_Suc append_Cons drop0 zero_less_Suc) + subgoal for l x + apply(rule exI[where x="x#l"]) + by auto + done + +lemma unwrapExist'' : "eval (ExN (i + j) A) L = eval (ExN i(ExN j A)) L" + apply simp + apply safe + subgoal for l + apply(rule exI[where x="drop j l"]) + apply auto + apply(rule exI[where x="take j l"]) + apply auto + by (metis append.assoc append_take_drop_id) + subgoal for l la + apply(rule exI[where x="la@l"]) + by auto + done + +lemma unwrapForall : "eval (AllN (j + 1) A) L = eval (AllQ (AllN j A)) L" + using unwrapExist[of j "neg A" L] eval_neg by fastforce + +lemma unwrapForall' : "eval (AllN (j + 1) A) L = eval (AllN j (AllQ A)) L" + using unwrapExist'[of j "neg A" L] eval_neg by fastforce + +lemma unwrapForall'' : "eval (AllN (i + j) A) L = eval (AllN i(AllN j A)) L" + using unwrapExist''[of i j "neg A" L] eval_neg by fastforce + +lemma var_not_in_eval : "\var. \L. (freeIn var \ \ ((\x. eval \ (list_update L var x)) = (\x. eval \ (list_update L var x))))" +proof(induction \) + case TrueF + then show ?case by(auto) +next + case FalseF + then show ?case by(auto) +next + case (Atom x) + then show ?case + using var_not_in_aEval eval.simps(1) by blast +next + case (And \1 \2) + then show ?case by (meson eval.simps(4) freeIn.simps(7)) +next + case (Or \1 \2) + then show ?case by fastforce +next + case (Neg \) + then show ?case by (meson eval.simps(6) freeIn.simps(9)) +next + case (ExQ \) + fix xa L var x + have "(xa::real) # L[var := x] = (xa#L)[var+1:=x]" + by simp + then show ?case using ExQ + by (metis Suc_eq_plus1 eval.simps(7) freeIn.simps(10) list_update_code(3)) +next + case (AllQ \) + fix xa L var x + have "(xa::real) # L[var := x] = (xa#L)[var+1:=x]" + by simp + then show ?case using AllQ + by (metis Suc_eq_plus1 eval.simps(8) freeIn.simps(11) list_update_code(3)) +next + case (ExN i \) + {fix xa L var x + assume "length (xa::real list) = i" + have "xa @ L[var := x] = (xa@L)[var+i:=x]" + by (simp add: \length xa = i\ list_update_append) + } + then show ?case using ExN + by (metis eval.simps(10) freeIn.simps(13)) +next + case (AllN i \) + {fix xa L var x + assume "length (xa::real list) = i" + have "xa @ L[var := x] = (xa@L)[var+i:=x]" + by (simp add: \length xa = i\ list_update_append) + } + then show ?case using AllN + by (metis eval.simps(9) freeIn.simps(12)) +qed + +lemma var_not_in_eval2 : "\L. (freeIn 0 \ \ ((\x. eval \ (x#L)) = (\x. eval \ (x#L))))" + by (metis list_update_code(2) var_not_in_eval) + +lemma var_not_in_eval3 : + assumes "freeIn var \" + assumes "length xs' = var" + shows "((\x. eval \ (xs'@x#L)) = (\x. eval \ (xs'@x#L)))" + using assms + by (metis list_update_length var_not_in_eval) + +lemma eval_list_conj : "eval (list_conj F) L = (\f\set(F). eval f L)" +proof - + { fix f F + have h : "eval (foldr and F f) L = (eval f L \ (\f \ set F. eval f L))" + apply(induct F) + apply simp + using eval_and by auto + } then show ?thesis + by(simp add:list_conj_def) +qed + + +lemma eval_list_disj : "eval (list_disj F) L = (\f\set(F). eval f L)" +proof - + { fix f F + have h : "eval (foldr or F f) L = (eval f L \ (\f \ set F. eval f L))" + apply(induct F) + apply simp + using eval_or by auto + } then show ?thesis + by(simp add:list_disj_def) +qed +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/PrettyPrinting.thy b/thys/Virtual_Substitution/PrettyPrinting.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/PrettyPrinting.thy @@ -0,0 +1,127 @@ +theory PrettyPrinting + imports + ExecutiblePolyProps + PolyAtoms + Polynomials.Show_Polynomials + Polynomials.Power_Products +begin + +global_interpretation drlex_pm: linorder drlex_pm drlex_pm_strict + defines Min_drlex_pm = "linorder.Min drlex_pm" + and Max_drlex_pm = "linorder.Max drlex_pm" + and sorted_drlex_pm = "linorder.sorted drlex_pm" + and sorted_list_of_set_drlex_pm = "linorder.sorted_list_of_set drlex_pm" + and sort_key_drlex_pm = "linorder.sort_key drlex_pm" + and insort_key_drlex_pm = "linorder.insort_key drlex_pm" + and part_drlex_pm = "drlex_pm.part" + apply unfold_locales + subgoal by (simp add: drlex_pm_strict_def) + subgoal by (simp add: drlex_pm_refl) + subgoal using drlex_pm_trans by auto + subgoal by (simp add: drlex_pm_antisym) + subgoal by (simp add: drlex_pm_lin) + done + +definition "monomials_list mp = drlex_pm.sorted_list_of_set (monomials mp)" + +definition shows_monomial_gen::"((nat \ nat) \ shows) \ ('a \ shows) \ shows \ (nat \\<^sub>0 nat) \ 'a option \ shows" where + "shows_monomial_gen shows_factor shows_coeff sep mon cff = + shows_sep (\s. case s of + Inl cff \ shows_coeff cff + | Inr factor \ shows_factor factor + ) sep ((case cff of None \ [] | Some cff \ [Inl cff]) @ map Inr (Poly_Mapping.items mon))" + +definition "shows_factor_compact factor = + (case factor of (k, v) \ shows_string ''x'' +@+ shows k +@+ + (if v = 1 then shows_string '''' else shows_string ''^'' +@+ shows v))" + +definition "shows_factor_Var factor = + (case factor of (k, v) \ shows_string ''(Var '' +@+ shows k +@+ shows_string '')'' +@+ + (if v = 1 then shows_string '''' else shows_string ''^'' +@+ shows v))" + +definition shows_monomial_compact::"('a \ shows) \ (nat \\<^sub>0 nat) \ 'a option \ shows" where + "shows_monomial_compact shows_coeff m = + shows_monomial_gen shows_factor_compact shows_coeff (shows_string '' '') m" + +definition shows_monomial_Var::"('a \ shows) \ (nat \\<^sub>0 nat) \ 'a option \ shows" where + "shows_monomial_Var shows_coeff m = + shows_monomial_gen shows_factor_Var shows_coeff (shows_string ''*'') m" + +fun shows_mpoly :: "bool \ ('a \ shows) \ 'a::{zero,one} mpoly \ shows" where + "shows_mpoly input shows_coeff p = shows_sep (\mon. + (if input then shows_monomial_Var (\x. shows_paren (shows_string ''Const '' +@+ shows_paren (shows_coeff x))) else shows_monomial_compact shows_coeff) + mon + (let cff = MPoly_Type.coeff p mon in if cff = 1 then None else Some cff) + ) + (shows_string '' + '') + (monomials_list p)" + + +definition "rat_of_real (x::real) = + (if (\r::rat. x = of_rat r) then (THE r. x = of_rat r) else 99999999999.99999999999)" + +lemma rat_of_real: "rat_of_real x = r" if "x = of_rat r" + using that + unfolding rat_of_real_def + by simp + +lemma rat_of_real_code[code]: "rat_of_real (Ratreal r) = r" + by (simp add: rat_of_real) + +definition "shows_real x = shows (rat_of_real x)" + +experiment begin +abbreviation "foo \ ((Var 0::real mpoly) + Const (0.5) * Var 1 + Var 2)^3" +value [code] "shows_mpoly True shows_real foo ''''" + (* rhs of foo\\_eq is the output of this \value\ command *) +lemma foo_eq: "foo = (Var 0)^3 + (Const (3/2))*(Var 0)^2*(Var 1) + (Const (3))*(Var 0)^2*(Var 2) + (Const (3/4))*(Var 0)*(Var 1)^2 + (Const (3))*(Var 0)*(Var 1)*(Var 2) + (Const (3))*(Var 0)*(Var 2)^2 + (Const (1/8))*(Var 1)^3 + (Const (3/4))*(Var 1)^2*(Var 2) + (Const (3/2))*(Var 1)*(Var 2)^2 + (Var 2)^3" + by code_simp +value [code] "shows_mpoly False shows_real foo ''''" +value [code] "shows_mpoly False (shows_paren o shows_mpoly False shows_real) (extract_var foo 0) ''''" +value [code] "shows_list_gen (shows_mpoly False shows_real) + ''[]'' ''['' '', '' '']'' + (Polynomial.coeffs (mpoly_to_nested_poly foo 0)) ''''" +end + +fun shows_atom :: "bool \ atom \ shows" where + "shows_atom c (Eq p) = (shows_string ''('' +@+ shows_mpoly c shows_real p +@+ shows_string ''=0)'')"| + "shows_atom c (Less p) = (shows_string ''('' +@+ shows_mpoly c shows_real p +@+ shows_string ''<0)'')"| + "shows_atom c (Leq p) = (shows_string ''('' +@+ shows_mpoly c shows_real p +@+ shows_string ''<=0)'')"| + "shows_atom c(Neq p) = (shows_string ''('' +@+ shows_mpoly c shows_real p +@+ shows_string ''~=0)'')" + +fun depth' :: "'a fm \ nat"where + "depth' TrueF = 1"| + "depth' FalseF = 1"| + "depth' (Atom _) = 1"| + "depth' (And \ \) = max (depth' \) (depth' \) + 1"| + "depth' (Or \ \) = max (depth' \) (depth' \) + 1"| + "depth' (Neg \) = depth' \ + 1"| + "depth' (ExQ \) = depth' \ + 1"| + "depth' (AllQ \) = depth' \ + 1"| + "depth' (AllN i \) = depth' \ + i * 2 + 1"| + "depth' (ExN i \) = depth' \ + i * 2 + 1" + + +function shows_fm :: "bool \ atom fm \ shows" where + "shows_fm c (Atom a) = shows_atom c a"| + "shows_fm c (TrueF) = shows_string ''(T)''"| + "shows_fm c (FalseF) = shows_string ''(F)''"| + "shows_fm c (And \ \) = (shows_string ''('' +@+ shows_fm c \ +@+ shows_string '' and '' +@+ shows_fm c \ +@+ shows_string ('')''))"| + "shows_fm c (Or \ \) = (shows_string ''('' +@+ shows_fm c \ +@+ shows_string '' or '' +@+ shows_fm c \ +@+ shows_string '')'')"| + "shows_fm c (Neg \) = (shows_string ''(neg '' +@+ shows_fm c \ +@+ shows_string '')'')"| + "shows_fm c (ExQ \) = (shows_string ''(exists'' +@+ shows_fm c \ +@+ shows_string '')'')"| + "shows_fm c (AllQ \) = (shows_string ''(forall'' +@+ shows_fm c \ +@+ shows_string '')'')"| + "shows_fm c (ExN 0 \) = shows_fm c \"| + "shows_fm c (ExN (Suc n) \) = shows_fm c (ExQ(ExN n \))"| + "shows_fm c (AllN 0 \) = shows_fm c \"| + "shows_fm c (AllN (Suc n) \) = shows_fm c (AllQ(AllN n \))" + by pat_completeness auto +termination + apply(relation "measures [\(_,A). depth' A]") + by auto + + +value "shows_fm False (ExQ (Or (AllQ(And (Neg TrueF) (Neg FalseF))) (Atom(Eq(Const 4))))) []" +value "shows_fm True (ExQ (Or (AllQ(And (Neg TrueF) (Neg FalseF))) (Atom(Eq(Const 4))))) []" + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/QE.thy b/thys/Virtual_Substitution/QE.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/QE.thy @@ -0,0 +1,8838 @@ +section "QE lemmas" +theory QE + imports Polynomials.MPoly_Type_Univariate + Polynomials.Polynomials Polynomials.MPoly_Type_Class_FMap + "HOL-Library.Quadratic_Discriminant" +begin + +(* This file may take some time to load *) + +subsection "Useful Definitions/Setting Up" + +definition sign:: "real Polynomial.poly \ real \ int" + where "sign p x \ (if poly p x = 0 then 0 else (if poly p x > 0 then 1 else -1))" + +definition sign_num:: "real \ int" + where "sign_num x \ (if x = 0 then 0 else (if x > 0 then 1 else -1))" + +definition root_list:: "real Polynomial.poly \ real set" + where "root_list p \ ({(x::real). poly p x = 0}::real set)" + +definition root_set:: "(real \ real \ real) set \ real set" + where "root_set les \ ({(x::real). (\ (a, b, c) \ les. a*x^2 + b*x + c = 0)}::real set)" + +definition sorted_root_list_set:: "(real \ real \ real) set \ real list" + where "sorted_root_list_set p \ sorted_list_of_set (root_set p)" + +definition nonzero_root_set:: "(real \ real \ real) set \ real set" + where "nonzero_root_set les \ ({(x::real). (\ (a, b, c) \ les. (a \ 0 \ b \ 0) \ a*x^2 + b*x + c = 0)}::real set)" + +definition sorted_nonzero_root_list_set:: "(real \ real \ real) set \ real list" + where "sorted_nonzero_root_list_set p \ sorted_list_of_set (nonzero_root_set p)" + + +(* Important property of sorted lists *) +lemma sorted_list_prop: + fixes l::"real list" + fixes x::"real" + assumes sorted: "sorted l" + assumes lengt: "length l > 0" + assumes xgt: "x > l ! 0" + assumes xlt: "x \ l ! (length l - 1)" + shows "\n. (n+1) < (length l) \ x \ l !n \ x \ l ! (n + 1)" +proof - + have "\(\n. (n+1) < (length l) \ x \ l !n \ x \ l ! (n + 1)) \ False" + proof clarsimp + fix n + assume alln: "\n. l ! n \ x \ Suc n < length l \ \ x \ l ! Suc n" + have "\k. (k < length l \ x > l ! k)" + proof clarsimp + fix k + show "k < length l \ l ! k < x" + proof (induct k) + case 0 + then show ?case using xgt by auto + next + case (Suc k) + then show ?case using alln + using less_eq_real_def by auto + qed + qed + then show "False" + using xlt diff_Suc_less lengt not_less + by (metis One_nat_def) + qed + then show ?thesis by auto +qed + + +subsection "Quadratic polynomial properties" +lemma quadratic_poly_eval: + fixes a b c::"real" + fixes x::"real" + shows "poly [:c, b, a:] x = a*x^2 + b*x + c" +proof - + have "x * (b + x * a) = a * x\<^sup>2 + b * x" by (metis add.commute distrib_right mult.assoc mult.commute power2_eq_square) + then show ?thesis by auto +qed + +lemma poly_roots_set_same: + fixes a b c:: "real" + shows "{(x::real). a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}" +proof - + have "\x. a*x^2 + b*x + c = poly [:c, b, a:] x" + proof clarsimp + fix x + show "a * x\<^sup>2 + b * x = x * (b + x * a)" + using quadratic_poly_eval[of c b a x] by auto + qed + then show ?thesis + by auto +qed + +lemma root_set_finite: + assumes fin: "finite les" + assumes nex: "\(\ (a, b, c) \ les. a = 0 \ b = 0 \ c = 0 )" + shows "finite (root_set les)" +proof - + have "\(a, b, c) \ les. finite {(x::real). a*x^2 + b*x + c = 0}" + proof clarsimp + fix a b c + assume "(a, b, c) \ les" + then have "[:c, b, a:] \ 0" using nex by auto + then have "finite {x. poly [:c, b, a:] x = 0}" + using poly_roots_finite[where p = "[:c, b, a:]"] by auto + then show "finite {x. a * x\<^sup>2 + b * x + c = 0}" + using poly_roots_set_same by auto + qed + then show ?thesis using fin + unfolding root_set_def by auto +qed + +lemma nonzero_root_set_finite: + assumes fin: "finite les" + shows "finite (nonzero_root_set les)" +proof - + have "\(a, b, c) \ les. (a \ 0 \ b \ 0) \ finite {(x::real). a*x^2 + b*x + c = 0}" + proof clarsimp + fix a b c + assume ins: "(a, b, c) \ les" + assume "a = 0 \ b \ 0" + then have "[:c, b, a:] \ 0" using ins by auto + then have "finite {x. poly [:c, b, a:] x = 0}" + using poly_roots_finite[where p = "[:c, b, a:]"] by auto + then show "finite {x. a * x\<^sup>2 + b * x + c = 0}" + using poly_roots_set_same by auto + qed + then show ?thesis using fin + unfolding nonzero_root_set_def by auto +qed + +lemma discriminant_lemma: + fixes a b c r::"real" + assumes aneq: "a \ 0" + assumes beq: "b = 2 * a * r" + assumes root: " a * r^2 - 2 * a * r*r + c = 0" + shows "\x. a * x\<^sup>2 + b * x + c = 0 \ x = -r" +proof - + have "c = a*r^2" using root + by (simp add: power2_eq_square) + then have same: "b^2 - 4*a*c = (2 * a * r)^2 - 4*a*(a*r^2)" using beq + by blast + have "(2 * a * r)^2 = 4*a^2*r^2" + by (simp add: mult.commute power2_eq_square) + then have "(2 * a * r)^2 - 4*a*(a*(r)^2) = 0" + using power2_eq_square by auto + then have "b^2 - 4*a*c = 0" using same + by simp + then have "\x. a * x\<^sup>2 + b * x + c = 0 \ x = -b / (2 * a)" + using discriminant_zero aneq unfolding discrim_def by auto + then show ?thesis using beq + by (simp add: aneq) +qed + +(* Show a polynomial only changes sign when it passes through a root *) +lemma changes_sign: + fixes p:: "real Polynomial.poly" + shows "\x::real. \ y::real. ((sign p x \ sign p y \ x < y) \ (\c \ (root_list p). x \ c \ c \ y))" +proof clarsimp + fix x y + assume "sign p x \ sign p y" + assume "x < y" + then show "\c\root_list p. x \ c \ c \ y" + using poly_IVT_pos[of x y p] poly_IVT_neg[of x y p] + by (metis (mono_tags) \sign p x \ sign p y\ less_eq_real_def linorder_neqE_linordered_idom mem_Collect_eq root_list_def sign_def) +qed + +(* Show a polynomial only changes sign if it passes through a root *) +lemma changes_sign_var: + fixes a b c x y:: "real" + shows "((sign_num (a*x^2 + b*x + c) \ sign_num (a*y^2 + b*y + c) \ x < y) \ (\q. (a*q^2 + b*q + c = 0 \ x \ q \ q \ y)))" +proof clarsimp + assume sn: "sign_num (a * x\<^sup>2 + b * x + c) \ sign_num (a * y\<^sup>2 + b * y + c)" + assume xy: " x < y" + let ?p = "[:c, b, a:]" + have cs: "((sign ?p x \ sign ?p y \ x < y) \ (\c \ (root_list ?p). x \ c \ c \ y))" + using changes_sign[of ?p] by auto + have "(sign ?p x \ sign ?p y \ x < y)" + using sn xy unfolding sign_def sign_num_def using quadratic_poly_eval + by presburger + then have "(\c \ (root_list ?p). x \ c \ c \ y)" + using cs + by auto + then obtain q where "q \ root_list ?p \ x \ q \ q \ y" + by auto + then have "a*q^2 + b*q + c = 0 \ x \ q \ q \ y" + unfolding root_list_def using quadratic_poly_eval[of c b a q] + by auto + then show "\q. a * q\<^sup>2 + b * q + c = 0 \ x \ q \ q \ y" + by auto +qed + +subsection "Continuity Properties" +lemma continuity_lem_eq0: + fixes p::"real" + shows "r < p \ \x\{r <..p}. a * x\<^sup>2 + b * x + c = 0 \ (a = 0 \ b = 0 \ c = 0)" +proof - + assume r_lt: "r < p" + assume inf_zer: "\x\{r <..p}. a * x\<^sup>2 + b * x + c = 0" + have nf: "\finite {r..(a = 0 \ b = 0 \ c = 0) \ False" + proof - + assume "\(a = 0 \ b = 0 \ c = 0)" + then have "[:c, b, a:] \ 0" by auto + then have fin: "finite {x. poly [:c, b, a:] x = 0}" using poly_roots_finite[where p = "[:c, b, a:]"] by auto + have "{x. a*x^2 + b*x + c = 0} = {x. poly [:c, b, a:] x = 0}" using quadratic_poly_eval by auto + then have finset: "finite {x. a*x^2 + b*x + c = 0}" using fin by auto + have "{r <..p} \ {x. a*x^2 + b*x + c = 0}" using inf_zer by blast + then show "False" using finset nf + using finite_subset + by (metis (no_types, lifting) infinite_Ioc_iff r_lt) + qed + then show "(a = 0 \ b = 0 \ c = 0)" by auto +qed + +lemma continuity_lem_lt0: + fixes r:: "real" + fixes a b c:: "real" + shows "poly [:c, b, a:] r < 0 \ + \y'> r. \x\{r<..y'}. poly [:c, b, a:] x < 0" +proof - + let ?f = "poly [:c,b,a:]" + assume r_ltz: "poly [:c, b, a:] r < 0" + then have "[:c, b, a:] \ 0" by auto + then have "finite {x. poly [:c, b, a:] x = 0}" using poly_roots_finite[where p = "[:c, b, a:]"] + by auto + then have fin: "finite {x. x > r \ poly [:c, b, a:] x = 0}" + using finite_Collect_conjI by blast + let ?l = "sorted_list_of_set {x. x > r \ poly [:c, b, a:] x = 0}" + show ?thesis proof (cases "length ?l = 0") + case True + then have no_zer: "\(\x>r. poly [:c, b, a:] x = 0)" using sorted_list_of_set_eq_Nil_iff fin by auto + then have "\y. y > r \ y < (r + 1) \ poly [:c, b, a:] y < 0 " + proof - + fix y + assume "y > r \ y < r + 1" + then show "poly [:c, b, a:] y < 0" + using r_ltz no_zer poly_IVT_pos[where a = "r", where p = "[:c, b, a:]", where b = "y"] + by (meson linorder_neqE_linordered_idom) + qed + then show ?thesis + by (metis (no_types, hide_lams) \\ (\x>r. poly [:c, b, a:] x = 0)\ \poly [:c, b, a:] r < 0\ greaterThanAtMost_iff linorder_neqE_linordered_idom linordered_field_no_ub poly_IVT_pos) + next + case False + then have len_nonz: "length (sorted_list_of_set {x. r < x \ poly [:c, b, a:] x = 0}) \ 0" + by blast + then have "\n \ {x. x > r \ poly [:c, b, a:] x = 0}. (nth_default 0 ?l 0) \ n" + using fin set_sorted_list_of_set sorted_sorted_list_of_set + using in_set_conv_nth leI not_less0 sorted_nth_mono + by (smt not_less_iff_gr_or_eq nth_default_def) + then have no_zer: "\(\x>r. (x < (nth_default 0 ?l 0) \ poly [:c, b, a:] x = 0))" + using sorted_sorted_list_of_set by auto + then have fa: "\y. y > r \ y < (nth_default 0 ?l 0) \ poly [:c, b, a:] y < 0 " + proof - + fix y + assume "y > r \ y < (nth_default 0 ?l 0)" + then show "poly [:c, b, a:] y < 0" + using r_ltz no_zer poly_IVT_pos[where a = "r", where p = "[:c, b, a:]", where b = "y"] + by (meson less_imp_le less_le_trans linorder_neqE_linordered_idom) + qed + have "nth_default 0 ?l 0 > r" using fin set_sorted_list_of_set + using len_nonz length_0_conv length_greater_0_conv mem_Collect_eq nth_mem + by (metis (no_types, lifting) nth_default_def) + then have "\(y'::real). r < y' \ y' < (nth_default 0 ?l 0)" + using dense by blast + then obtain y' where y_prop:"r < y' \y' < (nth_default 0 ?l 0)" by auto + then have "\x\{r<..y'}. poly [:c, b, a:] x < 0" + using fa by auto + then show ?thesis using y_prop by blast + qed +qed + +lemma continuity_lem_gt0: + fixes r:: "real" + fixes a b c:: "real" + shows "poly [:c, b, a:] r > 0 \ + \y'> r. \x\{r<..y'}. poly [:c, b, a:] x > 0" +proof - + assume r_gtz: "poly [:c, b, a:] r > 0 " + let ?p = "[:-c, -b, -a:]" + have revpoly: "\x. -1*(poly [:c, b, a:] x) = poly [:-c, -b, -a:] x" + by (metis (no_types, hide_lams) Polynomial.poly_minus add.inverse_neutral minus_pCons mult_minus1) + then have "poly ?p r < 0" using r_gtz + by (metis mult_minus1 neg_less_0_iff_less) + then have "\y'> r. \x\{r<..y'}. poly ?p x < 0" using continuity_lem_lt0 + by blast + then obtain y' where y_prop: "y' > r \ (\x\{r<..y'}. poly ?p x < 0)" by auto + then have "\x\{r<..y'}. poly [:c, b, a:] x > 0 " using revpoly + using neg_less_0_iff_less by fastforce + then show ?thesis + using y_prop by blast +qed + +lemma continuity_lem_lt0_expanded: + fixes r:: "real" + fixes a b c:: "real" + shows "a*r^2 + b*r + c < 0 \ + \y'> r. \x\{r<..y'}. a*x^2 + b*x + c < 0" + using quadratic_poly_eval continuity_lem_lt0 + by (simp add: add.commute) + +lemma continuity_lem_gt0_expanded: + fixes r:: "real" + fixes a b c:: "real" + fixes k::"real" + assumes kgt: "k > r" + shows "a*r^2 + b*r + c > 0 \ + \x\{r<..k}. a*x^2 + b*x + c > 0" +proof - + assume "a*r^2 + b*r + c > 0" + then have "\y'> r. \x\{r<..y'}. poly [:c, b, a:] x > 0" + using continuity_lem_gt0 quadratic_poly_eval[of c b a r] by auto + then obtain y' where y_prop: "y' > r \ (\x\{r<..y'}. poly [:c, b, a:] x > 0)" by auto + then have "\q. q > r \ q < min k y'" using kgt dense + by (metis min_less_iff_conj) + then obtain q where q_prop: "q > r \q < min k y'" by auto + then have "a*q^2 + b*q + c > 0" using y_prop quadratic_poly_eval[of c b a q] + by (metis greaterThanAtMost_iff less_eq_real_def min_less_iff_conj) + then show ?thesis + using q_prop by auto +qed + +subsection "Negative Infinity (Limit) Properties" + +lemma ysq_dom_y: + fixes b:: "real" + fixes c:: "real" + shows "\(w::real). \(y:: real). (y < w \ y^2 > b*y)" +proof - + have c1: "b \ 0 ==> \(w::real). \(y:: real). (y < w \ y^2 > b*y)" + proof - + assume "b \ 0" + then have p1: "\(y:: real). (y < -1 \ y*b \ 0)" + by (simp add: mult_nonneg_nonpos2) + have p2: "\(y:: real). (y < -1 \ y^2 > 0)" + by auto + then have h1: "\(y:: real). (y < -1 \ y^2 > b*y)" + using p1 p2 + by (metis less_eq_real_def less_le_trans mult.commute) + then show ?thesis by auto + qed + have c2: "b < 0 \ b > -1 ==> \(w::real). \(y:: real). (y < w \ y^2 > b*y)" + proof - + assume "b < 0 \ b > -1 " + then have h1: "\(y:: real). (y < -1 \ y^2 > b*y)" + by (simp add: power2_eq_square) + then show ?thesis by auto + qed + have c3: "b \ -1 ==> \(w::real). \(y:: real). (y < w \ y^2 > b*y)" + proof - + assume "b \ -1 " + then have h1: "\(y:: real). (y < b \ y^2 > b*y)" + by (metis le_minus_one_simps(3) less_irrefl less_le_trans mult.commute mult_less_cancel_left power2_eq_square) + then show ?thesis by auto + qed + then show ?thesis using c1 c2 c3 + by (metis less_trans linorder_not_less) +qed + +lemma ysq_dom_y_plus_coeff: + fixes b:: "real" + fixes c:: "real" + shows "\(w::real). \(y::real). (y < w \ y^2 > b*y + c)" +proof - + have "\(w::real). \(y:: real). (y < w \ y^2 > b*y)" using ysq_dom_y by auto + then obtain w where w_prop: "\(y:: real). (y < w \ y^2 > b*y)" by auto + have "c \ 0 \ \(y::real). (y < w \ y^2 > b*y + c)" + using w_prop by auto + then have c1: "c \ 0 \ \(w::real). \(y::real). (y < w \ y^2 > b*y + c)" by auto + have "\(w::real). \(y:: real). (y < w \ y^2 > (b-c)*y)" using ysq_dom_y by auto + then obtain k where k_prop: "\(y:: real). (y < k \ y^2 > (b-c)*y)" by auto + let ?mn = "min k (-1)" + have "(c> 0 \ (\ y < -1. -c*y > c))" + proof - + assume cgt: " c> 0" + show "\(y::real) < -1. -c*y > c" + proof clarsimp + fix y::"real" + assume "y < -1" + then have "-y > 1" + by auto + then have "c < c*(-y)" using cgt + by (metis \1 < - y\ mult.right_neutral mult_less_cancel_left_pos) + then show " c < - (c * y) " + by auto + qed + qed + then have "(c> 0 \ (\ y < ?mn. (b-c)*y > b*y + c))" + by (simp add: left_diff_distrib) + then have c2: "c > 0 \ \(y::real). (y < ?mn \ y^2 > b*y + c)" + using k_prop + by force + then have c2: "c > 0 \ \(w::real). \(y::real). (y < w \ y^2 > b*y + c)" + by blast + show ?thesis using c1 c2 + by fastforce +qed + +lemma ysq_dom_y_plus_coeff_2: + fixes b:: "real" + fixes c:: "real" + shows "\(w::real). \(y::real). (y > w \ y^2 > b*y + c)" +proof - + have "\(w::real). \(y::real). (y < w \ y^2 > -b*y + c)" + using ysq_dom_y_plus_coeff[where b = "-b", where c = "c"] by auto + then obtain w where w_prop: "\(y::real). (y < w \ y^2 > -b*y + c)" by auto + let ?mn = "min w (-1)" + have "\(y::real). (y < ?mn \ y^2 > -b*y + c)" using w_prop by auto + then have "\(y::real). (y > (-1*?mn) \ y^2 > b*y + c)" + by (metis (no_types, hide_lams) add.inverse_inverse minus_less_iff mult_minus1 mult_minus_left mult_minus_right power2_eq_square) + then show ?thesis by auto +qed + +lemma neg_lc_dom_quad: + fixes a:: "real" + fixes b:: "real" + fixes c:: "real" + assumes alt: "a < 0" + shows "\(w::real). \(y::real). (y > w \ a*y^2 + b*y + c < 0)" +proof - + have "\(w::real). \(y::real). (y > w \ y^2 > (-b/a)*y + (-c/a))" + using ysq_dom_y_plus_coeff_2[where b = "-b/a", where c = "-c/a"] by auto + then have keyh: "\(w::real). \(y::real). (y > w \ a*y^2 < a*((-b/a)*y + (-c/a)))" + using alt by auto + have simp1: "\y. a*((-b/a)*y + (-c/a)) = a*(-b/a)*y + a*(-c/a)" + using diff_divide_eq_iff by fastforce + have simp2: "\y. a*(-b/a)*y + a*(-c/a) = -b*y + a*(-c/a)" + using assms by auto + have simp3: "\y. -b*y + a*(-c/a) = -b*y - c" + using assms by auto + then have "\y. a*((-b/a)*y + (-c/a)) = -b*y - c" using simp1 simp2 simp3 by auto + then have keyh2: "\(w::real). \(y::real). (y > w \ a*y^2 < -b*y-c)" + using keyh by auto + have "\y. a*y^2 < -b*y-c \ a*y^2 + b*y + c < 0" by auto + then show ?thesis using keyh2 by auto +qed + +lemma pos_lc_dom_quad: + fixes a:: "real" + fixes b:: "real" + fixes c:: "real" + assumes alt: "a > 0" + shows "\(w::real). \(y::real). (y > w \ a*y^2 + b*y + c > 0)" +proof - + have "-a < 0" using alt + by simp + then have "\(w::real). \(y::real). (y > w \ -a*y^2 - b*y - c < 0)" + using neg_lc_dom_quad[where a = "-a", where b = "-b", where c = "-c"] by auto + then obtain w where w_prop: "\(y::real). (y > w \ -a*y^2 - b*y - c < 0)" by auto + then have "\(y::real). (y > w \ a*y^2 + b*y + c > 0)" + by auto + then show ?thesis by auto +qed + +(* lemma interval_infinite: + fixes r p::"real" + assumes "r < p" + shows "infinite {r<..(d, e, f)\set les. \y'> q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\y'>q. (\(d, e, f)\set les. \x\{q<..y'}. d * x\<^sup>2 + e * x + f < 0))" +proof (induct les) + case Nil + then show ?case using gt_ex by auto +next + case (Cons z les) + have "\a\set les. case a of (d, e, f) \ \y'>q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f < 0" + using Cons.prems by auto + then have " \y'>q. \a\set les. case a of (d, e, f) \ \x\{q<..y'}. d * x\<^sup>2 + e * x + f < 0" + using Cons.hyps by auto + then obtain y1 where y1_prop : "y1>q \ (\a\set les. case a of (d, e, f) \ \x\{q<..y1}. d * x\<^sup>2 + e * x + f < 0)" + by auto + have "case z of (d, e, f) \ \y'>q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f < 0" + using Cons.prems by auto + then obtain y2 where y2_prop: "y2>q \ (case z of (d, e, f) \ (\x\{q<..y2}. d * x\<^sup>2 + e * x + f < 0))" + by auto + let ?y = "min y1 y2" + have "?y > q \ (\a\set (z#les). case a of (d, e, f) \ \x\{q<..?y}. d * x\<^sup>2 + e * x + f < 0)" + using y1_prop y2_prop + by force + then show ?case + by blast +qed + +lemma have_inbetween_point_les: + fixes r::"real" + assumes "(\(d, e, f)\set les. \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0)" + shows "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" +proof - + have "(\(d, e, f)\set les. \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\y'>r. (\(d, e, f)\set les. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using les_qe_inf_helper assms by auto + then have "(\y'>r. (\(d, e, f)\set les. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using assms + by blast + then obtain y where y_prop: "y > r \ (\(d, e, f)\set les. \x\{r<..y}. d * x\<^sup>2 + e * x + f < 0)" + by auto + have "\q. q > r \q < y" using y_prop dense by auto + then obtain q where q_prop: "q > r \ q < y" by auto + then have "(\(d, e, f)\set les. d*q^2 + e*q + f < 0)" + using y_prop by auto + then show ?thesis + by auto +qed + +lemma one_root_a_gt0: + fixes a b c r:: "real" + shows "\y'. b = 2 * a * r \ + \ a < 0 \ + a * r^2 - 2 * a *r*r + c = 0 \ + - r < y' \ + \x\{-r<..y'}. \ a * x\<^sup>2 + 2 * a * r*x + c < 0" +proof - + fix y' + assume beq: "b = 2 * a * r" + assume aprop: " \ a < 0" + assume root: " a * r\<^sup>2 - 2 * a *r*r + c = 0" + assume rootlt: "- r < y'" + show " \x\{- r<..y'}. \ a * x\<^sup>2 + 2 * a* r*x+ c < 0" + proof - + have h: "a = 0 \ (b = 0 \ c = 0)" using beq root + by auto + then have aeq: "a = 0 \ \x\{- r<..y'}. \ a * x\<^sup>2 + 2 * a*r*x + c < 0" + using rootlt + by (metis add.left_neutral continuity_lem_eq0 less_numeral_extra(3) mult_zero_left mult_zero_right) + then have alt: "a > 0 \ \x\{- r<..y'}. \ a * x\<^sup>2 + 2 * a *r*x + c < 0" + proof - + assume agt: "a > 0" + then have "\(w::real). \(y::real). (y > w \ a*y^2 + b*y + c > 0)" + using pos_lc_dom_quad by auto + then obtain w where w_prop: "\y::real. (y > w \ a*y^2 + b*y + c > 0)" by auto + have isroot: "a*(-r)^2 + b*(-r) + c = 0" using root beq by auto + then have wgteq: "w \ -(r)" + proof - + have "w < -r \ False" + using w_prop isroot by auto + then show ?thesis + using not_less by blast + qed + then have w1: "w + 1 > -r" + by auto + have w2: "a*(w + 1)^2 + b*(w+1) + c > 0" using w_prop by auto + have rootiff: "\x. a * x\<^sup>2 + b * x + c = 0 \ x = -r" using discriminant_lemma[where a = "a", where b = "b", where c= "c", where r = "r"] + isroot agt beq by auto + have allgt: "\x > -r. a*x^2 + b*x + c > 0" + proof clarsimp + fix x + assume "x > -r" + have xgtw: "x > w + 1 \ a*x^2 + b*x + c > 0 " + using w1 w2 rootiff poly_IVT_neg[where a = "w+1", where b = "x", where p = "[:c,b,a:]"] + quadratic_poly_eval + by (metis less_eq_real_def linorder_not_less) + have xltw: "x < w + 1 \ a*x^2 + b*x + c > 0" + using w1 w2 rootiff poly_IVT_pos[where a= "x", where b = "w + 1", where p = "[:c,b,a:]"] + quadratic_poly_eval less_eq_real_def linorder_not_less + by (metis \- r < x\) + then show "a*x^2 + b*x + c > 0" + using w2 xgtw xltw by fastforce + qed + have "\z. z > -r \ z < y'" using rootlt dense[where x = "-r", where y = "y'"] + by auto + then obtain z where z_prop: " z > -r \ z < y'" by auto + then have "a*z^2 + b*z + c > 0" using allgt by auto + then show ?thesis using z_prop + using beq greaterThanAtMost_iff by force + qed + then show ?thesis using aeq alt aprop + by linarith + qed +qed + +lemma leq_qe_inf_helper: + fixes q:: "real" + shows"(\(d, e, f)\set leq. \y'> q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\y'>q. (\(d, e, f)\set leq. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0))" +proof (induct leq) + case Nil + then show ?case using gt_ex by auto +next + case (Cons z leq) + have "\a\set leq. case a of (d, e, f) \ \y'>q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using Cons.prems by auto + then have " \y'>q. \a\set leq. case a of (d, e, f) \ \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using Cons.hyps by auto + then obtain y1 where y1_prop : "y1>q \ (\a\set leq. case a of (d, e, f) \ \x\{q<..y1}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + have "case z of (d, e, f) \ \y'>q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using Cons.prems by auto + then obtain y2 where y2_prop: "y2>q \ (case z of (d, e, f) \ (\x\{q<..y2}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + let ?y = "min y1 y2" + have "?y > q \ (\a\set (z#leq). case a of (d, e, f) \ \x\{q<..?y}. d * x\<^sup>2 + e * x + f \ 0)" + using y1_prop y2_prop + by force + then show ?case + by blast +qed + +lemma neq_qe_inf_helper: + fixes q:: "real" + shows"(\(d, e, f)\set neq. \y'> q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\y'>q. (\(d, e, f)\set neq. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0))" +proof (induct neq) + case Nil + then show ?case using gt_ex by auto +next + case (Cons z neq) + have "\a\set neq. case a of (d, e, f) \ \y'>q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using Cons.prems by auto + then have " \y'>q. \a\set neq. case a of (d, e, f) \ \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using Cons.hyps by auto + then obtain y1 where y1_prop : "y1>q \ (\a\set neq. case a of (d, e, f) \ \x\{q<..y1}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + have "case z of (d, e, f) \ \y'>q. \x\{q<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using Cons.prems by auto + then obtain y2 where y2_prop: "y2>q \ (case z of (d, e, f) \ (\x\{q<..y2}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + let ?y = "min y1 y2" + have "?y > q \ (\a\set (z#neq). case a of (d, e, f) \ \x\{q<..?y}. d * x\<^sup>2 + e * x + f \ 0)" + using y1_prop y2_prop + by force + then show ?case + by blast +qed + + +subsection "Some Casework" + +lemma quadratic_shape1a: + fixes a b c x y::"real" + assumes agt: "a > 0" + assumes xyroots: "x < y \ a*x^2 + b*x + c = 0 \ a*y^2 + b*y + c = 0" + shows "\z. (z > x \ z < y \ a*z^2 + b*z + c < 0)" +proof clarsimp + fix z + assume zgt: "z > x" + assume zlt: "z < y" + have frac_gtz: "(1/(2*a)) > 0" using agt + by simp + have xy_prop:"(x = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ y = (-b - sqrt(b^2 - 4*a*c))/(2*a)) + \ (y = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ x = (-b - sqrt(b^2 - 4*a*c))/(2*a))" + using xyroots agt discriminant_iff unfolding discrim_def by auto + have "b^2 - 4*a*c \ 0" using xyroots discriminant_iff + using assms(1) discrim_def by auto + then have pos_discrim: "b^2 - 4*a*c > 0" using xyroots discriminant_zero + using \0 \ b\<^sup>2 - 4 * a * c\ assms(1) discrim_def less_eq_real_def linorder_not_less + by metis + then have sqrt_gt: "sqrt(b^2 - 4*a*c) > 0" + using real_sqrt_gt_0_iff by blast + then have "(- b - sqrt(b^2 - 4*a*c)) < (- b + sqrt(b^2 - 4*a*c))" + by auto + then have "(- b - sqrt(b^2 - 4*a*c))*(1/(2*a)) < (- b + sqrt(b^2 - 4*a*c))*(1/(2*a)) " + using frac_gtz + by (simp add: divide_strict_right_mono) + then have "(- b - sqrt(b^2 - 4*a*c))/(2*a) < (- b + sqrt(b^2 - 4*a*c))/(2*a)" + by auto + then have xandy: "x = (- b - sqrt(b^2 - 4*a*c))/(2*a) \ y = (- b + sqrt(b^2 - 4*a*c))/(2*a)" + using xy_prop xyroots by auto + let ?mdpt = "-b/(2*a)" + have xlt: "x < ?mdpt" + using xandy sqrt_gt using frac_gtz divide_minus_left divide_strict_right_mono sqrt_gt + by (smt (verit) agt) + have ylt: "?mdpt < y" + using xandy sqrt_gt frac_gtz + by (smt (verit, del_insts) divide_strict_right_mono zero_less_divide_1_iff) + have mdpt_val: "a*?mdpt^2 + b*?mdpt + c < 0" + proof - + have firsteq: "a*?mdpt^2 + b*?mdpt + c = (a*b^2)/(4*a^2) - (b^2)/(2*a) + c" + by (simp add: power2_eq_square) + have h1: "(a*b^2)/(4*a^2) = (b^2)/(4*a)" + by (simp add: power2_eq_square) + have h2: "(b^2)/(2*a) = (2*b^2)/(4*a)" + by linarith + have h3: "c = (4*a*c)/(4*a)" + using agt by auto + have "a*?mdpt^2 + b*?mdpt + c = (b^2)/(4*a) - (2*b^2)/(4*a) + (4*a*c)/(4*a) " + using firsteq h1 h2 h3 + by linarith + then have "a*?mdpt^2 + b*?mdpt + c = (b^2 - 2*b^2 + 4*a*c)/(4*a)" + by (simp add: diff_divide_distrib) + then have eq2: "a*?mdpt^2 + b*?mdpt + c = (4*a*c - b^2)/(4*a)" + by simp + have h: "4*a*c - b^2 < 0" using pos_discrim by auto + have "1/(4*a) > 0" using agt by auto + then have "(4*a*c - b^2)*(1/(4*a)) < 0" + using h + using mult_less_0_iff by blast + then show ?thesis using eq2 by auto + qed + have nex: "\ (\k> x. k < y \ poly [:c, b, a:] k = 0)" + using discriminant_iff agt + by (metis (no_types, hide_lams) discrim_def order_less_irrefl quadratic_poly_eval xandy) + have nor2: "\ (\x>z. x < - b / (2 * a) \ poly [:c, b, a:] x = 0)" + using nex xlt ylt zgt zlt by auto + have nor: "\ (\x>- b / (2 * a). x < z \ poly [:c, b, a:] x = 0)" + using nex xlt ylt zgt zlt discriminant_iff agt by auto + then have mdpt_lt: "?mdpt < z \ a*z^2 + b*z + c < 0 " + using mdpt_val zgt zlt xlt ylt poly_IVT_pos[where p = "[:c, b, a:]", where a= "?mdpt", where b = "z"] + quadratic_poly_eval[of c b a] + by (metis \\ (\k>x. k < y \ poly [:c, b, a:] k = 0)\ linorder_neqE_linordered_idom) + have mdpt_gt: "?mdpt > z \ a*z^2 + b*z + c < 0 " + using zgt zlt mdpt_val xlt ylt nor2 poly_IVT_neg[where p = "[:c, b, a:]", where a = "z", where b = "?mdpt"] quadratic_poly_eval[of c b a] + by (metis linorder_neqE_linordered_idom nex) + then show "a*z^2 + b*z + c < 0" + using mdpt_lt mdpt_gt mdpt_val by fastforce +qed + +lemma quadratic_shape1b: + fixes a b c x y::"real" + assumes agt: "a > 0" + assumes xy_roots: "x < y \ a*x^2 + b*x + c = 0 \ a*y^2 + b*y + c = 0" + shows "\z. (z > y \ a*z^2 + b*z + c > 0)" +proof - + fix z + assume z_gt :"z > y" + have nogt: "\(\w. w > y \ a*w^2 + b*w + c = 0)" using xy_roots discriminant_iff + by (metis agt less_eq_real_def linorder_not_less) + have "\(w::real). \(y::real). (y > w \ a*y^2 + b*y + c > 0)" + using agt pos_lc_dom_quad by auto + then have "\k > y. a*k^2 + b*k + c > 0" + by (metis add.commute agt less_add_same_cancel1 linorder_neqE_linordered_idom pos_add_strict) + then obtain k where k_prop: "k > y \ a*k^2 + b*k + c > 0" by auto + have kgt: "k > z \ a*z^2 + b*z + c > 0" + proof - + assume kgt: "k > z" + then have zneq: "a*z^2 + b*z + c = 0 \ False" + using nogt using z_gt by blast + have znlt: "a*z^2 + b*z + c < 0 \ False" + using kgt k_prop quadratic_poly_eval[of c b a] z_gt nogt poly_IVT_pos[where a= "z", where b = "k", where p = "[:c, b, a:]"] + by (metis less_eq_real_def less_le_trans) + then show "a*z^2 + b*z + c > 0" using zneq znlt + using linorder_neqE_linordered_idom by blast + qed + have klt: "k < z \ a*z^2 + b*z + c > 0" + proof - + assume klt: "k < z" + then have zneq: "a*z^2 + b*z + c = 0 \ False" + using nogt using z_gt by blast + have znlt: "a*z^2 + b*z + c < 0 \ False" + using klt k_prop quadratic_poly_eval[of c b a] z_gt nogt poly_IVT_neg[where a= "k", where b = "z", where p = "[:c, b, a:]"] + by (metis add.commute add_less_cancel_left add_mono_thms_linordered_field(3) less_eq_real_def) + then show "a*z^2 + b*z + c > 0" using zneq znlt + using linorder_neqE_linordered_idom by blast + qed + then show "a*z^2 + b*z + c > 0" using k_prop kgt klt + by fastforce +qed + +lemma quadratic_shape2a: + fixes a b c x y::"real" + assumes "a < 0" + assumes "x < y \ a*x^2 + b*x + c = 0 \ a*y^2 + b*y + c = 0" + shows "\z. (z > x \ z < y \ a*z^2 + b*z + c > 0)" + using quadratic_shape1a[where a= "-a", where b = "-b", where c = "-c", where x = "x", where y = "y"] + using assms(1) assms(2) by fastforce + +lemma quadratic_shape2b: + fixes a b c x y::"real" + assumes "a < 0" + assumes "x < y \ a*x^2 + b*x + c = 0 \ a*y^2 + b*y + c = 0" + shows "\z. (z > y \ a*z^2 + b*z + c < 0)" + using quadratic_shape1b[where a= "-a", where b = "-b", where c = "-c", where x = "x", where y = "y"] + using assms(1) assms(2) by force + +lemma case_d1: + fixes a b c r::"real" + shows "b < 2 * a * r \ + a * r^2 - b*r + c = 0 \ + \y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c < 0" +proof - + assume b_lt: "b < 2*a*r" + assume root: "a*r^2 - b*r + c = 0" + then have "c = b*r - a*r^2" by auto + have aeq: "a = 0 \ \y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c < 0" + proof - + assume azer: "a = 0" + then have bltz: "b < 0" using b_lt by auto + then have "c = b*r" using azer root by auto + then have eval: "\x. a*x^2 + b*x + c = b*(x + r)" using azer + by (simp add: distrib_left) + have "\x > -r. b*(x + r) < 0" + proof clarsimp + fix x + assume xgt: "- r < x" + then have "x + r > 0" + by linarith + then show "b * (x + r) < 0" + using bltz using mult_less_0_iff by blast + qed + then show ?thesis using eval + using less_add_same_cancel1 zero_less_one + by (metis greaterThanAtMost_iff) + qed + have aneq: "a \ 0 \\y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c < 0" + proof - + assume aneq: "(a::real) \ 0" + have "b^2 - 4*a*c < 0 \ a * r\<^sup>2 + b * r + c \ 0" using root discriminant_negative[of a b c r] unfolding discrim_def + using aneq by auto + then have " a * r\<^sup>2 + b * r + c \ 0 \ + a * r\<^sup>2 - b * r + c = 0 \ + b\<^sup>2 < 4 * a * c \ False" + proof - + assume a1: "a * r\<^sup>2 - b * r + c = 0" + assume a2: "b\<^sup>2 < 4 * a * c" + have f3: "(0 \ - 1 * (4 * a * c) + (- 1 * b)\<^sup>2) = (4 * a * c + - 1 * (- 1 * b)\<^sup>2 \ 0)" + by simp + have f4: "(- 1 * b)\<^sup>2 + - 1 * (4 * a * c) = - 1 * (4 * a * c) + (- 1 * b)\<^sup>2" + by auto + have f5: "c + a * r\<^sup>2 + - 1 * b * r = a * r\<^sup>2 + c + - 1 * b * r" + by auto + have f6: "\x0 x1 x2 x3. (x3::real) * x0\<^sup>2 + x2 * x0 + x1 = x1 + x3 * x0\<^sup>2 + x2 * x0" + by simp + have f7: "\x1 x2 x3. (discrim x3 x2 x1 < 0) = (\ 0 \ discrim x3 x2 x1)" + by auto + have f8: "\r ra rb. discrim r ra rb = ra\<^sup>2 + - 1 * (4 * r * rb)" + using discrim_def by auto + have "\ 4 * a * c + - 1 * (- 1 * b)\<^sup>2 \ 0" + using a2 by simp + then have "a * r\<^sup>2 + c + - 1 * b * r \ 0" + using f8 f7 f6 f5 f4 f3 by (metis (no_types) aneq discriminant_negative) + then show False + using a1 by linarith + qed + then have "\(b^2 - 4*a*c < 0)" using root + using \b\<^sup>2 - 4 * a * c < 0 \ a * r\<^sup>2 + b * r + c \ 0\ by auto + then have discrim: "b\<^sup>2 \ 4 * a * c " by auto + then have req: "r = (b + sqrt(b^2 - 4*a*c))/(2*a) \ r = (b - sqrt(b^2 - 4*a*c))/(2*a)" + using aneq root discriminant_iff[where a="a", where b ="-b", where c="c", where x="r"] unfolding discrim_def + by auto + then have "r = (b - sqrt(b^2 - 4*a*c))/(2*a) \ b > 2*a*r" + proof - + assume req: "r = (b - sqrt(b^2 - 4*a*c))/(2*a)" + then have h1: "2*a*r = 2*a*((b - sqrt(b^2 - 4*a*c))/(2*a))" by auto + then have h2: "2*a*((b - sqrt(b^2 - 4*a*c))/(2*a)) = b - sqrt(b^2 - 4*a*c)" + using aneq by auto + have h3: "sqrt(b^2 - 4*a*c) \ 0" using discrim by auto + then have "b - sqrt(b^2 - 4*a*c) < b" + using b_lt h1 h2 by linarith + then show ?thesis using req h2 by auto + qed + then have req: "r = (b + sqrt(b^2 - 4*a*c))/(2*a)" using req b_lt by auto + then have discrim2: "b^2 - 4 *a*c > 0" using aneq b_lt by auto + then have "\x y. x \ y \ a * x\<^sup>2 + b * x + c = 0 \ a * y\<^sup>2 + b * y + c = 0" + using aneq discriminant_pos_ex[of a b c] unfolding discrim_def + by auto + then obtain x y where xy_prop: "x < y \ a * x\<^sup>2 + b * x + c = 0 \ a * y\<^sup>2 + b * y + c = 0" + by (meson linorder_neqE_linordered_idom) + then have "(x = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ y = (-b - sqrt(b^2 - 4*a*c))/(2*a)) +\ (y = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ x = (-b - sqrt(b^2 - 4*a*c))/(2*a))" + using aneq discriminant_iff unfolding discrim_def by auto + then have xy_prop2: "(x = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ y = -r) + \ (y = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ x = -r)" using req + by (simp add: \x = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ x = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ minus_divide_left) + (* When a < 0, -r is the bigger root *) + have alt: "a < 0 \ \k > -r. a * k^2 + b * k + c < 0" + proof clarsimp + fix k + assume alt: " a < 0" + assume "- r < k" + have alt2: " (1/(2*a)::real) < 0" using alt + by simp + have "(-b - sqrt(b^2 - 4*a*c)) < (-b + sqrt(b^2 - 4*a*c))" + using discrim2 by auto + then have "(-b - sqrt(b^2 - 4*a*c))* (1/(2*a)::real) > (-b + sqrt(b^2 - 4*a*c))* (1/(2*a)::real)" + using alt2 + using mult_less_cancel_left_neg by fastforce + then have rgtroot: "-r > (-b + sqrt(b^2 - 4*a*c))/(2*a)" + using req \x = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ x = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ xy_prop2 + by auto + then have "(y = -r \ x = (-b + sqrt(b^2 - 4*a*c))/(2*a))" + using xy_prop xy_prop2 by auto + then show "a * k^2 + b * k + c < 0" + using xy_prop \- r < k\ alt quadratic_shape2b xy_prop + by blast + qed + (* When a > 0, -r is the smaller root *) + have agt: "a > 0 \ \y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c < 0" + proof - + assume agt: "a> 0" + have alt2: " (1/(2*a)::real) > 0" using agt + by simp + have "(-b - sqrt(b^2 - 4*a*c)) < (-b + sqrt(b^2 - 4*a*c))" + using discrim2 by auto + then have "(-b - sqrt(b^2 - 4*a*c))* (1/(2*a)::real) < (-b + sqrt(b^2 - 4*a*c))* (1/(2*a)::real)" + using alt2 + proof - + have f1: "- b - sqrt (b\<^sup>2 - c * (4 * a)) < - b + sqrt (b\<^sup>2 - c * (4 * a))" + by (metis \- b - sqrt (b\<^sup>2 - 4 * a * c) < - b + sqrt (b\<^sup>2 - 4 * a * c)\ mult.commute) + have "0 < a * 2" + using \0 < 1 / (2 * a)\ by auto + then show ?thesis + using f1 by (simp add: divide_strict_right_mono mult.commute) + qed + then have rlltroot: "-r < (-b + sqrt(b^2 - 4*a*c))/(2*a)" + using req \x = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ x = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ xy_prop2 + by auto + then have "(x = -r \ y = (-b + sqrt(b^2 - 4*a*c))/(2*a))" + using xy_prop xy_prop2 by auto + have "\k. x < k \ k < y" using xy_prop dense by auto + then obtain k where k_prop: "x < k \ k < y" by auto + then have "\x\{-r<..k}. a * x\<^sup>2 + b * x + c < 0" + using agt quadratic_shape1a[where a= "a", where b = "b", where c= "c", where x = "x", where y = "y"] + using \x = - r \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ greaterThanAtMost_iff xy_prop by auto + then show "\y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c < 0" + using k_prop using \x = - r \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ by blast + qed + show ?thesis + using alt agt + by (metis aneq greaterThanAtMost_iff less_add_same_cancel1 linorder_neqE_linordered_idom zero_less_one) + qed + show "\y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c < 0" using aeq aneq + by blast +qed + +lemma case_d4: + fixes a b c r::"real" + shows "\y'. b \ 2 * a * r \ + \ b < 2 * a * r \ + a *r^2 - b * r + c = 0 \ + -r < y' \ \x\{-r<..y'}. \ a * x\<^sup>2 + b * x + c < 0" +proof - + fix y' + assume bneq: "b \ 2 * a * r" + assume bnotless: "\ b < 2 * a * r" + assume root: "a *r^2 - b * r + c = 0" + assume y_prop: "-r < y'" + have b_gt: "b > 2*a*r" using bneq bnotless by auto + have aeq: "a = 0 \ \y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c > 0" + proof - + assume azer: "a = 0" + then have bgt: "b > 0" using b_gt by auto + then have "c = b*r" using azer root by auto + then have eval: "\x. a*x^2 + b*x + c = b*(x + r)" using azer + by (simp add: distrib_left) + have "\x > -r. b*(x + r) > 0" + proof clarsimp + fix x + assume xgt: "- r < x" + then have "x + r > 0" + by linarith + then show "b * (x + r) > 0" + using bgt by auto + qed + then show ?thesis using eval + using less_add_same_cancel1 zero_less_one + by (metis greaterThanAtMost_iff) + qed + have aneq: "a \ 0 \\y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c > 0" + proof - + assume aneq: "a\0" + { + assume a1: "a * r\<^sup>2 - b * r + c = 0" + assume a2: "b\<^sup>2 < 4 * a * c" + have f3: "(0 \ - 1 * (4 * a * c) + (- 1 * b)\<^sup>2) = (4 * a * c + - 1 * (- 1 * b)\<^sup>2 \ 0)" + by simp + have f4: "(- 1 * b)\<^sup>2 + - 1 * (4 * a * c) = - 1 * (4 * a * c) + (- 1 * b)\<^sup>2" + by auto + have f5: "c + a * r\<^sup>2 + - 1 * b * r = a * r\<^sup>2 + c + - 1 * b * r" + by auto + have f6: "\x0 x1 x2 x3. (x3::real) * x0\<^sup>2 + x2 * x0 + x1 = x1 + x3 * x0\<^sup>2 + x2 * x0" + by simp + have f7: "\x1 x2 x3. (discrim x3 x2 x1 < 0) = (\ 0 \ discrim x3 x2 x1)" + by auto + have f8: "\r ra rb. discrim r ra rb = ra\<^sup>2 + - 1 * (4 * r * rb)" + using discrim_def by auto + have "\ 4 * a * c + - 1 * (- 1 * b)\<^sup>2 \ 0" + using a2 by simp + then have "a * r\<^sup>2 + c + - 1 * b * r \ 0" + using f8 f7 f6 f5 f4 f3 by (metis (no_types) aneq discriminant_negative) + then have False + using a1 by linarith + } note * = this + have "b^2 - 4*a*c < 0 \ a * r\<^sup>2 + b * r + c \ 0" using root discriminant_negative[of a b c r] unfolding discrim_def + using aneq by auto + then have "\(b^2 - 4*a*c < 0)" using root * by auto + then have discrim: "b\<^sup>2 \ 4 * a * c " by auto + then have req: "r = (b + sqrt(b^2 - 4*a*c))/(2*a) \ r = (b - sqrt(b^2 - 4*a*c))/(2*a)" + using aneq root discriminant_iff[where a="a", where b ="-b", where c="c", where x="r"] unfolding discrim_def + by auto + then have "r = (b + sqrt(b^2 - 4*a*c))/(2*a) \ b < 2*a*r" + proof - + assume req: "r = (b + sqrt(b^2 - 4*a*c))/(2*a)" + then have h1: "2*a*r = 2*a*((b + sqrt(b^2 - 4*a*c))/(2*a))" by auto + then have h2: "2*a*((b + sqrt(b^2 - 4*a*c))/(2*a)) = b + sqrt(b^2 - 4*a*c)" + using aneq by auto + have h3: "sqrt(b^2 - 4*a*c) \ 0" using discrim by auto + then have "b + sqrt(b^2 - 4*a*c) > b" + using b_gt h1 h2 by linarith + then show ?thesis using req h2 by auto + qed + then have req: "r = (b - sqrt(b^2 - 4*a*c))/(2*a)" using req b_gt + using aneq discrim by auto + then have discrim2: "b^2 - 4 *a*c > 0" using aneq b_gt by auto + then have "\x y. x \ y \ a * x\<^sup>2 + b * x + c = 0 \ a * y\<^sup>2 + b * y + c = 0" + using aneq discriminant_pos_ex[of a b c] unfolding discrim_def + by auto + then obtain x y where xy_prop: "x < y \ a * x\<^sup>2 + b * x + c = 0 \ a * y\<^sup>2 + b * y + c = 0" + by (meson linorder_neqE_linordered_idom) + then have "(x = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ y = (-b - sqrt(b^2 - 4*a*c))/(2*a)) +\ (y = (-b + sqrt(b^2 - 4*a*c))/(2*a) \ x = (-b - sqrt(b^2 - 4*a*c))/(2*a))" + using aneq discriminant_iff unfolding discrim_def by auto + then have xy_prop2: "(x = (-b - sqrt(b^2 - 4*a*c))/(2*a) \ y = -r) + \ (y = (-b - sqrt(b^2 - 4*a*c))/(2*a) \ x = -r)" using req divide_inverse minus_diff_eq mult.commute mult_minus_right + by (smt (verit, ccfv_SIG) uminus_add_conv_diff) + (* When a > 0, -r is the greater root *) + have agt: "a > 0 \ \k > -r. a * k^2 + b * k + c > 0" + proof clarsimp + fix k + assume agt: " a > 0" + assume "- r < k" + have agt2: " (1/(2*a)::real) > 0" using agt + by simp + have "(-b - sqrt(b^2 - 4*a*c)) < (-b + sqrt(b^2 - 4*a*c))" + using discrim2 by auto + then have "(-b - sqrt(b^2 - 4*a*c))* (1/(2*a)::real) < (-b + sqrt(b^2 - 4*a*c))* (1/(2*a)::real)" + using agt2 by (simp add: divide_strict_right_mono) + then have rgtroot: "-r > (-b - sqrt(b^2 - 4*a*c))/(2*a)" + using req \x = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ x = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ xy_prop2 + by auto + then have "(x = (-b - sqrt(b^2 - 4*a*c))/(2*a)) \ y = -r" + using xy_prop xy_prop2 + by auto + then show "a * k^2 + b * k + c > 0" + using \- r < k\ xy_prop agt quadratic_shape1b[where a= "a", where b ="b", where c="c", where x = "x", where y = "-r", where z = "k"] + by blast + qed + (* When a < 0, -r is the smaller root *) + have agt2: "a < 0 \ \y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c > 0" + proof - + assume alt: "a<0" + have alt2: " (1/(2*a)::real) < 0" using alt + by simp + have "(-b - sqrt(b^2 - 4*a*c)) < (-b + sqrt(b^2 - 4*a*c))" + using discrim2 by auto + then have "(-b - sqrt(b^2 - 4*a*c))* (1/(2*a)::real) > (-b + sqrt(b^2 - 4*a*c))* (1/(2*a)::real)" + using alt2 using mult_less_cancel_left_neg by fastforce + then have rlltroot: "-r < (-b - sqrt(b^2 - 4*a*c))/(2*a)" + using req + using \x = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ y = (- b + sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a) \ x = (- b - sqrt (b\<^sup>2 - 4 * a * c)) / (2 * a)\ + xy_prop2 + by auto + then have h: "(x = -r \ y = (-b - sqrt(b^2 - 4*a*c))/(2*a))" + using xy_prop xy_prop2 + by auto + have "\k. x < k \ k < y" using xy_prop dense by auto + then obtain k where k_prop: "x < k \ k < y" by auto + then have "\x\{-r<..k}. a * x\<^sup>2 + b * x + c > 0" + using alt quadratic_shape2a[where a= "a", where b = "b", where c= "c", where x = "x", where y = "y"] + xy_prop h greaterThanAtMost_iff by auto + then show "\y'>- r. \x\{-r<..y'}. a * x\<^sup>2 + b * x + c > 0" + using k_prop using h by blast + qed + show ?thesis + using aneq agt agt2 + by (meson greaterThanAtMost_iff linorder_neqE_linordered_idom y_prop) + qed + show "\x\{-r<..y'}. \ a * x\<^sup>2 + b * x + c < 0" using aneq aeq + by (metis greaterThanAtMost_iff less_eq_real_def linorder_not_less y_prop) +qed + +lemma one_root_a_lt0: + fixes a b c r y'::"real" + assumes alt: "a < 0" + assumes beq: "b = 2 * a * r" + assumes root: " a * r^2 - 2*a*r*r + c = 0" + shows "\y'>- r. \x\{- r<..y'}. a * x\<^sup>2 + 2*a*r*x + c < 0" +proof - + have root_iff: "\x. a * x\<^sup>2 + b * x + c = 0 \ x = -r" using alt root discriminant_lemma[where r = "r"] beq + by auto + have "a < 0 \ (\y. \x > y. a*x^2 + b*x + c < 0)" using neg_lc_dom_quad + by auto + then obtain k where k_prop: "\x > k. a*x^2 + b*x + c < 0" using alt by auto + let ?mx = "max (k+1) (-r + 1)" + have "a*?mx^2 + b*?mx + c < 0" using k_prop by auto + then have "\y > -r. a*y^2 + b*y + c < 0" + by force + then obtain z where z_prop: "z > -r \ a*z^2 + b*z + c < 0" by auto + have poly_eval_prop: "\(x::real). poly [:c, b, a :] x = a*x^2 + b*x + c" + using quadratic_poly_eval by auto + then have nozer: "\(\x. (x > -r \ poly [:c, b, a :] x = 0))" using root_iff + by (simp add: add.commute) + have poly_z: "poly [:c, b, a:] z < 0" using z_prop poly_eval_prop by auto + have "\y > -r. a*y^2 + b*y + c < 0" + proof clarsimp + fix y + assume ygt: "- r < y" + have h1: "y = z \ a * y\<^sup>2 + b * y + c < 0" using z_prop by auto + have h2: "y < z \ a * y\<^sup>2 + b * y + c < 0" proof - + assume ylt: "y < z" + have notz: "a*y^2 + b*y + c \ 0" using ygt nozer poly_eval_prop by auto + have h1: "a *y^2 + b*y + c > 0 \ poly [:c, b, a:] y > 0" using poly_eval_prop by auto + have ivtprop: "poly [:c, b, a:] y > 0 \ (\x. y < x \ x < z \ poly [:c, b, a:] x = 0)" + using ylt poly_z poly_IVT_neg[where a = "y", where b = "z", where p = "[:c, b, a:]"] + by auto + then have "a*y^2 + b*y + c > 0 \ False" using h1 ivtprop ygt nozer by auto + then show "a*y^2 + b*y + c < 0" using notz + using linorder_neqE_linordered_idom by blast + qed + have h3: "y > z \ a * y\<^sup>2 + b * y + c < 0" + proof - + assume ygtz: "y > z" + have notz: "a*y^2 + b*y + c \ 0" using ygt nozer poly_eval_prop by auto + have h1: "a *y^2 + b*y + c > 0 \ poly [:c, b, a:] y > 0" using poly_eval_prop by auto + have ivtprop: "poly [:c, b, a:] y > 0 \ (\x. z < x \ x < y \ poly [:c, b, a:] x = 0)" + using ygtz poly_z using poly_IVT_pos by blast + then have "a*y^2 + b*y + c > 0 \ False" using h1 ivtprop z_prop nozer by auto + then show "a*y^2 + b*y + c < 0" using notz + using linorder_neqE_linordered_idom by blast + qed + show "a * y\<^sup>2 + b * y + c < 0" using h1 h2 h3 + using linorder_neqE_linordered_idom by blast + qed + then show ?thesis + using \\y>- r. a * y\<^sup>2 + b * y + c < 0\ beq by auto +qed + + +lemma one_root_a_lt0_var: + fixes a b c r y'::"real" + assumes alt: "a < 0" + assumes beq: "b = 2 * a * r" + assumes root: " a * r^2 - 2*a*r*r + c = 0" + shows "\y'>- r. \x\{- r<..y'}. a * x\<^sup>2 + 2*a*r*x + c \ 0" +proof - + have h1: "\y'>- r. \x\{- r<..y'}. a * x\<^sup>2 + 2 * a * r * x + c < 0 \ + \y'>-r. \x\{- r<..y'}. a * x\<^sup>2 + 2 * a *r * x + c \ 0" + using less_eq_real_def by blast + then show ?thesis + using one_root_a_lt0[of a b r] assms by auto +qed + +subsection "More Continuity Properties" +lemma continuity_lem_gt0_expanded_var: + fixes r:: "real" + fixes a b c:: "real" + fixes k::"real" + assumes kgt: "k > r" + shows "a*r^2 + b*r + c > 0 \ + \x\{r<..k}. a*x^2 + b*x + c \ 0" +proof - + assume a: "a*r^2 + b*r + c > 0 " + have h: "\x\{r<..k}. a*x^2 + b*x + c > 0 \ \x\{r<..k}. a*x^2 + b*x + c \ 0" + using less_eq_real_def by blast + have "\x\{r<..k}. a*x^2 + b*x + c > 0" using a continuity_lem_gt0_expanded[of r k a b c] assms by auto + then show "\x\{r<..k}. a*x^2 + b*x + c \ 0" + using h by auto +qed + +lemma continuity_lem_lt0_expanded_var: + fixes r:: "real" + fixes a b c:: "real" + shows "a*r^2 + b*r + c < 0 \ + \y'> r. \x\{r<..y'}. a*x^2 + b*x + c \ 0" +proof - + assume "a*r^2 + b*r + c < 0 " + then have " \y'> r. \x\{r<..y'}. a*x^2 + b*x + c < 0" + using continuity_lem_lt0_expanded by auto + then show " \y'> r. \x\{r<..y'}. a*x^2 + b*x + c \ 0" + using less_eq_real_def by auto +qed + +lemma nonzcoeffs: + fixes a b c r::"real" + shows "a\0 \ b\0 \ c\0 \ \y'>r. \x\{r<..y'}. a * x\<^sup>2 + b * x + c \ 0 " +proof - + assume "a\0 \ b\0 \ c\0" + then have fin: "finite {x. a*x^2 + b*x + c = 0}" + by (metis pCons_eq_0_iff poly_roots_finite poly_roots_set_same) + (* then have fin2: "finite {x. a*x^2 + b*x + c = 0 \ x > r}" + using finite_Collect_conjI by blast *) + let ?s = "{x. a*x^2 + b*x + c = 0}" + have imp: "(\q \ ?s. q > r) \ (\q \ ?s. (q > r \ (\x \ ?s. x > r \ x \ q)))" + proof - + assume asm: "(\q \ ?s. q > r)" + then have none: "{q. q \ ?s \ q > r} \ {}" + by blast + have fin2: "finite {q. q \ ?s \ q > r}" using fin + by simp + have "\k. k = Min {q. q \ ?s \ q > r}" using fin2 none + by blast + then obtain k where k_prop: "k = Min {q. q \ ?s \ q > r}" by auto + then have kp1: "k \ ?s \ k > r" + using Min_in fin2 none + by blast + then have kp2: "\x \ ?s. x > r \ x \ k" + using Min_le fin2 using k_prop by blast + show "(\q \ ?s. (q > r \ (\x \ ?s. x > r \ x \ q)))" + using kp1 kp2 by blast + qed + have h2: "(\q \ ?s. q > r) \ \y'>r. \x\{r<..y'}. a * x\<^sup>2 + b * x + c \ 0" + proof - + assume "(\q \ ?s. q > r)" + then obtain q where q_prop: "q \ ?s \ (q > r \ (\x \ ?s. x > r \ x \ q))" + using imp by blast + then have "\w. w > r \ w < q" using dense + by blast + then obtain w where w_prop: "w > r \ w < q" by auto + then have "\(\x\{r<..w}. x \ ?s)" + using w_prop q_prop by auto + then have "\x\{r<..w}. a * x\<^sup>2 + b * x + c \ 0" + by blast + then show "\y'>r. \x\{r<..y'}. a * x\<^sup>2 + b * x + c \ 0" + using w_prop by blast + qed + have h1: "\(\q \ ?s. q > r) \ \y'>r. \x\{r<..y'}. a * x\<^sup>2 + b * x + c \ 0" + proof - + assume "\(\q \ ?s. q > r)" + then have "\x\{r<..(r+1)}. a * x\<^sup>2 + b * x + c \ 0" + using greaterThanAtMost_iff by blast + then show ?thesis + using less_add_same_cancel1 less_numeral_extra(1) by blast + qed + then show "\y'>r. \x\{r<..y'}. a * x\<^sup>2 + b * x + c \ 0" + using h2 by blast +qed + + +(* Show if there are infinitely many values of x where a*x^2 + b*x + c is 0, +then the a*x^2 + b*x + c is the zero polynomial *) +lemma infzeros : + fixes y:: "real" + assumes "\x::real < (y::real). a * x\<^sup>2 + b * x + c = 0" + shows "a = 0 \ b=0 \ c=0" +proof - + let ?A = "{(x::real). x < y}" + have "\ (n::nat) f. ?A = f ` {i. i < n} \ inj_on f {i. i < n} \ False" + proof clarsimp + fix n:: "nat" + fix f + assume xlt: "{x. x < y} = f ` {i. i < n}" + assume injh: "inj_on f {i. i < n}" + have "?A \ {}" + by (simp add: linordered_field_no_lb) + then have ngtz: "n > 0" + using xlt injh using gr_implies_not_zero by auto + have cardisn: "card ?A = n" using xlt injh + by (simp add: card_image) + have "\k::nat. ((y - (k::nat) - 1) \ ?A)" + by auto + then have subs: "{k. \(x::nat). k = y - x - 1 \ 0 \ x \ x \ n} \ ?A" + by auto + have seteq: "(\x. y - real x - 1) ` {0..n} ={k. \(x::nat). k = y - x - 1 \ 0 \ x \ x \ n}" + by auto + have injf: "inj_on (\x. y - real x - 1) {0..n}" + unfolding inj_on_def by auto + have "card {k. \(x::nat). k = y - x - 1 \ 0 \ x \ x \ n} = n + 1" + using injf seteq card_atMost inj_on_iff_eq_card[where A = "{0..n}", where f = "\x. y - x - 1"] + by auto + then have if_fin: "finite ?A \ card ?A \ n + 1" + using subs card_mono + by (metis (lifting) card_mono) + then have if_inf: "infinite ?A \ card ?A = 0" + by (meson card.infinite) + then show "False" using if_fin if_inf cardisn ngtz by auto + qed + then have nfin: "\ finite {(x::real). x < y}" + using finite_imp_nat_seg_image_inj_on by blast + have "{(x::real). x < y} \ {x. a*x^2 + b*x + c = 0}" + using assms by auto + then have nfin2: "\ finite {x. a*x^2 + b*x + c = 0}" + using nfin finite_subset by blast + { + fix x + assume "a * x\<^sup>2 + b * x + c = 0" + then have f1: "a * (x * x) + x * b + c = 0" + by (simp add: Groups.mult_ac(2) power2_eq_square) + have f2: "\r. c + (r + (c + - c)) = r + c" + by simp + have f3: "\r ra rb. (rb::real) * ra + ra * r = (rb + r) * ra" + by (metis Groups.mult_ac(2) Rings.ring_distribs(2)) + have "\r. r + (c + - c) = r" + by simp + then have "c + x * (b + x * a) = 0" + using f3 f2 f1 by (metis Groups.add_ac(3) Groups.mult_ac(1) Groups.mult_ac(2)) + } + hence "{x. a*x^2 + b*x + c = 0} \ {x. poly [:c, b, a:] x = 0}" + by auto + then have " \ finite {x. poly [:c, b, a:] x = 0}" + using nfin2 using finite_subset by blast + then have "[:c, b, a:] = 0" + using poly_roots_finite[where p = "[:c, b, a:]"] by auto + then show ?thesis + by auto +qed + + + +lemma have_inbetween_point_leq: + fixes r::"real" + assumes "(\((d::real), (e::real), (f::real))\set leq. \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + shows "(\x. (\(a, b, c)\set leq. a * x\<^sup>2 + b * x + c \ 0))" +proof - + have "(\(d, e, f)\set leq. \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\y'>r. (\(d, e, f)\set leq. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using leq_qe_inf_helper assms by auto + then have "(\y'>r. (\(d, e, f)\set leq. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using assms + by blast + then obtain y where y_prop: "y > r \ (\(d, e, f)\set leq. \x\{r<..y}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + have "\q. q > r \q < y" using y_prop dense by auto + then obtain q where q_prop: "q > r \ q < y" by auto + then have "(\(d, e, f)\set leq. d*q^2 + e*q + f \ 0)" + using y_prop by auto + then show ?thesis + by auto +qed + + +lemma have_inbetween_point_neq: + fixes r::"real" + assumes "(\((d::real), (e::real), (f::real))\set neq. \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + shows "(\x. (\(a, b, c)\set neq. a * x\<^sup>2 + b * x + c \ 0))" +proof - + have "(\(d, e, f)\set neq. \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\y'>r. (\(d, e, f)\set neq. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using neq_qe_inf_helper assms by auto + then have "(\y'>r. (\(d, e, f)\set neq. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using assms + by blast + then obtain y where y_prop: "y > r \ (\(d, e, f)\set neq. \x\{r<..y}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + have "\q. q > r \q < y" using y_prop dense by auto + then obtain q where q_prop: "q > r \ q < y" by auto + then have "(\(d, e, f)\set neq. d*q^2 + e*q + f \ 0)" + using y_prop by auto + then show ?thesis + by auto +qed + +subsection "Setting up and Helper Lemmas" +subsubsection "The les\\_qe lemma" +lemma les_qe_forward : + shows "(((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))))) \ ((\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)))" +proof - + assume big_asm: "(((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)))))" + then have big_or: "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ + (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ + (\(a', b', c')\set les. a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)) " + by auto + have h1_helper: "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ (\y.\x(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + show "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ (\y.\x(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof (induct les) + case Nil + then show ?case + by auto + next + case (Cons q les) + have ind: " \a\set (q # les). case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0" + using Cons.prems + by auto + then have "case q of (a, ba, c) \ \x. \y2 + ba * y + c < 0 " + by simp + then obtain y2 where y2_prop: "case q of (a, ba, c) \ (\y2 + ba * y + c < 0)" + by auto + have "\a\set les. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0" + using ind by simp + then have " \y. \xa\set les. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0" + using Cons.hyps by blast + then obtain y1 where y1_prop: "\xa\set les. case a of (a, ba, c) \ a * x^2 + ba * x + c < 0" + by blast + let ?y = "min y1 y2" + have "\x < ?y. (\a\set (q #les). case a of (a, ba, c) \ a * x^2 + ba * x + c < 0)" + using y1_prop y2_prop + by fastforce + then show ?case + by blast + qed + qed + then have h1: "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + by (smt (z3) infzeros less_eq_real_def not_numeral_le_zero) + (* apply (auto) + by (metis (lifting) infzeros zero_neq_numeral) *) + have h2: " (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ (\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + assume asm: "(\(a', b', c')\set les. a' = 0 \ b' \ 0 \ + (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0))" + then obtain a' b' c' where abc_prop: "(a', b', c') \set les \ a' = 0 \ b' \ 0 \ + (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)" + by auto + then show "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using have_inbetween_point_les by auto + qed + have h3: " (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ ((\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)))" + proof - + assume asm: "\(a', b', c')\set les. a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set les \ a' \ 0 \ 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)" + by auto + then show "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using have_inbetween_point_les by auto + qed + have h4: "(\(a', b', c')\set les. a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)) \ (\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + assume asm: "(\(a', b', c')\set les. a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)) " + then obtain a' b' c' where abc_prop: "(a', b', c')\set les \ a' \ 0 \ 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)" + by auto + then have "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using have_inbetween_point_les by auto + then show ?thesis using asm by auto + qed + show ?thesis using big_or h1 h2 h3 h4 + by blast +qed + +(*sample points, some starter proofs below in comments *) +lemma les_qe_backward : + shows "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + ((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))))" + +proof - + assume havex: "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + then obtain x where x_prop: "\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0" by auto + have h: "(\ (\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ \ (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ + \ (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ + \ (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0))) \ False" + proof - + assume big: "(\ (\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ \ (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ + \ (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ + \ (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)))" + have notneginf: "\ (\(a, b, c)\set les. \x. \y2 + b * y + c < 0)" using big by auto + have notlinroot: "\ (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using big by auto + have notquadroot1: " \ (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using big by auto + have notquadroot2:" \ (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using big by auto + have nok: "\ (\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + proof - + have "(\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ False" + proof - + assume "(\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + then obtain k a b c where k_prop: "(a, b, c) \ set les \ a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0)" + by auto + have azer: "a = 0 \ False" + proof - + assume azer: "a = 0" + then have "b = 0 \ c = 0" using k_prop by auto + then have bnonz: "b\ 0" + using azer x_prop k_prop + by auto + then have "k = -c/b" using k_prop azer + by (metis (no_types, hide_lams) add.commute add.left_neutral add_uminus_conv_diff diff_le_0_iff_le divide_non_zero less_eq_real_def mult_zero_left neg_less_iff_less order_less_irrefl real_add_less_0_iff) + then have " (\(a', b', c')\set les. + a' = 0 \ b' \ 0 \ (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using k_prop azer bnonz by auto + then show "False" using notlinroot + by auto + qed + have anonz: "a \ 0 \ False" + proof - + assume anonz: "a \ 0 " + let ?r1 = "(- b - sqrt (b^2 - 4 * a * c)) / (2 * a)" + let ?r2 = "(- b + sqrt (b^2 - 4 * a * c)) / (2 * a)" + have discr: "4 * a * c \ b^2" using anonz k_prop discriminant_negative[of a b c] + unfolding discrim_def + by fastforce + then have "k = ?r1 \ k = ?r2" using k_prop discriminant_nonneg[of a b c] unfolding discrim_def + using anonz + by auto + then have "(\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) \ + (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using discr anonz notquadroot1 notquadroot2 k_prop + by auto + then show "False" using notquadroot1 notquadroot2 + by auto + qed + show "False" + using azer anonz by auto + qed + then show ?thesis by auto + qed + have finset: "finite (set les)" + by blast + have h1: "(\(a, b, c)\set les. a = 0 \ b = 0 \ c = 0) \ False" + using x_prop by fastforce + then have h2: "\(\(a, b, c)\set les. a = 0 \ b = 0 \ c = 0) \ False" + proof - + assume nozer: "\(\(a, b, c)\set les. a = 0 \ b = 0 \ c = 0)" + then have same_set: "root_set (set les) = set (sorted_root_list_set (set les))" + using root_set_finite finset set_sorted_list_of_set + by (simp add: nozer root_set_finite sorted_root_list_set_def) + have xnotin: "x \ root_set (set les)" + unfolding root_set_def using x_prop by auto + let ?srl = "sorted_root_list_set (set les)" + have notinlist: "\ List.member ?srl x" + using xnotin same_set + by (simp add: in_set_member) + then have notmem: "\n < (length ?srl). x \ nth_default 0 ?srl n" + using nth_mem same_set xnotin nth_default_def + by metis + show ?thesis + proof (induct ?srl) + case Nil + then have "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0)" + proof clarsimp + fix a b c + assume noroots: "[] = sorted_root_list_set (set les)" + assume inset: "(a, b, c) \ set les" + have "{} = root_set (set les)" + using noroots same_set + by auto + then have nozero: "\(\x. a*x^2 + b*x + c = 0)" + using inset unfolding root_set_def by auto + have "\y2 + b * y + c < 0" + proof clarsimp + fix y + assume "y < x" + then have "sign_num (a*x^2 + b*x + c) = sign_num (a*y^2 + b*y + c)" + using nozero by (metis changes_sign_var) + then show "a * y\<^sup>2 + b * y + c < 0" + unfolding sign_num_def using x_prop inset + by (smt split_conv) + qed + then show "\x. \y2 + b * y + c < 0" + by auto + qed + then show ?case using notneginf by auto + next + case (Cons w xa) + (* Need to argue that x isn't greater than the largest element of ?srl *) + (* that if srl has length \ 2, x isn't in between any of the roots of ?srl*) + (* and that x isn't less than the lowest root in ?srl *) + then have lengthsrl: "length ?srl > 0" by auto + have neginf: "x < nth_default 0 ?srl 0 \ False" + proof - + assume xlt: "x < nth_default 0 ?srl 0" + have all: "(\(a, b, c)\set les. \y2 + b * y + c < 0)" + proof clarsimp + fix a b c y + assume inset: "(a, b, c) \ set les" + assume "y < x" + have xl: "a*x^2 + b*x + c < 0" using x_prop inset by auto + have "\(\q. q < nth_default 0 ?srl 0 \ a*q^2 + b*q + c = 0)" + proof - + have "(\q. q < nth_default 0 ?srl 0 \ a*q^2 + b*q + c = 0) \ False" + proof - assume "\q. q < nth_default 0 ?srl 0 \ a*q^2 + b*q + c = 0" + then obtain q where q_prop: "q < nth_default 0 ?srl 0 \a*q^2 + b*q + c = 0" by auto + then have " q \ root_set (set les)" unfolding root_set_def using inset by auto + then have "List.member ?srl q" using same_set + by (simp add: in_set_member) + then have "q \ nth_default 0 ?srl 0" + using sorted_sorted_list_of_set[where A = "root_set (set les)"] + unfolding sorted_root_list_set_def + by (metis \q \ root_set (set les)\ in_set_conv_nth le_less_linear lengthsrl not_less0 nth_default_nth same_set sorted_nth_mono sorted_root_list_set_def) + then show "False" using q_prop by auto + qed + then show ?thesis by auto + qed + then have "\(\q. q < x \ a*q^2 + b*q + c = 0)" using xlt by auto + then show " a * y\<^sup>2 + b * y + c < 0" + using xl changes_sign_var[where a = "a", where b = "b", where c = "c", where x = "y", where y = "x"] + unfolding sign_num_def using \y < x\ less_eq_real_def zero_neq_numeral + by fastforce + qed + have "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0)" + proof clarsimp + fix a b c + assume "(a, b, c)\set les" + then show "\x. \y2 + b * y + c < 0" + using all by blast + qed + then show "False" using notneginf by auto + qed + have "x > nth_default 0 ?srl (length ?srl - 1) \ (\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + proof - + assume xgt: "x > nth_default 0 ?srl (length ?srl - 1)" + let ?lg = "nth_default 0 ?srl (length ?srl - 1)" + have "List.member ?srl ?lg" + by (metis diff_less in_set_member lengthsrl nth_default_def nth_mem zero_less_one) + then have "?lg \ root_set (set les) " + using same_set in_set_member[of ?lg ?srl] by auto + then have exabc: "\(a, b, c)\set les. a*?lg^2 + b*?lg + c = 0" + unfolding root_set_def by auto + have "(\(d, e, f)\set les. \q\{?lg<..x}. d * q^2 + e * q + f < 0)" + proof clarsimp + fix d e f q + assume inset: "(d, e, f) \ set les" + assume qgt: "(nth_default 0) (sorted_root_list_set (set les)) (length (sorted_root_list_set (set les)) - Suc 0) < q" + assume qlt: "q \ x" + have nor: "\(\r. d * r^2 + e * r + f = 0 \ r > ?lg)" + proof - + have "(\r. d * r^2 + e * r + f = 0 \ r > ?lg) \ False " + proof - + assume "\r. d * r^2 + e * r + f = 0 \ r > ?lg" + then obtain r where r_prop: "d*r^2 + e*r + f = 0 \ r > ?lg" by auto + then have "r \ root_set (set les)" using inset unfolding root_set_def by auto + then have "List.member ?srl r" + using same_set in_set_member + by (simp add: in_set_member) + then have " r \ ?lg" using sorted_sorted_list_of_set nth_default_def + by (metis One_nat_def Suc_pred \r \ root_set (set les)\ in_set_conv_nth lengthsrl lessI less_Suc_eq_le same_set sorted_nth_mono sorted_root_list_set_def) + then show "False" using r_prop by auto + qed + then show ?thesis by auto + qed + then have xltz_helper: "\(\r. r \ q \ d * r^2 + e * r + f = 0)" + using qgt by auto + then have xltz: "d*x^2 + e*x + f < 0" using inset x_prop by auto + show "d * q\<^sup>2 + e * q + f < 0" + using qlt qgt nor changes_sign_var[of d _ e f _] xltz xltz_helper unfolding sign_num_def + apply (auto) + by smt + qed + then have " (\(d, e, f)\set les. \y'>?lg. \x\{?lg<..y'}. d * x\<^sup>2 + e * x + f < 0)" + using xgt by auto + then have "(\(a, b, c)\set les. a*?lg^2 + b*?lg + c = 0 \ + (\(d, e, f)\set les. \y'>?lg. \x\{?lg<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using exabc by auto + then show "(\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + by auto + qed + then have posinf: "x > nth_default 0 ?srl (length ?srl - 1) \ False" + using nok by auto + have "(\n. (n+1) < (length ?srl) \ x > (nth_default 0 ?srl) n \ x < (nth_default 0 ?srl (n + 1))) \ (\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + proof - + assume "\n. (n+1) < (length ?srl) \ x > nth_default 0 ?srl n \ x < nth_default 0 ?srl (n + 1)" + then obtain n where n_prop: "(n+1) < (length ?srl) \ x > nth_default 0 ?srl n \ x < nth_default 0 ?srl (n + 1)" by auto + let ?elt = "nth_default 0 ?srl n" + let ?elt2 = "nth_default 0 ?srl (n + 1)" + have "List.member ?srl ?elt" + using n_prop nth_default_def + by (metis add_lessD1 in_set_member nth_mem) + then have "?elt \ root_set (set les) " + using same_set in_set_member[of ?elt ?srl] by auto + then have exabc: "\(a, b, c)\set les. a*?elt^2 + b*?elt + c = 0" + unfolding root_set_def by auto + then obtain a b c where "(a, b, c)\set les \ a*?elt^2 + b*?elt + c = 0" + by auto + have xltel2: "x < ?elt2" using n_prop by auto + have xgtel: "x > ?elt " using n_prop by auto + have "(\(d, e, f)\set les. \q\{?elt<..x}. d * q^2 + e * q + f < 0)" + proof clarsimp + fix d e f q + assume inset: "(d, e, f) \ set les" + assume qgt: "nth_default 0 (sorted_root_list_set (set les)) n < q" + assume qlt: "q \ x" + + have nor: "\(\r. d * r^2 + e * r + f = 0 \ r > ?elt \r < ?elt2)" + proof - + have "(\r. d * r^2 + e * r + f = 0 \ r > ?elt \ r < ?elt2) \ False " + proof - + assume "\r. d * r^2 + e * r + f = 0 \ r > ?elt \ r < ?elt2" + then obtain r where r_prop: "d*r^2 + e*r + f = 0 \ r > ?elt \ r < ?elt2" by auto + then have "r \ root_set (set les)" using inset unfolding root_set_def by auto + then have "List.member ?srl r" + using same_set in_set_member + by (simp add: in_set_member) + then have "\i < (length ?srl). r = nth_default 0 ?srl i" + by (metis \r \ root_set (set les)\ in_set_conv_nth same_set nth_default_def) + then obtain i where i_prop: "i < (length ?srl) \ r = nth_default 0 ?srl i" + by auto + have "r > ?elt" using r_prop by auto + then have igt: " i > n" using i_prop sorted_sorted_list_of_set + by (smt add_lessD1 leI n_prop nth_default_def sorted_nth_mono sorted_root_list_set_def) + have "r < ?elt2" using r_prop by auto + then have ilt: " i < n + 1" using i_prop sorted_sorted_list_of_set + by (smt leI n_prop nth_default_def sorted_nth_mono sorted_root_list_set_def) + then show "False" using igt ilt + by auto + qed + then show ?thesis by auto + qed + then have nor: "\(\r. d * r^2 + e * r + f = 0 \ r > ?elt \r \ x)" + using xltel2 xgtel by auto + then have xltz: "d*x^2 + e*x + f < 0" using inset x_prop by auto + show "d * q\<^sup>2 + e * q + f < 0" + using qlt qgt nor changes_sign_var[of d _ e f _] xltz unfolding sign_num_def + by smt + qed + then have " (\(d, e, f)\set les. \y'>?elt. \x\{?elt<..y'}. d * x\<^sup>2 + e * x + f < 0)" + using xgtel xltel2 by auto + then have "(\(a, b, c)\set les. a*?elt^2 + b*?elt + c = 0 \ + (\(d, e, f)\set les. \y'>?elt. \x\{?elt<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using exabc by auto + then show "(\k. \(a, b, c)\set les. a*k^2 + b*k + c = 0 \ + (\(d, e, f)\set les. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + by auto + qed + then have inbetw: "(\n. (n+1) < (length ?srl) \ x > nth_default 0 ?srl n \ x < nth_default 0 ?srl (n + 1)) \ False" + using nok by auto + have lenzer: "length xa = 0 \ False" + proof - + assume "length xa = 0" + have xis: "x > w \ x < w" + using notmem Cons.hyps + by (smt list.set_intros(1) same_set xnotin) + have xgt: "x > w \ False" + proof - + assume xgt: "x > w" + show "False" using posinf Cons.hyps + by (metis One_nat_def Suc_eq_plus1 \length xa = 0\ cancel_comm_monoid_add_class.diff_cancel list.size(4) nth_default_Cons_0 xgt) + qed + have xlt: "x < w \ False" + proof - + assume xlt: "x < w" + show "False" using neginf Cons.hyps + by (metis nth_default_Cons_0 xlt) + qed + show "False" using xis xgt xlt by auto + qed + have lengt: "length xa > 0 \ False" + proof - + assume "length xa > 0" + have "x \ nth_default 0 ?srl 0" using neginf + by fastforce + then have xgtf: "x > nth_default 0 ?srl 0" using notmem + using Cons.hyps(2) by fastforce + have "x \ nth_default 0 ?srl (length ?srl - 1)" using posinf by fastforce + then have "(\n. (n+1) < (length ?srl) \ x \ nth_default 0 ?srl n \ x \ nth_default 0 ?srl (n + 1))" + using lengthsrl xgtf notmem sorted_list_prop[where l = ?srl, where x = "x"] + by (metis add_lessD1 diff_less nth_default_nth sorted_root_list_set_def sorted_sorted_list_of_set zero_less_one) + then obtain n where n_prop: "(n+1) < (length ?srl) \ x \ nth_default 0 ?srl n \ x \ nth_default 0 ?srl (n + 1)" by auto + then have "x > nth_default 0 ?srl n \ x < nth_default 0 ?srl (n+1)" + using notmem + by (metis Suc_eq_plus1 Suc_lessD less_eq_real_def) + then have "(\n. (n+1) < (length ?srl) \ x > nth_default 0 ?srl n \ x < nth_default 0 ?srl (n + 1))" + using n_prop + by blast + then show "False" using inbetw by auto + qed + then show ?case using lenzer lengt by auto + qed + qed + show "False" + using h1 h2 by auto + qed + then have equiv_false: "\((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ + (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ + (\(a', b', c')\set les. a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))) \ False" + by linarith + have "\((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)))) \ False" + proof - + assume "\((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))))" + then have "\((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ (\(d, e, f)\set les. \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ + (\(a', b', c')\set les. + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. d * x\<^sup>2 + e * x + f < 0)) + \ + (\(a', b', c')\set les. a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)))" + by auto + then show ?thesis + using equiv_false by auto + qed + then show ?thesis + by blast +qed + +lemma les_qe : + shows "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) = + ((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))))" +proof - + have first: "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + ((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))))" + using les_qe_backward by auto + have second: "((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0)))) \ (\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) " + using les_qe_forward by auto + have "(\x. (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + ((\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ + (\(a', b', c')\set les. + a' = 0 \ + b' \ 0 \ + (\(d, e, f)\set les. + \y'>- (c' / b'). \x\{- (c' / b')<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + a' \ 0 \ + 4 * a' * c' \ b'\<^sup>2 \ + ((\(d, e, f)\set les. + \y'>(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a'). + \x\{(sqrt (b'\<^sup>2 - 4 * a' * c') - b') / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set les. + \y'>(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' - sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0))))" + using first second + by meson + then show ?thesis + by blast +qed + + +subsubsection "equiv\\_lemma" +lemma equiv_lemma: + assumes big_asm: "(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ + (\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + + (\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ + ((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + shows "((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" +proof - + let ?t = " ((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + have h1: "(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ ?t" + by auto + have h2: "(\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ ?t" + by auto + have h3: "(\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ ?t" + by auto + show ?thesis + using big_asm h1 h2 h3 + by presburger +qed + +subsubsection "The eq\\_qe lemma" +lemma eq_qe_forwards: + shows "(\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + ((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" +proof - + let ?big_or = "(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ + (\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + + (\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ + ((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + assume asm: "(\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) " + then obtain x where x_prop: "(\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)" by auto + have "\ (\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ + \ (\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + \ (\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ + \ ((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ False" + proof - + assume big_conj: "\ (\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ + \ (\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + \ (\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ + \ ((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + have not_lin: "\(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0))" + using big_conj by auto + have not_quad1: "\(\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)))" + using big_conj by auto + have not_quad2: "\(\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))" + using big_conj by auto + have not_zer: "\((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using big_conj by auto + then have not_zer1: "\(\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + \ (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)" by auto + have "(\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)" using asm + by auto + then have "\(\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0)" using not_zer1 by auto + then have "\ (d, e, f)\set eq. d \ 0 \ e \ 0 \ f \ 0 " + by auto + then obtain d e f where def_prop: "(d, e, f) \ set eq \ (d \ 0 \ e \ 0 \ f \ 0)" by auto + then have eval_at_x: "d*x^2 + e*x + f = 0" using x_prop by auto + have dnonz: "d \ 0 \ False" + proof - + assume dneq: "d \ 0" + then have discr: "-(e^2) + 4 *d *f \ 0" using discriminant_negative[of d e f x] eval_at_x unfolding discrim_def + by linarith + let ?r1 = "(- e + - 1 * sqrt (e^2 - 4 *d *f)) / (2 * d)" + let ?r2 = "(- e + 1 * sqrt (e^2 - 4 *d *f)) / (2 * d)" + have xis: "x = ?r1 \ x = ?r2" + using dneq discr discriminant_nonneg[of d e f x] eval_at_x unfolding discrim_def + by auto + have xr1: "x = ?r1 \ False" + using not_quad2 x_prop discr def_prop dneq by auto + have xr2: "x = ?r2 \ False" + using not_quad1 x_prop discr def_prop dneq by auto + show "False" using xr1 xr2 xis by auto + qed + then have dz: "d = 0" by auto + have enonz: "e \ 0 \ False" + proof - + assume enonz: "e\ 0" + then have "x = -f/e" using dz eval_at_x + by (metis add.commute minus_add_cancel mult.commute mult_zero_class.mult_zero_left nonzero_eq_divide_eq) + then show "False" + using not_lin x_prop enonz dz def_prop by auto + qed + then have ez: "e = 0" by auto + have fnonz: "f \ 0 \ False" using ez dz eval_at_x by auto + show "False" + using def_prop dnonz enonz fnonz by auto + qed + then have h: "\(?big_or) \ False" + by auto + then show ?thesis using equiv_lemma + by presburger +qed + +lemma eq_qe_backwards: "((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + (\x. ((\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))) + " +proof - + assume "((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + then have bigor: "(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ + (\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + + (\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ + ((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + by auto + have h1: "(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)) \ + (\(x::real). (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + assume "(\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0))" + then obtain a' b' c' where abc_prop: "(a', b', c')\set eq \ + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)" by auto + let ?x = "(-c' /b')::real" + have "(\(d, e, f)\set eq. d * ?x\<^sup>2 + e * ?x + f = 0) \ + (\(d, e, f)\set les. d * ?x^2 + e * ?x + f < 0)" using abc_prop by auto + then show ?thesis using abc_prop by blast + qed + have h2: " (\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ (\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + assume "(\(a', b', c')\set eq. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)))" + then obtain a' b' c' where abc_prop: "(a', b', c')\set eq \ a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))" by auto + let ?x = "((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')::real)" + have anonz: "a' \ 0" using abc_prop by auto + then have "\(q::real). q = ?x" by auto + then obtain q where q_prop: "q = ?x" by auto + have "(\(d, e, f)\set eq. d * (?x)\<^sup>2 + e * (?x) + f = 0) \ + (\(d, e, f)\set les. d * (?x)\<^sup>2 + e * (?x) + f < 0)" + using abc_prop by auto + then have "(\(d, e, f)\set eq. d * q\<^sup>2 + e * q + f = 0) \ + (\(d, e, f)\set les. d * q\<^sup>2 + e * q + f < 0)" using q_prop by auto + then show ?thesis by auto + qed + have h3: "(\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)) \ (\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + assume "(\(a', b', c')\set eq. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))" + then obtain a' b' c' where abc_prop: "a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (a', b', c')\set eq \ (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0)" by auto + let ?x = "(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" + have anonz: "a' \ 0" using abc_prop by auto + then have "\(q::real). q = ?x" by auto + then obtain q where q_prop: "q = ?x" by auto + have "(\(d, e, f)\set eq. d * (?x)\<^sup>2 + e * (?x) + f = 0) \ + (\(d, e, f)\set les. d * (?x)\<^sup>2 + e * (?x) + f < 0)" + using abc_prop by auto + then have "(\(d, e, f)\set eq. d * q\<^sup>2 + e * q + f = 0) \ + (\(d, e, f)\set les. d * q\<^sup>2 + e * q + f < 0)" using q_prop by auto + then show ?thesis by auto + qed + have h4: "((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ (\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof - + assume asm: "((\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + then have allzer: "(\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0)" by auto + have "(\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)" using asm by auto + then obtain x where x_prop: " \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0" by auto + then have "\(d, e, f)\set eq. d*x^2 + e*x + f = 0" + using allzer by auto + then show ?thesis using x_prop by auto + qed + show ?thesis + using bigor h1 h2 h3 h4 + by blast +qed + + +lemma eq_qe : "(\x. ((\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))) = + ((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" +proof - + have h1: "(\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + ((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using eq_qe_forwards by auto + have h2: "((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ (\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using eq_qe_backwards by auto + have h3: "(\x. (\(a, b, c)\set eq. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0)) \ + ((\(a', b', c')\set eq. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set les. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set eq. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set les. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0))) \ + (\(d, e, f)\set eq. d = 0 \ e = 0 \ f = 0) \ + (\x. \(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + using h1 h2 + by smt + then show ?thesis + by (auto) +qed + +subsubsection "The qe\\_forwards lemma" +lemma qe_forwards_helper_gen: + fixes r:: "real" + assumes f8: "\(\((a'::real), (b'::real), (c'::real))\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + ((\(d, e, f)\set a. d * r\<^sup>2 + e * r + f = 0) \ + (\(d, e, f)\set b. d * r^2 + e * r + f < 0) \ + (\(d, e, f)\set c. d * r^2 + e * r + f \ 0) \ + (\(d, e, f)\set d. d * r^2 + e * r + f \ 0)))" + assumes alleqset: "\x. (\(d, e, f)\set a. d * x^2 + e * x + f = 0)" + assumes f5: "\(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes f6: "\ (\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + assumes f7: "\ (\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + assumes f10: "\(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes f11: "\(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + assumes f12: "\(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + shows "\(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" +proof - + have "(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)) \ False" + proof - + assume "(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + have h1: "(\(d, e, f)\set a. d * r^2 + e * r + f = 0)" + using alleqset + by blast + have c_prop: "(\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + using abc_prop by auto + have h2: "(\(d, e, f)\set c. d *r^2 + e * r + f \ 0)" + proof - + have c1: "\ (d, e, f) \ set c. d * (r)\<^sup>2 + e * (r) + f > 0 \ False" + proof - + assume "\ (d, e, f) \ set c. d * (r)\<^sup>2 + e * (r) + f > 0" + then obtain d e f where def_prop: "(d, e, f) \ set c \ d * (r)\<^sup>2 + e * r + f > 0" + by auto + have "\y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using def_prop c_prop by auto + then obtain y' where y_prop: " y' >r \ (\x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)" by auto + have "\x\{r<..y'}. d*x^2 + e*x + f > 0" + using def_prop continuity_lem_gt0_expanded[of "r" y' d e f] + using y_prop by linarith + then show "False" using y_prop + by auto + qed + then show ?thesis + by fastforce + qed + have b_prop: "(\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0)" + using abc_prop by auto + have h3: "(\(d, e, f)\set b. d * r\<^sup>2 + e * r + f < 0)" + proof - + have c1: "\ (d, e, f) \ set b. d * r\<^sup>2 + e * r + f > 0 \ False" + proof - + assume "\ (d, e, f) \ set b. d * r\<^sup>2 + e * r + f > 0" + then obtain d e f where def_prop: "(d, e, f) \ set b \ d * r\<^sup>2 + e * r + f > 0" + by auto + then have "\y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0" + using b_prop by auto + then obtain y' where y_prop: " y' >r \ (\x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0)" by auto + then have "\k. k > r \ k < y' \ d * k^2 + e * k + f < 0" using dense + by (meson dense greaterThanAtMost_iff less_eq_real_def) + then obtain k where k_prop: "k > r \ k < y' \ d * k^2 + e * k + f < 0" + by auto + then have "\(\x>r. x < y' \ d * x\<^sup>2 + e * x + f = 0)" + using y_prop by force + then show "False" using k_prop def_prop y_prop poly_IVT_neg[of "r" "k" "[:f, e, d:]"] poly_IVT_pos[of "-c'/b'" "k" "[:f, e, d:]"] + by (smt quadratic_poly_eval) + qed + have c2: "\ (d, e, f) \ set b. d * r\<^sup>2 + e * r + f = 0 \ False" + proof - + assume "\ (d, e, f) \ set b. d * r\<^sup>2 + e * r + f = 0" + then obtain d' e f where def_prop: "(d', e, f) \ set b \ d' * r\<^sup>2 + e * r + f = 0" + by auto + then have same: "(d' = 0 \ e \ 0) \ (-f/e = r)" + proof - + assume asm: "(d' = 0 \ e \ 0)" + then have " e * r + f = 0" using def_prop + by auto + then show "-f/e = r" using asm + by (metis (no_types) add.commute diff_0 divide_minus_left minus_add_cancel nonzero_mult_div_cancel_left uminus_add_conv_diff) + qed + let ?r = "-f/e" + have "(d' = 0 \ e \ 0) \ ((d', e, f) \ set b \ ((\(d, e, f)\set a. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using same def_prop abc_prop by auto + then have "(d' = 0 \ e \ 0) \ (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + then have f1: "(d' = 0 \ e \ 0) \ False" using f5 + by auto + have f2: "(d' = 0 \ e = 0 \ f = 0) \ False" proof - + assume "(d' = 0 \ e = 0 \ f = 0)" + then have allzer: "\x. d'*x^2 + e*x + f = 0" by auto + have "\y'>r. \x\{r<..y'}. d' * x\<^sup>2 + e * x + f < 0" + using b_prop def_prop by auto + then obtain y' where y_prop: " y' >r \ (\x\{r<..y'}. d' * x\<^sup>2 + e * x + f < 0)" by auto + then have "\k. k > r \ k < y' \ d' * k^2 + e * k + f < 0" using dense + by (meson dense greaterThanAtMost_iff less_eq_real_def) + then show "False" using allzer + by auto + qed + have f3: "d' \ 0 \ False" + proof - + assume dnonz: "d' \ 0" + have discr: " - e\<^sup>2 + 4 * d' * f \ 0" + using def_prop discriminant_negative[of d' e f] unfolding discrim_def + using def_prop by fastforce + then have two_cases: "r = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') + \ r = (- e + 1 * sqrt (e\<^sup>2 - 4 * d' * f)) / (2 * d')" + using def_prop dnonz discriminant_nonneg[of d' e f] unfolding discrim_def + by fastforce + have some_props: "((d', e, f) \ set b \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0)" + using dnonz def_prop discr by auto + let ?r1 = "(- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + let ?r2 = "(- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + have cf1: "r = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "r = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set b \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f7 by auto + qed + have cf2: "r = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "r = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set b \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f6 by auto + qed + then show "False" using two_cases cf1 cf2 by auto + qed + (* discriminant_nonnegative *) + have eo: "(d' \ 0) \ (d' = 0 \ e \ 0) \ (d' = 0 \ e = 0 \ f = 0)" + using def_prop by auto + then show "False" using f1 f2 f3 by auto + qed + show ?thesis using c1 c2 + by fastforce + qed + have d_prop: "(\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + using abc_prop by auto + have h4: "(\(d, e, f)\set d. d * r\<^sup>2 + e * r + f \ 0)" + proof - + have "(\(d, e, f)\set d. d * r\<^sup>2 + e * r + f = 0) \ False" + proof - + assume "\ (d, e, f) \ set d. d * r\<^sup>2 + e * r + f = 0" + then obtain d' e f where def_prop: "(d', e, f) \ set d \ d' * r\<^sup>2 + e * r + f = 0" + by auto + then have same: "(d' = 0 \ e \ 0) \ (-f/e = r)" + proof - + assume asm: "(d' = 0 \ e \ 0)" + then have " e * r + f = 0" using def_prop + by auto + then show "-f/e = r" using asm + by (metis (no_types) add.commute diff_0 divide_minus_left minus_add_cancel nonzero_mult_div_cancel_left uminus_add_conv_diff) + qed + let ?r = "-f/e" + have "(d' = 0 \ e \ 0) \ ((d', e, f) \ set d \ ((\(d, e, f)\set a. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using same def_prop abc_prop by auto + then have "(d' = 0 \ e \ 0) \ (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'> -c'/b'. \x\{ -c'/b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'> -c'/b'. \x\{ -c'/b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'> -c'/b'. \x\{ -c'/b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'> -c'/b'. \x\{ -c'/b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + then have f1: "(d' = 0 \ e \ 0) \ False" using f10 + by auto + have f2: "(d' = 0 \ e = 0 \ f = 0) \ False" proof - + assume "(d' = 0 \ e = 0 \ f = 0)" + then have allzer: "\x. d'*x^2 + e*x + f = 0" by auto + have "\y'> r. \x\{ r<..y'}. d' * x\<^sup>2 + e * x + f \ 0" + using d_prop def_prop + by auto + then obtain y' where y_prop: " y' >r \ (\x\{r<..y'}. d' * x\<^sup>2 + e * x + f \ 0)" by auto + then have "\k. k > r \ k < y' \ d' * k^2 + e * k + f \ 0" using dense + by (meson dense greaterThanAtMost_iff less_eq_real_def) + then show "False" using allzer + by auto + qed + have f3: "d' \ 0 \ False" + proof - + assume dnonz: "d' \ 0" + have discr: " - e\<^sup>2 + 4 * d' * f \ 0" + using def_prop discriminant_negative[of d' e f] unfolding discrim_def + by fastforce + then have two_cases: "r = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') + \ r = (- e + 1 * sqrt (e\<^sup>2 - 4 * d' * f)) / (2 * d')" + using def_prop dnonz discriminant_nonneg[of d' e f] unfolding discrim_def + by fastforce + have some_props: "((d', e, f) \ set d \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0)" + using dnonz def_prop discr by auto + let ?r1 = "(- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + let ?r2 = "(- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + have cf1: "r = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "r = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set d \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f12 by auto + qed + have cf2: "r = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "r = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set d \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f11 by auto + qed + then show "False" using two_cases cf1 cf2 by auto + qed + (* discriminant_nonnegative *) + have eo: "(d' \ 0) \ (d' = 0 \ e \ 0) \ (d' = 0 \ e = 0 \ f = 0)" + using def_prop by auto + then show "False" using f1 f2 f3 by auto + qed + then show ?thesis by auto + qed + have "(\(a', b', c')\set c. ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. d * r\<^sup>2 + e * r + f = 0) \ + (\(d, e, f)\set b. d * r\<^sup>2 + e * r + f < 0) \ + (\(d, e, f)\set c. d * r\<^sup>2 + e * r + f \ 0) \ + (\(d, e, f)\set d. d * r\<^sup>2 + e * r + f \ 0))" + using h1 h2 h3 h4 abc_prop by auto + then show "False" using f8 by auto + qed + then show ?thesis by auto +qed + + + +lemma qe_forwards_helper_lin: + assumes alleqset: "\x. (\(d, e, f)\set a. d * x^2 + e * x + f = 0)" + assumes f5: "\(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes f6: "\ (\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + assumes f7: "\ (\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + assumes f8: "\(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + assumes f10: "\(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes f11: "\(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + assumes f12: "\(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + shows "\(\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" +proof - + have "(\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)) \ False" + proof - + assume "(\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + then have bnonz: "b'\0" by auto + have h1: "(\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0)" + using bnonz alleqset + by blast + have c_prop: "(\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + using abc_prop by auto + have h2: "(\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" + proof - + have c1: "\ (d, e, f) \ set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f > 0 \ False" + proof - + assume "\ (d, e, f) \ set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f > 0" + then obtain d e f where def_prop: "(d, e, f) \ set c \ d * (- c' / b')\<^sup>2 + e * (- c' / b') + f > 0" + by auto + have "\y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0" + using def_prop c_prop by auto + then obtain y' where y_prop: " y' >- c' / b' \ (\x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" by auto + have "\x\{(-c'/b')<..y'}. d*x^2 + e*x + f > 0" + using def_prop continuity_lem_gt0_expanded[of "(-c'/b')" y' d e f] + using y_prop by linarith + then show "False" using y_prop + by auto + qed + then show ?thesis + by fastforce + qed + have b_prop: "(\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0)" + using abc_prop by auto + have h3: "(\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0)" + proof - + have c1: "\ (d, e, f) \ set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f > 0 \ False" + proof - + assume "\ (d, e, f) \ set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f > 0" + then obtain d e f where def_prop: "(d, e, f) \ set b \ d * (- c' / b')\<^sup>2 + e * (- c' / b') + f > 0" + by auto + then have "\y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0" + using b_prop by auto + then obtain y' where y_prop: " y' >- c' / b' \ (\x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0)" by auto + then have "\k. k > -c'/b' \ k < y' \ d * k^2 + e * k + f < 0" using dense + by (meson dense greaterThanAtMost_iff less_eq_real_def) + then obtain k where k_prop: "k > -c'/b' \ k < y' \ d * k^2 + e * k + f < 0" + by auto + then have "\(\x>(-c'/b'). x < y' \ d * x\<^sup>2 + e * x + f = 0)" + using y_prop by force + then show "False" using k_prop def_prop y_prop poly_IVT_neg[of "-c'/b'" "k" "[:f, e, d:]"] poly_IVT_pos[of "-c'/b'" "k" "[:f, e, d:]"] + by (smt quadratic_poly_eval) + qed + have c2: "\ (d, e, f) \ set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0 \ False" + proof - + assume "\ (d, e, f) \ set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0" + then obtain d' e f where def_prop: "(d', e, f) \ set b \ d' * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0" + by auto + then have same: "(d' = 0 \ e \ 0) \ (-f/e = -c'/b')" + proof - + assume asm: "(d' = 0 \ e \ 0)" + then have " e * (- c' / b') + f = 0" using def_prop + by auto + then show "-f/e = -c'/b'" using asm + by auto + qed + let ?r = "-f/e" + have "(d' = 0 \ e \ 0) \ ((d', e, f) \ set b \ ((\(d, e, f)\set a. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using same def_prop abc_prop by auto + then have "(d' = 0 \ e \ 0) \ (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + then have f1: "(d' = 0 \ e \ 0) \ False" using f5 + by auto + have f2: "(d' = 0 \ e = 0 \ f = 0) \ False" proof - + assume "(d' = 0 \ e = 0 \ f = 0)" + then have allzer: "\x. d'*x^2 + e*x + f = 0" by auto + have "\y'>- c' / b'. \x\{- c' / b'<..y'}. d' * x\<^sup>2 + e * x + f < 0" + using b_prop def_prop by auto + then obtain y' where y_prop: " y' >- c' / b' \ (\x\{- c' / b'<..y'}. d' * x\<^sup>2 + e * x + f < 0)" by auto + then have "\k. k > -c'/b' \ k < y' \ d' * k^2 + e * k + f < 0" using dense + by (meson dense greaterThanAtMost_iff less_eq_real_def) + then show "False" using allzer + by auto + qed + have f3: "d' \ 0 \ False" + proof - + assume dnonz: "d' \ 0" + have discr: " - e\<^sup>2 + 4 * d' * f \ 0" + using def_prop discriminant_negative[of d' e f] unfolding discrim_def + by fastforce + then have two_cases: "(- c' / b') = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') + \ (- c' / b') = (- e + 1 * sqrt (e\<^sup>2 - 4 * d' * f)) / (2 * d')" + using def_prop dnonz discriminant_nonneg[of d' e f] unfolding discrim_def + by fastforce + have some_props: "((d', e, f) \ set b \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0)" + using dnonz def_prop discr by auto + let ?r1 = "(- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + let ?r2 = "(- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + have cf1: "(- c' / b') = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "(- c' / b') = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set b \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f7 by auto + qed + have cf2: "(- c' / b') = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "(- c' / b') = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set b \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f6 by auto + qed + then show "False" using two_cases cf1 cf2 by auto + qed + (* discriminant_nonnegative *) + have eo: "(d' \ 0) \ (d' = 0 \ e \ 0) \ (d' = 0 \ e = 0 \ f = 0)" + using def_prop by auto + then show "False" using f1 f2 f3 by auto + qed + show ?thesis using c1 c2 + by fastforce + qed + have d_prop: "(\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + using abc_prop by auto + have h4: "(\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" + proof - + have "(\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ False" + (* begin *) + proof - + assume "\ (d, e, f) \ set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0" + then obtain d' e f where def_prop: "(d', e, f) \ set d \ d' * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0" + by auto + then have same: "(d' = 0 \ e \ 0) \ (-f/e = -c'/b')" + proof - + assume asm: "(d' = 0 \ e \ 0)" + then have " e * (- c' / b') + f = 0" using def_prop + by auto + then show "-f/e = -c'/b'" using asm + by auto + qed + let ?r = "-f/e" + have "(d' = 0 \ e \ 0) \ ((d', e, f) \ set d \ ((\(d, e, f)\set a. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using same def_prop abc_prop by auto + then have "(d' = 0 \ e \ 0) \ (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + then have f1: "(d' = 0 \ e \ 0) \ False" using f10 + by auto + have f2: "(d' = 0 \ e = 0 \ f = 0) \ False" proof - + assume "(d' = 0 \ e = 0 \ f = 0)" + then have allzer: "\x. d'*x^2 + e*x + f = 0" by auto + have "\y'>- c' / b'. \x\{- c' / b'<..y'}. d' * x\<^sup>2 + e * x + f \ 0" + using d_prop def_prop by auto + then obtain y' where y_prop: " y' >- c' / b' \ (\x\{- c' / b'<..y'}. d' * x\<^sup>2 + e * x + f \ 0)" by auto + then have "\k. k > -c'/b' \ k < y' \ d' * k^2 + e * k + f \ 0" using dense + by (meson dense greaterThanAtMost_iff less_eq_real_def) + then show "False" using allzer + by auto + qed + have f3: "d' \ 0 \ False" + proof - + assume dnonz: "d' \ 0" + have discr: " - e\<^sup>2 + 4 * d' * f \ 0" + using def_prop discriminant_negative[of d' e f] unfolding discrim_def + by fastforce + then have two_cases: "(- c' / b') = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') + \ (- c' / b') = (- e + 1 * sqrt (e\<^sup>2 - 4 * d' * f)) / (2 * d')" + using def_prop dnonz discriminant_nonneg[of d' e f] unfolding discrim_def + by fastforce + have some_props: "((d', e, f) \ set d \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0)" + using dnonz def_prop discr by auto + let ?r1 = "(- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + let ?r2 = "(- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + have cf1: "(- c' / b') = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "(- c' / b') = (- e + - 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set d \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r1. \x\{?r1<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f12 by auto + qed + have cf2: "(- c' / b') = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d') \ False" + proof - + assume "(- c' / b') = (- e + 1 * sqrt (e^2 - 4 * d' * f)) / (2 * d')" + then have "(d', e, f) \ set d \ d' \ 0 \ - e\<^sup>2 + 4 * d' * f \ 0 \ + ((\(d, e, f)\set a. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>?r2. \x\{?r2<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop some_props by auto + then show "False" using f11 by auto + qed + then show "False" using two_cases cf1 cf2 by auto + qed + (* discriminant_nonnegative *) + have eo: "(d' \ 0) \ (d' = 0 \ e \ 0) \ (d' = 0 \ e = 0 \ f = 0)" + using def_prop by auto + then show "False" using f1 f2 f3 by auto + qed + then show ?thesis by auto + qed + have "(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + using h1 h2 h3 h4 bnonz abc_prop by auto + then show "False" using f8 by auto + qed + then show ?thesis by auto +qed + + + +lemma qe_forwards_helper: + assumes alleqset: "\x. (\(d, e, f)\set a. d * x^2 + e * x + f = 0)" + assumes f1: "\((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0))" + assumes f5: "\(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes f6: "\ (\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + assumes f7: "\ (\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + assumes f8: "\(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + assumes f13: "\(\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + assumes f9: "\(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + assumes f10: "\(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes f11: "\(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + assumes f12: "\(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + shows "\(\x. (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" +proof - + have nor: "\r. \(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + ((\(d, e, f)\set a. d * r\<^sup>2 + e * r + f = 0) \ + (\(d, e, f)\set b. d * r^2 + e * r + f < 0) \ + (\(d, e, f)\set c. d * r^2 + e * r + f \ 0) \ + (\(d, e, f)\set d. d * r^2 + e * r + f \ 0)))" + proof clarsimp + fix r t u v + assume inset: "(t, u, v) \ set c" + assume eo: "t = 0 \ u \ 0 " + assume zero_eq: "t*r^2 + u*r + v = 0" + assume ah: "\x\set a. case x of (d, e, f) \ d * r\<^sup>2 + e * r + f = 0" + assume bh: "\x\set b. case x of (d, e, f) \ d * r\<^sup>2 + e * r + f < 0" + assume ch: "\x\set c. case x of (d, e, f) \ d * r\<^sup>2 + e * r + f \ 0" + assume dh: "\x\set d. case x of (d, e, f) \ d * r\<^sup>2 + e * r + f \ 0" + have two_cases: "t \ 0 \ (t = 0 \ u \ 0)" using eo by auto + have c1: "t \ 0 \ False" + proof - + assume tnonz: "t \ 0" + then have discr_prop: "- u\<^sup>2 + 4 * t * v \ 0 " + using discriminant_negative[of t u v] zero_eq unfolding discrim_def + by force + then have ris: "r = ((-u + - 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ + r = ((-u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) " + using tnonz discriminant_nonneg[of t u v] zero_eq unfolding discrim_def by auto + let ?r1 = "((-u + - 1 * sqrt (u^2 - 4 * t * v)) / (2 * t))" + let ?r2 = "((-u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t))" + have ris1: "r = ?r1 \ False" + proof - + assume "r = ?r1" + then have "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + using inset ah bh ch dh discr_prop tnonz by auto + then show ?thesis + using f9 by auto + qed + have ris2: "r = ?r2 \ False" + proof - + assume "r = ?r2" + then have "(\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + using inset ah bh ch dh discr_prop tnonz by auto + then show ?thesis + using f13 by auto + qed + show "False" using ris ris1 ris2 by auto + qed + have c2: "(t = 0 \ u \ 0) \ False" + proof - + assume asm: "t = 0 \ u \ 0" + then have "r = -v/u" using zero_eq add.right_neutral nonzero_mult_div_cancel_left + by (metis add.commute divide_divide_eq_right divide_eq_0_iff neg_eq_iff_add_eq_0) + then have "(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + using asm inset ah bh ch dh by auto + then show "False" using f8 + by auto + qed + then show "False" using two_cases c1 c2 by auto + qed + have keyh: "\r. \(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + proof - + fix r + have h8: "\(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + ((\(d, e, f)\set a. d * r\<^sup>2 + e * r + f = 0) \ + (\(d, e, f)\set b. d * r^2 + e * r + f < 0) \ + (\(d, e, f)\set c. d * r^2 + e * r + f \ 0) \ + (\(d, e, f)\set d. d * r^2 + e * r + f \ 0)))" + using nor by auto + show "\(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*r^2 + b'*r + c' = 0) \ + (\(d, e, f)\set a. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>r. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using qe_forwards_helper_gen[of c r a b d] + alleqset f5 f6 f7 h8 f10 f11 f12 + by auto + qed + have f8a: "\(\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using qe_forwards_helper_lin[of a b c d] alleqset f5 f6 f7 f8 f10 f11 f12 + by blast + have f13a: "\ (\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + proof - + have "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) \ False" + proof - + assume "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" by auto + let ?r = "(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" + have somek: "\k. k = ?r" by auto + then obtain k where k_prop: "k = ?r" by auto + have "(a'\ 0 \ b'\ 0) \ (a'*?r^2 + b'*?r + c' = 0)" + using abc_prop discriminant_nonneg[of a' b' c'] + unfolding discrim_def apply (auto) + by (metis (mono_tags, lifting) times_divide_eq_right) + then have "(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*?r^2 + b'*?r + c' = 0) \ + (\(d, e, f)\set a. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop by auto + then have "(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*k^2 + b'*k + c' = 0) \ + (\(d, e, f)\set a. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using k_prop by auto + then have "\k. (\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*k^2 + b'*k + c' = 0) \ + (\(d, e, f)\set a. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + then show "False" using keyh by auto + qed + then + show ?thesis + by auto + qed + have f9a: "\ (\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + + proof - + have "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)) \ False" + proof - + assume "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" by auto + let ?r = "(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" + have somek: "\k. k = ?r" by auto + then obtain k where k_prop: "k = ?r" by auto + have "(a'\ 0 \ b'\ 0) \ (a'*?r^2 + b'*?r + c' = 0)" + using abc_prop discriminant_nonneg[of a' b' c'] + unfolding discrim_def apply (auto) + by (metis (mono_tags, lifting) times_divide_eq_right) + then have "(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*?r^2 + b'*?r + c' = 0) \ + (\(d, e, f)\set a. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?r. \x\{?r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using abc_prop by auto + then have "(\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*k^2 + b'*k + c' = 0) \ + (\(d, e, f)\set a. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using k_prop by auto + then have "\k. (\(a', b', c')\set c. + ((a'\ 0 \ b'\ 0) \ a'*k^2 + b'*k + c' = 0) \ + (\(d, e, f)\set a. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + by auto + then show "False" using keyh by auto + qed + then + show ?thesis + by auto + qed + (* We need to show that the point is in one of these ranges *) + have "(\x. (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)) \ False" + proof - + assume "(\x. (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" + then obtain x where x_prop: "(\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" by auto + (* Need this sorted_nonzero_root_list_set in case some of the tuples from set c are (0, 0, 0) *) + let ?srl = "sorted_nonzero_root_list_set (((set b) \ (set c))\ (set d))" + have alleqsetvar: "\(t, u, v) \ set a. t = 0 \ u = 0 \ v = 0" + proof clarsimp + fix t u v + assume "(t, u, v) \ set a" + then have "\x. t*x^2 + u*x + v = 0" + using alleqset by auto + then have "\x\{0<..1}. t * x\<^sup>2 + u * x + v = 0" + by auto + then show "t = 0 \ u = 0 \ v = 0" + using continuity_lem_eq0[of 0 1 t u v] + by auto + qed + (* Should violate f1 *) + have lenzero: "length ?srl = 0 \ False" + proof - + assume lenzero: "length ?srl = 0" + have ina: "(\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0)" + using alleqsetvar by auto + have inb: "(\(a, b, c)\set b. \y. a * y\<^sup>2 + b * y + c < 0)" + proof clarsimp + fix t u v y + assume insetb: "(t, u, v) \ set b" + then have "t * x\<^sup>2 + u * x + v < 0" using x_prop by auto + then have tuv_prop: "t \ 0 \ u \ 0 \ v \ 0" + by auto + then have tuzer: "(t = 0 \ u = 0) \ \(\q. t * q\<^sup>2 + u * q + v = 0)" + by simp + then have tunonz: "(t \ 0 \ u \ 0) \ \(\q. t * q\<^sup>2 + u * q + v = 0)" + proof - + assume tuv_asm: "t \ 0 \ u \ 0" + have "\q. t * q\<^sup>2 + u * q + v = 0 \ False" + proof - + assume "\ q. t * q\<^sup>2 + u * q + v = 0" + then obtain q where "t * q\<^sup>2 + u * q + v = 0" by auto + then have qin: "q \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetb tuv_asm tuv_prop by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "q \ set ?srl" using qin unfolding nonzero_root_set_def + by auto + then have "List.member ?srl q" + using in_set_member[of q ?srl] + by auto + then show "False" + using lenzero + by (simp add: member_rec(2)) + qed + then show ?thesis by auto + qed + have nozer: "\(\q. t * q\<^sup>2 + u * q + v = 0)" + using tuzer tunonz + by blast + have samesn: "sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + proof - + have "x < y \ sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + using changes_sign_var[of t x u v y] nozer by auto + have "y < x \ sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + using changes_sign_var[of t y u v x] nozer + proof - + assume "y < x" + then show ?thesis + using \\q. t * q\<^sup>2 + u * q + v = 0\ \sign_num (t * y\<^sup>2 + u * y + v) \ sign_num (t * x\<^sup>2 + u * x + v) \ y < x \ \q. t * q\<^sup>2 + u * q + v = 0 \ y \ q \ q \ x\ by presburger + qed + show ?thesis + using changes_sign_var using \x < y \ sign_num (t * x\<^sup>2 + u * x + v) = sign_num (t * y\<^sup>2 + u * y + v)\ \y < x \ sign_num (t * x\<^sup>2 + u * x + v) = sign_num (t * y\<^sup>2 + u * y + v)\ + by fastforce + qed + (* changes_sign_var *) + have "sign_num (t*x^2 + u*x + v) = -1" using insetb unfolding sign_num_def using x_prop + by auto + then have "sign_num (t*y^2 + u*y + v) = -1" using samesn by auto + then show "t * y\<^sup>2 + u * y + v < 0" unfolding sign_num_def + by smt + qed + have inc: "(\(a, b, c)\set c. \y. a * y\<^sup>2 + b * y + c \ 0)" + proof clarsimp + fix t u v y + assume insetc: "(t, u, v) \ set c" + then have "t * x\<^sup>2 + u * x + v \ 0" using x_prop by auto + then have tuzer: "t = 0 \ u = 0 \ t*y^2 + u*y + v \ 0 " + proof - + assume tandu: "t = 0 \ u = 0" + then have "v \ 0" using insetc x_prop + by auto + then show "t*y^2 + u*y + v \ 0" using tandu + by auto + qed + have tunonz: "t \ 0 \ u \ 0 \ t*y^2 + u*y + v \ 0" + proof - + assume tuv_asm: "t \ 0 \ u \ 0" + have insetcvar: "t*x^2 + u*x + v < 0" + proof - + have "t*x^2 + u*x + v = 0 \ False" + proof - + assume zer: "t*x^2 + u*x + v = 0" + then have xin: "x \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetc tuv_asm by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "x \ set ?srl" using xin unfolding nonzero_root_set_def + by auto + then have "List.member ?srl x" + using in_set_member[of x ?srl] + by auto + then show "False" using lenzero + by (simp add: member_rec(2)) + qed + then show ?thesis + using \t * x\<^sup>2 + u * x + v \ 0\ by fastforce + qed + then have tunonz: "\(\q. t * q\<^sup>2 + u * q + v = 0)" + proof - + have "\q. t * q\<^sup>2 + u * q + v = 0 \ False" + proof - + assume "\ q. t * q\<^sup>2 + u * q + v = 0" + then obtain q where "t * q\<^sup>2 + u * q + v = 0" by auto + then have qin: "q \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetc tuv_asm by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "q \ set ?srl" using qin unfolding nonzero_root_set_def + by auto + then have "List.member ?srl q" + using in_set_member[of q ?srl] + by auto + then show "False" + using lenzero + by (simp add: member_rec(2)) + qed + then show ?thesis by auto + qed + have nozer: "\(\q. t * q\<^sup>2 + u * q + v = 0)" + using tuzer tunonz + by blast + have samesn: "sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + proof - + have "x < y \ sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + using changes_sign_var[of t x u v y] nozer by auto + have "y < x \ sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + using changes_sign_var[of t y u v x] nozer + proof - + assume "y < x" + then show ?thesis + using \\q. t * q\<^sup>2 + u * q + v = 0\ \sign_num (t * y\<^sup>2 + u * y + v) \ sign_num (t * x\<^sup>2 + u * x + v) \ y < x \ \q. t * q\<^sup>2 + u * q + v = 0 \ y \ q \ q \ x\ by presburger + qed + show ?thesis + using changes_sign_var using \x < y \ sign_num (t * x\<^sup>2 + u * x + v) = sign_num (t * y\<^sup>2 + u * y + v)\ \y < x \ sign_num (t * x\<^sup>2 + u * x + v) = sign_num (t * y\<^sup>2 + u * y + v)\ + by fastforce + qed + (* changes_sign_var *) + have "sign_num (t*x^2 + u*x + v) = -1" using insetcvar unfolding sign_num_def using x_prop + by auto + then have "sign_num (t*y^2 + u*y + v) = -1" using samesn by auto + then show "t * y\<^sup>2 + u * y + v \ 0" unfolding sign_num_def + by smt + qed + then show "t * y\<^sup>2 + u * y + v \ 0" + using tuzer tunonz + by blast + qed + have ind: "(\(a, b, c)\set d. \y. a * y\<^sup>2 + b * y + c \ 0)" + proof clarsimp + fix t u v y + assume insetd: "(t, u, v) \ set d" + assume falseasm: "t * y\<^sup>2 + u * y + v = 0" + then have snz: "sign_num (t*y^2 + u*y + v) = 0" + unfolding sign_num_def by auto + have "t * x\<^sup>2 + u * x + v \ 0" using insetd x_prop by auto + then have tuv_prop: "t \ 0 \ u \ 0 \ v \ 0" + by auto + then have tuzer: "(t = 0 \ u = 0) \ \(\q. t * q\<^sup>2 + u * q + v = 0)" + by simp + then have tunonz: "(t \ 0 \ u \ 0) \ \(\q. t * q\<^sup>2 + u * q + v = 0)" + proof - + assume tuv_asm: "t \ 0 \ u \ 0" + have "\q. t * q\<^sup>2 + u * q + v = 0 \ False" + proof - + assume "\ q. t * q\<^sup>2 + u * q + v = 0" + then obtain q where "t * q\<^sup>2 + u * q + v = 0" by auto + then have qin: "q \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetd tuv_asm tuv_prop by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "q \ set ?srl" using qin unfolding nonzero_root_set_def + by auto + then have "List.member ?srl q" + using in_set_member[of q ?srl] + by auto + then show "False" + using lenzero + by (simp add: member_rec(2)) + qed + then show ?thesis by auto + qed + have nozer: "\(\q. t * q\<^sup>2 + u * q + v = 0)" + using tuzer tunonz + by blast + have samesn: "sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + proof - + have "x < y \ sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + using changes_sign_var[of t x u v y] nozer by auto + have "y < x \ sign_num (t*x^2 + u*x + v) = sign_num (t*y^2 + u*y + v)" + using changes_sign_var[of t y u v x] nozer + proof - + assume "y < x" + then show ?thesis + using \\q. t * q\<^sup>2 + u * q + v = 0\ \sign_num (t * y\<^sup>2 + u * y + v) \ sign_num (t * x\<^sup>2 + u * x + v) \ y < x \ \q. t * q\<^sup>2 + u * q + v = 0 \ y \ q \ q \ x\ by presburger + qed + show ?thesis + using changes_sign_var using \x < y \ sign_num (t * x\<^sup>2 + u * x + v) = sign_num (t * y\<^sup>2 + u * y + v)\ \y < x \ sign_num (t * x\<^sup>2 + u * x + v) = sign_num (t * y\<^sup>2 + u * y + v)\ + by fastforce + qed + (* changes_sign_var *) + have "sign_num (t*x^2 + u*x + v) = -1 \ sign_num (t*x^2 + u*x + v) = 1 " + using insetd unfolding sign_num_def using x_prop + by auto + then have "sign_num (t*y^2 + u*y + v) = -1 \ sign_num (t*y^2 + u*y + v) = 1" using samesn by auto + then show "False" using snz by auto + qed + (* Show all the polynomials never change sign *) + have "((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \y. a * y\<^sup>2 + b * y + c < 0) \ + (\(a, b, c)\set c. \y. a * y\<^sup>2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \y. a * y\<^sup>2 + b * y + c \ 0))" + using ina inb inc ind by auto + then show "False" + using f1 + by auto + qed + have cases_mem: "(List.member ?srl x) \ False" + proof - + assume "(List.member ?srl x)" + then have "x \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using set_sorted_list_of_set nonzero_root_set_finite in_set_member + by (metis List.finite_set finite_Un nonzero_root_set_def sorted_nonzero_root_list_set_def) + then have "\ (a, b, c) \ (((set b) \ (set c))\ (set d)) . (a \ 0 \ b \ 0) \ a*x^2 + b*x + c = 0" + by blast + then obtain t u v where def_prop: "(t, u, v) \ (((set b) \ (set c))\ (set d)) \ (t \ 0 \ u \ 0) \ t*x^2 + u*x + v = 0" + by auto + have notinb: "(t, u, v) \ (set b)" + proof - + have "(t, u, v) \ (set b ) \ False" + proof - + assume "(t, u, v) \ (set b)" + then have "t*x^2 + u*x + v < 0" using x_prop + by blast + then show "False" using def_prop + by simp + qed + then show ?thesis by auto + qed + have notind: "(t, u, v) \ (set d)" + proof - + have "(t, u, v) \ (set d) \ False" + proof - + assume "(t, u, v) \ (set d)" + then have "t*x^2 + u*x + v \ 0" using x_prop + by blast + then show "False" using def_prop + by simp + qed + then show ?thesis by auto + qed + then have inset: "(t, u, v) \ (set c)" + using def_prop notinb notind + by blast + have case1: "t \ 0 \ False" + proof - + assume tnonz: "t \ 0" + then have r1or2:"x = (- u + - 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t) \ + x = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t) " + using def_prop discriminant_negative[of t u v] discriminant_nonneg[of t u v] + apply (auto) + using notinb apply (force) + apply (simp add: discrim_def discriminant_iff) + using notind by force + have discrh: "-1*u^2 + 4 * t * v \ 0" + using tnonz discriminant_negative[of t u v] unfolding discrim_def + using def_prop by force + have r1: "x = (- u + - 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t) \ False" + proof - + assume xis: "x = (- u + - 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)" + have " t \ 0 \ + - 1*u^2 + 4 * t * v \ 0 \ + (\(d, e, f)\set a. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + d * x\<^sup>2 + e * x + f \ 0)" + using tnonz alleqset discrh x_prop + by auto + then have "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + using xis inset + by auto + then show "False" + using f9 by auto + qed + have r2: "x = (- u + 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t) \ False" + proof - + assume xis: "x = (- u + 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)" + have " t \ 0 \ + - 1*u^2 + 4 * t * v \ 0 \ + (\(d, e, f)\set a. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + d * x\<^sup>2 + e * x + f \ 0)" + using tnonz alleqset discrh x_prop + by auto + then have "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + using xis inset + by auto + then show "False" + using f13 by auto + qed + then show "False" + using r1or2 r1 r2 by auto + qed + have case2: "(t = 0 \ u \ 0) \ False" + proof - + assume asm: "t = 0 \ u \ 0" + then have xis: "x = - v / u" using def_prop notinb add.commute diff_0 divide_non_zero minus_add_cancel uminus_add_conv_diff + by (metis mult_zero_left) + have "((t = 0 \ u \ 0) \ + (\(d, e, f)\set a. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. d * x^2 + e * x + f < 0) \ + (\(d, e, f)\set c. d * x^2 + e * x + f \ 0) \ + (\(d, e, f)\set d. d * x^2 + e * x + f \ 0))" + using asm x_prop alleqset by auto + then have "(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + using xis inset + by auto + then show "False" + using f8 by auto + qed + show "False" + using def_prop case1 case2 by auto + qed + have lengt0: "length ?srl \ 1 \ False" + proof- + assume asm: "length ?srl \ 1" + (* should violate f1 *) + have cases_lt: "x < ?srl ! 0 \ False" + proof - + assume xlt: "x < ?srl ! 0" + have samesign: "\ (a, b, c) \ (set b \ set c \ set d). + (\y < x. sign_num (a * y\<^sup>2 + b * y + c) = sign_num (a*x^2 + b*x + c))" + proof clarsimp + fix t u v y + assume insetunion: "(t, u, v) \ set b \ (t, u, v) \ set c \ (t, u, v) \ set d" + assume ylt: "y < x" + have tuzer: "t = 0 \ u = 0 \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + unfolding sign_num_def + by auto + have tunonzer: "t \ 0 \ u \ 0 \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + proof - + assume tuv_asm: "t\ 0 \ u \ 0" + have "\(\q. q < ?srl ! 0 \ t * q\<^sup>2 + u * q + v = 0)" + proof clarsimp + fix q + assume qlt: "q < sorted_nonzero_root_list_set (set b \ set c \ set d) ! 0" + assume "t * q\<^sup>2 + u * q + v = 0" + then have qin: "q \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetunion tuv_asm by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "q \ set ?srl" using qin unfolding nonzero_root_set_def + by auto + then have lm: "List.member ?srl q" + using in_set_member[of q ?srl] + by auto + then have " List.member + (sorted_list_of_set (nonzero_root_set (set b \ set c \ set d))) + q \ + q < sorted_list_of_set (nonzero_root_set (set b \ set c \ set d)) ! + 0 \ + (\x xs. (x \ set xs) = (\i + (\x xs. (x \ set xs) = List.member xs x) \ + (\y x. \ y \ x \ x < y) \ + (\xs. sorted xs = + (\i j. i \ j \ j < length xs \ xs ! i \ xs ! j)) \ + (\p. sorted_nonzero_root_list_set p \ + sorted_list_of_set (nonzero_root_set p)) \ + False" + proof - + assume a1: "List.member (sorted_list_of_set (nonzero_root_set (set b \ set c \ set d))) q" + assume a2: "q < sorted_list_of_set (nonzero_root_set (set b \ set c \ set d)) ! 0" + have f3: "List.member (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)}) q" + using a1 by (metis nonzero_root_set_def) + have f4: "q < sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)} ! 0" + using a2 by (metis nonzero_root_set_def) + have f5: "q \ set (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)})" + using f3 by (meson in_set_member) + have "\rs r. \n. ((r::real) \ set rs \ n < length rs) \ (r \ set rs \ rs ! n = r)" + by (metis in_set_conv_nth) + then obtain nn :: "real list \ real \ nat" where + f6: "\r rs. (r \ set rs \ nn rs r < length rs) \ (r \ set rs \ rs ! nn rs r = r)" + by moura + then have "sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)} ! nn (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)}) q = q" + using f5 by blast + then have "\n. \ sorted (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)}) \ \ n \ nn (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)}) q \ \ nn (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)}) q < length (sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)}) \ sorted_list_of_set {r. \p. p \ set b \ set c \ set d \ (case p of (ra, rb, rc) \ (ra \ 0 \ rb \ 0) \ ra * r\<^sup>2 + rb * r + rc = 0)} ! n \ q" + using not_less not_less0 sorted_iff_nth_mono + by (metis (no_types, lifting)) + then show ?thesis + using f6 f5 f4 by (meson le0 not_less sorted_sorted_list_of_set) + qed + then show "False" using lm qlt in_set_conv_nth in_set_member not_le_imp_less not_less0 sorted_iff_nth_mono sorted_nonzero_root_list_set_def sorted_sorted_list_of_set + by auto + qed + then have "\(\q. q \ x \ t * q\<^sup>2 + u * q + v = 0)" + using xlt + by auto + then show " sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using ylt changes_sign_var[of t y u v x] + by blast + qed + then show " sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using tuzer + by blast + qed + have bseth: "(\(a, b, c)\set b. \y2 + b * y + c < 0)" + proof clarsimp + fix t u v y + assume insetb: "(t, u, v) \ set b" + assume yltx: "y < x" + have "(t, u, v) \ (set b \ set c \ set d)" using insetb + by auto + then have samesn: "sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using samesign insetb yltx + by blast + have "sign_num (t*x^2 + u*x + v) = -1" + using x_prop insetb unfolding sign_num_def + by auto + then show "t * y\<^sup>2 + u * y + v < 0" + using samesn unfolding sign_num_def + by (metis add.right_inverse add.right_neutral linorder_neqE_linordered_idom one_add_one zero_neq_numeral) + qed + have bset: " (\(a, b, c)\set b. \x. \y2 + b * y + c < 0)" + proof clarsimp + fix t u v + assume inset: "(t, u, v) \ set b" + then have " \y2 + u * y + v < 0 " using bseth by auto + then show "\x. \y2 + u * y + v < 0" + by auto + qed + have cseth: "(\(a, b, c)\set c. \y2 + b * y + c \ 0)" + proof clarsimp + fix t u v y + assume insetc: "(t, u, v) \ set c" + assume yltx: "y < x" + have "(t, u, v) \ (set b \ set c \ set d)" using insetc + by auto + then have samesn: "sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using samesign insetc yltx + by blast + have "sign_num (t*x^2 + u*x + v) = -1 \ sign_num (t*x^2 + u*x + v) = 0" + using x_prop insetc unfolding sign_num_def + by auto + then show "t * y\<^sup>2 + u * y + v \ 0" + using samesn unfolding sign_num_def + using zero_neq_one by fastforce + qed + have cset: " (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0)" + proof clarsimp + fix t u v + assume inset: "(t, u, v) \ set c" + then have " \y2 + u * y + v \ 0 " using cseth by auto + then show "\x. \y2 + u * y + v \0" + by auto + qed + have dseth: "(\(a, b, c)\set d. \y2 + b * y + c \ 0)" + proof clarsimp + fix t u v y + assume insetd: "(t, u, v) \ set d" + assume yltx: "y < x" + assume contrad: "t * y\<^sup>2 + u * y + v = 0" + have "(t, u, v) \ (set b \ set c \ set d)" using insetd + by auto + then have samesn: "sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using samesign insetd yltx + by blast + have "sign_num (t*x^2 + u*x + v) = -1 \ sign_num (t*x^2 + u*x + v) = 1" + using x_prop insetd unfolding sign_num_def + by auto + then have "t * y\<^sup>2 + u * y + v \ 0" + using samesn unfolding sign_num_def + by auto + then show "False" using contrad by auto + qed + have dset: " (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0)" + proof clarsimp + fix t u v + assume inset: "(t, u, v) \ set d" + then have " \y2 + u * y + v \ 0 " using dseth by auto + then show "\x. \y2 + u * y + v \ 0" + by auto + qed + have "(\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0)" + using alleqsetvar by auto + then have "((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0))" + using bset cset dset by auto + then show "False" using f1 by auto + qed + (* should violate one of the infinitesmials *) + have cases_gt: " x > ?srl ! (length ?srl - 1) \ False" + proof - + assume xgt: "x > ?srl ! (length ?srl - 1)" + let ?bgrt = "?srl ! (length ?srl - 1)" + have samesign: "\ (a, b, c) \ (set b \ set c \ set d). + (\y > ?bgrt. sign_num (a * y\<^sup>2 + b * y + c) = sign_num (a*x^2 + b*x + c))" + proof clarsimp + fix t u v y + assume insetunion: "(t, u, v) \ set b \ (t, u, v) \ set c \ (t, u, v) \ set d" + assume ygt: "sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0) < y" + have tuzer: "t = 0 \ u = 0 \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + unfolding sign_num_def + by auto + have tunonzer: "t \ 0 \ u \ 0 \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + proof - + assume tuv_asm: "t\ 0 \ u \ 0" + have "\(\q. q > ?srl ! (length ?srl - 1) \ t * q\<^sup>2 + u * q + v = 0)" + proof clarsimp + fix q + assume qgt: "sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0) < q" + assume "t * q\<^sup>2 + u * q + v = 0" + then have qin: "q \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetunion tuv_asm by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "q \ set ?srl" using qin unfolding nonzero_root_set_def + by auto + then have "List.member ?srl q" + using in_set_member[of q ?srl] + by auto + then show "False" using qgt in_set_conv_nth in_set_member not_le_imp_less not_less0 sorted_iff_nth_mono sorted_nonzero_root_list_set_def sorted_sorted_list_of_set + by (smt (z3) Suc_diff_Suc Suc_n_not_le_n \q \ set (sorted_nonzero_root_list_set (set b \ set c \ set d))\ in_set_conv_nth length_0_conv length_greater_0_conv length_sorted_list_of_set lenzero less_Suc_eq_le minus_nat.diff_0 not_le sorted_nth_mono sorted_sorted_list_of_set) + qed + then have nor: "\(\q. q > ?bgrt \ t * q\<^sup>2 + u * q + v = 0)" + using xgt + by auto + have c1: " x > y \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using nor changes_sign_var[of t y u v x] xgt ygt + by fastforce + then have c2: " y > x \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using nor changes_sign_var[of t x u v y] xgt ygt + by force + then have c3: " x = y \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + unfolding sign_num_def + by auto + then show "sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using c1 c2 c3 + by linarith + qed + then show " sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using tuzer + by blast + qed + + have "(\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0)" + using alleqsetvar by auto + have " ?bgrt \ set ?srl" + using set_sorted_list_of_set nonzero_root_set_finite in_set_member + using asm by auto + then have "?bgrt \ nonzero_root_set (set b \ set c \ set d )" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set nonzero_root_set_finite + by auto + then have "\t u v. (t, u, v) \ set b \ set c \ set d \(t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)" + unfolding nonzero_root_set_def by auto + then obtain t u v where tuvprop1: "(t, u, v) \ set b \ set c \ set d \(t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)" + by auto + then have tuvprop: "((t, u, v) \ set b \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) + \ ((t, u, v) \ set c \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ + ((t, u, v) \ set d \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) " + by auto + have tnonz: "t\ 0 \ (-1*u^2 + 4 * t * v \ 0 \ (?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t) \ ?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)))" + proof - + assume "t\ 0" + have "-1*u^2 + 4 * t * v \ 0 " using tuvprop1 discriminant_negative[of t u v] + unfolding discrim_def + using \t \ 0\ by force + then show ?thesis + using tuvprop discriminant_nonneg[of t u v] + unfolding discrim_def + using \t \ 0\ by auto + qed + have unonz: "(t = 0 \ u \ 0) \ ?bgrt = - v / u" + proof - + assume "(t = 0 \ u \ 0)" + then have "u*?bgrt + v = 0" using tuvprop1 + by simp + then show "?bgrt = - v / u" + by (simp add: \t = 0 \ u \ 0\ eq_minus_divide_eq mult.commute) + qed + + have allpropb: "(\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0)" + proof clarsimp + fix t1 u1 v1 y1 x1 + assume ins: "(t1, u1, v1) \ set b" + assume x1gt: " sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0) < x1" + assume "x1 \ y1" + have xsn: "sign_num (t1 * x^2 + u1 * x + v1 ) = -1" using ins x_prop unfolding sign_num_def + by auto + have "sign_num (t1 * x1\<^sup>2 + u1 * x1 + v1 ) = sign_num (t1 * x^2 + u1 * x + v1 ) " + using ins x1gt samesign + apply (auto) + by blast + then show "t1 * x1\<^sup>2 + u1 * x1 + v1 < 0" using xsn unfolding sign_num_def + by (metis add.right_inverse add.right_neutral linorder_neqE_linordered_idom one_add_one zero_neq_numeral) + qed + have allpropbvar: "(\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set b" + then have "\x\{?bgrt<..(?bgrt + 1)}. t1 * x\<^sup>2 + u1 * x + v1 < 0" + using allpropb + by force + then show "\y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0). + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0)<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 < 0" + using less_add_one + by (metis One_nat_def) + qed + have allpropc: "(\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 y1 x1 + assume ins: "(t1, u1, v1) \ set c" + assume x1gt: " sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0) < x1" + assume "x1 \ y1" + have xsn: "sign_num (t1 * x^2 + u1 * x + v1 ) = -1 \ sign_num (t1 * x^2 + u1 * x + v1 ) = 0" using ins x_prop unfolding sign_num_def + by auto + have "sign_num (t1 * x1\<^sup>2 + u1 * x1 + v1 ) = sign_num (t1 * x^2 + u1 * x + v1 ) " + using ins x1gt samesign One_nat_def + proof - + have "case (t1, u1, v1) of (r, ra, rb) \ \raa>sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1). sign_num (r * raa\<^sup>2 + ra * raa + rb) = sign_num (r * x\<^sup>2 + ra * x + rb)" + by (smt (z3) Un_iff ins samesign) + then show ?thesis + by (simp add: x1gt) + qed + then show "t1 * x1\<^sup>2 + u1 * x1 + v1 \ 0" using xsn unfolding sign_num_def + by (metis equal_neg_zero less_numeral_extra(3) linorder_not_less zero_neq_one) + qed + have allpropcvar: "(\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set c" + then have "\x\{?bgrt<..(?bgrt + 1)}. t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using allpropc + by force + then show "\y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0). + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0)<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using less_add_one One_nat_def + by (metis (no_types, hide_lams)) + qed + have allpropd: "(\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 y1 x1 + assume ins: "(t1, u1, v1) \ set d" + assume contrad:"t1 * x1\<^sup>2 + u1 * x1 + v1 = 0" + assume x1gt: " sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0) < x1" + assume "x1 \ y1" + have xsn: "sign_num (t1 * x^2 + u1 * x + v1 ) = -1 \ sign_num (t1 * x^2 + u1 * x + v1 ) = 1" using ins x_prop unfolding sign_num_def + by auto + have "sign_num (t1 * x1\<^sup>2 + u1 * x1 + v1 ) = sign_num (t1 * x^2 + u1 * x + v1 ) " + using ins x1gt samesign apply (auto) + by blast + then have "t1 * x1\<^sup>2 + u1 * x1 + v1 \ 0" using xsn unfolding sign_num_def + by auto + then show "False" using contrad by auto + qed + have allpropdvar: "(\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set d" + then have "\x\{?bgrt<..(?bgrt + 1)}. t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using allpropd + by force + then show "\y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0). + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0)<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using less_add_one + by (metis (no_types, hide_lams) One_nat_def) + qed + have "\x. (\(d, e, f)\set a. + d * x\<^sup>2 + e * x + f = 0)" using alleqsetvar + by auto + then have ast: "(\(d, e, f)\set a. + \x\{?bgrt<..(?bgrt + 1)}. d * x\<^sup>2 + e * x + f = 0)" + by auto + have allpropavar: "(\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set a" + then have "\x\{?bgrt<..(?bgrt + 1)}. t1 * x\<^sup>2 + u1 * x + v1 = 0 " + using ast by auto + then show "\y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0). + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! + (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - Suc 0)<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 = 0" + using less_add_one One_nat_def + by metis + qed + have quadsetb: "((t, u, v) \ set b \ t\ 0) \ False" + proof - + assume asm: "(t, u, v) \ set b \ t\ 0" + have bgrt1: "(?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + using \sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1) = (- u + 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)\ + by auto + have "((t, u, v)\set b \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f6 bgrtis + by auto + qed + have bgrt2: "(?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + using \sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1) = (- u + -1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)\ + by auto + have "((t, u, v)\set b \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f7 bgrtis + by auto + qed + show "False" using tnonz bgrt1 bgrt2 asm + by auto + qed + have linsetb: "((t, u, v) \ set b \ (t = 0 \ u \ 0)) \ False" + proof - + assume asm: "(t, u, v) \ set b \ (t = 0 \ u \ 0)" + then have bgrtis: "?bgrt = (- v / u)" + using unonz + by blast + have "((t, u, v)\set b \ (t = 0 \ u \ 0) \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using bgrtis f5 + by auto + qed + have insetb: "((t, u, v) \ set b \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ False" + using quadsetb linsetb by auto + have quadsetc: "(t, u, v) \ set c \ t\ 0 \ False" + proof - + assume asm: "(t, u, v) \ set c \ t\ 0" + have bgrt1: "(?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + using \sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1) = (- u + 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)\ + by auto + have "((t, u, v)\set c \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f13a bgrtis + by auto + qed + have bgrt2: "(?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + using \sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1) = (- u + -1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)\ + by auto + have "((t, u, v)\set c \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f9a bgrtis + by auto + qed + show "False" using tnonz bgrt1 bgrt2 asm + by auto + qed + have linsetc: "(t, u, v) \ set c \ (t = 0 \ u \ 0) \ False" + proof - + assume asm: "(t, u, v) \ set c \ (t = 0 \ u \ 0)" + then have bgrtis: "?bgrt = (- v / u)" + using unonz + by blast + have "((t, u, v)\set c \ (t = 0 \ u \ 0) \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using bgrtis f8a + by auto + qed + have insetc: "((t, u, v) \ set c \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ False" + using quadsetc linsetc by auto + have quadsetd: "(t, u, v) \ set d \ t\ 0 \ False" + proof - + assume asm: "(t, u, v) \ set d \ t\ 0" + have bgrt1: "(?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + using \sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1) = (- u + 1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)\ + by auto + have "((t, u, v)\set d \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f11 bgrtis + by auto + qed + have bgrt2: "(?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + using \sorted_nonzero_root_list_set (set b \ set c \ set d) ! (length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 1) = (- u + -1 * sqrt (u\<^sup>2 - 4 * t * v)) / (2 * t)\ + by auto + have "((t, u, v)\set d \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f12 bgrtis + by auto + qed + show "False" using tnonz bgrt1 bgrt2 asm + by auto + qed + have linsetd: "(t, u, v) \ set d \ (t = 0 \ u \ 0) \ False" + proof - + assume asm: "(t, u, v) \ set d \ (t = 0 \ u \ 0)" + then have bgrtis: "?bgrt = (- v / u)" + using unonz + by blast + have "((t, u, v)\set d \ (t = 0 \ u \ 0) \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using bgrtis f10 + by auto + qed + have insetd: "((t, u, v) \ set d \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ False" + using quadsetd linsetd by auto + then show "False" using insetb insetc insetd tuvprop + by auto + qed + have len1: "length ?srl = 1 \ False" + proof - + assume len1: "length ?srl = 1" + have cases: "(List.member ?srl x) \ x < ?srl ! 0 \ x > ?srl ! 0" + using in_set_member lenzero nth_mem by fastforce + then show "False" + using len1 cases_mem cases_lt cases_gt by auto + qed + have lengtone: "length ?srl > 1 \ False" + proof - + assume lengt1: "length ?srl > 1" + have cases: "(List.member ?srl x) \ x < ?srl ! 0 \ x > ?srl ! (length ?srl -1) + \ (\k \ (length ?srl - 2). (?srl ! k < x \ x x > ?srl ! (length ?srl -1) \ (x \ ?srl ! 0 \ x \ ?srl ! (length ?srl -1))" + by auto + have ifo: "(x \ ?srl ! 0 \ x \ ?srl ! (length ?srl -1)) \ ((List.member ?srl x) \ (\k \ (length ?srl - 2). ?srl ! k < x \ x ?srl ! 0 \ x \ ?srl ! (length ?srl -1)" + then have "\(List.member ?srl x) \ (\k \ (length ?srl - 2). ?srl ! k < x \ x (List.member ?srl x)" + have "\(\k \ (length ?srl - 2). ?srl ! k < x \ x False" + proof clarsimp + assume "\k. sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < x \ + k \ length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 2 \ + \ x < sorted_nonzero_root_list_set (set b \ set c \ set d) ! Suc k" + then have allk: "(\k \ length ?srl - 2. ?srl ! k < x \ + \ x < ?srl ! Suc k)" by auto + have basec: "x \ ?srl ! 0" using xinbtw by auto + have "\k \ length ?srl - 2. ?srl ! k < x" + proof clarsimp + fix k + assume klteq: "k \ length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 2" + show "sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < x" + using nonmem klteq basec + proof (induct k) + case 0 + then show ?case + using in_set_member lenzero nth_mem by fastforce + next + case (Suc k) + then show ?case + by (smt Suc_leD Suc_le_lessD \\k. sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < x \ k \ length (sorted_nonzero_root_list_set (set b \ set c \ set d)) - 2 \ \ x < sorted_nonzero_root_list_set (set b \ set c \ set d) ! Suc k\ diff_less in_set_member length_0_conv length_greater_0_conv lenzero less_trans_Suc nth_mem pos2) + qed + qed + then have "x \ ?srl ! (length ?srl -1)" + using allk + by (metis One_nat_def Suc_diff_Suc lengt1 less_eq_real_def less_or_eq_imp_le one_add_one plus_1_eq_Suc xinbtw) + then have "x > ?srl ! (length ?srl - 1)" using nonmem + by (metis One_nat_def Suc_le_D asm diff_Suc_Suc diff_zero in_set_member lessI less_eq_real_def nth_mem) + then show "False" using xinbtw by auto + qed + then show "(\k \ (length ?srl - 2). ?srl ! k < x \ x (\k \ (length ?srl - 2). ?srl ! k < x \ x k \ (length ?srl - 2). ?srl ! k < x \ x False" + proof - + assume "(\k \ (length ?srl - 2). ?srl ! k < x \ x (length ?srl - 2) \ ?srl ! k < x \ x (a, b, c) \ (set b \ set c \ set d). + (\y. (?srl ! k < y \ y sign_num (a * y\<^sup>2 + b * y + c) = sign_num (a*x^2 + b*x + c))" + proof clarsimp + fix t u v y + assume insetunion: "(t, u, v) \ set b \ (t, u, v) \ set c \ (t, u, v) \ set d" + assume ygt: " sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < y" + assume ylt: "y < sorted_nonzero_root_list_set (set b \ set c \ set d) ! Suc k" + have tuzer: "t = 0 \ u = 0 \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + unfolding sign_num_def + by auto + have tunonzer: "t \ 0 \ u \ 0 \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + proof - + assume tuv_asm: "t\ 0 \ u \ 0" + have nor: "\(\q. q > ?srl ! k \ q < ?srl ! (k + 1) \ t * q\<^sup>2 + u * q + v = 0)" + proof clarsimp + fix q + assume qlt: "q < sorted_nonzero_root_list_set (set b \ set c \ set d) ! Suc k" + assume qgt: "sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < q" + assume "t * q\<^sup>2 + u * q + v = 0" + then have qin: "q \ {x. \(a, b, c)\set b \ set c \ set d. (a \ 0 \ b \ 0) \ a * x\<^sup>2 + b * x + c = 0}" + using insetunion tuv_asm by auto + have "set ?srl = nonzero_root_set (set b \ set c \ set d)" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set[of "nonzero_root_set (set b \ set c \ set d)"] + nonzero_root_set_finite[of "(set b \ set c \ set d)"] + by auto + then have "q \ set ?srl" using qin unfolding nonzero_root_set_def + by auto + then have "List.member ?srl q" + using in_set_member[of q ?srl] + by auto + then have "\n < length ?srl. q = ?srl ! n" + by (metis \q \ set (sorted_nonzero_root_list_set (set b \ set c \ set d))\ in_set_conv_nth) + then obtain n where nprop: "n < length ?srl \ q = ?srl ! n" by auto + then have ngtk: "n > k" + proof - + have sortedh: "sorted ?srl" + by (simp add: sorted_nonzero_root_list_set_def) + then have nlteq: "n \ k \ ?srl ! n \ ?srl ! k" using nprop k_prop sorted_iff_nth_mono + using sorted_nth_mono + by (metis (no_types, hide_lams) Suc_1 \q \ set (sorted_nonzero_root_list_set (set b \ set c \ set d))\ diff_Suc_less length_pos_if_in_set sup.absorb_iff2 sup.strict_boundedE) + have "?srl ! n > ?srl ! k" using nprop qgt by auto + then show ?thesis + using nlteq + by linarith + qed + then have nltkp1: "n < k+1" + proof - + have sortedh: "sorted ?srl" + by (simp add: sorted_nonzero_root_list_set_def) + then have ngteq: "k+1 \ n \ ?srl ! (k+1) \ ?srl ! n" using nprop k_prop sorted_iff_nth_mono + by auto + have "?srl ! n < ?srl ! (k + 1)" using nprop qlt by auto + then show ?thesis + using ngteq by linarith + qed + then show "False" using ngtk nltkp1 by auto + qed + have c1: " x > y \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using nor changes_sign_var[of t y u v x] k_prop ygt ylt + by fastforce + then have c2: " y > x \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using nor changes_sign_var[of t x u v y] k_prop ygt ylt + by force + then have c3: " x = y \ sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + unfolding sign_num_def + by auto + then show "sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using c1 c2 c3 + by linarith + qed + then show " sign_num (t * y\<^sup>2 + u * y + v) = sign_num (t * x\<^sup>2 + u * x + v)" + using tuzer + by blast + qed + + let ?bgrt = "?srl ! k" + + have "(\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0)" + using alleqsetvar by auto + have " ?bgrt \ set ?srl" + using set_sorted_list_of_set nonzero_root_set_finite in_set_member k_prop asm + by (smt diff_Suc_less le_eq_less_or_eq less_le_trans nth_mem one_add_one plus_1_eq_Suc zero_less_one) + then have "?bgrt \ nonzero_root_set (set b \ set c \ set d )" + unfolding sorted_nonzero_root_list_set_def + using set_sorted_list_of_set nonzero_root_set_finite + by auto + then have "\t u v. (t, u, v) \ set b \ set c \ set d \(t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)" + unfolding nonzero_root_set_def by auto + then obtain t u v where tuvprop1: "(t, u, v) \ set b \ set c \ set d \(t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)" + by auto + then have tuvprop: "((t, u, v) \ set b \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) + \ ((t, u, v) \ set c \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ + ((t, u, v) \ set d \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) " + by auto + have tnonz: "t\ 0 \ (-1*u^2 + 4 * t * v \ 0 \ (?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t) \ ?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)))" + proof - + assume "t\ 0" + have "-1*u^2 + 4 * t * v \ 0 " using tuvprop1 discriminant_negative[of t u v] + unfolding discrim_def + using \t \ 0\ by force + then show ?thesis + using tuvprop discriminant_nonneg[of t u v] + unfolding discrim_def + using \t \ 0\ by auto + qed + have unonz: "(t = 0 \ u \ 0) \ ?bgrt = - v / u" + proof - + assume "(t = 0 \ u \ 0)" + then have "u*?bgrt + v = 0" using tuvprop1 + by simp + then show "?bgrt = - v / u" + by (simp add: \t = 0 \ u \ 0\ eq_minus_divide_eq mult.commute) + qed + + have "\y'. y' > x \ y' < ?srl ! (k+1)" using k_prop dense + by blast + then obtain y1 where y1_prop: "y1 > x \ y1 < ?srl ! (k+1)" by auto + then have y1inbtw: "y1 > ?srl ! k \ y1 < ?srl ! (k+1)" using k_prop + by auto + + have allpropb: "(\(d, e, f)\set b. + \x\{?bgrt<..y1}. d * x\<^sup>2 + e * x + f < 0)" + proof clarsimp + fix t1 u1 v1 x1 + assume ins: "(t1, u1, v1) \ set b" + assume x1gt: "sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < x1" + assume x1lt: "x1 \ y1" + have x1inbtw: "x1 > ?srl ! k \ x1 < ?srl ! (k+1)" + using x1gt x1lt y1inbtw + by (smt One_nat_def cases_gt k_prop) + have xsn: "sign_num (t1 * x^2 + u1 * x + v1 ) = -1" using ins x_prop unfolding sign_num_def + by auto + have "sign_num (t1 * x1\<^sup>2 + u1 * x1 + v1 ) = sign_num (t1 * x^2 + u1 * x + v1 ) " + using ins x1inbtw samesign + by blast + then show "t1 * x1\<^sup>2 + u1 * x1 + v1 < 0" using xsn unfolding sign_num_def + by (metis add.right_inverse add.right_neutral linorder_neqE_linordered_idom one_add_one zero_neq_numeral) + qed + have allpropbvar: "(\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set b" + then have "\x\{?bgrt<..y1}. t1 * x\<^sup>2 + u1 * x + v1 < 0" + using allpropb + by force + then show " \y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! k. + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! k<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 < 0" + using y1inbtw by blast + qed + have allpropc: "(\(d, e, f)\set c. + \x\{?bgrt<..y1}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 x1 + assume ins: "(t1, u1, v1) \ set c" + assume x1gt: " sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < x1" + assume x1lt: "x1 \ y1" + have x1inbtw: "x1 > ?srl ! k \ x1 < ?srl ! (k+1)" + using x1gt x1lt y1inbtw + by (smt One_nat_def cases_gt k_prop) + have xsn: "sign_num (t1 * x^2 + u1 * x + v1 ) = -1 \ sign_num (t1 * x^2 + u1 * x + v1 ) = 0" using ins x_prop unfolding sign_num_def + by auto + have "sign_num (t1 * x1\<^sup>2 + u1 * x1 + v1 ) = sign_num (t1 * x^2 + u1 * x + v1 ) " + using ins x1inbtw samesign + by blast + then show "t1 * x1\<^sup>2 + u1 * x1 + v1 \ 0" using xsn unfolding sign_num_def + by (metis (no_types, hide_lams) equal_neg_zero less_eq_real_def linorder_not_less zero_neq_one) + qed + have allpropcvar: "(\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set c" + then have "\x\{?bgrt<..y1}. t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using allpropc + by force + then show " \y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! k. + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! k<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using y1inbtw by blast + qed + have allpropd: "(\(d, e, f)\set d. + \x\{?bgrt<..y1}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 x1 + assume ins: "(t1, u1, v1) \ set d" + assume contrad:"t1 * x1\<^sup>2 + u1 * x1 + v1 = 0" + assume x1gt: " sorted_nonzero_root_list_set (set b \ set c \ set d) ! k < x1" + assume x1lt: "x1 \ y1" + have x1inbtw: "x1 > ?srl ! k \ x1 < ?srl ! (k+1)" + using x1gt x1lt y1inbtw + by (smt One_nat_def cases_gt k_prop) + have xsn: "sign_num (t1 * x^2 + u1 * x + v1 ) = -1 \ sign_num (t1 * x^2 + u1 * x + v1 ) = 1" using ins x_prop unfolding sign_num_def + by auto + have "sign_num (t1 * x1\<^sup>2 + u1 * x1 + v1 ) = sign_num (t1 * x^2 + u1 * x + v1 ) " + using ins x1inbtw samesign + by blast + then have "t1 * x1\<^sup>2 + u1 * x1 + v1 \ 0" using xsn unfolding sign_num_def + by auto + then show "False" using contrad by auto + qed + have allpropdvar: "(\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set d" + then have "\x\{?bgrt<..y1}. t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using allpropd + by force + then show " \y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! k. + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! k<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 \ 0" + using y1inbtw by blast + qed + have "\x. (\(d, e, f)\set a. + d * x\<^sup>2 + e * x + f = 0)" using alleqsetvar + by auto + then have ast: "(\(d, e, f)\set a. + \x\{?bgrt<..(?bgrt + 1)}. d * x\<^sup>2 + e * x + f = 0)" + by auto + have allpropavar: "(\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0)" + proof clarsimp + fix t1 u1 v1 + assume "(t1, u1, v1) \ set a" + then have "\x\{?bgrt<..(?bgrt + 1)}. t1 * x\<^sup>2 + u1 * x + v1 = 0 " + using ast by auto + then show "\y'>sorted_nonzero_root_list_set (set b \ set c \ set d) ! k. + \x\{sorted_nonzero_root_list_set (set b \ set c \ set d) ! k<..y'}. + t1 * x\<^sup>2 + u1 * x + v1 = 0" + using less_add_one by blast + qed + + have quadsetb: "((t, u, v) \ set b \ t\ 0) \ False" + proof - + assume asm: "(t, u, v) \ set b \ t\ 0" + have bgrt1: "(?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + by blast + have "((t, u, v)\set b \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f6 bgrtis + by auto + qed + have bgrt2: "(?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + by blast + have "((t, u, v)\set b \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f7 bgrtis + by auto + qed + show "False" using tnonz bgrt1 bgrt2 asm + by auto + qed + have linsetb: "((t, u, v) \ set b \ (t = 0 \ u \ 0)) \ False" + proof - + assume asm: "(t, u, v) \ set b \ (t = 0 \ u \ 0)" + then have bgrtis: "?bgrt = (- v / u)" + using unonz + by blast + have "((t, u, v)\set b \ (t = 0 \ u \ 0) \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using bgrtis f5 + by auto + qed + have insetb: "((t, u, v) \ set b \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ False" + using quadsetb linsetb by auto + have quadsetc: "(t, u, v) \ set c \ t\ 0 \ False" + proof - + assume asm: "(t, u, v) \ set c \ t\ 0" + have bgrt1: "(?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + by blast + have "((t, u, v)\set c \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f13a bgrtis + by auto + qed + have bgrt2: "(?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + by blast + have "((t, u, v)\set c \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f9a bgrtis + by auto + qed + show "False" using tnonz bgrt1 bgrt2 asm + by auto + qed + have linsetc: "(t, u, v) \ set c \ (t = 0 \ u \ 0) \ False" + proof - + assume asm: "(t, u, v) \ set c \ (t = 0 \ u \ 0)" + then have bgrtis: "?bgrt = (- v / u)" + using unonz + by blast + have "((t, u, v)\set c \ (t = 0 \ u \ 0) \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using bgrtis f8a + by auto + qed + have insetc: "((t, u, v) \ set c \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ False" + using quadsetc linsetc by auto + have quadsetd: "(t, u, v) \ set d \ t\ 0 \ False" + proof - + assume asm: "(t, u, v) \ set d \ t\ 0" + have bgrt1: "(?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + 1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + by blast + have "((t, u, v)\set d \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f11 bgrtis + by auto + qed + have bgrt2: "(?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)) \ False " + proof - + assume bgrtis: "?bgrt = (- u + -1 * sqrt (u^2 - 4 * t * v)) / (2 * t)" + have discrim_prop: "-1*u^2 + 4 * t * v \ 0" using asm tnonz + by blast + have "((t, u, v)\set d \ t \ 0 \ - 1*u^2 + 4 * t * v \ 0 \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm discrim_prop allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using f12 bgrtis + by auto + qed + show "False" using tnonz bgrt1 bgrt2 asm + by auto + qed + have linsetd: "(t, u, v) \ set d \ (t = 0 \ u \ 0) \ False" + proof - + assume asm: "(t, u, v) \ set d \ (t = 0 \ u \ 0)" + then have bgrtis: "?bgrt = (- v / u)" + using unonz + by blast + have "((t, u, v)\set d \ (t = 0 \ u \ 0) \ + ((\(d, e, f)\set a. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>?bgrt. \x\{?bgrt<..y'}. d * x\<^sup>2 + e * x + f \ 0)))" + using asm allpropavar allpropbvar allpropcvar allpropdvar + by linarith + then show "False" using bgrtis f10 + by auto + qed + have insetd: "((t, u, v) \ set d \ (t \ 0 \ u \ 0) \ (t * ?bgrt\<^sup>2 + u * ?bgrt + v = 0)) \ False" + using quadsetd linsetd by auto + then show "False" using insetb insetc insetd tuvprop + by auto + qed + show "False" using cases cases_btw cases_mem cases_lt cases_gt + by auto + qed + show "False" using asm len1 lengtone + by linarith + qed + show "False" using lenzero lengt0 + by linarith + qed + then show ?thesis + by blast +qed + + +lemma qe_forwards: + assumes "(\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" + shows "((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0) \ + (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0))) \ + (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) \ + (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0))) \ + (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))))" + (* using eq_qe_1 les_qe_1 *) +proof - + let ?e2 = "(((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0) + \ + (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))) + \ + (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) + \ + (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))) + \ + (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))))" + let ?f10orf11orf12 = "(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f8orf9 = "(\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + let ?f5orf6orf7 = "(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f2orf3orf4 = "(\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + let ?e1 = "(\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" + let ?f1 = "((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0))" + let ?f2 = "(\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + let ?f3 = "(\(a', b', c')\set a. a' \ 0 \ - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + let ?f4 = "(\(a', b', c')\set a. a' \ 0 \ - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)) " + let ?f5 = "(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + let ?f6 = "(\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f7 = "(\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + let ?f8 = "(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + let ?f13 = "(\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + let ?f9 = "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + let ?f10 = "(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + let ?f11 = "(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f12 = "(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + have h1a: "(?f1 \ ?f2orf3orf4 \ ?f5orf6orf7 \ ?f8orf9 \ ?f10orf11orf12) \ ?e2" + by auto + have h2: "(?f2 \ ?f3 \ ?f4) \ ?f2orf3orf4" by auto + then have h1b: "(?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5orf6orf7 \ ?f8orf9 \ ?f10orf11orf12) \ ?e2" + using h1a by auto + have h3: "(?f5 \ ?f6 \ ?f7) \ ?f5orf6orf7" by auto + then have h1c: "(?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8orf9 \ ?f10orf11orf12) \ ?e2" + using h1b by smt + have h4: "(?f8 \ ?f9 \ ?f13) \ ?f8orf9" by auto + then have h1d: "(?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8 \ ?f9 \ ?f13 \ ?f10orf11orf12) \ ?e2" + using h1c + by smt + have h5: "(?f10 \ ?f11 \ ?f12) \ ?f10orf11orf12" + by auto + then have bigor: "(?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8 \ ?f13 \ ?f9 \ ?f10 \ ?f11 \ ?f12) + \ ?e2 " + using h1d by smt + then have bigor_var: "\?e2 \ \(?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8 \ ?f13 \ ?f9 \ ?f10 \ ?f11 \ ?f12) + " using contrapos_nn + by smt + have not_eq: "\(?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8 \ ?f13 \ ?f9 \ ?f10 \ ?f11 \ ?f12) +=(\?f1 \ \?f2 \ \?f3 \ \?f4 \ \?f5 \ \?f6 \ \?f7 \ \?f8 \ \?f13 \ \?f9 \ \?f10 \ \?f11 \ \?f12) " + by linarith + obtain x where x_prop: "(\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" using assms by auto + have "(\?f1 \ \?f2 \ \?f3 \ \?f4 \ \?f5 \ \?f6 \ \?f7 \ \?f8 \ \?f13 \ \?f9 \ \?f10 \ \?f11 \ \?f12) \ False" + proof - + assume big_not: " \ ((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0)) \ + \ (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)) \ + \ (\(a', b', c')\set a. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)) \ + \ (\(a', b', c')\set a. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)) \ + \ (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)) \ + \ (\(a', b', c')\set b. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)) \ + \ (\(a', b', c')\set b. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)) \ + \ (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)) \ + \ (\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0)) \ + \ (\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0)) \ + \ (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)) \ + \ (\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)) \ + \ (\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + have c1: "(\ (d, e, f) \ set a. d \ 0 \ - e\<^sup>2 + 4 * d * f \ 0) \ False" + proof - + assume "(\ (d, e, f) \ set a. d \ 0 \ - e\<^sup>2 + 4 * d * f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c') \ set a \ a' \ 0 \ - b'\<^sup>2 + 4 * a' * c' \ 0" + by auto + then have "a'*x^2 + b'*x + c' = 0" using x_prop by auto + then have xis: "x = (- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a') \ x = (- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a') " + using abc_prop discriminant_nonneg[of a' b' c'] unfolding discrim_def + by auto + then have "((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)) \ + ((\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + using x_prop by auto + then have "(\(a', b', c')\set a. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)) \ + (\(a', b', c')\set a. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" using abc_prop xis by auto + then show "False" + using big_not by auto + qed + have c2: "(\ (d, e, f) \ set a. d = 0 \ e \ 0) \ False" + proof - + assume "(\ (d, e, f) \ set a. d = 0 \ e \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c') \ set a \ a' = 0 \ b' \ 0" by auto + then have "a'*x^2 + b'*x + c' = 0" using x_prop by auto + then have "b'*x + c' = 0" using abc_prop by auto + then have xis: "x = - c' / b'" using abc_prop + by (smt divide_non_zero) + then have "(\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" + using x_prop by auto + then have "(\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + using abc_prop xis by auto + then show "False" + using big_not by auto + qed + have c3: "(\ (d, e, f) \ set a. d = 0 \ e = 0 \ f = 0) \ False" + proof - + assume "(\ (d, e, f) \ set a. d = 0 \ e = 0 \ f = 0)" + then have equalset: "\x. (\(d, e, f)\set a. d * x^2 + e * x + f = 0)" + using case_prodE by auto + have "\?f5 \ \?f6 \ \?f7 \ \?f8 \ \?f13 \ \?f9 \ \?f10 \ \?f11 \ \?f12" + using big_not by auto + then have "\(\x. (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" + using equalset big_not qe_forwards_helper[of a b c d] by auto + then show "False" + using x_prop by auto + qed + have eo: "(\ (d, e, f) \ set a. d \ 0 \ - e\<^sup>2 + 4 * d * f \ 0) \ (\ (d, e, f) \ set a. d = 0 \ e \ 0) \ (\ (d, e, f) \ set a. d = 0 \ e = 0 \ f = 0)" + proof - + have "(\ (d, e, f) \ set a. (d \ 0 \ - e\<^sup>2 + 4 * d * f \ 0))" + proof clarsimp + fix d e f + assume in_set: " (d, e, f) \ set a" + assume dnonz: "d \ 0" + have "d*x^2 + e*x + f = 0" using in_set x_prop by auto + then show " 4 * d * f \ e\<^sup>2" + using dnonz discriminant_negative[of d e f] unfolding discrim_def + by fastforce + qed + then have discrim_prop: "\(\ (d, e, f) \ set a. d \ 0 \ - e\<^sup>2 + 4 * d * f \ 0) \ \(\ (d, e, f) \ set a. d \ 0)" + by auto + have "\(\ (d, e, f) \ set a. d \ 0) \ \(\ (d, e, f) \ set a. d = 0 \ e \ 0) \ (\ (d, e, f) \ set a. d = 0 \ e = 0 \ f = 0)" + proof - + assume ne: "\(\ (d, e, f) \ set a. d \ 0) \ \(\ (d, e, f) \ set a. d = 0 \ e \ 0)" + show "(\ (d, e, f) \ set a. d = 0 \ e = 0 \ f = 0)" + proof clarsimp + fix d e f + assume in_set: "(d, e, f) \set a" + then have xzer: "d*x^2 + e*x + f = 0" using x_prop by auto + have dzer: "d = 0" using ne in_set by auto + have ezer: "e = 0" using ne in_set by auto + show "d = 0 \ e = 0 \ f = 0" using xzer dzer ezer by auto + qed + qed + then show ?thesis using discrim_prop by auto + qed + show "False" using c1 c2 c3 eo by auto + qed + then have " \?e2 \ False" using bigor_var not_eq + by presburger (* Takes a second *) + then have " \?e2 \ False" using impI[of "\?e2" "False"] + by blast + then show ?thesis + by auto +qed + +subsubsection "Some Cases and Misc" +lemma quadratic_linear : + assumes "b\0" + assumes "a \ 0" + assumes "4 * a * ba \ aa\<^sup>2" + assumes "b * (sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a) + c = 0" + assumes "\x\set eq. + case x of + (d, e, f) \ + d * ((sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a))\<^sup>2 + + e * (sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a) + + f = + 0" + assumes "(aaa, aaaa, baa) \ set eq" + shows "aaa * (c / b)\<^sup>2 - aaaa * c / b + baa = 0" +proof- + have h: "-(c/b) = (sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a)" + using assms + by (smt divide_minus_left nonzero_mult_div_cancel_left times_divide_eq_right) + have h1 : "\x\set eq. case x of (d, e, f) \ d * (c / b)\<^sup>2 + e * - (c / b) + f = 0" + using assms(5) unfolding h[symmetric] Fields.division_ring_class.times_divide_eq_right[symmetric] + Power.ring_1_class.power2_minus . + show ?thesis + using bspec[OF h1 assms(6)] by simp +qed + +lemma quadratic_linear1: + assumes "b\0" + assumes "a \ 0" + assumes "4 * a * ba \ aa\<^sup>2" + assumes "(b::real) * (sqrt ((aa::real)\<^sup>2 - 4 * (a::real) * (ba::real)) - (aa::real)) / (2 * a) + (c::real) = 0" + assumes " + (\x\set (les::(real*real*real)list). + case x of + (d, e, f) \ + d * ((sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a))\<^sup>2 + + e * (sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a) + + f + < 0)" + assumes "(aaa, aaaa, baa) \ set les" + shows "aaa * (c / b)\<^sup>2 - aaaa * c / b + baa < 0" +proof- + have h: "-(c/b) = (sqrt (aa\<^sup>2 - 4 * a * ba) - aa) / (2 * a)" + using assms + by (smt divide_minus_left nonzero_mult_div_cancel_left times_divide_eq_right) + have h1 : "\x\set les. case x of (d, e, f) \ d * (c / b)\<^sup>2 + e * - (c / b) + f < 0" + using assms(5) unfolding h[symmetric] Fields.division_ring_class.times_divide_eq_right[symmetric] + Power.ring_1_class.power2_minus . + show ?thesis + using bspec[OF h1 assms(6)] by simp +qed + +lemma quadratic_linear2 : + assumes "b\0" + assumes "a \ 0" + assumes "4 * a * ba \ aa\<^sup>2" + assumes "b * (- aa -sqrt (aa\<^sup>2 - 4 * a * ba)) / (2 * a) + c = 0" + assumes "\x\set eq. + case x of + (d, e, f) \ + d * ((- aa -sqrt (aa\<^sup>2 - 4 * a * ba)) / (2 * a))\<^sup>2 + + e * (- aa -sqrt (aa\<^sup>2 - 4 * a * ba)) / (2 * a) + + f = + 0" + assumes "(aaa, aaaa, baa) \ set eq" + shows "aaa * (c / b)\<^sup>2 - aaaa * c / b + baa = 0" +proof- + have h: "-((c::real)/(b::real)) = (- (aa::real) -sqrt (aa\<^sup>2 - 4 * (a::real) * (ba::real))) / (2 * a)" + using assms + by (smt divide_minus_left nonzero_mult_div_cancel_left times_divide_eq_right) + have h1 : "\x\set eq. case x of (d, e, f) \ d * (c / b)\<^sup>2 + e * - (c / b) + f = 0" + using assms(5) unfolding h[symmetric] Fields.division_ring_class.times_divide_eq_right[symmetric] + Power.ring_1_class.power2_minus . + show ?thesis + using bspec[OF h1 assms(6)] by simp +qed + +lemma quadratic_linear3: + assumes "b\0" + assumes "a \ 0" + assumes "4 * a * ba \ aa\<^sup>2" + assumes "(b::real) * (- (aa::real)- sqrt ((aa::real)\<^sup>2 - 4 * (a::real) * (ba::real)) ) / (2 * a) + (c::real) = 0" + assumes "(\x\set (les::(real*real*real)list). + case x of + (d, e, f) \ + d * ((- aa - sqrt (aa\<^sup>2 - 4 * a * ba)) / (2 * a))\<^sup>2 + + e * (- aa - sqrt (aa\<^sup>2 - 4 * a * ba)) / (2 * a) + + f + < 0)" + assumes "(aaa, aaaa, baa) \ set les" + shows "aaa * (c / b)\<^sup>2 - aaaa * c / b + baa < 0" +proof- + have h: "-((c::real)/(b::real)) = (- (aa::real) -sqrt (aa\<^sup>2 - 4 * (a::real) * (ba::real))) / (2 * a)" + using assms + by (smt divide_minus_left nonzero_mult_div_cancel_left times_divide_eq_right) + have h1 : "\x\set les. case x of (d, e, f) \ d * (c / b)\<^sup>2 + e * - (c / b) + f < 0" + using assms(5) unfolding h[symmetric] Fields.division_ring_class.times_divide_eq_right[symmetric] + Power.ring_1_class.power2_minus . + show ?thesis + using bspec[OF h1 assms(6)] by simp +qed + + +lemma h1b_helper_les: + "(\((a::real), (b::real), (c::real))\set les. \x. \y2 + b * y + c < 0) \ (\y.\x(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" +proof - + show "(\(a, b, c)\set les. \x. \y2 + b * y + c < 0) \ (\y.\x(a, b, c)\set les. a * x\<^sup>2 + b * x + c < 0))" + proof (induct les) + case Nil + then show ?case + by auto + next + case (Cons q les) + have ind: " \a\set (q # les). case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0" + using Cons.prems + by auto + then have "case q of (a, ba, c) \ \x. \y2 + ba * y + c < 0 " + by simp + then obtain y2 where y2_prop: "case q of (a, ba, c) \ (\y2 + ba * y + c < 0)" + by auto + have "\a\set les. case a of (a, ba, c) \ \x. \y2 + ba * y + c < 0" + using ind by simp + then have " \y. \xa\set les. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c < 0" + using Cons.hyps by blast + then obtain y1 where y1_prop: "\xa\set les. case a of (a, ba, c) \ a * x^2 + ba * x + c < 0" + by blast + let ?y = "min y1 y2" + have "\x < ?y. (\a\set (q #les). case a of (a, ba, c) \ a * x^2 + ba * x + c < 0)" + using y1_prop y2_prop + by fastforce + then show ?case + by blast + qed +qed + +lemma h1b_helper_leq: + "(\((a::real), (b::real), (c::real))\set leq. \x. \y2 + b * y + c \ 0) \ (\y.\x(a, b, c)\set leq. a * x\<^sup>2 + b * x + c \ 0))" +proof - + show "(\(a, b, c)\set leq. \x. \y2 + b * y + c \ 0) \ (\y.\x(a, b, c)\set leq. a * x\<^sup>2 + b * x + c \ 0))" + proof (induct leq) + case Nil + then show ?case + by auto + next + case (Cons q leq) + have ind: " \a\set (q # leq). case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0" + using Cons.prems + by auto + then have "case q of (a, ba, c) \ \x. \y2 + ba * y + c \ 0 " + by simp + then obtain y2 where y2_prop: "case q of (a, ba, c) \ (\y2 + ba * y + c \ 0)" + by auto + have "\a\set leq. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0" + using ind by simp + then have " \y. \xa\set leq. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0" + using Cons.hyps by blast + then obtain y1 where y1_prop: "\xa\set leq. case a of (a, ba, c) \ a * x^2 + ba * x + c \ 0" + by blast + let ?y = "min y1 y2" + have "\x < ?y. (\a\set (q #leq). case a of (a, ba, c) \ a * x^2 + ba * x + c \ 0)" + using y1_prop y2_prop + by fastforce + then show ?case + by blast + qed +qed + +lemma h1b_helper_neq: + "(\((a::real), (b::real), (c::real))\set neq. \x. \y2 + b * y + c \ 0) \ (\y.\x(a, b, c)\set neq. a * x\<^sup>2 + b * x + c \ 0))" +proof - + show "(\(a, b, c)\set neq. \x. \y2 + b * y + c \ 0) \ (\y.\x(a, b, c)\set neq. a * x\<^sup>2 + b * x + c \ 0))" + proof (induct neq) + case Nil + then show ?case + by auto + next + case (Cons q neq) + have ind: " \a\set (q # neq). case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0" + using Cons.prems + by auto + then have "case q of (a, ba, c) \ \x. \y2 + ba * y + c \ 0 " + by simp + then obtain y2 where y2_prop: "case q of (a, ba, c) \ (\y2 + ba * y + c \ 0)" + by auto + have "\a\set neq. case a of (a, ba, c) \ \x. \y2 + ba * y + c \ 0" + using ind by simp + then have " \y. \xa\set neq. case a of (a, ba, c) \ a * x\<^sup>2 + ba * x + c \ 0" + using Cons.hyps by blast + then obtain y1 where y1_prop: "\xa\set neq. case a of (a, ba, c) \ a * x^2 + ba * x + c \ 0" + by blast + let ?y = "min y1 y2" + have "\x < ?y. (\a\set (q #neq). case a of (a, ba, c) \ a * x^2 + ba * x + c \ 0)" + using y1_prop y2_prop + by fastforce + then show ?case + by blast + qed +qed + + +lemma min_lem: + fixes r::"real" + assumes a1: "(\y'>r. (\((d::real), (e::real), (f::real))\set b. \x\{r<..y'}. d * x\<^sup>2 + e * x + f < 0))" + assumes a2: "(\y'>r. (\((d::real), (e::real), (f::real))\set c. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + assumes a3: "(\y'>r. (\((d::real), (e::real), (f::real))\set d. \x\{r<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + shows "(\x. (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" +proof - + obtain y1 where y1_prop: "y1 > r \ (\(d, e, f)\set b. \x\{r<..y1}. d * x\<^sup>2 + e * x + f < 0)" + using a1 by auto + obtain y2 where y2_prop: "y2 > r \ (\(d, e, f)\set c. \x\{r<..y2}. d * x\<^sup>2 + e * x + f \ 0)" + using a2 by auto + obtain y3 where y3_prop: "y3 > r \ (\(d, e, f)\set d. \x\{r<..y3}. d * x\<^sup>2 + e * x + f \ 0)" + using a3 by auto + let ?y = "(min (min y1 y2) y3)" + have "?y > r" using y1_prop y2_prop y3_prop by auto + then have "\x. x > r \ x < ?y" using dense[of r ?y] + by auto + then obtain x where x_prop: "x > r \ x < ?y" by auto + have bp: "(\(a, b, c)\set b. a *x\<^sup>2 + b * x + c < 0)" + using x_prop y1_prop by auto + have cp: "(\(a, b, c)\set c. a * x^2 + b * x + c \ 0)" + using x_prop y2_prop by auto + have dp: "(\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" + using x_prop y3_prop by auto + then have "(\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" + using bp cp dp by auto + then show ?thesis by auto +qed + +lemma qe_infinitesimals_helper: + fixes k::"real" + assumes asm: "(\(d, e, f)\set a. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + shows "(\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" +proof - + have "\(d, e, f)\set a. d = 0 \ e = 0 \ f = 0" + proof clarsimp + fix d e f + assume "(d, e, f) \ set a" + then have "\y'>k. \x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0" + using asm by auto + then obtain y' where y_prop: "y'>k \ (\x\{k<..y'}. d * x\<^sup>2 + e * x + f = 0)" + by auto + then show "d = 0 \ e = 0 \ f = 0" using continuity_lem_eq0[of "k" "y'" d e f] + by auto + qed + then have eqprop: "\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) " + by auto + have lesprop: "(\y'>k. (\(d, e, f)\set b. \x\{k<..y'}. d * x\<^sup>2 + e * x + f < 0))" + using les_qe_inf_helper[of b "k"] asm + by blast + have leqprop: "(\y'>k. (\(d, e, f)\set c. \x\{(k)<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using leq_qe_inf_helper[of c "k"] asm + by blast + have neqprop: "(\y'>(k). (\(d, e, f)\set d. \x\{(k)<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + using neq_qe_inf_helper[of d "k"] asm + by blast + then have "(\x. (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)) " + using lesprop leqprop neqprop min_lem[of "k" b c d] + by auto + then show ?thesis + using eqprop by auto +qed + +subsubsection "The qe\\_backwards lemma" +lemma qe_backwards: + assumes "(((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0) + \ + (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))) + \ + (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) + \ + (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))) + \ + (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))))" + shows " (\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" +proof - + let ?e2 = "(((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0) + \ + (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))) + \ + (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) + \ + (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))) + \ + (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))))" + let ?f10orf11orf12 = "(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f8orf9 = "(\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + let ?f5orf6orf7 = "(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) + \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f2orf3orf4 = "(\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) + \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) + \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + let ?e1 = "(\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" + let ?f1 = "((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0))" + let ?f2 = "(\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + let ?f3 = "(\(a', b', c')\set a. a' \ 0 \ - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + let ?f4 = "(\(a', b', c')\set a. a' \ 0 \ - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)) " + let ?f5 = "(\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + let ?f6 = "(\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f7 = "(\(a', b', c')\set b. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + let ?f8 = "(\(a', b', c')\set c. (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0))" + let ?f13 = "(\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)))" + let ?f9 = "(\(a', b', c')\set c. a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0))" + let ?f10 = "(\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0))" + let ?f11 = "(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + let ?f12 = "(\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))" + have h1a: "?e2 \ (?f1 \ ?f2orf3orf4 \ ?f5orf6orf7 \ ?f8orf9 \ ?f10orf11orf12)" + by auto + have h2: "?f2orf3orf4 \ (?f2 \ ?f3 \ ?f4)" by auto + then have h1b: "?e2 \ (?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5orf6orf7 \ ?f8orf9 \ ?f10orf11orf12) " + using h1a by auto + have h3: "?f5orf6orf7 \ (?f5 \ ?f6 \ ?f7)" by auto + then have h1c: "?e2 \ (?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8orf9 \ ?f10orf11orf12) " + using h1b by smt + have h4: "?f8orf9 \ (?f8 \ ?f9 \ ?f13)" by auto + then have h1d: "?e2 \ (?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8 \ ?f9 \ ?f13 \ ?f10orf11orf12) " + using h1c + by smt + have h5: "?f10orf11orf12 \ (?f10 \ ?f11 \ ?f12)" + by auto + then have bigor: "?e2 \ (?f1 \ ?f2 \ ?f3 \ ?f4 \ ?f5 \ ?f6 \ ?f7 \ ?f8 \ ?f13 \ ?f9 \ ?f10 \ ?f11 \ ?f12) " + using h1d by smt + have "?f1 \ ?e1" + proof - + assume asm: "(\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0)" + then have eqprop: "\x. \(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0" by auto + have "\y. \x(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0" + using asm h1b_helper_les by auto + then obtain y1 where y1_prop: "\x(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0" by auto + have "\y. \x(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0" + using asm h1b_helper_leq by auto + then obtain y2 where y2_prop: "\x(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0" by auto + have "\y. \x(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0" + using asm h1b_helper_neq by auto + then obtain y3 where y3_prop: "\x(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0" by auto + let ?y = "(min (min y1 y2) y3) - 1" + have y_prop: "?y < y1 \ ?y < y2 \ ?y < y3" + by auto + have ap: "(\(a, b, c)\set a. a * ?y\<^sup>2 + b * ?y + c = 0)" + using eqprop by auto + have bp: "(\(a, b, c)\set b. a * ?y\<^sup>2 + b * ?y + c < 0)" + using y_prop y1_prop by auto + have cp: "(\(a, b, c)\set c. a * ?y\<^sup>2 + b * ?y + c \ 0)" + using y_prop y2_prop by auto + have dp: "(\(a, b, c)\set d. a * ?y\<^sup>2 + b * ?y + c \ 0)" + using y_prop y3_prop by auto + then have "(\(a, b, c)\set a. a * ?y\<^sup>2 + b * ?y + c = 0) \ + (\(a, b, c)\set b. a * ?y\<^sup>2 + b * ?y + c < 0) \ + (\(a, b, c)\set c. a * ?y\<^sup>2 + b * ?y + c \ 0) \ + (\(a, b, c)\set d. a * ?y\<^sup>2 + b * ?y + c \ 0)" + using ap bp cp dp by auto + then show ?thesis by auto + qed + then have h1: "?f1 \ ?e1" + by auto + have "?f2 \ ?e1" + proof - + assume " \(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set a \ + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" + by auto + then have "\(x::real). x = -c'/b'" by auto + then obtain x where x_prop: "x = - c' / b'" by auto + then have "(\xa\set a. case xa of (a, b, c) \ a * x\<^sup>2 + b * x + c = 0) \ + (\xa\set b. case xa of (a, b, c) \ a * x\<^sup>2 + b * x + c < 0) \ + (\xa\set c. case xa of (a, b, c) \ a * x\<^sup>2 + b * x + c \ 0) \ + (\xa\set d. case xa of (a, b, c) \ a * x\<^sup>2 + b * x + c \ 0)" + using abc_prop by auto + then show ?thesis by auto + qed + then have h2: "?f2 \ ?e1" + by auto + have "?f3 \ ?e1" + proof - + assume "\(a', b', c')\set a. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set a \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" by auto + then have "\(x::real). x = (- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then obtain x where x_prop: " x = (- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then have "(\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" using abc_prop by auto + then show ?thesis by auto + qed + then have h3: "?f3 \ ?e1" + by auto + have "?f4 \ ?e1" + proof - + assume " \(a', b', c')\set a. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set a \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" by auto + then have "\(x::real). x = (- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then obtain x where x_prop: " x = (- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then have "(\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" using abc_prop by auto + then show ?thesis by auto + qed + then have "?f4 \ ?e1" by auto + have "?f5 \ ?e1" + proof - + assume asm: "\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set b \ + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + then show ?thesis using qe_infinitesimals_helper[of a "- c' / b'" b c d] + by auto + qed + then have h5: "?f5 \ ?e1" + by auto + have "?f6 \ ?e1" + proof - + assume "\(a', b', c')\set b. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set b \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" by auto + then show ?thesis using qe_infinitesimals_helper[of a "(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" b c d] + by auto + qed + then have h6: "?f6 \ ?e1" + by auto + have "?f7 \ ?e1" + proof - + assume "\(a', b', c')\set b. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set b \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" + by auto + then show ?thesis using qe_infinitesimals_helper[of a "(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" b c d] + by auto + qed + then have h7: "?f7 \ ?e1" + by auto + have "?f8 \ ?e1" + proof - + assume "\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0)" by auto + then have "\(x::real). x = (- c' / b')" by auto + then obtain x where x_prop: " x = - c' / b'" by auto + then have "(\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" using abc_prop by auto + then show ?thesis by auto + qed + then have h8: "?f8 \ ?e1" by auto + have "?f9 \ ?e1" + proof - + assume "\(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" by auto + then have "\(x::real). x = (- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then obtain x where x_prop: " x = (- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then have "(\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" using abc_prop by auto + then show ?thesis by auto + qed + then have h9: "?f9 \ ?e1" by auto + have "?f10 \ ?e1" + proof - + assume asm: "\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set d \ + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0)" + by auto + then show ?thesis using qe_infinitesimals_helper[of a "- c' / b'" b c d] + by auto + qed + then have h10: "?f10 \ ?e1" by auto + have "?f11 \ ?e1" + proof - + assume "\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set d \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" by auto + then show ?thesis using qe_infinitesimals_helper[of a "(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" b c d] + by auto + qed + then have h11: "?f11 \ ?e1" by auto + have "?f12 \ ?e1" proof - + assume "\(a', b', c')\set d. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set d \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)" + by auto + then show ?thesis using qe_infinitesimals_helper[of a "(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" b c d] + by auto + qed + then have h12: "?f12 \ ?e1" by auto + have "?f13 \ ?e1" proof - + assume " \(a', b', c')\set c. + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" + then obtain a' b' c' where abc_prop: "(a', b', c')\set c \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + (\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ 0)" by auto + then have "\(x::real). x = (- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then obtain x where x_prop: " x = (- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')" by auto + then have "(\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)" using abc_prop by auto + then show ?thesis by auto + qed + then have h13: "?f13 \ ?e1" by auto + show ?thesis using bigor h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 + using assms + by (smt \\(a', b', c')\set a. a' \ 0 \ - b'\<^sup>2 + 4 * a' * c' \ 0 \ (\(d, e, f)\set a. d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + f = 0) \ (\(d, e, f)\set b. d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + f < 0) \ (\(d, e, f)\set c. d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + f \ 0) \ (\(d, e, f)\set d. d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + f \ 0) \ \x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)\) + (* by force *) +qed + +subsection "General QE lemmas" + +lemma qe: "(\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0)) = + ((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0) \ + (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0))) \ + (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) \ + (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0))) \ + (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))))" +proof - + let ?e1 = "((\(a, b, c)\set a. a = 0 \ b = 0 \ c = 0) \ + (\(a, b, c)\set b. \x. \y2 + b * y + c < 0) \ + (\(a, b, c)\set c. \x. \y2 + b * y + c \ 0) \ + (\(a, b, c)\set d. \x. \y2 + b * y + c \ 0) \ + (\(a', b', c')\set a. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0))) \ + (\(a', b', c')\set b. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))) \ + (\(a', b', c')\set c. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\(d, e, f)\set b. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\(d, e, f)\set c. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\(d, e, f)\set d. d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\(d, e, f)\set a. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\(d, e, f)\set b. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\(d, e, f)\set c. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\(d, e, f)\set d. + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0))) \ + (\(a', b', c')\set d. + (a' = 0 \ b' \ 0) \ + (\(d, e, f)\set a. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set a. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set a. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set b. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set c. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set d. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0))))" + let ?e2 = "(\x. (\(a, b, c)\set a. a * x\<^sup>2 + b * x + c = 0) \ + (\(a, b, c)\set b. a * x\<^sup>2 + b * x + c < 0) \ + (\(a, b, c)\set c. a * x\<^sup>2 + b * x + c \ 0) \ + (\(a, b, c)\set d. a * x\<^sup>2 + b * x + c \ 0))" + have h1: "?e1 \ ?e2" using qe_backwards + by auto + have h2: "?e2 \ ?e1" using qe_forwards + by auto + have "(?e2 \ ?e1) \ (?e1 \ ?e2) " using h1 h2 + by force + then have "?e2 \ ?e1" + using iff_conv_conj_imp[of ?e1 ?e2] + by presburger + then show ?thesis + by auto +qed + + +fun eq_fun :: "real \ real \ real \ (real*real*real) list \ (real*real*real) list \ (real*real*real) list \ (real*real*real) list \ bool" where + "eq_fun a' b' c' eq les leq neq = ((a' = 0 \ b' \ 0) \ + (\a\set eq. + case a of (d, e, f) \ d * (- c' / b')\<^sup>2 + e * (- c' / b') + f = 0) \ + (\a\set les. + case a of (d, e, f) \ d * (- c' / b')\<^sup>2 + e * (- c' / b') + f < 0) \ + (\a\set leq. + case a of (d, e, f) \ d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + (\a\set neq. + case a of (d, e, f) \ d * (- c' / b')\<^sup>2 + e * (- c' / b') + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\a\set eq. + case a of + (d, e, f) \ + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\a\set les. + case a of + (d, e, f) \ + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\a\set leq. + case a of + (d, e, f) \ + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\a\set neq. + case a of + (d, e, f) \ + d * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0) \ + (\a\set eq. + case a of + (d, e, f) \ + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f = + 0) \ + (\a\set les. + case a of + (d, e, f) \ + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + < 0) \ + (\a\set leq. + case a of + (d, e, f) \ + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f + \ 0) \ + (\a\set neq. + case a of + (d, e, f) \ + d * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'))\<^sup>2 + + e * ((- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')) + + f \ + 0)))" + +fun les_fun :: "real \ real \ real \ (real*real*real) list \ (real*real*real) list \ (real*real*real) list \ (real*real*real) list \ bool" where + "les_fun a' b' c' eq les leq neq = ((a' = 0 \ b' \ 0) \ + (\(d, e, f)\set eq. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set les. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set leq. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set neq. + \y'>- c' / b'. \x\{- c' / b'<..y'}. d * x\<^sup>2 + e * x + f \ 0) \ + a' \ 0 \ + - b'\<^sup>2 + 4 * a' * c' \ 0 \ + ((\(d, e, f)\set eq. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set les. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set leq. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set neq. + \y'>(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set eq. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f = 0) \ + (\(d, e, f)\set les. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f < 0) \ + (\(d, e, f)\set leq. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0) \ + (\(d, e, f)\set neq. + \y'>(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a'). + \x\{(- b' + - 1 * sqrt (b'\<^sup>2 - 4 * a' * c')) / (2 * a')<..y'}. + d * x\<^sup>2 + e * x + f \ 0)))" + +lemma general_qe' : + (* Direct substitution F(x) *) + assumes "F = (\x. + (\(a,b,c)\set eq . a*x\<^sup>2+b*x+c=0)\ + (\(a,b,c)\set les. a*x\<^sup>2+b*x+c<0)\ + (\(a,b,c)\set leq. a*x\<^sup>2+b*x+c\0)\ + (\(a,b,c)\set neq. a*x\<^sup>2+b*x+c\0))" + (* Substitution of r+\ into F *) + assumes "F\ = (\r. + (\(a,b,c)\set eq. \y>r.\x\{r<..y}. a*x\<^sup>2+b*x+c=0) \ + (\(a,b,c)\set les. \y>r.\x\{r<..y}. a*x\<^sup>2+b*x+c<0) \ + (\(a,b,c)\set leq. \y>r.\x\{r<..y}. a*x\<^sup>2+b*x+c\0) \ + (\(a,b,c)\set neq. \y>r.\x\{r<..y}. a*x\<^sup>2+b*x+c\0) + )" + (* Substitution of -\ into F *) + assumes "F\<^sub>i\<^sub>n\<^sub>f = ( + (\(a,b,c)\set eq. \x. \y2+b*y+c=0) \ + (\(a,b,c)\set les. \x. \y2+b*y+c<0) \ + (\(a,b,c)\set leq. \x. \y2+b*y+c\0) \ + (\(a,b,c)\set neq. \x. \y2+b*y+c\0) + )" + (* finds linear or quadratic roots of a polynomial *) + assumes "roots = (\(a,b,c). + if a=0 \ b\0 then {-c/b}::real set else + if a\0 \ b\<^sup>2-4*a*c\0 then {(-b+sqrt(b\<^sup>2-4*a*c))/(2*a)}\{(-b-sqrt(b\<^sup>2-4*a*c))/(2*a)} else {})" + (* all the root of each atom *) + assumes "A = \(roots ` (set eq))" + assumes "B = \(roots ` (set les))" + assumes "C = \(roots ` (set leq))" + assumes "D = \(roots ` (set neq))" + (* Quantifier Elimination *) + shows "(\x. F(x)) = (F\<^sub>i\<^sub>n\<^sub>f\(\r\A. F r)\(\r\B. F\ r)\(\r\C. F r)\(\r\D. F\ r))" +proof- + { fix X + have "(\(a, b, c)\set X. eq_fun a b c eq les leq neq) = (\x\F ` \(roots ` (set X)). x)" + proof(induction X) + case Nil + then show ?case by auto + next + case (Cons p X) + have h1: "(\x\F ` \ (roots ` set (p # X)). x) = ((\x\F ` roots p. x) \ (\x\F ` \ (roots ` set X). x))" + by auto + have h2 :"(case p of (a,b,c) \ eq_fun a b c eq les leq neq) = (\x\F ` roots p. x)" + apply(cases p) unfolding assms apply simp by linarith + show ?case unfolding h1 Cons[symmetric] using h2 by auto + qed + } + then have eq : "\X. (\(a, b, c)\set X. eq_fun a b c eq les leq neq) = (\x\F ` \ (roots ` set X). x)" by auto + { fix X + have "(\(a, b, c)\set X. les_fun a b c eq les leq neq) = (\x\F\ ` \(roots ` (set X)). x)" + proof(induction X) + case Nil + then show ?case by auto + next + case (Cons p X) + have h1: "(\x\F\ ` \ (roots ` set (p # X)). x) = ((\x\F\ ` roots p. x) \ (\x\F\ ` \ (roots ` set X). x))" + by auto + have h2 :"(case p of (a,b,c) \ les_fun a b c eq les leq neq) = (\x\F\ ` roots p. x)" + apply(cases p) unfolding assms apply simp by linarith + show ?case unfolding h1 Cons[symmetric] using h2 by auto + qed + } + then have les : "\X. (\(a, b, c)\set X. les_fun a b c eq les leq neq) = (\x\F\ ` \ (roots ` set X). x)" by auto + have inf : "(\(a, b, c)\set eq. a = 0 \ b = 0 \ c = 0) = (\x\set eq. case x of (a, b, c) \ \x. \y2 + b * y + c = 0)" + proof(induction eq) + case Nil + then show ?case by auto + next + case (Cons p eq) + then show ?case proof(cases p) + case (fields a b c) + show ?thesis unfolding fields using infzeros[of _ a b c] Cons by auto + qed + qed + show ?thesis + using qe[of "eq" "les" "leq" "neq"] + using eq[of eq] eq[of leq] les[of les] les[of neq] unfolding inf assms + by auto +qed + +lemma general_qe'' : + (* Direct substitution F(x) *) + assumes "S = {(=), (<), (\), (\)}" + assumes "finite (X (=))" + assumes "finite (X (<))" + assumes "finite (X (\))" + assumes "finite (X (\))" + assumes "F = (\x. \rel\S. \(a,b,c)\(X rel). rel (a*x\<^sup>2+b*x+c) 0)" + (* Substitution of r+\ into F *) + assumes "F\ = (\r. \rel\S. \(a,b,c)\(X rel). \y>r.\x\{r<..y}. rel (a*x\<^sup>2+b*x+c) 0)" + (* Substitution of -\ into F *) + assumes "F\<^sub>i\<^sub>n\<^sub>f = (\rel\S. \(a,b,c)\(X rel). \x. \y2+b*y+c) 0)" + (* finds linear or quadratic roots of a polynomial *) + assumes "roots = (\(a,b,c). + if a=0 \ b\0 then {-c/b}::real set else + if a\0 \ b\<^sup>2-4*a*c\0 then {(-b+sqrt(b\<^sup>2-4*a*c))/(2*a)}\{(-b-sqrt(b\<^sup>2-4*a*c))/(2*a)} else {})" + (* all the root of each atom *) + assumes "A = \(roots ` ((X (=))))" + assumes "B = \(roots ` ((X (<))))" + assumes "C = \(roots ` ((X (\))))" + assumes "D = \(roots ` ((X (\))))" + (* Quantifier Elimination *) + shows "(\x. F(x)) = (F\<^sub>i\<^sub>n\<^sub>f\(\r\A. F r)\(\r\B. F\ r)\(\r\C. F r)\(\r\D. F\ r))" +proof- + define less where "less = (\(a::real,b::real,c::real).\(a',b',c'). a (a=a'\ (b(b=b'\cx.\y. x=y \ less x y)" + have linorder: "class.linorder leq less" + unfolding class.linorder_def class.order_def class.preorder_def class.order_axioms_def class.linorder_axioms_def + less_def leq_def by auto + show ?thesis + using assms(6-8) unfolding assms(1) apply simp + using general_qe'[OF _ _ _ assms(9), of F "List.linorder.sorted_list_of_set leq (X (=))" "List.linorder.sorted_list_of_set leq (X (<))" "List.linorder.sorted_list_of_set leq (X (\))" "List.linorder.sorted_list_of_set leq (X (\))" F\ F\<^sub>i\<^sub>n\<^sub>f A B C D] + unfolding List.linorder.set_sorted_list_of_set[OF linorder assms(2)] List.linorder.set_sorted_list_of_set[OF linorder assms(3)] List.linorder.set_sorted_list_of_set[OF linorder assms(4)] List.linorder.set_sorted_list_of_set[OF linorder assms(5)] + using assms(10-13)by auto +qed + + +theorem general_qe : + (* finite sets of atoms involving = < \ and \*) + assumes "R = {(=), (<), (\), (\)}" + assumes "\rel\R. finite (Atoms rel)" + (* Direct substitution F(x) *) + assumes "F = (\x. \rel\R. \(a,b,c)\(Atoms rel). rel (a*x\<^sup>2+b*x+c) 0)" + (* Substitution of r+\ into F *) + assumes "F\ = (\r. \rel\R. \(a,b,c)\(Atoms rel). \y>r.\x\{r<..y}. rel (a*x\<^sup>2+b*x+c) 0)" + (* Substitution of -\ into F *) + assumes "F\<^sub>i\<^sub>n\<^sub>f = (\rel\R. \(a,b,c)\(Atoms rel). \x. \y2+b*y+c) 0)" + (* finds linear or quadratic roots of a polynomial *) + assumes "roots = (\(a,b,c). + if a=0 \ b\0 then {-c/b} else + if a\0 \ b\<^sup>2-4*a*c\0 then {(-b+sqrt(b\<^sup>2-4*a*c))/(2*a)}\{(-b-sqrt(b\<^sup>2-4*a*c))/(2*a)} else {})" + (* Quantifier Elimination *) + shows "(\x. F(x)) = + (F\<^sub>i\<^sub>n\<^sub>f \ + (\r\\(roots ` (Atoms (=) \ Atoms (\))). F r) \ + (\r\\(roots ` (Atoms (<) \ Atoms (\))). F\ r))" + using general_qe''[OF assms(1) _ _ _ _ assms(3-6) refl refl refl refl] + using assms(2) unfolding assms(1) + by auto + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/QuadraticCase.thy b/thys/Virtual_Substitution/QuadraticCase.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/QuadraticCase.thy @@ -0,0 +1,969 @@ +subsection "Quadratic Case" +theory QuadraticCase + imports VSAlgos +begin + +(*-------------------------------------------------------------------------------------------------------------*) +lemma quad_part_1_eq : + assumes lLength : "length L > var" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg::nat)" + assumes nonzero : "D \ 0" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) a = (A::real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) b = (B::real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) d = (D::real)" + shows "aEval (Eq p) (list_update L var ((A+B*C)/D)) = aEval (Eq(quadratic_part_1 var a b d (Eq p))) (list_update L var C)" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var C)) (isolate_variable_sparse p var i) * ((A + B * C) ^ i)" for i + have h1 : "\i. (insertion (nth_default 0 (list_update L var C)) (isolate_variable_sparse p var i)) = (insertion (nth_default 0 (list_update L var ((A+B*C)/D))) (isolate_variable_sparse p var i))" + by(simp add: insertion_isovarspars_free) + have h2 : "((\i = 0..i = 0..i = 0..i = 0..i = 0..i = 0..i = 0.. var" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg::nat)" + assumes nonzero : "D \ 0" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) a = (A::real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) b = (B::real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) d = (D::real)" + shows "aEval (Less p) (list_update L var ((A+B*C)/D)) = aEval (Less(quadratic_part_1 var a b d (Less p))) (list_update L var C)" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var C)) (isolate_variable_sparse p var i) * ((A + B * C) ^ i)" for i + have h1a : "((\i = 0..i = 0..i. (insertion (nth_default 0 (list_update L var C)) (isolate_variable_sparse p var i)) = (insertion (nth_default 0 (list_update L var ((A+B*C)/D))) (isolate_variable_sparse p var i))" + by(simp add: insertion_isovarspars_free) + have "((\i = 0..i = 0..i = 0..i = 0..i = 0.. var" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg::nat)" + assumes nonzero : "D \ 0" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) a = (A::real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) b = (B::real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) d = (D::real)" + shows "aEval (Leq p) (list_update L var ((A+B*C)/D)) = aEval (Leq(quadratic_part_1 var a b d (Leq p))) (list_update L var C)" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var C)) (isolate_variable_sparse p var i) * ((A + B * C) ^ i)" for i + have h1a : "((\i = 0..i = 0..i = 0..i = 0..i = 0.. 0) =((\i = 0.. 0)" + using h1a h1b nonzero by auto + have h4a : "\i. (insertion (nth_default 0 (list_update L var C)) (isolate_variable_sparse p var i)) = (insertion (nth_default 0 (list_update L var ((A+B*C)/D))) (isolate_variable_sparse p var i))" + by(simp add: insertion_isovarspars_free) + have "((\i = 0.. 0)= + ((\i = 0.. 0)" + using h1c f_def by auto + also have "...=((\i = 0.. 0)" + by auto + also have "...=((\i = 0.. 0)" + by (metis (no_types, lifting) power_divide sum.cong) + also have "...=((\i = 0..0)" + using h4a by auto + also have "... = (insertion (nth_default 0 (list_update L var ((A+B*C)/D))) p\0)" + using sum_over_degree_insertion hdeg lLength by auto + finally show ?thesis + by(simp add: hdeg lLength insertion_add insertion_mult ha hb hd insertion_sum insertion_pow insertion_var) +qed + +(*------------------------------------------------------------------------------------------------*) +lemma quad_part_1_neq : + assumes lLength : "length L > var" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg::nat)" + assumes nonzero : "D \ 0" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) a = (A::real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) b = (B::real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) d = (D::real)" + shows "aEval (Neq p) (list_update L var ((A+B*C)/D)) = aEval (Neq(quadratic_part_1 var a b d (Neq p))) (list_update L var C)" +proof - + have "aEval (Eq(quadratic_part_1 var a b d (Eq p))) (list_update L var C) = aEval (Eq p) (list_update L var ((A+B*C)/D))" + using quad_part_1_eq assms by blast + then show ?thesis by auto +qed + +(*------------------------------------------------------------------------------------------------*) + + +lemma sqrt_case : + assumes detGreater0 : "SQ \ 0" + shows "((SQ^(i div 2)) * real (i mod 2) * sqrt SQ + SQ ^ (i div 2) * (1 - real (i mod 2))) = (sqrt SQ) ^ i" +proof - + have h1 : "i mod 2 = 0 \ (odd i \ (i mod 2 = 1))" + by auto + have h2 : "i mod 2 = 0 \ ((SQ^(i div 2)) * real (i mod 2) * sqrt SQ + SQ ^ (i div 2) * (1 - real (i mod 2))) = (sqrt SQ) ^ i" + using detGreater0 apply auto + by (simp add: real_sqrt_power_even) + have h3 : "(odd i \ (i mod 2 = 1)) \ ((SQ^(i div 2)) * real (i mod 2) * sqrt SQ + SQ ^ (i div 2) * (1 - real (i mod 2))) = (sqrt SQ) ^ i" + using detGreater0 apply auto + by (smt One_nat_def add_Suc_right mult.commute nat_arith.rule0 odd_two_times_div_two_succ power.simps(2) power_mult real_sqrt_pow2) + show ?thesis + using h1 h2 h3 + by linarith +qed + +lemma sum_over_sqrt : + assumes detGreater0 : "SQ \ 0" + shows "(\i\{0..i\{0.. var" + assumes detGreater0 : "SQ\0" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg ::nat)" + assumes hsq : "\x. insertion (nth_default 0 (list_update L var x)) sq = (SQ::real)" + shows "aEval (Eq p) (list_update L var (sqrt SQ)) = aEval (Eq(quadratic_part_2 var sq p)) (list_update L var (sqrt SQ))" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var (sqrt SQ))) (isolate_variable_sparse p var i)" for i + have h1a : "(\i\{0..i\{0..i\{0..i\{0.. var" + assumes detGreater0 : "SQ\0" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg ::nat)" + assumes hsq : "\x. insertion (nth_default 0 (list_update L var x)) sq = (SQ::real)" + shows "aEval (Less p) (list_update L var (sqrt SQ)) = aEval (Less(quadratic_part_2 var sq p)) (list_update L var (sqrt SQ))" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var (sqrt SQ))) (isolate_variable_sparse p var i)" for i + have h1a : "(\i\{0..i\{0..i\{0..i\{0.. var" + assumes detGreater0 : "SQ\0" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg ::nat)" + assumes hsq : "\x. insertion (nth_default 0 (list_update L var x)) sq = (SQ::real)" + shows "aEval (Neq p) (list_update L var (sqrt SQ)) = aEval (Neq(quadratic_part_2 var sq p)) (list_update L var (sqrt SQ))" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var (sqrt SQ))) (isolate_variable_sparse p var i)" for i + have h1a : "(\i\{0..i\{0..i\{0..i\{0.. var" + assumes detGreater0 : "SQ\0" + assumes hdeg : "MPoly_Type.degree (p::real mpoly) var = (deg ::nat)" + assumes hsq : "\x. insertion (nth_default 0 (list_update L var x)) sq = (SQ::real)" + shows "aEval (Leq p) (list_update L var (sqrt SQ)) = aEval (Leq(quadratic_part_2 var sq p)) (list_update L var (sqrt SQ))" +proof - + define f where "f i = insertion (nth_default 0 (list_update L var (sqrt SQ))) (isolate_variable_sparse p var i)" for i + have h1a : "(\i\{0..i\{0..i\{0..i\{0..vars(sq::real mpoly)" + shows "MPoly_Type.degree (quadratic_part_2 var sq p) var \ 1" +proof - + define deg where "deg = MPoly_Type.degree (p::real mpoly) var" + define f where "f i = isolate_variable_sparse p var i * sq ^ (i div 2) * Const (real (i mod 2)) * Var var" for i + define g where "g i = isolate_variable_sparse p var i * sq ^ (i div 2) * Const (1 - real (i mod 2))" for i + have h1a : "\i. MPoly_Type.degree (isolate_variable_sparse p var i) var = 0" + by (simp add: varNotIn_degree not_in_isovarspar) + have h1b : "\i. MPoly_Type.degree (sq ^ (i div 2)) var = 0" + by (simp add: sqfree varNotIn_degree not_in_pow) + have h1c : "\i. MPoly_Type.degree (Const (real (i mod 2))) var = 0" + using degree_const by blast + have h1d : "MPoly_Type.degree (Var var :: real mpoly) var = 1" + using degree_one by auto + have h1 : "\i 1" + using f_def degree_mult h1a h1b h1c h1d + by (smt ExecutiblePolyProps.degree_one add.right_neutral mult.commute mult_eq_0_iff nat_le_linear not_one_le_zero) + have h2a : "\i. MPoly_Type.degree (Const (1 - real (i mod 2))) var = 0" + using degree_const by blast + have h2 : "\ii 1" + using h1 h2 by (simp add: degree_add_leq) + show ?thesis using atLeastLessThanSuc_atLeastAtMost degree_sum f_def g_def h3 deg_def by auto +qed + + + +(*------------------------------------------------------------------------------------------------*) + +lemma quad_equality_helper : + assumes lLength : "length L > var" + assumes detGreat0 : "Cv\0" + assumes hC : "\x. insertion (nth_default 0 (list_update L var x)) (C::real mpoly) = (Cv::real)" + assumes hA : "\x. insertion (nth_default 0 (list_update L var x)) (A::real mpoly) = (Av::real)" + assumes hB : "\x. insertion (nth_default 0 (list_update L var x)) (B::real mpoly) = (Bv::real)" + shows "aEval (Eq (A + B * Var var)) (list_update L var (sqrt Cv)) = eval (And (Atom(Leq (A*B))) (Atom (Eq (A^2-B^2*C)))) (list_update L var (sqrt Cv))" +proof- + have h1 : "\x. insertion (nth_default 0 (list_update L var x)) (A^2-(B^2)*C) = Av^2-(Bv^2)*Cv" + by(simp add: hA hB hC insertion_add insertion_mult insertion_sub insertion_pow) + have h2a : "(Av + Bv * sqrt Cv = 0) = (Av = - Bv * sqrt Cv)" + by auto + have h2b : "(Av = - Bv * sqrt Cv) \ (Av^2 = (- Bv * sqrt Cv)^2)" + by simp + have h2c : "(Av^2 = (- Bv * sqrt Cv)^2) = (Av^2 = Bv^2 * (sqrt Cv)^2)" + by (simp add: power_mult_distrib) + have h2d : "(Av^2 = Bv^2 * (sqrt Cv)^2) = (Av^2 = Bv^2 * Cv)" + by (simp add: detGreat0) + have h2 : "(Av + Bv * sqrt Cv = 0) \ (Av^2 = Bv^2 * Cv)" + using h2a h2b h2c h2d by blast + have h3a : "(Av*Bv > 0) \ (Av + Bv * sqrt Cv \ 0)" + by (smt detGreat0 mult_nonneg_nonneg real_sqrt_ge_zero zero_less_mult_iff) + have h3 : "(Av + Bv * sqrt Cv = 0) \ (Av*Bv\ 0)" + using h3a by linarith + have h4 : "(Av * Bv \ 0 \ Av\<^sup>2 = Bv\<^sup>2 * Cv) \ (Av + Bv * sqrt Cv = 0)" + apply(cases "Av>0") + apply (metis detGreat0 h2a h2c h2d mult_minus_left not_le power2_eq_iff real_sqrt_lt_0_iff zero_less_mult_iff) + by (smt h2a real_sqrt_abs real_sqrt_mult zero_less_mult_iff) + show ?thesis + apply(simp add: hA hB h1 insertion_add insertion_mult insertion_var lLength) + using h2 h3 h4 by blast +qed + +lemma quadratic_sub_eq : + assumes lLength : "length L > var" + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update L var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) (d::real mpoly) = (Dv :: real)" + shows "aEval (Eq p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub var a b c d (Eq p)) (list_update L var (sqrt Cv))" +proof - + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Eq p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + have h3c : "MPoly_Type.degree p2 var = 0 \ MPoly_Type.degree p2 var = 1" + using freeC quad_part_2_deg p2_def by (meson le_neq_implies_less less_one) + have h3d : "MPoly_Type.degree p2 var = 0 \ B = 0" + by(simp add: B_def isovar_greater_degree) + then have h3f : "MPoly_Type.degree p2 var = 0 \ p2 = A + B * Var var" + by(simp add: h3d A_def degree0isovarspar) + have h3g1 : "MPoly_Type.degree p2 var = 1 \ p2 = (\i\1. isolate_variable_sparse p2 var i * Var var ^ i)" + using sum_over_zero by metis + have h3g2a : "\f. (\i::nat\1. f i) = f 0 + f 1" by simp + have h3g2 : "(\i::nat\1. isolate_variable_sparse p2 var i * Var var ^ i) = + isolate_variable_sparse p2 var 0 * Var var ^ 0 + isolate_variable_sparse p2 var 1 * Var var ^ 1" + using h3g2a by blast + have h3g : "MPoly_Type.degree p2 var = 1 \ p2 = A + B * Var var" + apply(simp add: sum_over_zero A_def B_def) + using h3g1 h3g2 + by (metis (no_types, lifting) One_nat_def mult_cancel_left2 power_0 power_one_right) + have h3h : "p2 = A + B * Var var" + using h3c h3f h3g by auto + + have h4a : "\x::real. \y::real. insertion (nth_default 0 (list_update L var y)) A = x" + using not_contains_insertion not_in_isovarspar A_def by blast + have h4b : "\x::real. \y::real. insertion (nth_default 0 (list_update L var y)) B = x" + using not_contains_insertion not_in_isovarspar B_def by blast + + + have "aEval (Eq p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = aEval (Eq p1) (list_update L var (sqrt Cv))" + using p1_def quad_part_1_eq nonzero ha hb hd lLength by blast + also have h2 : "... = aEval (Eq p2) (list_update L var (sqrt Cv))" + using p2_def quad_part_2_eq lLength detGreater0 hc by metis + also have "... = aEval (Eq (A + B * Var var)) (list_update L var (sqrt Cv))" + using h3h by auto + also have "... = eval (And (Atom(Leq (A*B))) (Atom (Eq (A^2-B^2*c)))) (list_update L var (sqrt Cv))" + using quad_equality_helper hc detGreater0 h4a h4b lLength by blast + also have "... = eval (quadratic_sub var a b c d (Eq p)) (list_update L var (sqrt Cv))" + using p2_def A_def B_def p1_def quadratic_sub.simps(1) by metis + finally show ?thesis by blast +qed + (*------------------------------------------------------------------------------------------------*) +lemma quadratic_sub_less_helper : + assumes lLength : "length L > var" + assumes detGreat0 : "Cv\0" + assumes hC : "\x. insertion (nth_default 0 (list_update L var x)) (C::real mpoly) = (Cv::real)" + assumes hA : "\x. insertion (nth_default 0 (list_update L var x)) (A::real mpoly) = (Av::real)" + assumes hB : "\x. insertion (nth_default 0 (list_update L var x)) (B::real mpoly) = (Bv::real)" + shows "aEval (Less (A + B * Var var)) (list_update L var (sqrt Cv)) = eval + (Or (And (fm.Atom (Less A)) (fm.Atom (Less (B\<^sup>2 * C - A\<^sup>2)))) + (And (fm.Atom (Leq B)) (Or (fm.Atom (Less A)) (fm.Atom (Less (A\<^sup>2 - B\<^sup>2 * C)))))) + (list_update L var (sqrt Cv)) " +proof- + have h1 : "\x. insertion (nth_default 0 (list_update L var x)) (A^2-(B^2)*C) = Av^2-(Bv^2)*Cv" + by(simp add: hA hB hC insertion_add insertion_mult insertion_sub insertion_pow) + have h2 : "\x. insertion (nth_default 0 (list_update L var x)) ((B^2)*C-A^2) = (Bv^2)*Cv-Av^2" + by(simp add: hA hB hC insertion_add insertion_mult insertion_sub insertion_pow) + have h3 : "Av=0 \ Bv=0 \ (Av + Bv * sqrt Cv < 0) = + (Av < 0 \ Bv\<^sup>2 * Cv < Av\<^sup>2 \ Bv \ 0 \ (Av < 0 \ Av\<^sup>2 < Bv\<^sup>2 * Cv))" + by simp + have h4 : "Av<0 \ Bv\0 \ (Av + Bv * sqrt Cv < 0) = + (Av < 0 \ Bv\<^sup>2 * Cv < Av\<^sup>2 \ Bv \ 0 \ (Av < 0 \ Av\<^sup>2 < Bv\<^sup>2 * Cv))" + by (metis add.right_neutral add_mono_thms_linordered_field(5) detGreat0 less_eq_real_def mult_less_0_iff mult_zero_class.mult_zero_left mult_zero_class.mult_zero_right real_sqrt_eq_zero_cancel_iff real_sqrt_gt_0_iff) + have h5a : "Av\0 \ Bv\0 \ (Av < -Bv * sqrt Cv) \ (Av\<^sup>2 < Bv\<^sup>2 * Cv)" + proof - + assume a1: "0 \ Av" + assume a2: "Av < - Bv * sqrt Cv" + assume "Bv \ 0" + then have "Av < sqrt (Cv * (Bv * Bv))" + using a2 by (simp add: mult.commute real_sqrt_mult) + then show ?thesis + using a1 by (metis (no_types) mult.commute power2_eq_square real_sqrt_less_iff real_sqrt_mult real_sqrt_pow2_iff) + qed + have h5b : "Av\0 \ Bv\0 \ (Av\<^sup>2 < Bv\<^sup>2 * Cv) \ (Av < -Bv * sqrt Cv)" + using real_less_rsqrt real_sqrt_mult by fastforce + have h5 : "Av\0 \ Bv\0 \ (Av + Bv * sqrt Cv < 0) = + (Av < 0 \ Bv\<^sup>2 * Cv < Av\<^sup>2 \ Bv \ 0 \ (Av < 0 \ Av\<^sup>2 < Bv\<^sup>2 * Cv))" + using h5a h5b by linarith + have h6 : "Av\0 \ Bv>0 \ (Av + Bv * sqrt Cv < 0) = + (Av < 0 \ Bv\<^sup>2 * Cv < Av\<^sup>2 \ Bv \ 0 \ (Av < 0 \ Av\<^sup>2 < Bv\<^sup>2 * Cv))" + by (smt detGreat0 mult_nonneg_nonneg real_sqrt_ge_zero) + have h7a : "Av<0 \ Bv>0 \ (Av < -Bv * sqrt Cv) \ (Bv\<^sup>2 * Cv < Av\<^sup>2)" + by (smt mult_minus_left real_sqrt_abs real_sqrt_le_mono real_sqrt_mult) + have h7b : "Av<0 \ Bv>0 \ (Bv\<^sup>2 * Cv < Av\<^sup>2) \ (Av < -Bv * sqrt Cv)" + by (metis abs_of_nonneg abs_real_def add.commute less_eq_real_def mult.assoc mult_minus_left power2_eq_square real_add_less_0_iff real_sqrt_less_iff real_sqrt_mult real_sqrt_mult_self) + have h7 : "Av<0 \ Bv>0 \ (Av + Bv * sqrt Cv < 0) = + (Av < 0 \ Bv\<^sup>2 * Cv < Av\<^sup>2 \ Bv \ 0 \ (Av < 0 \ Av\<^sup>2 < Bv\<^sup>2 * Cv))" + using h7a h7b by linarith + show ?thesis + apply(simp add: hA hB h1 h2 insertion_add insertion_mult insertion_var lLength) + using h3 h4 h5 h6 h7 by smt +qed + +lemma quadratic_sub_less : + assumes lLength : "length L > var" + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update L var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) (d::real mpoly) = (Dv :: real)" + shows "aEval (Less p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub var a b c d (Less p)) (list_update L var (sqrt Cv))" +proof - + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Less p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + + have h3b : "MPoly_Type.degree p2 var \ 1" + using freeC quad_part_2_deg p2_def by blast + then have h3c : "MPoly_Type.degree p2 var = 0 \ MPoly_Type.degree p2 var = 1" + by auto + have h3d : "MPoly_Type.degree p2 var = 0 \ B = 0" + by(simp add: B_def isovar_greater_degree) + then have h3f : "MPoly_Type.degree p2 var = 0 \ p2 = A + B * Var var" + by(simp add: h3d A_def degree0isovarspar) + have h3g1 : "MPoly_Type.degree p2 var = 1 \ p2 = (\i\1. isolate_variable_sparse p2 var i * Var var ^ i)" + using sum_over_zero by metis + have h3g2a : "\f. (\i::nat\1. f i) = f 0 + f 1" by simp + have h3g2 : "(\i::nat\1. isolate_variable_sparse p2 var i * Var var ^ i) = + isolate_variable_sparse p2 var 0 * Var var ^ 0 + isolate_variable_sparse p2 var 1 * Var var ^ 1" + using h3g2a by blast + have h3g : "MPoly_Type.degree p2 var = 1 \ p2 = A + B * Var var" + apply(simp add: sum_over_zero A_def B_def) + using h3g1 h3g2 + by (metis (no_types, lifting) One_nat_def mult_cancel_left2 power_0 power_one_right) + have h3h : "p2 = A + B * Var var" + using h3c h3f h3g by auto + + have h4a : "\x::real. \y::real. insertion (nth_default 0(list_update L var y)) A = x" + using not_contains_insertion not_in_isovarspar A_def by blast + have h4b : "\x::real. \y::real. insertion (nth_default 0(list_update L var y)) B = x" + using not_contains_insertion not_in_isovarspar B_def by blast + + have h1 : "aEval (Less p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = aEval (Less (quadratic_part_1 var a b d (Less p))) (list_update L var (sqrt Cv))" + using quad_part_1_less assms by blast + also have "... = aEval (Less p1) (list_update L var (sqrt Cv))" + using p1_def by auto + also have "... = aEval (Less (quadratic_part_2 var c p1)) (list_update L var (sqrt Cv))" + using quad_part_2_less assms by blast + also have "... = aEval (Less p2) (list_update L var (sqrt Cv))" + using p2_def by auto + also have "... = aEval (Less (A + B * Var var)) (list_update L var (sqrt Cv))" + using h3h by auto + also have "... = eval + (Or (And (fm.Atom (Less A)) (fm.Atom (Less (B\<^sup>2 * c - A\<^sup>2)))) + (And (fm.Atom (Leq B)) (Or (fm.Atom (Less A)) (fm.Atom (Less (A\<^sup>2 - B\<^sup>2 * c)))))) + (list_update L var (sqrt Cv))" + using quadratic_sub_less_helper hc detGreater0 h4a h4b lLength by blast + also have "... = eval (quadratic_sub var a b c d (Less p)) (list_update L var (sqrt Cv))" + using p2_def A_def B_def p1_def quadratic_sub.simps(2) by metis + finally show ?thesis by blast +qed + +(*------------------------------------------------------------------------------------------------*) +lemma quadratic_sub_leq_helper : + assumes lLength : "length L > var" + assumes detGreat0 : "Cv\0" + assumes hC : "\x. insertion (nth_default 0 (list_update L var x)) (C::real mpoly) = (Cv::real)" + assumes hA : "\x. insertion (nth_default 0 (list_update L var x)) (A::real mpoly) = (Av::real)" + assumes hB : "\x. insertion (nth_default 0 (list_update L var x)) (B::real mpoly) = (Bv::real)" + shows "aEval (Leq (A + B * Var var)) (list_update L var (sqrt Cv)) = + eval (Or(And(Atom(Leq(A)))(Atom (Leq(B^2*C-A^2))))(And (Atom(Leq B)) (Atom(Leq (A^2-B^2*C))))) (list_update L var (sqrt Cv))" +proof- + have h1 : "\x. insertion (nth_default 0 (list_update L var x)) (A^2-(B^2)*C) = Av^2-(Bv^2)*Cv" + by(simp add: hA hB hC insertion_add insertion_mult insertion_sub insertion_pow) + have h2 : "\x. insertion (nth_default 0 (list_update L var x)) ((B^2)*C-A^2) = (Bv^2)*Cv-Av^2" + by(simp add: hA hB hC insertion_add insertion_mult insertion_sub insertion_pow) + have h3 : "Av=0 \ Bv=0 \ (Av + Bv * sqrt Cv \ 0) = (Av \ 0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ Bv \ 0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv)" + by simp + have h4 : "Av<0 \ Bv\0 \ (Av + Bv * sqrt Cv \ 0) = (Av \ 0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ Bv \ 0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv)" + by (smt detGreat0 real_sqrt_ge_zero zero_less_mult_iff) + have h5 : "Av=0 \ Bv\0 \ (Av + Bv * sqrt Cv \ 0) = (Av \ 0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ Bv \ 0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv)" + by (smt detGreat0 real_sqrt_ge_zero zero_less_mult_iff) + have h6 : "Av\0 \ Bv>0 \ (Av + Bv * sqrt Cv \ 0) = (Av \ 0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ Bv \ 0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv)" + by (smt detGreat0 mult_nonneg_nonneg mult_pos_pos real_sqrt_gt_0_iff real_sqrt_zero zero_le_power2 zero_less_mult_pos zero_less_power2) + have h7a : "Av<0 \ Bv>0 \ (Av + Bv * sqrt Cv \ 0) \ Bv\<^sup>2 * Cv \ Av\<^sup>2" + by (smt real_sqrt_abs real_sqrt_less_mono real_sqrt_mult) + have h7b : "Av<0 \ Bv>0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ (Av + Bv * sqrt Cv \ 0) " + by (smt real_sqrt_abs real_sqrt_less_mono real_sqrt_mult) + have h7 : "Av<0 \ Bv>0 \ (Av + Bv * sqrt Cv \ 0) = (Av \ 0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ Bv \ 0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv)" + using h7a h7b by linarith + have h8c : "(-Bv * sqrt Cv)^2 = Bv\<^sup>2 * Cv" + by (simp add: detGreat0 power_mult_distrib) + have h8a : "Av>0 \ Bv\0 \ (Av \ -Bv * sqrt Cv) \ Av\<^sup>2 \ Bv\<^sup>2 * Cv" + using detGreat0 h8c power_both_sides by smt + have h8b : "Av>0 \ Bv\0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv \ (Av + Bv * sqrt Cv \ 0) " + using detGreat0 h8c power_both_sides + by (smt mult_minus_left real_sqrt_ge_zero zero_less_mult_iff) + have h8 : "Av>0 \ Bv\0 \ (Av + Bv * sqrt Cv \ 0) = (Av \ 0 \ Bv\<^sup>2 * Cv \ Av\<^sup>2 \ Bv \ 0 \ Av\<^sup>2 \ Bv\<^sup>2 * Cv)" + using h8a h8b by linarith + show ?thesis + apply(simp add: hA hB h1 h2 insertion_add insertion_mult insertion_var lLength) + using h3 h4 h5 h6 h7 h8 by smt +qed + +lemma quadratic_sub_leq : + assumes lLength : "length L > var" + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update L var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) (d::real mpoly) = (Dv :: real)" + shows "aEval (Leq p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub var a b c d (Leq p)) (list_update L var (sqrt Cv))" +proof - + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Leq p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + + have h3b : "MPoly_Type.degree p2 var \ 1" + using freeC quad_part_2_deg p2_def lLength by metis + then have h3c : "MPoly_Type.degree p2 var = 0 \ MPoly_Type.degree p2 var = 1" + by auto + have h3d : "MPoly_Type.degree p2 var = 0 \ B = 0" + by(simp add: B_def isovar_greater_degree) + then have h3f : "MPoly_Type.degree p2 var = 0 \ p2 = A + B * Var var" + by(simp add: h3d A_def degree0isovarspar) + have h3g1 : "MPoly_Type.degree p2 var = 1 \ p2 = (\i\1. isolate_variable_sparse p2 var i * Var var ^ i)" + using sum_over_zero by metis + have h3g2a : "\f. (\i::nat\1. f i) = f 0 + f 1" by simp + have h3g2 : "(\i::nat\1. isolate_variable_sparse p2 var i * Var var ^ i) = + isolate_variable_sparse p2 var 0 * Var var ^ 0 + isolate_variable_sparse p2 var 1 * Var var ^ 1" + using h3g2a by blast + have h3g : "MPoly_Type.degree p2 var = 1 \ p2 = A + B * Var var" + apply(simp add: sum_over_zero A_def B_def) + using h3g1 h3g2 + by (metis (no_types, lifting) One_nat_def mult_cancel_left2 power_0 power_one_right) + have h3h : "p2 = A + B * Var var" + using h3c h3f h3g by auto + + have h4a : "\x::real. \y::real. insertion (nth_default 0 (list_update L var y)) A = x" + using not_contains_insertion not_in_isovarspar A_def by blast + have h4b : "\x::real. \y::real. insertion (nth_default 0 (list_update L var y)) B = x" + using not_contains_insertion not_in_isovarspar B_def by blast + + have "aEval (Leq p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = aEval (Leq p1) (list_update L var (sqrt Cv))" + using quad_part_1_leq nonzero ha hb hd p1_def lLength by metis + also have "... = aEval (Leq p2) (list_update L var (sqrt Cv))" + using p2_def quad_part_2_leq hc detGreater0 lLength by metis + also have "... = aEval (Leq (A + B * Var var)) (list_update L var (sqrt Cv))" + using h3h by auto + also have h4 : "... = eval + (Or + (And + (Atom(Leq(A))) + (Atom (Leq(B^2*c-A^2)))) + (And + (Atom(Leq B)) + (Atom(Leq (A^2-B^2*c))))) + (list_update L var (sqrt Cv))" + using quadratic_sub_leq_helper hc detGreater0 h4a h4b lLength by blast + also have "... = eval (quadratic_sub var a b c d (Leq p)) (list_update L var (sqrt Cv))" + using p1_def quadratic_sub.simps(3) p2_def A_def B_def by metis + finally show ?thesis by blast +qed + (*------------------------------------------------------------------------------------------------*) +lemma quadratic_sub_neq : + assumes lLength : "length L > var" + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update L var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) (d::real mpoly) = (Dv :: real)" + shows "aEval (Neq p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub var a b c d (Neq p)) (list_update L var (sqrt Cv))" +proof - + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Neq p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + + have h3b : "MPoly_Type.degree p2 var \ 1" + using freeC quad_part_2_deg p2_def lLength by metis + then have h3c : "MPoly_Type.degree p2 var = 0 \ MPoly_Type.degree p2 var = 1" + by auto + have h3d : "MPoly_Type.degree p2 var = 0 \ B = 0" + by(simp add: B_def isovar_greater_degree) + then have h3f : "MPoly_Type.degree p2 var = 0 \ p2 = A + B * Var var" + by(simp add: h3d A_def degree0isovarspar) + have h3g1 : "MPoly_Type.degree p2 var = 1 \ p2 = (\i\1. isolate_variable_sparse p2 var i * Var var ^ i)" + using sum_over_zero by metis + have h3g2a : "\f. (\i::nat\1. f i) = f 0 + f 1" by simp + have h3g2 : "(\i::nat\1. isolate_variable_sparse p2 var i * Var var ^ i) = + isolate_variable_sparse p2 var 0 * Var var ^ 0 + isolate_variable_sparse p2 var 1 * Var var ^ 1" + using h3g2a by blast + have h3g : "MPoly_Type.degree p2 var = 1 \ p2 = A + B * Var var" + apply(simp add: sum_over_zero A_def B_def) + using h3g1 h3g2 + by (metis (no_types, lifting) One_nat_def mult_cancel_left2 power_0 power_one_right) + have h3h : "p2 = A + B * Var var" + using h3c h3f h3g by auto + + have h4a : "\x::real. \y::real. insertion (nth_default 0 (list_update L var y)) A = x" + using not_contains_insertion not_in_isovarspar A_def by blast + have h4b : "\x::real. \y::real. insertion (nth_default 0 (list_update L var y)) B = x" + using not_contains_insertion not_in_isovarspar B_def by blast + have h4c : "aEval (Eq (A + B * Var var)) (list_update L var (sqrt Cv)) + = eval (And (Atom(Leq (A*B))) (Atom (Eq (A^2-B^2*c)))) (list_update L var (sqrt Cv))" + using quad_equality_helper hc detGreater0 h4a h4b lLength by blast + have h4d : "aEval (Neq (A + B * Var var)) (list_update L var (sqrt Cv)) + = (\ (eval (And (Atom(Leq (A*B))) (Atom (Eq (A^2-B^2*c)))) (list_update L var (sqrt Cv))))" + using aEval.simps(1) aEval.simps(4) h4c by blast + have h4e : "(\ (eval (And (Atom(Leq (A*B))) (Atom (Eq (A^2-B^2*c)))) (list_update L var (sqrt Cv)))) + = eval (Or (Atom(Less(-A*B))) (Atom (Neq(A^2-B^2*c)))) (list_update L var (sqrt Cv))" + by (metis aNeg.simps(2) aNeg.simps(3) aNeg_aEval eval.simps(1) eval.simps(4) eval.simps(5) mult_minus_left) + + have "aEval (Neq p) (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = aEval (Neq p1) (list_update L var (sqrt Cv))" + using quad_part_1_neq nonzero ha hb hd p1_def lLength by blast + also have "... = aEval (Neq p2) (list_update L var (sqrt Cv))" + using p2_def quad_part_2_neq hc detGreater0 lLength by metis + also have "... = aEval (Neq (A + B * Var var)) (list_update L var (sqrt Cv))" + using h3h by auto + also have "... = eval (Or + (Atom(Less(-A*B))) + (Atom (Neq(A^2-B^2*c)))) (list_update L var (sqrt Cv))" + using h4c h4d h4e by auto + also have "... = eval (quadratic_sub var a b c d (Neq p)) (list_update L var (sqrt Cv))" + using p2_def A_def B_def p1_def quadratic_sub.simps(4) quadratic_part_1.simps(1) quadratic_part_1.simps(4) + by (metis (no_types, lifting)) + finally show ?thesis by blast +qed + (*-----------------------------------------------------------------------------------------------*) +theorem free_in_quad : + assumes freeA : "var\ vars a" + assumes freeB : "var\ vars b" + assumes freeC : "var\ vars c" + assumes freeD : "var\ vars d" + shows "freeIn var (quadratic_sub var a b c d A)" +proof(cases A) + case (Less p) + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Less p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + have h1 : "freeIn var (quadratic_sub var a b c d (Less p)) = freeIn var (Or (And (fm.Atom (Less A)) (fm.Atom (Less (B\<^sup>2 * c - A\<^sup>2)))) + (And (fm.Atom (Leq B)) (Or (fm.Atom (Less A)) (fm.Atom (Less (A\<^sup>2 - B\<^sup>2 * c))))))" + using p2_def A_def B_def p1_def quadratic_sub.simps(2) by metis + have h2d : "var\vars(4::real mpoly)" + by (metis freeB not_in_add not_in_pow numeral_Bit0 one_add_one power_0) + have h2 : "freeIn var ((Or (And (fm.Atom (Less A)) (fm.Atom (Less (B\<^sup>2 * c - A\<^sup>2)))) + (And (fm.Atom (Leq B)) (Or (fm.Atom (Less A)) (fm.Atom (Less (A\<^sup>2 - B\<^sup>2 * c)))))))" + using vars_mult not_in_isovarspar A_def B_def not_in_sub not_in_mult not_in_neg not_in_pow not_in_isovarspar h2d freeC + by (simp) + show ?thesis using h1 h2 Less by blast +next + case (Eq p) + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Eq p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + have h1 : "freeIn var (quadratic_sub var a b c d (Eq p)) = freeIn var (And (Atom(Leq (A*B))) (Atom (Eq (A\<^sup>2 - B\<^sup>2 * c))))" + using p2_def A_def B_def p1_def quadratic_sub.simps(1) by metis + have h2d : "var\vars(4::real mpoly)" + by (metis freeB not_in_add not_in_pow numeral_Bit0 one_add_one power_0) + have h2 : "freeIn var (And (Atom(Leq (A*B))) (Atom (Eq (A\<^sup>2 - B\<^sup>2 * c))))" + using vars_mult not_in_isovarspar A_def B_def not_in_sub not_in_mult not_in_neg not_in_pow not_in_isovarspar h2d freeC + by (simp) + show ?thesis using h1 h2 Eq by blast +next + case (Leq p) + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Leq p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + have h1 : "freeIn var (quadratic_sub var a b c d (Leq p)) = freeIn var (Or(And(Atom(Leq(A)))(Atom (Leq(B^2*c-A^2))))(And(Atom(Leq B))(Atom(Leq (A^2-B^2*c)))))" + using p2_def A_def B_def p1_def quadratic_sub.simps(3) by metis + have h2d : "var\vars(4::real mpoly)" + by (metis freeB not_in_add not_in_pow numeral_Bit0 one_add_one power_0) + have h2 : "freeIn var (Or(And(Atom(Leq(A)))(Atom (Leq(B^2*c-A^2))))(And(Atom(Leq B))(Atom(Leq (A^2-B^2*c)))))" + using vars_mult not_in_isovarspar A_def B_def not_in_sub not_in_mult not_in_neg not_in_pow not_in_isovarspar h2d freeC + by (simp) + show ?thesis using h1 h2 Leq by blast +next + case (Neq p) + define p1 where "(p1::real mpoly) = quadratic_part_1 var a b d (Neq p)" + define p2 where "(p2::real mpoly) = quadratic_part_2 var c p1" + define A where "A = isolate_variable_sparse p2 var 0" + define B where "B = isolate_variable_sparse p2 var 1" + have h1 : "freeIn var (quadratic_sub var a b c d (Neq p)) = freeIn var (Or (Atom(Less(-A*B))) (Atom (Neq(A^2-B^2*c))))" + using p2_def A_def B_def p1_def quadratic_sub.simps(4) by metis + have h2d : "var\vars(4::real mpoly)" + by (metis freeB not_in_add not_in_pow numeral_Bit0 one_add_one power_0) + have h2 : "freeIn var (Or (Atom(Less(-A*B))) (Atom (Neq(A^2-B^2*c))))" + using vars_mult not_in_isovarspar A_def B_def not_in_sub not_in_mult not_in_neg not_in_pow not_in_isovarspar h2d freeC + by (simp) + show ?thesis using h1 h2 Neq by blast +qed + +theorem quadratic_sub : + assumes lLength : "length L > var" + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update L var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) (d::real mpoly) = (Dv :: real)" + shows "aEval A (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub var a b c d A) (list_update L var (sqrt Cv))" +proof(cases A) + case (Less x1) + then show ?thesis using quadratic_sub_less assms by blast +next + case (Eq x2) + then show ?thesis using quadratic_sub_eq assms by blast +next + case (Leq x3) + then show ?thesis using quadratic_sub_leq assms by blast +next + case (Neq x4) + then show ?thesis using quadratic_sub_neq assms by blast +qed + + + + +lemma free_in_quad_fm_helper : + assumes freeA : "var\ vars a" + assumes freeB : "var\ vars b" + assumes freeC : "var\ vars c" + assumes freeD : "var\ vars d" + shows "freeIn (var+z) (quadratic_sub_fm_helper var a b c d F z)" +proof(induction F arbitrary: z) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom x) + then show ?case using free_in_quad[OF not_in_lift[OF assms(1)] not_in_lift[OF assms(2)] not_in_lift[OF assms(3)] not_in_lift[OF assms(4)], of z] by auto +next + case (And F1 F2) + then show ?case by auto +next + case (Or F1 F2) + then show ?case by auto +next + case (Neg F) + then show ?case by auto +next + case (ExQ F) + show ?case using ExQ[of "z+1"] by simp +next + case (AllQ F) + show ?case using AllQ[of "z+1"] by simp +next + case (ExN x1 F) + then show ?case + by (metis (no_types, lifting) add.assoc freeIn.simps(13) liftmap.simps(10) quadratic_sub_fm_helper.simps) +next + case (AllN x1 F) + then show ?case + by (metis (no_types, lifting) freeIn.simps(12) group_cancel.add1 liftmap.simps(9) quadratic_sub_fm_helper.simps) +qed + +theorem free_in_quad_fm : + assumes freeA : "var\ vars a" + assumes freeB : "var\ vars b" + assumes freeC : "var\ vars c" + assumes freeD : "var\ vars d" + shows "freeIn var (quadratic_sub_fm var a b c d A)" + using free_in_quad_fm_helper[OF assms, of 0] by auto + + + +lemma quadratic_sub_fm_helper : + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes lLength : "length L > var+z" + assumes ha : "\x. insertion (nth_default 0 (list_update (drop z L) var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update (drop z L) var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update (drop z L) var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update (drop z L) var x)) (d::real mpoly) = (Dv :: real)" + shows "eval F (list_update L (var+z) ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub_fm_helper var a b c d F z) (list_update L (var+z) (sqrt Cv))" + using assms proof(induction F arbitrary: z L) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom x) + define L1 where "L1 = drop z L" + define L2 where "L2 = take z L" + have L_def : "L = L2 @ L1" using L1_def L2_def by auto + have lengthl2 : "length L2 = z" using L2_def + using Atom.prems(4) by auto + have "eval (Atom(Eq (a-Const Av))) ([] @ L1) = eval (liftFm 0 z (Atom(Eq (a- Const Av)))) ([] @ L2 @ L1)" + by (metis eval_liftFm_helper lengthl2 list.size(3)) + then have "(insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z (a - Const Av)) = 0)" + apply(simp add: insertion_sub insertion_const) + using Atom(5) unfolding L1_def + by (metis list_update_id) + then have "insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z a) = Av" + using lift_minus by blast + then have a1 : "\x. insertion (nth_default 0 (L[var + z := x])) (liftPoly 0 z a) = Av" + unfolding L_def + by (metis (no_types, lifting) Atom.prems(5) L1_def add.right_neutral add_diff_cancel_right' append_eq_append_conv append_eq_append_conv2 length_append lengthl2 lift_insertion list.size(3) list_update_append not_add_less2) + have "eval (Atom(Eq (b-Const Bv))) ([] @ L1) = eval (liftFm 0 z (Atom(Eq (b- Const Bv)))) ([] @ L2 @ L1)" + by (metis eval_liftFm_helper lengthl2 list.size(3)) + then have "(insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z (b - Const Bv)) = 0)" + apply(simp add: insertion_sub insertion_const) + using Atom(6) unfolding L1_def + by (metis list_update_id) + then have "insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z b) = Bv" + using lift_minus by blast + then have a2 : "\x. insertion (nth_default 0 (L[var + z := x])) (liftPoly 0 z b) = Bv" + unfolding L_def using Atom(6) L1_def + by (metis L_def add_diff_cancel_right' append.simps(1) lengthl2 lift_insertion list.size(3) list_update_append not_add_less2) + have "eval (Atom(Eq (c-Const Cv))) ([] @ L1) = eval (liftFm 0 z (Atom(Eq (c- Const Cv)))) ([] @ L2 @ L1)" + by (metis eval_liftFm_helper lengthl2 list.size(3)) + then have "(insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z (c - Const Cv)) = 0)" + apply(simp add: insertion_sub insertion_const) + using Atom(7) unfolding L1_def + by (metis list_update_id) + then have "insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) = Cv" + using lift_minus by blast + then have a3 : "\x. insertion (nth_default 0 (L[var + z := x])) (liftPoly 0 z c) = Cv" + unfolding L_def + proof - + obtain nn :: "(nat \ real) \ (nat \ real) \ real mpoly \ nat" where + "\x0 x1 x2. (\v3. v3 \ vars x2 \ x1 v3 \ x0 v3) = (nn x0 x1 x2 \ vars x2 \ x1 (nn x0 x1 x2) \ x0 (nn x0 x1 x2))" + by moura + then have f1: "\m f fa. nn fa f m \ vars m \ f (nn fa f m) \ fa (nn fa f m) \ insertion f m = insertion fa m" + by (meson insertion_irrelevant_vars) + obtain rr :: real where + "(\v0. insertion (nth_default 0 ((L2 @ L1)[var + z := v0])) (liftPoly 0 z c) \ Cv) = (insertion (nth_default 0 ((L2 @ L1)[var + z := rr])) (liftPoly 0 z c) \ Cv)" + by blast + moreover + { assume "var + z \ nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)" + moreover + { assume "(nth_default 0 (L2 @ L1) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)) = nth_default 0 ((L2 @ L1)[var + z := rr]) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c))) \ ((L2 @ L1) ! nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) = (L2 @ L1)[var + z := rr] ! nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c))" + then have "nth_default 0 ((L2 @ L1)[var + z := rr]) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)) \ (L2 @ L1)[var + z := rr] ! nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) \ nth_default 0 (L2 @ L1) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)) \ (L2 @ L1) ! nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)" + by linarith + then have "nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) \ vars (liftPoly 0 z c) \ nth_default 0 (L2 @ L1) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)) = nth_default 0 ((L2 @ L1)[var + z := rr]) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c))" + by (metis (no_types) append_Nil2 length_list_update nth_default_append) } + ultimately have "nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) \ vars (liftPoly 0 z c) \ nth_default 0 (L2 @ L1) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c)) = nth_default 0 ((L2 @ L1)[var + z := rr]) (nn (nth_default 0 ((L2 @ L1)[var + z := rr])) (nth_default 0 (L2 @ L1)) (liftPoly 0 z c))" + by force } + ultimately show "\r. insertion (nth_default 0 ((L2 @ L1)[var + z := r])) (liftPoly 0 z c) = Cv" + using f1 by (metis (full_types) Atom.prems(3) \insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z c) = Cv\ not_in_lift) + qed + have "eval (Atom(Eq (d-Const Dv))) ([] @ L1) = eval (liftFm 0 z (Atom(Eq (d- Const Dv)))) ([] @ L2 @ L1)" + by (metis eval_liftFm_helper lengthl2 list.size(3)) + then have "(insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z (d - Const Dv)) = 0)" + apply(simp add: insertion_sub insertion_const) + using Atom(8) unfolding L1_def + by (metis list_update_id) + then have "insertion (nth_default 0 (L2 @ L1)) (liftPoly 0 z d) = Dv" + using lift_minus by blast + then have a4 : "\x. insertion (nth_default 0 (L[var + z := x])) (liftPoly 0 z d) = Dv" + unfolding L_def + by (metis Atom(8) L1_def L_def add_diff_cancel_right' append.simps(1) lengthl2 lift_insertion list.size(3) list_update_append not_add_less2) + then show ?case apply(simp) + using quadratic_sub[OF Atom(4) Atom(1) Atom(2) not_in_lift[OF Atom(3)], of "(liftPoly 0 z a)" Av "(liftPoly 0 z b)" Bv "(liftPoly 0 z d)" x + , OF a1 a2 a3 a4] . +next + case (And F1 F2) + then show ?case by auto +next + case (Or F1 F2) + then show ?case by auto +next + case (Neg F) + then show ?case by auto +next + case (ExQ F) + have lengthG : "var + (z + 1) < length (x#L)" for x using ExQ(5) by auto + have forall : "\x. insertion (nth_default 0 ((drop z L)[var := x])) a = Av \ + \x. insertion (nth_default 0 ((drop (z + 1) (x1 # L))[var := x])) a = Av" for x1 a Av + by auto + have l : "x # L[var + z := v] = ((x#L)[var+(z+1):=v])" for x v + by auto + have "eval (ExQ F) (L[var + z := (Av + Bv * sqrt Cv) / Dv]) = + (\x. eval F (x # L[var + z := (Av + Bv * sqrt Cv) / Dv]))" + by(simp) + also have "... = (\x. eval + (liftmap + (\x. quadratic_sub (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) + F (z + 1)) + (x # L[var + z := sqrt Cv]))" + apply(rule ex_cong1) + unfolding l + using ExQ(1)[OF ExQ(2) ExQ(3) ExQ(4) lengthG forall[OF ExQ(6)] forall[OF ExQ(7)] forall[OF ExQ(8)] forall[OF ExQ(9)]] + unfolding quadratic_sub_fm_helper.simps liftmap.simps + by simp + also have "... = eval (quadratic_sub_fm_helper var a b c d (ExQ F) z) (L[var + z := sqrt Cv])" + unfolding quadratic_sub_fm_helper.simps liftmap.simps eval.simps by auto + finally show ?case by simp +next + case (AllQ F) + have lengthG : "var + (z + 1) < length (x#L)" for x using AllQ(5) by auto + have forall : "\x. insertion (nth_default 0 ((drop z L)[var := x])) a = Av \ + \x. insertion (nth_default 0 ((drop (z + 1) (x1 # L))[var := x])) a = Av" for x1 a Av + by auto + have l : "x # L[var + z := v] = ((x#L)[var+(z+1):=v])" for x v + by auto + have "eval (AllQ F) (L[var + z := (Av + Bv * sqrt Cv) / Dv]) = + (\x. eval F (x # L[var + z := (Av + Bv * sqrt Cv) / Dv]))" + by(simp) + also have "... = (\x. eval + (liftmap + (\x. quadratic_sub (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) + F (z + 1)) + (x # L[var + z := sqrt Cv]))" + apply(rule all_cong1) + unfolding l + using AllQ(1)[OF AllQ(2) AllQ(3) AllQ(4) lengthG forall[OF AllQ(6)] forall[OF AllQ(7)] forall[OF AllQ(8)] forall[OF AllQ(9)]] + unfolding quadratic_sub_fm_helper.simps liftmap.simps + by simp + also have "... = eval (quadratic_sub_fm_helper var a b c d (AllQ F) z) (L[var + z := sqrt Cv])" + unfolding quadratic_sub_fm_helper.simps liftmap.simps eval.simps by auto + finally show ?case by simp +next + case (ExN x1 F) + have list : "\l. length l=x1 \ ((drop (z + x1) l @ drop (z + x1 - length l) L)) = ((drop z L))" + by auto + have map : "\ z L. eval (liftmap (\x A. (quadratic_sub (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d) A)) F (z + x1)) + L = eval (liftmap (\x A. (quadratic_sub (var + x1 + x) (liftPoly 0 (x+x1) a) (liftPoly 0 (x+x1) b) (liftPoly 0 (x+x1) c) (liftPoly 0 (x+x1) d) A)) F z) + L" + apply(induction F) apply(simp_all add:add.commute add.left_commute) + apply force + apply force + by (metis (mono_tags, lifting) ab_semigroup_add_class.add_ac(1))+ + show ?case apply simp apply(rule ex_cong1) + subgoal for l + using map[of z] list[of l] ExN(1)[OF ExN(2-4), of "z+x1" "l@L"] ExN(5-9) list_update_append + apply auto + by (simp add: list_update_append) + + done +next + case (AllN x1 F) + have list : "\l. length l=x1 \ ((drop (z + x1) l @ drop (z + x1 - length l) L)) = ((drop z L))" + by auto + have map : "\ z L. eval (liftmap (\x A. (quadratic_sub (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d) A)) F (z + x1)) + L = eval (liftmap (\x A. (quadratic_sub (var + x1 + x) (liftPoly 0 (x+x1) a) (liftPoly 0 (x+x1) b) (liftPoly 0 (x+x1) c) (liftPoly 0 (x+x1) d) A)) F z) + L" + apply(induction F) apply(simp_all add:add.commute add.left_commute) + apply force + apply force + by (metis (mono_tags, lifting) ab_semigroup_add_class.add_ac(1))+ + show ?case apply simp apply(rule all_cong1) + subgoal for l + using map[of z] list[of l] AllN(1)[OF AllN(2-4), of "z+x1" "l@L"] AllN(5-9) + apply auto + by (simp add: list_update_append) + + done +qed + +theorem quadratic_sub_fm : + assumes lLength : "length L > var" + assumes nonzero : "Dv \ 0" + assumes detGreater0 : "Cv \ 0" + assumes freeC : "var \ vars c" + assumes ha : "\x. insertion (nth_default 0 (list_update L var x)) (a::real mpoly) = (Av :: real)" + assumes hb : "\x. insertion (nth_default 0 (list_update L var x)) (b::real mpoly) = (Bv :: real)" + assumes hc : "\x. insertion (nth_default 0 (list_update L var x)) (c::real mpoly) = (Cv :: real)" + assumes hd : "\x. insertion (nth_default 0 (list_update L var x)) (d::real mpoly) = (Dv :: real)" + shows "eval F (list_update L var ((Av+Bv*sqrt(Cv))/Dv)) = eval (quadratic_sub_fm var a b c d F) (list_update L var (sqrt Cv))" + unfolding quadratic_sub_fm.simps using quadratic_sub_fm_helper[OF assms(2) assms(3) assms(4), of 0 L a Av b Bv d F] assms(1) assms(5) assms(6) assms(7) assms(8) + by (simp add: lLength) +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/README.txt b/thys/Virtual_Substitution/README.txt new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/README.txt @@ -0,0 +1,94 @@ +------------ +Quadratic Virtual Substitution Formalization +----------- + +********** Isabelle File Organization ********** + +Here is a quick summary from top to down of all the files + +Exports: + Creates an SML export of the developed algorithms for testing purposes + +VSQuad: + Provides the overarching algorithms to ramp up the VS procedure throughout the +whole formula from inside to outside + +Unpower: + Simplifies polynomials by factoring out zero roots, simplification algorithm + +PushForall: + Simplification algorithm which pushes forall statements inwards in a formula + +ClearQuantifiers: + Clears the successfully eliminated quantifiers after performing QE + +SimpFm: + Simplifies fully computed formulas by evaluation constant polynomials + +GeneralVSProofs: + Proofs associated with verifying the GeneralVS algorithm and its +univariate counterpart + +DNFUni: + Disjunctive Normal Form algorithm for univariate polynomials and associated +proofs + +QE: + Main lemmas for univarate quantifier elimination for quadratic polynomials, +proofs not necessarily dependant on the framework + +InfinitesimalsUni: + Univariate functions for the infinitesimal virtual substitution and associated +proofs + +EqualityVS: + Proofs for the equality virtual substitution procedure + +LuckyFind: + Optimization which quickly finds a nonzero root to eliminate the quantifier quickly + +EliminateVariable: + Substitution procedure which calls all other procedures for linear and quadratic +roots + +Infinitesimals: + Function for computing infinitesimal virtual substitution + +QuadraticCase: + Quadratic equality substitution case of virtual substitution + +NegInfinityUni: + Univariate version of negative infinity virtual substitution and associated +proofs + +NegInfinity: + Negative infinity virtual substitution + +UniAtoms: + Univariate formulation of atoms + +LinearCase: + Linear case of equality virtual substitution + +DNF: + Algorithm which splits up the formula into DNF form, while trying to maximize +the information content + +Debrujin: + Lifting and lowering of indices in polynomials to formalize DeBrujin indices + +UsefulLemmas: + Collection of miscellaneous lemmas used in several proofs + +NNF: + negation normal form and associated proofs + +PolyAtoms: + Formalization of real-arithmetic formulas + +FunWithPoly: + creation of polynomial code theorems and some proofs + +PrettyPrinting: + Helpful printing function for polynomials + diff --git a/thys/Virtual_Substitution/ROOT b/thys/Virtual_Substitution/ROOT new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/ROOT @@ -0,0 +1,47 @@ +chapter AFP + +session Virtual_Substitution (AFP) = "HOL-Analysis" + + options [timeout = 1200] + sessions + "Polynomials" + theories + QE + + MPolyExtension + ExecutiblePolyProps + + PolyAtoms + + Debruijn + Reindex + + Optimizations + OptimizationProofs + + VSAlgos + Heuristic + Exports + + LinearCase + QuadraticCase + EliminateVariable + LuckyFind + EqualityVS + + UniAtoms + NegInfinity + NegInfinityUni + Infinitesimals + InfinitesimalsUni + DNFUni + GeneralVSProofs + + DNF + VSQuad + HeuristicProofs + ExportProofs + theories [document = false] + PrettyPrinting + document_files + "root.tex" + "root.bib" \ No newline at end of file diff --git a/thys/Virtual_Substitution/Reindex.thy b/thys/Virtual_Substitution/Reindex.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/Reindex.thy @@ -0,0 +1,322 @@ +subsection "Swapping Indicies" +theory Reindex + imports Debruijn +begin + +context includes poly_mapping.lifting begin + +definition "swap i j x = (if x = i then j else if x = j then i else x)" + +lemma swap_swap : "swap i j (swap i j x) = x" + unfolding swap_def by auto + + +lemma finite_swap_ne: "finite {x. f x \ c} \ finite {x. f (swap b i x) \ c}" +proof - + assume finset: "finite {x. f x \ c}" + let ?A = "{x. f x \ c}" + let ?B = "{x. f (swap b i x) \ c}" + have finsubset: "finite (?A - {i, b})" using finset by auto + have sames: "(?A - {i, b}) = (?B - {i, b})" + unfolding swap_def by auto + then have "finite (?B - {i, b})" + using finsubset by auto + then have finBset: "finite ((?B - {i, b}) \ {i, b})" by auto + then have "?B \ ((?B - {i, b}) \ {i, b})" by auto + then show ?thesis using finBset by auto +qed + +lift_definition swap0::"nat \ nat \ (nat \\<^sub>0 'a) \ (nat \\<^sub>0 'a::zero)" + is "\b i p x. p (swap b i x)::'a" +proof - + fix b i::nat and p::"nat \ 'a" + assume "finite {x. p x \ 0}" + then have "finite {x. p (swap b i x) \ 0}" + by (rule finite_swap_ne) + from _ this show "finite {x. p (swap b i x) \ 0}" + by (rule finite_subset) auto +qed + +lemma swap0_swap0: "swap0 n i (swap0 n i x) = x" + by transfer (force simp: swap_def) + +lemma inj_swap: "inj (swap b i)" + using swap_swap + by (rule inj_on_inverseI) + +lemma inj_swap0: "inj (swap0 b i)" + using swap0_swap0 + by (rule inj_on_inverseI) + + +lemma swap0_eq: "lookup (swap0 b i p) x = lookup p (swap b i x)" + by (simp_all add: swap0.rep_eq) + +lemma eq_onp_swap : "eq_onp (\f. finite {x. f x \ 0}) (\x. lookup m (swap b i x)) + (\x. lookup m (swap b i x))" + unfolding eq_onp_def apply simp + apply(rule finite_swap_ne) + by auto + +lemma keys_swap: "keys (swap0 b i m) = swap b i ` keys m" + apply safe + subgoal for x + unfolding swap0_def apply simp + unfolding keys.abs_eq[OF eq_onp_swap] + by (metis (mono_tags, lifting) Reindex.swap_swap image_eqI lookupNotIn mem_Collect_eq) + subgoal for x y + unfolding swap0_def apply simp + unfolding keys.abs_eq[OF eq_onp_swap] + by (metis (mono_tags, lifting) Reindex.swap_swap lookup_eq_zero_in_keys_contradict mem_Collect_eq) + done + + +context includes fmap.lifting begin + +lift_definition swap\<^sub>f::"nat \ nat \ (nat, 'a) fmap \ (nat, 'a::zero) fmap" + is "\b i p x. p (swap b i x)" +proof - + fix b i::nat and p::"nat \ 'a option" + assume "finite (dom p)" + then have "finite {x. p x \ None}" by (simp add: dom_def) + + have "dom (\x. p (swap b i x)) = {x. p (swap b i x) \ None}" + by auto + also have "finite \" + by (rule finite_swap_ne) fact + finally + have "finite (dom (\x. p (swap b i x)))" . + from _ this + show "finite (dom (\x. p (swap b i x)))" + by (rule finite_subset) (auto split: if_splits) +qed + + +lemma compute_swap\<^sub>f[code]: "swap\<^sub>f b i (fmap_of_list xs) = + fmap_of_list (map (\(k, v). (swap b i k, v)) xs)" +proof - + have *: "map_of (map (\(k, y). (swap b i k, y)) (xs)) x = + map_of xs (swap b i x)" + for x + apply (rule map_of_map_key_inverse_fun_eq) + unfolding swap_swap by auto + show ?thesis + unfolding swap\<^sub>f_def apply simp + unfolding fmlookup_of_list + unfolding Finite_Map.fmap_of_list.abs_eq + using map_of_map_key_inverse_fun_eq[where f="swap b i", where g="swap b i", where xs=xs] + unfolding swap_swap + apply simp + by presburger +qed + +lemma compute_swap[code]: "swap0 n i (Pm_fmap xs) = Pm_fmap (swap\<^sub>f n i xs)" + apply(rule poly_mapping_eqI) + by (auto simp: swap\<^sub>f.rep_eq swap0.rep_eq fmlookup_default_def swap_def + split: option.splits) + +lift_definition swapPoly\<^sub>0::"nat \ nat \ ((nat\\<^sub>0nat)\\<^sub>0'a::zero) \ ((nat\\<^sub>0nat)\\<^sub>0 'a)" is + "\b i (mp::(nat\\<^sub>0nat)\'a) mon. mp (swap0 b i mon)" +proof - + fix b i and mp::"(nat \\<^sub>0 nat) \ 'a" + assume "finite {x. mp x \ 0}" + have "{x. mp (swap0 b i x) \ 0} = (swap0 b i -` {x. mp x \ 0})" + (is "?set = ?vimage") + by auto + also + from finite_vimageI[OF \finite _\ inj_swap0] + have "finite ?vimage" . + finally show "finite ?set" . +qed + +lemma swap_zero[simp]: "swap0 b i 0 = 0" + by transfer auto + + +context includes fmap.lifting begin + +lift_definition swapPoly\<^sub>f::"nat \ nat \ ((nat\\<^sub>0nat), 'a::zero)fmap \ ((nat\\<^sub>0nat), 'a)fmap" is + "\b i (mp::((nat\\<^sub>0nat)\'a)) mon::(nat\\<^sub>0nat). mp (swap0 b i mon)" +proof -\ \TODO: this is exactly the same proof as the one for \lowerPoly\<^sub>0\\ + fix b i and mp::"(nat \\<^sub>0 nat) \ 'a option" + assume "finite (dom mp)" + also have "dom mp = {x. mp x \ None}" by auto + finally have "finite {x. mp x \ None}" . + have "(dom (\mon. mp (swap0 b i mon))) = {mon. mp (swap0 b i mon) \ None}" + (is "?set = _") + by (auto split: if_splits) + also have "\ = swap0 b i -` {x. mp x \ None}" (is "_ = ?vimage") + by auto + also + from finite_vimageI[OF \finite {x. mp x \ None}\ inj_swap0] + have "finite ?vimage" . + finally show "finite ?set" . +qed + + +lemma keys_swap\<^sub>0: "keys (swapPoly\<^sub>0 b i mp) = swap0 b i ` (keys mp)" + apply (auto ) + subgoal for x + apply (rule image_eqI[where x="swap0 b i x"]) + by (auto simp: swap0_swap0 in_keys_iff swapPoly\<^sub>0.rep_eq) + subgoal for x + apply (auto simp: in_keys_iff swapPoly\<^sub>0.rep_eq) + by (simp add: swap0_swap0) + done + +end + +lemma compute_swapPoly\<^sub>0[code]: "swapPoly\<^sub>0 n i (Pm_fmap m) = Pm_fmap (swapPoly\<^sub>f n i m)" + by (auto simp: swapPoly\<^sub>0.rep_eq fmlookup_default_def swapPoly\<^sub>f.rep_eq + split: option.splits + intro!: poly_mapping_eqI) + +lemma compute_swapPoly\<^sub>f[code]: "swapPoly\<^sub>f n i (fmap_of_list xs) = + (fmap_of_list (map (\(mon, c). (swap0 n i mon, c)) + xs))" + apply (rule sym) + apply (rule fmap_ext) + unfolding swapPoly\<^sub>f.rep_eq fmlookup_of_list + apply (subst map_of_map_key_inverse_fun_eq[where g="swap0 n i"]) + unfolding swap0_swap0 by auto + +end +end + +lift_definition swap_poly::"nat \ nat \ 'a::zero mpoly \ 'a mpoly" is swapPoly\<^sub>0 . + +value "swap_poly 0 1 (Var 0 :: real mpoly)" + +lemma coeff_swap_poly: "MPoly_Type.coeff (swap_poly b i mp) x = MPoly_Type.coeff mp (swap0 b i x)" + by (transfer') (simp add: swapPoly\<^sub>0.rep_eq) + +lemma monomials_swap_poly: "monomials (swap_poly b i mp) = swap0 b i ` (monomials mp) " + by transfer' (simp add: keys_swap\<^sub>0) + +fun swap_atom :: "nat \ nat \ atom \ atom" where + "swap_atom a b (Eq p) = Eq (swap_poly a b p)"| + "swap_atom a b (Less p) = Less (swap_poly a b p)"| + "swap_atom a b (Leq p) = Leq (swap_poly a b p)"| + "swap_atom a b (Neq p) = Neq (swap_poly a b p)" + +fun swap_fm :: "nat \ nat \ atom fm \ atom fm" where + "swap_fm a b TrueF = TrueF"| + "swap_fm a b FalseF = FalseF"| + "swap_fm a b (Atom At) = Atom(swap_atom a b At)"| + "swap_fm a b (And A B) = And(swap_fm a b A)(swap_fm a b B)"| + "swap_fm a b (Or A B) = Or(swap_fm a b A)(swap_fm a b B)"| + "swap_fm a b (Neg A) = Neg(swap_fm a b A)"| + "swap_fm a b (ExQ A) = ExQ(swap_fm (a+1) (b+1) A)"| + "swap_fm a b (AllQ A) = AllQ(swap_fm (a+1) (b+1) A)"| + "swap_fm a b (ExN i A) = ExN i (swap_fm (a+i) (b+i) A)"| + "swap_fm a b (AllN i A) = AllN i (swap_fm (a+i) (b+i) A)" + +fun swap_list :: "nat \ nat \ 'a list \ 'a list"where + "swap_list i j l = l[j := nth l i, i := nth l j]" + +lemma swap_list_cons: "swap_list (Suc a) (Suc b) (x # L) = x # swap_list a b L" + by auto + +lemma inj_on : "inj_on (swap0 a b) (monomials p)" + unfolding inj_on_def + by (metis swap0_swap0) + +lemma inj_on' : "inj_on (swap a b) (keys m)" + unfolding inj_on_def + by (meson Reindex.inj_swap injD) + +lemma swap_list : + assumes "a < length L" + assumes "b < length L" + shows "nth_default 0 (L[b := L ! a, a := L ! b]) (swap a b xa) = nth_default 0 L xa" + using assms unfolding swap_def apply auto + apply (simp_all add: nth_default_nth) + by (simp add: nth_default_def) + +lemma swap_poly : + assumes "length L > a" + assumes "length L > b" + shows "insertion (nth_default 0 L) p = insertion (nth_default 0 (swap_list a b L)) (swap_poly a b p)" + unfolding insertion_code apply auto + unfolding monomials.abs_eq + unfolding coeff_swap_poly monomials_swap_poly apply auto + unfolding Groups_Big.comm_monoid_add_class.sum.reindex[OF inj_on] apply simp + unfolding swap0_swap0 + unfolding keys_swap + unfolding Groups_Big.comm_monoid_mult_class.prod.reindex[OF inj_on'] + apply simp + unfolding swap0_eq swap_swap swap_list[OF assms] by auto + +lemma swap_fm : + assumes "length L > a" + assumes "length L > b" + shows "eval F L = eval (swap_fm a b F) (swap_list a b L)" + using assms proof(induction F arbitrary: a b L) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom At) + then show ?case apply(cases At) using swap_poly[OF Atom(1) Atom(2)] by auto +next + case (And F1 F2) + show ?case using And(1)[OF And(3-4)] And(2)[OF And(3-4)] by auto +next + case (Or F1 F2) + then show ?case using Or(1)[OF Or(3-4)] Or(2)[OF Or(3-4)] by auto +next + case (Neg F) + then show ?case using Neg(1)[OF Neg(2-3)] by auto +next + case (ExQ F) + show ?case apply simp + apply(rule ex_cong1) + subgoal for x + using ExQ(1)[of "Suc a" "x#L" "Suc b"] unfolding swap_list_cons using ExQ(2-3) by simp + done +next + case (AllQ F) + then show ?case apply simp + apply(rule all_cong1) + subgoal for x + using AllQ(1)[of "Suc a" "x#L" "Suc b"] unfolding swap_list_cons using AllQ(2-3) by simp + done +next + case (ExN i F) + show ?case + apply simp + apply(rule ex_cong1) + subgoal for l + using ExN(1)[of "a+i" "l@L" "b+i"] + by (smt (verit, del_insts) ExN.prems(1) ExN.prems(2) add.commute add_diff_cancel_right' add_less_cancel_left length_append list_update_append not_add_less2 nth_append swap_list.elims) + done +next + case (AllN i F) + then show ?case + apply simp apply(rule all_cong1) + by (smt (z3) add.commute add_diff_cancel_right' le_add2 length_append less_diff_conv2 list_update_append not_add_less2 nth_append) +qed + +lemma "eval (ExQ (ExQ F)) L = eval (ExQ (ExQ (swap_fm 0 1 F))) L" + apply simp + apply safe + subgoal for i j + apply(rule exI[where x=j]) + apply(rule exI[where x=i]) + using swap_fm[of 0 "j # i # L" "Suc 0" F] + by simp + subgoal for i j + apply(rule exI[where x=j]) + apply(rule exI[where x=i]) + using swap_fm[of 0 "i # j # L" "Suc 0" F] + by simp + done + +lemma swap_atom: + assumes "length L > a" + assumes "length L > b" + shows "aEval F L = aEval (swap_atom a b F) (swap_list a b L)" + using swap_fm[OF assms, of "Atom F"] by auto +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/UniAtoms.thy b/thys/Virtual_Substitution/UniAtoms.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/UniAtoms.thy @@ -0,0 +1,467 @@ +section "General VS Proofs" +subsection "Univariate Atoms" +theory UniAtoms + imports Debruijn +begin + +datatype atomUni = LessUni "real * real * real" | EqUni "real * real * real" | LeqUni "real * real * real" | NeqUni "real * real * real" +datatype (atoms: 'a) fmUni = + TrueFUni | FalseFUni | AtomUni 'a | AndUni "'a fmUni" "'a fmUni" | OrUni "'a fmUni" "'a fmUni" + +fun aEvalUni :: "atomUni \ real \ bool" where + "aEvalUni (EqUni (a,b,c)) x = (a*x^2+b*x+c = 0)" | + "aEvalUni (LessUni (a,b,c)) x = (a*x^2+b*x+c < 0)" | + "aEvalUni (LeqUni (a,b,c)) x = (a*x^2+b*x+c \ 0)" | + "aEvalUni (NeqUni (a,b,c)) x = (a*x^2+b*x+c \ 0)" + +fun aNegUni :: "atomUni \ atomUni" where + "aNegUni (LessUni (a,b,c)) = LeqUni (-a,-b,-c)" | + "aNegUni (EqUni p) = NeqUni p" | + "aNegUni (LeqUni (a,b,c)) = LessUni (-a,-b,-c)" | + "aNegUni (NeqUni p) = EqUni p" + + +fun evalUni :: "atomUni fmUni \ real \ bool" where + "evalUni (AtomUni a) x = aEvalUni a x" | + "evalUni (TrueFUni) _ = True" | + "evalUni (FalseFUni) _ = False" | + "evalUni (AndUni \ \) x = ((evalUni \ x) \ (evalUni \ x))" | + "evalUni (OrUni \ \) x = ((evalUni \ x) \ (evalUni \ x))" + + +fun negUni :: "atomUni fmUni \ atomUni fmUni" where + "negUni (AtomUni a) = AtomUni(aNegUni a)" | + "negUni (TrueFUni) = FalseFUni" | + "negUni (FalseFUni) = TrueFUni" | + "negUni (AndUni \ \) = (OrUni (negUni \) (negUni \))" | + "negUni (OrUni \ \) = (AndUni (negUni \) (negUni \))" + +fun convert_poly :: "nat \ real mpoly \ real list \ (real * real * real) option" where + "convert_poly var p xs = ( + if MPoly_Type.degree p var < 3 + then let (A,B,C) = get_coeffs var p in Some(insertion (nth_default 0 (xs)) A,insertion (nth_default 0 (xs)) B,insertion (nth_default 0 (xs)) C) + else None)" + +fun convert_atom :: "nat \ atom \ real list \ atomUni option" where + "convert_atom var (Less p) xs = map_option LessUni (convert_poly var p xs)"| + "convert_atom var (Eq p) xs = map_option EqUni (convert_poly var p xs)"| + "convert_atom var (Leq p) xs = map_option LeqUni (convert_poly var p xs)"| + "convert_atom var (Neq p) xs = map_option NeqUni (convert_poly var p xs)" + +lemma convert_atom_change : + assumes "length xs' = var" + shows "convert_atom var At (xs' @ x # \) = convert_atom var At (xs' @ x' # \)" + apply(cases At)using assms apply simp_all + by (metis insertion_lowerPoly1 not_in_isovarspar)+ + +lemma degree_convert_eq : + assumes "convert_poly var p xs = Some(a)" + shows "MPoly_Type.degree p var < 3" + using assms apply(cases "MPoly_Type.degree p var < 3") by auto + +lemma poly_to_univar : + assumes "MPoly_Type.degree p var < 3" + assumes "get_coeffs var p = (A,B,C)" + assumes "a = insertion (nth_default 0 (xs'@y#xs)) A" + assumes "b = insertion (nth_default 0 (xs'@y#xs)) B" + assumes "c = insertion (nth_default 0 (xs'@y#xs)) C" + assumes "length xs' = var" + shows "insertion (nth_default 0 (xs'@x#xs)) p = (a*x^2)+(b*x)+c" +proof- + have ha: "\x. a = insertion (nth_default 0 (xs'@x # xs)) A" using assms(2) apply auto + by (metis assms(3) assms(6) insertion_lowerPoly1 not_in_isovarspar) + have hb: "\x. b = insertion (nth_default 0 (xs'@x # xs)) B" using assms(2) apply auto + by (metis assms(4) assms(6) insertion_lowerPoly1 not_in_isovarspar) + have hc: "\x. c = insertion (nth_default 0 (xs'@x # xs)) C" using assms(2) apply auto + by (metis assms(5) assms(6) insertion_lowerPoly1 not_in_isovarspar) + show ?thesis + proof(cases "MPoly_Type.degree p var = 0") + case True + have h1 : "var < length (xs'@x#xs)" using assms by auto + show ?thesis using assms ha hb hc sum_over_degree_insertion[OF h1 True, of y] apply(simp add: isovar_greater_degree[of p ] True) + using True degree0isovarspar by force + next + case False + then have notzero : "MPoly_Type.degree p var \ 0" by auto + show ?thesis proof(cases "MPoly_Type.degree p var = 1" ) + case True + have h1 : "var < length (xs'@x#xs)" using assms by auto + show ?thesis using sum_over_degree_insertion[OF h1 True, of x, symmetric] unfolding assms(6)[symmetric] list_update_length unfolding assms(6) apply simp using ha hb hc assms apply auto + by (smt (verit, ccfv_threshold) One_nat_def True express_poly h1 insertion_add insertion_mult insertion_pow insertion_var list_update_length) + next + case False + then have deg2 : "MPoly_Type.degree p var = 2" using notzero assms by auto + have h1 : "var < length (xs'@x#xs)" using assms by auto + have two : "2 = Suc(Suc 0)" by auto + show ?thesis + using sum_over_degree_insertion[OF h1 deg2, of x, symmetric] unfolding assms(6)[symmetric] list_update_length unfolding assms(6) two apply simp using ha hb hc assms apply auto + using deg2 express_poly h1 insertion_add insertion_mult insertion_pow insertion_var list_update_length + by (smt (verit, best) numeral_2_eq_2) + qed + qed +qed + +lemma "aEval_aEvalUni": + assumes "convert_atom var a (xs'@x#xs) = Some a'" + assumes "length xs' = var" + shows "aEval a (xs'@x#xs) = aEvalUni a' x" +proof(cases a) + case (Less x) + then show ?thesis + proof(cases "MPoly_Type.degree x var < 3") + case True + then show ?thesis + using assms apply(simp add:Less) + using poly_to_univar[OF True] + by (metis One_nat_def aEvalUni.simps(2) get_coeffs.elims) + next + case False + then show ?thesis using assms Less by auto + qed +next + case (Eq x) + then show ?thesis + proof(cases "MPoly_Type.degree x var < 3") + case True + then show ?thesis + using assms apply(simp add:Eq) + using poly_to_univar[OF True] + by (metis One_nat_def aEvalUni.simps(1) get_coeffs.elims) + next + case False + then show ?thesis using assms Eq by auto + qed +next + case (Leq x) + then show ?thesis + proof(cases "MPoly_Type.degree x var < 3") + case True + then show ?thesis + using assms apply(simp add:Leq) + using poly_to_univar[OF True] + by (metis One_nat_def aEvalUni.simps(3) get_coeffs.elims) + next + case False + then show ?thesis using assms Leq by auto + qed +next + case (Neq x) + then show ?thesis + proof(cases "MPoly_Type.degree x var < 3") + case True + then show ?thesis + using assms apply(simp add:Neq) + using poly_to_univar[OF True] + by (metis One_nat_def aEvalUni.simps(4) get_coeffs.elims) + next + case False + then show ?thesis using assms Neq by auto + qed +qed + + +fun convert_fm :: "nat \ atom fm \ real list \ (atomUni fmUni) option" where + "convert_fm var (Atom a) \ = map_option (AtomUni) (convert_atom var a \)" | + "convert_fm var (TrueF) _ = Some TrueFUni" | + "convert_fm var (FalseF) _ = Some FalseFUni" | + "convert_fm var (And \ \) \ = (case ((convert_fm var \ \),(convert_fm var \ \)) of (Some a, Some b) \ Some (AndUni a b) | _ \ None)" | + "convert_fm var (Or \ \) \ = (case ((convert_fm var \ \),(convert_fm var \ \)) of (Some a, Some b) \ Some (OrUni a b) | _ \ None)" | + "convert_fm var (Neg \) \ = None " | + "convert_fm var (ExQ \) \ = None" | + "convert_fm var (AllQ \) \ = None"| + "convert_fm var (AllN i \) \ = None"| + "convert_fm var (ExN i \) \ = None" + + +lemma "eval_evalUni": + assumes "convert_fm var F (xs'@x#xs) = Some F'" + assumes "length xs' = var" + shows "eval F (xs'@x#xs) = evalUni F' x" + using assms +proof(induction F arbitrary: F') + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom x) + then show ?case using aEval_aEvalUni by auto +next + case (And F1 F2) + then show ?case apply(cases "convert_fm var F1 (xs'@x#xs)") apply simp apply(cases "convert_fm var F2 (xs'@x#xs)") by auto +next + case (Or F1 F2) + then show ?case apply(cases "convert_fm var F1 (xs'@x#xs)") apply simp apply(cases "convert_fm var F2 (xs'@x#xs)") by auto +next + case (Neg F) + then show ?case by auto +next + case (ExQ F) + then show ?case by auto +next + case (AllQ F) + then show ?case by auto +next + case (ExN x1 \) + then show ?case by auto +next + case (AllN x1 \) + then show ?case by auto +qed + +fun grab_atoms :: "nat \ atom fm \ atom list option" where + "grab_atoms var TrueF = Some([])" | + "grab_atoms var FalseF = Some([])" | + "grab_atoms var (Atom(Eq p)) = (if MPoly_Type.degree p var < 3 then (if MPoly_Type.degree p var > 0 then Some([Eq p]) else Some([])) else None)"| + "grab_atoms var (Atom(Less p)) = (if MPoly_Type.degree p var < 3 then (if MPoly_Type.degree p var > 0 then Some([Less p]) else Some([])) else None)"| + "grab_atoms var (Atom(Leq p)) = (if MPoly_Type.degree p var < 3 then (if MPoly_Type.degree p var > 0 then Some([Leq p]) else Some([])) else None)"| + "grab_atoms var (Atom(Neq p)) = (if MPoly_Type.degree p var < 3 then (if MPoly_Type.degree p var > 0 then Some([Neq p]) else Some([])) else None)"| + "grab_atoms var (And a b) = ( +case grab_atoms var a of + Some(al) \ ( + case grab_atoms var b of + Some(bl) \ Some(al@bl) + | None \ None + ) +| None \ None +)"| + "grab_atoms var (Or a b) = ( +case grab_atoms var a of + Some(al) \ ( + case grab_atoms var b of + Some(bl) \ Some(al@bl) + | None \ None + ) +| None \ None +)"| + +"grab_atoms var (Neg _) = None"| +"grab_atoms var (ExQ _) = None"| +"grab_atoms var (AllQ _) = None"| +"grab_atoms var (AllN i _) = None"| +"grab_atoms var (ExN i _) = None" + + + +lemma nil_grab : "(grab_atoms var F = Some []) \ (freeIn var F)" +proof(induction F) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom x) + then show ?case proof(cases x) + case (Less p) + then show ?thesis using Atom apply(cases "MPoly_Type.degree p var < 3") apply auto apply(cases "MPoly_Type.degree p var > 0") apply auto + using degree0isovarspar not_in_isovarspar by blast + next + case (Eq p) + then show ?thesis using Atom apply(cases "MPoly_Type.degree p var < 3") apply auto apply(cases "MPoly_Type.degree p var > 0") apply auto + using degree0isovarspar not_in_isovarspar by blast + next + case (Leq p) + then show ?thesis using Atom apply(cases "MPoly_Type.degree p var < 3") apply auto apply(cases "MPoly_Type.degree p var > 0") apply auto + using degree0isovarspar not_in_isovarspar by blast + next + case (Neq p) + then show ?thesis using Atom apply(cases "MPoly_Type.degree p var < 3") apply auto apply(cases "MPoly_Type.degree p var > 0") apply auto + using degree0isovarspar not_in_isovarspar by blast + qed +next + case (And F1 F2) + then show ?case apply(cases "grab_atoms var F1") + apply(cases "grab_atoms var F2") apply(auto) + apply(cases "grab_atoms var F2") apply(auto) + apply(cases "grab_atoms var F2") by(auto) +next + case (Or F1 F2) + then show ?case apply(cases "grab_atoms var F1") + apply(cases "grab_atoms var F2") apply(auto) + apply(cases "grab_atoms var F2") apply(auto) + apply(cases "grab_atoms var F2") by(auto) +next + case (Neg F) + then show ?case by auto +next + case (ExQ F) + then show ?case by auto +next + case (AllQ F) + then show ?case by auto +next + case (ExN x1 F) + then show ?case by auto +next + case (AllN x1 F) + then show ?case by auto +qed + +fun isSome :: "'a option \ bool" where + "isSome (Some _) = True" | + "isSome None = False" + +lemma "grab_atoms_convert" : "(isSome (grab_atoms var F)) = (isSome (convert_fm var F xs))" +proof(induction F) + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom a) + then show ?case apply(cases a) by auto +next + case (And F1 F2) + then show ?case + by (smt convert_fm.simps(4) grab_atoms.simps(7) isSome.elims(2) isSome.elims(3) option.distinct(1) option.simps(5) option.split_sel_asm prod.simps(2)) +next + case (Or F1 F2) + then show ?case + by (smt convert_fm.simps(5) grab_atoms.simps(8) isSome.elims(2) isSome.elims(3) option.distinct(1) option.simps(5) option.split_sel_asm prod.simps(2)) +next + case (Neg F) + then show ?case by auto +next + case (ExQ F) + then show ?case by auto +next + case (AllQ F) + then show ?case by auto +next + case (ExN x1 F) + then show ?case by auto +next + case (AllN x1 F) + then show ?case by auto +qed + +lemma convert_aNeg : + assumes "convert_atom var A (xs'@x#xs) = Some(A')" + assumes "length xs' = var" + shows "aEval (aNeg A) (xs'@x#xs) = aEvalUni (aNegUni A') x" +proof- + have "aEval (aNeg A) (xs'@x#xs) = (\ aEval A (xs'@x#xs))" + using aNeg_aEval[of A "(xs'@x#xs)"] by auto + also have "... = (\ aEvalUni A' x)" + using assms aEval_aEvalUni by auto + also have "... = aEvalUni (aNegUni A') x" + by(cases A')(auto) + finally show ?thesis . +qed + +lemma convert_neg : + assumes "convert_fm var F (xs'@x#xs) = Some(F')" + assumes "length xs' = var" + shows "eval (Neg F) (xs'@x#xs) = evalUni (negUni F') x" + using assms +proof(induction F arbitrary:F') + case TrueF + then show ?case by auto +next + case FalseF + then show ?case by auto +next + case (Atom p) + then show ?case + using convert_aNeg[of _ p] + by (smt aNeg_aEval convert_fm.simps(1) evalUni.simps(1) eval.simps(1) eval.simps(6) map_option_eq_Some negUni.simps(1)) +next + case (And F1 F2) + then show ?case apply auto + apply (metis (no_types, lifting) evalUni.simps(5) negUni.simps(4) option.case_eq_if option.collapse option.distinct(1) option.sel) + apply (smt (verit, del_insts) evalUni.simps(5) isSome.elims(1) negUni.simps(4) option.inject option.simps(4) option.simps(5)) + by (smt (verit, del_insts) evalUni.simps(5) isSome.elims(1) negUni.simps(4) option.inject option.simps(4) option.simps(5)) +next + case (Or F1 F2) + then show ?case apply auto + apply (smt (verit, del_insts) evalUni.simps(4) isSome.elims(1) negUni.simps(5) option.inject option.simps(4) option.simps(5)) + apply (smt (verit, del_insts) evalUni.simps(4) isSome.elims(1) negUni.simps(5) option.inject option.simps(4) option.simps(5)) + by (smt (verit, del_insts) evalUni.simps(4) isSome.elims(1) negUni.simps(5) option.inject option.simps(4) option.simps(5)) +next + case (Neg F) + then show ?case by auto +next + case (ExQ F) + then show ?case by auto +next + case (AllQ F) + then show ?case by auto +next + case (ExN x1 F) + then show ?case by auto +next + case (AllN x1 F) + then show ?case by auto +qed + + +fun list_disj_Uni :: "'a fmUni list \ 'a fmUni" where + "list_disj_Uni [] = FalseFUni"| + "list_disj_Uni (x#xs) = OrUni x (list_disj_Uni xs)" + +fun list_conj_Uni :: "'a fmUni list \ 'a fmUni" where + "list_conj_Uni [] = TrueFUni"| + "list_conj_Uni (x#xs) = AndUni x (list_conj_Uni xs)" + +lemma eval_list_disj_Uni : "evalUni (list_disj_Uni L) x = (\l\set(L). evalUni l x)" + by(induction L)(auto) + +lemma eval_list_conj_Uni : "evalUni (list_conj_Uni A) x = (\l\set A. evalUni l x)" + apply(induction A)by auto + +lemma eval_list_conj_Uni_append : "evalUni (list_conj_Uni (A @ B)) x = (evalUni (list_conj_Uni (A)) x \ evalUni (list_conj_Uni (B)) x)" + apply(induction A)by auto + +fun map_atomUni :: "('a \ 'a fmUni) \ 'a fmUni \ 'a fmUni" where + "map_atomUni f (AtomUni a) = f a" | + "map_atomUni f (TrueFUni) = TrueFUni" | + "map_atomUni f (FalseFUni) = FalseFUni" | + "map_atomUni f (AndUni \ \) = (AndUni (map_atomUni f \) (map_atomUni f \))" | + "map_atomUni f (OrUni \ \) = (OrUni (map_atomUni f \) (map_atomUni f \))" + +fun map_atom :: "(atom \ atom fm) \ atom fm \ atom fm" where + "map_atom f TrueF = TrueF"| + "map_atom f FalseF = FalseF"| + "map_atom f (Atom a) = f a"| + "map_atom f (And \ \) = And (map_atom f \) (map_atom f \)"| + "map_atom f (Or \ \) = Or (map_atom f \) (map_atom f \)"| + "map_atom f (Neg \) = TrueF"| + "map_atom f (ExQ \) = TrueF"| + "map_atom f (AllQ \) = TrueF"| + "map_atom f (ExN i \) = TrueF"| + "map_atom f (AllN i \) = TrueF" + +fun getPoly :: "atomUni => real * real * real" where + "getPoly (EqUni p) = p"| + "getPoly (LeqUni p) = p"| + "getPoly (NeqUni p) = p"| + "getPoly (LessUni p) = p" + +lemma liftatom_map_atom : + assumes "\F'. convert_fm var F xs = Some F'" + shows "liftmap f F 0 = map_atom (f 0) F" + using assms + apply(induction F) + apply(auto) + apply fastforce + apply (metis (no_types, lifting) isSome.elims(2) isSome.elims(3) option.case_eq_if) + apply fastforce + by (metis (no_types, lifting) isSome.elims(2) isSome.elims(3) option.case_eq_if) + + +lemma eval_map : "(\l\set(map f L). evalUni l x) = (\l\set(L). evalUni (f l) x)" + by auto + +lemma eval_map_all : "(\l\set(map f L). evalUni l x) = (\l\set(L). evalUni (f l) x)" + by auto + +lemma eval_append : "(\l\set (A#B).evalUni l x) = (evalUni A x \ (\l\set (B).evalUni l x))" + by auto + +lemma eval_conj_atom : "evalUni (list_conj_Uni (map AtomUni L)) x = (\l\set(L). aEvalUni l x)" + unfolding eval_list_conj_Uni + by auto +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/VSAlgos.thy b/thys/Virtual_Substitution/VSAlgos.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/VSAlgos.thy @@ -0,0 +1,552 @@ +section "Algorithms" +subsection "Equality VS Helper Functions" +theory VSAlgos + imports Debruijn Optimizations +begin + + +text "This is a subprocess which simply separates out the equality atoms from the other kinds of atoms + +Note that we search for equality atoms that are of degree one or two + +This is used within the equalityVS algorithm" +fun find_eq :: "nat \ atom list \ real mpoly list * atom list" where + "find_eq var [] = ([],[])"| + "find_eq var ((Less p)#as) = (let (A,B) = find_eq var as in (A,Less p#B))" | + "find_eq var ((Eq p)#as) = (let (A,B) = find_eq var as in + if MPoly_Type.degree p var < 3 \ MPoly_Type.degree p var \ 0 + then (p # A,B) + else (A,Eq p # B) +)"| + "find_eq var ((Leq p)#as) = (let (A,B) = find_eq var as in (A,Leq p#B))" | + "find_eq var ((Neq p)#as) = (let (A,B) = find_eq var as in (A,Neq p#B))" + + + + +(* given ax^2+bx+c returns formula representing a=0 and b=0 and c=0 *) +fun split_p :: "nat \ real mpoly \ atom fm" where + "split_p var p = And (Atom (Eq (isolate_variable_sparse p var 2))) + (And (Atom (Eq (isolate_variable_sparse p var 1))) + (Atom (Eq (isolate_variable_sparse p var 0))))" + + + +text " +The linearsubstitution virtually substitutes in an equation of $b*x+c=0$ into an arbitrary atom + +linearsubstitution x b c (Eq p) = F corresponds to removing variable x from polynomial p and replacing +it with an equivalent function F where F doesn't mention variable x + +If there exists a way to assign variables that makes p = 0 true, +then that same set of variables will make F true + +If there exists a way to assign variables that makes F true and also have b*x+c=0, +then that same set of variables will make p=0 true + +Same applies for other kinds of atoms that aren't equality +" +fun linear_substitution :: "nat \ real mpoly \ real mpoly \ atom \ atom" where + "linear_substitution var a b (Eq p) = + (let d = MPoly_Type.degree p var in + (Eq (\i\{0..<(d+1)}. isolate_variable_sparse p var i * (a^i) * (b^(d-i)))) + )" | + "linear_substitution var a b (Less p) = + (let d = MPoly_Type.degree p var in + let P = (\i\{0..<(d+1)}. isolate_variable_sparse p var i * (a^i) * (b^(d-i))) in + (Less(P * (b ^ (d mod 2)))) + )"| + "linear_substitution var a b (Leq p) = + (let d = MPoly_Type.degree p var in + let P = (\i\{0..<(d+1)}. isolate_variable_sparse p var i * (a^i) * (b^(d-i))) in + (Leq(P * (b ^ (d mod 2)))) + )"| + "linear_substitution var a b (Neq p) = + (let d = MPoly_Type.degree p var in + (Neq (\i\{0..<(d+1)}. isolate_variable_sparse p var i * (a^i) * (b^(d-i)))) + )" + +fun linear_substitution_fm_helper :: "nat \ real mpoly \ real mpoly \ atom fm \ nat \ atom fm" where + "linear_substitution_fm_helper var b c F z = liftmap (\x.\A. Atom(linear_substitution (var+x) (liftPoly 0 x b) (liftPoly 0 x c) A)) F z" + +fun linear_substitution_fm :: "nat \ real mpoly \ real mpoly \ atom fm \ atom fm" where + "linear_substitution_fm var b c F = linear_substitution_fm_helper var b c F 0" + + +text " +quadraticpart1 var a b A takes in an expression of the form +(a+b * sqrt(c))/d +for an arbitrary c and substitutes it in for the variable var in the atom A +" +fun quadratic_part_1 :: "nat \ real mpoly \ real mpoly \ real mpoly \ atom \ real mpoly" where + "quadratic_part_1 var a b d (Eq p) = ( + let deg = MPoly_Type.degree p var in + \i\{0..<(deg+1)}. (isolate_variable_sparse p var i) * ((a+b*(Var var))^i) * (d^(deg - i)) +)" | + "quadratic_part_1 var a b d (Less p) = ( + let deg = MPoly_Type.degree p var in + let P = \i\{0..<(deg+1)}. (isolate_variable_sparse p var i) * ((a+b*(Var var))^i) * (d^(deg - i)) in + P * (d ^ (deg mod 2)) +)"| + "quadratic_part_1 var a b d (Leq p) = ( + let deg = MPoly_Type.degree p var in + let P = \i\{0..<(deg+1)}. (isolate_variable_sparse p var i) * ((a+b*(Var var))^i) * (d^(deg - i)) in + P * (d ^ (deg mod 2)) +)"| + "quadratic_part_1 var a b d (Neq p) = ( + let deg = MPoly_Type.degree p var in + \i\{0..<(deg+1)}. (isolate_variable_sparse p var i) * ((a+b*(Var var))^i) * (d^(deg - i)) +)" + +fun quadratic_part_2 :: "nat \ real mpoly \ real mpoly \ real mpoly" where + "quadratic_part_2 var sq p = ( + let deg = MPoly_Type.degree p var in + \i\{0.. real mpoly \ real mpoly \ real mpoly \ real mpoly \ atom \ atom fm" where + "quadratic_sub var a b c d (Eq p) = ( + let (p1::real mpoly) = quadratic_part_1 var a b d (Eq p) in + let (p2::real mpoly) = quadratic_part_2 var c p1 in + let (A::real mpoly) = isolate_variable_sparse p2 var 0 in + let (B::real mpoly) = isolate_variable_sparse p2 var 1 in + And + (Atom(Leq (A*B))) + (Atom (Eq (A^2-B^2*c))) +)" | + "quadratic_sub var a b c d (Less p) = ( + let (p1::real mpoly) = quadratic_part_1 var a b d (Less p) in + let (p2::real mpoly) = quadratic_part_2 var c p1 in + let (A::real mpoly) = isolate_variable_sparse p2 var 0 in + let (B::real mpoly) = isolate_variable_sparse p2 var 1 in + Or + (And + (Atom(Less(A))) + (Atom (Less (B^2*c-A^2)))) + (And + (Atom(Leq B)) + (Or + (Atom(Less A)) + (Atom(Less (A^2-B^2*c))))) +)" | + "quadratic_sub var a b c d (Leq p) = ( + let (p1::real mpoly) = quadratic_part_1 var a b d (Leq p) in + let (p2::real mpoly) = quadratic_part_2 var c p1 in + let (A::real mpoly) = isolate_variable_sparse p2 var 0 in + let (B::real mpoly) = isolate_variable_sparse p2 var 1 in + Or + (And + (Atom(Leq(A))) + (Atom (Leq(B^2*c-A^2)))) + (And + (Atom(Leq B)) + (Atom(Leq (A^2-B^2*c)))) +)" | + "quadratic_sub var a b c d (Neq p) = ( + let (p1::real mpoly) = quadratic_part_1 var a b d (Neq p) in + let (p2::real mpoly) = quadratic_part_2 var c p1 in + let (A::real mpoly) = isolate_variable_sparse p2 var 0 in + let (B::real mpoly) = isolate_variable_sparse p2 var 1 in + Or + (Atom(Less(-A*B))) + (Atom (Neq(A^2-B^2*c))) +)" + + +fun quadratic_sub_fm_helper :: "nat \ real mpoly \ real mpoly \ real mpoly \ real mpoly \ atom fm \ nat \ atom fm" where + "quadratic_sub_fm_helper var a b c d F z = liftmap (\x.\A. quadratic_sub (var+x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d) A) F z" + +fun quadratic_sub_fm :: "nat \ real mpoly \ real mpoly \ real mpoly \ real mpoly \ atom fm \ atom fm" where + "quadratic_sub_fm var a b c d F = quadratic_sub_fm_helper var a b c d F 0" + +subsection "General VS Helper Functions" + (* + allZero p var + takes in a polynomial of the form sum a_i x^i where x is the variable var + returns the formula where all a_i=0 +*) +fun allZero :: "real mpoly \ nat \ atom fm" where + "allZero p var = list_conj [Atom(Eq(isolate_variable_sparse p var i)). i <- [0..<(MPoly_Type.degree p var)+1]]" + +fun alternateNegInfinity :: "real mpoly \ nat \ atom fm" where + "alternateNegInfinity p var = foldl (\F.\i. +let a_n = isolate_variable_sparse p var i in +let exp = (if i mod 2 = 0 then Const(1) else Const(-1)) in + or (Atom(Less (exp * a_n))) + (and (Atom (Eq a_n)) F) +) FalseF ([0..<((MPoly_Type.degree p var)+1)])" + + +(* + substNegInfity var a + substitutes negative infinity for the variable var in the atom a + defined in pages 610-611 +*) +fun substNegInfinity :: "nat \ atom \ atom fm" where + "substNegInfinity var (Eq p) = allZero p var " | + "substNegInfinity var (Less p) = alternateNegInfinity p var"| + "substNegInfinity var (Leq p) = Or (alternateNegInfinity p var) (allZero p var)"| + "substNegInfinity var (Neq p) = Neg (allZero p var)" + +(* + convertDerivative var p + is equivalent to p^+ < 0 defined on page 615 around variable var +*) +function convertDerivative :: "nat \ real mpoly \ atom fm" where + "convertDerivative var p = (if (MPoly_Type.degree p var) = 0 then Atom (Less p) else + Or (Atom (Less p)) (And (Atom(Eq p)) (convertDerivative var (derivative var p))))" + by pat_completeness auto +termination + apply(relation "measures [\(var,p). MPoly_Type.degree p var]") + apply auto + using degree_derivative + by (metis less_add_one) + +(* + substInfinitesimalLinear var b c A + substitutes -c/b+epsilon for variable var in atom A + assumes b is nonzero + defined in page 615 +*) +fun substInfinitesimalLinear :: "nat \ real mpoly \ real mpoly \ atom \ atom fm" where + "substInfinitesimalLinear var b c (Eq p) = allZero p var"| + "substInfinitesimalLinear var b c (Less p) = + liftmap + (\x. \A. Atom(linear_substitution (var+x) (liftPoly 0 x b) (liftPoly 0 x c) A)) + (convertDerivative var p) + 0"| + "substInfinitesimalLinear var b c (Leq p) = +Or + (allZero p var) + (liftmap + (\x. \A. Atom(linear_substitution (var+x) (liftPoly 0 x b) (liftPoly 0 x c) A)) + (convertDerivative var p) + 0)"| + "substInfinitesimalLinear var b c (Neq p) = neg (allZero p var)" + +(* + substInfinitesimalQuadratic var a b c A + substitutes (quadratic equation)+epsilon for variable var in atom A + assumes a is nonzero and the determinant is positive + defined in page 615 +*) +fun substInfinitesimalQuadratic :: "nat \ real mpoly \ real mpoly \ real mpoly \ real mpoly \ atom \ atom fm" where + "substInfinitesimalQuadratic var a b c d (Eq p) = allZero p var"| + "substInfinitesimalQuadratic var a b c d (Less p) = quadratic_sub_fm var a b c d (convertDerivative var p)"| + "substInfinitesimalQuadratic var a b c d (Leq p) = +Or + (allZero p var) + (quadratic_sub_fm var a b c d (convertDerivative var p))"| + "substInfinitesimalQuadratic var a b c d (Neq p) = neg (allZero p var)" + + +fun substInfinitesimalLinear_fm :: "nat \ real mpoly \ real mpoly \ atom fm \ atom fm" where + "substInfinitesimalLinear_fm var b c F = liftmap (\x.\A. substInfinitesimalLinear (var+x) (liftPoly 0 x b) (liftPoly 0 x c) A) F 0" + + +fun substInfinitesimalQuadratic_fm :: "nat \ real mpoly \ real mpoly \ real mpoly \ real mpoly \ atom fm \ atom fm" where + "substInfinitesimalQuadratic_fm var a b c d F = liftmap (\x.\A. substInfinitesimalQuadratic (var+x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d) A) F 0" + +subsection "VS Algorithms" + +text + "elimVar var L F + attempts to do quadratic elimination on the variable defined by var. + L is the list of conjuctive atoms, F is a list of unnecessary garbage" +fun elimVar :: "nat \ atom list \ (atom fm) list \ atom \ atom fm" where + "elimVar var L F (Eq p) = ( + let (a,b,c) = get_coeffs var p in + + (Or + + (And (And (Atom (Eq a)) (Atom (Neq b))) + (list_conj ( + (map (\a. Atom (linear_substitution var (-c) b a)) L)@ + (map (linear_substitution_fm var (-c) b) F) + ))) + + + (And (Atom (Neq a)) (And (Atom(Leq (-(b^2)+4*a*c))) + (Or (list_conj ( + (map (quadratic_sub var (-b) 1 (b^2-4*a*c) (2*a)) L)@ + (map (quadratic_sub_fm var (-b) 1 (b^2-4*a*c) (2*a)) F) + )) + (list_conj ( + (map (quadratic_sub var (-b) (-1) (b^2-4*a*c) (2*a)) L)@ + (map (quadratic_sub_fm var (-b) (-1) (b^2-4*a*c) (2*a)) F) + )) + )) + )) + +)" | + "elimVar var L F (Less p) = ( + let (a,b,c) = get_coeffs var p in + (Or + + (And (And (Atom (Eq a)) (Atom (Neq b))) + (list_conj ( + (map (substInfinitesimalLinear var (-c) b) L) + @(map (substInfinitesimalLinear_fm var (-c) b) F) + ))) + + + (And (Atom (Neq a)) (And (Atom(Leq (-(b^2)+4*a*c))) + (Or (list_conj ( + (map (substInfinitesimalQuadratic var (-b) 1 (b^2-4*a*c) (2*a)) L)@ + (map (substInfinitesimalQuadratic_fm var (-b) 1 (b^2-4*a*c) (2*a)) F) + )) + (list_conj ( + (map (substInfinitesimalQuadratic var (-b) (-1) (b^2-4*a*c) (2*a)) L)@ + (map (substInfinitesimalQuadratic_fm var (-b) (-1) (b^2-4*a*c) (2*a)) F) + )) + )) + )) +)"| + "elimVar var L F (Neq p) = ( + let (a,b,c) = get_coeffs var p in + (Or + + (And (And (Atom (Eq a)) (Atom (Neq b))) + (list_conj ( + (map (substInfinitesimalLinear var (-c) b) L) + @(map (substInfinitesimalLinear_fm var (-c) b) F) + ))) + + + (And (Atom (Neq a)) (And (Atom(Leq (-(b^2)+4*a*c))) + (Or (list_conj ( + (map (substInfinitesimalQuadratic var (-b) 1 (b^2-4*a*c) (2*a)) L)@ + (map (substInfinitesimalQuadratic_fm var (-b) 1 (b^2-4*a*c) (2*a)) F) + )) + (list_conj ( + (map (substInfinitesimalQuadratic var (-b) (-1) (b^2-4*a*c) (2*a)) L)@ + (map (substInfinitesimalQuadratic_fm var (-b) (-1) (b^2-4*a*c) (2*a)) F) + )) + )) + ))) +"| + "elimVar var L F (Leq p) = ( + let (a,b,c) = get_coeffs var p in + + (Or + + (And (And (Atom (Eq a)) (Atom (Neq b))) + (list_conj ( + (map (\a. Atom (linear_substitution var (-c) b a)) L)@ + (map (linear_substitution_fm var (-c) b) F) + ))) + + + (And (Atom (Neq a)) (And (Atom(Leq (-(b^2)+4*a*c))) + (Or (list_conj ( + (map (quadratic_sub var (-b) 1 (b^2-4*a*c) (2*a)) L)@ + (map (quadratic_sub_fm var (-b) 1 (b^2-4*a*c) (2*a)) F) + )) + (list_conj ( + (map (quadratic_sub var (-b) (-1) (b^2-4*a*c) (2*a)) L)@ + (map (quadratic_sub_fm var (-b) (-1) (b^2-4*a*c) (2*a)) F) + )) + )) + )) + +)" + +(* single virtual substitution of equality *) +fun qe_eq_one :: "nat \ atom list \ atom fm list \ atom fm" where + "qe_eq_one var L F = + (case find_eq var L of + (p#A,L') \ Or (And (Neg (split_p var p)) + ((elimVar var L F) (Eq p)) + ) + (And (split_p var p) + (list_conj (map Atom ((map Eq A) @ L') @ F)) + ) + | ([],L') \ list_conj ((map Atom L) @ F) +)" + + +fun check_nonzero_const :: "real mpoly \ bool"where + "check_nonzero_const p = (case get_if_const p of Some x \ x \ 0 | None \ False)" + +fun find_lucky_eq :: "nat \ atom list \ real mpoly option"where + "find_lucky_eq v [] = None"| + "find_lucky_eq v (Eq p#L) = +(let (a,b,c) = get_coeffs v p in +(if (MPoly_Type.degree p v = 1 \ MPoly_Type.degree p v = 2) \ (check_nonzero_const a \ check_nonzero_const b \ check_nonzero_const c) then Some p else +find_lucky_eq v L +))"| + "find_lucky_eq v (_#L) = find_lucky_eq v L" + + +fun luckyFind :: "nat \ atom list \ atom fm list \ atom fm option" where + "luckyFind v L F = (case find_lucky_eq v L of Some p \ Some ((elimVar v L F) (Eq p)) | None \ None)" + +fun luckyFind' :: "nat \ atom list \ atom fm list \ atom fm" where + "luckyFind' v L F = (case find_lucky_eq v L of Some p \ (elimVar v L F) (Eq p) | None \ And (list_conj (map Atom L)) (list_conj F))" + + +fun find_luckiest_eq :: "nat \ atom list \ real mpoly option"where + "find_luckiest_eq v [] = None"| + "find_luckiest_eq v (Eq p#L) = +(if (MPoly_Type.degree p v = 1 \ MPoly_Type.degree p v = 2) then +(let (a,b,c) = get_coeffs v p in + (case get_if_const a of None \ find_luckiest_eq v L + | Some a \ (case get_if_const b of None \ find_luckiest_eq v L + | Some b \ (case get_if_const c of None \ find_luckiest_eq v L + | Some c \ if a\0\b\0\c\0 then Some p else find_luckiest_eq v L)))) + else +find_luckiest_eq v L +)"| + "find_luckiest_eq v (_#L) = find_luckiest_eq v L" + + + +fun luckiestFind :: "nat \ atom list \ atom fm list \ atom fm" where + "luckiestFind v L F = (case find_luckiest_eq v L of Some p \ (elimVar v L F) (Eq p) | None \ And (list_conj (map Atom L)) (list_conj F))" + + +primrec qe_eq_repeat_helper :: "nat \ real mpoly list \ atom list \ atom fm list \ atom fm" where + "qe_eq_repeat_helper var [] L F = list_conj ((map Atom L) @ F)"| + "qe_eq_repeat_helper var (p#A) L F = + Or (And (Neg (split_p var p)) + ((elimVar var ((map Eq (p#A)) @ L) F) (Eq p)) + ) + (And (split_p var p) + (qe_eq_repeat_helper var A L F) + )" + +fun qe_eq_repeat :: "nat \ atom list \ atom fm list \ atom fm" where + "qe_eq_repeat var L F = + (case luckyFind var L F of Some(F) \ F | None \ + (let (A,L') = find_eq var L in + qe_eq_repeat_helper var A L' F +) +) +" + +fun all_degree_2 :: "nat \ atom list \ bool" where + "all_degree_2 var [] = True"| + "all_degree_2 var (Eq p#as) = ((MPoly_Type.degree p var \ 2)\(all_degree_2 var as))"| + "all_degree_2 var (Less p#as) = ((MPoly_Type.degree p var \ 2)\(all_degree_2 var as))"| + "all_degree_2 var (Leq p#as) = ((MPoly_Type.degree p var \ 2)\(all_degree_2 var as))"| + "all_degree_2 var (Neq p#as) = ((MPoly_Type.degree p var \ 2)\(all_degree_2 var as))" + +fun gen_qe :: "nat \ atom list \ atom fm list \ atom fm" where + "gen_qe var L F = (case F of +[] \ (case luckyFind var L [] of Some F \ F | None \ ( + (if all_degree_2 var L + then list_disj (list_conj (map (substNegInfinity var) L) # (map (elimVar var L []) L)) + else (qe_eq_repeat var L [])))) +| _ \ qe_eq_repeat var L F +)" + +subsection "DNF" + +fun dnf :: "atom fm \ (atom list * atom fm list) list" where + "dnf TrueF = [([],[])]" | + "dnf FalseF = []" | + "dnf (Atom \) = [([\],[])]" | + "dnf (And \\<^sub>1 \\<^sub>2) = [(A@B,A'@B').(A,A')\dnf \\<^sub>1,(B,B')\dnf \\<^sub>2]" | + "dnf (Or \\<^sub>1 \\<^sub>2) = dnf \\<^sub>1 @ dnf \\<^sub>2" | + "dnf (ExQ \) = [([],[ExQ \])]" | + "dnf (Neg \) = [([],[Neg \])]"| + "dnf (AllQ \) = [([],[AllQ \])]"| + "dnf (AllN i \) = [([],[AllN i \])]"| + "dnf (ExN i \) = [([],[ExN i \])]" + +text " + dnf F + returns the \"disjunctive normal form\" of F, but since F can contain quantifiers, we return + (L,R,n) terms in a list. each term in the list represents a conjunction over the outside disjunctive list + + L is all the atoms we are able to reach, we are allowed to go underneath exists binders + + R is the remaining formulas (negation exists cannot be simplified) which are also under the same number + of exist binders. + + n is the total number of binders each conjunct has +" +fun dnf_modified :: "atom fm \ (atom list * atom fm list * nat) list" where + "dnf_modified TrueF = [([],[],0)]" | + "dnf_modified FalseF = []" | + "dnf_modified (Atom \) = [([\],[],0)]" | + "dnf_modified (And \\<^sub>1 \\<^sub>2) = [ + let A = map (liftAtom d1 d2) A in + let B = map (liftAtom 0 d1) B in + let A' = map (liftFm d1 d2) A' in + let B' = map (liftFm 0 d1) B' in + (A @ B, A' @ B',d1+d2). + (A,A',d1) \ dnf_modified \\<^sub>1, (B,B',d2) \ dnf_modified \\<^sub>2]" | + "dnf_modified (Or \\<^sub>1 \\<^sub>2) = dnf_modified \\<^sub>1 @ dnf_modified \\<^sub>2" | + "dnf_modified (ExQ \) = [(A,A',d+1). (A,A',d) \ dnf_modified \]" | + "dnf_modified (Neg \) = [([],[Neg \],0)]"| + "dnf_modified (AllQ \) = [([],[AllQ \],0)]"| + "dnf_modified (AllN i \) = [([],[AllN i \],0)]"| + "dnf_modified (ExN i \) = [(A,A',d+i). (A,A',d) \ dnf_modified \]" + + +(* +repeatedly applies nnf and dnf on subformulas and then attempts to eliminate the quantifier based +on the qe quantifier elimination method given. Works on innermost variables first and builds out +*) +fun QE_dnf :: "(atom fm \ atom fm) \ (nat \ nat \ atom list \ atom fm list \ atom fm) \ atom fm \ atom fm" where + "QE_dnf opt step (And \\<^sub>1 \\<^sub>2) = and (QE_dnf opt step \\<^sub>1) (QE_dnf opt step \\<^sub>2)" | + "QE_dnf opt step (Or \\<^sub>1 \\<^sub>2) = or (QE_dnf opt step \\<^sub>1) (QE_dnf opt step \\<^sub>2)" | + "QE_dnf opt step (Neg \) = neg(QE_dnf opt step \)" | + "QE_dnf opt step (ExQ \) = list_disj [ExN (n+1) (step 1 n al fl). (al,fl,n)\(dnf_modified(opt(QE_dnf opt step \)))]"| + "QE_dnf opt step (TrueF) = TrueF"| + "QE_dnf opt step (FalseF) = FalseF"| + "QE_dnf opt step (Atom a) = simp_atom a"| + "QE_dnf opt step (AllQ \) = Neg(list_disj [ExN (n+1) (step 1 n al fl). (al,fl,n)\(dnf_modified(opt(neg(QE_dnf opt step \))))])"| + "QE_dnf opt step (ExN 0 \) = QE_dnf opt step \"| + "QE_dnf opt step (AllN 0 \) = QE_dnf opt step \"| + "QE_dnf opt step (AllN (Suc i) \) = Neg(list_disj [ExN (n+i+1) (step (Suc i) (n+i) al fl). (al,fl,n)\(dnf_modified(opt(neg(QE_dnf opt step \))))])"| + "QE_dnf opt step (ExN (Suc i) \) = list_disj [ExN (n+i+1) (step (Suc i) (n+i) al fl). (al,fl,n)\(dnf_modified(opt(QE_dnf opt step \)))]" + +fun QE_dnf' :: "(atom fm \ atom fm) \ (nat \ (atom list * atom fm list * nat) list \ atom fm) \ atom fm \ atom fm" where + "QE_dnf' opt step (And \\<^sub>1 \\<^sub>2) = and (QE_dnf' opt step \\<^sub>1) (QE_dnf' opt step \\<^sub>2)" | + "QE_dnf' opt step (Or \\<^sub>1 \\<^sub>2) = or (QE_dnf' opt step \\<^sub>1) (QE_dnf' opt step \\<^sub>2)" | + "QE_dnf' opt step (Neg \) = neg(QE_dnf' opt step \)" | + "QE_dnf' opt step (ExQ \) = step 1 (dnf_modified(opt(QE_dnf' opt step \)))"| + "QE_dnf' opt step (TrueF) = TrueF"| + "QE_dnf' opt step (FalseF) = FalseF"| + "QE_dnf' opt step (Atom a) = simp_atom a"| + "QE_dnf' opt step (AllQ \) = Neg(step 1 (dnf_modified(opt(neg(QE_dnf' opt step \)))))"| + "QE_dnf' opt step (ExN 0 \) = QE_dnf' opt step \"| + "QE_dnf' opt step (AllN 0 \) = QE_dnf' opt step \"| + "QE_dnf' opt step (AllN (Suc i) \) = Neg(step (Suc i) (dnf_modified(opt(neg(QE_dnf' opt step \)))))"| + "QE_dnf' opt step (ExN (Suc i) \) = step (Suc i) (dnf_modified(opt(QE_dnf' opt step \)))" + +subsection "Repeat QE multiple times" + +fun countQuantifiers :: "atom fm \ nat" where + "countQuantifiers (Atom _) = 0"| + "countQuantifiers (TrueF) = 0"| + "countQuantifiers (FalseF) = 0"| + "countQuantifiers (And a b) = countQuantifiers a + countQuantifiers b"| + "countQuantifiers (Or a b) = countQuantifiers a + countQuantifiers b"| + "countQuantifiers (Neg a) = countQuantifiers a"| + "countQuantifiers (ExQ a) = countQuantifiers a + 1"| + "countQuantifiers (AllQ a) = countQuantifiers a + 1"| + "countQuantifiers (ExN n a) = countQuantifiers a + n"| + "countQuantifiers (AllN n a) = countQuantifiers a + n" + +fun repeatAmountOfQuantifiers_helper :: "(atom fm \ atom fm) \ nat \ atom fm \ atom fm" where + "repeatAmountOfQuantifiers_helper step 0 F = F"| + "repeatAmountOfQuantifiers_helper step (Suc i) F = repeatAmountOfQuantifiers_helper step i (step F)" + +fun repeatAmountOfQuantifiers :: "(atom fm \ atom fm) \ atom fm \ atom fm" where + "repeatAmountOfQuantifiers step F = ( +let F = step F in +let n = countQuantifiers F in +repeatAmountOfQuantifiers_helper step n F +)" + +end \ No newline at end of file diff --git a/thys/Virtual_Substitution/VSQuad.thy b/thys/Virtual_Substitution/VSQuad.thy new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/VSQuad.thy @@ -0,0 +1,392 @@ +subsection "Recursive QE" +theory VSQuad + imports EqualityVS GeneralVSProofs Reindex OptimizationProofs DNF +begin + +lemma existN_eval : "\xs. eval (ExN n \) xs = (\L. (length L = n \ eval \ (L@xs)))" +proof(induction n) + case 0 + then show ?case by simp +next + case (Suc n) + {fix xs + have "eval (ExN (Suc n) \) xs = (\l. length l = Suc n \ eval \ (l @ xs))" + by simp + also have "... = (\x.\L. (length L = n \ eval \ (L@(x#xs))))" + proof safe + fix l + assume h : "length l = Suc n" "eval \ (l @ xs)" + show "\x L. length L = n \ eval \ (L @ x # xs)" + apply(rule exI[where x="l ! n"]) + apply(rule exI[where x="take n l"]) + using h apply auto + by (metis Cons_nth_drop_Suc append.assoc append_Cons append_take_drop_id lessI order_refl self_append_conv self_append_conv2 take_all) + next + fix x L + assume h : "eval \ (L @ x # xs)" "n = length L" + show "\l. length l = Suc (length L) \ eval \ (l @ xs)" + apply(rule exI[where x="L@[x]"]) + using h by auto + qed + also have "... = (\x.\L. (length L = n \ eval \ ((L@[x])@xs)))" + by simp + also have "... = (\x.\L. (length (L@[x]) = (Suc n) \ eval \ ((L@[x])@xs)))" + by simp + also have "... = (\L. (length L = (Suc n) \ eval \ (L@xs)))" + by (metis append_butlast_last_id length_0_conv nat.simps(3)) + finally have "eval (ExN (Suc n) \) xs = (\L. (length L = (Suc n) \ eval \ (L@xs)))" + by simp + } + then show ?case by simp +qed + + + + +lemma boundedFlipNegQuantifier : "(\(\x\A. \ P x)) = (\x\A. P x)" + by blast + + +theorem QE_dnf'_eval: + assumes steph : "\amount F \. + (\xs. (length xs = amount \ eval (list_disj (map(\(L,F,n). ExN n (list_conj (map fm.Atom L @ F))) F)) (xs @ \))) = (eval (step amount F) \)" + assumes opt : "\xs F . eval (opt F) xs = eval F xs" + shows "eval (QE_dnf' opt step \) xs = eval \ xs" +proof(induction \ arbitrary : xs) + case (Atom x) + then show ?case by (simp add: simp_atom_eval) +next + case (And \1 \2) + then show ?case by (simp add: eval_and) +next + case (Or \1 \2) + then show ?case by (simp add: eval_or) +next + case (Neg \) + then show ?case apply simp + by (metis eval_neg ) +next + case (ExQ \) + have h1 : "\F. (\xs. length xs = Suc 0 \ + F xs) = (\x. + F [x])" + by (metis length_0_conv length_Suc_conv) + show ?case + apply simp + unfolding steph[symmetric] apply(simp add: eval_list_disj) + unfolding h1 apply(rule ex_cong1) + unfolding ExQ[symmetric] + unfolding opt[symmetric, of "(QE_dnf' opt step \)"] + unfolding dnf_modified_eval[symmetric, of "(opt (QE_dnf' opt step \))"] + apply(rule bex_cong) apply simp + subgoal for x f + apply(cases f) + apply (auto simp add:eval_list_conj) + by (metis Un_iff eval.simps(1) imageI) + done +next + case (AllQ \) + have h1 : "\F. (\xs::real list. (length xs = Suc 0 \ + F xs)) = (\x. + F [x])" + by (metis length_0_conv length_Suc_conv) + show ?case + apply simp + unfolding steph[symmetric] apply(simp add: eval_list_disj) + unfolding h1 apply(rule all_cong1) + unfolding AllQ[symmetric] + unfolding eval_neg[symmetric, of "(QE_dnf' opt step \)"] + unfolding opt[symmetric, of "neg(QE_dnf' opt step \)"] + unfolding Set.bex_simps(8)[symmetric] HOL.Not_eq_iff + unfolding dnf_modified_eval[symmetric, of "(opt (neg(QE_dnf' opt step \)))"] + apply(rule bex_cong) apply simp + subgoal for x f + apply(cases f) + apply (auto simp add:eval_list_conj) + by (metis Un_iff eval.simps(1) imageI) + done +next + case (ExN amount \) + show ?case + apply(cases amount) + apply (simp_all add: ExN) + unfolding steph[symmetric] apply(simp add: eval_list_disj) + unfolding ExN[symmetric] + unfolding opt[of "(QE_dnf' opt step \)",symmetric] + unfolding dnf_modified_eval[of "(opt (QE_dnf' opt step \))",symmetric] + apply(rule ex_cong1) + subgoal for nat xs + apply(cases "length xs = Suc nat") + apply simp_all + apply(rule bex_cong) + apply simp_all + subgoal for f + apply(cases f) + apply simp + apply(rule ex_cong1) + unfolding eval_list_conj + apply auto + by (meson Un_iff eval.simps(1) imageI) + done + done +next + case (AllN amount \) + show ?case + apply(cases amount) + apply (simp_all add: AllN) + unfolding steph[symmetric] apply(simp add: eval_list_disj) + unfolding AllN[symmetric] + unfolding eval_neg[symmetric, of "(QE_dnf' opt step \)"] + unfolding opt[symmetric, of "neg(QE_dnf' opt step \)"] + unfolding Set.bex_simps(8)[symmetric] + unfolding HOL.imp_conv_disj + unfolding HOL.de_Morgan_conj[symmetric] + unfolding HOL.not_ex[symmetric] + unfolding HOL.Not_eq_iff + unfolding dnf_modified_eval[symmetric, of "(opt (neg(QE_dnf' opt step \)))"] + apply(rule ex_cong1) + subgoal for nat xs + apply(cases "length xs = Suc nat") + apply simp_all + apply(rule bex_cong) + apply simp_all + subgoal for f + apply(cases f) + apply simp + apply(rule ex_cong1) + unfolding eval_list_conj + apply auto + by (meson Un_iff eval.simps(1) imageI) + done + done +qed auto + + + +theorem QE_dnf_eval: + assumes steph : "\var amount new L F \. + amount\var+1 \ + (\xs. (length xs = var+1 \ eval (list_conj (map fm.Atom L @ F)) (xs @ \))) = (\xs. (length xs = var+1 \eval (step amount var L F) (xs @ \)))" + assumes opt : "\xs F . eval (opt F) xs = eval F xs" + shows "eval (QE_dnf opt step \) xs = eval \ xs" +proof(induction \ arbitrary:xs) + case (Atom x) + then show ?case by (simp add: simp_atom_eval) +next + case (And \1 \2) + then show ?case by (simp add: eval_and) +next + case (Or \1 \2) + then show ?case by (simp add: eval_or) +next + case (Neg \) + then show ?case + by (metis eval.simps(6) eval_neg QE_dnf.simps(3)) +next + case (ExQ \) + have h : "(\x. \(al, fl, n)\set (dnf_modified (opt (QE_dnf opt step \))). + \L. length L = n \ (\a\set al. aEval a (L @ x # xs)) \ (\f\set fl. eval f (L @ x # xs))) = + (\(al, fl, n)\set (dnf_modified (opt (QE_dnf opt step \))). \x. + \L. length L = n \ (\a\set al. aEval a (L @ x # xs)) \ (\f\set fl. eval f (L @ x # xs)))" + apply safe + by blast+ + have lessThan : "\c. Suc 0 \ c + 1" + by simp + show ?case apply (simp add:eval_list_disj) + unfolding ExQ[symmetric] + unfolding opt[symmetric, of "(QE_dnf opt step \)"] + unfolding dnf_modified_eval[symmetric, of "opt(QE_dnf opt step \)"] + unfolding h + apply(rule bex_cong) + apply simp + subgoal for f + apply(cases f) + apply simp + subgoal for a b c + using steph[of "Suc 0" c a b xs, symmetric, OF lessThan] apply (simp add:eval_list_conj) + apply safe + subgoal for xs' l' l'' + apply(rule exI[where x="l'!c"]) + apply(rule exI[where x="take c l'"]) + apply auto + apply (metis Un_iff append.assoc append_Cons append_Nil eval.simps(1) image_eqI lessI order_refl take_Suc_conv_app_nth take_all) + by (metis Un_iff append.assoc append_Cons append_Nil lessI order_refl take_Suc_conv_app_nth take_all) + subgoal for A B C D + apply(rule exI[where x="D@[C]"]) by auto + subgoal for A B + apply(rule exI[where x="B@[A]"]) by auto + done + done + done +next + case (AllQ \) + have h : "(\x. \(al, fl, n)\set (dnf_modified (opt (neg(QE_dnf opt step \)))). + \L. length L = n \ (\a\set al. aEval a (L @ x # xs)) \ (\f\set fl. eval f (L @ x # xs))) = + (\(al, fl, n)\set (dnf_modified (opt (neg(QE_dnf opt step \)))). \x. + \L. length L = n \ (\a\set al. aEval a (L @ x # xs)) \ (\f\set fl. eval f (L @ x # xs)))" + apply safe + by blast+ + have lessThan : "\c. Suc 0 \ c + 1" + by simp + show ?case + apply (simp add:eval_list_disj) + unfolding AllQ[symmetric] + unfolding eval_neg[symmetric, of "(QE_dnf opt step \)"] + unfolding opt[symmetric, of "neg(QE_dnf opt step \)"] + unfolding HOL.Not_eq_iff[symmetric, of "(\f\set (dnf_modified (opt (neg (QE_dnf opt step \)))). \ eval (case f of (al, fl, n) \ ExN (Suc n) (step (Suc 0) n al fl)) xs)"] + unfolding SMT.verit_connective_def(3)[symmetric] + unfolding boundedFlipNegQuantifier + unfolding dnf_modified_eval[symmetric, of "opt(neg(QE_dnf opt step \))"] + unfolding h + apply(rule bex_cong) + apply simp + subgoal for f + apply(cases f) + apply simp + subgoal for a b c + using steph[of "Suc 0" c a b xs, symmetric,OF lessThan] apply (simp add:eval_list_conj) + apply safe + subgoal for xs' l' l'' + apply(rule exI[where x="l'!c"]) + apply(rule exI[where x="take c l'"]) + apply auto + apply (metis Un_iff append.assoc append_Cons append_Nil eval.simps(1) image_eqI lessI order_refl take_Suc_conv_app_nth take_all) + by (metis Un_iff append.assoc append_Cons append_Nil lessI order_refl take_Suc_conv_app_nth take_all) + subgoal for A B C D + apply(rule exI[where x="D@[C]"]) by auto + subgoal for A B + apply(rule exI[where x="B@[A]"]) by auto + done + done + done +next + case (ExN x1 \) + show ?case + proof(cases x1) + case 0 + then show ?thesis using ExN by simp + next + case (Suc nat) + have h : "(\l. length l = Suc nat \ + (\(al, fl, n)\set (dnf_modified (opt (QE_dnf opt step \))). + \L. length L = n \ (\a\set al. aEval a (L @ l @ xs)) \ (\f\set fl. eval f (L @ l @ xs)))) = + (\(al, fl, n)\set (dnf_modified (opt (QE_dnf opt step \))). (\l. length l = Suc nat \ + (\L. length L = n \ (\a\set al. aEval a (L @ l @ xs)) \ (\f\set fl. eval f (L @ l @ xs)))))" + apply safe + by blast+ + have lessThan : "\c. Suc nat \ c + nat + 1" by simp + show ?thesis + apply (simp add:eval_list_disj Suc) + unfolding ExN[symmetric] + unfolding opt[symmetric, of "(QE_dnf opt step \)"] + unfolding dnf_modified_eval[symmetric, of "(opt (QE_dnf opt step \))"] + unfolding h + apply(rule bex_cong) + apply simp + subgoal for f + apply(cases f) + subgoal for a b c + apply simp + using steph[of "Suc nat" "c+nat",symmetric, OF lessThan] + apply (auto simp add:eval_list_conj) + subgoal for L + apply(rule exI[where x="drop c L"]) + apply auto + apply(rule exI[where x="take c L"]) + apply auto + apply (metis Un_iff append.assoc append_take_drop_id eval.simps(1) image_eqI) + by (metis Un_iff append.assoc append_take_drop_id) + subgoal for L l + apply(rule exI[where x="l@L"]) + by auto + done + done + done + qed +next + case (AllN x1 \) + then show ?case + proof(cases x1) + case 0 + then show ?thesis using AllN by simp + next + case (Suc nat) + have h : "(\l. length l = Suc nat \ + (\(al, fl, n)\set (dnf_modified (opt (neg(QE_dnf opt step \)))). + \L. length L = n \ (\a\set al. aEval a (L @ l @ xs)) \ (\f\set fl. eval f (L @ l @ xs)))) = + (\(al, fl, n)\set (dnf_modified (opt (neg(QE_dnf opt step \)))). (\l. length l = Suc nat \ + (\L. length L = n \ (\a\set al. aEval a (L @ l @ xs)) \ (\f\set fl. eval f (L @ l @ xs)))))" + apply safe + by blast+ + have lessThan : "\c. Suc nat \ c + nat + 1" by simp + show ?thesis + apply (simp add:eval_list_disj Suc) + unfolding AllN[symmetric] + unfolding eval_neg[symmetric, of "QE_dnf opt step \"] + unfolding HOL.imp_conv_disj + unfolding HOL.de_Morgan_conj[symmetric] + unfolding opt[symmetric, of "neg(QE_dnf opt step \)"] + unfolding dnf_modified_eval[symmetric, of "(opt (neg(QE_dnf opt step \)))"] + unfolding HOL.Not_eq_iff[symmetric, of "(\f\set (dnf_modified (opt (neg (QE_dnf opt step \)))). + \ eval (case f of (al, fl, n) \ ExN (Suc (n + nat)) (step (Suc nat) (n + nat) al fl)) xs)"] + unfolding SMT.verit_connective_def(3)[symmetric] + unfolding boundedFlipNegQuantifier + unfolding h + apply(rule bex_cong) + apply simp + subgoal for f + apply(cases f) + subgoal for a b c + apply simp + using steph[of "Suc nat" "c+nat",symmetric, OF lessThan] + apply (auto simp add:eval_list_conj) + subgoal for L + apply(rule exI[where x="drop c L"]) + apply auto + apply(rule exI[where x="take c L"]) + apply auto + apply (metis Un_iff append.assoc append_take_drop_id eval.simps(1) image_eqI) + by (metis Un_iff append.assoc append_take_drop_id) + subgoal for L l + apply(rule exI[where x="l@L"]) + by auto + done + done + done + qed +qed auto + +lemma opt: "eval ((push_forall \ nnf \ unpower 0 o groupQuantifiers o clearQuantifiers) F) L= eval F L" + using push_forall_eval eval_nnf unpower_eval groupQuantifiers_eval clearQuantifiers_eval by auto + +lemma opt': "eval ((push_forall ( nnf ( unpower 0 ( groupQuantifiers (clearQuantifiers F)))))) L= eval F L" + using push_forall_eval eval_nnf unpower_eval groupQuantifiers_eval clearQuantifiers_eval by auto + +lemma opt_no_group: "eval ((push_forall \ nnf \ unpower 0 o clearQuantifiers) F) L= eval F L" + using push_forall_eval eval_nnf unpower_eval clearQuantifiers_eval by auto + + + +lemma repeatAmountOfQuantifiers_helper_eval : + assumes "\xs F. eval F xs = eval (step F) xs" + shows "eval F xs = eval (repeatAmountOfQuantifiers_helper step n F) xs" + apply(induction n arbitrary : F) + apply simp_all + subgoal for n F + using assms[of F xs] by auto + done + + +lemma repeatAmountOfQuantifiers_eval : + assumes "\xs F. eval F xs = eval (step F) xs" + shows "eval F xs = eval (repeatAmountOfQuantifiers step F) xs" +proof- + define F' where "F' = step F" + have h: "eval F xs = eval F' xs" + using assms unfolding F'_def by auto + show ?thesis + apply (simp add: F'_def[symmetric] h) + using repeatAmountOfQuantifiers_helper_eval[OF assms] by auto +qed + +end diff --git a/thys/Virtual_Substitution/document/root.bib b/thys/Virtual_Substitution/document/root.bib new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/document/root.bib @@ -0,0 +1,66 @@ +@BOOK{Platzer18, + author = {Andr{\'{e}} Platzer}, + title = {Logical Foundations of Cyber-Physical Systems}, + publisher = {Springer}, + address = {Cham}, + year = {2018}, + isbn = {978-3-319-63587-3}, + e-isbn = {978-3-319-63588-0}, + doi = {10.1007/978-3-319-63588-0}, + opturl = {http://www.springer.com/978-3-319-63587-3} +} + + +@article{weispfenning1988complexity, + author = {Volker Weispfenning}, + title = {The Complexity of Linear Problems in Fields}, + journal = {J. Symb. Comput.}, + volume = {5}, + number = {1/2}, + pages = {3--27}, + year = {1988}, + skipurl = {https://doi.org/10.1016/S0747-7171(88)80003-8}, + doi = {10.1016/S0747-7171(88)80003-8}, + timestamp = {Wed, 17 Feb 2021 08:56:48 +0100}, + biburl = {https://dblp.org/rec/journals/jsc/Weispfenning88.bib}, + bibsource = {dblp computer science bibliography, https://dblp.org} +} + +@article{weispfenning1997quantifier, + author = {Volker Weispfenning}, + title = {Quantifier Elimination for Real Algebra -- the Quadratic Case and Beyond}, + journal = {Appl. Algebra Eng. Commun. Comput.}, + volume = {8}, + number = {2}, + pages = {85--101}, + year = {1997}, + skipurl = {https://doi.org/10.1007/s002000050055}, + doi = {10.1007/s002000050055}, + timestamp = {Thu, 18 May 2017 09:50:54 +0200}, + biburl = {https://dblp.org/rec/journals/aaecc/Weispfenning97.bib}, + bibsource = {dblp computer science bibliography, https://dblp.org} +} + + +@article{nipkow2010linear, + author = {Tobias Nipkow}, + title = {Linear Quantifier Elimination}, + journal = {J. Autom. Reason.}, + volume = {45}, + number = {2}, + pages = {189--212}, + year = {2010}, + skipurl = {https://doi.org/10.1007/s10817-010-9183-0}, + doi = {10.1007/s10817-010-9183-0}, + timestamp = {Wed, 02 Sep 2020 13:29:58 +0200}, + biburl = {https://dblp.org/rec/journals/jar/Nipkow10.bib}, + bibsource = {dblp computer science bibliography, https://dblp.org} +} + +@phdthesis{chaieb2008automated, + title={Automated methods for formal proofs in simple arithmetics and algebra}, + author={Chaieb, Amine}, + year={2008}, + school={Technische Universit{\"a}t M{\"u}nchen}, +url={https://mediatum.ub.tum.de/doc/649541/649541.pdf} +} diff --git a/thys/Virtual_Substitution/document/root.tex b/thys/Virtual_Substitution/document/root.tex new file mode 100644 --- /dev/null +++ b/thys/Virtual_Substitution/document/root.tex @@ -0,0 +1,99 @@ +\documentclass[11pt,a4paper]{article} +\usepackage{isabelle,isabellesym} + +% further packages required for unusual symbols (see also +% isabellesym.sty), use only when needed + +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{mathtools} +\usepackage{marvosym} + %for \, \, \, \, \, \, + %\, \, \, \, \, + %\, \, \ + +%\usepackage{eurosym} + %for \ + +%\usepackage[only,bigsqcap]{stmaryrd} + %for \ + +%\usepackage{eufrak} + %for \ ... \, \ ... \ (also included in amssymb) + +%\usepackage{textcomp} + %for \, \, \, \, \, + %\ + +\newcommand{\FOLR}{$\text{FOL}_{\mathbb{R}}$} + +% this should be the last package used +\usepackage{pdfsetup} + +% urls in roman style, theory text in math-similar italics +\urlstyle{rm} +\isabellestyle{it} + +% for uniform font size +%\renewcommand{\isastyle}{\isastyleminor} + + +\begin{document} + +\title{Verified Quadratic Virtual Substitution\texorpdfstring{\\}{} for Real Arithmetic} + +\author{Matias Scharager, +Katherine Cordwell, +Stefan Mitsch and +Andr\'{e} Platzer} + + +\maketitle + +\begin{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 \cite{weispfenning1988complexity,weispfenning1997quantifier}. +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. +\end{abstract} + +\tableofcontents + +\section{Related Works} + +There has already been some work on formally verified VS: Nipkow \cite{nipkow2010linear} formally verified a VS procedure for \emph{linear} equations and inequalities. +The building blocks of \FOLR~formulas, or ``atoms," in Nipkow's work only allow for linear polynomials $\sum_i a_i x_i\sim c$, where $\sim\ \in \{=,<\}$, the $x_i$'s are quantified variables and $c$ and the $a_i$'s are real numbers. +These restrictions ensure that linear QE can always be performed, and they also simplify the substitution procedure and associated proofs. +Nipkow additionally provides a generic framework that can be applied to several different kinds of atoms (each new atom requires implementing several new code theorems in order to create an exportable algorithm). +While this is an excellent theoretical framework---we utilize several similar constructs in our formulation---we create an independent formalization that is specific to general \FOLR~formulas, as our main focus is to provide an efficient algorithm in this domain. +Specializing to one type of atom allows us to implement several optimizations, such as our modified DNF algorithm, which would be unwieldy to develop in a generic setting. + +Chaieb \cite{chaieb2008automated} extends Nipkow's work to quadratic equalities. +His formalizations are not publicly available, but he generously provided us with the code. +While this was helpful for reference, we chose to build on a newer Isabelle/HOL polynomial library, and we focus on VS as an exportable standalone procedure, whereas Chaieb intrinsically links VS with an auxiliary QE procedure. + +We also use the Logical Foundations of Cyber-Physical Systems textbook\cite{Platzer18} for easy reference for the VS algorithm. + +% sane default for proof documents +\parindent 0pt\parskip 0.5ex + +% generated text of all theories +\input{session} + +% optional bibliography +\bibliographystyle{abbrv} +\bibliography{root} + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff --git a/web/entries/BenOr_Kozen_Reif.html b/web/entries/BenOr_Kozen_Reif.html --- a/web/entries/BenOr_Kozen_Reif.html +++ b/web/entries/BenOr_Kozen_Reif.html @@ -1,206 +1,206 @@ The BKR Decision Procedure for Univariate Real Arithmetic - Archive of Formal Proofs

 

 

 

 

 

 

The BKR Decision Procedure for Univariate Real Arithmetic

 

Title: The BKR Decision Procedure for Univariate Real Arithmetic
Authors: - Katherine Cordwell, + Katherine Cordwell (kcordwel /at/ cs /dot/ cmu /dot/ edu), Yong Kiam Tan and - André Platzer + André Platzer (aplatzer /at/ cs /dot/ cmu /dot/ edu)
Submission date: 2021-04-24
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.
BibTeX:
@article{BenOr_Kozen_Reif-AFP,
   author  = {Katherine Cordwell and Yong Kiam Tan and André Platzer},
   title   = {The BKR Decision Procedure for Univariate Real Arithmetic},
   journal = {Archive of Formal Proofs},
   month   = apr,
   year    = 2021,
   note    = {\url{https://isa-afp.org/entries/BenOr_Kozen_Reif.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: Algebraic_Numbers, Sturm_Tarski

\ No newline at end of file diff --git a/web/entries/Differential_Game_Logic.html b/web/entries/Differential_Game_Logic.html --- a/web/entries/Differential_Game_Logic.html +++ b/web/entries/Differential_Game_Logic.html @@ -1,205 +1,205 @@ Differential Game Logic - Archive of Formal Proofs

 

 

 

 

 

 

Differential Game Logic

 

Title: Differential Game Logic
Author: - André Platzer + André Platzer (aplatzer /at/ cs /dot/ cmu /dot/ edu)
Submission date: 2019-06-03
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.
BibTeX:
@article{Differential_Game_Logic-AFP,
   author  = {André Platzer},
   title   = {Differential Game Logic},
   journal = {Archive of Formal Proofs},
   month   = jun,
   year    = 2019,
   note    = {\url{https://isa-afp.org/entries/Differential_Game_Logic.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License

\ No newline at end of file diff --git a/web/entries/Dominance_CHK.html b/web/entries/Dominance_CHK.html --- a/web/entries/Dominance_CHK.html +++ b/web/entries/Dominance_CHK.html @@ -1,199 +1,201 @@ A data flow analysis algorithm for computing dominators - Archive of Formal Proofs

 

 

 

 

 

 

A data flow analysis algorithm for computing dominators

 

- + + +
Title: A data flow analysis algorithm for computing dominators
Author: Nan Jiang
Submission date: 2021-09-05
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.
BibTeX:
@article{Dominance_CHK-AFP,
   author  = {Nan Jiang},
   title   = {A data flow analysis algorithm for computing dominators},
   journal = {Archive of Formal Proofs},
   month   = sep,
   year    = 2021,
   note    = {\url{https://isa-afp.org/entries/Dominance_CHK.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on:Jinja, List-Index

\ No newline at end of file diff --git a/web/entries/Jinja.html b/web/entries/Jinja.html --- a/web/entries/Jinja.html +++ b/web/entries/Jinja.html @@ -1,294 +1,294 @@ Jinja is not Java - Archive of Formal Proofs

 

 

 

 

 

 

Jinja is not Java

 

- +
Title: Jinja is not Java
Authors: Gerwin Klein and Tobias Nipkow
Submission date: 2005-06-01
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.
BibTeX:
@article{Jinja-AFP,
   author  = {Gerwin Klein and Tobias Nipkow},
   title   = {Jinja is not Java},
   journal = {Archive of Formal Proofs},
   month   = jun,
   year    = 2005,
   note    = {\url{https://isa-afp.org/entries/Jinja.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Depends on: List-Index
Used by:HRB-Slicing, JinjaDCI, Slicing
Dominance_CHK, HRB-Slicing, JinjaDCI, Slicing

\ No newline at end of file diff --git a/web/entries/List-Index.html b/web/entries/List-Index.html --- a/web/entries/List-Index.html +++ b/web/entries/List-Index.html @@ -1,262 +1,262 @@ List Index - Archive of Formal Proofs

 

 

 

 

 

 

List Index

 

- +
Title: List Index
Author: Tobias Nipkow
Submission date: 2010-02-20
Abstract: This theory provides functions for finding the index of an element in a list, by predicate and by value.
BibTeX:
@article{List-Index-AFP,
   author  = {Tobias Nipkow},
   title   = {List Index},
   journal = {Archive of Formal Proofs},
   month   = feb,
   year    = 2010,
   note    = {\url{https://isa-afp.org/entries/List-Index.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: BSD License
Used by:Affine_Arithmetic, Comparison_Sort_Lower_Bound, Formula_Derivatives, Higher_Order_Terms, Jinja, JinjaDCI, List_Update, LTL_to_DRA, Metalogic_ProofChecker, MSO_Regex_Equivalence, Nested_Multisets_Ordinals, Ordinary_Differential_Equations, Planarity_Certificates, Quick_Sort_Cost, Randomised_Social_Choice, Refine_Imperative_HOL, Smith_Normal_Form, Verified_SAT_Based_AI_Planning
Affine_Arithmetic, Comparison_Sort_Lower_Bound, Dominance_CHK, Formula_Derivatives, Higher_Order_Terms, Jinja, JinjaDCI, List_Update, LTL_to_DRA, Metalogic_ProofChecker, MSO_Regex_Equivalence, Nested_Multisets_Ordinals, Ordinary_Differential_Equations, Planarity_Certificates, Quick_Sort_Cost, Randomised_Social_Choice, Refine_Imperative_HOL, Smith_Normal_Form, Verified_SAT_Based_AI_Planning

\ No newline at end of file diff --git a/web/entries/Polynomials.html b/web/entries/Polynomials.html --- a/web/entries/Polynomials.html +++ b/web/entries/Polynomials.html @@ -1,301 +1,301 @@ Executable Multivariate Polynomials - Archive of Formal Proofs

 

 

 

 

 

 

Executable Multivariate Polynomials

 

- +
Title: Executable Multivariate Polynomials
Authors: Christian Sternagel (c /dot/ sternagel /at/ gmail /dot/ com), René Thiemann (rene /dot/ thiemann /at/ uibk /dot/ ac /dot/ at), Alexander Maletzky, Fabian Immler, Florian Haftmann, Andreas Lochbihler and Alexander Bentkamp (bentkamp /at/ gmail /dot/ com)
Submission date: 2010-08-10
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].

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.
BibTeX:
@article{Polynomials-AFP,
   author  = {Christian Sternagel and René Thiemann and Alexander Maletzky and Fabian Immler and Florian Haftmann and Andreas Lochbihler and Alexander Bentkamp},
   title   = {Executable Multivariate Polynomials},
   journal = {Archive of Formal Proofs},
   month   = aug,
   year    = 2010,
   note    = {\url{https://isa-afp.org/entries/Polynomials.html},
             Formal proof development},
   ISSN    = {2150-914x},
 }
License: GNU Lesser General Public License (LGPL)
Depends on: Abstract-Rewriting, Matrix, Show, Well_Quasi_Orders
Used by:Deep_Learning, Groebner_Bases, Lambda_Free_KBOs, PAC_Checker, Symmetric_Polynomials
Deep_Learning, Groebner_Bases, Lambda_Free_KBOs, PAC_Checker, Symmetric_Polynomials, Virtual_Substitution

\ No newline at end of file diff --git a/web/entries/Virtual_Substitution.html b/web/entries/Virtual_Substitution.html new file mode 100644 --- /dev/null +++ b/web/entries/Virtual_Substitution.html @@ -0,0 +1,213 @@ + + + + +Verified Quadratic Virtual Substitution for Real Arithmetic - Archive of Formal Proofs + + + + + + + + + + + + + + + + + + + + + + + + +
+

 

+ + + +

 

+

 

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

 

+

 

+
+
+

 

+

Verified + + Quadratic + + Virtual + + Substitution + + for + + Real + + Arithmetic + +

+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:Verified Quadratic Virtual Substitution for Real Arithmetic
+ Authors: + + Matias Scharager (mscharag /at/ cs /dot/ cmu /dot/ edu), + Katherine Cordwell (kcordwel /at/ cs /dot/ cmu /dot/ edu), + Stefan Mitsch (smitsch /at/ cs /dot/ cmu /dot/ edu) and + André Platzer (aplatzer /at/ cs /dot/ cmu /dot/ edu) +
Submission date:2021-10-02
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.
BibTeX: +
@article{Virtual_Substitution-AFP,
+  author  = {Matias Scharager and Katherine Cordwell and Stefan Mitsch and André Platzer},
+  title   = {Verified Quadratic Virtual Substitution for Real Arithmetic},
+  journal = {Archive of Formal Proofs},
+  month   = oct,
+  year    = 2021,
+  note    = {\url{https://isa-afp.org/entries/Virtual_Substitution.html},
+            Formal proof development},
+  ISSN    = {2150-914x},
+}
+
License:BSD License
Depends on:Polynomials
+ +

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + \ 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,5759 +1,5770 @@ Archive of Formal Proofs

 

 

 

 

 

 

Archive of Formal Proofs

 

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

A development version of the archive is available as well.

 

 

+ + +
2021
+ 2021-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, + Katherine Cordwell, Yong Kiam Tan - and André Platzer + 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 + 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,548 +1,562 @@ 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. - 24 Sep 2021 00:00:00 +0000 + 02 Oct 2021 00:00:00 +0000 + + Verified Quadratic Virtual Substitution for Real Arithmetic + https://www.isa-afp.org/entries/Virtual_Substitution.html + https://www.isa-afp.org/entries/Virtual_Substitution.html + Matias Scharager, Katherine Cordwell, Stefan Mitsch, André Platzer + 02 Oct 2021 00:00:00 +0000 + +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. + Soundness and Completeness of an Axiomatic System for First-Order Logic https://www.isa-afp.org/entries/FOL_Axiomatic.html https://www.isa-afp.org/entries/FOL_Axiomatic.html Asta Halkjær From 24 Sep 2021 00:00:00 +0000 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. Complex Bounded Operators https://www.isa-afp.org/entries/Complex_Bounded_Operators.html https://www.isa-afp.org/entries/Complex_Bounded_Operators.html Jose Manuel Rodriguez Caballero, Dominique Unruh 18 Sep 2021 00:00:00 +0000 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 (<em>cblinfun</em>) 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 <a href="Jordan_Normal_Form.html">Jordan_Normal_Form</a> AFP entry. A Formalization of Weighted Path Orders and Recursive Path Orders https://www.isa-afp.org/entries/Weighted_Path_Order.html https://www.isa-afp.org/entries/Weighted_Path_Order.html Christian Sternagel, René Thiemann, Akihisa Yamada 16 Sep 2021 00:00:00 +0000 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&ndash;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. Extension of Types-To-Sets https://www.isa-afp.org/entries/Types_To_Sets_Extension.html https://www.isa-afp.org/entries/Types_To_Sets_Extension.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 In their article titled <i>From Types to Sets by Local Type Definitions in Higher-Order Logic</i> and published in the proceedings of the conference <i>Interactive Theorem Proving</i> 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 <i>type-based theorems</i> to more flexible <i>set-based theorems</i>, collectively referred to as <i>Types-To-Sets</i>. 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 <i>Smooth Manifolds and Types to Sets for Linear Algebra in Isabelle/HOL</i> that was written by Fabian Immler and Bohua Zhan and published in the proceedings of the <i>International Conference on Certified Programs and Proofs</i> in 2019. IDE: Introduction, Destruction, Elimination https://www.isa-afp.org/entries/Intro_Dest_Elim.html https://www.isa-afp.org/entries/Intro_Dest_Elim.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 The article provides the command <b>mk_ide</b> for the object logic Isabelle/HOL of the formal proof assistant Isabelle. The command <b>mk_ide</b> enables the automated synthesis of the introduction, destruction and elimination rules from arbitrary definitions of constant predicates stated in Isabelle/HOL. Conditional Transfer Rule https://www.isa-afp.org/entries/Conditional_Transfer_Rule.html https://www.isa-afp.org/entries/Conditional_Transfer_Rule.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 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. Conditional Simplification https://www.isa-afp.org/entries/Conditional_Simplification.html https://www.isa-afp.org/entries/Conditional_Simplification.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 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 <i>auto</i>, 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. Category Theory for ZFC in HOL III: Universal Constructions https://www.isa-afp.org/entries/CZH_Universal_Constructions.html https://www.isa-afp.org/entries/CZH_Universal_Constructions.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 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 <i>Category Theory for ZFC in HOL II: Elementary Theory of 1-Categories</i>. Category Theory for ZFC in HOL I: Foundations: Design Patterns, Set Theory, Digraphs, Semicategories https://www.isa-afp.org/entries/CZH_Foundations.html https://www.isa-afp.org/entries/CZH_Foundations.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 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 <i>V</i> 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 <i>Set-Theoretical Foundations of Category Theory</i> 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 <i>V</i> embedded into a stage of the von Neumann hierarchy. Category Theory for ZFC in HOL II: Elementary Theory of 1-Categories https://www.isa-afp.org/entries/CZH_Elementary_Categories.html https://www.isa-afp.org/entries/CZH_Elementary_Categories.html Mihails Milehins 06 Sep 2021 00:00:00 +0000 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 <i>Category Theory for ZFC in HOL I: Foundations: Design Patterns, Set Theory, Digraphs, Semicategories</i>. A data flow analysis algorithm for computing dominators https://www.isa-afp.org/entries/Dominance_CHK.html https://www.isa-afp.org/entries/Dominance_CHK.html Nan Jiang 05 Sep 2021 00:00:00 +0000 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. Solving Cubic and Quartic Equations https://www.isa-afp.org/entries/Cubic_Quartic_Equations.html https://www.isa-afp.org/entries/Cubic_Quartic_Equations.html René Thiemann 03 Sep 2021 00:00:00 +0000 <p>We formalize Cardano's formula to solve a cubic equation $$ax^3 + bx^2 + cx + d = 0,$$ as well as Ferrari's formula to solve a quartic equation. We further turn both formulas into executable algorithms based on the algebraic number implementation in the AFP. To this end we also slightly extended this library, namely by making the minimal polynomial of an algebraic number executable, and by defining and implementing $n$-th roots of complex numbers.</p> Logging-independent Message Anonymity in the Relational Method https://www.isa-afp.org/entries/Logging_Independent_Anonymity.html https://www.isa-afp.org/entries/Logging_Independent_Anonymity.html Pasquale Noce 26 Aug 2021 00:00:00 +0000 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. The Theorem of Three Circles https://www.isa-afp.org/entries/Three_Circles.html https://www.isa-afp.org/entries/Three_Circles.html Fox Thomson, Wenda Li 21 Aug 2021 00:00:00 +0000 The Descartes test based on Bernstein coefficients and Descartes’ rule of signs effectively (over-)approximates the number of real roots of a univariate polynomial over an interval. In this entry we formalise the theorem of three circles, which gives sufficient conditions for when the Descartes test returns 0 or 1. This is the first step for efficient root isolation. Fresh identifiers https://www.isa-afp.org/entries/Fresh_Identifiers.html https://www.isa-afp.org/entries/Fresh_Identifiers.html Andrei Popescu, Thomas Bauereiss 16 Aug 2021 00:00:00 +0000 This entry defines a type class with an operator returning a fresh identifier, given a set of already used identifiers and a preferred identifier. The entry provides a default instantiation for any infinite type, as well as executable instantiations for natural numbers and strings. CoSMed: A confidentiality-verified social media platform https://www.isa-afp.org/entries/CoSMed.html https://www.isa-afp.org/entries/CoSMed.html Thomas Bauereiss, Andrei Popescu 16 Aug 2021 00:00:00 +0000 This entry contains the confidentiality verification of the (functional kernel of) the CoSMed social media platform. The confidentiality properties are formalized as instances of BD Security [<a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">1</a>, <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">2</a>]. An innovation in the deployment of BD Security compared to previous work is the use of dynamic declassification triggers, incorporated as part of inductive bounds, for providing stronger guarantees that account for the repeated opening and closing of access windows. To further strengthen the confidentiality guarantees, we also prove "traceback" properties about the accessibility decisions affecting the information managed by the system. CoSMeDis: A confidentiality-verified distributed social media platform https://www.isa-afp.org/entries/CoSMeDis.html https://www.isa-afp.org/entries/CoSMeDis.html Thomas Bauereiss, Andrei Popescu 16 Aug 2021 00:00:00 +0000 This entry contains the confidentiality verification of the (functional kernel of) the CoSMeDis distributed social media platform presented in [<a href="https://doi.org/10.1109/SP.2017.24">1</a>]. CoSMeDis is a multi-node extension the CoSMed prototype social media platform [<a href="https://doi.org/10.1007/978-3-319-43144-4_6">2</a>, <a href="https://doi.org/10.1007/s10817-017-9443-3">3</a>, <a href="https://www.isa-afp.org/entries/CoSMed.html">4</a>]. The confidentiality properties are formalized as instances of BD Security [<a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">5</a>, <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">6</a>]. The lifting of confidentiality properties from single nodes to the entire CoSMeDis network is performed using compositionality and transport theorems for BD Security, which are described in [<a href="https://doi.org/10.1109/SP.2017.24">1</a>] and formalized in a separate <a href="https://www.isa-afp.org/entries/BD_Security_Compositional.html">AFP entry</a>. CoCon: A Confidentiality-Verified Conference Management System https://www.isa-afp.org/entries/CoCon.html https://www.isa-afp.org/entries/CoCon.html Andrei Popescu, Peter Lammich, Thomas Bauereiss 16 Aug 2021 00:00:00 +0000 This entry contains the confidentiality verification of the (functional kernel of) the CoCon conference management system [<a href="https://doi.org/10.1007/978-3-319-08867-9_11">1</a>, <a href="https://doi.org/10.1007/s10817-020-09566-9">2</a>]. The confidentiality properties refer to the documents managed by the system, namely papers, reviews, discussion logs and acceptance/rejection decisions, and also to the assignment of reviewers to papers. They have all been formulated as instances of BD Security [<a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">3</a>, <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">4</a>] and verified using the BD Security unwinding technique. Compositional BD Security https://www.isa-afp.org/entries/BD_Security_Compositional.html https://www.isa-afp.org/entries/BD_Security_Compositional.html Thomas Bauereiss, Andrei Popescu 16 Aug 2021 00:00:00 +0000 Building on a previous <a href="https://www.isa-afp.org/entries/Bounded_Deducibility_Security.html">AFP entry</a> that formalizes the Bounded-Deducibility Security (BD Security) framework <a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">[1]</a>, we formalize compositionality and transport theorems for information flow security. These results allow lifting BD Security properties from individual components specified as transition systems, to a composition of systems specified as communicating products of transition systems. The underlying ideas of these results are presented in the papers <a href="https://doi.org/10.4230/LIPIcs.ITP.2021.3">[1]</a> and <a href="https://doi.org/10.1109/SP.2017.24">[2]</a>. The latter paper also describes a major case study where these results have been used: on verifying the CoSMeDis distributed social media platform (itself formalized as an <a href="https://www.isa-afp.org/entries/CoSMeDis.html">AFP entry</a> that builds on this entry). Combinatorial Design Theory https://www.isa-afp.org/entries/Design_Theory.html https://www.isa-afp.org/entries/Design_Theory.html Chelsea Edmonds, Lawrence Paulson 13 Aug 2021 00:00:00 +0000 Combinatorial design theory studies incidence set systems with certain balance and symmetry properties. It is closely related to hypergraph theory. This formalisation presents a general library for formal reasoning on incidence set systems, designs and their applications, including formal definitions and proofs for many key properties, operations, and theorems on the construction and existence of designs. Notably, this includes formalising t-designs, balanced incomplete block designs (BIBD), group divisible designs (GDD), pairwise balanced designs (PBD), design isomorphisms, and the relationship between graphs and designs. A locale-centric approach has been used to manage the relationships between the many different types of designs. Theorems of particular interest include the necessary conditions for existence of a BIBD, Wilson's construction on GDDs, and Bose's inequality on resolvable designs. Parts of this formalisation are explored in the paper "A Modular First Formalisation of Combinatorial Design Theory", presented at CICM 2021. Relational Forests https://www.isa-afp.org/entries/Relational_Forests.html https://www.isa-afp.org/entries/Relational_Forests.html Walter Guttmann 03 Aug 2021 00:00:00 +0000 We study second-order formalisations of graph properties expressed as first-order formulas in relation algebras extended with a Kleene star. The formulas quantify over relations while still avoiding quantification over elements of the base set. We formalise the property of undirected graphs being acyclic this way. This involves a study of various kinds of orientation of graphs. We also verify basic algorithms to constructively prove several second-order properties. Schutz' Independent Axioms for Minkowski Spacetime https://www.isa-afp.org/entries/Schutz_Spacetime.html https://www.isa-afp.org/entries/Schutz_Spacetime.html Richard Schmoetten, Jake Palmer, Jacques Fleuriot 27 Jul 2021 00:00:00 +0000 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. Finitely Generated Abelian Groups https://www.isa-afp.org/entries/Finitely_Generated_Abelian_Groups.html https://www.isa-afp.org/entries/Finitely_Generated_Abelian_Groups.html Joseph Thommes, Manuel Eberl 07 Jul 2021 00:00:00 +0000 This article deals with the formalisation of some group-theoretic results including the fundamental theorem of finitely generated abelian groups characterising the structure of these groups as a uniquely determined product of cyclic groups. Both the invariant factor decomposition and the primary decomposition are covered. Additional work includes results about the direct product, the internal direct product and more group-theoretic lemmas. SpecCheck - Specification-Based Testing for Isabelle/ML https://www.isa-afp.org/entries/SpecCheck.html https://www.isa-afp.org/entries/SpecCheck.html Kevin Kappelmann, Lukas Bulwahn, Sebastian Willenbrink 01 Jul 2021 00:00:00 +0000 SpecCheck is a <a href="https://en.wikipedia.org/wiki/QuickCheck">QuickCheck</a>-like testing framework for Isabelle/ML. You can use it to write specifications for ML functions. SpecCheck then checks whether your specification holds by testing your function against a given number of generated inputs. It helps you to identify bugs by printing counterexamples on failure and provides you timing information. SpecCheck is customisable and allows you to specify your own input generators, test output formats, as well as pretty printers and shrinking functions for counterexamples among other things. Van der Waerden's Theorem https://www.isa-afp.org/entries/Van_der_Waerden.html https://www.isa-afp.org/entries/Van_der_Waerden.html Katharina Kreuzer, Manuel Eberl 22 Jun 2021 00:00:00 +0000 This article formalises the proof of Van der Waerden's Theorem from Ramsey theory. Van der Waerden's Theorem states that for integers $k$ and $l$ there exists a number $N$ which guarantees that if an integer interval of length at least $N$ is coloured with $k$ colours, there will always be an arithmetic progression of length $l$ of the same colour in said interval. The proof goes along the lines of \cite{Swan}. The smallest number $N_{k,l}$ fulfilling Van der Waerden's Theorem is then called the Van der Waerden Number. Finding the Van der Waerden Number is still an open problem for most values of $k$ and $l$. MiniSail - A kernel language for the ISA specification language SAIL https://www.isa-afp.org/entries/MiniSail.html https://www.isa-afp.org/entries/MiniSail.html Mark Wassell 18 Jun 2021 00:00:00 +0000 MiniSail is a kernel language for Sail, an instruction set architecture (ISA) specification language. Sail is an imperative language with a light-weight dependent type system similar to refinement type systems. From an ISA specification, the Sail compiler can generate theorem prover code and C (or OCaml) to give an executable emulator for an architecture. The idea behind MiniSail is to capture the key and novel features of Sail in terms of their syntax, typing rules and operational semantics, and to confirm that they work together by proving progress and preservation lemmas. We use the Nominal2 library to handle binding. Public Announcement Logic https://www.isa-afp.org/entries/Public_Announcement_Logic.html https://www.isa-afp.org/entries/Public_Announcement_Logic.html Asta Halkjær From 17 Jun 2021 00:00:00 +0000 This work is a formalization of public announcement logic with countably many agents. It includes proofs of soundness and completeness for a variant of the axiom system PA + DIST! + NEC!. The completeness proof builds on the Epistemic Logic theory. A Shorter Compiler Correctness Proof for Language IMP https://www.isa-afp.org/entries/IMP_Compiler.html https://www.isa-afp.org/entries/IMP_Compiler.html Pasquale Noce 04 Jun 2021 00:00:00 +0000 This paper presents a compiler correctness proof for the didactic imperative programming language IMP, introduced in Nipkow and Klein's book on formal programming language semantics (version of March 2021), whose size is just two thirds of the book's proof in the number of formal text lines. As such, it promises to constitute a further enhanced reference for the formal verification of compilers meant for larger, real-world programming languages. The presented proof does not depend on language determinism, so that the proposed approach can be applied to non-deterministic languages as well. As a confirmation, this paper extends IMP with an additional non-deterministic choice command, and proves compiler correctness, viz. the simulation of compiled code execution by source code, for such extended language. Lyndon words https://www.isa-afp.org/entries/Combinatorics_Words_Lyndon.html https://www.isa-afp.org/entries/Combinatorics_Words_Lyndon.html Štěpán Holub, Štěpán Starosta 24 May 2021 00:00:00 +0000 Lyndon words are words lexicographically minimal in their conjugacy class. We formalize their basic properties and characterizations, in particular the concepts of the longest Lyndon suffix and the Lyndon factorization. Most of the work assumes a fixed lexicographical order. Nevertheless we also define the smallest relation guaranteeing lexicographical minimality of a given word (in its conjugacy class). - - Graph Lemma - https://www.isa-afp.org/entries/Combinatorics_Words_Graph_Lemma.html - https://www.isa-afp.org/entries/Combinatorics_Words_Graph_Lemma.html - Štěpán Holub, Štěpán Starosta - 24 May 2021 00:00:00 +0000 - -Graph lemma quantifies the defect effect of a system of word -equations. That is, it provides an upper bound on the rank of the -system. We formalize the proof based on the decomposition of a -solution into its free basis. A direct application is an alternative -proof of the fact that two noncommuting words form a code. - diff --git a/web/statistics.html b/web/statistics.html --- a/web/statistics.html +++ b/web/statistics.html @@ -1,307 +1,307 @@ Archive of Formal Proofs

 

 

 

 

 

 

Statistics

 

Statistics

- - - - + + + +
Number of Articles:630
Number of Authors:398
Number of lemmas:~182,900
Lines of Code:~3,183,900
Number of Articles:631
Number of Authors:400
Number of lemmas:~183,600
Lines of Code:~3,206,700

Most used AFP articles:

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

Growth in number of articles:

Growth in lines of code:

Growth in number of authors:

Size of articles:

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

 

 

 

 

 

 

Index by Topic

 

Computer science

Artificial intelligence

Automata and formal languages

Algorithms

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

Concurrency

Data structures

Functional programming

Hardware

SPARCv8  

Machine learning

Networks

Programming languages

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

Analysis

Probability theory

Number theory

Games and economics

Geometry

Topology

Graph theory

Combinatorics

Category theory

Physics

Misc

Tools

\ No newline at end of file