Datasets:
AI4M
/

text
stringlengths
0
3.34M
""" PyComplex(real, imag) Represents `complex(real, imag)`. """ struct PyComplex <: PyObject real :: Any imag :: Any end export PyComplex """ PyRange(start, stop, step) Represents `range(start, stop, step)`. """ struct PyRange <: PyObject start :: Any stop :: Any step :: Any end export PyRange """ PySlice(start, stop, step) Represents `slice(start, stop, step)`. """ struct PySlice <: PyObject start :: Any stop :: Any step :: Any end export PySlice """ PyList(values) Represents a `list`. """ struct PyList <: PyObject values :: Vector{Any} PyList(xs) = new(Any[x for x in xs]) PyList() = new(Any[]) end export PyList """ PyTuple(values) Represents a `tuple`. """ struct PyTuple <: PyObject values :: Vector{Any} PyTuple(xs) = new(Any[x for x in xs]) PyTuple() = new(Any[]) end export PyTuple """ PyDict(items) Represents a `dict`. """ struct PyDict <: PyObject items :: Vector{Pair{Any,Any}} PyDict(xs) = new(Pair{Any,Any}[x for x in xs]) PyDict() = new(Pair{Any,Any}[]) end export PyDict """ PySet(values) Represents a `set`. """ struct PySet <: PyObject values :: Vector{Any} PySet(xs) = new(Any[x for x in xs]) PySet() = new(Any[]) end export PySet """ PyFrozenSet(values) Represents a `frozenset`. """ struct PyFrozenSet <: PyObject values :: Vector{Any} PyFrozenSet(xs) = new(Any[x for x in xs]) PyFrozenSet() = new(Any[]) end export PyFrozenSet """ PyBytes(values) Represents a `bytes`. """ struct PyBytes <: PyObject values :: Vector{UInt8} PyBytes(xs) = new(UInt8[x for x in xs]) PyBytes() = new(UInt8[]) end export PyBytes """ PyByteArray(values) Represents a `bytearray`. """ struct PyByteArray <: PyObject values :: Vector{UInt8} PyByteArray(xs) = new(UInt8[x for x in xs]) PyByteArray() = new(UInt8[]) end export PyByteArray """ PyArray{T}(values) Represents an `array.array`. """ struct PyArray{T} <: PyObject values :: Vector{T} PyArray{T}(xs) where {T} = new{T}(T[x for x in xs]) PyArray{T}() where {T} = new{T}(T[]) end export PyArray
/** * Copyright (C) 2017 by dan (Daniel Friedrich) * * This file is part of project spoon * a c++14 (de)serialization library for (binary) protocols * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef SRC_SPOON_ENGINE_OPTIONAL_HPP_ #define SRC_SPOON_ENGINE_OPTIONAL_HPP_ #include <spoon/traits/has_call_operator.hpp> #include <spoon/engine/base.hpp> #include <spoon.hpp> #include <boost/optional.hpp> #include <type_traits> #include <utility> namespace spoon { namespace engine { namespace detail { template<typename Gear, typename ExpectedProvider> struct optional_with_expected_provider : Gear , ExpectedProvider { using size_type = std::size_t; using attribute_type = boost::optional<typename Gear::attribute_type>; template<typename FwdGear, typename FwdExpectedProvider> constexpr optional_with_expected_provider(FwdGear&& fwd_gear, FwdExpectedProvider&& fwd_expected_provider) : Gear{std::forward<FwdGear>(fwd_gear)} , ExpectedProvider{std::forward<FwdExpectedProvider>(fwd_expected_provider)} {} auto& as_gear() const noexcept { return static_cast< const Gear&>(*this); } auto& as_expected_provider() const noexcept { return static_cast< const ExpectedProvider&>(*this); } /** * handling infinitive, min and max */ template<typename Sink, typename OptAttr> inline auto serialize(bool& pass, Sink& sink, OptAttr&& opt_attr) const -> void { const auto is_expected = as_expected_provider()(); if(opt_attr && is_expected) { pass = spoon::serialize(sink, as_gear(), opt_attr.value()); } } /** deserialize */ template<typename Iterator, typename OptAttr> inline auto deserialize(bool& pass, Iterator& start, const Iterator& end, OptAttr& opt_attr) const -> void { using value_type = typename OptAttr::value_type; const auto is_expected = as_expected_provider()(); if(is_expected) { value_type value{}; pass = spoon::deserialize(start, end, as_gear(), value); if(pass) { opt_attr = value; } } } }; template<typename Gear> struct optional : gear<optional<Gear>, typename Gear::attribute_type>, Gear { //using attribute_type = boost::optional<typename Gear::attribute_type>; constexpr optional(const Gear& fwd_gears) : Gear{fwd_gears} { } constexpr optional(Gear&& fwd_gears) : Gear{std::forward<Gear>(fwd_gears)} { } constexpr auto& as_gear() const noexcept { return static_cast< const Gear&>(*this); } template<typename ExpectedProvider, typename = std::enable_if_t<spoon::traits::has_call_operator<ExpectedProvider>::value> > constexpr inline auto operator()(ExpectedProvider&& expected_provider) const { return optional_with_expected_provider<Gear, ExpectedProvider>{std::move(as_gear()), std::forward<ExpectedProvider>(expected_provider)}; } /** * */ template<typename Sink, typename OptAttr> constexpr inline auto serialize(bool& pass, Sink& sink, OptAttr&& opt_attr) const -> void { if(opt_attr) { pass = spoon::serialize(sink, as_gear(), opt_attr.value()); } } /** deserialize */ template<typename Iterator, typename OptAttr> constexpr inline auto deserialize(bool& pass, Iterator& start, const Iterator& end, OptAttr& opt_attr) const -> void { using value_type = typename OptAttr::value_type; value_type value{}; if(spoon::deserialize(start, end, as_gear(), value)) { opt_attr = value; } } }; }}}// spoon::engine::detail namespace spoon { namespace engine { struct optional { template<typename FwdGear> constexpr auto inline operator[](FwdGear&& fwd_gear) const { return detail::optional<FwdGear>(std::forward<FwdGear>(fwd_gear)); } template<typename Gear> constexpr auto inline operator[](const Gear& gear) const { return detail::optional<Gear>(gear); } template<typename FwdGear> constexpr auto inline operator()(FwdGear&& fwd_gear) const { return detail::optional<FwdGear>(std::forward<FwdGear>(fwd_gear)); } template<typename Gear> constexpr auto inline operator()(const Gear& gear) const { return detail::optional<Gear>(gear); } }; }} //spoon::engine namespace spoon { constexpr auto optional = engine::optional{}; } // spoon #endif /* SRC_SPOON_ENGINE_OPTIONAL_HPP_ */
\documentclass[pdftex,a4paper]{extarticle} \usepackage[utf8]{inputenc} \title{Functional Reactive Programming and its application in Functional Game Programming} \author{{\large David Kraeutmann, Philip Kindermann} \\ {\em RWTH Aachen}} \usepackage{natbib} \usepackage{graphicx} \usepackage{url} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsthm} \usepackage{enumitem} \usepackage{minted} \usepackage{parcolumns} \usepackage[normalem]{ulem} \usepackage{multicol} \usepackage{caption} \usepackage[a4paper, left=2.5cm, right=3cm, top=2.5cm, bottom=2.5cm]{geometry} \usepackage{float} \usepackage{pgfplots} \usepackage{tikz} \usetikzlibrary{shapes,snakes} \usetikzlibrary{scopes,backgrounds} \usetikzlibrary{fit, positioning} \usetikzlibrary{calc, matrix} \tikzset{pure function/.style={draw=black, circle, minimum width=3em}} \tikzset{signal function/.style={draw=black, rectangle, minimum width=3em}} \tikzset{signal function with state/.style={draw=black, rectangle split, rectangle split parts = 2, rectangle split draw splits = false, minimum width=6em}} \usepackage{fancyvrb} \DefineShortVerb{\|} \VerbatimFootnotes \begin{document} \maketitle \section{Introduction} Real-time programming is at its core quite imperative --- read input, update state, write output, repeat. That requires you to describe \emph{what to do} instead of \emph{what you want}, which leads to a lot of boilerplate when just trying to model a state update. However, without additional thought even programs written using declarative programming lose their unique benefits due to the imperative style imposed by the update loop, a large amount of state, and discrete-time semantics. \begin{listing}[ht] \inputminted[breaklines=true]{haskell}{Loop.hs} \captionof{listing}{Update loop of a Haskell program} \label{lst:imperative} \end{listing} To address these issues, Elliott/Hudak formulated \emph{Functional Reactive Programming} (FRP) in \cite{ElliottHudak97:Fran}. FRP evolved in a myriad of different directions and has applications in robotics, computer vision, animation and games \cite{haskell-wiki-yampa}. We'll provide an overview of FRP in Section~\ref{sec:frp} and focus on Elm in particular as implementations in Section~\ref{sec:frameworks}. A small game written is presented (Section~\ref{sec:game}) and example implementations of common patterns in game design are discussed. In Section~\ref{sec:conclusion} we provide an overview of benefits and unsolved problems of functional game systems. \section{Functional reactive programming} \label{sec:frp} The core idea of FRP is to provide a set of data types that capture values changing over time. While there are many implementations and approaches to FRP, there are two current approaches: classic and arrows-based functional reactive programming. \subsection{Classic FRP} The initial concept of FRP as used in implementations such as Fran \cite{ElliottHudak97:Fran} or reactive \cite{haskell-wiki-reactive} is based of a few central concepts \cite{conal-what-is-frp,Elliott2009-push-pull-frp}: \begin{itemize} \item Time-variant values are first-class, defined similar to \cite{haskell-wiki-frp} \inputminted{haskell}{Behaviour.hs} \item Behaviours are created by composing implementation-provided primitives or lifting pure functions into a primitive \item Discrete phenomena are represented by events \begin{minted}{haskell} data OccurTime = Already | Never | After Time newtype Event a = Event { occurences :: [(OccurTime, a)] } \end{minted} For instance, the contents of an event \mintinline{haskell}{keysPressed :: Event [Key]} after pressing A for a second together with W for half a second and then tapping Space for 0.1s after 1.5s would be \begin{minted}{haskell} occurrences keysPressed = [(Always, []), (After 0, [KeyA, KeyW]), (After 0.5, [KeyA]), (After 1, []), (After 1.5, [KeySpace]), (After 1.6, [])] \end{minted} \item For the sake of simplicity and composability, time is assumed to be continuous and discretisation is only introduced when needed. \end{itemize} While classical FRP served as an important milestone in the development of reactive programming in a purely functional environment, arrows allowed for a more composable expression of these principles. \subsection{Arrow-based FRP} An arrow is a computation that's \emph{like} a function in the sense that it has an input and an output, but is not necessarily a pure function like \mintinline{haskell}{map} or \mintinline{haskell}{(+)}. For example, the usual function type |(->)| is an instance of |Arrow|. You can capture these ideas with a Haskell type class taking two type arguments, an input type and an output type, and a set of laws that we'll illustrate using diagrams. \begin{figure*}[ht] \centering \begin{tikzpicture}[node distance=2cm] \node[pure function] (pure) {$f$}; \node[signal function, fit=(pure), minimum width=6em] (arrf) {}; \coordinate[left of=arrf] (in); \coordinate[right of=arrf] (out); \draw [->, near start] (in) to node[auto] {$b$} (pure); \draw [->, near end] (pure) to node[auto] {$c$} (out); \end{tikzpicture} \caption{arr $f$} \end{figure*} \begin{minted}{haskell} class Arrow a where -- Any pure function is a generalised computation arr :: (b -> c) -> a b c \end{minted} \begin{figure*}[ht] \centering \begin{tikzpicture}[node distance=2cm] \node[signal function, minimum width=2.8em] (f) {$f$}; \coordinate[below of=f, node distance=2.8em] (lol); \node[signal function, fit=(f)(lol), minimum width=6em] (arrf) {}; \coordinate[left of=f] (in); \coordinate[below of=in, node distance=2.3em] (in2); \coordinate[right of=f] (out); \coordinate[below of=out, node distance=2.3em] (out2); \draw [->, near start] (in) to node[auto] {b} (f); \draw [->, near end] (f) to node[auto] {c} (out); \draw [->] (in2) to node[auto] {d} (out2); \end{tikzpicture} \caption{first $f$} \end{figure*} \begin{minted}{haskell} -- Apply the computation to part of the input, and ignore the other first :: a b c -> a (b,d) (c,d) \end{minted} \begin{figure*}[ht] \centering \begin{tikzpicture}[node distance=2cm] \node[signal function, minimum width=3em] (f) {$f$}; \node[signal function, minimum width=3em, right of=f] (g) {$g$}; \node[signal function, fit=(f) (g), minimum width=6em] (arrf) {}; \coordinate[left of=f] (in); \coordinate[right of=g] (out); \draw [->, near start] (in) to node[auto] {b} (f); \draw [->] (f) to node[auto] {c} (g); \draw [->, near end] (g) to node[auto] {d} (out); \end{tikzpicture} \caption{$f \ggg g$} \end{figure*} \begin{minted}{haskell} -- Computations can be composed similar to (.) (>>>) :: a b c -> a c d -> a b d \end{minted} In our context, this allows us to store opaque (that is, not visible to the user) state along a function in a construct called \emph{signal functions}, which are an instance of |Arrow|. Another instance is the pure function type \mintinline{haskell}{(->)} with rather straightforward definitions: \mintinline{haskell}{arr = id}, \mintinline{haskell}{first f = \(a, b) -> (f a, b)} and \mintinline{haskell}{f >>> g = g . f}. Every other instance has to behave more or less similar to this one due to \mintinline{haskell}{arr :: Arrow a => (b -> c) -> a b c} and internal consistency requirements mandated by |Arrow| laws\cite{Hughes98generalisingmonads}. These are used in recent FRP frameworks such as Yampa \cite{hudak2003arrows}, Netwire \cite{haskell-wiki-netwire} and Elm \cite{elm-lang} (albeit in a less rigorous form) and as such we'll be giving an overview over their usage. \subsubsection{Signals and signal functions} \begin{figure}[ht] \centering \begin{tikzpicture}[node distance=2cm] \node[signal function with state, minimum width=6em] (arrf) {$f$ \nodepart{second} $[\: \operatorname{state}(t) \: ]$}; \coordinate[left of=arrf] (in); \coordinate[right of=arrf] (out); \draw [->] (in) to node[auto] {$x(t)$} (arrf); \draw [->] (arrf) to node[auto] {$y(t)$} (out); \end{tikzpicture} \captionof{figure}{Signal function} \label{fig:sigfunc} \end{figure} A \emph{signal} is essentially a |Behaviour| from classical FRP --- a value changing over time. \emph{Signal functions} are, as the name suggests, functions on signals, but also encapsulate state that is only dependent on the input history. State isn't always used; for instance |integral| is a stateful function while |arr| is stateless. That is, the output \(y(t)\) of a stateless function \(f(x)\) is only dependent on the input \(x(t)\), whereas for a stateful function $f(x, state)$ the output depends on a state function \(\operatorname{state}(t)\). This state function summarises the input history \(x(t')\) over the interval \(t' \in [0,t]\). It is also useful that signal functions can inhibit --- that is, produce no value at all, similar to how \mintinline{haskell}{data Either a b = Left a | Right b} is used for error catching with \mintinline{haskell}{Left} and the actual value with \mintinline{haskell}{Right}. Using that you can still have a total signal function while supporting missing values --- if you were to use |undefined| or a similar bottom value, your program would either crash or not perform properly\footnote{due to the denotational semantics of bottom values, meaningful pattern matching on them is fundamentally impossible; trying to do e.g. \mintinline{haskell}{case head xs of undefined -> 1; 'a' -> 0} would give a warning about overlapping pattern matching and always evaluate to 1, regardless whether |xs = []| or |xs = "a"| or anything else)}. For the purpose of game programming, we'll present a few combinators that are especially important. For the sake of simplicity, we'll define |SF a b| as a concrete signal function mapping a to b. Furthermore, we'll use monomorphic types like |Float -> Int| even when the underlying concept is valid for constrained polymorphic types like |Fractional a, Integral b => a -> b|. It should be noted that this is list is far from exhaustive and is only intended as an overview. \begin{itemize} \item In most games, movement input is mapped to change in velocity. In order to convert a velocity signal into a position signal, you need to integrate it: $x(t) = \int_{t_0}^t v(t') dt'$. This is pretty similar to a stateful signal function, and indeed it is. \begin{figure}[ht] \centering \begin{tikzpicture}[node distance=2cm] \node[signal function with state, minimum width=6em] (integral) {integral \nodepart{second} $\int_0^t v(t') dt'$}; \coordinate[left of=integral] (in); \coordinate[right of=integral] (out); \coordinate[above=1cm of integral] (opt); \draw [->] (in) to node[auto] {$v(t)$} (integral); \draw [->] (integral) to node[auto] {$x(t)$} (out); \draw [->] (opt) to node[auto] {$x_0$} (integral); \end{tikzpicture} \end{figure} For example, you could write \mintinline{haskell}{speed >>> integral 0} to construct a position signal function, and \mintinline[breaklines]{haskell}{gravity >>> integral 0 >>> integral 100} to do the same for a object in free fall from 100m. \item A set of signal functions operating on intervals. For example, \mintinline{haskell}{after :: Time -> SF a b} produces a value after a time period, \mintinline{haskell}{for :: Time -> SF a b} produces a value for a time period, and so on. \mintinline{haskell}{after 60 >>> for 70 >>> gameOver} would give you a 60 second time limit on your game, after which a game over screen displays for ten seconds (after that the wire inhibits forever). Note that \mintinline{haskell}{(>>>)} does not reset local time (unlike switching, detailed below) and as a result \mintinline{haskell}{after}, \mintinline{haskell}{for} and \mintinline{haskell}{gameOver} are at the same time at all times, even if they're not actually being evaluated. This leads to $70 - 60 = 10$ seconds of game over screen being shown. \item In order to respond to discrete occurrences, we use an |Event| type similar to classical FRP. Let's say we want to start moving left when the |A| key is held down. The signal function \mintinline{haskell}{between :: SF (a, Event b, Event c) a} inhibits until the left event occurs and then produces until the right event happens. If we define \mintinline{plain}{keyUp, keyDown :: SF Key (Event Key)} we can then write (using Arrow do-notation\cite{ghcdocs-arrownotation}, which for the intents of this paper can be read just like regular, monadic do notation with |proc x| replaced by |\x|) \begin{minted}{haskell} moving Left = proc x -> do down <- keyDown "A" up <- keyUp "A" between (x, down, up) \end{minted} \begin{figure}[ht] \centering \begin{tikzpicture}[node distance=2cm] \node[signal function, minimum width=7em] (kd) {|keyDown "A"|}; \node[signal function, minimum width=7em, below=0.2cm of kd] (ku) {|keyUp "A"|}; \coordinate (key) at ($(kd)!0.5!(ku)$); \coordinate[above=1.25cm of key] (a); \coordinate[right=3cm of a] (b); \node[auto, right=3cm of key] (cond) {when $E_a$ but not $E_b$}; \coordinate[below=0.5em of cond] (align); \coordinate[left=0.5em of cond] (coll); \coordinate[right=0.5em of cond] (sym); \node[signal function with state, fit={(b) (cond) (coll) (sym) (align)}] (between) {|between| \nodepart{second}}; \draw[->] (kd) to node[above] {$E_a$} (cond); \draw[->] (ku) to node[below] {$E_b$} (cond); \coordinate (reala) at ($(a) + (-2cm,-8pt)$); \draw [->] (reala) to node[above, midway] {a} (reala-|between.west); \coordinate[right=1cm of between] (out); \draw [->] (between) to node[above] {a} (out); \end{tikzpicture} \end{figure} In fact, this is just syntactic sugar for \mintinline{haskell}{arr}, \mintinline{haskell}{first} and \mintinline{haskell}{(>>>)}, but the resulting expression would be much more complicated to understand, which is why we chose to use do-notation here. \item All of our previously introduced signal functions can only evolve with time, not be replaced with some other combinator when something happens. For this we use \emph{switching}, with the most important operator being \mintinline{haskell}{(-->) :: SF a b -> SF a b -> SF a b}. When you have \mintinline{haskell}{f = f1 --> f2}, then \mintinline{haskell}{f = f1} as long as f1 doesn't inhibit. When it inhibits, the signal function permanently switches to \mintinline{haskell}{f = f2}. As an example let's implement elastic collision with a surface. \inputminted[breaklines=true]{haskell}{Switch.hs} The |when| combinator inhibits when the predicate evaluates to |False|, so until we reach the wall's position we move. Once that happens we switch and start moving backwards. Note that when a switch occurs, local time resets. For example, \mintinline[breaklines]{haskell}{f = pure 1 >>> for 3 --> pure 2 >>> at 3} would evaluate to 1 from $t=0$ to $3$, inhibit for $t=3$ to $6$ and then produce $2$ forever after $t=6$ since as soon as \mintinline{haskell}{for} inhibited, the switch occured to \mintinline{haskell}{at}, which then starts producing after 3 seconds. Similarly, \mintinline{haskell}{g = pure 1 >>> for 1 --> pure 0 >>> for 1 --> g} would create a periodical signal function oscillating between 1 and 0 each second. \end{itemize} \section{FRP frameworks} \label{sec:frameworks} \subsection{Elm} Elm is a basic functional programming language which comes with many features. One of those features is the Time Traveling Debugger\cite{elm-debugger} which allows the developer of a game to see the change of it over the time and lets him travel forward and backward in his program to seek out bugs. It allows us to track our data and visualise our program. We could track our main character. Then we would analyse their respective record\cite{elm-record}. A data structure which we use to store data related to our character similar to objects.. Then we could see our bugs unwind and analyse what causes them so we are able to fix them easily. Another benefit is the feature of hot-swapping\cite{elm-swapping} which allows us to program more interactively as we modify running code. Hot-swapping is made possible in Elm through the separation of state and function which is achieved through purity. This means that we will always get the same results for the same arguments. Combined with the immutability of data we will get the same results when we rewind our Program without destroying our data. This is hardly achievable in imperative languages as they feature destructive updates. Those features are combined in the Elm Reactor\cite{elm-reactor} which is a development tool providing us with a strong foundation to maintain our program. At the core of an implementation of FRP with Elm is the use of Signals\cite{elm-signal} Elm provides us with a network that processes those signals for us called a signal graph. This makes the use of signals and programming functionally reactive easy. Another important basis for the implementation of our game is to provide a state for our game. Elm allows us to inhibit signals by the use of the foldp\cite{elm-signal} function. This function takes an update function, our starting state, and a signal as input returning a Signal. foldp does this by applying our update function every time our signal occurs onto our starting state returning a Signal representing our current state. \newline \begin{minted}{haskell} foldp : (a -> state -> state) -> state -> Signal a -> Signal state \end{minted} Additionally through the use of an update function we can store data with this function such as mouse clicks. {\tt mouseClicks} tracks the count of incoming mouse clicks. \newline \begin{minted}{haskell} clickCount = foldp (\click count -> count + 1) 0 Mouse.clicks \end{minted} Here our {\tt mouse.clicks} signal triggers our update function which increments our counter starting at 0 every time a mouse click occurs. Now we are provided with our functional implementations of state, objects and input giving us the basis to create games. \section{A functional game} \label{sec:game} In the following section we are going to implement pong with Elm according to the paradigms of FRP. But first we have to understand the basic structure of most games including pong in Elm. \subsection{Elm's architecture} In imperative language you can reach into objects and data structure at any given time. With functional programming languages we do not have this luxury as a programmer. Therefor we need to structure our code accordingly so we have the data at hand when we need it. A common architecture for this is the Model-View-Controller architecture\cite{wiki-mvc} that is used widely in multiple domains of programming such as web applications to structure code. Elm's common architecture\cite{elm-mvc} resembles this closely but isn't exactly the same. Elm's architecture divides our code into 4 parts. First one being the input in which we take our input from outside in our example the keyboard and the time which is given to us through signals. This part is often called the signal section as well as we string together our input streams in this section. The update takes our input and defines functions to move our game forward by changing the information of our model or how our view is being displayed. This is described as the controller in a classic MVC-architecture but in Elm this is split into 2 parts. The model stores most of the data of our game which is needed for our view, update and input to work. The view implements our visual representation of our game. It requests the information of our model according to our update every time an input occurs to represent our game. By separating our code into those parts we can change each easily without messing with our code. \subsection{Our Game} The first part of our game is importing the required libraries for our game. We import graphics, color and text libraries so we can easily display our pong court with written instructions on it. We need the keyboard and time libraries for our input. Lastly we need a window library to render our game. \inputminted [breaklines=true] {haskell}{pong(1).hs} \subsection{Model} First off we define our Pong Court with \inputminted [breaklines=true] {haskell}{pong(2a).hs} This makes it easier to change our court later on in the game development. Next we define a Union Type which behaves like our user-defined types in Haskell. This allows us to enumerate possible states. In this cast {\tt State} is used to store if our game is running in play our being paused and has yet to start. \inputminted [breaklines=true] {haskell}{pong(2b).hs} Now we define multiple type aliases. Those are used to have an alias declaration for our declared type in this case our records\cite{elm-record}. A record is a data type which stores multiple values of different types similar to structures in C. Type aliases and records combined allow us to define our own data types with a custom name as a synonym for said type making our game more concise and easier to understand. Our first one being the ball. Here we need a type alias representing a record which stores the position and velocity of the ball. We break this data down into their x and y components. \inputminted [breaklines=true] {haskell}{pong(3a).hs} Second we define the same properties for our {\tt Player} type alias which represent the paddle and its according position and movement but each player can score so we store their score as well. \inputminted [breaklines=true] {haskell}{pong(3b).hs} The next type alias represents all our game items. Our 2 players, the game state and our ball. \inputminted [breaklines=true] {haskell}{pong(3c).hs} Lastly we have a type alias for the input. We store a Boolean called space to check if the space bar was pressed and we can therefor start the next round. We store 2 directions with an integer. This integer is 1 if our players press w or cursor up to move their respective paddle upwards. It is 0 the players are not pressing up or down. It is -1 if they press s or cursor down to move their respective paddle downwards. \inputminted [breaklines=true] {haskell}{pong(3d).hs} Now we introduce 2 functions to initialise our type aliases in their default position. {\tt player} takes in a float and returns a {\tt Player} type with all values besides our x-coordinate set as 0. Our x-coordinate is set with the value of our input floating-point number. \inputminted [breaklines=true] {haskell}{pong(4a).hs} The {\tt defaultGame} uses this function to initialise the default game. It starts with the state being {\tt Pause} and the ball at {\tt (0, 0)} with a velocity of 200 units on each axis. The players are set according to the player function on opposing sides of the court. \inputminted [breaklines=true] {haskell}{pong(4b).hs} \subsection{Input} To track the time our game implements a time delta which is defined by the {\tt fps}\cite{elm-time} function. {\tt fps} takes in a number of frames per second and the resulting signal returns a sequence of time deltas. This sequence to correlates to the input amount of frames. With {\tt inSeconds} we take the Elm's underlying units of time and transform them into their respective values expressed in seconds. \inputminted [breaklines=true] {haskell}{pong(5a).hs} Now with our time set we can define our current input every time our time delta occurs. That is achieved by the {\tt sampleOn}\cite{elm-sampleOn} function that takes a sample from our second input signal (Our keyboard and time input) every time our first input signal occurs returning us a signal of samples. Here we model our paddles direction through the use of the keyboard library. Whenever a signal occurs through pressing wasd-keys or arrow-keys our WASD and arrows function return an record storing an integer for the x and y directions. With the appliance of {\tt .y} onto those functions we only receive the y component. Through the definition of {\tt WASD} and {\tt arrows} we receive 1 for an upwards direction through the use of w or the up arrow and -1 with s and the down arrow. 0 is returned if no button or those with no impact on our y component were pressed. Note the use of {\tt\textless$\vert$}. {\tt\textless$\vert$} and {\tt$\vert$\textgreater} are operators to apply functions to avoid parentheses. In our case {\tt\textless$\vert$} takes the input on the right and applies it as a parameter of {\tt sampleOn}. \inputminted [breaklines=true] {haskell}{pong(5b).hs} \subsection{Update} To progress our game forward we will implement the update section of our game. First we break our interactions into smaller function to structure our code. {\tt near} checks if {\tt k} is within {\tt c} of {\tt n} which will be used to check for collisions of our ball and the player's paddles. \inputminted [ breaklines=true] {haskell}{pong(6).hs} {\tt within} uses near to check if the ball is within the paddles collision box. . We check if the ball is within 8 units of our x-axis to the players paddle and 20 units within the y-axis to validate if the ball is near a paddle. \inputminted [breaklines=true] {haskell}{pong(7).hs} {\tt stepV} changes our velocity according to a collision. According to the type of the collision the direction of our ball is changed with {\tt abs v} which turn our negative velocity value into a positive or vice versa with {\tt 0 - abs v}. If no collision is occurring the ball keeps moving without alternation. We will iterate this to update the position and velocity of our ball. \inputminted [breaklines=true] {haskell}{pong(8).hs} Next is {\tt physicsUpdate} that is used to translate the values of velocity of our players and the ball to their new position with each occurrence of our time delta. This allows us to actually display movement. Here we update our variable according to Elm's syntax as we access our record left of {\tt$\vert$} and update our variables left of {\tt \textless-} to their new values on the right. We can update as many fields of our record as we like separating each update by a comma. Note here that Elm supports structural typing\cite{wiki-structural-type} to give {\tt physicsUpdate} a record with {\tt {x, y, vx, vy}} as structural elements as an input object. This way we can use the player and the ball record as a input for this function. \inputminted [breaklines=true] {haskell}{pong(9).hs} Now onto our major functions which step our basic elements of our game forward. We start with analysing our {\tt updateBall} function. Here we progress the position of {\tt Ball} according to time and his positional relation to each players paddle. We first check if the ball is out of bounds through checking if the ball is near a {\tt halfWidth} of our court to 0. This is not the case when a player has scored moving the ball behind the enemy's paddle outside the court. If this occurs we set the ball to {\tt (0, 0)}. \inputminted [breaklines=true] {haskell}{pong(10a).hs} if the ball is within the court we update the position of our ball with {\tt physicsUpdate}. We update {\tt vx} and {\tt vy} through the use of {\tt stepV} to check for any occurring collisions. Those collisions could occur at the players paddle or on the horizontal limits of our court. \inputminted [breaklines=true] {haskell}{pong(10b).hs} {\tt updatePlayer} is implemented to update our player's paddles and scores according to their keyboard input and scored points. Here we use Elm's let expressions that first defines values with let and with in we apply those values. The first part of this structure is called the let-expression while the second part where we apply our predefined values is called the where-expression. First we define {\tt player1} which is defined through our input {\tt player}. His paddle position is updated according to the current input through the appliance of {\tt physicsUpdate}. {\tt physicsUpdate} applies an updated {\tt vy} representing the player's current input. \inputminted [breaklines=true] {haskell}{pong(11a).hs} Next we use that definition to keep our player's paddle in court with the use of {\tt clamp}\cite{elm-basics}. {\tt clamp} takes 3 numbers as an input and returns a number. {\tt clamp} checks if the the last input number is with the span of the first two and returning the number in that case. If our last input number exceeds our lower or upper bound it returns the exceeded bound. This way we can use {\tt clamp} to restricts our values for {\tt player1.y} to our first two inputs thus keeping our paddles within the court. Additionally we update our players score by adding our input points onto the players already existing ones. \inputminted [breaklines=true] {haskell}{pong(11b).hs} Now we combine all those integral parts into on big update function that updates our whole game. It takes our input and our current game state which includes our state, our ball as well as our 2 players returning us with an updated, current game state. In our let-expression we define two scores to store which player scored this round. We implement this by checking on which side of the court the ball went out of bounds. This can be evaluated through comparing our balls position on the x-axis compared to half the width of our court. \inputminted [breaklines=true] {haskell}{pong(12a).hs} Following we define the {\tt newState}. If space was pressed we set our state to {\tt Play}. If the {\tt score1} is not the same as {\tt score2} which occurs when a player has scored we pause our game for the next round. If nothing occurs our state remains. \inputminted [breaklines=true] {haskell}{pong(12b).hs} Next we define our {\tt newBall} which remains as it is if the game is paused. Otherwise it gets updated according to {\tt updateBall} if the game is running. \inputminted [breaklines=true] {haskell}{pong(12c).hs} In our where expression the game is updated accordingly to our previously updated elements of our game. \inputminted [breaklines=true] {haskell}{pong(12d).hs} \subsection{View} Now that all is set we have to implement our view so we can render the game. As we did in our update section we first define a few helpers to structure our code. First we define 2 colours for our pong court and text as well our on screen message itself. \inputminted [breaklines=true] {haskell}{pong(13a).hs} Our next function uses a very interesting concept of compositions. {\tt\textgreater\textgreater} passes along the results of our first function to the next one. Trough the use of {\tt\textgreater\textgreater} and {\tt\textless\textless} we can compose functions with one another and run them successively. In this case we transform our string {\tt f} to Elm's type {\tt Text} so we can use Elm's {\tt color} function and and use monospace as a font lastly our text will be made left aligned. \inputminted [breaklines=true] {haskell}{pong(13b).hs} {\tt make} is used to create elements for our objects such as the paddles, the field and the ball. It creates an element according to the input shape and moves it to the location stored in the the object. \inputminted [breaklines=true] {haskell}{pong(13c).hs} {\tt view} takes a integer tuple and our current game state to represent it visually as an {\tt Element}. With our let expression we define scores returning an {\tt Element} to display our current scores onto the court. We use our {\tt txt} function in this expression to transform our input text into an {\tt Element}. \inputminted [breaklines=true] {haskell}{pong(14a).hs} In our where expression we implement elements for our pong court, our ball, our 2 paddles for our respective players as well as a score counter and our on screen information that is only displayed when the game is paused. \inputminted [breaklines=true] {haskell}{pong(14b).hs} \subsection{Combining the pieces} This is usually a part of the input section but has been moved towards the end for the sake of a more comprehensible structure of explanation. {\tt gameState} is implemented to store our game state through the use of {\tt foldp}. We apply our update function onto our {\tt defaultGame} every time an input occurs. \inputminted [breaklines=true] {haskell}{pong(15).hs} Now finally we finished all of our game and put it together in one tiny main function. {\tt map2} here is used to apply a function onto 2 signals return one signal. So we apply {\tt view} every time our {\tt gameState} our our window dimensions change and are able to run our game. \inputminted [breaklines=true] {haskell}{pong(16).hs} \subsection{Summary} To create our game we first implemented data structures to model our objects through the use of union types and type aliases as well as a function to define their default game state. Then we implemented the passage of time and following our input as it relies on our delta to function. As we lay the ground for our game we implemented our update section that we build first from basic interactions to check positional differences, collisions and to apply velocity. This was then combined into larger functions to update our ball's and our player's state which was further combined into one big update function which updates the whole game's state. Now we provided visuals with our view section through the use of our graphical libraries through creating different shapes and texts. Lastly we implemented our {\tt gameState} function that updates our {\tt defaultGame} according to our input with the update function. With all this implemented we could set up our main function that represents the view according to the game's state and the window's dimensions. \section{Related works} \label{sec:related} Conal Elliott's paper "Push-pull functional reactive programming" \cite{Elliott2009-push-pull-frp} serves an integral role in modern FRP and serves as the theoretical basis of many FRP libraries. Alexander Berntsen master thesis on programming game systems in Haskell \cite{Berntsen2014-game-systems-haskell} compares imperative and functional game design based on a medium-sized game and provides substantial evidence supporting the usage of strongly static typed purely functional programming for game development. Charles' post about recreating Asteroids in Netwire \cite{asteroids} describes difficulties encountered when implementing a game using Netwire. Evan Czaplicki's implementation and blog about making pong\cite{elm-pong, elm-making-pong} serves as the exemplary game to showcase in Elm. \section{Conclusion and Outlook} \label{sec:conclusion} Game programming using FRP allows for faster and cleaner development, but it's also not a panacea --- without additional care (such as push-pull FRP\cite{Elliott2009-push-pull-frp} and various optimisations) performance and space leaks become an issue. Additionally, the paradigm shift from imperative to purely functional reactive programming is quite extreme, requiring a comparatively large training period. The amount of actively developed FRP game engines is fairly low\cite{hackage-frp}, so solutions using Haskell might need a custom game engine. However with increased usage of FRP for game development this should become less of an issue. The actual implementation of FRP is beyond the scope of this paper, and implementers of game engines or similar should consult references and their framework's internal documentation. \bibliographystyle{plain} \bibliography{references} \end{document}
static char help[] = "Load a collection of PETSc vectors and stack them into a tall-skinny matrix\n\n"; #include <petsc.h> #include <petscvec.h> #include <petscmat.h> /* Mesh size (129, 33, 257) <xdmf reverse order>, so ni = 257, nk = 129 */ PetscErrorCode SnapshotView(Vec u,const char suffix[]) { const PetscInt M = 257; const PetscInt N = 33; const PetscInt P = 129; DM dm; Vec cu; PetscViewer viewer; char ofile[PETSC_MAX_PATH_LEN]; PetscErrorCode ierr; PetscFunctionBegin; ierr = DMDACreate3d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE, DMDA_STENCIL_BOX,M,N,P,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE, 1,1,NULL,NULL,NULL,&dm);CHKERRQ(ierr); ierr = DMSetUp(dm);CHKERRQ(ierr); ierr = DMDASetUniformCoordinates(dm,0.0,12.0,-1.5,0.0,0.0,6.0);CHKERRQ(ierr); ierr = DMCreateGlobalVector(dm,&cu);CHKERRQ(ierr); ierr = VecCopy(u,cu);CHKERRQ(ierr); PetscSNPrintf(ofile,PETSC_MAX_PATH_LEN-1,"%s.vts",suffix); ierr = PetscViewerVTKOpen(PETSC_COMM_WORLD,ofile,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); ierr = VecView(cu,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); ierr = DMDestroy(&dm);CHKERRQ(ierr); ierr = VecDestroy(&cu);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode SnapshotViewFromFile(const char coor_fname[],const char u_fname[],const char suffix[]) { const PetscInt M = 257; const PetscInt N = 33; const PetscInt P = 129; DM dm; Vec u,coor,_u,_coor; PetscViewer viewer; char ofile[PETSC_MAX_PATH_LEN]; PetscErrorCode ierr; PetscFunctionBegin; PetscPrintf(PETSC_COMM_WORLD,"Loading solution: %s\n",u_fname); ierr = VecCreate(PETSC_COMM_WORLD,&u);CHKERRQ(ierr); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,u_fname,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = VecLoad(u,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscPrintf(PETSC_COMM_WORLD,"Loading coordinates: %s\n",coor_fname); ierr = VecCreate(PETSC_COMM_WORLD,&coor);CHKERRQ(ierr); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,coor_fname,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = VecLoad(coor,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); ierr = DMDACreate3d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE, DMDA_STENCIL_BOX,M,N,P,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE, 1,1,NULL,NULL,NULL,&dm);CHKERRQ(ierr); ierr = DMSetUp(dm);CHKERRQ(ierr); ierr = DMDASetUniformCoordinates(dm,0.0,1.0,0.0,1.0,0.0,1.0);CHKERRQ(ierr); ierr = DMCreateGlobalVector(dm,&_u);CHKERRQ(ierr); ierr = VecCopy(u,_u);CHKERRQ(ierr); ierr = DMGetCoordinates(dm,&_coor);CHKERRQ(ierr); ierr = VecCopy(coor,_coor);CHKERRQ(ierr); PetscSNPrintf(ofile,PETSC_MAX_PATH_LEN-1,"%s.vts",suffix); PetscPrintf(PETSC_COMM_WORLD,"Writing output: %s\n",ofile); ierr = PetscViewerVTKOpen(PETSC_COMM_WORLD,ofile,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); ierr = VecView(_u,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); ierr = DMDestroy(&dm);CHKERRQ(ierr); ierr = VecDestroy(&_u);CHKERRQ(ierr); ierr = VecDestroy(&u);CHKERRQ(ierr); ierr = VecDestroy(&coor);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode SnapshotMatCreate(Mat *snapshots) { PetscErrorCode ierr; Vec u; PetscViewer viewer; const PetscInt steps[] = { 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400 }; char fname[PETSC_MAX_PATH_LEN]; PetscInt i,len,m,n,k; Mat S; PetscInt *idx; PetscFunctionBegin; len = sizeof(steps) / sizeof(PetscInt); n = len; ierr = PetscOptionsGetInt(NULL,NULL,"-truncate",&n,NULL);CHKERRQ(ierr); if (n > len) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_USER,"Truncate value cannot be larger than %D",len); for (i=0; i<n; i++) { PetscSNPrintf(fname,PETSC_MAX_PATH_LEN-1,"data/step%1.6d_energy.pbvec",steps[i]); PetscPrintf(PETSC_COMM_WORLD,"[%d] Loading: %s\n",i,fname); ierr = VecCreate(PETSC_COMM_WORLD,&u);CHKERRQ(ierr); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,fname,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = VecLoad(u,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); if (i == 0) { ierr = VecGetSize(u,&m);CHKERRQ(ierr); PetscPrintf(PETSC_COMM_WORLD,"S: m %d, n %d\n",m,n); ierr = MatCreate(PETSC_COMM_WORLD,&S);CHKERRQ(ierr); ierr = MatSetSizes(S,PETSC_DECIDE,PETSC_DECIDE,m,n);CHKERRQ(ierr); ierr = MatSetType(S,MATDENSE);CHKERRQ(ierr); ierr = MatSetUp(S);CHKERRQ(ierr); ierr = PetscCalloc1(m,&idx);CHKERRQ(ierr); for (k=0; k<m; k++) { idx[k] = k; } } { const PetscScalar *_u; ierr = VecGetArrayRead(u,&_u);CHKERRQ(ierr); ierr = MatSetValues(S,m,idx,1,&i,_u,INSERT_VALUES);CHKERRQ(ierr); ierr = VecRestoreArrayRead(u,&_u);CHKERRQ(ierr); } ierr = MatAssemblyBegin(S,MAT_FLUSH_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(S,MAT_FLUSH_ASSEMBLY);CHKERRQ(ierr); if (i == 0) { ierr = SnapshotView(u,"snapshot0");CHKERRQ(ierr); } ierr = VecDestroy(&u);CHKERRQ(ierr); } ierr = MatAssemblyBegin(S,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(S,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); *snapshots = S; ierr = PetscFree(idx);CHKERRQ(ierr); PetscFunctionReturn(0); } int main(int argc,char **args) { PetscErrorCode ierr; Mat S; PetscInt step = -1; PetscBool found = PETSC_FALSE; ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr; ierr = SnapshotMatCreate(&S);CHKERRQ(ierr); /* Dump S(i,j) as ascii to stdout */ /*ierr = MatView(S,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);*/ /* Dump S(i,j) as bindary to file */ { PetscViewer viewer; ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,"snapshot.pbmat",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); ierr = MatView(S,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetInt(NULL,NULL,"-solution_view",&step,&found);CHKERRQ(ierr); if (found) { char s_fname[PETSC_MAX_PATH_LEN]; char c_fname[PETSC_MAX_PATH_LEN]; char ofname[PETSC_MAX_PATH_LEN]; PetscSNPrintf(s_fname,PETSC_MAX_PATH_LEN-1,"data/step%1.6d_energy.pbvec",step); PetscSNPrintf(c_fname,PETSC_MAX_PATH_LEN-1,"data/step%1.6d_coor.pbvec",step); PetscSNPrintf(ofname,PETSC_MAX_PATH_LEN-1,"step%d_temperature",step); PetscPrintf(PETSC_COMM_WORLD,"Snapshot to visualize: %d\n",step); ierr = SnapshotViewFromFile(c_fname,s_fname,ofname);CHKERRQ(ierr); } ierr = PetscFinalize(); return ierr; }
\section{Introduction}\label{sec:intro} The current model for \VRO is that is provides proprietary data to approved users in Chile and the \gls{US}. The data access model accommodates this restricted data rights policy. This policy requires control over access, publication, and sharing of proprietary data which any (\gls{IDAC}) would have to comply with just as the \gls{US} and Chile DACs do. Access to \RO data products for any users will be possible through a \gls{DAC}. The United States's \gls{DAC} , referred to as the \gls{US} Data Facility, is where registered \RO~ users will perform scientific queries. Most users will have access to a default set of resources at the \gls{DAC} sufficient for basic queries and analysis. Users who require more resources will be able to apply for them, and those granted additional resources will be allowed (for example) to perform analysis on the full data releases using the \gls{RSP}. The \gls{RSP} is documented with the vision given in \citeds{LSE-319}, with more formal requirements in \citeds{LDM-554} and the design in \citeds{LDM-542}. The Chilean \gls{DAC} will be equivalent in functionality to the \gls{US} \gls{DAC}, but scaled-down in terms of the computational resources available for query and analysis given the smaller Chilean community \citedsp{LDM-572}. %This document proposes a set of guidelines and policies for partner institutions -- in the US, Chile, or one of the International Contributors with signed Memoranda of Agreement -- that are interested in hosting the LSST data, in whole or in part, for their affiliated members as an independent Data Access Center (IDAC). The following sections include the types of data products that could be hosted (Section \ref{sec:data}), the requirements and responsibilities that would be expected of an \gls{IDAC} hosting \RO proprietary data products (Section \ref{sec:reqs}), and a description of the main costs {\it vs.} their science impacts (Section \ref{sec:costs}). The contents of this draft document are meant to provide a preliminary resource for partner institutions who may be assessing the feasibility of hosting an \gls{IDAC}. The specific mechanisms and processes by which future \gls{IDAC}s will negotiate the bulk transfer of data, the installation of software, etc. is considered beyond the scope of this document. A simplified checklist is given in \appref{sec:checklist}. To better understand the sizes of \RO data products, \tabref{tab:storageSizingOps} gives an overview of sizes and the estimaed storage needs are in \tabref{tab:storageFloorOps}(from \citeds{DMTN-135}). \begin{landscape} \input{dmtn-135/storageSizingOps.tex} \input{dmtn-135/storageFloorOps.tex} \end{landscape} All access to, and use of the \RO data and data products is subject to the policies described in \citeds{LDO-13}. In addition to the sizes shown in \tabref{tab:storageSizingOps} it is interesting to consider how much access and potentially how much science there is per table. This is discussed in detail in \citeds{PSTN-003}. The \gls{AMCL} made an interesting table concerning this topic which is reproduced here in \tabref{tab:use}. Feedback on the correctness of this table has been sought from \gls{PST}. \input{images/usetab.tex} % this is in the images git repo
import Data.Vect read_vect_len : (len : Nat) -> IO (Vect len String) read_vect_len Z = pure [] read_vect_len (S k) = do x <- getLine xs <- read_vect_len k pure (x :: xs) data VectUnknown : Type -> Type where MkVect : (len : Nat) -> Vect len a -> VectUnknown a read_vect : IO (len ** Vect len String) read_vect = do x <- getLine if (x == "") then pure (_ ** []) else do (_ ** xs) <- read_vect pure (_ ** x :: xs)
```python import numpy as np import sympy as sym import pydae.build as db from pydae.grid_bpu import bpu ``` ```python bpu_obj = bpu(data_input='oc_3bus_uvsg_high.json') g_list = bpu_obj.dae['g'] h_dict = bpu_obj.dae['h_dict'] f_list = bpu_obj.dae['f'] x_list = bpu_obj.dae['x'] params_dict = bpu_obj.dae['params_dict'] sys = {'name':'oc_3bus_uvsg_high', 'params_dict':params_dict, 'f_list':f_list, 'g_list':g_list, 'x_list':x_list, 'y_ini_list':bpu_obj.dae['y_ini'], 'y_run_list':bpu_obj.dae['y_run'], 'u_run_dict':bpu_obj.dae['u_run_dict'], 'u_ini_dict':bpu_obj.dae['u_ini_dict'], 'h_dict':h_dict} sys = db.system(sys) db.sys2num(sys) ``` ```python H = 5.0; # desired virtual inertia K_p = 0.01; # active power proportinal gain #H = T_p/K_p/2 T_p = K_p*2*H; # active power integral time constant ``` ```python T_p ``` 0.1 ```python 160**2*0.2e-6 ``` 0.0051199999999999996 ```python ```
(* Title: HOL/Auth/n_g2kAbsAfter_lemma_inv__75_on_rules.thy Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences *) header{*The n_g2kAbsAfter Protocol Case Study*} theory n_g2kAbsAfter_lemma_inv__75_on_rules imports n_g2kAbsAfter_lemma_on_inv__75 begin section{*All lemmas on causal relation between inv__75*} lemma lemma_inv__75_on_rules: assumes b1: "r \<in> rules N" and b2: "(f=inv__75 )" shows "invHoldForRule s f r (invariants N)" proof - have c1: "(\<exists> d. d\<le>N\<and>r=n_n_Store_i1 d)\<or> (\<exists> d. d\<le>N\<and>r=n_n_AStore_i1 d)\<or> (r=n_n_SendReqS_j1 )\<or> (r=n_n_SendReqEI_i1 )\<or> (r=n_n_SendReqES_i1 )\<or> (r=n_n_RecvReq_i1 )\<or> (r=n_n_SendInvE_i1 )\<or> (r=n_n_SendInvS_i1 )\<or> (r=n_n_SendInvAck_i1 )\<or> (r=n_n_RecvInvAck_i1 )\<or> (r=n_n_SendGntS_i1 )\<or> (r=n_n_SendGntE_i1 )\<or> (r=n_n_RecvGntS_i1 )\<or> (r=n_n_RecvGntE_i1 )\<or> (r=n_n_ASendReqIS_j1 )\<or> (r=n_n_ASendReqSE_j1 )\<or> (r=n_n_ASendReqEI_i1 )\<or> (r=n_n_ASendReqES_i1 )\<or> (r=n_n_SendReqEE_i1 )\<or> (r=n_n_ARecvReq_i1 )\<or> (r=n_n_ASendInvE_i1 )\<or> (r=n_n_ASendInvS_i1 )\<or> (r=n_n_ASendInvAck_i1 )\<or> (r=n_n_ARecvInvAck_i1 )\<or> (r=n_n_ASendGntS_i1 )\<or> (r=n_n_ASendGntE_i1 )\<or> (r=n_n_ARecvGntS_i1 )\<or> (r=n_n_ARecvGntE_i1 )" apply (cut_tac b1, auto) done moreover { assume d1: "(\<exists> d. d\<le>N\<and>r=n_n_Store_i1 d)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_Store_i1Vsinv__75) done } moreover { assume d1: "(\<exists> d. d\<le>N\<and>r=n_n_AStore_i1 d)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_AStore_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendReqS_j1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendReqS_j1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendReqEI_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendReqEI_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendReqES_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendReqES_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_RecvReq_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_RecvReq_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendInvE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendInvE_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendInvS_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendInvS_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendInvAck_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendInvAck_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_RecvInvAck_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_RecvInvAck_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendGntS_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendGntS_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendGntE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendGntE_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_RecvGntS_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_RecvGntS_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_RecvGntE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_RecvGntE_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendReqIS_j1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendReqIS_j1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendReqSE_j1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendReqSE_j1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendReqEI_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendReqEI_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendReqES_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendReqES_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_SendReqEE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_SendReqEE_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ARecvReq_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ARecvReq_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendInvE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendInvE_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendInvS_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendInvS_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendInvAck_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendInvAck_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ARecvInvAck_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ARecvInvAck_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendGntS_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendGntS_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ASendGntE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ASendGntE_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ARecvGntS_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ARecvGntS_i1Vsinv__75) done } moreover { assume d1: "(r=n_n_ARecvGntE_i1 )" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_n_ARecvGntE_i1Vsinv__75) done } ultimately show "invHoldForRule s f r (invariants N)" by satx qed end
#' waitcopy. #' #' Copy files during particular times of day and with metadata. #' #' @section Functionality: #' #' `waitcopy` provides the function `wait_copy` that: #' - will only copy files during a set time interval #' - will wait a specific amount of time between file copies #' - creates a json file with some limited meta-data about the file #' - removes special characters from the file name #' #' @section Motivation: #' #' Imagine someone you work with has a hard drive that you need data from, but that #' hard drive is only accessible via the network, mounted via SAMBA, and there are #' potentially duplicate files with the same name, files with the same base name #' that are different, and the file path provides some meta-information about the #' sample. In addition, the file names have odd characters in them (spaces, colons, etc) #' that make them a pain to work with from the command line on Linux, so you'd prefer #' if they weren't there. #' #' The files are small, so even copying over the network is fast, but if you copy #' too many too quickly during the day, you'll get complaints about hitting this shared #' resource too often by the people who are local to it. #' #' @section Solution: #' #' So ideally, you want to copy the files only during certain hours, wait a little #' bit between each copy operation, check for duplicates (via names and md5 hashing), #' strip the file name of special characters, and note where the file originated. #' #' @name waitcopy #' @docType package NULL
Formal statement is: lemma contour_integrable_continuous_linepath: assumes "continuous_on (closed_segment a b) f" shows "f contour_integrable_on (linepath a b)" Informal statement is: If $f$ is continuous on the closed segment $[a,b]$, then $f$ is integrable on the line segment $[a,b]$.
[STATEMENT] lemma OclIsEmpty_invalid[simp,code_unfold]:"(invalid->isEmpty\<^sub>B\<^sub>a\<^sub>g()) = invalid" [PROOF STATE] proof (prove) goal (1 subgoal): 1. invalid->isEmpty\<^sub>B\<^sub>a\<^sub>g() = invalid [PROOF STEP] by(simp add: OclIsEmpty_def)
import tactic import group_theory.quotient_group import algebra.archimedean import order.conditionally_complete_lattice open_locale classical def df (f : ℤ → ℤ) : ℤ → ℤ → ℤ := λ p q, f (p + q) - f (p) - f (q) def almost_homo (f : ℤ → ℤ) : Prop := ∃ C, ∀ p q, abs (df f p q) < C @[simp] lemma df_eq (f : ℤ → ℤ) (p q : ℤ) : df f p q = f (p + q) - f (p) - f (q) := rfl def S := {f | almost_homo f} def S.add : S → S → S := λ f g, ⟨λ z, f.1 z + g.1 z, begin rcases f with ⟨f, C1, hf⟩, rcases g with ⟨g, C2, hg⟩, use C1 + C2, intros p q, specialize hf p q, specialize hg p q, have h1 : df (λ (z : ℤ), f z + g z) p q = df f p q + df g p q, simp, ring, rw h1, linarith [abs_add (df f p q) (df g p q)], end⟩ def S.neg : S → S := λ f, ⟨λ p, - f.1 p, begin rcases f with ⟨f, C1, hf⟩, use C1, simp, intros p q, specialize hf p q, simp at hf, have h : f p - f (p + q) + f q = - (f (p + q) - f p - f q), ring, rw [h, abs_neg], exact hf, end⟩ def S.zero : S := ⟨λ p, 0, 1, by norm_num⟩ @[simp] lemma S.add_eq (f g : S) : S.add f g = ⟨λ p, f.1 p + g.1 p, S.add._proof_1 f g⟩ := rfl @[simp] lemma S.neg_eq (f : S) : S.neg f = ⟨λ p, - f.1 p, S.neg._proof_1 f⟩ := rfl instance add_group_S : add_group S := { add := λ f g, S.add f g, add_assoc := begin intros f g h, simp, ring, end, zero := ⟨λ p, 0, 1, by norm_num⟩, zero_add := begin intro f, show S.add ⟨λ p, 0, 1, by norm_num⟩ f = f, simp, end, add_zero := begin intro f, show S.add f ⟨λ p, 0, 1, by norm_num⟩ = f, simp, end, neg := λ f, ⟨λ p, - f.1 p, begin rcases f with ⟨f, C1, hf⟩, use C1, simp, intros p q, specialize hf p q, simp at hf, have h : f p - f (p + q) + f q = - (f (p + q) - f p - f q), ring, rw [h, abs_neg], exact hf, end⟩, add_left_neg := begin intro f, show S.add (S.neg f) f = ⟨λ (p : ℤ), 0, _⟩, simp, end } @[simp] lemma S.add_eq' (f g : S) : f + g = S.add f g := rfl @[simp] lemma S.neg_eq' (f : S) : -f = S.neg f := rfl @[simp] lemma S.zero_eq' : (0 : S) = ⟨λ p, 0, 1, by norm_num⟩ := rfl instance : add_comm_group S := { add_comm := begin intros f g, show S.add f g = S.add g f, simp, simp_rw [add_comm], end, ..add_group_S } def B : add_subgroup S := { carrier := {f : S | ∃ C, ∀ p, abs (f.1 p) < C}, zero_mem' := begin use 1, intro p, norm_num, end, add_mem' := begin rintro f g ⟨C1, hf⟩ ⟨C2, hg⟩, use C1 + C2, intro p, specialize hf p, specialize hg p, simp, change abs (f.1 p + g.1 p) < C1 + C2, linarith [abs_add (f.1 p) (g.1 p)], end, neg_mem' := begin rintro f ⟨C, hf⟩, use C, intro p, specialize hf p, change abs (-(f.val p)) < C, simp, exact hf, end } @[simp] lemma in_B_iff (f : S) : f ∈ B ↔ ∃ C, ∀ p, abs (f.1 p) < C := iff.rfl def eudoxus_reals_group := quotient_add_group.quotient B notation `𝔼` := eudoxus_reals_group instance add_comm_group_𝔼 : add_comm_group 𝔼 := quotient_add_group.add_comm_group B lemma lemma1 {f : ℤ → ℤ} (hf1 : almost_homo f) (hf2 : ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f p) : ∀ D, 0 < D → ∃ M (hM : 0 < M), ∀ m, 0 < m → (m + 1) * D < f (m * M) := begin rcases hf1 with ⟨C, hf1⟩, intros D hD, set E := C + D with hE, have key : ∃ M (hM : 0 < M), 2 * E < f M, have h2E : 0 < 2 * E, linarith [hf1 0 0, abs_nonneg (df f 0 0)], rcases hf2 (2 * E) h2E with ⟨M, hM, H⟩, use [M, hM], exact H, rcases key with ⟨M, hM, hfM⟩, use [M, hM], intros m hm, have hC : 0 ≤ C, specialize hf1 1 2, linarith [abs_nonneg (df f 1 2)], have hED : ∀ k, 0 < k → (k + 1) * D ≤ (k + 1) * E, intros k hk, rw mul_le_mul_left, linarith, linarith, apply lt_of_le_of_lt (hED m hm), induction m, { induction m with m h, exfalso, norm_num at hm, have hm0 : m = 0 ∨ 0 < m, exact nat.eq_zero_or_pos m, cases hm0, { rw hm0, simp, exact hfM, }, { have hm0' : int.of_nat m > 0, exact int.lt_to_nat.mp hm0, specialize h hm0', have hdf1 : f ((int.of_nat m.succ) * M) = f (int.of_nat m * M) + f (M) + df f (int.of_nat m * M) (M), simp, ring, rw mul_comm, have hdf2 : -E < df f (int.of_nat m * M) M, specialize hf1 (int.of_nat m * M) M, rw abs_lt at hf1, linarith, have h1 : (int.of_nat m + 1) * E + 2 * E + (-E) < f (int.of_nat m * M) + f M + df f (int.of_nat m * M) M, linarith, have h2 : (int.of_nat m.succ + 1) * E = (int.of_nat m + 1) * E + 2 * E + (-E), dsimp, ring, linarith, }, }, { exfalso, linarith [int.neg_succ_lt_zero m], }, end theorem QRT : ∀ n m : ℤ, m > 0 → ∃ q r : ℤ, n = m * q + r ∧ (0 ≤ r ∧ r < m) := begin intros n m h, use (n / m), use (n % m), have HH: n = m * (n / m) + (n % m), from calc n = n % m + m * (n / m) : by rw [int.mod_add_div] ... = m * (n / m) + (n % m) : by rw add_comm, have HH1: 0 ≤ (n % m), from int.mod_nonneg n (ne_of_gt h), have HH2: (n % m) < m, from calc (n % m) < abs m : int.mod_lt n (ne_of_gt h) ... = m : abs_of_pos h, exact ⟨HH , ⟨HH1, HH2⟩⟩, end instance : has_coe_t ↥S 𝔼 := quotient_add_group.has_coe_t instance : has_lift_t ↥S 𝔼 := coe_to_lift lemma 𝔼.zero_eq : (0 : 𝔼) = ↑(0 : S) := rfl def P := {e : 𝔼 | ∃ (f : S) (H : ↑f = e), ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p} lemma P_eq : P = {e : 𝔼 | ∃ (f : S) (H : ↑f = e), ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p} := rfl @[simp] lemma upper_bounds_eq {S : set ℤ} : upper_bounds S = {x : ℤ | ∀ ⦃a : ℤ⦄, a ∈ S → a ≤ x} := rfl @[simp] lemma lower_bounds_eq {S : set ℤ} : lower_bounds S = {x : ℤ | ∀ ⦃a : ℤ⦄, a ∈ S → x ≤ a} := rfl lemma lemma2 (f : S) (hf : ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p) : (∀ C (HC : 0 < C), ∃ N : ℤ, ∀ p (hNp : N < p), C < f.1 p) := begin rcases f.2 with ⟨D, hD⟩, have hD1 : ∀ (p q : ℤ), abs (df f.1 p q) < D := hD, specialize hD 1 2, have hD' : 0 < D, linarith [abs_nonneg (df f.1 1 2)], rcases lemma1 f.2 hf D hD' with ⟨M, hM0, hM⟩, have hE : ∃ E, ∀ r (h0r : 0 ≤ r) (hrM : r < M), abs(f.1 r) < E, have hfin : set.finite ((abs ∘ f.1) '' (set.Ico 0 M)), apply set.finite.image, split, apply fintype.of_finset (finset.Ico_ℤ 0 M), simp, have hbdd : bdd_above ((abs ∘ f.1) '' (set.Ico 0 M)), apply set.finite.bdd_above hfin, cases hbdd with m hm, simp at hm, use m + 1, intros r h0r hrM, specialize @hm (abs (f.1 r)) r h0r hrM rfl, linarith, cases hE with E hE, have hE1 : ∀ (r : ℤ), 0 ≤ r → r < M → abs (f.1 r) < E := hE, specialize hE 0 _ _, { set B := E + D with hB, intros C hC, have hBC0 : 0 < B + C, linarith [abs_nonneg (f.1 0)], have hn : ∃ n (hn0 : n > 0), B + C < (n + 1) * D, rcases (QRT (B + C) D hD') with ⟨n, r, hnr, h0r, hrD⟩, rw hnr at hBC0, have h0n : 0 ≤ n, by_contradiction hfalse, simp at hfalse, have hnn : ∃ (nn : ℤ) (hnn0 : nn > 0), n = -nn, use -n, split, linarith, simp, rcases hnn with ⟨nn, hnn0, hnn⟩, rw hnn at hBC0, have hDnnr : D * nn ≤ r, linarith, have hDDnn : D ≤ D * nn, exact (le_mul_iff_one_le_right hD').mpr (show nn ≥ 1, by linarith), linarith, use n + 1, split, linarith, have hfinal : (n + 1 + 1) * D = D * n + 2 * D, ring, rw hfinal, linarith, rcases hn with ⟨n, hn0, hn⟩, use n * M, intros p hp, rcases (QRT p M hM0) with ⟨d, r, hdr, h0r, hrM⟩, rw hdr at hp, have hndr : (n - d) * M < M, linarith, have hnd : n - d < 1, exact (mul_lt_iff_lt_one_left hM0).mp hndr, have hnd' : n ≤ d, linarith, have hd0 : 0 < d, linarith, have hfdm1 : B + C < f.1 (d * M), have hnDdD1 : n + 1 ≤ d + 1, linarith, have hnDdD2 : (n + 1) * D ≤ (d + 1) * D, exact (mul_le_mul_right hD').mpr hnDdD1, linarith [hM d hd0], have hfdMr : abs (f.1 p - f.1 (d * M)) < B, rw hdr, have heq1 : f.1 (M * d + r) = f.1 (M * d) + f.1 (r) + df f.1 (M * d) r, simp, ring, have heq2 : f.1 (d * M) + f.1 r + df f.1 (d * M) r - f.1 (d * M) = f.1 r + df f.1 (d * M) r, ring, rw [heq1, mul_comm, heq2], linarith [hD1 (d * M) r, hE1 r h0r hrM, abs_add (f.1 r) (df f.1 (d * M) r)], rw abs_lt at hfdMr, linarith, }, { refl, }, { exact hM0, }, end lemma lemma3 (f : S) (hf : ∀ n (hn : n < 0), ∃ p (hp : 0 < p), f.1 p < n) : (∀ C (HC : 0 < C), ∃ N : ℤ, ∀ p (hNp : N < p), f.1 p < -C) := begin set g := -f with hgf, have hfval : ∀ p, (-f).val p = -(f.val p), intro p, refl, have key : ∀ (C : ℤ), 0 < C → (∃ (N : ℤ), ∀ (p : ℤ), N < p → C < g.val p), apply lemma2 g, simp_rw [hgf, hfval], intros n hn, have : -n < 0, linarith, specialize hf (-n) this, rcases hf with ⟨p, hp, hf⟩, use [p, hp], linarith, simp_rw [hgf, hfval] at key, rintro C hC, specialize key C hC, cases key with N key, use N, intros p hp, specialize key p hp, linarith, end lemma lemma4 (f : S) (hf : ∃ C, ∀ p (hp : 0 ≤ p), abs (f.1 p) < C) : ∃ B, ∀ p, abs (f.1 p) < B := begin cases f.2 with D hD, cases hf with C hC, have hneg : ∃ C', ∀ p (hp : p < 0), abs (f.1 p) < C', use C + D + abs (f.1 0), intros p hp, have hfp : f.1 p = f.1 0 - f.1 (-p) - df f.1 (-p) p, simp, ring, rw hfp, have hnegp : 0 < -p, exact neg_pos.mpr hp, have hnegp' : 0 ≤ -p, linarith, specialize hC (-p) hnegp', specialize hD (-p) p, have heq : f.val 0 - f.val (-p) - df f.val (-p) p = f.val 0 + (-f.val (-p)) + (-df f.val (-p) p), ring, rw heq, have habs3 : abs (f.val 0 + -f.val (-p) + -df f.val (-p) p) ≤ abs (f.val 0) + abs (-f.val (-p)) + abs (-df f.val (-p) p), exact abs_add_three (f.val 0) (-f.val (-p)) (-df f.val (-p) p), rw [abs_neg, abs_neg] at habs3, linarith [abs_add_three (f.val 0) (-f.val (-p)) (-df f.val (-p) p)], cases hneg with C' hC', use C + C', intro p, have hp : 0 ≤ p ∨ p < 0 := le_or_lt 0 p, cases hp, { specialize hC p hp, have hne1 : (-1 : ℤ) < 0, norm_num, specialize hC' (-1) hne1, linarith [abs_nonneg (f.val (-1))], }, { specialize hC' p hp, have h01 : (0 : ℤ) ≤ 1, norm_num, specialize hC 1 h01, linarith [abs_nonneg (f.val 1)], }, end lemma lemma5 (f : S) : (∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p) ∨ (∀ n (hn : n < 0), ∃ p (hp : 0 < p), f.1 p < n) ∨ (∃ C, ∀ p (hp : 0 ≤ p), abs (f.1 p) < C) := begin by_cases h1 : ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p, left, exact h1, by_cases h2 : ∀ n (hn : n < 0), ∃ p (hp : 0 < p), f.1 p < n, right, left, exact h2, have h1' : ∃ n (hn : 0 < n), ∀ p (hp : 0 < p), f.1 p ≤ n, finish, have h2' : ∃ n (hn : n < 0), ∀ p (hp : 0 < p), n ≤ f.1 p, finish, rcases h1' with ⟨C1, hC1, h1'⟩, rcases h2' with ⟨C2, hC2, h2'⟩, right, right, use abs (C1) + abs (C2) + abs (f.val 0) + 1, intros p hp, have hfval0 : 0 < f.1 p ∨ f.1 p ≤ 0, exact lt_or_ge 0 (f.val p), cases hfval0, { have habs : abs (f.val p) ≤ abs C1 + abs (f.val 0), have := eq_or_lt_of_le hp, cases this, rw ← this, linarith [abs_nonneg C1], specialize h1' p this, have : abs (f.val p) ≤ abs C1, apply abs_le_abs h1', linarith, linarith [abs_nonneg (f.val 0)], linarith [abs_nonneg C2], }, { have hfval0' : f.1 p < 0 ∨ f.1 p = 0, exact lt_or_eq_of_le hfval0, cases hfval0', { have habs : abs (f.val p) ≤ abs C2 + abs (f.val 0), have := eq_or_lt_of_le hp, cases this, rw ← this, linarith [abs_nonneg C2], specialize h2' p this, have habs : abs (f.val p) ≤ abs C2, rw abs_of_neg hfval0', have hC2 : C2 < 0, linarith, rw abs_of_neg hC2, linarith, linarith [abs_nonneg (f.val 0)], linarith [abs_nonneg C1], }, { rw hfval0', simp only [abs_zero], linarith [abs_nonneg C1, abs_nonneg C2, abs_nonneg (f.1 0)], }, }, end lemma lemma6 (f : S) : (∀ C (HC : 0 < C), ∃ N : ℤ, ∀ p (hNp : N < p), C < f.1 p) ∧ (∀ C (HC : 0 < C), ∃ N : ℤ, ∀ p (hNp : N < p), f.1 p < -C) → false := begin rintro ⟨h1, h2⟩, have h01 : (0 : int) < 1, norm_num, specialize h1 1 h01, specialize h2 1 h01, cases h1 with N1 h1, cases h2 with N2 h2, have hN1 : N1 < abs N1 + abs N2 + 1, linarith [abs_nonneg N2, le_abs_self N1], have hN2 : N2 < abs N1 + abs N2 + 1, linarith [abs_nonneg N1, le_abs_self N2], specialize h1 (abs N1 + abs N2 + 1) hN1, specialize h2 (abs N1 + abs N2 + 1) hN2, linarith, end lemma lemma7 (f : S) : (∀ C (HC : 0 < C), ∃ N : ℤ, ∀ p (hNp : N < p), C < f.1 p) ∧ (∃ B, ∀ p, abs (f.1 p) < B) → false := begin rintro ⟨h1, h2⟩, cases h2 with B h2, have h01 : (0 : int) < 1, norm_num, have h2' : ∀ (p : ℤ), abs (f.val p) < B := h2, specialize h2' 0, have hB : 0 < B, linarith [abs_nonneg (f.1 0)], specialize h1 B hB, cases h1 with N h1, have hN : N < N + 1, linarith, specialize h1 (N + 1) hN, specialize h2 (N + 1), rw abs_lt at h2, linarith, end lemma lemma8 (f : S) : (∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p) ↔ (∀ C (HC : 0 < C), ∃ N : ℤ, ∀ p (hNp : N < p), C < f.1 p) := begin split, { intro hf, exact lemma2 f hf, }, { cases lemma5 f, { intro, exact h, }, { cases h, { intro h1, exfalso, exact lemma6 f ⟨h1, lemma3 f h⟩, }, { intro h1, exfalso, exact lemma7 f ⟨h1, lemma4 f h⟩, }, }, }, end lemma lemma9 : ∀ a b ∈ P, a + b ∈ P := begin rintro a b ⟨f1, hf1a, h1⟩ ⟨f2, hf2b, h2⟩, use f1 + f2, split, rw [← hf1a, ← hf2b], refl, rw lemma8 at *, intros C hC, specialize h1 C hC, specialize h2 C hC, cases h1 with M h1, cases h2 with N h2, use max M N, intro p, intro hMNp, have hMNp': M < p ∧ N < p, rw ← max_lt_iff, exact hMNp, specialize h1 p hMNp'.1, specialize h2 p hMNp'.2, have hfinal : (f1 + f2).val p = f1.val p + f2.val p, refl, rw hfinal, linarith, end lemma lemma10 : (0 : 𝔼) ∈ P → false := begin intro hfalse, rw P_eq at hfalse, rcases hfalse with ⟨f, H, hfalse⟩, rw lemma8 at hfalse, rw 𝔼.zero_eq at H, rw quotient_add_group.eq at H, simp at H, exact lemma7 f ⟨hfalse, H⟩, end lemma lemma11 {a : 𝔼} : a ∈ P → -a ∈ P → false := begin rw P_eq, rintro ⟨f1, hf1, ha1⟩ ⟨f2, hf2, ha2⟩, rw ← hf1 at hf2, have hf1f2 : ↑f2 + ↑f1 = (0 : 𝔼), rw hf2, simp, have hf1f2' : (@coe ↥S 𝔼) eudoxus_reals_group.has_lift_t (0 : S) = ↑(f2 + f1), have heq : (@coe ↥S 𝔼) eudoxus_reals_group.has_lift_t (f2 + f1) = ↑f2 + ↑f1, refl, have h0 : (@coe ↥S 𝔼) eudoxus_reals_group.has_lift_t (0 : S) = (0 : 𝔼), refl, rw [heq, h0, ← hf1f2], rw quotient_add_group.eq at hf1f2', simp only [nonempty_of_inhabited, sub_zero, abs_zero, S.neg_eq', zero_add, df_eq, S.neg_eq, in_B_iff, neg_zero] at hf1f2', cases hf1f2' with C hf1f2', rw lemma8 at *, have h0C : 0 < C, linarith [hf1f2' 0, abs_nonneg ((f2 + f1).val 0)], cases ha1 C h0C with N1 ha1, cases ha2 C h0C with N2 ha2, have hN1 : N1 < max N1 N2 + 1, linarith [le_max_left N1 N2], have hN2 : N2 < max N1 N2 + 1, linarith [le_max_right N1 N2], specialize ha1 (max N1 N2 + 1) hN1, specialize ha2 (max N1 N2 + 1) hN2, specialize hf1f2' (max N1 N2 + 1), have heq : (f2 + f1).val (max N1 N2 + 1) = f2.val (max N1 N2 + 1) + f1.val (max N1 N2 + 1) := rfl, rw [heq, abs_lt] at hf1f2', linarith, end lemma lemma12 : ∀ a : 𝔼, ∃ f : S, ↑f = a := λ a, quot.exists_rep a lemma lemma13 : ∀ {f : ℤ → ℤ} (C : ℤ), set.finite (f '' (set.Ioo (-C) C)) := begin intros f C, apply set.finite.image, exact ⟨fintype.of_finset (finset.Ico_ℤ (-C + 1) (C)) (by {simp [int.add_one_le_iff]})⟩, end lemma lemma14 : ∀ f g : S, f.1 ∘ g.1 ∈ S := begin intros f g, rcases f with ⟨f, C1, hf⟩, rcases g with ⟨g, C2, hg⟩, simp, have hfin : set.finite (f '' (set.Ioo (-C2) (C2))) := lemma13 C2, cases set.finite.bdd_above hfin with C3 hC3, simp at hC3, cases set.finite.bdd_below hfin with C4 hC4, simp at hC4, use C1 + C1 + max (abs (C4)) (abs (C3)), simp_rw df_eq at *, intros p q, have hf' := hf, set t := g (p + q) - g p - g q with ht, have heq : g (p + q) = t + (g p + g q), rw ht, ring, specialize hf (g p) (g q), specialize hg p q, specialize hf' t (g p + g q), rw [← ht, abs_lt] at hg, specialize @hC3 (f t) t hg.1 hg.2 rfl, specialize @hC4 (f t) t hg.1 hg.2 rfl, rw ← heq at hf', have h123 : abs ((f (g p + g q) - f (g p) - f (g q)) + (f (g (p + q)) - f t - f (g p + g q)) + f t) ≤ abs (f (g p + g q) - f (g p) - f (g q)) + abs (f (g (p + q)) - f t - f (g p + g q)) + abs (f t), exact abs_add_three (f (g p + g q) - f (g p) - f (g q)) (f (g (p + q)) - f t - f (g p + g q)) (f t), have heq : (f (g p + g q) - f (g p) - f (g q)) + (f (g (p + q)) - f t - f (g p + g q)) + f t = (f ∘ g) (p + q) - (f ∘ g) p - (f ∘ g) q, ring, rw heq at h123, have hft : abs (f t) ≤ max (abs (C4)) (abs (C3)), apply abs_le_max_abs_abs hC4 hC3, linarith, end lemma lemma15 : ∀ {f1 g1 f2 g2 : S}, (@coe ↥S 𝔼) eudoxus_reals_group.has_lift_t f1 = ↑f2 → (@coe ↥S 𝔼) eudoxus_reals_group.has_lift_t g1 = ↑g2 → -(⟨f1.1 ∘ g1.1, lemma14 f1 g1⟩ : S) + (⟨f2.1 ∘ g2.1, lemma14 f2 g2⟩ : S) ∈ B := begin rintros ⟨f1, hf1⟩ ⟨g1, hfg⟩ ⟨f2, Bf2, hf2⟩ ⟨g2, hg2⟩ hf1f2 hg1g2, rw quotient_add_group.eq at *, cases hf1f2 with Cf hf1f2, cases hg1g2 with Cg hg1g2, have hfin : set.finite (f2 '' (set.Ioo (-Cg) (Cg))) := lemma13 Cg, cases set.finite.bdd_above hfin with C3 hC3, simp at hC3, cases set.finite.bdd_below hfin with C4 hC4, simp at hC4, use Cf + Bf2 + max (abs (C4)) (abs (C3)), simp_rw df_eq at hf2, intros x, set t := -g1 x + g2 x with ht, have heq : g2 x = t + g1 x, rw ht, ring, specialize hf1f2 (g1 x), specialize hg1g2 x, specialize hf2 t (g1 x), simp at hf1f2, simp at hg1g2, rw [← ht, abs_lt] at hg1g2, specialize @hC3 (f2 t) t hg1g2.1 hg1g2.2 rfl, specialize @hC4 (f2 t) t hg1g2.1 hg1g2.2 rfl, rw ← heq at hf2, simp, have h123 := abs_add_three (-(f1 (g1 x))+ f2 (g1 x)) (f2 (g2 x) - f2 t - f2 (g1 x)) (f2 t), have heq : (-(f1 (g1 x)) + f2 (g1 x)) + (f2 (g2 x) - f2 t - f2 (g1 x)) + f2 t = -(f1 (g1 x)) + f2 (g2 x), ring, rw heq at h123, have hft : abs (f2 t) ≤ max (abs (C4)) (abs (C3)), apply abs_le_max_abs_abs hC4 hC3, linarith, end lemma lemma16 : (id : ℤ → ℤ) ∈ S := begin use 1, intros p q, norm_num, end noncomputable def 𝔼.mul : 𝔼 → 𝔼 → 𝔼 := λ a b, begin choose f hf using lemma12 a, choose g hg using lemma12 b, let h : ↥S := ⟨f.1 ∘ g.1, lemma14 f g⟩, exact ↑h, end @[simp] lemma 𝔼.mul_eq (a b : 𝔼) : 𝔼.mul a b = (begin choose f hf using lemma12 a, choose g hg using lemma12 b, let h : ↥S := ⟨f.1 ∘ g.1, lemma14 f g⟩, exact ↑h, end : 𝔼) := rfl lemma lemma17 : ∀ x y : S, 𝔼.mul ↑x ↑y = ↑(⟨x.1 ∘ y.1, lemma14 x y⟩ : S) := begin intros x y, simp, rw quotient_add_group.eq, have hxeq := classical.some_spec (lemma12 ↑x), have hyeq := classical.some_spec (lemma12 ↑y), apply lemma15 hxeq hyeq, end lemma lemma18 : ∀ x y : S, x = y → -x + y ∈ B := begin intros x y hxy, rw hxy, simp, use 1, norm_num, end lemma lemma19 (f : S) : ∃ C, ∀ p (H : 0 ≤ p) q, abs (f.1 (p * q) - p * (f.1 q)) < (abs p + 1) * C := begin cases f.2 with C hC, use C, intros p H, induction p, { induction p with p hp, { intro q, simp, change abs (f.1 0) < C, have hf0 : abs (f.1 0) = abs (f.1 (0 + 0) - f.1 0 - f.1 0), simp, have hdf0 : df f.1 0 0 = f.1 (0 + 0) - f.1 0 - f.1 0 := rfl, rw [hf0, ← hdf0], exact hC 0 0, }, { intro q, specialize hp (int.of_nat_nonneg p) q, have hkey : f.val (int.of_nat p.succ * q) - f.1 (p * q) - f.1 q = df f.1 (p * q) q, simp, ring, specialize hC (p * q) q, rw ← hkey at hC, have heq : f.val (int.of_nat p.succ * q) - int.of_nat p.succ * f.val q = (f.val (int.of_nat p.succ * q) - f.val (↑p * q) - f.val q) + (f.val (int.of_nat p * q) - int.of_nat p * f.val q), simp, ring, rw heq, have : (abs (int.of_nat p.succ) + 1) * C = C + (abs (int.of_nat p) + 1) * C, have hp1 : 0 < (↑p : ℤ) + 1, linarith, simp, rw [abs_of_pos hp1], ring, linarith [abs_add (f.val (int.of_nat p.succ * q) - f.val (↑p * q) - f.val q) (f.val (int.of_nat p * q) - int.of_nat p * f.val q)], }, }, { exfalso, linarith [int.neg_succ_lt_zero p], }, end lemma lemma20 (f : S) : ∃ C, ∀ p (H : 0 ≤ p) q, abs (f.1 ((-p) * q) - (-p) * (f.1 q)) < (abs (-p) + 1) * C := begin cases f.2 with C hC, use C, intros p H, induction p, { induction p with p hp, { intro q, simp, change abs (f.1 0) < C, have hf0 : abs (f.1 0) = abs (f.1 (0 + 0) - f.1 0 - f.1 0), simp, have hdf0 : df f.1 0 0 = f.1 (0 + 0) - f.1 0 - f.1 0 := rfl, rw [hf0, ← hdf0], exact hC 0 0, }, { intro q, specialize hp (int.of_nat_nonneg p) q, have hkey : -f.1 (-int.of_nat p.succ * q) + f.1 (-(p * q)) - f.1 q = df f.1 (-(p + 1) * q) q, simp, have heq : (-1 + -↑p) * q + q = -(↑p * q), ring, rw heq, ring, specialize hC (-(↑p + 1) * q) q, rw ← hkey at hC, have heq : f.val (-int.of_nat p.succ * q) - -int.of_nat p.succ * f.val q = -(-f.val (-int.of_nat p.succ * q) + f.val (-(p * q)) - f.val q) + (f.val (-int.of_nat p * q) - -int.of_nat p * f.val q), simp, ring, rw heq, have : (abs (-int.of_nat p.succ) + 1) * C = C + (abs (-int.of_nat p) + 1) * C, have hp1 : 0 ≤ (↑p : ℤ) := int.of_nat_nonneg p, have hp2 : -1 + -(↑p : ℤ) < 0, linarith, simp, rw [abs_of_neg hp2], ring, have := abs_add (-(-f.val (-int.of_nat p.succ * q) + f.val (-(p * q)) - f.val q)) (f.val (-int.of_nat p * q) - -int.of_nat p * f.val q), rw abs_neg at this, linarith, }, }, { exfalso, linarith [int.neg_succ_lt_zero p], }, end lemma lemma21 (f : S) : ∃ C, ∀ p q, abs (f.1 (p * q) - p * (f.1 q)) < (abs p + 1) * C := begin cases lemma19 f with C1 hC1, cases lemma20 f with C2 hC2, use max C1 C2, intro p, have hp0 := le_or_lt 0 p, cases hp0, { intro q, specialize hC1 p hp0 q, have := le_max_left C1 C2, have h0abs : 0 < abs p + 1, linarith [abs_nonneg p], have : (abs p + 1) * C1 ≤ (abs p + 1) * max C1 C2, have := @mul_le_mul_left ℤ (linear_ordered_ring.to_linear_ordered_semiring) C1 (max C1 C2) (abs p + 1), rw this, exact le_max_left C1 C2, linarith, linarith, }, { intro q, set np := -p with hnp, have hnp0 : 0 ≤ np, linarith, specialize hC2 np hnp0 q, have hnpp : -np = p, rw hnp, simp, rw hnpp at hC2, have := le_max_left C1 C2, have h0abs : 0 < abs p + 1, linarith [abs_nonneg p], have : (abs p + 1) * C2 ≤ (abs p + 1) * max C1 C2, have := @mul_le_mul_left ℤ (linear_ordered_ring.to_linear_ordered_semiring) C2 (max C1 C2) (abs p + 1), rw this, exact le_max_right C1 C2, linarith, linarith, }, end lemma lemma22 (f : S) : ∃ C, ∀ p q, abs (p * (f.1 q) - q * (f.1 p)) < (abs p + abs q + 2) * C := begin cases lemma21 f with C hC, use C, intros p q, have hC' := hC, specialize hC p q, specialize hC' q p, rw ← abs_neg at hC, have heq1 : (-(f.val (p * q) - p * f.val q)) + (f.val (q * p) - q * f.val p) = p * f.val q - q * f.val p, rw mul_comm, ring, have heq2 : (abs p + abs q + 2) * C = ((abs p + 1) * C) + ((abs q + 1) * C), ring, rw [← heq1, heq2], linarith [abs_add (-(f.val (p * q) - p * f.val q)) (f.val (q * p) - q * f.val p)], end lemma lemma23 (f : S) : ∃ A B (hA : 0 < A), ∀ p, abs (f.1 p) < A * abs p + B := begin cases lemma22 f with C hC, have hC0 : 0 < C + abs (f.1 1), specialize hC 0 0, simp at hC, linarith [abs_nonneg (f.1 1)], use [C + abs (f.1 1), 3 * C, hC0], intro p, specialize hC p 1, have heq1 : f.1 p = -(p * f.1 1 - f.1 p) + (p * f.1 1), ring, have heq2 : (C + abs (f.val 1)) * abs p + 3 * C = (abs p + 1 + 2) * C + abs (p * f.1 1), have : abs (p * f.1 1) = (abs p) * abs (f.1 1) := abs_mul p (f.1 1), rw this, ring, rw [heq1, heq2], simp at hC, change abs (p * f.1 1 - f.1 p) < (abs p + 1 + 2) * C at hC, rw ← abs_neg at hC, linarith [abs_add (-(p * f.val 1 - f.val p)) (p * f.1 1)], end lemma lemma24 (f g : S) : ∃ D E, ∀ p, abs p * abs (f.1 (g.1 p) - g.1 (f.1 p)) < D * abs p + E := begin have h1 : ∃ C, ∀ p, abs (p * f.1 (g.1 p) - g.1 p * f.1 p) < (abs p + abs (g.1 p) + 2) * C, cases lemma22 f with C hC, use C, intro p, specialize hC p (g.1 p), exact hC, have h2 : ∃ C, ∀ p, abs (g.1 p * f.1 p - p * g.1 (f.1 p)) < (abs p + abs (f.1 p) + 2) * C, cases lemma22 g with C hC, use C, intro p, specialize hC p (f.1 p), have heq : p * g.val (f.val p) - f.val p * g.val p = -(g.val p * f.val p - p * g.val (f.val p)), ring, rw [heq, abs_neg] at hC, exact hC, have h3 : ∃ C, ∀ p, abs (p * f.1 (g.1 p) - p * g.1 (f.1 p)) < (2 * abs p + abs (g.1 p) + abs (f.1 p) + 4) * C, cases h1 with C1 h1, cases h2 with C2 h2, use max C1 C2, intro p, specialize h1 p, specialize h2 p, have h0abs1 : 0 < abs p + abs (g.val p) + 2, linarith [abs_nonneg p, abs_nonneg (g.val p)], have h0abs2 : 0 < abs p + abs (f.val p) + 2, linarith [abs_nonneg p, abs_nonneg (f.val p)], have : (abs p + abs (g.val p) + 2) * C1 ≤ (abs p + abs (g.val p) + 2) * max C1 C2, have := @mul_le_mul_left ℤ (linear_ordered_ring.to_linear_ordered_semiring) C1 (max C1 C2) (abs p + abs (g.val p) + 2), rw this, exact le_max_left C1 C2, linarith, have : (abs p + abs (f.val p) + 2) * C2 ≤ (abs p + abs (f.val p) + 2) * max C1 C2, have := @mul_le_mul_left ℤ (linear_ordered_ring.to_linear_ordered_semiring) C2 (max C1 C2) (abs p + abs (f.val p) + 2), rw this, exact le_max_right C1 C2, linarith, have heq1 : (2 * abs p + abs (g.val p) + abs (f.val p) + 4) * max C1 C2 = (abs p + abs (g.val p) + 2) * max C1 C2 + (abs p + abs (f.val p) + 2) * max C1 C2, ring, have heq2 : p * f.val (g.val p) - p * g.val (f.val p) = (p * f.1 (g.1 p) - g.1 p * f.1 p) + (g.1 p * f.1 p - p * g.1 (f.1 p)), ring, rw [heq1, heq2], linarith [abs_add (p * f.1 (g.1 p) - g.1 p * f.1 p) (g.1 p * f.1 p - p * g.1 (f.1 p))], cases h3 with C h3, rcases lemma23 f with ⟨Af, Bf, hAf, hABf⟩, rcases lemma23 g with ⟨Ag, Bg, hAg, hABg⟩, have h4 : ∀ (p : ℤ), abs (p * f.val (g.val p) - p * g.val (f.val p)) < (2 * abs p + (Ag * abs p + Bg) + (Af * abs p + Bf) + 4) * C, intro p, specialize hABf p, specialize hABg p, specialize h3 p, have h0abs : 0 < (2 * abs p + abs (g.val p) + abs (f.val p) + 4), linarith [abs_nonneg p, abs_nonneg (g.val p), abs_nonneg (f.val p)], have : (2 * abs p + abs (g.val p) + abs (f.val p) + 4) * C < (2 * abs p + (Ag * abs p + Bg) + (Af * abs p + Bf) + 4) * C, have hfvalgval : (2 * abs p + abs (g.val p) + abs (f.val p) + 4) < (2 * abs p + (Ag * abs p + Bg) + (Af * abs p + Bf) + 4), linarith, apply mul_lt_mul hfvalgval (le_refl C), have := abs_nonneg (p * f.val (g.val p) - p * g.val (f.val p)), have h0mul : 0 < (2 * abs p + abs (g.val p) + abs (f.val p) + 4) * C, linarith, have : 0 < C, exact (zero_lt_mul_left h0abs).mp h0mul, linarith, linarith, linarith, use [(2 + Ag + Af) * C, (Bg + Bf + 4) * C], intro p, specialize h4 p, have heq1 : (2 * abs p + (Ag * abs p + Bg) + (Af * abs p + Bf) + 4) * C = (2 * abs p + (Ag * abs p + Bg) + (Af * abs p + Bf) + 4) * C, ring, have heq2 : abs p * abs (f.val (g.val p) - g.val (f.val p)) = abs (p * f.val (g.val p) - p * g.val (f.val p)), have := (abs_mul p (f.val (g.val p) - g.val (f.val p))).symm, convert this, ring, linarith, end lemma lemma25 (f g : S) : -(⟨f.1 ∘ g.1, lemma14 f g⟩ : S) + (⟨g.1 ∘ f.1, lemma14 g f⟩ : S) ∈ B := begin rcases lemma24 f g with ⟨D, E, hDE⟩, simp, change ∃ (C : ℤ), ∀ (p : ℤ), abs (-(f.1 (g.1 p)) + g.1 (f.1 p)) < C, have h1 : ∀ p (H : abs E < abs p), abs (f.val (g.val p) - g.val (f.val p)) < D + 1, intros p hp, specialize hDE p, have hDE' : abs p * abs (f.val (g.val p) - g.val (f.val p)) < D * abs p + abs E, linarith [le_abs_self E], have : abs p * abs (f.val (g.val p) - g.val (f.val p)) < abs p * (D + 1), linarith, have habsp : abs p > 0, linarith [abs_nonneg E], have hiff := @mul_lt_mul_left ℤ (linear_ordered_ring.to_linear_ordered_semiring) (abs (f.val (g.val p) - g.val (f.val p))) (D + 1) (abs p) habsp, rw ← hiff, exact this, have hB : ∃ B, ∀ (p : ℤ), abs p ≤ abs E → abs (f.val (g.val p) - g.val (f.val p)) < B, have hfin : set.finite ((λ p, abs (f.val (g.val p) - g.val (f.val p))) '' (set.Icc (-(abs E)) (abs E))), apply set.finite.image, exact ⟨fintype.of_finset (finset.Ico_ℤ (-(abs E)) (abs E + 1)) (by {simp [int.lt_add_one_iff]})⟩, have hbdd : bdd_above ((λ p, abs (f.val (g.val p) - g.val (f.val p))) '' (set.Icc (-(abs E)) (abs E))), apply set.finite.bdd_above hfin, cases hbdd with m hm, simp at hm, use m + 1, intros p hpE, rw abs_le at hpE, specialize @hm (abs (f.val (g.val p) - g.val (f.val p))) p hpE.1 hpE.2 rfl, linarith, cases hB with B hB, use max B (D + 1), intro p, rw ← abs_neg, have : -(-f.val (g.val p) + g.val (f.val p)) = f.val (g.val p) - g.val (f.val p), ring, rw this, have hpE := le_or_lt (abs p) (abs E), cases hpE, specialize hB p hpE, linarith [le_max_left B (D + 1)], specialize h1 p hpE, linarith [le_max_right B (D + 1)], end lemma 𝔼.mul_comm : ∀ (a b : 𝔼), 𝔼.mul a b = 𝔼.mul b a := begin intros a b, cases lemma12 a with u hu, cases lemma12 b with v hv, rw [← hu, ← hv, lemma17 u v, lemma17 v u, quotient_add_group.eq], apply lemma25, end lemma 𝔼.mul_right_distrib : ∀ (a b c : 𝔼), 𝔼.mul (a + b) c = 𝔼.mul a c + 𝔼.mul b c := begin intros a b c, cases lemma12 a with u hu, cases lemma12 b with v hv, cases lemma12 c with w hw, have H1 := lemma17 (u + v) w, have H2 := lemma17 u w, have H3 := lemma17 v w, have heq : ∀ v w, (@coe ↥S 𝔼) eudoxus_reals_group.has_lift_t (v + w) = @has_add.add 𝔼 (@add_semigroup.to_has_add 𝔼 (add_monoid.to_add_semigroup 𝔼)) ↑v ↑w := λ v w, rfl, rw heq at H1, rw [← hu, ← hv, ← hw], rw [H1, H2, H3, ← heq, quotient_add_group.eq], apply lemma18, simp, end noncomputable instance comm_ring_𝔼 : comm_ring 𝔼 := { mul := 𝔼.mul, mul_assoc := begin intros a b c, cases lemma12 a with u hu, cases lemma12 b with v hv, cases lemma12 c with w hw, set ab : ↥S := ⟨u.1 ∘ v.1, lemma14 u v⟩ with hab, set abc : ↥S := ⟨ab.1 ∘ w.1, lemma14 ab w⟩ with habc, set bc : ↥S := ⟨v.1 ∘ w.1, lemma14 v w⟩ with hbc, set abc' : ↥S := ⟨u.1 ∘ bc.1, lemma14 u bc⟩ with habc', have H1 := lemma17 u v, have H2 := lemma17 ab w, have H3 := lemma17 v w, have H4 := lemma17 u bc, rw [hu, hv] at H1, rw [hab, ← habc, ← H1, hw] at H2, rw [hv, hw] at H3, rw [hbc, ← habc', ← H3, hu] at H4, show 𝔼.mul (𝔼.mul a b) c = 𝔼.mul a (𝔼.mul b c), rw [H2, H4], end, one := ↑(⟨(id : ℤ → ℤ), lemma16⟩ : S), one_mul := begin intro a, cases lemma12 a with u hu, rw ← hu, change 𝔼.mul ↑(⟨(id : ℤ → ℤ), lemma16⟩ : S) (↑u : 𝔼) = ↑u, simp, rw quotient_add_group.eq, have h1 := classical.some_spec (lemma12 ↑u), have h2 := classical.some_spec (lemma12 ↑(⟨(id : ℤ → ℤ), lemma16⟩ : S)), have h3 := lemma15 h2 h1, have h4 : u = (⟨(⟨(id : ℤ → ℤ), lemma16⟩ : S).val ∘ u.val, lemma14 ⟨(id : ℤ → ℤ), lemma16⟩ u⟩ : S), simp, rw h4, convert h3, simp, end, mul_one := begin intro a, cases lemma12 a with u hu, rw ← hu, change 𝔼.mul (↑u : 𝔼) ↑(⟨(id : ℤ → ℤ), lemma16⟩ : S) = ↑u, simp, rw quotient_add_group.eq, have h1 := classical.some_spec (lemma12 ↑u), have h2 := classical.some_spec (lemma12 ↑(⟨(id : ℤ → ℤ), lemma16⟩ : S)), have h3 := lemma15 h1 h2, have h4 : u = (⟨(⟨(id : ℤ → ℤ), lemma16⟩ : S).val ∘ u.val, lemma14 ⟨(id : ℤ → ℤ), lemma16⟩ u⟩ : S), simp, rw h4, convert h3, simp, end, left_distrib := begin intros a b c, change 𝔼.mul a (b + c) = 𝔼.mul a b + 𝔼.mul a c, rw [𝔼.mul_comm], have := 𝔼.mul_comm a c, symmetry, rw [𝔼.mul_comm, this], symmetry, apply 𝔼.mul_right_distrib, end, right_distrib := begin intros a b c, change 𝔼.mul (a + b) c = 𝔼.mul a c + 𝔼.mul b c, apply 𝔼.mul_right_distrib, end, mul_comm := begin intros a b, apply 𝔼.mul_comm, end, ..add_comm_group_𝔼 } @[simp] lemma 𝔼.mul_eq' (a b : 𝔼) : a * b = 𝔼.mul a b := rfl @[simp] lemma 𝔼.one_eq' : (1 : 𝔼) = ↑(⟨(id : ℤ → ℤ), lemma16⟩ : S) := rfl lemma lemma26 {f : ℤ → ℤ} : (∀ p < 0, f p = -(f (-p))) → (∃ C, ∀ m n (hm : 0 ≤ m) (hn : 0 ≤ n), abs (df f m n) < C) → f ∈ S := begin rintro h1 ⟨C, h2⟩, use C, intros p q, have hp := le_or_lt 0 p, have hq := le_or_lt 0 q, cases hp, { cases hq, exact h2 p q hp hq, have hpq := le_or_lt 0 (p + q), cases hpq, have h0q : 0 ≤ -q, linarith, simp, specialize h2 (p + q) (-q) hpq h0q, simp at h2, have : -(f (p + q) - f p - -f (-q)) = f p - f (p + q) - f (-q), ring, rw [h1 q hq, ← abs_neg, this], exact h2, have hpq' : 0 ≤ -(p + q), linarith, specialize h2 (-(p + q)) p hpq' hp, simp at h2, simp, have : -f (-(p + q)) - f p - -f (-q) = f (-q) - f (-q + -p) - f p, have : -(p + q) = -q + -p, ring, rw this, ring, rw [h1 q hq, h1 (p + q) hpq, this], exact h2, }, cases hq, { have hpq := le_or_lt 0 (p + q), cases hpq, have h0p : 0 ≤ -p, linarith, simp, specialize h2 (p + q) (-p) hpq h0p, simp at h2, have : -(f (p + q) - -f (-p) - f q) = f (p + q + -p) - f (p + q) - f (-p), have : p + q + -p = q, ring, rw this, ring, rw [h1 p hp, ← abs_neg, this], simp [h2], have hpq' : 0 ≤ -(p + q), linarith, specialize h2 (-(p + q)) q hpq' hq, simp at h2, simp, have : -f (-(p + q)) - -f (-p) - f q = f (-q + -p + q) - f (-q + -p) - f q, have eq1 : -(p + q) = -q + -p, ring, have eq2 : -q + -p + q = -p, ring, rw [eq1, eq2], ring, rw [h1 p hp, h1 (p + q) hpq, this], simp [h2], }, have H1 : df f p q = -(df f (-p) (-q)), have hpq : p + q < 0, linarith, have heq : -(p + q) = -p - q, ring, simp, rw [h1 p hp, h1 q hq, h1 (p + q) hpq], ring, rw heq, ring, have h0p : 0 ≤ -p, linarith, have h0q : 0 ≤ -q, linarith, specialize h2 (-p) (-q) h0p h0q, rw [H1, abs_neg], exact h2, end lemma lemma27 (S : set ℤ) : S.nonempty → (∀ n : ℤ, n ∈ S → 0 ≤ n) → ∃ n ∈ S, ∀ m ∈ S, n ≤ m := begin intros H1 H2, set S' := {a : ℕ | ∃ (s : ℤ) (Hs : s ∈ S), s = ↑a}, have hS' : S'.nonempty, show ∃ (t : ℕ) (s : ℤ) (Hs : s ∈ S), s = ↑t, cases H1 with x hx, specialize H2 x hx, have := int.eq_coe_of_zero_le H2, cases this, use [this_w, x, hx, this_h], have hS'S : ∀ {a : ℕ}, a ∈ S' → ↑a ∈ S, rintro a ⟨a', ha', haa'⟩, rw ← haa', exact ha', use ↑(nat.find_x hS').1, cases (nat.find_x hS').2 with h1 h2, use hS'S h1, intros m hm, specialize H2 m hm, cases int.eq_coe_of_zero_le H2 with m' hm', specialize h2 m', have h2' : m' ∈ S' → (nat.find_x hS').val ≤ m', contrapose, simp only [exists_prop, not_le, exists_eq_right], exact h2, have : m' ∈ S' := ⟨m, hm, hm'⟩, specialize h2' this, rw hm', exact int.coe_nat_le.mpr h2', end def P' := {f : S | ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p} @[simp] lemma in_P'_iff (f : S) : f ∈ P' ↔ ∀ n (hn : 0 < n), ∃ p (hp : 0 < p), n < f.1 p := iff.rfl lemma lemma28 (f : P') : ∀ p (hp : 0 ≤ p), ∃ n (hn : n ∈ {m | p ≤ f.1.1 m ∧ 0 ≤ m}), ∀ x ∈ {m | p ≤ f.1.1 m ∧ 0 ≤ m}, n ≤ x := begin intros p hp, cases f with f hf, rw in_P'_iff at hf, rw lemma8 f at hf, have hp1 : 0 < p + 1, linarith, specialize hf (p + 1) hp1, have hnonempty : {m : ℤ | p ≤ f.val m ∧ 0 ≤ m}.nonempty, cases hf with N hf, have hN : N < max 0 (N + 1), rw lt_max_iff, right, linarith, specialize hf (max 0 (N + 1)) hN, use (max 0 (N + 1)), simp only [set.mem_set_of_eq], split, linarith, rw le_max_iff, left, linarith, have hall : ∀ n : ℤ, n ∈ {m : ℤ | p ≤ f.val m ∧ 0 ≤ m} → 0 ≤ n, intros n hn, exact hn.2, exact lemma27 {m : ℤ | p ≤ f.val m ∧ 0 ≤ m} hnonempty hall, end lemma lemma29 (a : 𝔼) : a ∈ P ∨ a = 0 ∨ -a ∈ P := begin cases lemma12 a with u hu, cases lemma5 u, left, use [u.1, u.2], simp only [subtype.coe_eta, subtype.val_eq_coe], use [hu, h], cases h, right, right, have : ↑-u = -a, rw ← hu, refl, use [-u, this], intros n hn, have hn0 : -n < 0, linarith, specialize h (-n) hn0, rcases h with ⟨p, hp, h⟩, use [p, hp], have huval : (-u).val p = -(u.val p) := rfl, linarith, right, left, have : (0 : 𝔼) = ↑(0 : S) := rfl, symmetry, rw [← hu, this, quotient_add_group.eq], simp, exact lemma4 u h, end lemma lemma30 {a : 𝔼} : a ∉ P → ¬(a = 0) → -a ∈ P := begin intros h1 h2, cases lemma29 a, exfalso, exact h1 h, cases h, exfalso, exact h2 h, exact h, end noncomputable def 𝔼.inv.g1 : P' → (ℤ → ℤ) := λ f, (λ p, if hp : 0 ≤ p then begin choose n hn using lemma28 f p hp, exact n, end else begin have hp' : 0 ≤ -p, linarith, choose n hn using lemma28 f (-p) hp', exact -n, end) lemma lemma31 (f : P') : ∀ n (hn : 0 ≤ n), 0 ≤ 𝔼.inv.g1 f n := begin intros n hn, simp only [𝔼.inv.g1], split_ifs, have := classical.some_spec (lemma28 f n hn), cases this with hsome1 hsome2, rw set.mem_set_of_eq at hsome1, exact hsome1.2, end lemma lemma32 (f : P') : ∃ n (hn : 0 < n), 0 < 𝔼.inv.g1 f n := begin by_contradiction hfalse, have hfalse' : ∀ n (hn : 0 < n), 𝔼.inv.g1 f n ≤ 0, rw not_exists at hfalse, intros n hn, specialize hfalse n, rw not_exists at hfalse, specialize hfalse hn, linarith, clear hfalse, cases f with f hf, rw in_P'_iff at hf, have hfalse1 : ∀ (n : ℤ), 0 < n → 𝔼.inv.g1 ⟨f, hf⟩ n = 0, intros n hn0, specialize hfalse' n hn0, have hn0' : 0 ≤ n, linarith, have := lemma31 ⟨f, hf⟩ n hn0', exact le_antisymm hfalse' this, have hfalse2 : ∀ (n : ℤ), 0 < n → n ≤ f.1 0, intros n hn, specialize hfalse1 n hn, simp only [𝔼.inv.g1] at hfalse1, split_ifs at hfalse1, have hn' : 0 ≤ n, linarith, have := classical.some_spec (lemma28 ⟨f, hf⟩ n hn'), cases this with hsome1 hsome2, simp at hsome1, rw ← hfalse1, simp, exact hsome1.1, exfalso, linarith, have hlt : 0 < max (f.val 0 + 1) 1, rw lt_max_iff, right, norm_num, specialize hfalse2 (max (f.val 0 + 1) 1) hlt, have : (f.val 0 + 1) ≤ max (f.val 0 + 1) 1 := le_max_left (f.val 0 + 1) 1, linarith, end lemma lemma33 (f : P') : ∀ n m (hn : 0 ≤ n) (hm : n ≤ m), 𝔼.inv.g1 f n ≤ 𝔼.inv.g1 f m := begin intros n m hn hm, simp only [𝔼.inv.g1], have hm' : 0 ≤ m, linarith, split_ifs, have h1 := classical.some_spec (lemma28 f n hn), have h2 := classical.some_spec (lemma28 f m hm'), set gn := classical.some (lemma28 f n hn) with hgn, set gm := classical.some (lemma28 f m hm') with hgm, rw ← hgn at *, rw ← hgm at *, cases h1 with h11 h12, cases h2 with h21 h22, rw set.mem_set_of_eq at *, have : n ≤ f.val.val gm, linarith, specialize h12 gm, rw set.mem_set_of_eq at h12, specialize h12 ⟨this, h21.2⟩, exact h12, end lemma lemma34 (f : P') : ∃ N (HN : 0 < N), ∀ n (hn : N ≤ n), 0 < 𝔼.inv.g1 f n := begin rcases lemma32 f with ⟨N, hN, h⟩, have : 0 ≤ N, linarith, use [N, hN], intros n hNn, have := lemma33 f N n this hNn, linarith, end lemma lemma35 (f : P') : ∀ n (hn : 0 ≤ n), n ≤ f.1.1 (𝔼.inv.g1 f n) := begin intros n h0n, simp only [𝔼.inv.g1], split_ifs, have := classical.some_spec (lemma28 f n h0n), set gn := classical.some (lemma28 f n h0n) with hgn, rw ← hgn at *, cases this with hgn1 hgn2, rw set.mem_set_of_eq at hgn1, exact hgn1.1, end lemma lemma36 (f g h : ℤ → ℤ → ℤ) {c : ℤ} {F : P'} : (∀ a b (ha : c ≤ a) (hb : 0 ≤ b) (hgb : 0 < 𝔼.inv.g1 F b), f a b > 0 ∧ g a b < 0) → (∃ C, ∀ a b, abs (h a b - f a b) < C) → (∃ D, ∀ a b, abs (h a b - g a b) < D) → (∃ E, ∀ a b (ha : c ≤ a) (hb : 0 ≤ b) (hgb : 0 < 𝔼.inv.g1 F b), abs (h a b) < E) := begin rintro h ⟨C, h1⟩ ⟨D, h2⟩, use C + D, intros a b ha hb hgb, specialize h a b ha hb hgb, specialize h1 a b, specialize h2 a b, cases h with hf hg, rw abs_lt at *, cases h1, cases h2, split, linarith, linarith, end lemma lemma37 (f : P') (T : set ℤ) : (∃ C, ∀ x ∈ T, abs (f.1.1 x) < C) → (∃ B, ∀ x ∈ T, abs x ≤ B) := begin rintro ⟨C, hC⟩, by_contradiction hfalse, have hfalse' : ∀ (B : ℤ), ∃ (x : ℤ), x ∈ T ∧ B < abs x, rw not_exists at hfalse, intro B, specialize hfalse B, rw not_forall at hfalse, cases hfalse with x hx, use x, rw not_imp at hx, use hx.1, have := hx.2, simp at this, exact this, clear hfalse, cases f with f hf, rw in_P'_iff at hf, have := lemma2 f hf, have hD : ∃ D, ∀ p, abs (f.1 p + f.1 (-p)) < D, rcases f with ⟨f, E, hE⟩, use E + abs (f 0), intro p, specialize hE p (-p), rw ← abs_neg at hE, simp at hE, simp, have heq : f p + f (-p) = (f (-p) - (f 0 - f p)) + f 0, ring, rw heq, linarith [abs_add (f (-p) - (f 0 - f p)) (f 0), le_abs_self (f 0)], cases hD with D hD, have h0D : 0 < D, linarith [hD 0, abs_nonneg (f.1 0 + f.1 (-0))], have hCD : 0 < max 0 C + D, linarith [le_max_left 0 C], specialize this (max 0 C + D) hCD, cases this with N hN, rcases hfalse' N with ⟨x, hxT, hNx⟩, rw lt_abs at hNx, cases hNx, specialize hC x hxT, specialize hN x hNx, simp at hC, simp at hN, linarith [le_abs_self ((↑f : (ℤ → ℤ)) x), le_max_left 0 C, le_max_right 0 C], specialize hC x hxT, specialize hN (-x) hNx, specialize hD x, simp at hC, simp at hN, have : abs ((↑f : ℤ → ℤ) (-x)) < C + D, rw ← abs_neg at hC, simp at hD, have : (↑f : ℤ → ℤ) (-x) = -(↑f : ℤ → ℤ) x + ((↑f : ℤ → ℤ) x + (↑f : ℤ → ℤ) (-x)), ring, rw this, linarith [abs_add (-(↑f : ℤ → ℤ) x) ((↑f : ℤ → ℤ) x + (↑f : ℤ → ℤ) (-x))], linarith [le_abs_self ((↑f : (ℤ → ℤ)) (-x)), le_max_right 0 C], end lemma lemma38 (f : P') : ∃ C, ∀ m n, abs ((f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n)) - (f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m - 1) - f.1.1 (𝔼.inv.g1 f n - 1))) < C := begin rcases f with ⟨⟨f, C, hC⟩, hf⟩, use 2 * C + 2 * abs (f 1), intros m n, simp, ring, have hC' := hC, specialize hC (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ m - 1) 1, specialize hC' (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ n - 1) 1, simp at hC, simp at hC', rw abs_lt at *, cases hC, cases hC', split, linarith [le_abs_self (f 1)], linarith [le_abs_self (-f 1), abs_neg (f 1)], end lemma lemma39 (f : P') : ∃ C, ∀ m n, abs ((f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n)) - (f.1.1 (𝔼.inv.g1 f (m + n) - 1) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n))) < C := begin rcases f with ⟨⟨f, C, hC⟩, hf⟩, use C + abs (f 1), intros m n, simp, ring, specialize hC (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ (m + n) - 1) 1, simp at hC, rw abs_lt at *, cases hC, split, linarith [le_abs_self (-f 1), abs_neg (f 1)], linarith [le_abs_self (f 1)], end lemma lemma40 (f : P') : ∃ C, ∀ m n, abs (f.1.1 (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)) - (f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n))) < C := begin rcases f with ⟨⟨f, C, hC⟩, hf⟩, use 2 * C, intros m n, have : ∀ p q r, abs (f(r - p - q) - (f r - f p - f q)) < 2 * C, intros p q r, have hC' := hC, specialize hC (r - p - q) (p + q), specialize hC' p q, simp at hC, simp at hC', rw abs_lt at *, cases hC, cases hC', split, linarith, linarith, exact this (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ m) (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ n) (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ (m + n)), end lemma lemma41 (f : P') : ∃ C, ∀ m n, abs (f.1.1 (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)) - (f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m - 1) - f.1.1 (𝔼.inv.g1 f n - 1))) < C := begin cases lemma38 f with C1 hC1, cases lemma40 f with C2 hC2, use C1 + C2, intros m n, specialize hC1 m n, specialize hC2 m n, rw abs_lt at *, split, linarith, linarith, end lemma lemma42 (f : P') : ∃ C, ∀ m n, abs (f.1.1 (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)) - (f.1.1 (𝔼.inv.g1 f (m + n) - 1) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n))) < C := begin cases lemma39 f with C1 hC1, cases lemma40 f with C2 hC2, use C1 + C2, intros m n, specialize hC1 m n, specialize hC2 m n, rw abs_lt at *, split, linarith, linarith, end lemma lemma43 (f : P') : ∀ n (hn : 0 ≤ n), 0 < 𝔼.inv.g1 f n → (f.1.1 (𝔼.inv.g1 f n - 1) < n ∧ n ≤ f.1.1 (𝔼.inv.g1 f n)) := begin intros n h0n h, simp only [𝔼.inv.g1], split, { split_ifs, have := classical.some_spec (lemma28 f n h0n), set gn := classical.some (lemma28 f n h0n) with hgn, rw ← hgn at *, cases this with hgn1 hgn2, by_contradiction hfgn, rw not_lt at hfgn, specialize hgn2 (gn - 1), have : gn - 1 ∈ {m : ℤ | n ≤ f.val.val m ∧ 0 ≤ m}, rw set.mem_set_of_eq, use hfgn, simp only [𝔼.inv.g1] at h, split_ifs at h, rw ← hgn at *, linarith, specialize hgn2 this, linarith, }, { exact lemma35 f n h0n, }, end lemma lemma44 (f : P') : ∃ C, ∀ m n (hgn : 0 = 𝔼.inv.g1 f n), abs ((f.1.1 (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n))) - (f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m - 1))) < C := begin rcases f with ⟨⟨f, C, hC⟩, hf⟩, use 2 * C + abs (f 1), intros m n hgn, rw ←hgn, simp only [sub_zero, neg_add_rev, zero_add, set.mem_set_of_eq, add_neg_le_iff_le_add', neg_zero], have : ∀ p q, abs (f (p - q) - (f p - f (q - 1))) < 2 * C + abs (f 1), intros p q, have hC' := hC, specialize hC 1 (q - 1), specialize hC' (p - q) q, simp at hC, simp at hC', rw abs_lt at *, cases hC, cases hC', split, linarith [le_abs_self (f 1)], linarith [le_abs_self (-f 1), abs_neg (f 1)], specialize this (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ (m + n)) (𝔼.inv.g1 ⟨⟨f, _⟩, hf⟩ (m)), exact this, end lemma lemma45 (f g h : ℤ → ℤ → ℤ) {c : ℤ} {F : P'} : (∀ a b (ha : c ≤ a) (hb : 0 ≤ b) (hgb : 0 = 𝔼.inv.g1 F b), f a b > 0 ∧ g a b < 0) → (∃ C, ∀ a b (hgb : 0 = 𝔼.inv.g1 F b), abs (h a b - f a b) < C) → (∃ D, ∀ a b, abs (h a b - g a b) < D) → (∃ E, ∀ a b (ha : c ≤ a) (hb : 0 ≤ b) (hgb : 0 = 𝔼.inv.g1 F b), abs (h a b) < E) := begin rintro h ⟨C, h1⟩ ⟨D, h2⟩, use C + D, intros a b ha hb hgb, specialize h a b ha hb hgb, specialize h1 a b hgb, specialize h2 a b, cases h with hf hg, rw abs_lt at *, cases h1, cases h2, split, linarith, linarith, end lemma lemma46 (f : P') : ∃ (N : ℤ) (C : ℤ) , ∀ (m n : ℤ), N ≤ m → 0 ≤ n → abs (df (λ (p : ℤ), 𝔼.inv.g1 f p) m n) < C := begin rcases lemma34 f with ⟨N, hN, hfN⟩, have h1 : ∀ m n (hm : N ≤ m) (h0n : 0 ≤ n) (hgn : 0 < 𝔼.inv.g1 f n), (f.1.1 (𝔼.inv.g1 f m - 1) < m ∧ m ≤ f.1.1 (𝔼.inv.g1 f m)) ∧ (f.1.1 (𝔼.inv.g1 f n - 1) < n ∧ n ≤ f.1.1 (𝔼.inv.g1 f n)) ∧ (f.1.1 (𝔼.inv.g1 f (m + n) - 1) < m + n ∧ m + n ≤ f.1.1 (𝔼.inv.g1 f (m + n))), intros m n hm h0n hgn, have h0m : 0 ≤ m, linarith, have h0mn : 0 ≤ m + n, linarith, have hmn : N ≤ m + n, linarith, use [lemma43 f m h0m (hfN m hm), lemma43 f n h0n hgn, lemma43 f (m + n) h0mn (hfN (m + n) hmn)], set f1 : ℤ → ℤ → ℤ := λ m n, f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m - 1) - f.1.1 (𝔼.inv.g1 f n - 1), set f2 : ℤ → ℤ → ℤ := λ m n, f.1.1 (𝔼.inv.g1 f (m + n) - 1) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n), set f3 : ℤ → ℤ → ℤ := λ m n, f.1.1 (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)), have h2 : ∀ m n (hm : N ≤ m) (h0n : 0 ≤ n) (hgn : 0 < 𝔼.inv.g1 f n), f1 m n > 0 ∧ f2 m n < 0, intros m n hm h0n hgn, rcases h1 m n hm h0n hgn with ⟨⟨hm1, hm2⟩, ⟨hn1, hn2⟩, ⟨hmn1, hmn2⟩⟩, simp only [sub_lt_zero, gt_iff_lt, sub_pos], split, linarith, linarith, have := lemma36 f1 f2 f3 h2 (lemma41 f) (lemma42 f), set T := {t | ∃ m n (hm : N ≤ m) (hn : 0 ≤ n) (hgn : 0 < 𝔼.inv.g1 f n), (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)) = t}, have hCT : ∃ C, ∀ x ∈ T, abs (f.1.1 x) < C, cases this with E hE, use E, intros x hxT, rcases hxT with ⟨m, n, hm, hn, hgn, h⟩, specialize hE m n hm hn hgn, rw ← h, linarith, cases lemma37 f T hCT with C1 hC1, have h3 : ∀ m n (hm : N ≤ m) (h0n : 0 ≤ n) (hgn : 0 = 𝔼.inv.g1 f n), (f.1.1 (𝔼.inv.g1 f m - 1) < m ∧ m ≤ f.1.1 (𝔼.inv.g1 f m)) ∧ (n ≤ f.1.1 (𝔼.inv.g1 f n)) ∧ (f.1.1 (𝔼.inv.g1 f (m + n) - 1) < m + n ∧ m + n ≤ f.1.1 (𝔼.inv.g1 f (m + n))), intros m n hm h0n hgn, have h0m : 0 ≤ m, linarith, have h0mn : 0 ≤ m + n, linarith, have hmn : N ≤ m + n, linarith, use [lemma43 f m h0m (hfN m hm), lemma35 f n h0n, lemma43 f (m + n) h0mn (hfN (m + n) hmn)], set f1' : ℤ → ℤ → ℤ := λ m n, f.1.1 (𝔼.inv.g1 f (m + n)) - f.1.1 (𝔼.inv.g1 f m - 1), set f2' : ℤ → ℤ → ℤ := λ m n, f.1.1 (𝔼.inv.g1 f (m + n) - 1) - f.1.1 (𝔼.inv.g1 f m) - f.1.1 (𝔼.inv.g1 f n), set f3' : ℤ → ℤ → ℤ := λ m n, f.1.1 (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)), have h4 : ∀ m n (hm : N ≤ m) (h0n : 0 ≤ n) (hgn : 0 = 𝔼.inv.g1 f n), f1' m n > 0 ∧ f2' m n < 0, intros m n hm h0n hgn, rcases h3 m n hm h0n hgn with ⟨⟨hm1, hm2⟩, hn1, ⟨hmn1, hmn2⟩⟩, simp only [sub_lt_zero, gt_iff_lt, sub_pos], split, linarith, linarith, have := lemma45 f1' f2' f3' h4 (lemma44 f) (lemma42 f), set T' := {t | ∃ m n (hm : N ≤ m) (hn : 0 ≤ n) (hgn : 0 = 𝔼.inv.g1 f n), (𝔼.inv.g1 f (m + n) - (𝔼.inv.g1 f m) - (𝔼.inv.g1 f n)) = t}, have hCT' : ∃ C, ∀ x ∈ T', abs (f.1.1 x) < C, cases this with E hE, use E, intros x hxT, rcases hxT with ⟨m, n, hm, hn, hgn, h⟩, specialize hE m n hm hn hgn, rw ← h, linarith, cases lemma37 f T hCT with C1 hC1, cases lemma37 f T' hCT' with C2 hC2, use [N, (max C1 C2) + 1], intros m n hm hn, by_cases hgn : 0 = 𝔼.inv.g1 f n, { specialize hC2 (df (λ (p : ℤ), 𝔼.inv.g1 f p) m n), have : df (λ (p : ℤ), 𝔼.inv.g1 f p) m n ∈ T', simp, use [m, hm, n, hn, hgn], specialize hC2 this, linarith [le_max_right C1 C2], }, { have hgn' : 0 < 𝔼.inv.g1 f n, have := lemma31 f n hn, exact lt_of_le_of_ne this hgn, specialize hC1 (df (λ (p : ℤ), 𝔼.inv.g1 f p) m n), have : df (λ (p : ℤ), 𝔼.inv.g1 f p) m n ∈ T, simp, use [m, hm, n, hn, hgn'], specialize hC1 this, linarith [le_max_left C1 C2], }, end lemma lemma47 (f : P') : ∃ (C : ℤ) , ∀ (m n : ℤ), 0 ≤ m → 0 ≤ n → abs (df (λ (p : ℤ), 𝔼.inv.g1 f p) m n) < C := begin rcases lemma46 f with ⟨N, C, hfN⟩, have hfs1 : set.finite (set.image2 (λ m n, abs (df (λ (p : ℤ), 𝔼.inv.g1 f p) m n)) {m | 0 ≤ m ∧ m < N} {n | 0 ≤ n ∧ n < N}), apply set.finite.image2, split, apply fintype.of_finset (finset.Ico_ℤ 0 N), simp, split, apply fintype.of_finset (finset.Ico_ℤ 0 N), simp, have hbdd : bdd_above (set.image2 (λ m n, abs (df (λ (p : ℤ), 𝔼.inv.g1 f p) m n)) {m | 0 ≤ m ∧ m < N} {n | 0 ≤ n ∧ n < N}), apply set.finite.bdd_above hfs1, simp at hbdd, cases hbdd with C1 hC1, simp at hC1, use max C C1 + 1, intros m n hm hn, have hmN := lt_or_le m N, have hnN := lt_or_le n N, cases hmN, { cases hnN, specialize @hC1 (abs (𝔼.inv.g1 f (m + n) - 𝔼.inv.g1 f m - 𝔼.inv.g1 f n)) m hm hmN n hn hnN rfl, simp, linarith [le_max_right C C1], specialize hfN n m hnN hm, simp at hfN, simp, have : 𝔼.inv.g1 f (m + n) - 𝔼.inv.g1 f m - 𝔼.inv.g1 f n = 𝔼.inv.g1 f (n + m) - 𝔼.inv.g1 f n - 𝔼.inv.g1 f m, rw [add_comm], ring, rw this, linarith [le_max_left C C1], }, { specialize hfN m n hmN hn, linarith [le_max_left C C1], }, end noncomputable def 𝔼.inv.g : P' → S := λ f, ⟨λ p, 𝔼.inv.g1 f p, begin apply lemma26, { intros p hp, simp only [𝔼.inv.g1], split_ifs with hp1 hp2, exfalso, linarith, exfalso, linarith, refl, exfalso, linarith, }, exact lemma47 f, end⟩ lemma lemma48 (f : P') : ∃ (C : ℤ), ∀ n (hn : 0 ≤ n), abs (f.1.1 ((𝔼.inv.g f).1 n) - n) < C := begin have H : ∃ (N C : ℤ), ∀ n (hn : N ≤ n), abs (f.1.1 ((𝔼.inv.g f).1 n) - n) < C, rcases lemma34 f with ⟨N, hN, h⟩, have hN' : 0 ≤ N, linarith, set g := 𝔼.inv.g f with hg, choose C hC using f.1.2, use [N, C + abs (f.1.1 1)], intros n hn, specialize h n hn, have h0n : 0 ≤ n, linarith, have key := lemma43 f n h0n h, have : g.val = 𝔼.inv.g1 f, rw hg, refl, rw ← this at *, specialize hC 1 (g.1 n - 1), simp only [add_sub_cancel'_right, df_eq] at hC, cases key, rw abs_lt at *, cases hC, split, linarith [abs_nonneg (f.1.1 1)], linarith [le_abs_self (f.1.1 1)], rcases H with ⟨N, C, H⟩, have hfin : set.finite ((λ n, abs (f.1.1 ((𝔼.inv.g f).1 n) - n)) '' set.Ico 0 N), apply set.finite.image, split, apply fintype.of_finset (finset.Ico_ℤ 0 N), simp, have hbdd : bdd_above ((λ n, abs (f.1.1 ((𝔼.inv.g f).1 n) - n)) '' set.Ico 0 N), apply set.finite.bdd_above hfin, simp at hbdd, cases hbdd with C1 hC1, simp only [upper_bounds_eq, and_imp, set.mem_Ico, set.mem_image, set.mem_set_of_eq, exists_imp_distrib] at hC1, use max C C1 + 1, intros n hn, have hnN := lt_or_le n N, cases hnN, specialize @hC1 (abs (f.val.val ((𝔼.inv.g f).val n) - n)) n hn hnN rfl, linarith [le_max_right C C1], specialize H n hnN, linarith [le_max_left C C1], end lemma lemma49 : ∀ (a : 𝔼) (ha : a ∈ P), ∃ b, a * b = 1 := begin rintro a ⟨f, hf, h⟩, have hfP' : f ∈ P', exact h, use ↑(𝔼.inv.g ⟨f, hfP'⟩), rw ← hf, simp only [𝔼.mul_eq', 𝔼.one_eq'], rw [lemma17, quotient_add_group.eq], apply lemma4, cases lemma48 ⟨f, hfP'⟩ with C hC, use C, intros p hp, specialize hC p hp, rw ← abs_neg at hC, simp at hC, rw [add_comm], simp, exact hC, end lemma lemma50 : ∀ a b, a ∈ P → b ∈ P → a * b ∈ P := begin intros a b ha hb, rcases ha with ⟨u, hu, ha⟩, rcases hb with ⟨v, hv, hb⟩, rw [← hu, ← hv], simp only [𝔼.mul_eq'], rw lemma17, use [⟨u.val ∘ v.val, lemma14 u v⟩, rfl], rw lemma8 at *, intros C hC, cases ha C hC with M hM, have : 0 < max M 1, rw lt_max_iff, right, norm_num, cases hb (max M 1) this with N hN, use N, intros p hNp, specialize hN p hNp, have hvval : M < v.val p, rw max_lt_iff at hN, exact hN.1, specialize hM (v.val p) hvval, exact hM, end lemma lemma51 : (1 : 𝔼) ∈ P := begin use [(⟨(id : ℤ → ℤ), lemma16⟩ : S), rfl], intros n hn, use n + 1, split, linarith, norm_num, end noncomputable def 𝔼.inv : 𝔼 → 𝔼 := λ a, if ha1 : a ∈ P then begin choose b hb using lemma49 a ha1, exact b, end else if ha2 : a = 0 then (0 : 𝔼) else begin choose b hb using lemma49 (-a) (lemma30 ha1 ha2), exact -b, end noncomputable instance field_𝔼 : field 𝔼 := { inv := 𝔼.inv, exists_pair_ne := begin use [0, 1], have h0P := lemma10, have h1P := lemma51, intro h01, rw h01 at h0P, exact h0P h1P, end, mul_inv_cancel := begin intros a ha, show a * (𝔼.inv a) = 1, simp only [𝔼.inv], split_ifs, have := classical.some_spec (lemma49 a h), exact this, have := classical.some_spec (𝔼.inv._proof_2 a h ha), have heq : a * -(classical.some (𝔼.inv._proof_2 a h ha)) = -a * (classical.some (𝔼.inv._proof_2 a h ha)), ring, rw heq, exact this, end, inv_zero := begin show (𝔼.inv 0) = 0, simp only [𝔼.inv], split_ifs, exfalso, exact lemma10 h, refl, end, ..comm_ring_𝔼 } lemma 𝔼.field.zero_eq : field.zero = (0 : 𝔼) := rfl lemma 𝔼.field.one_eq : field.one = (1 : 𝔼) := rfl noncomputable instance linear_ordered_field_𝔼 : linear_ordered_field 𝔼 := { le := λ a b, -a + b ∈ P ∪ {0}, lt := λ a b, -a + b ∈ P, le_refl := begin intro a, simp, end, le_trans := begin intros a b c hab hbc, simp at *, cases hab, { cases hbc, { left, rw [neg_add_eq_zero.mp hab, neg_add_eq_zero.mp hbc], simp, }, { rw neg_add_eq_zero.mp hab, cc, }, }, { cases hbc, { rw ← (neg_add_eq_zero.mp hbc), cc, }, { right, have h : (-a + b) + (-b + c) ∈ P := lemma9 (-a + b) (-b + c) hab hbc, have heq : -a + c = (-a + b) + (-b + c), abel, rw heq, exact h, }, }, end, lt_iff_le_not_le := begin intros a b, split, { intro hab, simp at hab, simp, split, cc, intro hfalse, cases hfalse, { rw neg_add_eq_zero.mp hfalse at hab, simp at hab, exact lemma10 hab, }, { have heq : -b + a = -(-a + b), abel, rw heq at hfalse, exact lemma11 hab hfalse, }, }, { rintro ⟨hab, hba⟩, cases hab, { exact hab, }, { simp at hab, simp at hba, have : ¬(-b + a = 0), finish, exfalso, apply this, rw neg_add_eq_zero at *, exact eq.symm hab, }, }, end, le_antisymm := begin intros a b hab hba, cases hab, { cases hba, { exfalso, have : -b + a = -(-a + b), abel, rw this at hba, exact lemma11 hab hba, }, { simp at hba, exact eq.symm (neg_add_eq_zero.mp hba), }, }, { simp at hab, exact neg_add_eq_zero.mp hab, }, end, add_le_add_left := begin intros a b hab c, show -(c + a) + (c + b) ∈ P ∪ {0}, have : -(c + a) + (c + b) = -a + b, abel, rw this, exact hab, end, mul_pos := begin intros a b ha hb, change -(0 : 𝔼) + a ∈ P at ha, change -(0 : 𝔼) + b ∈ P at hb, change -(0 : 𝔼) + (a * b) ∈ P, simp at *, exact lemma50 a b ha hb, end, le_total := begin intros a b, change -a + b ∈ P ∪ {0} ∨ -b + a ∈ P ∪ {0}, simp, cases lemma29 (-a + b), left, right, exact h, cases h, left, left, exact h, simp at h, right, right, exact h, end, zero_lt_one := begin simp only [𝔼.field.zero_eq, 𝔼.field.one_eq], change -(0 : 𝔼) + 1 ∈ P, ring, exact lemma51, end, ..field_𝔼 } lemma lemma52 : ∀ n, (λ p, n * p) ∈ S := begin intro n, use 1, intros p q, simp, ring, norm_num, end lemma lemma53 : ∀ n : ℕ, (n : 𝔼) = @coe ↥S 𝔼 eudoxus_reals_group.has_lift_t ⟨λ p, n * p, lemma52 n⟩ := begin intro n, induction n, simp, refl, simp, rw n_ih, ring, have : @coe ↥S 𝔼 eudoxus_reals_group.has_lift_t ⟨has_mul.mul ↑n_n, lemma52 n_n⟩ + @coe ↥S 𝔼 eudoxus_reals_group.has_lift_t ⟨id, lemma16⟩ = @coe ↥S 𝔼 eudoxus_reals_group.has_lift_t (⟨has_mul.mul ↑n_n, lemma52 n_n⟩ + ⟨id, lemma16⟩), refl, rw this, simp, have heq : ∀ (z : ℤ), ↑n_n * z + z = (↑n_n + 1) * z, intro z, ring, simp_rw heq, end lemma lemma54 (f g : S) (hfg : (↑f : 𝔼) = ↑g) : (∀ (C : ℤ), 0 < C → (∃ (N : ℤ), ∀ (p : ℤ), N < p → C < f.val p)) → (∀ (C : ℤ), 0 < C → (∃ (N : ℤ), ∀ (p : ℤ), N < p → C < g.val p)) := begin intro hf, intros C hC, have hfg' : (0 : 𝔼) = -↑(f : S) + ↑(g : S), rw hfg, simp, change ↑(0 : S) = ↑(-f + g) at hfg', rw quotient_add_group.eq at hfg', simp at hfg', cases hfg' with B hB, change ∀ (p : ℤ), abs (-f.val p + g.val p) < B at hB, have h0BC : 0 < B + C, linarith [hB 0, abs_nonneg (-f.val 0 + g.val 0)], cases hf (B + C) h0BC with N hN, use N, intros p hNp, specialize hN p hNp, specialize hB p, rw abs_lt at hB, cases hB, linarith, end lemma lemma55 {f g : S} (B : ℤ) : (0 : 𝔼) < ↑g → (∀ p, abs (f.1 p) < abs (g.1 p) + B) → (↑f : 𝔼) ≤ ↑g := begin rintro ⟨v, hvg, hv⟩ habs, simp at hvg, by_contradiction hfalse, simp at hfalse, change ↑((-g) + f) ∈ P at hfalse, rcases hfalse with ⟨gf, hgf, hfalse⟩, rw lemma8 at *, have h1 := lemma54 gf (-g + f) hgf hfalse, have h2 := lemma54 v g hvg hv, have : (0 : ℤ) < max B 1, rw lt_max_iff, norm_num, cases h1 (max B 1) this with N1 h1, cases h2 (max B 1) this with N2 h2, have hle1 : N1 < max N1 N2 + 1, linarith [le_max_left N1 N2], have hle2 : N2 < max N1 N2 + 1, linarith [le_max_right N1 N2], specialize h1 (max N1 N2 + 1) hle1, specialize h2 (max N1 N2 + 1) hle2, specialize habs (max N1 N2 + 1), change max B 1 < -g.val (max N1 N2 + 1) + f.val (max N1 N2 + 1) at h1, have heq : abs (g.val (max N1 N2 + 1)) = g.val (max N1 N2 + 1), rw abs_of_pos, linarith, rw [heq, abs_lt] at habs, cases habs, linarith [le_max_left B 1], end instance archimedean_𝔼 : archimedean 𝔼 := begin rw archimedean_iff_nat_le, intro a, cases lemma12 a with u hu, rcases lemma23 u with ⟨A, B, hA, hAB⟩, have := int.eq_coe_of_zero_le (le_of_lt hA), cases this with n hAn, have hn : 0 < n, rw hAn at hA, exact int.coe_nat_pos.mp hA, use n, rw [← hu, lemma53], apply lemma55 B, rw ← lemma53, exact nat.cast_pos.mpr hn, rw ← hAn, intro p, specialize hAB p, have : A * abs p = abs (A * p), have heq : abs A * abs p = abs (A * p) := (abs_mul A p).symm, rw abs_of_pos hA at heq, exact heq, rw this at hAB, exact hAB, end noncomputable instance : floor_ring 𝔼 := archimedean.floor_ring 𝔼 noncomputable instance decidable_linear_order_𝔼 : decidable_linear_order 𝔼 := classical.DLO 𝔼 noncomputable instance lattice_𝔼 : lattice 𝔼 := by apply_instance lemma lemma56 : ∀ {x y : 𝔼} (hxy : x < y), ∃ (M N : ℤ) (hN : 0 < N), (N : 𝔼) * x < (M : 𝔼) ∧ (M : 𝔼) < (N : 𝔼) * y := begin intros x y hxy, rcases exists_rat_btwn hxy with ⟨q, hq1, hq2⟩, rcases q with ⟨M, N, h1, h2⟩, use [M, N, int.coe_nat_pos.mpr h1], split, rw mul_comm, rw ← lt_div_iff, exact hq1, exact int.cast_pos.mpr (int.coe_nat_pos.mpr h1), rw mul_comm, rw ← div_lt_iff, exact hq2, exact int.cast_pos.mpr (int.coe_nat_pos.mpr h1), end lemma lemma57 : ∃ C, ∀ (a b : 𝔼), abs (floor (a + b) - floor a - floor b) < C := begin use 2, intros a b, have ha1 := floor_le a, have ha2 := lt_floor_add_one a, have hb1 := floor_le b, have hb2 := lt_floor_add_one b, have : (2 : 𝔼) = (↑2 : 𝔼), simp, have h1 : ↑⌊a + b⌋ - ↑⌊a⌋ - ↑⌊b⌋ < (↑2 : 𝔼), linarith [floor_le (a + b)], have h2 : -(↑2 : 𝔼) < ↑⌊a + b⌋ - ↑⌊a⌋ - ↑⌊b⌋, linarith [lt_floor_add_one (a + b)], have h3 : ↑⌊a + b⌋ - ↑⌊a⌋ - ↑⌊b⌋ = (↑(⌊a + b⌋ - ⌊a⌋ - ⌊b⌋) : 𝔼), simp, rw h3 at *, have h1' : ⌊a + b⌋ - ⌊a⌋ - ⌊b⌋ < 2, rw ← @int.cast_lt 𝔼, exact h1, have h2' : -2 < ⌊a + b⌋ - ⌊a⌋ - ⌊b⌋, rw ← @int.cast_lt 𝔼, exact h2, rw abs_lt, split, linarith, linarith, end @[simp] lemma upper_bounds_eq' {S : set 𝔼} : upper_bounds S = {x : 𝔼 | ∀ ⦃a : 𝔼⦄, a ∈ S → a ≤ x} := rfl lemma lemma58 (K : set ℤ) (hK1 : set.finite K) (hK2 : K.nonempty) : ∃ n (hn : n ∈ K), ∀ t ∈ K, t ≤ n := begin cases set.finite.exists_finset hK1 with K' hK'K, have hK' : K'.nonempty, cases hK2 with x hx, use x, rw hK'K, exact hx, use finset.max' K' hK', simp_rw ← hK'K, use finset.max'_mem K' hK', intros t ht, use finset.le_max' K' t ht, end lemma lemma59 (K : set ℤ) (hK1 : K.nonempty) (hK2 : bdd_above K) : ∃ n (hn : n ∈ K), ∀ t ∈ K, t ≤ n := begin cases hK2 with M hM, simp at hM, cases hK1 with m hm, set K' := K ∩ set.Icc m M with hK'K, have hK'1 : set.finite K', have : (set.Icc m M).finite := ⟨fintype.of_finset (finset.Ico_ℤ m (M + 1)) (by {simp [int.lt_add_one_iff]})⟩, rw hK'K, apply set.finite.subset this, exact set.inter_subset_right K (set.Icc m M), have hK'2 : K'.nonempty, rw hK'K, use [m, hm], simp, apply hM, exact hm, rcases lemma58 K' hK'1 hK'2 with ⟨n, hn, h⟩, rw hK'K at *, use [n, hn.1], intros t htK, have htm := lt_or_le t m, cases htm, have : m ≤ n, rcases hn with ⟨hn1, hn2, hn3⟩, exact hn2, linarith, apply h, use [htK, htm, hM htK], end lemma lemma60 (p : ℤ) (hp : 0 ≤ p) (T : set 𝔼) (hT1 : T.nonempty) (hT2 : bdd_above T) : ∃ n (hn : n ∈ {m | ∃ x ∈ T, m = floor ((p : 𝔼) * x)}), ∀ t ∈ {m | ∃ x ∈ T, m = floor ((p : 𝔼) * x)}, t ≤ n := begin have h1 : {m | ∃ x ∈ T, m = floor ((p : 𝔼) * x)}.nonempty, cases hT1 with x hx, use [⌊↑p * x⌋, x, hx], have h2 : bdd_above {m | ∃ x ∈ T, m = floor ((p : 𝔼) * x)}, cases hT2 with M hM, use ⌊↑p * M⌋ + 1, simp only [set.mem_set_of_eq, exists_imp_distrib, upper_bounds_eq], intros a x hxT hapx, rw hapx, have hpxpM : ↑p * x ≤ ↑p * M, apply mul_le_mul_of_nonneg_left, simp at hM, exact hM hxT, exact int.cast_nonneg.mpr hp, have : ↑⌊↑p * x⌋ ≤ ↑⌊↑p * M⌋ + (1 : 𝔼), linarith [floor_le (↑p * x), lt_floor_add_one (↑p * M)], have heq : ↑⌊↑p * M⌋ + 1 = (↑(⌊↑p * M⌋ + 1) : 𝔼), simp, rw heq at this, rw ← @int.cast_le 𝔼, exact this, exact lemma59 {m | ∃ x ∈ T, m = floor ((p : 𝔼) * x)} h1 h2, end noncomputable def T_sup_f1 (T : set 𝔼) (hT1 : T.nonempty) (hT2 : bdd_above T) : ℤ → ℤ := λ p, if hp : 0 ≤ p then begin choose n hn using lemma60 p hp T hT1 hT2, exact n, end else begin simp at hp, have hp' : 0 ≤ -p, linarith, choose n hn using lemma60 (-p) hp' T hT1 hT2, exact -n, end lemma lemma61 (a p : ℤ) (T : set 𝔼) (hT1 : T.nonempty) (hT2 : bdd_above T) (hp : 0 ≤ p) (m1 m2 : 𝔼) (hm1 : m1 ∈ T) (hm2 : m2 ∈ T) : a = T_sup_f1 T hT1 hT2 p → a = ⌊↑p * m1⌋ → a = ⌊↑p * max m1 m2⌋ := begin intros ha1 ha2, simp only [T_sup_f1] at ha1, split_ifs at ha1, rcases classical.some_spec (lemma60 p hp T hT1 hT2) with ⟨⟨c, hc, hfc1⟩, hfc2⟩, set fp := classical.some (lemma60 p hp T hT1 hT2) with hfpeq, rw ← hfpeq at *, have h1 : ⌊↑p * m1⌋ ≤ ⌊↑p * max m1 m2⌋, have : (↑p * m1 : 𝔼) ≤ ↑p * max m1 m2, apply mul_le_mul_of_nonneg_left (le_max_left m1 m2), exact int.cast_nonneg.mpr hp, exact floor_mono this, have h2 : ⌊↑p * max m1 m2⌋ ≤ ⌊↑p * m1⌋, specialize hfc2 ⌊↑p * max m1 m2⌋, rw ha2 at ha1, rw ← ha1 at hfc2, apply hfc2, use max m1 m2, split, cases max_choice m1 m2, rw h, exact hm1, rw h, exact hm2, refl, linarith, end noncomputable def T_sup_f (T : set 𝔼) (hT1 : T.nonempty) (hT2 : bdd_above T) : S := ⟨λ p, T_sup_f1 T hT1 hT2 p, begin apply lemma26, { intros p hp, simp only [T_sup_f1], split_ifs with hp1 hp2, exfalso, linarith, exfalso, linarith, refl, exfalso, linarith, }, cases lemma57 with C hC, use C, intros m n hm hn, have hmn : 0 ≤ m + n, linarith, rw abs_lt, simp, simp only [T_sup_f1], split_ifs, set fm := classical.some (lemma60 m hm T hT1 hT2) with hfmeq, set fn := classical.some (lemma60 n hn T hT1 hT2) with hfneq, set fmn := classical.some (lemma60 (m + n) hmn T hT1 hT2) with hfmneq, rcases classical.some_spec (lemma60 m hm T hT1 hT2) with ⟨⟨xm, hxm, hfm1⟩, hfm2⟩, rcases classical.some_spec (lemma60 n hn T hT1 hT2) with ⟨⟨xn, hxn, hfn1⟩, hfn2⟩, rcases classical.some_spec (lemma60 (m + n) hmn T hT1 hT2) with ⟨⟨xmn, hxmn, hfmn1⟩, hfmn2⟩, rw ← hfmeq at *, rw ← hfneq at *, rw ← hfmneq at *, set x1 := max xm xn with hx1, have hx1' : x1 = max xn xm, rw hx1, exact max_comm xm xn, have hx1'' : x1 ∈ T, rw hx1, cases max_choice xm xn, rw h, exact hxm, rw h, exact hxn, have hx11 := lemma61 fm m T hT1 hT2 hm xm xn hxm hxn, have : fm = T_sup_f1 T hT1 hT2 m, simp only [T_sup_f1], split_ifs, exact hfmeq, specialize hx11 this hfm1, have hx12 := lemma61 fn n T hT1 hT2 hn xn xm hxn hxm, have : fn = T_sup_f1 T hT1 hT2 n, simp only [T_sup_f1], split_ifs, exact hfneq, specialize hx12 this hfn1, rw ← hx1 at hx11, rw ← hx1' at hx12, set x := max x1 xmn with hx, have hx' : x = max xmn x1, rw hx, exact max_comm x1 xmn, have hx01 := lemma61 fm m T hT1 hT2 hm x1 xmn hx1'' hxmn, have : fm = T_sup_f1 T hT1 hT2 m, simp only [T_sup_f1], split_ifs, exact hfmeq, specialize hx01 this hx11, have hx02 := lemma61 fn n T hT1 hT2 hn x1 xmn hx1'' hxmn, have : fn = T_sup_f1 T hT1 hT2 n, simp only [T_sup_f1], split_ifs, exact hfneq, specialize hx02 this hx12, have hx03 := lemma61 fmn (m + n) T hT1 hT2 hmn xmn x1 hxmn hx1'', have : fmn = T_sup_f1 T hT1 hT2 (m + n), simp only [T_sup_f1], split_ifs, exact hfmneq, specialize hx03 this hfmn1, rw ← hx at hx01, rw ← hx at hx02, rw ← hx' at hx03, have hmxnx : ↑(m + n) * x = ↑m * x + ↑n * x, have heq : (↑(m + n) : 𝔼) = ↑m + ↑n, simp, rw heq, ring, rw hmxnx at hx03, specialize hC (↑m * x) (↑n * x), rw abs_lt at hC, split, linarith, linarith, end⟩ lemma lemma62 : ∀ (x y : 𝔼) (hxy : x < y), ∃ (M N : ℤ) (hN : 0 < N), x < (M : 𝔼) / (N : 𝔼) ∧ (M : 𝔼) / (N : 𝔼) < y := begin intros x y hxy, rcases exists_rat_btwn hxy with ⟨q, hq1, hq2⟩, rcases q with ⟨M, N, h1, h2⟩, use [M, N, int.coe_nat_pos.mpr h1, hq1, hq2], end noncomputable def T_sup (T : set 𝔼) : 𝔼 := if hT1 : T.nonempty ∧ bdd_above T then if hT2 : ∃ x ∈ T, ∀ y ∈ T, y ≤ x then begin choose x hx using hT2, exact x, end else (↑(T_sup_f T hT1.1 hT1.2) : 𝔼) else 0 lemma lemma63 (f g : S) : (∀ p (hp : 0 ≤ p), f.1 p ≤ g.1 p) → (↑f : 𝔼) ≤ (↑g : 𝔼) := begin intro h, by_contradiction hfalse, simp at hfalse, change ↑(-g + f) ∈ P at hfalse, rcases hfalse with ⟨gf, hgf, hfalse⟩, have := lemma54 gf (-g + f) hgf, rw lemma8 at hfalse, specialize this hfalse, have h01 : (0 : ℤ) < 1, norm_num, cases this 1 h01 with N hN, have hN01 : N < max (N + 1) 0, linarith [le_max_left (N + 1) 0], have hN02 : 0 ≤ max (N + 1) 0, exact le_max_right (N + 1) 0, specialize hN (max (N + 1) 0) hN01, specialize h (max (N + 1) 0) hN02, simp only [S.add_eq', S.add_eq, S.neg_eq', lt_neg_add_iff_add_lt, S.neg_eq] at hN, linarith, end lemma lemma64 : ∀ n : ℤ, (n : 𝔼) = @coe ↥S 𝔼 eudoxus_reals_group.has_lift_t ⟨λ p, n * p, lemma52 n⟩ := begin intro n, cases le_or_lt n 0, have hn : 0 ≤ -n, linarith, cases int.eq_coe_of_zero_le hn with n' hn', have := lemma53 n', have heq1 : (↑n : 𝔼) = -↑(↑n' : ℤ), rw ← hn', simp, have heq2 : (↑n : 𝔼) = -↑(n' : ℕ), rw heq1, simp, have heq3 : (↑(⟨λ (p : ℤ), n * p, lemma52 n⟩ : S) : 𝔼) = -↑(⟨λ (p : ℤ), ↑n' * p, lemma52 ↑n'⟩ : S), rw ← hn', show ↑(⟨λ (p : ℤ), n * p, lemma52 n⟩ : S) = ↑(-⟨λ (p : ℤ), -n * p, lemma52 (-n)⟩ : S), rw quotient_add_group.eq, use 1, intro p, norm_num, linarith, have hn : 0 ≤ n, linarith, cases int.eq_coe_of_zero_le hn with n' hn', rw hn', exact lemma53 n', end lemma T_le_cSup : ∀ (s : set 𝔼) (a : 𝔼), bdd_above s → a ∈ s → a ≤ T_sup s := begin intros T x hT hxT, simp only [T_sup], split_ifs with hT1 hT3, { cases classical.some_spec hT3, exact h x hxT, }, { have hT3' : ∀ (x : 𝔼) (H : x ∈ T), ∃ (y : 𝔼), y ∈ T ∧ x < y, rw not_exists at hT3, intros x hx, specialize hT3 x, rw not_exists at hT3, specialize hT3 hx, rw not_forall at hT3, cases hT3 with y hy, use y, rw not_imp at hy, cases hy with hy1 hy2, simp at hy2, use [hy1, hy2], rcases hT3' x hxT with ⟨y, hy, hxy⟩, rcases lemma62 x y hxy with ⟨M, N, hN, hMN1, hMN2⟩, have : ∀ p (h0p : 0 ≤ p), p * M ≤ T_sup_f1 T hT1.1 hT1.2 (p * N), intros p hp, have hpN0 : 0 ≤ p * N, apply mul_nonneg hp, linarith, simp only [T_sup_f1], split_ifs, rcases classical.some_spec (lemma60 (p * N) hpN0 T hT1.1 hT1.2) with ⟨⟨xm, hxmT, hsome1⟩, hsome2⟩, rw hsome1 at *, specialize hsome2 ⌊↑(p * N) * y⌋, rw set.mem_set_of_eq at hsome2, have : ∃ (x : 𝔼) (H : x ∈ T), ⌊↑(p * N) * y⌋ = ⌊↑(p * N) * x⌋, use [y, hy, rfl], specialize hsome2 this, have : ⌊(↑(p * N) : 𝔼) * (↑M : 𝔼) / (↑N : 𝔼)⌋ ≤ ⌊(↑(p * N) : 𝔼) * (y : 𝔼)⌋, apply floor_mono, rw [div_eq_mul_inv, mul_assoc], apply mul_le_mul_of_nonneg_left, rw [← div_eq_mul_inv], linarith, exact int.cast_nonneg.mpr hpN0, have heq : (↑(p * N) : 𝔼) * (↑M : 𝔼) / (↑N : 𝔼) = (↑(p * M) : 𝔼), have heq1 : ∀ N : ℤ, (↑(p * N) : 𝔼) = ↑p * ↑N, intro N, simp, rw [heq1 N, heq1 M, mul_comm, div_eq_mul_inv, mul_assoc, mul_assoc, mul_inv_cancel], ring, simp, linarith, rw heq at this, have heq' : ⌊(↑(p * M) : 𝔼)⌋ = p * (M : ℤ), rw floor_eq_iff, split, linarith, linarith, linarith, have H := lemma63 (⟨(λ p, M * p), lemma52 M⟩), set fN := (T_sup_f T hT1.1 hT1.2).1 ∘ (⟨(λ p, N * p), lemma52 N⟩ : S).1 with hfN1, have hfN2 : fN ∈ S, rw hfN1, apply lemma14 (T_sup_f T hT1.1 hT1.2) ⟨(λ p, N * p), lemma52 N⟩, specialize H (⟨fN, hfN2⟩ : S), dsimp at H, dsimp at hfN1, have : (∀ (p : ℤ), 0 ≤ p → M * p ≤ fN p), rw hfN1, intros p h0p, specialize this p h0p, have heq : T_sup_f1 T hT1.1 hT1.2 (p * N) = (↑(T_sup_f T hT1.1 hT1.2) ∘ has_mul.mul N) p, simp, rw mul_comm, simp only [T_sup_f], simp, rw [← heq, mul_comm], exact this, specialize H this, have heq1 : (M : 𝔼) = (⟨has_mul.mul M, lemma52 M⟩ : S) := lemma64 M, have heq2 : ↑(⟨fN, hfN2⟩ : S) = ↑(T_sup_f T hT1.1 hT1.2) * (↑N : 𝔼), simp_rw hfN1, rw [lemma64 N, 𝔼.mul_eq', lemma17], simp, rw [← heq1, heq2, mul_comm] at H, have := (@div_le_iff' 𝔼 (linear_ordered_field_𝔼) (↑M) (↑N) (↑(T_sup_f T hT1.1 hT1.2)) (int.cast_pos.mpr hN)).mpr H, linarith, }, { exfalso, simp at hT1, cases set.eq_empty_or_nonempty T, rw h at hxT, exact hxT, exact hT1 h hT, }, end lemma T_cSup_le : ∀ (s : set 𝔼) (a : 𝔼), s.nonempty → a ∈ upper_bounds s → T_sup s ≤ a := begin intros T y hT1 hyT, have hT2 : bdd_above T, use [y, hyT], have hT : T.nonempty ∧ bdd_above T := ⟨hT1, hT2⟩, simp only [T_sup], split_ifs, { simp at hyT, cases classical.some_spec h with hs1 hs2, exact hyT hs1, }, { by_contradiction hfalse, rw not_le at hfalse, rcases lemma56 hfalse with ⟨M, N, hN, hMN1, hMN2⟩, have heq1 := lemma64 M, have hin := lemma14 (T_sup_f T hT1 hT2) ⟨has_mul.mul N, lemma52 N⟩, have heq2 : (↑N : 𝔼) * ↑(T_sup_f T hT1 hT2) = ↑(⟨(↑(T_sup_f T hT1 hT2) ∘ has_mul.mul N), hin⟩ : S), rw [mul_comm, 𝔼.mul_eq', lemma64 N, lemma17], refl, rw [heq1, heq2] at hMN2, simp only [T_sup_f, subtype.coe_mk, subtype.val_eq_coe] at hMN2, rcases hMN2 with ⟨sum, hsumeq, H⟩, rw lemma8 at H, change ↑sum = ↑(-(⟨has_mul.mul M, lemma52 M⟩ : S) + ⟨T_sup_f1 T hT1 hT2 ∘ has_mul.mul N, hin⟩) at hsumeq, have := lemma54 sum (-(⟨has_mul.mul M, lemma52 M⟩ : S) + ⟨T_sup_f1 T hT1 hT2 ∘ has_mul.mul N, hin⟩) hsumeq H, rw ← lemma8 at this, have h01 : (0 : ℤ) < 1, norm_num, rcases this 1 h01 with ⟨p, h0p, hfp⟩, simp at hfp, have hcomm : N * p = p * N := mul_comm N p, rw [mul_comm, hcomm] at hfp, have hpN : 0 ≤ p * N := le_of_lt (mul_pos h0p hN), have hx : ∃ x ∈ T, T_sup_f1 T hT1 hT2 (p * N) = ⌊↑(p * N) * x⌋, simp only [T_sup_f1], split_ifs, cases classical.some_spec (lemma60 (p * N) hpN T hT1 hT2) with hsome1 hsome2, exact hsome1, rcases hx with ⟨x, hxT, hx⟩, specialize hyT hxT, have hle1 : ↑(p * N) * x ≤ ↑(p * N) * y := mul_le_mul_of_nonneg_left hyT (int.cast_nonneg.mpr hpN), have heq3 : ↑(p * N) * y = ↑p * (↑N * y), rw ← mul_assoc, simp, have hle2 : ↑p * (↑N * y) < ↑p * ↑M, rw mul_lt_mul_left, exact hMN1, exact int.cast_pos.mpr h0p, have hle3 : ↑(p * N) * x < ↑p * ↑M, linarith, rw hx at hfp, have hle4 : ⌊(↑(p * N) : 𝔼) * x⌋ ≤ ⌊(↑p : 𝔼) * (↑M : 𝔼)⌋ := floor_mono (le_of_lt hle3), have heq4 : ⌊(↑p : 𝔼) * (↑M : 𝔼)⌋ = p * M, rw floor_eq_iff, split, simp, have : (↑(p * M) : 𝔼) = ↑p * ↑M, simp, linarith, linarith, }, end @[simp] lemma lower_bounds_eq' {S : set 𝔼} : lower_bounds S = {x : 𝔼 | ∀ ⦃a : 𝔼⦄, a ∈ S → x ≤ a} := rfl lemma T_cInf_le : ∀ (s : set 𝔼) (a : 𝔼), bdd_below s → a ∈ s → -T_sup {x : 𝔼 | -x ∈ s} ≤ a := begin intros T x hT hxT, cases hT with y hy, simp at hy, have h1 : bdd_above {x : 𝔼 | -x ∈ T}, use -y, intros a ha, simp at ha, specialize hy ha, linarith, have := T_le_cSup {x : 𝔼 | -x ∈ T} (-x) h1, have h2 : -x ∈ {x : 𝔼 | -x ∈ T}, simp, exact hxT, specialize this h2, linarith, end lemma T_le_cInf : ∀ (s : set 𝔼) (a : 𝔼), s.nonempty → a ∈ lower_bounds s → a ≤ -T_sup {x : 𝔼 | -x ∈ s} := begin intros T x hT hxT, cases hT with y hy, simp at hxT, have h1 : (-x) ∈ upper_bounds {x : 𝔼 | -x ∈ T}, intros a ha, specialize hxT ha, linarith, have h2 : {x : 𝔼 | -x ∈ T}.nonempty, use -y, simp, exact hy, have := T_cSup_le {x : 𝔼 | -x ∈ T} (-x) h2 h1, linarith, end noncomputable instance : conditionally_complete_linear_order 𝔼 := { Sup := λ T, T_sup T, Inf := λ T, -T_sup {x | -x ∈ T}, le_cSup := T_le_cSup, cSup_le := T_cSup_le, cInf_le := T_cInf_le, le_cInf := T_le_cInf, ..decidable_linear_order_𝔼, ..lattice_𝔼 }
Formal statement is: lemma pred_sets1: "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> f \<in> measurable N M \<Longrightarrow> pred N (\<lambda>x. P (f x))" Informal statement is: If $P$ is a measurable predicate on $M$, and $f$ is a measurable function from $N$ to $M$, then $P \circ f$ is a measurable predicate on $N$.
State Before: α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α ⊢ exponent α = Fintype.card α State After: case intro α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ exponent α = Fintype.card α Tactic: obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α) State Before: case intro α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ exponent α = Fintype.card α State After: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ exponent α ∣ Fintype.card α case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ Fintype.card α ∣ exponent α Tactic: apply Nat.dvd_antisymm State Before: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ Fintype.card α ∣ exponent α State After: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ orderOf g ∣ exponent α Tactic: rw [← orderOf_eq_card_of_forall_mem_zpowers hg] State Before: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ orderOf g ∣ exponent α State After: no goals Tactic: exact order_dvd_exponent _ State Before: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ exponent α ∣ Fintype.card α State After: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ ∀ (b : α), b ∈ Finset.univ → orderOf b ∣ Fintype.card α Tactic: rw [← lcm_order_eq_exponent, Finset.lcm_dvd_iff] State Before: case intro.a α : Type u a : α inst✝² : Group α inst✝¹ : IsCyclic α inst✝ : Fintype α g : α hg : ∀ (x : α), x ∈ Subgroup.zpowers g ⊢ ∀ (b : α), b ∈ Finset.univ → orderOf b ∣ Fintype.card α State After: no goals Tactic: exact fun b _ => orderOf_dvd_card_univ
# Qiskit Aer: Pulse simulation of two qubits using a Duffing oscillator model This notebook shows how to use the Qiskit Aer pulse simulator, which simulates experiments specified as pulse `Schedule` objects at the Hamiltonian level. The simulator solves the Schrodinger equation for a specified Hamiltonian model and pulse `Schedule` in the frame of the drift Hamiltonian. In particular, in this tutorial we will: - Construct a model of a two qubit superconducting system. - Calibrate $\pi$ pulses on each qubit in the simulated system. - Observe cross-resonance oscillations when driving qubit 1 with target qubit 0. The Introduction outlines the concepts and flow of this notebook. ## 1. Introduction <a name='introduction'></a> The main sections proceed as follows. ### Section 3: Duffing oscillator model To simulate a physical system, it is necessary to specify a model. In this notebook, we will model superconducting qubits as a collection of *Duffing oscillators*. The model is specified in terms of the following parameters: - Each Duffing oscillator is specified by a frequency $\nu$, anharmonicity $\alpha$, and drive strength $r$, which result in the Hamiltonian terms: \begin{equation} 2\pi\nu a^\dagger a + \pi \alpha a^\dagger a(a^\dagger a - 1) + 2 \pi r (a + a^\dagger) \times D(t), \end{equation} where $D(t)$ is the signal on the drive channel for the qubit, and $a^\dagger$ and $a$ are, respectively, the creation and annihilation operators for the qubit. Note that the drive strength $r$ sets the scaling of the control term, with $D(t)$ assumed to be a complex and unitless number satisfying $|D(t)| \leq 1$. - A coupling between a pair of oscillators $(l,k)$ is specified by the coupling strength $J$, resulting in an exchange coupling term: \begin{equation} 2 \pi J (a_l a_k^\dagger + a_l^\dagger a_k), \end{equation} where the subscript denotes which qubit the operators act on. - Additionally, for numerical simulation, it is necessary to specify a cutoff dimension; the Duffing oscillator model is *infinite dimensional*, and computer simulation requires restriction of the operators to a finite dimensional subspace. **In the code:** We will define a model of the above form for two coupled qubits using the helper function `duffing_system_model`. ### Section 4: $\pi$-pulse calibration using Ignis Once the model is defined, we will calibrate $\pi$-pulses on each qubit. A $\pi$-pulse is defined as a pulse on the drive channel of a qubit that "flips" the qubit; i.e. that takes the ground state to the first excited state, and the first excited state to the ground state. We will experimentally find a $\pi$-pulse for each qubit using the following procedure: - A fixed pulse shape is set - in this case it will be a Gaussian pulse. - A sequence of experiments is run, each consisting of a Gaussian pulse on the qubit, followed by a measurement, with each experiment in the sequence having a subsequently larger amplitude for the Gaussian pulse. - The measurement data is fit, and the pulse amplitude that completely flips the qubit is found (i.e. the $\pi$-pulse amplitude). **In the code:** Using Ignis we will construct `Schedule` objects for the above experiments, then fit the data to find the $\pi$-pulse amplitudes. ### Section 5: Cross-resonance oscillations Once the $\pi$-pulses are calibrated, we will simulate the effects of cross-resonance driving on qubit $1$ with target qubit $0$. This means that we will drive qubit $1$ at the frequency of qubit $0$, with the goal of observing that the trajectory and oscillations of qubit $0$ *depends* on the state of qubit $1$. This phenomenon provides a basis for creating two-qubit *controlled* gates. Note: This section requires the calibration of the $\pi$-pulse in Section 4. To observe cross-resonance driving, we will use experiments very similar to the $\pi$-pulse calibration case: - Initially, qubit $1$ is either left in the ground state, or is driven to its first excited state using the $\pi$-pulse found in Section 4. - A sequence of experiments is run, each consisting of a Gaussian pulse on qubit $1$ driven at the frequency of qubit $0$, followed by a measurement of both qubits, with each experiment of the sequence having a subsequently larger amplitude for the Gaussian pulse. **In the code:** Functions for defining the experiments and visualizing the data are constructed, including a visualization of the trajectory of the target qubit on the Bloch sphere. ## 2. Imports <a name='imports'></a> This notebook makes use of the following imports. ```python import numpy as np from scipy.optimize import curve_fit, root # visualization tools import matplotlib.pyplot as plt from qiskit.visualization.bloch import Bloch ``` Import qiskit libraries for working with `pulse` and calibration: ```python import qiskit.pulse as pulse from qiskit.pulse.commands.parametric_pulses import Gaussian, GaussianSquare from qiskit.compiler import assemble from qiskit.ignis.characterization.calibrations import rabi_schedules, RabiFitter ``` Imports for qiskit pulse simulator: ```python # The pulse simulator from qiskit.providers.aer import PulseSimulator # function for constructing duffing models from qiskit.providers.aer.pulse import duffing_system_model ``` ## 3. Duffing oscillator system model <a name='duffing'></a> An object representing a model for a collection of Duffing oscillators can be constructed using the `duffing_system_model` function. Here we construct a $2$ Duffing oscillator model with cutoff dimension $3$. ```python # cutoff dimension dim_oscillators = 3 # frequencies for transmon drift terms, harmonic term and anharmonic term # Number of oscillators in the model is determined from len(oscillator_freqs) oscillator_freqs = [5.0e9, 5.2e9] anharm_freqs = [-0.33e9, -0.33e9] # drive strengths drive_strengths = [0.02e9, 0.02e9] # specify coupling as a dictionary (qubits 0 and 1 are coupled with a coefficient 0.002e9) coupling_dict = {(0,1): 0.002e9} # sample duration for pulse instructions dt = 1e-9 # create the model two_qubit_model = duffing_system_model(dim_oscillators=dim_oscillators, oscillator_freqs=oscillator_freqs, anharm_freqs=anharm_freqs, drive_strengths=drive_strengths, coupling_dict=coupling_dict, dt=dt) ``` The function `duffing_system_model` returns a `PulseSystemModel` object, which is a general object for storing model information required for simulation with the `PulseSimulator`. ## 4 Calibrating $\pi$ pulses on each qubit using Ignis <a name='rabi'></a> As described in the introduction, we now calibrate $\pi$ pulses on each qubit in `two_qubit_model`. The experiments in this calibration procedure are known as *Rabi experiments*, and the data we will observe are known as *Rabi oscillations*. ### 4.1 Constructing the schedules We construct the schedules using the `rabi_schedules` function in Ignis. To do this, we need to supply an `InstructionScheduleMap` containing a measurement schedule. ```python # list of qubits to be used throughout the notebook qubits = [0, 1] # Construct a measurement schedule and add it to an InstructionScheduleMap meas_amp = 0.025 meas_samples = 1200 meas_sigma = 4 meas_width = 1150 meas_pulse = GaussianSquare(duration=meas_samples, amp=meas_amp, sigma=meas_sigma, width=meas_width) acq_cmd = pulse.Acquire(duration=meas_samples) acq_sched = acq_cmd(pulse.AcquireChannel(0), pulse.MemorySlot(0)) acq_sched += acq_cmd(pulse.AcquireChannel(1), pulse.MemorySlot(1)) measure_sched = meas_pulse(pulse.MeasureChannel(0)) | meas_pulse(pulse.MeasureChannel(1)) | acq_sched inst_map = pulse.InstructionScheduleMap() inst_map.add('measure', qubits, measure_sched) ``` /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:121: DeprecationWarning: Usage of Acquire without specifying a channel is deprecated. For example, Acquire(1200)(AcquireChannel(0)) should be replaced by Acquire(1200, AcquireChannel(0)). "Acquire(1200, AcquireChannel(0)).", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:218: DeprecationWarning: Calling Acquire with a channel is deprecated. Instantiate the acquire with a channel instead. "a channel instead.", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:218: DeprecationWarning: Calling Acquire with a channel is deprecated. Instantiate the acquire with a channel instead. "a channel instead.", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=1200, amp=(0.025+0j), sigma=4, width=1150), MeasureChannel(0))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=1200, amp=(0.025+0j), sigma=4, width=1150), MeasureChannel(1))`. DeprecationWarning) Next, construct the Rabi schedules. ```python # construct Rabi experiments drive_amps = np.linspace(0, 0.9, 41) drive_sigma = 16 drive_duration = 128 drive_channels = [pulse.DriveChannel(qubit) for qubit in qubits] rabi_experiments, rabi_amps = rabi_schedules(amp_list=drive_amps, qubits=qubits, pulse_width=drive_duration, pulse_sigma=drive_sigma, drives=drive_channels, inst_map=inst_map, meas_map=[[0, 1]]) ``` The `Schedule`s in `rabi_schedules` correspond to experiments to generate Rabi oscillations on both qubits in parallel. Each experiment consists of a Gaussian pulse on the qubits of a given magnitude, followed by measurement. For example: ```python rabi_experiments[10].draw() ``` ### 4.2 Simulate the Rabi experiments To simulate the Rabi experiments, assemble the `Schedule` list into a qobj. When assembling, pass the `PulseSimulator` as the backend. Here, we want to use local oscillators with frequencies automatically computed from Duffing model Hamiltonian. ```python # instantiate the pulse simulator backend_sim = PulseSimulator() # compute frequencies from the Hamiltonian qubit_lo_freq = two_qubit_model.hamiltonian.get_qubit_lo_from_drift() rabi_qobj = assemble(rabi_experiments, backend=backend_sim, qubit_lo_freq=qubit_lo_freq, meas_level=1, meas_return='avg', shots=512) ``` Run the simulation using the simulator backend. ```python # run the simulation rabi_result = backend_sim.run(rabi_qobj, two_qubit_model).result() ``` ### 4.3 Fit and plot the data Next, we use `RabiFitter` in Ignis to fit the data, extract the $\pi$-pulse amplitude, and then plot the data. ```python rabifit = RabiFitter(rabi_result, rabi_amps, qubits, fit_p0 = [0.5,0.5,0.6,1.5]) plt.figure(figsize=(15, 10)) q_offset = 0 for qubit in qubits: ax = plt.subplot(2, 2, qubit + 1) rabifit.plot(qubit, ax=ax) print('Pi Amp: %f'%rabifit.pi_amplitude(qubit)) plt.show() ``` Plotted is the averaged IQ data for observing each qubit. Observe that here, each qubit oscillates between the 0 and 1 state. The amplitude at which a given qubit reaches the peak of the oscillation is the desired $\pi$-pulse amplitude. ## 5. Oscillations from cross-resonance drive <a name='cr'></a> Next, we simulate the effects of a cross-resonance drive on qubit $1$ with target qubit $0$, observing that the trajectory and oscillations of qubit $0$ *depends* on the state of qubit $1$. **Note:** This section depends on the $\pi$-pulse calibrations of Section 2. ### 5.1 Cross-resonance `ControlChannel` indices Driving qubit $1$ at the frequency of qubit $0$ requires use of a pulse `ControlChannel`. The model generating function `duffing_system_model`, automatically sets up `ControlChannels` for performing cross-resonance drives between pairs of coupled qubits. The index of the `ControlChannel` for performing a particular cross-resonance drive is retrievable using the class method `control_channel_index` on the returned `PulseSystemModel`. For example, to get the `ControlChannel` index corresponding to a CR drive on qubit 1 with target 0, call the function `control_channel_index` with the tuple `(1,0)`: ```python two_qubit_model.control_channel_index((1,0)) ``` 1 Hence, to perform a cross-resonance drive on qubit $1$ with target qubit $0$, use `ControlChannel(1)`. This will be made use of when constructing `Schedule` objects in this section. ### 5.2 Functions to generate the experiment list, and analyze the output First, we define a function `cr_drive_experiments`, which, given the drive and target indices, and the option to either start with the drive qubit in the ground or excited state, returns a list of experiments for observing the oscillations. ```python # store the pi amplitudes from Section 2 in a list pi_amps = [rabifit.pi_amplitude(0), rabifit.pi_amplitude(1)] def cr_drive_experiments(drive_idx, target_idx, flip_drive_qubit = False, cr_drive_amps=np.linspace(0, 0.9, 41), cr_drive_samples=600, cr_drive_sigma=4, pi_drive_samples=128, pi_drive_sigma=16): """Generate schedules corresponding to CR drive experiments. Args: drive_idx (int): label of driven qubit target_idx (int): label of target qubit flip_drive_qubit (bool): whether or not to start the driven qubit in the ground or excited state cr_drive_amps (array): list of drive amplitudes to use cr_drive_samples (int): number samples for each CR drive signal cr_drive_sigma (float): standard deviation of CR Gaussian pulse pi_drive_samples (int): number samples for pi pulse on drive pi_drive_sigma (float): standard deviation of Gaussian pi pulse on drive Returns: list[Schedule]: A list of Schedule objects for each experiment """ # Construct measurement commands to be used for all schedules meas_amp = 0.025 meas_samples = 1200 meas_sigma = 4 meas_width = 1150 meas_pulse = GaussianSquare(duration=meas_samples, amp=meas_amp, sigma=meas_sigma, width=meas_width) acq_cmd = pulse.Acquire(duration=meas_samples) acq_sched = acq_cmd(pulse.AcquireChannel(0), pulse.MemorySlot(0)) acq_sched += acq_cmd(pulse.AcquireChannel(1), pulse.MemorySlot(1)) # create measurement schedule measure_sched = meas_pulse(pulse.MeasureChannel(0)) | meas_pulse(pulse.MeasureChannel(1)) | acq_sched # Create schedule schedules = [] for ii, cr_drive_amp in enumerate(cr_drive_amps): # pulse for flipping drive qubit if desired pi_pulse = Gaussian(duration=pi_drive_samples, amp=pi_amps[drive_idx], sigma=pi_drive_sigma) # cr drive pulse cr_width = cr_drive_samples - 2*cr_drive_sigma*4 cr_rabi_pulse = GaussianSquare(duration=cr_drive_samples, amp=cr_drive_amp, sigma=cr_drive_sigma, width=cr_width) # add commands to schedule schedule = pulse.Schedule(name='cr_rabi_exp_amp_%s' % cr_drive_amp) # flip drive qubit if desired if flip_drive_qubit: schedule += pi_pulse(pulse.DriveChannel(drive_idx)) # do cr drive # First, get the ControlChannel index for CR drive from drive to target cr_idx = two_qubit_model.control_channel_index((drive_idx, target_idx)) schedule += cr_rabi_pulse(pulse.ControlChannel(cr_idx)) << schedule.duration schedule += measure_sched << schedule.duration schedules.append(schedule) return schedules ``` Next we create two functions for observing the data: - `plot_cr_pop_data` - for plotting the oscillations between the ground state and the first excited state - `plot_bloch_sphere` - for viewing the trajectory of the target qubit on the bloch sphere ```python def plot_cr_pop_data(drive_idx, target_idx, sim_result, cr_drive_amps=np.linspace(0, 0.9, 41)): """Plot the population of each qubit. Args: drive_idx (int): label of driven qubit target_idx (int): label of target qubit sim_result (Result): results of simulation cr_drive_amps (array): list of drive amplitudes to use for axis labels """ amp_data_Q0 = [] amp_data_Q1 = [] for exp_idx in range(len(cr_drive_amps)): exp_mem = sim_result.get_memory(exp_idx) amp_data_Q0.append(np.abs(exp_mem[0])) amp_data_Q1.append(np.abs(exp_mem[1])) plt.plot(cr_drive_amps, amp_data_Q0, label='Q0') plt.plot(cr_drive_amps, amp_data_Q1, label='Q1') plt.legend() plt.xlabel('Pulse amplitude, a.u.', fontsize=20) plt.ylabel('Signal, a.u.', fontsize=20) plt.title('CR (Target Q{0}, driving on Q{1})'.format(target_idx, drive_idx), fontsize=20) plt.grid(True) def bloch_vectors(drive_idx, drive_energy_level, sim_result): """Plot the population of each qubit. Args: drive_idx (int): label of driven qubit drive_energy_level (int): energy level of drive qubit at start of CR drive sim_result (Result): results of simulation Returns: list: list of Bloch vectors corresponding to the final state of the target qubit for each experiment """ # get the dimension used for simulation dim = int(np.sqrt(len(sim_result.get_statevector(0)))) # get the relevant dressed state indices idx0 = 0 idx1 = 0 if drive_idx == 0: if drive_energy_level == 0: idx0, idx1 = 0, dim elif drive_energy_level == 1: idx0, idx1 = 1, dim + 1 if drive_idx == 1: if drive_energy_level == 0: idx0, idx1 = 0, 1 elif drive_energy_level == 1: idx0, idx1 = dim, dim + 1 # construct Pauli operators for correct dressed manifold state0 = np.array([two_qubit_model.hamiltonian._estates[idx0]]) state1 = np.array([two_qubit_model.hamiltonian._estates[idx1]]) outer01 = np.transpose(state0)@state1 outer10 = np.transpose(state1)@state0 outer00 = np.transpose(state0)@state0 outer11 = np.transpose(state1)@state1 X = outer01 + outer10 Y = -1j*outer01 + 1j*outer10 Z = outer00 - outer11 # function for computing a single bloch vector bloch_vec = lambda vec: np.real(np.array([np.conj(vec)@X@vec, np.conj(vec)@Y@vec, np.conj(vec)@Z@vec])) return [bloch_vec(sim_result.get_statevector(idx)) for idx in range(len(sim_result.results))] def plot_bloch_sphere(bloch_vectors): """Given a list of Bloch vectors, plot them on the Bloch sphere Args: bloch_vectors (list): list of bloch vectors """ sphere = Bloch() sphere.add_points(np.transpose(bloch_vectors)) sphere.show() ``` ### 5.3 Drive qubit 1 to observe CR oscillations on qubit 0 #### Qubit 1 in the ground state First, we drive with both qubit 0 and qubit 1 in the ground state. ```python # construct experiments drive_idx = 1 target_idx = 0 flip_drive = False experiments = cr_drive_experiments(drive_idx, target_idx, flip_drive) # compute frequencies from the Hamiltonian qubit_lo_freq = two_qubit_model.hamiltonian.get_qubit_lo_from_drift() # assemble the qobj cr_rabi_qobj = assemble(experiments, backend=backend_sim, qubit_lo_freq=qubit_lo_freq, meas_level=1, meas_return='avg', shots=512) ``` /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:121: DeprecationWarning: Usage of Acquire without specifying a channel is deprecated. For example, Acquire(1200)(AcquireChannel(0)) should be replaced by Acquire(1200, AcquireChannel(0)). "Acquire(1200, AcquireChannel(0)).", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:218: DeprecationWarning: Calling Acquire with a channel is deprecated. Instantiate the acquire with a channel instead. "a channel instead.", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:218: DeprecationWarning: Calling Acquire with a channel is deprecated. Instantiate the acquire with a channel instead. "a channel instead.", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=1200, amp=(0.025+0j), sigma=4, width=1150), MeasureChannel(0))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=1200, amp=(0.025+0j), sigma=4, width=1150), MeasureChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=0j, sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.0225+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.045+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.0675+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.09+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.11249999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.135+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.1575+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.18+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.20249999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.22499999999999998+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.2475+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.27+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.2925+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.315+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.33749999999999997+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.36+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.3825+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.40499999999999997+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.4275+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.44999999999999996+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.4725+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.495+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.5175+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.54+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.5625+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.585+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6074999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.63+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6525+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6749999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6975+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.72+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.7424999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.765+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.7875+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.8099999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.8325+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.855+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.8775+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.9+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) Run the simulation: ```python sim_result = backend_sim.run(cr_rabi_qobj, two_qubit_model).result() plot_cr_pop_data(drive_idx, target_idx, sim_result) ``` Observe that qubit 1 remains in the ground state, while excitations are driven in qubit 0. We may also observe the trajectory of qubit 0 on the Bloch sphere: ```python bloch_vecs = bloch_vectors(drive_idx, int(flip_drive), sim_result) plot_bloch_sphere(bloch_vecs) ``` #### Qubit 1 in the first excited state Next, we again perform a CR drive qubit 1 with qubit 0 as the target, but now we start each experiment by flipping qubit 1 into the first excited state. ```python # construct experiments, now with flip_drive == True drive_idx = 1 target_idx = 0 flip_drive = True experiments = cr_drive_experiments(drive_idx, target_idx, flip_drive) # compute frequencies from the Hamiltonian qubit_lo_freq = two_qubit_model.hamiltonian.get_qubit_lo_from_drift() # assemble the qobj cr_rabi_qobj = assemble(experiments, backend=backend_sim, qubit_lo_freq=qubit_lo_freq, meas_level=1, meas_return='avg', shots=512) ``` /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:121: DeprecationWarning: Usage of Acquire without specifying a channel is deprecated. For example, Acquire(1200)(AcquireChannel(0)) should be replaced by Acquire(1200, AcquireChannel(0)). "Acquire(1200, AcquireChannel(0)).", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:218: DeprecationWarning: Calling Acquire with a channel is deprecated. Instantiate the acquire with a channel instead. "a channel instead.", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/instructions/acquire.py:218: DeprecationWarning: Calling Acquire with a channel is deprecated. Instantiate the acquire with a channel instead. "a channel instead.", DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=1200, amp=(0.025+0j), sigma=4, width=1150), MeasureChannel(0))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=1200, amp=(0.025+0j), sigma=4, width=1150), MeasureChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=0j, sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.0225+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.045+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.0675+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.09+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.11249999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.135+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.1575+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.18+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.20249999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.22499999999999998+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.2475+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.27+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.2925+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.315+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.33749999999999997+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.36+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.3825+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.40499999999999997+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.4275+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.44999999999999996+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.4725+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.495+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.5175+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.54+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.5625+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.585+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6074999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.63+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6525+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6749999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.6975+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.72+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.7424999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.765+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.7875+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.8099999999999999+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.8325+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.855+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.8775+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.31081040780699565+0j), sigma=16), DriveChannel(1))`. DeprecationWarning) /opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `GaussianSquare` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(GaussianSquare(duration=600, amp=(0.9+0j), sigma=4, width=568), ControlChannel(1))`. DeprecationWarning) ```python sim_result = backend_sim.run(cr_rabi_qobj, two_qubit_model).result() plot_cr_pop_data(drive_idx, target_idx, sim_result) ``` Observe that now qubit 1 is in the excited state, while oscillations are again being driven on qubit 0, now at a different rate as before. Again, observe the trajectory of qubit 0 on the Bloch sphere: ```python bloch_vecs = bloch_vectors(drive_idx, int(flip_drive), sim_result) plot_bloch_sphere(bloch_vecs) ``` Here we see that qubit 0 takes a *different* trajectory on the Bloch sphere when qubit 1 is in the excited state. This is what enables controlled operations between two qubits. ```python import qiskit.tools.jupyter %qiskit_version_table %qiskit_copyright ``` <h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.19.6</td></tr><tr><td>Terra</td><td>0.14.2</td></tr><tr><td>Aer</td><td>0.5.2</td></tr><tr><td>Ignis</td><td>0.3.3</td></tr><tr><td>Aqua</td><td>0.7.3</td></tr><tr><td>IBM Q Provider</td><td>0.7.2</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.7 (default, May 6 2020, 04:59:01) [Clang 4.0.1 (tags/RELEASE_401/final)]</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Mon Jul 13 15:35:23 2020 EDT</td></tr></table> <div style='width: 100%; background-color:#d5d9e0;padding-left: 10px; padding-bottom: 10px; padding-right: 10px; padding-top: 5px'><h3>This code is a part of Qiskit</h3><p>&copy; Copyright IBM 2017, 2020.</p><p>This code is licensed under the Apache License, Version 2.0. You may<br>obtain a copy of this license in the LICENSE.txt file in the root directory<br> of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.<p>Any modifications or derivative works of this code must retain this<br>copyright notice, and modified files need to carry a notice indicating<br>that they have been altered from the originals.</p></div> ```python ```
Require Import Coq.Lists.List. Require Import PL.Imp3. Require Import PL.ImpExt4. Local Open Scope Z. (* ################################################################# *) (** * Review *) (** Last time, we have introduced a programming language with parallel composition. *) Inductive com : Type := | CSkip | CAss (X: var) (a : aexp) | CSeq (c1 c2 : com) | CIf (b : bexp) (c1 c2 : com) | CWhile (b : bexp) (c : com) | CPar (c1 c2: com) (* <- new *) . Bind Scope imp_scope with com. Notation "'Skip'" := CSkip : imp_scope. Notation "c1 ;; c2" := (CSeq c1 c2) (at level 80, right associativity) : imp_scope. Notation "'While' b 'Do' c 'EndWhile'" := (CWhile b c) (at level 80, right associativity) : imp_scope. Notation "'If' c1 'Then' c2 'Else' c3 'EndIf'" := (CIf c1 c2 c3) (at level 10, right associativity) : imp_scope. Local Open Scope imp. (** We introduced its small step semantics. *) Module SmallStepSemantics. Inductive cstep : (com * state) -> (com * state) -> Prop := | CS_AssStep : forall st X a a', astep st a a' -> cstep (CAss X a, st) (CAss X a', st) | CS_Ass : forall st1 st2 X n, st2 X = n -> (forall Y, X <> Y -> st1 Y = st2 Y) -> cstep (CAss X (ANum n), st1) (Skip, st2) | CS_SeqStep : forall st c1 c1' st' c2, cstep (c1, st) (c1', st') -> cstep (c1 ;; c2 , st) (c1' ;; c2, st') | CS_Seq : forall st c2, cstep (Skip ;; c2, st) (c2, st) | CS_IfStep : forall st b b' c1 c2, bstep st b b' -> cstep (If b Then c1 Else c2 EndIf, st) (If b' Then c1 Else c2 EndIf, st) | CS_IfTrue : forall st c1 c2, cstep (If BTrue Then c1 Else c2 EndIf, st) (c1, st) | CS_IfFalse : forall st c1 c2, cstep (If BFalse Then c1 Else c2 EndIf, st) (c2, st) | CS_While : forall st b c, cstep (While b Do c EndWhile, st) (If b Then (c;; While b Do c EndWhile) Else Skip EndIf, st) | CS_ParLeft: forall st st' c1 c1' c2, cstep (c1, st) (c1', st') -> cstep (CPar c1 c2, st) (CPar c1' c2, st') | CS_ParRight: forall st st' c1 c2 c2', cstep (c2, st) (c2', st') -> cstep (CPar c1 c2, st) (CPar c1 c2', st') | CS_Par: forall st, cstep (CPar Skip Skip, st) (Skip, st). End SmallStepSemantics. (* ################################################################# *) (** * Denotational Semantics *) (** Obviously, original denotational semantics does not work. If using initial state and ending state pairs as denotations, then - [X ::= 1] - [X ::= 2;; X ::= 1] have the same denotations. However, parallelly executing one of them and - [Y ::= X] may have different results. That means, this ordinary approach is not expressive enough. In the following part of this lecture, we will use trace sets to describe all intermediate states. *) Module DenotationalSemantics_Trace. (** Here, we use a combination of - initial state - intermediate states - ending state to represent an execution trace. But we do not only consider the behavior of one program itself. We only consider potential behavior of other threads, we call that environment's behavior. Specifically, we distinguish thread local actions and envirionment actions. *) Inductive abs_thread := | LOCAL | ENVIR. Definition trace_set := state -> list (abs_thread * state) -> state -> Prop. Inductive environ_trace: trace_set := | environ_trace_nil: forall st, environ_trace st nil st | environ_trace_cons: forall st1 st2 st3 tr, environ_trace st2 tr st3 -> environ_trace st1 ((ENVIR, st2) :: tr) st3. Definition seq_sem (d1 d2: trace_set): trace_set := fun st1 tr st3 => exists tr1 tr2 st2, d1 st1 tr1 st2 /\ d2 st2 tr2 st3 /\ tr = tr1 ++ tr2. Definition union_sem (d d': trace_set): trace_set := fun st1 tr st2 => d st1 tr st2 \/ d' st1 tr st2. Definition omega_union_sem (d: nat -> trace_set): trace_set := fun st1 tr st2 => exists n, d n st1 tr st2. (** The most interesting case is to define parallel compositions' behavior. *) Inductive interleave_trace: list (abs_thread * state) -> list (abs_thread * state) -> list (abs_thread * state) -> Prop := | interleave_nil: interleave_trace nil nil nil | interleave_cons_l: forall tr1 tr2 tr3 st, interleave_trace tr1 tr2 tr3 -> interleave_trace ((LOCAL, st) :: tr1) ((ENVIR, st) :: tr2) ((LOCAL, st) :: tr3) | interleave_cons_r: forall tr1 tr2 tr3 st, interleave_trace tr1 tr2 tr3 -> interleave_trace ((ENVIR, st) :: tr1) ((LOCAL, st) :: tr2) ((LOCAL, st) :: tr3) | interleave_cons_env: forall tr1 tr2 tr3 st, interleave_trace tr1 tr2 tr3 -> interleave_trace ((ENVIR, st) :: tr1) ((ENVIR, st) :: tr2) ((ENVIR, st) :: tr3). Definition par_sem (d1 d2: trace_set): trace_set := fun st1 tr st2 => exists tr1 tr2, d1 st1 tr1 st2 /\ d2 st1 tr2 st2 /\ interleave_trace tr1 tr2 tr. Module DenotationalSemantics_MiddleStepTrace. Definition skip_sem: state -> list (abs_thread * state) -> state -> Prop := environ_trace. Definition local_asgn_sem (X: var) (E: aexp): trace_set := fun st1 tr st2 => st2 X = aeval E st1 /\ (forall Y, X <> Y -> st1 Y = st2 Y) /\ tr = (LOCAL, st2) :: nil. Definition asgn_sem (X: var) (E: aexp): trace_set := seq_sem environ_trace (seq_sem (local_asgn_sem X E) environ_trace). Definition local_test_sem (X: state -> Prop): trace_set := fun st1 tr st2 => st1 = st2 /\ tr = (LOCAL, st1) :: nil /\ X st1. Definition if_sem (b: bexp) (d1 d2: trace_set): trace_set := union_sem (seq_sem environ_trace (seq_sem (local_test_sem (beval b)) d1)) (seq_sem environ_trace (seq_sem (local_test_sem (beval (! b))) d2)). Fixpoint iter_loop_body (b: bexp) (loop_body: trace_set) (n: nat): trace_set := match n with | O => local_test_sem (beval (! b)) | S n' => seq_sem (local_test_sem (beval b)) (seq_sem loop_body (iter_loop_body b loop_body n')) end. Definition loop_sem (b: bexp) (loop_body: trace_set): trace_set := seq_sem environ_trace (seq_sem (omega_union_sem (iter_loop_body b loop_body)) environ_trace). Fixpoint ceval (c: com): trace_set := match c with | CSkip => skip_sem | CAss X E => asgn_sem X E | CSeq c1 c2 => seq_sem (ceval c1) (ceval c2) | CIf b c1 c2 => if_sem b (ceval c1) (ceval c2) | CWhile b c => loop_sem b (ceval c) | CPar c1 c2 => par_sem (ceval c1) (ceval c2) end. End DenotationalSemantics_MiddleStepTrace. Module DenotationalSemantics_SmallStepTrace. (** In the definitions above, we actually assume that an assignment or an testing can happen in one instant. However, you may think it is not true because evaluating an expression needs to read program variables' values. That does not happen instantly. Due to that consideration, we may choose an alternative semantics. *) Local Open Scope Z. Definition ANum_sem (n: Z): Z -> trace_set := fun res st1 tr st2 => environ_trace st1 tr st2 /\ res = n. Definition local_AId_sem (X: var): Z -> trace_set := fun res st1 tr st2 => st1 = st2 /\ tr = (LOCAL, st1) :: nil /\ res = st1 X. Definition AId_sem (X: var): Z -> trace_set := fun res => seq_sem environ_trace (seq_sem (local_AId_sem X res) environ_trace). Definition APlus_sem (d1 d2: Z -> trace_set): Z -> trace_set := fun res st1 tr st2 => exists res1 res2, seq_sem (d1 res1) (d2 res2) st1 tr st2 /\ res = res1 + res2. Definition AMinus_sem (d1 d2: Z -> trace_set): Z -> trace_set := fun res st1 tr st2 => exists res1 res2, seq_sem (d1 res1) (d2 res2) st1 tr st2 /\ res = res1 - res2. Definition AMult_sem (d1 d2: Z -> trace_set): Z -> trace_set := fun res st1 tr st2 => exists res1 res2, seq_sem (d1 res1) (d2 res2) st1 tr st2 /\ res = res1 * res2. Fixpoint aeval (a: aexp): Z -> trace_set := match a with | ANum n => ANum_sem n | AId X => AId_sem X | APlus a1 a2 => APlus_sem (aeval a1) (aeval a2) | AMinus a1 a2 => AMinus_sem (aeval a1) (aeval a2) | AMult a1 a2 => AMult_sem (aeval a1) (aeval a2) end. Definition BEq_sem (d1 d2: Z -> trace_set): bool -> trace_set := fun res st1 tr st2 => exists res1 res2, seq_sem (d1 res1) (d2 res2) st1 tr st2 /\ (res = true <-> res1 = res2). Definition BLe_sem (d1 d2: Z -> trace_set): bool -> trace_set := fun res st1 tr st2 => exists res1 res2, seq_sem (d1 res1) (d2 res2) st1 tr st2 /\ (res = true <-> res1 <= res2). Definition BTrue_sem: bool -> trace_set := fun res st1 tr st2 => environ_trace st1 tr st2 /\ res = true. Definition BFalse_sem: bool -> trace_set := fun res st1 tr st2 => environ_trace st1 tr st2 /\ res = false. Definition BNot_sem (d: bool -> trace_set) : bool -> trace_set := fun res st1 tr st2 => exists res', d res' st1 tr st2 /\ res = negb res'. Definition BAnd_sem (d1 d2: bool -> trace_set) : bool -> trace_set := fun res st1 tr st2 => (d1 false st1 tr st2 /\ res = false) \/ (seq_sem (d1 true) (d2 res) st1 tr st2). Fixpoint beval (b: bexp): bool -> trace_set := match b with | BEq a1 a2 => BEq_sem (aeval a1) (aeval a2) | BLe a1 a2 => BLe_sem (aeval a1) (aeval a2) | BTrue => BTrue_sem | BFalse => BFalse_sem | BNot b0 => BNot_sem (beval b0) | BAnd b1 b2 => BAnd_sem (beval b1) (beval b2) end. Definition skip_sem: state -> list (abs_thread * state) -> state -> Prop := environ_trace. Definition local_asgn_sem (X: var) (n: Z): trace_set := fun st1 tr st2 => st2 X = n /\ (forall Y, X <> Y -> st1 Y = st2 Y) /\ tr = (LOCAL, st2) :: nil. Definition asgn_sem (X: var) (E: aexp): trace_set := fun st1 tr st2 => exists n, seq_sem (aeval E n) (seq_sem (local_asgn_sem X n) environ_trace) st1 tr st2. Definition if_sem (b: bexp) (d1 d2: trace_set): trace_set := union_sem (seq_sem (beval b true) d1) (seq_sem (beval b false) d2). Fixpoint iter_loop_body (b: bexp) (loop_body: trace_set) (n: nat): trace_set := match n with | O => beval b false | S n' => seq_sem (beval b true) (seq_sem loop_body (iter_loop_body b loop_body n')) end. Definition loop_sem (b: bexp) (loop_body: trace_set): trace_set := omega_union_sem (iter_loop_body b loop_body). Fixpoint ceval (c: com): trace_set := match c with | CSkip => skip_sem | CAss X E => asgn_sem X E | CSeq c1 c2 => seq_sem (ceval c1) (ceval c2) | CIf b c1 c2 => if_sem b (ceval c1) (ceval c2) | CWhile b c => loop_sem b (ceval c) | CPar c1 c2 => par_sem (ceval c1) (ceval c2) end. End DenotationalSemantics_SmallStepTrace. End DenotationalSemantics_Trace. (* ################################################################# *) (** * Hoare Logic *) (** For axiomatic semantics, we introduce an extension of Hoare logic here, the logic of _rely-guanrantee_ (依赖保证). Sometimes we write RG for simplicity. In short, rely is a set of actions that the environment may take. Guanrantee is a promise that the local thread make: "I will only take these actions." *) Module HoareLogic. Import Assertion_D. (** Here, - [stable P R] means if a program state statisfies [P] then it will still satisfy [P] if an action in [R] is taken; - [permit P X E G] means if a program state statisfies [P] then [X ::= E] is an action permit by [G]. *) Class Actions : Type := { action_set: Type; action_union: action_set -> action_set -> action_set; stable: Assertion -> action_set -> Prop; permit: Assertion -> var -> aexp -> action_set -> Prop }. Inductive hoare_triple {A: Actions}: Type := | Build_hoare_triple (R: action_set) (G: action_set) (P: Assertion) (c: com) (Q: Assertion). Reserved Notation "R :; G |-- {{ P }} c {{ Q }}" (at level 90, G at next level, P at next level, c at next level, Q at next level). Inductive provable {A: Actions} {T: FirstOrderLogic}: hoare_triple -> Prop := | hoare_seq : forall R G (P1 P2 P3: Assertion) (c1 c2: com), R :; G |-- {{P1}} c1 {{P2}} -> R :; G |-- {{P2}} c2 {{P3}} -> R :; G |-- {{P1}} (CSeq c1 c2) {{P3}} | hoare_skip : forall R G P, stable P R -> R :; G |-- {{P}} CSkip {{P}} | hoare_if : forall R G P Q (b: bexp) c1 c2, R :; G |-- {{ P AND {[b]} }} c1 {{ Q }} -> R :; G |-- {{ P AND NOT {[b]} }} c2 {{ Q }} -> R :; G |-- {{ P }} CIf b c1 c2 {{ Q }} | hoare_while : forall R G P (b: bexp) c, stable (P AND NOT {[b]}) R -> R :; G |-- {{ P AND {[b]} }} c {{P}} -> R :; G |-- {{P}} CWhile b c {{ P AND NOT {[b]} }} | hoare_asgn_bwd : forall R G P (X: var) (E: aexp), stable (P [ X |-> E ]) R -> stable P R -> permit (P [ X |-> E ]) X E G -> R :; G |-- {{ P [ X |-> E] }} CAss X E {{ P }} | hoare_par : forall G1 G2 R P c1 c2 Q, G1 :; action_union G2 R |-- {{ P }} c1 {{ Q }} -> G2 :; action_union G1 R |-- {{ P }} c2 {{ Q }} -> action_union G1 G2 :; R |-- {{ P }} CPar c1 c2 {{ Q }} | hoare_consequence : forall R G (P P' Q Q' : Assertion) c, stable P R -> stable Q R -> P |-- P' -> R :; G |-- {{P'}} c {{Q'}} -> Q' |-- Q -> R :; G |-- {{P}} c {{Q}} where "R :; G |-- {{ P }} c {{ Q }}" := (provable (Build_hoare_triple R G P (c%imp) Q)). End HoareLogic. (* Wed Jun 10 23:33:23 CST 2020 *)
#pragma once #include "string_utils.hpp" #include <vector> #include <boost/lexical_cast/try_lexical_convert.hpp> #include <boost/tokenizer.hpp> namespace msrv { template<typename T> struct ValueParser; template<typename T> bool tryParseValue(StringView str, T* outVal); template<typename T> bool tryParseValueList(StringView str, char sep, std::vector<T>* outVal); template<typename T> bool tryParseValueListStrict(StringView str, char sep, char esc, std::vector<T> *outVal); template<typename T> T parseValue(StringView str); template<typename T> std::vector<T> parseValueList(StringView str, char sep); template<typename T> std::vector<T> parseValueListStrict(StringView str, char sep, char esc); template<typename T> struct ValueParser { static bool tryParse(StringView str, T* outVal) { assert(str.data()); assert(outVal); return boost::conversion::try_lexical_convert(str.data(), str.length(), *outVal); } }; template<> struct ValueParser<std::string> { static bool tryParse(StringView str, std::string* outVal) { *outVal = str.to_string(); return true; } }; template<> struct ValueParser<bool> { static bool tryParse(StringView str, bool* outVal); }; template<typename T> struct ValueParser<std::vector<T>> { static bool tryParse(StringView str, std::vector<T>* outVal) { return tryParseValueListStrict(str, ',', '\\', outVal); } }; template<typename T> bool tryParseValue(StringView str, T* outVal) { assert(str.data()); assert(outVal); return ValueParser<T>::tryParse(str, outVal); } template<typename T> bool tryParseValueList(StringView str, char sep, std::vector<T>* outVal) { assert(str.data()); assert(outVal); auto input = str.to_string(); char sepString[] = { sep, '\0' }; boost::char_separator<char> separator( sepString, "", boost::drop_empty_tokens); boost::tokenizer<boost::char_separator<char>> tokenizer(input, separator); std::vector<T> items; for (const auto& token : tokenizer) { T value; auto trimmedToken = trimWhitespace(token); if (trimmedToken.empty()) continue; if (!tryParseValue(trimmedToken, &value)) return false; items.emplace_back(std::move(value)); } *outVal = std::move(items); return true; } template<typename T> bool tryParseValueListStrict(StringView str, char sep, char esc, std::vector<T> *outVal) { assert(str.data()); assert(outVal); auto input = str.to_string(); boost::escaped_list_separator<char> separator( std::string(1, esc), std::string(1, sep), std::string()); boost::tokenizer<boost::escaped_list_separator<char>> tokenizer(input, separator); std::vector<T> items; for (const auto& token : tokenizer) { T value; if (!tryParseValue(token, &value)) return false; items.emplace_back(std::move(value)); } *outVal = std::move(items); return true; } template<typename T> T parseValue(StringView str) { T result; if (!tryParseValue(str, &result)) throw std::invalid_argument("invalid value format"); return result; } template<typename T> std::vector<T> parseValueList(StringView str, char sep) { std::vector<T> result; if (!tryParseValueList(str, sep, &result)) throw std::invalid_argument("invalid value format"); return result; } template<typename T> std::vector<T> parseValueListStrict(StringView str, char sep, char esc) { std::vector<T> result; if (!tryParseValueListStrict(str, sep, esc, &result)) throw std::invalid_argument("invalid value format"); return result; } }
State Before: α : Type u inst✝² : Group α inst✝¹ : LE α inst✝ : CovariantClass α α (swap fun x x_1 => x * x_1) fun x x_1 => x ≤ x_1 a b c : α ⊢ 1 ≤ a⁻¹ ↔ a ≤ 1 State After: α : Type u inst✝² : Group α inst✝¹ : LE α inst✝ : CovariantClass α α (swap fun x x_1 => x * x_1) fun x x_1 => x ≤ x_1 a b c : α ⊢ 1 * a ≤ a⁻¹ * a ↔ a ≤ 1 Tactic: rw [← mul_le_mul_iff_right a] State Before: α : Type u inst✝² : Group α inst✝¹ : LE α inst✝ : CovariantClass α α (swap fun x x_1 => x * x_1) fun x x_1 => x ≤ x_1 a b c : α ⊢ 1 * a ≤ a⁻¹ * a ↔ a ≤ 1 State After: no goals Tactic: simp
labelWith : Stream labelType -> List a -> List (labelType, a) labelWith lbls [] = [] labelWith (lbl :: lbls) (x :: xs) = (lbl, x) :: labelWith lbls xs label : List a -> List (Integer, a) label = labelWith (iterate (+1) 0)
[STATEMENT] lemma TensorDiag_Diag: assumes "Diag (t \<^bold>\<otimes> u)" shows "t \<^bold>\<lfloor>\<^bold>\<otimes>\<^bold>\<rfloor> u = t \<^bold>\<otimes> u" [PROOF STATE] proof (prove) goal (1 subgoal): 1. t \<^bold>\<lfloor>\<^bold>\<otimes>\<^bold>\<rfloor> u = t \<^bold>\<otimes> u [PROOF STEP] using assms TensorDiag_Prim [PROOF STATE] proof (prove) using this: Diag (t \<^bold>\<otimes> u) ?t \<noteq> \<^bold>\<I> \<Longrightarrow> \<^bold>\<langle>?f\<^bold>\<rangle> \<^bold>\<lfloor>\<^bold>\<otimes>\<^bold>\<rfloor> ?t = \<^bold>\<langle>?f\<^bold>\<rangle> \<^bold>\<otimes> ?t goal (1 subgoal): 1. t \<^bold>\<lfloor>\<^bold>\<otimes>\<^bold>\<rfloor> u = t \<^bold>\<otimes> u [PROOF STEP] by (cases t, simp_all)
State Before: F : Type ?u.77288 α : Type u_1 β : Type ?u.77294 𝕜 : Type ?u.77297 E : Type ?u.77300 inst✝ : CancelCommMonoid α s : Set α a : α hs : MulSalemSpencer s ⊢ MulSalemSpencer ((fun x x_1 => x * x_1) a '' s) State After: case intro.intro.intro.intro.intro.intro F : Type ?u.77288 α : Type u_1 β : Type ?u.77294 𝕜 : Type ?u.77297 E : Type ?u.77300 inst✝ : CancelCommMonoid α s : Set α a : α hs : MulSalemSpencer s b : α hb : b ∈ s c : α hc : c ∈ s d : α hd : d ∈ s h : (fun x x_1 => x * x_1) a b * (fun x x_1 => x * x_1) a c = (fun x x_1 => x * x_1) a d * (fun x x_1 => x * x_1) a d ⊢ (fun x x_1 => x * x_1) a b = (fun x x_1 => x * x_1) a c Tactic: rintro _ _ _ ⟨b, hb, rfl⟩ ⟨c, hc, rfl⟩ ⟨d, hd, rfl⟩ h State Before: case intro.intro.intro.intro.intro.intro F : Type ?u.77288 α : Type u_1 β : Type ?u.77294 𝕜 : Type ?u.77297 E : Type ?u.77300 inst✝ : CancelCommMonoid α s : Set α a : α hs : MulSalemSpencer s b : α hb : b ∈ s c : α hc : c ∈ s d : α hd : d ∈ s h : (fun x x_1 => x * x_1) a b * (fun x x_1 => x * x_1) a c = (fun x x_1 => x * x_1) a d * (fun x x_1 => x * x_1) a d ⊢ (fun x x_1 => x * x_1) a b = (fun x x_1 => x * x_1) a c State After: case intro.intro.intro.intro.intro.intro F : Type ?u.77288 α : Type u_1 β : Type ?u.77294 𝕜 : Type ?u.77297 E : Type ?u.77300 inst✝ : CancelCommMonoid α s : Set α a : α hs : MulSalemSpencer s b : α hb : b ∈ s c : α hc : c ∈ s d : α hd : d ∈ s h : a * a * (b * c) = a * a * (d * d) ⊢ (fun x x_1 => x * x_1) a b = (fun x x_1 => x * x_1) a c Tactic: rw [mul_mul_mul_comm, mul_mul_mul_comm a d] at h State Before: case intro.intro.intro.intro.intro.intro F : Type ?u.77288 α : Type u_1 β : Type ?u.77294 𝕜 : Type ?u.77297 E : Type ?u.77300 inst✝ : CancelCommMonoid α s : Set α a : α hs : MulSalemSpencer s b : α hb : b ∈ s c : α hc : c ∈ s d : α hd : d ∈ s h : a * a * (b * c) = a * a * (d * d) ⊢ (fun x x_1 => x * x_1) a b = (fun x x_1 => x * x_1) a c State After: no goals Tactic: rw [hs hb hc hd (mul_left_cancel h)]
SUBROUTINE DT_LTINI(Idpr,Idta,Epn0,Ppn0,Ecm0,Mode) C*********************************************************************** C Initializations of Lorentz-transformations, calculation of Lorentz- * C parameters. * C This version dated 13.11.95 is written by S. Roesler. * C*********************************************************************** IMPLICIT NONE DOUBLE PRECISION amgam , amgam2 , amlpt2 , amp , amp2 , amt , & amt2 , ecm , Ecm0 , epn , Epn0 , etarg , ONE , & ppn , Ppn0 , ptarg , q2 , s , TINY10 , TINY3 DOUBLE PRECISION TWO , ZERO INTEGER idp , Idpr , idt , Idta , Mode SAVE INCLUDE 'inc/dtflka' PARAMETER (TINY10=1.0D-10,TINY3=1.0D-3,ZERO=0.0D0,ONE=1.0D0, & TWO=2.0D0) C Lorentz-parameters of the current interaction INCLUDE 'inc/dtltra' C properties of photon/lepton projectiles INCLUDE 'inc/dtgpro' C particle properties (BAMJET index convention) INCLUDE 'inc/dtpart' C nucleon-nucleon event-generator INCLUDE 'inc/dtmodl' q2 = VIRt idp = Idpr IF ( MCGene.NE.3 ) THEN C lepton-projectiles and PHOJET: initialize real photon instead IF ( (Idpr.EQ.3) .OR. (Idpr.EQ.4) .OR. (Idpr.EQ.10) .OR. & (Idpr.EQ.11) .OR. (Idpr.EQ.5) .OR. (Idpr.EQ.6) ) THEN idp = 7 q2 = ZERO END IF END IF idt = Idta epn = Epn0 ppn = Ppn0 ecm = Ecm0 amp = AAM(idp) - SQRT(ABS(q2)) amt = AAM(idt) amp2 = SIGN(amp**2,amp) amt2 = amt**2 IF ( Ecm0.GT.ZERO ) THEN epn = (ecm**2-amp2-amt2)/(TWO*amt) IF ( amp2.GT.ZERO ) THEN ppn = SQRT((epn+amp)*(epn-amp)) ELSE ppn = SQRT(epn**2-amp2) END IF ELSE IF ( (Epn0.NE.ZERO) .AND. (Ppn0.EQ.ZERO) ) THEN IF ( idp.EQ.7 ) epn = ABS(epn) IF ( epn.LT.ZERO ) epn = ABS(epn) + amp IF ( amp2.GT.ZERO ) THEN ppn = SQRT((epn+amp)*(epn-amp)) ELSE ppn = SQRT(epn**2-amp2) END IF ELSE IF ( (Ppn0.GT.ZERO) .AND. (Epn0.EQ.ZERO) ) THEN IF ( amp2.GT.ZERO ) THEN epn = ppn*SQRT(ONE+(amp/ppn)**2) ELSE epn = SQRT(ppn**2+amp2) END IF END IF ecm = SQRT(amp2+amt2+TWO*amt*epn) END IF UMO = ecm EPRoj = epn PPRoj = ppn IF ( amp2.GT.ZERO ) THEN etarg = (ecm**2-amp2-amt2)/(TWO*amp) ptarg = -SQRT((etarg+amt)*(etarg-amt)) ELSE etarg = TINY10 ptarg = TINY10 END IF C photon-projectiles (get momentum in cm-frame for virtuality Q^2) IF ( idp.EQ.7 ) THEN PGAmm(1) = ZERO PGAmm(2) = ZERO amgam = amp amgam2 = amp2 IF ( Ecm0.GT.ZERO ) THEN s = Ecm0**2 ELSE IF ( (Epn0.NE.ZERO) .AND. (Ppn0.EQ.ZERO) ) THEN s = amgam2 + amt2 + TWO*amt*ABS(Epn0) ELSE IF ( (Ppn0.GT.ZERO) .AND. (Epn0.EQ.ZERO) ) THEN s = amgam2 + amt2 + TWO*amt*SQRT(Ppn0**2+amgam2) END IF PGAmm(3) = SQRT((s**2-TWO*amgam2*s-TWO*amt2*s-TWO*amgam2*amt2+ & amgam2**2+amt2**2)/(4.0D0*s)) PGAmm(4) = SQRT(amgam2+PGAmm(3)**2) IF ( Mode.EQ.1 ) THEN PNUcl(1) = ZERO PNUcl(2) = ZERO PNUcl(3) = -PGAmm(3) PNUcl(4) = SQRT(s) - PGAmm(4) END IF END IF IF ( (Idpr.EQ.3) .OR. (Idpr.EQ.4) .OR. (Idpr.EQ.10) .OR. & (Idpr.EQ.11) ) THEN PLEpt0(1) = ZERO PLEpt0(2) = ZERO C neglect lepton masses C AMLPT2 = AAM(IDPR)**2 amlpt2 = ZERO C IF ( Ecm0.GT.ZERO ) THEN s = Ecm0**2 ELSE IF ( (Epn0.NE.ZERO) .AND. (Ppn0.EQ.ZERO) ) THEN s = amlpt2 + amt2 + TWO*amt*ABS(Epn0) ELSE IF ( (Ppn0.GT.ZERO) .AND. (Epn0.EQ.ZERO) ) THEN s = amlpt2 + amt2 + TWO*amt*SQRT(Ppn0**2+amlpt2) END IF PLEpt0(3) = SQRT((s**2-TWO*amlpt2*s-TWO*amt2*s-TWO*amlpt2*amt2+ & amlpt2**2+amt2**2)/(4.0D0*s)) PLEpt0(4) = SQRT(amlpt2+PLEpt0(3)**2) PNUcl(1) = ZERO PNUcl(2) = ZERO PNUcl(3) = -PLEpt0(3) PNUcl(4) = SQRT(s) - PLEpt0(4) END IF C Lorentz-parameter for transformation Lab. - projectile rest system IF ( (idp.EQ.7) .OR. (amp.LT.TINY10) ) THEN GALab = TINY10 BGLab = TINY10 BLAb = TINY10 ELSE GALab = EPRoj/amp BGLab = PPRoj/amp BLAb = BGLab/GALab END IF C Lorentz-parameter for transf. proj. rest sys. - nucl.-nucl. cms. IF ( idp.EQ.7 ) THEN GACms(1) = TINY10 BGCms(1) = TINY10 ELSE GACms(1) = (etarg+amp)/UMO BGCms(1) = ptarg/UMO END IF C Lorentz-parameter for transformation Lab. - nucl.-nucl. cms. GACms(2) = (EPRoj+amt)/UMO BGCms(2) = PPRoj/UMO PPCm = GACms(2)*PPRoj - BGCms(2)*EPRoj Epn0 = epn Ppn0 = ppn Ecm0 = ecm END SUBROUTINE
State Before: a b : Int ⊢ natAbs a ∣ natAbs b ↔ a ∣ b State After: a b : Int x✝ : natAbs a ∣ natAbs b k : Nat hk : natAbs b = natAbs a * k ⊢ a ∣ b Tactic: refine ⟨fun ⟨k, hk⟩ => ?_, fun ⟨k, hk⟩ => ⟨natAbs k, hk.symm ▸ natAbs_mul a k⟩⟩ State Before: a b : Int x✝ : natAbs a ∣ natAbs b k : Nat hk : natAbs b = natAbs a * k ⊢ a ∣ b State After: a b : Int x✝ : natAbs a ∣ natAbs b k : Nat hk : b = a * ↑k ∨ b = -(a * ↑k) ⊢ a ∣ b Tactic: rw [← natAbs_ofNat k, ← natAbs_mul, natAbs_eq_natAbs_iff] at hk State Before: a b : Int x✝ : natAbs a ∣ natAbs b k : Nat hk : b = a * ↑k ∨ b = -(a * ↑k) ⊢ a ∣ b State After: case inl a : Int k : Nat x✝ : natAbs a ∣ natAbs (a * ↑k) ⊢ a ∣ a * ↑k case inr a : Int k : Nat x✝ : natAbs a ∣ natAbs (-(a * ↑k)) ⊢ a ∣ -(a * ↑k) Tactic: cases hk <;> subst b State Before: case inl a : Int k : Nat x✝ : natAbs a ∣ natAbs (a * ↑k) ⊢ a ∣ a * ↑k State After: no goals Tactic: apply Int.dvd_mul_right State Before: case inr a : Int k : Nat x✝ : natAbs a ∣ natAbs (-(a * ↑k)) ⊢ a ∣ -(a * ↑k) State After: case inr a : Int k : Nat x✝ : natAbs a ∣ natAbs (-(a * ↑k)) ⊢ a ∣ a * -↑k Tactic: rw [← Int.mul_neg] State Before: case inr a : Int k : Nat x✝ : natAbs a ∣ natAbs (-(a * ↑k)) ⊢ a ∣ a * -↑k State After: no goals Tactic: apply Int.dvd_mul_right
function [soln,eqn,info] = PoissonWG(node,elem,bdFlag,pde,option) %% POISSONWG Poisson equation: lowest order weak Galerkin element % % u = POISSONWG(node,elem,bdFlag,pde) produces the linear finite element % approximation of the Poisson equation % % -div(d*grad(u))=f in \Omega, with % Dirichlet boundary condition u=g_D on \Gamma_D, % Neumann boundary condition d*grad(u)*n=g_N on \Gamma_N, % Robin boundary condition g_R*u + d*grad(u)*n=g_N on \Gamma _R % % The usage is the same as <a href="matlab:help Poisson">Poisson</a>. Weak Galerkin method on a triangle is % summarized in <a href="matlab:ifem PoissonWGfemrate">PoissonWGfemrate</a> for detail. % % Example % % squarePoissonWG; % % See also Poisson, squarePoissonWG % % Copyright (C) Long Chen. See COPYRIGHT.txt for details. %% Preprocess if ~exist('bdFlag','var'), bdFlag = []; end if ~exist('option','var'), option = []; end % important constants NT = size(elem,1); N = size(node,1); %% Diffusion coefficient time = cputime; % record assembling time if ~isfield(pde,'d'), pde.d = []; end if ~isfield(option,'dquadorder'), option.dquadorder = 1; end if ~isempty(pde.d) && isnumeric(pde.d) K = pde.d; % d is an array end if ~isempty(pde.d) && ~isnumeric(pde.d) % d is a function [lambda,weight] = quadpts(option.dquadorder); nQuad = size(lambda,1); K = zeros(NT,1); for p = 1:nQuad pxy = lambda(p,1)*node(elem(:,1),:) ... + lambda(p,2)*node(elem(:,2),:) ... + lambda(p,3)*node(elem(:,3),:); K = K + weight(p)*pde.d(pxy); end end %% Construct data structure [elem2edge,edge] = dofedge(elem); NE = size(edge,1); Ndof = NT + NE; elem2dof = NT + elem2edge; %% Assemble stiffness matrix A = sparse(Ndof,Ndof); % compute ct2 = 1/mean(||x-xc||^2) center = (node(elem(:,1),:) + node(elem(:,2),:) + node(elem(:,3),:))/3; mid1 = (node(elem(:,2),:) + node(elem(:,3),:))/2; mid2 = (node(elem(:,3),:) + node(elem(:,1),:))/2; mid3 = (node(elem(:,1),:) + node(elem(:,2),:))/2; ct2 = 3./sum((mid1 - center).^2 + (mid2 - center).^2 + (mid3 - center).^2,2); [Dphi,area] = gradbasis(node,elem); clear center mid1 mid2 mid3 % Mbb: edge - edge for i = 1:3 for j = i:3 % local to global index map ii = double(elem2dof(:,i)); jj = double(elem2dof(:,j)); % local stiffness matrix Aij = 4*dot(Dphi(:,:,i),Dphi(:,:,j),2).*area + 4/9*ct2.*area; if ~isempty(pde.d) Aij = K.*Aij; end if (j==i) A = A + sparse(ii,jj,Aij,Ndof,Ndof); else A = A + sparse([ii,jj],[jj,ii],[Aij; Aij],Ndof,Ndof); end end end % Mob: interior - edge Aij = -4/3*ct2.*area; if ~isempty(pde.d) Aij = K.*Aij; end Mob = sparse([(1:NT)', (1:NT)', (1:NT)'], ... double(elem2dof(:)), [Aij, Aij, Aij], Ndof, Ndof); A = A + Mob + Mob'; % Moo: diagonal of interor Aij = 4*ct2.*area; if ~isempty(pde.d) Aij = K.*Aij; end A = A + sparse(1:NT, 1:NT, Aij, Ndof, Ndof); clear K Aij %% Assemble the right hand side b = zeros(Ndof,1); if ~isfield(option,'fquadorder') option.fquadorder = 2; % default order end if ~isfield(pde,'f') || (isreal(pde.f) && (pde.f==0)) pde.f = []; end if isreal(pde.f) % f is a real number or vector and not a function switch length(pde.f) case NT % f is piecewise constant b(1:NT) = pde.f.*area; case N % f is piecewise linear b(1:NT) = (pde.f(elem(:,1)) + pde.f(elem(:,2)) + pde.f(elem(:,3)))/3.*area; case 1 % f is a scalar e.g. f = 1 b(1:NT) = pde.f*area; end end if ~isempty(pde.f) && ~isreal(pde.f) % f is a function [lambda,weight] = quadpts(option.fquadorder); nQuad = size(lambda,1); bt = zeros(NT,1); for p = 1:nQuad % quadrature points in the x-y coordinate pxy = lambda(p,1)*node(elem(:,1),:) ... + lambda(p,2)*node(elem(:,2),:) ... + lambda(p,3)*node(elem(:,3),:); fp = pde.f(pxy); bt = bt + weight(p)*fp; end bt = bt.*area; b(1:NT) = bt; end clear pxy bt %% Set up boundary conditions if nargin<=3, bdFlag = []; end [AD,b,u,freeDof,isPureNeumann] = getbdWG(A,b); %% Record assembling time assembleTime = cputime - time; if ~isfield(option,'printlevel'), option.printlevel = 1; end if option.printlevel >= 2 fprintf('Time to assemble matrix equation %4.2g s\n',assembleTime); end %% Solve the system of linear equations if isempty(freeDof), return; end % Set up solver type if isempty(option) || ~isfield(option,'solver') % no option.solver if NE <= 1e3 % Direct solver for small size systems option.solver = 'direct'; else % MGCG solver for large size systems option.solver = 'mg'; end end solver = option.solver; % solve switch solver case 'direct' tic; u(freeDof) = AD(freeDof,freeDof)\b(freeDof); residual = norm(b - AD*u); info = struct('solverTime',toc,'itStep',0,'err',residual,'flag',2,'stopErr',residual); case 'none' info = struct('solverTime',[],'itStep',0,'err',[],'flag',3,'stopErr',[]); case 'mg' % eleminate elementwise dof option.solver = 'CG'; if isfield(option,'reducesystem') && (option.reducesystem == 0) option.x0 = u; [u,info] = mg(AD,b,elem,option,edge); else option.x0 = u(NT+1:end); Aoinv = spdiags(1./diag(AD(1:NT,1:NT)),0,NT,NT); Aob = AD(1:NT,NT+1:end); Abo = Aob'; Abb = AD(NT+1:end,NT+1:end); Abbm = Abb - Abo*Aoinv*Aob; bm = -Abo*Aoinv*b(1:NT) + b(NT+1:end); [ub,info] = mg(Abbm,bm,elem,option,edge); u(1:NT) = Aoinv*(b(1:NT) - Aob*ub); u(NT+1:end) = ub; end case 'amg' option.solver = 'CG'; [u(freeDof),info] = amg(AD(freeDof,freeDof),b(freeDof),option); end % post-process for pure Neumann problem if isPureNeumann uc = sum(u(1:NT).*area); u = u - uc; % normalization for pure Neumann problem end %% Compute Du dudx = u(elem2dof(:,1)).*Dphi(:,1,1) + u(elem2dof(:,2)).*Dphi(:,1,2) ... + u(elem2dof(:,3)).*Dphi(:,1,3); dudy = u(elem2dof(:,1)).*Dphi(:,2,1) + u(elem2dof(:,2)).*Dphi(:,2,2) ... + u(elem2dof(:,3)).*Dphi(:,2,3); Du = -2*[dudx, dudy]; %% Output information if nargout == 1 soln = u; else soln = struct('u',u,'Du',Du); eqn = struct('A',AD,'b',b,'edge',edge,'freeDof',freeDof); info.assembleTime = assembleTime; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % subfunctions getbdWG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [AD,b,u,freeDof,isPureNeumann]= getbdWG(A,b) %% GETBDCR Boundary conditions for Poisson equation: WG element. u =zeros(Ndof,1); %% Initial check if ~isfield(pde,'g_D'), pde.g_D = []; end if ~isfield(pde,'g_N'), pde.g_N = []; end if ~isfield(pde,'g_R'), pde.g_R = []; end %% Part 1: Modify the matrix for Dirichlet and Robin condition % Robin boundary condition Robin = []; idxR = (bdFlag(:) == 3); % index of Robin edges in bdFlag if any(idxR) isRobin = false(NE,1); isRobin(elem2edge(idxR)) = true; Robin = edge(isRobin,:); % Robin edges end if ~isempty(Robin) && ~isempty(pde.g_R) && ~(isnumeric(pde.g_R) && (pde.g_R == 0)) ve = node(Robin(:,1),:) - node(Robin(:,2),:); edgeLength = sqrt(sum(ve.^2,2)); mid = (node(Robin(:,1),:) + node(Robin(:,2),:))/2; ii = NT + find(isRobin); % for WG: edge dof is after elem dof ss = pde.g_R(mid).*edgeLength; % exact for linear g_R A = A + sparse(ii,ii,ss,Ndof,Ndof); end % Find Dirichlet boundary nodes: fixedEdge fixedEdge = []; freeEdge = []; if ~isempty(bdFlag) % find boundary edges idxD = (bdFlag(:) == 1); % all Dirichlet edges in bdFlag isFixedEdge = false(NE,1); isFixedEdge(elem2edge(idxD)) = true; % index of fixed boundary edges fixedEdge = find(isFixedEdge); freeEdge = find(~isFixedEdge); end if isempty(bdFlag) && ~isempty(pde.g_D) && isempty(pde.g_N) && isempty(pde.g_R) % no bdFlag, only pde.g_D is given in the input s = accumarray(elem2edge(:), 1, [NE 1]); fixedEdge = find(s == 1); freeEdge = find(s == 2); end isPureNeumann = false; if isempty(fixedEdge) && isempty(Robin) % pure Neumann boundary condition % pde.g_N could be empty which is homogenous Neumann boundary condition isPureNeumann = true; fixedEdge = 1; freeEdge = (2:NE)'; % eliminate the kernel by enforcing u(1) = 0; end % Modify the matrix % Build Dirichlet boundary condition into the matrix AD by enforcing % AD(fixedEdge,fixedEdge)=I, AD(fixedEdge,freeEdge)=0, AD(freeEdge,fixedEdge)=0. if ~isempty(fixedEdge) bdidx = zeros(Ndof,1); bdidx(NT + fixedEdge) = 1; Tbd = spdiags(bdidx,0,Ndof,Ndof); T = spdiags(1-bdidx,0,Ndof,Ndof); AD = T*A*T + Tbd; else AD = A; end %% Part 2: Find boundary edges and modify the right hand side b % Find boundary edges: Neumann Neumann = []; if ~isempty(bdFlag) % bdFlag specifies different bd conditions idxN = (bdFlag(:) == 2); % all Neumann edges in bdFlag isNeumann = elem2edge(idxN | idxR); % index of Neumann and Robin edges % since boundary integral is also needed for Robin edges Neumann = edge(isNeumann,:); % Neumann edges end if isempty(bdFlag) && (~isempty(pde.g_N) || ~isempty(pde.g_R)) % no bdFlag, only pde.g_N or pde.g_R is given in the input s = accumarray(elem2edge(:), 1, [NE 1]); Neumann = edge(s == 1,:); end % Neumann boundary condition if ~isempty(Neumann) && ~isempty(pde.g_N) && ~(isnumeric(pde.g_N) && (pde.g_N == 0)) if ~isfield(option,'gNquadorder') option.gNquadorder = 3; % default order exact for linear gN end [lambdagN,weightgN] = quadpts1(option.gNquadorder); nQuadgN = size(lambdagN,1); ge = zeros(size(Neumann,1),1); el = sqrt(sum((node(Neumann(:,1),:) - node(Neumann(:,2),:)).^2,2)); for pp = 1:nQuadgN % quadrature points in the x-y coordinate ppxy = lambdagN(pp,1)*node(Neumann(:,1),:) ... + lambdagN(pp,2)*node(Neumann(:,2),:); gNp = pde.g_N(ppxy); ge = ge+ weightgN(pp)*gNp; end ge = ge.*el; b(NT+isNeumann) = b(NT+isNeumann) + ge; end % The case with non-empty Neumann edges but g_N=0 or g_N=[] corresponds to % the zero flux boundary condition on Neumann edges and no modification of % A,u,b is needed. % Dirichlet boundary condition if ~isPureNeumann && ~isempty(fixedEdge) && ... ~isempty(pde.g_D) && ~(isnumeric(pde.g_D) && all(pde.g_D == 0)) % nonzero g_D if isnumeric(pde.g_D) % pde.g_D could be a numerical array u(fixedEdge) = pde.g_D(fixedEdge); else % pde.g_D is a function handle mid = (node(edge(fixedEdge,1),:) + node(edge(fixedEdge,2),:))/2; u(NT+fixedEdge) = pde.g_D(mid); end b = b - A*u; b(NT+fixedEdge) = u(NT+fixedEdge); end % The case with non-empty Dirichlet nodes but g_D=0 or g_D=[] corresponds % to the zero Dirichlet boundary condition and no modification of u,b is % needed. % Pure Neumann boundary condition if isPureNeumann b = b - mean(b); % compatilbe condition: sum(b) = 0 b(1) = 0; end freeDof = [(1:NT)'; NT+freeEdge]; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end % end of PoissonWG
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ | Phycas: Python software for phylogenetic analysis | | Copyright (C) 2006 Mark T. Holder, Paul O. Lewis and David L. Swofford | | | | This program is free software; you can redistribute it and/or modify | | it under the terms of the GNU General Public License as published by | | the Free Software Foundation; either version 2 of the License, or | | (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of the GNU General Public License along | | with this program; if not, write to the Free Software Foundation, Inc., | | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #if defined(_MSC_VER) # pragma warning(disable : 4267) // boost's builtin_converters.hpp casts size_t to int rather than unsigned #endif #include <boost/python.hpp> //#include "phycas/force_include.h" #include "model.hpp" #include "gtr.hpp" #include "jc.hpp" #include "hky.hpp" #include "codon_model.hpp" #include "varcov.hpp" using namespace boost::python; using namespace phycas; void model_pymod() { class_<QMatrix, boost::noncopyable>("QMatrixBase") .def("getDimension", &QMatrix::getDimension) .def("setRelativeRates", &QMatrix::setRelativeRates) .def("setStateFreqs", &QMatrix::setStateFreqs) .def("getPMatrix", &QMatrix::getPMatrix) .def("getQMatrix", &QMatrix::getQMatrix) .def("getEigenVectors", &QMatrix::getEigenVectors) .def("getEigenValues", &QMatrix::getEigenValues) ; class_<VarCovMatrix, boost::noncopyable>("VarCovBase", init<std::string,unsigned,unsigned>()) //.def("copyNewick", &VarCovMatrix::copyNewick) //.def("copyParamTypes", &VarCovMatrix::copyParamTypes) .def("setParamNames", &VarCovMatrix::setParamNames) .def("copyParamVector", &VarCovMatrix::copyParamVector) .def("standardizeSamples", &VarCovMatrix::standardizeSamples) .def("getLogRatioSum", &VarCovMatrix::getLogRatioSum) .def("getLogRatioVect", &VarCovMatrix::getLogRatioVect) .def("getRepresentativeLogKernel", &VarCovMatrix::getRepresentativeLogKernel) .def("getRepresentativeLogLikelihood", &VarCovMatrix::getRepresentativeLogLikelihood) .def("getRepresentativeLogPrior", &VarCovMatrix::getRepresentativeLogPrior) .def("getRepresentativeLogJacobianEdgelen", &VarCovMatrix::getRepresentativeLogJacobianEdgelen) .def("getRepresentativeLogJacobianSubstmodel", &VarCovMatrix::getRepresentativeLogJacobianSubstmodel) .def("getRepresentativeLogJacobianStandardization", &VarCovMatrix::getRepresentativeLogJacobianStandardization) .def("getRepresentativeParamVect", &VarCovMatrix::getRepresentativeParamVect) .def("calcRepresentativeForShell", &VarCovMatrix::calcRepresentativeForShell) .def("getRepresentativesForShell", &VarCovMatrix::getRepresentativesForShell) .def("debugTestStandardization", &VarCovMatrix::debugTestStandardization) .def("logJacobianForStandardization", &VarCovMatrix::logJacobianForStandardization) .def("destandardizeSample", &VarCovMatrix::destandardizeSample) ; class_<phycas::Model, boost::noncopyable, boost::shared_ptr<phycas::Model> >("Model", no_init) .def("fixEdgeLenHyperprior", &phycas::Model::fixEdgeLenHyperprior) .def("freeEdgeLenHyperprior", &phycas::Model::freeEdgeLenHyperprior) .def("fixEdgeLengths", &phycas::Model::fixEdgeLengths) .def("freeEdgeLengths", &phycas::Model::freeEdgeLengths) .def("fixStateFreqs", &phycas::Model::fixStateFreqs) .def("freeStateFreqs", &phycas::Model::freeStateFreqs) .def("fixShape", &phycas::Model::fixShape) .def("freeShape", &phycas::Model::freeShape) .def("shapeFixed", &phycas::Model::shapeFixed) .def("pinvarFixed", &phycas::Model::pinvarFixed) .def("stateFreqsFixed", &phycas::Model::stateFreqsFixed) .def("edgeLenHyperParamFixed", &phycas::Model::edgeLenHyperParamFixed) .def("edgeLengthsFixed", &phycas::Model::edgeLengthsFixed) .def("isPinvarModel", &phycas::Model::isPinvarModel) .def("setPinvarModel", &phycas::Model::setPinvarModel) .def("setNotPinvarModel", &phycas::Model::setNotPinvarModel) .def("fixPinvar", &phycas::Model::fixPinvar) .def("freePinvar", &phycas::Model::freePinvar) .def("getPinvarPrior", &phycas::Model::getPinvarPrior) .def("setPinvarPrior", &phycas::Model::setPinvarPrior) .def("getDiscreteGammaShapePrior", &phycas::Model::getDiscreteGammaShapePrior) .def("setDiscreteGammaShapePrior", &phycas::Model::setDiscreteGammaShapePrior) .def("getTreeLengthPrior", &phycas::Model::getTreeLengthPrior) .def("setTreeLengthPrior", &phycas::Model::setTreeLengthPrior) .def("getExternalEdgeLenPrior", &phycas::Model::getExternalEdgeLenPrior) .def("setExternalEdgeLenPrior", &phycas::Model::setExternalEdgeLenPrior) .def("getInternalEdgeLenPrior", &phycas::Model::getInternalEdgeLenPrior) .def("setInternalEdgeLenPrior", &phycas::Model::setInternalEdgeLenPrior) .def("isSeparateInternalExternalEdgeLenPriors", &phycas::Model::isSeparateInternalExternalEdgeLenPriors) .def("setEdgeSpecificParams", &phycas::Model::setEdgeSpecificParams) .def("separateInternalExternalEdgeLenPriors", &phycas::Model::separateInternalExternalEdgeLenPriors) .def("hasEdgeLenHyperPrior", &phycas::Model::hasEdgeLenHyperPrior) .def("getInternalEdgelenHyperparam", &phycas::Model::getInternalEdgelenHyperparam) .def("getExternalEdgelenHyperparam", &phycas::Model::getExternalEdgelenHyperparam) .def("getEdgeLenHyperPrior", &phycas::Model::getEdgeLenHyperPrior) .def("setEdgeLenHyperPrior", &phycas::Model::setEdgeLenHyperPrior) .def("getModelName", &phycas::Model::getModelName) .def("getPinvar", &phycas::Model::getPinvar) .def("setPinvar", &phycas::Model::setPinvar) .def("getShape", &phycas::Model::getShape) .def("setShape", &phycas::Model::setShape) .def("getNGammaRates", &phycas::Model::getNGammaRates) .def("setNGammaRates", &phycas::Model::setNGammaRates) .def("getGammaRateProbs", &phycas::Model::getGammaRateProbs, return_value_policy<copy_const_reference>()) .def("setAllGammaRateProbsEqual", &phycas::Model::setAllGammaRateProbsEqual) .def("getPMatrix", &phycas::Model::getPMatrix) .def("setStateFreqsUnnorm", &phycas::Model::setStateFreqsUnnorm) .def("setStateFreqUnnorm", &phycas::Model::setStateFreqUnnorm) .def("getTimeStamp", &phycas::Model::getTimeStamp) ; class_<phycas::Irreversible, bases<phycas::Model> >("IrreversibleModelBase") .def("getModelName", &phycas::Irreversible::getModelName) .def("getNStates", &phycas::Irreversible::getNumStates) .def("getStateFreqs", &phycas::Irreversible::getStateFreqs, return_value_policy<copy_const_reference>()) .def("fixScalingFactor", &phycas::Irreversible::fixScalingFactor) .def("freeScalingFactor", &phycas::Irreversible::freeScalingFactor) .def("getScalingFactor", &phycas::Irreversible::getScalingFactor) .def("setScalingFactor", &phycas::Irreversible::setScalingFactor) .def("getScalingFactorPrior", &phycas::Irreversible::getScalingFactorPrior) .def("setScalingFactorPrior", &phycas::Irreversible::setScalingFactorPrior) .def("setGainOnly", &phycas::Irreversible::setGainOnly) .def("setLossOnly", &phycas::Irreversible::setLossOnly) .def("paramHeader", &phycas::Irreversible::paramHeader) .def("paramReport", &phycas::Irreversible::paramReport) ; class_<phycas::Binary, bases<phycas::Model> >("BinaryModelBase") .def("getModelName", &phycas::Binary::getModelName) .def("getNStates", &phycas::Binary::getNumStates) .def("getStateFreqs", &phycas::Binary::getStateFreqs, return_value_policy<copy_const_reference>()) .def("setAllFreqsEqual", &phycas::Binary::setAllFreqsEqual) .def("fixScalingFactor", &phycas::Binary::fixScalingFactor) .def("freeScalingFactor", &phycas::Binary::freeScalingFactor) .def("getScalingFactor", &phycas::Binary::getScalingFactor) .def("setScalingFactor", &phycas::Binary::setScalingFactor) .def("getScalingFactorPrior", &phycas::Binary::getScalingFactorPrior) .def("setScalingFactorPrior", &phycas::Binary::setScalingFactorPrior) .def("fixKappa", &phycas::Binary::fixKappa) .def("freeKappa", &phycas::Binary::freeKappa) .def("getKappa", &phycas::Binary::getKappa) .def("setKappa", &phycas::Binary::setKappa) .def("getKappaPrior", &phycas::Binary::getKappaPrior) .def("setKappaPrior", &phycas::Binary::setKappaPrior) .def("paramHeader", &phycas::Binary::paramHeader) .def("paramReport", &phycas::Binary::paramReport) ; class_<phycas::JC, bases<phycas::Model> >("JCModelBase") .def("getModelName", &phycas::JC::getModelName) .def("getNStates", &phycas::JC::getNumStates) .def("getStateFreqs", &phycas::JC::getStateFreqs, return_value_policy<copy_const_reference>()) .def("setAllFreqsEqual", &phycas::JC::setAllFreqsEqual) .def("paramHeader", &phycas::JC::paramHeader) .def("paramReport", &phycas::JC::paramReport) ; class_<phycas::HKY, bases<phycas::Model> >("HKYModelBase") .def("getModelName", &phycas::HKY::getModelName) .def("fixKappa", &phycas::HKY::fixKappa) .def("freeKappa", &phycas::HKY::freeKappa) .def("getKappa", &phycas::HKY::getKappa) .def("setKappa", &phycas::HKY::setKappa) .def("getKappaPrior", &phycas::HKY::getKappaPrior) .def("setKappaPrior", &phycas::HKY::setKappaPrior) .def("getStateFreqPrior", &phycas::HKY::getStateFreqPrior) .def("setStateFreqPrior", &phycas::HKY::setStateFreqPrior) .def("getStateFreqParamPrior", &phycas::HKY::getStateFreqParamPrior) .def("setStateFreqParamPrior", &phycas::HKY::setStateFreqParamPrior) .def("setKappaFromTRatio", &phycas::HKY::setKappaFromTRatio) .def("calcTRatio", &phycas::HKY::calcTRatio) .def("getNStates", &phycas::HKY::getNumStates) .def("getStateFreqs", &phycas::HKY::getStateFreqs, return_value_policy<copy_const_reference>()) .def("setAllFreqsEqual", &phycas::HKY::setAllFreqsEqual) .def("setNucleotideFreqs", &phycas::HKY::setNucleotideFreqs) .def("paramHeader", &phycas::HKY::paramHeader) .def("paramReport", &phycas::HKY::paramReport) ; class_<phycas::GTR, bases<phycas::Model> >("GTRModelBase") .def("getModelName", &phycas::GTR::getModelName) //.def("createParameters", &phycas::GTR::createParameters) //.def("calcPMat", &phycas::GTR::calcPMat) .def("fixRelRates", &phycas::GTR::fixRelRates) .def("freeRelRates", &phycas::GTR::freeRelRates) .def("getRelRates", &phycas::GTR::getRelRates) .def("setRelRates", &phycas::GTR::setRelRates) .def("setRelRateUnnorm", &phycas::GTR::setRelRateUnnorm) .def("setRelRateParamPrior", &phycas::GTR::setRelRateParamPrior) .def("getRelRateParamPrior", &phycas::GTR::getRelRateParamPrior) .def("setRelRatePrior", &phycas::GTR::setRelRatePrior) .def("getRelRatePrior", &phycas::GTR::getRelRatePrior) .def("setNucleotideFreqs", &phycas::GTR::setNucleotideFreqs) .def("getStateFreqs", &phycas::GTR::getStateFreqs, return_value_policy<copy_const_reference>()) .def("setAllFreqsEqual", &phycas::GTR::setAllFreqsEqual) .def("getStateFreqPrior", &phycas::GTR::getStateFreqPrior) .def("setStateFreqPrior", &phycas::GTR::setStateFreqPrior) .def("setStateFreqParamPrior", &phycas::GTR::setStateFreqParamPrior) .def("getStateFreqParamPrior", &phycas::GTR::getStateFreqParamPrior) .def("paramHeader", &phycas::GTR::paramHeader) .def("paramReport", &phycas::GTR::paramReport) .def("calcTRatio", &phycas::GTR::calcTRatio) ; class_<phycas::Codon, bases<phycas::Model> >("CodonModelBase") .def("getModelName", &phycas::Codon::getModelName) .def("getNStates", &phycas::Codon::getNumStates) .def("getStateFreqs", &phycas::Codon::getStateFreqs, return_value_policy<copy_const_reference>()) .def("setStateFreqUnnorm", &phycas::Codon::setStateFreqUnnorm) .def("setAllFreqsEqual", &phycas::Codon::setAllFreqsEqual) .def("setNucleotideFreqs", &phycas::Codon::setNucleotideFreqs) .def("fixKappa", &phycas::Codon::fixKappa) .def("freeKappa", &phycas::Codon::freeKappa) .def("fixOmega", &phycas::Codon::fixOmega) .def("freeOmega", &phycas::Codon::freeOmega) .def("getKappa", &phycas::Codon::getKappa) .def("setKappa", &phycas::Codon::setKappa) .def("getOmega", &phycas::Codon::getOmega) .def("setOmega", &phycas::Codon::setOmega) .def("getNGammaRates", &phycas::Codon::getNGammaRates) .def("setNGammaRates", &phycas::Codon::setNGammaRates) .def("getKappaPrior", &phycas::Codon::getKappaPrior) .def("setKappaPrior", &phycas::Codon::setKappaPrior) .def("getOmegaPrior", &phycas::Codon::getOmegaPrior) .def("setOmegaPrior", &phycas::Codon::setOmegaPrior) .def("getStateFreqPrior", &phycas::Codon::getStateFreqPrior) .def("setStateFreqPrior", &phycas::Codon::setStateFreqPrior) .def("setStateFreqParamPrior", &phycas::Codon::setStateFreqParamPrior) .def("getStateFreqParamPrior", &phycas::Codon::getStateFreqParamPrior) .def("paramHeader", &phycas::Codon::paramHeader) .def("paramReport", &phycas::Codon::paramReport) ; }
""" A `WrappedDomain` is a wrapper around an object that implements the domain interface, and that is itself a domain. """ struct WrappedDomain{D,T} <: Domain{T} domain :: D end WrappedDomain(domain) = WrappedDomain{typeof(domain),eltype(domain)}(domain) indomain(x, d::WrappedDomain) = in(x, d.domain) # Anything can be converted to a domain by wrapping it. An error will be thrown # if the object does not support `eltype`. convert(::Type{Domain}, v::Domain) = v convert(::Type{Domain}, v) = WrappedDomain(v)
function _record_pointers(o::IO) n = o.size ÷ 80 # number of records in IO (36 records/block) r = [(i-1)*80 for i=1:n] # start-of-record pointers (80 bytes/record) return r end function _block_pointers(o::IO) n = o.size ÷ 2880 # number of blocks in IO b = [(i-1)*2880 for i=1:n] # start-of-block pointers (2880 bytes/block) return b end function _header_pointers(o::IO) b = _block_pointers(o::IO) # b: start-of-block pointers h::Array{Int,1} = [] # h: init start-of-header pointers for i ∈ Base.eachindex(b) # i: start-of-block pointer Base.seek(o,b[i]) key = String(Base.read(o,8)) key ∈ ["SIMPLE ", "XTENSION"] ? Base.push!(h,b[i]) : false end return h # return start-of-header pointers end function _hdu_pointers(o::IO) h = _header_pointers(o::IO) # h: start-of-header pointers return h # return start-of-HDU (= start-of-header) pointers end function _data_pointers(o::IO) b = _block_pointers(o::IO) # b: start-of-block pointers d::Array{Int,1} = [] # h: init start-of-data pointers for i ∈ eachindex(b) # i: start-of-block pointer (36 records/block = 2880 bytes) Base.seek(o,b[i]) [(key = String(Base.read(o,8)); key == "END " ? Base.push!(d,b[i]+2880) : Base.skip(o,72)) for j=0:35] end return d # return start-of-data pointers end
| pc = 0xc003 | a = 0xfa | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 10110100 | MEM[0xc025] = 0xfa | | pc = 0xc006 | a = 0x00 | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110110 | MEM[0xc026] = 0x00 | | pc = 0xc009 | a = 0x0f | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110100 | MEM[0xc027] = 0x0f | | pc = 0xc00c | a = 0x00 | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110110 | MEM[0xc028] = 0x00 | | pc = 0xc00f | a = 0x00 | x = 0xfa | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 10110100 | MEM[0xc025] = 0xfa | | pc = 0xc012 | a = 0x00 | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110110 | MEM[0xc026] = 0x00 | | pc = 0xc015 | a = 0x00 | x = 0x0f | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110100 | MEM[0xc027] = 0x0f | | pc = 0xc018 | a = 0x00 | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110110 | MEM[0xc028] = 0x00 | | pc = 0xc01b | a = 0x00 | x = 0x00 | y = 0xfa | sp = 0x01fd | p[NV-BDIZC] = 10110100 | MEM[0xc025] = 0xfa | | pc = 0xc01e | a = 0x00 | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110110 | MEM[0xc026] = 0x00 | | pc = 0xc021 | a = 0x00 | x = 0x00 | y = 0x0f | sp = 0x01fd | p[NV-BDIZC] = 00110100 | MEM[0xc027] = 0x0f | | pc = 0xc024 | a = 0x00 | x = 0x00 | y = 0x00 | sp = 0x01fd | p[NV-BDIZC] = 00110110 | MEM[0xc028] = 0x00 |
State Before: q : ℚ x y : ℝ h : Irrational x ⊢ Irrational (↑q - x) State After: no goals Tactic: simpa only [sub_eq_add_neg] using h.neg.rat_add q
Astellas Pharma Inc. has completed the acquisition of Ogeda SA (previously Euroscreen SA, Gosselies, Belgium). Under the share purchase agreement executed between Astellas and Ogeda shareholders, Astellas paid €500m to acquire 100% of the equity in Ogeda. Ogeda shareholders will become eligible to receive up to €300m in milestones relating to clinical progress of fezolinetant, Ogeda’s most advanced clinical programme for the treatment of menopausal-related vasomotor symptoms. With the acquisition, Astellas’ expands its clinical pipeline with fezolinetant, an oral compound targeting the NK3 receptor. The lead compound of Ogeda (formerly Euroscreen S.A.), fezolinetant (ESN364), is currently being developed in three Phase IIa programmes to treat different conditions: menopausal hot flashes, polycystic ovary syndrome (PCOS) and uterine fibroids. Furthermore, Ogeda’s preclinical ulcerative colitis programme ESN 282 has been partnered with Merck & Co. Ogeda’s third published compound ESN601 in discovery stage is designed to treat autoimmune diseases. In January, Ogeda announced positive results from a Phase IIa study for the non-hormonal treatment of menopause-related vasomotor symptoms (“MR-VMS”). In 80 patients, fezolinetant reduced the frequency of moderate-to-severe HF at week-4 by 89% from baseline compared to 38% for placebo, and 93% at week-12, compared to 54% for placebo. Fezolinetant also reduced HF severity at week 4 by 60% from baseline compared to 12% for placebo, and 70% at week-12 compared to 23% for placebo. No severe adverse events were reported in either treatment group. Mild-to-moderate adverse events were reported in 67% of the fezolinetant group and 80% in the placebo group.
\label{sec:install} This chapter contains guidance on how to obtain a copy of NWChem and install it on your system. The best source for installation instructions is the INSTALL file in the NWChem source distribution, so those instructions will not be repeated here. If you have problems with the installation, you can request help from NWChem support via e-mail at {\tt [email protected]}. The following subsections discuss some of the important considerations when installing NWChem, and provide information on environmental variables, libraries, and makefiles needed to run the code. \section{How to Obtain NWChem} The NWChem source code tree current release is version 5.1.1. To obtain NWChem a User's Agreement must be properly filled out and sent to us. The User's Agreement may be found on the NWChem webpages at \begin{verbatim} http://www.emsl.pnl.gov:2080/docs/nwchem \end{verbatim} by clicking on the link "Download" and following the instructions as they appear. If you already have an older version of NWChem, new download informaiton may be obtained at the location on the web. If you have any problems using the WWW pages or forms, or getting access to the code, send e-mail to {\tt [email protected]}. \section{Supported Platforms} \label{sec:platforms} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % NOTE: this section is adapted from the current (as of 3/28/01) version of % the script INSTALL for NWChem, in the CVS repository. If INSTALL % has been updated since, this section should be updated, too. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NWChem is readily portable to essentially any sequential or parallel computer. The source code currently contains options for versions that will run on the following platforms. \begin{verbatim} NWCHEM_TARGET Platform Checked OS/Version Precision ----------------------------------------------------------------- SOLARIS Sun *** Solaris 2.X double IBM IBM RS/6000 *** AIX 4.X double SGI_N32 SGI 64 bit os *** IRIX 6.5 double using 32 ints SGITFP SGI 64 bit os *** IRIX 6.5 double CRAY-T3D Cray T3D UNICOS single CRAY-T3E Cray T3E *** UNICOS single LAPI IBM SP *** AIX/LAPI double LINUX Intel x86 *** RedHat 5.2-6.2 double PowerPC ** RedHat 6.0 double LINUX64 Alpha ** RedHat 6.2 double HPUX HP ** HPUX 11.0 double WIN32 Intel x86 * Windows98/NT double ----------------------------------------------------------------- *Note: LAPI is now the primary way to use NWChem on an IBM SP system. If you don't have it get it from IBM. \end{verbatim} The environment variable {\tt NWCHEM\_TARGET} must be set to the symbolic name that matches your target platform. For example, if you are installing the code on an IBM SP, the command is \begin{verbatim} % setenv NWCHEM_TARGET LAPI \end{verbatim} Refer to Section \ref{sec:envar} for additional discussion of environmental variables required by NWChem. \subsection{Porting Notes} \label{sec:PortingNotes} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % NOTE: this section is adapted from the current (as of 9/29/98) version of % the file Porting.notes, from ~/doc/ in the CVS repository. If Porting.notes % has been updated since, this section should be updated, too. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% While it is true that NWChem will run on {\em almost} any computer, there are always a few jokers in the deck. Here are some that have been found, and were considered sufficiently amusing to be documented. \begin{itemize} \item from the Intel Paragon OSF/1 R1.2.1 (discovered 16 July 1994 by DE Bernholdt); PGI's compilation system is braindamaged in some fascinating ways: \begin{enumerate} \item cpp860 by default defines {\tt \_\_PARAGON\_\_} and other things, as stated in the {\tt man} page, but when invoked by {\tt if77}, these things are {\em not} defined. \item ld's -L prepends directories to the search path instead of appending, as is done in almost every other unix compiler package \end{enumerate} \item from the HP-UX 9000/735, also some others (reported 08 Feb 1996 by Jarek Nieplocha): \begin{enumerate} \item Avoid the "free" HP C compiler - use gcc instead: HP cc does not generate any symbols or code for several routines in one of the GA files. To make the user's life more entertaining, there are no warning or error messages either -- compiler creates a junk object file quietly and pretends that everything went well. (Karl Anderson says: "(HP) cc is worth every penny you paid for it.") \item {\tt fort77} instead of {\tt f77} should be used to link fortran programs, since {\tt f77} doesn't support the {\tt -L} flag. Fortran code should be compiled with the {\tt +ppu} flag that adds underscores to the subroutine names. \end{enumerate} \end{itemize} \section{Environmental Variables} \label{sec:envar} There are mandatory environmental variables, as well as optional ones, that need to be set for the compilation of NWChem to work correctly. The mandatory one are listed first: \begin{table}[htbp] \begin{center} \begin{tabular}{lcc} \verb+NWCHEM_TOP+ & the top directory of the NWChem tree, e.g.\\ \verb+ setenv NWCHEM_TOP /u/adrian/nwchem+\\ \\ \verb+NWCHEM_TARGET+ & the symbolic name that matches your target \\ & platform, e.g.\\ \verb+ setenv NWCHEM_TARGET LAPI+\\ \\ \verb+NWCHEM_MODUELS+ & the modules you want included in the binary \\ & that you build, e.g.\\ \verb+ setenv NWCHEM_MODULES "all gapss"+ \end{tabular} \end{center} \end{table} The following environment variables which tell NWChem more about your system are optional. If they are not set, NWChem will try to pick reasonable defaults: \begin{table}[htbp] \begin{center} \begin{tabular}{lcc} \verb+NWCHEM_TARGET_CPU+ & more information about a particular\\ & architechture\\ \verb+ setenv NWCHEM_TARGET_CPU P2SC+\\ \\ \verb+SCRATCH_DEF_DIR+ & default scratch directory for\\ & temporary files, e.g.\\ \verb+ setenv SCRATCH_DEF_DIR "\'/scratch\'"+\\ \\ \verb+PERMANENT_DEF_DIR+ & default permanent directory for\\ & files to keep, e.g.\\ \verb+ setenv PERMANENT_DEF_DIR "\'/home/user\'"+\\ \\ \verb+NWCHEM_BASIS_LIBRARY_PATH+ & location of the basis set libraries \\ & (the builder is responsible to make \\ & sure that the library gets to the \\ & place), e.g.\\ \verb+ setenv NWCHEM_BASIS_LIBRARY_PATH "/bin/libraries/"+\\ \\ \verb+LARGE_FILES+ & needed to circumvent the 2 GB limit\\ & on IBM (note that your system \\ & administrator must also enable \\ & large files in the file system), e.g.\\ \verb+ setenv LARGE_FILES TRUE+\\ \\ \verb+JOBTIME_PATH+ & directory where jobtime and jobtime.pl\\ & will be placed by the builder on \\ & IBM SP, e.g.\\ \verb+ setenv JOBTIME_PATH /u/nwchem/bin+\\ \\ \verb+LIB_DEFINES+ & additional defines for the C \\ & preprocessor (for both Fortran \\ & and C), e.g.\\ \verb+ setenv LIB_DEFINES -DDFLT_TOT_MEM=16777216+\\ This sets the dynamic memory available for \\ NWChem to run, where the units are in doubles.\\ Check out the Section for MEMORY SCRIPT below.\\ \\ \verb+TCGRSH+ & alternate path for rsh, it is intended \\ & to allow usage of ssh in TCGMSG \\ & (default communication protocol \\ & for workstation builds).\\ \verb+ setenv TCGRSH /usr/local/bin/ssh+\\ \\ IMPORTANT: ssh should not ask for a password. \\ In order to do that:\\ 1) On the master node, run "ssh-keygen"\\ 2) For each slave node, \verb+slave_node+,\\ \verb+ scp ~/.ssh/identity.pub \+ \\ \verb+ username@slave_node:.ssh/authorized_keys+ \end{tabular} \end{center} \end{table}
#### 13-2 #### ## -------------------------------------------------------------------- ## mpg <- as.data.frame(ggplot2::mpg) library(dplyr) mpg_diff <- mpg %>% select(class, cty) %>% filter(class %in% c("compact", "suv")) head(mpg_diff) table(mpg_diff$class) t.test(data = mpg_diff, cty ~ class, var.equal = T) ## -------------------------------------------------------------------- ## mpg_diff2 <- mpg %>% select(fl, cty) %>% filter(fl %in% c("r", "p")) # r:regular, p:premium table(mpg_diff2$fl) t.test(data = mpg_diff2, cty ~ fl, var.equal = T) #### 13-3 #### ## -------------------------------------------------------------------- ## economics <- as.data.frame(ggplot2::economics) cor.test(economics$unemploy, economics$pce) ## -------------------------------------------------------------------- ## head(mtcars) car_cor <- cor(mtcars) # 상관행렬 생성 round(car_cor, 2) # 소수점 셋째 자리에서 반올림해서 출력 install.packages("corrplot") library(corrplot) corrplot(car_cor) corrplot(car_cor, method = "number") col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA")) corrplot(car_cor, method = "color", # 색깔로 표현 col = col(200), # 색상 200개 선정 type = "lower", # 왼쪽 아래 행렬만 표시 order = "hclust", # 유사한 상관계수끼리 군집화 addCoef.col = "black", # 상관계수 색깔 tl.col = "black", # 변수명 색깔 tl.srt = 45, # 변수명 45도 기울임 diag = F) # 대각 행렬 제외
[STATEMENT] lemma InfCard_le_cadd_eq: "\<lbrakk>InfCard \<kappa>; \<mu> \<le> \<kappa>\<rbrakk> \<Longrightarrow> \<kappa> \<oplus> \<mu> = \<kappa>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>InfCard \<kappa>; \<mu> \<le> \<kappa>\<rbrakk> \<Longrightarrow> \<kappa> \<oplus> \<mu> = \<kappa> [PROOF STEP] by (metis InfCard_cdouble_eq InfCard_def antisym cadd_le_mono cadd_le_self)
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Callum Sutton, Yury Kudryashov ! This file was ported from Lean 3 source module algebra.hom.equiv.units.group_with_zero ! leanprover-community/mathlib commit 655994e298904d7e5bbd1e18c95defd7b543eb94 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Algebra.Hom.Equiv.Units.Basic import Mathlib.Algebra.GroupWithZero.Units.Basic /-! # Multiplication by a nonzero element in a `GroupWithZero` is a permutation. -/ variable {G : Type _} namespace Equiv section GroupWithZero variable [GroupWithZero G] /-- Left multiplication by a nonzero element in a `GroupWithZero` is a permutation of the underlying type. -/ @[simps! (config := { fullyApplied := false })] protected def mulLeft₀ (a : G) (ha : a ≠ 0) : Perm G := (Units.mk0 a ha).mulLeft #align equiv.mul_left₀ Equiv.mulLeft₀ #align equiv.mul_left₀_symm_apply Equiv.mulLeft₀_symm_apply #align equiv.mul_left₀_apply Equiv.mulLeft₀_apply theorem mulLeft_bijective₀ (a : G) (ha : a ≠ 0) : Function.Bijective ((· * ·) a : G → G) := (Equiv.mulLeft₀ a ha).bijective #align mul_left_bijective₀ Equiv.mulLeft_bijective₀ /-- Right multiplication by a nonzero element in a `GroupWithZero` is a permutation of the underlying type. -/ @[simps! (config := { fullyApplied := false })] protected def mulRight₀ (a : G) (ha : a ≠ 0) : Perm G := (Units.mk0 a ha).mulRight #align equiv.mul_right₀ Equiv.mulRight₀ #align equiv.mul_right₀_symm_apply Equiv.mulRight₀_symm_apply #align equiv.mul_right₀_apply Equiv.mulRight₀_apply theorem mulRight_bijective₀ (a : G) (ha : a ≠ 0) : Function.Bijective ((· * a) : G → G) := (Equiv.mulRight₀ a ha).bijective #align mul_right_bijective₀ Equiv.mulRight_bijective₀ end GroupWithZero end Equiv
/* * Copyright (c) 1997-1999 Massachusetts Institute of Technology * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* fftw.h -- system-wide definitions */ /* $Id: fftw-int.h,v 1.39 1999/02/19 17:22:00 athena Exp $ */ #ifndef FFTW_INT_H #define FFTW_INT_H #include <config.h> #include <fftw.h> #ifdef __cplusplus extern "C" { #else #endif /* __cplusplus */ /****************************************************************************/ /* Private Functions */ /****************************************************************************/ extern fftw_twiddle *fftw_create_twiddle(int n, const fftw_codelet_desc *d); extern void fftw_destroy_twiddle(fftw_twiddle *tw); extern void fftw_strided_copy(int, fftw_complex *, int, fftw_complex *); extern void fftw_executor_simple(int, const fftw_complex *, fftw_complex *, fftw_plan_node *, int, int); extern fftwnd_plan fftwnd_create_plan_aux(int rank, const int *n, fftw_direction dir, int flags); extern fftw_plan *fftwnd_new_plan_array(int rank); extern fftw_plan *fftwnd_create_plans_generic(fftw_plan *plans, int rank, const int *n, fftw_direction dir, int flags); extern fftw_plan *fftwnd_create_plans_specific(fftw_plan *plans, int rank, const int *n, const int *n_after, fftw_direction dir, int flags, fftw_complex *in, int istride, fftw_complex *out, int ostride); extern int fftwnd_work_size(int rank, const int *n, int flags, int ncopies); extern void fftwnd_aux(fftwnd_plan p, int cur_dim, fftw_complex *in, int istride, fftw_complex *out, int ostride, fftw_complex *work); extern void fftwnd_aux_howmany(fftwnd_plan p, int cur_dim, int howmany, fftw_complex *in, int istride, int idist, fftw_complex *out, int ostride, int odist, fftw_complex *work); /* wisdom prototypes */ enum fftw_wisdom_category { FFTW_WISDOM, RFFTW_WISDOM }; extern int fftw_wisdom_lookup(int n, int flags, fftw_direction dir, enum fftw_wisdom_category category, int istride, int ostride, enum fftw_node_type *type, int *signature, int replace_p); extern void fftw_wisdom_add(int n, int flags, fftw_direction dir, enum fftw_wisdom_category cat, int istride, int ostride, enum fftw_node_type type, int signature); /* Private planner functions: */ extern double fftw_estimate_node(fftw_plan_node *p); extern fftw_plan_node *fftw_make_node_notw(int size, const fftw_codelet_desc *config); extern fftw_plan_node *fftw_make_node_real2hc(int size, const fftw_codelet_desc *config); extern fftw_plan_node *fftw_make_node_hc2real(int size, const fftw_codelet_desc *config); extern fftw_plan_node *fftw_make_node_twiddle(int n, const fftw_codelet_desc *config, fftw_plan_node *recurse, int flags); extern fftw_plan_node *fftw_make_node_hc2hc(int n, fftw_direction dir, const fftw_codelet_desc *config, fftw_plan_node *recurse, int flags); extern fftw_plan_node *fftw_make_node_generic(int n, int size, fftw_generic_codelet *codelet, fftw_plan_node *recurse, int flags); extern fftw_plan_node *fftw_make_node_rgeneric(int n, int size, fftw_direction dir, fftw_rgeneric_codelet * codelet, fftw_plan_node *recurse, int flags); extern int fftw_factor(int n); extern fftw_plan_node *fftw_make_node(void); extern fftw_plan fftw_make_plan(int n, fftw_direction dir, fftw_plan_node *root, int flags, enum fftw_node_type wisdom_type, int wisdom_signature); extern void fftw_use_plan(fftw_plan p); extern void fftw_use_node(fftw_plan_node *p); extern void fftw_destroy_plan_internal(fftw_plan p); extern fftw_plan fftw_pick_better(fftw_plan p1, fftw_plan p2); extern fftw_plan fftw_lookup(fftw_plan *table, int n, int flags); extern void fftw_insert(fftw_plan *table, fftw_plan this_plan, int n); extern void fftw_make_empty_table(fftw_plan *table); extern void fftw_destroy_table(fftw_plan *table); extern void fftw_complete_twiddle(fftw_plan_node *p, int n); extern fftw_plan_node *fftw_make_node_rader(int n, int size, fftw_direction dir, fftw_plan_node *recurse, int flags); extern fftw_rader_data *fftw_rader_top; /****************************************************************************/ /* Floating Point Types */ /****************************************************************************/ /* * We use these definitions to make it easier for people to change * FFTW to use long double and similar types. You shouldn't have to * change this just to use float or double. */ /* * Change this if your floating-point constants need to be expressed * in a special way. For example, if fftw_real is long double, you * will need to append L to your fp constants to make them of the * same precision. Do this by changing "x" below to "x##L". */ #define FFTW_KONST(x) ((fftw_real) x) #define FFTW_TRIG_SIN sin #define FFTW_TRIG_COS cos typedef double FFTW_TRIG_REAL; /* the argument type for sin and cos */ #define FFTW_K2PI FFTW_KONST(6.2831853071795864769252867665590057683943388) /****************************************************************************/ /* gcc/x86 hacks */ /****************************************************************************/ /* * gcc 2.[78].x and x86 specific hacks. These macros align the stack * pointer so that the double precision temporary variables in the * codelets will be aligned to a multiple of 8 bytes (*way* faster on * pentium and pentiumpro) */ #ifdef __GNUC__ #ifdef __i386__ #ifdef FFTW_ENABLE_I386_HACKS #ifndef FFTW_ENABLE_FLOAT #define FFTW_USING_I386_HACKS #define HACK_ALIGN_STACK_EVEN() { \ if ((((long) (__builtin_alloca(0))) & 0x7)) __builtin_alloca(4); \ } #define HACK_ALIGN_STACK_ODD() { \ if (!(((long) (__builtin_alloca(0))) & 0x7)) __builtin_alloca(4); \ } #ifdef FFTW_DEBUG_ALIGNMENT #define ASSERT_ALIGNED_DOUBLE() { \ double __foo; \ if ((((long) &__foo) & 0x7)) abort(); \ } #endif #endif #endif #endif #endif #ifndef HACK_ALIGN_STACK_EVEN #define HACK_ALIGN_STACK_EVEN() #endif #ifndef HACK_ALIGN_STACK_ODD #define HACK_ALIGN_STACK_ODD() #endif #ifndef ASSERT_ALIGNED_DOUBLE #define ASSERT_ALIGNED_DOUBLE() #endif /****************************************************************************/ /* Timers */ /****************************************************************************/ /* * Here, you can use all the nice timers available in your machine. */ /* * Things you should define to include your own clock: fftw_time -- the data type used to store a time extern fftw_time fftw_get_time(void); -- a function returning the current time. (We have implemented this as a macro in most cases.) extern fftw_time fftw_time_diff(fftw_time t1, fftw_time t2); -- returns the time difference (t1 - t2). If t1 < t2, it may simply return zero (although this is not required). (We have implemented this as a macro in most cases.) extern double fftw_time_to_sec(fftw_time t); -- returns the time t expressed in seconds, as a double. (Implemented as a macro in most cases.) FFTW_TIME_MIN -- a double-precision macro holding the minimum time interval (in seconds) for accurate time measurements. This should probably be at least 100 times the precision of your clock (we use even longer intervals, to be conservative). This will determine how long the planner takes to measure the speeds of different possible plans. Bracket all of your definitions with an appropriate #ifdef so that they will be enabled on your machine. If you do add your own high-precision timer code, let us know (at [email protected]). Only declarations should go in this file. Any function definitions that you need should go into timer.c. */ /* * define a symbol so that we know that we have the fftw_time_diff * function/macro (it did not exist prior to FFTW 1.2) */ #define FFTW_HAS_TIME_DIFF /********************************************** * SOLARIS **********************************************/ #if defined(HAVE_GETHRTIME) /* we use the nanosecond virtual timer */ #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif typedef hrtime_t fftw_time; #define fftw_get_time() gethrtime() #define fftw_time_diff(t1,t2) ((t1) - (t2)) #define fftw_time_to_sec(t) ((double) t / 1.0e9) /* * a measurement is valid if it runs for at least * FFTW_TIME_MIN seconds. */ #define FFTW_TIME_MIN (1.0e-4) /* for Solaris nanosecond timer */ #define FFTW_TIME_REPEAT 8 /********************************************** * Pentium time stamp counter **********************************************/ #elif defined(__GNUC__) && defined(__i386__) && defined(FFTW_ENABLE_PENTIUM_TIMER) /* * Use internal Pentium register (time stamp counter). Resolution * is 1/FFTW_CYCLES_PER_SEC seconds (e.g. 5 ns for Pentium 200 MHz). * (This code was contributed by Wolfgang Reimer) */ #ifndef FFTW_CYCLES_PER_SEC #error "Must define FFTW_CYCLES_PER_SEC in fftw/config.h to use the Pentium cycle counter" #endif typedef unsigned long long fftw_time; static __inline__ fftw_time read_tsc() { struct { long unsigned lo, hi; } counter; long unsigned sav_eax, sav_edx; __asm__("movl %%eax,%0":"=m"(sav_eax)); __asm__("movl %%edx,%0":"=m"(sav_edx)); __asm__("rdtsc"); __asm__("movl %%eax,%0":"=m"(counter.lo)); __asm__("movl %%edx,%0":"=m"(counter.hi)); __asm__("movl %0,%%eax": : "m"(sav_eax):"eax"); __asm__("movl %0,%%edx": : "m"(sav_edx):"edx"); return *(fftw_time *) & counter; } #define fftw_get_time() read_tsc() #define fftw_time_diff(t1,t2) ((t1) - (t2)) #define fftw_time_to_sec(t) (((double) (t)) / FFTW_CYCLES_PER_SEC) #define FFTW_TIME_MIN (1.0e-4) /* for Pentium TSC register */ /************* generic systems having gettimeofday ************/ #elif defined(HAVE_GETTIMEOFDAY) || defined(HAVE_BSDGETTIMEOFDAY) #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #define FFTW_USE_GETTIMEOFDAY typedef struct timeval fftw_time; extern fftw_time fftw_gettimeofday_get_time(void); extern fftw_time fftw_gettimeofday_time_diff(fftw_time t1, fftw_time t2); #define fftw_get_time() fftw_gettimeofday_get_time() #define fftw_time_diff(t1, t2) fftw_gettimeofday_time_diff(t1, t2) #define fftw_time_to_sec(t) ((double)(t).tv_sec + (double)(t).tv_usec * 1.0E-6) #ifndef FFTW_TIME_MIN /* this should be fine on any system claiming a microsecond timer */ #define FFTW_TIME_MIN (1.0e-2) #endif /********************************************** * MACINTOSH **********************************************/ #elif defined(HAVE_MAC_TIMER) /* * By default, use the microsecond-timer in the Mac Time Manager. * Alternatively, by changing the following #if 1 to #if 0, you * can use the nanosecond timer available *only* on PCI PowerMacs. */ #ifndef HAVE_MAC_PCI_TIMER /* use time manager */ /* * Use Macintosh Time Manager routines (maximum resolution is about 20 * microseconds). */ typedef struct fftw_time_struct { unsigned long hi, lo; } fftw_time; extern fftw_time get_Mac_microseconds(void); #define fftw_get_time() get_Mac_microseconds() /* define as a function instead of a macro: */ extern fftw_time fftw_time_diff(fftw_time t1, fftw_time t2); #define fftw_time_to_sec(t) ((t).lo * 1.0e-6 + 4294967295.0e-6 * (t).hi) /* very conservative, since timer should be accurate to 20e-6: */ /* (although this seems not to be the case in practice) */ #define FFTW_TIME_MIN (5.0e-2) /* for MacOS Time Manager timer */ #else /* use nanosecond timer */ /* Use the nanosecond timer available on PCI PowerMacs. */ #include <DriverServices.h> typedef AbsoluteTime fftw_time; #define fftw_get_time() UpTime() #define fftw_time_diff(t1,t2) SubAbsoluteFromAbsolute(t1,t2) #define fftw_time_to_sec(t) (AbsoluteToNanoseconds(t).lo * 1.0e-9) /* Extremely conservative minimum time: */ /* for MacOS PCI PowerMac nanosecond timer */ #define FFTW_TIME_MIN (5.0e-3) #endif /* use nanosecond timer */ /********************************************** * WINDOWS **********************************************/ #elif defined(HAVE_WIN32_TIMER) #include <time.h> typedef unsigned long fftw_time; extern unsigned long GetPerfTime(void); extern double GetPerfSec(double ticks); #define fftw_get_time() GetPerfTime() #define fftw_time_diff(t1,t2) ((t1) - (t2)) #define fftw_time_to_sec(t) GetPerfSec(t) #define FFTW_TIME_MIN (5.0e-2) /* for Win32 timer */ /********************************************** * CRAY **********************************************/ #elif defined(_CRAYMPP) /* Cray MPP system */ double SECONDR(void); /* * I think you have to link with -lsci to * get this */ typedef double fftw_time; #define fftw_get_time() SECONDR() #define fftw_time_diff(t1,t2) ((t1) - (t2)) #define fftw_time_to_sec(t) (t) #define FFTW_TIME_MIN (1.0e-1) /* for Cray MPP SECONDR timer */ /********************************************** * VANILLA UNIX/ISO C SYSTEMS **********************************************/ /* last resort: use good old Unix clock() */ #else #include <time.h> typedef clock_t fftw_time; #ifndef CLOCKS_PER_SEC #ifdef sun /* stupid sunos4 prototypes */ #define CLOCKS_PER_SEC 1000000 extern long clock(void); #else /* not sun, we don't know CLOCKS_PER_SEC */ #error Please define CLOCKS_PER_SEC #endif #endif #define fftw_get_time() clock() #define fftw_time_diff(t1,t2) ((t1) - (t2)) #define fftw_time_to_sec(t) (((double) (t)) / CLOCKS_PER_SEC) /* * ***VERY*** conservative constant: this says that a * measurement must run for 200ms in order to be valid. * You had better check the manual of your machine * to discover if it can do better than this */ #define FFTW_TIME_MIN (2.0e-1) /* for default clock() timer */ #endif /* UNIX clock() */ /* take FFTW_TIME_REPEAT measurements... */ #ifndef FFTW_TIME_REPEAT #define FFTW_TIME_REPEAT 4 #endif /* but do not run for more than TIME_LIMIT seconds while measuring one FFT */ #ifndef FFTW_TIME_LIMIT #define FFTW_TIME_LIMIT 2.0 #endif #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* FFTW_INT_H */
{- A 42 -} module Main data V a = A a instance Show a => Show (V a) where show (A a) = "A " ++ show a main : IO () main = printLn $ A 42
*.............................................................. !------------------------------------------------------------------------- ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS ! !------------------------------------------------------------------------- !BOP ! ! !ROUTINE: ODS_Cal2Min() --- Convert "calendar" date and time to minutes since a given reference ! ! !DESCRIPTION: ! \label{ODS:Cal2Min} ! The routine converts date and time in calendar format to ! minutes since a given reference date and time (also in ! calendar format). The format for the calendar date and ! time is year 2000 compliant. ! ! Note: For a list of error codes, see Table~\ref{tab:errors}. ! ! !INTERFACE: ! subroutine ODS_Cal2Min ( NVal, . CalDate, CalTime, . RefDate, RefTime, Minutes ) ! ! ! !INPUT PARAMETERS: implicit NONE integer NVal ! number of values to be ! converted integer CalDate ( NVal ) ! Calendar date in the format ! YYYYMMDD where YYYY is the ! year, MM is the month and ! DD is the day. A negative ! number implies that the ! year is B.C. integer CalTime ( NVal ) ! Time in the format HHMMSS ! where HH is the hour, MM ! is the minute and SS is ! the second. ! ! !OUTPUT PARAMETERS: integer RefDate ! Reference date in the format ! YYYYMMDD where YYYY is the ! year, MM is the month and ! DD is the day. A negative ! number implies that the ! year is B.C. integer RefTime ! Reference time in the format ! HHMMSS where HH is the hour, ! MM is the minute and SS is ! the second. integer Minutes ( NVal ) ! Minutes since given reference ! date and time ! ! !SEE ALSO: ! ODS_Min2Cal() - Convert minutes since a given reference to ! "calendar" date and time ! ODS_Time2Cal() - converts ODS "time" attribute to "calendar" ! date and time ! ODS_Cal2Time() - converts "calendar" date and time to ODS ! time attribute ! ODS_Julian() - calculates the Julian day from date and ! time in "calendar" format ! ODS_CalDat() - calculates the "calendar" date and time ! from the Julian day ! ! !REVISION HISTORY: ! 10May2000 C. Redder Original code. ! !EOP !------------------------------------------------------------------------- * Function referenced * ------------------- integer ODS_Julian * Other variables * --------------- integer Time integer Hour, RHour integer Minute, RMinute integer RMinutes integer Second, RSecond integer RJDay, days_offset integer iVal integer MinDay parameter ( MinDay = 60 * 24 ) * Find the reference Julian minutes since reference Julian day * ------------------------------------------------------------ RJDay = ODS_Julian ( RefDate ) RHour = RefTime / 10000 RMinute = mod ( RefTime, 10000 ) / 100 RSecond = mod ( RefTime, 100 ) RMinutes = 60 * RHour + RMinute if ( RSecond .ge. 30 ) RMinutes = RMinutes + 1 * For each value ... * ------------------ do iVal = 1, NVal * Determine the hour, minute and second of the day * ------------------------------------------------ Time = CalTime ( iVal ) Hour = Time / 10000 Minute = mod ( Time, 10000 ) / 100 Second = mod ( Time, 100 ) if ( Second .ge. 30 ) Minute = Minute + 1 * Determine the number of days from first_jday * -------------------------------------------- days_offset . = ODS_Julian ( CalDate ( iVal ) ) - RJDay * Determine the time in ODS foramt * -------------------------------- Minutes ( iVal ) . = days_offset * MinDay . + Hour * 60 . + Minute . - RMinutes end do return end
import pseudo_normed_group.category.strictCompHausFiltPseuNormGrp universe variables u open category_theory open_locale nnreal noncomputable theory local attribute [instance] type_pow /-- The category of profinitely filtered pseudo-normed groups. -/ def ProFiltPseuNormGrp : Type (u+1) := bundled profinitely_filtered_pseudo_normed_group namespace ProFiltPseuNormGrp local attribute [instance] CompHausFiltPseuNormGrp.bundled_hom def bundled_hom : bundled_hom.parent_projection @profinitely_filtered_pseudo_normed_group.to_comphaus_filtered_pseudo_normed_group := ⟨⟩ local attribute [instance] bundled_hom attribute [derive [large_category, concrete_category]] ProFiltPseuNormGrp instance : has_coe_to_sort ProFiltPseuNormGrp Type* := bundled.has_coe_to_sort instance : has_forget₂ ProFiltPseuNormGrp CompHausFiltPseuNormGrp := bundled_hom.forget₂ _ _ @[simps] def to_CompHausFilt : ProFiltPseuNormGrp ⥤ CompHausFiltPseuNormGrp := forget₂ _ _ /-- Construct a bundled `ProFiltPseuNormGrp` from the underlying type and typeclass. -/ def of (M : Type u) [profinitely_filtered_pseudo_normed_group M] : ProFiltPseuNormGrp := bundled.of M instance : has_zero ProFiltPseuNormGrp := ⟨of punit⟩ instance : inhabited ProFiltPseuNormGrp := ⟨0⟩ instance (M : ProFiltPseuNormGrp) : profinitely_filtered_pseudo_normed_group M := M.str @[simp] lemma coe_of (V : Type u) [profinitely_filtered_pseudo_normed_group V] : (ProFiltPseuNormGrp.of V : Type u) = V := rfl @[simp] lemma coe_id (V : ProFiltPseuNormGrp) : ⇑(𝟙 V) = id := rfl @[simp] lemma coe_comp {A B C : ProFiltPseuNormGrp} (f : A ⟶ B) (g : B ⟶ C) : ⇑(f ≫ g) = g ∘ f := rfl @[simp] lemma coe_comp_apply {A B C : ProFiltPseuNormGrp} (f : A ⟶ B) (g : B ⟶ C) (x : A) : (f ≫ g) x = g (f x) := rfl open pseudo_normed_group section variables (M : Type*) [profinitely_filtered_pseudo_normed_group M] (c : ℝ≥0) instance : t2_space (Top.of (filtration M c)) := by { dsimp, apply_instance } instance : totally_disconnected_space (Top.of (filtration M c)) := by { dsimp, apply_instance } instance : compact_space (Top.of (filtration M c)) := by { dsimp, apply_instance } end end ProFiltPseuNormGrp
import JuLIP: read_dict, write_dict export @D, @DD, @GRAD, @pot using JuLIP: AtomicNumber # =========================================================================== # implement some fun little macros for easier access # to the potentials # =========================================================================== # REMARK on @pot: # --------------- # Julia 0.4 version: # call(pp::Potential, varargs...) = evaluate(pp, varargs...) # call(pp::Potential, ::Type{Val{:D}}, varargs...) = evaluate_d(pp, varargs...) # call(pp::Potential, ::Type{Val{:DD}}, varargs...) = evaluate_dd(pp, varargs...) # call(pp::Potential, ::Type{Val{:GRAD}}, varargs...) = grad(pp, varargs...) # unfortunately, in 0.5 `call` doesn't take anabstractargument anymore, # which means that we need to specify for every potential how to # create this syntactic sugar. This is what `@pot` is for. """ Annotate a type with `@pot` to setup the syntax sugar for `evaluate, evaluate_d, evaluate_dd, grad`. ## Usage: For example, the declaration ```julia "documentation for `LennardJones`" mutable struct LennardJones <: PairPotential r0::Float64 end @pot LennardJones ``` creates the following aliases: ```julia lj = LennardJones(1.0) lj(args...) = evaluate(lj, args...) @D lj(args...) = evaluate_d(lj, args...) @DD lj(args...) = evaluate_dd(lj, args...) @GRAD lj(args...) = grad(lj, args...) ``` Usage of `@pot` is not restricted to pair potentials, but can be applied to *any* type. """ macro pot(fsig) @assert fsig isa Symbol sym = esc(:x) tsym = esc(fsig) quote @inline ($sym::$tsym)(args...) = evaluate($sym, args...) @inline ($sym::$tsym)(::Type{Val{:D}}, args...) = evaluate_d($sym, args...) @inline ($sym::$tsym)(::Type{Val{:DD}}, args...) = evaluate_dd($sym, args...) @inline ($sym::$tsym)(::Type{Val{:GRAD}}, args...) = grad($sym, args...) end end # -------------------------------------------------------------------------- # next create macros that translate """ `@D`: Use to evaluate the derivative of a potential. E.g., to compute the Lennard-Jones potential, ```julia lj = LennardJones() r = 1.0 + rand(10) ϕ = lj(r) ϕ' = @D lj(r) ``` see also `@DD`. """ macro D(fsig::Expr) @assert fsig.head == :call insert!(fsig.args, 2, Val{:D}) for n = 1:length(fsig.args) fsig.args[n] = esc(fsig.args[n]) end return fsig end "`@DD` : analogous to `@D`" macro DD(fsig::Expr) @assert fsig.head == :call for n = 1:length(fsig.args) fsig.args[n] = esc(fsig.args[n]) end insert!(fsig.args, 2, Val{:DD}) return fsig end "`@GRAD` : analogous to `@D`, but escapes to `grad`" macro GRAD(fsig::Expr) @assert fsig.head == :call for n = 1:length(fsig.args) fsig.args[n] = esc(fsig.args[n]) end insert!(fsig.args, 2, Val{:GRAD}) return fsig end # ---------------------------------------------------------------------- # Managing a list of species # ---------------------------------------------------------------------- abstract type AbstractZList end """ `ZList` and `SZList{NZ}` : simple data structures that store a list of species and convert between atomic numbers and the index in the list. Can be constructed via * `ZList(zors)` : where `zors` is an Integer or `Symbol` (single species) * `ZList(zs1, zs2, ..., zsn)` * `ZList([sz1, zs2, ..., zsn])` * All of these take a kwarg `static = {true, false}`; if `true`, then `ZList` will return a `SZList{NZ}` for (possibly) faster access. """ struct ZList <: AbstractZList list::Vector{AtomicNumber} end Base.length(zlist::AbstractZList) = length(zlist.list) struct SZList{N} <: AbstractZList list::SVector{N, AtomicNumber} end function ZList(zlist::AbstractVector{<: Number}; static = false, sorted=true) sortfun = sorted ? sort : identity return (static ? SZList(SVector( (AtomicNumber.(sortfun(zlist)))... )) : ZList( convert(Vector{AtomicNumber}, sortfun(zlist)) )) end ZList(s::Symbol; kwargs...) = ZList( [ atomic_number(s) ]; kwargs... ) ZList(S::AbstractVector{Symbol}; kwargs...) = ZList( atomic_number.(S); kwargs... ) ZList(args...; kwargs... ) = ZList( [args...]; kwargs...) i2z(Zs::AbstractZList, i::Integer) = Zs.list[i] function z2i(Zs::AbstractZList, z::AtomicNumber) if Zs.list[1] == JuLIP.Chemistry.__zAny__ return 1 end for j = 1:length(Zs.list) if Zs.list[j] == z return j end end error("z = $z not found in ZList $(Zs.list)") end zlist(V) = V.zlist i2z(V, i::Integer) = i2z(zlist(V), i) z2i(V, z::AtomicNumber ) = z2i(zlist(V), z) numz(V) = length(zlist(V)) write_dict(zlist::ZList) = Dict("__id__" => "JuLIP_ZList", "list" => Int.(zlist.list)) read_dict(::Val{:JuLIP_ZList}, D::Dict) = ZList(D) ZList(D::Dict) = ZList(D["list"]) write_dict(zlist::SZList) = Dict("__id__" => "JuLIP_SZList", "list" => Int.(zlist.list)) read_dict(::Val{:JuLIP_SZList}, D::Dict) = SZList(D) SZList(D::Dict) = ZList([D["list"]...], static = true)
/* * Copyright 2020 Makani Technologies LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SIM_PHYSICS_DELTA_COEFF_AERO_DATABASE_H_ #define SIM_PHYSICS_DELTA_COEFF_AERO_DATABASE_H_ #include <gsl/gsl_matrix.h> #include <gsl/gsl_vector.h> #include <stdint.h> #include <string> #include "common/c_math/linalg.h" #include "common/c_math/vec3.h" #include "common/macros.h" #include "sim/sim_params.h" #include "sim/sim_types.h" #include "system/labels.h" class DeltaCoeffAeroDatabase { friend class AeroTest; public: explicit DeltaCoeffAeroDatabase(const std::string &filename); ~DeltaCoeffAeroDatabase(); // Returns the nominal force-moment coefficient after adjusting for // delta coefficients. void AdjustForceMomentCoeff(double alpha, const Vec &flaps, ForceMoment *force_moment_coeff) const; private: // Returns true if the database passes basic sign checks. bool IsValid() const; bool applicable_flaps_[kNumFlaps]; double reynolds_number_; gsl_vector *alphads_, *deltads_; gsl_matrix *CX_[kNumFlaps]; gsl_matrix *CY_[kNumFlaps]; gsl_matrix *CZ_[kNumFlaps]; gsl_matrix *CL_[kNumFlaps]; gsl_matrix *CM_[kNumFlaps]; gsl_matrix *CN_[kNumFlaps]; DISALLOW_COPY_AND_ASSIGN(DeltaCoeffAeroDatabase); }; #endif // SIM_PHYSICS_DELTA_COEFF_AERO_DATABASE_H_
# Base - Reinforcement - author: Marcelo de Gomensoro Malheiros - revision: 2020-09 - license: MIT (attribution is not required but greatly appreciated) ## Reinforcement model - diffusion rate is based on the scale $s$ - depends on parameters threshold $t$ and width $w$ \begin{align} \frac{\partial{c}}{\partial{t}} &= \gamma (t - w - c) (t - c) (t + w - c) + s \nabla^2 c \\ \gamma &= \frac{3 \sqrt{3}}{2 w^2} \end{align} ```python from scipy import ndimage def reinforcement_model(mc, kc, lc, dc, dt, t, w, g, wrap): if wrap: ndimage.convolve(mc, kc, output=lc, mode='wrap') else: ndimage.convolve(mc, kc, output=lc, mode='reflect') global c c = mc + ((t - w - mc) * (t - mc) * (t + w - mc) * g + dc * lc) * dt ``` ## Simulation Parameter list, with default values shown: - `threshold=1` - threshold parameter - `width=1` - width parameter - `scale=1` - overall scale of the pattern - `speed=100` - percent of default time step - `start=0` - start iteration counter - `stop=1000` - final iteration counter - `time=None` - simulation time (in milliseconds), used instead of `stop` and taking into account `speed` - `use_c=False` - use previous values for C? - `wrap=True` - use toroidal domain if true, non-flux boundary otherwise - `seed=1` - random seed - `ini_c=0` - initial constant values for C - `var_c=2` - added randomness magnitude for C - `shape=40` - domain dimension (single integer for square, or tuple) - `axis=False` - show domain size? - `cmap='inferno'` - Matplotlib colormap used - `first=False` - show initial state? - `info=False` - monitor concentration intervals (each 100 iterations, may be changed) - `limit=None` - plot images with given dimension - `show='c'` - reagents to show (can be the empty string) - `size=2` - image output size - `snap=4` - how many captures are shown (can also be a list of iteration counts) - `detail=None` - show 1-D plot at given domain row (A in orange and B in blue) - `extent=(-0.2, 2.2)` - upper and lower values for 1-D plot - `func=None` - auxiliary function - `out=None` - output file name (PDF/PNG/JPG/...) - `dpi=100` - resolution for output - `interpolation='bilinear'` - used when converting a matrix to an image - `detect=False` - detect constant-valued and stable pattern states, besides numerical problems (each 100 iterations, may be changed) - `model=reinforcement_model` - model function used Global variables set after the simulation is run: - `c` - final concentrations for C - `sim` - information about the simulation (can be used as an object or a dict) ```python %matplotlib inline import matplotlib.pyplot as plt import numpy as np # reinforcement: cubic autocatalytic reinforcement model - v6.3 kernel_c = np.array([[1, 4, 1], [4, -20, 4], [1, 4, 1]]) / 6 class Bunch(dict): def __init__(self, dictionary): dict.__init__(self, dictionary) self.__dict__.update(dictionary) def reinforcement(threshold=1, width=1, scale=1, speed=100, start=0, stop=1000, time=None, use_c=False, wrap=True, seed=1, ini_c=0, var_c=2, shape=40, axis=False, cmap='inferno', first=False, info=False, limit=None, show='c', size=2, snap=4, detail=None, extent=(-0.2, 2.2), func=None, out=None, dpi=100, interpolation='bilinear', detect=False, model=reinforcement_model): # simulation init diff_c = scale delta_t = 0.01 * speed / 100 if time: stop = int(time * 100 / speed) + start global sim, c np.random.seed(seed) if type(shape) == int: shape = (shape, shape) if not use_c: c = np.full(shape, ini_c, dtype=float) if var_c != 0: c += np.random.random_sample(shape) * var_c lap_c = np.empty_like(c) is_nan = is_stable = is_uniform = last_c = False if info: high_c = - float('inf') low_c = float('inf') if info is True: info = 100 if detect is True: detect = 100 # plotting helper functions def draw(matrix, row): if axis: axes[row, col].axis('on') axes[row, col].imshow(matrix, cmap=cmap, interpolation=interpolation) axes[row, col].set_anchor('N') if limit: axes[row, col].set_xbound(0, limit[1] - 1) axes[row, col].set_ybound(0, limit[0] - 1) def plot(): axes[0, col].set_title(iteration) row = 0 if detail: if 'c' in show: t = c.copy() t[detail - 1,:] = t[detail + 1,:] = c.min() draw(t, row); row += 1 else: if 'c' in show: draw(c, row); row += 1 if detail: axes[row, col].axis('on') axes[row, col].get_xaxis().set_visible(False) axes[row, col].grid() axes[row, col].plot((threshold - width,) * shape[1], color='orange', linestyle='--') axes[row, col].plot((threshold, ) * shape[1], color='orange', linestyle='--') axes[row, col].plot((threshold + width,) * shape[1], color='orange', linestyle='--') axes[row, col].plot(c[detail], color='blue') axes[row, col].set_anchor('N') axes[row, col].set_ybound(extent[0], extent[1]) # plotting init axes = ax = ay = col = fig = rows = 0 if 'c' in show: rows += 1 if detail: rows += 1 if type(snap) == int: if snap > 100: print("too many captures, check 'snap' parameter"); return if first: snap = np.linspace(start, stop, snap, dtype=int) else: snap = np.linspace(start, stop, snap + 1, dtype=int)[1:] cols = len(snap) if show: fig, axes = plt.subplots(rows, cols, squeeze=False, figsize=(cols * size, rows * size)) for ay in axes: for ax in ay: ax.axis('off') if first and show: iteration = start plot() col += 1 if type(limit) == int: limit = (limit, limit) # simulation loop gamma = 3 * np.sqrt(3) / (2 * width * width) for iteration in range(start + 1, stop + 1): if func: func(iteration, seed) if detect and iteration % detect == 0: last_c = c.copy() if c.shape != shape: shape = c.shape lap_c = np.empty_like(c) model(c, kernel_c, lap_c, diff_c, delta_t, threshold, width, gamma, wrap) if info and iteration % info == 0: high_c = max(c.max(), high_c) low_c = min(c.min(), low_c) if detect and iteration % detect == 0: if c.ptp() < 0.001: is_uniform = True elif np.isnan(np.sum(c)): is_nan = True elif type(last_c) != bool and np.allclose(c, last_c, atol=0.00001, rtol=0): is_stable = True last_c = c.copy() if is_stable or iteration in snap: if show: plot() col += 1 if is_stable or is_uniform or is_nan: break # finalization if info: min_c, max_c = c.min(), c.max() print('C [{:.2f}, {:.2f}] <{:.2f}, {:.2f}>'.format(min_c, max_c, low_c, high_c), end=' ') if is_stable: print('stability of C at {}'.format(iteration)) elif is_uniform: print('uniformity of C at {}'.format(iteration)) elif is_nan: print('NaN found in C at {}'.format(iteration)) else: print() if col == 0 or not show: plt.close() else: plt.show() if out: fig.savefig(out, bbox_inches='tight', dpi=dpi) del axes, ax, ay, col, cols, draw, fig, gamma, last_c, lap_c, plot, rows sim = Bunch(locals()) ``` ## Simple validation ```python reinforcement() ``` ## Usage examples ```python # change in the initial state, compensated by the threshold and width parameters, yields the same pattern reinforcement(ini_c=2, var_c=1, threshold=2.5, width=0.5, scale=1, stop=1000) ``` ```python # show C and 1D detail view (dashed lines indicate the t-w, t and t+w levels) # show initial state (iteration 0) reinforcement(detail=25, first=True, snap=5, stop=2000, scale=1.2) ``` ```python # set non-zero 'start' iteration count # 'time' adjusts number of iterations accordingly to speed reinforcement(scale=0.6, stop=2000) reinforcement(scale=0.6, start=1000, time=2000, speed=50) ``` ```python # skip output, but still stop at a stable pattern reinforcement(detect=True, info=True, scale=0.1, show='') ``` C [0.00, 2.00] <0.00, 2.00> stability of C at 600 ```python # stop prematurely when concentrations turn constant reinforcement(detect=True, threshold=2) print('is uniform?', sim.is_uniform) ``` is uniform? True ```python # fields available for simulation object for i in sorted(sim): print(i + '=' + repr(sim[i])) ``` axis=False cmap='inferno' delta_t=0.01 detail=None detect=100 diff_c=1 dpi=100 extent=(-0.2, 2.2) first=False func=None info=False ini_c=0 interpolation='bilinear' is_nan=False is_stable=False is_uniform=True iteration=200 limit=None model=<function reinforcement_model at 0x7ff2594009e0> out=None scale=1 seed=1 shape=(40, 40) show='c' size=2 snap=array([ 250, 500, 750, 1000]) speed=100 start=0 stop=1000 threshold=2 time=None use_c=False var_c=2 width=1 wrap=True
Subroutine pyrand Common /ludat1/mstu(200), paru(200), mstj(200), parj(200) Save /ludat1/ Common /ludat2/kchg(500, 3), pmas(500, 4), parf(2000), vckm(4, 4) Save /ludat2/ Common /pysubs/msel, msub(200), kfin(2, -40:40), ckin(200) Save /pysubs/ Common /pypars/mstp(200), parp(200), msti(200), pari(200) Save /pypars/ Common /pyint1/mint(400), vint(400) Save /pyint1/ Common /pyint2/iset(200), kfpr(200, 2), coef(200, 20), icol(40, 4, 2) Save /pyint2/ Common /pyint3/xsfx(2, -40:40), isig(1000, 3), sigh(1000) Save /pyint3/ Common /pyint4/widp(21:40, 0:40), wide(21:40, 0:40), wids(21:40, 3) Save /pyint4/ Common /pyint5/ngen(0:200, 3), xsec(0:200, 3) Save /pyint5/ mint(17) = 0 mint(18) = 0 vint(143) = 1. vint(144) = 1. If (msub(95)==1 .Or. mint(82)>=2) Call pymult(2) isub = 0 100 mint(51) = 0 If (mint(82)==1 .And. (isub<=90 .Or. isub>96)) Then rsub = xsec(0, 1)*rlu(0) Do i = 1, 200 If (msub(i)/=1) Goto 110 isub = i rsub = rsub - xsec(i, 1) If (rsub<=0.) Goto 120 110 End Do 120 If (isub==95) isub = 96 Else If (mint(82)>=2 .And. isub==0) Then rsub = vint(131)*rlu(0) isub = 96 If (rsub>vint(106)) isub = 93 If (rsub>vint(106)+vint(104)) isub = 92 If (rsub>vint(106)+vint(104)+vint(103)) isub = 91 End If If (mint(82)==1) ngen(0, 1) = ngen(0, 1) + 1 If (mint(82)==1) ngen(isub, 1) = ngen(isub, 1) + 1 mint(1) = isub mint(72) = 0 kfr1 = 0 If (iset(isub)==1 .Or. iset(isub)==3) Then kfr1 = kfpr(isub, 1) Else If (isub>=71 .And. isub<=77) Then kfr1 = 25 End If If (kfr1/=0) Then taur1 = pmas(kfr1, 1)**2/vint(2) gamr1 = pmas(kfr1, 1)*pmas(kfr1, 2)/vint(2) mint(72) = 1 mint(73) = kfr1 vint(73) = taur1 vint(74) = gamr1 End If If (isub==141) Then kfr2 = 23 taur2 = pmas(kfr2, 1)**2/vint(2) gamr2 = pmas(kfr2, 1)*pmas(kfr2, 2)/vint(2) mint(72) = 2 mint(74) = kfr2 vint(75) = taur2 vint(76) = gamr2 End If vint(63) = 0. vint(64) = 0. mint(71) = 0 vint(71) = ckin(3) If (mint(82)>=2) vint(71) = 0. If (iset(isub)==2 .Or. iset(isub)==4) Then Do i = 1, 2 If (kfpr(isub,i)==0) Then Else If (mstp(42)<=0) Then vint(62+i) = pmas(kfpr(isub,i), 1)**2 Else vint(62+i) = ulmass(kfpr(isub,i))**2 End If End Do If (min(vint(63),vint(64))<ckin(6)**2) mint(71) = 1 If (mint(71)==1) vint(71) = max(ckin(3), ckin(5)) End If If (iset(isub)==0) Then is = int(1.5+rlu(0)) vint(63) = vint(3)**2 vint(64) = vint(4)**2 If (isub==92 .Or. isub==93) vint(62+is) = parp(111)**2 If (isub==93) vint(65-is) = parp(111)**2 sh = vint(2) sqm1 = vint(3)**2 sqm2 = vint(4)**2 sqm3 = vint(63) sqm4 = vint(64) sqla12 = (sh-sqm1-sqm2)**2 - 4.*sqm1*sqm2 sqla34 = (sh-sqm3-sqm4)**2 - 4.*sqm3*sqm4 thter1 = sqm1 + sqm2 + sqm3 + sqm4 - (sqm1-sqm2)*(sqm3-sqm4)/sh - sh thter2 = sqrt(max(0.,sqla12))*sqrt(max(0.,sqla34))/sh thl = 0.5*(thter1-thter2) thu = 0.5*(thter1+thter2) thm = min(max(thl,parp(101)), thu) jtmax = 0 If (isub==92 .Or. isub==93) jtmax = isub - 91 Do jt = 1, jtmax mint(13+3*jt-is*(2*jt-3)) = 1 sqmmin = vint(59+3*jt-is*(2*jt-3)) sqmi = vint(8-3*jt+is*(2*jt-3))**2 sqmj = vint(3*jt-1-is*(2*jt-3))**2 sqmf = vint(68-3*jt+is*(2*jt-3)) squa = 0.5*sh/sqmi*((1.+(sqmi-sqmj)/sh)*thm+sqmi-sqmf-sqmj**2/sh+(sqmi+sqmj)*sqmf/sh+(sqmi-sqmj)**2/sh**2*sqmf) quar = sh/sqmi*(thm*(thm+sh-sqmi-sqmj-sqmf*(1.-(sqmi-sqmj)/sh))+sqmi*sqmj-sqmj*sqmf*(1.+(sqmi-sqmj-sqmf)/sh)) sqmmax = squa + sqrt(max(0.,squa**2-quar)) If (abs(quar/squa**2)<1.E-06) sqmmax = 0.5*quar/squa sqmmax = min(sqmmax, (vint(1)-sqrt(sqmf))**2) vint(59+3*jt-is*(2*jt-3)) = sqmmin*(sqmmax/sqmmin)**rlu(0) End Do sqm3 = vint(63) sqm4 = vint(64) sqla34 = (sh-sqm3-sqm4)**2 - 4.*sqm3*sqm4 thter1 = sqm1 + sqm2 + sqm3 + sqm4 - (sqm1-sqm2)*(sqm3-sqm4)/sh - sh thter2 = sqrt(max(0.,sqla12))*sqrt(max(0.,sqla34))/sh thl = 0.5*(thter1-thter2) thu = 0.5*(thter1+thter2) b = vint(121) c = vint(122) If (isub==92 .Or. isub==93) Then b = 0.5*b c = 0.5*c End If thm = min(max(thl,parp(101)), thu) expth = 0. tharg = b*(thm-thu) If (tharg>-20.) expth = exp(tharg) 150 th = thu + log(expth+(1.-expth)*rlu(0))/b th = max(thm, min(thu,th)) ratlog = min((b+c*(th+thm))*(th-thm), (b+c*(th+thu))*(th-thu)) If (ratlog<log(rlu(0))) Goto 150 vint(21) = 1. vint(22) = 0. vint(23) = min(1., max(-1.,(2.*th-thter1)/thter2)) Else If (iset(isub)>=1 .And. iset(isub)<=4) Then Call pyklim(1) If (mint(51)/=0) Goto 100 rtau = rlu(0) mtau = 1 If (rtau>coef(isub,1)) mtau = 2 If (rtau>coef(isub,1)+coef(isub,2)) mtau = 3 If (rtau>coef(isub,1)+coef(isub,2)+coef(isub,3)) mtau = 4 If (rtau>coef(isub,1)+coef(isub,2)+coef(isub,3)+coef(isub,4)) mtau = 5 If (rtau>coef(isub,1)+coef(isub,2)+coef(isub,3)+coef(isub,4)+coef(isub,5)) mtau = 6 Call pykmap(1, mtau, rlu(0)) If (iset(isub)==3 .Or. iset(isub)==4) Then Call pyklim(4) If (mint(51)/=0) Goto 100 rtaup = rlu(0) mtaup = 1 If (rtaup>coef(isub,15)) mtaup = 2 Call pykmap(4, mtaup, rlu(0)) End If Call pyklim(2) If (mint(51)/=0) Goto 100 ryst = rlu(0) myst = 1 If (ryst>coef(isub,7)) myst = 2 If (ryst>coef(isub,7)+coef(isub,8)) myst = 3 Call pykmap(2, myst, rlu(0)) Call pyklim(3) If (mint(51)/=0) Goto 100 If (iset(isub)==2 .Or. iset(isub)==4) Then rcth = rlu(0) mcth = 1 If (rcth>coef(isub,10)) mcth = 2 If (rcth>coef(isub,10)+coef(isub,11)) mcth = 3 If (rcth>coef(isub,10)+coef(isub,11)+coef(isub,12)) mcth = 4 If (rcth>coef(isub,10)+coef(isub,11)+coef(isub,12)+coef(isub,13)) mcth = 5 Call pykmap(3, mcth, rlu(0)) End If Else If (iset(isub)==5) Then Call pymult(3) isub = mint(1) End If vint(24) = paru(2)*rlu(0) mint(51) = 0 If (isub<=90 .Or. isub>100) Call pyklim(0) If (mint(51)/=0) Goto 100 If (mint(82)==1 .And. mstp(141)>=1) Then mcut = 0 If (msub(91)+msub(92)+msub(93)+msub(94)+msub(95)==0) Call pykcut(mcut) If (mcut/=0) Goto 100 End If Call pysigh(nchn, sigs) If (mint(82)==1 .And. isub<=90 .Or. isub>=96) Then xsec(isub, 2) = xsec(isub, 2) + sigs Else If (mint(82)==1) Then xsec(isub, 2) = xsec(isub, 2) + xsec(isub, 1) End If If (mint(43)==4 .And. mstp(82)>=3) Then vint(153) = sigs Call pymult(4) End If viol = sigs/xsec(isub, 1) If (viol<rlu(0)) Goto 100 If (mstp(123)<=0) Then If (viol>1.) Then Write (mstu(11), 1000) viol, ngen(0, 3) + 1 Write (mstu(11), 1100) isub, vint(21), vint(22), vint(23), vint(26) Stop End If Else If (mstp(123)==1) Then If (viol>vint(108)) Then vint(108) = viol End If Else If (viol>vint(108)) Then vint(108) = viol If (viol>1.) Then xdif = xsec(isub, 1)*(viol-1.) xsec(isub, 1) = xsec(isub, 1) + xdif If (msub(isub)==1 .And. (isub<=90 .Or. isub>96)) xsec(0, 1) = xsec(0, 1) + xdif vint(108) = 1. End If End If vint(148) = 1. If (mint(43)==4 .And. (isub<=90 .Or. isub>=96) .And. mstp(82)>=3) Then Call pymult(5) If (vint(150)<rlu(0)) Goto 100 End If If (mint(82)==1 .And. msub(95)==1) Then If (isub<=90 .Or. isub>=95) ngen(95, 1) = ngen(95, 1) + 1 If (isub<=90 .Or. isub>=96) ngen(96, 2) = ngen(96, 2) + 1 End If If (isub<=90 .Or. isub>=96) mint(31) = mint(31) + 1 rsigs = sigs*rlu(0) qt2 = vint(48) rqqbar = parp(87)*(1.-(qt2/(qt2+(parp(88)*parp(82))**2))**2) If (isub/=95 .And. (isub/=96 .Or. mstp(82)<=1 .Or. rlu(0)>rqqbar)) Then Do ichn = 1, nchn kfl1 = isig(ichn, 1) kfl2 = isig(ichn, 2) mint(2) = isig(ichn, 3) rsigs = rsigs - sigh(ichn) If (rsigs<=0.) Goto 210 End Do Else If (isub==96) Then Call pyspli(mint(11), 21, kfl1, kfldum) Call pyspli(mint(12), 21, kfl2, kfldum) mint(1) = 11 mint(2) = 1 If (kfl1==kfl2 .And. rlu(0)<0.5) mint(2) = 2 Else kfl1 = 21 kfl2 = 21 rsigs = 6.*rlu(0) mint(2) = 1 If (rsigs>1.) mint(2) = 2 If (rsigs>2.) mint(2) = 3 End If 210 If (mint(2)>10) Then mint(1) = mint(2)/10 mint(2) = mod(mint(2), 10) End If mint(15) = kfl1 mint(16) = kfl2 mint(13) = mint(15) mint(14) = mint(16) vint(141) = vint(41) vint(142) = vint(42) Return 1000 Format (1X, 'Error: maximum violated by', 1P, E11.3, 1X, 'in event', 1X, I7, '.'/1X, 'Execution stopped!') 1100 Format (1X, 'ISUB = ', I3, '; Point of violation:'/1X, 'tau=', 1P, E11.3, ', y* =', E11.3, ', cthe = ', 0P, F11.7, ', tau'' =', 1P, E11.3) End Subroutine pyrand
open import Agda.Builtin.Nat postulate P : Nat → Set record R : Set where field f : P zero foo : R → Set foo (record { f = f0 }) with zero foo r | x = Nat
import datetime import logging.config import os import re import time import numpy import requests from requests.auth import HTTPBasicAuth, HTTPDigestAuth from xml.etree import ElementTree from PIL import Image from io import BytesIO try: logging.config.fileConfig("logging.ini") except: pass exiv2_exists = False try: import pyexiv2 exiv2_exists = True except Exception as e: logging.debug("Couldnt import pyexiv2: {}".format(str(e))) class IPCamera(object): def __init__(self, identifier=None, config=None, **kwargs): if not config: config = dict() self.config = config.copy() self.return_parser = config.get("return_parser", "plaintext") e = os.environ.get("RETURN_PARSER", None) e = os.environ.get("CAMERA_RETURN_PARSER", e) self.return_parser = e if e is not None else self.return_parser self.logger = logging.getLogger(identifier) self.identifier = identifier self.camera_name = config.get("camera_name", identifier) self.interval = int(config.get("interval", 300)) self.current_capture_time = datetime.datetime.now() self._image = None self._notified = [] format_str = config.get("format_url", "http://{HTTP_login}@{ip}{command}") e = os.environ.get("FORMAT_URL", None) e = os.environ.get("CAMERA_FORMAT_URL", e) format_str = e if e is not None else format_str self.auth_type = config.get("auth_type", "basic") e = os.environ.get("AUTH_TYPE", None) e = os.environ.get("CAMERA_AUTH_TYPE", e) self.auth_type = e if e is not None else self.auth_type self.auth_object = None username = config.get("username", "admin") e = os.environ.get("AUTH_USERNAME", None) e = os.environ.get("CAMERA_AUTH_USERNAME", e) username = e if e is not None else username password = config.get("password", "admin") e = os.environ.get("AUTH_PASSWORD", None) e = os.environ.get("CAMERA_AUTH_PASSWORD", e) username = e if e is not None else username if format_str.startswith("http://{HTTP_login}@"): format_str = format_str.replace("{HTTP_login}@", "") self.auth_object = HTTPBasicAuth(username, password) self.auth_object_digest = HTTPDigestAuth(username, password) self.auth_object = self.auth_object_digest if self.auth_type == "digest" else self.auth_object self._HTTP_login = config.get("HTTP_login", "{user}:{password}").format( user=username, password=password) ip = config.get("ip", "192.168.1.101:81") ip = os.environ.get("IP", ip) ip = os.environ.get("CAMERA_IP", ip) self._url = format_str.format( ip=ip, HTTP_login=self._HTTP_login, command="{command}") ) self._image_size = config.get("image_size", [1920, 1080]) self._image_size = os.environ.get("CAMERA_IMAGE_SIZE", self._image_size) if type(self._image_size) is str: self._image_size = re.split("[\W+|\||,|x|x|:]", self._image_size) self._image_size = [ int(float(x)) for x in self._image_size ] self.image_quality = config.get("image_quality", 100) self.image_quality = os.environ.get("CAMERA_IMAGE_QUALITY", self.image_quality) # no autofocus modes by default. self._autofocus_modes = config.get("autofocus_modes", []) self._hfov_list = config.get("horizontal_fov_list", [71.664, 58.269, 47.670, 40.981, 33.177, 25.246, 18.126, 12.782, 9.217, 7.050, 5.82]) self._vfov_list = config.get("vertical_fov_list", [39.469, 33.601, 26.508, 22.227, 16.750, 13.002, 10.324, 7.7136, 4.787, 3.729, 2.448]) self._hfov = self._vfov = None self._zoom_list = config.get("zoom_list", [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1000]) self._focus_range = config.get("focus_range", [1, 99999]) # set commands from the rest of the config. self.command_urls = config.get('urls', {}) self.return_keys = config.get("keys", {}) self.logger.info(self.status) def _make_request(self, command_string, *args, **kwargs): """ Makes a generic request formatting the command string and applying the authentication. :param command_string: command string like read stream raw :type command_string: str :param args: :param kwargs: :return: """ url = self._url.format(*args, command=command_string, **kwargs) if "&" in url and "?" not in url: url = url.replace("&", "?", 1) response = None try: response = requests.get(url, timeout=60, auth=self.auth_object) if response.status_code == 401: self.logger.debug("Auth is not basic, trying digest") response = requests.get(url, timeout=60, auth=self.auth_object_digest) if response.status_code not in [200, 204]: self.logger.error( "[{}] - {}\n{}".format(str(response.status_code), str(response.reason), str(response.url))) return return response except Exception as e: self.logger.error("Some exception got raised {}".format(str(e))) return def _read_stream(self, command_string, *args, **kwargs): """ opens a url with the current HTTP_login string :type command_string: str :param command_string: url to go to with parameters :return: string of data returned from the camera """ response = self._make_request(command_string, *args, **kwargs) if response is None: return return response.text def _read_stream_raw(self, command_string, *args, **kwargs): """ opens a url with the current HTTP_login string :param command_string: url to go to with parameters :type command_string: str :return: string of data returned from the camera """ response = self._make_request(command_string, *args, **kwargs) if response is None: return return response.content def _get_cmd(self, cmd): cmd_str = self.command_urls.get(cmd, None) if not cmd_str and cmd_str not in self._notified: print("No command available for \"{}\"".format(cmd)) self._notified.append(cmd_str) return None, None keys = self.return_keys.get(cmd, []) if type(keys) not in (list, tuple): keys = [keys] return cmd_str, keys @staticmethod def get_value_from_xml(message_xml, *args): """ gets float, int or string values from a xml string where the key is the tag of the first element with value as text. :param message_xml: the xml to searach in. :param args: list of keys to find values for. :rtype: dict :return: dict of arg: value pairs requested """ return_values = dict() if not len(args): return return_values if not len(message_xml): return return_values # apparently, there is an issue parsing when the ptz returns INVALID XML (WTF?) # these seem to be the tags that get mutilated. illegal = ['\n', '\t', '\r', "<CPStatusMsg>", "</CPStatusMsg>", "<Text>", "</Text>", "<Type>Info</Type>", "<Type>Info", "Info</Type>", "</Type>", "<Type>"] for ill in illegal: message_xml = message_xml.replace(ill, "") root_element = ElementTree.Element("invalidation_tag") try: root_element = ElementTree.fromstring(message_xml) except Exception as e: print(str(e)) print("Couldnt parse XML!!!") print(message_xml) return_values = dict for key in args: target_ele = root_element.find(key) if target_ele is None: continue value = target_ele.text.replace(' ', '') if value is None: continue types = [float, int, str] for t in types: try: return_values[key] = t(value) break except ValueError: pass else: print("Couldnt cast an xml element text attribute to str. What are you feeding the xml parser?") return return_values @staticmethod def get_value_from_plaintext(message, *args): """ gets float, int or string values from a xml string where the key is the tag of the first element with value as text. :param message: :param args: list of keys to find values for. :rtype: dict :return: dict of arg: value pairs requested """ return_values = dict() if not len(args): return return_values if not len(message): return return_values for line in message.split("\n"): line = line.replace("= ", "=").replace(" =", "=").strip() name, value = line.partition("=")[::2] name, value = name.strip(), value.strip() types = [float, int, str] if name in args: for t in types: try: v = t(value) if str(v).lower() in ['yes', 'no', 'true', 'false', 'on', 'off']: v = str(v).lower() in ['yes', 'true', 'on'] return_values[name] = v break except ValueError: pass else: print("Couldnt cast an plaintext element text attribute to str. What are you feeding the parser?") return return_values def get_value_from_stream(self, stream, *keys): """ Gets a value from some text data (xml or plaintext = separated values) returns a dict of "key":value pairs. :param stream: text data to search for values :type stream: str :param keys: :type keys: list :return: dict of values :rtype: dict """ if self.return_parser == 'plaintext': return self.get_value_from_plaintext(stream, *keys) elif self.return_parser == 'xml': return self.get_value_from_xml(stream, *keys) else: return dict() def encode_write_image(self, img: Image, fn: str) -> list: """ takes an image from PIL and writes it to disk as a tif and jpg converts from rgb to bgr for cv2 so that the images save correctly also tries to add exif data to the images :param PIL.Image img: 3 dimensional image array, x,y,rgb :param str fn: filename :return: files successfully written. :rtype: list(str) """ # output types must be valid! fnp = os.path.splitext(fn)[0] successes = list() output_types = ["jpg", "tiff"] e = os.environ.get("OUTPUT_TYPES", None) if e is not None: output_types = re.split("[\W+|\||,|:]", e) for ext in output_types: fn = "{}.{}".format(fnp, ext) s = False try: if ext in ("tiff", "tif"): if fn.endswith(".tiff"): fn = fn[:-1] img.save(fn, format="TIFF", compression='tiff_lzw') if ext in ("jpeg", "jpg"): img.save(fn, format="JPEG", quality=95, optimize=True, progressive=True, subsampling="4:4:4") else: img.save(fn) s = True except Exception as e: self.logger.error("Couldnt write image") self.logger.error(e) # im = Image.fromarray(np.uint8(img)) # s = cv2.imwrite(fn, img) if s: successes.append(fn) try: # set exif data if exiv2_exists: meta = pyexiv2.ImageMetadata(fn) meta.read() for k, v in self.exif.items(): try: meta[k] = v except: pass meta.write() except Exception as e: self.logger.debug("Couldnt write the appropriate metadata: {}".format(str(e))) return successes def capture_image(self, filename=None) -> numpy.array: """ Captures an image with the IP camera, uses requests.get to acqire the image. :param filename: filename without extension to capture to. :return: list of filenames (of captured images) if filename was specified, otherwise a numpy array of the image. :rtype: numpy.array or list """ st = time.time() cmd, keys = self._get_cmd("get_image") if "{width}" in cmd and "{height}" in cmd: cmd = cmd.format(width=self._image_size[0], height=self.image_size[1]) if not cmd: self.logger.error("No capture command, this is wrong...") return self._image url = self._url.format(command=cmd) for x in range(10): try: # fast method a = self._read_stream_raw(cmd) # b = numpy.fromstring(a, numpy.uint8) self._image = Image.open(BytesIO(a)) if filename: rfiles = self.encode_write_image(self._image, filename) self.logger.debug("Took {0:.2f}s to capture".format(time.time() - st)) return rfiles else: self.logger.debug("Took {0:.2f}s to capture".format(time.time() - st)) break except Exception as e: self.logger.error("Capture from network camera failed {}".format(str(e))) time.sleep(0.2) else: self.logger.error("All capture attempts (10) for network camera failed.") return self._image # def set_fov_from_zoom(self): # self._hfov = numpy.interp(self._zoom_position, self.zoom_list, self.hfov_list) # self._vfov = numpy.interp(self._zoom_position, self.zoom_list, self.vfov_list) @property def image_quality(self) -> float: """ Image quality as a percentage. :getter: cached. :setter: to camera. :rtype: float """ return self._image_quality @image_quality.setter def image_quality(self, value: float): assert (1 <= value <= 100) cmd, keys = self._get_cmd("get_image_quality") if cmd: self._read_stream(cmd.format(value)) @property def image_size(self) -> list: """ Image resolution in pixels, tuple of (width, height) :getter: from camera. :setter: to camera. :rtype: tuple """ cmd, keys = self._get_cmd("get_image_size") if cmd: stream = self._read_stream(cmd) output = self.get_value_from_stream(stream, keys) width,height = self._image_size for k,v in output.items(): if "width" in k: width = v if "height" in k: height = v self._image_size = [width, height] return self._image_size @image_size.setter def image_size(self, value): assert type(value) in (list, tuple), "image size is not a list or tuple!" assert len(value) == 2, "image size doesnt have 2 elements width,height are required" value = list(value) cmd, keys = self._get_cmd("set_image_size") if cmd: self._read_stream(cmd.format(width=value[0], height=value[1])) self._image_size = value @property def focus_mode(self) -> str: """ TODO: this is broken, returns the dict of key: value not value Focus Mode When setting, the mode provided must be in 'focus_modes' :getter: from camera. :setter: to camera. :rtype: list """ cmd, keys = self._get_cmd("get_focus_mode") if not cmd: return None stream_output = self._read_stream(cmd) return self.get_value_from_stream(stream_output, keys)['mode'] @focus_mode.setter def focus_mode(self, mode: str): assert (self._autofocus_modes is not None) if str(mode).upper() not in [x.upper() for x in self._autofocus_modes]: print("Focus mode not in list of supported focus modes, not setting.") return cmd, keys = self._get_cmd("set_focus_mode") if cmd: self._read_stream(cmd.format(mode=mode)) @property def focus_position(self): """ Focal position as an absolute value. :getter: from camera. :setter: to camera. :rtype: float """ cmd, keys = self._get_cmd("get_focus") if not cmd: return None stream_output = self._read_stream(cmd) result = self.get_value_from_stream(stream_output, keys) return next(iter(result), float(99999)) @focus_position.setter def focus_position(self, absolute_position): self.logger.debug("Setting focus position to {}".format(absolute_position)) cmd, key = self._get_cmd("set_focus") if not cmd: assert (self._focus_range is not None and absolute_position is not None) absolute_position = min(self._focus_range[1], max(self._focus_range[0], absolute_position)) assert (self._focus_range[0] <= absolute_position <= self._focus_range[1]) self._read_stream(cmd.format(focus=absolute_position)) def focus(self): """ focuses the camera by cycling it through its autofocus modes. """ self.logger.debug("Focusing...") tempfocus = self.focus_mode cmd, key = self._get_cmd("set_autofocus_mode") if not cmd or len(self._autofocus_modes) < 1: return for mode in self._autofocus_modes: self.focus_mode = mode time.sleep(2) self.focus_mode = tempfocus self._read_stream(cmd.format(mode=self._autofocus_modes[0])) time.sleep(2) self.logger.debug("Focus complete.") @property def focus_range(self): """ Information about the focus of the camera :return: focus type, focus max, focus min :rtype: list [str, float, float] """ cmd, keys = self._get_cmd("get_focus_range") if not cmd: return None stream_output = self._read_stream(cmd) values = self.get_value_from_stream(stream_output, keys) return values[2:0:-1] @property def hfov_list(self): """ List of horizontal FoV values according to focus list. :getter: cached. :setter: cache. :rrtype: list(float) """ return self._hfov_list @hfov_list.setter def hfov_list(self, value): assert type(value) in (list, tuple), "must be either list or tuple" # assert len(value) == len(self._zoom_list), "must be the same length as zoom list" self._hfov_list = list(value) @property def vfov_list(self): """ List of vertical FoV values according to focus list. :getter: cached. :setter: cache. :rrtype: list(float) """ return self._vfov_list @vfov_list.setter def vfov_list(self, value): assert type(value) in (list, tuple), "must be either list or tuple" # assert len(value) == len(self._zoom_list), "must be the same length as zoom list" self._vfov_list = list(value) @property def hfov(self): """ Horizontal FoV :getter: calculated using cached zoom_position, zoom_list and hfov_list. :setter: cache. :rrtype: list(float) """ # self._hfov = numpy.interp(self._zoom_position, self.zoom_list, self.hfov_list) return self._hfov @hfov.setter def hfov(self, value: float): self._hfov = value @property def vfov(self): """ Vertical FoV :getter: calculated using cached zoom_position, zoom_list and vfov_list. :setter: cache. :rrtype: list(float) """ # self._vfov = numpy.interp(self._zoom_position, self.zoom_list, self.vfov_list) return self._vfov @vfov.setter def vfov(self, value: float): self._vfov = value @property def status(self) -> str: """ Helper property for a string of the current zoom/focus status. :return: informative string of zoom_pos zoom_range focus_pos focus_range :rtype: str """ # fmt_string = "zoom_pos:\t{}\nzoom_range:\t{}" fmt_string = "".join(("\nfocus_pos:\t{}\nfocus_range:\t{}")) return fmt_string.format(self.focus_position, self.focus_range)
Load LFindLoad. From lfind Require Import LFind. From QuickChick Require Import QuickChick. From adtind Require Import goal33. Derive Show for natural. Derive Arbitrary for natural. Instance Dec_Eq_natural : Dec_Eq natural. Proof. dec_eq. Qed. Lemma conj11synthconj2 : forall (lv0 : natural) (lv1 : natural), (@eq natural (Succ (plus lv0 lv1)) (plus (Succ lv1) lv0)). Admitted. QuickChick conj11synthconj2.
\section{Improper Integrals} Now that we've developed the tools to deal with limits as they approach infinity and the possible indeterminate forms that may arise, we can apply these ideas to integrals, allowing us to have $-\infty$ and $\infty$ as limits of integration. We call these integrals with $\pm\infty$ as limits of integration, and functions that become $\pm\infty$ somewhere within the interval we're integrating on improper integrals. \subsection{Infinite Integration Limits} \begin{definition} If $f$ is continuous on $[a,\infty)$, then \begin{equation*} \int_{a}^{\infty}{f(x)\d{x}} = \lim_{b\to\infty}{\int_{a}^{b}{f(x)\d{x}}}. \end{equation*} If $f$ is continuous on $(-\infty,b]$, then \begin{equation*} \int_{\infty}^{b}{f(x)\d{x}} = \lim_{a\to-\infty}{\int_{a}^{b}{f(x)\d{x}}}. \end{equation*} If $f$ is continuous on $(-\infty,\infty)$, then \begin{equation*} \int_{-\infty}^{\infty}{f(x)\d{x}} = \int_{-\infty}^{c}{f(x)\d{x}} + \int_{c}^{\infty}{f(x)\d{x}} \end{equation*} for any real constant $c$. If these limits exist, then the integral converges and has a value. Otherwise, the integral diverges and does not have a value. \end{definition} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{2}^{\infty}{\frac{3}{x^2-x}\d{x}}. \end{equation*} \end{example} \begin{answer} Applying the definition, \begin{align*} \int_{2}^{\infty}{\frac{3}{x^2-x}\d{x}} &= \lim_{b\to\infty}{\int_{2}^{b}{\frac{3}{x^2-x}\d{x}}} \\ &= \lim_{b\to\infty}{3\int_{2}^{b}{\left(\frac{1}{x-1}-\frac{1}{x}\right)\d{x}}} \\ &= \lim_{b\to\infty}{3\ln{\bigg\lvert\frac{x-1}{x}\bigg\rvert}\Biggr\rvert_{2}^{b}} \\ &= \lim_{b\to\infty}{3\ln{\bigg\lvert\frac{b-1}{b}\bigg\rvert}} - 3\ln{\bigg\lvert\frac{1}{2}\bigg\rvert} \\ &= 0 + 3\ln{2} \\ &= 3\ln{2}. \end{align*} \end{answer} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{\frac{\d{x}}{\sqrt[4]{x}}}. \end{equation*} \end{example} \begin{answer} Applying the definition, \begin{align*} \int_{1}^{\infty}{\frac{\d{x}}{\sqrt[4]{x}}} &= \lim_{b\to\infty}{\int_{1}^{b}{\frac{\d{x}}{\sqrt[4]{x}}}} \\ &= \lim_{b\to\infty}{\frac{4}{3}\sqrt[4]{x^3}\biggr\rvert_{1}^{b}} \\ &= \lim_{b\to\infty}{\frac{4}{3}\sqrt[4]{b^3}} - \frac{4}{3}\sqrt[4]{1^3} \\ &= \infty - \frac{4}{3} \\ &= \text{diverges}. \end{align*} \end{answer} \subsection{Infinite Discontinuities} An infinite discontinuity occurs when a function takes on a value of $\pm\infty$ on the interval we're integrating on. In this case, we'll need to split the integral into pieces, evaluating the limit as we approach this infinite discontinuity from both sides. \begin{definition} If $f$ is continuous on $(a,b]$, then \begin{equation*} \int_{a}^{b}{f(x)\d{x}} = \lim_{c\to a^+}{\int_{c}^{b}{f(x)\d{x}}}. \end{equation*} If $f$ is continuous on $[a,b)$, then \begin{equation*} \int_{a}^{b}{f(x)\d{x}} = \lim_{c\to b^-}{\int_{a}^{c}{f(x)\d{x}}}. \end{equation*} If $f$ is continuous on $[a,c) \cup (c,b]$, then \begin{equation*} \int_{a}^{b}{f(x)\d{x}} = \int_{a}^{c}{f(x)\d{x}} + \int_{c}^{b}{f(x)\d{x}}. \end{equation*} If these limits exist, then the integral converges and has a value. Otherwise, the integral diverges and does not have a value. \end{definition} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{0}^{1}{\frac{\d{x}}{x^2}}. \end{equation*} \end{example} \begin{answer} We see that we have an infinite discontinuity at $x=0$. Applying the definition, \begin{align*} \int_{0}^{1}{\frac{\d{x}}{x^2}} &= \lim_{c\to 0^+}{\int_{c}^{1}{\frac{\d{x}}{x^2}}} \\ &= \lim_{c\to 0^+}{\frac{-1}{x}\biggr\rvert_{c}^{1}} \\ &= \frac{-1}{1} + \lim_{c\to 0^+}{\frac{1}{c}} \\ &= -1 + \infty \\ &= \text{diverges}. \end{align*} \end{answer} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{0}^{1}{\frac{\d{x}}{x^{1/2}}}. \end{equation*} \end{example} \begin{answer} We see that we have an infinite discontinuity at $x=0$. Applying the definition, \begin{align*} \int_{0}^{1}{\frac{\d{x}}{x^{1/2}}} &= \lim_{c\to 0^+}{\int_{c}^{1}{\frac{\d{x}}{x^{1/2}}}} \\ &= \lim_{c\to 0^+}{2x^{1/2}\biggr\rvert_{c}^{1}} \\ &= 2 - \lim_{c\to 0^+}{2c^{1/2}} \\ &= 2 - 0 \\ &= 2. \end{align*} \end{answer} \subsection{Convergence Tests} \subsubsection{P-Test} \begin{lemma} The following integral will converge when $p > 1$ and diverge if $0 < p \leq 1$. \begin{equation*} \int_{1}^{\infty}{\frac{\d{x}}{x^p}}. \end{equation*} \end{lemma} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{\frac{\d{x}}{x}}. \end{equation*} \end{example} \begin{answer} We have an integral where $p=1$. So, by the P-Test, the integral diverges. \end{answer} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{\frac{\d{x}}{x^{1.001}}}. \end{equation*} \end{example} \begin{answer} We have an integral where $p=1.001$. So, by the P-Test, the integral converges. \begin{align*} \int_{1}^{\infty}{\frac{\d{x}}{x^{1.001}}} &= \lim_{b\to\infty}{\int_{1}^{b}{\frac{\d{x}}{x^{1.001}}}} \\ &= \lim_{b\to\infty}{-1000x^{-0.001}\biggr\rvert_{1}^{b}} \\ &= \lim_{b\to\infty}{-1000b^{-0.001}} + 1000(1)^{-0.001} \\ &= 0 + 1000 \\ &= 1000. \end{align*} \end{answer} \subsubsection{Direct Comparison Test} \begin{lemma} Let $f$ and $g$ be continuous on $[a,\infty)$ with $0 \leq f(x) \leq g(x)$ for all $x \geq a$. \begin{align*} \int_{a}^{\infty}{f(x)\d{x}} &\text{ converges if } \int_{a}^{\infty}{g(x)\d{x}} \text{ converges.} \\ \int_{a}^{\infty}{g(x)\d{x}} &\text{ diverges if } \int_{a}^{\infty}{f(x)\d{x}} \text{ diverges.} \end{align*} \end{lemma} That is, if a larger function converges, then so will a smaller funtion; if a smaller function diverges, then so will a larger function. \\ The hardest part of the Direct Comparison Test is deciding what function you should compare to. A general rule is to pick a function that is similar to, but simpler than then given function. \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{\frac{\d{x}}{x^2-0.1}}. \end{equation*} \end{example} \begin{answer} If the 0.1 wasn't inside the square root, the function would simplify to $1/x$. Since the 0.1 is subtracted, the denominator is smaller than $1/x$. So, $1/x$ is a function that is smaller on $[1,\infty)$, meaning if it diverges, then so will the original function. We know by the P-Test that the integral of $1/x$ from 1 to $\infty$ will diverge, so the original function also diverges. \end{answer} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{e^{-x^2}\d{x}}. \end{equation*} \end{example} \begin{answer} Since the exponent is negative, a smaller exponent would mean a larger value. So, $e^{-x}$ is a larger function on $[1,\infty)$. \begin{equation*} \int_{1}^{\infty}{e^{-x}\d{x}} = \frac{1}{e}, \end{equation*} meaning it converges, so the original function also converges. \end{answer} \subsubsection{Limit Comparison Test} \begin{lemma} If positive functions $f$ and $g$ are continuous on $[a,\infty)$ and \begin{equation*} \lim_{x\to\infty}{\frac{f(x)}{g(x)}} \end{equation*} converges to a positive real number, then \begin{equation*} \int_{a}^{\infty}{f(x)\d{x}} \text { and } \int_{a}^{\infty}{g(x)\d{x}} \end{equation*} both converge or both diverge. \end{lemma} Many functions to which you can apply the Limit Comparison Test you can also apply the Direct Comparison Test. The practical use of the limit comparison test is to take an uglier function, that may be tedious to integrate and compare it to a function that is easy to determine whether it diverges using something like the P-Test. A common strategy, especially for rational functions, is to look at their end behavior model. \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{\frac{\d{x}}{1+x^2}}. \end{equation*} \end{example} \begin{answer} Although you might recognize this as the derivative of $\arctan$, let's continue with the Direct Comparison Test. This function looks very similar to $1/x^2$, which we know by the P-Test will converge on $[1,\infty)$. \begin{equation*} \lim_{x\to\infty}{\frac{\frac{1}{x^2}}{\frac{1}{1+x^2}}} = \lim_{x\to\infty}{\frac{1+x^2}{x^2}} = 1. \end{equation*} Since 1 is a positive real constant and the integral of $1/x^2$ converges, then the original integral also converges by the Limit Comparison Test. \end{answer} \begin{example} Evaluate the following integral or state that it diverges. \begin{equation*} \int_{1}^{\infty}{\frac{3x+6}{1-5x+7x^2}\d{x}}. \end{equation*} \end{example} \begin{answer} Looking at this rational function, we see a degree 1 polynomial in the numerator and a degree 2 polynomial in the denominator. So, we'd expect this rational function to have the same end behavior model as $1/x$, which we know by the P-Test diverges. \begin{equation*} \lim_{x\to\infty}{\frac{\frac{3x+6}{1-5x+7x^2}}{\frac{1}{x}}} = \lim_{x\to\infty}{\frac{3x^2+6x}{7x^2-5x+1}} = \frac{3}{7}. \end{equation*} Since 3/7 is a positive real constant and the integral of $1/x$ diverges, the the original integral also diverges by the Limit Comparison Test. \end{answer}
import numpy as np from math import pi,asin,sin import lattice_utils as lu from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear from mpl_toolkits.axes_grid.axislines import Subplot import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt def dynamic_range(Efixed,E,E_max,theta_range = [10,120],step = 10, color = 'k',showplot = True): #modify to allow fixed Ef or fixed Ei, and input of scattering #angles omega = np.linspace(0,E_max,100) theta_s = np.arange(theta_range[0]*np.pi/180,theta_range[1]*np.pi/180,step*np.pi/180) Q = np.empty([theta_s.size,omega.size],float) if Efixed == "Ef": kf = np.sqrt((E)/2.072) ki = np.sqrt((omega+E)/2.072) elif Efixed =="Ei": ki = np.sqrt((E)/2.072) kf = np.sqrt((E-omega)/2.072) for i, theta in enumerate(theta_s): Q[i] = np.sqrt(ki**2 + kf**2 - 2*ki*kf*np.cos(theta)) if showplot: plt.plot(Q[i],omega,lw=1,ls = '--',color = color) txt = "$2\\theta_s$ = {0}$^o$".format(np.round(theta*180/np.pi,1)) plt.text(Q[i,i+25],omega[50],txt, bbox=dict(fc = '1',lw = 0,alpha = 0.05),rotation = 75,color = color) plt.xlabel('Q ($\\AA^{-1}$)') plt.ylabel('Energy Transfer (meV)') title = 'Accessible dynamic range for {1} fixed = {0} meV'.format(E,Efixed) plt.title(title) plt.grid(True) plt.show() return omega,Q def spec_twoTheta(Efixed,E,E_T,Q): if Efixed == "Ef": kf = np.sqrt((E)/2.072) ki = np.sqrt((E_T+E)/2.072) elif Efixed =="Ei": ki = np.sqrt((E)/2.072) kf = np.sqrt((E-E_T)/2.072) theta =np.arccos(-(Q**2 - ki**2 - kf**2)/ki/kf/2.) return theta*180./np.pi def Bragg_angle(wavelength,q,rlatt): d = lu.dspacing(q,rlatt) print(wavelength/d/2) tth = 360./pi*asin(wavelength/d/2) print('\n') print( '\t wavelength = {:.2f}, Q = [{:.2f} {:.2f} {:.2f}], Two-theta = {:.3f}'.format(wavelength,q[0],q[1],q[2],tth)) return def TOF_par(q,tth,rlatt): d = lu.dspacing(q,rlatt) wavelength = 2*d*sin(tth*pi/360) E = (9.044/wavelength)**2 k = 2*pi/wavelength velocity = 629.62*k # m/s print('Q = [{:.2f} {:.2f} {:.2f}]\n d = {:.3f} \n Two-theta = {:.2f}\n wavelength = {:.3f} Angstrom\n Energy = {:3f} meV\n Velocity = {:3f} m/s'.format(q[0],q[1],q[2],d,tth,wavelength,E,velocity)) return d,wavelength,E,velocity def Recip_space(sample): """ Set up general reciprocal space grid for plotting Miller indicies in a general space. Would be cool if returned fig object had a custom transformation so that all data added to plot after it has been created can be given in miller indicies grid for custom transform. """ def tr(x, y): x, y = np.asarray(x), np.asarray(y) return x, y-x def inv_tr(x,y): x, y = np.asarray(x), np.asarray(y) return x, y+x grid_helper = GridHelperCurveLinear((tr, inv_tr)) fig = plt.figure(1, figsize=(7, 4)) ax = Subplot(fig, 1, 1, 1, grid_helper=grid_helper) rlatt = sample.star_lattice [xs,ys,zs] = sample.StandardSystem fig.add_subplot(ax) ax.grid(True) return def Al_peaks(wavelength = 1.0): energy = (9.044/wavelength)**2 # Al_lattice a = 4.0498; b = 4.0498; c = 4.0498 aa =90; bb = 90; cc = 90 latt = lu.lattice(a,b,c,aa,bb,cc) rlatt = lu.recip_lattice(latt) # Al is FCC so peaks must be all even or all odd peaks = [[1,1,1],[2,0,0],[2,2,0],[3,1,1],[2,2,2],[4,0,0],[3,3,1],[4,2,0], [4,2,2],[5,1,1],[3,3,3],[4,4,0],[5,3,1],[4,4,2],[6,0,0]] print('\tAluminum Bragg Peaks') print('\tNeutron wavelength {:.2f} Angstroms ({:.2f} meV)\n'.format(wavelength,energy)) print('\t H K L\tQ (AA-1) d(AA) 2theta 2theta(l/2) 2theta(l/3)') print('\t----------------------------------------------------------------------------') for p in peaks: modQ = lu.modVec(p,rlatt) dsp = lu.dspacing(p,rlatt) if abs(wavelength/(2*dsp)) < 1: tth = 360/pi * asin(wavelength/(2*dsp)) line = '\t {:d} {:d} {:d}\t {:.3f} {:.3f} {:.2f}\t {:.2f}\t {:.2f}' else : tth = 'NaN' line = '\t {:d} {:d} {:d}\t {:.3f} {:.3f} {:s}\t {:.2f}\t {:.2f}' if abs((wavelength/2)/(2*dsp)) < 1: tth2 = 360/pi * asin((wavelength/2)/(2*dsp)) else : tth2 = 'NaN' line = '\t {:d} {:d} {:d}\t {:.3f} {:.3f} {:s}\t {:s}\t\t {:.2f}' if abs((wavelength/3)/(2*dsp)) < 1: tth3 = 360/pi * asin((wavelength/3)/(2*dsp)) else : tth3 = 'NaN' line = '\t {:d} {:d} {:d}\t {:.3f} {:.3f} {:s}\t {:s}\t\t {:s}' # else : # tth = 360/pi * asin(wavelength/(2*dsp)) # tth2 = 360/pi * asin((wavelength/2)/(2*dsp)) # tth3 = 360/pi * asin((wavelength/3)/(2*dsp)) # line = '\t {:d} {:d} {:d}\t {:.3f} {:.3f} {:.2f}\t {:.2f}\t {:.2f}' print(line.format(p[0],p[1],p[2],modQ,dsp,tth,tth2,tth3)) return if __name__ == '__main__': Al_peaks()
[GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G s : Set M x₀ : M hf : ContMDiffWithinAt I' I n f s x₀ hg : ContMDiffWithinAt I' I n g s x₀ ⊢ ContMDiffWithinAt I' I n (fun x => f x / g x) s x₀ [PROOFSTEP] simp_rw [div_eq_mul_inv] [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G s : Set M x₀ : M hf : ContMDiffWithinAt I' I n f s x₀ hg : ContMDiffWithinAt I' I n g s x₀ ⊢ ContMDiffWithinAt I' I n (fun x => f x * (g x)⁻¹) s x₀ [PROOFSTEP] exact hf.mul hg.inv [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G x₀ : M hf : ContMDiffAt I' I n f x₀ hg : ContMDiffAt I' I n g x₀ ⊢ ContMDiffAt I' I n (fun x => f x / g x) x₀ [PROOFSTEP] simp_rw [div_eq_mul_inv] [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G x₀ : M hf : ContMDiffAt I' I n f x₀ hg : ContMDiffAt I' I n g x₀ ⊢ ContMDiffAt I' I n (fun x => f x * (g x)⁻¹) x₀ [PROOFSTEP] exact hf.mul hg.inv [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G s : Set M hf : ContMDiffOn I' I n f s hg : ContMDiffOn I' I n g s ⊢ ContMDiffOn I' I n (fun x => f x / g x) s [PROOFSTEP] simp_rw [div_eq_mul_inv] [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G s : Set M hf : ContMDiffOn I' I n f s hg : ContMDiffOn I' I n g s ⊢ ContMDiffOn I' I n (fun x => f x * (g x)⁻¹) s [PROOFSTEP] exact hf.mul hg.inv [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G hf : ContMDiff I' I n f hg : ContMDiff I' I n g ⊢ ContMDiff I' I n fun x => f x / g x [PROOFSTEP] simp_rw [div_eq_mul_inv] [GOAL] 𝕜 : Type u_1 inst✝¹⁹ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹⁸ : TopologicalSpace H E : Type u_3 inst✝¹⁷ : NormedAddCommGroup E inst✝¹⁶ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H F : Type u_4 inst✝¹⁵ : NormedAddCommGroup F inst✝¹⁴ : NormedSpace 𝕜 F J : ModelWithCorners 𝕜 F F G : Type u_5 inst✝¹³ : TopologicalSpace G inst✝¹² : ChartedSpace H G inst✝¹¹ : Group G inst✝¹⁰ : LieGroup I G E' : Type u_6 inst✝⁹ : NormedAddCommGroup E' inst✝⁸ : NormedSpace 𝕜 E' H' : Type u_7 inst✝⁷ : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_8 inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H' M E'' : Type u_9 inst✝⁴ : NormedAddCommGroup E'' inst✝³ : NormedSpace 𝕜 E'' H'' : Type u_10 inst✝² : TopologicalSpace H'' I'' : ModelWithCorners 𝕜 E'' H'' M' : Type u_11 inst✝¹ : TopologicalSpace M' inst✝ : ChartedSpace H'' M' n : ℕ∞ f g : M → G hf : ContMDiff I' I n f hg : ContMDiff I' I n g ⊢ ContMDiff I' I n fun x => f x * (g x)⁻¹ [PROOFSTEP] exact hf.mul hg.inv [GOAL] 𝕜 : Type u_1 inst✝¹ : NontriviallyNormedField 𝕜 inst✝ : CompleteSpace 𝕜 ⊢ ∀ ⦃x : 𝕜⦄, x ≠ 0 → SmoothAt 𝓘(𝕜, 𝕜) 𝓘(𝕜, 𝕜) (fun y => y⁻¹) x [PROOFSTEP] intro x hx [GOAL] 𝕜 : Type u_1 inst✝¹ : NontriviallyNormedField 𝕜 inst✝ : CompleteSpace 𝕜 x : 𝕜 hx : x ≠ 0 ⊢ SmoothAt 𝓘(𝕜, 𝕜) 𝓘(𝕜, 𝕜) (fun y => y⁻¹) x [PROOFSTEP] change ContMDiffAt 𝓘(𝕜) 𝓘(𝕜) ⊤ Inv.inv x [GOAL] 𝕜 : Type u_1 inst✝¹ : NontriviallyNormedField 𝕜 inst✝ : CompleteSpace 𝕜 x : 𝕜 hx : x ≠ 0 ⊢ ContMDiffAt 𝓘(𝕜, 𝕜) 𝓘(𝕜, 𝕜) ⊤ Inv.inv x [PROOFSTEP] rw [contMDiffAt_iff_contDiffAt] [GOAL] 𝕜 : Type u_1 inst✝¹ : NontriviallyNormedField 𝕜 inst✝ : CompleteSpace 𝕜 x : 𝕜 hx : x ≠ 0 ⊢ ContDiffAt 𝕜 ⊤ Inv.inv x [PROOFSTEP] exact contDiffAt_inv 𝕜 hx [GOAL] 𝕜 : Type u_1 inst✝¹³ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹² : TopologicalSpace H E : Type u_3 inst✝¹¹ : NormedAddCommGroup E inst✝¹⁰ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H G : Type u_4 inst✝⁹ : TopologicalSpace G inst✝⁸ : ChartedSpace H G inst✝⁷ : GroupWithZero G inst✝⁶ : SmoothInv₀ I G inst✝⁵ : SmoothMul I G E' : Type u_5 inst✝⁴ : NormedAddCommGroup E' inst✝³ : NormedSpace 𝕜 E' H' : Type u_6 inst✝² : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_7 inst✝¹ : TopologicalSpace M inst✝ : ChartedSpace H' M f g : M → G n : ℕ∞ s : Set M a : M hf : ContMDiffWithinAt I' I n f s a hg : ContMDiffWithinAt I' I n g s a h₀ : g a ≠ 0 ⊢ ContMDiffWithinAt I' I n (f / g) s a [PROOFSTEP] simpa [div_eq_mul_inv] using hf.mul (hg.inv₀ h₀) [GOAL] 𝕜 : Type u_1 inst✝¹³ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹² : TopologicalSpace H E : Type u_3 inst✝¹¹ : NormedAddCommGroup E inst✝¹⁰ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H G : Type u_4 inst✝⁹ : TopologicalSpace G inst✝⁸ : ChartedSpace H G inst✝⁷ : GroupWithZero G inst✝⁶ : SmoothInv₀ I G inst✝⁵ : SmoothMul I G E' : Type u_5 inst✝⁴ : NormedAddCommGroup E' inst✝³ : NormedSpace 𝕜 E' H' : Type u_6 inst✝² : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_7 inst✝¹ : TopologicalSpace M inst✝ : ChartedSpace H' M f g : M → G n : ℕ∞ s : Set M hf : ContMDiffOn I' I n f s hg : ContMDiffOn I' I n g s h₀ : ∀ (x : M), x ∈ s → g x ≠ 0 ⊢ ContMDiffOn I' I n (f / g) s [PROOFSTEP] simpa [div_eq_mul_inv] using hf.mul (hg.inv₀ h₀) [GOAL] 𝕜 : Type u_1 inst✝¹³ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹² : TopologicalSpace H E : Type u_3 inst✝¹¹ : NormedAddCommGroup E inst✝¹⁰ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H G : Type u_4 inst✝⁹ : TopologicalSpace G inst✝⁸ : ChartedSpace H G inst✝⁷ : GroupWithZero G inst✝⁶ : SmoothInv₀ I G inst✝⁵ : SmoothMul I G E' : Type u_5 inst✝⁴ : NormedAddCommGroup E' inst✝³ : NormedSpace 𝕜 E' H' : Type u_6 inst✝² : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_7 inst✝¹ : TopologicalSpace M inst✝ : ChartedSpace H' M f g : M → G n : ℕ∞ a : M hf : ContMDiffAt I' I n f a hg : ContMDiffAt I' I n g a h₀ : g a ≠ 0 ⊢ ContMDiffAt I' I n (f / g) a [PROOFSTEP] simpa [div_eq_mul_inv] using hf.mul (hg.inv₀ h₀) [GOAL] 𝕜 : Type u_1 inst✝¹³ : NontriviallyNormedField 𝕜 H : Type u_2 inst✝¹² : TopologicalSpace H E : Type u_3 inst✝¹¹ : NormedAddCommGroup E inst✝¹⁰ : NormedSpace 𝕜 E I : ModelWithCorners 𝕜 E H G : Type u_4 inst✝⁹ : TopologicalSpace G inst✝⁸ : ChartedSpace H G inst✝⁷ : GroupWithZero G inst✝⁶ : SmoothInv₀ I G inst✝⁵ : SmoothMul I G E' : Type u_5 inst✝⁴ : NormedAddCommGroup E' inst✝³ : NormedSpace 𝕜 E' H' : Type u_6 inst✝² : TopologicalSpace H' I' : ModelWithCorners 𝕜 E' H' M : Type u_7 inst✝¹ : TopologicalSpace M inst✝ : ChartedSpace H' M f g : M → G n : ℕ∞ hf : ContMDiff I' I n f hg : ContMDiff I' I n g h₀ : ∀ (x : M), g x ≠ 0 ⊢ ContMDiff I' I n (f / g) [PROOFSTEP] simpa only [div_eq_mul_inv] using hf.mul (hg.inv₀ h₀)
module Text.Greek.SBLGNT.2Thess where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β : List (Word) ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β = word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "2Thess.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1" ∷ word (Σ ∷ ι ∷ ∙λ ∷ ο ∷ υ ∷ α ∷ ν ∷ ὸ ∷ ς ∷ []) "2Thess.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1" ∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ς ∷ []) "2Thess.1.1" ∷ word (τ ∷ ῇ ∷ []) "2Thess.1.1" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "2Thess.1.1" ∷ word (Θ ∷ ε ∷ σ ∷ σ ∷ α ∷ ∙λ ∷ ο ∷ ν ∷ ι ∷ κ ∷ έ ∷ ω ∷ ν ∷ []) "2Thess.1.1" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.1" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.1" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "2Thess.1.1" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "2Thess.1.1" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2Thess.1.2" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.2" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "2Thess.1.2" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.2" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.2" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.2" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.2" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.2" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.2" ∷ word (Ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "2Thess.1.3" ∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.1.3" ∷ word (τ ∷ ῷ ∷ []) "2Thess.1.3" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.3" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.1.3" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.1.3" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.1.3" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2Thess.1.3" ∷ word (ἄ ∷ ξ ∷ ι ∷ ό ∷ ν ∷ []) "2Thess.1.3" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.1.3" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.1.3" ∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ α ∷ υ ∷ ξ ∷ ά ∷ ν ∷ ε ∷ ι ∷ []) "2Thess.1.3" ∷ word (ἡ ∷ []) "2Thess.1.3" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "2Thess.1.3" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.3" ∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ά ∷ ζ ∷ ε ∷ ι ∷ []) "2Thess.1.3" ∷ word (ἡ ∷ []) "2Thess.1.3" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "2Thess.1.3" ∷ word (ἑ ∷ ν ∷ ὸ ∷ ς ∷ []) "2Thess.1.3" ∷ word (ἑ ∷ κ ∷ ά ∷ σ ∷ τ ∷ ο ∷ υ ∷ []) "2Thess.1.3" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.1.3" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.3" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.1.3" ∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "2Thess.1.4" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.4" ∷ word (ἐ ∷ γ ∷ κ ∷ α ∷ υ ∷ χ ∷ ᾶ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.1.4" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4" ∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "2Thess.1.4" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.4" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.4" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.1.4" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ῆ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.4" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.4" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.4" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.4" ∷ word (δ ∷ ι ∷ ω ∷ γ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.4" ∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "2Thess.1.4" ∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.4" ∷ word (α ∷ ἷ ∷ ς ∷ []) "2Thess.1.4" ∷ word (ἀ ∷ ν ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.1.4" ∷ word (ἔ ∷ ν ∷ δ ∷ ε ∷ ι ∷ γ ∷ μ ∷ α ∷ []) "2Thess.1.5" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.5" ∷ word (δ ∷ ι ∷ κ ∷ α ∷ ί ∷ α ∷ ς ∷ []) "2Thess.1.5" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.5" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.5" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.5" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.5" ∷ word (τ ∷ ὸ ∷ []) "2Thess.1.5" ∷ word (κ ∷ α ∷ τ ∷ α ∷ ξ ∷ ι ∷ ω ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.5" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.5" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.5" ∷ word (β ∷ α ∷ σ ∷ ι ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.1.5" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.5" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.5" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.1.5" ∷ word (ἧ ∷ ς ∷ []) "2Thess.1.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.5" ∷ word (π ∷ ά ∷ σ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.1.5" ∷ word (ε ∷ ἴ ∷ π ∷ ε ∷ ρ ∷ []) "2Thess.1.6" ∷ word (δ ∷ ί ∷ κ ∷ α ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.6" ∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "2Thess.1.6" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.6" ∷ word (ἀ ∷ ν ∷ τ ∷ α ∷ π ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.6" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.6" ∷ word (θ ∷ ∙λ ∷ ί ∷ β ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.6" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.6" ∷ word (θ ∷ ∙λ ∷ ῖ ∷ ψ ∷ ι ∷ ν ∷ []) "2Thess.1.6" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.7" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.7" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.7" ∷ word (θ ∷ ∙λ ∷ ι ∷ β ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.1.7" ∷ word (ἄ ∷ ν ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.7" ∷ word (μ ∷ ε ∷ θ ∷ []) "2Thess.1.7" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.7" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.7" ∷ word (τ ∷ ῇ ∷ []) "2Thess.1.7" ∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ ύ ∷ ψ ∷ ε ∷ ι ∷ []) "2Thess.1.7" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.7" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7" ∷ word (ἀ ∷ π ∷ []) "2Thess.1.7" ∷ word (ο ∷ ὐ ∷ ρ ∷ α ∷ ν ∷ ο ∷ ῦ ∷ []) "2Thess.1.7" ∷ word (μ ∷ ε ∷ τ ∷ []) "2Thess.1.7" ∷ word (ἀ ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ω ∷ ν ∷ []) "2Thess.1.7" ∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.7" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.8" ∷ word (φ ∷ ∙λ ∷ ο ∷ γ ∷ ὶ ∷ []) "2Thess.1.8" ∷ word (π ∷ υ ∷ ρ ∷ ό ∷ ς ∷ []) "2Thess.1.8" ∷ word (δ ∷ ι ∷ δ ∷ ό ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.1.8" ∷ word (ἐ ∷ κ ∷ δ ∷ ί ∷ κ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.8" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.8" ∷ word (μ ∷ ὴ ∷ []) "2Thess.1.8" ∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ σ ∷ ι ∷ []) "2Thess.1.8" ∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2Thess.1.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.8" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.8" ∷ word (μ ∷ ὴ ∷ []) "2Thess.1.8" ∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.8" ∷ word (τ ∷ ῷ ∷ []) "2Thess.1.8" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ῳ ∷ []) "2Thess.1.8" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.8" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.8" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.8" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.8" ∷ word (ο ∷ ἵ ∷ τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "2Thess.1.9" ∷ word (δ ∷ ί ∷ κ ∷ η ∷ ν ∷ []) "2Thess.1.9" ∷ word (τ ∷ ί ∷ σ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.9" ∷ word (ὄ ∷ ∙λ ∷ ε ∷ θ ∷ ρ ∷ ο ∷ ν ∷ []) "2Thess.1.9" ∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.9" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.9" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ώ ∷ π ∷ ο ∷ υ ∷ []) "2Thess.1.9" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.9" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.9" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.9" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.9" ∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "2Thess.1.9" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.9" ∷ word (ἰ ∷ σ ∷ χ ∷ ύ ∷ ο ∷ ς ∷ []) "2Thess.1.9" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.9" ∷ word (ὅ ∷ τ ∷ α ∷ ν ∷ []) "2Thess.1.10" ∷ word (ἔ ∷ ∙λ ∷ θ ∷ ῃ ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ ν ∷ δ ∷ ο ∷ ξ ∷ α ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.10" ∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.1.10" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.10" ∷ word (θ ∷ α ∷ υ ∷ μ ∷ α ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.10" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.10" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.10" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ θ ∷ η ∷ []) "2Thess.1.10" ∷ word (τ ∷ ὸ ∷ []) "2Thess.1.10" ∷ word (μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.10" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ φ ∷ []) "2Thess.1.10" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10" ∷ word (τ ∷ ῇ ∷ []) "2Thess.1.10" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ ᾳ ∷ []) "2Thess.1.10" ∷ word (ἐ ∷ κ ∷ ε ∷ ί ∷ ν ∷ ῃ ∷ []) "2Thess.1.10" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.11" ∷ word (ὃ ∷ []) "2Thess.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ό ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "2Thess.1.11" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.1.11" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.1.11" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.11" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.1.11" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.11" ∷ word (ἀ ∷ ξ ∷ ι ∷ ώ ∷ σ ∷ ῃ ∷ []) "2Thess.1.11" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.11" ∷ word (κ ∷ ∙λ ∷ ή ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.11" ∷ word (ὁ ∷ []) "2Thess.1.11" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.1.11" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11" ∷ word (π ∷ ∙λ ∷ η ∷ ρ ∷ ώ ∷ σ ∷ ῃ ∷ []) "2Thess.1.11" ∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "2Thess.1.11" ∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.1.11" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ω ∷ σ ∷ ύ ∷ ν ∷ η ∷ ς ∷ []) "2Thess.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11" ∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "2Thess.1.11" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.11" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.11" ∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "2Thess.1.11" ∷ word (ὅ ∷ π ∷ ω ∷ ς ∷ []) "2Thess.1.12" ∷ word (ἐ ∷ ν ∷ δ ∷ ο ∷ ξ ∷ α ∷ σ ∷ θ ∷ ῇ ∷ []) "2Thess.1.12" ∷ word (τ ∷ ὸ ∷ []) "2Thess.1.12" ∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "2Thess.1.12" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.12" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.12" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.12" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.12" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.1.12" ∷ word (ἐ ∷ ν ∷ []) "2Thess.1.12" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2Thess.1.12" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.1.12" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.1.12" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "2Thess.1.12" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.12" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.12" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.12" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12" ∷ word (Ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.2.1" ∷ word (δ ∷ ὲ ∷ []) "2Thess.2.1" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.2.1" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.2.1" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.1" ∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.1" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.1" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.1" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.1" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ υ ∷ ν ∷ α ∷ γ ∷ ω ∷ γ ∷ ῆ ∷ ς ∷ []) "2Thess.2.1" ∷ word (ἐ ∷ π ∷ []) "2Thess.2.1" ∷ word (α ∷ ὐ ∷ τ ∷ ό ∷ ν ∷ []) "2Thess.2.1" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.2" ∷ word (τ ∷ ὸ ∷ []) "2Thess.2.2" ∷ word (μ ∷ ὴ ∷ []) "2Thess.2.2" ∷ word (τ ∷ α ∷ χ ∷ έ ∷ ω ∷ ς ∷ []) "2Thess.2.2" ∷ word (σ ∷ α ∷ ∙λ ∷ ε ∷ υ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.2" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.2" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.2.2" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.2" ∷ word (ν ∷ ο ∷ ὸ ∷ ς ∷ []) "2Thess.2.2" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "2Thess.2.2" ∷ word (θ ∷ ρ ∷ ο ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.2.2" ∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.2" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.2" ∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.2" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "2Thess.2.2" ∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2" ∷ word (δ ∷ ι ∷ []) "2Thess.2.2" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.2.2" ∷ word (ὡ ∷ ς ∷ []) "2Thess.2.2" ∷ word (δ ∷ ι ∷ []) "2Thess.2.2" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.2" ∷ word (ὡ ∷ ς ∷ []) "2Thess.2.2" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.2" ∷ word (ἐ ∷ ν ∷ έ ∷ σ ∷ τ ∷ η ∷ κ ∷ ε ∷ ν ∷ []) "2Thess.2.2" ∷ word (ἡ ∷ []) "2Thess.2.2" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ []) "2Thess.2.2" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.2" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.2" ∷ word (μ ∷ ή ∷ []) "2Thess.2.3" ∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.2.3" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.3" ∷ word (ἐ ∷ ξ ∷ α ∷ π ∷ α ∷ τ ∷ ή ∷ σ ∷ ῃ ∷ []) "2Thess.2.3" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.2.3" ∷ word (μ ∷ η ∷ δ ∷ έ ∷ ν ∷ α ∷ []) "2Thess.2.3" ∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ο ∷ ν ∷ []) "2Thess.2.3" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.3" ∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "2Thess.2.3" ∷ word (μ ∷ ὴ ∷ []) "2Thess.2.3" ∷ word (ἔ ∷ ∙λ ∷ θ ∷ ῃ ∷ []) "2Thess.2.3" ∷ word (ἡ ∷ []) "2Thess.2.3" ∷ word (ἀ ∷ π ∷ ο ∷ σ ∷ τ ∷ α ∷ σ ∷ ί ∷ α ∷ []) "2Thess.2.3" ∷ word (π ∷ ρ ∷ ῶ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.2.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.3" ∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ῇ ∷ []) "2Thess.2.3" ∷ word (ὁ ∷ []) "2Thess.2.3" ∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ς ∷ []) "2Thess.2.3" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.3" ∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.3" ∷ word (ὁ ∷ []) "2Thess.2.3" ∷ word (υ ∷ ἱ ∷ ὸ ∷ ς ∷ []) "2Thess.2.3" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.3" ∷ word (ἀ ∷ π ∷ ω ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.3" ∷ word (ὁ ∷ []) "2Thess.2.4" ∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ κ ∷ ε ∷ ί ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.2.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.4" ∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ α ∷ ι ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.2.4" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "2Thess.2.4" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "2Thess.2.4" ∷ word (∙λ ∷ ε ∷ γ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "2Thess.2.4" ∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2Thess.2.4" ∷ word (ἢ ∷ []) "2Thess.2.4" ∷ word (σ ∷ έ ∷ β ∷ α ∷ σ ∷ μ ∷ α ∷ []) "2Thess.2.4" ∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "2Thess.2.4" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.4" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4" ∷ word (ν ∷ α ∷ ὸ ∷ ν ∷ []) "2Thess.2.4" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.4" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.2.4" ∷ word (κ ∷ α ∷ θ ∷ ί ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.4" ∷ word (ἀ ∷ π ∷ ο ∷ δ ∷ ε ∷ ι ∷ κ ∷ ν ∷ ύ ∷ ν ∷ τ ∷ α ∷ []) "2Thess.2.4" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.4" ∷ word (ἔ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.2.4" ∷ word (θ ∷ ε ∷ ό ∷ ς ∷ []) "2Thess.2.4" ∷ word (ο ∷ ὐ ∷ []) "2Thess.2.5" ∷ word (μ ∷ ν ∷ η ∷ μ ∷ ο ∷ ν ∷ ε ∷ ύ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.2.5" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.5" ∷ word (ἔ ∷ τ ∷ ι ∷ []) "2Thess.2.5" ∷ word (ὢ ∷ ν ∷ []) "2Thess.2.5" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.2.5" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.5" ∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "2Thess.2.5" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ ο ∷ ν ∷ []) "2Thess.2.5" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.2.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.6" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "2Thess.2.6" ∷ word (τ ∷ ὸ ∷ []) "2Thess.2.6" ∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ο ∷ ν ∷ []) "2Thess.2.6" ∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "2Thess.2.6" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.6" ∷ word (τ ∷ ὸ ∷ []) "2Thess.2.6" ∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.6" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.6" ∷ word (ἐ ∷ ν ∷ []) "2Thess.2.6" ∷ word (τ ∷ ῷ ∷ []) "2Thess.2.6" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.6" ∷ word (κ ∷ α ∷ ι ∷ ρ ∷ ῷ ∷ []) "2Thess.2.6" ∷ word (τ ∷ ὸ ∷ []) "2Thess.2.7" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.2.7" ∷ word (μ ∷ υ ∷ σ ∷ τ ∷ ή ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.2.7" ∷ word (ἤ ∷ δ ∷ η ∷ []) "2Thess.2.7" ∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ε ∷ ῖ ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.7" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.7" ∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.7" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "2Thess.2.7" ∷ word (ὁ ∷ []) "2Thess.2.7" ∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ω ∷ ν ∷ []) "2Thess.2.7" ∷ word (ἄ ∷ ρ ∷ τ ∷ ι ∷ []) "2Thess.2.7" ∷ word (ἕ ∷ ω ∷ ς ∷ []) "2Thess.2.7" ∷ word (ἐ ∷ κ ∷ []) "2Thess.2.7" ∷ word (μ ∷ έ ∷ σ ∷ ο ∷ υ ∷ []) "2Thess.2.7" ∷ word (γ ∷ έ ∷ ν ∷ η ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.8" ∷ word (τ ∷ ό ∷ τ ∷ ε ∷ []) "2Thess.2.8" ∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ή ∷ σ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.8" ∷ word (ὁ ∷ []) "2Thess.2.8" ∷ word (ἄ ∷ ν ∷ ο ∷ μ ∷ ο ∷ ς ∷ []) "2Thess.2.8" ∷ word (ὃ ∷ ν ∷ []) "2Thess.2.8" ∷ word (ὁ ∷ []) "2Thess.2.8" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.2.8" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "2Thess.2.8" ∷ word (ἀ ∷ ν ∷ ε ∷ ∙λ ∷ ε ∷ ῖ ∷ []) "2Thess.2.8" ∷ word (τ ∷ ῷ ∷ []) "2Thess.2.8" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "2Thess.2.8" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.8" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.8" ∷ word (κ ∷ α ∷ τ ∷ α ∷ ρ ∷ γ ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "2Thess.2.8" ∷ word (τ ∷ ῇ ∷ []) "2Thess.2.8" ∷ word (ἐ ∷ π ∷ ι ∷ φ ∷ α ∷ ν ∷ ε ∷ ί ∷ ᾳ ∷ []) "2Thess.2.8" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.8" ∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.8" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8" ∷ word (ο ∷ ὗ ∷ []) "2Thess.2.9" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.2.9" ∷ word (ἡ ∷ []) "2Thess.2.9" ∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ []) "2Thess.2.9" ∷ word (κ ∷ α ∷ τ ∷ []) "2Thess.2.9" ∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2Thess.2.9" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.9" ∷ word (Σ ∷ α ∷ τ ∷ α ∷ ν ∷ ᾶ ∷ []) "2Thess.2.9" ∷ word (ἐ ∷ ν ∷ []) "2Thess.2.9" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.2.9" ∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "2Thess.2.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.9" ∷ word (σ ∷ η ∷ μ ∷ ε ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.2.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.9" ∷ word (τ ∷ έ ∷ ρ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.9" ∷ word (ψ ∷ ε ∷ ύ ∷ δ ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.2.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.10" ∷ word (ἐ ∷ ν ∷ []) "2Thess.2.10" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.2.10" ∷ word (ἀ ∷ π ∷ ά ∷ τ ∷ ῃ ∷ []) "2Thess.2.10" ∷ word (ἀ ∷ δ ∷ ι ∷ κ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.10" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.2.10" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ∙λ ∷ υ ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.2.10" ∷ word (ἀ ∷ ν ∷ θ ∷ []) "2Thess.2.10" ∷ word (ὧ ∷ ν ∷ []) "2Thess.2.10" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.2.10" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "2Thess.2.10" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.10" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.10" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.2.10" ∷ word (ἐ ∷ δ ∷ έ ∷ ξ ∷ α ∷ ν ∷ τ ∷ ο ∷ []) "2Thess.2.10" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.10" ∷ word (τ ∷ ὸ ∷ []) "2Thess.2.10" ∷ word (σ ∷ ω ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.10" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ύ ∷ ς ∷ []) "2Thess.2.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.11" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.11" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "2Thess.2.11" ∷ word (π ∷ έ ∷ μ ∷ π ∷ ε ∷ ι ∷ []) "2Thess.2.11" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.2.11" ∷ word (ὁ ∷ []) "2Thess.2.11" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.11" ∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2Thess.2.11" ∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ η ∷ ς ∷ []) "2Thess.2.11" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.11" ∷ word (τ ∷ ὸ ∷ []) "2Thess.2.11" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῦ ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.11" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.2.11" ∷ word (τ ∷ ῷ ∷ []) "2Thess.2.11" ∷ word (ψ ∷ ε ∷ ύ ∷ δ ∷ ε ∷ ι ∷ []) "2Thess.2.11" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.2.12" ∷ word (κ ∷ ρ ∷ ι ∷ θ ∷ ῶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.12" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12" ∷ word (ο ∷ ἱ ∷ []) "2Thess.2.12" ∷ word (μ ∷ ὴ ∷ []) "2Thess.2.12" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12" ∷ word (τ ∷ ῇ ∷ []) "2Thess.2.12" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "2Thess.2.12" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.2.12" ∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ή ∷ σ ∷ α ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12" ∷ word (τ ∷ ῇ ∷ []) "2Thess.2.12" ∷ word (ἀ ∷ δ ∷ ι ∷ κ ∷ ί ∷ ᾳ ∷ []) "2Thess.2.12" ∷ word (Ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.2.13" ∷ word (δ ∷ ὲ ∷ []) "2Thess.2.13" ∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.2.13" ∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "2Thess.2.13" ∷ word (τ ∷ ῷ ∷ []) "2Thess.2.13" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.2.13" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.2.13" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.2.13" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.13" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὶ ∷ []) "2Thess.2.13" ∷ word (ἠ ∷ γ ∷ α ∷ π ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.2.13" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "2Thess.2.13" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.13" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.13" ∷ word (ε ∷ ἵ ∷ ∙λ ∷ α ∷ τ ∷ ο ∷ []) "2Thess.2.13" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.13" ∷ word (ὁ ∷ []) "2Thess.2.13" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.13" ∷ word (ἀ ∷ π ∷ α ∷ ρ ∷ χ ∷ ὴ ∷ ν ∷ []) "2Thess.2.13" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.13" ∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.2.13" ∷ word (ἐ ∷ ν ∷ []) "2Thess.2.13" ∷ word (ἁ ∷ γ ∷ ι ∷ α ∷ σ ∷ μ ∷ ῷ ∷ []) "2Thess.2.13" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.13" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.13" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "2Thess.2.13" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.13" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.14" ∷ word (ὃ ∷ []) "2Thess.2.14" ∷ word (ἐ ∷ κ ∷ ά ∷ ∙λ ∷ ε ∷ σ ∷ ε ∷ ν ∷ []) "2Thess.2.14" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.14" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.14" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.14" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.14" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.14" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ ο ∷ ί ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.14" ∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "2Thess.2.14" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.14" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.14" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14" ∷ word (ἄ ∷ ρ ∷ α ∷ []) "2Thess.2.15" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "2Thess.2.15" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.2.15" ∷ word (σ ∷ τ ∷ ή ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.2.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.15" ∷ word (κ ∷ ρ ∷ α ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.2.15" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.2.15" ∷ word (π ∷ α ∷ ρ ∷ α ∷ δ ∷ ό ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "2Thess.2.15" ∷ word (ἃ ∷ ς ∷ []) "2Thess.2.15" ∷ word (ἐ ∷ δ ∷ ι ∷ δ ∷ ά ∷ χ ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "2Thess.2.15" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "2Thess.2.15" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.15" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "2Thess.2.15" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "2Thess.2.15" ∷ word (δ ∷ ι ∷ []) "2Thess.2.15" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.2.15" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.15" ∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.2.16" ∷ word (δ ∷ ὲ ∷ []) "2Thess.2.16" ∷ word (ὁ ∷ []) "2Thess.2.16" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.2.16" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.16" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "2Thess.2.16" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.2.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.16" ∷ word (ὁ ∷ []) "2Thess.2.16" ∷ word (π ∷ α ∷ τ ∷ ὴ ∷ ρ ∷ []) "2Thess.2.16" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.16" ∷ word (ὁ ∷ []) "2Thess.2.16" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ή ∷ σ ∷ α ∷ ς ∷ []) "2Thess.2.16" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16" ∷ word (δ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.2.16" ∷ word (π ∷ α ∷ ρ ∷ ά ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.16" ∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ α ∷ ν ∷ []) "2Thess.2.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16" ∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "2Thess.2.16" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὴ ∷ ν ∷ []) "2Thess.2.16" ∷ word (ἐ ∷ ν ∷ []) "2Thess.2.16" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ ι ∷ []) "2Thess.2.16" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ έ ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.17" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.17" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.2.17" ∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.17" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.17" ∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ α ∷ ι ∷ []) "2Thess.2.17" ∷ word (ἐ ∷ ν ∷ []) "2Thess.2.17" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "2Thess.2.17" ∷ word (ἔ ∷ ρ ∷ γ ∷ ῳ ∷ []) "2Thess.2.17" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.17" ∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "2Thess.2.17" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ῷ ∷ []) "2Thess.2.17" ∷ word (Τ ∷ ὸ ∷ []) "2Thess.3.1" ∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ὸ ∷ ν ∷ []) "2Thess.3.1" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ ύ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.1" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.3.1" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.1" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.1" ∷ word (ὁ ∷ []) "2Thess.3.1" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ς ∷ []) "2Thess.3.1" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.1" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.1" ∷ word (τ ∷ ρ ∷ έ ∷ χ ∷ ῃ ∷ []) "2Thess.3.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.1" ∷ word (δ ∷ ο ∷ ξ ∷ ά ∷ ζ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "2Thess.3.1" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2Thess.3.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.1" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.1" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.2" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.2" ∷ word (ῥ ∷ υ ∷ σ ∷ θ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.2" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.2" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "2Thess.3.2" ∷ word (ἀ ∷ τ ∷ ό ∷ π ∷ ω ∷ ν ∷ []) "2Thess.3.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.2" ∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ῶ ∷ ν ∷ []) "2Thess.3.2" ∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "2Thess.3.2" ∷ word (ο ∷ ὐ ∷ []) "2Thess.3.2" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.2" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.2" ∷ word (ἡ ∷ []) "2Thess.3.2" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "2Thess.3.2" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.3" ∷ word (δ ∷ έ ∷ []) "2Thess.3.3" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.3.3" ∷ word (ὁ ∷ []) "2Thess.3.3" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.3" ∷ word (ὃ ∷ ς ∷ []) "2Thess.3.3" ∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ ε ∷ ι ∷ []) "2Thess.3.3" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.3" ∷ word (φ ∷ υ ∷ ∙λ ∷ ά ∷ ξ ∷ ε ∷ ι ∷ []) "2Thess.3.3" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.3" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.3" ∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῦ ∷ []) "2Thess.3.3" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ί ∷ θ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.4" ∷ word (δ ∷ ὲ ∷ []) "2Thess.3.4" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.4" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.3.4" ∷ word (ἐ ∷ φ ∷ []) "2Thess.3.4" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.4" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.4" ∷ word (ἃ ∷ []) "2Thess.3.4" ∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.4" ∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.3.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.4" ∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.3.4" ∷ word (ὁ ∷ []) "2Thess.3.5" ∷ word (δ ∷ ὲ ∷ []) "2Thess.3.5" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.5" ∷ word (κ ∷ α ∷ τ ∷ ε ∷ υ ∷ θ ∷ ύ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.3.5" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.5" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.3.5" ∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.3.5" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.5" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.5" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "2Thess.3.5" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.3.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.5" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.5" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.5" ∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ὴ ∷ ν ∷ []) "2Thess.3.5" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5" ∷ word (Π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.6" ∷ word (δ ∷ ὲ ∷ []) "2Thess.3.6" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.6" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.6" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.6" ∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "2Thess.3.6" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.6" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.6" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6" ∷ word (σ ∷ τ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.6" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.6" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.6" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.6" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6" ∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.6" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.3.6" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.6" ∷ word (μ ∷ ὴ ∷ []) "2Thess.3.6" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.3.6" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.6" ∷ word (π ∷ α ∷ ρ ∷ ά ∷ δ ∷ ο ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.3.6" ∷ word (ἣ ∷ ν ∷ []) "2Thess.3.6" ∷ word (π ∷ α ∷ ρ ∷ ε ∷ ∙λ ∷ ά ∷ β ∷ ο ∷ σ ∷ α ∷ ν ∷ []) "2Thess.3.6" ∷ word (π ∷ α ∷ ρ ∷ []) "2Thess.3.6" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.6" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "2Thess.3.7" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.7" ∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "2Thess.3.7" ∷ word (π ∷ ῶ ∷ ς ∷ []) "2Thess.3.7" ∷ word (δ ∷ ε ∷ ῖ ∷ []) "2Thess.3.7" ∷ word (μ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.7" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.7" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.7" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.3.7" ∷ word (ἠ ∷ τ ∷ α ∷ κ ∷ τ ∷ ή ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.7" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.7" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.7" ∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "2Thess.3.8" ∷ word (δ ∷ ω ∷ ρ ∷ ε ∷ ὰ ∷ ν ∷ []) "2Thess.3.8" ∷ word (ἄ ∷ ρ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.8" ∷ word (ἐ ∷ φ ∷ ά ∷ γ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.8" ∷ word (π ∷ α ∷ ρ ∷ ά ∷ []) "2Thess.3.8" ∷ word (τ ∷ ι ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.3.8" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "2Thess.3.8" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.8" ∷ word (κ ∷ ό ∷ π ∷ ῳ ∷ []) "2Thess.3.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.8" ∷ word (μ ∷ ό ∷ χ ∷ θ ∷ ῳ ∷ []) "2Thess.3.8" ∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.8" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "2Thess.3.8" ∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.3.8" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.8" ∷ word (τ ∷ ὸ ∷ []) "2Thess.3.8" ∷ word (μ ∷ ὴ ∷ []) "2Thess.3.8" ∷ word (ἐ ∷ π ∷ ι ∷ β ∷ α ∷ ρ ∷ ῆ ∷ σ ∷ α ∷ ί ∷ []) "2Thess.3.8" ∷ word (τ ∷ ι ∷ ν ∷ α ∷ []) "2Thess.3.8" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.8" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "2Thess.3.9" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.9" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.3.9" ∷ word (ἔ ∷ χ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.9" ∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.3.9" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "2Thess.3.9" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.9" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.3.9" ∷ word (τ ∷ ύ ∷ π ∷ ο ∷ ν ∷ []) "2Thess.3.9" ∷ word (δ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.9" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.9" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.9" ∷ word (τ ∷ ὸ ∷ []) "2Thess.3.9" ∷ word (μ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.9" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.10" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.10" ∷ word (ὅ ∷ τ ∷ ε ∷ []) "2Thess.3.10" ∷ word (ἦ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.10" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.10" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.10" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "2Thess.3.10" ∷ word (π ∷ α ∷ ρ ∷ η ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.10" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.10" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.10" ∷ word (ε ∷ ἴ ∷ []) "2Thess.3.10" ∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.3.10" ∷ word (ο ∷ ὐ ∷ []) "2Thess.3.10" ∷ word (θ ∷ έ ∷ ∙λ ∷ ε ∷ ι ∷ []) "2Thess.3.10" ∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.10" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "2Thess.3.10" ∷ word (ἐ ∷ σ ∷ θ ∷ ι ∷ έ ∷ τ ∷ ω ∷ []) "2Thess.3.10" ∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.11" ∷ word (γ ∷ ά ∷ ρ ∷ []) "2Thess.3.11" ∷ word (τ ∷ ι ∷ ν ∷ α ∷ ς ∷ []) "2Thess.3.11" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "2Thess.3.11" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.11" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.11" ∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.11" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "2Thess.3.11" ∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.3.11" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.3.11" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ε ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.3.11" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.3.12" ∷ word (δ ∷ ὲ ∷ []) "2Thess.3.12" ∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.3.12" ∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.12" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.12" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.12" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.3.12" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.12" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "2Thess.3.12" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.12" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.12" ∷ word (ἡ ∷ σ ∷ υ ∷ χ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.3.12" ∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.3.12" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "2Thess.3.12" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "2Thess.3.12" ∷ word (ἄ ∷ ρ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.12" ∷ word (ἐ ∷ σ ∷ θ ∷ ί ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.3.12" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.3.13" ∷ word (δ ∷ έ ∷ []) "2Thess.3.13" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.13" ∷ word (μ ∷ ὴ ∷ []) "2Thess.3.13" ∷ word (ἐ ∷ γ ∷ κ ∷ α ∷ κ ∷ ή ∷ σ ∷ η ∷ τ ∷ ε ∷ []) "2Thess.3.13" ∷ word (κ ∷ α ∷ ∙λ ∷ ο ∷ π ∷ ο ∷ ι ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.3.13" ∷ word (Ε ∷ ἰ ∷ []) "2Thess.3.14" ∷ word (δ ∷ έ ∷ []) "2Thess.3.14" ∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.3.14" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "2Thess.3.14" ∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ύ ∷ ε ∷ ι ∷ []) "2Thess.3.14" ∷ word (τ ∷ ῷ ∷ []) "2Thess.3.14" ∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "2Thess.3.14" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.14" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.3.14" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.3.14" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.3.14" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.14" ∷ word (σ ∷ η ∷ μ ∷ ε ∷ ι ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.14" ∷ word (μ ∷ ὴ ∷ []) "2Thess.3.14" ∷ word (σ ∷ υ ∷ ν ∷ α ∷ ν ∷ α ∷ μ ∷ ί ∷ γ ∷ ν ∷ υ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.14" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2Thess.3.14" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.14" ∷ word (ἐ ∷ ν ∷ τ ∷ ρ ∷ α ∷ π ∷ ῇ ∷ []) "2Thess.3.14" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.15" ∷ word (μ ∷ ὴ ∷ []) "2Thess.3.15" ∷ word (ὡ ∷ ς ∷ []) "2Thess.3.15" ∷ word (ἐ ∷ χ ∷ θ ∷ ρ ∷ ὸ ∷ ν ∷ []) "2Thess.3.15" ∷ word (ἡ ∷ γ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.15" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.3.15" ∷ word (ν ∷ ο ∷ υ ∷ θ ∷ ε ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.3.15" ∷ word (ὡ ∷ ς ∷ []) "2Thess.3.15" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ό ∷ ν ∷ []) "2Thess.3.15" ∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.16" ∷ word (δ ∷ ὲ ∷ []) "2Thess.3.16" ∷ word (ὁ ∷ []) "2Thess.3.16" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.16" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.3.16" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ς ∷ []) "2Thess.3.16" ∷ word (δ ∷ ῴ ∷ η ∷ []) "2Thess.3.16" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.16" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.16" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ν ∷ []) "2Thess.3.16" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.3.16" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.16" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.16" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "2Thess.3.16" ∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ῳ ∷ []) "2Thess.3.16" ∷ word (ὁ ∷ []) "2Thess.3.16" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.16" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.16" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.16" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.16" ∷ word (Ὁ ∷ []) "2Thess.3.17" ∷ word (ἀ ∷ σ ∷ π ∷ α ∷ σ ∷ μ ∷ ὸ ∷ ς ∷ []) "2Thess.3.17" ∷ word (τ ∷ ῇ ∷ []) "2Thess.3.17" ∷ word (ἐ ∷ μ ∷ ῇ ∷ []) "2Thess.3.17" ∷ word (χ ∷ ε ∷ ι ∷ ρ ∷ ὶ ∷ []) "2Thess.3.17" ∷ word (Π ∷ α ∷ ύ ∷ ∙λ ∷ ο ∷ υ ∷ []) "2Thess.3.17" ∷ word (ὅ ∷ []) "2Thess.3.17" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.3.17" ∷ word (σ ∷ η ∷ μ ∷ ε ∷ ῖ ∷ ο ∷ ν ∷ []) "2Thess.3.17" ∷ word (ἐ ∷ ν ∷ []) "2Thess.3.17" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.3.17" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῇ ∷ []) "2Thess.3.17" ∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.17" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ω ∷ []) "2Thess.3.17" ∷ word (ἡ ∷ []) "2Thess.3.18" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2Thess.3.18" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.18" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.18" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.18" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.18" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.18" ∷ []
\part{Introduction} \chapter{Overview} \noindent This document is both a user's guide and a reference manual for Stan's probabilistic modeling language. This introductory chapter provides a high-level overview of Stan. The remaining parts of this document include a practically-oriented user's guide for programming models and a detailed reference manual for Stan's modeling language and associated programs and data formats. \section{Stan Home Page} For links to up-to-date code, examples, manuals, bug reports, feature requests, and everything else Stan related, see the Stan home page: % \begin{quote} \url{http://mc-stan.org} \end{quote} \section{Stan Interfaces} There are three interfaces for Stan that are supported as part of the Stan project. Models and their use are the same across the three interfaces, and this manual is the modeling language manual for all three interfaces. All of the interfaces share initialization, sampling and tuning controls, and roughly share posterior analysis functionality. The interfaces all provide getting-started guides, documentation, and full source code. \subsection{CmdStan} CmdStan allows Stan to be run from the command line. In some sense, CmdStan is the reference implementation of Stan. The CmdStan documentation used to be part of this document, but is now its own standalone document. The CmdStan home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/cmdstan.html} \end{quote} \subsection{RStan} RStan is the R interface to Stan. RStan interfaces to Stan through R's memory rather than just calling Stan from the outside, as in the R2WinBUGS and R2jags interfaces on which it was modeled. The RStan home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/rstan.html} \end{quote} \subsection{PyStan} PyStan is the Python interface to Stan. Like RStan, it interfaces at the Python memory level rather than calling Stan from the outside. The PyStan home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/pystan.html} \end{quote} \subsubsection{MatlabStan} MatlabStan is the MATLAB interface to Stan. Unlike RStan and PyStan, MatlabStan currently wraps a CmdStan process. The MatlabStan home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/matlab-stan.html} \end{quote} % \subsubsection{Stan.jl} Stan.jl is the Julia interface to Stan. Like MatlabStan, Stan.jl wraps a CmdStan process. The Stan.jl home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/julia-stan.html} \end{quote} % \subsubsection{StataStan} StataStan is the Stata interface to Stan. Like MatlabStan, Stan.jl wraps a CmdStan process. The StataStan home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/stata-stan.html} \end{quote} \subsubsection{MathematicaStan} MathematicaStan is the Mathematica interface to Stan. Like MatlabStan, MathematicaStan wraps a CmdStan process. The MathematicaStan home page is % \begin{quote} \url{http://mc-stan.org/users/interfaces/mathematica-stan.html} \end{quote} \section{Stan Programs} A Stan program defines a statistical model through a conditional probability function $p(\theta|y,x)$, where $\theta$ is a sequence of modeled unknown values (e.g., model parameters, latent variables, missing data, future predictions), $y$ is a sequence of modeled known values, and $x$ is a sequence of unmodeled predictors and constants (e.g., sizes, hyperparameters). Stan programs consist of variable type declarations and statements. Variable types include constrained and unconstrained integer, scalar, vector, and matrix types, as well as (multidimensional) arrays of other types. Variables are declared in blocks corresponding to the variable's use: data, transformed data, parameter, transformed parameter, or generated quantity. Unconstrained local variables may be declared within statement blocks. The transformed data, transformed parameter, and generated quantities blocks contain statements defining the variables declared in their blocks. A special model block consists of statements defining the log probability for the model. Within the model block, \BUGS-style sampling notation may be used as shorthand for incrementing an underlying log probability variable, the value of which defines the log probability function. The log probability variable may also be accessed directly, allowing user-defined probability functions and Jacobians of transforms. \subsection{Variable Constraints} Variable constraints are very important in Stan, particularly for parameters. For Stan to sample efficiently, any parameter values that satisfy the constraints declared for the parameters must have support in the model block (i.e., must have non-zero posterior density). Constraints in the data and transformed data block are only used for error checking data input and transforms. Constraints in the transformed parameters block must be satisfied the same way as parameter constraints or sampling will devolve to a random walk or fail. Constraints in the generated quantities block must succeed or sampling will be halted altogether because it is too late to reject a draw at the point the generated quantities block is evaluated. \subsection{Execution Order} Statements in Stan are interpreted imperatively, so their order matters. Atomic statements involve the assignment of a value to a variable. Sequences of statements (and optionally local variable declarations) may be organized into a block. Stan also provides bounded for-each loops of the sort used in \R and \BUGS. \subsection{Probabilistic Programming Language} Stan is an imperative probabilistic programming language. It is an instance of a domain-specific language, meaning that it was developed for a specific domain, namely statistical inference. Stan is a probabilistic programming language in the sense that a random variable is a bona fide first-class object. In Stan, variables may be treated as random, and among the random variables, some are observed and some are unknown and need to be estimated or used for posterior predictive inference. Observed random variables are declared as data and unobserved random variables are declared as parameters (including transformed parameters, generated quantities, and local variables depending on them). For the unobserved random variables, it is possible to sample them either marginally or jointly, estimate their means and variance, or plug them in for downstream posterior predictive inference. Stan is an imperative language, like C or Fortran (and parts of \Cpp, R, Python, and Java), in the sense that is based on assignment, loops, conditionals, local variables, object-level function application, and array-like data structures. In contrast and/or complement, functional languages typically allow higher-order functions and often allow reflection of programming language features into the object language, whereas pure functional languages remove assignment altogether. Object-oriented languages introduce more general data types with dynamic function dispatch. Stan's language is Church-Turing complete \cite{Church:1936,Turing:1936,HopcroftMotwani:2006}, in the same way that C or R is. That means any program that is computable on a Turing machine (or in C) can be implemented in Stan (not necessarily easily, of course). All that is required for Turing completeness is loops, conditionals, and arrays that can be dynamically (re)sized in a loop. \section{Compiling and Running Stan Programs} A Stan program is first translated to a \Cpp program by the Stan compiler \stanc, then the \Cpp program compiled to a self-contained platform-specific executable. Stan can generate executables for various flavors of Windows, Mac OS X, and Linux.% % \footnote{A Stan program may also be compiled to a dynamically linkable object file for use in a higher-level scripting language such as \R or Python.} % Running the Stan executable for a model first reads in and validates the known values $y$ and $x$, then generates a sequence of (non-independent) identically distributed samples $\theta^{(1)}, \theta^{(2)}, \ldots$, each of which has the marginal distribution $p(\theta|y,x)$. \section{Sampling} For continuous parameters, Stan uses Hamiltonian Monte Carlo (\HMC) sampling \citep{Duane:1987, Neal:1994, Neal:2011}, a form of Markov chain Monte Carlo (\MCMC) sampling \citep{Metropolis:1953}. Stan does not provide discrete sampling for parameters. Discrete observations can be handled directly, but discrete parameters must be marginalized out of the model. \refchapter{mixture-modeling} and \refchapter{latent-discrete} discuss how finite discrete parameters can be summed out of models, leading to large efficiency gains versus discrete parameter sampling. \HMC accelerates both convergence to the stationary distribution and subsequent parameter exploration by using the gradient of the log probability function. The unknown quantity vector $\theta$ is interpreted as the position of a fictional particle. Each iteration generates a random momentum and simulates the path of the particle with potential energy determined by the (negative) log probability function. Hamilton's decomposition shows that the gradient of this potential determines change in momentum and the momentum determines the change in position. These continuous changes over time are approximated using the leapfrog algorithm, which breaks the time into discrete steps which are easily simulated. A Metropolis reject step is then applied to correct for any simulation error and ensure detailed balance of the resulting Markov chain transitions \citep{Metropolis:1953, Hastings:1970}. Basic Euclidean Hamiltonian Monte Carlo involves three ``tuning'' parameters to which its behavior is quite sensitive. Stan's samplers allow these parameters to be set by hand or set automatically without user intervention. The first tuning parameter is the step size, measured in temporal units (i.e., the discretization interval) of the Hamiltonian. Stan can be configured with a user-specified step size or it can estimate an optimal step size during warmup using dual averaging \citep{Nesterov:2009, Hoffman-Gelman:2011, Hoffman-Gelman:2014}. In either case, additional randomization may be applied to draw the step size from an interval of possible step sizes \citep{Neal:2011}. The second tuning parameter is the number of steps taken per iteration, the product of which with the temporal step size determines the total Hamiltonian simulation time. Stan can be set to use a specified number of steps, or it can automatically adapt the number of steps during sampling using the No-U-Turn (\NUTS) sampler \citep{Hoffman-Gelman:2011, Hoffman-Gelman:2014}. The third tuning parameter is a mass matrix for the fictional particle. Stan can be configured to estimate a diagonal mass matrix or a full mass matrix during warmup; Stan will support user-specified mass matrices in the future. Estimating a diagonal mass matrix normalizes the scale of each element $\theta_k$ of the unknown variable sequence $\theta$, whereas estimating a full mass matrix accounts for both scaling and rotation,% % \footnote{These estimated mass matrices are global, meaning they are applied to every point in the parameter space being sampled. Riemann-manifold HMC generalizes this to allow the curvature implied by the mass matrix to vary by position.} % but is more memory and computation intensive per leapfrog step due to the underlying matrix operations. \subsection{Convergence Monitoring and Effective Sample Size} Samples in a Markov chain are only drawn with the marginal distribution $p(\theta|y,x)$ after the chain has converged to its equilibrium distribution. There are several methods to test whether an \MCMC method has failed to converge; unfortunately, passing the tests does not guarantee convergence. The recommended method for Stan is to run multiple Markov chains, initialized randomly with a diffuse set of initial parameter values, discard the warmup/adaptation samples, then split the remainder of each chain in half and compute the potential scale reduction statistic, $\hat{R}$ \citep{GelmanRubin:1992}. If the result is not enough effective samples, double the number of iterations and start again, including rerunning warmup and everything.% % \footnote{Often a lack of effective samples is a result of not enough warmup iterations. At most this rerunning strategy will consume about 50\% more cycles than guessing the correct number of iterations at the outset.} When estimating a mean based on a sample of $M$ independent draws, the estimation error is proportional to $1/\sqrt{M}$. If the draws are positively correlated, as they typically are when drawn using \MCMC methods, the error is proportional to $1/\sqrt{\mbox{\sc n\_eff}}$, where {\sc n\_eff} is the effective sample size. Thus it is standard practice to also monitor (an estimate of) the effective sample size until it is large enough for the estimation or inference task at hand. \subsection{Bayesian Inference and Monte Carlo Methods} Stan was developed to support full Bayesian inference. Bayesian inference is based in part on Bayes's rule, \[ p(\theta|y,x) \propto p(y|\theta,x) \, p(\theta,x), \] which, in this unnormalized form, states that the posterior probability $p(\theta|y,x)$ of parameters $\theta$ given data $y$ (and constants $x$) is proportional (for fixed $y$ and $x$) to the product of the likelihood function $p(y|\theta,x)$ and prior $p(\theta,x)$. For Stan, Bayesian modeling involves coding the posterior probability function up to a proportion, which Bayes's rule shows is equivalent to modeling the product of the likelihood function and prior up to a proportion. Full Bayesian inference involves propagating the uncertainty in the value of parameters $\theta$ modeled by the posterior $p(\theta|y,x)$. This can be accomplished by basing inference on a sequence of samples from the posterior using plug-in estimates for quantities of interest such as posterior means, posterior intervals, predictions based on the posterior such as event outcomes or the values of as yet unobserved data. \section{Optimization} Stan also supports optimization-based inference for models. Given a posterior $p(\theta|y)$, Stan can find the posterior mode $\theta^*$, which is defined by % \[ \theta^{*} = \mbox{argmax}_{\theta} \ p(\theta|y). \] % Here the notation $\mbox{argmax}_v \ f(v)$ is used to pick out the value of $v$ at which $f(v)$ is maximized. If the prior is uniform, the posterior mode corresponds to the maximum likelihood estimate (MLE) of the parameters. If the prior is not uniform, the posterior mode is sometimes called the maximum a posteriori (MAP) estimate. For optimization, the Jacobian of any transforms induced by constraints on variables are ignored. It is more efficient in many optimization problems to remove lower and upper bound constraints in variable declarations and instead rely on rejection in the model block to disallow out-of-support solutions. \subsection{Inference with Point Estimates} The estimate $\theta^{*}$ is a so-called ``point estimate,'' meaning that it summarizes the posterior distribution by a single point, rather than with a distribution. Of course, a point estimate does not, in and of itself, take into account estimation variance. Posterior predictive inferences $p(\tilde{y} \, | \, y)$ can be made using the posterior mode given data $y$ as $p(\tilde{y} \, | \, \theta^*)$, but they are not Bayesian inferences, even if the model involves a prior, because they do not take posterior uncertainty into account. If the posterior variance is low and the posterior mean is near the posterior mode, inference with point estimates can be very similar to full Bayesian inference. \section{Variational Inference} Stan also supports variational inference, an approximate Bayesian inference technique \citep{Jordan:1999,Wainwright-Jordan:2008}. Variational inference provides estimates of posterior means and uncertainty through a parametric approximation of a posterior that is optimized for its fit to the true posterior. Variational inference has had a tremendous impact on Bayesian computation, especially in the machine learning community; it is typically faster than sampling techniques and can scale to massive datasets \citep{Hoffman:2013}. Variational inference approximates the posterior $p(\theta \, | \, y)$ with a simple, parameterized distribution $q(\theta \, | \, \phi)$. It matches the approximation to the true posterior by minimizing the Kullback-Leibler divergence, % \[ \phi^* = \argmin_\phi \KL{ q(\theta \, | \, \phi) }{ p(\theta \, | \, y) }. \] % This converts Bayesian inference into an optimization problem with a well-defined metric for convergence. Variational inference can provide orders of magnitude faster convergence than sampling; the quality of the approximation will vary from model to model. Note that variational inference is not a point estimation technique; the result is a distribution that approximates the posterior. Stan implements Automatic Differentiation Variational Inference (ADVI), an algorithm designed to leverage Stan's library of transformations and automatic differentiation toolbox \citep{Kucukelbir:2015}. ADVI circumvents all of the mathematics typically required to derive variational inference algorithms; it works with any Stan model.
Formal statement is: lemma convex_Int: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<inter> t)" Informal statement is: The intersection of two convex sets is convex.
import topology.category.Profinite.as_limit import for_mathlib.Fintype import hacks_and_tricks.asyncI noncomputable theory namespace Profinite open category_theory open category_theory.limits universes v u u' variables {C : Type u} [category.{v} C] (F : Fintype.{v} ⥤ C) variables {D : Type u'} [category.{v} D] /-- Change a cone with respect to a morphism from `Profinite`. -/ @[simps] def change_cone {X Y : Profinite} (f : X ⟶ Y) (D : cone (X.fintype_diagram ⋙ F)) : cone (Y.fintype_diagram ⋙ F) := { X := D.X, π := { app := λ S, D.π.app (S.comap f.continuous) ≫ F.map (discrete_quotient.map $ le_refl _), naturality' := by asyncI { rintros I J h, dsimp, simp only [category.id_comp, category.assoc], rw ← D.w (hom_of_le $ discrete_quotient.comap_mono _ $ le_of_hom h), simp only [category.assoc, ← F.map_comp, functor.comp_map], congr' 2, ext ⟨t⟩, refl, } } } . -- Assume that C has enough limits. variable [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] -- PROJECT: Prove that this is isomorphic to the right Kan extension along `Fintype.to_Profinite`. /-- Extend a functor `Fintype ⥤ C` to `Profinite`. -/ @[simps] def extend : Profinite ⥤ C := { obj := λ X, limit (X.fintype_diagram ⋙ F), map := λ X Y f, limit.lift _ (change_cone _ f _), map_id' := by asyncI { intros X, ext S, dsimp, simp only [limit.lift_π, coe_id, change_cone_π_app, limit.cone_π, category.id_comp], erw discrete_quotient.map_id, change _ ≫ F.map (𝟙 _) = _, rw [F.map_id, category.comp_id], congr, exact S.comap_id, }, map_comp' := by asyncI { intros X Y Z f g, ext S, dsimp, simp only [limit.lift_π, change_cone_π_app, limit.cone_π, limit.lift_π_assoc, coe_comp, category.assoc, ← F.map_comp], congr, exact discrete_quotient.map_comp _ _, } } . /-- discrete quotients of a finite type has an initial object given by `⊥`. -/ @[simps] def bot_initial (X : Fintype) : is_initial (⊥ : discrete_quotient (Fintype.to_Profinite.obj X)) := { desc := λ S, hom_of_le bot_le } /-- The extension of `F : Fintype ⥤ C` extends `F`. -/ @[simps] def extend_extends : Fintype.to_Profinite ⋙ extend F ≅ F := nat_iso.of_components (λ X, begin dsimp only [extend, functor.comp_obj], let Y := Fintype.to_Profinite.obj X, let D := limit.is_limit (Y.fintype_diagram ⋙ F), let E := limit_of_diagram_initial (bot_initial X) (Y.fintype_diagram ⋙ F), letI : topological_space X := ⊥, let e : Fintype.of (⊥ : discrete_quotient X) ≅ X := Fintype.iso_of_equiv (equiv.of_bijective _ (discrete_quotient.proj_bot_bijective)).symm, let g := D.cone_point_unique_up_to_iso E, exact g ≪≫ F.map_iso e, end) $ by asyncI { intros X Y f, letI : topological_space X := ⊥, letI : topological_space Y := ⊥, have hf : continuous f := continuous_bot, let A := Fintype.to_Profinite.obj X, let B := Fintype.to_Profinite.obj Y, dsimp [is_limit.cone_point_unique_up_to_iso, limit_of_diagram_initial], simp only [change_cone_π_app, limit.cone_π, limit.lift_π_assoc, category.assoc], let e : (⊥ : discrete_quotient X) ⟶ (⊥ : discrete_quotient Y).comap hf := hom_of_le bot_le, erw ← limit.w (A.fintype_diagram ⋙ F) e, simp only [category.assoc, ← F.map_comp, functor.comp_map], congr' 2, simp_rw [← iso.inv_comp_eq, ← category.assoc], symmetry, rw ← iso.comp_inv_eq, refl, } . /- instance extend_preserves_limit (X : Profinite) : preserves_limit X.diagram (extend F) := { preserves := λ D hD, let e : X.diagram ⋙ extend F ≅ X.fintype_diagram ⋙ F := iso_whisker_left _ (extend_extends F), D' : cone (X.fintype_diagram ⋙ F) := (cones.postcompose e.hom).obj ((extend F).map_cone D) in { lift := λ E, begin dsimp, let D'' : cone X.diagram := X.as_limit_cone, let f' : X ⟶ D.X := hD.lift D'', admit end, fac' := _, uniq' := _ } } -/ /-- `extend` is characterized by the fact that it preserves the correct limits and that its composition with `Profinite.to_Fintype` is the original functor. -/ def extend_unique (G : Profinite ⥤ C) [∀ X : Profinite, preserves_limit X.diagram G] (w : Fintype.to_Profinite ⋙ G ≅ F) : G ≅ extend F := nat_iso.of_components (λ X, let D := (X.as_limit_cone), hD := (X.as_limit), E := G.map_cone D, hE : is_limit E := preserves_limit.preserves hD, f : X.diagram ⋙ G ≅ X.fintype_diagram ⋙ F := iso_whisker_left _ w, E' : cone (X.fintype_diagram ⋙ F) := (cones.postcompose f.hom).obj E, hE' : is_limit E' := (is_limit.postcompose_hom_equiv f _).symm hE in hE'.cone_point_unique_up_to_iso (limit.is_limit _) ) $ by asyncI { intros A B f, dsimp [is_limit.postcompose_hom_equiv, is_limit.of_cone_equiv, is_limit.cone_point_unique_up_to_iso], ext S, simp only [←nat_trans.naturality w.hom, limit.lift_π, cones.postcompose_obj_π, functor.comp_map, functor.map_cone_π_app, change_cone_π_app, limit.cone_π, limit.lift_π_assoc, whisker_left_app, nat_trans.comp_app, category.assoc], simp only [← category.assoc, ← G.map_comp], refl, } . @[simps] def extend_commutes (G : C ⥤ D) [∀ X : Profinite.{v}, preserves_limits_of_shape (discrete_quotient X) G] [∀ X : Profinite.{v}, has_limit (X.fintype_diagram ⋙ F ⋙ G)] : extend F ⋙ G ≅ extend (F ⋙ G) := nat_iso.of_components (λ X, (is_limit_of_preserves G (limit.is_limit _)).cone_point_unique_up_to_iso (limit.is_limit _)) $ by asyncI { intros X Y f, ext, dsimp, simp only [category.assoc, limit.lift_π, change_cone_π_app, limit.cone_π, functor.comp_map], erw [limit.lift_π, limit.lift_π_assoc], dsimp, rw [← G.map_comp, limit.lift_π, ← G.map_comp], refl, } @[reassoc] lemma extend_commutes_comp_extend_extends (G : C ⥤ D) [∀ X : Profinite.{v}, preserves_limits_of_shape (discrete_quotient X) G] [∀ X : Profinite.{v}, has_limit (X.fintype_diagram ⋙ F ⋙ G)] : whisker_left Fintype.to_Profinite (extend_commutes F G).hom ≫ (extend_extends _).hom = (functor.associator _ _ _).inv ≫ (whisker_right (extend_extends _).hom G) := begin ext, simp only [nat_trans.comp_app, whisker_left_app, extend_extends_hom_app, functor.comp_map, functor.associator_inv_app, whisker_right_app, functor.map_comp, category.id_comp, extend_commutes_hom_app], rw [← category.assoc], congr' 1, rw [← iso.eq_comp_inv], ext, simp only [is_limit.cone_point_unique_up_to_iso, category.assoc, functor.map_iso_hom, is_limit.unique_up_to_iso_hom, cones.forget_map, is_limit.lift_cone_morphism_hom, limit.is_limit_lift], erw [limit.lift_π, limit.lift_π], simp only [functor.map_cone_π_app, limit.cone_π, functor.map_iso_inv, cones.forget_map, is_limit.unique_up_to_iso_inv, is_limit.lift_cone_morphism_hom, limit.is_limit_lift, cone_of_diagram_initial_π_app, functor.comp_map, limit_of_diagram_initial], rw [← functor.map_comp], congr' 1, symmetry, exact limit.w _ ((bot_initial x).to j), end /-- A natural transformation induces a natural transformation on extensions. -/ @[simps] def extend_nat_trans {F G : Fintype ⥤ C} [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ G)] (η : F ⟶ G) : extend F ⟶ extend G := { app := λ X, category_theory.limits.lim_map $ whisker_left _ η } . @[simp] lemma extend_nat_trans_id (F : Fintype ⥤ C) [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] : extend_nat_trans (𝟙 F) = 𝟙 _ := begin ext S, dsimp, simp, end @[simp] lemma extend_nat_trans_comp {F G H : Fintype ⥤ C} [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ G)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ H)] (α : F ⟶ G) (β : G ⟶ H) : extend_nat_trans (α ≫ β) = extend_nat_trans α ≫ extend_nat_trans β := begin ext S, dsimp, simp, end lemma extend_π (F G : Fintype ⥤ C) [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ G)] (α : extend F ⟶ extend G) (X : Profinite) (T : discrete_quotient X) : α.app X ≫ limit.π _ T = (extend F).map (X.as_limit_cone.π.app T) ≫ α.app (Profinite.of T) ≫ (extend_extends G).hom.app _ := begin have : (extend_extends G).hom.app (X.fintype_diagram.obj T) = limit.π _ ⊥ ≫ _ := rfl, erw [this, α.naturality_assoc], congr' 1, dsimp [extend], simp only [limit.lift_π_assoc, change_cone_π_app, limit.cone_π, category.assoc, ← G.map_comp], convert (limit.w _ _).symm, swap, { apply hom_of_le, intros x y h, dsimp [discrete_quotient.comap] at h, change _ = _ at h, dsimp [Profinite.as_limit_cone] at h, exact quotient.exact' h }, ext t, rcases t with ⟨t⟩, dsimp, let E : ↥(X.fintype_diagram.obj T) ≃ (⊥ : discrete_quotient T) := equiv.of_bijective _ discrete_quotient.proj_bot_bijective, change E.symm _ = _, apply_fun E, rw equiv.apply_symm_apply, refl, end lemma extend_nat_trans_ext {F G : Fintype ⥤ C} [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ G)] (α β : extend F ⟶ extend G) (h : whisker_left Fintype.to_Profinite α = whisker_left Fintype.to_Profinite β) : α = β := begin ext S T, dsimp, let p : S ⟶ of T := S.as_limit_cone.π.app T, let E : Fintype.to_Profinite ⋙ extend G ≅ G := extend_extends G, apply_fun (λ e, (extend F).map p ≫ e.app ⟨T⟩ ≫ E.hom.app _) at h, simpa only [extend_π] using h, end lemma extend_nat_trans_whisker_left {F G : Fintype ⥤ C} [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ G)] (α : F ⟶ G) : whisker_left Fintype.to_Profinite (extend_nat_trans α) = (extend_extends F).hom ≫ α ≫ (extend_extends G).inv := begin ext S, simp only [lim_map, is_limit.map, whisker_left_app, extend_nat_trans_app, limit.is_limit_lift, limit.lift_π, cones.postcompose_obj_π, nat_trans.comp_app, limit.cone_π, extend_extends_hom_app, extend_extends_inv_app, category.assoc, nat_trans.naturality_assoc, ← G.map_iso_hom, ← G.map_iso_inv, iso.hom_inv_id_assoc], rw [← iso.inv_comp_eq], erw [limit.cone_point_unique_up_to_iso_inv_comp, limit.cone_point_unique_up_to_iso_inv_comp_assoc], simp only [cone_of_diagram_initial_π_app, functor.comp_map], erw [nat_trans.naturality], end lemma extend_nat_trans_whisker_right {F G : Fintype ⥤ C} [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ F)] [∀ X : Profinite, has_limit (X.fintype_diagram ⋙ G)] (α : F ⟶ G) (E : C ⥤ D) [∀ X : Profinite.{v}, preserves_limits_of_shape (discrete_quotient X) E] [∀ X : Profinite.{v}, has_limit (X.fintype_diagram ⋙ F ⋙ E)] [∀ X : Profinite.{v}, has_limit (X.fintype_diagram ⋙ G ⋙ E)] : extend_nat_trans (whisker_right α E) = (extend_commutes _ _).inv ≫ whisker_right (extend_nat_trans α) E ≫ (extend_commutes _ _).hom := begin apply extend_nat_trans_ext, simp only [extend_nat_trans_whisker_left, ← whisker_right_left, category.assoc, whisker_left_comp, whisker_right_comp], rw [← iso_whisker_left_inv, iso.eq_inv_comp, iso_whisker_left_hom, extend_commutes_comp_extend_extends_assoc], simp only [← category.assoc, iso.comp_inv_eq], simp only [category.assoc, extend_commutes_comp_extend_extends], ext, simp only [nat_trans.comp_app, functor.associator_hom_app, functor.associator_inv_app], erw [category.id_comp, category.id_comp], simp only [← nat_trans.comp_app, ← iso_whisker_right_hom, ← iso_whisker_right_inv, iso.inv_hom_id], erw [category.comp_id], end end Profinite
Wesley Homes Des Moines brings the traveling ACT 1 Theatre Productions to its stage in The Terrace Auditorium with a Special Valentine's Evening bonus. Wesley Homes Des Moines hosts three Valentine’s Day weekend performances of “The Fantasticks” by ACT 1 Theatre Productions on Friday, Saturday and Sunday, February 12 through 14. Show times and tickets for Friday and Sunday performances and the Special Valentine's Eve performance - complete with a long-stemmed rose, chocolate and a gift for each member of the audience - can be found at Brown Paper Tickets. “The Fantasticks” is a comical and romantic musical about a boy, a girl and their two parents who try to get them together by pretending to want to keep them apart. As originally written, the play cast the respective fathers as the conniving parents. ACT 1 Theatre Productions Director Petra Karr has chosen to instead put the mothers into the story, a change previous directors of the play have made. While the lines in the play have not been altered, the dynamics of the story with two women delivering the lines is different. Karr made the change, in part, in order to take advantage of the way in which the two actors she cast as the mothers interact. The narrator of the play, El Gallo, asks the audience to use their imagination and follow him into a world of moonlight and magic. The boy and the girl fall in love, grow apart and find their way back to each other after realizing the truth in El Gallo's words: "Without a hurt, the heart is hollow." “The Fantasicks” is the longest running off/on Broadway musical in history. The book and lyrics were written by Tom Jones and the music composed by Harvey Schmidt. ACT 1 is donating 100 tickets per Des Moines performance to Wesley Homes’ residents and encourages guests to purchase tickets early. Seating is limited. For additional show times and locations or to find out more about ACT 1, please visit their website. All proceeds go to ACT 1 Theatre Productions. With more than 50 combined years of regional and educational theatre experience under their belts, Christopher and Petra Karr officially launched ACT 1 Theatre Productions in 2008. In 2012, the theatre company became a non-profit organization. Though ACT 1 takes its act on the road, all of its major productions are done in the studio in Sumner, Washington.
||| Compiling of expressions ||| ||| Experssions track their type along with the generated Rust code. ||| Because Rust is a statically typeed language and some primitive types in ||| Idris map nicely to Rust it makes sense to keep this information around to ||| only inseert the casts that are necessary. module Idris2Rust.Expr import Compiler.Common import Compiler.CompileExpr import Core.Context import Data.List import Data.Maybe import Data.Vect rustKeywords : List String rustKeywords = [ "as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", "use", "where", "while", "async", "await", "dyn", "abstract", "become", "box", "do", "final", "macro", "override", "priv", "typeof", "unsized", "virtual", "yield", "try", "union" ]
[STATEMENT] lemma exists_some_channel: shows "\<exists>i p q. channel i = Some (p, q)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] obtain p q where "p : (UNIV :: 'a set) \<and> q : (UNIV :: 'a set) \<and> p \<noteq> q" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>p q. p \<in> UNIV \<and> q \<in> UNIV \<and> p \<noteq> q \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (metis (mono_tags) One_nat_def UNIV_eq_I all_not_in_conv at_least_two_processes card_Suc_Diff1 card.empty finite_processes insert_iff iso_tuple_UNIV_I less_numeral_extra(4) n_not_Suc_n) [PROOF STATE] proof (state) this: p \<in> UNIV \<and> q \<in> UNIV \<and> p \<noteq> q goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: p \<in> UNIV \<and> q \<in> UNIV \<and> p \<noteq> q [PROOF STEP] have "(tranclp has_channel) p q" [PROOF STATE] proof (prove) using this: p \<in> UNIV \<and> q \<in> UNIV \<and> p \<noteq> q goal (1 subgoal): 1. has_channel\<^sup>+\<^sup>+ p q [PROOF STEP] using strongly_connected [PROOF STATE] proof (prove) using this: p \<in> UNIV \<and> q \<in> UNIV \<and> p \<noteq> q \<forall>p q. p \<noteq> q \<longrightarrow> has_channel\<^sup>+\<^sup>+ p q goal (1 subgoal): 1. has_channel\<^sup>+\<^sup>+ p q [PROOF STEP] by simp [PROOF STATE] proof (state) this: has_channel\<^sup>+\<^sup>+ p q goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: has_channel\<^sup>+\<^sup>+ p q [PROOF STEP] obtain r s where "has_channel r s" [PROOF STATE] proof (prove) using this: has_channel\<^sup>+\<^sup>+ p q goal (1 subgoal): 1. (\<And>r s. has_channel r s \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (meson tranclpD) [PROOF STATE] proof (state) this: has_channel r s goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: has_channel r s [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: has_channel r s goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] using has_channel_def [PROOF STATE] proof (prove) using this: has_channel r s has_channel ?p ?q = (\<exists>i. channel i = Some (?p, ?q)) goal (1 subgoal): 1. \<exists>i p q. channel i = Some (p, q) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<exists>i p q. channel i = Some (p, q) goal: No subgoals! [PROOF STEP] qed
We provide the Finest Carpet Cleaning in Maine. We serve the Midcoast Region from Bath, Brunswick, Wiscasset, Nobleboro, Thomaston, Warren, Damariscotta, Waldoboro, Camden, Rockland and all points south of Route 1. All of our PROCYON products are powerful and yet soap free, odor free, hypo-allergenic, non-toxic with no VOCs and no off-gassing. Made with all natural ingredients, PROCYON products are one of the safest on the market today. Superior Cleaning technicians will explain the cleaning process in a straight-forward fashion without fancy terminology. Our responsible cleaning technicians use safe cleaning products and are knowledgeable in different types of carpet and the cleaning requirements for each. We will always keep your office’s security in mind while we are working. Superior Cleaning has Maintenance plans available, and will work after hours for the least amount of disruption to your business. Whether cleaning your home or office we will listen to your needs & concerns and will develop a plan to provide the best available service to complete the job.
(* Title: HOL/Num.thy Author: Florian Haftmann Author: Brian Huffman *) section {* Binary Numerals *} theory Num imports BNF_Least_Fixpoint begin subsection {* The @{text num} type *} datatype num = One | Bit0 num | Bit1 num text {* Increment function for type @{typ num} *} primrec inc :: "num \<Rightarrow> num" where "inc One = Bit0 One" | "inc (Bit0 x) = Bit1 x" | "inc (Bit1 x) = Bit0 (inc x)" text {* Converting between type @{typ num} and type @{typ nat} *} primrec nat_of_num :: "num \<Rightarrow> nat" where "nat_of_num One = Suc 0" | "nat_of_num (Bit0 x) = nat_of_num x + nat_of_num x" | "nat_of_num (Bit1 x) = Suc (nat_of_num x + nat_of_num x)" primrec num_of_nat :: "nat \<Rightarrow> num" where "num_of_nat 0 = One" | "num_of_nat (Suc n) = (if 0 < n then inc (num_of_nat n) else One)" lemma nat_of_num_pos: "0 < nat_of_num x" by (induct x) simp_all lemma nat_of_num_neq_0: " nat_of_num x \<noteq> 0" by (induct x) simp_all lemma nat_of_num_inc: "nat_of_num (inc x) = Suc (nat_of_num x)" by (induct x) simp_all lemma num_of_nat_double: "0 < n \<Longrightarrow> num_of_nat (n + n) = Bit0 (num_of_nat n)" by (induct n) simp_all text {* Type @{typ num} is isomorphic to the strictly positive natural numbers. *} lemma nat_of_num_inverse: "num_of_nat (nat_of_num x) = x" by (induct x) (simp_all add: num_of_nat_double nat_of_num_pos) lemma num_of_nat_inverse: "0 < n \<Longrightarrow> nat_of_num (num_of_nat n) = n" by (induct n) (simp_all add: nat_of_num_inc) lemma num_eq_iff: "x = y \<longleftrightarrow> nat_of_num x = nat_of_num y" apply safe apply (drule arg_cong [where f=num_of_nat]) apply (simp add: nat_of_num_inverse) done lemma num_induct [case_names One inc]: fixes P :: "num \<Rightarrow> bool" assumes One: "P One" and inc: "\<And>x. P x \<Longrightarrow> P (inc x)" shows "P x" proof - obtain n where n: "Suc n = nat_of_num x" by (cases "nat_of_num x", simp_all add: nat_of_num_neq_0) have "P (num_of_nat (Suc n))" proof (induct n) case 0 show ?case using One by simp next case (Suc n) then have "P (inc (num_of_nat (Suc n)))" by (rule inc) then show "P (num_of_nat (Suc (Suc n)))" by simp qed with n show "P x" by (simp add: nat_of_num_inverse) qed text {* From now on, there are two possible models for @{typ num}: as positive naturals (rule @{text "num_induct"}) and as digit representation (rules @{text "num.induct"}, @{text "num.cases"}). *} subsection {* Numeral operations *} instantiation num :: "{plus,times,linorder}" begin definition [code del]: "m + n = num_of_nat (nat_of_num m + nat_of_num n)" definition [code del]: "m * n = num_of_nat (nat_of_num m * nat_of_num n)" definition [code del]: "m \<le> n \<longleftrightarrow> nat_of_num m \<le> nat_of_num n" definition [code del]: "m < n \<longleftrightarrow> nat_of_num m < nat_of_num n" instance by (default, auto simp add: less_num_def less_eq_num_def num_eq_iff) end lemma nat_of_num_add: "nat_of_num (x + y) = nat_of_num x + nat_of_num y" unfolding plus_num_def by (intro num_of_nat_inverse add_pos_pos nat_of_num_pos) lemma nat_of_num_mult: "nat_of_num (x * y) = nat_of_num x * nat_of_num y" unfolding times_num_def by (intro num_of_nat_inverse mult_pos_pos nat_of_num_pos) lemma add_num_simps [simp, code]: "One + One = Bit0 One" "One + Bit0 n = Bit1 n" "One + Bit1 n = Bit0 (n + One)" "Bit0 m + One = Bit1 m" "Bit0 m + Bit0 n = Bit0 (m + n)" "Bit0 m + Bit1 n = Bit1 (m + n)" "Bit1 m + One = Bit0 (m + One)" "Bit1 m + Bit0 n = Bit1 (m + n)" "Bit1 m + Bit1 n = Bit0 (m + n + One)" by (simp_all add: num_eq_iff nat_of_num_add) lemma mult_num_simps [simp, code]: "m * One = m" "One * n = n" "Bit0 m * Bit0 n = Bit0 (Bit0 (m * n))" "Bit0 m * Bit1 n = Bit0 (m * Bit1 n)" "Bit1 m * Bit0 n = Bit0 (Bit1 m * n)" "Bit1 m * Bit1 n = Bit1 (m + n + Bit0 (m * n))" by (simp_all add: num_eq_iff nat_of_num_add nat_of_num_mult distrib_right distrib_left) lemma eq_num_simps: "One = One \<longleftrightarrow> True" "One = Bit0 n \<longleftrightarrow> False" "One = Bit1 n \<longleftrightarrow> False" "Bit0 m = One \<longleftrightarrow> False" "Bit1 m = One \<longleftrightarrow> False" "Bit0 m = Bit0 n \<longleftrightarrow> m = n" "Bit0 m = Bit1 n \<longleftrightarrow> False" "Bit1 m = Bit0 n \<longleftrightarrow> False" "Bit1 m = Bit1 n \<longleftrightarrow> m = n" by simp_all lemma le_num_simps [simp, code]: "One \<le> n \<longleftrightarrow> True" "Bit0 m \<le> One \<longleftrightarrow> False" "Bit1 m \<le> One \<longleftrightarrow> False" "Bit0 m \<le> Bit0 n \<longleftrightarrow> m \<le> n" "Bit0 m \<le> Bit1 n \<longleftrightarrow> m \<le> n" "Bit1 m \<le> Bit1 n \<longleftrightarrow> m \<le> n" "Bit1 m \<le> Bit0 n \<longleftrightarrow> m < n" using nat_of_num_pos [of n] nat_of_num_pos [of m] by (auto simp add: less_eq_num_def less_num_def) lemma less_num_simps [simp, code]: "m < One \<longleftrightarrow> False" "One < Bit0 n \<longleftrightarrow> True" "One < Bit1 n \<longleftrightarrow> True" "Bit0 m < Bit0 n \<longleftrightarrow> m < n" "Bit0 m < Bit1 n \<longleftrightarrow> m \<le> n" "Bit1 m < Bit1 n \<longleftrightarrow> m < n" "Bit1 m < Bit0 n \<longleftrightarrow> m < n" using nat_of_num_pos [of n] nat_of_num_pos [of m] by (auto simp add: less_eq_num_def less_num_def) text {* Rules using @{text One} and @{text inc} as constructors *} lemma add_One: "x + One = inc x" by (simp add: num_eq_iff nat_of_num_add nat_of_num_inc) lemma add_One_commute: "One + n = n + One" by (induct n) simp_all lemma add_inc: "x + inc y = inc (x + y)" by (simp add: num_eq_iff nat_of_num_add nat_of_num_inc) lemma mult_inc: "x * inc y = x * y + x" by (simp add: num_eq_iff nat_of_num_mult nat_of_num_add nat_of_num_inc) text {* The @{const num_of_nat} conversion *} lemma num_of_nat_One: "n \<le> 1 \<Longrightarrow> num_of_nat n = One" by (cases n) simp_all lemma num_of_nat_plus_distrib: "0 < m \<Longrightarrow> 0 < n \<Longrightarrow> num_of_nat (m + n) = num_of_nat m + num_of_nat n" by (induct n) (auto simp add: add_One add_One_commute add_inc) text {* A double-and-decrement function *} primrec BitM :: "num \<Rightarrow> num" where "BitM One = One" | "BitM (Bit0 n) = Bit1 (BitM n)" | "BitM (Bit1 n) = Bit1 (Bit0 n)" lemma BitM_plus_one: "BitM n + One = Bit0 n" by (induct n) simp_all lemma one_plus_BitM: "One + BitM n = Bit0 n" unfolding add_One_commute BitM_plus_one .. text {* Squaring and exponentiation *} primrec sqr :: "num \<Rightarrow> num" where "sqr One = One" | "sqr (Bit0 n) = Bit0 (Bit0 (sqr n))" | "sqr (Bit1 n) = Bit1 (Bit0 (sqr n + n))" primrec pow :: "num \<Rightarrow> num \<Rightarrow> num" where "pow x One = x" | "pow x (Bit0 y) = sqr (pow x y)" | "pow x (Bit1 y) = sqr (pow x y) * x" lemma nat_of_num_sqr: "nat_of_num (sqr x) = nat_of_num x * nat_of_num x" by (induct x, simp_all add: algebra_simps nat_of_num_add) lemma sqr_conv_mult: "sqr x = x * x" by (simp add: num_eq_iff nat_of_num_sqr nat_of_num_mult) subsection {* Binary numerals *} text {* We embed binary representations into a generic algebraic structure using @{text numeral}. *} class numeral = one + semigroup_add begin primrec numeral :: "num \<Rightarrow> 'a" where numeral_One: "numeral One = 1" | numeral_Bit0: "numeral (Bit0 n) = numeral n + numeral n" | numeral_Bit1: "numeral (Bit1 n) = numeral n + numeral n + 1" lemma numeral_code [code]: "numeral One = 1" "numeral (Bit0 n) = (let m = numeral n in m + m)" "numeral (Bit1 n) = (let m = numeral n in m + m + 1)" by (simp_all add: Let_def) lemma one_plus_numeral_commute: "1 + numeral x = numeral x + 1" apply (induct x) apply simp apply (simp add: add.assoc [symmetric], simp add: add.assoc) apply (simp add: add.assoc [symmetric], simp add: add.assoc) done lemma numeral_inc: "numeral (inc x) = numeral x + 1" proof (induct x) case (Bit1 x) have "numeral x + (1 + numeral x) + 1 = numeral x + (numeral x + 1) + 1" by (simp only: one_plus_numeral_commute) with Bit1 show ?case by (simp add: add.assoc) qed simp_all declare numeral.simps [simp del] abbreviation "Numeral1 \<equiv> numeral One" declare numeral_One [code_post] end text {* Numeral syntax. *} syntax "_Numeral" :: "num_const \<Rightarrow> 'a" ("_") ML_file "Tools/numeral.ML" parse_translation {* let fun numeral_tr [(c as Const (@{syntax_const "_constrain"}, _)) $ t $ u] = c $ numeral_tr [t] $ u | numeral_tr [Const (num, _)] = (Numeral.mk_number_syntax o #value o Lexicon.read_num) num | numeral_tr ts = raise TERM ("numeral_tr", ts); in [(@{syntax_const "_Numeral"}, K numeral_tr)] end *} typed_print_translation {* let fun dest_num (Const (@{const_syntax Bit0}, _) $ n) = 2 * dest_num n | dest_num (Const (@{const_syntax Bit1}, _) $ n) = 2 * dest_num n + 1 | dest_num (Const (@{const_syntax One}, _)) = 1; fun num_tr' ctxt T [n] = let val k = dest_num n; val t' = Syntax.const @{syntax_const "_Numeral"} $ Syntax.free (string_of_int k); in (case T of Type (@{type_name fun}, [_, T']) => if Printer.type_emphasis ctxt T' then Syntax.const @{syntax_const "_constrain"} $ t' $ Syntax_Phases.term_of_typ ctxt T' else t' | _ => if T = dummyT then t' else raise Match) end; in [(@{const_syntax numeral}, num_tr')] end *} subsection {* Class-specific numeral rules *} text {* @{const numeral} is a morphism. *} subsubsection {* Structures with addition: class @{text numeral} *} context numeral begin lemma numeral_add: "numeral (m + n) = numeral m + numeral n" by (induct n rule: num_induct) (simp_all only: numeral_One add_One add_inc numeral_inc add.assoc) lemma numeral_plus_numeral: "numeral m + numeral n = numeral (m + n)" by (rule numeral_add [symmetric]) lemma numeral_plus_one: "numeral n + 1 = numeral (n + One)" using numeral_add [of n One] by (simp add: numeral_One) lemma one_plus_numeral: "1 + numeral n = numeral (One + n)" using numeral_add [of One n] by (simp add: numeral_One) lemma one_add_one: "1 + 1 = 2" using numeral_add [of One One] by (simp add: numeral_One) lemmas add_numeral_special = numeral_plus_one one_plus_numeral one_add_one end subsubsection {* Structures with negation: class @{text neg_numeral} *} class neg_numeral = numeral + group_add begin lemma uminus_numeral_One: "- Numeral1 = - 1" by (simp add: numeral_One) text {* Numerals form an abelian subgroup. *} inductive is_num :: "'a \<Rightarrow> bool" where "is_num 1" | "is_num x \<Longrightarrow> is_num (- x)" | "\<lbrakk>is_num x; is_num y\<rbrakk> \<Longrightarrow> is_num (x + y)" lemma is_num_numeral: "is_num (numeral k)" by (induct k, simp_all add: numeral.simps is_num.intros) lemma is_num_add_commute: "\<lbrakk>is_num x; is_num y\<rbrakk> \<Longrightarrow> x + y = y + x" apply (induct x rule: is_num.induct) apply (induct y rule: is_num.induct) apply simp apply (rule_tac a=x in add_left_imp_eq) apply (rule_tac a=x in add_right_imp_eq) apply (simp add: add.assoc) apply (simp add: add.assoc [symmetric], simp add: add.assoc) apply (rule_tac a=x in add_left_imp_eq) apply (rule_tac a=x in add_right_imp_eq) apply (simp add: add.assoc) apply (simp add: add.assoc, simp add: add.assoc [symmetric]) done lemma is_num_add_left_commute: "\<lbrakk>is_num x; is_num y\<rbrakk> \<Longrightarrow> x + (y + z) = y + (x + z)" by (simp only: add.assoc [symmetric] is_num_add_commute) lemmas is_num_normalize = add.assoc is_num_add_commute is_num_add_left_commute is_num.intros is_num_numeral minus_add definition dbl :: "'a \<Rightarrow> 'a" where "dbl x = x + x" definition dbl_inc :: "'a \<Rightarrow> 'a" where "dbl_inc x = x + x + 1" definition dbl_dec :: "'a \<Rightarrow> 'a" where "dbl_dec x = x + x - 1" definition sub :: "num \<Rightarrow> num \<Rightarrow> 'a" where "sub k l = numeral k - numeral l" lemma numeral_BitM: "numeral (BitM n) = numeral (Bit0 n) - 1" by (simp only: BitM_plus_one [symmetric] numeral_add numeral_One eq_diff_eq) lemma dbl_simps [simp]: "dbl (- numeral k) = - dbl (numeral k)" "dbl 0 = 0" "dbl 1 = 2" "dbl (- 1) = - 2" "dbl (numeral k) = numeral (Bit0 k)" by (simp_all add: dbl_def numeral.simps minus_add) lemma dbl_inc_simps [simp]: "dbl_inc (- numeral k) = - dbl_dec (numeral k)" "dbl_inc 0 = 1" "dbl_inc 1 = 3" "dbl_inc (- 1) = - 1" "dbl_inc (numeral k) = numeral (Bit1 k)" by (simp_all add: dbl_inc_def dbl_dec_def numeral.simps numeral_BitM is_num_normalize algebra_simps del: add_uminus_conv_diff) lemma dbl_dec_simps [simp]: "dbl_dec (- numeral k) = - dbl_inc (numeral k)" "dbl_dec 0 = - 1" "dbl_dec 1 = 1" "dbl_dec (- 1) = - 3" "dbl_dec (numeral k) = numeral (BitM k)" by (simp_all add: dbl_dec_def dbl_inc_def numeral.simps numeral_BitM is_num_normalize) lemma sub_num_simps [simp]: "sub One One = 0" "sub One (Bit0 l) = - numeral (BitM l)" "sub One (Bit1 l) = - numeral (Bit0 l)" "sub (Bit0 k) One = numeral (BitM k)" "sub (Bit1 k) One = numeral (Bit0 k)" "sub (Bit0 k) (Bit0 l) = dbl (sub k l)" "sub (Bit0 k) (Bit1 l) = dbl_dec (sub k l)" "sub (Bit1 k) (Bit0 l) = dbl_inc (sub k l)" "sub (Bit1 k) (Bit1 l) = dbl (sub k l)" by (simp_all add: dbl_def dbl_dec_def dbl_inc_def sub_def numeral.simps numeral_BitM is_num_normalize del: add_uminus_conv_diff add: diff_conv_add_uminus) lemma add_neg_numeral_simps: "numeral m + - numeral n = sub m n" "- numeral m + numeral n = sub n m" "- numeral m + - numeral n = - (numeral m + numeral n)" by (simp_all add: sub_def numeral_add numeral.simps is_num_normalize del: add_uminus_conv_diff add: diff_conv_add_uminus) lemma add_neg_numeral_special: "1 + - numeral m = sub One m" "- numeral m + 1 = sub One m" "numeral m + - 1 = sub m One" "- 1 + numeral n = sub n One" "- 1 + - numeral n = - numeral (inc n)" "- numeral m + - 1 = - numeral (inc m)" "1 + - 1 = 0" "- 1 + 1 = 0" "- 1 + - 1 = - 2" by (simp_all add: sub_def numeral_add numeral.simps is_num_normalize right_minus numeral_inc del: add_uminus_conv_diff add: diff_conv_add_uminus) lemma diff_numeral_simps: "numeral m - numeral n = sub m n" "numeral m - - numeral n = numeral (m + n)" "- numeral m - numeral n = - numeral (m + n)" "- numeral m - - numeral n = sub n m" by (simp_all add: sub_def numeral_add numeral.simps is_num_normalize del: add_uminus_conv_diff add: diff_conv_add_uminus) lemma diff_numeral_special: "1 - numeral n = sub One n" "numeral m - 1 = sub m One" "1 - - numeral n = numeral (One + n)" "- numeral m - 1 = - numeral (m + One)" "- 1 - numeral n = - numeral (inc n)" "numeral m - - 1 = numeral (inc m)" "- 1 - - numeral n = sub n One" "- numeral m - - 1 = sub One m" "1 - 1 = 0" "- 1 - 1 = - 2" "1 - - 1 = 2" "- 1 - - 1 = 0" by (simp_all add: sub_def numeral_add numeral.simps is_num_normalize numeral_inc del: add_uminus_conv_diff add: diff_conv_add_uminus) end subsubsection {* Structures with multiplication: class @{text semiring_numeral} *} class semiring_numeral = semiring + monoid_mult begin subclass numeral .. lemma numeral_mult: "numeral (m * n) = numeral m * numeral n" apply (induct n rule: num_induct) apply (simp add: numeral_One) apply (simp add: mult_inc numeral_inc numeral_add distrib_left) done lemma numeral_times_numeral: "numeral m * numeral n = numeral (m * n)" by (rule numeral_mult [symmetric]) lemma mult_2: "2 * z = z + z" unfolding one_add_one [symmetric] distrib_right by simp lemma mult_2_right: "z * 2 = z + z" unfolding one_add_one [symmetric] distrib_left by simp end subsubsection {* Structures with a zero: class @{text semiring_1} *} context semiring_1 begin subclass semiring_numeral .. lemma of_nat_numeral [simp]: "of_nat (numeral n) = numeral n" by (induct n, simp_all only: numeral.simps numeral_class.numeral.simps of_nat_add of_nat_1) end lemma nat_of_num_numeral [code_abbrev]: "nat_of_num = numeral" proof fix n have "numeral n = nat_of_num n" by (induct n) (simp_all add: numeral.simps) then show "nat_of_num n = numeral n" by simp qed lemma nat_of_num_code [code]: "nat_of_num One = 1" "nat_of_num (Bit0 n) = (let m = nat_of_num n in m + m)" "nat_of_num (Bit1 n) = (let m = nat_of_num n in Suc (m + m))" by (simp_all add: Let_def) subsubsection {* Equality: class @{text semiring_char_0} *} context semiring_char_0 begin lemma numeral_eq_iff: "numeral m = numeral n \<longleftrightarrow> m = n" unfolding of_nat_numeral [symmetric] nat_of_num_numeral [symmetric] of_nat_eq_iff num_eq_iff .. lemma numeral_eq_one_iff: "numeral n = 1 \<longleftrightarrow> n = One" by (rule numeral_eq_iff [of n One, unfolded numeral_One]) lemma one_eq_numeral_iff: "1 = numeral n \<longleftrightarrow> One = n" by (rule numeral_eq_iff [of One n, unfolded numeral_One]) lemma numeral_neq_zero: "numeral n \<noteq> 0" unfolding of_nat_numeral [symmetric] nat_of_num_numeral [symmetric] by (simp add: nat_of_num_pos) lemma zero_neq_numeral: "0 \<noteq> numeral n" unfolding eq_commute [of 0] by (rule numeral_neq_zero) lemmas eq_numeral_simps [simp] = numeral_eq_iff numeral_eq_one_iff one_eq_numeral_iff numeral_neq_zero zero_neq_numeral end subsubsection {* Comparisons: class @{text linordered_semidom} *} text {* Could be perhaps more general than here. *} context linordered_semidom begin lemma numeral_le_iff: "numeral m \<le> numeral n \<longleftrightarrow> m \<le> n" proof - have "of_nat (numeral m) \<le> of_nat (numeral n) \<longleftrightarrow> m \<le> n" unfolding less_eq_num_def nat_of_num_numeral of_nat_le_iff .. then show ?thesis by simp qed lemma one_le_numeral: "1 \<le> numeral n" using numeral_le_iff [of One n] by (simp add: numeral_One) lemma numeral_le_one_iff: "numeral n \<le> 1 \<longleftrightarrow> n \<le> One" using numeral_le_iff [of n One] by (simp add: numeral_One) lemma numeral_less_iff: "numeral m < numeral n \<longleftrightarrow> m < n" proof - have "of_nat (numeral m) < of_nat (numeral n) \<longleftrightarrow> m < n" unfolding less_num_def nat_of_num_numeral of_nat_less_iff .. then show ?thesis by simp qed lemma not_numeral_less_one: "\<not> numeral n < 1" using numeral_less_iff [of n One] by (simp add: numeral_One) lemma one_less_numeral_iff: "1 < numeral n \<longleftrightarrow> One < n" using numeral_less_iff [of One n] by (simp add: numeral_One) lemma zero_le_numeral: "0 \<le> numeral n" by (induct n) (simp_all add: numeral.simps) lemma zero_less_numeral: "0 < numeral n" by (induct n) (simp_all add: numeral.simps add_pos_pos) lemma not_numeral_le_zero: "\<not> numeral n \<le> 0" by (simp add: not_le zero_less_numeral) lemma not_numeral_less_zero: "\<not> numeral n < 0" by (simp add: not_less zero_le_numeral) lemmas le_numeral_extra = zero_le_one not_one_le_zero order_refl [of 0] order_refl [of 1] lemmas less_numeral_extra = zero_less_one not_one_less_zero less_irrefl [of 0] less_irrefl [of 1] lemmas le_numeral_simps [simp] = numeral_le_iff one_le_numeral numeral_le_one_iff zero_le_numeral not_numeral_le_zero lemmas less_numeral_simps [simp] = numeral_less_iff one_less_numeral_iff not_numeral_less_one zero_less_numeral not_numeral_less_zero end subsubsection {* Multiplication and negation: class @{text ring_1} *} context ring_1 begin subclass neg_numeral .. lemma mult_neg_numeral_simps: "- numeral m * - numeral n = numeral (m * n)" "- numeral m * numeral n = - numeral (m * n)" "numeral m * - numeral n = - numeral (m * n)" unfolding mult_minus_left mult_minus_right by (simp_all only: minus_minus numeral_mult) lemma mult_minus1 [simp]: "- 1 * z = - z" unfolding numeral.simps mult_minus_left by simp lemma mult_minus1_right [simp]: "z * - 1 = - z" unfolding numeral.simps mult_minus_right by simp end subsubsection {* Equality using @{text iszero} for rings with non-zero characteristic *} context ring_1 begin definition iszero :: "'a \<Rightarrow> bool" where "iszero z \<longleftrightarrow> z = 0" lemma iszero_0 [simp]: "iszero 0" by (simp add: iszero_def) lemma not_iszero_1 [simp]: "\<not> iszero 1" by (simp add: iszero_def) lemma not_iszero_Numeral1: "\<not> iszero Numeral1" by (simp add: numeral_One) lemma not_iszero_neg_1 [simp]: "\<not> iszero (- 1)" by (simp add: iszero_def) lemma not_iszero_neg_Numeral1: "\<not> iszero (- Numeral1)" by (simp add: numeral_One) lemma iszero_neg_numeral [simp]: "iszero (- numeral w) \<longleftrightarrow> iszero (numeral w)" unfolding iszero_def by (rule neg_equal_0_iff_equal) lemma eq_iff_iszero_diff: "x = y \<longleftrightarrow> iszero (x - y)" unfolding iszero_def by (rule eq_iff_diff_eq_0) text {* The @{text "eq_numeral_iff_iszero"} lemmas are not declared @{text "[simp]"} by default, because for rings of characteristic zero, better simp rules are possible. For a type like integers mod @{text "n"}, type-instantiated versions of these rules should be added to the simplifier, along with a type-specific rule for deciding propositions of the form @{text "iszero (numeral w)"}. bh: Maybe it would not be so bad to just declare these as simp rules anyway? I should test whether these rules take precedence over the @{text "ring_char_0"} rules in the simplifier. *} lemma eq_numeral_iff_iszero: "numeral x = numeral y \<longleftrightarrow> iszero (sub x y)" "numeral x = - numeral y \<longleftrightarrow> iszero (numeral (x + y))" "- numeral x = numeral y \<longleftrightarrow> iszero (numeral (x + y))" "- numeral x = - numeral y \<longleftrightarrow> iszero (sub y x)" "numeral x = 1 \<longleftrightarrow> iszero (sub x One)" "1 = numeral y \<longleftrightarrow> iszero (sub One y)" "- numeral x = 1 \<longleftrightarrow> iszero (numeral (x + One))" "1 = - numeral y \<longleftrightarrow> iszero (numeral (One + y))" "numeral x = 0 \<longleftrightarrow> iszero (numeral x)" "0 = numeral y \<longleftrightarrow> iszero (numeral y)" "- numeral x = 0 \<longleftrightarrow> iszero (numeral x)" "0 = - numeral y \<longleftrightarrow> iszero (numeral y)" unfolding eq_iff_iszero_diff diff_numeral_simps diff_numeral_special by simp_all end subsubsection {* Equality and negation: class @{text ring_char_0} *} class ring_char_0 = ring_1 + semiring_char_0 begin lemma not_iszero_numeral [simp]: "\<not> iszero (numeral w)" by (simp add: iszero_def) lemma neg_numeral_eq_iff: "- numeral m = - numeral n \<longleftrightarrow> m = n" by simp lemma numeral_neq_neg_numeral: "numeral m \<noteq> - numeral n" unfolding eq_neg_iff_add_eq_0 by (simp add: numeral_plus_numeral) lemma neg_numeral_neq_numeral: "- numeral m \<noteq> numeral n" by (rule numeral_neq_neg_numeral [symmetric]) lemma zero_neq_neg_numeral: "0 \<noteq> - numeral n" unfolding neg_0_equal_iff_equal by simp lemma neg_numeral_neq_zero: "- numeral n \<noteq> 0" unfolding neg_equal_0_iff_equal by simp lemma one_neq_neg_numeral: "1 \<noteq> - numeral n" using numeral_neq_neg_numeral [of One n] by (simp add: numeral_One) lemma neg_numeral_neq_one: "- numeral n \<noteq> 1" using neg_numeral_neq_numeral [of n One] by (simp add: numeral_One) lemma neg_one_neq_numeral: "- 1 \<noteq> numeral n" using neg_numeral_neq_numeral [of One n] by (simp add: numeral_One) lemma numeral_neq_neg_one: "numeral n \<noteq> - 1" using numeral_neq_neg_numeral [of n One] by (simp add: numeral_One) lemma neg_one_eq_numeral_iff: "- 1 = - numeral n \<longleftrightarrow> n = One" using neg_numeral_eq_iff [of One n] by (auto simp add: numeral_One) lemma numeral_eq_neg_one_iff: "- numeral n = - 1 \<longleftrightarrow> n = One" using neg_numeral_eq_iff [of n One] by (auto simp add: numeral_One) lemma neg_one_neq_zero: "- 1 \<noteq> 0" by simp lemma zero_neq_neg_one: "0 \<noteq> - 1" by simp lemma neg_one_neq_one: "- 1 \<noteq> 1" using neg_numeral_neq_numeral [of One One] by (simp only: numeral_One not_False_eq_True) lemma one_neq_neg_one: "1 \<noteq> - 1" using numeral_neq_neg_numeral [of One One] by (simp only: numeral_One not_False_eq_True) lemmas eq_neg_numeral_simps [simp] = neg_numeral_eq_iff numeral_neq_neg_numeral neg_numeral_neq_numeral one_neq_neg_numeral neg_numeral_neq_one zero_neq_neg_numeral neg_numeral_neq_zero neg_one_neq_numeral numeral_neq_neg_one neg_one_eq_numeral_iff numeral_eq_neg_one_iff neg_one_neq_zero zero_neq_neg_one neg_one_neq_one one_neq_neg_one end subsubsection {* Structures with negation and order: class @{text linordered_idom} *} context linordered_idom begin subclass ring_char_0 .. lemma neg_numeral_le_iff: "- numeral m \<le> - numeral n \<longleftrightarrow> n \<le> m" by (simp only: neg_le_iff_le numeral_le_iff) lemma neg_numeral_less_iff: "- numeral m < - numeral n \<longleftrightarrow> n < m" by (simp only: neg_less_iff_less numeral_less_iff) lemma neg_numeral_less_zero: "- numeral n < 0" by (simp only: neg_less_0_iff_less zero_less_numeral) lemma neg_numeral_le_zero: "- numeral n \<le> 0" by (simp only: neg_le_0_iff_le zero_le_numeral) lemma not_zero_less_neg_numeral: "\<not> 0 < - numeral n" by (simp only: not_less neg_numeral_le_zero) lemma not_zero_le_neg_numeral: "\<not> 0 \<le> - numeral n" by (simp only: not_le neg_numeral_less_zero) lemma neg_numeral_less_numeral: "- numeral m < numeral n" using neg_numeral_less_zero zero_less_numeral by (rule less_trans) lemma neg_numeral_le_numeral: "- numeral m \<le> numeral n" by (simp only: less_imp_le neg_numeral_less_numeral) lemma not_numeral_less_neg_numeral: "\<not> numeral m < - numeral n" by (simp only: not_less neg_numeral_le_numeral) lemma not_numeral_le_neg_numeral: "\<not> numeral m \<le> - numeral n" by (simp only: not_le neg_numeral_less_numeral) lemma neg_numeral_less_one: "- numeral m < 1" by (rule neg_numeral_less_numeral [of m One, unfolded numeral_One]) lemma neg_numeral_le_one: "- numeral m \<le> 1" by (rule neg_numeral_le_numeral [of m One, unfolded numeral_One]) lemma not_one_less_neg_numeral: "\<not> 1 < - numeral m" by (simp only: not_less neg_numeral_le_one) lemma not_one_le_neg_numeral: "\<not> 1 \<le> - numeral m" by (simp only: not_le neg_numeral_less_one) lemma not_numeral_less_neg_one: "\<not> numeral m < - 1" using not_numeral_less_neg_numeral [of m One] by (simp add: numeral_One) lemma not_numeral_le_neg_one: "\<not> numeral m \<le> - 1" using not_numeral_le_neg_numeral [of m One] by (simp add: numeral_One) lemma neg_one_less_numeral: "- 1 < numeral m" using neg_numeral_less_numeral [of One m] by (simp add: numeral_One) lemma neg_one_le_numeral: "- 1 \<le> numeral m" using neg_numeral_le_numeral [of One m] by (simp add: numeral_One) lemma neg_numeral_less_neg_one_iff: "- numeral m < - 1 \<longleftrightarrow> m \<noteq> One" by (cases m) simp_all lemma neg_numeral_le_neg_one: "- numeral m \<le> - 1" by simp lemma not_neg_one_less_neg_numeral: "\<not> - 1 < - numeral m" by simp lemma not_neg_one_le_neg_numeral_iff: "\<not> - 1 \<le> - numeral m \<longleftrightarrow> m \<noteq> One" by (cases m) simp_all lemma sub_non_negative: "sub n m \<ge> 0 \<longleftrightarrow> n \<ge> m" by (simp only: sub_def le_diff_eq) simp lemma sub_positive: "sub n m > 0 \<longleftrightarrow> n > m" by (simp only: sub_def less_diff_eq) simp lemma sub_non_positive: "sub n m \<le> 0 \<longleftrightarrow> n \<le> m" by (simp only: sub_def diff_le_eq) simp lemma sub_negative: "sub n m < 0 \<longleftrightarrow> n < m" by (simp only: sub_def diff_less_eq) simp lemmas le_neg_numeral_simps [simp] = neg_numeral_le_iff neg_numeral_le_numeral not_numeral_le_neg_numeral neg_numeral_le_zero not_zero_le_neg_numeral neg_numeral_le_one not_one_le_neg_numeral neg_one_le_numeral not_numeral_le_neg_one neg_numeral_le_neg_one not_neg_one_le_neg_numeral_iff lemma le_minus_one_simps [simp]: "- 1 \<le> 0" "- 1 \<le> 1" "\<not> 0 \<le> - 1" "\<not> 1 \<le> - 1" by simp_all lemmas less_neg_numeral_simps [simp] = neg_numeral_less_iff neg_numeral_less_numeral not_numeral_less_neg_numeral neg_numeral_less_zero not_zero_less_neg_numeral neg_numeral_less_one not_one_less_neg_numeral neg_one_less_numeral not_numeral_less_neg_one neg_numeral_less_neg_one_iff not_neg_one_less_neg_numeral lemma less_minus_one_simps [simp]: "- 1 < 0" "- 1 < 1" "\<not> 0 < - 1" "\<not> 1 < - 1" by (simp_all add: less_le) lemma abs_numeral [simp]: "abs (numeral n) = numeral n" by simp lemma abs_neg_numeral [simp]: "abs (- numeral n) = numeral n" by (simp only: abs_minus_cancel abs_numeral) lemma abs_neg_one [simp]: "abs (- 1) = 1" by simp end subsubsection {* Natural numbers *} lemma Suc_1 [simp]: "Suc 1 = 2" unfolding Suc_eq_plus1 by (rule one_add_one) lemma Suc_numeral [simp]: "Suc (numeral n) = numeral (n + One)" unfolding Suc_eq_plus1 by (rule numeral_plus_one) definition pred_numeral :: "num \<Rightarrow> nat" where [code del]: "pred_numeral k = numeral k - 1" lemma numeral_eq_Suc: "numeral k = Suc (pred_numeral k)" unfolding pred_numeral_def by simp lemma eval_nat_numeral: "numeral One = Suc 0" "numeral (Bit0 n) = Suc (numeral (BitM n))" "numeral (Bit1 n) = Suc (numeral (Bit0 n))" by (simp_all add: numeral.simps BitM_plus_one) lemma pred_numeral_simps [simp]: "pred_numeral One = 0" "pred_numeral (Bit0 k) = numeral (BitM k)" "pred_numeral (Bit1 k) = numeral (Bit0 k)" unfolding pred_numeral_def eval_nat_numeral by (simp_all only: diff_Suc_Suc diff_0) lemma numeral_2_eq_2: "2 = Suc (Suc 0)" by (simp add: eval_nat_numeral) lemma numeral_3_eq_3: "3 = Suc (Suc (Suc 0))" by (simp add: eval_nat_numeral) lemma numeral_1_eq_Suc_0: "Numeral1 = Suc 0" by (simp only: numeral_One One_nat_def) lemma Suc_nat_number_of_add: "Suc (numeral v + n) = numeral (v + One) + n" by simp (*Maps #n to n for n = 1, 2*) lemmas numerals = numeral_One [where 'a=nat] numeral_2_eq_2 text {* Comparisons involving @{term Suc}. *} lemma eq_numeral_Suc [simp]: "numeral k = Suc n \<longleftrightarrow> pred_numeral k = n" by (simp add: numeral_eq_Suc) lemma Suc_eq_numeral [simp]: "Suc n = numeral k \<longleftrightarrow> n = pred_numeral k" by (simp add: numeral_eq_Suc) lemma less_numeral_Suc [simp]: "numeral k < Suc n \<longleftrightarrow> pred_numeral k < n" by (simp add: numeral_eq_Suc) lemma less_Suc_numeral [simp]: "Suc n < numeral k \<longleftrightarrow> n < pred_numeral k" by (simp add: numeral_eq_Suc) lemma le_numeral_Suc [simp]: "numeral k \<le> Suc n \<longleftrightarrow> pred_numeral k \<le> n" by (simp add: numeral_eq_Suc) lemma le_Suc_numeral [simp]: "Suc n \<le> numeral k \<longleftrightarrow> n \<le> pred_numeral k" by (simp add: numeral_eq_Suc) lemma diff_Suc_numeral [simp]: "Suc n - numeral k = n - pred_numeral k" by (simp add: numeral_eq_Suc) lemma diff_numeral_Suc [simp]: "numeral k - Suc n = pred_numeral k - n" by (simp add: numeral_eq_Suc) lemma max_Suc_numeral [simp]: "max (Suc n) (numeral k) = Suc (max n (pred_numeral k))" by (simp add: numeral_eq_Suc) lemma max_numeral_Suc [simp]: "max (numeral k) (Suc n) = Suc (max (pred_numeral k) n)" by (simp add: numeral_eq_Suc) lemma min_Suc_numeral [simp]: "min (Suc n) (numeral k) = Suc (min n (pred_numeral k))" by (simp add: numeral_eq_Suc) lemma min_numeral_Suc [simp]: "min (numeral k) (Suc n) = Suc (min (pred_numeral k) n)" by (simp add: numeral_eq_Suc) text {* For @{term case_nat} and @{term rec_nat}. *} lemma case_nat_numeral [simp]: "case_nat a f (numeral v) = (let pv = pred_numeral v in f pv)" by (simp add: numeral_eq_Suc) lemma case_nat_add_eq_if [simp]: "case_nat a f ((numeral v) + n) = (let pv = pred_numeral v in f (pv + n))" by (simp add: numeral_eq_Suc) lemma rec_nat_numeral [simp]: "rec_nat a f (numeral v) = (let pv = pred_numeral v in f pv (rec_nat a f pv))" by (simp add: numeral_eq_Suc Let_def) lemma rec_nat_add_eq_if [simp]: "rec_nat a f (numeral v + n) = (let pv = pred_numeral v in f (pv + n) (rec_nat a f (pv + n)))" by (simp add: numeral_eq_Suc Let_def) text {* Case analysis on @{term "n < 2"} *} lemma less_2_cases: "n < 2 \<Longrightarrow> n = 0 \<or> n = Suc 0" by (auto simp add: numeral_2_eq_2) text {* Removal of Small Numerals: 0, 1 and (in additive positions) 2 *} text {* bh: Are these rules really a good idea? *} lemma add_2_eq_Suc [simp]: "2 + n = Suc (Suc n)" by simp lemma add_2_eq_Suc' [simp]: "n + 2 = Suc (Suc n)" by simp text {* Can be used to eliminate long strings of Sucs, but not by default. *} lemma Suc3_eq_add_3: "Suc (Suc (Suc n)) = 3 + n" by simp lemmas nat_1_add_1 = one_add_one [where 'a=nat] (* legacy *) subsection {* Particular lemmas concerning @{term 2} *} context linordered_field_inverse_zero begin lemma half_gt_zero_iff: "0 < a / 2 \<longleftrightarrow> 0 < a" (is "?P \<longleftrightarrow> ?Q") by (auto simp add: field_simps) lemma half_gt_zero [simp]: "0 < a \<Longrightarrow> 0 < a / 2" by (simp add: half_gt_zero_iff) end subsection {* Numeral equations as default simplification rules *} declare (in numeral) numeral_One [simp] declare (in numeral) numeral_plus_numeral [simp] declare (in numeral) add_numeral_special [simp] declare (in neg_numeral) add_neg_numeral_simps [simp] declare (in neg_numeral) add_neg_numeral_special [simp] declare (in neg_numeral) diff_numeral_simps [simp] declare (in neg_numeral) diff_numeral_special [simp] declare (in semiring_numeral) numeral_times_numeral [simp] declare (in ring_1) mult_neg_numeral_simps [simp] subsection {* Setting up simprocs *} lemma mult_numeral_1: "Numeral1 * a = (a::'a::semiring_numeral)" by simp lemma mult_numeral_1_right: "a * Numeral1 = (a::'a::semiring_numeral)" by simp lemma divide_numeral_1: "a / Numeral1 = (a::'a::field)" by simp lemma inverse_numeral_1: "inverse Numeral1 = (Numeral1::'a::division_ring)" by simp text{*Theorem lists for the cancellation simprocs. The use of a binary numeral for 1 reduces the number of special cases.*} lemma mult_1s: fixes a :: "'a::semiring_numeral" and b :: "'b::ring_1" shows "Numeral1 * a = a" "a * Numeral1 = a" "- Numeral1 * b = - b" "b * - Numeral1 = - b" by simp_all setup {* Reorient_Proc.add (fn Const (@{const_name numeral}, _) $ _ => true | Const (@{const_name uminus}, _) $ (Const (@{const_name numeral}, _) $ _) => true | _ => false) *} simproc_setup reorient_numeral ("numeral w = x" | "- numeral w = y") = Reorient_Proc.proc subsubsection {* Simplification of arithmetic operations on integer constants. *} lemmas arith_special = (* already declared simp above *) add_numeral_special add_neg_numeral_special diff_numeral_special (* rules already in simpset *) lemmas arith_extra_simps = numeral_plus_numeral add_neg_numeral_simps add_0_left add_0_right minus_zero diff_numeral_simps diff_0 diff_0_right numeral_times_numeral mult_neg_numeral_simps mult_zero_left mult_zero_right abs_numeral abs_neg_numeral text {* For making a minimal simpset, one must include these default simprules. Also include @{text simp_thms}. *} lemmas arith_simps = add_num_simps mult_num_simps sub_num_simps BitM.simps dbl_simps dbl_inc_simps dbl_dec_simps abs_zero abs_one arith_extra_simps lemmas more_arith_simps = neg_le_iff_le minus_zero left_minus right_minus mult_1_left mult_1_right mult_minus_left mult_minus_right minus_add_distrib minus_minus mult.assoc lemmas of_nat_simps = of_nat_0 of_nat_1 of_nat_Suc of_nat_add of_nat_mult text {* Simplification of relational operations *} lemmas eq_numeral_extra = zero_neq_one one_neq_zero lemmas rel_simps = le_num_simps less_num_simps eq_num_simps le_numeral_simps le_neg_numeral_simps le_minus_one_simps le_numeral_extra less_numeral_simps less_neg_numeral_simps less_minus_one_simps less_numeral_extra eq_numeral_simps eq_neg_numeral_simps eq_numeral_extra lemma Let_numeral [simp]: "Let (numeral v) f = f (numeral v)" -- {* Unfold all @{text let}s involving constants *} unfolding Let_def .. lemma Let_neg_numeral [simp]: "Let (- numeral v) f = f (- numeral v)" -- {* Unfold all @{text let}s involving constants *} unfolding Let_def .. declaration {* let fun number_of thy T n = if not (Sign.of_sort thy (T, @{sort numeral})) then raise CTERM ("number_of", []) else Numeral.mk_cnumber (Thm.ctyp_of thy T) n; in K ( Lin_Arith.add_simps (@{thms arith_simps} @ @{thms more_arith_simps} @ @{thms rel_simps} @ @{thms pred_numeral_simps} @ @{thms arith_special numeral_One} @ @{thms of_nat_simps}) #> Lin_Arith.add_simps [@{thm Suc_numeral}, @{thm Let_numeral}, @{thm Let_neg_numeral}, @{thm Let_0}, @{thm Let_1}, @{thm le_Suc_numeral}, @{thm le_numeral_Suc}, @{thm less_Suc_numeral}, @{thm less_numeral_Suc}, @{thm Suc_eq_numeral}, @{thm eq_numeral_Suc}, @{thm mult_Suc}, @{thm mult_Suc_right}, @{thm of_nat_numeral}] #> Lin_Arith.set_number_of number_of) end *} subsubsection {* Simplification of arithmetic when nested to the right. *} lemma add_numeral_left [simp]: "numeral v + (numeral w + z) = (numeral(v + w) + z)" by (simp_all add: add.assoc [symmetric]) lemma add_neg_numeral_left [simp]: "numeral v + (- numeral w + y) = (sub v w + y)" "- numeral v + (numeral w + y) = (sub w v + y)" "- numeral v + (- numeral w + y) = (- numeral(v + w) + y)" by (simp_all add: add.assoc [symmetric]) lemma mult_numeral_left [simp]: "numeral v * (numeral w * z) = (numeral(v * w) * z :: 'a::semiring_numeral)" "- numeral v * (numeral w * y) = (- numeral(v * w) * y :: 'b::ring_1)" "numeral v * (- numeral w * y) = (- numeral(v * w) * y :: 'b::ring_1)" "- numeral v * (- numeral w * y) = (numeral(v * w) * y :: 'b::ring_1)" by (simp_all add: mult.assoc [symmetric]) hide_const (open) One Bit0 Bit1 BitM inc pow sqr sub dbl dbl_inc dbl_dec subsection {* code module namespace *} code_identifier code_module Num \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith end
Do you want to work for one of the market leaders in the field of Inspection and certification? With an organization that makes international quality and safety transparent in a large number of branches and in very different areas? And where you make a concrete contribution every day to a sustainable and safer world? Apply now at Kiwa! This position represents a unique opportunity to join a major player in the Testing, Inspection & Certification (TIC) industry within the food / feed sector. As the (Senior) Key Account Manager / Business Developer, you will manage new and existing relationships with international key accounts in the food sectors whole chain, from producers to retailers. By drawing on your collaborative working relationships and deep business understanding, you will be responsible for developing international key accounts. The role offers the prospect of working in a dynamic multi-functional team environment, within a fast paced and constantly changing industry. You will be responsible for developing the sales relationships together with local Kiwa offices throughout Europe. This international role will have its focus in The Netherlands, West and Northern Europe so will involve travelling. For this position, we are looking for an individual with strong interpersonal skills, a problem solving mentality and a proactive mindset. Above all, you have a real passion for achieving winning result as part of a team. You must be fluent in English and preferably a second European language, being German, French, Spanish and Italian. As a modern employer we believe our employees are our most important asset. This can be seen in our favorable working conditions, in the attention we have for our employees and in the way we handle learning and development. What this means for you depends on your specific knowledge and experience. We would like to discuss this with you. Do you want to work in a fascinating and varied job in an ambitious company? Then send your resume and motivation to corporate HR at [email protected]. you would like to receive additional information or have any questions, please contact Hans Lindahl ([email protected]), head of business sector FFF or Ad Besemer ([email protected]), Vice President Business Development. We look forward meeting you!
\chapter{Image Buffers} \label{chap:imagebuf} \index{Image Buffers|(} \index{ImageBuf|(} \section{ImageBuf Introduction and Theory of Operation} \label{sec:imagebuf:intro} \ImageBuf is a utility class that stores an entire image. It provides a nice API for reading, writing, and manipulating images as a single unit, without needing to worry about any of the details of storage or I/O. \smallskip \noindent An \ImageBuf can store its pixels in one of several ways: \begin{itemize} \item Allocate ``local storage'' to hold the image pixels internal to the \ImageBuf. This storage will be freed when the \ImageBuf is destroyed. \item ``Wrap'' pixel memory already allocated by the calling application, which will continue to own that memory and be responsible for freeing it after the \ImageBuf is destroyed. \item Be ``backed'' by an \ImageCache, which will automatically be used to retreive pixels when requested, but the \ImageBuf will not allocate separate storage for it. This brings all the advantages of the \ImageCache, but can only be used for read-only \ImageBuf's that reference a stored image file. \end{itemize} All I/O involving \ImageBuf (that is, calls to {\cf read} or {\cf write}) are implemented in terms of \ImageCache, \ImageInput, and \ImageOutput underneath, and so support all of the image file formats supported by OIIO. \smallskip \noindent The \ImageBuf class definition requires that you \begin{code} #include <OpenImageIO/imagebuf.h> \end{code} \subsection{Helper: \ROI} \label{sec:ROI} \indexapi{ROI} \index{region of interest} \ROI is a small helper struct that describes a rectangular region of pixels of an image (and a channel range). An \ROI holds the following data members: \apiitem{int xbegin, xend, ybegin, yend, zbegin, zend; \\ int chbegin, chend;} Describes the $x, y, z$ range of the region. The {\cf end} values are \emph{exclusive}; that is, ({\cf xbegin, ybegin, zbegin}) is the first pixel included in the range, ({\cf xend-1, yend-1, zend-1}) is the last pixel included in the range, and ({\cf xend, yend, zend}) is \emph{one past the last pixel} in each dimension. Similarly, {\cf chbegin} and {\cf chend} describe a range of channels: {\cf chbegin} is the first channel, {\cf chend} is \emph{one past the last channel}. \apiend \smallskip \noindent \ROI has the following member functions and friends: \smallskip \apiitem{ROI ()} A default-constructed \ROI has an \emph{undefined} region, which is interpreted to mean all valid pixels and all valid channels of an image. \apiend \apiitem{bool ROI::defined () const} Returns {\cf true} if the \ROI is defined, having a specified region, or {\cf false} if the \ROI is undefined. \apiend \apiitem{static ROI ROI::All ()} Returns an undefined \ROI, which is interpreted to mean all valid pixels and all valid channels of an image. \apiend \apiitem{int ROI::width () const \\ int ROI::height () const \\ int ROI::depth () const} Returns the width, height, and depth, respectively, of a defined region. These do not return sensible values for an \ROI that is not {\cf defined()}. \apiend \apiitem{imagesize_t ROI::npixels () const} For an \ROI that is {\cf defined()}, returns the total number of pixels included in the region, or {\cf 0} for an undefined \ROI. \apiend \apiitem{imagesize_t ROI::nchannels () const} For an \ROI that is {\cf defined()}, returns the number of channels in the channel range. \apiend \apiitem{ROI roi_union (const ROI \&A, const ROI \&B) \\ ROI roi_intersection (const ROI \&A, const ROI \&B)} Returns the union of two \ROI's (an \ROI that is exactly big enough to include all the pixels of both individual \ROI's) or intersection of two \ROI's (an \ROI that contains only the pixels that are contained in \emph{both} \ROI's). \apiend \apiitem{ROI get_roi (const ImageSpec \&spec) \\ ROI get_roi_full (const ImageSpec \&spec)} Return the ROI describing {\cf spec}'s pixel data window (the {\cf x, y, z, width, height, depth} fields) or the full (display) window (the {\cf full_x, full_y, full_z, full_width, full_height, full_depth} fields), respectively. \apiend \apiitem{void set_roi (const ImageSpec \&spec, const ROI \&newroi) \\ void set_roi_full (const ImageSpec \&spec, const ROI \&newroi)} Alters the {\cf spec} so to make its pixel data window or the full (display) window match {\cf newroi}. \apiend \section{Constructing, reading, and writing an \ImageBuf} \subsection*{Default constructor of an empty \ImageBuf} \apiitem{ImageBuf ()} The default constructor makes an uninitialized \ImageBuf. There isn't much you can do with an uninitialized buffer until you call {\cf reset()}. \apiend \apiitem{void clear ()} Resets the \ImageBuf to a pristine state identical to that of a freshly constructed \ImageBuf using the default constructor. \apiend \subsection*{Constructing and initializing a writeable \ImageBuf} \apiitem{ImageBuf (const ImageSpec \&spec) \\ ImageBuf (string_view name, const ImageSpec \&spec)} Constructs a writeable \ImageBuf with the given specification (including resolution, data type, metadata, etc.), initially set to all black pixels. Optionally, you may name the \ImageBuf. \apiend \apiitem{void reset (const ImageSpec \&spec) \\ void reset (string_view name, const ImageSpec \&spec)} Destroys any previous contents of the \ImageBuf and re-initializes it as a writeable all-black \ImageBuf with the given specification (including resolution, data type, metadata, etc.). Optionally, you may name the \ImageBuf. \apiend \apiitem{bool make_writeable (bool keep_cache_type = false)} \NEW % 1.6 Force the \ImageBuf to be writeable. That means that if it was previously backed by an \ImageCache (storage was {\cf IMAGECACHE}), it will force a full read so that the whole image is in local memory. This will invalidate any current iterators on the image. It has no effect if the image storage not {\cf IMAGECACHE}. Return {\cf true} if it works (including if no read was necessary), {\cf false} if something went horribly wrong. If {\cf keep_cache_type} is true, it preserves any \ImageCache-forced data types (you might want to do this if it is critical that the apparent data type doesn't change, for example if you are calling make_writeable from within a type-specialized function). \apiend \subsection*{Constructing a readable \ImageBuf and reading from a file} Constructing a readable \ImageBuf that will hold an image to be read from disk. \apiitem{ImageBuf (string_view name, int subimage=0, int miplevel=0, \\ \bigspc\bigspc ImageCache *imagecache = NULL, \\ \bigspc\bigspc const ImageSpec *config = NULL)} Construct an \ImageBuf that will be used to read the named file (at the given subimage and MIP-level, defaulting to the first in the file). But don't read it yet! The image will actually be read when other methods need to access the spec and/or pixels, or when an explicit call to {\cf init_spec()} or {\cf read()} is made, whichever comes first. If {\cf imagecache} is non-NULL, the custom \ImageCache will be used (if applicable); otherwise, a NULL imagecache indicates that the global/shared \ImageCache should be used. If {\cf config} is not NULL, it points to an \ImageSpec giving requests or special instructions to be passed on to the eventual {\cf ImageInput::open()} call. \apiend \apiitem{void reset (string_view name, int subimage=0, int miplevel=0, \\ \bigspc\bigspc ImageCache *imagecache = NULL \\ \bigspc\bigspc const ImageSpec *config = NULL)} Destroys any previous contents of the \ImageBuf and re-initializes it to read the named file (but doesn't actually read yet). If {\cf config} is not NULL, it points to an \ImageSpec giving requests or special instructions to be passed on to the eventual {\cf ImageInput::open()} call. \apiend \apiitem{bool read (int subimage=0, int miplevel=0, bool force=false, \\ \bigspc TypeDesc convert=TypeDesc::UNKNOWN, \\ \bigspc ProgressCallback progress_callback=NULL, \\ \bigspc void *progress_callback_data=NULL)} Explicitly reads the particular subimage and MIP level of the image. Generally, this will skip the expensive read if the file has already been read into the \ImageBuf (at the specified subimage and MIP level). It will clear and re-allocate memory if the previously allocated space was not appropriate for the size or data type of the image being read. If {\cf convert} is set to a specific type (not {\cf UNKNOWN}), the \ImageBuf memory will be allocated for that type specifically and converted upon read. In general, {\cf read()} will try not to do any I/O at the time of the {\cf read()} call, but rather to have the \ImageBuf ``backed'' by an \ImageCache, which will do the file I/O on demand, as pixel values are needed, and in that case the \ImageBuf doesn't actually allocate memory for the pixels (the data lives in the \ImageCache). However, there are several conditions for which the \ImageCache will be bypassed, the \ImageBuf will allocate ``local'' memory, and the disk file will be read directly into allocated buffer at the time of the {\cf read()} call: (a) if the {\cf force} parameter is {\cf true}; (b) if the {\cf convert} parameter requests a data format conversion to a type that is not the native file type and also is not one of the internal types supported by the {\cf ImageCache} (specifically, {\cf FLOAT} and {\cf UINT8}); (c) if the \ImageBuf already has local pixel memory allocated, or ``wraps'' an application buffer. If {\cf progress_callback} is non-NULL, the underlying read, if expensive, may make several calls to \begin{code} progress_callback(progress_callback_data, portion_done); \end{code} \noindent which allows you to implement some sort or progress meter. Note that if the \ImageBuf is backed by an \ImageCache, the progress callback will never be called, since no actual file I/O will occur at this time (\ImageCache will load tiles or scanlines on demand, as individual pixel values are needed). Note that {\cf read()} is not strictly necessary. If you are happy with the filename, subimage and MIP level specified by the \ImageBuf constructor (or the last call to {\cf reset()}), and you want the storage to be backed by the {\cf ImageCache} (including storing the pixels in whatever data format that implies), then the file contents will be automatically read the first time you make any other \ImageBuf API call that requires the spec or pixel values. The only reason to call {\cf read()} yourself is if you are changing the filename, subimage, or MIP level, or if you want to use {\cf force=true} or a specific {\cf convert} value to force data format conversion. \apiend \apiitem{bool init_spec (string_view filename, int subimage, int miplevel)} This call will read the \ImageSpec for the given file, subimage, and MIP level into the \ImageBuf, but will not read the pixels or allocate any local storage (until a subsequent call to {\cf read()}). This is helpful if you have an \ImageBuf and you need to know information about the image, but don't want to do a full read yet, and maybe won't need to do the full read, depending on what's found in the spec. Note that {\cf init_spec()} is not strictly necessary. If you are happy with the filename, subimage and MIP level specified by the \ImageBuf constructor (or the last call to {\cf reset()}), then the spec will be automatically read the first time you make any other \ImageBuf API call that requires it. The only reason to call {\cf read()} yourself is if you are changing the filename, subimage, or MIP level, or if you want to use {\cf force=true} or a specific {\cf convert} value to force data format conversion. \apiend \subsection*{Constructing an \ImageBuf that ``wraps'' an application buffer} \apiitem{ImageBuf (const ImageSpec \&spec, void *buffer) \\ ImageBuf (string_view name, const ImageSpec \&spec, void *buffer)} Constructs an ImageBuf that "wraps" a memory buffer owned by the calling application. It can write pixels to this buffer, but can't change its resolution or data type. Optionally, it names the \ImageBuf. \apiend \subsection*{Writing an \ImageBuf to a file} \apiitem{bool write (string_view filename, \\ \bigspc string_view fileformat = "", \\ \bigspc ProgressCallback progress_callback=NULL, \\ \bigspc void *progress_callback_data=NULL) const} Write the image to the named file in the named format (an empty format means to infer the type from the filename extension). Return {\cf true} if all went ok, {\cf false} if there were errors writing. By default, it will always write a scanline-oriented file, unless the {\cf set_write_tiles()} method has been used to override this. Also, it will use the data format of the buffer itself, unless the {\cf set_write_format()} method has been used to override the data format. \apiend \apiitem{bool write (ImageOutput *out, \\ \bigspc ProgressCallback progress_callback=NULL, \\ \bigspc void *progress_callback_data=NULL) const} Write the image to the open \ImageOutput {\cf out}. Return {\cf true} if all went ok, {\cf false} if there were errors writing. It does NOT close the file when it's done (and so may be called in a loop to write a multi-image file). \apiend \apiitem{void set_write_format (TypeDesc format=TypeDesc::UNKNOWN) \\ set set_write_tiles (int width=0, int height=0, int depth=0)} These methods allow the caller to override the data format and tile sizing when using the {\cf write()} function (the variety that does not take an open {\cf ImageOutput*}). \apiend \section{Getting and setting basic information about an \ImageBuf} \apiitem{bool initialized () const} Returns {\cf true} if the \ImageBuf is initialized, {\cf false} if not yet initialized. \apiend \apiitem{IBStorage {\ce storage} () const} Returns an enumerated type describing the type of storage currently employed by the \ImageBuf: {\cf UNINITIALIZED} (no storage), {\cf LOCALBUFFER} (the \ImageBuf has allocated and owns the pixel memory), {\cf APPBUFFER} (the \ImageBuf ``wraps'' memory owned by the calling application), or {\cf IMAGECACHE} (the image is backed by an \ImageCache). \apiend \apiitem{const ImageSpec \& spec () const \\ const ImageSpec \& nativespec () const} The {\cf spec()} function returns a {\cf const} reference to an \ImageSpec that describes the image data held by the \ImageBuf. The {\cf nativespec()} function returns a {\cf const} reference to an \ImageSpec that describes the actual data in the file that was read. These may differ --- for example, if a data format conversion was requested, if the buffer is backed by an \ImageCache which stores the pixels internally in a different data format than that of the file, or if the file had differing per-channel data formats (\ImageBuf must contain a single data format for all channels). \apiend \apiitem{string_view {\ce name} () const} Returns the name of the buffer (name of the file, for an \ImageBuf read from disk). \apiend \apiitem{string_view {\ce file_format_name} () const} Returns the name of the file format, for an \ImageBuf read from disk (for example, \qkw{openexr}). \apiend \apiitem{int subimage () const \\ int nsubimages () const \\ int miplevel () const \\ int nmiplevels () const} The {\cf subimage()} and {\cf miplevel()} methods return the subimage and MIP level of the image held by the \ImageBuf (the file it came from may hold multiple subimages and/or MIP levels, but the \ImageBuf can only store one of those at any given time). The {\cf nsubimages()} method returns the total number of subimages in the file, and the {\cf nmiplevels()} method returns the total number of MIP levels in the currently-loaded subimage. \apiend \apiitem{int nchannels () const} Returns the number of channels stored in the buffer (this is equivalent to {\cf spec().nchannels}). \apiend \apiitem{int xbegin () const \\ int xend () const \\ int ybegin () const \\ int yend () const \\ int zbegin () const \\ int zend () const} Returns the {\cf [begin,end)} range of the pixel data window of the buffer. These are equivalent to {\cf spec().x}, {\cf spec().x+spec().width}, {\cf spec().y}, {\cf spec().y+spec().height}, {\cf spec().z}, and {\cf spec().z+spec().depth}, respectively. \apiend \apiitem{int orientation () const \\ int oriented_width () const \\ int oriented_height () const \\ int oriented_x () const \\ int oriented_y () const \\ int oriented_full_width () const \\ int oriented_full_height () const \\ int oriented_full_x () const \\ int oriented_full_y () const } The {\cf orientation()} returns the interpretation of the layout (top/bottom, left/right) of the image, per the table in Section~\ref{metadata:orientation}. The oriented width, height, x, and y describe the pixel data window after taking the display orientation into consideration. The \emph{full} versions the ``full'' (a.k.a.\ display) window after taking the display orientation into consideration. \apiend \apiitem{void {\ce set_orientation} (int orient)} Sets the \qkw{Orientation} metadata value. \apiend \apiitem{TypeDesc pixeltype () const} The data type of the pixels stored in the buffer (equivalent to {\cf spec().format}). \apiend \apiitem{void set_full (int xbegin, int xend, int ybegin, int yend, \\ \bigspc\spc int zbegin, int zend)} Alters the metadata of the spec in the \ImageBuf to reset the ``full'' image size (a.k.a.\ ``display window''). This does not affect the size of the pixel data window. \apiend \apiitem{ImageSpec \& specmod ()} This returns a \emph{writeable} reference to the \ImageSpec describing the buffer. It's ok to modify most of the metadata, but if you modify the spec's {\cf format}, {\cf width}, {\cf height}, or {\cf depth} fields, you get the pain you deserve, as the \ImageBuf will no longer have correct knowledge of its pixel memory layout. USE WITH EXTREME CAUTION. \apiend \section{Copying \ImageBuf's and blocks of pixels} \apiitem{bool {\ce copy} (const ImageBuf \&src) \\ bool {\ce copy} (const ImageBuf \&src, TypeDesc format)} Copies {\cf src} to {\cf this} -- both pixel values and all metadata. If a {\cf format} is provided, {\cf this} will get the specified pixel data type rather than using the same pixel format as {\cf src}. \apiend \apiitem{void copy_metadata (const ImageBuf \&src)} Copies all metadata (except for {\cf format}, {\cf width}, {\cf height}, {\cf depth} from {\cf src} to {\cf this}. \apiend \apiitem{bool copy_pixels (const ImageBuf \&src)} Copies the pixels of {\cf src} to {\cf this}, but does not change the metadata (other than format and resolution) of {\cf this}. \apiend \apiitem{void swap (ImageBuf \&other)} Swaps the entire contents of {\cf other} and {\cf this}. \apiend \apiitem{bool get_pixel_channels (int xbegin, int xend, int ybegin, int yend, \\ \bigspc\bigspc int zbegin, int zend, int chbegin, int chend,\\ \bigspc\bigspc TypeDesc format, void *result,\\ \bigspc\bigspc stride_t xstride=AutoStride,\\ \bigspc\bigspc stride_t ystride=AutoStride,\\ \bigspc\bigspc stride_t zstride=AutoStride) const} Retrieve the rectangle of pixels spanning {\cf [xbegin..xend)} $\times$ {\cf [ybegin..yend)} $\times$ {\cf [zbegin..zend)}, channels {\cf [chbegin,chend)} (all with exclusive end), specified as integer pixel coordinates, at the current subimage and MIP-map level, storing the pixel values beginning at the address specified by {\cf result} and with the given strides (by default, {\cf AutoStride} means the usual contiguous packing of pixels) and converting into the data type described by {\cf format}. It is up to the caller to ensure that {\cf result} points to an area of memory big enough to accommodate the requested rectangle. Return {\cf true} if the operation could be completed, otherwise return {\cf false}. \apiend \apiitem{bool get_pixels (int xbegin, int xend, int ybegin, int yend, \\ \bigspc\bigspc int zbegin, int zend, TypeDesc format, \\ \bigspc\bigspc void *result, stride_t xstride=AutoStride,\\ \bigspc\bigspc stride_t ystride=AutoStride, \\ \bigspc\bigspc stride_t zstride=AutoStride) const} Retrieve the rectangle of pixels spanning {\cf [xbegin..xend)} $\times$ {\cf [ybegin..yend)} $\times$ {\cf [zbegin..zend)} (all with exclusive end), specified as integer pixel coordinates, at the current subimage and MIP-map level, storing the pixel values beginning at the address specified by {\cf result} and with the given strides (by default, {\cf AutoStride} means the usual contiguous packing of pixels) and converting into the data type described by {\cf format}. It is up to the caller to ensure that {\cf result} points to an area of memory big enough to accommodate the requested rectangle. Return {\cf true} if the operation could be completed, otherwise return {\cf false}. \apiend \section{Getting and setting individual pixel values -- simple but slow} \apiitem{float getchannel (int x, int y, int z, int c, \\ \bigspc\spc WrapMode wrap=WrapBlack) const} Returns the value of pixel {\cf x, y, z}, channel {\cf c}. The {\cf wrap} describes what value should be returned if the {\cf x, y, z} coordinates are outside the pixel data window, and may be one of: {\cf WrapBlack}, {\cf WrapClamp}, {\cf WrapPeriodic}, or {\cf WrapMirror}. \apiend \apiitem{void getpixel (int x, int y, int z, float *pixel, \\ \bigspc\spc int maxchannels=1000, WrapMode wrap=WrapBlack) const} Retrieves pixel ({\cf x, y, z}), placing its contents in {\cf pixel[0..n-1]}, where $n$ is the smaller of {\cf maxchannels} or the actual number of channels stored in the buffer. It is up to the application to ensure that {\cf pixel} points to enough memory to hold the required number of channels. The {\cf wrap} describes what value should be returned if the {\cf x, y, z} coordinates are outside the pixel data window, and may be one of: {\cf WrapBlack}, {\cf WrapClamp}, {\cf WrapPeriodic}, or {\cf WrapMirror}. \apiend \apiitem{void {\ce interppixel} (float x, float y, float *pixel, \\ \bigspc\bigspc WrapMode wrap=WrapBlack) const \\ void {\ce interppixel_bicubic} (float x, float y, float *pixel, \\ \bigspc\bigspc WrapMode wrap=WrapBlack) const} Sample the image plane at coordinates $(x,y)$, using linear interpolation between pixels by default, or B-spline bicubic interpolation for the {\cf _bicubic} varieties, placing the result in {\cf pixel[0..n-1]}, where $n$ is the smaller of {\cf maxchannels} or the actual number of channels stored in the buffer. It is up to the application to ensure that {\cf pixel} points to enough memory to hold the required number of channels. The sampling location is specified in the floating-point pixel coordinate system, where pixel $(i,j)$ is centered at image plane coordinate $(i+0.5, j+0.5)$. The {\cf wrap} describes how the image function should be computed outside the boundaries of the pixel data window, and may be one of: {\cf WrapBlack}, {\cf WrapClamp}, {\cf WrapPeriodic}, or {\cf WrapMirror}. \apiend \apiitem{void {\ce interppixel_NDC} (float s, float t, float *pixel, \\ \bigspc\bigspc WrapMode wrap=WrapBlack) const \\ void {\ce interppixel_bicubic_NDC} (float s, float t, float *pixel, \\ \bigspc\bigspc WrapMode wrap=WrapBlack) const} Sample the image plane at coordinates $(s,t)$, similar to the {\cf\small interppixel} and {\cf\small interppixel_bicubic} methods, but specifying location using the ``NDC'' (normalized device coordinate) system where (0,0) is the upper left corner of the full (a.k.a. ``display'') window and (1,1) is the lower right corner of the full/display window. \apiend \apiitem{void setpixel (int x, int y, int z, const float *pixel, int maxchannels=1000)} Set the pixel with coordinates {\cf (x, y, z)} to have the values {\cf pixel[0..n-1]}. The number of channels, {\cf n}, is the minimum of {\cf minchannels} and the actual number of channels in the image. \apiend \subsection*{Deep data in an \ImageBuf} \apiitem{bool deep () const} Returns {\cf true} if the \ImageBuf holds a ``deep'' image, {\cf false} if the \ImageBuf holds an ordinary pixel-based image. \apiend \apiitem{int deep_samples (int x, int y, int z=0) const} Returns the number of deep samples for the given pixel, or 0 if there are no deep samples for that pixel (including if the pixel coordinates are outside the data area). For non-deep images, it will always return 0. \apiend \apiitem{const void *deep_pixel_ptr (int x, int y, int z, int c) const} Returns a pointer to the raw array of deep samples for channel {\cf c} of pixel {\cf (x,y,z)}. This will return {\cf NULL} if the pixel coordinates or channel number are out of range, if the pixel/channel has no deep samples, or if the image is not deep. \apiend \apiitem{float deep_value (int x, int y, int z, int c, int s) const} Return the value (as a {\cf float}) of sample {\cf s} of channel {\cf c} of pixel {\cf (x,y,z)}. Return {\cf 0.0} if not a deep image or if the pixel coordinates, channel number, or sample number are out of range, or if it has no deep samples. \apiend \section{Miscellaneous} \apiitem{void error (const char *format, ...) const} This can be used to register an error associated with this \ImageBuf. \apiend \apiitem{bool has_error (void) const} Returns {\cf true} if the \ImageBuf has had an error and has an error message to retrieve via {\cf geterror()}. \apiend \apiitem{std::string geterror (void) const} Return the text of all error messages issued since {\cf geterror()} was called (or an empty string if no errors are pending). This also clears the error message for next time. \apiend \apiitem{void *localpixels (); \\ const void *localpixels () const;} Returns a raw pointer to the ``local'' pixel memory, if they are fully in RAM and not backed by an \ImageCache (in which case, {\cf NULL} will be returned). You can also test it like a {\cf bool} to find out if pixels are local. \apiend \apiitem{const void *pixeladdr (int x, int y, int z=0) const \\ void *pixeladdr (int x, int y, int z)} Return the address where pixel (x,y,z) is stored in the image buffer. Use with extreme caution! Will return NULL if the pixel values aren't local (for example, if backed by an \ImageCache). \apiend \section{Iterators -- the fast way of accessing individual pixels} Sometimes you need to visit every pixel in an \ImageBuf (or at least, every pixel in a large region). Using the {\cf getpixel} and {\cf setpixel} for this purpose is simple but very slow. But \ImageBuf provides templated {\cf Iterator} and {\cf ConstIterator} types that are very inexpensive and hide all the details of local versus cached storage. An {\cf Iterator} is associated with a particular \ImageBuf. The {\cf Iterator} has a \emph{current pixel} coordinate that it is visiting, and an \emph{iteration range} that describes a rectangular region of pixels that it will visits as it advances. It always starts at the upper left corner of the iteration region. We say that the iterator is \emph{done} after it has visited every pixel in its iteration range. We say that a pixel coordinate \emph{exists} if it is within the pixel data window of the \ImageBuf. We say that a pixel coordinate is \emph{valid} if it is within the iteration range of the iterator. The {\cf ImageBuf::ConstIterator} is identical to the {\cf Iterator}, except that {\cf ConstIterator} may be used on a {\cf const ImageBuf} and may not be used to alter the contents of the \ImageBuf. For simplicity, the remainder of this section will only discuss the {\cf Iterator}. The {\cf Iterator<BUFT,USERT>} is templated based on two types: {\cf BUFT} the type of the data stored in the \ImageBuf, and {\cf USERT} type type of the data that you want to manipulate with your code. {\cf USERT} defaults to {\cf float}, since usually you will want to do all your pixel math with {\cf float}. We will thus use {\cf Iterator<T>} synonymously with {\cf Iterator<T,float>}. For the remainder of this section, we will assume that you have a {\cf float}-based \ImageBuf, for example, if it were set up like this: \begin{code} ImageBuf buf ("myfile.exr"); buf.read (0, 0, true, TypeDesc::FLOAT); \end{code} \apiitem{Iterator<BUFT> (ImageBuf \&buf, WrapMode wrap=WrapDefault)} Initialize an iterator that will visit every pixel in the data window of {\cf buf}, and start it out pointing to the upper left corner of the data window. The {\cf wrap} describes what values will be retrieved if the iterator is positioned outside the data window of the buffer. \apiend \apiitem{Iterator<BUFT> (ImageBuf \&buf, const ROI \&roi, WrapMode wrap=WrapDefault)} Initialize an iterator that will visit every pixel of {\cf buf} within the region described by {\cf roi}, and start it out pointing to pixel ({\cf roi.xbegin, roi.ybegin, roi.zbegin}). The {\cf wrap} describes what values will be retrieved if the iterator is positioned outside the data window of the buffer. \apiend \apiitem{Iterator<BUFT> (ImageBuf \&buf, int x, int y, int z, WrapMode wrap=WrapDefault)} Initialize an iterator that will visit every pixel in the data window of {\cf buf}, and start it out pointing to pixel ({\cf x, y, z}). The {\cf wrap} describes what values will be retrieved if the iterator is positioned outside the data window of the buffer. \apiend \apiitem{Iterator::operator++ ()} The {\cf ++} operator advances the iterator to the next pixel in its iteration range. (Both prefix and postfix increment operator are supported.) \apiend \apiitem{bool Iterator::done () const} Returns {\cf true} if the iterator has completed its visit of all pixels in its iteration range. \apiend \apiitem{ROI Iterator::range () const} Returns the iteration range of the iterator, expressed as an \ROI. \apiend \apiitem{int Iterator::x () const \\ int Iterator::y () const \\ int Iterator::z () const} Returns the $x$, $y$, and $z$ pixel coordinates, respectively, of the pixel that the iterator is currently visiting. \apiend \apiitem{bool Iterator::valid () const} Returns {\cf true} if the iterator's current pixel coordinates are within its iteration range. \apiend \apiitem{bool Iterator::valid (int x, int y, int z=0) const} Returns {\cf true} if pixel coordinate ({\cf x, y, z}) are within the iterator's iteration range (regardless of where the iterator itself is currently pointing). \apiend \apiitem{bool Iterator::exists () const} Returns {\cf true} if the iterator's current pixel coordinates are within the data window of the \ImageBuf. \apiend \apiitem{bool Iterator::exists (int x, int y, int z=0) const} Returns {\cf true} if pixel coordinate ({\cf x, y, z}) are within the pixel data window of the \ImageBuf (regardless of where the iterator itself is currently pointing). \apiend \apiitem{USERT\& Iterator::operator[] (int i)} The value of channel {\cf i} of the current pixel. (The wrap mode, set up when the iterator was constructed, determines what value is returned if the iterator points outside the pixel data window of its buffer.) \apiend \apiitem{int Iterator::deep_samples () const} For deep images only, retrieves the number of deep samples for the current pixel. \apiend \apiitem{USERT\& Iterator::deep_value (int c, int s)} For deep images only, returns the value of channel {\cf c}, sample number {\cf s}, at the current pixel. \apiend \subsection*{Example: Visiting all pixels to compute an average color} \begin{code} void print_channel_averages (const std::string &filename) { // Set up the ImageBuf and read the file ImageBuf buf (filename); bool ok = buf.read (0, 0, true, TypeDesc::FLOAT); // Force a float buffer if (! ok) return; // Initialize a vector to contain the running total int nc = buf.nchannels(); std::vector<float> total (n, 0.0f); // Iterate over all pixels of the image, summing channels separately for (ImageBuf::ConstIterator<float> it (buf); ! it.done(); ++it) for (int c = 0; c < nc; ++c) total[c] += it[c]; // Print the averages imagesize_t npixels = buf.spec().image_pixels(); for (int c = 0; c < nc; ++c) std::cout << "Channel " << c << " avg = " (total[c] / npixels) << "\n"; } \end{code} \subsection*{Example: Set all pixels in a region to black} \label{makeblackexample} \begin{code} bool make_black (ImageBuf &buf, ROI region) { if (buf.spec().format != TypeDesc::FLOAT) return false; // Assume it's a float buffer // Clamp the region's channel range to the channels in the image roi.chend = std::min (roi.chend, buf.nchannels); // Iterate over all pixels in the region... for (ImageBuf::Iterator<float> it (buf, region); ! it.done(); ++it) { if (! it.exists()) // Make sure the iterator is pointing continue; // to a pixel in the data window for (int c = roi.chbegin; c < roi.chend; ++c) it[c] = 0.0f; // clear the value } return true; } \end{code} \section{Dealing with buffer data types} The previous section on iterators presented examples and discussion based on the assumption that the \ImageBuf was guaranteed to store {\cf float} data and that you wanted all math to also be done as {\cf float} computations. Here we will explain how to deal with buffers and files that contain different data types. \subsection*{Strategy 1: Only have {\cf float} data in your \ImageBuf} \noindent When creating your own buffers, make sure they are {\cf float}: \begin{code} ImageSpec spec (640, 480, 3, TypeDesc::FLOAT); // <-- float buffer ImageBuf buf ("mybuf", spec); \end{code} \noindent When using \ImageCache-backed buffers, force the \ImageCache to convert everything to {\cf float}: \begin{code} // Just do this once, to set up the cache: ImageCache *cache = ImageCache::create (true /* shared cache */); cache->attribute ("forcefloat", 1); ... ImageBuf buf ("myfile.exr"); // Backed by the shared cache \end{code} \noindent Or force the read to convert to {\cf float} in the buffer if it's not a native type that would automatically stored as a {\cf float} internally to the \ImageCache:\footnote{\ImageCache only supports a limited set of types internally, currently only FLOAT and UINT8, and all other data types are converted to these automatically as they are read into the cache.} \begin{code} ImageBuf buf ("myfile.exr"); // Backed by the shared cache buf.read (0, 0, false /* don't force read to local mem */, TypeDesc::FLOAT /* but do force conversion to float*/); \end{code} \noindent Or force a read into local memory unconditionally (rather than relying on the \ImageCache), and convert to {\cf float}: \begin{code} ImageBuf buf ("myfile.exr"); buf.read (0, 0, true /*force read*/, TypeDesc::FLOAT /* force conversion */); \end{code} \subsection*{Strategy 2: Template your iterating functions based on buffer type} Consider the following alternate version of the {\cf make_black} function from Section~\ref{makeblackexample}: \begin{code} template<type BUFT> static bool make_black_impl (ImageBuf &buf, ROI region) { // Clamp the region's channel range to the channels in the image roi.chend = std::min (roi.chend, buf.nchannels); // Iterate over all pixels in the region... for (ImageBuf::Iterator<BUFT> it (buf, region); ! it.done(); ++it) { if (! it.exists()) // Make sure the iterator is pointing continue; // to a pixel in the data window for (int c = roi.chbegin; c < roi.chend; ++c) it[c] = 0.0f; // clear the value } return true; } bool make_black (ImageBuf &buf, ROI region) { if (buf.spec().format == TypeDesc::FLOAT) return make_black_impl<float> (buf, region); else if (buf.spec().format == TypeDesc::HALF) return make_black_impl<half> (buf, region); else if (buf.spec().format == TypeDesc::UINT8) return make_black_impl<unsigned char> (buf, region); else if (buf.spec().format == TypeDesc::UINT16) return make_black_impl<unsigned short> (buf, region); else { buf.error ("Unsupported pixel data format %s", buf.spec().format); retrn false; } } \end{code} In this example, we make an implementation that is templated on the buffer type, and then a wrapper that calls the appropriate template specialization for each of 4 common types (and logs an error in the buffer for any other types it encounters). In fact, {\cf imagebufalgo_util.h} provides a macro to do this (and several variants, which will be discussed in more detail in the next chapter). You could rewrite the example even more simply: \begin{code} #include <OpenImageIO/imagebufalgo_util.h> template<type BUFT> static bool make_black_impl (ImageBuf &buf, ROI region) { ... same as before ... } bool make_black (ImageBuf &buf, ROI region) { bool ok; OIIO_DISPATCH_COMMON_TYPES (ok, "make_black", make_black_impl, buf.spec().format, buf, region); return ok; } \end{code} \noindent This other type-dispatching helper macros will be discussed in more detail in Chapter~\ref{chap:imagebufalgo}. \index{ImageBuf|)} \index{Image Buffers|)} \chapwidthend
-- Conmutatividad_del_minimo.lean -- Si a, b ∈ ℝ, entonces min(a,b) = min(b,a) -- José A. Alonso Jiménez <https://jaalonso.github.io> -- Sevilla, 29-septiembre-2022 -- --------------------------------------------------------------------- -- --------------------------------------------------------------------- -- Demostrar que si a, b ∈ ℝ, entonces min(a,b) = min(b,a) -- --------------------------------------------------------------------- import data.real.basic variables a b : ℝ -- 1ª demostración -- =============== example : min a b = min b a := begin apply le_antisymm, { show min a b ≤ min b a, apply le_min, { apply min_le_right }, { apply min_le_left }}, { show min b a ≤ min a b, apply le_min, { apply min_le_right }, { apply min_le_left }}, end -- 2ª demostración -- =============== example : min a b = min b a := begin have h : ∀ x y : ℝ, min x y ≤ min y x, { intros x y, apply le_min, { apply min_le_right }, { apply min_le_left }}, apply le_antisymm, apply h, apply h, end -- 3ª demostración -- =============== example : min a b = min b a := begin have h : ∀ {x y : ℝ}, min x y ≤ min y x, { intros x y, exact le_min (min_le_right x y) (min_le_left x y) }, exact le_antisymm h h, end -- 4ª demostración -- =============== example : min a b = min b a := begin apply le_antisymm, repeat { apply le_min, apply min_le_right, apply min_le_left }, end
# -*- coding: utf-8 -*- """ Implements classical-quantum circuits. Objects are :class:`Ty` generated by two basic types :code:`bit` and :code:`qubit`. Arrows are diagrams generated by :class:`QuantumGate`, :class:`ClassicalGate`, :class:`Discard`, :class:`Measure` and :class:`Encode`. >>> from discopy.quantum.gates import Ket, CX, H, X, Rz, sqrt, Controlled >>> circuit = Ket(0, 0) >> CX >> Controlled(Rz(0.25)) >> Measure() @ Discard() >>> circuit.draw( ... figsize=(3, 6), ... path='docs/_static/imgs/quantum/circuit-example.png') .. image:: ../_static/imgs/quantum/circuit-example.png :align: center >>> from discopy.grammar.pregroup import Word >>> from discopy.rigid import Ty, Cup, Id >>> s, n = Ty('s'), Ty('n') >>> Alice = Word('Alice', n) >>> loves = Word('loves', n.r @ s @ n.l) >>> Bob = Word('Bob', n) >>> grammar = Cup(n, n.r) @ Id(s) @ Cup(n.l, n) >>> sentence = grammar << Alice @ loves @ Bob >>> ob = {s: 0, n: 1} >>> ar = {Alice: Ket(0), ... loves: CX << sqrt(2) @ H @ X << Ket(0, 0), ... Bob: Ket(1)} >>> F = Functor(ob, ar) >>> assert abs(F(sentence).eval().array) ** 2 >>> from discopy import drawing >>> drawing.equation( ... sentence, F(sentence), symbol='$\\\\mapsto$', ... figsize=(6, 3), nodesize=.5, ... path='docs/_static/imgs/quantum/functor-example.png') .. image:: ../_static/imgs/quantum/functor-example.png :align: center """ import random from itertools import takewhile, chain from collections.abc import Mapping from discopy import messages, monoidal, rigid, tensor from discopy.cat import AxiomError from discopy.rigid import Diagram from discopy.tensor import Dim, Tensor from math import pi from functools import reduce, partial class AntiConjugate: def conjugate(self): return type(self)(-self.phase) l = r = property(conjugate) class RealConjugate: def conjugate(self): return self l = r = property(conjugate) class Anti2QubitConjugate: def conjugate(self): algebraic_conj = type(self)(-self.phase) return Swap(qubit, qubit) >> algebraic_conj >> Swap(qubit, qubit) l = r = property(conjugate) def index2bitstring(i, length): """ Turns an index into a bitstring of a given length. """ if i >= 2 ** length: raise ValueError("Index should be less than 2 ** length.") if not i and not length: return () return tuple(map(int, '{{:0{}b}}'.format(length).format(i))) def bitstring2index(bitstring): """ Turns a bitstring into an index. """ return sum(value * 2 ** i for i, value in enumerate(bitstring[::-1])) class Ob(RealConjugate, rigid.Ob): """ Implements the generating objects of :class:`Circuit`, i.e. information units of some integer dimension greater than 1. Examples -------- >>> assert bit.objects == [Ob("bit", dim=2)] >>> assert qubit.objects == [Ob("qubit", dim=2)] """ def __init__(self, name, dim=2, z=0): super().__init__(name) if z != 0: raise AxiomError("circuit.Ob are self-dual.") if not isinstance(dim, int) or dim < 2: raise ValueError("Dimension should be an int greater than 1.") self._dim = dim @property def dim(self): """ Dimension of the unit, e.g. :code:`dim=2` for bits and qubits. """ return self._dim def __repr__(self): return self.name class Digit(Ob): """ Classical unit of information of some dimension :code:`dim`. Examples -------- >>> assert bit.objects == [Digit(2)] == [Ob("bit", dim=2)] """ def __init__(self, dim, z=0): name = "bit" if dim == 2 else "Digit({})".format(dim) super().__init__(name, dim) class Qudit(Ob): """ Quantum unit of information of some dimension :code:`dim`. Examples -------- >>> assert qubit.objects == [Qudit(2)] == [Ob("qubit", dim=2)] """ def __init__(self, dim, z=0): name = "qubit" if dim == 2 else "Qudit({})".format(dim) super().__init__(name, dim) class Ty(rigid.Ty): """ Implements the input and output types of :class:`Circuit`. Examples -------- >>> assert bit == Ty(Digit(2)) >>> assert qubit == Ty(Qudit(2)) >>> assert bit @ qubit != qubit @ bit You can construct :code:`n` qubits by taking powers of :code:`qubit`: >>> print(bit ** 2 @ qubit ** 3) bit @ bit @ qubit @ qubit @ qubit """ @staticmethod def upgrade(old): return Ty(*old.objects) def __repr__(self): return str(self) bit, qubit = Ty(Digit(2)), Ty(Qudit(2)) @monoidal.Diagram.subclass class Circuit(tensor.Diagram): """ Classical-quantum circuits. """ def __repr__(self): return super().__repr__().replace('Diagram', 'Circuit') def conjugate(self): return self.l @property def is_mixed(self): """ Whether the circuit is mixed, i.e. it contains both bits and qubits or it discards qubits. Mixed circuits can be evaluated only by a :class:`CQMapFunctor` not a :class:`discopy.tensor.Functor`. """ both_bits_and_qubits = self.dom.count(bit) and self.dom.count(qubit)\ or any(layer.cod.count(bit) and layer.cod.count(qubit) for layer in self.layers) return both_bits_and_qubits or any(box.is_mixed for box in self.boxes) def init_and_discard(self): """ Returns a circuit with empty domain and only bits as codomain. """ from discopy.quantum.gates import Bits, Ket circuit = self if circuit.dom: init = Id(0).tensor(*( Bits(0) if x.name == "bit" else Ket(0) for x in circuit.dom)) circuit = init >> circuit if circuit.cod != bit ** len(circuit.cod): discards = Id(0).tensor(*( Discard() if x.name == "qubit" else Id(bit) for x in circuit.cod)) circuit = circuit >> discards return circuit def eval(self, *others, backend=None, mixed=False, contractor=None, **params): """ Evaluate a circuit on a backend, or simulate it with numpy. Parameters ---------- others : :class:`discopy.quantum.circuit.Circuit` Other circuits to process in batch. backend : pytket.Backend, optional Backend on which to run the circuit, if none then we apply :class:`discopy.tensor.Functor` or :class:`CQMapFunctor` instead. mixed : bool, optional Whether to apply :class:`discopy.tensor.Functor` or :class:`CQMapFunctor`. contractor : callable, optional Use :class:`tensornetwork` contraction instead of discopy's basic eval feature. params : kwargs, optional Get passed to Circuit.get_counts. Returns ------- tensor : :class:`discopy.tensor.Tensor` If :code:`backend is not None` or :code:`mixed=False`. cqmap : :class:`CQMap` Otherwise. Examples -------- We can evaluate a pure circuit (i.e. with :code:`not circuit.is_mixed`) as a unitary :class:`discopy.tensor.Tensor` or as a :class:`CQMap`: >>> from discopy.quantum import * >>> H.eval().round(2) # doctest: +ELLIPSIS Tensor(dom=Dim(2), cod=Dim(2), array=[0.71+0.j, ..., -0.71+0.j]) >>> H.eval(mixed=True).round(1) # doctest: +ELLIPSIS CQMap(dom=Q(Dim(2)), cod=Q(Dim(2)), array=[0.5+0.j, ..., 0.5+0.j]) We can evaluate a mixed circuit as a :class:`CQMap`: >>> assert Measure().eval()\\ ... == CQMap(dom=Q(Dim(2)), cod=C(Dim(2)), ... array=[1, 0, 0, 0, 0, 0, 0, 1]) >>> circuit = Bits(1, 0) @ Ket(0) >> Discard(bit ** 2 @ qubit) >>> assert circuit.eval() == CQMap(dom=CQ(), cod=CQ(), array=[1]) We can execute any circuit on a `pytket.Backend`: >>> circuit = Ket(0, 0) >> sqrt(2) @ H @ X >> CX >> Measure() @ Bra(0) >>> from discopy.quantum.tk import mockBackend >>> backend = mockBackend({(0, 1): 512, (1, 0): 512}) >>> assert circuit.eval(backend, n_shots=2**10).round()\\ ... == Tensor(dom=Dim(1), cod=Dim(2), array=[0., 1.]) """ from discopy.quantum import cqmap if contractor is not None: array = contractor(*self.to_tn(mixed=mixed)).tensor if self.is_mixed or mixed: f = cqmap.Functor() return cqmap.CQMap(f(self.dom), f(self.cod), array) f = tensor.Functor(lambda x: x[0].dim, {}) return Tensor(f(self.dom), f(self.cod), array) from discopy import cqmap from discopy.quantum.gates import Bits, scalar if len(others) == 1 and not isinstance(others[0], Circuit): # This allows the syntax :code:`circuit.eval(backend)` return self.eval(backend=others[0], mixed=mixed, **params) if backend is None: if others: return [circuit.eval(mixed=mixed, **params) for circuit in (self, ) + others] functor = cqmap.Functor() if mixed or self.is_mixed\ else tensor.Functor(lambda x: x[0].dim, lambda f: f.array) box = functor(self) return type(box)(box.dom, box.cod, box.array + 0j) circuits = [circuit.to_tk() for circuit in (self, ) + others] results, counts = [], circuits[0].get_counts( *circuits[1:], backend=backend, **params) for i, circuit in enumerate(circuits): n_bits = len(circuit.post_processing.dom) result = Tensor.zeros(Dim(1), Dim(*(n_bits * (2, )))) for bitstring, count in counts[i].items(): result += (scalar(count) @ Bits(*bitstring)).eval() if circuit.post_processing: result = result >> circuit.post_processing.eval() results.append(result) return results if len(results) > 1 else results[0] def get_counts(self, *others, backend=None, **params): """ Get counts from a backend, or simulate them with numpy. Parameters ---------- others : :class:`discopy.quantum.circuit.Circuit` Other circuits to process in batch. backend : pytket.Backend, optional Backend on which to run the circuit, if none then `numpy`. n_shots : int, optional Number of shots, default is :code:`2**10`. measure_all : bool, optional Whether to measure all qubits, default is :code:`False`. normalize : bool, optional Whether to normalize the counts, default is :code:`True`. post_select : bool, optional Whether to perform post-selection, default is :code:`True`. scale : bool, optional Whether to scale the output, default is :code:`True`. seed : int, optional Seed to feed the backend, default is :code:`None`. compilation : callable, optional Compilation function to apply before getting counts. Returns ------- counts : dict From bitstrings to counts. Examples -------- >>> from discopy.quantum import * >>> circuit = H @ X >> CX >> Measure(2) >>> from discopy.quantum.tk import mockBackend >>> backend = mockBackend({(0, 1): 512, (1, 0): 512}) >>> circuit.get_counts(backend, n_shots=2**10) {(0, 1): 0.5, (1, 0): 0.5} """ if len(others) == 1 and not isinstance(others[0], Circuit): # This allows the syntax :code:`circuit.get_counts(backend)` return self.get_counts(backend=others[0], **params) if backend is None: if others: return [circuit.get_counts(**params) for circuit in (self, ) + others] utensor, counts = self.init_and_discard().eval(), dict() for i in range(2**len(utensor.cod)): bits = index2bitstring(i, len(utensor.cod)) if utensor.array[bits]: counts[bits] = utensor.array[bits].real return counts counts = self.to_tk().get_counts( *(other.to_tk() for other in others), backend=backend, **params) return counts if len(counts) > 1 else counts[0] def measure(self, mixed=False): """ Measures a circuit on the computational basis using :code:`numpy`. Parameters ---------- mixed : bool, optional Whether to apply :class:`tensor.Functor` or :class:`cqmap.Functor`. Returns ------- array : numpy.ndarray """ from discopy.quantum.gates import Bra, Ket if mixed or self.is_mixed: return self.init_and_discard().eval(mixed=True).array.real state = (Ket(*(len(self.dom) * [0])) >> self).eval() effects = [Bra(*index2bitstring(j, len(self.cod))).eval() for j in range(2 ** len(self.cod))] array = Tensor.np.zeros(len(self.cod) * (2, )) + 0j for effect in effects: array +=\ effect.array * Tensor.np.absolute((state >> effect).array) ** 2 return array def to_tn(self, mixed=False): """ Sends a diagram to a mixed :code:`tensornetwork`. Parameters ---------- mixed : bool, default: False Whether to perform mixed (also known as density matrix) evaluation of the circuit. Returns ------- nodes : :class:`tensornetwork.Node` Nodes of the network. output_edge_order : list of :class:`tensornetwork.Edge` Output edges of the network. """ if not mixed and not self.is_mixed: return super().to_tn() import tensornetwork as tn from discopy.quantum import ( qubit, bit, ClassicalGate, Copy, Match, Discard, SWAP) for box in self.boxes + [self]: if set(box.dom @ box.cod) - set(bit @ qubit): raise ValueError( "Only circuits with qubits and bits are supported.") # try to decompose some gates diag = Id(self.dom) last_i = 0 for i, box in enumerate(self.boxes): if hasattr(box, '_decompose'): decomp = box._decompose() if box != decomp: diag >>= self[last_i:i] left, _, right = self.layers[i] diag >>= Id(left) @ decomp @ Id(right) last_i = i + 1 diag >>= self[last_i:] self = diag c_nodes = [tn.CopyNode(2, 2, f'c_input_{i}', dtype=complex) for i in range(self.dom.count(bit))] q_nodes1 = [tn.CopyNode(2, 2, f'q1_input_{i}', dtype=complex) for i in range(self.dom.count(qubit))] q_nodes2 = [tn.CopyNode(2, 2, f'q2_input_{i}', dtype=complex) for i in range(self.dom.count(qubit))] inputs = [n[0] for n in c_nodes + q_nodes1 + q_nodes2] c_scan = [n[1] for n in c_nodes] q_scan1 = [n[1] for n in q_nodes1] q_scan2 = [n[1] for n in q_nodes2] nodes = c_nodes + q_nodes1 + q_nodes2 for box, layer, offset in zip(self.boxes, self.layers, self.offsets): if box == Circuit.swap(bit, bit): left, _, _ = layer c_offset = left.count(bit) c_scan[c_offset], c_scan[c_offset + 1] =\ c_scan[c_offset + 1], c_scan[c_offset] elif box.is_mixed or isinstance(box, ClassicalGate): c_dom = box.dom.count(bit) q_dom = box.dom.count(qubit) c_cod = box.cod.count(bit) left, _, _ = layer c_offset = left.count(bit) q_offset = left.count(qubit) if isinstance(box, Discard): assert box.n_qubits == 1 tn.connect(q_scan1[q_offset], q_scan2[q_offset]) del q_scan1[q_offset] del q_scan2[q_offset] continue if isinstance(box, (Copy, Match, Measure, Encode)): assert len(box.dom) == 1 or len(box.cod) == 1 node = tn.CopyNode(3, 2, 'cq_' + str(box), dtype=complex) else: # only unoptimised gate is MixedState() array = box.eval(mixed=True).array node = tn.Node(array + 0j, 'cq_' + str(box)) for i in range(c_dom): tn.connect(c_scan[c_offset + i], node[i]) for i in range(q_dom): tn.connect(q_scan1[q_offset + i], node[c_dom + i]) for i in range(q_dom): tn.connect(q_scan2[q_offset + i], node[c_dom + q_dom + i]) cq_dom = c_dom + 2 * q_dom c_edges = node[cq_dom:cq_dom + c_cod] q_edges1 = node[cq_dom + c_cod::2] q_edges2 = node[cq_dom + c_cod + 1::2] c_scan = (c_scan[:c_offset] + c_edges + c_scan[c_offset + c_dom:]) q_scan1 = (q_scan1[:q_offset] + q_edges1 + q_scan1[q_offset + q_dom:]) q_scan2 = (q_scan2[:q_offset] + q_edges2 + q_scan2[q_offset + q_dom:]) nodes.append(node) else: left, _, _ = layer q_offset = left[:offset + 1].count(qubit) if box == SWAP: q_scan1[q_offset], q_scan1[q_offset + 1] =\ q_scan1[q_offset + 1], q_scan1[q_offset] q_scan2[q_offset], q_scan2[q_offset + 1] =\ q_scan2[q_offset + 1], q_scan2[q_offset] continue utensor = box.array node1 = tn.Node(utensor.conjugate() + 0j, 'q1_' + str(box)) node2 = tn.Node(utensor + 0j, 'q2_' + str(box)) for i in range(len(box.dom)): tn.connect(q_scan1[q_offset + i], node1[i]) tn.connect(q_scan2[q_offset + i], node2[i]) edges1 = node1[len(box.dom):] edges2 = node2[len(box.dom):] q_scan1 = (q_scan1[:q_offset] + edges1 + q_scan1[q_offset + len(box.dom):]) q_scan2 = (q_scan2[:q_offset] + edges2 + q_scan2[q_offset + len(box.dom):]) nodes.extend([node1, node2]) outputs = c_scan + q_scan1 + q_scan2 return nodes, inputs + outputs def to_tk(self): """ Export to t|ket>. Returns ------- tk_circuit : pytket.Circuit A :class:`pytket.Circuit`. Note ---- * No measurements are performed. * SWAP gates are treated as logical swaps. * If the circuit contains scalars or a :class:`Bra`, then :code:`tk_circuit` will hold attributes :code:`post_selection` and :code:`scalar`. Examples -------- >>> from discopy.quantum import * >>> bell_test = H @ Id(1) >> CX >> Measure() @ Measure() >>> bell_test.to_tk() tk.Circuit(2, 2).H(0).CX(0, 1).Measure(0, 0).Measure(1, 1) >>> circuit0 = sqrt(2) @ H @ Rx(0.5) >> CX >> Measure() @ Discard() >>> circuit0.to_tk() tk.Circuit(2, 1).H(0).Rx(1.0, 1).CX(0, 1).Measure(0, 0).scale(2) >>> circuit1 = Ket(1, 0) >> CX >> Id(1) @ Ket(0) @ Id(1) >>> circuit1.to_tk() tk.Circuit(3).X(0).CX(0, 2) >>> circuit2 = X @ Id(2) >> Id(1) @ SWAP >> CX @ Id(1) >> Id(1) @ SWAP >>> circuit2.to_tk() tk.Circuit(3).X(0).CX(0, 2) >>> circuit3 = Ket(0, 0)\\ ... >> H @ Id(1)\\ ... >> Id(1) @ X\\ ... >> CX\\ ... >> Id(1) @ Bra(0) >>> print(repr(circuit3.to_tk())) tk.Circuit(2, 1).H(0).X(1).CX(0, 1).Measure(1, 0).post_select({0: 0}) """ # pylint: disable=import-outside-toplevel from discopy.quantum.tk import to_tk return to_tk(self) @staticmethod def from_tk(*tk_circuits): """ Translates a :class:`pytket.Circuit` into a :class:`Circuit`, or a list of :class:`pytket` circuits into a :class:`Sum`. Parameters ---------- tk_circuits : pytket.Circuit potentially with :code:`scalar` and :code:`post_selection` attributes. Returns ------- circuit : :class:`Circuit` Such that :code:`Circuit.from_tk(circuit.to_tk()) == circuit`. Note ---- * :meth:`Circuit.init_and_discard` is applied beforehand. * SWAP gates are introduced when applying gates to non-adjacent qubits. Examples -------- >>> from discopy.quantum import * >>> import pytket as tk >>> c = Rz(0.5) @ Id(1) >> Id(1) @ Rx(0.25) >> CX >>> assert Circuit.from_tk(c.to_tk()) == c.init_and_discard() >>> tk_GHZ = tk.Circuit(3).H(1).CX(1, 2).CX(1, 0) >>> pprint = lambda c: print(str(c).replace(' >>', '\\n >>')) >>> pprint(Circuit.from_tk(tk_GHZ)) Ket(0) >> Id(1) @ Ket(0) >> Id(2) @ Ket(0) >> Id(1) @ H @ Id(1) >> Id(1) @ CX >> SWAP @ Id(1) >> CX @ Id(1) >> SWAP @ Id(1) >> Discard(qubit) @ Id(2) >> Discard(qubit) @ Id(1) >> Discard(qubit) >>> circuit = Ket(1, 0) >> CX >> Id(1) @ Ket(0) @ Id(1) >>> print(Circuit.from_tk(circuit.to_tk())[3:-3]) X @ Id(2) >> Id(1) @ SWAP >> CX @ Id(1) >> Id(1) @ SWAP >>> bell_state = Circuit.caps(qubit, qubit) >>> bell_effect = bell_state[::-1] >>> circuit = bell_state @ Id(1) >> Id(1) @ bell_effect >> Bra(0) >>> pprint(Circuit.from_tk(circuit.to_tk())[3:]) H @ Id(2) >> CX @ Id(1) >> Id(1) @ CX >> Id(1) @ H @ Id(1) >> Bra(0) @ Id(2) >> Bra(0) @ Id(1) >> Bra(0) >> scalar(4) """ # pylint: disable=import-outside-toplevel from discopy.quantum.tk import from_tk if not tk_circuits: return Sum([], qubit ** 0, qubit ** 0) if len(tk_circuits) == 1: return from_tk(tk_circuits[0]) return sum(Circuit.from_tk(c) for c in tk_circuits) def grad(self, var, **params): """ Gradient with respect to :code:`var`. Parameters ---------- var : sympy.Symbol Differentiated variable. Returns ------- circuit : `discopy.quantum.circuit.Sum` Examples -------- >>> from sympy.abc import phi >>> from discopy.quantum import * >>> circuit = Rz(phi / 2) @ Rz(phi + 1) >> CX >>> assert circuit.grad(phi, mixed=False)\\ ... == (Rz(phi / 2) @ scalar(pi) @ Rz(phi + 1.5) >> CX)\\ ... + (scalar(pi/2) @ Rz(phi/2 + .5) @ Rz(phi + 1) >> CX) """ return super().grad(var, **params) def jacobian(self, variables, **params): """ Jacobian with respect to :code:`variables`. Parameters ---------- variables : List[sympy.Symbol] Differentiated variables. Returns ------- circuit : `discopy.quantum.circuit.Sum` with :code:`circuit.dom == self.dom` and :code:`circuit.cod == Digit(len(variables)) @ self.cod`. Examples -------- >>> from sympy.abc import x, y >>> from discopy.quantum.gates import Bits, Ket, Rx, Rz >>> circuit = Ket(0) >> Rx(x) >> Rz(y) >>> assert circuit.jacobian([x, y])\\ ... == (Bits(0) @ circuit.grad(x)) + (Bits(1) @ circuit.grad(y)) >>> assert not circuit.jacobian([]) >>> assert circuit.jacobian([x]) == circuit.grad(x) """ if not variables: return Sum([], self.dom, self.cod) if len(variables) == 1: return self.grad(variables[0], **params) from discopy.quantum.gates import Digits return sum(Digits(i, dim=len(variables)) @ self.grad(x, **params) for i, x in enumerate(variables)) def draw(self, **params): """ We draw the labels of a circuit whenever it's mixed. """ draw_type_labels = params.get('draw_type_labels') or self.is_mixed params = dict({'draw_type_labels': draw_type_labels}, **params) return super().draw(**params) @staticmethod def swap(left, right): return monoidal.Diagram.swap( left, right, ar_factory=Circuit, swap_factory=Swap) @staticmethod def permutation(perm, dom=None): if dom is None: dom = qubit ** len(perm) return monoidal.Diagram.permutation(perm, dom, ar_factory=Circuit) @staticmethod def cups(left, right): from discopy.quantum.gates import CX, H, sqrt, Bra, Match def cup_factory(left, right): if left == right == qubit: return CX >> H @ sqrt(2) @ Id(1) >> Bra(0, 0) if left == right == bit: return Match() >> Discard(bit) raise ValueError return rigid.cups( left, right, ar_factory=Circuit, cup_factory=cup_factory) @staticmethod def caps(left, right): return Circuit.cups(left, right).dagger() @staticmethod def spiders(n_legs_in, n_legs_out, dim): from discopy.quantum.gates import CX, H, Bra, sqrt t = rigid.Ty('PRO') if len(dim) == 0: return Id() def decomp_ar(spider): return spider.decompose() def spider_ar(spider): dom, cod = len(spider.dom), len(spider.cod) if dom < cod: return spider_ar(spider.dagger()).dagger() circ = Id(qubit) if dom == 2: circ = CX >> Id(qubit) @ Bra(0) if cod == 0: circ >>= H >> Bra(0) @ sqrt(2) return circ diag = Diagram.spiders(n_legs_in, n_legs_out, t ** len(dim)) decomp = monoidal.Functor(ob={t: t}, ar=decomp_ar) to_circ = monoidal.Functor(ob={t: qubit}, ar=spider_ar, ar_factory=Circuit, ob_factory=Ty) circ = to_circ(decomp(diag)) return circ def _apply_gate(self, gate, position): """ Apply gate at position """ if position < 0 or position >= len(self.cod): raise ValueError(f'Index {position} out of range.') left = Id(position) right = Id(len(self.cod) - len(left.cod) - len(gate.cod)) return self >> left @ gate @ right def _apply_controlled(self, base_gate, *xs): from discopy.quantum import Controlled if len(set(xs)) != len(xs): raise ValueError(f'Indices {xs} not unique.') if min(xs) < 0 or max(xs) >= len(self.cod): raise ValueError(f'Indices {xs} out of range.') before = sorted(filter(lambda x: x < xs[-1], xs[:-1])) after = sorted(filter(lambda x: x > xs[-1], xs[:-1])) gate = base_gate last_x = xs[-1] for x in before[::-1]: gate = Controlled(gate, distance=last_x - x) last_x = x last_x = xs[-1] for x in after[::-1]: gate = Controlled(gate, distance=last_x - x) last_x = x return self._apply_gate(gate, min(xs)) def H(self, x): """ Apply Hadamard gate to circuit. """ from discopy.quantum import H return self._apply_gate(H, x) def S(self, x): """ Apply S gate to circuit. """ from discopy.quantum import S return self._apply_gate(S, x) def X(self, x): """ Apply Pauli X gate to circuit. """ from discopy.quantum import X return self._apply_gate(X, x) def Y(self, x): """ Apply Pauli Y gate to circuit. """ from discopy.quantum import Y return self._apply_gate(Y, x) def Z(self, x): """ Apply Pauli Z gate to circuit. """ from discopy.quantum import Z return self._apply_gate(Z, x) def Rx(self, phase, x): """ Apply Rx gate to circuit. """ from discopy.quantum import Rx return self._apply_gate(Rx(phase), x) def Ry(self, phase, x): """ Apply Rx gate to circuit. """ from discopy.quantum import Ry return self._apply_gate(Ry(phase), x) def Rz(self, phase, x): """ Apply Rz gate to circuit. """ from discopy.quantum import Rz return self._apply_gate(Rz(phase), x) def CX(self, x, y): """ Apply Controlled X / CNOT gate to circuit. """ from discopy.quantum import X return self._apply_controlled(X, x, y) def CY(self, x, y): """ Apply Controlled Y gate to circuit. """ from discopy.quantum import Y return self._apply_controlled(Y, x, y) def CZ(self, x, y): """ Apply Controlled Z gate to circuit. """ from discopy.quantum import Z return self._apply_controlled(Z, x, y) def CCX(self, x, y, z): """ Apply Controlled CX / Toffoli gate to circuit. """ from discopy.quantum import X return self._apply_controlled(X, x, y, z) def CCZ(self, x, y, z): """ Apply Controlled CZ gate to circuit. """ from discopy.quantum import Z return self._apply_controlled(Z, x, y, z) def CRx(self, phase, x, y): """ Apply Controlled Rx gate to circuit. """ from discopy.quantum import Rx return self._apply_controlled(Rx(phase), x, y) def CRz(self, phase, x, y): """ Apply Controlled Rz gate to circuit. """ from discopy.quantum import Rz return self._apply_controlled(Rz(phase), x, y) class Id(rigid.Id, Circuit): """ Identity circuit. """ def __init__(self, dom=0): if isinstance(dom, int): dom = qubit ** dom self._qubit_only = all(x.name == "qubit" for x in dom) rigid.Id.__init__(self, dom) Circuit.__init__(self, dom, dom, [], []) def __repr__(self): return "Id({})".format(len(self.dom) if self._qubit_only else self.dom) def __str__(self): return repr(self) Circuit.id = Id class Box(rigid.Box, Circuit): """ Boxes in a circuit diagram. Parameters ---------- name : any dom : discopy.quantum.circuit.Ty cod : discopy.quantum.circuit.Ty is_mixed : bool, optional Whether the box is mixed, default is :code:`True`. _dagger : bool, optional If set to :code:`None` then the box is self-adjoint. """ def __init__(self, name, dom, cod, is_mixed=True, data=None, _dagger=False, _conjugate=False): if dom and not isinstance(dom, Ty): raise TypeError(messages.type_err(Ty, dom)) if cod and not isinstance(cod, Ty): raise TypeError(messages.type_err(Ty, cod)) z = 1 if _conjugate else 0 self._conjugate = _conjugate rigid.Box.__init__( self, name, dom, cod, data=data, _dagger=_dagger, _z=z) Circuit.__init__(self, dom, cod, [self], [0]) if not is_mixed: if all(isinstance(x, Digit) for x in dom @ cod): self.classical = True elif all(isinstance(x, Qudit) for x in dom @ cod): self.classical = False else: raise ValueError( "dom and cod should be Digits only or Qudits only.") self._mixed = is_mixed def grad(self, var, **params): if var not in self.free_symbols: return Sum([], self.dom, self.cod) raise NotImplementedError @property def is_mixed(self): return self._mixed def __repr__(self): return self.name class Sum(tensor.Sum, Box): """ Sums of circuits. """ @staticmethod def upgrade(old): return Sum(old.terms, old.dom, old.cod) @property def is_mixed(self): return any(circuit.is_mixed for circuit in self.terms) def get_counts(self, backend=None, **params): if not self.terms: return {} if len(self.terms) == 1: return self.terms[0].get_counts(backend=backend, **params) counts = Circuit.get_counts(*self.terms, backend=backend, **params) result = {} for circuit_counts in counts: for bitstring, count in circuit_counts.items(): result[bitstring] = result.get(bitstring, 0) + count return result def eval(self, backend=None, mixed=False, **params): mixed = mixed or any(t.is_mixed for t in self.terms) if not self.terms: return 0 if len(self.terms) == 1: return self.terms[0].eval(backend=backend, mixed=mixed, **params) return sum( Circuit.eval(*self.terms, backend=backend, mixed=mixed, **params)) def grad(self, var, **params): return sum(circuit.grad(var, **params) for circuit in self.terms) def to_tk(self): return [circuit.to_tk() for circuit in self.terms] Circuit.sum = Sum class Swap(rigid.Swap, Box): """ Implements swaps of circuit wires. """ def __init__(self, left, right): rigid.Swap.__init__(self, left, right) Box.__init__( self, self.name, self.dom, self.cod, is_mixed=left != right) def dagger(self): return Swap(self.right, self.left) def conjugate(self): return Swap(self.right, self.left) l = r = property(conjugate) def __repr__(self): return "SWAP"\ if self.left == self.right == qubit else super().__repr__() def __str__(self): return repr(self) class Discard(RealConjugate, Box): """ Discard n qubits. If :code:`dom == bit` then marginal distribution. """ def __init__(self, dom=1): if isinstance(dom, int): dom = qubit ** dom super().__init__( "Discard({})".format(dom), dom, qubit ** 0, is_mixed=True) self.draw_as_discards = True self.n_qubits = len(dom) def dagger(self): return MixedState(self.dom) def _decompose(self): return Id().tensor(*[Discard()] * self.n_qubits) class MixedState(RealConjugate, Box): """ Maximally-mixed state on n qubits. If :code:`cod == bit` then uniform distribution. """ def __init__(self, cod=1): if isinstance(cod, int): cod = qubit ** cod super().__init__( "MixedState({})".format(cod), qubit ** 0, cod, is_mixed=True) self.drawing_name = "MixedState" if cod == bit: self.drawing_name = "" self.draw_as_spider, self.color = True, "black" def dagger(self): return Discard(self.cod) def _decompose(self): return Id().tensor(*[MixedState()] * len(self.cod)) class Measure(RealConjugate, Box): """ Measure n qubits into n bits. Parameters ---------- n_qubits : int Number of qubits to measure. destructive : bool, optional Whether to do a non-destructive measurement instead. override_bits : bool, optional Whether to override input bits, this is the standard behaviour of tket. """ def __init__(self, n_qubits=1, destructive=True, override_bits=False): dom, cod = qubit ** n_qubits, bit ** n_qubits name = "Measure({})".format("" if n_qubits == 1 else n_qubits) if not destructive: cod = qubit ** n_qubits @ cod name = name\ .replace("()", "(1)").replace(')', ", destructive=False)") if override_bits: dom = dom @ bit ** n_qubits name = name\ .replace("()", "(1)").replace(')', ", override_bits=True)") super().__init__(name, dom, cod, is_mixed=True) self.destructive, self.override_bits = destructive, override_bits self.n_qubits = n_qubits self.draw_as_measures = True def dagger(self): return Encode(self.n_qubits, constructive=self.destructive, reset_bits=self.override_bits) def _decompose(self): return Id().tensor(*[ Measure(destructive=self.destructive, override_bits=self.override_bits)] * self.n_qubits) class Encode(RealConjugate, Box): """ Controlled preparation, i.e. encode n bits into n qubits. Parameters ---------- n_bits : int Number of bits to encode. constructive : bool, optional Whether to do a classically-controlled correction instead. reset_bits : bool, optional Whether to reset the bits to the uniform distribution. """ def __init__(self, n_bits=1, constructive=True, reset_bits=False): dom, cod = bit ** n_bits, qubit ** n_bits name = Measure(n_bits, constructive, reset_bits).name\ .replace("Measure", "Encode")\ .replace("destructive", "constructive")\ .replace("override_bits", "reset_bits") super().__init__(name, dom, cod, is_mixed=True) self.constructive, self.reset_bits = constructive, reset_bits self.n_bits = n_bits def dagger(self): return Measure(self.n_bits, destructive=self.constructive, override_bits=self.reset_bits) def _decompose(self): return Id().tensor(*[ Encode(constructive=self.constructive, reset_bits=self.reset_bits)] * self.n_bits) class Functor(rigid.Functor): """ Functors into :class:`Circuit`. """ def __init__(self, ob, ar): if isinstance(ob, Mapping): ob = {x: qubit ** y if isinstance(y, int) else y for x, y in ob.items()} super().__init__(ob, ar, ob_factory=Ty, ar_factory=Circuit) def __repr__(self): return super().__repr__().replace("Functor", "circuit.Functor") class IQPansatz(Circuit): """ Builds an IQP ansatz on n qubits, if n = 1 returns an Euler decomposition >>> pprint = lambda c: print(str(c).replace(' >>', '\\n >>')) >>> pprint(IQPansatz(3, [[0.1, 0.2], [0.3, 0.4]])) H @ Id(2) >> Id(1) @ H @ Id(1) >> Id(2) @ H >> CRz(0.1) @ Id(1) >> Id(1) @ CRz(0.2) >> H @ Id(2) >> Id(1) @ H @ Id(1) >> Id(2) @ H >> CRz(0.3) @ Id(1) >> Id(1) @ CRz(0.4) >>> print(IQPansatz(1, [0.3, 0.8, 0.4])) Rx(0.3) >> Rz(0.8) >> Rx(0.4) """ def __init__(self, n_qubits, params): from discopy.quantum.gates import H, Rx, Rz, CRz def layer(thetas): hadamards = Id(0).tensor(*(n_qubits * [H])) rotations = Id(n_qubits).then(*( Id(i) @ CRz(thetas[i]) @ Id(n_qubits - 2 - i) for i in range(n_qubits - 1))) return hadamards >> rotations if n_qubits == 1: circuit = Rx(params[0]) >> Rz(params[1]) >> Rx(params[2]) elif len(Tensor.np.shape(params)) != 2\ or Tensor.np.shape(params)[1] != n_qubits - 1: raise ValueError( "Expected params of shape (depth, {})".format(n_qubits - 1)) else: depth = Tensor.np.shape(params)[0] circuit = Id(n_qubits).then(*( layer(params[i]) for i in range(depth))) super().__init__( circuit.dom, circuit.cod, circuit.boxes, circuit.offsets) def real_amp_ansatz(params: Tensor.np.ndarray, *, entanglement='full'): """ The real-amplitudes 2-local circuit. The shape of the params determines the number of layers and the number of qubits respectively (layers, qubit). This heuristic generates orthogonal operators so the imaginary part of the correponding matrix is always the zero matrix. :param params: A 2D numpy array of parameters. :param entanglement: Configuration for the entaglement, currently either 'full' (default), 'linear' or 'circular'. """ from discopy.quantum.gates import CX, Ry, rewire ext_cx = partial(rewire, CX) assert entanglement in ('linear', 'circular', 'full') params = Tensor.np.asarray(params) assert params.ndim == 2 dom = qubit**params.shape[1] def layer(v, is_last=False): n = len(dom) rys = Id(0).tensor(*(Ry(v[k]) for k in range(n))) if is_last: return rys if entanglement == 'full': cxs = [[ext_cx(k1, k2, dom=dom) for k2 in range(k1 + 1, n)] for k1 in range(n - 1)] cxs = reduce(lambda a, b: a >> b, chain(*cxs)) else: cxs = [ext_cx(k, k + 1, dom=dom) for k in range(n - 1)] cxs = reduce(lambda a, b: a >> b, cxs) if entanglement == 'circular': cxs = ext_cx(n - 1, 0, dom=dom) >> cxs return rys >> cxs circuit = [layer(v, is_last=idx == (len(params) - 1)) for idx, v in enumerate(params)] circuit = reduce(lambda a, b: a >> b, circuit) return circuit def random_tiling(n_qubits, depth=3, gateset=None, seed=None): """ Returns a random Euler decomposition if n_qubits == 1, otherwise returns a random tiling with the given depth and gateset. >>> from discopy.quantum.gates import CX, H, T, Rx, Rz >>> c = random_tiling(1, seed=420) >>> print(c) Rx(0.0263) >> Rz(0.781) >> Rx(0.273) >>> print(random_tiling(2, 2, gateset=[CX, H, T], seed=420)) CX >> T @ Id(1) >> Id(1) @ T >>> print(random_tiling(3, 2, gateset=[CX, H, T], seed=420)) CX @ Id(1) >> Id(2) @ T >> H @ Id(2) >> Id(1) @ H @ Id(1) >> Id(2) @ H >>> print(random_tiling(2, 1, gateset=[Rz, Rx], seed=420)) Rz(0.673) @ Id(1) >> Id(1) @ Rx(0.273) """ from discopy.quantum.gates import H, CX, Rx, Rz, Parametrized gateset = gateset or [H, Rx, CX] if seed is not None: random.seed(seed) if n_qubits == 1: phases = [random.random() for _ in range(3)] return Rx(phases[0]) >> Rz(phases[1]) >> Rx(phases[2]) result = Id(n_qubits) for _ in range(depth): line, n_affected = Id(0), 0 while n_affected < n_qubits: gate = random.choice( gateset if n_qubits - n_affected > 1 else [ g for g in gateset if g is Rx or g is Rz or len(g.dom) == 1]) if isinstance(gate, type) and issubclass(gate, Parametrized): gate = gate(random.random()) line = line @ gate n_affected += len(gate.dom) result = result >> line return result
theory cancel_at_props imports Main "HOL-Library.FuncSet" "HOL-Algebra.Group" "HOL-Proofs-Lambda.Commutation" begin datatype ('a,'b) monoidgentype = C 'a 'b (infix "!" 63) datatype ('a,'b) groupgentype = P "('a,'b) monoidgentype" | N "('a,'b) monoidgentype" type_synonym ('a,'b) word = "(('a,'b) groupgentype) list" primrec inverse::"('a,'b) groupgentype \<Rightarrow> ('a,'b) groupgentype" where "inverse (P x) = (N x)" |"inverse (N x) = (P x)" primrec wordinverse::"('a,'b) word \<Rightarrow> ('a, 'b) word" where "wordinverse [] = []" |"wordinverse (x#xs) = (wordinverse xs)@[inverse x]" inductive_set spanset::"('a,'b) word set\<Rightarrow> ('a,'b) word set" ("\<langle>_\<rangle>") for S::"('a,'b) word set" where "x \<in> S \<Longrightarrow> x \<in> \<langle>S\<rangle>" |"x \<in> inver ` S \<Longrightarrow> x \<in> \<langle>S\<rangle>" |"x \<in> S \<Longrightarrow> y \<in> \<langle>S\<rangle>\<Longrightarrow> x@y \<in> \<langle>S\<rangle>" |"x \<in> inver ` S \<Longrightarrow> ys \<in> \<langle>S\<rangle> \<Longrightarrow> x@ys \<in> \<langle>S\<rangle>" definition setlistcross::"'a set \<Rightarrow> 'a list \<Rightarrow> 'a list set" where "setlistcross S xs = {[s]@xs | s. s \<in> S}" value "setlistcross {(1::nat), 2, 3} [(4::nat), 5, 6]" primrec lengthword::"nat \<Rightarrow> 'a set \<Rightarrow> 'a list set" where "lengthword 0 S = {[s] | s. s \<in> S}" |"lengthword (Suc n) S = \<Union> {setlistcross S xs | xs. xs \<in> (lengthword n S)}" abbreviation "ngroupword \<equiv> \<lambda> n (S::('a,'b) word set). lengthword n (S \<union> (wordinverse ` S))" datatype char = G | H value "ngroupword 1 {[P (C G (1::nat))], [N (C G (2::nat))], [P (C H (3::nat))]}" (*reduction removes cancellations next to each other*) fun reduction:: "('a,'b) word \<Rightarrow> ('a,'b) word" where "reduction [] = []" |"reduction [x] = [x]" |"reduction (g1#g2#wrd) = (if (g1 = inverse g2) then reduction wrd else (g1#(reduction (g2#wrd))))" value "reduction [P (C G (3::nat)), N (C G (3::nat)), (N (C G (2::nat)))]" fun reduced::"('a,'b) word \<Rightarrow> bool" where "reduced [] = True" |"reduced [g] = True" |"reduced (g#h#wrd) = (if (g \<noteq> inverse h) then reduced (h#wrd) else False)" primrec iter::"nat \<Rightarrow>('a \<Rightarrow> 'a) \<Rightarrow> ('a \<Rightarrow> 'a)" where "iter 0 f = (\<lambda> x. x)" |"iter (Suc n) f = (\<lambda> x. f ((iter n f) x))" (*Prove the following*) lemma fixedpt_iteration: assumes "f x = x" shows "iter (n+1) f x = x" using assms proof(induction n) case 0 then show ?case by simp next case (Suc n) then show ?case by simp qed lemma iterative_fixed_pt: assumes "iter (n+1) f x = iter n f x" shows "iter (k+(n+1)) f x = iter (k+n) f x" using assms proof(induction k) case 0 then show ?case by force next case (Suc m) have "iter (m + (n + 1)) f x = iter (Suc m + n) f x" by simp then show ?case using Suc.IH Suc.prems by fastforce qed (*prove converse of the following too*) lemma assumes "reduced wrd" shows "reduction wrd = wrd" using assms proof(induction wrd rule: reduction.induct) case 1 then show ?case by simp next case (2 x) then show ?case by simp next case (3 g1 g2 wrd) then show ?case proof(cases "g1 = inverse g2") case True then show ?thesis using 3 by force next case False have "reduced (g2#wrd)" using False 3 by force then show ?thesis using False 3 by force qed qed lemma length_reduction: "length (reduction wrd) \<le> length wrd" proof(induction wrd rule: reduction.induct) case 1 then show ?case by simp next case (2 x) then show ?case by simp next case (3 g1 g2 wrd) then show ?case proof(cases "g1 = inverse g2") case True then show ?thesis using 3 by force next case False then show ?thesis using 3 by auto qed qed lemma decreasing_length: assumes "reduction wrd \<noteq> wrd" shows "length (reduction wrd) < length wrd" using assms proof(induction wrd rule: reduction.induct) case 1 then show ?case by simp next case (2 x) then show ?case by simp next case (3 g1 g2 wrd) then show ?case proof(cases "g1 = inverse g2") case True then have red_inv:"reduction (g1#g2#wrd) = reduction wrd" by auto then show ?thesis proof(cases "reduction wrd = wrd") case True then have "reduction (g1#g2#wrd) = wrd" using red_inv by auto then have "length (reduction (g1#g2#wrd)) = length wrd" by auto then show ?thesis by simp next case False then have "length (reduction wrd) < length wrd" using 3 True by argo then show ?thesis using red_inv by force qed next case False have prem:"reduction (g1#g2#wrd) \<noteq> (g1#g2#wrd)" using 3 by argo then have "reduction (g1#g2#wrd) = g1#reduction (g2#wrd)" using False by auto then have "reduction (g2#wrd) \<noteq> g2#wrd" using prem by fastforce then have "length (g2#wrd) > length (reduction (g2#wrd))" using 3 False by blast then have "length (g1#g2#wrd) > length (reduction (g1#g2#wrd))" using False by force then show ?thesis by fast qed qed lemma if_length_reduction_eq: assumes "length (reduction (wrd)) = length wrd" shows "reduction wrd = wrd" using assms proof(induction wrd rule: reduction.induct) case 1 then show ?case by simp next case (2 x) then show ?case by simp next case (3 g1 g2 wrd) then show ?case proof(cases "g1 = inverse g2") case True then have "reduction (g1#g2#wrd) = reduction (wrd)" by simp then have "length (reduction (g1#g2#wrd)) = length (reduction (wrd))" by auto moreover have "length (wrd) > length (reduction wrd)" using 3 by (metis \<open>reduction (g1 # g2 # wrd) = reduction wrd\<close> decreasing_length impossible_Cons le_cases) then show ?thesis using 3 by auto next case False then show ?thesis using "3.prems" decreasing_length nat_neq_iff by blast qed qed lemma reduction_fixpt: assumes "reduction wrd = wrd" shows "reduced wrd" using assms proof(induction wrd rule:reduction.induct) case 1 then show ?case by simp next case (2 x) then show ?case by simp next case (3 g1 g2 wrd) then show ?case by (metis decreasing_length impossible_Cons length_Cons less_Suc_eq less_or_eq_imp_le list.inject reduced.simps(3) reduction.simps(3)) qed (*Show that length decreases if and only the word after reduction is not the same as the original word*) (*show that if after reduction of a word it does not change, that subsequent reductions will be ineffective*) (*use the word length argument decrement argument to show that the reduced word is finally reduced*) value "reduced [P (C G (1::nat)), N (C G (2::nat)), P (C G (1::nat))]" inductive reln::"('a,'b) word \<Rightarrow> ('a,'b) word \<Rightarrow> bool" (infixr "~" 65) where refl[intro!]: "a ~ a" | sym: "a ~ b \<Longrightarrow> b ~ a" | trans: "a ~ b \<Longrightarrow> b ~ c \<Longrightarrow> a ~ c" | base: "[g, inverse g] ~ []" | mult: "xs ~ xs' \<Longrightarrow> ys ~ ys' \<Longrightarrow> (xs@ys) ~ (xs'@ys')" lemma assumes "h = inverse g" shows "[g, h] ~ []" using assms reln.base inverse.simps by simp lemma relation: "(xs@ys) ~ xs@[g,inverse g]@ys" using reln.base reln.refl reln.mult proof- have "(xs@[g, inverse g]) ~ xs" using reln.base reln.mult reln.refl by fastforce then show ?thesis using mult[of "xs@[g, inverse g]" "xs" "ys" "ys"] reln.refl reln.sym by auto qed lemma inverse_of_inverse: assumes "g = inverse h" shows "h = inverse g" using assms inverse.simps by (metis groupgentype.exhaust) lemma rel_to_reduction:"xs ~ reduction xs" proof(induction xs rule:reduction.induct ) case 1 then show ?case using reln.refl by auto next case (2 x) then show ?case using reln.refl by auto next case (3 g1 g2 wrd) then show ?case proof(cases "g1 = inverse g2") case True have "[g1, g2] ~ []" using reln.base[of "g1"] inverse_of_inverse[of "g1" "g2"] True by blast then have 1:"([g1,g2]@wrd) ~ wrd" using reln.mult refl by fastforce with 3(1) have 2:"reduction ([g1,g2]@wrd) ~ wrd" using reln.trans True using append_Cons append_Nil reduction.simps(3) reln.sym by auto then show ?thesis using 1 reln.sym reln.trans by (metis append_Cons append_Nil) next case False then have "([g1]@(g2#wrd)) ~ ([g1]@(reduction (g2#wrd)))" using 3(2) reln.mult reln.refl by blast then have "([g1]@(g2#wrd)) ~ (reduction (g1#g2#wrd))" using False by simp then show ?thesis by simp qed qed definition wordeq::"('a,'b) word \<Rightarrow> ('a,'b) word set" ("[[_]]") where "wordeq wrd = {wrds. wrd ~ wrds}" (*This is approach for normal form using newsmans lemma*) definition cancel_at :: "nat \<Rightarrow> ('a,'b) word \<Rightarrow> ('a,'b) word" where "cancel_at i l = take i l @ drop (2+i) l" lemma cancel_at_leftappend: assumes "i\<ge>0" "(1+i) < length a" "cancel_at i a = b" shows "cancel_at (length c + i) (c@a) = (c@b)" proof- have "c@(take i a) = take (length c + i) (c@a)" using assms(1) assms(2) by auto moreover have "drop (i+2) a = drop (length c + (i+2)) (c@a)"using assms(1) assms(2) by simp ultimately show ?thesis unfolding cancel_at_def by (metis add.assoc add.commute append.assoc assms(3) cancel_at_def) qed lemma cancel_at_rightappend: assumes "i\<ge>0" "(1+i) < length a" "cancel_at i a = b" shows "cancel_at i (a@c) = (b@c)" proof- have "take i (a@c) = take i a" using assms(1) assms (2) by simp moreover have "(drop (2+i) a)@c = drop (2+i) (a@c)" using assms(1) assms(2) by simp ultimately show ?thesis unfolding cancel_at_def by (metis append.assoc assms(3) cancel_at_def) qed definition cancels_to_1_at :: "nat \<Rightarrow> ('a,'b) word \<Rightarrow> ('a,'b) word \<Rightarrow> bool" where "cancels_to_1_at i l1 l2 = (0\<le>i \<and> (1+i) < length l1 \<and> (inverse (l1 ! i) = (l1 ! (1+i))) \<and> (l2 = cancel_at i l1))" lemma cancels_to_1_at_leftappend: assumes "i\<ge>0" "(1+i) < length a" "cancels_to_1_at i a b" shows "cancels_to_1_at (length c + i) (c@a) (c@b)" unfolding cancels_to_1_at_def proof- have 1:"0 \<le> (length c + i)" using assms(1) by simp moreover have 2: "1 + (length c + i) < length (c @ a)" using assms(2) by auto have "(inverse (a ! i)) = (a ! (i+1))" using assms(3) by (metis add.commute cancels_to_1_at_def) moreover then have 3: "inverse ((c @ a) ! (length c + i)) = (c @ a) ! (1 + (length c + i))" by (metis add.commute add.left_commute nth_append_length_plus) have "(b = cancel_at i a)" using assms(3)using cancels_to_1_at_def by auto moreover then have 4: "c @ b = cancel_at (length c + i) (c @ a)" using cancel_at_leftappend assms(1) assms(2) by metis ultimately show "0 \<le> length c + i \<and> 1 + (length c + i) < length (c @ a) \<and> inverse ((c @ a) ! (length c + i)) = (c @ a) ! (1 + (length c + i)) \<and> c @ b = cancel_at (length c + i) (c @ a)" using "2" "3" by blast qed lemma cancels_to_1_at_rightappend: assumes "i\<ge>0" "(1+i) < length a" "cancels_to_1_at i a b" shows "cancels_to_1_at i (a@c) (b@c)" unfolding cancels_to_1_at_def proof- have 1:"0 \<le> i" using assms(1) by simp moreover have 2: "1 + i < length (a@c)" using assms(2) by auto have "(inverse (a ! i)) = (a ! (i+1))" using assms(3) by (metis add.commute cancels_to_1_at_def) moreover then have 3: "inverse ((a @ c) ! i) = (a @ c) ! (1 + i)" by (metis Suc_eq_plus1 Suc_lessD add.commute assms(2) nth_append) have "(b = cancel_at i a)" using assms(3)using cancels_to_1_at_def by auto moreover then have 4: "b@c = cancel_at i (a@c)" using cancel_at_rightappend assms(1) assms(2) by metis ultimately show "0 \<le> i \<and> 1 + i < length (a @ c) \<and> inverse ((a @ c) ! i) = (a @ c) ! (1 + i) \<and> b @ c = cancel_at i (a @ c)" using "2" "3" by blast qed definition cancels_to_1 :: "('a,'b) word \<Rightarrow> ('a,'b) word \<Rightarrow> bool" where "cancels_to_1 l1 l2 = (\<exists>i. cancels_to_1_at i l1 l2)" lemma cancels_to_1_leftappend: assumes "cancels_to_1 a b" shows "cancels_to_1 (c@a) (c@b)" using assms unfolding cancels_to_1_def proof- obtain i where "cancels_to_1_at i a b" using assms cancels_to_1_def by auto then have "i\<ge>0 \<and> (1+i) < length a" using cancels_to_1_at_def by auto then have "cancels_to_1_at (length c + i) (c@a) (c@b)" using \<open>cancels_to_1_at i a b\<close> cancels_to_1_at_leftappend by auto then show "\<exists>i. cancels_to_1_at i (c @ a) (c @ b)" by auto qed lemma cancels_to_1_rightappend: assumes "cancels_to_1 a b" shows "cancels_to_1 (a@c) (b@c)" using assms unfolding cancels_to_1_def proof- obtain i where "cancels_to_1_at i a b" using assms cancels_to_1_def by auto then have "i\<ge>0 \<and> (1+i) < length a" using cancels_to_1_at_def by auto then have "cancels_to_1_at i (a@c) (b@c)" by (simp add: cancels_to_1_at_rightappend \<open>cancels_to_1_at i a b\<close>) then show "\<exists>i. cancels_to_1_at i (a @ c) (b @ c)" by auto qed definition cancels_to :: "('a,'b) word \<Rightarrow> ('a,'b) word \<Rightarrow> bool" where "cancels_to = (cancels_to_1)^**" lemma cancels_to_leftappend: "cancels_to a b \<longrightarrow> cancels_to (z@a) (z@b)" unfolding cancels_to_def apply(rule impI) proof(induction rule:rtranclp.induct) case (rtrancl_refl a) then show ?case by simp next case (rtrancl_into_rtrancl a b c) then have 1:"cancels_to_1 (z@b) (z@c)"by (simp add: cancels_to_1_leftappend) have "cancels_to_1\<^sup>*\<^sup>* (z @ a) (z @ b)" by (simp add: rtrancl_into_rtrancl.IH) then show "cancels_to_1\<^sup>*\<^sup>* (z @ a) (z @ c)" using 1 by auto qed lemma cancels_to_rightappend: "cancels_to a b \<longrightarrow> cancels_to (a@z) (b@z)" unfolding cancels_to_def apply(rule impI) proof(induction rule:rtranclp.induct) case (rtrancl_refl a) then show ?case by simp next case (rtrancl_into_rtrancl a b c) then have 1:"cancels_to_1 (b@z) (c@z)"by (simp add: cancels_to_1_rightappend) have "cancels_to_1\<^sup>*\<^sup>* (a@z) (b@z)" by (simp add: rtrancl_into_rtrancl.IH) then show "cancels_to_1\<^sup>*\<^sup>* (a@z) (c@z)" using 1 by auto qed lemma "cancels_to x y \<Longrightarrow> x ~ y" unfolding cancels_to_def proof(induction rule: rtranclp.induct) case (rtrancl_refl a) then show ?case by blast next case (rtrancl_into_rtrancl a b c) then have "cancels_to_1 b c" by simp then obtain i where i:"cancels_to_1_at i b c" unfolding cancels_to_1_def by meson then have c_def:"(take i b)@(drop (i + 2) b) = c" unfolding cancels_to_1_at_def cancel_at_def by force moreover have "b!i = inverse (b!(i+1))" using i unfolding cancels_to_1_at_def cancel_at_def using inverse_of_inverse by (simp add: inverse_of_inverse add.commute) then have "[b!i, b!(i+1)] ~ []" by (metis base inverse_of_inverse) then have "([b!i, b!(i+1)]@(drop (i+2) b)) ~ []@(drop (i+2) b)" using reln.refl reln.mult by fast then have "((take i b)@(([b!i, b!(i+1)]@(drop (i+2) b)))) ~ (take i b)@(drop (i+2) b)" using reln.refl reln.mult by (simp add: mult reln.refl) then have "b ~ c" using c_def by (metis Cons_nth_drop_Suc add.commute add_2_eq_Suc' append_Cons append_self_conv2 cancels_to_1_at_def i id_take_nth_drop linorder_not_less plus_1_eq_Suc trans_le_add2) then show ?case using reln.trans rtrancl_into_rtrancl(3) by fast qed definition cancels_eq::"('a,'b) word \<Rightarrow> ('a,'b) word \<Rightarrow> bool" where "cancels_eq = (\<lambda> wrd1 wrd2. cancels_to wrd1 wrd2 \<or> cancels_to wrd2 wrd1)^**" lemma cancels_eq_leftappend: "cancels_eq a b \<longrightarrow> cancels_eq (z@a) (z@b)" unfolding cancels_eq_def apply(rule impI) proof(induction rule:rtranclp.induct) case (rtrancl_refl a) then show ?case by simp next case (rtrancl_into_rtrancl a b c) then have 1: "cancels_to (z@b) (z@c) \<or> cancels_to (z@c) (z@b)" using cancels_to_leftappend by blast have "(\<lambda> wrd1 wrd2. cancels_to wrd1 wrd2 \<or> cancels_to wrd2 wrd1)\<^sup>*\<^sup>* (z @ a) (z @ b)" by (simp add: rtrancl_into_rtrancl.IH) then show "(\<lambda> wrd1 wrd2. cancels_to wrd1 wrd2 \<or> cancels_to wrd2 wrd1)\<^sup>*\<^sup>* (z @ a) (z @ c)" unfolding cancels_eq_def using 1 by (metis (no_types, lifting) rtranclp.simps) qed lemma cancels_eq_rightappend: "cancels_eq a b \<longrightarrow> cancels_eq (a@z) (b@z)" unfolding cancels_eq_def apply(rule impI) proof(induction rule:rtranclp.induct) case (rtrancl_refl a) then show ?case by simp next case (rtrancl_into_rtrancl a b c) then have 1: "cancels_to (b@z) (c@z) \<or> cancels_to (c@z) (b@z)" using cancels_to_rightappend by auto have "(\<lambda> wrd1 wrd2. cancels_to wrd1 wrd2 \<or> cancels_to wrd2 wrd1)\<^sup>*\<^sup>* (a@z) (b@z)" by (simp add: rtrancl_into_rtrancl.IH) then show "(\<lambda> wrd1 wrd2. cancels_to wrd1 wrd2 \<or> cancels_to wrd2 wrd1)\<^sup>*\<^sup>* (a@z) (c@z)" unfolding cancels_eq_def using 1 by (metis (no_types, lifting) rtranclp.simps) qed lemma "x ~ y \<Longrightarrow> cancels_eq x y" proof(induction rule:reln.induct) case (refl a) then show ?case unfolding cancels_eq_def cancels_to_def by simp next case (sym a b) then show ?case unfolding cancels_eq_def by (metis (no_types, lifting) sympD sympI symp_rtranclp) next case (trans a b c) then show ?case by (metis (no_types, lifting) cancels_eq_def rtranclp_trans) next case (base g) then have "cancels_to_1_at 0 [g, inverse g] []" unfolding cancels_to_1_at_def cancel_at_def by auto then have "cancels_to [g, inverse g] []" unfolding cancels_to_def using cancels_to_1_def by auto then show ?case unfolding cancels_eq_def by (simp add: r_into_rtranclp) next case (mult xs xs' ys ys') have "cancels_eq xs xs'" by (simp add: mult.IH(1)) then have 1:"cancels_eq (xs@ys) (xs'@ys)" by (simp add: cancels_eq_rightappend) have "cancels_eq ys ys'" by (simp add: mult.IH(2)) then have 2:"cancels_eq (xs'@ys) (xs'@ys')" by (simp add: cancels_eq_leftappend) then show "cancels_eq (xs@ys) (xs'@ys')" using 1 2 by (metis (no_types, lifting) cancels_eq_def rtranclp_trans) qed lemma cancels_to_iter: "cancels_to wrd (iter n reduction wrd)" unfolding cancels_to_def cancels_to_1_def proof (induction wrd) case Nil have "iter n reduction [] = []" sorry then show ?case sorry next case (Cons a wrd) then show ?case sorry qed lemma reduced_right_append: assumes "reduced (xs@ys)" shows "reduced xs" using assms proof (induction xs rule : reduction.induct) case 1 then show ?case try by simp next case (2 x) then show ?case try by simp next case (3 g1 g2 wrd) then show ?case proof (cases "g1 = inverse g2") case True then show ?thesis using "3.prems" by force next case False have "reduced ((g2 # wrd) @ ys)" by (metis "3.prems" append_Cons reduced.simps(3)) then have "reduced (g2#wrd)" using "3.IH"(2) False by auto then show ?thesis by (simp add: False) qed qed lemma reduced_append: assumes "reduced (ys@xs)" shows "reduced xs" using assms sorry lemma reduced_no_cancels_to_1_at: assumes "reduced xs" shows "(\<nexists>i . cancels_to_1_at i xs ys)" proof(rule ccontr) assume assm: "\<not>(\<nexists>i . cancels_to_1_at i xs ys)" hence "\<exists>i . cancels_to_1_at i xs ys" by auto then obtain i where "cancels_to_1_at i xs ys" by auto then have 1:"inverse (xs!i) = (xs!(i+1))" using cancels_to_1_at_def by (simp add: cancels_to_1_at_def) have 2: "i + 1 < length xs" by (metis \<open>cancels_to_1_at i xs ys\<close> add.commute cancels_to_1_at_def) then have "xs = (take i xs) @ ((xs!i)#(xs!(i+1))#(drop (i+2) xs))" by (metis Cons_nth_drop_Suc Suc_1 Suc_eq_plus1 add_Suc_right add_lessD1 append_take_drop_id) then have "reduced ((xs!i)#(xs!(i+1))#(drop (i+2) xs))" using assms reduced_append by metis then show "False" using reduced.simps by (simp add: "1" inverse_of_inverse) qed lemma cancels_to_1_red: assumes "reduced x" shows "\<forall>y. \<not>(cancels_to_1 x y)" proof(rule ccontr) assume assm : "\<not>(\<forall>y. \<not>(cancels_to_1 x y))" then have "\<exists>y. cancels_to_1 x y" by simp then obtain y where y : "cancels_to_1 x y" by auto then have 1: " \<exists>i\<ge>0. cancels_to_1_at i x y" unfolding cancels_to_1_def cancels_to_1_at_def by simp then have "\<exists>i. inverse (x ! i) = x ! (i + 1)" using cancels_to_1_at_def by auto then have "i + 1 < length x" using "1" assms reduced_no_cancels_to_1_at by blast then have "x = (take i x) @ ((x!i)#(x!(i+1))#(drop (i+2) x))" by (metis Cons_nth_drop_Suc Suc_1 Suc_eq_plus1 add_Suc_right add_lessD1 append_take_drop_id) then have "reduced ((x!i)#(x!(i+1))#(drop (i+2) x))" by (metis assms reduced_append) then have "reduced x = False" using "1" using reduced_no_cancels_to_1_at by auto then show "False" using assms by simp qed lemma assumes "\<not>(reduced xs)" shows "\<not>(reduced (ys@xs))" proof- have 1: "reduced (ys@xs) \<longrightarrow> reduced xs" using reduced_append by auto then show ?thesis using not_mono [OF 1] assms by argo qed lemma inv_not_reduced: assumes "(i + 1) < length wrd" "inverse (wrd ! i) = (wrd ! (i + 1))" shows "\<not>(reduced wrd)" using assms proof- have "inverse (wrd ! i) = wrd ! (i + 1)" using assms by auto have "i + 1 < length wrd" using assms reduced_no_cancels_to_1_at by blast then have 1: "wrd = (take i wrd) @ ((wrd ! i)#(wrd !(i + 1))#(drop (i + 2) wrd))" by (metis Cons_nth_drop_Suc Suc_1 Suc_eq_plus1 add_Suc_right add_lessD1 append_take_drop_id) then have "\<not>(reduced ((wrd ! i)#(wrd ! (i + 1))#(drop (i + 2) wrd)))" using assms by (metis inverse_of_inverse reduced.simps(3)) then have "reduced wrd = False" using "1" by (metis reduced_append) then show ?thesis using assms by simp qed (*proof(induction wrd arbitrary : i) case Nil then show ?case by simp next case (Cons a wrd) then show ?case proof (cases "i = 0") case True then have "inverse((a # wrd) ! 0) = (a # wrd) ! 1" using Cons reduced.simps by simp then have "(a # wrd) ! 0 = inverse((a # wrd) ! 1)" using inverse_of_inverse by metis then show ?thesis using True by (smt (z3) Cons.prems(1) One_nat_def add_cancel_right_left canonically_ordered_monoid_add_class.lessE diff_Suc_1 less_numeral_extra(1) list.discI list.size(3) list.size(4) nth_Cons_0 nth_Cons_pos plus_1_eq_Suc reduced.elims(2)) next case False have "i \<ge> 1" using False by linarith have "(i + 1) < length (a # wrd)" using local.Cons(2) by simp then have "(i + 1) \<le> length wrd" by simp have "inverse ((a # wrd) ! i) = (a # wrd) ! (i + 1)" using local.Cons(3) by auto then show ?thesis sorry qed *) lemma takei_cancelatj: assumes "i < j" (*take i (cancel_at j xs) = take i xs*) shows "take i ((take j xs)@(drop (j+2) xs)) = take i xs" using assms proof(induction xs arbitrary: i j) case (Cons a xs) then show ?case proof(cases "i = 0") case True then show ?thesis by simp next case False hence j:"j > 1" using Cons(2) by arith then have "take j (a#xs) = a#(take (j - 1) xs)" by (simp add: take_Cons') moreover have "drop (j + 2) (a#xs) = drop (j + 1) xs" using j by force ultimately have 1:"(take j (a#xs))@(drop (j + 1) xs) = a#(take (j-1) xs)@(drop (j + 1) xs)" by simp with take_Cons' False have 2:"take i (a#(take (j-1) xs)@(drop (j + 1) xs)) = a#(take (i - 1) ((take (j-1) xs)@(drop (j + 1) xs)))" by metis then have 3:"... = a#(take (i - 1) xs)" using Cons(1)[of "i-1" "j-1"] Cons(2) by force then have 4:"... = (take i (a#xs))" using False by (metis take_Cons') then show ?thesis by (metis "2" "3" Cons_eq_appendI \<open>drop (j + 2) (a # xs) = drop (j + 1) xs\<close> \<open>take j (a # xs) = a # take (j - 1) xs\<close>) qed qed(auto) lemma cancels_to_reduced : assumes "i\<ge>0" "(1+i)<length x" "cancels_to x y" "cancels_to x z" "reduced y" "reduced z" shows "y = z" unfolding cancels_to_1_def proof- have "cancels_to_1 \<^sup>*\<^sup>* x y" by (metis assms(3) cancels_to_def) moreover have "cancels_to_1 \<^sup>*\<^sup>* x z" by (metis assms(4) cancels_to_def) moreover have "\<forall>h. \<not>(cancels_to_1 y h)" using cancels_to_1_red assms (5) by auto moreover have "\<forall>h. \<not>(cancels_to_1 z h)" using cancels_to_1_red assms(6) by auto ultimately show "y = z" sorry qed lemma "cancels_eq x y \<Longrightarrow> reduced x \<Longrightarrow> reduced y \<Longrightarrow> x = y" sorry (* define overlapping where "overlapping \<equiv> \<lambda> m (n :: nat). m \<in> {n, n + 1} \<or> n \<in> {m, m + 1}" *) lemma novl : assumes "i \<ge> 0" "i + 1 < j" "(1 + j) < length wrd" shows "cancel_at (j-2) (cancel_at i wrd) = cancel_at i (cancel_at j wrd)" proof- have "(cancel_at i wrd) = take i wrd @ (drop (2 + i) wrd)" unfolding cancel_at_def by simp then show "cancel_at (j-2) (cancel_at i wrd) = cancel_at i (cancel_at j wrd)" sorry qed lemma "diamond (λ x y. (cancels_to_1 x y) ∨ x = y)" unfolding diamond_def cancels_to_1_def commute_def square_def apply (rule allI, rule allI, rule impI, rule allI, rule impI) proof- fix x y z :: "('a,'b) word" assume 1:"(∃i. cancels_to_1_at i x y) ∨ x = y" assume 2:"(∃i. cancels_to_1_at i x z) ∨ x = z" show "∃u. ((∃i. cancels_to_1_at i y u) ∨ y = u) ∧ ((∃i. cancels_to_1_at i z u) ∨ z = u)" proof (cases "x = y ∨ x = z") case True have "(∃i. cancels_to_1_at i y z) ∨ (∃i. cancels_to_1_at i z y) ∨ z = y" using "1" "2" True by auto then show ?thesis by auto next case False then have "x ≠ y" "x ≠ z" by auto then show ?thesis proof (cases "y = z") case True then show ?thesis by auto next case False then have asm1:"(∃i. cancels_to_1_at i x y)" using "1" False ‹x ≠ y› by auto then obtain i where i: "cancels_to_1_at i x y" by auto have asm2 :"(∃i. cancels_to_1_at i x z)" using "2" False ‹x ≠ z› by auto then obtain j where j: "cancels_to_1_at j x z" by auto define overlapping where "overlapping ≡ λ m (n :: nat). m ∈ {n, n + 1} ∨ n ∈ {m, m + 1}" then show ?thesis proof (cases "overlapping i j") case True then have ovl:"i ∈ {j, j + 1} ∨ j ∈ {i, i + 1}" using overlapping_def by auto then show ?thesis proof (cases "i = j") case True then have "y = z" using i j cancels_to_1_at_def by metis then show ?thesis by auto next case False then have "(i > j) ∨ (i < j)" by auto then have "i = j + 1 ∨ j = i + 1" using ovl by blast then show ?thesis proof (cases "j = i + 1") case True have t: "j = i + 1" using True by auto then have a: "inverse (x ! i) = x ! (i + 1)" using cancels_to_1_at_def i by fastforce have b : "inverse (x ! j) = x ! (j + 1)" by (metis add.commute cancels_to_1_at_def j) then have "inverse (x ! (i + 1)) = x ! (i + 2)" using t by simp then have m: "((nth x (i + 2)) = (nth x i))" using a b t inverse_of_inverse by metis then have n: "cancel_at i x = y" using "1" i cancels_to_1_at_def cancel_at_def by metis have "cancel_at j x = z" using "1" i cancels_to_1_at_def cancel_at_def by (metis True j) then have "take i x @ drop (2 + i) x = take j x @ drop (2 + j) x" using a b m n sorry then have y: "y = z" using m n a b cancel_at_def by (metis ‹cancel_at j x = z›) then show ?thesis by auto next case False then have t: "i = j + 1" using ‹i = j + 1 ∨ j = i + 1› by blast then have a: "inverse (x ! j) = x ! (j + 1)" using cancels_to_1_at_def j by fastforce have b : "inverse (x ! i) = x ! (i + 1)" using cancels_to_1_at_def i by auto then have "inverse (x ! (j + 1)) = x ! (j + 2)" using t by simp then have m: "((nth x (j + 2)) = (nth x j))" using a b t inverse_of_inverse by metis then have n: "cancel_at j x = z" using "1" j cancels_to_1_at_def cancel_at_def by metis have "cancel_at i x = y" using "1" i cancels_to_1_at_def cancel_at_def by (metis True j) then have "take i x @ drop (2 + i) x = take j x @ drop (2 + j) x" using a b m n sorry then have y: "y = z" using m n a b cancel_at_def by (metis ‹cancel_at i x = y›) then show ?thesis by auto qed qed next case False then have novl1:"¬(i ∈ {j, j + 1})" by (simp add: overlapping_def) have novl2: "¬(j ∈ {i, i + 1})" using False by (simp add: overlapping_def) then show ?thesis proof (cases "i<j") case True then have a:"(i + 1) < j" using i j True overlapping_def by (metis Nat.add_0_right add_Suc_right insertCI linorder_neqE_nat nat_1 nat_one_as_int not_less_eq novl2) have "cancels_to_1_at j x z" using j by auto then have b: "(j + 1) < length x" using cancels_to_1_at_def by auto have "cancels_to_1_at i x y" using i by auto then have c: "i ≥ 0" by simp then have "cancel_at i (cancel_at j x) = cancel_at (j - 2) (cancel_at i x)" using a b novl[of i j x] by simp then have "cancel_at (j - 2) y = cancel_at i z" using cancels_to_1_at_def by (metis i j) then have "(nth x i) = (nth z i)" sorry then show ?thesis sorry next case False then have "i ≠ j" using novl1 by auto then have "i > j" using False by auto then have a:"(j + 1) < i" using i j overlapping_def using novl1 by force have "cancels_to_1_at i x y" using i by auto then have b: "(i + 1) < length x" using cancels_to_1_at_def by auto have "cancels_to_1_at j x z" using j by auto then have c: "j ≥ 0" by simp then have "cancel_at j (cancel_at i x) = cancel_at (i - 2) (cancel_at j x)" using a b novl[of j i x] by simp then have "cancel_at (i - 2) z = cancel_at j y" using cancels_to_1_at_def by (metis i j) then have "(nth x j) = (nth z j)" sorry then show ?thesis using i j sorry qed qed qed qed qed
[STATEMENT] lemma PosOrd_SeqI2: assumes "v2 :\<sqsubset>val w2" "flat v2 = flat w2" shows "Seq v v2 :\<sqsubset>val Seq v w2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Seq v v2 :\<sqsubset>val Seq v w2 [PROOF STEP] using assms(1) [PROOF STATE] proof (prove) using this: v2 :\<sqsubset>val w2 goal (1 subgoal): 1. Seq v v2 :\<sqsubset>val Seq v w2 [PROOF STEP] apply(subst (asm) PosOrd_ex_def) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>p. v2 \<sqsubset>val p w2 \<Longrightarrow> Seq v v2 :\<sqsubset>val Seq v w2 [PROOF STEP] apply(subst (asm) PosOrd_def) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>p. pflat_len w2 p < pflat_len v2 p \<and> (\<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q) \<Longrightarrow> Seq v v2 :\<sqsubset>val Seq v w2 [PROOF STEP] apply(clarify) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> Seq v v2 :\<sqsubset>val Seq v w2 [PROOF STEP] apply(subst PosOrd_ex_def) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> \<exists>p. Seq v v2 \<sqsubset>val p Seq v w2 [PROOF STEP] apply(rule_tac x="Suc 0#p" in exI) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> Seq v v2 \<sqsubset>val Suc 0 # p Seq v w2 [PROOF STEP] apply(subst PosOrd_def) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> pflat_len (Seq v w2) (Suc 0 # p) < pflat_len (Seq v v2) (Suc 0 # p) \<and> (\<forall>q\<in>Pos (Seq v v2) \<union> Pos (Seq v w2). q \<sqsubset>lex Suc 0 # p \<longrightarrow> pflat_len (Seq v v2) q = pflat_len (Seq v w2) q) [PROOF STEP] apply(rule conjI) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> pflat_len (Seq v w2) (Suc 0 # p) < pflat_len (Seq v v2) (Suc 0 # p) 2. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> \<forall>q\<in>Pos (Seq v v2) \<union> Pos (Seq v w2). q \<sqsubset>lex Suc 0 # p \<longrightarrow> pflat_len (Seq v v2) q = pflat_len (Seq v w2) q [PROOF STEP] apply(simp add: pflat_len_simps) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> \<forall>q\<in>Pos (Seq v v2) \<union> Pos (Seq v w2). q \<sqsubset>lex Suc 0 # p \<longrightarrow> pflat_len (Seq v v2) q = pflat_len (Seq v w2) q [PROOF STEP] apply(rule ballI) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p q. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; q \<in> Pos (Seq v v2) \<union> Pos (Seq v w2)\<rbrakk> \<Longrightarrow> q \<sqsubset>lex Suc 0 # p \<longrightarrow> pflat_len (Seq v v2) q = pflat_len (Seq v w2) q [PROOF STEP] apply(rule impI) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p q. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; q \<in> Pos (Seq v v2) \<union> Pos (Seq v w2); q \<sqsubset>lex Suc 0 # p\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) q = pflat_len (Seq v w2) q [PROOF STEP] apply(simp only: Pos.simps) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>p q. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; q \<in> {[]} \<union> {0 # ps |ps. ps \<in> Pos v} \<union> {1 # ps |ps. ps \<in> Pos v2} \<union> ({[]} \<union> {0 # ps |ps. ps \<in> Pos v} \<union> {1 # ps |ps. ps \<in> Pos w2}); q \<sqsubset>lex Suc 0 # p\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) q = pflat_len (Seq v w2) q [PROOF STEP] apply(auto)[1] [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) [] = pflat_len (Seq v w2) [] 2. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 3. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos v2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) 4. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 5. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos w2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) [PROOF STEP] apply(simp add: pflat_len_simps) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> length (flat v2) = length (flat w2) 2. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 3. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos v2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) 4. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 5. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos w2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) [PROOF STEP] using assms(2) [PROOF STATE] proof (prove) using this: flat v2 = flat w2 goal (5 subgoals): 1. \<And>p. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q\<rbrakk> \<Longrightarrow> length (flat v2) = length (flat w2) 2. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 3. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos v2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) 4. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 5. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos w2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 2. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos v2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) 3. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<in> Pos v\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (0 # ps) = pflat_len (Seq v w2) (0 # ps) 4. \<And>p ps. \<lbrakk>pflat_len w2 p < pflat_len v2 p; \<forall>q\<in>Pos v2 \<union> Pos w2. q \<sqsubset>lex p \<longrightarrow> pflat_len v2 q = pflat_len w2 q; ps \<sqsubset>lex p; ps \<in> Pos w2\<rbrakk> \<Longrightarrow> pflat_len (Seq v v2) (Suc 0 # ps) = pflat_len (Seq v w2) (Suc 0 # ps) [PROOF STEP] apply(auto simp add: pflat_len_simps) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
#include "../SDPB_Parameters.hxx" #include <boost/program_options.hpp> #include <boost/filesystem/fstream.hpp> namespace po = boost::program_options; SDPB_Parameters::SDPB_Parameters(int argc, char *argv[]) { int int_verbosity; std::string write_solution_string; using namespace std::string_literals; po::options_description required_options("Required options"); required_options.add_options()( "sdpDir,s", po::value<boost::filesystem::path>(&sdp_path)->required(), "Directory containing preprocessed SDP data files."); required_options.add_options()( "procsPerNode", po::value<size_t>(&procs_per_node)->required(), "The number of processes that can run on a node. When running on " "more " "than one node, the load balancer needs to know how many processes " "are assigned to each node. On a laptop or desktop, this would be " "the number of physical cores on your machine, not including " "hyperthreaded cores. For current laptops (2018), this is probably " "2 or 4.\n\n" "If you are using the Slurm workload manager, this should be set to " "'$SLURM_NTASKS_PER_NODE'."); po::options_description cmd_line_options; cmd_line_options.add(required_options); po::options_description basic_options("Basic options"); basic_options.add_options()("help,h", "Show this helpful message."); basic_options.add_options()("version", "Show version and configuration info."); basic_options.add_options()( "paramFile,p", po::value<boost::filesystem::path>(&param_path), "Any parameter can optionally be set via this file in key=value " "format. Command line arguments override values in the parameter " "file."); basic_options.add_options()( "outDir,o", po::value<boost::filesystem::path>(&out_directory), "The optimal solution is saved to this directory in Mathematica " "format. Defaults to sdpDir with '_out' appended."); basic_options.add_options()( "noFinalCheckpoint", po::bool_switch(&no_final_checkpoint)->default_value(false), "Don't save a final checkpoint after terminating (useful when " "debugging)."); basic_options.add_options()( "writeSolution", po::value<std::string>(&write_solution_string)->default_value("x,y"s), "A comma separated list of vectors and matrices to write into the output " "directory. The default only writes the vectors 'x' and 'y'. If you add " "the 'X' and 'Y' matrices, then the output directory can be used as a " "final text " "checkpoint. Runs started from text checkpoints will very close to, but " "not bitwise identical to, the original run.\nTo only output the result " "(because, for example, you only want to know if SDPB found a primal " "feasible point), set this to an empty string."); basic_options.add_options()( "procGranularity", po::value<size_t>(&proc_granularity)->default_value(1), "procGranularity must evenly divide procsPerNode.\n\n" "The minimum number of cores in a group, used during load balancing. " "Setting it to anything larger than 1 will make the solution take " "longer. " "This option is generally useful only when trying to fit a large problem " "in a small machine."); basic_options.add_options()("verbosity", po::value<int>(&int_verbosity)->default_value(1), "Verbosity. 0 -> no output, 1 -> regular " "output, 2 -> debug output"); cmd_line_options.add(basic_options); cmd_line_options.add(solver.options()); po::variables_map variables_map; try { po::store(po::parse_command_line(argc, argv, cmd_line_options), variables_map); if(variables_map.count("help") != 0) { if(El::mpi::Rank() == 0) { std::cout << cmd_line_options << '\n'; } } else if(variables_map.count("version") != 0) { if(El::mpi::Rank() == 0) { std::cout << "SDPB " << SDPB_VERSION_STRING << "\n"; } El::PrintVersion(); El::PrintConfig(); El::PrintCCompilerInfo(); El::PrintCxxCompilerInfo(); } else { if(variables_map.count("paramFile") != 0) { // TODO: The next line is redundant. param_file has // already been set. Also, I can use // boost::filesystem::ifstream and avoid the // .string().c_str() nonsense. param_path = variables_map["paramFile"].as<boost::filesystem::path>(); std::ifstream ifs(param_path.string().c_str()); if(!ifs.good()) { throw std::runtime_error("Could not open '" + param_path.string() + "'"); } po::store(po::parse_config_file(ifs, cmd_line_options), variables_map); } po::notify(variables_map); if(!boost::filesystem::exists(sdp_path)) { throw std::runtime_error("sdp directory '" + sdp_path.string() + "' does not exist"); } if(variables_map.count("outDir") == 0) { out_directory = sdp_path; if(out_directory.filename() == ".") { out_directory = out_directory.parent_path(); } out_directory += "_out"; } if(variables_map.count("checkpointDir") == 0) { solver.checkpoint_out = sdp_path; if(solver.checkpoint_out.filename() == ".") { solver.checkpoint_out = solver.checkpoint_out.parent_path(); } solver.checkpoint_out += ".ck"; } if(variables_map.count("initialCheckpointDir") == 0) { solver.checkpoint_in = solver.checkpoint_out; } else { require_initial_checkpoint = true; } write_solution = Write_Solution(write_solution_string); if(El::mpi::Rank() == 0) { boost::filesystem::create_directories(out_directory); boost::filesystem::ofstream ofs(out_directory / "out.txt"); if(!ofs.good()) { throw std::runtime_error("Cannot write to outDir: " + out_directory.string()); } } if(int_verbosity != 0 && int_verbosity != 1 && int_verbosity != 2) { throw std::runtime_error( "Invalid number for Verbosity. Only 0, 1 or 2 are allowed\n"); } else { verbosity = static_cast<Verbosity>(int_verbosity); } } } catch(po::error &e) { El::ReportException(e); El::mpi::Abort(El::mpi::COMM_WORLD, 1); } }
from mpmath import mp from .argparser import args DPS = args.dps DPS_BUFFER = args.buffer + int(mp.log10(DPS)) # set mpmath decimal precision mp.dps = DPS + DPS_BUFFER
(* Title: HOL/Quotient_Examples/Lift_Fun.thy Author: Ondrej Kuncar *) section \<open>Example of lifting definitions with contravariant or co/contravariant type variables\<close> theory Lift_Fun imports Main "~~/src/HOL/Library/Quotient_Syntax" begin text \<open>This file is meant as a test case. It contains examples of lifting definitions with quotients that have contravariant type variables or type variables which are covariant and contravariant in the same time.\<close> subsection \<open>Contravariant type variables\<close> text \<open>'a is a contravariant type variable and we are able to map over this variable in the following four definitions. This example is based on HOL/Fun.thy.\<close> quotient_type ('a, 'b) fun' (infixr "\<rightarrow>" 55) = "'a \<Rightarrow> 'b" / "op =" by (simp add: identity_equivp) quotient_definition "comp' :: ('b \<rightarrow> 'c) \<rightarrow> ('a \<rightarrow> 'b) \<rightarrow> 'a \<rightarrow> 'c" is "comp :: ('b \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'c" done quotient_definition "fcomp' :: ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'c" is fcomp done quotient_definition "map_fun' :: ('c \<rightarrow> 'a) \<rightarrow> ('b \<rightarrow> 'd) \<rightarrow> ('a \<rightarrow> 'b) \<rightarrow> 'c \<rightarrow> 'd" is "map_fun::('c \<Rightarrow> 'a) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'c \<Rightarrow> 'd" done quotient_definition "inj_on' :: ('a \<rightarrow> 'b) \<rightarrow> 'a set \<rightarrow> bool" is inj_on done quotient_definition "bij_betw' :: ('a \<rightarrow> 'b) \<rightarrow> 'a set \<rightarrow> 'b set \<rightarrow> bool" is bij_betw done subsection \<open>Co/Contravariant type variables\<close> text \<open>'a is a covariant and contravariant type variable in the same time. The following example is a bit artificial. We haven't had a natural one yet.\<close> quotient_type 'a endofun = "'a \<Rightarrow> 'a" / "op =" by (simp add: identity_equivp) definition map_endofun' :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> ('a => 'a) \<Rightarrow> ('b => 'b)" where "map_endofun' f g e = map_fun g f e" quotient_definition "map_endofun :: ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a endofun \<Rightarrow> 'b endofun" is map_endofun' done text \<open>Registration of the map function for 'a endofun.\<close> functor map_endofun : map_endofun proof - have "\<forall> x. abs_endofun (rep_endofun x) = x" using Quotient3_endofun by (auto simp: Quotient3_def) then show "map_endofun id id = id" by (auto simp: map_endofun_def map_endofun'_def map_fun_def fun_eq_iff) have a:"\<forall> x. rep_endofun (abs_endofun x) = x" using Quotient3_endofun Quotient3_rep_abs[of "(op =)" abs_endofun rep_endofun] by blast show "\<And>f g h i. map_endofun f g \<circ> map_endofun h i = map_endofun (f \<circ> h) (i \<circ> g)" by (auto simp: map_endofun_def map_endofun'_def map_fun_def fun_eq_iff) (simp add: a o_assoc) qed text \<open>Relator for 'a endofun.\<close> definition rel_endofun' :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> bool" where "rel_endofun' R = (\<lambda>f g. (R ===> R) f g)" quotient_definition "rel_endofun :: ('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a endofun \<Rightarrow> 'b endofun \<Rightarrow> bool" is rel_endofun' done lemma endofun_quotient: assumes a: "Quotient3 R Abs Rep" shows "Quotient3 (rel_endofun R) (map_endofun Abs Rep) (map_endofun Rep Abs)" proof (intro Quotient3I) show "\<And>a. map_endofun Abs Rep (map_endofun Rep Abs a) = a" by (metis (hide_lams, no_types) a abs_o_rep id_apply map_endofun.comp map_endofun.id o_eq_dest_lhs) next show "\<And>a. rel_endofun R (map_endofun Rep Abs a) (map_endofun Rep Abs a)" using fun_quotient3[OF a a, THEN Quotient3_rep_reflp] unfolding rel_endofun_def map_endofun_def map_fun_def o_def map_endofun'_def rel_endofun'_def id_def by (metis (mono_tags) Quotient3_endofun rep_abs_rsp) next have abs_to_eq: "\<And> x y. abs_endofun x = abs_endofun y \<Longrightarrow> x = y" by (drule arg_cong[where f=rep_endofun]) (simp add: Quotient3_rep_abs[OF Quotient3_endofun]) fix r s show "rel_endofun R r s = (rel_endofun R r r \<and> rel_endofun R s s \<and> map_endofun Abs Rep r = map_endofun Abs Rep s)" apply(auto simp add: rel_endofun_def rel_endofun'_def map_endofun_def map_endofun'_def) using fun_quotient3[OF a a,THEN Quotient3_refl1] apply metis using fun_quotient3[OF a a,THEN Quotient3_refl2] apply metis using fun_quotient3[OF a a, THEN Quotient3_rel] apply metis by (auto intro: fun_quotient3[OF a a, THEN Quotient3_rel, THEN iffD1] simp add: abs_to_eq) qed declare [[mapQ3 endofun = (rel_endofun, endofun_quotient)]] quotient_definition "endofun_id_id :: ('a endofun) endofun" is "id :: ('a \<Rightarrow> 'a) \<Rightarrow> ('a \<Rightarrow> 'a)" done term endofun_id_id thm endofun_id_id_def quotient_type 'a endofun' = "'a endofun" / "op =" by (simp add: identity_equivp) text \<open>We have to map "'a endofun" to "('a endofun') endofun", i.e., mapping (lifting) over a type variable which is a covariant and contravariant type variable.\<close> quotient_definition "endofun'_id_id :: ('a endofun') endofun'" is endofun_id_id done term endofun'_id_id thm endofun'_id_id_def end
/- Definition of diagonally dominant matrices and tactic. -/ import data.matrix.basic import data.matrix.notation import data.rat.basic import data.finset.basic import tactic.fin_cases import tactic.linarith open_locale big_operators def diagdom {n : ℕ} (A : matrix (fin n) (fin n) ℚ) : Prop := ∀ i, (∑ j, if i ≠ j then abs (A i j) else 0) ≤ abs (A i i) namespace diagdom open tactic open interactive (parse) open lean.parser (ident) private meta def unfold_matrix : tactic unit := do `(diagdom %%M) ← target, dunfold_target [name.from_string M.to_string] {} meta def prove_diagdom : tactic unit := `[unfold_matrix, intros i, fin_cases i; simp only [fin.sum_univ_succ]; dec_trivial] def I2 : matrix (fin 2) (fin 2) ℚ := ![![1, 0], ![0, 1]] def I4 : matrix (fin 4) (fin 4) ℚ := ![![1, 0, 0, 0], ![0, 1, 0, 0], ![0, 0, 1, 0], ![0, 0, 0, 1]] def A : matrix (fin 3) (fin 3) ℚ := ![![ 3, -2, 1], ![ 1, -3, 2], ![-1, 2, 4]] def F : matrix (fin 9) (fin 9) ℚ := ![![1, 0.04, 0.05, 0.04, 0.02, 0.01, 0.02, 0.05, 0.03], ![0.02, 1, 0.02, 0.02, 0.03, 0.02, 0.04, 0.04, 0.02], ![0.04, 0.02, 1, 0.05, 0.05, 0.04, 0.03, 0.05, 0.03], ![0.05, 0.04, 0.03, 1, 0.02, 0.05, 0.03, 0.02, 0.03], ![0.03, 0.03, 0.05, 0.03, 1, 0.02, 0.04, 0.01, 0.03], ![0.05, 0.04, 0.02, 0.01, 0.03, 1, 0.04, 0.05, 0.04], ![0.03, 0.04, 0.04, 0.02, 0.02, 0.03, 1, 0.01, 0.01], ![0.04, 0.03, 0.01, 0.02, 0.05, 0.02, 0.02, 1, 0.02], ![0.05, 0.01, 0.03, 0.04, 0.04, 0.05, 0.03, 0.03, 1]] set_option profiler true set_option timeout 10000000 example : diagdom I2 := by prove_diagdom example : diagdom I4 := by prove_diagdom example : diagdom A := by prove_diagdom --example : diagdom F := by prove_diagdom end diagdom
{-# OPTIONS --prop --rewriting #-} module Examples.Sorting.Sequential where open import Examples.Sorting.Sequential.Comparable open import Calf costMonoid open import Calf.Types.Nat open import Calf.Types.List open import Relation.Binary.PropositionalEquality as Eq using (_≡_) open import Data.Product using (_,_) test/forward = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ 6 ∷ 7 ∷ 8 ∷ 9 ∷ 10 ∷ 11 ∷ 12 ∷ 13 ∷ 14 ∷ 15 ∷ 16 ∷ [] test/backward = 16 ∷ 15 ∷ 14 ∷ 13 ∷ 12 ∷ 11 ∷ 10 ∷ 9 ∷ 8 ∷ 7 ∷ 6 ∷ 5 ∷ 4 ∷ 3 ∷ 2 ∷ 1 ∷ [] test/shuffled = 4 ∷ 8 ∷ 12 ∷ 16 ∷ 13 ∷ 3 ∷ 5 ∷ 14 ∷ 9 ∷ 6 ∷ 7 ∷ 10 ∷ 11 ∷ 1 ∷ 2 ∷ 15 ∷ [] module Ex/InsertionSort where import Examples.Sorting.Sequential.InsertionSort NatComparable as Sort list' = list nat ex/insert : cmp (F list') ex/insert = Sort.insert 3 (1 ∷ 2 ∷ 4 ∷ []) ex/sort : cmp (F list') ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ []) ex/sort/forward : cmp (F list') ex/sort/forward = Sort.sort test/forward -- cost: 15 ex/sort/backward : cmp (F list') ex/sort/backward = Sort.sort test/backward -- cost: 120 ex/sort/shuffled : cmp (F list') ex/sort/shuffled = Sort.sort test/shuffled -- cost: 76 module Ex/MergeSort where import Examples.Sorting.Sequential.MergeSort NatComparable as Sort list' = list nat ex/split : cmp (F Sort.pair) ex/split = Sort.split (6 ∷ 2 ∷ 8 ∷ 3 ∷ 1 ∷ 8 ∷ 5 ∷ []) ex/merge : cmp (F list') ex/merge = Sort.merge (2 ∷ 3 ∷ 6 ∷ 8 ∷ [] , 1 ∷ 5 ∷ 8 ∷ []) ex/sort : cmp (F list') ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ []) ex/sort/forward : cmp (F list') ex/sort/forward = Sort.sort test/forward -- cost: 32 ex/sort/backward : cmp (F list') ex/sort/backward = Sort.sort test/backward -- cost: 32 ex/sort/shuffled : cmp (F list') ex/sort/shuffled = Sort.sort test/shuffled -- cost: 47 module SortEquivalence (M : Comparable) where open Comparable M open import Examples.Sorting.Sequential.Core M import Examples.Sorting.Sequential.InsertionSort M as ISort import Examples.Sorting.Sequential.MergeSort M as MSort isort≡msort : ◯ (ISort.sort ≡ MSort.sort) isort≡msort = IsSort⇒≡ ISort.sort ISort.sort/correct MSort.sort MSort.sort/correct
The convex hull of a set is contained in its affine hull.
(** ** Normalization of types This file contains a lot of stuff related to the historical normalization of types performed as a pre-processing phase. The current version uses a notion of dynamic types instead and a conversion function [TypToDtyp.typ_to_dtyp]. The content of this file is however likely to be useful for static analyses in the future. *) From Coq Require Import List String Logic.FunctionalExtensionality. From Vellvm Require Import Utils.Util Syntax.LLVMAst Syntax.AstLib Syntax.DynamicTypes. Require Import Coqlib. Import ListNotations. Open Scope list_scope. Ltac contra := try match goal with | [Heq : ?x = ?y, Hneq : ?y <> ?x |- _] => symmetry in Heq end; contradiction. (* Inductive predicate for types in LLVM with a size *) Inductive sized_typ : list (ident * typ) -> typ -> Prop := | sized_typ_I : forall (defs : list (ident * typ)) (sz : N), sized_typ defs (TYPE_I sz) | sized_typ_Pointer : forall (defs : list (ident * typ)) (t : typ), sized_typ defs (TYPE_Pointer t) | sized_typ_Half : forall (defs : list (ident * typ)), sized_typ defs TYPE_Half | sized_typ_Float : forall (defs : list (ident * typ)), sized_typ defs TYPE_Float | sized_typ_Double : forall (defs : list (ident * typ)), sized_typ defs TYPE_Double | sized_typ_X86_fp80 : forall (defs : list (ident * typ)), sized_typ defs TYPE_X86_fp80 | sized_typ_Fp128 : forall (defs : list (ident * typ)), sized_typ defs TYPE_Fp128 | sized_typ_Ppc_fp128 : forall (defs : list (ident * typ)), sized_typ defs TYPE_Ppc_fp128 | sized_typ_Metadata : forall (defs : list (ident * typ)), sized_typ defs TYPE_Metadata | sized_typ_X86_mmx : forall (defs : list (ident * typ)), sized_typ defs TYPE_X86_mmx | sized_typ_Array : forall (defs : list (ident * typ)) (sz : N) (t : typ), sized_typ defs t -> sized_typ defs (TYPE_Array sz t) | sized_typ_Struct : forall (defs : list (ident * typ)) (fields : list typ), (forall (f : typ), In f fields -> sized_typ defs f) -> sized_typ defs (TYPE_Struct fields) | sized_typ_Packed_struct : forall (defs : list (ident * typ)) (fields : list typ), (forall (f : typ), In f fields -> sized_typ defs f) -> sized_typ defs (TYPE_Packed_struct fields) | sized_typ_Vector : forall (defs : list (ident * typ)) (sz : N) (t : typ), sized_typ defs t -> sized_typ defs (TYPE_Vector sz t) | sized_typ_Identified : forall (defs : list (ident * typ)) (id : ident), (exists (t : typ), In (id, t) defs -> sized_typ defs t) -> sized_typ defs (TYPE_Identified id) . (* Inductive predicate for types in LLVM that can be elements of vectors. "elementtype" may be any integer, floating-point or pointer type. https://llvm.org/docs/LangRef.html#vector-type *) Inductive element_typ : typ -> Prop := | element_typ_Pointer : forall (t : typ), element_typ (TYPE_Pointer t) | element_typ_I : forall (sz : N), element_typ (TYPE_I sz) | element_typ_Half : element_typ TYPE_Half | element_typ_Float : element_typ TYPE_Float | element_typ_Double : element_typ TYPE_Double | element_typ_X86_fp80 : element_typ TYPE_X86_fp80 | element_typ_Fp128 : element_typ TYPE_Fp128 | element_typ_Ppc_fp128 : element_typ TYPE_Ppc_fp128 . (* Predicate to ensure that an ident is guarded by a pointer everywhere in a type in an environment *) Inductive guarded_typ : ident -> list (ident * typ) -> typ -> Prop := | guarded_typ_I : forall (id : ident) (env : list (ident * typ)) (sz : N), guarded_typ id env (TYPE_I sz) | guarded_typ_Pointer : forall (id : ident) (env : list (ident * typ)) (t : typ), guarded_typ id env (TYPE_Pointer t) | guarded_typ_Void : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Void | guarded_typ_Half : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Half | guarded_typ_Float : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Float | guarded_typ_Double : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Double | guarded_typ_X86_fp80 : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_X86_fp80 | guarded_typ_Fp128 : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Fp128 | guarded_typ_Ppc_fp128 : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Ppc_fp128 | guarded_typ_Metadata : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Metadata | guarded_typ_X86_mmx : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_X86_mmx | guarded_typ_Function : forall (id : ident) (env : list (ident * typ)) (ret : typ) (args : list typ), guarded_typ id env ret -> (forall a, In a args -> guarded_typ id env a) -> guarded_typ id env (TYPE_Function ret args) | guarded_typ_Array : forall (id : ident) (env : list (ident * typ)) (sz : N) (t : typ), guarded_typ id env t -> guarded_typ id env (TYPE_Array sz t) | guarded_typ_Struct : forall (id : ident) (env : list (ident * typ)) (t : typ) (fields : list typ), (forall f, In f fields -> guarded_typ id env f) -> guarded_typ id env (TYPE_Struct fields) | guarded_typ_Packed_struct : forall (id : ident) (env : list (ident * typ)) (t : typ) (fields : list typ), (forall f, In f fields -> guarded_typ id env f) -> guarded_typ id env (TYPE_Packed_struct fields) | guarded_typ_Opaque : forall (id : ident) (env : list (ident * typ)), guarded_typ id env TYPE_Opaque | guarded_typ_Vector : forall (id : ident) (env : list (ident * typ)) (sz : N) (t : typ), guarded_typ id env (TYPE_Vector sz t) | guarded_typ_Identified_Some : forall (id : ident) (env : list (ident * typ)) (id' : ident) (t : typ), id <> id' -> Some (id', t) = find (fun a => Ident.eq_dec id' (fst a)) env -> guarded_typ id env t -> guarded_typ id' env t -> guarded_typ id env (TYPE_Identified id') | guarded_typ_Identified_None : forall (id : ident) (env : list (ident * typ)) (id' : ident), id <> id' -> None = find (fun a => Ident.eq_dec id' (fst a)) env -> guarded_typ id env (TYPE_Identified id') . Inductive first_class_typ : typ -> Prop := | first_class_I : forall sz, first_class_typ (TYPE_I sz) | first_class_Pointer : forall t, first_class_typ (TYPE_Pointer t) | first_class_Void : first_class_typ TYPE_Void | first_class_Half : first_class_typ TYPE_Half | first_class_Float : first_class_typ TYPE_Float | first_class_Double : first_class_typ TYPE_Double | first_class_X86_fp80 : first_class_typ TYPE_X86_fp80 | first_class_Fp128 : first_class_typ TYPE_Fp128 | first_class_Ppc_fp128 : first_class_typ TYPE_Ppc_fp128 | first_class_Metadata : first_class_typ TYPE_Metadata | first_class_X86_mmx : first_class_typ TYPE_X86_mmx | first_class_Array : forall sz t, first_class_typ (TYPE_Array sz t) | first_class_Struct : forall fields, first_class_typ (TYPE_Struct fields) | first_class_Packed_struct : forall fields, first_class_typ (TYPE_Packed_struct fields) | first_class_Opaque : first_class_typ TYPE_Opaque | first_class_Vector : forall sz t, first_class_typ (TYPE_Vector sz t) | first_class_Identified : forall id, first_class_typ (TYPE_Identified id) . Definition function_ret_typ (t : typ) : Prop := first_class_typ t /\ t <> TYPE_Metadata. (* Inductive predicate for well-formed LLVM types. wf_typ env t means that 't' is a well-formed type in the environment 'env'. The environment just associates identifiers to types, so this contains things like user-defined structure types. well-formed LLVM types should cover every valid type in LLVM. Examples of invalid types: - Vectors of size 0 - Arrays with unsized elements - Recursive structures (must be guarded by a pointer) *) Inductive wf_typ : list (ident * typ) -> typ -> Prop := | wf_typ_Pointer: forall (defs : list (ident * typ)) (t : typ), wf_typ defs t -> wf_typ defs (TYPE_Pointer t) | wf_typ_I : forall (defs : list (ident * typ)) (sz : N), (sz > 0)%N -> wf_typ defs (TYPE_I sz) | wf_typ_Void : forall (defs : list (ident * typ)), wf_typ defs TYPE_Void | wf_typ_Half : forall (defs : list (ident * typ)), wf_typ defs TYPE_Half | wf_typ_Float : forall (defs : list (ident * typ)), wf_typ defs TYPE_Float | wf_typ_Double : forall (defs : list (ident * typ)), wf_typ defs TYPE_Double | wf_typ_X86_fp80 : forall (defs : list (ident * typ)), wf_typ defs TYPE_X86_fp80 | wf_typ_Fp128 : forall (defs : list (ident * typ)), wf_typ defs TYPE_Fp128 | wf_typ_Ppc_fp128 : forall (defs : list (ident * typ)), wf_typ defs TYPE_Ppc_fp128 | wf_typ_Metadata : forall (defs : list (ident * typ)), wf_typ defs TYPE_Metadata | wf_typ_X86_mmx : forall (defs : list (ident * typ)), wf_typ defs TYPE_X86_mmx | wf_typ_Function : forall (defs : list (ident * typ)) (ret : typ) (args : list typ), function_ret_typ ret -> wf_typ defs ret -> (forall (a : typ), In a args -> sized_typ defs a) -> (forall (a : typ), In a args -> wf_typ defs a) -> wf_typ defs (TYPE_Function ret args) (* Arrays are only well formed if the size is >= 0, and the element type is sized. *) | wf_typ_Array : forall (defs : list (ident * typ)) (sz : N) (t : typ), (sz >= 0)%N -> sized_typ defs t -> wf_typ defs t -> wf_typ defs (TYPE_Array sz t) (* Vectors of size 0 are not allowed, and elements must be of element_typ. *) | wf_typ_Vector : forall (defs : list (ident * typ)) (sz : N) (t : typ), (sz > 0)%N -> element_typ t -> wf_typ defs t -> wf_typ defs (TYPE_Vector sz t) (* Any type identifier must exist in the environment. Additionally the identifier must not occur anywhere in the type that it refers to *unless* it is guarded by a pointer. *) | wf_typ_Identified : forall (defs : list (ident * typ)) (id : ident), (exists t, In (id, t) defs) -> (forall (t : typ), In (id, t) defs -> guarded_typ id defs t) -> (forall (t : typ), In (id, t) defs -> wf_typ defs t) -> wf_typ defs (TYPE_Identified id) (* Fields of structure must be sized types *) | wf_typ_Struct : forall (defs : list (ident * typ)) (fields : list typ), (forall (f : typ), In f fields -> sized_typ defs f) -> (forall (f : typ), In f fields -> wf_typ defs f) -> wf_typ defs (TYPE_Struct fields) | wf_typ_Packed_struct : forall (defs : list (ident * typ)) (fields : list typ), (forall (f : typ), In f fields -> sized_typ defs f) -> (forall (f : typ), In f fields -> wf_typ defs f) -> wf_typ defs (TYPE_Packed_struct fields) | wf_typ_Opaque : forall (defs : list (ident * typ)), wf_typ defs TYPE_Opaque . Hint Constructors wf_typ. Definition wf_env (env : list (ident * typ)) : Prop := NoDup (map fst env) /\ Forall (wf_typ env) (map snd env). Inductive guarded_wf_typ : list (ident * typ) -> typ -> Prop := | guarded_wf_typ_Pointer: forall (defs : list (ident * typ)) (t : typ), guarded_wf_typ defs (TYPE_Pointer t) | guarded_wf_typ_I : forall (defs : list (ident * typ)) (sz : N), (sz > 0)%N -> guarded_wf_typ defs (TYPE_I sz) | guarded_wf_typ_Void : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Void | guarded_wf_typ_Half : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Half | guarded_wf_typ_Float : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Float | guarded_wf_typ_Double : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Double | guarded_wf_typ_X86_fp80 : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_X86_fp80 | guarded_wf_typ_Fp128 : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Fp128 | guarded_wf_typ_Ppc_fp128 : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Ppc_fp128 | guarded_wf_typ_Metadata : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Metadata | guarded_wf_typ_X86_mmx : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_X86_mmx | guarded_wf_typ_Function : forall (defs : list (ident * typ)) (ret : typ) (args : list typ), function_ret_typ ret -> guarded_wf_typ defs ret -> (forall (a : typ), In a args -> sized_typ defs a) -> (forall (a : typ), In a args -> guarded_wf_typ defs a) -> guarded_wf_typ defs (TYPE_Function ret args) (* Arrays are only well formed if the size is >= 0, and the element type is sized. *) | guarded_wf_typ_Array : forall (defs : list (ident * typ)) (sz : N) (t : typ), (sz >= 0)%N -> sized_typ defs t -> guarded_wf_typ defs t -> guarded_wf_typ defs (TYPE_Array sz t) (* Vectors of size 0 are not allowed, and elemnts must be of element_typ. *) | guarded_wf_typ_Vector : forall (defs : list (ident * typ)) (sz : N) (t : typ), (sz > 0)%N -> element_typ t -> guarded_wf_typ defs t -> guarded_wf_typ defs (TYPE_Vector sz t) (* Identifier must be in the typing environment. Additionally the identifier must not occur anywhere in the type that it refers to *unless* it is guarded by a pointer. *) | guarded_wf_typ_Identified : forall (defs : list (ident * typ)) (id : ident), (exists t, In (id, t) defs) -> (forall (t : typ), In (id, t) defs -> guarded_typ id defs t) -> (forall (t : typ), In (id, t) defs -> guarded_wf_typ defs t) -> guarded_wf_typ defs (TYPE_Identified id) (* Fields of structure must be sized types *) | guarded_wf_typ_Struct : forall (defs : list (ident * typ)) (fields : list typ), (forall (f : typ), In f fields -> sized_typ defs f) -> (forall (f : typ), In f fields -> guarded_wf_typ defs f) -> guarded_wf_typ defs (TYPE_Struct fields) | guarded_wf_typ_Packed_struct : forall (defs : list (ident * typ)) (fields : list typ), (forall (f : typ), In f fields -> sized_typ defs f) -> (forall (f : typ), In f fields -> guarded_wf_typ defs f) -> guarded_wf_typ defs (TYPE_Packed_struct fields) | guarded_wf_typ_Opaque : forall (defs : list (ident * typ)), guarded_wf_typ defs TYPE_Opaque . Hint Constructors guarded_wf_typ. Theorem wf_typ_is_guarded_wf_typ : forall env t, wf_typ env t -> guarded_wf_typ env t. Proof. induction 1; auto. Qed. (* An unrolled type is an LLVM type that contains no identifiers, unless the identifier is behind a pointer. *) Inductive unrolled_typ : typ -> Prop := | unrolled_typ_I : forall (sz : N), unrolled_typ (TYPE_I sz) | unrolled_typ_Pointer : forall (t : typ), unrolled_typ (TYPE_Pointer t) | unrolled_typ_Void : unrolled_typ TYPE_Void | unrolled_typ_Half : unrolled_typ TYPE_Half | unrolled_typ_Float : unrolled_typ TYPE_Float | unrolled_typ_Double : unrolled_typ TYPE_Double | unrolled_typ_X86_fp80 : unrolled_typ TYPE_X86_fp80 | unrolled_typ_Fp128 : unrolled_typ TYPE_Fp128 | unrolled_typ_Ppc_fp128 : unrolled_typ TYPE_Ppc_fp128 | unrolled_typ_Metadata : unrolled_typ TYPE_Metadata | unrolled_typ_X86_mmx : unrolled_typ TYPE_X86_mmx | unrolled_typ_Array : forall (sz : N) (t : typ), unrolled_typ t -> unrolled_typ (TYPE_Array sz t) | unrolled_typ_Function : forall (ret : typ) (args : list typ), unrolled_typ ret -> Forall unrolled_typ args -> unrolled_typ (TYPE_Function ret args) | unrolled_typ_Struct : forall (fields : list typ), Forall (unrolled_typ) fields -> unrolled_typ (TYPE_Struct fields) | unrolled_typ_Packed_struct : forall (fields : list typ), Forall (unrolled_typ) fields -> unrolled_typ (TYPE_Packed_struct fields) | unrolled_typ_Opaque : unrolled_typ TYPE_Opaque | unrolled_typ_Vector : forall (sz : N) (t : typ), unrolled_typ (TYPE_Vector sz t) . Inductive typ_order : typ -> typ -> Prop := | typ_order_Pointer : forall (t : typ), typ_order t (TYPE_Pointer t) | typ_order_Array : forall (sz : N) (t : typ), typ_order t (TYPE_Array sz t) | typ_order_Vector : forall (sz : N) (t : typ), typ_order t (TYPE_Vector sz t) | typ_order_Struct : forall (fields : list typ), forall f, In f fields -> typ_order f (TYPE_Struct fields) | typ_order_Packed_struct : forall (fields : list typ), forall f, In f fields -> typ_order f (TYPE_Packed_struct fields) | typ_order_Function_args : forall (ret : typ) (args : list typ), forall a, In a args -> typ_order a (TYPE_Function ret args) | typ_order_Function_ret : forall (ret : typ) (args : list typ), typ_order ret (TYPE_Function ret args) . Hint Constructors typ_order. Theorem wf_typ_order : well_founded typ_order. Proof. unfold well_founded. induction a; constructor; intros y H'; inversion H'; subst; auto. Qed. Theorem wf_lt_typ_order : well_founded (lex_ord lt typ_order). Proof. apply wf_lex_ord. apply lt_wf. apply wf_typ_order. Qed. Hint Resolve wf_lt_typ_order. Hint Constructors lex_ord. Definition length_order {A : Type} (l1 l2 : list A) := (List.length l1 < List.length l2)%nat. (* Lemma lengthOrder_wf' : forall A len, forall ls, (List.length ls <= len)%nat -> Acc (@length_order A) ls. *) (* unfold length_order; induction len; *) (* intros ls H; inversion H; subst; constructor; firstorder. *) (* Defined. *) (* Theorem lengthOrder_wf : forall A, well_founded (@length_order A). *) (* red; intros A a; eapply lengthOrder_wf'; eauto. *) (* Defined. *) (* Theorem wf_length_typ_order : *) (* forall A, *) (* well_founded (lex_ord (@length_order A) typ_order). *) (* Proof. *) (* intros. *) (* apply wf_lex_ord. apply lengthOrder_wf. apply wf_typ_order. *) (* Defined. *) Lemma map_In {A B : Type} (l : list A) (f : forall (x : A), In x l -> B) : list B. Proof. induction l. - exact []. - refine (f a _ :: IHl _). + simpl. auto. + intros x H. apply (f x). simpl. auto. Defined. Fixpoint remove_key {A B : Type} (eq_dec : (forall (x y : A), {x = y} + {x <> y})) (a : A) (l : list (A * B)) : list (A * B) := match l with | nil => nil | cons (h, b) t => match eq_dec a h with | left _ => t | right _ => (h, b) :: remove_key eq_dec a t end end. Fixpoint remove_keys {A B : Type} (eq_dec : (forall (x y : A), {x = y} + {x <> y})) (keys : list A) (l : list (A * B)) : list (A * B) := match keys with | nil => l | key :: rest_of_keys => remove_keys eq_dec rest_of_keys (remove_key eq_dec key l) end. Ltac destruct_prod := match goal with | [ |- context[let (_, _) := ?p in _]] => destruct p | [ p: ?A * ?B |- _ ] => destruct p end. Ltac destruct_eq_dec := match goal with | [ eq: forall x y : ?A , {x = y} + {x <> y} |- context[eq ?a ?b] ] => destruct (eq a b) eqn:?; simpl | [ |- context[Ident.eq_dec ?a ?b] ] => destruct (Ident.eq_dec a b) eqn:?; simpl end. Lemma remove_key_in : forall (A B : Type) (a : A) (b : B) eq_dec l, In (a, b) l -> (List.length (remove_key eq_dec a l) < List.length l)%nat. Proof. induction l. - intros H. inversion H. - intros H. destruct_prod. simpl. destruct_eq_dec. + apply Nat.lt_succ_diag_r. + simpl. apply lt_n_S. apply IHl. destruct H. * inversion H. subst. contradiction. * assumption. Qed. Lemma remove_key_not_in : forall (A B : Type) (a : A) eq_dec (l : list (A * B)), ~ In a (map fst l) -> remove_key eq_dec a l = l. Proof. induction l; intros H. - reflexivity. - simpl in *. destruct_prod; destruct_eq_dec. + intuition. + rewrite IHl; intuition. Qed. Ltac solve_eq_dec_if := match goal with | [ eq: forall x y : ?A , {x = y} + {x <> y}, Heq : ?eq ?a ?b = ?c |- context[if ?eq ?a ?b then _ else _] ] => rewrite Heq | [ Heq : Ident.eq_dec ?a ?b = ?c |- context[if Ident.eq_dec ?a ?b then _ else _] ] => rewrite Heq | [ eq: forall x y : ?A , {x = y} + {x <> y}, Heq : ?eq ?a ?b = ?c |- context[if proj_sumbool (?eq ?a ?b) then _ else _] ] => rewrite Heq | [ Heq : Ident.eq_dec ?a ?b = ?c |- context[if proj_sumbool (Ident.eq_dec ?a ?b) then _ else _] ] => rewrite Heq end. Ltac subst_eq := match goal with | [ eq: forall x y : ?A , {x = y} + {x <> y}, Heq: eq ?a ?b = ?c |- _ ] => rewrite Heq | [ Heq : Ident.eq_dec ?a ?b = ?c |- _ ] => rewrite Heq end. Ltac solve_eq_dec := repeat destruct_prod; simpl in *; repeat (destruct_eq_dec; simpl in *; subst; simpl; try contra; auto; repeat (solve_eq_dec_if; simpl); auto); intuition; try congruence. Lemma remove_key_commutes : forall (A B : Type) (k1 k2 : A) eq_dec (l : list (A * B)), remove_key eq_dec k1 (remove_key eq_dec k2 l) = remove_key eq_dec k2 (remove_key eq_dec k1 l). Proof. induction l; solve_eq_dec. Qed. Lemma remove_key_keys : forall (A B : Type) (keys : list A) eq_dec (key : A) (l : list (A * B)), remove_key eq_dec key (remove_keys eq_dec keys l) = remove_keys eq_dec (key :: keys) l. Proof. intros A B keys. induction keys as [| k keys' IHkeys]; intros eq_dec key l; auto. simpl in *. rewrite IHkeys. apply f_equal; apply remove_key_commutes. Qed. Lemma remove_keys_key : forall (A B : Type) (keys : list A) eq_dec (key : A) (l : list (A * B)), remove_keys eq_dec keys (remove_key eq_dec key l) = remove_keys eq_dec (key :: keys) l. Proof. intros A B keys. induction keys; intros eq_dec key l; auto. Qed. Program Fixpoint normalize_type (env : list (ident * typ)) (t : typ) {measure (List.length env, t) (lex_ord lt typ_order)} : typ := match t with | TYPE_Array sz t => let nt := normalize_type env t in TYPE_Array sz nt | TYPE_Function ret args => let nret := (normalize_type env ret) in let nargs := map_In args (fun t _ => normalize_type env t) in TYPE_Function nret nargs | TYPE_Struct fields => let nfields := map_In fields (fun t _ => normalize_type env t) in TYPE_Struct nfields | TYPE_Packed_struct fields => let nfields := map_In fields (fun t _ => normalize_type env t) in TYPE_Packed_struct nfields | TYPE_Vector sz t => let nt := normalize_type env t in TYPE_Vector sz nt | TYPE_Identified id => match find (fun a => Ident.eq_dec id (fst a)) env with | None => TYPE_Identified id | Some (_, t) => normalize_type (remove_key Ident.eq_dec id env) t end | TYPE_I sz => t | TYPE_Pointer t' => t | TYPE_Void => t | TYPE_Half => t | TYPE_Float => t | TYPE_Double => t | TYPE_X86_fp80 => t | TYPE_Fp128 => t | TYPE_Ppc_fp128 => t | TYPE_Metadata => t | TYPE_X86_mmx => t | TYPE_Opaque => t end. Next Obligation. left. symmetry in Heq_anonymous. apply find_some in Heq_anonymous. destruct Heq_anonymous as [Hin Heqb_ident]. simpl in Heqb_ident. destruct (Ident.eq_dec id wildcard'). subst. eapply remove_key_in. apply Hin. inversion Heqb_ident. Defined. Lemma normalize_type_equation : forall env t, normalize_type env t = match t with | TYPE_Array sz t => let nt := normalize_type env t in TYPE_Array sz nt | TYPE_Function ret args => let nret := (normalize_type env ret) in let nargs := map_In args (fun t _ => normalize_type env t) in TYPE_Function nret nargs | TYPE_Struct fields => let nfields := map_In fields (fun t _ => normalize_type env t) in TYPE_Struct nfields | TYPE_Packed_struct fields => let nfields := map_In fields (fun t _ => normalize_type env t) in TYPE_Packed_struct nfields | TYPE_Vector sz t => let nt := normalize_type env t in TYPE_Vector sz nt | TYPE_Identified id => let opt := find (fun a => Ident.eq_dec id (fst a)) env in match opt with | None => TYPE_Identified id (* TODO: should this be None? *) | Some (_, t) => normalize_type (remove_key Ident.eq_dec id env) t end | TYPE_I sz => TYPE_I sz | TYPE_Pointer t' => TYPE_Pointer t' | TYPE_Void => TYPE_Void | TYPE_Half => TYPE_Half | TYPE_Float => TYPE_Float | TYPE_Double => TYPE_Double | TYPE_X86_fp80 => TYPE_X86_fp80 | TYPE_Fp128 => TYPE_Fp128 | TYPE_Ppc_fp128 => TYPE_Ppc_fp128 | TYPE_Metadata => TYPE_Metadata | TYPE_X86_mmx => TYPE_X86_mmx | TYPE_Opaque => TYPE_Opaque end. Proof. intros env t. unfold normalize_type. unfold normalize_type_func at 1. rewrite Wf.WfExtensionality.fix_sub_eq_ext. destruct t; try reflexivity. simpl. destruct (find (fun a : ident * typ => Ident.eq_dec id (fst a)) env). destruct p; simpl; eauto. reflexivity. Defined. Hint Constructors unrolled_typ. Lemma find_in_wf_env : forall env id t, NoDup (map fst env) -> In (id, t) env -> find (fun a : ident * typ => Ident.eq_dec id (fst a)) env = Some (id, t). Proof. intros env id t Hdup Hin. induction env as [| [id' t'] env IHenv]. - contradiction. - destruct Hin as [Hin | Hin]; try inversion Hin; subst. + simpl. destruct_eq_dec; intuition. + simpl. destruct_eq_dec. * inversion Hdup. subst. apply in_map with (f:=fst) in Hin. simpl in *. contradiction. * simpl. inversion Hdup. auto. Qed. Lemma guarded_typ_id_same : forall env id, guarded_typ id env (TYPE_Identified id) -> False. Proof. intros env id H. inversion H; contradiction. Qed. Lemma find_different_key_from_removed : forall env id id', id <> id' -> find (fun a : ident * typ => Ident.eq_dec id' (fst a)) env = find (fun a : ident * typ => Ident.eq_dec id' (fst a)) (remove_key Ident.eq_dec id env). Proof. intros env id id' H. induction env; solve_eq_dec. Qed. Lemma remove_keys_find : forall env id ids, ~ In id ids -> find (fun a : ident * typ => Ident.eq_dec id (fst a)) env = find (fun a : ident * typ => Ident.eq_dec id (fst a)) (remove_keys Ident.eq_dec ids env). Proof. intros env id ids H. induction ids. - reflexivity. - rewrite <- remove_key_keys. rewrite <- find_different_key_from_removed with (id:=a); intuition; subst; intuition. Qed. Ltac solve_some := match goal with | [ H: (?i1, ?t1) = (?i2, ?t2) |- ?F (?i1, ?t1) = ?F (?i2, ?t2) ] => inversion H; reflexivity | [ Hdup : NoDup (?i :: map fst ?env), Hin : In (?i, ?t) ?env |- ?F (?i, ?t1) = ?F (?i, ?t2) ] => let Hnin := fresh in let Hdup' := fresh in inversion Hdup as [| ? ? Hnin Hdup']; subst; exfalso; apply Hnin; replace i with (fst (i, t)) by reflexivity; apply in_map; auto | [ Hin : In (?i, ?t1) ((?i, ?t2) :: ?env) |- ?F (?i, ?t1) = ?F (?i, ?t2) ] => symmetry; solve_some | [ Hin : In (?i, ?t2) ((?i, ?t1) :: ?env) |- ?F (?i, ?t1) = ?F (?i, ?t2) ] => inversion Hin; solve_some end. Ltac solve_in := match goal with | [ Hin: In (?id, ?t) ((?i, ?t0) :: ?env), Hneq: ?id <> ?i |- In (?id, ?t) ?env ] => let Htup := fresh in inversion Hin as [Htup | ?]; [> inversion Htup; contra | auto] | [ H: find (fun a => (proj_sumbool (?eq ?id (fst a)))) ?env = Some (?i, ?t) |- In (?id, ?t) ?env ] => let Hfind := fresh in apply find_some in H as [? Hfind]; simpl in Hfind; destruct (Ident.eq_dec id i) eqn:?; subst; intuition end. Lemma find_some_id : forall env id p t, NoDup (map fst env) -> In (id, t) env -> find (fun a : ident * typ => Ident.eq_dec id (fst a)) env = Some p -> find (fun a : ident * typ => Ident.eq_dec id (fst a)) env = Some (id, t). Proof. intros env id p t Hdup Hin H. induction env. - inversion H. - destruct a. simpl. destruct_eq_dec. + subst. simpl in Hdup. solve_some. + simpl. apply IHenv. * inversion Hdup; auto. * solve_in. * simpl in *. rewrite Heqs in H. simpl in *. assumption. Qed. Hint Constructors sized_typ. Hint Constructors guarded_typ. (* Types with no identifiers *) Inductive simple_typ : typ -> Prop := | simple_typ_I : forall sz, simple_typ (TYPE_I sz) | simple_typ_Pointer : forall t, simple_typ t -> simple_typ (TYPE_Pointer t) | simple_typ_Void : simple_typ (TYPE_Void) | simple_typ_Half : simple_typ (TYPE_Half) | simple_typ_Float : simple_typ (TYPE_Float) | simple_typ_Double : simple_typ (TYPE_Double) | simple_typ_X86_fp80 : simple_typ (TYPE_X86_fp80) | simple_typ_Fp128 : simple_typ (TYPE_Fp128) | simple_typ_Ppc_fp128 : simple_typ (TYPE_Ppc_fp128) | simple_typ_Metadata : simple_typ (TYPE_Metadata) | simple_typ_X86_mmx : simple_typ (TYPE_X86_mmx) | simple_typ_Array : forall sz t, simple_typ t -> simple_typ (TYPE_Array sz t) | simple_typ_Function : forall ret args, simple_typ ret -> (forall a, In a args -> simple_typ a) -> simple_typ (TYPE_Function ret args) | simple_typ_Struct : forall fields, (forall f, In f fields -> simple_typ f) -> simple_typ (TYPE_Struct fields) | simple_typ_Packed_struct : forall fields, (forall f, In f fields -> simple_typ f) -> simple_typ (TYPE_Packed_struct fields) | simple_typ_Opaque : simple_typ (TYPE_Opaque) | simple_typ_Vector : forall sz t, simple_typ t -> simple_typ (TYPE_Vector sz t) . Hint Constructors simple_typ. Theorem map_in_id : forall {A : Type} (l : list A) (f : forall x : A, In x l -> A), (forall a (Hin : In a l), f a Hin = a) -> map_In l f = l. Proof. intros A l f H. induction l; auto. simpl. rewrite H. rewrite IHl; auto. Qed. Theorem simple_normalizes_to_self : forall env t, simple_typ t -> normalize_type env t = t. Proof. intros env t H. induction H; rewrite normalize_type_equation; simpl; repeat match goal with | [H : normalize_type env _ = _ |- context[normalize_type _ _]] => rewrite H | [|- context[(map_In _ (fun (t : typ) (_ : In t _) => normalize_type env t))]] => rewrite map_in_id; auto end; auto. Qed. Theorem simple_unrolled : forall t, simple_typ t -> unrolled_typ t. Proof. intros t H. induction H; constructor; try match goal with | [|- Forall _ _] => apply Forall_forall end; auto. Qed. Theorem in_map_in : forall {A : Type} (x : A) (l : list A) f, In x (map_In l (fun t (_ : In t l) => f t)) -> exists t, In t l /\ f t = x. Proof. intros A x l f H. induction l. - inversion H. - simpl in *. destruct H. + exists a. split; auto. + apply IHl in H as [t [Hin Hftx]]. exists t. intuition. Qed. Theorem map_rewrite : forall {A B : Type} (x : A) (l : list A) (f g : A -> B), (forall x, In x l -> f x = g x) -> map_In l (fun t (_ : In t l) => f t) = map_In l (fun t (_ : In t l) => g t). Proof. intros A B x l f g H. induction l as [| a l IHl]; simpl; auto. pose proof (H a) as Ha. rewrite Ha; intuition. rewrite IHl; intuition. Qed. Ltac simpl_remove_keys := match goal with | [ |- context[remove_key ?eq ?id (remove_keys ?eq ?ids ?assoc_list)] ] => replace (remove_key eq id (remove_keys eq ids assoc_list)) with (remove_keys eq (id :: ids) assoc_list) by auto using remove_key_keys | [ |- context[remove_keys ?eq ?ids (remove_key ?eq ?id ?assoc_list)] ] => replace (remove_keys eq ids (remove_key eq id assoc_list)) with (remove_keys eq (id :: ids) assoc_list) by auto using remove_keys_key | [ |- context[remove_key ?eq ?id ?assoc_list] ] => replace (remove_key eq id assoc_list) with (remove_keys eq [id] assoc_list) by auto end. Ltac subst_find_some := match goal with | [ H1: ?F ?filter ?defs = ?G (?i1, ?t1), H2: ?X = ?F ?filter ?defs |- _ ] => rewrite H1 in H2; inversion H2 end. Ltac solve_guard := match goal with | [ H: element_typ ?x |- guarded_typ ?id ?defs ?x ] => match goal with | [H : element_typ _ |- _] => inversion H end; auto | [ Hguard: forall i, In i ?ids -> guarded_typ i ?env ?t |- ~(In ?id ?ids) ] => let Hguard' := fresh in let Hin := fresh in unfold not; intros Hin; pose proof Hguard id Hin as Hguard'; inversion Hguard'; auto | [ Hguard: forall t, In (?i, t) ?defs -> guarded_typ ?i ?defs t, Hin: In ?id [?i] |- _ ] => intros; inversion Hin; subst; try contradiction; auto | [ Hguard: forall i, In ?id [i] -> guarded_typ ?i ?env ?t |- ~(In ?id ?ids) ] => let Hguard' := fresh in let Hin := fresh in unfold not; intros Hin; pose proof Hguard id Hin as Hguard'; inversion Hguard'; subst; try contra; auto | [ Hguard: forall i, In i ?ids -> guarded_typ i ?env ?t, Hin: In ?id [?one] |- guarded_typ ?id ?defs ?x ] => inversion Hin; subst; auto; contra | [ Hguard: forall i, In i ?ids -> guarded_typ i ?env ?t, Hin: In ?id ?ids |- guarded_typ ?id ?defs ?x ] => let Hguard' := fresh in pose proof Hguard _ Hin as Hguard'; inversion Hguard'; auto; subst; subst_find_some; subst; auto | [ |- forall id, In id ?ids -> guarded_typ id ?defs ?x ] => intros; solve_guard end. Theorem guarded_id_normalize_same : forall t env, NoDup (map fst env) -> guarded_wf_typ env t -> (forall ids, (forall id, In id ids -> guarded_typ id env t) -> normalize_type (remove_keys Ident.eq_dec ids env) t = normalize_type env t). Proof. intros t env Hdup Hwf. induction Hwf; intros ids Hguard; rewrite normalize_type_equation; symmetry; rewrite normalize_type_equation; simpl; auto; try rewrite IHHwf; auto; try match goal with | [H : element_typ _ |- _] => inversion H end; try (rewrite map_rewrite with (f:=normalize_type (remove_keys _ _ _)) (g:=normalize_type defs); try exact (TYPE_Void); auto; intros; match goal with | [ H: _ |- _ ] => apply H end; auto); try (intros id Hidin; solve_guard). (* Identifiers *) repeat simpl_remove_keys. (* If id is in ids, this means that guarded_typ id defs (TYPE_Identified id), which is a contradiction. *) assert (~ In id ids) as Hnotin by solve_guard. replace (find (fun a : ident * typ => Ident.eq_dec id (fst a)) (remove_keys Ident.eq_dec ids defs)) with (find (fun a : ident * typ => Ident.eq_dec id (fst a)) defs) by (auto using remove_keys_find). destruct (find (fun a : ident * typ => Ident.eq_dec id (fst a)) defs) eqn:Hfind; auto. destruct_prod. simpl. assert (In (id, t) defs). apply find_some in Hfind as [Hin Hfind]. simpl in Hfind. destruct (Ident.eq_dec id i) eqn:Hidi; subst; intuition. repeat (simpl_remove_keys; repeat match goal with | [ H: _ |- _ ] => rewrite H end; auto); intros id0 [Hidid0 | Hin']; subst; auto. - inversion Hin'. - pose proof (Hguard id0 Hin') as Hguard'. inversion Hguard'; subst_find_some; subst; auto. Qed. Theorem double_map_In : forall A B C (l : list A) (f : A -> B) (g : B -> C), (map_In (map_In l (fun x (_ : In x l) => f x)) (fun x (_ : In x (map_In l (fun x (_ : In x l) => f x))) => g x)) = map_In l (fun x (_ : In x l) => g (f x)). Proof. intros A B C l f g. induction l; simpl; auto using f_equal. Qed. Ltac solve_map_in := repeat match goal with | [ |- context[map_In (map_In _ _)] ] => rewrite double_map_In | [ defs : list (ident * typ) |- _ ] => try (rewrite map_rewrite with (f:=fun x => normalize_type defs (normalize_type defs x)) (g:=normalize_type defs); [> eauto | exact TYPE_Void | eauto]); try solve [intros; match goal with | [ H: _ |- _ ] => apply H end; auto; solve_guard] end. Ltac solve_match_find := match goal with | [ |- context[match ?Find with _ => _ end = _] ] => let i := fresh in let t := fresh in let Hfind := fresh in destruct Find as [[i t] |] eqn:Hfind; match goal with | [ Hf: context[find (fun a => proj_sumbool (?eq ?id (fst a))) ?defs], defs : list (ident * typ) |- _ ] => try (assert (In (id, t) defs) by solve_in; symmetry; simpl_remove_keys; rewrite guarded_id_normalize_same; auto using wf_typ_is_guarded_wf_typ; try solve_guard; try (match goal with | [ H: _ |- _ ] => apply H end; auto; solve_guard)); try (rewrite normalize_type_equation; simpl; rewrite Hfind; reflexivity) end end. Theorem guarded_normalize_same : forall t env, NoDup (map fst env) -> guarded_wf_typ env t -> (forall ids, (forall id, In id ids -> guarded_typ id env t) -> normalize_type env (normalize_type env t) = normalize_type env t). Proof. intros t env Hdup Hwf ids Hguard_all. induction Hwf; try solve [rewrite normalize_type_equation; symmetry; rewrite normalize_type_equation; simpl; auto; try rewrite IHHwf; auto; try solve_guard; solve_map_in]. symmetry; rewrite normalize_type_equation; simpl. solve_match_find. Qed. Lemma wf_typ_guarded_normalize_twice : forall env t, NoDup (map fst env) -> wf_typ env t -> (forall ids, (forall id, In id ids -> guarded_typ id env t) -> normalize_type env (normalize_type env t) = normalize_type env t). Proof. eauto using wf_typ_is_guarded_wf_typ, guarded_normalize_same. Qed. Theorem double_normalize_type : forall env t, wf_env env -> wf_typ env t -> normalize_type env (normalize_type env t) = normalize_type env t. Proof. intros env t [Hdup Henv] Hwf. induction Hwf; try solve [rewrite normalize_type_equation; symmetry; rewrite normalize_type_equation; simpl; auto; try rewrite IHHwf; auto; try solve_guard; solve_map_in]. symmetry; rewrite normalize_type_equation; simpl. solve_match_find. Qed. Theorem guarded_normalize_type_unrolls: forall env t, NoDup (map fst env) -> guarded_wf_typ env t -> (forall ids, (forall id, In id ids -> guarded_typ id env t) -> unrolled_typ (normalize_type env t)). Proof. intros env t Hdup Hwf ids Hguard_all. induction Hwf; rewrite normalize_type_equation; simpl; auto; try constructor; try (apply IHHwf; auto; solve_guard); try (rewrite Forall_forall; intros; match goal with | [ H: In ?x (map_In _ _) |- _ ] => apply in_map_in in H as [t [Hin Hnorm]] end; rewrite <- Hnorm; match goal with | [ H: _ |- _ ] => apply H end; auto; solve_guard). - destruct (find (fun a : ident * typ => Ident.eq_dec id (fst a)) defs) as [[i t] |] eqn:Hfind. + pose proof Hfind as Hfind'. apply find_some in Hfind' as [Hin Heq]. simpl in *. destruct (Ident.eq_dec id i) as [He | He]; inversion Heq. rewrite He. simpl_remove_keys. rewrite guarded_id_normalize_same; auto; try match goal with | [ H: _ |- _ ] => apply H end; subst; auto; solve_guard. + destruct H as [t Hin]. eapply find_none in Hfind; eauto. simpl in Hfind. destruct (Ident.eq_dec id id). inversion Hfind. contradiction. Qed. Theorem normalize_type_unrolls: forall env t, wf_env env -> wf_typ env t -> unrolled_typ (normalize_type env t). Proof. intros env t [Hdup Henv] Hwf. induction Hwf; rewrite normalize_type_equation; simpl; auto; try constructor; try (apply IHHwf; auto); try (rewrite Forall_forall; intros; match goal with | [ H: In ?x (map_In _ _) |- _ ] => apply in_map_in in H as [t [Hin Hnorm]] end; rewrite <- Hnorm; match goal with | [ H: _ |- _ ] => apply H end; auto; solve_guard). - destruct (find (fun a : ident * typ => Ident.eq_dec id (fst a)) defs) as [[i t] |] eqn:Hfind. + apply find_some in Hfind as [Hin Heq]. simpl in *. destruct (Ident.eq_dec id i); inversion Heq; subst. simpl_remove_keys. rewrite guarded_id_normalize_same; auto using wf_typ_is_guarded_wf_typ; solve_guard. + destruct H as [t Hin]. eapply find_none in Hfind; eauto. simpl in Hfind. destruct (Ident.eq_dec id id). inversion Hfind. contradiction. Qed.
State Before: R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p✝ q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f p : MvPolynomial σ S₁ ⊢ ∃ a, ↑(map f) a = p State After: case h1 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f i : σ →₀ ℕ fr : S₁ ⊢ ∃ a, ↑(map f) a = ↑(monomial i) fr case h2 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a✝ a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f a b : MvPolynomial σ S₁ ha : ∃ a_1, ↑(map f) a_1 = a hb : ∃ a, ↑(map f) a = b ⊢ ∃ a_1, ↑(map f) a_1 = a + b Tactic: induction' p using MvPolynomial.induction_on' with i fr a b ha hb State Before: case h1 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f i : σ →₀ ℕ fr : S₁ ⊢ ∃ a, ↑(map f) a = ↑(monomial i) fr State After: case h1.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f i : σ →₀ ℕ r : R ⊢ ∃ a, ↑(map f) a = ↑(monomial i) (↑f r) Tactic: obtain ⟨r, rfl⟩ := hf fr State Before: case h1.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f i : σ →₀ ℕ r : R ⊢ ∃ a, ↑(map f) a = ↑(monomial i) (↑f r) State After: no goals Tactic: exact ⟨monomial i r, map_monomial _ _ _⟩ State Before: case h2 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a✝ a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f a b : MvPolynomial σ S₁ ha : ∃ a_1, ↑(map f) a_1 = a hb : ∃ a, ↑(map f) a = b ⊢ ∃ a_1, ↑(map f) a_1 = a + b State After: case h2.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a✝ a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f b : MvPolynomial σ S₁ hb : ∃ a, ↑(map f) a = b a : MvPolynomial σ R ⊢ ∃ a_1, ↑(map f) a_1 = ↑(map f) a + b Tactic: obtain ⟨a, rfl⟩ := ha State Before: case h2.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a✝ a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f b : MvPolynomial σ S₁ hb : ∃ a, ↑(map f) a = b a : MvPolynomial σ R ⊢ ∃ a_1, ↑(map f) a_1 = ↑(map f) a + b State After: case h2.intro.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a✝ a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f a b : MvPolynomial σ R ⊢ ∃ a_1, ↑(map f) a_1 = ↑(map f) a + ↑(map f) b Tactic: obtain ⟨b, rfl⟩ := hb State Before: case h2.intro.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a✝ a' a₁ a₂ : R e : ℕ n m : σ s : σ →₀ ℕ inst✝¹ : CommSemiring R inst✝ : CommSemiring S₁ p q : MvPolynomial σ R f : R →+* S₁ hf : Surjective ↑f a b : MvPolynomial σ R ⊢ ∃ a_1, ↑(map f) a_1 = ↑(map f) a + ↑(map f) b State After: no goals Tactic: exact ⟨a + b, RingHom.map_add _ _ _⟩
Poor girl mist be so confused , going into a new home then the puppies coming . I hope she settles down and is able to relax . Me too Missi...she has to be scared and has only been with Abby and Eric a few weeks...I feel so bad for her. Poor girl. I hope that she calms down and is able to care for the pups and accept the help that she will need so much from her foster parents. Heck, I get testy after having just one baby! Can't imagine having 7 and nobody in the room that you really know & trust. I feel so sorry for her. I swear I can't stand the cuteness!!! Tee hee, Deb's getting a puppy and Joker is getting that brother he's been wanting. I have no idea why you keep posting that...YOU DO NEED A PUPPY...Jaimie & Joker need a baby brudda!!! See this is why you didn't adopt Smoke a while back .... Joker's twin was waiting to be made just for you! Help me think of a really cool name, OK?
%% GSA_GetSy: calculate the Sobol' sensitivity indices % % Usage: % [S eS pro] = GSA_GetSy(pro, iset, verbose) % % Inputs: % pro project structure % iset cell array or array of inputs of the considered set, they can be selected % by index (1,2,3 ...) or by name ('in1','x',..) or % mixed % verbose if not empty, it shows the time (in hours) for % finishing % % Output: % S sensitivity coefficient % eS error of sensitivity coefficient % pro project structure % % ------------------------------------------------------------------------ % See also % % Author : Flavio Cannavo' % e-mail: flavio(dot)cannavo(at)gmail(dot)com % Release: 1.0 % Date : 15-02-2011 % % History: % 1.0 15-04-2011 Added verbose parameter % 1.0 15-01-2011 First release. %% function [S eS pro] = GSA_GetSy(pro, iset, verbose) if ~exist('verbose','var') verbose = 0; else verbose = ~isempty(verbose) && verbose; end index = fnc_SelectInput(pro, iset); if isempty(index) S = 0; eS = 0; else S = 0; eS = 0; n = length(index); L = 2^n; if verbose tic end for i=1:(L-1) ii = fnc_GetInputs(i); si = fnc_GetIndex(index(ii)); if isnan(pro.GSA.GSI(si)) %------- if isnan(pro.GSA.Di(si)) ixi = fnc_GetInputs(si); s = length(ixi); l = 2^s - 1; %====== if isnan(pro.GSA.Dmi(si)) n = length(pro.Inputs.pdfs); N = size(pro.SampleSets.E,1); H = pro.SampleSets.E(:,:); cii = fnc_GetComplementayInputs(si, n); H(:,cii) = pro.SampleSets.T(:,cii); ff = nan(N,1); for j=1:N ff(j) = pro.GSA.fE(j)*(pro.Model.handle(H(j,:))-pro.GSA.mfE); end pro.GSA.Dmi(si) = nanmean(ff); pro.GSA.eDmi(si) = 0.6745*sqrt((nanmean(ff.^2) - pro.GSA.Dmi(si)^2)/sum(~isnan(ff))); end %======= Di = pro.GSA.Dmi(si); eDi = pro.GSA.eDmi(si)^2; for j=1:(l-1) sii = fnc_GetInputs(j); k = fnc_GetIndex(ixi(sii)); s_r = s - length(sii); Di = Di + pro.GSA.Dmi(k)*((-1)^s_r); eDi = eDi + pro.GSA.eDmi(k)^2; end pro.GSA.Di(si) = Di + (pro.GSA.f0^2)*((-1)^s); pro.GSA.eDi(si) = sqrt(eDi + 2*(pro.GSA.ef0^2)); end %------ pro.GSA.GSI(si) = pro.GSA.Di(si)/pro.GSA.D; pro.GSA.eGSI(si) = pro.GSA.GSI(si)*pro.GSA.eDi(si)/pro.GSA.D; end S = S + pro.GSA.GSI(si); eS = eS + pro.GSA.eGSI(si); if verbose timelapse = toc; disp(timelapse*(L-1-i)/i/60/60); end end end
module Size public export record Size where constructor CreateSize src : String width : Integer height : Integer type : String
> module Opt.Operations > import Control.Isomorphism > import Data.Fin > import Data.Vect > import Syntax.PreorderReasoning > import Finite.Predicates > import Finite.Operations > import Finite.Properties > import Rel.TotalPreorder > import Rel.TotalPreorderOperations > import Vect.Operations > import Vect.Properties > import Fun.Operations > import Nat.LTProperties > %default total > %access public export > ||| > argmaxMax : {A, B : Type} -> {R : B -> B -> Type} -> > TotalPreorder R -> > (fA : Finite A) -> > (ne : CardNotZ fA) -> > (f : A -> B) -> (A, B) > argmaxMax {A} {B} tp fA nefA f = max (extendLeftLemma tp) abs ltZn where > n : Nat > n = card fA > ltZn : LT Z n > ltZn = notZisgtZ nefA > abs : Vect n (A,B) > abs = map (pair (id, f)) (toVect fA) > ||| > max : {A, B : Type} -> {R : B -> B -> Type} -> > TotalPreorder R -> > (fA : Finite A) -> > (ne : CardNotZ fA) -> > (f : A -> B) -> B > max tp fA nefA f = snd (argmaxMax tp fA nefA f) > ||| > argmax : {A, B : Type} -> {R : B -> B -> Type} -> > TotalPreorder R -> > (fA : Finite A) -> > (ne : CardNotZ fA) -> > (f : A -> B) -> A > argmax tp fA nefA f = fst (argmaxMax tp fA nefA f) > ||| > maxSpec : {A, B : Type} -> {R : B -> B -> Type} -> > (tp : TotalPreorder R) -> > (fA : Finite A) -> > (nefA : CardNotZ fA) -> > (f : A -> B) -> > (a : A) -> R (f a) (max tp fA nefA f) > maxSpec {A} {B} {R} tp fA nefA f a = s4 where > n : Nat > n = card fA > ltZn : LT Z n > ltZn = notZisgtZ nefA > abs : Vect n (A,B) > abs = map (pair (id, f)) (toVect fA) > s1 : Elem (a, f a) abs > s1 = mapLemma (toVect fA) (pair (id, f)) a (toVectComplete fA a) > s2 : (extendLeft R) (a, f a) (max (extendLeftLemma tp) abs ltZn) > s2 = maxLemma (extendLeftLemma tp) (a, f a) abs ltZn s1 > s3 : R (f a) (snd (max (extendLeftLemma tp) abs ltZn)) > s3 = s2 > s4 : R (f a) (max tp fA nefA f) > s4 = s3 > ||| > argmaxSpec : {A, B : Type} -> {R : B -> B -> Type} -> > (tp : TotalPreorder R) -> > (fA : Finite A) -> > (nefA : CardNotZ fA) -> > (f : A -> B) -> > (max tp fA nefA f) = f (argmax tp fA nefA f) > argmaxSpec {A} {B} tp fA nefA f = s3 where > ab : (A,B) > ab = argmaxMax tp fA nefA f > s1 : Elem ab (map (pair (Prelude.Basics.id, f)) (toVect fA)) > s1 = maxElemLemma (extendLeftLemma tp) (map (pair (id, f)) (toVect fA)) (notZisgtZ nefA) > s2 : f (fst ab) = snd ab > s2 = mapIdfLemma (toVect fA) f ab s1 > s3 : max tp fA nefA f = f (argmax tp fA nefA f) > s3 = sym s2 > {- > argmaxMax : {A, B : Type} -> > TotalPreorder B -> > (fA : Finite A) -> > (ne : CardNotZ fA) -> > (f : A -> B) -> (A, B) > argmaxMax {A} {B} tp fA nefA f = max (fromTotalPreorder2 tp) abs ltZn where > n : Nat > n = card fA > ltZn : LT Z n > ltZn = notZisgtZ nefA > abs : Vect n (A,B) > abs = map (pair (id, f)) (toVect fA) > max : {A, B : Type} -> > TotalPreorder B -> > (fA : Finite A) -> > (ne : CardNotZ fA) -> > (f : A -> B) -> B > max tp fA nefA f = snd (argmaxMax tp fA nefA f) > argmax : {A, B : Type} -> > TotalPreorder B -> > (fA : Finite A) -> > (ne : CardNotZ fA) -> > (f : A -> B) -> A > argmax tp fA nefA f = fst (argmaxMax tp fA nefA f) > maxSpec : {A, B : Type} -> > (tp : TotalPreorder B) -> > (fA : Finite A) -> > (nefA : CardNotZ fA) -> > (f : A -> B) -> > (a : A) -> R tp (f a) (max tp fA nefA f) > maxSpec {A} {B} tp fA nefA f a = s4 where > n : Nat > n = card fA > ltZn : LT Z n > ltZn = notZisgtZ nefA > abs : Vect n (A,B) > abs = map (pair (id, f)) (toVect fA) > s1 : Elem (a, f a) abs > s1 = mapLemma (toVect fA) (pair (id, f)) a (toVectComplete fA a) > s2 : (from2 (R tp)) (a, f a) (max (fromTotalPreorder2 tp) abs ltZn) > s2 = maxLemma (fromTotalPreorder2 tp) (a, f a) abs ltZn s1 > s3 : R tp (f a) (snd (max (fromTotalPreorder2 tp) abs ltZn)) > s3 = s2 > s4 : R tp (f a) (max tp fA nefA f) > s4 = s3 > argmaxSpec : {A, B : Type} -> > (tp : TotalPreorder B) -> > (fA : Finite A) -> > (nefA : CardNotZ fA) -> > (f : A -> B) -> > (max tp fA nefA f) = f (argmax tp fA nefA f) > argmaxSpec {A} {B} tp fA nefA f = s3 where > ab : (A,B) > ab = argmaxMax tp fA nefA f > s1 : Elem ab (map (pair (Prelude.Basics.id, f)) (toVect fA)) > s1 = maxElemLemma (fromTotalPreorder2 tp) (map (pair (id, f)) (toVect fA)) (notZisgtZ nefA) > s2 : f (fst ab) = snd ab > s2 = mapIdfLemma (toVect fA) f ab s1 > s3 : max tp fA nefA f = f (argmax tp fA nefA f) > s3 = sym s2 > {- > argmaxMax : {A, B : Type} -> {TO : B -> B -> Type} -> > Preordered B TO => > (fA : Finite A) -> (ne : CardNotZ fA) -> > (f : A -> B) -> (A,B) > argmaxMax {A} {B} {TO} fA nefA f = > VectOperations.max {A = (A,B)} {TO = sndType TO} abs ltZn where > n : Nat > n = card fA > ltZn : LT Z n > ltZn = notZisgtZ nefA > abs : Vect n (A,B) > abs = map (pair (id, f)) (toVect fA) > max : {A, B : Type} -> {TO : B -> B -> Type} -> > Preordered B TO => > (fA : Finite A) -> (ne : CardNotZ fA) -> > (f : A -> B) -> B > max fA nefA f = snd (argmaxMax fA nefA f) > argmax : {A, B : Type} -> {TO : B -> B -> Type} -> > Preordered B TO => > (fA : Finite A) -> (ne : CardNotZ fA) -> > (f : A -> B) -> A > argmax fA nefA f = fst (argmaxMax fA nefA f) > maxSpec : {A, B : Type} -> {TO : B -> B -> Type} -> > Preordered B TO => > (fA : Finite A) -> (nefA : CardNotZ fA) -> > (f : A -> B) -> > (a : A) -> TO (f a) (max fA nefA f) > maxSpec {A} {B} {TO} fA nefA f a = s4 where > n : Nat > n = card fA > ltZn : LT Z n > ltZn = notZisgtZ nefA > abs : Vect n (A,B) > abs = map (pair (id, f)) (toVect fA) > s1 : Elem (a, f a) abs > s1 = mapLemma (toVect fA) (pair (id, f)) a (toVectComplete fA a) > s2 : (sndType TO) (a, f a) (max abs ltZn) > s2 = maxLemma (a, f a) abs ltZn s1 > s3 : TO (f a) (snd (max abs ltZn)) > s3 = s2 > s4 : TO (f a) (max fA nefA f) > s4 = s3 > argmaxSpec : {A, B : Type} -> {TO : B -> B -> Type} -> > Preordered B TO => > (fA : Finite A) -> (nefA : CardNotZ fA) -> > (f : A -> B) -> > (max fA nefA f) = f (argmax fA nefA f) > argmaxSpec {A} {B} fA nefA f = s3 where > ab : (A,B) > ab = argmaxMax fA nefA f > s1 : Elem ab (map (pair (id, f)) (toVect fA)) > s1 = maxElemLemma (map (pair (id, f)) (toVect fA)) (notZisgtZ nefA) > s2 : f (fst ab) = snd ab > s2 = mapIdfLemma (toVect fA) f ab s1 > s3 : max fA nefA f = f (argmax fA nefA f) > s3 = sym s2 > -} > ---}
import tag006T -- sheaves of types import tag006N -- presheaves of rings -- this should really be done for abstract categories; we "cheat" here because -- equalizers in the category of commutative rings are the same as equalizers -- in the underlying category of sets: see tag0073 (lemma 6.9.2) def is_sheaf_of_rings {α : Type*} [T : topological_space α] (PR : presheaf_of_rings α) : Prop := is_sheaf_of_types PR.to_presheaf_of_types
Meet the fighters post event to see who take homes fight of the night bonuses. Special drink discounts starting at just 100baht, free entry, and FMD style good times. Chat with the Ring Girls, chill by the pool, lounge on the astroturfed roof top and enjoy a classic mix of music from all genres.
module BigStep -- Relation 'BigStep' for fully reducing terms -- in the simply-typed lambda calculus to values. import Term import Subst %default total %access public export ----------------------------------------------------------------------- -- Begin: BIG-STEP EVALUATION RELATION FOR TERMS IN THE LAMBDA CALCULUS -- The relation 'BigStep' defines evaluation of terms in the lambda -- calculus following big-step semantics. -- -- Big-step semantics fully evaluates terms to values. -- (A proof of this statement appears below.) data BigStep : Term [] t -> (y: Term [] t) -> Type where BStValue : (v : Value e) -> BigStep e e -- BStApp : BigStep e1 (TAbs e1') -> BigStep e2 e2' -> BigStep (subst e2' FZ e1') e -> BigStep (TApp e1 e2) e -- BStFix : BigStep e (TAbs e') -> BigStep (subst (TFix (TAbs e')) FZ e') e'' -> BigStep (TFix e) e'' -- BStSucc : BigStep e e' -> BigStep (TSucc e) (TSucc e') -- BStPredZero : BigStep e TZero -> BigStep (TPred e) TZero -- BStPredSucc : BigStep e (TSucc e') -> BigStep (TPred e) e' -- BStIfzZero : BigStep e1 TZero -> BigStep e2 e -> BigStep (TIfz e1 e2 _) e -- BStIfzSucc : BigStep e1 (TSucc _) -> BigStep e3 e -> BigStep (TIfz e1 _ e3) e bigStepFst : {e : Term [] t} -> BigStep e _ -> Term [] t bigStepFst {e = e} _ = e bigStepSnd : {e : Term [] t} -> BigStep _ e -> Term [] t bigStepSnd {e = e} _ = e bigStepValue : BigStep _ e -> Value e bigStepValue (BStValue v) = v bigStepValue (BStApp _ _ z) = bigStepValue z bigStepValue (BStFix _ z) = bigStepValue z bigStepValue (BStSucc z) = VSucc (bigStepValue z) bigStepValue (BStPredZero _) = VZero bigStepValue (BStPredSucc z) = case bigStepValue z of VZero impossible VSucc v => v bigStepValue (BStIfzZero _ z) = bigStepValue z bigStepValue (BStIfzSucc _ z) = bigStepValue z -- End: BIG-STEP EVALUATION RELATION FOR TERMS IN THE LAMBDA CALCULUS --------------------------------------------------------------------- --------------------------------------------------------- -- Begin: DIVERGENCE OF TERM 'Subst.omega' UNDER BIG-STEP -- The following straightforward approach to proving -- that 'omega' diverges does not pass Idris' totality -- checker because of the rewriting of 'bst' in the -- induction step: -- -- divergenceOmega : BigStep Subst.omega e -> Void -- divergenceOmega {e = _} (BStValue v) = case v of -- VZero impossible -- (VSucc _) impossible -- VAbs impossible -- divergenceOmega {e = e} (BStFix (BStValue v) bst) = -- let bst' = replace {P = \x => BigStep x e} substOmega bst -- in divergenceOmega bst' -- To prove that 'omega' diverges under big-step semantics, -- an indexed version of the 'BigStep' relation is introduced: data BigStepN : Nat -> Term [] t -> (y: Term [] t) -> Type where BStValueN : (v : Value e) -> BigStepN Z e e -- BStAppN : BigStepN k e1 (TAbs e1') -> BigStepN m e2 e2' -> BigStepN n (subst e2' FZ e1') e -> BigStepN (S $ k+m+n) (TApp e1 e2) e -- BStFixN : BigStepN m e (TAbs e') -> BigStepN n (subst (TFix (TAbs e')) FZ e') e'' -> BigStepN (S $ m+n) (TFix e) e'' -- BStSuccN : BigStepN n e e' -> BigStepN (S n) (TSucc e) (TSucc e') -- BStPredZeroN : BigStepN n e TZero -> BigStepN (S n) (TPred e) TZero -- BStPredSuccN : BigStepN n e (TSucc e') -> BigStepN (S n) (TPred e) e' -- BStIfzZeroN : BigStepN m e1 TZero -> BigStepN n e2 e -> BigStepN (S $ m+n) (TIfz e1 e2 _) e -- BStIfzSuccN : BigStepN m e1 (TSucc _) -> BigStepN n e3 e -> BigStepN (S $ m+n) (TIfz e1 _ e3) e bigStepToN : BigStep e1 e2 -> (n : Nat ** BigStepN n e1 e2) bigStepToN (BStValue v) = (Z ** BStValueN v) -- bigStepToN (BStApp bst1 bst2 bst3) = let (n1 ** bstn1) = bigStepToN bst1 (n2 ** bstn2) = bigStepToN bst2 (n3 ** bstn3) = bigStepToN bst3 in ((S $ n1+n2+n3) ** BStAppN bstn1 bstn2 bstn3) -- bigStepToN (BStFix bst1 bst2) = let (n1 ** bstn1) = bigStepToN bst1 (n2 ** bstn2) = bigStepToN bst2 in ((S $ n1+n2) ** BStFixN bstn1 bstn2) -- bigStepToN (BStSucc bst) = let (n ** bstn) = bigStepToN bst in ((S n) ** BStSuccN bstn) -- bigStepToN (BStPredZero bst) = let (n ** bstn) = bigStepToN bst in ((S n) ** BStPredZeroN bstn) -- bigStepToN (BStPredSucc bst) = let (n ** bstn) = bigStepToN bst in ((S n) ** BStPredSuccN bstn) -- bigStepToN (BStIfzZero bst1 bst2) = let (n1 ** bstn1) = bigStepToN bst1 (n2 ** bstn2) = bigStepToN bst2 in ((S $ n1+n2) ** BStIfzZeroN bstn1 bstn2) -- bigStepToN (BStIfzSucc bst1 bst2) = let (n1 ** bstn1) = bigStepToN bst1 (n2 ** bstn2) = bigStepToN bst2 in ((S $ n1+n2) ** BStIfzSuccN bstn1 bstn2) bigStepFromN : BigStepN n e1 e2 -> BigStep e1 e2 bigStepFromN (BStValueN v) = BStValue v -- bigStepFromN (BStAppN bstn1 bstn2 bstn3) = let bst1 = bigStepFromN bstn1 bst2 = bigStepFromN bstn2 bst3 = bigStepFromN bstn3 in BStApp bst1 bst2 bst3 -- bigStepFromN (BStFixN bstn1 bstn2) = let bst1 = bigStepFromN bstn1 bst2 = bigStepFromN bstn2 in BStFix bst1 bst2 -- bigStepFromN (BStSuccN bstn) = let bst = bigStepFromN bstn in BStSucc bst -- bigStepFromN (BStPredZeroN bstn) = let bst = bigStepFromN bstn in BStPredZero bst -- bigStepFromN (BStPredSuccN bstn) = let bst = bigStepFromN bstn in BStPredSucc bst -- bigStepFromN (BStIfzZeroN bstn1 bstn2) = let bst1 = bigStepFromN bstn1 bst2 = bigStepFromN bstn2 in BStIfzZero bst1 bst2 -- bigStepFromN (BStIfzSuccN bstn1 bstn2) = let bst1 = bigStepFromN bstn1 bst2 = bigStepFromN bstn2 in BStIfzSucc bst1 bst2 -- Divergence of 'omega' under the indexed version of big-step semantics: divergenceOmega' : {e : Term [] TyNat} -> (n : Nat) -> BigStepN n Subst.omega e -> Void divergenceOmega' Z (BStValueN v) = case v of VZero impossible (VSucc _) impossible VAbs impossible divergenceOmega' {e} (S n) bstn = case bstn of (BStFixN (BStValueN v) bstn2) => let bstn2' = replace {P = \x => BigStepN n x e} substOmega bstn2 in divergenceOmega' n bstn2' divergenceOmega : BigStep Subst.omega e -> Void divergenceOmega bst = let (n ** bstn) = bigStepToN bst in divergenceOmega' n bstn -- End: DIVERGENCE OF TERM 'Subst.omega' UNDER BIG-STEP -------------------------------------------------------
module Curves export Curve, interpolate, apply, concat, drop_duplicates, firstpoint, lastpoint export ItpLinear, ItpConstant, EtpFlat, EtpLine # type constants referring to Interpolations.jl export Tenor, get_days, get_tenor, @t_str using Interpolations using RecipesBase #= The Curve object is intended to be immutable, i.e. each operation on it creates a new Curve instance. In principle it would be possible to change points of the arrays curve.x or curve.y without creating a new Curve instance, but this should be avoided because it may introduce inconsistencies (especially when using log-interpolation). In order to have both extrapolation and interpolation, a nested extrapolation(interpolation) object (using Interpolations.jl) is created. The x and y arrays are passed to the Interpolations.jl interpolator directly if log-interpolation is switched off. In this case, the interpolation object contains a pointer to the same array, thus there are no duplicates of the x and y arrays in memory. The arrays x and y are mainly kept directly in the Curve struct (and not only inside the interpolation object) to avoid problems with type inference. However, if log interpolation is activated for one axis, a second array is created for the axis containing the log values of the original array and stored in the interpolation object. This results in double memory usage, but allows quick access to both the axis values (via curve.x and curve.y) and interpolated values. Note that Interpolation.jl does not support log-interpolation (yet?), therefore it needs to be implemented here explicitly. =# include("tenors.jl") # Type constants referring to Interpolations.jl const ItpLinear = Gridded ∘ Linear const ItpConstant = Gridded ∘ Constant const EtpFlat = Flat const EtpLine = Line # Basic definition abstract type AbstractCurve end struct Curve{Tx <: AbstractVector, Ty <: AbstractVector, Titp <: Union{Interpolations.AbstractInterpolation, Nothing}} <: AbstractCurve "data points x-axis" x:: Tx "data points y-axis" y:: Ty "Interpolations.jl extrapolation(interpolation) object" etp:: Titp "is x-axis logarithmic?" logx:: Bool "is y-axis logarithmic?" logy:: Bool end """ Curve(x:: AbstractVector, y:: AbstractVector; method=ItpLinear(), extrapolation=EtpFlat(), logx=false, logy=false, sort=true) Standard curve constructor. Creates the interpolation/extrapolation object of the curve instance. The points `x` and `y` do not need to be sorted, this is done in the Curve constructor. Interpolation/extrapolation details can be changed using the keyword arguments, defaults are: * linear interpolation * constant extrapolation * no logarithmic axes Note that for method ˋGridded(x)ˋ must be used so that the x-grid can be non-uniform. Valid choices for ˋmethodˋ are: * ˋItpLinear()ˋ, corresponds to Interpolation.jl ˋGridded(Linear())ˋ - default * ˋItpConstant()ˋ, corresponds to Interpolation.jl ˋGridded(Constant())ˋ Valid choices for ˋextrapolationˋ are: * ˋEtpFlat()ˋ, corresponds to Interpolation.jl ˋFlat()ˋ - default * ˋEtpLine()ˋ, corresponds to Interpolation.jl ˋLine()ˋ If the curve consists only of a single point, always constant extrapolation is used. * `sort=true`: per default, the input points are sorted and duplicate x-values are removed. `sort=true` is unsafe and intended to be used for Curves.jl internal operations only, where it can be guaranteed that the points are sorted and not duplicate. """ function Curve(x:: AbstractVector, y:: AbstractVector; method=ItpLinear(), extrapolation=EtpFlat(), logx=false, logy=false, sort=true) length(x) == length(y) || error("length of x and y arrays must match") if length(x) == 1 return Curve(x, y, nothing, logx, logy) else if sort x, y = uniquexy(x, y) perm = sortperm(x) x = x[perm] y = y[perm] end return Curve(x, y, extrapolate(interpolate(logx ? (log.(x),) : (x,), logy ? log.(y) : y, method), extrapolation), logx, logy) end end Base.show(io:: IO, c:: Curve) = print(io, "x = $(c.x), y = $(c.y), logx = $(c.logx), logy = $(c.logy)") "helper function to get Interpolations.jl interpolation method" getitpm(c1:: Curve) = isnothing(c1.etp) ? nothing : c1.etp.itp.it "helper function to get Interpolations.jl extrapolation method" getetpm(c1:: Curve) = isnothing(c1.etp) ? nothing : c1.etp.et """ Curve(c1:: Curve; method=getitpm(c1), extrapolation=getetpm(c1), logx=c1.logx, logy=c1.logy, sort=true) Copy constructor to generate a new curve from an existing one. The interpolation / extrapolation parameters can be changed. """ Curve(c1:: Curve; method=getitpm(c1), extrapolation=getetpm(c1), logx=c1.logx, logy=c1.logy, sort=true) = Curve(c1.x, c1.y, method=method, extrapolation=extrapolation, logx=logx, logy=logy, sort=sort) """ Curve(x:: AbstractVector{<: AbstractString}, y; kwargs...) Construct Curve objects from an array of tenor strings as x-axis. """ Curve(x:: AbstractVector{<: AbstractString}, y:: AbstractVector; kwargs...) = Curve(Tenor.(x), y; kwargs...) """ Curve(x:: AbstractVector{Tenor}, y:: AbstractVector; offset:: Real = 0, kwargs...) Construct Curve objects from an array of Tenor objects strings as x-axis. With the `offset` keyword argument the points on the x-axis, defined by the given tenors, can be shifted. This could be e.g. used to take a spot lag of financial instruments into account. Note that the shift is always in calendar days, a spot lag given in business days must be converted to calendar days beforehand. """ Curve(x:: AbstractVector{Tenor}, y:: AbstractVector; offset:: Real = 0, kwargs...) = Curve(get_days.(x) .+ offset, y; kwargs...) Curve(x:: Real, y:: Real; kwargs...) = Curve([x], [y]; kwargs...) Curve(x:: Tenor, y:: Real; kwargs...) = Curve([get_days(x)], [y]; kwargs...) Base.Broadcast.broadcastable(q:: Curve) = Ref(q) # treat it as a scalar in broadcasting @recipe plot(c::Curve) = c.x, c.y include("curve_functions.jl") end # module
A complex-valued function $f$ converges to a complex number $x$ if and only if the real and imaginary parts of $f$ converge to the real and imaginary parts of $x$, respectively.
\section{Logical Paradoxes} \newcommand{\starttoken}{\textsc{s}} \newcommand{\finishtoken}{\textsc{f}} In this section we provide proofs of some logical inconsistencies that arise when slight changes are made to the Iris logic. \subsection{Saved Propositions without a Later} \label{sec:saved-prop-no-later} As a preparation for the proof about invariants in \Sref{app:section:invariants-without-a-later}, we show that omitting the later modality from a variant of \emph{saved propositions} leads to a contradiction. Saved propositions have been introduced in prior work~\cite{dodds:higher-order-sync,iris2} to prove correctness of synchronization primitives; we will explain all that is necessary here. The counterexample assumes a higher-order logic with separating conjunction, magic wand and the modalities $\always$ and $\upd$ satisfying the rules in \Sref{sec:base-logic}. \begin{thm} \label{thm:counterexample-1} If there exists a type $\GName$ and a proposition $\_ \Mapsto \_ : \GName \to \Prop \to \Prop$ associating names $\gamma : \GName$ to propositions and satisfying: \begin{align} \proves{}& \upd \Exists \gname : \GName. \gname \Mapsto P(\gname) \tagH{sprop-alloc} \\ \gname \Mapsto P \proves{}& \always (\gname \Mapsto P) \tagH{sprop-persist} \\ \gname \Mapsto \prop * \gname \Mapsto \propB \proves{} & \prop \Lra \propB \tagH{sprop-agree} \end{align} then $\proves\upd \FALSE$. \end{thm} The type $\GName$ should be thought of as the type of ``locations'' and $\gname \Mapsto P$ should be read as stating that location $\gname$ ``stores'' proposition $P$. Notice that these are immutable locations, so the maps-to proposition is persistent. The rule \ruleref{sprop-alloc} is then thought of as allocation, and the rule \ruleref{sprop-agree} states that a given location $\gname$ can only store \emph{one} proposition, so multiple witnesses covering the same location must agree. %Compared to saved propositions in prior work, \ruleref{sprop-alloc} is stronger since the stored proposition can depend on the name being allocated. %\derek{Can't we cut the above sentence? This makes it sound like we are doing something weird that we ought not to be since prior work didn't do it. But in fact, I thought that in our construction we do not really need to rely on this feature at all! So I'm confused.} The conclusion of \ruleref{sprop-agree} usually is guarded by a $\later$. The point of this theorem is to show that said later is \emph{essential}, as removing it introduces inconsistency. % The key to proving \thmref{thm:counterexample-1} is the following proposition: \begin{defn} $A(\gname) \eqdef \Exists \prop : \Prop. \always\lnot \prop \land \gname \Mapsto \prop$. \end{defn} Intuitively, $A(\gname)$ says that the saved proposition named $\gname$ does \emph{not} hold, \ie we can disprove it. Using \ruleref{sprop-persist}, it is immediate that $A(\gname)$ is persistent. Now, by applying \ruleref{sprop-alloc} with $A$, we obtain a proof of $\prop \eqdef \gname \Mapsto A(\gname)$: this says that the proposition named $\gname$ is the proposition saying that it, itself, does not hold. In other words, $\prop$ says that the proposition named $\gname$ expresses its own negation. Unsurprisingly, that leads to a contradiction, as is shown in the following lemma: \begin{lem} \label{lem:saved-prop-counterexample-not-agname} We have $\gname \Mapsto A(\gname) \proves \always\lnot A(\gname)$ and $\gname \Mapsto A(\gname) \proves A(\gname)$. \end{lem} \begin{proof}%[\lemref{lem:saved-prop-counterexample-not-agname}] \leavevmode \begin{itemize} \item First we show $\gname \Mapsto A(\gname) \proves \always\lnot A(\gname)$. Since $\gname \Mapsto A(\gname)$ is persistent it suffices to show $\gname \Mapsto A(\gname) \proves \lnot A(\gname)$. Suppose $\gname \Mapsto A(\gname)$ and $A(\gname)$. Then by definition of \(A\) there is a $\prop$ such that $\always \lnot \prop$ and $\gname \Mapsto \prop$. By \ruleref{sprop-agree} we have $\prop \Lra A(\gname)$ and so from $\lnot \prop$ we get $\lnot A(\gname)$, which leads to a contradiction with $A(\gname)$. \item Using the first item we can now prove $\gname \Mapsto A(\gname) \proves A(\gname)$. We need to prove \begin{align*} \Exists \prop : \Prop. \always \lnot \prop \land \gname \Mapsto \prop. \end{align*} We do so by picking $\prop$ to be $A(\gname)$, which leaves us to prove \(\always \lnot A(\gname) \land \gname \Mapsto A(\gname)\). The last conjunct holds by assumption, and the first conjunct follows from the previous item of this lemma. \end{itemize} \end{proof} With this lemma in hand, the proof of \thmref{thm:counterexample-1} is simple. \begin{proof}[\thmref{thm:counterexample-1}] Using the previous lemmas we have \begin{align*} \proves \All \gname. \lnot (\gname \Mapsto A(\gname)). \end{align*} Together with the rule \ruleref{sprop-alloc} we thus derive $\upd \FALSE$. \end{proof} \subsection{Invariants without a Later} \label{app:section:invariants-without-a-later} Now we come to the main paradox: if we remove the $\later$ from \ruleref{inv-open}, the logic becomes inconsistent. The theorem is stated as general as possible so that it also applies to previous, less powerful versions of Iris. \begin{thm} \label{thm:counterexample-2} Assume a higher-order separation logic with $\always$ and an update modality with a binary mask ${\upd}_{\set{0,1}}$ (think: empty mask and full mask) satisfying strong monad rules with respect to separating conjunction and such that: \begin{mathpar} \inferhref{weaken-mask}{eq:update-weaken-mask} {}{{\upd}_0 \prop \proves {\upd}_1 \prop} \end{mathpar} \noindent Assume a type $\InvName$ and a proposition $\knowInv{\cdot}{\cdot} : \InvName \to \Prop \to \Prop$ satisfying: % \begin{mathpar} \inferhref{inv-alloc}{eq:inv-alloc} {} {\prop \proves {\upd}_1 \Exists \iname. \knowInv \iname \prop} \and \inferhref{inv-persist}{eq:inv-persistent} {} {\knowInv \iname \prop \proves \always \knowInv \iname \prop} \and \inferhref{inv-open-nolater}{eq:inv-open} {\prop * \propB \proves {\upd}_0 (\prop * \propC) } {\knowInv \iname \prop * \propB \proves {\upd}_1 \propC} \end{mathpar} \noindent Finally, assume the existence of a type $\GName$ and two tokens $\ownGhost{\cdot}{\starttoken} : \GName \to \Prop$ and $\ownGhost{\cdot}{\finishtoken}: \GName \to \Prop$ parameterized by $\GName$ and satisfying the following properties: \begin{mathpar} \inferhref{start-alloc}{eq:start-alloc} {}{\proves {\upd}_0 \Exists \gname. \ownGhost \gname \starttoken} \and \inferhref{start-finish}{eq:start-finish} {}{\ownGhost \gname \starttoken \proves {\upd}_0 \ownGhost \gname \finishtoken} \and \inferhref{start-not-finished}{eq:start-not-finished} {}{\ownGhost \gname \starttoken * \ownGhost \gname \finishtoken \proves \FALSE} \and \inferhref{finished-dup}{eq:finished-dup} {}{\ownGhost \gname \finishtoken \proves \ownGhost \gname \finishtoken * \ownGhost \gname \finishtoken} \end{mathpar} \noindent Then $\TRUE \proves{\upd}_1 \FALSE$. \end{thm} The core of the proof is defining the $\Mapsto$ from the previous counterexample using invariants. Then, using the standard proof rules for invariants, we show that it satisfies \ruleref{sprop-alloc} and \ruleref{sprop-persist}. Furthermore, assuming the rule for opening invariants without a $\later$, we can prove a slightly weaker version of \ruleref{sprop-agree}, which is sufficient for deriving a contradiction. % Taking ${\upd}_0$ and ${\upd}_1$ to be the fancy update modalities $\pvs[\emptyset]$ % and $\pvs[\nat]$, respectively, we can see that Iris % \emph{almost} satisfies these axioms. First, to implement the tokens, % we can use the RA with the carrier % $\{\mundef,\epsilon,\starttoken,\finishtoken\}$ and operation % $\epsilon \mtimes x = x \mtimes \epsilon = x$, % $\finishtoken \mtimes \finishtoken = \finishtoken$ and otherwise % $x \mtimes y = \mundef$. Then, observe that the rules for % $\knowInv{\cdot}{\cdot}$ are special cases of (derivable) invariant % rules in Iris. The fly in the ointment is the \ruleref{eq:inv-open} % rule: in Iris, this rule would protect each occurrence of $\prop$ % in the premise of the rule with a $\later$, whereas here they are % unprotected. We start by defining $\Mapsto$ satisfying (almost) the assumptions of \lemref{lem:counterexample-invariants-saved-prop-agree}. % \begin{defn} We define $\_ \Mapsto \_ : \GName \to \Prop \to \Prop$ as: % \begin{align*} \gname \Mapsto \prop \eqdef \Exists \iname. \knowInv \iname {\ownGhost \gname \starttoken \lor \ownGhost \gname \finishtoken * \always \prop}. \end{align*} \end{defn} Note that using \ruleref{eq:inv-persistent}, it is immediate that $\gname \Mapsto \prop$ is persistent. We use the tokens $\ownGhost \gname \starttoken$ and $\ownGhost \gname \finishtoken$ to model invariants that can be initialized ``lazily'': $\ownGhost \gname \starttoken$ indicates that the invariant is still not initialized, whereas the duplicable $\ownGhost \gname \finishtoken$ indicates it has been initialized with a resource satisfying $\prop$.% %\footnote{We would usually require the token to be persistent, but it turns out the proof also works with the weaker assumption of duplicability.} % RK: cut the footnote, it takes space. Maybe restore later % TODO, explain this ... We can show variants of \ruleref{sprop-agree} and \ruleref{sprop-alloc} for the defined $\Mapsto$. \begin{lem} \label{lem:counterexample-invariants-saved-prop-alloc} We have \(\proves {\upd}_1 \Exists \gname. \gname \Mapsto \prop(\gname)\). \end{lem} \begin{proof} We have to show the allocation rule \[\proves {\upd}_1 \Exists \gname. \gname \Mapsto \prop.\] From \ruleref{eq:start-alloc} we have a $\gname$ such that ${\upd}_0 \ownGhost \gname \starttoken$ holds and hence from \ruleref{eq:update-weaken-mask} we have ${\upd}_1\ownGhost\gname \starttoken$. Since we are proving a goal of the form ${\upd}_1 R$ we may assume $\ownGhost \gname \starttoken$. Thus for any $\prop$ we have ${\upd}_1\left(\ownGhost{\gname}{\starttoken} \lor \ownGhost \gname \finishtoken * \prop\right)$. Again since our goal is still of the form ${\upd}_1$ we may assume $\ownGhost{\gname}{\starttoken} \lor \ownGhost \gname \finishtoken * \always \prop$. The rule \ruleref{eq:inv-alloc} then gives us precisely what we need. \qed \end{proof} % \begin{lem} \label{lem:counterexample-invariants-saved-prop-agree} We have \( \gname \Mapsto \prop * \gname \Mapsto \propB * \always \prop \proves {\upd}_1 \always \propB \) and thus \( \gname \Mapsto \prop * \gname \Mapsto \propB \proves ({\upd}_1 \always \prop) \Lra ({\upd}_1 \always \propB). \) \end{lem} \begin{proof}[\lemref{lem:counterexample-invariants-saved-prop-agree}] \begin{itemize} \item We first show \[\gname \Mapsto \prop * \gname \Mapsto \propB * \always \prop \proves {\upd}_1 \always \propB.\] We use \ruleref{eq:inv-open} to open the invariant in $\gname \Mapsto \prop$ and consider two cases: % \begin{enumerate} \item $\ownGhost \gname \starttoken$(the invariant is ``uninitialized'') : In this case, we use \ruleref{eq:start-finish} to ``initialize'' the invariant and obtain $\ownGhost{\gname}{\finishtoken}$. Then we duplicate $\ownGhost \gname \finishtoken$, and use it together with $\always \prop$ to close the invariant. \item $\ownGhost \gname \finishtoken * \always \prop$ (the invariant is ``initialized''): In this case we duplicate $\ownGhost \gname \finishtoken$, and use a copy to close the invariant. \end{enumerate} % After closing the invariant, we have obtained $\ownGhost \gname \finishtoken$. Hence, it is sufficient to prove \[ \ownGhost{\gname}{\finishtoken} * \gname \Mapsto \prop * \gname \Mapsto \propB * \always \prop \proves {\upd}_1 \always \propB.\] We proceed by using \ruleref{eq:inv-open} to open the other invariant in $\gname \Mapsto \propB$, and we again consider two cases: \begin{enumerate} \item $\ownGhost{\gname}{\starttoken}$ (the invariant is ``uninitialized''): As witnessed by \ruleref{eq:start-not-finished}, this cannot happen, so we derive a contradiction. Notice that this is a key point of the proof: because the two invariants ($\gname \Mapsto \prop$ and $\gname \Mapsto \propB$) \emph{share} the ghost name $\gname$, initializing one of them is enough to show that the other one has been initialized. Essentially, this is an indirect way of saying that really, we have been opening the same invariant two times. \item $\ownGhost{\gname}{\finishtoken} * \always \propB$ (the invariant is ``initialized''): Since $\always \propB$ is duplicable we use one copy to close the invariant, and retain another to prove ${\upd}_1 \always \propB$. \end{enumerate} \item By applying the above twice, we easily obtain \[ \gname \Mapsto \prop * \gname \Mapsto \propB \proves ({\upd}_1 \always \prop) \Lra ({\upd}_1 \always \propB) \] \end{itemize} \qed \end{proof} % When allocating $\gname \Mapsto \prop(\gname)$ in \lemref{lem:counterexample-invariants-saved-prop-alloc}, we will start off in ``state'' $\ownGhost \gname \starttoken$, and once we have $P$ in \lemref{lem:counterexample-invariants-saved-prop-agree} we use \ruleref{eq:start-finish} to transition to $\ownGhost\gname \finishtoken$, obtaining ourselves a copy of said token. % Finally, we use this token with $\gname \Mapsto \propB$ to obtain a proof of $\propB$. Intuitively, \lemref{lem:counterexample-invariants-saved-prop-agree} shows that we can ``convert'' a proof from $\prop$ to $\propB$. We are now in a position to replay the counterexample from \Sref{sec:saved-prop-no-later}. The only difference is that because \lemref{lem:counterexample-invariants-saved-prop-agree} is slightly weaker than the rule \ruleref{sprop-agree} of \thmref{thm:counterexample-1}, we need to use ${\upd}_1 \FALSE$ in place of $\FALSE$ in the definition of the predicate $A$: we let \( A(\gname) \eqdef \Exists \prop : \Prop. \always (\prop \Ra {\upd}_1 \FALSE) \land \gname \Mapsto \prop\) and replay the proof that we have presented above. %TODO: What about executing a view shift under a later? %%% Local Variables: %%% mode: latex %%% TeX-master: "iris" %%% End:
lemma continuous_on_op_minus: "continuous_on (s::'a::topological_group_add set) ((-) x)"
We are halfway through utility and other construction on 1300 East between 2100 South and 1300 South! Come get updated on progress and the Spring 2019 construction phase of the project on Thursday, December 6th. The event is a public open house at East High School Commons, from 5:30 to 7 p.m. Representatives from SLC Department of Public Utilities and the City’s Engineering and Transportation divisions will be on hand with maps, information, and answers to questions regarding the nearly completed sewer and water line work and upcoming road repaving, curb and gutter rehab, bike lanes, and transit stops. We anticipate the entire project will be completed by late Fall 2019.
(* Property from Case-Analysis for Rippling and Inductive Proof, Moa Johansson, Lucas Dixon and Alan Bundy, ITP 2010. This Isabelle theory is produced using the TIP tool offered at the following website: https://github.com/tip-org/tools This file was originally provided as part of TIP benchmark at the following website: https://github.com/tip-org/benchmarks Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly to make it compatible with Isabelle2017. Some proofs were added by Yutaka Nagashima.*) theory TIP_prop_15 imports "../../Test_Base" begin datatype 'a list = nil2 | cons2 "'a" "'a list" datatype Nat = Z | S "Nat" fun len :: "'a list => Nat" where "len (nil2) = Z" | "len (cons2 y xs) = S (len xs)" fun t2 :: "Nat => Nat => bool" where "t2 x (Z) = False" | "t2 (Z) (S z) = True" | "t2 (S x2) (S z) = t2 x2 z" fun ins :: "Nat => Nat list => Nat list" where "ins x (nil2) = cons2 x (nil2)" | "ins x (cons2 z xs) = (if t2 x z then cons2 x (cons2 z xs) else cons2 z (ins x xs))" theorem property0 : "((len (ins x xs)) = (S (len xs)))" find_proof DInd apply (induct rule: TIP_prop_15.len.induct) apply auto done end
[STATEMENT] lemma splitAt_distinct_fst: "distinct vs \<Longrightarrow> distinct (fst (splitAt ram1 vs))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. distinct vs \<Longrightarrow> distinct (fst (splitAt ram1 vs)) [PROOF STEP] by (simp add: splitAt_def splitAtRec_distinct_fst)
open import Formalization.PredicateLogic.Signature module Formalization.PredicateLogic.Classical.NaturalDeduction (𝔏 : Signature) where open Signature(𝔏) open import Data.ListSized import Lvl open import Formalization.PredicateLogic.Syntax(𝔏) open import Formalization.PredicateLogic.Syntax.Substitution(𝔏) open import Functional using (_∘_ ; _∘₂_ ; swap) open import Numeral.Finite open import Numeral.Natural open import Relator.Equals.Proofs.Equiv open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to · ; _≡_ to _≡ₛ_) open import Type private variable ℓ : Lvl.Level private variable args vars : ℕ private variable Γ : PredSet{ℓ}(Formula(vars)) data _⊢_ {ℓ} : PredSet{ℓ}(Formula(vars)) → Formula(vars) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ Lvl.⊔ ℓ)} where direct : (Γ ⊆ (Γ ⊢_)) [⊤]-intro : (Γ ⊢ ⊤) [⊥]-elim : ∀{φ} → ((Γ ∪ ·(¬ φ)) ⊢ ⊥) → (Γ ⊢ φ) [∧]-intro : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ ψ) → (Γ ⊢ (φ ∧ ψ)) [∧]-elimₗ : ∀{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ φ) [∧]-elimᵣ : ∀{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ ψ) [∨]-introₗ : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ∨ ψ)) [∨]-introᵣ : ∀{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ∨ ψ)) [∨]-elim : ∀{φ ψ χ} → ((Γ ∪ · φ) ⊢ χ) → ((Γ ∪ · ψ) ⊢ χ) → (Γ ⊢ (φ ∨ ψ)) → (Γ ⊢ χ) [⟶]-intro : ∀{φ ψ} → ((Γ ∪ · φ) ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ)) [⟶]-elim : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟶ ψ)) → (Γ ⊢ ψ) [Ɐ]-intro : ∀{φ} → (∀{t} → (Γ ⊢ (substitute0 t φ))) → (Γ ⊢ (Ɐ φ)) [Ɐ]-elim : ∀{φ} → (Γ ⊢ (Ɐ φ)) → ∀{t} → (Γ ⊢ (substitute0 t φ)) [∃]-intro : ∀{φ}{t} → (Γ ⊢ (substitute0 t φ)) → (Γ ⊢ (∃ φ)) [∃]-elim : ∀{φ ψ} → (∀{t} → (Γ ∪ ·(substitute0 t φ)) ⊢ ψ) → (Γ ⊢ (∃ φ)) → (Γ ⊢ ψ) module _ where open import Data.Either as Either import Logic.Propositional as Meta open import Relator.Equals private variable Γ₁ Γ₂ : PredSet{ℓ}(Formula(vars)) private variable φ ψ : Formula(vars) _⊬_ : PredSet{ℓ}(Formula(vars)) → Formula(vars) → Type _⊬_ = Meta.¬_ ∘₂ (_⊢_) [⟵]-intro : ((Γ ∪ · φ) ⊢ ψ) → (Γ ⊢ (ψ ⟵ φ)) [⟵]-intro = [⟶]-intro [⟵]-elim : (Γ ⊢ φ) → (Γ ⊢ (ψ ⟵ φ)) → (Γ ⊢ ψ) [⟵]-elim = [⟶]-elim [¬]-intro : ((Γ ∪ · φ) ⊢ ⊥) → (Γ ⊢ (¬ φ)) [¬]-intro = [⟶]-intro [⟷]-intro : ∀{φ ψ} → ((Γ ∪ · ψ) ⊢ φ) → ((Γ ∪ · φ) ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ)) [⟷]-intro l r = [∧]-intro ([⟶]-intro l) ([⟶]-intro r) [⟷]-elimₗ : ∀{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ φ) [⟷]-elimₗ Γψ Γφψ = [⟶]-elim Γψ ([∧]-elimₗ Γφψ) [⟷]-elimᵣ : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ ψ) [⟷]-elimᵣ Γφ Γφψ = [⟶]-elim Γφ ([∧]-elimᵣ Γφψ) weaken-union-singleton : (Γ₁ ⊆ Γ₂) → (((Γ₁ ∪ · φ) ⊢_) ⊆ ((Γ₂ ∪ · φ) ⊢_)) weaken : (Γ₁ ⊆ Γ₂) → ((Γ₁ ⊢_) ⊆ (Γ₂ ⊢_)) weaken Γ₁Γ₂ {φ} (direct p) = direct (Γ₁Γ₂ p) weaken Γ₁Γ₂ {.⊤} [⊤]-intro = [⊤]-intro weaken Γ₁Γ₂ {φ} ([⊥]-elim p) = [⊥]-elim (weaken-union-singleton Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(_ ∧ _)} ([∧]-intro p q) = [∧]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken Γ₁Γ₂ {φ} ([∧]-elimₗ p) = [∧]-elimₗ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([∧]-elimᵣ p) = [∧]-elimᵣ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introₗ p) = [∨]-introₗ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introᵣ p) = [∨]-introᵣ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([∨]-elim p q r) = [∨]-elim (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q) (weaken Γ₁Γ₂ r) weaken Γ₁Γ₂ {.(_ ⟶ _)} ([⟶]-intro p) = [⟶]-intro (weaken-union-singleton Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([⟶]-elim p q) = [⟶]-elim (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken Γ₁Γ₂ {.(Ɐ _)} ([Ɐ]-intro p) = [Ɐ]-intro (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(substitute0 _ _)} ([Ɐ]-elim p) = [Ɐ]-elim (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(∃ _)} ([∃]-intro p) = [∃]-intro (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([∃]-elim p q) = [∃]-elim (weaken-union-singleton Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken-union-singleton Γ₁Γ₂ p = weaken (Either.mapLeft Γ₁Γ₂) p weaken-union : (Γ₁ ⊢_) ⊆ ((Γ₁ ∪ Γ₂) ⊢_) weaken-union = weaken Left [⊥]-elim-constructive : (Γ ⊢ ⊥) → (Γ ⊢ φ) [⊥]-elim-constructive Γ⊥ = [⊥]-elim (weaken-union Γ⊥) [¬¬]-elim : (Γ ⊢ ¬(¬ φ)) → (Γ ⊢ φ) [¬¬]-elim nnφ = ([⊥]-elim ([⟶]-elim (direct(Right [≡]-intro)) (weaken-union nnφ) ) ) [¬¬]-intro : (Γ ⊢ φ) → (Γ ⊢ ¬(¬ φ)) [¬¬]-intro Γφ = ([¬]-intro ([⟶]-elim (weaken-union Γφ) (direct (Right [≡]-intro)) ) )
[STATEMENT] lemma progress_e: assumes "\<S>\<bullet>None \<tturnstile>_i vs;cs_es : ts'" "\<And> k lholed. \<not>(Lfilled k lholed [$Return] cs_es)" "\<And> i k lholed. (Lfilled k lholed [$Br (i)] cs_es) \<Longrightarrow> i < k" "cs_es \<noteq> [Trap]" "\<not> const_list (cs_es)" "store_typing s \<S>" shows "\<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_i \<lparr>s';vs';es'\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> [PROOF STEP] fix \<C> cs es ts_c [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> [PROOF STEP] have prems1: "\<S>\<bullet>\<C> \<turnstile> es : (ts_c _> ts') \<Longrightarrow> \<S>\<bullet>\<C> \<turnstile> cs_es : ([] _> ts') \<Longrightarrow> cs_es = cs@es \<Longrightarrow> const_list cs \<Longrightarrow> \<S>\<bullet>\<C> \<turnstile> cs : ([] _> ts_c) \<Longrightarrow> (\<And> k lholed. \<not>(Lfilled k lholed [$Return] cs_es)) \<Longrightarrow> (\<And> i k lholed. (Lfilled k lholed [$Br (i)] cs_es) \<Longrightarrow> i < k) \<Longrightarrow> cs_es \<noteq> [Trap] \<Longrightarrow> \<not> const_list (cs_es) \<Longrightarrow> store_typing s \<S> \<Longrightarrow> i < length (s_inst \<S>) \<Longrightarrow> length (local \<C>) = length (vs) \<Longrightarrow> Option.is_none (memory \<C>) = Option.is_none (inst.mem ((inst s)!i)) \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_i \<lparr>s';vs';cs_es'\<rparr>" and prems2: "\<S>\<bullet>None \<tturnstile>_i vs;cs_es : ts' \<Longrightarrow> (\<And> k lholed. \<not>(Lfilled k lholed [$Return] cs_es)) \<Longrightarrow> (\<And> i k lholed. (Lfilled k lholed [$Br (i)] cs_es) \<Longrightarrow> i < k) \<Longrightarrow> cs_es \<noteq> [Trap] \<Longrightarrow> \<not> const_list (cs_es) \<Longrightarrow> store_typing s \<S> \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_i \<lparr>s';vs';cs_es'\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : ts_c _> ts'; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';cs_es'\<rparr>) &&& (\<lbrakk>\<S>\<bullet>None \<tturnstile>_ i vs;cs_es : ts'; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';cs_es'\<rparr>) [PROOF STEP] proof (induction arbitrary: vs ts_c ts' i cs_es cs rule: e_typing_s_typing.inducts) [PROOF STATE] proof (state) goal (8 subgoals): 1. \<And>\<C> b_es tf \<S> vs ts_c ts' i cs_es cs. \<lbrakk>\<C> \<turnstile> b_es : tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ ($* b_es); const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> es t1s t2s e t3s vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 6. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 7. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 8. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (1 \<C> b_es tf \<S>) [PROOF STATE] proof (state) this: \<C> \<turnstile> b_es : tf \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ ($* b_es) const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (8 subgoals): 1. \<And>\<C> b_es tf \<S> vs ts_c ts' i cs_es cs. \<lbrakk>\<C> \<turnstile> b_es : tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ ($* b_es); const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> es t1s t2s e t3s vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 6. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 7. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 8. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] hence "\<C> \<turnstile> b_es : (ts_c _> ts')" [PROOF STATE] proof (prove) using this: \<C> \<turnstile> b_es : tf \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ ($* b_es) const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<C> \<turnstile> b_es : ts_c _> ts' [PROOF STEP] using e_type_comp_conc1[of \<S> \<C> cs "($* b_es)" "[]" "ts'"] unlift_b_e [PROOF STATE] proof (prove) using this: \<C> \<turnstile> b_es : tf \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ ($* b_es) const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) \<S>\<bullet>\<C> \<turnstile> cs @ ($* b_es) : [] _> ts' \<Longrightarrow> \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts'' \<and> \<S>\<bullet>\<C> \<turnstile> $* b_es : ts'' _> ts' ?\<S>\<bullet>?\<C> \<turnstile> $* ?b_es : ?tf \<Longrightarrow> ?\<C> \<turnstile> ?b_es : ?tf goal (1 subgoal): 1. \<C> \<turnstile> b_es : ts_c _> ts' [PROOF STEP] by (metis e_type_const_conv_vs typing_map_typeof) [PROOF STATE] proof (state) this: \<C> \<turnstile> b_es : ts_c _> ts' goal (8 subgoals): 1. \<And>\<C> b_es tf \<S> vs ts_c ts' i cs_es cs. \<lbrakk>\<C> \<turnstile> b_es : tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ ($* b_es); const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> es t1s t2s e t3s vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 6. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 7. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 8. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<C> \<turnstile> b_es : ts_c _> ts' [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: \<C> \<turnstile> b_es : ts_c _> ts' goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using progress_b_e[OF _ 1(5) _ _ 1(4)] 1(3,4,9) list_all_append 1 [PROOF STATE] proof (prove) using this: \<C> \<turnstile> b_es : ts_c _> ts' \<lbrakk>\<C> \<turnstile> ?b_es : ts_c _> ?ts'; \<And>lholed. \<not> Lfilled 0 lholed [$Return] (cs @ ($* ?b_es)); \<And>i lholed. \<not> Lfilled 0 lholed [$Br i] (cs @ ($* ?b_es)); \<not> const_list ($* ?b_es); ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst ?s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' es'. \<lparr>?s;?vs;cs @ ($* ?b_es)\<rparr> \<leadsto>_ ?i \<lparr>s';vs';es'\<rparr> cs_es = cs @ ($* b_es) const_list cs \<not> const_list cs_es list_all ?P (?xs @ ?ys) = (list_all ?P ?xs \<and> list_all ?P ?ys) \<C> \<turnstile> b_es : tf \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ ($* b_es) const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: \<C> \<turnstile> b_es : ts_c _> ts' \<lbrakk>\<C> \<turnstile> ?b_es : ts_c _> ?ts'; \<And>lholed. \<not> Lfilled 0 lholed [$Return] (cs @ ($* ?b_es)); \<And>i lholed. \<not> Lfilled 0 lholed [$Br i] (cs @ ($* ?b_es)); \<not> list_all is_const ($* ?b_es); ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst ?s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' es'. \<lparr>?s;?vs;cs @ ($* ?b_es)\<rparr> \<leadsto>_ ?i \<lparr>s';vs';es'\<rparr> cs_es = cs @ ($* b_es) list_all is_const cs \<not> list_all is_const cs_es list_all ?P (?xs @ ?ys) = (list_all ?P ?xs \<and> list_all ?P ?ys) \<C> \<turnstile> b_es : tf \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ ($* b_es) list_all is_const cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> list_all is_const cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (7 subgoals): 1. \<And>\<S> \<C> es t1s t2s e t3s vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 5. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 6. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 7. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (7 subgoals): 1. \<And>\<S> \<C> es t1s t2s e t3s vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 5. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 6. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 7. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (2 \<S> \<C> es t1s t2s e t3s) [PROOF STATE] proof (state) this: \<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ es; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ [e]; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ es @ [e] const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (7 subgoals): 1. \<And>\<S> \<C> es t1s t2s e t3s vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> [e] : t2s _> t3s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es @ [e]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 5. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 6. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 7. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] proof (cases "const_list es") [PROOF STATE] proof (state) goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case True [PROOF STATE] proof (state) this: const_list es goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence "const_list (cs@es)" [PROOF STATE] proof (prove) using this: const_list es goal (1 subgoal): 1. const_list (cs @ es) [PROOF STEP] using 2(7) [PROOF STATE] proof (prove) using this: const_list es const_list cs goal (1 subgoal): 1. const_list (cs @ es) [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: list_all is_const es list_all is_const cs goal (1 subgoal): 1. list_all is_const (cs @ es) [PROOF STEP] by simp [PROOF STATE] proof (state) this: const_list (cs @ es) goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] moreover [PROOF STATE] proof (state) this: const_list (cs @ es) goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<exists>ts''. (\<S>\<bullet>\<C> \<turnstile> (cs @ es) : ([] _> ts''))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' [PROOF STEP] using 2(5,6) [PROOF STATE] proof (prove) using this: \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ es @ [e] goal (1 subgoal): 1. \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' [PROOF STEP] by (metis append.assoc e_type_comp_conc1) [PROOF STATE] proof (state) this: \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: const_list (cs @ es) \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: const_list (cs @ es) \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using 2(4)[OF 2(5) _ _ _ 2(9,10,11,12,13,14,15), of "(cs@es)"] 2(6,16) [PROOF STATE] proof (prove) using this: const_list (cs @ es) \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' \<lbrakk>cs_es = (cs @ es) @ [e]; const_list (cs @ es); \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ?ts_c; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> Lfilled k (?lholed1 i k lholed) [$Br i] cs_es; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> cs_es = cs @ es @ [e] Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case False [PROOF STATE] proof (state) this: \<not> const_list es goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence "\<not>const_list (cs@es)" [PROOF STATE] proof (prove) using this: \<not> const_list es goal (1 subgoal): 1. \<not> const_list (cs @ es) [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: \<not> list_all is_const es goal (1 subgoal): 1. \<not> list_all is_const (cs @ es) [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<not> const_list (cs @ es) goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<not> const_list (cs @ es) goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<exists>ts''. (\<S>\<bullet>\<C> \<turnstile> (cs @ es) : ([] _> ts''))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' [PROOF STEP] using 2(5,6) [PROOF STATE] proof (prove) using this: \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ es @ [e] goal (1 subgoal): 1. \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' [PROOF STEP] by (metis append.assoc e_type_comp_conc1) [PROOF STATE] proof (state) this: \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] { [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] assume "\<exists>k lholed. Lfilled k lholed [$Return] (cs @ es)" [PROOF STATE] proof (state) this: \<exists>k lholed. Lfilled k lholed [$Return] (cs @ es) goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>k lholed. Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] obtain k lholed where local_assms:"Lfilled k lholed [$Return] (cs @ es)" [PROOF STATE] proof (prove) using this: \<exists>k lholed. Lfilled k lholed [$Return] (cs @ es) goal (1 subgoal): 1. (\<And>k lholed. Lfilled k lholed [$Return] (cs @ es) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled k lholed [$Return] (cs @ es) goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] hence "\<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e])" [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Return] (cs @ es) goal (1 subgoal): 1. \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] proof (cases rule: Lfilled.cases) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>vs es'. \<lbrakk>k = 0; cs @ es = vs @ [$Return] @ es'; const_list vs; lholed = LBase vs es'\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) 2. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] case (L0 vs es') [PROOF STATE] proof (state) this: k = 0 cs @ es = vs @ [$Return] @ es' const_list vs lholed = LBase vs es' goal (2 subgoals): 1. \<And>vs es'. \<lbrakk>k = 0; cs @ es = vs @ [$Return] @ es'; const_list vs; lholed = LBase vs es'\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) 2. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] obtain lholed' where "lholed' = LBase vs (es'@[e])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>lholed'. lholed' = LBase vs (es' @ [e]) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: lholed' = LBase vs (es' @ [e]) goal (2 subgoals): 1. \<And>vs es'. \<lbrakk>k = 0; cs @ es = vs @ [$Return] @ es'; const_list vs; lholed = LBase vs es'\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) 2. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: lholed' = LBase vs (es' @ [e]) goal (1 subgoal): 1. \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] using L0 [PROOF STATE] proof (prove) using this: lholed' = LBase vs (es' @ [e]) k = 0 cs @ es = vs @ [$Return] @ es' const_list vs lholed = LBase vs es' goal (1 subgoal): 1. \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] by (metis Lfilled.intros(1) append.assoc) [PROOF STATE] proof (state) this: \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] case (LN vs ts es' l es'' k lfilledk) [PROOF STATE] proof (state) this: k__ = k + 1 cs @ es = vs @ [Label ts es' lfilledk] @ es'' const_list vs lholed = LRec vs ts es' l es'' Lfilled k l [$Return] lfilledk goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k__ = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k__ lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] obtain lholed' where "lholed' = LRec vs ts es' l (es''@[e])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>lholed'. lholed' = LRec vs ts es' l (es'' @ [e]) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: lholed' = LRec vs ts es' l (es'' @ [e]) goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>k__ = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Return] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k__ lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: lholed' = LRec vs ts es' l (es'' @ [e]) goal (1 subgoal): 1. \<exists>lholed'. Lfilled k__ lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] using LN [PROOF STATE] proof (prove) using this: lholed' = LRec vs ts es' l (es'' @ [e]) k__ = k + 1 cs @ es = vs @ [Label ts es' lfilledk] @ es'' const_list vs lholed = LRec vs ts es' l es'' Lfilled k l [$Return] lfilledk goal (1 subgoal): 1. \<exists>lholed'. Lfilled k__ lholed' [$Return] (cs @ es @ [e]) [PROOF STEP] by (metis Lfilled.intros(2) append.assoc) [PROOF STATE] proof (state) this: \<exists>lholed'. Lfilled k__ lholed' [$Return] (cs @ es @ [e]) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] hence False [PROOF STATE] proof (prove) using this: \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) goal (1 subgoal): 1. False [PROOF STEP] using 2(6,9) [PROOF STATE] proof (prove) using this: \<exists>lholed'. Lfilled k lholed' [$Return] (cs @ es @ [e]) cs_es = cs @ es @ [e] \<not> Lfilled ?k ?lholed [$Return] cs_es goal (1 subgoal): 1. False [PROOF STEP] by blast [PROOF STATE] proof (state) this: False goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] } [PROOF STATE] proof (state) this: \<exists>k lholed. Lfilled k lholed [$Return] (cs @ es) \<Longrightarrow> False goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] thus "\<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es)" [PROOF STATE] proof (prove) using this: \<exists>k lholed. Lfilled k lholed [$Return] (cs @ es) \<Longrightarrow> False goal (1 subgoal): 1. \<And>k lholed. \<not> Lfilled k lholed [$Return] (cs @ es) [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<not> Lfilled ?k ?lholed [$Return] (cs @ es) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<not> Lfilled ?k ?lholed [$Return] (cs @ es) goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<not> Lfilled ?k ?lholed [$Return] (cs @ es) goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] { [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] assume "\<exists>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<and> \<not>(i < k)" [PROOF STATE] proof (state) this: \<exists>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<and> \<not> i < k goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<and> \<not> i < k [PROOF STEP] obtain i k lholed where local_assms:"Lfilled k lholed [$Br i] (cs @ es)" "\<not>(i < k)" [PROOF STATE] proof (prove) using this: \<exists>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<and> \<not> i < k goal (1 subgoal): 1. (\<And>k lholed i. \<lbrakk>Lfilled k lholed [$Br i] (cs @ es); \<not> i < k\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled k lholed [$Br i] (cs @ es) \<not> i < k goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] hence "\<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not>(i < k)" [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Br i] (cs @ es) \<not> i < k goal (1 subgoal): 1. \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] proof (cases rule: Lfilled.cases) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>vs es'. \<lbrakk>\<not> i < k; k = 0; cs @ es = vs @ [$Br i] @ es'; const_list vs; lholed = LBase vs es'\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k 2. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k; k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] case (L0 vs es') [PROOF STATE] proof (state) this: k = 0 cs @ es = vs @ [$Br i] @ es' const_list vs lholed = LBase vs es' goal (2 subgoals): 1. \<And>vs es'. \<lbrakk>\<not> i < k; k = 0; cs @ es = vs @ [$Br i] @ es'; const_list vs; lholed = LBase vs es'\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k 2. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k; k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] obtain lholed' where "lholed' = LBase vs (es'@[e])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>lholed'. lholed' = LBase vs (es' @ [e]) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: lholed' = LBase vs (es' @ [e]) goal (2 subgoals): 1. \<And>vs es'. \<lbrakk>\<not> i < k; k = 0; cs @ es = vs @ [$Br i] @ es'; const_list vs; lholed = LBase vs es'\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k 2. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k; k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: lholed' = LBase vs (es' @ [e]) goal (1 subgoal): 1. \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] using L0 local_assms(2) [PROOF STATE] proof (prove) using this: lholed' = LBase vs (es' @ [e]) k = 0 cs @ es = vs @ [$Br i] @ es' const_list vs lholed = LBase vs es' \<not> i < k goal (1 subgoal): 1. \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] by (metis Lfilled.intros(1) append.assoc) [PROOF STATE] proof (state) this: \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k; k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k; k = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k [PROOF STEP] case (LN vs ts es' l es'' k lfilledk) [PROOF STATE] proof (state) this: k__ = k + 1 cs @ es = vs @ [Label ts es' lfilledk] @ es'' const_list vs lholed = LRec vs ts es' l es'' Lfilled k l [$Br i] lfilledk goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k__; k__ = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k__ lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k__ [PROOF STEP] obtain lholed' where "lholed' = LRec vs ts es' l (es''@[e])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>lholed'. lholed' = LRec vs ts es' l (es'' @ [e]) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: lholed' = LRec vs ts es' l (es'' @ [e]) goal (1 subgoal): 1. \<And>vs n es' l es'' ka lfilledk. \<lbrakk>\<not> i < k__; k__ = ka + 1; cs @ es = vs @ [Label n es' lfilledk] @ es''; const_list vs; lholed = LRec vs n es' l es''; Lfilled ka l [$Br i] lfilledk\<rbrakk> \<Longrightarrow> \<exists>lholed'. Lfilled k__ lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k__ [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: lholed' = LRec vs ts es' l (es'' @ [e]) goal (1 subgoal): 1. \<exists>lholed'. Lfilled k__ lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k__ [PROOF STEP] using LN local_assms(2) [PROOF STATE] proof (prove) using this: lholed' = LRec vs ts es' l (es'' @ [e]) k__ = k + 1 cs @ es = vs @ [Label ts es' lfilledk] @ es'' const_list vs lholed = LRec vs ts es' l es'' Lfilled k l [$Br i] lfilledk \<not> i < k__ goal (1 subgoal): 1. \<exists>lholed'. Lfilled k__ lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k__ [PROOF STEP] by (metis Lfilled.intros(2) append.assoc) [PROOF STATE] proof (state) this: \<exists>lholed'. Lfilled k__ lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k__ goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] hence False [PROOF STATE] proof (prove) using this: \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k goal (1 subgoal): 1. False [PROOF STEP] using 2(6,10) [PROOF STATE] proof (prove) using this: \<exists>lholed'. Lfilled k lholed' [$Br i] (cs @ es @ [e]) \<and> \<not> i < k cs_es = cs @ es @ [e] Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k goal (1 subgoal): 1. False [PROOF STEP] by blast [PROOF STATE] proof (state) this: False goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] } [PROOF STATE] proof (state) this: \<exists>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<and> \<not> i < k \<Longrightarrow> False goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] thus "\<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k" [PROOF STATE] proof (prove) using this: \<exists>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<and> \<not> i < k \<Longrightarrow> False goal (1 subgoal): 1. \<And>i k lholed. Lfilled k lholed [$Br i] (cs @ es) \<Longrightarrow> i < k [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled ?k ?lholed [$Br ?i] (cs @ es) \<Longrightarrow> ?i < ?k goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: Lfilled ?k ?lholed [$Br ?i] (cs @ es) \<Longrightarrow> ?i < ?k goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] moreover [PROOF STATE] proof (state) this: Lfilled ?k ?lholed [$Br ?i] (cs @ es) \<Longrightarrow> ?i < ?k goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] note preds = calculation [PROOF STATE] proof (state) this: \<not> const_list (cs @ es) \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' \<not> Lfilled ?k ?lholed [$Return] (cs @ es) Lfilled ?k ?lholed [$Br ?i] (cs @ es) \<Longrightarrow> ?i < ?k goal (1 subgoal): 1. \<not> const_list es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] proof (cases "cs @ es = [Trap]") [PROOF STATE] proof (state) goal (2 subgoals): 1. cs @ es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. cs @ es \<noteq> [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case True [PROOF STATE] proof (state) this: cs @ es = [Trap] goal (2 subgoals): 1. cs @ es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. cs @ es \<noteq> [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: cs @ es = [Trap] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using reduce_simple.trap[of _ "(LBase [] [e])"] Lfilled.intros(1)[of "[]" "LBase [] [e]" "[e]" "cs @ es"] reduce.intros(1) 2(6,11) [PROOF STATE] proof (prove) using this: cs @ es = [Trap] \<lbrakk>?es \<noteq> [Trap]; Lfilled 0 (LBase [] [e]) [Trap] ?es\<rbrakk> \<Longrightarrow> \<lparr>?es\<rparr> \<leadsto> \<lparr>[Trap]\<rparr> \<lbrakk>const_list []; LBase [] [e] = LBase [] [e]\<rbrakk> \<Longrightarrow> Lfilled 0 (LBase [] [e]) (cs @ es) ([] @ (cs @ es) @ [e]) \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> cs_es = cs @ es @ [e] cs_es \<noteq> [Trap] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: cs @ es = [Trap] \<lbrakk>?es \<noteq> [Trap]; Lfilled 0 (LBase [] [e]) [Trap] ?es\<rbrakk> \<Longrightarrow> \<lparr>?es\<rparr> \<leadsto> \<lparr>[Trap]\<rparr> \<lbrakk>list_all is_const []; LBase [] [e] = LBase [] [e]\<rbrakk> \<Longrightarrow> Lfilled 0 (LBase [] [e]) (cs @ es) ([] @ (cs @ es) @ [e]) \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> cs_es = cs @ es @ [e] cs_es \<noteq> [Trap] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by (metis append.assoc append_Nil list.pred_inject(1)) [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (1 subgoal): 1. cs @ es \<noteq> [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. cs @ es \<noteq> [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case False [PROOF STATE] proof (state) this: cs @ es \<noteq> [Trap] goal (1 subgoal): 1. cs @ es \<noteq> [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: cs @ es \<noteq> [Trap] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using 2(3)[OF _ _ 2(7,8) _ _ _ _ 2(13,14,15)] preds 2(6,16) progress_L0[of s vs "(cs @ es)" _ _ _ _ "[]" "[e]"] [PROOF STATE] proof (prove) using this: cs @ es \<noteq> [Trap] \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = cs @ es; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;?cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> \<not> const_list (cs @ es) \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' \<not> Lfilled ?k ?lholed [$Return] (cs @ es) Lfilled ?k ?lholed [$Br ?i] (cs @ es) \<Longrightarrow> ?i < ?k cs_es = cs @ es @ [e] Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) \<lbrakk>\<lparr>s;vs;cs @ es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr>; const_list []\<rbrakk> \<Longrightarrow> \<lparr>s;vs;[] @ (cs @ es) @ [e]\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';[] @ ?es' @ [e]\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: cs @ es \<noteq> [Trap] \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = cs @ es; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> list_all is_const ?cs_es; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;?cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> \<not> list_all is_const (cs @ es) \<exists>ts''. \<S>\<bullet>\<C> \<turnstile> cs @ es : [] _> ts'' \<not> Lfilled ?k ?lholed [$Return] (cs @ es) Lfilled ?k ?lholed [$Br ?i] (cs @ es) \<Longrightarrow> ?i < ?k cs_es = cs @ es @ [e] Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) \<lbrakk>\<lparr>s;vs;cs @ es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr>; list_all is_const []\<rbrakk> \<Longrightarrow> \<lparr>s;vs;[] @ (cs @ es) @ [e]\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';[] @ ?es' @ [e]\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by (metis append.assoc append_Nil list.pred_inject(1)) [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (6 subgoals): 1. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 4. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 6. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (6 subgoals): 1. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 4. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 6. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (3 \<S> \<C> es t1s t2s ts) [PROOF STATE] proof (state) this: \<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ es; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ es const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (6 subgoals): 1. \<And>\<S> \<C> es t1s t2s ts vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 4. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 6. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: \<S>\<bullet>\<C> \<turnstile> es : t1s _> t2s \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ es; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ es const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (5 subgoals): 1. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 3. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (5 subgoals): 1. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 3. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (4 \<S> \<C>) [PROOF STATE] proof (state) this: \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ [Trap] const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (5 subgoals): 1. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 3. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] have cs_es_def:"Lfilled 0 (LBase cs []) [Trap] cs_es" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Lfilled 0 (LBase cs []) [Trap] cs_es [PROOF STEP] using Lfilled.intros(1)[OF 4(3), of _ "[]" "[Trap]"] 4(2) [PROOF STATE] proof (prove) using this: ?lholed = LBase cs [] \<Longrightarrow> Lfilled 0 ?lholed [Trap] (cs @ [Trap] @ []) cs_es = cs @ [Trap] goal (1 subgoal): 1. Lfilled 0 (LBase cs []) [Trap] cs_es [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled 0 (LBase cs []) [Trap] cs_es goal (5 subgoals): 1. \<And>\<S> \<C> tf vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Trap]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 3. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 5. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase cs []) [Trap] cs_es goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using reduce_simple.trap[OF 4(7) cs_es_def] reduce.intros(1) [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase cs []) [Trap] cs_es \<lparr>cs_es\<rparr> \<leadsto> \<lparr>[Trap]\<rparr> \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (4 subgoals): 1. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 2. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (4 subgoals): 1. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 2. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (5 \<S> ts j vls es n \<C>) [PROOF STATE] proof (state) this: \<S>\<bullet>Some ts \<tturnstile>_ j vls;es : ts length ts = n \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vls;es\<rparr> \<leadsto>_ j \<lparr>s';vs';b\<rparr> \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ [Local n j vls es] const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (4 subgoals): 1. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 2. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] consider (1) "(\<And>k lholed. \<not> Lfilled k lholed [$Return] es)" "(\<And>k lholed i. (Lfilled k lholed [$Br i] es) \<Longrightarrow> i < k)" "es \<noteq> [Trap]" "\<not> const_list es" | (2) "\<exists>k lholed. Lfilled k lholed [$Return] es" | (3) "const_list es \<or> (es = [Trap])" | (4) "\<exists>k lholed i. (Lfilled k lholed [$Br i] es) \<and> i \<ge> k" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> thesis; const_list es \<or> es = [Trap] \<Longrightarrow> thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] using not_le_imp_less [PROOF STATE] proof (prove) using this: \<not> ?y \<le> ?x \<Longrightarrow> ?x < ?y goal (1 subgoal): 1. \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> thesis; const_list es \<or> es = [Trap] \<Longrightarrow> thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> ?thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> ?thesis; const_list es \<or> es = [Trap] \<Longrightarrow> ?thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (4 subgoals): 1. \<And>\<S> ts i vs es n \<C> vsa ts_c ts' ia cs_es cs. \<lbrakk>\<S>\<bullet>Some ts \<tturnstile>_ i vs;es : ts; \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Local n i vs es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; ia < length (s_inst \<S>); length (local \<C>) = length vsa; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ia))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vsa cs_es ia s' vs') 2. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 4. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> ?thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> ?thesis; const_list es \<or> es = [Trap] \<Longrightarrow> ?thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] proof (cases) [PROOF STATE] proof (state) goal (4 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 1 [PROOF STATE] proof (state) this: \<not> Lfilled ?k ?lholed [$Return] es Lfilled ?k ?lholed [$Br ?i] es \<Longrightarrow> ?i < ?k es \<noteq> [Trap] \<not> const_list es goal (4 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] obtain s' vs'' a where temp1:"\<lparr>s;vls;es\<rparr> \<leadsto>_ j \<lparr>s';vs'';a\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>s' vs'' a. \<lparr>s;vls;es\<rparr> \<leadsto>_ j \<lparr>s';vs'';a\<rparr> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using 5(3)[OF 1(1) _ 1(3,4) 5(12)] 1(2) [PROOF STATE] proof (prove) using this: (\<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k) \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vls;es\<rparr> \<leadsto>_ j \<lparr>s';vs';b\<rparr> Lfilled ?k ?lholed [$Br ?i] es \<Longrightarrow> ?i < ?k goal (1 subgoal): 1. (\<And>s' vs'' a. \<lparr>s;vls;es\<rparr> \<leadsto>_ j \<lparr>s';vs'';a\<rparr> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<lparr>s;vls;es\<rparr> \<leadsto>_ j \<lparr>s';vs'';a\<rparr> goal (4 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using reduce.intros(24)[OF temp1, of vs] progress_L0[where ?cs = cs, OF _ 5(6)] 5(5) [PROOF STATE] proof (prove) using this: \<lparr>s;vs;[Local ?n j vls es]\<rparr> \<leadsto>_ ?j \<lparr>s';vs;[Local ?n j vs'' a]\<rparr> \<lparr>?s;?vs;?es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';cs @ ?es' @ ?es_c\<rparr> cs_es = cs @ [Local n j vls es] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (3 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (3 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 2 [PROOF STATE] proof (state) this: \<exists>k lholed. Lfilled k lholed [$Return] es goal (3 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>k lholed. Lfilled k lholed [$Return] es [PROOF STEP] obtain k lholed where local_assms:"(Lfilled k lholed [$Return] es)" [PROOF STATE] proof (prove) using this: \<exists>k lholed. Lfilled k lholed [$Return] es goal (1 subgoal): 1. (\<And>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled k lholed [$Return] es goal (3 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: Lfilled k lholed [$Return] es [PROOF STEP] obtain lholed' vs' \<C>' where lholed'_def:"(Lfilled k lholed' (vs'@[$Return]) es)" "\<S>\<bullet>\<C>' \<turnstile> vs' : ([] _> ts)" "const_list vs'" [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Return] es goal (1 subgoal): 1. (\<And>lholed' vs' \<C>'. \<lbrakk>Lfilled k lholed' (vs' @ [$Return]) es; \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts; const_list vs'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using progress_LN_return[OF local_assms, of \<S> _ ts ts] s_type_unfold[OF 5(1)] [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Return] es \<lbrakk>\<S>\<bullet>?\<C> \<turnstile> es : [] _> ts; return ?\<C> = Some ts\<rbrakk> \<Longrightarrow> \<exists>lholed' vs \<C>'. Lfilled k lholed' (vs @ [$Return]) es \<and> \<S>\<bullet>\<C>' \<turnstile> vs : [] _> ts \<and> const_list vs j < length (s_inst \<S>) Some ts = Some ts \<or> Some ts = None \<S>\<bullet>(s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> \<turnstile> es : [] _> ts goal (1 subgoal): 1. (\<And>lholed' vs' \<C>'. \<lbrakk>Lfilled k lholed' (vs' @ [$Return]) es; \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts; const_list vs'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled k lholed' (vs' @ [$Return]) es \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts const_list vs' goal (3 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence temp1:"\<exists>a. \<lparr>[Local n j vls es]\<rparr> \<leadsto> \<lparr>vs'\<rparr>" [PROOF STATE] proof (prove) using this: Lfilled k lholed' (vs' @ [$Return]) es \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts const_list vs' goal (1 subgoal): 1. \<exists>a. \<lparr>[Local n j vls es]\<rparr> \<leadsto> \<lparr>vs'\<rparr> [PROOF STEP] using reduce_simple.return[OF lholed'_def(3)] e_type_const_list[OF lholed'_def(3,2)] 5(2) [PROOF STATE] proof (prove) using this: Lfilled k lholed' (vs' @ [$Return]) es \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts const_list vs' \<lbrakk>length vs' = ?n; Lfilled ?j ?lholed (vs' @ [$Return]) ?es\<rbrakk> \<Longrightarrow> \<lparr>[Local ?n ?i ?vls ?es]\<rparr> \<leadsto> \<lparr>vs'\<rparr> \<exists>tvs. ts = [] @ tvs \<and> length vs' = length tvs \<and> \<S>\<bullet>?\<C>' \<turnstile> vs' : [] _> tvs length ts = n goal (1 subgoal): 1. \<exists>a. \<lparr>[Local n j vls es]\<rparr> \<leadsto> \<lparr>vs'\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a. \<lparr>[Local n j vls es]\<rparr> \<leadsto> \<lparr>vs'\<rparr> goal (3 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using temp1 progress_L0[OF reduce.intros(1) 5(6)] 5(5) [PROOF STATE] proof (prove) using this: \<exists>a. \<lparr>[Local n j vls es]\<rparr> \<leadsto> \<lparr>vs'\<rparr> \<lparr>?es\<rparr> \<leadsto> \<lparr>?es'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;cs @ ?es' @ ?es_c\<rparr> cs_es = cs @ [Local n j vls es] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (2 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (2 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 3 [PROOF STATE] proof (state) this: const_list es \<or> es = [Trap] goal (2 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: const_list es \<or> es = [Trap] [PROOF STEP] consider (1) "const_list es" | (2) "es = [Trap]" [PROOF STATE] proof (prove) using this: const_list es \<or> es = [Trap] goal (1 subgoal): 1. \<lbrakk>const_list es \<Longrightarrow> thesis; es = [Trap] \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<lbrakk>const_list es \<Longrightarrow> ?thesis; es = [Trap] \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (2 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence temp1:"\<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr>" [PROOF STATE] proof (prove) using this: \<lbrakk>const_list es \<Longrightarrow> ?thesis; es = [Trap] \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] proof (cases) [PROOF STATE] proof (state) goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> 2. es = [Trap] \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] case 1 [PROOF STATE] proof (state) this: const_list es goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> 2. es = [Trap] \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] have "length es = length ts" [PROOF STATE] proof (prove) goal (1 subgoal): 1. length es = length ts [PROOF STEP] using s_type_unfold[OF 5(1)] e_type_const_list[OF 1] [PROOF STATE] proof (prove) using this: j < length (s_inst \<S>) Some ts = Some ts \<or> Some ts = None \<S>\<bullet>(s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> \<turnstile> es : [] _> ts ?\<S>\<bullet>?\<C> \<turnstile> es : ?ts _> ?ts' \<Longrightarrow> \<exists>tvs. ?ts' = ?ts @ tvs \<and> length es = length tvs \<and> ?\<S>\<bullet>?\<C>' \<turnstile> es : [] _> tvs goal (1 subgoal): 1. length es = length ts [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: length es = length ts goal (2 subgoals): 1. const_list es \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> 2. es = [Trap] \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: length es = length ts goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] using reduce_simple.local_const[OF 1] reduce.intros(1) 5(2) [PROOF STATE] proof (prove) using this: length es = length ts length es = ?n \<Longrightarrow> \<lparr>[Local ?n ?i ?vs es]\<rparr> \<leadsto> \<lparr>es\<rparr> \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> length ts = n goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> goal (1 subgoal): 1. es = [Trap] \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. es = [Trap] \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] case 2 [PROOF STATE] proof (state) this: es = [Trap] goal (1 subgoal): 1. es = [Trap] \<Longrightarrow> \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: es = [Trap] goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] using reduce_simple.local_trap reduce.intros(1) [PROOF STATE] proof (prove) using this: es = [Trap] \<lparr>[Local ?n ?i ?vs [Trap]]\<rparr> \<leadsto> \<lparr>[Trap]\<rparr> \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> goal (2 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using progress_L0[where ?cs = cs, OF _ 5(6)] 5(5) [PROOF STATE] proof (prove) using this: \<exists>a. \<lparr>s;vs;[Local n j vls es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> \<lparr>?s;?vs;?es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';cs @ ?es' @ ?es_c\<rparr> cs_es = cs @ [Local n j vls es] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 4 [PROOF STATE] proof (state) this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i [PROOF STEP] obtain k' lholed' i' where temp1:"Lfilled k' lholed' [$Br (k'+i')] es" [PROOF STATE] proof (prove) using this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i goal (1 subgoal): 1. (\<And>k' lholed' i'. Lfilled k' lholed' [$Br (k' + i')] es \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using le_Suc_ex [PROOF STATE] proof (prove) using this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i ?k \<le> ?l \<Longrightarrow> \<exists>n. ?l = ?k + n goal (1 subgoal): 1. (\<And>k' lholed' i'. Lfilled k' lholed' [$Br (k' + i')] es \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled k' lholed' [$Br (k' + i')] es goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] obtain \<C>' where c_def:"\<C>' = ((s_inst \<S>)!j)\<lparr>local := (local ((s_inst \<S>)!j)) @ (map typeof vls), return := Some ts\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>\<C>'. \<C>' = (s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<C>' = (s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence es_def:"\<S>\<bullet>\<C>' \<turnstile> es : ([] _> ts)" "j < length (s_inst \<S>)" [PROOF STATE] proof (prove) using this: \<C>' = (s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> goal (1 subgoal): 1. \<S>\<bullet>\<C>' \<turnstile> es : [] _> ts &&& j < length (s_inst \<S>) [PROOF STEP] using 5(1) s_type_unfold [PROOF STATE] proof (prove) using this: \<C>' = (s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> \<S>\<bullet>Some ts \<tturnstile>_ j vls;es : ts ?\<S>\<bullet>?rs \<tturnstile>_ ?i ?vs;?es : ?ts \<Longrightarrow> ?i < length (s_inst ?\<S>) ?\<S>\<bullet>?rs \<tturnstile>_ ?i ?vs;?es : ?ts \<Longrightarrow> ?rs = Some ?ts \<or> ?rs = None ?\<S>\<bullet>?rs \<tturnstile>_ ?i ?vs;?es : ?ts \<Longrightarrow> ?\<S>\<bullet>(s_inst ?\<S> ! ?i)\<lparr>local := local (s_inst ?\<S> ! ?i) @ map typeof ?vs, return := ?rs\<rparr> \<turnstile> ?es : [] _> ?ts goal (1 subgoal): 1. \<S>\<bullet>\<C>' \<turnstile> es : [] _> ts &&& j < length (s_inst \<S>) [PROOF STEP] by fastforce+ [PROOF STATE] proof (state) this: \<S>\<bullet>\<C>' \<turnstile> es : [] _> ts j < length (s_inst \<S>) goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence "length (label \<C>') = 0" [PROOF STATE] proof (prove) using this: \<S>\<bullet>\<C>' \<turnstile> es : [] _> ts j < length (s_inst \<S>) goal (1 subgoal): 1. length (label \<C>') = 0 [PROOF STEP] using c_def store_local_label_empty 5(12) [PROOF STATE] proof (prove) using this: \<S>\<bullet>\<C>' \<turnstile> es : [] _> ts j < length (s_inst \<S>) \<C>' = (s_inst \<S> ! j)\<lparr>local := local (s_inst \<S> ! j) @ map typeof vls, return := Some ts\<rparr> \<lbrakk>?i < length (s_inst ?\<S>); store_typing ?s ?\<S>\<rbrakk> \<Longrightarrow> label (s_inst ?\<S> ! ?i) = [] \<lbrakk>?i < length (s_inst ?\<S>); store_typing ?s ?\<S>\<rbrakk> \<Longrightarrow> local (s_inst ?\<S> ! ?i) = [] store_typing s \<S> goal (1 subgoal): 1. length (label \<C>') = 0 [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: length (label \<C>') = 0 goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k \<le> i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: length (label \<C>') = 0 goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using progress_LN1[OF temp1 es_def(1)] [PROOF STATE] proof (prove) using this: length (label \<C>') = 0 i' < length (label \<C>') goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by linarith [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (6 \<S> cl tf \<C>) [PROOF STATE] proof (state) this: cl_typing \<S> cl tf \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ [Callcl cl] const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] obtain ts'' where ts''_def:"\<S>\<bullet>\<C> \<turnstile> cs : ([] _> ts'')" "\<S>\<bullet>\<C> \<turnstile> [Callcl cl] : (ts'' _> ts')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>ts''. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs : [] _> ts''; \<S>\<bullet>\<C> \<turnstile> [Callcl cl] : ts'' _> ts'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using 6(2,3) e_type_comp_conc1 [PROOF STATE] proof (prove) using this: \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ [Callcl cl] ?\<S>\<bullet>?\<C> \<turnstile> ?es @ ?es' : ?ts _> ?ts' \<Longrightarrow> \<exists>ts''. ?\<S>\<bullet>?\<C> \<turnstile> ?es : ?ts _> ts'' \<and> ?\<S>\<bullet>?\<C> \<turnstile> ?es' : ts'' _> ?ts' goal (1 subgoal): 1. (\<And>ts''. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs : [] _> ts''; \<S>\<bullet>\<C> \<turnstile> [Callcl cl] : ts'' _> ts'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts'' \<S>\<bullet>\<C> \<turnstile> [Callcl cl] : ts'' _> ts' goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] obtain ts_c t1s t2s where cl_def:"(ts'' = ts_c @ t1s)" "(ts' = ts_c @ t2s)" "cl_type cl = (t1s _> t2s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>ts_c t1s t2s. \<lbrakk>ts'' = ts_c @ t1s; ts' = ts_c @ t2s; cl_type cl = t1s _> t2s\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using e_type_callcl[OF ts''_def(2)] [PROOF STATE] proof (prove) using this: \<exists>t1s t2s ts_c. ts'' = ts_c @ t1s \<and> ts' = ts_c @ t2s \<and> cl_type cl = t1s _> t2s goal (1 subgoal): 1. (\<And>ts_c t1s t2s. \<lbrakk>ts'' = ts_c @ t1s; ts' = ts_c @ t2s; cl_type cl = t1s _> t2s\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: ts'' = ts_c @ t1s ts' = ts_c @ t2s cl_type cl = t1s _> t2s goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] obtain vs1 vs2 where vs_def:"\<S>\<bullet>\<C> \<turnstile> vs1 : ([] _> ts_c)" "\<S>\<bullet>\<C> \<turnstile> vs2 : (ts_c _> ts_c @ t1s)" "cs = vs1 @ vs2" "const_list vs1" "const_list vs2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>vs1 vs2. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> vs1 : [] _> ts_c; \<S>\<bullet>\<C> \<turnstile> vs2 : ts_c _> ts_c @ t1s; cs = vs1 @ vs2; const_list vs1; const_list vs2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using e_type_const_list_cons[OF 6(4)] ts''_def(1) cl_def(1) [PROOF STATE] proof (prove) using this: ?\<S>\<bullet>?\<C> \<turnstile> cs : [] _> ?ts1.0 @ ?ts2.0 \<Longrightarrow> \<exists>vs1 vs2. ?\<S>\<bullet>?\<C> \<turnstile> vs1 : [] _> ?ts1.0 \<and> ?\<S>\<bullet>?\<C> \<turnstile> vs2 : ?ts1.0 _> ?ts1.0 @ ?ts2.0 \<and> cs = vs1 @ vs2 \<and> const_list vs1 \<and> const_list vs2 \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts'' ts'' = ts_c @ t1s goal (1 subgoal): 1. (\<And>vs1 vs2. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> vs1 : [] _> ts_c; \<S>\<bullet>\<C> \<turnstile> vs2 : ts_c _> ts_c @ t1s; cs = vs1 @ vs2; const_list vs1; const_list vs2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<S>\<bullet>\<C> \<turnstile> vs1 : [] _> ts_c \<S>\<bullet>\<C> \<turnstile> vs2 : ts_c _> ts_c @ t1s cs = vs1 @ vs2 const_list vs1 const_list vs2 goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] have l:"(length vs2) = (length t1s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. length vs2 = length t1s [PROOF STEP] using e_type_const_list vs_def(2,5) [PROOF STATE] proof (prove) using this: \<lbrakk>const_list ?vs; ?\<S>\<bullet>?\<C> \<turnstile> ?vs : ?ts _> ?ts'\<rbrakk> \<Longrightarrow> \<exists>tvs. ?ts' = ?ts @ tvs \<and> length ?vs = length tvs \<and> ?\<S>\<bullet>?\<C>' \<turnstile> ?vs : [] _> tvs \<S>\<bullet>\<C> \<turnstile> vs2 : ts_c _> ts_c @ t1s const_list vs2 goal (1 subgoal): 1. length vs2 = length t1s [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: length vs2 = length t1s goal (3 subgoals): 1. \<And>\<S> cl tf \<C> vs ts_c ts' i cs_es cs. \<lbrakk>cl_typing \<S> cl tf; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Callcl cl]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 3. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] proof (cases cl) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>x11 x12 x13 x14. cl = Func_native x11 x12 x13 x14 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case (Func_native x11 x12 x13 x14) [PROOF STATE] proof (state) this: cl = Func_native x11 x12 x13 x14 goal (2 subgoals): 1. \<And>x11 x12 x13 x14. cl = Func_native x11 x12 x13 x14 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence func_native_def:"cl = Func_native x11 (t1s _> t2s) x13 x14" [PROOF STATE] proof (prove) using this: cl = Func_native x11 x12 x13 x14 goal (1 subgoal): 1. cl = Func_native x11 (t1s _> t2s) x13 x14 [PROOF STEP] using cl_def(3) [PROOF STATE] proof (prove) using this: cl = Func_native x11 x12 x13 x14 cl_type cl = t1s _> t2s goal (1 subgoal): 1. cl = Func_native x11 (t1s _> t2s) x13 x14 [PROOF STEP] unfolding cl_type_def [PROOF STATE] proof (prove) using this: cl = Func_native x11 x12 x13 x14 (case cl of Func_native x tf xa xb \<Rightarrow> tf | Func_host tf x \<Rightarrow> tf) = t1s _> t2s goal (1 subgoal): 1. cl = Func_native x11 (t1s _> t2s) x13 x14 [PROOF STEP] by simp [PROOF STATE] proof (state) this: cl = Func_native x11 (t1s _> t2s) x13 x14 goal (2 subgoals): 1. \<And>x11 x12 x13 x14. cl = Func_native x11 x12 x13 x14 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr> [PROOF STEP] using reduce.intros(5)[OF func_native_def] e_type_const_conv_vs[OF vs_def(5)] l [PROOF STATE] proof (prove) using this: \<lbrakk>?ves = $$* ?vcs; length ?vcs = ?n; length x13 = ?k; length t1s = ?n; length t2s = ?m; n_zeros x13 = ?zs\<rbrakk> \<Longrightarrow> \<lparr>?s;?vs;?ves @ [Callcl cl]\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;[Local ?m x11 (?vcs @ ?zs) [$Block ([] _> t2s) x14]]\<rparr> \<exists>vs. vs2 = $$* vs length vs2 = length t1s goal (1 subgoal): 1. \<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr> [PROOF STEP] unfolding n_zeros_def [PROOF STATE] proof (prove) using this: \<lbrakk>?ves = $$* ?vcs; length ?vcs = ?n; length x13 = ?k; length t1s = ?n; length t2s = ?m; map bitzero x13 = ?zs\<rbrakk> \<Longrightarrow> \<lparr>?s;?vs;?ves @ [Callcl cl]\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;[Local ?m x11 (?vcs @ ?zs) [$Block ([] _> t2s) x14]]\<rparr> \<exists>vs. vs2 = $$* vs length vs2 = length t1s goal (1 subgoal): 1. \<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr> goal (2 subgoals): 1. \<And>x11 x12 x13 x14. cl = Func_native x11 x12 x13 x14 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: \<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using progress_L0 vs_def(3,4) 6(3) [PROOF STATE] proof (prove) using this: \<exists>a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s;vs;a\<rparr> \<lbrakk>\<lparr>?s;?vs;?es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr>; const_list ?cs\<rbrakk> \<Longrightarrow> \<lparr>?s;?vs;?cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?cs @ ?es' @ ?es_c\<rparr> cs = vs1 @ vs2 const_list vs1 cs_es = cs @ [Callcl cl] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case (Func_host x21 x22) [PROOF STATE] proof (state) this: cl = Func_host x21 x22 goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence func_host_def:"cl = Func_host (t1s _> t2s) x22" [PROOF STATE] proof (prove) using this: cl = Func_host x21 x22 goal (1 subgoal): 1. cl = Func_host (t1s _> t2s) x22 [PROOF STEP] using cl_def(3) [PROOF STATE] proof (prove) using this: cl = Func_host x21 x22 cl_type cl = t1s _> t2s goal (1 subgoal): 1. cl = Func_host (t1s _> t2s) x22 [PROOF STEP] unfolding cl_type_def [PROOF STATE] proof (prove) using this: cl = Func_host x21 x22 (case cl of Func_native x tf xa xb \<Rightarrow> tf | Func_host tf x \<Rightarrow> tf) = t1s _> t2s goal (1 subgoal): 1. cl = Func_host (t1s _> t2s) x22 [PROOF STEP] by simp [PROOF STATE] proof (state) this: cl = Func_host (t1s _> t2s) x22 goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] obtain vcs where vcs_def:"vs2 = $$* vcs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>vcs. vs2 = $$* vcs \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using e_type_const_conv_vs[OF vs_def(5)] [PROOF STATE] proof (prove) using this: \<exists>vs. vs2 = $$* vs goal (1 subgoal): 1. (\<And>vcs. vs2 = $$* vcs \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: vs2 = $$* vcs goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] fix hs [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] proof (cases "host_apply s (t1s _> t2s) x22 vcs hs") [PROOF STATE] proof (state) goal (2 subgoals): 1. host_apply s (t1s _> t2s) x22 vcs hs = None \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> 2. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] case None [PROOF STATE] proof (state) this: host_apply s (t1s _> t2s) x22 vcs hs = None goal (2 subgoals): 1. host_apply s (t1s _> t2s) x22 vcs hs = None \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> 2. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: host_apply s (t1s _> t2s) x22 vcs hs = None goal (1 subgoal): 1. \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] using reduce.intros(7)[OF func_host_def] l vcs_def [PROOF STATE] proof (prove) using this: host_apply s (t1s _> t2s) x22 vcs hs = None \<lbrakk>?ves = $$* ?vcs; length ?vcs = ?n; length t1s = ?n; length t2s = ?m\<rbrakk> \<Longrightarrow> \<lparr>?s;?vs;?ves @ [Callcl cl]\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;[Trap]\<rparr> length vs2 = length t1s vs2 = $$* vcs goal (1 subgoal): 1. \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> goal (1 subgoal): 1. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] case (Some a) [PROOF STATE] proof (state) this: host_apply s (t1s _> t2s) x22 vcs hs = Some a goal (1 subgoal): 1. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: host_apply s (t1s _> t2s) x22 vcs hs = Some a [PROOF STEP] obtain s' vcs' where ha_def:"host_apply s (t1s _> t2s) x22 vcs hs = Some (s', vcs')" [PROOF STATE] proof (prove) using this: host_apply s (t1s _> t2s) x22 vcs hs = Some a goal (1 subgoal): 1. (\<And>s' vcs'. host_apply s (t1s _> t2s) x22 vcs hs = Some (s', vcs') \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (metis surj_pair) [PROOF STATE] proof (state) this: host_apply s (t1s _> t2s) x22 vcs hs = Some (s', vcs') goal (1 subgoal): 1. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] have "list_all2 types_agree t1s vcs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. list_all2 types_agree t1s vcs [PROOF STEP] using e_typing_imp_list_types_agree vs_def(2,4) vcs_def [PROOF STATE] proof (prove) using this: ?\<S>\<bullet>?\<C> \<turnstile> $$* ?vs : ?ts' _> ?ts' @ ?ts \<Longrightarrow> list_all2 types_agree ?ts ?vs \<S>\<bullet>\<C> \<turnstile> vs2 : ts_c _> ts_c @ t1s const_list vs1 vs2 = $$* vcs goal (1 subgoal): 1. list_all2 types_agree t1s vcs [PROOF STEP] by simp [PROOF STATE] proof (state) this: list_all2 types_agree t1s vcs goal (1 subgoal): 1. \<And>a. host_apply s (t1s _> t2s) x22 vcs hs = Some a \<Longrightarrow> \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: list_all2 types_agree t1s vcs goal (1 subgoal): 1. \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] using reduce.intros(6)[OF func_host_def _ _ _ _ ha_def] l vcs_def host_apply_respect_type[OF _ ha_def] [PROOF STATE] proof (prove) using this: list_all2 types_agree t1s vcs \<lbrakk>?ves = $$* vcs; length vcs = ?n; length t1s = ?n; length t2s = ?m\<rbrakk> \<Longrightarrow> \<lparr>s;?vs;?ves @ [Callcl cl]\<rparr> \<leadsto>_ ?i \<lparr>s';?vs;$$* vcs'\<rparr> length vs2 = length t1s vs2 = $$* vcs list_all2 types_agree t1s vcs \<Longrightarrow> list_all2 types_agree t2s vcs' goal (1 subgoal): 1. \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> goal (1 subgoal): 1. \<And>x21 x22. cl = Func_host x21 x22 \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using vs_def(3,4) 6(3) progress_L0 [PROOF STATE] proof (prove) using this: \<exists>s' a a'. \<lparr>s;vs;vs2 @ [Callcl cl]\<rparr> \<leadsto>_ i \<lparr>s';vs;a\<rparr> cs = vs1 @ vs2 const_list vs1 cs_es = cs @ [Callcl cl] \<lbrakk>\<lparr>?s;?vs;?es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr>; const_list ?cs\<rbrakk> \<Longrightarrow> \<lparr>?s;?vs;?cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?cs @ ?es' @ ?es_c\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (2 subgoals): 1. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (7 \<S> \<C> e0s ts t2s es n) [PROOF STATE] proof (state) this: \<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s length ts = n \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ e0s; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ es; const_list ?cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length ?vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts' cs_es = cs @ [Label n e0s es] const_list cs \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c \<not> Lfilled ?k ?lholed [$Return] cs_es Lfilled ?k ?lholed [$Br ?i] cs_es \<Longrightarrow> ?i < ?k cs_es \<noteq> [Trap] \<not> const_list cs_es store_typing s \<S> i < length (s_inst \<S>) length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (2 subgoals): 1. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] consider (1) "(\<And>k lholed. \<not> Lfilled k lholed [$Return] es)" "(\<And>k lholed i. (Lfilled k lholed [$Br i] es) \<Longrightarrow> i < k)" "es \<noteq> [Trap]" "\<not> const_list es" | (2) "\<exists>k lholed. Lfilled k lholed [$Return] es" | (3) "const_list es \<or> (es = [Trap])" | (4) "\<exists>k lholed i. (Lfilled k lholed [$Br i] es) \<and> i = k" | (5) "\<exists>k lholed i. (Lfilled k lholed [$Br i] es) \<and> i > k" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> thesis; const_list es \<or> es = [Trap] \<Longrightarrow> thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] using linorder_neqE_nat [PROOF STATE] proof (prove) using this: \<lbrakk>?x \<noteq> ?y; ?x < ?y \<Longrightarrow> ?R; ?y < ?x \<Longrightarrow> ?R\<rbrakk> \<Longrightarrow> ?R goal (1 subgoal): 1. \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> thesis; const_list es \<or> es = [Trap] \<Longrightarrow> thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> ?thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> ?thesis; const_list es \<or> es = [Trap] \<Longrightarrow> ?thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> ?thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (2 subgoals): 1. \<And>\<S> \<C> e0s ts t2s es n vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> e0s : ts _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ e0s; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> es : [] _> t2s; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); length ts = n; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ [Label n e0s es]; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs') 2. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: \<lbrakk>\<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> ?thesis; \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> ?thesis; const_list es \<or> es = [Trap] \<Longrightarrow> ?thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> ?thesis; \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] proof (cases) [PROOF STATE] proof (state) goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 1 [PROOF STATE] proof (state) this: \<not> Lfilled ?k ?lholed [$Return] es Lfilled ?k ?lholed [$Br ?i] es \<Longrightarrow> ?i < ?k es \<noteq> [Trap] \<not> const_list es goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have temp1:"es = [] @ es" "const_list []" [PROOF STATE] proof (prove) goal (1 subgoal): 1. es = [] @ es &&& const_list [] [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. es = [] @ es &&& list_all is_const [] [PROOF STEP] by auto [PROOF STATE] proof (state) this: es = [] @ es const_list [] goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have temp2:"\<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> [] : ([] _> [])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> [] : [] _> [] [PROOF STEP] using b_e_typing.empty e_typing_s_typing.intros(1) [PROOF STATE] proof (prove) using this: ?\<C> \<turnstile> [] : [] _> [] ?\<C> \<turnstile> ?b_es : ?tf \<Longrightarrow> ?\<S>\<bullet>?\<C> \<turnstile> $* ?b_es : ?tf goal (1 subgoal): 1. \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> [] : [] _> [] [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<S>\<bullet>\<C>\<lparr>label := [ts] @ label \<C>\<rparr> \<turnstile> [] : [] _> [] goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> [PROOF STEP] using 7(5)[OF 7(2), of "[]" "[]", OF temp1 temp2 1(1) _ 1(3,4) 7(14,15)] 1(2) 7(16,17) [PROOF STATE] proof (prove) using this: \<lbrakk>\<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length ?vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> Lfilled ?k ?lholed [$Br ?i] es \<Longrightarrow> ?i < ?k length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: \<lbrakk>\<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; length (local (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = length ?vs; Option.is_none (memory (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>)) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> Lfilled ?k ?lholed [$Br ?i] es \<Longrightarrow> ?i < ?k length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> [PROOF STEP] obtain s' vs' a where red_def:"\<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr>" [PROOF STATE] proof (prove) using this: \<exists>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> goal (1 subgoal): 1. (\<And>s' vs' a. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have temp4:"\<And>es. Lfilled 0 (LBase [] []) es es" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>es. Lfilled 0 (LBase [] []) es es [PROOF STEP] using Lfilled.intros(1)[of "[]" "(LBase [] [])" "[]"] [PROOF STATE] proof (prove) using this: \<lbrakk>const_list []; LBase [] [] = LBase [] []\<rbrakk> \<Longrightarrow> Lfilled 0 (LBase [] []) ?es ([] @ ?es @ []) goal (1 subgoal): 1. \<And>es. Lfilled 0 (LBase [] []) es es [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: \<lbrakk>list_all is_const []; LBase [] [] = LBase [] []\<rbrakk> \<Longrightarrow> Lfilled 0 (LBase [] []) ?es ([] @ ?es @ []) goal (1 subgoal): 1. \<And>es. Lfilled 0 (LBase [] []) es es [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled 0 (LBase [] []) ?es ?es goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence temp5:"Lfilled 1 (LRec cs n e0s (LBase [] []) []) es (cs@[Label n e0s es])" [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase [] []) ?es ?es goal (1 subgoal): 1. Lfilled 1 (LRec cs n e0s (LBase [] []) []) es (cs @ [Label n e0s es]) [PROOF STEP] using Lfilled.intros(2)[of cs "(LRec cs n e0s (LBase [] []) [])" n e0s "(LBase [] [])" "[]" 0 es es] 7(8) [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase [] []) ?es ?es \<lbrakk>const_list cs; LRec cs n e0s (LBase [] []) [] = LRec cs n e0s (LBase [] []) []; Lfilled 0 (LBase [] []) es es\<rbrakk> \<Longrightarrow> Lfilled (0 + 1) (LRec cs n e0s (LBase [] []) []) es (cs @ [Label n e0s es] @ []) const_list cs goal (1 subgoal): 1. Lfilled 1 (LRec cs n e0s (LBase [] []) []) es (cs @ [Label n e0s es]) [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase [] []) ?es ?es \<lbrakk>list_all is_const cs; LRec cs n e0s (LBase [] []) [] = LRec cs n e0s (LBase [] []) []; Lfilled 0 (LBase [] []) es es\<rbrakk> \<Longrightarrow> Lfilled (0 + 1) (LRec cs n e0s (LBase [] []) []) es (cs @ [Label n e0s es] @ []) list_all is_const cs goal (1 subgoal): 1. Lfilled 1 (LRec cs n e0s (LBase [] []) []) es (cs @ [Label n e0s es]) [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled 1 (LRec cs n e0s (LBase [] []) []) es (cs @ [Label n e0s es]) goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have temp6:"Lfilled 1 (LRec cs n e0s (LBase [] []) []) a (cs@[Label n e0s a])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Lfilled 1 (LRec cs n e0s (LBase [] []) []) a (cs @ [Label n e0s a]) [PROOF STEP] using temp4 Lfilled.intros(2)[of cs "(LRec cs n e0s (LBase [] []) [])" n e0s "(LBase [] [])" "[]" 0 a a] 7(8) [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase [] []) ?es ?es \<lbrakk>const_list cs; LRec cs n e0s (LBase [] []) [] = LRec cs n e0s (LBase [] []) []; Lfilled 0 (LBase [] []) a a\<rbrakk> \<Longrightarrow> Lfilled (0 + 1) (LRec cs n e0s (LBase [] []) []) a (cs @ [Label n e0s a] @ []) const_list cs goal (1 subgoal): 1. Lfilled 1 (LRec cs n e0s (LBase [] []) []) a (cs @ [Label n e0s a]) [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: Lfilled 0 (LBase [] []) ?es ?es \<lbrakk>list_all is_const cs; LRec cs n e0s (LBase [] []) [] = LRec cs n e0s (LBase [] []) []; Lfilled 0 (LBase [] []) a a\<rbrakk> \<Longrightarrow> Lfilled (0 + 1) (LRec cs n e0s (LBase [] []) []) a (cs @ [Label n e0s a] @ []) list_all is_const cs goal (1 subgoal): 1. Lfilled 1 (LRec cs n e0s (LBase [] []) []) a (cs @ [Label n e0s a]) [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled 1 (LRec cs n e0s (LBase [] []) []) a (cs @ [Label n e0s a]) goal (5 subgoals): 1. \<lbrakk>\<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>k lholed i. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 5. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using reduce.intros(23)[OF _ temp5 temp6] 7(7) red_def [PROOF STATE] proof (prove) using this: \<lparr>?s;?vs;es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';a\<rparr> \<Longrightarrow> \<lparr>?s;?vs;cs @ [Label n e0s es]\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';cs @ [Label n e0s a]\<rparr> cs_es = cs @ [Label n e0s es] \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';a\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (4 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (4 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 2 [PROOF STATE] proof (state) this: \<exists>k lholed. Lfilled k lholed [$Return] es goal (4 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>k lholed. Lfilled k lholed [$Return] es [PROOF STEP] obtain k lholed where "(Lfilled k lholed [$Return] es)" [PROOF STATE] proof (prove) using this: \<exists>k lholed. Lfilled k lholed [$Return] es goal (1 subgoal): 1. (\<And>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled k lholed [$Return] es goal (4 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence "(Lfilled (k+1) (LRec cs n e0s lholed []) [$Return] (cs@[Label n e0s es]))" [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Return] es goal (1 subgoal): 1. Lfilled (k + 1) (LRec cs n e0s lholed []) [$Return] (cs @ [Label n e0s es]) [PROOF STEP] using Lfilled.intros(2) 7(8) [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Return] es \<lbrakk>const_list ?vs; ?lholed = LRec ?vs ?n ?es' ?l ?es''; Lfilled ?k ?l ?es ?lfilledk\<rbrakk> \<Longrightarrow> Lfilled (?k + 1) ?lholed ?es (?vs @ [Label ?n ?es' ?lfilledk] @ ?es'') const_list cs goal (1 subgoal): 1. Lfilled (k + 1) (LRec cs n e0s lholed []) [$Return] (cs @ [Label n e0s es]) [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled (k + 1) (LRec cs n e0s lholed []) [$Return] (cs @ [Label n e0s es]) goal (4 subgoals): 1. \<exists>k lholed. Lfilled k lholed [$Return] es \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 4. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: Lfilled (k + 1) (LRec cs n e0s lholed []) [$Return] (cs @ [Label n e0s es]) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using 7(10)[of "k+1"] 7(7) [PROOF STATE] proof (prove) using this: Lfilled (k + 1) (LRec cs n e0s lholed []) [$Return] (cs @ [Label n e0s es]) \<not> Lfilled (k + 1) ?lholed [$Return] cs_es cs_es = cs @ [Label n e0s es] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (3 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (3 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 3 [PROOF STATE] proof (state) this: const_list es \<or> es = [Trap] goal (3 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence temp1:"\<exists>a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr>" [PROOF STATE] proof (prove) using this: const_list es \<or> es = [Trap] goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] using reduce_simple.label_const reduce_simple.label_trap reduce.intros(1) [PROOF STATE] proof (prove) using this: const_list es \<or> es = [Trap] const_list ?vs \<Longrightarrow> \<lparr>[Label ?n ?es ?vs]\<rparr> \<leadsto> \<lparr>?vs\<rparr> \<lparr>[Label ?n ?es [Trap]]\<rparr> \<leadsto> \<lparr>[Trap]\<rparr> \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> goal (1 subgoal): 1. \<exists>a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> goal (3 subgoals): 1. const_list es \<or> es = [Trap] \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 3. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using progress_L0[OF _ 7(8)] 7(7) temp1 [PROOF STATE] proof (prove) using this: \<lparr>?s;?vs;?es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';cs @ ?es' @ ?es_c\<rparr> cs_es = cs @ [Label n e0s es] \<exists>a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 4 [PROOF STATE] proof (state) this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k [PROOF STEP] obtain k lholed where lholed_def:"(Lfilled k lholed [$Br (k+0)] es)" [PROOF STATE] proof (prove) using this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k goal (1 subgoal): 1. (\<And>k lholed. Lfilled k lholed [$Br (k + 0)] es \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled k lholed [$Br (k + 0)] es goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: Lfilled k lholed [$Br (k + 0)] es [PROOF STEP] obtain lholed' vs' \<C>' where lholed'_def:"(Lfilled k lholed' (vs'@[$Br (k)]) es)" "\<S>\<bullet>\<C>' \<turnstile> vs' : ([] _> ts)" "const_list vs'" [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Br (k + 0)] es goal (1 subgoal): 1. (\<And>lholed' vs' \<C>'. \<lbrakk>Lfilled k lholed' (vs' @ [$Br k]) es; \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts; const_list vs'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using progress_LN[OF lholed_def 7(2), of ts] [PROOF STATE] proof (prove) using this: Lfilled k lholed [$Br (k + 0)] es label (\<C>\<lparr>label := [ts] @ label \<C>\<rparr>) ! 0 = ts \<Longrightarrow> \<exists>lholed' vs \<C>'. Lfilled k lholed' (vs @ [$Br (k + 0)]) es \<and> \<S>\<bullet>\<C>' \<turnstile> vs : [] _> ts \<and> const_list vs goal (1 subgoal): 1. (\<And>lholed' vs' \<C>'. \<lbrakk>Lfilled k lholed' (vs' @ [$Br k]) es; \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts; const_list vs'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled k lholed' (vs' @ [$Br k]) es \<S>\<bullet>\<C>' \<turnstile> vs' : [] _> ts const_list vs' goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] have "\<exists>es' a. \<lparr>[Label n e0s es]\<rparr> \<leadsto> \<lparr>vs'@e0s\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>es' a. \<lparr>[Label n e0s es]\<rparr> \<leadsto> \<lparr>vs' @ e0s\<rparr> [PROOF STEP] using reduce_simple.br[OF lholed'_def(3) _ lholed'_def(1)] 7(3) e_type_const_list[OF lholed'_def(3,2)] [PROOF STATE] proof (prove) using this: length vs' = ?n \<Longrightarrow> \<lparr>[Label ?n ?es es]\<rparr> \<leadsto> \<lparr>vs' @ ?es\<rparr> length ts = n \<exists>tvs. ts = [] @ tvs \<and> length vs' = length tvs \<and> \<S>\<bullet>?\<C>' \<turnstile> vs' : [] _> tvs goal (1 subgoal): 1. \<exists>es' a. \<lparr>[Label n e0s es]\<rparr> \<leadsto> \<lparr>vs' @ e0s\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>es' a. \<lparr>[Label n e0s es]\<rparr> \<leadsto> \<lparr>vs' @ e0s\<rparr> goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] hence "\<exists>es' a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es'\<rparr>" [PROOF STATE] proof (prove) using this: \<exists>es' a. \<lparr>[Label n e0s es]\<rparr> \<leadsto> \<lparr>vs' @ e0s\<rparr> goal (1 subgoal): 1. \<exists>es' a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es'\<rparr> [PROOF STEP] using reduce.intros(1) [PROOF STATE] proof (prove) using this: \<exists>es' a. \<lparr>[Label n e0s es]\<rparr> \<leadsto> \<lparr>vs' @ e0s\<rparr> \<lparr>?e\<rparr> \<leadsto> \<lparr>?e'\<rparr> \<Longrightarrow> \<lparr>?s;?vs;?e\<rparr> \<leadsto>_ ?i \<lparr>?s;?vs;?e'\<rparr> goal (1 subgoal): 1. \<exists>es' a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es'\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>es' a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es'\<rparr> goal (2 subgoals): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> i = k \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> 2. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: \<exists>es' a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es'\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using progress_L0 7(7,8) [PROOF STATE] proof (prove) using this: \<exists>es' a. \<lparr>s;vs;[Label n e0s es]\<rparr> \<leadsto>_ i \<lparr>s;vs;es'\<rparr> \<lbrakk>\<lparr>?s;?vs;?es\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?es'\<rparr>; const_list ?cs\<rbrakk> \<Longrightarrow> \<lparr>?s;?vs;?cs @ ?es @ ?es_c\<rparr> \<leadsto>_ ?i \<lparr>?s';?vs';?cs @ ?es' @ ?es_c\<rparr> cs_es = cs @ [Label n e0s es] const_list cs goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] case 5 [PROOF STATE] proof (state) this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i [PROOF STEP] obtain i k lholed where lholed_def:"(Lfilled k lholed [$Br i] es)" "i > k" [PROOF STATE] proof (prove) using this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i goal (1 subgoal): 1. (\<And>k lholed i. \<lbrakk>Lfilled k lholed [$Br i] es; k < i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using less_imp_add_positive [PROOF STATE] proof (prove) using this: \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i ?i < ?j \<Longrightarrow> \<exists>k>0. ?i + k = ?j goal (1 subgoal): 1. (\<And>k lholed i. \<lbrakk>Lfilled k lholed [$Br i] es; k < i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: Lfilled k lholed [$Br i] es k < i goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ ia__ \<lparr>s';vs';b\<rparr> [PROOF STEP] have k1_def:"Lfilled (k+1) (LRec cs n e0s lholed []) [$Br i] cs_es" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Lfilled (k + 1) (LRec cs n e0s lholed []) [$Br i] cs_es [PROOF STEP] using 7(7) Lfilled.intros(2)[OF 7(8) _ lholed_def(1), of _ n e0s "[]"] [PROOF STATE] proof (prove) using this: cs_es = cs @ [Label n e0s es] ?lholed = LRec cs n e0s lholed [] \<Longrightarrow> Lfilled (k + 1) ?lholed [$Br i] (cs @ [Label n e0s es] @ []) goal (1 subgoal): 1. Lfilled (k + 1) (LRec cs n e0s lholed []) [$Br i] cs_es [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: Lfilled (k + 1) (LRec cs n e0s lholed []) [$Br i] cs_es goal (1 subgoal): 1. \<exists>k lholed i. Lfilled k lholed [$Br i] es \<and> k < i \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ ia__ \<lparr>s';vs';b\<rparr> [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: Lfilled (k + 1) (LRec cs n e0s lholed []) [$Br i] cs_es goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ ia__ \<lparr>s';vs';b\<rparr> [PROOF STEP] using 7(11)[OF k1_def] lholed_def(2) [PROOF STATE] proof (prove) using this: Lfilled (k + 1) (LRec cs n e0s lholed []) [$Br i] cs_es i < k + 1 k < i goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ ia__ \<lparr>s';vs';b\<rparr> [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ ia__ \<lparr>s';vs';b\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal (1 subgoal): 1. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] case (8 i \<S> tvs vs \<C> rs es ts) [PROOF STATE] proof (state) this: i < length (s_inst \<S>) tvs = map typeof vs \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr> \<S>\<bullet>\<C> \<turnstile> es : [] _> ts rs = Some ts \<or> rs = None \<lbrakk>\<S>\<bullet>\<C> \<turnstile> ?cs_es : [] _> ?ts'; ?cs_es = ?cs @ es; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] ?cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] ?cs_es \<Longrightarrow> i < k; ?cs_es \<noteq> [Trap]; \<not> const_list ?cs_es; store_typing s \<S>; ?i < length (s_inst \<S>); length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! ?i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;?cs_es\<rparr> \<leadsto>_ ?i \<lparr>s';vs';b\<rparr> \<not> Lfilled ?k ?lholed [$Return] es Lfilled ?k ?lholed [$Br ?i] es \<Longrightarrow> ?i < ?k es \<noteq> [Trap] \<not> const_list es store_typing s \<S> goal (1 subgoal): 1. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] have "length (local \<C>) = length vs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. length (local \<C>) = length vs [PROOF STEP] using 8(2,3) store_local_label_empty[OF 8(1,11)] [PROOF STATE] proof (prove) using this: tvs = map typeof vs \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr> label (s_inst \<S> ! i) = [] local (s_inst \<S> ! i) = [] goal (1 subgoal): 1. length (local \<C>) = length vs [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: length (local \<C>) = length vs goal (1 subgoal): 1. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] moreover [PROOF STATE] proof (state) this: length (local \<C>) = length vs goal (1 subgoal): 1. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] have "Option.is_none (memory \<C>) = Option.is_none (inst.mem ((inst s)!i))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) [PROOF STEP] using store_mem_exists[OF 8(1,11)] 8(3) [PROOF STATE] proof (prove) using this: Option.is_none (memory (s_inst \<S> ! i)) = Option.is_none (inst.mem (inst s ! i)) \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr> goal (1 subgoal): 1. Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) [PROOF STEP] by simp [PROOF STATE] proof (state) this: Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<And>i \<S> tvs vs \<C> rs es ts. \<lbrakk>i < length (s_inst \<S>); tvs = map typeof vs; \<C> = (s_inst \<S> ! i)\<lparr>local := local (s_inst \<S> ! i) @ tvs, return := rs\<rparr>; \<S>\<bullet>\<C> \<turnstile> es : [] _> ts; \<And>vs ts_c ts' i cs_es cs. \<lbrakk>\<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs cs_es i s' vs'); rs = Some ts \<or> rs = None; \<And>k lholed. \<not> Lfilled k lholed [$Return] es; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> i < k; es \<noteq> [Trap]; \<not> const_list es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs'. Ex (reduce s vs es i s' vs') [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] using 8(6)[OF 8(4) _ _ _ 8(7,8,9,10,11,1)] e_typing_s_typing.intros(1)[OF b_e_typing.empty[of \<C>]] [PROOF STATE] proof (prove) using this: length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) \<lbrakk>es = ?cs @ es; const_list ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> Lfilled k (?lholed1 i k lholed) [$Br i] es; length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> ?\<S>\<bullet>\<C> \<turnstile> $* [] : [] _> [] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] unfolding const_list_def [PROOF STATE] proof (prove) using this: length (local \<C>) = length vs Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i)) \<lbrakk>es = ?cs @ es; list_all is_const ?cs; \<S>\<bullet>\<C> \<turnstile> ?cs : [] _> ?ts_c; \<And>i k lholed. Lfilled k lholed [$Br i] es \<Longrightarrow> Lfilled k (?lholed1 i k lholed) [$Br i] es; length (local \<C>) = length ?vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' b. \<lparr>s;?vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> ?\<S>\<bullet>\<C> \<turnstile> $* [] : [] _> [] goal (1 subgoal): 1. \<exists>a s' vs' b. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' b. \<lparr>s;vs;es\<rparr> \<leadsto>_ i \<lparr>s';vs';b\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<lbrakk>\<S>\<bullet>\<C> \<turnstile> es : ts_c _> ts'; \<S>\<bullet>\<C> \<turnstile> cs_es : [] _> ts'; cs_es = cs @ es; const_list cs; \<S>\<bullet>\<C> \<turnstile> cs : [] _> ts_c; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>; i < length (s_inst \<S>); length (local \<C>) = length vs; Option.is_none (memory \<C>) = Option.is_none (inst.mem (inst s ! i))\<rbrakk> \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';cs_es'\<rparr> \<lbrakk>\<S>\<bullet>None \<tturnstile>_ i vs;cs_es : ts'; \<And>k lholed. \<not> Lfilled k lholed [$Return] cs_es; \<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> i < k; cs_es \<noteq> [Trap]; \<not> const_list cs_es; store_typing s \<S>\<rbrakk> \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';cs_es'\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> [PROOF STEP] using prems2[OF assms] [PROOF STATE] proof (prove) using this: (\<And>i k lholed. Lfilled k lholed [$Br i] cs_es \<Longrightarrow> Lfilled k (?lholed2 i k lholed) [$Br i] cs_es) \<Longrightarrow> \<exists>a s' vs' cs_es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';cs_es'\<rparr> goal (1 subgoal): 1. \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>a s' vs' es'. \<lparr>s;vs;cs_es\<rparr> \<leadsto>_ i \<lparr>s';vs';es'\<rparr> goal: No subgoals! [PROOF STEP] qed
controversy pull behind engineer perspective outcome limitation frustration parent opinion elderly site pay nature status though attach against blood all PC fly cotton clock odds democratic fair defendant dimension reject lady airport metal champion conclusion lover conventional lunch surface affair characteristic fight assumption demonstration dramatically either constantly ever it extent drug scheme question theory exciting nine regulation make testify habit dispute vary mind anyone rich one catch ocean Indian accident amazing rank available uniform truth sing vulnerable base individual tribe modern association original perceive illness tonight museum operator indeed lift deeply emerge pleasure wide spend vessel page side progress setting lost kid variable blame description toss volunteer transition succeed bite employment return consist stare thank assist signal scandal cognitive alcohol efficient boat concrete through guy doctor big night interview detail say entire ie provide count stake medium pick wait stir insist contain together eight change odd Jewish prominent small deputy moderate which shout immediately working debate Christian bunch assignment European worth chair mainly hi expense tail vast electric later federal contract both wave favorite decade lab killing division founder commander time attempt formation involve attitude ethnic short require defensive preference acknowledge without gesture enforcement stock credit lifetime headquarters approximately cope cheese adopt preserve reform addition expensive gold flight comedy satisfy acid anticipate merely initially testimony ahead obligation brick index continued literally narrow horizon visual energy drop cooperation experiment tournament defend swing Muslim delay justify terms art proposal joy document Arab comprehensive finance implication bag process administrator home consume detailed silver normal investigator principal each advocate whether double because gear else increasingly tomato department hand pop willing other series stream appropriate herself authority chain cloud conservative trick heaven lake television chase appeal easily studio should independent until friend imply margin lower contest origin slip tired oven suppose farmer confirm uncle grass buy regularly learning wing assault budget chocolate crowd corporation out spread event particularly childhood crazy outside lemon button like father every championship die resemble bright influence suddenly degree strengthen alliance general treaty household overall barrier pilot weight lock shoe language cookie interesting contemporary tennis toe join province apart private focus analyst mix or rapidly nowhere submit nonetheless mess AIDS calculate satisfaction biological inflation punishment disagree survey clothing sorry possibly senator toward role feeling library entrance row hero awareness incredible airline number ear decrease ice improve owner minister record intervention roof vote complicated sake average beautiful thus mystery governor extreme board swim course computer eastern politician viewer wine late form percentage start marry building mark accuse break morning leadership ten reporter stone pretty personal terrible guest cop nomination extremely security force day Senate jail practice yield shoulder them chart tall summer month function rise girl wheel soft fat personnel dinner bus track fashion almost muscle company straight speed limited running boyfriend prison exist entry gender field depth pure candidate police complaint inspire storm disorder neighbor tip license quick relax works and miss magazine below silent valuable athletic alive engineering temperature chamber square
EJ Healers, Inc is simply a tool to connect with people, share our gifts and talents, and market awareness and hope. EJ Healers, Inc in the business of hope and its purpose is to promote effortless joy, and to provide a safe, professional, friendly environment where individuals can find direction and resources to improve their lives; facilitated through establishment of therapeutic relationships; and involves the ventilation, validation and education process. It is holistic in that it factors and integrates the mind, body, spirit connection. It also is based on the individual “right to” and “responsibility for” their own thoughts, feelings and behaviors. Just as a lighthouse never steers the ship through the harbor, neither will we ever take responsibility for another person’s journey. We only will offer light to make the passage easier and safer. All things are as they are supposed to be. Nothing is as it seems to be. It is better. Together All Things are Possible. Simple is good. Quiet speaks loudly. Less can be more. There is good in everyone. There is a gift in all trauma. Gratefulness is a way of life. Nature can teach us most of what we need to know. Each person is responsible for their own path. We are responsible to be a light, as a beacon in the harbor but we are not responsible for steering the ship through the storm. There is ALWAYS hope. Having fun is a requirement to succeed. Being real and true to oneself is contagious. If you can’t find your own tribe, create one. Most people make good decisions once they are aware. Being is more important that doing. One person can make a difference. There is always more than two choices. Health should be affordable. Spirituality and religion are not the same. There is a higher power, and it is called love. There is no bad and evil only light and dark. There is mind body spirit connection, and all three need equal attention. Healing is possible. Living and breathing in the present moment is the key to the rest. And we believe that it is possible to not only to get through any storm but to find the gift not only on the other side of the storm, but in the storm itself. And we believe in the power and purpose of the collective energy of a group or a tribe. We provide education and information. We try to collaborate with other health care professionals (Eastern and Western, traditional and complimentary). We encourage and celebrate recovery, health, and individual responsibility. We try to lead by example. I will listen to and care for and nourish my body with good food, water, good movement, good rest and I will dance. I will express gratefulness, daily, I will laugh and provide joy to my 6 senses. I will create something daily. I will actively try to make a difference in someone’s life daily. I will forgive and love without judgment. I will let love guide my thoughts and my actions. I will be authentic and real, and be as honest as I am allowed to be, with love and kindness. I will get quiet and listen daily, and remember that I have ALL the answers inside of me. I will embrace the paradoxes of life and seek balance. I will live in the present but change the world. I will remember that I am never alone and that all things are as they are suppose to be; nothing is as it seems to be. It is better; And Together All Things are Possible. Copyright 2013 E.J. Healers. All rights reserved.
The function $f(x) = x^2/2$ has derivative $f'(x) = x$.
import sys sys.path.append('../../') import json import numpy as np import pandas as pd from sleep_control.traffic_emulator import MMPPEmulator from rl.mmpp import MMPP model = MMPP(n_components=2, n_iter=1, init_params='', verbose=False) model.startprob_ = np.array([.5, .5]) model.transmat_ = np.array([[0.5, 0.5], [0.5, 0.5]]) model.emissionrates_ = np.array([10.0, 0.0]) session_df = pd.DataFrame() head = pd.datetime(year=2014, month=9, day=4, hour=1) tail = pd.datetime(year=2014, month=9, day=4, hour=2) time_step = pd.Timedelta(seconds=10) te = MMPPEmulator(session_df=session_df, head_datetime=head, tail_datetime=tail, time_step=time_step, verbose=0, traffic_model=model) # while True: for i in range(0, 1000): print "{} to {}".format(head+i*time_step, head+(i+1)*time_step) t = te.generate_traffic() if t is not None: print t service_df = pd.DataFrame(columns=['sessionID', 'service_per_request_domain'], index=t.index) for idx in t.index: bytesSent_req_domain = json.loads(t.loc[idx, 'bytesSent_per_request_domain']) service_req_domain = {} for domain in bytesSent_req_domain: for reqID in bytesSent_req_domain[domain]: if domain not in service_req_domain: service_req_domain[domain] = {} service_req_domain[domain][int(reqID)] = 'serve' service_df.loc[idx, 'service_per_request_domain'] = json.dumps(service_req_domain) service_df.loc[idx, 'sessionID'] = t.loc[idx, 'sessionID'] else: service_df = pd.DataFrame(columns=['sessionID', 'service_per_request_domain'], index=pd.Index([])) print te.serve_and_reward(service_df=service_df)
C %W% %G% subroutine mdcreg C C THIS SUBROUTINE SOLVES THE DIFFERENTIAL EQUATIONS FOR C FOR THE CURRENT REGULATOR MODEL USED IN THE MULTI- C TERMINAL DC MODEL C include 'tspinc/params.inc' include 'tspinc/blkcom1.inc' include 'tspinc/blkcom2.inc' include 'tspinc/cntrl2.inc' include 'tspinc/ecsind.inc' include 'tspinc/ecstbj.inc' include 'tspinc/ldcc.inc' include 'tspinc/ectba.inc' include 'tspinc/mdcfil.inc' include 'tspinc/dcpul.inc' include 'tspinc/mdctbl.inc' include 'tspinc/param.inc' include 'tspinc/prt.inc' include 'tspinc/rk.inc' include 'tspinc/gamma.inc' include 'tspinc/dcmodd.inc' include 'tspinc/vrgov.inc' common /toler/divn, delang, twodt dimension drv(14) equivalence (erio, tab(164)), (eroo, tab(165)), (eron, tab(166)), & (eiio, tab(167)), (eioo, tab(168)), (eion, tab(169)), & (ectimc, tab(148)) equivalence (tmpdy, drv) equivalence (tmpy(1), nsubt), (tmpy(2), nstmx), (tmpy(3), timh), & (tmpy(4), timl), (tmpy(5), noith), (tmpy(6), noitl), & (tmpy(7), loopdc) include 'tspinc/spare1.inc' include 'tspinc/bname.inc' character*8 name timh = 500. timl = 0.0 noith = 500 noitl = 0 if (.not. (lppwr .gt. noith .or. & lppwr .lt. noitl .or. & to .gt. timh .or. to .lt. timl)) then if (.not. (nsubt .gt. nstmx .or. loopdc .gt. nstmx)) then if (keybrd(16) .ne. 0) then call skipln(3) write (outbuf, 10000) call prtout(1) endif 10000 format (40x, '---- SUBROUTINE MDCREG ----') endif endif lterm = 0 C 'INCM' POINTS TO THE ADDRESS OF THE DCA TABLE FOR THE TERMINAL C WITH CURRENT MARGIN . incm = nterm itdc = 1 sumio = 0.0 ind = 0 nbusp1 = nbus + 1 nbusp2 = nbus + 2 C C LOOP OVER ALL THE D C CONVERTERS C do while (.true.) ind = ind + 1 C C 'LTERM' COUNTS THE NUMBER OF TERMINALS THAT HAVE BEEN C PROCESSED. 'IND1' POINTS TO THE STARTING ADDRESS OF THE C TABLE FOR THIS TERMINAL. C lterm = lterm + 1 if (lterm .gt. nterm) goto 130 if (lterm .eq. nterm) ind = incm ind1 = lbt + ind call redecs(dca, idcb(ind1), msizea) C C MODCOD IS A CODE FOR THE TYPE OF MODULATION BEING USED C MODCOD = 1 IS LOW LEVEL WITH BRANCH POWER INPUT C MODCOD = 2 IS LOW LEVEL WITH BRANCH CURRENT INPUT C MODCOD = 3 IS HIGH LEVEL WITH BRANCH POWER INPUT C MODCOD = 4 IS HIGH LEVEL WITH BRANCH CURRENT INPUT C MODCOD = 5 IS GAMMA MODULATION C MODCOD = 6 IS DUAL FREQUENCY MODULATION C modcod = idca(78) if (modcod .ne. 0) imod = idca(79) C C VOLTAGE AND CURRENT TRANSDUCER LAG BLOCKS C twotv = twodt*dctv tvp = twotv + 1.0 tvm = twotv - 1.0 twotc = twodt*dctc tcp = twotc + 1.0 tcm = twotc - 1.0 edcan = (dcstor(3, ind)*tvm+vdcnew(ibus)+vdcsto(ibus))/tvp if (abs(edcan) .lt. 0.0001) edcan = 0.0001 if (dctv .eq. 0.) edcan = vdcnew(ibus) cdcn = currt(ind) fdin = (dcstor(4, ind)*tcm-csign*(cdcn+dcstor(9, ind)))/tcp if (dctc .eq. 0.) fdin = - csign*cdcn C C MODERI=1 FOR RECTIFIER, MODERI=2,3 FOR INVERTER *** C if (moderi .eq. 2) then if (lterm .ne. nterm) then incm = ind lterm = lterm - 1 goto 120 endif endif C C MODEPC = 1 CONSTANT POWER MODE, =2 CONSTANT CURRENT MODE C if (modepc .eq. 1) then cdesrd = csign*(pinit+dlpord)/edcan cdprim = cdesrd C C MODE CHANGE TO CONST. I FROM CONT P BELOW V CUT OFF C ADD HYSTERIS EFFECT SO THAT MODEL DOES NOT RETURN C TO CONSTANT I UNTIL VOLTAGE RISES TO 0.85 OF RATED VOLTA C if (idca(81) .gt. 0) then if (edcan .lt. (dca(89)*vsched)) then cdprim = csign*(pinit+dlpord)/(vsched) idca(81) = 2 endif if (idca(81) .eq. 2 .and. edcan .lt. (dca(95)*vsched)) then cdprim = csign*(pinit+dlpord)/(vsched) idca(81) = 2 else idca(81) = 1 endif C C DESIRED CURRENT (CDESRD) IS FILTERED THRU A TIME CONST C TT C twott = dca(96)*twodt ttp = twott + 1. ttm = twott - 1. cdesrd = (cdprim+dcfil(4, ldcc)+dcfil(3, ldcc)*ttm)/ttp dcfil(1, ldcc) = cdesrd dcfil(2, ldcc) = cdprim endif C C ADD HIGH LEVEL MODULATION SIGNAL IF PRESENT C if (modcod .eq. 3 .or. modcod .eq. 4 .or. modcod .eq. 6) & cdesrd = cdesrd + sighim(imod)/edcan endif if (modepc .eq. 2) then cdesrd = - csign*(cinit-dliord) C C ADD HIGH LEVEL MODULATION SIGNAL IF PRESENT C if (modcod .eq. 3 .or. modcod .eq. 4 .or. modcod .eq. 6) & cdesrd = cdesrd + sighim(imod)/vsched endif C C VOLTAGE-DEPENDENT CURRENT ORDER LIMIT C fipm = cmx C C THIS IS THE VDCOL FROM THE 'D ' CARD (SIMPLIFIED) C if (idca(80) .lt. 1) then fimin = 0.1*crated vsch25 = dca(77)*vsched if (edcan .lt. vsch25) fipm = fimin + (fipm-fimin)*edcan & /vsch25 C C PUT CURRENT ORDER THROUGH LIMITER. FIORD IS ORDERED CURR C fiord = amax1(amin1(fipm, cdesrd), fimin) else C C DETAILED VDCL CHARACTERISTICS FROM THE 'DC' CARD C vchv1 = dca(85)*vsched vchv2 = dca(86)*vsched fimin = dca(83)*crated fimy1 = dca(84)*crated if (edcan .lt. vchv1) then fipm = fimin + (fimy1-fimin)/vchv1*edcan elseif (edcan .ge. vchv1 .and. edcan .lt. vchv2) then fipm = fimy1 + (fipm-fimy1)/(vchv2-vchv1)*(edcan-vchv1) endif fiord = amax1(amin1(fipm, cdesrd), fimin) endif C C MODERI... 1=REC,2=INV WITH DELI,3=INV WITHOUT DELI C if (moderi .eq. 2) then C C INVERTER WITH CURRENT MARGIN C cmarg = delcm C C CURRENT AT THE INVT. WITH CURRENT MARGIN TAKES UP SLACK C ITS ORDER IS THE SUMMATION OF ALL OTHER TERMINAL ORDERS C fiord = sumio elseif (moderi .eq. 3) then C C INVERTER C cmarg = 0.0 C C OMIT ADDING IORD TO SLACK TERMINAL IF INV. IS DISCONNECT C if (cdcn .ge. 1.e-4) sumio = sumio - fiord else C C RECTIFIER C cmarg = 0.0 C C OMIT ADDING IORD TO SLACK TERMINAL IF THIS RECTFIER IS C DISCONNECTED . C if (cdcn .le. -1.0e-4) then sumio = sumio + fiord C C ADD LOW LEVEL MODULATION SIGNAL IF PRESENT C if (modcod .eq. 1 .or. modcod .eq. 2) fiord = fiord + & siglom(imod) endif cosm = cosmin goto 100 endif cosm = costop 100 eo = sqr2*eocdn*rpib3 C C COMPUTE UPPER LIMIT OF CURRENT AMPLIFIER C vc = 2.0*xc*fdin*rpib3 dmax = eo*(cosgam+cosm) C C IF ICCDE = 1 THIS IS CONSTANT EXTINCTION ANGLE CONTROL C IF ICCDE = 2 THIS IS CONSTANT BETA ANGLE CONTROL C iccde = idca(93) if (iccde .ne. 1) then if (moderi .eq. 1) then vcord = 2.*xc*rpib3*fdin else vcord = 2.*xc*rpib3*fiord endif dmax = dmax - vcord endif C C CURRENT REGULATOR INTEGRATION C v1n = fdin - fiord + cmarg + bias tt1 = twodt*dct1 ttp1 = tt1 + 1.0 ttm1 = tt1 - 1.0 tt2 = twodt*dct2 ttp2 = tt2 + 1.0 ttm2 = tt2 - 1.0 tt3 = twodt*dct3 ttp3 = tt3 + 1.0 ttm3 = tt3 - 1.0 v2n = (dcstor(6, ind)*ttm2+ckalph*(v1n+dcstor(5, ind)))/ttp2 v3n = (dcstor(7, ind)*ttm3+v2n*ttp1-dcstor(6, ind)*ttm1)/ttp3 C C TEST FOR LIMIT VIOLATION C if (v3n .gt. dmax) then v3n = dmax elseif (v3n .ge. 0.0) then goto 110 else v3n = 0.0 endif C C SET UP VARIABLES FOR LIMIT CONDITION C v2n = v3n v1n = v3n/ckalph C C CALCULATE COSINE ALPHA C 110 valph = v3n C C IF GAMMA MODULATION IS PRESENT GET MODULATED EXTINCTION AN C cosgmx = cosgam if (modcod .eq. 5) cosgmx = cos(gama(imod)) C C CHECK TO SEE IF A PLUSE IS BEING APPLIED TO THE EXTINCTION C if (idcp(1, ldcc) .eq. 1) then tnow = tsim + edt if (tnow .ge. dcp(1, ldcc) .and. tnow .le. dcp(2, ldcc)) then gam = acos(cosgam) + dcp(3, ldcc) cosgmx = cos(gam) endif endif C C CHECK TO SEE IF WE ARE PROCESSING THE CURRENT MARGIN TERMINAL AN C HENCE MUST ALTER CHARACTERISTICS FOR CONSTANT SLOPE . C fbias = 0. C C RECTIFIERS USE THE ACTURAL CURRENT TO CALULATE VCORD C INVERTERS USE THE ORDERED CURRENT FOR NUMERICAL STABILIY C if (iccde .ne. 2) then if (moderi .eq. 2) then if (vc .gt. v3n) valph = vc fiordp = eo*(cosgap-cosgmx)/(2.*rpib3*xc) + fiord vcord = 2.*xc*rpib3*fiordp if (vcord .gt. valph) valph = vcord fbias = - cosgap + cosgmx endif endif eo1 = eo if (iccde .eq. 2) valph = valph + vcord dca(61) = valph if (eo1 .lt. 0.0001) eo1 = 0.0001 cosan = valph/eo1 - cosgmx + fbias C C CONSTANT DC VOLTAGE OPERATION C if (idca(82) .gt. 0) then if (moderi .eq. 1) then cosan1 = dca(91) + fdin*(xc*rpib3+dca(92)) + twovd/2. cosan1 = cosan1/eo cosan = amin1(cosan, cosan1) else cosan1 = - dca(91) + fdin*(xc*rpib3+dca(92)) + twovd/2. cosan1 = cosan1/eo cosan = amax1(cosan, cosan1) endif endif C C LIMIT COSINE OF FIRING ANGLE TO ABS. VALUE .LT. 1 C if (cosan .lt. -1.0) cosan = - 1.0 if (cosan .gt. 1.0) cosan = 1.0 C C CHECK FOR VALVE BLOCKING C if (idcf(ind) .eq. 2 .or. idcf(ind) .eq. 4) cosan = cosblk if (abs(cosan-dcstor(12, ind)) .gt. 0.0001) itdc = 2 dcstor(12, ind) = cosan C C COMPUTE THE RIGHT-HAND-SIDE IN CASE OF ANOTHER ITERATION C if (.not. (idcf(ind) .eq. 2 .or. idcf(ind) .eq. 3)) ymtrx(ibus, & nbusp1) = (biim+csign*f135*eocn*cosan)*yiop + ymtrx(ibus, & nbusp1) call ritecs(dca(1), idcb(ind1), msizea) C C DEBUG PRINT OUT ONLY AT SELECTED INTERVALS C if (.not. (lppwr .gt. noith .or. lppwr .lt. noitl .or. to .gt. & timh .or. to .lt. timl)) then if (.not. (nsubt .gt. nstmx .or. loopdc .gt. nstmx)) then if (keybrd(16) .ne. 0) then write (outbuf, 10010) itdc, ibus call prtout(1) write (outbuf, 10020) cosan, eocn, fiord, ymtrx(ibus, & nbusp1), v1n, v2n, v3n, v4n, dmax, fdin call prtout(1) endif 10010 format ( & '0S667 ITDC,IBUS,COSAN,EOCN,FIORD,YMTRX,V1-4,DMAX,FDIN', & 2i10) 10020 format (1x, 10e13.5) endif endif C C LOOP BACK FOR ANOTHER TERMINAL C 120 continue enddo 130 return end
lemma poly_div_diff_left: "(x - y) div z = x div z - y div z" for x y z :: "'a::field poly"
#!/usr/bin/env python3 # Author: Cunren Liang # Copyright 2021 import os import copy import argparse import numpy as np import isce import isceobj from isceobj.Constants import SPEED_OF_LIGHT from isceobj.TopsProc.runIon import computeIonosphere from isceobj.Alos2Proc.runIonFilt import reformatMaskedAreas from Stack import ionParam def createParser(): parser = argparse.ArgumentParser(description='compute ionosphere using lower and upper band interferograms') parser.add_argument('-l', '--lower', dest='lower', type=str, required=True, help='lower band interferogram') parser.add_argument('-u', '--upper', dest='upper', type=str, required=True, help='upper band interferogram') parser.add_argument('-c', '--coherence', dest='coherence', type=str, required=True, help='input coherence') parser.add_argument('-i', '--ionosphere', dest='ionosphere', type=str, required=True, help='output ionosphere') parser.add_argument('-o', '--coherence_output', dest='coherence_output', type=str, required=True, help='output coherence file name. simply copy input coherence') parser.add_argument('-m', '--masked_areas', dest='masked_areas', type=int, nargs='+', action='append', default=None, help='This is a 2-d list. Each element in the 2-D list is a four-element list: [firstLine, lastLine, firstColumn, lastColumn], with line/column numbers starting with 1. If one of the four elements is specified with -1, the program will use firstLine/lastLine/firstColumn/lastColumn instead. e.g. two areas masked out: --masked_areas 10 20 10 20 --masked_areas 110 120 110 120') #parser.add_argument('-m', '--masked_areas', dest='masked_areas', type=int, nargs='+', default=None, # help='This is a 2-d list. Each element in the 2-D list is a four-element list: [firstLine, lastLine, firstColumn, lastColumn], with line/column numbers starting with 1. If one of the four elements is specified with -1, the program will use firstLine/lastLine/firstColumn/lastColumn instead. e.g. two areas masked out: --masked_areas 10 20 10 20 110 120 110 120') return parser def cmdLineParse(iargs = None): parser = createParser() return parser.parse_args(args=iargs) def main(iargs=None): ''' ''' inps = cmdLineParse(iargs) # #convert 1-d list to 2-d list # if len(inps.masked_areas) % 4 != 0: # raise Exception('each maksed area must have four elements') # else: # masked_areas = [] # n = np.int32(len(inps.masked_areas)/4) # for i in range(n): # masked_areas.append([inps.masked_areas[i*4+0], inps.masked_areas[i*4+1], inps.masked_areas[i*4+2], inps.masked_areas[i*4+3]]) # inps.masked_areas = masked_areas ################################### #SET PARAMETERS HERE #THESE SHOULD BE GOOD ENOUGH, NO NEED TO SET IN setup(self) corThresholdAdj = 0.85 ################################### print('computing ionosphere') #get files lowerUnwfile = inps.lower upperUnwfile = inps.upper corfile = inps.coherence #use image size from lower unwrapped interferogram img = isceobj.createImage() img.load(lowerUnwfile + '.xml') width = img.width length = img.length lowerUnw = (np.fromfile(lowerUnwfile, dtype=np.float32).reshape(length*2, width))[1:length*2:2, :] upperUnw = (np.fromfile(upperUnwfile, dtype=np.float32).reshape(length*2, width))[1:length*2:2, :] #lowerAmp = (np.fromfile(lowerUnwfile, dtype=np.float32).reshape(length*2, width))[0:length*2:2, :] #upperAmp = (np.fromfile(upperUnwfile, dtype=np.float32).reshape(length*2, width))[0:length*2:2, :] cor = (np.fromfile(corfile, dtype=np.float32).reshape(length*2, width))[1:length*2:2, :] #amp = np.sqrt(lowerAmp**2+upperAmp**2) amp = (np.fromfile(corfile, dtype=np.float32).reshape(length*2, width))[0:length*2:2, :] #masked out user-specified areas if inps.masked_areas != None: maskedAreas = reformatMaskedAreas(inps.masked_areas, length, width) for area in maskedAreas: lowerUnw[area[0]:area[1], area[2]:area[3]] = 0 upperUnw[area[0]:area[1], area[2]:area[3]] = 0 cor[area[0]:area[1], area[2]:area[3]] = 0 ionParamObj=ionParam() ionParamObj.configure() #compute ionosphere fl = SPEED_OF_LIGHT / ionParamObj.radarWavelengthLower fu = SPEED_OF_LIGHT / ionParamObj.radarWavelengthUpper adjFlag = 1 ionos = computeIonosphere(lowerUnw, upperUnw, cor, fl, fu, adjFlag, corThresholdAdj, 0) #dump ionosphere outFilename = inps.ionosphere os.makedirs(os.path.dirname(inps.ionosphere), exist_ok=True) ion = np.zeros((length*2, width), dtype=np.float32) ion[0:length*2:2, :] = amp ion[1:length*2:2, :] = ionos ion.astype(np.float32).tofile(outFilename) img.filename = outFilename img.extraFilename = outFilename + '.vrt' img.renderHdr() #dump coherence outFilename = inps.coherence_output os.makedirs(os.path.dirname(inps.coherence_output), exist_ok=True) ion[1:length*2:2, :] = cor ion.astype(np.float32).tofile(outFilename) img.filename = outFilename img.extraFilename = outFilename + '.vrt' img.renderHdr() if __name__ == '__main__': ''' Main driver. ''' # Main Driver main()
module Integration.Riemann %access private ||| Computes the left Riemann sum of a function. ||| ||| @f the function ||| @d the delta x value ||| @a the left limit of the interval ||| @n the number of subintervals export lrs : (f : Double -> Double) -> (d : Double) -> (a : Double) -> (n : Nat) -> Double lrs f d s Z = 0 lrs f d a (S n') = d * (lrs' n') where lrs' : (i : Nat) -> Double lrs' Z = f a lrs' i@(S i') = (f (a + ((cast i) * d))) + (lrs' i') ||| Computes the right Riemann sum of a function. ||| ||| @f the function ||| @d the delta x value ||| @a the left limit of the interval ||| @n the number of subintervals export rrs : (f : Double -> Double) -> (d : Double) -> (a : Double) -> (n : Nat) -> Double rrs f d a Z = 0 rrs f d a n@(S n') = d * (rrs' n) where rrs' : (i : Nat) -> Double rrs' Z = 0 rrs' i@(S i') = (f (a + ((cast i) * d))) + (rrs' i') ||| Approximates the integral of a function using the trapezoidal rule. ||| ||| @f the function ||| @d the delta x value ||| @a the left limit of the interval ||| @n the number of subintervals export trapz : (f : Double -> Double) -> (d : Double) -> (a : Double) -> (n : Nat) -> Double trapz f d a n = ((lrs f d a n) + (rrs f d a n)) / 2
For many manufacturers, compressed air is often extremely expensive. On average, compressed air costs can consist of up to 50% of the total electric expenditure of a large manufacturing plant – adding up to millions of dollars per year. Our fundamental approach at Bay Controls is to work with you to reduce your compressed air system energy usage and, in turn, bring you predictable and reliable energy savings of 10-13%. This approach is based on several core strategies. Our controllers use powerful microprocessors to collect and analyze critical compressor monitoring points up to 100 times every second. Through this industry-leading combination of power and data, we can recognize and react to even the smallest changes in air system conditions faster than any other systems out there. As a result, Bay controllers consistently maintain pressure within a narrow 1-2 psi band and enable pressure set points to be lowered while still reliably maintaining the minimum required system pressure. Lowered pressure points bring about immediate and substantial savings. According to the Department of Energy, the average compressed air system loses between 10-30% of its air due to leaks. Our focus is at Bay Controls to reduce potential leaks and translate that into lowered costs. Since our controllers enable lower pressure set points with precise pressure control bands, they also drastically reduce the amount of lost and leaked air. Many control systems don’t have the ability to automatically start and stop as plant air demand changes. The result? Air compressors often run continuously and unloaded for long periods of times. Bay controllers allow you to schedule your air when you need it, matching your air supply to your demand based on your plant’s production. You can reduce unnecessary run time and save energy overall. As an energy solutions company, Bay Controls is often included in the custom incentive programs that investor-owned utilities (IOUs) offer their customers. IOUs are focused on reducing energy consumption, and our systems and solutions are the perfect way to achieve these goals. If you’re considering doing any energy projects at your facility and are eligible for a custom incentive program from your IOU provider, we can offset the project costs and have a faster ROI on any investment(s) you make. Would you like to learn how you can save up to 10-13% on your total energy spend? Schedule a 5-minute discovery call with the Bay Controls team!
{-# OPTIONS --safe #-} module Cubical.Data.SumFin.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_) open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Unit open import Cubical.Data.Bool open import Cubical.Data.Nat open import Cubical.Data.Nat.Order import Cubical.Data.Fin as Fin import Cubical.Data.Fin.LehmerCode as LehmerCode open import Cubical.Data.SumFin.Base as SumFin open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.HITs.PropositionalTruncation as Prop open import Cubical.Relation.Nullary private variable ℓ : Level k : ℕ SumFin→Fin : Fin k → Fin.Fin k SumFin→Fin = SumFin.elim (λ {k} _ → Fin.Fin k) Fin.fzero Fin.fsuc Fin→SumFin : Fin.Fin k → Fin k Fin→SumFin = Fin.elim (λ {k} _ → Fin k) fzero fsuc Fin→SumFin-fsuc : (fk : Fin.Fin k) → Fin→SumFin (Fin.fsuc fk) ≡ fsuc (Fin→SumFin fk) Fin→SumFin-fsuc = Fin.elim-fsuc (λ {k} _ → Fin k) fzero fsuc SumFin→Fin→SumFin : (fk : Fin k) → Fin→SumFin (SumFin→Fin fk) ≡ fk SumFin→Fin→SumFin = SumFin.elim (λ fk → Fin→SumFin (SumFin→Fin fk) ≡ fk) refl λ {k} {fk} eq → Fin→SumFin (Fin.fsuc (SumFin→Fin fk)) ≡⟨ Fin→SumFin-fsuc (SumFin→Fin fk) ⟩ fsuc (Fin→SumFin (SumFin→Fin fk)) ≡⟨ cong fsuc eq ⟩ fsuc fk ∎ Fin→SumFin→Fin : (fk : Fin.Fin k) → SumFin→Fin (Fin→SumFin fk) ≡ fk Fin→SumFin→Fin = Fin.elim (λ fk → SumFin→Fin (Fin→SumFin fk) ≡ fk) refl λ {k} {fk} eq → SumFin→Fin (Fin→SumFin (Fin.fsuc fk)) ≡⟨ cong SumFin→Fin (Fin→SumFin-fsuc fk) ⟩ Fin.fsuc (SumFin→Fin (Fin→SumFin fk)) ≡⟨ cong Fin.fsuc eq ⟩ Fin.fsuc fk ∎ SumFin≃Fin : ∀ k → Fin k ≃ Fin.Fin k SumFin≃Fin _ = isoToEquiv (iso SumFin→Fin Fin→SumFin Fin→SumFin→Fin SumFin→Fin→SumFin) SumFin≡Fin : ∀ k → Fin k ≡ Fin.Fin k SumFin≡Fin k = ua (SumFin≃Fin k) enum : (n : ℕ)(p : n < k) → Fin k enum n p = Fin→SumFin (n , p) enumElim : (P : Fin k → Type ℓ) → ((n : ℕ)(p : n < k) → P (enum _ p)) → (i : Fin k) → P i enumElim P f i = subst P (SumFin→Fin→SumFin i) (f (SumFin→Fin i .fst) (SumFin→Fin i .snd)) -- Closure properties of SumFin under type constructors SumFin⊎≃ : (m n : ℕ) → (Fin m ⊎ Fin n) ≃ (Fin (m + n)) SumFin⊎≃ 0 n = ⊎-swap-≃ ⋆ ⊎-⊥-≃ SumFin⊎≃ (suc m) n = ⊎-assoc-≃ ⋆ ⊎-equiv (idEquiv ⊤) (SumFin⊎≃ m n) SumFinΣ≃ : (n : ℕ)(f : Fin n → ℕ) → (Σ (Fin n) (λ x → Fin (f x))) ≃ (Fin (totalSum f)) SumFinΣ≃ 0 f = ΣEmpty _ SumFinΣ≃ (suc n) f = Σ⊎≃ ⋆ ⊎-equiv (ΣUnit (λ tt → Fin (f (inl tt)))) (SumFinΣ≃ n (λ x → f (inr x))) ⋆ SumFin⊎≃ (f (inl tt)) (totalSum (λ x → f (inr x))) SumFin×≃ : (m n : ℕ) → (Fin m × Fin n) ≃ (Fin (m · n)) SumFin×≃ m n = SumFinΣ≃ m (λ _ → n) ⋆ pathToEquiv (λ i → Fin (totalSumConst {m = m} n i)) SumFinΠ≃ : (n : ℕ)(f : Fin n → ℕ) → ((x : Fin n) → Fin (f x)) ≃ (Fin (totalProd f)) SumFinΠ≃ 0 _ = isContr→≃Unit (isContrΠ⊥) ⋆ invEquiv (⊎-⊥-≃) SumFinΠ≃ (suc n) f = Π⊎≃ ⋆ Σ-cong-equiv (ΠUnit (λ tt → Fin (f (inl tt)))) (λ _ → SumFinΠ≃ n (λ x → f (inr x))) ⋆ SumFin×≃ (f (inl tt)) (totalProd (λ x → f (inr x))) isNotZero : ℕ → ℕ isNotZero 0 = 0 isNotZero (suc n) = 1 SumFin∥∥≃ : (n : ℕ) → ∥ Fin n ∥ ≃ Fin (isNotZero n) SumFin∥∥≃ 0 = propTruncIdempotent≃ (isProp⊥) SumFin∥∥≃ (suc n) = isContr→≃Unit (inhProp→isContr ∣ inl tt ∣ isPropPropTrunc) ⋆ isContr→≃Unit (isContrUnit) ⋆ invEquiv (⊎-⊥-≃) ℕ→Bool : ℕ → Bool ℕ→Bool 0 = false ℕ→Bool (suc n) = true SumFin∥∥DecProp : (n : ℕ) → ∥ Fin n ∥ ≃ Bool→Type (ℕ→Bool n) SumFin∥∥DecProp 0 = uninhabEquiv (Prop.rec isProp⊥ ⊥.rec) ⊥.rec SumFin∥∥DecProp (suc n) = isContr→≃Unit (inhProp→isContr ∣ inl tt ∣ isPropPropTrunc) -- negation of SumFin SumFin¬ : (n : ℕ) → (¬ Fin n) ≃ Bool→Type (isZero n) SumFin¬ 0 = isContr→≃Unit isContr⊥→A SumFin¬ (suc n) = uninhabEquiv (λ f → f fzero) ⊥.rec -- SumFin 1 is equivalent to unit Fin1≃Unit : Fin 1 ≃ Unit Fin1≃Unit = ⊎-⊥-≃ isContrSumFin1 : isContr (Fin 1) isContrSumFin1 = isOfHLevelRespectEquiv 0 (invEquiv Fin1≃Unit) isContrUnit -- SumFin 2 is equivalent to Bool SumFin2≃Bool : Fin 2 ≃ Bool SumFin2≃Bool = ⊎-equiv (idEquiv _) ⊎-⊥-≃ ⋆ isoToEquiv Iso-⊤⊎⊤-Bool -- decidable predicate over SumFin SumFinℙ≃ : (n : ℕ) → (Fin n → Bool) ≃ Fin (2 ^ n) SumFinℙ≃ 0 = isContr→≃Unit (isContrΠ⊥) ⋆ invEquiv (⊎-⊥-≃) SumFinℙ≃ (suc n) = Π⊎≃ ⋆ Σ-cong-equiv (UnitToType≃ Bool ⋆ invEquiv SumFin2≃Bool) (λ _ → SumFinℙ≃ n) ⋆ SumFin×≃ 2 (2 ^ n) -- decidable subsets of SumFin Bool→ℕ : Bool → ℕ Bool→ℕ true = 1 Bool→ℕ false = 0 trueCount : {n : ℕ}(f : Fin n → Bool) → ℕ trueCount {n = 0} _ = 0 trueCount {n = suc n} f = Bool→ℕ (f (inl tt)) + (trueCount (f ∘ inr)) SumFinDec⊎≃ : (n : ℕ)(t : Bool) → (Bool→Type t ⊎ Fin n) ≃ (Fin (Bool→ℕ t + n)) SumFinDec⊎≃ _ true = idEquiv _ SumFinDec⊎≃ _ false = ⊎-swap-≃ ⋆ ⊎-⊥-≃ SumFinSub≃ : (n : ℕ)(f : Fin n → Bool) → Σ _ (Bool→Type ∘ f) ≃ Fin (trueCount f) SumFinSub≃ 0 _ = ΣEmpty _ SumFinSub≃ (suc n) f = Σ⊎≃ ⋆ ⊎-equiv (ΣUnit (Bool→Type ∘ f ∘ inl)) (SumFinSub≃ n (f ∘ inr)) ⋆ SumFinDec⊎≃ _ (f (inl tt)) -- decidable quantifier trueForSome : (n : ℕ)(f : Fin n → Bool) → Bool trueForSome 0 _ = false trueForSome (suc n) f = f (inl tt) or trueForSome n (f ∘ inr) trueForAll : (n : ℕ)(f : Fin n → Bool) → Bool trueForAll 0 _ = true trueForAll (suc n) f = f (inl tt) and trueForAll n (f ∘ inr) SumFin∃→ : (n : ℕ)(f : Fin n → Bool) → Σ _ (Bool→Type ∘ f) → Bool→Type (trueForSome n f) SumFin∃→ 0 _ = ΣEmpty _ .fst SumFin∃→ (suc n) f = Bool→Type⊎' _ _ ∘ map-⊎ (ΣUnit (Bool→Type ∘ f ∘ inl) .fst) (SumFin∃→ n (f ∘ inr)) ∘ Σ⊎≃ .fst SumFin∃← : (n : ℕ)(f : Fin n → Bool) → Bool→Type (trueForSome n f) → Σ _ (Bool→Type ∘ f) SumFin∃← 0 _ = ⊥.rec SumFin∃← (suc n) f = invEq Σ⊎≃ ∘ map-⊎ (invEq (ΣUnit (Bool→Type ∘ f ∘ inl))) (SumFin∃← n (f ∘ inr)) ∘ Bool→Type⊎ _ _ SumFin∃≃ : (n : ℕ)(f : Fin n → Bool) → ∥ Σ (Fin n) (Bool→Type ∘ f) ∥ ≃ Bool→Type (trueForSome n f) SumFin∃≃ n f = propBiimpl→Equiv isPropPropTrunc isPropBool→Type (Prop.rec isPropBool→Type (SumFin∃→ n f)) (∣_∣ ∘ SumFin∃← n f) SumFin∀≃ : (n : ℕ)(f : Fin n → Bool) → ((x : Fin n) → Bool→Type (f x)) ≃ Bool→Type (trueForAll n f) SumFin∀≃ 0 _ = isContr→≃Unit (isContrΠ⊥) SumFin∀≃ (suc n) f = Π⊎≃ ⋆ Σ-cong-equiv (ΠUnit (Bool→Type ∘ f ∘ inl)) (λ _ → SumFin∀≃ n (f ∘ inr)) ⋆ Bool→Type×≃ _ _ -- internal equality SumFin≡ : (n : ℕ) → (a b : Fin n) → Bool SumFin≡ 0 _ _ = true SumFin≡ (suc n) (inl tt) (inl tt) = true SumFin≡ (suc n) (inl tt) (inr y) = false SumFin≡ (suc n) (inr x) (inl tt) = false SumFin≡ (suc n) (inr x) (inr y) = SumFin≡ n x y isSetSumFin : (n : ℕ)→ isSet (Fin n) isSetSumFin 0 = isProp→isSet isProp⊥ isSetSumFin (suc n) = isSet⊎ (isProp→isSet isPropUnit) (isSetSumFin n) SumFin≡≃ : (n : ℕ) → (a b : Fin n) → (a ≡ b) ≃ Bool→Type (SumFin≡ n a b) SumFin≡≃ 0 _ _ = isContr→≃Unit (isProp→isContrPath isProp⊥ _ _) SumFin≡≃ (suc n) (inl tt) (inl tt) = isContr→≃Unit (inhProp→isContr refl (isSetSumFin _ _ _)) SumFin≡≃ (suc n) (inl tt) (inr y) = invEquiv (⊎Path.Cover≃Path _ _) ⋆ uninhabEquiv ⊥.rec* ⊥.rec SumFin≡≃ (suc n) (inr x) (inl tt) = invEquiv (⊎Path.Cover≃Path _ _) ⋆ uninhabEquiv ⊥.rec* ⊥.rec SumFin≡≃ (suc n) (inr x) (inr y) = invEquiv (_ , isEmbedding-inr x y) ⋆ SumFin≡≃ n x y -- propositional truncation of Fin -- decidability of Fin DecFin : (n : ℕ) → Dec (Fin n) DecFin 0 = no (idfun _) DecFin (suc n) = yes fzero -- propositional truncation of Fin Dec∥Fin∥ : (n : ℕ) → Dec ∥ Fin n ∥ Dec∥Fin∥ n = Dec∥∥ (DecFin n) -- some properties about cardinality fzero≠fone : {n : ℕ} → ¬ (fzero ≡ fsuc fzero) fzero≠fone {n = n} = SumFin≡≃ (suc (suc n)) fzero (fsuc fzero) .fst Fin>0→isInhab : (n : ℕ) → 0 < n → Fin n Fin>0→isInhab 0 p = ⊥.rec (¬-<-zero p) Fin>0→isInhab (suc n) p = fzero Fin>1→hasNonEqualTerm : (n : ℕ) → 1 < n → Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] ¬ i ≡ j Fin>1→hasNonEqualTerm 0 p = ⊥.rec (snotz (≤0→≡0 p)) Fin>1→hasNonEqualTerm 1 p = ⊥.rec (snotz (≤0→≡0 (pred-≤-pred p))) Fin>1→hasNonEqualTerm (suc (suc n)) _ = fzero , fsuc fzero , fzero≠fone isEmpty→Fin≡0 : (n : ℕ) → ¬ Fin n → 0 ≡ n isEmpty→Fin≡0 0 _ = refl isEmpty→Fin≡0 (suc n) p = ⊥.rec (p fzero) isInhab→Fin>0 : (n : ℕ) → Fin n → 0 < n isInhab→Fin>0 0 i = ⊥.rec i isInhab→Fin>0 (suc n) _ = suc-≤-suc zero-≤ hasNonEqualTerm→Fin>1 : (n : ℕ) → (i j : Fin n) → ¬ i ≡ j → 1 < n hasNonEqualTerm→Fin>1 0 i _ _ = ⊥.rec i hasNonEqualTerm→Fin>1 1 i j p = ⊥.rec (p (isContr→isProp isContrSumFin1 i j)) hasNonEqualTerm→Fin>1 (suc (suc n)) _ _ _ = suc-≤-suc (suc-≤-suc zero-≤) Fin≤1→isProp : (n : ℕ) → n ≤ 1 → isProp (Fin n) Fin≤1→isProp 0 _ = isProp⊥ Fin≤1→isProp 1 _ = isContr→isProp isContrSumFin1 Fin≤1→isProp (suc (suc n)) p = ⊥.rec (¬-<-zero (pred-≤-pred p)) isProp→Fin≤1 : (n : ℕ) → isProp (Fin n) → n ≤ 1 isProp→Fin≤1 0 _ = ≤-solver 0 1 isProp→Fin≤1 1 _ = ≤-solver 1 1 isProp→Fin≤1 (suc (suc n)) p = ⊥.rec (fzero≠fone (p fzero (fsuc fzero))) -- automorphisms of SumFin SumFin≃≃ : (n : ℕ) → (Fin n ≃ Fin n) ≃ Fin (LehmerCode.factorial n) SumFin≃≃ _ = equivComp (SumFin≃Fin _) (SumFin≃Fin _) ⋆ LehmerCode.lehmerEquiv ⋆ LehmerCode.lehmerFinEquiv ⋆ invEquiv (SumFin≃Fin _)
import polyhedral_lattice.basic import normed_group.pseudo_normed_group import pseudo_normed_group.profinitely_filtered noncomputable theory open_locale nnreal big_operators namespace polyhedral_lattice open pseudo_normed_group normed_add_comm_group variables (Λ : Type*) [polyhedral_lattice Λ] lemma filtration_finite (ε : ℝ≥0) : (filtration Λ ε).finite := begin classical, obtain ⟨ι, _ι_inst, l, hl, hl'⟩ := polyhedral_lattice.polyhedral Λ, resetI, let n : ι → ℕ := λ i, ⌈(ε / ∥l i∥₊ : ℝ)⌉.nat_abs + 1, let S := finset.univ.pi (λ i, finset.range (n i)), let S' : finset Λ := S.image (λ x, ∑ i, x i (finset.mem_univ _) • l i), apply S'.finite_to_set.subset, intros l₀ H, obtain ⟨c, h1, h2⟩ := hl.generates_nnnorm l₀, simp only [S', set.mem_image, finset.mem_univ, finset.mem_pi, forall_true_left, finset.mem_range, finset.mem_coe, finset.coe_image], refine ⟨λ i _, c i, _, h1.symm⟩, intro i, apply nat.succ_le_succ, contrapose! H, simp only [not_le, seminormed_add_comm_group.mem_filtration_iff, h2], have aux : 0 < ∥l i∥₊, { rw [zero_lt_iff, ne.def, nnnorm_eq_zero], exact hl' i }, calc ε ≤ (⌈(ε / ∥l i∥₊ : ℝ)⌉.nat_abs : ℝ≥0) * ∥l i∥₊ : _ ... < ↑(c i) * ∥l i∥₊ : _ ... ≤ ∑ (i : ι), ↑(c i) * ∥l i∥₊ : _, { rw [← nnreal.div_le_iff aux.ne', ← nnreal.coe_le_coe], simp only [coe_nnnorm, nnreal.coe_nat_abs, nnreal.coe_div], refine (int.le_ceil _).trans (le_abs_self _), }, { rw mul_lt_mul_right aux, { exact_mod_cast H }, }, { refine @finset.single_le_sum _ _ _ _ _ _ i (finset.mem_univ _), exact λ _ _, zero_le', } end open metric seminormed_add_comm_group instance : discrete_topology Λ := discrete_topology_of_open_singleton_zero $ begin classical, have aux := filtration_finite Λ 1, let s := aux.to_finset, let s₀ := s.erase 0, by_cases hs₀ : s₀.nonempty, { let ε : ℝ≥0 := finset.min' (s₀.image $ nnnorm) (hs₀.image _), obtain ⟨a, has₀, ha⟩ : ∃ a ∈ s₀, ∥a∥₊ = ε, { rw ← finset.mem_image, apply finset.min'_mem }, have H : 0 < ∥a∥ := by simpa only [norm_pos_iff] using finset.ne_of_mem_erase has₀, have h0ε : 0 < ε, { simpa only [← ha] }, have hε1 : ε ≤ 1, { replace has₀ := finset.mem_of_mem_erase has₀, simp only [set.finite.mem_to_finset, mem_filtration_iff] at has₀, rwa [← ha] }, suffices : ({0} : set Λ) = ball (0:Λ) ε, { rw this, apply is_open_ball }, ext, simp only [metric.mem_ball, set.mem_singleton_iff, dist_zero_right], split, { rintro rfl, rw norm_zero, exact_mod_cast h0ε }, intro h, have hx : x ∈ s, { simp only [set.finite.mem_to_finset, mem_filtration_iff], exact le_of_lt (lt_of_lt_of_le h hε1) }, by_contra hx0, replace hx := finset.mem_erase_of_ne_of_mem hx0 hx, have := finset.min'_le (s₀.image $ nnnorm), refine not_lt.2 (this ∥x∥₊ _) h, simp only [exists_prop, set.finite.mem_to_finset, finset.mem_image], use ⟨x, ⟨hx, rfl⟩⟩ }, { suffices : ({0} : set Λ) = ball (0:Λ) 1, { rw this, apply is_open_ball }, ext, simp only [metric.mem_ball, set.mem_singleton_iff, dist_zero_right], split, { rintro rfl, rw norm_zero, exact zero_lt_one }, intro h, contrapose! hs₀, refine ⟨x, _⟩, simp only [set.finite.mem_to_finset, finset.mem_erase, mem_filtration_iff, nnreal.coe_one], exact ⟨hs₀, h.le⟩ } end instance filtration_fintype (c : ℝ≥0) : fintype (filtration Λ c) := (filtration_finite Λ c).fintype -- we don't need this instance : profinitely_filtered_pseudo_normed_group Λ := { compact := λ c, by apply_instance, -- compact of finite continuous_add' := λ _ _, continuous_of_discrete_topology, continuous_neg' := λ _, continuous_of_discrete_topology, continuous_cast_le := λ _ _ _, continuous_of_discrete_topology, .. (show pseudo_normed_group Λ, by apply_instance) } end polyhedral_lattice
\long\def\DBFRONT{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Histogram Template Library UG Front matter % % % % Front Material: Title page, % % Copyright Notice % % Preliminary Remarks % % Table of Contents % % EPS file : cern15.eps, cnastit.eps % % % % Editor: Michel Goossens / IT-ASD % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Tile page % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\Ptitle##1{\special{ps: /Printstring (##1) def} \epsfbox{cnastit.eps}} \begin{titlepage} \vspace*{-23mm} \includegraphics[height=30mm]{cern15.eps}% \hfill \raisebox{10mm}{\Large\bf CERN Computer Program Library Documentation} \hfill\mbox{} \begin{center} \mbox{}\\[10mm] \mbox{\Ptitle{HTL}}\\[2cm] {\Huge Histogram Template Library}\\[1cm] {\LARGE User Guide}\\[3cm] {\Large Applications for Physics \& Infrastructure Group}\\[5mm] {\Large Information Technologies Division}\\[2cm] {\Large CERN Geneva, Switzerland} \end{center} \end{titlepage} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright page % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \thispagestyle{empty} \framebox[\textwidth][t]{\hfill\begin{minipage}{0.96\textwidth}% \vspace*{3mm}\begin{center}Copyright Notice\end{center} \parskip\baselineskip \textbf{Histogram Template Library} CERN Program Library Documentation \copyright{} Copyright CERN, Geneva 1998, 1999, 2000 Copyright and any other appropriate legal protection of these computer programs and associated documentation reserved in all countries of the world by their respective copyright holders. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but \textbf{without any warranty}; without even the implied warranty of \textbf{merchantability} or \textbf{fitness for a particular purpose}. See the GNU General Public License (\url{http://www.gnu.org/copyleft/gpl.html}) for more details. The software (source and documentation) can be downloaded from the URL \url{http://cern.ch/...}. \vspace*{2mm} \end{minipage}\hfill}%end of minipage in framebox \vspace{6mm} \textbf{Trademark notice: All trademarks appearing in this guide are acknowledged as such.} \bigskip {\small The source of this document is marked up in \textsc{xml} using the DocBook \textsc{dtd}. It is translated with an \textsc{xsl} style sheet and James Clark's \texttt{xt} Java program into and \textsc{html} and typeset with \LaTeX{} source and the \texttt{docbook} class file developed at CERN to generate a printable PostScript file.} \section*{Acknowledgements} HTL has benefited from the suggestions, advice and help of many individuals. In particular the major part of HTL was written during 1998 by Savrak Sar, who worked for sixteen months at CERN as a French \emph{coop\'erant}. A special mention should be given to Yemi Adesanya and Jacub Moscicki for the existing HistOOgrams package and the templated prototype; Dirk D\"ullman and Marcin Nowak for help with Objectivity; Vincenzo Innocente for his version of templated histograms; Olivier Couet and Michel Goossens for general support. \vfill \begin{flushleft} \begin{tabular}{@{}l@{\quad}l@{\quad}l} \emph{Contact Person}:& Dino Ferrero Merlino /IT & \texttt{[email protected]}\\ \emph{Documentation}: & Michel Goossens /IT & \texttt{[email protected]} \end{tabular}\\[5mm] \emph{Edition -- April 2000} \hfill \footnotesize Printed \today \end{flushleft} \newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Introductory material % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagenumbering{roman} \setcounter{page}{1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Tables of contents ... % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \tableofcontents %\newpage %\listoffigures %\listoftables \cleardoublepage % ==================== Body of text ============================== \pagenumbering{arabic} \setcounter{page}{1} } \endinput
(* TLC in Coq * * Module: tlc.utility.function * Purpose: Contains helpers for functional programming. *) Require Import mathcomp.ssreflect.ssreflect. Require Import mathcomp.ssreflect.ssrnat. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. (* Iterate f over x n times *) Fixpoint iter A (f : A -> A) (x : A) n := match n with | 0 => x | n.+1 => iter f (f x) n end.